summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/NPTest.cache (renamed from plugins/t/NPTest.cache.travis)47
-rw-r--r--.github/dependabot.yml11
-rwxr-xr-x.github/prepare_debian.sh135
-rw-r--r--.github/workflows/codeql-analysis.yml73
-rw-r--r--.github/workflows/test.yml84
-rw-r--r--.gitignore19
-rw-r--r--.travis.yml76
-rw-r--r--ACKNOWLEDGEMENTS8
-rw-r--r--AUTHORS3
-rw-r--r--Makefile.am1
-rw-r--r--NEWS374
-rwxr-xr-xNP-VERSION-GEN2
-rw-r--r--NPTest.pm258
-rw-r--r--README4
-rw-r--r--REQUIREMENTS28
-rw-r--r--ROADMAP14
-rw-r--r--THANKS.in70
-rwxr-xr-xbuild-aux/config.rpath22
-rw-r--r--build-aux/ltmain.sh6
-rw-r--r--build-aux/snippet/_Noreturn.h10
-rw-r--r--build-aux/snippet/warn-on-use.h109
-rw-r--r--config_test/child_test.c2
-rw-r--r--configure.ac263
-rw-r--r--doc/RELEASING39
-rw-r--r--doc/RELEASING.md98
-rw-r--r--doc/developer-guidelines.sgml167
-rw-r--r--gl/Makefile.am2392
-rw-r--r--gl/_Noreturn.h50
-rw-r--r--gl/af_alg.c213
-rw-r--r--gl/af_alg.h115
-rw-r--r--gl/alloca.in.h35
-rw-r--r--gl/arg-nonnull.h (renamed from build-aux/snippet/arg-nonnull.h)14
-rw-r--r--gl/arpa_inet.in.h32
-rw-r--r--gl/asnprintf.c18
-rw-r--r--gl/asprintf.c18
-rw-r--r--gl/assert.in.h27
-rw-r--r--gl/attribute.h226
-rw-r--r--gl/base64.c126
-rw-r--r--gl/base64.h41
-rw-r--r--gl/basename-lgpl.c37
-rw-r--r--gl/basename-lgpl.h78
-rw-r--r--gl/basename.c56
-rw-r--r--gl/btowc.c18
-rw-r--r--gl/byteswap.in.h44
-rw-r--r--gl/c++defs.h (renamed from build-aux/snippet/c++defs.h)130
-rw-r--r--gl/calloc.c55
-rw-r--r--gl/cdefs.h707
-rw-r--r--gl/cloexec.c83
-rw-r--r--gl/cloexec.h34
-rw-r--r--gl/close.c75
-rw-r--r--gl/config.charset684
-rw-r--r--gl/dirname-lgpl.c18
-rw-r--r--gl/dirname.c6
-rw-r--r--gl/dirname.h55
-rw-r--r--gl/dosname.h53
-rw-r--r--gl/dup2.c189
-rw-r--r--gl/dynarray.h284
-rw-r--r--gl/errno.in.h22
-rw-r--r--gl/error.c74
-rw-r--r--gl/error.h45
-rw-r--r--gl/exitfail.c18
-rw-r--r--gl/exitfail.h18
-rw-r--r--gl/fcntl.c629
-rw-r--r--gl/fcntl.in.h445
-rw-r--r--gl/fd-hook.c22
-rw-r--r--gl/fd-hook.h22
-rw-r--r--gl/fflush.c233
-rw-r--r--gl/filename.h112
-rw-r--r--gl/float+.h18
-rw-r--r--gl/float.c18
-rw-r--r--gl/float.in.h30
-rw-r--r--gl/floor.c20
-rw-r--r--gl/floorf.c18
-rw-r--r--gl/fopen.c229
-rw-r--r--gl/fpurge.c150
-rw-r--r--gl/freading.c76
-rw-r--r--gl/freading.h54
-rw-r--r--gl/free.c53
-rw-r--r--gl/fseek.c30
-rw-r--r--gl/fseeko.c164
-rw-r--r--gl/fstat.c94
-rw-r--r--gl/fsusage.c118
-rw-r--r--gl/fsusage.h19
-rw-r--r--gl/ftell.c37
-rw-r--r--gl/ftello.c157
-rw-r--r--gl/full-read.c18
-rw-r--r--gl/full-read.h24
-rw-r--r--gl/full-write.c79
-rw-r--r--gl/gai_strerror.c18
-rw-r--r--gl/getaddrinfo.c180
-rw-r--r--gl/getdelim.c147
-rw-r--r--gl/getdtablesize.c124
-rw-r--r--gl/gethostname.c20
-rw-r--r--gl/getline.c27
-rw-r--r--gl/getloadavg.c179
-rw-r--r--gl/getopt-cdefs.in.h66
-rw-r--r--gl/getopt-core.h96
-rw-r--r--gl/getopt-ext.h77
-rw-r--r--gl/getopt-pfx-core.h66
-rw-r--r--gl/getopt-pfx-ext.h70
-rw-r--r--gl/getopt.c1442
-rw-r--r--gl/getopt.in.h242
-rw-r--r--gl/getopt1.c179
-rw-r--r--gl/getopt_int.h91
-rw-r--r--gl/getprogname.c302
-rw-r--r--gl/getprogname.h40
-rw-r--r--gl/gettext.h50
-rw-r--r--gl/gl_openssl.h116
-rw-r--r--gl/glthread/lock.c866
-rw-r--r--gl/glthread/lock.h544
-rw-r--r--gl/glthread/threadlib.c55
-rw-r--r--gl/hard-locale.c35
-rw-r--r--gl/hard-locale.h26
-rw-r--r--gl/ialloc.c21
-rw-r--r--gl/ialloc.h100
-rw-r--r--gl/idpriv-droptemp.c14
-rw-r--r--gl/idpriv.h12
-rw-r--r--gl/idx.h134
-rw-r--r--gl/inet_ntop.c20
-rw-r--r--gl/intprops-internal.h392
-rw-r--r--gl/intprops.h250
-rw-r--r--gl/inttypes.in.h1002
-rw-r--r--gl/itold.c18
-rw-r--r--gl/langinfo.in.h66
-rw-r--r--gl/lc-charset-dispatch.c82
-rw-r--r--gl/lc-charset-dispatch.h40
-rw-r--r--gl/libc-config.h202
-rw-r--r--gl/limits.in.h131
-rw-r--r--gl/localcharset.c1309
-rw-r--r--gl/localcharset.h119
-rw-r--r--gl/locale.in.h121
-rw-r--r--gl/localeconv.c18
-rw-r--r--gl/lseek.c89
-rw-r--r--gl/m4/00gnulib.m491
-rw-r--r--gl/m4/__inline.m422
-rw-r--r--gl/m4/absolute-header.m4100
-rw-r--r--gl/m4/af_alg.m457
-rw-r--r--gl/m4/alloca.m453
-rw-r--r--gl/m4/arpa_inet_h.m435
-rw-r--r--gl/m4/assert_h.m467
-rw-r--r--gl/m4/base64.m42
-rw-r--r--gl/m4/btowc.m433
-rw-r--r--gl/m4/builtin-expect.m449
-rw-r--r--gl/m4/byteswap.m417
-rw-r--r--gl/m4/c-bool.m451
-rw-r--r--gl/m4/calloc.m483
-rw-r--r--gl/m4/close.m435
-rw-r--r--gl/m4/codeset.m43
-rw-r--r--gl/m4/configmake.m450
-rw-r--r--gl/m4/dirname.m419
-rw-r--r--gl/m4/double-slash-root.m42
-rw-r--r--gl/m4/dup2.m4105
-rw-r--r--gl/m4/eealloc.m42
-rw-r--r--gl/m4/environ.m423
-rw-r--r--gl/m4/errno_h.m420
-rw-r--r--gl/m4/error.m48
-rw-r--r--gl/m4/exponentd.m42
-rw-r--r--gl/m4/extensions.m4214
-rw-r--r--gl/m4/extern-inline.m496
-rw-r--r--gl/m4/fcntl-o.m422
-rw-r--r--gl/m4/fcntl.m4151
-rw-r--r--gl/m4/fcntl_h.m470
-rw-r--r--gl/m4/fflush.m4100
-rw-r--r--gl/m4/float_h.m454
-rw-r--r--gl/m4/floorf.m418
-rw-r--r--gl/m4/fopen.m4149
-rw-r--r--gl/m4/fpurge.m473
-rw-r--r--gl/m4/freading.m4 (renamed from gl/m4/sha1.m4)11
-rw-r--r--gl/m4/free.m452
-rw-r--r--gl/m4/fseek.m415
-rw-r--r--gl/m4/fseeko.m477
-rw-r--r--gl/m4/fstat.m440
-rw-r--r--gl/m4/fstypename.m42
-rw-r--r--gl/m4/fsusage.m4363
-rw-r--r--gl/m4/ftell.m415
-rw-r--r--gl/m4/ftello.m4151
-rw-r--r--gl/m4/getaddrinfo.m443
-rw-r--r--gl/m4/getdelim.m4111
-rw-r--r--gl/m4/getdtablesize.m463
-rw-r--r--gl/m4/gethostname.m48
-rw-r--r--gl/m4/getline.m4109
-rw-r--r--gl/m4/getloadavg.m417
-rw-r--r--gl/m4/getopt.m439
-rw-r--r--gl/m4/getprogname.m443
-rw-r--r--gl/m4/gettext.m4401
-rw-r--r--gl/m4/gl-openssl.m476
-rw-r--r--gl/m4/glibc2.m431
-rw-r--r--gl/m4/glibc21.m434
-rw-r--r--gl/m4/gnulib-cache.m444
-rw-r--r--gl/m4/gnulib-common.m41022
-rw-r--r--gl/m4/gnulib-comp.m4885
-rw-r--r--gl/m4/gnulib-tool.m410
-rw-r--r--gl/m4/hostent.m48
-rw-r--r--gl/m4/iconv.m4268
-rw-r--r--gl/m4/idpriv.m42
-rw-r--r--gl/m4/include_next.m490
-rw-r--r--gl/m4/inet_ntop.m416
-rw-r--r--gl/m4/intdiv0.m487
-rw-r--r--gl/m4/intl.m4271
-rw-r--r--gl/m4/intldir.m419
-rw-r--r--gl/m4/intlmacosx.m456
-rw-r--r--gl/m4/intmax.m436
-rw-r--r--gl/m4/intmax_t.m416
-rw-r--r--gl/m4/inttypes-pri.m442
-rw-r--r--gl/m4/inttypes.m4180
-rw-r--r--gl/m4/inttypes_h.m42
-rw-r--r--gl/m4/langinfo_h.m448
-rw-r--r--gl/m4/largefile.m4378
-rw-r--r--gl/m4/lcmessage.m435
-rw-r--r--gl/m4/lib-ld.m4119
-rw-r--r--gl/m4/lib-link.m4777
-rw-r--r--gl/m4/lib-prefix.m4224
-rw-r--r--gl/m4/limits-h.m441
-rw-r--r--gl/m4/localcharset.m410
-rw-r--r--gl/m4/locale-fr.m443
-rw-r--r--gl/m4/locale-ja.m445
-rw-r--r--gl/m4/locale-zh.m445
-rw-r--r--gl/m4/locale_h.m4134
-rw-r--r--gl/m4/localeconv.m42
-rw-r--r--gl/m4/lock.m411
-rw-r--r--gl/m4/longlong.m4113
-rw-r--r--gl/m4/ls-mntd-fs.m4357
-rw-r--r--gl/m4/lseek.m478
-rw-r--r--gl/m4/malloc.m4173
-rw-r--r--gl/m4/malloca.m45
-rw-r--r--gl/m4/math_h.m4560
-rw-r--r--gl/m4/mbrtowc.m4358
-rw-r--r--gl/m4/mbsinit.m415
-rw-r--r--gl/m4/mbstate_t.m413
-rw-r--r--gl/m4/mbtowc.m413
-rw-r--r--gl/m4/memchr.m474
-rw-r--r--gl/m4/minmax.m444
-rw-r--r--gl/m4/mktime.m4142
-rw-r--r--gl/m4/mmap-anon.m48
-rw-r--r--gl/m4/mode_t.m426
-rw-r--r--gl/m4/mountlist.m4331
-rw-r--r--gl/m4/msvc-inval.m42
-rw-r--r--gl/m4/msvc-nothrow.m42
-rw-r--r--gl/m4/multiarch.m469
-rw-r--r--gl/m4/netdb_h.m428
-rw-r--r--gl/m4/netinet_in_h.m410
-rw-r--r--gl/m4/nl_langinfo.m437
-rw-r--r--gl/m4/nls.m432
-rw-r--r--gl/m4/nocrash.m413
-rw-r--r--gl/m4/off_t.m42
-rw-r--r--gl/m4/onceonly.m4104
-rw-r--r--gl/m4/open-cloexec.m421
-rw-r--r--gl/m4/open-slash.m460
-rw-r--r--gl/m4/open.m456
-rw-r--r--gl/m4/pathmax.m442
-rw-r--r--gl/m4/pid_t.m438
-rw-r--r--gl/m4/po.m4453
-rw-r--r--gl/m4/printf-posix.m448
-rw-r--r--gl/m4/printf.m4490
-rw-r--r--gl/m4/progtest.m491
-rw-r--r--gl/m4/pthread_rwlock_rdlock.m4185
-rw-r--r--gl/m4/read.m426
-rw-r--r--gl/m4/realloc.m463
-rw-r--r--gl/m4/reallocarray.m423
-rw-r--r--gl/m4/regex.m4193
-rw-r--r--gl/m4/safe-read.m412
-rw-r--r--gl/m4/servent.m48
-rw-r--r--gl/m4/setenv.m476
-rw-r--r--gl/m4/setlocale_null.m498
-rw-r--r--gl/m4/sha256.m414
-rw-r--r--gl/m4/size_max.m416
-rw-r--r--gl/m4/snprintf.m412
-rw-r--r--gl/m4/socketlib.m438
-rw-r--r--gl/m4/sockets.m42
-rw-r--r--gl/m4/socklen.m417
-rw-r--r--gl/m4/sockpfaf.m423
-rw-r--r--gl/m4/ssize_t.m42
-rw-r--r--gl/m4/stat-time.m483
-rw-r--r--gl/m4/stat.m485
-rw-r--r--gl/m4/std-gnu11.m4829
-rw-r--r--gl/m4/stdalign.m4121
-rw-r--r--gl/m4/stdbool.m4100
-rw-r--r--gl/m4/stddef_h.m481
-rw-r--r--gl/m4/stdint.m4169
-rw-r--r--gl/m4/stdint_h.m42
-rw-r--r--gl/m4/stdio_h.m4229
-rw-r--r--gl/m4/stdlib_h.m4173
-rw-r--r--gl/m4/strcase.m48
-rw-r--r--gl/m4/strcasestr.m461
-rw-r--r--gl/m4/strerror.m430
-rw-r--r--gl/m4/string_h.m4150
-rw-r--r--gl/m4/strings_h.m440
-rw-r--r--gl/m4/strndup.m455
-rw-r--r--gl/m4/strnlen.m430
-rw-r--r--gl/m4/strsep.m46
-rw-r--r--gl/m4/strstr.m467
-rw-r--r--gl/m4/sys_socket_h.m488
-rw-r--r--gl/m4/sys_stat_h.m4129
-rw-r--r--gl/m4/sys_types_h.m450
-rw-r--r--gl/m4/sys_uio_h.m425
-rw-r--r--gl/m4/threadlib.m4667
-rw-r--r--gl/m4/time_h.m4114
-rw-r--r--gl/m4/time_r.m449
-rw-r--r--gl/m4/timegm.m410
-rw-r--r--gl/m4/uintmax_t.m430
-rw-r--r--gl/m4/ungetc.m473
-rw-r--r--gl/m4/unistd_h.m4348
-rw-r--r--gl/m4/unlocked-io.m436
-rw-r--r--gl/m4/vararrays.m472
-rw-r--r--gl/m4/vasnprintf.m417
-rw-r--r--gl/m4/vasprintf.m42
-rw-r--r--gl/m4/visibility.m479
-rw-r--r--gl/m4/vsnprintf.m412
-rw-r--r--gl/m4/warn-on-use.m461
-rw-r--r--gl/m4/wchar_h.m4222
-rw-r--r--gl/m4/wchar_t.m42
-rw-r--r--gl/m4/wcrtomb.m490
-rw-r--r--gl/m4/wctype_h.m499
-rw-r--r--gl/m4/wint_t.m449
-rw-r--r--gl/m4/xalloc.m42
-rw-r--r--gl/m4/xsize.m42
-rw-r--r--gl/m4/xstrndup.m415
-rw-r--r--gl/m4/zzgnulib.m423
-rw-r--r--gl/malloc.c43
-rw-r--r--gl/malloc/dynarray-skeleton.c528
-rw-r--r--gl/malloc/dynarray.h177
-rw-r--r--gl/malloc/dynarray_at_failure.c40
-rw-r--r--gl/malloc/dynarray_emplace_enlarge.c77
-rw-r--r--gl/malloc/dynarray_finalize.c66
-rw-r--r--gl/malloc/dynarray_resize.c68
-rw-r--r--gl/malloc/dynarray_resize_clear.c39
-rw-r--r--gl/malloca.c165
-rw-r--r--gl/malloca.h69
-rw-r--r--gl/malloca.valgrind7
-rw-r--r--gl/math.c19
-rw-r--r--gl/math.in.h722
-rw-r--r--gl/mbrtowc-impl-utf8.h138
-rw-r--r--gl/mbrtowc-impl.h262
-rw-r--r--gl/mbrtowc.c393
-rw-r--r--gl/mbsinit.c52
-rw-r--r--gl/mbtowc-impl.h18
-rw-r--r--gl/mbtowc-lock.c150
-rw-r--r--gl/mbtowc-lock.h125
-rw-r--r--gl/mbtowc.c18
-rw-r--r--gl/memchr.c26
-rw-r--r--gl/memchr.valgrind16
-rw-r--r--gl/minmax.h60
-rw-r--r--gl/mktime-internal.h83
-rw-r--r--gl/mktime.c837
-rw-r--r--gl/mountlist.c486
-rw-r--r--gl/mountlist.h14
-rw-r--r--gl/msvc-inval.c18
-rw-r--r--gl/msvc-inval.h22
-rw-r--r--gl/msvc-nothrow.c22
-rw-r--r--gl/msvc-nothrow.h20
-rw-r--r--gl/netdb.in.h72
-rw-r--r--gl/netinet_in.in.h18
-rw-r--r--gl/nl_langinfo-lock.c150
-rw-r--r--gl/nl_langinfo.c579
-rw-r--r--gl/open.c209
-rw-r--r--gl/pathmax.h83
-rw-r--r--gl/printf-args.c22
-rw-r--r--gl/printf-args.h30
-rw-r--r--gl/printf-parse.c55
-rw-r--r--gl/printf-parse.h18
-rw-r--r--gl/read.c85
-rw-r--r--gl/realloc.c63
-rw-r--r--gl/reallocarray.c38
-rw-r--r--gl/ref-add.sin29
-rw-r--r--gl/ref-del.sin24
-rw-r--r--gl/regcomp.c1364
-rw-r--r--gl/regex.c21
-rw-r--r--gl/regex.h142
-rw-r--r--gl/regex_internal.c394
-rw-r--r--gl/regex_internal.h299
-rw-r--r--gl/regexec.c1169
-rw-r--r--gl/safe-read.c77
-rw-r--r--gl/safe-read.h47
-rw-r--r--gl/setenv.c20
-rw-r--r--gl/setlocale-lock.c150
-rw-r--r--gl/setlocale_null.c411
-rw-r--r--gl/setlocale_null.h82
-rw-r--r--gl/sha1.c426
-rw-r--r--gl/sha1.h91
-rw-r--r--gl/sha256-stream.c145
-rw-r--r--gl/sha256.c432
-rw-r--r--gl/sha256.h121
-rw-r--r--gl/size_max.h18
-rw-r--r--gl/snprintf.c18
-rw-r--r--gl/sockets.c33
-rw-r--r--gl/sockets.h46
-rw-r--r--gl/stat-time.c21
-rw-r--r--gl/stat-time.h251
-rw-r--r--gl/stat-w32.c460
-rw-r--r--gl/stat-w32.h37
-rw-r--r--gl/stat.c438
-rw-r--r--gl/stdalign.in.h78
-rw-r--r--gl/stdbool.in.h132
-rw-r--r--gl/stdckdint.in.h35
-rw-r--r--gl/stddef.in.h111
-rw-r--r--gl/stdint.in.h834
-rw-r--r--gl/stdio-impl.h218
-rw-r--r--gl/stdio-read.c168
-rw-r--r--gl/stdio-write.c206
-rw-r--r--gl/stdio.in.h715
-rw-r--r--gl/stdlib.in.h763
-rw-r--r--gl/str-two-way.h30
-rw-r--r--gl/strcasecmp.c20
-rw-r--r--gl/strcasestr.c19
-rw-r--r--gl/streq.h22
-rw-r--r--gl/strerror-override.c104
-rw-r--r--gl/strerror-override.h21
-rw-r--r--gl/strerror.c24
-rw-r--r--gl/string.in.h467
-rw-r--r--gl/strings.in.h18
-rw-r--r--gl/stripslash.c18
-rw-r--r--gl/strncasecmp.c20
-rw-r--r--gl/strndup.c36
-rw-r--r--gl/strnlen.c30
-rw-r--r--gl/strsep.c18
-rw-r--r--gl/strstr.c24
-rw-r--r--gl/sys-limits.h42
-rw-r--r--gl/sys_socket.c19
-rw-r--r--gl/sys_socket.in.h138
-rw-r--r--gl/sys_stat.in.h954
-rw-r--r--gl/sys_types.in.h77
-rw-r--r--gl/sys_uio.in.h18
-rw-r--r--gl/time.in.h273
-rw-r--r--gl/time_r.c18
-rw-r--r--gl/timegm.c62
-rw-r--r--gl/unistd.c19
-rw-r--r--gl/unistd.in.h997
-rw-r--r--gl/unlocked-io.h136
-rw-r--r--gl/unsetenv.c18
-rw-r--r--gl/vasnprintf.c932
-rw-r--r--gl/vasnprintf.h41
-rw-r--r--gl/vasprintf.c18
-rw-r--r--gl/verify.h191
-rw-r--r--gl/vsnprintf.c18
-rw-r--r--gl/w32sock.h24
-rw-r--r--gl/warn-on-use.h149
-rw-r--r--gl/wchar.in.h571
-rw-r--r--gl/wcrtomb.c49
-rw-r--r--gl/wctype-h.c19
-rw-r--r--gl/wctype.in.h457
-rw-r--r--gl/windows-initguard.h35
-rw-r--r--gl/windows-mutex.c95
-rw-r--r--gl/windows-mutex.h51
-rw-r--r--gl/windows-once.c62
-rw-r--r--gl/windows-once.h47
-rw-r--r--gl/windows-recmutex.c127
-rw-r--r--gl/windows-recmutex.h57
-rw-r--r--gl/windows-rwlock.c377
-rw-r--r--gl/windows-rwlock.h68
-rw-r--r--gl/xalloc-die.c6
-rw-r--r--gl/xalloc-oversized.h79
-rw-r--r--gl/xalloc.h231
-rw-r--r--gl/xmalloc.c306
-rw-r--r--gl/xsize.c18
-rw-r--r--gl/xsize.h44
-rw-r--r--gl/xstrndup.c36
-rw-r--r--gl/xstrndup.h23
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/maxfd.c26
-rw-r--r--lib/maxfd.h9
-rw-r--r--lib/parse_ini.c4
-rw-r--r--lib/tests/Makefile.am2
-rw-r--r--lib/tests/test_cmd.c14
-rw-r--r--lib/tests/test_disk.c4
-rwxr-xr-xlib/tests/test_ini3.t2
-rwxr-xr-xlib/tests/test_opts3.t2
-rw-r--r--lib/tests/test_utils.c8
-rw-r--r--lib/utils_base.c75
-rw-r--r--lib/utils_base.h10
-rw-r--r--lib/utils_cmd.c73
-rw-r--r--lib/utils_cmd.h4
-rw-r--r--lib/utils_disk.c36
-rw-r--r--lib/utils_disk.h6
-rw-r--r--m4/libcurl.m4272
-rw-r--r--m4/np_mysqlclient.m432
-rw-r--r--m4/uriparser.m4140
-rwxr-xr-xpkg/solaris/solpkg2
-rw-r--r--plugins-root/Makefile.am5
-rw-r--r--plugins-root/check_dhcp.c699
-rw-r--r--plugins-root/check_icmp.c573
-rw-r--r--plugins-root/pst3.c2
-rw-r--r--plugins-root/t/check_dhcp.t9
-rw-r--r--plugins-root/t/check_icmp.t13
-rw-r--r--plugins-scripts/Makefile.am2
-rwxr-xr-xplugins-scripts/check_breeze.pl3
-rw-r--r--[-rwxr-xr-x]plugins-scripts/check_disk_smb.pl28
-rwxr-xr-xplugins-scripts/check_file_age.pl61
-rwxr-xr-xplugins-scripts/check_ifoperstatus.pl12
-rwxr-xr-xplugins-scripts/check_ifstatus.pl4
-rwxr-xr-xplugins-scripts/check_ircd.pl8
-rwxr-xr-xplugins-scripts/check_log.sh168
-rwxr-xr-xplugins-scripts/check_mailq.pl84
-rwxr-xr-xplugins-scripts/check_mssql.pl2
-rwxr-xr-xplugins-scripts/check_oracle.sh244
-rwxr-xr-xplugins-scripts/check_rpc.pl2
-rwxr-xr-xplugins-scripts/check_sensors.sh34
-rwxr-xr-xplugins-scripts/check_uptime.pl328
-rwxr-xr-xplugins-scripts/check_wave.pl15
-rw-r--r--plugins-scripts/t/check_file_age.t75
-rw-r--r--plugins-scripts/t/check_log.t82
-rw-r--r--plugins-scripts/t/check_uptime.t135
-rw-r--r--plugins-scripts/t/utils.t1
-rw-r--r--plugins-scripts/utils.pm.in1
-rw-r--r--plugins/Makefile.am15
-rw-r--r--plugins/check_apt.c150
-rw-r--r--plugins/check_by_ssh.c41
-rw-r--r--plugins/check_cluster.c10
-rw-r--r--plugins/check_curl.c2696
-rw-r--r--plugins/check_dbi.c15
-rw-r--r--plugins/check_dig.c6
-rw-r--r--plugins/check_disk.c449
-rw-r--r--plugins/check_dns.c165
-rw-r--r--plugins/check_fping.c42
-rw-r--r--plugins/check_game.c2
-rw-r--r--plugins/check_hpjd.c30
-rw-r--r--plugins/check_http.c468
-rw-r--r--plugins/check_ide_smart.c28
-rw-r--r--plugins/check_ldap.c9
-rw-r--r--plugins/check_load.c173
-rw-r--r--plugins/check_mysql.c45
-rw-r--r--plugins/check_mysql_query.c12
-rw-r--r--plugins/check_nt.c2
-rw-r--r--plugins/check_ntp.c30
-rw-r--r--plugins/check_ntp_peer.c14
-rw-r--r--plugins/check_ntp_time.c10
-rw-r--r--plugins/check_nwstat.c2
-rw-r--r--plugins/check_pgsql.c82
-rw-r--r--plugins/check_ping.c69
-rw-r--r--plugins/check_procs.c108
-rw-r--r--plugins/check_radius.c50
-rw-r--r--plugins/check_real.c6
-rw-r--r--plugins/check_smtp.c156
-rw-r--r--plugins/check_snmp.c242
-rw-r--r--plugins/check_swap.c306
-rw-r--r--plugins/check_tcp.c29
-rw-r--r--plugins/check_ups.c21
-rw-r--r--plugins/check_users.c95
-rw-r--r--plugins/common.h12
-rw-r--r--plugins/negate.c8
-rw-r--r--plugins/netutils.c15
-rw-r--r--plugins/netutils.h9
-rw-r--r--plugins/picohttpparser/Makefile.am3
-rw-r--r--plugins/picohttpparser/picohttpparser.c651
-rw-r--r--plugins/picohttpparser/picohttpparser.h87
-rw-r--r--plugins/popen.c97
-rw-r--r--plugins/popen.h3
-rw-r--r--plugins/runcmd.c33
-rw-r--r--plugins/sslutils.c135
-rw-r--r--plugins/t/check_apt.t18
-rw-r--r--plugins/t/check_by_ssh.t32
-rw-r--r--plugins/t/check_curl.t213
-rw-r--r--plugins/t/check_disk.t54
-rw-r--r--plugins/t/check_dns.t34
-rw-r--r--plugins/t/check_fping.t44
-rw-r--r--plugins/t/check_ftp.t11
-rw-r--r--plugins/t/check_http.t167
-rw-r--r--plugins/t/check_imap.t17
-rw-r--r--plugins/t/check_jabber.t20
-rw-r--r--plugins/t/check_ldap.t17
-rw-r--r--plugins/t/check_load.t15
-rw-r--r--plugins/t/check_mysql.t31
-rw-r--r--plugins/t/check_mysql_query.t13
-rw-r--r--plugins/t/check_nagios.t2
-rw-r--r--plugins/t/check_smtp.t40
-rw-r--r--plugins/t/check_snmp.t90
-rw-r--r--plugins/t/check_ssh.t14
-rw-r--r--plugins/t/check_swap.t6
-rw-r--r--plugins/t/check_tcp.t25
-rw-r--r--plugins/t/check_time.t11
-rw-r--r--plugins/t/check_udp.t6
-rw-r--r--plugins/t/check_users.t6
-rw-r--r--plugins/t/negate.t2
-rw-r--r--plugins/tests/certs/.gitignore2
-rw-r--r--plugins/tests/certs/client-cert.pem22
-rw-r--r--plugins/tests/certs/client-key.pem28
-rw-r--r--plugins/tests/certs/clientca-cert.pem25
-rw-r--r--plugins/tests/certs/clientca-key.pem28
-rw-r--r--plugins/tests/certs/clientchain-cert.pem45
-rw-r--r--plugins/tests/certs/clientchain-key.pem28
-rw-r--r--plugins/tests/certs/clientintermediate-cert.pem23
-rw-r--r--plugins/tests/certs/clientintermediate-key.pem28
-rw-r--r--plugins/tests/certs/expired-cert.pem41
-rw-r--r--plugins/tests/certs/expired-key.pem43
-rw-r--r--plugins/tests/certs/ext.cnf2
-rwxr-xr-xplugins/tests/certs/generate-certs.sh63
-rw-r--r--plugins/tests/certs/server-cert.pem41
-rw-r--r--plugins/tests/certs/server-key.pem43
-rwxr-xr-xplugins/tests/check_curl.t526
-rwxr-xr-xplugins/tests/check_http.t392
-rwxr-xr-xplugins/tests/check_procs.t32
-rwxr-xr-xplugins/tests/check_snmp.t151
-rw-r--r--plugins/tests/check_snmp_agent.pl8
-rw-r--r--plugins/tests/var/ps-axwo.debian219
-rw-r--r--plugins/tests/var/ps_axwo.debian84
-rw-r--r--plugins/utils.c200
-rw-r--r--plugins/utils.h54
-rw-r--r--po/Makevars2
-rw-r--r--po/de.po2247
-rw-r--r--po/fr.po2133
-rw-r--r--po/monitoring-plugins.pot1978
-rw-r--r--tap/tap.34
-rw-r--r--tap/tap.h2
-rwxr-xr-xtools/build_perl_modules6
-rw-r--r--tools/p1.pl2
-rw-r--r--tools/squid.conf7979
-rwxr-xr-xtools/tinderbox_build2
-rwxr-xr-xtools/update-thanks2
607 files changed, 62142 insertions, 27200 deletions
diff --git a/plugins/t/NPTest.cache.travis b/.github/NPTest.cache
index fe8aabdb..d488d1b9 100644
--- a/plugins/t/NPTest.cache.travis
+++ b/.github/NPTest.cache
@@ -1,58 +1,55 @@
1{ 1{
2 'MYSQL_LOGIN_DETAILS' => '-u root -d test',
3 'NP_ALLOW_SUDO' => 'yes', 2 'NP_ALLOW_SUDO' => 'yes',
4 'NP_DNS_SERVER' => '8.8.8.8', 3 'NP_DNS_SERVER' => '8.8.8.8',
5 'NP_GOOD_NTP_SERVICE' => '', 4 'NP_GOOD_NTP_SERVICE' => '',
5 'NP_HOST_DHCP_RESPONSIVE' => '',
6 'NP_HOST_HPJD_PORT_INVALID' => '161',
7 'NP_HOST_HPJD_PORT_VALID' => '',
8 'NP_HOSTNAME_INVALID_CIDR' => '130.133.8.39/30',
6 'NP_HOSTNAME_INVALID' => 'nosuchhost', 9 'NP_HOSTNAME_INVALID' => 'nosuchhost',
7 'NP_HOSTNAME_VALID' => 'monitoringplugins.org', 10 'NP_HOSTNAME_VALID_CIDR' => '130.133.8.41/30',
8 'NP_HOSTNAME_VALID_IP' => '130.133.8.40', 11 'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
12 'NP_HOSTNAME_VALID' => 'monitoring-plugins.org',
9 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.', 13 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
10 'NP_HOST_DHCP_RESPONSIVE' => '', 14 'NP_HOST_NONRESPONSIVE' => '192.168.1.2',
11 'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
12 'NP_HOST_RESPONSIVE' => 'localhost', 15 'NP_HOST_RESPONSIVE' => 'localhost',
13 'NP_HOST_SMB' => '', 16 'NP_HOST_SMB' => '',
14 'NP_HOST_SNMP' => '', 17 'NP_HOST_SNMP' => '',
15 'NP_HOST_TCP_FTP' => '', 18 'NP_HOST_TCP_FTP' => '',
16 'NP_HOST_TCP_HPJD' => '', 19 'NP_HOST_TCP_HPJD' => '',
17 'NP_HOST_HPJD_PORT_INVALID' => '161',
18 'NP_HOST_HPJD_PORT_VALID' => '',
19 'NP_HOST_TCP_HTTP' => 'localhost',
20 'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org', 20 'NP_HOST_TCP_HTTP2' => 'test.monitoring-plugins.org',
21 'NP_HOST_TCP_HTTP' => 'localhost',
21 'NP_HOST_TCP_IMAP' => 'imap.web.de', 22 'NP_HOST_TCP_IMAP' => 'imap.web.de',
23 'NP_HOST_TCP_JABBER' => 'jabber.org',
22 'NP_HOST_TCP_LDAP' => 'localhost', 24 'NP_HOST_TCP_LDAP' => 'localhost',
23 'NP_HOST_TCP_POP' => 'pop.web.de', 25 'NP_HOST_TCP_POP' => 'pop.web.de',
26 'NP_HOST_TCP_PROXY' => 'localhost',
24 'NP_HOST_TCP_SMTP' => 'localhost', 27 'NP_HOST_TCP_SMTP' => 'localhost',
25 'NP_HOST_TCP_SMTP_NOTLS' => '', 28 'NP_HOST_TCP_SMTP_NOSTARTTLS' => '',
26 'NP_HOST_TCP_SMTP_TLS' => '', 29 'NP_HOST_TCP_SMTP_STARTTLS' => 'localhost',
30 'NP_HOST_TCP_SMTP_TLS' => 'localhost',
31 'NP_HOST_TLS_CERT' => 'localhost',
32 'NP_HOST_TLS_HTTP' => 'localhost',
33 'NP_HOST_UDP_TIME' => 'none',
27 'NP_INTERNET_ACCESS' => 'yes', 34 'NP_INTERNET_ACCESS' => 'yes',
28 'NP_LDAP_BASE_DN' => 'cn=admin,dc=nodomain', 35 'NP_LDAP_BASE_DN' => 'dc=nodomain',
29 'NP_MOUNTPOINT2_VALID' => '', 36 'NP_MOUNTPOINT2_VALID' => '/media/ramdisk1',
30 'NP_MOUNTPOINT_VALID' => '/', 37 'NP_MOUNTPOINT_VALID' => '/',
38 'NP_MYSQL_LOGIN_DETAILS' => '-u root -d test',
31 'NP_MYSQL_SERVER' => 'localhost', 39 'NP_MYSQL_SERVER' => 'localhost',
32 'NP_HOST_UDP_TIME' => 'localhost',
33 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock', 40 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock',
34 'NP_MYSQL_WITH_SLAVE' => '', 41 'NP_MYSQL_WITH_SLAVE' => '',
35 'NP_MYSQL_WITH_SLAVE_LOGIN' => '', 42 'NP_MYSQL_WITH_SLAVE_LOGIN' => '',
36 'NP_NO_NTP_SERVICE' => 'localhost', 43 'NP_NO_NTP_SERVICE' => 'localhost',
44 'NP_PORT_TCP_PROXY' => '3128',
37 'NP_SMB_SHARE' => '', 45 'NP_SMB_SHARE' => '',
38 'NP_SMB_SHARE_DENY' => '', 46 'NP_SMB_SHARE_DENY' => '',
39 'NP_SMB_SHARE_SPC' => '', 47 'NP_SMB_SHARE_SPC' => '',
40 'NP_SMB_VALID_USER' => '', 48 'NP_SMB_VALID_USER' => '',
41 'NP_SMB_VALID_USER_PASS' => '', 49 'NP_SMB_VALID_USER_PASS' => '',
42 'NP_SNMP_COMMUNITY' => '', 50 'NP_SNMP_COMMUNITY' => '',
51 'NP_SNMP_USER' => '',
43 'NP_SSH_CONFIGFILE' => '~/.ssh/config', 52 'NP_SSH_CONFIGFILE' => '~/.ssh/config',
44 'NP_SSH_HOST' => 'localhost', 53 'NP_SSH_HOST' => 'localhost',
45 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa', 54 'NP_SSH_IDENTITY' => '~/.ssh/id_rsa'
46 'NP_HOST_TCP_JABBER' => 'jabber.org',
47 'host_nonresponsive' => '10.0.0.1',
48 'host_responsive' => 'localhost',
49 'host_snmp' => '',
50 'host_tcp_ftp' => '',
51 'host_tcp_http' => 'localhost',
52 'host_tcp_imap' => 'imap.nierlein.de',
53 'host_tcp_smtp' => 'localhost',
54 'hostname_invalid' => 'nosuchhost',
55 'snmp_community' => '',
56 'user_snmp' => '',
57 'host_udp_time' => 'none',
58} 55}
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..07073644
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,11 @@
1---
2version: 2
3updates:
4 - package-ecosystem: github-actions
5 directory: "/"
6 schedule:
7 interval: daily
8 time: "04:00"
9 pull-request-branch-name:
10 separator: "-"
11 open-pull-requests-limit: 10
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh
new file mode 100755
index 00000000..dcf778bc
--- /dev/null
+++ b/.github/prepare_debian.sh
@@ -0,0 +1,135 @@
1#!/bin/bash
2
3set -x
4set -e
5
6export DEBIAN_FRONTEND=noninteractive
7
8source /etc/os-release
9
10if [ ${ID} = "debian" ]; then
11 if [ -f /etc/apt/sources.list.d/debian.sources ]; then
12 sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources
13 else
14 apt-get update
15 apt-get -y install software-properties-common
16 apt-add-repository non-free
17 fi
18fi
19apt-get update
20apt-get -y install perl \
21 autotools-dev \
22 libdbi-dev \
23 libldap2-dev \
24 libpq-dev \
25 libradcli-dev \
26 libnet-snmp-perl \
27 procps \
28 libdbi0-dev \
29 libdbd-sqlite3 \
30 libssl-dev \
31 dnsutils \
32 snmp-mibs-downloader \
33 libsnmp-perl \
34 snmpd \
35 fping \
36 snmp \
37 netcat-openbsd \
38 smbclient \
39 vsftpd \
40 apache2 \
41 ssl-cert \
42 postfix \
43 libhttp-daemon-ssl-perl \
44 libdbd-sybase-perl \
45 libnet-dns-perl \
46 slapd \
47 ldap-utils \
48 gcc \
49 make \
50 autoconf \
51 automake \
52 gettext \
53 faketime \
54 libmonitoring-plugin-perl \
55 libcurl4-openssl-dev \
56 liburiparser-dev \
57 squid \
58 openssh-server \
59 mariadb-server \
60 mariadb-client \
61 libmariadb-dev \
62 cron \
63 iputils-ping \
64 iproute2
65
66# remove ipv6 interface from hosts
67if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then
68 sed '/^::1/d' /etc/hosts > /tmp/hosts
69 cp -f /tmp/hosts /etc/hosts
70fi
71
72ip addr show
73
74cat /etc/hosts
75
76# apache
77a2enmod ssl
78a2ensite default-ssl
79# replace snakeoil certs with openssl generated ones as the make-ssl-cert ones
80# seems to cause problems with our plugins
81rm /etc/ssl/certs/ssl-cert-snakeoil.pem
82rm /etc/ssl/private/ssl-cert-snakeoil.key
83openssl req -nodes -newkey rsa:2048 -x509 -sha256 -days 365 -nodes -keyout /etc/ssl/private/ssl-cert-snakeoil.key -out /etc/ssl/certs/ssl-cert-snakeoil.pem -subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=$(hostname)"
84service apache2 restart
85
86# squid
87cp tools/squid.conf /etc/squid/squid.conf
88service squid start
89
90# mariadb
91service mariadb start || service mysql start
92mysql -e "create database IF NOT EXISTS test;" -uroot
93
94# ldap
95sed -e 's/cn=admin,dc=nodomain/'$(/usr/sbin/slapcat|grep ^dn:|awk '{print $2}')'/' -i .github/NPTest.cache
96service slapd start
97
98# sshd
99ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
100cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
101service ssh start
102sleep 1
103ssh-keyscan localhost >> ~/.ssh/known_hosts
104touch ~/.ssh/config
105
106# start one login session, required for check_users
107ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
108disown %1
109
110# snmpd
111service snmpd stop
112mkdir -p /var/lib/snmp/mib_indexes
113sed -e 's/^agentaddress.*/agentaddress 127.0.0.1/' -i /etc/snmp/snmpd.conf
114service snmpd start
115
116# start cron, will be used by check_nagios
117cron
118
119# postfix
120cat <<EOD >> /etc/postfix/master.cf
121smtps inet n - n - - smtpd
122 -o smtpd_tls_wrappermode=yes
123EOD
124service postfix start
125
126# start ftpd
127service vsftpd start
128
129# hostname
130sed "/NP_HOST_TLS_CERT/s/.*/'NP_HOST_TLS_CERT' => '$(hostname)',/" -i /src/.github/NPTest.cache
131
132# create some test files to lower inodes
133for i in $(seq 10); do
134 touch /media/ramdisk2/test.$1
135done
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 00000000..0317c8c0
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,73 @@
1---
2# For most projects, this workflow file will not need changing; you simply need
3# to commit it to your repository.
4#
5# You may wish to alter this file to override the set of languages analyzed,
6# or to provide custom queries or build logic.
7#
8# ******** NOTE ********
9# We have attempted to detect the languages in your repository. Please check
10# the `language` matrix defined below to confirm you have the correct set of
11# supported CodeQL languages.
12#
13name: "CodeQL"
14
15on:
16 push:
17 branches: [master]
18 pull_request:
19 # The branches below must be a subset of the branches above
20 branches: [master]
21 schedule:
22 - cron: '15 18 * * 0'
23
24jobs:
25 analyze:
26 name: Analyze
27 runs-on: ubuntu-latest
28 permissions:
29 actions: read
30 contents: read
31 security-events: write
32
33 strategy:
34 fail-fast: false
35 matrix:
36 language: ['cpp']
37 # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
38 # Learn more:
39 # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
40
41 steps:
42 - name: Checkout repository
43 uses: actions/checkout@v4
44
45 # Initializes the CodeQL tools for scanning.
46 - name: Initialize CodeQL
47 uses: github/codeql-action/init@v2
48 with:
49 languages: ${{ matrix.language }}
50 # If you wish to specify custom queries, you can do so here or in a config file.
51 # By default, queries listed here will override any specified in a config file.
52 # Prefix the list here with "+" to use these queries and those in the config file.
53 # queries: ./path/to/local/query, your-org/your-repo/queries@main
54
55 - name: Install packages
56 run: |
57 sudo apt update
58 sudo apt-get install -y --no-install-recommends m4 gettext automake autoconf make build-essential
59 sudo apt-get install -y --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev \
60 libmysqlclient-dev libradcli-dev libkrb5-dev libdbi0-dev \
61 libdbd-sqlite3 libssl-dev libcurl4-openssl-dev liburiparser-dev
62
63 - name: Configure build
64 run: |
65 ./tools/setup
66 ./configure --enable-libtap
67
68 - name: Build
69 run: |
70 make
71
72 - name: Perform CodeQL Analysis
73 uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 00000000..0f845de7
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,84 @@
1---
2name: Test
3
4on:
5 push:
6 branches:
7 - '*'
8 # Run test for any PRs
9 pull_request:
10
11jobs:
12 codespell:
13 name: codespell
14 strategy:
15 fail-fast: false
16 runs-on: ubuntu-latest
17 steps:
18 - name: Checkout
19 uses: actions/checkout@v4
20 - name: Codespell
21 uses: codespell-project/actions-codespell@v2
22 with:
23 skip: "./.git,./.gitignore,./ABOUT-NLS,*.po,./gl,./po,./tools/squid.conf,./build-aux/ltmain.sh"
24 ignore_words_list: allright,gord,didi,hda,nd,alis,clen,scrit,ser,fot,te,parm,isnt,consol,oneliners,esponse
25 check_filenames: true
26 check_hidden: true
27# super-linter:
28# name: super-linter
29# strategy:
30# fail-fast: false
31# runs-on: ubuntu-latest
32# steps:
33# - name: Checkout
34# uses: actions/checkout@v4
35# - name: Lint Code Base
36# uses: github/super-linter@v5.0.0
37# env:
38# DEFAULT_BRANCH: master
39# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40# macos:
41# ...
42 linux:
43 needs:
44 - codespell
45# - super-linter
46 runs-on: ubuntu-latest
47 name: Running tests on ${{ matrix.distro }}
48 strategy:
49 fail-fast: false
50 matrix:
51 distro:
52 - 'debian:stable'
53 #...
54 include:
55 - distro: 'debian:stable'
56 prepare: .github/prepare_debian.sh
57 #...
58 steps:
59 - name: Git clone repository
60 uses: actions/checkout@v4
61 #- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate
62 # uses: mxschmitt/action-tmate@v3
63 - name: Run the tests on ${{ matrix.distro }}
64 run: |
65 docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000 tmp-vol
66 docker run \
67 -e NPTEST_ACCEPTDEFAULT=1 \
68 -e NPTEST_CACHE="/src/.github/NPTest.cache" \
69 -w /src -v ${PWD}:/src \
70 --tmpfs /media/ramdisk1 \
71 -v /var/run/utmp:/var/run/utmp \
72 --mount source=tmp-vol,destination=/src,target=/media/ramdisk2 \
73 ${{ matrix.distro }} \
74 /bin/sh -c '${{ matrix.prepare }} && \
75 tools/setup && \
76 ./configure --enable-libtap --with-ipv6=no && \
77 set -x && \
78 tmp_dir=$(mktemp -d -t test-XXXX) && cp -a po/ $tmp_dir/ && \
79 cd po && make update-po && cd .. && \
80 diff -Nur $tmp_dir/po/*.po po/*.po | tee -a /tmp/po.diff && diff -Nur $tmp_dir/po/*.pot po/*.pot | tee -a /tmp/po.diff && if [ $(wc -l /tmp/po.diff | cut -f 1 -d" ") -gt 0 ]; then echo "Error: Translations needs to be updated with make update-po!" && exit 1; fi && \
81 make && \
82 make test'
83 docker container prune -f
84 docker volume prune -f
diff --git a/.gitignore b/.gitignore
index 3093c6ea..02ca61e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,10 +53,8 @@ NP-VERSION-FILE
53# /gl/ 53# /gl/
54/gl/.deps 54/gl/.deps
55/gl/alloca.h 55/gl/alloca.h
56/gl/arg-nonnull.h
57/gl/arpa 56/gl/arpa
58/gl/arpa_inet.h 57/gl/arpa_inet.h
59/gl/c++defs.h
60/gl/charset.alias 58/gl/charset.alias
61/gl/configmake.h 59/gl/configmake.h
62/gl/errno.h 60/gl/errno.h
@@ -70,6 +68,8 @@ NP-VERSION-FILE
70/gl/locale.h 68/gl/locale.h
71/gl/Makefile 69/gl/Makefile
72/gl/Makefile.in 70/gl/Makefile.in
71/gl/malloc/.dirstamp
72/gl/malloc/.deps
73/gl/math.h 73/gl/math.h
74/gl/netdb.h 74/gl/netdb.h
75/gl/netinet_in.h 75/gl/netinet_in.h
@@ -88,9 +88,13 @@ NP-VERSION-FILE
88/gl/sys 88/gl/sys
89/gl/time.h 89/gl/time.h
90/gl/unistd.h 90/gl/unistd.h
91/gl/warn-on-use.h
92/gl/wchar.h 91/gl/wchar.h
93/gl/wctype.h 92/gl/wctype.h
93/gl/inttypes.h
94/gl/limits.h
95/gl/malloc/dynarray-skeleton.gl.h
96/gl/malloc/dynarray.gl.h
97/gl/stdckdint.
94 98
95# /lib/ 99# /lib/
96/lib/.deps 100/lib/.deps
@@ -142,6 +146,7 @@ NP-VERSION-FILE
142/plugins/check_by_ssh 146/plugins/check_by_ssh
143/plugins/check_clamd 147/plugins/check_clamd
144/plugins/check_cluster 148/plugins/check_cluster
149/plugins/check_curl
145/plugins/check_dbi 150/plugins/check_dbi
146/plugins/check_dig 151/plugins/check_dig
147/plugins/check_disk 152/plugins/check_disk
@@ -202,6 +207,12 @@ NP-VERSION-FILE
202/plugins/stamp-h* 207/plugins/stamp-h*
203/plugins/urlize 208/plugins/urlize
204 209
210# /plugins/picohttpparser
211/plugins/picohttpparser/Makefile
212/plugins/picohttpparser/Makefile.in
213/plugins/picohttpparser/.deps
214/plugins/picohttpparser/libpicohttpparser.a
215
205# /plugins/t/ 216# /plugins/t/
206/plugins/t/*.tmp 217/plugins/t/*.tmp
207 218
@@ -235,12 +246,14 @@ NP-VERSION-FILE
235/plugins-scripts/check_ircd 246/plugins-scripts/check_ircd
236/plugins-scripts/check_log 247/plugins-scripts/check_log
237/plugins-scripts/check_mailq 248/plugins-scripts/check_mailq
249/plugins-scripts/check_mssql
238/plugins-scripts/check_ntp 250/plugins-scripts/check_ntp
239/plugins-scripts/check_oracle 251/plugins-scripts/check_oracle
240/plugins-scripts/check_rpc 252/plugins-scripts/check_rpc
241/plugins-scripts/check_sensors 253/plugins-scripts/check_sensors
242/plugins-scripts/check_wave 254/plugins-scripts/check_wave
243/plugins-scripts/check_file_age 255/plugins-scripts/check_file_age
256/plugins-scripts/check_uptime
244 257
245# /po/ 258# /po/
246/po/Makefile 259/po/Makefile
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 29290fd1..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,76 +0,0 @@
1sudo: required
2dist: trusty
3language: c
4
5before_install:
6 # Trusty related fixed
7 # multiverse is no on trusty activated (https://github.com/travis-ci/travis-ci/issues/4979)
8 - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty multiverse" && sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-updates multiverse"
9 # /etc/hosts has IPv6 hosts (https://github.com/travis-ci/travis-ci/issues/4978)
10 - sudo [ $(ip addr show | grep "inet6 ::1" | wc -l) -lt "1" ] && sudo sed -i '/^::1/d' /etc/hosts
11 # Trusty has running ntpd on localhost, but we don't like that for our tests
12 - sudo killall -9 ntpd
13 # Trusty has no swap, lets create some
14 - sudo fallocate -l 20M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile
15 - sudo add-apt-repository -y ppa:waja/trusty-backports
16 - sudo apt-get update -qq
17 - sudo apt-get purge -qq gawk
18 # http://docs.travis-ci.com/user/trusty-ci-environment/ indicates, no MySQL on Trusty (yet)
19 # # ensure we have a test database in place for tests
20 # - mysql -e "create database IF NOT EXISTS test;" -uroot
21
22install:
23 - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps
24 - sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd
25 - sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl
26 - sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl
27 - sudo apt-get install -qq --no-install-recommends slapd ldap-utils
28 - sudo apt-get install -qq --no-install-recommends autoconf automake
29 - sudo apt-get install -qq --no-install-recommends faketime
30 # Trusty related dependencies (not yet provided)
31 - sudo apt-get install -qq --no-install-recommends mariadb-client mariadb-server
32
33before_script:
34 # ensure we have a test database in place for tests
35 - mysql -e "create database IF NOT EXISTS test;" -uroot
36 # Detect LDAP configuration (seems volatile on trusty env)
37 - sed -e 's/cn=admin,dc=nodomain/'$(sudo /usr/sbin/slapcat|grep ^dn:|grep cn=|awk '{print $2}')'/' -i plugins/t/NPTest.cache.travis
38 - tools/setup
39 - ./configure --enable-libtap
40 - make
41 - export NPTEST_CACHE="$(pwd)/plugins/t/NPTest.cache.travis"
42 - ssh-keygen -t dsa -N "" -f ~/.ssh/id_dsa
43 - cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
44 - ssh-keyscan localhost >> ~/.ssh/known_hosts
45 - touch ~/.ssh/config
46 - sudo rm -f /usr/share/mibs/ietf/SNMPv2-PDU /usr/share/mibs/ietf/IPSEC-SPD-MIB /usr/share/mibs/ietf/IPATM-IPMC-MIB /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
47 - sudo mkdir -p /var/lib/snmp/mib_indexes
48
49script:
50 - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make test; fi
51
52notifications:
53 irc:
54 channels:
55 - "chat.freenode.net#Monitoring-Plugins"
56 on_success: change
57 on_failure: always
58 skip_join: true
59 email:
60 - team@monitoring-plugins.org
61
62env:
63 global:
64 # This is the encrypted COVERITY_SCAN_TOKEN, created via the "travis
65 # encrypt" command using the project repository's public key.
66 - secure: "ggJ9c/VfKcwtrwz/My+ne4My7D8g3qi3vz5Hh+yLiri0+oIXCy313ZD6ssIEY/5beQZEOnuHhBgBJd/Y3clSQNc2M9fRNc+wxOkIO992lgnY0MZJN3y9MLfpqUbTClhU9Fst0qXQqGpI6UI8yz1tj7yKi7DPrycJLRrjMpyTfyo="
67
68addons:
69 coverity_scan:
70 project:
71 name: "monitoring-plugins/monitoring-plugins"
72 description: "Monitoring Plugins"
73 notification_email: team@monitoring-plugins.org
74 build_command_prepend: tools/setup && ./configure
75 build_command: make
76 branch_pattern: coverity.*
diff --git a/ACKNOWLEDGEMENTS b/ACKNOWLEDGEMENTS
index 50c714c3..af29c154 100644
--- a/ACKNOWLEDGEMENTS
+++ b/ACKNOWLEDGEMENTS
@@ -20,7 +20,7 @@ Using the DLPI support on SysV systems to get the host MAC address in check_dhcp
20Stenberg, Daniel 20Stenberg, Daniel
21Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se> 21Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se>
22http://curl.haxx.se/ 22http://curl.haxx.se/
23Use of duplication of macros in m4/np_curl.m4 23Use of duplication of macros in m4/np_curl.m4 (slightly adapted for m4/uriparser.m4 too)
24 24
25Coreutils team 25Coreutils team
26Copyright (C) 91, 1995-2004 Free Software Foundation, Inc. 26Copyright (C) 91, 1995-2004 Free Software Foundation, Inc.
@@ -31,3 +31,9 @@ Gnulib team
31Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc 31Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc
32http://www.gnu.org/software/gnulib/ 32http://www.gnu.org/software/gnulib/
33Use of lib files that originally were used from coreutils 33Use of lib files that originally were used from coreutils
34
35Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase,
36 Shigeo Mitsunari
37picohttpparser
38https://github.com/h2o/picohttpparser
39Use of the library for HTTP header parsing in check_curl.
diff --git a/AUTHORS b/AUTHORS
index 0c667f60..1b1a0366 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -21,3 +21,6 @@ Ton Voon
21Jan Wagner 21Jan Wagner
22Holger Weiss 22Holger Weiss
23Michael Wirtgen 23Michael Wirtgen
24Oliver Skibbe
25Andreas Baumann
26Lorenz Kästle
diff --git a/Makefile.am b/Makefile.am
index 7e0d4131..df1bcbb3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,6 +34,7 @@ test test-debug:
34 if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi 34 if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi
35 cd plugins && $(MAKE) $@ 35 cd plugins && $(MAKE) $@
36 cd plugins-scripts && $(MAKE) $@ 36 cd plugins-scripts && $(MAKE) $@
37 cd plugins-root && $(MAKE) $@
37 38
38# Solaris pkgmk 39# Solaris pkgmk
39BUILDDIR = build-solaris 40BUILDDIR = build-solaris
diff --git a/NEWS b/NEWS
index 2a9ea62c..9ec3c5e0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,24 +1,234 @@
1This file documents the major additions and syntax changes between releases. 1This file documents the major additions and syntax changes between releases.
2 2
32.2 [...] 32.3.3 2nd Feb 2023
4 ENHANCEMENTS
5 using PRId64 and PRIu64 instead of %ld directly
6 check_http: Make faster with larger files
7 check_snmp: add 'multiplier' to modify current value
8 check_http: Implement chunked encoding decoding
9 check_http/check_curl: add chunked encoding test
10 check_log: Added --exclude to exclude patterns
11 check_log: Add tests
12 check_disk: Clarify usage possibilities
13
14 FIXES
15 fixed two PRId64 to PRIu64 in perfdata_uint64
16 check_pgsql: Removing is_pg_dbname altogether,using postgres API.
17 check_http: Remove superfluous CRLF in HTTP-Requests
18 check_curl: detect ipv6
19 check_icmp: fix parsing help/version long options
20 check_http: fix test plan
21 check_disk: Find accessible mount path if multiple are available
22 check_apt: Fix unknown escape sequence error output
23 check_curl: fix checking large bodys
24 check_snmp: Improve tests for check_snmp & multiply option
25 check_snmp: always apply format when applying multiplier
26 check_http: Use real booleans instead of ints
27 check_http: Document process_arguments a little bit better
28 check_http: Remove dead code
29 check_http: Fix several bug in the implementation of unchunking
30 check_http: Reformat a part to increase readability
31 check_apt: Put upgrade options in the root sections
32 check_apt: Fix comment
33 check_apt: Use real booleans
34 check_mailq: Fixing nullmailer regex
35 check_snmp: Fix regex matches
36 check_log: Fixed a bug when using --all
37 check_log: Cleaned up duplicated code in the args
38 check_http: Fix memory reallocation error in chunk decoding logic
39 check_http: Add space for ending NULL byte in array for chunked encoding
40
412.3.2 20th Oct 2022
42 GENERAL
43 Use netcat-openbsd for debian explicitly (by @RincewindsHat #1704)
44 Replace egrep with grep -E (by @RincewindsHat #1791)
45 Use silent automake by default (by @RincewindsHat #1747)
46
47 SINGLE PLUGINS
48 check_by_ssh: added option to exit with an warning, if there is output on STDERR (by @nafets #1301)
49 check_by_ssh: Add "-U" flag (#1123). (by @archiecobbs #1774)
50 check_by_ssh: Let ssh decide if a host is valid, enables usage of ssh .config file (by @RincewindsHat #1691)
51 check_curl: Add an option to check_curl to verify the peer certificate & host using the system CA's (by @bazzisoft #1669)
52 check_curl: fixed -ffollow for HTTP/2.0 (Fixes #1685): added major_version parsing to PicoHTTPParser (by @andreasbaumann #1742)
53 check_curl: fixes check_curl: "CRITICAL - Cannot retrieve certificate subject." (by @andreasbaumann #1689)
54 check_curl: fix if http header contains leading spaces (by @sni #1666)
55 check_curl: Update check_curl.c to display a specific human-readable error message where possible (by @bazzisoft #1668)
56 check_curl: verify certificates option should not force SSL to be used (by @bazzisoft #1688)
57 check_disk: Description for -M was the wrong way around (by @RincewindsHat #1746)
58 check_disk: Fixing the stuff that is broken on btrfs (by @waja #1388)
59 check_disk: Fix perfdata for big values for check disk (by @RincewindsHat #1714)
60 check_disk_smb: Add configfile feature (by @Napsty #1402)
61 check_disk_smb: Add timeout (by @cdruee #1770)
62 check_dns: Add --expect-nxdomain (by @Jonny007-MKD #1623)
63 check_dns: split multiple IP addresses passed in one -a argument (by @DerDakon #1649)
64 check_file_age: Make size parameter a little bit more intelligible (by @RincewindsHat #1730)
65 check_fping: Implements 'host-alive' mode (Closes. #1027) (by @waja #1740)
66 check_game: Update Url to qstat (by @RincewindsHat #1725)
67 check_http: changed 'STATE_CRITICAL' to 'STATE_WARNING' for infinite loop (by @xFuture603 #1690)
68 check_http: Increase regexp limit (by @hydrapolic #1566)
69 check_http: Support http redirect (by @waja #1449)
70 check_icmp: buffer offerflow (by @RincewindsHat #1733)
71 check_icmp: delay set_source_ip() until address_family is detected (by @ghciv6 #1735)
72 check_icmp: Fix "Invalid Argument" from sendmsg() under FreeBSD 13.1 and "setsockopt failed" for TTL setting (by @eriksejr #1771)
73 check_icmp: Fix pkt perfdata in check_host mode (by @sjoegren #1721)
74 check_ldap: Allows check_ldap to read password from environment variable (by @mullumaus #1724)
75 check_load: add LOAD prefix to load plugin (by @haraldj #1694)
76 check_load: Display total and scaled load values if check_load scales the values (by number of CPUs by @RincewindsHat #1778)
77 check_log: Missing oldlog now aborts check_log (by @RincewindsHat #1732)
78 check_mailq: Add mailq -C option for config dir or config file (by @leeclemens #1490)
79 check_mailq: Check mailq domain specific warnings (by @RincewindsHat #1731)
80 check_mailq: Fix regexp for nullmailer "mailq" output (by @darksoul42 #1493)
81 check_mysql: fix segfaults with mysql-connector-c #1562 (by @ghciv6 #1644)
82 check_pgsql: add --queryname parameter to check_pgsql (by @datamuc #1741)
83 check_ping: Do not show RTA if no connection was possible (by @RincewindsHat #1697)
84 check_ping: understang ping6 output from iputils package (by @glensc #1412)
85 check_proc: Fix check proc ps detection (by @sni #1712)
86 check_procs: exchange needle and haystack in strstr() for proper st… (by @wolfgangkarall #1654)
87 check_smtp: add -L flag to support LMTP (LHLO instead of HELO/EHLO). (by @ghen2 #1715)
88 check_snmp: Added option for null zero length string exit codes (by @FracKenA #1496)
89 check_snmp: fix performance thresholds when using multiple oids (by @sni #1722)
90 check_snmp fix segfaults (by @adrb #1589)
91 check_snmp: put the "c" (to mark a counter) after the perfdata value (by @lausser #1465)
92 check_swap: fix parsing swap values (by @sni #1780)
93 check_swap: Fix perfdata for check swap (by @RincewindsHat #1707)
94 check_swap: Fix unit for total in perfdata (by @RincewindsHat #1779)
95 check_swap: Handle cached swap (by @mdavranche #1642)
96 check_swap: Small fix to threshold validation and style (indentation) fixes (by @RincewindsHat #1723)
97 check_ups: Fix possible overflow in check_ups (by @phibos #1727)
98 check_uptime: Add option to report uptime in days instead of seconds (by @amotl #1750)
99 check_uptime: Fix/improve output message "Uptime is ..." (by @amotl #1751)
100
101 MULTIPLE PLUGINS
102 check_http, check_curl: added --max-redirs=N option (feature #1684) (by @andreasbaumann #1744)
103 check_http, check_curl: Enhancement --continue-after-certificate (backport from nagios-plugins) (by @andreasbaumann #1762)
104 check_http, check_curl: Remove check_http and check_curl test which are somehow always failing (by @RincewindsHat #1777)
105 check_log, check_oracle, check_sensors: Several fixes shellcheck complaining about (by @waja #1459)
106 sslutils: use chain from client certificates (by @tobiaswiese #1664)
107
108 NON FUNCTIONAL CHANGES
109 Trivial source code whitespace formatting fixes to standard. (by @ziesemer #1424)
110 docs: fix simple typo, conspicuosly -> conspicuously (by @timgates42 #1652)
111 Migrate to GitHub actions (by @jacobbaungard #1686)
112 Point to Icinga Exchange instead of dead Monitoring Exchange (by @RincewindsHat #1737)
113 github actions: fix check_users test case (by @sni #1713)
114 Add CodeQL checks (by @phibos #1682)
115 Fix some QL problems (by @RincewindsHat #1729)
116 Update CodeQL and update runner before installing (by @RincewindsHat #1775)
117 check_disk: Check disk compiler warnings (by @RincewindsHat #1758)
118 check_disk: Trivial printf fix and a little bit of code style (by @RincewindsHat #1695)
119 check_http: Docs: make -C obvious (by @stblassitude #1554)
120 check_ifoperstatus: Re-attach a comment to where it actually belongs (by @peternewman #1699)
121 check_ircd: Restrict the nickname length of the test user for check_ircd (by @RincewindsHat #1710)
122 check_load: Check load compiler warnings (by @RincewindsHat #1759)
123 check_log: Modernize check log (by @RincewindsHat #1692)
124 check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755)
125 check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781)
126 check_pgsql: Using snprintf which honors the buffers size and guarantees null termination. (Closes: #1601) (by @waja #1663)
127 check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743)
128 check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679)
129 check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676)
130 check_swap: Check swap compiler warnings (by @RincewindsHat #1756)
131
1322.3.1 10 April 2021
133 ENHANCEMENTS
134 check_curl: Add an option to verify the peer certificate & host using the system CA's
135
136 FIXES
137 check_icmp: fix simple typo, conspicuosly -> conspicuously
138 check_curl: fixed help, usage and errors for TLS 1.3
139 check_curl: fixed a potential buffer overflow in url buffer
140 check_dns: split multiple IP addresses passed in one -a argument
141 check_curl: added string_statuscode function for printing HTTP/1.1 and HTTP/2 correctly
142 check_curl: fix crash if http header contains leading spaces
143 check_curl: display a specific human-readable error message where possible
144 check_pgsql: Using snprintf which honors the buffers size and guarantees null termination.
145 check_snmp: put the "c" (to mark a counter) after the perfdata value
146 check_http: Increase regexp limit
147 check_http: make -C obvious
148 check_curl: Increase regexp limit (to 1024 as in check_http)
149 check_curl: make -C obvious (from check_http)
150 check_curl: backported --show-body/-B to print body (from check_http)
151
1522.3 10th December 2020
153 ENHANCEMENTS
154 check_dns: allow 'expected address' (-a) to be specified in CIDR notation
155 (IPv4 only).
156 check_dns: allow for IPv6 RDNS
157 check_dns: Accept CIDR
158 check_dns: allow unsorted addresses
159 check_dns: allow forcing complete match of all addresses
160 check_dns: option to expect NXDOMAIN
161 check_apt: add --only-critical switch
162 check_apt: add -l/--list option to print packages
163 check_file_age: add range checking
164 check_file_age: enable to test for maximum file size
165 check_apt: adding packages-warning option
166 check_load: Adding top consuming processes option
167 check_http: Adding Proxy-Authorization and extra headers
168 check_snmp: make calculation of timeout value in help output more clear
169 check_uptime: new plugin for checking uptime to see how long the system is running
170 check_curl: check_http replacement based on libcurl
171 check_http: Allow user to specify HTTP method after proxy CONNECT
172 check_http: Add new flag --show-body/-B to print body
173 check_cluster: Added data argument validation
174 check_icmp: Add IPv6 support
175 check_icmp: Automatically detect IP protocol
176 check_icmp: emit error if multiple protocol version
177 check_disk: add support to display inodes usage in perfdata
178 check_hpjd: Added -D option to disable warning on 'out of paper'
179 check_http: support the --show-body/-B flag when --expect is used
180 check_mysql: allow mariadbclient to be used
181 check_tcp: add --sni
182 check_dns: detect unreachable dns service in nslookup output
183
184 FIXES
185 Fix regression where check_dhcp was rereading response in a tight loop
186 check_dns: fix error detection on sles nslookup
187 check_disk_smb: fix timeout issue
188 check_swap: repaired "-n" behaviour
189 check_icmp: Correctly set address_family on lookup
190 check_icmp: Do not overwrite -4,-6 on lookup
191 check_smtp: initializes n before it is used
192 check_dns: fix typo in parameter description
193 check_by_ssh: fix child process leak on timeouts
194 check_mysql: Allow sockets to be specified to -H
195 check_procs: improve command examples for 'at least' processes
196 check_swap: repaired "-n" behaviour
197 check_disk: include -P switch in help
198 check_mailq: restore accidentally removed options
199
2002.2 29th November 2016
4 ENHANCEMENTS 201 ENHANCEMENTS
5 check_snmp's performance data now also includes warning/critical
6 thresholds
7 New check_snmp "-N" option to specify SNMPv3 context name
8 New check_nt "-l" parameters: seconds|minutes|hours|days
9 New check_mailq -s option which tells the plugin to use sudo(8)
10 New -W/-C option for check_ldap to check number of entries (Gerhard Lausser)
11 The check_http -S/--ssl option now accepts the arguments "1.1" and "1.2" 202 The check_http -S/--ssl option now accepts the arguments "1.1" and "1.2"
12 to force TLSv1.1 and TLSv1.2 connections, respectively 203 to force TLSv1.1 and TLSv1.2 connections, respectively
13 The check_http -S/--ssl option now allows for specifying the desired 204 The check_http -S/--ssl option now allows for specifying the desired
14 protocol with a "+" suffix to also accept newer versions 205 protocol with a "+" suffix to also accept newer versions
206 Let check_http check HTTPS web sites via proxies
207 check_http: add timeout to performance data as max value
208 check_http: report certificate expiry date in UTC
209 check_snmp: add IPv6 support
210 check_snmp's performance data now also includes warning/critical
211 thresholds
212 New check_snmp -N option to specify SNMPv3 context name
213 Let check_smtp's -D option imply -S
214 Let check_smtp's -e option match against the full SMTP response
215 check_dig: expected response is now case-insensitive
216 New check_mailq -s option which tells the plugin to use sudo(8)
217 New check_nt -l parameters: seconds|minutes|hours|days
218 New -W/-C option for check_ldap to check number of entries
219 check_users: add support for range thresholds
220 check_fping now auto-detects IPv6 addresses
221 check_radius now supports the radcli library
222 Support OpenSSL 1.1
15 223
16 FIXES 224 FIXES
225 check_http: fix host header port handling
17 Let check_real terminate lines with CRLF when talking to the server, as 226 Let check_real terminate lines with CRLF when talking to the server, as
18 mandated by 2326 227 mandated by RFC 2326
19 Fix check_procs on HP-UX 228 Fix check_procs on HP-UX
20 check_smtp's -e/--expect option can now be combined with -S/--starttls 229 check_smtp's -e/--expect option can now be combined with -S/--starttls
21 Fix incorrect performance data thresholds emitted by check_ups 230 Fix incorrect performance data thresholds emitted by check_ups
231 Don't let check_procs miss some processes on busy Solaris systems
22 232
23 WARNINGS 233 WARNINGS
24 The format of the performance data emitted by check_mrtgtraf has been 234 The format of the performance data emitted by check_mrtgtraf has been
@@ -42,11 +252,10 @@ This file documents the major additions and syntax changes between releases.
42 Fix check_apt's handling of invalid regular expressions 252 Fix check_apt's handling of invalid regular expressions
43 Fix check_real's server response processing 253 Fix check_real's server response processing
44 Fix backslash escaping in check_tcp's --help output 254 Fix backslash escaping in check_tcp's --help output
45 Fix check_procs's unclosed filehandle in pst3 on Solaris
46 255
472.1 15th October 2014 2562.1 15th October 2014
48 ENHANCEMENTS 257 ENHANCEMENTS
49 New check_hpjd -p option for port specification (abrist) 258 New check_hpjd -p option for port specification
50 New ./configure --with-qmail-qstat-command option to specify the path to 259 New ./configure --with-qmail-qstat-command option to specify the path to
51 qmail-qstat(8) 260 qmail-qstat(8)
52 New check_ifstatus -n option to ignore interfaces by name 261 New check_ifstatus -n option to ignore interfaces by name
@@ -54,7 +263,7 @@ This file documents the major additions and syntax changes between releases.
54 New check_mysql -n option to ignore authentication failures 263 New check_mysql -n option to ignore authentication failures
55 Added IP and port or socket name to error messages 264 Added IP and port or socket name to error messages
56 New check_ntp_time -o option to add expected offset 265 New check_ntp_time -o option to add expected offset
57 check_disk shows now troubled partions in verbose mode 266 check_disk shows now troubled partitions in verbose mode
58 check_dig has now support for drill and dig 267 check_dig has now support for drill and dig
59 check_dig has now support for -6 option 268 check_dig has now support for -6 option
60 Add performance data to check_file_age 269 Add performance data to check_file_age
@@ -94,7 +303,7 @@ This file documents the major additions and syntax changes between releases.
94 Don't have check_http's -N option expect an argument 303 Don't have check_http's -N option expect an argument
95 check_ide_smart could disable offline auto tests but could not re-enable them. 304 check_ide_smart could disable offline auto tests but could not re-enable them.
96 For this reason all SMART command modes have been disabled. 305 For this reason all SMART command modes have been disabled.
97 check_dig: fix wrong IPv6 arguments order (Stéphane Bortzmeyer) 306 check_dig: fix wrong IPv6 arguments order
98 check_dig: make sure not to give up too early when a timeout is specified with -t 307 check_dig: make sure not to give up too early when a timeout is specified with -t
99 check_log: don't stumble over log lines that include a "%" character 308 check_log: don't stumble over log lines that include a "%" character
100 check_nt: add UPTIME to perfdata 309 check_nt: add UPTIME to perfdata
@@ -128,15 +337,15 @@ This file documents the major additions and syntax changes between releases.
128 Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page) 337 Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page)
129 Add performance data to check_apt 338 Add performance data to check_apt
130 Add performance data to check_procs 339 Add performance data to check_procs
131 Added -4/-6 options to check_dig (Ville Mattila) 340 Added -4/-6 options to check_dig
132 New check_oracle --connect option to perform real login 341 New check_oracle --connect option to perform real login
133 New check_nagios -t option to override the default timeout 342 New check_nagios -t option to override the default timeout
134 New check_disk -f/--freespace-ignore-reserved option to ignore space reserved for root 343 New check_disk -f/--freespace-ignore-reserved option to ignore space reserved for root
135 New check_disk -N/--include-type option to limit the filesystem types to check 344 New check_disk -N/--include-type option to limit the filesystem types to check
136 Allow for building the plugins in parallel 345 Allow for building the plugins in parallel
137 Add --without-{dbi,ldap,radius} options to ./configure 346 Add --without-{dbi,ldap,radius} options to ./configure
138 Made Verbose output of check_sensors compliant (Gabriele Tozzi) 347 Made Verbose output of check_sensors compliant
139 New switch -E/--extended-perfdata for check_http to print additional performance data (Sebastian Nohn) 348 New switch -E/--extended-perfdata for check_http to print additional performance data
140 New check_http -d option to specify a string to expect within the response headers 349 New check_http -d option to specify a string to expect within the response headers
141 New check_http -J/-K options for client certificate authentication support 350 New check_http -J/-K options for client certificate authentication support
142 Add support for executing queries to check_pgsql 351 Add support for executing queries to check_pgsql
@@ -148,10 +357,10 @@ This file documents the major additions and syntax changes between releases.
148 New check_procs -k option to ignore kernel threads (on Linux) 357 New check_procs -k option to ignore kernel threads (on Linux)
149 Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified 358 Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified
150 Let check_mysql support SSL 359 Let check_mysql support SSL
151 Let check_mysql add perfromance metrics for all checks 360 Let check_mysql add performance metrics for all checks
152 New check_mysql -f option to specify a client options file 361 New check_mysql -f option to specify a client options file
153 New check_mysql -g option to specify a client options group 362 New check_mysql -g option to specify a client options group
154 New check_snmp --offset option to allow for adding/substracting an offset value to sensor data 363 New check_snmp --offset option to allow for adding/subtracting an offset value to sensor data
155 Let check_snmp support an arbitrary number of OIDs 364 Let check_snmp support an arbitrary number of OIDs
156 Let check_ide_smart support NetBSD 365 Let check_ide_smart support NetBSD
157 366
@@ -159,47 +368,47 @@ This file documents the major additions and syntax changes between releases.
159 Change the MAIL FROM command generated by check_smtp to be RFC compliant 368 Change the MAIL FROM command generated by check_smtp to be RFC compliant
160 Fix compilation of check_http without SSL support 369 Fix compilation of check_http without SSL support
161 Fix check_snmp reversed threshold ranges (backward-compatibility) 370 Fix check_snmp reversed threshold ranges (backward-compatibility)
162 Fix check_snmp memory violation when using more than 8 oids (Robin Sonefors) 371 Fix check_snmp memory violation when using more than 8 oids
163 Fix check_apt security regular expression (Alex Bradley) 372 Fix check_apt security regular expression
164 Fix check_http handling extra header (-k) containing semicolons (Richard Leitner) 373 Fix check_http handling extra header (-k) containing semicolons
165 Fix check_apt handling unknown exit codes from apt-get (Richard Leitner) 374 Fix check_apt handling unknown exit codes from apt-get
166 Fix deprecated imports of check_nmap.py (Fabio Rueda) 375 Fix deprecated imports of check_nmap.py
167 376
168 WARNINGS 377 WARNINGS
169 check_http behaviour of -k/--header changed since it does not seperate multiple headers by semicolons anymore. Use multiple -k switches instead. 378 check_http behaviour of -k/--header changed since it does not separate multiple headers by semicolons anymore. Use multiple -k switches instead.
170 check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way) 379 check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way)
171 The contrib directory has been removed from this distribution 380 The contrib directory has been removed from this distribution
172 381
1731.4.16 27th June 2012 3821.4.16 27th June 2012
174 ENHANCEMENTS 383 ENHANCEMENTS
175 check_nt UPTIME accepts warning/critical thresholds (Ryan Kelly) 384 check_nt UPTIME accepts warning/critical thresholds
176 check_disk_smb now allows spaces in share names (#990948, #1370031, Debian #601699) 385 check_disk_smb now allows spaces in share names (#990948, #1370031, Debian #601699)
177 check_http now uses standard threshold functions (enables floating point and ranges) 386 check_http now uses standard threshold functions (enables floating point and ranges)
178 check_http now checks for and prints the certificate cn (hostname) in SSL certificate checks (Stéphane Urbanovski) 387 check_http now checks for and prints the certificate cn (hostname) in SSL certificate checks
179 check_http now supports an optional -S/--ssl value to choose the SSL protocol version (#3066166 - Jason Lunn) 388 check_http now supports an optional -S/--ssl value to choose the SSL protocol version (#3066166)
180 Add perfdata to check_ssh (#3244097 - Marco Beck) 389 Add perfdata to check_ssh (#3244097)
181 New option to check_smtp to ignore failures when sending QUIT (#3358348 - Duncan Ferguson) 390 New option to check_smtp to ignore failures when sending QUIT (#3358348)
182 New check_by_ssh -F option which allows for specifying an alternative ssh_config(5) file (#2895334 - Sven Nierlein) 391 New check_by_ssh -F option which allows for specifying an alternative ssh_config(5) file (#2895334)
183 check_sensors now detects faulty sensors unless --ignore-fault is specified (Jan Wagner) 392 check_sensors now detects faulty sensors unless --ignore-fault is specified
184 utils.sh now provides a check_range function (Alex Griffin) 393 utils.sh now provides a check_range function
185 Improved the performance of check_users (Marc Remy) 394 Improved the performance of check_users
186 Add perfdata to check_disk_smb (Debian #654259 - Charles-Henri Larose) 395 Add perfdata to check_disk_smb (Debian #654259)
187 Updated Nagios::Plugin perl module 396 Updated Nagios::Plugin perl module
188 Add warning threshold to certificate expiration checks of check_tcp/http/smtp (William Leibzon) 397 Add warning threshold to certificate expiration checks of check_tcp/http/smtp
189 Add --perf-oids option for check_snmp (Jochen Bern) 398 Add --perf-oids option for check_snmp
190 399
191 FIXES 400 FIXES
192 Fix check_disk free space calculation if blocksizes differ within a disk group (Bekar - #2973603) 401 Fix check_disk free space calculation if blocksizes differ within a disk group (#2973603)
193 check_disk_smb now handles NT_STATUS_ACCESS_DENIED properly (Debian #601696) 402 check_disk_smb now handles NT_STATUS_ACCESS_DENIED properly (Debian #601696)
194 Make check_snmp work more like v1.4.14 with regard to using special values (Timeticks, STRING) as numeric thresholds 403 Make check_snmp work more like v1.4.14 with regard to using special values (Timeticks, STRING) as numeric thresholds
195 Fix check_ldap overriding the port when --ssl was specified after -p 404 Fix check_ldap overriding the port when --ssl was specified after -p
196 Fix check_procs where regex input of '|' would get displayed in output - now replaced with ',' 405 Fix check_procs where regex input of '|' would get displayed in output - now replaced with ','
197 Fix segfault in check_host when hostname returns multiple IP addresses (Sebastian Harl) 406 Fix segfault in check_host when hostname returns multiple IP addresses
198 Fix check_smtp and check_tcp where duplicate messages were displayed for certificate errors 407 Fix check_smtp and check_tcp where duplicate messages were displayed for certificate errors
199 Fix check_ping's parsing of ping6(1) output (#1894850, Debian #514588, Debian #662638 - Matej Vela) 408 Fix check_ping's parsing of ping6(1) output (#1894850, Debian #514588, Debian #662638)
200 Fix a check_dhcp bug which was triggered by checking Windows 2003 DHCP servers (#3503921) 409 Fix a check_dhcp bug which was triggered by checking Windows 2003 DHCP servers (#3503921)
201 Disable RFC4507 support, to work around SSL negotiation issues with (at least) some Tomcat versions 410 Disable RFC4507 support, to work around SSL negotiation issues with (at least) some Tomcat versions
202 Fix performance data label containing spaces in check_snmp (Jochen Bern) 411 Fix performance data label containing spaces in check_snmp
203 412
2041.4.15 27th July 2010 4131.4.15 27th July 2010
205 ENHANCEMENTS 414 ENHANCEMENTS
@@ -209,30 +418,30 @@ This file documents the major additions and syntax changes between releases.
209 New check_snmp --rate option to store differences between invocations. Saves state in PREFIX/var/{plugin} 418 New check_snmp --rate option to store differences between invocations. Saves state in PREFIX/var/{plugin}
210 check_snmp -l label option now also changes the perfdata label. See WARNINGS 419 check_snmp -l label option now also changes the perfdata label. See WARNINGS
211 check_snmp has an --invert-search option which reverses status of the string and regexp searches 420 check_snmp has an --invert-search option which reverses status of the string and regexp searches
212 check_http now displays the missing search string and the URL in the output when failed (Duncan Ferguson - #2999924) 421 check_http now displays the missing search string and the URL in the output when failed (#2999924)
213 Updated Nagios::Plugin perl module 422 Updated Nagios::Plugin perl module
214 Updated gnulib to June 2010 423 Updated gnulib to June 2010
215 424
216 FIXES 425 FIXES
217 Fix check_ircd binding to wrong interface (#668778) 426 Fix check_ircd binding to wrong interface (#668778)
218 Add proxy-authorization option to check_http (Marcel Kuiper - #1323230, Bryan Irvine - #2863925) 427 Add proxy-authorization option to check_http (#1323230, #2863925)
219 check_icmp now increment the sequence counter in each packet 428 check_icmp now increment the sequence counter in each packet
220 Fix usage of repeated -o options in check_snmp 429 Fix usage of repeated -o options in check_snmp
221 Try to detect arguments passed via --with-ping[6]-command and set options accordingly (#2908236) 430 Try to detect arguments passed via --with-ping[6]-command and set options accordingly (#2908236)
222 Fix memory leak in check_http for large pages (Jimmy Bergman - #2957455) 431 Fix memory leak in check_http for large pages (#2957455)
223 Fix compilation with GCC 2.96 (Konstantin Khomoutov - #2977105) 432 Fix compilation with GCC 2.96 (#2977105)
224 Fix regression introduced in #1867716 where partially valid performance strings would not be printed anymore 433 Fix regression introduced in #1867716 where partially valid performance strings would not be printed anymore
225 Fix regression in check_http ssl checks on some servers - make SNI an option 434 Fix regression in check_http ssl checks on some servers - make SNI an option
226 Fix guest mode support in check_disk_smb 435 Fix guest mode support in check_disk_smb
227 Fix check_disk_smb and check_ircd failures when run via ePN 436 Fix check_disk_smb and check_ircd failures when run via ePN
228 check_ldap now allows for specifying an empty LDAP base 437 check_ldap now allows for specifying an empty LDAP base
229 Fix compilation error of pst3 in Solaris 8 438 Fix compilation error of pst3 in Solaris 8
230 Fix check_radius returning OK on unexpected results (Craig Leres - #2911752) 439 Fix check_radius returning OK on unexpected results (#2911752)
231 Fix translations when extra-opts aren't enabled (Jan Wagner - #2832884) 440 Fix translations when extra-opts aren't enabled (#2832884)
232 Fix parsing of multi-line strings in check_snmp (broken in 1.4.14) and enhance output in such case (#2832451) 441 Fix parsing of multi-line strings in check_snmp (broken in 1.4.14) and enhance output in such case (#2832451)
233 Fix detection of pst3 64-bit compile flags with Sun CC 442 Fix detection of pst3 64-bit compile flags with Sun CC
234 Fix cmd_run overwriting the environment, which would break some commands that needed it 443 Fix cmd_run overwriting the environment, which would break some commands that needed it
235 Allow check_ifstatus to accept version=2c - used to only allow version=2 (Brian Landers) 444 Allow check_ifstatus to accept version=2c - used to only allow version=2
236 Fix examples in check_disk, where it implied was possible to suffix unit values to warn/crit parameters 445 Fix examples in check_disk, where it implied was possible to suffix unit values to warn/crit parameters
237 446
238 WARNINGS 447 WARNINGS
@@ -245,71 +454,71 @@ This file documents the major additions and syntax changes between releases.
245 check_http has options to specify the HTTP method (#2155152) 454 check_http has options to specify the HTTP method (#2155152)
246 check_users thresholds were not working exactly as documented (>= rather than >) 455 check_users thresholds were not working exactly as documented (>= rather than >)
247 Updated tinderbox_build script to point to new tinderbox server 456 Updated tinderbox_build script to point to new tinderbox server
248 check_ifoperstatus -n flag now works as expected (sf.net #1569488) 457 check_ifoperstatus -n flag now works as expected (#1569488)
249 check_ifoperstatus now supports ifType based lookup for ifIndex 458 check_ifoperstatus now supports ifType based lookup for ifIndex
250 check_ups now sends a LOGOUT string (debian bug #387001) 459 check_ups now sends a LOGOUT string (Debian #387001)
251 Extra-opts (C plugins) now allows both '#' and ';' for comments (like N::P) 460 Extra-opts (C plugins) now allows both '#' and ';' for comments (like N::P)
252 Extra-opts (C plugins) does not allow trailing comments anymore (like N::P) 461 Extra-opts (C plugins) does not allow trailing comments anymore (like N::P)
253 Fixed dependency issue on libtap when ./configure --enable-libtap used. Warning: will install libtap 462 Fixed dependency issue on libtap when ./configure --enable-libtap used. Warning: will install libtap
254 Fixed segfault in extra-opts under some circumstance when reading multiple sections 463 Fixed segfault in extra-opts under some circumstance when reading multiple sections
255 Fix long options parsing in check_disk, check_dns, check_mrtg, check_mrtgtraf and check_tcp 464 Fix long options parsing in check_disk, check_dns, check_mrtg, check_mrtgtraf and check_tcp
256 Add missing long options for check_nt (for use with extra-opts) 465 Add missing long options for check_nt (for use with extra-opts)
257 check_icmp now reports min and max round trip time perfdata (Steve Rader) 466 check_icmp now reports min and max round trip time perfdata
258 Fixed check_http bug where additional headers with redirection caused a segfault (Dieter Van de Walle - 2089159) 467 Fixed check_http bug where additional headers with redirection caused a segfault (2089159)
259 check_disk: make autofs mount paths specified with -p before we determine the mount list (Erik Welch) 468 check_disk: make autofs mount paths specified with -p before we determine the mount list
260 Fixed buffer overflow in check_ntp/check_ntp_peer (#1999319, Ubuntu #291265) 469 Fixed buffer overflow in check_ntp/check_ntp_peer (#1999319, Ubuntu #291265)
261 Re-bundled libtap as a built-in library (--enable-libtap): detects system library as pre-1.4.13 and does not install the built-in library anymore 470 Re-bundled libtap as a built-in library (--enable-libtap): detects system library as pre-1.4.13 and does not install the built-in library anymore
262 Fixed check_mrtg returning UNKNOWN instead of OK (bug #2378068) 471 Fixed check_mrtg returning UNKNOWN instead of OK (#2378068)
263 Fixed check_http behaviour: all check are now performed as long as a valid response is returned (sf.net #1460312) 472 Fixed check_http behaviour: all check are now performed as long as a valid response is returned (#1460312)
264 check_http --onredirect=sticky follows using the same IP address (sf.net #2550208) 473 check_http --onredirect=sticky follows using the same IP address (#2550208)
265 check_http --onredirect=stickyport also follows the same port 474 check_http --onredirect=stickyport also follows the same port
266 Fixed coredump from check_nt when invalid drive is specified (#2179754 - Olli Hauer) 475 Fixed coredump from check_nt when invalid drive is specified (#2179754)
267 Fixed crash from check_nt when -H unspecified or given multiple times (sf.net #2731755, debian #521097) 476 Fixed crash from check_nt when -H unspecified or given multiple times (#2731755, Debian #521097)
268 Fixed passing of quotes in OID for check_snmp (#1985230 - Jan Wagner, patch by John Barbuto) 477 Fixed passing of quotes in OID for check_snmp (#1985230)
269 Fixed check_http sending HTTP/1.0 with v1.1 headers (#2638765) 478 Fixed check_http sending HTTP/1.0 with v1.1 headers (#2638765)
270 Fixed check_http not timing-out on redirects 479 Fixed check_http not timing-out on redirects
271 Fixed negate not printing the real timeout in ALRM handler when left to default 480 Fixed negate not printing the real timeout in ALRM handler when left to default
272 negate timeout result is now configurable 481 negate timeout result is now configurable
273 Fixed segfault in check_mysql with old slaves (#2696823 - Oskar Ahner) 482 Fixed segfault in check_mysql with old slaves (#2696823)
274 check_nt can return UNKNOWN on timeouts (-u) 483 check_nt can return UNKNOWN on timeouts (-u)
275 Fixed typos for check_disk (Chris Pepper) 484 Fixed typos for check_disk
276 Fixed check_mysql* not using password set in my.cnf (#2531905 - Ben Timby) - Specify an empty password explicitly if you need to override it. 485 Fixed check_mysql* not using password set in my.cnf (#2531905) - Specify an empty password explicitly if you need to override it.
277 Fixed awk subst.in/subst script path error (#2722832 - Martin Foster) 486 Fixed awk subst.in/subst script path error (#2722832)
278 check_http: Add SSL/TLS hostname extension support (SNI) - (#1939022 - Joe Presbrey) 487 check_http: Add SSL/TLS hostname extension support (SNI) - (#1939022)
279 Fixed wrong perfdata label for output traffic in check_mrtgtraf (#2654308 - Gavin Williams) 488 Fixed wrong perfdata label for output traffic in check_mrtgtraf (#2654308)
280 Fixed check_by_ssh interpretation of quotes in -C parameter (#1985246, #2268675) 489 Fixed check_by_ssh interpretation of quotes in -C parameter (#1985246, #2268675)
281 check_snmp now supports standard threshold ranges and doubles (floating numbers) in thresholds 490 check_snmp now supports standard threshold ranges and doubles (floating numbers) in thresholds
282 check_fping now supports passing target timeout and interval to fping (#2347686 - Martin Foster) 491 check_fping now supports passing target timeout and interval to fping (#2347686)
283 Fixed SNMPv3 behaviour of check_ifoperstatus and check_ifstatus. Added -P to define privprotocol (#2343438 - Robin Schroeder) 492 Fixed SNMPv3 behaviour of check_ifoperstatus and check_ifstatus. Added -P to define privprotocol (#2343438)
284 check_ifoperstatus and check_ifstatus are now more user-friendly in case of missing arguments 493 check_ifoperstatus and check_ifstatus are now more user-friendly in case of missing arguments
285 pst3 compile fix for Sun Studio Compiler (Grant Byers) 494 pst3 compile fix for Sun Studio Compiler
286 495
2871.4.13 25th Sept 2008 4961.4.13 25th Sept 2008
288 Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen) 497 Fix Debian bug #460097: check_http --max-age broken
289 Optimised pst3 for systems with large number of processes (Duncan Ferguson) 498 Optimised pst3 for systems with large number of processes
290 Updated Nagios::Plugin to 0.27 499 Updated Nagios::Plugin to 0.27
291 Fix Debian bug #479013: check_dig's -l is mandatory now (sf.net #1986306) 500 Fix Debian bug #479013: check_dig's -l is mandatory now (#1986306)
292 check_dig now returns CRITICAL instead of WARNING when no answer section is found 501 check_dig now returns CRITICAL instead of WARNING when no answer section is found
293 check_procs now captures stderr in external command and adds to plugin output 502 check_procs now captures stderr in external command and adds to plugin output
294 check_snmp now only prints perfdata for non numeric values (#1867716) 503 check_snmp now only prints perfdata for non numeric values (#1867716)
295 check_icmp now supports packet size modification 504 check_icmp now supports packet size modification
296 check_http -e now accepts a comma-delimited list of expected status codes (Sven Nierlein) 505 check_http -e now accepts a comma-delimited list of expected status codes
297 libtap now included with this distribution for easier testing. Run ./configure with --enable-libtap 506 libtap now included with this distribution for easier testing. Run ./configure with --enable-libtap
298 check_ntp_peer/check_ntp_time used to show port in --help but ignored the argument - now implemented 507 check_ntp_peer/check_ntp_time used to show port in --help but ignored the argument - now implemented
299 Fix possible segfault in check_ntp_peer with deliberately invalid packets 508 Fix possible segfault in check_ntp_peer with deliberately invalid packets
300 509
3011.4.12 27th May 2008 5101.4.12 27th May 2008
302 Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren) 511 Added ./check_nt -v INSTANCES to count number of instances
303 New check_icmp -s option to specify the source IP address 512 New check_icmp -s option to specify the source IP address
304 check_dns now sorts addresses for testing results for more than one returned IP (Matthias Urlichs) 513 check_dns now sorts addresses for testing results for more than one returned IP
305 Fix segfault in check_ntp_time and (deprecated) check_ntp (Bug #1862300) 514 Fix segfault in check_ntp_time and (deprecated) check_ntp (#1862300)
306 check_disk should now work with large file systems (2TB+) on all archs that supports it 515 check_disk should now work with large file systems (2TB+) on all archs that supports it
307 Fixed check_disk disk usage calculation when using --group=NAME (related to bug #1348746) 516 Fixed check_disk disk usage calculation when using --group=NAME (related to #1348746)
308 Fix help text of check_ntp* (Bug #1880095) 517 Fix help text of check_ntp* (#1880095)
309 Fix bugs and flaws in best offset server selection of check_ntp_time and (deprecated) check_ntp 518 Fix bugs and flaws in best offset server selection of check_ntp_time and (deprecated) check_ntp
310 check_ntp_peer now checks for the LI_ALARM flag 519 check_ntp_peer now checks for the LI_ALARM flag
311 Sync to latest Gnulib (includes new floorf function) 520 Sync to latest Gnulib (includes new floorf function)
312 check_pgsql now successfully builds with postgres lib v8.3 (Bug #1878972) 521 check_pgsql now successfully builds with postgres lib v8.3 (#1878972)
313 check_procs now accepts --ereg-argument-array for a regular expression match to the argument array 522 check_procs now accepts --ereg-argument-array for a regular expression match to the argument array
314 Reverted back to using pst3 for Solaris systems. Fixed issues re: -m64 needed to compile on 64bit systems 523 Reverted back to using pst3 for Solaris systems. Fixed issues re: -m64 needed to compile on 64bit systems
315 If applicable, Gettext linked dynamically instead of statically 524 If applicable, Gettext linked dynamically instead of statically
@@ -317,9 +526,9 @@ This file documents the major additions and syntax changes between releases.
317 check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help 526 check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help
318 check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers) 527 check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers)
319 check_mysql and check_radius now try clearing password in processlist just like check_mysql_query 528 check_mysql and check_radius now try clearing password in processlist just like check_mysql_query
320 check_mysql and check_mysql_query now support sockets explicitely (-s, --socket) 529 check_mysql and check_mysql_query now support sockets explicitly (-s, --socket)
321 negate now has the ability to replace the status text as well (-s, --substitute) 530 negate now has the ability to replace the status text as well (-s, --substitute)
322 Added performance data to check_ping (Christian Schneemann) 531 Added performance data to check_ping
323 Added support for --extra-opts in all C plugins (disabled by default, see configure --help) 532 Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
324 Fixed passive option in check_by_ssh 533 Fixed passive option in check_by_ssh
325 On non-skipped stderr, check_by_ssh now returns UNKNOWN or worse (result from command) instead of always UNKNOWN. 534 On non-skipped stderr, check_by_ssh now returns UNKNOWN or worse (result from command) instead of always UNKNOWN.
@@ -338,9 +547,9 @@ This file documents the major additions and syntax changes between releases.
338 is "-1" as the default range starts at 0. See Examples in --help output. 547 is "-1" as the default range starts at 0. See Examples in --help output.
339 Fixed broken usage2 in check_snmp and check_cluster 548 Fixed broken usage2 in check_snmp and check_cluster
340 check_cluster now accepts all valid characters in its thresholds ("-", "@", "~") 549 check_cluster now accepts all valid characters in its thresholds ("-", "@", "~")
341 Fixed check_disk reporting OK if disk usage grows over 100% (bug #1348746). 550 Fixed check_disk reporting OK if disk usage grows over 100% (#1348746).
342 The problem happens to be in Gnulib but a workaround have been implemented in check_disk.c 551 The problem happens to be in Gnulib but a workaround have been implemented in check_disk.c
343 Fixed check_load argument handling when not passing triplets (bug #1831890) 552 Fixed check_load argument handling when not passing triplets (#1831890)
344 Fixed buffer overflow in check_snmp (CVE-2007-5623) 553 Fixed buffer overflow in check_snmp (CVE-2007-5623)
345 Tinderbox builds now runs tests in a verbose mode 554 Tinderbox builds now runs tests in a verbose mode
346 Updated Nagios::Plugin to 0.22 555 Updated Nagios::Plugin to 0.22
@@ -357,7 +566,7 @@ This file documents the major additions and syntax changes between releases.
357 New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too. 566 New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
358 Thus accessibility of remote filesystems can be checked without any threshold comparison. 567 Thus accessibility of remote filesystems can be checked without any threshold comparison.
359 Check_disk's --help now prints some examples for the new features introduced in 1.4.8 568 Check_disk's --help now prints some examples for the new features introduced in 1.4.8
360 New check_disk -i/-I option to ignore pathes/partitions based on regular expressions 569 New check_disk -i/-I option to ignore paths/partitions based on regular expressions
361 New check_disk -A option to select all filesystems explicitly 570 New check_disk -A option to select all filesystems explicitly
362 WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments 571 WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
363 Passing -E after -p or -r results in UNKNOWN state, now 572 Passing -E after -p or -r results in UNKNOWN state, now
@@ -406,7 +615,7 @@ This file documents the major additions and syntax changes between releases.
406 Fixed MKINSTALLDIRS problem in po/ 615 Fixed MKINSTALLDIRS problem in po/
407 ./configure now detects if possible to compile check_mysql 616 ./configure now detects if possible to compile check_mysql
408 Fixed broken HELO in check_smtp 617 Fixed broken HELO in check_smtp
409 check_icmp now allows to set a minimum number of hosts required for successs (-m) 618 check_icmp now allows to set a minimum number of hosts required for success (-m)
410 check_icmp fix for *BSD when running for long time 619 check_icmp fix for *BSD when running for long time
411 check_ping times out 1 second quicker if host is unreachable 620 check_ping times out 1 second quicker if host is unreachable
412 Root plugins installed with world executable 621 Root plugins installed with world executable
@@ -464,4 +673,3 @@ This file documents the major additions and syntax changes between releases.
464 check_swap % thresholds changed to measure amount free, instead of amount used 673 check_swap % thresholds changed to measure amount free, instead of amount used
465 check_disk syntax changes for -p, -m/-M, defaults to MB instead of kB 674 check_disk syntax changes for -p, -m/-M, defaults to MB instead of kB
466 check_procs -C expects no path for the command name 675 check_procs -C expects no path for the command name
467
diff --git a/NP-VERSION-GEN b/NP-VERSION-GEN
index dd82bf11..c353b1d1 100755
--- a/NP-VERSION-GEN
+++ b/NP-VERSION-GEN
@@ -6,7 +6,7 @@
6SRC_ROOT=`dirname $0` 6SRC_ROOT=`dirname $0`
7 7
8NPVF=NP-VERSION-FILE 8NPVF=NP-VERSION-FILE
9DEF_VER=2.1.2.git 9DEF_VER=2.3git
10 10
11LF=' 11LF='
12' 12'
diff --git a/NPTest.pm b/NPTest.pm
index f72ed2df..9b25ac3e 100644
--- a/NPTest.pm
+++ b/NPTest.pm
@@ -53,8 +53,8 @@ developer to interactively request test parameter information from the
53user. The user can accept the developer's default value or reply "none" 53user. The user can accept the developer's default value or reply "none"
54which will then be returned as "" for the test to skip if appropriate. 54which will then be returned as "" for the test to skip if appropriate.
55 55
56If a parameter needs to be entered and the test is run without a tty 56If a parameter needs to be entered and the test is run without a tty
57attached (such as a cronjob), the parameter will be assigned as if it 57attached (such as a cronjob), the parameter will be assigned as if it
58was "none". Tests can check for the parameter and skip if not set. 58was "none". Tests can check for the parameter and skip if not set.
59 59
60Responses are stored in an external, file-based cache so subsequent test 60Responses are stored in an external, file-based cache so subsequent test
@@ -62,17 +62,6 @@ runs will use these values. The user is able to change the values by
62amending the values in the file /var/tmp/NPTest.cache, or by setting 62amending the values in the file /var/tmp/NPTest.cache, or by setting
63the appropriate environment variable before running the test. 63the appropriate environment variable before running the test.
64 64
65The option exists to store parameters in a scoped means, allowing a
66test harness to a localise a parameter should the need arise. This
67allows a parameter of the same name to exist in a test harness
68specific scope, while not affecting the globally scoped parameter. The
69scoping identifier is the name of the test harness sans the trailing
70".t". All cache searches first look to a scoped parameter before
71looking for the parameter at global scope. Thus for a test harness
72called "check_disk.t" requesting the parameter "mountpoint_valid", the
73cache is first searched for "check_disk"/"mountpoint_valid", if this
74fails, then a search is conducted for "mountpoint_valid".
75
76To facilitate quick testing setup, it is possible to accept all the 65To facilitate quick testing setup, it is possible to accept all the
77developer provided defaults by setting the environment variable 66developer provided defaults by setting the environment variable
78"NPTEST_ACCEPTDEFAULT" to "1" (or any other perl truth value). Note 67"NPTEST_ACCEPTDEFAULT" to "1" (or any other perl truth value). Note
@@ -162,14 +151,14 @@ of testing against a set of desired exit status values.
162=item * 151=item *
163 152
164Firstly, if C<$desiredExitStatus> is a reference to an array of exit 153Firstly, if C<$desiredExitStatus> is a reference to an array of exit
165stati, if the actual exit status of the command is present in the 154statuses, if the actual exit status of the command is present in the
166array, it is used in the call to C<Test::ok(...)> when testing the 155array, it is used in the call to C<Test::ok(...)> when testing the
167exit status. 156exit status.
168 157
169=item * 158=item *
170 159
171Alternatively, if C<$desiredExitStatus> is a reference to a hash of 160Alternatively, if C<$desiredExitStatus> is a reference to a hash of
172exit stati (mapped to the strings "continue" or "skip"), similar 161exit statuses(mapped to the strings "continue" or "skip"), similar
173processing to the above occurs with the side affect of determining if 162processing to the above occurs with the side affect of determining if
174any generated output testing should proceed. Note: only the string 163any generated output testing should proceed. Note: only the string
175"skip" will result in generated output testing being skipped. 164"skip" will result in generated output testing being skipped.
@@ -218,7 +207,7 @@ under the same terms as the Monitoring Plugins release.
218 207
219my( %CACHE ) = (); 208my( %CACHE ) = ();
220 209
221# I'm not really sure wether to house a site-specific cache inside 210# I'm not really sure whether to house a site-specific cache inside
222# or outside of the extracted source / build tree - lets default to outside 211# or outside of the extracted source / build tree - lets default to outside
223my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} ) 212my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} )
224 ? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd"; 213 ? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd";
@@ -249,26 +238,26 @@ sub checkCmd
249 { 238 {
250 if ( scalar( grep { $_ == $exitStatus } @{$desiredExitStatus} ) ) 239 if ( scalar( grep { $_ == $exitStatus } @{$desiredExitStatus} ) )
251 { 240 {
252 $desiredExitStatus = $exitStatus; 241 $desiredExitStatus = $exitStatus;
253 } 242 }
254 else 243 else
255 { 244 {
256 $desiredExitStatus = -1; 245 $desiredExitStatus = -1;
257 } 246 }
258 } 247 }
259 elsif ( ref $desiredExitStatus eq "HASH" ) 248 elsif ( ref $desiredExitStatus eq "HASH" )
260 { 249 {
261 if ( exists( ${$desiredExitStatus}{$exitStatus} ) ) 250 if ( exists( ${$desiredExitStatus}{$exitStatus} ) )
262 { 251 {
263 if ( defined( ${$desiredExitStatus}{$exitStatus} ) ) 252 if ( defined( ${$desiredExitStatus}{$exitStatus} ) )
264 { 253 {
265 $testOutput = ${$desiredExitStatus}{$exitStatus}; 254 $testOutput = ${$desiredExitStatus}{$exitStatus};
266 } 255 }
267 $desiredExitStatus = $exitStatus; 256 $desiredExitStatus = $exitStatus;
268 } 257 }
269 else 258 else
270 { 259 {
271 $desiredExitStatus = -1; 260 $desiredExitStatus = -1;
272 } 261 }
273 } 262 }
274 263
@@ -327,78 +316,51 @@ sub skipMsg
327 return $testStatus; 316 return $testStatus;
328} 317}
329 318
330sub getTestParameter 319sub getTestParameter {
331{ 320 my($param, $description, $default) = @_;
332 my( $param, $envvar, $default, $brief, $scoped );
333 my $new_style;
334 if (scalar @_ <= 3) {
335 ($param, $brief, $default) = @_;
336 $envvar = $param;
337 $new_style = 1;
338 } else {
339 ( $param, $envvar, $default, $brief, $scoped ) = @_;
340 $new_style = 0;
341 }
342
343 # Apply default values for optional arguments
344 $scoped = ( defined( $scoped ) && $scoped );
345
346 my $testharness = basename( (caller(0))[1], ".t" ); # used for scoping
347 321
348 if ( defined( $envvar ) && exists( $ENV{$envvar} ) && $ENV{$envvar} ) 322 if($param !~ m/^NP_[A-Z0-9_]+$/mx) {
349 { 323 die("parameter should be all uppercase and start with NP_ (requested from ".(caller(0))[1].")");
350 return $ENV{$envvar};
351 } 324 }
352 325
353 my $cachedValue = SearchCache( $param, $testharness ); 326 return $ENV{$param} if $ENV{$param};
354 if ( defined( $cachedValue ) ) 327
355 { 328 my $cachedValue = SearchCache($param);
356 # This save required to convert to new style because the key required is 329 if(defined $cachedValue) {
357 # changing to the environment variable
358 if ($new_style == 0) {
359 SetCacheParameter( $envvar, undef, $cachedValue );
360 }
361 return $cachedValue; 330 return $cachedValue;
362 } 331 }
363 332
364 my $defaultValid = ( defined( $default ) && $default ); 333 if($ENV{'NPTEST_ACCEPTDEFAULT'}) {
365 my $autoAcceptDefault = ( exists( $ENV{'NPTEST_ACCEPTDEFAULT'} ) && $ENV{'NPTEST_ACCEPTDEFAULT'} ); 334 return $default if $default;
366 335 return "";
367 if ( $autoAcceptDefault && $defaultValid )
368 {
369 return $default;
370 } 336 }
371 337
372 # Set "none" if no terminal attached (eg, tinderbox build servers when new variables set) 338 # Set "none" if no terminal attached (eg, tinderbox build servers when new variables set)
373 return "" unless (-t STDIN); 339 return "" unless (-t STDIN);
374 340
375 my $userResponse = ""; 341 my $userResponse = "";
376 342 while($userResponse eq "") {
377 while ( $userResponse eq "" )
378 {
379 print STDERR "\n"; 343 print STDERR "\n";
380 print STDERR "Test Harness : $testharness\n"; 344 print STDERR "Test File : ".(caller(0))[1]."\n";
381 print STDERR "Test Parameter : $param\n"; 345 print STDERR "Test Parameter : $param\n";
382 print STDERR "Environment Variable : $envvar\n" if ($param ne $envvar); 346 print STDERR "Description : $description\n";
383 print STDERR "Brief Description : $brief\n"; 347 print STDERR "Enter value (or 'none') ", ($default ? "[${default}]" : "[]"), " => ";
384 print STDERR "Enter value (or 'none') ", ($defaultValid ? "[${default}]" : "[]"), " => ";
385 $userResponse = <STDIN>; 348 $userResponse = <STDIN>;
386 $userResponse = "" if ! defined( $userResponse ); # Handle EOF 349 $userResponse = "" if ! defined( $userResponse ); # Handle EOF
387 chomp( $userResponse ); 350 chomp($userResponse);
388 if ( $defaultValid && $userResponse eq "" ) 351 if($default && $userResponse eq "") {
389 {
390 $userResponse = $default; 352 $userResponse = $default;
391 } 353 }
392 } 354 }
393 355
394 print STDERR "\n"; 356 print STDERR "\n";
395 357
396 if ($userResponse =~ /^(na|none)$/) { 358 if($userResponse =~ /^(na|none)$/) {
397 $userResponse = ""; 359 $userResponse = "";
398 } 360 }
399 361
400 # define all user responses at global scope 362 # store user responses
401 SetCacheParameter( $param, ( $scoped ? $testharness : undef ), $userResponse ); 363 SetCacheParameter($param, $userResponse);
402 364
403 return $userResponse; 365 return $userResponse;
404} 366}
@@ -407,37 +369,20 @@ sub getTestParameter
407# Internal Cache Management Functions 369# Internal Cache Management Functions
408# 370#
409 371
410sub SearchCache 372sub SearchCache {
411{ 373 my($param) = @_;
412 my( $param, $scope ) = @_;
413 374
414 LoadCache(); 375 LoadCache();
415 376
416 if ( exists( $CACHE{$scope} ) && exists( $CACHE{$scope}{$param} ) ) 377 if(exists $CACHE{$param}) {
417 {
418 return $CACHE{$scope}{$param};
419 }
420
421 if ( exists( $CACHE{$param} ) )
422 {
423 return $CACHE{$param}; 378 return $CACHE{$param};
424 } 379 }
425 return undef; # Need this to say "nothing found" 380 return undef; # Need this to say "nothing found"
426} 381}
427 382
428sub SetCacheParameter 383sub SetCacheParameter {
429{ 384 my($param, $value) = @_;
430 my( $param, $scope, $value ) = @_; 385 $CACHE{$param} = $value;
431
432 if ( defined( $scope ) )
433 {
434 $CACHE{$scope}{$param} = $value;
435 }
436 else
437 {
438 $CACHE{$param} = $value;
439 }
440
441 SaveCache(); 386 SaveCache();
442} 387}
443 388
@@ -475,6 +420,11 @@ sub SaveCache
475 delete $CACHE{'_cache_loaded_'}; 420 delete $CACHE{'_cache_loaded_'};
476 my $oldFileContents = delete $CACHE{'_original_cache'}; 421 my $oldFileContents = delete $CACHE{'_original_cache'};
477 422
423 # clean up old style params
424 for my $key (keys %CACHE) {
425 delete $CACHE{$key} if $key !~ m/^NP_[A-Z0-9_]+$/mx;
426 }
427
478 my($dataDumper) = new Data::Dumper([\%CACHE]); 428 my($dataDumper) = new Data::Dumper([\%CACHE]);
479 $dataDumper->Terse(1); 429 $dataDumper->Terse(1);
480 $dataDumper->Sortkeys(1); 430 $dataDumper->Sortkeys(1);
@@ -486,7 +436,7 @@ sub SaveCache
486 if($oldFileContents ne $data) { 436 if($oldFileContents ne $data) {
487 my($fileHandle) = new IO::File; 437 my($fileHandle) = new IO::File;
488 if (!$fileHandle->open( "> ${CACHEFILENAME}")) { 438 if (!$fileHandle->open( "> ${CACHEFILENAME}")) {
489 print STDERR "NPTest::LoadCache() : Problem saving ${CACHEFILENAME} : $!\n"; 439 print STDERR "NPTest::SaveCache() : Problem saving ${CACHEFILENAME} : $!\n";
490 return; 440 return;
491 } 441 }
492 print $fileHandle $data; 442 print $fileHandle $data;
@@ -542,10 +492,10 @@ sub DetermineTestHarnessDirectory
542 push ( @dirs, "./tests"); 492 push ( @dirs, "./tests");
543 } 493 }
544 494
545 if ( @dirs > 0 ) 495 if ( @dirs > 0 )
546 { 496 {
547 return @dirs; 497 return @dirs;
548 } 498 }
549 499
550 # To be honest I don't understand which case satisfies the 500 # To be honest I don't understand which case satisfies the
551 # original code in test.pl : when $tstdir == `pwd` w.r.t. 501 # original code in test.pl : when $tstdir == `pwd` w.r.t.
@@ -611,73 +561,73 @@ sub TestsFrom
611 561
612# All the new object oriented stuff below 562# All the new object oriented stuff below
613 563
614sub new { 564sub new {
615 my $type = shift; 565 my $type = shift;
616 my $self = {}; 566 my $self = {};
617 return bless $self, $type; 567 return bless $self, $type;
618} 568}
619 569
620# Accessors 570# Accessors
621sub return_code { 571sub return_code {
622 my $self = shift; 572 my $self = shift;
623 if (@_) { 573 if (@_) {
624 return $self->{return_code} = shift; 574 return $self->{return_code} = shift;
625 } else { 575 } else {
626 return $self->{return_code}; 576 return $self->{return_code};
627 } 577 }
628} 578}
629sub output { 579sub output {
630 my $self = shift; 580 my $self = shift;
631 if (@_) { 581 if (@_) {
632 return $self->{output} = shift; 582 return $self->{output} = shift;
633 } else { 583 } else {
634 return $self->{output}; 584 return $self->{output};
635 } 585 }
636} 586}
637 587
638sub perf_output { 588sub perf_output {
639 my $self = shift; 589 my $self = shift;
640 $_ = $self->{output}; 590 $_ = $self->{output};
641 /\|(.*)$/; 591 /\|(.*)$/;
642 return $1 || ""; 592 return $1 || "";
643} 593}
644 594
645sub only_output { 595sub only_output {
646 my $self = shift; 596 my $self = shift;
647 $_ = $self->{output}; 597 $_ = $self->{output};
648 /(.*?)\|/; 598 /(.*?)\|/;
649 return $1 || ""; 599 return $1 || "";
650} 600}
651 601
652sub testCmd { 602sub testCmd {
653 my $class = shift; 603 my $class = shift;
654 my $command = shift or die "No command passed to testCmd"; 604 my $command = shift or die "No command passed to testCmd";
655 my $timeout = shift || 120; 605 my $timeout = shift || 120;
656 my $object = $class->new; 606 my $object = $class->new;
657 607
658 local $SIG{'ALRM'} = sub { die("timeout in command: $command"); }; 608 local $SIG{'ALRM'} = sub { die("timeout in command: $command"); };
659 alarm($timeout); # no test should take longer than 120 seconds 609 alarm($timeout); # no test should take longer than 120 seconds
660 610
661 my $output = `$command`; 611 my $output = `$command`;
662 $object->return_code($? >> 8); 612 $object->return_code($? >> 8);
663 $_ = $? & 127; 613 $_ = $? & 127;
664 if ($_) { 614 if ($_) {
665 die "Got signal $_ for command $command"; 615 die "Got signal $_ for command $command";
666 } 616 }
667 chomp $output; 617 chomp $output;
668 $object->output($output); 618 $object->output($output);
669 619
670 alarm(0); 620 alarm(0);
671 621
672 my ($pkg, $file, $line) = caller(0); 622 my ($pkg, $file, $line) = caller(0);
673 print "Testing: $command", $/; 623 print "Testing: $command", $/;
674 if ($ENV{'NPTEST_DEBUG'}) { 624 if ($ENV{'NPTEST_DEBUG'}) {
675 print "testCmd: Called from line $line in $file", $/; 625 print "testCmd: Called from line $line in $file", $/;
676 print "Output: ", $object->output, $/; 626 print "Output: ", $object->output, $/;
677 print "Return code: ", $object->return_code, $/; 627 print "Return code: ", $object->return_code, $/;
678 } 628 }
679 629
680 return $object; 630 return $object;
681} 631}
682 632
683# do we have ipv6 633# do we have ipv6
diff --git a/README b/README
index beb77690..71b4d37c 100644
--- a/README
+++ b/README
@@ -10,7 +10,7 @@ Monitoring Plugins
10* For information on detailed changes that have been made or plugins 10* For information on detailed changes that have been made or plugins
11 that have been added, read the `ChangeLog` file. 11 that have been added, read the `ChangeLog` file.
12 12
13* Some plugins require that you have additional programs and/or 13* Some plugins require that you have additional programs or
14 libraries installed on your system before they can be used. Plugins that 14 libraries installed on your system before they can be used. Plugins that
15 are dependent on other programs/libraries that are missing are usually not 15 are dependent on other programs/libraries that are missing are usually not
16 compiled. Read the `REQUIREMENTS` file for more information. 16 compiled. Read the `REQUIREMENTS` file for more information.
@@ -19,7 +19,7 @@ Monitoring Plugins
19 the basic guidelines for development will provide detailed help when 19 the basic guidelines for development will provide detailed help when
20 invoked with the `-h` or `--help` options. 20 invoked with the `-h` or `--help` options.
21 21
22You can check for the latest plugins at: 22You can check the latest plugins at:
23 23
24* <https://www.monitoring-plugins.org/> 24* <https://www.monitoring-plugins.org/>
25 25
diff --git a/REQUIREMENTS b/REQUIREMENTS
index 303fd62b..f3b1c01d 100644
--- a/REQUIREMENTS
+++ b/REQUIREMENTS
@@ -11,6 +11,22 @@ check_ldaps, check_http --ssl, check_tcp --ssl, check_smtp --starttls
11 - Requires openssl or gnutls libraries for SSL connections 11 - Requires openssl or gnutls libraries for SSL connections
12 http://www.openssl.org, http://www.gnu.org/software/gnutls 12 http://www.openssl.org, http://www.gnu.org/software/gnutls
13 13
14check_curl:
15 - Requires libcurl 7.15.2 or later
16 http://www.haxx.se
17 - --ssl/-S and -C requires OpenSSL for certificate checks, otherwise
18 libcurl must be quite new to support CURLINFO_CERTINFO with
19 GnuTLS and NSS libraries:
20 - 7.42.0 or newer for GnuTLS
21 - 7.34.0 or newer for NSS
22 GnuTLS is known to create problems on some distributions with
23 self-signed certificate chains
24 http://www.openssl.org, http://www.gnu.org/software/gnutls,
25 http://www.mozilla.org/projects/security/pki/nss/,
26 other SSL implementations are currently not supported
27 - uriparser 0.7.5 or later
28 https://uriparser.github.io/
29
14check_fping: 30check_fping:
15 - Requires the fping utility distributed with SATAN. Either 31 - Requires the fping utility distributed with SATAN. Either
16 download and install SATAN or grab the fping program from 32 download and install SATAN or grab the fping program from
@@ -50,16 +66,18 @@ check_dbi:
50 http://libdbi.sourceforge.net/ 66 http://libdbi.sourceforge.net/
51 67
52check_radius: 68check_radius:
53 - Requires the FreeRADIUS Client library available from: 69 - Requires the radcli library available from:
70 http://radcli.github.io/radcli/
71 - As an alternative, the FreeRADIUS Client library may be used:
54 http://freeradius.org/freeradius-client/ 72 http://freeradius.org/freeradius-client/
55 - As an alternative, the radiusclient-ng library may be used: 73 - As another alternative, the radiusclient-ng library may be used:
56 http://sourceforge.net/projects/radiusclient-ng.berlios/ 74 http://sourceforge.net/projects/radiusclient-ng.berlios/
57 - This plugin also works with the original radiusclient library from 75 - This plugin also works with the original radiusclient library from
58 ftp://ftp.cityline.net/pub/radiusclient/ 76 ftp://ftp.cityline.net/pub/radiusclient/
59 RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2 77 RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2
60 However, you probably want to use the FreeRADIUS Client library, as 78 However, you probably want to use either radcli or the FreeRADIUS
61 both radiusclient and radiusclient-ng are unmaintained and have known 79 Client library, as both radiusclient and radiusclient-ng are
62 issues. 80 unmaintained and have known issues.
63 81
64check_snmp: 82check_snmp:
65 - Requires the NET-SNMP package available from 83 - Requires the NET-SNMP package available from
diff --git a/ROADMAP b/ROADMAP
index 28f9b31c..6378ec74 100644
--- a/ROADMAP
+++ b/ROADMAP
@@ -7,7 +7,7 @@ With that done, it's time to figure out what we are doing for release
71.3 development. I have a few ideas. Maybe others do as well. 71.3 development. I have a few ideas. Maybe others do as well.
8 8
9DOCUMENTATION: 9DOCUMENTATION:
10 We pretty much have decieded that we will doing something along 10 We pretty much have decided that we will doing something along
11 the lines of a literate programming model. So far, we have site 11 the lines of a literate programming model. So far, we have site
12 documentation in DocBook. I have some ideas here, which I will 12 documentation in DocBook. I have some ideas here, which I will
13 discuss in a separate thread. 13 discuss in a separate thread.
@@ -39,9 +39,9 @@ inconsistent mess and I'd love to ditch it. I only created it to
39satisfy people that wanted reverse compatibility and did not have 39satisfy people that wanted reverse compatibility and did not have
40GNU getopt. 40GNU getopt.
41 41
42Bu I would like to urge that all standard plugins contain 42But I would like to urge that all standard plugins contain
43validate_arguments(). I think this will help convey the idea that 43validate_arguments(). I think this will help convey the idea that
44validations hould be done, even if we don't insist on the specific 44validations should be done, even if we don't insist on the specific
45extent that each plugin must do that validation. 45extent that each plugin must do that validation.
46 46
47This is the set of standard options I envision: 47This is the set of standard options I envision:
@@ -59,7 +59,7 @@ Reserved:
59-F, --file = STRING (usually input) 59-F, --file = STRING (usually input)
60-O, --output = STRING (output file) 60-O, --output = STRING (output file)
61 61
62Recommended, but not reserverd: 62Recommended, but not reserved:
63 63
64-I, --ipaddress = STRING 64-I, --ipaddress = STRING
65-C, --community = STRING 65-C, --community = STRING
@@ -69,7 +69,7 @@ Recommended, but not reserverd:
69-P, --port = INT 69-P, --port = INT
70-u, --url = STRING (also --username if --url is not needed) 70-u, --url = STRING (also --username if --url is not needed)
71 71
72I am suggesting that port alway be '-P' (uppercase) -- we are 72I am suggesting that port always be '-P' (uppercase) -- we are
73currently inconsistent in that regard. 73currently inconsistent in that regard.
74 74
75I am also adding '-q' for silent running. This is totally self 75I am also adding '-q' for silent running. This is totally self
@@ -87,12 +87,12 @@ Programming:
87 length character assignments, at least to the extent possible, 87 length character assignments, at least to the extent possible,
88 from the C-based plugins. To that end, I have made strscpy and 88 from the C-based plugins. To that end, I have made strscpy and
89 friends in utils.c -- I'd like to deploy them. I have comments 89 friends in utils.c -- I'd like to deploy them. I have comments
90 that there is alot of duplicated code, and techniques used that 90 that there is a lot of duplicated code, and techniques used that
91 should be cleaned up. Details in a separate thread. 91 should be cleaned up. Details in a separate thread.
92 92
93Remote checks: 93Remote checks:
94 I have a proposal in hand to incorporate ssh check into spopen() 94 I have a proposal in hand to incorporate ssh check into spopen()
95 so that remote machine checks can be seemless. A nice idea, but 95 so that remote machine checks can be seamless. A nice idea, but
96 complex enough to require discussion. Another thread. 96 complex enough to require discussion. Another thread.
97 97
98I also have a wish list, and I'm sure I've forgot some items. I'll 98I also have a wish list, and I'm sure I've forgot some items. I'll
diff --git a/THANKS.in b/THANKS.in
index 59c90feb..b1327440 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -336,3 +336,73 @@ Nick Peelman
336Sebastian Herbszt 336Sebastian Herbszt
337Christopher Schultz 337Christopher Schultz
338Matthias Hähnel 338Matthias Hähnel
339Roberto Greiner
340Peter Radcliffe
341John C. Frickson
342Christian Kujau
343Christopher Odenbach
344Adrian Murphy
345Andreas Seemueller
346Andrew Berglund
347Bernd Apfel
348Daniel Stirnimann
349Elan Ruusamäe
350Greg Cox
351Johannes Engel
352Laurent Licour
353Matthieu Kermagoret
354Michael Melcher
355Sven Geggus
356Thomas Kurschel
357Yannick Charton
358Nicolai Søborg
359Rolf Eike Beer
360Bernd Arnold
361Andreas Baumann
362Tobias Wolf
363Lars Michelsen
364Vincent Danjean
365Kostyantyn Hushchyn
366Christian Tacke
367Alexander A. Klimov
368Vadim Zhukov
369Bernard Spil
370Christian Schmidt
371Guido Falsi
372Harald Koch
373Iustin Pop
374Jacob Hansen
375Jean-François Rameau
376Karol Babioch
377Lucas Bussey
378Marc Sánchez
379Markus Frosch
380Michael Kraus
381Patrick Rauscher
382Prathamesh Bhanuse
383Valentin Vidic
384Barak Shohat
385Florian Lohoff
386Stefan Bethke
387Tim Gates
388Tomas Mozes
389Aksel Sjögren
390Andreas Motl
391Claudio Kuenzler
392Daniel Uhlmann
393Eric Wunderlin
394Geert Hendrickx
395Ken D
396Klaus Ethgen
397Lee Clemens
398Linda Guo
399Peter Newman
400Tobias Fiebig
401Tobias Wiese
402Wolfgang Karall-Ahlborn
403Danijel Tasov
404Robert Bohne
405Wolfgang Nieder
406andrew bezella
407Lorenz Gruenwald
408John Morrissey
diff --git a/build-aux/config.rpath b/build-aux/config.rpath
index c38b914d..1e2595ff 100755
--- a/build-aux/config.rpath
+++ b/build-aux/config.rpath
@@ -2,7 +2,7 @@
2# Output a system dependent set of variables, describing how to set the 2# Output a system dependent set of variables, describing how to set the
3# run time search path of shared libraries in an executable. 3# run time search path of shared libraries in an executable.
4# 4#
5# Copyright 1996-2013 Free Software Foundation, Inc. 5# Copyright 1996-2023 Free Software Foundation, Inc.
6# Taken from GNU libtool, 2001 6# Taken from GNU libtool, 2001
7# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 7# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8# 8#
@@ -367,15 +367,11 @@ else
367 dgux*) 367 dgux*)
368 hardcode_libdir_flag_spec='-L$libdir' 368 hardcode_libdir_flag_spec='-L$libdir'
369 ;; 369 ;;
370 freebsd2.2*) 370 freebsd2.[01]*)
371 hardcode_libdir_flag_spec='-R$libdir'
372 hardcode_direct=yes
373 ;;
374 freebsd2*)
375 hardcode_direct=yes 371 hardcode_direct=yes
376 hardcode_minus_L=yes 372 hardcode_minus_L=yes
377 ;; 373 ;;
378 freebsd* | dragonfly*) 374 freebsd* | dragonfly* | midnightbsd*)
379 hardcode_libdir_flag_spec='-R$libdir' 375 hardcode_libdir_flag_spec='-R$libdir'
380 hardcode_direct=yes 376 hardcode_direct=yes
381 ;; 377 ;;
@@ -548,13 +544,11 @@ case "$host_os" in
548 dgux*) 544 dgux*)
549 library_names_spec='$libname$shrext' 545 library_names_spec='$libname$shrext'
550 ;; 546 ;;
551 freebsd* | dragonfly*) 547 freebsd[23].*)
552 case "$host_os" in 548 library_names_spec='$libname$shrext$versuffix'
553 freebsd[123]*) 549 ;;
554 library_names_spec='$libname$shrext$versuffix' ;; 550 freebsd* | dragonfly* | midnightbsd*)
555 *) 551 library_names_spec='$libname$shrext'
556 library_names_spec='$libname$shrext' ;;
557 esac
558 ;; 552 ;;
559 gnu*) 553 gnu*)
560 library_names_spec='$libname$shrext' 554 library_names_spec='$libname$shrext'
diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
index 33f642a0..2e8548d3 100644
--- a/build-aux/ltmain.sh
+++ b/build-aux/ltmain.sh
@@ -189,7 +189,7 @@ func_basename ()
189# to NONDIR_REPLACEMENT. 189# to NONDIR_REPLACEMENT.
190# value returned in "$func_dirname_result" 190# value returned in "$func_dirname_result"
191# basename: Compute filename of FILE. 191# basename: Compute filename of FILE.
192# value retuned in "$func_basename_result" 192# value returned in "$func_basename_result"
193# Implementation must be kept synchronized with func_dirname 193# Implementation must be kept synchronized with func_dirname
194# and func_basename. For efficiency, we do not delegate to 194# and func_basename. For efficiency, we do not delegate to
195# those functions but instead duplicate the functionality here. 195# those functions but instead duplicate the functionality here.
@@ -522,7 +522,7 @@ func_mkdir_p ()
522 # While some portion of DIR does not yet exist... 522 # While some portion of DIR does not yet exist...
523 while test ! -d "$my_directory_path"; do 523 while test ! -d "$my_directory_path"; do
524 # ...make a list in topmost first order. Use a colon delimited 524 # ...make a list in topmost first order. Use a colon delimited
525 # list incase some portion of path contains whitespace. 525 # list in case some portion of path contains whitespace.
526 my_dir_list="$my_directory_path:$my_dir_list" 526 my_dir_list="$my_directory_path:$my_dir_list"
527 527
528 # If the last portion added has no slash in it, the list is done 528 # If the last portion added has no slash in it, the list is done
@@ -4394,7 +4394,7 @@ EOF
4394 { 4394 {
4395 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4395 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396 namespace, but it is not one of the ones we know about and 4396 namespace, but it is not one of the ones we know about and
4397 have already dealt with, above (inluding dump-script), then 4397 have already dealt with, above (including dump-script), then
4398 report an error. Otherwise, targets might begin to believe 4398 report an error. Otherwise, targets might begin to believe
4399 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4399 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400 namespace. The first time any user complains about this, we'll 4400 namespace. The first time any user complains about this, we'll
diff --git a/build-aux/snippet/_Noreturn.h b/build-aux/snippet/_Noreturn.h
deleted file mode 100644
index c44ad89b..00000000
--- a/build-aux/snippet/_Noreturn.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#if !defined _Noreturn && __STDC_VERSION__ < 201112
2# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
3 || 0x5110 <= __SUNPRO_C)
4# define _Noreturn __attribute__ ((__noreturn__))
5# elif 1200 <= _MSC_VER
6# define _Noreturn __declspec (noreturn)
7# else
8# define _Noreturn
9# endif
10#endif
diff --git a/build-aux/snippet/warn-on-use.h b/build-aux/snippet/warn-on-use.h
deleted file mode 100644
index 1736a1bd..00000000
--- a/build-aux/snippet/warn-on-use.h
+++ /dev/null
@@ -1,109 +0,0 @@
1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
18 for FUNCTION which will then trigger a compiler warning containing
19 the text of "literal string" anywhere that function is called, if
20 supported by the compiler. If the compiler does not support this
21 feature, the macro expands to an unused extern declaration.
22
23 This macro is useful for marking a function as a potential
24 portability trap, with the intent that "literal string" include
25 instructions on the replacement function that should be used
26 instead. However, one of the reasons that a function is a
27 portability trap is if it has the wrong signature. Declaring
28 FUNCTION with a different signature in C is a compilation error, so
29 this macro must use the same type as any existing declaration so
30 that programs that avoid the problematic FUNCTION do not fail to
31 compile merely because they included a header that poisoned the
32 function. But this implies that _GL_WARN_ON_USE is only safe to
33 use if FUNCTION is known to already have a declaration. Use of
34 this macro implies that there must not be any other macro hiding
35 the declaration of FUNCTION; but undefining FUNCTION first is part
36 of the poisoning process anyway (although for symbols that are
37 provided only via a macro, the result is a compilation error rather
38 than a warning containing "literal string"). Also note that in
39 C++, it is only safe to use if FUNCTION has no overloads.
40
41 For an example, it is possible to poison 'getline' by:
42 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
43 [getline]) in configure.ac, which potentially defines
44 HAVE_RAW_DECL_GETLINE
45 - adding this code to a header that wraps the system <stdio.h>:
46 #undef getline
47 #if HAVE_RAW_DECL_GETLINE
48 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
49 "not universally present; use the gnulib module getline");
50 #endif
51
52 It is not possible to directly poison global variables. But it is
53 possible to write a wrapper accessor function, and poison that
54 (less common usage, like &environ, will cause a compilation error
55 rather than issue the nice warning, but the end result of informing
56 the developer about their portability problem is still achieved):
57 #if HAVE_RAW_DECL_ENVIRON
58 static char ***rpl_environ (void) { return &environ; }
59 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
60 # undef environ
61 # define environ (*rpl_environ ())
62 #endif
63 */
64#ifndef _GL_WARN_ON_USE
65
66# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
67/* A compiler attribute is available in gcc versions 4.3.0 and later. */
68# define _GL_WARN_ON_USE(function, message) \
69extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
70# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
71/* Verify the existence of the function. */
72# define _GL_WARN_ON_USE(function, message) \
73extern __typeof__ (function) function
74# else /* Unsupported. */
75# define _GL_WARN_ON_USE(function, message) \
76_GL_WARN_EXTERN_C int _gl_warn_on_use
77# endif
78#endif
79
80/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
81 is like _GL_WARN_ON_USE (function, "string"), except that the function is
82 declared with the given prototype, consisting of return type, parameters,
83 and attributes.
84 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
85 not work in this case. */
86#ifndef _GL_WARN_ON_USE_CXX
87# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
88# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
89extern rettype function parameters_and_attributes \
90 __attribute__ ((__warning__ (msg)))
91# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
92/* Verify the existence of the function. */
93# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
94extern rettype function parameters_and_attributes
95# else /* Unsupported. */
96# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
97_GL_WARN_EXTERN_C int _gl_warn_on_use
98# endif
99#endif
100
101/* _GL_WARN_EXTERN_C declaration;
102 performs the declaration with C linkage. */
103#ifndef _GL_WARN_EXTERN_C
104# if defined __cplusplus
105# define _GL_WARN_EXTERN_C extern "C"
106# else
107# define _GL_WARN_EXTERN_C extern
108# endif
109#endif
diff --git a/config_test/child_test.c b/config_test/child_test.c
index 4bf85049..2add3bcf 100644
--- a/config_test/child_test.c
+++ b/config_test/child_test.c
@@ -30,7 +30,7 @@ int main(){
30 /* pipefd[1] is for writing to the pipe. We want the output 30 /* pipefd[1] is for writing to the pipe. We want the output
31 * that used to go to the standard output (file descriptor 1) 31 * that used to go to the standard output (file descriptor 1)
32 * to be written to the pipe. The following command does this, 32 * to be written to the pipe. The following command does this,
33 * creating a new file descripter 1 (the lowest available) 33 * creating a new file descriptor 1 (the lowest available)
34 * that writes where pipefd[1] goes. */ 34 * that writes where pipefd[1] goes. */
35 dup (pipefd[1]); /* points pipefd at file descriptor */ 35 dup (pipefd[1]); /* points pipefd at file descriptor */
36 /* the child isn't going to read from the pipe, so 36 /* the child isn't going to read from the pipe, so
diff --git a/configure.ac b/configure.ac
index 0a554af6..e6a40d3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,11 @@
1dnl Process this file with autoconf to produce a configure script. 1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.59) 2AC_PREREQ(2.64)
3AC_INIT(monitoring-plugins,2.1.2) 3AC_INIT(monitoring-plugins,2.3git)
4AC_CONFIG_SRCDIR(NPTest.pm) 4AC_CONFIG_SRCDIR(NPTest.pm)
5AC_CONFIG_FILES([gl/Makefile]) 5AC_CONFIG_FILES([gl/Makefile])
6AC_CONFIG_AUX_DIR(build-aux) 6AC_CONFIG_AUX_DIR(build-aux)
7AM_INIT_AUTOMAKE([1.8.3]) 7AM_INIT_AUTOMAKE([1.8.3])
8AM_SILENT_RULES([yes])
8AM_MAINTAINER_MODE([enable]) 9AM_MAINTAINER_MODE([enable])
9AC_CONFIG_HEADERS([config.h]) 10AC_CONFIG_HEADERS([config.h])
10AC_CANONICAL_HOST 11AC_CANONICAL_HOST
@@ -273,26 +274,33 @@ AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plug
273dnl Check for radius libraries 274dnl Check for radius libraries
274AS_IF([test "x$with_radius" != "xno"], [ 275AS_IF([test "x$with_radius" != "xno"], [
275 _SAVEDLIBS="$LIBS" 276 _SAVEDLIBS="$LIBS"
276 AC_CHECK_LIB(freeradius-client,rc_read_config) 277 AC_CHECK_LIB(radcli,rc_read_config)
277 if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then 278 if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then
278 EXTRAS="$EXTRAS check_radius\$(EXEEXT)" 279 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
279 RADIUSLIBS="-lfreeradius-client" 280 RADIUSLIBS="-lradcli"
280 AC_SUBST(RADIUSLIBS) 281 AC_SUBST(RADIUSLIBS)
281 else 282 else
282 AC_CHECK_LIB(radiusclient-ng,rc_read_config) 283 AC_CHECK_LIB(freeradius-client,rc_read_config)
283 if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then 284 if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
284 EXTRAS="$EXTRAS check_radius\$(EXEEXT)" 285 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
285 RADIUSLIBS="-lradiusclient-ng" 286 RADIUSLIBS="-lfreeradius-client"
286 AC_SUBST(RADIUSLIBS) 287 AC_SUBST(RADIUSLIBS)
287 else 288 else
288 AC_CHECK_LIB(radiusclient,rc_read_config) 289 AC_CHECK_LIB(radiusclient-ng,rc_read_config)
289 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then 290 if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
290 EXTRAS="$EXTRAS check_radius\$(EXEEXT)" 291 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
291 RADIUSLIBS="-lradiusclient" 292 RADIUSLIBS="-lradiusclient-ng"
292 AC_SUBST(RADIUSLIBS) 293 AC_SUBST(RADIUSLIBS)
293 else 294 else
294 AC_MSG_WARN([Skipping radius plugin]) 295 AC_CHECK_LIB(radiusclient,rc_read_config)
295 AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) 296 if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
297 EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
298 RADIUSLIBS="-lradiusclient"
299 AC_SUBST(RADIUSLIBS)
300 else
301 AC_MSG_WARN([Skipping radius plugin])
302 AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
303 fi
296 fi 304 fi
297 fi 305 fi
298 fi 306 fi
@@ -320,6 +328,25 @@ AS_IF([test "x$with_ldap" != "xno"], [
320 LIBS="$_SAVEDLIBS" 328 LIBS="$_SAVEDLIBS"
321]) 329])
322 330
331
332AC_ARG_WITH([systemd], [AS_HELP_STRING([--without-systemd], [Skips systemd support])])
333
334dnl Check for libsystemd
335AS_IF([test "x$with_systemd" != "xno"], [
336 _SAVEDLIBS="$LIBS"
337 AC_CHECK_LIB(systemd,sd_get_sessions,,,-lsystemd)
338 if test "$ac_cv_lib_systemd_sd_get_sessions" = "yes"; then
339 SYSTEMDLIBS="-lsystemd"
340 SYSTEMDINCLUDE=""
341 AC_SUBST(SYSTEMDLIBS)
342 AC_SUBST(SYSTEMDINCLUDE)
343 else
344 AC_MSG_WARN([Skipping systemd support])
345 fi
346 LIBS="$_SAVEDLIBS"
347])
348
349
323dnl Check for headers used by check_ide_smart 350dnl Check for headers used by check_ide_smart
324case $host in 351case $host in
325 *linux*) 352 *linux*)
@@ -378,12 +405,48 @@ if test "$ac_cv_header_wtsapi32_h" = "yes"; then
378 AC_SUBST(WTSAPI32LIBS) 405 AC_SUBST(WTSAPI32LIBS)
379fi 406fi
380 407
408_can_enable_check_curl=no
409dnl Check for cURL library
410LIBCURL_CHECK_CONFIG(yes, 7.15.2, [
411 _can_enable_check_curl=yes
412 LIBCURLINCLUDE="$LIBCURL_CPPFLAGS"
413 LIBCURLLIBS="$LIBCURL"
414 LIBCURLCFLAGS="$LIBCURL_CPPFLAGS"
415 AC_SUBST(LIBCURLINCLUDE)
416 AC_SUBST(LIBCURLLIBS)
417 AC_SUBST(LIBCURLCFLAGS)
418 ], [
419 _can_enable_check_curl=no
420 AC_MSG_WARN([Skipping curl plugin])
421 AC_MSG_WARN([install libcurl libs to compile this plugin (see REQUIREMENTS).])
422])
423
424dnl Check for uriparser library
425URIPARSER_CHECK(yes, 0.7.5, [
426 URIPARSERINCLUDE="$URIPARSER_CPPFLAGS"
427 URIPARSERLIBS="$URIPARSER"
428 URIPARSERCFLAGS="$URIPARSER_CPPFLAGS"
429 AC_SUBST(URIPARSERINCLUDE)
430 AC_SUBST(URIPARSERLIBS)
431 AC_SUBST(URIPARSERCFLAGS)
432 ], [
433 _can_enable_check_curl=no
434 AC_MSG_WARN([Skipping curl plugin])
435 AC_MSG_WARN([install the uriparser library to compile this plugin (see REQUIREMENTS).])
436])
437
438dnl prerequisites met, enable the plugin
439if test x$_can_enable_check_curl = xyes; then
440 EXTRAS="$EXTRAS check_curl\$(EXEEXT)"
441fi
442AC_CONFIG_FILES([plugins/picohttpparser/Makefile])
443
381dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface 444dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface
382if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no" 445if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
383then 446then
384 AC_PATH_PROG(PATH_TO_WHO,who) 447 AC_PATH_PROG(PATH_TO_WHO,who)
385 448
386 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null] 449 if [$PATH_TO_WHO -q 2>/dev/null | grep -E -i "^# users=[0-9]+$" >/dev/null]
387 then 450 then
388 ac_cv_path_to_who="$PATH_TO_WHO -q" 451 ac_cv_path_to_who="$PATH_TO_WHO -q"
389 else 452 else
@@ -493,15 +556,15 @@ if ! test x"$with_openssl" = x"no"; then
493 dnl Check for crypto lib 556 dnl Check for crypto lib
494 _SAVEDLIBS="$LIBS" 557 _SAVEDLIBS="$LIBS"
495 LIBS="-L${with_openssl}/lib" 558 LIBS="-L${with_openssl}/lib"
496 AC_CHECK_LIB(crypto,CRYPTO_lock) 559 AC_CHECK_LIB(crypto,CRYPTO_new_ex_data)
497 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then 560 if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
498 dnl Check for SSL lib 561 dnl Check for SSL lib
499 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto) 562 AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
500 fi 563 fi
501 LIBS="$_SAVEDLIBS" 564 LIBS="$_SAVEDLIBS"
502 565
503 dnl test headers and libs to decide whether check_http should use SSL 566 dnl test headers and libs to decide whether check_http should use SSL
504 if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then 567 if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
505 if test "$ac_cv_lib_ssl_main" = "yes"; then 568 if test "$ac_cv_lib_ssl_main" = "yes"; then
506 if test "$FOUNDINCLUDE" = "yes"; then 569 if test "$FOUNDINCLUDE" = "yes"; then
507 FOUNDOPENSSL="yes" 570 FOUNDOPENSSL="yes"
@@ -558,7 +621,6 @@ AC_C_CONST
558AC_STRUCT_TM 621AC_STRUCT_TM
559AC_TYPE_PID_T 622AC_TYPE_PID_T
560AC_TYPE_SIZE_T 623AC_TYPE_SIZE_T
561AC_TYPE_SIGNAL
562 624
563AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[ 625AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
564AC_TRY_LINK([#include <stdarg.h> 626AC_TRY_LINK([#include <stdarg.h>
@@ -732,7 +794,7 @@ dnl Removing this for the moment - Ton
732dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation 794dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
733dnl Limitation that command name is not available 795dnl Limitation that command name is not available
734dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \ 796dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
735dnl egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null 797dnl grep -E -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
736dnl then 798dnl then
737dnl ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]" 799dnl ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
738dnl ac_cv_ps_command="/usr/ucb/ps -alxwwn" 800dnl ac_cv_ps_command="/usr/ucb/ps -alxwwn"
@@ -740,10 +802,20 @@ dnl ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT
740dnl ac_cv_ps_cols=8 802dnl ac_cv_ps_cols=8
741dnl AC_MSG_RESULT([$ac_cv_ps_command]) 803dnl AC_MSG_RESULT([$ac_cv_ps_command])
742 804
805dnl This one is the exact same test as the next one but includes etime
806elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
807 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null
808then
809 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
810 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'"
811 ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
812 ac_cv_ps_cols=10
813 AC_MSG_RESULT([$ac_cv_ps_command])
814
743dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. 815dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
744dnl so test for this first... 816dnl so test for this first...
745elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 817elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
746 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null 818 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
747then 819then
748 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 820 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
749 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'" 821 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -755,7 +827,7 @@ dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
755dnl Should also work for FreeBSD 5.2.1 and 5.3 827dnl Should also work for FreeBSD 5.2.1 and 5.3
756dnl STAT UCOMM VSZ RSS USER PPID COMMAND 828dnl STAT UCOMM VSZ RSS USER PPID COMMAND
757elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 829elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
758 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null 830 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
759then 831then
760 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 832 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
761 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'" 833 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -767,7 +839,7 @@ dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
767dnl Limitation: Only first 16 chars returned for ucomm field 839dnl Limitation: Only first 16 chars returned for ucomm field
768dnl Must come before ps -weo 840dnl Must come before ps -weo
769elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ 841elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
770 egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null 842 grep -E -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
771then 843then
772 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 844 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
773 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" 845 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
@@ -777,7 +849,7 @@ then
777 849
778dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND 850dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND
779elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ 851elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
780 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null 852 grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
781then 853then
782 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" 854 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
783 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'" 855 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
@@ -787,7 +859,7 @@ then
787 859
788dnl FreeBSD 860dnl FreeBSD
789elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \ 861elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
790 egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null 862 grep -E -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
791then 863then
792 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 864 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
793 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'" 865 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
@@ -797,7 +869,7 @@ then
797 869
798dnl BSD-like mode in RH 6.1 870dnl BSD-like mode in RH 6.1
799elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ 871elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
800 egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 872 grep -E -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
801then 873then
802 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 874 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
803 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'" 875 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
@@ -809,7 +881,7 @@ dnl SunOS 4.1.3:
809dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND 881dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND
810dnl Need the head -1 otherwise test will work because arguments are found 882dnl Need the head -1 otherwise test will work because arguments are found
811elif ps -laxnwww 2>/dev/null | head -1 | \ 883elif ps -laxnwww 2>/dev/null | head -1 | \
812 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null 884 grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
813then 885then
814 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" 886 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
815 ac_cv_ps_command="$PATH_TO_PS -laxnwww" 887 ac_cv_ps_command="$PATH_TO_PS -laxnwww"
@@ -822,7 +894,7 @@ dnl FLAGS UID PID PPID PRI NI SIZE RSS WCHAN STA TTY TIME COMMA
822dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2] 894dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2]
823dnl 895dnl
824elif ps laxnwww 2>/dev/null | \ 896elif ps laxnwww 2>/dev/null | \
825 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null 897 grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
826then 898then
827 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" 899 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
828 ac_cv_ps_command="$PATH_TO_PS laxnwww" 900 ac_cv_ps_command="$PATH_TO_PS laxnwww"
@@ -832,7 +904,7 @@ then
832 904
833dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) 905dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
834elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 906elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
835 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null 907 grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
836then 908then
837 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 909 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
838 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'" 910 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -845,7 +917,7 @@ dnl Has /usr/bin/ps and /sbin/ps - force sbin version
845dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 917dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
846dnl of 1500). Will need big changes to check_procs to support 918dnl of 1500). Will need big changes to check_procs to support
847elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \ 919elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
848 egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null 920 grep -E -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
849then 921then
850 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]" 922 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
851 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'" 923 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
@@ -854,7 +926,7 @@ then
854 AC_MSG_RESULT([$ac_cv_ps_command]) 926 AC_MSG_RESULT([$ac_cv_ps_command])
855 927
856elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \ 928elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
857 egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null 929 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
858then 930then
859 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 931 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
860 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'" 932 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
@@ -864,7 +936,7 @@ then
864 936
865dnl AIX 4.3.3 and 5.1 do not have an rss field 937dnl AIX 4.3.3 and 5.1 do not have an rss field
866elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \ 938elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
867 egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null 939 grep -E -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
868then 940then
869 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]" 941 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
870 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'" 942 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
@@ -874,18 +946,18 @@ then
874 946
875dnl Solaris 2.6 947dnl Solaris 2.6
876elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \ 948elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
877 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 949 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
878then 950then
879 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 951 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
880 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'" 952 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
881 # There must be no space between the %s and %n due to a wierd problem in sscanf where 953 # There must be no space between the %s and %n due to a weird problem in sscanf where
882 # it will return %n as longer than the line length 954 # it will return %n as longer than the line length
883 ac_cv_ps_format="%s %d %d %d %d %d %f %s%n" 955 ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
884 ac_cv_ps_cols=9 956 ac_cv_ps_cols=9
885 AC_MSG_RESULT([$ac_cv_ps_command]) 957 AC_MSG_RESULT([$ac_cv_ps_command])
886 958
887elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \ 959elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
888 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 960 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
889then 961then
890 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 962 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
891 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'" 963 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
@@ -894,7 +966,7 @@ then
894 AC_MSG_RESULT([$ac_cv_ps_command]) 966 AC_MSG_RESULT([$ac_cv_ps_command])
895 967
896elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ 968elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
897 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 969 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
898then 970then
899 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 971 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
900 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'" 972 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
@@ -904,7 +976,7 @@ then
904 976
905dnl wonder who takes state instead of stat 977dnl wonder who takes state instead of stat
906elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \ 978elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
907 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 979 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
908then 980then
909 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 981 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
910 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'" 982 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
@@ -914,7 +986,7 @@ then
914 986
915dnl IRIX 53 987dnl IRIX 53
916elif ps -el 2>/dev/null | \ 988elif ps -el 2>/dev/null | \
917 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 989 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
918then 990then
919 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]" 991 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
920 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)" 992 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
@@ -924,7 +996,7 @@ then
924 996
925dnl IRIX 63 997dnl IRIX 63
926elif ps -el 2>/dev/null | \ 998elif ps -el 2>/dev/null | \
927 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 999 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
928then 1000then
929 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1001 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
930 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)" 1002 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
@@ -937,7 +1009,7 @@ dnl S UID RUID USER RUSER PID PPID VSZ %CPU COMMAND
937dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X 1009dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X
938dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit 1010dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit
939elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \ 1011elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \
940 egrep -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null 1012 grep -E -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
941then 1013then
942 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]" 1014 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
943 ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'" 1015 ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'"
@@ -949,7 +1021,7 @@ dnl AIX 4.1:
949dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD 1021dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
950dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper 1022dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper
951elif ps -el 2>/dev/null | \ 1023elif ps -el 2>/dev/null | \
952 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 1024 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
953then 1025then
954 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1026 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
955 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)" 1027 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
@@ -959,7 +1031,7 @@ then
959 1031
960dnl AIX? 1032dnl AIX?
961elif ps glaxen 2>/dev/null | \ 1033elif ps glaxen 2>/dev/null | \
962 egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null 1034 grep -E -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
963then 1035then
964 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" 1036 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
965 ac_cv_ps_command="$PATH_TO_PS glaxen" 1037 ac_cv_ps_command="$PATH_TO_PS glaxen"
@@ -973,7 +1045,7 @@ dnl Some truncation will happen in UCOMM column
973dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND 1045dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND
974dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon 1046dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon
975elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \ 1047elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
976 egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null 1048 grep -E -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
977then 1049then
978 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'" 1050 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
979 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]" 1051 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
@@ -983,7 +1055,7 @@ then
983 1055
984dnl UnixWare 1056dnl UnixWare
985elif ps -Al 2>/dev/null | \ 1057elif ps -Al 2>/dev/null | \
986 egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null 1058 grep -E -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
987then 1059then
988 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1060 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
989 ac_cv_ps_command="$PATH_TO_PS -Al" 1061 ac_cv_ps_command="$PATH_TO_PS -Al"
@@ -1009,6 +1081,10 @@ if test -n "$ac_cv_ps_varlist" ; then
1009 AC_DEFINE(PS_USES_PROCETIME,"yes", 1081 AC_DEFINE(PS_USES_PROCETIME,"yes",
1010 [Whether the ps utility uses the "procetime" field]) 1082 [Whether the ps utility uses the "procetime" field])
1011 fi 1083 fi
1084 if echo "$ac_cv_ps_varlist" | grep "procpcpu" >/dev/null; then
1085 AC_DEFINE(PS_USES_PROCPCPU,"yes",
1086 [Whether the ps utility uses the "procpcpu" field])
1087 fi
1012fi 1088fi
1013 1089
1014AC_PATH_PROG(PATH_TO_PING,ping) 1090AC_PATH_PROG(PATH_TO_PING,ping)
@@ -1047,14 +1123,22 @@ then
1047 1123
1048elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1124elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1049 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \ 1125 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1050 egrep -i "^round-trip|^rtt" >/dev/null 1126 grep -E -i "^round-trip|^rtt" >/dev/null
1051then 1127then
1052 with_ping_command="$PATH_TO_PING -n -U -c %d %s" 1128 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1053 ac_cv_ping_packets_first=yes 1129 ac_cv_ping_packets_first=yes
1054 AC_MSG_RESULT([$with_ping_command]) 1130 AC_MSG_RESULT([$with_ping_command])
1055 1131
1132elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1133 grep -E -i "^round-trip|^rtt" >/dev/null
1134then
1135 # check if -4 is supported - issue #1550
1136 with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s"
1137 ac_cv_ping_packets_first=yes
1138 ac_cv_ping_has_timeout=yes
1139 AC_MSG_RESULT([$with_ping_command])
1056elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \ 1140elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1057 egrep -i "^round-trip|^rtt" >/dev/null 1141 grep -E -i "^round-trip|^rtt" >/dev/null
1058then 1142then
1059 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s" 1143 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
1060 ac_cv_ping_packets_first=yes 1144 ac_cv_ping_packets_first=yes
@@ -1062,52 +1146,52 @@ then
1062 AC_MSG_RESULT([$with_ping_command]) 1146 AC_MSG_RESULT([$with_ping_command])
1063 1147
1064elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \ 1148elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1065 egrep -i "^round-trip|^rtt" >/dev/null 1149 grep -E -i "^round-trip|^rtt" >/dev/null
1066then 1150then
1067 with_ping_command="$PATH_TO_PING -n -U -c %d %s" 1151 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1068 ac_cv_ping_packets_first=yes 1152 ac_cv_ping_packets_first=yes
1069 AC_MSG_RESULT([$with_ping_command]) 1153 AC_MSG_RESULT([$with_ping_command])
1070 1154
1071elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \ 1155elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1072 egrep -i "^round-trip|^rtt" >/dev/null 1156 grep -E -i "^round-trip|^rtt" >/dev/null
1073then 1157then
1074 with_ping_command="$PATH_TO_PING -n -c %d %s" 1158 with_ping_command="$PATH_TO_PING -n -c %d %s"
1075 ac_cv_ping_packets_first=yes 1159 ac_cv_ping_packets_first=yes
1076 AC_MSG_RESULT([$with_ping_command]) 1160 AC_MSG_RESULT([$with_ping_command])
1077 1161
1078elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \ 1162elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1079 egrep -i "^round-trip|^rtt" >/dev/null 1163 grep -E -i "^round-trip|^rtt" >/dev/null
1080then 1164then
1081 with_ping_command="$PATH_TO_PING -n %s -c %d" 1165 with_ping_command="$PATH_TO_PING -n %s -c %d"
1082 AC_MSG_RESULT([$with_ping_command]) 1166 AC_MSG_RESULT([$with_ping_command])
1083 1167
1084elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \ 1168elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1085 egrep -i "^round-trip|^rtt" >/dev/null 1169 grep -E -i "^round-trip|^rtt" >/dev/null
1086then 1170then
1087 with_ping_command="$PATH_TO_PING %s -n %d" 1171 with_ping_command="$PATH_TO_PING %s -n %d"
1088 AC_MSG_RESULT([$with_ping_command]) 1172 AC_MSG_RESULT([$with_ping_command])
1089 1173
1090elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \ 1174elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1091 egrep -i "^round-trip|^rtt" >/dev/null 1175 grep -E -i "^round-trip|^rtt" >/dev/null
1092then 1176then
1093 with_ping_command="$PATH_TO_PING -n -s %s 56 %d" 1177 with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1094 AC_MSG_RESULT([$with_ping_command]) 1178 AC_MSG_RESULT([$with_ping_command])
1095 1179
1096elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \ 1180elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1097 egrep -i "^round-trip|^rtt" >/dev/null 1181 grep -E -i "^round-trip|^rtt" >/dev/null
1098then 1182then
1099 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d" 1183 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1100 AC_MSG_RESULT([$with_ping_command]) 1184 AC_MSG_RESULT([$with_ping_command])
1101 1185
1102elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \ 1186elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1103 egrep -i "^round-trip|^rtt" >/dev/null 1187 grep -E -i "^round-trip|^rtt" >/dev/null
1104then 1188then
1105 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s" 1189 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1106 ac_cv_ping_packets_first=yes 1190 ac_cv_ping_packets_first=yes
1107 AC_MSG_RESULT([$with_ping_command]) 1191 AC_MSG_RESULT([$with_ping_command])
1108 1192
1109elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \ 1193elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1110 egrep -i "^round-trip|^rtt" >/dev/null 1194 grep -E -i "^round-trip|^rtt" >/dev/null
1111then 1195then
1112 with_ping_command="$PATH_TO_PING -n -c %d %s" 1196 with_ping_command="$PATH_TO_PING -n -c %d %s"
1113 ac_cv_ping_packets_first=yes 1197 ac_cv_ping_packets_first=yes
@@ -1163,14 +1247,14 @@ elif [[ "z$ac_cv_uname_o" = "zCygwin" -a "x$PATH_TO_PING" != "x" ]]; then
1163elif test "x$PATH_TO_PING6" != "x"; then 1247elif test "x$PATH_TO_PING6" != "x"; then
1164 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1248 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1165 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \ 1249 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1166 egrep -i "^round-trip|^rtt" >/dev/null 1250 grep -E -i "^round-trip|^rtt" >/dev/null
1167 then 1251 then
1168 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s" 1252 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1169 ac_cv_ping6_packets_first=yes 1253 ac_cv_ping6_packets_first=yes
1170 AC_MSG_RESULT([$with_ping6_command]) 1254 AC_MSG_RESULT([$with_ping6_command])
1171 1255
1172 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \ 1256 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1173 egrep -i "^round-trip|^rtt" >/dev/null 1257 grep -E -i "^round-trip|^rtt" >/dev/null
1174 then 1258 then
1175 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s" 1259 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1176 ac_cv_ping6_packets_first=yes 1260 ac_cv_ping6_packets_first=yes
@@ -1178,52 +1262,52 @@ elif test "x$PATH_TO_PING6" != "x"; then
1178 AC_MSG_RESULT([$with_ping6_command]) 1262 AC_MSG_RESULT([$with_ping6_command])
1179 1263
1180 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \ 1264 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1181 egrep -i "^round-trip|^rtt" >/dev/null 1265 grep -E -i "^round-trip|^rtt" >/dev/null
1182 then 1266 then
1183 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s" 1267 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1184 ac_cv_ping6_packets_first=yes 1268 ac_cv_ping6_packets_first=yes
1185 AC_MSG_RESULT([$with_ping6_command]) 1269 AC_MSG_RESULT([$with_ping6_command])
1186 1270
1187 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \ 1271 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1188 egrep -i "^round-trip|^rtt" >/dev/null 1272 grep -E -i "^round-trip|^rtt" >/dev/null
1189 then 1273 then
1190 with_ping6_command="$PATH_TO_PING6 -n -c %d %s" 1274 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1191 ac_cv_ping6_packets_first=yes 1275 ac_cv_ping6_packets_first=yes
1192 AC_MSG_RESULT([$with_ping6_command]) 1276 AC_MSG_RESULT([$with_ping6_command])
1193 1277
1194 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \ 1278 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1195 egrep -i "^round-trip|^rtt" >/dev/null 1279 grep -E -i "^round-trip|^rtt" >/dev/null
1196 then 1280 then
1197 with_ping6_command="$PATH_TO_PING6 -n %s -c %d" 1281 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1198 AC_MSG_RESULT([$with_ping6_command]) 1282 AC_MSG_RESULT([$with_ping6_command])
1199 1283
1200 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \ 1284 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1201 egrep -i "^round-trip|^rtt" >/dev/null 1285 grep -E -i "^round-trip|^rtt" >/dev/null
1202 then 1286 then
1203 with_ping6_command="$PATH_TO_PING6 %s -n %d" 1287 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1204 AC_MSG_RESULT([$with_ping6_command]) 1288 AC_MSG_RESULT([$with_ping6_command])
1205 1289
1206 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \ 1290 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1207 egrep -i "^round-trip|^rtt" >/dev/null 1291 grep -E -i "^round-trip|^rtt" >/dev/null
1208 then 1292 then
1209 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d" 1293 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1210 AC_MSG_RESULT([$with_ping6_command]) 1294 AC_MSG_RESULT([$with_ping6_command])
1211 1295
1212 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \ 1296 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1213 egrep -i "^round-trip|^rtt" >/dev/null 1297 grep -E -i "^round-trip|^rtt" >/dev/null
1214 then 1298 then
1215 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d" 1299 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1216 AC_MSG_RESULT([$with_ping6_command]) 1300 AC_MSG_RESULT([$with_ping6_command])
1217 1301
1218 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \ 1302 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1219 egrep -i "^round-trip|^rtt" >/dev/null 1303 grep -E -i "^round-trip|^rtt" >/dev/null
1220 then 1304 then
1221 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s" 1305 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1222 ac_cv_ping6_packets_first=yes 1306 ac_cv_ping6_packets_first=yes
1223 AC_MSG_RESULT([$with_ping_command]) 1307 AC_MSG_RESULT([$with_ping_command])
1224 1308
1225 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \ 1309 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1226 egrep -i "^round-trip|^rtt" >/dev/null 1310 grep -E -i "^round-trip|^rtt" >/dev/null
1227 then 1311 then
1228 with_ping6_command="$PATH_TO_PING6 -n -c %d %s" 1312 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1229 ac_cv_ping6_packets_first=yes 1313 ac_cv_ping6_packets_first=yes
@@ -1234,59 +1318,59 @@ elif test "x$PATH_TO_PING6" != "x"; then
1234elif test "x$PATH_TO_PING" != "x"; then 1318elif test "x$PATH_TO_PING" != "x"; then
1235 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1319 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1236 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \ 1320 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1237 egrep -i "^round-trip|^rtt" >/dev/null 1321 grep -E -i "^round-trip|^rtt" >/dev/null
1238 then 1322 then
1239 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s" 1323 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1240 ac_cv_ping6_packets_first=yes 1324 ac_cv_ping6_packets_first=yes
1241 AC_MSG_RESULT([$with_ping6_command]) 1325 AC_MSG_RESULT([$with_ping6_command])
1242 1326
1243 elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \ 1327 elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1244 egrep -i "^round-trip|^rtt" >/dev/null 1328 grep -E -i "^round-trip|^rtt" >/dev/null
1245 then 1329 then
1246 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s" 1330 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1247 ac_cv_ping6_packets_first=yes 1331 ac_cv_ping6_packets_first=yes
1248 AC_MSG_RESULT([$with_ping6_command]) 1332 AC_MSG_RESULT([$with_ping6_command])
1249 1333
1250 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \ 1334 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1251 egrep -i "^round-trip|^rtt" >/dev/null 1335 grep -E -i "^round-trip|^rtt" >/dev/null
1252 then 1336 then
1253 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s" 1337 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1254 ac_cv_ping6_packets_first=yes 1338 ac_cv_ping6_packets_first=yes
1255 AC_MSG_RESULT([$with_ping6_command]) 1339 AC_MSG_RESULT([$with_ping6_command])
1256 1340
1257 elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \ 1341 elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1258 egrep -i "^round-trip|^rtt" >/dev/null 1342 grep -E -i "^round-trip|^rtt" >/dev/null
1259 then 1343 then
1260 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d" 1344 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1261 AC_MSG_RESULT([$with_ping6_command]) 1345 AC_MSG_RESULT([$with_ping6_command])
1262 1346
1263 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \ 1347 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1264 egrep -i "^round-trip|^rtt" >/dev/null 1348 grep -E -i "^round-trip|^rtt" >/dev/null
1265 then 1349 then
1266 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d" 1350 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1267 AC_MSG_RESULT([$with_ping6_command]) 1351 AC_MSG_RESULT([$with_ping6_command])
1268 1352
1269 elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \ 1353 elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1270 egrep -i "^round-trip|^rtt" >/dev/null 1354 grep -E -i "^round-trip|^rtt" >/dev/null
1271 then 1355 then
1272 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d" 1356 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1273 AC_MSG_RESULT([$with_ping6_command]) 1357 AC_MSG_RESULT([$with_ping6_command])
1274 1358
1275 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \ 1359 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1276 egrep -i "^round-trip|^rtt" >/dev/null 1360 grep -E -i "^round-trip|^rtt" >/dev/null
1277 then 1361 then
1278 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d" 1362 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1279 AC_MSG_RESULT([$with_ping6_command]) 1363 AC_MSG_RESULT([$with_ping6_command])
1280 1364
1281 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \ 1365 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1282 egrep -i "^round-trip|^rtt" >/dev/null 1366 grep -E -i "^round-trip|^rtt" >/dev/null
1283 then 1367 then
1284 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s" 1368 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1285 ac_cv_ping6_packets_first=yes 1369 ac_cv_ping6_packets_first=yes
1286 AC_MSG_RESULT([$with_ping_command]) 1370 AC_MSG_RESULT([$with_ping_command])
1287 1371
1288 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \ 1372 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1289 egrep -i "^round-trip|^rtt" >/dev/null 1373 grep -E -i "^round-trip|^rtt" >/dev/null
1290 then 1374 then
1291 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s" 1375 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1292 ac_cv_ping6_packets_first=yes 1376 ac_cv_ping6_packets_first=yes
@@ -1486,7 +1570,7 @@ if test -n "$PATH_TO_SUDO"
1486then 1570then
1487 AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo]) 1571 AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
1488else 1572else
1489 AC_MSG_WARN([Could not find sudo or eqivalent]) 1573 AC_MSG_WARN([Could not find sudo or equivalent])
1490fi 1574fi
1491 1575
1492AC_PATH_PROG(PATH_TO_MAILQ,mailq) 1576AC_PATH_PROG(PATH_TO_MAILQ,mailq)
@@ -1497,7 +1581,7 @@ if test -n "$PATH_TO_MAILQ"
1497then 1581then
1498 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq]) 1582 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1499else 1583else
1500 AC_MSG_WARN([Could not find mailq or eqivalent]) 1584 AC_MSG_WARN([Could not find mailq or equivalent])
1501fi 1585fi
1502 1586
1503AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat) 1587AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
@@ -1508,7 +1592,7 @@ if test -n "$PATH_TO_QMAIL_QSTAT"
1508then 1592then
1509 AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat]) 1593 AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1510else 1594else
1511 AC_MSG_WARN([Could not find qmail-qstat or eqivalent]) 1595 AC_MSG_WARN([Could not find qmail-qstat or equivalent])
1512fi 1596fi
1513 1597
1514dnl SWAP info required is amount allocated/available and amount free 1598dnl SWAP info required is amount allocated/available and amount free
@@ -1523,16 +1607,16 @@ then
1523 ac_cv_have_swap=yes 1607 ac_cv_have_swap=yes
1524 ac_cv_swap_command="$PATH_TO_SWAP -l" 1608 ac_cv_swap_command="$PATH_TO_SWAP -l"
1525 if [$PATH_TO_SWAP -l 2>/dev/null | \ 1609 if [$PATH_TO_SWAP -l 2>/dev/null | \
1526 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \ 1610 grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1527 >/dev/null] 1611 >/dev/null]
1528 then 1612 then
1529 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"] 1613 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %lu %lu"]
1530 ac_cv_swap_conv=2048 1614 ac_cv_swap_conv=2048
1531 AC_MSG_RESULT([using IRIX format swap]) 1615 AC_MSG_RESULT([using IRIX format swap])
1532 1616
1533 elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null] 1617 elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
1534 then 1618 then
1535 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"] 1619 ac_cv_swap_format=["%*s %*[0-9,-] %*d %lu %lu"]
1536 ac_cv_swap_conv=2048 1620 ac_cv_swap_conv=2048
1537 AC_MSG_RESULT([using Unixware format swap]) 1621 AC_MSG_RESULT([using Unixware format swap])
1538 else 1622 else
@@ -1549,23 +1633,23 @@ AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1549if (test -n "$PATH_TO_SWAPINFO") 1633if (test -n "$PATH_TO_SWAPINFO")
1550then 1634then
1551AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format]) 1635AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1552if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null] 1636if [$PATH_TO_SWAPINFO -k 2>&1 | grep -E -i "^Device" >/dev/null]
1553then 1637then
1554 ac_cv_have_swap=yes 1638 ac_cv_have_swap=yes
1555 ac_cv_swap_command="$PATH_TO_SWAPINFO -k" 1639 ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1556 1640
1557 if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null] 1641 if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1558 then 1642 then
1559 ac_cv_swap_format=["%*s %f %*d %f"] 1643 ac_cv_swap_format=["%*s %lu %*d %lu"]
1560 ac_cv_swap_conv=1024 1644 ac_cv_swap_conv=1024
1561 AC_MSG_RESULT([using FreeBSD format swapinfo]) 1645 AC_MSG_RESULT([using FreeBSD format swapinfo])
1562 fi 1646 fi
1563 1647
1564elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null] 1648elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1565then 1649then
1566 ac_cv_have_swap=yes 1650 ac_cv_have_swap=yes
1567 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM" 1651 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1568 ac_cv_swap_format=["%*s %f %*d %f"] 1652 ac_cv_swap_format=["%*s %lu %*d %lu"]
1569 ac_cv_swap_conv=1024 1653 ac_cv_swap_conv=1024
1570 AC_MSG_RESULT([using HP-UX format swapinfo]) 1654 AC_MSG_RESULT([using HP-UX format swapinfo])
1571fi 1655fi
@@ -1576,11 +1660,11 @@ AC_PATH_PROG(PATH_TO_LSPS,lsps)
1576if (test -n "$PATH_TO_LSPS") 1660if (test -n "$PATH_TO_LSPS")
1577then 1661then
1578AC_MSG_CHECKING([for $PATH_TO_LSPS format]) 1662AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1579if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null] 1663if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
1580then 1664then
1581 ac_cv_have_swap=yes 1665 ac_cv_have_swap=yes
1582 ac_cv_swap_command="$PATH_TO_LSPS -a" 1666 ac_cv_swap_command="$PATH_TO_LSPS -a"
1583 ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"] 1667 ac_cv_swap_format=["%*s %*s %*s %lu%*s %lu %*s"]
1584 ac_cv_swap_conv=1 1668 ac_cv_swap_conv=1
1585 AC_MSG_RESULT([using AIX lsps]) 1669 AC_MSG_RESULT([using AIX lsps])
1586fi 1670fi
@@ -1766,7 +1850,7 @@ AM_GNU_GETTEXT([external], [need-ngettext])
1766AM_GNU_GETTEXT_VERSION(0.15) 1850AM_GNU_GETTEXT_VERSION(0.15)
1767 1851
1768dnl Check for Redhat spopen problem 1852dnl Check for Redhat spopen problem
1769dnl Wierd problem where ECHILD is returned from a wait call in error 1853dnl Weird problem where ECHILD is returned from a wait call in error
1770dnl Only appears to affect nslookup and dig calls. Only affects redhat around 1854dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1771dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause 1855dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1772dnl We patch plugins/popen.c 1856dnl We patch plugins/popen.c
@@ -1778,7 +1862,7 @@ AC_ARG_ENABLE(redhat-pthread-workaround,
1778 [ac_cv_enable_redhat_pthread_workaround=$enableval], 1862 [ac_cv_enable_redhat_pthread_workaround=$enableval],
1779 [ac_cv_enable_redhat_pthread_workaround=test]) 1863 [ac_cv_enable_redhat_pthread_workaround=test])
1780if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then 1864if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1781 if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then 1865 if echo $ac_cv_uname_r | grep -E "\.EL(smp)?$" >/dev/null 2>&1 ; then
1782 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time]) 1866 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time])
1783 AC_MSG_CHECKING(for redhat spopen problem) 1867 AC_MSG_CHECKING(for redhat spopen problem)
1784 ( cd config_test && make && make test ) > /dev/null 2>&1 1868 ( cd config_test && make && make test ) > /dev/null 2>&1
@@ -1875,4 +1959,5 @@ ACX_FEATURE([enable],[perl-modules])
1875ACX_FEATURE([with],[cgiurl]) 1959ACX_FEATURE([with],[cgiurl])
1876ACX_FEATURE([with],[trusted-path]) 1960ACX_FEATURE([with],[trusted-path])
1877ACX_FEATURE([enable],[libtap]) 1961ACX_FEATURE([enable],[libtap])
1878 1962ACX_FEATURE([with],[libcurl])
1963ACX_FEATURE([with],[uriparser])
diff --git a/doc/RELEASING b/doc/RELEASING
deleted file mode 100644
index 30c81ccf..00000000
--- a/doc/RELEASING
+++ /dev/null
@@ -1,39 +0,0 @@
1NOTES ON RELEASING NEW VERSION OF MONITORING-PLUGINS
2
3*** Pre-release
4git pull
5. tools/devmode, if feeling adventurous
6check compilation, check tinderbox screens
7
8*** Prepare and commit files
9Update NEWS file
10Update AUTHORS if new members
11Update configure.ac and NP-VERSION-GEN with version
12commit NEWS configure.ac NP-VERSION-GEN
13
14*** Create new annotated tag
15git tag -a v2.1.1 -m v2.1.1
16
17*** Push the code and tag to origin
18git push origin master
19git push origin v2.1.1
20
21*** Checkout new version
22rm -fr /tmp/monitoringplug
23# If you need to checkout the tag, don't forget to "checkout master" later to
24# get back to your development branch:
25git checkout tags/v2.1.1
26# Beware: the trailing slash of --prefix is REQUIRED
27git checkout-index --prefix=/tmp/monitoringplug/ -a
28
29*** Build the tarball
30cd /tmp/monitoringplug
31tools/setup
32./configure
33make dist
34
35*** Upload generated tarball to our Project Site
36
37*** Announce new release
38Send email to help, announce with the news text
39Add a news item to https://monitoring-plugins.org
diff --git a/doc/RELEASING.md b/doc/RELEASING.md
new file mode 100644
index 00000000..432b1da1
--- /dev/null
+++ b/doc/RELEASING.md
@@ -0,0 +1,98 @@
1Releasing a New Monitoring Plugins Version
2==========================================
3
4Throughout this document, it is assumed that the current Monitoring
5Plugins version is 2.3.3, and that we're about to publish version 2.4.
6It is also assumed that the official repository on GitHub is tracked
7using the remote name `monitoring-plugins` (rather than `origin`).
8
9Before you start
10----------------
11
12- Check Github Actions status.
13- Update local Git repository to the current `master` tip. For a
14 maintenance release (e.g., version 2.3.4), update to the current
15 `maint-2.3` tip, instead.
16
17Prepare and commit files
18------------------------
19
20- Update `configure.ac` and `NP-VERSION-GEN` with new version.
21- Update `NEWS` from `git log --reverse v2.3.3..` output, and specify
22 the release version/date.
23- Update `AUTHORS` if there are new team members.
24- Update `THANKS.in` using `tools/update-thanks`.
25- Commit the results:
26
27 git commit configure.ac NP-VERSION-GEN NEWS AUTHORS THANKS.in
28
29Create annotated tag
30--------------------
31
32 git tag -a -m 'Monitoring Plugins 2.4' v2.4
33
34Push the code and tag to GitHub
35-------------------------------
36
37 git push monitoring-plugins master
38 git push monitoring-plugins v2.4
39
40Create new maintenance branch
41-----------------------------
42
43_Only necessary when creating a feature release._
44
45 git checkout -b maint-2.4 v2.4
46 git push -u monitoring-plugins maint-2.4
47
48Checkout new version
49--------------------
50
51 rm -rf /tmp/plugins
52 git archive --prefix=tmp/plugins/ v2.4 | (cd /; tar -xf -)
53
54Build the tarball
55-----------------
56
57 cd /tmp/plugins
58 tools/setup # requires docbook to be installed
59 ./configure
60 make dist
61
62Upload tarball to web site
63--------------------------
64
65 scp monitoring-plugins-2.4.tar.gz \
66 plugins@orwell.monitoring-plugins.org:web/download/
67
68Generate SHA1 checksum file on web site
69---------------------------------------
70
71 ssh plugins@orwell.monitoring-plugins.org \
72 '(cd web/download; $HOME/bin/create-checksum monitoring-plugins-2.4.tar.gz)'
73
74Announce new release
75--------------------
76
77- In the site.git repository:
78
79 - Create `web/input/news/release-2-4.md`.
80 - Update the `plugins_release` version in `web/macros.py`.
81 - Commit and push the result:
82
83 git add web/input/news/release-2-4.md
84 git commit web/input/news/release-2-4.md web/macros.py
85 git push origin master
86
87- Post an announcement on (at least) the following mailing lists:
88
89 - <announce@monitoring-plugins.org>
90 - <help@monitoring-plugins.org> (set `Reply-To:` to this one)
91
92- Ask the social media department to announce the release on Twitter :-)
93
94If you want to mention the number of contributors in the announcement:
95
96 git shortlog -s v2.3.3..v2.4 | wc -l
97
98<!-- vim:set filetype=markdown textwidth=72: -->
diff --git a/doc/developer-guidelines.sgml b/doc/developer-guidelines.sgml
index 6f31f365..37c963ed 100644
--- a/doc/developer-guidelines.sgml
+++ b/doc/developer-guidelines.sgml
@@ -13,7 +13,7 @@
13 13
14 <pubdate>2013</pubdate> 14 <pubdate>2013</pubdate>
15 <title>Monitoring Plugins Development Guidelines</title> 15 <title>Monitoring Plugins Development Guidelines</title>
16 16
17 <revhistory> 17 <revhistory>
18 <revision> 18 <revision>
19 <revnumber>1796</revnumber> 19 <revnumber>1796</revnumber>
@@ -31,7 +31,7 @@
31 31
32<preface id="preface"><title>Preface</title> 32<preface id="preface"><title>Preface</title>
33 <para>The purpose of this guidelines is to provide a reference for 33 <para>The purpose of this guidelines is to provide a reference for
34 the plugin developers and encourage the standarization of the 34 the plugin developers and encourage the standardization of the
35 different kind of plugins: C, shell, perl, python, etc.</para> 35 different kind of plugins: C, shell, perl, python, etc.</para>
36 36
37 <para>Monitoring Plugins Development Guidelines Copyright (C) 2000-2013 37 <para>Monitoring Plugins Development Guidelines Copyright (C) 2000-2013
@@ -72,14 +72,14 @@
72</section> 72</section>
73 73
74<section id="PlugOutput"><title>Plugin Output for Nagios</title> 74<section id="PlugOutput"><title>Plugin Output for Nagios</title>
75 75
76 <para>You should always print something to STDOUT that tells if the 76 <para>You should always print something to STDOUT that tells if the
77 service is working or why it is failing. Try to keep the output short - 77 service is working or why it is failing. Try to keep the output short -
78 probably less that 80 characters. Remember that you ideally would like 78 probably less that 80 characters. Remember that you ideally would like
79 the entire output to appear in a pager message, which will get chopped 79 the entire output to appear in a pager message, which will get chopped
80 off after a certain length.</para> 80 off after a certain length.</para>
81 81
82 <para>As Nagios does not capture stderr output, you should only output to 82 <para>As Nagios does not capture stderr output, you should only output to
83 STDOUT and not print to STDERR.</para> 83 STDOUT and not print to STDERR.</para>
84 84
85 <section><title>Print only one line of text</title> 85 <section><title>Print only one line of text</title>
@@ -101,7 +101,7 @@
101 SERVICE STATUS: Information text 101 SERVICE STATUS: Information text
102 </literallayout> 102 </literallayout>
103 <para>However, note that this is not a requirement of the API, so you cannot depend on this 103 <para>However, note that this is not a requirement of the API, so you cannot depend on this
104 being an accurate reflection of the status of the service - the status should always 104 being an accurate reflection of the status of the service - the status should always
105 be determined by the return code.</para> 105 be determined by the return code.</para>
106 </section> 106 </section>
107 107
@@ -148,7 +148,7 @@
148 <para>Code and output should try to respect the 80x25 size of a 148 <para>Code and output should try to respect the 80x25 size of a
149 crt (remember when fixing stuff in the server room!)</para> 149 crt (remember when fixing stuff in the server room!)</para>
150 </section> 150 </section>
151 151
152 <section><title>Plugin Return Codes</title> 152 <section><title>Plugin Return Codes</title>
153 <para>The return codes below are based on the POSIX spec of returning 153 <para>The return codes below are based on the POSIX spec of returning
154 a positive value. Netsaint prior to v0.0.7 supported non-POSIX 154 a positive value. Netsaint prior to v0.0.7 supported non-POSIX
@@ -157,11 +157,11 @@
157 157
158 <para>Note: Some plugins will on occasion print on STDOUT that an error 158 <para>Note: Some plugins will on occasion print on STDOUT that an error
159 occurred and error code is 138 or 255 or some such number. These 159 occurred and error code is 138 or 255 or some such number. These
160 are usually caused by plugins using system commands and having not 160 are usually caused by plugins using system commands and having not
161 enough checks to catch unexpected output. Developers should include a 161 enough checks to catch unexpected output. Developers should include a
162 default catch-all for system command output that returns an UNKNOWN 162 default catch-all for system command output that returns an UNKNOWN
163 return code.</para> 163 return code.</para>
164 164
165 <table id="ReturnCodes"><title>Plugin Return Codes</title> 165 <table id="ReturnCodes"><title>Plugin Return Codes</title>
166 <tgroup cols="3"> 166 <tgroup cols="3">
167 <thead> 167 <thead>
@@ -175,20 +175,20 @@
175 <row> 175 <row>
176 <entry align="center"><para>0</para></entry> 176 <entry align="center"><para>0</para></entry>
177 <entry valign="middle"><para>OK</para></entry> 177 <entry valign="middle"><para>OK</para></entry>
178 <entry><para>The plugin was able to check the service and it 178 <entry><para>The plugin was able to check the service and it
179 appeared to be functioning properly</para></entry> 179 appeared to be functioning properly</para></entry>
180 </row> 180 </row>
181 <row> 181 <row>
182 <entry align="center"><para>1</para></entry> 182 <entry align="center"><para>1</para></entry>
183 <entry valign="middle"><para>Warning</para></entry> 183 <entry valign="middle"><para>Warning</para></entry>
184 <entry><para>The plugin was able to check the service, but it 184 <entry><para>The plugin was able to check the service, but it
185 appeared to be above some "warning" threshold or did not appear 185 appeared to be above some "warning" threshold or did not appear
186 to be working properly</para></entry> 186 to be working properly</para></entry>
187 </row> 187 </row>
188 <row> 188 <row>
189 <entry align="center"><para>2</para></entry> 189 <entry align="center"><para>2</para></entry>
190 <entry valign="middle"><para>Critical</para></entry> 190 <entry valign="middle"><para>Critical</para></entry>
191 <entry><para>The plugin detected that either the service was not 191 <entry><para>The plugin detected that either the service was not
192 running or it was above some "critical" threshold</para></entry> 192 running or it was above some "critical" threshold</para></entry>
193 </row> 193 </row>
194 <row> 194 <row>
@@ -207,7 +207,7 @@
207 </tgroup> 207 </tgroup>
208 </table> 208 </table>
209 209
210 210
211 </section> 211 </section>
212 212
213 <section id="thresholdformat"><title>Threshold and ranges</title> 213 <section id="thresholdformat"><title>Threshold and ranges</title>
@@ -218,7 +218,7 @@
218 set_thresholds(thresholds *, char *, char *) function to set the thresholds. 218 set_thresholds(thresholds *, char *, char *) function to set the thresholds.
219 </para> 219 </para>
220 <para>The theory is that the plugin will do some sort of check which returns 220 <para>The theory is that the plugin will do some sort of check which returns
221 back a numerical value, or metric, which is then compared to the warning and 221 back a numerical value, or metric, which is then compared to the warning and
222 critical thresholds. Use the get_status(double, thresholds *) function to 222 critical thresholds. Use the get_status(double, thresholds *) function to
223 compare the value against the thresholds.</para> 223 compare the value against the thresholds.</para>
224 <para>This is the generalised format for ranges:</para> 224 <para>This is the generalised format for ranges:</para>
@@ -226,14 +226,14 @@
226 <literallayout> 226 <literallayout>
227 [@]start:end 227 [@]start:end
228 </literallayout> 228 </literallayout>
229 229
230 <para>Notes:</para> 230 <para>Notes:</para>
231 <orderedlist> 231 <orderedlist>
232 <listitem><para>start &le; end</para> 232 <listitem><para>start &le; end</para>
233 </listitem> 233 </listitem>
234 <listitem><para>start and ":" is not required if start=0</para> 234 <listitem><para>start and ":" is not required if start=0</para>
235 </listitem> 235 </listitem>
236 <listitem><para>if range is of format "start:" and end is not specified, 236 <listitem><para>if range is of format "start:" and end is not specified,
237 assume end is infinity</para> 237 assume end is infinity</para>
238 </listitem> 238 </listitem>
239 <listitem><para>to specify negative infinity, use "~"</para> 239 <listitem><para>to specify negative infinity, use "~"</para>
@@ -245,7 +245,7 @@
245 (inclusive of endpoints)</para> 245 (inclusive of endpoints)</para>
246 </listitem> 246 </listitem>
247 </orderedlist> 247 </orderedlist>
248 248
249 <para>Note: Not all plugins are coded to expect ranges in this format yet. 249 <para>Note: Not all plugins are coded to expect ranges in this format yet.
250 There will be some work in providing multiple metrics.</para> 250 There will be some work in providing multiple metrics.</para>
251 251
@@ -344,7 +344,7 @@
344 </listitem> 344 </listitem>
345 <listitem><para>label can contain any characters except the equals sign or single quote (')</para> 345 <listitem><para>label can contain any characters except the equals sign or single quote (')</para>
346 </listitem> 346 </listitem>
347 <listitem><para>the single quotes for the label are optional. Required if 347 <listitem><para>the single quotes for the label are optional. Required if
348 spaces are in the label</para> 348 spaces are in the label</para>
349 </listitem> 349 </listitem>
350 <listitem><para>label length is arbitrary, but ideally the first 19 characters 350 <listitem><para>label length is arbitrary, but ideally the first 19 characters
@@ -353,7 +353,7 @@
353 </listitem> 353 </listitem>
354 <listitem><para>to specify a quote character, use two single quotes</para> 354 <listitem><para>to specify a quote character, use two single quotes</para>
355 </listitem> 355 </listitem>
356 <listitem><para>warn, crit, min or max may be null (for example, if the threshold is 356 <listitem><para>warn, crit, min or max may be null (for example, if the threshold is
357 not defined or min and max do not apply). Trailing unfilled semicolons can be 357 not defined or min and max do not apply). Trailing unfilled semicolons can be
358 dropped</para> 358 dropped</para>
359 </listitem> 359 </listitem>
@@ -363,18 +363,18 @@
363 same UOM. value may be a literal "U" instead, this would indicate that the 363 same UOM. value may be a literal "U" instead, this would indicate that the
364 actual value couldn't be determined</para> 364 actual value couldn't be determined</para>
365 </listitem> 365 </listitem>
366 <listitem><para>warn and crit are in the range format (see 366 <listitem><para>warn and crit are in the range format (see
367 <xref linkend="thresholdformat">). Must be the same UOM</para> 367 <xref linkend="thresholdformat">). Must be the same UOM</para>
368 </listitem> 368 </listitem>
369 <listitem><para>UOM (unit of measurement) is one of:</para> 369 <listitem><para>UOM (unit of measurement) is one of:</para>
370 <orderedlist> 370 <orderedlist>
371 <listitem><para>no unit specified - assume a number (int or float) 371 <listitem><para>no unit specified - assume a number (int or float)
372 of things (eg, users, processes, load averages)</para> 372 of things (eg, users, processes, load averages)</para>
373 </listitem> 373 </listitem>
374 <listitem><para>s - seconds (also us, ms)</para></listitem> 374 <listitem><para>s - seconds (also us, ms)</para></listitem>
375 <listitem><para>% - percentage</para></listitem> 375 <listitem><para>% - percentage</para></listitem>
376 <listitem><para>B - bytes (also KB, MB, TB)</para></listitem> 376 <listitem><para>B - bytes (also KB, MB, TB)</para></listitem>
377 <listitem><para>c - a continous counter (such as bytes 377 <listitem><para>c - a continuous counter (such as bytes
378 transmitted on an interface)</para></listitem> 378 transmitted on an interface)</para></listitem>
379 </orderedlist> 379 </orderedlist>
380 </listitem> 380 </listitem>
@@ -385,9 +385,9 @@
385 </section> 385 </section>
386 386
387 <section><title>Translations</title> 387 <section><title>Translations</title>
388 <para>If possible, use translation tools for all output to respect the user's language 388 <para>If possible, use translation tools for all output to respect the user's language
389 settings. See <xref linkend="translationsdevelopers"> for guidelines 389 settings. See <xref linkend="translationsdevelopers"> for guidelines
390 for the core plugins. 390 for the core plugins.
391 </para> 391 </para>
392 </section> 392 </section>
393</section> 393</section>
@@ -397,7 +397,7 @@
397 <section><title>Don't execute system commands without specifying their 397 <section><title>Don't execute system commands without specifying their
398 full path</title> 398 full path</title>
399 <para>Don't use exec(), popen(), etc. to execute external 399 <para>Don't use exec(), popen(), etc. to execute external
400 commands without explicity using the full path of the external 400 commands without explicitly using the full path of the external
401 program.</para> 401 program.</para>
402 402
403 <para>Doing otherwise makes the plugin vulnerable to hijacking 403 <para>Doing otherwise makes the plugin vulnerable to hijacking
@@ -436,7 +436,7 @@
436 </section> 436 </section>
437 437
438</section> 438</section>
439 439
440 440
441 441
442 442
@@ -447,17 +447,17 @@
447 Perl Nagios (ePN) requires stricter use of the some of Perl's features. 447 Perl Nagios (ePN) requires stricter use of the some of Perl's features.
448 This section outlines some of the steps needed to use ePN 448 This section outlines some of the steps needed to use ePN
449 effectively.</para> 449 effectively.</para>
450 450
451 <orderedlist> 451 <orderedlist>
452 452
453 <listitem><para> Do not use BEGIN and END blocks since they will be called 453 <listitem><para> Do not use BEGIN and END blocks since they will be called
454 only once (when Nagios starts and shuts down) with Embedded Perl (ePN). In 454 only once (when Nagios starts and shuts down) with Embedded Perl (ePN). In
455 particular, do not use BEGIN blocks to initialize variables.</para> 455 particular, do not use BEGIN blocks to initialize variables.</para>
456 </listitem> 456 </listitem>
457 457
458 <listitem><para>To use utils.pm, you need to provide a full path to the 458 <listitem><para>To use utils.pm, you need to provide a full path to the
459 module in order for it to work.</para> 459 module in order for it to work.</para>
460 460
461 <literallayout> 461 <literallayout>
462 e.g. 462 e.g.
463 use lib "/usr/local/nagios/libexec"; 463 use lib "/usr/local/nagios/libexec";
@@ -467,24 +467,24 @@
467 467
468 <listitem><para>Perl scripts should be called with "-w"</para> 468 <listitem><para>Perl scripts should be called with "-w"</para>
469 </listitem> 469 </listitem>
470 470
471 <listitem><para>All Perl plugins must compile cleanly under "use strict" - i.e. at 471 <listitem><para>All Perl plugins must compile cleanly under "use strict" - i.e. at
472 least explicitly package names as in "$main::x" or predeclare every 472 least explicitly package names as in "$main::x" or predeclare every
473 variable. </para> 473 variable. </para>
474 474
475 475
476 <para>Explicitly initialize each variable in use. Otherwise with 476 <para>Explicitly initialize each variable in use. Otherwise with
477 caching enabled, the plugin will not be recompiled each time, and 477 caching enabled, the plugin will not be recompiled each time, and
478 therefore Perl will not reinitialize all the variables. All old 478 therefore Perl will not reinitialize all the variables. All old
479 variable values will still be in effect.</para> 479 variable values will still be in effect.</para>
480 </listitem> 480 </listitem>
481 481
482 <listitem><para>Do not use &gt;DATA&lt; handles (these simply do not compile under ePN).</para> 482 <listitem><para>Do not use &gt;DATA&lt; handles (these simply do not compile under ePN).</para>
483 </listitem> 483 </listitem>
484 484
485 <listitem><para>Do not use global variables in named subroutines. This is bad practise anyway, but with ePN the 485 <listitem><para>Do not use global variables in named subroutines. This is bad practise anyway, but with ePN the
486 compiler will report an error "&lt;global_var&gt; will not stay shared ..". Values used by 486 compiler will report an error "&lt;global_var&gt; will not stay shared ..". Values used by
487 subroutines should be passed in the argument list.</para> 487 subroutines should be passed in the argument list.</para>
488 </listitem> 488 </listitem>
489 489
490 <listitem><para>If writing to a file (perhaps recording 490 <listitem><para>If writing to a file (perhaps recording
@@ -492,8 +492,8 @@
492 calls <emphasis role="strong">exit</emphasis>; that is caught by 492 calls <emphasis role="strong">exit</emphasis>; that is caught by
493 p1.pl, so output streams are never closed.</para> 493 p1.pl, so output streams are never closed.</para>
494 </listitem> 494 </listitem>
495 495
496 <listitem><para>As in <xref linkend="runtime"> all plugins need 496 <listitem><para>As in <xref linkend="runtime"> all plugins need
497 to monitor their runtime, specially if they are using network 497 to monitor their runtime, specially if they are using network
498 resources. Use of the <emphasis>alarm</emphasis> is recommended 498 resources. Use of the <emphasis>alarm</emphasis> is recommended
499 noting that some Perl modules (eg LWP) manage timers, so that an alarm 499 noting that some Perl modules (eg LWP) manage timers, so that an alarm
@@ -507,9 +507,9 @@
507 and then "exit $ERRORS{'OK'}" rather than "exit 0" 507 and then "exit $ERRORS{'OK'}" rather than "exit 0"
508 </para> 508 </para>
509 </listitem> 509 </listitem>
510 510
511 </orderedlist> 511 </orderedlist>
512 512
513</section> 513</section>
514 514
515<section id="runtime"><title>Runtime Timeouts</title> 515<section id="runtime"><title>Runtime Timeouts</title>
@@ -524,14 +524,14 @@
524 df could lock up like that. Plus, it should just be more error 524 df could lock up like that. Plus, it should just be more error
525 resistant to be able to time out rather than consume 525 resistant to be able to time out rather than consume
526 resources.</para> 526 resources.</para>
527 527
528 <section><title>Use DEFAULT_SOCKET_TIMEOUT</title> 528 <section><title>Use DEFAULT_SOCKET_TIMEOUT</title>
529 529
530 <para>All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout</para> 530 <para>All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout</para>
531 531
532 </section> 532 </section>
533 533
534 534
535 <section><title>Add alarms to network plugins</title> 535 <section><title>Add alarms to network plugins</title>
536 536
537 <para>If you write a plugin which communicates with another 537 <para>If you write a plugin which communicates with another
@@ -543,16 +543,16 @@
543 543
544 </section> 544 </section>
545 545
546 546
547 547
548</section> 548</section>
549 549
550<section id="PlugOptions"><title>Plugin Options</title> 550<section id="PlugOptions"><title>Plugin Options</title>
551 551
552 <para>A well written plugin should have --help as a way to get 552 <para>A well written plugin should have --help as a way to get
553 verbose help. Code and output should try to respect the 80x25 size of a 553 verbose help. Code and output should try to respect the 80x25 size of a
554 crt (remember when fixing stuff in the server room!)</para> 554 crt (remember when fixing stuff in the server room!)</para>
555 555
556 <section><title>Option Processing</title> 556 <section><title>Option Processing</title>
557 557
558 <para>For plugins written in C, we recommend the C standard 558 <para>For plugins written in C, we recommend the C standard
@@ -585,11 +585,11 @@
585 -p port or password (--port or --passwd/--password)monitors operational 585 -p port or password (--port or --passwd/--password)monitors operational
586 -u url or username (--url or --username) 586 -u url or username (--url or --username)
587 </literallayout> 587 </literallayout>
588 588
589 <para>Look at check_pgsql and check_procs to see how I currently 589 <para>Look at check_pgsql and check_procs to see how I currently
590 think this can work. Standard options are:</para> 590 think this can work. Standard options are:</para>
591 591
592 592
593 <para>The option -V or --version should be present in all 593 <para>The option -V or --version should be present in all
594 plugins. For C plugins it should result in a call to print_revision, a 594 plugins. For C plugins it should result in a call to print_revision, a
595 function in utils.c which takes two character arguments, the 595 function in utils.c which takes two character arguments, the
@@ -603,7 +603,7 @@
603 603
604 <para>The option -h or --help should be present in all plugins. 604 <para>The option -h or --help should be present in all plugins.
605 In C plugins, it should result in a call to print_help (or 605 In C plugins, it should result in a call to print_help (or
606 equivalent). The function print_help should call print_revision, 606 equivalent). The function print_help should call print_revision,
607 then print_usage, then should provide detailed 607 then print_usage, then should provide detailed
608 help. Help text should fit on an 80-character width display, but 608 help. Help text should fit on an 80-character width display, but
609 may run as many lines as needed.</para> 609 may run as many lines as needed.</para>
@@ -655,7 +655,7 @@
655 <para>If possible when writing lists, use tokens to make the 655 <para>If possible when writing lists, use tokens to make the
656 list easy to remember and non-order dependent - so 656 list easy to remember and non-order dependent - so
657 check_disk uses '-c 10000,10%' so that it is clear which is 657 check_disk uses '-c 10000,10%' so that it is clear which is
658 the precentage and which is the KB values (note that due to 658 the percentage and which is the KB values (note that due to
659 my own lack of foresight, that used to be '-c 10000:10%' but 659 my own lack of foresight, that used to be '-c 10000:10%' but
660 such constructs should all be changed for consistency, 660 such constructs should all be changed for consistency,
661 though providing reverse compatibility is fairly 661 though providing reverse compatibility is fairly
@@ -666,7 +666,7 @@
666 666
667 <para>As always, comments are welcome - making this consistent 667 <para>As always, comments are welcome - making this consistent
668 without a host of long options was quite a hassle, and I would 668 without a host of long options was quite a hassle, and I would
669 suspect that there are flaws in this strategy. 669 suspect that there are flaws in this strategy.
670 </para> 670 </para>
671 </section> 671 </section>
672</section> 672</section>
@@ -678,7 +678,7 @@ create and update test cases where possible.
678</para> 678</para>
679 679
680<para> 680<para>
681To run a test, from the top level directory, run "make test". This will run 681To run a test, from the top level directory, run "make test". This will run
682all the current tests and report an overall success rate. 682all the current tests and report an overall success rate.
683</para> 683</para>
684 684
@@ -686,7 +686,7 @@ all the current tests and report an overall success rate.
686<para>These use perl's Test::More. To do a one time test, run "cd plugins && perl t/check_disk.t". 686<para>These use perl's Test::More. To do a one time test, run "cd plugins && perl t/check_disk.t".
687</para> 687</para>
688 688
689<para>There will somtimes be failures seen in this output which are known failures that 689<para>There will sometimes be failures seen in this output which are known failures that
690need to be fixed. As long as the return code is 0, it will be reported as "test pass". 690need to be fixed. As long as the return code is 0, it will be reported as "test pass".
691(If you have a fix so that the specific test passes, that will be gratefully received!) 691(If you have a fix so that the specific test passes, that will be gratefully received!)
692</para> 692</para>
@@ -697,7 +697,7 @@ This runs the test in a summary format.
697</para> 697</para>
698 698
699<para> 699<para>
700For a good and amusing tutorial on using Test::More, see this 700For a good and amusing tutorial on using Test::More, see this
701<ulink url="http://search.cpan.org/dist/Test-Simple/lib/Test/Tutorial.pod"> 701<ulink url="http://search.cpan.org/dist/Test-Simple/lib/Test/Tutorial.pod">
702link</ulink> 702link</ulink>
703</para> 703</para>
@@ -706,16 +706,16 @@ link</ulink>
706 706
707<section><title>Testing the C library functions</title> 707<section><title>Testing the C library functions</title>
708<para> 708<para>
709We use <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap">the libtap library</ulink>, which gives 709We use <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap">the libtap library</ulink>, which gives
710perl's TAP 710perl's TAP
711(Test Anything Protocol) output. This is used by the FreeBSD team for their regression testing. 711(Test Anything Protocol) output. This is used by the FreeBSD team for their regression testing.
712</para> 712</para>
713 713
714<para> 714<para>
715To run tests using the libtap library, download the latest tar ball and extract. 715To run tests using the libtap library, download the latest tar ball and extract.
716There is a problem with tap-1.01 where 716There is a problem with tap-1.01 where
717<ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/25">pthread support doesn't appear to work</ulink> 717<ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/25">pthread support doesn't appear to work</ulink>
718properly on non-FreeBSD systems. Install with 'CPPFLAGS="-UHAVE_LIBPTHREAD" ./configure && make && make check && make install'. 718properly on non-FreeBSD systems. Install with 'CPPFLAGS="-UHAVE_LIBPTHREAD" ./configure && make && make check && make install'.
719</para> 719</para>
720 720
721<para> 721<para>
@@ -729,24 +729,21 @@ setup the tests. Run "make test" to run all the tests.
729 <para>See <ulink url="http://www.gnu.org/prep/standards_toc.html">GNU 729 <para>See <ulink url="http://www.gnu.org/prep/standards_toc.html">GNU
730 Coding standards</ulink> for general guidelines.</para> 730 Coding standards</ulink> for general guidelines.</para>
731 <section><title>C coding</title> 731 <section><title>C coding</title>
732
733 <para>Variables should be declared at the beginning of code blocks and
734 not inline because of portability with older compilers.</para>
735 732
736 <para>You should use /* */ for comments and not // as some compilers 733 <para>Variables should be declared at the beginning of code blocks and
737 do not handle the latter form.</para> 734 not inline because of portability with older compilers.</para>
738 735
739 <para>You should also avoid using the type "bool" and its values 736 <para>You should use the type "bool" and its values
740 "true" and "false". Instead use the "int" type and the plugins' own 737 "true" and "false" instead of the "int" type for booleans.
741 "TRUE"/"FALSE" values to keep the code uniformly.</para> 738 </para>
742 </section> 739 </section>
743 740
744 <section><title>Crediting sources</title> 741 <section><title>Crediting sources</title>
745 <para>If you have copied a routine from another source, make sure the licence 742 <para>If you have copied a routine from another source, make sure the licence
746 from your source allows this. Add a comment referencing the ACKNOWLEDGEMENTS 743 from your source allows this. Add a comment referencing the ACKNOWLEDGEMENTS
747 file, where you can put more detail about the source.</para> 744 file, where you can put more detail about the source.</para>
748 <para>For contributed code, do not add any named credits in the source code 745 <para>For contributed code, do not add any named credits in the source code
749 - contributors should be added into the THANKS.in file instead. 746 - contributors should be added into the THANKS.in file instead.
750 </para> 747 </para>
751 </section> 748 </section>
752 749
@@ -809,11 +806,11 @@ setup the tests. Run "make test" to run all the tests.
809 806
810 807
811 <section id="Contributedplugins"><title>Contributed plugins</title> 808 <section id="Contributedplugins"><title>Contributed plugins</title>
812 <para>Plugins that have been contributed to the project and 809 <para>Plugins that have been contributed to the project and
813 distributed with the Monitoring Plugins files are held in the contrib/ directory and are not installed 810 distributed with the Monitoring Plugins files are held in the contrib/ directory and are not installed
814 by default. These plugins are not officially supported by the team. 811 by default. These plugins are not officially supported by the team.
815 The current policy is that these plugins should be owned and maintained by the original 812 The current policy is that these plugins should be owned and maintained by the original
816 contributor, preferably hosted on <ulink url="http://monitoringexchange.org">Monitoring Exchange</ulink>. 813 contributor, preferably hosted on <ulink url="https://exchange.icinga.com/">Icinga Exchange</ulink>.
817 </para> 814 </para>
818 <para>If patches or bugs are raised to an contributed plugin, we will start communications with the 815 <para>If patches or bugs are raised to an contributed plugin, we will start communications with the
819 original contributor, but seek to remove the plugin from our distribution. 816 original contributor, but seek to remove the plugin from our distribution.
@@ -824,11 +821,11 @@ setup the tests. Run "make test" to run all the tests.
824 821
825 <section id="Newplugins"><title>New plugins</title> 822 <section id="Newplugins"><title>New plugins</title>
826 <para>If you would like others to use your plugins, please add it to 823 <para>If you would like others to use your plugins, please add it to
827 the official 3rd party plugin repository, 824 the official 3rd party plugin repository,
828 <ulink url="http://monitoringexchange.org">Monitoring Exchange</ulink>. 825 <ulink url="https://exchange.icinga.com/">Icinga Exchange</ulink>.
829 </para> 826 </para>
830 827
831 <para>We are not accepting requests for inclusion of plugins into 828 <para>We are not accepting requests for inclusion of plugins into
832 our distribution at the moment, but when we do, these are the minimum 829 our distribution at the moment, but when we do, these are the minimum
833 requirements: 830 requirements:
834 </para> 831 </para>
@@ -843,10 +840,10 @@ setup the tests. Run "make test" to run all the tests.
843 --timeout, --warning, --critical)</para> 840 --timeout, --warning, --critical)</para>
844 </listitem> 841 </listitem>
845 <listitem> 842 <listitem>
846 <para>It is determined to be not redundant (for instance, we would not 843 <para>It is determined to be not redundant (for instance, we would not
847 add a new version of check_disk just because someone had provide 844 add a new version of check_disk just because someone had provide
848 a plugin that had perf checking - we would incorporate the features 845 a plugin that had perf checking - we would incorporate the features
849 into an exisiting plugin)</para> 846 into an existing plugin)</para>
850 </listitem> 847 </listitem>
851 <listitem> 848 <listitem>
852 <para>One of the developers has had the time to audit the code and declare 849 <para>One of the developers has had the time to audit the code and declare
@@ -857,7 +854,7 @@ setup the tests. Run "make test" to run all the tests.
857utils (perl or c or sh) rather than using its own</para> 854utils (perl or c or sh) rather than using its own</para>
858 </listitem> 855 </listitem>
859 <listitem> 856 <listitem>
860 <para>Includes patches to configure.in if required (via the EXTRAS list if 857 <para>Includes patches to configure.in if required (via the EXTRAS list if
861 it will only work on some platforms)</para> 858 it will only work on some platforms)</para>
862 </listitem> 859 </listitem>
863 <listitem> 860 <listitem>
@@ -870,5 +867,5 @@ utils (perl or c or sh) rather than using its own</para>
870 867
871</section> 868</section>
872</article> 869</article>
873 870
874</book> 871</book>
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 15135c8b..dcebd4aa 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -1,10 +1,10 @@
1## DO NOT EDIT! GENERATED AUTOMATICALLY! 1## DO NOT EDIT! GENERATED AUTOMATICALLY!
2## Process this file with automake to produce Makefile.in. 2## Process this file with automake to produce Makefile.in.
3# Copyright (C) 2002-2013 Free Software Foundation, Inc. 3# Copyright (C) 2002-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; you can redistribute it and/or modify 5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or 7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version. 8# (at your option) any later version.
9# 9#
10# This file is distributed in the hope that it will be useful, 10# This file is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
13# GNU General Public License for more details. 13# GNU General Public License for more details.
14# 14#
15# You should have received a copy of the GNU General Public License 15# You should have received a copy of the GNU General Public License
16# along with this file. If not, see <http://www.gnu.org/licenses/>. 16# along with this file. If not, see <https://www.gnu.org/licenses/>.
17# 17#
18# As a special exception to the GNU General Public License, 18# As a special exception to the GNU General Public License,
19# this file may be distributed as part of a program that 19# this file may be distributed as part of a program that
@@ -21,9 +21,42 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf 24# Reproduce by:
25 25# gnulib-tool --import \
26AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects 26# --lib=libgnu \
27# --source-base=gl \
28# --m4-base=gl/m4 \
29# --doc-base=doc \
30# --tests-base=tests \
31# --aux-dir=build-aux \
32# --no-conditional-dependencies \
33# --no-libtool \
34# --macro-prefix=gl \
35# --no-vc-files \
36# base64 \
37# crypto/sha256 \
38# dirname \
39# environ \
40# floorf \
41# fsusage \
42# getaddrinfo \
43# gethostname \
44# getloadavg \
45# getopt-gnu \
46# gettext-h \
47# idpriv-droptemp \
48# mountlist \
49# regex \
50# setenv \
51# strcase \
52# strcasestr \
53# strsep \
54# timegm \
55# unsetenv \
56# vasprintf \
57# vsnprintf
58
59AUTOMAKE_OPTIONS = 1.14 gnits subdir-objects
27 60
28SUBDIRS = 61SUBDIRS =
29noinst_HEADERS = 62noinst_HEADERS =
@@ -37,6 +70,7 @@ MOSTLYCLEANDIRS =
37CLEANFILES = 70CLEANFILES =
38DISTCLEANFILES = 71DISTCLEANFILES =
39MAINTAINERCLEANFILES = 72MAINTAINERCLEANFILES =
73# No GNU Make output.
40EXTRA_DIST += m4/gnulib-cache.m4 74EXTRA_DIST += m4/gnulib-cache.m4
41 75
42AM_CPPFLAGS = 76AM_CPPFLAGS =
@@ -45,10 +79,20 @@ AM_CFLAGS =
45noinst_LIBRARIES += libgnu.a 79noinst_LIBRARIES += libgnu.a
46 80
47libgnu_a_SOURCES = 81libgnu_a_SOURCES =
82libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
48libgnu_a_LIBADD = $(gl_LIBOBJS) 83libgnu_a_LIBADD = $(gl_LIBOBJS)
49libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 84libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
50EXTRA_libgnu_a_SOURCES = 85EXTRA_libgnu_a_SOURCES =
51 86
87## begin gnulib module absolute-header
88
89# Use this preprocessor expression to decide whether #include_next works.
90# Do not rely on a 'configure'-time test for this, since the expression
91# might appear in an installed header, which is used by some other compiler.
92HAVE_INCLUDE_NEXT = (__GNUC__ || __clang__ || 60000000 <= __DECC_VER)
93
94## end gnulib module absolute-header
95
52## begin gnulib module alloca-opt 96## begin gnulib module alloca-opt
53 97
54BUILT_SOURCES += $(ALLOCA_H) 98BUILT_SOURCES += $(ALLOCA_H)
@@ -57,11 +101,10 @@ BUILT_SOURCES += $(ALLOCA_H)
57# doesn't have one that works with the given compiler. 101# doesn't have one that works with the given compiler.
58if GL_GENERATE_ALLOCA_H 102if GL_GENERATE_ALLOCA_H
59alloca.h: alloca.in.h $(top_builddir)/config.status 103alloca.h: alloca.in.h $(top_builddir)/config.status
60 $(AM_V_GEN)rm -f $@-t $@ && \ 104 $(gl_V_at)$(SED_HEADER_STDOUT) \
61 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 105 -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' \
62 cat $(srcdir)/alloca.in.h; \ 106 $(srcdir)/alloca.in.h > $@-t
63 } > $@-t && \ 107 $(AM_V_at)mv $@-t $@
64 mv -f $@-t $@
65else 108else
66alloca.h: $(top_builddir)/config.status 109alloca.h: $(top_builddir)/config.status
67 rm -f $@ 110 rm -f $@
@@ -79,18 +122,18 @@ BUILT_SOURCES += arpa/inet.h
79# We need the following in order to create <arpa/inet.h> when the system 122# We need the following in order to create <arpa/inet.h> when the system
80# doesn't have one. 123# doesn't have one.
81arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 124arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
82 $(AM_V_at)$(MKDIR_P) arpa 125 $(AM_V_GEN)$(MKDIR_P) '%reldir%/arpa'
83 $(AM_V_GEN)rm -f $@-t $@ && \ 126 $(AM_V_at)$(SED_HEADER_STDOUT) \
84 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 127 -e 's|@''GUARD_PREFIX''@|GL|g' \
85 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
86 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 128 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
87 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 129 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
88 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 130 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
89 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ 131 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
90 -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ 132 -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
91 -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ 133 -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
92 -e 's/@''GNULIB_INET_NTOP''@/$(GNULIB_INET_NTOP)/g' \ 134 -e 's/@''GNULIB_INET_NTOP''@/$(GL_GNULIB_INET_NTOP)/g' \
93 -e 's/@''GNULIB_INET_PTON''@/$(GNULIB_INET_PTON)/g' \ 135 -e 's/@''GNULIB_INET_PTON''@/$(GL_GNULIB_INET_PTON)/g' \
136 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
94 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ 137 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
95 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ 138 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
96 -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \ 139 -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \
@@ -98,9 +141,8 @@ arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON
98 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 141 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
99 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 142 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
100 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 143 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
101 < $(srcdir)/arpa_inet.in.h; \ 144 $(srcdir)/arpa_inet.in.h > $@-t
102 } > $@-t && \ 145 $(AM_V_at)mv $@-t $@
103 mv $@-t $@
104MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t 146MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
105MOSTLYCLEANDIRS += arpa 147MOSTLYCLEANDIRS += arpa
106 148
@@ -108,72 +150,141 @@ EXTRA_DIST += arpa_inet.in.h
108 150
109## end gnulib module arpa_inet 151## end gnulib module arpa_inet
110 152
153## begin gnulib module assert-h
154
155BUILT_SOURCES += $(ASSERT_H)
156
157# We need the following in order to create <assert.h> when the system
158# doesn't have one that works with the given compiler.
159if GL_GENERATE_ASSERT_H
160assert.h: assert.in.h verify.h $(top_builddir)/config.status
161 $(gl_V_at){ $(SED_HEADER_STDOUT) \
162 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
163 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
164 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
165 -e 's|@''NEXT_ASSERT_H''@|$(NEXT_ASSERT_H)|g' \
166 < $(srcdir)/assert.in.h && \
167 sed -e '/@assert.h omit start@/,/@assert.h omit end@/d' \
168 -e 's|_gl_verify|_gl_static_assert|g' \
169 -e 's|_GL_VERIFY|_GL_STATIC_ASSERT|g' \
170 -e 's|_GL\(_STATIC_ASSERT_H\)|_GL\1|g' \
171 < $(srcdir)/verify.h; \
172 } > $@-t
173 $(AM_V_at)mv $@-t $@
174else
175assert.h: $(top_builddir)/config.status
176 rm -f $@
177endif
178MOSTLYCLEANFILES += assert.h assert.h-t
179
180EXTRA_DIST += assert.in.h verify.h
181
182## end gnulib module assert-h
183
184## begin gnulib module attribute
185
186
187EXTRA_DIST += attribute.h
188
189## end gnulib module attribute
190
111## begin gnulib module base64 191## begin gnulib module base64
112 192
113libgnu_a_SOURCES += base64.h base64.c 193libgnu_a_SOURCES += base64.h base64.c
114 194
115## end gnulib module base64 195## end gnulib module base64
116 196
117## begin gnulib module btowc 197## begin gnulib module basename-lgpl
118 198
199libgnu_a_SOURCES += basename-lgpl.c
119 200
120EXTRA_DIST += btowc.c 201EXTRA_DIST += basename-lgpl.h
121 202
122EXTRA_libgnu_a_SOURCES += btowc.c 203## end gnulib module basename-lgpl
204
205## begin gnulib module btowc
206
207if GL_COND_OBJ_BTOWC
208libgnu_a_SOURCES += btowc.c
209endif
123 210
124## end gnulib module btowc 211## end gnulib module btowc
125 212
126## begin gnulib module configmake 213## begin gnulib module byteswap
127 214
128# Listed in the same order as the GNU makefile conventions, and 215BUILT_SOURCES += $(BYTESWAP_H)
129# provided by autoconf 2.59c+. 216
130# The Automake-defined pkg* macros are appended, in the order 217# We need the following in order to create <byteswap.h> when the system
131# listed in the Automake 1.10a+ documentation. 218# doesn't have one.
132configmake.h: Makefile 219if GL_GENERATE_BYTESWAP_H
133 $(AM_V_GEN)rm -f $@-t && \ 220byteswap.h: byteswap.in.h $(top_builddir)/config.status
134 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 221 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/byteswap.in.h
135 echo '#define PREFIX "$(prefix)"'; \ 222 $(AM_V_at)mv $@-t $@
136 echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ 223else
137 echo '#define BINDIR "$(bindir)"'; \ 224byteswap.h: $(top_builddir)/config.status
138 echo '#define SBINDIR "$(sbindir)"'; \ 225 rm -f $@
139 echo '#define LIBEXECDIR "$(libexecdir)"'; \ 226endif
140 echo '#define DATAROOTDIR "$(datarootdir)"'; \ 227MOSTLYCLEANFILES += byteswap.h byteswap.h-t
141 echo '#define DATADIR "$(datadir)"'; \ 228
142 echo '#define SYSCONFDIR "$(sysconfdir)"'; \ 229EXTRA_DIST += byteswap.in.h
143 echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \ 230
144 echo '#define LOCALSTATEDIR "$(localstatedir)"'; \ 231## end gnulib module byteswap
145 echo '#define INCLUDEDIR "$(includedir)"'; \ 232
146 echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \ 233## begin gnulib module calloc-gnu
147 echo '#define DOCDIR "$(docdir)"'; \ 234
148 echo '#define INFODIR "$(infodir)"'; \ 235
149 echo '#define HTMLDIR "$(htmldir)"'; \ 236EXTRA_DIST += calloc.c
150 echo '#define DVIDIR "$(dvidir)"'; \ 237
151 echo '#define PDFDIR "$(pdfdir)"'; \ 238EXTRA_libgnu_a_SOURCES += calloc.c
152 echo '#define PSDIR "$(psdir)"'; \ 239
153 echo '#define LIBDIR "$(libdir)"'; \ 240## end gnulib module calloc-gnu
154 echo '#define LISPDIR "$(lispdir)"'; \ 241
155 echo '#define LOCALEDIR "$(localedir)"'; \ 242## begin gnulib module calloc-posix
156 echo '#define MANDIR "$(mandir)"'; \ 243
157 echo '#define MANEXT "$(manext)"'; \ 244
158 echo '#define PKGDATADIR "$(pkgdatadir)"'; \ 245EXTRA_DIST += calloc.c
159 echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ 246
160 echo '#define PKGLIBDIR "$(pkglibdir)"'; \ 247EXTRA_libgnu_a_SOURCES += calloc.c
161 echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ 248
162 } | sed '/""/d' > $@-t && \ 249## end gnulib module calloc-posix
163 mv -f $@-t $@ 250
164 251## begin gnulib module cloexec
165BUILT_SOURCES += configmake.h 252
166CLEANFILES += configmake.h configmake.h-t 253libgnu_a_SOURCES += cloexec.c
167 254
168## end gnulib module configmake 255EXTRA_DIST += cloexec.h
169 256
170## begin gnulib module crypto/sha1 257## end gnulib module cloexec
171 258
172libgnu_a_SOURCES += sha1.c 259## begin gnulib module close
173 260
174EXTRA_DIST += sha1.h 261if GL_COND_OBJ_CLOSE
175 262libgnu_a_SOURCES += close.c
176## end gnulib module crypto/sha1 263endif
264
265## end gnulib module close
266
267## begin gnulib module crypto/af_alg
268
269libgnu_a_SOURCES += af_alg.c
270
271EXTRA_DIST += af_alg.h sys-limits.h
272
273## end gnulib module crypto/af_alg
274
275## begin gnulib module crypto/sha256
276
277libgnu_a_SOURCES += sha256-stream.c
278
279## end gnulib module crypto/sha256
280
281## begin gnulib module crypto/sha256-buffer
282
283libgnu_a_SOURCES += sha256.c
284
285EXTRA_DIST += gl_openssl.h sha256.h
286
287## end gnulib module crypto/sha256-buffer
177 288
178## begin gnulib module dirname 289## begin gnulib module dirname
179 290
@@ -187,18 +298,19 @@ EXTRA_libgnu_a_SOURCES += stripslash.c
187 298
188## begin gnulib module dirname-lgpl 299## begin gnulib module dirname-lgpl
189 300
190libgnu_a_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c 301libgnu_a_SOURCES += dirname-lgpl.c stripslash.c
191 302
192EXTRA_DIST += dirname.h 303EXTRA_DIST += dirname.h
193 304
194## end gnulib module dirname-lgpl 305## end gnulib module dirname-lgpl
195 306
196## begin gnulib module dosname 307## begin gnulib module dup2
197
198 308
199EXTRA_DIST += dosname.h 309if GL_COND_OBJ_DUP2
310libgnu_a_SOURCES += dup2.c
311endif
200 312
201## end gnulib module dosname 313## end gnulib module dup2
202 314
203## begin gnulib module errno 315## begin gnulib module errno
204 316
@@ -208,9 +320,8 @@ BUILT_SOURCES += $(ERRNO_H)
208# doesn't have one that is POSIX compliant. 320# doesn't have one that is POSIX compliant.
209if GL_GENERATE_ERRNO_H 321if GL_GENERATE_ERRNO_H
210errno.h: errno.in.h $(top_builddir)/config.status 322errno.h: errno.in.h $(top_builddir)/config.status
211 $(AM_V_GEN)rm -f $@-t $@ && \ 323 $(gl_V_at)$(SED_HEADER_STDOUT) \
212 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 324 -e 's|@''GUARD_PREFIX''@|GL|g' \
213 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
214 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 325 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
215 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 326 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
216 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 327 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -221,9 +332,8 @@ errno.h: errno.in.h $(top_builddir)/config.status
221 -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \ 332 -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
222 -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ 333 -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
223 -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ 334 -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
224 < $(srcdir)/errno.in.h; \ 335 $(srcdir)/errno.in.h > $@-t
225 } > $@-t && \ 336 $(AM_V_at)mv $@-t $@
226 mv $@-t $@
227else 337else
228errno.h: $(top_builddir)/config.status 338errno.h: $(top_builddir)/config.status
229 rm -f $@ 339 rm -f $@
@@ -236,10 +346,11 @@ EXTRA_DIST += errno.in.h
236 346
237## begin gnulib module error 347## begin gnulib module error
238 348
349if GL_COND_OBJ_ERROR
350libgnu_a_SOURCES += error.c
351endif
239 352
240EXTRA_DIST += error.c error.h 353EXTRA_DIST += error.h
241
242EXTRA_libgnu_a_SOURCES += error.c
243 354
244## end gnulib module error 355## end gnulib module error
245 356
@@ -251,6 +362,51 @@ EXTRA_DIST += exitfail.h
251 362
252## end gnulib module exitfail 363## end gnulib module exitfail
253 364
365## begin gnulib module fcntl
366
367if GL_COND_OBJ_FCNTL
368libgnu_a_SOURCES += fcntl.c
369endif
370
371## end gnulib module fcntl
372
373## begin gnulib module fcntl-h
374
375BUILT_SOURCES += fcntl.h
376
377# We need the following in order to create <fcntl.h> when the system
378# doesn't have one that works with the given compiler.
379fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
380 $(gl_V_at)$(SED_HEADER_STDOUT) \
381 -e 's|@''GUARD_PREFIX''@|GL|g' \
382 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
383 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
384 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
385 -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
386 -e 's/@''GNULIB_CREAT''@/$(GL_GNULIB_CREAT)/g' \
387 -e 's/@''GNULIB_FCNTL''@/$(GL_GNULIB_FCNTL)/g' \
388 -e 's/@''GNULIB_NONBLOCKING''@/$(GL_GNULIB_NONBLOCKING)/g' \
389 -e 's/@''GNULIB_OPEN''@/$(GL_GNULIB_OPEN)/g' \
390 -e 's/@''GNULIB_OPENAT''@/$(GL_GNULIB_OPENAT)/g' \
391 -e 's/@''GNULIB_MDA_CREAT''@/$(GL_GNULIB_MDA_CREAT)/g' \
392 -e 's/@''GNULIB_MDA_OPEN''@/$(GL_GNULIB_MDA_OPEN)/g' \
393 -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
394 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
395 -e 's|@''REPLACE_CREAT''@|$(REPLACE_CREAT)|g' \
396 -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
397 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
398 -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
399 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
400 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
401 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
402 $(srcdir)/fcntl.in.h > $@-t
403 $(AM_V_at)mv $@-t $@
404MOSTLYCLEANFILES += fcntl.h fcntl.h-t
405
406EXTRA_DIST += fcntl.in.h
407
408## end gnulib module fcntl-h
409
254## begin gnulib module fd-hook 410## begin gnulib module fd-hook
255 411
256libgnu_a_SOURCES += fd-hook.c 412libgnu_a_SOURCES += fd-hook.c
@@ -259,6 +415,23 @@ EXTRA_DIST += fd-hook.h
259 415
260## end gnulib module fd-hook 416## end gnulib module fd-hook
261 417
418## begin gnulib module fflush
419
420if GL_COND_OBJ_FFLUSH
421libgnu_a_SOURCES += fflush.c
422endif
423
424EXTRA_DIST += stdio-impl.h
425
426## end gnulib module fflush
427
428## begin gnulib module filename
429
430
431EXTRA_DIST += filename.h
432
433## end gnulib module filename
434
262## begin gnulib module float 435## begin gnulib module float
263 436
264BUILT_SOURCES += $(FLOAT_H) 437BUILT_SOURCES += $(FLOAT_H)
@@ -267,127 +440,267 @@ BUILT_SOURCES += $(FLOAT_H)
267# doesn't have one that works with the given compiler. 440# doesn't have one that works with the given compiler.
268if GL_GENERATE_FLOAT_H 441if GL_GENERATE_FLOAT_H
269float.h: float.in.h $(top_builddir)/config.status 442float.h: float.in.h $(top_builddir)/config.status
270 $(AM_V_GEN)rm -f $@-t $@ && \ 443 $(gl_V_at)$(SED_HEADER_STDOUT) \
271 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 444 -e 's|@''GUARD_PREFIX''@|GL|g' \
272 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
273 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 445 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
274 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 446 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
275 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 447 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
276 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ 448 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
277 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ 449 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
278 < $(srcdir)/float.in.h; \ 450 $(srcdir)/float.in.h > $@-t
279 } > $@-t && \ 451 $(AM_V_at)mv $@-t $@
280 mv $@-t $@
281else 452else
282float.h: $(top_builddir)/config.status 453float.h: $(top_builddir)/config.status
283 rm -f $@ 454 rm -f $@
284endif 455endif
285MOSTLYCLEANFILES += float.h float.h-t 456MOSTLYCLEANFILES += float.h float.h-t
286 457
287EXTRA_DIST += float.c float.in.h itold.c 458if GL_COND_OBJ_FLOAT
459libgnu_a_SOURCES += float.c
460endif
461if GL_COND_OBJ_ITOLD
462libgnu_a_SOURCES += itold.c
463endif
288 464
289EXTRA_libgnu_a_SOURCES += float.c itold.c 465EXTRA_DIST += float.in.h
290 466
291## end gnulib module float 467## end gnulib module float
292 468
293## begin gnulib module floorf 469## begin gnulib module floorf
294 470
471if GL_COND_OBJ_FLOORF
472libgnu_a_SOURCES += floorf.c
473endif
295 474
296EXTRA_DIST += floor.c floorf.c 475EXTRA_DIST += floor.c
297 476
298EXTRA_libgnu_a_SOURCES += floor.c floorf.c 477EXTRA_libgnu_a_SOURCES += floor.c
299 478
300## end gnulib module floorf 479## end gnulib module floorf
301 480
302## begin gnulib module fsusage 481## begin gnulib module fopen
482
303 483
484EXTRA_DIST += fopen.c
304 485
305EXTRA_DIST += fsusage.c fsusage.h 486EXTRA_libgnu_a_SOURCES += fopen.c
306 487
307EXTRA_libgnu_a_SOURCES += fsusage.c 488## end gnulib module fopen
489
490## begin gnulib module fopen-gnu
491
492
493EXTRA_DIST += fopen.c
494
495EXTRA_libgnu_a_SOURCES += fopen.c
496
497## end gnulib module fopen-gnu
498
499## begin gnulib module fpurge
500
501if GL_COND_OBJ_FPURGE
502libgnu_a_SOURCES += fpurge.c
503endif
504
505EXTRA_DIST += stdio-impl.h
506
507## end gnulib module fpurge
508
509## begin gnulib module freading
510
511libgnu_a_SOURCES += freading.c
512
513EXTRA_DIST += freading.h stdio-impl.h
514
515## end gnulib module freading
516
517## begin gnulib module free-posix
518
519if GL_COND_OBJ_FREE
520libgnu_a_SOURCES += free.c
521endif
522
523## end gnulib module free-posix
524
525## begin gnulib module fseek
526
527if GL_COND_OBJ_FSEEK
528libgnu_a_SOURCES += fseek.c
529endif
530
531## end gnulib module fseek
532
533## begin gnulib module fseeko
534
535if GL_COND_OBJ_FSEEKO
536libgnu_a_SOURCES += fseeko.c
537endif
538
539EXTRA_DIST += stdio-impl.h
540
541## end gnulib module fseeko
542
543## begin gnulib module fstat
544
545if GL_COND_OBJ_FSTAT
546libgnu_a_SOURCES += fstat.c
547endif
548
549EXTRA_DIST += stat-w32.c stat-w32.h
550
551EXTRA_libgnu_a_SOURCES += stat-w32.c
552
553## end gnulib module fstat
554
555## begin gnulib module fsusage
556
557if GL_COND_OBJ_FSUSAGE
558libgnu_a_SOURCES += fsusage.c
559endif
560
561EXTRA_DIST += fsusage.h
308 562
309## end gnulib module fsusage 563## end gnulib module fsusage
310 564
311## begin gnulib module full-read 565## begin gnulib module ftell
566
567if GL_COND_OBJ_FTELL
568libgnu_a_SOURCES += ftell.c
569endif
570
571## end gnulib module ftell
312 572
313libgnu_a_SOURCES += full-read.h full-read.c 573## begin gnulib module ftello
314 574
315EXTRA_DIST += full-write.c 575if GL_COND_OBJ_FTELLO
576libgnu_a_SOURCES += ftello.c
577endif
316 578
317EXTRA_libgnu_a_SOURCES += full-write.c 579EXTRA_DIST += stdio-impl.h
318 580
319## end gnulib module full-read 581## end gnulib module ftello
320 582
321## begin gnulib module getaddrinfo 583## begin gnulib module gen-header
322 584
585# In 'sed', replace the pattern space with a "DO NOT EDIT" comment.
586SED_HEADER_NOEDIT = s,.*,/* DO NOT EDIT! GENERATED AUTOMATICALLY! */,
323 587
324EXTRA_DIST += gai_strerror.c getaddrinfo.c 588# '$(SED_HEADER_STDOUT) -e "..."' runs 'sed' but first outputs "DO NOT EDIT".
589SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G
325 590
326EXTRA_libgnu_a_SOURCES += gai_strerror.c getaddrinfo.c 591# '$(SED_HEADER_TO_AT_t) FILE' copies FILE to $@-t, prepending a leading
592# "DO_NOT_EDIT". Although this could be done more simply via:
593# SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) > $@-t
594# the -n and 'w' avoid a fork+exec, at least when GNU Make is used.
595SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t'
596
597# Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that
598gl_V_at = $(AM_V_GEN)
599
600## end gnulib module gen-header
601
602## begin gnulib module getaddrinfo
603
604if GL_COND_OBJ_GETADDRINFO
605libgnu_a_SOURCES += getaddrinfo.c
606endif
607if GL_COND_OBJ_GAI_STRERROR
608libgnu_a_SOURCES += gai_strerror.c
609endif
327 610
328## end gnulib module getaddrinfo 611## end gnulib module getaddrinfo
329 612
330## begin gnulib module gethostname 613## begin gnulib module getdelim
614
615if GL_COND_OBJ_GETDELIM
616libgnu_a_SOURCES += getdelim.c
617endif
618
619## end gnulib module getdelim
620
621## begin gnulib module getdtablesize
331 622
623if GL_COND_OBJ_GETDTABLESIZE
624libgnu_a_SOURCES += getdtablesize.c
625endif
626
627## end gnulib module getdtablesize
628
629## begin gnulib module gethostname
332 630
333EXTRA_DIST += gethostname.c w32sock.h 631if GL_COND_OBJ_GETHOSTNAME
632libgnu_a_SOURCES += gethostname.c
633endif
334 634
335EXTRA_libgnu_a_SOURCES += gethostname.c 635EXTRA_DIST += w32sock.h
336 636
337## end gnulib module gethostname 637## end gnulib module gethostname
338 638
339## begin gnulib module getloadavg 639## begin gnulib module getline
640
641if GL_COND_OBJ_GETLINE
642libgnu_a_SOURCES += getline.c
643endif
340 644
645## end gnulib module getline
341 646
342EXTRA_DIST += getloadavg.c 647## begin gnulib module getloadavg
343 648
344EXTRA_libgnu_a_SOURCES += getloadavg.c 649if GL_COND_OBJ_GETLOADAVG
650libgnu_a_SOURCES += getloadavg.c
651endif
345 652
346## end gnulib module getloadavg 653## end gnulib module getloadavg
347 654
348## begin gnulib module getopt-posix 655## begin gnulib module getopt-posix
349 656
350BUILT_SOURCES += $(GETOPT_H) 657BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H)
351 658
352# We need the following in order to create <getopt.h> when the system 659# We need the following in order to create <getopt.h> when the system
353# doesn't have one that works with the given compiler. 660# doesn't have one that works with the given compiler.
661if GL_GENERATE_GETOPT_H
354getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) 662getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
355 $(AM_V_GEN)rm -f $@-t $@ && \ 663 $(gl_V_at)$(SED_HEADER_STDOUT) \
356 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 664 -e 's|@''GUARD_PREFIX''@|GL|g' \
357 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
358 -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ 665 -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
359 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 666 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
360 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 667 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
361 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 668 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
362 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ 669 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
363 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 670 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
364 < $(srcdir)/getopt.in.h; \ 671 $(srcdir)/getopt.in.h > $@-t
365 } > $@-t && \ 672 $(AM_V_at)mv $@-t $@
366 mv -f $@-t $@ 673else
367MOSTLYCLEANFILES += getopt.h getopt.h-t 674getopt.h: $(top_builddir)/config.status
675 rm -f $@
676endif
368 677
369EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h 678if GL_GENERATE_GETOPT_CDEFS_H
679getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status
680 $(AM_V_GEN)$(SED_HEADER_STDOUT) \
681 -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
682 $(srcdir)/getopt-cdefs.in.h > $@-t
683 $(AM_V_at)mv $@-t $@
684else
685getopt-cdefs.h: $(top_builddir)/config.status
686 rm -f $@
687endif
370 688
371EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c 689MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t
372 690
373## end gnulib module getopt-posix 691if GL_COND_OBJ_GETOPT
692libgnu_a_SOURCES += getopt.c getopt1.c
693endif
694
695EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.in.h getopt_int.h
374 696
375## begin gnulib module gettext 697## end gnulib module getopt-posix
376 698
377# If your project uses "gettextize --intl" to put a source-code 699## begin gnulib module getprogname
378# copy of libintl into the package, every Makefile.am needs
379# -I$(top_builddir)/intl, so that <libintl.h> can be found in this directory.
380# Here's one way to do this:
381#AM_CPPFLAGS += -I$(top_builddir)/intl
382# This option has no effect when the user disables NLS (because then
383# the intl directory contains no libintl.h file). This option is not
384# enabled by default because the intl directory might not exist if
385# your project does not use "gettext --intl", and some compilers
386# complain about -I options applied to nonexistent directories.
387 700
388EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath 701libgnu_a_SOURCES += getprogname.h getprogname.c
389 702
390## end gnulib module gettext 703## end gnulib module getprogname
391 704
392## begin gnulib module gettext-h 705## begin gnulib module gettext-h
393 706
@@ -395,12 +708,54 @@ libgnu_a_SOURCES += gettext.h
395 708
396## end gnulib module gettext-h 709## end gnulib module gettext-h
397 710
398## begin gnulib module havelib 711## begin gnulib module glibc-internal/dynarray
712
713BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h
714
715malloc/dynarray.gl.h: malloc/dynarray.h
716 $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc'
717 $(AM_V_at)$(SED_HEADER_STDOUT) \
718 -e '/libc_hidden_proto/d' \
719 $(srcdir)/malloc/dynarray.h > $@-t
720 $(AM_V_at)mv $@-t $@
721MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t
722
723malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c
724 $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc'
725 $(AM_V_at)$(SED_HEADER_STDOUT) \
726 -e 's|<malloc/dynarray\.h>|<malloc/dynarray.gl.h>|g' \
727 -e 's|__attribute_maybe_unused__|_GL_ATTRIBUTE_MAYBE_UNUSED|g' \
728 -e 's|__attribute_nonnull__|_GL_ATTRIBUTE_NONNULL|g' \
729 -e 's|__attribute_warn_unused_result__|_GL_ATTRIBUTE_NODISCARD|g' \
730 -e 's|__glibc_likely|_GL_LIKELY|g' \
731 -e 's|__glibc_unlikely|_GL_UNLIKELY|g' \
732 $(srcdir)/malloc/dynarray-skeleton.c > $@-t
733 $(AM_V_at)mv $@-t $@
734MOSTLYCLEANFILES += malloc/dynarray-skeleton.gl.h malloc/dynarray-skeleton.gl.h-t
735
736libgnu_a_SOURCES += malloc/dynarray_at_failure.c malloc/dynarray_emplace_enlarge.c malloc/dynarray_finalize.c malloc/dynarray_resize.c malloc/dynarray_resize_clear.c
737
738EXTRA_DIST += dynarray.h malloc/dynarray-skeleton.c malloc/dynarray.h
739
740EXTRA_libgnu_a_SOURCES += malloc/dynarray-skeleton.c
741
742## end gnulib module glibc-internal/dynarray
743
744## begin gnulib module hard-locale
745
746libgnu_a_SOURCES += hard-locale.c
399 747
748EXTRA_DIST += hard-locale.h
400 749
401EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath 750## end gnulib module hard-locale
402 751
403## end gnulib module havelib 752## begin gnulib module ialloc
753
754libgnu_a_SOURCES += ialloc.c
755
756EXTRA_DIST += ialloc.h
757
758## end gnulib module ialloc
404 759
405## begin gnulib module idpriv-droptemp 760## begin gnulib module idpriv-droptemp
406 761
@@ -410,22 +765,68 @@ EXTRA_DIST += idpriv.h
410 765
411## end gnulib module idpriv-droptemp 766## end gnulib module idpriv-droptemp
412 767
413## begin gnulib module inet_ntop 768## begin gnulib module idx
769
770libgnu_a_SOURCES += idx.h
414 771
772## end gnulib module idx
415 773
416EXTRA_DIST += inet_ntop.c 774## begin gnulib module inet_ntop
417 775
418EXTRA_libgnu_a_SOURCES += inet_ntop.c 776if GL_COND_OBJ_INET_NTOP
777libgnu_a_SOURCES += inet_ntop.c
778endif
419 779
420## end gnulib module inet_ntop 780## end gnulib module inet_ntop
421 781
422## begin gnulib module intprops 782## begin gnulib module intprops
423 783
424 784
425EXTRA_DIST += intprops.h 785EXTRA_DIST += intprops-internal.h intprops.h
426 786
427## end gnulib module intprops 787## end gnulib module intprops
428 788
789## begin gnulib module inttypes-incomplete
790
791BUILT_SOURCES += inttypes.h
792
793# We need the following in order to create <inttypes.h> when the system
794# doesn't have one that works with the given compiler.
795inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
796 $(gl_V_at)$(SED_HEADER_STDOUT) \
797 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
798 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
799 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
800 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
801 -e 's|@''NEXT_INTTYPES_H''@|$(NEXT_INTTYPES_H)|g' \
802 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
803 -e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \
804 -e 's/@''GNULIB_IMAXABS''@/$(GL_GNULIB_IMAXABS)/g' \
805 -e 's/@''GNULIB_IMAXDIV''@/$(GL_GNULIB_IMAXDIV)/g' \
806 -e 's/@''GNULIB_STRTOIMAX''@/$(GL_GNULIB_STRTOIMAX)/g' \
807 -e 's/@''GNULIB_STRTOUMAX''@/$(GL_GNULIB_STRTOUMAX)/g' \
808 -e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \
809 -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
810 -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
811 -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
812 -e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \
813 -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
814 -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \
815 -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \
816 -e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \
817 -e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \
818 -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \
819 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
820 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
821 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
822 $(srcdir)/inttypes.in.h > $@-t
823 $(AM_V_at)mv $@-t $@
824MOSTLYCLEANFILES += inttypes.h inttypes.h-t
825
826EXTRA_DIST += inttypes.in.h
827
828## end gnulib module inttypes-incomplete
829
429## begin gnulib module langinfo 830## begin gnulib module langinfo
430 831
431BUILT_SOURCES += langinfo.h 832BUILT_SOURCES += langinfo.h
@@ -433,103 +834,69 @@ BUILT_SOURCES += langinfo.h
433# We need the following in order to create an empty placeholder for 834# We need the following in order to create an empty placeholder for
434# <langinfo.h> when the system doesn't have one. 835# <langinfo.h> when the system doesn't have one.
435langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) 836langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
436 $(AM_V_GEN)rm -f $@-t $@ && \ 837 $(gl_V_at)$(SED_HEADER_STDOUT) \
437 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 838 -e 's|@''GUARD_PREFIX''@|GL|g' \
438 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
439 -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \ 839 -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
440 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 840 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
441 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 841 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
442 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 842 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
443 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ 843 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
444 -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \ 844 -e 's/@''GNULIB_NL_LANGINFO''@/$(GL_GNULIB_NL_LANGINFO)/g' \
445 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ 845 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
446 -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \ 846 -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
847 -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
447 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ 848 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
448 -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \ 849 -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
449 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ 850 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
450 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ 851 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
451 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 852 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
452 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 853 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
453 < $(srcdir)/langinfo.in.h; \ 854 $(srcdir)/langinfo.in.h > $@-t
454 } > $@-t && \ 855 $(AM_V_at)mv $@-t $@
455 mv $@-t $@
456MOSTLYCLEANFILES += langinfo.h langinfo.h-t 856MOSTLYCLEANFILES += langinfo.h langinfo.h-t
457 857
458EXTRA_DIST += langinfo.in.h 858EXTRA_DIST += langinfo.in.h
459 859
460## end gnulib module langinfo 860## end gnulib module langinfo
461 861
462## begin gnulib module localcharset 862## begin gnulib module libc-config
463 863
464libgnu_a_SOURCES += localcharset.h localcharset.c
465
466# We need the following in order to install a simple file in $(libdir)
467# which is shared with other installed packages. We use a list of referencing
468# packages so that "make uninstall" will remove the file if and only if it
469# is not used by another installed package.
470# On systems with glibc-2.1 or newer, the file is redundant, therefore we
471# avoid installing it.
472
473all-local: charset.alias ref-add.sed ref-del.sed
474
475charset_alias = $(DESTDIR)$(libdir)/charset.alias
476charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
477install-exec-local: install-exec-localcharset
478install-exec-localcharset: all-local
479 if test $(GLIBC21) = no; then \
480 case '$(host_os)' in \
481 darwin[56]*) \
482 need_charset_alias=true ;; \
483 darwin* | cygwin* | mingw* | pw32* | cegcc*) \
484 need_charset_alias=false ;; \
485 *) \
486 need_charset_alias=true ;; \
487 esac ; \
488 else \
489 need_charset_alias=false ; \
490 fi ; \
491 if $$need_charset_alias; then \
492 $(mkinstalldirs) $(DESTDIR)$(libdir) ; \
493 fi ; \
494 if test -f $(charset_alias); then \
495 sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
496 $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
497 rm -f $(charset_tmp) ; \
498 else \
499 if $$need_charset_alias; then \
500 sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
501 $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
502 rm -f $(charset_tmp) ; \
503 fi ; \
504 fi
505
506uninstall-local: uninstall-localcharset
507uninstall-localcharset: all-local
508 if test -f $(charset_alias); then \
509 sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
510 if grep '^# Packages using this file: $$' $(charset_tmp) \
511 > /dev/null; then \
512 rm -f $(charset_alias); \
513 else \
514 $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
515 fi; \
516 rm -f $(charset_tmp); \
517 fi
518 864
519charset.alias: config.charset 865EXTRA_DIST += cdefs.h libc-config.h
520 $(AM_V_GEN)rm -f t-$@ $@ && \
521 $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \
522 mv t-$@ $@
523 866
524SUFFIXES += .sed .sin 867## end gnulib module libc-config
525.sin.sed:
526 $(AM_V_GEN)rm -f t-$@ $@ && \
527 sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \
528 mv t-$@ $@
529 868
530CLEANFILES += charset.alias ref-add.sed ref-del.sed 869## begin gnulib module limits-h
531 870
532EXTRA_DIST += config.charset ref-add.sin ref-del.sin 871BUILT_SOURCES += $(LIMITS_H)
872
873# We need the following in order to create <limits.h> when the system
874# doesn't have one that is compatible with GNU.
875if GL_GENERATE_LIMITS_H
876limits.h: limits.in.h $(top_builddir)/config.status
877 $(gl_V_at)$(SED_HEADER_STDOUT) \
878 -e 's|@''GUARD_PREFIX''@|GL|g' \
879 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
880 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
881 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
882 -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
883 $(srcdir)/limits.in.h > $@-t
884 $(AM_V_at)mv $@-t $@
885else
886limits.h: $(top_builddir)/config.status
887 rm -f $@
888endif
889MOSTLYCLEANFILES += limits.h limits.h-t
890
891EXTRA_DIST += limits.in.h
892
893## end gnulib module limits-h
894
895## begin gnulib module localcharset
896
897libgnu_a_SOURCES += localcharset.c
898
899EXTRA_DIST += localcharset.h
533 900
534## end gnulib module localcharset 901## end gnulib module localcharset
535 902
@@ -540,28 +907,33 @@ BUILT_SOURCES += locale.h
540# We need the following in order to create <locale.h> when the system 907# We need the following in order to create <locale.h> when the system
541# doesn't have one that provides all definitions. 908# doesn't have one that provides all definitions.
542locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 909locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
543 $(AM_V_GEN)rm -f $@-t $@ && \ 910 $(gl_V_at)$(SED_HEADER_STDOUT) \
544 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 911 -e 's|@''GUARD_PREFIX''@|GL|g' \
545 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
546 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 912 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
547 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 913 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
548 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 914 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
549 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ 915 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
550 -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \ 916 -e 's/@''GNULIB_LOCALECONV''@/$(GL_GNULIB_LOCALECONV)/g' \
551 -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \ 917 -e 's/@''GNULIB_SETLOCALE''@/$(GL_GNULIB_SETLOCALE)/g' \
552 -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \ 918 -e 's/@''GNULIB_SETLOCALE_NULL''@/$(GL_GNULIB_SETLOCALE_NULL)/g' \
919 -e 's/@''GNULIB_DUPLOCALE''@/$(GL_GNULIB_DUPLOCALE)/g' \
920 -e 's/@''GNULIB_LOCALENAME''@/$(GL_GNULIB_LOCALENAME)/g' \
921 -e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \
553 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ 922 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
923 -e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \
554 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ 924 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
555 -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \ 925 -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
556 -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \ 926 -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
927 -e 's|@''REPLACE_NEWLOCALE''@|$(REPLACE_NEWLOCALE)|g' \
557 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ 928 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
929 -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \
558 -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \ 930 -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
931 -e 's|@''LOCALENAME_ENHANCE_LOCALE_FUNCS''@|$(LOCALENAME_ENHANCE_LOCALE_FUNCS)|g' \
559 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 932 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
560 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 933 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
561 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 934 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
562 < $(srcdir)/locale.in.h; \ 935 $(srcdir)/locale.in.h > $@-t
563 } > $@-t && \ 936 $(AM_V_at)mv $@-t $@
564 mv $@-t $@
565MOSTLYCLEANFILES += locale.h locale.h-t 937MOSTLYCLEANFILES += locale.h locale.h-t
566 938
567EXTRA_DIST += locale.in.h 939EXTRA_DIST += locale.in.h
@@ -570,10 +942,9 @@ EXTRA_DIST += locale.in.h
570 942
571## begin gnulib module localeconv 943## begin gnulib module localeconv
572 944
573 945if GL_COND_OBJ_LOCALECONV
574EXTRA_DIST += localeconv.c 946libgnu_a_SOURCES += localeconv.c
575 947endif
576EXTRA_libgnu_a_SOURCES += localeconv.c
577 948
578## end gnulib module localeconv 949## end gnulib module localeconv
579 950
@@ -583,6 +954,14 @@ libgnu_a_SOURCES += glthread/lock.h glthread/lock.c
583 954
584## end gnulib module lock 955## end gnulib module lock
585 956
957## begin gnulib module lseek
958
959if GL_COND_OBJ_LSEEK
960libgnu_a_SOURCES += lseek.c
961endif
962
963## end gnulib module lseek
964
586## begin gnulib module malloc-gnu 965## begin gnulib module malloc-gnu
587 966
588 967
@@ -605,7 +984,7 @@ EXTRA_libgnu_a_SOURCES += malloc.c
605 984
606libgnu_a_SOURCES += malloca.c 985libgnu_a_SOURCES += malloca.c
607 986
608EXTRA_DIST += malloca.h malloca.valgrind 987EXTRA_DIST += malloca.h
609 988
610## end gnulib module malloca 989## end gnulib module malloca
611 990
@@ -617,109 +996,114 @@ libgnu_a_SOURCES += math.c
617# We need the following in order to create <math.h> when the system 996# We need the following in order to create <math.h> when the system
618# doesn't have one that works with the given compiler. 997# doesn't have one that works with the given compiler.
619math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 998math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
620 $(AM_V_GEN)rm -f $@-t $@ && \ 999 $(gl_V_at)$(SED_HEADER_STDOUT) \
621 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1000 -e 's|@''GUARD_PREFIX''@|GL|g' \
622 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
623 -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ 1001 -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
624 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1002 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
625 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1003 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
626 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \ 1004 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
627 -e 's/@''GNULIB_ACOSF''@/$(GNULIB_ACOSF)/g' \ 1005 -e 's/@''GNULIB_ACOSF''@/$(GL_GNULIB_ACOSF)/g' \
628 -e 's/@''GNULIB_ACOSL''@/$(GNULIB_ACOSL)/g' \ 1006 -e 's/@''GNULIB_ACOSL''@/$(GL_GNULIB_ACOSL)/g' \
629 -e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \ 1007 -e 's/@''GNULIB_ASINF''@/$(GL_GNULIB_ASINF)/g' \
630 -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \ 1008 -e 's/@''GNULIB_ASINL''@/$(GL_GNULIB_ASINL)/g' \
631 -e 's/@''GNULIB_ATANF''@/$(GNULIB_ATANF)/g' \ 1009 -e 's/@''GNULIB_ATANF''@/$(GL_GNULIB_ATANF)/g' \
632 -e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \ 1010 -e 's/@''GNULIB_ATANL''@/$(GL_GNULIB_ATANL)/g' \
633 -e 's/@''GNULIB_ATAN2F''@/$(GNULIB_ATAN2F)/g' \ 1011 -e 's/@''GNULIB_ATAN2F''@/$(GL_GNULIB_ATAN2F)/g' \
634 -e 's/@''GNULIB_CBRT''@/$(GNULIB_CBRT)/g' \ 1012 -e 's/@''GNULIB_CBRT''@/$(GL_GNULIB_CBRT)/g' \
635 -e 's/@''GNULIB_CBRTF''@/$(GNULIB_CBRTF)/g' \ 1013 -e 's/@''GNULIB_CBRTF''@/$(GL_GNULIB_CBRTF)/g' \
636 -e 's/@''GNULIB_CBRTL''@/$(GNULIB_CBRTL)/g' \ 1014 -e 's/@''GNULIB_CBRTL''@/$(GL_GNULIB_CBRTL)/g' \
637 -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \ 1015 -e 's/@''GNULIB_CEIL''@/$(GL_GNULIB_CEIL)/g' \
638 -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \ 1016 -e 's/@''GNULIB_CEILF''@/$(GL_GNULIB_CEILF)/g' \
639 -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \ 1017 -e 's/@''GNULIB_CEILL''@/$(GL_GNULIB_CEILL)/g' \
640 -e 's/@''GNULIB_COPYSIGN''@/$(GNULIB_COPYSIGN)/g' \ 1018 -e 's/@''GNULIB_COPYSIGN''@/$(GL_GNULIB_COPYSIGN)/g' \
641 -e 's/@''GNULIB_COPYSIGNF''@/$(GNULIB_COPYSIGNF)/g' \ 1019 -e 's/@''GNULIB_COPYSIGNF''@/$(GL_GNULIB_COPYSIGNF)/g' \
642 -e 's/@''GNULIB_COPYSIGNL''@/$(GNULIB_COPYSIGNL)/g' \ 1020 -e 's/@''GNULIB_COPYSIGNL''@/$(GL_GNULIB_COPYSIGNL)/g' \
643 -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \ 1021 -e 's/@''GNULIB_COSF''@/$(GL_GNULIB_COSF)/g' \
644 -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \ 1022 -e 's/@''GNULIB_COSL''@/$(GL_GNULIB_COSL)/g' \
645 -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \ 1023 -e 's/@''GNULIB_COSHF''@/$(GL_GNULIB_COSHF)/g' \
646 -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \ 1024 -e 's/@''GNULIB_EXPF''@/$(GL_GNULIB_EXPF)/g' \
647 -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \ 1025 -e 's/@''GNULIB_EXPL''@/$(GL_GNULIB_EXPL)/g' \
648 -e 's/@''GNULIB_EXP2''@/$(GNULIB_EXP2)/g' \ 1026 -e 's/@''GNULIB_EXP2''@/$(GL_GNULIB_EXP2)/g' \
649 -e 's/@''GNULIB_EXP2F''@/$(GNULIB_EXP2F)/g' \ 1027 -e 's/@''GNULIB_EXP2F''@/$(GL_GNULIB_EXP2F)/g' \
650 -e 's/@''GNULIB_EXP2L''@/$(GNULIB_EXP2L)/g' \ 1028 -e 's/@''GNULIB_EXP2L''@/$(GL_GNULIB_EXP2L)/g' \
651 -e 's/@''GNULIB_EXPM1''@/$(GNULIB_EXPM1)/g' \ 1029 -e 's/@''GNULIB_EXPM1''@/$(GL_GNULIB_EXPM1)/g' \
652 -e 's/@''GNULIB_EXPM1F''@/$(GNULIB_EXPM1F)/g' \ 1030 -e 's/@''GNULIB_EXPM1F''@/$(GL_GNULIB_EXPM1F)/g' \
653 -e 's/@''GNULIB_EXPM1L''@/$(GNULIB_EXPM1L)/g' \ 1031 -e 's/@''GNULIB_EXPM1L''@/$(GL_GNULIB_EXPM1L)/g' \
654 -e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \ 1032 -e 's/@''GNULIB_FABSF''@/$(GL_GNULIB_FABSF)/g' \
655 -e 's/@''GNULIB_FABSL''@/$(GNULIB_FABSL)/g' \ 1033 -e 's/@''GNULIB_FABSL''@/$(GL_GNULIB_FABSL)/g' \
656 -e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \ 1034 -e 's/@''GNULIB_FLOOR''@/$(GL_GNULIB_FLOOR)/g' \
657 -e 's/@''GNULIB_FLOORF''@/$(GNULIB_FLOORF)/g' \ 1035 -e 's/@''GNULIB_FLOORF''@/$(GL_GNULIB_FLOORF)/g' \
658 -e 's/@''GNULIB_FLOORL''@/$(GNULIB_FLOORL)/g' \ 1036 -e 's/@''GNULIB_FLOORL''@/$(GL_GNULIB_FLOORL)/g' \
659 -e 's/@''GNULIB_FMA''@/$(GNULIB_FMA)/g' \ 1037 -e 's/@''GNULIB_FMA''@/$(GL_GNULIB_FMA)/g' \
660 -e 's/@''GNULIB_FMAF''@/$(GNULIB_FMAF)/g' \ 1038 -e 's/@''GNULIB_FMAF''@/$(GL_GNULIB_FMAF)/g' \
661 -e 's/@''GNULIB_FMAL''@/$(GNULIB_FMAL)/g' \ 1039 -e 's/@''GNULIB_FMAL''@/$(GL_GNULIB_FMAL)/g' \
662 -e 's/@''GNULIB_FMOD''@/$(GNULIB_FMOD)/g' \ 1040 -e 's/@''GNULIB_FMOD''@/$(GL_GNULIB_FMOD)/g' \
663 -e 's/@''GNULIB_FMODF''@/$(GNULIB_FMODF)/g' \ 1041 -e 's/@''GNULIB_FMODF''@/$(GL_GNULIB_FMODF)/g' \
664 -e 's/@''GNULIB_FMODL''@/$(GNULIB_FMODL)/g' \ 1042 -e 's/@''GNULIB_FMODL''@/$(GL_GNULIB_FMODL)/g' \
665 -e 's/@''GNULIB_FREXPF''@/$(GNULIB_FREXPF)/g' \ 1043 -e 's/@''GNULIB_FREXPF''@/$(GL_GNULIB_FREXPF)/g' \
666 -e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \ 1044 -e 's/@''GNULIB_FREXP''@/$(GL_GNULIB_FREXP)/g' \
667 -e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \ 1045 -e 's/@''GNULIB_FREXPL''@/$(GL_GNULIB_FREXPL)/g' \
668 -e 's/@''GNULIB_HYPOT''@/$(GNULIB_HYPOT)/g' \ 1046 -e 's/@''GNULIB_HYPOT''@/$(GL_GNULIB_HYPOT)/g' \
669 -e 's/@''GNULIB_HYPOTF''@/$(GNULIB_HYPOTF)/g' \ 1047 -e 's/@''GNULIB_HYPOTF''@/$(GL_GNULIB_HYPOTF)/g' \
670 -e 's/@''GNULIB_HYPOTL''@/$(GNULIB_HYPOTL)/g' \ 1048 -e 's/@''GNULIB_HYPOTL''@/$(GL_GNULIB_HYPOTL)/g' \
671 < $(srcdir)/math.in.h | \ 1049 < $(srcdir)/math.in.h | \
672 sed -e 's/@''GNULIB_ILOGB''@/$(GNULIB_ILOGB)/g' \ 1050 sed -e 's/@''GNULIB_ILOGB''@/$(GL_GNULIB_ILOGB)/g' \
673 -e 's/@''GNULIB_ILOGBF''@/$(GNULIB_ILOGBF)/g' \ 1051 -e 's/@''GNULIB_ILOGBF''@/$(GL_GNULIB_ILOGBF)/g' \
674 -e 's/@''GNULIB_ILOGBL''@/$(GNULIB_ILOGBL)/g' \ 1052 -e 's/@''GNULIB_ILOGBL''@/$(GL_GNULIB_ILOGBL)/g' \
675 -e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \ 1053 -e 's/@''GNULIB_ISFINITE''@/$(GL_GNULIB_ISFINITE)/g' \
676 -e 's/@''GNULIB_ISINF''@/$(GNULIB_ISINF)/g' \ 1054 -e 's/@''GNULIB_ISINF''@/$(GL_GNULIB_ISINF)/g' \
677 -e 's/@''GNULIB_ISNAN''@/$(GNULIB_ISNAN)/g' \ 1055 -e 's/@''GNULIB_ISNAN''@/$(GL_GNULIB_ISNAN)/g' \
678 -e 's/@''GNULIB_ISNANF''@/$(GNULIB_ISNANF)/g' \ 1056 -e 's/@''GNULIB_ISNANF''@/$(GL_GNULIB_ISNANF)/g' \
679 -e 's/@''GNULIB_ISNAND''@/$(GNULIB_ISNAND)/g' \ 1057 -e 's/@''GNULIB_ISNAND''@/$(GL_GNULIB_ISNAND)/g' \
680 -e 's/@''GNULIB_ISNANL''@/$(GNULIB_ISNANL)/g' \ 1058 -e 's/@''GNULIB_ISNANL''@/$(GL_GNULIB_ISNANL)/g' \
681 -e 's/@''GNULIB_LDEXPF''@/$(GNULIB_LDEXPF)/g' \ 1059 -e 's/@''GNULIB_LDEXPF''@/$(GL_GNULIB_LDEXPF)/g' \
682 -e 's/@''GNULIB_LDEXPL''@/$(GNULIB_LDEXPL)/g' \ 1060 -e 's/@''GNULIB_LDEXPL''@/$(GL_GNULIB_LDEXPL)/g' \
683 -e 's/@''GNULIB_LOG''@/$(GNULIB_LOG)/g' \ 1061 -e 's/@''GNULIB_LOG''@/$(GL_GNULIB_LOG)/g' \
684 -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \ 1062 -e 's/@''GNULIB_LOGF''@/$(GL_GNULIB_LOGF)/g' \
685 -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \ 1063 -e 's/@''GNULIB_LOGL''@/$(GL_GNULIB_LOGL)/g' \
686 -e 's/@''GNULIB_LOG10''@/$(GNULIB_LOG10)/g' \ 1064 -e 's/@''GNULIB_LOG10''@/$(GL_GNULIB_LOG10)/g' \
687 -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \ 1065 -e 's/@''GNULIB_LOG10F''@/$(GL_GNULIB_LOG10F)/g' \
688 -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \ 1066 -e 's/@''GNULIB_LOG10L''@/$(GL_GNULIB_LOG10L)/g' \
689 -e 's/@''GNULIB_LOG1P''@/$(GNULIB_LOG1P)/g' \ 1067 -e 's/@''GNULIB_LOG1P''@/$(GL_GNULIB_LOG1P)/g' \
690 -e 's/@''GNULIB_LOG1PF''@/$(GNULIB_LOG1PF)/g' \ 1068 -e 's/@''GNULIB_LOG1PF''@/$(GL_GNULIB_LOG1PF)/g' \
691 -e 's/@''GNULIB_LOG1PL''@/$(GNULIB_LOG1PL)/g' \ 1069 -e 's/@''GNULIB_LOG1PL''@/$(GL_GNULIB_LOG1PL)/g' \
692 -e 's/@''GNULIB_LOG2''@/$(GNULIB_LOG2)/g' \ 1070 -e 's/@''GNULIB_LOG2''@/$(GL_GNULIB_LOG2)/g' \
693 -e 's/@''GNULIB_LOG2F''@/$(GNULIB_LOG2F)/g' \ 1071 -e 's/@''GNULIB_LOG2F''@/$(GL_GNULIB_LOG2F)/g' \
694 -e 's/@''GNULIB_LOG2L''@/$(GNULIB_LOG2L)/g' \ 1072 -e 's/@''GNULIB_LOG2L''@/$(GL_GNULIB_LOG2L)/g' \
695 -e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \ 1073 -e 's/@''GNULIB_LOGB''@/$(GL_GNULIB_LOGB)/g' \
696 -e 's/@''GNULIB_LOGBF''@/$(GNULIB_LOGBF)/g' \ 1074 -e 's/@''GNULIB_LOGBF''@/$(GL_GNULIB_LOGBF)/g' \
697 -e 's/@''GNULIB_LOGBL''@/$(GNULIB_LOGBL)/g' \ 1075 -e 's/@''GNULIB_LOGBL''@/$(GL_GNULIB_LOGBL)/g' \
698 -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \ 1076 -e 's/@''GNULIB_MODF''@/$(GL_GNULIB_MODF)/g' \
699 -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ 1077 -e 's/@''GNULIB_MODFF''@/$(GL_GNULIB_MODFF)/g' \
700 -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \ 1078 -e 's/@''GNULIB_MODFL''@/$(GL_GNULIB_MODFL)/g' \
701 -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \ 1079 -e 's/@''GNULIB_POWF''@/$(GL_GNULIB_POWF)/g' \
702 -e 's/@''GNULIB_REMAINDER''@/$(GNULIB_REMAINDER)/g' \ 1080 -e 's/@''GNULIB_REMAINDER''@/$(GL_GNULIB_REMAINDER)/g' \
703 -e 's/@''GNULIB_REMAINDERF''@/$(GNULIB_REMAINDERF)/g' \ 1081 -e 's/@''GNULIB_REMAINDERF''@/$(GL_GNULIB_REMAINDERF)/g' \
704 -e 's/@''GNULIB_REMAINDERL''@/$(GNULIB_REMAINDERL)/g' \ 1082 -e 's/@''GNULIB_REMAINDERL''@/$(GL_GNULIB_REMAINDERL)/g' \
705 -e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \ 1083 -e 's/@''GNULIB_RINT''@/$(GL_GNULIB_RINT)/g' \
706 -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \ 1084 -e 's/@''GNULIB_RINTF''@/$(GL_GNULIB_RINTF)/g' \
707 -e 's/@''GNULIB_RINTL''@/$(GNULIB_RINTL)/g' \ 1085 -e 's/@''GNULIB_RINTL''@/$(GL_GNULIB_RINTL)/g' \
708 -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \ 1086 -e 's/@''GNULIB_ROUND''@/$(GL_GNULIB_ROUND)/g' \
709 -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \ 1087 -e 's/@''GNULIB_ROUNDF''@/$(GL_GNULIB_ROUNDF)/g' \
710 -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \ 1088 -e 's/@''GNULIB_ROUNDL''@/$(GL_GNULIB_ROUNDL)/g' \
711 -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \ 1089 -e 's/@''GNULIB_SIGNBIT''@/$(GL_GNULIB_SIGNBIT)/g' \
712 -e 's/@''GNULIB_SINF''@/$(GNULIB_SINF)/g' \ 1090 -e 's/@''GNULIB_SINF''@/$(GL_GNULIB_SINF)/g' \
713 -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ 1091 -e 's/@''GNULIB_SINL''@/$(GL_GNULIB_SINL)/g' \
714 -e 's/@''GNULIB_SINHF''@/$(GNULIB_SINHF)/g' \ 1092 -e 's/@''GNULIB_SINHF''@/$(GL_GNULIB_SINHF)/g' \
715 -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ 1093 -e 's/@''GNULIB_SQRTF''@/$(GL_GNULIB_SQRTF)/g' \
716 -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ 1094 -e 's/@''GNULIB_SQRTL''@/$(GL_GNULIB_SQRTL)/g' \
717 -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \ 1095 -e 's/@''GNULIB_TANF''@/$(GL_GNULIB_TANF)/g' \
718 -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \ 1096 -e 's/@''GNULIB_TANL''@/$(GL_GNULIB_TANL)/g' \
719 -e 's/@''GNULIB_TANHF''@/$(GNULIB_TANHF)/g' \ 1097 -e 's/@''GNULIB_TANHF''@/$(GL_GNULIB_TANHF)/g' \
720 -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \ 1098 -e 's/@''GNULIB_TRUNC''@/$(GL_GNULIB_TRUNC)/g' \
721 -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \ 1099 -e 's/@''GNULIB_TRUNCF''@/$(GL_GNULIB_TRUNCF)/g' \
722 -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \ 1100 -e 's/@''GNULIB_TRUNCL''@/$(GL_GNULIB_TRUNCL)/g' \
1101 -e 's/@''GNULIB_MDA_J0''@/$(GL_GNULIB_MDA_J0)/g' \
1102 -e 's/@''GNULIB_MDA_J1''@/$(GL_GNULIB_MDA_J1)/g' \
1103 -e 's/@''GNULIB_MDA_JN''@/$(GL_GNULIB_MDA_JN)/g' \
1104 -e 's/@''GNULIB_MDA_Y0''@/$(GL_GNULIB_MDA_Y0)/g' \
1105 -e 's/@''GNULIB_MDA_Y1''@/$(GL_GNULIB_MDA_Y1)/g' \
1106 -e 's/@''GNULIB_MDA_YN''@/$(GL_GNULIB_MDA_YN)/g' \
723 | \ 1107 | \
724 sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ 1108 sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \
725 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ 1109 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
@@ -818,13 +1202,22 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
818 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ 1202 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
819 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ 1203 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
820 | \ 1204 | \
821 sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \ 1205 sed -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \
1206 -e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \
1207 -e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \
1208 -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \
1209 -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \
822 -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \ 1210 -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \
823 -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ 1211 -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
824 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ 1212 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
825 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ 1213 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
1214 -e 's|@''REPLACE_COSF''@|$(REPLACE_COSF)|g' \
1215 -e 's|@''REPLACE_COSHF''@|$(REPLACE_COSHF)|g' \
1216 -e 's|@''REPLACE_EXPF''@|$(REPLACE_EXPF)|g' \
1217 -e 's|@''REPLACE_EXPL''@|$(REPLACE_EXPL)|g' \
826 -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \ 1218 -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \
827 -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \ 1219 -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \
1220 -e 's|@''REPLACE_EXPM1L''@|$(REPLACE_EXPM1L)|g' \
828 -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \ 1221 -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \
829 -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \ 1222 -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \
830 -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \ 1223 -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \
@@ -846,6 +1239,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
846 -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \ 1239 -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \
847 -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \ 1240 -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \
848 -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \ 1241 -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \
1242 -e 's|@''REPLACE_ILOGBL''@|$(REPLACE_ILOGBL)|g' \
849 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ 1243 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
850 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ 1244 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \
851 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ 1245 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \
@@ -873,20 +1267,26 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
873 -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \ 1267 -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \
874 -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \ 1268 -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \
875 -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \ 1269 -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \
1270 -e 's|@''REPLACE_RINTL''@|$(REPLACE_RINTL)|g' \
876 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ 1271 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \
877 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ 1272 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \
878 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ 1273 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
879 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ 1274 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \
880 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ 1275 -e 's|@''REPLACE_SIGNBIT_USING_BUILTINS''@|$(REPLACE_SIGNBIT_USING_BUILTINS)|g' \
1276 -e 's|@''REPLACE_SINF''@|$(REPLACE_SINF)|g' \
1277 -e 's|@''REPLACE_SINHF''@|$(REPLACE_SINHF)|g' \
1278 -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \
881 -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ 1279 -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \
1280 -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \
1281 -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \
882 -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ 1282 -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \
883 -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ 1283 -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \
884 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ 1284 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
885 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1285 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
886 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1286 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
887 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 1287 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
888 } > $@-t && \ 1288 > $@-t
889 mv $@-t $@ 1289 $(AM_V_at)mv $@-t $@
890MOSTLYCLEANFILES += math.h math.h-t 1290MOSTLYCLEANFILES += math.h math.h-t
891 1291
892EXTRA_DIST += math.in.h 1292EXTRA_DIST += math.in.h
@@ -895,40 +1295,50 @@ EXTRA_DIST += math.in.h
895 1295
896## begin gnulib module mbrtowc 1296## begin gnulib module mbrtowc
897 1297
1298if GL_COND_OBJ_MBRTOWC
1299libgnu_a_SOURCES += mbrtowc.c
1300endif
898 1301
899EXTRA_DIST += mbrtowc.c 1302EXTRA_DIST += lc-charset-dispatch.c lc-charset-dispatch.h mbrtowc-impl-utf8.h mbrtowc-impl.h mbtowc-lock.c mbtowc-lock.h windows-initguard.h
900 1303
901EXTRA_libgnu_a_SOURCES += mbrtowc.c 1304EXTRA_libgnu_a_SOURCES += lc-charset-dispatch.c mbtowc-lock.c
902 1305
903## end gnulib module mbrtowc 1306## end gnulib module mbrtowc
904 1307
905## begin gnulib module mbsinit 1308## begin gnulib module mbsinit
906 1309
907 1310if GL_COND_OBJ_MBSINIT
908EXTRA_DIST += mbsinit.c 1311libgnu_a_SOURCES += mbsinit.c
909 1312endif
910EXTRA_libgnu_a_SOURCES += mbsinit.c
911 1313
912## end gnulib module mbsinit 1314## end gnulib module mbsinit
913 1315
914## begin gnulib module mbtowc 1316## begin gnulib module mbtowc
915 1317
1318if GL_COND_OBJ_MBTOWC
1319libgnu_a_SOURCES += mbtowc.c
1320endif
916 1321
917EXTRA_DIST += mbtowc-impl.h mbtowc.c 1322EXTRA_DIST += mbtowc-impl.h
918
919EXTRA_libgnu_a_SOURCES += mbtowc.c
920 1323
921## end gnulib module mbtowc 1324## end gnulib module mbtowc
922 1325
923## begin gnulib module memchr 1326## begin gnulib module memchr
924 1327
1328if GL_COND_OBJ_MEMCHR
1329libgnu_a_SOURCES += memchr.c
1330endif
925 1331
926EXTRA_DIST += memchr.c memchr.valgrind 1332EXTRA_DIST += memchr.valgrind
927
928EXTRA_libgnu_a_SOURCES += memchr.c
929 1333
930## end gnulib module memchr 1334## end gnulib module memchr
931 1335
1336## begin gnulib module minmax
1337
1338libgnu_a_SOURCES += minmax.h
1339
1340## end gnulib module minmax
1341
932## begin gnulib module mktime 1342## begin gnulib module mktime
933 1343
934 1344
@@ -949,28 +1359,31 @@ EXTRA_libgnu_a_SOURCES += mktime.c
949 1359
950## begin gnulib module mountlist 1360## begin gnulib module mountlist
951 1361
1362if GL_COND_OBJ_MOUNTLIST
1363libgnu_a_SOURCES += mountlist.c
1364endif
952 1365
953EXTRA_DIST += mountlist.c mountlist.h 1366EXTRA_DIST += mountlist.h
954
955EXTRA_libgnu_a_SOURCES += mountlist.c
956 1367
957## end gnulib module mountlist 1368## end gnulib module mountlist
958 1369
959## begin gnulib module msvc-inval 1370## begin gnulib module msvc-inval
960 1371
1372if GL_COND_OBJ_MSVC_INVAL
1373libgnu_a_SOURCES += msvc-inval.c
1374endif
961 1375
962EXTRA_DIST += msvc-inval.c msvc-inval.h 1376EXTRA_DIST += msvc-inval.h
963
964EXTRA_libgnu_a_SOURCES += msvc-inval.c
965 1377
966## end gnulib module msvc-inval 1378## end gnulib module msvc-inval
967 1379
968## begin gnulib module msvc-nothrow 1380## begin gnulib module msvc-nothrow
969 1381
1382if GL_COND_OBJ_MSVC_NOTHROW
1383libgnu_a_SOURCES += msvc-nothrow.c
1384endif
970 1385
971EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h 1386EXTRA_DIST += msvc-nothrow.h
972
973EXTRA_libgnu_a_SOURCES += msvc-nothrow.c
974 1387
975## end gnulib module msvc-nothrow 1388## end gnulib module msvc-nothrow
976 1389
@@ -981,27 +1394,26 @@ BUILT_SOURCES += netdb.h
981# We need the following in order to create <netdb.h> when the system 1394# We need the following in order to create <netdb.h> when the system
982# doesn't have one that works with the given compiler. 1395# doesn't have one that works with the given compiler.
983netdb.h: netdb.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1396netdb.h: netdb.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
984 $(AM_V_GEN)rm -f $@-t $@ && \ 1397 $(gl_V_at)$(SED_HEADER_STDOUT) \
985 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1398 -e 's|@''GUARD_PREFIX''@|GL|g' \
986 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
987 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1399 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
988 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1400 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
989 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1401 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
990 -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \ 1402 -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \
991 -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \ 1403 -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
992 -e 's/@''GNULIB_GETADDRINFO''@/$(GNULIB_GETADDRINFO)/g' \ 1404 -e 's/@''GNULIB_GETADDRINFO''@/$(GL_GNULIB_GETADDRINFO)/g' \
993 -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \ 1405 -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \
994 -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \ 1406 -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \
995 -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \ 1407 -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
996 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ 1408 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
997 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ 1409 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
998 -e 's|@''REPLACE_GAI_STRERROR''@|$(REPLACE_GAI_STRERROR)|g' \ 1410 -e 's|@''REPLACE_GAI_STRERROR''@|$(REPLACE_GAI_STRERROR)|g' \
1411 -e 's|@''REPLACE_GETADDRINFO''@|$(REPLACE_GETADDRINFO)|g' \
999 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1412 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1000 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1413 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1001 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 1414 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1002 < $(srcdir)/netdb.in.h; \ 1415 $(srcdir)/netdb.in.h > $@-t
1003 } > $@-t && \ 1416 $(AM_V_at)mv $@-t $@
1004 mv $@-t $@
1005MOSTLYCLEANFILES += netdb.h netdb.h-t 1417MOSTLYCLEANFILES += netdb.h netdb.h-t
1006 1418
1007EXTRA_DIST += netdb.in.h 1419EXTRA_DIST += netdb.in.h
@@ -1016,18 +1428,16 @@ BUILT_SOURCES += $(NETINET_IN_H)
1016# doesn't have one. 1428# doesn't have one.
1017if GL_GENERATE_NETINET_IN_H 1429if GL_GENERATE_NETINET_IN_H
1018netinet/in.h: netinet_in.in.h $(top_builddir)/config.status 1430netinet/in.h: netinet_in.in.h $(top_builddir)/config.status
1019 $(AM_V_at)$(MKDIR_P) netinet 1431 $(AM_V_GEN)$(MKDIR_P) '%reldir%/netinet'
1020 $(AM_V_GEN)rm -f $@-t $@ && \ 1432 $(AM_V_at)$(SED_HEADER_STDOUT) \
1021 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1433 -e 's|@''GUARD_PREFIX''@|GL|g' \
1022 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1023 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1434 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1024 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1435 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1025 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1436 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1026 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ 1437 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
1027 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ 1438 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
1028 < $(srcdir)/netinet_in.in.h; \ 1439 $(srcdir)/netinet_in.in.h > $@-t
1029 } > $@-t && \ 1440 $(AM_V_at)mv $@-t $@
1030 mv $@-t $@
1031else 1441else
1032netinet/in.h: $(top_builddir)/config.status 1442netinet/in.h: $(top_builddir)/config.status
1033 rm -f $@ 1443 rm -f $@
@@ -1041,48 +1451,89 @@ EXTRA_DIST += netinet_in.in.h
1041 1451
1042## begin gnulib module nl_langinfo 1452## begin gnulib module nl_langinfo
1043 1453
1454if GL_COND_OBJ_NL_LANGINFO
1455libgnu_a_SOURCES += nl_langinfo.c
1456endif
1457if GL_COND_OBJ_NL_LANGINFO_LOCK
1458libgnu_a_SOURCES += nl_langinfo-lock.c
1459endif
1044 1460
1045EXTRA_DIST += nl_langinfo.c 1461EXTRA_DIST += windows-initguard.h
1046
1047EXTRA_libgnu_a_SOURCES += nl_langinfo.c
1048 1462
1049## end gnulib module nl_langinfo 1463## end gnulib module nl_langinfo
1050 1464
1051## begin gnulib module read 1465## begin gnulib module open
1052 1466
1467if GL_COND_OBJ_OPEN
1468libgnu_a_SOURCES += open.c
1469endif
1053 1470
1054EXTRA_DIST += read.c 1471## end gnulib module open
1055 1472
1056EXTRA_libgnu_a_SOURCES += read.c 1473## begin gnulib module pathmax
1057 1474
1058## end gnulib module read
1059 1475
1060## begin gnulib module regex 1476EXTRA_DIST += pathmax.h
1061 1477
1478## end gnulib module pathmax
1062 1479
1063EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c 1480## begin gnulib module realloc-gnu
1064 1481
1065EXTRA_libgnu_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
1066 1482
1067## end gnulib module regex 1483EXTRA_DIST += realloc.c
1068 1484
1069## begin gnulib module safe-read 1485EXTRA_libgnu_a_SOURCES += realloc.c
1070 1486
1071libgnu_a_SOURCES += safe-read.c 1487## end gnulib module realloc-gnu
1072 1488
1073EXTRA_DIST += safe-read.h 1489## begin gnulib module realloc-posix
1074 1490
1075## end gnulib module safe-read
1076 1491
1077## begin gnulib module setenv 1492EXTRA_DIST += realloc.c
1493
1494EXTRA_libgnu_a_SOURCES += realloc.c
1495
1496## end gnulib module realloc-posix
1497
1498## begin gnulib module reallocarray
1499
1500if GL_COND_OBJ_REALLOCARRAY
1501libgnu_a_SOURCES += reallocarray.c
1502endif
1078 1503
1504## end gnulib module reallocarray
1079 1505
1080EXTRA_DIST += setenv.c 1506## begin gnulib module regex
1507
1508if GL_COND_OBJ_REGEX
1509libgnu_a_SOURCES += regex.c
1510endif
1511
1512EXTRA_DIST += regcomp.c regex.h regex_internal.c regex_internal.h regexec.c
1513
1514EXTRA_libgnu_a_SOURCES += regcomp.c regex_internal.c regexec.c
1515
1516## end gnulib module regex
1517
1518## begin gnulib module setenv
1081 1519
1082EXTRA_libgnu_a_SOURCES += setenv.c 1520if GL_COND_OBJ_SETENV
1521libgnu_a_SOURCES += setenv.c
1522endif
1083 1523
1084## end gnulib module setenv 1524## end gnulib module setenv
1085 1525
1526## begin gnulib module setlocale-null
1527
1528libgnu_a_SOURCES += setlocale_null.c
1529if GL_COND_OBJ_SETLOCALE_LOCK
1530libgnu_a_SOURCES += setlocale-lock.c
1531endif
1532
1533EXTRA_DIST += setlocale_null.h windows-initguard.h
1534
1535## end gnulib module setlocale-null
1536
1086## begin gnulib module size_max 1537## begin gnulib module size_max
1087 1538
1088libgnu_a_SOURCES += size_max.h 1539libgnu_a_SOURCES += size_max.h
@@ -1092,81 +1543,48 @@ libgnu_a_SOURCES += size_max.h
1092## begin gnulib module snippet/_Noreturn 1543## begin gnulib module snippet/_Noreturn
1093 1544
1094# Because this Makefile snippet defines a variable used by other 1545# Because this Makefile snippet defines a variable used by other
1095# gnulib Makefile snippets, it must be present in all Makefile.am that 1546# gnulib Makefile snippets, it must be present in all makefiles that
1096# need it. This is ensured by the applicability 'all' defined above. 1547# need it. This is ensured by the applicability 'all' defined above.
1097 1548
1098_NORETURN_H=$(top_srcdir)/build-aux/snippet/_Noreturn.h 1549_NORETURN_H=$(srcdir)/_Noreturn.h
1099 1550
1100EXTRA_DIST += $(top_srcdir)/build-aux/snippet/_Noreturn.h 1551EXTRA_DIST += _Noreturn.h
1101 1552
1102## end gnulib module snippet/_Noreturn 1553## end gnulib module snippet/_Noreturn
1103 1554
1104## begin gnulib module snippet/arg-nonnull 1555## begin gnulib module snippet/arg-nonnull
1105 1556
1106# The BUILT_SOURCES created by this Makefile snippet are not used via #include 1557# Because this Makefile snippet defines a variable used by other
1107# statements but through direct file reference. Therefore this snippet must be 1558# gnulib Makefile snippets, it must be present in all makefiles that
1108# present in all Makefile.am that need it. This is ensured by the applicability 1559# need it. This is ensured by the applicability 'all' defined above.
1109# 'all' defined above.
1110
1111BUILT_SOURCES += arg-nonnull.h
1112# The arg-nonnull.h that gets inserted into generated .h files is the same as
1113# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
1114# off.
1115arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h
1116 $(AM_V_GEN)rm -f $@-t $@ && \
1117 sed -n -e '/GL_ARG_NONNULL/,$$p' \
1118 < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \
1119 > $@-t && \
1120 mv $@-t $@
1121MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
1122 1560
1123ARG_NONNULL_H=arg-nonnull.h 1561ARG_NONNULL_H=$(srcdir)/arg-nonnull.h
1124 1562
1125EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h 1563EXTRA_DIST += arg-nonnull.h
1126 1564
1127## end gnulib module snippet/arg-nonnull 1565## end gnulib module snippet/arg-nonnull
1128 1566
1129## begin gnulib module snippet/c++defs 1567## begin gnulib module snippet/c++defs
1130 1568
1131# The BUILT_SOURCES created by this Makefile snippet are not used via #include 1569# Because this Makefile snippet defines a variable used by other
1132# statements but through direct file reference. Therefore this snippet must be 1570# gnulib Makefile snippets, it must be present in all makefiles that
1133# present in all Makefile.am that need it. This is ensured by the applicability 1571# need it. This is ensured by the applicability 'all' defined above.
1134# 'all' defined above.
1135
1136BUILT_SOURCES += c++defs.h
1137# The c++defs.h that gets inserted into generated .h files is the same as
1138# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
1139c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h
1140 $(AM_V_GEN)rm -f $@-t $@ && \
1141 sed -n -e '/_GL_CXXDEFS/,$$p' \
1142 < $(top_srcdir)/build-aux/snippet/c++defs.h \
1143 > $@-t && \
1144 mv $@-t $@
1145MOSTLYCLEANFILES += c++defs.h c++defs.h-t
1146 1572
1147CXXDEFS_H=c++defs.h 1573CXXDEFS_H=$(srcdir)/c++defs.h
1148 1574
1149EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h 1575EXTRA_DIST += c++defs.h
1150 1576
1151## end gnulib module snippet/c++defs 1577## end gnulib module snippet/c++defs
1152 1578
1153## begin gnulib module snippet/warn-on-use 1579## begin gnulib module snippet/warn-on-use
1154 1580
1155BUILT_SOURCES += warn-on-use.h 1581# Because this Makefile snippet defines a variable used by other
1156# The warn-on-use.h that gets inserted into generated .h files is the same as 1582# gnulib Makefile snippets, it must be present in all makefiles that
1157# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut 1583# need it. This is ensured by the applicability 'all' defined above.
1158# off.
1159warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h
1160 $(AM_V_GEN)rm -f $@-t $@ && \
1161 sed -n -e '/^.ifndef/,$$p' \
1162 < $(top_srcdir)/build-aux/snippet/warn-on-use.h \
1163 > $@-t && \
1164 mv $@-t $@
1165MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
1166 1584
1167WARN_ON_USE_H=warn-on-use.h 1585WARN_ON_USE_H=$(srcdir)/warn-on-use.h
1168 1586
1169EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h 1587EXTRA_DIST += warn-on-use.h
1170 1588
1171## end gnulib module snippet/warn-on-use 1589## end gnulib module snippet/warn-on-use
1172 1590
@@ -1187,6 +1605,26 @@ EXTRA_DIST += w32sock.h
1187 1605
1188## end gnulib module sockets 1606## end gnulib module sockets
1189 1607
1608## begin gnulib module stat
1609
1610if GL_COND_OBJ_STAT
1611libgnu_a_SOURCES += stat.c
1612endif
1613
1614EXTRA_DIST += stat-w32.c stat-w32.h
1615
1616EXTRA_libgnu_a_SOURCES += stat-w32.c
1617
1618## end gnulib module stat
1619
1620## begin gnulib module stat-time
1621
1622libgnu_a_SOURCES += stat-time.c
1623
1624EXTRA_DIST += stat-time.h
1625
1626## end gnulib module stat-time
1627
1190## begin gnulib module stdalign 1628## begin gnulib module stdalign
1191 1629
1192BUILT_SOURCES += $(STDALIGN_H) 1630BUILT_SOURCES += $(STDALIGN_H)
@@ -1195,11 +1633,8 @@ BUILT_SOURCES += $(STDALIGN_H)
1195# doesn't have one that works. 1633# doesn't have one that works.
1196if GL_GENERATE_STDALIGN_H 1634if GL_GENERATE_STDALIGN_H
1197stdalign.h: stdalign.in.h $(top_builddir)/config.status 1635stdalign.h: stdalign.in.h $(top_builddir)/config.status
1198 $(AM_V_GEN)rm -f $@-t $@ && \ 1636 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/stdalign.in.h
1199 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1637 $(AM_V_at)mv $@-t $@
1200 cat $(srcdir)/stdalign.in.h; \
1201 } > $@-t && \
1202 mv $@-t $@
1203else 1638else
1204stdalign.h: $(top_builddir)/config.status 1639stdalign.h: $(top_builddir)/config.status
1205 rm -f $@ 1640 rm -f $@
@@ -1210,28 +1645,26 @@ EXTRA_DIST += stdalign.in.h
1210 1645
1211## end gnulib module stdalign 1646## end gnulib module stdalign
1212 1647
1213## begin gnulib module stdbool 1648## begin gnulib module stdckdint
1214 1649
1215BUILT_SOURCES += $(STDBOOL_H) 1650BUILT_SOURCES += $(STDCKDINT_H)
1216 1651
1217# We need the following in order to create <stdbool.h> when the system 1652# We need the following in order to create <stdckdint.h> when the system
1218# doesn't have one that works. 1653# doesn't have one that works with the given compiler.
1219if GL_GENERATE_STDBOOL_H 1654if GL_GENERATE_STDCKDINT_H
1220stdbool.h: stdbool.in.h $(top_builddir)/config.status 1655stdckdint.h: stdckdint.in.h $(top_builddir)/config.status
1221 $(AM_V_GEN)rm -f $@-t $@ && \ 1656 $(gl_V_at)$(SED_HEADER_STDOUT) \
1222 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1657 $(srcdir)/stdckdint.in.h > $@-t
1223 sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ 1658 $(AM_V_at)mv $@-t $@
1224 } > $@-t && \
1225 mv $@-t $@
1226else 1659else
1227stdbool.h: $(top_builddir)/config.status 1660stdckdint.h: $(top_builddir)/config.status
1228 rm -f $@ 1661 rm -f $@
1229endif 1662endif
1230MOSTLYCLEANFILES += stdbool.h stdbool.h-t 1663MOSTLYCLEANFILES += stdckdint.h stdckdint.h-t
1231 1664
1232EXTRA_DIST += stdbool.in.h 1665EXTRA_DIST += intprops-internal.h stdckdint.in.h
1233 1666
1234## end gnulib module stdbool 1667## end gnulib module stdckdint
1235 1668
1236## begin gnulib module stddef 1669## begin gnulib module stddef
1237 1670
@@ -1241,18 +1674,17 @@ BUILT_SOURCES += $(STDDEF_H)
1241# doesn't have one that works with the given compiler. 1674# doesn't have one that works with the given compiler.
1242if GL_GENERATE_STDDEF_H 1675if GL_GENERATE_STDDEF_H
1243stddef.h: stddef.in.h $(top_builddir)/config.status 1676stddef.h: stddef.in.h $(top_builddir)/config.status
1244 $(AM_V_GEN)rm -f $@-t $@ && \ 1677 $(gl_V_at)$(SED_HEADER_STDOUT) \
1245 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1678 -e 's|@''GUARD_PREFIX''@|GL|g' \
1246 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1247 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1679 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1248 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1680 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1249 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1681 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1250 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ 1682 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
1683 -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
1251 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ 1684 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
1252 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ 1685 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
1253 < $(srcdir)/stddef.in.h; \ 1686 $(srcdir)/stddef.in.h > $@-t
1254 } > $@-t && \ 1687 $(AM_V_at)mv $@-t $@
1255 mv $@-t $@
1256else 1688else
1257stddef.h: $(top_builddir)/config.status 1689stddef.h: $(top_builddir)/config.status
1258 rm -f $@ 1690 rm -f $@
@@ -1271,21 +1703,19 @@ BUILT_SOURCES += $(STDINT_H)
1271# doesn't have one that works with the given compiler. 1703# doesn't have one that works with the given compiler.
1272if GL_GENERATE_STDINT_H 1704if GL_GENERATE_STDINT_H
1273stdint.h: stdint.in.h $(top_builddir)/config.status 1705stdint.h: stdint.in.h $(top_builddir)/config.status
1274 $(AM_V_GEN)rm -f $@-t $@ && \ 1706 $(gl_V_at)$(SED_HEADER_STDOUT) \
1275 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1707 -e 's|@''GUARD_PREFIX''@|GL|g' \
1276 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1277 -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ 1708 -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
1278 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1709 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1279 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1710 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1280 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1711 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1281 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ 1712 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
1713 -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \
1282 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ 1714 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
1283 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ 1715 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
1284 -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ 1716 -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
1285 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ 1717 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
1286 -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ 1718 -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
1287 -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
1288 -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
1289 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ 1719 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
1290 -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ 1720 -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
1291 -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ 1721 -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
@@ -1300,9 +1730,9 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
1300 -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ 1730 -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
1301 -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ 1731 -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
1302 -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ 1732 -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
1303 < $(srcdir)/stdint.in.h; \ 1733 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
1304 } > $@-t && \ 1734 $(srcdir)/stdint.in.h > $@-t
1305 mv $@-t $@ 1735 $(AM_V_at)mv $@-t $@
1306else 1736else
1307stdint.h: $(top_builddir)/config.status 1737stdint.h: $(top_builddir)/config.status
1308 rm -f $@ 1738 rm -f $@
@@ -1320,68 +1750,75 @@ BUILT_SOURCES += stdio.h
1320# We need the following in order to create <stdio.h> when the system 1750# We need the following in order to create <stdio.h> when the system
1321# doesn't have one that works with the given compiler. 1751# doesn't have one that works with the given compiler.
1322stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1752stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1323 $(AM_V_GEN)rm -f $@-t $@ && \ 1753 $(gl_V_at)$(SED_HEADER_STDOUT) \
1324 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1754 -e 's|@''GUARD_PREFIX''@|GL|g' \
1325 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1326 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1755 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1327 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1756 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1328 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1757 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1329 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ 1758 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
1330 -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ 1759 -e 's/@''GNULIB_DPRINTF''@/$(GL_GNULIB_DPRINTF)/g' \
1331 -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ 1760 -e 's/@''GNULIB_FCLOSE''@/$(GL_GNULIB_FCLOSE)/g' \
1332 -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \ 1761 -e 's/@''GNULIB_FDOPEN''@/$(GL_GNULIB_FDOPEN)/g' \
1333 -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ 1762 -e 's/@''GNULIB_FFLUSH''@/$(GL_GNULIB_FFLUSH)/g' \
1334 -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ 1763 -e 's/@''GNULIB_FGETC''@/$(GL_GNULIB_FGETC)/g' \
1335 -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ 1764 -e 's/@''GNULIB_FGETS''@/$(GL_GNULIB_FGETS)/g' \
1336 -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \ 1765 -e 's/@''GNULIB_FOPEN''@/$(GL_GNULIB_FOPEN)/g' \
1337 -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \ 1766 -e 's/@''GNULIB_FOPEN_GNU''@/$(GL_GNULIB_FOPEN_GNU)/g' \
1338 -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \ 1767 -e 's/@''GNULIB_FPRINTF''@/$(GL_GNULIB_FPRINTF)/g' \
1339 -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \ 1768 -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GL_GNULIB_FPRINTF_POSIX)/g' \
1340 -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \ 1769 -e 's/@''GNULIB_FPURGE''@/$(GL_GNULIB_FPURGE)/g' \
1341 -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \ 1770 -e 's/@''GNULIB_FPUTC''@/$(GL_GNULIB_FPUTC)/g' \
1342 -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \ 1771 -e 's/@''GNULIB_FPUTS''@/$(GL_GNULIB_FPUTS)/g' \
1343 -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \ 1772 -e 's/@''GNULIB_FREAD''@/$(GL_GNULIB_FREAD)/g' \
1344 -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \ 1773 -e 's/@''GNULIB_FREOPEN''@/$(GL_GNULIB_FREOPEN)/g' \
1345 -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \ 1774 -e 's/@''GNULIB_FSCANF''@/$(GL_GNULIB_FSCANF)/g' \
1346 -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \ 1775 -e 's/@''GNULIB_FSEEK''@/$(GL_GNULIB_FSEEK)/g' \
1347 -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \ 1776 -e 's/@''GNULIB_FSEEKO''@/$(GL_GNULIB_FSEEKO)/g' \
1348 -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \ 1777 -e 's/@''GNULIB_FTELL''@/$(GL_GNULIB_FTELL)/g' \
1349 -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \ 1778 -e 's/@''GNULIB_FTELLO''@/$(GL_GNULIB_FTELLO)/g' \
1350 -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \ 1779 -e 's/@''GNULIB_FWRITE''@/$(GL_GNULIB_FWRITE)/g' \
1351 -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \ 1780 -e 's/@''GNULIB_GETC''@/$(GL_GNULIB_GETC)/g' \
1352 -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \ 1781 -e 's/@''GNULIB_GETCHAR''@/$(GL_GNULIB_GETCHAR)/g' \
1353 -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \ 1782 -e 's/@''GNULIB_GETDELIM''@/$(GL_GNULIB_GETDELIM)/g' \
1354 -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ 1783 -e 's/@''GNULIB_GETLINE''@/$(GL_GNULIB_GETLINE)/g' \
1355 -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ 1784 -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GL_GNULIB_OBSTACK_PRINTF)/g' \
1356 -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \ 1785 -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GL_GNULIB_OBSTACK_PRINTF_POSIX)/g' \
1357 -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ 1786 -e 's/@''GNULIB_PCLOSE''@/$(GL_GNULIB_PCLOSE)/g' \
1358 -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ 1787 -e 's/@''GNULIB_PERROR''@/$(GL_GNULIB_PERROR)/g' \
1359 -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ 1788 -e 's/@''GNULIB_POPEN''@/$(GL_GNULIB_POPEN)/g' \
1360 -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \ 1789 -e 's/@''GNULIB_PRINTF''@/$(GL_GNULIB_PRINTF)/g' \
1361 -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \ 1790 -e 's/@''GNULIB_PRINTF_POSIX''@/$(GL_GNULIB_PRINTF_POSIX)/g' \
1362 -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \ 1791 -e 's/@''GNULIB_PUTC''@/$(GL_GNULIB_PUTC)/g' \
1363 -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \ 1792 -e 's/@''GNULIB_PUTCHAR''@/$(GL_GNULIB_PUTCHAR)/g' \
1364 -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \ 1793 -e 's/@''GNULIB_PUTS''@/$(GL_GNULIB_PUTS)/g' \
1365 -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \ 1794 -e 's/@''GNULIB_REMOVE''@/$(GL_GNULIB_REMOVE)/g' \
1366 -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \ 1795 -e 's/@''GNULIB_RENAME''@/$(GL_GNULIB_RENAME)/g' \
1367 -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \ 1796 -e 's/@''GNULIB_RENAMEAT''@/$(GL_GNULIB_RENAMEAT)/g' \
1368 -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \ 1797 -e 's/@''GNULIB_SCANF''@/$(GL_GNULIB_SCANF)/g' \
1369 -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \ 1798 -e 's/@''GNULIB_SNPRINTF''@/$(GL_GNULIB_SNPRINTF)/g' \
1370 -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \ 1799 -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GL_GNULIB_SPRINTF_POSIX)/g' \
1371 -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \ 1800 -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GL_GNULIB_STDIO_H_NONBLOCKING)/g' \
1372 -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \ 1801 -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GL_GNULIB_STDIO_H_SIGPIPE)/g' \
1373 -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \ 1802 -e 's/@''GNULIB_TMPFILE''@/$(GL_GNULIB_TMPFILE)/g' \
1374 -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \ 1803 -e 's/@''GNULIB_VASPRINTF''@/$(GL_GNULIB_VASPRINTF)/g' \
1375 -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \ 1804 -e 's/@''GNULIB_VDPRINTF''@/$(GL_GNULIB_VDPRINTF)/g' \
1376 -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \ 1805 -e 's/@''GNULIB_VFPRINTF''@/$(GL_GNULIB_VFPRINTF)/g' \
1377 -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \ 1806 -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GL_GNULIB_VFPRINTF_POSIX)/g' \
1378 -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \ 1807 -e 's/@''GNULIB_VFSCANF''@/$(GL_GNULIB_VFSCANF)/g' \
1379 -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \ 1808 -e 's/@''GNULIB_VSCANF''@/$(GL_GNULIB_VSCANF)/g' \
1380 -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \ 1809 -e 's/@''GNULIB_VPRINTF''@/$(GL_GNULIB_VPRINTF)/g' \
1381 -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \ 1810 -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GL_GNULIB_VPRINTF_POSIX)/g' \
1382 -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \ 1811 -e 's/@''GNULIB_VSNPRINTF''@/$(GL_GNULIB_VSNPRINTF)/g' \
1812 -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GL_GNULIB_VSPRINTF_POSIX)/g' \
1813 -e 's/@''GNULIB_MDA_FCLOSEALL''@/$(GL_GNULIB_MDA_FCLOSEALL)/g' \
1814 -e 's/@''GNULIB_MDA_FDOPEN''@/$(GL_GNULIB_MDA_FDOPEN)/g' \
1815 -e 's/@''GNULIB_MDA_FILENO''@/$(GL_GNULIB_MDA_FILENO)/g' \
1816 -e 's/@''GNULIB_MDA_GETW''@/$(GL_GNULIB_MDA_GETW)/g' \
1817 -e 's/@''GNULIB_MDA_PUTW''@/$(GL_GNULIB_MDA_PUTW)/g' \
1818 -e 's/@''GNULIB_MDA_TEMPNAM''@/$(GL_GNULIB_MDA_TEMPNAM)/g' \
1383 < $(srcdir)/stdio.in.h | \ 1819 < $(srcdir)/stdio.in.h | \
1384 sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ 1820 sed -e 's|@''HAVE_DECL_FCLOSEALL''@|$(HAVE_DECL_FCLOSEALL)|g' \
1821 -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
1385 -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ 1822 -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
1386 -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ 1823 -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
1387 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ 1824 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
@@ -1402,6 +1839,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1402 -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ 1839 -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
1403 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ 1840 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
1404 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ 1841 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
1842 -e 's|@''REPLACE_FOPEN_FOR_FOPEN_GNU''@|$(REPLACE_FOPEN_FOR_FOPEN_GNU)|g' \
1405 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ 1843 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
1406 -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ 1844 -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
1407 -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ 1845 -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
@@ -1432,11 +1870,18 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1432 -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \ 1870 -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \
1433 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1871 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1434 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1872 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1435 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 1873 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1436 } > $@-t && \ 1874 > $@-t
1437 mv $@-t $@ 1875 $(AM_V_at)mv $@-t $@
1438MOSTLYCLEANFILES += stdio.h stdio.h-t 1876MOSTLYCLEANFILES += stdio.h stdio.h-t
1439 1877
1878if GL_COND_OBJ_STDIO_READ
1879libgnu_a_SOURCES += stdio-read.c
1880endif
1881if GL_COND_OBJ_STDIO_WRITE
1882libgnu_a_SOURCES += stdio-write.c
1883endif
1884
1440EXTRA_DIST += stdio.in.h 1885EXTRA_DIST += stdio.in.h
1441 1886
1442## end gnulib module stdio 1887## end gnulib module stdio
@@ -1449,95 +1894,141 @@ BUILT_SOURCES += stdlib.h
1449# doesn't have one that works with the given compiler. 1894# doesn't have one that works with the given compiler.
1450stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ 1895stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1451 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1896 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1452 $(AM_V_GEN)rm -f $@-t $@ && \ 1897 $(gl_V_at)$(SED_HEADER_STDOUT) \
1453 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1898 -e 's|@''GUARD_PREFIX''@|GL|g' \
1454 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1455 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1899 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1456 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1900 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1457 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1901 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1458 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ 1902 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
1459 -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \ 1903 -e 's/@''GNULIB__EXIT''@/$(GL_GNULIB__EXIT)/g' \
1460 -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \ 1904 -e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GL_GNULIB_ALIGNED_ALLOC)/g' \
1461 -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \ 1905 -e 's/@''GNULIB_ATOLL''@/$(GL_GNULIB_ATOLL)/g' \
1462 -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \ 1906 -e 's/@''GNULIB_CALLOC_GNU''@/$(GL_GNULIB_CALLOC_GNU)/g' \
1463 -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \ 1907 -e 's/@''GNULIB_CALLOC_POSIX''@/$(GL_GNULIB_CALLOC_POSIX)/g' \
1464 -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \ 1908 -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GL_GNULIB_CANONICALIZE_FILE_NAME)/g' \
1465 -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \ 1909 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
1466 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \ 1910 -e 's/@''GNULIB_GETLOADAVG''@/$(GL_GNULIB_GETLOADAVG)/g' \
1467 -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \ 1911 -e 's/@''GNULIB_GETSUBOPT''@/$(GL_GNULIB_GETSUBOPT)/g' \
1468 -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \ 1912 -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \
1469 -e 's/@''GNULIB_MKOSTEMP''@/$(GNULIB_MKOSTEMP)/g' \ 1913 -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \
1470 -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \ 1914 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \
1471 -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \ 1915 -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \
1472 -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \ 1916 -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \
1473 -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \ 1917 -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \
1474 -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ 1918 -e 's/@''GNULIB_MKOSTEMPS''@/$(GL_GNULIB_MKOSTEMPS)/g' \
1475 -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \ 1919 -e 's/@''GNULIB_MKSTEMP''@/$(GL_GNULIB_MKSTEMP)/g' \
1476 -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ 1920 -e 's/@''GNULIB_MKSTEMPS''@/$(GL_GNULIB_MKSTEMPS)/g' \
1477 -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \ 1921 -e 's/@''GNULIB_POSIX_MEMALIGN''@/$(GL_GNULIB_POSIX_MEMALIGN)/g' \
1478 -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ 1922 -e 's/@''GNULIB_POSIX_OPENPT''@/$(GL_GNULIB_POSIX_OPENPT)/g' \
1479 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \ 1923 -e 's/@''GNULIB_PTSNAME''@/$(GL_GNULIB_PTSNAME)/g' \
1480 -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \ 1924 -e 's/@''GNULIB_PTSNAME_R''@/$(GL_GNULIB_PTSNAME_R)/g' \
1481 -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \ 1925 -e 's/@''GNULIB_PUTENV''@/$(GL_GNULIB_PUTENV)/g' \
1482 -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \ 1926 -e 's/@''GNULIB_QSORT_R''@/$(GL_GNULIB_QSORT_R)/g' \
1483 -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \ 1927 -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \
1484 -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \ 1928 -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \
1485 -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \ 1929 -e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \
1486 -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \ 1930 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \
1487 -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \ 1931 -e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \
1488 -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \ 1932 -e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \
1489 -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \ 1933 -e 's/@''GNULIB_RPMATCH''@/$(GL_GNULIB_RPMATCH)/g' \
1490 -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \ 1934 -e 's/@''GNULIB_SECURE_GETENV''@/$(GL_GNULIB_SECURE_GETENV)/g' \
1935 -e 's/@''GNULIB_SETENV''@/$(GL_GNULIB_SETENV)/g' \
1936 -e 's/@''GNULIB_STRTOD''@/$(GL_GNULIB_STRTOD)/g' \
1937 -e 's/@''GNULIB_STRTOL''@/$(GL_GNULIB_STRTOL)/g' \
1938 -e 's/@''GNULIB_STRTOLD''@/$(GL_GNULIB_STRTOLD)/g' \
1939 -e 's/@''GNULIB_STRTOLL''@/$(GL_GNULIB_STRTOLL)/g' \
1940 -e 's/@''GNULIB_STRTOUL''@/$(GL_GNULIB_STRTOUL)/g' \
1941 -e 's/@''GNULIB_STRTOULL''@/$(GL_GNULIB_STRTOULL)/g' \
1942 -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GL_GNULIB_SYSTEM_POSIX)/g' \
1943 -e 's/@''GNULIB_UNLOCKPT''@/$(GL_GNULIB_UNLOCKPT)/g' \
1944 -e 's/@''GNULIB_UNSETENV''@/$(GL_GNULIB_UNSETENV)/g' \
1945 -e 's/@''GNULIB_WCTOMB''@/$(GL_GNULIB_WCTOMB)/g' \
1946 -e 's/@''GNULIB_MDA_ECVT''@/$(GL_GNULIB_MDA_ECVT)/g' \
1947 -e 's/@''GNULIB_MDA_FCVT''@/$(GL_GNULIB_MDA_FCVT)/g' \
1948 -e 's/@''GNULIB_MDA_GCVT''@/$(GL_GNULIB_MDA_GCVT)/g' \
1949 -e 's/@''GNULIB_MDA_MKTEMP''@/$(GL_GNULIB_MDA_MKTEMP)/g' \
1950 -e 's/@''GNULIB_MDA_PUTENV''@/$(GL_GNULIB_MDA_PUTENV)/g' \
1491 < $(srcdir)/stdlib.in.h | \ 1951 < $(srcdir)/stdlib.in.h | \
1492 sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ 1952 sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
1953 -e 's|@''HAVE_ALIGNED_ALLOC''@|$(HAVE_ALIGNED_ALLOC)|g' \
1493 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ 1954 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
1494 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ 1955 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
1956 -e 's|@''HAVE_DECL_ECVT''@|$(HAVE_DECL_ECVT)|g' \
1957 -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \
1958 -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \
1495 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ 1959 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
1496 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ 1960 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
1497 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ 1961 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
1962 -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \
1963 -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \
1964 -e 's|@''HAVE_MBTOWC''@|$(HAVE_MBTOWC)|g' \
1498 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ 1965 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
1499 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ 1966 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
1500 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ 1967 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
1501 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ 1968 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
1502 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ 1969 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
1970 -e 's|@''HAVE_POSIX_MEMALIGN''@|$(HAVE_POSIX_MEMALIGN)|g' \
1503 -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ 1971 -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
1504 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ 1972 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
1505 -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \ 1973 -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
1974 -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
1506 -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \ 1975 -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
1507 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ 1976 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
1508 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ 1977 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
1978 -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \
1509 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ 1979 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
1510 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ 1980 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
1511 -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \ 1981 -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
1512 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ 1982 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
1983 -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \
1984 -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
1513 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ 1985 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
1986 -e 's|@''HAVE_STRTOL''@|$(HAVE_STRTOL)|g' \
1987 -e 's|@''HAVE_STRTOLD''@|$(HAVE_STRTOLD)|g' \
1514 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ 1988 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
1989 -e 's|@''HAVE_STRTOUL''@|$(HAVE_STRTOUL)|g' \
1515 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ 1990 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
1516 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ 1991 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
1517 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ 1992 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
1518 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ 1993 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
1519 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ 1994 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
1520 -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ 1995 -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
1996 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \
1997 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
1521 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ 1998 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
1522 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ 1999 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2000 -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
2001 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
2002 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
1523 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ 2003 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
1524 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ 2004 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
2005 -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \
1525 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ 2006 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
1526 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ 2007 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
1527 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ 2008 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
2009 -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
2010 -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
1528 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ 2011 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
1529 -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ 2012 -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \
2013 -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \
2014 -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \
1530 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ 2015 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
1531 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ 2016 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
2017 -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \
1532 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ 2018 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
2019 -e 's|@''REPLACE_STRTOL''@|$(REPLACE_STRTOL)|g' \
2020 -e 's|@''REPLACE_STRTOLD''@|$(REPLACE_STRTOLD)|g' \
2021 -e 's|@''REPLACE_STRTOLL''@|$(REPLACE_STRTOLL)|g' \
2022 -e 's|@''REPLACE_STRTOUL''@|$(REPLACE_STRTOUL)|g' \
2023 -e 's|@''REPLACE_STRTOULL''@|$(REPLACE_STRTOULL)|g' \
1533 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ 2024 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
1534 -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ 2025 -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
1535 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2026 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1536 -e '/definition of _Noreturn/r $(_NORETURN_H)' \ 2027 -e '/definition of _Noreturn/r $(_NORETURN_H)' \
1537 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2028 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1538 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2029 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1539 } > $@-t && \ 2030 > $@-t
1540 mv $@-t $@ 2031 $(AM_V_at)mv $@-t $@
1541MOSTLYCLEANFILES += stdlib.h stdlib.h-t 2032MOSTLYCLEANFILES += stdlib.h stdlib.h-t
1542 2033
1543EXTRA_DIST += stdlib.in.h 2034EXTRA_DIST += stdlib.in.h
@@ -1546,12 +2037,23 @@ EXTRA_DIST += stdlib.in.h
1546 2037
1547## begin gnulib module strcase 2038## begin gnulib module strcase
1548 2039
2040if GL_COND_OBJ_STRCASECMP
2041libgnu_a_SOURCES += strcasecmp.c
2042endif
2043if GL_COND_OBJ_STRNCASECMP
2044libgnu_a_SOURCES += strncasecmp.c
2045endif
2046
2047## end gnulib module strcase
1549 2048
1550EXTRA_DIST += strcasecmp.c strncasecmp.c 2049## begin gnulib module strcasestr
1551 2050
1552EXTRA_libgnu_a_SOURCES += strcasecmp.c strncasecmp.c
1553 2051
1554## end gnulib module strcase 2052EXTRA_DIST += strcasestr.c
2053
2054EXTRA_libgnu_a_SOURCES += strcasestr.c
2055
2056## end gnulib module strcasestr
1555 2057
1556## begin gnulib module strcasestr-simple 2058## begin gnulib module strcasestr-simple
1557 2059
@@ -1571,19 +2073,19 @@ EXTRA_DIST += streq.h
1571 2073
1572## begin gnulib module strerror 2074## begin gnulib module strerror
1573 2075
1574 2076if GL_COND_OBJ_STRERROR
1575EXTRA_DIST += strerror.c 2077libgnu_a_SOURCES += strerror.c
1576 2078endif
1577EXTRA_libgnu_a_SOURCES += strerror.c
1578 2079
1579## end gnulib module strerror 2080## end gnulib module strerror
1580 2081
1581## begin gnulib module strerror-override 2082## begin gnulib module strerror-override
1582 2083
2084if GL_COND_OBJ_STRERROR_OVERRIDE
2085libgnu_a_SOURCES += strerror-override.c
2086endif
1583 2087
1584EXTRA_DIST += strerror-override.c strerror-override.h 2088EXTRA_DIST += strerror-override.h
1585
1586EXTRA_libgnu_a_SOURCES += strerror-override.c
1587 2089
1588## end gnulib module strerror-override 2090## end gnulib module strerror-override
1589 2091
@@ -1594,58 +2096,66 @@ BUILT_SOURCES += string.h
1594# We need the following in order to create <string.h> when the system 2096# We need the following in order to create <string.h> when the system
1595# doesn't have one that works with the given compiler. 2097# doesn't have one that works with the given compiler.
1596string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2098string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1597 $(AM_V_GEN)rm -f $@-t $@ && \ 2099 $(gl_V_at)$(SED_HEADER_STDOUT) \
1598 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2100 -e 's|@''GUARD_PREFIX''@|GL|g' \
1599 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1600 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2101 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1601 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2102 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1602 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2103 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1603 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ 2104 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
1604 -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \ 2105 -e 's/@''GNULIB_EXPLICIT_BZERO''@/$(GL_GNULIB_EXPLICIT_BZERO)/g' \
1605 -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \ 2106 -e 's/@''GNULIB_FFSL''@/$(GL_GNULIB_FFSL)/g' \
1606 -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \ 2107 -e 's/@''GNULIB_FFSLL''@/$(GL_GNULIB_FFSLL)/g' \
1607 -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \ 2108 -e 's/@''GNULIB_MBSLEN''@/$(GL_GNULIB_MBSLEN)/g' \
1608 -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \ 2109 -e 's/@''GNULIB_MBSNLEN''@/$(GL_GNULIB_MBSNLEN)/g' \
1609 -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \ 2110 -e 's/@''GNULIB_MBSCHR''@/$(GL_GNULIB_MBSCHR)/g' \
1610 -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \ 2111 -e 's/@''GNULIB_MBSRCHR''@/$(GL_GNULIB_MBSRCHR)/g' \
1611 -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \ 2112 -e 's/@''GNULIB_MBSSTR''@/$(GL_GNULIB_MBSSTR)/g' \
1612 -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \ 2113 -e 's/@''GNULIB_MBSCASECMP''@/$(GL_GNULIB_MBSCASECMP)/g' \
1613 -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \ 2114 -e 's/@''GNULIB_MBSNCASECMP''@/$(GL_GNULIB_MBSNCASECMP)/g' \
1614 -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \ 2115 -e 's/@''GNULIB_MBSPCASECMP''@/$(GL_GNULIB_MBSPCASECMP)/g' \
1615 -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \ 2116 -e 's/@''GNULIB_MBSCASESTR''@/$(GL_GNULIB_MBSCASESTR)/g' \
1616 -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \ 2117 -e 's/@''GNULIB_MBSCSPN''@/$(GL_GNULIB_MBSCSPN)/g' \
1617 -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \ 2118 -e 's/@''GNULIB_MBSPBRK''@/$(GL_GNULIB_MBSPBRK)/g' \
1618 -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \ 2119 -e 's/@''GNULIB_MBSSPN''@/$(GL_GNULIB_MBSSPN)/g' \
1619 -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \ 2120 -e 's/@''GNULIB_MBSSEP''@/$(GL_GNULIB_MBSSEP)/g' \
1620 -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \ 2121 -e 's/@''GNULIB_MBSTOK_R''@/$(GL_GNULIB_MBSTOK_R)/g' \
1621 -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \ 2122 -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \
1622 -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \ 2123 -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \
1623 -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \ 2124 -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \
1624 -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \ 2125 -e 's/@''GNULIB_MEMRCHR''@/$(GL_GNULIB_MEMRCHR)/g' \
1625 -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \ 2126 -e 's/@''GNULIB_MEMSET_EXPLICIT''@/$(GL_GNULIB_MEMSET_EXPLICIT)/g' \
1626 -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \ 2127 -e 's/@''GNULIB_RAWMEMCHR''@/$(GL_GNULIB_RAWMEMCHR)/g' \
1627 -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \ 2128 -e 's/@''GNULIB_STPCPY''@/$(GL_GNULIB_STPCPY)/g' \
1628 -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \ 2129 -e 's/@''GNULIB_STPNCPY''@/$(GL_GNULIB_STPNCPY)/g' \
1629 -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \ 2130 -e 's/@''GNULIB_STRCHRNUL''@/$(GL_GNULIB_STRCHRNUL)/g' \
1630 -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \ 2131 -e 's/@''GNULIB_STRDUP''@/$(GL_GNULIB_STRDUP)/g' \
1631 -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \ 2132 -e 's/@''GNULIB_STRNCAT''@/$(GL_GNULIB_STRNCAT)/g' \
1632 -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \ 2133 -e 's/@''GNULIB_STRNDUP''@/$(GL_GNULIB_STRNDUP)/g' \
1633 -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \ 2134 -e 's/@''GNULIB_STRNLEN''@/$(GL_GNULIB_STRNLEN)/g' \
1634 -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \ 2135 -e 's/@''GNULIB_STRPBRK''@/$(GL_GNULIB_STRPBRK)/g' \
1635 -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \ 2136 -e 's/@''GNULIB_STRSEP''@/$(GL_GNULIB_STRSEP)/g' \
1636 -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \ 2137 -e 's/@''GNULIB_STRSTR''@/$(GL_GNULIB_STRSTR)/g' \
1637 -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \ 2138 -e 's/@''GNULIB_STRCASESTR''@/$(GL_GNULIB_STRCASESTR)/g' \
1638 -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \ 2139 -e 's/@''GNULIB_STRTOK_R''@/$(GL_GNULIB_STRTOK_R)/g' \
1639 -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ 2140 -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \
1640 -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \ 2141 -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \
2142 -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \
2143 -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \
2144 -e 's/@''GNULIB_SIGDESCR_NP''@/$(GL_GNULIB_SIGDESCR_NP)/g' \
2145 -e 's/@''GNULIB_STRSIGNAL''@/$(GL_GNULIB_STRSIGNAL)/g' \
2146 -e 's/@''GNULIB_STRVERSCMP''@/$(GL_GNULIB_STRVERSCMP)/g' \
2147 -e 's/@''GNULIB_MDA_MEMCCPY''@/$(GL_GNULIB_MDA_MEMCCPY)/g' \
2148 -e 's/@''GNULIB_MDA_STRDUP''@/$(GL_GNULIB_MDA_STRDUP)/g' \
2149 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
1641 < $(srcdir)/string.in.h | \ 2150 < $(srcdir)/string.in.h | \
1642 sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ 2151 sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
2152 -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
1643 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ 2153 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
1644 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ 2154 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
1645 -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
1646 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ 2155 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
1647 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ 2156 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
1648 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ 2157 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
2158 -e 's|@''HAVE_MEMSET_EXPLICIT''@|$(HAVE_MEMSET_EXPLICIT)|g' \
1649 -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ 2159 -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
1650 -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ 2160 -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
1651 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ 2161 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
@@ -1658,29 +2168,34 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
1658 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ 2168 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
1659 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ 2169 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
1660 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ 2170 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
2171 -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \
2172 -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \
2173 -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \
1661 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ 2174 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
1662 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ 2175 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
1663 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ 2176 -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \
1664 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ 2177 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
1665 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ 2178 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
1666 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ 2179 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2180 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
1667 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ 2181 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
1668 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ 2182 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
1669 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
1670 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
1671 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
1672 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ 2183 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
1673 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ 2184 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
1674 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ 2185 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
1675 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ 2186 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
2187 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
1676 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ 2188 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
2189 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
2190 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
2191 -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \
2192 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
1677 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ 2193 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
1678 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2194 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1679 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2195 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1680 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2196 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1681 < $(srcdir)/string.in.h; \ 2197 > $@-t
1682 } > $@-t && \ 2198 $(AM_V_at)mv $@-t $@
1683 mv $@-t $@
1684MOSTLYCLEANFILES += string.h string.h-t 2199MOSTLYCLEANFILES += string.h string.h-t
1685 2200
1686EXTRA_DIST += string.in.h 2201EXTRA_DIST += string.in.h
@@ -1694,54 +2209,33 @@ BUILT_SOURCES += strings.h
1694# We need the following in order to create <strings.h> when the system 2209# We need the following in order to create <strings.h> when the system
1695# doesn't have one that works with the given compiler. 2210# doesn't have one that works with the given compiler.
1696strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 2211strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
1697 $(AM_V_GEN)rm -f $@-t $@ && \ 2212 $(gl_V_at)$(SED_HEADER_STDOUT) \
1698 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2213 -e 's|@''GUARD_PREFIX''@|GL|g' \
1699 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1700 -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \ 2214 -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
1701 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2215 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1702 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2216 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1703 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2217 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1704 -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ 2218 -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
1705 -e 's|@''GNULIB_FFS''@|$(GNULIB_FFS)|g' \ 2219 -e 's/@''GNULIB_FFS''@/$(GL_GNULIB_FFS)/g' \
1706 -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \ 2220 -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
1707 -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ 2221 -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
1708 -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ 2222 -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
1709 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2223 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1710 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2224 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1711 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2225 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1712 < $(srcdir)/strings.in.h; \ 2226 $(srcdir)/strings.in.h > $@-t
1713 } > $@-t && \ 2227 $(AM_V_at)mv $@-t $@
1714 mv $@-t $@
1715MOSTLYCLEANFILES += strings.h strings.h-t 2228MOSTLYCLEANFILES += strings.h strings.h-t
1716 2229
1717EXTRA_DIST += strings.in.h 2230EXTRA_DIST += strings.in.h
1718 2231
1719## end gnulib module strings 2232## end gnulib module strings
1720 2233
1721## begin gnulib module strndup
1722
1723
1724EXTRA_DIST += strndup.c
1725
1726EXTRA_libgnu_a_SOURCES += strndup.c
1727
1728## end gnulib module strndup
1729
1730## begin gnulib module strnlen
1731
1732
1733EXTRA_DIST += strnlen.c
1734
1735EXTRA_libgnu_a_SOURCES += strnlen.c
1736
1737## end gnulib module strnlen
1738
1739## begin gnulib module strsep 2234## begin gnulib module strsep
1740 2235
1741 2236if GL_COND_OBJ_STRSEP
1742EXTRA_DIST += strsep.c 2237libgnu_a_SOURCES += strsep.c
1743 2238endif
1744EXTRA_libgnu_a_SOURCES += strsep.c
1745 2239
1746## end gnulib module strsep 2240## end gnulib module strsep
1747 2241
@@ -1762,31 +2256,30 @@ libgnu_a_SOURCES += sys_socket.c
1762# We need the following in order to create <sys/socket.h> when the system 2256# We need the following in order to create <sys/socket.h> when the system
1763# doesn't have one that works with the given compiler. 2257# doesn't have one that works with the given compiler.
1764sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 2258sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
1765 $(AM_V_at)$(MKDIR_P) sys 2259 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
1766 $(AM_V_GEN)rm -f $@-t $@ && \ 2260 $(AM_V_at)$(SED_HEADER_STDOUT) \
1767 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2261 -e 's|@''GUARD_PREFIX''@|GL|g' \
1768 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1769 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2262 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1770 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2263 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1771 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2264 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1772 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ 2265 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
1773 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ 2266 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
1774 -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ 2267 -e 's/@''GNULIB_CLOSE''@/$(GL_GNULIB_CLOSE)/g' \
1775 -e 's/@''GNULIB_SOCKET''@/$(GNULIB_SOCKET)/g' \ 2268 -e 's/@''GNULIB_SOCKET''@/$(GL_GNULIB_SOCKET)/g' \
1776 -e 's/@''GNULIB_CONNECT''@/$(GNULIB_CONNECT)/g' \ 2269 -e 's/@''GNULIB_CONNECT''@/$(GL_GNULIB_CONNECT)/g' \
1777 -e 's/@''GNULIB_ACCEPT''@/$(GNULIB_ACCEPT)/g' \ 2270 -e 's/@''GNULIB_ACCEPT''@/$(GL_GNULIB_ACCEPT)/g' \
1778 -e 's/@''GNULIB_BIND''@/$(GNULIB_BIND)/g' \ 2271 -e 's/@''GNULIB_BIND''@/$(GL_GNULIB_BIND)/g' \
1779 -e 's/@''GNULIB_GETPEERNAME''@/$(GNULIB_GETPEERNAME)/g' \ 2272 -e 's/@''GNULIB_GETPEERNAME''@/$(GL_GNULIB_GETPEERNAME)/g' \
1780 -e 's/@''GNULIB_GETSOCKNAME''@/$(GNULIB_GETSOCKNAME)/g' \ 2273 -e 's/@''GNULIB_GETSOCKNAME''@/$(GL_GNULIB_GETSOCKNAME)/g' \
1781 -e 's/@''GNULIB_GETSOCKOPT''@/$(GNULIB_GETSOCKOPT)/g' \ 2274 -e 's/@''GNULIB_GETSOCKOPT''@/$(GL_GNULIB_GETSOCKOPT)/g' \
1782 -e 's/@''GNULIB_LISTEN''@/$(GNULIB_LISTEN)/g' \ 2275 -e 's/@''GNULIB_LISTEN''@/$(GL_GNULIB_LISTEN)/g' \
1783 -e 's/@''GNULIB_RECV''@/$(GNULIB_RECV)/g' \ 2276 -e 's/@''GNULIB_RECV''@/$(GL_GNULIB_RECV)/g' \
1784 -e 's/@''GNULIB_SEND''@/$(GNULIB_SEND)/g' \ 2277 -e 's/@''GNULIB_SEND''@/$(GL_GNULIB_SEND)/g' \
1785 -e 's/@''GNULIB_RECVFROM''@/$(GNULIB_RECVFROM)/g' \ 2278 -e 's/@''GNULIB_RECVFROM''@/$(GL_GNULIB_RECVFROM)/g' \
1786 -e 's/@''GNULIB_SENDTO''@/$(GNULIB_SENDTO)/g' \ 2279 -e 's/@''GNULIB_SENDTO''@/$(GL_GNULIB_SENDTO)/g' \
1787 -e 's/@''GNULIB_SETSOCKOPT''@/$(GNULIB_SETSOCKOPT)/g' \ 2280 -e 's/@''GNULIB_SETSOCKOPT''@/$(GL_GNULIB_SETSOCKOPT)/g' \
1788 -e 's/@''GNULIB_SHUTDOWN''@/$(GNULIB_SHUTDOWN)/g' \ 2281 -e 's/@''GNULIB_SHUTDOWN''@/$(GL_GNULIB_SHUTDOWN)/g' \
1789 -e 's/@''GNULIB_ACCEPT4''@/$(GNULIB_ACCEPT4)/g' \ 2282 -e 's/@''GNULIB_ACCEPT4''@/$(GL_GNULIB_ACCEPT4)/g' \
1790 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ 2283 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
1791 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ 2284 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
1792 -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ 2285 -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
@@ -1796,9 +2289,8 @@ sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_
1796 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2289 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1797 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2290 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1798 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2291 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1799 < $(srcdir)/sys_socket.in.h; \ 2292 $(srcdir)/sys_socket.in.h > $@-t
1800 } > $@-t && \ 2293 $(AM_V_at)mv $@-t $@
1801 mv -f $@-t $@
1802MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t 2294MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
1803MOSTLYCLEANDIRS += sys 2295MOSTLYCLEANDIRS += sys
1804 2296
@@ -1806,6 +2298,79 @@ EXTRA_DIST += sys_socket.in.h
1806 2298
1807## end gnulib module sys_socket 2299## end gnulib module sys_socket
1808 2300
2301## begin gnulib module sys_stat
2302
2303BUILT_SOURCES += sys/stat.h
2304
2305# We need the following in order to create <sys/stat.h> when the system
2306# has one that is incomplete.
2307sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2308 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
2309 $(AM_V_at)$(SED_HEADER_STDOUT) \
2310 -e 's|@''GUARD_PREFIX''@|GL|g' \
2311 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2312 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2313 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2314 -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
2315 -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
2316 -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
2317 -e 's/@''GNULIB_CHMOD''@/$(GL_GNULIB_CHMOD)/g' \
2318 -e 's/@''GNULIB_FCHMODAT''@/$(GL_GNULIB_FCHMODAT)/g' \
2319 -e 's/@''GNULIB_FSTAT''@/$(GL_GNULIB_FSTAT)/g' \
2320 -e 's/@''GNULIB_FSTATAT''@/$(GL_GNULIB_FSTATAT)/g' \
2321 -e 's/@''GNULIB_FUTIMENS''@/$(GL_GNULIB_FUTIMENS)/g' \
2322 -e 's/@''GNULIB_GETUMASK''@/$(GL_GNULIB_GETUMASK)/g' \
2323 -e 's/@''GNULIB_LCHMOD''@/$(GL_GNULIB_LCHMOD)/g' \
2324 -e 's/@''GNULIB_LSTAT''@/$(GL_GNULIB_LSTAT)/g' \
2325 -e 's/@''GNULIB_MKDIR''@/$(GL_GNULIB_MKDIR)/g' \
2326 -e 's/@''GNULIB_MKDIRAT''@/$(GL_GNULIB_MKDIRAT)/g' \
2327 -e 's/@''GNULIB_MKFIFO''@/$(GL_GNULIB_MKFIFO)/g' \
2328 -e 's/@''GNULIB_MKFIFOAT''@/$(GL_GNULIB_MKFIFOAT)/g' \
2329 -e 's/@''GNULIB_MKNOD''@/$(GL_GNULIB_MKNOD)/g' \
2330 -e 's/@''GNULIB_MKNODAT''@/$(GL_GNULIB_MKNODAT)/g' \
2331 -e 's/@''GNULIB_STAT''@/$(GL_GNULIB_STAT)/g' \
2332 -e 's/@''GNULIB_UTIMENSAT''@/$(GL_GNULIB_UTIMENSAT)/g' \
2333 -e 's/@''GNULIB_OVERRIDES_STRUCT_STAT''@/$(GL_GNULIB_OVERRIDES_STRUCT_STAT)/g' \
2334 -e 's/@''GNULIB_MDA_CHMOD''@/$(GL_GNULIB_MDA_CHMOD)/g' \
2335 -e 's/@''GNULIB_MDA_MKDIR''@/$(GL_GNULIB_MDA_MKDIR)/g' \
2336 -e 's/@''GNULIB_MDA_UMASK''@/$(GL_GNULIB_MDA_UMASK)/g' \
2337 -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
2338 -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
2339 -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
2340 -e 's|@''HAVE_GETUMASK''@|$(HAVE_GETUMASK)|g' \
2341 -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
2342 -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
2343 -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
2344 -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
2345 -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
2346 -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
2347 -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
2348 -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
2349 -e 's|@''REPLACE_CHMOD''@|$(REPLACE_CHMOD)|g' \
2350 -e 's|@''REPLACE_FCHMODAT''@|$(REPLACE_FCHMODAT)|g' \
2351 -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
2352 -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
2353 -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
2354 -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
2355 -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
2356 -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
2357 -e 's|@''REPLACE_MKFIFOAT''@|$(REPLACE_MKFIFOAT)|g' \
2358 -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
2359 -e 's|@''REPLACE_MKNODAT''@|$(REPLACE_MKNODAT)|g' \
2360 -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
2361 -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
2362 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2363 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2364 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2365 $(srcdir)/sys_stat.in.h > $@-t
2366 $(AM_V_at)mv $@-t $@
2367MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
2368MOSTLYCLEANDIRS += sys
2369
2370EXTRA_DIST += sys_stat.in.h
2371
2372## end gnulib module sys_stat
2373
1809## begin gnulib module sys_types 2374## begin gnulib module sys_types
1810 2375
1811BUILT_SOURCES += sys/types.h 2376BUILT_SOURCES += sys/types.h
@@ -1813,18 +2378,17 @@ BUILT_SOURCES += sys/types.h
1813# We need the following in order to create <sys/types.h> when the system 2378# We need the following in order to create <sys/types.h> when the system
1814# doesn't have one that works with the given compiler. 2379# doesn't have one that works with the given compiler.
1815sys/types.h: sys_types.in.h $(top_builddir)/config.status 2380sys/types.h: sys_types.in.h $(top_builddir)/config.status
1816 $(AM_V_at)$(MKDIR_P) sys 2381 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
1817 $(AM_V_GEN)rm -f $@-t $@ && \ 2382 $(AM_V_at)$(SED_HEADER_STDOUT) \
1818 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2383 -e 's|@''GUARD_PREFIX''@|GL|g' \
1819 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1820 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2384 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1821 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2385 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1822 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2386 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1823 -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ 2387 -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
1824 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ 2388 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
1825 < $(srcdir)/sys_types.in.h; \ 2389 -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
1826 } > $@-t && \ 2390 $(srcdir)/sys_types.in.h > $@-t
1827 mv $@-t $@ 2391 $(AM_V_at)mv $@-t $@
1828MOSTLYCLEANFILES += sys/types.h sys/types.h-t 2392MOSTLYCLEANFILES += sys/types.h sys/types.h-t
1829 2393
1830EXTRA_DIST += sys_types.in.h 2394EXTRA_DIST += sys_types.in.h
@@ -1838,18 +2402,16 @@ BUILT_SOURCES += sys/uio.h
1838# We need the following in order to create <sys/uio.h> when the system 2402# We need the following in order to create <sys/uio.h> when the system
1839# doesn't have one that works with the given compiler. 2403# doesn't have one that works with the given compiler.
1840sys/uio.h: sys_uio.in.h $(top_builddir)/config.status 2404sys/uio.h: sys_uio.in.h $(top_builddir)/config.status
1841 $(AM_V_at)$(MKDIR_P) sys 2405 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
1842 $(AM_V_GEN)rm -f $@-t $@ && \ 2406 $(AM_V_at)$(SED_HEADER_STDOUT) \
1843 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2407 -e 's|@''GUARD_PREFIX''@|GL|g' \
1844 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1845 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2408 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1846 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2409 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1847 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2410 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1848 -e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \ 2411 -e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \
1849 -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \ 2412 -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \
1850 < $(srcdir)/sys_uio.in.h; \ 2413 $(srcdir)/sys_uio.in.h > $@-t
1851 } > $@-t && \ 2414 $(AM_V_at)mv $@-t $@
1852 mv -f $@-t $@
1853MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t 2415MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t
1854MOSTLYCLEANDIRS += sys 2416MOSTLYCLEANDIRS += sys
1855 2417
@@ -1861,8 +2423,6 @@ EXTRA_DIST += sys_uio.in.h
1861 2423
1862libgnu_a_SOURCES += glthread/threadlib.c 2424libgnu_a_SOURCES += glthread/threadlib.c
1863 2425
1864EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
1865
1866## end gnulib module threadlib 2426## end gnulib module threadlib
1867 2427
1868## begin gnulib module time 2428## begin gnulib module time
@@ -1872,35 +2432,51 @@ BUILT_SOURCES += time.h
1872# We need the following in order to create <time.h> when the system 2432# We need the following in order to create <time.h> when the system
1873# doesn't have one that works with the given compiler. 2433# doesn't have one that works with the given compiler.
1874time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2434time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1875 $(AM_V_GEN)rm -f $@-t $@ && \ 2435 $(gl_V_at)$(SED_HEADER_STDOUT) \
1876 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2436 -e 's|@''GUARD_PREFIX''@|GL|g' \
1877 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1878 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2437 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1879 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2438 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1880 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2439 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1881 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ 2440 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
1882 -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ 2441 -e 's/@''GNULIB_CTIME''@/$(GL_GNULIB_CTIME)/g' \
1883 -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ 2442 -e 's/@''GNULIB_LOCALTIME''@/$(GL_GNULIB_LOCALTIME)/g' \
1884 -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ 2443 -e 's/@''GNULIB_MKTIME''@/$(GL_GNULIB_MKTIME)/g' \
1885 -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ 2444 -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \
1886 -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ 2445 -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \
2446 -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \
2447 -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \
2448 -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \
2449 -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \
2450 -e 's/@''GNULIB_TIME_R''@/$(GL_GNULIB_TIME_R)/g' \
2451 -e 's/@''GNULIB_TIME_RZ''@/$(GL_GNULIB_TIME_RZ)/g' \
2452 -e 's/@''GNULIB_TZSET''@/$(GL_GNULIB_TZSET)/g' \
2453 -e 's/@''GNULIB_MDA_TZSET''@/$(GL_GNULIB_MDA_TZSET)/g' \
1887 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ 2454 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
1888 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ 2455 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
1889 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ 2456 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
1890 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ 2457 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
2458 -e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \
2459 -e 's|@''HAVE_TIMESPEC_GETRES''@|$(HAVE_TIMESPEC_GETRES)|g' \
2460 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
2461 -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
2462 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
2463 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
1891 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ 2464 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
1892 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ 2465 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
1893 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ 2466 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
2467 -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
1894 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ 2468 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
2469 -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
1895 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2470 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
1896 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2471 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
1897 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2472 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
2473 -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \
2474 -e 's|@''TIME_H_DEFINES_TIME_UTC''@|$(TIME_H_DEFINES_TIME_UTC)|g' \
1898 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2475 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1899 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2476 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1900 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2477 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1901 < $(srcdir)/time.in.h; \ 2478 $(srcdir)/time.in.h > $@-t
1902 } > $@-t && \ 2479 $(AM_V_at)mv $@-t $@
1903 mv $@-t $@
1904MOSTLYCLEANFILES += time.h time.h-t 2480MOSTLYCLEANFILES += time.h time.h-t
1905 2481
1906EXTRA_DIST += time.in.h 2482EXTRA_DIST += time.in.h
@@ -1909,19 +2485,19 @@ EXTRA_DIST += time.in.h
1909 2485
1910## begin gnulib module time_r 2486## begin gnulib module time_r
1911 2487
1912 2488if GL_COND_OBJ_TIME_R
1913EXTRA_DIST += time_r.c 2489libgnu_a_SOURCES += time_r.c
1914 2490endif
1915EXTRA_libgnu_a_SOURCES += time_r.c
1916 2491
1917## end gnulib module time_r 2492## end gnulib module time_r
1918 2493
1919## begin gnulib module timegm 2494## begin gnulib module timegm
1920 2495
2496if GL_COND_OBJ_TIMEGM
2497libgnu_a_SOURCES += timegm.c
2498endif
1921 2499
1922EXTRA_DIST += mktime-internal.h timegm.c 2500EXTRA_DIST += mktime-internal.h
1923
1924EXTRA_libgnu_a_SOURCES += timegm.c
1925 2501
1926## end gnulib module timegm 2502## end gnulib module timegm
1927 2503
@@ -1933,69 +2509,104 @@ libgnu_a_SOURCES += unistd.c
1933# We need the following in order to create an empty placeholder for 2509# We need the following in order to create an empty placeholder for
1934# <unistd.h> when the system doesn't have one. 2510# <unistd.h> when the system doesn't have one.
1935unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2511unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1936 $(AM_V_GEN)rm -f $@-t $@ && \ 2512 $(gl_V_at)$(SED_HEADER_STDOUT) \
1937 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2513 -e 's|@''GUARD_PREFIX''@|GL|g' \
1938 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1939 -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ 2514 -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
1940 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2515 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1941 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2516 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1942 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2517 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1943 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ 2518 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
1944 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ 2519 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
1945 -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \ 2520 -e 's/@''GNULIB_ACCESS''@/$(GL_GNULIB_ACCESS)/g' \
1946 -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ 2521 -e 's/@''GNULIB_CHDIR''@/$(GL_GNULIB_CHDIR)/g' \
1947 -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ 2522 -e 's/@''GNULIB_CHOWN''@/$(GL_GNULIB_CHOWN)/g' \
1948 -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \ 2523 -e 's/@''GNULIB_CLOSE''@/$(GL_GNULIB_CLOSE)/g' \
1949 -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ 2524 -e 's/@''GNULIB_COPY_FILE_RANGE''@/$(GL_GNULIB_COPY_FILE_RANGE)/g' \
1950 -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ 2525 -e 's/@''GNULIB_DUP''@/$(GL_GNULIB_DUP)/g' \
1951 -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ 2526 -e 's/@''GNULIB_DUP2''@/$(GL_GNULIB_DUP2)/g' \
1952 -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \ 2527 -e 's/@''GNULIB_DUP3''@/$(GL_GNULIB_DUP3)/g' \
1953 -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ 2528 -e 's/@''GNULIB_ENVIRON''@/$(GL_GNULIB_ENVIRON)/g' \
1954 -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ 2529 -e 's/@''GNULIB_EUIDACCESS''@/$(GL_GNULIB_EUIDACCESS)/g' \
1955 -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ 2530 -e 's/@''GNULIB_EXECL''@/$(GL_GNULIB_EXECL)/g' \
1956 -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \ 2531 -e 's/@''GNULIB_EXECLE''@/$(GL_GNULIB_EXECLE)/g' \
1957 -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ 2532 -e 's/@''GNULIB_EXECLP''@/$(GL_GNULIB_EXECLP)/g' \
1958 -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ 2533 -e 's/@''GNULIB_EXECV''@/$(GL_GNULIB_EXECV)/g' \
1959 -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ 2534 -e 's/@''GNULIB_EXECVE''@/$(GL_GNULIB_EXECVE)/g' \
1960 -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \ 2535 -e 's/@''GNULIB_EXECVP''@/$(GL_GNULIB_EXECVP)/g' \
1961 -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \ 2536 -e 's/@''GNULIB_EXECVPE''@/$(GL_GNULIB_EXECVPE)/g' \
1962 -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \ 2537 -e 's/@''GNULIB_FACCESSAT''@/$(GL_GNULIB_FACCESSAT)/g' \
1963 -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \ 2538 -e 's/@''GNULIB_FCHDIR''@/$(GL_GNULIB_FCHDIR)/g' \
1964 -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ 2539 -e 's/@''GNULIB_FCHOWNAT''@/$(GL_GNULIB_FCHOWNAT)/g' \
1965 -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ 2540 -e 's/@''GNULIB_FDATASYNC''@/$(GL_GNULIB_FDATASYNC)/g' \
1966 -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ 2541 -e 's/@''GNULIB_FSYNC''@/$(GL_GNULIB_FSYNC)/g' \
1967 -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \ 2542 -e 's/@''GNULIB_FTRUNCATE''@/$(GL_GNULIB_FTRUNCATE)/g' \
1968 -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \ 2543 -e 's/@''GNULIB_GETCWD''@/$(GL_GNULIB_GETCWD)/g' \
1969 -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \ 2544 -e 's/@''GNULIB_GETDOMAINNAME''@/$(GL_GNULIB_GETDOMAINNAME)/g' \
1970 -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \ 2545 -e 's/@''GNULIB_GETDTABLESIZE''@/$(GL_GNULIB_GETDTABLESIZE)/g' \
1971 -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \ 2546 -e 's/@''GNULIB_GETENTROPY''@/$(GL_GNULIB_GETENTROPY)/g' \
1972 -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \ 2547 -e 's/@''GNULIB_GETGROUPS''@/$(GL_GNULIB_GETGROUPS)/g' \
1973 -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \ 2548 -e 's/@''GNULIB_GETHOSTNAME''@/$(GL_GNULIB_GETHOSTNAME)/g' \
1974 -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \ 2549 -e 's/@''GNULIB_GETLOGIN''@/$(GL_GNULIB_GETLOGIN)/g' \
1975 -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \ 2550 -e 's/@''GNULIB_GETLOGIN_R''@/$(GL_GNULIB_GETLOGIN_R)/g' \
1976 -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \ 2551 -e 's/@''GNULIB_GETOPT_POSIX''@/$(GL_GNULIB_GETOPT_POSIX)/g' \
1977 -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \ 2552 -e 's/@''GNULIB_GETPAGESIZE''@/$(GL_GNULIB_GETPAGESIZE)/g' \
1978 -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \ 2553 -e 's/@''GNULIB_GETPASS''@/$(GL_GNULIB_GETPASS)/g' \
1979 -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \ 2554 -e 's/@''GNULIB_GETPASS_GNU''@/$(GL_GNULIB_GETPASS_GNU)/g' \
1980 -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \ 2555 -e 's/@''GNULIB_GETUSERSHELL''@/$(GL_GNULIB_GETUSERSHELL)/g' \
1981 -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \ 2556 -e 's/@''GNULIB_GROUP_MEMBER''@/$(GL_GNULIB_GROUP_MEMBER)/g' \
1982 -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \ 2557 -e 's/@''GNULIB_ISATTY''@/$(GL_GNULIB_ISATTY)/g' \
1983 -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ 2558 -e 's/@''GNULIB_LCHOWN''@/$(GL_GNULIB_LCHOWN)/g' \
1984 -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ 2559 -e 's/@''GNULIB_LINK''@/$(GL_GNULIB_LINK)/g' \
1985 -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ 2560 -e 's/@''GNULIB_LINKAT''@/$(GL_GNULIB_LINKAT)/g' \
1986 -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \ 2561 -e 's/@''GNULIB_LSEEK''@/$(GL_GNULIB_LSEEK)/g' \
1987 -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \ 2562 -e 's/@''GNULIB_PIPE''@/$(GL_GNULIB_PIPE)/g' \
1988 -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \ 2563 -e 's/@''GNULIB_PIPE2''@/$(GL_GNULIB_PIPE2)/g' \
1989 -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \ 2564 -e 's/@''GNULIB_PREAD''@/$(GL_GNULIB_PREAD)/g' \
1990 -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \ 2565 -e 's/@''GNULIB_PWRITE''@/$(GL_GNULIB_PWRITE)/g' \
1991 -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \ 2566 -e 's/@''GNULIB_READ''@/$(GL_GNULIB_READ)/g' \
1992 -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \ 2567 -e 's/@''GNULIB_READLINK''@/$(GL_GNULIB_READLINK)/g' \
1993 -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \ 2568 -e 's/@''GNULIB_READLINKAT''@/$(GL_GNULIB_READLINKAT)/g' \
2569 -e 's/@''GNULIB_RMDIR''@/$(GL_GNULIB_RMDIR)/g' \
2570 -e 's/@''GNULIB_SETHOSTNAME''@/$(GL_GNULIB_SETHOSTNAME)/g' \
2571 -e 's/@''GNULIB_SLEEP''@/$(GL_GNULIB_SLEEP)/g' \
2572 -e 's/@''GNULIB_SYMLINK''@/$(GL_GNULIB_SYMLINK)/g' \
2573 -e 's/@''GNULIB_SYMLINKAT''@/$(GL_GNULIB_SYMLINKAT)/g' \
2574 -e 's/@''GNULIB_TRUNCATE''@/$(GL_GNULIB_TRUNCATE)/g' \
2575 -e 's/@''GNULIB_TTYNAME_R''@/$(GL_GNULIB_TTYNAME_R)/g' \
2576 -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GL_GNULIB_UNISTD_H_GETOPT)/g' \
2577 -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GL_GNULIB_UNISTD_H_NONBLOCKING)/g' \
2578 -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GL_GNULIB_UNISTD_H_SIGPIPE)/g' \
2579 -e 's/@''GNULIB_UNLINK''@/$(GL_GNULIB_UNLINK)/g' \
2580 -e 's/@''GNULIB_UNLINKAT''@/$(GL_GNULIB_UNLINKAT)/g' \
2581 -e 's/@''GNULIB_USLEEP''@/$(GL_GNULIB_USLEEP)/g' \
2582 -e 's/@''GNULIB_WRITE''@/$(GL_GNULIB_WRITE)/g' \
2583 -e 's/@''GNULIB_MDA_ACCESS''@/$(GL_GNULIB_MDA_ACCESS)/g' \
2584 -e 's/@''GNULIB_MDA_CHDIR''@/$(GL_GNULIB_MDA_CHDIR)/g' \
2585 -e 's/@''GNULIB_MDA_CLOSE''@/$(GL_GNULIB_MDA_CLOSE)/g' \
2586 -e 's/@''GNULIB_MDA_DUP''@/$(GL_GNULIB_MDA_DUP)/g' \
2587 -e 's/@''GNULIB_MDA_DUP2''@/$(GL_GNULIB_MDA_DUP2)/g' \
2588 -e 's/@''GNULIB_MDA_EXECL''@/$(GL_GNULIB_MDA_EXECL)/g' \
2589 -e 's/@''GNULIB_MDA_EXECLE''@/$(GL_GNULIB_MDA_EXECLE)/g' \
2590 -e 's/@''GNULIB_MDA_EXECLP''@/$(GL_GNULIB_MDA_EXECLP)/g' \
2591 -e 's/@''GNULIB_MDA_EXECV''@/$(GL_GNULIB_MDA_EXECV)/g' \
2592 -e 's/@''GNULIB_MDA_EXECVE''@/$(GL_GNULIB_MDA_EXECVE)/g' \
2593 -e 's/@''GNULIB_MDA_EXECVP''@/$(GL_GNULIB_MDA_EXECVP)/g' \
2594 -e 's/@''GNULIB_MDA_EXECVPE''@/$(GL_GNULIB_MDA_EXECVPE)/g' \
2595 -e 's/@''GNULIB_MDA_GETCWD''@/$(GL_GNULIB_MDA_GETCWD)/g' \
2596 -e 's/@''GNULIB_MDA_GETPID''@/$(GL_GNULIB_MDA_GETPID)/g' \
2597 -e 's/@''GNULIB_MDA_ISATTY''@/$(GL_GNULIB_MDA_ISATTY)/g' \
2598 -e 's/@''GNULIB_MDA_LSEEK''@/$(GL_GNULIB_MDA_LSEEK)/g' \
2599 -e 's/@''GNULIB_MDA_READ''@/$(GL_GNULIB_MDA_READ)/g' \
2600 -e 's/@''GNULIB_MDA_RMDIR''@/$(GL_GNULIB_MDA_RMDIR)/g' \
2601 -e 's/@''GNULIB_MDA_SWAB''@/$(GL_GNULIB_MDA_SWAB)/g' \
2602 -e 's/@''GNULIB_MDA_UNLINK''@/$(GL_GNULIB_MDA_UNLINK)/g' \
2603 -e 's/@''GNULIB_MDA_WRITE''@/$(GL_GNULIB_MDA_WRITE)/g' \
1994 < $(srcdir)/unistd.in.h | \ 2604 < $(srcdir)/unistd.in.h | \
1995 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ 2605 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
1996 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ 2606 -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \
1997 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ 2607 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
1998 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ 2608 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
2609 -e 's|@''HAVE_EXECVPE''@|$(HAVE_EXECVPE)|g' \
1999 -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ 2610 -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
2000 -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ 2611 -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
2001 -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ 2612 -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
@@ -2003,10 +2614,11 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2003 -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ 2614 -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
2004 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ 2615 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
2005 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ 2616 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
2617 -e 's|@''HAVE_GETENTROPY''@|$(HAVE_GETENTROPY)|g' \
2006 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ 2618 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
2007 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ 2619 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
2008 -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
2009 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ 2620 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
2621 -e 's|@''HAVE_GETPASS''@|$(HAVE_GETPASS)|g' \
2010 -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ 2622 -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
2011 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ 2623 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
2012 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ 2624 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
@@ -2024,28 +2636,44 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2024 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ 2636 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
2025 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ 2637 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
2026 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ 2638 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
2639 -e 's|@''HAVE_DECL_EXECVPE''@|$(HAVE_DECL_EXECVPE)|g' \
2027 -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ 2640 -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
2028 -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ 2641 -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
2029 -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ 2642 -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
2643 -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \
2030 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ 2644 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
2031 -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ 2645 -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
2032 -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ 2646 -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
2033 -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \ 2647 -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
2648 -e 's|@''HAVE_DECL_TRUNCATE''@|$(HAVE_DECL_TRUNCATE)|g' \
2034 -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ 2649 -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
2035 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ 2650 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
2036 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ 2651 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
2037 | \ 2652 | \
2038 sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ 2653 sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \
2654 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
2039 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ 2655 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
2656 -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \
2040 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ 2657 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
2041 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ 2658 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
2659 -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \
2660 -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \
2661 -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \
2662 -e 's|@''REPLACE_EXECV''@|$(REPLACE_EXECV)|g' \
2663 -e 's|@''REPLACE_EXECVE''@|$(REPLACE_EXECVE)|g' \
2664 -e 's|@''REPLACE_EXECVP''@|$(REPLACE_EXECVP)|g' \
2665 -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \
2666 -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
2042 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ 2667 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
2043 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ 2668 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
2044 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ 2669 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
2045 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ 2670 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
2671 -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
2046 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ 2672 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
2047 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ 2673 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
2048 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ 2674 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
2675 -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
2676 -e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \
2049 -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ 2677 -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
2050 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ 2678 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
2051 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ 2679 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
@@ -2055,33 +2683,43 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2055 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ 2683 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
2056 -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ 2684 -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
2057 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ 2685 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
2686 -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
2058 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ 2687 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
2059 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ 2688 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
2060 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ 2689 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
2690 -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
2691 -e 's|@''REPLACE_TRUNCATE''@|$(REPLACE_TRUNCATE)|g' \
2061 -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ 2692 -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
2062 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ 2693 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
2063 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ 2694 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
2064 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ 2695 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
2065 -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ 2696 -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
2697 -e 's|@''UNISTD_H_HAVE_SYS_RANDOM_H''@|$(UNISTD_H_HAVE_SYS_RANDOM_H)|g' \
2066 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ 2698 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
2067 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ 2699 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
2068 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2700 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2069 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2701 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2070 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2702 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2071 } > $@-t && \ 2703 > $@-t
2072 mv $@-t $@ 2704 $(AM_V_at)mv $@-t $@
2073MOSTLYCLEANFILES += unistd.h unistd.h-t 2705MOSTLYCLEANFILES += unistd.h unistd.h-t
2074 2706
2075EXTRA_DIST += unistd.in.h 2707EXTRA_DIST += unistd.in.h
2076 2708
2077## end gnulib module unistd 2709## end gnulib module unistd
2078 2710
2079## begin gnulib module unsetenv 2711## begin gnulib module unlocked-io-internal
2080 2712
2081 2713
2082EXTRA_DIST += unsetenv.c 2714EXTRA_DIST += unlocked-io.h
2715
2716## end gnulib module unlocked-io-internal
2717
2718## begin gnulib module unsetenv
2083 2719
2084EXTRA_libgnu_a_SOURCES += unsetenv.c 2720if GL_COND_OBJ_UNSETENV
2721libgnu_a_SOURCES += unsetenv.c
2722endif
2085 2723
2086## end gnulib module unsetenv 2724## end gnulib module unsetenv
2087 2725
@@ -2126,54 +2764,59 @@ BUILT_SOURCES += wchar.h
2126# We need the following in order to create <wchar.h> when the system 2764# We need the following in order to create <wchar.h> when the system
2127# version does not work standalone. 2765# version does not work standalone.
2128wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2766wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2129 $(AM_V_GEN)rm -f $@-t $@ && \ 2767 $(gl_V_at)$(SED_HEADER_STDOUT) \
2130 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2768 -e 's|@''GUARD_PREFIX''@|GL|g' \
2131 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2132 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2769 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2133 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2770 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2134 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2771 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2135 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ 2772 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
2136 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ 2773 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
2137 -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ 2774 -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
2138 -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \ 2775 -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
2139 -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \ 2776 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
2140 -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \ 2777 -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \
2141 -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \ 2778 -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \
2142 -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \ 2779 -e 's/@''GNULIB_MBSINIT''@/$(GL_GNULIB_MBSINIT)/g' \
2143 -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \ 2780 -e 's/@''GNULIB_MBRTOWC''@/$(GL_GNULIB_MBRTOWC)/g' \
2144 -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \ 2781 -e 's/@''GNULIB_MBRLEN''@/$(GL_GNULIB_MBRLEN)/g' \
2145 -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \ 2782 -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \
2146 -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \ 2783 -e 's/@''GNULIB_MBSNRTOWCS''@/$(GL_GNULIB_MBSNRTOWCS)/g' \
2147 -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \ 2784 -e 's/@''GNULIB_WCRTOMB''@/$(GL_GNULIB_WCRTOMB)/g' \
2148 -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \ 2785 -e 's/@''GNULIB_WCSRTOMBS''@/$(GL_GNULIB_WCSRTOMBS)/g' \
2149 -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \ 2786 -e 's/@''GNULIB_WCSNRTOMBS''@/$(GL_GNULIB_WCSNRTOMBS)/g' \
2150 -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \ 2787 -e 's/@''GNULIB_WCWIDTH''@/$(GL_GNULIB_WCWIDTH)/g' \
2151 -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \ 2788 -e 's/@''GNULIB_WMEMCHR''@/$(GL_GNULIB_WMEMCHR)/g' \
2152 -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \ 2789 -e 's/@''GNULIB_WMEMCMP''@/$(GL_GNULIB_WMEMCMP)/g' \
2153 -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \ 2790 -e 's/@''GNULIB_WMEMCPY''@/$(GL_GNULIB_WMEMCPY)/g' \
2154 -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \ 2791 -e 's/@''GNULIB_WMEMMOVE''@/$(GL_GNULIB_WMEMMOVE)/g' \
2155 -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \ 2792 -e 's/@''GNULIB_WMEMPCPY''@/$(GL_GNULIB_WMEMPCPY)/g' \
2156 -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \ 2793 -e 's/@''GNULIB_WMEMSET''@/$(GL_GNULIB_WMEMSET)/g' \
2157 -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \ 2794 -e 's/@''GNULIB_WCSLEN''@/$(GL_GNULIB_WCSLEN)/g' \
2158 -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \ 2795 -e 's/@''GNULIB_WCSNLEN''@/$(GL_GNULIB_WCSNLEN)/g' \
2159 -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \ 2796 -e 's/@''GNULIB_WCSCPY''@/$(GL_GNULIB_WCSCPY)/g' \
2160 -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \ 2797 -e 's/@''GNULIB_WCPCPY''@/$(GL_GNULIB_WCPCPY)/g' \
2161 -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \ 2798 -e 's/@''GNULIB_WCSNCPY''@/$(GL_GNULIB_WCSNCPY)/g' \
2162 -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \ 2799 -e 's/@''GNULIB_WCPNCPY''@/$(GL_GNULIB_WCPNCPY)/g' \
2163 -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \ 2800 -e 's/@''GNULIB_WCSCAT''@/$(GL_GNULIB_WCSCAT)/g' \
2164 -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \ 2801 -e 's/@''GNULIB_WCSNCAT''@/$(GL_GNULIB_WCSNCAT)/g' \
2165 -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \ 2802 -e 's/@''GNULIB_WCSCMP''@/$(GL_GNULIB_WCSCMP)/g' \
2166 -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \ 2803 -e 's/@''GNULIB_WCSNCMP''@/$(GL_GNULIB_WCSNCMP)/g' \
2167 -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \ 2804 -e 's/@''GNULIB_WCSCASECMP''@/$(GL_GNULIB_WCSCASECMP)/g' \
2168 -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \ 2805 -e 's/@''GNULIB_WCSNCASECMP''@/$(GL_GNULIB_WCSNCASECMP)/g' \
2169 -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \ 2806 -e 's/@''GNULIB_WCSCOLL''@/$(GL_GNULIB_WCSCOLL)/g' \
2170 -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \ 2807 -e 's/@''GNULIB_WCSXFRM''@/$(GL_GNULIB_WCSXFRM)/g' \
2171 -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \ 2808 -e 's/@''GNULIB_WCSDUP''@/$(GL_GNULIB_WCSDUP)/g' \
2172 -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \ 2809 -e 's/@''GNULIB_WCSCHR''@/$(GL_GNULIB_WCSCHR)/g' \
2173 -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \ 2810 -e 's/@''GNULIB_WCSRCHR''@/$(GL_GNULIB_WCSRCHR)/g' \
2174 -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \ 2811 -e 's/@''GNULIB_WCSCSPN''@/$(GL_GNULIB_WCSCSPN)/g' \
2175 -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \ 2812 -e 's/@''GNULIB_WCSSPN''@/$(GL_GNULIB_WCSSPN)/g' \
2176 -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \ 2813 -e 's/@''GNULIB_WCSPBRK''@/$(GL_GNULIB_WCSPBRK)/g' \
2814 -e 's/@''GNULIB_WCSSTR''@/$(GL_GNULIB_WCSSTR)/g' \
2815 -e 's/@''GNULIB_WCSTOK''@/$(GL_GNULIB_WCSTOK)/g' \
2816 -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \
2817 -e 's/@''GNULIB_WCSFTIME''@/$(GL_GNULIB_WCSFTIME)/g' \
2818 -e 's/@''GNULIB_MDA_WCSDUP''@/$(GL_GNULIB_MDA_WCSDUP)/g' \
2819 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
2177 < $(srcdir)/wchar.in.h | \ 2820 < $(srcdir)/wchar.in.h | \
2178 sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ 2821 sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
2179 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ 2822 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
@@ -2189,6 +2832,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2189 -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \ 2832 -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \
2190 -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \ 2833 -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \
2191 -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \ 2834 -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \
2835 -e 's|@''HAVE_WMEMPCPY''@|$(HAVE_WMEMPCPY)|g' \
2192 -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \ 2836 -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \
2193 -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \ 2837 -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \
2194 -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \ 2838 -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \
@@ -2213,12 +2857,15 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2213 -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \ 2857 -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \
2214 -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \ 2858 -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
2215 -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \ 2859 -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
2860 -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \
2216 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ 2861 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
2862 -e 's|@''HAVE_DECL_WCSDUP''@|$(HAVE_DECL_WCSDUP)|g' \
2217 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ 2863 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
2218 | \ 2864 | \
2219 sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ 2865 sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
2220 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ 2866 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
2221 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ 2867 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
2868 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2222 -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ 2869 -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
2223 -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \ 2870 -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
2224 -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \ 2871 -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
@@ -2229,11 +2876,13 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2229 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ 2876 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
2230 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ 2877 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
2231 -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \ 2878 -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
2879 -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
2880 -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \
2232 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2881 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2233 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2882 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2234 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2883 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2235 } > $@-t && \ 2884 > $@-t
2236 mv $@-t $@ 2885 $(AM_V_at)mv $@-t $@
2237MOSTLYCLEANFILES += wchar.h wchar.h-t 2886MOSTLYCLEANFILES += wchar.h wchar.h-t
2238 2887
2239EXTRA_DIST += wchar.in.h 2888EXTRA_DIST += wchar.in.h
@@ -2242,10 +2891,9 @@ EXTRA_DIST += wchar.in.h
2242 2891
2243## begin gnulib module wcrtomb 2892## begin gnulib module wcrtomb
2244 2893
2245 2894if GL_COND_OBJ_WCRTOMB
2246EXTRA_DIST += wcrtomb.c 2895libgnu_a_SOURCES += wcrtomb.c
2247 2896endif
2248EXTRA_libgnu_a_SOURCES += wcrtomb.c
2249 2897
2250## end gnulib module wcrtomb 2898## end gnulib module wcrtomb
2251 2899
@@ -2257,38 +2905,82 @@ libgnu_a_SOURCES += wctype-h.c
2257# We need the following in order to create <wctype.h> when the system 2905# We need the following in order to create <wctype.h> when the system
2258# doesn't have one that works with the given compiler. 2906# doesn't have one that works with the given compiler.
2259wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) 2907wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
2260 $(AM_V_GEN)rm -f $@-t $@ && \ 2908 $(gl_V_at)$(SED_HEADER_STDOUT) \
2261 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2909 -e 's|@''GUARD_PREFIX''@|GL|g' \
2262 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2263 -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ 2910 -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
2264 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2911 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2265 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2912 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2266 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2913 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2267 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ 2914 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
2268 -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \ 2915 -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
2269 -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \ 2916 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
2270 -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \ 2917 -e 's/@''GNULIB_ISWBLANK''@/$(GL_GNULIB_ISWBLANK)/g' \
2271 -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \ 2918 -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \
2272 -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \ 2919 -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \
2920 -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \
2921 -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \
2922 -e 's/@''GNULIB_WCTRANS''@/$(GL_GNULIB_WCTRANS)/g' \
2923 -e 's/@''GNULIB_TOWCTRANS''@/$(GL_GNULIB_TOWCTRANS)/g' \
2273 -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ 2924 -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
2274 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ 2925 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
2275 -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ 2926 -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \
2276 -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \ 2927 -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \
2277 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ 2928 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
2278 -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ 2929 -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
2930 -e 's/@''REPLACE_ISWDIGIT''@/$(REPLACE_ISWDIGIT)/g' \
2931 -e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \
2279 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ 2932 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
2280 -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ 2933 -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
2281 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2934 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2282 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2935 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2283 < $(srcdir)/wctype.in.h; \ 2936 $(srcdir)/wctype.in.h > $@-t
2284 } > $@-t && \ 2937 $(AM_V_at)mv $@-t $@
2285 mv $@-t $@
2286MOSTLYCLEANFILES += wctype.h wctype.h-t 2938MOSTLYCLEANFILES += wctype.h wctype.h-t
2287 2939
2288EXTRA_DIST += wctype.in.h 2940EXTRA_DIST += wctype.in.h
2289 2941
2290## end gnulib module wctype-h 2942## end gnulib module wctype-h
2291 2943
2944## begin gnulib module windows-mutex
2945
2946if GL_COND_OBJ_WINDOWS_MUTEX
2947libgnu_a_SOURCES += windows-mutex.c
2948endif
2949
2950EXTRA_DIST += windows-initguard.h windows-mutex.h
2951
2952## end gnulib module windows-mutex
2953
2954## begin gnulib module windows-once
2955
2956if GL_COND_OBJ_WINDOWS_ONCE
2957libgnu_a_SOURCES += windows-once.c
2958endif
2959
2960EXTRA_DIST += windows-once.h
2961
2962## end gnulib module windows-once
2963
2964## begin gnulib module windows-recmutex
2965
2966if GL_COND_OBJ_WINDOWS_RECMUTEX
2967libgnu_a_SOURCES += windows-recmutex.c
2968endif
2969
2970EXTRA_DIST += windows-initguard.h windows-recmutex.h
2971
2972## end gnulib module windows-recmutex
2973
2974## begin gnulib module windows-rwlock
2975
2976if GL_COND_OBJ_WINDOWS_RWLOCK
2977libgnu_a_SOURCES += windows-rwlock.c
2978endif
2979
2980EXTRA_DIST += windows-initguard.h windows-rwlock.h
2981
2982## end gnulib module windows-rwlock
2983
2292## begin gnulib module xalloc 2984## begin gnulib module xalloc
2293 2985
2294libgnu_a_SOURCES += xmalloc.c 2986libgnu_a_SOURCES += xmalloc.c
@@ -2301,6 +2993,8 @@ EXTRA_DIST += xalloc.h
2301 2993
2302libgnu_a_SOURCES += xalloc-die.c 2994libgnu_a_SOURCES += xalloc-die.c
2303 2995
2996EXTRA_DIST += xalloc.h
2997
2304## end gnulib module xalloc-die 2998## end gnulib module xalloc-die
2305 2999
2306## begin gnulib module xalloc-oversized 3000## begin gnulib module xalloc-oversized
@@ -2316,12 +3010,6 @@ libgnu_a_SOURCES += xsize.h xsize.c
2316 3010
2317## end gnulib module xsize 3011## end gnulib module xsize
2318 3012
2319## begin gnulib module xstrndup
2320
2321libgnu_a_SOURCES += xstrndup.h xstrndup.c
2322
2323## end gnulib module xstrndup
2324
2325 3013
2326mostlyclean-local: mostlyclean-generic 3014mostlyclean-local: mostlyclean-generic
2327 @for dir in '' $(MOSTLYCLEANDIRS); do \ 3015 @for dir in '' $(MOSTLYCLEANDIRS); do \
@@ -2330,3 +3018,7 @@ mostlyclean-local: mostlyclean-generic
2330 fi; \ 3018 fi; \
2331 done; \ 3019 done; \
2332 : 3020 :
3021distclean-local: distclean-gnulib-libobjs
3022distclean-gnulib-libobjs:
3023 -rm -f @gl_LIBOBJDEPS@
3024maintainer-clean-local: distclean-gnulib-libobjs
diff --git a/gl/_Noreturn.h b/gl/_Noreturn.h
new file mode 100644
index 00000000..6ecea98b
--- /dev/null
+++ b/gl/_Noreturn.h
@@ -0,0 +1,50 @@
1/* A C macro for declaring that a function does not return.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _Noreturn
18# if (defined __cplusplus \
19 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
20 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
21 && 0)
22 /* [[noreturn]] is not practically usable, because with it the syntax
23 extern _Noreturn void func (...);
24 would not be valid; such a declaration would only be valid with 'extern'
25 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
26 AIX system header files and several gnulib header files use precisely
27 this syntax with 'extern'. */
28# define _Noreturn [[noreturn]]
29# elif (defined __clang__ && __clang_major__ < 16 \
30 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
31 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
32 that rare LLVM bug, though you may get many false-alarm warnings. */
33# define _Noreturn
34# elif ((!defined __cplusplus || defined __clang__) \
35 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
36 || (!defined __STRICT_ANSI__ \
37 && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
38 || (defined __apple_build_version__ \
39 ? 6000000 <= __apple_build_version__ \
40 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
41 /* _Noreturn works as-is. */
42# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
43 || 0x5110 <= __SUNPRO_C)
44# define _Noreturn __attribute__ ((__noreturn__))
45# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
46# define _Noreturn __declspec (noreturn)
47# else
48# define _Noreturn
49# endif
50#endif
diff --git a/gl/af_alg.c b/gl/af_alg.c
new file mode 100644
index 00000000..9f022ce5
--- /dev/null
+++ b/gl/af_alg.c
@@ -0,0 +1,213 @@
1/* af_alg.c - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Matteo Croce <mcroce@redhat.com>, 2018. */
18
19#include <config.h>
20
21#include "af_alg.h"
22
23#if USE_LINUX_CRYPTO_API
24
25#include <unistd.h>
26#include <string.h>
27#include <stdio.h>
28#include <errno.h>
29#include <linux/if_alg.h>
30#include <sys/stat.h>
31#include <sys/sendfile.h>
32#include <sys/socket.h>
33
34#include "sys-limits.h"
35
36#define BLOCKSIZE 32768
37
38/* Return a newly created socket for ALG.
39 On error, return a negative error number. */
40static int
41alg_socket (char const *alg)
42{
43 struct sockaddr_alg salg = {
44 .salg_family = AF_ALG,
45 .salg_type = "hash",
46 };
47 /* Copy alg into salg.salg_name, without calling strcpy nor strlen. */
48 for (size_t i = 0; (salg.salg_name[i] = alg[i]) != '\0'; i++)
49 if (i == sizeof salg.salg_name - 1)
50 /* alg is too long. */
51 return -EINVAL;
52
53 int cfd = socket (AF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
54 if (cfd < 0)
55 return -EAFNOSUPPORT;
56 int ofd = (bind (cfd, (struct sockaddr *) &salg, sizeof salg) == 0
57 ? accept4 (cfd, NULL, 0, SOCK_CLOEXEC)
58 : -1);
59 close (cfd);
60 return ofd < 0 ? -EAFNOSUPPORT : ofd;
61}
62
63int
64afalg_buffer (const char *buffer, size_t len, const char *alg,
65 void *resblock, ssize_t hashlen)
66{
67 /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
68 See <https://patchwork.kernel.org/patch/9308641/>.
69 This was not fixed properly until November 2016,
70 see <https://patchwork.kernel.org/patch/9434741/>. */
71 if (len == 0)
72 return -EAFNOSUPPORT;
73
74 int ofd = alg_socket (alg);
75 if (ofd < 0)
76 return ofd;
77
78 int result;
79
80 for (;;)
81 {
82 ssize_t size = (len > BLOCKSIZE ? BLOCKSIZE : len);
83 if (send (ofd, buffer, size, MSG_MORE) != size)
84 {
85 result = -EAFNOSUPPORT;
86 break;
87 }
88 buffer += size;
89 len -= size;
90 if (len == 0)
91 {
92 result = read (ofd, resblock, hashlen) == hashlen ? 0 : -EAFNOSUPPORT;
93 break;
94 }
95 }
96
97 close (ofd);
98 return result;
99}
100
101int
102afalg_stream (FILE *stream, const char *alg,
103 void *resblock, ssize_t hashlen)
104{
105 int ofd = alg_socket (alg);
106 if (ofd < 0)
107 return ofd;
108
109 /* If STREAM's size is known and nonzero and not too large, attempt
110 sendfile to pipe the data. The nonzero restriction avoids issues
111 with /proc files that pretend to be empty, and lets the classic
112 read-write loop work around an empty-input bug noted below. */
113 int fd = fileno (stream);
114 int result;
115 struct stat st;
116 off_t off = ftello (stream);
117 if (0 <= off && fstat (fd, &st) == 0
118 && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
119 && off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
120 {
121 /* Make sure the offset of fileno (stream) reflects how many bytes
122 have been read from stream before this function got invoked.
123 Note: fflush on an input stream after ungetc does not work as expected
124 on some platforms. Therefore this situation is not supported here. */
125 if (fflush (stream))
126 result = -EIO;
127 else
128 {
129 off_t nbytes = st.st_size - off;
130 if (sendfile (ofd, fd, &off, nbytes) == nbytes)
131 {
132 if (read (ofd, resblock, hashlen) == hashlen)
133 {
134 /* The input buffers of stream are no longer valid. */
135 if (lseek (fd, off, SEEK_SET) != (off_t)-1)
136 result = 0;
137 else
138 /* The file position of fd has not changed. */
139 result = -EAFNOSUPPORT;
140 }
141 else
142 /* The file position of fd has not changed. */
143 result = -EAFNOSUPPORT;
144 }
145 else
146 /* The file position of fd has not changed. */
147 result = -EAFNOSUPPORT;
148 }
149 }
150 else
151 {
152 /* sendfile not possible, do a classic read-write loop. */
153
154 /* Number of bytes to seek (backwards) in case of error. */
155 off_t nseek = 0;
156
157 for (;;)
158 {
159 char buf[BLOCKSIZE];
160 /* When the stream is not seekable, start with a single-byte block,
161 so that we can use ungetc() in the case that send() fails. */
162 size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
163 ssize_t size = fread (buf, 1, blocksize, stream);
164 if (size == 0)
165 {
166 /* On Linux < 4.9, the value for an empty stream is wrong (all 0).
167 See <https://patchwork.kernel.org/patch/9308641/>.
168 This was not fixed properly until November 2016,
169 see <https://patchwork.kernel.org/patch/9434741/>. */
170 result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
171 break;
172 }
173 nseek -= size;
174 if (send (ofd, buf, size, MSG_MORE) != size)
175 {
176 if (nseek == -1)
177 {
178 /* 1 byte of pushback buffer is guaranteed on stream, even
179 if stream is not seekable. */
180 ungetc ((unsigned char) buf[0], stream);
181 result = -EAFNOSUPPORT;
182 }
183 else if (fseeko (stream, nseek, SEEK_CUR) == 0)
184 /* The position of stream has been restored. */
185 result = -EAFNOSUPPORT;
186 else
187 result = -EIO;
188 break;
189 }
190
191 /* Don't assume that EOF is sticky. See:
192 <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>. */
193 if (feof (stream))
194 {
195 result = 0;
196 break;
197 }
198 }
199
200 if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
201 {
202 if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
203 /* The position of stream has been restored. */
204 result = -EAFNOSUPPORT;
205 else
206 result = -EIO;
207 }
208 }
209 close (ofd);
210 return result;
211}
212
213#endif
diff --git a/gl/af_alg.h b/gl/af_alg.h
new file mode 100644
index 00000000..e8ffb3f7
--- /dev/null
+++ b/gl/af_alg.h
@@ -0,0 +1,115 @@
1/* af_alg.h - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Matteo Croce <mcroce@redhat.com>, 2018.
18 Documentation by Bruno Haible <bruno@clisp.org>, 2018. */
19
20/* Declare specific functions for computing message digests
21 using the Linux kernel crypto API, if available. This kernel API gives
22 access to specialized crypto instructions (that would also be available
23 in user space) or to crypto devices (not directly available in user space).
24
25 For a more complete set of facilities that use the Linux kernel crypto API,
26 look at libkcapi. */
27
28#ifndef AF_ALG_H
29# define AF_ALG_H 1
30
31# include <stdio.h>
32# include <errno.h>
33
34# ifdef __cplusplus
35extern "C" {
36# endif
37
38# if USE_LINUX_CRYPTO_API
39
40/* Compute a message digest of a memory region.
41
42 The memory region starts at BUFFER and is LEN bytes long.
43
44 ALG is the message digest algorithm; see the file /proc/crypto.
45
46 RESBLOCK points to a block of HASHLEN bytes, for the result.
47 HASHLEN must be the length of the message digest, in bytes, in particular:
48
49 alg | hashlen
50 -------+--------
51 md5 | 16
52 sha1 | 20
53 sha224 | 28
54 sha256 | 32
55 sha384 | 48
56 sha512 | 64
57
58 If successful, fill RESBLOCK and return 0.
59 Upon failure, return a negated error number. */
60int
61afalg_buffer (const char *buffer, size_t len, const char *alg,
62 void *resblock, ssize_t hashlen);
63
64/* Compute a message digest of data read from STREAM.
65
66 STREAM is an open file stream. The last operation on STREAM should
67 not be 'ungetc', and if STREAM is also open for writing it should
68 have been fflushed since its last write. Read from the current
69 position to the end of STREAM. Handle regular files efficiently.
70
71 ALG is the message digest algorithm; see the file /proc/crypto.
72
73 RESBLOCK points to a block of HASHLEN bytes, for the result.
74 HASHLEN must be the length of the message digest, in bytes, in particular:
75
76 alg | hashlen
77 -------+--------
78 md5 | 16
79 sha1 | 20
80 sha224 | 28
81 sha256 | 32
82 sha384 | 48
83 sha512 | 64
84
85 If successful, fill RESBLOCK and return 0.
86 Upon failure, return a negated error number.
87 Unless returning 0 or -EIO, restore STREAM's file position so that
88 the caller can fall back on some other method. */
89int
90afalg_stream (FILE *stream, const char *alg,
91 void *resblock, ssize_t hashlen);
92
93# else
94
95static inline int
96afalg_buffer (const char *buffer, size_t len, const char *alg,
97 void *resblock, ssize_t hashlen)
98{
99 return -EAFNOSUPPORT;
100}
101
102static inline int
103afalg_stream (FILE *stream, const char *alg,
104 void *resblock, ssize_t hashlen)
105{
106 return -EAFNOSUPPORT;
107}
108
109# endif
110
111# ifdef __cplusplus
112}
113# endif
114
115#endif /* AF_ALG_H */
diff --git a/gl/alloca.in.h b/gl/alloca.in.h
index 72d28ee3..a1bb3d75 100644
--- a/gl/alloca.in.h
+++ b/gl/alloca.in.h
@@ -1,22 +1,20 @@
1/* Memory allocation on the stack. 1/* Memory allocation on the stack.
2 2
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation, 3 Copyright (C) 1995, 1999, 2001-2004, 2006-2023 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This file is free software: you can redistribute it and/or modify
7 under the terms of the GNU General Public License as published 7 it under the terms of the GNU Lesser General Public License as
8 by the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public License
17 License along with this program; if not, see 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 <http://www.gnu.org/licenses/>.
19 */
20 18
21/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H 19/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
22 means there is a real alloca function. */ 20 means there is a real alloca function. */
@@ -35,7 +33,16 @@
35 */ 33 */
36 34
37#ifndef alloca 35#ifndef alloca
38# ifdef __GNUC__ 36 /* Some version of mingw have an <alloca.h> that causes trouble when
37 included after 'alloca' gets defined as a macro. As a workaround,
38 include this <alloca.h> first and define 'alloca' as a macro afterwards
39 if needed. */
40# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
41# include_next <alloca.h>
42# endif
43#endif
44#ifndef alloca
45# if defined __GNUC__ || (__clang_major__ >= 4)
39# define alloca __builtin_alloca 46# define alloca __builtin_alloca
40# elif defined _AIX 47# elif defined _AIX
41# define alloca __alloca 48# define alloca __alloca
@@ -51,6 +58,8 @@ extern "C"
51void *_alloca (unsigned short); 58void *_alloca (unsigned short);
52# pragma intrinsic (_alloca) 59# pragma intrinsic (_alloca)
53# define alloca _alloca 60# define alloca _alloca
61# elif defined __MVS__
62# include <stdlib.h>
54# else 63# else
55# include <stddef.h> 64# include <stddef.h>
56# ifdef __cplusplus 65# ifdef __cplusplus
diff --git a/build-aux/snippet/arg-nonnull.h b/gl/arg-nonnull.h
index 8ea2a474..9498ae1f 100644
--- a/build-aux/snippet/arg-nonnull.h
+++ b/gl/arg-nonnull.h
@@ -1,24 +1,24 @@
1/* A C macro for declaring that specific arguments must not be NULL. 1/* A C macro for declaring that specific arguments must not be NULL.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published 5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or 6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details. 12 Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 17/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
18 that the values passed as arguments n, ..., m must be non-NULL pointers. 18 that the values passed as arguments n, ..., m must be non-NULL pointers.
19 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 19 n = 1 stands for the first argument, n = 2 for the second argument etc. */
20#ifndef _GL_ARG_NONNULL 20#ifndef _GL_ARG_NONNULL
21# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 21# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
22# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 22# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
23# else 23# else
24# define _GL_ARG_NONNULL(params) 24# define _GL_ARG_NONNULL(params)
diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h
index ba89e977..80e6713f 100644
--- a/gl/arpa_inet.in.h
+++ b/gl/arpa_inet.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <arpa/inet.h>. 1/* A GNU-like <arpa/inet.h>.
2 2
3 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_ARPA_INET_H 18#ifndef _@GUARD_PREFIX@_ARPA_INET_H
19 19
@@ -49,6 +49,12 @@
49#ifndef _@GUARD_PREFIX@_ARPA_INET_H 49#ifndef _@GUARD_PREFIX@_ARPA_INET_H
50#define _@GUARD_PREFIX@_ARPA_INET_H 50#define _@GUARD_PREFIX@_ARPA_INET_H
51 51
52/* Get all possible declarations of inet_ntop() and inet_pton(). */
53#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
54 && @HAVE_WS2TCPIP_H@
55# include <ws2tcpip.h>
56#endif
57
52/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 58/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
53 59
54/* The definition of _GL_ARG_NONNULL is copied here. */ 60/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -70,8 +76,8 @@
70 the return value is NULL and errno is set to ENOSPC. A good value 76 the return value is NULL and errno is set to ENOSPC. A good value
71 for CNT is 46. 77 for CNT is 46.
72 78
73 For more details, see the POSIX:2001 specification 79 For more details, see the POSIX:2008 specification
74 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */ 80 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>. */
75# if @REPLACE_INET_NTOP@ 81# if @REPLACE_INET_NTOP@
76# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 82# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
77# undef inet_ntop 83# undef inet_ntop
@@ -97,7 +103,9 @@ _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
97 (int af, const void *restrict src, 103 (int af, const void *restrict src,
98 char *restrict dst, socklen_t cnt)); 104 char *restrict dst, socklen_t cnt));
99# endif 105# endif
106# if __GLIBC__ >= 2
100_GL_CXXALIASWARN (inet_ntop); 107_GL_CXXALIASWARN (inet_ntop);
108# endif
101#elif defined GNULIB_POSIXCHECK 109#elif defined GNULIB_POSIXCHECK
102# undef inet_ntop 110# undef inet_ntop
103# if HAVE_RAW_DECL_INET_NTOP 111# if HAVE_RAW_DECL_INET_NTOP
@@ -126,7 +134,9 @@ _GL_FUNCDECL_SYS (inet_pton, int,
126_GL_CXXALIAS_SYS (inet_pton, int, 134_GL_CXXALIAS_SYS (inet_pton, int,
127 (int af, const char *restrict src, void *restrict dst)); 135 (int af, const char *restrict src, void *restrict dst));
128# endif 136# endif
137# if __GLIBC__ >= 2
129_GL_CXXALIASWARN (inet_pton); 138_GL_CXXALIASWARN (inet_pton);
139# endif
130#elif defined GNULIB_POSIXCHECK 140#elif defined GNULIB_POSIXCHECK
131# undef inet_pton 141# undef inet_pton
132# if HAVE_RAW_DECL_INET_PTON 142# if HAVE_RAW_DECL_INET_PTON
diff --git a/gl/asnprintf.c b/gl/asnprintf.c
index 76e228d8..f4861bf8 100644
--- a/gl/asnprintf.c
+++ b/gl/asnprintf.c
@@ -1,18 +1,18 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/asprintf.c b/gl/asprintf.c
index 713dae13..ba58e064 100644
--- a/gl/asprintf.c
+++ b/gl/asprintf.c
@@ -1,19 +1,19 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2007, 2009-2013 Free Software Foundation, 2 Copyright (C) 1999, 2002, 2006-2007, 2009-2023 Free Software Foundation,
3 Inc. 3 Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/assert.in.h b/gl/assert.in.h
new file mode 100644
index 00000000..b0ab99c7
--- /dev/null
+++ b/gl/assert.in.h
@@ -0,0 +1,27 @@
1/* Substitute for and wrapper around <assert.h>
2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Do not guard the include, since <assert.h> is supposed to define
18 the assert macro each time it is included. */
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23@PRAGMA_COLUMNS@
24
25#@INCLUDE_NEXT@ @NEXT_ASSERT_H@
26
27/* The definition of static_assert is copied here. */
diff --git a/gl/attribute.h b/gl/attribute.h
new file mode 100644
index 00000000..130644d8
--- /dev/null
+++ b/gl/attribute.h
@@ -0,0 +1,226 @@
1/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
2
3 Copyright 2020-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
21 macros used within Gnulib. */
22
23/* These attributes can be placed in two ways:
24 - At the start of a declaration (i.e. even before storage-class
25 specifiers!); then they apply to all entities that are declared
26 by the declaration.
27 - Immediately after the name of an entity being declared by the
28 declaration; then they apply to that entity only. */
29
30#ifndef _GL_ATTRIBUTE_H
31#define _GL_ATTRIBUTE_H
32
33
34/* This file defines two types of attributes:
35 * C23 standard attributes. These have macro names that do not begin with
36 'ATTRIBUTE_'.
37 * Selected GCC attributes; see:
38 https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
39 https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
40 https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html
41 These names begin with 'ATTRIBUTE_' to avoid name clashes. */
42
43
44/* =============== Attributes for specific kinds of functions =============== */
45
46/* Attributes for functions that should not be used. */
47
48/* Warn if the entity is used. */
49/* Applies to:
50 - function, variable,
51 - struct, union, struct/union member,
52 - enumeration, enumeration item,
53 - typedef,
54 in C++ also: namespace, class, template specialization. */
55#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED
56
57/* If a function call is not optimized way, warn with MSG. */
58/* Applies to: functions. */
59#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg)
60
61/* If a function call is not optimized way, report an error with MSG. */
62/* Applies to: functions. */
63#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg)
64
65
66/* Attributes for memory-allocating functions. */
67
68/* The function returns a pointer to freshly allocated memory. */
69/* Applies to: functions. */
70#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC
71
72/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function
73 is the size of the returned memory block.
74 ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
75 to determine the size of the returned memory block. */
76/* Applies to: function, pointer to function, function types. */
77#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
78
79/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
80 that can be freed by passing them as the Ith argument to the
81 function F.
82 ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
83 can be freed via 'free'; it can be used only after declaring 'free'. */
84/* Applies to: functions. Cannot be used on inline functions. */
85#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i)
86#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE
87
88/* Attributes for variadic functions. */
89
90/* The variadic function expects a trailing NULL argument.
91 ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
92 ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
93/* Applies to: functions. */
94#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos)
95
96
97/* ================== Attributes for compiler diagnostics ================== */
98
99/* Attributes that help the compiler diagnose programmer mistakes.
100 Some of them may also help for some compiler optimizations. */
101
102/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) -
103 The STRING-INDEXth function argument is a format string of style
104 ARCHETYPE, which is one of:
105 printf, gnu_printf
106 scanf, gnu_scanf,
107 strftime, gnu_strftime,
108 strfmon,
109 or the same thing prefixed and suffixed with '__'.
110 If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
111 are suitable for the format string. */
112/* Applies to: functions. */
113#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec)
114
115/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL.
116 ATTRIBUTE_NONNULL () - All pointer arguments must not be null. */
117/* Applies to: functions. */
118#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
119
120/* The function's return value is a non-NULL pointer. */
121/* Applies to: functions. */
122#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
123
124/* Warn if the caller does not use the return value,
125 unless the caller uses something like ignore_value. */
126/* Applies to: function, enumeration, class. */
127#define NODISCARD _GL_ATTRIBUTE_NODISCARD
128
129
130/* Attributes that disable false alarms when the compiler diagnoses
131 programmer "mistakes". */
132
133/* Do not warn if the entity is not used. */
134/* Applies to:
135 - function, variable,
136 - struct, union, struct/union member,
137 - enumeration, enumeration item,
138 - typedef,
139 in C++ also: class. */
140#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
141
142/* The contents of a character array is not meant to be NUL-terminated. */
143/* Applies to: struct/union members and variables that are arrays of element
144 type '[[un]signed] char'. */
145#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING
146
147/* Do not warn if control flow falls through to the immediately
148 following 'case' or 'default' label. */
149/* Applies to: Empty statement (;), inside a 'switch' statement. */
150#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
151
152
153/* ================== Attributes for debugging information ================== */
154
155/* Attributes regarding debugging information emitted by the compiler. */
156
157/* Omit the function from stack traces when debugging. */
158/* Applies to: function. */
159#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
160
161/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */
162/* Applies to: functions, variables. */
163#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
164
165
166/* ========== Attributes that mainly direct compiler optimizations ========== */
167
168/* The function does not throw exceptions. */
169/* Applies to: functions. */
170#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
171
172/* Do not inline the function. */
173/* Applies to: functions. */
174#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE
175
176/* Always inline the function, and report an error if the compiler
177 cannot inline. */
178/* Applies to: function. */
179#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
180
181/* It is OK for a compiler to omit duplicate calls with the same arguments.
182 This attribute is safe for a function that neither depends on
183 nor affects observable state, and always returns exactly once -
184 e.g., does not loop forever, and does not call longjmp.
185 (This attribute is stricter than ATTRIBUTE_PURE.) */
186/* Applies to: functions. */
187#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
188
189/* It is OK for a compiler to omit duplicate calls with the same
190 arguments if observable state is not changed between calls.
191 This attribute is safe for a function that does not affect
192 observable state, and always returns exactly once.
193 (This attribute is looser than ATTRIBUTE_CONST.) */
194/* Applies to: functions. */
195#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
196
197/* The function is rarely executed. */
198/* Applies to: functions. */
199#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
200
201/* If called from some other compilation unit, the function executes
202 code from that unit only by return or by exception handling,
203 letting the compiler optimize that unit more aggressively. */
204/* Applies to: functions. */
205#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF
206
207/* For struct members: The member has the smallest possible alignment.
208 For struct, union, class: All members have the smallest possible alignment,
209 minimizing the memory required. */
210/* Applies to: struct members, struct, union,
211 in C++ also: class. */
212#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED
213
214
215/* ================ Attributes that make invalid code valid ================ */
216
217/* Attributes that prevent fatal compiler optimizations for code that is not
218 fully ISO C compliant. */
219
220/* Pointers to the type may point to the same storage as pointers to
221 other types, thus disabling strict aliasing optimization. */
222/* Applies to: types. */
223#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
224
225
226#endif /* _GL_ATTRIBUTE_H */
diff --git a/gl/base64.c b/gl/base64.c
index 8da969c0..95b669aa 100644
--- a/gl/base64.c
+++ b/gl/base64.c
@@ -1,24 +1,24 @@
1/* base64.c -- Encode binary data using printable characters. 1/* base64.c -- Encode binary data using printable characters.
2 Copyright (C) 1999-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999-2001, 2004-2006, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Simon Josefsson. Partially adapted from GNU MailUtils 17/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
18 * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review 18 * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
19 * from Paul Eggert, Bruno Haible, and Stepan Kasal. 19 * from Paul Eggert, Bruno Haible, and Stepan Kasal.
20 * 20 *
21 * See also RFC 4648 <http://www.ietf.org/rfc/rfc4648.txt>. 21 * See also RFC 4648 <https://www.ietf.org/rfc/rfc4648.txt>.
22 * 22 *
23 * Be careful with error checking. Here is how you would typically 23 * Be careful with error checking. Here is how you would typically
24 * use these functions: 24 * use these functions:
@@ -30,7 +30,7 @@
30 * FAIL: memory allocation error 30 * FAIL: memory allocation error
31 * OK: data in OUT/OUTLEN 31 * OK: data in OUT/OUTLEN
32 * 32 *
33 * size_t outlen = base64_encode_alloc (in, inlen, &out); 33 * idx_t outlen = base64_encode_alloc (in, inlen, &out);
34 * if (out == NULL && outlen == 0 && inlen != 0) 34 * if (out == NULL && outlen == 0 && inlen != 0)
35 * FAIL: input too long 35 * FAIL: input too long
36 * if (out == NULL) 36 * if (out == NULL)
@@ -44,51 +44,84 @@
44/* Get prototype. */ 44/* Get prototype. */
45#include "base64.h" 45#include "base64.h"
46 46
47/* Get malloc. */ 47/* Get imalloc. */
48#include <stdlib.h> 48#include <ialloc.h>
49
50#include <intprops.h>
49 51
50/* Get UCHAR_MAX. */ 52/* Get UCHAR_MAX. */
51#include <limits.h> 53#include <limits.h>
52 54
53#include <string.h> 55#include <string.h>
54 56
55/* C89 compliant way to cast 'char' to 'unsigned char'. */ 57/* Convert 'char' to 'unsigned char' without casting. */
56static unsigned char 58static unsigned char
57to_uchar (char ch) 59to_uchar (char ch)
58{ 60{
59 return ch; 61 return ch;
60} 62}
61 63
64static const char b64c[64] =
65 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
66
67/* Base64 encode IN array of size INLEN into OUT array. OUT needs
68 to be of length >= BASE64_LENGTH(INLEN), and INLEN needs to be
69 a multiple of 3. */
70static void
71base64_encode_fast (const char *restrict in, idx_t inlen, char *restrict out)
72{
73 while (inlen)
74 {
75 *out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
76 *out++ = b64c[((to_uchar (in[0]) << 4) + (to_uchar (in[1]) >> 4)) & 0x3f];
77 *out++ = b64c[((to_uchar (in[1]) << 2) + (to_uchar (in[2]) >> 6)) & 0x3f];
78 *out++ = b64c[to_uchar (in[2]) & 0x3f];
79
80 inlen -= 3;
81 in += 3;
82 }
83}
84
62/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN. 85/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
63 If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as 86 If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
64 possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero 87 possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
65 terminate the output buffer. */ 88 terminate the output buffer. */
66void 89void
67base64_encode (const char *restrict in, size_t inlen, 90base64_encode (const char *restrict in, idx_t inlen,
68 char *restrict out, size_t outlen) 91 char *restrict out, idx_t outlen)
69{ 92{
70 static const char b64str[64] = 93 /* Note this outlen constraint can be enforced at compile time.
71 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 94 I.E. that the output buffer is exactly large enough to hold
95 the encoded inlen bytes. The inlen constraints (of corresponding
96 to outlen, and being a multiple of 3) can change at runtime
97 at the end of input. However the common case when reading
98 large inputs is to have both constraints satisfied, so we depend
99 on both in base_encode_fast(). */
100 if (outlen % 4 == 0 && inlen == (outlen >> 2) * 3)
101 {
102 base64_encode_fast (in, inlen, out);
103 return;
104 }
72 105
73 while (inlen && outlen) 106 while (inlen && outlen)
74 { 107 {
75 *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f]; 108 *out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
76 if (!--outlen) 109 if (!--outlen)
77 break; 110 break;
78 *out++ = b64str[((to_uchar (in[0]) << 4) 111 *out++ = b64c[((to_uchar (in[0]) << 4)
79 + (--inlen ? to_uchar (in[1]) >> 4 : 0)) 112 + (--inlen ? to_uchar (in[1]) >> 4 : 0))
80 & 0x3f]; 113 & 0x3f];
81 if (!--outlen) 114 if (!--outlen)
82 break; 115 break;
83 *out++ = 116 *out++ =
84 (inlen 117 (inlen
85 ? b64str[((to_uchar (in[1]) << 2) 118 ? b64c[((to_uchar (in[1]) << 2)
86 + (--inlen ? to_uchar (in[2]) >> 6 : 0)) 119 + (--inlen ? to_uchar (in[2]) >> 6 : 0))
87 & 0x3f] 120 & 0x3f]
88 : '='); 121 : '=');
89 if (!--outlen) 122 if (!--outlen)
90 break; 123 break;
91 *out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '='; 124 *out++ = inlen ? b64c[to_uchar (in[2]) & 0x3f] : '=';
92 if (!--outlen) 125 if (!--outlen)
93 break; 126 break;
94 if (inlen) 127 if (inlen)
@@ -110,30 +143,21 @@ base64_encode (const char *restrict in, size_t inlen,
110 memory allocation failed, OUT is set to NULL, and the return value 143 memory allocation failed, OUT is set to NULL, and the return value
111 indicates length of the requested memory block, i.e., 144 indicates length of the requested memory block, i.e.,
112 BASE64_LENGTH(inlen) + 1. */ 145 BASE64_LENGTH(inlen) + 1. */
113size_t 146idx_t
114base64_encode_alloc (const char *in, size_t inlen, char **out) 147base64_encode_alloc (const char *in, idx_t inlen, char **out)
115{ 148{
116 size_t outlen = 1 + BASE64_LENGTH (inlen);
117
118 /* Check for overflow in outlen computation. 149 /* Check for overflow in outlen computation.
119 * 150 Treat negative INLEN as overflow, for better compatibility with
120 * If there is no overflow, outlen >= inlen. 151 pre-2021-08-27 API, which used size_t. */
121 * 152 idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen;
122 * If the operation (inlen + 2) overflows then it yields at most +1, so 153 if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen) || inlen < 0)
123 * outlen is 0.
124 *
125 * If the multiplication overflows, we lose at least half of the
126 * correct value, so the result is < ((inlen + 2) / 3) * 2, which is
127 * less than (inlen + 2) * 0.66667, which is less than inlen as soon as
128 * (inlen > 4).
129 */
130 if (inlen > outlen)
131 { 154 {
132 *out = NULL; 155 *out = NULL;
133 return 0; 156 return 0;
134 } 157 }
158 outlen++;
135 159
136 *out = malloc (outlen); 160 *out = imalloc (outlen);
137 if (!*out) 161 if (!*out)
138 return outlen; 162 return outlen;
139 163
@@ -317,7 +341,7 @@ base64_decode_ctx_init (struct base64_decode_context *ctx)
317static char * 341static char *
318get_4 (struct base64_decode_context *ctx, 342get_4 (struct base64_decode_context *ctx,
319 char const *restrict *in, char const *restrict in_end, 343 char const *restrict *in, char const *restrict in_end,
320 size_t *n_non_newline) 344 idx_t *n_non_newline)
321{ 345{
322 if (ctx->i == 4) 346 if (ctx->i == 4)
323 ctx->i = 0; 347 ctx->i = 0;
@@ -369,8 +393,8 @@ get_4 (struct base64_decode_context *ctx,
369 *OUT to point to the byte after the last one written, and decrement 393 *OUT to point to the byte after the last one written, and decrement
370 *OUTLEN to reflect the number of bytes remaining in *OUT. */ 394 *OUTLEN to reflect the number of bytes remaining in *OUT. */
371static bool 395static bool
372decode_4 (char const *restrict in, size_t inlen, 396decode_4 (char const *restrict in, idx_t inlen,
373 char *restrict *outp, size_t *outleft) 397 char *restrict *outp, idx_t *outleft)
374{ 398{
375 char *out = *outp; 399 char *out = *outp;
376 if (inlen < 2) 400 if (inlen < 2)
@@ -455,10 +479,10 @@ decode_4 (char const *restrict in, size_t inlen,
455 479
456bool 480bool
457base64_decode_ctx (struct base64_decode_context *ctx, 481base64_decode_ctx (struct base64_decode_context *ctx,
458 const char *restrict in, size_t inlen, 482 const char *restrict in, idx_t inlen,
459 char *restrict out, size_t *outlen) 483 char *restrict out, idx_t *outlen)
460{ 484{
461 size_t outleft = *outlen; 485 idx_t outleft = *outlen;
462 bool ignore_newlines = ctx != NULL; 486 bool ignore_newlines = ctx != NULL;
463 bool flush_ctx = false; 487 bool flush_ctx = false;
464 unsigned int ctx_i = 0; 488 unsigned int ctx_i = 0;
@@ -472,7 +496,7 @@ base64_decode_ctx (struct base64_decode_context *ctx,
472 496
473 while (true) 497 while (true)
474 { 498 {
475 size_t outleft_save = outleft; 499 idx_t outleft_save = outleft;
476 if (ctx_i == 0 && !flush_ctx) 500 if (ctx_i == 0 && !flush_ctx)
477 { 501 {
478 while (true) 502 while (true)
@@ -546,17 +570,17 @@ base64_decode_ctx (struct base64_decode_context *ctx,
546 undefined. */ 570 undefined. */
547bool 571bool
548base64_decode_alloc_ctx (struct base64_decode_context *ctx, 572base64_decode_alloc_ctx (struct base64_decode_context *ctx,
549 const char *in, size_t inlen, char **out, 573 const char *in, idx_t inlen, char **out,
550 size_t *outlen) 574 idx_t *outlen)
551{ 575{
552 /* This may allocate a few bytes too many, depending on input, 576 /* This may allocate a few bytes too many, depending on input,
553 but it's not worth the extra CPU time to compute the exact size. 577 but it's not worth the extra CPU time to compute the exact size.
554 The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the 578 The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
555 input ends with "=" and minus another 1 if the input ends with "==". 579 input ends with "=" and minus another 1 if the input ends with "==".
556 Dividing before multiplying avoids the possibility of overflow. */ 580 Shifting before multiplying avoids the possibility of overflow. */
557 size_t needlen = 3 * (inlen / 4) + 3; 581 idx_t needlen = 3 * ((inlen >> 2) + 1);
558 582
559 *out = malloc (needlen); 583 *out = imalloc (needlen);
560 if (!*out) 584 if (!*out)
561 return true; 585 return true;
562 586
diff --git a/gl/base64.h b/gl/base64.h
index 343150cb..99137652 100644
--- a/gl/base64.h
+++ b/gl/base64.h
@@ -1,28 +1,25 @@
1/* base64.h -- Encode binary data using printable characters. 1/* base64.h -- Encode binary data using printable characters.
2 Copyright (C) 2004-2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2004-2006, 2009-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef BASE64_H 18#ifndef BASE64_H
19# define BASE64_H 19# define BASE64_H
20 20
21/* Get size_t. */ 21/* Get idx_t. */
22# include <stddef.h> 22# include <idx.h>
23
24/* Get bool. */
25# include <stdbool.h>
26 23
27# ifdef __cplusplus 24# ifdef __cplusplus
28extern "C" { 25extern "C" {
@@ -34,26 +31,26 @@ extern "C" {
34 31
35struct base64_decode_context 32struct base64_decode_context
36{ 33{
37 unsigned int i; 34 int i;
38 char buf[4]; 35 char buf[4];
39}; 36};
40 37
41extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST; 38extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
42 39
43extern void base64_encode (const char *restrict in, size_t inlen, 40extern void base64_encode (const char *restrict in, idx_t inlen,
44 char *restrict out, size_t outlen); 41 char *restrict out, idx_t outlen);
45 42
46extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out); 43extern idx_t base64_encode_alloc (const char *in, idx_t inlen, char **out);
47 44
48extern void base64_decode_ctx_init (struct base64_decode_context *ctx); 45extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
49 46
50extern bool base64_decode_ctx (struct base64_decode_context *ctx, 47extern bool base64_decode_ctx (struct base64_decode_context *ctx,
51 const char *restrict in, size_t inlen, 48 const char *restrict in, idx_t inlen,
52 char *restrict out, size_t *outlen); 49 char *restrict out, idx_t *outlen);
53 50
54extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx, 51extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
55 const char *in, size_t inlen, 52 const char *in, idx_t inlen,
56 char **out, size_t *outlen); 53 char **out, idx_t *outlen);
57 54
58#define base64_decode(in, inlen, out, outlen) \ 55#define base64_decode(in, inlen, out, outlen) \
59 base64_decode_ctx (NULL, in, inlen, out, outlen) 56 base64_decode_ctx (NULL, in, inlen, out, outlen)
diff --git a/gl/basename-lgpl.c b/gl/basename-lgpl.c
index 9307e831..6de60aa6 100644
--- a/gl/basename-lgpl.c
+++ b/gl/basename-lgpl.c
@@ -1,37 +1,36 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
21#include "dirname.h" 21/* Specification. */
22#include "basename-lgpl.h"
22 23
23#include <string.h> 24#include <string.h>
24 25
25/* Return the address of the last file name component of NAME. If 26#include "filename.h"
26 NAME has no relative file name components because it is a file
27 system root, return the empty string. */
28 27
29char * 28char *
30last_component (char const *name) 29last_component (char const *name)
31{ 30{
32 char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); 31 char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
33 char const *p; 32 char const *p;
34 bool saw_slash = false; 33 bool last_was_slash = false;
35 34
36 while (ISSLASH (*base)) 35 while (ISSLASH (*base))
37 base++; 36 base++;
@@ -39,21 +38,17 @@ last_component (char const *name)
39 for (p = base; *p; p++) 38 for (p = base; *p; p++)
40 { 39 {
41 if (ISSLASH (*p)) 40 if (ISSLASH (*p))
42 saw_slash = true; 41 last_was_slash = true;
43 else if (saw_slash) 42 else if (last_was_slash)
44 { 43 {
45 base = p; 44 base = p;
46 saw_slash = false; 45 last_was_slash = false;
47 } 46 }
48 } 47 }
49 48
50 return (char *) base; 49 return (char *) base;
51} 50}
52 51
53/* Return the length of the basename NAME. Typically NAME is the
54 value returned by base_name or last_component. Act like strlen
55 (NAME), except omit all trailing slashes. */
56
57size_t 52size_t
58base_len (char const *name) 53base_len (char const *name)
59{ 54{
diff --git a/gl/basename-lgpl.h b/gl/basename-lgpl.h
new file mode 100644
index 00000000..5d996c1d
--- /dev/null
+++ b/gl/basename-lgpl.h
@@ -0,0 +1,78 @@
1/* Extract the last component (base name) of a file name.
2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
4 Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#ifndef _BASENAME_LGPL_H
20#define _BASENAME_LGPL_H
21
22#include <stddef.h>
23
24#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
25# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
26#endif
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32
33/* Return the address of the last file name component of FILENAME.
34 If FILENAME has some trailing slash(es), they are considered to be
35 part of the last component.
36 If FILENAME has no relative file name components because it is a file
37 system root, return the empty string.
38 Examples:
39 FILENAME RESULT
40 "foo.c" "foo.c"
41 "foo/bar.c" "bar.c"
42 "/foo/bar.c" "bar.c"
43 "foo/bar/" "bar/"
44 "foo/bar//" "bar//"
45 "/" ""
46 "//" ""
47 "" ""
48 The return value is a tail of the given FILENAME; do NOT free() it! */
49
50/* This function was traditionally called 'basename', but we avoid this
51 function name because
52 * Various platforms have different functions in their libc.
53 In particular, the glibc basename(), defined in <string.h>, does
54 not consider trailing slashes to be part of the component:
55 FILENAME RESULT
56 "foo/bar/" ""
57 "foo/bar//" ""
58 * The 'basename' command eliminates trailing slashes and for a root
59 produces a non-empty result:
60 FILENAME RESULT
61 "foo/bar/" "bar"
62 "foo/bar//" "bar"
63 "/" "/"
64 "//" "/"
65 */
66extern char *last_component (char const *filename) _GL_ATTRIBUTE_PURE;
67
68/* Return the length of the basename FILENAME.
69 Typically FILENAME is the value returned by base_name or last_component.
70 Act like strlen (FILENAME), except omit all trailing slashes. */
71extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE;
72
73
74#ifdef __cplusplus
75} /* extern "C" */
76#endif
77
78#endif /* _BASENAME_LGPL_H */
diff --git a/gl/basename.c b/gl/basename.c
index d73fd41a..21fab1ef 100644
--- a/gl/basename.c
+++ b/gl/basename.c
@@ -1,11 +1,11 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
@@ -22,37 +22,43 @@
22 22
23#include <string.h> 23#include <string.h>
24#include "xalloc.h" 24#include "xalloc.h"
25#include "xstrndup.h"
26 25
27char * 26char *
28base_name (char const *name) 27base_name (char const *name)
29{ 28{
30 char const *base = last_component (name); 29 char const *base = last_component (name);
31 size_t length; 30 idx_t length;
32 31 int dotslash_len;
33 /* If there is no last component, then name is a file system root or the 32 if (*base)
34 empty string. */ 33 {
35 if (! *base) 34 length = base_len (base);
36 return xstrndup (name, base_len (name)); 35
37 36 /* Collapse a sequence of trailing slashes into one. */
38 /* Collapse a sequence of trailing slashes into one. */ 37 length += ISSLASH (base[length]);
39 length = base_len (base); 38
40 if (ISSLASH (base[length])) 39 /* On systems with drive letters, "a/b:c" must return "./b:c" rather
41 length++; 40 than "b:c" to avoid confusion with a drive letter. On systems
42 41 with pure POSIX semantics, this is not an issue. */
43 /* On systems with drive letters, "a/b:c" must return "./b:c" rather 42 dotslash_len = FILE_SYSTEM_PREFIX_LEN (base) != 0 ? 2 : 0;
44 than "b:c" to avoid confusion with a drive letter. On systems 43 }
45 with pure POSIX semantics, this is not an issue. */ 44 else
46 if (FILE_SYSTEM_PREFIX_LEN (base)) 45 {
46 /* There is no last component, so NAME is a file system root or
47 the empty string. */
48 base = name;
49 length = base_len (base);
50 dotslash_len = 0;
51 }
52
53 char *p = ximalloc (dotslash_len + length + 1);
54 if (dotslash_len)
47 { 55 {
48 char *p = xmalloc (length + 3);
49 p[0] = '.'; 56 p[0] = '.';
50 p[1] = '/'; 57 p[1] = '/';
51 memcpy (p + 2, base, length);
52 p[length + 2] = '\0';
53 return p;
54 } 58 }
55 59
56 /* Finally, copy the basename. */ 60 /* Finally, copy the basename. */
57 return xstrndup (base, length); 61 memcpy (p + dotslash_len, base, length);
62 p[dotslash_len + length] = '\0';
63 return p;
58} 64}
diff --git a/gl/btowc.c b/gl/btowc.c
index 6c7cbec9..caadbd76 100644
--- a/gl/btowc.c
+++ b/gl/btowc.c
@@ -1,19 +1,19 @@
1/* Convert unibyte character to wide character. 1/* Convert unibyte character to wide character.
2 Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/byteswap.in.h b/gl/byteswap.in.h
new file mode 100644
index 00000000..e61be27e
--- /dev/null
+++ b/gl/byteswap.in.h
@@ -0,0 +1,44 @@
1/* byteswap.h - Byte swapping
2 Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_BYTESWAP_H
19#define _GL_BYTESWAP_H
20
21/* Given an unsigned 16-bit argument X, return the value corresponding to
22 X with reversed byte order. */
23#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
24 (((x) & 0xFF00) >> 8))
25
26/* Given an unsigned 32-bit argument X, return the value corresponding to
27 X with reversed byte order. */
28#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
29 (((x) & 0x0000FF00) << 8) | \
30 (((x) & 0x00FF0000) >> 8) | \
31 (((x) & 0xFF000000) >> 24))
32
33/* Given an unsigned 64-bit argument X, return the value corresponding to
34 X with reversed byte order. */
35#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
36 (((x) & 0x000000000000FF00ULL) << 40) | \
37 (((x) & 0x0000000000FF0000ULL) << 24) | \
38 (((x) & 0x00000000FF000000ULL) << 8) | \
39 (((x) & 0x000000FF00000000ULL) >> 8) | \
40 (((x) & 0x0000FF0000000000ULL) >> 24) | \
41 (((x) & 0x00FF000000000000ULL) >> 40) | \
42 (((x) & 0xFF00000000000000ULL) >> 56))
43
44#endif /* _GL_BYTESWAP_H */
diff --git a/build-aux/snippet/c++defs.h b/gl/c++defs.h
index b35b933c..8ad46951 100644
--- a/build-aux/snippet/c++defs.h
+++ b/gl/c++defs.h
@@ -1,22 +1,31 @@
1/* C++ compatible function declaration macros. 1/* C++ compatible function declaration macros.
2 Copyright (C) 2010-2013 Free Software Foundation, Inc. 2 Copyright (C) 2010-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published 5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or 6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details. 12 Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _GL_CXXDEFS_H 17#ifndef _GL_CXXDEFS_H
18#define _GL_CXXDEFS_H 18#define _GL_CXXDEFS_H
19 19
20/* Begin/end the GNULIB_NAMESPACE namespace. */
21#if defined __cplusplus && defined GNULIB_NAMESPACE
22# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
23# define _GL_END_NAMESPACE }
24#else
25# define _GL_BEGIN_NAMESPACE
26# define _GL_END_NAMESPACE
27#endif
28
20/* The three most frequent use cases of these macros are: 29/* The three most frequent use cases of these macros are:
21 30
22 * For providing a substitute for a function that is missing on some 31 * For providing a substitute for a function that is missing on some
@@ -111,14 +120,25 @@
111 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 120 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
112 Example: 121 Example:
113 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 122 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
114 */ 123
124 Wrapping rpl_func in an object with an inline conversion operator
125 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
126 actually used in the program. */
115#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 127#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
116 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 128 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
117#if defined __cplusplus && defined GNULIB_NAMESPACE 129#if defined __cplusplus && defined GNULIB_NAMESPACE
118# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 130# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
119 namespace GNULIB_NAMESPACE \ 131 namespace GNULIB_NAMESPACE \
120 { \ 132 { \
121 rettype (*const func) parameters = ::rpl_func; \ 133 static const struct _gl_ ## func ## _wrapper \
134 { \
135 typedef rettype (*type) parameters; \
136 \
137 inline operator type () const \
138 { \
139 return ::rpl_func; \
140 } \
141 } func = {}; \
122 } \ 142 } \
123 _GL_EXTERN_C int _gl_cxxalias_dummy 143 _GL_EXTERN_C int _gl_cxxalias_dummy
124#else 144#else
@@ -126,6 +146,16 @@
126 _GL_EXTERN_C int _gl_cxxalias_dummy 146 _GL_EXTERN_C int _gl_cxxalias_dummy
127#endif 147#endif
128 148
149/* _GL_CXXALIAS_MDA (func, rettype, parameters);
150 is to be used when func is a Microsoft deprecated alias, on native Windows.
151 It declares a C++ alias called GNULIB_NAMESPACE::func
152 that redirects to _func, if GNULIB_NAMESPACE is defined.
153 Example:
154 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
155 */
156#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
157 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
158
129/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 159/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
130 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 160 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
131 except that the C function rpl_func may have a slightly different 161 except that the C function rpl_func may have a slightly different
@@ -135,8 +165,15 @@
135# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 165# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
136 namespace GNULIB_NAMESPACE \ 166 namespace GNULIB_NAMESPACE \
137 { \ 167 { \
138 rettype (*const func) parameters = \ 168 static const struct _gl_ ## func ## _wrapper \
139 reinterpret_cast<rettype(*)parameters>(::rpl_func); \ 169 { \
170 typedef rettype (*type) parameters; \
171 \
172 inline operator type () const \
173 { \
174 return reinterpret_cast<type>(::rpl_func); \
175 } \
176 } func = {}; \
140 } \ 177 } \
141 _GL_EXTERN_C int _gl_cxxalias_dummy 178 _GL_EXTERN_C int _gl_cxxalias_dummy
142#else 179#else
@@ -144,25 +181,38 @@
144 _GL_EXTERN_C int _gl_cxxalias_dummy 181 _GL_EXTERN_C int _gl_cxxalias_dummy
145#endif 182#endif
146 183
184/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
185 is like _GL_CXXALIAS_MDA (func, rettype, parameters);
186 except that the C function func may have a slightly different declaration.
187 A cast is used to silence the "invalid conversion" error that would
188 otherwise occur. */
189#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
190 _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
191
147/* _GL_CXXALIAS_SYS (func, rettype, parameters); 192/* _GL_CXXALIAS_SYS (func, rettype, parameters);
148 declares a C++ alias called GNULIB_NAMESPACE::func 193 declares a C++ alias called GNULIB_NAMESPACE::func
149 that redirects to the system provided function func, if GNULIB_NAMESPACE 194 that redirects to the system provided function func, if GNULIB_NAMESPACE
150 is defined. 195 is defined.
151 Example: 196 Example:
152 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 197 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
153 */ 198
199 Wrapping func in an object with an inline conversion operator
200 avoids a reference to func unless GNULIB_NAMESPACE::func is
201 actually used in the program. */
154#if defined __cplusplus && defined GNULIB_NAMESPACE 202#if defined __cplusplus && defined GNULIB_NAMESPACE
155 /* If we were to write 203# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
156 rettype (*const func) parameters = ::func; 204 namespace GNULIB_NAMESPACE \
157 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls 205 { \
158 better (remove an indirection through a 'static' pointer variable), 206 static const struct _gl_ ## func ## _wrapper \
159 but then the _GL_CXXALIASWARN macro below would cause a warning not only 207 { \
160 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ 208 typedef rettype (*type) parameters; \
161# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 209 \
162 namespace GNULIB_NAMESPACE \ 210 inline operator type () const \
163 { \ 211 { \
164 static rettype (*func) parameters = ::func; \ 212 return ::func; \
165 } \ 213 } \
214 } func = {}; \
215 } \
166 _GL_EXTERN_C int _gl_cxxalias_dummy 216 _GL_EXTERN_C int _gl_cxxalias_dummy
167#else 217#else
168# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 218# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
@@ -178,8 +228,15 @@
178# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 228# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
179 namespace GNULIB_NAMESPACE \ 229 namespace GNULIB_NAMESPACE \
180 { \ 230 { \
181 static rettype (*func) parameters = \ 231 static const struct _gl_ ## func ## _wrapper \
182 reinterpret_cast<rettype(*)parameters>(::func); \ 232 { \
233 typedef rettype (*type) parameters; \
234 \
235 inline operator type () const \
236 { \
237 return reinterpret_cast<type>(::func); \
238 } \
239 } func = {}; \
183 } \ 240 } \
184 _GL_EXTERN_C int _gl_cxxalias_dummy 241 _GL_EXTERN_C int _gl_cxxalias_dummy
185#else 242#else
@@ -202,9 +259,15 @@
202# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 259# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
203 namespace GNULIB_NAMESPACE \ 260 namespace GNULIB_NAMESPACE \
204 { \ 261 { \
205 static rettype (*func) parameters = \ 262 static const struct _gl_ ## func ## _wrapper \
206 reinterpret_cast<rettype(*)parameters>( \ 263 { \
207 (rettype2(*)parameters2)(::func)); \ 264 typedef rettype (*type) parameters; \
265 \
266 inline operator type () const \
267 { \
268 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
269 } \
270 } func = {}; \
208 } \ 271 } \
209 _GL_EXTERN_C int _gl_cxxalias_dummy 272 _GL_EXTERN_C int _gl_cxxalias_dummy
210#else 273#else
@@ -221,9 +284,9 @@
221 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 284 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
222# define _GL_CXXALIASWARN_1(func,namespace) \ 285# define _GL_CXXALIASWARN_1(func,namespace) \
223 _GL_CXXALIASWARN_2 (func, namespace) 286 _GL_CXXALIASWARN_2 (func, namespace)
224/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 287/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
225 we enable the warning only when not optimizing. */ 288 we enable the warning only when not optimizing. */
226# if !__OPTIMIZE__ 289# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
227# define _GL_CXXALIASWARN_2(func,namespace) \ 290# define _GL_CXXALIASWARN_2(func,namespace) \
228 _GL_WARN_ON_USE (func, \ 291 _GL_WARN_ON_USE (func, \
229 "The symbol ::" #func " refers to the system function. " \ 292 "The symbol ::" #func " refers to the system function. " \
@@ -249,16 +312,13 @@
249 GNULIB_NAMESPACE) 312 GNULIB_NAMESPACE)
250# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 313# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
251 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 314 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
252/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 315/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
253 we enable the warning only when not optimizing. */ 316 we enable the warning only when not optimizing. */
254# if !__OPTIMIZE__ 317# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
255# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 318# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
256 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 319 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
257 "The symbol ::" #func " refers to the system function. " \ 320 "The symbol ::" #func " refers to the system function. " \
258 "Use " #namespace "::" #func " instead.") 321 "Use " #namespace "::" #func " instead.")
259# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
260# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
261 extern __typeof__ (func) func
262# else 322# else
263# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 323# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
264 _GL_EXTERN_C int _gl_cxxalias_dummy 324 _GL_EXTERN_C int _gl_cxxalias_dummy
diff --git a/gl/calloc.c b/gl/calloc.c
new file mode 100644
index 00000000..08843acd
--- /dev/null
+++ b/gl/calloc.c
@@ -0,0 +1,55 @@
1/* calloc() function that is glibc compatible.
2 This wrapper function is required at least on Tru64 UNIX 5.1 and mingw.
3 Copyright (C) 2004-2007, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Jim Meyering and Bruno Haible */
19
20#include <config.h>
21
22/* Specification. */
23#include <stdlib.h>
24
25#include <errno.h>
26
27#include "xalloc-oversized.h"
28
29/* Call the system's calloc below. */
30#undef calloc
31
32/* Allocate and zero-fill an NxS-byte block of memory from the heap,
33 even if N or S is zero. */
34
35void *
36rpl_calloc (size_t n, size_t s)
37{
38 if (n == 0 || s == 0)
39 n = s = 1;
40
41 if (xalloc_oversized (n, s))
42 {
43 errno = ENOMEM;
44 return NULL;
45 }
46
47 void *result = calloc (n, s);
48
49#if !HAVE_MALLOC_POSIX
50 if (result == NULL)
51 errno = ENOMEM;
52#endif
53
54 return result;
55}
diff --git a/gl/cdefs.h b/gl/cdefs.h
new file mode 100644
index 00000000..09a3d19b
--- /dev/null
+++ b/gl/cdefs.h
@@ -0,0 +1,707 @@
1/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
2 Copyright The GNU Toolchain Authors.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_CDEFS_H
20#define _SYS_CDEFS_H 1
21
22/* We are almost always included from features.h. */
23#ifndef _FEATURES_H
24# include <features.h>
25#endif
26
27/* The GNU libc does not support any K&R compilers or the traditional mode
28 of ISO C compilers anymore. Check for some of the combinations not
29 supported anymore. */
30#if defined __GNUC__ && !defined __STDC__
31# error "You need a ISO C conforming compiler to use the glibc headers"
32#endif
33
34/* Some user header file might have defined this before. */
35#undef __P
36#undef __PMT
37
38/* Compilers that lack __has_attribute may object to
39 #if defined __has_attribute && __has_attribute (...)
40 even though they do not need to evaluate the right-hand side of the &&.
41 Similarly for __has_builtin, etc. */
42#if (defined __has_attribute \
43 && (!defined __clang_minor__ \
44 || (defined __apple_build_version__ \
45 ? 6000000 <= __apple_build_version__ \
46 : 3 < __clang_major__ + (5 <= __clang_minor__))))
47# define __glibc_has_attribute(attr) __has_attribute (attr)
48#else
49# define __glibc_has_attribute(attr) 0
50#endif
51#ifdef __has_builtin
52# define __glibc_has_builtin(name) __has_builtin (name)
53#else
54# define __glibc_has_builtin(name) 0
55#endif
56#ifdef __has_extension
57# define __glibc_has_extension(ext) __has_extension (ext)
58#else
59# define __glibc_has_extension(ext) 0
60#endif
61
62#if defined __GNUC__ || defined __clang__
63
64/* All functions, except those with callbacks or those that
65 synchronize memory, are leaf functions. */
66# if __GNUC_PREREQ (4, 6) && !defined _LIBC
67# define __LEAF , __leaf__
68# define __LEAF_ATTR __attribute__ ((__leaf__))
69# else
70# define __LEAF
71# define __LEAF_ATTR
72# endif
73
74/* GCC can always grok prototypes. For C++ programs we add throw()
75 to help it optimize the function calls. But this only works with
76 gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
77 as non-throwing using a function attribute since programs can use
78 the -fexceptions options for C code as well. */
79# if !defined __cplusplus \
80 && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
81# define __THROW __attribute__ ((__nothrow__ __LEAF))
82# define __THROWNL __attribute__ ((__nothrow__))
83# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
84# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
85# else
86# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
87# if __cplusplus >= 201103L
88# define __THROW noexcept (true)
89# else
90# define __THROW throw ()
91# endif
92# define __THROWNL __THROW
93# define __NTH(fct) __LEAF_ATTR fct __THROW
94# define __NTHNL(fct) fct __THROW
95# else
96# define __THROW
97# define __THROWNL
98# define __NTH(fct) fct
99# define __NTHNL(fct) fct
100# endif
101# endif
102
103#else /* Not GCC or clang. */
104
105# if (defined __cplusplus \
106 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
107# define __inline inline
108# else
109# define __inline /* No inline functions. */
110# endif
111
112# define __THROW
113# define __THROWNL
114# define __NTH(fct) fct
115
116#endif /* GCC || clang. */
117
118/* These two macros are not used in glibc anymore. They are kept here
119 only because some other projects expect the macros to be defined. */
120#define __P(args) args
121#define __PMT(args) args
122
123/* For these things, GCC behaves the ANSI way normally,
124 and the non-ANSI way under -traditional. */
125
126#define __CONCAT(x,y) x ## y
127#define __STRING(x) #x
128
129/* This is not a typedef so `const __ptr_t' does the right thing. */
130#define __ptr_t void *
131
132
133/* C++ needs to know that types and declarations are C, not C++. */
134#ifdef __cplusplus
135# define __BEGIN_DECLS extern "C" {
136# define __END_DECLS }
137#else
138# define __BEGIN_DECLS
139# define __END_DECLS
140#endif
141
142
143/* Fortify support. */
144#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
145#define __bos0(ptr) __builtin_object_size (ptr, 0)
146
147/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
148#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
149 || __GNUC_PREREQ (12, 0))
150# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
151# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
152#else
153# define __glibc_objsize0(__o) __bos0 (__o)
154# define __glibc_objsize(__o) __bos (__o)
155#endif
156
157/* Compile time conditions to choose between the regular, _chk and _chk_warn
158 variants. These conditions should get evaluated to constant and optimized
159 away. */
160
161#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
162#define __glibc_unsigned_or_positive(__l) \
163 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
164 || (__builtin_constant_p (__l) && (__l) > 0))
165
166/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
167 condition can be folded to a constant and if it is true, or unknown (-1) */
168#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
169 ((__osz) == (__SIZE_TYPE__) -1 \
170 || (__glibc_unsigned_or_positive (__l) \
171 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
172 (__s), (__osz))) \
173 && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
174
175/* Conversely, we know at compile time that the length is unsafe if the
176 __L * __S <= __OBJSZ condition can be folded to a constant and if it is
177 false. */
178#define __glibc_unsafe_len(__l, __s, __osz) \
179 (__glibc_unsigned_or_positive (__l) \
180 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
181 __s, __osz)) \
182 && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
183
184/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
185 declared. */
186
187#define __glibc_fortify(f, __l, __s, __osz, ...) \
188 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
189 ? __ ## f ## _alias (__VA_ARGS__) \
190 : (__glibc_unsafe_len (__l, __s, __osz) \
191 ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
192 : __ ## f ## _chk (__VA_ARGS__, __osz))) \
193
194/* Fortify function f, where object size argument passed to f is the number of
195 elements and not total size. */
196
197#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
198 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
199 ? __ ## f ## _alias (__VA_ARGS__) \
200 : (__glibc_unsafe_len (__l, __s, __osz) \
201 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
202 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
203
204#if __GNUC_PREREQ (4,3)
205# define __warnattr(msg) __attribute__((__warning__ (msg)))
206# define __errordecl(name, msg) \
207 extern void name (void) __attribute__((__error__ (msg)))
208#else
209# define __warnattr(msg)
210# define __errordecl(name, msg) extern void name (void)
211#endif
212
213/* Support for flexible arrays.
214 Headers that should use flexible arrays only if they're "real"
215 (e.g. only if they won't affect sizeof()) should test
216 #if __glibc_c99_flexarr_available. */
217#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
218# define __flexarr []
219# define __glibc_c99_flexarr_available 1
220#elif __GNUC_PREREQ (2,97) || defined __clang__
221/* GCC 2.97 and clang support C99 flexible array members as an extension,
222 even when in C89 mode or compiling C++ (any version). */
223# define __flexarr []
224# define __glibc_c99_flexarr_available 1
225#elif defined __GNUC__
226/* Pre-2.97 GCC did not support C99 flexible arrays but did have
227 an equivalent extension with slightly different notation. */
228# define __flexarr [0]
229# define __glibc_c99_flexarr_available 1
230#else
231/* Some other non-C99 compiler. Approximate with [1]. */
232# define __flexarr [1]
233# define __glibc_c99_flexarr_available 0
234#endif
235
236
237/* __asm__ ("xyz") is used throughout the headers to rename functions
238 at the assembly language level. This is wrapped by the __REDIRECT
239 macro, in order to support compilers that can do this some other
240 way. When compilers don't support asm-names at all, we have to do
241 preprocessor tricks instead (which don't have exactly the right
242 semantics, but it's the best we can do).
243
244 Example:
245 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
246
247#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
248
249# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
250# ifdef __cplusplus
251# define __REDIRECT_NTH(name, proto, alias) \
252 name proto __THROW __asm__ (__ASMNAME (#alias))
253# define __REDIRECT_NTHNL(name, proto, alias) \
254 name proto __THROWNL __asm__ (__ASMNAME (#alias))
255# else
256# define __REDIRECT_NTH(name, proto, alias) \
257 name proto __asm__ (__ASMNAME (#alias)) __THROW
258# define __REDIRECT_NTHNL(name, proto, alias) \
259 name proto __asm__ (__ASMNAME (#alias)) __THROWNL
260# endif
261# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
262# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
263
264/*
265#elif __SOME_OTHER_COMPILER__
266
267# define __REDIRECT(name, proto, alias) name proto; \
268 _Pragma("let " #name " = " #alias)
269*/
270#endif
271
272/* GCC and clang have various useful declarations that can be made with
273 the '__attribute__' syntax. All of the ways we use this do fine if
274 they are omitted for compilers that don't understand it. */
275#if !(defined __GNUC__ || defined __clang__)
276# define __attribute__(xyz) /* Ignore */
277#endif
278
279/* At some point during the gcc 2.96 development the `malloc' attribute
280 for functions was introduced. We don't want to use it unconditionally
281 (although this would be possible) since it generates warnings. */
282#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
283# define __attribute_malloc__ __attribute__ ((__malloc__))
284#else
285# define __attribute_malloc__ /* Ignore */
286#endif
287
288/* Tell the compiler which arguments to an allocation function
289 indicate the size of the allocation. */
290#if __GNUC_PREREQ (4, 3)
291# define __attribute_alloc_size__(params) \
292 __attribute__ ((__alloc_size__ params))
293#else
294# define __attribute_alloc_size__(params) /* Ignore. */
295#endif
296
297/* Tell the compiler which argument to an allocation function
298 indicates the alignment of the allocation. */
299#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
300# define __attribute_alloc_align__(param) \
301 __attribute__ ((__alloc_align__ param))
302#else
303# define __attribute_alloc_align__(param) /* Ignore. */
304#endif
305
306/* At some point during the gcc 2.96 development the `pure' attribute
307 for functions was introduced. We don't want to use it unconditionally
308 (although this would be possible) since it generates warnings. */
309#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
310# define __attribute_pure__ __attribute__ ((__pure__))
311#else
312# define __attribute_pure__ /* Ignore */
313#endif
314
315/* This declaration tells the compiler that the value is constant. */
316#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
317# define __attribute_const__ __attribute__ ((__const__))
318#else
319# define __attribute_const__ /* Ignore */
320#endif
321
322#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
323# define __attribute_maybe_unused__ __attribute__ ((__unused__))
324#else
325# define __attribute_maybe_unused__ /* Ignore */
326#endif
327
328/* At some point during the gcc 3.1 development the `used' attribute
329 for functions was introduced. We don't want to use it unconditionally
330 (although this would be possible) since it generates warnings. */
331#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
332# define __attribute_used__ __attribute__ ((__used__))
333# define __attribute_noinline__ __attribute__ ((__noinline__))
334#else
335# define __attribute_used__ __attribute__ ((__unused__))
336# define __attribute_noinline__ /* Ignore */
337#endif
338
339/* Since version 3.2, gcc allows marking deprecated functions. */
340#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
341# define __attribute_deprecated__ __attribute__ ((__deprecated__))
342#else
343# define __attribute_deprecated__ /* Ignore */
344#endif
345
346/* Since version 4.5, gcc also allows one to specify the message printed
347 when a deprecated function is used. clang claims to be gcc 4.2, but
348 may also support this feature. */
349#if __GNUC_PREREQ (4,5) \
350 || __glibc_has_extension (__attribute_deprecated_with_message__)
351# define __attribute_deprecated_msg__(msg) \
352 __attribute__ ((__deprecated__ (msg)))
353#else
354# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
355#endif
356
357/* At some point during the gcc 2.8 development the `format_arg' attribute
358 for functions was introduced. We don't want to use it unconditionally
359 (although this would be possible) since it generates warnings.
360 If several `format_arg' attributes are given for the same function, in
361 gcc-3.0 and older, all but the last one are ignored. In newer gccs,
362 all designated arguments are considered. */
363#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
364# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
365#else
366# define __attribute_format_arg__(x) /* Ignore */
367#endif
368
369/* At some point during the gcc 2.97 development the `strfmon' format
370 attribute for functions was introduced. We don't want to use it
371 unconditionally (although this would be possible) since it
372 generates warnings. */
373#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
374# define __attribute_format_strfmon__(a,b) \
375 __attribute__ ((__format__ (__strfmon__, a, b)))
376#else
377# define __attribute_format_strfmon__(a,b) /* Ignore */
378#endif
379
380/* The nonnull function attribute marks pointer parameters that
381 must not be NULL. This has the name __nonnull in glibc,
382 and __attribute_nonnull__ in files shared with Gnulib to avoid
383 collision with a different __nonnull in DragonFlyBSD 5.9. */
384#ifndef __attribute_nonnull__
385# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
386# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
387# else
388# define __attribute_nonnull__(params)
389# endif
390#endif
391#ifndef __nonnull
392# define __nonnull(params) __attribute_nonnull__ (params)
393#endif
394
395/* The returns_nonnull function attribute marks the return type of the function
396 as always being non-null. */
397#ifndef __returns_nonnull
398# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
399# define __returns_nonnull __attribute__ ((__returns_nonnull__))
400# else
401# define __returns_nonnull
402# endif
403#endif
404
405/* If fortification mode, we warn about unused results of certain
406 function calls which can lead to problems. */
407#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
408# define __attribute_warn_unused_result__ \
409 __attribute__ ((__warn_unused_result__))
410# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
411# define __wur __attribute_warn_unused_result__
412# endif
413#else
414# define __attribute_warn_unused_result__ /* empty */
415#endif
416#ifndef __wur
417# define __wur /* Ignore */
418#endif
419
420/* Forces a function to be always inlined. */
421#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
422/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
423 it conflicts with this definition. Therefore undefine it first to
424 allow either header to be included first. */
425# undef __always_inline
426# define __always_inline __inline __attribute__ ((__always_inline__))
427#else
428# undef __always_inline
429# define __always_inline __inline
430#endif
431
432/* Associate error messages with the source location of the call site rather
433 than with the source location inside the function. */
434#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
435# define __attribute_artificial__ __attribute__ ((__artificial__))
436#else
437# define __attribute_artificial__ /* Ignore */
438#endif
439
440/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
441 inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
442 or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
443 older than 4.3 may define these macros and still not guarantee GNU inlining
444 semantics.
445
446 clang++ identifies itself as gcc-4.2, but has support for GNU inlining
447 semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
448 __GNUC_GNU_INLINE__ macro definitions. */
449#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
450 || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
451 || defined __GNUC_GNU_INLINE__)))
452# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
453# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
454# define __extern_always_inline \
455 extern __always_inline __attribute__ ((__gnu_inline__))
456# else
457# define __extern_inline extern __inline
458# define __extern_always_inline extern __always_inline
459# endif
460#endif
461
462#ifdef __extern_always_inline
463# define __fortify_function __extern_always_inline __attribute_artificial__
464#endif
465
466/* GCC 4.3 and above allow passing all anonymous arguments of an
467 __extern_always_inline function to some other vararg function. */
468#if __GNUC_PREREQ (4,3)
469# define __va_arg_pack() __builtin_va_arg_pack ()
470# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
471#endif
472
473/* It is possible to compile containing GCC extensions even if GCC is
474 run in pedantic mode if the uses are carefully marked using the
475 `__extension__' keyword. But this is not generally available before
476 version 2.8. */
477#if !(__GNUC_PREREQ (2,8) || defined __clang__)
478# define __extension__ /* Ignore */
479#endif
480
481/* __restrict is known in EGCS 1.2 and above, and in clang.
482 It works also in C++ mode (outside of arrays), but only when spelled
483 as '__restrict', not 'restrict'. */
484#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
485# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
486# define __restrict restrict
487# else
488# define __restrict /* Ignore */
489# endif
490#endif
491
492/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
493 array_name[restrict]
494 GCC 3.1 and clang support this.
495 This syntax is not usable in C++ mode. */
496#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
497# define __restrict_arr __restrict
498#else
499# ifdef __GNUC__
500# define __restrict_arr /* Not supported in old GCC. */
501# else
502# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
503# define __restrict_arr restrict
504# else
505/* Some other non-C99 compiler. */
506# define __restrict_arr /* Not supported. */
507# endif
508# endif
509#endif
510
511#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
512# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
513# define __glibc_likely(cond) __builtin_expect ((cond), 1)
514#else
515# define __glibc_unlikely(cond) (cond)
516# define __glibc_likely(cond) (cond)
517#endif
518
519#if (!defined _Noreturn \
520 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
521 && !(__GNUC_PREREQ (4,7) \
522 || (3 < __clang_major__ + (5 <= __clang_minor__))))
523# if __GNUC_PREREQ (2,8)
524# define _Noreturn __attribute__ ((__noreturn__))
525# else
526# define _Noreturn
527# endif
528#endif
529
530#if __GNUC_PREREQ (8, 0)
531/* Describes a char array whose address can safely be passed as the first
532 argument to strncpy and strncat, as the char array is not necessarily
533 a NUL-terminated string. */
534# define __attribute_nonstring__ __attribute__ ((__nonstring__))
535#else
536# define __attribute_nonstring__
537#endif
538
539/* Undefine (also defined in libc-symbols.h). */
540#undef __attribute_copy__
541#if __GNUC_PREREQ (9, 0)
542/* Copies attributes from the declaration or type referenced by
543 the argument. */
544# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
545#else
546# define __attribute_copy__(arg)
547#endif
548
549#if (!defined _Static_assert && !defined __cplusplus \
550 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
551 && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
552 || defined __STRICT_ANSI__))
553# define _Static_assert(expr, diagnostic) \
554 extern int (*__Static_assert_function (void)) \
555 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
556#endif
557
558/* Gnulib avoids including these, as they don't work on non-glibc or
559 older glibc platforms. */
560#ifndef __GNULIB_CDEFS
561# include <bits/wordsize.h>
562# include <bits/long-double.h>
563#endif
564
565#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
566# ifdef __REDIRECT
567
568/* Alias name defined automatically. */
569# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
570# define __LDBL_REDIR_DECL(name) \
571 extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
572
573/* Alias name defined automatically, with leading underscores. */
574# define __LDBL_REDIR2_DECL(name) \
575 extern __typeof (__##name) __##name \
576 __asm (__ASMNAME ("__" #name "ieee128"));
577
578/* Alias name defined manually. */
579# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
580# define __LDBL_REDIR1_DECL(name, alias) \
581 extern __typeof (name) name __asm (__ASMNAME (#alias));
582
583# define __LDBL_REDIR1_NTH(name, proto, alias) \
584 __REDIRECT_NTH (name, proto, alias)
585# define __REDIRECT_NTH_LDBL(name, proto, alias) \
586 __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
587
588/* Unused. */
589# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
590# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
591
592# else
593_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
594# endif
595#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
596# define __LDBL_COMPAT 1
597# ifdef __REDIRECT
598# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
599# define __LDBL_REDIR(name, proto) \
600 __LDBL_REDIR1 (name, proto, __nldbl_##name)
601# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
602# define __LDBL_REDIR_NTH(name, proto) \
603 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
604# define __LDBL_REDIR2_DECL(name) \
605 extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
606# define __LDBL_REDIR1_DECL(name, alias) \
607 extern __typeof (name) name __asm (__ASMNAME (#alias));
608# define __LDBL_REDIR_DECL(name) \
609 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
610# define __REDIRECT_LDBL(name, proto, alias) \
611 __LDBL_REDIR1 (name, proto, __nldbl_##alias)
612# define __REDIRECT_NTH_LDBL(name, proto, alias) \
613 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
614# endif
615#endif
616#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
617 || !defined __REDIRECT
618# define __LDBL_REDIR1(name, proto, alias) name proto
619# define __LDBL_REDIR(name, proto) name proto
620# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
621# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
622# define __LDBL_REDIR2_DECL(name)
623# define __LDBL_REDIR_DECL(name)
624# ifdef __REDIRECT
625# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
626# define __REDIRECT_NTH_LDBL(name, proto, alias) \
627 __REDIRECT_NTH (name, proto, alias)
628# endif
629#endif
630
631/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
632 intended for use in preprocessor macros.
633
634 Note: MESSAGE must be a _single_ string; concatenation of string
635 literals is not supported. */
636#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
637# define __glibc_macro_warning1(message) _Pragma (#message)
638# define __glibc_macro_warning(message) \
639 __glibc_macro_warning1 (GCC warning message)
640#else
641# define __glibc_macro_warning(msg)
642#endif
643
644/* Generic selection (ISO C11) is a C-only feature, available in GCC
645 since version 4.9. Previous versions do not provide generic
646 selection, even though they might set __STDC_VERSION__ to 201112L,
647 when in -std=c11 mode. Thus, we must check for !defined __GNUC__
648 when testing __STDC_VERSION__ for generic selection support.
649 On the other hand, Clang also defines __GNUC__, so a clang-specific
650 check is required to enable the use of generic selection. */
651#if !defined __cplusplus \
652 && (__GNUC_PREREQ (4, 9) \
653 || __glibc_has_extension (c_generic_selections) \
654 || (!defined __GNUC__ && defined __STDC_VERSION__ \
655 && __STDC_VERSION__ >= 201112L))
656# define __HAVE_GENERIC_SELECTION 1
657#else
658# define __HAVE_GENERIC_SELECTION 0
659#endif
660
661#if __GNUC_PREREQ (10, 0)
662/* Designates a 1-based positional argument ref-index of pointer type
663 that can be used to access size-index elements of the pointed-to
664 array according to access mode, or at least one element when
665 size-index is not provided:
666 access (access-mode, <ref-index> [, <size-index>]) */
667# define __attr_access(x) __attribute__ ((__access__ x))
668/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
669 use the access attribute to get object sizes from function definition
670 arguments, so we can't use them on functions we fortify. Drop the object
671 size hints for such functions. */
672# if __USE_FORTIFY_LEVEL == 3
673# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
674# else
675# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
676# endif
677# if __GNUC_PREREQ (11, 0)
678# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
679# else
680# define __attr_access_none(argno)
681# endif
682#else
683# define __fortified_attr_access(a, o, s)
684# define __attr_access(x)
685# define __attr_access_none(argno)
686#endif
687
688#if __GNUC_PREREQ (11, 0)
689/* Designates dealloc as a function to call to deallocate objects
690 allocated by the declared function. */
691# define __attr_dealloc(dealloc, argno) \
692 __attribute__ ((__malloc__ (dealloc, argno)))
693# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
694#else
695# define __attr_dealloc(dealloc, argno)
696# define __attr_dealloc_free
697#endif
698
699/* Specify that a function such as setjmp or vfork may return
700 twice. */
701#if __GNUC_PREREQ (4, 1)
702# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
703#else
704# define __attribute_returns_twice__ /* Ignore. */
705#endif
706
707#endif /* sys/cdefs.h */
diff --git a/gl/cloexec.c b/gl/cloexec.c
new file mode 100644
index 00000000..e4cecbd2
--- /dev/null
+++ b/gl/cloexec.c
@@ -0,0 +1,83 @@
1/* cloexec.c - set or clear the close-on-exec descriptor flag
2
3 Copyright (C) 1991, 2004-2006, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* The code is taken from glibc/manual/llio.texi */
19
20#include <config.h>
21
22#include "cloexec.h"
23
24#include <errno.h>
25#include <fcntl.h>
26#include <unistd.h>
27
28/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
29 or clear the flag if VALUE is false.
30 Return 0 on success, or -1 on error with 'errno' set.
31
32 Note that on MingW, this function does NOT protect DESC from being
33 inherited into spawned children. Instead, either use dup_cloexec
34 followed by closing the original DESC, or use interfaces such as
35 open or pipe2 that accept flags like O_CLOEXEC to create DESC
36 non-inheritable in the first place. */
37
38int
39set_cloexec_flag (int desc, bool value)
40{
41#ifdef F_SETFD
42
43 int flags = fcntl (desc, F_GETFD, 0);
44
45 if (0 <= flags)
46 {
47 int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
48
49 if (flags == newflags
50 || fcntl (desc, F_SETFD, newflags) != -1)
51 return 0;
52 }
53
54 return -1;
55
56#else /* !F_SETFD */
57
58 /* Use dup2 to reject invalid file descriptors; the cloexec flag
59 will be unaffected. */
60 if (desc < 0)
61 {
62 errno = EBADF;
63 return -1;
64 }
65 if (dup2 (desc, desc) < 0)
66 /* errno is EBADF here. */
67 return -1;
68
69 /* There is nothing we can do on this kind of platform. Punt. */
70 return 0;
71#endif /* !F_SETFD */
72}
73
74
75/* Duplicates a file handle FD, while marking the copy to be closed
76 prior to exec or spawn. Returns -1 and sets errno if FD could not
77 be duplicated. */
78
79int
80dup_cloexec (int fd)
81{
82 return fcntl (fd, F_DUPFD_CLOEXEC, 0);
83}
diff --git a/gl/cloexec.h b/gl/cloexec.h
new file mode 100644
index 00000000..057fd668
--- /dev/null
+++ b/gl/cloexec.h
@@ -0,0 +1,34 @@
1/* cloexec.c - set or clear the close-on-exec descriptor flag
2
3 Copyright (C) 2004, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
19 or clear the flag if VALUE is false.
20 Return 0 on success, or -1 on error with 'errno' set.
21
22 Note that on MingW, this function does NOT protect DESC from being
23 inherited into spawned children. Instead, either use dup_cloexec
24 followed by closing the original DESC, or use interfaces such as
25 open or pipe2 that accept flags like O_CLOEXEC to create DESC
26 non-inheritable in the first place. */
27
28int set_cloexec_flag (int desc, bool value);
29
30/* Duplicates a file handle FD, while marking the copy to be closed
31 prior to exec or spawn. Returns -1 and sets errno if FD could not
32 be duplicated. */
33
34int dup_cloexec (int fd);
diff --git a/gl/close.c b/gl/close.c
new file mode 100644
index 00000000..3c1b09ea
--- /dev/null
+++ b/gl/close.c
@@ -0,0 +1,75 @@
1/* close replacement.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <unistd.h>
21
22#include <errno.h>
23
24#include "fd-hook.h"
25#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
26# include "msvc-inval.h"
27#endif
28
29#undef close
30
31#if defined _WIN32 && !defined __CYGWIN__
32# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
33static int
34close_nothrow (int fd)
35{
36 int result;
37
38 TRY_MSVC_INVAL
39 {
40 result = _close (fd);
41 }
42 CATCH_MSVC_INVAL
43 {
44 result = -1;
45 errno = EBADF;
46 }
47 DONE_MSVC_INVAL;
48
49 return result;
50}
51# else
52# define close_nothrow _close
53# endif
54#else
55# define close_nothrow close
56#endif
57
58/* Override close() to call into other gnulib modules. */
59
60int
61rpl_close (int fd)
62{
63#if WINDOWS_SOCKETS
64 int retval = execute_all_close_hooks (close_nothrow, fd);
65#else
66 int retval = close_nothrow (fd);
67#endif
68
69#if REPLACE_FCHDIR
70 if (retval >= 0)
71 _gl_unregister_fd (fd);
72#endif
73
74 return retval;
75}
diff --git a/gl/config.charset b/gl/config.charset
deleted file mode 100644
index a991419c..00000000
--- a/gl/config.charset
+++ /dev/null
@@ -1,684 +0,0 @@
1#! /bin/sh
2# Output a system dependent table of character encoding aliases.
3#
4# Copyright (C) 2000-2004, 2006-2013 Free Software Foundation, Inc.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, see <http://www.gnu.org/licenses/>.
18#
19# The table consists of lines of the form
20# ALIAS CANONICAL
21#
22# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
23# ALIAS is compared in a case sensitive way.
24#
25# CANONICAL is the GNU canonical name for this character encoding.
26# It must be an encoding supported by libiconv. Support by GNU libc is
27# also desirable. CANONICAL is case insensitive. Usually an upper case
28# MIME charset name is preferred.
29# The current list of GNU canonical charset names is as follows.
30#
31# name MIME? used by which systems
32# (darwin = Mac OS X, woe32 = native Windows)
33#
34# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
35# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
36# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
37# ISO-8859-3 Y glibc solaris cygwin
38# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin
39# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
40# ISO-8859-6 Y glibc aix hpux solaris cygwin
41# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
42# ISO-8859-8 Y glibc aix hpux osf solaris cygwin
43# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin
44# ISO-8859-13 glibc netbsd openbsd darwin cygwin
45# ISO-8859-14 glibc cygwin
46# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
47# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin
48# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
49# KOI8-T glibc
50# CP437 dos
51# CP775 dos
52# CP850 aix osf dos
53# CP852 dos
54# CP855 dos
55# CP856 aix
56# CP857 dos
57# CP861 dos
58# CP862 dos
59# CP864 dos
60# CP865 dos
61# CP866 freebsd netbsd openbsd darwin dos
62# CP869 dos
63# CP874 woe32 dos
64# CP922 aix
65# CP932 aix cygwin woe32 dos
66# CP943 aix
67# CP949 osf darwin woe32 dos
68# CP950 woe32 dos
69# CP1046 aix
70# CP1124 aix
71# CP1125 dos
72# CP1129 aix
73# CP1131 darwin
74# CP1250 woe32
75# CP1251 glibc solaris netbsd openbsd darwin cygwin woe32
76# CP1252 aix woe32
77# CP1253 woe32
78# CP1254 woe32
79# CP1255 glibc woe32
80# CP1256 woe32
81# CP1257 woe32
82# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
83# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
84# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
85# EUC-TW glibc aix hpux irix osf solaris netbsd
86# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
87# BIG5-HKSCS glibc solaris darwin
88# GBK glibc aix osf solaris darwin cygwin woe32 dos
89# GB18030 glibc solaris netbsd darwin
90# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
91# JOHAB glibc solaris woe32
92# TIS-620 glibc aix hpux osf solaris cygwin
93# VISCII Y glibc
94# TCVN5712-1 glibc
95# ARMSCII-8 glibc darwin
96# GEORGIAN-PS glibc cygwin
97# PT154 glibc
98# HP-ROMAN8 hpux
99# HP-ARABIC8 hpux
100# HP-GREEK8 hpux
101# HP-HEBREW8 hpux
102# HP-TURKISH8 hpux
103# HP-KANA8 hpux
104# DEC-KANJI osf
105# DEC-HANYU osf
106# UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
107#
108# Note: Names which are not marked as being a MIME name should not be used in
109# Internet protocols for information interchange (mail, news, etc.).
110#
111# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
112# must understand both names and treat them as equivalent.
113#
114# The first argument passed to this file is the canonical host specification,
115# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
116# or
117# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
118
119host="$1"
120os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
121echo "# This file contains a table of character encoding aliases,"
122echo "# suitable for operating system '${os}'."
123echo "# It was automatically generated from config.charset."
124# List of references, updated during installation:
125echo "# Packages using this file: "
126case "$os" in
127 linux-gnulibc1*)
128 # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
129 # localcharset.c falls back to using the full locale name
130 # from the environment variables.
131 echo "C ASCII"
132 echo "POSIX ASCII"
133 for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
134 en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
135 en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
136 es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
137 et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
138 fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
139 it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
140 sv_FI sv_SE; do
141 echo "$l ISO-8859-1"
142 echo "$l.iso-8859-1 ISO-8859-1"
143 echo "$l.iso-8859-15 ISO-8859-15"
144 echo "$l.iso-8859-15@euro ISO-8859-15"
145 echo "$l@euro ISO-8859-15"
146 echo "$l.cp-437 CP437"
147 echo "$l.cp-850 CP850"
148 echo "$l.cp-1252 CP1252"
149 echo "$l.cp-1252@euro CP1252"
150 #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
151 echo "$l.utf-8 UTF-8"
152 echo "$l.utf-8@euro UTF-8"
153 done
154 for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
155 sl_SI sr sr_CS sr_YU; do
156 echo "$l ISO-8859-2"
157 echo "$l.iso-8859-2 ISO-8859-2"
158 echo "$l.cp-852 CP852"
159 echo "$l.cp-1250 CP1250"
160 echo "$l.utf-8 UTF-8"
161 done
162 for l in mk mk_MK ru ru_RU; do
163 echo "$l ISO-8859-5"
164 echo "$l.iso-8859-5 ISO-8859-5"
165 echo "$l.koi8-r KOI8-R"
166 echo "$l.cp-866 CP866"
167 echo "$l.cp-1251 CP1251"
168 echo "$l.utf-8 UTF-8"
169 done
170 for l in ar ar_SA; do
171 echo "$l ISO-8859-6"
172 echo "$l.iso-8859-6 ISO-8859-6"
173 echo "$l.cp-864 CP864"
174 #echo "$l.cp-868 CP868" # not a commonly used encoding
175 echo "$l.cp-1256 CP1256"
176 echo "$l.utf-8 UTF-8"
177 done
178 for l in el el_GR gr gr_GR; do
179 echo "$l ISO-8859-7"
180 echo "$l.iso-8859-7 ISO-8859-7"
181 echo "$l.cp-869 CP869"
182 echo "$l.cp-1253 CP1253"
183 echo "$l.cp-1253@euro CP1253"
184 echo "$l.utf-8 UTF-8"
185 echo "$l.utf-8@euro UTF-8"
186 done
187 for l in he he_IL iw iw_IL; do
188 echo "$l ISO-8859-8"
189 echo "$l.iso-8859-8 ISO-8859-8"
190 echo "$l.cp-862 CP862"
191 echo "$l.cp-1255 CP1255"
192 echo "$l.utf-8 UTF-8"
193 done
194 for l in tr tr_TR; do
195 echo "$l ISO-8859-9"
196 echo "$l.iso-8859-9 ISO-8859-9"
197 echo "$l.cp-857 CP857"
198 echo "$l.cp-1254 CP1254"
199 echo "$l.utf-8 UTF-8"
200 done
201 for l in lt lt_LT lv lv_LV; do
202 #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
203 echo "$l ISO-8859-13"
204 done
205 for l in ru_UA uk uk_UA; do
206 echo "$l KOI8-U"
207 done
208 for l in zh zh_CN; do
209 #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
210 echo "$l GB2312"
211 done
212 for l in ja ja_JP ja_JP.EUC; do
213 echo "$l EUC-JP"
214 done
215 for l in ko ko_KR; do
216 echo "$l EUC-KR"
217 done
218 for l in th th_TH; do
219 echo "$l TIS-620"
220 done
221 for l in fa fa_IR; do
222 #echo "$l ISIRI-3342" # a broken encoding
223 echo "$l.utf-8 UTF-8"
224 done
225 ;;
226 linux* | *-gnu*)
227 # With glibc-2.1 or newer, we don't need any canonicalization,
228 # because glibc has iconv and both glibc and libiconv support all
229 # GNU canonical names directly. Therefore, the Makefile does not
230 # need to install the alias file at all.
231 # The following applies only to glibc-2.0.x and older libcs.
232 echo "ISO_646.IRV:1983 ASCII"
233 ;;
234 aix*)
235 echo "ISO8859-1 ISO-8859-1"
236 echo "ISO8859-2 ISO-8859-2"
237 echo "ISO8859-5 ISO-8859-5"
238 echo "ISO8859-6 ISO-8859-6"
239 echo "ISO8859-7 ISO-8859-7"
240 echo "ISO8859-8 ISO-8859-8"
241 echo "ISO8859-9 ISO-8859-9"
242 echo "ISO8859-15 ISO-8859-15"
243 echo "IBM-850 CP850"
244 echo "IBM-856 CP856"
245 echo "IBM-921 ISO-8859-13"
246 echo "IBM-922 CP922"
247 echo "IBM-932 CP932"
248 echo "IBM-943 CP943"
249 echo "IBM-1046 CP1046"
250 echo "IBM-1124 CP1124"
251 echo "IBM-1129 CP1129"
252 echo "IBM-1252 CP1252"
253 echo "IBM-eucCN GB2312"
254 echo "IBM-eucJP EUC-JP"
255 echo "IBM-eucKR EUC-KR"
256 echo "IBM-eucTW EUC-TW"
257 echo "big5 BIG5"
258 echo "GBK GBK"
259 echo "TIS-620 TIS-620"
260 echo "UTF-8 UTF-8"
261 ;;
262 hpux*)
263 echo "iso88591 ISO-8859-1"
264 echo "iso88592 ISO-8859-2"
265 echo "iso88595 ISO-8859-5"
266 echo "iso88596 ISO-8859-6"
267 echo "iso88597 ISO-8859-7"
268 echo "iso88598 ISO-8859-8"
269 echo "iso88599 ISO-8859-9"
270 echo "iso885915 ISO-8859-15"
271 echo "roman8 HP-ROMAN8"
272 echo "arabic8 HP-ARABIC8"
273 echo "greek8 HP-GREEK8"
274 echo "hebrew8 HP-HEBREW8"
275 echo "turkish8 HP-TURKISH8"
276 echo "kana8 HP-KANA8"
277 echo "tis620 TIS-620"
278 echo "big5 BIG5"
279 echo "eucJP EUC-JP"
280 echo "eucKR EUC-KR"
281 echo "eucTW EUC-TW"
282 echo "hp15CN GB2312"
283 #echo "ccdc ?" # what is this?
284 echo "SJIS SHIFT_JIS"
285 echo "utf8 UTF-8"
286 ;;
287 irix*)
288 echo "ISO8859-1 ISO-8859-1"
289 echo "ISO8859-2 ISO-8859-2"
290 echo "ISO8859-5 ISO-8859-5"
291 echo "ISO8859-7 ISO-8859-7"
292 echo "ISO8859-9 ISO-8859-9"
293 echo "eucCN GB2312"
294 echo "eucJP EUC-JP"
295 echo "eucKR EUC-KR"
296 echo "eucTW EUC-TW"
297 ;;
298 osf*)
299 echo "ISO8859-1 ISO-8859-1"
300 echo "ISO8859-2 ISO-8859-2"
301 echo "ISO8859-4 ISO-8859-4"
302 echo "ISO8859-5 ISO-8859-5"
303 echo "ISO8859-7 ISO-8859-7"
304 echo "ISO8859-8 ISO-8859-8"
305 echo "ISO8859-9 ISO-8859-9"
306 echo "ISO8859-15 ISO-8859-15"
307 echo "cp850 CP850"
308 echo "big5 BIG5"
309 echo "dechanyu DEC-HANYU"
310 echo "dechanzi GB2312"
311 echo "deckanji DEC-KANJI"
312 echo "deckorean EUC-KR"
313 echo "eucJP EUC-JP"
314 echo "eucKR EUC-KR"
315 echo "eucTW EUC-TW"
316 echo "GBK GBK"
317 echo "KSC5601 CP949"
318 echo "sdeckanji EUC-JP"
319 echo "SJIS SHIFT_JIS"
320 echo "TACTIS TIS-620"
321 echo "UTF-8 UTF-8"
322 ;;
323 solaris*)
324 echo "646 ASCII"
325 echo "ISO8859-1 ISO-8859-1"
326 echo "ISO8859-2 ISO-8859-2"
327 echo "ISO8859-3 ISO-8859-3"
328 echo "ISO8859-4 ISO-8859-4"
329 echo "ISO8859-5 ISO-8859-5"
330 echo "ISO8859-6 ISO-8859-6"
331 echo "ISO8859-7 ISO-8859-7"
332 echo "ISO8859-8 ISO-8859-8"
333 echo "ISO8859-9 ISO-8859-9"
334 echo "ISO8859-15 ISO-8859-15"
335 echo "koi8-r KOI8-R"
336 echo "ansi-1251 CP1251"
337 echo "BIG5 BIG5"
338 echo "Big5-HKSCS BIG5-HKSCS"
339 echo "gb2312 GB2312"
340 echo "GBK GBK"
341 echo "GB18030 GB18030"
342 echo "cns11643 EUC-TW"
343 echo "5601 EUC-KR"
344 echo "ko_KR.johap92 JOHAB"
345 echo "eucJP EUC-JP"
346 echo "PCK SHIFT_JIS"
347 echo "TIS620.2533 TIS-620"
348 #echo "sun_eu_greek ?" # what is this?
349 echo "UTF-8 UTF-8"
350 ;;
351 freebsd* | os2*)
352 # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
353 # localcharset.c falls back to using the full locale name
354 # from the environment variables.
355 # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
356 # reuse FreeBSD's locale data for OS/2.
357 echo "C ASCII"
358 echo "US-ASCII ASCII"
359 for l in la_LN lt_LN; do
360 echo "$l.ASCII ASCII"
361 done
362 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
363 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
364 lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
365 echo "$l.ISO_8859-1 ISO-8859-1"
366 echo "$l.DIS_8859-15 ISO-8859-15"
367 done
368 for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
369 echo "$l.ISO_8859-2 ISO-8859-2"
370 done
371 for l in la_LN lt_LT; do
372 echo "$l.ISO_8859-4 ISO-8859-4"
373 done
374 for l in ru_RU ru_SU; do
375 echo "$l.KOI8-R KOI8-R"
376 echo "$l.ISO_8859-5 ISO-8859-5"
377 echo "$l.CP866 CP866"
378 done
379 echo "uk_UA.KOI8-U KOI8-U"
380 echo "zh_TW.BIG5 BIG5"
381 echo "zh_TW.Big5 BIG5"
382 echo "zh_CN.EUC GB2312"
383 echo "ja_JP.EUC EUC-JP"
384 echo "ja_JP.SJIS SHIFT_JIS"
385 echo "ja_JP.Shift_JIS SHIFT_JIS"
386 echo "ko_KR.EUC EUC-KR"
387 ;;
388 netbsd*)
389 echo "646 ASCII"
390 echo "ISO8859-1 ISO-8859-1"
391 echo "ISO8859-2 ISO-8859-2"
392 echo "ISO8859-4 ISO-8859-4"
393 echo "ISO8859-5 ISO-8859-5"
394 echo "ISO8859-7 ISO-8859-7"
395 echo "ISO8859-13 ISO-8859-13"
396 echo "ISO8859-15 ISO-8859-15"
397 echo "eucCN GB2312"
398 echo "eucJP EUC-JP"
399 echo "eucKR EUC-KR"
400 echo "eucTW EUC-TW"
401 echo "BIG5 BIG5"
402 echo "SJIS SHIFT_JIS"
403 ;;
404 openbsd*)
405 echo "646 ASCII"
406 echo "ISO8859-1 ISO-8859-1"
407 echo "ISO8859-2 ISO-8859-2"
408 echo "ISO8859-4 ISO-8859-4"
409 echo "ISO8859-5 ISO-8859-5"
410 echo "ISO8859-7 ISO-8859-7"
411 echo "ISO8859-13 ISO-8859-13"
412 echo "ISO8859-15 ISO-8859-15"
413 ;;
414 darwin[56]*)
415 # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
416 # localcharset.c falls back to using the full locale name
417 # from the environment variables.
418 echo "C ASCII"
419 for l in en_AU en_CA en_GB en_US la_LN; do
420 echo "$l.US-ASCII ASCII"
421 done
422 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
423 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
424 nl_NL no_NO pt_PT sv_SE; do
425 echo "$l ISO-8859-1"
426 echo "$l.ISO8859-1 ISO-8859-1"
427 echo "$l.ISO8859-15 ISO-8859-15"
428 done
429 for l in la_LN; do
430 echo "$l.ISO8859-1 ISO-8859-1"
431 echo "$l.ISO8859-15 ISO-8859-15"
432 done
433 for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
434 echo "$l.ISO8859-2 ISO-8859-2"
435 done
436 for l in la_LN lt_LT; do
437 echo "$l.ISO8859-4 ISO-8859-4"
438 done
439 for l in ru_RU; do
440 echo "$l.KOI8-R KOI8-R"
441 echo "$l.ISO8859-5 ISO-8859-5"
442 echo "$l.CP866 CP866"
443 done
444 for l in bg_BG; do
445 echo "$l.CP1251 CP1251"
446 done
447 echo "uk_UA.KOI8-U KOI8-U"
448 echo "zh_TW.BIG5 BIG5"
449 echo "zh_TW.Big5 BIG5"
450 echo "zh_CN.EUC GB2312"
451 echo "ja_JP.EUC EUC-JP"
452 echo "ja_JP.SJIS SHIFT_JIS"
453 echo "ko_KR.EUC EUC-KR"
454 ;;
455 darwin*)
456 # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
457 # useless:
458 # - It returns the empty string when LANG is set to a locale of the
459 # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
460 # LC_CTYPE file.
461 # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
462 # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
463 # - The documentation says:
464 # "... all code that calls BSD system routines should ensure
465 # that the const *char parameters of these routines are in UTF-8
466 # encoding. All BSD system functions expect their string
467 # parameters to be in UTF-8 encoding and nothing else."
468 # It also says
469 # "An additional caveat is that string parameters for files,
470 # paths, and other file-system entities must be in canonical
471 # UTF-8. In a canonical UTF-8 Unicode string, all decomposable
472 # characters are decomposed ..."
473 # but this is not true: You can pass non-decomposed UTF-8 strings
474 # to file system functions, and it is the OS which will convert
475 # them to decomposed UTF-8 before accessing the file system.
476 # - The Apple Terminal application displays UTF-8 by default.
477 # - However, other applications are free to use different encodings:
478 # - xterm uses ISO-8859-1 by default.
479 # - TextEdit uses MacRoman by default.
480 # We prefer UTF-8 over decomposed UTF-8-MAC because one should
481 # minimize the use of decomposed Unicode. Unfortunately, through the
482 # Darwin file system, decomposed UTF-8 strings are leaked into user
483 # space nevertheless.
484 # Then there are also the locales with encodings other than US-ASCII
485 # and UTF-8. These locales can be occasionally useful to users (e.g.
486 # when grepping through ISO-8859-1 encoded text files), when all their
487 # file names are in US-ASCII.
488 echo "ISO8859-1 ISO-8859-1"
489 echo "ISO8859-2 ISO-8859-2"
490 echo "ISO8859-4 ISO-8859-4"
491 echo "ISO8859-5 ISO-8859-5"
492 echo "ISO8859-7 ISO-8859-7"
493 echo "ISO8859-9 ISO-8859-9"
494 echo "ISO8859-13 ISO-8859-13"
495 echo "ISO8859-15 ISO-8859-15"
496 echo "KOI8-R KOI8-R"
497 echo "KOI8-U KOI8-U"
498 echo "CP866 CP866"
499 echo "CP949 CP949"
500 echo "CP1131 CP1131"
501 echo "CP1251 CP1251"
502 echo "eucCN GB2312"
503 echo "GB2312 GB2312"
504 echo "eucJP EUC-JP"
505 echo "eucKR EUC-KR"
506 echo "Big5 BIG5"
507 echo "Big5HKSCS BIG5-HKSCS"
508 echo "GBK GBK"
509 echo "GB18030 GB18030"
510 echo "SJIS SHIFT_JIS"
511 echo "ARMSCII-8 ARMSCII-8"
512 echo "PT154 PT154"
513 #echo "ISCII-DEV ?"
514 echo "* UTF-8"
515 ;;
516 beos* | haiku*)
517 # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
518 echo "* UTF-8"
519 ;;
520 msdosdjgpp*)
521 # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
522 # localcharset.c falls back to using the full locale name
523 # from the environment variables.
524 echo "#"
525 echo "# The encodings given here may not all be correct."
526 echo "# If you find that the encoding given for your language and"
527 echo "# country is not the one your DOS machine actually uses, just"
528 echo "# correct it in this file, and send a mail to"
529 echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
530 echo "# and Bruno Haible <bruno@clisp.org>."
531 echo "#"
532 echo "C ASCII"
533 # ISO-8859-1 languages
534 echo "ca CP850"
535 echo "ca_ES CP850"
536 echo "da CP865" # not CP850 ??
537 echo "da_DK CP865" # not CP850 ??
538 echo "de CP850"
539 echo "de_AT CP850"
540 echo "de_CH CP850"
541 echo "de_DE CP850"
542 echo "en CP850"
543 echo "en_AU CP850" # not CP437 ??
544 echo "en_CA CP850"
545 echo "en_GB CP850"
546 echo "en_NZ CP437"
547 echo "en_US CP437"
548 echo "en_ZA CP850" # not CP437 ??
549 echo "es CP850"
550 echo "es_AR CP850"
551 echo "es_BO CP850"
552 echo "es_CL CP850"
553 echo "es_CO CP850"
554 echo "es_CR CP850"
555 echo "es_CU CP850"
556 echo "es_DO CP850"
557 echo "es_EC CP850"
558 echo "es_ES CP850"
559 echo "es_GT CP850"
560 echo "es_HN CP850"
561 echo "es_MX CP850"
562 echo "es_NI CP850"
563 echo "es_PA CP850"
564 echo "es_PY CP850"
565 echo "es_PE CP850"
566 echo "es_SV CP850"
567 echo "es_UY CP850"
568 echo "es_VE CP850"
569 echo "et CP850"
570 echo "et_EE CP850"
571 echo "eu CP850"
572 echo "eu_ES CP850"
573 echo "fi CP850"
574 echo "fi_FI CP850"
575 echo "fr CP850"
576 echo "fr_BE CP850"
577 echo "fr_CA CP850"
578 echo "fr_CH CP850"
579 echo "fr_FR CP850"
580 echo "ga CP850"
581 echo "ga_IE CP850"
582 echo "gd CP850"
583 echo "gd_GB CP850"
584 echo "gl CP850"
585 echo "gl_ES CP850"
586 echo "id CP850" # not CP437 ??
587 echo "id_ID CP850" # not CP437 ??
588 echo "is CP861" # not CP850 ??
589 echo "is_IS CP861" # not CP850 ??
590 echo "it CP850"
591 echo "it_CH CP850"
592 echo "it_IT CP850"
593 echo "lt CP775"
594 echo "lt_LT CP775"
595 echo "lv CP775"
596 echo "lv_LV CP775"
597 echo "nb CP865" # not CP850 ??
598 echo "nb_NO CP865" # not CP850 ??
599 echo "nl CP850"
600 echo "nl_BE CP850"
601 echo "nl_NL CP850"
602 echo "nn CP865" # not CP850 ??
603 echo "nn_NO CP865" # not CP850 ??
604 echo "no CP865" # not CP850 ??
605 echo "no_NO CP865" # not CP850 ??
606 echo "pt CP850"
607 echo "pt_BR CP850"
608 echo "pt_PT CP850"
609 echo "sv CP850"
610 echo "sv_SE CP850"
611 # ISO-8859-2 languages
612 echo "cs CP852"
613 echo "cs_CZ CP852"
614 echo "hr CP852"
615 echo "hr_HR CP852"
616 echo "hu CP852"
617 echo "hu_HU CP852"
618 echo "pl CP852"
619 echo "pl_PL CP852"
620 echo "ro CP852"
621 echo "ro_RO CP852"
622 echo "sk CP852"
623 echo "sk_SK CP852"
624 echo "sl CP852"
625 echo "sl_SI CP852"
626 echo "sq CP852"
627 echo "sq_AL CP852"
628 echo "sr CP852" # CP852 or CP866 or CP855 ??
629 echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
630 echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
631 # ISO-8859-3 languages
632 echo "mt CP850"
633 echo "mt_MT CP850"
634 # ISO-8859-5 languages
635 echo "be CP866"
636 echo "be_BE CP866"
637 echo "bg CP866" # not CP855 ??
638 echo "bg_BG CP866" # not CP855 ??
639 echo "mk CP866" # not CP855 ??
640 echo "mk_MK CP866" # not CP855 ??
641 echo "ru CP866"
642 echo "ru_RU CP866"
643 echo "uk CP1125"
644 echo "uk_UA CP1125"
645 # ISO-8859-6 languages
646 echo "ar CP864"
647 echo "ar_AE CP864"
648 echo "ar_DZ CP864"
649 echo "ar_EG CP864"
650 echo "ar_IQ CP864"
651 echo "ar_IR CP864"
652 echo "ar_JO CP864"
653 echo "ar_KW CP864"
654 echo "ar_MA CP864"
655 echo "ar_OM CP864"
656 echo "ar_QA CP864"
657 echo "ar_SA CP864"
658 echo "ar_SY CP864"
659 # ISO-8859-7 languages
660 echo "el CP869"
661 echo "el_GR CP869"
662 # ISO-8859-8 languages
663 echo "he CP862"
664 echo "he_IL CP862"
665 # ISO-8859-9 languages
666 echo "tr CP857"
667 echo "tr_TR CP857"
668 # Japanese
669 echo "ja CP932"
670 echo "ja_JP CP932"
671 # Chinese
672 echo "zh_CN GBK"
673 echo "zh_TW CP950" # not CP938 ??
674 # Korean
675 echo "kr CP949" # not CP934 ??
676 echo "kr_KR CP949" # not CP934 ??
677 # Thai
678 echo "th CP874"
679 echo "th_TH CP874"
680 # Other
681 echo "eo CP850"
682 echo "eo_EO CP850"
683 ;;
684esac
diff --git a/gl/dirname-lgpl.c b/gl/dirname-lgpl.c
index 82f66301..e9454af3 100644
--- a/gl/dirname-lgpl.c
+++ b/gl/dirname-lgpl.c
@@ -1,20 +1,20 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/dirname.c b/gl/dirname.c
index 1fb65888..e72f7130 100644
--- a/gl/dirname.c
+++ b/gl/dirname.c
@@ -1,11 +1,11 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/dirname.h b/gl/dirname.h
index 4ad03120..f98e83bd 100644
--- a/gl/dirname.h
+++ b/gl/dirname.h
@@ -1,46 +1,53 @@
1/* Take file names apart into directory and base names. 1/* Take file names apart into directory and base names.
2 2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation, 3 Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef DIRNAME_H_ 19#ifndef DIRNAME_H_
20# define DIRNAME_H_ 1 20# define DIRNAME_H_ 1
21 21
22# include <stdbool.h> 22# include <stdlib.h>
23# include <stddef.h> 23# include "filename.h"
24# include "dosname.h" 24# include "basename-lgpl.h"
25 25
26# ifndef DIRECTORY_SEPARATOR 26# ifndef DIRECTORY_SEPARATOR
27# define DIRECTORY_SEPARATOR '/' 27# define DIRECTORY_SEPARATOR '/'
28# endif 28# endif
29 29
30# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT 30#ifdef __cplusplus
31# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 31extern "C" {
32# endif 32#endif
33 33
34# if GNULIB_DIRNAME 34# if GNULIB_DIRNAME
35char *base_name (char const *file); 35char *base_name (char const *file)
36char *dir_name (char const *file); 36 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
37 _GL_ATTRIBUTE_RETURNS_NONNULL;
38char *dir_name (char const *file)
39 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
40 _GL_ATTRIBUTE_RETURNS_NONNULL;
37# endif 41# endif
38 42
39char *mdir_name (char const *file); 43char *mdir_name (char const *file)
40size_t base_len (char const *file) _GL_ATTRIBUTE_PURE; 44 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
41size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE; 45size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
42char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
43 46
44bool strip_trailing_slashes (char *file); 47bool strip_trailing_slashes (char *file);
45 48
49#ifdef __cplusplus
50} /* extern "C" */
51#endif
52
46#endif /* not DIRNAME_H_ */ 53#endif /* not DIRNAME_H_ */
diff --git a/gl/dosname.h b/gl/dosname.h
deleted file mode 100644
index ba63ce4b..00000000
--- a/gl/dosname.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/* File names on MS-DOS/Windows systems.
2
3 Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 From Paul Eggert and Jim Meyering. */
19
20#ifndef _DOSNAME_H
21#define _DOSNAME_H
22
23#if (defined _WIN32 || defined __WIN32__ || \
24 defined __MSDOS__ || defined __CYGWIN__ || \
25 defined __EMX__ || defined __DJGPP__)
26 /* This internal macro assumes ASCII, but all hosts that support drive
27 letters use ASCII. */
28# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
29 <= 'z' - 'a')
30# define FILE_SYSTEM_PREFIX_LEN(Filename) \
31 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
32# ifndef __CYGWIN__
33# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
34# endif
35# define ISSLASH(C) ((C) == '/' || (C) == '\\')
36#else
37# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
38# define ISSLASH(C) ((C) == '/')
39#endif
40
41#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
42# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
43#endif
44
45#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
46# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
47# else
48# define IS_ABSOLUTE_FILE_NAME(F) \
49 (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
50#endif
51#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
52
53#endif /* DOSNAME_H_ */
diff --git a/gl/dup2.c b/gl/dup2.c
new file mode 100644
index 00000000..7d197ca3
--- /dev/null
+++ b/gl/dup2.c
@@ -0,0 +1,189 @@
1/* Duplicate an open file descriptor to a specified file descriptor.
2
3 Copyright (C) 1999, 2004-2007, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Paul Eggert */
19
20#include <config.h>
21
22/* Specification. */
23#include <unistd.h>
24
25#include <errno.h>
26#include <fcntl.h>
27
28#undef dup2
29
30#if defined _WIN32 && ! defined __CYGWIN__
31
32/* Get declarations of the native Windows API functions. */
33# define WIN32_LEAN_AND_MEAN
34# include <windows.h>
35
36# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
37# include "msvc-inval.h"
38# endif
39
40/* Get _get_osfhandle. */
41# if GNULIB_MSVC_NOTHROW
42# include "msvc-nothrow.h"
43# else
44# include <io.h>
45# endif
46
47# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
48static int
49dup2_nothrow (int fd, int desired_fd)
50{
51 int result;
52
53 TRY_MSVC_INVAL
54 {
55 result = _dup2 (fd, desired_fd);
56 }
57 CATCH_MSVC_INVAL
58 {
59 errno = EBADF;
60 result = -1;
61 }
62 DONE_MSVC_INVAL;
63
64 return result;
65}
66# else
67# define dup2_nothrow _dup2
68# endif
69
70static int
71ms_windows_dup2 (int fd, int desired_fd)
72{
73 int result;
74
75 /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
76 dup2 (fd, fd) returns 0, but all further attempts to use fd in
77 future dup2 calls will hang. */
78 if (fd == desired_fd)
79 {
80 if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
81 {
82 errno = EBADF;
83 return -1;
84 }
85 return fd;
86 }
87
88 /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
89 https://bugs.winehq.org/show_bug.cgi?id=21289 */
90 if (desired_fd < 0)
91 {
92 errno = EBADF;
93 return -1;
94 }
95
96 result = dup2_nothrow (fd, desired_fd);
97
98 if (result == 0)
99 result = desired_fd;
100
101 return result;
102}
103
104# define dup2 ms_windows_dup2
105
106#elif defined __KLIBC__
107
108# include <InnoTekLIBC/backend.h>
109
110static int
111klibc_dup2dirfd (int fd, int desired_fd)
112{
113 int tempfd;
114 int dupfd;
115
116 tempfd = open ("NUL", O_RDONLY);
117 if (tempfd == -1)
118 return -1;
119
120 if (tempfd == desired_fd)
121 {
122 close (tempfd);
123
124 char path[_MAX_PATH];
125 if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
126 return -1;
127
128 return open(path, O_RDONLY);
129 }
130
131 dupfd = klibc_dup2dirfd (fd, desired_fd);
132
133 close (tempfd);
134
135 return dupfd;
136}
137
138static int
139klibc_dup2 (int fd, int desired_fd)
140{
141 int dupfd;
142 struct stat sbuf;
143
144 dupfd = dup2 (fd, desired_fd);
145 if (dupfd == -1 && errno == ENOTSUP \
146 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
147 {
148 close (desired_fd);
149
150 return klibc_dup2dirfd (fd, desired_fd);
151 }
152
153 return dupfd;
154}
155
156# define dup2 klibc_dup2
157#endif
158
159int
160rpl_dup2 (int fd, int desired_fd)
161{
162 int result;
163
164#ifdef F_GETFL
165 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
166 On Cygwin 1.5.x, dup2 (1, 1) returns 0.
167 On Cygwin 1.7.17, dup2 (1, -1) dumps core.
168 On Cygwin 1.7.25, dup2 (1, 256) can dump core.
169 On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */
170# if HAVE_SETDTABLESIZE
171 setdtablesize (desired_fd + 1);
172# endif
173 if (desired_fd < 0)
174 fd = desired_fd;
175 if (fd == desired_fd)
176 return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
177#endif
178
179 result = dup2 (fd, desired_fd);
180
181 /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */
182 if (result == -1 && errno == EMFILE)
183 errno = EBADF;
184#if REPLACE_FCHDIR
185 if (fd != desired_fd && result != -1)
186 result = _gl_register_dup (fd, result);
187#endif
188 return result;
189}
diff --git a/gl/dynarray.h b/gl/dynarray.h
new file mode 100644
index 00000000..91559109
--- /dev/null
+++ b/gl/dynarray.h
@@ -0,0 +1,284 @@
1/* Type-safe arrays which grow dynamically.
2 Copyright 2021-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Paul Eggert and Bruno Haible, 2021. */
18
19#ifndef _GL_DYNARRAY_H
20#define _GL_DYNARRAY_H
21
22/* Before including this file, you need to define:
23
24 DYNARRAY_STRUCT
25 The struct tag of dynamic array to be defined.
26
27 DYNARRAY_ELEMENT
28 The type name of the element type. Elements are copied
29 as if by memcpy, and can change address as the dynamic
30 array grows.
31
32 DYNARRAY_PREFIX
33 The prefix of the functions which are defined.
34
35 The following parameters are optional:
36
37 DYNARRAY_ELEMENT_FREE
38 DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
39 contents of elements. E is of type DYNARRAY_ELEMENT *.
40
41 DYNARRAY_ELEMENT_INIT
42 DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
43 element. E is of type DYNARRAY_ELEMENT *.
44 If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
45 defined, new elements are automatically zero-initialized.
46 Otherwise, new elements have undefined contents.
47
48 DYNARRAY_INITIAL_SIZE
49 The size of the statically allocated array (default:
50 at least 2, more elements if they fit into 128 bytes).
51 Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
52 there is no statically allocated array at, and all non-empty
53 arrays are heap-allocated.
54
55 DYNARRAY_FINAL_TYPE
56 The name of the type which holds the final array. If not
57 defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
58 must be a struct type, with members of type DYNARRAY_ELEMENT and
59 size_t at the start (in this order).
60
61 These macros are undefined after this header file has been
62 included.
63
64 The following types are provided (their members are private to the
65 dynarray implementation):
66
67 struct DYNARRAY_STRUCT
68
69 The following functions are provided:
70 */
71
72/* Initialize a dynamic array object. This must be called before any
73 use of the object. */
74#if 0
75static void
76 DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *list);
77#endif
78
79/* Deallocate the dynamic array and its elements. */
80#if 0
81static void
82 DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *list);
83#endif
84
85/* Return true if the dynamic array is in an error state. */
86#if 0
87static bool
88 DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *list);
89#endif
90
91/* Mark the dynamic array as failed. All elements are deallocated as
92 a side effect. */
93#if 0
94static void
95 DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *list);
96#endif
97
98/* Return the number of elements which have been added to the dynamic
99 array. */
100#if 0
101static size_t
102 DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *list);
103#endif
104
105/* Return a pointer to the first array element, if any. For a
106 zero-length array, the pointer can be NULL even though the dynamic
107 array has not entered the failure state. */
108#if 0
109static DYNARRAY_ELEMENT *
110 DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *list);
111#endif
112
113/* Return a pointer one element past the last array element. For a
114 zero-length array, the pointer can be NULL even though the dynamic
115 array has not entered the failure state. */
116#if 0
117static DYNARRAY_ELEMENT *
118 DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *list);
119#endif
120
121/* Return a pointer to the array element at INDEX. Terminate the
122 process if INDEX is out of bounds. */
123#if 0
124static DYNARRAY_ELEMENT *
125 DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *list, size_t index);
126#endif
127
128/* Add ITEM at the end of the array, enlarging it by one element.
129 Mark *LIST as failed if the dynamic array allocation size cannot be
130 increased. */
131#if 0
132static void
133 DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *list,
134 DYNARRAY_ELEMENT item);
135#endif
136
137/* Allocate a place for a new element in *LIST and return a pointer to
138 it. The pointer can be NULL if the dynamic array cannot be
139 enlarged due to a memory allocation failure. */
140#if 0
141static DYNARRAY_ELEMENT *
142 DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *list);
143#endif
144
145/* Change the size of *LIST to SIZE. If SIZE is larger than the
146 existing size, new elements are added (which can be initialized).
147 Otherwise, the list is truncated, and elements are freed. Return
148 false on memory allocation failure (and mark *LIST as failed). */
149#if 0
150static bool
151 DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *list, size_t size);
152#endif
153
154/* Remove the last element of LIST if it is present. */
155#if 0
156static void
157 DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *list);
158#endif
159
160/* Remove all elements from the list. The elements are freed, but the
161 list itself is not. */
162#if 0
163static void
164 DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *list);
165#endif
166
167#if defined DYNARRAY_FINAL_TYPE
168/* Transfer the dynamic array to a permanent location at *RESULT.
169 Returns true on success on false on allocation failure. In either
170 case, *LIST is re-initialized and can be reused. A NULL pointer is
171 stored in *RESULT if LIST refers to an empty list. On success, the
172 pointer in *RESULT is heap-allocated and must be deallocated using
173 free. */
174#if 0
175static bool
176 DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
177 DYNARRAY_FINAL_TYPE *result);
178#endif
179#else /* !defined DYNARRAY_FINAL_TYPE */
180/* Transfer the dynamic array to a heap-allocated array and return a
181 pointer to it. The pointer is NULL if memory allocation fails, or
182 if the array is empty, so this function should be used only for
183 arrays which are known not be empty (usually because they always
184 have a sentinel at the end). If LENGTHP is not NULL, the array
185 length is written to *LENGTHP. *LIST is re-initialized and can be
186 reused. */
187#if 0
188static DYNARRAY_ELEMENT *
189 DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
190 size_t *lengthp);
191#endif
192#endif
193
194/* A minimal example which provides a growing list of integers can be
195 defined like this:
196
197 struct int_array
198 {
199 // Pointer to result array followed by its length,
200 // as required by DYNARRAY_FINAL_TYPE.
201 int *array;
202 size_t length;
203 };
204
205 #define DYNARRAY_STRUCT dynarray_int
206 #define DYNARRAY_ELEMENT int
207 #define DYNARRAY_PREFIX dynarray_int_
208 #define DYNARRAY_FINAL_TYPE struct int_array
209 #include <malloc/dynarray-skeleton.c>
210
211 To create a three-element array with elements 1, 2, 3, use this
212 code:
213
214 struct dynarray_int dyn;
215 dynarray_int_init (&dyn);
216 for (int i = 1; i <= 3; ++i)
217 {
218 int *place = dynarray_int_emplace (&dyn);
219 assert (place != NULL);
220 *place = i;
221 }
222 struct int_array result;
223 bool ok = dynarray_int_finalize (&dyn, &result);
224 assert (ok);
225 assert (result.length == 3);
226 assert (result.array[0] == 1);
227 assert (result.array[1] == 2);
228 assert (result.array[2] == 3);
229 free (result.array);
230
231 If the elements contain resources which must be freed, define
232 DYNARRAY_ELEMENT_FREE appropriately, like this:
233
234 struct str_array
235 {
236 char **array;
237 size_t length;
238 };
239
240 #define DYNARRAY_STRUCT dynarray_str
241 #define DYNARRAY_ELEMENT char *
242 #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
243 #define DYNARRAY_PREFIX dynarray_str_
244 #define DYNARRAY_FINAL_TYPE struct str_array
245 #include <malloc/dynarray-skeleton.c>
246 */
247
248
249/* The implementation is imported from glibc. */
250
251/* Avoid possible conflicts with symbols exported by the GNU libc. */
252#define __libc_dynarray_at_failure gl_dynarray_at_failure
253#define __libc_dynarray_emplace_enlarge gl_dynarray_emplace_enlarge
254#define __libc_dynarray_finalize gl_dynarray_finalize
255#define __libc_dynarray_resize_clear gl_dynarray_resize_clear
256#define __libc_dynarray_resize gl_dynarray_resize
257
258#if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX
259
260# ifndef _GL_LIKELY
261/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */
262# define _GL_LIKELY(cond) __builtin_expect ((cond), 1)
263# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0)
264# endif
265
266/* Define auxiliary structs and declare auxiliary functions, common to all
267 instantiations of dynarray. */
268# include <malloc/dynarray.gl.h>
269
270/* Define the instantiation, specified through
271 DYNARRAY_STRUCT
272 DYNARRAY_ELEMENT
273 DYNARRAY_PREFIX
274 etc. */
275# include <malloc/dynarray-skeleton.gl.h>
276
277#else
278
279/* This file is being included from one of the malloc/dynarray_*.c files. */
280# include <malloc/dynarray.h>
281
282#endif
283
284#endif /* _GL_DYNARRAY_H */
diff --git a/gl/errno.in.h b/gl/errno.in.h
index 49b35464..3dda9c26 100644
--- a/gl/errno.in.h
+++ b/gl/errno.in.h
@@ -1,19 +1,19 @@
1/* A POSIX-like <errno.h>. 1/* A POSIX-like <errno.h>.
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_ERRNO_H 18#ifndef _@GUARD_PREFIX@_ERRNO_H
19 19
@@ -30,7 +30,7 @@
30 30
31 31
32/* On native Windows platforms, many macros are not defined. */ 32/* On native Windows platforms, many macros are not defined. */
33# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 33# if defined _WIN32 && ! defined __CYGWIN__
34 34
35/* These are the same values as defined by MSVC 10, for interoperability. */ 35/* These are the same values as defined by MSVC 10, for interoperability. */
36 36
@@ -248,7 +248,7 @@
248 interoperability. */ 248 interoperability. */
249# define EOWNERDEAD 58 249# define EOWNERDEAD 58
250# define ENOTRECOVERABLE 59 250# define ENOTRECOVERABLE 59
251# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 251# elif defined _WIN32 && ! defined __CYGWIN__
252 /* We have a conflict here: pthreads-win32 defines these values 252 /* We have a conflict here: pthreads-win32 defines these values
253 differently than MSVC 10. It's hairy to decide which one to use. */ 253 differently than MSVC 10. It's hairy to decide which one to use. */
254# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS 254# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
diff --git a/gl/error.c b/gl/error.c
index 865b2934..6875f134 100644
--- a/gl/error.c
+++ b/gl/error.c
@@ -1,19 +1,19 @@
1/* Error handler for noninteractive utilities 1/* Error handler for noninteractive utilities
2 Copyright (C) 1990-1998, 2000-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1990-1998, 2000-2007, 2009-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ 18/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
19 19
@@ -39,6 +39,11 @@
39# include <stdint.h> 39# include <stdint.h>
40# include <wchar.h> 40# include <wchar.h>
41# define mbsrtowcs __mbsrtowcs 41# define mbsrtowcs __mbsrtowcs
42# define USE_UNLOCKED_IO 0
43# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b)
44# define _GL_ARG_NONNULL(a)
45#else
46# include "getprogname.h"
42#endif 47#endif
43 48
44#if USE_UNLOCKED_IO 49#if USE_UNLOCKED_IO
@@ -72,14 +77,14 @@ extern void __error (int status, int errnum, const char *message, ...)
72extern void __error_at_line (int status, int errnum, const char *file_name, 77extern void __error_at_line (int status, int errnum, const char *file_name,
73 unsigned int line_number, const char *message, 78 unsigned int line_number, const char *message,
74 ...) 79 ...)
75 __attribute__ ((__format__ (__printf__, 5, 6)));; 80 __attribute__ ((__format__ (__printf__, 5, 6)));
76# define error __error 81# define error __error
77# define error_at_line __error_at_line 82# define error_at_line __error_at_line
78 83
79# include <libio/iolibio.h> 84# include <libio/iolibio.h>
80# define fflush(s) INTUSE(_IO_fflush) (s) 85# define fflush(s) _IO_fflush (s)
81# undef putc 86# undef putc
82# define putc(c, fp) INTUSE(_IO_putc) (c, fp) 87# define putc(c, fp) _IO_putc (c, fp)
83 88
84# include <bits/libc-lock.h> 89# include <bits/libc-lock.h>
85 90
@@ -88,35 +93,37 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
88# include <fcntl.h> 93# include <fcntl.h>
89# include <unistd.h> 94# include <unistd.h>
90 95
91# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 96# if defined _WIN32 && ! defined __CYGWIN__
92/* Get declarations of the native Windows API functions. */ 97/* Get declarations of the native Windows API functions. */
93# define WIN32_LEAN_AND_MEAN 98# define WIN32_LEAN_AND_MEAN
94# include <windows.h> 99# include <windows.h>
95/* Get _get_osfhandle. */ 100/* Get _get_osfhandle. */
96# include "msvc-nothrow.h" 101# if GNULIB_MSVC_NOTHROW
102# include "msvc-nothrow.h"
103# else
104# include <io.h>
105# endif
97# endif 106# endif
98 107
99/* The gnulib override of fcntl is not needed in this file. */ 108/* The gnulib override of fcntl is not needed in this file. */
100# undef fcntl 109# undef fcntl
101 110
102# if !HAVE_DECL_STRERROR_R 111# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
103# ifndef HAVE_DECL_STRERROR_R 112# ifndef HAVE_DECL_STRERROR_R
104"this configure-time declaration test was not run" 113"this configure-time declaration test was not run"
105# endif 114# endif
106# if STRERROR_R_CHAR_P 115# if STRERROR_R_CHAR_P
107char *strerror_r (); 116char *strerror_r (int errnum, char *buf, size_t buflen);
108# else 117# else
109int strerror_r (); 118int strerror_r (int errnum, char *buf, size_t buflen);
110# endif 119# endif
111# endif 120# endif
112 121
113/* The calling program should define program_name and set it to the 122# define program_name getprogname ()
114 name of the executing program. */
115extern char *program_name;
116 123
117# if HAVE_STRERROR_R || defined strerror_r 124# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
118# define __strerror_r strerror_r 125# define __strerror_r strerror_r
119# endif /* HAVE_STRERROR_R || defined strerror_r */ 126# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
120#endif /* not _LIBC */ 127#endif /* not _LIBC */
121 128
122#if !_LIBC 129#if !_LIBC
@@ -124,7 +131,7 @@ extern char *program_name;
124static int 131static int
125is_open (int fd) 132is_open (int fd)
126{ 133{
127# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 134# if defined _WIN32 && ! defined __CYGWIN__
128 /* On native Windows: The initial state of unassigned standard file 135 /* On native Windows: The initial state of unassigned standard file
129 descriptors is that they are open but point to an INVALID_HANDLE_VALUE. 136 descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
130 There is no fcntl, and the gnulib replacement fcntl does not support 137 There is no fcntl, and the gnulib replacement fcntl does not support
@@ -169,9 +176,9 @@ print_errno_message (int errnum)
169{ 176{
170 char const *s; 177 char const *s;
171 178
172#if defined HAVE_STRERROR_R || _LIBC 179#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
173 char errbuf[1024]; 180 char errbuf[1024];
174# if STRERROR_R_CHAR_P || _LIBC 181# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
175 s = __strerror_r (errnum, errbuf, sizeof errbuf); 182 s = __strerror_r (errnum, errbuf, sizeof errbuf);
176# else 183# else
177 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) 184 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
@@ -195,13 +202,12 @@ print_errno_message (int errnum)
195#endif 202#endif
196} 203}
197 204
198static void 205static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))
199error_tail (int status, int errnum, const char *message, va_list args) 206error_tail (int status, int errnum, const char *message, va_list args)
200{ 207{
201#if _LIBC 208#if _LIBC
202 if (_IO_fwide (stderr, 0) > 0) 209 if (_IO_fwide (stderr, 0) > 0)
203 { 210 {
204# define ALLOCA_LIMIT 2000
205 size_t len = strlen (message) + 1; 211 size_t len = strlen (message) + 1;
206 wchar_t *wmessage = NULL; 212 wchar_t *wmessage = NULL;
207 mbstate_t st; 213 mbstate_t st;
@@ -237,7 +243,7 @@ error_tail (int status, int errnum, const char *message, va_list args)
237 if (res != len) 243 if (res != len)
238 break; 244 break;
239 245
240 if (__builtin_expect (len >= SIZE_MAX / 2, 0)) 246 if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
241 { 247 {
242 /* This really should not happen if everything is fine. */ 248 /* This really should not happen if everything is fine. */
243 res = (size_t) -1; 249 res = (size_t) -1;
@@ -266,7 +272,6 @@ error_tail (int status, int errnum, const char *message, va_list args)
266 else 272 else
267#endif 273#endif
268 vfprintf (stderr, message, args); 274 vfprintf (stderr, message, args);
269 va_end (args);
270 275
271 ++error_message_count; 276 ++error_message_count;
272 if (errnum) 277 if (errnum)
@@ -316,6 +321,7 @@ error (int status, int errnum, const char *message, ...)
316 321
317 va_start (args, message); 322 va_start (args, message);
318 error_tail (status, errnum, message, args); 323 error_tail (status, errnum, message, args);
324 va_end (args);
319 325
320#ifdef _LIBC 326#ifdef _LIBC
321 _IO_funlockfile (stderr); 327 _IO_funlockfile (stderr);
@@ -342,7 +348,10 @@ error_at_line (int status, int errnum, const char *file_name,
342 348
343 if (old_line_number == line_number 349 if (old_line_number == line_number
344 && (file_name == old_file_name 350 && (file_name == old_file_name
345 || strcmp (old_file_name, file_name) == 0)) 351 || (old_file_name != NULL
352 && file_name != NULL
353 && strcmp (old_file_name, file_name) == 0)))
354
346 /* Simply return and print nothing. */ 355 /* Simply return and print nothing. */
347 return; 356 return;
348 357
@@ -374,15 +383,16 @@ error_at_line (int status, int errnum, const char *file_name,
374 } 383 }
375 384
376#if _LIBC 385#if _LIBC
377 __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", 386 __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
378 file_name, line_number); 387 file_name, line_number);
379#else 388#else
380 fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", 389 fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
381 file_name, line_number); 390 file_name, line_number);
382#endif 391#endif
383 392
384 va_start (args, message); 393 va_start (args, message);
385 error_tail (status, errnum, message, args); 394 error_tail (status, errnum, message, args);
395 va_end (args);
386 396
387#ifdef _LIBC 397#ifdef _LIBC
388 _IO_funlockfile (stderr); 398 _IO_funlockfile (stderr);
diff --git a/gl/error.h b/gl/error.h
index afcb0e10..a240526a 100644
--- a/gl/error.h
+++ b/gl/error.h
@@ -1,35 +1,26 @@
1/* Declaration for error-reporting function 1/* Declaration for error-reporting function
2 Copyright (C) 1995-1997, 2003, 2006, 2008-2013 Free Software Foundation, 2 Copyright (C) 1995-1997, 2003, 2006, 2008-2023 Free Software Foundation,
3 Inc. 3 Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef _ERROR_H 19#ifndef _ERROR_H
20#define _ERROR_H 1 20#define _ERROR_H 1
21 21
22/* The __attribute__ feature is available in gcc versions 2.5 and later. 22/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */
23 The __-protected variants of the attributes 'format' and 'printf' are 23#include <stdio.h>
24 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
25 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
26 gnulib and libintl do '#define printf __printf__' when they override
27 the 'printf' function. */
28#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
29# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
30#else
31# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
32#endif
33 24
34#ifdef __cplusplus 25#ifdef __cplusplus
35extern "C" { 26extern "C" {
@@ -40,11 +31,21 @@ extern "C" {
40 If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ 31 If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
41 32
42extern void error (int __status, int __errnum, const char *__format, ...) 33extern void error (int __status, int __errnum, const char *__format, ...)
43 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); 34#if GNULIB_VFPRINTF_POSIX
35 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4))
36#else
37 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 3, 4))
38#endif
39 ;
44 40
45extern void error_at_line (int __status, int __errnum, const char *__fname, 41extern void error_at_line (int __status, int __errnum, const char *__fname,
46 unsigned int __lineno, const char *__format, ...) 42 unsigned int __lineno, const char *__format, ...)
47 _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6)); 43#if GNULIB_VFPRINTF_POSIX
44 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 6))
45#else
46 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 5, 6))
47#endif
48 ;
48 49
49/* If NULL, error will flush stdout, then print on stderr the program 50/* If NULL, error will flush stdout, then print on stderr the program
50 name, a colon and a space. Otherwise, error will call this 51 name, a colon and a space. Otherwise, error will call this
diff --git a/gl/exitfail.c b/gl/exitfail.c
index b0b4ebe4..d67a130c 100644
--- a/gl/exitfail.c
+++ b/gl/exitfail.c
@@ -1,19 +1,19 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/exitfail.h b/gl/exitfail.h
index e54333bd..85a6af64 100644
--- a/gl/exitfail.h
+++ b/gl/exitfail.h
@@ -1,18 +1,18 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18extern int volatile exit_failure; 18extern int volatile exit_failure;
diff --git a/gl/fcntl.c b/gl/fcntl.c
new file mode 100644
index 00000000..e2208008
--- /dev/null
+++ b/gl/fcntl.c
@@ -0,0 +1,629 @@
1/* Provide file descriptor control.
2
3 Copyright (C) 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Eric Blake <ebb9@byu.net>. */
19
20#include <config.h>
21
22/* Specification. */
23#include <fcntl.h>
24
25#include <errno.h>
26#include <limits.h>
27#include <stdarg.h>
28#include <stdlib.h>
29#include <unistd.h>
30
31#ifdef __KLIBC__
32# define INCL_DOS
33# include <os2.h>
34#endif
35
36#if defined _WIN32 && ! defined __CYGWIN__
37/* Get declarations of the native Windows API functions. */
38# define WIN32_LEAN_AND_MEAN
39# include <windows.h>
40
41/* Get _get_osfhandle. */
42# if GNULIB_MSVC_NOTHROW
43# include "msvc-nothrow.h"
44# else
45# include <io.h>
46# endif
47
48/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
49# define OPEN_MAX_MAX 0x10000
50
51/* Duplicate OLDFD into the first available slot of at least NEWFD,
52 which must be positive, with FLAGS determining whether the duplicate
53 will be inheritable. */
54static int
55dupfd (int oldfd, int newfd, int flags)
56{
57 /* Mingw has no way to create an arbitrary fd. Iterate until all
58 file descriptors less than newfd are filled up. */
59 HANDLE curr_process = GetCurrentProcess ();
60 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
61 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
62 unsigned int fds_to_close_bound = 0;
63 int result;
64 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
65 int mode;
66
67 if (newfd < 0 || getdtablesize () <= newfd)
68 {
69 errno = EINVAL;
70 return -1;
71 }
72 if (old_handle == INVALID_HANDLE_VALUE
73 || (mode = _setmode (oldfd, O_BINARY)) == -1)
74 {
75 /* oldfd is not open, or is an unassigned standard file
76 descriptor. */
77 errno = EBADF;
78 return -1;
79 }
80 _setmode (oldfd, mode);
81 flags |= mode;
82
83 for (;;)
84 {
85 HANDLE new_handle;
86 int duplicated_fd;
87 unsigned int index;
88
89 if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
90 old_handle, /* SourceHandle */
91 curr_process, /* TargetProcessHandle */
92 (PHANDLE) &new_handle, /* TargetHandle */
93 (DWORD) 0, /* DesiredAccess */
94 inherit, /* InheritHandle */
95 DUPLICATE_SAME_ACCESS)) /* Options */
96 {
97 switch (GetLastError ())
98 {
99 case ERROR_TOO_MANY_OPEN_FILES:
100 errno = EMFILE;
101 break;
102 case ERROR_INVALID_HANDLE:
103 case ERROR_INVALID_TARGET_HANDLE:
104 case ERROR_DIRECT_ACCESS_HANDLE:
105 errno = EBADF;
106 break;
107 case ERROR_INVALID_PARAMETER:
108 case ERROR_INVALID_FUNCTION:
109 case ERROR_INVALID_ACCESS:
110 errno = EINVAL;
111 break;
112 default:
113 errno = EACCES;
114 break;
115 }
116 result = -1;
117 break;
118 }
119 duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
120 if (duplicated_fd < 0)
121 {
122 CloseHandle (new_handle);
123 result = -1;
124 break;
125 }
126 if (newfd <= duplicated_fd)
127 {
128 result = duplicated_fd;
129 break;
130 }
131
132 /* Set the bit duplicated_fd in fds_to_close[]. */
133 index = (unsigned int) duplicated_fd / CHAR_BIT;
134 if (fds_to_close_bound <= index)
135 {
136 if (sizeof fds_to_close <= index)
137 /* Need to increase OPEN_MAX_MAX. */
138 abort ();
139 memset (fds_to_close + fds_to_close_bound, '\0',
140 index + 1 - fds_to_close_bound);
141 fds_to_close_bound = index + 1;
142 }
143 fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
144 }
145
146 /* Close the previous fds that turned out to be too small. */
147 {
148 int saved_errno = errno;
149 unsigned int duplicated_fd;
150
151 for (duplicated_fd = 0;
152 duplicated_fd < fds_to_close_bound * CHAR_BIT;
153 duplicated_fd++)
154 if ((fds_to_close[duplicated_fd / CHAR_BIT]
155 >> (duplicated_fd % CHAR_BIT))
156 & 1)
157 close (duplicated_fd);
158
159 errno = saved_errno;
160 }
161
162# if REPLACE_FCHDIR
163 if (0 <= result)
164 result = _gl_register_dup (oldfd, result);
165# endif
166 return result;
167}
168#endif /* W32 */
169
170/* Forward declarations, because we '#undef fcntl' in the middle of this
171 compilation unit. */
172/* Our implementation of fcntl (fd, F_DUPFD, target). */
173static int rpl_fcntl_DUPFD (int fd, int target);
174/* Our implementation of fcntl (fd, F_DUPFD_CLOEXEC, target). */
175static int rpl_fcntl_DUPFD_CLOEXEC (int fd, int target);
176#ifdef __KLIBC__
177/* Adds support for fcntl on directories. */
178static int klibc_fcntl (int fd, int action, /* arg */...);
179#endif
180
181
182/* Perform the specified ACTION on the file descriptor FD, possibly
183 using the argument ARG further described below. This replacement
184 handles the following actions, and forwards all others on to the
185 native fcntl. An unrecognized ACTION returns -1 with errno set to
186 EINVAL.
187
188 F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
189 If successful, return the duplicate, which will be inheritable;
190 otherwise return -1 and set errno.
191
192 F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
193 target fd. If successful, return the duplicate, which will not be
194 inheritable; otherwise return -1 and set errno.
195
196 F_GETFD - ARG need not be present. If successful, return a
197 non-negative value containing the descriptor flags of FD (only
198 FD_CLOEXEC is portable, but other flags may be present); otherwise
199 return -1 and set errno. */
200
201int
202fcntl (int fd, int action, /* arg */...)
203#undef fcntl
204#ifdef __KLIBC__
205# define fcntl klibc_fcntl
206#endif
207{
208 va_list arg;
209 int result = -1;
210 va_start (arg, action);
211 switch (action)
212 {
213 case F_DUPFD:
214 {
215 int target = va_arg (arg, int);
216 result = rpl_fcntl_DUPFD (fd, target);
217 break;
218 }
219
220 case F_DUPFD_CLOEXEC:
221 {
222 int target = va_arg (arg, int);
223 result = rpl_fcntl_DUPFD_CLOEXEC (fd, target);
224 break;
225 }
226
227#if !HAVE_FCNTL
228 case F_GETFD:
229 {
230# if defined _WIN32 && ! defined __CYGWIN__
231 HANDLE handle = (HANDLE) _get_osfhandle (fd);
232 DWORD flags;
233 if (handle == INVALID_HANDLE_VALUE
234 || GetHandleInformation (handle, &flags) == 0)
235 errno = EBADF;
236 else
237 result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
238# else /* !W32 */
239 /* Use dup2 to reject invalid file descriptors. No way to
240 access this information, so punt. */
241 if (0 <= dup2 (fd, fd))
242 result = 0;
243# endif /* !W32 */
244 break;
245 } /* F_GETFD */
246#endif /* !HAVE_FCNTL */
247
248 /* Implementing F_SETFD on mingw is not trivial - there is no
249 API for changing the O_NOINHERIT bit on an fd, and merely
250 changing the HANDLE_FLAG_INHERIT bit on the underlying handle
251 can lead to odd state. It may be possible by duplicating the
252 handle, using _open_osfhandle with the right flags, then
253 using dup2 to move the duplicate onto the original, but that
254 is not supported for now. */
255
256 default:
257 {
258#if HAVE_FCNTL
259 switch (action)
260 {
261 #ifdef F_BARRIERFSYNC /* macOS */
262 case F_BARRIERFSYNC:
263 #endif
264 #ifdef F_CHKCLEAN /* macOS */
265 case F_CHKCLEAN:
266 #endif
267 #ifdef F_CLOSEM /* NetBSD, HP-UX */
268 case F_CLOSEM:
269 #endif
270 #ifdef F_FLUSH_DATA /* macOS */
271 case F_FLUSH_DATA:
272 #endif
273 #ifdef F_FREEZE_FS /* macOS */
274 case F_FREEZE_FS:
275 #endif
276 #ifdef F_FULLFSYNC /* macOS */
277 case F_FULLFSYNC:
278 #endif
279 #ifdef F_GETCONFINED /* macOS */
280 case F_GETCONFINED:
281 #endif
282 #ifdef F_GETDEFAULTPROTLEVEL /* macOS */
283 case F_GETDEFAULTPROTLEVEL:
284 #endif
285 #ifdef F_GETFD /* POSIX */
286 case F_GETFD:
287 #endif
288 #ifdef F_GETFL /* POSIX */
289 case F_GETFL:
290 #endif
291 #ifdef F_GETLEASE /* Linux */
292 case F_GETLEASE:
293 #endif
294 #ifdef F_GETNOSIGPIPE /* macOS */
295 case F_GETNOSIGPIPE:
296 #endif
297 #ifdef F_GETOWN /* POSIX */
298 case F_GETOWN:
299 #endif
300 #ifdef F_GETPIPE_SZ /* Linux */
301 case F_GETPIPE_SZ:
302 #endif
303 #ifdef F_GETPROTECTIONCLASS /* macOS */
304 case F_GETPROTECTIONCLASS:
305 #endif
306 #ifdef F_GETPROTECTIONLEVEL /* macOS */
307 case F_GETPROTECTIONLEVEL:
308 #endif
309 #ifdef F_GET_SEALS /* Linux */
310 case F_GET_SEALS:
311 #endif
312 #ifdef F_GETSIG /* Linux */
313 case F_GETSIG:
314 #endif
315 #ifdef F_MAXFD /* NetBSD */
316 case F_MAXFD:
317 #endif
318 #ifdef F_RECYCLE /* macOS */
319 case F_RECYCLE:
320 #endif
321 #ifdef F_SETFIFOENH /* HP-UX */
322 case F_SETFIFOENH:
323 #endif
324 #ifdef F_THAW_FS /* macOS */
325 case F_THAW_FS:
326 #endif
327 /* These actions take no argument. */
328 result = fcntl (fd, action);
329 break;
330
331 #ifdef F_ADD_SEALS /* Linux */
332 case F_ADD_SEALS:
333 #endif
334 #ifdef F_BADFD /* Solaris */
335 case F_BADFD:
336 #endif
337 #ifdef F_CHECK_OPENEVT /* macOS */
338 case F_CHECK_OPENEVT:
339 #endif
340 #ifdef F_DUP2FD /* FreeBSD, AIX, Solaris */
341 case F_DUP2FD:
342 #endif
343 #ifdef F_DUP2FD_CLOEXEC /* FreeBSD, Solaris */
344 case F_DUP2FD_CLOEXEC:
345 #endif
346 #ifdef F_DUP2FD_CLOFORK /* Solaris */
347 case F_DUP2FD_CLOFORK:
348 #endif
349 #ifdef F_DUPFD /* POSIX */
350 case F_DUPFD:
351 #endif
352 #ifdef F_DUPFD_CLOEXEC /* POSIX */
353 case F_DUPFD_CLOEXEC:
354 #endif
355 #ifdef F_DUPFD_CLOFORK /* Solaris */
356 case F_DUPFD_CLOFORK:
357 #endif
358 #ifdef F_GETXFL /* Solaris */
359 case F_GETXFL:
360 #endif
361 #ifdef F_GLOBAL_NOCACHE /* macOS */
362 case F_GLOBAL_NOCACHE:
363 #endif
364 #ifdef F_MAKECOMPRESSED /* macOS */
365 case F_MAKECOMPRESSED:
366 #endif
367 #ifdef F_MOVEDATAEXTENTS /* macOS */
368 case F_MOVEDATAEXTENTS:
369 #endif
370 #ifdef F_NOCACHE /* macOS */
371 case F_NOCACHE:
372 #endif
373 #ifdef F_NODIRECT /* macOS */
374 case F_NODIRECT:
375 #endif
376 #ifdef F_NOTIFY /* Linux */
377 case F_NOTIFY:
378 #endif
379 #ifdef F_OPLKACK /* IRIX */
380 case F_OPLKACK:
381 #endif
382 #ifdef F_OPLKREG /* IRIX */
383 case F_OPLKREG:
384 #endif
385 #ifdef F_RDAHEAD /* macOS */
386 case F_RDAHEAD:
387 #endif
388 #ifdef F_SETBACKINGSTORE /* macOS */
389 case F_SETBACKINGSTORE:
390 #endif
391 #ifdef F_SETCONFINED /* macOS */
392 case F_SETCONFINED:
393 #endif
394 #ifdef F_SETFD /* POSIX */
395 case F_SETFD:
396 #endif
397 #ifdef F_SETFL /* POSIX */
398 case F_SETFL:
399 #endif
400 #ifdef F_SETLEASE /* Linux */
401 case F_SETLEASE:
402 #endif
403 #ifdef F_SETNOSIGPIPE /* macOS */
404 case F_SETNOSIGPIPE:
405 #endif
406 #ifdef F_SETOWN /* POSIX */
407 case F_SETOWN:
408 #endif
409 #ifdef F_SETPIPE_SZ /* Linux */
410 case F_SETPIPE_SZ:
411 #endif
412 #ifdef F_SETPROTECTIONCLASS /* macOS */
413 case F_SETPROTECTIONCLASS:
414 #endif
415 #ifdef F_SETSIG /* Linux */
416 case F_SETSIG:
417 #endif
418 #ifdef F_SINGLE_WRITER /* macOS */
419 case F_SINGLE_WRITER:
420 #endif
421 /* These actions take an 'int' argument. */
422 {
423 int x = va_arg (arg, int);
424 result = fcntl (fd, action, x);
425 }
426 break;
427
428 default:
429 /* Other actions take a pointer argument. */
430 {
431 void *p = va_arg (arg, void *);
432 result = fcntl (fd, action, p);
433 }
434 break;
435 }
436#else
437 errno = EINVAL;
438#endif
439 break;
440 }
441 }
442 va_end (arg);
443 return result;
444}
445
446static int
447rpl_fcntl_DUPFD (int fd, int target)
448{
449 int result;
450#if !HAVE_FCNTL
451 result = dupfd (fd, target, 0);
452#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
453 /* Detect invalid target; needed for cygwin 1.5.x. */
454 if (target < 0 || getdtablesize () <= target)
455 {
456 result = -1;
457 errno = EINVAL;
458 }
459 else
460 {
461 /* Haiku alpha 2 loses fd flags on original. */
462 int flags = fcntl (fd, F_GETFD);
463 if (flags < 0)
464 result = -1;
465 else
466 {
467 result = fcntl (fd, F_DUPFD, target);
468 if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
469 {
470 int saved_errno = errno;
471 close (result);
472 result = -1;
473 errno = saved_errno;
474 }
475# if REPLACE_FCHDIR
476 if (0 <= result)
477 result = _gl_register_dup (fd, result);
478# endif
479 }
480 }
481#else
482 result = fcntl (fd, F_DUPFD, target);
483#endif
484 return result;
485}
486
487static int
488rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
489{
490 int result;
491#if !HAVE_FCNTL
492 result = dupfd (fd, target, O_CLOEXEC);
493#else /* HAVE_FCNTL */
494# if defined __NetBSD__ || defined __HAIKU__
495 /* On NetBSD 9.0, the system fcntl (fd, F_DUPFD_CLOEXEC, target)
496 has only the same effect as fcntl (fd, F_DUPFD, target). */
497 /* On Haiku, the system fcntl (fd, F_DUPFD_CLOEXEC, target) sets
498 the FD_CLOEXEC flag on fd, not on target. Therefore avoid the
499 system fcntl in this case. */
500# define have_dupfd_cloexec -1
501# else
502 /* Try the system call first, if the headers claim it exists
503 (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
504 may be running with a glibc that has the macro but with an
505 older kernel that does not support it. Cache the
506 information on whether the system call really works, but
507 avoid caching failure if the corresponding F_DUPFD fails
508 for any reason. 0 = unknown, 1 = yes, -1 = no. */
509 static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
510 if (0 <= have_dupfd_cloexec)
511 {
512 result = fcntl (fd, F_DUPFD_CLOEXEC, target);
513 if (0 <= result || errno != EINVAL)
514 {
515 have_dupfd_cloexec = 1;
516# if REPLACE_FCHDIR
517 if (0 <= result)
518 result = _gl_register_dup (fd, result);
519# endif
520 }
521 else
522 {
523 result = rpl_fcntl_DUPFD (fd, target);
524 if (result >= 0)
525 have_dupfd_cloexec = -1;
526 }
527 }
528 else
529# endif
530 result = rpl_fcntl_DUPFD (fd, target);
531 if (0 <= result && have_dupfd_cloexec == -1)
532 {
533 int flags = fcntl (result, F_GETFD);
534 if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
535 {
536 int saved_errno = errno;
537 close (result);
538 errno = saved_errno;
539 result = -1;
540 }
541 }
542#endif /* HAVE_FCNTL */
543 return result;
544}
545
546#undef fcntl
547
548#ifdef __KLIBC__
549
550static int
551klibc_fcntl (int fd, int action, /* arg */...)
552{
553 va_list arg_ptr;
554 int arg;
555 struct stat sbuf;
556 int result;
557
558 va_start (arg_ptr, action);
559 arg = va_arg (arg_ptr, int);
560 result = fcntl (fd, action, arg);
561 /* EPERM for F_DUPFD, ENOTSUP for others */
562 if (result == -1 && (errno == EPERM || errno == ENOTSUP)
563 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
564 {
565 ULONG ulMode;
566
567 switch (action)
568 {
569 case F_DUPFD:
570 /* Find available fd */
571 while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
572 arg++;
573
574 result = dup2 (fd, arg);
575 break;
576
577 /* Using underlying APIs is right ? */
578 case F_GETFD:
579 if (DosQueryFHState (fd, &ulMode))
580 break;
581
582 result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
583 break;
584
585 case F_SETFD:
586 if (arg & ~FD_CLOEXEC)
587 break;
588
589 if (DosQueryFHState (fd, &ulMode))
590 break;
591
592 if (arg & FD_CLOEXEC)
593 ulMode |= OPEN_FLAGS_NOINHERIT;
594 else
595 ulMode &= ~OPEN_FLAGS_NOINHERIT;
596
597 /* Filter supported flags. */
598 ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
599 | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
600
601 if (DosSetFHState (fd, ulMode))
602 break;
603
604 result = 0;
605 break;
606
607 case F_GETFL:
608 result = 0;
609 break;
610
611 case F_SETFL:
612 if (arg != 0)
613 break;
614
615 result = 0;
616 break;
617
618 default:
619 errno = EINVAL;
620 break;
621 }
622 }
623
624 va_end (arg_ptr);
625
626 return result;
627}
628
629#endif
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h
new file mode 100644
index 00000000..e034eaf9
--- /dev/null
+++ b/gl/fcntl.in.h
@@ -0,0 +1,445 @@
1/* Like <fcntl.h>, but with non-working flags defined to 0.
2
3 Copyright (C) 2006-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Paul Eggert */
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23@PRAGMA_COLUMNS@
24
25#if defined __need_system_fcntl_h
26/* Special invocation convention. */
27
28/* Needed before <sys/stat.h>.
29 May also define off_t to a 64-bit type on native Windows. */
30#include <sys/types.h>
31/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
32 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
33 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
34 extern "C" { ... } block, which leads to errors in C++ mode with the
35 overridden <sys/stat.h> from gnulib. These errors are known to be gone
36 with g++ version >= 4.3. */
37#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
38# include <sys/stat.h>
39#endif
40#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
41
42/* Native Windows platforms declare open(), creat() in <io.h>. */
43#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
44 && (defined _WIN32 && ! defined __CYGWIN__)
45# include <io.h>
46#endif
47
48#else
49/* Normal invocation convention. */
50
51#ifndef _@GUARD_PREFIX@_FCNTL_H
52
53/* Needed before <sys/stat.h>.
54 May also define off_t to a 64-bit type on native Windows. */
55#include <sys/types.h>
56/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
57 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
58 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
59 extern "C" { ... } block, which leads to errors in C++ mode with the
60 overridden <sys/stat.h> from gnulib. These errors are known to be gone
61 with g++ version >= 4.3. */
62#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
63# include <sys/stat.h>
64#endif
65/* The include_next requires a split double-inclusion guard. */
66#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
67
68/* Native Windows platforms declare open(), creat() in <io.h>. */
69#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
70 && (defined _WIN32 && ! defined __CYGWIN__)
71# include <io.h>
72#endif
73
74#ifndef _@GUARD_PREFIX@_FCNTL_H
75#define _@GUARD_PREFIX@_FCNTL_H
76
77#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
78# include <unistd.h>
79#endif
80
81
82/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
83
84/* The definition of _GL_ARG_NONNULL is copied here. */
85
86/* The definition of _GL_WARN_ON_USE is copied here. */
87
88
89/* Declare overridden functions. */
90
91#if @GNULIB_CREAT@
92# if @REPLACE_CREAT@
93# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
94# undef creat
95# define creat rpl_creat
96# endif
97_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
98 _GL_ARG_NONNULL ((1)));
99_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
100# elif defined _WIN32 && !defined __CYGWIN__
101# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
102# undef creat
103# define creat _creat
104# endif
105_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode));
106# else
107_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
108# endif
109_GL_CXXALIASWARN (creat);
110#elif defined GNULIB_POSIXCHECK
111# undef creat
112/* Assume creat is always declared. */
113_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
114 "use gnulib module creat for portability");
115#elif @GNULIB_MDA_CREAT@
116/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
117 required. In C++ with GNULIB_NAMESPACE, avoid differences between
118 platforms by defining GNULIB_NAMESPACE::creat always. */
119# if defined _WIN32 && !defined __CYGWIN__
120# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
121# undef creat
122# define creat _creat
123# endif
124/* Need to cast, because in mingw the last argument is 'int mode'. */
125_GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode));
126# else
127_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
128# endif
129_GL_CXXALIASWARN (creat);
130#endif
131
132#if @GNULIB_FCNTL@
133# if @REPLACE_FCNTL@
134# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
135# undef fcntl
136# define fcntl rpl_fcntl
137# endif
138_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
139_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
140# if !GNULIB_defined_rpl_fcntl
141# define GNULIB_defined_rpl_fcntl 1
142# endif
143# else
144# if !@HAVE_FCNTL@
145_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
146# if !GNULIB_defined_fcntl
147# define GNULIB_defined_fcntl 1
148# endif
149# endif
150_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
151# endif
152_GL_CXXALIASWARN (fcntl);
153#elif defined GNULIB_POSIXCHECK
154# undef fcntl
155# if HAVE_RAW_DECL_FCNTL
156_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
157 "use gnulib module fcntl for portability");
158# endif
159#endif
160
161#if @GNULIB_OPEN@
162# if @REPLACE_OPEN@
163# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
164# undef open
165# define open rpl_open
166# endif
167_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
168 _GL_ARG_NONNULL ((1)));
169_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
170# elif defined _WIN32 && !defined __CYGWIN__
171# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
172# undef open
173# define open _open
174# endif
175_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
176# else
177_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
178# endif
179/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
180 default argument. _GL_CXXALIASWARN does not work in this case. */
181# if !defined __hpux
182_GL_CXXALIASWARN (open);
183# endif
184#elif defined GNULIB_POSIXCHECK
185# undef open
186/* Assume open is always declared. */
187_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
188 "use gnulib module open for portability");
189#elif @GNULIB_MDA_OPEN@
190/* On native Windows, map 'open' to '_open', so that -loldnames is not
191 required. In C++ with GNULIB_NAMESPACE, avoid differences between
192 platforms by defining GNULIB_NAMESPACE::open always. */
193# if defined _WIN32 && !defined __CYGWIN__
194# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
195# undef open
196# define open _open
197# endif
198_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
199# else
200_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
201# endif
202# if !defined __hpux
203_GL_CXXALIASWARN (open);
204# endif
205#endif
206
207#if @GNULIB_OPENAT@
208# if @REPLACE_OPENAT@
209# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
210# undef openat
211# define openat rpl_openat
212# endif
213_GL_FUNCDECL_RPL (openat, int,
214 (int fd, char const *file, int flags, /* mode_t mode */ ...)
215 _GL_ARG_NONNULL ((2)));
216_GL_CXXALIAS_RPL (openat, int,
217 (int fd, char const *file, int flags, /* mode_t mode */ ...));
218# else
219# if !@HAVE_OPENAT@
220_GL_FUNCDECL_SYS (openat, int,
221 (int fd, char const *file, int flags, /* mode_t mode */ ...)
222 _GL_ARG_NONNULL ((2)));
223# endif
224_GL_CXXALIAS_SYS (openat, int,
225 (int fd, char const *file, int flags, /* mode_t mode */ ...));
226# endif
227_GL_CXXALIASWARN (openat);
228#elif defined GNULIB_POSIXCHECK
229# undef openat
230# if HAVE_RAW_DECL_OPENAT
231_GL_WARN_ON_USE (openat, "openat is not portable - "
232 "use gnulib module openat for portability");
233# endif
234#endif
235
236
237/* Fix up the FD_* macros, only known to be missing on mingw. */
238
239#ifndef FD_CLOEXEC
240# define FD_CLOEXEC 1
241#endif
242
243/* Fix up the supported F_* macros. Intentionally leave other F_*
244 macros undefined. Only known to be missing on mingw. */
245
246#ifndef F_DUPFD_CLOEXEC
247# define F_DUPFD_CLOEXEC 0x40000000
248/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
249# define GNULIB_defined_F_DUPFD_CLOEXEC 1
250#else
251# define GNULIB_defined_F_DUPFD_CLOEXEC 0
252#endif
253
254#ifndef F_DUPFD
255# define F_DUPFD 1
256#endif
257
258#ifndef F_GETFD
259# define F_GETFD 2
260#endif
261
262/* Fix up the O_* macros. */
263
264/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
265 to values outside 'int' range, so omit these misdefinitions.
266 But avoid namespace pollution on non-AIX systems. */
267#ifdef _AIX
268# include <limits.h>
269# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
270# undef O_CLOEXEC
271# endif
272# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
273# undef O_NOFOLLOW
274# endif
275# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
276# undef O_TTY_INIT
277# endif
278#endif
279
280#if !defined O_DIRECT && defined O_DIRECTIO
281/* Tru64 spells it 'O_DIRECTIO'. */
282# define O_DIRECT O_DIRECTIO
283#endif
284
285#if !defined O_CLOEXEC && defined O_NOINHERIT
286/* Mingw spells it 'O_NOINHERIT'. */
287# define O_CLOEXEC O_NOINHERIT
288#endif
289
290#ifndef O_CLOEXEC
291# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
292# define GNULIB_defined_O_CLOEXEC 1
293#else
294# define GNULIB_defined_O_CLOEXEC 0
295#endif
296
297#ifndef O_DIRECT
298# define O_DIRECT 0
299#endif
300
301#ifndef O_DIRECTORY
302# define O_DIRECTORY 0
303#endif
304
305#ifndef O_DSYNC
306# define O_DSYNC 0
307#endif
308
309#ifndef O_EXEC
310# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
311#endif
312
313#ifndef O_IGNORE_CTTY
314# define O_IGNORE_CTTY 0
315#endif
316
317#ifndef O_NDELAY
318# define O_NDELAY 0
319#endif
320
321#ifndef O_NOATIME
322# define O_NOATIME 0
323#endif
324
325#ifndef O_NONBLOCK
326# define O_NONBLOCK O_NDELAY
327#endif
328
329/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
330 value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
331 or to 0 as fallback. */
332#if @GNULIB_NONBLOCKING@
333# if O_NONBLOCK
334# define GNULIB_defined_O_NONBLOCK 0
335# else
336# define GNULIB_defined_O_NONBLOCK 1
337# undef O_NONBLOCK
338# define O_NONBLOCK 0x40000000
339# endif
340#endif
341
342#ifndef O_NOCTTY
343# define O_NOCTTY 0
344#endif
345
346#ifndef O_NOFOLLOW
347# define O_NOFOLLOW 0
348#endif
349
350#ifndef O_NOLINK
351# define O_NOLINK 0
352#endif
353
354#ifndef O_NOLINKS
355# define O_NOLINKS 0
356#endif
357
358#ifndef O_NOTRANS
359# define O_NOTRANS 0
360#endif
361
362#ifndef O_RSYNC
363# define O_RSYNC 0
364#endif
365
366#ifndef O_SEARCH
367# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
368#endif
369
370#ifndef O_SYNC
371# define O_SYNC 0
372#endif
373
374#ifndef O_TTY_INIT
375# define O_TTY_INIT 0
376#endif
377
378#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
379# undef O_ACCMODE
380# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
381#endif
382
383/* For systems that distinguish between text and binary I/O.
384 O_BINARY is usually declared in fcntl.h */
385#if !defined O_BINARY && defined _O_BINARY
386 /* For MSC-compatible compilers. */
387# define O_BINARY _O_BINARY
388# define O_TEXT _O_TEXT
389#endif
390
391#if defined __BEOS__ || defined __HAIKU__
392 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
393# undef O_BINARY
394# undef O_TEXT
395#endif
396
397#ifndef O_BINARY
398# define O_BINARY 0
399# define O_TEXT 0
400#endif
401
402/* Fix up the AT_* macros. */
403
404/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
405 value exceeds INT_MAX, so its use as an int doesn't conform to the
406 C standard, and GCC and Sun C complain in some cases. If the bug
407 is present, undef AT_FDCWD here, so it can be redefined below. */
408#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
409# undef AT_FDCWD
410#endif
411
412/* Use the same bit pattern as Solaris 9, but with the proper
413 signedness. The bit pattern is important, in case this actually is
414 Solaris with the above workaround. */
415#ifndef AT_FDCWD
416# define AT_FDCWD (-3041965)
417#endif
418
419/* Use the same values as Solaris 9. This shouldn't matter, but
420 there's no real reason to differ. */
421#ifndef AT_SYMLINK_NOFOLLOW
422# define AT_SYMLINK_NOFOLLOW 4096
423#endif
424
425#ifndef AT_REMOVEDIR
426# define AT_REMOVEDIR 1
427#endif
428
429/* Solaris 9 lacks these two, so just pick unique values. */
430#ifndef AT_SYMLINK_FOLLOW
431# define AT_SYMLINK_FOLLOW 2
432#endif
433
434#ifndef AT_EACCESS
435# define AT_EACCESS 4
436#endif
437
438/* Ignore this flag if not supported. */
439#ifndef AT_NO_AUTOMOUNT
440# define AT_NO_AUTOMOUNT 0
441#endif
442
443#endif /* _@GUARD_PREFIX@_FCNTL_H */
444#endif /* _@GUARD_PREFIX@_FCNTL_H */
445#endif
diff --git a/gl/fd-hook.c b/gl/fd-hook.c
index e158a52a..36261150 100644
--- a/gl/fd-hook.c
+++ b/gl/fd-hook.c
@@ -1,19 +1,19 @@
1/* Hook for making making file descriptor functions close(), ioctl() extensible. 1/* Hook for making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009. 3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4 4
5 This program is free software: you can redistribute it and/or modify it 5 This file is free software: you can redistribute it and/or modify
6 under the terms of the GNU General Public License as published 6 it under the terms of the GNU Lesser General Public License as
7 by the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/fd-hook.h b/gl/fd-hook.h
index d15b5771..6bf3c24d 100644
--- a/gl/fd-hook.h
+++ b/gl/fd-hook.h
@@ -1,18 +1,18 @@
1/* Hook for making making file descriptor functions close(), ioctl() extensible. 1/* Hook for making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This file is free software: you can redistribute it and/or modify
5 under the terms of the GNU General Public License as published 5 it under the terms of the GNU Lesser General Public License as
6 by the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17 17
18#ifndef FD_HOOK_H 18#ifndef FD_HOOK_H
diff --git a/gl/fflush.c b/gl/fflush.c
new file mode 100644
index 00000000..f3689b3e
--- /dev/null
+++ b/gl/fflush.c
@@ -0,0 +1,233 @@
1/* fflush.c -- allow flushing input streams
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Eric Blake. */
18
19#include <config.h>
20
21/* Specification. */
22#include <stdio.h>
23
24#include <errno.h>
25#include <unistd.h>
26
27#include "freading.h"
28
29#include "stdio-impl.h"
30
31#undef fflush
32
33
34#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35/* GNU libc, BeOS, Haiku, Linux libc5 */
36
37/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
38static void
39clear_ungetc_buffer_preserving_position (FILE *fp)
40{
41 if (fp->_flags & _IO_IN_BACKUP)
42 /* _IO_free_backup_area is a bit complicated. Simply call fseek. */
43 fseeko (fp, 0, SEEK_CUR);
44}
45
46#else
47
48/* Clear the stream's ungetc buffer. May modify the value of ftello (fp). */
49static void
50clear_ungetc_buffer (FILE *fp)
51{
52# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
53 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
54 if (HASUB (fp))
55 {
56 fp_->_p += fp_->_r;
57 fp_->_r = 0;
58 }
59# elif defined __EMX__ /* emx+gcc */
60 if (fp->_ungetc_count > 0)
61 {
62 fp->_ungetc_count = 0;
63 fp->_rcount = - fp->_rcount;
64 }
65# elif defined _IOERR /* Minix, AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
66 /* Nothing to do. */
67# else /* other implementations */
68 fseeko (fp, 0, SEEK_CUR);
69# endif
70}
71
72#endif
73
74#if ! (defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1)
75/* GNU libc, BeOS, Haiku, Linux libc5 */
76
77# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
78/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
79
80static int
81disable_seek_optimization (FILE *fp)
82{
83 int saved_flags = fp_->_flags & (__SOPT | __SNPT);
84 fp_->_flags = (fp_->_flags & ~__SOPT) | __SNPT;
85 return saved_flags;
86}
87
88static void
89restore_seek_optimization (FILE *fp, int saved_flags)
90{
91 fp_->_flags = (fp_->_flags & ~(__SOPT | __SNPT)) | saved_flags;
92}
93
94# else
95
96static void
97update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
98 _GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
99{
100# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
101 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
102# if defined __CYGWIN__ || defined __ANDROID__
103 /* fp_->_offset is typed as an integer. */
104 fp_->_offset = pos;
105# else
106 /* fp_->_offset is an fpos_t. */
107 /* Use a union, since on NetBSD, the compilation flags determine
108 whether fpos_t is typedef'd to off_t or a struct containing a
109 single off_t member. */
110 union
111 {
112 fpos_t f;
113 off_t o;
114 } u;
115 u.o = pos;
116 fp_->_offset = u.f;
117# endif
118 fp_->_flags |= __SOFF;
119# endif
120}
121# endif
122#endif
123
124/* Flush all pending data on STREAM according to POSIX rules. Both
125 output and seekable input streams are supported. */
126int
127rpl_fflush (FILE *stream)
128{
129 /* When stream is NULL, POSIX and C99 only require flushing of "output
130 streams and update streams in which the most recent operation was not
131 input", and all implementations do this.
132
133 When stream is "an output stream or an update stream in which the most
134 recent operation was not input", POSIX and C99 requires that fflush
135 writes out any buffered data, and all implementations do this.
136
137 When stream is, however, an input stream or an update stream in
138 which the most recent operation was input, C99 specifies nothing,
139 and POSIX only specifies behavior if the stream is seekable.
140 mingw, in particular, drops the input buffer, leaving the file
141 descriptor positioned at the end of the input buffer. I.e. ftell
142 (stream) is lost. We don't want to call the implementation's
143 fflush in this case.
144
145 We test ! freading (stream) here, rather than fwriting (stream), because
146 what we need to know is whether the stream holds a "read buffer", and on
147 mingw this is indicated by _IOREAD, regardless of _IOWRT. */
148 if (stream == NULL || ! freading (stream))
149 return fflush (stream);
150
151#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
152 /* GNU libc, BeOS, Haiku, Linux libc5 */
153
154 clear_ungetc_buffer_preserving_position (stream);
155
156 return fflush (stream);
157
158#else
159 {
160 /* What POSIX says:
161 1) About the file-position indicator (-> fseeko, ftello):
162 The file position indicator is incremented by fgetc() and decremented
163 by ungetc():
164 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fgetc.html>
165 "... the fgetc() function shall ... advance the associated file
166 position indicator for the stream ..."
167 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ungetc.html>
168 "The file-position indicator is decremented by each successful
169 call to ungetc()..."
170 2) fflush discards bytes pushed back by ungetc:
171 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
172 "...any characters pushed back onto the stream by ungetc()
173 or ungetwc() that have not subsequently been read from the
174 stream shall be discarded..."
175 This implies implicitly: fflush does not change the file position
176 indicator.
177 3) Effects on the file descriptor, if the file descriptor is capable of
178 seeking:
179 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
180 "...the file offset of the underlying open file description shall
181 be set to the file position of the stream..." */
182
183 /* POSIX does not specify fflush behavior for non-seekable input
184 streams. Some implementations purge unread data, some return
185 EBADF, some do nothing. */
186 off_t pos = ftello (stream);
187 if (pos == -1)
188 {
189 errno = EBADF;
190 return EOF;
191 }
192
193 /* Clear the ungetc buffer. */
194 clear_ungetc_buffer (stream);
195
196 /* To get here, we must be flushing a seekable input stream, so the
197 semantics of fpurge are now appropriate to clear the buffer. To
198 avoid losing data, the lseek is also necessary. */
199 {
200 int result = fpurge (stream);
201 if (result != 0)
202 return result;
203 }
204
205# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
206 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
207
208 {
209 /* Disable seek optimization for the next fseeko call. This tells the
210 following fseeko call to seek to the desired position directly, rather
211 than to seek to a block-aligned boundary. */
212 int saved_flags = disable_seek_optimization (stream);
213 int result = fseeko (stream, pos, SEEK_SET);
214
215 restore_seek_optimization (stream, saved_flags);
216 return result;
217 }
218
219# else
220
221 pos = lseek (fileno (stream), pos, SEEK_SET);
222 if (pos == -1)
223 return EOF;
224 /* After a successful lseek, update the file descriptor's position cache
225 in the stream. */
226 update_fpos_cache (stream, pos);
227
228 return 0;
229
230# endif
231 }
232#endif
233}
diff --git a/gl/filename.h b/gl/filename.h
new file mode 100644
index 00000000..a2400a9d
--- /dev/null
+++ b/gl/filename.h
@@ -0,0 +1,112 @@
1/* Basic filename support macros.
2 Copyright (C) 2001-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* From Paul Eggert and Jim Meyering. */
20
21#ifndef _FILENAME_H
22#define _FILENAME_H
23
24#include <string.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30
31/* Filename support.
32 ISSLASH(C) tests whether C is a directory separator
33 character.
34 HAS_DEVICE(Filename) tests whether Filename contains a device
35 specification.
36 FILE_SYSTEM_PREFIX_LEN(Filename) length of the device specification
37 at the beginning of Filename,
38 index of the part consisting of
39 alternating components and slashes.
40 FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
41 1 when a non-empty device specification
42 can be followed by an empty or relative
43 part,
44 0 when a non-empty device specification
45 must be followed by a slash,
46 0 when device specification don't exist.
47 IS_ABSOLUTE_FILE_NAME(Filename)
48 tests whether Filename is independent of
49 any notion of "current directory".
50 IS_RELATIVE_FILE_NAME(Filename)
51 tests whether Filename may be concatenated
52 to a directory filename.
53 Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
54 relative file name!
55 IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device
56 or directory specification.
57 */
58#if defined _WIN32 || defined __CYGWIN__ \
59 || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
60 /* Native Windows, Cygwin, OS/2, DOS */
61# define ISSLASH(C) ((C) == '/' || (C) == '\\')
62 /* Internal macro: Tests whether a character is a drive letter. */
63# define _IS_DRIVE_LETTER(C) \
64 (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
65 /* Help the compiler optimizing it. This assumes ASCII. */
66# undef _IS_DRIVE_LETTER
67# define _IS_DRIVE_LETTER(C) \
68 (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
69# define HAS_DEVICE(Filename) \
70 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
71# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
72# ifdef __CYGWIN__
73# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
74# else
75 /* On native Windows, OS/2, DOS, the system has the notion of a
76 "current directory" on each drive. */
77# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
78# endif
79# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
80# define IS_ABSOLUTE_FILE_NAME(Filename) \
81 ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
82# else
83# define IS_ABSOLUTE_FILE_NAME(Filename) \
84 (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
85# endif
86# define IS_RELATIVE_FILE_NAME(Filename) \
87 (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
88# define IS_FILE_NAME_WITH_DIR(Filename) \
89 (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
90 || HAS_DEVICE (Filename))
91#else
92 /* Unix */
93# define ISSLASH(C) ((C) == '/')
94# define HAS_DEVICE(Filename) ((void) (Filename), 0)
95# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
96# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
97# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
98# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
99# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
100#endif
101
102/* Deprecated macros. For backward compatibility with old users of the
103 'filename' module. */
104#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
105#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
106
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif /* _FILENAME_H */
diff --git a/gl/float+.h b/gl/float+.h
index 32fb790b..e7531e46 100644
--- a/gl/float+.h
+++ b/gl/float+.h
@@ -1,19 +1,19 @@
1/* Supplemental information about the floating-point formats. 1/* Supplemental information about the floating-point formats.
2 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2007. 3 Written by Bruno Haible <bruno@clisp.org>, 2007.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _FLOATPLUS_H 18#ifndef _FLOATPLUS_H
19#define _FLOATPLUS_H 19#define _FLOATPLUS_H
diff --git a/gl/float.c b/gl/float.c
index 366945fa..f81ff33d 100644
--- a/gl/float.c
+++ b/gl/float.c
@@ -1,19 +1,19 @@
1/* Auxiliary definitions for <float.h>. 1/* Auxiliary definitions for <float.h>.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/float.in.h b/gl/float.in.h
index 84e1950f..bf2c502c 100644
--- a/gl/float.in.h
+++ b/gl/float.in.h
@@ -1,19 +1,19 @@
1/* A correct <float.h>. 1/* A correct <float.h>.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_FLOAT_H 18#ifndef _@GUARD_PREFIX@_FLOAT_H
19 19
@@ -62,8 +62,8 @@
62 62
63/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of 63/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
64 precision in the compiler but 64 bits of precision at runtime. See 64 precision in the compiler but 64 bits of precision at runtime. See
65 <http://lists.gnu.org/archive/html/bug-gnulib/2008-07/msg00063.html>. */ 65 <https://lists.gnu.org/r/bug-gnulib/2008-07/msg00063.html>. */
66#if defined __i386__ && defined __FreeBSD__ 66#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
67/* Number of mantissa units, in base FLT_RADIX. */ 67/* Number of mantissa units, in base FLT_RADIX. */
68# undef LDBL_MANT_DIG 68# undef LDBL_MANT_DIG
69# define LDBL_MANT_DIG 64 69# define LDBL_MANT_DIG 64
@@ -81,7 +81,7 @@
81# define LDBL_MAX_EXP 16384 81# define LDBL_MAX_EXP 16384
82/* Minimum positive normalized number. */ 82/* Minimum positive normalized number. */
83# undef LDBL_MIN 83# undef LDBL_MIN
84# define LDBL_MIN 3.3621031431120935E-4932L /* = 0x1p-16382L */ 84# define LDBL_MIN 3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */
85/* Maximum representable finite number. */ 85/* Maximum representable finite number. */
86# undef LDBL_MAX 86# undef LDBL_MAX
87/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }. 87/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
@@ -93,11 +93,14 @@
93 extern const long double LDBL_MAX; 93 extern const long double LDBL_MAX;
94 94
95 Unfortunately, this is not a constant expression. */ 95 Unfortunately, this is not a constant expression. */
96# if !GNULIB_defined_long_double_union
96union gl_long_double_union 97union gl_long_double_union
97 { 98 {
98 struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd; 99 struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
99 long double ld; 100 long double ld;
100 }; 101 };
102# define GNULIB_defined_long_double_union 1
103# endif
101extern const union gl_long_double_union gl_LDBL_MAX; 104extern const union gl_long_double_union gl_LDBL_MAX;
102# define LDBL_MAX (gl_LDBL_MAX.ld) 105# define LDBL_MAX (gl_LDBL_MAX.ld)
103/* Minimum e such that 10^e is in the range of normalized numbers. */ 106/* Minimum e such that 10^e is in the range of normalized numbers. */
@@ -146,11 +149,14 @@ extern const union gl_long_double_union gl_LDBL_MAX;
146 149
147 Unfortunately, this is not a constant expression, and the latter expression 150 Unfortunately, this is not a constant expression, and the latter expression
148 does not work well when GCC is optimizing.. */ 151 does not work well when GCC is optimizing.. */
152# if !GNULIB_defined_long_double_union
149union gl_long_double_union 153union gl_long_double_union
150 { 154 {
151 struct { double hi; double lo; } dd; 155 struct { double hi; double lo; } dd;
152 long double ld; 156 long double ld;
153 }; 157 };
158# define GNULIB_defined_long_double_union 1
159# endif
154extern const union gl_long_double_union gl_LDBL_MAX; 160extern const union gl_long_double_union gl_LDBL_MAX;
155# define LDBL_MAX (gl_LDBL_MAX.ld) 161# define LDBL_MAX (gl_LDBL_MAX.ld)
156#endif 162#endif
diff --git a/gl/floor.c b/gl/floor.c
index cf29b196..238f4879 100644
--- a/gl/floor.c
+++ b/gl/floor.c
@@ -1,18 +1,18 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2010-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2010-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation, either version 3 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18 18
@@ -44,7 +44,7 @@
44 44
45/* MSVC with option -fp:strict refuses to compile constant initializers that 45/* MSVC with option -fp:strict refuses to compile constant initializers that
46 contain floating-point operations. Pacify this compiler. */ 46 contain floating-point operations. Pacify this compiler. */
47#ifdef _MSC_VER 47#if defined _MSC_VER && !defined __clang__
48# pragma fenv_access (off) 48# pragma fenv_access (off)
49#endif 49#endif
50 50
diff --git a/gl/floorf.c b/gl/floorf.c
index bbd3382e..e465c180 100644
--- a/gl/floorf.c
+++ b/gl/floorf.c
@@ -1,18 +1,18 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation, either version 3 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18 18
diff --git a/gl/fopen.c b/gl/fopen.c
new file mode 100644
index 00000000..f8469a0b
--- /dev/null
+++ b/gl/fopen.c
@@ -0,0 +1,229 @@
1/* Open a stream to a file.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18
19/* If the user's config.h happens to include <stdio.h>, let it include only
20 the system's <stdio.h> here, so that orig_fopen doesn't recurse to
21 rpl_fopen. */
22#define _GL_ALREADY_INCLUDING_STDIO_H
23#include <config.h>
24
25/* Get the original definition of fopen. It might be defined as a macro. */
26#include <stdio.h>
27#undef _GL_ALREADY_INCLUDING_STDIO_H
28
29static FILE *
30orig_fopen (const char *filename, const char *mode)
31{
32 return fopen (filename, mode);
33}
34
35/* Specification. */
36/* Write "stdio.h" here, not <stdio.h>, otherwise OSF/1 5.1 DTK cc eliminates
37 this include because of the preliminary #include <stdio.h> above. */
38#include "stdio.h"
39
40#include <errno.h>
41#include <fcntl.h>
42#include <string.h>
43#include <unistd.h>
44#include <sys/types.h>
45#include <sys/stat.h>
46
47FILE *
48rpl_fopen (const char *filename, const char *mode)
49{
50 int open_direction;
51 int open_flags;
52#if GNULIB_FOPEN_GNU
53 bool open_flags_gnu;
54# define BUF_SIZE 80
55 char fdopen_mode_buf[BUF_SIZE + 1];
56#endif
57
58#if defined _WIN32 && ! defined __CYGWIN__
59 if (strcmp (filename, "/dev/null") == 0)
60 filename = "NUL";
61#endif
62
63 /* Parse the mode. */
64 open_direction = 0;
65 open_flags = 0;
66#if GNULIB_FOPEN_GNU
67 open_flags_gnu = false;
68#endif
69 {
70 const char *p = mode;
71#if GNULIB_FOPEN_GNU
72 char *q = fdopen_mode_buf;
73#endif
74
75 for (; *p != '\0'; p++)
76 {
77 switch (*p)
78 {
79 case 'r':
80 open_direction = O_RDONLY;
81#if GNULIB_FOPEN_GNU
82 if (q < fdopen_mode_buf + BUF_SIZE)
83 *q++ = *p;
84#endif
85 continue;
86 case 'w':
87 open_direction = O_WRONLY;
88 open_flags |= O_CREAT | O_TRUNC;
89#if GNULIB_FOPEN_GNU
90 if (q < fdopen_mode_buf + BUF_SIZE)
91 *q++ = *p;
92#endif
93 continue;
94 case 'a':
95 open_direction = O_WRONLY;
96 open_flags |= O_CREAT | O_APPEND;
97#if GNULIB_FOPEN_GNU
98 if (q < fdopen_mode_buf + BUF_SIZE)
99 *q++ = *p;
100#endif
101 continue;
102 case 'b':
103 /* While it is non-standard, O_BINARY is guaranteed by
104 gnulib <fcntl.h>. We can also assume that orig_fopen
105 supports the 'b' flag. */
106 open_flags |= O_BINARY;
107#if GNULIB_FOPEN_GNU
108 if (q < fdopen_mode_buf + BUF_SIZE)
109 *q++ = *p;
110#endif
111 continue;
112 case '+':
113 open_direction = O_RDWR;
114#if GNULIB_FOPEN_GNU
115 if (q < fdopen_mode_buf + BUF_SIZE)
116 *q++ = *p;
117#endif
118 continue;
119#if GNULIB_FOPEN_GNU
120 case 'x':
121 open_flags |= O_EXCL;
122 open_flags_gnu = true;
123 continue;
124 case 'e':
125 open_flags |= O_CLOEXEC;
126 open_flags_gnu = true;
127 continue;
128#endif
129 default:
130 break;
131 }
132#if GNULIB_FOPEN_GNU
133 /* The rest of the mode string can be a platform-dependent extension.
134 Copy it unmodified. */
135 {
136 size_t len = strlen (p);
137 if (len > fdopen_mode_buf + BUF_SIZE - q)
138 len = fdopen_mode_buf + BUF_SIZE - q;
139 memcpy (q, p, len);
140 q += len;
141 }
142#endif
143 break;
144 }
145#if GNULIB_FOPEN_GNU
146 *q = '\0';
147#endif
148 }
149
150#if FOPEN_TRAILING_SLASH_BUG
151 /* Fail if the mode requires write access and the filename ends in a slash,
152 as POSIX says such a filename must name a directory
153 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
154 "A pathname that contains at least one non-<slash> character and that
155 ends with one or more trailing <slash> characters shall not be resolved
156 successfully unless the last pathname component before the trailing
157 <slash> characters names an existing directory"
158 If the named file already exists as a directory, then if a mode that
159 requires write access is specified, fopen() must fail because POSIX
160 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html>
161 says that it fails with errno = EISDIR in this case.
162 If the named file does not exist or does not name a directory, then
163 fopen() must fail since the file does not contain a '.' directory. */
164 {
165 size_t len = strlen (filename);
166 if (len > 0 && filename[len - 1] == '/')
167 {
168 int fd;
169 struct stat statbuf;
170 FILE *fp;
171
172 if (open_direction != O_RDONLY)
173 {
174 errno = EISDIR;
175 return NULL;
176 }
177
178 fd = open (filename, open_direction | open_flags,
179 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
180 if (fd < 0)
181 return NULL;
182
183 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
184 {
185 close (fd);
186 errno = ENOTDIR;
187 return NULL;
188 }
189
190# if GNULIB_FOPEN_GNU
191 fp = fdopen (fd, fdopen_mode_buf);
192# else
193 fp = fdopen (fd, mode);
194# endif
195 if (fp == NULL)
196 {
197 int saved_errno = errno;
198 close (fd);
199 errno = saved_errno;
200 }
201 return fp;
202 }
203 }
204#endif
205
206#if GNULIB_FOPEN_GNU
207 if (open_flags_gnu)
208 {
209 int fd;
210 FILE *fp;
211
212 fd = open (filename, open_direction | open_flags,
213 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
214 if (fd < 0)
215 return NULL;
216
217 fp = fdopen (fd, fdopen_mode_buf);
218 if (fp == NULL)
219 {
220 int saved_errno = errno;
221 close (fd);
222 errno = saved_errno;
223 }
224 return fp;
225 }
226#endif
227
228 return orig_fopen (filename, mode);
229}
diff --git a/gl/fpurge.c b/gl/fpurge.c
new file mode 100644
index 00000000..0dcb2b79
--- /dev/null
+++ b/gl/fpurge.c
@@ -0,0 +1,150 @@
1/* Flushing buffers of a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
23# if HAVE_STDIO_EXT_H
24# include <stdio_ext.h>
25# endif
26#endif
27#include <stdlib.h>
28
29#include "stdio-impl.h"
30
31int
32fpurge (FILE *fp)
33{
34#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
35
36 __fpurge (fp);
37 /* The __fpurge function does not have a return value. */
38 return 0;
39
40#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */
41
42 /* Call the system's fpurge function. */
43# undef fpurge
44# if !HAVE_DECL_FPURGE
45 extern int fpurge (FILE *);
46# endif
47 int result = fpurge (fp);
48# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
49 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
50 if (result == 0)
51 /* Correct the invariants that fpurge broke.
52 <stdio.h> on BSD systems says:
53 "The following always hold: if _flags & __SRD, _w is 0."
54 If this invariant is not fulfilled and the stream is read-write but
55 currently reading, subsequent putc or fputc calls will write directly
56 into the buffer, although they shouldn't be allowed to. */
57 if ((fp_->_flags & __SRD) != 0)
58 fp_->_w = 0;
59# endif
60 return result;
61
62#else
63
64 /* Most systems provide FILE as a struct and the necessary bitmask in
65 <stdio.h>, because they need it for implementing getc() and putc() as
66 fast macros. */
67# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
68 /* GNU libc, BeOS, Haiku, Linux libc5 */
69 fp->_IO_read_end = fp->_IO_read_ptr;
70 fp->_IO_write_ptr = fp->_IO_write_base;
71 /* Avoid memory leak when there is an active ungetc buffer. */
72 if (fp->_IO_save_base != NULL)
73 {
74 free (fp->_IO_save_base);
75 fp->_IO_save_base = NULL;
76 }
77 return 0;
78# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
79 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
80 fp_->_p = fp_->_bf._base;
81 fp_->_r = 0;
82 fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
83 ? fp_->_bf._size
84 : 0);
85 /* Avoid memory leak when there is an active ungetc buffer. */
86 if (fp_ub._base != NULL)
87 {
88 if (fp_ub._base != fp_->_ubuf)
89 free (fp_ub._base);
90 fp_ub._base = NULL;
91 }
92 return 0;
93# elif defined __EMX__ /* emx+gcc */
94 fp->_ptr = fp->_buffer;
95 fp->_rcount = 0;
96 fp->_wcount = 0;
97 fp->_ungetc_count = 0;
98 return 0;
99# elif defined __minix /* Minix */
100 fp->_ptr = fp->_buf;
101 if (fp->_ptr != NULL)
102 fp->_count = 0;
103 return 0;
104# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
105 fp_->_ptr = fp_->_base;
106 if (fp_->_ptr != NULL)
107 fp_->_cnt = 0;
108 return 0;
109# elif defined __UCLIBC__ /* uClibc */
110# ifdef __STDIO_BUFFERS
111 if (fp->__modeflags & __FLAG_WRITING)
112 fp->__bufpos = fp->__bufstart;
113 else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
114 fp->__bufpos = fp->__bufread;
115# endif
116 return 0;
117# elif defined __QNX__ /* QNX */
118 fp->_Rback = fp->_Back + sizeof (fp->_Back);
119 fp->_Rsave = NULL;
120 if (fp->_Mode & 0x2000 /* _MWRITE */)
121 /* fp->_Buf <= fp->_Next <= fp->_Wend */
122 fp->_Next = fp->_Buf;
123 else
124 /* fp->_Buf <= fp->_Next <= fp->_Rend */
125 fp->_Rend = fp->_Next;
126 return 0;
127# elif defined __MINT__ /* Atari FreeMiNT */
128 if (fp->__pushed_back)
129 {
130 fp->__bufp = fp->__pushback_bufp;
131 fp->__pushed_back = 0;
132 }
133 /* Preserve the current file position. */
134 if (fp->__target != -1)
135 fp->__target += fp->__bufp - fp->__buffer;
136 fp->__bufp = fp->__buffer;
137 /* Nothing in the buffer, next getc is nontrivial. */
138 fp->__get_limit = fp->__bufp;
139 /* Nothing in the buffer, next putc is nontrivial. */
140 fp->__put_limit = fp->__buffer;
141 return 0;
142# elif defined EPLAN9 /* Plan9 */
143 fp->rp = fp->wp = fp->lp = fp->buf;
144 return 0;
145# else
146# error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
147# endif
148
149#endif
150}
diff --git a/gl/freading.c b/gl/freading.c
new file mode 100644
index 00000000..b9377cb0
--- /dev/null
+++ b/gl/freading.c
@@ -0,0 +1,76 @@
1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include "freading.h"
21
22#include "stdio-impl.h"
23
24/* Don't use glibc's __freading function in glibc < 2.7, see
25 <https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
26#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
27
28bool
29freading (FILE *fp)
30{
31 /* Most systems provide FILE as a struct and the necessary bitmask in
32 <stdio.h>, because they need it for implementing getc() and putc() as
33 fast macros. */
34# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35 /* GNU libc, BeOS, Haiku, Linux libc5 */
36 return ((fp->_flags & _IO_NO_WRITES) != 0
37 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
38 && fp->_IO_read_base != NULL));
39# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
40 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
41 return (fp_->_flags & __SRD) != 0;
42# elif defined __EMX__ /* emx+gcc */
43 return (fp->_flags & _IOREAD) != 0;
44# elif defined __minix /* Minix */
45 return (fp->_flags & _IOREADING) != 0;
46# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
47# if defined __sun /* Solaris */
48 return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
49# else
50 return (fp_->_flag & _IOREAD) != 0;
51# endif
52# elif defined __UCLIBC__ /* uClibc */
53 return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
54# elif defined __QNX__ /* QNX */
55 return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
56 || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
57# elif defined __MINT__ /* Atari FreeMiNT */
58 if (!fp->__mode.__write)
59 return 1;
60 if (!fp->__mode.__read)
61 return 0;
62# ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
63 return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
64# else
65 return (fp->__buffer < fp->__get_limit /*|| fp->__bufp == fp->__put_limit ??*/);
66# endif
67# elif defined EPLAN9 /* Plan9 */
68 if (fp->state == 0 /* CLOSED */ || fp->state == 4 /* WR */)
69 return 0;
70 return (fp->state == 3 /* RD */ && (fp->bufl == 0 || fp->rp < fp->wp));
71# else
72# error "Please port gnulib freading.c to your platform!"
73# endif
74}
75
76#endif
diff --git a/gl/freading.h b/gl/freading.h
new file mode 100644
index 00000000..27b3abbc
--- /dev/null
+++ b/gl/freading.h
@@ -0,0 +1,54 @@
1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <stdio.h>
18
19/* Return true if the stream STREAM is opened read-only, or if the
20 last operation on the stream was a read operation. Return false if
21 the stream is opened write-only or append-only, or if it supports
22 writing and there is no current read operation (such as fgetc).
23
24 freading and fwriting will never both be true. If STREAM supports
25 both reads and writes, then:
26 - both freading and fwriting might be false when the stream is first
27 opened, after read encounters EOF, or after fflush,
28 - freading might be false or true and fwriting might be false
29 after repositioning (such as fseek, fsetpos, or rewind),
30 depending on the underlying implementation.
31
32 STREAM must not be wide-character oriented. */
33
34#if HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
35/* Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34, Android API >= 29, not glibc >= 2.2, but glibc >= 2.7, or musl libc */
36
37# if HAVE_STDIO_EXT_H
38# include <stdio_ext.h>
39# endif
40# define freading(stream) (__freading (stream) != 0)
41
42#else
43
44# ifdef __cplusplus
45extern "C" {
46# endif
47
48extern bool freading (FILE *stream) _GL_ATTRIBUTE_PURE;
49
50# ifdef __cplusplus
51}
52# endif
53
54#endif
diff --git a/gl/free.c b/gl/free.c
new file mode 100644
index 00000000..372a6b0f
--- /dev/null
+++ b/gl/free.c
@@ -0,0 +1,53 @@
1/* Make free() preserve errno.
2
3 Copyright (C) 2003, 2006, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Paul Eggert */
19
20#include <config.h>
21
22/* Specification. */
23#include <stdlib.h>
24
25/* A function definition is only needed if HAVE_FREE_POSIX is not defined. */
26#if !HAVE_FREE_POSIX
27
28# include <errno.h>
29
30void
31rpl_free (void *p)
32# undef free
33{
34# if defined __GNUC__ && !defined __clang__
35 /* An invalid GCC optimization
36 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396>
37 would optimize away the assignments in the code below, when link-time
38 optimization (LTO) is enabled. Make the code more complicated, so that
39 GCC does not grok how to optimize it. */
40 int err[2];
41 err[0] = errno;
42 err[1] = errno;
43 errno = 0;
44 free (p);
45 errno = err[errno == 0];
46# else
47 int err = errno;
48 free (p);
49 errno = err;
50# endif
51}
52
53#endif
diff --git a/gl/fseek.c b/gl/fseek.c
new file mode 100644
index 00000000..9764375a
--- /dev/null
+++ b/gl/fseek.c
@@ -0,0 +1,30 @@
1/* An fseek() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22/* Get off_t. */
23#include <unistd.h>
24
25int
26fseek (FILE *fp, long offset, int whence)
27{
28 /* Use the replacement fseeko function with all its workarounds. */
29 return fseeko (fp, (off_t)offset, whence);
30}
diff --git a/gl/fseeko.c b/gl/fseeko.c
new file mode 100644
index 00000000..89a70874
--- /dev/null
+++ b/gl/fseeko.c
@@ -0,0 +1,164 @@
1/* An fseeko() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22/* Get off_t, lseek, _POSIX_VERSION. */
23#include <unistd.h>
24
25#include "stdio-impl.h"
26
27int
28fseeko (FILE *fp, off_t offset, int whence)
29#undef fseeko
30#if !HAVE_FSEEKO
31# undef fseek
32# define fseeko fseek
33#endif
34#if _GL_WINDOWS_64_BIT_OFF_T
35# undef fseeko
36# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
37# define fseeko _fseeki64
38# else /* mingw before msvcrt8.0 */
39# define fseeko fseeko64
40# endif
41#endif
42{
43#if LSEEK_PIPE_BROKEN
44 /* mingw gives bogus answers rather than failure on non-seekable files. */
45 if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
46 return EOF;
47#endif
48
49 /* These tests are based on fpurge.c. */
50#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
51 /* GNU libc, BeOS, Haiku, Linux libc5 */
52 if (fp->_IO_read_end == fp->_IO_read_ptr
53 && fp->_IO_write_ptr == fp->_IO_write_base
54 && fp->_IO_save_base == NULL)
55#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
56 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
57# if defined __SL64 && defined __SCLE /* Cygwin */
58 if ((fp->_flags & __SL64) == 0)
59 {
60 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
61 mode; but has an fseeko that requires 64-bit mode. */
62 FILE *tmp = fopen ("/dev/null", "r");
63 if (!tmp)
64 return -1;
65 fp->_flags |= __SL64;
66 fp->_seek64 = tmp->_seek64;
67 fclose (tmp);
68 }
69# endif
70 if (fp_->_p == fp_->_bf._base
71 && fp_->_r == 0
72 && fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
73 ? fp_->_bf._size
74 : 0)
75 && fp_ub._base == NULL)
76#elif defined __EMX__ /* emx+gcc */
77 if (fp->_ptr == fp->_buffer
78 && fp->_rcount == 0
79 && fp->_wcount == 0
80 && fp->_ungetc_count == 0)
81#elif defined __minix /* Minix */
82 if (fp_->_ptr == fp_->_buf
83 && (fp_->_ptr == NULL || fp_->_count == 0))
84#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
85 if (fp_->_ptr == fp_->_base
86 && (fp_->_ptr == NULL || fp_->_cnt == 0))
87#elif defined __UCLIBC__ /* uClibc */
88 if (((fp->__modeflags & __FLAG_WRITING) == 0
89 || fp->__bufpos == fp->__bufstart)
90 && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
91 || fp->__bufpos == fp->__bufread))
92#elif defined __QNX__ /* QNX */
93 if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
94 && fp->_Rback == fp->_Back + sizeof (fp->_Back)
95 && fp->_Rsave == NULL)
96#elif defined __MINT__ /* Atari FreeMiNT */
97 if (fp->__bufp == fp->__buffer
98 && fp->__get_limit == fp->__bufp
99 && fp->__put_limit == fp->__bufp
100 && !fp->__pushed_back)
101#elif defined EPLAN9 /* Plan9 */
102 if (fp->rp == fp->buf
103 && fp->wp == fp->buf)
104#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
105 /* Cross-compiling to some other system advertising conformance to
106 POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
107 If this assumption is incorrect, please report the bug to
108 bug-gnulib. */
109 if (0)
110#else
111 #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
112#endif
113 {
114 /* We get here when an fflush() call immediately preceded this one (or
115 if ftell() has created buffers but no I/O has occurred on a
116 newly-opened stream). We know there are no buffers. */
117 off_t pos = lseek (fileno (fp), offset, whence);
118 if (pos == -1)
119 {
120#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
121 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
122 fp_->_flags &= ~__SOFF;
123#endif
124 return -1;
125 }
126
127#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
128 /* GNU libc, BeOS, Haiku, Linux libc5 */
129 fp->_flags &= ~_IO_EOF_SEEN;
130 fp->_offset = pos;
131#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
132 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
133# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
134 /* fp_->_offset is typed as an integer. */
135 fp_->_offset = pos;
136# else
137 /* fp_->_offset is an fpos_t. */
138 {
139 /* Use a union, since on NetBSD, the compilation flags
140 determine whether fpos_t is typedef'd to off_t or a struct
141 containing a single off_t member. */
142 union
143 {
144 fpos_t f;
145 off_t o;
146 } u;
147 u.o = pos;
148 fp_->_offset = u.f;
149 }
150# endif
151 fp_->_flags |= __SOFF;
152 fp_->_flags &= ~__SEOF;
153#elif defined __EMX__ /* emx+gcc */
154 fp->_flags &= ~_IOEOF;
155#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
156 fp_->_flag &= ~_IOEOF;
157#elif defined __MINT__ /* Atari FreeMiNT */
158 fp->__offset = pos;
159 fp->__eof = 0;
160#endif
161 return 0;
162 }
163 return fseeko (fp, offset, whence);
164}
diff --git a/gl/fstat.c b/gl/fstat.c
new file mode 100644
index 00000000..6a235002
--- /dev/null
+++ b/gl/fstat.c
@@ -0,0 +1,94 @@
1/* fstat() replacement.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* If the user's config.h happens to include <sys/stat.h>, let it include only
18 the system's <sys/stat.h> here, so that orig_fstat doesn't recurse to
19 rpl_fstat. */
20#define __need_system_sys_stat_h
21#include <config.h>
22
23/* Get the original definition of fstat. It might be defined as a macro. */
24#include <sys/types.h>
25#include <sys/stat.h>
26#undef __need_system_sys_stat_h
27
28#if defined _WIN32 && ! defined __CYGWIN__
29# define WINDOWS_NATIVE
30#endif
31
32#if !defined WINDOWS_NATIVE
33
34static int
35orig_fstat (int fd, struct stat *buf)
36{
37 return fstat (fd, buf);
38}
39
40#endif
41
42/* Specification. */
43#ifdef __osf__
44/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
45 eliminates this include because of the preliminary #include <sys/stat.h>
46 above. */
47# include "sys/stat.h"
48#else
49# include <sys/stat.h>
50#endif
51
52#include "stat-time.h"
53
54#include <errno.h>
55#include <unistd.h>
56#ifdef WINDOWS_NATIVE
57# define WIN32_LEAN_AND_MEAN
58# include <windows.h>
59# if GNULIB_MSVC_NOTHROW
60# include "msvc-nothrow.h"
61# else
62# include <io.h>
63# endif
64# include "stat-w32.h"
65#endif
66
67int
68rpl_fstat (int fd, struct stat *buf)
69{
70#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY
71 /* Handle the case when rpl_open() used a dummy file descriptor to work
72 around an open() that can't normally visit directories. */
73 const char *name = _gl_directory_name (fd);
74 if (name != NULL)
75 return stat (name, buf);
76#endif
77
78#ifdef WINDOWS_NATIVE
79 /* Fill the fields ourselves, because the original fstat function returns
80 values for st_atime, st_mtime, st_ctime that depend on the current time
81 zone. See
82 <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
83 HANDLE h = (HANDLE) _get_osfhandle (fd);
84
85 if (h == INVALID_HANDLE_VALUE)
86 {
87 errno = EBADF;
88 return -1;
89 }
90 return _gl_fstat_by_handle (h, NULL, buf);
91#else
92 return stat_time_normalize (orig_fstat (fd, buf), buf);
93#endif
94}
diff --git a/gl/fsusage.c b/gl/fsusage.c
index 0657555f..f6f4b1c3 100644
--- a/gl/fsusage.c
+++ b/gl/fsusage.c
@@ -1,20 +1,20 @@
1/* fsusage.c -- return space usage of mounted file systems 1/* fsusage.c -- return space usage of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2013 Free Software 3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation, either version 3 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
@@ -43,23 +43,11 @@
43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ 43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */
44# include <sys/fs/s5param.h> 44# include <sys/fs/s5param.h>
45# endif 45# endif
46# if defined HAVE_SYS_FILSYS_H && !defined _CRAY
47# include <sys/filsys.h> /* SVR2 */
48# endif
49# if HAVE_SYS_STATFS_H 46# if HAVE_SYS_STATFS_H
50# include <sys/statfs.h> 47# include <sys/statfs.h>
51# endif 48# endif
52# if HAVE_DUSTAT_H /* AIX PS/2 */
53# include <sys/dustat.h>
54# endif
55# include "full-read.h"
56#endif 49#endif
57 50
58/* The results of open() in this file are not used with fchdir,
59 therefore save some unnecessary work in fchdir.c. */
60#undef open
61#undef close
62
63/* Many space usage primitives use all 1 bits to denote a value that is 51/* Many space usage primitives use all 1 bits to denote a value that is
64 not applicable or unknown. Propagate this information by returning 52 not applicable or unknown. Propagate this information by returning
65 a uintmax_t value that is all 1 bits if X is all 1 bits, even if X 53 a uintmax_t value that is all 1 bits if X is all 1 bits, even if X
@@ -160,56 +148,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
160 ? PROPAGATE_ALL_ONES (fsd.f_frsize) 148 ? PROPAGATE_ALL_ONES (fsd.f_frsize)
161 : PROPAGATE_ALL_ONES (fsd.f_bsize)); 149 : PROPAGATE_ALL_ONES (fsd.f_bsize));
162 150
163#elif defined STAT_STATFS2_FS_DATA /* Ultrix */
164
165 struct fs_data fsd;
166
167 if (statfs (file, &fsd) != 1)
168 return -1;
169
170 fsp->fsu_blocksize = 1024;
171 fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.fd_req.btot);
172 fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.fd_req.bfree);
173 fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.fd_req.bfreen);
174 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0;
175 fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
176 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
177
178#elif defined STAT_READ_FILSYS /* SVR2 */
179# ifndef SUPERBOFF
180# define SUPERBOFF (SUPERB * 512)
181# endif
182
183 struct filsys fsd;
184 int fd;
185
186 if (! disk)
187 {
188 errno = 0;
189 return -1;
190 }
191
192 fd = open (disk, O_RDONLY);
193 if (fd < 0)
194 return -1;
195 lseek (fd, (off_t) SUPERBOFF, 0);
196 if (full_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
197 {
198 close (fd);
199 return -1;
200 }
201 close (fd);
202
203 fsp->fsu_blocksize = (fsd.s_type == Fs2b ? 1024 : 512);
204 fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.s_fsize);
205 fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.s_tfree);
206 fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree);
207 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0;
208 fsp->fsu_files = (fsd.s_isize == -1
209 ? UINTMAX_MAX
210 : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
211 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
212
213#elif defined STAT_STATFS3_OSF1 /* OSF/1 */ 151#elif defined STAT_STATFS3_OSF1 /* OSF/1 */
214 152
215 struct statfs fsd; 153 struct statfs fsd;
@@ -263,12 +201,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
263 201
264 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); 202 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
265 203
266#elif defined STAT_STATFS4 /* SVR3, Dynix, old Irix, old AIX, \ 204#elif defined STAT_STATFS4 /* SVR3, old Irix */
267 Dolphin */
268
269# if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN
270# define f_bavail f_bfree
271# endif
272 205
273 struct statfs fsd; 206 struct statfs fsd;
274 207
@@ -278,11 +211,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
278 /* Empirically, the block counts on most SVR3 and SVR3-derived 211 /* Empirically, the block counts on most SVR3 and SVR3-derived
279 systems seem to always be in terms of 512-byte blocks, 212 systems seem to always be in terms of 512-byte blocks,
280 no matter what value f_bsize has. */ 213 no matter what value f_bsize has. */
281# if _AIX || defined _CRAY
282 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
283# else
284 fsp->fsu_blocksize = 512; 214 fsp->fsu_blocksize = 512;
285# endif
286 215
287#endif 216#endif
288 217
@@ -302,30 +231,3 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
302 (void) disk; /* avoid argument-unused warning */ 231 (void) disk; /* avoid argument-unused warning */
303 return 0; 232 return 0;
304} 233}
305
306#if defined _AIX && defined _I386
307/* AIX PS/2 does not supply statfs. */
308
309int
310statfs (char *file, struct statfs *fsb)
311{
312 struct stat stats;
313 struct dustat fsd;
314
315 if (stat (file, &stats) != 0)
316 return -1;
317 if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
318 return -1;
319 fsb->f_type = 0;
320 fsb->f_bsize = fsd.du_bsize;
321 fsb->f_blocks = fsd.du_fsize - fsd.du_isize;
322 fsb->f_bfree = fsd.du_tfree;
323 fsb->f_bavail = fsd.du_tfree;
324 fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb;
325 fsb->f_ffree = fsd.du_tinode;
326 fsb->f_fsid.val[0] = fsd.du_site;
327 fsb->f_fsid.val[1] = fsd.du_pckno;
328 return 0;
329}
330
331#endif /* _AIX && _I386 */
diff --git a/gl/fsusage.h b/gl/fsusage.h
index 7810fc01..9630b04e 100644
--- a/gl/fsusage.h
+++ b/gl/fsusage.h
@@ -1,20 +1,20 @@
1/* fsusage.h -- declarations for file system space usage info 1/* fsusage.h -- declarations for file system space usage info
2 2
3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation, either version 3 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* Space usage statistics for a file system. Blocks are 512-byte. */ 19/* Space usage statistics for a file system. Blocks are 512-byte. */
20 20
@@ -22,7 +22,6 @@
22# define FSUSAGE_H_ 22# define FSUSAGE_H_
23 23
24# include <stdint.h> 24# include <stdint.h>
25# include <stdbool.h>
26 25
27struct fs_usage 26struct fs_usage
28{ 27{
diff --git a/gl/ftell.c b/gl/ftell.c
new file mode 100644
index 00000000..ce2bd542
--- /dev/null
+++ b/gl/ftell.c
@@ -0,0 +1,37 @@
1/* An ftell() function that works around platform bugs.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#include <errno.h>
23#include <limits.h>
24
25long
26ftell (FILE *fp)
27{
28 /* Use the replacement ftello function with all its workarounds. */
29 off_t offset = ftello (fp);
30 if (LONG_MIN <= offset && offset <= LONG_MAX)
31 return /* (long) */ offset;
32 else
33 {
34 errno = EOVERFLOW;
35 return -1;
36 }
37}
diff --git a/gl/ftello.c b/gl/ftello.c
new file mode 100644
index 00000000..14184e5e
--- /dev/null
+++ b/gl/ftello.c
@@ -0,0 +1,157 @@
1/* An ftello() function that works around platform bugs.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#include <errno.h>
23#include "intprops.h"
24
25/* Get lseek. */
26#include <unistd.h>
27
28#include "stdio-impl.h"
29
30off_t
31ftello (FILE *fp)
32#undef ftello
33#if !HAVE_FTELLO
34# undef ftell
35# define ftello ftell
36#endif
37#if _GL_WINDOWS_64_BIT_OFF_T
38# undef ftello
39# if HAVE__FTELLI64 /* msvc, mingw64 */
40# define ftello _ftelli64
41# else /* mingw */
42# define ftello ftello64
43# endif
44#endif
45{
46#if FTELLO_BROKEN_AFTER_UNGETC /* macOS >= 10.15 */
47 /* The system's ftello() is completely broken, because it calls __sflush,
48 which makes side effects on the stream. */
49
50 /* Handle non-seekable files first. */
51 if (fp->_file < 0 || fp->_seek == NULL)
52 {
53 errno = ESPIPE;
54 return -1;
55 }
56
57 /* Determine the current offset, ignoring buffered and pushed-back bytes. */
58 off_t pos;
59
60 if (fp->_flags & __SOFF)
61 pos = fp->_offset;
62 else
63 {
64 pos = fp->_seek (fp->_cookie, 0, SEEK_CUR);
65 if (pos < 0)
66 return -1;
67 if (fp->_flags & __SOPT)
68 {
69 fp->_offset = pos;
70 fp->_flags |= __SOFF;
71 }
72 }
73
74 if (fp->_flags & __SRD)
75 {
76 /* Now consider buffered and pushed-back bytes from ungetc. */
77 if (fp->_ub._base != NULL)
78 /* Considering the buffered bytes, we are at position
79 pos - fp->_ur.
80 Considering also the pushed-back bytes, we are at position
81 pos - fp->_ur - fp->_r. */
82 pos = pos - fp->_ur - fp->_r;
83 else
84 /* Considering the buffered bytes, we are at position
85 pos - fp->_r. */
86 pos = pos - fp->_r;
87 if (pos < 0)
88 {
89 errno = EIO;
90 return -1;
91 }
92 }
93 else if ((fp->_flags & __SWR) && fp->_p != NULL)
94 {
95 /* Consider the buffered bytes. */
96 off_t buffered = fp->_p - fp->_bf._base;
97
98 /* Compute pos + buffered, with overflow check. */
99 off_t sum;
100 if (! INT_ADD_OK (pos, buffered, &sum))
101 {
102 errno = EOVERFLOW;
103 return -1;
104 }
105 pos = sum;
106 }
107
108 return pos;
109
110#else
111
112# if LSEEK_PIPE_BROKEN
113 /* mingw gives bogus answers rather than failure on non-seekable files. */
114 if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
115 return -1;
116# endif
117
118# if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */
119 /* The Solaris stdio leaves the _IOREAD flag set after reading from a file
120 reaches EOF and the program then starts writing to the file. ftello
121 gets confused by this. */
122 if (fp_->_flag & _IOWRT)
123 {
124 off_t pos;
125
126 /* Call ftello nevertheless, for the side effects that it does on fp. */
127 ftello (fp);
128
129 /* Compute the file position ourselves. */
130 pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
131 if (pos >= 0)
132 {
133 if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
134 pos += fp_->_ptr - fp_->_base;
135 }
136 return pos;
137 }
138# endif
139
140# if defined __SL64 && defined __SCLE /* Cygwin */
141 if ((fp->_flags & __SL64) == 0)
142 {
143 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
144 mode; but has an ftello that requires 64-bit mode. */
145 FILE *tmp = fopen ("/dev/null", "r");
146 if (!tmp)
147 return -1;
148 fp->_flags |= __SL64;
149 fp->_seek64 = tmp->_seek64;
150 fclose (tmp);
151 }
152# endif
153
154 return ftello (fp);
155
156#endif
157}
diff --git a/gl/full-read.c b/gl/full-read.c
deleted file mode 100644
index a0dc82c2..00000000
--- a/gl/full-read.c
+++ /dev/null
@@ -1,18 +0,0 @@
1/* An interface to read that retries after partial reads and interrupts.
2 Copyright (C) 2002-2003, 2009-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#define FULL_READ
18#include "full-write.c"
diff --git a/gl/full-read.h b/gl/full-read.h
deleted file mode 100644
index 66c8c5c1..00000000
--- a/gl/full-read.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/* An interface to read() that reads all it is asked to read.
2
3 Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, read to the Free Software Foundation,
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include <stddef.h>
20
21/* Read COUNT bytes at BUF to descriptor FD, retrying if interrupted
22 or if partial reads occur. Return the number of bytes successfully
23 read, setting errno if that is less than COUNT. errno = 0 means EOF. */
24extern size_t full_read (int fd, void *buf, size_t count);
diff --git a/gl/full-write.c b/gl/full-write.c
deleted file mode 100644
index beb5bf95..00000000
--- a/gl/full-write.c
+++ /dev/null
@@ -1,79 +0,0 @@
1/* An interface to read and write that retries (if necessary) until complete.
2
3 Copyright (C) 1993-1994, 1997-2006, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#ifdef FULL_READ
22# include "full-read.h"
23#else
24# include "full-write.h"
25#endif
26
27#include <errno.h>
28
29#ifdef FULL_READ
30# include "safe-read.h"
31# define safe_rw safe_read
32# define full_rw full_read
33# undef const
34# define const /* empty */
35#else
36# include "safe-write.h"
37# define safe_rw safe_write
38# define full_rw full_write
39#endif
40
41#ifdef FULL_READ
42/* Set errno to zero upon EOF. */
43# define ZERO_BYTE_TRANSFER_ERRNO 0
44#else
45/* Some buggy drivers return 0 when one tries to write beyond
46 a device's end. (Example: Linux 1.2.13 on /dev/fd0.)
47 Set errno to ENOSPC so they get a sensible diagnostic. */
48# define ZERO_BYTE_TRANSFER_ERRNO ENOSPC
49#endif
50
51/* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if
52 interrupted or if a partial write(read) occurs. Return the number
53 of bytes transferred.
54 When writing, set errno if fewer than COUNT bytes are written.
55 When reading, if fewer than COUNT bytes are read, you must examine
56 errno to distinguish failure from EOF (errno == 0). */
57size_t
58full_rw (int fd, const void *buf, size_t count)
59{
60 size_t total = 0;
61 const char *ptr = (const char *) buf;
62
63 while (count > 0)
64 {
65 size_t n_rw = safe_rw (fd, ptr, count);
66 if (n_rw == (size_t) -1)
67 break;
68 if (n_rw == 0)
69 {
70 errno = ZERO_BYTE_TRANSFER_ERRNO;
71 break;
72 }
73 total += n_rw;
74 ptr += n_rw;
75 count -= n_rw;
76 }
77
78 return total;
79}
diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c
index 1e371d27..3436c07a 100644
--- a/gl/gai_strerror.c
+++ b/gl/gai_strerror.c
@@ -1,20 +1,20 @@
1/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2013 Free Software 1/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2023 Free Software
2 Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. 4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef _LIBC 19#ifndef _LIBC
20# include <config.h> 20# include <config.h>
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 58d28115..6586ee58 100644
--- a/gl/getaddrinfo.c
+++ b/gl/getaddrinfo.c
@@ -1,19 +1,19 @@
1/* Get address information (partial implementation). 1/* Get address information (partial implementation).
2 Copyright (C) 1997, 2001-2002, 2004-2013 Free Software Foundation, Inc. 2 Copyright (C) 1997, 2001-2002, 2004-2023 Free Software Foundation, Inc.
3 Contributed by Simon Josefsson <simon@josefsson.org>. 3 Contributed by Simon Josefsson <simon@josefsson.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
19 optimizes away the sa == NULL test below. */ 19 optimizes away the sa == NULL test below. */
@@ -39,8 +39,6 @@
39/* Get snprintf. */ 39/* Get snprintf. */
40#include <stdio.h> 40#include <stdio.h>
41 41
42#include <stdbool.h>
43
44#include "gettext.h" 42#include "gettext.h"
45#define _(String) gettext (String) 43#define _(String) gettext (String)
46#define N_(String) String 44#define N_(String) String
@@ -54,14 +52,48 @@
54# define PF_UNSPEC 0 52# define PF_UNSPEC 0
55#endif 53#endif
56 54
57#if defined _WIN32 || defined __WIN32__ 55#if HAVE_GETADDRINFO
58# define WINDOWS_NATIVE 56
59#endif 57/* Override with cdecl calling convention. */
58
59int
60getaddrinfo (const char *restrict nodename,
61 const char *restrict servname,
62 const struct addrinfo *restrict hints,
63 struct addrinfo **restrict res)
64# undef getaddrinfo
65{
66 return getaddrinfo (nodename, servname, hints, res);
67}
68
69void
70freeaddrinfo (struct addrinfo *ai)
71# undef freeaddrinfo
72{
73 freeaddrinfo (ai);
74}
75
76#else
77
78# if defined _WIN32 && !defined __CYGWIN__
79# define WINDOWS_NATIVE
80# endif
60 81
61/* gl_sockets_startup */ 82/* gl_sockets_startup */
62#include "sockets.h" 83# include "sockets.h"
84
85# ifdef WINDOWS_NATIVE
86
87/* Don't assume that UNICODE is not defined. */
88# undef GetModuleHandle
89# define GetModuleHandle GetModuleHandleA
90
91# if !(_WIN32_WINNT >= _WIN32_WINNT_WINXP)
92
93/* Avoid warnings from gcc -Wcast-function-type. */
94# define GetProcAddress \
95 (void *) GetProcAddress
63 96
64#ifdef WINDOWS_NATIVE
65typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, 97typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
66 const struct addrinfo*, 98 const struct addrinfo*,
67 struct addrinfo**); 99 struct addrinfo**);
@@ -107,20 +139,43 @@ use_win32_p (void)
107 139
108 return 1; 140 return 1;
109} 141}
110#endif 142
143# else
144
145static int
146use_win32_p (void)
147{
148 static int done = 0;
149
150 if (!done)
151 {
152 done = 1;
153
154 gl_sockets_startup (SOCKETS_1_1);
155 }
156
157 return 1;
158}
159
160# define getaddrinfo_ptr getaddrinfo
161# define freeaddrinfo_ptr freeaddrinfo
162# define getnameinfo_ptr getnameinfo
163
164# endif
165# endif
111 166
112static bool 167static bool
113validate_family (int family) 168validate_family (int family)
114{ 169{
115 /* FIXME: Support more families. */ 170 /* FIXME: Support more families. */
116#if HAVE_IPV4 171# if HAVE_IPV4
117 if (family == PF_INET) 172 if (family == PF_INET)
118 return true; 173 return true;
119#endif 174# endif
120#if HAVE_IPV6 175# if HAVE_IPV6
121 if (family == PF_INET6) 176 if (family == PF_INET6)
122 return true; 177 return true;
123#endif 178# endif
124 if (family == PF_UNSPEC) 179 if (family == PF_UNSPEC)
125 return true; 180 return true;
126 return false; 181 return false;
@@ -133,29 +188,30 @@ getaddrinfo (const char *restrict nodename,
133 const char *restrict servname, 188 const char *restrict servname,
134 const struct addrinfo *restrict hints, 189 const struct addrinfo *restrict hints,
135 struct addrinfo **restrict res) 190 struct addrinfo **restrict res)
191#undef getaddrinfo
136{ 192{
137 struct addrinfo *tmp; 193 struct addrinfo *tmp;
138 int port = 0; 194 int port = 0;
139 struct hostent *he; 195 struct hostent *he;
140 void *storage; 196 void *storage;
141 size_t size; 197 size_t size;
142#if HAVE_IPV6 198# if HAVE_IPV6
143 struct v6_pair { 199 struct v6_pair {
144 struct addrinfo addrinfo; 200 struct addrinfo addrinfo;
145 struct sockaddr_in6 sockaddr_in6; 201 struct sockaddr_in6 sockaddr_in6;
146 }; 202 };
147#endif 203# endif
148#if HAVE_IPV4 204# if HAVE_IPV4
149 struct v4_pair { 205 struct v4_pair {
150 struct addrinfo addrinfo; 206 struct addrinfo addrinfo;
151 struct sockaddr_in sockaddr_in; 207 struct sockaddr_in sockaddr_in;
152 }; 208 };
153#endif 209# endif
154 210
155#ifdef WINDOWS_NATIVE 211# ifdef WINDOWS_NATIVE
156 if (use_win32_p ()) 212 if (use_win32_p ())
157 return getaddrinfo_ptr (nodename, servname, hints, res); 213 return getaddrinfo_ptr (nodename, servname, hints, res);
158#endif 214# endif
159 215
160 if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE))) 216 if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE)))
161 /* FIXME: Support more flags. */ 217 /* FIXME: Support more flags. */
@@ -174,11 +230,11 @@ getaddrinfo (const char *restrict nodename,
174 if (!(hints->ai_flags & AI_PASSIVE)) 230 if (!(hints->ai_flags & AI_PASSIVE))
175 return EAI_NONAME; 231 return EAI_NONAME;
176 232
177#ifdef HAVE_IPV6 233# ifdef HAVE_IPV6
178 nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0"; 234 nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
179#else 235# else
180 nodename = "0.0.0.0"; 236 nodename = "0.0.0.0";
181#endif 237# endif
182 } 238 }
183 239
184 if (servname) 240 if (servname)
@@ -212,17 +268,17 @@ getaddrinfo (const char *restrict nodename,
212 268
213 switch (he->h_addrtype) 269 switch (he->h_addrtype)
214 { 270 {
215#if HAVE_IPV6 271# if HAVE_IPV6
216 case PF_INET6: 272 case PF_INET6:
217 size = sizeof (struct v6_pair); 273 size = sizeof (struct v6_pair);
218 break; 274 break;
219#endif 275# endif
220 276
221#if HAVE_IPV4 277# if HAVE_IPV4
222 case PF_INET: 278 case PF_INET:
223 size = sizeof (struct v4_pair); 279 size = sizeof (struct v4_pair);
224 break; 280 break;
225#endif 281# endif
226 282
227 default: 283 default:
228 return EAI_NODATA; 284 return EAI_NODATA;
@@ -234,7 +290,7 @@ getaddrinfo (const char *restrict nodename,
234 290
235 switch (he->h_addrtype) 291 switch (he->h_addrtype)
236 { 292 {
237#if HAVE_IPV6 293# if HAVE_IPV6
238 case PF_INET6: 294 case PF_INET6:
239 { 295 {
240 struct v6_pair *p = storage; 296 struct v6_pair *p = storage;
@@ -256,9 +312,9 @@ getaddrinfo (const char *restrict nodename,
256 tmp->ai_addrlen = sizeof *sinp; 312 tmp->ai_addrlen = sizeof *sinp;
257 } 313 }
258 break; 314 break;
259#endif 315# endif
260 316
261#if HAVE_IPV4 317# if HAVE_IPV4
262 case PF_INET: 318 case PF_INET:
263 { 319 {
264 struct v4_pair *p = storage; 320 struct v4_pair *p = storage;
@@ -280,7 +336,7 @@ getaddrinfo (const char *restrict nodename,
280 tmp->ai_addrlen = sizeof *sinp; 336 tmp->ai_addrlen = sizeof *sinp;
281 } 337 }
282 break; 338 break;
283#endif 339# endif
284 340
285 default: 341 default:
286 free (storage); 342 free (storage);
@@ -308,21 +364,21 @@ getaddrinfo (const char *restrict nodename,
308 tmp->ai_addr->sa_family = he->h_addrtype; 364 tmp->ai_addr->sa_family = he->h_addrtype;
309 tmp->ai_family = he->h_addrtype; 365 tmp->ai_family = he->h_addrtype;
310 366
311#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN 367# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
312 switch (he->h_addrtype) 368 switch (he->h_addrtype)
313 { 369 {
314#if HAVE_IPV4 370# if HAVE_IPV4
315 case AF_INET: 371 case AF_INET:
316 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in); 372 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in);
317 break; 373 break;
318#endif 374# endif
319#if HAVE_IPV6 375# if HAVE_IPV6
320 case AF_INET6: 376 case AF_INET6:
321 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6); 377 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6);
322 break; 378 break;
323#endif 379# endif
324 } 380 }
325#endif 381# endif
326 382
327 /* FIXME: If more than one address, create linked list of addrinfo's. */ 383 /* FIXME: If more than one address, create linked list of addrinfo's. */
328 384
@@ -334,14 +390,15 @@ getaddrinfo (const char *restrict nodename,
334/* Free 'addrinfo' structure AI including associated storage. */ 390/* Free 'addrinfo' structure AI including associated storage. */
335void 391void
336freeaddrinfo (struct addrinfo *ai) 392freeaddrinfo (struct addrinfo *ai)
393#undef freeaddrinfo
337{ 394{
338#ifdef WINDOWS_NATIVE 395# ifdef WINDOWS_NATIVE
339 if (use_win32_p ()) 396 if (use_win32_p ())
340 { 397 {
341 freeaddrinfo_ptr (ai); 398 freeaddrinfo_ptr (ai);
342 return; 399 return;
343 } 400 }
344#endif 401# endif
345 402
346 while (ai) 403 while (ai)
347 { 404 {
@@ -360,12 +417,13 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
360 char *restrict node, socklen_t nodelen, 417 char *restrict node, socklen_t nodelen,
361 char *restrict service, socklen_t servicelen, 418 char *restrict service, socklen_t servicelen,
362 int flags) 419 int flags)
420#undef getnameinfo
363{ 421{
364#ifdef WINDOWS_NATIVE 422# ifdef WINDOWS_NATIVE
365 if (use_win32_p ()) 423 if (use_win32_p ())
366 return getnameinfo_ptr (sa, salen, node, nodelen, 424 return getnameinfo_ptr (sa, salen, node, nodelen,
367 service, servicelen, flags); 425 service, servicelen, flags);
368#endif 426# endif
369 427
370 /* FIXME: Support other flags. */ 428 /* FIXME: Support other flags. */
371 if ((node && nodelen > 0 && !(flags & NI_NUMERICHOST)) || 429 if ((node && nodelen > 0 && !(flags & NI_NUMERICHOST)) ||
@@ -378,18 +436,18 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
378 436
379 switch (sa->sa_family) 437 switch (sa->sa_family)
380 { 438 {
381#if HAVE_IPV4 439# if HAVE_IPV4
382 case AF_INET: 440 case AF_INET:
383 if (salen < sizeof (struct sockaddr_in)) 441 if (salen < sizeof (struct sockaddr_in))
384 return EAI_FAMILY; 442 return EAI_FAMILY;
385 break; 443 break;
386#endif 444# endif
387#if HAVE_IPV6 445# if HAVE_IPV6
388 case AF_INET6: 446 case AF_INET6:
389 if (salen < sizeof (struct sockaddr_in6)) 447 if (salen < sizeof (struct sockaddr_in6))
390 return EAI_FAMILY; 448 return EAI_FAMILY;
391 break; 449 break;
392#endif 450# endif
393 default: 451 default:
394 return EAI_FAMILY; 452 return EAI_FAMILY;
395 } 453 }
@@ -398,23 +456,23 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
398 { 456 {
399 switch (sa->sa_family) 457 switch (sa->sa_family)
400 { 458 {
401#if HAVE_IPV4 459# if HAVE_IPV4
402 case AF_INET: 460 case AF_INET:
403 if (!inet_ntop (AF_INET, 461 if (!inet_ntop (AF_INET,
404 &(((const struct sockaddr_in *) sa)->sin_addr), 462 &(((const struct sockaddr_in *) sa)->sin_addr),
405 node, nodelen)) 463 node, nodelen))
406 return EAI_SYSTEM; 464 return EAI_SYSTEM;
407 break; 465 break;
408#endif 466# endif
409 467
410#if HAVE_IPV6 468# if HAVE_IPV6
411 case AF_INET6: 469 case AF_INET6:
412 if (!inet_ntop (AF_INET6, 470 if (!inet_ntop (AF_INET6,
413 &(((const struct sockaddr_in6 *) sa)->sin6_addr), 471 &(((const struct sockaddr_in6 *) sa)->sin6_addr),
414 node, nodelen)) 472 node, nodelen))
415 return EAI_SYSTEM; 473 return EAI_SYSTEM;
416 break; 474 break;
417#endif 475# endif
418 476
419 default: 477 default:
420 return EAI_FAMILY; 478 return EAI_FAMILY;
@@ -424,12 +482,12 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
424 if (service && servicelen > 0 && flags & NI_NUMERICSERV) 482 if (service && servicelen > 0 && flags & NI_NUMERICSERV)
425 switch (sa->sa_family) 483 switch (sa->sa_family)
426 { 484 {
427#if HAVE_IPV4 485# if HAVE_IPV4
428 case AF_INET: 486 case AF_INET:
429#endif 487# endif
430#if HAVE_IPV6 488# if HAVE_IPV6
431 case AF_INET6: 489 case AF_INET6:
432#endif 490# endif
433 { 491 {
434 unsigned short int port 492 unsigned short int port
435 = ntohs (((const struct sockaddr_in *) sa)->sin_port); 493 = ntohs (((const struct sockaddr_in *) sa)->sin_port);
@@ -441,3 +499,5 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
441 499
442 return 0; 500 return 0;
443} 501}
502
503#endif
diff --git a/gl/getdelim.c b/gl/getdelim.c
new file mode 100644
index 00000000..79ec3dd1
--- /dev/null
+++ b/gl/getdelim.c
@@ -0,0 +1,147 @@
1/* getdelim.c --- Implementation of replacement getdelim function.
2 Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2023 Free Software
3 Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Ported from glibc by Simon Josefsson. */
19
20/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
21 optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
22#define _GL_ARG_NONNULL(params)
23
24#include <config.h>
25
26#include <stdio.h>
27
28#include <limits.h>
29#include <stdint.h>
30#include <stdlib.h>
31#include <errno.h>
32
33#ifndef SSIZE_MAX
34# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
35#endif
36
37#if USE_UNLOCKED_IO
38# include "unlocked-io.h"
39# define getc_maybe_unlocked(fp) getc(fp)
40#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
41# undef flockfile
42# undef funlockfile
43# define flockfile(x) ((void) 0)
44# define funlockfile(x) ((void) 0)
45# define getc_maybe_unlocked(fp) getc(fp)
46#else
47# define getc_maybe_unlocked(fp) getc_unlocked(fp)
48#endif
49
50static void
51alloc_failed (void)
52{
53#if defined _WIN32 && ! defined __CYGWIN__
54 /* Avoid errno problem without using the realloc module; see:
55 https://lists.gnu.org/r/bug-gnulib/2016-08/msg00025.html */
56 errno = ENOMEM;
57#endif
58}
59
60/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
61 NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
62 NULL), pointing to *N characters of space. It is realloc'ed as
63 necessary. Returns the number of characters read (not including
64 the null terminator), or -1 on error or EOF. */
65
66ssize_t
67getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
68{
69 ssize_t result;
70 size_t cur_len = 0;
71
72 if (lineptr == NULL || n == NULL || fp == NULL)
73 {
74 errno = EINVAL;
75 return -1;
76 }
77
78 flockfile (fp);
79
80 if (*lineptr == NULL || *n == 0)
81 {
82 char *new_lineptr;
83 *n = 120;
84 new_lineptr = (char *) realloc (*lineptr, *n);
85 if (new_lineptr == NULL)
86 {
87 alloc_failed ();
88 result = -1;
89 goto unlock_return;
90 }
91 *lineptr = new_lineptr;
92 }
93
94 for (;;)
95 {
96 int i;
97
98 i = getc_maybe_unlocked (fp);
99 if (i == EOF)
100 {
101 result = -1;
102 break;
103 }
104
105 /* Make enough space for len+1 (for final NUL) bytes. */
106 if (cur_len + 1 >= *n)
107 {
108 size_t needed_max =
109 SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
110 size_t needed = 2 * *n + 1; /* Be generous. */
111 char *new_lineptr;
112
113 if (needed_max < needed)
114 needed = needed_max;
115 if (cur_len + 1 >= needed)
116 {
117 result = -1;
118 errno = EOVERFLOW;
119 goto unlock_return;
120 }
121
122 new_lineptr = (char *) realloc (*lineptr, needed);
123 if (new_lineptr == NULL)
124 {
125 alloc_failed ();
126 result = -1;
127 goto unlock_return;
128 }
129
130 *lineptr = new_lineptr;
131 *n = needed;
132 }
133
134 (*lineptr)[cur_len] = i;
135 cur_len++;
136
137 if (i == delimiter)
138 break;
139 }
140 (*lineptr)[cur_len] = '\0';
141 result = cur_len ? cur_len : result;
142
143 unlock_return:
144 funlockfile (fp); /* doesn't set errno */
145
146 return result;
147}
diff --git a/gl/getdtablesize.c b/gl/getdtablesize.c
new file mode 100644
index 00000000..ac2d1753
--- /dev/null
+++ b/gl/getdtablesize.c
@@ -0,0 +1,124 @@
1/* getdtablesize() function: Return maximum possible file descriptor value + 1.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <unistd.h>
22
23#if defined _WIN32 && ! defined __CYGWIN__
24
25# include <stdio.h>
26
27# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
28# include "msvc-inval.h"
29# endif
30
31# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
32static int
33_setmaxstdio_nothrow (int newmax)
34{
35 int result;
36
37 TRY_MSVC_INVAL
38 {
39 result = _setmaxstdio (newmax);
40 }
41 CATCH_MSVC_INVAL
42 {
43 result = -1;
44 }
45 DONE_MSVC_INVAL;
46
47 return result;
48}
49# else
50# define _setmaxstdio_nothrow _setmaxstdio
51# endif
52
53/* Cache for the previous getdtablesize () result. Safe to cache because
54 Windows also lacks setrlimit. */
55static int dtablesize;
56
57int
58getdtablesize (void)
59{
60 if (dtablesize == 0)
61 {
62 /* We are looking for the number N such that the valid file descriptors
63 are 0..N-1. It can be obtained through a loop as follows:
64 {
65 int fd;
66 for (fd = 3; fd < 65536; fd++)
67 if (dup2 (0, fd) == -1)
68 break;
69 return fd;
70 }
71 On Windows XP, the result is 2048.
72 The drawback of this loop is that it allocates memory for a libc
73 internal array that is never freed.
74
75 The number N can also be obtained as the upper bound for
76 _getmaxstdio (). _getmaxstdio () returns the maximum number of open
77 FILE objects. The sanity check in _setmaxstdio reveals the maximum
78 number of file descriptors. This too allocates memory, but it is
79 freed when we call _setmaxstdio with the original value. */
80 int orig_max_stdio = _getmaxstdio ();
81 unsigned int bound;
82 for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
83 ;
84 _setmaxstdio_nothrow (orig_max_stdio);
85 dtablesize = bound;
86 }
87 return dtablesize;
88}
89
90#else
91
92# include <limits.h>
93# include <sys/resource.h>
94
95# ifndef RLIM_SAVED_CUR
96# define RLIM_SAVED_CUR RLIM_INFINITY
97# endif
98# ifndef RLIM_SAVED_MAX
99# define RLIM_SAVED_MAX RLIM_INFINITY
100# endif
101
102# ifdef __CYGWIN__
103 /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it
104 hits the compile-time constant hard limit of 3200. We might as
105 well just report the hard limit. */
106# define rlim_cur rlim_max
107# endif
108
109int
110getdtablesize (void)
111{
112 struct rlimit lim;
113
114 if (getrlimit (RLIMIT_NOFILE, &lim) == 0
115 && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX
116 && lim.rlim_cur != RLIM_INFINITY
117 && lim.rlim_cur != RLIM_SAVED_CUR
118 && lim.rlim_cur != RLIM_SAVED_MAX)
119 return lim.rlim_cur;
120
121 return INT_MAX;
122}
123
124#endif
diff --git a/gl/gethostname.c b/gl/gethostname.c
index 22015732..0c616c34 100644
--- a/gl/gethostname.c
+++ b/gl/gethostname.c
@@ -1,26 +1,26 @@
1/* gethostname emulation for SysV and POSIX.1. 1/* gethostname emulation for SysV and POSIX.1.
2 2
3 Copyright (C) 1992, 2003, 2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 1992, 2003, 2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* David MacKenzie <djm@gnu.ai.mit.edu> 18/* David MacKenzie <djm@gnu.ai.mit.edu>
19 Windows port by Simon Josefsson <simon@josefsson.org> */ 19 Windows port by Simon Josefsson <simon@josefsson.org> */
20 20
21#include <config.h> 21#include <config.h>
22 22
23#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) 23#if !(defined _WIN32 && !defined __CYGWIN__)
24/* Unix API. */ 24/* Unix API. */
25 25
26/* Specification. */ 26/* Specification. */
diff --git a/gl/getline.c b/gl/getline.c
new file mode 100644
index 00000000..85f16ab8
--- /dev/null
+++ b/gl/getline.c
@@ -0,0 +1,27 @@
1/* getline.c --- Implementation of replacement getline function.
2 Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Simon Josefsson. */
18
19#include <config.h>
20
21#include <stdio.h>
22
23ssize_t
24getline (char **lineptr, size_t *n, FILE *stream)
25{
26 return getdelim (lineptr, n, '\n', stream);
27}
diff --git a/gl/getloadavg.c b/gl/getloadavg.c
index 6e228191..59b53e79 100644
--- a/gl/getloadavg.c
+++ b/gl/getloadavg.c
@@ -1,6 +1,6 @@
1/* Get the system load averages. 1/* Get the system load averages.
2 2
3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2013 Free Software 3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 NOTE: The canonical source of this file is maintained with gnulib. 6 NOTE: The canonical source of this file is maintained with gnulib.
@@ -8,7 +8,7 @@
8 8
9 This program is free software: you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or 11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
14 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
@@ -17,7 +17,7 @@
17 GNU General Public License for more details. 17 GNU General Public License for more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 20 along with this program. If not, see <https://www.gnu.org/licenses/>. */
21 21
22/* Compile-time symbols that this file uses: 22/* Compile-time symbols that this file uses:
23 23
@@ -47,29 +47,25 @@
47 N_NAME_POINTER The nlist n_name element is a pointer, 47 N_NAME_POINTER The nlist n_name element is a pointer,
48 not an array. 48 not an array.
49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'. 49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
50 LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing 50 LINUX_LDAV_FILE [__linux__, __ANDROID__, __CYGWIN__]: File
51 load averages. 51 containing load averages.
52 52
53 Specific system predefines this file uses, aside from setting 53 Specific system predefines this file uses, aside from setting
54 default values if not emacs: 54 default values if not emacs:
55 55
56 apollo 56 apollo
57 BSD Real BSD, not just BSD-like. 57 BSD Real BSD, not just BSD-like.
58 convex
59 DGUX 58 DGUX
60 eunice UNIX emulator under VMS. 59 eunice UNIX emulator under VMS.
61 hpux 60 hpux
62 __MSDOS__ No-op for MSDOS. 61 __MSDOS__ No-op for MSDOS.
63 NeXT 62 NeXT
64 sgi 63 sgi
65 sequent Sequent Dynix 3.x.x (BSD)
66 _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
67 sony_news NEWS-OS (works at least for 4.1C)
68 UMAX 64 UMAX
69 UMAX4_3 65 UMAX4_3
70 VMS 66 VMS
71 WINDOWS32 No-op for Windows95/NT. 67 _WIN32 Native Windows (possibly also defined on Cygwin)
72 __linux__ Linux: assumes /proc file system mounted. 68 __linux__, __ANDROID__ Linux: assumes /proc file system mounted.
73 Support from Michael K. Johnson. 69 Support from Michael K. Johnson.
74 __CYGWIN__ Cygwin emulates linux /proc/loadavg. 70 __CYGWIN__ Cygwin emulates linux /proc/loadavg.
75 __NetBSD__ NetBSD: assumes /kern file system mounted. 71 __NetBSD__ NetBSD: assumes /kern file system mounted.
@@ -86,7 +82,6 @@
86#include <stdlib.h> 82#include <stdlib.h>
87 83
88#include <errno.h> 84#include <errno.h>
89#include <stdbool.h>
90#include <stdio.h> 85#include <stdio.h>
91 86
92# include <sys/types.h> 87# include <sys/types.h>
@@ -97,9 +92,8 @@
97 92
98# include "intprops.h" 93# include "intprops.h"
99 94
100# if !defined (BSD) && defined (ultrix) 95# if defined _WIN32 && ! defined __CYGWIN__ && ! defined WINDOWS32
101/* Ultrix behaves like BSD on Vaxen. */ 96# define WINDOWS32
102# define BSD
103# endif 97# endif
104 98
105# ifdef NeXT 99# ifdef NeXT
@@ -141,10 +135,6 @@
141# define MORE_BSD 135# define MORE_BSD
142# endif 136# endif
143 137
144# if defined (ultrix) && defined (mips)
145# define decstation
146# endif
147
148# if defined (__SVR4) && !defined (SVR4) 138# if defined (__SVR4) && !defined (SVR4)
149# define SVR4 139# define SVR4
150# endif 140# endif
@@ -168,13 +158,6 @@
168# include <sys/table.h> 158# include <sys/table.h>
169# endif 159# endif
170 160
171/* UTek's /bin/cc on the 4300 has no architecture specific cpp define by
172 default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine
173 that with a couple of other things and we'll have a unique match. */
174# if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
175# define tek4300 /* Define by emacs, but not by other users. */
176# endif
177
178 161
179/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */ 162/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */
180# ifndef LOAD_AVE_TYPE 163# ifndef LOAD_AVE_TYPE
@@ -187,14 +170,6 @@
187# define LOAD_AVE_TYPE long 170# define LOAD_AVE_TYPE long
188# endif 171# endif
189 172
190# ifdef decstation
191# define LOAD_AVE_TYPE long
192# endif
193
194# ifdef _SEQUENT_
195# define LOAD_AVE_TYPE long
196# endif
197
198# ifdef sgi 173# ifdef sgi
199# define LOAD_AVE_TYPE long 174# define LOAD_AVE_TYPE long
200# endif 175# endif
@@ -203,41 +178,14 @@
203# define LOAD_AVE_TYPE long 178# define LOAD_AVE_TYPE long
204# endif 179# endif
205 180
206# ifdef sony_news
207# define LOAD_AVE_TYPE long
208# endif
209
210# ifdef sequent
211# define LOAD_AVE_TYPE long
212# endif
213
214# ifdef OSF_ALPHA 181# ifdef OSF_ALPHA
215# define LOAD_AVE_TYPE long 182# define LOAD_AVE_TYPE long
216# endif 183# endif
217 184
218# if defined (ardent) && defined (titan)
219# define LOAD_AVE_TYPE long
220# endif
221
222# ifdef tek4300
223# define LOAD_AVE_TYPE long
224# endif
225
226# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
227# define LOAD_AVE_TYPE long
228# endif
229
230# if defined _AIX && ! defined HAVE_LIBPERFSTAT 185# if defined _AIX && ! defined HAVE_LIBPERFSTAT
231# define LOAD_AVE_TYPE long 186# define LOAD_AVE_TYPE long
232# endif 187# endif
233 188
234# ifdef convex
235# define LOAD_AVE_TYPE double
236# ifndef LDAV_CVT
237# define LDAV_CVT(n) (n)
238# endif
239# endif
240
241# endif /* No LOAD_AVE_TYPE. */ 189# endif /* No LOAD_AVE_TYPE. */
242 190
243# ifdef OSF_ALPHA 191# ifdef OSF_ALPHA
@@ -247,13 +195,6 @@
247# define FSCALE 1024.0 195# define FSCALE 1024.0
248# endif 196# endif
249 197
250# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
251/* <sys/param.h> defines an incorrect value for FSCALE on an
252 Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */
253# undef FSCALE
254# define FSCALE 100.0
255# endif
256
257 198
258# ifndef FSCALE 199# ifndef FSCALE
259 200
@@ -263,25 +204,17 @@
263# define FSCALE 2048.0 204# define FSCALE 2048.0
264# endif 205# endif
265 206
266# if defined (MIPS) || defined (SVR4) || defined (decstation) 207# if defined (MIPS) || defined (SVR4)
267# define FSCALE 256 208# define FSCALE 256
268# endif 209# endif
269 210
270# if defined (sgi) || defined (sequent) 211# if defined (sgi)
271/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined 212/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
272 above under #ifdef MIPS. But we want the sgi value. */ 213 above under #ifdef MIPS. But we want the sgi value. */
273# undef FSCALE 214# undef FSCALE
274# define FSCALE 1000.0 215# define FSCALE 1000.0
275# endif 216# endif
276 217
277# if defined (ardent) && defined (titan)
278# define FSCALE 65536.0
279# endif
280
281# ifdef tek4300
282# define FSCALE 100.0
283# endif
284
285# if defined _AIX && !defined HAVE_LIBPERFSTAT 218# if defined _AIX && !defined HAVE_LIBPERFSTAT
286# define FSCALE 65536.0 219# define FSCALE 65536.0
287# endif 220# endif
@@ -303,28 +236,22 @@
303# endif 236# endif
304 237
305 238
306# if !defined (KERNEL_FILE) && defined (sequent)
307# define KERNEL_FILE "/dynix"
308# endif
309
310# if !defined (KERNEL_FILE) && defined (hpux) 239# if !defined (KERNEL_FILE) && defined (hpux)
311# define KERNEL_FILE "/hp-ux" 240# define KERNEL_FILE "/hp-ux"
312# endif 241# endif
313 242
314# if !defined (KERNEL_FILE) && (defined (_SEQUENT_) || defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan))) 243# if !defined (KERNEL_FILE) && (defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi))
315# define KERNEL_FILE "/unix" 244# define KERNEL_FILE "/unix"
316# endif 245# endif
317 246
318 247
319# if !defined (LDAV_SYMBOL) && defined (alliant) 248# if !defined (LDAV_SYMBOL) && (defined (hpux) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
320# define LDAV_SYMBOL "_Loadavg"
321# endif
322
323# if !defined (LDAV_SYMBOL) && ((defined (hpux) && !defined (hp9000s300)) || defined (_SEQUENT_) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
324# define LDAV_SYMBOL "avenrun" 249# define LDAV_SYMBOL "avenrun"
325# endif 250# endif
326 251
327# include <unistd.h> 252# ifdef HAVE_UNISTD_H
253# include <unistd.h>
254# endif
328 255
329/* LOAD_AVE_TYPE should only get defined if we're going to use the 256/* LOAD_AVE_TYPE should only get defined if we're going to use the
330 nlist method. */ 257 nlist method. */
@@ -335,7 +262,7 @@
335# ifdef LOAD_AVE_TYPE 262# ifdef LOAD_AVE_TYPE
336 263
337# ifndef __VMS 264# ifndef __VMS
338# ifndef __linux__ 265# if !(defined __linux__ || defined __ANDROID__)
339# ifndef NLIST_STRUCT 266# ifndef NLIST_STRUCT
340# include <a.out.h> 267# include <a.out.h>
341# else /* NLIST_STRUCT */ 268# else /* NLIST_STRUCT */
@@ -358,7 +285,7 @@
358# ifndef LDAV_SYMBOL 285# ifndef LDAV_SYMBOL
359# define LDAV_SYMBOL "_avenrun" 286# define LDAV_SYMBOL "_avenrun"
360# endif /* LDAV_SYMBOL */ 287# endif /* LDAV_SYMBOL */
361# endif /* __linux__ */ 288# endif /* __linux__ || __ANDROID__ */
362 289
363# else /* __VMS */ 290# else /* __VMS */
364 291
@@ -431,7 +358,8 @@
431# include <sys/dg_sys_info.h> 358# include <sys/dg_sys_info.h>
432# endif 359# endif
433 360
434# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5 \ 361# if (defined __linux__ || defined __ANDROID__ \
362 || defined __CYGWIN__ || defined SUNOS_5 \
435 || (defined LOAD_AVE_TYPE && ! defined __VMS)) 363 || (defined LOAD_AVE_TYPE && ! defined __VMS))
436# include <fcntl.h> 364# include <fcntl.h>
437# endif 365# endif
@@ -460,7 +388,7 @@ static bool getloadavg_initialized;
460/* Offset in kmem to seek to read load average, or 0 means invalid. */ 388/* Offset in kmem to seek to read load average, or 0 means invalid. */
461static long offset; 389static long offset;
462 390
463# if ! defined __VMS && ! defined sgi && ! defined __linux__ 391# if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined __ANDROID__)
464static struct nlist name_list[2]; 392static struct nlist name_list[2];
465# endif 393# endif
466 394
@@ -495,17 +423,17 @@ getloadavg (double loadavg[], int nelem)
495 int saved_errno; 423 int saved_errno;
496 424
497 kc = kstat_open (); 425 kc = kstat_open ();
498 if (kc == 0) 426 if (kc == NULL)
499 return -1; 427 return -1;
500 ksp = kstat_lookup (kc, "unix", 0, "system_misc"); 428 ksp = kstat_lookup (kc, "unix", 0, "system_misc");
501 if (ksp == 0) 429 if (ksp == NULL)
502 return -1; 430 return -1;
503 if (kstat_read (kc, ksp, 0) == -1) 431 if (kstat_read (kc, ksp, 0) == -1)
504 return -1; 432 return -1;
505 433
506 434
507 kn = kstat_data_lookup (ksp, "avenrun_1min"); 435 kn = kstat_data_lookup (ksp, "avenrun_1min");
508 if (kn == 0) 436 if (kn == NULL)
509 { 437 {
510 /* Return -1 if no load average information is available. */ 438 /* Return -1 if no load average information is available. */
511 nelem = 0; 439 nelem = 0;
@@ -518,14 +446,14 @@ getloadavg (double loadavg[], int nelem)
518 if (nelem >= 2) 446 if (nelem >= 2)
519 { 447 {
520 kn = kstat_data_lookup (ksp, "avenrun_5min"); 448 kn = kstat_data_lookup (ksp, "avenrun_5min");
521 if (kn != 0) 449 if (kn != NULL)
522 { 450 {
523 loadavg[elem++] = (double) kn->value.ul / FSCALE; 451 loadavg[elem++] = (double) kn->value.ul / FSCALE;
524 452
525 if (nelem >= 3) 453 if (nelem >= 3)
526 { 454 {
527 kn = kstat_data_lookup (ksp, "avenrun_15min"); 455 kn = kstat_data_lookup (ksp, "avenrun_15min");
528 if (kn != 0) 456 if (kn != NULL)
529 loadavg[elem++] = (double) kn->value.ul / FSCALE; 457 loadavg[elem++] = (double) kn->value.ul / FSCALE;
530 } 458 }
531 } 459 }
@@ -570,8 +498,8 @@ getloadavg (double loadavg[], int nelem)
570 } 498 }
571# endif 499# endif
572 500
573# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__)) 501# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__)
574 /* Linux without glibc, Cygwin */ 502 /* Linux without glibc, Android, Cygwin */
575# define LDAV_DONE 503# define LDAV_DONE
576# undef LOAD_AVE_TYPE 504# undef LOAD_AVE_TYPE
577 505
@@ -583,7 +511,7 @@ getloadavg (double loadavg[], int nelem)
583 char const *ptr = ldavgbuf; 511 char const *ptr = ldavgbuf;
584 int fd, count, saved_errno; 512 int fd, count, saved_errno;
585 513
586 fd = open (LINUX_LDAV_FILE, O_RDONLY); 514 fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC);
587 if (fd == -1) 515 if (fd == -1)
588 return -1; 516 return -1;
589 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1); 517 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
@@ -621,12 +549,12 @@ getloadavg (double loadavg[], int nelem)
621 for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++) 549 for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
622 numerator = 10 * numerator + (*ptr - '0'), denominator *= 10; 550 numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
623 551
624 loadavg[elem++] = numerator / denominator; 552 loadavg[elem] = numerator / denominator;
625 } 553 }
626 554
627 return elem; 555 return elem;
628 556
629# endif /* __linux__ || __CYGWIN__ */ 557# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */
630 558
631# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */ 559# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */
632# define LDAV_DONE 560# define LDAV_DONE
@@ -638,15 +566,22 @@ getloadavg (double loadavg[], int nelem)
638 566
639 unsigned long int load_ave[3], scale; 567 unsigned long int load_ave[3], scale;
640 int count; 568 int count;
641 FILE *fp; 569 char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
642 570 int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC);
643 fp = fopen (NETBSD_LDAV_FILE, "r"); 571 if (fd < 0)
644 if (fp == NULL) 572 return fd;
645 return -1; 573 int nread = read (fd, readbuf, sizeof readbuf - 1);
646 count = fscanf (fp, "%lu %lu %lu %lu\n", 574 int err = errno;
575 close (fd);
576 if (nread < 0)
577 {
578 errno = err;
579 return -1;
580 }
581 readbuf[nread] = '\0';
582 count = sscanf (readbuf, "%lu %lu %lu %lu\n",
647 &load_ave[0], &load_ave[1], &load_ave[2], 583 &load_ave[0], &load_ave[1], &load_ave[2],
648 &scale); 584 &scale);
649 (void) fclose (fp);
650 if (count != 4) 585 if (count != 4)
651 { 586 {
652 errno = ENOTSUP; 587 errno = ENOTSUP;
@@ -915,7 +850,7 @@ getloadavg (double loadavg[], int nelem)
915 850
916# ifndef SUNOS_5 851# ifndef SUNOS_5
917 if ( 852 if (
918# if !(defined (_AIX) && !defined (ps2)) 853# if !defined (_AIX)
919 nlist (KERNEL_FILE, name_list) 854 nlist (KERNEL_FILE, name_list)
920# else /* _AIX */ 855# else /* _AIX */
921 knlist (name_list, 1, sizeof (name_list[0])) 856 knlist (name_list, 1, sizeof (name_list[0]))
@@ -940,33 +875,17 @@ getloadavg (double loadavg[], int nelem)
940 if (!getloadavg_initialized) 875 if (!getloadavg_initialized)
941 { 876 {
942# ifndef SUNOS_5 877# ifndef SUNOS_5
943 /* Set the channel to close on exec, so it does not
944 litter any child's descriptor table. */
945# ifndef O_CLOEXEC
946# define O_CLOEXEC 0
947# endif
948 int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC); 878 int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
949 if (0 <= fd) 879 if (0 <= fd)
950 { 880 {
951# if F_DUPFD_CLOEXEC 881 channel = fd;
952 if (fd <= STDERR_FILENO) 882 getloadavg_initialized = true;
953 {
954 int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
955 close (fd);
956 fd = fd1;
957 }
958# endif
959 if (0 <= fd)
960 {
961 channel = fd;
962 getloadavg_initialized = true;
963 }
964 } 883 }
965# else /* SUNOS_5 */ 884# else /* SUNOS_5 */
966 /* We pass 0 for the kernel, corefile, and swapfile names 885 /* We pass 0 for the kernel, corefile, and swapfile names
967 to use the currently running kernel. */ 886 to use the currently running kernel. */
968 kd = kvm_open (0, 0, 0, O_RDONLY, 0); 887 kd = kvm_open (0, 0, 0, O_RDONLY, 0);
969 if (kd != 0) 888 if (kd != NULL)
970 { 889 {
971 /* nlist the currently running kernel. */ 890 /* nlist the currently running kernel. */
972 kvm_nlist (kd, name_list); 891 kvm_nlist (kd, name_list);
diff --git a/gl/getopt-cdefs.in.h b/gl/getopt-cdefs.in.h
new file mode 100644
index 00000000..e76c78cb
--- /dev/null
+++ b/gl/getopt-cdefs.in.h
@@ -0,0 +1,66 @@
1/* getopt-on-non-glibc compatibility macros.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_CDEFS_H
21#define _GETOPT_CDEFS_H 1
22
23/* This header should not be used directly; include getopt.h or
24 unistd.h instead. It does not have a protective #error, because
25 the guard macro for getopt.h in gnulib is not fixed. */
26
27/* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
28 a number of the internal macros supplied to GNU libc's headers by
29 sys/cdefs.h. Provide fallback definitions for all of them. */
30#if @HAVE_SYS_CDEFS_H@
31# include <sys/cdefs.h>
32#endif
33
34#ifndef __BEGIN_DECLS
35# ifdef __cplusplus
36# define __BEGIN_DECLS extern "C" {
37# else
38# define __BEGIN_DECLS /* nothing */
39# endif
40#endif
41#ifndef __END_DECLS
42# ifdef __cplusplus
43# define __END_DECLS }
44# else
45# define __END_DECLS /* nothing */
46# endif
47#endif
48
49#ifndef __GNUC_PREREQ
50# if defined __GNUC__ && defined __GNUC_VERSION__
51# define __GNUC_PREREQ(maj, min) \
52 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
53# else
54# define __GNUC_PREREQ(maj, min) 0
55# endif
56#endif
57
58#ifndef __THROW
59# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
60# define __THROW throw ()
61# else
62# define __THROW
63# endif
64#endif
65
66#endif /* _GETOPT_CDEFS_H */
diff --git a/gl/getopt-core.h b/gl/getopt-core.h
new file mode 100644
index 00000000..c5dd4936
--- /dev/null
+++ b/gl/getopt-core.h
@@ -0,0 +1,96 @@
1/* Declarations for getopt (basic, portable features only).
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_CORE_H
21#define _GETOPT_CORE_H 1
22
23/* This header should not be used directly; include getopt.h or
24 unistd.h instead. Unlike most bits headers, it does not have
25 a protective #error, because the guard macro for getopt.h in
26 gnulib is not fixed. */
27
28__BEGIN_DECLS
29
30/* For communication from 'getopt' to the caller.
31 When 'getopt' finds an option that takes an argument,
32 the argument value is returned here.
33 Also, when 'ordering' is RETURN_IN_ORDER,
34 each non-option ARGV-element is returned here. */
35
36extern char *optarg;
37
38/* Index in ARGV of the next element to be scanned.
39 This is used for communication to and from the caller
40 and for communication between successive calls to 'getopt'.
41
42 On entry to 'getopt', zero means this is the first call; initialize.
43
44 When 'getopt' returns -1, this is the index of the first of the
45 non-option elements that the caller should itself scan.
46
47 Otherwise, 'optind' communicates from one call to the next
48 how much of ARGV has been scanned so far. */
49
50extern int optind;
51
52/* Callers store zero here to inhibit the error message 'getopt' prints
53 for unrecognized options. */
54
55extern int opterr;
56
57/* Set to an option character which was unrecognized. */
58
59extern int optopt;
60
61/* Get definitions and prototypes for functions to process the
62 arguments in ARGV (ARGC of them, minus the program name) for
63 options given in OPTS.
64
65 Return the option character from OPTS just read. Return -1 when
66 there are no more options. For unrecognized options, or options
67 missing arguments, 'optopt' is set to the option letter, and '?' is
68 returned.
69
70 The OPTS string is a list of characters which are recognized option
71 letters, optionally followed by colons, specifying that that letter
72 takes an argument, to be placed in 'optarg'.
73
74 If a letter in OPTS is followed by two colons, its argument is
75 optional. This behavior is specific to the GNU 'getopt'.
76
77 The argument '--' causes premature termination of argument
78 scanning, explicitly telling 'getopt' that there are no more
79 options.
80
81 If OPTS begins with '-', then non-option arguments are treated as
82 arguments to the option '\1'. This behavior is specific to the GNU
83 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
84 the environment, then do not permute arguments.
85
86 For standards compliance, the 'argv' argument has the type
87 char *const *, but this is inaccurate; if argument permutation is
88 enabled, the argv array (not the strings it points to) must be
89 writable. */
90
91extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
92 __THROW _GL_ARG_NONNULL ((2, 3));
93
94__END_DECLS
95
96#endif /* _GETOPT_CORE_H */
diff --git a/gl/getopt-ext.h b/gl/getopt-ext.h
new file mode 100644
index 00000000..d37c2932
--- /dev/null
+++ b/gl/getopt-ext.h
@@ -0,0 +1,77 @@
1/* Declarations for getopt (GNU extensions).
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_EXT_H
21#define _GETOPT_EXT_H 1
22
23/* This header should not be used directly; include getopt.h instead.
24 Unlike most bits headers, it does not have a protective #error,
25 because the guard macro for getopt.h in gnulib is not fixed. */
26
27__BEGIN_DECLS
28
29/* Describe the long-named options requested by the application.
30 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
31 of 'struct option' terminated by an element containing a name which is
32 zero.
33
34 The field 'has_arg' is:
35 no_argument (or 0) if the option does not take an argument,
36 required_argument (or 1) if the option requires an argument,
37 optional_argument (or 2) if the option takes an optional argument.
38
39 If the field 'flag' is not NULL, it points to a variable that is set
40 to the value given in the field 'val' when the option is found, but
41 left unchanged if the option is not found.
42
43 To have a long-named option do something other than set an 'int' to
44 a compiled-in constant, such as set a value from 'optarg', set the
45 option's 'flag' field to zero and its 'val' field to a nonzero
46 value (the equivalent single-letter option character, if there is
47 one). For long options that have a zero 'flag' field, 'getopt'
48 returns the contents of the 'val' field. */
49
50struct option
51{
52 const char *name;
53 /* has_arg can't be an enum because some compilers complain about
54 type mismatches in all the code that assumes it is an int. */
55 int has_arg;
56 int *flag;
57 int val;
58};
59
60/* Names for the values of the 'has_arg' field of 'struct option'. */
61
62#define no_argument 0
63#define required_argument 1
64#define optional_argument 2
65
66extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
67 const char *__shortopts,
68 const struct option *__longopts, int *__longind)
69 __THROW _GL_ARG_NONNULL ((2, 3));
70extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
71 const char *__shortopts,
72 const struct option *__longopts, int *__longind)
73 __THROW _GL_ARG_NONNULL ((2, 3));
74
75__END_DECLS
76
77#endif /* _GETOPT_EXT_H */
diff --git a/gl/getopt-pfx-core.h b/gl/getopt-pfx-core.h
new file mode 100644
index 00000000..3a2fde5a
--- /dev/null
+++ b/gl/getopt-pfx-core.h
@@ -0,0 +1,66 @@
1/* getopt (basic, portable features) gnulib wrapper header.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_PFX_CORE_H
21#define _GETOPT_PFX_CORE_H 1
22
23/* This header should not be used directly; include getopt.h or
24 unistd.h instead. It does not have a protective #error, because
25 the guard macro for getopt.h in gnulib is not fixed. */
26
27/* Standalone applications should #define __GETOPT_PREFIX to an
28 identifier that prefixes the external functions and variables
29 defined in getopt-core.h and getopt-ext.h. Systematically
30 rename identifiers so that they do not collide with the system
31 functions and variables. Renaming avoids problems with some
32 compilers and linkers. */
33#ifdef __GETOPT_PREFIX
34# ifndef __GETOPT_ID
35# define __GETOPT_CONCAT(x, y) x ## y
36# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
37# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
38# endif
39# undef getopt
40# undef optarg
41# undef opterr
42# undef optind
43# undef optopt
44# define getopt __GETOPT_ID (getopt)
45# define optarg __GETOPT_ID (optarg)
46# define opterr __GETOPT_ID (opterr)
47# define optind __GETOPT_ID (optind)
48# define optopt __GETOPT_ID (optopt)
49
50/* Work around a a problem on macOS, which declares getopt with a
51 trailing __DARWIN_ALIAS(getopt) that would expand to something like
52 __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
53 hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */
54# ifdef __APPLE__
55# define _GETOPT
56# endif
57
58/* The system's getopt.h may have already included getopt-core.h to
59 declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
60 getopt-core.h declares them with prefixes. */
61# undef _GETOPT_CORE_H
62#endif
63
64#include <getopt-core.h>
65
66#endif /* _GETOPT_PFX_CORE_H */
diff --git a/gl/getopt-pfx-ext.h b/gl/getopt-pfx-ext.h
new file mode 100644
index 00000000..8578d725
--- /dev/null
+++ b/gl/getopt-pfx-ext.h
@@ -0,0 +1,70 @@
1/* getopt (GNU extensions) gnulib wrapper header.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_PFX_EXT_H
21#define _GETOPT_PFX_EXT_H 1
22
23/* This header should not be used directly; include getopt.h instead.
24 It does not have a protective #error, because the guard macro for
25 getopt.h in gnulib is not fixed. */
26
27/* Standalone applications should #define __GETOPT_PREFIX to an
28 identifier that prefixes the external functions and variables
29 defined in getopt-core.h and getopt-ext.h. Systematically
30 rename identifiers so that they do not collide with the system
31 functions and variables. Renaming avoids problems with some
32 compilers and linkers. */
33#ifdef __GETOPT_PREFIX
34# ifndef __GETOPT_ID
35# define __GETOPT_CONCAT(x, y) x ## y
36# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
37# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
38# endif
39# undef getopt_long
40# undef getopt_long_only
41# undef option
42# undef _getopt_internal
43# define getopt_long __GETOPT_ID (getopt_long)
44# define getopt_long_only __GETOPT_ID (getopt_long_only)
45# define option __GETOPT_ID (option)
46# define _getopt_internal __GETOPT_ID (getopt_internal)
47
48/* The system's getopt.h may have already included getopt-ext.h to
49 declare the unprefixed identifiers. Undef _GETOPT_EXT_H so that
50 getopt-ext.h declares them with prefixes. */
51# undef _GETOPT_EXT_H
52#endif
53
54/* Standalone applications get correct prototypes for getopt_long and
55 getopt_long_only; they declare "char **argv". For backward
56 compatibility with old applications, if __GETOPT_PREFIX is not
57 defined, we supply GNU-libc-compatible, but incorrect, prototypes
58 using "char *const *argv". (GNU libc is stuck with the incorrect
59 prototypes, as they are baked into older versions of LSB.) */
60#ifndef __getopt_argv_const
61# if defined __GETOPT_PREFIX
62# define __getopt_argv_const /* empty */
63# else
64# define __getopt_argv_const const
65# endif
66#endif
67
68#include <getopt-ext.h>
69
70#endif /* _GETOPT_PFX_EXT_H */
diff --git a/gl/getopt.c b/gl/getopt.c
index ef0f4cee..1e2441c4 100644
--- a/gl/getopt.c
+++ b/gl/getopt.c
@@ -1,23 +1,21 @@
1/* Getopt for GNU. 1/* Getopt for GNU.
2 NOTE: getopt is part of the C library, so if you don't know what 2 Copyright (C) 1987-2023 Free Software Foundation, Inc.
3 "Keep this file name-space clean" means, talk to drepper@gnu.org 3 This file is part of the GNU C Library and is also part of gnulib.
4 before changing it! 4 Patches to this file should be submitted to both projects.
5 Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2013 Free Software 5
6 Foundation, Inc. 6 The GNU C Library is free software; you can redistribute it and/or
7 This file is part of the GNU C Library. 7 modify it under the terms of the GNU Lesser General Public
8 8 License as published by the Free Software Foundation; either
9 This program is free software: you can redistribute it and/or modify 9 version 2.1 of the License, or (at your option) any later version.
10 it under the terms of the GNU General Public License as published by 10
11 the Free Software Foundation; either version 3 of the License, or 11 The GNU C Library is distributed in the hope that it will be useful,
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 GNU General Public License for more details. 14 Lesser General Public License for more details.
18 15
19 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
21 19
22#ifndef _LIBC 20#ifndef _LIBC
23# include <config.h> 21# include <config.h>
@@ -31,30 +29,54 @@
31#include <unistd.h> 29#include <unistd.h>
32 30
33#ifdef _LIBC 31#ifdef _LIBC
32/* When used as part of glibc, error printing must be done differently
33 for standards compliance. getopt is not a cancellation point, so
34 it must not call functions that are, and it is specified by an
35 older standard than stdio locking, so it must not refer to
36 functions in the "user namespace" related to stdio locking.
37 Finally, it must use glibc's internal message translation so that
38 the messages are looked up in the proper text domain. */
34# include <libintl.h> 39# include <libintl.h>
40# define fprintf __fxprintf_nocancel
41# define flockfile(fp) _IO_flockfile (fp)
42# define funlockfile(fp) _IO_funlockfile (fp)
35#else 43#else
36# include "gettext.h" 44# include "gettext.h"
37# define _(msgid) gettext (msgid) 45# define _(msgid) gettext (msgid)
46/* When used standalone, flockfile and funlockfile might not be
47 available. */
48# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
49 || (defined _WIN32 && ! defined __CYGWIN__))
50# define flockfile(fp) /* nop */
51# define funlockfile(fp) /* nop */
52# endif
53/* When used standalone, do not attempt to use alloca. */
54# define __libc_use_alloca(size) 0
55# undef alloca
56# define alloca(size) (abort (), (void *)0)
38#endif 57#endif
39 58
40#if defined _LIBC && defined USE_IN_LIBIO 59/* This implementation of 'getopt' has three modes for handling
41# include <wchar.h> 60 options interspersed with non-option arguments. It can stop
42#endif 61 scanning for options at the first non-option argument encountered,
43 62 as POSIX specifies. It can continue scanning for options after the
44/* This version of 'getopt' appears to the caller like standard Unix 'getopt' 63 first non-option argument, but permute 'argv' as it goes so that,
45 but it behaves differently for the user, since it allows the user 64 after 'getopt' is done, all the options precede all the non-option
46 to intersperse the options with the other arguments. 65 arguments and 'optind' points to the first non-option argument.
47 66 Or, it can report non-option arguments as if they were arguments to
48 As 'getopt_long' works, it permutes the elements of ARGV so that, 67 the option character '\x01'.
49 when it is done, all the options precede everything else. Thus 68
50 all application programs are extended to handle flexible argument order. 69 The default behavior of 'getopt_long' is to permute the argument list.
51 70 When this implementation is used standalone, the default behavior of
52 Using 'getopt' or setting the environment variable POSIXLY_CORRECT 71 'getopt' is to stop at the first non-option argument, but when it is
72 used as part of GNU libc it also permutes the argument list. In both
73 cases, setting the environment variable POSIXLY_CORRECT to any value
53 disables permutation. 74 disables permutation.
54 Then the behavior is completely standard.
55 75
56 GNU application programs can use a third alternative mode in which 76 If the first character of the OPTSTRING argument to 'getopt' or
57 they can distinguish the relative order of options and other arguments. */ 77 'getopt_long' is '+', both functions will stop at the first
78 non-option argument. If it is '-', both functions will report
79 non-option arguments as arguments to the option character '\x01'. */
58 80
59#include "getopt_int.h" 81#include "getopt_int.h"
60 82
@@ -95,42 +117,7 @@ int optopt = '?';
95/* Keep a global copy of all internal members of getopt_data. */ 117/* Keep a global copy of all internal members of getopt_data. */
96 118
97static struct _getopt_data getopt_data; 119static struct _getopt_data getopt_data;
98
99
100#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV
101extern char *getenv ();
102#endif
103 120
104#ifdef _LIBC
105/* Stored original parameters.
106 XXX This is no good solution. We should rather copy the args so
107 that we can compare them later. But we must not use malloc(3). */
108extern int __libc_argc;
109extern char **__libc_argv;
110
111/* Bash 2.0 gives us an environment variable containing flags
112 indicating ARGV elements that should not be considered arguments. */
113
114# ifdef USE_NONOPTION_FLAGS
115/* Defined in getopt_init.c */
116extern char *__getopt_nonoption_flags;
117# endif
118
119# ifdef USE_NONOPTION_FLAGS
120# define SWAP_FLAGS(ch1, ch2) \
121 if (d->__nonoption_flags_len > 0) \
122 { \
123 char __tmp = __getopt_nonoption_flags[ch1]; \
124 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
125 __getopt_nonoption_flags[ch2] = __tmp; \
126 }
127# else
128# define SWAP_FLAGS(ch1, ch2)
129# endif
130#else /* !_LIBC */
131# define SWAP_FLAGS(ch1, ch2)
132#endif /* _LIBC */
133
134/* Exchange two adjacent subsequences of ARGV. 121/* Exchange two adjacent subsequences of ARGV.
135 One subsequence is elements [first_nonopt,last_nonopt) 122 One subsequence is elements [first_nonopt,last_nonopt)
136 which contains all the non-options that have been skipped so far. 123 which contains all the non-options that have been skipped so far.
@@ -153,64 +140,40 @@ exchange (char **argv, struct _getopt_data *d)
153 It leaves the longer segment in the right place overall, 140 It leaves the longer segment in the right place overall,
154 but it consists of two parts that need to be swapped next. */ 141 but it consists of two parts that need to be swapped next. */
155 142
156#if defined _LIBC && defined USE_NONOPTION_FLAGS
157 /* First make sure the handling of the '__getopt_nonoption_flags'
158 string can work normally. Our top argument must be in the range
159 of the string. */
160 if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
161 {
162 /* We must extend the array. The user plays games with us and
163 presents new arguments. */
164 char *new_str = malloc (top + 1);
165 if (new_str == NULL)
166 d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
167 else
168 {
169 memset (__mempcpy (new_str, __getopt_nonoption_flags,
170 d->__nonoption_flags_max_len),
171 '\0', top + 1 - d->__nonoption_flags_max_len);
172 d->__nonoption_flags_max_len = top + 1;
173 __getopt_nonoption_flags = new_str;
174 }
175 }
176#endif
177
178 while (top > middle && middle > bottom) 143 while (top > middle && middle > bottom)
179 { 144 {
180 if (top - middle > middle - bottom) 145 if (top - middle > middle - bottom)
181 { 146 {
182 /* Bottom segment is the short one. */ 147 /* Bottom segment is the short one. */
183 int len = middle - bottom; 148 int len = middle - bottom;
184 register int i; 149 int i;
185 150
186 /* Swap it with the top part of the top segment. */ 151 /* Swap it with the top part of the top segment. */
187 for (i = 0; i < len; i++) 152 for (i = 0; i < len; i++)
188 { 153 {
189 tem = argv[bottom + i]; 154 tem = argv[bottom + i];
190 argv[bottom + i] = argv[top - (middle - bottom) + i]; 155 argv[bottom + i] = argv[top - (middle - bottom) + i];
191 argv[top - (middle - bottom) + i] = tem; 156 argv[top - (middle - bottom) + i] = tem;
192 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); 157 }
193 } 158 /* Exclude the moved bottom segment from further swapping. */
194 /* Exclude the moved bottom segment from further swapping. */ 159 top -= len;
195 top -= len; 160 }
196 }
197 else 161 else
198 { 162 {
199 /* Top segment is the short one. */ 163 /* Top segment is the short one. */
200 int len = top - middle; 164 int len = top - middle;
201 register int i; 165 int i;
202 166
203 /* Swap it with the bottom part of the bottom segment. */ 167 /* Swap it with the bottom part of the bottom segment. */
204 for (i = 0; i < len; i++) 168 for (i = 0; i < len; i++)
205 { 169 {
206 tem = argv[bottom + i]; 170 tem = argv[bottom + i];
207 argv[bottom + i] = argv[middle + i]; 171 argv[bottom + i] = argv[middle + i];
208 argv[middle + i] = tem; 172 argv[middle + i] = tem;
209 SWAP_FLAGS (bottom + i, middle + i); 173 }
210 } 174 /* Exclude the moved top segment from further swapping. */
211 /* Exclude the moved top segment from further swapping. */ 175 bottom += len;
212 bottom += len; 176 }
213 }
214 } 177 }
215 178
216 /* Update records for the slots the non-options now occupy. */ 179 /* Update records for the slots the non-options now occupy. */
@@ -219,25 +182,216 @@ exchange (char **argv, struct _getopt_data *d)
219 d->__last_nonopt = d->optind; 182 d->__last_nonopt = d->optind;
220} 183}
221 184
222/* Initialize the internal data when the first call is made. */ 185/* Process the argument starting with d->__nextchar as a long option.
186 d->optind should *not* have been advanced over this argument.
187
188 If the value returned is -1, it was not actually a long option, the
189 state is unchanged, and the argument should be processed as a set
190 of short options (this can only happen when long_only is true).
191 Otherwise, the option (and its argument, if any) have been consumed
192 and the return value is the value to return from _getopt_internal_r. */
193static int
194process_long_option (int argc, char **argv, const char *optstring,
195 const struct option *longopts, int *longind,
196 int long_only, struct _getopt_data *d,
197 int print_errors, const char *prefix)
198{
199 char *nameend;
200 size_t namelen;
201 const struct option *p;
202 const struct option *pfound = NULL;
203 int n_options;
204 int option_index;
205
206 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
207 /* Do nothing. */ ;
208 namelen = nameend - d->__nextchar;
209
210 /* First look for an exact match, counting the options as a side
211 effect. */
212 for (p = longopts, n_options = 0; p->name; p++, n_options++)
213 if (!strncmp (p->name, d->__nextchar, namelen)
214 && namelen == strlen (p->name))
215 {
216 /* Exact match found. */
217 pfound = p;
218 option_index = n_options;
219 break;
220 }
221
222 if (pfound == NULL)
223 {
224 /* Didn't find an exact match, so look for abbreviations. */
225 unsigned char *ambig_set = NULL;
226 int ambig_malloced = 0;
227 int ambig_fallback = 0;
228 int indfound = -1;
229
230 for (p = longopts, option_index = 0; p->name; p++, option_index++)
231 if (!strncmp (p->name, d->__nextchar, namelen))
232 {
233 if (pfound == NULL)
234 {
235 /* First nonexact match found. */
236 pfound = p;
237 indfound = option_index;
238 }
239 else if (long_only
240 || pfound->has_arg != p->has_arg
241 || pfound->flag != p->flag
242 || pfound->val != p->val)
243 {
244 /* Second or later nonexact match found. */
245 if (!ambig_fallback)
246 {
247 if (!print_errors)
248 /* Don't waste effort tracking the ambig set if
249 we're not going to print it anyway. */
250 ambig_fallback = 1;
251 else if (!ambig_set)
252 {
253 if (__libc_use_alloca (n_options))
254 ambig_set = alloca (n_options);
255 else if ((ambig_set = malloc (n_options)) == NULL)
256 /* Fall back to simpler error message. */
257 ambig_fallback = 1;
258 else
259 ambig_malloced = 1;
260
261 if (ambig_set)
262 {
263 memset (ambig_set, 0, n_options);
264 ambig_set[indfound] = 1;
265 }
266 }
267 if (ambig_set)
268 ambig_set[option_index] = 1;
269 }
270 }
271 }
272
273 if (ambig_set || ambig_fallback)
274 {
275 if (print_errors)
276 {
277 if (ambig_fallback)
278 fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"),
279 argv[0], prefix, d->__nextchar);
280 else
281 {
282 flockfile (stderr);
283 fprintf (stderr,
284 _("%s: option '%s%s' is ambiguous; possibilities:"),
285 argv[0], prefix, d->__nextchar);
286
287 for (option_index = 0; option_index < n_options; option_index++)
288 if (ambig_set[option_index])
289 fprintf (stderr, " '%s%s'",
290 prefix, longopts[option_index].name);
291
292 /* This must use 'fprintf' even though it's only
293 printing a single character, so that it goes through
294 __fxprintf_nocancel when compiled as part of glibc. */
295 fprintf (stderr, "\n");
296 funlockfile (stderr);
297 }
298 }
299 if (ambig_malloced)
300 free (ambig_set);
301 d->__nextchar += strlen (d->__nextchar);
302 d->optind++;
303 d->optopt = 0;
304 return '?';
305 }
306
307 option_index = indfound;
308 }
309
310 if (pfound == NULL)
311 {
312 /* Can't find it as a long option. If this is not getopt_long_only,
313 or the option starts with '--' or is not a valid short option,
314 then it's an error. */
315 if (!long_only || argv[d->optind][1] == '-'
316 || strchr (optstring, *d->__nextchar) == NULL)
317 {
318 if (print_errors)
319 fprintf (stderr, _("%s: unrecognized option '%s%s'\n"),
320 argv[0], prefix, d->__nextchar);
321
322 d->__nextchar = NULL;
323 d->optind++;
324 d->optopt = 0;
325 return '?';
326 }
327
328 /* Otherwise interpret it as a short option. */
329 return -1;
330 }
331
332 /* We have found a matching long option. Consume it. */
333 d->optind++;
334 d->__nextchar = NULL;
335 if (*nameend)
336 {
337 /* Don't test has_arg with >, because some C compilers don't
338 allow it to be used on enums. */
339 if (pfound->has_arg)
340 d->optarg = nameend + 1;
341 else
342 {
343 if (print_errors)
344 fprintf (stderr,
345 _("%s: option '%s%s' doesn't allow an argument\n"),
346 argv[0], prefix, pfound->name);
347
348 d->optopt = pfound->val;
349 return '?';
350 }
351 }
352 else if (pfound->has_arg == 1)
353 {
354 if (d->optind < argc)
355 d->optarg = argv[d->optind++];
356 else
357 {
358 if (print_errors)
359 fprintf (stderr,
360 _("%s: option '%s%s' requires an argument\n"),
361 argv[0], prefix, pfound->name);
362
363 d->optopt = pfound->val;
364 return optstring[0] == ':' ? ':' : '?';
365 }
366 }
367
368 if (longind != NULL)
369 *longind = option_index;
370 if (pfound->flag)
371 {
372 *(pfound->flag) = pfound->val;
373 return 0;
374 }
375 return pfound->val;
376}
377
378/* Initialize internal data upon the first call to getopt. */
223 379
224static const char * 380static const char *
225_getopt_initialize (int argc _GL_UNUSED, 381_getopt_initialize (_GL_UNUSED int argc,
226 char **argv _GL_UNUSED, const char *optstring, 382 _GL_UNUSED char **argv, const char *optstring,
227 struct _getopt_data *d, int posixly_correct) 383 struct _getopt_data *d, int posixly_correct)
228{ 384{
229 /* Start processing options with ARGV-element 1 (since ARGV-element 0 385 /* Start processing options with ARGV-element 1 (since ARGV-element 0
230 is the program name); the sequence of previously skipped 386 is the program name); the sequence of previously skipped
231 non-option ARGV-elements is empty. */ 387 non-option ARGV-elements is empty. */
388 if (d->optind == 0)
389 d->optind = 1;
232 390
233 d->__first_nonopt = d->__last_nonopt = d->optind; 391 d->__first_nonopt = d->__last_nonopt = d->optind;
234
235 d->__nextchar = NULL; 392 d->__nextchar = NULL;
236 393
237 d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT");
238
239 /* Determine how to handle the ordering of options and nonoptions. */ 394 /* Determine how to handle the ordering of options and nonoptions. */
240
241 if (optstring[0] == '-') 395 if (optstring[0] == '-')
242 { 396 {
243 d->__ordering = RETURN_IN_ORDER; 397 d->__ordering = RETURN_IN_ORDER;
@@ -248,41 +402,12 @@ _getopt_initialize (int argc _GL_UNUSED,
248 d->__ordering = REQUIRE_ORDER; 402 d->__ordering = REQUIRE_ORDER;
249 ++optstring; 403 ++optstring;
250 } 404 }
251 else if (d->__posixly_correct) 405 else if (posixly_correct || !!getenv ("POSIXLY_CORRECT"))
252 d->__ordering = REQUIRE_ORDER; 406 d->__ordering = REQUIRE_ORDER;
253 else 407 else
254 d->__ordering = PERMUTE; 408 d->__ordering = PERMUTE;
255 409
256#if defined _LIBC && defined USE_NONOPTION_FLAGS 410 d->__initialized = 1;
257 if (!d->__posixly_correct
258 && argc == __libc_argc && argv == __libc_argv)
259 {
260 if (d->__nonoption_flags_max_len == 0)
261 {
262 if (__getopt_nonoption_flags == NULL
263 || __getopt_nonoption_flags[0] == '\0')
264 d->__nonoption_flags_max_len = -1;
265 else
266 {
267 const char *orig_str = __getopt_nonoption_flags;
268 int len = d->__nonoption_flags_max_len = strlen (orig_str);
269 if (d->__nonoption_flags_max_len < argc)
270 d->__nonoption_flags_max_len = argc;
271 __getopt_nonoption_flags =
272 (char *) malloc (d->__nonoption_flags_max_len);
273 if (__getopt_nonoption_flags == NULL)
274 d->__nonoption_flags_max_len = -1;
275 else
276 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
277 '\0', d->__nonoption_flags_max_len - len);
278 }
279 }
280 d->__nonoption_flags_len = d->__nonoption_flags_max_len;
281 }
282 else
283 d->__nonoption_flags_len = 0;
284#endif
285
286 return optstring; 411 return optstring;
287} 412}
288 413
@@ -344,8 +469,8 @@ _getopt_initialize (int argc _GL_UNUSED,
344 469
345int 470int
346_getopt_internal_r (int argc, char **argv, const char *optstring, 471_getopt_internal_r (int argc, char **argv, const char *optstring,
347 const struct option *longopts, int *longind, 472 const struct option *longopts, int *longind,
348 int long_only, struct _getopt_data *d, int posixly_correct) 473 int long_only, struct _getopt_data *d, int posixly_correct)
349{ 474{
350 int print_errors = d->opterr; 475 int print_errors = d->opterr;
351 476
@@ -355,431 +480,129 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
355 d->optarg = NULL; 480 d->optarg = NULL;
356 481
357 if (d->optind == 0 || !d->__initialized) 482 if (d->optind == 0 || !d->__initialized)
358 { 483 optstring = _getopt_initialize (argc, argv, optstring, d, posixly_correct);
359 if (d->optind == 0)
360 d->optind = 1; /* Don't scan ARGV[0], the program name. */
361 optstring = _getopt_initialize (argc, argv, optstring, d,
362 posixly_correct);
363 d->__initialized = 1;
364 }
365 else if (optstring[0] == '-' || optstring[0] == '+') 484 else if (optstring[0] == '-' || optstring[0] == '+')
366 optstring++; 485 optstring++;
486
367 if (optstring[0] == ':') 487 if (optstring[0] == ':')
368 print_errors = 0; 488 print_errors = 0;
369 489
370 /* Test whether ARGV[optind] points to a non-option argument. 490 /* Test whether ARGV[optind] points to a non-option argument. */
371 Either it does not have option syntax, or there is an environment flag 491#define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
372 from the shell indicating it is not an option. The later information
373 is only used when the used in the GNU libc. */
374#if defined _LIBC && defined USE_NONOPTION_FLAGS
375# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
376 || (d->optind < d->__nonoption_flags_len \
377 && __getopt_nonoption_flags[d->optind] == '1'))
378#else
379# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
380#endif
381 492
382 if (d->__nextchar == NULL || *d->__nextchar == '\0') 493 if (d->__nextchar == NULL || *d->__nextchar == '\0')
383 { 494 {
384 /* Advance to the next ARGV-element. */ 495 /* Advance to the next ARGV-element. */
385 496
386 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been 497 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
387 moved back by the user (who may also have changed the arguments). */ 498 moved back by the user (who may also have changed the arguments). */
388 if (d->__last_nonopt > d->optind) 499 if (d->__last_nonopt > d->optind)
389 d->__last_nonopt = d->optind; 500 d->__last_nonopt = d->optind;
390 if (d->__first_nonopt > d->optind) 501 if (d->__first_nonopt > d->optind)
391 d->__first_nonopt = d->optind; 502 d->__first_nonopt = d->optind;
392 503
393 if (d->__ordering == PERMUTE) 504 if (d->__ordering == PERMUTE)
394 { 505 {
395 /* If we have just processed some options following some non-options, 506 /* If we have just processed some options following some non-options,
396 exchange them so that the options come first. */ 507 exchange them so that the options come first. */
397 508
398 if (d->__first_nonopt != d->__last_nonopt 509 if (d->__first_nonopt != d->__last_nonopt
399 && d->__last_nonopt != d->optind) 510 && d->__last_nonopt != d->optind)
400 exchange ((char **) argv, d); 511 exchange (argv, d);
401 else if (d->__last_nonopt != d->optind) 512 else if (d->__last_nonopt != d->optind)
402 d->__first_nonopt = d->optind; 513 d->__first_nonopt = d->optind;
403 514
404 /* Skip any additional non-options 515 /* Skip any additional non-options
405 and extend the range of non-options previously skipped. */ 516 and extend the range of non-options previously skipped. */
406 517
407 while (d->optind < argc && NONOPTION_P) 518 while (d->optind < argc && NONOPTION_P)
408 d->optind++; 519 d->optind++;
409 d->__last_nonopt = d->optind; 520 d->__last_nonopt = d->optind;
410 } 521 }
411 522
412 /* The special ARGV-element '--' means premature end of options. 523 /* The special ARGV-element '--' means premature end of options.
413 Skip it like a null option, 524 Skip it like a null option,
414 then exchange with previous non-options as if it were an option, 525 then exchange with previous non-options as if it were an option,
415 then skip everything else like a non-option. */ 526 then skip everything else like a non-option. */
416 527
417 if (d->optind != argc && !strcmp (argv[d->optind], "--")) 528 if (d->optind != argc && !strcmp (argv[d->optind], "--"))
418 { 529 {
419 d->optind++; 530 d->optind++;
420 531
421 if (d->__first_nonopt != d->__last_nonopt 532 if (d->__first_nonopt != d->__last_nonopt
422 && d->__last_nonopt != d->optind) 533 && d->__last_nonopt != d->optind)
423 exchange ((char **) argv, d); 534 exchange (argv, d);
424 else if (d->__first_nonopt == d->__last_nonopt) 535 else if (d->__first_nonopt == d->__last_nonopt)
425 d->__first_nonopt = d->optind; 536 d->__first_nonopt = d->optind;
426 d->__last_nonopt = argc; 537 d->__last_nonopt = argc;
427 538
428 d->optind = argc; 539 d->optind = argc;
429 } 540 }
430 541
431 /* If we have done all the ARGV-elements, stop the scan 542 /* If we have done all the ARGV-elements, stop the scan
432 and back over any non-options that we skipped and permuted. */ 543 and back over any non-options that we skipped and permuted. */
433 544
434 if (d->optind == argc) 545 if (d->optind == argc)
435 { 546 {
436 /* Set the next-arg-index to point at the non-options 547 /* Set the next-arg-index to point at the non-options
437 that we previously skipped, so the caller will digest them. */ 548 that we previously skipped, so the caller will digest them. */
438 if (d->__first_nonopt != d->__last_nonopt) 549 if (d->__first_nonopt != d->__last_nonopt)
439 d->optind = d->__first_nonopt; 550 d->optind = d->__first_nonopt;
440 return -1; 551 return -1;
441 } 552 }
442 553
443 /* If we have come to a non-option and did not permute it, 554 /* If we have come to a non-option and did not permute it,
444 either stop the scan or describe it to the caller and pass it by. */ 555 either stop the scan or describe it to the caller and pass it by. */
445 556
446 if (NONOPTION_P) 557 if (NONOPTION_P)
447 { 558 {
448 if (d->__ordering == REQUIRE_ORDER) 559 if (d->__ordering == REQUIRE_ORDER)
449 return -1; 560 return -1;
450 d->optarg = argv[d->optind++]; 561 d->optarg = argv[d->optind++];
451 return 1; 562 return 1;
452 } 563 }
453 564
454 /* We have found another option-ARGV-element. 565 /* We have found another option-ARGV-element.
455 Skip the initial punctuation. */ 566 Check whether it might be a long option. */
456 567 if (longopts)
457 d->__nextchar = (argv[d->optind] + 1 568 {
458 + (longopts != NULL && argv[d->optind][1] == '-')); 569 if (argv[d->optind][1] == '-')
459 } 570 {
460 571 /* "--foo" is always a long option. The special option
461 /* Decode the current option-ARGV-element. */ 572 "--" was handled above. */
462 573 d->__nextchar = argv[d->optind] + 2;
463 /* Check whether the ARGV-element is a long option. 574 return process_long_option (argc, argv, optstring, longopts,
464 575 longind, long_only, d,
465 If long_only and the ARGV-element has the form "-f", where f is 576 print_errors, "--");
466 a valid short option, don't consider it an abbreviated form of 577 }
467 a long option that starts with f. Otherwise there would be no 578
468 way to give the -f short option. 579 /* If long_only and the ARGV-element has the form "-f",
469 580 where f is a valid short option, don't consider it an
470 On the other hand, if there's a long option "fubar" and 581 abbreviated form of a long option that starts with f.
471 the ARGV-element is "-fu", do consider that an abbreviation of 582 Otherwise there would be no way to give the -f short
472 the long option, just like "--fu", and not "-f" with arg "u". 583 option.
473 584
474 This distinction seems to be the most useful approach. */ 585 On the other hand, if there's a long option "fubar" and
475 586 the ARGV-element is "-fu", do consider that an
476 if (longopts != NULL 587 abbreviation of the long option, just like "--fu", and
477 && (argv[d->optind][1] == '-' 588 not "-f" with arg "u".
478 || (long_only && (argv[d->optind][2] 589
479 || !strchr (optstring, argv[d->optind][1]))))) 590 This distinction seems to be the most useful approach. */
480 { 591 if (long_only && (argv[d->optind][2]
481 char *nameend; 592 || !strchr (optstring, argv[d->optind][1])))
482 unsigned int namelen; 593 {
483 const struct option *p; 594 int code;
484 const struct option *pfound = NULL; 595 d->__nextchar = argv[d->optind] + 1;
485 struct option_list 596 code = process_long_option (argc, argv, optstring, longopts,
486 { 597 longind, long_only, d,
487 const struct option *p; 598 print_errors, "-");
488 struct option_list *next; 599 if (code != -1)
489 } *ambig_list = NULL; 600 return code;
490 int exact = 0; 601 }
491 int indfound = -1; 602 }
492 int option_index; 603
493 604 /* It is not a long option. Skip the initial punctuation. */
494 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) 605 d->__nextchar = argv[d->optind] + 1;
495 /* Do nothing. */ ;
496 namelen = nameend - d->__nextchar;
497
498 /* Test all long options for either exact match
499 or abbreviated matches. */
500 for (p = longopts, option_index = 0; p->name; p++, option_index++)
501 if (!strncmp (p->name, d->__nextchar, namelen))
502 {
503 if (namelen == (unsigned int) strlen (p->name))
504 {
505 /* Exact match found. */
506 pfound = p;
507 indfound = option_index;
508 exact = 1;
509 break;
510 }
511 else if (pfound == NULL)
512 {
513 /* First nonexact match found. */
514 pfound = p;
515 indfound = option_index;
516 }
517 else if (long_only
518 || pfound->has_arg != p->has_arg
519 || pfound->flag != p->flag
520 || pfound->val != p->val)
521 {
522 /* Second or later nonexact match found. */
523 struct option_list *newp = malloc (sizeof (*newp));
524 newp->p = p;
525 newp->next = ambig_list;
526 ambig_list = newp;
527 }
528 }
529
530 if (ambig_list != NULL && !exact)
531 {
532 if (print_errors)
533 {
534 struct option_list first;
535 first.p = pfound;
536 first.next = ambig_list;
537 ambig_list = &first;
538
539#if defined _LIBC && defined USE_IN_LIBIO
540 char *buf = NULL;
541 size_t buflen = 0;
542
543 FILE *fp = open_memstream (&buf, &buflen);
544 if (fp != NULL)
545 {
546 fprintf (fp,
547 _("%s: option '%s' is ambiguous; possibilities:"),
548 argv[0], argv[d->optind]);
549
550 do
551 {
552 fprintf (fp, " '--%s'", ambig_list->p->name);
553 ambig_list = ambig_list->next;
554 }
555 while (ambig_list != NULL);
556
557 fputc_unlocked ('\n', fp);
558
559 if (__builtin_expect (fclose (fp) != EOF, 1))
560 {
561 _IO_flockfile (stderr);
562
563 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
564 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
565
566 __fxprintf (NULL, "%s", buf);
567
568 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
569 _IO_funlockfile (stderr);
570
571 free (buf);
572 }
573 }
574#else
575 fprintf (stderr,
576 _("%s: option '%s' is ambiguous; possibilities:"),
577 argv[0], argv[d->optind]);
578 do
579 {
580 fprintf (stderr, " '--%s'", ambig_list->p->name);
581 ambig_list = ambig_list->next;
582 }
583 while (ambig_list != NULL);
584
585 fputc ('\n', stderr);
586#endif
587 }
588 d->__nextchar += strlen (d->__nextchar);
589 d->optind++;
590 d->optopt = 0;
591 return '?';
592 }
593
594 while (ambig_list != NULL)
595 {
596 struct option_list *pn = ambig_list->next;
597 free (ambig_list);
598 ambig_list = pn;
599 }
600
601 if (pfound != NULL)
602 {
603 option_index = indfound;
604 d->optind++;
605 if (*nameend)
606 {
607 /* Don't test has_arg with >, because some C compilers don't
608 allow it to be used on enums. */
609 if (pfound->has_arg)
610 d->optarg = nameend + 1;
611 else
612 {
613 if (print_errors)
614 {
615#if defined _LIBC && defined USE_IN_LIBIO
616 char *buf;
617 int n;
618#endif
619
620 if (argv[d->optind - 1][1] == '-')
621 {
622 /* --option */
623#if defined _LIBC && defined USE_IN_LIBIO
624 n = __asprintf (&buf, _("\
625%s: option '--%s' doesn't allow an argument\n"),
626 argv[0], pfound->name);
627#else
628 fprintf (stderr, _("\
629%s: option '--%s' doesn't allow an argument\n"),
630 argv[0], pfound->name);
631#endif
632 }
633 else
634 {
635 /* +option or -option */
636#if defined _LIBC && defined USE_IN_LIBIO
637 n = __asprintf (&buf, _("\
638%s: option '%c%s' doesn't allow an argument\n"),
639 argv[0], argv[d->optind - 1][0],
640 pfound->name);
641#else
642 fprintf (stderr, _("\
643%s: option '%c%s' doesn't allow an argument\n"),
644 argv[0], argv[d->optind - 1][0],
645 pfound->name);
646#endif
647 }
648
649#if defined _LIBC && defined USE_IN_LIBIO
650 if (n >= 0)
651 {
652 _IO_flockfile (stderr);
653
654 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
655 ((_IO_FILE *) stderr)->_flags2
656 |= _IO_FLAGS2_NOTCANCEL;
657
658 __fxprintf (NULL, "%s", buf);
659
660 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
661 _IO_funlockfile (stderr);
662
663 free (buf);
664 }
665#endif
666 }
667
668 d->__nextchar += strlen (d->__nextchar);
669
670 d->optopt = pfound->val;
671 return '?';
672 }
673 }
674 else if (pfound->has_arg == 1)
675 {
676 if (d->optind < argc)
677 d->optarg = argv[d->optind++];
678 else
679 {
680 if (print_errors)
681 {
682#if defined _LIBC && defined USE_IN_LIBIO
683 char *buf;
684
685 if (__asprintf (&buf, _("\
686%s: option '--%s' requires an argument\n"),
687 argv[0], pfound->name) >= 0)
688 {
689 _IO_flockfile (stderr);
690
691 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
692 ((_IO_FILE *) stderr)->_flags2
693 |= _IO_FLAGS2_NOTCANCEL;
694
695 __fxprintf (NULL, "%s", buf);
696
697 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
698 _IO_funlockfile (stderr);
699
700 free (buf);
701 }
702#else
703 fprintf (stderr,
704 _("%s: option '--%s' requires an argument\n"),
705 argv[0], pfound->name);
706#endif
707 }
708 d->__nextchar += strlen (d->__nextchar);
709 d->optopt = pfound->val;
710 return optstring[0] == ':' ? ':' : '?';
711 }
712 }
713 d->__nextchar += strlen (d->__nextchar);
714 if (longind != NULL)
715 *longind = option_index;
716 if (pfound->flag)
717 {
718 *(pfound->flag) = pfound->val;
719 return 0;
720 }
721 return pfound->val;
722 }
723
724 /* Can't find it as a long option. If this is not getopt_long_only,
725 or the option starts with '--' or is not a valid short
726 option, then it's an error.
727 Otherwise interpret it as a short option. */
728 if (!long_only || argv[d->optind][1] == '-'
729 || strchr (optstring, *d->__nextchar) == NULL)
730 {
731 if (print_errors)
732 {
733#if defined _LIBC && defined USE_IN_LIBIO
734 char *buf;
735 int n;
736#endif
737
738 if (argv[d->optind][1] == '-')
739 {
740 /* --option */
741#if defined _LIBC && defined USE_IN_LIBIO
742 n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"),
743 argv[0], d->__nextchar);
744#else
745 fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
746 argv[0], d->__nextchar);
747#endif
748 }
749 else
750 {
751 /* +option or -option */
752#if defined _LIBC && defined USE_IN_LIBIO
753 n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"),
754 argv[0], argv[d->optind][0], d->__nextchar);
755#else
756 fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
757 argv[0], argv[d->optind][0], d->__nextchar);
758#endif
759 }
760
761#if defined _LIBC && defined USE_IN_LIBIO
762 if (n >= 0)
763 {
764 _IO_flockfile (stderr);
765
766 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
767 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
768
769 __fxprintf (NULL, "%s", buf);
770
771 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
772 _IO_funlockfile (stderr);
773
774 free (buf);
775 }
776#endif
777 }
778 d->__nextchar = (char *) "";
779 d->optind++;
780 d->optopt = 0;
781 return '?';
782 }
783 } 606 }
784 607
785 /* Look at and handle the next short option-character. */ 608 /* Look at and handle the next short option-character. */
@@ -794,331 +617,83 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
794 617
795 if (temp == NULL || c == ':' || c == ';') 618 if (temp == NULL || c == ':' || c == ';')
796 { 619 {
797 if (print_errors) 620 if (print_errors)
798 { 621 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
799#if defined _LIBC && defined USE_IN_LIBIO 622 d->optopt = c;
800 char *buf; 623 return '?';
801 int n;
802#endif
803
804#if defined _LIBC && defined USE_IN_LIBIO
805 n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
806 argv[0], c);
807#else
808 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
809#endif
810
811#if defined _LIBC && defined USE_IN_LIBIO
812 if (n >= 0)
813 {
814 _IO_flockfile (stderr);
815
816 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
817 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
818
819 __fxprintf (NULL, "%s", buf);
820
821 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
822 _IO_funlockfile (stderr);
823
824 free (buf);
825 }
826#endif
827 }
828 d->optopt = c;
829 return '?';
830 } 624 }
625
831 /* Convenience. Treat POSIX -W foo same as long option --foo */ 626 /* Convenience. Treat POSIX -W foo same as long option --foo */
832 if (temp[0] == 'W' && temp[1] == ';') 627 if (temp[0] == 'W' && temp[1] == ';' && longopts != NULL)
833 { 628 {
834 char *nameend; 629 /* This is an option that requires an argument. */
835 const struct option *p; 630 if (*d->__nextchar != '\0')
836 const struct option *pfound = NULL; 631 d->optarg = d->__nextchar;
837 int exact = 0; 632 else if (d->optind == argc)
838 int ambig = 0; 633 {
839 int indfound = 0; 634 if (print_errors)
840 int option_index; 635 fprintf (stderr,
841 636 _("%s: option requires an argument -- '%c'\n"),
842 if (longopts == NULL) 637 argv[0], c);
843 goto no_longs; 638
844 639 d->optopt = c;
845 /* This is an option that requires an argument. */ 640 if (optstring[0] == ':')
846 if (*d->__nextchar != '\0') 641 c = ':';
847 { 642 else
848 d->optarg = d->__nextchar; 643 c = '?';
849 /* If we end this ARGV-element by taking the rest as an arg, 644 return c;
850 we must advance to the next element now. */ 645 }
851 d->optind++; 646 else
852 } 647 d->optarg = argv[d->optind];
853 else if (d->optind == argc) 648
854 { 649 d->__nextchar = d->optarg;
855 if (print_errors) 650 d->optarg = NULL;
856 { 651 return process_long_option (argc, argv, optstring, longopts, longind,
857#if defined _LIBC && defined USE_IN_LIBIO 652 0 /* long_only */, d, print_errors, "-W ");
858 char *buf;
859
860 if (__asprintf (&buf,
861 _("%s: option requires an argument -- '%c'\n"),
862 argv[0], c) >= 0)
863 {
864 _IO_flockfile (stderr);
865
866 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
867 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
868
869 __fxprintf (NULL, "%s", buf);
870
871 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
872 _IO_funlockfile (stderr);
873
874 free (buf);
875 }
876#else
877 fprintf (stderr,
878 _("%s: option requires an argument -- '%c'\n"),
879 argv[0], c);
880#endif
881 }
882 d->optopt = c;
883 if (optstring[0] == ':')
884 c = ':';
885 else
886 c = '?';
887 return c;
888 }
889 else
890 /* We already incremented 'd->optind' once;
891 increment it again when taking next ARGV-elt as argument. */
892 d->optarg = argv[d->optind++];
893
894 /* optarg is now the argument, see if it's in the
895 table of longopts. */
896
897 for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
898 nameend++)
899 /* Do nothing. */ ;
900
901 /* Test all long options for either exact match
902 or abbreviated matches. */
903 for (p = longopts, option_index = 0; p->name; p++, option_index++)
904 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
905 {
906 if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
907 {
908 /* Exact match found. */
909 pfound = p;
910 indfound = option_index;
911 exact = 1;
912 break;
913 }
914 else if (pfound == NULL)
915 {
916 /* First nonexact match found. */
917 pfound = p;
918 indfound = option_index;
919 }
920 else if (long_only
921 || pfound->has_arg != p->has_arg
922 || pfound->flag != p->flag
923 || pfound->val != p->val)
924 /* Second or later nonexact match found. */
925 ambig = 1;
926 }
927 if (ambig && !exact)
928 {
929 if (print_errors)
930 {
931#if defined _LIBC && defined USE_IN_LIBIO
932 char *buf;
933
934 if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"),
935 argv[0], d->optarg) >= 0)
936 {
937 _IO_flockfile (stderr);
938
939 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
940 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
941
942 __fxprintf (NULL, "%s", buf);
943
944 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
945 _IO_funlockfile (stderr);
946
947 free (buf);
948 }
949#else
950 fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
951 argv[0], d->optarg);
952#endif
953 }
954 d->__nextchar += strlen (d->__nextchar);
955 d->optind++;
956 return '?';
957 }
958 if (pfound != NULL)
959 {
960 option_index = indfound;
961 if (*nameend)
962 {
963 /* Don't test has_arg with >, because some C compilers don't
964 allow it to be used on enums. */
965 if (pfound->has_arg)
966 d->optarg = nameend + 1;
967 else
968 {
969 if (print_errors)
970 {
971#if defined _LIBC && defined USE_IN_LIBIO
972 char *buf;
973
974 if (__asprintf (&buf, _("\
975%s: option '-W %s' doesn't allow an argument\n"),
976 argv[0], pfound->name) >= 0)
977 {
978 _IO_flockfile (stderr);
979
980 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
981 ((_IO_FILE *) stderr)->_flags2
982 |= _IO_FLAGS2_NOTCANCEL;
983
984 __fxprintf (NULL, "%s", buf);
985
986 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
987 _IO_funlockfile (stderr);
988
989 free (buf);
990 }
991#else
992 fprintf (stderr, _("\
993%s: option '-W %s' doesn't allow an argument\n"),
994 argv[0], pfound->name);
995#endif
996 }
997
998 d->__nextchar += strlen (d->__nextchar);
999 return '?';
1000 }
1001 }
1002 else if (pfound->has_arg == 1)
1003 {
1004 if (d->optind < argc)
1005 d->optarg = argv[d->optind++];
1006 else
1007 {
1008 if (print_errors)
1009 {
1010#if defined _LIBC && defined USE_IN_LIBIO
1011 char *buf;
1012
1013 if (__asprintf (&buf, _("\
1014%s: option '-W %s' requires an argument\n"),
1015 argv[0], pfound->name) >= 0)
1016 {
1017 _IO_flockfile (stderr);
1018
1019 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
1020 ((_IO_FILE *) stderr)->_flags2
1021 |= _IO_FLAGS2_NOTCANCEL;
1022
1023 __fxprintf (NULL, "%s", buf);
1024
1025 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
1026 _IO_funlockfile (stderr);
1027
1028 free (buf);
1029 }
1030#else
1031 fprintf (stderr, _("\
1032%s: option '-W %s' requires an argument\n"),
1033 argv[0], pfound->name);
1034#endif
1035 }
1036 d->__nextchar += strlen (d->__nextchar);
1037 return optstring[0] == ':' ? ':' : '?';
1038 }
1039 }
1040 else
1041 d->optarg = NULL;
1042 d->__nextchar += strlen (d->__nextchar);
1043 if (longind != NULL)
1044 *longind = option_index;
1045 if (pfound->flag)
1046 {
1047 *(pfound->flag) = pfound->val;
1048 return 0;
1049 }
1050 return pfound->val;
1051 }
1052
1053 no_longs:
1054 d->__nextchar = NULL;
1055 return 'W'; /* Let the application handle it. */
1056 } 653 }
1057 if (temp[1] == ':') 654 if (temp[1] == ':')
1058 { 655 {
1059 if (temp[2] == ':') 656 if (temp[2] == ':')
1060 { 657 {
1061 /* This is an option that accepts an argument optionally. */ 658 /* This is an option that accepts an argument optionally. */
1062 if (*d->__nextchar != '\0') 659 if (*d->__nextchar != '\0')
1063 { 660 {
1064 d->optarg = d->__nextchar; 661 d->optarg = d->__nextchar;
1065 d->optind++; 662 d->optind++;
1066 } 663 }
1067 else 664 else
1068 d->optarg = NULL; 665 d->optarg = NULL;
1069 d->__nextchar = NULL; 666 d->__nextchar = NULL;
1070 } 667 }
1071 else 668 else
1072 { 669 {
1073 /* This is an option that requires an argument. */ 670 /* This is an option that requires an argument. */
1074 if (*d->__nextchar != '\0') 671 if (*d->__nextchar != '\0')
1075 { 672 {
1076 d->optarg = d->__nextchar; 673 d->optarg = d->__nextchar;
1077 /* If we end this ARGV-element by taking the rest as an arg, 674 /* If we end this ARGV-element by taking the rest as an arg,
1078 we must advance to the next element now. */ 675 we must advance to the next element now. */
1079 d->optind++; 676 d->optind++;
1080 } 677 }
1081 else if (d->optind == argc) 678 else if (d->optind == argc)
1082 { 679 {
1083 if (print_errors) 680 if (print_errors)
1084 { 681 fprintf (stderr,
1085#if defined _LIBC && defined USE_IN_LIBIO 682 _("%s: option requires an argument -- '%c'\n"),
1086 char *buf; 683 argv[0], c);
1087 684
1088 if (__asprintf (&buf, _("\ 685 d->optopt = c;
1089%s: option requires an argument -- '%c'\n"), 686 if (optstring[0] == ':')
1090 argv[0], c) >= 0) 687 c = ':';
1091 { 688 else
1092 _IO_flockfile (stderr); 689 c = '?';
1093 690 }
1094 int old_flags2 = ((_IO_FILE *) stderr)->_flags2; 691 else
1095 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; 692 /* We already incremented 'optind' once;
1096 693 increment it again when taking next ARGV-elt as argument. */
1097 __fxprintf (NULL, "%s", buf); 694 d->optarg = argv[d->optind++];
1098 695 d->__nextchar = NULL;
1099 ((_IO_FILE *) stderr)->_flags2 = old_flags2; 696 }
1100 _IO_funlockfile (stderr);
1101
1102 free (buf);
1103 }
1104#else
1105 fprintf (stderr,
1106 _("%s: option requires an argument -- '%c'\n"),
1107 argv[0], c);
1108#endif
1109 }
1110 d->optopt = c;
1111 if (optstring[0] == ':')
1112 c = ':';
1113 else
1114 c = '?';
1115 }
1116 else
1117 /* We already incremented 'optind' once;
1118 increment it again when taking next ARGV-elt as argument. */
1119 d->optarg = argv[d->optind++];
1120 d->__nextchar = NULL;
1121 }
1122 } 697 }
1123 return c; 698 return c;
1124 } 699 }
@@ -1126,8 +701,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
1126 701
1127int 702int
1128_getopt_internal (int argc, char **argv, const char *optstring, 703_getopt_internal (int argc, char **argv, const char *optstring,
1129 const struct option *longopts, int *longind, int long_only, 704 const struct option *longopts, int *longind, int long_only,
1130 int posixly_correct) 705 int posixly_correct)
1131{ 706{
1132 int result; 707 int result;
1133 708
@@ -1135,8 +710,8 @@ _getopt_internal (int argc, char **argv, const char *optstring,
1135 getopt_data.opterr = opterr; 710 getopt_data.opterr = opterr;
1136 711
1137 result = _getopt_internal_r (argc, argv, optstring, longopts, 712 result = _getopt_internal_r (argc, argv, optstring, longopts,
1138 longind, long_only, &getopt_data, 713 longind, long_only, &getopt_data,
1139 posixly_correct); 714 posixly_correct);
1140 715
1141 optind = getopt_data.optind; 716 optind = getopt_data.optind;
1142 optarg = getopt_data.optarg; 717 optarg = getopt_data.optarg;
@@ -1145,32 +720,23 @@ _getopt_internal (int argc, char **argv, const char *optstring,
1145 return result; 720 return result;
1146} 721}
1147 722
1148/* glibc gets a LSB-compliant getopt. 723/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt.
1149 Standalone applications get a POSIX-compliant getopt. */ 724 Standalone applications just get a POSIX-compliant getopt.
1150#if _LIBC 725 POSIX and LSB both require these functions to take 'char *const *argv'
1151enum { POSIXLY_CORRECT = 0 }; 726 even though this is incorrect (because of the permutation). */
1152#else 727#define GETOPT_ENTRY(NAME, POSIXLY_CORRECT) \
1153enum { POSIXLY_CORRECT = 1 }; 728 int \
1154#endif 729 NAME (int argc, char *const *argv, const char *optstring) \
1155 730 { \
1156int 731 return _getopt_internal (argc, (char **)argv, optstring, \
1157getopt (int argc, char *const *argv, const char *optstring) 732 0, 0, 0, POSIXLY_CORRECT); \
1158{ 733 }
1159 return _getopt_internal (argc, (char **) argv, optstring,
1160 (const struct option *) 0,
1161 (int *) 0,
1162 0, POSIXLY_CORRECT);
1163}
1164 734
1165#ifdef _LIBC 735#ifdef _LIBC
1166int 736GETOPT_ENTRY(getopt, 0)
1167__posix_getopt (int argc, char *const *argv, const char *optstring) 737GETOPT_ENTRY(__posix_getopt, 1)
1168{ 738#else
1169 return _getopt_internal (argc, argv, optstring, 739GETOPT_ENTRY(getopt, 1)
1170 (const struct option *) 0,
1171 (int *) 0,
1172 0, 1);
1173}
1174#endif 740#endif
1175 741
1176 742
@@ -1191,51 +757,51 @@ main (int argc, char **argv)
1191 757
1192 c = getopt (argc, argv, "abc:d:0123456789"); 758 c = getopt (argc, argv, "abc:d:0123456789");
1193 if (c == -1) 759 if (c == -1)
1194 break; 760 break;
1195 761
1196 switch (c) 762 switch (c)
1197 { 763 {
1198 case '0': 764 case '0':
1199 case '1': 765 case '1':
1200 case '2': 766 case '2':
1201 case '3': 767 case '3':
1202 case '4': 768 case '4':
1203 case '5': 769 case '5':
1204 case '6': 770 case '6':
1205 case '7': 771 case '7':
1206 case '8': 772 case '8':
1207 case '9': 773 case '9':
1208 if (digit_optind != 0 && digit_optind != this_option_optind) 774 if (digit_optind != 0 && digit_optind != this_option_optind)
1209 printf ("digits occur in two different argv-elements.\n"); 775 printf ("digits occur in two different argv-elements.\n");
1210 digit_optind = this_option_optind; 776 digit_optind = this_option_optind;
1211 printf ("option %c\n", c); 777 printf ("option %c\n", c);
1212 break; 778 break;
1213 779
1214 case 'a': 780 case 'a':
1215 printf ("option a\n"); 781 printf ("option a\n");
1216 break; 782 break;
1217 783
1218 case 'b': 784 case 'b':
1219 printf ("option b\n"); 785 printf ("option b\n");
1220 break; 786 break;
1221 787
1222 case 'c': 788 case 'c':
1223 printf ("option c with value '%s'\n", optarg); 789 printf ("option c with value '%s'\n", optarg);
1224 break; 790 break;
1225 791
1226 case '?': 792 case '?':
1227 break; 793 break;
1228 794
1229 default: 795 default:
1230 printf ("?? getopt returned character code 0%o ??\n", c); 796 printf ("?? getopt returned character code 0%o ??\n", c);
1231 } 797 }
1232 } 798 }
1233 799
1234 if (optind < argc) 800 if (optind < argc)
1235 { 801 {
1236 printf ("non-option ARGV-elements: "); 802 printf ("non-option ARGV-elements: ");
1237 while (optind < argc) 803 while (optind < argc)
1238 printf ("%s ", argv[optind++]); 804 printf ("%s ", argv[optind++]);
1239 printf ("\n"); 805 printf ("\n");
1240 } 806 }
1241 807
diff --git a/gl/getopt.in.h b/gl/getopt.in.h
index d9c7d814..0867d365 100644
--- a/gl/getopt.in.h
+++ b/gl/getopt.in.h
@@ -1,20 +1,22 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software 2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 Foundation, Inc. 3 This file is part of gnulib.
4 This file is part of the GNU C Library. 4 Unlike most of the getopt implementation, it is NOT shared
5 5 with the GNU C Library, which supplies a different version of
6 This program is free software: you can redistribute it and/or modify 6 this file.
7 it under the terms of the GNU General Public License as published by 7
8 the Free Software Foundation; either version 3 of the License, or 8 This file is free software: you can redistribute it and/or modify
9 (at your option) any later version. 9 it under the terms of the GNU Lesser General Public License as
10 10 published by the Free Software Foundation; either version 2.1 of the
11 This program is distributed in the hope that it will be useful, 11 License, or (at your option) any later version.
12
13 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 16 GNU Lesser General Public License for more details.
15 17
16 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 20
19#ifndef _@GUARD_PREFIX@_GETOPT_H 21#ifndef _@GUARD_PREFIX@_GETOPT_H
20 22
@@ -32,22 +34,15 @@
32# undef _GL_SYSTEM_GETOPT 34# undef _GL_SYSTEM_GETOPT
33#endif 35#endif
34 36
35#ifndef _@GUARD_PREFIX@_GETOPT_H 37#define _@GUARD_PREFIX@_GETOPT_H 1
36
37#ifndef __need_getopt
38# define _@GUARD_PREFIX@_GETOPT_H 1
39#endif
40 38
41/* Standalone applications should #define __GETOPT_PREFIX to an 39/* Standalone applications should #define __GETOPT_PREFIX to an
42 identifier that prefixes the external functions and variables 40 identifier that prefixes the external functions and variables
43 defined in this header. When this happens, include the 41 defined in getopt-core.h and getopt-ext.h. When this happens,
44 headers that might declare getopt so that they will not cause 42 include the headers that might declare getopt so that they will not
45 confusion if included after this file (if the system had <getopt.h>, 43 cause confusion if included after this file (if the system had
46 we have already included it). Then systematically rename 44 <getopt.h>, we have already included it). */
47 identifiers so that they do not collide with the system functions 45#if defined __GETOPT_PREFIX
48 and variables. Renaming avoids problems with some compilers and
49 linkers. */
50#if defined __GETOPT_PREFIX && !defined __need_getopt
51# if !@HAVE_GETOPT_H@ 46# if !@HAVE_GETOPT_H@
52# define __need_system_stdlib_h 47# define __need_system_stdlib_h
53# include <stdlib.h> 48# include <stdlib.h>
@@ -55,201 +50,12 @@
55# include <stdio.h> 50# include <stdio.h>
56# include <unistd.h> 51# include <unistd.h>
57# endif 52# endif
58# undef __need_getopt
59# undef getopt
60# undef getopt_long
61# undef getopt_long_only
62# undef optarg
63# undef opterr
64# undef optind
65# undef optopt
66# undef option
67# define __GETOPT_CONCAT(x, y) x ## y
68# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
69# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
70# define getopt __GETOPT_ID (getopt)
71# define getopt_long __GETOPT_ID (getopt_long)
72# define getopt_long_only __GETOPT_ID (getopt_long_only)
73# define optarg __GETOPT_ID (optarg)
74# define opterr __GETOPT_ID (opterr)
75# define optind __GETOPT_ID (optind)
76# define optopt __GETOPT_ID (optopt)
77# define option __GETOPT_ID (option)
78# define _getopt_internal __GETOPT_ID (getopt_internal)
79#endif
80
81/* Standalone applications get correct prototypes for getopt_long and
82 getopt_long_only; they declare "char **argv". libc uses prototypes
83 with "char *const *argv" that are incorrect because getopt_long and
84 getopt_long_only can permute argv; this is required for backward
85 compatibility (e.g., for LSB 2.0.1).
86
87 This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt',
88 but it caused redefinition warnings if both unistd.h and getopt.h were
89 included, since unistd.h includes getopt.h having previously defined
90 __need_getopt.
91
92 The only place where __getopt_argv_const is used is in definitions
93 of getopt_long and getopt_long_only below, but these are visible
94 only if __need_getopt is not defined, so it is quite safe to rewrite
95 the conditional as follows:
96*/
97#if !defined __need_getopt
98# if defined __GETOPT_PREFIX
99# define __getopt_argv_const /* empty */
100# else
101# define __getopt_argv_const const
102# endif
103#endif
104
105/* If __GNU_LIBRARY__ is not already defined, either we are being used
106 standalone, or this is the first header included in the source file.
107 If we are being used with glibc, we need to include <features.h>, but
108 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
109 not defined, include <ctype.h>, which will pull in <features.h> for us
110 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
111 doesn't flood the namespace with stuff the way some other headers do.) */
112#if !defined __GNU_LIBRARY__
113# include <ctype.h>
114#endif
115
116#ifndef __THROW
117# ifndef __GNUC_PREREQ
118# define __GNUC_PREREQ(maj, min) (0)
119# endif
120# if defined __cplusplus && __GNUC_PREREQ (2,8)
121# define __THROW throw ()
122# else
123# define __THROW
124# endif
125#endif 53#endif
126 54
127/* The definition of _GL_ARG_NONNULL is copied here. */ 55/* The definition of _GL_ARG_NONNULL is copied here. */
128 56
129#ifdef __cplusplus 57#include <getopt-cdefs.h>
130extern "C" { 58#include <getopt-pfx-core.h>
131#endif 59#include <getopt-pfx-ext.h>
132
133/* For communication from 'getopt' to the caller.
134 When 'getopt' finds an option that takes an argument,
135 the argument value is returned here.
136 Also, when 'ordering' is RETURN_IN_ORDER,
137 each non-option ARGV-element is returned here. */
138
139extern char *optarg;
140
141/* Index in ARGV of the next element to be scanned.
142 This is used for communication to and from the caller
143 and for communication between successive calls to 'getopt'.
144
145 On entry to 'getopt', zero means this is the first call; initialize.
146
147 When 'getopt' returns -1, this is the index of the first of the
148 non-option elements that the caller should itself scan.
149
150 Otherwise, 'optind' communicates from one call to the next
151 how much of ARGV has been scanned so far. */
152
153extern int optind;
154
155/* Callers store zero here to inhibit the error message 'getopt' prints
156 for unrecognized options. */
157
158extern int opterr;
159 60
160/* Set to an option character which was unrecognized. */
161
162extern int optopt;
163
164#ifndef __need_getopt
165/* Describe the long-named options requested by the application.
166 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
167 of 'struct option' terminated by an element containing a name which is
168 zero.
169
170 The field 'has_arg' is:
171 no_argument (or 0) if the option does not take an argument,
172 required_argument (or 1) if the option requires an argument,
173 optional_argument (or 2) if the option takes an optional argument.
174
175 If the field 'flag' is not NULL, it points to a variable that is set
176 to the value given in the field 'val' when the option is found, but
177 left unchanged if the option is not found.
178
179 To have a long-named option do something other than set an 'int' to
180 a compiled-in constant, such as set a value from 'optarg', set the
181 option's 'flag' field to zero and its 'val' field to a nonzero
182 value (the equivalent single-letter option character, if there is
183 one). For long options that have a zero 'flag' field, 'getopt'
184 returns the contents of the 'val' field. */
185
186# if !GNULIB_defined_struct_option
187struct option
188{
189 const char *name;
190 /* has_arg can't be an enum because some compilers complain about
191 type mismatches in all the code that assumes it is an int. */
192 int has_arg;
193 int *flag;
194 int val;
195};
196# define GNULIB_defined_struct_option 1
197# endif
198
199/* Names for the values of the 'has_arg' field of 'struct option'. */
200
201# define no_argument 0
202# define required_argument 1
203# define optional_argument 2
204#endif /* need getopt */
205
206
207/* Get definitions and prototypes for functions to process the
208 arguments in ARGV (ARGC of them, minus the program name) for
209 options given in OPTS.
210
211 Return the option character from OPTS just read. Return -1 when
212 there are no more options. For unrecognized options, or options
213 missing arguments, 'optopt' is set to the option letter, and '?' is
214 returned.
215
216 The OPTS string is a list of characters which are recognized option
217 letters, optionally followed by colons, specifying that that letter
218 takes an argument, to be placed in 'optarg'.
219
220 If a letter in OPTS is followed by two colons, its argument is
221 optional. This behavior is specific to the GNU 'getopt'.
222
223 The argument '--' causes premature termination of argument
224 scanning, explicitly telling 'getopt' that there are no more
225 options.
226
227 If OPTS begins with '-', then non-option arguments are treated as
228 arguments to the option '\1'. This behavior is specific to the GNU
229 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
230 the environment, then do not permute arguments. */
231
232extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
233 __THROW _GL_ARG_NONNULL ((2, 3));
234
235#ifndef __need_getopt
236extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
237 const char *__shortopts,
238 const struct option *__longopts, int *__longind)
239 __THROW _GL_ARG_NONNULL ((2, 3));
240extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
241 const char *__shortopts,
242 const struct option *__longopts, int *__longind)
243 __THROW _GL_ARG_NONNULL ((2, 3));
244
245#endif
246
247#ifdef __cplusplus
248}
249#endif
250
251/* Make sure we later can get all the definitions and declarations. */
252#undef __need_getopt
253
254#endif /* _@GUARD_PREFIX@_GETOPT_H */
255#endif /* _@GUARD_PREFIX@_GETOPT_H */ 61#endif /* _@GUARD_PREFIX@_GETOPT_H */
diff --git a/gl/getopt1.c b/gl/getopt1.c
index 55a6b4ea..49323aa8 100644
--- a/gl/getopt1.c
+++ b/gl/getopt1.c
@@ -1,56 +1,44 @@
1/* getopt_long and getopt_long_only entry points for GNU getopt. 1/* getopt_long and getopt_long_only entry points for GNU getopt.
2 Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software 2 Copyright (C) 1987-2023 Free Software Foundation, Inc.
3 Foundation, Inc. 3 This file is part of the GNU C Library and is also part of gnulib.
4 This file is part of the GNU C Library. 4 Patches to this file should be submitted to both projects.
5 5
6 This program is free software: you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3 of the License, or 8 License as published by the Free Software Foundation; either
9 (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifdef _LIBC 20#ifndef _LIBC
20# include <getopt.h>
21#else
22# include <config.h> 21# include <config.h>
23# include "getopt.h"
24#endif 22#endif
25#include "getopt_int.h"
26
27#include <stdio.h>
28 23
29/* This needs to come after some library #include 24#include "getopt.h"
30 to get __GNU_LIBRARY__ defined. */ 25#include "getopt_int.h"
31#ifdef __GNU_LIBRARY__
32#include <stdlib.h>
33#endif
34
35#ifndef NULL
36#define NULL 0
37#endif
38 26
39int 27int
40getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, 28getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
41 const struct option *long_options, int *opt_index) 29 const struct option *long_options, int *opt_index)
42{ 30{
43 return _getopt_internal (argc, (char **) argv, options, long_options, 31 return _getopt_internal (argc, (char **) argv, options, long_options,
44 opt_index, 0, 0); 32 opt_index, 0, 0);
45} 33}
46 34
47int 35int
48_getopt_long_r (int argc, char **argv, const char *options, 36_getopt_long_r (int argc, char **argv, const char *options,
49 const struct option *long_options, int *opt_index, 37 const struct option *long_options, int *opt_index,
50 struct _getopt_data *d) 38 struct _getopt_data *d)
51{ 39{
52 return _getopt_internal_r (argc, argv, options, long_options, opt_index, 40 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
53 0, d, 0); 41 0, d, 0);
54} 42}
55 43
56/* Like getopt_long, but '-' as well as '--' can indicate a long option. 44/* Like getopt_long, but '-' as well as '--' can indicate a long option.
@@ -60,26 +48,27 @@ _getopt_long_r (int argc, char **argv, const char *options,
60 48
61int 49int
62getopt_long_only (int argc, char *__getopt_argv_const *argv, 50getopt_long_only (int argc, char *__getopt_argv_const *argv,
63 const char *options, 51 const char *options,
64 const struct option *long_options, int *opt_index) 52 const struct option *long_options, int *opt_index)
65{ 53{
66 return _getopt_internal (argc, (char **) argv, options, long_options, 54 return _getopt_internal (argc, (char **) argv, options, long_options,
67 opt_index, 1, 0); 55 opt_index, 1, 0);
68} 56}
69 57
70int 58int
71_getopt_long_only_r (int argc, char **argv, const char *options, 59_getopt_long_only_r (int argc, char **argv, const char *options,
72 const struct option *long_options, int *opt_index, 60 const struct option *long_options, int *opt_index,
73 struct _getopt_data *d) 61 struct _getopt_data *d)
74{ 62{
75 return _getopt_internal_r (argc, argv, options, long_options, opt_index, 63 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
76 1, d, 0); 64 1, d, 0);
77} 65}
78 66
79 67
80#ifdef TEST 68#ifdef TEST
81 69
82#include <stdio.h> 70#include <stdio.h>
71#include <stdlib.h>
83 72
84int 73int
85main (int argc, char **argv) 74main (int argc, char **argv)
@@ -93,74 +82,74 @@ main (int argc, char **argv)
93 int option_index = 0; 82 int option_index = 0;
94 static const struct option long_options[] = 83 static const struct option long_options[] =
95 { 84 {
96 {"add", 1, 0, 0}, 85 {"add", 1, 0, 0},
97 {"append", 0, 0, 0}, 86 {"append", 0, 0, 0},
98 {"delete", 1, 0, 0}, 87 {"delete", 1, 0, 0},
99 {"verbose", 0, 0, 0}, 88 {"verbose", 0, 0, 0},
100 {"create", 0, 0, 0}, 89 {"create", 0, 0, 0},
101 {"file", 1, 0, 0}, 90 {"file", 1, 0, 0},
102 {0, 0, 0, 0} 91 {0, 0, 0, 0}
103 }; 92 };
104 93
105 c = getopt_long (argc, argv, "abc:d:0123456789", 94 c = getopt_long (argc, argv, "abc:d:0123456789",
106 long_options, &option_index); 95 long_options, &option_index);
107 if (c == -1) 96 if (c == -1)
108 break; 97 break;
109 98
110 switch (c) 99 switch (c)
111 { 100 {
112 case 0: 101 case 0:
113 printf ("option %s", long_options[option_index].name); 102 printf ("option %s", long_options[option_index].name);
114 if (optarg) 103 if (optarg)
115 printf (" with arg %s", optarg); 104 printf (" with arg %s", optarg);
116 printf ("\n"); 105 printf ("\n");
117 break; 106 break;
118 107
119 case '0': 108 case '0':
120 case '1': 109 case '1':
121 case '2': 110 case '2':
122 case '3': 111 case '3':
123 case '4': 112 case '4':
124 case '5': 113 case '5':
125 case '6': 114 case '6':
126 case '7': 115 case '7':
127 case '8': 116 case '8':
128 case '9': 117 case '9':
129 if (digit_optind != 0 && digit_optind != this_option_optind) 118 if (digit_optind != 0 && digit_optind != this_option_optind)
130 printf ("digits occur in two different argv-elements.\n"); 119 printf ("digits occur in two different argv-elements.\n");
131 digit_optind = this_option_optind; 120 digit_optind = this_option_optind;
132 printf ("option %c\n", c); 121 printf ("option %c\n", c);
133 break; 122 break;
134 123
135 case 'a': 124 case 'a':
136 printf ("option a\n"); 125 printf ("option a\n");
137 break; 126 break;
138 127
139 case 'b': 128 case 'b':
140 printf ("option b\n"); 129 printf ("option b\n");
141 break; 130 break;
142 131
143 case 'c': 132 case 'c':
144 printf ("option c with value '%s'\n", optarg); 133 printf ("option c with value '%s'\n", optarg);
145 break; 134 break;
146 135
147 case 'd': 136 case 'd':
148 printf ("option d with value '%s'\n", optarg); 137 printf ("option d with value '%s'\n", optarg);
149 break; 138 break;
150 139
151 case '?': 140 case '?':
152 break; 141 break;
153 142
154 default: 143 default:
155 printf ("?? getopt returned character code 0%o ??\n", c); 144 printf ("?? getopt returned character code 0%o ??\n", c);
156 } 145 }
157 } 146 }
158 147
159 if (optind < argc) 148 if (optind < argc)
160 { 149 {
161 printf ("non-option ARGV-elements: "); 150 printf ("non-option ARGV-elements: ");
162 while (optind < argc) 151 while (optind < argc)
163 printf ("%s ", argv[optind++]); 152 printf ("%s ", argv[optind++]);
164 printf ("\n"); 153 printf ("\n");
165 } 154 }
166 155
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index a6e4b9ea..4d9e24be 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -1,30 +1,31 @@
1/* Internal declarations for getopt. 1/* Internal declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software 2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 Foundation, Inc. 3 This file is part of the GNU C Library and is also part of gnulib.
4 This file is part of the GNU C Library. 4 Patches to this file should be submitted to both projects.
5 5
6 This program is free software: you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3 of the License, or 8 License as published by the Free Software Foundation; either
9 (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifndef _GETOPT_INT_H 20#ifndef _GETOPT_INT_H
20#define _GETOPT_INT_H 1 21#define _GETOPT_INT_H 1
21 22
22#include <getopt.h> 23#include <getopt.h>
23 24
24extern int _getopt_internal (int ___argc, char **___argv, 25extern int _getopt_internal (int ___argc, char **___argv,
25 const char *__shortopts, 26 const char *__shortopts,
26 const struct option *__longopts, int *__longind, 27 const struct option *__longopts, int *__longind,
27 int __long_only, int __posixly_correct); 28 int __long_only, int __posixly_correct);
28 29
29 30
30/* Reentrant versions which can handle parsing multiple argument 31/* Reentrant versions which can handle parsing multiple argument
@@ -32,28 +33,20 @@ extern int _getopt_internal (int ___argc, char **___argv,
32 33
33/* Describe how to deal with options that follow non-option ARGV-elements. 34/* Describe how to deal with options that follow non-option ARGV-elements.
34 35
35 If the caller did not specify anything, 36 REQUIRE_ORDER means don't recognize them as options; stop option
36 the default is REQUIRE_ORDER if the environment variable 37 processing when the first non-option is seen. This is what POSIX
37 POSIXLY_CORRECT is defined, PERMUTE otherwise. 38 specifies should happen.
38 39
39 REQUIRE_ORDER means don't recognize them as options; 40 PERMUTE means permute the contents of ARGV as we scan, so that
40 stop option processing when the first non-option is seen. 41 eventually all the non-options are at the end. This allows options
41 This is what Unix does. 42 to be given in any order, even with programs that were not written
42 This mode of operation is selected by either setting the environment 43 to expect this.
43 variable POSIXLY_CORRECT, or using '+' as the first character
44 of the list of option characters, or by calling getopt.
45
46 PERMUTE is the default. We permute the contents of ARGV as we
47 scan, so that eventually all the non-options are at the end.
48 This allows options to be given in any order, even with programs
49 that were not written to expect this.
50 44
51 RETURN_IN_ORDER is an option available to programs that were 45 RETURN_IN_ORDER is an option available to programs that were
52 written to expect options and other ARGV-elements in any order 46 written to expect options and other ARGV-elements in any order
53 and that care about the ordering of the two. We describe each 47 and that care about the ordering of the two. We describe each
54 non-option ARGV-element as if it were the argument of an option 48 non-option ARGV-element as if it were the argument of an option
55 with character code 1. Using '-' as the first character of the 49 with character code 1.
56 list of option characters selects this mode of operation.
57 50
58 The special argument '--' forces an end of option-scanning regardless 51 The special argument '--' forces an end of option-scanning regardless
59 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only 52 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
@@ -91,11 +84,6 @@ struct _getopt_data
91 /* See __ord above. */ 84 /* See __ord above. */
92 enum __ord __ordering; 85 enum __ord __ordering;
93 86
94 /* If the POSIXLY_CORRECT environment variable is set
95 or getopt was called. */
96 int __posixly_correct;
97
98
99 /* Handle permutation of arguments. */ 87 /* Handle permutation of arguments. */
100 88
101 /* Describe the part of ARGV that contains non-options that have 89 /* Describe the part of ARGV that contains non-options that have
@@ -104,32 +92,27 @@ struct _getopt_data
104 92
105 int __first_nonopt; 93 int __first_nonopt;
106 int __last_nonopt; 94 int __last_nonopt;
107
108#if defined _LIBC && defined USE_NONOPTION_FLAGS
109 int __nonoption_flags_max_len;
110 int __nonoption_flags_len;
111#endif
112}; 95};
113 96
114/* The initializer is necessary to set OPTIND and OPTERR to their 97/* The initializer is necessary to set OPTIND and OPTERR to their
115 default values and to clear the initialization flag. */ 98 default values and to clear the initialization flag. */
116#define _GETOPT_DATA_INITIALIZER { 1, 1 } 99#define _GETOPT_DATA_INITIALIZER { 1, 1 }
117 100
118extern int _getopt_internal_r (int ___argc, char **___argv, 101extern int _getopt_internal_r (int ___argc, char **___argv,
119 const char *__shortopts, 102 const char *__shortopts,
120 const struct option *__longopts, int *__longind, 103 const struct option *__longopts, int *__longind,
121 int __long_only, struct _getopt_data *__data, 104 int __long_only, struct _getopt_data *__data,
122 int __posixly_correct); 105 int __posixly_correct);
123 106
124extern int _getopt_long_r (int ___argc, char **___argv, 107extern int _getopt_long_r (int ___argc, char **___argv,
125 const char *__shortopts, 108 const char *__shortopts,
126 const struct option *__longopts, int *__longind, 109 const struct option *__longopts, int *__longind,
127 struct _getopt_data *__data); 110 struct _getopt_data *__data);
128 111
129extern int _getopt_long_only_r (int ___argc, char **___argv, 112extern int _getopt_long_only_r (int ___argc, char **___argv,
130 const char *__shortopts, 113 const char *__shortopts,
131 const struct option *__longopts, 114 const struct option *__longopts,
132 int *__longind, 115 int *__longind,
133 struct _getopt_data *__data); 116 struct _getopt_data *__data);
134 117
135#endif /* getopt_int.h */ 118#endif /* getopt_int.h */
diff --git a/gl/getprogname.c b/gl/getprogname.c
new file mode 100644
index 00000000..32c96043
--- /dev/null
+++ b/gl/getprogname.c
@@ -0,0 +1,302 @@
1/* Program name management.
2 Copyright (C) 2016-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include "getprogname.h"
21
22#include <errno.h> /* get program_invocation_name declaration */
23#include <stdlib.h> /* get __argv declaration */
24
25#ifdef _AIX
26# include <unistd.h>
27# include <procinfo.h>
28# include <string.h>
29#endif
30
31#ifdef __MVS__
32# ifndef _OPEN_SYS
33# define _OPEN_SYS
34# endif
35# include <string.h>
36# include <sys/ps.h>
37#endif
38
39#ifdef __hpux
40# include <unistd.h>
41# include <sys/param.h>
42# include <sys/pstat.h>
43# include <string.h>
44#endif
45
46#if defined __sgi || defined __osf__
47# include <string.h>
48# include <unistd.h>
49# include <stdio.h>
50# include <fcntl.h>
51# include <sys/procfs.h>
52#endif
53
54#if defined __SCO_VERSION__ || defined __sysv5__
55# include <fcntl.h>
56# include <stdlib.h>
57# include <string.h>
58#endif
59
60#include "basename-lgpl.h"
61
62#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
63char const *
64getprogname (void)
65{
66# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* glibc, BeOS */
67 /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
68 return program_invocation_short_name;
69# elif HAVE_DECL_PROGRAM_INVOCATION_NAME /* glibc, BeOS */
70 /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
71 return last_component (program_invocation_name);
72# elif HAVE_GETEXECNAME /* Solaris */
73 /* https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */
74 const char *p = getexecname ();
75 if (!p)
76 p = "?";
77 return last_component (p);
78# elif HAVE_DECL___ARGV /* mingw, MSVC */
79 /* https://docs.microsoft.com/en-us/cpp/c-runtime-library/argc-argv-wargv */
80 const char *p = __argv && __argv[0] ? __argv[0] : "?";
81 return last_component (p);
82# elif HAVE_VAR___PROGNAME /* OpenBSD, Android, QNX */
83 /* https://man.openbsd.org/style.9 */
84 /* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */
85 /* Be careful to declare this only when we absolutely need it
86 (OpenBSD 5.1), rather than when it's available. Otherwise,
87 its mere declaration makes program_invocation_short_name
88 malfunction (have zero length) with Fedora 25's glibc. */
89 extern char *__progname;
90 const char *p = __progname;
91# if defined __ANDROID__
92 return last_component (p);
93# else
94 return p && p[0] ? p : "?";
95# endif
96# elif _AIX /* AIX */
97 /* Idea by Bastien ROUCARIÈS,
98 https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html
99 Reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.basetrf1/getprocs.htm
100 */
101 static char *p;
102 static int first = 1;
103 if (first)
104 {
105 first = 0;
106 pid_t pid = getpid ();
107 struct procentry64 procs;
108 p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1)
109 ? strdup (procs.pi_comm)
110 : NULL);
111 if (!p)
112 p = "?";
113 }
114 return p;
115# elif defined __hpux
116 static char *p;
117 static int first = 1;
118 if (first)
119 {
120 first = 0;
121 pid_t pid = getpid ();
122 struct pst_status status;
123 if (pstat_getproc (&status, sizeof status, 0, pid) > 0)
124 {
125 char *ucomm = status.pst_ucomm;
126 char *cmd = status.pst_cmd;
127 if (strlen (ucomm) < PST_UCOMMLEN - 1)
128 p = ucomm;
129 else
130 {
131 /* ucomm is truncated to length PST_UCOMMLEN - 1.
132 Look at cmd instead. */
133 char *space = strchr (cmd, ' ');
134 if (space != NULL)
135 *space = '\0';
136 p = strrchr (cmd, '/');
137 if (p != NULL)
138 p++;
139 else
140 p = cmd;
141 if (strlen (p) > PST_UCOMMLEN - 1
142 && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
143 /* p is less truncated than ucomm. */
144 ;
145 else
146 p = ucomm;
147 }
148 p = strdup (p);
149 }
150 else
151 {
152# if !defined __LP64__
153 /* Support for 32-bit programs running in 64-bit HP-UX.
154 The documented way to do this is to use the same source code
155 as above, but in a compilation unit where '#define _PSTAT64 1'
156 is in effect. I prefer a single compilation unit; the struct
157 size and the offsets are not going to change. */
158 char status64[1216];
159 if (__pstat_getproc64 (status64, sizeof status64, 0, pid) > 0)
160 {
161 char *ucomm = status64 + 288;
162 char *cmd = status64 + 168;
163 if (strlen (ucomm) < PST_UCOMMLEN - 1)
164 p = ucomm;
165 else
166 {
167 /* ucomm is truncated to length PST_UCOMMLEN - 1.
168 Look at cmd instead. */
169 char *space = strchr (cmd, ' ');
170 if (space != NULL)
171 *space = '\0';
172 p = strrchr (cmd, '/');
173 if (p != NULL)
174 p++;
175 else
176 p = cmd;
177 if (strlen (p) > PST_UCOMMLEN - 1
178 && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
179 /* p is less truncated than ucomm. */
180 ;
181 else
182 p = ucomm;
183 }
184 p = strdup (p);
185 }
186 else
187# endif
188 p = NULL;
189 }
190 if (!p)
191 p = "?";
192 }
193 return p;
194# elif __MVS__ /* z/OS */
195 /* https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm */
196 static char *p = "?";
197 static int first = 1;
198 if (first)
199 {
200 pid_t pid = getpid ();
201 int token;
202 W_PSPROC buf;
203 first = 0;
204 memset (&buf, 0, sizeof(buf));
205 buf.ps_cmdptr = (char *) malloc (buf.ps_cmdlen = PS_CMDBLEN_LONG);
206 buf.ps_conttyptr = (char *) malloc (buf.ps_conttylen = PS_CONTTYBLEN);
207 buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN);
208 if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr)
209 {
210 for (token = 0; token >= 0;
211 token = w_getpsent (token, &buf, sizeof(buf)))
212 {
213 if (token > 0 && buf.ps_pid == pid)
214 {
215 char *s = strdup (last_component (buf.ps_pathptr));
216 if (s)
217 p = s;
218 break;
219 }
220 }
221 }
222 free (buf.ps_cmdptr);
223 free (buf.ps_conttyptr);
224 free (buf.ps_pathptr);
225 }
226 return p;
227# elif defined __sgi || defined __osf__ /* IRIX or Tru64 */
228 char filename[50];
229 int fd;
230
231 # if defined __sgi
232 sprintf (filename, "/proc/pinfo/%d", (int) getpid ());
233 # else
234 sprintf (filename, "/proc/%d", (int) getpid ());
235 # endif
236 fd = open (filename, O_RDONLY | O_CLOEXEC);
237 if (0 <= fd)
238 {
239 prpsinfo_t buf;
240 int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf);
241 close (fd);
242 if (ioctl_ok)
243 {
244 char *name = buf.pr_fname;
245 size_t namesize = sizeof buf.pr_fname;
246 /* It may not be NUL-terminated. */
247 char *namenul = memchr (name, '\0', namesize);
248 size_t namelen = namenul ? namenul - name : namesize;
249 char *namecopy = malloc (namelen + 1);
250 if (namecopy)
251 {
252 namecopy[namelen] = '\0';
253 return memcpy (namecopy, name, namelen);
254 }
255 }
256 }
257 return NULL;
258# elif defined __SCO_VERSION__ || defined __sysv5__ /* SCO OpenServer6/UnixWare */
259 char buf[80];
260 int fd;
261 sprintf (buf, "/proc/%d/cmdline", getpid());
262 fd = open (buf, O_RDONLY);
263 if (0 <= fd)
264 {
265 size_t n = read (fd, buf, 79);
266 if (n > 0)
267 {
268 buf[n] = '\0'; /* Guarantee null-termination */
269 char *progname;
270 progname = strrchr (buf, '/');
271 if (progname)
272 {
273 progname = progname + 1; /* Skip the '/' */
274 }
275 else
276 {
277 progname = buf;
278 }
279 char *ret;
280 ret = malloc (strlen (progname) + 1);
281 if (ret)
282 {
283 strcpy (ret, progname);
284 return ret;
285 }
286 }
287 close (fd);
288 }
289 return "?";
290# else
291# error "getprogname module not ported to this OS"
292# endif
293}
294
295#endif
296
297/*
298 * Hey Emacs!
299 * Local Variables:
300 * coding: utf-8
301 * End:
302 */
diff --git a/gl/getprogname.h b/gl/getprogname.h
new file mode 100644
index 00000000..4b9126f9
--- /dev/null
+++ b/gl/getprogname.h
@@ -0,0 +1,40 @@
1/* Program name management.
2 Copyright (C) 2016-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _GL_GETPROGNAME_H
18#define _GL_GETPROGNAME_H
19
20#include <stdlib.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/* Return the base name of the executing program.
27 On native Windows this will usually end in ".exe" or ".EXE". */
28#ifndef HAVE_GETPROGNAME
29extern char const *getprogname (void)
30# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
31 _GL_ATTRIBUTE_PURE
32# endif
33 ;
34#endif
35
36#ifdef __cplusplus
37}
38#endif
39
40#endif
diff --git a/gl/gettext.h b/gl/gettext.h
index d0215715..d0462c47 100644
--- a/gl/gettext.h
+++ b/gl/gettext.h
@@ -1,25 +1,26 @@
1/* Convenience header for conditional use of GNU <libintl.h>. 1/* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software 2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _LIBGETTEXT_H 18#ifndef _LIBGETTEXT_H
19#define _LIBGETTEXT_H 1 19#define _LIBGETTEXT_H 1
20 20
21/* NLS can be disabled through the configure --disable-nls option. */ 21/* NLS can be disabled through the configure --disable-nls option
22#if ENABLE_NLS 22 or through "#define ENABLE NLS 0" before including this file. */
23#if defined ENABLE_NLS && ENABLE_NLS
23 24
24/* Get declarations of GNU message catalog functions. */ 25/* Get declarations of GNU message catalog functions. */
25# include <libintl.h> 26# include <libintl.h>
@@ -137,7 +138,7 @@
137#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ 138#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
138 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) 139 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
139 140
140#ifdef __GNUC__ 141#if defined __GNUC__ || defined __clang__
141__inline 142__inline
142#else 143#else
143#ifdef __cplusplus 144#ifdef __cplusplus
@@ -156,7 +157,7 @@ pgettext_aux (const char *domain,
156 return translation; 157 return translation;
157} 158}
158 159
159#ifdef __GNUC__ 160#if defined __GNUC__ || defined __clang__
160__inline 161__inline
161#else 162#else
162#ifdef __cplusplus 163#ifdef __cplusplus
@@ -183,8 +184,15 @@ npgettext_aux (const char *domain,
183 184
184#include <string.h> 185#include <string.h>
185 186
186#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ 187/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
187 /* || __STDC_VERSION__ >= 199901L */ ) 188 This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
189 the default GCC many warnings set. This allows programs to disable use
190 of VLAs, which may be unintended, or may be awkward to support portably,
191 or may have security implications due to non-deterministic stack usage. */
192
193#if (!defined GNULIB_NO_VLA \
194 && defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
195 && !defined __STDC_NO_VLA__)
188# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 196# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
189#else 197#else
190# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 198# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
@@ -199,7 +207,7 @@ npgettext_aux (const char *domain,
199#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ 207#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
200 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) 208 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
201 209
202#ifdef __GNUC__ 210#if defined __GNUC__ || defined __clang__
203__inline 211__inline
204#else 212#else
205#ifdef __cplusplus 213#ifdef __cplusplus
@@ -225,15 +233,17 @@ dcpgettext_expr (const char *domain,
225 if (msg_ctxt_id != NULL) 233 if (msg_ctxt_id != NULL)
226#endif 234#endif
227 { 235 {
236 int found_translation;
228 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 237 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
229 msg_ctxt_id[msgctxt_len - 1] = '\004'; 238 msg_ctxt_id[msgctxt_len - 1] = '\004';
230 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 239 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
231 translation = dcgettext (domain, msg_ctxt_id, category); 240 translation = dcgettext (domain, msg_ctxt_id, category);
241 found_translation = (translation != msg_ctxt_id);
232#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 242#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
233 if (msg_ctxt_id != buf) 243 if (msg_ctxt_id != buf)
234 free (msg_ctxt_id); 244 free (msg_ctxt_id);
235#endif 245#endif
236 if (translation != msg_ctxt_id) 246 if (found_translation)
237 return translation; 247 return translation;
238 } 248 }
239 return msgid; 249 return msgid;
@@ -244,7 +254,7 @@ dcpgettext_expr (const char *domain,
244#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ 254#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
245 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) 255 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
246 256
247#ifdef __GNUC__ 257#if defined __GNUC__ || defined __clang__
248__inline 258__inline
249#else 259#else
250#ifdef __cplusplus 260#ifdef __cplusplus
@@ -271,15 +281,17 @@ dcnpgettext_expr (const char *domain,
271 if (msg_ctxt_id != NULL) 281 if (msg_ctxt_id != NULL)
272#endif 282#endif
273 { 283 {
284 int found_translation;
274 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 285 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
275 msg_ctxt_id[msgctxt_len - 1] = '\004'; 286 msg_ctxt_id[msgctxt_len - 1] = '\004';
276 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 287 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
277 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); 288 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
289 found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
278#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 290#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
279 if (msg_ctxt_id != buf) 291 if (msg_ctxt_id != buf)
280 free (msg_ctxt_id); 292 free (msg_ctxt_id);
281#endif 293#endif
282 if (!(translation == msg_ctxt_id || translation == msgid_plural)) 294 if (found_translation)
283 return translation; 295 return translation;
284 } 296 }
285 return (n == 1 ? msgid : msgid_plural); 297 return (n == 1 ? msgid : msgid_plural);
diff --git a/gl/gl_openssl.h b/gl/gl_openssl.h
new file mode 100644
index 00000000..f63c386e
--- /dev/null
+++ b/gl/gl_openssl.h
@@ -0,0 +1,116 @@
1/* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*-
2
3 Copyright (C) 2013-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Pádraig Brady */
19
20#ifndef GL_OPENSSL_NAME
21# error "Please define GL_OPENSSL_NAME to 1,5,256 etc."
22#endif
23
24#ifndef _GL_INLINE_HEADER_BEGIN
25# error "Please include config.h first."
26#endif
27_GL_INLINE_HEADER_BEGIN
28#ifndef GL_OPENSSL_INLINE
29# define GL_OPENSSL_INLINE _GL_INLINE
30#endif
31
32/* Concatenate two preprocessor tokens. */
33#define _GLCRYPTO_CONCAT_(prefix, suffix) prefix##suffix
34#define _GLCRYPTO_CONCAT(prefix, suffix) _GLCRYPTO_CONCAT_ (prefix, suffix)
35
36#if GL_OPENSSL_NAME == 5
37# define OPENSSL_ALG md5
38#else
39# define OPENSSL_ALG _GLCRYPTO_CONCAT (sha, GL_OPENSSL_NAME)
40#endif
41
42/* Context type mappings. */
43#if BASE_OPENSSL_TYPE != GL_OPENSSL_NAME
44# undef BASE_OPENSSL_TYPE
45# if GL_OPENSSL_NAME == 224
46# define BASE_OPENSSL_TYPE 256
47# elif GL_OPENSSL_NAME == 384
48# define BASE_OPENSSL_TYPE 512
49# endif
50# define md5_CTX MD5_CTX
51# define sha1_CTX SHA_CTX
52# define sha224_CTX SHA256_CTX
53# define sha224_ctx sha256_ctx
54# define sha256_CTX SHA256_CTX
55# define sha384_CTX SHA512_CTX
56# define sha384_ctx sha512_ctx
57# define sha512_CTX SHA512_CTX
58# undef _gl_CTX
59# undef _gl_ctx
60# define _gl_CTX _GLCRYPTO_CONCAT (OPENSSL_ALG, _CTX) /* openssl type. */
61# define _gl_ctx _GLCRYPTO_CONCAT (OPENSSL_ALG, _ctx) /* gnulib type. */
62
63struct _gl_ctx { _gl_CTX CTX; };
64#endif
65
66/* Function name mappings. */
67#define md5_prefix MD5
68#define sha1_prefix SHA1
69#define sha224_prefix SHA224
70#define sha256_prefix SHA256
71#define sha384_prefix SHA384
72#define sha512_prefix SHA512
73#define _GLCRYPTO_PREFIX _GLCRYPTO_CONCAT (OPENSSL_ALG, _prefix)
74#define OPENSSL_FN(suffix) _GLCRYPTO_CONCAT (_GLCRYPTO_PREFIX, suffix)
75#define GL_CRYPTO_FN(suffix) _GLCRYPTO_CONCAT (OPENSSL_ALG, suffix)
76
77GL_OPENSSL_INLINE void
78GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx)
79{ (void) OPENSSL_FN (_Init) ((_gl_CTX *) ctx); }
80
81/* These were never exposed by gnulib. */
82#if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384)
83GL_OPENSSL_INLINE void
84GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx *ctx)
85{ OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); }
86
87GL_OPENSSL_INLINE void
88GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx *ctx)
89{ GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); }
90#endif
91
92GL_OPENSSL_INLINE void *
93GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *restrict res)
94{ OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; }
95
96GL_OPENSSL_INLINE void *
97GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *restrict res)
98{ return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) res); }
99
100GL_OPENSSL_INLINE void *
101GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
102{
103 /* Assume any unprocessed bytes in ctx are not to be ignored. */
104 _gl_CTX tmp_ctx = *(_gl_CTX *) ctx;
105 OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
106 return res;
107}
108
109/* Undef so we can include multiple times. */
110#undef GL_CRYPTO_FN
111#undef OPENSSL_FN
112#undef _GLCRYPTO_PREFIX
113#undef OPENSSL_ALG
114#undef GL_OPENSSL_NAME
115
116_GL_INLINE_HEADER_END
diff --git a/gl/glthread/lock.c b/gl/glthread/lock.c
index f62aa301..82fb7553 100644
--- a/gl/glthread/lock.c
+++ b/gl/glthread/lock.c
@@ -1,22 +1,21 @@
1/* Locking in multithreaded situations. 1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005. 17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, 18 Based on GCC's gthr-posix.h, gthr-posix95.h. */
19 gthr-win32.h. */
20 19
21#include <config.h> 20#include <config.h>
22 21
@@ -24,15 +23,267 @@
24 23
25/* ========================================================================= */ 24/* ========================================================================= */
26 25
26#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS
27
28/* -------------------------- gl_lock_t datatype -------------------------- */
29
30int
31glthread_lock_init (gl_lock_t *lock)
32{
33 if (mtx_init (&lock->mutex, mtx_plain) != thrd_success)
34 return ENOMEM;
35 lock->init_needed = 0;
36 return 0;
37}
38
39int
40glthread_lock_lock (gl_lock_t *lock)
41{
42 if (lock->init_needed)
43 call_once (&lock->init_once, lock->init_func);
44 if (mtx_lock (&lock->mutex) != thrd_success)
45 return EAGAIN;
46 return 0;
47}
48
49int
50glthread_lock_unlock (gl_lock_t *lock)
51{
52 if (lock->init_needed)
53 call_once (&lock->init_once, lock->init_func);
54 if (mtx_unlock (&lock->mutex) != thrd_success)
55 return EINVAL;
56 return 0;
57}
58
59int
60glthread_lock_destroy (gl_lock_t *lock)
61{
62 if (lock->init_needed)
63 call_once (&lock->init_once, lock->init_func);
64 mtx_destroy (&lock->mutex);
65 return 0;
66}
67
68/* ------------------------- gl_rwlock_t datatype ------------------------- */
69
70int
71glthread_rwlock_init (gl_rwlock_t *lock)
72{
73 if (mtx_init (&lock->lock, mtx_plain) != thrd_success
74 || cnd_init (&lock->waiting_readers) != thrd_success
75 || cnd_init (&lock->waiting_writers) != thrd_success)
76 return ENOMEM;
77 lock->waiting_writers_count = 0;
78 lock->runcount = 0;
79 lock->init_needed = 0;
80 return 0;
81}
82
83int
84glthread_rwlock_rdlock (gl_rwlock_t *lock)
85{
86 if (lock->init_needed)
87 call_once (&lock->init_once, lock->init_func);
88 if (mtx_lock (&lock->lock) != thrd_success)
89 return EAGAIN;
90 /* Test whether only readers are currently running, and whether the runcount
91 field will not overflow, and whether no writer is waiting. The latter
92 condition is because POSIX recommends that "write locks shall take
93 precedence over read locks", to avoid "writer starvation". */
94 while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
95 {
96 /* This thread has to wait for a while. Enqueue it among the
97 waiting_readers. */
98 if (cnd_wait (&lock->waiting_readers, &lock->lock) != thrd_success)
99 {
100 mtx_unlock (&lock->lock);
101 return EINVAL;
102 }
103 }
104 lock->runcount++;
105 if (mtx_unlock (&lock->lock) != thrd_success)
106 return EINVAL;
107 return 0;
108}
109
110int
111glthread_rwlock_wrlock (gl_rwlock_t *lock)
112{
113 if (lock->init_needed)
114 call_once (&lock->init_once, lock->init_func);
115 if (mtx_lock (&lock->lock) != thrd_success)
116 return EAGAIN;
117 /* Test whether no readers or writers are currently running. */
118 while (!(lock->runcount == 0))
119 {
120 /* This thread has to wait for a while. Enqueue it among the
121 waiting_writers. */
122 lock->waiting_writers_count++;
123 if (cnd_wait (&lock->waiting_writers, &lock->lock) != thrd_success)
124 {
125 lock->waiting_writers_count--;
126 mtx_unlock (&lock->lock);
127 return EINVAL;
128 }
129 lock->waiting_writers_count--;
130 }
131 lock->runcount--; /* runcount becomes -1 */
132 if (mtx_unlock (&lock->lock) != thrd_success)
133 return EINVAL;
134 return 0;
135}
136
137int
138glthread_rwlock_unlock (gl_rwlock_t *lock)
139{
140 if (lock->init_needed)
141 call_once (&lock->init_once, lock->init_func);
142 if (mtx_lock (&lock->lock) != thrd_success)
143 return EAGAIN;
144 if (lock->runcount < 0)
145 {
146 /* Drop a writer lock. */
147 if (!(lock->runcount == -1))
148 {
149 mtx_unlock (&lock->lock);
150 return EINVAL;
151 }
152 lock->runcount = 0;
153 }
154 else
155 {
156 /* Drop a reader lock. */
157 if (!(lock->runcount > 0))
158 {
159 mtx_unlock (&lock->lock);
160 return EINVAL;
161 }
162 lock->runcount--;
163 }
164 if (lock->runcount == 0)
165 {
166 /* POSIX recommends that "write locks shall take precedence over read
167 locks", to avoid "writer starvation". */
168 if (lock->waiting_writers_count > 0)
169 {
170 /* Wake up one of the waiting writers. */
171 if (cnd_signal (&lock->waiting_writers) != thrd_success)
172 {
173 mtx_unlock (&lock->lock);
174 return EINVAL;
175 }
176 }
177 else
178 {
179 /* Wake up all waiting readers. */
180 if (cnd_broadcast (&lock->waiting_readers) != thrd_success)
181 {
182 mtx_unlock (&lock->lock);
183 return EINVAL;
184 }
185 }
186 }
187 if (mtx_unlock (&lock->lock) != thrd_success)
188 return EINVAL;
189 return 0;
190}
191
192int
193glthread_rwlock_destroy (gl_rwlock_t *lock)
194{
195 if (lock->init_needed)
196 call_once (&lock->init_once, lock->init_func);
197 mtx_destroy (&lock->lock);
198 cnd_destroy (&lock->waiting_readers);
199 cnd_destroy (&lock->waiting_writers);
200 return 0;
201}
202
203/* --------------------- gl_recursive_lock_t datatype --------------------- */
204
205int
206glthread_recursive_lock_init (gl_recursive_lock_t *lock)
207{
208 if (mtx_init (&lock->mutex, mtx_plain | mtx_recursive) != thrd_success)
209 return ENOMEM;
210 lock->init_needed = 0;
211 return 0;
212}
213
214int
215glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
216{
217 if (lock->init_needed)
218 call_once (&lock->init_once, lock->init_func);
219 if (mtx_lock (&lock->mutex) != thrd_success)
220 return EAGAIN;
221 return 0;
222}
223
224int
225glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
226{
227 if (lock->init_needed)
228 call_once (&lock->init_once, lock->init_func);
229 if (mtx_unlock (&lock->mutex) != thrd_success)
230 return EINVAL;
231 return 0;
232}
233
234int
235glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
236{
237 if (lock->init_needed)
238 call_once (&lock->init_once, lock->init_func);
239 mtx_destroy (&lock->mutex);
240 return 0;
241}
242
243/* -------------------------- gl_once_t datatype -------------------------- */
244
245#endif
246
247/* ========================================================================= */
248
27#if USE_POSIX_THREADS 249#if USE_POSIX_THREADS
28 250
29/* -------------------------- gl_lock_t datatype -------------------------- */ 251/* -------------------------- gl_lock_t datatype -------------------------- */
30 252
31/* ------------------------- gl_rwlock_t datatype ------------------------- */ 253/* ------------------------- gl_rwlock_t datatype ------------------------- */
32 254
33# if HAVE_PTHREAD_RWLOCK 255# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
256
257# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP
258
259# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
260 /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
261
262int
263glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
264{
265 pthread_rwlockattr_t attributes;
266 int err;
34 267
35# if !defined PTHREAD_RWLOCK_INITIALIZER 268 err = pthread_rwlockattr_init (&attributes);
269 if (err != 0)
270 return err;
271 /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that
272 causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not
273 do this; see
274 http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
275 err = pthread_rwlockattr_setkind_np (&attributes,
276 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
277 if (err == 0)
278 err = pthread_rwlock_init(lock, &attributes);
279 /* pthread_rwlockattr_destroy always returns 0. It cannot influence the
280 return value. */
281 pthread_rwlockattr_destroy (&attributes);
282 return err;
283}
284
285# endif
286# else
36 287
37int 288int
38glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) 289glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
@@ -152,11 +403,9 @@ glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
152 if (err != 0) 403 if (err != 0)
153 return err; 404 return err;
154 /* Test whether only readers are currently running, and whether the runcount 405 /* Test whether only readers are currently running, and whether the runcount
155 field will not overflow. */ 406 field will not overflow, and whether no writer is waiting. The latter
156 /* POSIX says: "It is implementation-defined whether the calling thread 407 condition is because POSIX recommends that "write locks shall take
157 acquires the lock when a writer does not hold the lock and there are 408 precedence over read locks", to avoid "writer starvation". */
158 writers blocked on the lock." Let's say, no: give the writers a higher
159 priority. */
160 while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) 409 while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
161 { 410 {
162 /* This thread has to wait for a while. Enqueue it among the 411 /* This thread has to wait for a while. Enqueue it among the
@@ -469,161 +718,25 @@ glthread_once_singlethreaded (pthread_once_t *once_control)
469 return 0; 718 return 0;
470} 719}
471 720
472#endif 721# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK)
473
474/* ========================================================================= */
475
476#if USE_PTH_THREADS
477
478/* Use the GNU Pth threads library. */
479
480/* -------------------------- gl_lock_t datatype -------------------------- */
481
482/* ------------------------- gl_rwlock_t datatype ------------------------- */
483
484/* --------------------- gl_recursive_lock_t datatype --------------------- */
485
486/* -------------------------- gl_once_t datatype -------------------------- */
487
488static void
489glthread_once_call (void *arg)
490{
491 void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
492 void (*initfunction) (void) = *gl_once_temp_addr;
493 initfunction ();
494}
495
496int
497glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void))
498{
499 void (*temp) (void) = initfunction;
500 return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0);
501}
502
503int
504glthread_once_singlethreaded (pth_once_t *once_control)
505{
506 /* We know that pth_once_t is an integer type. */
507 if (*once_control == PTH_ONCE_INIT)
508 {
509 /* First time use of once_control. Invert the marker. */
510 *once_control = ~ PTH_ONCE_INIT;
511 return 1;
512 }
513 else
514 return 0;
515}
516
517#endif
518
519/* ========================================================================= */
520
521#if USE_SOLARIS_THREADS
522
523/* Use the old Solaris threads library. */
524
525/* -------------------------- gl_lock_t datatype -------------------------- */
526
527/* ------------------------- gl_rwlock_t datatype ------------------------- */
528
529/* --------------------- gl_recursive_lock_t datatype --------------------- */
530 722
531int 723int
532glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) 724glthread_once_multithreaded (pthread_once_t *once_control,
725 void (*init_function) (void))
533{ 726{
534 int err; 727 int err = pthread_once (once_control, init_function);
535 728 if (err == ENOSYS)
536 err = mutex_init (&lock->mutex, USYNC_THREAD, NULL);
537 if (err != 0)
538 return err;
539 lock->owner = (thread_t) 0;
540 lock->depth = 0;
541 return 0;
542}
543
544int
545glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
546{
547 thread_t self = thr_self ();
548 if (lock->owner != self)
549 { 729 {
550 int err; 730 /* This happens on FreeBSD 11: The pthread_once function in libc returns
551 731 ENOSYS. */
552 err = mutex_lock (&lock->mutex); 732 if (glthread_once_singlethreaded (once_control))
553 if (err != 0) 733 init_function ();
554 return err; 734 return 0;
555 lock->owner = self;
556 } 735 }
557 if (++(lock->depth) == 0) /* wraparound? */ 736 return err;
558 {
559 lock->depth--;
560 return EAGAIN;
561 }
562 return 0;
563} 737}
564 738
565int 739# endif
566glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
567{
568 if (lock->owner != thr_self ())
569 return EPERM;
570 if (lock->depth == 0)
571 return EINVAL;
572 if (--(lock->depth) == 0)
573 {
574 lock->owner = (thread_t) 0;
575 return mutex_unlock (&lock->mutex);
576 }
577 else
578 return 0;
579}
580
581int
582glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
583{
584 if (lock->owner != (thread_t) 0)
585 return EBUSY;
586 return mutex_destroy (&lock->mutex);
587}
588
589/* -------------------------- gl_once_t datatype -------------------------- */
590
591int
592glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void))
593{
594 if (!once_control->inited)
595 {
596 int err;
597
598 /* Use the mutex to guarantee that if another thread is already calling
599 the initfunction, this thread waits until it's finished. */
600 err = mutex_lock (&once_control->mutex);
601 if (err != 0)
602 return err;
603 if (!once_control->inited)
604 {
605 once_control->inited = 1;
606 initfunction ();
607 }
608 return mutex_unlock (&once_control->mutex);
609 }
610 else
611 return 0;
612}
613
614int
615glthread_once_singlethreaded (gl_once_t *once_control)
616{
617 /* We know that gl_once_t contains an integer type. */
618 if (!once_control->inited)
619 {
620 /* First time use of once_control. Invert the marker. */
621 once_control->inited = ~ 0;
622 return 1;
623 }
624 else
625 return 0;
626}
627 740
628#endif 741#endif
629 742
@@ -631,427 +744,6 @@ glthread_once_singlethreaded (gl_once_t *once_control)
631 744
632#if USE_WINDOWS_THREADS 745#if USE_WINDOWS_THREADS
633 746
634/* -------------------------- gl_lock_t datatype -------------------------- */
635
636void
637glthread_lock_init_func (gl_lock_t *lock)
638{
639 InitializeCriticalSection (&lock->lock);
640 lock->guard.done = 1;
641}
642
643int
644glthread_lock_lock_func (gl_lock_t *lock)
645{
646 if (!lock->guard.done)
647 {
648 if (InterlockedIncrement (&lock->guard.started) == 0)
649 /* This thread is the first one to need this lock. Initialize it. */
650 glthread_lock_init (lock);
651 else
652 /* Yield the CPU while waiting for another thread to finish
653 initializing this lock. */
654 while (!lock->guard.done)
655 Sleep (0);
656 }
657 EnterCriticalSection (&lock->lock);
658 return 0;
659}
660
661int
662glthread_lock_unlock_func (gl_lock_t *lock)
663{
664 if (!lock->guard.done)
665 return EINVAL;
666 LeaveCriticalSection (&lock->lock);
667 return 0;
668}
669
670int
671glthread_lock_destroy_func (gl_lock_t *lock)
672{
673 if (!lock->guard.done)
674 return EINVAL;
675 DeleteCriticalSection (&lock->lock);
676 lock->guard.done = 0;
677 return 0;
678}
679
680/* ------------------------- gl_rwlock_t datatype ------------------------- */
681
682/* In this file, the waitqueues are implemented as circular arrays. */
683#define gl_waitqueue_t gl_carray_waitqueue_t
684
685static void
686gl_waitqueue_init (gl_waitqueue_t *wq)
687{
688 wq->array = NULL;
689 wq->count = 0;
690 wq->alloc = 0;
691 wq->offset = 0;
692}
693
694/* Enqueues the current thread, represented by an event, in a wait queue.
695 Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
696static HANDLE
697gl_waitqueue_add (gl_waitqueue_t *wq)
698{
699 HANDLE event;
700 unsigned int index;
701
702 if (wq->count == wq->alloc)
703 {
704 unsigned int new_alloc = 2 * wq->alloc + 1;
705 HANDLE *new_array =
706 (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
707 if (new_array == NULL)
708 /* No more memory. */
709 return INVALID_HANDLE_VALUE;
710 /* Now is a good opportunity to rotate the array so that its contents
711 starts at offset 0. */
712 if (wq->offset > 0)
713 {
714 unsigned int old_count = wq->count;
715 unsigned int old_alloc = wq->alloc;
716 unsigned int old_offset = wq->offset;
717 unsigned int i;
718 if (old_offset + old_count > old_alloc)
719 {
720 unsigned int limit = old_offset + old_count - old_alloc;
721 for (i = 0; i < limit; i++)
722 new_array[old_alloc + i] = new_array[i];
723 }
724 for (i = 0; i < old_count; i++)
725 new_array[i] = new_array[old_offset + i];
726 wq->offset = 0;
727 }
728 wq->array = new_array;
729 wq->alloc = new_alloc;
730 }
731 /* Whether the created event is a manual-reset one or an auto-reset one,
732 does not matter, since we will wait on it only once. */
733 event = CreateEvent (NULL, TRUE, FALSE, NULL);
734 if (event == INVALID_HANDLE_VALUE)
735 /* No way to allocate an event. */
736 return INVALID_HANDLE_VALUE;
737 index = wq->offset + wq->count;
738 if (index >= wq->alloc)
739 index -= wq->alloc;
740 wq->array[index] = event;
741 wq->count++;
742 return event;
743}
744
745/* Notifies the first thread from a wait queue and dequeues it. */
746static void
747gl_waitqueue_notify_first (gl_waitqueue_t *wq)
748{
749 SetEvent (wq->array[wq->offset + 0]);
750 wq->offset++;
751 wq->count--;
752 if (wq->count == 0 || wq->offset == wq->alloc)
753 wq->offset = 0;
754}
755
756/* Notifies all threads from a wait queue and dequeues them all. */
757static void
758gl_waitqueue_notify_all (gl_waitqueue_t *wq)
759{
760 unsigned int i;
761
762 for (i = 0; i < wq->count; i++)
763 {
764 unsigned int index = wq->offset + i;
765 if (index >= wq->alloc)
766 index -= wq->alloc;
767 SetEvent (wq->array[index]);
768 }
769 wq->count = 0;
770 wq->offset = 0;
771}
772
773void
774glthread_rwlock_init_func (gl_rwlock_t *lock)
775{
776 InitializeCriticalSection (&lock->lock);
777 gl_waitqueue_init (&lock->waiting_readers);
778 gl_waitqueue_init (&lock->waiting_writers);
779 lock->runcount = 0;
780 lock->guard.done = 1;
781}
782
783int
784glthread_rwlock_rdlock_func (gl_rwlock_t *lock)
785{
786 if (!lock->guard.done)
787 {
788 if (InterlockedIncrement (&lock->guard.started) == 0)
789 /* This thread is the first one to need this lock. Initialize it. */
790 glthread_rwlock_init (lock);
791 else
792 /* Yield the CPU while waiting for another thread to finish
793 initializing this lock. */
794 while (!lock->guard.done)
795 Sleep (0);
796 }
797 EnterCriticalSection (&lock->lock);
798 /* Test whether only readers are currently running, and whether the runcount
799 field will not overflow. */
800 if (!(lock->runcount + 1 > 0))
801 {
802 /* This thread has to wait for a while. Enqueue it among the
803 waiting_readers. */
804 HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
805 if (event != INVALID_HANDLE_VALUE)
806 {
807 DWORD result;
808 LeaveCriticalSection (&lock->lock);
809 /* Wait until another thread signals this event. */
810 result = WaitForSingleObject (event, INFINITE);
811 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
812 abort ();
813 CloseHandle (event);
814 /* The thread which signalled the event already did the bookkeeping:
815 removed us from the waiting_readers, incremented lock->runcount. */
816 if (!(lock->runcount > 0))
817 abort ();
818 return 0;
819 }
820 else
821 {
822 /* Allocation failure. Weird. */
823 do
824 {
825 LeaveCriticalSection (&lock->lock);
826 Sleep (1);
827 EnterCriticalSection (&lock->lock);
828 }
829 while (!(lock->runcount + 1 > 0));
830 }
831 }
832 lock->runcount++;
833 LeaveCriticalSection (&lock->lock);
834 return 0;
835}
836
837int
838glthread_rwlock_wrlock_func (gl_rwlock_t *lock)
839{
840 if (!lock->guard.done)
841 {
842 if (InterlockedIncrement (&lock->guard.started) == 0)
843 /* This thread is the first one to need this lock. Initialize it. */
844 glthread_rwlock_init (lock);
845 else
846 /* Yield the CPU while waiting for another thread to finish
847 initializing this lock. */
848 while (!lock->guard.done)
849 Sleep (0);
850 }
851 EnterCriticalSection (&lock->lock);
852 /* Test whether no readers or writers are currently running. */
853 if (!(lock->runcount == 0))
854 {
855 /* This thread has to wait for a while. Enqueue it among the
856 waiting_writers. */
857 HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
858 if (event != INVALID_HANDLE_VALUE)
859 {
860 DWORD result;
861 LeaveCriticalSection (&lock->lock);
862 /* Wait until another thread signals this event. */
863 result = WaitForSingleObject (event, INFINITE);
864 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
865 abort ();
866 CloseHandle (event);
867 /* The thread which signalled the event already did the bookkeeping:
868 removed us from the waiting_writers, set lock->runcount = -1. */
869 if (!(lock->runcount == -1))
870 abort ();
871 return 0;
872 }
873 else
874 {
875 /* Allocation failure. Weird. */
876 do
877 {
878 LeaveCriticalSection (&lock->lock);
879 Sleep (1);
880 EnterCriticalSection (&lock->lock);
881 }
882 while (!(lock->runcount == 0));
883 }
884 }
885 lock->runcount--; /* runcount becomes -1 */
886 LeaveCriticalSection (&lock->lock);
887 return 0;
888}
889
890int
891glthread_rwlock_unlock_func (gl_rwlock_t *lock)
892{
893 if (!lock->guard.done)
894 return EINVAL;
895 EnterCriticalSection (&lock->lock);
896 if (lock->runcount < 0)
897 {
898 /* Drop a writer lock. */
899 if (!(lock->runcount == -1))
900 abort ();
901 lock->runcount = 0;
902 }
903 else
904 {
905 /* Drop a reader lock. */
906 if (!(lock->runcount > 0))
907 {
908 LeaveCriticalSection (&lock->lock);
909 return EPERM;
910 }
911 lock->runcount--;
912 }
913 if (lock->runcount == 0)
914 {
915 /* POSIX recommends that "write locks shall take precedence over read
916 locks", to avoid "writer starvation". */
917 if (lock->waiting_writers.count > 0)
918 {
919 /* Wake up one of the waiting writers. */
920 lock->runcount--;
921 gl_waitqueue_notify_first (&lock->waiting_writers);
922 }
923 else
924 {
925 /* Wake up all waiting readers. */
926 lock->runcount += lock->waiting_readers.count;
927 gl_waitqueue_notify_all (&lock->waiting_readers);
928 }
929 }
930 LeaveCriticalSection (&lock->lock);
931 return 0;
932}
933
934int
935glthread_rwlock_destroy_func (gl_rwlock_t *lock)
936{
937 if (!lock->guard.done)
938 return EINVAL;
939 if (lock->runcount != 0)
940 return EBUSY;
941 DeleteCriticalSection (&lock->lock);
942 if (lock->waiting_readers.array != NULL)
943 free (lock->waiting_readers.array);
944 if (lock->waiting_writers.array != NULL)
945 free (lock->waiting_writers.array);
946 lock->guard.done = 0;
947 return 0;
948}
949
950/* --------------------- gl_recursive_lock_t datatype --------------------- */
951
952void
953glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
954{
955 lock->owner = 0;
956 lock->depth = 0;
957 InitializeCriticalSection (&lock->lock);
958 lock->guard.done = 1;
959}
960
961int
962glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
963{
964 if (!lock->guard.done)
965 {
966 if (InterlockedIncrement (&lock->guard.started) == 0)
967 /* This thread is the first one to need this lock. Initialize it. */
968 glthread_recursive_lock_init (lock);
969 else
970 /* Yield the CPU while waiting for another thread to finish
971 initializing this lock. */
972 while (!lock->guard.done)
973 Sleep (0);
974 }
975 {
976 DWORD self = GetCurrentThreadId ();
977 if (lock->owner != self)
978 {
979 EnterCriticalSection (&lock->lock);
980 lock->owner = self;
981 }
982 if (++(lock->depth) == 0) /* wraparound? */
983 {
984 lock->depth--;
985 return EAGAIN;
986 }
987 }
988 return 0;
989}
990
991int
992glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
993{
994 if (lock->owner != GetCurrentThreadId ())
995 return EPERM;
996 if (lock->depth == 0)
997 return EINVAL;
998 if (--(lock->depth) == 0)
999 {
1000 lock->owner = 0;
1001 LeaveCriticalSection (&lock->lock);
1002 }
1003 return 0;
1004}
1005
1006int
1007glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
1008{
1009 if (lock->owner != 0)
1010 return EBUSY;
1011 DeleteCriticalSection (&lock->lock);
1012 lock->guard.done = 0;
1013 return 0;
1014}
1015
1016/* -------------------------- gl_once_t datatype -------------------------- */
1017
1018void
1019glthread_once_func (gl_once_t *once_control, void (*initfunction) (void))
1020{
1021 if (once_control->inited <= 0)
1022 {
1023 if (InterlockedIncrement (&once_control->started) == 0)
1024 {
1025 /* This thread is the first one to come to this once_control. */
1026 InitializeCriticalSection (&once_control->lock);
1027 EnterCriticalSection (&once_control->lock);
1028 once_control->inited = 0;
1029 initfunction ();
1030 once_control->inited = 1;
1031 LeaveCriticalSection (&once_control->lock);
1032 }
1033 else
1034 {
1035 /* Undo last operation. */
1036 InterlockedDecrement (&once_control->started);
1037 /* Some other thread has already started the initialization.
1038 Yield the CPU while waiting for the other thread to finish
1039 initializing and taking the lock. */
1040 while (once_control->inited < 0)
1041 Sleep (0);
1042 if (once_control->inited <= 0)
1043 {
1044 /* Take the lock. This blocks until the other thread has
1045 finished calling the initfunction. */
1046 EnterCriticalSection (&once_control->lock);
1047 LeaveCriticalSection (&once_control->lock);
1048 if (!(once_control->inited > 0))
1049 abort ();
1050 }
1051 }
1052 }
1053}
1054
1055#endif 747#endif
1056 748
1057/* ========================================================================= */ 749/* ========================================================================= */
diff --git a/gl/glthread/lock.h b/gl/glthread/lock.h
index d20bbdef..ae3ee2d6 100644
--- a/gl/glthread/lock.h
+++ b/gl/glthread/lock.h
@@ -1,22 +1,21 @@
1/* Locking in multithreaded situations. 1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005. 17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, 18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */
19 gthr-win32.h. */
20 19
21/* This file contains locking primitives for use with a given thread library. 20/* This file contains locking primitives for use with a given thread library.
22 It does not contain primitives for creating threads or for other 21 It does not contain primitives for creating threads or for other
@@ -81,6 +80,127 @@
81#include <errno.h> 80#include <errno.h>
82#include <stdlib.h> 81#include <stdlib.h>
83 82
83#if !defined c11_threads_in_use
84# if HAVE_THREADS_H && USE_POSIX_THREADS_FROM_LIBC
85# define c11_threads_in_use() 1
86# elif HAVE_THREADS_H && USE_POSIX_THREADS_WEAK
87# include <threads.h>
88# pragma weak thrd_exit
89# define c11_threads_in_use() (thrd_exit != NULL)
90# else
91# define c11_threads_in_use() 0
92# endif
93#endif
94
95/* ========================================================================= */
96
97#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS
98
99/* Use the ISO C threads library. */
100
101# include <threads.h>
102
103# ifdef __cplusplus
104extern "C" {
105# endif
106
107/* -------------------------- gl_lock_t datatype -------------------------- */
108
109typedef struct
110 {
111 int volatile init_needed;
112 once_flag init_once;
113 void (*init_func) (void);
114 mtx_t mutex;
115 }
116 gl_lock_t;
117# define gl_lock_define(STORAGECLASS, NAME) \
118 STORAGECLASS gl_lock_t NAME;
119# define gl_lock_define_initialized(STORAGECLASS, NAME) \
120 static void _atomic_init_##NAME (void); \
121 STORAGECLASS gl_lock_t NAME = \
122 { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \
123 static void _atomic_init_##NAME (void) \
124 { \
125 if (glthread_lock_init (&(NAME))) \
126 abort (); \
127 }
128extern int glthread_lock_init (gl_lock_t *lock);
129extern int glthread_lock_lock (gl_lock_t *lock);
130extern int glthread_lock_unlock (gl_lock_t *lock);
131extern int glthread_lock_destroy (gl_lock_t *lock);
132
133/* ------------------------- gl_rwlock_t datatype ------------------------- */
134
135typedef struct
136 {
137 int volatile init_needed;
138 once_flag init_once;
139 void (*init_func) (void);
140 mtx_t lock; /* protects the remaining fields */
141 cnd_t waiting_readers; /* waiting readers */
142 cnd_t waiting_writers; /* waiting writers */
143 unsigned int waiting_writers_count; /* number of waiting writers */
144 int runcount; /* number of readers running, or -1 when a writer runs */
145 }
146 gl_rwlock_t;
147# define gl_rwlock_define(STORAGECLASS, NAME) \
148 STORAGECLASS gl_rwlock_t NAME;
149# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
150 static void _atomic_init_##NAME (void); \
151 STORAGECLASS gl_rwlock_t NAME = \
152 { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \
153 static void _atomic_init_##NAME (void) \
154 { \
155 if (glthread_rwlock_init (&(NAME))) \
156 abort (); \
157 }
158extern int glthread_rwlock_init (gl_rwlock_t *lock);
159extern int glthread_rwlock_rdlock (gl_rwlock_t *lock);
160extern int glthread_rwlock_wrlock (gl_rwlock_t *lock);
161extern int glthread_rwlock_unlock (gl_rwlock_t *lock);
162extern int glthread_rwlock_destroy (gl_rwlock_t *lock);
163
164/* --------------------- gl_recursive_lock_t datatype --------------------- */
165
166typedef struct
167 {
168 int volatile init_needed;
169 once_flag init_once;
170 void (*init_func) (void);
171 mtx_t mutex;
172 }
173 gl_recursive_lock_t;
174# define gl_recursive_lock_define(STORAGECLASS, NAME) \
175 STORAGECLASS gl_recursive_lock_t NAME;
176# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
177 static void _atomic_init_##NAME (void); \
178 STORAGECLASS gl_recursive_lock_t NAME = \
179 { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \
180 static void _atomic_init_##NAME (void) \
181 { \
182 if (glthread_recursive_lock_init (&(NAME))) \
183 abort (); \
184 }
185extern int glthread_recursive_lock_init (gl_recursive_lock_t *lock);
186extern int glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
187extern int glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
188extern int glthread_recursive_lock_destroy (gl_recursive_lock_t *lock);
189
190/* -------------------------- gl_once_t datatype -------------------------- */
191
192typedef once_flag gl_once_t;
193# define gl_once_define(STORAGECLASS, NAME) \
194 STORAGECLASS once_flag NAME = ONCE_FLAG_INIT;
195# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
196 (call_once (ONCE_CONTROL, INITFUNCTION), 0)
197
198# ifdef __cplusplus
199}
200# endif
201
202#endif
203
84/* ========================================================================= */ 204/* ========================================================================= */
85 205
86#if USE_POSIX_THREADS 206#if USE_POSIX_THREADS
@@ -139,13 +259,25 @@ extern int glthread_in_use (void);
139# pragma weak pthread_mutexattr_init 259# pragma weak pthread_mutexattr_init
140# pragma weak pthread_mutexattr_settype 260# pragma weak pthread_mutexattr_settype
141# pragma weak pthread_mutexattr_destroy 261# pragma weak pthread_mutexattr_destroy
262# pragma weak pthread_rwlockattr_init
263# if __GNU_LIBRARY__ > 1
264# pragma weak pthread_rwlockattr_setkind_np
265# endif
266# pragma weak pthread_rwlockattr_destroy
142# ifndef pthread_self 267# ifndef pthread_self
143# pragma weak pthread_self 268# pragma weak pthread_self
144# endif 269# endif
145 270
146# if !PTHREAD_IN_USE_DETECTION_HARD 271# if !PTHREAD_IN_USE_DETECTION_HARD
147# pragma weak pthread_cancel 272 /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols
148# define pthread_in_use() (pthread_cancel != NULL) 273 can be used to determine whether libpthread is in use. These are:
274 pthread_mutexattr_gettype
275 pthread_rwlockattr_destroy
276 pthread_rwlockattr_init
277 */
278# pragma weak pthread_mutexattr_gettype
279# define pthread_in_use() \
280 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
149# endif 281# endif
150 282
151# else 283# else
@@ -176,19 +308,32 @@ typedef pthread_mutex_t gl_lock_t;
176 308
177/* ------------------------- gl_rwlock_t datatype ------------------------- */ 309/* ------------------------- gl_rwlock_t datatype ------------------------- */
178 310
179# if HAVE_PTHREAD_RWLOCK 311# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
180 312
181# ifdef PTHREAD_RWLOCK_INITIALIZER 313# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP
182 314
183typedef pthread_rwlock_t gl_rwlock_t; 315typedef pthread_rwlock_t gl_rwlock_t;
184# define gl_rwlock_define(STORAGECLASS, NAME) \ 316# define gl_rwlock_define(STORAGECLASS, NAME) \
185 STORAGECLASS pthread_rwlock_t NAME; 317 STORAGECLASS pthread_rwlock_t NAME;
186# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ 318# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
187 STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; 319 STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
188# define gl_rwlock_initializer \ 320# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
189 PTHREAD_RWLOCK_INITIALIZER 321# if defined PTHREAD_RWLOCK_INITIALIZER
190# define glthread_rwlock_init(LOCK) \ 322# define gl_rwlock_initializer \
191 (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) 323 PTHREAD_RWLOCK_INITIALIZER
324# else
325# define gl_rwlock_initializer \
326 PTHREAD_RWLOCK_INITIALIZER_NP
327# endif
328# define glthread_rwlock_init(LOCK) \
329 (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
330# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
331# define gl_rwlock_initializer \
332 PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
333# define glthread_rwlock_init(LOCK) \
334 (pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0)
335extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock);
336# endif
192# define glthread_rwlock_rdlock(LOCK) \ 337# define glthread_rwlock_rdlock(LOCK) \
193 (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) 338 (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
194# define glthread_rwlock_wrlock(LOCK) \ 339# define glthread_rwlock_wrlock(LOCK) \
@@ -362,248 +507,20 @@ extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *l
362typedef pthread_once_t gl_once_t; 507typedef pthread_once_t gl_once_t;
363# define gl_once_define(STORAGECLASS, NAME) \ 508# define gl_once_define(STORAGECLASS, NAME) \
364 STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; 509 STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
365# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ 510# if PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK
366 (pthread_in_use () \ 511# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
367 ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ 512 (pthread_in_use () \
368 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) 513 ? pthread_once (ONCE_CONTROL, INITFUNCTION) \
369extern int glthread_once_singlethreaded (pthread_once_t *once_control); 514 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
370
371# ifdef __cplusplus
372}
373# endif
374
375#endif
376
377/* ========================================================================= */
378
379#if USE_PTH_THREADS
380
381/* Use the GNU Pth threads library. */
382
383# include <pth.h>
384
385# ifdef __cplusplus
386extern "C" {
387# endif
388
389# if USE_PTH_THREADS_WEAK
390
391/* Use weak references to the GNU Pth threads library. */
392
393# pragma weak pth_mutex_init
394# pragma weak pth_mutex_acquire
395# pragma weak pth_mutex_release
396# pragma weak pth_rwlock_init
397# pragma weak pth_rwlock_acquire
398# pragma weak pth_rwlock_release
399# pragma weak pth_once
400
401# pragma weak pth_cancel
402# define pth_in_use() (pth_cancel != NULL)
403
404# else 515# else
405 516# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
406# define pth_in_use() 1 517 (pthread_in_use () \
407 518 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
519 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
520extern int glthread_once_multithreaded (pthread_once_t *once_control,
521 void (*init_function) (void));
408# endif 522# endif
409 523extern int glthread_once_singlethreaded (pthread_once_t *once_control);
410/* -------------------------- gl_lock_t datatype -------------------------- */
411
412typedef pth_mutex_t gl_lock_t;
413# define gl_lock_define(STORAGECLASS, NAME) \
414 STORAGECLASS pth_mutex_t NAME;
415# define gl_lock_define_initialized(STORAGECLASS, NAME) \
416 STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
417# define gl_lock_initializer \
418 PTH_MUTEX_INIT
419# define glthread_lock_init(LOCK) \
420 (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
421# define glthread_lock_lock(LOCK) \
422 (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
423# define glthread_lock_unlock(LOCK) \
424 (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
425# define glthread_lock_destroy(LOCK) \
426 ((void)(LOCK), 0)
427
428/* ------------------------- gl_rwlock_t datatype ------------------------- */
429
430typedef pth_rwlock_t gl_rwlock_t;
431# define gl_rwlock_define(STORAGECLASS, NAME) \
432 STORAGECLASS pth_rwlock_t NAME;
433# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
434 STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
435# define gl_rwlock_initializer \
436 PTH_RWLOCK_INIT
437# define glthread_rwlock_init(LOCK) \
438 (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
439# define glthread_rwlock_rdlock(LOCK) \
440 (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
441# define glthread_rwlock_wrlock(LOCK) \
442 (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
443# define glthread_rwlock_unlock(LOCK) \
444 (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
445# define glthread_rwlock_destroy(LOCK) \
446 ((void)(LOCK), 0)
447
448/* --------------------- gl_recursive_lock_t datatype --------------------- */
449
450/* In Pth, mutexes are recursive by default. */
451typedef pth_mutex_t gl_recursive_lock_t;
452# define gl_recursive_lock_define(STORAGECLASS, NAME) \
453 STORAGECLASS pth_mutex_t NAME;
454# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
455 STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
456# define gl_recursive_lock_initializer \
457 PTH_MUTEX_INIT
458# define glthread_recursive_lock_init(LOCK) \
459 (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
460# define glthread_recursive_lock_lock(LOCK) \
461 (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
462# define glthread_recursive_lock_unlock(LOCK) \
463 (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
464# define glthread_recursive_lock_destroy(LOCK) \
465 ((void)(LOCK), 0)
466
467/* -------------------------- gl_once_t datatype -------------------------- */
468
469typedef pth_once_t gl_once_t;
470# define gl_once_define(STORAGECLASS, NAME) \
471 STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
472# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
473 (pth_in_use () \
474 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
475 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
476extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
477extern int glthread_once_singlethreaded (pth_once_t *once_control);
478
479# ifdef __cplusplus
480}
481# endif
482
483#endif
484
485/* ========================================================================= */
486
487#if USE_SOLARIS_THREADS
488
489/* Use the old Solaris threads library. */
490
491# include <thread.h>
492# include <synch.h>
493
494# ifdef __cplusplus
495extern "C" {
496# endif
497
498# if USE_SOLARIS_THREADS_WEAK
499
500/* Use weak references to the old Solaris threads library. */
501
502# pragma weak mutex_init
503# pragma weak mutex_lock
504# pragma weak mutex_unlock
505# pragma weak mutex_destroy
506# pragma weak rwlock_init
507# pragma weak rw_rdlock
508# pragma weak rw_wrlock
509# pragma weak rw_unlock
510# pragma weak rwlock_destroy
511# pragma weak thr_self
512
513# pragma weak thr_suspend
514# define thread_in_use() (thr_suspend != NULL)
515
516# else
517
518# define thread_in_use() 1
519
520# endif
521
522/* -------------------------- gl_lock_t datatype -------------------------- */
523
524typedef mutex_t gl_lock_t;
525# define gl_lock_define(STORAGECLASS, NAME) \
526 STORAGECLASS mutex_t NAME;
527# define gl_lock_define_initialized(STORAGECLASS, NAME) \
528 STORAGECLASS mutex_t NAME = gl_lock_initializer;
529# define gl_lock_initializer \
530 DEFAULTMUTEX
531# define glthread_lock_init(LOCK) \
532 (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
533# define glthread_lock_lock(LOCK) \
534 (thread_in_use () ? mutex_lock (LOCK) : 0)
535# define glthread_lock_unlock(LOCK) \
536 (thread_in_use () ? mutex_unlock (LOCK) : 0)
537# define glthread_lock_destroy(LOCK) \
538 (thread_in_use () ? mutex_destroy (LOCK) : 0)
539
540/* ------------------------- gl_rwlock_t datatype ------------------------- */
541
542typedef rwlock_t gl_rwlock_t;
543# define gl_rwlock_define(STORAGECLASS, NAME) \
544 STORAGECLASS rwlock_t NAME;
545# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
546 STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
547# define gl_rwlock_initializer \
548 DEFAULTRWLOCK
549# define glthread_rwlock_init(LOCK) \
550 (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
551# define glthread_rwlock_rdlock(LOCK) \
552 (thread_in_use () ? rw_rdlock (LOCK) : 0)
553# define glthread_rwlock_wrlock(LOCK) \
554 (thread_in_use () ? rw_wrlock (LOCK) : 0)
555# define glthread_rwlock_unlock(LOCK) \
556 (thread_in_use () ? rw_unlock (LOCK) : 0)
557# define glthread_rwlock_destroy(LOCK) \
558 (thread_in_use () ? rwlock_destroy (LOCK) : 0)
559
560/* --------------------- gl_recursive_lock_t datatype --------------------- */
561
562/* Old Solaris threads did not have recursive locks.
563 We have to implement them ourselves. */
564
565typedef struct
566 {
567 mutex_t mutex;
568 thread_t owner;
569 unsigned long depth;
570 }
571 gl_recursive_lock_t;
572# define gl_recursive_lock_define(STORAGECLASS, NAME) \
573 STORAGECLASS gl_recursive_lock_t NAME;
574# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
575 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
576# define gl_recursive_lock_initializer \
577 { DEFAULTMUTEX, (thread_t) 0, 0 }
578# define glthread_recursive_lock_init(LOCK) \
579 (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
580# define glthread_recursive_lock_lock(LOCK) \
581 (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
582# define glthread_recursive_lock_unlock(LOCK) \
583 (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
584# define glthread_recursive_lock_destroy(LOCK) \
585 (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
586extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
587extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
588extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
589extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
590
591/* -------------------------- gl_once_t datatype -------------------------- */
592
593typedef struct
594 {
595 volatile int inited;
596 mutex_t mutex;
597 }
598 gl_once_t;
599# define gl_once_define(STORAGECLASS, NAME) \
600 STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
601# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
602 (thread_in_use () \
603 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
604 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
605extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
606extern int glthread_once_singlethreaded (gl_once_t *once_control);
607 524
608# ifdef __cplusplus 525# ifdef __cplusplus
609} 526}
@@ -618,6 +535,11 @@ extern int glthread_once_singlethreaded (gl_once_t *once_control);
618# define WIN32_LEAN_AND_MEAN /* avoid including junk */ 535# define WIN32_LEAN_AND_MEAN /* avoid including junk */
619# include <windows.h> 536# include <windows.h>
620 537
538# include "windows-mutex.h"
539# include "windows-rwlock.h"
540# include "windows-recmutex.h"
541# include "windows-once.h"
542
621# ifdef __cplusplus 543# ifdef __cplusplus
622extern "C" { 544extern "C" {
623# endif 545# endif
@@ -633,127 +555,69 @@ extern "C" {
633/* There is no way to statically initialize a CRITICAL_SECTION. It needs 555/* There is no way to statically initialize a CRITICAL_SECTION. It needs
634 to be done lazily, once only. For this we need spinlocks. */ 556 to be done lazily, once only. For this we need spinlocks. */
635 557
636typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
637
638/* -------------------------- gl_lock_t datatype -------------------------- */ 558/* -------------------------- gl_lock_t datatype -------------------------- */
639 559
640typedef struct 560typedef glwthread_mutex_t gl_lock_t;
641 {
642 gl_spinlock_t guard; /* protects the initialization */
643 CRITICAL_SECTION lock;
644 }
645 gl_lock_t;
646# define gl_lock_define(STORAGECLASS, NAME) \ 561# define gl_lock_define(STORAGECLASS, NAME) \
647 STORAGECLASS gl_lock_t NAME; 562 STORAGECLASS gl_lock_t NAME;
648# define gl_lock_define_initialized(STORAGECLASS, NAME) \ 563# define gl_lock_define_initialized(STORAGECLASS, NAME) \
649 STORAGECLASS gl_lock_t NAME = gl_lock_initializer; 564 STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
650# define gl_lock_initializer \ 565# define gl_lock_initializer \
651 { { 0, -1 } } 566 GLWTHREAD_MUTEX_INIT
652# define glthread_lock_init(LOCK) \ 567# define glthread_lock_init(LOCK) \
653 (glthread_lock_init_func (LOCK), 0) 568 (glwthread_mutex_init (LOCK), 0)
654# define glthread_lock_lock(LOCK) \ 569# define glthread_lock_lock(LOCK) \
655 glthread_lock_lock_func (LOCK) 570 glwthread_mutex_lock (LOCK)
656# define glthread_lock_unlock(LOCK) \ 571# define glthread_lock_unlock(LOCK) \
657 glthread_lock_unlock_func (LOCK) 572 glwthread_mutex_unlock (LOCK)
658# define glthread_lock_destroy(LOCK) \ 573# define glthread_lock_destroy(LOCK) \
659 glthread_lock_destroy_func (LOCK) 574 glwthread_mutex_destroy (LOCK)
660extern void glthread_lock_init_func (gl_lock_t *lock);
661extern int glthread_lock_lock_func (gl_lock_t *lock);
662extern int glthread_lock_unlock_func (gl_lock_t *lock);
663extern int glthread_lock_destroy_func (gl_lock_t *lock);
664 575
665/* ------------------------- gl_rwlock_t datatype ------------------------- */ 576/* ------------------------- gl_rwlock_t datatype ------------------------- */
666 577
667/* It is impossible to implement read-write locks using plain locks, without 578typedef glwthread_rwlock_t gl_rwlock_t;
668 introducing an extra thread dedicated to managing read-write locks.
669 Therefore here we need to use the low-level Event type. */
670
671typedef struct
672 {
673 HANDLE *array; /* array of waiting threads, each represented by an event */
674 unsigned int count; /* number of waiting threads */
675 unsigned int alloc; /* length of allocated array */
676 unsigned int offset; /* index of first waiting thread in array */
677 }
678 gl_carray_waitqueue_t;
679typedef struct
680 {
681 gl_spinlock_t guard; /* protects the initialization */
682 CRITICAL_SECTION lock; /* protects the remaining fields */
683 gl_carray_waitqueue_t waiting_readers; /* waiting readers */
684 gl_carray_waitqueue_t waiting_writers; /* waiting writers */
685 int runcount; /* number of readers running, or -1 when a writer runs */
686 }
687 gl_rwlock_t;
688# define gl_rwlock_define(STORAGECLASS, NAME) \ 579# define gl_rwlock_define(STORAGECLASS, NAME) \
689 STORAGECLASS gl_rwlock_t NAME; 580 STORAGECLASS gl_rwlock_t NAME;
690# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ 581# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
691 STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; 582 STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
692# define gl_rwlock_initializer \ 583# define gl_rwlock_initializer \
693 { { 0, -1 } } 584 GLWTHREAD_RWLOCK_INIT
694# define glthread_rwlock_init(LOCK) \ 585# define glthread_rwlock_init(LOCK) \
695 (glthread_rwlock_init_func (LOCK), 0) 586 (glwthread_rwlock_init (LOCK), 0)
696# define glthread_rwlock_rdlock(LOCK) \ 587# define glthread_rwlock_rdlock(LOCK) \
697 glthread_rwlock_rdlock_func (LOCK) 588 glwthread_rwlock_rdlock (LOCK)
698# define glthread_rwlock_wrlock(LOCK) \ 589# define glthread_rwlock_wrlock(LOCK) \
699 glthread_rwlock_wrlock_func (LOCK) 590 glwthread_rwlock_wrlock (LOCK)
700# define glthread_rwlock_unlock(LOCK) \ 591# define glthread_rwlock_unlock(LOCK) \
701 glthread_rwlock_unlock_func (LOCK) 592 glwthread_rwlock_unlock (LOCK)
702# define glthread_rwlock_destroy(LOCK) \ 593# define glthread_rwlock_destroy(LOCK) \
703 glthread_rwlock_destroy_func (LOCK) 594 glwthread_rwlock_destroy (LOCK)
704extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
705extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
706extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
707extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
708extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
709 595
710/* --------------------- gl_recursive_lock_t datatype --------------------- */ 596/* --------------------- gl_recursive_lock_t datatype --------------------- */
711 597
712/* The native Windows documentation says that CRITICAL_SECTION already 598typedef glwthread_recmutex_t gl_recursive_lock_t;
713 implements a recursive lock. But we need not rely on it: It's easy to
714 implement a recursive lock without this assumption. */
715
716typedef struct
717 {
718 gl_spinlock_t guard; /* protects the initialization */
719 DWORD owner;
720 unsigned long depth;
721 CRITICAL_SECTION lock;
722 }
723 gl_recursive_lock_t;
724# define gl_recursive_lock_define(STORAGECLASS, NAME) \ 599# define gl_recursive_lock_define(STORAGECLASS, NAME) \
725 STORAGECLASS gl_recursive_lock_t NAME; 600 STORAGECLASS gl_recursive_lock_t NAME;
726# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ 601# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
727 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; 602 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
728# define gl_recursive_lock_initializer \ 603# define gl_recursive_lock_initializer \
729 { { 0, -1 }, 0, 0 } 604 GLWTHREAD_RECMUTEX_INIT
730# define glthread_recursive_lock_init(LOCK) \ 605# define glthread_recursive_lock_init(LOCK) \
731 (glthread_recursive_lock_init_func (LOCK), 0) 606 (glwthread_recmutex_init (LOCK), 0)
732# define glthread_recursive_lock_lock(LOCK) \ 607# define glthread_recursive_lock_lock(LOCK) \
733 glthread_recursive_lock_lock_func (LOCK) 608 glwthread_recmutex_lock (LOCK)
734# define glthread_recursive_lock_unlock(LOCK) \ 609# define glthread_recursive_lock_unlock(LOCK) \
735 glthread_recursive_lock_unlock_func (LOCK) 610 glwthread_recmutex_unlock (LOCK)
736# define glthread_recursive_lock_destroy(LOCK) \ 611# define glthread_recursive_lock_destroy(LOCK) \
737 glthread_recursive_lock_destroy_func (LOCK) 612 glwthread_recmutex_destroy (LOCK)
738extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
739extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
740extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
741extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
742 613
743/* -------------------------- gl_once_t datatype -------------------------- */ 614/* -------------------------- gl_once_t datatype -------------------------- */
744 615
745typedef struct 616typedef glwthread_once_t gl_once_t;
746 {
747 volatile int inited;
748 volatile long started;
749 CRITICAL_SECTION lock;
750 }
751 gl_once_t;
752# define gl_once_define(STORAGECLASS, NAME) \ 617# define gl_once_define(STORAGECLASS, NAME) \
753 STORAGECLASS gl_once_t NAME = { -1, -1 }; 618 STORAGECLASS gl_once_t NAME = GLWTHREAD_ONCE_INIT;
754# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ 619# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
755 (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0) 620 (glwthread_once (ONCE_CONTROL, INITFUNCTION), 0)
756extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
757 621
758# ifdef __cplusplus 622# ifdef __cplusplus
759} 623}
@@ -763,7 +627,7 @@ extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (v
763 627
764/* ========================================================================= */ 628/* ========================================================================= */
765 629
766#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS) 630#if !(USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS)
767 631
768/* Provide dummy implementation if threads are not supported. */ 632/* Provide dummy implementation if threads are not supported. */
769 633
diff --git a/gl/glthread/threadlib.c b/gl/glthread/threadlib.c
index b4476573..5ecf827f 100644
--- a/gl/glthread/threadlib.c
+++ b/gl/glthread/threadlib.c
@@ -1,18 +1,18 @@
1/* Multithreading primitives. 1/* Multithreading primitives.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2005. */
18 18
@@ -20,15 +20,48 @@
20 20
21/* ========================================================================= */ 21/* ========================================================================= */
22 22
23#if USE_POSIX_THREADS 23#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS
24 24
25/* Use the POSIX threads library. */ 25/* Use the POSIX threads library. */
26 26
27# include <errno.h>
27# include <pthread.h> 28# include <pthread.h>
28# include <stdlib.h> 29# include <stdlib.h>
29 30
30# if PTHREAD_IN_USE_DETECTION_HARD 31# if PTHREAD_IN_USE_DETECTION_HARD
31 32
33# if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */
34
35/* Test using pthread_key_create. */
36
37int
38glthread_in_use (void)
39{
40 static int tested;
41 static int result; /* 1: linked with -lpthread, 0: only with libc */
42
43 if (!tested)
44 {
45 pthread_key_t key;
46 int err = pthread_key_create (&key, NULL);
47
48 if (err == ENOSYS)
49 result = 0;
50 else
51 {
52 result = 1;
53 if (err == 0)
54 pthread_key_delete (key);
55 }
56 tested = 1;
57 }
58 return result;
59}
60
61# else /* Solaris, HP-UX */
62
63/* Test using pthread_create. */
64
32/* The function to be executed by a dummy thread. */ 65/* The function to be executed by a dummy thread. */
33static void * 66static void *
34dummy_thread_func (void *arg) 67dummy_thread_func (void *arg)
@@ -62,6 +95,8 @@ glthread_in_use (void)
62 return result; 95 return result;
63} 96}
64 97
98# endif
99
65# endif 100# endif
66 101
67#endif 102#endif
diff --git a/gl/hard-locale.c b/gl/hard-locale.c
new file mode 100644
index 00000000..0a28552e
--- /dev/null
+++ b/gl/hard-locale.c
@@ -0,0 +1,35 @@
1/* hard-locale.c -- Determine whether a locale is hard.
2
3 Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2023 Free Software
4 Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#include <config.h>
20
21#include "hard-locale.h"
22
23#include <locale.h>
24#include <string.h>
25
26bool
27hard_locale (int category)
28{
29 char locale[SETLOCALE_NULL_MAX];
30
31 if (setlocale_null_r (category, locale, sizeof (locale)))
32 return false;
33
34 return !(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0);
35}
diff --git a/gl/hard-locale.h b/gl/hard-locale.h
new file mode 100644
index 00000000..880c9e85
--- /dev/null
+++ b/gl/hard-locale.h
@@ -0,0 +1,26 @@
1/* Determine whether a locale is hard.
2
3 Copyright (C) 1999, 2003-2004, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef HARD_LOCALE_H_
19# define HARD_LOCALE_H_ 1
20
21/* Return true if the specified CATEGORY of the current locale is hard, i.e.
22 different from the C or POSIX locale that has a fixed behavior.
23 CATEGORY must be one of the LC_* values, but not LC_ALL. */
24extern bool hard_locale (int category);
25
26#endif /* HARD_LOCALE_H_ */
diff --git a/gl/ialloc.c b/gl/ialloc.c
new file mode 100644
index 00000000..cd44d8ca
--- /dev/null
+++ b/gl/ialloc.c
@@ -0,0 +1,21 @@
1/* malloc with idx_t rather than size_t
2
3 Copyright 2021-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20#define IALLOC_INLINE _GL_EXTERN_INLINE
21#include "ialloc.h"
diff --git a/gl/ialloc.h b/gl/ialloc.h
new file mode 100644
index 00000000..1d43faf3
--- /dev/null
+++ b/gl/ialloc.h
@@ -0,0 +1,100 @@
1/* ialloc.h -- malloc with idx_t rather than size_t
2
3 Copyright 2021-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef IALLOC_H_
19#define IALLOC_H_
20
21#include "idx.h"
22
23#include <errno.h>
24#include <stdint.h>
25#include <stdlib.h>
26
27#ifndef _GL_INLINE_HEADER_BEGIN
28 #error "Please include config.h first."
29#endif
30_GL_INLINE_HEADER_BEGIN
31#ifndef IALLOC_INLINE
32# define IALLOC_INLINE _GL_INLINE
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39IALLOC_INLINE void * _GL_ATTRIBUTE_COLD
40_gl_alloc_nomem (void)
41{
42 errno = ENOMEM;
43 return NULL;
44}
45
46IALLOC_INLINE
47_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/
48void *
49imalloc (idx_t s)
50{
51 return s <= SIZE_MAX ? malloc (s) : _gl_alloc_nomem ();
52}
53
54IALLOC_INLINE
55/*_GL_ATTRIBUTE_DEALLOC_FREE*/
56void *
57irealloc (void *p, idx_t s)
58{
59 /* Work around GNU realloc glitch by treating a zero size as if it
60 were 1, so that returning NULL is equivalent to failing. */
61 return s <= SIZE_MAX ? realloc (p, s | !s) : _gl_alloc_nomem ();
62}
63
64IALLOC_INLINE
65_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/
66void *
67icalloc (idx_t n, idx_t s)
68{
69 if (SIZE_MAX < n)
70 {
71 if (s != 0)
72 return _gl_alloc_nomem ();
73 n = 0;
74 }
75 if (SIZE_MAX < s)
76 {
77 if (n != 0)
78 return _gl_alloc_nomem ();
79 s = 0;
80 }
81 return calloc (n, s);
82}
83
84IALLOC_INLINE void *
85ireallocarray (void *p, idx_t n, idx_t s)
86{
87 /* Work around GNU reallocarray glitch by treating a zero size as if
88 it were 1, so that returning NULL is equivalent to failing. */
89 if (n == 0 || s == 0)
90 n = s = 1;
91 return (n <= SIZE_MAX && s <= SIZE_MAX
92 ? reallocarray (p, n, s)
93 : _gl_alloc_nomem ());
94}
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif
diff --git a/gl/idpriv-droptemp.c b/gl/idpriv-droptemp.c
index 13d1064e..2a85431a 100644
--- a/gl/idpriv-droptemp.c
+++ b/gl/idpriv-droptemp.c
@@ -1,9 +1,9 @@
1/* Dropping uid/gid privileges of the current process temporarily. 1/* Dropping uid/gid privileges of the current process temporarily.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
@@ -12,7 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
@@ -58,7 +58,9 @@ idpriv_temp_drop (void)
58 58
59 /* This is for executables that have the setuid bit set. */ 59 /* This is for executables that have the setuid bit set. */
60# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */ 60# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
61 /* See <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf> 61 /* See
62 Hao Chen, David Wagner, Drew Dean: Setuid Demystified
63 <https://www.usenix.org/legacy/publications/library/proceedings/sec02/full_papers/chen/chen.pdf>
62 figure 14. */ 64 figure 14. */
63 if (setresuid (-1, uid, saved_uid) < 0) 65 if (setresuid (-1, uid, saved_uid) < 0)
64 return -1; 66 return -1;
@@ -134,7 +136,9 @@ idpriv_temp_restore (void)
134 136
135 /* This is for executables that have the setuid bit set. */ 137 /* This is for executables that have the setuid bit set. */
136# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */ 138# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
137 /* See <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf> 139 /* See
140 Hao Chen, David Wagner, Drew Dean: Setuid Demystified
141 <https://www.usenix.org/legacy/publications/library/proceedings/sec02/full_papers/chen/chen.pdf>
138 figure 14. */ 142 figure 14. */
139 if (setresuid (-1, saved_uid, -1) < 0) 143 if (setresuid (-1, saved_uid, -1) < 0)
140 return -1; 144 return -1;
diff --git a/gl/idpriv.h b/gl/idpriv.h
index f454a2cc..99f87c08 100644
--- a/gl/idpriv.h
+++ b/gl/idpriv.h
@@ -1,9 +1,9 @@
1/* Dropping uid/gid privileges of the current process. 1/* Dropping uid/gid privileges of the current process.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
@@ -12,7 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _IDPRIV_H 17#ifndef _IDPRIV_H
18#define _IDPRIV_H 18#define _IDPRIV_H
@@ -74,11 +74,11 @@ extern "C" {
74 74
75/* For more in-depth discussion of these topics, see the papers/articles 75/* For more in-depth discussion of these topics, see the papers/articles
76 * Hao Chen, David Wagner, Drew Dean: Setuid Demystified 76 * Hao Chen, David Wagner, Drew Dean: Setuid Demystified
77 <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf> 77 <https://www.usenix.org/legacy/publications/library/proceedings/sec02/full_papers/chen/chen.pdf>
78 * Dan Tsafrir, Dilma da Silva, David Wagner: The Murky Issue of Changing 78 * Dan Tsafrir, Dilma da Silva, David Wagner: The Murky Issue of Changing
79 Process Identity: Revising "Setuid Demystified" 79 Process Identity: Revising "Setuid Demystified"
80 <http://www.eecs.berkeley.edu/~daw/papers/setuid-login08b.pdf> 80 <https://people.eecs.berkeley.edu/~daw/papers/setuid-login08b.pdf>
81 <http://code.google.com/p/change-process-identity/> 81 <https://code.google.com/archive/p/change-process-identity/>
82 * Dhruv Mohindra: Observe correct revocation order while relinquishing 82 * Dhruv Mohindra: Observe correct revocation order while relinquishing
83 privileges 83 privileges
84 <https://www.securecoding.cert.org/confluence/display/seccode/POS36-C.+Observe+correct+revocation+order+while+relinquishing+privileges> 84 <https://www.securecoding.cert.org/confluence/display/seccode/POS36-C.+Observe+correct+revocation+order+while+relinquishing+privileges>
diff --git a/gl/idx.h b/gl/idx.h
new file mode 100644
index 00000000..23020b7e
--- /dev/null
+++ b/gl/idx.h
@@ -0,0 +1,134 @@
1/* A type for indices and sizes.
2 Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _IDX_H
20#define _IDX_H
21
22/* Get ptrdiff_t. */
23#include <stddef.h>
24
25/* Get PTRDIFF_MAX. */
26#include <stdint.h>
27
28/* The type 'idx_t' holds an (array) index or an (object) size.
29 Its implementation promotes to a signed integer type,
30 which can hold the values
31 0..2^63-1 (on 64-bit platforms) or
32 0..2^31-1 (on 32-bit platforms).
33
34 Why a signed integer type?
35
36 * Security: Signed types can be checked for overflow via
37 '-fsanitize=undefined', but unsigned types cannot.
38
39 * Comparisons without surprises: ISO C99 § 6.3.1.8 specifies a few
40 surprising results for comparisons, such as
41
42 (int) -3 < (unsigned long) 7 => false
43 (int) -3 < (unsigned int) 7 => false
44 and on 32-bit machines:
45 (long) -3 < (unsigned int) 7 => false
46
47 This is surprising because the natural comparison order is by
48 value in the realm of infinite-precision signed integers (ℤ).
49
50 The best way to get rid of such surprises is to use signed types
51 for numerical integer values, and use unsigned types only for
52 bit masks and enums.
53
54 Why not use 'size_t' directly?
55
56 * Because 'size_t' is an unsigned type, and a signed type is better.
57 See above.
58
59 Why not use 'ssize_t'?
60
61 * 'ptrdiff_t' is more portable; it is standardized by ISO C
62 whereas 'ssize_t' is standardized only by POSIX.
63
64 * 'ssize_t' is not required to be as wide as 'size_t', and some
65 now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'.
66
67 * Conversely, some now-obsolete platforms had 'ptrdiff_t' wider
68 than 'size_t', which can be a win and conforms to POSIX.
69
70 Won't this cause a problem with objects larger than PTRDIFF_MAX?
71
72 * Typical modern or large platforms do not allocate such objects,
73 so this is not much of a problem in practice; for example, you
74 can safely write 'idx_t len = strlen (s);'. To port to older
75 small platforms where allocations larger than PTRDIFF_MAX could
76 in theory be a problem, you can use Gnulib's ialloc module, or
77 functions like ximalloc in Gnulib's xalloc module.
78
79 Why not use 'ptrdiff_t' directly?
80
81 * Maintainability: When reading and modifying code, it helps to know that
82 a certain variable cannot have negative values. For example, when you
83 have a loop
84
85 int n = ...;
86 for (int i = 0; i < n; i++) ...
87
88 or
89
90 ptrdiff_t n = ...;
91 for (ptrdiff_t i = 0; i < n; i++) ...
92
93 you have to ask yourself "what if n < 0?". Whereas in
94
95 idx_t n = ...;
96 for (idx_t i = 0; i < n; i++) ...
97
98 you know that this case cannot happen.
99
100 Similarly, when a programmer writes
101
102 idx_t = ptr2 - ptr1;
103
104 there is an implied assertion that ptr1 and ptr2 point into the same
105 object and that ptr1 <= ptr2.
106
107 * Being future-proof: In the future, range types (integers which are
108 constrained to a certain range of values) may be added to C compilers
109 or to the C standard. Several programming languages (Ada, Haskell,
110 Common Lisp, Pascal) already have range types. Such range types may
111 help producing good code and good warnings. The type 'idx_t' could
112 then be typedef'ed to a range type that is signed after promotion. */
113
114/* In the future, idx_t could be typedef'ed to a signed range type.
115 The clang "extended integer types", supported in Clang 11 or newer
116 <https://clang.llvm.org/docs/LanguageExtensions.html#extended-integer-types>,
117 are a special case of range types. However, these types don't support binary
118 operators with plain integer types (e.g. expressions such as x > 1).
119 Therefore, they don't behave like signed types (and not like unsigned types
120 either). So, we cannot use them here. */
121
122/* Use the signed type 'ptrdiff_t'. */
123/* Note: ISO C does not mandate that 'size_t' and 'ptrdiff_t' have the same
124 size, but it is so on all platforms we have seen since 1990. */
125typedef ptrdiff_t idx_t;
126
127/* IDX_MAX is the maximum value of an idx_t. */
128#define IDX_MAX PTRDIFF_MAX
129
130/* So far no need has been found for an IDX_WIDTH macro.
131 Perhaps there should be another macro IDX_VALUE_BITS that does not
132 count the sign bit and is therefore one less than PTRDIFF_WIDTH. */
133
134#endif /* _IDX_H */
diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c
index fdfd21dc..9e2d412e 100644
--- a/gl/inet_ntop.c
+++ b/gl/inet_ntop.c
@@ -1,19 +1,19 @@
1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form 1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
2 2
3 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* 18/*
19 * Copyright (c) 1996-1999 by Internet Software Consortium. 19 * Copyright (c) 1996-1999 by Internet Software Consortium.
@@ -40,7 +40,7 @@
40/* Use this to suppress gcc's "...may be used before initialized" warnings. 40/* Use this to suppress gcc's "...may be used before initialized" warnings.
41 Beware: The Code argument must not contain commas. */ 41 Beware: The Code argument must not contain commas. */
42#ifndef IF_LINT 42#ifndef IF_LINT
43# ifdef lint 43# if defined GCC_LINT || defined lint
44# define IF_LINT(Code) Code 44# define IF_LINT(Code) Code
45# else 45# else
46# define IF_LINT(Code) /* empty */ 46# define IF_LINT(Code) /* empty */
diff --git a/gl/intprops-internal.h b/gl/intprops-internal.h
new file mode 100644
index 00000000..0467a9ca
--- /dev/null
+++ b/gl/intprops-internal.h
@@ -0,0 +1,392 @@
1/* intprops-internal.h -- properties of integer types not visible to users
2
3 Copyright (C) 2001-2023 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_INTPROPS_INTERNAL_H
19#define _GL_INTPROPS_INTERNAL_H
20
21#include <limits.h>
22
23/* Return a value with the common real type of E and V and the value of V.
24 Do not evaluate E. */
25#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
26
27/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
28 <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
29#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
30
31/* The extra casts in the following macros work around compiler bugs,
32 e.g., in Cray C 5.0.3.0. */
33
34/* True if the real type T is signed. */
35#define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
36
37/* Return 1 if the real expression E, after promotion, has a
38 signed or floating type. Do not evaluate E. */
39#define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
40
41
42/* Minimum and maximum values for integer types and expressions. */
43
44/* The width in bits of the integer type or expression T.
45 Do not evaluate T. T must not be a bit-field expression.
46 Padding bits are not supported; this is checked at compile-time below. */
47#define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
48
49/* The maximum and minimum values for the type of the expression E,
50 after integer promotion. E is not evaluated. */
51#define _GL_INT_MINIMUM(e) \
52 (_GL_EXPR_SIGNED (e) \
53 ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
54 : _GL_INT_CONVERT (e, 0))
55#define _GL_INT_MAXIMUM(e) \
56 (_GL_EXPR_SIGNED (e) \
57 ? _GL_SIGNED_INT_MAXIMUM (e) \
58 : _GL_INT_NEGATE_CONVERT (e, 1))
59#define _GL_SIGNED_INT_MAXIMUM(e) \
60 (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
61
62/* Work around OpenVMS incompatibility with C99. */
63#if !defined LLONG_MAX && defined __INT64_MAX
64# define LLONG_MAX __INT64_MAX
65# define LLONG_MIN __INT64_MIN
66#endif
67
68/* This include file assumes that signed types are two's complement without
69 padding bits; the above macros have undefined behavior otherwise.
70 If this is a problem for you, please let us know how to fix it for your host.
71 This assumption is tested by the intprops-tests module. */
72
73/* Does the __typeof__ keyword work? This could be done by
74 'configure', but for now it's easier to do it by hand. */
75#if (2 <= __GNUC__ \
76 || (4 <= __clang_major__) \
77 || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
78 || (0x5110 <= __SUNPRO_C && !__STDC__))
79# define _GL_HAVE___TYPEOF__ 1
80#else
81# define _GL_HAVE___TYPEOF__ 0
82#endif
83
84/* Return 1 if the integer type or expression T might be signed. Return 0
85 if it is definitely unsigned. T must not be a bit-field expression.
86 This macro does not evaluate its argument, and expands to an
87 integer constant expression. */
88#if _GL_HAVE___TYPEOF__
89# define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t))
90#else
91# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
92#endif
93
94/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
95 A should not have side effects, and A's type should be an
96 integer with minimum value MIN and maximum MAX. */
97#define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
98 ((min) < 0 ? (a) < - (max) : 0 < (a))
99
100/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
101 (A, B, P) work when P is non-null. */
102#ifdef __EDG__
103/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
104 <https://bugs.gnu.org/53256>. */
105# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
106#elif defined __has_builtin
107# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
108/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
109 see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
110#elif 7 <= __GNUC__
111# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
112#else
113# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
114#endif
115
116/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
117#if defined __clang_major__ && __clang_major__ < 14
118/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
119# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
120#else
121# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
122#endif
123
124/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
125 __builtin_sub_overflow_p and __builtin_mul_overflow_p. */
126#ifdef __EDG__
127/* In EDG-based compilers like ICC 2021.3 and earlier,
128 __builtin_add_overflow_p etc. are not treated as integral constant
129 expressions even when all arguments are. */
130# define _GL_HAS_BUILTIN_OVERFLOW_P 0
131#elif defined __has_builtin
132# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
133#else
134# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
135#endif
136
137#if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \
138 && ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW))
139# include <stdckdint.h>
140#endif
141
142/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
143 Return 1 if the result overflows. Arguments should not have side
144 effects and A, B and *R can be of any integer type other than char,
145 bool, a bit-precise integer type, or an enumeration type. */
146#if _GL_HAS_BUILTIN_ADD_OVERFLOW
147# define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
148# define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
149#elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H
150# define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b))
151# define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b))
152#else
153# define _GL_INT_ADD_WRAPV(a, b, r) \
154 _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
155# define _GL_INT_SUBTRACT_WRAPV(a, b, r) \
156 _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
157#endif
158#if _GL_HAS_BUILTIN_MUL_OVERFLOW
159# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
160 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
161 && !defined __EDG__)
162# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
163# else
164 /* Work around GCC bug 91450. */
165# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
166 ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
167 && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
168 ? ((void) __builtin_mul_overflow (a, b, r), 1) \
169 : __builtin_mul_overflow (a, b, r))
170# endif
171#elif defined ckd_mul && !defined _GL_STDCKDINT_H
172# define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b))
173#else
174# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
175 _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
176#endif
177
178/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
179 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
180 https://llvm.org/bugs/show_bug.cgi?id=25390
181 For now, assume all versions of GCC-like compilers generate bogus
182 warnings for _Generic. This matters only for compilers that
183 lack relevant builtins. */
184#if __GNUC__ || defined __clang__
185# define _GL__GENERIC_BOGUS 1
186#else
187# define _GL__GENERIC_BOGUS 0
188#endif
189
190/* Store the low-order bits of A <op> B into *R, where OP specifies
191 the operation and OVERFLOW the overflow predicate. Return 1 if the
192 result overflows. Arguments should not have side effects,
193 and A, B and *R can be of any integer type other than char, bool, a
194 bit-precise integer type, or an enumeration type. */
195#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
196# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
197 (_Generic \
198 (*(r), \
199 signed char: \
200 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
201 signed char, SCHAR_MIN, SCHAR_MAX), \
202 unsigned char: \
203 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
204 unsigned char, 0, UCHAR_MAX), \
205 short int: \
206 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
207 short int, SHRT_MIN, SHRT_MAX), \
208 unsigned short int: \
209 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
210 unsigned short int, 0, USHRT_MAX), \
211 int: \
212 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
213 int, INT_MIN, INT_MAX), \
214 unsigned int: \
215 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
216 unsigned int, 0, UINT_MAX), \
217 long int: \
218 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
219 long int, LONG_MIN, LONG_MAX), \
220 unsigned long int: \
221 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
222 unsigned long int, 0, ULONG_MAX), \
223 long long int: \
224 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
225 long long int, LLONG_MIN, LLONG_MAX), \
226 unsigned long long int: \
227 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
228 unsigned long long int, 0, ULLONG_MAX)))
229#else
230/* Store the low-order bits of A <op> B into *R, where OP specifies
231 the operation and OVERFLOW the overflow predicate. If *R is
232 signed, its type is ST with bounds SMIN..SMAX; otherwise its type
233 is UT with bounds U..UMAX. ST and UT are narrower than int.
234 Return 1 if the result overflows. Arguments should not have side
235 effects, and A, B and *R can be of any integer type other than
236 char, bool, a bit-precise integer type, or an enumeration type. */
237# if _GL_HAVE___TYPEOF__
238# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
239 (_GL_TYPE_SIGNED (__typeof__ (*(r))) \
240 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
241 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
242# else
243# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
244 (overflow (a, b, smin, smax) \
245 ? (overflow (a, b, 0, umax) \
246 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
247 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
248 : (overflow (a, b, 0, umax) \
249 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
250 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
251# endif
252
253# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
254 (sizeof *(r) == sizeof (signed char) \
255 ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
256 signed char, SCHAR_MIN, SCHAR_MAX, \
257 unsigned char, UCHAR_MAX) \
258 : sizeof *(r) == sizeof (short int) \
259 ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
260 short int, SHRT_MIN, SHRT_MAX, \
261 unsigned short int, USHRT_MAX) \
262 : sizeof *(r) == sizeof (int) \
263 ? (_GL_EXPR_SIGNED (*(r)) \
264 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
265 int, INT_MIN, INT_MAX) \
266 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
267 unsigned int, 0, UINT_MAX)) \
268 : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
269# ifdef LLONG_MAX
270# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
271 (sizeof *(r) == sizeof (long int) \
272 ? (_GL_EXPR_SIGNED (*(r)) \
273 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
274 long int, LONG_MIN, LONG_MAX) \
275 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
276 unsigned long int, 0, ULONG_MAX)) \
277 : (_GL_EXPR_SIGNED (*(r)) \
278 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
279 long long int, LLONG_MIN, LLONG_MAX) \
280 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
281 unsigned long long int, 0, ULLONG_MAX)))
282# else
283# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
284 (_GL_EXPR_SIGNED (*(r)) \
285 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
286 long int, LONG_MIN, LONG_MAX) \
287 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
288 unsigned long int, 0, ULONG_MAX))
289# endif
290#endif
291
292/* Store the low-order bits of A <op> B into *R, where the operation
293 is given by OP. Use the unsigned type UT for calculation to avoid
294 overflow problems. *R's type is T, with extrema TMIN and TMAX.
295 T can be any signed integer type other than char, bool, a
296 bit-precise integer type, or an enumeration type.
297 Return 1 if the result overflows. */
298#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
299 (overflow (a, b, tmin, tmax) \
300 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
301 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
302
303/* Return 1 if the integer expressions A - B and -A would overflow,
304 respectively. Arguments should not have side effects,
305 and can be any signed integer type other than char, bool, a
306 bit-precise integer type, or an enumeration type.
307 These macros are tuned for their last input argument being a constant. */
308
309#if _GL_HAS_BUILTIN_OVERFLOW_P
310# define _GL_INT_NEGATE_OVERFLOW(a) \
311 __builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0)
312#else
313# define _GL_INT_NEGATE_OVERFLOW(a) \
314 _GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
315#endif
316
317/* Return the low-order bits of A <op> B, where the operation is given
318 by OP. Use the unsigned type UT for calculation to avoid undefined
319 behavior on signed integer overflow, and convert the result to type T.
320 UT is at least as wide as T and is no narrower than unsigned int,
321 T is two's complement, and there is no padding or trap representations.
322 Assume that converting UT to T yields the low-order bits, as is
323 done in all known two's-complement C compilers. E.g., see:
324 https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
325
326 According to the C standard, converting UT to T yields an
327 implementation-defined result or signal for values outside T's
328 range. However, code that works around this theoretical problem
329 runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
330 https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
331 As the compiler bug is real, don't try to work around the
332 theoretical problem. */
333
334#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
335 ((t) ((ut) (a) op (ut) (b)))
336
337/* Return true if the numeric values A + B, A - B, A * B fall outside
338 the range TMIN..TMAX. Arguments should not have side effects
339 and can be any integer type other than char, bool,
340 a bit-precise integer type, or an enumeration type.
341 TMIN should be signed and nonpositive.
342 TMAX should be positive, and should be signed unless TMIN is zero. */
343#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
344 ((b) < 0 \
345 ? (((tmin) \
346 ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
347 && (a) < (tmin) - (b)) \
348 : (a) <= -1 - (b)) \
349 || ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
350 : (a) < 0 \
351 ? (((tmin) \
352 ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
353 && (b) < (tmin) - (a)) \
354 : (b) <= -1 - (a)) \
355 || ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
356 && (tmax) < (a) + (b))) \
357 : (tmax) < (b) || (tmax) - (b) < (a))
358#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
359 (((a) < 0) == ((b) < 0) \
360 ? ((a) < (b) \
361 ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
362 : (tmax) < (a) - (b)) \
363 : (a) < 0 \
364 ? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
365 || (a) - (tmin) < (b)) \
366 : ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
367 && _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
368 && (tmax) <= -1 - (b)) \
369 || (tmax) + (b) < (a)))
370#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
371 ((b) < 0 \
372 ? ((a) < 0 \
373 ? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
374 ? (a) < (tmax) / (b) \
375 : ((_GL_INT_NEGATE_OVERFLOW (b) \
376 ? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \
377 : (tmax) / -(b)) \
378 <= -1 - (a))) \
379 : _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
380 ? (_GL_EXPR_SIGNED (a) \
381 ? 0 < (a) + (tmin) \
382 : 0 < (a) && -1 - (tmin) < (a) - 1) \
383 : (tmin) / (b) < (a)) \
384 : (b) == 0 \
385 ? 0 \
386 : ((a) < 0 \
387 ? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
388 ? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
389 : (tmin) / (a) < (b)) \
390 : (tmax) / (b) < (a)))
391
392#endif /* _GL_INTPROPS_INTERNAL_H */
diff --git a/gl/intprops.h b/gl/intprops.h
index f57f9b4d..44b5e60f 100644
--- a/gl/intprops.h
+++ b/gl/intprops.h
@@ -1,34 +1,24 @@
1/* intprops.h -- properties of integer types 1/* intprops.h -- properties of integer types
2 2
3 Copyright (C) 2001-2005, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2001-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published by 6 under the terms of the GNU Lesser General Public License as published
7 the Free Software Foundation; either version 3 of the License, or 7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19 17
20#ifndef _GL_INTPROPS_H 18#ifndef _GL_INTPROPS_H
21#define _GL_INTPROPS_H 19#define _GL_INTPROPS_H
22 20
23#include <limits.h> 21#include "intprops-internal.h"
24
25/* Return an integer value, converted to the same type as the integer
26 expression E after integer type promotion. V is the unconverted value. */
27#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
28
29/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
30 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
31#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
32 22
33/* The extra casts in the following macros work around compiler bugs, 23/* The extra casts in the following macros work around compiler bugs,
34 e.g., in Cray C 5.0.3.0. */ 24 e.g., in Cray C 5.0.3.0. */
@@ -37,72 +27,27 @@
37 an integer. */ 27 an integer. */
38#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) 28#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
39 29
40/* True if negative values of the signed integer type T use two's 30/* True if the real type T is signed. */
41 complement, ones' complement, or signed magnitude representation, 31#define TYPE_SIGNED(t) _GL_TYPE_SIGNED (t)
42 respectively. Much GNU code assumes two's complement, but some
43 people like to be portable to all possible C hosts. */
44#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
45#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
46#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
47 32
48/* True if the signed integer expression E uses two's complement. */ 33/* Return 1 if the real expression E, after promotion, has a
49#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1) 34 signed or floating type. Do not evaluate E. */
35#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e)
50 36
51/* True if the arithmetic type T is signed. */
52#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
53 37
54/* Return 1 if the integer expression E, after integer promotion, has 38/* Minimum and maximum values for integer types and expressions. */
55 a signed type. */
56#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
57 39
58 40/* The width in bits of the integer type or expression T.
59/* Minimum and maximum values for integer types and expressions. These 41 Do not evaluate T. T must not be a bit-field expression.
60 macros have undefined behavior if T is signed and has padding bits. 42 Padding bits are not supported; this is checked at compile-time below. */
61 If this is a problem for you, please let us know how to fix it for 43#define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t)
62 your host. */
63 44
64/* The maximum and minimum values for the integer type T. */ 45/* The maximum and minimum values for the integer type T. */
65#define TYPE_MINIMUM(t) \ 46#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
66 ((t) (! TYPE_SIGNED (t) \
67 ? (t) 0 \
68 : TYPE_SIGNED_MAGNITUDE (t) \
69 ? ~ (t) 0 \
70 : ~ TYPE_MAXIMUM (t)))
71#define TYPE_MAXIMUM(t) \ 47#define TYPE_MAXIMUM(t) \
72 ((t) (! TYPE_SIGNED (t) \ 48 ((t) (! TYPE_SIGNED (t) \
73 ? (t) -1 \ 49 ? (t) -1 \
74 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) 50 : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
75
76/* The maximum and minimum values for the type of the expression E,
77 after integer promotion. E should not have side effects. */
78#define _GL_INT_MINIMUM(e) \
79 (_GL_INT_SIGNED (e) \
80 ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \
81 : _GL_INT_CONVERT (e, 0))
82#define _GL_INT_MAXIMUM(e) \
83 (_GL_INT_SIGNED (e) \
84 ? _GL_SIGNED_INT_MAXIMUM (e) \
85 : _GL_INT_NEGATE_CONVERT (e, 1))
86#define _GL_SIGNED_INT_MAXIMUM(e) \
87 (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
88
89
90/* Return 1 if the __typeof__ keyword works. This could be done by
91 'configure', but for now it's easier to do it by hand. */
92#if 2 <= __GNUC__ || defined __IBM__TYPEOF__ || 0x5110 <= __SUNPRO_C
93# define _GL_HAVE___TYPEOF__ 1
94#else
95# define _GL_HAVE___TYPEOF__ 0
96#endif
97
98/* Return 1 if the integer type or expression T might be signed. Return 0
99 if it is definitely unsigned. This macro does not evaluate its argument,
100 and expands to an integer constant expression. */
101#if _GL_HAVE___TYPEOF__
102# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
103#else
104# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
105#endif
106 51
107/* Bound on length of the string representing an unsigned integer 52/* Bound on length of the string representing an unsigned integer
108 value representable in B bits. log10 (2.0) < 146/485. The 53 value representable in B bits. log10 (2.0) < 146/485. The
@@ -110,30 +55,31 @@
110#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) 55#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
111 56
112/* Bound on length of the string representing an integer type or expression T. 57/* Bound on length of the string representing an integer type or expression T.
58 T must not be a bit-field expression.
59
113 Subtract 1 for the sign bit if T is signed, and then add 1 more for 60 Subtract 1 for the sign bit if T is signed, and then add 1 more for
114 a minus sign if needed. 61 a minus sign if needed.
115 62
116 Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is 63 Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 1 when its argument is
117 signed, this macro may overestimate the true bound by one byte when 64 unsigned, this macro may overestimate the true bound by one byte when
118 applied to unsigned types of size 2, 4, 16, ... bytes. */ 65 applied to unsigned types of size 2, 4, 16, ... bytes. */
119#define INT_STRLEN_BOUND(t) \ 66#define INT_STRLEN_BOUND(t) \
120 (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \ 67 (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
121 - _GL_SIGNED_TYPE_OR_EXPR (t)) \
122 + _GL_SIGNED_TYPE_OR_EXPR (t)) 68 + _GL_SIGNED_TYPE_OR_EXPR (t))
123 69
124/* Bound on buffer size needed to represent an integer type or expression T, 70/* Bound on buffer size needed to represent an integer type or expression T,
125 including the terminating null. */ 71 including the terminating null. T must not be a bit-field expression. */
126#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) 72#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
127 73
128 74
129/* Range overflow checks. 75/* Range overflow checks.
130 76
131 The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C 77 The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
132 operators might not yield numerically correct answers due to 78 operators overflow arithmetically when given the same arguments.
133 arithmetic overflow. They do not rely on undefined or 79 These macros do not rely on undefined or implementation-defined behavior.
134 implementation-defined behavior. Their implementations are simple 80 Although their implementations are simple and straightforward,
135 and straightforward, but they are a bit harder to use than the 81 they are harder to use and may be less efficient than the
136 INT_<op>_OVERFLOW macros described below. 82 INT_<op>_WRAPV, INT_<op>_OK, and INT_<op>_OVERFLOW macros described below.
137 83
138 Example usage: 84 Example usage:
139 85
@@ -157,6 +103,9 @@
157 must have minimum value MIN and maximum MAX. Unsigned types should 103 must have minimum value MIN and maximum MAX. Unsigned types should
158 use a zero MIN of the proper type. 104 use a zero MIN of the proper type.
159 105
106 Because all arguments are subject to integer promotions, these
107 macros typically do not work on types narrower than 'int'.
108
160 These macros are tuned for constant MIN and MAX. For commutative 109 These macros are tuned for constant MIN and MAX. For commutative
161 operations such as A + B, they are also tuned for constant B. */ 110 operations such as A + B, they are also tuned for constant B. */
162 111
@@ -177,14 +126,12 @@
177/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. 126/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
178 See above for restrictions. */ 127 See above for restrictions. */
179#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ 128#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
180 ((min) < 0 \ 129 _GL_INT_NEGATE_RANGE_OVERFLOW (a, min, max)
181 ? (a) < - (max) \
182 : 0 < (a))
183 130
184/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. 131/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
185 See above for restrictions. Avoid && and || as they tickle 132 See above for restrictions. Avoid && and || as they tickle
186 bugs in Sun C 5.11 2010/08/13 and other compilers; see 133 bugs in Sun C 5.11 2010/08/13 and other compilers; see
187 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */ 134 <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
188#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ 135#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
189 ((b) < 0 \ 136 ((b) < 0 \
190 ? ((a) < 0 \ 137 ? ((a) < 0 \
@@ -223,24 +170,32 @@
223 ? (a) < (min) >> (b) \ 170 ? (a) < (min) >> (b) \
224 : (max) >> (b) < (a)) 171 : (max) >> (b) < (a))
225 172
226
227/* The _GL*_OVERFLOW macros have the same restrictions as the 173/* The _GL*_OVERFLOW macros have the same restrictions as the
228 *_RANGE_OVERFLOW macros, except that they do not assume that operands 174 *_RANGE_OVERFLOW macros, except that they do not assume that operands
229 (e.g., A and B) have the same type as MIN and MAX. Instead, they assume 175 (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
230 that the result (e.g., A + B) has that type. */ 176 that the result (e.g., A + B) has that type. */
231#define _GL_ADD_OVERFLOW(a, b, min, max) \ 177#if _GL_HAS_BUILTIN_OVERFLOW_P
232 ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ 178# define _GL_ADD_OVERFLOW(a, b, min, max) \
233 : (a) < 0 ? (b) <= (a) + (b) \ 179 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
234 : (b) < 0 ? (a) <= (a) + (b) \ 180# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
235 : (a) + (b) < (b)) 181 __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
236#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ 182# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
237 ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ 183 __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
238 : (a) < 0 ? 1 \ 184#else
239 : (b) < 0 ? (a) - (b) <= (a) \ 185# define _GL_ADD_OVERFLOW(a, b, min, max) \
240 : (a) < (b)) 186 ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
241#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ 187 : (a) < 0 ? (b) <= (a) + (b) \
242 (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ 188 : (b) < 0 ? (a) <= (a) + (b) \
243 || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) 189 : (a) + (b) < (b))
190# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
191 ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
192 : (a) < 0 ? 1 \
193 : (b) < 0 ? (a) - (b) <= (a) \
194 : (a) < (b))
195# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
196 (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
197 || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
198#endif
244#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ 199#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
245 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ 200 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
246 : (a) < 0 ? (b) <= (a) + (b) - 1 \ 201 : (a) < 0 ? (b) <= (a) + (b) - 1 \
@@ -262,22 +217,31 @@
262 : (a) % - (b)) \ 217 : (a) % - (b)) \
263 == 0) 218 == 0)
264 219
265 220/* Check for integer overflow, and report low order bits of answer.
266/* Integer overflow checks.
267 221
268 The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators 222 The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
269 might not yield numerically correct answers due to arithmetic overflow. 223 might not yield numerically correct answers due to arithmetic overflow.
270 They work correctly on all known practical hosts, and do not rely 224 The INT_<op>_WRAPV macros compute the low-order bits of the sum,
225 difference, and product of two C integers, and return 1 if these
226 low-order bits are not numerically correct.
227 These macros work correctly on all known practical hosts, and do not rely
271 on undefined behavior due to signed arithmetic overflow. 228 on undefined behavior due to signed arithmetic overflow.
272 229
273 Example usage: 230 Example usage, assuming A and B are long int:
274 231
275 long int i = ...; 232 if (INT_MULTIPLY_OVERFLOW (a, b))
276 long int j = ...; 233 printf ("result would overflow\n");
277 if (INT_MULTIPLY_OVERFLOW (i, j))
278 printf ("multiply would overflow");
279 else 234 else
280 printf ("product is %ld", i * j); 235 printf ("result is %ld (no overflow)\n", a * b);
236
237 Example usage with WRAPV flavor:
238
239 long int result;
240 bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
241 printf ("result is %ld (%s)\n", result,
242 overflow ? "after overflow" : "no overflow");
243
244 Restrictions on these macros:
281 245
282 These macros do not check for all possible numerical problems or 246 These macros do not check for all possible numerical problems or
283 undefined or unspecified behavior: they do not check for division 247 undefined or unspecified behavior: they do not check for division
@@ -286,7 +250,23 @@
286 These macros may evaluate their arguments zero or multiple times, so the 250 These macros may evaluate their arguments zero or multiple times, so the
287 arguments should not have side effects. 251 arguments should not have side effects.
288 252
289 These macros are tuned for their last argument being a constant. 253 The WRAPV macros are not constant expressions. They support only
254 +, binary -, and *.
255
256 Because the WRAPV macros convert the result, they report overflow
257 in different circumstances than the OVERFLOW macros do. For
258 example, in the typical case with 16-bit 'short' and 32-bit 'int',
259 if A, B and *R are all of type 'short' then INT_ADD_OVERFLOW (A, B)
260 returns false because the addition cannot overflow after A and B
261 are converted to 'int', whereas INT_ADD_WRAPV (A, B, R) returns
262 true or false depending on whether the sum fits into 'short'.
263
264 These macros are tuned for their last input argument being a constant.
265
266 A, B, and *R should be integers; they need not be the same type,
267 and they need not be all signed or all unsigned.
268 However, none of the integer types should be bit-precise,
269 and *R's type should not be char, bool, or an enumeration type.
290 270
291 Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, 271 Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
292 A % B, and A << B would overflow, respectively. */ 272 A % B, and A << B would overflow, respectively. */
@@ -295,8 +275,7 @@
295 _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) 275 _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
296#define INT_SUBTRACT_OVERFLOW(a, b) \ 276#define INT_SUBTRACT_OVERFLOW(a, b) \
297 _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) 277 _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
298#define INT_NEGATE_OVERFLOW(a) \ 278#define INT_NEGATE_OVERFLOW(a) _GL_INT_NEGATE_OVERFLOW (a)
299 INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
300#define INT_MULTIPLY_OVERFLOW(a, b) \ 279#define INT_MULTIPLY_OVERFLOW(a, b) \
301 _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) 280 _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
302#define INT_DIVIDE_OVERFLOW(a, b) \ 281#define INT_DIVIDE_OVERFLOW(a, b) \
@@ -313,7 +292,44 @@
313 Arguments should be free of side effects. */ 292 Arguments should be free of side effects. */
314#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ 293#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
315 op_result_overflow (a, b, \ 294 op_result_overflow (a, b, \
316 _GL_INT_MINIMUM (0 * (b) + (a)), \ 295 _GL_INT_MINIMUM (_GL_INT_CONVERT (a, b)), \
317 _GL_INT_MAXIMUM (0 * (b) + (a))) 296 _GL_INT_MAXIMUM (_GL_INT_CONVERT (a, b)))
297
298/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
299 Return 1 if the result overflows. See above for restrictions. */
300#define INT_ADD_WRAPV(a, b, r) _GL_INT_ADD_WRAPV (a, b, r)
301#define INT_SUBTRACT_WRAPV(a, b, r) _GL_INT_SUBTRACT_WRAPV (a, b, r)
302#define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
303
304/* The following macros compute A + B, A - B, and A * B, respectively.
305 If no overflow occurs, they set *R to the result and return 1;
306 otherwise, they return 0 and may modify *R.
307
308 Example usage:
309
310 long int result;
311 if (INT_ADD_OK (a, b, &result))
312 printf ("result is %ld\n", result);
313 else
314 printf ("overflow\n");
315
316 A, B, and *R should be integers; they need not be the same type,
317 and they need not be all signed or all unsigned.
318 However, none of the integer types should be bit-precise,
319 and *R's type should not be char, bool, or an enumeration type.
320
321 These macros work correctly on all known practical hosts, and do not rely
322 on undefined behavior due to signed arithmetic overflow.
323
324 These macros are not constant expressions.
325
326 These macros may evaluate their arguments zero or multiple times, so the
327 arguments should not have side effects.
328
329 These macros are tuned for B being a constant. */
330
331#define INT_ADD_OK(a, b, r) (! INT_ADD_WRAPV (a, b, r))
332#define INT_SUBTRACT_OK(a, b, r) (! INT_SUBTRACT_WRAPV (a, b, r))
333#define INT_MULTIPLY_OK(a, b, r) (! INT_MULTIPLY_WRAPV (a, b, r))
318 334
319#endif /* _GL_INTPROPS_H */ 335#endif /* _GL_INTPROPS_H */
diff --git a/gl/inttypes.in.h b/gl/inttypes.in.h
new file mode 100644
index 00000000..50a2bbfc
--- /dev/null
+++ b/gl/inttypes.in.h
@@ -0,0 +1,1002 @@
1/* Copyright (C) 2006-2023 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Derek Price.
3 This file is part of gnulib.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C 99 <inttypes.h> for platforms that lack it.
20 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html>
21 */
22
23#if __GNUC__ >= 3
24@PRAGMA_SYSTEM_HEADER@
25#endif
26@PRAGMA_COLUMNS@
27
28/* Include the original <inttypes.h> if it exists, and if this file
29 has not been included yet or if this file includes gnulib stdint.h
30 which in turn includes this file.
31 The include_next requires a split double-inclusion guard. */
32#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
33# if @HAVE_INTTYPES_H@
34
35 /* Some pre-C++11 <stdint.h> implementations need this. */
36# if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
37# define __STDC_FORMAT_MACROS 1
38# endif
39
40# @INCLUDE_NEXT@ @NEXT_INTTYPES_H@
41
42# define _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H
43# endif
44#endif
45
46#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
47#define INTTYPES_H
48
49/* Include <stdint.h> or the gnulib replacement.
50 But avoid namespace pollution on glibc systems. */
51#ifndef __GLIBC__
52# include <stdint.h>
53#endif
54/* Get CHAR_BIT, INT_MAX, LONG_MAX, etc. */
55#include <limits.h>
56/* On mingw, __USE_MINGW_ANSI_STDIO only works if <stdio.h> is also included */
57#if defined _WIN32 && ! defined __CYGWIN__
58# include <stdio.h>
59#endif
60
61#if !(INT_MAX == 0x7fffffff && INT_MIN + INT_MAX == -1)
62# error "This file assumes that 'int' is 32-bit two's complement. Please report your platform and compiler to <bug-gnulib@gnu.org>."
63#endif
64
65/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
66
67/* The definition of _GL_ARG_NONNULL is copied here. */
68
69/* The definition of _GL_WARN_ON_USE is copied here. */
70
71/* 7.8.1 Macros for format specifiers */
72
73#if defined _TNS_R_TARGET
74 /* Tandem NonStop R series and compatible platforms released before
75 July 2005 support %Ld but not %lld. */
76# define _LONG_LONG_FORMAT_PREFIX "L"
77#else
78# define _LONG_LONG_FORMAT_PREFIX "ll"
79#endif
80
81#if !defined PRId8
82# ifdef INT8_MAX
83# define PRId8 "d"
84# endif
85#endif
86#if !defined PRIi8
87# ifdef INT8_MAX
88# define PRIi8 "i"
89# endif
90#endif
91#if !defined PRIo8
92# ifdef UINT8_MAX
93# define PRIo8 "o"
94# endif
95#endif
96#if !defined PRIu8
97# ifdef UINT8_MAX
98# define PRIu8 "u"
99# endif
100#endif
101#if !defined PRIx8
102# ifdef UINT8_MAX
103# define PRIx8 "x"
104# endif
105#endif
106#if !defined PRIX8
107# ifdef UINT8_MAX
108# define PRIX8 "X"
109# endif
110#endif
111#if !defined PRId16
112# ifdef INT16_MAX
113# define PRId16 "d"
114# endif
115#endif
116#if !defined PRIi16
117# ifdef INT16_MAX
118# define PRIi16 "i"
119# endif
120#endif
121#if !defined PRIo16
122# ifdef UINT16_MAX
123# define PRIo16 "o"
124# endif
125#endif
126#if !defined PRIu16
127# ifdef UINT16_MAX
128# define PRIu16 "u"
129# endif
130#endif
131#if !defined PRIx16
132# ifdef UINT16_MAX
133# define PRIx16 "x"
134# endif
135#endif
136#if !defined PRIX16
137# ifdef UINT16_MAX
138# define PRIX16 "X"
139# endif
140#endif
141#if !defined PRId32
142# ifdef INT32_MAX
143# define PRId32 "d"
144# endif
145#endif
146#if !defined PRIi32
147# ifdef INT32_MAX
148# define PRIi32 "i"
149# endif
150#endif
151#if !defined PRIo32
152# ifdef UINT32_MAX
153# define PRIo32 "o"
154# endif
155#endif
156#if !defined PRIu32
157# ifdef UINT32_MAX
158# define PRIu32 "u"
159# endif
160#endif
161#if !defined PRIx32
162# ifdef UINT32_MAX
163# define PRIx32 "x"
164# endif
165#endif
166#if !defined PRIX32
167# ifdef UINT32_MAX
168# define PRIX32 "X"
169# endif
170#endif
171#ifdef INT64_MAX
172# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
173# define _PRI64_PREFIX "l"
174# elif defined _MSC_VER || defined __MINGW32__
175# define _PRI64_PREFIX "I64"
176# elif LONG_MAX >> 30 == 1
177# define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
178# endif
179# if !defined PRId64
180# define PRId64 _PRI64_PREFIX "d"
181# endif
182# if !defined PRIi64
183# define PRIi64 _PRI64_PREFIX "i"
184# endif
185#endif
186#ifdef UINT64_MAX
187# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
188# define _PRIu64_PREFIX "l"
189# elif defined _MSC_VER || defined __MINGW32__
190# define _PRIu64_PREFIX "I64"
191# elif ULONG_MAX >> 31 == 1
192# define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
193# endif
194# if !defined PRIo64
195# define PRIo64 _PRIu64_PREFIX "o"
196# endif
197# if !defined PRIu64
198# define PRIu64 _PRIu64_PREFIX "u"
199# endif
200# if !defined PRIx64
201# define PRIx64 _PRIu64_PREFIX "x"
202# endif
203# if !defined PRIX64
204# define PRIX64 _PRIu64_PREFIX "X"
205# endif
206#endif
207
208#if !defined PRIdLEAST8
209# define PRIdLEAST8 "d"
210#endif
211#if !defined PRIiLEAST8
212# define PRIiLEAST8 "i"
213#endif
214#if !defined PRIoLEAST8
215# define PRIoLEAST8 "o"
216#endif
217#if !defined PRIuLEAST8
218# define PRIuLEAST8 "u"
219#endif
220#if !defined PRIxLEAST8
221# define PRIxLEAST8 "x"
222#endif
223#if !defined PRIXLEAST8
224# define PRIXLEAST8 "X"
225#endif
226#if !defined PRIdLEAST16
227# define PRIdLEAST16 "d"
228#endif
229#if !defined PRIiLEAST16
230# define PRIiLEAST16 "i"
231#endif
232#if !defined PRIoLEAST16
233# define PRIoLEAST16 "o"
234#endif
235#if !defined PRIuLEAST16
236# define PRIuLEAST16 "u"
237#endif
238#if !defined PRIxLEAST16
239# define PRIxLEAST16 "x"
240#endif
241#if !defined PRIXLEAST16
242# define PRIXLEAST16 "X"
243#endif
244#if !defined PRIdLEAST32
245# define PRIdLEAST32 "d"
246#endif
247#if !defined PRIiLEAST32
248# define PRIiLEAST32 "i"
249#endif
250#if !defined PRIoLEAST32
251# define PRIoLEAST32 "o"
252#endif
253#if !defined PRIuLEAST32
254# define PRIuLEAST32 "u"
255#endif
256#if !defined PRIxLEAST32
257# define PRIxLEAST32 "x"
258#endif
259#if !defined PRIXLEAST32
260# define PRIXLEAST32 "X"
261#endif
262#ifdef INT64_MAX
263# if !defined PRIdLEAST64
264# define PRIdLEAST64 PRId64
265# endif
266# if !defined PRIiLEAST64
267# define PRIiLEAST64 PRIi64
268# endif
269#endif
270#ifdef UINT64_MAX
271# if !defined PRIoLEAST64
272# define PRIoLEAST64 PRIo64
273# endif
274# if !defined PRIuLEAST64
275# define PRIuLEAST64 PRIu64
276# endif
277# if !defined PRIxLEAST64
278# define PRIxLEAST64 PRIx64
279# endif
280# if !defined PRIXLEAST64
281# define PRIXLEAST64 PRIX64
282# endif
283#endif
284
285#if !defined PRIdFAST8
286# if INT_FAST8_MAX > INT32_MAX
287# define PRIdFAST8 PRId64
288# else
289# define PRIdFAST8 "d"
290# endif
291#endif
292#if !defined PRIiFAST8
293# if INT_FAST8_MAX > INT32_MAX
294# define PRIiFAST8 PRIi64
295# else
296# define PRIiFAST8 "i"
297# endif
298#endif
299#if !defined PRIoFAST8
300# if UINT_FAST8_MAX > UINT32_MAX
301# define PRIoFAST8 PRIo64
302# else
303# define PRIoFAST8 "o"
304# endif
305#endif
306#if !defined PRIuFAST8
307# if UINT_FAST8_MAX > UINT32_MAX
308# define PRIuFAST8 PRIu64
309# else
310# define PRIuFAST8 "u"
311# endif
312#endif
313#if !defined PRIxFAST8
314# if UINT_FAST8_MAX > UINT32_MAX
315# define PRIxFAST8 PRIx64
316# else
317# define PRIxFAST8 "x"
318# endif
319#endif
320#if !defined PRIXFAST8
321# if UINT_FAST8_MAX > UINT32_MAX
322# define PRIXFAST8 PRIX64
323# else
324# define PRIXFAST8 "X"
325# endif
326#endif
327#if !defined PRIdFAST16
328# if INT_FAST16_MAX > INT32_MAX
329# define PRIdFAST16 PRId64
330# else
331# define PRIdFAST16 "d"
332# endif
333#endif
334#if !defined PRIiFAST16
335# if INT_FAST16_MAX > INT32_MAX
336# define PRIiFAST16 PRIi64
337# else
338# define PRIiFAST16 "i"
339# endif
340#endif
341#if !defined PRIoFAST16
342# if UINT_FAST16_MAX > UINT32_MAX
343# define PRIoFAST16 PRIo64
344# else
345# define PRIoFAST16 "o"
346# endif
347#endif
348#if !defined PRIuFAST16
349# if UINT_FAST16_MAX > UINT32_MAX
350# define PRIuFAST16 PRIu64
351# else
352# define PRIuFAST16 "u"
353# endif
354#endif
355#if !defined PRIxFAST16
356# if UINT_FAST16_MAX > UINT32_MAX
357# define PRIxFAST16 PRIx64
358# else
359# define PRIxFAST16 "x"
360# endif
361#endif
362#if !defined PRIXFAST16
363# if UINT_FAST16_MAX > UINT32_MAX
364# define PRIXFAST16 PRIX64
365# else
366# define PRIXFAST16 "X"
367# endif
368#endif
369#if !defined PRIdFAST32
370# if INT_FAST32_MAX > INT32_MAX
371# define PRIdFAST32 PRId64
372# else
373# define PRIdFAST32 "d"
374# endif
375#endif
376#if !defined PRIiFAST32
377# if INT_FAST32_MAX > INT32_MAX
378# define PRIiFAST32 PRIi64
379# else
380# define PRIiFAST32 "i"
381# endif
382#endif
383#if !defined PRIoFAST32
384# if UINT_FAST32_MAX > UINT32_MAX
385# define PRIoFAST32 PRIo64
386# else
387# define PRIoFAST32 "o"
388# endif
389#endif
390#if !defined PRIuFAST32
391# if UINT_FAST32_MAX > UINT32_MAX
392# define PRIuFAST32 PRIu64
393# else
394# define PRIuFAST32 "u"
395# endif
396#endif
397#if !defined PRIxFAST32
398# if UINT_FAST32_MAX > UINT32_MAX
399# define PRIxFAST32 PRIx64
400# else
401# define PRIxFAST32 "x"
402# endif
403#endif
404#if !defined PRIXFAST32
405# if UINT_FAST32_MAX > UINT32_MAX
406# define PRIXFAST32 PRIX64
407# else
408# define PRIXFAST32 "X"
409# endif
410#endif
411#ifdef INT64_MAX
412# if !defined PRIdFAST64
413# define PRIdFAST64 PRId64
414# endif
415# if !defined PRIiFAST64
416# define PRIiFAST64 PRIi64
417# endif
418#endif
419#ifdef UINT64_MAX
420# if !defined PRIoFAST64
421# define PRIoFAST64 PRIo64
422# endif
423# if !defined PRIuFAST64
424# define PRIuFAST64 PRIu64
425# endif
426# if !defined PRIxFAST64
427# define PRIxFAST64 PRIx64
428# endif
429# if !defined PRIXFAST64
430# define PRIXFAST64 PRIX64
431# endif
432#endif
433
434#if !defined PRIdMAX
435# if @INT32_MAX_LT_INTMAX_MAX@
436# define PRIdMAX PRId64
437# else
438# define PRIdMAX "ld"
439# endif
440#endif
441#if !defined PRIiMAX
442# if @INT32_MAX_LT_INTMAX_MAX@
443# define PRIiMAX PRIi64
444# else
445# define PRIiMAX "li"
446# endif
447#endif
448#if !defined PRIoMAX
449# if @UINT32_MAX_LT_UINTMAX_MAX@
450# define PRIoMAX PRIo64
451# else
452# define PRIoMAX "lo"
453# endif
454#endif
455#if !defined PRIuMAX
456# if @UINT32_MAX_LT_UINTMAX_MAX@
457# define PRIuMAX PRIu64
458# else
459# define PRIuMAX "lu"
460# endif
461#endif
462#if !defined PRIxMAX
463# if @UINT32_MAX_LT_UINTMAX_MAX@
464# define PRIxMAX PRIx64
465# else
466# define PRIxMAX "lx"
467# endif
468#endif
469#if !defined PRIXMAX
470# if @UINT32_MAX_LT_UINTMAX_MAX@
471# define PRIXMAX PRIX64
472# else
473# define PRIXMAX "lX"
474# endif
475#endif
476
477#if !defined PRIdPTR
478# ifdef INTPTR_MAX
479# define PRIdPTR @PRIPTR_PREFIX@ "d"
480# endif
481#endif
482#if !defined PRIiPTR
483# ifdef INTPTR_MAX
484# define PRIiPTR @PRIPTR_PREFIX@ "i"
485# endif
486#endif
487#if !defined PRIoPTR
488# ifdef UINTPTR_MAX
489# define PRIoPTR @PRIPTR_PREFIX@ "o"
490# endif
491#endif
492#if !defined PRIuPTR
493# ifdef UINTPTR_MAX
494# define PRIuPTR @PRIPTR_PREFIX@ "u"
495# endif
496#endif
497#if !defined PRIxPTR
498# ifdef UINTPTR_MAX
499# define PRIxPTR @PRIPTR_PREFIX@ "x"
500# endif
501#endif
502#if !defined PRIXPTR
503# ifdef UINTPTR_MAX
504# define PRIXPTR @PRIPTR_PREFIX@ "X"
505# endif
506#endif
507
508#if !defined SCNd8
509# ifdef INT8_MAX
510# define SCNd8 "hhd"
511# endif
512#endif
513#if !defined SCNi8
514# ifdef INT8_MAX
515# define SCNi8 "hhi"
516# endif
517#endif
518#if !defined SCNo8
519# ifdef UINT8_MAX
520# define SCNo8 "hho"
521# endif
522#endif
523#if !defined SCNu8
524# ifdef UINT8_MAX
525# define SCNu8 "hhu"
526# endif
527#endif
528#if !defined SCNx8
529# ifdef UINT8_MAX
530# define SCNx8 "hhx"
531# endif
532#endif
533#if !defined SCNd16
534# ifdef INT16_MAX
535# define SCNd16 "hd"
536# endif
537#endif
538#if !defined SCNi16
539# ifdef INT16_MAX
540# define SCNi16 "hi"
541# endif
542#endif
543#if !defined SCNo16
544# ifdef UINT16_MAX
545# define SCNo16 "ho"
546# endif
547#endif
548#if !defined SCNu16
549# ifdef UINT16_MAX
550# define SCNu16 "hu"
551# endif
552#endif
553#if !defined SCNx16
554# ifdef UINT16_MAX
555# define SCNx16 "hx"
556# endif
557#endif
558#if !defined SCNd32
559# ifdef INT32_MAX
560# define SCNd32 "d"
561# endif
562#endif
563#if !defined SCNi32
564# ifdef INT32_MAX
565# define SCNi32 "i"
566# endif
567#endif
568#if !defined SCNo32
569# ifdef UINT32_MAX
570# define SCNo32 "o"
571# endif
572#endif
573#if !defined SCNu32
574# ifdef UINT32_MAX
575# define SCNu32 "u"
576# endif
577#endif
578#if !defined SCNx32
579# ifdef UINT32_MAX
580# define SCNx32 "x"
581# endif
582#endif
583#ifdef INT64_MAX
584# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
585# define _SCN64_PREFIX "l"
586# elif defined _MSC_VER || defined __MINGW32__
587# define _SCN64_PREFIX "I64"
588# elif LONG_MAX >> 30 == 1
589# define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
590# endif
591# if !defined SCNd64
592# define SCNd64 _SCN64_PREFIX "d"
593# endif
594# if !defined SCNi64
595# define SCNi64 _SCN64_PREFIX "i"
596# endif
597#endif
598#ifdef UINT64_MAX
599# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
600# define _SCNu64_PREFIX "l"
601# elif defined _MSC_VER || defined __MINGW32__
602# define _SCNu64_PREFIX "I64"
603# elif ULONG_MAX >> 31 == 1
604# define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
605# endif
606# if !defined SCNo64
607# define SCNo64 _SCNu64_PREFIX "o"
608# endif
609# if !defined SCNu64
610# define SCNu64 _SCNu64_PREFIX "u"
611# endif
612# if !defined SCNx64
613# define SCNx64 _SCNu64_PREFIX "x"
614# endif
615#endif
616
617#if !defined SCNdLEAST8
618# define SCNdLEAST8 "hhd"
619#endif
620#if !defined SCNiLEAST8
621# define SCNiLEAST8 "hhi"
622#endif
623#if !defined SCNoLEAST8
624# define SCNoLEAST8 "hho"
625#endif
626#if !defined SCNuLEAST8
627# define SCNuLEAST8 "hhu"
628#endif
629#if !defined SCNxLEAST8
630# define SCNxLEAST8 "hhx"
631#endif
632#if !defined SCNdLEAST16
633# define SCNdLEAST16 "hd"
634#endif
635#if !defined SCNiLEAST16
636# define SCNiLEAST16 "hi"
637#endif
638#if !defined SCNoLEAST16
639# define SCNoLEAST16 "ho"
640#endif
641#if !defined SCNuLEAST16
642# define SCNuLEAST16 "hu"
643#endif
644#if !defined SCNxLEAST16
645# define SCNxLEAST16 "hx"
646#endif
647#if !defined SCNdLEAST32
648# define SCNdLEAST32 "d"
649#endif
650#if !defined SCNiLEAST32
651# define SCNiLEAST32 "i"
652#endif
653#if !defined SCNoLEAST32
654# define SCNoLEAST32 "o"
655#endif
656#if !defined SCNuLEAST32
657# define SCNuLEAST32 "u"
658#endif
659#if !defined SCNxLEAST32
660# define SCNxLEAST32 "x"
661#endif
662#ifdef INT64_MAX
663# if !defined SCNdLEAST64
664# define SCNdLEAST64 SCNd64
665# endif
666# if !defined SCNiLEAST64
667# define SCNiLEAST64 SCNi64
668# endif
669#endif
670#ifdef UINT64_MAX
671# if !defined SCNoLEAST64
672# define SCNoLEAST64 SCNo64
673# endif
674# if !defined SCNuLEAST64
675# define SCNuLEAST64 SCNu64
676# endif
677# if !defined SCNxLEAST64
678# define SCNxLEAST64 SCNx64
679# endif
680#endif
681
682#if !defined SCNdFAST8
683# if INT_FAST8_MAX > INT32_MAX
684# define SCNdFAST8 SCNd64
685# elif INT_FAST8_MAX == 0x7fff
686# define SCNdFAST8 "hd"
687# elif INT_FAST8_MAX == 0x7f
688# define SCNdFAST8 "hhd"
689# else
690# define SCNdFAST8 "d"
691# endif
692#endif
693#if !defined SCNiFAST8
694# if INT_FAST8_MAX > INT32_MAX
695# define SCNiFAST8 SCNi64
696# elif INT_FAST8_MAX == 0x7fff
697# define SCNiFAST8 "hi"
698# elif INT_FAST8_MAX == 0x7f
699# define SCNiFAST8 "hhi"
700# else
701# define SCNiFAST8 "i"
702# endif
703#endif
704#if !defined SCNoFAST8
705# if UINT_FAST8_MAX > UINT32_MAX
706# define SCNoFAST8 SCNo64
707# elif UINT_FAST8_MAX == 0xffff
708# define SCNoFAST8 "ho"
709# elif UINT_FAST8_MAX == 0xff
710# define SCNoFAST8 "hho"
711# else
712# define SCNoFAST8 "o"
713# endif
714#endif
715#if !defined SCNuFAST8
716# if UINT_FAST8_MAX > UINT32_MAX
717# define SCNuFAST8 SCNu64
718# elif UINT_FAST8_MAX == 0xffff
719# define SCNuFAST8 "hu"
720# elif UINT_FAST8_MAX == 0xff
721# define SCNuFAST8 "hhu"
722# else
723# define SCNuFAST8 "u"
724# endif
725#endif
726#if !defined SCNxFAST8
727# if UINT_FAST8_MAX > UINT32_MAX
728# define SCNxFAST8 SCNx64
729# elif UINT_FAST8_MAX == 0xffff
730# define SCNxFAST8 "hx"
731# elif UINT_FAST8_MAX == 0xff
732# define SCNxFAST8 "hhx"
733# else
734# define SCNxFAST8 "x"
735# endif
736#endif
737#if !defined SCNdFAST16
738# if INT_FAST16_MAX > INT32_MAX
739# define SCNdFAST16 SCNd64
740# elif INT_FAST16_MAX == 0x7fff
741# define SCNdFAST16 "hd"
742# else
743# define SCNdFAST16 "d"
744# endif
745#endif
746#if !defined SCNiFAST16
747# if INT_FAST16_MAX > INT32_MAX
748# define SCNiFAST16 SCNi64
749# elif INT_FAST16_MAX == 0x7fff
750# define SCNiFAST16 "hi"
751# else
752# define SCNiFAST16 "i"
753# endif
754#endif
755#if !defined SCNoFAST16
756# if UINT_FAST16_MAX > UINT32_MAX
757# define SCNoFAST16 SCNo64
758# elif UINT_FAST16_MAX == 0xffff
759# define SCNoFAST16 "ho"
760# else
761# define SCNoFAST16 "o"
762# endif
763#endif
764#if !defined SCNuFAST16
765# if UINT_FAST16_MAX > UINT32_MAX
766# define SCNuFAST16 SCNu64
767# elif UINT_FAST16_MAX == 0xffff
768# define SCNuFAST16 "hu"
769# else
770# define SCNuFAST16 "u"
771# endif
772#endif
773#if !defined SCNxFAST16
774# if UINT_FAST16_MAX > UINT32_MAX
775# define SCNxFAST16 SCNx64
776# elif UINT_FAST16_MAX == 0xffff
777# define SCNxFAST16 "hx"
778# else
779# define SCNxFAST16 "x"
780# endif
781#endif
782#if !defined SCNdFAST32
783# if INT_FAST32_MAX > INT32_MAX
784# define SCNdFAST32 SCNd64
785# else
786# define SCNdFAST32 "d"
787# endif
788#endif
789#if !defined SCNiFAST32
790# if INT_FAST32_MAX > INT32_MAX
791# define SCNiFAST32 SCNi64
792# else
793# define SCNiFAST32 "i"
794# endif
795#endif
796#if !defined SCNoFAST32
797# if UINT_FAST32_MAX > UINT32_MAX
798# define SCNoFAST32 SCNo64
799# else
800# define SCNoFAST32 "o"
801# endif
802#endif
803#if !defined SCNuFAST32
804# if UINT_FAST32_MAX > UINT32_MAX
805# define SCNuFAST32 SCNu64
806# else
807# define SCNuFAST32 "u"
808# endif
809#endif
810#if !defined SCNxFAST32
811# if UINT_FAST32_MAX > UINT32_MAX
812# define SCNxFAST32 SCNx64
813# else
814# define SCNxFAST32 "x"
815# endif
816#endif
817#ifdef INT64_MAX
818# if !defined SCNdFAST64
819# define SCNdFAST64 SCNd64
820# endif
821# if !defined SCNiFAST64
822# define SCNiFAST64 SCNi64
823# endif
824#endif
825#ifdef UINT64_MAX
826# if !defined SCNoFAST64
827# define SCNoFAST64 SCNo64
828# endif
829# if !defined SCNuFAST64
830# define SCNuFAST64 SCNu64
831# endif
832# if !defined SCNxFAST64
833# define SCNxFAST64 SCNx64
834# endif
835#endif
836
837#if !defined SCNdMAX
838# if @INT32_MAX_LT_INTMAX_MAX@
839# define SCNdMAX SCNd64
840# else
841# define SCNdMAX "ld"
842# endif
843#endif
844#if !defined SCNiMAX
845# if @INT32_MAX_LT_INTMAX_MAX@
846# define SCNiMAX SCNi64
847# else
848# define SCNiMAX "li"
849# endif
850#endif
851#if !defined SCNoMAX
852# if @UINT32_MAX_LT_UINTMAX_MAX@
853# define SCNoMAX SCNo64
854# else
855# define SCNoMAX "lo"
856# endif
857#endif
858#if !defined SCNuMAX
859# if @UINT32_MAX_LT_UINTMAX_MAX@
860# define SCNuMAX SCNu64
861# else
862# define SCNuMAX "lu"
863# endif
864#endif
865#if !defined SCNxMAX
866# if @UINT32_MAX_LT_UINTMAX_MAX@
867# define SCNxMAX SCNx64
868# else
869# define SCNxMAX "lx"
870# endif
871#endif
872
873#if !defined SCNdPTR
874# ifdef INTPTR_MAX
875# define SCNdPTR @PRIPTR_PREFIX@ "d"
876# endif
877#endif
878#if !defined SCNiPTR
879# ifdef INTPTR_MAX
880# define SCNiPTR @PRIPTR_PREFIX@ "i"
881# endif
882#endif
883#if !defined SCNoPTR
884# ifdef UINTPTR_MAX
885# define SCNoPTR @PRIPTR_PREFIX@ "o"
886# endif
887#endif
888#if !defined SCNuPTR
889# ifdef UINTPTR_MAX
890# define SCNuPTR @PRIPTR_PREFIX@ "u"
891# endif
892#endif
893#if !defined SCNxPTR
894# ifdef UINTPTR_MAX
895# define SCNxPTR @PRIPTR_PREFIX@ "x"
896# endif
897#endif
898
899/* 7.8.2 Functions for greatest-width integer types */
900
901#ifdef __cplusplus
902extern "C" {
903#endif
904
905#if @GNULIB_IMAXABS@
906# if !@HAVE_DECL_IMAXABS@
907extern intmax_t imaxabs (intmax_t);
908# endif
909#elif defined GNULIB_POSIXCHECK
910# undef imaxabs
911# if HAVE_RAW_DECL_IMAXABS
912_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
913 "use gnulib module imaxabs for portability");
914# endif
915#endif
916
917#if @GNULIB_IMAXDIV@
918# if !@HAVE_IMAXDIV_T@
919# if !GNULIB_defined_imaxdiv_t
920typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
921# define GNULIB_defined_imaxdiv_t 1
922# endif
923# endif
924# if !@HAVE_DECL_IMAXDIV@
925extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
926# endif
927#elif defined GNULIB_POSIXCHECK
928# undef imaxdiv
929# if HAVE_RAW_DECL_IMAXDIV
930_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
931 "use gnulib module imaxdiv for portability");
932# endif
933#endif
934
935#if @GNULIB_STRTOIMAX@
936# if @REPLACE_STRTOIMAX@
937# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
938# undef strtoimax
939# define strtoimax rpl_strtoimax
940# endif
941_GL_FUNCDECL_RPL (strtoimax, intmax_t,
942 (const char *restrict, char **restrict, int)
943 _GL_ARG_NONNULL ((1)));
944_GL_CXXALIAS_RPL (strtoimax, intmax_t,
945 (const char *restrict, char **restrict, int));
946# else
947# if !@HAVE_DECL_STRTOIMAX@
948# undef strtoimax
949_GL_FUNCDECL_SYS (strtoimax, intmax_t,
950 (const char *restrict, char **restrict, int)
951 _GL_ARG_NONNULL ((1)));
952# endif
953_GL_CXXALIAS_SYS (strtoimax, intmax_t,
954 (const char *restrict, char **restrict, int));
955# endif
956_GL_CXXALIASWARN (strtoimax);
957#elif defined GNULIB_POSIXCHECK
958# undef strtoimax
959# if HAVE_RAW_DECL_STRTOIMAX
960_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
961 "use gnulib module strtoimax for portability");
962# endif
963#endif
964
965#if @GNULIB_STRTOUMAX@
966# if @REPLACE_STRTOUMAX@
967# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
968# undef strtoumax
969# define strtoumax rpl_strtoumax
970# endif
971_GL_FUNCDECL_RPL (strtoumax, uintmax_t,
972 (const char *restrict, char **restrict, int)
973 _GL_ARG_NONNULL ((1)));
974_GL_CXXALIAS_RPL (strtoumax, uintmax_t,
975 (const char *restrict, char **restrict, int));
976# else
977# if !@HAVE_DECL_STRTOUMAX@
978# undef strtoumax
979_GL_FUNCDECL_SYS (strtoumax, uintmax_t,
980 (const char *restrict, char **restrict, int)
981 _GL_ARG_NONNULL ((1)));
982# endif
983_GL_CXXALIAS_SYS (strtoumax, uintmax_t,
984 (const char *restrict, char **restrict, int));
985# endif
986_GL_CXXALIASWARN (strtoumax);
987#elif defined GNULIB_POSIXCHECK
988# undef strtoumax
989# if HAVE_RAW_DECL_STRTOUMAX
990_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - "
991 "use gnulib module strtoumax for portability");
992# endif
993#endif
994
995/* Don't bother defining or declaring wcstoimax and wcstoumax, since
996 wide-character functions like this are hardly ever useful. */
997
998#ifdef __cplusplus
999}
1000#endif
1001
1002#endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */
diff --git a/gl/itold.c b/gl/itold.c
index 9aabc7e4..0ef4464e 100644
--- a/gl/itold.c
+++ b/gl/itold.c
@@ -1,19 +1,19 @@
1/* Replacement for 'int' to 'long double' conversion routine. 1/* Replacement for 'int' to 'long double' conversion routine.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/langinfo.in.h b/gl/langinfo.in.h
index 5388ce62..c7555a6a 100644
--- a/gl/langinfo.in.h
+++ b/gl/langinfo.in.h
@@ -1,22 +1,22 @@
1/* Substitute for and wrapper around <langinfo.h>. 1/* Substitute for and wrapper around <langinfo.h>.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* 17/*
18 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one. 18 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
19 * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html> 19 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
20 */ 20 */
21 21
22#ifndef _@GUARD_PREFIX@_LANGINFO_H 22#ifndef _@GUARD_PREFIX@_LANGINFO_H
@@ -49,7 +49,10 @@ typedef int nl_item;
49# define CODESET 10000 49# define CODESET 10000
50/* nl_langinfo items of the LC_NUMERIC category */ 50/* nl_langinfo items of the LC_NUMERIC category */
51# define RADIXCHAR 10001 51# define RADIXCHAR 10001
52# define DECIMAL_POINT RADIXCHAR
52# define THOUSEP 10002 53# define THOUSEP 10002
54# define THOUSANDS_SEP THOUSEP
55# define GROUPING 10114
53/* nl_langinfo items of the LC_TIME category */ 56/* nl_langinfo items of the LC_TIME category */
54# define D_T_FMT 10003 57# define D_T_FMT 10003
55# define D_FMT 10004 58# define D_FMT 10004
@@ -83,6 +86,18 @@ typedef int nl_item;
83# define MON_10 (MON_1 + 9) 86# define MON_10 (MON_1 + 9)
84# define MON_11 (MON_1 + 10) 87# define MON_11 (MON_1 + 10)
85# define MON_12 (MON_1 + 11) 88# define MON_12 (MON_1 + 11)
89# define ALTMON_1 10200
90# define ALTMON_2 (ALTMON_1 + 1)
91# define ALTMON_3 (ALTMON_1 + 2)
92# define ALTMON_4 (ALTMON_1 + 3)
93# define ALTMON_5 (ALTMON_1 + 4)
94# define ALTMON_6 (ALTMON_1 + 5)
95# define ALTMON_7 (ALTMON_1 + 6)
96# define ALTMON_8 (ALTMON_1 + 7)
97# define ALTMON_9 (ALTMON_1 + 8)
98# define ALTMON_10 (ALTMON_1 + 9)
99# define ALTMON_11 (ALTMON_1 + 10)
100# define ALTMON_12 (ALTMON_1 + 11)
86# define ABMON_1 10035 101# define ABMON_1 10035
87# define ABMON_2 (ABMON_1 + 1) 102# define ABMON_2 (ABMON_1 + 1)
88# define ABMON_3 (ABMON_1 + 2) 103# define ABMON_3 (ABMON_1 + 2)
@@ -102,6 +117,21 @@ typedef int nl_item;
102# define ALT_DIGITS 10051 117# define ALT_DIGITS 10051
103/* nl_langinfo items of the LC_MONETARY category */ 118/* nl_langinfo items of the LC_MONETARY category */
104# define CRNCYSTR 10052 119# define CRNCYSTR 10052
120# define CURRENCY_SYMBOL CRNCYSTR
121# define INT_CURR_SYMBOL 10100
122# define MON_DECIMAL_POINT 10101
123# define MON_THOUSANDS_SEP 10102
124# define MON_GROUPING 10103
125# define POSITIVE_SIGN 10104
126# define NEGATIVE_SIGN 10105
127# define FRAC_DIGITS 10106
128# define INT_FRAC_DIGITS 10107
129# define P_CS_PRECEDES 10108
130# define N_CS_PRECEDES 10109
131# define P_SEP_BY_SPACE 10110
132# define N_SEP_BY_SPACE 10111
133# define P_SIGN_POSN 10112
134# define N_SIGN_POSN 10113
105/* nl_langinfo items of the LC_MESSAGES category */ 135/* nl_langinfo items of the LC_MESSAGES category */
106# define YESEXPR 10053 136# define YESEXPR 10053
107# define NOEXPR 10054 137# define NOEXPR 10054
@@ -120,6 +150,22 @@ typedef int nl_item;
120# define GNULIB_defined_T_FMT_AMPM 1 150# define GNULIB_defined_T_FMT_AMPM 1
121# endif 151# endif
122 152
153# if !@HAVE_LANGINFO_ALTMON@
154# define ALTMON_1 10200
155# define ALTMON_2 (ALTMON_1 + 1)
156# define ALTMON_3 (ALTMON_1 + 2)
157# define ALTMON_4 (ALTMON_1 + 3)
158# define ALTMON_5 (ALTMON_1 + 4)
159# define ALTMON_6 (ALTMON_1 + 5)
160# define ALTMON_7 (ALTMON_1 + 6)
161# define ALTMON_8 (ALTMON_1 + 7)
162# define ALTMON_9 (ALTMON_1 + 8)
163# define ALTMON_10 (ALTMON_1 + 9)
164# define ALTMON_11 (ALTMON_1 + 10)
165# define ALTMON_12 (ALTMON_1 + 11)
166# define GNULIB_defined_ALTMON 1
167# endif
168
123# if !@HAVE_LANGINFO_ERA@ 169# if !@HAVE_LANGINFO_ERA@
124# define ERA 10047 170# define ERA 10047
125# define ERA_D_FMT 10048 171# define ERA_D_FMT 10048
diff --git a/gl/lc-charset-dispatch.c b/gl/lc-charset-dispatch.c
new file mode 100644
index 00000000..cd74466b
--- /dev/null
+++ b/gl/lc-charset-dispatch.c
@@ -0,0 +1,82 @@
1/* Dispatching based on the current locale's character encoding.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2018. */
18
19#include <config.h>
20
21/* Specification. */
22#include "lc-charset-dispatch.h"
23
24#if GNULIB_defined_mbstate_t
25
26# include "localcharset.h"
27# include "streq.h"
28
29# if GNULIB_WCHAR_SINGLE_LOCALE
30/* When we know that the locale does not change, provide a speedup by
31 caching the value of locale_encoding_classification. */
32# define locale_encoding_classification_cached locale_encoding_classification
33# else
34/* By default, don't make assumptions, hence no caching. */
35# define locale_encoding_classification_uncached locale_encoding_classification
36# endif
37
38# if GNULIB_WCHAR_SINGLE_LOCALE
39static inline
40# endif
41enc_t
42locale_encoding_classification_uncached (void)
43{
44 const char *encoding = locale_charset ();
45 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
46 return enc_utf8;
47 if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
48 return enc_eucjp;
49 if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
50 || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
51 || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
52 return enc_94;
53 if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
54 return enc_euctw;
55 if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
56 return enc_gb18030;
57 if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
58 return enc_sjis;
59 return enc_other;
60}
61
62# if GNULIB_WCHAR_SINGLE_LOCALE
63
64static int cached_locale_enc = -1;
65
66enc_t
67locale_encoding_classification_cached (void)
68{
69 if (cached_locale_enc < 0)
70 cached_locale_enc = locale_encoding_classification_uncached ();
71 return cached_locale_enc;
72}
73
74# endif
75
76#else
77
78/* This declaration is solely to ensure that after preprocessing
79 this file is never empty. */
80typedef int dummy;
81
82#endif
diff --git a/gl/lc-charset-dispatch.h b/gl/lc-charset-dispatch.h
new file mode 100644
index 00000000..c82b6a60
--- /dev/null
+++ b/gl/lc-charset-dispatch.h
@@ -0,0 +1,40 @@
1/* Dispatching based on the current locale's character encoding.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2018. */
18
19#include <wchar.h>
20
21#if GNULIB_defined_mbstate_t
22
23/* A classification of special values of the encoding of the current locale. */
24typedef enum
25 {
26 enc_other, /* other */
27 enc_utf8, /* UTF-8 */
28 enc_eucjp, /* EUC-JP */
29 enc_94, /* EUC-KR, GB2312, BIG5 */
30 enc_euctw, /* EUC-TW */
31 enc_gb18030, /* GB18030 */
32 enc_sjis /* SJIS */
33 }
34 enc_t;
35
36/* Returns a classification of special values of the encoding of the current
37 locale. */
38extern enc_t locale_encoding_classification (void);
39
40#endif
diff --git a/gl/libc-config.h b/gl/libc-config.h
new file mode 100644
index 00000000..1d28e58c
--- /dev/null
+++ b/gl/libc-config.h
@@ -0,0 +1,202 @@
1/* System definitions for code taken from the GNU C Library
2
3 Copyright 2017-2023 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this program; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* Written by Paul Eggert. */
20
21/* This is intended to be a good-enough substitute for glibc system
22 macros like those defined in <sys/cdefs.h>, so that Gnulib code
23 shared with glibc can do this as the first #include:
24
25 #ifndef _LIBC
26 # include <libc-config.h>
27 #endif
28
29 When compiled as part of glibc this is a no-op; when compiled as
30 part of Gnulib this includes Gnulib's <config.h> and defines macros
31 that glibc library code would normally assume.
32
33 Note: This header file MUST NOT be included by public header files
34 of Gnulib. */
35
36#include <config.h>
37
38/* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
39 _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 and
40 DragonFlyBSD 5.9 it includes <sys/cdefs.h> which defines __nonnull.
41 Elsewhere it is harmless. */
42#include <errno.h>
43
44/* From glibc <errno.h>. */
45#ifndef __set_errno
46# define __set_errno(val) (errno = (val))
47#endif
48
49/* From glibc <features.h>. */
50
51#ifndef __GNUC_PREREQ
52# if defined __GNUC__ && defined __GNUC_MINOR__
53# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
54# else
55# define __GNUC_PREREQ(maj, min) 0
56# endif
57#endif
58
59#ifndef __glibc_clang_prereq
60# if defined __clang_major__ && defined __clang_minor__
61# ifdef __apple_build_version__
62/* Apple for some reason renumbers __clang_major__ and __clang_minor__.
63 Gnulib code uses only __glibc_clang_prereq (3, 5); map it to
64 6000000 <= __apple_build_version__. Support for other calls to
65 __glibc_clang_prereq can be added here as needed. */
66# define __glibc_clang_prereq(maj, min) \
67 ((maj) == 3 && (min) == 5 ? 6000000 <= __apple_build_version__ : 0)
68# else
69# define __glibc_clang_prereq(maj, min) \
70 ((maj) < __clang_major__ + ((min) <= __clang_minor__))
71# endif
72# else
73# define __glibc_clang_prereq(maj, min) 0
74# endif
75#endif
76
77#ifndef __attribute_nonnull__
78/* <sys/cdefs.h> either does not exist, or is too old for Gnulib.
79 Prepare to include <cdefs.h>, which is Gnulib's version of a
80 more-recent glibc <sys/cdefs.h>. */
81
82/* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
83# ifndef _FEATURES_H
84# define _FEATURES_H 1
85# endif
86/* Define __GNULIB_CDEFS so that <cdefs.h> does not attempt to include
87 nonexistent files. */
88# define __GNULIB_CDEFS
89/* Undef the macros unconditionally defined by our copy of glibc
90 <sys/cdefs.h>, so that they do not clash with any system-defined
91 versions. */
92# undef _SYS_CDEFS_H
93# undef __ASMNAME
94# undef __ASMNAME2
95# undef __BEGIN_DECLS
96# undef __CONCAT
97# undef __END_DECLS
98# undef __HAVE_GENERIC_SELECTION
99# undef __LDBL_COMPAT
100# undef __LDBL_REDIR
101# undef __LDBL_REDIR1
102# undef __LDBL_REDIR1_DECL
103# undef __LDBL_REDIR1_NTH
104# undef __LDBL_REDIR2_DECL
105# undef __LDBL_REDIR_DECL
106# undef __LDBL_REDIR_NTH
107# undef __LEAF
108# undef __LEAF_ATTR
109# undef __NTH
110# undef __NTHNL
111# undef __REDIRECT
112# undef __REDIRECT_LDBL
113# undef __REDIRECT_NTH
114# undef __REDIRECT_NTHNL
115# undef __REDIRECT_NTH_LDBL
116# undef __STRING
117# undef __THROW
118# undef __THROWNL
119# undef __attr_access
120# undef __attr_access_none
121# undef __attr_dealloc
122# undef __attr_dealloc_free
123# undef __attribute__
124# undef __attribute_alloc_align__
125# undef __attribute_alloc_size__
126# undef __attribute_artificial__
127# undef __attribute_const__
128# undef __attribute_deprecated__
129# undef __attribute_deprecated_msg__
130# undef __attribute_format_arg__
131# undef __attribute_format_strfmon__
132# undef __attribute_malloc__
133# undef __attribute_maybe_unused__
134# undef __attribute_noinline__
135# undef __attribute_nonstring__
136# undef __attribute_pure__
137# undef __attribute_returns_twice__
138# undef __attribute_used__
139# undef __attribute_warn_unused_result__
140# undef __bos
141# undef __bos0
142# undef __errordecl
143# undef __extension__
144# undef __extern_always_inline
145# undef __extern_inline
146# undef __flexarr
147# undef __fortified_attr_access
148# undef __fortify_function
149# undef __glibc_c99_flexarr_available
150# undef __glibc_fortify
151# undef __glibc_fortify_n
152# undef __glibc_has_attribute
153# undef __glibc_has_builtin
154# undef __glibc_has_extension
155# undef __glibc_likely
156# undef __glibc_macro_warning
157# undef __glibc_macro_warning1
158# undef __glibc_objsize
159# undef __glibc_objsize0
160# undef __glibc_safe_len_cond
161# undef __glibc_safe_or_unknown_len
162# undef __glibc_unlikely
163# undef __glibc_unsafe_len
164# undef __glibc_unsigned_or_positive
165# undef __inline
166# undef __ptr_t
167# undef __restrict
168# undef __restrict_arr
169# undef __va_arg_pack
170# undef __va_arg_pack_len
171# undef __warnattr
172# undef __wur
173
174/* Include our copy of glibc <sys/cdefs.h>. */
175# include <cdefs.h>
176
177/* <cdefs.h> __inline is too pessimistic for non-GCC. */
178# undef __inline
179# ifndef HAVE___INLINE
180# if 199901 <= __STDC_VERSION__ || defined inline
181# define __inline inline
182# else
183# define __inline
184# endif
185# endif
186
187#endif /* defined __glibc_likely */
188
189
190/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
191#define attribute_hidden
192#define libc_hidden_proto(name)
193#define libc_hidden_def(name)
194#define libc_hidden_weak(name)
195#define libc_hidden_ver(local, name)
196#define strong_alias(name, aliasname)
197#define weak_alias(name, aliasname)
198
199/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
200#define SHLIB_COMPAT(lib, introduced, obsoleted) 0
201#define compat_symbol(lib, local, symbol, version) extern int dummy
202#define versioned_symbol(lib, local, symbol, version) extern int dummy
diff --git a/gl/limits.in.h b/gl/limits.in.h
new file mode 100644
index 00000000..eaeac472
--- /dev/null
+++ b/gl/limits.in.h
@@ -0,0 +1,131 @@
1/* A GNU-like <limits.h>.
2
3 Copyright 2016-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@
20#endif
21@PRAGMA_COLUMNS@
22
23#if defined _GL_ALREADY_INCLUDING_LIMITS_H
24/* Special invocation convention:
25 On Haiku/x86_64, we have a sequence of nested includes
26 <limits.h> -> <syslimits.h> -> <limits.h>.
27 In this situation, LONG_MAX and INT_MAX are not yet defined,
28 therefore we should not attempt to define LONG_BIT. */
29
30#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
31
32#else
33/* Normal invocation convention. */
34
35#ifndef _@GUARD_PREFIX@_LIMITS_H
36
37# define _GL_ALREADY_INCLUDING_LIMITS_H
38
39/* The include_next requires a split double-inclusion guard. */
40# @INCLUDE_NEXT@ @NEXT_LIMITS_H@
41
42# undef _GL_ALREADY_INCLUDING_LIMITS_H
43
44#ifndef _@GUARD_PREFIX@_LIMITS_H
45#define _@GUARD_PREFIX@_LIMITS_H
46
47#ifndef LLONG_MIN
48# if defined LONG_LONG_MIN /* HP-UX 11.31 */
49# define LLONG_MIN LONG_LONG_MIN
50# elif defined LONGLONG_MIN /* IRIX 6.5 */
51# define LLONG_MIN LONGLONG_MIN
52# elif defined __GNUC__
53# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
54# endif
55#endif
56#ifndef LLONG_MAX
57# if defined LONG_LONG_MAX /* HP-UX 11.31 */
58# define LLONG_MAX LONG_LONG_MAX
59# elif defined LONGLONG_MAX /* IRIX 6.5 */
60# define LLONG_MAX LONGLONG_MAX
61# elif defined __GNUC__
62# define LLONG_MAX __LONG_LONG_MAX__
63# endif
64#endif
65#ifndef ULLONG_MAX
66# if defined ULONG_LONG_MAX /* HP-UX 11.31 */
67# define ULLONG_MAX ULONG_LONG_MAX
68# elif defined ULONGLONG_MAX /* IRIX 6.5 */
69# define ULLONG_MAX ULONGLONG_MAX
70# elif defined __GNUC__
71# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
72# endif
73#endif
74
75/* The number of usable bits in an unsigned or signed integer type
76 with minimum value MIN and maximum value MAX, as an int expression
77 suitable in #if. Cover all known practical hosts. This
78 implementation exploits the fact that MAX is 1 less than a power of
79 2, and merely counts the number of 1 bits in MAX; "COBn" means
80 "count the number of 1 bits in the low-order n bits"). */
81#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
82#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
83#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
84#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
85#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
86#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
87#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
88
89#ifndef WORD_BIT
90/* Assume 'int' is 32 bits wide. */
91# define WORD_BIT 32
92#endif
93#ifndef LONG_BIT
94/* Assume 'long' is 32 or 64 bits wide. */
95# if LONG_MAX == INT_MAX
96# define LONG_BIT 32
97# else
98# define LONG_BIT 64
99# endif
100#endif
101
102/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */
103
104#if (! defined ULLONG_WIDTH \
105 && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \
106 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
107# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
108# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
109# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
110# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
111# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
112# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
113# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
114# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
115# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
116# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
117# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
118#endif
119
120/* Macros specified by C23. */
121
122#if (! defined BOOL_WIDTH \
123 && (defined _GNU_SOURCE \
124 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
125# define BOOL_MAX 1
126# define BOOL_WIDTH 1
127#endif
128
129#endif /* _@GUARD_PREFIX@_LIMITS_H */
130#endif /* _@GUARD_PREFIX@_LIMITS_H */
131#endif
diff --git a/gl/localcharset.c b/gl/localcharset.c
index a225a2ea..7ed9c957 100644
--- a/gl/localcharset.c
+++ b/gl/localcharset.c
@@ -1,19 +1,19 @@
1/* Determine a canonical name for the current locale's character encoding. 1/* Determine a canonical name for the current locale's character encoding.
2 2
3 Copyright (C) 2000-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2000-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Bruno Haible <bruno@clisp.org>. */ 18/* Written by Bruno Haible <bruno@clisp.org>. */
19 19
@@ -22,7 +22,6 @@
22/* Specification. */ 22/* Specification. */
23#include "localcharset.h" 23#include "localcharset.h"
24 24
25#include <fcntl.h>
26#include <stddef.h> 25#include <stddef.h>
27#include <stdio.h> 26#include <stdio.h>
28#include <string.h> 27#include <string.h>
@@ -32,8 +31,9 @@
32# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */ 31# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
33#endif 32#endif
34 33
35#if defined _WIN32 || defined __WIN32__ 34#if defined _WIN32 && !defined __CYGWIN__
36# define WINDOWS_NATIVE 35# define WINDOWS_NATIVE
36# include <locale.h>
37#endif 37#endif
38 38
39#if defined __EMX__ 39#if defined __EMX__
@@ -44,11 +44,10 @@
44#endif 44#endif
45 45
46#if !defined WINDOWS_NATIVE 46#if !defined WINDOWS_NATIVE
47# include <unistd.h>
48# if HAVE_LANGINFO_CODESET 47# if HAVE_LANGINFO_CODESET
49# include <langinfo.h> 48# include <langinfo.h>
50# else 49# else
51# if 0 /* see comment below */ 50# if 0 /* see comment regarding use of setlocale(), below */
52# include <locale.h> 51# include <locale.h>
53# endif 52# endif
54# endif 53# endif
@@ -59,6 +58,9 @@
59#elif defined WINDOWS_NATIVE 58#elif defined WINDOWS_NATIVE
60# define WIN32_LEAN_AND_MEAN 59# define WIN32_LEAN_AND_MEAN
61# include <windows.h> 60# include <windows.h>
61 /* For the use of setlocale() below, the Gnulib override in setlocale.c is
62 not needed; see the platform lists in setlocale_null.m4. */
63# undef setlocale
62#endif 64#endif
63#if defined OS2 65#if defined OS2
64# define INCL_DOS 66# define INCL_DOS
@@ -70,288 +72,755 @@
70# include <xlocale.h> 72# include <xlocale.h>
71#endif 73#endif
72 74
73#if ENABLE_RELOCATABLE
74# include "relocatable.h"
75#else
76# define relocate(pathname) (pathname)
77#endif
78 75
79/* Get LIBDIR. */ 76#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
80#ifndef LIBDIR
81# include "configmake.h"
82#endif
83
84/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */
85#ifndef O_NOFOLLOW
86# define O_NOFOLLOW 0
87#endif
88
89#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
90 /* Native Windows, Cygwin, OS/2, DOS */
91# define ISSLASH(C) ((C) == '/' || (C) == '\\')
92#endif
93
94#ifndef DIRECTORY_SEPARATOR
95# define DIRECTORY_SEPARATOR '/'
96#endif
97 77
98#ifndef ISSLASH 78/* On these platforms, we use a mapping from non-canonical encoding name
99# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) 79 to GNU canonical encoding name. */
100#endif
101 80
102#if HAVE_DECL_GETC_UNLOCKED 81/* With glibc-2.1 or newer, we don't need any canonicalization,
103# undef getc 82 because glibc has iconv and both glibc and libiconv support all
104# define getc getc_unlocked 83 GNU canonical names directly. */
105#endif 84# if !((defined __GNU_LIBRARY__ && __GLIBC__ >= 2) || defined __UCLIBC__)
106 85
107/* The following static variable is declared 'volatile' to avoid a 86struct table_entry
108 possible multithread problem in the function get_charset_aliases. If we
109 are running in a threaded environment, and if two threads initialize
110 'charset_aliases' simultaneously, both will produce the same value,
111 and everything will be ok if the two assignments to 'charset_aliases'
112 are atomic. But I don't know what will happen if the two assignments mix. */
113#if __STDC__ != 1
114# define volatile /* empty */
115#endif
116/* Pointer to the contents of the charset.alias file, if it has already been
117 read, else NULL. Its format is:
118 ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */
119static const char * volatile charset_aliases;
120
121/* Return a pointer to the contents of the charset.alias file. */
122static const char *
123get_charset_aliases (void)
124{ 87{
125 const char *cp; 88 const char alias[11+1];
126 89 const char canonical[11+1];
127 cp = charset_aliases; 90};
128 if (cp == NULL) 91
129 { 92/* Table of platform-dependent mappings, sorted in ascending order. */
130#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__) 93static const struct table_entry alias_table[] =
131 const char *dir; 94 {
132 const char *base = "charset.alias"; 95# if defined __FreeBSD__ /* FreeBSD */
133 char *file_name; 96 /*{ "ARMSCII-8", "ARMSCII-8" },*/
134 97 { "Big5", "BIG5" },
135 /* Make it possible to override the charset.alias location. This is 98 { "C", "ASCII" },
136 necessary for running the testsuite before "make install". */ 99 /*{ "CP1131", "CP1131" },*/
137 dir = getenv ("CHARSETALIASDIR"); 100 /*{ "CP1251", "CP1251" },*/
138 if (dir == NULL || dir[0] == '\0') 101 /*{ "CP866", "CP866" },*/
139 dir = relocate (LIBDIR); 102 /*{ "GB18030", "GB18030" },*/
140 103 /*{ "GB2312", "GB2312" },*/
141 /* Concatenate dir and base into freshly allocated file_name. */ 104 /*{ "GBK", "GBK" },*/
142 { 105 /*{ "ISCII-DEV", "?" },*/
143 size_t dir_len = strlen (dir); 106 { "ISO8859-1", "ISO-8859-1" },
144 size_t base_len = strlen (base); 107 { "ISO8859-13", "ISO-8859-13" },
145 int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); 108 { "ISO8859-15", "ISO-8859-15" },
146 file_name = (char *) malloc (dir_len + add_slash + base_len + 1); 109 { "ISO8859-2", "ISO-8859-2" },
147 if (file_name != NULL) 110 { "ISO8859-5", "ISO-8859-5" },
148 { 111 { "ISO8859-7", "ISO-8859-7" },
149 memcpy (file_name, dir, dir_len); 112 { "ISO8859-9", "ISO-8859-9" },
150 if (add_slash) 113 /*{ "KOI8-R", "KOI8-R" },*/
151 file_name[dir_len] = DIRECTORY_SEPARATOR; 114 /*{ "KOI8-U", "KOI8-U" },*/
152 memcpy (file_name + dir_len + add_slash, base, base_len + 1); 115 { "SJIS", "SHIFT_JIS" },
153 } 116 { "US-ASCII", "ASCII" },
154 } 117 { "eucCN", "GB2312" },
155 118 { "eucJP", "EUC-JP" },
156 if (file_name == NULL) 119 { "eucKR", "EUC-KR" }
157 /* Out of memory. Treat the file as empty. */ 120# define alias_table_defined
158 cp = ""; 121# endif
159 else 122# if defined __NetBSD__ /* NetBSD */
160 { 123 { "646", "ASCII" },
161 int fd; 124 /*{ "ARMSCII-8", "ARMSCII-8" },*/
162 125 /*{ "BIG5", "BIG5" },*/
163 /* Open the file. Reject symbolic links on platforms that support 126 { "Big5-HKSCS", "BIG5-HKSCS" },
164 O_NOFOLLOW. This is a security feature. Without it, an attacker 127 /*{ "CP1251", "CP1251" },*/
165 could retrieve parts of the contents (namely, the tail of the 128 /*{ "CP866", "CP866" },*/
166 first line that starts with "* ") of an arbitrary file by placing 129 /*{ "GB18030", "GB18030" },*/
167 a symbolic link to that file under the name "charset.alias" in 130 /*{ "GB2312", "GB2312" },*/
168 some writable directory and defining the environment variable 131 { "ISO8859-1", "ISO-8859-1" },
169 CHARSETALIASDIR to point to that directory. */ 132 { "ISO8859-13", "ISO-8859-13" },
170 fd = open (file_name, 133 { "ISO8859-15", "ISO-8859-15" },
171 O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); 134 { "ISO8859-2", "ISO-8859-2" },
172 if (fd < 0) 135 { "ISO8859-4", "ISO-8859-4" },
173 /* File not found. Treat it as empty. */ 136 { "ISO8859-5", "ISO-8859-5" },
174 cp = ""; 137 { "ISO8859-7", "ISO-8859-7" },
175 else 138 /*{ "KOI8-R", "KOI8-R" },*/
176 { 139 /*{ "KOI8-U", "KOI8-U" },*/
177 FILE *fp; 140 /*{ "PT154", "PT154" },*/
178 141 { "SJIS", "SHIFT_JIS" },
179 fp = fdopen (fd, "r"); 142 { "eucCN", "GB2312" },
180 if (fp == NULL) 143 { "eucJP", "EUC-JP" },
181 { 144 { "eucKR", "EUC-KR" },
182 /* Out of memory. Treat the file as empty. */ 145 { "eucTW", "EUC-TW" }
183 close (fd); 146# define alias_table_defined
184 cp = ""; 147# endif
185 } 148# if defined __OpenBSD__ /* OpenBSD */
186 else 149 { "646", "ASCII" },
187 { 150 { "ISO8859-1", "ISO-8859-1" },
188 /* Parse the file's contents. */ 151 { "ISO8859-13", "ISO-8859-13" },
189 char *res_ptr = NULL; 152 { "ISO8859-15", "ISO-8859-15" },
190 size_t res_size = 0; 153 { "ISO8859-2", "ISO-8859-2" },
191 154 { "ISO8859-4", "ISO-8859-4" },
192 for (;;) 155 { "ISO8859-5", "ISO-8859-5" },
193 { 156 { "ISO8859-7", "ISO-8859-7" },
194 int c; 157 { "US-ASCII", "ASCII" }
195 char buf1[50+1]; 158# define alias_table_defined
196 char buf2[50+1]; 159# endif
197 size_t l1, l2; 160# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
198 char *old_res_ptr; 161 /* Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
199 162 useless:
200 c = getc (fp); 163 - It returns the empty string when LANG is set to a locale of the
201 if (c == EOF) 164 form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
202 break; 165 LC_CTYPE file.
203 if (c == '\n' || c == ' ' || c == '\t') 166 - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
204 continue; 167 the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
205 if (c == '#') 168 - The documentation says:
206 { 169 "... all code that calls BSD system routines should ensure
207 /* Skip comment, to end of line. */ 170 that the const *char parameters of these routines are in UTF-8
208 do 171 encoding. All BSD system functions expect their string
209 c = getc (fp); 172 parameters to be in UTF-8 encoding and nothing else."
210 while (!(c == EOF || c == '\n')); 173 It also says
211 if (c == EOF) 174 "An additional caveat is that string parameters for files,
212 break; 175 paths, and other file-system entities must be in canonical
213 continue; 176 UTF-8. In a canonical UTF-8 Unicode string, all decomposable
214 } 177 characters are decomposed ..."
215 ungetc (c, fp); 178 but this is not true: You can pass non-decomposed UTF-8 strings
216 if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) 179 to file system functions, and it is the OS which will convert
217 break; 180 them to decomposed UTF-8 before accessing the file system.
218 l1 = strlen (buf1); 181 - The Apple Terminal application displays UTF-8 by default.
219 l2 = strlen (buf2); 182 - However, other applications are free to use different encodings:
220 old_res_ptr = res_ptr; 183 - xterm uses ISO-8859-1 by default.
221 if (res_size == 0) 184 - TextEdit uses MacRoman by default.
222 { 185 We prefer UTF-8 over decomposed UTF-8-MAC because one should
223 res_size = l1 + 1 + l2 + 1; 186 minimize the use of decomposed Unicode. Unfortunately, through the
224 res_ptr = (char *) malloc (res_size + 1); 187 Darwin file system, decomposed UTF-8 strings are leaked into user
225 } 188 space nevertheless.
226 else 189 Then there are also the locales with encodings other than US-ASCII
227 { 190 and UTF-8. These locales can be occasionally useful to users (e.g.
228 res_size += l1 + 1 + l2 + 1; 191 when grepping through ISO-8859-1 encoded text files), when all their
229 res_ptr = (char *) realloc (res_ptr, res_size + 1); 192 file names are in US-ASCII.
230 } 193 */
231 if (res_ptr == NULL) 194 { "ARMSCII-8", "ARMSCII-8" },
232 { 195 { "Big5", "BIG5" },
233 /* Out of memory. */ 196 { "Big5HKSCS", "BIG5-HKSCS" },
234 res_size = 0; 197 { "CP1131", "CP1131" },
235 free (old_res_ptr); 198 { "CP1251", "CP1251" },
236 break; 199 { "CP866", "CP866" },
237 } 200 { "CP949", "CP949" },
238 strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); 201 { "GB18030", "GB18030" },
239 strcpy (res_ptr + res_size - (l2 + 1), buf2); 202 { "GB2312", "GB2312" },
240 } 203 { "GBK", "GBK" },
241 fclose (fp); 204 /*{ "ISCII-DEV", "?" },*/
242 if (res_size == 0) 205 { "ISO8859-1", "ISO-8859-1" },
243 cp = ""; 206 { "ISO8859-13", "ISO-8859-13" },
244 else 207 { "ISO8859-15", "ISO-8859-15" },
245 { 208 { "ISO8859-2", "ISO-8859-2" },
246 *(res_ptr + res_size) = '\0'; 209 { "ISO8859-4", "ISO-8859-4" },
247 cp = res_ptr; 210 { "ISO8859-5", "ISO-8859-5" },
248 } 211 { "ISO8859-7", "ISO-8859-7" },
249 } 212 { "ISO8859-9", "ISO-8859-9" },
250 } 213 { "KOI8-R", "KOI8-R" },
214 { "KOI8-U", "KOI8-U" },
215 { "PT154", "PT154" },
216 { "SJIS", "SHIFT_JIS" },
217 { "eucCN", "GB2312" },
218 { "eucJP", "EUC-JP" },
219 { "eucKR", "EUC-KR" }
220# define alias_table_defined
221# endif
222# if defined _AIX /* AIX */
223 /*{ "GBK", "GBK" },*/
224 { "IBM-1046", "CP1046" },
225 { "IBM-1124", "CP1124" },
226 { "IBM-1129", "CP1129" },
227 { "IBM-1252", "CP1252" },
228 { "IBM-850", "CP850" },
229 { "IBM-856", "CP856" },
230 { "IBM-921", "ISO-8859-13" },
231 { "IBM-922", "CP922" },
232 { "IBM-932", "CP932" },
233 { "IBM-943", "CP943" },
234 { "IBM-eucCN", "GB2312" },
235 { "IBM-eucJP", "EUC-JP" },
236 { "IBM-eucKR", "EUC-KR" },
237 { "IBM-eucTW", "EUC-TW" },
238 { "ISO8859-1", "ISO-8859-1" },
239 { "ISO8859-15", "ISO-8859-15" },
240 { "ISO8859-2", "ISO-8859-2" },
241 { "ISO8859-5", "ISO-8859-5" },
242 { "ISO8859-6", "ISO-8859-6" },
243 { "ISO8859-7", "ISO-8859-7" },
244 { "ISO8859-8", "ISO-8859-8" },
245 { "ISO8859-9", "ISO-8859-9" },
246 { "TIS-620", "TIS-620" },
247 /*{ "UTF-8", "UTF-8" },*/
248 { "big5", "BIG5" }
249# define alias_table_defined
250# endif
251# if defined __hpux /* HP-UX */
252 { "SJIS", "SHIFT_JIS" },
253 { "arabic8", "HP-ARABIC8" },
254 { "big5", "BIG5" },
255 { "cp1251", "CP1251" },
256 { "eucJP", "EUC-JP" },
257 { "eucKR", "EUC-KR" },
258 { "eucTW", "EUC-TW" },
259 { "gb18030", "GB18030" },
260 { "greek8", "HP-GREEK8" },
261 { "hebrew8", "HP-HEBREW8" },
262 { "hkbig5", "BIG5-HKSCS" },
263 { "hp15CN", "GB2312" },
264 { "iso88591", "ISO-8859-1" },
265 { "iso885913", "ISO-8859-13" },
266 { "iso885915", "ISO-8859-15" },
267 { "iso88592", "ISO-8859-2" },
268 { "iso88594", "ISO-8859-4" },
269 { "iso88595", "ISO-8859-5" },
270 { "iso88596", "ISO-8859-6" },
271 { "iso88597", "ISO-8859-7" },
272 { "iso88598", "ISO-8859-8" },
273 { "iso88599", "ISO-8859-9" },
274 { "kana8", "HP-KANA8" },
275 { "koi8r", "KOI8-R" },
276 { "roman8", "HP-ROMAN8" },
277 { "tis620", "TIS-620" },
278 { "turkish8", "HP-TURKISH8" },
279 { "utf8", "UTF-8" }
280# define alias_table_defined
281# endif
282# if defined __sgi /* IRIX */
283 { "ISO8859-1", "ISO-8859-1" },
284 { "ISO8859-15", "ISO-8859-15" },
285 { "ISO8859-2", "ISO-8859-2" },
286 { "ISO8859-5", "ISO-8859-5" },
287 { "ISO8859-7", "ISO-8859-7" },
288 { "ISO8859-9", "ISO-8859-9" },
289 { "eucCN", "GB2312" },
290 { "eucJP", "EUC-JP" },
291 { "eucKR", "EUC-KR" },
292 { "eucTW", "EUC-TW" }
293# define alias_table_defined
294# endif
295# if defined __osf__ /* OSF/1 */
296 /*{ "GBK", "GBK" },*/
297 { "ISO8859-1", "ISO-8859-1" },
298 { "ISO8859-15", "ISO-8859-15" },
299 { "ISO8859-2", "ISO-8859-2" },
300 { "ISO8859-4", "ISO-8859-4" },
301 { "ISO8859-5", "ISO-8859-5" },
302 { "ISO8859-7", "ISO-8859-7" },
303 { "ISO8859-8", "ISO-8859-8" },
304 { "ISO8859-9", "ISO-8859-9" },
305 { "KSC5601", "CP949" },
306 { "SJIS", "SHIFT_JIS" },
307 { "TACTIS", "TIS-620" },
308 /*{ "UTF-8", "UTF-8" },*/
309 { "big5", "BIG5" },
310 { "cp850", "CP850" },
311 { "dechanyu", "DEC-HANYU" },
312 { "dechanzi", "GB2312" },
313 { "deckanji", "DEC-KANJI" },
314 { "deckorean", "EUC-KR" },
315 { "eucJP", "EUC-JP" },
316 { "eucKR", "EUC-KR" },
317 { "eucTW", "EUC-TW" },
318 { "sdeckanji", "EUC-JP" }
319# define alias_table_defined
320# endif
321# if defined __sun /* Solaris */
322 { "5601", "EUC-KR" },
323 { "646", "ASCII" },
324 /*{ "BIG5", "BIG5" },*/
325 { "Big5-HKSCS", "BIG5-HKSCS" },
326 { "GB18030", "GB18030" },
327 /*{ "GBK", "GBK" },*/
328 { "ISO8859-1", "ISO-8859-1" },
329 { "ISO8859-11", "TIS-620" },
330 { "ISO8859-13", "ISO-8859-13" },
331 { "ISO8859-15", "ISO-8859-15" },
332 { "ISO8859-2", "ISO-8859-2" },
333 { "ISO8859-3", "ISO-8859-3" },
334 { "ISO8859-4", "ISO-8859-4" },
335 { "ISO8859-5", "ISO-8859-5" },
336 { "ISO8859-6", "ISO-8859-6" },
337 { "ISO8859-7", "ISO-8859-7" },
338 { "ISO8859-8", "ISO-8859-8" },
339 { "ISO8859-9", "ISO-8859-9" },
340 { "PCK", "SHIFT_JIS" },
341 { "TIS620.2533", "TIS-620" },
342 /*{ "UTF-8", "UTF-8" },*/
343 { "ansi-1251", "CP1251" },
344 { "cns11643", "EUC-TW" },
345 { "eucJP", "EUC-JP" },
346 { "gb2312", "GB2312" },
347 { "koi8-r", "KOI8-R" }
348# define alias_table_defined
349# endif
350# if defined __minix /* Minix */
351 { "646", "ASCII" }
352# define alias_table_defined
353# endif
354# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Windows */
355 { "CP1361", "JOHAB" },
356 { "CP20127", "ASCII" },
357 { "CP20866", "KOI8-R" },
358 { "CP20936", "GB2312" },
359 { "CP21866", "KOI8-RU" },
360 { "CP28591", "ISO-8859-1" },
361 { "CP28592", "ISO-8859-2" },
362 { "CP28593", "ISO-8859-3" },
363 { "CP28594", "ISO-8859-4" },
364 { "CP28595", "ISO-8859-5" },
365 { "CP28596", "ISO-8859-6" },
366 { "CP28597", "ISO-8859-7" },
367 { "CP28598", "ISO-8859-8" },
368 { "CP28599", "ISO-8859-9" },
369 { "CP28605", "ISO-8859-15" },
370 { "CP38598", "ISO-8859-8" },
371 { "CP51932", "EUC-JP" },
372 { "CP51936", "GB2312" },
373 { "CP51949", "EUC-KR" },
374 { "CP51950", "EUC-TW" },
375 { "CP54936", "GB18030" },
376 { "CP65001", "UTF-8" },
377 { "CP936", "GBK" }
378# define alias_table_defined
379# endif
380# if defined OS2 /* OS/2 */
381 /* The list of encodings is taken from "List of OS/2 Codepages"
382 by Alex Taylor:
383 <http://altsan.org/os2/toolkits/uls/index.html#codepages>.
384 See also "__convcp() of kLIBC":
385 <https://github.com/bitwiseworks/libc/blob/master/src/emx/src/lib/locale/__convcp.c>. */
386 { "CP1004", "CP1252" },
387 /*{ "CP1041", "CP943" },*/
388 /*{ "CP1088", "CP949" },*/
389 { "CP1089", "ISO-8859-6" },
390 /*{ "CP1114", "CP950" },*/
391 /*{ "CP1115", "GB2312" },*/
392 { "CP1208", "UTF-8" },
393 /*{ "CP1380", "GB2312" },*/
394 { "CP1381", "GB2312" },
395 { "CP1383", "GB2312" },
396 { "CP1386", "GBK" },
397 /*{ "CP301", "CP943" },*/
398 { "CP3372", "EUC-JP" },
399 { "CP4946", "CP850" },
400 /*{ "CP5048", "JIS_X0208-1990" },*/
401 /*{ "CP5049", "JIS_X0212-1990" },*/
402 /*{ "CP5067", "KS_C_5601-1987" },*/
403 { "CP813", "ISO-8859-7" },
404 { "CP819", "ISO-8859-1" },
405 { "CP878", "KOI8-R" },
406 /*{ "CP897", "CP943" },*/
407 { "CP912", "ISO-8859-2" },
408 { "CP913", "ISO-8859-3" },
409 { "CP914", "ISO-8859-4" },
410 { "CP915", "ISO-8859-5" },
411 { "CP916", "ISO-8859-8" },
412 { "CP920", "ISO-8859-9" },
413 { "CP921", "ISO-8859-13" },
414 { "CP923", "ISO-8859-15" },
415 /*{ "CP941", "CP943" },*/
416 /*{ "CP947", "CP950" },*/
417 /*{ "CP951", "CP949" },*/
418 /*{ "CP952", "JIS_X0208-1990" },*/
419 /*{ "CP953", "JIS_X0212-1990" },*/
420 { "CP954", "EUC-JP" },
421 { "CP964", "EUC-TW" },
422 { "CP970", "EUC-KR" },
423 /*{ "CP971", "KS_C_5601-1987" },*/
424 { "IBM-1004", "CP1252" },
425 /*{ "IBM-1006", "?" },*/
426 /*{ "IBM-1008", "?" },*/
427 /*{ "IBM-1041", "CP943" },*/
428 /*{ "IBM-1051", "?" },*/
429 /*{ "IBM-1088", "CP949" },*/
430 { "IBM-1089", "ISO-8859-6" },
431 /*{ "IBM-1098", "?" },*/
432 /*{ "IBM-1114", "CP950" },*/
433 /*{ "IBM-1115", "GB2312" },*/
434 /*{ "IBM-1116", "?" },*/
435 /*{ "IBM-1117", "?" },*/
436 /*{ "IBM-1118", "?" },*/
437 /*{ "IBM-1119", "?" },*/
438 { "IBM-1124", "CP1124" },
439 { "IBM-1125", "CP1125" },
440 { "IBM-1131", "CP1131" },
441 { "IBM-1208", "UTF-8" },
442 { "IBM-1250", "CP1250" },
443 { "IBM-1251", "CP1251" },
444 { "IBM-1252", "CP1252" },
445 { "IBM-1253", "CP1253" },
446 { "IBM-1254", "CP1254" },
447 { "IBM-1255", "CP1255" },
448 { "IBM-1256", "CP1256" },
449 { "IBM-1257", "CP1257" },
450 /*{ "IBM-1275", "?" },*/
451 /*{ "IBM-1276", "?" },*/
452 /*{ "IBM-1277", "?" },*/
453 /*{ "IBM-1280", "?" },*/
454 /*{ "IBM-1281", "?" },*/
455 /*{ "IBM-1282", "?" },*/
456 /*{ "IBM-1283", "?" },*/
457 /*{ "IBM-1380", "GB2312" },*/
458 { "IBM-1381", "GB2312" },
459 { "IBM-1383", "GB2312" },
460 { "IBM-1386", "GBK" },
461 /*{ "IBM-301", "CP943" },*/
462 { "IBM-3372", "EUC-JP" },
463 { "IBM-367", "ASCII" },
464 { "IBM-437", "CP437" },
465 { "IBM-4946", "CP850" },
466 /*{ "IBM-5048", "JIS_X0208-1990" },*/
467 /*{ "IBM-5049", "JIS_X0212-1990" },*/
468 /*{ "IBM-5067", "KS_C_5601-1987" },*/
469 { "IBM-813", "ISO-8859-7" },
470 { "IBM-819", "ISO-8859-1" },
471 { "IBM-850", "CP850" },
472 /*{ "IBM-851", "?" },*/
473 { "IBM-852", "CP852" },
474 { "IBM-855", "CP855" },
475 { "IBM-856", "CP856" },
476 { "IBM-857", "CP857" },
477 /*{ "IBM-859", "?" },*/
478 { "IBM-860", "CP860" },
479 { "IBM-861", "CP861" },
480 { "IBM-862", "CP862" },
481 { "IBM-863", "CP863" },
482 { "IBM-864", "CP864" },
483 { "IBM-865", "CP865" },
484 { "IBM-866", "CP866" },
485 /*{ "IBM-868", "?" },*/
486 { "IBM-869", "CP869" },
487 { "IBM-874", "CP874" },
488 { "IBM-878", "KOI8-R" },
489 /*{ "IBM-895", "?" },*/
490 /*{ "IBM-897", "CP943" },*/
491 /*{ "IBM-907", "?" },*/
492 /*{ "IBM-909", "?" },*/
493 { "IBM-912", "ISO-8859-2" },
494 { "IBM-913", "ISO-8859-3" },
495 { "IBM-914", "ISO-8859-4" },
496 { "IBM-915", "ISO-8859-5" },
497 { "IBM-916", "ISO-8859-8" },
498 { "IBM-920", "ISO-8859-9" },
499 { "IBM-921", "ISO-8859-13" },
500 { "IBM-922", "CP922" },
501 { "IBM-923", "ISO-8859-15" },
502 { "IBM-932", "CP932" },
503 /*{ "IBM-941", "CP943" },*/
504 /*{ "IBM-942", "?" },*/
505 { "IBM-943", "CP943" },
506 /*{ "IBM-947", "CP950" },*/
507 { "IBM-949", "CP949" },
508 { "IBM-950", "CP950" },
509 /*{ "IBM-951", "CP949" },*/
510 /*{ "IBM-952", "JIS_X0208-1990" },*/
511 /*{ "IBM-953", "JIS_X0212-1990" },*/
512 { "IBM-954", "EUC-JP" },
513 /*{ "IBM-955", "?" },*/
514 { "IBM-964", "EUC-TW" },
515 { "IBM-970", "EUC-KR" },
516 /*{ "IBM-971", "KS_C_5601-1987" },*/
517 { "IBM-eucCN", "GB2312" },
518 { "IBM-eucJP", "EUC-JP" },
519 { "IBM-eucKR", "EUC-KR" },
520 { "IBM-eucTW", "EUC-TW" },
521 { "IBM33722", "EUC-JP" },
522 { "ISO8859-1", "ISO-8859-1" },
523 { "ISO8859-2", "ISO-8859-2" },
524 { "ISO8859-3", "ISO-8859-3" },
525 { "ISO8859-4", "ISO-8859-4" },
526 { "ISO8859-5", "ISO-8859-5" },
527 { "ISO8859-6", "ISO-8859-6" },
528 { "ISO8859-7", "ISO-8859-7" },
529 { "ISO8859-8", "ISO-8859-8" },
530 { "ISO8859-9", "ISO-8859-9" },
531 /*{ "JISX0201-1976", "JISX0201-1976" },*/
532 /*{ "JISX0208-1978", "?" },*/
533 /*{ "JISX0208-1983", "JIS_X0208-1983" },*/
534 /*{ "JISX0208-1990", "JIS_X0208-1990" },*/
535 /*{ "JISX0212-1990", "JIS_X0212-1990" },*/
536 /*{ "KSC5601-1987", "KS_C_5601-1987" },*/
537 { "SJIS-1", "CP943" },
538 { "SJIS-2", "CP943" },
539 { "eucJP", "EUC-JP" },
540 { "eucKR", "EUC-KR" },
541 { "eucTW-1993", "EUC-TW" }
542# define alias_table_defined
543# endif
544# if defined VMS /* OpenVMS */
545 /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
546 "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
547 section 10.7 "Handling Different Character Sets". */
548 { "DECHANYU", "DEC-HANYU" },
549 { "DECHANZI", "GB2312" },
550 { "DECKANJI", "DEC-KANJI" },
551 { "DECKOREAN", "EUC-KR" },
552 { "ISO8859-1", "ISO-8859-1" },
553 { "ISO8859-2", "ISO-8859-2" },
554 { "ISO8859-5", "ISO-8859-5" },
555 { "ISO8859-7", "ISO-8859-7" },
556 { "ISO8859-8", "ISO-8859-8" },
557 { "ISO8859-9", "ISO-8859-9" },
558 { "SDECKANJI", "EUC-JP" },
559 { "SJIS", "SHIFT_JIS" },
560 { "eucJP", "EUC-JP" },
561 { "eucTW", "EUC-TW" }
562# define alias_table_defined
563# endif
564# ifndef alias_table_defined
565 /* Just a dummy entry, to avoid a C syntax error. */
566 { "", "" }
567# endif
568 };
251 569
252 free (file_name); 570# endif
253 }
254 571
255#else 572#else
256 573
257# if defined DARWIN7 574/* On these platforms, we use a mapping from locale name to GNU canonical
258 /* To avoid the trouble of installing a file that is shared by many 575 encoding name. */
259 GNU packages -- many packaging systems have problems with this --,
260 simply inline the aliases here. */
261 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
262 "ISO8859-2" "\0" "ISO-8859-2" "\0"
263 "ISO8859-4" "\0" "ISO-8859-4" "\0"
264 "ISO8859-5" "\0" "ISO-8859-5" "\0"
265 "ISO8859-7" "\0" "ISO-8859-7" "\0"
266 "ISO8859-9" "\0" "ISO-8859-9" "\0"
267 "ISO8859-13" "\0" "ISO-8859-13" "\0"
268 "ISO8859-15" "\0" "ISO-8859-15" "\0"
269 "KOI8-R" "\0" "KOI8-R" "\0"
270 "KOI8-U" "\0" "KOI8-U" "\0"
271 "CP866" "\0" "CP866" "\0"
272 "CP949" "\0" "CP949" "\0"
273 "CP1131" "\0" "CP1131" "\0"
274 "CP1251" "\0" "CP1251" "\0"
275 "eucCN" "\0" "GB2312" "\0"
276 "GB2312" "\0" "GB2312" "\0"
277 "eucJP" "\0" "EUC-JP" "\0"
278 "eucKR" "\0" "EUC-KR" "\0"
279 "Big5" "\0" "BIG5" "\0"
280 "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
281 "GBK" "\0" "GBK" "\0"
282 "GB18030" "\0" "GB18030" "\0"
283 "SJIS" "\0" "SHIFT_JIS" "\0"
284 "ARMSCII-8" "\0" "ARMSCII-8" "\0"
285 "PT154" "\0" "PT154" "\0"
286 /*"ISCII-DEV" "\0" "?" "\0"*/
287 "*" "\0" "UTF-8" "\0";
288# endif
289 576
290# if defined VMS 577struct table_entry
291 /* To avoid the troubles of an extra file charset.alias_vms in the 578{
292 sources of many GNU packages, simply inline the aliases here. */ 579 const char locale[17+1];
293 /* The list of encodings is taken from the OpenVMS 7.3-1 documentation 580 const char canonical[11+1];
294 "Compaq C Run-Time Library Reference Manual for OpenVMS systems" 581};
295 section 10.7 "Handling Different Character Sets". */ 582
296 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" 583/* Table of platform-dependent mappings, sorted in ascending order. */
297 "ISO8859-2" "\0" "ISO-8859-2" "\0" 584static const struct table_entry locale_table[] =
298 "ISO8859-5" "\0" "ISO-8859-5" "\0" 585 {
299 "ISO8859-7" "\0" "ISO-8859-7" "\0" 586# if defined __FreeBSD__ /* FreeBSD 4.2 */
300 "ISO8859-8" "\0" "ISO-8859-8" "\0" 587 { "cs_CZ.ISO_8859-2", "ISO-8859-2" },
301 "ISO8859-9" "\0" "ISO-8859-9" "\0" 588 { "da_DK.DIS_8859-15", "ISO-8859-15" },
302 /* Japanese */ 589 { "da_DK.ISO_8859-1", "ISO-8859-1" },
303 "eucJP" "\0" "EUC-JP" "\0" 590 { "de_AT.DIS_8859-15", "ISO-8859-15" },
304 "SJIS" "\0" "SHIFT_JIS" "\0" 591 { "de_AT.ISO_8859-1", "ISO-8859-1" },
305 "DECKANJI" "\0" "DEC-KANJI" "\0" 592 { "de_CH.DIS_8859-15", "ISO-8859-15" },
306 "SDECKANJI" "\0" "EUC-JP" "\0" 593 { "de_CH.ISO_8859-1", "ISO-8859-1" },
307 /* Chinese */ 594 { "de_DE.DIS_8859-15", "ISO-8859-15" },
308 "eucTW" "\0" "EUC-TW" "\0" 595 { "de_DE.ISO_8859-1", "ISO-8859-1" },
309 "DECHANYU" "\0" "DEC-HANYU" "\0" 596 { "en_AU.DIS_8859-15", "ISO-8859-15" },
310 "DECHANZI" "\0" "GB2312" "\0" 597 { "en_AU.ISO_8859-1", "ISO-8859-1" },
311 /* Korean */ 598 { "en_CA.DIS_8859-15", "ISO-8859-15" },
312 "DECKOREAN" "\0" "EUC-KR" "\0"; 599 { "en_CA.ISO_8859-1", "ISO-8859-1" },
600 { "en_GB.DIS_8859-15", "ISO-8859-15" },
601 { "en_GB.ISO_8859-1", "ISO-8859-1" },
602 { "en_US.DIS_8859-15", "ISO-8859-15" },
603 { "en_US.ISO_8859-1", "ISO-8859-1" },
604 { "es_ES.DIS_8859-15", "ISO-8859-15" },
605 { "es_ES.ISO_8859-1", "ISO-8859-1" },
606 { "fi_FI.DIS_8859-15", "ISO-8859-15" },
607 { "fi_FI.ISO_8859-1", "ISO-8859-1" },
608 { "fr_BE.DIS_8859-15", "ISO-8859-15" },
609 { "fr_BE.ISO_8859-1", "ISO-8859-1" },
610 { "fr_CA.DIS_8859-15", "ISO-8859-15" },
611 { "fr_CA.ISO_8859-1", "ISO-8859-1" },
612 { "fr_CH.DIS_8859-15", "ISO-8859-15" },
613 { "fr_CH.ISO_8859-1", "ISO-8859-1" },
614 { "fr_FR.DIS_8859-15", "ISO-8859-15" },
615 { "fr_FR.ISO_8859-1", "ISO-8859-1" },
616 { "hr_HR.ISO_8859-2", "ISO-8859-2" },
617 { "hu_HU.ISO_8859-2", "ISO-8859-2" },
618 { "is_IS.DIS_8859-15", "ISO-8859-15" },
619 { "is_IS.ISO_8859-1", "ISO-8859-1" },
620 { "it_CH.DIS_8859-15", "ISO-8859-15" },
621 { "it_CH.ISO_8859-1", "ISO-8859-1" },
622 { "it_IT.DIS_8859-15", "ISO-8859-15" },
623 { "it_IT.ISO_8859-1", "ISO-8859-1" },
624 { "ja_JP.EUC", "EUC-JP" },
625 { "ja_JP.SJIS", "SHIFT_JIS" },
626 { "ja_JP.Shift_JIS", "SHIFT_JIS" },
627 { "ko_KR.EUC", "EUC-KR" },
628 { "la_LN.ASCII", "ASCII" },
629 { "la_LN.DIS_8859-15", "ISO-8859-15" },
630 { "la_LN.ISO_8859-1", "ISO-8859-1" },
631 { "la_LN.ISO_8859-2", "ISO-8859-2" },
632 { "la_LN.ISO_8859-4", "ISO-8859-4" },
633 { "lt_LN.ASCII", "ASCII" },
634 { "lt_LN.DIS_8859-15", "ISO-8859-15" },
635 { "lt_LN.ISO_8859-1", "ISO-8859-1" },
636 { "lt_LN.ISO_8859-2", "ISO-8859-2" },
637 { "lt_LT.ISO_8859-4", "ISO-8859-4" },
638 { "nl_BE.DIS_8859-15", "ISO-8859-15" },
639 { "nl_BE.ISO_8859-1", "ISO-8859-1" },
640 { "nl_NL.DIS_8859-15", "ISO-8859-15" },
641 { "nl_NL.ISO_8859-1", "ISO-8859-1" },
642 { "no_NO.DIS_8859-15", "ISO-8859-15" },
643 { "no_NO.ISO_8859-1", "ISO-8859-1" },
644 { "pl_PL.ISO_8859-2", "ISO-8859-2" },
645 { "pt_PT.DIS_8859-15", "ISO-8859-15" },
646 { "pt_PT.ISO_8859-1", "ISO-8859-1" },
647 { "ru_RU.CP866", "CP866" },
648 { "ru_RU.ISO_8859-5", "ISO-8859-5" },
649 { "ru_RU.KOI8-R", "KOI8-R" },
650 { "ru_SU.CP866", "CP866" },
651 { "ru_SU.ISO_8859-5", "ISO-8859-5" },
652 { "ru_SU.KOI8-R", "KOI8-R" },
653 { "sl_SI.ISO_8859-2", "ISO-8859-2" },
654 { "sv_SE.DIS_8859-15", "ISO-8859-15" },
655 { "sv_SE.ISO_8859-1", "ISO-8859-1" },
656 { "uk_UA.KOI8-U", "KOI8-U" },
657 { "zh_CN.EUC", "GB2312" },
658 { "zh_TW.BIG5", "BIG5" },
659 { "zh_TW.Big5", "BIG5" }
660# define locale_table_defined
313# endif 661# endif
314 662# if defined __DJGPP__ /* DOS / DJGPP 2.03 */
315# if defined WINDOWS_NATIVE || defined __CYGWIN__ 663 /* The encodings given here may not all be correct.
316 /* To avoid the troubles of installing a separate file in the same 664 If you find that the encoding given for your language and
317 directory as the DLL and of retrieving the DLL's directory at 665 country is not the one your DOS machine actually uses, just
318 runtime, simply inline the aliases here. */ 666 correct it in this file, and send a mail to
319 667 Juan Manuel Guerrero <juan.guerrero@gmx.de>
320 cp = "CP936" "\0" "GBK" "\0" 668 and <bug-gnulib@gnu.org>. */
321 "CP1361" "\0" "JOHAB" "\0" 669 { "C", "ASCII" },
322 "CP20127" "\0" "ASCII" "\0" 670 { "ar", "CP864" },
323 "CP20866" "\0" "KOI8-R" "\0" 671 { "ar_AE", "CP864" },
324 "CP20936" "\0" "GB2312" "\0" 672 { "ar_DZ", "CP864" },
325 "CP21866" "\0" "KOI8-RU" "\0" 673 { "ar_EG", "CP864" },
326 "CP28591" "\0" "ISO-8859-1" "\0" 674 { "ar_IQ", "CP864" },
327 "CP28592" "\0" "ISO-8859-2" "\0" 675 { "ar_IR", "CP864" },
328 "CP28593" "\0" "ISO-8859-3" "\0" 676 { "ar_JO", "CP864" },
329 "CP28594" "\0" "ISO-8859-4" "\0" 677 { "ar_KW", "CP864" },
330 "CP28595" "\0" "ISO-8859-5" "\0" 678 { "ar_MA", "CP864" },
331 "CP28596" "\0" "ISO-8859-6" "\0" 679 { "ar_OM", "CP864" },
332 "CP28597" "\0" "ISO-8859-7" "\0" 680 { "ar_QA", "CP864" },
333 "CP28598" "\0" "ISO-8859-8" "\0" 681 { "ar_SA", "CP864" },
334 "CP28599" "\0" "ISO-8859-9" "\0" 682 { "ar_SY", "CP864" },
335 "CP28605" "\0" "ISO-8859-15" "\0" 683 { "be", "CP866" },
336 "CP38598" "\0" "ISO-8859-8" "\0" 684 { "be_BE", "CP866" },
337 "CP51932" "\0" "EUC-JP" "\0" 685 { "bg", "CP866" }, /* not CP855 ?? */
338 "CP51936" "\0" "GB2312" "\0" 686 { "bg_BG", "CP866" }, /* not CP855 ?? */
339 "CP51949" "\0" "EUC-KR" "\0" 687 { "ca", "CP850" },
340 "CP51950" "\0" "EUC-TW" "\0" 688 { "ca_ES", "CP850" },
341 "CP54936" "\0" "GB18030" "\0" 689 { "cs", "CP852" },
342 "CP65001" "\0" "UTF-8" "\0"; 690 { "cs_CZ", "CP852" },
691 { "da", "CP865" }, /* not CP850 ?? */
692 { "da_DK", "CP865" }, /* not CP850 ?? */
693 { "de", "CP850" },
694 { "de_AT", "CP850" },
695 { "de_CH", "CP850" },
696 { "de_DE", "CP850" },
697 { "el", "CP869" },
698 { "el_GR", "CP869" },
699 { "en", "CP850" },
700 { "en_AU", "CP850" }, /* not CP437 ?? */
701 { "en_CA", "CP850" },
702 { "en_GB", "CP850" },
703 { "en_NZ", "CP437" },
704 { "en_US", "CP437" },
705 { "en_ZA", "CP850" }, /* not CP437 ?? */
706 { "eo", "CP850" },
707 { "eo_EO", "CP850" },
708 { "es", "CP850" },
709 { "es_AR", "CP850" },
710 { "es_BO", "CP850" },
711 { "es_CL", "CP850" },
712 { "es_CO", "CP850" },
713 { "es_CR", "CP850" },
714 { "es_CU", "CP850" },
715 { "es_DO", "CP850" },
716 { "es_EC", "CP850" },
717 { "es_ES", "CP850" },
718 { "es_GT", "CP850" },
719 { "es_HN", "CP850" },
720 { "es_MX", "CP850" },
721 { "es_NI", "CP850" },
722 { "es_PA", "CP850" },
723 { "es_PE", "CP850" },
724 { "es_PY", "CP850" },
725 { "es_SV", "CP850" },
726 { "es_UY", "CP850" },
727 { "es_VE", "CP850" },
728 { "et", "CP850" },
729 { "et_EE", "CP850" },
730 { "eu", "CP850" },
731 { "eu_ES", "CP850" },
732 { "fi", "CP850" },
733 { "fi_FI", "CP850" },
734 { "fr", "CP850" },
735 { "fr_BE", "CP850" },
736 { "fr_CA", "CP850" },
737 { "fr_CH", "CP850" },
738 { "fr_FR", "CP850" },
739 { "ga", "CP850" },
740 { "ga_IE", "CP850" },
741 { "gd", "CP850" },
742 { "gd_GB", "CP850" },
743 { "gl", "CP850" },
744 { "gl_ES", "CP850" },
745 { "he", "CP862" },
746 { "he_IL", "CP862" },
747 { "hr", "CP852" },
748 { "hr_HR", "CP852" },
749 { "hu", "CP852" },
750 { "hu_HU", "CP852" },
751 { "id", "CP850" }, /* not CP437 ?? */
752 { "id_ID", "CP850" }, /* not CP437 ?? */
753 { "is", "CP861" }, /* not CP850 ?? */
754 { "is_IS", "CP861" }, /* not CP850 ?? */
755 { "it", "CP850" },
756 { "it_CH", "CP850" },
757 { "it_IT", "CP850" },
758 { "ja", "CP932" },
759 { "ja_JP", "CP932" },
760 { "kr", "CP949" }, /* not CP934 ?? */
761 { "kr_KR", "CP949" }, /* not CP934 ?? */
762 { "lt", "CP775" },
763 { "lt_LT", "CP775" },
764 { "lv", "CP775" },
765 { "lv_LV", "CP775" },
766 { "mk", "CP866" }, /* not CP855 ?? */
767 { "mk_MK", "CP866" }, /* not CP855 ?? */
768 { "mt", "CP850" },
769 { "mt_MT", "CP850" },
770 { "nb", "CP865" }, /* not CP850 ?? */
771 { "nb_NO", "CP865" }, /* not CP850 ?? */
772 { "nl", "CP850" },
773 { "nl_BE", "CP850" },
774 { "nl_NL", "CP850" },
775 { "nn", "CP865" }, /* not CP850 ?? */
776 { "nn_NO", "CP865" }, /* not CP850 ?? */
777 { "no", "CP865" }, /* not CP850 ?? */
778 { "no_NO", "CP865" }, /* not CP850 ?? */
779 { "pl", "CP852" },
780 { "pl_PL", "CP852" },
781 { "pt", "CP850" },
782 { "pt_BR", "CP850" },
783 { "pt_PT", "CP850" },
784 { "ro", "CP852" },
785 { "ro_RO", "CP852" },
786 { "ru", "CP866" },
787 { "ru_RU", "CP866" },
788 { "sk", "CP852" },
789 { "sk_SK", "CP852" },
790 { "sl", "CP852" },
791 { "sl_SI", "CP852" },
792 { "sq", "CP852" },
793 { "sq_AL", "CP852" },
794 { "sr", "CP852" }, /* CP852 or CP866 or CP855 ?? */
795 { "sr_CS", "CP852" }, /* CP852 or CP866 or CP855 ?? */
796 { "sr_YU", "CP852" }, /* CP852 or CP866 or CP855 ?? */
797 { "sv", "CP850" },
798 { "sv_SE", "CP850" },
799 { "th", "CP874" },
800 { "th_TH", "CP874" },
801 { "tr", "CP857" },
802 { "tr_TR", "CP857" },
803 { "uk", "CP1125" },
804 { "uk_UA", "CP1125" },
805 { "zh_CN", "GBK" },
806 { "zh_TW", "CP950" } /* not CP938 ?? */
807# define locale_table_defined
343# endif 808# endif
344#endif 809# ifndef locale_table_defined
810 /* Just a dummy entry, to avoid a C syntax error. */
811 { "", "" }
812# endif
813 };
345 814
346 charset_aliases = cp; 815#endif
347 }
348 816
349 return cp;
350}
351 817
352/* Determine the current locale's character encoding, and canonicalize it 818/* Determine the current locale's character encoding, and canonicalize it
353 into one of the canonical names listed in config.charset. 819 into one of the canonical names listed below.
354 The result must not be freed; it is statically allocated. 820 The result must not be freed; it is statically allocated. The result
821 becomes invalid when setlocale() is used to change the global locale, or
822 when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
823 is changed; threads in multithreaded programs should not do this.
355 If the canonical name cannot be determined, the result is a non-canonical 824 If the canonical name cannot be determined, the result is a non-canonical
356 name. */ 825 name. */
357 826
@@ -362,9 +831,15 @@ const char *
362locale_charset (void) 831locale_charset (void)
363{ 832{
364 const char *codeset; 833 const char *codeset;
365 const char *aliases;
366 834
367#if !(defined WINDOWS_NATIVE || defined OS2) 835 /* This function must be multithread-safe. To achieve this without using
836 thread-local storage, we use a simple strcpy or memcpy to fill this static
837 buffer. Filling it through, for example, strcpy + strcat would not be
838 guaranteed to leave the buffer's contents intact if another thread is
839 currently accessing it. If necessary, the contents is first assembled in
840 a stack-allocated buffer. */
841
842#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
368 843
369# if HAVE_LANGINFO_CODESET 844# if HAVE_LANGINFO_CODESET
370 845
@@ -378,7 +853,7 @@ locale_charset (void)
378 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) 853 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
379 { 854 {
380 const char *locale; 855 const char *locale;
381 static char buf[2 + 10 + 1]; 856 static char resultbuf[2 + 10 + 1];
382 857
383 locale = getenv ("LC_ALL"); 858 locale = getenv ("LC_ALL");
384 if (locale == NULL || locale[0] == '\0') 859 if (locale == NULL || locale[0] == '\0')
@@ -402,11 +877,12 @@ locale_charset (void)
402 modifier = strchr (dot, '@'); 877 modifier = strchr (dot, '@');
403 if (modifier == NULL) 878 if (modifier == NULL)
404 return dot; 879 return dot;
405 if (modifier - dot < sizeof (buf)) 880 if (modifier - dot < sizeof (resultbuf))
406 { 881 {
407 memcpy (buf, dot, modifier - dot); 882 /* This way of filling resultbuf is multithread-safe. */
408 buf [modifier - dot] = '\0'; 883 memcpy (resultbuf, dot, modifier - dot);
409 return buf; 884 resultbuf [modifier - dot] = '\0';
885 return resultbuf;
410 } 886 }
411 } 887 }
412 } 888 }
@@ -422,62 +898,65 @@ locale_charset (void)
422 converting to GetConsoleOutputCP(). This leads to correct results, 898 converting to GetConsoleOutputCP(). This leads to correct results,
423 except when SetConsoleOutputCP has been called and a raster font is 899 except when SetConsoleOutputCP has been called and a raster font is
424 in use. */ 900 in use. */
425 sprintf (buf, "CP%u", GetACP ()); 901 {
426 codeset = buf; 902 char buf[2 + 10 + 1];
427 }
428# endif
429
430# else
431
432 /* On old systems which lack it, use setlocale or getenv. */
433 const char *locale = NULL;
434 903
435 /* But most old systems don't have a complete set of locales. Some 904 sprintf (buf, "CP%u", GetACP ());
436 (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't 905 strcpy (resultbuf, buf);
437 use setlocale here; it would return "C" when it doesn't support the 906 codeset = resultbuf;
438 locale name the user has set. */ 907 }
439# if 0
440 locale = setlocale (LC_CTYPE, NULL);
441# endif
442 if (locale == NULL || locale[0] == '\0')
443 {
444 locale = getenv ("LC_ALL");
445 if (locale == NULL || locale[0] == '\0')
446 {
447 locale = getenv ("LC_CTYPE");
448 if (locale == NULL || locale[0] == '\0')
449 locale = getenv ("LANG");
450 }
451 } 908 }
909# endif
452 910
453 /* On some old systems, one used to set locale = "iso8859_1". On others, 911 if (codeset == NULL)
454 you set it to "language_COUNTRY.charset". In any case, we resolve it 912 /* The canonical name cannot be determined. */
455 through the charset.alias file. */ 913 codeset = "";
456 codeset = locale;
457 914
458# endif 915# elif defined WINDOWS_NATIVE
459 916
460#elif defined WINDOWS_NATIVE 917 char buf[2 + 10 + 1];
918 static char resultbuf[2 + 10 + 1];
461 919
462 static char buf[2 + 10 + 1]; 920 /* The Windows API has a function returning the locale's codepage as
921 a number, but the value doesn't change according to what the
922 'setlocale' call specified. So we use it as a last resort, in
923 case the string returned by 'setlocale' doesn't specify the
924 codepage. */
925 char *current_locale = setlocale (LC_CTYPE, NULL);
926 char *pdot = strrchr (current_locale, '.');
463 927
464 /* The Windows API has a function returning the locale's codepage as a 928 if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
465 number: GetACP(). 929 sprintf (buf, "CP%s", pdot + 1);
466 When the output goes to a console window, it needs to be provided in 930 else
467 GetOEMCP() encoding if the console is using a raster font, or in 931 {
468 GetConsoleOutputCP() encoding if it is using a TrueType font. 932 /* The Windows API has a function returning the locale's codepage as a
469 But in GUI programs and for output sent to files and pipes, GetACP() 933 number: GetACP().
470 encoding is the best bet. */ 934 When the output goes to a console window, it needs to be provided in
471 sprintf (buf, "CP%u", GetACP ()); 935 GetOEMCP() encoding if the console is using a raster font, or in
472 codeset = buf; 936 GetConsoleOutputCP() encoding if it is using a TrueType font.
937 But in GUI programs and for output sent to files and pipes, GetACP()
938 encoding is the best bet. */
939 sprintf (buf, "CP%u", GetACP ());
940 }
941 /* For a locale name such as "French_France.65001", in Windows 10,
942 setlocale now returns "French_France.utf8" instead. */
943 if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
944 codeset = "UTF-8";
945 else
946 {
947 strcpy (resultbuf, buf);
948 codeset = resultbuf;
949 }
473 950
474#elif defined OS2 951# elif defined OS2
475 952
476 const char *locale; 953 const char *locale;
477 static char buf[2 + 10 + 1]; 954 static char resultbuf[2 + 10 + 1];
478 ULONG cp[3]; 955 ULONG cp[3];
479 ULONG cplen; 956 ULONG cplen;
480 957
958 codeset = NULL;
959
481 /* Allow user to override the codeset, as set in the operating system, 960 /* Allow user to override the codeset, as set in the operating system,
482 with standard language environment variables. */ 961 with standard language environment variables. */
483 locale = getenv ("LC_ALL"); 962 locale = getenv ("LC_ALL");
@@ -501,51 +980,173 @@ locale_charset (void)
501 modifier = strchr (dot, '@'); 980 modifier = strchr (dot, '@');
502 if (modifier == NULL) 981 if (modifier == NULL)
503 return dot; 982 return dot;
504 if (modifier - dot < sizeof (buf)) 983 if (modifier - dot < sizeof (resultbuf))
505 { 984 {
506 memcpy (buf, dot, modifier - dot); 985 /* This way of filling resultbuf is multithread-safe. */
507 buf [modifier - dot] = '\0'; 986 memcpy (resultbuf, dot, modifier - dot);
508 return buf; 987 resultbuf [modifier - dot] = '\0';
988 return resultbuf;
509 } 989 }
510 } 990 }
511 991
512 /* Resolve through the charset.alias file. */ 992 /* For the POSIX locale, don't use the system's codepage. */
513 codeset = locale; 993 if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
994 codeset = "";
514 } 995 }
515 else 996
997 if (codeset == NULL)
516 { 998 {
517 /* OS/2 has a function returning the locale's codepage as a number. */ 999 /* OS/2 has a function returning the locale's codepage as a number. */
518 if (DosQueryCp (sizeof (cp), cp, &cplen)) 1000 if (DosQueryCp (sizeof (cp), cp, &cplen))
519 codeset = ""; 1001 codeset = "";
520 else 1002 else
521 { 1003 {
1004 char buf[2 + 10 + 1];
1005
522 sprintf (buf, "CP%u", cp[0]); 1006 sprintf (buf, "CP%u", cp[0]);
523 codeset = buf; 1007 strcpy (resultbuf, buf);
1008 codeset = resultbuf;
524 } 1009 }
525 } 1010 }
526 1011
527#endif 1012# else
528 1013
529 if (codeset == NULL) 1014# error "Add code for other platforms here."
530 /* The canonical name cannot be determined. */ 1015
531 codeset = ""; 1016# endif
1017
1018 /* Resolve alias. */
1019 {
1020# ifdef alias_table_defined
1021 /* On some platforms, UTF-8 locales are the most frequently used ones.
1022 Speed up the common case and slow down the less common cases by
1023 testing for this case first. */
1024# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__
1025 if (strcmp (codeset, "UTF-8") == 0)
1026 goto done_table_lookup;
1027 else
1028# endif
1029 {
1030 const struct table_entry * const table = alias_table;
1031 size_t const table_size =
1032 sizeof (alias_table) / sizeof (struct table_entry);
1033 /* The table is sorted. Perform a binary search. */
1034 size_t hi = table_size;
1035 size_t lo = 0;
1036 while (lo < hi)
1037 {
1038 /* Invariant:
1039 for i < lo, strcmp (table[i].alias, codeset) < 0,
1040 for i >= hi, strcmp (table[i].alias, codeset) > 0. */
1041 size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
1042 int cmp = strcmp (table[mid].alias, codeset);
1043 if (cmp < 0)
1044 lo = mid + 1;
1045 else if (cmp > 0)
1046 hi = mid;
1047 else
1048 {
1049 /* Found an i with
1050 strcmp (table[i].alias, codeset) == 0. */
1051 codeset = table[mid].canonical;
1052 goto done_table_lookup;
1053 }
1054 }
1055 }
1056 if (0)
1057 done_table_lookup: ;
1058 else
1059# endif
1060 {
1061 /* Did not find it in the table. */
1062 /* On Mac OS X, all modern locales use the UTF-8 encoding.
1063 BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
1064# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
1065 codeset = "UTF-8";
1066# else
1067 /* Don't return an empty string. GNU libc and GNU libiconv interpret
1068 the empty string as denoting "the locale's character encoding",
1069 thus GNU libiconv would call this function a second time. */
1070 if (codeset[0] == '\0')
1071 codeset = "ASCII";
1072# endif
1073 }
1074 }
1075
1076#else
532 1077
533 /* Resolve alias. */ 1078 /* On old systems which lack it, use setlocale or getenv. */
534 for (aliases = get_charset_aliases (); 1079 const char *locale = NULL;
535 *aliases != '\0'; 1080
536 aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) 1081 /* But most old systems don't have a complete set of locales. Some
537 if (strcmp (codeset, aliases) == 0 1082 (like DJGPP) have only the C locale. Therefore we don't use setlocale
538 || (aliases[0] == '*' && aliases[1] == '\0')) 1083 here; it would return "C" when it doesn't support the locale name the
1084 user has set. */
1085# if 0
1086 locale = setlocale (LC_CTYPE, NULL);
1087# endif
1088 if (locale == NULL || locale[0] == '\0')
1089 {
1090 locale = getenv ("LC_ALL");
1091 if (locale == NULL || locale[0] == '\0')
1092 {
1093 locale = getenv ("LC_CTYPE");
1094 if (locale == NULL || locale[0] == '\0')
1095 locale = getenv ("LANG");
1096 if (locale == NULL)
1097 locale = "";
1098 }
1099 }
1100
1101 /* Map locale name to canonical encoding name. */
1102 {
1103# ifdef locale_table_defined
1104 const struct table_entry * const table = locale_table;
1105 size_t const table_size =
1106 sizeof (locale_table) / sizeof (struct table_entry);
1107 /* The table is sorted. Perform a binary search. */
1108 size_t hi = table_size;
1109 size_t lo = 0;
1110 while (lo < hi)
539 { 1111 {
540 codeset = aliases + strlen (aliases) + 1; 1112 /* Invariant:
541 break; 1113 for i < lo, strcmp (table[i].locale, locale) < 0,
1114 for i >= hi, strcmp (table[i].locale, locale) > 0. */
1115 size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
1116 int cmp = strcmp (table[mid].locale, locale);
1117 if (cmp < 0)
1118 lo = mid + 1;
1119 else if (cmp > 0)
1120 hi = mid;
1121 else
1122 {
1123 /* Found an i with
1124 strcmp (table[i].locale, locale) == 0. */
1125 codeset = table[mid].canonical;
1126 goto done_table_lookup;
1127 }
1128 }
1129 if (0)
1130 done_table_lookup: ;
1131 else
1132# endif
1133 {
1134 /* Did not find it in the table. */
1135 /* On Mac OS X, all modern locales use the UTF-8 encoding.
1136 BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
1137# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
1138 codeset = "UTF-8";
1139# else
1140 /* The canonical name cannot be determined. */
1141 /* Don't return an empty string. GNU libc and GNU libiconv interpret
1142 the empty string as denoting "the locale's character encoding",
1143 thus GNU libiconv would call this function a second time. */
1144 codeset = "ASCII";
1145# endif
542 } 1146 }
1147 }
543 1148
544 /* Don't return an empty string. GNU libc and GNU libiconv interpret 1149#endif
545 the empty string as denoting "the locale's character encoding",
546 thus GNU libiconv would call this function a second time. */
547 if (codeset[0] == '\0')
548 codeset = "ASCII";
549 1150
550#ifdef DARWIN7 1151#ifdef DARWIN7
551 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" 1152 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
diff --git a/gl/localcharset.h b/gl/localcharset.h
index c2098298..29ee8dc0 100644
--- a/gl/localcharset.h
+++ b/gl/localcharset.h
@@ -1,19 +1,19 @@
1/* Determine a canonical name for the current locale's character encoding. 1/* Determine a canonical name for the current locale's character encoding.
2 Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2000-2003, 2009-2023 Free Software Foundation, Inc.
3 This file is part of the GNU CHARSET Library. 3 This file is part of the GNU CHARSET Library.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _LOCALCHARSET_H 18#ifndef _LOCALCHARSET_H
19#define _LOCALCHARSET_H 19#define _LOCALCHARSET_H
@@ -25,12 +25,109 @@ extern "C" {
25 25
26 26
27/* Determine the current locale's character encoding, and canonicalize it 27/* Determine the current locale's character encoding, and canonicalize it
28 into one of the canonical names listed in config.charset. 28 into one of the canonical names listed below.
29 The result must not be freed; it is statically allocated. 29 The result must not be freed; it is statically allocated. The result
30 becomes invalid when setlocale() is used to change the global locale, or
31 when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
32 is changed; threads in multithreaded programs should not do this.
30 If the canonical name cannot be determined, the result is a non-canonical 33 If the canonical name cannot be determined, the result is a non-canonical
31 name. */ 34 name. */
32extern const char * locale_charset (void); 35extern const char * locale_charset (void);
33 36
37/* About GNU canonical names for character encodings:
38
39 Every canonical name must be supported by GNU libiconv. Support by GNU libc
40 is also desirable.
41
42 The name is case insensitive. Usually an upper case MIME charset name is
43 preferred.
44
45 The current list of these GNU canonical names is:
46
47 name MIME? used by which systems
48 (darwin = Mac OS X, windows = native Windows)
49
50 ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
51 ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
52 ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
53 ISO-8859-3 Y glibc solaris cygwin
54 ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
55 ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
56 ISO-8859-6 Y glibc aix hpux solaris cygwin
57 ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
58 ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos
59 ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos
60 ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
61 ISO-8859-14 glibc cygwin
62 ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
63 KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
64 KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
65 KOI8-T glibc
66 CP437 dos
67 CP775 dos
68 CP850 aix osf dos
69 CP852 dos
70 CP855 dos
71 CP856 aix
72 CP857 dos
73 CP861 dos
74 CP862 dos
75 CP864 dos
76 CP865 dos
77 CP866 freebsd netbsd openbsd darwin dos
78 CP869 dos
79 CP874 windows dos
80 CP922 aix
81 CP932 aix cygwin windows dos
82 CP943 aix zos
83 CP949 osf darwin windows dos
84 CP950 windows dos
85 CP1046 aix
86 CP1124 aix
87 CP1125 dos
88 CP1129 aix
89 CP1131 freebsd darwin
90 CP1250 windows
91 CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
92 CP1252 aix windows
93 CP1253 windows
94 CP1254 windows
95 CP1255 glibc windows
96 CP1256 windows
97 CP1257 windows
98 GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
99 EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
100 EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
101 EUC-TW glibc aix hpux irix osf solaris netbsd
102 BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
103 BIG5-HKSCS glibc hpux solaris netbsd darwin
104 GBK glibc aix osf solaris freebsd darwin cygwin windows dos
105 GB18030 glibc hpux solaris freebsd netbsd darwin
106 SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
107 JOHAB glibc solaris windows
108 TIS-620 glibc aix hpux osf solaris cygwin zos
109 VISCII Y glibc
110 TCVN5712-1 glibc
111 ARMSCII-8 glibc freebsd netbsd darwin
112 GEORGIAN-PS glibc cygwin
113 PT154 glibc netbsd cygwin
114 HP-ROMAN8 hpux
115 HP-ARABIC8 hpux
116 HP-GREEK8 hpux
117 HP-HEBREW8 hpux
118 HP-TURKISH8 hpux
119 HP-KANA8 hpux
120 DEC-KANJI osf
121 DEC-HANYU osf
122 UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos
123
124 Note: Names which are not marked as being a MIME name should not be used in
125 Internet protocols for information interchange (mail, news, etc.).
126
127 Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
128 must understand both names and treat them as equivalent.
129 */
130
34 131
35#ifdef __cplusplus 132#ifdef __cplusplus
36} 133}
diff --git a/gl/locale.in.h b/gl/locale.in.h
index 264161a6..538b8341 100644
--- a/gl/locale.in.h
+++ b/gl/locale.in.h
@@ -1,28 +1,31 @@
1/* A POSIX <locale.h>. 1/* A POSIX <locale.h>.
2 Copyright (C) 2007-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#if __GNUC__ >= 3 17#if __GNUC__ >= 3
18@PRAGMA_SYSTEM_HEADER@ 18@PRAGMA_SYSTEM_HEADER@
19#endif 19#endif
20@PRAGMA_COLUMNS@ 20@PRAGMA_COLUMNS@
21 21
22#ifdef _GL_ALREADY_INCLUDING_LOCALE_H 22#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
23 || defined _GL_ALREADY_INCLUDING_LOCALE_H
23 24
24/* Special invocation conventions to handle Solaris header files 25/* Special invocation convention:
25 (through Solaris 10) when combined with gettext's libintl.h. */ 26 - Inside mingw header files,
27 - To handle Solaris header files (through Solaris 10) when combined
28 with gettext's libintl.h. */
26 29
27#@INCLUDE_NEXT@ @NEXT_LOCALE_H@ 30#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
28 31
@@ -61,6 +64,18 @@
61# define LC_MESSAGES 1729 64# define LC_MESSAGES 1729
62#endif 65#endif
63 66
67/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
68 int_n_*. Instead of overriding 'struct lconv', merely define these member
69 names as macros. This avoids trouble in C++ mode. */
70#if defined _MSC_VER
71# define int_p_cs_precedes p_cs_precedes
72# define int_p_sign_posn p_sign_posn
73# define int_p_sep_by_space p_sep_by_space
74# define int_n_cs_precedes n_cs_precedes
75# define int_n_sign_posn n_sign_posn
76# define int_n_sep_by_space n_sep_by_space
77#endif
78
64/* Bionic libc's 'struct lconv' is just a dummy. */ 79/* Bionic libc's 'struct lconv' is just a dummy. */
65#if @REPLACE_STRUCT_LCONV@ 80#if @REPLACE_STRUCT_LCONV@
66# define lconv rpl_lconv 81# define lconv rpl_lconv
@@ -69,7 +84,7 @@ struct lconv
69 /* All 'char *' are actually 'const char *'. */ 84 /* All 'char *' are actually 'const char *'. */
70 85
71 /* Members that depend on the LC_NUMERIC category of the locale. See 86 /* Members that depend on the LC_NUMERIC category of the locale. See
72 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */ 87 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
73 88
74 /* Symbol used as decimal point. */ 89 /* Symbol used as decimal point. */
75 char *decimal_point; 90 char *decimal_point;
@@ -81,7 +96,7 @@ struct lconv
81 char *grouping; 96 char *grouping;
82 97
83 /* Members that depend on the LC_MONETARY category of the locale. See 98 /* Members that depend on the LC_MONETARY category of the locale. See
84 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */ 99 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
85 100
86 /* Symbol used as decimal point. */ 101 /* Symbol used as decimal point. */
87 char *mon_decimal_point; 102 char *mon_decimal_point;
@@ -153,7 +168,9 @@ _GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
153# else 168# else
154_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void)); 169_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
155# endif 170# endif
171# if __GLIBC__ >= 2
156_GL_CXXALIASWARN (localeconv); 172_GL_CXXALIASWARN (localeconv);
173# endif
157#elif @REPLACE_STRUCT_LCONV@ 174#elif @REPLACE_STRUCT_LCONV@
158# undef localeconv 175# undef localeconv
159# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv 176# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
@@ -178,7 +195,9 @@ _GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
178# else 195# else
179_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale)); 196_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
180# endif 197# endif
198# if __GLIBC__ >= 2
181_GL_CXXALIASWARN (setlocale); 199_GL_CXXALIASWARN (setlocale);
200# endif
182#elif defined GNULIB_POSIXCHECK 201#elif defined GNULIB_POSIXCHECK
183# undef setlocale 202# undef setlocale
184# if HAVE_RAW_DECL_SETLOCALE 203# if HAVE_RAW_DECL_SETLOCALE
@@ -187,11 +206,50 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
187# endif 206# endif
188#endif 207#endif
189 208
190#if @GNULIB_DUPLOCALE@ 209#if @GNULIB_SETLOCALE_NULL@
210/* Included here for convenience. */
211# include "setlocale_null.h"
212#endif
213
214#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@)
215# if @REPLACE_NEWLOCALE@
216# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
217# undef newlocale
218# define newlocale rpl_newlocale
219# define GNULIB_defined_newlocale 1
220# endif
221_GL_FUNCDECL_RPL (newlocale, locale_t,
222 (int category_mask, const char *name, locale_t base)
223 _GL_ARG_NONNULL ((2)));
224_GL_CXXALIAS_RPL (newlocale, locale_t,
225 (int category_mask, const char *name, locale_t base));
226# else
227# if @HAVE_NEWLOCALE@
228_GL_CXXALIAS_SYS (newlocale, locale_t,
229 (int category_mask, const char *name, locale_t base));
230# endif
231# endif
232# if @HAVE_NEWLOCALE@
233_GL_CXXALIASWARN (newlocale);
234# endif
235# if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
236# ifndef HAVE_WORKING_NEWLOCALE
237# define HAVE_WORKING_NEWLOCALE 1
238# endif
239# endif
240#elif defined GNULIB_POSIXCHECK
241# undef newlocale
242# if HAVE_RAW_DECL_NEWLOCALE
243_GL_WARN_ON_USE (newlocale, "newlocale is not portable");
244# endif
245#endif
246
247#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@)
191# if @REPLACE_DUPLOCALE@ 248# if @REPLACE_DUPLOCALE@
192# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 249# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
193# undef duplocale 250# undef duplocale
194# define duplocale rpl_duplocale 251# define duplocale rpl_duplocale
252# define GNULIB_defined_duplocale 1
195# endif 253# endif
196_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); 254_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
197_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); 255_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
@@ -203,6 +261,11 @@ _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
203# if @HAVE_DUPLOCALE@ 261# if @HAVE_DUPLOCALE@
204_GL_CXXALIASWARN (duplocale); 262_GL_CXXALIASWARN (duplocale);
205# endif 263# endif
264# if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
265# ifndef HAVE_WORKING_DUPLOCALE
266# define HAVE_WORKING_DUPLOCALE 1
267# endif
268# endif
206#elif defined GNULIB_POSIXCHECK 269#elif defined GNULIB_POSIXCHECK
207# undef duplocale 270# undef duplocale
208# if HAVE_RAW_DECL_DUPLOCALE 271# if HAVE_RAW_DECL_DUPLOCALE
@@ -211,6 +274,32 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
211# endif 274# endif
212#endif 275#endif
213 276
277#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@)
278# if @REPLACE_FREELOCALE@
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# undef freelocale
281# define freelocale rpl_freelocale
282# define GNULIB_defined_freelocale 1
283# endif
284_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1)));
285_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
286# else
287# if @HAVE_FREELOCALE@
288/* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
289 int. */
290_GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
291# endif
292# endif
293# if @HAVE_FREELOCALE@
294_GL_CXXALIASWARN (freelocale);
295# endif
296#elif defined GNULIB_POSIXCHECK
297# undef freelocale
298# if HAVE_RAW_DECL_FREELOCALE
299_GL_WARN_ON_USE (freelocale, "freelocale is not portable");
300# endif
301#endif
302
214#endif /* _@GUARD_PREFIX@_LOCALE_H */ 303#endif /* _@GUARD_PREFIX@_LOCALE_H */
215#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */
216#endif /* _@GUARD_PREFIX@_LOCALE_H */ 304#endif /* _@GUARD_PREFIX@_LOCALE_H */
305#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */
diff --git a/gl/localeconv.c b/gl/localeconv.c
index 7c7c77cf..60c050f4 100644
--- a/gl/localeconv.c
+++ b/gl/localeconv.c
@@ -1,18 +1,18 @@
1/* Query locale dependent information for formatting numbers. 1/* Query locale dependent information for formatting numbers.
2 Copyright (C) 2012-2013 Free Software Foundation, Inc. 2 Copyright (C) 2012-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/lseek.c b/gl/lseek.c
new file mode 100644
index 00000000..7919b03c
--- /dev/null
+++ b/gl/lseek.c
@@ -0,0 +1,89 @@
1/* An lseek() function that detects pipes.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <unistd.h>
21
22#if defined _WIN32 && ! defined __CYGWIN__
23/* Windows platforms. */
24/* Get GetFileType. */
25# include <windows.h>
26/* Get _get_osfhandle. */
27# if GNULIB_MSVC_NOTHROW
28# include "msvc-nothrow.h"
29# else
30# include <io.h>
31# endif
32#else
33# include <sys/stat.h>
34#endif
35#include <errno.h>
36
37#undef lseek
38
39off_t
40rpl_lseek (int fd, off_t offset, int whence)
41{
42#if defined _WIN32 && ! defined __CYGWIN__
43 /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
44 HANDLE h = (HANDLE) _get_osfhandle (fd);
45 if (h == INVALID_HANDLE_VALUE)
46 {
47 errno = EBADF;
48 return -1;
49 }
50 if (GetFileType (h) != FILE_TYPE_DISK)
51 {
52 errno = ESPIPE;
53 return -1;
54 }
55#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
56 if (whence == SEEK_DATA)
57 {
58 /* If OFFSET points to data, macOS lseek+SEEK_DATA returns the
59 start S of the first data region that begins *after* OFFSET,
60 where the region from OFFSET to S consists of possibly-empty
61 data followed by a possibly-empty hole. To work around this
62 portability glitch, check whether OFFSET is within data by
63 using lseek+SEEK_HOLE, and if so return to OFFSET by using
64 lseek+SEEK_SET. Also, contrary to the macOS documentation,
65 lseek+SEEK_HOLE can fail with ENXIO if there are no holes on
66 or after OFFSET. What a mess! */
67 off_t next_hole = lseek (fd, offset, SEEK_HOLE);
68 if (next_hole < 0)
69 return errno == ENXIO ? offset : next_hole;
70 if (next_hole != offset)
71 whence = SEEK_SET;
72 }
73#else
74 /* BeOS lseek mistakenly succeeds on pipes... */
75 struct stat statbuf;
76 if (fstat (fd, &statbuf) < 0)
77 return -1;
78 if (!S_ISREG (statbuf.st_mode))
79 {
80 errno = ESPIPE;
81 return -1;
82 }
83#endif
84#if _GL_WINDOWS_64_BIT_OFF_T || (defined __MINGW32__ && defined _FILE_OFFSET_BITS && (_FILE_OFFSET_BITS == 64))
85 return _lseeki64 (fd, offset, whence);
86#else
87 return lseek (fd, offset, whence);
88#endif
89}
diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4
index d4ad759f..7fe03e0b 100644
--- a/gl/m4/00gnulib.m4
+++ b/gl/m4/00gnulib.m4
@@ -1,27 +1,82 @@
1# 00gnulib.m4 serial 2 1# 00gnulib.m4 serial 8
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl This file must be named something that sorts before all other 7dnl This file must be named something that sorts before all other
8dnl gnulib-provided .m4 files. It is needed until such time as we can 8dnl gnulib-provided .m4 files. It is needed until the clang fix has
9dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. 9dnl been included in Autoconf.
10 10
11# AC_DEFUN_ONCE([NAME], VALUE) 11# The following definitions arrange to use a compiler option
12# ---------------------------- 12# -Werror=implicit-function-declaration in AC_CHECK_DECL, when the
13# Define NAME to expand to VALUE on the first use (whether by direct 13# compiler is clang. Without it, clang implicitly declares "known"
14# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. 14# library functions in C mode, but not in C++ mode, which would cause
15# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This 15# Gnulib to omit a declaration and thus later produce an error in C++
16# definition is slower than the version in Autoconf 2.64, because it 16# mode. As of clang 9.0, these "known" functions are identified through
17# can only use interfaces that existed since 2.59; but it achieves the 17# LIBBUILTIN invocations in the LLVM source file
18# same effect. Quoting is necessary to avoid confusing Automake. 18# llvm/tools/clang/include/clang/Basic/Builtins.def.
19m4_version_prereq([2.63.263], [], 19# It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL,
20[m4_define([AC][_DEFUN_ONCE], 20# because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed
21 [AC][_DEFUN([$1], 21# to AC_REQUIRE anything: some configure.ac files have their first
22 [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], 22# AC_CHECK_DECL executed conditionally. Therefore append the extra tests
23 [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl 23# to AC_PROG_CC.
24[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) 24AC_DEFUN([gl_COMPILER_CLANG],
25[
26dnl AC_REQUIRE([AC_PROG_CC])
27 AC_CACHE_CHECK([whether the compiler is clang],
28 [gl_cv_compiler_clang],
29 [dnl Use _AC_COMPILE_IFELSE instead of AC_EGREP_CPP, to avoid error
30 dnl "circular dependency of AC_LANG_COMPILER(C)" if AC_PROG_CC has
31 dnl not yet been invoked.
32 _AC_COMPILE_IFELSE(
33 [AC_LANG_PROGRAM([[
34 #ifdef __clang__
35 barfbarf
36 #endif
37 ]],[[]])
38 ],
39 [gl_cv_compiler_clang=no],
40 [gl_cv_compiler_clang=yes])
41 ])
42])
43AC_DEFUN([gl_COMPILER_PREPARE_CHECK_DECL],
44[
45dnl AC_REQUIRE([AC_PROG_CC])
46dnl AC_REQUIRE([gl_COMPILER_CLANG])
47 AC_CACHE_CHECK([for compiler option needed when checking for declarations],
48 [gl_cv_compiler_check_decl_option],
49 [if test $gl_cv_compiler_clang = yes; then
50 dnl Test whether the compiler supports the option
51 dnl '-Werror=implicit-function-declaration'.
52 save_ac_compile="$ac_compile"
53 ac_compile="$ac_compile -Werror=implicit-function-declaration"
54 dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a
55 dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
56 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
57 [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'],
58 [gl_cv_compiler_check_decl_option=none])
59 ac_compile="$save_ac_compile"
60 else
61 gl_cv_compiler_check_decl_option=none
62 fi
63 ])
64 if test "x$gl_cv_compiler_check_decl_option" != xnone; then
65 ac_compile_for_check_decl="$ac_compile $gl_cv_compiler_check_decl_option"
66 else
67 ac_compile_for_check_decl="$ac_compile"
68 fi
69])
70dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl
71dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC
72dnl in zzgnulib.m4 is inactive, use the original ac_compile.
73m4_define([_AC_CHECK_DECL_BODY],
74[ ac_save_ac_compile="$ac_compile"
75 if test -n "$ac_compile_for_check_decl"; then
76 ac_compile="$ac_compile_for_check_decl"
77 fi]
78m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile"
79])
25 80
26# gl_00GNULIB 81# gl_00GNULIB
27# ----------- 82# -----------
diff --git a/gl/m4/__inline.m4 b/gl/m4/__inline.m4
new file mode 100644
index 00000000..acf8668b
--- /dev/null
+++ b/gl/m4/__inline.m4
@@ -0,0 +1,22 @@
1# Test for __inline keyword
2dnl Copyright 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl___INLINE],
8[
9 AC_CACHE_CHECK([whether the compiler supports the __inline keyword],
10 [gl_cv_c___inline],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_PROGRAM(
13 [[typedef int foo_t;
14 static __inline foo_t foo (void) { return 0; }]],
15 [[return foo ();]])],
16 [gl_cv_c___inline=yes],
17 [gl_cv_c___inline=no])])
18 if test $gl_cv_c___inline = yes; then
19 AC_DEFINE([HAVE___INLINE], [1],
20 [Define to 1 if the compiler supports the keyword '__inline'.])
21 fi
22])
diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4
new file mode 100644
index 00000000..e7947648
--- /dev/null
+++ b/gl/m4/absolute-header.m4
@@ -0,0 +1,100 @@
1# absolute-header.m4 serial 17
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price.
8
9# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
10# ---------------------------------------
11# Find the absolute name of a header file, testing first if the header exists.
12# If the header were sys/inttypes.h, this macro would define
13# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h
14# in config.h
15# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
16# The three "///" are to pacify Sun C 5.8, which otherwise would say
17# "warning: #include of /usr/include/... may be non-portable".
18# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
19# Note: This macro assumes that the header file is not empty after
20# preprocessing, i.e. it does not only define preprocessor macros but also
21# provides some type/enum definitions or function/variable declarations.
22AC_DEFUN([gl_ABSOLUTE_HEADER],
23[AC_REQUIRE([AC_CANONICAL_HOST])
24AC_LANG_PREPROC_REQUIRE()dnl
25m4_foreach_w([gl_HEADER_NAME], [$1],
26 [AS_VAR_PUSHDEF([gl_absolute_header],
27 [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl
28 AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>],
29 [gl_absolute_header],
30 [AS_VAR_PUSHDEF([ac_header_exists],
31 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
32 AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
33 if test AS_VAR_GET([ac_header_exists]) = yes; then
34 gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
35 fi
36 AS_VAR_POPDEF([ac_header_exists])dnl
37 ])dnl
38 AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])),
39 ["AS_VAR_GET([gl_absolute_header])"],
40 [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.])
41 AS_VAR_POPDEF([gl_absolute_header])dnl
42])dnl
43])# gl_ABSOLUTE_HEADER
44
45# gl_ABSOLUTE_HEADER_ONE(HEADER)
46# ------------------------------
47# Like gl_ABSOLUTE_HEADER, except that:
48# - it assumes that the header exists,
49# - it uses the current CPPFLAGS,
50# - it does not cache the result,
51# - it is silent.
52AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
53[
54 AC_REQUIRE([AC_CANONICAL_HOST])
55 AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
56 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
57 dnl that contain only a #include of other header files and no
58 dnl non-comment tokens of their own. This leads to a failure to
59 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
60 dnl and others. The workaround is to force preservation of comments
61 dnl through option -C. This ensures all necessary #line directives
62 dnl are present. GCC supports option -C as well.
63 case "$host_os" in
64 aix*) gl_absname_cpp="$ac_cpp -C" ;;
65 *) gl_absname_cpp="$ac_cpp" ;;
66 esac
67changequote(,)
68 case "$host_os" in
69 mingw*)
70 dnl For the sake of native Windows compilers (excluding gcc),
71 dnl treat backslash as a directory separator, like /.
72 dnl Actually, these compilers use a double-backslash as
73 dnl directory separator, inside the
74 dnl # line "filename"
75 dnl directives.
76 gl_dirsep_regex='[/\\]'
77 ;;
78 *)
79 gl_dirsep_regex='\/'
80 ;;
81 esac
82 dnl A sed expression that turns a string into a basic regular
83 dnl expression, for use within "/.../".
84 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
85 gl_header_literal_regex=`echo '$1' \
86 | sed -e "$gl_make_literal_regex_sed"`
87 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
88 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
89 s|^/[^/]|//&|
90 p
91 q
92 }'
93changequote([,])
94 dnl eval is necessary to expand gl_absname_cpp.
95 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
96 dnl so use subshell.
97 AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
98[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
99 sed -n "$gl_absolute_header_sed"`])
100])
diff --git a/gl/m4/af_alg.m4 b/gl/m4/af_alg.m4
new file mode 100644
index 00000000..f4c0d624
--- /dev/null
+++ b/gl/m4/af_alg.m4
@@ -0,0 +1,57 @@
1# af_alg.m4 serial 6
2dnl Copyright 2018-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Matteo Croce.
8
9AC_DEFUN_ONCE([gl_AF_ALG],
10[
11 AC_REQUIRE([gl_SYS_SOCKET_H])
12 AC_REQUIRE([AC_C_INLINE])
13
14 dnl Check whether linux/if_alg.h has needed features.
15 AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
16 [gl_cv_header_linux_if_alg_salg],
17 [AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM([[#include <sys/socket.h>
19 #include <linux/if_alg.h>
20 struct sockaddr_alg salg = {
21 .salg_family = AF_ALG,
22 .salg_type = "hash",
23 .salg_name = "sha1",
24 };]])],
25 [gl_cv_header_linux_if_alg_salg=yes],
26 [gl_cv_header_linux_if_alg_salg=no])])
27 if test "$gl_cv_header_linux_if_alg_salg" = yes; then
28 AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
29 [Define to 1 if you have 'struct sockaddr_alg' defined.])
30 fi
31
32 dnl The default is to not use AF_ALG if available,
33 dnl as it's system dependent as to whether the kernel
34 dnl routines are faster than libcrypto for example.
35 use_af_alg=no
36 AC_ARG_WITH([linux-crypto],
37 [AS_HELP_STRING([[--with-linux-crypto]],
38 [use Linux kernel cryptographic API (if available) for the hash functions
39 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 on files])],
40 [use_af_alg=$withval],
41 [use_af_alg=no])
42 dnl We cannot use it if it is not available.
43 if test "$gl_cv_header_linux_if_alg_salg" != yes; then
44 if test "$use_af_alg" != no; then
45 AC_MSG_WARN([Linux kernel cryptographic API not found])
46 fi
47 use_af_alg=no
48 fi
49
50 if test "$use_af_alg" != no; then
51 USE_AF_ALG=1
52 else
53 USE_AF_ALG=0
54 fi
55 AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
56 [Define to 1 if you want to use the Linux kernel cryptographic API.])
57])
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
index 270abd0c..c685fac9 100644
--- a/gl/m4/alloca.m4
+++ b/gl/m4/alloca.m4
@@ -1,5 +1,5 @@
1# alloca.m4 serial 14 1# alloca.m4 serial 21
2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -26,30 +26,35 @@ AC_DEFUN([gl_FUNC_ALLOCA],
26 AC_DEFINE([HAVE_ALLOCA], [1], 26 AC_DEFINE([HAVE_ALLOCA], [1],
27 [Define to 1 if you have 'alloca' after including <alloca.h>, 27 [Define to 1 if you have 'alloca' after including <alloca.h>,
28 a header that may be supplied by this distribution.]) 28 a header that may be supplied by this distribution.])
29 ALLOCA_H=alloca.h 29 GL_GENERATE_ALLOCA_H=true
30 else 30 else
31 dnl alloca exists as a library function, i.e. it is slow and probably 31 dnl alloca exists as a library function, i.e. it is slow and probably
32 dnl a memory leak. Don't define HAVE_ALLOCA in this case. 32 dnl a memory leak. Don't define HAVE_ALLOCA in this case.
33 ALLOCA_H= 33 GL_GENERATE_ALLOCA_H=false
34 fi 34 fi
35 else 35 else
36 ALLOCA_H=alloca.h 36 GL_GENERATE_ALLOCA_H=true
37 fi 37 fi
38 AC_SUBST([ALLOCA_H]) 38
39 AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"]) 39 if test $ac_cv_working_alloca_h = yes; then
40 HAVE_ALLOCA_H=1
41 else
42 HAVE_ALLOCA_H=0
43 fi
44 AC_SUBST([HAVE_ALLOCA_H])
40]) 45])
41 46
42# Prerequisites of lib/alloca.c. 47# Prerequisites of lib/alloca.c.
43# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. 48# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
44AC_DEFUN([gl_PREREQ_ALLOCA], [:]) 49AC_DEFUN([gl_PREREQ_ALLOCA], [:])
45 50
46# This works around a bug in autoconf <= 2.68. 51m4_version_prereq([2.70], [], [
47# See <http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00277.html>.
48 52
49m4_version_prereq([2.69], [] ,[ 53# This works around a bug in autoconf <= 2.68 and has simplifications
50 54# from 2.70. See:
51# This is taken from the following Autoconf patch: 55# https://lists.gnu.org/r/bug-gnulib/2011-06/msg00277.html
52# http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497 56# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
57# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=15edf7fd8094fd14a89d9891dd72a9624762597a
53 58
54# _AC_LIBOBJ_ALLOCA 59# _AC_LIBOBJ_ALLOCA
55# ----------------- 60# -----------------
@@ -65,26 +70,6 @@ AC_LIBSOURCES(alloca.c)
65AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl 70AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
66AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.]) 71AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.])
67 72
68AC_CACHE_CHECK(whether 'alloca.c' needs Cray hooks, ac_cv_os_cray,
69[AC_EGREP_CPP(webecray,
70[#if defined CRAY && ! defined CRAY2
71webecray
72#else
73wenotbecray
74#endif
75], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
76if test $ac_cv_os_cray = yes; then
77 for ac_func in _getb67 GETB67 getb67; do
78 AC_CHECK_FUNC($ac_func,
79 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
80 [Define to one of '_getb67', 'GETB67',
81 'getb67' for Cray-2 and Cray-YMP
82 systems. This function is required for
83 'alloca.c' support on those systems.])
84 break])
85 done
86fi
87
88AC_CACHE_CHECK([stack direction for C alloca], 73AC_CACHE_CHECK([stack direction for C alloca],
89 [ac_cv_c_stack_direction], 74 [ac_cv_c_stack_direction],
90[AC_RUN_IFELSE([AC_LANG_SOURCE( 75[AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -115,7 +100,7 @@ AH_VERBATIM([STACK_DIRECTION],
115 STACK_DIRECTION > 0 => grows toward higher addresses 100 STACK_DIRECTION > 0 => grows toward higher addresses
116 STACK_DIRECTION < 0 => grows toward lower addresses 101 STACK_DIRECTION < 0 => grows toward lower addresses
117 STACK_DIRECTION = 0 => direction of growth unknown */ 102 STACK_DIRECTION = 0 => direction of growth unknown */
118@%:@undef STACK_DIRECTION])dnl 103#undef STACK_DIRECTION])dnl
119AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) 104AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
120])# _AC_LIBOBJ_ALLOCA 105])# _AC_LIBOBJ_ALLOCA
121]) 106])
diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4
index ea69af57..fa5fe831 100644
--- a/gl/m4/arpa_inet_h.m4
+++ b/gl/m4/arpa_inet_h.m4
@@ -1,15 +1,15 @@
1# arpa_inet_h.m4 serial 13 1# arpa_inet_h.m4 serial 17
2dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Simon Josefsson and Bruno Haible 7dnl Written by Simon Josefsson and Bruno Haible
8 8
9AC_DEFUN([gl_HEADER_ARPA_INET], 9AC_DEFUN_ONCE([gl_ARPA_INET_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) 13 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
14 14
15 AC_CHECK_HEADERS_ONCE([arpa/inet.h]) 15 AC_CHECK_HEADERS_ONCE([arpa/inet.h])
@@ -24,6 +24,8 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
24 24
25 AC_REQUIRE([gl_FEATURES_H]) 25 AC_REQUIRE([gl_FEATURES_H])
26 26
27 gl_PREREQ_SYS_H_WS2TCPIP
28
27 dnl Check for declarations of anything we want to poison if the 29 dnl Check for declarations of anything we want to poison if the
28 dnl corresponding gnulib module is not in use. 30 dnl corresponding gnulib module is not in use.
29 gl_WARN_ON_USE_PREPARE([[ 31 gl_WARN_ON_USE_PREPARE([[
@@ -38,17 +40,32 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
38 ]], [inet_ntop inet_pton]) 40 ]], [inet_ntop inet_pton])
39]) 41])
40 42
43# gl_ARPA_INET_MODULE_INDICATOR([modulename])
44# sets the shell variable that indicates the presence of the given module
45# to a C preprocessor expression that will evaluate to 1.
46# This macro invocation must not occur in macros that are AC_REQUIREd.
41AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], 47AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
42[ 48[
43 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 49 dnl Ensure to expand the default settings once only.
44 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) 50 gl_ARPA_INET_H_REQUIRE_DEFAULTS
45 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 51 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
46]) 52])
47 53
54# Initializes the default values for AC_SUBSTed shell variables.
55# This macro must not be AC_REQUIREd. It must only be invoked, and only
56# outside of macros or in macros that are not AC_REQUIREd.
57AC_DEFUN([gl_ARPA_INET_H_REQUIRE_DEFAULTS],
58[
59 m4_defun(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS], [
60 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_NTOP])
61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_PTON])
62 ])
63 m4_require(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS])
64 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
65])
66
48AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], 67AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
49[ 68[
50 GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
51 GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
52 dnl Assume proper GNU behavior unless another module says otherwise. 69 dnl Assume proper GNU behavior unless another module says otherwise.
53 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP]) 70 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP])
54 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON]) 71 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON])
diff --git a/gl/m4/assert_h.m4 b/gl/m4/assert_h.m4
new file mode 100644
index 00000000..abba4fa3
--- /dev/null
+++ b/gl/m4/assert_h.m4
@@ -0,0 +1,67 @@
1# assert-h.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9AC_DEFUN([gl_ASSERT_H],
10[
11 AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert],
12 [gl_save_CFLAGS=$CFLAGS
13 for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do
14 AS_CASE([$gl_working],
15 [*assert.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_ASSERT_H"])
16
17 AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM(
19 [[#if defined __clang__ && __STDC_VERSION__ < 202311
20 #pragma clang diagnostic error "-Wc2x-extensions"
21 #pragma clang diagnostic error "-Wc++17-extensions"
22 #endif
23 #ifdef INCLUDE_ASSERT_H
24 #include <assert.h>
25 #endif
26 static_assert (2 + 2 == 4, "arithmetic does not work");
27 static_assert (2 + 2 == 4);
28 ]],
29 [[
30 static_assert (sizeof (char) == 1, "sizeof does not work");
31 static_assert (sizeof (char) == 1);
32 ]])],
33 [gl_cv_static_assert=$gl_working],
34 [gl_cv_static_assert=no])
35 CFLAGS=$gl_save_CFLAGS
36 test "$gl_cv_static_assert" != no && break
37 done])
38
39 GL_GENERATE_ASSERT_H=false
40 AS_CASE([$gl_cv_static_assert],
41 [yes*keyword*],
42 [AC_DEFINE([HAVE_C_STATIC_ASSERT], [1],
43 [Define to 1 if the static_assert keyword works.])],
44 [no],
45 [GL_GENERATE_ASSERT_H=true
46 gl_NEXT_HEADERS([assert.h])])
47
48 dnl The "zz" puts this toward config.h's end, to avoid potential
49 dnl collisions with other definitions. #undef assert so that
50 dnl programs are not tempted to use it without specifically
51 dnl including assert.h. Break the #undef apart with a comment
52 dnl so that 'configure' does not comment it out.
53 AH_VERBATIM([zzstatic_assert],
54[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \
55 && (!defined __cplusplus \
56 || (__cpp_static_assert < 201411 \
57 && __GNUG__ < 6 && __clang_major__ < 6)))
58 #include <assert.h>
59 #undef/**/assert
60 /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
61 We need it also to be invocable with a single argument. */
62 #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
63 #undef/**/static_assert
64 #define static_assert _Static_assert
65 #endif
66#endif])
67])
diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4
index fc19893e..987930ab 100644
--- a/gl/m4/base64.m4
+++ b/gl/m4/base64.m4
@@ -1,5 +1,5 @@
1# base64.m4 serial 4 1# base64.m4 serial 4
2dnl Copyright (C) 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4
index 978a06e9..77218a7d 100644
--- a/gl/m4/btowc.m4
+++ b/gl/m4/btowc.m4
@@ -1,5 +1,5 @@
1# btowc.m4 serial 10 1# btowc.m4 serial 12
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_BTOWC],
10 10
11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test 11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
12 dnl program below may lead to an endless loop. See 12 dnl program below may lead to an endless loop. See
13 dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. 13 dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) 14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
15 15
16 AC_CHECK_FUNCS_ONCE([btowc]) 16 AC_CHECK_FUNCS_ONCE([btowc])
@@ -28,14 +28,6 @@ AC_DEFUN([gl_FUNC_BTOWC],
28 [ 28 [
29 AC_RUN_IFELSE( 29 AC_RUN_IFELSE(
30 [AC_LANG_SOURCE([[ 30 [AC_LANG_SOURCE([[
31#include <string.h>
32/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
33 <wchar.h>.
34 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
35 included before <wchar.h>. */
36#include <stddef.h>
37#include <stdio.h>
38#include <time.h>
39#include <wchar.h> 31#include <wchar.h>
40int main () 32int main ()
41{ 33{
@@ -50,6 +42,8 @@ changequote(,)dnl
50 case "$host_os" in 42 case "$host_os" in
51 # Guess no on Cygwin. 43 # Guess no on Cygwin.
52 cygwin*) gl_cv_func_btowc_nul="guessing no" ;; 44 cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
45 # Guess yes on native Windows.
46 mingw*) gl_cv_func_btowc_nul="guessing yes" ;;
53 # Guess yes otherwise. 47 # Guess yes otherwise.
54 *) gl_cv_func_btowc_nul="guessing yes" ;; 48 *) gl_cv_func_btowc_nul="guessing yes" ;;
55 esac 49 esac
@@ -65,24 +59,19 @@ changequote([,])dnl
65 dnl is present. 59 dnl is present.
66changequote(,)dnl 60changequote(,)dnl
67 case "$host_os" in 61 case "$host_os" in
68 # Guess no on IRIX. 62 # Guess no on IRIX.
69 irix*) gl_cv_func_btowc_eof="guessing no" ;; 63 irix*) gl_cv_func_btowc_eof="guessing no" ;;
70 # Guess yes otherwise. 64 # Guess yes on native Windows.
71 *) gl_cv_func_btowc_eof="guessing yes" ;; 65 mingw*) gl_cv_func_btowc_eof="guessing yes" ;;
66 # Guess yes otherwise.
67 *) gl_cv_func_btowc_eof="guessing yes" ;;
72 esac 68 esac
73changequote([,])dnl 69changequote([,])dnl
74 if test $LOCALE_FR != none; then 70 if test $LOCALE_FR != none; then
75 AC_RUN_IFELSE( 71 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[ 72 [AC_LANG_SOURCE([[
77#include <locale.h> 73#include <locale.h>
78#include <string.h>
79/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
80 <wchar.h>.
81 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
82 included before <wchar.h>. */
83#include <stddef.h>
84#include <stdio.h> 74#include <stdio.h>
85#include <time.h>
86#include <wchar.h> 75#include <wchar.h>
87int main () 76int main ()
88{ 77{
diff --git a/gl/m4/builtin-expect.m4 b/gl/m4/builtin-expect.m4
new file mode 100644
index 00000000..531ed48a
--- /dev/null
+++ b/gl/m4/builtin-expect.m4
@@ -0,0 +1,49 @@
1dnl Check for __builtin_expect.
2
3dnl Copyright 2016-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN([gl___BUILTIN_EXPECT],
11[
12 AC_CACHE_CHECK([for __builtin_expect],
13 [gl_cv___builtin_expect],
14 [AC_LINK_IFELSE(
15 [AC_LANG_SOURCE([[
16 int
17 main (int argc, char **argv)
18 {
19 argc = __builtin_expect (argc, 100);
20 return argv[argc != 100][0];
21 }]])],
22 [gl_cv___builtin_expect=yes],
23 [AC_LINK_IFELSE(
24 [AC_LANG_SOURCE([[
25 #include <builtins.h>
26 int
27 main (int argc, char **argv)
28 {
29 argc = __builtin_expect (argc, 100);
30 return argv[argc != 100][0];
31 }]])],
32 [gl_cv___builtin_expect="in <builtins.h>"],
33 [gl_cv___builtin_expect=no])])])
34 if test "$gl_cv___builtin_expect" = yes; then
35 AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
36 elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
37 AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
38 fi
39 AH_VERBATIM([HAVE___BUILTIN_EXPECT],
40 [/* Define to 1 if the compiler supports __builtin_expect,
41 and to 2 if <builtins.h> does. */
42#undef HAVE___BUILTIN_EXPECT
43#ifndef HAVE___BUILTIN_EXPECT
44# define __builtin_expect(e, c) (e)
45#elif HAVE___BUILTIN_EXPECT == 2
46# include <builtins.h>
47#endif
48 ])
49])
diff --git a/gl/m4/byteswap.m4 b/gl/m4/byteswap.m4
new file mode 100644
index 00000000..8058d178
--- /dev/null
+++ b/gl/m4/byteswap.m4
@@ -0,0 +1,17 @@
1# byteswap.m4 serial 5
2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Oskar Liljeblad.
8
9AC_DEFUN([gl_BYTESWAP],
10[
11 dnl Prerequisites of lib/byteswap.in.h.
12 AC_CHECK_HEADERS([byteswap.h], [
13 GL_GENERATE_BYTESWAP_H=false
14 ], [
15 GL_GENERATE_BYTESWAP_H=true
16 ])
17])
diff --git a/gl/m4/c-bool.m4 b/gl/m4/c-bool.m4
new file mode 100644
index 00000000..f614371b
--- /dev/null
+++ b/gl/m4/c-bool.m4
@@ -0,0 +1,51 @@
1# Check for bool that conforms to C2023.
2
3dnl Copyright 2022-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_C_BOOL],
9[
10 AC_CACHE_CHECK([for bool, true, false], [gl_cv_c_bool],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_SOURCE([[
13 #if true == false
14 #error "true == false"
15 #endif
16 extern bool b;
17 bool b = true == false;]])],
18 [gl_cv_c_bool=yes],
19 [gl_cv_c_bool=no])])
20 if test "$gl_cv_c_bool" = yes; then
21 AC_DEFINE([HAVE_C_BOOL], [1],
22 [Define to 1 if bool, true and false work as per C2023.])
23 fi
24
25 AC_CHECK_HEADERS_ONCE([stdbool.h])
26
27 dnl The "zz" puts this toward config.h's end, to avoid potential
28 dnl collisions with other definitions.
29 dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
30 dnl In C, this means including <stdbool.h> if it is not already included.
31 dnl However, if the preprocessor mistakenly treats 'true' as 0,
32 dnl define it to a bool expression equal to 1; this is needed in
33 dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
34 AH_VERBATIM([zzbool],
35[#ifndef HAVE_C_BOOL
36# if !defined __cplusplus && !defined __bool_true_false_are_defined
37# if HAVE_STDBOOL_H
38# include <stdbool.h>
39# else
40# if defined __SUNPRO_C
41# error "<stdbool.h> is not usable with this configuration. To make it usable, add -D_STDC_C99= to $CC."
42# else
43# error "<stdbool.h> does not exist on this platform. Use gnulib module 'stdbool-c99' instead of gnulib module 'stdbool'."
44# endif
45# endif
46# endif
47# if !true
48# define true (!false)
49# endif
50#endif])
51])
diff --git a/gl/m4/calloc.m4 b/gl/m4/calloc.m4
new file mode 100644
index 00000000..23c0dd9f
--- /dev/null
+++ b/gl/m4/calloc.m4
@@ -0,0 +1,83 @@
1# calloc.m4 serial 29
2
3# Copyright (C) 2004-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# Written by Jim Meyering.
9
10# Determine whether calloc (N, S) returns non-NULL when N*S is zero,
11# and returns NULL when N*S overflows.
12# If so, define HAVE_CALLOC. Otherwise, define calloc to rpl_calloc
13# and arrange to use a calloc wrapper function that does work in that case.
14
15# _AC_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT])
16# -------------------------------------
17# If calloc is compatible with GNU calloc, run IF-WORKS, otherwise, IF-NOT.
18AC_DEFUN([_AC_FUNC_CALLOC_IF],
19[
20 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CACHE_CHECK([whether calloc (0, n) and calloc (n, 0) return nonnull],
22 [ac_cv_func_calloc_0_nonnull],
23 [if test $cross_compiling != yes; then
24 ac_cv_func_calloc_0_nonnull=yes
25 AC_RUN_IFELSE(
26 [AC_LANG_PROGRAM(
27 [AC_INCLUDES_DEFAULT],
28 [[int result = 0;
29 char * volatile p = calloc (0, 0);
30 if (!p)
31 result |= 1;
32 free (p);
33 return result;
34 ]])],
35 [],
36 [ac_cv_func_calloc_0_nonnull=no])
37 else
38 case "$host_os" in
39 # Guess yes on glibc systems.
40 *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
41 # Guess yes on musl systems.
42 *-musl*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
43 # Guess yes on native Windows.
44 mingw*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
45 # If we don't know, obey --enable-cross-guesses.
46 *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;;
47 esac
48 fi
49 ])
50 AS_CASE([$ac_cv_func_calloc_0_nonnull], [*yes], [$1], [$2])
51])
52
53
54# gl_FUNC_CALLOC_GNU
55# ------------------
56# Replace calloc if it is not compatible with GNU libc.
57AC_DEFUN([gl_FUNC_CALLOC_GNU],
58[
59 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
60 AC_REQUIRE([gl_FUNC_CALLOC_POSIX])
61 REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX"
62 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then
63 _AC_FUNC_CALLOC_IF([], [REPLACE_CALLOC_FOR_CALLOC_GNU=1])
64 fi
65])# gl_FUNC_CALLOC_GNU
66
67# gl_FUNC_CALLOC_POSIX
68# --------------------
69# Test whether 'calloc' is POSIX compliant (sets errno to ENOMEM when it
70# fails, and doesn't mess up with ptrdiff_t or size_t overflow),
71# and replace calloc if it is not.
72AC_DEFUN([gl_FUNC_CALLOC_POSIX],
73[
74 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
75 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
76 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
77 REPLACE_CALLOC_FOR_CALLOC_POSIX=1
78 fi
79 dnl Although in theory we should also test for size_t overflow,
80 dnl in practice testing for ptrdiff_t overflow suffices
81 dnl since PTRDIFF_MAX <= SIZE_MAX on all known Gnulib porting targets.
82 dnl A separate size_t test would slow down 'configure'.
83])
diff --git a/gl/m4/close.m4 b/gl/m4/close.m4
new file mode 100644
index 00000000..9f95c670
--- /dev/null
+++ b/gl/m4/close.m4
@@ -0,0 +1,35 @@
1# close.m4 serial 9
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_CLOSE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 m4_ifdef([gl_MSVC_INVAL], [
11 AC_REQUIRE([gl_MSVC_INVAL])
12 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
13 REPLACE_CLOSE=1
14 fi
15 ])
16 m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [
17 gl_PREREQ_SYS_H_WINSOCK2
18 if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then
19 dnl Even if the 'socket' module is not used here, another part of the
20 dnl application may use it and pass file descriptors that refer to
21 dnl sockets to the close() function. So enable the support for sockets.
22 REPLACE_CLOSE=1
23 fi
24 ])
25 dnl Replace close() for supporting the gnulib-defined fchdir() function,
26 dnl to keep fchdir's bookkeeping up-to-date.
27 m4_ifdef([gl_FUNC_FCHDIR], [
28 if test $REPLACE_CLOSE = 0; then
29 gl_TEST_FCHDIR
30 if test $HAVE_FCHDIR = 0; then
31 REPLACE_CLOSE=1
32 fi
33 fi
34 ])
35])
diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4
index c2761be2..5804f472 100644
--- a/gl/m4/codeset.m4
+++ b/gl/m4/codeset.m4
@@ -1,5 +1,6 @@
1# codeset.m4 serial 5 (gettext-0.18.2) 1# codeset.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2023 Free Software
3dnl Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/configmake.m4 b/gl/m4/configmake.m4
deleted file mode 100644
index 823ffc0d..00000000
--- a/gl/m4/configmake.m4
+++ /dev/null
@@ -1,50 +0,0 @@
1# configmake.m4 serial 1
2dnl Copyright (C) 2010-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# gl_CONFIGMAKE_PREP
8# ------------------
9# Guarantee all of the standard directory variables, even when used with
10# autoconf 2.59 (datarootdir wasn't supported until 2.59c) or automake
11# 1.9.6 (pkglibexecdir wasn't supported until 1.10b.).
12AC_DEFUN([gl_CONFIGMAKE_PREP],
13[
14 dnl Technically, datadir should default to datarootdir. But if
15 dnl autoconf is too old to provide datarootdir, then reversing the
16 dnl definition is a reasonable compromise. Only AC_SUBST a variable
17 dnl if it was not already defined earlier by autoconf.
18 if test "x$datarootdir" = x; then
19 AC_SUBST([datarootdir], ['${datadir}'])
20 fi
21 dnl Copy the approach used in autoconf 2.60.
22 if test "x$docdir" = x; then
23 AC_SUBST([docdir], [m4_ifset([AC_PACKAGE_TARNAME],
24 ['${datarootdir}/doc/${PACKAGE_TARNAME}'],
25 ['${datarootdir}/doc/${PACKAGE}'])])
26 fi
27 dnl The remaining variables missing from autoconf 2.59 are easier.
28 if test "x$htmldir" = x; then
29 AC_SUBST([htmldir], ['${docdir}'])
30 fi
31 if test "x$dvidir" = x; then
32 AC_SUBST([dvidir], ['${docdir}'])
33 fi
34 if test "x$pdfdir" = x; then
35 AC_SUBST([pdfdir], ['${docdir}'])
36 fi
37 if test "x$psdir" = x; then
38 AC_SUBST([psdir], ['${docdir}'])
39 fi
40 if test "x$lispdir" = x; then
41 AC_SUBST([lispdir], ['${datarootdir}/emacs/site-lisp'])
42 fi
43 if test "x$localedir" = x; then
44 AC_SUBST([localedir], ['${datarootdir}/locale'])
45 fi
46
47 dnl Automake 1.9.6 only lacks pkglibexecdir; and since 1.11 merely
48 dnl provides it without AC_SUBST, this blind use of AC_SUBST is safe.
49 AC_SUBST([pkglibexecdir], ['${libexecdir}/${PACKAGE}'])
50])
diff --git a/gl/m4/dirname.m4 b/gl/m4/dirname.m4
deleted file mode 100644
index 5897a2a8..00000000
--- a/gl/m4/dirname.m4
+++ /dev/null
@@ -1,19 +0,0 @@
1#serial 10 -*- autoconf -*-
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_DIRNAME],
8[
9 AC_REQUIRE([gl_DIRNAME_LGPL])
10])
11
12AC_DEFUN([gl_DIRNAME_LGPL],
13[
14 dnl Prerequisites of lib/dirname.h.
15 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
16
17 dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
18 dnl lib/stripslash.c.
19])
diff --git a/gl/m4/double-slash-root.m4 b/gl/m4/double-slash-root.m4
index bd6f8671..1776e5eb 100644
--- a/gl/m4/double-slash-root.m4
+++ b/gl/m4/double-slash-root.m4
@@ -1,5 +1,5 @@
1# double-slash-root.m4 serial 4 -*- Autoconf -*- 1# double-slash-root.m4 serial 4 -*- Autoconf -*-
2dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
new file mode 100644
index 00000000..e1cc73e1
--- /dev/null
+++ b/gl/m4/dup2.m4
@@ -0,0 +1,105 @@
1#serial 27
2dnl Copyright (C) 2002, 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_DUP2],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
12 [AC_RUN_IFELSE([
13 AC_LANG_PROGRAM(
14 [[#include <errno.h>
15 #include <fcntl.h>
16 #include <limits.h>
17 #include <sys/resource.h>
18 #include <unistd.h>
19 ]GL_MDA_DEFINES[
20 #ifndef RLIM_SAVED_CUR
21 # define RLIM_SAVED_CUR RLIM_INFINITY
22 #endif
23 #ifndef RLIM_SAVED_MAX
24 # define RLIM_SAVED_MAX RLIM_INFINITY
25 #endif
26 ]],
27 [[int result = 0;
28 int bad_fd = INT_MAX;
29 struct rlimit rlim;
30 if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
31 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
32 && rlim.rlim_cur != RLIM_INFINITY
33 && rlim.rlim_cur != RLIM_SAVED_MAX
34 && rlim.rlim_cur != RLIM_SAVED_CUR)
35 bad_fd = rlim.rlim_cur;
36 #ifdef FD_CLOEXEC
37 if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
38 result |= 1;
39 #endif
40 if (dup2 (1, 1) != 1)
41 result |= 2;
42 #ifdef FD_CLOEXEC
43 if (fcntl (1, F_GETFD) != FD_CLOEXEC)
44 result |= 4;
45 #endif
46 close (0);
47 if (dup2 (0, 0) != -1)
48 result |= 8;
49 /* Many gnulib modules require POSIX conformance of EBADF. */
50 if (dup2 (2, bad_fd) == -1 && errno != EBADF)
51 result |= 16;
52 /* Flush out some cygwin core dumps. */
53 if (dup2 (2, -1) != -1 || errno != EBADF)
54 result |= 32;
55 dup2 (2, 255);
56 dup2 (2, 256);
57 /* On OS/2 kLIBC, dup2() does not work on a directory fd. */
58 {
59 int fd = open (".", O_RDONLY);
60 if (fd == -1)
61 result |= 64;
62 else if (dup2 (fd, fd + 1) == -1)
63 result |= 128;
64 close (fd);
65 }
66 return result;]])
67 ],
68 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
69 [case "$host_os" in
70 mingw*) # on this platform, dup2 always returns 0 for success
71 gl_cv_func_dup2_works="guessing no" ;;
72 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
73 gl_cv_func_dup2_works="guessing no" ;;
74 aix* | freebsd*)
75 # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
76 # not EBADF.
77 gl_cv_func_dup2_works="guessing no" ;;
78 haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
79 gl_cv_func_dup2_works="guessing no" ;;
80 *-android*) # implemented using dup3(), which fails if oldfd == newfd
81 gl_cv_func_dup2_works="guessing no" ;;
82 os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd.
83 gl_cv_func_dup2_works="guessing no" ;;
84 *) gl_cv_func_dup2_works="guessing yes" ;;
85 esac])
86 ])
87 case "$gl_cv_func_dup2_works" in
88 *yes) ;;
89 *)
90 REPLACE_DUP2=1
91 AC_CHECK_FUNCS([setdtablesize])
92 ;;
93 esac
94 dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
95 dnl to keep fchdir's bookkeeping up-to-date.
96 m4_ifdef([gl_FUNC_FCHDIR], [
97 gl_TEST_FCHDIR
98 if test $HAVE_FCHDIR = 0; then
99 REPLACE_DUP2=1
100 fi
101 ])
102])
103
104# Prerequisites of lib/dup2.c.
105AC_DEFUN([gl_PREREQ_DUP2], [])
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4
index c640ec12..cb3e08fe 100644
--- a/gl/m4/eealloc.m4
+++ b/gl/m4/eealloc.m4
@@ -1,5 +1,5 @@
1# eealloc.m4 serial 3 1# eealloc.m4 serial 3
2dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4
index 593a33ed..741dfc56 100644
--- a/gl/m4/environ.m4
+++ b/gl/m4/environ.m4
@@ -1,5 +1,5 @@
1# environ.m4 serial 6 1# environ.m4 serial 8
2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -29,16 +29,15 @@ AC_DEFUN_ONCE([gl_ENVIRON],
29AC_DEFUN([gt_CHECK_VAR_DECL], 29AC_DEFUN([gt_CHECK_VAR_DECL],
30[ 30[
31 define([gt_cv_var], [gt_cv_var_]$2[_declaration]) 31 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
32 AC_MSG_CHECKING([if $2 is properly declared]) 32 AC_CACHE_CHECK([if $2 is properly declared], [gt_cv_var],
33 AC_CACHE_VAL([gt_cv_var], [ 33 [AC_COMPILE_IFELSE(
34 AC_COMPILE_IFELSE( 34 [AC_LANG_PROGRAM(
35 [AC_LANG_PROGRAM( 35 [[$1
36 [[$1 36 typedef struct { int foo; } foo_t;
37 extern struct { int foo; } $2;]], 37 extern foo_t $2;]],
38 [[$2.foo = 1;]])], 38 [[$2.foo = 1;]])],
39 [gt_cv_var=no], 39 [gt_cv_var=no],
40 [gt_cv_var=yes])]) 40 [gt_cv_var=yes])])
41 AC_MSG_RESULT([$gt_cv_var])
42 if test $gt_cv_var = yes; then 41 if test $gt_cv_var = yes; then
43 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, 42 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
44 [Define if you have the declaration of $2.]) 43 [Define if you have the declaration of $2.])
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index c813ea58..4c70d225 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,9 +1,11 @@
1# errno_h.m4 serial 12 1# errno_h.m4 serial 14
2dnl Copyright (C) 2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_PREREQ([2.61])
8
7AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], 9AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
8[ 10[
9 AC_REQUIRE([AC_PROG_CC]) 11 AC_REQUIRE([AC_PROG_CC])
@@ -66,13 +68,11 @@ booboo
66 [gl_cv_header_errno_h_complete=yes]) 68 [gl_cv_header_errno_h_complete=yes])
67 ]) 69 ])
68 if test $gl_cv_header_errno_h_complete = yes; then 70 if test $gl_cv_header_errno_h_complete = yes; then
69 ERRNO_H='' 71 GL_GENERATE_ERRNO_H=false
70 else 72 else
71 gl_NEXT_HEADERS([errno.h]) 73 gl_NEXT_HEADERS([errno.h])
72 ERRNO_H='errno.h' 74 GL_GENERATE_ERRNO_H=true
73 fi 75 fi
74 AC_SUBST([ERRNO_H])
75 AM_CONDITIONAL([GL_GENERATE_ERRNO_H], [test -n "$ERRNO_H"])
76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP]) 76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
77 gl_REPLACE_ERRNO_VALUE([ENOLINK]) 77 gl_REPLACE_ERRNO_VALUE([ENOLINK])
78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW]) 78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
@@ -86,7 +86,7 @@ booboo
86# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE. 86# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
87AC_DEFUN([gl_REPLACE_ERRNO_VALUE], 87AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
88[ 88[
89 if test -n "$ERRNO_H"; then 89 if $GL_GENERATE_ERRNO_H; then
90 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [ 90 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
91 AC_EGREP_CPP([yes],[ 91 AC_EGREP_CPP([yes],[
92#include <errno.h> 92#include <errno.h>
@@ -129,9 +129,3 @@ yes
129 AC_SUBST($1[_VALUE]) 129 AC_SUBST($1[_VALUE])
130 fi 130 fi
131]) 131])
132
133dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
134dnl Remove this when we can assume autoconf >= 2.61.
135m4_ifdef([AC_COMPUTE_INT], [], [
136 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
137])
diff --git a/gl/m4/error.m4 b/gl/m4/error.m4
index 29e6fdc9..8cc75dff 100644
--- a/gl/m4/error.m4
+++ b/gl/m4/error.m4
@@ -1,6 +1,6 @@
1#serial 14 1#serial 15
2 2
3# Copyright (C) 1996-1998, 2001-2004, 2009-2013 Free Software Foundation, Inc. 3# Copyright (C) 1996-1998, 2001-2004, 2009-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
@@ -22,6 +22,10 @@ AC_DEFUN([gl_ERROR],
22# Prerequisites of lib/error.c. 22# Prerequisites of lib/error.c.
23AC_DEFUN([gl_PREREQ_ERROR], 23AC_DEFUN([gl_PREREQ_ERROR],
24[ 24[
25 dnl Use system extensions on Android, so that AC_FUNC_STRERROR_R
26 dnl discovers the GNU API for strerror_r on Android API level 23 and later.
27 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
28
25 AC_REQUIRE([AC_FUNC_STRERROR_R]) 29 AC_REQUIRE([AC_FUNC_STRERROR_R])
26 : 30 :
27]) 31])
diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4
index 09df468c..2ef46437 100644
--- a/gl/m4/exponentd.m4
+++ b/gl/m4/exponentd.m4
@@ -1,5 +1,5 @@
1# exponentd.m4 serial 3 1# exponentd.m4 serial 3
2dnl Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index e30f1220..5336b8da 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -1,14 +1,19 @@
1# serial 13 -*- Autoconf -*- 1# serial 23 -*- Autoconf -*-
2# Enable extensions on systems that normally disable them. 2# Enable extensions on systems that normally disable them.
3 3
4# Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. 4# Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
8 8
9dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that
10dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+.
11m4_ifndef([AC_CHECK_INCLUDES_DEFAULT],
12 [AC_DEFUN([AC_CHECK_INCLUDES_DEFAULT], [])])
13
9# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git 14# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git
10# Autoconf. Perhaps we can remove this once we can assume Autoconf 15# Autoconf. Perhaps we can remove this once we can assume Autoconf
11# 2.70 or later everywhere, but since Autoconf mutates rapidly 16# is recent-enough everywhere, but since Autoconf mutates rapidly
12# enough in this area it's likely we'll need to redefine 17# enough in this area it's likely we'll need to redefine
13# AC_USE_SYSTEM_EXTENSIONS for quite some time. 18# AC_USE_SYSTEM_EXTENSIONS for quite some time.
14 19
@@ -26,67 +31,125 @@
26# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS 31# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
27# invocation occurs in gl_EARLY, not in gl_INIT. 32# invocation occurs in gl_EARLY, not in gl_INIT.
28 33
34m4_version_prereq([2.72], [], [
35
29# AC_USE_SYSTEM_EXTENSIONS 36# AC_USE_SYSTEM_EXTENSIONS
30# ------------------------ 37# ------------------------
31# Enable extensions on systems that normally disable them, 38# Enable extensions on systems that normally disable them,
32# typically due to standards-conformance issues. 39# typically due to standards-conformance issues.
33# 40# We unconditionally define as many of the known feature-enabling
34# Remember that #undef in AH_VERBATIM gets replaced with #define by 41# as possible, reserving conditional behavior for macros that are
35# AC_DEFINE. The goal here is to define all known feature-enabling 42# known to cause problems on some platforms (such as __EXTENSIONS__).
36# macros, then, if reports of conflicts are made, disable macros that
37# cause problems on some platforms (such as __EXTENSIONS__).
38AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], 43AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
39[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl 44[AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl
45AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
46AC_BEFORE([$0], [AC_LINK_IFELSE])dnl
40AC_BEFORE([$0], [AC_RUN_IFELSE])dnl 47AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
41 48AC_BEFORE([$0], [AC_CHECK_INCLUDES_DEFAULT])dnl
42 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) 49dnl #undef in AH_VERBATIM gets replaced with #define by AC_DEFINE.
43 if test "$MINIX" = yes; then
44 AC_DEFINE([_POSIX_SOURCE], [1],
45 [Define to 1 if you need to in order for 'stat' and other
46 things to work.])
47 AC_DEFINE([_POSIX_1_SOURCE], [2],
48 [Define to 2 if the system does not provide POSIX.1 features
49 except with this defined.])
50 AC_DEFINE([_MINIX], [1],
51 [Define to 1 if on MINIX.])
52 AC_DEFINE([_NETBSD_SOURCE], [1],
53 [Define to 1 to make NetBSD features available. MINIX 3 needs this.])
54 fi
55
56dnl Use a different key than __EXTENSIONS__, as that name broke existing 50dnl Use a different key than __EXTENSIONS__, as that name broke existing
57dnl configure.ac when using autoheader 2.62. 51dnl configure.ac when using autoheader 2.62.
58 AH_VERBATIM([USE_SYSTEM_EXTENSIONS], 52dnl The macros below are in alphabetical order ignoring leading _ or __
53dnl prefixes.
54AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
59[/* Enable extensions on AIX 3, Interix. */ 55[/* Enable extensions on AIX 3, Interix. */
60#ifndef _ALL_SOURCE 56#ifndef _ALL_SOURCE
61# undef _ALL_SOURCE 57# undef _ALL_SOURCE
62#endif 58#endif
63/* Enable general extensions on OS X. */ 59/* Enable general extensions on macOS. */
64#ifndef _DARWIN_C_SOURCE 60#ifndef _DARWIN_C_SOURCE
65# undef _DARWIN_C_SOURCE 61# undef _DARWIN_C_SOURCE
66#endif 62#endif
63/* Enable general extensions on Solaris. */
64#ifndef __EXTENSIONS__
65# undef __EXTENSIONS__
66#endif
67/* Enable GNU extensions on systems that have them. */ 67/* Enable GNU extensions on systems that have them. */
68#ifndef _GNU_SOURCE 68#ifndef _GNU_SOURCE
69# undef _GNU_SOURCE 69# undef _GNU_SOURCE
70#endif 70#endif
71/* Enable threading extensions on Solaris. */ 71/* Enable X/Open compliant socket functions that do not require linking
72 with -lxnet on HP-UX 11.11. */
73#ifndef _HPUX_ALT_XOPEN_SOCKET_API
74# undef _HPUX_ALT_XOPEN_SOCKET_API
75#endif
76/* Identify the host operating system as Minix.
77 This macro does not affect the system headers' behavior.
78 A future release of Autoconf may stop defining this macro. */
79#ifndef _MINIX
80# undef _MINIX
81#endif
82/* Enable general extensions on NetBSD.
83 Enable NetBSD compatibility extensions on Minix. */
84#ifndef _NETBSD_SOURCE
85# undef _NETBSD_SOURCE
86#endif
87/* Enable OpenBSD compatibility extensions on NetBSD.
88 Oddly enough, this does nothing on OpenBSD. */
89#ifndef _OPENBSD_SOURCE
90# undef _OPENBSD_SOURCE
91#endif
92/* Define to 1 if needed for POSIX-compatible behavior. */
93#ifndef _POSIX_SOURCE
94# undef _POSIX_SOURCE
95#endif
96/* Define to 2 if needed for POSIX-compatible behavior. */
97#ifndef _POSIX_1_SOURCE
98# undef _POSIX_1_SOURCE
99#endif
100/* Enable POSIX-compatible threading on Solaris. */
72#ifndef _POSIX_PTHREAD_SEMANTICS 101#ifndef _POSIX_PTHREAD_SEMANTICS
73# undef _POSIX_PTHREAD_SEMANTICS 102# undef _POSIX_PTHREAD_SEMANTICS
74#endif 103#endif
104/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
105#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
106# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
107#endif
108/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
109#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
110# undef __STDC_WANT_IEC_60559_BFP_EXT__
111#endif
112/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
113#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
114# undef __STDC_WANT_IEC_60559_DFP_EXT__
115#endif
116/* Enable extensions specified by C23 Annex F. */
117#ifndef __STDC_WANT_IEC_60559_EXT__
118# undef __STDC_WANT_IEC_60559_EXT__
119#endif
120/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
121#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
122# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
123#endif
124/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */
125#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
126# undef __STDC_WANT_IEC_60559_TYPES_EXT__
127#endif
128/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
129#ifndef __STDC_WANT_LIB_EXT2__
130# undef __STDC_WANT_LIB_EXT2__
131#endif
132/* Enable extensions specified by ISO/IEC 24747:2009. */
133#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
134# undef __STDC_WANT_MATH_SPEC_FUNCS__
135#endif
75/* Enable extensions on HP NonStop. */ 136/* Enable extensions on HP NonStop. */
76#ifndef _TANDEM_SOURCE 137#ifndef _TANDEM_SOURCE
77# undef _TANDEM_SOURCE 138# undef _TANDEM_SOURCE
78#endif 139#endif
79/* Enable X/Open extensions if necessary. HP-UX 11.11 defines 140/* Enable X/Open extensions. Define to 500 only if necessary
80 mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of 141 to make mbstate_t available. */
81 whether compiling with -Ae or -D_HPUX_SOURCE=1. */
82#ifndef _XOPEN_SOURCE 142#ifndef _XOPEN_SOURCE
83# undef _XOPEN_SOURCE 143# undef _XOPEN_SOURCE
84#endif 144#endif
85/* Enable general extensions on Solaris. */ 145])dnl
86#ifndef __EXTENSIONS__ 146
87# undef __EXTENSIONS__ 147 AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl
88#endif 148 _AC_CHECK_HEADER_ONCE([wchar.h])
89]) 149 _AC_CHECK_HEADER_ONCE([minix/config.h])
150
151dnl Defining __EXTENSIONS__ may break the system headers on some systems.
152dnl (FIXME: Which ones?)
90 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], 153 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
91 [ac_cv_safe_to_define___extensions__], 154 [ac_cv_safe_to_define___extensions__],
92 [AC_COMPILE_IFELSE( 155 [AC_COMPILE_IFELSE(
@@ -95,30 +158,57 @@ dnl configure.ac when using autoheader 2.62.
95 ]AC_INCLUDES_DEFAULT])], 158 ]AC_INCLUDES_DEFAULT])],
96 [ac_cv_safe_to_define___extensions__=yes], 159 [ac_cv_safe_to_define___extensions__=yes],
97 [ac_cv_safe_to_define___extensions__=no])]) 160 [ac_cv_safe_to_define___extensions__=no])])
98 test $ac_cv_safe_to_define___extensions__ = yes && 161
99 AC_DEFINE([__EXTENSIONS__]) 162dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to
100 AC_DEFINE([_ALL_SOURCE]) 163dnl 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1.
101 AC_DEFINE([_DARWIN_C_SOURCE]) 164dnl But defining _XOPEN_SOURCE may turn *off* extensions on platforms
102 AC_DEFINE([_GNU_SOURCE]) 165dnl not covered by turn-on-extensions macros (notably Dragonfly, Free,
103 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) 166dnl and OpenBSD, which don't have any equivalent of _NETBSD_SOURCE) so
104 AC_DEFINE([_TANDEM_SOURCE]) 167dnl it should only be defined when necessary.
105 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], 168 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
106 [ac_cv_should_define__xopen_source], 169 [ac_cv_should_define__xopen_source],
107 [ac_cv_should_define__xopen_source=no 170 [ac_cv_should_define__xopen_source=no
108 AC_COMPILE_IFELSE( 171 AS_IF([test $ac_cv_header_wchar_h = yes],
109 [AC_LANG_PROGRAM([[ 172 [AC_COMPILE_IFELSE(
173 [AC_LANG_PROGRAM([[
110 #include <wchar.h> 174 #include <wchar.h>
111 mbstate_t x;]])], 175 mbstate_t x;]])],
112 [], 176 [],
113 [AC_COMPILE_IFELSE( 177 [AC_COMPILE_IFELSE(
114 [AC_LANG_PROGRAM([[ 178 [AC_LANG_PROGRAM([[
115 #define _XOPEN_SOURCE 500 179 #define _XOPEN_SOURCE 500
116 #include <wchar.h> 180 #include <wchar.h>
117 mbstate_t x;]])], 181 mbstate_t x;]])],
118 [ac_cv_should_define__xopen_source=yes])])]) 182 [ac_cv_should_define__xopen_source=yes])])])])
119 test $ac_cv_should_define__xopen_source = yes && 183
120 AC_DEFINE([_XOPEN_SOURCE], [500]) 184 AC_DEFINE([_ALL_SOURCE])
185 AC_DEFINE([_DARWIN_C_SOURCE])
186 AC_DEFINE([_GNU_SOURCE])
187 AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API])
188 AC_DEFINE([_NETBSD_SOURCE])
189 AC_DEFINE([_OPENBSD_SOURCE])
190 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
191 AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
192 AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
193 AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
194 AC_DEFINE([__STDC_WANT_IEC_60559_EXT__])
195 AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
196 AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
197 AC_DEFINE([__STDC_WANT_LIB_EXT2__])
198 AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
199 AC_DEFINE([_TANDEM_SOURCE])
200 AS_IF([test $ac_cv_header_minix_config_h = yes],
201 [MINIX=yes
202 AC_DEFINE([_MINIX])
203 AC_DEFINE([_POSIX_SOURCE])
204 AC_DEFINE([_POSIX_1_SOURCE], [2])],
205 [MINIX=])
206 AS_IF([test $ac_cv_safe_to_define___extensions__ = yes],
207 [AC_DEFINE([__EXTENSIONS__])])
208 AS_IF([test $ac_cv_should_define__xopen_source = yes],
209 [AC_DEFINE([_XOPEN_SOURCE], [500])])
121])# AC_USE_SYSTEM_EXTENSIONS 210])# AC_USE_SYSTEM_EXTENSIONS
211])
122 212
123# gl_USE_SYSTEM_EXTENSIONS 213# gl_USE_SYSTEM_EXTENSIONS
124# ------------------------ 214# ------------------------
@@ -126,13 +216,17 @@ dnl configure.ac when using autoheader 2.62.
126# typically due to standards-conformance issues. 216# typically due to standards-conformance issues.
127AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], 217AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
128[ 218[
129 dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
130 dnl gnulib does not need it. But if it gets required by third-party macros
131 dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
132 dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
133 dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
134 dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
135 AC_REQUIRE([AC_GNU_SOURCE])
136
137 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 219 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
220
221 dnl On OpenBSD 6.8 with GCC, the include files contain a couple of
222 dnl definitions that are only activated with an explicit -D_ISOC11_SOURCE.
223 dnl That's because this version of GCC (4.2.1) supports the option
224 dnl '-std=gnu99' but not the option '-std=gnu11'.
225 AC_REQUIRE([AC_CANONICAL_HOST])
226 case "$host_os" in
227 openbsd*)
228 AC_DEFINE([_ISOC11_SOURCE], [1],
229 [Define to enable the declarations of ISO C 11 types and functions.])
230 ;;
231 esac
138]) 232])
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
index c4c5e7f2..c001b1cf 100644
--- a/gl/m4/extern-inline.m4
+++ b/gl/m4/extern-inline.m4
@@ -1,61 +1,121 @@
1dnl 'extern inline' a la ISO C99. 1dnl 'extern inline' a la ISO C99.
2 2
3dnl Copyright 2012-2013 Free Software Foundation, Inc. 3dnl Copyright 2012-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7 7
8AC_DEFUN([gl_EXTERN_INLINE], 8AC_DEFUN([gl_EXTERN_INLINE],
9[ 9[
10 AH_VERBATIM([extern_inline], 10 AC_CACHE_CHECK([whether ctype.h defines __header_inline],
11 [gl_cv_have___header_inline],
12 [AC_PREPROC_IFELSE(
13 [AC_LANG_SOURCE([[#include <ctype.h>
14 #ifndef __header_inline
15 #error "<ctype.h> does not define __header_inline"
16 #endif
17 ]])],
18 [gl_cv_have___header_inline=yes],
19 [gl_cv_have___header_inline=no])])
20 if test "$gl_cv_have___header_inline" = yes; then
21 AC_DEFINE([HAVE___HEADER_INLINE], [1],
22 [Define to 1 if ctype.h defines __header_inline.])
23 fi
24
25 AH_VERBATIM([HAVE___HEADER_INLINE_1],
11[/* Please see the Gnulib manual for how to use these macros. 26[/* Please see the Gnulib manual for how to use these macros.
12 27
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see 28 Suppress extern inline with HP-UX cc, as it appears to be broken; see
14 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>. 29 <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>.
15 30
16 Suppress extern inline with Sun C in standards-conformance mode, as it 31 Suppress extern inline with Sun C in standards-conformance mode, as it
17 mishandles inline functions that call each other. E.g., for 'inline void f 32 mishandles inline functions that call each other. E.g., for 'inline void f
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains 33 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
19 'reference to static identifier "f" in extern inline function'. 34 'reference to static identifier "f" in extern inline function'.
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. 35 This bug was observed with Oracle Developer Studio 12.6
36 (Sun C 5.15 SunOS_sparc 2017/05/30).
37
38 Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
39 on configurations that mistakenly use 'static inline' to implement
40 functions or macros in standard C headers like <ctype.h>. For example,
41 if isdigit is mistakenly implemented via a static inline function,
42 a program containing an extern inline function that calls isdigit
43 may not work since the C standard prohibits extern inline functions
44 from calling static functions (ISO C 99 section 6.7.4.(3).
45 This bug is known to occur on:
46
47 OS X 10.8 and earlier; see:
48 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
49
50 DragonFly; see
51 http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log
21 52
22 Suppress the use of extern inline on Apple's platforms, as Libc at least 53 FreeBSD; see:
23 through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g., 54 https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html
24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. 55
25 Perhaps Apple will fix this some day. */ 56 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
57 for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
58 Assume DragonFly and FreeBSD will be similar.
59
60 GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
61 inline semantics, unless -fgnu89-inline is used. It defines a macro
62 __GNUC_STDC_INLINE__ to indicate this situation or a macro
63 __GNUC_GNU_INLINE__ to indicate the opposite situation.
64 GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
65 semantics but warns, unless -fgnu89-inline is used:
66 warning: C99 inline functions are not supported; using GNU89
67 warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
68 It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
69 */
70#if (((defined __APPLE__ && defined __MACH__) \
71 || defined __DragonFly__ || defined __FreeBSD__) \
72 && (defined HAVE___HEADER_INLINE \
73 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
74 && ! defined __clang__) \
75 : ((! defined _DONT_USE_CTYPE_INLINE_ \
76 && (defined __GNUC__ || defined __cplusplus)) \
77 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
78 && defined __GNUC__ && ! defined __cplusplus))))
79# define _GL_EXTERN_INLINE_STDHEADER_BUG
80#endif
26#if ((__GNUC__ \ 81#if ((__GNUC__ \
27 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ 82 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
28 : (199901L <= __STDC_VERSION__ \ 83 : (199901L <= __STDC_VERSION__ \
29 && !defined __HP_cc \ 84 && !defined __HP_cc \
85 && !defined __PGI \
30 && !(defined __SUNPRO_C && __STDC__))) \ 86 && !(defined __SUNPRO_C && __STDC__))) \
31 && !defined __APPLE__) 87 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
32# define _GL_INLINE inline 88# define _GL_INLINE inline
33# define _GL_EXTERN_INLINE extern inline 89# define _GL_EXTERN_INLINE extern inline
90# define _GL_EXTERN_INLINE_IN_USE
34#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ 91#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
35 && !defined __APPLE__) 92 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
36# if __GNUC_GNU_INLINE__ 93# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
37 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ 94 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
38# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) 95# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
39# else 96# else
40# define _GL_INLINE extern inline 97# define _GL_INLINE extern inline
41# endif 98# endif
42# define _GL_EXTERN_INLINE extern 99# define _GL_EXTERN_INLINE extern
100# define _GL_EXTERN_INLINE_IN_USE
43#else 101#else
44# define _GL_INLINE static _GL_UNUSED 102# define _GL_INLINE _GL_UNUSED static
45# define _GL_EXTERN_INLINE static _GL_UNUSED 103# define _GL_EXTERN_INLINE _GL_UNUSED static
46#endif 104#endif
47 105
48#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 106/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
107 suppress bogus "no previous prototype for 'FOO'"
108 and "no previous declaration for 'FOO'" diagnostics,
109 when FOO is an inline function in the header; see
110 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
111 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */
112#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
49# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ 113# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
50# define _GL_INLINE_HEADER_CONST_PRAGMA 114# define _GL_INLINE_HEADER_CONST_PRAGMA
51# else 115# else
52# define _GL_INLINE_HEADER_CONST_PRAGMA \ 116# define _GL_INLINE_HEADER_CONST_PRAGMA \
53 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") 117 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
54# endif 118# endif
55 /* Suppress GCC's bogus "no previous prototype for 'FOO'"
56 and "no previous declaration for 'FOO'" diagnostics,
57 when FOO is an inline function in the header; see
58 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
59# define _GL_INLINE_HEADER_BEGIN \ 119# define _GL_INLINE_HEADER_BEGIN \
60 _Pragma ("GCC diagnostic push") \ 120 _Pragma ("GCC diagnostic push") \
61 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ 121 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4
index 87cc4bd2..59d558bd 100644
--- a/gl/m4/fcntl-o.m4
+++ b/gl/m4/fcntl-o.m4
@@ -1,23 +1,22 @@
1# fcntl-o.m4 serial 4 1# fcntl-o.m4 serial 7
2dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Paul Eggert. 7dnl Written by Paul Eggert.
8 8
9AC_PREREQ([2.60])
10
9# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. 11# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
10# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. 12# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
11# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. 13# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
12AC_DEFUN([gl_FCNTL_O_FLAGS], 14AC_DEFUN([gl_FCNTL_O_FLAGS],
13[ 15[
14 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW. 16 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
15 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16 dnl AC_GNU_SOURCE.
17 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
18 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
19 [AC_REQUIRE([AC_GNU_SOURCE])])
20 18
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CHECK_HEADERS_ONCE([unistd.h]) 20 AC_CHECK_HEADERS_ONCE([unistd.h])
22 AC_CHECK_FUNCS_ONCE([symlink]) 21 AC_CHECK_FUNCS_ONCE([symlink])
23 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], 22 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
@@ -33,6 +32,7 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
33 # defined sleep(n) _sleep ((n) * 1000) 32 # defined sleep(n) _sleep ((n) * 1000)
34 #endif 33 #endif
35 #include <fcntl.h> 34 #include <fcntl.h>
35 ]GL_MDA_DEFINES[
36 #ifndef O_NOATIME 36 #ifndef O_NOATIME
37 #define O_NOATIME 0 37 #define O_NOATIME 0
38 #endif 38 #endif
@@ -116,7 +116,13 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
117 *) gl_cv_header_working_fcntl_h='no';; 117 *) gl_cv_header_working_fcntl_h='no';;
118 esac], 118 esac],
119 [gl_cv_header_working_fcntl_h=cross-compiling])]) 119 [case "$host_os" in
120 # Guess 'no' on native Windows.
121 mingw*) gl_cv_header_working_fcntl_h='no' ;;
122 *) gl_cv_header_working_fcntl_h=cross-compiling ;;
123 esac
124 ])
125 ])
120 126
121 case $gl_cv_header_working_fcntl_h in #( 127 case $gl_cv_header_working_fcntl_h in #(
122 *O_NOATIME* | no | cross-compiling) ac_val=0;; #( 128 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
diff --git a/gl/m4/fcntl.m4 b/gl/m4/fcntl.m4
new file mode 100644
index 00000000..524a99af
--- /dev/null
+++ b/gl/m4/fcntl.m4
@@ -0,0 +1,151 @@
1# fcntl.m4 serial 11
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For now, this module ensures that fcntl()
8# - supports F_DUPFD correctly
9# - supports or emulates F_DUPFD_CLOEXEC
10# - supports F_GETFD
11# Still to be ported to mingw:
12# - F_SETFD
13# - F_GETFL, F_SETFL
14# - F_GETOWN, F_SETOWN
15# - F_GETLK, F_SETLK, F_SETLKW
16AC_DEFUN([gl_FUNC_FCNTL],
17[
18 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
21 AC_REQUIRE([AC_CANONICAL_HOST])
22 AC_CHECK_FUNCS_ONCE([fcntl])
23 if test $ac_cv_func_fcntl = no; then
24 gl_REPLACE_FCNTL
25 else
26 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
27 dnl haiku alpha 2 F_DUPFD has wrong errno
28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
29 [gl_cv_func_fcntl_f_dupfd_works],
30 [AC_RUN_IFELSE(
31 [AC_LANG_PROGRAM(
32 [[#include <errno.h>
33 #include <fcntl.h>
34 #include <limits.h>
35 #include <sys/resource.h>
36 #include <unistd.h>
37 ]GL_MDA_DEFINES[
38 #ifndef RLIM_SAVED_CUR
39 # define RLIM_SAVED_CUR RLIM_INFINITY
40 #endif
41 #ifndef RLIM_SAVED_MAX
42 # define RLIM_SAVED_MAX RLIM_INFINITY
43 #endif
44 ]],
45 [[int result = 0;
46 int bad_fd = INT_MAX;
47 struct rlimit rlim;
48 if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
49 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
50 && rlim.rlim_cur != RLIM_INFINITY
51 && rlim.rlim_cur != RLIM_SAVED_MAX
52 && rlim.rlim_cur != RLIM_SAVED_CUR)
53 bad_fd = rlim.rlim_cur;
54 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
55 if (errno != EINVAL) result |= 2;
56 if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
57 if (errno != EINVAL) result |= 8;
58 /* On OS/2 kLIBC, F_DUPFD does not work on a directory fd */
59 {
60 int fd;
61 fd = open (".", O_RDONLY);
62 if (fd == -1)
63 result |= 16;
64 else if (fcntl (fd, F_DUPFD, STDERR_FILENO + 1) == -1)
65 result |= 32;
66
67 close (fd);
68 }
69 return result;]])],
70 [gl_cv_func_fcntl_f_dupfd_works=yes],
71 [gl_cv_func_fcntl_f_dupfd_works=no],
72 [case $host_os in
73 aix* | cygwin* | haiku*)
74 gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
75 *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
76 esac])])
77 case $gl_cv_func_fcntl_f_dupfd_works in
78 *yes) ;;
79 *) gl_REPLACE_FCNTL
80 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
81 behavior does not match POSIX]) ;;
82 esac
83
84 dnl Many systems lack F_DUPFD_CLOEXEC.
85 dnl NetBSD 9.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD.
86 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
87 [gl_cv_func_fcntl_f_dupfd_cloexec],
88 [AC_RUN_IFELSE(
89 [AC_LANG_SOURCE(
90 [[#include <fcntl.h>
91 #include <unistd.h>
92 int main (int argc, char *argv[])
93 {
94 if (argc == 1)
95 /* parent process */
96 {
97 if (fcntl (1, F_DUPFD_CLOEXEC, 10) < 0)
98 return 1;
99 return execl ("./conftest", "./conftest", "child", NULL);
100 }
101 else
102 /* child process */
103 return (fcntl (10, F_GETFL) < 0 ? 0 : 42);
104 }
105 ]])
106 ],
107 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
108#ifdef __linux__
109/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
110 it to support the semantics on older kernels that failed with EINVAL. */
111choke me
112#endif
113 ]])],
114 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
115 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])
116 ],
117 [gl_cv_func_fcntl_f_dupfd_cloexec=no],
118 [case "$host_os" in
119 # Guess no on NetBSD.
120 netbsd*) gl_cv_func_fcntl_f_dupfd_cloexec="guessing no" ;;
121 *) gl_cv_func_fcntl_f_dupfd_cloexec="$gl_cross_guess_normal" ;;
122 esac
123 ])
124 ])
125 case "$gl_cv_func_fcntl_f_dupfd_cloexec" in
126 *yes) ;;
127 *) gl_REPLACE_FCNTL
128 dnl No witness macro needed for this bug.
129 ;;
130 esac
131 fi
132 dnl Replace fcntl() for supporting the gnulib-defined fchdir() function,
133 dnl to keep fchdir's bookkeeping up-to-date.
134 m4_ifdef([gl_FUNC_FCHDIR], [
135 gl_TEST_FCHDIR
136 if test $HAVE_FCHDIR = 0; then
137 gl_REPLACE_FCNTL
138 fi
139 ])
140])
141
142AC_DEFUN([gl_REPLACE_FCNTL],
143[
144 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
145 AC_CHECK_FUNCS_ONCE([fcntl])
146 if test $ac_cv_func_fcntl = no; then
147 HAVE_FCNTL=0
148 else
149 REPLACE_FCNTL=1
150 fi
151])
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
new file mode 100644
index 00000000..68f4e648
--- /dev/null
+++ b/gl/m4/fcntl_h.m4
@@ -0,0 +1,70 @@
1# serial 20
2# Configure fcntl.h.
3dnl Copyright (C) 2006-2007, 2009-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN_ONCE([gl_FCNTL_H],
11[
12 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
13 AC_REQUIRE([gl_FCNTL_O_FLAGS])
14 gl_NEXT_HEADERS([fcntl.h])
15
16 dnl Ensure the type pid_t gets defined.
17 AC_REQUIRE([AC_TYPE_PID_T])
18
19 dnl Ensure the type mode_t gets defined.
20 AC_REQUIRE([AC_TYPE_MODE_T])
21
22 dnl Check for declarations of anything we want to poison if the
23 dnl corresponding gnulib module is not in use, if it is not common
24 dnl enough to be declared everywhere.
25 gl_WARN_ON_USE_PREPARE([[#include <fcntl.h>
26 ]], [fcntl openat])
27])
28
29# gl_FCNTL_MODULE_INDICATOR([modulename])
30# sets the shell variable that indicates the presence of the given module
31# to a C preprocessor expression that will evaluate to 1.
32# This macro invocation must not occur in macros that are AC_REQUIREd.
33AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
34[
35 dnl Ensure to expand the default settings once only.
36 gl_FCNTL_H_REQUIRE_DEFAULTS
37 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
38 dnl Define it also as a C macro, for the benefit of the unit tests.
39 gl_MODULE_INDICATOR_FOR_TESTS([$1])
40])
41
42# Initializes the default values for AC_SUBSTed shell variables.
43# This macro must not be AC_REQUIREd. It must only be invoked, and only
44# outside of macros or in macros that are not AC_REQUIREd.
45AC_DEFUN([gl_FCNTL_H_REQUIRE_DEFAULTS],
46[
47 m4_defun(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS], [
48 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CREAT])
49 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCNTL])
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NONBLOCKING])
51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPEN])
52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT])
53 dnl Support Microsoft deprecated alias function names by default.
54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CREAT], [1])
55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_OPEN], [1])
56 ])
57 m4_require(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS])
58 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
59])
60
61AC_DEFUN([gl_FCNTL_H_DEFAULTS],
62[
63 dnl Assume proper GNU behavior unless another module says otherwise.
64 HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
65 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
66 REPLACE_CREAT=0; AC_SUBST([REPLACE_CREAT])
67 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
68 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
69 REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
70])
diff --git a/gl/m4/fflush.m4 b/gl/m4/fflush.m4
new file mode 100644
index 00000000..3e3c8903
--- /dev/null
+++ b/gl/m4/fflush.m4
@@ -0,0 +1,100 @@
1# fflush.m4 serial 18
2
3# Copyright (C) 2007-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8dnl From Eric Blake
9
10dnl Find out how to obey POSIX semantics of fflush(stdin) discarding
11dnl unread input on seekable streams, rather than C99 undefined semantics.
12
13AC_DEFUN([gl_FUNC_FFLUSH],
14[
15 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
16 gl_FUNC_FFLUSH_STDIN
17 case "$gl_cv_func_fflush_stdin" in
18 *yes) ;;
19 *) REPLACE_FFLUSH=1 ;;
20 esac
21])
22
23dnl Determine whether fflush works on input streams.
24dnl Sets gl_cv_func_fflush_stdin.
25
26AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
27[
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
29 AC_CHECK_HEADERS_ONCE([unistd.h])
30 AC_CACHE_CHECK([whether fflush works on input streams],
31 [gl_cv_func_fflush_stdin],
32 [echo hello world > conftest.txt
33 AC_RUN_IFELSE([AC_LANG_PROGRAM(
34 [[
35#include <stdio.h>
36#if HAVE_UNISTD_H
37# include <unistd.h>
38#else /* on Windows with MSVC */
39# include <io.h>
40#endif
41 ]GL_MDA_DEFINES],
42 [[FILE *f = fopen ("conftest.txt", "r");
43 char buffer[10];
44 int fd;
45 int c;
46 if (f == NULL)
47 return 1;
48 fd = fileno (f);
49 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
50 { fclose (f); return 2; }
51 /* For deterministic results, ensure f read a bigger buffer. */
52 if (lseek (fd, 0, SEEK_CUR) == 5)
53 { fclose (f); return 3; }
54 /* POSIX requires fflush-fseek to set file offset of fd. This fails
55 on BSD systems and on mingw. */
56 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
57 { fclose (f); return 4; }
58 if (lseek (fd, 0, SEEK_CUR) != 5)
59 { fclose (f); return 5; }
60 /* Verify behaviour of fflush after ungetc. See
61 <https://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
62 /* Verify behaviour of fflush after a backup ungetc. This fails on
63 mingw. */
64 c = fgetc (f);
65 ungetc (c, f);
66 fflush (f);
67 if (fgetc (f) != c)
68 { fclose (f); return 6; }
69 /* Verify behaviour of fflush after a non-backup ungetc. This fails
70 on glibc 2.8 and on BSD systems. */
71 c = fgetc (f);
72 ungetc ('@', f);
73 fflush (f);
74 if (fgetc (f) != c)
75 { fclose (f); return 7; }
76 fclose (f);
77 return 0;
78 ]])],
79 [gl_cv_func_fflush_stdin=yes],
80 [gl_cv_func_fflush_stdin=no],
81 [case "$host_os" in
82 # Guess no on native Windows.
83 mingw*) gl_cv_func_fflush_stdin="guessing no" ;;
84 *) gl_cv_func_fflush_stdin=cross ;;
85 esac
86 ])
87 rm conftest.txt
88 ])
89 case "$gl_cv_func_fflush_stdin" in
90 *yes) gl_func_fflush_stdin=1 ;;
91 *no) gl_func_fflush_stdin=0 ;;
92 *) gl_func_fflush_stdin='(-1)' ;;
93 esac
94 AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin],
95 [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008,
96 0 if fflush is known to not work, -1 if unknown.])
97])
98
99# Prerequisites of lib/fflush.c.
100AC_DEFUN([gl_PREREQ_FFLUSH], [:])
diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4
index 397f2d1f..2f0c9c4e 100644
--- a/gl/m4/float_h.m4
+++ b/gl/m4/float_h.m4
@@ -1,5 +1,5 @@
1# float_h.m4 serial 9 1# float_h.m4 serial 13
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,42 +8,46 @@ AC_DEFUN([gl_FLOAT_H],
8[ 8[
9 AC_REQUIRE([AC_PROG_CC]) 9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) 10 AC_REQUIRE([AC_CANONICAL_HOST])
11 FLOAT_H= 11 GL_GENERATE_FLOAT_H=false
12 REPLACE_FLOAT_LDBL=0 12 REPLACE_FLOAT_LDBL=0
13 case "$host_os" in 13 case "$host_os" in
14 aix* | beos* | openbsd* | mirbsd* | irix*) 14 aix* | beos* | openbsd* | mirbsd* | irix*)
15 FLOAT_H=float.h 15 GL_GENERATE_FLOAT_H=true
16 ;; 16 ;;
17 freebsd*) 17 freebsd* | dragonfly*)
18 case "$host_cpu" in 18 case "$host_cpu" in
19changequote(,)dnl 19changequote(,)dnl
20 i[34567]86 ) 20 i[34567]86 )
21changequote([,])dnl 21changequote([,])dnl
22 FLOAT_H=float.h 22 GL_GENERATE_FLOAT_H=true
23 ;; 23 ;;
24 x86_64 ) 24 x86_64 )
25 # On x86_64 systems, the C compiler may still be generating 25 # On x86_64 systems, the C compiler may still be generating
26 # 32-bit code. 26 # 32-bit code.
27 AC_EGREP_CPP([yes], 27 AC_COMPILE_IFELSE(
28 [#if defined __LP64__ || defined __x86_64__ || defined __amd64__ 28 [AC_LANG_SOURCE(
29 yes 29 [[#if defined __LP64__ || defined __x86_64__ || defined __amd64__
30 #endif], 30 int ok;
31 #else
32 error fail
33 #endif
34 ]])],
31 [], 35 [],
32 [FLOAT_H=float.h]) 36 [GL_GENERATE_FLOAT_H=true])
33 ;; 37 ;;
34 esac 38 esac
35 ;; 39 ;;
36 linux*) 40 linux*)
37 case "$host_cpu" in 41 case "$host_cpu" in
38 powerpc*) 42 powerpc*)
39 FLOAT_H=float.h 43 GL_GENERATE_FLOAT_H=true
40 ;; 44 ;;
41 esac 45 esac
42 ;; 46 ;;
43 esac 47 esac
44 case "$host_os" in 48 case "$host_os" in
45 aix* | freebsd* | linux*) 49 aix* | freebsd* | dragonfly* | linux*)
46 if test -n "$FLOAT_H"; then 50 if $GL_GENERATE_FLOAT_H; then
47 REPLACE_FLOAT_LDBL=1 51 REPLACE_FLOAT_LDBL=1
48 fi 52 fi
49 ;; 53 ;;
@@ -69,14 +73,20 @@ int main ()
69 [gl_cv_func_itold_works=no], 73 [gl_cv_func_itold_works=no],
70 [case "$host" in 74 [case "$host" in
71 sparc*-*-linux*) 75 sparc*-*-linux*)
72 AC_EGREP_CPP([yes], 76 AC_COMPILE_IFELSE(
73 [#if defined __LP64__ || defined __arch64__ 77 [AC_LANG_SOURCE(
74 yes 78 [[#if defined __LP64__ || defined __arch64__
75 #endif], 79 int ok;
80 #else
81 error fail
82 #endif
83 ]])],
76 [gl_cv_func_itold_works="guessing no"], 84 [gl_cv_func_itold_works="guessing no"],
77 [gl_cv_func_itold_works="guessing yes"]) 85 [gl_cv_func_itold_works="guessing yes"])
78 ;; 86 ;;
79 *) gl_cv_func_itold_works="guessing yes" ;; 87 # Guess yes on native Windows.
88 mingw*) gl_cv_func_itold_works="guessing yes" ;;
89 *) gl_cv_func_itold_works="guessing yes" ;;
80 esac 90 esac
81 ]) 91 ])
82 ]) 92 ])
@@ -85,14 +95,12 @@ int main ()
85 REPLACE_ITOLD=1 95 REPLACE_ITOLD=1
86 dnl We add the workaround to <float.h> but also to <math.h>, 96 dnl We add the workaround to <float.h> but also to <math.h>,
87 dnl to increase the chances that the fix function gets pulled in. 97 dnl to increase the chances that the fix function gets pulled in.
88 FLOAT_H=float.h 98 GL_GENERATE_FLOAT_H=true
89 ;; 99 ;;
90 esac 100 esac
91 101
92 if test -n "$FLOAT_H"; then 102 if $GL_GENERATE_FLOAT_H; then
93 gl_NEXT_HEADERS([float.h]) 103 gl_NEXT_HEADERS([float.h])
94 fi 104 fi
95 AC_SUBST([FLOAT_H])
96 AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
97 AC_SUBST([REPLACE_ITOLD]) 105 AC_SUBST([REPLACE_ITOLD])
98]) 106])
diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4
index c892ff9c..c49ffa6b 100644
--- a/gl/m4/floorf.m4
+++ b/gl/m4/floorf.m4
@@ -1,5 +1,5 @@
1# floorf.m4 serial 13 1# floorf.m4 serial 18
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -39,7 +39,7 @@ AC_DEFUN([gl_FUNC_FLOORF],
39static float dummy (float f) { return 0; } 39static float dummy (float f) { return 0; }
40int main (int argc, char *argv[]) 40int main (int argc, char *argv[])
41{ 41{
42 float (*my_floorf) (float) = argc ? floorf : dummy; 42 float (* volatile my_floorf) (float) = argc ? floorf : dummy;
43 /* Test whether floorf (-0.0f) is -0.0f. */ 43 /* Test whether floorf (-0.0f) is -0.0f. */
44 if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof))) 44 if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof)))
45 return 1; 45 return 1;
@@ -49,10 +49,14 @@ int main (int argc, char *argv[])
49 [gl_cv_func_floorf_ieee=yes], 49 [gl_cv_func_floorf_ieee=yes],
50 [gl_cv_func_floorf_ieee=no], 50 [gl_cv_func_floorf_ieee=no],
51 [case "$host_os" in 51 [case "$host_os" in
52 # Guess yes on glibc systems. 52 # Guess yes on glibc systems.
53 *-gnu*) gl_cv_func_floorf_ieee="guessing yes" ;; 53 *-gnu* | gnu*) gl_cv_func_floorf_ieee="guessing yes" ;;
54 # If we don't know, assume the worst. 54 # Guess yes on musl systems.
55 *) gl_cv_func_floorf_ieee="guessing no" ;; 55 *-musl*) gl_cv_func_floorf_ieee="guessing yes" ;;
56 # Guess yes on native Windows.
57 mingw*) gl_cv_func_floorf_ieee="guessing yes" ;;
58 # If we don't know, obey --enable-cross-guesses.
59 *) gl_cv_func_floorf_ieee="$gl_cross_guess_normal" ;;
56 esac 60 esac
57 ]) 61 ])
58 LIBS="$save_LIBS" 62 LIBS="$save_LIBS"
diff --git a/gl/m4/fopen.m4 b/gl/m4/fopen.m4
new file mode 100644
index 00000000..9c39ff72
--- /dev/null
+++ b/gl/m4/fopen.m4
@@ -0,0 +1,149 @@
1# fopen.m4 serial 13
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FOPEN],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 case "$host_os" in
12 mingw* | pw*)
13 dnl Replace fopen, for handling of "/dev/null".
14 REPLACE_FOPEN=1
15 dnl fopen on mingw also has the trailing slash bug.
16 gl_cv_func_fopen_slash="guessing no"
17 ;;
18 *)
19 dnl fopen("foo/", "w") should not create a file when the file name has a
20 dnl trailing slash.
21 AC_CACHE_CHECK([whether fopen recognizes a trailing slash],
22 [gl_cv_func_fopen_slash],
23 [
24 AC_RUN_IFELSE(
25 [AC_LANG_SOURCE([[
26#include <stddef.h>
27#include <stdio.h>
28int main ()
29{
30 FILE *fp = fopen ("conftest.sl/", "w");
31 int result = (fp != NULL);
32 if (fp != NULL)
33 fclose (fp);
34 return result;
35}]])],
36 [gl_cv_func_fopen_slash=yes],
37 [gl_cv_func_fopen_slash=no],
38 [
39changequote(,)dnl
40 case "$host_os" in
41 aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
42 gl_cv_func_fopen_slash="guessing no" ;;
43 *)
44 gl_cv_func_fopen_slash="guessing yes" ;;
45 esac
46changequote([,])dnl
47 ])
48 rm -f conftest.sl
49 ])
50 ;;
51 esac
52 case "$gl_cv_func_fopen_slash" in
53 *no)
54 AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], [1],
55 [Define to 1 if fopen() fails to recognize a trailing slash.])
56 REPLACE_FOPEN=1
57 ;;
58 esac
59])
60
61AC_DEFUN([gl_FUNC_FOPEN_GNU],
62[
63 AC_REQUIRE([gl_FUNC_FOPEN])
64 AC_CACHE_CHECK([whether fopen supports the mode character 'x'],
65 [gl_cv_func_fopen_mode_x],
66 [rm -f conftest.x
67 AC_RUN_IFELSE(
68 [AC_LANG_SOURCE([[
69#include <stdio.h>
70#include <errno.h>
71int main ()
72{
73 FILE *fp;
74 fp = fopen ("conftest.x", "w");
75 fclose (fp);
76 fp = fopen ("conftest.x", "wx");
77 if (fp != NULL)
78 /* 'x' ignored */
79 return 1;
80 else if (errno == EEXIST)
81 return 0;
82 else
83 /* 'x' rejected */
84 return 2;
85}]])],
86 [gl_cv_func_fopen_mode_x=yes],
87 [gl_cv_func_fopen_mode_x=no],
88 [case "$host_os" in
89 # Guess yes on glibc and musl systems.
90 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*)
91 gl_cv_func_fopen_mode_x="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses.
93 *)
94 gl_cv_func_fopen_mode_x="$gl_cross_guess_normal" ;;
95 esac
96 ])
97 rm -f conftest.x
98 ])
99 AC_CACHE_CHECK([whether fopen supports the mode character 'e'],
100 [gl_cv_func_fopen_mode_e],
101 [echo foo > conftest.x
102 AC_RUN_IFELSE(
103 [AC_LANG_SOURCE([[
104#include <stdio.h>
105#include <errno.h>
106#include <fcntl.h>
107]GL_MDA_DEFINES[
108int main ()
109{
110 FILE *fp = fopen ("conftest.x", "re");
111 if (fp != NULL)
112 {
113 if (fcntl (fileno (fp), F_GETFD) & FD_CLOEXEC)
114 return 0;
115 else
116 /* 'e' ignored */
117 return 1;
118 }
119 else
120 /* 'e' rejected */
121 return 2;
122}]])],
123 [gl_cv_func_fopen_mode_e=yes],
124 [gl_cv_func_fopen_mode_e=no],
125 [case "$host_os" in
126 # Guess yes on glibc and musl systems.
127 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*)
128 gl_cv_func_fopen_mode_e="guessing yes" ;;
129 # Guess no on native Windows.
130 mingw*)
131 gl_cv_func_fopen_mode_e="guessing no" ;;
132 # If we don't know, obey --enable-cross-guesses.
133 *)
134 gl_cv_func_fopen_mode_e="$gl_cross_guess_normal" ;;
135 esac
136 ])
137 rm -f conftest.x
138 ])
139 REPLACE_FOPEN_FOR_FOPEN_GNU="$REPLACE_FOPEN"
140 case "$gl_cv_func_fopen_mode_x" in
141 *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
142 esac
143 case "$gl_cv_func_fopen_mode_e" in
144 *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
145 esac
146])
147
148# Prerequisites of lib/fopen.c.
149AC_DEFUN([gl_PREREQ_FOPEN], [:])
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4
new file mode 100644
index 00000000..b365409d
--- /dev/null
+++ b/gl/m4/fpurge.m4
@@ -0,0 +1,73 @@
1# fpurge.m4 serial 12
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FPURGE],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
12 AC_CHECK_FUNCS_ONCE([fpurge])
13 AC_CHECK_FUNCS_ONCE([__fpurge])
14 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
15 if test "x$ac_cv_func_fpurge" = xyes; then
16 HAVE_FPURGE=1
17 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune.
18 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
19 [AC_RUN_IFELSE(
20 [AC_LANG_PROGRAM(
21 [[#include <stdio.h>
22]],
23 [[FILE *f = fopen ("conftest.txt", "w+");
24 if (!f)
25 return 1;
26 if (fputc ('a', f) != 'a')
27 { fclose (f); return 2; }
28 rewind (f);
29 if (fgetc (f) != 'a')
30 { fclose (f); return 3; }
31 if (fgetc (f) != EOF)
32 { fclose (f); return 4; }
33 if (fpurge (f) != 0)
34 { fclose (f); return 5; }
35 if (putc ('b', f) != 'b')
36 { fclose (f); return 6; }
37 if (fclose (f) != 0)
38 return 7;
39 if ((f = fopen ("conftest.txt", "r")) == NULL)
40 return 8;
41 if (fgetc (f) != 'a')
42 { fclose (f); return 9; }
43 if (fgetc (f) != 'b')
44 { fclose (f); return 10; }
45 if (fgetc (f) != EOF)
46 { fclose (f); return 11; }
47 if (fclose (f) != 0)
48 return 12;
49 if (remove ("conftest.txt") != 0)
50 return 13;
51 return 0;
52 ]])],
53 [gl_cv_func_fpurge_works=yes],
54 [gl_cv_func_fpurge_works=no],
55 [case "$host_os" in
56 # Guess yes on musl systems.
57 *-musl*) gl_cv_func_fpurge_works="guessing yes" ;;
58 # Otherwise obey --enable-cross-guesses.
59 *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;;
60 esac
61 ])
62 ])
63 case "$gl_cv_func_fpurge_works" in
64 *yes) ;;
65 *) REPLACE_FPURGE=1 ;;
66 esac
67 else
68 HAVE_FPURGE=0
69 fi
70 if test "x$ac_cv_have_decl_fpurge" = xno; then
71 HAVE_DECL_FPURGE=0
72 fi
73])
diff --git a/gl/m4/sha1.m4 b/gl/m4/freading.m4
index 21c775e3..35333369 100644
--- a/gl/m4/sha1.m4
+++ b/gl/m4/freading.m4
@@ -1,12 +1,11 @@
1# sha1.m4 serial 11 1# freading.m4 serial 2
2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_SHA1], 7AC_DEFUN([gl_FUNC_FREADING],
8[ 8[
9 dnl Prerequisites of lib/sha1.c. 9 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
10 AC_REQUIRE([gl_BIGENDIAN]) 10 AC_CHECK_FUNCS_ONCE([__freading])
11 :
12]) 11])
diff --git a/gl/m4/free.m4 b/gl/m4/free.m4
new file mode 100644
index 00000000..0389dea3
--- /dev/null
+++ b/gl/m4/free.m4
@@ -0,0 +1,52 @@
1# free.m4 serial 6
2# Copyright (C) 2003-2005, 2009-2023 Free Software Foundation, Inc.
3# This file is free software; the Free Software Foundation
4# gives unlimited permission to copy and/or distribute it,
5# with or without modifications, as long as this notice is preserved.
6
7# Written by Paul Eggert and Bruno Haible.
8
9AC_DEFUN([gl_FUNC_FREE],
10[
11 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
12
13 dnl In the next release of POSIX, free must preserve errno.
14 dnl https://www.austingroupbugs.net/view.php?id=385
15 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924
16 dnl So far, we know of three platforms that do this:
17 dnl * glibc >= 2.33, thanks to the fix for this bug:
18 dnl <https://sourceware.org/bugzilla/show_bug.cgi?id=17924>
19 dnl * OpenBSD >= 4.5, thanks to this commit:
20 dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h>
21 dnl * Solaris, because its malloc() implementation is based on brk(),
22 dnl not mmap(); hence its free() implementation makes no system calls.
23 dnl For other platforms, you can only be sure if they state it in their
24 dnl documentation, or by code inspection of the free() implementation in libc.
25 AC_CACHE_CHECK([whether free is known to preserve errno],
26 [gl_cv_func_free_preserves_errno],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[#include <stdlib.h>
30 ]],
31 [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__)
32 #elif defined __OpenBSD__
33 #elif defined __sun
34 #else
35 #error "'free' is not known to preserve errno"
36 #endif
37 ]])],
38 [gl_cv_func_free_preserves_errno=yes],
39 [gl_cv_func_free_preserves_errno=no])
40 ])
41
42 case $gl_cv_func_free_preserves_errno in
43 *yes)
44 AC_DEFINE([HAVE_FREE_POSIX], [1],
45 [Define if the 'free' function is guaranteed to preserve errno.])
46 ;;
47 *) REPLACE_FREE=1 ;;
48 esac
49])
50
51# Prerequisites of lib/free.c.
52AC_DEFUN([gl_PREREQ_FREE], [:])
diff --git a/gl/m4/fseek.m4 b/gl/m4/fseek.m4
new file mode 100644
index 00000000..c5fe688c
--- /dev/null
+++ b/gl/m4/fseek.m4
@@ -0,0 +1,15 @@
1# fseek.m4 serial 4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEK],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FSEEKO])
11 dnl When fseeko needs fixes, fseek needs them too.
12 if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
13 REPLACE_FSEEK=1
14 fi
15])
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
new file mode 100644
index 00000000..05ee06bc
--- /dev/null
+++ b/gl/m4/fseeko.m4
@@ -0,0 +1,77 @@
1# fseeko.m4 serial 20
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEKO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
11 AC_REQUIRE([gl_SYS_TYPES_H])
12 AC_REQUIRE([AC_PROG_CC])
13
14 dnl Persuade glibc <stdio.h> to declare fseeko().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
18 [
19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
20]], [[fseeko (stdin, 0, 0);]])],
21 [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
22 ])
23
24 AC_CHECK_DECLS_ONCE([fseeko])
25 if test $ac_cv_have_decl_fseeko = no; then
26 HAVE_DECL_FSEEKO=0
27 fi
28
29 if test $gl_cv_func_fseeko = no; then
30 HAVE_FSEEKO=0
31 else
32 if test $WINDOWS_64_BIT_OFF_T = 1; then
33 REPLACE_FSEEKO=1
34 fi
35 if test $gl_cv_var_stdin_large_offset = no; then
36 REPLACE_FSEEKO=1
37 fi
38 m4_ifdef([gl_FUNC_FFLUSH_STDIN], [
39 gl_FUNC_FFLUSH_STDIN
40 case "$gl_cv_func_fflush_stdin" in
41 *yes) ;;
42 *) REPLACE_FSEEKO=1 ;;
43 esac
44 ])
45 fi
46])
47
48dnl Code shared by fseeko and ftello. Determine if large files are supported,
49dnl but stdin does not start as a large file by default.
50AC_DEFUN([gl_STDIN_LARGE_OFFSET],
51 [
52 AC_CACHE_CHECK([whether stdin defaults to large file offsets],
53 [gl_cv_var_stdin_large_offset],
54 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
55[[#if defined __SL64 && defined __SCLE /* cygwin */
56 /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
57 fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and
58 it is easier to do a version check than building a runtime test. */
59# include <cygwin/version.h>
60# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
61 choke me
62# endif
63#endif]])],
64 [gl_cv_var_stdin_large_offset=yes],
65 [gl_cv_var_stdin_large_offset=no])])
66])
67
68# Prerequisites of lib/fseeko.c.
69AC_DEFUN([gl_PREREQ_FSEEKO],
70[
71 dnl Native Windows has the function _fseeki64. mingw hides it in some
72 dnl circumstances, but mingw64 makes it usable again.
73 AC_CHECK_FUNCS([_fseeki64])
74 if test $ac_cv_func__fseeki64 = yes; then
75 AC_CHECK_DECLS([_fseeki64])
76 fi
77])
diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4
new file mode 100644
index 00000000..7cb2edb0
--- /dev/null
+++ b/gl/m4/fstat.m4
@@ -0,0 +1,40 @@
1# fstat.m4 serial 8
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSTAT],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
11
12 case "$host_os" in
13 mingw* | solaris*)
14 dnl On MinGW, the original stat() returns st_atime, st_mtime,
15 dnl st_ctime values that are affected by the time zone.
16 dnl Solaris stat can return a negative tv_nsec.
17 REPLACE_FSTAT=1
18 ;;
19 esac
20
21 dnl Replace fstat() for supporting the gnulib-defined open() on directories.
22 m4_ifdef([gl_FUNC_FCHDIR], [
23 gl_TEST_FCHDIR
24 if test $HAVE_FCHDIR = 0; then
25 case "$gl_cv_func_open_directory_works" in
26 *yes) ;;
27 *)
28 REPLACE_FSTAT=1
29 ;;
30 esac
31 fi
32 ])
33])
34
35# Prerequisites of lib/fstat.c and lib/stat-w32.c.
36AC_DEFUN([gl_PREREQ_FSTAT], [
37 AC_REQUIRE([gl_SYS_STAT_H])
38 AC_REQUIRE([gl_PREREQ_STAT_W32])
39 :
40])
diff --git a/gl/m4/fstypename.m4 b/gl/m4/fstypename.m4
index c72ecb80..f65c459f 100644
--- a/gl/m4/fstypename.m4
+++ b/gl/m4/fstypename.m4
@@ -6,7 +6,7 @@ dnl See if struct statfs has the f_fstypename member.
6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME. 6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME.
7dnl 7dnl
8 8
9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2013 Free Software 9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2023 Free Software
10# Foundation, Inc. 10# Foundation, Inc.
11# This file is free software; the Free Software Foundation 11# This file is free software; the Free Software Foundation
12# gives unlimited permission to copy and/or distribute it, 12# gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4
index 6277bfa5..88f3ca81 100644
--- a/gl/m4/fsusage.m4
+++ b/gl/m4/fsusage.m4
@@ -1,7 +1,7 @@
1# serial 30 1# serial 35
2# Obtaining file system usage information. 2# Obtaining file system usage information.
3 3
4# Copyright (C) 1997-1998, 2000-2001, 2003-2013 Free Software Foundation, Inc. 4# Copyright (C) 1997-1998, 2000-2001, 2003-2023 Free Software Foundation, Inc.
5# 5#
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -29,27 +29,29 @@ AC_DEFUN([gl_FSUSAGE],
29 29
30AC_DEFUN([gl_FILE_SYSTEM_USAGE], 30AC_DEFUN([gl_FILE_SYSTEM_USAGE],
31[ 31[
32dnl Enable large-file support. This has the effect of changing the size 32 dnl Enable large-file support. This has the effect of changing the size
33dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on 33 dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on
34dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size 34 dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size
35dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on 35 dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on
36dnl Mac OS X >= 10.5 (32-bit mode). 36 dnl Mac OS X >= 10.5 (32-bit mode).
37AC_REQUIRE([AC_SYS_LARGEFILE]) 37 AC_REQUIRE([AC_SYS_LARGEFILE])
38 38
39AC_MSG_NOTICE([checking how to get file system space usage]) 39 ac_fsusage_space=no
40ac_fsusage_space=no
41 40
42# Perform only the link test since it seems there are no variants of the 41 # Perform only the link test since it seems there are no variants of the
43# statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs]) 42 # statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs])
44# because that got a false positive on SCO OSR5. Adding the declaration 43 # because that got a false positive on SCO OSR5. Adding the declaration
45# of a 'struct statvfs' causes this test to fail (as it should) on such 44 # of a 'struct statvfs' causes this test to fail (as it should) on such
46# systems. That system is reported to work fine with STAT_STATFS4 which 45 # systems. That system is reported to work fine with STAT_STATFS4 which
47# is what it gets when this test fails. 46 # is what it gets when this test fails.
48if test $ac_fsusage_space = no; then 47 if test $ac_fsusage_space = no; then
49 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 48 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
50 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. 49 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS.
51 AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], 50 AC_CACHE_CHECK([for statvfs function (SVR4)],
52 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 51 [fu_cv_sys_stat_statvfs],
52 [AC_LINK_IFELSE(
53 [AC_LANG_PROGRAM([[
54#include <sys/types.h>
53#ifdef __osf__ 55#ifdef __osf__
54"Do not use Tru64's statvfs implementation" 56"Do not use Tru64's statvfs implementation"
55#endif 57#endif
@@ -68,45 +70,47 @@ struct statvfs fsd;
68int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1]; 70int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
69#endif 71#endif
70]], 72]],
71 [[statvfs (0, &fsd);]])], 73 [[statvfs (0, &fsd);]])],
72 [fu_cv_sys_stat_statvfs=yes], 74 [fu_cv_sys_stat_statvfs=yes],
73 [fu_cv_sys_stat_statvfs=no])]) 75 [fu_cv_sys_stat_statvfs=no])
74 if test $fu_cv_sys_stat_statvfs = yes; then
75 ac_fsusage_space=yes
76 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
77 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
78 # statvfs with large-file support is already equivalent to statvfs64.
79 AC_CACHE_CHECK([whether to use statvfs64],
80 [fu_cv_sys_stat_statvfs64],
81 [AC_LINK_IFELSE(
82 [AC_LANG_PROGRAM(
83 [[#include <sys/types.h>
84 #include <sys/statvfs.h>
85 struct statvfs64 fsd;
86 int check_f_blocks_larger_in_statvfs64
87 [sizeof (((struct statvfs64 *) 0)->f_blocks)
88 > sizeof (((struct statvfs *) 0)->f_blocks)
89 ? 1 : -1];
90 ]],
91 [[statvfs64 (0, &fsd);]])],
92 [fu_cv_sys_stat_statvfs64=yes],
93 [fu_cv_sys_stat_statvfs64=no])
94 ]) 76 ])
95 if test $fu_cv_sys_stat_statvfs64 = yes; then 77 if test $fu_cv_sys_stat_statvfs = yes; then
96 AC_DEFINE([STAT_STATVFS64], [1], 78 ac_fsusage_space=yes
97 [ Define if statvfs64 should be preferred over statvfs.]) 79 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
98 else 80 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
99 AC_DEFINE([STAT_STATVFS], [1], 81 # statvfs with large-file support is already equivalent to statvfs64.
100 [ Define if there is a function named statvfs. (SVR4)]) 82 AC_CACHE_CHECK([whether to use statvfs64],
83 [fu_cv_sys_stat_statvfs64],
84 [AC_LINK_IFELSE(
85 [AC_LANG_PROGRAM(
86 [[#include <sys/types.h>
87 #include <sys/statvfs.h>
88 struct statvfs64 fsd;
89 int check_f_blocks_larger_in_statvfs64
90 [sizeof (((struct statvfs64 *) 0)->f_blocks)
91 > sizeof (((struct statvfs *) 0)->f_blocks)
92 ? 1 : -1];
93 ]],
94 [[statvfs64 (0, &fsd);]])],
95 [fu_cv_sys_stat_statvfs64=yes],
96 [fu_cv_sys_stat_statvfs64=no])
97 ])
98 if test $fu_cv_sys_stat_statvfs64 = yes; then
99 AC_DEFINE([STAT_STATVFS64], [1],
100 [Define if statvfs64 should be preferred over statvfs.])
101 else
102 AC_DEFINE([STAT_STATVFS], [1],
103 [Define if there is a function named statvfs. (SVR4)])
104 fi
101 fi 105 fi
102 fi 106 fi
103fi
104 107
105# Check for this unconditionally so we have a 108 # Check for this unconditionally so we have a
106# good fallback on glibc/Linux > 2.6 < 2.6.36 109 # good fallback on glibc/Linux > 2.6 < 2.6.36
107AC_MSG_CHECKING([for two-argument statfs with statfs.f_frsize member]) 110 AC_CACHE_CHECK([for two-argument statfs with statfs.f_frsize member],
108AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize], 111 [fu_cv_sys_stat_statfs2_frsize],
109[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 112 [AC_RUN_IFELSE(
113 [AC_LANG_SOURCE([[
110#ifdef HAVE_SYS_PARAM_H 114#ifdef HAVE_SYS_PARAM_H
111#include <sys/param.h> 115#include <sys/param.h>
112#endif 116#endif
@@ -119,26 +123,26 @@ AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize],
119 int 123 int
120 main () 124 main ()
121 { 125 {
122 struct statfs fsd; 126 struct statfs fsd;
123 fsd.f_frsize = 0; 127 fsd.f_frsize = 0;
124 return statfs (".", &fsd) != 0; 128 return statfs (".", &fsd) != 0;
125 }]])], 129 }]])],
126 [fu_cv_sys_stat_statfs2_frsize=yes], 130 [fu_cv_sys_stat_statfs2_frsize=yes],
127 [fu_cv_sys_stat_statfs2_frsize=no], 131 [fu_cv_sys_stat_statfs2_frsize=no],
128 [fu_cv_sys_stat_statfs2_frsize=no])]) 132 [fu_cv_sys_stat_statfs2_frsize=no])
129AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_frsize]) 133 ])
130if test $fu_cv_sys_stat_statfs2_frsize = yes; then 134 if test $fu_cv_sys_stat_statfs2_frsize = yes; then
131 ac_fsusage_space=yes 135 ac_fsusage_space=yes
132 AC_DEFINE([STAT_STATFS2_FRSIZE], [1], 136 AC_DEFINE([STAT_STATFS2_FRSIZE], [1],
133[ Define if statfs takes 2 args and struct statfs has a field named f_frsize. 137 [Define if statfs takes 2 args and struct statfs has a field named f_frsize.
134 (glibc/Linux > 2.6)]) 138 (glibc/Linux > 2.6)])
135fi 139 fi
136 140
137if test $ac_fsusage_space = no; then 141 if test $ac_fsusage_space = no; then
138 # DEC Alpha running OSF/1 142 # DEC Alpha running OSF/1
139 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) 143 AC_CACHE_CHECK([for 3-argument statfs function (DEC OSF/1)],
140 AC_CACHE_VAL([fu_cv_sys_stat_statfs3_osf1], 144 [fu_cv_sys_stat_statfs3_osf1],
141 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 145 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
142#include <sys/param.h> 146#include <sys/param.h>
143#include <sys/types.h> 147#include <sys/types.h>
144#include <sys/mount.h> 148#include <sys/mount.h>
@@ -149,28 +153,27 @@ if test $ac_fsusage_space = no; then
149 fsd.f_fsize = 0; 153 fsd.f_fsize = 0;
150 return statfs (".", &fsd, sizeof (struct statfs)) != 0; 154 return statfs (".", &fsd, sizeof (struct statfs)) != 0;
151 }]])], 155 }]])],
152 [fu_cv_sys_stat_statfs3_osf1=yes], 156 [fu_cv_sys_stat_statfs3_osf1=yes],
153 [fu_cv_sys_stat_statfs3_osf1=no], 157 [fu_cv_sys_stat_statfs3_osf1=no],
154 [fu_cv_sys_stat_statfs3_osf1=no])]) 158 [fu_cv_sys_stat_statfs3_osf1=no])
155 AC_MSG_RESULT([$fu_cv_sys_stat_statfs3_osf1]) 159 ])
156 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then 160 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
157 ac_fsusage_space=yes 161 ac_fsusage_space=yes
158 AC_DEFINE([STAT_STATFS3_OSF1], [1], 162 AC_DEFINE([STAT_STATFS3_OSF1], [1],
159 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)]) 163 [Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
164 fi
160 fi 165 fi
161fi
162 166
163if test $ac_fsusage_space = no; then 167 if test $ac_fsusage_space = no; then
164 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. 168 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
165 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 169 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
166 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) 170 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.)
167 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and 171 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
168 # <sys/vfs.h>.) 172 # <sys/vfs.h>.)
169 # (On Solaris, statfs has 4 arguments.) 173 # (On Solaris, statfs has 4 arguments.)
170 AC_MSG_CHECKING([for two-argument statfs with statfs.f_bsize dnl 174 AC_CACHE_CHECK([for two-argument statfs with statfs.f_bsize member (AIX, 4.3BSD)],
171member (AIX, 4.3BSD)]) 175 [fu_cv_sys_stat_statfs2_bsize],
172 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize], 176 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
173 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
174#ifdef HAVE_SYS_PARAM_H 177#ifdef HAVE_SYS_PARAM_H
175#include <sys/param.h> 178#include <sys/param.h>
176#endif 179#endif
@@ -183,88 +186,56 @@ member (AIX, 4.3BSD)])
183 int 186 int
184 main () 187 main ()
185 { 188 {
186 struct statfs fsd; 189 struct statfs fsd;
187 fsd.f_bsize = 0; 190 fsd.f_bsize = 0;
188 return statfs (".", &fsd) != 0; 191 return statfs (".", &fsd) != 0;
189 }]])], 192 }]])],
190 [fu_cv_sys_stat_statfs2_bsize=yes], 193 [fu_cv_sys_stat_statfs2_bsize=yes],
191 [fu_cv_sys_stat_statfs2_bsize=no], 194 [fu_cv_sys_stat_statfs2_bsize=no],
192 [fu_cv_sys_stat_statfs2_bsize=no])]) 195 [fu_cv_sys_stat_statfs2_bsize=no])
193 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize]) 196 ])
194 if test $fu_cv_sys_stat_statfs2_bsize = yes; then 197 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
195 ac_fsusage_space=yes 198 ac_fsusage_space=yes
196 AC_DEFINE([STAT_STATFS2_BSIZE], [1], 199 AC_DEFINE([STAT_STATFS2_BSIZE], [1],
197[ Define if statfs takes 2 args and struct statfs has a field named f_bsize. 200 [Define if statfs takes 2 args and struct statfs has a field named f_bsize.
198 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)]) 201 (4.3BSD, SunOS 4, HP-UX)])
202 fi
199 fi 203 fi
200fi
201 204
202if test $ac_fsusage_space = no; then 205 if test $ac_fsusage_space = no; then
203 # SVR3 206 # SVR3
204 # (Solaris already handled above.) 207 # (Solaris already handled above.)
205 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) 208 AC_CACHE_CHECK([for four-argument statfs (SVR3)],
206 AC_CACHE_VAL([fu_cv_sys_stat_statfs4], 209 [fu_cv_sys_stat_statfs4],
207 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 210 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
208#include <sys/types.h> 211#include <sys/types.h>
209#include <sys/statfs.h> 212#include <sys/statfs.h>
210 int 213 int
211 main () 214 main ()
212 { 215 {
213 struct statfs fsd; 216 struct statfs fsd;
214 return statfs (".", &fsd, sizeof fsd, 0) != 0; 217 return statfs (".", &fsd, sizeof fsd, 0) != 0;
215 }]])],
216 [fu_cv_sys_stat_statfs4=yes],
217 [fu_cv_sys_stat_statfs4=no],
218 [fu_cv_sys_stat_statfs4=no])])
219 AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
220 if test $fu_cv_sys_stat_statfs4 = yes; then
221 ac_fsusage_space=yes
222 AC_DEFINE([STAT_STATFS4], [1],
223 [ Define if statfs takes 4 args. (SVR3, Dynix, old Irix, old AIX, Dolphin)])
224 fi
225fi
226
227if test $ac_fsusage_space = no; then
228 # 4.4BSD and older NetBSD
229 # (OSF/1 already handled above.)
230 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
231 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
232 # <sys/mount.h>.)
233 AC_MSG_CHECKING([for two-argument statfs with statfs.f_fsize dnl
234member (4.4BSD and NetBSD)])
235 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize],
236 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
237#include <sys/types.h>
238#ifdef HAVE_SYS_PARAM_H
239#include <sys/param.h>
240#endif
241#ifdef HAVE_SYS_MOUNT_H
242#include <sys/mount.h>
243#endif
244 int
245 main ()
246 {
247 struct statfs fsd;
248 fsd.f_fsize = 0;
249 return statfs (".", &fsd) != 0;
250 }]])], 218 }]])],
251 [fu_cv_sys_stat_statfs2_fsize=yes], 219 [fu_cv_sys_stat_statfs4=yes],
252 [fu_cv_sys_stat_statfs2_fsize=no], 220 [fu_cv_sys_stat_statfs4=no],
253 [fu_cv_sys_stat_statfs2_fsize=no])]) 221 [fu_cv_sys_stat_statfs4=no])
254 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize]) 222 ])
255 if test $fu_cv_sys_stat_statfs2_fsize = yes; then 223 if test $fu_cv_sys_stat_statfs4 = yes; then
256 ac_fsusage_space=yes 224 ac_fsusage_space=yes
257 AC_DEFINE([STAT_STATFS2_FSIZE], [1], 225 AC_DEFINE([STAT_STATFS4], [1],
258[ Define if statfs takes 2 args and struct statfs has a field named f_fsize. 226 [Define if statfs takes 4 args. (SVR3, old Irix)])
259 (4.4BSD, NetBSD)]) 227 fi
260 fi 228 fi
261fi
262 229
263if test $ac_fsusage_space = no; then 230 if test $ac_fsusage_space = no; then
264 # Ultrix 231 # 4.4BSD and older NetBSD
265 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) 232 # (OSF/1 already handled above.)
266 AC_CACHE_VAL([fu_cv_sys_stat_fs_data], 233 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
267 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 234 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
235 # <sys/mount.h>.)
236 AC_CACHE_CHECK([for two-argument statfs with statfs.f_fsize member (4.4BSD and NetBSD)],
237 [fu_cv_sys_stat_statfs2_fsize],
238 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
268#include <sys/types.h> 239#include <sys/types.h>
269#ifdef HAVE_SYS_PARAM_H 240#ifdef HAVE_SYS_PARAM_H
270#include <sys/param.h> 241#include <sys/param.h>
@@ -272,41 +243,26 @@ if test $ac_fsusage_space = no; then
272#ifdef HAVE_SYS_MOUNT_H 243#ifdef HAVE_SYS_MOUNT_H
273#include <sys/mount.h> 244#include <sys/mount.h>
274#endif 245#endif
275#ifdef HAVE_SYS_FS_TYPES_H
276#include <sys/fs_types.h>
277#endif
278 int 246 int
279 main () 247 main ()
280 { 248 {
281 struct fs_data fsd; 249 struct statfs fsd;
282 /* Ultrix's statfs returns 1 for success, 250 fsd.f_fsize = 0;
283 0 for not mounted, -1 for failure. */ 251 return statfs (".", &fsd) != 0;
284 return statfs (".", &fsd) != 1;
285 }]])], 252 }]])],
286 [fu_cv_sys_stat_fs_data=yes], 253 [fu_cv_sys_stat_statfs2_fsize=yes],
287 [fu_cv_sys_stat_fs_data=no], 254 [fu_cv_sys_stat_statfs2_fsize=no],
288 [fu_cv_sys_stat_fs_data=no])]) 255 [fu_cv_sys_stat_statfs2_fsize=no])
289 AC_MSG_RESULT([$fu_cv_sys_stat_fs_data]) 256 ])
290 if test $fu_cv_sys_stat_fs_data = yes; then 257 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
291 ac_fsusage_space=yes 258 ac_fsusage_space=yes
292 AC_DEFINE([STAT_STATFS2_FS_DATA], [1], 259 AC_DEFINE([STAT_STATFS2_FSIZE], [1],
293[ Define if statfs takes 2 args and the second argument has 260 [Define if statfs takes 2 args and struct statfs has a field named f_fsize.
294 type struct fs_data. (Ultrix)]) 261 (4.4BSD, NetBSD)])
262 fi
295 fi 263 fi
296fi
297 264
298if test $ac_fsusage_space = no; then 265 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
299 # SVR2
300 # (AIX, HP-UX, OSF/1 already handled above.)
301 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h>
302 ]])],
303 [AC_DEFINE([STAT_READ_FILSYS], [1],
304 [Define if there is no specific function for reading file systems usage
305 information and you have the <sys/filsys.h> header file. (SVR2)])
306 ac_fsusage_space=yes])
307fi
308
309AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
310 266
311]) 267])
312 268
@@ -316,18 +272,22 @@ AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
316# enable the work-around code in fsusage.c. 272# enable the work-around code in fsusage.c.
317AC_DEFUN([gl_STATFS_TRUNCATES], 273AC_DEFUN([gl_STATFS_TRUNCATES],
318[ 274[
319 AC_MSG_CHECKING([for statfs that truncates block counts]) 275 AC_CACHE_CHECK([for statfs that truncates block counts],
320 AC_CACHE_VAL([fu_cv_sys_truncating_statfs], 276 [fu_cv_sys_truncating_statfs],
321 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 277 [AC_COMPILE_IFELSE(
278 [AC_LANG_PROGRAM([[
322#if !defined(sun) && !defined(__sun) 279#if !defined(sun) && !defined(__sun)
323choke -- this is a workaround for a Sun-specific problem 280choke -- this is a workaround for a Sun-specific problem
324#endif 281#endif
325#include <sys/types.h> 282#include <sys/types.h>
326#include <sys/vfs.h>]], 283#include <sys/vfs.h>
327 [[struct statfs t; long c = *(t.f_spare); 284 ]],
328 if (c) return 0;]])], 285 [[struct statfs t; long c = *(t.f_spare);
329 [fu_cv_sys_truncating_statfs=yes], 286 if (c) return 0;
330 [fu_cv_sys_truncating_statfs=no])]) 287 ]])],
288 [fu_cv_sys_truncating_statfs=yes],
289 [fu_cv_sys_truncating_statfs=no])
290 ])
331 if test $fu_cv_sys_truncating_statfs = yes; then 291 if test $fu_cv_sys_truncating_statfs = yes; then
332 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1], 292 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1],
333 [Define if the block counts reported by statfs may be truncated to 2GB 293 [Define if the block counts reported by statfs may be truncated to 2GB
@@ -335,13 +295,12 @@ choke -- this is a workaround for a Sun-specific problem
335 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. 295 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
336 SunOS 4.1.1 seems not to be affected.)]) 296 SunOS 4.1.1 seems not to be affected.)])
337 fi 297 fi
338 AC_MSG_RESULT([$fu_cv_sys_truncating_statfs])
339]) 298])
340 299
341 300
342# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE. 301# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
343AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], 302AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
344[ 303[
345 AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h]) 304 AC_CHECK_HEADERS([sys/fs/s5param.h sys/statfs.h])
346 gl_STATFS_TRUNCATES 305 gl_STATFS_TRUNCATES
347]) 306])
diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4
new file mode 100644
index 00000000..79f1aaf2
--- /dev/null
+++ b/gl/m4/ftell.m4
@@ -0,0 +1,15 @@
1# ftell.m4 serial 3
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELL],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FTELLO])
11 dnl When ftello needs fixes, ftell needs them too.
12 if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
13 REPLACE_FTELL=1
14 fi
15])
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4
new file mode 100644
index 00000000..4901b168
--- /dev/null
+++ b/gl/m4/ftello.m4
@@ -0,0 +1,151 @@
1# ftello.m4 serial 14
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELLO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_PROG_CC])
11 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
12 AC_REQUIRE([gl_SYS_TYPES_H])
13
14 dnl Persuade glibc <stdio.h> to declare ftello().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CHECK_DECLS_ONCE([ftello])
18 if test $ac_cv_have_decl_ftello = no; then
19 HAVE_DECL_FTELLO=0
20 fi
21
22 AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello],
23 [
24 AC_LINK_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[#include <stdio.h>]],
27 [[ftello (stdin);]])],
28 [gl_cv_func_ftello=yes],
29 [gl_cv_func_ftello=no])
30 ])
31 if test $gl_cv_func_ftello = no; then
32 HAVE_FTELLO=0
33 else
34 if test $WINDOWS_64_BIT_OFF_T = 1; then
35 REPLACE_FTELLO=1
36 fi
37 if test $gl_cv_var_stdin_large_offset = no; then
38 REPLACE_FTELLO=1
39 fi
40 if test $REPLACE_FTELLO = 0; then
41 dnl Detect bug on Solaris.
42 dnl ftell and ftello produce incorrect results after putc that followed a
43 dnl getc call that reached EOF on Solaris. This is because the _IOREAD
44 dnl flag does not get cleared in this case, even though _IOWRT gets set,
45 dnl and ftell and ftello look whether the _IOREAD flag is set.
46 AC_REQUIRE([AC_CANONICAL_HOST])
47 AC_CACHE_CHECK([whether ftello works],
48 [gl_cv_func_ftello_works],
49 [
50 dnl Initial guess, used when cross-compiling or when /dev/tty cannot
51 dnl be opened.
52changequote(,)dnl
53 case "$host_os" in
54 # Guess no on Solaris.
55 solaris*) gl_cv_func_ftello_works="guessing no" ;;
56 # Guess yes on native Windows.
57 mingw*) gl_cv_func_ftello_works="guessing yes" ;;
58 # Guess yes otherwise.
59 *) gl_cv_func_ftello_works="guessing yes" ;;
60 esac
61changequote([,])dnl
62 AC_RUN_IFELSE(
63 [AC_LANG_SOURCE([[
64#include <stdio.h>
65#include <stdlib.h>
66#include <string.h>
67#define TESTFILE "conftest.tmp"
68int
69main (void)
70{
71 FILE *fp;
72
73 /* Create a file with some contents. */
74 fp = fopen (TESTFILE, "w");
75 if (fp == NULL)
76 return 70;
77 if (fwrite ("foogarsh", 1, 8, fp) < 8)
78 { fclose (fp); return 71; }
79 if (fclose (fp))
80 return 72;
81
82 /* The file's contents is now "foogarsh". */
83
84 /* Try writing after reading to EOF. */
85 fp = fopen (TESTFILE, "r+");
86 if (fp == NULL)
87 return 73;
88 if (fseek (fp, -1, SEEK_END))
89 { fclose (fp); return 74; }
90 if (!(getc (fp) == 'h'))
91 { fclose (fp); return 1; }
92 if (!(getc (fp) == EOF))
93 { fclose (fp); return 2; }
94 if (!(ftell (fp) == 8))
95 { fclose (fp); return 3; }
96 if (!(ftell (fp) == 8))
97 { fclose (fp); return 4; }
98 if (!(putc ('!', fp) == '!'))
99 { fclose (fp); return 5; }
100 if (!(ftell (fp) == 9))
101 { fclose (fp); return 6; }
102 if (!(fclose (fp) == 0))
103 return 7;
104 fp = fopen (TESTFILE, "r");
105 if (fp == NULL)
106 return 75;
107 {
108 char buf[10];
109 if (!(fread (buf, 1, 10, fp) == 9))
110 { fclose (fp); return 10; }
111 if (!(memcmp (buf, "foogarsh!", 9) == 0))
112 { fclose (fp); return 11; }
113 }
114 if (!(fclose (fp) == 0))
115 return 12;
116
117 /* The file's contents is now "foogarsh!". */
118
119 return 0;
120}]])],
121 [gl_cv_func_ftello_works=yes],
122 [gl_cv_func_ftello_works=no], [:])
123 ])
124 case "$gl_cv_func_ftello_works" in
125 *yes) ;;
126 *)
127 REPLACE_FTELLO=1
128 AC_DEFINE([FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE], [1],
129 [Define to 1 if the system's ftello function has the Solaris bug.])
130 ;;
131 esac
132 fi
133 if test $REPLACE_FTELLO = 0; then
134 dnl Detect bug on macOS >= 10.15.
135 gl_FUNC_UNGETC_WORKS
136 if test $gl_ftello_broken_after_ungetc = yes; then
137 REPLACE_FTELLO=1
138 AC_DEFINE([FTELLO_BROKEN_AFTER_UNGETC], [1],
139 [Define to 1 if the system's ftello function has the macOS bug.])
140 fi
141 fi
142 fi
143])
144
145# Prerequisites of lib/ftello.c.
146AC_DEFUN([gl_PREREQ_FTELLO],
147[
148 dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64
149 dnl makes it usable again.
150 AC_CHECK_FUNCS([_ftelli64])
151])
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 1d631f8c..15f09ffb 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,14 +1,13 @@
1# getaddrinfo.m4 serial 30 1# getaddrinfo.m4 serial 34
2dnl Copyright (C) 2004-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_GETADDRINFO], 7AC_DEFUN([gl_GETADDRINFO],
8[ 8[
9 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 9 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
10 AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H 10 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H
11 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
12 GETADDRINFO_LIB= 11 GETADDRINFO_LIB=
13 gai_saved_LIBS="$LIBS" 12 gai_saved_LIBS="$LIBS"
14 13
@@ -55,10 +54,40 @@ AC_DEFUN([gl_GETADDRINFO],
55 if test "$gl_cv_w32_getaddrinfo" = "yes"; then 54 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
56 GETADDRINFO_LIB="-lws2_32" 55 GETADDRINFO_LIB="-lws2_32"
57 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB" 56 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
57 dnl Check for correct signature, in particular for a cdecl-compatible
58 dnl calling convention.
59 AC_CACHE_CHECK([for getaddrinfo with POSIX signature],
60 [gl_cv_func_getaddrinfo_posix_signature],
61 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
62#include <sys/types.h>
63#ifdef HAVE_SYS_SOCKET_H
64#include <sys/socket.h>
65#endif
66#ifdef HAVE_NETDB_H
67#include <netdb.h>
68#endif
69#ifdef HAVE_WS2TCPIP_H
70#include <ws2tcpip.h>
71#endif
72#include <stddef.h>
73extern
74#ifdef __cplusplus
75"C"
76#endif
77int getaddrinfo (const char *, const char *, const struct addrinfo *, struct addrinfo **);
78]])],
79 [gl_cv_func_getaddrinfo_posix_signature=yes],
80 [gl_cv_func_getaddrinfo_posix_signature=no])
81 ])
82 if test $gl_cv_func_getaddrinfo_posix_signature = no; then
83 REPLACE_GETADDRINFO=1
84 fi
58 else 85 else
59 HAVE_GETADDRINFO=0 86 HAVE_GETADDRINFO=0
60 fi 87 fi
61 fi 88 fi
89 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
90 [Define to 1 if getaddrinfo exists, or to 0 otherwise.])
62 91
63 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an 92 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an
64 # inline function declared in ws2tcpip.h, so we need to get that 93 # inline function declared in ws2tcpip.h, so we need to get that
@@ -127,13 +156,13 @@ const char *gai_strerror(int);]])],
127# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c. 156# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
128AC_DEFUN([gl_PREREQ_GETADDRINFO], [ 157AC_DEFUN([gl_PREREQ_GETADDRINFO], [
129 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 158 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
130 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 159 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
131 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB 160 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
132 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB 161 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
133 AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB 162 AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB
134 AC_REQUIRE([AC_C_RESTRICT]) 163 AC_REQUIRE([AC_C_RESTRICT])
135 AC_REQUIRE([gl_SOCKET_FAMILIES]) 164 AC_REQUIRE([gl_SOCKET_FAMILIES])
136 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 165 AC_REQUIRE([gl_SYS_SOCKET_H])
137 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 166 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
138 167
139 dnl Including sys/socket.h is wrong for Windows, but Windows does not 168 dnl Including sys/socket.h is wrong for Windows, but Windows does not
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
new file mode 100644
index 00000000..9aaed202
--- /dev/null
+++ b/gl/m4/getdelim.m4
@@ -0,0 +1,111 @@
1# getdelim.m4 serial 16
2
3dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
4dnl
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8
9AC_PREREQ([2.59])
10
11AC_DEFUN([gl_FUNC_GETDELIM],
12[
13 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
14 AC_REQUIRE([AC_CANONICAL_HOST])
15
16 dnl Persuade glibc <stdio.h> to declare getdelim().
17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
18
19 AC_CHECK_DECLS_ONCE([getdelim])
20
21 AC_CHECK_FUNCS_ONCE([getdelim])
22 if test $ac_cv_func_getdelim = yes; then
23 HAVE_GETDELIM=1
24 dnl Found it in some library. Verify that it works.
25 AC_CACHE_CHECK([for working getdelim function],
26 [gl_cv_func_working_getdelim],
27 [case "$host_os" in
28 darwin*)
29 dnl On macOS 10.13, valgrind detected an out-of-bounds read during
30 dnl the GNU sed test suite:
31 dnl Invalid read of size 16
32 dnl at 0x100EE6A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
33 dnl by 0x100B7B0BD: getdelim (in /usr/lib/system/libsystem_c.dylib)
34 dnl by 0x10000B0BE: ck_getdelim (utils.c:254)
35 gl_cv_func_working_getdelim=no ;;
36 *)
37 echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
38 AC_RUN_IFELSE([AC_LANG_SOURCE([[
39# include <stdio.h>
40# include <stdlib.h>
41# include <string.h>
42 int main ()
43 {
44 FILE *in = fopen ("./conftest.data", "r");
45 if (!in)
46 return 1;
47 {
48 /* Test result for a NULL buffer and a zero size.
49 Based on a test program from Karl Heuer. */
50 char *line = NULL;
51 size_t siz = 0;
52 int len = getdelim (&line, &siz, '\n', in);
53 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
54 { free (line); fclose (in); return 2; }
55 free (line);
56 }
57 {
58 /* Test result for a NULL buffer and a non-zero size.
59 This crashes on FreeBSD 8.0. */
60 char *line = NULL;
61 size_t siz = (size_t)(~0) / 4;
62 if (getdelim (&line, &siz, '\n', in) == -1)
63 { fclose (in); return 3; }
64 free (line);
65 }
66 fclose (in);
67 return 0;
68 }
69 ]])],
70 [gl_cv_func_working_getdelim=yes],
71 [gl_cv_func_working_getdelim=no],
72 [dnl We're cross compiling.
73 dnl Guess it works on glibc2 systems and musl systems.
74 AC_EGREP_CPP([Lucky GNU user],
75 [
76#include <features.h>
77#ifdef __GNU_LIBRARY__
78 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
79 Lucky GNU user
80 #endif
81#endif
82 ],
83 [gl_cv_func_working_getdelim="guessing yes"],
84 [case "$host_os" in
85 *-musl*) gl_cv_func_working_getdelim="guessing yes" ;;
86 *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;;
87 esac
88 ])
89 ])
90 ;;
91 esac
92 ])
93 case "$gl_cv_func_working_getdelim" in
94 *yes) ;;
95 *) REPLACE_GETDELIM=1 ;;
96 esac
97 else
98 HAVE_GETDELIM=0
99 fi
100
101 if test $ac_cv_have_decl_getdelim = no; then
102 HAVE_DECL_GETDELIM=0
103 fi
104])
105
106# Prerequisites of lib/getdelim.c.
107AC_DEFUN([gl_PREREQ_GETDELIM],
108[
109 AC_CHECK_FUNCS([flockfile funlockfile])
110 AC_CHECK_DECLS([getc_unlocked])
111])
diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4
new file mode 100644
index 00000000..8bcda905
--- /dev/null
+++ b/gl/m4/getdtablesize.m4
@@ -0,0 +1,63 @@
1# getdtablesize.m4 serial 8
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([getdtablesize])
12 AC_CHECK_DECLS_ONCE([getdtablesize])
13 if test $ac_cv_func_getdtablesize = yes &&
14 test $ac_cv_have_decl_getdtablesize = yes; then
15 AC_CACHE_CHECK([whether getdtablesize works],
16 [gl_cv_func_getdtablesize_works],
17 [dnl There are two concepts: the "maximum possible file descriptor value + 1"
18 dnl and the "maximum number of open file descriptors in a process".
19 dnl Per SUSv2 and POSIX, getdtablesize() should return the first one.
20 dnl On most platforms, the first and the second concept are the same.
21 dnl On OpenVMS, however, they are different and getdtablesize() returns
22 dnl the second one; thus the test below fails. But we don't care
23 dnl because there's no good way to write a replacement getdtablesize().
24 case "$host_os" in
25 vms*) gl_cv_func_getdtablesize_works="no (limitation)" ;;
26 *)
27 dnl Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft
28 dnl limit up to an unchangeable hard limit; all other platforms
29 dnl correctly require setrlimit before getdtablesize() can report
30 dnl a larger value.
31 AC_RUN_IFELSE([
32 AC_LANG_PROGRAM(
33 [[#include <unistd.h>]
34 GL_MDA_DEFINES
35 ],
36 [[int size = getdtablesize();
37 if (dup2 (0, getdtablesize()) != -1)
38 return 1;
39 if (size != getdtablesize())
40 return 2;
41 ]])],
42 [gl_cv_func_getdtablesize_works=yes],
43 [gl_cv_func_getdtablesize_works=no],
44 [case "$host_os" in
45 cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
46 gl_cv_func_getdtablesize_works="guessing no" ;;
47 *) gl_cv_func_getdtablesize_works="guessing yes" ;;
48 esac
49 ])
50 ;;
51 esac
52 ])
53 case "$gl_cv_func_getdtablesize_works" in
54 *yes | "no (limitation)") ;;
55 *) REPLACE_GETDTABLESIZE=1 ;;
56 esac
57 else
58 HAVE_GETDTABLESIZE=0
59 fi
60])
61
62# Prerequisites of lib/getdtablesize.c.
63AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])
diff --git a/gl/m4/gethostname.m4 b/gl/m4/gethostname.m4
index 7413f9e3..63f5f636 100644
--- a/gl/m4/gethostname.m4
+++ b/gl/m4/gethostname.m4
@@ -1,5 +1,5 @@
1# gethostname.m4 serial 13 1# gethostname.m4 serial 15
2dnl Copyright (C) 2002, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -48,7 +48,7 @@ AC_DEFUN([gl_PREREQ_HOST_NAME_MAX], [
48 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead. 48 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead.
49 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead. 49 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead.
50 dnl - On mingw, use 256, because 50 dnl - On mingw, use 256, because
51 dnl <http://msdn.microsoft.com/en-us/library/ms738527.aspx> says: 51 dnl <https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-gethostname> says:
52 dnl "if a buffer of 256 bytes is passed in the name parameter and 52 dnl "if a buffer of 256 bytes is passed in the name parameter and
53 dnl the namelen parameter is set to 256, the buffer size will always 53 dnl the namelen parameter is set to 256, the buffer size will always
54 dnl be adequate." 54 dnl be adequate."
@@ -74,7 +74,7 @@ lucky
74 dnl mingw. 74 dnl mingw.
75 gl_cv_decl_HOST_NAME_MAX=256 75 gl_cv_decl_HOST_NAME_MAX=256
76 else 76 else
77 _AC_COMPUTE_INT([MAXHOSTNAMELEN], [gl_cv_decl_HOST_NAME_MAX], [ 77 AC_COMPUTE_INT([gl_cv_decl_HOST_NAME_MAX], [MAXHOSTNAMELEN], [
78#include <sys/types.h> 78#include <sys/types.h>
79#if HAVE_SYS_PARAM_H 79#if HAVE_SYS_PARAM_H
80# include <sys/param.h> 80# include <sys/param.h>
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
new file mode 100644
index 00000000..03569f06
--- /dev/null
+++ b/gl/m4/getline.m4
@@ -0,0 +1,109 @@
1# getline.m4 serial 30
2
3dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation,
4dnl Inc.
5dnl
6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved.
9
10AC_PREREQ([2.59])
11
12dnl See if there's a working, system-supplied version of the getline function.
13dnl We can't just do AC_REPLACE_FUNCS([getline]) because some systems
14dnl have a function by that name in -linet that doesn't have anything
15dnl to do with the function we need.
16AC_DEFUN([gl_FUNC_GETLINE],
17[
18 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
20
21 dnl Persuade glibc <stdio.h> to declare getline().
22 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
23
24 AC_CHECK_DECLS_ONCE([getline])
25
26 gl_getline_needs_run_time_check=no
27 AC_CHECK_FUNC([getline],
28 [dnl Found it in some library. Verify that it works.
29 gl_getline_needs_run_time_check=yes],
30 [am_cv_func_working_getline=no])
31 if test $gl_getline_needs_run_time_check = yes; then
32 AC_CACHE_CHECK([for working getline function],
33 [am_cv_func_working_getline],
34 [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
35 AC_RUN_IFELSE([AC_LANG_SOURCE([[
36# include <stdio.h>
37# include <stdlib.h>
38# include <string.h>
39 int main ()
40 {
41 FILE *in = fopen ("./conftest.data", "r");
42 if (!in)
43 return 1;
44 {
45 /* Test result for a NULL buffer and a zero size.
46 Based on a test program from Karl Heuer. */
47 char *line = NULL;
48 size_t siz = 0;
49 int len = getline (&line, &siz, in);
50 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
51 { free (line); fclose (in); return 2; }
52 free (line);
53 }
54 {
55 /* Test result for a NULL buffer and a non-zero size.
56 This crashes on FreeBSD 8.0. */
57 char *line = NULL;
58 size_t siz = (size_t)(~0) / 4;
59 if (getline (&line, &siz, in) == -1)
60 { fclose (in); return 3; }
61 free (line);
62 }
63 fclose (in);
64 return 0;
65 }
66 ]])],
67 [am_cv_func_working_getline=yes],
68 [am_cv_func_working_getline=no],
69 [dnl We're cross compiling.
70 dnl Guess it works on glibc2 systems and musl systems.
71 AC_EGREP_CPP([Lucky GNU user],
72 [
73#include <features.h>
74#ifdef __GNU_LIBRARY__
75 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
76 Lucky GNU user
77 #endif
78#endif
79 ],
80 [am_cv_func_working_getline="guessing yes"],
81 [case "$host_os" in
82 *-musl*) am_cv_func_working_getline="guessing yes" ;;
83 *) am_cv_func_working_getline="$gl_cross_guess_normal" ;;
84 esac
85 ])
86 ])
87 ])
88 fi
89
90 if test $ac_cv_have_decl_getline = no; then
91 HAVE_DECL_GETLINE=0
92 fi
93
94 case "$am_cv_func_working_getline" in
95 *yes) ;;
96 *)
97 dnl Set REPLACE_GETLINE always: Even if we have not found the broken
98 dnl getline function among $LIBS, it may exist in libinet and the
99 dnl executable may be linked with -linet.
100 REPLACE_GETLINE=1
101 ;;
102 esac
103])
104
105# Prerequisites of lib/getline.c.
106AC_DEFUN([gl_PREREQ_GETLINE],
107[
108 :
109])
diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4
index 611372aa..79e420ba 100644
--- a/gl/m4/getloadavg.m4
+++ b/gl/m4/getloadavg.m4
@@ -1,13 +1,13 @@
1# Check for getloadavg. 1# Check for getloadavg.
2 2
3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2013 Free Software 3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2023 Free Software
4# Foundation, Inc. 4# Foundation, Inc.
5 5
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved. 8# with or without modifications, as long as this notice is preserved.
9 9
10#serial 6 10#serial 10
11 11
12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. 12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
13# New applications should use gl_GETLOADAVG instead. 13# New applications should use gl_GETLOADAVG instead.
@@ -22,7 +22,7 @@ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
22 22
23gl_save_LIBS=$LIBS 23gl_save_LIBS=$LIBS
24 24
25# getloadvg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0, 25# getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7. 26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
27HAVE_GETLOADAVG=1 27HAVE_GETLOADAVG=1
28AC_CHECK_FUNC([getloadavg], [], 28AC_CHECK_FUNC([getloadavg], [],
@@ -45,7 +45,9 @@ AC_CHECK_FUNC([getloadavg], [],
45 # There is a commonly available library for RS/6000 AIX. 45 # There is a commonly available library for RS/6000 AIX.
46 # Since it is not a standard part of AIX, it might be installed locally. 46 # Since it is not a standard part of AIX, it might be installed locally.
47 gl_getloadavg_LIBS=$LIBS 47 gl_getloadavg_LIBS=$LIBS
48 LIBS="-L/usr/local/lib $LIBS" 48 if test $cross_compiling != yes; then
49 LIBS="-L/usr/local/lib $LIBS"
50 fi
49 AC_CHECK_LIB([getloadavg], [getloadavg], 51 AC_CHECK_LIB([getloadavg], [getloadavg],
50 [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes], 52 [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes],
51 [LIBS=$gl_getloadavg_LIBS]) 53 [LIBS=$gl_getloadavg_LIBS])
@@ -92,6 +94,9 @@ else
92fi 94fi
93AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0], 95AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
94 [[#if HAVE_SYS_LOADAVG_H 96 [[#if HAVE_SYS_LOADAVG_H
97 /* OpenIndiana has a bug: <sys/time.h> must be included before
98 <sys/loadavg.h>. */
99 # include <sys/time.h>
95 # include <sys/loadavg.h> 100 # include <sys/loadavg.h>
96 #endif 101 #endif
97 #include <stdlib.h>]]) 102 #include <stdlib.h>]])
@@ -105,7 +110,7 @@ AC_DEFUN([gl_PREREQ_GETLOADAVG],
105[ 110[
106# Figure out what our getloadavg.c needs. 111# Figure out what our getloadavg.c needs.
107 112
108AC_CHECK_HEADERS_ONCE([sys/param.h]) 113AC_CHECK_HEADERS_ONCE([sys/param.h unistd.h])
109 114
110# On HPUX9, an unprivileged user can get load averages this way. 115# On HPUX9, an unprivileged user can get load averages this way.
111if test $gl_func_getloadavg_done = no; then 116if test $gl_func_getloadavg_done = no; then
@@ -142,7 +147,7 @@ fi
142AC_CHECK_HEADERS([nlist.h], 147AC_CHECK_HEADERS([nlist.h],
143[AC_CHECK_MEMBERS([struct nlist.n_un.n_name], 148[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
144 [], [], 149 [], [],
145 [@%:@include <nlist.h>]) 150 [#include <nlist.h>])
146 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]], 151 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
147 [[struct nlist x; 152 [[struct nlist x;
148 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME 153 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 50f45091..7981a095 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,5 +1,5 @@
1# getopt.m4 serial 44 1# getopt.m4 serial 48
2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -21,6 +21,8 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
21 REPLACE_GETOPT=1 21 REPLACE_GETOPT=1
22 fi 22 fi
23 ]) 23 ])
24 GL_GENERATE_GETOPT_H=false
25 GL_GENERATE_GETOPT_CDEFS_H=false
24 if test $REPLACE_GETOPT = 1; then 26 if test $REPLACE_GETOPT = 1; then
25 dnl Arrange for getopt.h to be created. 27 dnl Arrange for getopt.h to be created.
26 gl_GETOPT_SUBSTITUTE_HEADER 28 gl_GETOPT_SUBSTITUTE_HEADER
@@ -32,9 +34,16 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
32# getopt_long_only. 34# getopt_long_only.
33AC_DEFUN([gl_FUNC_GETOPT_GNU], 35AC_DEFUN([gl_FUNC_GETOPT_GNU],
34[ 36[
37 dnl Set the variable gl_getopt_required, so that all invocations of
38 dnl gl_GETOPT_CHECK_HEADERS in the scope of the current configure file
39 dnl will check for getopt with GNU extensions.
40 dnl This means that if one gnulib-tool invocation requests getopt-posix
41 dnl and another gnulib-tool invocation requests getopt-gnu, it is as if
42 dnl both had requested getopt-gnu.
35 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU]) 43 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
36 44
37 AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) 45 dnl No need to invoke gl_FUNC_GETOPT_POSIX here; this is automatically
46 dnl done through the module dependency getopt-gnu -> getopt-posix.
38]) 47])
39 48
40# Determine whether to replace the entire getopt facility. 49# Determine whether to replace the entire getopt facility.
@@ -295,8 +304,10 @@ dnl is ambiguous with environment values that contain newlines.
295 ]])], 304 ]])],
296 [gl_cv_func_getopt_gnu=yes], 305 [gl_cv_func_getopt_gnu=yes],
297 [gl_cv_func_getopt_gnu=no], 306 [gl_cv_func_getopt_gnu=no],
298 [dnl Cross compiling. Assume the worst, even on glibc platforms. 307 [dnl Cross compiling.
299 gl_cv_func_getopt_gnu="guessing no" 308 dnl Assume the worst, even on glibc platforms.
309 dnl But obey --enable-cross-guesses.
310 gl_cv_func_getopt_gnu="$gl_cross_guess_normal"
300 ]) 311 ])
301 case $gl_had_POSIXLY_CORRECT in 312 case $gl_had_POSIXLY_CORRECT in
302 exported) ;; 313 exported) ;;
@@ -354,15 +365,17 @@ dnl is ambiguous with environment values that contain newlines.
354 365
355AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], 366AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
356[ 367[
357 GETOPT_H=getopt.h 368 AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
369 if test $ac_cv_header_sys_cdefs_h = yes; then
370 HAVE_SYS_CDEFS_H=1
371 else
372 HAVE_SYS_CDEFS_H=0
373 fi
374 AC_SUBST([HAVE_SYS_CDEFS_H])
375
358 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], 376 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
359 [Define to rpl_ if the getopt replacement functions and variables 377 [Define to rpl_ if the getopt replacement functions and variables
360 should be used.]) 378 should be used.])
361 AC_SUBST([GETOPT_H]) 379 GL_GENERATE_GETOPT_H=true
362]) 380 GL_GENERATE_GETOPT_CDEFS_H=true
363
364# Prerequisites of lib/getopt*.
365AC_DEFUN([gl_PREREQ_GETOPT],
366[
367 AC_CHECK_DECLS_ONCE([getenv])
368]) 381])
diff --git a/gl/m4/getprogname.m4 b/gl/m4/getprogname.m4
new file mode 100644
index 00000000..b67c527c
--- /dev/null
+++ b/gl/m4/getprogname.m4
@@ -0,0 +1,43 @@
1# getprogname.m4 - check for getprogname or replacements for it
2
3# Copyright (C) 2016-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# serial 4
9
10AC_DEFUN([gl_FUNC_GETPROGNAME],
11[
12 AC_CHECK_FUNCS_ONCE([getprogname getexecname])
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 ac_found=0
15 AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [],
16 [#include <errno.h>])
17 AC_CHECK_DECLS([program_invocation_short_name], [ac_found=1], [],
18 [#include <errno.h>])
19 AC_CHECK_DECLS([__argv], [ac_found=1], [], [#include <stdlib.h>])
20
21 # Incur the cost of this test only if none of the above worked.
22 if test $ac_found = 0; then
23 # On OpenBSD 5.1, using the global __progname variable appears to be
24 # the only way to implement getprogname.
25 AC_CACHE_CHECK([whether __progname is defined in default libraries],
26 [gl_cv_var___progname],
27 [
28 gl_cv_var___progname=
29 AC_LINK_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[extern char *__progname;]],
32 [[return *__progname;]]
33 )],
34 [gl_cv_var___progname=yes]
35 )
36 ]
37 )
38 if test "$gl_cv_var___progname" = yes; then
39 AC_DEFINE([HAVE_VAR___PROGNAME], 1,
40 [Define if you have a global __progname variable])
41 fi
42 fi
43])
diff --git a/gl/m4/gettext.m4 b/gl/m4/gettext.m4
deleted file mode 100644
index 8d1f0665..00000000
--- a/gl/m4/gettext.m4
+++ /dev/null
@@ -1,401 +0,0 @@
1# gettext.m4 serial 66 (gettext-0.18.2)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
19
20dnl Macro to add for using GNU gettext.
21
22dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
23dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
24dnl default (if it is not specified or empty) is 'no-libtool'.
25dnl INTLSYMBOL should be 'external' for packages with no intl directory,
26dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
27dnl If INTLSYMBOL is 'use-libtool', then a libtool library
28dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
29dnl depending on --{enable,disable}-{shared,static} and on the presence of
30dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
31dnl $(top_builddir)/intl/libintl.a will be created.
32dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
33dnl implementations (in libc or libintl) without the ngettext() function
34dnl will be ignored. If NEEDSYMBOL is specified and is
35dnl 'need-formatstring-macros', then GNU gettext implementations that don't
36dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
37dnl INTLDIR is used to find the intl libraries. If empty,
38dnl the value '$(top_builddir)/intl/' is used.
39dnl
40dnl The result of the configuration is one of three cases:
41dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
42dnl and used.
43dnl Catalog format: GNU --> install in $(datadir)
44dnl Catalog extension: .mo after installation, .gmo in source tree
45dnl 2) GNU gettext has been found in the system's C library.
46dnl Catalog format: GNU --> install in $(datadir)
47dnl Catalog extension: .mo after installation, .gmo in source tree
48dnl 3) No internationalization, always use English msgid.
49dnl Catalog format: none
50dnl Catalog extension: none
51dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
52dnl The use of .gmo is historical (it was needed to avoid overwriting the
53dnl GNU format catalogs when building on a platform with an X/Open gettext),
54dnl but we keep it in order not to force irrelevant filename changes on the
55dnl maintainers.
56dnl
57AC_DEFUN([AM_GNU_GETTEXT],
58[
59 dnl Argument checking.
60 ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
61 [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
62])])])])])
63 ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
64 [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
65 ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
66 [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
67])])])])
68 define([gt_included_intl],
69 ifelse([$1], [external],
70 ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
71 [yes]))
72 define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
73 gt_NEEDS_INIT
74 AM_GNU_GETTEXT_NEED([$2])
75
76 AC_REQUIRE([AM_PO_SUBDIRS])dnl
77 ifelse(gt_included_intl, yes, [
78 AC_REQUIRE([AM_INTL_SUBDIR])dnl
79 ])
80
81 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
82 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
83 AC_REQUIRE([AC_LIB_RPATH])
84
85 dnl Sometimes libintl requires libiconv, so first search for libiconv.
86 dnl Ideally we would do this search only after the
87 dnl if test "$USE_NLS" = "yes"; then
88 dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
89 dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
90 dnl the configure script would need to contain the same shell code
91 dnl again, outside any 'if'. There are two solutions:
92 dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
93 dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
94 dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
95 dnl documented, we avoid it.
96 ifelse(gt_included_intl, yes, , [
97 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
98 ])
99
100 dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
101 gt_INTL_MACOSX
102
103 dnl Set USE_NLS.
104 AC_REQUIRE([AM_NLS])
105
106 ifelse(gt_included_intl, yes, [
107 BUILD_INCLUDED_LIBINTL=no
108 USE_INCLUDED_LIBINTL=no
109 ])
110 LIBINTL=
111 LTLIBINTL=
112 POSUB=
113
114 dnl Add a version number to the cache macros.
115 case " $gt_needs " in
116 *" need-formatstring-macros "*) gt_api_version=3 ;;
117 *" need-ngettext "*) gt_api_version=2 ;;
118 *) gt_api_version=1 ;;
119 esac
120 gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
121 gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
122
123 dnl If we use NLS figure out what method
124 if test "$USE_NLS" = "yes"; then
125 gt_use_preinstalled_gnugettext=no
126 ifelse(gt_included_intl, yes, [
127 AC_MSG_CHECKING([whether included gettext is requested])
128 AC_ARG_WITH([included-gettext],
129 [ --with-included-gettext use the GNU gettext library included here],
130 nls_cv_force_use_gnu_gettext=$withval,
131 nls_cv_force_use_gnu_gettext=no)
132 AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
133
134 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
135 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
136 ])
137 dnl User does not insist on using GNU NLS library. Figure out what
138 dnl to use. If GNU gettext is available we use this. Else we have
139 dnl to fall back to GNU NLS library.
140
141 if test $gt_api_version -ge 3; then
142 gt_revision_test_code='
143#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
144#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
145#endif
146changequote(,)dnl
147typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
148changequote([,])dnl
149'
150 else
151 gt_revision_test_code=
152 fi
153 if test $gt_api_version -ge 2; then
154 gt_expression_test_code=' + * ngettext ("", "", 0)'
155 else
156 gt_expression_test_code=
157 fi
158
159 AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
160 [AC_LINK_IFELSE(
161 [AC_LANG_PROGRAM(
162 [[
163#include <libintl.h>
164$gt_revision_test_code
165extern int _nl_msg_cat_cntr;
166extern int *_nl_domain_bindings;
167 ]],
168 [[
169bindtextdomain ("", "");
170return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings
171 ]])],
172 [eval "$gt_func_gnugettext_libc=yes"],
173 [eval "$gt_func_gnugettext_libc=no"])])
174
175 if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
176 dnl Sometimes libintl requires libiconv, so first search for libiconv.
177 ifelse(gt_included_intl, yes, , [
178 AM_ICONV_LINK
179 ])
180 dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
181 dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
182 dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
183 dnl even if libiconv doesn't exist.
184 AC_LIB_LINKFLAGS_BODY([intl])
185 AC_CACHE_CHECK([for GNU gettext in libintl],
186 [$gt_func_gnugettext_libintl],
187 [gt_save_CPPFLAGS="$CPPFLAGS"
188 CPPFLAGS="$CPPFLAGS $INCINTL"
189 gt_save_LIBS="$LIBS"
190 LIBS="$LIBS $LIBINTL"
191 dnl Now see whether libintl exists and does not depend on libiconv.
192 AC_LINK_IFELSE(
193 [AC_LANG_PROGRAM(
194 [[
195#include <libintl.h>
196$gt_revision_test_code
197extern int _nl_msg_cat_cntr;
198extern
199#ifdef __cplusplus
200"C"
201#endif
202const char *_nl_expand_alias (const char *);
203 ]],
204 [[
205bindtextdomain ("", "");
206return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
207 ]])],
208 [eval "$gt_func_gnugettext_libintl=yes"],
209 [eval "$gt_func_gnugettext_libintl=no"])
210 dnl Now see whether libintl exists and depends on libiconv.
211 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
212 LIBS="$LIBS $LIBICONV"
213 AC_LINK_IFELSE(
214 [AC_LANG_PROGRAM(
215 [[
216#include <libintl.h>
217$gt_revision_test_code
218extern int _nl_msg_cat_cntr;
219extern
220#ifdef __cplusplus
221"C"
222#endif
223const char *_nl_expand_alias (const char *);
224 ]],
225 [[
226bindtextdomain ("", "");
227return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
228 ]])],
229 [LIBINTL="$LIBINTL $LIBICONV"
230 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
231 eval "$gt_func_gnugettext_libintl=yes"
232 ])
233 fi
234 CPPFLAGS="$gt_save_CPPFLAGS"
235 LIBS="$gt_save_LIBS"])
236 fi
237
238 dnl If an already present or preinstalled GNU gettext() is found,
239 dnl use it. But if this macro is used in GNU gettext, and GNU
240 dnl gettext is already preinstalled in libintl, we update this
241 dnl libintl. (Cf. the install rule in intl/Makefile.in.)
242 if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
243 || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
244 && test "$PACKAGE" != gettext-runtime \
245 && test "$PACKAGE" != gettext-tools; }; then
246 gt_use_preinstalled_gnugettext=yes
247 else
248 dnl Reset the values set by searching for libintl.
249 LIBINTL=
250 LTLIBINTL=
251 INCINTL=
252 fi
253
254 ifelse(gt_included_intl, yes, [
255 if test "$gt_use_preinstalled_gnugettext" != "yes"; then
256 dnl GNU gettext is not found in the C library.
257 dnl Fall back on included GNU gettext library.
258 nls_cv_use_gnu_gettext=yes
259 fi
260 fi
261
262 if test "$nls_cv_use_gnu_gettext" = "yes"; then
263 dnl Mark actions used to generate GNU NLS library.
264 BUILD_INCLUDED_LIBINTL=yes
265 USE_INCLUDED_LIBINTL=yes
266 LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
267 LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
268 LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
269 fi
270
271 CATOBJEXT=
272 if test "$gt_use_preinstalled_gnugettext" = "yes" \
273 || test "$nls_cv_use_gnu_gettext" = "yes"; then
274 dnl Mark actions to use GNU gettext tools.
275 CATOBJEXT=.gmo
276 fi
277 ])
278
279 if test -n "$INTL_MACOSX_LIBS"; then
280 if test "$gt_use_preinstalled_gnugettext" = "yes" \
281 || test "$nls_cv_use_gnu_gettext" = "yes"; then
282 dnl Some extra flags are needed during linking.
283 LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
284 LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
285 fi
286 fi
287
288 if test "$gt_use_preinstalled_gnugettext" = "yes" \
289 || test "$nls_cv_use_gnu_gettext" = "yes"; then
290 AC_DEFINE([ENABLE_NLS], [1],
291 [Define to 1 if translation of program messages to the user's native language
292 is requested.])
293 else
294 USE_NLS=no
295 fi
296 fi
297
298 AC_MSG_CHECKING([whether to use NLS])
299 AC_MSG_RESULT([$USE_NLS])
300 if test "$USE_NLS" = "yes"; then
301 AC_MSG_CHECKING([where the gettext function comes from])
302 if test "$gt_use_preinstalled_gnugettext" = "yes"; then
303 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
304 gt_source="external libintl"
305 else
306 gt_source="libc"
307 fi
308 else
309 gt_source="included intl directory"
310 fi
311 AC_MSG_RESULT([$gt_source])
312 fi
313
314 if test "$USE_NLS" = "yes"; then
315
316 if test "$gt_use_preinstalled_gnugettext" = "yes"; then
317 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
318 AC_MSG_CHECKING([how to link with libintl])
319 AC_MSG_RESULT([$LIBINTL])
320 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
321 fi
322
323 dnl For backward compatibility. Some packages may be using this.
324 AC_DEFINE([HAVE_GETTEXT], [1],
325 [Define if the GNU gettext() function is already present or preinstalled.])
326 AC_DEFINE([HAVE_DCGETTEXT], [1],
327 [Define if the GNU dcgettext() function is already present or preinstalled.])
328 fi
329
330 dnl We need to process the po/ directory.
331 POSUB=po
332 fi
333
334 ifelse(gt_included_intl, yes, [
335 dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
336 dnl to 'yes' because some of the testsuite requires it.
337 if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
338 BUILD_INCLUDED_LIBINTL=yes
339 fi
340
341 dnl Make all variables we use known to autoconf.
342 AC_SUBST([BUILD_INCLUDED_LIBINTL])
343 AC_SUBST([USE_INCLUDED_LIBINTL])
344 AC_SUBST([CATOBJEXT])
345
346 dnl For backward compatibility. Some configure.ins may be using this.
347 nls_cv_header_intl=
348 nls_cv_header_libgt=
349
350 dnl For backward compatibility. Some Makefiles may be using this.
351 DATADIRNAME=share
352 AC_SUBST([DATADIRNAME])
353
354 dnl For backward compatibility. Some Makefiles may be using this.
355 INSTOBJEXT=.mo
356 AC_SUBST([INSTOBJEXT])
357
358 dnl For backward compatibility. Some Makefiles may be using this.
359 GENCAT=gencat
360 AC_SUBST([GENCAT])
361
362 dnl For backward compatibility. Some Makefiles may be using this.
363 INTLOBJS=
364 if test "$USE_INCLUDED_LIBINTL" = yes; then
365 INTLOBJS="\$(GETTOBJS)"
366 fi
367 AC_SUBST([INTLOBJS])
368
369 dnl Enable libtool support if the surrounding package wishes it.
370 INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
371 AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
372 ])
373
374 dnl For backward compatibility. Some Makefiles may be using this.
375 INTLLIBS="$LIBINTL"
376 AC_SUBST([INTLLIBS])
377
378 dnl Make all documented variables known to autoconf.
379 AC_SUBST([LIBINTL])
380 AC_SUBST([LTLIBINTL])
381 AC_SUBST([POSUB])
382])
383
384
385dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
386m4_define([gt_NEEDS_INIT],
387[
388 m4_divert_text([DEFAULTS], [gt_needs=])
389 m4_define([gt_NEEDS_INIT], [])
390])
391
392
393dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
394AC_DEFUN([AM_GNU_GETTEXT_NEED],
395[
396 m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
397])
398
399
400dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
401AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
diff --git a/gl/m4/gl-openssl.m4 b/gl/m4/gl-openssl.m4
new file mode 100644
index 00000000..7eab4e10
--- /dev/null
+++ b/gl/m4/gl-openssl.m4
@@ -0,0 +1,76 @@
1# gl-openssl.m4 serial 6
2dnl Copyright (C) 2013-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT],
8[
9 m4_define([gl_CRYPTO_CHECK_DEFAULT], [$1])
10])
11gl_SET_CRYPTO_CHECK_DEFAULT([no])
12
13AC_DEFUN([gl_CRYPTO_CHECK],
14[
15 dnl gnulib users set this before gl_INIT with gl_SET_CRYPTO_CHECK_DEFAULT()
16 m4_divert_once([DEFAULTS], [with_openssl_default='gl_CRYPTO_CHECK_DEFAULT'])
17
18 dnl Only clear once, so crypto routines can be checked for individually
19 m4_divert_once([DEFAULTS], [LIB_CRYPTO=])
20
21 AC_ARG_WITH([openssl],
22 [[ --with-openssl[=ARG] use libcrypto hash routines for the hash functions
23 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512.
24 Valid ARGs are:
25 'yes',
26 'no',
27 'auto' => use if any version available,
28 'auto-gpl-compat' => use if GPL compatible version
29 available,
30 'optional' => use if available
31 and warn if not available;
32 Default is ']gl_CRYPTO_CHECK_DEFAULT['.]m4_ifdef([gl_AF_ALG], [
33 Note also --with-linux-crypto, which will enable the
34 use of Linux kernel crypto routines (if available),
35 which has precedence for files.])],
36 [],
37 [with_openssl=$with_openssl_default])
38
39 AC_SUBST([LIB_CRYPTO])
40 if test "x$with_openssl" != xno; then
41 if test "x$with_openssl" = xauto-gpl-compat; then
42 AC_CACHE_CHECK([whether openssl is GPL compatible],
43 [gl_cv_openssl_gpl_compat],
44 [AC_COMPILE_IFELSE(
45 [AC_LANG_PROGRAM([[
46 #include <openssl/opensslv.h>
47 #if OPENSSL_VERSION_MAJOR < 3
48 #error "openssl >= version 3 not found"
49 #endif
50 ]])],
51 [gl_cv_openssl_gpl_compat=yes],
52 [gl_cv_openssl_gpl_compat=no])])
53 fi
54 if test "x$with_openssl" != xauto-gpl-compat ||
55 test "x$gl_cv_openssl_gpl_compat" = xyes; then
56 AC_CHECK_LIB([crypto], [$1],
57 [AC_CHECK_HEADERS(
58 m4_if([$1], [MD5], [openssl/md5.h], [openssl/sha.h]),
59 [LIB_CRYPTO=-lcrypto
60 AC_DEFINE([HAVE_OPENSSL_$1], [1],
61 [Define to 1 if libcrypto is used for $1.])])])
62 fi
63 if test "x$LIB_CRYPTO" = x; then
64 message='openssl development library not found for $1.
65 If you want to install it, first find the pre-built package name:
66 - On Debian and Debian-based systems: libssl-dev,
67 - On Red Hat distributions: openssl-devel.
68 - Other: https://repology.org/project/openssl/versions'
69 if test "x$with_openssl" = xyes; then
70 AC_MSG_ERROR([$message])
71 elif test "x$with_openssl" = xoptional; then
72 AC_MSG_WARN([$message])
73 fi
74 fi
75 fi
76])
diff --git a/gl/m4/glibc2.m4 b/gl/m4/glibc2.m4
deleted file mode 100644
index 0e506826..00000000
--- a/gl/m4/glibc2.m4
+++ /dev/null
@@ -1,31 +0,0 @@
1# glibc2.m4 serial 3
2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Test for the GNU C Library, version 2.0 or newer.
9# From Bruno Haible.
10
11AC_DEFUN([gt_GLIBC2],
12 [
13 AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer],
14 [ac_cv_gnu_library_2],
15 [AC_EGREP_CPP([Lucky GNU user],
16 [
17#include <features.h>
18#ifdef __GNU_LIBRARY__
19 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
20 Lucky GNU user
21 #endif
22#endif
23 ],
24 [ac_cv_gnu_library_2=yes],
25 [ac_cv_gnu_library_2=no])
26 ]
27 )
28 AC_SUBST([GLIBC2])
29 GLIBC2="$ac_cv_gnu_library_2"
30 ]
31)
diff --git a/gl/m4/glibc21.m4 b/gl/m4/glibc21.m4
deleted file mode 100644
index 613fb2a4..00000000
--- a/gl/m4/glibc21.m4
+++ /dev/null
@@ -1,34 +0,0 @@
1# glibc21.m4 serial 5
2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Test for the GNU C Library, version 2.1 or newer, or uClibc.
9# From Bruno Haible.
10
11AC_DEFUN([gl_GLIBC21],
12 [
13 AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
14 [ac_cv_gnu_library_2_1],
15 [AC_EGREP_CPP([Lucky],
16 [
17#include <features.h>
18#ifdef __GNU_LIBRARY__
19 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
20 Lucky GNU user
21 #endif
22#endif
23#ifdef __UCLIBC__
24 Lucky user
25#endif
26 ],
27 [ac_cv_gnu_library_2_1=yes],
28 [ac_cv_gnu_library_2_1=no])
29 ]
30 )
31 AC_SUBST([GLIBC21])
32 GLIBC21="$ac_cv_gnu_library_2_1"
33 ]
34)
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 90ad4aaa..267f0692 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -1,8 +1,8 @@
1# Copyright (C) 2002-2013 Free Software Foundation, Inc. 1# Copyright (C) 2002-2023 Free Software Foundation, Inc.
2# 2#
3# This file is free software; you can redistribute it and/or modify 3# This file is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by 4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or 5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version. 6# (at your option) any later version.
7# 7#
8# This file is distributed in the hope that it will be useful, 8# This file is distributed in the hope that it will be useful,
@@ -11,7 +11,7 @@
11# GNU General Public License for more details. 11# GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License 13# You should have received a copy of the GNU General Public License
14# along with this file. If not, see <http://www.gnu.org/licenses/>. 14# along with this file. If not, see <https://www.gnu.org/licenses/>.
15# 15#
16# As a special exception to the GNU General Public License, 16# As a special exception to the GNU General Public License,
17# this file may be distributed as part of a program that 17# this file may be distributed as part of a program that
@@ -27,13 +27,45 @@
27 27
28 28
29# Specification in the form of a command-line invocation: 29# Specification in the form of a command-line invocation:
30# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf 30# gnulib-tool --import \
31# --lib=libgnu \
32# --source-base=gl \
33# --m4-base=gl/m4 \
34# --doc-base=doc \
35# --tests-base=tests \
36# --aux-dir=build-aux \
37# --no-conditional-dependencies \
38# --no-libtool \
39# --macro-prefix=gl \
40# --no-vc-files \
41# base64 \
42# crypto/sha256 \
43# dirname \
44# environ \
45# floorf \
46# fsusage \
47# getaddrinfo \
48# gethostname \
49# getloadavg \
50# getopt-gnu \
51# gettext-h \
52# idpriv-droptemp \
53# mountlist \
54# regex \
55# setenv \
56# strcase \
57# strcasestr \
58# strsep \
59# timegm \
60# unsetenv \
61# vasprintf \
62# vsnprintf
31 63
32# Specification in the form of a few gnulib-tool.m4 macro invocations: 64# Specification in the form of a few gnulib-tool.m4 macro invocations:
33gl_LOCAL_DIR([]) 65gl_LOCAL_DIR([])
34gl_MODULES([ 66gl_MODULES([
35 base64 67 base64
36 crypto/sha1 68 crypto/sha256
37 dirname 69 dirname
38 environ 70 environ
39 floorf 71 floorf
@@ -42,7 +74,7 @@ gl_MODULES([
42 gethostname 74 gethostname
43 getloadavg 75 getloadavg
44 getopt-gnu 76 getopt-gnu
45 gettext 77 gettext-h
46 idpriv-droptemp 78 idpriv-droptemp
47 mountlist 79 mountlist
48 regex 80 regex
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 0ae5a9ec..facc3404 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,25 +1,59 @@
1# gnulib-common.m4 serial 33 1# gnulib-common.m4 serial 75a
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_PREREQ([2.62])
8
7# gl_COMMON 9# gl_COMMON
8# is expanded unconditionally through gnulib-tool magic. 10# is expanded unconditionally through gnulib-tool magic.
9AC_DEFUN([gl_COMMON], [ 11AC_DEFUN([gl_COMMON], [
10 dnl Use AC_REQUIRE here, so that the code is expanded once only. 12 dnl Use AC_REQUIRE here, so that the code is expanded once only.
11 AC_REQUIRE([gl_00GNULIB]) 13 AC_REQUIRE([gl_00GNULIB])
12 AC_REQUIRE([gl_COMMON_BODY]) 14 AC_REQUIRE([gl_COMMON_BODY])
15 AC_REQUIRE([gl_ZZGNULIB])
13]) 16])
14AC_DEFUN([gl_COMMON_BODY], [ 17AC_DEFUN([gl_COMMON_BODY], [
18 AH_VERBATIM([_GL_GNUC_PREREQ],
19[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */
20#if defined __GNUC__ && defined __GNUC_MINOR__
21# define _GL_GNUC_PREREQ(major, minor) \
22 ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
23#else
24# define _GL_GNUC_PREREQ(major, minor) 0
25#endif
26])
15 AH_VERBATIM([_Noreturn], 27 AH_VERBATIM([_Noreturn],
16[/* The _Noreturn keyword of C11. */ 28[/* The _Noreturn keyword of C11. */
17#if ! (defined _Noreturn \ 29#ifndef _Noreturn
18 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) 30# if (defined __cplusplus \
19# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ 31 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
20 || 0x5110 <= __SUNPRO_C) 32 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
33 && 0)
34 /* [[noreturn]] is not practically usable, because with it the syntax
35 extern _Noreturn void func (...);
36 would not be valid; such a declaration would only be valid with 'extern'
37 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
38 AIX system header files and several gnulib header files use precisely
39 this syntax with 'extern'. */
40# define _Noreturn [[noreturn]]
41# elif (defined __clang__ && __clang_major__ < 16 \
42 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
43 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
44 that rare LLVM bug, though you may get many false-alarm warnings. */
45# define _Noreturn
46# elif ((!defined __cplusplus || defined __clang__) \
47 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
48 || (!defined __STRICT_ANSI__ \
49 && (_GL_GNUC_PREREQ (4, 7) \
50 || (defined __apple_build_version__ \
51 ? 6000000 <= __apple_build_version__ \
52 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
53 /* _Noreturn works as-is. */
54# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
21# define _Noreturn __attribute__ ((__noreturn__)) 55# define _Noreturn __attribute__ ((__noreturn__))
22# elif defined _MSC_VER && 1200 <= _MSC_VER 56# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
23# define _Noreturn __declspec (noreturn) 57# define _Noreturn __declspec (noreturn)
24# else 58# else
25# define _Noreturn 59# define _Noreturn
@@ -36,33 +70,519 @@ AC_DEFUN([gl_COMMON_BODY], [
36#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ 70#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
37# define __GNUC_STDC_INLINE__ 1 71# define __GNUC_STDC_INLINE__ 1
38#endif]) 72#endif])
39 AH_VERBATIM([unused_parameter], 73 AH_VERBATIM([attribute],
40[/* Define as a marker that can be attached to declarations that might not 74[/* Attributes. */
41 be used. This helps to reduce warnings, such as from 75#if (defined __has_attribute \
42 GCC -Wunused-parameter. */ 76 && (!defined __clang_minor__ \
43#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 77 || (defined __apple_build_version__ \
44# define _GL_UNUSED __attribute__ ((__unused__)) 78 ? 6000000 <= __apple_build_version__ \
79 : 3 < __clang_major__ + (5 <= __clang_minor__))))
80# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
45#else 81#else
46# define _GL_UNUSED 82# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
83# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
84# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
85# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
86# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
87# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
88# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
89# define _GL_ATTR_diagnose_if 0
90# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
91# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
92# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
93# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
94# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
95# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
96# ifdef _ICC
97# define _GL_ATTR_may_alias 0
98# else
99# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
100# endif
101# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
102# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
103# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
104# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
105# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
106# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
107# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
108# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
109# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
110# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
47#endif 111#endif
48/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
49 is a misnomer outside of parameter lists. */
50#define _UNUSED_PARAMETER_ _GL_UNUSED
51 112
52/* The __pure__ attribute was added in gcc 2.96. */ 113/* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */
53#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 114#if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \
54# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 115 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)
55#else 116# pragma GCC diagnostic ignored "-Wpedantic"
56# define _GL_ATTRIBUTE_PURE /* empty */
57#endif 117#endif
58 118
59/* The __const__ attribute was added in gcc 2.95. */ 119]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead.
60#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 120[
61# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) 121/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
62#else 122 is the size of the returned memory block.
63# define _GL_ATTRIBUTE_CONST /* empty */ 123 _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
124 by the Nth argument of the function is the size of the returned memory block.
125 */
126/* Applies to: function, pointer to function, function types. */
127#ifndef _GL_ATTRIBUTE_ALLOC_SIZE
128# if _GL_HAS_ATTRIBUTE (alloc_size)
129# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
130# else
131# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
132# endif
133#endif
134
135/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
136 function and report an error if it cannot do so. */
137/* Applies to: function. */
138#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE
139# if _GL_HAS_ATTRIBUTE (always_inline)
140# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
141# else
142# define _GL_ATTRIBUTE_ALWAYS_INLINE
143# endif
144#endif
145
146/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
147 in stack traces when debugging. The compiler should omit the function from
148 stack traces. */
149/* Applies to: function. */
150#ifndef _GL_ATTRIBUTE_ARTIFICIAL
151# if _GL_HAS_ATTRIBUTE (artificial)
152# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
153# else
154# define _GL_ATTRIBUTE_ARTIFICIAL
155# endif
156#endif
157
158/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */
159/* Applies to: functions. */
160/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
161 <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
162 Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */
163#ifndef _GL_ATTRIBUTE_COLD
164# if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
165# ifndef __SUNPRO_C
166# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
167# else
168# define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
169# endif
170# else
171# define _GL_ATTRIBUTE_COLD
172# endif
173#endif
174
175/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
176 calls to the function with the same arguments.
177 This attribute is safe for a function that neither depends on nor affects
178 observable state, and always returns exactly once - e.g., does not loop
179 forever, and does not call longjmp.
180 (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */
181/* Applies to: functions. */
182#ifndef _GL_ATTRIBUTE_CONST
183# if _GL_HAS_ATTRIBUTE (const)
184# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
185# else
186# define _GL_ATTRIBUTE_CONST
187# endif
188#endif
189
190/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
191 that can be freed by passing them as the Ith argument to the
192 function F.
193 _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
194 can be freed via 'free'; it can be used only after declaring 'free'. */
195/* Applies to: functions. Cannot be used on inline functions. */
196#ifndef _GL_ATTRIBUTE_DEALLOC
197# if _GL_GNUC_PREREQ (11, 0)
198# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
199# else
200# define _GL_ATTRIBUTE_DEALLOC(f, i)
201# endif
202#endif
203/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
204 to use this earlier definition, since <stdlib.h> may not have been included
205 yet. */
206#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
207# if defined __cplusplus && defined __GNUC__ && !defined __clang__
208/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
209# define _GL_ATTRIBUTE_DEALLOC_FREE \
210 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
211# else
212# define _GL_ATTRIBUTE_DEALLOC_FREE \
213 _GL_ATTRIBUTE_DEALLOC (free, 1)
214# endif
215#endif
216
217/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
218 The compiler may warn if the entity is used. */
219/* Applies to:
220 - function, variable,
221 - struct, union, struct/union member,
222 - enumeration, enumeration item,
223 - typedef,
224 in C++ also: namespace, class, template specialization. */
225#ifndef _GL_ATTRIBUTE_DEPRECATED
226# ifdef __has_c_attribute
227# if __has_c_attribute (__deprecated__)
228# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
229# endif
230# endif
231# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated)
232# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
233# endif
234# ifndef _GL_ATTRIBUTE_DEPRECATED
235# define _GL_ATTRIBUTE_DEPRECATED
236# endif
237#endif
238
239/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
240 the function call is not optimized away.
241 _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
242 the function call is not optimized away. */
243/* Applies to: functions. */
244#if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING)
245# if _GL_HAS_ATTRIBUTE (error)
246# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
247# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
248# elif _GL_HAS_ATTRIBUTE (diagnose_if)
249# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
250# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
251# else
252# define _GL_ATTRIBUTE_ERROR(msg)
253# define _GL_ATTRIBUTE_WARNING(msg)
254# endif
255#endif
256
257/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
258 visible to debuggers etc., even with '-fwhole-program'. */
259/* Applies to: functions, variables. */
260#ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
261# if _GL_HAS_ATTRIBUTE (externally_visible)
262# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
263# else
264# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
265# endif
266#endif
267
268/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if
269 the control flow falls through to the immediately following 'case' or
270 'default' label. The compiler should not warn in this case. */
271/* Applies to: Empty statement (;), inside a 'switch' statement. */
272/* Always expands to something. */
273#ifndef _GL_ATTRIBUTE_FALLTHROUGH
274# ifdef __has_c_attribute
275# if __has_c_attribute (__fallthrough__)
276# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
277# endif
278# endif
279# if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough)
280# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
281# endif
282# ifndef _GL_ATTRIBUTE_FALLTHROUGH
283# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
284# endif
285#endif
286
287/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK))
288 declares that the STRING-INDEXth function argument is a format string of
289 style ARCHETYPE, which is one of:
290 printf, gnu_printf
291 scanf, gnu_scanf,
292 strftime, gnu_strftime,
293 strfmon,
294 or the same thing prefixed and suffixed with '__'.
295 If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
296 are suitable for the format string. */
297/* Applies to: functions. */
298#ifndef _GL_ATTRIBUTE_FORMAT
299# if _GL_HAS_ATTRIBUTE (format)
300# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
301# else
302# define _GL_ATTRIBUTE_FORMAT(spec)
303# endif
304#endif
305
306/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other
307 compilation unit, it executes code from that unit only by return or by
308 exception handling. This declaration lets the compiler optimize that unit
309 more aggressively. */
310/* Applies to: functions. */
311#ifndef _GL_ATTRIBUTE_LEAF
312# if _GL_HAS_ATTRIBUTE (leaf)
313# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
314# else
315# define _GL_ATTRIBUTE_LEAF
316# endif
317#endif
318
319/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
320 allocated memory. */
321/* Applies to: functions. */
322#ifndef _GL_ATTRIBUTE_MALLOC
323# if _GL_HAS_ATTRIBUTE (malloc)
324# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
325# else
326# define _GL_ATTRIBUTE_MALLOC
327# endif
328#endif
329
330/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the
331 same storage as pointers to other types. Thus this declaration disables
332 strict aliasing optimization. */
333/* Applies to: types. */
334/* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */
335#ifndef _GL_ATTRIBUTE_MAY_ALIAS
336# if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
337# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
338# else
339# define _GL_ATTRIBUTE_MAY_ALIAS
340# endif
341#endif
342
343/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
344 the entity is not used. The compiler should not warn if the entity is not
345 used. */
346/* Applies to:
347 - function, variable,
348 - struct, union, struct/union member,
349 - enumeration, enumeration item,
350 - typedef,
351 in C++ also: class. */
352/* In C++ and C23, this is spelled [[__maybe_unused__]].
353 GCC's syntax is __attribute__ ((__unused__)).
354 clang supports both syntaxes. */
355#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
356# ifdef __has_c_attribute
357# if __has_c_attribute (__maybe_unused__)
358# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
359# endif
360# endif
361# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
362# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
363# endif
364#endif
365/* Alternative spelling of this macro, for convenience and for
366 compatibility with glibc/include/libc-symbols.h. */
367#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
368/* Earlier spellings of this macro. */
369#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
370
371/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not
372 discard the return value. The compiler may warn if the caller does not use
373 the return value, unless the caller uses something like ignore_value. */
374/* Applies to: function, enumeration, class. */
375#ifndef _GL_ATTRIBUTE_NODISCARD
376# ifdef __has_c_attribute
377# if __has_c_attribute (__nodiscard__)
378# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
379# endif
380# endif
381# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result)
382# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
383# endif
384# ifndef _GL_ATTRIBUTE_NODISCARD
385# define _GL_ATTRIBUTE_NODISCARD
386# endif
387#endif
388
389/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the
390 function. */
391/* Applies to: functions. */
392#ifndef _GL_ATTRIBUTE_NOINLINE
393# if _GL_HAS_ATTRIBUTE (noinline)
394# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
395# else
396# define _GL_ATTRIBUTE_NOINLINE
397# endif
398#endif
399
400/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,...
401 must not be NULL.
402 _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be
403 null. */
404/* Applies to: functions. */
405#ifndef _GL_ATTRIBUTE_NONNULL
406# if _GL_HAS_ATTRIBUTE (nonnull)
407# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
408# else
409# define _GL_ATTRIBUTE_NONNULL(args)
410# endif
411#endif
412
413/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
414 not meant to be NUL-terminated. */
415/* Applies to: struct/union members and variables that are arrays of element
416 type '[[un]signed] char'. */
417#ifndef _GL_ATTRIBUTE_NONSTRING
418# if _GL_HAS_ATTRIBUTE (nonstring)
419# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
420# else
421# define _GL_ATTRIBUTE_NONSTRING
422# endif
423#endif
424
425/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
426
427/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
428 */
429/* Applies to: functions. */
430#ifndef _GL_ATTRIBUTE_NOTHROW
431# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
432# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
433# else
434# define _GL_ATTRIBUTE_NOTHROW
435# endif
436#endif
437
438/* _GL_ATTRIBUTE_PACKED declares:
439 For struct members: The member has the smallest possible alignment.
440 For struct, union, class: All members have the smallest possible alignment,
441 minimizing the memory required. */
442/* Applies to: struct members, struct, union,
443 in C++ also: class. */
444#ifndef _GL_ATTRIBUTE_PACKED
445# if _GL_HAS_ATTRIBUTE (packed)
446# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
447# else
448# define _GL_ATTRIBUTE_PACKED
449# endif
450#endif
451
452/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
453 calls to the function with the same arguments if observable state is not
454 changed between calls.
455 This attribute is safe for a function that does not affect
456 observable state, and always returns exactly once.
457 (This attribute is looser than _GL_ATTRIBUTE_CONST.) */
458/* Applies to: functions. */
459#ifndef _GL_ATTRIBUTE_PURE
460# if _GL_HAS_ATTRIBUTE (pure)
461# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
462# else
463# define _GL_ATTRIBUTE_PURE
464# endif
465#endif
466
467/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
468 a non-NULL pointer. */
469/* Applies to: functions. */
470#ifndef _GL_ATTRIBUTE_RETURNS_NONNULL
471# if _GL_HAS_ATTRIBUTE (returns_nonnull)
472# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
473# else
474# define _GL_ATTRIBUTE_RETURNS_NONNULL
475# endif
476#endif
477
478/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a
479 trailing NULL argument.
480 _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
481 _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
482/* Applies to: functions. */
483#ifndef _GL_ATTRIBUTE_SENTINEL
484# if _GL_HAS_ATTRIBUTE (sentinel)
485# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
486# else
487# define _GL_ATTRIBUTE_SENTINEL(pos)
488# endif
489#endif
490
491/* A helper macro. Don't use it directly. */
492#ifndef _GL_ATTRIBUTE_UNUSED
493# if _GL_HAS_ATTRIBUTE (unused)
494# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
495# else
496# define _GL_ATTRIBUTE_UNUSED
497# endif
498#endif
499
500]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
501[
502/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the
503 immediately preceding label is not used. The compiler should not warn
504 if the label is not used. */
505/* Applies to: label (both in C and C++). */
506/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
507 syntax. But clang does. */
508#ifndef _GL_UNUSED_LABEL
509# if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
510# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
511# else
512# define _GL_UNUSED_LABEL
513# endif
64#endif 514#endif
65]) 515])
516 AH_VERBATIM([async_safe],
517[/* The _GL_ASYNC_SAFE marker should be attached to functions that are
518 signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
519 invoked from such signal handlers. Such functions have some restrictions:
520 * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
521 or should be listed as async-signal-safe in POSIX
522 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
523 section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in
524 particular, are NOT async-signal-safe.
525 * All memory locations (variables and struct fields) that these functions
526 access must be marked 'volatile'. This holds for both read and write
527 accesses. Otherwise the compiler might optimize away stores to and
528 reads from such locations that occur in the program, depending on its
529 data flow analysis. For example, when the program contains a loop
530 that is intended to inspect a variable set from within a signal handler
531 while (!signal_occurred)
532 ;
533 the compiler is allowed to transform this into an endless loop if the
534 variable 'signal_occurred' is not declared 'volatile'.
535 Additionally, recall that:
536 * A signal handler should not modify errno (except if it is a handler
537 for a fatal signal and ends by raising the same signal again, thus
538 provoking the termination of the process). If it invokes a function
539 that may clobber errno, it needs to save and restore the value of
540 errno. */
541#define _GL_ASYNC_SAFE
542])
543 AH_VERBATIM([micro_optimizations],
544[/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where
545 n1 and n2 are expressions without side effects, that evaluate to real
546 numbers (excluding NaN).
547 It returns
548 1 if n1 > n2
549 0 if n1 == n2
550 -1 if n1 < n2
551 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional
552 jump with nearly all GCC versions up to GCC 10.
553 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many
554 GCC versions up to GCC 9.
555 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9
556 avoids conditional jumps in all GCC versions >= 3.4. */
557#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
558])
559 dnl Hint which direction to take regarding cross-compilation guesses:
560 dnl When a user installs a program on a platform they are not intimately
561 dnl familiar with, --enable-cross-guesses=conservative is the appropriate
562 dnl choice. It implements the "If we don't know, assume the worst" principle.
563 dnl However, when an operating system developer (on a platform which is not
564 dnl yet known to gnulib) builds packages for their platform, they want to
565 dnl expose, not hide, possible platform bugs; in this case,
566 dnl --enable-cross-guesses=risky is the appropriate choice.
567 dnl Sets the variables
568 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad),
569 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad).
570 AC_ARG_ENABLE([cross-guesses],
571 [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
572 [specify policy for cross-compilation guesses])],
573 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
574 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
575 enableval=conservative
576 fi
577 gl_cross_guesses="$enableval"],
578 [gl_cross_guesses=conservative])
579 if test $gl_cross_guesses = risky; then
580 gl_cross_guess_normal="guessing yes"
581 gl_cross_guess_inverted="guessing no"
582 else
583 gl_cross_guess_normal="guessing no"
584 gl_cross_guess_inverted="guessing yes"
585 fi
66 dnl Preparation for running test programs: 586 dnl Preparation for running test programs:
67 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not 587 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
68 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics 588 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
@@ -71,6 +591,16 @@ AC_DEFUN([gl_COMMON_BODY], [
71 export LIBC_FATAL_STDERR_ 591 export LIBC_FATAL_STDERR_
72]) 592])
73 593
594# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename])
595# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue])
596# initializes the shell variable that indicates the presence of the given module
597# as a C preprocessor expression.
598AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE],
599[
600 GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2])
601 AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1])
602])
603
74# gl_MODULE_INDICATOR_CONDITION 604# gl_MODULE_INDICATOR_CONDITION
75# expands to a C preprocessor expression that evaluates to 1 or 0, depending 605# expands to a C preprocessor expression that evaluates to 1 or 0, depending
76# whether a gnulib module that has been requested shall be considered present 606# whether a gnulib module that has been requested shall be considered present
@@ -83,9 +613,9 @@ m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
83AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], 613AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
84[ 614[
85 gl_MODULE_INDICATOR_SET_VARIABLE_AUX( 615 gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
86 [GNULIB_[]m4_translit([[$1]], 616 [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]],
87 [abcdefghijklmnopqrstuvwxyz./-], 617 [abcdefghijklmnopqrstuvwxyz./-],
88 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], 618 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
89 [gl_MODULE_INDICATOR_CONDITION]) 619 [gl_MODULE_INDICATOR_CONDITION])
90]) 620])
91 621
@@ -197,42 +727,20 @@ AC_DEFUN([gl_FEATURES_H],
197 AC_SUBST([HAVE_FEATURES_H]) 727 AC_SUBST([HAVE_FEATURES_H])
198]) 728])
199 729
200# m4_foreach_w
201# is a backport of autoconf-2.59c's m4_foreach_w.
202# Remove this macro when we can assume autoconf >= 2.60.
203m4_ifndef([m4_foreach_w],
204 [m4_define([m4_foreach_w],
205 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
206
207# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
208# ----------------------------------------------------
209# Backport of autoconf-2.63b's macro.
210# Remove this macro when we can assume autoconf >= 2.64.
211m4_ifndef([AS_VAR_IF],
212[m4_define([AS_VAR_IF],
213[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
214
215# gl_PROG_CC_C99 730# gl_PROG_CC_C99
216# Modifies the value of the shell variable CC in an attempt to make $CC 731# Modifies the value of the shell variable CC in an attempt to make $CC
217# understand ISO C99 source code. 732# understand ISO C99 source code.
218# This is like AC_PROG_CC_C99, except that
219# - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60,
220# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
221# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
222# but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
223# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
224# Remaining problems:
225# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
226# to CC twice
227# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
228# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
229AC_DEFUN([gl_PROG_CC_C99], 733AC_DEFUN([gl_PROG_CC_C99],
230[ 734[
231 dnl Change that version number to the minimum Autoconf version that supports 735 dnl Just use AC_PROG_CC_C99.
232 dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls. 736 dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted
233 m4_version_prereq([9.0], 737 dnl value of CC will contain the C99 enabling options twice. But this is only
234 [AC_REQUIRE([AC_PROG_CC_C99])], 738 dnl a cosmetic problem.
235 [AC_REQUIRE([AC_PROG_CC_STDC])]) 739 dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99;
740 dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete."
741 m4_version_prereq([2.70],
742 [AC_REQUIRE([AC_PROG_CC])],
743 [AC_REQUIRE([AC_PROG_CC_C99])])
236]) 744])
237 745
238# gl_PROG_AR_RANLIB 746# gl_PROG_AR_RANLIB
@@ -243,9 +751,11 @@ AC_DEFUN([gl_PROG_AR_RANLIB],
243[ 751[
244 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler 752 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
245 dnl as "cc", and GCC as "gcc". They have different object file formats and 753 dnl as "cc", and GCC as "gcc". They have different object file formats and
246 dnl library formats. In particular, the GNU binutils programs ar, ranlib 754 dnl library formats. In particular, the GNU binutils programs ar and ranlib
247 dnl produce libraries that work only with gcc, not with cc. 755 dnl produce libraries that work only with gcc, not with cc.
248 AC_REQUIRE([AC_PROG_CC]) 756 AC_REQUIRE([AC_PROG_CC])
757 dnl The '][' hides this use from 'aclocal'.
758 AC_BEFORE([$0], [A][M_PROG_AR])
249 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], 759 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
250 [ 760 [
251 AC_EGREP_CPP([Amsterdam], 761 AC_EGREP_CPP([Amsterdam],
@@ -257,25 +767,39 @@ Amsterdam
257 [gl_cv_c_amsterdam_compiler=yes], 767 [gl_cv_c_amsterdam_compiler=yes],
258 [gl_cv_c_amsterdam_compiler=no]) 768 [gl_cv_c_amsterdam_compiler=no])
259 ]) 769 ])
260 if test -z "$AR"; then 770
261 if test $gl_cv_c_amsterdam_compiler = yes; then 771 dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
772 dnl building with __ACK__.
773 if test $gl_cv_c_amsterdam_compiler = yes; then
774 if test -z "$AR"; then
262 AR='cc -c.a' 775 AR='cc -c.a'
263 if test -z "$ARFLAGS"; then
264 ARFLAGS='-o'
265 fi
266 else
267 dnl Use the Automake-documented default values for AR and ARFLAGS,
268 dnl but prefer ${host}-ar over ar (useful for cross-compiling).
269 AC_CHECK_TOOL([AR], [ar], [ar])
270 if test -z "$ARFLAGS"; then
271 ARFLAGS='cru'
272 fi
273 fi 776 fi
274 else
275 if test -z "$ARFLAGS"; then 777 if test -z "$ARFLAGS"; then
276 ARFLAGS='cru' 778 ARFLAGS='-o'
277 fi 779 fi
780 else
781 dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST
782 dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
783 dnl script on-demand, if not specified by ./configure of course).
784 dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
785 dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block
786 dnl because AM_PROG_AR is written so it could re-set AR variable even for
787 dnl __ACK__. It may seem like its easier to avoid calling the macro here,
788 dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
789 dnl default value and automake should usually know them).
790 dnl
791 dnl The '][' hides this use from 'aclocal'.
792 m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
278 fi 793 fi
794
795 dnl In case the code above has not helped with setting AR/ARFLAGS, use
796 dnl Automake-documented default values for AR and ARFLAGS, but prefer
797 dnl ${host}-ar over ar (useful for cross-compiling).
798 AC_CHECK_TOOL([AR], [ar], [ar])
799 if test -z "$ARFLAGS"; then
800 ARFLAGS='cr'
801 fi
802
279 AC_SUBST([AR]) 803 AC_SUBST([AR])
280 AC_SUBST([ARFLAGS]) 804 AC_SUBST([ARFLAGS])
281 if test -z "$RANLIB"; then 805 if test -z "$RANLIB"; then
@@ -289,46 +813,29 @@ Amsterdam
289 AC_SUBST([RANLIB]) 813 AC_SUBST([RANLIB])
290]) 814])
291 815
292# AC_PROG_MKDIR_P
293# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
294# for interoperability with automake-1.9.6 from autoconf-2.62.
295# Remove this macro when we can assume autoconf >= 2.62 or
296# autoconf >= 2.60 && automake >= 1.10.
297# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
298m4_ifndef([AC_AUTOCONF_VERSION],[
299m4_ifdef([AC_PROG_MKDIR_P], [
300 dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
301 m4_define([AC_PROG_MKDIR_P],
302 m4_defn([AC_PROG_MKDIR_P])[
303 AC_SUBST([MKDIR_P])])], [
304 dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
305 AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
306 [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
307 MKDIR_P='$(mkdir_p)'
308 AC_SUBST([MKDIR_P])])])
309])
310
311# AC_C_RESTRICT 816# AC_C_RESTRICT
312# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, 817# This definition is copied from post-2.70 Autoconf and overrides the
313# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ 818# AC_C_RESTRICT macro from autoconf 2.60..2.70.
314# works. 819m4_version_prereq([2.70.1], [], [
315# This definition can be removed once autoconf >= 2.62 can be assumed.
316# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
317m4_ifndef([AC_AUTOCONF_VERSION],[
318AC_DEFUN([AC_C_RESTRICT], 820AC_DEFUN([AC_C_RESTRICT],
319[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], 821[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
320 [ac_cv_c_restrict=no 822 [ac_cv_c_restrict=no
321 # The order here caters to the fact that C++ does not require restrict. 823 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
322 for ac_kw in __restrict __restrict__ _Restrict restrict; do 824 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
323 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 825 # Put 'restrict' last, because C++ lacks it.
324 [[typedef int * int_ptr; 826 for ac_kw in __restrict__ __restrict _Restrict restrict; do
325 int foo (int_ptr $ac_kw ip) { 827 AC_COMPILE_IFELSE(
326 return ip[0]; 828 [AC_LANG_PROGRAM(
327 }]], 829 [[typedef int *int_ptr;
328 [[int s[1]; 830 int foo (int_ptr $ac_kw ip) { return ip[0]; }
329 int * $ac_kw t = s; 831 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
330 t[0] = 0; 832 int bar (int ip[$ac_kw]) { return ip[0]; }
331 return foo(t)]])], 833 ]],
834 [[int s[1];
835 int *$ac_kw t = s;
836 t[0] = 0;
837 return foo (t) + bar (t);
838 ]])],
332 [ac_cv_c_restrict=$ac_kw]) 839 [ac_cv_c_restrict=$ac_kw])
333 test "$ac_cv_c_restrict" != no && break 840 test "$ac_cv_c_restrict" != no && break
334 done 841 done
@@ -336,22 +843,24 @@ AC_DEFUN([AC_C_RESTRICT],
336 AH_VERBATIM([restrict], 843 AH_VERBATIM([restrict],
337[/* Define to the equivalent of the C99 'restrict' keyword, or to 844[/* Define to the equivalent of the C99 'restrict' keyword, or to
338 nothing if this is not supported. Do not define if restrict is 845 nothing if this is not supported. Do not define if restrict is
339 supported directly. */ 846 supported only directly. */
340#undef restrict 847#undef restrict
341/* Work around a bug in Sun C++: it does not support _Restrict, even 848/* Work around a bug in older versions of Sun C++, which did not
342 though the corresponding Sun C compiler does, which causes 849 #define __restrict__ or support _Restrict or __restrict__
343 "#define restrict _Restrict" in the previous line. Perhaps some future 850 even though the corresponding Sun C compiler ended up with
344 version of Sun C++ will work with _Restrict; if so, it'll probably 851 "#define restrict _Restrict" or "#define restrict __restrict__"
345 define __RESTRICT, just as Sun C does. */ 852 in the previous line. This workaround can be removed once
346#if defined __SUNPRO_CC && !defined __RESTRICT 853 we assume Oracle Developer Studio 12.5 (2016) or later. */
854#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
347# define _Restrict 855# define _Restrict
856# define __restrict__
348#endif]) 857#endif])
349 case $ac_cv_c_restrict in 858 case $ac_cv_c_restrict in
350 restrict) ;; 859 restrict) ;;
351 no) AC_DEFINE([restrict], []) ;; 860 no) AC_DEFINE([restrict], []) ;;
352 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; 861 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
353 esac 862 esac
354]) 863])# AC_C_RESTRICT
355]) 864])
356 865
357# gl_BIGENDIAN 866# gl_BIGENDIAN
@@ -363,6 +872,22 @@ AC_DEFUN([gl_BIGENDIAN],
363 AC_C_BIGENDIAN 872 AC_C_BIGENDIAN
364]) 873])
365 874
875# A temporary file descriptor.
876# Must be less than 10, because dash 0.5.8 does not support redirections
877# with multi-digit file descriptors.
878m4_define([GL_TMP_FD], 9)
879
880# gl_SILENT(command)
881# executes command, but without the normal configure output.
882# This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.)
883# inside another AC_CACHE_CHECK.
884AC_DEFUN([gl_SILENT],
885[
886 exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
887 $1
888 exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&-
889])
890
366# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) 891# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
367# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not 892# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
368# output a spurious "(cached)" mark in the midst of other configure output. 893# output a spurious "(cached)" mark in the midst of other configure output.
@@ -370,8 +895,257 @@ AC_DEFUN([gl_BIGENDIAN],
370# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. 895# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
371AC_DEFUN([gl_CACHE_VAL_SILENT], 896AC_DEFUN([gl_CACHE_VAL_SILENT],
372[ 897[
373 saved_as_echo_n="$as_echo_n" 898 gl_SILENT([
374 as_echo_n=':' 899 AC_CACHE_VAL([$1], [$2])
375 AC_CACHE_VAL([$1], [$2]) 900 ])
376 as_echo_n="$saved_as_echo_n" 901])
902
903# gl_CONDITIONAL(conditional, condition)
904# is like AM_CONDITIONAL(conditional, condition), except that it does not
905# produce an error
906# configure: error: conditional "..." was never defined.
907# Usually this means the macro was only invoked conditionally.
908# when only invoked conditionally. Instead, in that case, both the _TRUE
909# and the _FALSE case are disabled.
910AC_DEFUN([gl_CONDITIONAL],
911[
912 pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
913 AM_CONDITIONAL([$1], [$2])
914 popdef([AC_CONFIG_COMMANDS_PRE])dnl
915 if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
916 [$1]_TRUE='#'
917 [$1]_FALSE='#'
918 fi
919])
920
921# gl_CC_ALLOW_WARNINGS
922# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
923# that reverts a preceding '-Werror' option, if available.
924# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang
925# and empty otherwise.
926AC_DEFUN([gl_CC_ALLOW_WARNINGS],
927[
928 AC_REQUIRE([AC_PROG_CC])
929 AC_CACHE_CHECK([for C compiler option to allow warnings],
930 [gl_cv_cc_wallow],
931 [rm -f conftest*
932 echo 'int dummy;' > conftest.c
933 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
934 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
935 dnl Test the number of error output lines, because AIX xlc accepts the
936 dnl option '-Wno-error', just to produce a warning
937 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
938 dnl afterwards.
939 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
940 gl_cv_cc_wallow='-Wno-error'
941 else
942 gl_cv_cc_wallow=none
943 fi
944 rm -f conftest*
945 ])
946 case "$gl_cv_cc_wallow" in
947 none) GL_CFLAG_ALLOW_WARNINGS='' ;;
948 *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;;
949 esac
950 AC_SUBST([GL_CFLAG_ALLOW_WARNINGS])
951])
952
953# gl_CXX_ALLOW_WARNINGS
954# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option
955# that reverts a preceding '-Werror' option, if available.
956AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
957[
958 dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX.
959 if test -n "$CXX" && test "$CXX" != no; then
960 AC_CACHE_CHECK([for C++ compiler option to allow warnings],
961 [gl_cv_cxx_wallow],
962 [rm -f conftest*
963 echo 'int dummy;' > conftest.cc
964 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
965 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
966 dnl Test the number of error output lines, because AIX xlC accepts the
967 dnl option '-Wno-error', just to produce a warning
968 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
969 dnl afterwards.
970 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
971 gl_cv_cxx_wallow='-Wno-error'
972 else
973 gl_cv_cxx_wallow=none
974 fi
975 rm -f conftest*
976 ])
977 case "$gl_cv_cxx_wallow" in
978 none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
979 *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;;
980 esac
981 else
982 GL_CXXFLAG_ALLOW_WARNINGS=''
983 fi
984 AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
985])
986
987# gl_CC_GNULIB_WARNINGS
988# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
989# set that enables or disables warnings as suitable for the Gnulib coding style.
990AC_DEFUN([gl_CC_GNULIB_WARNINGS],
991[
992 AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
993 dnl Assume that the compiler supports -Wno-* options only if it also supports
994 dnl -Wno-error.
995 GL_CFLAG_GNULIB_WARNINGS=''
996 if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
997 dnl Enable these warning options:
998 dnl
999 dnl GCC clang
1000 dnl -Wno-cast-qual >= 3 >= 3.9
1001 dnl -Wno-conversion >= 3 >= 3.9
1002 dnl -Wno-float-conversion >= 4.9 >= 3.9
1003 dnl -Wno-float-equal >= 3 >= 3.9
1004 dnl -Wimplicit-fallthrough >= 7 >= 3.9
1005 dnl -Wno-pedantic >= 4.8 >= 3.9
1006 dnl -Wno-sign-compare >= 3 >= 3.9
1007 dnl -Wno-sign-conversion >= 4.3 >= 3.9
1008 dnl -Wno-type-limits >= 4.3 >= 3.9
1009 dnl -Wno-undef >= 3 >= 3.9
1010 dnl -Wno-unsuffixed-float-constants >= 4.5
1011 dnl -Wno-unused-function >= 3 >= 3.9
1012 dnl -Wno-unused-parameter >= 3 >= 3.9
1013 dnl
1014 cat > conftest.c <<\EOF
1015 #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1016 -Wno-cast-qual
1017 -Wno-conversion
1018 -Wno-float-equal
1019 -Wno-sign-compare
1020 -Wno-undef
1021 -Wno-unused-function
1022 -Wno-unused-parameter
1023 #endif
1024 #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1025 -Wno-float-conversion
1026 #endif
1027 #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1028 -Wimplicit-fallthrough
1029 #endif
1030 #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1031 -Wno-pedantic
1032 #endif
1033 #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1034 -Wno-sign-conversion
1035 -Wno-type-limits
1036 #endif
1037 #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
1038 -Wno-unsuffixed-float-constants
1039 #endif
1040EOF
1041 gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
1042 if AC_TRY_EVAL([gl_command]); then
1043 gl_options=`grep -v '#' conftest.out`
1044 for word in $gl_options; do
1045 GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
1046 done
1047 fi
1048 rm -f conftest.c conftest.out
1049 fi
1050 AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
1051])
1052
1053dnl gl_CONDITIONAL_HEADER([foo.h])
1054dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
1055dnl and produces
1056dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
1057dnl on whether GL_GENERATE_FOO_H is true or false,
1058dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
1059dnl the shell variable GL_GENERATE_FOO_H.
1060AC_DEFUN([gl_CONDITIONAL_HEADER],
1061[
1062 m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
1063 m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1064 m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1065 case "$gl_generate_var" in
1066 false) gl_header_name='' ;;
1067 true)
1068 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
1069 dnl versa.
1070 if test -z "$gl_header_name"; then
1071 gl_header_name="${gl_source_base_prefix}$1"
1072 fi
1073 ;;
1074 *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
1075 esac
1076 AC_SUBST(gl_header_name)
1077 gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
1078 m4_popdef([gl_generate_cond])
1079 m4_popdef([gl_generate_var])
1080 m4_popdef([gl_header_name])
1081])
1082
1083dnl Expands to some code for use in .c programs that, on native Windows, defines
1084dnl the Microsoft deprecated alias function names to the underscore-prefixed
1085dnl actual function names. With this macro, these function names are available
1086dnl without linking with '-loldnames' and without generating warnings.
1087dnl Usage: Use it after all system header files are included.
1088dnl #include <...>
1089dnl #include <...>
1090dnl ]GL_MDA_DEFINES[
1091dnl ...
1092AC_DEFUN([GL_MDA_DEFINES],[
1093AC_REQUIRE([_GL_MDA_DEFINES])
1094[$gl_mda_defines]
1095])
1096AC_DEFUN([_GL_MDA_DEFINES],
1097[gl_mda_defines='
1098#if defined _WIN32 && !defined __CYGWIN__
1099#define access _access
1100#define chdir _chdir
1101#define chmod _chmod
1102#define close _close
1103#define creat _creat
1104#define dup _dup
1105#define dup2 _dup2
1106#define ecvt _ecvt
1107#define execl _execl
1108#define execle _execle
1109#define execlp _execlp
1110#define execv _execv
1111#define execve _execve
1112#define execvp _execvp
1113#define execvpe _execvpe
1114#define fcloseall _fcloseall
1115#define fcvt _fcvt
1116#define fdopen _fdopen
1117#define fileno _fileno
1118#define gcvt _gcvt
1119#define getcwd _getcwd
1120#define getpid _getpid
1121#define getw _getw
1122#define isatty _isatty
1123#define j0 _j0
1124#define j1 _j1
1125#define jn _jn
1126#define lfind _lfind
1127#define lsearch _lsearch
1128#define lseek _lseek
1129#define memccpy _memccpy
1130#define mkdir _mkdir
1131#define mktemp _mktemp
1132#define open _open
1133#define putenv _putenv
1134#define putw _putw
1135#define read _read
1136#define rmdir _rmdir
1137#define strdup _strdup
1138#define swab _swab
1139#define tempnam _tempnam
1140#define tzset _tzset
1141#define umask _umask
1142#define unlink _unlink
1143#define utime _utime
1144#define wcsdup _wcsdup
1145#define write _write
1146#define y0 _y0
1147#define y1 _y1
1148#define yn _yn
1149#endif
1150'
377]) 1151])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 9a4f5027..4764622e 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -1,9 +1,9 @@
1# DO NOT EDIT! GENERATED AUTOMATICALLY! 1# DO NOT EDIT! GENERATED AUTOMATICALLY!
2# Copyright (C) 2002-2013 Free Software Foundation, Inc. 2# Copyright (C) 2002-2023 Free Software Foundation, Inc.
3# 3#
4# This file is free software; you can redistribute it and/or modify 4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or 6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version. 7# (at your option) any later version.
8# 8#
9# This file is distributed in the hope that it will be useful, 9# This file is distributed in the hope that it will be useful,
@@ -12,7 +12,7 @@
12# GNU General Public License for more details. 12# GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with this file. If not, see <http://www.gnu.org/licenses/>. 15# along with this file. If not, see <https://www.gnu.org/licenses/>.
16# 16#
17# As a special exception to the GNU General Public License, 17# As a special exception to the GNU General Public License,
18# this file may be distributed as part of a program that 18# this file may be distributed as part of a program that
@@ -37,50 +37,91 @@ AC_DEFUN([gl_EARLY],
37 m4_pattern_allow([^gl_ES$])dnl a valid locale name 37 m4_pattern_allow([^gl_ES$])dnl a valid locale name
38 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable 38 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
39 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 39 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
40
41 # Pre-early section.
42 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
40 AC_REQUIRE([gl_PROG_AR_RANLIB]) 43 AC_REQUIRE([gl_PROG_AR_RANLIB])
41 AC_REQUIRE([AM_PROG_CC_C_O]) 44
45 # Code from module absolute-header:
42 # Code from module alloca-opt: 46 # Code from module alloca-opt:
43 # Code from module arpa_inet: 47 # Code from module arpa_inet:
48 # Code from module assert-h:
49 # Code from module attribute:
44 # Code from module base64: 50 # Code from module base64:
51 # Code from module basename-lgpl:
45 # Code from module btowc: 52 # Code from module btowc:
46 # Code from module configmake: 53 # Code from module builtin-expect:
47 # Code from module crypto/sha1: 54 # Code from module byteswap:
55 # Code from module c99:
56 # Code from module calloc-gnu:
57 # Code from module calloc-posix:
58 # Code from module cloexec:
59 # Code from module close:
60 # Code from module crypto/af_alg:
61 # Code from module crypto/sha256:
62 # Code from module crypto/sha256-buffer:
48 # Code from module dirname: 63 # Code from module dirname:
49 # Code from module dirname-lgpl: 64 # Code from module dirname-lgpl:
50 # Code from module dosname:
51 # Code from module double-slash-root: 65 # Code from module double-slash-root:
66 # Code from module dup2:
52 # Code from module environ: 67 # Code from module environ:
53 # Code from module errno: 68 # Code from module errno:
54 # Code from module error: 69 # Code from module error:
55 # Code from module exitfail: 70 # Code from module exitfail:
56 # Code from module extensions: 71 # Code from module extensions:
57 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
58 # Code from module extern-inline: 72 # Code from module extern-inline:
73 # Code from module fcntl:
74 # Code from module fcntl-h:
59 # Code from module fd-hook: 75 # Code from module fd-hook:
76 # Code from module fflush:
77 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
78 # Code from module filename:
60 # Code from module float: 79 # Code from module float:
61 # Code from module floorf: 80 # Code from module floorf:
81 # Code from module fopen:
82 # Code from module fopen-gnu:
83 # Code from module fpurge:
84 # Code from module freading:
85 # Code from module free-posix:
86 # Code from module fseek:
87 # Code from module fseeko:
88 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
89 # Code from module fstat:
62 # Code from module fsusage: 90 # Code from module fsusage:
63 # Code from module full-read: 91 # Code from module ftell:
92 # Code from module ftello:
93 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
94 # Code from module gen-header:
64 # Code from module getaddrinfo: 95 # Code from module getaddrinfo:
96 # Code from module getdelim:
97 # Code from module getdtablesize:
65 # Code from module gethostname: 98 # Code from module gethostname:
99 # Code from module getline:
66 # Code from module getloadavg: 100 # Code from module getloadavg:
67 # Code from module getopt-gnu: 101 # Code from module getopt-gnu:
68 # Code from module getopt-posix: 102 # Code from module getopt-posix:
69 # Code from module gettext: 103 # Code from module getprogname:
70 # Code from module gettext-h: 104 # Code from module gettext-h:
71 # Code from module havelib: 105 # Code from module glibc-internal/dynarray:
106 # Code from module hard-locale:
72 # Code from module hostent: 107 # Code from module hostent:
108 # Code from module ialloc:
73 # Code from module idpriv-droptemp: 109 # Code from module idpriv-droptemp:
110 # Code from module idx:
74 # Code from module include_next: 111 # Code from module include_next:
75 # Code from module inet_ntop: 112 # Code from module inet_ntop:
76 # Code from module intprops: 113 # Code from module intprops:
114 # Code from module inttypes-incomplete:
77 # Code from module langinfo: 115 # Code from module langinfo:
78 # Code from module largefile: 116 # Code from module largefile:
79 AC_REQUIRE([AC_SYS_LARGEFILE]) 117 AC_REQUIRE([AC_SYS_LARGEFILE])
118 # Code from module libc-config:
119 # Code from module limits-h:
80 # Code from module localcharset: 120 # Code from module localcharset:
81 # Code from module locale: 121 # Code from module locale:
82 # Code from module localeconv: 122 # Code from module localeconv:
83 # Code from module lock: 123 # Code from module lock:
124 # Code from module lseek:
84 # Code from module malloc-gnu: 125 # Code from module malloc-gnu:
85 # Code from module malloc-posix: 126 # Code from module malloc-posix:
86 # Code from module malloca: 127 # Code from module malloca:
@@ -89,6 +130,7 @@ AC_DEFUN([gl_EARLY],
89 # Code from module mbsinit: 130 # Code from module mbsinit:
90 # Code from module mbtowc: 131 # Code from module mbtowc:
91 # Code from module memchr: 132 # Code from module memchr:
133 # Code from module minmax:
92 # Code from module mktime: 134 # Code from module mktime:
93 # Code from module mktime-internal: 135 # Code from module mktime-internal:
94 # Code from module mountlist: 136 # Code from module mountlist:
@@ -99,11 +141,15 @@ AC_DEFUN([gl_EARLY],
99 # Code from module netinet_in: 141 # Code from module netinet_in:
100 # Code from module nl_langinfo: 142 # Code from module nl_langinfo:
101 # Code from module nocrash: 143 # Code from module nocrash:
102 # Code from module read: 144 # Code from module open:
145 # Code from module pathmax:
146 # Code from module realloc-gnu:
147 # Code from module realloc-posix:
148 # Code from module reallocarray:
103 # Code from module regex: 149 # Code from module regex:
104 # Code from module safe-read:
105 # Code from module servent: 150 # Code from module servent:
106 # Code from module setenv: 151 # Code from module setenv:
152 # Code from module setlocale-null:
107 # Code from module size_max: 153 # Code from module size_max:
108 # Code from module snippet/_Noreturn: 154 # Code from module snippet/_Noreturn:
109 # Code from module snippet/arg-nonnull: 155 # Code from module snippet/arg-nonnull:
@@ -114,8 +160,12 @@ AC_DEFUN([gl_EARLY],
114 # Code from module sockets: 160 # Code from module sockets:
115 # Code from module socklen: 161 # Code from module socklen:
116 # Code from module ssize_t: 162 # Code from module ssize_t:
163 # Code from module stat:
164 # Code from module stat-time:
165 # Code from module std-gnu11:
117 # Code from module stdalign: 166 # Code from module stdalign:
118 # Code from module stdbool: 167 # Code from module stdbool:
168 # Code from module stdckdint:
119 # Code from module stddef: 169 # Code from module stddef:
120 # Code from module stdint: 170 # Code from module stdint:
121 # Code from module stdio: 171 # Code from module stdio:
@@ -128,11 +178,10 @@ AC_DEFUN([gl_EARLY],
128 # Code from module strerror-override: 178 # Code from module strerror-override:
129 # Code from module string: 179 # Code from module string:
130 # Code from module strings: 180 # Code from module strings:
131 # Code from module strndup:
132 # Code from module strnlen:
133 # Code from module strsep: 181 # Code from module strsep:
134 # Code from module strstr-simple: 182 # Code from module strstr-simple:
135 # Code from module sys_socket: 183 # Code from module sys_socket:
184 # Code from module sys_stat:
136 # Code from module sys_types: 185 # Code from module sys_types:
137 # Code from module sys_uio: 186 # Code from module sys_uio:
138 # Code from module threadlib: 187 # Code from module threadlib:
@@ -141,7 +190,9 @@ AC_DEFUN([gl_EARLY],
141 # Code from module time_r: 190 # Code from module time_r:
142 # Code from module timegm: 191 # Code from module timegm:
143 # Code from module unistd: 192 # Code from module unistd:
193 # Code from module unlocked-io-internal:
144 # Code from module unsetenv: 194 # Code from module unsetenv:
195 # Code from module vararrays:
145 # Code from module vasnprintf: 196 # Code from module vasnprintf:
146 # Code from module vasprintf: 197 # Code from module vasprintf:
147 # Code from module verify: 198 # Code from module verify:
@@ -149,11 +200,14 @@ AC_DEFUN([gl_EARLY],
149 # Code from module wchar: 200 # Code from module wchar:
150 # Code from module wcrtomb: 201 # Code from module wcrtomb:
151 # Code from module wctype-h: 202 # Code from module wctype-h:
203 # Code from module windows-mutex:
204 # Code from module windows-once:
205 # Code from module windows-recmutex:
206 # Code from module windows-rwlock:
152 # Code from module xalloc: 207 # Code from module xalloc:
153 # Code from module xalloc-die: 208 # Code from module xalloc-die:
154 # Code from module xalloc-oversized: 209 # Code from module xalloc-oversized:
155 # Code from module xsize: 210 # Code from module xsize:
156 # Code from module xstrndup:
157]) 211])
158 212
159# This macro should be invoked from ./configure.ac, in the section 213# This macro should be invoked from ./configure.ac, in the section
@@ -170,154 +224,300 @@ AC_DEFUN([gl_INIT],
170 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) 224 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
171 m4_pushdef([gl_LIBSOURCES_LIST], []) 225 m4_pushdef([gl_LIBSOURCES_LIST], [])
172 m4_pushdef([gl_LIBSOURCES_DIR], []) 226 m4_pushdef([gl_LIBSOURCES_DIR], [])
227 m4_pushdef([GL_MACRO_PREFIX], [gl])
228 m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL])
173 gl_COMMON 229 gl_COMMON
174 gl_source_base='gl' 230 gl_source_base='gl'
231 gl_source_base_prefix=
175 gl_FUNC_ALLOCA 232 gl_FUNC_ALLOCA
176 gl_HEADER_ARPA_INET 233 gl_CONDITIONAL_HEADER([alloca.h])
234 AC_PROG_MKDIR_P
235 gl_ARPA_INET_H
236 gl_ARPA_INET_H_REQUIRE_DEFAULTS
237 AC_PROG_MKDIR_P
238 gl_ASSERT_H
239 gl_CONDITIONAL_HEADER([assert.h])
177 AC_PROG_MKDIR_P 240 AC_PROG_MKDIR_P
178 gl_FUNC_BASE64 241 gl_FUNC_BASE64
179 gl_FUNC_BTOWC 242 gl_FUNC_BTOWC
180 if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then 243 gl_CONDITIONAL([GL_COND_OBJ_BTOWC],
181 AC_LIBOBJ([btowc]) 244 [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1])
245 AM_COND_IF([GL_COND_OBJ_BTOWC], [
182 gl_PREREQ_BTOWC 246 gl_PREREQ_BTOWC
183 fi 247 ])
184 gl_WCHAR_MODULE_INDICATOR([btowc]) 248 gl_WCHAR_MODULE_INDICATOR([btowc])
185 gl_CONFIGMAKE_PREP 249 gl___BUILTIN_EXPECT
186 gl_SHA1 250 gl_BYTESWAP
187 gl_DIRNAME 251 gl_CONDITIONAL_HEADER([byteswap.h])
252 AC_PROG_MKDIR_P
253 gl_FUNC_CALLOC_GNU
254 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then
255 AC_LIBOBJ([calloc])
256 fi
257 gl_STDLIB_MODULE_INDICATOR([calloc-gnu])
258 gl_FUNC_CALLOC_POSIX
259 if test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1; then
260 AC_LIBOBJ([calloc])
261 fi
262 gl_STDLIB_MODULE_INDICATOR([calloc-posix])
263 gl_MODULE_INDICATOR_FOR_TESTS([cloexec])
264 gl_FUNC_CLOSE
265 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1])
266 gl_UNISTD_MODULE_INDICATOR([close])
267 gl_AF_ALG
268 AC_REQUIRE([AC_C_RESTRICT])
269 gl_SHA256
188 gl_MODULE_INDICATOR([dirname]) 270 gl_MODULE_INDICATOR([dirname])
189 gl_DIRNAME_LGPL
190 gl_DOUBLE_SLASH_ROOT 271 gl_DOUBLE_SLASH_ROOT
272 gl_FUNC_DUP2
273 gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1])
274 AM_COND_IF([GL_COND_OBJ_DUP2], [
275 gl_PREREQ_DUP2
276 ])
277 gl_UNISTD_MODULE_INDICATOR([dup2])
191 gl_ENVIRON 278 gl_ENVIRON
192 gl_UNISTD_MODULE_INDICATOR([environ]) 279 gl_UNISTD_MODULE_INDICATOR([environ])
193 gl_HEADER_ERRNO_H 280 gl_HEADER_ERRNO_H
281 gl_CONDITIONAL_HEADER([errno.h])
282 AC_PROG_MKDIR_P
194 gl_ERROR 283 gl_ERROR
195 if test $ac_cv_lib_error_at_line = no; then 284 gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test "$ac_cv_lib_error_at_line" = no])
196 AC_LIBOBJ([error]) 285 AM_COND_IF([GL_COND_OBJ_ERROR], [
197 gl_PREREQ_ERROR 286 gl_PREREQ_ERROR
198 fi 287 ])
199 m4_ifdef([AM_XGETTEXT_OPTION], 288 m4_ifdef([AM_XGETTEXT_OPTION],
200 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) 289 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
201 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) 290 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
202 AC_REQUIRE([gl_EXTERN_INLINE]) 291 AC_REQUIRE([gl_EXTERN_INLINE])
292 gl_FUNC_FCNTL
293 gl_CONDITIONAL([GL_COND_OBJ_FCNTL],
294 [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1])
295 gl_FCNTL_MODULE_INDICATOR([fcntl])
296 gl_FCNTL_H
297 gl_FCNTL_H_REQUIRE_DEFAULTS
298 AC_PROG_MKDIR_P
299 gl_FUNC_FFLUSH
300 gl_CONDITIONAL([GL_COND_OBJ_FFLUSH], [test $REPLACE_FFLUSH = 1])
301 AM_COND_IF([GL_COND_OBJ_FFLUSH], [
302 gl_PREREQ_FFLUSH
303 ])
304 gl_MODULE_INDICATOR([fflush])
305 gl_STDIO_MODULE_INDICATOR([fflush])
203 gl_FLOAT_H 306 gl_FLOAT_H
204 if test $REPLACE_FLOAT_LDBL = 1; then 307 gl_CONDITIONAL_HEADER([float.h])
205 AC_LIBOBJ([float]) 308 AC_PROG_MKDIR_P
206 fi 309 gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1])
207 if test $REPLACE_ITOLD = 1; then 310 gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1])
208 AC_LIBOBJ([itold])
209 fi
210 gl_FUNC_FLOORF 311 gl_FUNC_FLOORF
211 if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then 312 gl_CONDITIONAL([GL_COND_OBJ_FLOORF],
212 AC_LIBOBJ([floorf]) 313 [test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1])
213 fi
214 gl_MATH_MODULE_INDICATOR([floorf]) 314 gl_MATH_MODULE_INDICATOR([floorf])
315 gl_FUNC_FOPEN
316 if test $REPLACE_FOPEN = 1; then
317 AC_LIBOBJ([fopen])
318 gl_PREREQ_FOPEN
319 fi
320 gl_STDIO_MODULE_INDICATOR([fopen])
321 gl_FUNC_FOPEN_GNU
322 if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then
323 AC_LIBOBJ([fopen])
324 gl_PREREQ_FOPEN
325 fi
326 gl_MODULE_INDICATOR([fopen-gnu])
327 gl_STDIO_MODULE_INDICATOR([fopen-gnu])
328 gl_FUNC_FPURGE
329 gl_CONDITIONAL([GL_COND_OBJ_FPURGE],
330 [test $HAVE_FPURGE = 0 || test $REPLACE_FPURGE = 1])
331 gl_STDIO_MODULE_INDICATOR([fpurge])
332 gl_FUNC_FREADING
333 gl_FUNC_FREE
334 gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1])
335 AM_COND_IF([GL_COND_OBJ_FREE], [
336 gl_PREREQ_FREE
337 ])
338 gl_STDLIB_MODULE_INDICATOR([free-posix])
339 gl_FUNC_FSEEK
340 gl_CONDITIONAL([GL_COND_OBJ_FSEEK], [test $REPLACE_FSEEK = 1])
341 gl_STDIO_MODULE_INDICATOR([fseek])
342 gl_FUNC_FSEEKO
343 gl_CONDITIONAL([GL_COND_OBJ_FSEEKO],
344 [test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1])
345 AM_COND_IF([GL_COND_OBJ_FSEEKO], [
346 gl_PREREQ_FSEEKO
347 ])
348 gl_STDIO_MODULE_INDICATOR([fseeko])
349 gl_FUNC_FSTAT
350 gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1])
351 AM_COND_IF([GL_COND_OBJ_FSTAT], [
352 case "$host_os" in
353 mingw*)
354 AC_LIBOBJ([stat-w32])
355 ;;
356 esac
357 gl_PREREQ_FSTAT
358 ])
359 gl_SYS_STAT_MODULE_INDICATOR([fstat])
215 gl_FSUSAGE 360 gl_FSUSAGE
216 if test $gl_cv_fs_space = yes; then 361 gl_CONDITIONAL([GL_COND_OBJ_FSUSAGE], [test $gl_cv_fs_space = yes])
217 AC_LIBOBJ([fsusage]) 362 AM_COND_IF([GL_COND_OBJ_FSUSAGE], [
218 gl_PREREQ_FSUSAGE_EXTRA 363 gl_PREREQ_FSUSAGE_EXTRA
219 fi 364 ])
365 gl_FUNC_FTELL
366 gl_CONDITIONAL([GL_COND_OBJ_FTELL], [test $REPLACE_FTELL = 1])
367 gl_STDIO_MODULE_INDICATOR([ftell])
368 gl_FUNC_FTELLO
369 gl_CONDITIONAL([GL_COND_OBJ_FTELLO],
370 [test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1])
371 AM_COND_IF([GL_COND_OBJ_FTELLO], [
372 gl_PREREQ_FTELLO
373 ])
374 gl_STDIO_MODULE_INDICATOR([ftello])
220 gl_GETADDRINFO 375 gl_GETADDRINFO
221 if test $HAVE_GETADDRINFO = 0; then 376 gl_CONDITIONAL([GL_COND_OBJ_GETADDRINFO],
222 AC_LIBOBJ([getaddrinfo]) 377 [test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1])
223 fi 378 gl_CONDITIONAL([GL_COND_OBJ_GAI_STRERROR],
224 if test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1; then 379 [test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1])
225 AC_LIBOBJ([gai_strerror])
226 fi
227 gl_NETDB_MODULE_INDICATOR([getaddrinfo]) 380 gl_NETDB_MODULE_INDICATOR([getaddrinfo])
381 gl_FUNC_GETDELIM
382 gl_CONDITIONAL([GL_COND_OBJ_GETDELIM],
383 [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1])
384 AM_COND_IF([GL_COND_OBJ_GETDELIM], [
385 gl_PREREQ_GETDELIM
386 ])
387 gl_STDIO_MODULE_INDICATOR([getdelim])
388 gl_FUNC_GETDTABLESIZE
389 gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE],
390 [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1])
391 AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [
392 gl_PREREQ_GETDTABLESIZE
393 ])
394 gl_UNISTD_MODULE_INDICATOR([getdtablesize])
228 gl_FUNC_GETHOSTNAME 395 gl_FUNC_GETHOSTNAME
229 if test $HAVE_GETHOSTNAME = 0; then 396 gl_CONDITIONAL([GL_COND_OBJ_GETHOSTNAME], [test $HAVE_GETHOSTNAME = 0])
230 AC_LIBOBJ([gethostname]) 397 AM_COND_IF([GL_COND_OBJ_GETHOSTNAME], [
231 gl_PREREQ_GETHOSTNAME 398 gl_PREREQ_GETHOSTNAME
232 fi 399 ])
233 gl_UNISTD_MODULE_INDICATOR([gethostname]) 400 gl_UNISTD_MODULE_INDICATOR([gethostname])
401 gl_FUNC_GETLINE
402 gl_CONDITIONAL([GL_COND_OBJ_GETLINE], [test $REPLACE_GETLINE = 1])
403 AM_COND_IF([GL_COND_OBJ_GETLINE], [
404 gl_PREREQ_GETLINE
405 ])
406 gl_STDIO_MODULE_INDICATOR([getline])
407 AC_REQUIRE([AC_CANONICAL_HOST])
234 gl_GETLOADAVG 408 gl_GETLOADAVG
235 if test $HAVE_GETLOADAVG = 0; then 409 gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0])
236 AC_LIBOBJ([getloadavg]) 410 AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [
237 gl_PREREQ_GETLOADAVG 411 gl_PREREQ_GETLOADAVG
238 fi 412 ])
239 gl_STDLIB_MODULE_INDICATOR([getloadavg]) 413 gl_STDLIB_MODULE_INDICATOR([getloadavg])
240 gl_FUNC_GETOPT_GNU 414 gl_FUNC_GETOPT_GNU
241 if test $REPLACE_GETOPT = 1; then 415 dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the gl_getopt_required
242 AC_LIBOBJ([getopt]) 416 dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they are
243 AC_LIBOBJ([getopt1]) 417 dnl done in the getopt-posix module.
244 gl_PREREQ_GETOPT
245 dnl Arrange for unistd.h to include getopt.h.
246 GNULIB_GL_UNISTD_H_GETOPT=1
247 fi
248 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
249 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
250 gl_FUNC_GETOPT_POSIX 418 gl_FUNC_GETOPT_POSIX
251 if test $REPLACE_GETOPT = 1; then 419 gl_CONDITIONAL_HEADER([getopt.h])
252 AC_LIBOBJ([getopt]) 420 gl_CONDITIONAL_HEADER([getopt-cdefs.h])
253 AC_LIBOBJ([getopt1]) 421 AC_PROG_MKDIR_P
254 gl_PREREQ_GETOPT 422 gl_CONDITIONAL([GL_COND_OBJ_GETOPT], [test $REPLACE_GETOPT = 1])
255 dnl Arrange for unistd.h to include getopt.h. 423 AM_COND_IF([GL_COND_OBJ_GETOPT], [
256 GNULIB_GL_UNISTD_H_GETOPT=1 424 dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1.
257 fi 425 gl_UNISTD_H_REQUIRE_DEFAULTS
258 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT]) 426 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1])
259 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. 427 ])
260 AM_GNU_GETTEXT_VERSION([0.18.1]) 428 gl_UNISTD_MODULE_INDICATOR([getopt-posix])
429 gl_FUNC_GETPROGNAME
261 AC_SUBST([LIBINTL]) 430 AC_SUBST([LIBINTL])
262 AC_SUBST([LTLIBINTL]) 431 AC_SUBST([LTLIBINTL])
432 AC_PROG_MKDIR_P
433 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
434 LIB_HARD_LOCALE="$LIB_SETLOCALE_NULL"
435 AC_SUBST([LIB_HARD_LOCALE])
263 gl_HOSTENT 436 gl_HOSTENT
264 gl_IDPRIV 437 gl_IDPRIV
265 gl_FUNC_INET_NTOP 438 gl_FUNC_INET_NTOP
266 if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then 439 gl_CONDITIONAL([GL_COND_OBJ_INET_NTOP],
267 AC_LIBOBJ([inet_ntop]) 440 [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1])
441 AM_COND_IF([GL_COND_OBJ_INET_NTOP], [
268 gl_PREREQ_INET_NTOP 442 gl_PREREQ_INET_NTOP
269 fi 443 ])
270 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) 444 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
445 gl_INTTYPES_INCOMPLETE
446 gl_INTTYPES_H_REQUIRE_DEFAULTS
447 AC_PROG_MKDIR_P
271 gl_LANGINFO_H 448 gl_LANGINFO_H
449 gl_LANGINFO_H_REQUIRE_DEFAULTS
450 AC_PROG_MKDIR_P
272 AC_REQUIRE([gl_LARGEFILE]) 451 AC_REQUIRE([gl_LARGEFILE])
452 gl___INLINE
453 gl_LIMITS_H
454 gl_CONDITIONAL_HEADER([limits.h])
455 AC_PROG_MKDIR_P
273 gl_LOCALCHARSET 456 gl_LOCALCHARSET
274 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" 457 dnl For backward compatibility. Some packages still use this.
458 LOCALCHARSET_TESTS_ENVIRONMENT=
275 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) 459 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
276 gl_LOCALE_H 460 gl_LOCALE_H
461 gl_LOCALE_H_REQUIRE_DEFAULTS
462 AC_PROG_MKDIR_P
277 gl_FUNC_LOCALECONV 463 gl_FUNC_LOCALECONV
278 if test $REPLACE_LOCALECONV = 1; then 464 gl_CONDITIONAL([GL_COND_OBJ_LOCALECONV], [test $REPLACE_LOCALECONV = 1])
279 AC_LIBOBJ([localeconv]) 465 AM_COND_IF([GL_COND_OBJ_LOCALECONV], [
280 gl_PREREQ_LOCALECONV 466 gl_PREREQ_LOCALECONV
281 fi 467 ])
282 gl_LOCALE_MODULE_INDICATOR([localeconv]) 468 gl_LOCALE_MODULE_INDICATOR([localeconv])
283 gl_LOCK 469 gl_LOCK
284 gl_MODULE_INDICATOR([lock]) 470 gl_MODULE_INDICATOR([lock])
471 gl_FUNC_LSEEK
472 gl_CONDITIONAL([GL_COND_OBJ_LSEEK], [test $REPLACE_LSEEK = 1])
473 gl_UNISTD_MODULE_INDICATOR([lseek])
285 gl_FUNC_MALLOC_GNU 474 gl_FUNC_MALLOC_GNU
286 if test $REPLACE_MALLOC = 1; then 475 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then
287 AC_LIBOBJ([malloc]) 476 AC_LIBOBJ([malloc])
288 fi 477 fi
289 gl_MODULE_INDICATOR([malloc-gnu]) 478 gl_STDLIB_MODULE_INDICATOR([malloc-gnu])
290 gl_FUNC_MALLOC_POSIX 479 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
291 if test $REPLACE_MALLOC = 1; then 480 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
292 AC_LIBOBJ([malloc]) 481 AC_LIBOBJ([malloc])
293 fi 482 fi
294 gl_STDLIB_MODULE_INDICATOR([malloc-posix]) 483 gl_STDLIB_MODULE_INDICATOR([malloc-posix])
295 gl_MALLOCA 484 gl_MALLOCA
296 gl_MATH_H 485 gl_MATH_H
486 gl_MATH_H_REQUIRE_DEFAULTS
487 AC_PROG_MKDIR_P
297 gl_FUNC_MBRTOWC 488 gl_FUNC_MBRTOWC
298 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then 489 gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC],
299 AC_LIBOBJ([mbrtowc]) 490 [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1])
491 AM_COND_IF([GL_COND_OBJ_MBRTOWC], [
492 if test $REPLACE_MBSTATE_T = 1; then
493 AC_LIBOBJ([lc-charset-dispatch])
494 AC_LIBOBJ([mbtowc-lock])
495 gl_PREREQ_MBTOWC_LOCK
496 fi
300 gl_PREREQ_MBRTOWC 497 gl_PREREQ_MBRTOWC
301 fi 498 ])
302 gl_WCHAR_MODULE_INDICATOR([mbrtowc]) 499 gl_WCHAR_MODULE_INDICATOR([mbrtowc])
303 gl_FUNC_MBSINIT 500 gl_FUNC_MBSINIT
304 if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then 501 gl_CONDITIONAL([GL_COND_OBJ_MBSINIT],
305 AC_LIBOBJ([mbsinit]) 502 [test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1])
503 AM_COND_IF([GL_COND_OBJ_MBSINIT], [
306 gl_PREREQ_MBSINIT 504 gl_PREREQ_MBSINIT
307 fi 505 ])
308 gl_WCHAR_MODULE_INDICATOR([mbsinit]) 506 gl_WCHAR_MODULE_INDICATOR([mbsinit])
309 gl_FUNC_MBTOWC 507 gl_FUNC_MBTOWC
310 if test $REPLACE_MBTOWC = 1; then 508 gl_CONDITIONAL([GL_COND_OBJ_MBTOWC],
311 AC_LIBOBJ([mbtowc]) 509 [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1])
510 AM_COND_IF([GL_COND_OBJ_MBTOWC], [
312 gl_PREREQ_MBTOWC 511 gl_PREREQ_MBTOWC
313 fi 512 ])
314 gl_STDLIB_MODULE_INDICATOR([mbtowc]) 513 gl_STDLIB_MODULE_INDICATOR([mbtowc])
315 gl_FUNC_MEMCHR 514 gl_FUNC_MEMCHR
316 if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then 515 gl_CONDITIONAL([GL_COND_OBJ_MEMCHR], [test $REPLACE_MEMCHR = 1])
317 AC_LIBOBJ([memchr]) 516 AM_COND_IF([GL_COND_OBJ_MEMCHR], [
318 gl_PREREQ_MEMCHR 517 gl_PREREQ_MEMCHR
319 fi 518 ])
320 gl_STRING_MODULE_INDICATOR([memchr]) 519 gl_STRING_MODULE_INDICATOR([memchr])
520 gl_MINMAX
321 gl_FUNC_MKTIME 521 gl_FUNC_MKTIME
322 if test $REPLACE_MKTIME = 1; then 522 if test $REPLACE_MKTIME = 1; then
323 AC_LIBOBJ([mktime]) 523 AC_LIBOBJ([mktime])
@@ -325,73 +525,162 @@ AC_DEFUN([gl_INIT],
325 fi 525 fi
326 gl_TIME_MODULE_INDICATOR([mktime]) 526 gl_TIME_MODULE_INDICATOR([mktime])
327 gl_FUNC_MKTIME_INTERNAL 527 gl_FUNC_MKTIME_INTERNAL
328 if test $REPLACE_MKTIME = 1; then 528 if test $WANT_MKTIME_INTERNAL = 1; then
329 AC_LIBOBJ([mktime]) 529 AC_LIBOBJ([mktime])
330 gl_PREREQ_MKTIME 530 gl_PREREQ_MKTIME
331 fi 531 fi
332 gl_MOUNTLIST 532 gl_MOUNTLIST
333 if test $gl_cv_list_mounted_fs = yes; then 533 gl_CONDITIONAL([GL_COND_OBJ_MOUNTLIST], [test $gl_cv_list_mounted_fs = yes])
334 AC_LIBOBJ([mountlist]) 534 AM_COND_IF([GL_COND_OBJ_MOUNTLIST], [
335 gl_PREREQ_MOUNTLIST_EXTRA 535 gl_PREREQ_MOUNTLIST_EXTRA
336 fi 536 ])
337 gl_MSVC_INVAL 537 AC_REQUIRE([gl_MSVC_INVAL])
338 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 538 gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL],
339 AC_LIBOBJ([msvc-inval]) 539 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1])
340 fi 540 AC_REQUIRE([gl_MSVC_NOTHROW])
341 gl_MSVC_NOTHROW 541 gl_CONDITIONAL([GL_COND_OBJ_MSVC_NOTHROW],
342 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 542 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1])
343 AC_LIBOBJ([msvc-nothrow]) 543 gl_MODULE_INDICATOR([msvc-nothrow])
344 fi
345 gl_MULTIARCH 544 gl_MULTIARCH
346 gl_HEADER_NETDB 545 gl_NETDB_H
546 gl_NETDB_H_REQUIRE_DEFAULTS
547 AC_PROG_MKDIR_P
347 gl_HEADER_NETINET_IN 548 gl_HEADER_NETINET_IN
549 gl_CONDITIONAL_HEADER([netinet/in.h])
348 AC_PROG_MKDIR_P 550 AC_PROG_MKDIR_P
349 gl_FUNC_NL_LANGINFO 551 gl_FUNC_NL_LANGINFO
350 if test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1; then 552 gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO],
351 AC_LIBOBJ([nl_langinfo]) 553 [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1])
554 gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO_LOCK],
555 [test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0])
556 if test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0; then
557 gl_PREREQ_NL_LANGINFO_LOCK
352 fi 558 fi
353 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) 559 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
354 gl_FUNC_READ 560 gl_FUNC_OPEN
355 if test $REPLACE_READ = 1; then 561 gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1])
356 AC_LIBOBJ([read]) 562 AM_COND_IF([GL_COND_OBJ_OPEN], [
357 gl_PREREQ_READ 563 gl_PREREQ_OPEN
564 ])
565 gl_FCNTL_MODULE_INDICATOR([open])
566 gl_PATHMAX
567 gl_FUNC_REALLOC_GNU
568 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
569 AC_LIBOBJ([realloc])
570 fi
571 gl_STDLIB_MODULE_INDICATOR([realloc-gnu])
572 gl_FUNC_REALLOC_POSIX
573 if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then
574 AC_LIBOBJ([realloc])
358 fi 575 fi
359 gl_UNISTD_MODULE_INDICATOR([read]) 576 gl_STDLIB_MODULE_INDICATOR([realloc-posix])
577 gl_FUNC_REALLOCARRAY
578 gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY],
579 [test $HAVE_REALLOCARRAY = 0 || test $REPLACE_REALLOCARRAY = 1])
580 AM_COND_IF([GL_COND_OBJ_REALLOCARRAY], [
581 gl_PREREQ_REALLOCARRAY
582 ])
583 gl_MODULE_INDICATOR([reallocarray])
584 gl_STDLIB_MODULE_INDICATOR([reallocarray])
360 gl_REGEX 585 gl_REGEX
361 if test $ac_use_included_regex = yes; then 586 gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes])
362 AC_LIBOBJ([regex]) 587 AM_COND_IF([GL_COND_OBJ_REGEX], [
363 gl_PREREQ_REGEX 588 gl_PREREQ_REGEX
364 fi 589 ])
365 gl_PREREQ_SAFE_READ
366 gl_SERVENT 590 gl_SERVENT
367 gl_FUNC_SETENV 591 gl_FUNC_SETENV
368 if test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1; then 592 gl_CONDITIONAL([GL_COND_OBJ_SETENV],
369 AC_LIBOBJ([setenv]) 593 [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1])
370 fi
371 gl_STDLIB_MODULE_INDICATOR([setenv]) 594 gl_STDLIB_MODULE_INDICATOR([setenv])
595 gl_FUNC_SETLOCALE_NULL
596 gl_CONDITIONAL([GL_COND_OBJ_SETLOCALE_LOCK],
597 [test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0])
598 AM_COND_IF([GL_COND_OBJ_SETLOCALE_LOCK], [
599 gl_PREREQ_SETLOCALE_LOCK
600 ])
601 gl_LOCALE_MODULE_INDICATOR([setlocale_null])
372 gl_SIZE_MAX 602 gl_SIZE_MAX
373 gl_FUNC_SNPRINTF 603 gl_FUNC_SNPRINTF
374 gl_STDIO_MODULE_INDICATOR([snprintf]) 604 gl_STDIO_MODULE_INDICATOR([snprintf])
375 gl_MODULE_INDICATOR([snprintf]) 605 gl_MODULE_INDICATOR([snprintf])
376 gl_SOCKETLIB 606 AC_REQUIRE([gl_SOCKETLIB])
377 gl_SOCKETS 607 AC_REQUIRE([gl_SOCKETS])
378 gl_TYPE_SOCKLEN_T 608 gl_TYPE_SOCKLEN_T
379 gt_TYPE_SSIZE_T 609 gt_TYPE_SSIZE_T
610 gl_FUNC_STAT
611 gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1])
612 AM_COND_IF([GL_COND_OBJ_STAT], [
613 case "$host_os" in
614 mingw*)
615 AC_LIBOBJ([stat-w32])
616 ;;
617 esac
618 gl_PREREQ_STAT
619 ])
620 gl_SYS_STAT_MODULE_INDICATOR([stat])
621 gl_STAT_TIME
622 gl_STAT_BIRTHTIME
380 gl_STDALIGN_H 623 gl_STDALIGN_H
381 AM_STDBOOL_H 624 gl_CONDITIONAL_HEADER([stdalign.h])
625 AC_PROG_MKDIR_P
626 gl_C_BOOL
627 AC_CHECK_HEADERS_ONCE([stdckdint.h])
628 if test $ac_cv_header_stdckdint_h = yes; then
629 GL_GENERATE_STDCKDINT_H=false
630 else
631 GL_GENERATE_STDCKDINT_H=true
632 fi
633 gl_CONDITIONAL_HEADER([stdckdint.h])
634 AC_PROG_MKDIR_P
382 gl_STDDEF_H 635 gl_STDDEF_H
636 gl_STDDEF_H_REQUIRE_DEFAULTS
637 gl_CONDITIONAL_HEADER([stddef.h])
638 AC_PROG_MKDIR_P
383 gl_STDINT_H 639 gl_STDINT_H
640 gl_CONDITIONAL_HEADER([stdint.h])
641 dnl Because of gl_REPLACE_LIMITS_H:
642 gl_CONDITIONAL_HEADER([limits.h])
643 AC_PROG_MKDIR_P
384 gl_STDIO_H 644 gl_STDIO_H
645 gl_STDIO_H_REQUIRE_DEFAULTS
646 AC_PROG_MKDIR_P
647 gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1])
648 gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1])
649 dnl No need to create extra modules for these functions. Everyone who uses
650 dnl <stdio.h> likely needs them.
651 gl_STDIO_MODULE_INDICATOR([fscanf])
652 gl_MODULE_INDICATOR([fscanf])
653 gl_STDIO_MODULE_INDICATOR([scanf])
654 gl_MODULE_INDICATOR([scanf])
655 gl_STDIO_MODULE_INDICATOR([fgetc])
656 gl_STDIO_MODULE_INDICATOR([getc])
657 gl_STDIO_MODULE_INDICATOR([getchar])
658 gl_STDIO_MODULE_INDICATOR([fgets])
659 gl_STDIO_MODULE_INDICATOR([fread])
660 dnl No need to create extra modules for these functions. Everyone who uses
661 dnl <stdio.h> likely needs them.
662 gl_STDIO_MODULE_INDICATOR([fprintf])
663 gl_STDIO_MODULE_INDICATOR([printf])
664 gl_STDIO_MODULE_INDICATOR([vfprintf])
665 gl_STDIO_MODULE_INDICATOR([vprintf])
666 gl_STDIO_MODULE_INDICATOR([fputc])
667 gl_STDIO_MODULE_INDICATOR([putc])
668 gl_STDIO_MODULE_INDICATOR([putchar])
669 gl_STDIO_MODULE_INDICATOR([fputs])
670 gl_STDIO_MODULE_INDICATOR([puts])
671 gl_STDIO_MODULE_INDICATOR([fwrite])
385 gl_STDLIB_H 672 gl_STDLIB_H
673 gl_STDLIB_H_REQUIRE_DEFAULTS
674 AC_PROG_MKDIR_P
386 gl_STRCASE 675 gl_STRCASE
387 if test $HAVE_STRCASECMP = 0; then 676 gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP], [test $HAVE_STRCASECMP = 0])
388 AC_LIBOBJ([strcasecmp]) 677 AM_COND_IF([GL_COND_OBJ_STRCASECMP], [
389 gl_PREREQ_STRCASECMP 678 gl_PREREQ_STRCASECMP
390 fi 679 ])
391 if test $HAVE_STRNCASECMP = 0; then 680 gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP], [test $HAVE_STRNCASECMP = 0])
392 AC_LIBOBJ([strncasecmp]) 681 AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [
393 gl_PREREQ_STRNCASECMP 682 gl_PREREQ_STRNCASECMP
394 fi 683 ])
395 gl_FUNC_STRCASESTR 684 gl_FUNC_STRCASESTR
396 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then 685 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
397 AC_LIBOBJ([strcasestr]) 686 AC_LIBOBJ([strcasestr])
@@ -404,68 +693,76 @@ AC_DEFUN([gl_INIT],
404 fi 693 fi
405 gl_STRING_MODULE_INDICATOR([strcasestr]) 694 gl_STRING_MODULE_INDICATOR([strcasestr])
406 gl_FUNC_STRERROR 695 gl_FUNC_STRERROR
407 if test $REPLACE_STRERROR = 1; then 696 gl_CONDITIONAL([GL_COND_OBJ_STRERROR], [test $REPLACE_STRERROR = 1])
408 AC_LIBOBJ([strerror])
409 fi
410 gl_MODULE_INDICATOR([strerror]) 697 gl_MODULE_INDICATOR([strerror])
411 gl_STRING_MODULE_INDICATOR([strerror]) 698 gl_STRING_MODULE_INDICATOR([strerror])
412 AC_REQUIRE([gl_HEADER_ERRNO_H]) 699 AC_REQUIRE([gl_HEADER_ERRNO_H])
413 AC_REQUIRE([gl_FUNC_STRERROR_0]) 700 AC_REQUIRE([gl_FUNC_STRERROR_0])
414 if test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1; then 701 gl_CONDITIONAL([GL_COND_OBJ_STRERROR_OVERRIDE],
415 AC_LIBOBJ([strerror-override]) 702 [test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1])
703 AM_COND_IF([GL_COND_OBJ_STRERROR_OVERRIDE], [
416 gl_PREREQ_SYS_H_WINSOCK2 704 gl_PREREQ_SYS_H_WINSOCK2
417 fi 705 ])
418 gl_HEADER_STRING_H 706 gl_STRING_H
419 gl_HEADER_STRINGS_H 707 gl_STRING_H_REQUIRE_DEFAULTS
420 gl_FUNC_STRNDUP 708 AC_PROG_MKDIR_P
421 if test $HAVE_STRNDUP = 0 || test $REPLACE_STRNDUP = 1; then 709 gl_STRINGS_H
422 AC_LIBOBJ([strndup]) 710 gl_STRINGS_H_REQUIRE_DEFAULTS
423 fi 711 AC_PROG_MKDIR_P
424 gl_STRING_MODULE_INDICATOR([strndup])
425 gl_FUNC_STRNLEN
426 if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
427 AC_LIBOBJ([strnlen])
428 gl_PREREQ_STRNLEN
429 fi
430 gl_STRING_MODULE_INDICATOR([strnlen])
431 gl_FUNC_STRSEP 712 gl_FUNC_STRSEP
432 if test $HAVE_STRSEP = 0; then 713 gl_CONDITIONAL([GL_COND_OBJ_STRSEP], [test $HAVE_STRSEP = 0])
433 AC_LIBOBJ([strsep]) 714 AM_COND_IF([GL_COND_OBJ_STRSEP], [
434 gl_PREREQ_STRSEP 715 gl_PREREQ_STRSEP
435 fi 716 ])
436 gl_STRING_MODULE_INDICATOR([strsep]) 717 gl_STRING_MODULE_INDICATOR([strsep])
437 gl_FUNC_STRSTR_SIMPLE 718 gl_FUNC_STRSTR_SIMPLE
438 if test $REPLACE_STRSTR = 1; then 719 if test $REPLACE_STRSTR = 1; then
439 AC_LIBOBJ([strstr]) 720 AC_LIBOBJ([strstr])
440 fi 721 fi
441 gl_STRING_MODULE_INDICATOR([strstr]) 722 gl_STRING_MODULE_INDICATOR([strstr])
442 gl_HEADER_SYS_SOCKET 723 gl_SYS_SOCKET_H
724 gl_SYS_SOCKET_H_REQUIRE_DEFAULTS
725 AC_PROG_MKDIR_P
726 gl_SYS_STAT_H
727 gl_SYS_STAT_H_REQUIRE_DEFAULTS
443 AC_PROG_MKDIR_P 728 AC_PROG_MKDIR_P
444 gl_SYS_TYPES_H 729 gl_SYS_TYPES_H
730 gl_SYS_TYPES_H_REQUIRE_DEFAULTS
731 AC_PROG_MKDIR_P
732 gl_SYS_UIO_H
733 gl_SYS_UIO_H_REQUIRE_DEFAULTS
445 AC_PROG_MKDIR_P 734 AC_PROG_MKDIR_P
446 gl_HEADER_SYS_UIO 735 AC_REQUIRE([gl_THREADLIB])
736 gl_TIME_H
737 gl_TIME_H_REQUIRE_DEFAULTS
447 AC_PROG_MKDIR_P 738 AC_PROG_MKDIR_P
448 gl_THREADLIB
449 gl_HEADER_TIME_H
450 gl_TIME_R 739 gl_TIME_R
451 if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then 740 gl_CONDITIONAL([GL_COND_OBJ_TIME_R],
452 AC_LIBOBJ([time_r]) 741 [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1])
742 AM_COND_IF([GL_COND_OBJ_TIME_R], [
453 gl_PREREQ_TIME_R 743 gl_PREREQ_TIME_R
454 fi 744 ])
455 gl_TIME_MODULE_INDICATOR([time_r]) 745 gl_TIME_MODULE_INDICATOR([time_r])
456 gl_FUNC_TIMEGM 746 gl_FUNC_TIMEGM
457 if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then 747 gl_CONDITIONAL([GL_COND_OBJ_TIMEGM],
458 AC_LIBOBJ([timegm]) 748 [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1])
749 AM_COND_IF([GL_COND_OBJ_TIMEGM], [
459 gl_PREREQ_TIMEGM 750 gl_PREREQ_TIMEGM
460 fi 751 ])
461 gl_TIME_MODULE_INDICATOR([timegm]) 752 gl_TIME_MODULE_INDICATOR([timegm])
462 gl_UNISTD_H 753 gl_UNISTD_H
754 gl_UNISTD_H_REQUIRE_DEFAULTS
755 AC_PROG_MKDIR_P
756 gl_FUNC_GLIBC_UNLOCKED_IO
463 gl_FUNC_UNSETENV 757 gl_FUNC_UNSETENV
464 if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then 758 gl_CONDITIONAL([GL_COND_OBJ_UNSETENV],
465 AC_LIBOBJ([unsetenv]) 759 [test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1])
760 AM_COND_IF([GL_COND_OBJ_UNSETENV], [
466 gl_PREREQ_UNSETENV 761 gl_PREREQ_UNSETENV
467 fi 762 ])
468 gl_STDLIB_MODULE_INDICATOR([unsetenv]) 763 gl_STDLIB_MODULE_INDICATOR([unsetenv])
764 AC_C_VARARRAYS
765 AC_REQUIRE([AC_C_RESTRICT])
469 gl_FUNC_VASNPRINTF 766 gl_FUNC_VASNPRINTF
470 gl_FUNC_VASPRINTF 767 gl_FUNC_VASPRINTF
471 gl_STDIO_MODULE_INDICATOR([vasprintf]) 768 gl_STDIO_MODULE_INDICATOR([vasprintf])
@@ -475,16 +772,34 @@ AC_DEFUN([gl_INIT],
475 gl_FUNC_VSNPRINTF 772 gl_FUNC_VSNPRINTF
476 gl_STDIO_MODULE_INDICATOR([vsnprintf]) 773 gl_STDIO_MODULE_INDICATOR([vsnprintf])
477 gl_WCHAR_H 774 gl_WCHAR_H
775 gl_WCHAR_H_REQUIRE_DEFAULTS
776 AC_PROG_MKDIR_P
478 gl_FUNC_WCRTOMB 777 gl_FUNC_WCRTOMB
479 if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then 778 gl_CONDITIONAL([GL_COND_OBJ_WCRTOMB],
480 AC_LIBOBJ([wcrtomb]) 779 [test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1])
780 AM_COND_IF([GL_COND_OBJ_WCRTOMB], [
481 gl_PREREQ_WCRTOMB 781 gl_PREREQ_WCRTOMB
482 fi 782 ])
483 gl_WCHAR_MODULE_INDICATOR([wcrtomb]) 783 gl_WCHAR_MODULE_INDICATOR([wcrtomb])
484 gl_WCTYPE_H 784 gl_WCTYPE_H
785 gl_WCTYPE_H_REQUIRE_DEFAULTS
786 AC_PROG_MKDIR_P
787 AC_REQUIRE([AC_CANONICAL_HOST])
788 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX],
789 [case "$host_os" in mingw*) true;; *) false;; esac])
790 AC_REQUIRE([AC_CANONICAL_HOST])
791 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE],
792 [case "$host_os" in mingw*) true;; *) false;; esac])
793 AC_REQUIRE([AC_CANONICAL_HOST])
794 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX],
795 [case "$host_os" in mingw*) true;; *) false;; esac])
796 AC_REQUIRE([AC_CANONICAL_HOST])
797 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK],
798 [case "$host_os" in mingw*) true;; *) false;; esac])
485 gl_XALLOC 799 gl_XALLOC
800 gl_MODULE_INDICATOR([xalloc])
801 gl_MODULE_INDICATOR([xalloc-die])
486 gl_XSIZE 802 gl_XSIZE
487 gl_XSTRNDUP
488 # End of code from modules 803 # End of code from modules
489 m4_ifval(gl_LIBSOURCES_LIST, [ 804 m4_ifval(gl_LIBSOURCES_LIST, [
490 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || 805 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
@@ -497,6 +812,8 @@ AC_DEFUN([gl_INIT],
497 m4_if(m4_sysval, [0], [], 812 m4_if(m4_sysval, [0], [],
498 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) 813 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
499 ]) 814 ])
815 m4_popdef([GL_MODULE_INDICATOR_PREFIX])
816 m4_popdef([GL_MACRO_PREFIX])
500 m4_popdef([gl_LIBSOURCES_DIR]) 817 m4_popdef([gl_LIBSOURCES_DIR])
501 m4_popdef([gl_LIBSOURCES_LIST]) 818 m4_popdef([gl_LIBSOURCES_LIST])
502 m4_popdef([AC_LIBSOURCES]) 819 m4_popdef([AC_LIBSOURCES])
@@ -505,16 +822,28 @@ AC_DEFUN([gl_INIT],
505 AC_CONFIG_COMMANDS_PRE([ 822 AC_CONFIG_COMMANDS_PRE([
506 gl_libobjs= 823 gl_libobjs=
507 gl_ltlibobjs= 824 gl_ltlibobjs=
825 gl_libobjdeps=
508 if test -n "$gl_LIBOBJS"; then 826 if test -n "$gl_LIBOBJS"; then
509 # Remove the extension. 827 # Remove the extension.
828changequote(,)dnl
510 sed_drop_objext='s/\.o$//;s/\.obj$//' 829 sed_drop_objext='s/\.o$//;s/\.obj$//'
830 sed_dirname1='s,//*,/,g'
831 sed_dirname2='s,\(.\)/$,\1,'
832 sed_dirname3='s,^[^/]*$,.,'
833 sed_dirname4='s,\(.\)/[^/]*$,\1,'
834 sed_basename1='s,.*/,,'
835changequote([, ])dnl
511 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 836 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
512 gl_libobjs="$gl_libobjs $i.$ac_objext" 837 gl_libobjs="$gl_libobjs $i.$ac_objext"
513 gl_ltlibobjs="$gl_ltlibobjs $i.lo" 838 gl_ltlibobjs="$gl_ltlibobjs $i.lo"
839 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
840 i_base=`echo "$i" | sed -e "$sed_basename1"`
841 gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
514 done 842 done
515 fi 843 fi
516 AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) 844 AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
517 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) 845 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
846 AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps])
518 ]) 847 ])
519 gltests_libdeps= 848 gltests_libdeps=
520 gltests_ltlibdeps= 849 gltests_ltlibdeps=
@@ -523,8 +852,11 @@ AC_DEFUN([gl_INIT],
523 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) 852 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
524 m4_pushdef([gltests_LIBSOURCES_LIST], []) 853 m4_pushdef([gltests_LIBSOURCES_LIST], [])
525 m4_pushdef([gltests_LIBSOURCES_DIR], []) 854 m4_pushdef([gltests_LIBSOURCES_DIR], [])
855 m4_pushdef([GL_MACRO_PREFIX], [gltests])
856 m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL])
526 gl_COMMON 857 gl_COMMON
527 gl_source_base='tests' 858 gl_source_base='tests'
859 gl_source_base_prefix=
528changequote(,)dnl 860changequote(,)dnl
529 gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS 861 gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
530changequote([, ])dnl 862changequote([, ])dnl
@@ -543,6 +875,8 @@ changequote([, ])dnl
543 m4_if(m4_sysval, [0], [], 875 m4_if(m4_sysval, [0], [],
544 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) 876 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
545 ]) 877 ])
878 m4_popdef([GL_MODULE_INDICATOR_PREFIX])
879 m4_popdef([GL_MACRO_PREFIX])
546 m4_popdef([gltests_LIBSOURCES_DIR]) 880 m4_popdef([gltests_LIBSOURCES_DIR])
547 m4_popdef([gltests_LIBSOURCES_LIST]) 881 m4_popdef([gltests_LIBSOURCES_LIST])
548 m4_popdef([AC_LIBSOURCES]) 882 m4_popdef([AC_LIBSOURCES])
@@ -551,17 +885,30 @@ changequote([, ])dnl
551 AC_CONFIG_COMMANDS_PRE([ 885 AC_CONFIG_COMMANDS_PRE([
552 gltests_libobjs= 886 gltests_libobjs=
553 gltests_ltlibobjs= 887 gltests_ltlibobjs=
888 gltests_libobjdeps=
554 if test -n "$gltests_LIBOBJS"; then 889 if test -n "$gltests_LIBOBJS"; then
555 # Remove the extension. 890 # Remove the extension.
891changequote(,)dnl
556 sed_drop_objext='s/\.o$//;s/\.obj$//' 892 sed_drop_objext='s/\.o$//;s/\.obj$//'
893 sed_dirname1='s,//*,/,g'
894 sed_dirname2='s,\(.\)/$,\1,'
895 sed_dirname3='s,^[^/]*$,.,'
896 sed_dirname4='s,\(.\)/[^/]*$,\1,'
897 sed_basename1='s,.*/,,'
898changequote([, ])dnl
557 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 899 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
558 gltests_libobjs="$gltests_libobjs $i.$ac_objext" 900 gltests_libobjs="$gltests_libobjs $i.$ac_objext"
559 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" 901 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
902 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
903 i_base=`echo "$i" | sed -e "$sed_basename1"`
904 gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
560 done 905 done
561 fi 906 fi
562 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) 907 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
563 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) 908 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
909 AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps])
564 ]) 910 ])
911 AC_REQUIRE([gl_CC_GNULIB_WARNINGS])
565 LIBGNU_LIBDEPS="$gl_libdeps" 912 LIBGNU_LIBDEPS="$gl_libdeps"
566 AC_SUBST([LIBGNU_LIBDEPS]) 913 AC_SUBST([LIBGNU_LIBDEPS])
567 LIBGNU_LTLIBDEPS="$gl_ltlibdeps" 914 LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
@@ -625,76 +972,130 @@ AC_DEFUN([gltests_LIBSOURCES], [
625# This macro records the list of files which have been installed by 972# This macro records the list of files which have been installed by
626# gnulib-tool and may be removed by future gnulib-tool invocations. 973# gnulib-tool and may be removed by future gnulib-tool invocations.
627AC_DEFUN([gl_FILE_LIST], [ 974AC_DEFUN([gl_FILE_LIST], [
628 build-aux/config.rpath 975 lib/_Noreturn.h
629 build-aux/snippet/_Noreturn.h 976 lib/af_alg.c
630 build-aux/snippet/arg-nonnull.h 977 lib/af_alg.h
631 build-aux/snippet/c++defs.h
632 build-aux/snippet/warn-on-use.h
633 lib/alloca.in.h 978 lib/alloca.in.h
979 lib/arg-nonnull.h
634 lib/arpa_inet.in.h 980 lib/arpa_inet.in.h
635 lib/asnprintf.c 981 lib/asnprintf.c
636 lib/asprintf.c 982 lib/asprintf.c
983 lib/assert.in.h
984 lib/attribute.h
637 lib/base64.c 985 lib/base64.c
638 lib/base64.h 986 lib/base64.h
639 lib/basename-lgpl.c 987 lib/basename-lgpl.c
988 lib/basename-lgpl.h
640 lib/basename.c 989 lib/basename.c
641 lib/btowc.c 990 lib/btowc.c
642 lib/config.charset 991 lib/byteswap.in.h
992 lib/c++defs.h
993 lib/calloc.c
994 lib/cdefs.h
995 lib/cloexec.c
996 lib/cloexec.h
997 lib/close.c
643 lib/dirname-lgpl.c 998 lib/dirname-lgpl.c
644 lib/dirname.c 999 lib/dirname.c
645 lib/dirname.h 1000 lib/dirname.h
646 lib/dosname.h 1001 lib/dup2.c
1002 lib/dynarray.h
647 lib/errno.in.h 1003 lib/errno.in.h
648 lib/error.c 1004 lib/error.c
649 lib/error.h 1005 lib/error.h
650 lib/exitfail.c 1006 lib/exitfail.c
651 lib/exitfail.h 1007 lib/exitfail.h
1008 lib/fcntl.c
1009 lib/fcntl.in.h
652 lib/fd-hook.c 1010 lib/fd-hook.c
653 lib/fd-hook.h 1011 lib/fd-hook.h
1012 lib/fflush.c
1013 lib/filename.h
654 lib/float+.h 1014 lib/float+.h
655 lib/float.c 1015 lib/float.c
656 lib/float.in.h 1016 lib/float.in.h
657 lib/floor.c 1017 lib/floor.c
658 lib/floorf.c 1018 lib/floorf.c
1019 lib/fopen.c
1020 lib/fpurge.c
1021 lib/freading.c
1022 lib/freading.h
1023 lib/free.c
1024 lib/fseek.c
1025 lib/fseeko.c
1026 lib/fstat.c
659 lib/fsusage.c 1027 lib/fsusage.c
660 lib/fsusage.h 1028 lib/fsusage.h
661 lib/full-read.c 1029 lib/ftell.c
662 lib/full-read.h 1030 lib/ftello.c
663 lib/full-write.c
664 lib/gai_strerror.c 1031 lib/gai_strerror.c
665 lib/getaddrinfo.c 1032 lib/getaddrinfo.c
1033 lib/getdelim.c
1034 lib/getdtablesize.c
666 lib/gethostname.c 1035 lib/gethostname.c
1036 lib/getline.c
667 lib/getloadavg.c 1037 lib/getloadavg.c
1038 lib/getopt-cdefs.in.h
1039 lib/getopt-core.h
1040 lib/getopt-ext.h
1041 lib/getopt-pfx-core.h
1042 lib/getopt-pfx-ext.h
668 lib/getopt.c 1043 lib/getopt.c
669 lib/getopt.in.h 1044 lib/getopt.in.h
670 lib/getopt1.c 1045 lib/getopt1.c
671 lib/getopt_int.h 1046 lib/getopt_int.h
1047 lib/getprogname.c
1048 lib/getprogname.h
672 lib/gettext.h 1049 lib/gettext.h
1050 lib/gl_openssl.h
673 lib/glthread/lock.c 1051 lib/glthread/lock.c
674 lib/glthread/lock.h 1052 lib/glthread/lock.h
675 lib/glthread/threadlib.c 1053 lib/glthread/threadlib.c
1054 lib/hard-locale.c
1055 lib/hard-locale.h
1056 lib/ialloc.c
1057 lib/ialloc.h
676 lib/idpriv-droptemp.c 1058 lib/idpriv-droptemp.c
677 lib/idpriv.h 1059 lib/idpriv.h
1060 lib/idx.h
678 lib/inet_ntop.c 1061 lib/inet_ntop.c
1062 lib/intprops-internal.h
679 lib/intprops.h 1063 lib/intprops.h
1064 lib/inttypes.in.h
680 lib/itold.c 1065 lib/itold.c
681 lib/langinfo.in.h 1066 lib/langinfo.in.h
1067 lib/lc-charset-dispatch.c
1068 lib/lc-charset-dispatch.h
1069 lib/libc-config.h
1070 lib/limits.in.h
682 lib/localcharset.c 1071 lib/localcharset.c
683 lib/localcharset.h 1072 lib/localcharset.h
684 lib/locale.in.h 1073 lib/locale.in.h
685 lib/localeconv.c 1074 lib/localeconv.c
1075 lib/lseek.c
686 lib/malloc.c 1076 lib/malloc.c
1077 lib/malloc/dynarray-skeleton.c
1078 lib/malloc/dynarray.h
1079 lib/malloc/dynarray_at_failure.c
1080 lib/malloc/dynarray_emplace_enlarge.c
1081 lib/malloc/dynarray_finalize.c
1082 lib/malloc/dynarray_resize.c
1083 lib/malloc/dynarray_resize_clear.c
687 lib/malloca.c 1084 lib/malloca.c
688 lib/malloca.h 1085 lib/malloca.h
689 lib/malloca.valgrind
690 lib/math.c 1086 lib/math.c
691 lib/math.in.h 1087 lib/math.in.h
1088 lib/mbrtowc-impl-utf8.h
1089 lib/mbrtowc-impl.h
692 lib/mbrtowc.c 1090 lib/mbrtowc.c
693 lib/mbsinit.c 1091 lib/mbsinit.c
694 lib/mbtowc-impl.h 1092 lib/mbtowc-impl.h
1093 lib/mbtowc-lock.c
1094 lib/mbtowc-lock.h
695 lib/mbtowc.c 1095 lib/mbtowc.c
696 lib/memchr.c 1096 lib/memchr.c
697 lib/memchr.valgrind 1097 lib/memchr.valgrind
1098 lib/minmax.h
698 lib/mktime-internal.h 1099 lib/mktime-internal.h
699 lib/mktime.c 1100 lib/mktime.c
700 lib/mountlist.c 1101 lib/mountlist.c
@@ -705,33 +1106,45 @@ AC_DEFUN([gl_FILE_LIST], [
705 lib/msvc-nothrow.h 1106 lib/msvc-nothrow.h
706 lib/netdb.in.h 1107 lib/netdb.in.h
707 lib/netinet_in.in.h 1108 lib/netinet_in.in.h
1109 lib/nl_langinfo-lock.c
708 lib/nl_langinfo.c 1110 lib/nl_langinfo.c
1111 lib/open.c
1112 lib/pathmax.h
709 lib/printf-args.c 1113 lib/printf-args.c
710 lib/printf-args.h 1114 lib/printf-args.h
711 lib/printf-parse.c 1115 lib/printf-parse.c
712 lib/printf-parse.h 1116 lib/printf-parse.h
713 lib/read.c 1117 lib/realloc.c
714 lib/ref-add.sin 1118 lib/reallocarray.c
715 lib/ref-del.sin
716 lib/regcomp.c 1119 lib/regcomp.c
717 lib/regex.c 1120 lib/regex.c
718 lib/regex.h 1121 lib/regex.h
719 lib/regex_internal.c 1122 lib/regex_internal.c
720 lib/regex_internal.h 1123 lib/regex_internal.h
721 lib/regexec.c 1124 lib/regexec.c
722 lib/safe-read.c
723 lib/safe-read.h
724 lib/setenv.c 1125 lib/setenv.c
725 lib/sha1.c 1126 lib/setlocale-lock.c
726 lib/sha1.h 1127 lib/setlocale_null.c
1128 lib/setlocale_null.h
1129 lib/sha256-stream.c
1130 lib/sha256.c
1131 lib/sha256.h
727 lib/size_max.h 1132 lib/size_max.h
728 lib/snprintf.c 1133 lib/snprintf.c
729 lib/sockets.c 1134 lib/sockets.c
730 lib/sockets.h 1135 lib/sockets.h
1136 lib/stat-time.c
1137 lib/stat-time.h
1138 lib/stat-w32.c
1139 lib/stat-w32.h
1140 lib/stat.c
731 lib/stdalign.in.h 1141 lib/stdalign.in.h
732 lib/stdbool.in.h 1142 lib/stdckdint.in.h
733 lib/stddef.in.h 1143 lib/stddef.in.h
734 lib/stdint.in.h 1144 lib/stdint.in.h
1145 lib/stdio-impl.h
1146 lib/stdio-read.c
1147 lib/stdio-write.c
735 lib/stdio.in.h 1148 lib/stdio.in.h
736 lib/stdlib.in.h 1149 lib/stdlib.in.h
737 lib/str-two-way.h 1150 lib/str-two-way.h
@@ -745,12 +1158,12 @@ AC_DEFUN([gl_FILE_LIST], [
745 lib/strings.in.h 1158 lib/strings.in.h
746 lib/stripslash.c 1159 lib/stripslash.c
747 lib/strncasecmp.c 1160 lib/strncasecmp.c
748 lib/strndup.c
749 lib/strnlen.c
750 lib/strsep.c 1161 lib/strsep.c
751 lib/strstr.c 1162 lib/strstr.c
1163 lib/sys-limits.h
752 lib/sys_socket.c 1164 lib/sys_socket.c
753 lib/sys_socket.in.h 1165 lib/sys_socket.in.h
1166 lib/sys_stat.in.h
754 lib/sys_types.in.h 1167 lib/sys_types.in.h
755 lib/sys_uio.in.h 1168 lib/sys_uio.in.h
756 lib/time.in.h 1169 lib/time.in.h
@@ -758,6 +1171,7 @@ AC_DEFUN([gl_FILE_LIST], [
758 lib/timegm.c 1171 lib/timegm.c
759 lib/unistd.c 1172 lib/unistd.c
760 lib/unistd.in.h 1173 lib/unistd.in.h
1174 lib/unlocked-io.h
761 lib/unsetenv.c 1175 lib/unsetenv.c
762 lib/vasnprintf.c 1176 lib/vasnprintf.c
763 lib/vasnprintf.h 1177 lib/vasnprintf.h
@@ -765,27 +1179,43 @@ AC_DEFUN([gl_FILE_LIST], [
765 lib/verify.h 1179 lib/verify.h
766 lib/vsnprintf.c 1180 lib/vsnprintf.c
767 lib/w32sock.h 1181 lib/w32sock.h
1182 lib/warn-on-use.h
768 lib/wchar.in.h 1183 lib/wchar.in.h
769 lib/wcrtomb.c 1184 lib/wcrtomb.c
770 lib/wctype-h.c 1185 lib/wctype-h.c
771 lib/wctype.in.h 1186 lib/wctype.in.h
1187 lib/windows-initguard.h
1188 lib/windows-mutex.c
1189 lib/windows-mutex.h
1190 lib/windows-once.c
1191 lib/windows-once.h
1192 lib/windows-recmutex.c
1193 lib/windows-recmutex.h
1194 lib/windows-rwlock.c
1195 lib/windows-rwlock.h
772 lib/xalloc-die.c 1196 lib/xalloc-die.c
773 lib/xalloc-oversized.h 1197 lib/xalloc-oversized.h
774 lib/xalloc.h 1198 lib/xalloc.h
775 lib/xmalloc.c 1199 lib/xmalloc.c
776 lib/xsize.c 1200 lib/xsize.c
777 lib/xsize.h 1201 lib/xsize.h
778 lib/xstrndup.c
779 lib/xstrndup.h
780 m4/00gnulib.m4 1202 m4/00gnulib.m4
1203 m4/__inline.m4
1204 m4/absolute-header.m4
1205 m4/af_alg.m4
781 m4/alloca.m4 1206 m4/alloca.m4
782 m4/arpa_inet_h.m4 1207 m4/arpa_inet_h.m4
1208 m4/assert_h.m4
783 m4/base64.m4 1209 m4/base64.m4
784 m4/btowc.m4 1210 m4/btowc.m4
1211 m4/builtin-expect.m4
1212 m4/byteswap.m4
1213 m4/c-bool.m4
1214 m4/calloc.m4
1215 m4/close.m4
785 m4/codeset.m4 1216 m4/codeset.m4
786 m4/configmake.m4
787 m4/dirname.m4
788 m4/double-slash-root.m4 1217 m4/double-slash-root.m4
1218 m4/dup2.m4
789 m4/eealloc.m4 1219 m4/eealloc.m4
790 m4/environ.m4 1220 m4/environ.m4
791 m4/errno_h.m4 1221 m4/errno_h.m4
@@ -794,37 +1224,42 @@ AC_DEFUN([gl_FILE_LIST], [
794 m4/extensions.m4 1224 m4/extensions.m4
795 m4/extern-inline.m4 1225 m4/extern-inline.m4
796 m4/fcntl-o.m4 1226 m4/fcntl-o.m4
1227 m4/fcntl.m4
1228 m4/fcntl_h.m4
1229 m4/fflush.m4
797 m4/float_h.m4 1230 m4/float_h.m4
798 m4/floorf.m4 1231 m4/floorf.m4
1232 m4/fopen.m4
1233 m4/fpurge.m4
1234 m4/freading.m4
1235 m4/free.m4
1236 m4/fseek.m4
1237 m4/fseeko.m4
1238 m4/fstat.m4
799 m4/fstypename.m4 1239 m4/fstypename.m4
800 m4/fsusage.m4 1240 m4/fsusage.m4
1241 m4/ftell.m4
1242 m4/ftello.m4
801 m4/getaddrinfo.m4 1243 m4/getaddrinfo.m4
1244 m4/getdelim.m4
1245 m4/getdtablesize.m4
802 m4/gethostname.m4 1246 m4/gethostname.m4
1247 m4/getline.m4
803 m4/getloadavg.m4 1248 m4/getloadavg.m4
804 m4/getopt.m4 1249 m4/getopt.m4
805 m4/gettext.m4 1250 m4/getprogname.m4
806 m4/glibc2.m4 1251 m4/gl-openssl.m4
807 m4/glibc21.m4
808 m4/gnulib-common.m4 1252 m4/gnulib-common.m4
809 m4/hostent.m4 1253 m4/hostent.m4
810 m4/iconv.m4
811 m4/idpriv.m4 1254 m4/idpriv.m4
812 m4/include_next.m4 1255 m4/include_next.m4
813 m4/inet_ntop.m4 1256 m4/inet_ntop.m4
814 m4/intdiv0.m4
815 m4/intl.m4
816 m4/intldir.m4
817 m4/intlmacosx.m4
818 m4/intmax.m4
819 m4/intmax_t.m4 1257 m4/intmax_t.m4
820 m4/inttypes-pri.m4 1258 m4/inttypes.m4
821 m4/inttypes_h.m4 1259 m4/inttypes_h.m4
822 m4/langinfo_h.m4 1260 m4/langinfo_h.m4
823 m4/largefile.m4 1261 m4/largefile.m4
824 m4/lcmessage.m4 1262 m4/limits-h.m4
825 m4/lib-ld.m4
826 m4/lib-link.m4
827 m4/lib-prefix.m4
828 m4/localcharset.m4 1263 m4/localcharset.m4
829 m4/locale-fr.m4 1264 m4/locale-fr.m4
830 m4/locale-ja.m4 1265 m4/locale-ja.m4
@@ -832,8 +1267,7 @@ AC_DEFUN([gl_FILE_LIST], [
832 m4/locale_h.m4 1267 m4/locale_h.m4
833 m4/localeconv.m4 1268 m4/localeconv.m4
834 m4/lock.m4 1269 m4/lock.m4
835 m4/longlong.m4 1270 m4/lseek.m4
836 m4/ls-mntd-fs.m4
837 m4/malloc.m4 1271 m4/malloc.m4
838 m4/malloca.m4 1272 m4/malloca.m4
839 m4/math_h.m4 1273 m4/math_h.m4
@@ -842,8 +1276,10 @@ AC_DEFUN([gl_FILE_LIST], [
842 m4/mbstate_t.m4 1276 m4/mbstate_t.m4
843 m4/mbtowc.m4 1277 m4/mbtowc.m4
844 m4/memchr.m4 1278 m4/memchr.m4
1279 m4/minmax.m4
845 m4/mktime.m4 1280 m4/mktime.m4
846 m4/mmap-anon.m4 1281 m4/mmap-anon.m4
1282 m4/mode_t.m4
847 m4/mountlist.m4 1283 m4/mountlist.m4
848 m4/msvc-inval.m4 1284 m4/msvc-inval.m4
849 m4/msvc-nothrow.m4 1285 m4/msvc-nothrow.m4
@@ -851,20 +1287,22 @@ AC_DEFUN([gl_FILE_LIST], [
851 m4/netdb_h.m4 1287 m4/netdb_h.m4
852 m4/netinet_in_h.m4 1288 m4/netinet_in_h.m4
853 m4/nl_langinfo.m4 1289 m4/nl_langinfo.m4
854 m4/nls.m4
855 m4/nocrash.m4 1290 m4/nocrash.m4
856 m4/off_t.m4 1291 m4/off_t.m4
857 m4/onceonly.m4 1292 m4/open-cloexec.m4
858 m4/po.m4 1293 m4/open-slash.m4
859 m4/printf-posix.m4 1294 m4/open.m4
1295 m4/pathmax.m4
1296 m4/pid_t.m4
860 m4/printf.m4 1297 m4/printf.m4
861 m4/progtest.m4 1298 m4/pthread_rwlock_rdlock.m4
862 m4/read.m4 1299 m4/realloc.m4
1300 m4/reallocarray.m4
863 m4/regex.m4 1301 m4/regex.m4
864 m4/safe-read.m4
865 m4/servent.m4 1302 m4/servent.m4
866 m4/setenv.m4 1303 m4/setenv.m4
867 m4/sha1.m4 1304 m4/setlocale_null.m4
1305 m4/sha256.m4
868 m4/size_max.m4 1306 m4/size_max.m4
869 m4/snprintf.m4 1307 m4/snprintf.m4
870 m4/socketlib.m4 1308 m4/socketlib.m4
@@ -872,8 +1310,10 @@ AC_DEFUN([gl_FILE_LIST], [
872 m4/socklen.m4 1310 m4/socklen.m4
873 m4/sockpfaf.m4 1311 m4/sockpfaf.m4
874 m4/ssize_t.m4 1312 m4/ssize_t.m4
1313 m4/stat-time.m4
1314 m4/stat.m4
1315 m4/std-gnu11.m4
875 m4/stdalign.m4 1316 m4/stdalign.m4
876 m4/stdbool.m4
877 m4/stddef_h.m4 1317 m4/stddef_h.m4
878 m4/stdint.m4 1318 m4/stdint.m4
879 m4/stdint_h.m4 1319 m4/stdint_h.m4
@@ -884,19 +1324,20 @@ AC_DEFUN([gl_FILE_LIST], [
884 m4/strerror.m4 1324 m4/strerror.m4
885 m4/string_h.m4 1325 m4/string_h.m4
886 m4/strings_h.m4 1326 m4/strings_h.m4
887 m4/strndup.m4
888 m4/strnlen.m4
889 m4/strsep.m4 1327 m4/strsep.m4
890 m4/strstr.m4 1328 m4/strstr.m4
891 m4/sys_socket_h.m4 1329 m4/sys_socket_h.m4
1330 m4/sys_stat_h.m4
892 m4/sys_types_h.m4 1331 m4/sys_types_h.m4
893 m4/sys_uio_h.m4 1332 m4/sys_uio_h.m4
894 m4/threadlib.m4 1333 m4/threadlib.m4
895 m4/time_h.m4 1334 m4/time_h.m4
896 m4/time_r.m4 1335 m4/time_r.m4
897 m4/timegm.m4 1336 m4/timegm.m4
898 m4/uintmax_t.m4 1337 m4/ungetc.m4
899 m4/unistd_h.m4 1338 m4/unistd_h.m4
1339 m4/unlocked-io.m4
1340 m4/vararrays.m4
900 m4/vasnprintf.m4 1341 m4/vasnprintf.m4
901 m4/vasprintf.m4 1342 m4/vasprintf.m4
902 m4/visibility.m4 1343 m4/visibility.m4
@@ -909,5 +1350,5 @@ AC_DEFUN([gl_FILE_LIST], [
909 m4/wint_t.m4 1350 m4/wint_t.m4
910 m4/xalloc.m4 1351 m4/xalloc.m4
911 m4/xsize.m4 1352 m4/xsize.m4
912 m4/xstrndup.m4 1353 m4/zzgnulib.m4
913]) 1354])
diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4
index f3dea1a9..a9dd569b 100644
--- a/gl/m4/gnulib-tool.m4
+++ b/gl/m4/gnulib-tool.m4
@@ -1,5 +1,5 @@
1# gnulib-tool.m4 serial 2 1# gnulib-tool.m4 serial 4
2dnl Copyright (C) 2004-2005, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,12 @@ AC_DEFUN([gl_LGPL], [])
44dnl Usage: gl_MAKEFILE_NAME([FILENAME]) 44dnl Usage: gl_MAKEFILE_NAME([FILENAME])
45AC_DEFUN([gl_MAKEFILE_NAME], []) 45AC_DEFUN([gl_MAKEFILE_NAME], [])
46 46
47dnl Usage: gl_TESTS_MAKEFILE_NAME([FILENAME])
48AC_DEFUN([gl_TESTS_MAKEFILE_NAME], [])
49
50dnl Usage: gl_AUTOMAKE_SUBDIR
51AC_DEFUN([gl_AUTOMAKE_SUBDIR], [])
52
47dnl Usage: gl_LIBTOOL 53dnl Usage: gl_LIBTOOL
48AC_DEFUN([gl_LIBTOOL], []) 54AC_DEFUN([gl_LIBTOOL], [])
49 55
diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4
index 72be876b..3b2cc2b2 100644
--- a/gl/m4/hostent.m4
+++ b/gl/m4/hostent.m4
@@ -1,5 +1,5 @@
1# hostent.m4 serial 2 1# hostent.m4 serial 4
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,12 +8,12 @@ AC_DEFUN([gl_HOSTENT],
8[ 8[
9 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(), 9 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
10 dnl gethostbyaddr() defined? 10 dnl gethostbyaddr() defined?
11 dnl - On Solaris, they are in libnsl. Ignore libxnet. 11 dnl - On Solaris < 11.4, they are in libnsl. Ignore libxnet.
12 dnl - On Haiku, they are in libnetwork. 12 dnl - On Haiku, they are in libnetwork.
13 dnl - On BeOS, they are in libnet. 13 dnl - On BeOS, they are in libnet.
14 dnl - On native Windows, they are in ws2_32.dll. 14 dnl - On native Windows, they are in ws2_32.dll.
15 dnl - Otherwise they are in libc. 15 dnl - Otherwise they are in libc.
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 16 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
17 HOSTENT_LIB= 17 HOSTENT_LIB=
18 gl_saved_libs="$LIBS" 18 gl_saved_libs="$LIBS"
19 AC_SEARCH_LIBS([gethostbyname], [nsl network net], 19 AC_SEARCH_LIBS([gethostbyname], [nsl network net],
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
deleted file mode 100644
index a5036465..00000000
--- a/gl/m4/iconv.m4
+++ /dev/null
@@ -1,268 +0,0 @@
1# iconv.m4 serial 18 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
10[
11 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
12 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
13 AC_REQUIRE([AC_LIB_RPATH])
14
15 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
16 dnl accordingly.
17 AC_LIB_LINKFLAGS_BODY([iconv])
18])
19
20AC_DEFUN([AM_ICONV_LINK],
21[
22 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
23 dnl those with the standalone portable GNU libiconv installed).
24 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
25
26 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
27 dnl accordingly.
28 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
29
30 dnl Add $INCICONV to CPPFLAGS before performing the following checks,
31 dnl because if the user has installed libiconv and not disabled its use
32 dnl via --without-libiconv-prefix, he wants to use it. The first
33 dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
34 am_save_CPPFLAGS="$CPPFLAGS"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
36
37 AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
38 am_cv_func_iconv="no, consider installing GNU libiconv"
39 am_cv_lib_iconv=no
40 AC_LINK_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[
43#include <stdlib.h>
44#include <iconv.h>
45 ]],
46 [[iconv_t cd = iconv_open("","");
47 iconv(cd,NULL,NULL,NULL,NULL);
48 iconv_close(cd);]])],
49 [am_cv_func_iconv=yes])
50 if test "$am_cv_func_iconv" != yes; then
51 am_save_LIBS="$LIBS"
52 LIBS="$LIBS $LIBICONV"
53 AC_LINK_IFELSE(
54 [AC_LANG_PROGRAM(
55 [[
56#include <stdlib.h>
57#include <iconv.h>
58 ]],
59 [[iconv_t cd = iconv_open("","");
60 iconv(cd,NULL,NULL,NULL,NULL);
61 iconv_close(cd);]])],
62 [am_cv_lib_iconv=yes]
63 [am_cv_func_iconv=yes])
64 LIBS="$am_save_LIBS"
65 fi
66 ])
67 if test "$am_cv_func_iconv" = yes; then
68 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
69 dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
70 dnl Solaris 10.
71 am_save_LIBS="$LIBS"
72 if test $am_cv_lib_iconv = yes; then
73 LIBS="$LIBS $LIBICONV"
74 fi
75 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[
77#include <iconv.h>
78#include <string.h>
79int main ()
80{
81 int result = 0;
82 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
83 returns. */
84 {
85 iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
86 if (cd_utf8_to_88591 != (iconv_t)(-1))
87 {
88 static const char input[] = "\342\202\254"; /* EURO SIGN */
89 char buf[10];
90 const char *inptr = input;
91 size_t inbytesleft = strlen (input);
92 char *outptr = buf;
93 size_t outbytesleft = sizeof (buf);
94 size_t res = iconv (cd_utf8_to_88591,
95 (char **) &inptr, &inbytesleft,
96 &outptr, &outbytesleft);
97 if (res == 0)
98 result |= 1;
99 iconv_close (cd_utf8_to_88591);
100 }
101 }
102 /* Test against Solaris 10 bug: Failures are not distinguishable from
103 successful returns. */
104 {
105 iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
106 if (cd_ascii_to_88591 != (iconv_t)(-1))
107 {
108 static const char input[] = "\263";
109 char buf[10];
110 const char *inptr = input;
111 size_t inbytesleft = strlen (input);
112 char *outptr = buf;
113 size_t outbytesleft = sizeof (buf);
114 size_t res = iconv (cd_ascii_to_88591,
115 (char **) &inptr, &inbytesleft,
116 &outptr, &outbytesleft);
117 if (res == 0)
118 result |= 2;
119 iconv_close (cd_ascii_to_88591);
120 }
121 }
122 /* Test against AIX 6.1..7.1 bug: Buffer overrun. */
123 {
124 iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
125 if (cd_88591_to_utf8 != (iconv_t)(-1))
126 {
127 static const char input[] = "\304";
128 static char buf[2] = { (char)0xDE, (char)0xAD };
129 const char *inptr = input;
130 size_t inbytesleft = 1;
131 char *outptr = buf;
132 size_t outbytesleft = 1;
133 size_t res = iconv (cd_88591_to_utf8,
134 (char **) &inptr, &inbytesleft,
135 &outptr, &outbytesleft);
136 if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
137 result |= 4;
138 iconv_close (cd_88591_to_utf8);
139 }
140 }
141#if 0 /* This bug could be worked around by the caller. */
142 /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
143 {
144 iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
145 if (cd_88591_to_utf8 != (iconv_t)(-1))
146 {
147 static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
148 char buf[50];
149 const char *inptr = input;
150 size_t inbytesleft = strlen (input);
151 char *outptr = buf;
152 size_t outbytesleft = sizeof (buf);
153 size_t res = iconv (cd_88591_to_utf8,
154 (char **) &inptr, &inbytesleft,
155 &outptr, &outbytesleft);
156 if ((int)res > 0)
157 result |= 8;
158 iconv_close (cd_88591_to_utf8);
159 }
160 }
161#endif
162 /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
163 provided. */
164 if (/* Try standardized names. */
165 iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
166 /* Try IRIX, OSF/1 names. */
167 && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
168 /* Try AIX names. */
169 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
170 /* Try HP-UX names. */
171 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
172 result |= 16;
173 return result;
174}]])],
175 [am_cv_func_iconv_works=yes],
176 [am_cv_func_iconv_works=no],
177 [
178changequote(,)dnl
179 case "$host_os" in
180 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
181 *) am_cv_func_iconv_works="guessing yes" ;;
182 esac
183changequote([,])dnl
184 ])
185 LIBS="$am_save_LIBS"
186 ])
187 case "$am_cv_func_iconv_works" in
188 *no) am_func_iconv=no am_cv_lib_iconv=no ;;
189 *) am_func_iconv=yes ;;
190 esac
191 else
192 am_func_iconv=no am_cv_lib_iconv=no
193 fi
194 if test "$am_func_iconv" = yes; then
195 AC_DEFINE([HAVE_ICONV], [1],
196 [Define if you have the iconv() function and it works.])
197 fi
198 if test "$am_cv_lib_iconv" = yes; then
199 AC_MSG_CHECKING([how to link with libiconv])
200 AC_MSG_RESULT([$LIBICONV])
201 else
202 dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
203 dnl either.
204 CPPFLAGS="$am_save_CPPFLAGS"
205 LIBICONV=
206 LTLIBICONV=
207 fi
208 AC_SUBST([LIBICONV])
209 AC_SUBST([LTLIBICONV])
210])
211
212dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
213dnl avoid warnings like
214dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
215dnl This is tricky because of the way 'aclocal' is implemented:
216dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
217dnl Otherwise aclocal's initial scan pass would miss the macro definition.
218dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
219dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
220dnl warnings.
221m4_define([gl_iconv_AC_DEFUN],
222 m4_version_prereq([2.64],
223 [[AC_DEFUN_ONCE(
224 [$1], [$2])]],
225 [m4_ifdef([gl_00GNULIB],
226 [[AC_DEFUN_ONCE(
227 [$1], [$2])]],
228 [[AC_DEFUN(
229 [$1], [$2])]])]))
230gl_iconv_AC_DEFUN([AM_ICONV],
231[
232 AM_ICONV_LINK
233 if test "$am_cv_func_iconv" = yes; then
234 AC_MSG_CHECKING([for iconv declaration])
235 AC_CACHE_VAL([am_cv_proto_iconv], [
236 AC_COMPILE_IFELSE(
237 [AC_LANG_PROGRAM(
238 [[
239#include <stdlib.h>
240#include <iconv.h>
241extern
242#ifdef __cplusplus
243"C"
244#endif
245#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
246size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
247#else
248size_t iconv();
249#endif
250 ]],
251 [[]])],
252 [am_cv_proto_iconv_arg1=""],
253 [am_cv_proto_iconv_arg1="const"])
254 am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
255 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
256 AC_MSG_RESULT([
257 $am_cv_proto_iconv])
258 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
259 [Define as const if the declaration of iconv() needs const.])
260 dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
261 m4_ifdef([gl_ICONV_H_DEFAULTS],
262 [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
263 if test -n "$am_cv_proto_iconv_arg1"; then
264 ICONV_CONST="const"
265 fi
266 ])
267 fi
268])
diff --git a/gl/m4/idpriv.m4 b/gl/m4/idpriv.m4
index 167f5238..fc3dd17d 100644
--- a/gl/m4/idpriv.m4
+++ b/gl/m4/idpriv.m4
@@ -1,5 +1,5 @@
1# idpriv.m4 serial 1 1# idpriv.m4 serial 1
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index 108d9456..9f19215e 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,12 +1,13 @@
1# include_next.m4 serial 23 1# include_next.m4 serial 26
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Paul Eggert and Derek Price. 7dnl From Paul Eggert and Derek Price.
8 8
9dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. 9dnl Sets INCLUDE_NEXT, INCLUDE_NEXT_AS_FIRST_DIRECTIVE, PRAGMA_SYSTEM_HEADER,
10dnl and PRAGMA_COLUMNS.
10dnl 11dnl
11dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to 12dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
12dnl 'include' otherwise. 13dnl 'include' otherwise.
@@ -105,19 +106,21 @@ dnl We intentionally avoid using AC_LANG_SOURCE here.
105 AC_SUBST([INCLUDE_NEXT]) 106 AC_SUBST([INCLUDE_NEXT])
106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) 107 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
107 AC_SUBST([PRAGMA_SYSTEM_HEADER]) 108 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length], 109
109 [gl_cv_pragma_columns], 110 dnl HP NonStop systems, which define __TANDEM, limit the line length
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature. 111 dnl after including some system header files.
111 AC_EGREP_CPP([choke me], 112 AC_CACHE_CHECK([whether source code line length is unlimited],
113 [gl_cv_source_line_length_unlimited],
114 [AC_EGREP_CPP([choke me],
112 [ 115 [
113#ifdef __TANDEM 116#ifdef __TANDEM
114choke me 117choke me
115#endif 118#endif
116 ], 119 ],
117 [gl_cv_pragma_columns=yes], 120 [gl_cv_source_line_length_unlimited=no],
118 [gl_cv_pragma_columns=no]) 121 [gl_cv_source_line_length_unlimited=yes])
119 ]) 122 ])
120 if test $gl_cv_pragma_columns = yes; then 123 if test $gl_cv_source_line_length_unlimited = no; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000" 124 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else 125 else
123 PRAGMA_COLUMNS= 126 PRAGMA_COLUMNS=
@@ -175,89 +178,40 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
175 [AC_CHECK_HEADERS_ONCE([$1]) 178 [AC_CHECK_HEADERS_ONCE([$1])
176 ]) 179 ])
177 180
178dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
179dnl until we can assume autoconf 2.64 or newer.
180 m4_foreach_w([gl_HEADER_NAME], [$1], 181 m4_foreach_w([gl_HEADER_NAME], [$1],
181 [AS_VAR_PUSHDEF([gl_next_header], 182 [AS_VAR_PUSHDEF([gl_next_header],
182 [gl_cv_next_]m4_defn([gl_HEADER_NAME])) 183 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
183 if test $gl_cv_have_include_next = yes; then 184 if test $gl_cv_have_include_next = yes; then
184 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 185 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
185 else 186 else
186 AC_CACHE_CHECK( 187 AC_CACHE_CHECK(
187 [absolute name of <]m4_defn([gl_HEADER_NAME])[>], 188 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
188 m4_defn([gl_next_header]), 189 [gl_next_header],
189 [m4_if([$2], [check], 190 [m4_if([$2], [check],
190 [AS_VAR_PUSHDEF([gl_header_exists], 191 [AS_VAR_PUSHDEF([gl_header_exists],
191 [ac_cv_header_]m4_defn([gl_HEADER_NAME])) 192 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
192 if test AS_VAR_GET(gl_header_exists) = yes; then 193 if test AS_VAR_GET([gl_header_exists]) = yes; then
193 AS_VAR_POPDEF([gl_header_exists]) 194 AS_VAR_POPDEF([gl_header_exists])
194 ]) 195 ])
195 AC_LANG_CONFTEST( 196 gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME)
196 [AC_LANG_SOURCE( 197 AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME))
197 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 198 AS_VAR_SET([gl_next_header], ['"'$gl_header'"'])
198 )])
199 dnl AIX "xlc -E" and "cc -E" omit #line directives for header
200 dnl files that contain only a #include of other header files and
201 dnl no non-comment tokens of their own. This leads to a failure
202 dnl to detect the absolute name of <dirent.h>, <signal.h>,
203 dnl <poll.h> and others. The workaround is to force preservation
204 dnl of comments through option -C. This ensures all necessary
205 dnl #line directives are present. GCC supports option -C as well.
206 case "$host_os" in
207 aix*) gl_absname_cpp="$ac_cpp -C" ;;
208 *) gl_absname_cpp="$ac_cpp" ;;
209 esac
210changequote(,)
211 case "$host_os" in
212 mingw*)
213 dnl For the sake of native Windows compilers (excluding gcc),
214 dnl treat backslash as a directory separator, like /.
215 dnl Actually, these compilers use a double-backslash as
216 dnl directory separator, inside the
217 dnl # line "filename"
218 dnl directives.
219 gl_dirsep_regex='[/\\]'
220 ;;
221 *)
222 gl_dirsep_regex='\/'
223 ;;
224 esac
225 dnl A sed expression that turns a string into a basic regular
226 dnl expression, for use within "/.../".
227 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
228changequote([,])
229 gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \
230 | sed -e "$gl_make_literal_regex_sed"`
231 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
232 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
233changequote(,)dnl
234 s|^/[^/]|//&|
235changequote([,])dnl
236 p
237 q
238 }'
239 dnl eval is necessary to expand gl_absname_cpp.
240 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
241 dnl so use subshell.
242 AS_VAR_SET(gl_next_header,
243 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
244 sed -n "$gl_absolute_header_sed"`'"'])
245 m4_if([$2], [check], 199 m4_if([$2], [check],
246 [else 200 [else
247 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 201 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
248 fi 202 fi
249 ]) 203 ])
250 ]) 204 ])
251 fi 205 fi
252 AC_SUBST( 206 AC_SUBST(
253 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), 207 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
254 [AS_VAR_GET(gl_next_header)]) 208 [AS_VAR_GET([gl_next_header])])
255 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then 209 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
256 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' 210 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
257 gl_next_as_first_directive='<'gl_HEADER_NAME'>' 211 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
258 else 212 else
259 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' 213 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
260 gl_next_as_first_directive=AS_VAR_GET(gl_next_header) 214 gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
261 fi 215 fi
262 AC_SUBST( 216 AC_SUBST(
263 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), 217 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index 476f063f..48822d69 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,5 +1,5 @@
1# inet_ntop.m4 serial 19 1# inet_ntop.m4 serial 21
2dnl Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,6 +16,7 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
16 dnl Most platforms that provide inet_ntop define it in libc. 16 dnl Most platforms that provide inet_ntop define it in libc.
17 dnl Solaris 8..10 provide inet_ntop in libnsl instead. 17 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead. 18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
19 dnl Haiku provides it in -lnetwork.
19 dnl Native Windows provides it in -lws2_32 instead, with a declaration in 20 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
20 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl 21 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
21 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). 22 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
@@ -23,19 +24,20 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
23 INET_NTOP_LIB= 24 INET_NTOP_LIB=
24 gl_PREREQ_SYS_H_WINSOCK2 25 gl_PREREQ_SYS_H_WINSOCK2
25 if test $HAVE_WINSOCK2_H = 1; then 26 if test $HAVE_WINSOCK2_H = 1; then
27 dnl It needs to be overridden, because the stdcall calling convention
28 dnl is not compliant with POSIX. Set REPLACE_INET_NTOP in order to avoid
29 dnl a name conflict at the linker level, even though the header file
30 dnl <ws2tcpip.h> declares inet_ntop only if _WIN32_WINNT >= 0x0600.
31 REPLACE_INET_NTOP=1
26 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]]) 32 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
27 if test $ac_cv_have_decl_inet_ntop = yes; then 33 if test $ac_cv_have_decl_inet_ntop = yes; then
28 dnl It needs to be overridden, because the stdcall calling convention
29 dnl is not compliant with POSIX.
30 REPLACE_INET_NTOP=1
31 INET_NTOP_LIB="-lws2_32" 34 INET_NTOP_LIB="-lws2_32"
32 else 35 else
33 HAVE_DECL_INET_NTOP=0 36 HAVE_DECL_INET_NTOP=0
34 HAVE_INET_NTOP=0
35 fi 37 fi
36 else 38 else
37 gl_save_LIBS=$LIBS 39 gl_save_LIBS=$LIBS
38 AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [], 40 AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
39 [AC_CHECK_FUNCS([inet_ntop]) 41 [AC_CHECK_FUNCS([inet_ntop])
40 if test $ac_cv_func_inet_ntop = no; then 42 if test $ac_cv_func_inet_ntop = no; then
41 HAVE_INET_NTOP=0 43 HAVE_INET_NTOP=0
diff --git a/gl/m4/intdiv0.m4 b/gl/m4/intdiv0.m4
deleted file mode 100644
index 74d0e80d..00000000
--- a/gl/m4/intdiv0.m4
+++ /dev/null
@@ -1,87 +0,0 @@
1# intdiv0.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002, 2007-2008, 2010-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN([gt_INTDIV0],
10[
11 AC_REQUIRE([AC_PROG_CC])dnl
12 AC_REQUIRE([AC_CANONICAL_HOST])dnl
13
14 AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
15 gt_cv_int_divbyzero_sigfpe,
16 [
17 gt_cv_int_divbyzero_sigfpe=
18changequote(,)dnl
19 case "$host_os" in
20 macos* | darwin[6-9]* | darwin[1-9][0-9]*)
21 # On Mac OS X 10.2 or newer, just assume the same as when cross-
22 # compiling. If we were to perform the real test, 1 Crash Report
23 # dialog window would pop up.
24 case "$host_cpu" in
25 i[34567]86 | x86_64)
26 gt_cv_int_divbyzero_sigfpe="guessing yes" ;;
27 esac
28 ;;
29 esac
30changequote([,])dnl
31 if test -z "$gt_cv_int_divbyzero_sigfpe"; then
32 AC_RUN_IFELSE(
33 [AC_LANG_SOURCE([[
34#include <stdlib.h>
35#include <signal.h>
36
37static void
38sigfpe_handler (int sig)
39{
40 /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
41 exit (sig != SIGFPE);
42}
43
44int x = 1;
45int y = 0;
46int z;
47int nan;
48
49int main ()
50{
51 signal (SIGFPE, sigfpe_handler);
52/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
53#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
54 signal (SIGTRAP, sigfpe_handler);
55#endif
56/* Linux/SPARC yields signal SIGILL. */
57#if defined (__sparc__) && defined (__linux__)
58 signal (SIGILL, sigfpe_handler);
59#endif
60
61 z = x / y;
62 nan = y / y;
63 exit (2);
64}
65]])],
66 [gt_cv_int_divbyzero_sigfpe=yes],
67 [gt_cv_int_divbyzero_sigfpe=no],
68 [
69 # Guess based on the CPU.
70changequote(,)dnl
71 case "$host_cpu" in
72 alpha* | i[34567]86 | x86_64 | m68k | s390*)
73 gt_cv_int_divbyzero_sigfpe="guessing yes";;
74 *)
75 gt_cv_int_divbyzero_sigfpe="guessing no";;
76 esac
77changequote([,])dnl
78 ])
79 fi
80 ])
81 case "$gt_cv_int_divbyzero_sigfpe" in
82 *yes) value=1;;
83 *) value=0;;
84 esac
85 AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value],
86 [Define if integer division by zero raises signal SIGFPE.])
87])
diff --git a/gl/m4/intl.m4 b/gl/m4/intl.m4
deleted file mode 100644
index 959bd042..00000000
--- a/gl/m4/intl.m4
+++ /dev/null
@@ -1,271 +0,0 @@
1# intl.m4 serial 23 (gettext-0.18.3)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009.
19
20AC_PREREQ([2.60])
21
22dnl Checks for all prerequisites of the intl subdirectory,
23dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
24dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
25AC_DEFUN([AM_INTL_SUBDIR],
26[
27 AC_REQUIRE([AC_PROG_INSTALL])dnl
28 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
29 AC_REQUIRE([AC_PROG_CC])dnl
30 AC_REQUIRE([AC_CANONICAL_HOST])dnl
31 AC_REQUIRE([gt_GLIBC2])dnl
32 AC_REQUIRE([AC_PROG_RANLIB])dnl
33 AC_REQUIRE([gl_VISIBILITY])dnl
34 AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl
36 AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
37 AC_REQUIRE([gt_TYPE_WINT_T])dnl
38 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
39 AC_REQUIRE([gt_TYPE_INTMAX_T])
40 AC_REQUIRE([gt_PRINTF_POSIX])
41 AC_REQUIRE([gl_GLIBC21])dnl
42 AC_REQUIRE([gl_XSIZE])dnl
43 AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl
44 AC_REQUIRE([gt_INTL_MACOSX])dnl
45
46 dnl Support for automake's --enable-silent-rules.
47 case "$enable_silent_rules" in
48 yes) INTL_DEFAULT_VERBOSITY=0;;
49 no) INTL_DEFAULT_VERBOSITY=1;;
50 *) INTL_DEFAULT_VERBOSITY=1;;
51 esac
52 AC_SUBST([INTL_DEFAULT_VERBOSITY])
53
54 AC_CHECK_TYPE([ptrdiff_t], ,
55 [AC_DEFINE([ptrdiff_t], [long],
56 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
57 ])
58 AC_CHECK_HEADERS([features.h stddef.h stdlib.h string.h])
59 AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
60 snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
61
62 dnl Use the _snprintf function only if it is declared (because on NetBSD it
63 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
64 AC_CHECK_DECLS([_snprintf _snwprintf], , , [#include <stdio.h>])
65
66 dnl Use the *_unlocked functions only if they are declared.
67 dnl (because some of them were defined without being declared in Solaris
68 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
69 dnl on Solaris 2.5.1 to run on Solaris 2.6).
70 AC_CHECK_DECLS([getc_unlocked], , , [#include <stdio.h>])
71
72 case $gt_cv_func_printf_posix in
73 *yes) HAVE_POSIX_PRINTF=1 ;;
74 *) HAVE_POSIX_PRINTF=0 ;;
75 esac
76 AC_SUBST([HAVE_POSIX_PRINTF])
77 if test "$ac_cv_func_asprintf" = yes; then
78 HAVE_ASPRINTF=1
79 else
80 HAVE_ASPRINTF=0
81 fi
82 AC_SUBST([HAVE_ASPRINTF])
83 if test "$ac_cv_func_snprintf" = yes; then
84 HAVE_SNPRINTF=1
85 else
86 HAVE_SNPRINTF=0
87 fi
88 AC_SUBST([HAVE_SNPRINTF])
89 if test "$ac_cv_func_newlocale" = yes; then
90 HAVE_NEWLOCALE=1
91 else
92 HAVE_NEWLOCALE=0
93 fi
94 AC_SUBST([HAVE_NEWLOCALE])
95 if test "$ac_cv_func_wprintf" = yes; then
96 HAVE_WPRINTF=1
97 else
98 HAVE_WPRINTF=0
99 fi
100 AC_SUBST([HAVE_WPRINTF])
101
102 AM_LANGINFO_CODESET
103 gt_LC_MESSAGES
104
105 dnl Compilation on mingw and Cygwin needs special Makefile rules, because
106 dnl 1. when we install a shared library, we must arrange to export
107 dnl auxiliary pointer variables for every exported variable,
108 dnl 2. when we install a shared library and a static library simultaneously,
109 dnl the include file specifies __declspec(dllimport) and therefore we
110 dnl must arrange to define the auxiliary pointer variables for the
111 dnl exported variables _also_ in the static library.
112 if test "$enable_shared" = yes; then
113 case "$host_os" in
114 mingw* | cygwin*) is_woe32dll=yes ;;
115 *) is_woe32dll=no ;;
116 esac
117 else
118 is_woe32dll=no
119 fi
120 WOE32DLL=$is_woe32dll
121 AC_SUBST([WOE32DLL])
122
123 dnl On mingw and Cygwin, we can activate special Makefile rules which add
124 dnl version information to the shared libraries and executables.
125 case "$host_os" in
126 mingw* | cygwin*) is_woe32=yes ;;
127 *) is_woe32=no ;;
128 esac
129 WOE32=$is_woe32
130 AC_SUBST([WOE32])
131 if test $WOE32 = yes; then
132 dnl Check for a program that compiles Windows resource files.
133 AC_CHECK_TOOL([WINDRES], [windres])
134 fi
135
136 dnl Determine whether when creating a library, "-lc" should be passed to
137 dnl libtool or not. On many platforms, it is required for the libtool option
138 dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool
139 dnl in the *.la files - makes it impossible to create multithreaded programs,
140 dnl because libtool also reorders the -lc to come before the -pthread, and
141 dnl this disables pthread_create() <http://docs.hp.com/en/1896/pthreads.html>.
142 case "$host_os" in
143 hpux*) LTLIBC="" ;;
144 *) LTLIBC="-lc" ;;
145 esac
146 AC_SUBST([LTLIBC])
147
148 dnl Rename some macros and functions used for locking.
149 AH_BOTTOM([
150#define __libc_lock_t gl_lock_t
151#define __libc_lock_define gl_lock_define
152#define __libc_lock_define_initialized gl_lock_define_initialized
153#define __libc_lock_init gl_lock_init
154#define __libc_lock_lock gl_lock_lock
155#define __libc_lock_unlock gl_lock_unlock
156#define __libc_lock_recursive_t gl_recursive_lock_t
157#define __libc_lock_define_recursive gl_recursive_lock_define
158#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized
159#define __libc_lock_init_recursive gl_recursive_lock_init
160#define __libc_lock_lock_recursive gl_recursive_lock_lock
161#define __libc_lock_unlock_recursive gl_recursive_lock_unlock
162#define glthread_in_use libintl_thread_in_use
163#define glthread_lock_init_func libintl_lock_init_func
164#define glthread_lock_lock_func libintl_lock_lock_func
165#define glthread_lock_unlock_func libintl_lock_unlock_func
166#define glthread_lock_destroy_func libintl_lock_destroy_func
167#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded
168#define glthread_rwlock_init_func libintl_rwlock_init_func
169#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded
170#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func
171#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded
172#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func
173#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded
174#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func
175#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded
176#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func
177#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded
178#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func
179#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded
180#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func
181#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded
182#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func
183#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded
184#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func
185#define glthread_once_func libintl_once_func
186#define glthread_once_singlethreaded libintl_once_singlethreaded
187#define glthread_once_multithreaded libintl_once_multithreaded
188])
189])
190
191
192dnl Checks for the core files of the intl subdirectory:
193dnl dcigettext.c
194dnl eval-plural.h
195dnl explodename.c
196dnl finddomain.c
197dnl gettextP.h
198dnl gmo.h
199dnl hash-string.h hash-string.c
200dnl l10nflist.c
201dnl libgnuintl.h.in (except the *printf stuff)
202dnl loadinfo.h
203dnl loadmsgcat.c
204dnl localealias.c
205dnl log.c
206dnl plural-exp.h plural-exp.c
207dnl plural.y
208dnl Used by libglocale.
209AC_DEFUN([gt_INTL_SUBDIR_CORE],
210[
211 AC_REQUIRE([AC_C_INLINE])dnl
212 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
213 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
214 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
215 AC_REQUIRE([AC_FUNC_MMAP])dnl
216 AC_REQUIRE([gt_INTDIV0])dnl
217 AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl
218 AC_REQUIRE([gt_INTTYPES_PRI])dnl
219 AC_REQUIRE([gl_LOCK])dnl
220
221 AC_LINK_IFELSE(
222 [AC_LANG_PROGRAM(
223 [[int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }]],
224 [[]])],
225 [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
226 [Define to 1 if the compiler understands __builtin_expect.])])
227
228 AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
229 AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
230 stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \
231 argz_stringify argz_next __fsetlocking])
232
233 dnl Use the *_unlocked functions only if they are declared.
234 dnl (because some of them were defined without being declared in Solaris
235 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
236 dnl on Solaris 2.5.1 to run on Solaris 2.6).
237 AC_CHECK_DECLS([feof_unlocked fgets_unlocked], , , [#include <stdio.h>])
238
239 AM_ICONV
240
241 dnl intl/plural.c is generated from intl/plural.y. It requires bison,
242 dnl because plural.y uses bison specific features. It requires at least
243 dnl bison-1.26 because earlier versions generate a plural.c that doesn't
244 dnl compile.
245 dnl bison is only needed for the maintainer (who touches plural.y). But in
246 dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
247 dnl the rule in general Makefile. Now, some people carelessly touch the
248 dnl files or have a broken "make" program, hence the plural.c rule will
249 dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
250 dnl present or too old.
251 AC_CHECK_PROGS([INTLBISON], [bison])
252 if test -z "$INTLBISON"; then
253 ac_verc_fail=yes
254 else
255 dnl Found it, now check the version.
256 AC_MSG_CHECKING([version of bison])
257changequote(<<,>>)dnl
258 ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
259 case $ac_prog_version in
260 '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
261 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
262changequote([,])dnl
263 ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
264 *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
265 esac
266 AC_MSG_RESULT([$ac_prog_version])
267 fi
268 if test $ac_verc_fail = yes; then
269 INTLBISON=:
270 fi
271])
diff --git a/gl/m4/intldir.m4 b/gl/m4/intldir.m4
deleted file mode 100644
index 388ecd6f..00000000
--- a/gl/m4/intldir.m4
+++ /dev/null
@@ -1,19 +0,0 @@
1# intldir.m4 serial 2 (gettext-0.18)
2dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16AC_PREREQ([2.52])
17
18dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory.
19AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], [])
diff --git a/gl/m4/intlmacosx.m4 b/gl/m4/intlmacosx.m4
deleted file mode 100644
index ab97d39f..00000000
--- a/gl/m4/intlmacosx.m4
+++ /dev/null
@@ -1,56 +0,0 @@
1# intlmacosx.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2004-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Checks for special options needed on Mac OS X.
17dnl Defines INTL_MACOSX_LIBS.
18AC_DEFUN([gt_INTL_MACOSX],
19[
20 dnl Check for API introduced in Mac OS X 10.2.
21 AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
22 [gt_cv_func_CFPreferencesCopyAppValue],
23 [gt_save_LIBS="$LIBS"
24 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
25 AC_LINK_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <CoreFoundation/CFPreferences.h>]],
28 [[CFPreferencesCopyAppValue(NULL, NULL)]])],
29 [gt_cv_func_CFPreferencesCopyAppValue=yes],
30 [gt_cv_func_CFPreferencesCopyAppValue=no])
31 LIBS="$gt_save_LIBS"])
32 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
33 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
34 [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
35 fi
36 dnl Check for API introduced in Mac OS X 10.3.
37 AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
38 [gt_save_LIBS="$LIBS"
39 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
40 AC_LINK_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[#include <CoreFoundation/CFLocale.h>]],
43 [[CFLocaleCopyCurrent();]])],
44 [gt_cv_func_CFLocaleCopyCurrent=yes],
45 [gt_cv_func_CFLocaleCopyCurrent=no])
46 LIBS="$gt_save_LIBS"])
47 if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
48 AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
49 [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
50 fi
51 INTL_MACOSX_LIBS=
52 if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
53 INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
54 fi
55 AC_SUBST([INTL_MACOSX_LIBS])
56])
diff --git a/gl/m4/intmax.m4 b/gl/m4/intmax.m4
deleted file mode 100644
index 18733a52..00000000
--- a/gl/m4/intmax.m4
+++ /dev/null
@@ -1,36 +0,0 @@
1# intmax.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002-2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether the system has the 'intmax_t' type, but don't attempt to
9dnl find a replacement if it is lacking.
10
11AC_DEFUN([gt_TYPE_INTMAX_T],
12[
13 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
15 AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
16 [AC_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[
19#include <stddef.h>
20#include <stdlib.h>
21#if HAVE_STDINT_H_WITH_UINTMAX
22#include <stdint.h>
23#endif
24#if HAVE_INTTYPES_H_WITH_UINTMAX
25#include <inttypes.h>
26#endif
27 ]],
28 [[intmax_t x = -1;
29 return !x;]])],
30 [gt_cv_c_intmax_t=yes],
31 [gt_cv_c_intmax_t=no])])
32 if test $gt_cv_c_intmax_t = yes; then
33 AC_DEFINE([HAVE_INTMAX_T], [1],
34 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
35 fi
36])
diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4
index 6ea70531..ef32e1b9 100644
--- a/gl/m4/intmax_t.m4
+++ b/gl/m4/intmax_t.m4
@@ -1,5 +1,5 @@
1# intmax_t.m4 serial 8 1# intmax_t.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -19,11 +19,7 @@ AC_DEFUN([gl_AC_TYPE_INTMAX_T],
19 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 19 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
20 AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 20 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
21 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then 21 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
22 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 22 AC_DEFINE_UNQUOTED([intmax_t], [long long],
23 test $ac_cv_type_long_long_int = yes \
24 && ac_type='long long' \
25 || ac_type='long'
26 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
27 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.]) 23 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
28 else 24 else
29 AC_DEFINE([HAVE_INTMAX_T], [1], 25 AC_DEFINE([HAVE_INTMAX_T], [1],
@@ -57,11 +53,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
57 AC_DEFINE([HAVE_INTMAX_T], [1], 53 AC_DEFINE([HAVE_INTMAX_T], [1],
58 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 54 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
59 else 55 else
60 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 56 AC_DEFINE_UNQUOTED([intmax_t], [long long],
61 test $ac_cv_type_long_long_int = yes \
62 && ac_type='long long' \
63 || ac_type='long'
64 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
65 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.]) 57 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
66 fi 58 fi
67]) 59])
diff --git a/gl/m4/inttypes-pri.m4 b/gl/m4/inttypes-pri.m4
deleted file mode 100644
index e5a1e057..00000000
--- a/gl/m4/inttypes-pri.m4
+++ /dev/null
@@ -1,42 +0,0 @@
1# inttypes-pri.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1997-2002, 2006, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_PREREQ([2.53])
10
11# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
12# macros to non-string values. This is the case on AIX 4.3.3.
13
14AC_DEFUN([gt_INTTYPES_PRI],
15[
16 AC_CHECK_HEADERS([inttypes.h])
17 if test $ac_cv_header_inttypes_h = yes; then
18 AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
19 [gt_cv_inttypes_pri_broken],
20 [
21 AC_COMPILE_IFELSE(
22 [AC_LANG_PROGRAM(
23 [[
24#include <inttypes.h>
25#ifdef PRId32
26char *p = PRId32;
27#endif
28 ]],
29 [[]])],
30 [gt_cv_inttypes_pri_broken=no],
31 [gt_cv_inttypes_pri_broken=yes])
32 ])
33 fi
34 if test "$gt_cv_inttypes_pri_broken" = yes; then
35 AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1],
36 [Define if <inttypes.h> exists and defines unusable PRI* macros.])
37 PRI_MACROS_BROKEN=1
38 else
39 PRI_MACROS_BROKEN=0
40 fi
41 AC_SUBST([PRI_MACROS_BROKEN])
42])
diff --git a/gl/m4/inttypes.m4 b/gl/m4/inttypes.m4
new file mode 100644
index 00000000..bf2eab2b
--- /dev/null
+++ b/gl/m4/inttypes.m4
@@ -0,0 +1,180 @@
1# inttypes.m4 serial 36
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price, Bruno Haible.
8dnl Test whether <inttypes.h> is supported or must be substituted.
9
10AC_DEFUN_ONCE([gl_INTTYPES_H],
11[
12 AC_REQUIRE([gl_INTTYPES_INCOMPLETE])
13 gl_INTTYPES_PRI_SCN
14])
15
16AC_DEFUN_ONCE([gl_INTTYPES_INCOMPLETE],
17[
18 AC_REQUIRE([gl_STDINT_H])
19 AC_CHECK_HEADERS_ONCE([inttypes.h])
20
21 dnl Override <inttypes.h> always, so that the portability warnings work.
22 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
23 gl_CHECK_NEXT_HEADERS([inttypes.h])
24
25 AC_REQUIRE([gl_MULTIARCH])
26
27 dnl Check for declarations of anything we want to poison if the
28 dnl corresponding gnulib module is not in use.
29 gl_WARN_ON_USE_PREPARE([[#include <inttypes.h>
30 ]], [imaxabs imaxdiv strtoimax strtoumax])
31
32 AC_REQUIRE([AC_C_RESTRICT])
33])
34
35# Ensure that the PRI* and SCN* macros are defined appropriately.
36AC_DEFUN([gl_INTTYPES_PRI_SCN],
37[
38 PRIPTR_PREFIX=
39 if $GL_GENERATE_STDINT_H; then
40 dnl Using the gnulib <stdint.h>. It defines intptr_t to 'long' or
41 dnl 'long long', depending on _WIN64.
42 AC_COMPILE_IFELSE(
43 [AC_LANG_PROGRAM([[
44 #ifdef _WIN64
45 LLP64
46 #endif
47 ]])
48 ],
49 [PRIPTR_PREFIX='"l"'],
50 [PRIPTR_PREFIX='"ll"'])
51 else
52 dnl Using the system's <stdint.h>.
53 for glpfx in '' l ll I64; do
54 case $glpfx in
55 '') gltype1='int';;
56 l) gltype1='long int';;
57 ll) gltype1='long long int';;
58 I64) gltype1='__int64';;
59 esac
60 AC_COMPILE_IFELSE(
61 [AC_LANG_PROGRAM([[#include <stdint.h>
62 extern intptr_t foo;
63 extern $gltype1 foo;]])],
64 [PRIPTR_PREFIX='"'$glpfx'"'])
65 test -n "$PRIPTR_PREFIX" && break
66 done
67 fi
68 AC_SUBST([PRIPTR_PREFIX])
69
70 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
71 [INT32_MAX_LT_INTMAX_MAX],
72 [defined INT32_MAX && defined INTMAX_MAX],
73 [INT32_MAX < INTMAX_MAX],
74 [sizeof (int) < sizeof (long long int)])
75 if test $APPLE_UNIVERSAL_BUILD = 0; then
76 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
77 [INT64_MAX_EQ_LONG_MAX],
78 [defined INT64_MAX],
79 [INT64_MAX == LONG_MAX],
80 [sizeof (long long int) == sizeof (long int)])
81 else
82 INT64_MAX_EQ_LONG_MAX=-1
83 fi
84 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
85 [UINT32_MAX_LT_UINTMAX_MAX],
86 [defined UINT32_MAX && defined UINTMAX_MAX],
87 [UINT32_MAX < UINTMAX_MAX],
88 [sizeof (unsigned int) < sizeof (unsigned long long int)])
89 if test $APPLE_UNIVERSAL_BUILD = 0; then
90 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
91 [UINT64_MAX_EQ_ULONG_MAX],
92 [defined UINT64_MAX],
93 [UINT64_MAX == ULONG_MAX],
94 [sizeof (unsigned long long int) == sizeof (unsigned long int)])
95 else
96 UINT64_MAX_EQ_ULONG_MAX=-1
97 fi
98])
99
100# Define the symbol $1 to be 1 if the condition is true, 0 otherwise.
101# If $2 is true, the condition is $3; otherwise if long long int is supported
102# approximate the condition with $4; otherwise, assume the condition is false.
103# The condition should work on all C99 platforms; the approximations should be
104# good enough to work on all practical pre-C99 platforms.
105# $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants.
106AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION],
107[
108 AC_CACHE_CHECK([whether $3],
109 [gl_cv_test_$1],
110 [AC_COMPILE_IFELSE(
111 [AC_LANG_PROGRAM(
112 [[/* Work also in C++ mode. */
113 #define __STDC_LIMIT_MACROS 1
114
115 /* Work if build is not clean. */
116 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H
117
118 #include <limits.h>
119 #if HAVE_STDINT_H
120 #include <stdint.h>
121 #endif
122
123 #if $2
124 #define CONDITION ($3)
125 #else
126 #define CONDITION ($4)
127 #endif
128 int test[CONDITION ? 1 : -1];]])],
129 [gl_cv_test_$1=yes],
130 [gl_cv_test_$1=no])])
131 if test $gl_cv_test_$1 = yes; then
132 $1=1;
133 else
134 $1=0;
135 fi
136 AC_SUBST([$1])
137])
138
139# gl_INTTYPES_MODULE_INDICATOR([modulename])
140# sets the shell variable that indicates the presence of the given module
141# to a C preprocessor expression that will evaluate to 1.
142# This macro invocation must not occur in macros that are AC_REQUIREd.
143AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR],
144[
145 dnl Ensure to expand the default settings once only.
146 gl_INTTYPES_H_REQUIRE_DEFAULTS
147 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
148])
149
150# Initializes the default values for AC_SUBSTed shell variables.
151# This macro must not be AC_REQUIREd. It must only be invoked, and only
152# outside of macros or in macros that are not AC_REQUIREd.
153AC_DEFUN([gl_INTTYPES_H_REQUIRE_DEFAULTS],
154[
155 m4_defun(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS], [
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXABS])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXDIV])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOIMAX])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUMAX])
160 ])
161 m4_require(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS])
162 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
163])
164
165AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
166[
167 dnl Assume proper GNU behavior unless another module says otherwise.
168 HAVE_DECL_IMAXABS=1; AC_SUBST([HAVE_DECL_IMAXABS])
169 HAVE_DECL_IMAXDIV=1; AC_SUBST([HAVE_DECL_IMAXDIV])
170 HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
171 HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
172 HAVE_IMAXDIV_T=1; AC_SUBST([HAVE_IMAXDIV_T])
173 REPLACE_STRTOIMAX=0; AC_SUBST([REPLACE_STRTOIMAX])
174 REPLACE_STRTOUMAX=0; AC_SUBST([REPLACE_STRTOUMAX])
175 INT32_MAX_LT_INTMAX_MAX=1; AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
176 INT64_MAX_EQ_LONG_MAX='defined _LP64'; AC_SUBST([INT64_MAX_EQ_LONG_MAX])
177 PRIPTR_PREFIX=__PRIPTR_PREFIX; AC_SUBST([PRIPTR_PREFIX])
178 UINT32_MAX_LT_UINTMAX_MAX=1; AC_SUBST([UINT32_MAX_LT_UINTMAX_MAX])
179 UINT64_MAX_EQ_ULONG_MAX='defined _LP64'; AC_SUBST([UINT64_MAX_EQ_ULONG_MAX])
180])
diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4
index 5f05ac58..68c60e9d 100644
--- a/gl/m4/inttypes_h.m4
+++ b/gl/m4/inttypes_h.m4
@@ -1,5 +1,5 @@
1# inttypes_h.m4 serial 10 1# inttypes_h.m4 serial 10
2dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/langinfo_h.m4 b/gl/m4/langinfo_h.m4
index 73bef8bc..b17a526a 100644
--- a/gl/m4/langinfo_h.m4
+++ b/gl/m4/langinfo_h.m4
@@ -1,10 +1,10 @@
1# langinfo_h.m4 serial 7 1# langinfo_h.m4 serial 12
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_LANGINFO_H], 7AC_DEFUN_ONCE([gl_LANGINFO_H],
8[ 8[
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 10
@@ -17,13 +17,17 @@ AC_DEFUN([gl_LANGINFO_H],
17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS. 17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
18 HAVE_LANGINFO_CODESET=0 18 HAVE_LANGINFO_CODESET=0
19 HAVE_LANGINFO_T_FMT_AMPM=0 19 HAVE_LANGINFO_T_FMT_AMPM=0
20 HAVE_LANGINFO_ALTMON=0
20 HAVE_LANGINFO_ERA=0 21 HAVE_LANGINFO_ERA=0
21 HAVE_LANGINFO_YESEXPR=0 22 HAVE_LANGINFO_YESEXPR=0
22 AC_CHECK_HEADERS_ONCE([langinfo.h]) 23 AC_CHECK_HEADERS_ONCE([langinfo.h])
23 if test $ac_cv_header_langinfo_h = yes; then 24 if test $ac_cv_header_langinfo_h = yes; then
24 HAVE_LANGINFO_H=1 25 HAVE_LANGINFO_H=1
25 dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing 26 dnl Determine what <langinfo.h> defines.
26 dnl on OpenBSD 3.8. T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3. 27 dnl CODESET is missing on OpenBSD 3.8.
28 dnl ERA etc. are missing on OpenBSD 6.7.
29 dnl T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
30 dnl ALTMON_* are missing on glibc 2.26 and many other systems.
27 AC_CACHE_CHECK([whether langinfo.h defines CODESET], 31 AC_CACHE_CHECK([whether langinfo.h defines CODESET],
28 [gl_cv_header_langinfo_codeset], 32 [gl_cv_header_langinfo_codeset],
29 [AC_COMPILE_IFELSE( 33 [AC_COMPILE_IFELSE(
@@ -48,6 +52,18 @@ int a = T_FMT_AMPM;
48 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then 52 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
49 HAVE_LANGINFO_T_FMT_AMPM=1 53 HAVE_LANGINFO_T_FMT_AMPM=1
50 fi 54 fi
55 AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1],
56 [gl_cv_header_langinfo_altmon],
57 [AC_COMPILE_IFELSE(
58 [AC_LANG_PROGRAM([[#include <langinfo.h>
59int a = ALTMON_1;
60]])],
61 [gl_cv_header_langinfo_altmon=yes],
62 [gl_cv_header_langinfo_altmon=no])
63 ])
64 if test $gl_cv_header_langinfo_altmon = yes; then
65 HAVE_LANGINFO_ALTMON=1
66 fi
51 AC_CACHE_CHECK([whether langinfo.h defines ERA], 67 AC_CACHE_CHECK([whether langinfo.h defines ERA],
52 [gl_cv_header_langinfo_era], 68 [gl_cv_header_langinfo_era],
53 [AC_COMPILE_IFELSE( 69 [AC_COMPILE_IFELSE(
@@ -78,6 +94,7 @@ int a = YESEXPR;
78 AC_SUBST([HAVE_LANGINFO_H]) 94 AC_SUBST([HAVE_LANGINFO_H])
79 AC_SUBST([HAVE_LANGINFO_CODESET]) 95 AC_SUBST([HAVE_LANGINFO_CODESET])
80 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM]) 96 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
97 AC_SUBST([HAVE_LANGINFO_ALTMON])
81 AC_SUBST([HAVE_LANGINFO_ERA]) 98 AC_SUBST([HAVE_LANGINFO_ERA])
82 AC_SUBST([HAVE_LANGINFO_YESEXPR]) 99 AC_SUBST([HAVE_LANGINFO_YESEXPR])
83 100
@@ -87,18 +104,33 @@ int a = YESEXPR;
87 ]], [nl_langinfo]) 104 ]], [nl_langinfo])
88]) 105])
89 106
107# gl_LANGINFO_MODULE_INDICATOR([modulename])
108# sets the shell variable that indicates the presence of the given module
109# to a C preprocessor expression that will evaluate to 1.
110# This macro invocation must not occur in macros that are AC_REQUIREd.
90AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR], 111AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
91[ 112[
92 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 113 dnl Ensure to expand the default settings once only.
93 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 114 gl_LANGINFO_H_REQUIRE_DEFAULTS
94 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 115 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
95 dnl Define it also as a C macro, for the benefit of the unit tests. 116 dnl Define it also as a C macro, for the benefit of the unit tests.
96 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 117 gl_MODULE_INDICATOR_FOR_TESTS([$1])
97]) 118])
98 119
120# Initializes the default values for AC_SUBSTed shell variables.
121# This macro must not be AC_REQUIREd. It must only be invoked, and only
122# outside of macros or in macros that are not AC_REQUIREd.
123AC_DEFUN([gl_LANGINFO_H_REQUIRE_DEFAULTS],
124[
125 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS], [
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NL_LANGINFO])
127 ])
128 m4_require(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS])
129 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
130])
131
99AC_DEFUN([gl_LANGINFO_H_DEFAULTS], 132AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
100[ 133[
101 GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO])
102 dnl Assume proper GNU behavior unless another module says otherwise. 134 dnl Assume proper GNU behavior unless another module says otherwise.
103 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO]) 135 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO])
104 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO]) 136 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4
index 1e605e3d..7fb81b86 100644
--- a/gl/m4/largefile.m4
+++ b/gl/m4/largefile.m4
@@ -1,104 +1,319 @@
1# Enable large files on systems where this is not the default. 1# Enable large files on systems where this is not the default.
2# Enable support for files on Linux file systems with 64-bit inode numbers.
2 3
3# Copyright 1992-1996, 1998-2013 Free Software Foundation, Inc. 4# Copyright 1992-1996, 1998-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
7 8
8# The following implementation works around a problem in autoconf <= 2.69; 9# The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO:
10# It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this
11# setting of _LARGEFILE_SOURCE is needed so that <stdio.h> declares fseeko
12# and ftello in C++ mode as well.
13# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038.
14AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
15 m4_ifndef([AC_SYS_YEAR2038], [[
16 AC_REQUIRE([AC_CANONICAL_HOST])
17 AC_FUNC_FSEEKO
18 case "$host_os" in
19 hpux*)
20 AC_DEFINE([_LARGEFILE_SOURCE], [1],
21 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).])
22 ;;
23 esac
24 ]])
25)
26
27# Work around a problem in autoconf <= 2.69:
9# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, 28# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
10# or configures them incorrectly in some cases. 29# or configures them incorrectly in some cases.
11m4_version_prereq([2.70], [] ,[ 30m4_version_prereq([2.70], [], [
12 31
13# _AC_SYS_LARGEFILE_TEST_INCLUDES 32# _AC_SYS_LARGEFILE_TEST_INCLUDES
14# ------------------------------- 33# -------------------------------
15m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], 34m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
16[@%:@include <sys/types.h> 35[#include <sys/types.h>
17 /* Check that off_t can represent 2**63 - 1 correctly. 36 /* Check that off_t can represent 2**63 - 1 correctly.
18 We can't simply define LARGE_OFF_T to be 9223372036854775807, 37 We can't simply define LARGE_OFF_T to be 9223372036854775807,
19 since some C++ compilers masquerading as C compilers 38 since some C++ compilers masquerading as C compilers
20 incorrectly reject 9223372036854775807. */ 39 incorrectly reject 9223372036854775807. */
21@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) 40#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
22 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 41 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
23 && LARGE_OFF_T % 2147483647 == 1) 42 && LARGE_OFF_T % 2147483647 == 1)
24 ? 1 : -1]];[]dnl 43 ? 1 : -1]];[]dnl
25]) 44])
45])# m4_version_prereq 2.70
46
47# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier.
48# This code is taken from Autoconf master.
49m4_ifndef([AC_SYS_YEAR2038], [
50
51# _AC_SYS_YEAR2038_TEST_CODE
52# --------------------------
53# C code used to probe for time_t that can represent time points more
54# than 2**31 - 1 seconds after the epoch. With the usual Unix epoch,
55# these correspond to dates after 2038-01-18 22:14:07 +0000 (Gregorian),
56# hence the name.
57AC_DEFUN([_AC_SYS_YEAR2038_TEST_CODE],
58[[
59 #include <time.h>
60 /* Check that time_t can represent 2**32 - 1 correctly. */
61 #define LARGE_TIME_T \\
62 ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))
63 int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535
64 && LARGE_TIME_T % 65537 == 0)
65 ? 1 : -1];
66]])
67
68# _AC_SYS_YEAR2038_OPTIONS
69# ------------------------
70# List of known ways to enable support for large time_t. If you change
71# this list you probably also need to change the AS_CASE at the end of
72# _AC_SYS_YEAR2038_PROBE.
73m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
74 ["none needed"] dnl 64-bit and newer 32-bit Unix
75 ["-D_TIME_BITS=64"] dnl glibc 2.34 with some 32-bit ABIs
76 ["-D__MINGW_USE_VC2005_COMPAT"] dnl 32-bit MinGW
77 ["-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"]
78 dnl 32-bit MinGW (misconfiguration)
79))
80
81# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED])
82# -----------------------------------------
83# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent
84# time points more than 2**31 - 1 seconds after the epoch (dates after
85# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts
86# to one of the values in the _AC_SYS_YEAR2038_OPTIONS list, or to
87# "support not detected" if none of them worked. Then, set compilation
88# options and #defines as necessary to enable large time_t support.
89#
90# Note that we do not test whether mktime, localtime, etc. handle
91# large values of time_t correctly, as that would require use of
92# AC_TRY_RUN. Note also that some systems only support large time_t
93# together with large off_t.
94#
95# If support is not detected, the behavior depends on which of the
96# top-level AC_SYS_YEAR2038 macros was used (see below).
97#
98# If you change this macro you may also need to change
99# _AC_SYS_YEAR2038_OPTIONS.
100AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
101[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038],
102 [ac_cv_sys_year2038_opts],
103 [ac_save_CPPFLAGS="$CPPFLAGS"
104 ac_opt_found=no
105 for ac_opt in _AC_SYS_YEAR2038_OPTIONS; do
106 AS_IF([test x"$ac_opt" != x"none needed"],
107 [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
108 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_YEAR2038_TEST_CODE])],
109 [ac_cv_sys_year2038_opts="$ac_opt"
110 ac_opt_found=yes])
111 test $ac_opt_found = no || break
112 done
113 CPPFLAGS="$ac_save_CPPFLAGS"
114 test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected"])
115
116ac_have_year2038=yes
117AS_CASE([$ac_cv_sys_year2038_opts],
118 ["none needed"], [],
119 ["support not detected"],
120 [ac_have_year2038=no
121 AS_CASE([$enable_year2038],
122 [yes],
123 [# If we're not cross compiling and 'touch' works with a large
124 # timestamp, then we can presume the system supports wider time_t
125 # *somehow* and we just weren't able to detect it. One common
126 # case that we deliberately *don't* probe for is a system that
127 # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
128 # wide time_t. (It would be inappropriate for us to override an
129 # intentional use of -m32.) Error out, demanding use of
130 # --disable-year2038 if this is intentional.
131 AS_IF([test $cross_compiling = no],
132 [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
133 [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
134 [*'Feb 7 2106'* | *'Feb 7 17:10'*],
135 [AC_MSG_FAILURE(m4_text_wrap(
136 [this system appears to support timestamps after January 2038,
137 but no mechanism for enabling wide 'time_t' was detected.
138 Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.)
139 To proceed with 32-bit time_t, configure with '--disable-year2038'.],
140 [], [], [55]))])])])])],
141
142 ["-D_TIME_BITS=64"],
143 [AC_DEFINE([_TIME_BITS], [64],
144 [Number of bits in time_t, on hosts where this is settable.])],
145
146 ["-D__MINGW_USE_VC2005_COMPAT=1"],
147 [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
148 [Define to 1 on platforms where this makes time_t a 64-bit type.])],
149
150 ["-U_USE_32_BIT_TIME_T"*],
151 [AC_MSG_FAILURE(m4_text_wrap(
152 [the 'time_t' type is currently forced to be 32-bit.
153 It will stop working after January 2038.
154 Remove _USE_32BIT_TIME_T from the compiler flags.],
155 [], [], [55]))],
156
157 [AC_MSG_ERROR(
158 [internal error: bad value for \$ac_cv_sys_year2038_opts])])
159])
160
161# _AC_SYS_YEAR2038_ENABLE
162# -----------------------
163# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN.
164# Depending on which of the YEAR2038 macros was used, add either an
165# --enable-year2038, or a --disable-year2038, or no option at all to
166# the configure script. Note that this is expanded very late and
167# therefore there cannot be any code in the AC_ARG_ENABLE. The
168# default value for enable_year2038 is emitted unconditionally
169# because the generated code always looks at this variable.
170m4_define([_AC_SYS_YEAR2038_ENABLE],
171[m4_divert_text([DEFAULTS],
172 m4_provide_if([AC_SYS_YEAR2038],
173 [enable_year2038=yes],
174 [enable_year2038=no]))]dnl
175[AC_ARG_ENABLE([year2038],
176 m4_provide_if([AC_SYS_YEAR2038],
177 [AS_HELP_STRING([--disable-year2038],
178 [do not support timestamps after 2038])],
179 [AS_HELP_STRING([--enable-year2038],
180 [support timestamps after 2038])]))])
181
182# _AC_SYS_YEAR2038_OPT_IN
183# -----------------------
184# If the --enable-year2038 option is given to configure, attempt to
185# detect and activate support for large time_t on 32-bit systems.
186# This macro is automatically invoked by AC_SYS_LARGEFILE when large
187# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE
188# to avoid a dependency loop, and is therefore unsafe to expose as a
189# documented macro.
190AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN],
191[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
192 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
193 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
194])])
195
196# AC_SYS_YEAR2038
197# ---------------
198# Attempt to detect and activate support for large time_t.
199# On systems where time_t is not always 64 bits, this probe can be
200# skipped by passing the --disable-year2038 option to configure.
201AC_DEFUN([AC_SYS_YEAR2038],
202[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl
203[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
204 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
205 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
206])])
207
208# _AC_SYS_LARGEFILE_TEST_CODE
209# ---------------------------
210# C code used to probe for large file support.
211m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
212[@%:@include <sys/types.h>
213 /* Check that off_t can represent 2**63 - 1 correctly.
214 We can't simply define LARGE_OFF_T to be 9223372036854775807,
215 since some C++ compilers masquerading as C compilers
216 incorrectly reject 9223372036854775807. */
217@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
218 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
219 && LARGE_OFF_T % 2147483647 == 1)
220 ? 1 : -1]];[]dnl
221])
222
223# _AC_SYS_LARGEFILE_OPTIONS
224# -------------------------
225# List of known ways to enable support for large files. If you change
226# this list you probably also need to change the AS_CASE at the end of
227# _AC_SYS_LARGEFILE_PROBE.
228m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
229 ["none needed"] dnl Most current systems
230 ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec
231 ["-D_LARGE_FILES=1"] dnl AIX (which versions?)
232 ["-n32"] dnl Irix 6.2 w/ SGI compiler
233))
234
235# _AC_SYS_LARGEFILE_PROBE
236# -----------------------
237# Subroutine of AC_SYS_LARGEFILE. Probe for large file support and set
238# the cache variable ac_cv_sys_largefile_opts to one of the values in
239# the _AC_SYS_LARGEFILE_OPTIONS list, or to "support not detected" if
240# none of the options in that list worked. Then, set compilation
241# options and #defines as necessary to enable large file support.
242#
243# If large file support is not detected, the behavior depends on which of
244# the top-level AC_SYS_LARGEFILE macros was used (see below).
245#
246# If you change this macro you may also need to change
247# _AC_SYS_LARGEFILE_OPTIONS.
248AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
249[AC_CACHE_CHECK([for $CC option to enable large file support],
250 [ac_cv_sys_largefile_opts],
251 [ac_save_CC="$CC"
252 ac_opt_found=no
253 for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
254 AS_IF([test x"$ac_opt" != x"none needed"],
255 [CC="$ac_save_CC $ac_opt"])
256 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
257 [ac_cv_sys_largefile_opts="$ac_opt"
258 ac_opt_found=yes])
259 test $ac_opt_found = no || break
260 done
261 CC="$ac_save_CC"
262 test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
263
264ac_have_largefile=yes
265AS_CASE([$ac_cv_sys_largefile_opts],
266 ["none needed"], [],
267 ["support not detected"],
268 [ac_have_largefile=no],
269
270 ["-D_FILE_OFFSET_BITS=64"],
271 [AC_DEFINE([_FILE_OFFSET_BITS], [64],
272 [Number of bits in a file offset, on hosts where this is settable.])],
273
274 ["-D_LARGE_FILES=1"],
275 [AC_DEFINE([_LARGE_FILES], [1],
276 [Define to 1 on platforms where this makes off_t a 64-bit type.])],
26 277
278 ["-n32"],
279 [CC="$CC -n32"],
27 280
28# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, 281 [AC_MSG_ERROR(
29# CACHE-VAR, 282 [internal error: bad value for \$ac_cv_sys_largefile_opts])])
30# DESCRIPTION,
31# PROLOGUE, [FUNCTION-BODY])
32# --------------------------------------------------------
33m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
34[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
35[while :; do
36 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
37 [AC_LANG_PROGRAM([$5], [$6])],
38 [$3=no; break])
39 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
40 [AC_LANG_PROGRAM([@%:@define $1 $2
41$5], [$6])],
42 [$3=$2; break])
43 $3=unknown
44 break
45done])
46case $$3 in #(
47 no | unknown) ;;
48 *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
49esac
50rm -rf conftest*[]dnl
51])# _AC_SYS_LARGEFILE_MACRO_VALUE
52 283
284_AC_SYS_YEAR2038_OPT_IN
285])
286
287# _AC_SYS_LARGEFILE_ENABLE
288# ------------------------
289# Subroutine of AC_SYS_LARGEFILE. Note that this
290# is expanded very late and therefore there cannot be any code in the
291# AC_ARG_ENABLE. The default value for enable_largefile is emitted
292# unconditionally because the generated shell code always looks at
293# this variable.
294m4_define([_AC_SYS_LARGEFILE_ENABLE],
295[m4_divert_text([DEFAULTS],
296 enable_largefile=yes)]dnl
297[AC_ARG_ENABLE([largefile],
298 [AS_HELP_STRING([--disable-largefile], [omit support for large files])])])
53 299
54# AC_SYS_LARGEFILE 300# AC_SYS_LARGEFILE
55# ---------------- 301# ----------------
56# By default, many hosts won't let programs access large files; 302# By default, many hosts won't let programs access large files;
57# one must use special compiler options to get large-file access to work. 303# one must use special compiler options to get large-file access to work.
58# For more details about this brain damage please see: 304# For more details about this brain damage please see:
59# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html 305# http://www.unix.org/version2/whatsnew/lfs20mar.html
306# Additionally, on Linux file systems with 64-bit inodes a file that happens
307# to have a 64-bit inode number cannot be accessed by 32-bit applications on
308# Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
309# This macro allows configuration to continue if the system doesn't support
310# large files.
60AC_DEFUN([AC_SYS_LARGEFILE], 311AC_DEFUN([AC_SYS_LARGEFILE],
61[AC_ARG_ENABLE(largefile, 312[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl
62 [ --disable-largefile omit support for large files]) 313 AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE])
63if test "$enable_largefile" != no; then 314 AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE])
64 315])])
65 AC_CACHE_CHECK([for special C compiler options needed for large files], 316])# m4_ifndef AC_SYS_YEAR2038
66 ac_cv_sys_largefile_CC,
67 [ac_cv_sys_largefile_CC=no
68 if test "$GCC" != yes; then
69 ac_save_CC=$CC
70 while :; do
71 # IRIX 6.2 and later do not support large files by default,
72 # so use the C compiler's -n32 option if that helps.
73 AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
74 AC_COMPILE_IFELSE([], [break])
75 CC="$CC -n32"
76 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
77 break
78 done
79 CC=$ac_save_CC
80 rm -f conftest.$ac_ext
81 fi])
82 if test "$ac_cv_sys_largefile_CC" != no; then
83 CC=$CC$ac_cv_sys_largefile_CC
84 fi
85
86 _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
87 ac_cv_sys_file_offset_bits,
88 [Number of bits in a file offset, on hosts where this is settable.],
89 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
90 if test $ac_cv_sys_file_offset_bits = unknown; then
91 _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
92 ac_cv_sys_large_files,
93 [Define for large files, on AIX-style hosts.],
94 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
95 fi
96
97 AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1],
98 [Enable large inode numbers on Mac OS X 10.5.])
99fi
100])# AC_SYS_LARGEFILE
101])# m4_version_prereq 2.70
102 317
103# Enable large files on systems where this is implemented by Gnulib, not by the 318# Enable large files on systems where this is implemented by Gnulib, not by the
104# system headers. 319# system headers.
@@ -126,9 +341,24 @@ AC_DEFUN([gl_LARGEFILE],
126 else 341 else
127 WINDOWS_64_BIT_OFF_T=0 342 WINDOWS_64_BIT_OFF_T=0
128 fi 343 fi
129 dnl But all native Windows platforms (including mingw64) have a 32-bit 344 dnl Some mingw versions define, if _FILE_OFFSET_BITS=64, 'struct stat'
130 dnl st_size member in 'struct stat'. 345 dnl to 'struct _stat32i64' or 'struct _stat64' (depending on
131 WINDOWS_64_BIT_ST_SIZE=1 346 dnl _USE_32BIT_TIME_T), which has a 32-bit st_size member.
347 AC_CACHE_CHECK([for 64-bit st_size], [gl_cv_member_st_size_64],
348 [AC_COMPILE_IFELSE(
349 [AC_LANG_PROGRAM(
350 [[#include <sys/types.h>
351 struct stat buf;
352 int verify_st_size_size[sizeof (buf.st_size) >= 8 ? 1 : -1];
353 ]],
354 [[]])],
355 [gl_cv_member_st_size_64=yes], [gl_cv_member_st_size_64=no])
356 ])
357 if test $gl_cv_member_st_size_64 = no; then
358 WINDOWS_64_BIT_ST_SIZE=1
359 else
360 WINDOWS_64_BIT_ST_SIZE=0
361 fi
132 ;; 362 ;;
133 *) 363 *)
134 dnl Nothing to do on gnulib's side. 364 dnl Nothing to do on gnulib's side.
diff --git a/gl/m4/lcmessage.m4 b/gl/m4/lcmessage.m4
deleted file mode 100644
index d62a175f..00000000
--- a/gl/m4/lcmessage.m4
+++ /dev/null
@@ -1,35 +0,0 @@
1# lcmessage.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1995-2002, 2004-2005, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl
8dnl This file can can be used in projects which are not available under
9dnl the GNU General Public License or the GNU Library General Public
10dnl License but which still want to provide support for the GNU gettext
11dnl functionality.
12dnl Please note that the actual code of the GNU gettext library is covered
13dnl by the GNU Library General Public License, and the rest of the GNU
14dnl gettext package package is covered by the GNU General Public License.
15dnl They are *not* in the public domain.
16
17dnl Authors:
18dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
19
20# Check whether LC_MESSAGES is available in <locale.h>.
21
22AC_DEFUN([gt_LC_MESSAGES],
23[
24 AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
25 [AC_LINK_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <locale.h>]],
28 [[return LC_MESSAGES]])],
29 [gt_cv_val_LC_MESSAGES=yes],
30 [gt_cv_val_LC_MESSAGES=no])])
31 if test $gt_cv_val_LC_MESSAGES = yes; then
32 AC_DEFINE([HAVE_LC_MESSAGES], [1],
33 [Define if your <locale.h> file defines LC_MESSAGES.])
34 fi
35])
diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4
deleted file mode 100644
index c145e478..00000000
--- a/gl/m4/lib-ld.m4
+++ /dev/null
@@ -1,119 +0,0 @@
1# lib-ld.m4 serial 6
2dnl Copyright (C) 1996-2003, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Subroutines of libtool.m4,
8dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
9dnl collision with libtool.m4.
10
11dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
12AC_DEFUN([AC_LIB_PROG_LD_GNU],
13[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
14[# I'd rather use --version here, but apparently some GNU lds only accept -v.
15case `$LD -v 2>&1 </dev/null` in
16*GNU* | *'with BFD'*)
17 acl_cv_prog_gnu_ld=yes
18 ;;
19*)
20 acl_cv_prog_gnu_ld=no
21 ;;
22esac])
23with_gnu_ld=$acl_cv_prog_gnu_ld
24])
25
26dnl From libtool-2.4. Sets the variable LD.
27AC_DEFUN([AC_LIB_PROG_LD],
28[AC_REQUIRE([AC_PROG_CC])dnl
29AC_REQUIRE([AC_CANONICAL_HOST])dnl
30
31AC_ARG_WITH([gnu-ld],
32 [AS_HELP_STRING([--with-gnu-ld],
33 [assume the C compiler uses GNU ld [default=no]])],
34 [test "$withval" = no || with_gnu_ld=yes],
35 [with_gnu_ld=no])dnl
36
37# Prepare PATH_SEPARATOR.
38# The user is always right.
39if test "${PATH_SEPARATOR+set}" != set; then
40 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
41 # contains only /bin. Note that ksh looks also at the FPATH variable,
42 # so we have to set that as well for the test.
43 PATH_SEPARATOR=:
44 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
45 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
46 || PATH_SEPARATOR=';'
47 }
48fi
49
50ac_prog=ld
51if test "$GCC" = yes; then
52 # Check if gcc -print-prog-name=ld gives a path.
53 AC_MSG_CHECKING([for ld used by $CC])
54 case $host in
55 *-*-mingw*)
56 # gcc leaves a trailing carriage return which upsets mingw
57 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
58 *)
59 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
60 esac
61 case $ac_prog in
62 # Accept absolute paths.
63 [[\\/]]* | ?:[[\\/]]*)
64 re_direlt='/[[^/]][[^/]]*/\.\./'
65 # Canonicalize the pathname of ld
66 ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
67 while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
68 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
69 done
70 test -z "$LD" && LD="$ac_prog"
71 ;;
72 "")
73 # If it fails, then pretend we aren't using GCC.
74 ac_prog=ld
75 ;;
76 *)
77 # If it is relative, then search for the first ld in PATH.
78 with_gnu_ld=unknown
79 ;;
80 esac
81elif test "$with_gnu_ld" = yes; then
82 AC_MSG_CHECKING([for GNU ld])
83else
84 AC_MSG_CHECKING([for non-GNU ld])
85fi
86AC_CACHE_VAL([acl_cv_path_LD],
87[if test -z "$LD"; then
88 acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
89 for ac_dir in $PATH; do
90 IFS="$acl_save_ifs"
91 test -z "$ac_dir" && ac_dir=.
92 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
93 acl_cv_path_LD="$ac_dir/$ac_prog"
94 # Check to see if the program is GNU ld. I'd rather use --version,
95 # but apparently some variants of GNU ld only accept -v.
96 # Break only if it was the GNU/non-GNU ld that we prefer.
97 case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
98 *GNU* | *'with BFD'*)
99 test "$with_gnu_ld" != no && break
100 ;;
101 *)
102 test "$with_gnu_ld" != yes && break
103 ;;
104 esac
105 fi
106 done
107 IFS="$acl_save_ifs"
108else
109 acl_cv_path_LD="$LD" # Let the user override the test with a path.
110fi])
111LD="$acl_cv_path_LD"
112if test -n "$LD"; then
113 AC_MSG_RESULT([$LD])
114else
115 AC_MSG_RESULT([no])
116fi
117test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
118AC_LIB_PROG_LD_GNU
119])
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
deleted file mode 100644
index 073f0405..00000000
--- a/gl/m4/lib-link.m4
+++ /dev/null
@@ -1,777 +0,0 @@
1# lib-link.m4 serial 26 (gettext-0.18.2)
2dnl Copyright (C) 2001-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_PREREQ([2.54])
10
11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12dnl the libraries corresponding to explicit and implicit dependencies.
13dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
14dnl augments the CPPFLAGS variable.
15dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
16dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
17AC_DEFUN([AC_LIB_LINKFLAGS],
18[
19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20 AC_REQUIRE([AC_LIB_RPATH])
21 pushdef([Name],[m4_translit([$1],[./+-], [____])])
22 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25 AC_LIB_LINKFLAGS_BODY([$1], [$2])
26 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
27 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
28 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29 ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
30 ])
31 LIB[]NAME="$ac_cv_lib[]Name[]_libs"
32 LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
33 INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
34 LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
36 AC_SUBST([LIB]NAME)
37 AC_SUBST([LTLIB]NAME)
38 AC_SUBST([LIB]NAME[_PREFIX])
39 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
40 dnl results of this search when this library appears as a dependency.
41 HAVE_LIB[]NAME=yes
42 popdef([NAME])
43 popdef([Name])
44])
45
46dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
47dnl searches for libname and the libraries corresponding to explicit and
48dnl implicit dependencies, together with the specified include files and
49dnl the ability to compile and link the specified testcode. The missing-message
50dnl defaults to 'no' and may contain additional hints for the user.
51dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
52dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
53dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
54dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
55dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
56dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
57AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
58[
59 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
60 AC_REQUIRE([AC_LIB_RPATH])
61 pushdef([Name],[m4_translit([$1],[./+-], [____])])
62 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
63 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
64
65 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
66 dnl accordingly.
67 AC_LIB_LINKFLAGS_BODY([$1], [$2])
68
69 dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
70 dnl because if the user has installed lib[]Name and not disabled its use
71 dnl via --without-lib[]Name-prefix, he wants to use it.
72 ac_save_CPPFLAGS="$CPPFLAGS"
73 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
74
75 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
76 ac_save_LIBS="$LIBS"
77 dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
78 dnl because these -l options might require -L options that are present in
79 dnl LIBS. -l options benefit only from the -L options listed before it.
80 dnl Otherwise, add it to the front of LIBS, because it may be a static
81 dnl library that depends on another static library that is present in LIBS.
82 dnl Static libraries benefit only from the static libraries listed after
83 dnl it.
84 case " $LIB[]NAME" in
85 *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86 *) LIBS="$LIB[]NAME $LIBS" ;;
87 esac
88 AC_LINK_IFELSE(
89 [AC_LANG_PROGRAM([[$3]], [[$4]])],
90 [ac_cv_lib[]Name=yes],
91 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
92 LIBS="$ac_save_LIBS"
93 ])
94 if test "$ac_cv_lib[]Name" = yes; then
95 HAVE_LIB[]NAME=yes
96 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
97 AC_MSG_CHECKING([how to link with lib[]$1])
98 AC_MSG_RESULT([$LIB[]NAME])
99 else
100 HAVE_LIB[]NAME=no
101 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
102 dnl $INC[]NAME either.
103 CPPFLAGS="$ac_save_CPPFLAGS"
104 LIB[]NAME=
105 LTLIB[]NAME=
106 LIB[]NAME[]_PREFIX=
107 fi
108 AC_SUBST([HAVE_LIB]NAME)
109 AC_SUBST([LIB]NAME)
110 AC_SUBST([LTLIB]NAME)
111 AC_SUBST([LIB]NAME[_PREFIX])
112 popdef([NAME])
113 popdef([Name])
114])
115
116dnl Determine the platform dependent parameters needed to use rpath:
117dnl acl_libext,
118dnl acl_shlibext,
119dnl acl_libname_spec,
120dnl acl_library_names_spec,
121dnl acl_hardcode_libdir_flag_spec,
122dnl acl_hardcode_libdir_separator,
123dnl acl_hardcode_direct,
124dnl acl_hardcode_minus_L.
125AC_DEFUN([AC_LIB_RPATH],
126[
127 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
128 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
129 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
130 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
131 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
132 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
133 AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
134 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
135 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
136 . ./conftest.sh
137 rm -f ./conftest.sh
138 acl_cv_rpath=done
139 ])
140 wl="$acl_cv_wl"
141 acl_libext="$acl_cv_libext"
142 acl_shlibext="$acl_cv_shlibext"
143 acl_libname_spec="$acl_cv_libname_spec"
144 acl_library_names_spec="$acl_cv_library_names_spec"
145 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
146 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
147 acl_hardcode_direct="$acl_cv_hardcode_direct"
148 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
149 dnl Determine whether the user wants rpath handling at all.
150 AC_ARG_ENABLE([rpath],
151 [ --disable-rpath do not hardcode runtime library paths],
152 :, enable_rpath=yes)
153])
154
155dnl AC_LIB_FROMPACKAGE(name, package)
156dnl declares that libname comes from the given package. The configure file
157dnl will then not have a --with-libname-prefix option but a
158dnl --with-package-prefix option. Several libraries can come from the same
159dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
160dnl macro call that searches for libname.
161AC_DEFUN([AC_LIB_FROMPACKAGE],
162[
163 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
164 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
165 define([acl_frompackage_]NAME, [$2])
166 popdef([NAME])
167 pushdef([PACK],[$2])
168 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
169 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
170 define([acl_libsinpackage_]PACKUP,
171 m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
172 popdef([PACKUP])
173 popdef([PACK])
174])
175
176dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
177dnl the libraries corresponding to explicit and implicit dependencies.
178dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
179dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
180dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
181AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
182[
183 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
184 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
185 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
186 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
187 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
188 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
189 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
190 dnl Autoconf >= 2.61 supports dots in --with options.
191 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
192 dnl By default, look in $includedir and $libdir.
193 use_additional=yes
194 AC_LIB_WITH_FINAL_PREFIX([
195 eval additional_includedir=\"$includedir\"
196 eval additional_libdir=\"$libdir\"
197 ])
198 AC_ARG_WITH(P_A_C_K[-prefix],
199[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
200 --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
201[
202 if test "X$withval" = "Xno"; then
203 use_additional=no
204 else
205 if test "X$withval" = "X"; then
206 AC_LIB_WITH_FINAL_PREFIX([
207 eval additional_includedir=\"$includedir\"
208 eval additional_libdir=\"$libdir\"
209 ])
210 else
211 additional_includedir="$withval/include"
212 additional_libdir="$withval/$acl_libdirstem"
213 if test "$acl_libdirstem2" != "$acl_libdirstem" \
214 && ! test -d "$withval/$acl_libdirstem"; then
215 additional_libdir="$withval/$acl_libdirstem2"
216 fi
217 fi
218 fi
219])
220 dnl Search the library and its dependencies in $additional_libdir and
221 dnl $LDFLAGS. Using breadth-first-seach.
222 LIB[]NAME=
223 LTLIB[]NAME=
224 INC[]NAME=
225 LIB[]NAME[]_PREFIX=
226 dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
227 dnl computed. So it has to be reset here.
228 HAVE_LIB[]NAME=
229 rpathdirs=
230 ltrpathdirs=
231 names_already_handled=
232 names_next_round='$1 $2'
233 while test -n "$names_next_round"; do
234 names_this_round="$names_next_round"
235 names_next_round=
236 for name in $names_this_round; do
237 already_handled=
238 for n in $names_already_handled; do
239 if test "$n" = "$name"; then
240 already_handled=yes
241 break
242 fi
243 done
244 if test -z "$already_handled"; then
245 names_already_handled="$names_already_handled $name"
246 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
247 dnl or AC_LIB_HAVE_LINKFLAGS call.
248 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
249 eval value=\"\$HAVE_LIB$uppername\"
250 if test -n "$value"; then
251 if test "$value" = yes; then
252 eval value=\"\$LIB$uppername\"
253 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
254 eval value=\"\$LTLIB$uppername\"
255 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
256 else
257 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
258 dnl that this library doesn't exist. So just drop it.
259 :
260 fi
261 else
262 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
263 dnl and the already constructed $LIBNAME/$LTLIBNAME.
264 found_dir=
265 found_la=
266 found_so=
267 found_a=
268 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
269 if test -n "$acl_shlibext"; then
270 shrext=".$acl_shlibext" # typically: shrext=.so
271 else
272 shrext=
273 fi
274 if test $use_additional = yes; then
275 dir="$additional_libdir"
276 dnl The same code as in the loop below:
277 dnl First look for a shared library.
278 if test -n "$acl_shlibext"; then
279 if test -f "$dir/$libname$shrext"; then
280 found_dir="$dir"
281 found_so="$dir/$libname$shrext"
282 else
283 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
284 ver=`(cd "$dir" && \
285 for f in "$libname$shrext".*; do echo "$f"; done \
286 | sed -e "s,^$libname$shrext\\\\.,," \
287 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
288 | sed 1q ) 2>/dev/null`
289 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
290 found_dir="$dir"
291 found_so="$dir/$libname$shrext.$ver"
292 fi
293 else
294 eval library_names=\"$acl_library_names_spec\"
295 for f in $library_names; do
296 if test -f "$dir/$f"; then
297 found_dir="$dir"
298 found_so="$dir/$f"
299 break
300 fi
301 done
302 fi
303 fi
304 fi
305 dnl Then look for a static library.
306 if test "X$found_dir" = "X"; then
307 if test -f "$dir/$libname.$acl_libext"; then
308 found_dir="$dir"
309 found_a="$dir/$libname.$acl_libext"
310 fi
311 fi
312 if test "X$found_dir" != "X"; then
313 if test -f "$dir/$libname.la"; then
314 found_la="$dir/$libname.la"
315 fi
316 fi
317 fi
318 if test "X$found_dir" = "X"; then
319 for x in $LDFLAGS $LTLIB[]NAME; do
320 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
321 case "$x" in
322 -L*)
323 dir=`echo "X$x" | sed -e 's/^X-L//'`
324 dnl First look for a shared library.
325 if test -n "$acl_shlibext"; then
326 if test -f "$dir/$libname$shrext"; then
327 found_dir="$dir"
328 found_so="$dir/$libname$shrext"
329 else
330 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
331 ver=`(cd "$dir" && \
332 for f in "$libname$shrext".*; do echo "$f"; done \
333 | sed -e "s,^$libname$shrext\\\\.,," \
334 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
335 | sed 1q ) 2>/dev/null`
336 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
337 found_dir="$dir"
338 found_so="$dir/$libname$shrext.$ver"
339 fi
340 else
341 eval library_names=\"$acl_library_names_spec\"
342 for f in $library_names; do
343 if test -f "$dir/$f"; then
344 found_dir="$dir"
345 found_so="$dir/$f"
346 break
347 fi
348 done
349 fi
350 fi
351 fi
352 dnl Then look for a static library.
353 if test "X$found_dir" = "X"; then
354 if test -f "$dir/$libname.$acl_libext"; then
355 found_dir="$dir"
356 found_a="$dir/$libname.$acl_libext"
357 fi
358 fi
359 if test "X$found_dir" != "X"; then
360 if test -f "$dir/$libname.la"; then
361 found_la="$dir/$libname.la"
362 fi
363 fi
364 ;;
365 esac
366 if test "X$found_dir" != "X"; then
367 break
368 fi
369 done
370 fi
371 if test "X$found_dir" != "X"; then
372 dnl Found the library.
373 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
374 if test "X$found_so" != "X"; then
375 dnl Linking with a shared library. We attempt to hardcode its
376 dnl directory into the executable's runpath, unless it's the
377 dnl standard /usr/lib.
378 if test "$enable_rpath" = no \
379 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
380 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
381 dnl No hardcoding is needed.
382 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
383 else
384 dnl Use an explicit option to hardcode DIR into the resulting
385 dnl binary.
386 dnl Potentially add DIR to ltrpathdirs.
387 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
388 haveit=
389 for x in $ltrpathdirs; do
390 if test "X$x" = "X$found_dir"; then
391 haveit=yes
392 break
393 fi
394 done
395 if test -z "$haveit"; then
396 ltrpathdirs="$ltrpathdirs $found_dir"
397 fi
398 dnl The hardcoding into $LIBNAME is system dependent.
399 if test "$acl_hardcode_direct" = yes; then
400 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
401 dnl resulting binary.
402 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
403 else
404 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
405 dnl Use an explicit option to hardcode DIR into the resulting
406 dnl binary.
407 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
408 dnl Potentially add DIR to rpathdirs.
409 dnl The rpathdirs will be appended to $LIBNAME at the end.
410 haveit=
411 for x in $rpathdirs; do
412 if test "X$x" = "X$found_dir"; then
413 haveit=yes
414 break
415 fi
416 done
417 if test -z "$haveit"; then
418 rpathdirs="$rpathdirs $found_dir"
419 fi
420 else
421 dnl Rely on "-L$found_dir".
422 dnl But don't add it if it's already contained in the LDFLAGS
423 dnl or the already constructed $LIBNAME
424 haveit=
425 for x in $LDFLAGS $LIB[]NAME; do
426 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
427 if test "X$x" = "X-L$found_dir"; then
428 haveit=yes
429 break
430 fi
431 done
432 if test -z "$haveit"; then
433 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
434 fi
435 if test "$acl_hardcode_minus_L" != no; then
436 dnl FIXME: Not sure whether we should use
437 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
438 dnl here.
439 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
440 else
441 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
442 dnl here, because this doesn't fit in flags passed to the
443 dnl compiler. So give up. No hardcoding. This affects only
444 dnl very old systems.
445 dnl FIXME: Not sure whether we should use
446 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
447 dnl here.
448 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
449 fi
450 fi
451 fi
452 fi
453 else
454 if test "X$found_a" != "X"; then
455 dnl Linking with a static library.
456 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
457 else
458 dnl We shouldn't come here, but anyway it's good to have a
459 dnl fallback.
460 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
461 fi
462 fi
463 dnl Assume the include files are nearby.
464 additional_includedir=
465 case "$found_dir" in
466 */$acl_libdirstem | */$acl_libdirstem/)
467 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
468 if test "$name" = '$1'; then
469 LIB[]NAME[]_PREFIX="$basedir"
470 fi
471 additional_includedir="$basedir/include"
472 ;;
473 */$acl_libdirstem2 | */$acl_libdirstem2/)
474 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
475 if test "$name" = '$1'; then
476 LIB[]NAME[]_PREFIX="$basedir"
477 fi
478 additional_includedir="$basedir/include"
479 ;;
480 esac
481 if test "X$additional_includedir" != "X"; then
482 dnl Potentially add $additional_includedir to $INCNAME.
483 dnl But don't add it
484 dnl 1. if it's the standard /usr/include,
485 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
486 dnl 3. if it's already present in $CPPFLAGS or the already
487 dnl constructed $INCNAME,
488 dnl 4. if it doesn't exist as a directory.
489 if test "X$additional_includedir" != "X/usr/include"; then
490 haveit=
491 if test "X$additional_includedir" = "X/usr/local/include"; then
492 if test -n "$GCC"; then
493 case $host_os in
494 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
495 esac
496 fi
497 fi
498 if test -z "$haveit"; then
499 for x in $CPPFLAGS $INC[]NAME; do
500 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
501 if test "X$x" = "X-I$additional_includedir"; then
502 haveit=yes
503 break
504 fi
505 done
506 if test -z "$haveit"; then
507 if test -d "$additional_includedir"; then
508 dnl Really add $additional_includedir to $INCNAME.
509 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
510 fi
511 fi
512 fi
513 fi
514 fi
515 dnl Look for dependencies.
516 if test -n "$found_la"; then
517 dnl Read the .la file. It defines the variables
518 dnl dlname, library_names, old_library, dependency_libs, current,
519 dnl age, revision, installed, dlopen, dlpreopen, libdir.
520 save_libdir="$libdir"
521 case "$found_la" in
522 */* | *\\*) . "$found_la" ;;
523 *) . "./$found_la" ;;
524 esac
525 libdir="$save_libdir"
526 dnl We use only dependency_libs.
527 for dep in $dependency_libs; do
528 case "$dep" in
529 -L*)
530 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
531 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
532 dnl But don't add it
533 dnl 1. if it's the standard /usr/lib,
534 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
535 dnl 3. if it's already present in $LDFLAGS or the already
536 dnl constructed $LIBNAME,
537 dnl 4. if it doesn't exist as a directory.
538 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
539 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
540 haveit=
541 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
542 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
543 if test -n "$GCC"; then
544 case $host_os in
545 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
546 esac
547 fi
548 fi
549 if test -z "$haveit"; then
550 haveit=
551 for x in $LDFLAGS $LIB[]NAME; do
552 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
553 if test "X$x" = "X-L$additional_libdir"; then
554 haveit=yes
555 break
556 fi
557 done
558 if test -z "$haveit"; then
559 if test -d "$additional_libdir"; then
560 dnl Really add $additional_libdir to $LIBNAME.
561 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
562 fi
563 fi
564 haveit=
565 for x in $LDFLAGS $LTLIB[]NAME; do
566 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
567 if test "X$x" = "X-L$additional_libdir"; then
568 haveit=yes
569 break
570 fi
571 done
572 if test -z "$haveit"; then
573 if test -d "$additional_libdir"; then
574 dnl Really add $additional_libdir to $LTLIBNAME.
575 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
576 fi
577 fi
578 fi
579 fi
580 ;;
581 -R*)
582 dir=`echo "X$dep" | sed -e 's/^X-R//'`
583 if test "$enable_rpath" != no; then
584 dnl Potentially add DIR to rpathdirs.
585 dnl The rpathdirs will be appended to $LIBNAME at the end.
586 haveit=
587 for x in $rpathdirs; do
588 if test "X$x" = "X$dir"; then
589 haveit=yes
590 break
591 fi
592 done
593 if test -z "$haveit"; then
594 rpathdirs="$rpathdirs $dir"
595 fi
596 dnl Potentially add DIR to ltrpathdirs.
597 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
598 haveit=
599 for x in $ltrpathdirs; do
600 if test "X$x" = "X$dir"; then
601 haveit=yes
602 break
603 fi
604 done
605 if test -z "$haveit"; then
606 ltrpathdirs="$ltrpathdirs $dir"
607 fi
608 fi
609 ;;
610 -l*)
611 dnl Handle this in the next round.
612 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
613 ;;
614 *.la)
615 dnl Handle this in the next round. Throw away the .la's
616 dnl directory; it is already contained in a preceding -L
617 dnl option.
618 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
619 ;;
620 *)
621 dnl Most likely an immediate library name.
622 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
623 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
624 ;;
625 esac
626 done
627 fi
628 else
629 dnl Didn't find the library; assume it is in the system directories
630 dnl known to the linker and runtime loader. (All the system
631 dnl directories known to the linker should also be known to the
632 dnl runtime loader, otherwise the system is severely misconfigured.)
633 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
634 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
635 fi
636 fi
637 fi
638 done
639 done
640 if test "X$rpathdirs" != "X"; then
641 if test -n "$acl_hardcode_libdir_separator"; then
642 dnl Weird platform: only the last -rpath option counts, the user must
643 dnl pass all path elements in one option. We can arrange that for a
644 dnl single library, but not when more than one $LIBNAMEs are used.
645 alldirs=
646 for found_dir in $rpathdirs; do
647 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
648 done
649 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
650 acl_save_libdir="$libdir"
651 libdir="$alldirs"
652 eval flag=\"$acl_hardcode_libdir_flag_spec\"
653 libdir="$acl_save_libdir"
654 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
655 else
656 dnl The -rpath options are cumulative.
657 for found_dir in $rpathdirs; do
658 acl_save_libdir="$libdir"
659 libdir="$found_dir"
660 eval flag=\"$acl_hardcode_libdir_flag_spec\"
661 libdir="$acl_save_libdir"
662 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
663 done
664 fi
665 fi
666 if test "X$ltrpathdirs" != "X"; then
667 dnl When using libtool, the option that works for both libraries and
668 dnl executables is -R. The -R options are cumulative.
669 for found_dir in $ltrpathdirs; do
670 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
671 done
672 fi
673 popdef([P_A_C_K])
674 popdef([PACKLIBS])
675 popdef([PACKUP])
676 popdef([PACK])
677 popdef([NAME])
678])
679
680dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
681dnl unless already present in VAR.
682dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
683dnl contains two or three consecutive elements that belong together.
684AC_DEFUN([AC_LIB_APPENDTOVAR],
685[
686 for element in [$2]; do
687 haveit=
688 for x in $[$1]; do
689 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
690 if test "X$x" = "X$element"; then
691 haveit=yes
692 break
693 fi
694 done
695 if test -z "$haveit"; then
696 [$1]="${[$1]}${[$1]:+ }$element"
697 fi
698 done
699])
700
701dnl For those cases where a variable contains several -L and -l options
702dnl referring to unknown libraries and directories, this macro determines the
703dnl necessary additional linker options for the runtime path.
704dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
705dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
706dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
707dnl otherwise linking without libtool is assumed.
708AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
709[
710 AC_REQUIRE([AC_LIB_RPATH])
711 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
712 $1=
713 if test "$enable_rpath" != no; then
714 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
715 dnl Use an explicit option to hardcode directories into the resulting
716 dnl binary.
717 rpathdirs=
718 next=
719 for opt in $2; do
720 if test -n "$next"; then
721 dir="$next"
722 dnl No need to hardcode the standard /usr/lib.
723 if test "X$dir" != "X/usr/$acl_libdirstem" \
724 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
725 rpathdirs="$rpathdirs $dir"
726 fi
727 next=
728 else
729 case $opt in
730 -L) next=yes ;;
731 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
732 dnl No need to hardcode the standard /usr/lib.
733 if test "X$dir" != "X/usr/$acl_libdirstem" \
734 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
735 rpathdirs="$rpathdirs $dir"
736 fi
737 next= ;;
738 *) next= ;;
739 esac
740 fi
741 done
742 if test "X$rpathdirs" != "X"; then
743 if test -n ""$3""; then
744 dnl libtool is used for linking. Use -R options.
745 for dir in $rpathdirs; do
746 $1="${$1}${$1:+ }-R$dir"
747 done
748 else
749 dnl The linker is used for linking directly.
750 if test -n "$acl_hardcode_libdir_separator"; then
751 dnl Weird platform: only the last -rpath option counts, the user
752 dnl must pass all path elements in one option.
753 alldirs=
754 for dir in $rpathdirs; do
755 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
756 done
757 acl_save_libdir="$libdir"
758 libdir="$alldirs"
759 eval flag=\"$acl_hardcode_libdir_flag_spec\"
760 libdir="$acl_save_libdir"
761 $1="$flag"
762 else
763 dnl The -rpath options are cumulative.
764 for dir in $rpathdirs; do
765 acl_save_libdir="$libdir"
766 libdir="$dir"
767 eval flag=\"$acl_hardcode_libdir_flag_spec\"
768 libdir="$acl_save_libdir"
769 $1="${$1}${$1:+ }$flag"
770 done
771 fi
772 fi
773 fi
774 fi
775 fi
776 AC_SUBST([$1])
777])
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4
deleted file mode 100644
index 60908e8f..00000000
--- a/gl/m4/lib-prefix.m4
+++ /dev/null
@@ -1,224 +0,0 @@
1# lib-prefix.m4 serial 7 (gettext-0.18)
2dnl Copyright (C) 2001-2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
10dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
11dnl require excessive bracketing.
12ifdef([AC_HELP_STRING],
13[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
14[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
15
16dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
17dnl to access previously installed libraries. The basic assumption is that
18dnl a user will want packages to use other packages he previously installed
19dnl with the same --prefix option.
20dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
21dnl libraries, but is otherwise very convenient.
22AC_DEFUN([AC_LIB_PREFIX],
23[
24 AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
25 AC_REQUIRE([AC_PROG_CC])
26 AC_REQUIRE([AC_CANONICAL_HOST])
27 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
28 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
29 dnl By default, look in $includedir and $libdir.
30 use_additional=yes
31 AC_LIB_WITH_FINAL_PREFIX([
32 eval additional_includedir=\"$includedir\"
33 eval additional_libdir=\"$libdir\"
34 ])
35 AC_LIB_ARG_WITH([lib-prefix],
36[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
37 --without-lib-prefix don't search for libraries in includedir and libdir],
38[
39 if test "X$withval" = "Xno"; then
40 use_additional=no
41 else
42 if test "X$withval" = "X"; then
43 AC_LIB_WITH_FINAL_PREFIX([
44 eval additional_includedir=\"$includedir\"
45 eval additional_libdir=\"$libdir\"
46 ])
47 else
48 additional_includedir="$withval/include"
49 additional_libdir="$withval/$acl_libdirstem"
50 fi
51 fi
52])
53 if test $use_additional = yes; then
54 dnl Potentially add $additional_includedir to $CPPFLAGS.
55 dnl But don't add it
56 dnl 1. if it's the standard /usr/include,
57 dnl 2. if it's already present in $CPPFLAGS,
58 dnl 3. if it's /usr/local/include and we are using GCC on Linux,
59 dnl 4. if it doesn't exist as a directory.
60 if test "X$additional_includedir" != "X/usr/include"; then
61 haveit=
62 for x in $CPPFLAGS; do
63 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
64 if test "X$x" = "X-I$additional_includedir"; then
65 haveit=yes
66 break
67 fi
68 done
69 if test -z "$haveit"; then
70 if test "X$additional_includedir" = "X/usr/local/include"; then
71 if test -n "$GCC"; then
72 case $host_os in
73 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
74 esac
75 fi
76 fi
77 if test -z "$haveit"; then
78 if test -d "$additional_includedir"; then
79 dnl Really add $additional_includedir to $CPPFLAGS.
80 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
81 fi
82 fi
83 fi
84 fi
85 dnl Potentially add $additional_libdir to $LDFLAGS.
86 dnl But don't add it
87 dnl 1. if it's the standard /usr/lib,
88 dnl 2. if it's already present in $LDFLAGS,
89 dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
90 dnl 4. if it doesn't exist as a directory.
91 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
92 haveit=
93 for x in $LDFLAGS; do
94 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
95 if test "X$x" = "X-L$additional_libdir"; then
96 haveit=yes
97 break
98 fi
99 done
100 if test -z "$haveit"; then
101 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
102 if test -n "$GCC"; then
103 case $host_os in
104 linux*) haveit=yes;;
105 esac
106 fi
107 fi
108 if test -z "$haveit"; then
109 if test -d "$additional_libdir"; then
110 dnl Really add $additional_libdir to $LDFLAGS.
111 LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
112 fi
113 fi
114 fi
115 fi
116 fi
117])
118
119dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
120dnl acl_final_exec_prefix, containing the values to which $prefix and
121dnl $exec_prefix will expand at the end of the configure script.
122AC_DEFUN([AC_LIB_PREPARE_PREFIX],
123[
124 dnl Unfortunately, prefix and exec_prefix get only finally determined
125 dnl at the end of configure.
126 if test "X$prefix" = "XNONE"; then
127 acl_final_prefix="$ac_default_prefix"
128 else
129 acl_final_prefix="$prefix"
130 fi
131 if test "X$exec_prefix" = "XNONE"; then
132 acl_final_exec_prefix='${prefix}'
133 else
134 acl_final_exec_prefix="$exec_prefix"
135 fi
136 acl_save_prefix="$prefix"
137 prefix="$acl_final_prefix"
138 eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
139 prefix="$acl_save_prefix"
140])
141
142dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
143dnl variables prefix and exec_prefix bound to the values they will have
144dnl at the end of the configure script.
145AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
146[
147 acl_save_prefix="$prefix"
148 prefix="$acl_final_prefix"
149 acl_save_exec_prefix="$exec_prefix"
150 exec_prefix="$acl_final_exec_prefix"
151 $1
152 exec_prefix="$acl_save_exec_prefix"
153 prefix="$acl_save_prefix"
154])
155
156dnl AC_LIB_PREPARE_MULTILIB creates
157dnl - a variable acl_libdirstem, containing the basename of the libdir, either
158dnl "lib" or "lib64" or "lib/64",
159dnl - a variable acl_libdirstem2, as a secondary possible value for
160dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
161dnl "lib/amd64".
162AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
163[
164 dnl There is no formal standard regarding lib and lib64.
165 dnl On glibc systems, the current practice is that on a system supporting
166 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
167 dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
168 dnl the compiler's default mode by looking at the compiler's library search
169 dnl path. If at least one of its elements ends in /lib64 or points to a
170 dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
171 dnl Otherwise we use the default, namely "lib".
172 dnl On Solaris systems, the current practice is that on a system supporting
173 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
174 dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
175 dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
176 AC_REQUIRE([AC_CANONICAL_HOST])
177 acl_libdirstem=lib
178 acl_libdirstem2=
179 case "$host_os" in
180 solaris*)
181 dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
182 dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
183 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
184 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
185 dnl symlink is missing, so we set acl_libdirstem2 too.
186 AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
187 [AC_EGREP_CPP([sixtyfour bits], [
188#ifdef _LP64
189sixtyfour bits
190#endif
191 ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
192 ])
193 if test $gl_cv_solaris_64bit = yes; then
194 acl_libdirstem=lib/64
195 case "$host_cpu" in
196 sparc*) acl_libdirstem2=lib/sparcv9 ;;
197 i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
198 esac
199 fi
200 ;;
201 *)
202 searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
203 if test -n "$searchpath"; then
204 acl_save_IFS="${IFS= }"; IFS=":"
205 for searchdir in $searchpath; do
206 if test -d "$searchdir"; then
207 case "$searchdir" in
208 */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
209 */../ | */.. )
210 # Better ignore directories of this form. They are misleading.
211 ;;
212 *) searchdir=`cd "$searchdir" && pwd`
213 case "$searchdir" in
214 */lib64 ) acl_libdirstem=lib64 ;;
215 esac ;;
216 esac
217 fi
218 done
219 IFS="$acl_save_IFS"
220 fi
221 ;;
222 esac
223 test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
224])
diff --git a/gl/m4/limits-h.m4 b/gl/m4/limits-h.m4
new file mode 100644
index 00000000..5088fa16
--- /dev/null
+++ b/gl/m4/limits-h.m4
@@ -0,0 +1,41 @@
1dnl Check whether limits.h has needed features.
2
3dnl Copyright 2016-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl From Paul Eggert.
9
10AC_DEFUN_ONCE([gl_LIMITS_H],
11[
12 gl_CHECK_NEXT_HEADERS([limits.h])
13
14 AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.],
15 [gl_cv_header_limits_width],
16 [AC_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
19 #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
20 #endif
21 #include <limits.h>
22 long long llm = LLONG_MAX;
23 int wb = WORD_BIT;
24 int ullw = ULLONG_WIDTH;
25 int bw = BOOL_WIDTH;
26 ]])],
27 [gl_cv_header_limits_width=yes],
28 [gl_cv_header_limits_width=no])])
29 if test "$gl_cv_header_limits_width" = yes; then
30 GL_GENERATE_LIMITS_H=false
31 else
32 GL_GENERATE_LIMITS_H=true
33 fi
34])
35
36dnl Unconditionally enables the replacement of <limits.h>.
37AC_DEFUN([gl_REPLACE_LIMITS_H],
38[
39 AC_REQUIRE([gl_LIMITS_H])
40 GL_GENERATE_LIMITS_H=true
41])
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index 2e93e581..15b6b2a5 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,5 +1,5 @@
1# localcharset.m4 serial 7 1# localcharset.m4 serial 8
2dnl Copyright (C) 2002, 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,10 +8,4 @@ AC_DEFUN([gl_LOCALCHARSET],
8[ 8[
9 dnl Prerequisites of lib/localcharset.c. 9 dnl Prerequisites of lib/localcharset.c.
10 AC_REQUIRE([AM_LANGINFO_CODESET]) 10 AC_REQUIRE([AM_LANGINFO_CODESET])
11 AC_REQUIRE([gl_FCNTL_O_FLAGS])
12 AC_CHECK_DECLS_ONCE([getc_unlocked])
13
14 dnl Prerequisites of the lib/Makefile.am snippet.
15 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_REQUIRE([gl_GLIBC21])
17]) 11])
diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4
index ef199e39..8c41fadf 100644
--- a/gl/m4/locale-fr.m4
+++ b/gl/m4/locale-fr.m4
@@ -1,5 +1,5 @@
1# locale-fr.m4 serial 17 1# locale-fr.m4 serial 20
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_FR],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ 14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <time.h> 17#include <time.h>
19#if HAVE_LANGINFO_CODESET 18#if HAVE_LANGINFO_CODESET
@@ -24,8 +23,14 @@ changequote(,)dnl
24struct tm t; 23struct tm t;
25char buf[16]; 24char buf[16];
26int main () { 25int main () {
26 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
27 imitates locale dependent behaviour by looking at the environment
28 variables, and all locales use the UTF-8 encoding. */
29#if defined __BEOS__ || defined __HAIKU__
30 return 1;
31#else
27 /* Check whether the given locale name is recognized by the system. */ 32 /* Check whether the given locale name is recognized by the system. */
28#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 33# if defined _WIN32 && !defined __CYGWIN__
29 /* On native Windows, setlocale(category, "") looks at the system settings, 34 /* On native Windows, setlocale(category, "") looks at the system settings,
30 not at the environment variables. Also, when an encoding suffix such 35 not at the environment variables. Also, when an encoding suffix such
31 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 36 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -33,9 +38,9 @@ int main () {
33 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 38 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
34 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 39 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
35 return 1; 40 return 1;
36#else 41# else
37 if (setlocale (LC_ALL, "") == NULL) return 1; 42 if (setlocale (LC_ALL, "") == NULL) return 1;
38#endif 43# endif
39 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 44 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
40 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 45 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
41 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 46 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -44,35 +49,35 @@ int main () {
44 some unit tests fail. 49 some unit tests fail.
45 On MirBSD 10, when an unsupported locale is specified, setlocale() 50 On MirBSD 10, when an unsupported locale is specified, setlocale()
46 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 51 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
47#if HAVE_LANGINFO_CODESET 52# if HAVE_LANGINFO_CODESET
48 { 53 {
49 const char *cs = nl_langinfo (CODESET); 54 const char *cs = nl_langinfo (CODESET);
50 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 55 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
51 || strcmp (cs, "UTF-8") == 0) 56 || strcmp (cs, "UTF-8") == 0)
52 return 1; 57 return 1;
53 } 58 }
54#endif 59# endif
55#ifdef __CYGWIN__ 60# ifdef __CYGWIN__
56 /* On Cygwin, avoid locale names without encoding suffix, because the 61 /* On Cygwin, avoid locale names without encoding suffix, because the
57 locale_charset() function relies on the encoding suffix. Note that 62 locale_charset() function relies on the encoding suffix. Note that
58 LC_ALL is set on the command line. */ 63 LC_ALL is set on the command line. */
59 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 64 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
60#endif 65# endif
61 /* Check whether in the abbreviation of the second month, the second 66 /* Check whether in the abbreviation of the second month, the second
62 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only 67 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
63 one byte long. This excludes the UTF-8 encoding. */ 68 one byte long. This excludes the UTF-8 encoding. */
64 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
65 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; 70 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
66#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ 71# if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
67 /* Check whether the decimal separator is a comma. 72 /* Check whether the decimal separator is a comma.
68 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 73 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
69 are nl_langinfo(RADIXCHAR) are both ".". */ 74 are nl_langinfo(RADIXCHAR) are both ".". */
70 if (localeconv () ->decimal_point[0] != ',') return 1; 75 if (localeconv () ->decimal_point[0] != ',') return 1;
71#endif 76# endif
72 return 0; 77 return 0;
78#endif
73} 79}
74changequote([,])dnl 80 ]])])
75 ])])
76 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 81 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
77 case "$host_os" in 82 case "$host_os" in
78 # Handle native Windows specially, because there setlocale() interprets 83 # Handle native Windows specially, because there setlocale() interprets
@@ -136,8 +141,7 @@ AC_DEFUN([gt_LOCALE_FR_UTF8],
136[ 141[
137 AC_REQUIRE([AM_LANGINFO_CODESET]) 142 AC_REQUIRE([AM_LANGINFO_CODESET])
138 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ 143 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
139 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 144 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
140changequote(,)dnl
141#include <locale.h> 145#include <locale.h>
142#include <time.h> 146#include <time.h>
143#if HAVE_LANGINFO_CODESET 147#if HAVE_LANGINFO_CODESET
@@ -153,7 +157,7 @@ int main () {
153 variables, and all locales use the UTF-8 encoding. */ 157 variables, and all locales use the UTF-8 encoding. */
154#if !(defined __BEOS__ || defined __HAIKU__) 158#if !(defined __BEOS__ || defined __HAIKU__)
155 /* Check whether the given locale name is recognized by the system. */ 159 /* Check whether the given locale name is recognized by the system. */
156# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 160# if defined _WIN32 && !defined __CYGWIN__
157 /* On native Windows, setlocale(category, "") looks at the system settings, 161 /* On native Windows, setlocale(category, "") looks at the system settings,
158 not at the environment variables. Also, when an encoding suffix such 162 not at the environment variables. Also, when an encoding suffix such
159 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 163 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -199,8 +203,7 @@ int main () {
199#endif 203#endif
200 return 0; 204 return 0;
201} 205}
202changequote([,])dnl 206 ]])])
203 ])])
204 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 207 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
205 case "$host_os" in 208 case "$host_os" in
206 # Handle native Windows specially, because there setlocale() interprets 209 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4
index 132a3e77..25901730 100644
--- a/gl/m4/locale-ja.m4
+++ b/gl/m4/locale-ja.m4
@@ -1,5 +1,5 @@
1# locale-ja.m4 serial 12 1# locale-ja.m4 serial 15
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_JA],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [ 14 AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <time.h> 17#include <time.h>
19#if HAVE_LANGINFO_CODESET 18#if HAVE_LANGINFO_CODESET
@@ -25,9 +24,14 @@ struct tm t;
25char buf[16]; 24char buf[16];
26int main () 25int main ()
27{ 26{
28 const char *p; 27 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
28 imitates locale dependent behaviour by looking at the environment
29 variables, and all locales use the UTF-8 encoding. */
30#if defined __BEOS__ || defined __HAIKU__
31 return 1;
32#else
29 /* Check whether the given locale name is recognized by the system. */ 33 /* Check whether the given locale name is recognized by the system. */
30#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 34# if defined _WIN32 && !defined __CYGWIN__
31 /* On native Windows, setlocale(category, "") looks at the system settings, 35 /* On native Windows, setlocale(category, "") looks at the system settings,
32 not at the environment variables. Also, when an encoding suffix such 36 not at the environment variables. Also, when an encoding suffix such
33 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 37 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -35,9 +39,9 @@ int main ()
35 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 39 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
36 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 40 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
37 return 1; 41 return 1;
38#else 42# else
39 if (setlocale (LC_ALL, "") == NULL) return 1; 43 if (setlocale (LC_ALL, "") == NULL) return 1;
40#endif 44# endif
41 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 45 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
42 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 46 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
43 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 47 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -46,35 +50,38 @@ int main ()
46 some unit tests fail. 50 some unit tests fail.
47 On MirBSD 10, when an unsupported locale is specified, setlocale() 51 On MirBSD 10, when an unsupported locale is specified, setlocale()
48 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 52 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
49#if HAVE_LANGINFO_CODESET 53# if HAVE_LANGINFO_CODESET
50 { 54 {
51 const char *cs = nl_langinfo (CODESET); 55 const char *cs = nl_langinfo (CODESET);
52 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 56 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
53 || strcmp (cs, "UTF-8") == 0) 57 || strcmp (cs, "UTF-8") == 0)
54 return 1; 58 return 1;
55 } 59 }
56#endif 60# endif
57#ifdef __CYGWIN__ 61# ifdef __CYGWIN__
58 /* On Cygwin, avoid locale names without encoding suffix, because the 62 /* On Cygwin, avoid locale names without encoding suffix, because the
59 locale_charset() function relies on the encoding suffix. Note that 63 locale_charset() function relies on the encoding suffix. Note that
60 LC_ALL is set on the command line. */ 64 LC_ALL is set on the command line. */
61 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 65 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
62#endif 66# endif
63 /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales 67 /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales
64 on Cygwin 1.5.x. */ 68 on Cygwin 1.5.x. */
65 if (MB_CUR_MAX == 1) 69 if (MB_CUR_MAX == 1)
66 return 1; 70 return 1;
67 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 71 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
68 This excludes the UTF-8 encoding (except on MirBSD). */ 72 This excludes the UTF-8 encoding (except on MirBSD). */
69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 73 {
70 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 74 const char *p;
71 for (p = buf; *p != '\0'; p++) 75 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
72 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) 76 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
73 return 1; 77 for (p = buf; *p != '\0'; p++)
78 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
79 return 1;
80 }
74 return 0; 81 return 0;
82#endif
75} 83}
76changequote([,])dnl 84 ]])])
77 ])])
78 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 85 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
79 case "$host_os" in 86 case "$host_os" in
80 # Handle native Windows specially, because there setlocale() interprets 87 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4
index 4eed73f4..b9f9eef7 100644
--- a/gl/m4/locale-zh.m4
+++ b/gl/m4/locale-zh.m4
@@ -1,5 +1,5 @@
1# locale-zh.m4 serial 12 1# locale-zh.m4 serial 15
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_ZH_CN],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [ 14 AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <stdlib.h> 17#include <stdlib.h>
19#include <time.h> 18#include <time.h>
@@ -26,9 +25,14 @@ struct tm t;
26char buf[16]; 25char buf[16];
27int main () 26int main ()
28{ 27{
29 const char *p; 28 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
29 imitates locale dependent behaviour by looking at the environment
30 variables, and all locales use the UTF-8 encoding. */
31#if defined __BEOS__ || defined __HAIKU__
32 return 1;
33#else
30 /* Check whether the given locale name is recognized by the system. */ 34 /* Check whether the given locale name is recognized by the system. */
31#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 35# if defined _WIN32 && !defined __CYGWIN__
32 /* On native Windows, setlocale(category, "") looks at the system settings, 36 /* On native Windows, setlocale(category, "") looks at the system settings,
33 not at the environment variables. Also, when an encoding suffix such 37 not at the environment variables. Also, when an encoding suffix such
34 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 38 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -36,9 +40,9 @@ int main ()
36 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 40 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
37 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 41 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
38 return 1; 42 return 1;
39#else 43# else
40 if (setlocale (LC_ALL, "") == NULL) return 1; 44 if (setlocale (LC_ALL, "") == NULL) return 1;
41#endif 45# endif
42 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 46 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
43 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 47 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
44 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 48 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -47,35 +51,38 @@ int main ()
47 some unit tests fail. 51 some unit tests fail.
48 On MirBSD 10, when an unsupported locale is specified, setlocale() 52 On MirBSD 10, when an unsupported locale is specified, setlocale()
49 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 53 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
50#if HAVE_LANGINFO_CODESET 54# if HAVE_LANGINFO_CODESET
51 { 55 {
52 const char *cs = nl_langinfo (CODESET); 56 const char *cs = nl_langinfo (CODESET);
53 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 57 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
54 || strcmp (cs, "UTF-8") == 0) 58 || strcmp (cs, "UTF-8") == 0)
55 return 1; 59 return 1;
56 } 60 }
57#endif 61# endif
58#ifdef __CYGWIN__ 62# ifdef __CYGWIN__
59 /* On Cygwin, avoid locale names without encoding suffix, because the 63 /* On Cygwin, avoid locale names without encoding suffix, because the
60 locale_charset() function relies on the encoding suffix. Note that 64 locale_charset() function relies on the encoding suffix. Note that
61 LC_ALL is set on the command line. */ 65 LC_ALL is set on the command line. */
62 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 66 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
63#endif 67# endif
64 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 68 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
65 This excludes the UTF-8 encoding (except on MirBSD). */ 69 This excludes the UTF-8 encoding (except on MirBSD). */
66 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 70 {
67 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 71 const char *p;
68 for (p = buf; *p != '\0'; p++) 72 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
69 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) 73 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
70 return 1; 74 for (p = buf; *p != '\0'; p++)
75 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
76 return 1;
77 }
71 /* Check whether a typical GB18030 multibyte sequence is recognized as a 78 /* Check whether a typical GB18030 multibyte sequence is recognized as a
72 single wide character. This excludes the GB2312 and GBK encodings. */ 79 single wide character. This excludes the GB2312 and GBK encodings. */
73 if (mblen ("\203\062\332\066", 5) != 4) 80 if (mblen ("\203\062\332\066", 5) != 4)
74 return 1; 81 return 1;
75 return 0; 82 return 0;
83#endif
76} 84}
77changequote([,])dnl 85 ]])])
78 ])])
79 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 86 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
80 case "$host_os" in 87 case "$host_os" in
81 # Handle native Windows specially, because there setlocale() interprets 88 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale_h.m4 b/gl/m4/locale_h.m4
index 8bd12e80..a33a0a46 100644
--- a/gl/m4/locale_h.m4
+++ b/gl/m4/locale_h.m4
@@ -1,13 +1,13 @@
1# locale_h.m4 serial 19 1# locale_h.m4 serial 28
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_LOCALE_H], 7AC_DEFUN_ONCE([gl_LOCALE_H],
8[ 8[
9 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 9 dnl Ensure to expand the default settings once only, before all statements
10 dnl once only, before all statements that occur in other macros. 10 dnl that occur in other macros.
11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
12 12
13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_* 13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
@@ -17,7 +17,9 @@ AC_DEFUN([gl_LOCALE_H],
17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced. 17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
18 AC_REQUIRE([gl_STDDEF_H]) 18 AC_REQUIRE([gl_STDDEF_H])
19 19
20 dnl Solaris 11 2011-11 defines the int_p_*, int_n_* members of 'struct lconv' 20 AC_REQUIRE([gl_LOCALE_T])
21
22 dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
21 dnl only if _LCONV_C99 is defined. 23 dnl only if _LCONV_C99 is defined.
22 AC_REQUIRE([AC_CANONICAL_HOST]) 24 AC_REQUIRE([AC_CANONICAL_HOST])
23 case "$host_os" in 25 case "$host_os" in
@@ -37,34 +39,6 @@ AC_DEFUN([gl_LOCALE_H],
37 [gl_cv_header_locale_h_posix2001=yes], 39 [gl_cv_header_locale_h_posix2001=yes],
38 [gl_cv_header_locale_h_posix2001=no])]) 40 [gl_cv_header_locale_h_posix2001=no])])
39 41
40 dnl Check for <xlocale.h>.
41 AC_CHECK_HEADERS_ONCE([xlocale.h])
42 if test $ac_cv_header_xlocale_h = yes; then
43 HAVE_XLOCALE_H=1
44 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
45 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
46 dnl itself, we assume that <xlocale.h> will do so.
47 AC_CACHE_CHECK([whether locale.h defines locale_t],
48 [gl_cv_header_locale_has_locale_t],
49 [AC_COMPILE_IFELSE(
50 [AC_LANG_PROGRAM(
51 [[#include <locale.h>
52 locale_t x;]],
53 [[]])],
54 [gl_cv_header_locale_has_locale_t=yes],
55 [gl_cv_header_locale_has_locale_t=no])
56 ])
57 if test $gl_cv_header_locale_has_locale_t = yes; then
58 gl_cv_header_locale_h_needs_xlocale_h=no
59 else
60 gl_cv_header_locale_h_needs_xlocale_h=yes
61 fi
62 else
63 HAVE_XLOCALE_H=0
64 gl_cv_header_locale_h_needs_xlocale_h=no
65 fi
66 AC_SUBST([HAVE_XLOCALE_H])
67
68 dnl Check whether 'struct lconv' is complete. 42 dnl Check whether 'struct lconv' is complete.
69 dnl Bionic libc's 'struct lconv' is just a dummy. 43 dnl Bionic libc's 'struct lconv' is just a dummy.
70 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, 44 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
@@ -82,7 +56,20 @@ AC_DEFUN([gl_LOCALE_H],
82 [gl_cv_sys_struct_lconv_ok=no]) 56 [gl_cv_sys_struct_lconv_ok=no])
83 ]) 57 ])
84 if test $gl_cv_sys_struct_lconv_ok = no; then 58 if test $gl_cv_sys_struct_lconv_ok = no; then
85 REPLACE_STRUCT_LCONV=1 59 dnl On native Windows with MSVC, merely define these member names as macros.
60 dnl This avoids trouble in C++ mode.
61 case "$host_os" in
62 mingw*)
63 AC_EGREP_CPP([Special], [
64#ifdef _MSC_VER
65 Special
66#endif
67 ],
68 [],
69 [REPLACE_STRUCT_LCONV=1])
70 ;;
71 *) REPLACE_STRUCT_LCONV=1 ;;
72 esac
86 fi 73 fi
87 74
88 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK. 75 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
@@ -96,27 +83,92 @@ AC_DEFUN([gl_LOCALE_H],
96# include <xlocale.h> 83# include <xlocale.h>
97#endif 84#endif
98 ]], 85 ]],
99 [setlocale duplocale]) 86 [setlocale newlocale duplocale freelocale])
87])
88
89dnl Checks to determine whether the system has the locale_t type,
90dnl and how to obtain it.
91AC_DEFUN([gl_LOCALE_T],
92[
93 dnl Persuade glibc and Solaris <locale.h> to define locale_t.
94 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
95
96 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
97 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
98 dnl itself, we assume that <xlocale.h> will do so.
99 AC_CACHE_CHECK([whether locale.h defines locale_t],
100 [gl_cv_header_locale_has_locale_t],
101 [AC_COMPILE_IFELSE(
102 [AC_LANG_PROGRAM(
103 [[#include <locale.h>
104 locale_t x;]],
105 [[]])],
106 [gl_cv_header_locale_has_locale_t=yes],
107 [gl_cv_header_locale_has_locale_t=no])
108 ])
109
110 dnl Check for <xlocale.h>.
111 AC_CHECK_HEADERS_ONCE([xlocale.h])
112 if test $ac_cv_header_xlocale_h = yes; then
113 HAVE_XLOCALE_H=1
114 if test $gl_cv_header_locale_has_locale_t = yes; then
115 gl_cv_header_locale_h_needs_xlocale_h=no
116 else
117 gl_cv_header_locale_h_needs_xlocale_h=yes
118 fi
119 HAVE_LOCALE_T=1
120 else
121 HAVE_XLOCALE_H=0
122 gl_cv_header_locale_h_needs_xlocale_h=no
123 if test $gl_cv_header_locale_has_locale_t = yes; then
124 HAVE_LOCALE_T=1
125 else
126 HAVE_LOCALE_T=0
127 fi
128 fi
129 AC_SUBST([HAVE_XLOCALE_H])
100]) 130])
101 131
132# gl_LOCALE_MODULE_INDICATOR([modulename])
133# sets the shell variable that indicates the presence of the given module
134# to a C preprocessor expression that will evaluate to 1.
135# This macro invocation must not occur in macros that are AC_REQUIREd.
102AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], 136AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
103[ 137[
104 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 138 dnl Ensure to expand the default settings once only.
105 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 139 gl_LOCALE_H_REQUIRE_DEFAULTS
106 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 140 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
107 dnl Define it also as a C macro, for the benefit of the unit tests. 141 dnl Define it also as a C macro, for the benefit of the unit tests.
108 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 142 gl_MODULE_INDICATOR_FOR_TESTS([$1])
109]) 143])
110 144
145# Initializes the default values for AC_SUBSTed shell variables.
146# This macro must not be AC_REQUIREd. It must only be invoked, and only
147# outside of macros or in macros that are not AC_REQUIREd.
148AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
149[
150 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS], [
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME])
156 ])
157 m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS])
158 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
159])
160
111AC_DEFUN([gl_LOCALE_H_DEFAULTS], 161AC_DEFUN([gl_LOCALE_H_DEFAULTS],
112[ 162[
113 GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
114 GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
115 GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
116 dnl Assume proper GNU behavior unless another module says otherwise. 163 dnl Assume proper GNU behavior unless another module says otherwise.
164 HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE])
117 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) 165 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
166 HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE])
118 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV]) 167 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
119 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE]) 168 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
169 REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE])
120 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) 170 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
171 REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE])
121 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV]) 172 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
173 LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
122]) 174])
diff --git a/gl/m4/localeconv.m4 b/gl/m4/localeconv.m4
index b8bb5964..ae225fed 100644
--- a/gl/m4/localeconv.m4
+++ b/gl/m4/localeconv.m4
@@ -1,5 +1,5 @@
1# localeconv.m4 serial 1 1# localeconv.m4 serial 1
2dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index aae1701a..88cf5575 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -1,5 +1,5 @@
1# lock.m4 serial 13 (gettext-0.18.2) 1# lock.m4 serial 14
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,11 +12,16 @@ AC_DEFUN([gl_LOCK],
12 if test "$gl_threads_api" = posix; then 12 if test "$gl_threads_api" = posix; then
13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the 13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the
14 # pthread_rwlock_* functions. 14 # pthread_rwlock_* functions.
15 has_rwlock=false
15 AC_CHECK_TYPE([pthread_rwlock_t], 16 AC_CHECK_TYPE([pthread_rwlock_t],
16 [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], 17 [has_rwlock=true
18 AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
17 [Define if the POSIX multithreading library has read/write locks.])], 19 [Define if the POSIX multithreading library has read/write locks.])],
18 [], 20 [],
19 [#include <pthread.h>]) 21 [#include <pthread.h>])
22 if $has_rwlock; then
23 gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
24 fi
20 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. 25 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
21 AC_COMPILE_IFELSE([ 26 AC_COMPILE_IFELSE([
22 AC_LANG_PROGRAM( 27 AC_LANG_PROGRAM(
diff --git a/gl/m4/longlong.m4 b/gl/m4/longlong.m4
deleted file mode 100644
index 3af6ab5a..00000000
--- a/gl/m4/longlong.m4
+++ /dev/null
@@ -1,113 +0,0 @@
1# longlong.m4 serial 17
2dnl Copyright (C) 1999-2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9# Define HAVE_LONG_LONG_INT if 'long long int' works.
10# This fixes a bug in Autoconf 2.61, and can be faster
11# than what's in Autoconf 2.62 through 2.68.
12
13# Note: If the type 'long long int' exists but is only 32 bits large
14# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
15# defined. In this case you can treat 'long long int' like 'long int'.
16
17AC_DEFUN([AC_TYPE_LONG_LONG_INT],
18[
19 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
20 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
21 [ac_cv_type_long_long_int=yes
22 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
23 ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
24 if test $ac_cv_type_long_long_int = yes; then
25 dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
26 dnl If cross compiling, assume the bug is not important, since
27 dnl nobody cross compiles for this platform as far as we know.
28 AC_RUN_IFELSE(
29 [AC_LANG_PROGRAM(
30 [[@%:@include <limits.h>
31 @%:@ifndef LLONG_MAX
32 @%:@ define HALF \
33 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
34 @%:@ define LLONG_MAX (HALF - 1 + HALF)
35 @%:@endif]],
36 [[long long int n = 1;
37 int i;
38 for (i = 0; ; i++)
39 {
40 long long int m = n << i;
41 if (m >> i != n)
42 return 1;
43 if (LLONG_MAX / 2 < m)
44 break;
45 }
46 return 0;]])],
47 [],
48 [ac_cv_type_long_long_int=no],
49 [:])
50 fi
51 fi])
52 if test $ac_cv_type_long_long_int = yes; then
53 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
54 [Define to 1 if the system has the type 'long long int'.])
55 fi
56])
57
58# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
59# This fixes a bug in Autoconf 2.61, and can be faster
60# than what's in Autoconf 2.62 through 2.68.
61
62# Note: If the type 'unsigned long long int' exists but is only 32 bits
63# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
64# will not be defined. In this case you can treat 'unsigned long long int'
65# like 'unsigned long int'.
66
67AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
68[
69 AC_CACHE_CHECK([for unsigned long long int],
70 [ac_cv_type_unsigned_long_long_int],
71 [ac_cv_type_unsigned_long_long_int=yes
72 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
73 AC_LINK_IFELSE(
74 [_AC_TYPE_LONG_LONG_SNIPPET],
75 [],
76 [ac_cv_type_unsigned_long_long_int=no])
77 fi])
78 if test $ac_cv_type_unsigned_long_long_int = yes; then
79 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
80 [Define to 1 if the system has the type 'unsigned long long int'.])
81 fi
82])
83
84# Expands to a C program that can be used to test for simultaneous support
85# of 'long long' and 'unsigned long long'. We don't want to say that
86# 'long long' is available if 'unsigned long long' is not, or vice versa,
87# because too many programs rely on the symmetry between signed and unsigned
88# integer types (excluding 'bool').
89AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
90[
91 AC_LANG_PROGRAM(
92 [[/* For now, do not test the preprocessor; as of 2007 there are too many
93 implementations with broken preprocessors. Perhaps this can
94 be revisited in 2012. In the meantime, code should not expect
95 #if to work with literals wider than 32 bits. */
96 /* Test literals. */
97 long long int ll = 9223372036854775807ll;
98 long long int nll = -9223372036854775807LL;
99 unsigned long long int ull = 18446744073709551615ULL;
100 /* Test constant expressions. */
101 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
102 ? 1 : -1)];
103 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
104 ? 1 : -1)];
105 int i = 63;]],
106 [[/* Test availability of runtime routines for shift and division. */
107 long long int llmax = 9223372036854775807ll;
108 unsigned long long int ullmax = 18446744073709551615ull;
109 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
110 | (llmax / ll) | (llmax % ll)
111 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
112 | (ullmax / ull) | (ullmax % ull));]])
113])
diff --git a/gl/m4/ls-mntd-fs.m4 b/gl/m4/ls-mntd-fs.m4
deleted file mode 100644
index fb116c8b..00000000
--- a/gl/m4/ls-mntd-fs.m4
+++ /dev/null
@@ -1,357 +0,0 @@
1# serial 30
2# How to list mounted file systems.
3
4# Copyright (C) 1998-2004, 2006, 2009-2013 Free Software Foundation, Inc.
5#
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl From Jim Meyering.
11dnl
12dnl This is not pretty. I've just taken the autoconf code and wrapped
13dnl it in an AC_DEFUN and made some other fixes.
14dnl
15
16# Replace Autoconf's AC_FUNC_GETMNTENT to work around a bug in Autoconf
17# through Autoconf 2.59. We can remove this once we assume Autoconf 2.60
18# or later.
19AC_DEFUN([AC_FUNC_GETMNTENT],
20[# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
21# -lseq on Dynix/PTX, -lgen on Unixware.
22AC_SEARCH_LIBS([getmntent], [sun seq gen])
23AC_CHECK_FUNCS([getmntent])
24])
25
26# gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
27AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
28 [
29AC_CHECK_FUNCS([listmntent getmntinfo])
30AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
31
32# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
33# NGROUPS (as the array dimension for a struct member) without a definition.
34AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
35
36AC_CHECK_HEADERS([sys/mount.h], [], [],
37 [AC_INCLUDES_DEFAULT
38 [#if HAVE_SYS_PARAM_H
39 #include <sys/param.h>
40 #endif]])
41
42AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
43 getfsstat_includes="\
44$ac_includes_default
45#if HAVE_SYS_PARAM_H
46# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
47#endif
48#if HAVE_SYS_UCRED_H
49# include <grp.h> /* needed for definition of NGROUPS */
50# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
51#endif
52#if HAVE_SYS_MOUNT_H
53# include <sys/mount.h>
54#endif
55#if HAVE_SYS_FS_TYPES_H
56# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
57#endif
58"
59AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
60
61# Determine how to get the list of mounted file systems.
62ac_list_mounted_fs=
63
64# If the getmntent function is available but not in the standard library,
65# make sure LIBS contains the appropriate -l option.
66AC_FUNC_GETMNTENT
67
68# This test must precede the ones for getmntent because Unicos-9 is
69# reported to have the getmntent function, but its support is incompatible
70# with other getmntent implementations.
71
72# NOTE: Normally, I wouldn't use a check for system type as I've done for
73# 'CRAY' below since that goes against the whole autoconf philosophy. But
74# I think there is too great a chance that some non-Cray system has a
75# function named listmntent to risk the false positive.
76
77if test -z "$ac_list_mounted_fs"; then
78 # Cray UNICOS 9
79 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
80 AC_CACHE_VAL([fu_cv_sys_mounted_cray_listmntent],
81 [fu_cv_sys_mounted_cray_listmntent=no
82 AC_EGREP_CPP([yes],
83 [#ifdef _CRAY
84yes
85#endif
86 ], [test $ac_cv_func_listmntent = yes \
87 && fu_cv_sys_mounted_cray_listmntent=yes]
88 )
89 ]
90 )
91 AC_MSG_RESULT([$fu_cv_sys_mounted_cray_listmntent])
92 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
93 ac_list_mounted_fs=found
94 AC_DEFINE([MOUNTED_LISTMNTENT], [1],
95 [Define if there is a function named listmntent that can be used to
96 list all mounted file systems. (UNICOS)])
97 fi
98fi
99
100if test -z "$ac_list_mounted_fs"; then
101 # AIX.
102 AC_MSG_CHECKING([for mntctl function and struct vmount])
103 AC_CACHE_VAL([fu_cv_sys_mounted_vmount],
104 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <fshelp.h>]])],
105 [fu_cv_sys_mounted_vmount=yes],
106 [fu_cv_sys_mounted_vmount=no])])
107 AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
108 if test $fu_cv_sys_mounted_vmount = yes; then
109 ac_list_mounted_fs=found
110 AC_DEFINE([MOUNTED_VMOUNT], [1],
111 [Define if there is a function named mntctl that can be used to read
112 the list of mounted file systems, and there is a system header file
113 that declares 'struct vmount'. (AIX)])
114 fi
115fi
116
117if test $ac_cv_func_getmntent = yes; then
118
119 # This system has the getmntent function.
120 # Determine whether it's the one-argument variant or the two-argument one.
121
122 if test -z "$ac_list_mounted_fs"; then
123 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
124 AC_MSG_CHECKING([for one-argument getmntent function])
125 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent1],
126 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
127/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
128#include <stdio.h>
129
130#include <mntent.h>
131#if !defined MOUNTED
132# if defined _PATH_MOUNTED /* GNU libc */
133# define MOUNTED _PATH_MOUNTED
134# endif
135# if defined MNT_MNTTAB /* HP-UX. */
136# define MOUNTED MNT_MNTTAB
137# endif
138# if defined MNTTABNAME /* Dynix. */
139# define MOUNTED MNTTABNAME
140# endif
141#endif
142]],
143 [[ struct mntent *mnt = 0; char *table = MOUNTED;
144 if (sizeof mnt && sizeof table) return 0;]])],
145 [fu_cv_sys_mounted_getmntent1=yes],
146 [fu_cv_sys_mounted_getmntent1=no])])
147 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
148 if test $fu_cv_sys_mounted_getmntent1 = yes; then
149 ac_list_mounted_fs=found
150 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
151 [Define if there is a function named getmntent for reading the list
152 of mounted file systems, and that function takes a single argument.
153 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
154 fi
155 fi
156
157 if test -z "$ac_list_mounted_fs"; then
158 # SVR4
159 AC_MSG_CHECKING([for two-argument getmntent function])
160 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent2],
161 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
162 fu_cv_sys_mounted_getmntent2=yes,
163 fu_cv_sys_mounted_getmntent2=no)])
164 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
165 if test $fu_cv_sys_mounted_getmntent2 = yes; then
166 ac_list_mounted_fs=found
167 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
168 [Define if there is a function named getmntent for reading the list of
169 mounted file systems, and that function takes two arguments. (SVR4)])
170 AC_CHECK_FUNCS([hasmntopt])
171 fi
172 fi
173
174fi
175
176if test -z "$ac_list_mounted_fs"; then
177 # DEC Alpha running OSF/1, and Apple Darwin 1.3.
178 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
179
180 AC_MSG_CHECKING([for getfsstat function])
181 AC_CACHE_VAL([fu_cv_sys_mounted_getfsstat],
182 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
183#include <sys/types.h>
184#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
185# define FS_TYPE(Ent) ((Ent).f_fstypename)
186#else
187# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
188#endif
189$getfsstat_includes]]
190,
191 [[struct statfs *stats;
192 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
193 char *t = FS_TYPE (*stats); ]])],
194 [fu_cv_sys_mounted_getfsstat=yes],
195 [fu_cv_sys_mounted_getfsstat=no])])
196 AC_MSG_RESULT([$fu_cv_sys_mounted_getfsstat])
197 if test $fu_cv_sys_mounted_getfsstat = yes; then
198 ac_list_mounted_fs=found
199 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
200 [Define if there is a function named getfsstat for reading the
201 list of mounted file systems. (DEC Alpha running OSF/1)])
202 fi
203fi
204
205if test -z "$ac_list_mounted_fs"; then
206 # SVR3
207 AC_MSG_CHECKING([for FIXME existence of three headers])
208 AC_CACHE_VAL([fu_cv_sys_mounted_fread_fstyp],
209 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
210#include <sys/statfs.h>
211#include <sys/fstyp.h>
212#include <mnttab.h>]])],
213 [fu_cv_sys_mounted_fread_fstyp=yes],
214 [fu_cv_sys_mounted_fread_fstyp=no])])
215 AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
216 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
217 ac_list_mounted_fs=found
218 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
219 [Define if (like SVR2) there is no specific function for reading the
220 list of mounted file systems, and your system has these header files:
221 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
222 fi
223fi
224
225if test -z "$ac_list_mounted_fs"; then
226 # 4.4BSD and DEC OSF/1.
227 AC_MSG_CHECKING([for getmntinfo function])
228 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo],
229 [
230 test "$ac_cv_func_getmntinfo" = yes \
231 && fu_cv_sys_mounted_getmntinfo=yes \
232 || fu_cv_sys_mounted_getmntinfo=no
233 ])
234 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
235 if test $fu_cv_sys_mounted_getmntinfo = yes; then
236 AC_MSG_CHECKING([whether getmntinfo returns statvfs structures])
237 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo2],
238 [
239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
240#if HAVE_SYS_PARAM_H
241# include <sys/param.h>
242#endif
243#include <sys/types.h>
244#if HAVE_SYS_MOUNT_H
245# include <sys/mount.h>
246#endif
247#if HAVE_SYS_STATVFS_H
248# include <sys/statvfs.h>
249#endif
250extern
251#ifdef __cplusplus
252"C"
253#endif
254int getmntinfo (struct statfs **, int);
255 ]], [])],
256 [fu_cv_sys_mounted_getmntinfo2=no],
257 [fu_cv_sys_mounted_getmntinfo2=yes])
258 ])
259 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2])
260 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
261 ac_list_mounted_fs=found
262 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
263 [Define if there is a function named getmntinfo for reading the
264 list of mounted file systems and it returns an array of
265 'struct statfs'. (4.4BSD, Darwin)])
266 else
267 ac_list_mounted_fs=found
268 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
269 [Define if there is a function named getmntinfo for reading the
270 list of mounted file systems and it returns an array of
271 'struct statvfs'. (NetBSD 3.0)])
272 fi
273 fi
274fi
275
276if test -z "$ac_list_mounted_fs"; then
277 # Ultrix
278 AC_MSG_CHECKING([for getmnt function])
279 AC_CACHE_VAL([fu_cv_sys_mounted_getmnt],
280 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
281#include <sys/fs_types.h>
282#include <sys/mount.h>]])],
283 [fu_cv_sys_mounted_getmnt=yes],
284 [fu_cv_sys_mounted_getmnt=no])])
285 AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
286 if test $fu_cv_sys_mounted_getmnt = yes; then
287 ac_list_mounted_fs=found
288 AC_DEFINE([MOUNTED_GETMNT], [1],
289 [Define if there is a function named getmnt for reading the list of
290 mounted file systems. (Ultrix)])
291 fi
292fi
293
294if test -z "$ac_list_mounted_fs"; then
295 # BeOS
296 AC_CHECK_FUNCS([next_dev fs_stat_dev])
297 AC_CHECK_HEADERS([fs_info.h])
298 AC_MSG_CHECKING([for BEOS mounted file system support functions])
299 if test $ac_cv_header_fs_info_h = yes \
300 && test $ac_cv_func_next_dev = yes \
301 && test $ac_cv_func_fs_stat_dev = yes; then
302 fu_result=yes
303 else
304 fu_result=no
305 fi
306 AC_MSG_RESULT([$fu_result])
307 if test $fu_result = yes; then
308 ac_list_mounted_fs=found
309 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
310 [Define if there are functions named next_dev and fs_stat_dev for
311 reading the list of mounted file systems. (BeOS)])
312 fi
313fi
314
315if test -z "$ac_list_mounted_fs"; then
316 # SVR2
317 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
318 AC_CACHE_VAL([fu_cv_sys_mounted_fread],
319 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <mnttab.h>]])],
320 [fu_cv_sys_mounted_fread=yes],
321 [fu_cv_sys_mounted_fread=no])])
322 AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
323 if test $fu_cv_sys_mounted_fread = yes; then
324 ac_list_mounted_fs=found
325 AC_DEFINE([MOUNTED_FREAD], [1],
326 [Define if there is no specific function for reading the list of
327 mounted file systems. fread will be used to read /etc/mnttab.
328 (SVR2) ])
329 fi
330fi
331
332if test -z "$ac_list_mounted_fs"; then
333 # Interix / BSD alike statvfs
334 # the code is really interix specific, so make sure, we're on it.
335 case "$host" in
336 *-interix*)
337 AC_CHECK_FUNCS([statvfs])
338 if test $ac_cv_func_statvfs = yes; then
339 ac_list_mounted_fs=found
340 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
341 [Define if we are on interix, and ought to use statvfs plus
342 some special knowledge on where mounted file systems can be
343 found. (Interix)])
344 fi
345 ;;
346 esac
347fi
348
349if test -z "$ac_list_mounted_fs"; then
350 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
351 # FIXME -- no need to abort building the whole package
352 # Can't build mountlist.c or anything that needs its functions
353fi
354
355AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])
356
357 ])
diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4
new file mode 100644
index 00000000..fd4f1f27
--- /dev/null
+++ b/gl/m4/lseek.m4
@@ -0,0 +1,78 @@
1# lseek.m4 serial 12
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_LSEEK],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_REQUIRE([AC_PROG_CC])
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
15 [case "$host_os" in
16 mingw*)
17 dnl Native Windows.
18 dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or
19 dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT)
20 dnl for a pipe depends on the environment: In a Cygwin 1.5
21 dnl environment it succeeds (wrong); in a Cygwin 1.7 environment
22 dnl it fails with a wrong errno value.
23 gl_cv_func_lseek_pipe=no
24 ;;
25 *)
26 if test $cross_compiling = no; then
27 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
28#include <sys/types.h> /* for off_t */
29#include <stdio.h> /* for SEEK_CUR */
30#if HAVE_UNISTD_H
31# include <unistd.h>
32#else /* on Windows with MSVC */
33# include <io.h>
34#endif
35]GL_MDA_DEFINES],
36[[
37 /* Exit with success only if stdin is seekable. */
38 return lseek (0, (off_t)0, SEEK_CUR) < 0;
39]])],
40 [if test -s conftest$ac_exeext \
41 && ./conftest$ac_exeext < conftest.$ac_ext \
42 && test 1 = "`echo hi \
43 | { ./conftest$ac_exeext; echo $?; cat >/dev/null; }`"; then
44 gl_cv_func_lseek_pipe=yes
45 else
46 gl_cv_func_lseek_pipe=no
47 fi
48 ],
49 [gl_cv_func_lseek_pipe=no])
50 else
51 AC_COMPILE_IFELSE(
52 [AC_LANG_SOURCE([[
53#if defined __BEOS__
54/* BeOS mistakenly return 0 when trying to seek on pipes. */
55 Choke me.
56#endif]])],
57 [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
58 fi
59 ;;
60 esac
61 ])
62 if test "$gl_cv_func_lseek_pipe" = no; then
63 REPLACE_LSEEK=1
64 AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
65 [Define to 1 if lseek does not detect pipes.])
66 fi
67
68 AC_REQUIRE([gl_SYS_TYPES_H])
69 if test $WINDOWS_64_BIT_OFF_T = 1; then
70 REPLACE_LSEEK=1
71 fi
72
73 dnl macOS SEEK_DATA is incompatible with other platforms.
74 case $host_os in
75 darwin*)
76 REPLACE_LSEEK=1;;
77 esac
78])
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index 4b24a0b1..55402924 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,98 +1,175 @@
1# malloc.m4 serial 14 1# malloc.m4 serial 28
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7m4_version_prereq([2.70], [] ,[ 7# This is adapted with modifications from upstream Autoconf here:
8 8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949
9# This is taken from the following Autoconf patch:
10# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
11AC_DEFUN([_AC_FUNC_MALLOC_IF], 9AC_DEFUN([_AC_FUNC_MALLOC_IF],
12[ 10[
13 AC_REQUIRE([AC_HEADER_STDC])dnl
14 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles 11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
15 AC_CHECK_HEADERS([stdlib.h]) 12 AC_CACHE_CHECK([whether malloc (0) returns nonnull],
16 AC_CACHE_CHECK([for GNU libc compatible malloc],
17 [ac_cv_func_malloc_0_nonnull], 13 [ac_cv_func_malloc_0_nonnull],
18 [AC_RUN_IFELSE( 14 [AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM( 15 [AC_LANG_PROGRAM(
20 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H 16 [[#include <stdlib.h>
21 # include <stdlib.h>
22 #else
23 char *malloc ();
24 #endif
25 ]], 17 ]],
26 [[return ! malloc (0);]]) 18 [[void *p = malloc (0);
19 int result = !p;
20 free (p);
21 return result;]])
27 ], 22 ],
28 [ac_cv_func_malloc_0_nonnull=yes], 23 [ac_cv_func_malloc_0_nonnull=yes],
29 [ac_cv_func_malloc_0_nonnull=no], 24 [ac_cv_func_malloc_0_nonnull=no],
30 [case "$host_os" in 25 [case "$host_os" in
31 # Guess yes on platforms where we know the result. 26 # Guess yes on platforms where we know the result.
32 *-gnu* | freebsd* | netbsd* | openbsd* \ 27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
33 | hpux* | solaris* | cygwin* | mingw*) 28 | gnu* | *-musl* | midnightbsd* \
34 ac_cv_func_malloc_0_nonnull=yes ;; 29 | hpux* | solaris* | cygwin* | mingw* | msys* )
35 # If we don't know, assume the worst. 30 ac_cv_func_malloc_0_nonnull="guessing yes" ;;
36 *) ac_cv_func_malloc_0_nonnull=no ;; 31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;;
37 esac 33 esac
38 ]) 34 ])
39 ]) 35 ])
40 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2]) 36 AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2])
41])# _AC_FUNC_MALLOC_IF 37])# _AC_FUNC_MALLOC_IF
42 38
43])
44
45# gl_FUNC_MALLOC_GNU 39# gl_FUNC_MALLOC_GNU
46# ------------------ 40# ------------------
47# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if 41# Replace malloc if it is not compatible with GNU libc.
48# it is not.
49AC_DEFUN([gl_FUNC_MALLOC_GNU], 42AC_DEFUN([gl_FUNC_MALLOC_GNU],
50[ 43[
51 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
52 dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. 45 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
53 _AC_FUNC_MALLOC_IF( 46 REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX"
54 [AC_DEFINE([HAVE_MALLOC_GNU], [1], 47 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then
55 [Define to 1 if your system has a GNU libc compatible 'malloc' 48 _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
56 function, and to 0 otherwise.])], 49 fi
57 [AC_DEFINE([HAVE_MALLOC_GNU], [0]) 50])
58 REPLACE_MALLOC=1 51
52# gl_FUNC_MALLOC_PTRDIFF
53# ----------------------
54# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX,
55# and replace malloc otherwise.
56AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF],
57[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
60 test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1
61])
62
63# Test whether malloc, realloc, calloc refuse to create objects
64# larger than what can be expressed in ptrdiff_t.
65# Set gl_cv_func_malloc_gnu to yes or no accordingly.
66AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF],
67[
68 AC_CACHE_CHECK([whether malloc is ptrdiff_t safe],
69 [gl_cv_malloc_ptrdiff],
70 [AC_COMPILE_IFELSE(
71 [AC_LANG_PROGRAM(
72 [[#include <stdint.h>
73 ]],
74 [[/* 64-bit ptrdiff_t is so wide that no practical platform
75 can exceed it. */
76 #define WIDE_PTRDIFF (PTRDIFF_MAX >> 31 >> 31 != 0)
77
78 /* On rare machines where size_t fits in ptrdiff_t there
79 is no problem. */
80 #define NARROW_SIZE (SIZE_MAX <= PTRDIFF_MAX)
81
82 /* glibc 2.30 and later malloc refuses to exceed ptrdiff_t
83 bounds even on 32-bit platforms. We don't know which
84 non-glibc systems are safe. */
85 #define KNOWN_SAFE (2 < __GLIBC__ + (30 <= __GLIBC_MINOR__))
86
87 #if WIDE_PTRDIFF || NARROW_SIZE || KNOWN_SAFE
88 return 0;
89 #else
90 #error "malloc might not be ptrdiff_t safe"
91 syntax error
92 #endif
93 ]])],
94 [gl_cv_malloc_ptrdiff=yes],
95 [gl_cv_malloc_ptrdiff=no])
59 ]) 96 ])
60]) 97])
61 98
62# gl_FUNC_MALLOC_POSIX 99# gl_FUNC_MALLOC_POSIX
63# -------------------- 100# --------------------
64# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it 101# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
65# fails), and replace malloc if it is not. 102# fails, and doesn't mess up with ptrdiff_t overflow), and replace
103# malloc if it is not.
66AC_DEFUN([gl_FUNC_MALLOC_POSIX], 104AC_DEFUN([gl_FUNC_MALLOC_POSIX],
67[ 105[
68 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 106 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
107 AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF])
69 AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) 108 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
70 if test $gl_cv_func_malloc_posix = yes; then 109 if test "$gl_cv_func_malloc_posix" = yes; then
71 AC_DEFINE([HAVE_MALLOC_POSIX], [1], 110 AC_DEFINE([HAVE_MALLOC_POSIX], [1],
72 [Define if the 'malloc' function is POSIX compliant.]) 111 [Define if malloc, realloc, and calloc set errno on allocation failure.])
73 else 112 else
74 REPLACE_MALLOC=1 113 REPLACE_MALLOC_FOR_MALLOC_POSIX=1
75 fi 114 fi
76]) 115])
77 116
78# Test whether malloc, realloc, calloc are POSIX compliant, 117# Test whether malloc, realloc, calloc set errno to ENOMEM on failure.
79# Set gl_cv_func_malloc_posix to yes or no accordingly. 118# Set gl_cv_func_malloc_posix to yes or no accordingly.
80AC_DEFUN([gl_CHECK_MALLOC_POSIX], 119AC_DEFUN([gl_CHECK_MALLOC_POSIX],
81[ 120[
82 AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant], 121 AC_REQUIRE([AC_CANONICAL_HOST])
122 AC_CACHE_CHECK([whether malloc, realloc, calloc set errno on failure],
83 [gl_cv_func_malloc_posix], 123 [gl_cv_func_malloc_posix],
84 [ 124 [
85 dnl It is too dangerous to try to allocate a large amount of memory: 125 dnl It is too dangerous to try to allocate a large amount of memory:
86 dnl some systems go to their knees when you do that. So assume that 126 dnl some systems go to their knees when you do that. So assume that
87 dnl all Unix implementations of the function are POSIX compliant. 127 dnl all Unix implementations of the function set errno on failure,
88 AC_COMPILE_IFELSE( 128 dnl except on those platforms where we have seen 'test-malloc-gnu',
89 [AC_LANG_PROGRAM( 129 dnl 'test-realloc-gnu', 'test-calloc-gnu' fail.
90 [[]], 130 case "$host_os" in
91 [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 131 mingw*)
92 choke me 132 gl_cv_func_malloc_posix=no ;;
93 #endif 133 irix* | solaris*)
94 ]])], 134 dnl On IRIX 6.5, the three functions return NULL with errno unset
95 [gl_cv_func_malloc_posix=yes], 135 dnl when the argument is larger than PTRDIFF_MAX.
96 [gl_cv_func_malloc_posix=no]) 136 dnl On Solaris 11.3, the three functions return NULL with errno set
137 dnl to EAGAIN, not ENOMEM, when the argument is larger than
138 dnl PTRDIFF_MAX.
139 dnl Here is a test program:
140m4_divert_push([KILL])
141#include <errno.h>
142#include <stdio.h>
143#include <stdlib.h>
144#define ptrdiff_t long
145#ifndef PTRDIFF_MAX
146# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1))
147#endif
148
149int main ()
150{
151 void *p;
152
153 fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX);
154
155 errno = 0;
156 p = malloc ((unsigned long) PTRDIFF_MAX + 1);
157 fprintf (stderr, "p=%p errno=%d\n", p, errno);
158
159 errno = 0;
160 p = calloc (PTRDIFF_MAX / 2 + 1, 2);
161 fprintf (stderr, "p=%p errno=%d\n", p, errno);
162
163 errno = 0;
164 p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1);
165 fprintf (stderr, "p=%p errno=%d\n", p, errno);
166
167 return 0;
168}
169m4_divert_pop([KILL])
170 gl_cv_func_malloc_posix=no ;;
171 *)
172 gl_cv_func_malloc_posix=yes ;;
173 esac
97 ]) 174 ])
98]) 175])
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4
index 791ce10d..1d777ebe 100644
--- a/gl/m4/malloca.m4
+++ b/gl/m4/malloca.m4
@@ -1,5 +1,5 @@
1# malloca.m4 serial 1 1# malloca.m4 serial 2
2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -11,5 +11,4 @@ AC_DEFUN([gl_MALLOCA],
11 dnl @ALLOCA@ and @LTALLOCA@. 11 dnl @ALLOCA@ and @LTALLOCA@.
12 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. 12 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies.
13 AC_REQUIRE([gl_EEMALLOC]) 13 AC_REQUIRE([gl_EEMALLOC])
14 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
15]) 14])
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4
index bf0845fd..d2e90ff1 100644
--- a/gl/m4/math_h.m4
+++ b/gl/m4/math_h.m4
@@ -1,16 +1,16 @@
1# math_h.m4 serial 114 1# math_h.m4 serial 125
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_MATH_H], 7AC_DEFUN_ONCE([gl_MATH_H],
8[ 8[
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([math.h]) 10 gl_CHECK_NEXT_HEADERS([math.h])
11 11
12 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works], 12 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
13 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]], 13 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
14 [[/* Solaris 10 has a broken definition of NAN. Other platforms 14 [[/* Solaris 10 has a broken definition of NAN. Other platforms
15 fail to provide NAN, or provide it only in C99 mode; this 15 fail to provide NAN, or provide it only in C99 mode; this
16 test only needs to fail when NAN is provided but wrong. */ 16 test only needs to fail when NAN is provided but wrong. */
@@ -25,7 +25,7 @@ AC_DEFUN([gl_MATH_H],
25 REPLACE_NAN=1 25 REPLACE_NAN=1
26 fi 26 fi
27 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works], 27 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]], 28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
29 [[/* Solaris 10 has a broken definition of HUGE_VAL. */ 29 [[/* Solaris 10 has a broken definition of HUGE_VAL. */
30 double d = HUGE_VAL; 30 double d = HUGE_VAL;
31 return d == 0;]])], 31 return d == 0;]])],
@@ -53,272 +53,310 @@ AC_DEFUN([gl_MATH_H],
53 tanf tanl tanhf trunc truncf truncl]) 53 tanf tanl tanhf trunc truncf truncl])
54]) 54])
55 55
56# gl_MATH_MODULE_INDICATOR([modulename])
57# sets the shell variable that indicates the presence of the given module
58# to a C preprocessor expression that will evaluate to 1.
59# This macro invocation must not occur in macros that are AC_REQUIREd.
56AC_DEFUN([gl_MATH_MODULE_INDICATOR], 60AC_DEFUN([gl_MATH_MODULE_INDICATOR],
57[ 61[
58 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 62 dnl Ensure to expand the default settings once only.
59 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 63 gl_MATH_H_REQUIRE_DEFAULTS
60 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 64 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
61 dnl Define it also as a C macro, for the benefit of the unit tests. 65 dnl Define it also as a C macro, for the benefit of the unit tests.
62 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 66 gl_MODULE_INDICATOR_FOR_TESTS([$1])
63]) 67])
64 68
69# Initializes the default values for AC_SUBSTed shell variables.
70# This macro must not be AC_REQUIREd. It must only be invoked, and only
71# outside of macros or in macros that are not AC_REQUIREd.
72AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
73[
74 m4_defun(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS], [
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSF])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSL])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINF])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINL])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANF])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANL])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATAN2F])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRT])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTF])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTL])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEIL])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILF])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILL])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGN])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNF])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNL])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSF])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSL])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSHF])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPF])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPL])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2F])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2L])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1F])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1L])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSF])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSL])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOOR])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORF])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORL])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMA])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAF])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAL])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMOD])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODF])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODL])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPF])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXP])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPL])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOT])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTF])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTL])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGB])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBF])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBL])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISFINITE])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISINF])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAN])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANF])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAND])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANL])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPF])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPL])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGF])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGL])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10F])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10L])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1P])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PF])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PL])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2F])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2L])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGB])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBF])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBL])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POWF])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDER])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERF])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERL])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINT])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTL])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUND])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDL])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINF])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINL])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINHF])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTF])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTL])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANF])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANL])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANHF])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNC])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCF])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCL])
170 dnl Support Microsoft deprecated alias function names by default.
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J0], [1])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J1], [1])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_JN], [1])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y0], [1])
175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y1], [1])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_YN], [1])
177 ])
178 m4_require(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS])
179 AC_REQUIRE([gl_MATH_H_DEFAULTS])
180])
181
65AC_DEFUN([gl_MATH_H_DEFAULTS], 182AC_DEFUN([gl_MATH_H_DEFAULTS],
66[ 183[
67 GNULIB_ACOSF=0; AC_SUBST([GNULIB_ACOSF])
68 GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL])
69 GNULIB_ASINF=0; AC_SUBST([GNULIB_ASINF])
70 GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL])
71 GNULIB_ATANF=0; AC_SUBST([GNULIB_ATANF])
72 GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL])
73 GNULIB_ATAN2F=0; AC_SUBST([GNULIB_ATAN2F])
74 GNULIB_CBRT=0; AC_SUBST([GNULIB_CBRT])
75 GNULIB_CBRTF=0; AC_SUBST([GNULIB_CBRTF])
76 GNULIB_CBRTL=0; AC_SUBST([GNULIB_CBRTL])
77 GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL])
78 GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
79 GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL])
80 GNULIB_COPYSIGN=0; AC_SUBST([GNULIB_COPYSIGN])
81 GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
82 GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL])
83 GNULIB_COSF=0; AC_SUBST([GNULIB_COSF])
84 GNULIB_COSL=0; AC_SUBST([GNULIB_COSL])
85 GNULIB_COSHF=0; AC_SUBST([GNULIB_COSHF])
86 GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF])
87 GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL])
88 GNULIB_EXP2=0; AC_SUBST([GNULIB_EXP2])
89 GNULIB_EXP2F=0; AC_SUBST([GNULIB_EXP2F])
90 GNULIB_EXP2L=0; AC_SUBST([GNULIB_EXP2L])
91 GNULIB_EXPM1=0; AC_SUBST([GNULIB_EXPM1])
92 GNULIB_EXPM1F=0; AC_SUBST([GNULIB_EXPM1F])
93 GNULIB_EXPM1L=0; AC_SUBST([GNULIB_EXPM1L])
94 GNULIB_FABSF=0; AC_SUBST([GNULIB_FABSF])
95 GNULIB_FABSL=0; AC_SUBST([GNULIB_FABSL])
96 GNULIB_FLOOR=0; AC_SUBST([GNULIB_FLOOR])
97 GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF])
98 GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL])
99 GNULIB_FMA=0; AC_SUBST([GNULIB_FMA])
100 GNULIB_FMAF=0; AC_SUBST([GNULIB_FMAF])
101 GNULIB_FMAL=0; AC_SUBST([GNULIB_FMAL])
102 GNULIB_FMOD=0; AC_SUBST([GNULIB_FMOD])
103 GNULIB_FMODF=0; AC_SUBST([GNULIB_FMODF])
104 GNULIB_FMODL=0; AC_SUBST([GNULIB_FMODL])
105 GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF])
106 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
107 GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
108 GNULIB_HYPOT=0; AC_SUBST([GNULIB_HYPOT])
109 GNULIB_HYPOTF=0; AC_SUBST([GNULIB_HYPOTF])
110 GNULIB_HYPOTL=0; AC_SUBST([GNULIB_HYPOTL])
111 GNULIB_ILOGB=0; AC_SUBST([GNULIB_ILOGB])
112 GNULIB_ILOGBF=0; AC_SUBST([GNULIB_ILOGBF])
113 GNULIB_ILOGBL=0; AC_SUBST([GNULIB_ILOGBL])
114 GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
115 GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
116 GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
117 GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF])
118 GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND])
119 GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL])
120 GNULIB_LDEXPF=0; AC_SUBST([GNULIB_LDEXPF])
121 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
122 GNULIB_LOG=0; AC_SUBST([GNULIB_LOG])
123 GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF])
124 GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL])
125 GNULIB_LOG10=0; AC_SUBST([GNULIB_LOG10])
126 GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F])
127 GNULIB_LOG10L=0; AC_SUBST([GNULIB_LOG10L])
128 GNULIB_LOG1P=0; AC_SUBST([GNULIB_LOG1P])
129 GNULIB_LOG1PF=0; AC_SUBST([GNULIB_LOG1PF])
130 GNULIB_LOG1PL=0; AC_SUBST([GNULIB_LOG1PL])
131 GNULIB_LOG2=0; AC_SUBST([GNULIB_LOG2])
132 GNULIB_LOG2F=0; AC_SUBST([GNULIB_LOG2F])
133 GNULIB_LOG2L=0; AC_SUBST([GNULIB_LOG2L])
134 GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB])
135 GNULIB_LOGBF=0; AC_SUBST([GNULIB_LOGBF])
136 GNULIB_LOGBL=0; AC_SUBST([GNULIB_LOGBL])
137 GNULIB_MODF=0; AC_SUBST([GNULIB_MODF])
138 GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
139 GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL])
140 GNULIB_POWF=0; AC_SUBST([GNULIB_POWF])
141 GNULIB_REMAINDER=0; AC_SUBST([GNULIB_REMAINDER])
142 GNULIB_REMAINDERF=0; AC_SUBST([GNULIB_REMAINDERF])
143 GNULIB_REMAINDERL=0; AC_SUBST([GNULIB_REMAINDERL])
144 GNULIB_RINT=0; AC_SUBST([GNULIB_RINT])
145 GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF])
146 GNULIB_RINTL=0; AC_SUBST([GNULIB_RINTL])
147 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
148 GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
149 GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
150 GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT])
151 GNULIB_SINF=0; AC_SUBST([GNULIB_SINF])
152 GNULIB_SINL=0; AC_SUBST([GNULIB_SINL])
153 GNULIB_SINHF=0; AC_SUBST([GNULIB_SINHF])
154 GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF])
155 GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL])
156 GNULIB_TANF=0; AC_SUBST([GNULIB_TANF])
157 GNULIB_TANL=0; AC_SUBST([GNULIB_TANL])
158 GNULIB_TANHF=0; AC_SUBST([GNULIB_TANHF])
159 GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC])
160 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF])
161 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL])
162 dnl Assume proper GNU behavior unless another module says otherwise. 184 dnl Assume proper GNU behavior unless another module says otherwise.
163 HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF]) 185 HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF])
164 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL]) 186 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL])
165 HAVE_ASINF=1; AC_SUBST([HAVE_ASINF]) 187 HAVE_ASINF=1; AC_SUBST([HAVE_ASINF])
166 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL]) 188 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
167 HAVE_ATANF=1; AC_SUBST([HAVE_ATANF]) 189 HAVE_ATANF=1; AC_SUBST([HAVE_ATANF])
168 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL]) 190 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
169 HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F]) 191 HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F])
170 HAVE_CBRT=1; AC_SUBST([HAVE_CBRT]) 192 HAVE_CBRT=1; AC_SUBST([HAVE_CBRT])
171 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF]) 193 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF])
172 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL]) 194 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL])
173 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN]) 195 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN])
174 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL]) 196 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL])
175 HAVE_COSF=1; AC_SUBST([HAVE_COSF]) 197 HAVE_COSF=1; AC_SUBST([HAVE_COSF])
176 HAVE_COSL=1; AC_SUBST([HAVE_COSL]) 198 HAVE_COSL=1; AC_SUBST([HAVE_COSL])
177 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF]) 199 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF])
178 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF]) 200 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF])
179 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL]) 201 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
180 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1]) 202 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1])
181 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F]) 203 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F])
182 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF]) 204 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF])
183 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL]) 205 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL])
184 HAVE_FMA=1; AC_SUBST([HAVE_FMA]) 206 HAVE_FMA=1; AC_SUBST([HAVE_FMA])
185 HAVE_FMAF=1; AC_SUBST([HAVE_FMAF]) 207 HAVE_FMAF=1; AC_SUBST([HAVE_FMAF])
186 HAVE_FMAL=1; AC_SUBST([HAVE_FMAL]) 208 HAVE_FMAL=1; AC_SUBST([HAVE_FMAL])
187 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF]) 209 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
188 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL]) 210 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL])
189 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF]) 211 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
190 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF]) 212 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF])
191 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL]) 213 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL])
192 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB]) 214 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB])
193 HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF]) 215 HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF])
194 HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL]) 216 HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL])
195 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF]) 217 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
196 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND]) 218 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
197 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL]) 219 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
198 HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF]) 220 HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF])
199 HAVE_LOGF=1; AC_SUBST([HAVE_LOGF]) 221 HAVE_LOGF=1; AC_SUBST([HAVE_LOGF])
200 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) 222 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL])
201 HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) 223 HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F])
202 HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L]) 224 HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L])
203 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P]) 225 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P])
204 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF]) 226 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF])
205 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL]) 227 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL])
206 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF]) 228 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF])
207 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL]) 229 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL])
208 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) 230 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
209 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) 231 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL])
210 HAVE_POWF=1; AC_SUBST([HAVE_POWF]) 232 HAVE_POWF=1; AC_SUBST([HAVE_POWF])
211 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER]) 233 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER])
212 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF]) 234 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF])
213 HAVE_RINT=1; AC_SUBST([HAVE_RINT]) 235 HAVE_RINT=1; AC_SUBST([HAVE_RINT])
214 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL]) 236 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL])
215 HAVE_SINF=1; AC_SUBST([HAVE_SINF]) 237 HAVE_SINF=1; AC_SUBST([HAVE_SINF])
216 HAVE_SINL=1; AC_SUBST([HAVE_SINL]) 238 HAVE_SINL=1; AC_SUBST([HAVE_SINL])
217 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) 239 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF])
218 HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) 240 HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF])
219 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) 241 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL])
220 HAVE_TANF=1; AC_SUBST([HAVE_TANF]) 242 HAVE_TANF=1; AC_SUBST([HAVE_TANF])
221 HAVE_TANL=1; AC_SUBST([HAVE_TANL]) 243 HAVE_TANL=1; AC_SUBST([HAVE_TANL])
222 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF]) 244 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF])
223 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) 245 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
224 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) 246 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
225 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) 247 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
226 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF]) 248 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF])
227 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL]) 249 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL])
228 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) 250 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF])
229 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) 251 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL])
230 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF]) 252 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF])
231 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) 253 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL])
232 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) 254 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL])
233 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2]) 255 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2])
234 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F]) 256 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F])
235 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L]) 257 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L])
236 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L]) 258 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L])
237 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) 259 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF])
238 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) 260 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL])
239 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) 261 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL])
240 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) 262 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL])
241 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) 263 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL])
242 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L]) 264 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L])
243 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2]) 265 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2])
244 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F]) 266 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F])
245 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L]) 267 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L])
246 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) 268 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB])
247 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER]) 269 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER])
248 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL]) 270 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL])
249 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF]) 271 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF])
250 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) 272 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND])
251 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) 273 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF])
252 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL]) 274 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL])
253 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) 275 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL])
254 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) 276 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL])
255 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) 277 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
256 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) 278 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC])
257 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) 279 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF])
258 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) 280 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL])
259 REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF]) 281 REPLACE_ACOSF=0; AC_SUBST([REPLACE_ACOSF])
260 REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL]) 282 REPLACE_ASINF=0; AC_SUBST([REPLACE_ASINF])
261 REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) 283 REPLACE_ATANF=0; AC_SUBST([REPLACE_ATANF])
262 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) 284 REPLACE_ATAN2F=0; AC_SUBST([REPLACE_ATAN2F])
263 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) 285 REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF])
264 REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1]) 286 REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL])
265 REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F]) 287 REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL])
266 REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2]) 288 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF])
267 REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L]) 289 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL])
268 REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL]) 290 REPLACE_COSF=0; AC_SUBST([REPLACE_COSF])
269 REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR]) 291 REPLACE_COSHF=0; AC_SUBST([REPLACE_COSHF])
270 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) 292 REPLACE_EXPF=0; AC_SUBST([REPLACE_EXPF])
271 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) 293 REPLACE_EXPL=0; AC_SUBST([REPLACE_EXPL])
272 REPLACE_FMA=0; AC_SUBST([REPLACE_FMA]) 294 REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1])
273 REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF]) 295 REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F])
274 REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL]) 296 REPLACE_EXPM1L=0; AC_SUBST([REPLACE_EXPM1L])
275 REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD]) 297 REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2])
276 REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF]) 298 REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L])
277 REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL]) 299 REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL])
278 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF]) 300 REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR])
279 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) 301 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF])
280 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) 302 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL])
281 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) 303 REPLACE_FMA=0; AC_SUBST([REPLACE_FMA])
282 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT]) 304 REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF])
283 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF]) 305 REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL])
284 REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL]) 306 REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD])
285 REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB]) 307 REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF])
286 REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF]) 308 REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL])
287 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) 309 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF])
288 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) 310 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
289 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) 311 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
290 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) 312 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
291 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) 313 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT])
292 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) 314 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF])
293 REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) 315 REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL])
294 REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10]) 316 REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB])
295 REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F]) 317 REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF])
296 REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L]) 318 REPLACE_ILOGBL=0; AC_SUBST([REPLACE_ILOGBL])
297 REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P]) 319 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
298 REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) 320 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
299 REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL]) 321 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
300 REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2]) 322 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
301 REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F]) 323 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG])
302 REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L]) 324 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF])
303 REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB]) 325 REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL])
304 REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF]) 326 REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10])
305 REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL]) 327 REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F])
306 REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) 328 REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L])
307 REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) 329 REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P])
308 REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL]) 330 REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF])
309 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) 331 REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL])
310 REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER]) 332 REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2])
311 REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF]) 333 REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F])
312 REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL]) 334 REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L])
313 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) 335 REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB])
314 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) 336 REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF])
315 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) 337 REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL])
316 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) 338 REPLACE_MODF=0; AC_SUBST([REPLACE_MODF])
317 REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) 339 REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF])
318 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) 340 REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL])
319 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) 341 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN])
320 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) 342 REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER])
321 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) 343 REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF])
344 REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL])
345 REPLACE_RINTL=0; AC_SUBST([REPLACE_RINTL])
346 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND])
347 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF])
348 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL])
349 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT])
350 REPLACE_SIGNBIT_USING_BUILTINS=0; AC_SUBST([REPLACE_SIGNBIT_USING_BUILTINS])
351 REPLACE_SINF=0; AC_SUBST([REPLACE_SINF])
352 REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF])
353 REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF])
354 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL])
355 REPLACE_TANF=0; AC_SUBST([REPLACE_TANF])
356 REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF])
357 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC])
358 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF])
359 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL])
322]) 360])
323 361
324# gl_LONG_DOUBLE_VS_DOUBLE 362# gl_LONG_DOUBLE_VS_DOUBLE
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
index 4c9f3886..bb393041 100644
--- a/gl/m4/mbrtowc.m4
+++ b/gl/m4/mbrtowc.m4
@@ -1,5 +1,5 @@
1# mbrtowc.m4 serial 25 1# mbrtowc.m4 serial 38 -*- coding: utf-8 -*-
2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation, 2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,8 @@ dnl with or without modifications, as long as this notice is preserved.
8AC_DEFUN([gl_FUNC_MBRTOWC], 8AC_DEFUN([gl_FUNC_MBRTOWC],
9[ 9[
10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 AC_REQUIRE([gl_PTHREADLIB])
12 AC_CHECK_HEADERS_ONCE([threads.h])
11 13
12 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 14 AC_REQUIRE([AC_TYPE_MBSTATE_T])
13 gl_MBSTATE_T_BROKEN 15 gl_MBSTATE_T_BROKEN
@@ -16,15 +18,8 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
16 if test $ac_cv_func_mbrtowc = no; then 18 if test $ac_cv_func_mbrtowc = no; then
17 HAVE_MBRTOWC=0 19 HAVE_MBRTOWC=0
18 AC_CHECK_DECLS([mbrtowc],,, [[ 20 AC_CHECK_DECLS([mbrtowc],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 21 #include <wchar.h>
20 <wchar.h>. 22 ]])
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbrtowc = yes; then 23 if test $ac_cv_have_decl_mbrtowc = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although 24 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although
30 dnl it does not have the function. Avoid a collision with gnulib's 25 dnl it does not have the function. Avoid a collision with gnulib's
@@ -39,6 +34,9 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
39 gl_MBRTOWC_NULL_ARG2 34 gl_MBRTOWC_NULL_ARG2
40 gl_MBRTOWC_RETVAL 35 gl_MBRTOWC_RETVAL
41 gl_MBRTOWC_NUL_RETVAL 36 gl_MBRTOWC_NUL_RETVAL
37 gl_MBRTOWC_STORES_INCOMPLETE
38 gl_MBRTOWC_EMPTY_INPUT
39 gl_MBRTOWC_C_LOCALE
42 case "$gl_cv_func_mbrtowc_null_arg1" in 40 case "$gl_cv_func_mbrtowc_null_arg1" in
43 *yes) ;; 41 *yes) ;;
44 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], 42 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
@@ -67,8 +65,47 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
67 REPLACE_MBRTOWC=1 65 REPLACE_MBRTOWC=1
68 ;; 66 ;;
69 esac 67 esac
68 case "$gl_cv_func_mbrtowc_stores_incomplete" in
69 *no) ;;
70 *) AC_DEFINE([MBRTOWC_STORES_INCOMPLETE_BUG], [1],
71 [Define if the mbrtowc function stores a wide character when reporting incomplete input.])
72 REPLACE_MBRTOWC=1
73 ;;
74 esac
75 case "$gl_cv_func_mbrtowc_empty_input" in
76 *yes) ;;
77 *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1],
78 [Define if the mbrtowc function does not return (size_t) -2
79 for empty input.])
80 REPLACE_MBRTOWC=1
81 ;;
82 esac
83 case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
84 *yes) ;;
85 *) AC_DEFINE([MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ], [1],
86 [Define if the mbrtowc function may signal encoding errors in the C locale.])
87 REPLACE_MBRTOWC=1
88 ;;
89 esac
70 fi 90 fi
71 fi 91 fi
92 if test $REPLACE_MBSTATE_T = 1; then
93 case "$host_os" in
94 mingw*) LIB_MBRTOWC= ;;
95 *)
96 gl_WEAK_SYMBOLS
97 case "$gl_cv_have_weak" in
98 *yes) LIB_MBRTOWC= ;;
99 *) LIB_MBRTOWC="$LIBPTHREAD" ;;
100 esac
101 ;;
102 esac
103 else
104 LIB_MBRTOWC=
105 fi
106 dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX
107 dnl with gcc or xlc, and empty otherwise.
108 AC_SUBST([LIB_MBRTOWC])
72]) 109])
73 110
74dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that 111dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
@@ -80,11 +117,19 @@ dnl avoid inconsistencies.
80AC_DEFUN([gl_MBSTATE_T_BROKEN], 117AC_DEFUN([gl_MBSTATE_T_BROKEN],
81[ 118[
82 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 119 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
120 AC_REQUIRE([AC_CANONICAL_HOST])
83 121
84 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 122 AC_REQUIRE([AC_TYPE_MBSTATE_T])
85 AC_CHECK_FUNCS_ONCE([mbsinit]) 123 AC_CHECK_FUNCS_ONCE([mbsinit])
86 AC_CHECK_FUNCS_ONCE([mbrtowc]) 124 AC_CHECK_FUNCS_ONCE([mbrtowc])
87 if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then 125 dnl On native Windows, we know exactly how mbsinit() behaves and don't need
126 dnl to override it, even if - like on MSVC - mbsinit() is only defined as
127 dnl an inline function, not as a global function.
128 if case "$host_os" in
129 mingw*) true ;;
130 *) test $ac_cv_func_mbsinit = yes ;;
131 esac \
132 && test $ac_cv_func_mbrtowc = yes; then
88 gl_MBRTOWC_INCOMPLETE_STATE 133 gl_MBRTOWC_INCOMPLETE_STATE
89 gl_MBRTOWC_SANITYCHECK 134 gl_MBRTOWC_SANITYCHECK
90 REPLACE_MBSTATE_T=0 135 REPLACE_MBSTATE_T=0
@@ -109,6 +154,7 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
109[ 154[
110 AC_REQUIRE([AC_PROG_CC]) 155 AC_REQUIRE([AC_PROG_CC])
111 AC_REQUIRE([gt_LOCALE_JA]) 156 AC_REQUIRE([gt_LOCALE_JA])
157 AC_REQUIRE([gt_LOCALE_FR_UTF8])
112 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 158 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
113 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], 159 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
114 [gl_cv_func_mbrtowc_incomplete_state], 160 [gl_cv_func_mbrtowc_incomplete_state],
@@ -128,13 +174,6 @@ changequote([,])dnl
128 [AC_LANG_SOURCE([[ 174 [AC_LANG_SOURCE([[
129#include <locale.h> 175#include <locale.h>
130#include <string.h> 176#include <string.h>
131/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
132 <wchar.h>.
133 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
134 included before <wchar.h>. */
135#include <stddef.h>
136#include <stdio.h>
137#include <time.h>
138#include <wchar.h> 177#include <wchar.h>
139int main () 178int main ()
140{ 179{
@@ -147,13 +186,39 @@ int main ()
147 memset (&state, '\0', sizeof (mbstate_t)); 186 memset (&state, '\0', sizeof (mbstate_t));
148 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) 187 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
149 if (mbsinit (&state)) 188 if (mbsinit (&state))
150 return 1; 189 return 2;
190 }
191 return 0;
192}]])],
193 [gl_cv_func_mbrtowc_incomplete_state=yes],
194 [gl_cv_func_mbrtowc_incomplete_state=no],
195 [:])
196 else
197 if test $LOCALE_FR_UTF8 != none; then
198 AC_RUN_IFELSE(
199 [AC_LANG_SOURCE([[
200#include <locale.h>
201#include <string.h>
202#include <wchar.h>
203int main ()
204{
205 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
206 {
207 const char input[] = "B\303\274\303\237er"; /* "Büßer" */
208 mbstate_t state;
209 wchar_t wc;
210
211 memset (&state, '\0', sizeof (mbstate_t));
212 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
213 if (mbsinit (&state))
214 return 2;
151 } 215 }
152 return 0; 216 return 0;
153}]])], 217}]])],
154 [gl_cv_func_mbrtowc_incomplete_state=yes], 218 [gl_cv_func_mbrtowc_incomplete_state=yes],
155 [gl_cv_func_mbrtowc_incomplete_state=no], 219 [gl_cv_func_mbrtowc_incomplete_state=no],
156 [:]) 220 [:])
221 fi
157 fi 222 fi
158 ]) 223 ])
159]) 224])
@@ -185,13 +250,6 @@ changequote([,])dnl
185#include <locale.h> 250#include <locale.h>
186#include <stdlib.h> 251#include <stdlib.h>
187#include <string.h> 252#include <string.h>
188/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
189 <wchar.h>.
190 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
191 included before <wchar.h>. */
192#include <stddef.h>
193#include <stdio.h>
194#include <time.h>
195#include <wchar.h> 253#include <wchar.h>
196int main () 254int main ()
197{ 255{
@@ -207,7 +265,7 @@ int main ()
207 memset (&state, '\0', sizeof (mbstate_t)); 265 memset (&state, '\0', sizeof (mbstate_t));
208 if (mbrtowc (&wc, input + 3, 6, &state) != 4 266 if (mbrtowc (&wc, input + 3, 6, &state) != 4
209 && mbtowc (&wc, input + 3, 6) == 4) 267 && mbtowc (&wc, input + 3, 6) == 4)
210 return 1; 268 return 2;
211 } 269 }
212 return 0; 270 return 0;
213}]])], 271}]])],
@@ -245,13 +303,6 @@ changequote([,])dnl
245#include <locale.h> 303#include <locale.h>
246#include <stdlib.h> 304#include <stdlib.h>
247#include <string.h> 305#include <string.h>
248/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
249 <wchar.h>.
250 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
251 included before <wchar.h>. */
252#include <stddef.h>
253#include <stdio.h>
254#include <time.h>
255#include <wchar.h> 306#include <wchar.h>
256int main () 307int main ()
257{ 308{
@@ -314,13 +365,6 @@ changequote([,])dnl
314 [AC_LANG_SOURCE([[ 365 [AC_LANG_SOURCE([[
315#include <locale.h> 366#include <locale.h>
316#include <string.h> 367#include <string.h>
317/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
318 <wchar.h>.
319 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
320 included before <wchar.h>. */
321#include <stddef.h>
322#include <stdio.h>
323#include <time.h>
324#include <wchar.h> 368#include <wchar.h>
325int main () 369int main ()
326{ 370{
@@ -335,7 +379,7 @@ int main ()
335 mbrtowc (&wc, NULL, 5, &state); 379 mbrtowc (&wc, NULL, 5, &state);
336 /* Check that wc was not modified. */ 380 /* Check that wc was not modified. */
337 if (wc != (wchar_t) 0xBADFACE) 381 if (wc != (wchar_t) 0xBADFACE)
338 return 1; 382 return 2;
339 } 383 }
340 return 0; 384 return 0;
341}]])], 385}]])],
@@ -376,13 +420,6 @@ changequote([,])dnl
376 [AC_LANG_SOURCE([[ 420 [AC_LANG_SOURCE([[
377#include <locale.h> 421#include <locale.h>
378#include <string.h> 422#include <string.h>
379/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
380 <wchar.h>.
381 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
382 included before <wchar.h>. */
383#include <stddef.h>
384#include <stdio.h>
385#include <time.h>
386#include <wchar.h> 423#include <wchar.h>
387int main () 424int main ()
388{ 425{
@@ -504,13 +541,6 @@ changequote([,])dnl
504 [AC_LANG_SOURCE([[ 541 [AC_LANG_SOURCE([[
505#include <locale.h> 542#include <locale.h>
506#include <string.h> 543#include <string.h>
507/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
508 <wchar.h>.
509 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
510 included before <wchar.h>. */
511#include <stddef.h>
512#include <stdio.h>
513#include <time.h>
514#include <wchar.h> 544#include <wchar.h>
515int main () 545int main ()
516{ 546{
@@ -522,7 +552,7 @@ int main ()
522 552
523 memset (&state, '\0', sizeof (mbstate_t)); 553 memset (&state, '\0', sizeof (mbstate_t));
524 if (mbrtowc (&wc, "", 1, &state) != 0) 554 if (mbrtowc (&wc, "", 1, &state) != 0)
525 return 1; 555 return 2;
526 } 556 }
527 return 0; 557 return 0;
528}]])], 558}]])],
@@ -533,11 +563,206 @@ int main ()
533 ]) 563 ])
534]) 564])
535 565
536# Prerequisites of lib/mbrtowc.c. 566dnl Test whether mbrtowc stores a wide character when reporting incomplete
567dnl input.
568
569AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE],
570[
571 AC_REQUIRE([AC_PROG_CC])
572 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
573 AC_CACHE_CHECK([whether mbrtowc stores incomplete characters],
574 [gl_cv_func_mbrtowc_stores_incomplete],
575 [
576 dnl Initial guess, used when cross-compiling or when no suitable locale
577 dnl is present.
578changequote(,)dnl
579 case "$host_os" in
580 # Guess yes on native Windows.
581 mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;;
582 *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;;
583 esac
584changequote([,])dnl
585 case "$host_os" in
586 mingw*)
587 AC_RUN_IFELSE(
588 [AC_LANG_SOURCE([[
589#include <locale.h>
590#include <string.h>
591#include <wchar.h>
592int main ()
593{
594 int result = 0;
595 if (setlocale (LC_ALL, "French_France.65001") != NULL)
596 {
597 wchar_t wc = (wchar_t) 0xBADFACE;
598 mbstate_t state;
599
600 memset (&state, '\0', sizeof (mbstate_t));
601 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
602 && wc != (wchar_t) 0xBADFACE)
603 result |= 1;
604 }
605 if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
606 {
607 wchar_t wc = (wchar_t) 0xBADFACE;
608 mbstate_t state;
609
610 memset (&state, '\0', sizeof (mbstate_t));
611 if (mbrtowc (&wc, "\226", 1, &state) == (size_t)(-2)
612 && wc != (wchar_t) 0xBADFACE)
613 result |= 2;
614 }
615 if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
616 {
617 wchar_t wc = (wchar_t) 0xBADFACE;
618 mbstate_t state;
619
620 memset (&state, '\0', sizeof (mbstate_t));
621 if (mbrtowc (&wc, "\245", 1, &state) == (size_t)(-2)
622 && wc != (wchar_t) 0xBADFACE)
623 result |= 4;
624 }
625 if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
626 {
627 wchar_t wc = (wchar_t) 0xBADFACE;
628 mbstate_t state;
629
630 memset (&state, '\0', sizeof (mbstate_t));
631 if (mbrtowc (&wc, "\261", 1, &state) == (size_t)(-2)
632 && wc != (wchar_t) 0xBADFACE)
633 result |= 8;
634 }
635 return result;
636}]])],
637 [gl_cv_func_mbrtowc_stores_incomplete=no],
638 [gl_cv_func_mbrtowc_stores_incomplete=yes],
639 [:])
640 ;;
641 *)
642 AC_REQUIRE([gt_LOCALE_FR_UTF8])
643 if test $LOCALE_FR_UTF8 != none; then
644 AC_RUN_IFELSE(
645 [AC_LANG_SOURCE([[
646#include <locale.h>
647#include <string.h>
648#include <wchar.h>
649int main ()
650{
651 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
652 {
653 wchar_t wc = (wchar_t) 0xBADFACE;
654 mbstate_t state;
655
656 memset (&state, '\0', sizeof (mbstate_t));
657 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
658 && wc != (wchar_t) 0xBADFACE)
659 return 1;
660 }
661 return 0;
662}]])],
663 [gl_cv_func_mbrtowc_stores_incomplete=no],
664 [gl_cv_func_mbrtowc_stores_incomplete=yes],
665 [:])
666 fi
667 ;;
668 esac
669 ])
670])
671
672dnl Test whether mbrtowc returns the correct value on empty input.
673
674AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
675[
676 AC_REQUIRE([AC_PROG_CC])
677 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
678 AC_CACHE_CHECK([whether mbrtowc works on empty input],
679 [gl_cv_func_mbrtowc_empty_input],
680 [
681 dnl Initial guess, used when cross-compiling or when no suitable locale
682 dnl is present.
683changequote(,)dnl
684 case "$host_os" in
685 # Guess no on AIX and glibc systems.
686 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
687 # Guess yes on native Windows.
688 mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
689 *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
690 esac
691changequote([,])dnl
692 AC_RUN_IFELSE(
693 [AC_LANG_SOURCE([[
694 #include <wchar.h>
695 static wchar_t wc;
696 static mbstate_t mbs;
697 int
698 main (void)
699 {
700 return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2;
701 }]])],
702 [gl_cv_func_mbrtowc_empty_input=yes],
703 [gl_cv_func_mbrtowc_empty_input=no],
704 [:])
705 ])
706])
707
708dnl Test whether mbrtowc reports encoding errors in the C locale.
709dnl Although POSIX was never intended to allow this, the GNU C Library
710dnl and other implementations do it. See:
711dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932
712
713AC_DEFUN([gl_MBRTOWC_C_LOCALE],
714[
715 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
716 AC_CACHE_CHECK([whether the C locale is free of encoding errors],
717 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ],
718 [
719 dnl Initial guess, used when cross-compiling or when no suitable locale
720 dnl is present.
721 gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal"
722
723 AC_RUN_IFELSE(
724 [AC_LANG_PROGRAM(
725 [[#include <limits.h>
726 #include <locale.h>
727 #include <wchar.h>
728 ]], [[
729 int i;
730 char *locale = setlocale (LC_ALL, "C");
731 if (! locale)
732 return 2;
733 for (i = CHAR_MIN; i <= CHAR_MAX; i++)
734 {
735 char c = i;
736 wchar_t wc;
737 mbstate_t mbs = { 0, };
738 size_t ss = mbrtowc (&wc, &c, 1, &mbs);
739 if (1 < ss)
740 return 3;
741 }
742 return 0;
743 ]])],
744 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes],
745 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no],
746 [case "$host_os" in
747 # Guess yes on native Windows.
748 mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;;
749 esac
750 ])
751 ])
752])
753
754# Prerequisites of lib/mbrtowc.c and lib/lc-charset-dispatch.c.
537AC_DEFUN([gl_PREREQ_MBRTOWC], [ 755AC_DEFUN([gl_PREREQ_MBRTOWC], [
756 AC_REQUIRE([AC_C_INLINE])
538 : 757 :
539]) 758])
540 759
760# Prerequisites of lib/mbtowc-lock.c.
761AC_DEFUN([gl_PREREQ_MBTOWC_LOCK],
762[
763 gl_VISIBILITY
764])
765
541 766
542dnl From Paul Eggert 767dnl From Paul Eggert
543 768
@@ -547,24 +772,17 @@ AC_DEFUN([AC_FUNC_MBRTOWC],
547[ 772[
548 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. 773 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
549 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], 774 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
550 gl_cv_func_mbrtowc, 775 [gl_cv_func_mbrtowc],
551 [AC_LINK_IFELSE( 776 [AC_LINK_IFELSE(
552 [AC_LANG_PROGRAM( 777 [AC_LANG_PROGRAM(
553 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 778 [[#include <wchar.h>]],
554 included before <wchar.h>.
555 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
556 must be included before <wchar.h>. */
557 #include <stddef.h>
558 #include <stdio.h>
559 #include <time.h>
560 #include <wchar.h>]],
561 [[wchar_t wc; 779 [[wchar_t wc;
562 char const s[] = ""; 780 char const s[] = "";
563 size_t n = 1; 781 size_t n = 1;
564 mbstate_t state; 782 mbstate_t state;
565 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], 783 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
566 gl_cv_func_mbrtowc=yes, 784 [gl_cv_func_mbrtowc=yes],
567 gl_cv_func_mbrtowc=no)]) 785 [gl_cv_func_mbrtowc=no])])
568 if test $gl_cv_func_mbrtowc = yes; then 786 if test $gl_cv_func_mbrtowc = yes; then
569 AC_DEFINE([HAVE_MBRTOWC], [1], 787 AC_DEFINE([HAVE_MBRTOWC], [1],
570 [Define to 1 if mbrtowc and mbstate_t are properly declared.]) 788 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4
index 2e6d0921..c388a8b9 100644
--- a/gl/m4/mbsinit.m4
+++ b/gl/m4/mbsinit.m4
@@ -1,5 +1,5 @@
1# mbsinit.m4 serial 8 1# mbsinit.m4 serial 9
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,15 +16,8 @@ AC_DEFUN([gl_FUNC_MBSINIT],
16 if test $ac_cv_func_mbsinit = no; then 16 if test $ac_cv_func_mbsinit = no; then
17 HAVE_MBSINIT=0 17 HAVE_MBSINIT=0
18 AC_CHECK_DECLS([mbsinit],,, [[ 18 AC_CHECK_DECLS([mbsinit],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 19 #include <wchar.h>
20 <wchar.h>. 20 ]])
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbsinit = yes; then 21 if test $ac_cv_have_decl_mbsinit = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although 22 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although
30 dnl it does not have the function. Avoid a collision with gnulib's 23 dnl it does not have the function. Avoid a collision with gnulib's
diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4
index ed001179..dcd66b96 100644
--- a/gl/m4/mbstate_t.m4
+++ b/gl/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
1# mbstate_t.m4 serial 13 1# mbstate_t.m4 serial 14
2dnl Copyright (C) 2000-2002, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -20,14 +20,7 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
20 [AC_COMPILE_IFELSE( 20 [AC_COMPILE_IFELSE(
21 [AC_LANG_PROGRAM( 21 [AC_LANG_PROGRAM(
22 [AC_INCLUDES_DEFAULT[ 22 [AC_INCLUDES_DEFAULT[
23/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 23 #include <wchar.h>]],
24 <wchar.h>.
25 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
26 included before <wchar.h>. */
27#include <stddef.h>
28#include <stdio.h>
29#include <time.h>
30#include <wchar.h>]],
31 [[mbstate_t x; return sizeof x;]])], 24 [[mbstate_t x; return sizeof x;]])],
32 [ac_cv_type_mbstate_t=yes], 25 [ac_cv_type_mbstate_t=yes],
33 [ac_cv_type_mbstate_t=no])]) 26 [ac_cv_type_mbstate_t=no])])
diff --git a/gl/m4/mbtowc.m4 b/gl/m4/mbtowc.m4
index e4794619..7823be0e 100644
--- a/gl/m4/mbtowc.m4
+++ b/gl/m4/mbtowc.m4
@@ -1,5 +1,5 @@
1# mbtowc.m4 serial 2 1# mbtowc.m4 serial 3
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,8 +8,13 @@ AC_DEFUN([gl_FUNC_MBTOWC],
8[ 8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 10
11 if false; then 11 AC_CHECK_FUNCS([mbtowc])
12 REPLACE_MBTOWC=1 12 if test $ac_cv_func_mbtowc = no; then
13 HAVE_MBTOWC=0
14 else
15 if false; then
16 REPLACE_MBTOWC=1
17 fi
13 fi 18 fi
14]) 19])
15 20
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4
index 2d8abe75..4f1aed01 100644
--- a/gl/m4/memchr.m4
+++ b/gl/m4/memchr.m4
@@ -1,35 +1,30 @@
1# memchr.m4 serial 12 1# memchr.m4 serial 18
2dnl Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN_ONCE([gl_FUNC_MEMCHR], 7AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
8[ 8[
9 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
10
9 dnl Check for prerequisites for memory fence checks. 11 dnl Check for prerequisites for memory fence checks.
10 gl_FUNC_MMAP_ANON 12 gl_FUNC_MMAP_ANON
11 AC_CHECK_HEADERS_ONCE([sys/mman.h]) 13 AC_CHECK_HEADERS_ONCE([sys/mman.h])
12 AC_CHECK_FUNCS_ONCE([mprotect]) 14 AC_CHECK_FUNCS_ONCE([mprotect])
13 15
14 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 16 AC_REQUIRE([gl_STRING_H_DEFAULTS])
15 m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ 17 # Detect platform-specific bugs in some versions of glibc:
16 dnl These days, we assume memchr is present. But if support for old 18 # memchr should not dereference anything with length 0
17 dnl platforms is desired: 19 # https://bugzilla.redhat.com/show_bug.cgi?id=499689
18 AC_CHECK_FUNCS_ONCE([memchr]) 20 # memchr should not dereference overestimated length after a match
19 if test $ac_cv_func_memchr = no; then 21 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
20 HAVE_MEMCHR=0 22 # https://sourceware.org/bugzilla/show_bug.cgi?id=10162
21 fi 23 # memchr should cast the second argument to 'unsigned char'.
22 ]) 24 # This bug exists in Android 4.3.
23 if test $HAVE_MEMCHR = 1; then 25 # Assume that memchr works on platforms that lack mprotect.
24 # Detect platform-specific bugs in some versions of glibc: 26 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
25 # memchr should not dereference anything with length 0 27 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
26 # http://bugzilla.redhat.com/499689
27 # memchr should not dereference overestimated length after a match
28 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
29 # http://sourceware.org/bugzilla/show_bug.cgi?id=10162
30 # Assume that memchr works on platforms that lack mprotect.
31 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
32 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
33#include <string.h> 28#include <string.h>
34#if HAVE_SYS_MMAN_H 29#if HAVE_SYS_MMAN_H
35# include <fcntl.h> 30# include <fcntl.h>
@@ -64,6 +59,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
64#endif 59#endif
65 if (fence) 60 if (fence)
66 { 61 {
62 /* Test against bugs on glibc systems. */
67 if (memchr (fence, 0, 0)) 63 if (memchr (fence, 0, 0))
68 result |= 1; 64 result |= 1;
69 strcpy (fence - 9, "12345678"); 65 strcpy (fence - 9, "12345678");
@@ -71,15 +67,37 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
71 result |= 2; 67 result |= 2;
72 if (memchr (fence - 1, 0, 3) != fence - 1) 68 if (memchr (fence - 1, 0, 3) != fence - 1)
73 result |= 4; 69 result |= 4;
70 /* Test against bug on AIX 7.2. */
71 if (memchr (fence - 4, '6', 16) != fence - 4)
72 result |= 8;
74 } 73 }
74 /* Test against bug on Android 4.3. */
75 {
76 char input[3];
77 input[0] = 'a';
78 input[1] = 'b';
79 input[2] = 'c';
80 if (memchr (input, 0x789abc00 | 'b', 3) != input + 1)
81 result |= 16;
82 }
75 return result; 83 return result;
76]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], 84]])],
77 [dnl Be pessimistic for now. 85 [gl_cv_func_memchr_works=yes],
78 gl_cv_func_memchr_works="guessing no"])]) 86 [gl_cv_func_memchr_works=no],
79 if test "$gl_cv_func_memchr_works" != yes; then 87 [case "$host_os" in
80 REPLACE_MEMCHR=1 88 # Guess no on Android.
81 fi 89 linux*-android*) gl_cv_func_memchr_works="guessing no" ;;
82 fi 90 # Guess yes on native Windows.
91 mingw*) gl_cv_func_memchr_works="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses.
93 *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;;
94 esac
95 ])
96 ])
97 case "$gl_cv_func_memchr_works" in
98 *yes) ;;
99 *) REPLACE_MEMCHR=1 ;;
100 esac
83]) 101])
84 102
85# Prerequisites of lib/memchr.c. 103# Prerequisites of lib/memchr.c.
diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4
new file mode 100644
index 00000000..fd09846f
--- /dev/null
+++ b/gl/m4/minmax.m4
@@ -0,0 +1,44 @@
1# minmax.m4 serial 4
2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_PREREQ([2.53])
8
9AC_DEFUN([gl_MINMAX],
10[
11 AC_REQUIRE([gl_PREREQ_MINMAX])
12])
13
14# Prerequisites of lib/minmax.h.
15AC_DEFUN([gl_PREREQ_MINMAX],
16[
17 gl_MINMAX_IN_HEADER([limits.h])
18 gl_MINMAX_IN_HEADER([sys/param.h])
19])
20
21dnl gl_MINMAX_IN_HEADER(HEADER)
22dnl The parameter has to be a literal header name; it cannot be macro,
23dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
24dnl invocations with a literal macro name.)
25AC_DEFUN([gl_MINMAX_IN_HEADER],
26[
27 m4_pushdef([header], AS_TR_SH([$1]))
28 m4_pushdef([HEADER], AS_TR_CPP([$1]))
29 AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
30 [gl_cv_minmax_in_]header,
31 [AC_COMPILE_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[#include <$1>
34 int x = MIN (42, 17);]],
35 [[]])],
36 [gl_cv_minmax_in_]header[=yes],
37 [gl_cv_minmax_in_]header[=no])])
38 if test $gl_cv_minmax_in_[]header = yes; then
39 AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
40 [Define to 1 if <$1> defines the MIN and MAX macros.])
41 fi
42 m4_popdef([HEADER])
43 m4_popdef([header])
44])
diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4
index faefb770..e9d31f35 100644
--- a/gl/m4/mktime.m4
+++ b/gl/m4/mktime.m4
@@ -1,5 +1,5 @@
1# serial 25 1# serial 37
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -7,24 +7,40 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl From Jim Meyering. 8dnl From Jim Meyering.
9 9
10AC_DEFUN([gl_FUNC_MKTIME], 10AC_DEFUN([gl_TIME_T_IS_SIGNED],
11[
12 AC_CACHE_CHECK([whether time_t is signed],
13 [gl_cv_time_t_is_signed],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM([[#include <time.h>
16 char time_t_signed[(time_t) -1 < 0 ? 1 : -1];]])],
17 [gl_cv_time_t_is_signed=yes],
18 [gl_cv_time_t_is_signed=no])])
19 if test $gl_cv_time_t_is_signed = yes; then
20 AC_DEFINE([TIME_T_IS_SIGNED], [1], [Define to 1 if time_t is signed.])
21 fi
22])
23
24dnl Test whether mktime works. Set gl_cv_func_working_mktime.
25AC_DEFUN([gl_FUNC_MKTIME_WORKS],
11[ 26[
12 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 27 AC_REQUIRE([gl_TIME_T_IS_SIGNED])
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 29
14 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained 30 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained
15 dnl in Autoconf and because it invokes AC_LIBOBJ. 31 dnl in Autoconf and because it invokes AC_LIBOBJ.
16 AC_CHECK_HEADERS_ONCE([unistd.h]) 32 AC_CHECK_HEADERS_ONCE([unistd.h])
17 AC_CHECK_DECLS_ONCE([alarm]) 33 AC_CHECK_DECLS_ONCE([alarm])
18 AC_REQUIRE([gl_MULTIARCH]) 34 AC_REQUIRE([gl_MULTIARCH])
19 if test $APPLE_UNIVERSAL_BUILD = 1; then
20 # A universal build on Apple Mac OS X platforms.
21 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
22 # But we need a configuration result that is valid in both modes.
23 gl_cv_func_working_mktime=no
24 fi
25 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime], 35 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime],
26 [AC_RUN_IFELSE( 36 [if test $APPLE_UNIVERSAL_BUILD = 1; then
27 [AC_LANG_SOURCE( 37 # A universal build on Apple Mac OS X platforms.
38 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
39 # But we need a configuration result that is valid in both modes.
40 gl_cv_func_working_mktime="guessing no"
41 else
42 AC_RUN_IFELSE(
43 [AC_LANG_SOURCE(
28[[/* Test program from Paul Eggert and Tony Leneis. */ 44[[/* Test program from Paul Eggert and Tony Leneis. */
29#include <limits.h> 45#include <limits.h>
30#include <stdlib.h> 46#include <stdlib.h>
@@ -38,8 +54,11 @@ AC_DEFUN([gl_FUNC_MKTIME],
38# include <signal.h> 54# include <signal.h>
39#endif 55#endif
40 56
41/* Work around redefinition to rpl_putenv by other config tests. */ 57]GL_MDA_DEFINES[
42#undef putenv 58
59#ifndef TIME_T_IS_SIGNED
60# define TIME_T_IS_SIGNED 0
61#endif
43 62
44static time_t time_t_max; 63static time_t time_t_max;
45static time_t time_t_min; 64static time_t time_t_min;
@@ -63,7 +82,8 @@ spring_forward_gap ()
63 instead of "TZ=America/Vancouver" in order to detect the bug even 82 instead of "TZ=America/Vancouver" in order to detect the bug even
64 on systems that don't support the Olson extension, or don't have the 83 on systems that don't support the Olson extension, or don't have the
65 full zoneinfo tables installed. */ 84 full zoneinfo tables installed. */
66 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); 85 if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
86 return -1;
67 87
68 tm.tm_year = 98; 88 tm.tm_year = 98;
69 tm.tm_mon = 3; 89 tm.tm_mon = 3;
@@ -151,7 +171,8 @@ year_2050_test ()
151 instead of "TZ=America/Vancouver" in order to detect the bug even 171 instead of "TZ=America/Vancouver" in order to detect the bug even
152 on systems that don't support the Olson extension, or don't have the 172 on systems that don't support the Olson extension, or don't have the
153 full zoneinfo tables installed. */ 173 full zoneinfo tables installed. */
154 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); 174 if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
175 return -1;
155 176
156 t = mktime (&tm); 177 t = mktime (&tm);
157 178
@@ -162,6 +183,25 @@ year_2050_test ()
162 || (0 < t && answer - 120 <= t && t <= answer + 120)); 183 || (0 < t && answer - 120 <= t && t <= answer + 120));
163} 184}
164 185
186static int
187indiana_test ()
188{
189 if (putenv ("TZ=America/Indiana/Indianapolis") != 0)
190 return -1;
191 struct tm tm;
192 tm.tm_year = 1986 - 1900; tm.tm_mon = 4 - 1; tm.tm_mday = 28;
193 tm.tm_hour = 16; tm.tm_min = 24; tm.tm_sec = 50; tm.tm_isdst = 0;
194 time_t std = mktime (&tm);
195 if (! (std == 515107490 || std == 515107503))
196 return 1;
197
198 /* This platform supports TZDB, either without or with leap seconds.
199 Return true if GNU Bug#48085 is absent. */
200 tm.tm_isdst = 1;
201 time_t dst = mktime (&tm);
202 return std - dst == 60 * 60;
203}
204
165int 205int
166main () 206main ()
167{ 207{
@@ -169,7 +209,6 @@ main ()
169 time_t t, delta; 209 time_t t, delta;
170 int i, j; 210 int i, j;
171 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1; 211 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1;
172 int time_t_signed = ! ((time_t) 0 < (time_t) -1);
173 212
174#if HAVE_DECL_ALARM 213#if HAVE_DECL_ALARM
175 /* This test makes some buggy mktime implementations loop. 214 /* This test makes some buggy mktime implementations loop.
@@ -179,11 +218,11 @@ main ()
179 alarm (60); 218 alarm (60);
180#endif 219#endif
181 220
182 time_t_max = (! time_t_signed 221 time_t_max = (! TIME_T_IS_SIGNED
183 ? (time_t) -1 222 ? (time_t) -1
184 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1) 223 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)
185 * 2 + 1)); 224 * 2 + 1));
186 time_t_min = (! time_t_signed 225 time_t_min = (! TIME_T_IS_SIGNED
187 ? (time_t) 0 226 ? (time_t) 0
188 : time_t_signed_magnitude 227 : time_t_signed_magnitude
189 ? ~ (time_t) 0 228 ? ~ (time_t) 0
@@ -218,35 +257,62 @@ main ()
218 result |= 16; 257 result |= 16;
219 if (! spring_forward_gap ()) 258 if (! spring_forward_gap ())
220 result |= 32; 259 result |= 32;
221 if (! year_2050_test ()) 260 if (! year_2050_test () || ! indiana_test ())
222 result |= 64; 261 result |= 64;
223 return result; 262 return result;
224}]])], 263}]])],
225 [gl_cv_func_working_mktime=yes], 264 [gl_cv_func_working_mktime=yes],
226 [gl_cv_func_working_mktime=no], 265 [gl_cv_func_working_mktime=no],
227 [gl_cv_func_working_mktime=no]) 266 [case "$host_os" in
267 # Guess no on native Windows.
268 mingw*) gl_cv_func_working_mktime="guessing no" ;;
269 *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;;
270 esac
271 ])
272 fi
228 ]) 273 ])
274])
275
276dnl Main macro of module 'mktime'.
277AC_DEFUN([gl_FUNC_MKTIME],
278[
279 AC_REQUIRE([gl_TIME_H_DEFAULTS])
280 AC_REQUIRE([AC_CANONICAL_HOST])
281 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
229 282
230 if test $gl_cv_func_working_mktime = no; then 283 REPLACE_MKTIME=0
284 if test "$gl_cv_func_working_mktime" != yes; then
231 REPLACE_MKTIME=1 285 REPLACE_MKTIME=1
232 else 286 AC_DEFINE([NEED_MKTIME_WORKING], [1],
233 REPLACE_MKTIME=0 287 [Define if the compilation of mktime.c should define 'mktime'
288 with the algorithmic workarounds.])
234 fi 289 fi
290 case "$host_os" in
291 mingw*)
292 REPLACE_MKTIME=1
293 AC_DEFINE([NEED_MKTIME_WINDOWS], [1],
294 [Define if the compilation of mktime.c should define 'mktime'
295 with the native Windows TZ workaround.])
296 ;;
297 esac
235]) 298])
236 299
300dnl Main macro of module 'mktime-internal'.
237AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [ 301AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [
238 AC_REQUIRE([gl_FUNC_MKTIME]) 302 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
239 if test $REPLACE_MKTIME = 0; then 303
240 dnl BeOS has __mktime_internal in libc, but other platforms don't. 304 WANT_MKTIME_INTERNAL=0
241 AC_CHECK_FUNC([__mktime_internal], 305 dnl BeOS has __mktime_internal in libc, but other platforms don't.
242 [AC_DEFINE([mktime_internal], [__mktime_internal], 306 AC_CHECK_FUNC([__mktime_internal],
243 [Define to the real name of the mktime_internal function.]) 307 [AC_DEFINE([mktime_internal], [__mktime_internal],
244 ], 308 [Define to the real name of the mktime_internal function.])
245 [dnl mktime works but it doesn't export __mktime_internal, 309 ],
246 dnl so we need to substitute our own mktime implementation. 310 [dnl mktime works but it doesn't export __mktime_internal,
247 REPLACE_MKTIME=1 311 dnl so we need to substitute our own mktime implementation.
248 ]) 312 WANT_MKTIME_INTERNAL=1
249 fi 313 AC_DEFINE([NEED_MKTIME_INTERNAL], [1],
314 [Define if the compilation of mktime.c should define 'mktime_internal'.])
315 ])
250]) 316])
251 317
252# Prerequisites of lib/mktime.c. 318# Prerequisites of lib/mktime.c.
diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4
index 9b60ddfa..d07d26e4 100644
--- a/gl/m4/mmap-anon.m4
+++ b/gl/m4/mmap-anon.m4
@@ -1,5 +1,5 @@
1# mmap-anon.m4 serial 10 1# mmap-anon.m4 serial 12
2dnl Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,11 +9,11 @@ dnl with or without modifications, as long as this notice is preserved.
9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS 9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
10# and MAP_ANON exist and have the same value. 10# and MAP_ANON exist and have the same value.
11# - On HP-UX, only MAP_ANONYMOUS exists. 11# - On HP-UX, only MAP_ANONYMOUS exists.
12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists. 12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, only MAP_ANON exists.
13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be 13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
14# used. 14# used.
15 15
16AC_DEFUN([gl_FUNC_MMAP_ANON], 16AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON],
17[ 17[
18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS. 18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
diff --git a/gl/m4/mode_t.m4 b/gl/m4/mode_t.m4
new file mode 100644
index 00000000..82197c02
--- /dev/null
+++ b/gl/m4/mode_t.m4
@@ -0,0 +1,26 @@
1# mode_t.m4 serial 2
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and
8# include <sys/types.h>.
9
10# Define PROMOTED_MODE_T to the type that is the result of "default argument
11# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t.
12AC_DEFUN([gl_PROMOTED_TYPE_MODE_T],
13[
14 AC_REQUIRE([AC_TYPE_MODE_T])
15 AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [
16 dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int',
17 dnl and to itself otherwise. This assumption is not guaranteed by the ISO C
18 dnl standard, but we don't know of any real-world counterexamples.
19 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
20 [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])],
21 [gl_cv_promoted_mode_t='int'],
22 [gl_cv_promoted_mode_t='mode_t'])
23 ])
24 AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t],
25 [Define to the type that is the result of default argument promotions of type mode_t.])
26])
diff --git a/gl/m4/mountlist.m4 b/gl/m4/mountlist.m4
index cd137c91..a9b4edb9 100644
--- a/gl/m4/mountlist.m4
+++ b/gl/m4/mountlist.m4
@@ -1,19 +1,338 @@
1# serial 11 1# serial 15
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Jim Meyering.
8
9AC_PREREQ([2.60])
10
7AC_DEFUN([gl_MOUNTLIST], 11AC_DEFUN([gl_MOUNTLIST],
8[ 12[
9 gl_LIST_MOUNTED_FILE_SYSTEMS([gl_cv_list_mounted_fs=yes], 13 AC_REQUIRE([AC_CANONICAL_HOST])
10 [gl_cv_list_mounted_fs=no]) 14 AC_CHECK_FUNCS([listmntent])
15 AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
16
17 # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
18 # NGROUPS (as the array dimension for a struct member) without a definition.
19 AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
20
21 AC_CHECK_HEADERS([sys/mount.h], [], [],
22 [AC_INCLUDES_DEFAULT
23 [#if HAVE_SYS_PARAM_H
24 #include <sys/param.h>
25 #endif
26 ]])
27
28 AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
29 getfsstat_includes="\
30$ac_includes_default
31#if HAVE_SYS_PARAM_H
32# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
33#endif
34#if HAVE_SYS_UCRED_H
35# include <grp.h> /* needed for definition of NGROUPS */
36# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
37#endif
38#if HAVE_SYS_MOUNT_H
39# include <sys/mount.h>
40#endif
41#if HAVE_SYS_FS_TYPES_H
42# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
43#endif
44"
45 AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
46
47 # Determine how to get the list of mounted file systems.
48 ac_list_mounted_fs=
49
50 # If the getmntent function is available but not in the standard library,
51 # make sure LIBS contains the appropriate -l option.
52 AC_FUNC_GETMNTENT
53
54 if test -z "$ac_list_mounted_fs"; then
55 # AIX.
56 AC_CACHE_CHECK([for mntctl function and struct vmount],
57 [fu_cv_sys_mounted_vmount],
58 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <fshelp.h>]])],
59 [fu_cv_sys_mounted_vmount=yes],
60 [fu_cv_sys_mounted_vmount=no])])
61 if test $fu_cv_sys_mounted_vmount = yes; then
62 ac_list_mounted_fs=found
63 AC_DEFINE([MOUNTED_VMOUNT], [1],
64 [Define if there is a function named mntctl that can be used to read
65 the list of mounted file systems, and there is a system header file
66 that declares 'struct vmount'. (AIX)])
67 fi
68 fi
69
70 if test $ac_cv_func_getmntent = yes; then
71
72 # This system has the getmntent function.
73 # Determine whether it's the one-argument variant or the two-argument one.
74
75 if test -z "$ac_list_mounted_fs"; then
76 # glibc, HP-UX, IRIX, Cygwin, Android, also (obsolete) 4.3BSD, SunOS.
77 AC_CACHE_CHECK([for one-argument getmntent function],
78 [fu_cv_sys_mounted_getmntent1],
79 [AC_COMPILE_IFELSE(
80 [AC_LANG_PROGRAM([[
81/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
82#include <stdio.h>
83
84#include <mntent.h>
85#if defined __ANDROID__ /* Android */
86# undef MOUNTED
87# define MOUNTED "/proc/mounts"
88#elif !defined MOUNTED
89# if defined _PATH_MOUNTED /* GNU libc */
90# define MOUNTED _PATH_MOUNTED
91# endif
92# if defined MNT_MNTTAB /* HP-UX. */
93# define MOUNTED MNT_MNTTAB
94# endif
95#endif
96]],
97 [[struct mntent *mnt = 0; char *table = MOUNTED;
98 if (sizeof mnt && sizeof table) return 0;
99 ]])],
100 [fu_cv_sys_mounted_getmntent1=yes],
101 [fu_cv_sys_mounted_getmntent1=no])
102 ])
103 if test $fu_cv_sys_mounted_getmntent1 = yes; then
104 ac_list_mounted_fs=found
105 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
106 [Define if there is a function named getmntent for reading the list
107 of mounted file systems, and that function takes a single argument.
108 (4.3BSD, SunOS, HP-UX, Irix)])
109 AC_CHECK_FUNCS([setmntent endmntent hasmntopt])
110 fi
111 fi
112
113 if test -z "$ac_list_mounted_fs"; then
114 # Solaris >= 8.
115 AC_CACHE_CHECK([for getextmntent function],
116 [fu_cv_sys_mounted_getextmntent],
117 [AC_EGREP_HEADER([getextmntent], [sys/mnttab.h],
118 [fu_cv_sys_mounted_getextmntent=yes],
119 [fu_cv_sys_mounted_getextmntent=no])])
120 if test $fu_cv_sys_mounted_getextmntent = yes; then
121 ac_list_mounted_fs=found
122 AC_DEFINE([MOUNTED_GETEXTMNTENT], [1],
123 [Define if there is a function named getextmntent for reading the list
124 of mounted file systems. (Solaris)])
125 fi
126 fi
127
128 if test -z "$ac_list_mounted_fs"; then
129 # Solaris < 8, also (obsolete) SVR4.
130 # Solaris >= 8 has the two-argument getmntent but is already handled above.
131 AC_CACHE_CHECK([for two-argument getmntent function],
132 [fu_cv_sys_mounted_getmntent2],
133 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
134 [fu_cv_sys_mounted_getmntent2=yes],
135 [fu_cv_sys_mounted_getmntent2=no])
136 ])
137 if test $fu_cv_sys_mounted_getmntent2 = yes; then
138 ac_list_mounted_fs=found
139 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
140 [Define if there is a function named getmntent for reading the list of
141 mounted file systems, and that function takes two arguments. (SVR4)])
142 AC_CHECK_FUNCS([hasmntopt])
143 fi
144 fi
145
146 fi
147
148 if test -z "$ac_list_mounted_fs"; then
149 # OSF/1, also (obsolete) Apple Darwin 1.3.
150 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
151
152 AC_CACHE_CHECK([for getfsstat function],
153 [fu_cv_sys_mounted_getfsstat],
154 [AC_LINK_IFELSE(
155 [AC_LANG_PROGRAM([[
156#include <sys/types.h>
157#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
158# define FS_TYPE(Ent) ((Ent).f_fstypename)
159#else
160# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
161#endif
162$getfsstat_includes
163 ]],
164 [[struct statfs *stats;
165 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
166 char *t = FS_TYPE (*stats);
167 ]])],
168 [fu_cv_sys_mounted_getfsstat=yes],
169 [fu_cv_sys_mounted_getfsstat=no])
170 ])
171 if test $fu_cv_sys_mounted_getfsstat = yes; then
172 ac_list_mounted_fs=found
173 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
174 [Define if there is a function named getfsstat for reading the
175 list of mounted file systems. (DEC Alpha running OSF/1)])
176 fi
177 fi
178
179 if test -z "$ac_list_mounted_fs"; then
180 # (obsolete) SVR3
181 AC_CACHE_CHECK([for FIXME existence of three headers],
182 [fu_cv_sys_mounted_fread_fstyp],
183 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
184#include <sys/statfs.h>
185#include <sys/fstyp.h>
186#include <mnttab.h>
187]])],
188 [fu_cv_sys_mounted_fread_fstyp=yes],
189 [fu_cv_sys_mounted_fread_fstyp=no])
190 ])
191 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
192 ac_list_mounted_fs=found
193 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
194 [Define if (like SVR2) there is no specific function for reading the
195 list of mounted file systems, and your system has these header files:
196 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
197 fi
198 fi
199
200 if test -z "$ac_list_mounted_fs"; then
201 # Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, also (obsolete) 4.4BSD.
202 # OSF/1 also has getmntinfo but is already handled above.
203 # We cannot use AC_CHECK_FUNCS([getmntinfo]) here, because at the linker
204 # level the function is sometimes called getmntinfo64 or getmntinfo$INODE64
205 # on Mac OS X, __getmntinfo13 on NetBSD and Minix, _F64_getmntinfo on OSF/1.
206 AC_CACHE_CHECK([for getmntinfo function],
207 [fu_cv_sys_mounted_getmntinfo],
208 [AC_LINK_IFELSE(
209 [AC_LANG_PROGRAM([[
210#if HAVE_SYS_PARAM_H
211# include <sys/param.h>
212#endif
213#include <sys/types.h>
214#if HAVE_SYS_MOUNT_H
215# include <sys/mount.h>
216#endif
217#if HAVE_SYS_STATVFS_H
218# include <sys/statvfs.h>
219#endif
220#include <stdlib.h>
221 ]],
222 [[int count = getmntinfo (NULL, MNT_WAIT);
223 ]])],
224 [fu_cv_sys_mounted_getmntinfo=yes],
225 [fu_cv_sys_mounted_getmntinfo=no])
226 ])
227 if test $fu_cv_sys_mounted_getmntinfo = yes; then
228 AC_CACHE_CHECK([whether getmntinfo returns statvfs structures],
229 [fu_cv_sys_mounted_getmntinfo2],
230 [AC_COMPILE_IFELSE(
231 [AC_LANG_PROGRAM([[
232#if HAVE_SYS_PARAM_H
233# include <sys/param.h>
234#endif
235#include <sys/types.h>
236#if HAVE_SYS_MOUNT_H
237# include <sys/mount.h>
238#endif
239#if HAVE_SYS_STATVFS_H
240# include <sys/statvfs.h>
241#endif
242extern
243#ifdef __cplusplus
244"C"
245#endif
246int getmntinfo (struct statfs **, int);
247 ]], [[]])],
248 [fu_cv_sys_mounted_getmntinfo2=no],
249 [fu_cv_sys_mounted_getmntinfo2=yes])
250 ])
251 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
252 # Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD.
253 ac_list_mounted_fs=found
254 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
255 [Define if there is a function named getmntinfo for reading the
256 list of mounted file systems and it returns an array of
257 'struct statfs'. (4.4BSD, Darwin)])
258 else
259 # NetBSD, Minix.
260 ac_list_mounted_fs=found
261 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
262 [Define if there is a function named getmntinfo for reading the
263 list of mounted file systems and it returns an array of
264 'struct statvfs'. (NetBSD 3.0)])
265 fi
266 fi
267 fi
268
269 if test -z "$ac_list_mounted_fs"; then
270 # Haiku, also (obsolete) BeOS.
271 AC_CHECK_FUNCS([next_dev fs_stat_dev])
272 AC_CHECK_HEADERS([fs_info.h])
273 AC_CACHE_CHECK([for BEOS mounted file system support functions],
274 [fu_cv_sys_mounted_fs_stat_dev],
275 [if test $ac_cv_header_fs_info_h = yes \
276 && test $ac_cv_func_next_dev = yes \
277 && test $ac_cv_func_fs_stat_dev = yes; then
278 fu_cv_sys_mounted_fs_stat_dev=yes
279 else
280 fu_cv_sys_mounted_fs_stat_dev=no
281 fi
282 ])
283 if test $fu_cv_sys_mounted_fs_stat_dev = yes; then
284 ac_list_mounted_fs=found
285 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
286 [Define if there are functions named next_dev and fs_stat_dev for
287 reading the list of mounted file systems. (BeOS)])
288 fi
289 fi
290
291 if test -z "$ac_list_mounted_fs"; then
292 # Interix / BSD alike statvfs
293 # the code is really interix specific, so make sure, we're on it.
294 case "$host" in
295 *-interix*)
296 AC_CHECK_FUNCS([statvfs])
297 if test $ac_cv_func_statvfs = yes; then
298 ac_list_mounted_fs=found
299 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
300 [Define if we are on interix, and ought to use statvfs plus
301 some special knowledge on where mounted file systems can be
302 found. (Interix)])
303 fi
304 ;;
305 esac
306 fi
307
308 if test -z "$ac_list_mounted_fs"; then
309 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
310 # FIXME -- no need to abort building the whole package
311 # Can't build mountlist.c or anything that needs its functions
312 fi
313
314 if test $ac_list_mounted_fs = found; then
315 gl_cv_list_mounted_fs=yes
316 else
317 gl_cv_list_mounted_fs=no
318 fi
11]) 319])
12 320
13# Prerequisites of lib/mountlist.c not done by gl_LIST_MOUNTED_FILE_SYSTEMS. 321# Prerequisites of lib/mountlist.c not done by gl_MOUNTLIST.
14AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA], 322AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA],
15[ 323[
16 dnl Note gl_LIST_MOUNTED_FILE_SYSTEMS checks for mntent.h, not sys/mntent.h. 324 dnl Note gl_MOUNTLIST checks for mntent.h, not sys/mntent.h.
17 AC_CHECK_HEADERS([sys/mntent.h]) 325 AC_CHECK_HEADERS([sys/mntent.h])
326 AC_HEADER_MAJOR()dnl for use of makedev ()
18 gl_FSTYPENAME 327 gl_FSTYPENAME
19]) 328])
329
330# Replace Autoconf's AC_FUNC_GETMNTENT to omit checks that are unnecessary
331# nowadays.
332AC_DEFUN([AC_FUNC_GETMNTENT],
333[
334 # getmntent is in the standard C library on most systems, but in -lgen on
335 # Unixware.
336 AC_SEARCH_LIBS([getmntent], [gen])
337 AC_CHECK_FUNCS([getmntent])
338])
diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4
index 9a6a47a7..8d9d21b5 100644
--- a/gl/m4/msvc-inval.m4
+++ b/gl/m4/msvc-inval.m4
@@ -1,5 +1,5 @@
1# msvc-inval.m4 serial 1 1# msvc-inval.m4 serial 1
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/msvc-nothrow.m4 b/gl/m4/msvc-nothrow.m4
index a39618a4..0263e490 100644
--- a/gl/m4/msvc-nothrow.m4
+++ b/gl/m4/msvc-nothrow.m4
@@ -1,5 +1,5 @@
1# msvc-nothrow.m4 serial 1 1# msvc-nothrow.m4 serial 1
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4
index 552ec7e7..3ba5b0f7 100644
--- a/gl/m4/multiarch.m4
+++ b/gl/m4/multiarch.m4
@@ -1,5 +1,5 @@
1# multiarch.m4 serial 7 1# multiarch.m4 serial 9
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -21,37 +21,40 @@ dnl with or without modifications, as long as this notice is preserved.
21AC_DEFUN_ONCE([gl_MULTIARCH], 21AC_DEFUN_ONCE([gl_MULTIARCH],
22[ 22[
23 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. 23 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
24 gl_cv_c_multiarch=no 24 AC_CACHE_CHECK([whether the compiler produces multi-arch binaries],
25 AC_COMPILE_IFELSE( 25 [gl_cv_c_multiarch],
26 [AC_LANG_SOURCE( 26 [gl_cv_c_multiarch=no
27 [[#ifndef __APPLE_CC__ 27 AC_COMPILE_IFELSE(
28 not a universal capable compiler 28 [AC_LANG_SOURCE(
29 #endif 29 [[#ifndef __APPLE_CC__
30 typedef int dummy; 30 not a universal capable compiler
31 ]])], 31 #endif
32 [ 32 typedef int dummy;
33 dnl Check for potential -arch flags. It is not universal unless 33 ]])],
34 dnl there are at least two -arch flags with different values. 34 [
35 arch= 35 dnl Check for potential -arch flags. It is not universal unless
36 prev= 36 dnl there are at least two -arch flags with different values.
37 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do 37 arch=
38 if test -n "$prev"; then 38 prev=
39 case $word in 39 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
40 i?86 | x86_64 | ppc | ppc64) 40 if test -n "$prev"; then
41 if test -z "$arch" || test "$arch" = "$word"; then 41 case $word in
42 arch="$word" 42 i?86 | x86_64 | ppc | ppc64 | arm | arm64)
43 else 43 if test -z "$arch" || test "$arch" = "$word"; then
44 gl_cv_c_multiarch=yes 44 arch="$word"
45 fi 45 else
46 ;; 46 gl_cv_c_multiarch=yes
47 esac 47 fi
48 prev= 48 ;;
49 else 49 esac
50 if test "x$word" = "x-arch"; then 50 prev=
51 prev=arch 51 else
52 fi 52 if test "x$word" = "x-arch"; then
53 fi 53 prev=arch
54 done 54 fi
55 fi
56 done
57 ])
55 ]) 58 ])
56 if test $gl_cv_c_multiarch = yes; then 59 if test $gl_cv_c_multiarch = yes; then
57 APPLE_UNIVERSAL_BUILD=1 60 APPLE_UNIVERSAL_BUILD=1
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
index 2c69f999..e6aa8925 100644
--- a/gl/m4/netdb_h.m4
+++ b/gl/m4/netdb_h.m4
@@ -1,10 +1,10 @@
1# netdb_h.m4 serial 11 1# netdb_h.m4 serial 15
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_HEADER_NETDB], 7AC_DEFUN_ONCE([gl_NETDB_H],
8[ 8[
9 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 9 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([netdb.h]) 10 gl_CHECK_NEXT_HEADERS([netdb.h])
@@ -21,18 +21,33 @@ AC_DEFUN([gl_HEADER_NETDB],
21 [getaddrinfo freeaddrinfo gai_strerror getnameinfo]) 21 [getaddrinfo freeaddrinfo gai_strerror getnameinfo])
22]) 22])
23 23
24# gl_NETDB_MODULE_INDICATOR([modulename])
25# sets the shell variable that indicates the presence of the given module
26# to a C preprocessor expression that will evaluate to 1.
27# This macro invocation must not occur in macros that are AC_REQUIREd.
24AC_DEFUN([gl_NETDB_MODULE_INDICATOR], 28AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
25[ 29[
26 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 30 dnl Ensure to expand the default settings once only.
27 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 31 gl_NETDB_H_REQUIRE_DEFAULTS
28 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 32 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
29 dnl Define it also as a C macro, for the benefit of the unit tests. 33 dnl Define it also as a C macro, for the benefit of the unit tests.
30 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 34 gl_MODULE_INDICATOR_FOR_TESTS([$1])
31]) 35])
32 36
37# Initializes the default values for AC_SUBSTed shell variables.
38# This macro must not be AC_REQUIREd. It must only be invoked, and only
39# outside of macros or in macros that are not AC_REQUIREd.
40AC_DEFUN([gl_NETDB_H_REQUIRE_DEFAULTS],
41[
42 m4_defun(GL_MODULE_INDICATOR_PREFIX[_NETDB_H_MODULE_INDICATOR_DEFAULTS], [
43 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETADDRINFO])
44 ])
45 m4_require(GL_MODULE_INDICATOR_PREFIX[_NETDB_H_MODULE_INDICATOR_DEFAULTS])
46 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
47])
48
33AC_DEFUN([gl_NETDB_H_DEFAULTS], 49AC_DEFUN([gl_NETDB_H_DEFAULTS],
34[ 50[
35 GNULIB_GETADDRINFO=0; AC_SUBST([GNULIB_GETADDRINFO])
36 dnl Assume proper GNU behavior unless another module says otherwise. 51 dnl Assume proper GNU behavior unless another module says otherwise.
37 HAVE_STRUCT_ADDRINFO=1; AC_SUBST([HAVE_STRUCT_ADDRINFO]) 52 HAVE_STRUCT_ADDRINFO=1; AC_SUBST([HAVE_STRUCT_ADDRINFO])
38 HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO]) 53 HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO])
@@ -40,4 +55,5 @@ AC_DEFUN([gl_NETDB_H_DEFAULTS],
40 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO]) 55 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO])
41 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO]) 56 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO])
42 REPLACE_GAI_STRERROR=0; AC_SUBST([REPLACE_GAI_STRERROR]) 57 REPLACE_GAI_STRERROR=0; AC_SUBST([REPLACE_GAI_STRERROR])
58 REPLACE_GETADDRINFO=0; AC_SUBST([REPLACE_GETADDRINFO])
43]) 59])
diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4
index 21971b29..71154191 100644
--- a/gl/m4/netinet_in_h.m4
+++ b/gl/m4/netinet_in_h.m4
@@ -1,5 +1,5 @@
1# netinet_in_h.m4 serial 5 1# netinet_in_h.m4 serial 6
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -14,9 +14,9 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
14 [gl_cv_header_netinet_in_h_selfcontained=no]) 14 [gl_cv_header_netinet_in_h_selfcontained=no])
15 ]) 15 ])
16 if test $gl_cv_header_netinet_in_h_selfcontained = yes; then 16 if test $gl_cv_header_netinet_in_h_selfcontained = yes; then
17 NETINET_IN_H='' 17 GL_GENERATE_NETINET_IN_H=false
18 else 18 else
19 NETINET_IN_H='netinet/in.h' 19 GL_GENERATE_NETINET_IN_H=true
20 AC_CHECK_HEADERS([netinet/in.h]) 20 AC_CHECK_HEADERS([netinet/in.h])
21 gl_CHECK_NEXT_HEADERS([netinet/in.h]) 21 gl_CHECK_NEXT_HEADERS([netinet/in.h])
22 if test $ac_cv_header_netinet_in_h = yes; then 22 if test $ac_cv_header_netinet_in_h = yes; then
@@ -26,6 +26,4 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
26 fi 26 fi
27 AC_SUBST([HAVE_NETINET_IN_H]) 27 AC_SUBST([HAVE_NETINET_IN_H])
28 fi 28 fi
29 AC_SUBST([NETINET_IN_H])
30 AM_CONDITIONAL([GL_GENERATE_NETINET_IN_H], [test -n "$NETINET_IN_H"])
31]) 29])
diff --git a/gl/m4/nl_langinfo.m4 b/gl/m4/nl_langinfo.m4
index 25e21015..51e783ce 100644
--- a/gl/m4/nl_langinfo.m4
+++ b/gl/m4/nl_langinfo.m4
@@ -1,5 +1,5 @@
1# nl_langinfo.m4 serial 5 1# nl_langinfo.m4 serial 8
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,10 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 AC_REQUIRE([gl_LANGINFO_H]) 10 AC_REQUIRE([gl_LANGINFO_H])
11 AC_CHECK_FUNCS_ONCE([nl_langinfo]) 11 AC_CHECK_FUNCS_ONCE([nl_langinfo])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
14 AC_REQUIRE([gl_PTHREADLIB])
15 AC_CHECK_HEADERS_ONCE([threads.h])
13 if test $ac_cv_func_nl_langinfo = yes; then 16 if test $ac_cv_func_nl_langinfo = yes; then
14 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. 17 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken.
15 AC_CACHE_CHECK([whether YESEXPR works], 18 AC_CACHE_CHECK([whether YESEXPR works],
@@ -36,8 +39,19 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
36 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS], 39 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS],
37 [$FUNC_NL_LANGINFO_YESEXPR_WORKS], 40 [$FUNC_NL_LANGINFO_YESEXPR_WORKS],
38 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.]) 41 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.])
39 if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \ 42 # On Solaris 10 and Solaris 11.3, nl_langinfo is not multithread-safe.
40 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then 43 case "$host_os" in
44 solaris*) NL_LANGINFO_MTSAFE=0 ;;
45 *) NL_LANGINFO_MTSAFE=1 ;;
46 esac
47 AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE],
48 [Define to 1 if nl_langinfo is multithread-safe.])
49 if test $HAVE_LANGINFO_CODESET = 1 \
50 && test $HAVE_LANGINFO_T_FMT_AMPM = 1 \
51 && test $HAVE_LANGINFO_ALTMON = 1 \
52 && test $HAVE_LANGINFO_ERA = 1 \
53 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1 \
54 && test $NL_LANGINFO_MTSAFE = 1; then
41 : 55 :
42 else 56 else
43 REPLACE_NL_LANGINFO=1 57 REPLACE_NL_LANGINFO=1
@@ -47,4 +61,17 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
47 else 61 else
48 HAVE_NL_LANGINFO=0 62 HAVE_NL_LANGINFO=0
49 fi 63 fi
64 if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then
65 LIB_NL_LANGINFO="$LIB_SETLOCALE_NULL"
66 else
67 LIB_NL_LANGINFO=
68 fi
69 dnl LIB_NL_LANGINFO is expected to be empty everywhere.
70 AC_SUBST([LIB_NL_LANGINFO])
71])
72
73# Prerequisites of lib/nl_langinfo-lock.c.
74AC_DEFUN([gl_PREREQ_NL_LANGINFO_LOCK],
75[
76 gl_VISIBILITY
50]) 77])
diff --git a/gl/m4/nls.m4 b/gl/m4/nls.m4
deleted file mode 100644
index 8f8a147b..00000000
--- a/gl/m4/nls.m4
+++ /dev/null
@@ -1,32 +0,0 @@
1# nls.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 1995-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl
8dnl This file can can be used in projects which are not available under
9dnl the GNU General Public License or the GNU Library General Public
10dnl License but which still want to provide support for the GNU gettext
11dnl functionality.
12dnl Please note that the actual code of the GNU gettext library is covered
13dnl by the GNU Library General Public License, and the rest of the GNU
14dnl gettext package package is covered by the GNU General Public License.
15dnl They are *not* in the public domain.
16
17dnl Authors:
18dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
19dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
20
21AC_PREREQ([2.50])
22
23AC_DEFUN([AM_NLS],
24[
25 AC_MSG_CHECKING([whether NLS is requested])
26 dnl Default is enabled NLS
27 AC_ARG_ENABLE([nls],
28 [ --disable-nls do not use Native Language Support],
29 USE_NLS=$enableval, USE_NLS=yes)
30 AC_MSG_RESULT([$USE_NLS])
31 AC_SUBST([USE_NLS])
32])
diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4
index 105b884f..6a766387 100644
--- a/gl/m4/nocrash.m4
+++ b/gl/m4/nocrash.m4
@@ -1,5 +1,5 @@
1# nocrash.m4 serial 4 1# nocrash.m4 serial 5
2dnl Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -53,7 +53,7 @@ nocrash_init (void)
53 /* Allocate a port on which the thread shall listen for exceptions. */ 53 /* Allocate a port on which the thread shall listen for exceptions. */
54 if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) 54 if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
55 == KERN_SUCCESS) { 55 == KERN_SUCCESS) {
56 /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ 56 /* See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */
57 if (mach_port_insert_right (self, our_exception_port, our_exception_port, 57 if (mach_port_insert_right (self, our_exception_port, our_exception_port,
58 MACH_MSG_TYPE_MAKE_SEND) 58 MACH_MSG_TYPE_MAKE_SEND)
59 == KERN_SUCCESS) { 59 == KERN_SUCCESS) {
@@ -72,14 +72,14 @@ nocrash_init (void)
72 for a particular thread. This has the effect that when our exception 72 for a particular thread. This has the effect that when our exception
73 port gets the message, the thread specific exception port has already 73 port gets the message, the thread specific exception port has already
74 been asked, and we don't need to bother about it. 74 been asked, and we don't need to bother about it.
75 See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ 75 See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */
76 task_set_exception_ports (self, mask, our_exception_port, 76 task_set_exception_ports (self, mask, our_exception_port,
77 EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); 77 EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
78 } 78 }
79 } 79 }
80 } 80 }
81} 81}
82#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 82#elif defined _WIN32 && ! defined __CYGWIN__
83/* Avoid a crash on native Windows. */ 83/* Avoid a crash on native Windows. */
84#define WIN32_LEAN_AND_MEAN 84#define WIN32_LEAN_AND_MEAN
85#include <windows.h> 85#include <windows.h>
@@ -110,11 +110,12 @@ nocrash_init (void)
110#else 110#else
111/* Avoid a crash on POSIX systems. */ 111/* Avoid a crash on POSIX systems. */
112#include <signal.h> 112#include <signal.h>
113#include <unistd.h>
113/* A POSIX signal handler. */ 114/* A POSIX signal handler. */
114static void 115static void
115exception_handler (int sig) 116exception_handler (int sig)
116{ 117{
117 exit (1); 118 _exit (1);
118} 119}
119static void 120static void
120nocrash_init (void) 121nocrash_init (void)
diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4
index d355d013..880f3472 100644
--- a/gl/m4/off_t.m4
+++ b/gl/m4/off_t.m4
@@ -1,5 +1,5 @@
1# off_t.m4 serial 1 1# off_t.m4 serial 1
2dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/onceonly.m4 b/gl/m4/onceonly.m4
deleted file mode 100644
index 0a875a3d..00000000
--- a/gl/m4/onceonly.m4
+++ /dev/null
@@ -1,104 +0,0 @@
1# onceonly.m4 serial 9
2dnl Copyright (C) 2002-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl
5dnl This file is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This file is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this file. If not, see <http://www.gnu.org/licenses/>.
17dnl
18dnl As a special exception to the GNU General Public License,
19dnl this file may be distributed as part of a program
20dnl that contains a configuration script generated by Autoconf, under
21dnl the same distribution terms as the rest of that program.
22
23dnl This file defines some "once only" variants of standard autoconf macros.
24dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
25dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
26dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
27dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL
28dnl The advantage is that the check for each of the headers/functions/decls
29dnl will be put only once into the 'configure' file. It keeps the size of
30dnl the 'configure' file down, and avoids redundant output when 'configure'
31dnl is run.
32dnl The drawback is that the checks cannot be conditionalized. If you write
33dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
34dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
35dnl empty, and the check will be inserted before the body of the AC_DEFUNed
36dnl function.
37
38dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
39dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
40dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
41dnl headers at once, thus reducing the size of 'configure'. It is known to work
42dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
43
44dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
45dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
46dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
47dnl argument!
48AC_PREREQ([2.59])
49
50# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
51# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
52AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
53 :
54 m4_foreach_w([gl_HEADER_NAME], [$1], [
55 AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
56 [./-], [___])), [
57 m4_divert_text([INIT_PREPARE],
58 [gl_header_list="$gl_header_list gl_HEADER_NAME"])
59 gl_HEADERS_EXPANSION
60 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
61 [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
62 ])
63 AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
64 [./-], [___])))
65 ])
66])
67m4_define([gl_HEADERS_EXPANSION], [
68 m4_divert_text([DEFAULTS], [gl_header_list=])
69 AC_CHECK_HEADERS([$gl_header_list])
70 m4_define([gl_HEADERS_EXPANSION], [])
71])
72
73# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
74# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
75AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
76 :
77 m4_foreach_w([gl_FUNC_NAME], [$1], [
78 AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
79 m4_divert_text([INIT_PREPARE],
80 [gl_func_list="$gl_func_list gl_FUNC_NAME"])
81 gl_FUNCS_EXPANSION
82 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
83 [Define to 1 if you have the ']m4_defn([gl_FUNC_NAME])[' function.])
84 ])
85 AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
86 ])
87])
88m4_define([gl_FUNCS_EXPANSION], [
89 m4_divert_text([DEFAULTS], [gl_func_list=])
90 AC_CHECK_FUNCS([$gl_func_list])
91 m4_define([gl_FUNCS_EXPANSION], [])
92])
93
94# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
95# AC_CHECK_DECLS(DECL1, DECL2, ...).
96AC_DEFUN([AC_CHECK_DECLS_ONCE], [
97 :
98 m4_foreach_w([gl_DECL_NAME], [$1], [
99 AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
100 AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
101 ])
102 AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
103 ])
104])
diff --git a/gl/m4/open-cloexec.m4 b/gl/m4/open-cloexec.m4
new file mode 100644
index 00000000..fd572fcd
--- /dev/null
+++ b/gl/m4/open-cloexec.m4
@@ -0,0 +1,21 @@
1# Test whether O_CLOEXEC is defined.
2
3dnl Copyright 2017-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_PREPROC_O_CLOEXEC],
9[
10 AC_CACHE_CHECK([for O_CLOEXEC],
11 [gl_cv_macro_O_CLOEXEC],
12 [AC_COMPILE_IFELSE(
13 [AC_LANG_PROGRAM([[#include <fcntl.h>
14 #ifndef O_CLOEXEC
15 choke me;
16 #endif
17 ]],
18 [[return O_CLOEXEC;]])],
19 [gl_cv_macro_O_CLOEXEC=yes],
20 [gl_cv_macro_O_CLOEXEC=no])])
21])
diff --git a/gl/m4/open-slash.m4 b/gl/m4/open-slash.m4
new file mode 100644
index 00000000..1f731f8a
--- /dev/null
+++ b/gl/m4/open-slash.m4
@@ -0,0 +1,60 @@
1# open-slash.m4 serial 2
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Tests whether open() and creat() recognize a trailing slash.
8dnl Sets gl_cv_func_open_slash.
9AC_DEFUN([gl_OPEN_TRAILING_SLASH_BUG],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 dnl open("foo/") should not create a file when the file name has a
13 dnl trailing slash. FreeBSD only has the problem on symlinks.
14 AC_CHECK_FUNCS_ONCE([lstat])
15 AC_CACHE_CHECK([whether open recognizes a trailing slash],
16 [gl_cv_func_open_slash],
17 [# Assume that if we have lstat, we can also check symlinks.
18 if test $ac_cv_func_lstat = yes; then
19 touch conftest.tmp
20 ln -s conftest.tmp conftest.lnk
21 fi
22 AC_RUN_IFELSE(
23 [AC_LANG_SOURCE([[
24#include <fcntl.h>
25#if HAVE_UNISTD_H
26# include <unistd.h>
27#endif
28]GL_MDA_DEFINES[
29int main ()
30{
31 int result = 0;
32#if HAVE_LSTAT
33 if (open ("conftest.lnk/", O_RDONLY) != -1)
34 result |= 1;
35#endif
36 if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
37 result |= 2;
38 return result;
39}]])],
40 [gl_cv_func_open_slash=yes],
41 [gl_cv_func_open_slash=no],
42 [
43changequote(,)dnl
44 case "$host_os" in
45 freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
46 gl_cv_func_open_slash="guessing no" ;;
47 *)
48 gl_cv_func_open_slash="guessing yes" ;;
49 esac
50changequote([,])dnl
51 ])
52 rm -f conftest.sl conftest.tmp conftest.lnk
53 ])
54 case "$gl_cv_func_open_slash" in
55 *no)
56 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
57 [Define to 1 if open() fails to recognize a trailing slash.])
58 ;;
59 esac
60])
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
new file mode 100644
index 00000000..94fa2bb7
--- /dev/null
+++ b/gl/m4/open.m4
@@ -0,0 +1,56 @@
1# open.m4 serial 15
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_OPEN],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PREPROC_O_CLOEXEC])
11 case "$host_os" in
12 mingw* | pw*)
13 REPLACE_OPEN=1
14 ;;
15 *)
16 dnl open("foo/") should not create a file when the file name has a
17 dnl trailing slash. FreeBSD only has the problem on symlinks.
18 AC_CHECK_FUNCS_ONCE([lstat])
19 if test "$gl_cv_macro_O_CLOEXEC" != yes; then
20 REPLACE_OPEN=1
21 fi
22 gl_OPEN_TRAILING_SLASH_BUG
23 case "$gl_cv_func_open_slash" in
24 *no)
25 REPLACE_OPEN=1
26 ;;
27 esac
28 ;;
29 esac
30 dnl Replace open() for supporting the gnulib-defined fchdir() function,
31 dnl to keep fchdir's bookkeeping up-to-date.
32 m4_ifdef([gl_FUNC_FCHDIR], [
33 if test $REPLACE_OPEN = 0; then
34 gl_TEST_FCHDIR
35 if test $HAVE_FCHDIR = 0; then
36 REPLACE_OPEN=1
37 fi
38 fi
39 ])
40 dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag.
41 m4_ifdef([gl_NONBLOCKING_IO], [
42 if test $REPLACE_OPEN = 0; then
43 gl_NONBLOCKING_IO
44 if test $gl_cv_have_open_O_NONBLOCK != yes; then
45 REPLACE_OPEN=1
46 fi
47 fi
48 ])
49])
50
51# Prerequisites of lib/open.c.
52AC_DEFUN([gl_PREREQ_OPEN],
53[
54 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
55 :
56])
diff --git a/gl/m4/pathmax.m4 b/gl/m4/pathmax.m4
new file mode 100644
index 00000000..6d47d2c0
--- /dev/null
+++ b/gl/m4/pathmax.m4
@@ -0,0 +1,42 @@
1# pathmax.m4 serial 11
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_PATHMAX],
9[
10 dnl Prerequisites of lib/pathmax.h.
11 AC_CHECK_HEADERS_ONCE([sys/param.h])
12])
13
14# Expands to a piece of C program that defines PATH_MAX in the same way as
15# "pathmax.h" will do.
16AC_DEFUN([gl_PATHMAX_SNIPPET], [[
17/* Arrange to define PATH_MAX, like "pathmax.h" does. */
18#if HAVE_UNISTD_H
19# include <unistd.h>
20#endif
21#include <limits.h>
22#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
23# include <sys/param.h>
24#endif
25#if !defined PATH_MAX && defined MAXPATHLEN
26# define PATH_MAX MAXPATHLEN
27#endif
28#ifdef __hpux
29# undef PATH_MAX
30# define PATH_MAX 1024
31#endif
32#if defined _WIN32 && ! defined __CYGWIN__
33# undef PATH_MAX
34# define PATH_MAX 260
35#endif
36]])
37
38# Prerequisites of gl_PATHMAX_SNIPPET.
39AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ],
40[
41 AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
42])
diff --git a/gl/m4/pid_t.m4 b/gl/m4/pid_t.m4
new file mode 100644
index 00000000..0fd7d0a1
--- /dev/null
+++ b/gl/m4/pid_t.m4
@@ -0,0 +1,38 @@
1# pid_t.m4 serial 4
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# The following implementation works around a problem in autoconf <= 2.69.
8m4_version_prereq([2.70], [], [
9
10dnl Define pid_t if the headers don't define it.
11AC_DEFUN([AC_TYPE_PID_T],
12[
13 AC_CHECK_TYPE([pid_t],
14 [],
15 [dnl On 64-bit native Windows, define it to the equivalent of 'intptr_t'
16 dnl (= 'long long' = '__int64'), because that is the return type
17 dnl of the _spawnv* functions
18 dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnvp-wspawnvp>
19 dnl and the argument type of the _cwait function
20 dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/cwait>.
21 dnl Otherwise (on 32-bit Windows and on old Unix platforms), define it
22 dnl to 'int'.
23 AC_COMPILE_IFELSE(
24 [AC_LANG_PROGRAM([[
25 #if defined _WIN64 && !defined __CYGWIN__
26 LLP64
27 #endif
28 ]])
29 ],
30 [gl_pid_type='int'],
31 [gl_pid_type='__int64'])
32 AC_DEFINE_UNQUOTED([pid_t], [$gl_pid_type],
33 [Define as a signed integer type capable of holding a process identifier.])
34 ],
35 [AC_INCLUDES_DEFAULT])
36])
37
38])# m4_version_prereq 2.70
diff --git a/gl/m4/po.m4 b/gl/m4/po.m4
deleted file mode 100644
index 1c70b6c1..00000000
--- a/gl/m4/po.m4
+++ /dev/null
@@ -1,453 +0,0 @@
1# po.m4 serial 21 (gettext-0.18.3)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19
20AC_PREREQ([2.60])
21
22dnl Checks for all prerequisites of the po subdirectory.
23AC_DEFUN([AM_PO_SUBDIRS],
24[
25 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
26 AC_REQUIRE([AC_PROG_INSTALL])dnl
27 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
28 AC_REQUIRE([AC_PROG_SED])dnl
29 AC_REQUIRE([AM_NLS])dnl
30
31 dnl Release version of the gettext macros. This is used to ensure that
32 dnl the gettext macros and po/Makefile.in.in are in sync.
33 AC_SUBST([GETTEXT_MACRO_VERSION], [0.18])
34
35 dnl Perform the following tests also if --disable-nls has been given,
36 dnl because they are needed for "make dist" to work.
37
38 dnl Search for GNU msgfmt in the PATH.
39 dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
40 dnl The second test excludes FreeBSD msgfmt.
41 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
42 [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
43 (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
44 :)
45 AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
46
47 dnl Test whether it is GNU msgfmt >= 0.15.
48changequote(,)dnl
49 case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
50 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;;
51 *) MSGFMT_015=$MSGFMT ;;
52 esac
53changequote([,])dnl
54 AC_SUBST([MSGFMT_015])
55changequote(,)dnl
56 case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
57 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
58 *) GMSGFMT_015=$GMSGFMT ;;
59 esac
60changequote([,])dnl
61 AC_SUBST([GMSGFMT_015])
62
63 dnl Search for GNU xgettext 0.12 or newer in the PATH.
64 dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
65 dnl The second test excludes FreeBSD xgettext.
66 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
67 [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
68 (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
69 :)
70 dnl Remove leftover from FreeBSD xgettext call.
71 rm -f messages.po
72
73 dnl Test whether it is GNU xgettext >= 0.15.
74changequote(,)dnl
75 case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
76 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
77 *) XGETTEXT_015=$XGETTEXT ;;
78 esac
79changequote([,])dnl
80 AC_SUBST([XGETTEXT_015])
81
82 dnl Search for GNU msgmerge 0.11 or newer in the PATH.
83 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
84 [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
85
86 dnl Installation directories.
87 dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we
88 dnl have to define it here, so that it can be used in po/Makefile.
89 test -n "$localedir" || localedir='${datadir}/locale'
90 AC_SUBST([localedir])
91
92 dnl Support for AM_XGETTEXT_OPTION.
93 test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
94 AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
95
96 AC_CONFIG_COMMANDS([po-directories], [[
97 for ac_file in $CONFIG_FILES; do
98 # Support "outfile[:infile[:infile...]]"
99 case "$ac_file" in
100 *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
101 esac
102 # PO directories have a Makefile.in generated from Makefile.in.in.
103 case "$ac_file" in */Makefile.in)
104 # Adjust a relative srcdir.
105 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
106 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
107 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
108 # In autoconf-2.13 it is called $ac_given_srcdir.
109 # In autoconf-2.50 it is called $srcdir.
110 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
111 case "$ac_given_srcdir" in
112 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
113 /*) top_srcdir="$ac_given_srcdir" ;;
114 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
115 esac
116 # Treat a directory as a PO directory if and only if it has a
117 # POTFILES.in file. This allows packages to have multiple PO
118 # directories under different names or in different locations.
119 if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
120 rm -f "$ac_dir/POTFILES"
121 test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
122 gt_tab=`printf '\t'`
123 cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
124 POMAKEFILEDEPS="POTFILES.in"
125 # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
126 # on $ac_dir but don't depend on user-specified configuration
127 # parameters.
128 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
129 # The LINGUAS file contains the set of available languages.
130 if test -n "$OBSOLETE_ALL_LINGUAS"; then
131 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
132 fi
133 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
134 # Hide the ALL_LINGUAS assignment from automake < 1.5.
135 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
136 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
137 else
138 # The set of available languages was given in configure.in.
139 # Hide the ALL_LINGUAS assignment from automake < 1.5.
140 eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
141 fi
142 # Compute POFILES
143 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
144 # Compute UPDATEPOFILES
145 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
146 # Compute DUMMYPOFILES
147 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
148 # Compute GMOFILES
149 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
150 case "$ac_given_srcdir" in
151 .) srcdirpre= ;;
152 *) srcdirpre='$(srcdir)/' ;;
153 esac
154 POFILES=
155 UPDATEPOFILES=
156 DUMMYPOFILES=
157 GMOFILES=
158 for lang in $ALL_LINGUAS; do
159 POFILES="$POFILES $srcdirpre$lang.po"
160 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
161 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
162 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
163 done
164 # CATALOGS depends on both $ac_dir and the user's LINGUAS
165 # environment variable.
166 INST_LINGUAS=
167 if test -n "$ALL_LINGUAS"; then
168 for presentlang in $ALL_LINGUAS; do
169 useit=no
170 if test "%UNSET%" != "$LINGUAS"; then
171 desiredlanguages="$LINGUAS"
172 else
173 desiredlanguages="$ALL_LINGUAS"
174 fi
175 for desiredlang in $desiredlanguages; do
176 # Use the presentlang catalog if desiredlang is
177 # a. equal to presentlang, or
178 # b. a variant of presentlang (because in this case,
179 # presentlang can be used as a fallback for messages
180 # which are not translated in the desiredlang catalog).
181 case "$desiredlang" in
182 "$presentlang"*) useit=yes;;
183 esac
184 done
185 if test $useit = yes; then
186 INST_LINGUAS="$INST_LINGUAS $presentlang"
187 fi
188 done
189 fi
190 CATALOGS=
191 if test -n "$INST_LINGUAS"; then
192 for lang in $INST_LINGUAS; do
193 CATALOGS="$CATALOGS $lang.gmo"
194 done
195 fi
196 test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
197 sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
198 for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
199 if test -f "$f"; then
200 case "$f" in
201 *.orig | *.bak | *~) ;;
202 *) cat "$f" >> "$ac_dir/Makefile" ;;
203 esac
204 fi
205 done
206 fi
207 ;;
208 esac
209 done]],
210 [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
211 # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it
212 # from automake < 1.5.
213 eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
214 # Capture the value of LINGUAS because we need it to compute CATALOGS.
215 LINGUAS="${LINGUAS-%UNSET%}"
216 ])
217])
218
219dnl Postprocesses a Makefile in a directory containing PO files.
220AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
221[
222 # When this code is run, in config.status, two variables have already been
223 # set:
224 # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
225 # - LINGUAS is the value of the environment variable LINGUAS at configure
226 # time.
227
228changequote(,)dnl
229 # Adjust a relative srcdir.
230 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
231 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
232 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
233 # In autoconf-2.13 it is called $ac_given_srcdir.
234 # In autoconf-2.50 it is called $srcdir.
235 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
236 case "$ac_given_srcdir" in
237 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
238 /*) top_srcdir="$ac_given_srcdir" ;;
239 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
240 esac
241
242 # Find a way to echo strings without interpreting backslash.
243 if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
244 gt_echo='echo'
245 else
246 if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
247 gt_echo='printf %s\n'
248 else
249 echo_func () {
250 cat <<EOT
251$*
252EOT
253 }
254 gt_echo='echo_func'
255 fi
256 fi
257
258 # A sed script that extracts the value of VARIABLE from a Makefile.
259 tab=`printf '\t'`
260 sed_x_variable='
261# Test if the hold space is empty.
262x
263s/P/P/
264x
265ta
266# Yes it was empty. Look if we have the expected variable definition.
267/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{
268 # Seen the first line of the variable definition.
269 s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=//
270 ba
271}
272bd
273:a
274# Here we are processing a line from the variable definition.
275# Remove comment, more precisely replace it with a space.
276s/#.*$/ /
277# See if the line ends in a backslash.
278tb
279:b
280s/\\$//
281# Print the line, without the trailing backslash.
282p
283tc
284# There was no trailing backslash. The end of the variable definition is
285# reached. Clear the hold space.
286s/^.*$//
287x
288bd
289:c
290# A trailing backslash means that the variable definition continues in the
291# next line. Put a nonempty string into the hold space to indicate this.
292s/^.*$/P/
293x
294:d
295'
296changequote([,])dnl
297
298 # Set POTFILES to the value of the Makefile variable POTFILES.
299 sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
300 POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
301 # Compute POTFILES_DEPS as
302 # $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
303 POTFILES_DEPS=
304 for file in $POTFILES; do
305 POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
306 done
307 POMAKEFILEDEPS=""
308
309 if test -n "$OBSOLETE_ALL_LINGUAS"; then
310 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
311 fi
312 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
313 # The LINGUAS file contains the set of available languages.
314 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
315 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
316 else
317 # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
318 sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
319 ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
320 fi
321 # Hide the ALL_LINGUAS assignment from automake < 1.5.
322 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
323 # Compute POFILES
324 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
325 # Compute UPDATEPOFILES
326 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
327 # Compute DUMMYPOFILES
328 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
329 # Compute GMOFILES
330 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
331 # Compute PROPERTIESFILES
332 # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
333 # Compute CLASSFILES
334 # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
335 # Compute QMFILES
336 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
337 # Compute MSGFILES
338 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
339 # Compute RESOURCESDLLFILES
340 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
341 case "$ac_given_srcdir" in
342 .) srcdirpre= ;;
343 *) srcdirpre='$(srcdir)/' ;;
344 esac
345 POFILES=
346 UPDATEPOFILES=
347 DUMMYPOFILES=
348 GMOFILES=
349 PROPERTIESFILES=
350 CLASSFILES=
351 QMFILES=
352 MSGFILES=
353 RESOURCESDLLFILES=
354 for lang in $ALL_LINGUAS; do
355 POFILES="$POFILES $srcdirpre$lang.po"
356 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
357 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
358 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
359 PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties"
360 CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class"
361 QMFILES="$QMFILES $srcdirpre$lang.qm"
362 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
363 MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
364 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
365 RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
366 done
367 # CATALOGS depends on both $ac_dir and the user's LINGUAS
368 # environment variable.
369 INST_LINGUAS=
370 if test -n "$ALL_LINGUAS"; then
371 for presentlang in $ALL_LINGUAS; do
372 useit=no
373 if test "%UNSET%" != "$LINGUAS"; then
374 desiredlanguages="$LINGUAS"
375 else
376 desiredlanguages="$ALL_LINGUAS"
377 fi
378 for desiredlang in $desiredlanguages; do
379 # Use the presentlang catalog if desiredlang is
380 # a. equal to presentlang, or
381 # b. a variant of presentlang (because in this case,
382 # presentlang can be used as a fallback for messages
383 # which are not translated in the desiredlang catalog).
384 case "$desiredlang" in
385 "$presentlang"*) useit=yes;;
386 esac
387 done
388 if test $useit = yes; then
389 INST_LINGUAS="$INST_LINGUAS $presentlang"
390 fi
391 done
392 fi
393 CATALOGS=
394 JAVACATALOGS=
395 QTCATALOGS=
396 TCLCATALOGS=
397 CSHARPCATALOGS=
398 if test -n "$INST_LINGUAS"; then
399 for lang in $INST_LINGUAS; do
400 CATALOGS="$CATALOGS $lang.gmo"
401 JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
402 QTCATALOGS="$QTCATALOGS $lang.qm"
403 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
404 TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
405 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
406 CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
407 done
408 fi
409
410 sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
411 tab=`printf '\t'`
412 if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
413 # Add dependencies that cannot be formulated as a simple suffix rule.
414 for lang in $ALL_LINGUAS; do
415 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
416 cat >> "$ac_file.tmp" <<EOF
417$frobbedlang.msg: $lang.po
418${tab}@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
419${tab}\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
420EOF
421 done
422 fi
423 if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
424 # Add dependencies that cannot be formulated as a simple suffix rule.
425 for lang in $ALL_LINGUAS; do
426 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
427 cat >> "$ac_file.tmp" <<EOF
428$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
429${tab}@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
430${tab}\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
431EOF
432 done
433 fi
434 if test -n "$POMAKEFILEDEPS"; then
435 cat >> "$ac_file.tmp" <<EOF
436Makefile: $POMAKEFILEDEPS
437EOF
438 fi
439 mv "$ac_file.tmp" "$ac_file"
440])
441
442dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
443AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
444[
445 XGETTEXT_EXTRA_OPTIONS=
446])
447
448dnl Registers an option to be passed to xgettext in the po subdirectory.
449AC_DEFUN([AM_XGETTEXT_OPTION],
450[
451 AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
452 XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
453])
diff --git a/gl/m4/printf-posix.m4 b/gl/m4/printf-posix.m4
deleted file mode 100644
index d7dfb60f..00000000
--- a/gl/m4/printf-posix.m4
+++ /dev/null
@@ -1,48 +0,0 @@
1# printf-posix.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether the printf() function supports POSIX/XSI format strings with
9dnl positions.
10
11AC_DEFUN([gt_PRINTF_POSIX],
12[
13 AC_REQUIRE([AC_PROG_CC])
14 AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings],
15 gt_cv_func_printf_posix,
16 [
17 AC_RUN_IFELSE(
18 [AC_LANG_SOURCE([[
19#include <stdio.h>
20#include <string.h>
21/* The string "%2$d %1$d", with dollar characters protected from the shell's
22 dollar expansion (possibly an autoconf bug). */
23static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
24static char buf[100];
25int main ()
26{
27 sprintf (buf, format, 33, 55);
28 return (strcmp (buf, "55 33") != 0);
29}]])],
30 [gt_cv_func_printf_posix=yes],
31 [gt_cv_func_printf_posix=no],
32 [
33 AC_EGREP_CPP([notposix], [
34#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
35 notposix
36#endif
37 ],
38 [gt_cv_func_printf_posix="guessing no"],
39 [gt_cv_func_printf_posix="guessing yes"])
40 ])
41 ])
42 case $gt_cv_func_printf_posix in
43 *yes)
44 AC_DEFINE([HAVE_POSIX_PRINTF], [1],
45 [Define if your printf() function supports format strings with positions.])
46 ;;
47 esac
48])
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index ef44f785..4e65abc6 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,5 +1,5 @@
1# printf.m4 serial 50 1# printf.m4 serial 73
2dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -38,6 +38,8 @@ int main ()
38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
39 || strcmp (buf, "12345671 33") != 0) 39 || strcmp (buf, "12345671 33") != 0)
40 result |= 1; 40 result |= 1;
41#else
42 result |= 1;
41#endif 43#endif
42 buf[0] = '\0'; 44 buf[0] = '\0';
43 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 45 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
@@ -56,13 +58,16 @@ int main ()
56 [gl_cv_func_printf_sizes_c99=yes], 58 [gl_cv_func_printf_sizes_c99=yes],
57 [gl_cv_func_printf_sizes_c99=no], 59 [gl_cv_func_printf_sizes_c99=no],
58 [ 60 [
59changequote(,)dnl
60 case "$host_os" in 61 case "$host_os" in
62changequote(,)dnl
61 # Guess yes on glibc systems. 63 # Guess yes on glibc systems.
62 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; 64 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on musl systems.
66 *-musl*) gl_cv_func_printf_sizes_c99="guessing yes";;
63 # Guess yes on FreeBSD >= 5. 67 # Guess yes on FreeBSD >= 5.
64 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; 68 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";;
65 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 69 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
70 midnightbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
66 # Guess yes on Mac OS X >= 10.3. 71 # Guess yes on Mac OS X >= 10.3.
67 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; 72 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
68 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; 73 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
@@ -77,10 +82,21 @@ changequote(,)dnl
77 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 82 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
78 gl_cv_func_printf_sizes_c99="guessing no";; 83 gl_cv_func_printf_sizes_c99="guessing no";;
79 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 84 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
80 # If we don't know, assume the worst. 85 # Guess yes on Android.
81 *) gl_cv_func_printf_sizes_c99="guessing no";; 86 linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";;
82 esac
83changequote([,])dnl 87changequote([,])dnl
88 # Guess yes on MSVC, no on mingw.
89 mingw*) AC_EGREP_CPP([Known], [
90#ifdef _MSC_VER
91 Known
92#endif
93 ],
94 [gl_cv_func_printf_sizes_c99="guessing yes"],
95 [gl_cv_func_printf_sizes_c99="guessing no"])
96 ;;
97 # If we don't know, obey --enable-cross-guesses.
98 *) gl_cv_func_printf_sizes_c99="$gl_cross_guess_normal";;
99 esac
84 ]) 100 ])
85 ]) 101 ])
86]) 102])
@@ -120,14 +136,22 @@ int main ()
120}]])], 136}]])],
121 [gl_cv_func_printf_long_double=yes], 137 [gl_cv_func_printf_long_double=yes],
122 [gl_cv_func_printf_long_double=no], 138 [gl_cv_func_printf_long_double=no],
123 [ 139 [case "$host_os" in
124changequote(,)dnl 140 # Guess no on BeOS.
125 case "$host_os" in 141 beos*) gl_cv_func_printf_long_double="guessing no";;
126 beos*) gl_cv_func_printf_long_double="guessing no";; 142 # Guess yes on Android.
127 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; 143 linux*-android*) gl_cv_func_printf_long_double="guessing yes";;
128 *) gl_cv_func_printf_long_double="guessing yes";; 144 # Guess yes on MSVC, no on mingw.
145 mingw*) AC_EGREP_CPP([Known], [
146#ifdef _MSC_VER
147 Known
148#endif
149 ],
150 [gl_cv_func_printf_long_double="guessing yes"],
151 [gl_cv_func_printf_long_double="guessing no"])
152 ;;
153 *) gl_cv_func_printf_long_double="guessing yes";;
129 esac 154 esac
130changequote([,])dnl
131 ]) 155 ])
132 ]) 156 ])
133]) 157])
@@ -215,13 +239,16 @@ int main ()
215 [gl_cv_func_printf_infinite=yes], 239 [gl_cv_func_printf_infinite=yes],
216 [gl_cv_func_printf_infinite=no], 240 [gl_cv_func_printf_infinite=no],
217 [ 241 [
218changequote(,)dnl
219 case "$host_os" in 242 case "$host_os" in
243changequote(,)dnl
220 # Guess yes on glibc systems. 244 # Guess yes on glibc systems.
221 *-gnu*) gl_cv_func_printf_infinite="guessing yes";; 245 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";;
246 # Guess yes on musl systems.
247 *-musl*) gl_cv_func_printf_infinite="guessing yes";;
222 # Guess yes on FreeBSD >= 6. 248 # Guess yes on FreeBSD >= 6.
223 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; 249 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
224 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; 250 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
251 midnightbsd*) gl_cv_func_printf_infinite="guessing yes";;
225 # Guess yes on Mac OS X >= 10.3. 252 # Guess yes on Mac OS X >= 10.3.
226 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; 253 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
227 darwin*) gl_cv_func_printf_infinite="guessing yes";; 254 darwin*) gl_cv_func_printf_infinite="guessing yes";;
@@ -232,12 +259,26 @@ changequote(,)dnl
232 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 259 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
233 gl_cv_func_printf_infinite="guessing no";; 260 gl_cv_func_printf_infinite="guessing no";;
234 netbsd*) gl_cv_func_printf_infinite="guessing yes";; 261 netbsd*) gl_cv_func_printf_infinite="guessing yes";;
262 # Guess yes on OpenBSD >= 6.0.
263 openbsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
264 openbsd*) gl_cv_func_printf_infinite="guessing yes";;
235 # Guess yes on BeOS. 265 # Guess yes on BeOS.
236 beos*) gl_cv_func_printf_infinite="guessing yes";; 266 beos*) gl_cv_func_printf_infinite="guessing yes";;
237 # If we don't know, assume the worst. 267 # Guess no on Android.
238 *) gl_cv_func_printf_infinite="guessing no";; 268 linux*-android*) gl_cv_func_printf_infinite="guessing no";;
239 esac
240changequote([,])dnl 269changequote([,])dnl
270 # Guess yes on MSVC, no on mingw.
271 mingw*) AC_EGREP_CPP([Known], [
272#ifdef _MSC_VER
273 Known
274#endif
275 ],
276 [gl_cv_func_printf_infinite="guessing yes"],
277 [gl_cv_func_printf_infinite="guessing no"])
278 ;;
279 # If we don't know, obey --enable-cross-guesses.
280 *) gl_cv_func_printf_infinite="$gl_cross_guess_normal";;
281 esac
241 ]) 282 ])
242 ]) 283 ])
243]) 284])
@@ -328,7 +369,7 @@ int main ()
328# ifdef WORDS_BIGENDIAN 369# ifdef WORDS_BIGENDIAN
329# define LDBL80_WORDS(exponent,manthi,mantlo) \ 370# define LDBL80_WORDS(exponent,manthi,mantlo) \
330 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ 371 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
331 ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \ 372 ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \
332 (unsigned int) (mantlo) << 16 \ 373 (unsigned int) (mantlo) << 16 \
333 } 374 }
334# else 375# else
@@ -365,66 +406,51 @@ int main ()
365 { /* Pseudo-NaN. */ 406 { /* Pseudo-NaN. */
366 static union { unsigned int word[4]; long double value; } x = 407 static union { unsigned int word[4]; long double value; } x =
367 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; 408 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
368 if (sprintf (buf, "%Lf", x.value) < 0 409 if (sprintf (buf, "%Lf", x.value) <= 0)
369 || !strisnan (buf, 0, strlen (buf)))
370 result |= 4; 410 result |= 4;
371 if (sprintf (buf, "%Le", x.value) < 0 411 if (sprintf (buf, "%Le", x.value) <= 0)
372 || !strisnan (buf, 0, strlen (buf)))
373 result |= 4; 412 result |= 4;
374 if (sprintf (buf, "%Lg", x.value) < 0 413 if (sprintf (buf, "%Lg", x.value) <= 0)
375 || !strisnan (buf, 0, strlen (buf)))
376 result |= 4; 414 result |= 4;
377 } 415 }
378 { /* Pseudo-Infinity. */ 416 { /* Pseudo-Infinity. */
379 static union { unsigned int word[4]; long double value; } x = 417 static union { unsigned int word[4]; long double value; } x =
380 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; 418 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
381 if (sprintf (buf, "%Lf", x.value) < 0 419 if (sprintf (buf, "%Lf", x.value) <= 0)
382 || !strisnan (buf, 0, strlen (buf)))
383 result |= 8; 420 result |= 8;
384 if (sprintf (buf, "%Le", x.value) < 0 421 if (sprintf (buf, "%Le", x.value) <= 0)
385 || !strisnan (buf, 0, strlen (buf)))
386 result |= 8; 422 result |= 8;
387 if (sprintf (buf, "%Lg", x.value) < 0 423 if (sprintf (buf, "%Lg", x.value) <= 0)
388 || !strisnan (buf, 0, strlen (buf)))
389 result |= 8; 424 result |= 8;
390 } 425 }
391 { /* Pseudo-Zero. */ 426 { /* Pseudo-Zero. */
392 static union { unsigned int word[4]; long double value; } x = 427 static union { unsigned int word[4]; long double value; } x =
393 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; 428 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
394 if (sprintf (buf, "%Lf", x.value) < 0 429 if (sprintf (buf, "%Lf", x.value) <= 0)
395 || !strisnan (buf, 0, strlen (buf)))
396 result |= 16; 430 result |= 16;
397 if (sprintf (buf, "%Le", x.value) < 0 431 if (sprintf (buf, "%Le", x.value) <= 0)
398 || !strisnan (buf, 0, strlen (buf)))
399 result |= 16; 432 result |= 16;
400 if (sprintf (buf, "%Lg", x.value) < 0 433 if (sprintf (buf, "%Lg", x.value) <= 0)
401 || !strisnan (buf, 0, strlen (buf)))
402 result |= 16; 434 result |= 16;
403 } 435 }
404 { /* Unnormalized number. */ 436 { /* Unnormalized number. */
405 static union { unsigned int word[4]; long double value; } x = 437 static union { unsigned int word[4]; long double value; } x =
406 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; 438 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
407 if (sprintf (buf, "%Lf", x.value) < 0 439 if (sprintf (buf, "%Lf", x.value) <= 0)
408 || !strisnan (buf, 0, strlen (buf)))
409 result |= 32; 440 result |= 32;
410 if (sprintf (buf, "%Le", x.value) < 0 441 if (sprintf (buf, "%Le", x.value) <= 0)
411 || !strisnan (buf, 0, strlen (buf)))
412 result |= 32; 442 result |= 32;
413 if (sprintf (buf, "%Lg", x.value) < 0 443 if (sprintf (buf, "%Lg", x.value) <= 0)
414 || !strisnan (buf, 0, strlen (buf)))
415 result |= 32; 444 result |= 32;
416 } 445 }
417 { /* Pseudo-Denormal. */ 446 { /* Pseudo-Denormal. */
418 static union { unsigned int word[4]; long double value; } x = 447 static union { unsigned int word[4]; long double value; } x =
419 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; 448 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
420 if (sprintf (buf, "%Lf", x.value) < 0 449 if (sprintf (buf, "%Lf", x.value) <= 0)
421 || !strisnan (buf, 0, strlen (buf)))
422 result |= 64; 450 result |= 64;
423 if (sprintf (buf, "%Le", x.value) < 0 451 if (sprintf (buf, "%Le", x.value) <= 0)
424 || !strisnan (buf, 0, strlen (buf)))
425 result |= 64; 452 result |= 64;
426 if (sprintf (buf, "%Lg", x.value) < 0 453 if (sprintf (buf, "%Lg", x.value) <= 0)
427 || !strisnan (buf, 0, strlen (buf)))
428 result |= 64; 454 result |= 64;
429 } 455 }
430#endif 456#endif
@@ -432,27 +458,43 @@ int main ()
432}]])], 458}]])],
433 [gl_cv_func_printf_infinite_long_double=yes], 459 [gl_cv_func_printf_infinite_long_double=yes],
434 [gl_cv_func_printf_infinite_long_double=no], 460 [gl_cv_func_printf_infinite_long_double=no],
435 [ 461 [case "$host_cpu" in
436changequote(,)dnl
437 case "$host_cpu" in
438 # Guess no on ia64, x86_64, i386. 462 # Guess no on ia64, x86_64, i386.
439 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; 463 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
440 *) 464 *)
441 case "$host_os" in 465 case "$host_os" in
466changequote(,)dnl
442 # Guess yes on glibc systems. 467 # Guess yes on glibc systems.
443 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; 468 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
469 # Guess yes on musl systems.
470 *-musl*) gl_cv_func_printf_infinite_long_double="guessing yes";;
444 # Guess yes on FreeBSD >= 6. 471 # Guess yes on FreeBSD >= 6.
445 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; 472 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
446 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; 473 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
474 midnightbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
447 # Guess yes on HP-UX >= 11. 475 # Guess yes on HP-UX >= 11.
448 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; 476 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
449 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; 477 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
450 # If we don't know, assume the worst. 478 # Guess yes on OpenBSD >= 6.0.
451 *) gl_cv_func_printf_infinite_long_double="guessing no";; 479 openbsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
480 openbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
481 # Guess no on Android.
482 linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";;
483changequote([,])dnl
484 # Guess yes on MSVC, no on mingw.
485 mingw*) AC_EGREP_CPP([Known], [
486#ifdef _MSC_VER
487 Known
488#endif
489 ],
490 [gl_cv_func_printf_infinite_long_double="guessing yes"],
491 [gl_cv_func_printf_infinite_long_double="guessing no"])
492 ;;
493 # If we don't know, obey --enable-cross-guesses.
494 *) gl_cv_func_printf_infinite_long_double="$gl_cross_guess_normal";;
452 esac 495 esac
453 ;; 496 ;;
454 esac 497 esac
455changequote([,])dnl
456 ]) 498 ])
457 ]) 499 ])
458 ;; 500 ;;
@@ -495,15 +537,22 @@ int main ()
495 && strcmp (buf, "-0X6.488P-1 33") != 0 537 && strcmp (buf, "-0X6.488P-1 33") != 0
496 && strcmp (buf, "-0XC.91P-2 33") != 0)) 538 && strcmp (buf, "-0XC.91P-2 33") != 0))
497 result |= 2; 539 result |= 2;
498 /* This catches a FreeBSD 6.1 bug: it doesn't round. */ 540 /* This catches a FreeBSD 13.0 bug: it doesn't round. */
499 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 541 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
500 || (strcmp (buf, "0x1.83p+0 33") != 0 542 || (strcmp (buf, "0x1.83p+0 33") != 0
501 && strcmp (buf, "0x3.05p-1 33") != 0 543 && strcmp (buf, "0x3.05p-1 33") != 0
502 && strcmp (buf, "0x6.0ap-2 33") != 0 544 && strcmp (buf, "0x6.0ap-2 33") != 0
503 && strcmp (buf, "0xc.14p-3 33") != 0)) 545 && strcmp (buf, "0xc.14p-3 33") != 0))
504 result |= 4; 546 result |= 4;
547 /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round. */
548 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0
549 || (strcmp (buf, "0x2p+0 33") != 0
550 && strcmp (buf, "0x3p-1 33") != 0
551 && strcmp (buf, "0x6p-2 33") != 0
552 && strcmp (buf, "0xcp-3 33") != 0))
553 result |= 4;
505 /* This catches a FreeBSD 6.1 bug. See 554 /* This catches a FreeBSD 6.1 bug. See
506 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ 555 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */
507 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 556 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
508 || buf[0] == '0') 557 || buf[0] == '0')
509 result |= 8; 558 result |= 8;
@@ -515,7 +564,7 @@ int main ()
515 && strcmp (buf, "0x8.0p-2") != 0)) 564 && strcmp (buf, "0x8.0p-2") != 0))
516 result |= 16; 565 result |= 16;
517 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a 566 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
518 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ 567 glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
519 if (sprintf (buf, "%.1La", 1.999L) < 0 568 if (sprintf (buf, "%.1La", 1.999L) < 0
520 || (strcmp (buf, "0x1.0p+1") != 0 569 || (strcmp (buf, "0x1.0p+1") != 0
521 && strcmp (buf, "0x2.0p+0") != 0 570 && strcmp (buf, "0x2.0p+0") != 0
@@ -529,7 +578,7 @@ int main ()
529 [ 578 [
530 case "$host_os" in 579 case "$host_os" in
531 # Guess yes on glibc >= 2.5 systems. 580 # Guess yes on glibc >= 2.5 systems.
532 *-gnu*) 581 *-gnu* | gnu*)
533 AC_EGREP_CPP([BZ2908], [ 582 AC_EGREP_CPP([BZ2908], [
534 #include <features.h> 583 #include <features.h>
535 #ifdef __GNU_LIBRARY__ 584 #ifdef __GNU_LIBRARY__
@@ -541,8 +590,14 @@ int main ()
541 [gl_cv_func_printf_directive_a="guessing yes"], 590 [gl_cv_func_printf_directive_a="guessing yes"],
542 [gl_cv_func_printf_directive_a="guessing no"]) 591 [gl_cv_func_printf_directive_a="guessing no"])
543 ;; 592 ;;
544 # If we don't know, assume the worst. 593 # Guess yes on musl systems.
545 *) gl_cv_func_printf_directive_a="guessing no";; 594 *-musl*) gl_cv_func_printf_directive_a="guessing yes";;
595 # Guess no on Android.
596 linux*-android*) gl_cv_func_printf_directive_a="guessing no";;
597 # Guess no on native Windows.
598 mingw*) gl_cv_func_printf_directive_a="guessing no";;
599 # If we don't know, obey --enable-cross-guesses.
600 *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";;
546 esac 601 esac
547 ]) 602 ])
548 ]) 603 ])
@@ -583,23 +638,40 @@ int main ()
583 [gl_cv_func_printf_directive_f=yes], 638 [gl_cv_func_printf_directive_f=yes],
584 [gl_cv_func_printf_directive_f=no], 639 [gl_cv_func_printf_directive_f=no],
585 [ 640 [
586changequote(,)dnl
587 case "$host_os" in 641 case "$host_os" in
642changequote(,)dnl
588 # Guess yes on glibc systems. 643 # Guess yes on glibc systems.
589 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; 644 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";;
645 # Guess yes on musl systems.
646 *-musl*) gl_cv_func_printf_directive_f="guessing yes";;
590 # Guess yes on FreeBSD >= 6. 647 # Guess yes on FreeBSD >= 6.
591 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; 648 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
592 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; 649 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
650 midnightbsd*) gl_cv_func_printf_directive_f="guessing yes";;
593 # Guess yes on Mac OS X >= 10.3. 651 # Guess yes on Mac OS X >= 10.3.
594 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; 652 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
595 darwin*) gl_cv_func_printf_directive_f="guessing yes";; 653 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
654 # Guess yes on OpenBSD >= 6.0.
655 openbsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
656 openbsd*) gl_cv_func_printf_directive_f="guessing yes";;
596 # Guess yes on Solaris >= 2.10. 657 # Guess yes on Solaris >= 2.10.
597 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; 658 solaris2.[1-9][0-9]*) gl_cv_func_printf_directive_f="guessing yes";;
598 solaris*) gl_cv_func_printf_sizes_c99="guessing no";; 659 solaris*) gl_cv_func_printf_directive_f="guessing no";;
599 # If we don't know, assume the worst. 660 # Guess no on Android.
600 *) gl_cv_func_printf_directive_f="guessing no";; 661 linux*-android*) gl_cv_func_printf_directive_f="guessing no";;
601 esac
602changequote([,])dnl 662changequote([,])dnl
663 # Guess yes on MSVC, no on mingw.
664 mingw*) AC_EGREP_CPP([Known], [
665#ifdef _MSC_VER
666 Known
667#endif
668 ],
669 [gl_cv_func_printf_directive_f="guessing yes"],
670 [gl_cv_func_printf_directive_f="guessing no"])
671 ;;
672 # If we don't know, obey --enable-cross-guesses.
673 *) gl_cv_func_printf_directive_f="$gl_cross_guess_normal";;
674 esac
603 ]) 675 ])
604 ]) 676 ])
605]) 677])
@@ -621,7 +693,10 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
621#include <stdlib.h> 693#include <stdlib.h>
622#include <string.h> 694#include <string.h>
623#ifdef _MSC_VER 695#ifdef _MSC_VER
624/* See page about "Parameter Validation" on msdn.microsoft.com. */ 696#include <inttypes.h>
697/* See page about "Parameter Validation" on msdn.microsoft.com.
698 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation>
699 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-invalid-parameter-handler-set-thread-local-invalid-parameter-handler> */
625static void cdecl 700static void cdecl
626invalid_parameter_handler (const wchar_t *expression, 701invalid_parameter_handler (const wchar_t *expression,
627 const wchar_t *function, 702 const wchar_t *function,
@@ -651,13 +726,23 @@ int main ()
651}]])], 726}]])],
652 [gl_cv_func_printf_directive_n=yes], 727 [gl_cv_func_printf_directive_n=yes],
653 [gl_cv_func_printf_directive_n=no], 728 [gl_cv_func_printf_directive_n=no],
654 [ 729 [case "$host_os" in
655changequote(,)dnl 730 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
656 case "$host_os" in 731 *-gnu* | gnu*) AC_COMPILE_IFELSE(
657 mingw*) gl_cv_func_printf_directive_n="guessing no";; 732 [AC_LANG_SOURCE(
658 *) gl_cv_func_printf_directive_n="guessing yes";; 733 [[#if _FORTIFY_SOURCE >= 2
734 error fail
735 #endif
736 ]])],
737 [gl_cv_func_printf_directive_n="guessing yes"],
738 [gl_cv_func_printf_directive_n="guessing no"])
739 ;;
740 # Guess no on Android.
741 linux*-android*) gl_cv_func_printf_directive_n="guessing no";;
742 # Guess no on native Windows.
743 mingw*) gl_cv_func_printf_directive_n="guessing no";;
744 *) gl_cv_func_printf_directive_n="guessing yes";;
659 esac 745 esac
660changequote([,])dnl
661 ]) 746 ])
662 ]) 747 ])
663]) 748])
@@ -678,13 +763,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
678 [ 763 [
679 AC_RUN_IFELSE( 764 AC_RUN_IFELSE(
680 [AC_LANG_SOURCE([[ 765 [AC_LANG_SOURCE([[
681/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
682 <wchar.h>.
683 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
684 included before <wchar.h>. */
685#include <stddef.h>
686#include <stdio.h> 766#include <stdio.h>
687#include <time.h>
688#include <wchar.h> 767#include <wchar.h>
689#include <string.h> 768#include <string.h>
690int main () 769int main ()
@@ -732,11 +811,17 @@ int main ()
732 [ 811 [
733changequote(,)dnl 812changequote(,)dnl
734 case "$host_os" in 813 case "$host_os" in
735 openbsd*) gl_cv_func_printf_directive_ls="guessing no";; 814 # Guess yes on OpenBSD >= 6.0.
815 openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";;
816 openbsd*) gl_cv_func_printf_directive_ls="guessing yes";;
736 irix*) gl_cv_func_printf_directive_ls="guessing no";; 817 irix*) gl_cv_func_printf_directive_ls="guessing no";;
737 solaris*) gl_cv_func_printf_directive_ls="guessing no";; 818 solaris*) gl_cv_func_printf_directive_ls="guessing no";;
738 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; 819 cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
739 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; 820 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
821 # Guess no on Android.
822 linux*-android*) gl_cv_func_printf_directive_ls="guessing no";;
823 # Guess yes on native Windows.
824 mingw*) gl_cv_func_printf_directive_ls="guessing yes";;
740 *) gl_cv_func_printf_directive_ls="guessing yes";; 825 *) gl_cv_func_printf_directive_ls="guessing yes";;
741 esac 826 esac
742changequote([,])dnl 827changequote([,])dnl
@@ -774,10 +859,13 @@ int main ()
774changequote(,)dnl 859changequote(,)dnl
775 case "$host_os" in 860 case "$host_os" in
776 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) 861 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
777 gl_cv_func_printf_positions="guessing no";; 862 gl_cv_func_printf_positions="guessing no";;
778 beos*) gl_cv_func_printf_positions="guessing no";; 863 beos*) gl_cv_func_printf_positions="guessing no";;
779 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; 864 # Guess yes on Android.
780 *) gl_cv_func_printf_positions="guessing yes";; 865 linux*-android*) gl_cv_func_printf_positions="guessing yes";;
866 # Guess no on native Windows.
867 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
868 *) gl_cv_func_printf_positions="guessing yes";;
781 esac 869 esac
782changequote([,])dnl 870changequote([,])dnl
783 ]) 871 ])
@@ -812,10 +900,13 @@ int main ()
812 [ 900 [
813changequote(,)dnl 901changequote(,)dnl
814 case "$host_os" in 902 case "$host_os" in
815 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; 903 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
816 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; 904 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
817 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; 905 # Guess no on Android.
818 *) gl_cv_func_printf_flag_grouping="guessing yes";; 906 linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";;
907 # Guess no on native Windows.
908 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
909 *) gl_cv_func_printf_flag_grouping="guessing yes";;
819 esac 910 esac
820changequote([,])dnl 911changequote([,])dnl
821 ]) 912 ])
@@ -824,7 +915,7 @@ changequote([,])dnl
824 915
825dnl Test whether the *printf family of functions supports the - flag correctly. 916dnl Test whether the *printf family of functions supports the - flag correctly.
826dnl (ISO C99.) See 917dnl (ISO C99.) See
827dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html> 918dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html>
828dnl Result is gl_cv_func_printf_flag_leftadjust. 919dnl Result is gl_cv_func_printf_flag_leftadjust.
829 920
830AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], 921AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
@@ -852,12 +943,16 @@ int main ()
852 [ 943 [
853changequote(,)dnl 944changequote(,)dnl
854 case "$host_os" in 945 case "$host_os" in
855 # Guess yes on HP-UX 11. 946 # Guess yes on HP-UX 11.
856 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 947 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
857 # Guess no on HP-UX 10 and older. 948 # Guess no on HP-UX 10 and older.
858 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; 949 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
859 # Guess yes otherwise. 950 # Guess yes on Android.
860 *) gl_cv_func_printf_flag_leftadjust="guessing yes";; 951 linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
952 # Guess yes on native Windows.
953 mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
954 # Guess yes otherwise.
955 *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
861 esac 956 esac
862changequote([,])dnl 957changequote([,])dnl
863 ]) 958 ])
@@ -866,7 +961,7 @@ changequote([,])dnl
866 961
867dnl Test whether the *printf family of functions supports padding of non-finite 962dnl Test whether the *printf family of functions supports padding of non-finite
868dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See 963dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
869dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> 964dnl <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html>
870dnl Result is gl_cv_func_printf_flag_zero. 965dnl Result is gl_cv_func_printf_flag_zero.
871 966
872AC_DEFUN([gl_PRINTF_FLAG_ZERO], 967AC_DEFUN([gl_PRINTF_FLAG_ZERO],
@@ -895,12 +990,18 @@ int main ()
895 [ 990 [
896changequote(,)dnl 991changequote(,)dnl
897 case "$host_os" in 992 case "$host_os" in
898 # Guess yes on glibc systems. 993 # Guess yes on glibc systems.
899 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; 994 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
900 # Guess yes on BeOS. 995 # Guess yes on musl systems.
901 beos*) gl_cv_func_printf_flag_zero="guessing yes";; 996 *-musl*) gl_cv_func_printf_flag_zero="guessing yes";;
902 # If we don't know, assume the worst. 997 # Guess yes on BeOS.
903 *) gl_cv_func_printf_flag_zero="guessing no";; 998 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
999 # Guess no on Android.
1000 linux*-android*) gl_cv_func_printf_flag_zero="guessing no";;
1001 # Guess no on native Windows.
1002 mingw*) gl_cv_func_printf_flag_zero="guessing no";;
1003 # If we don't know, obey --enable-cross-guesses.
1004 *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";;
904 esac 1005 esac
905changequote([,])dnl 1006changequote([,])dnl
906 ]) 1007 ])
@@ -953,10 +1054,12 @@ int main ()
953changequote(,)dnl 1054changequote(,)dnl
954 case "$host_os" in 1055 case "$host_os" in
955 # Guess no only on Solaris, native Windows, and BeOS systems. 1056 # Guess no only on Solaris, native Windows, and BeOS systems.
956 solaris*) gl_cv_func_printf_precision="guessing no" ;; 1057 solaris*) gl_cv_func_printf_precision="guessing no" ;;
957 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; 1058 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
958 beos*) gl_cv_func_printf_precision="guessing no" ;; 1059 beos*) gl_cv_func_printf_precision="guessing no" ;;
959 *) gl_cv_func_printf_precision="guessing yes" ;; 1060 # Guess yes on Android.
1061 linux*-android*) gl_cv_func_printf_precision="guessing yes" ;;
1062 *) gl_cv_func_printf_precision="guessing yes" ;;
960 esac 1063 esac
961changequote([,])dnl 1064changequote([,])dnl
962 ]) 1065 ])
@@ -978,9 +1081,8 @@ AC_DEFUN([gl_PRINTF_ENOMEM],
978 gl_cv_func_printf_enomem="guessing no" 1081 gl_cv_func_printf_enomem="guessing no"
979 if test "$cross_compiling" = no; then 1082 if test "$cross_compiling" = no; then
980 if test $APPLE_UNIVERSAL_BUILD = 0; then 1083 if test $APPLE_UNIVERSAL_BUILD = 0; then
981 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 1084 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
982]GL_NOCRASH[ 1085]GL_NOCRASH[
983changequote(,)dnl
984#include <stdio.h> 1086#include <stdio.h>
985#include <sys/types.h> 1087#include <sys/types.h>
986#include <sys/time.h> 1088#include <sys/time.h>
@@ -1025,8 +1127,7 @@ int main()
1025 ret = printf ("%.5000000f", 1.0); 1127 ret = printf ("%.5000000f", 1.0);
1026 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); 1128 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
1027} 1129}
1028changequote([,])dnl 1130 ]])])
1029 ])])
1030 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 1131 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
1031 (./conftest 2>&AS_MESSAGE_LOG_FD 1132 (./conftest 2>&AS_MESSAGE_LOG_FD
1032 result=$? 1133 result=$?
@@ -1053,28 +1154,30 @@ changequote([,])dnl
1053 if test "$gl_cv_func_printf_enomem" = "guessing no"; then 1154 if test "$gl_cv_func_printf_enomem" = "guessing no"; then
1054changequote(,)dnl 1155changequote(,)dnl
1055 case "$host_os" in 1156 case "$host_os" in
1056 # Guess yes on glibc systems. 1157 # Guess yes on glibc systems.
1057 *-gnu*) gl_cv_func_printf_enomem="guessing yes";; 1158 *-gnu* | gnu*) gl_cv_func_printf_enomem="guessing yes";;
1058 # Guess yes on Solaris. 1159 # Guess yes on Solaris.
1059 solaris*) gl_cv_func_printf_enomem="guessing yes";; 1160 solaris*) gl_cv_func_printf_enomem="guessing yes";;
1060 # Guess yes on AIX. 1161 # Guess yes on AIX.
1061 aix*) gl_cv_func_printf_enomem="guessing yes";; 1162 aix*) gl_cv_func_printf_enomem="guessing yes";;
1062 # Guess yes on HP-UX/hppa. 1163 # Guess yes on HP-UX/hppa.
1063 hpux*) case "$host_cpu" in 1164 hpux*) case "$host_cpu" in
1064 hppa*) gl_cv_func_printf_enomem="guessing yes";; 1165 hppa*) gl_cv_func_printf_enomem="guessing yes";;
1065 *) gl_cv_func_printf_enomem="guessing no";; 1166 *) gl_cv_func_printf_enomem="guessing no";;
1066 esac 1167 esac
1067 ;; 1168 ;;
1068 # Guess yes on IRIX. 1169 # Guess yes on IRIX.
1069 irix*) gl_cv_func_printf_enomem="guessing yes";; 1170 irix*) gl_cv_func_printf_enomem="guessing yes";;
1070 # Guess yes on OSF/1. 1171 # Guess yes on OSF/1.
1071 osf*) gl_cv_func_printf_enomem="guessing yes";; 1172 osf*) gl_cv_func_printf_enomem="guessing yes";;
1072 # Guess yes on BeOS. 1173 # Guess yes on BeOS.
1073 beos*) gl_cv_func_printf_enomem="guessing yes";; 1174 beos*) gl_cv_func_printf_enomem="guessing yes";;
1074 # Guess yes on Haiku. 1175 # Guess yes on Haiku.
1075 haiku*) gl_cv_func_printf_enomem="guessing yes";; 1176 haiku*) gl_cv_func_printf_enomem="guessing yes";;
1076 # If we don't know, assume the worst. 1177 # Guess no on Android.
1077 *) gl_cv_func_printf_enomem="guessing no";; 1178 linux*-android*) gl_cv_func_printf_enomem="guessing no";;
1179 # If we don't know, obey --enable-cross-guesses.
1180 *) gl_cv_func_printf_enomem="$gl_cross_guess_normal";;
1078 esac 1181 esac
1079changequote([,])dnl 1182changequote([,])dnl
1080 fi 1183 fi
@@ -1093,7 +1196,7 @@ dnl Test whether the string produced by the snprintf function is always NUL
1093dnl terminated. (ISO C99, POSIX:2001) 1196dnl terminated. (ISO C99, POSIX:2001)
1094dnl Result is gl_cv_func_snprintf_truncation_c99. 1197dnl Result is gl_cv_func_snprintf_truncation_c99.
1095 1198
1096AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], 1199AC_DEFUN_ONCE([gl_SNPRINTF_TRUNCATION_C99],
1097[ 1200[
1098 AC_REQUIRE([AC_PROG_CC]) 1201 AC_REQUIRE([AC_PROG_CC])
1099 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1202 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
@@ -1134,10 +1237,13 @@ int main ()
1134changequote(,)dnl 1237changequote(,)dnl
1135 case "$host_os" in 1238 case "$host_os" in
1136 # Guess yes on glibc systems. 1239 # Guess yes on glibc systems.
1137 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1240 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1241 # Guess yes on musl systems.
1242 *-musl*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1138 # Guess yes on FreeBSD >= 5. 1243 # Guess yes on FreeBSD >= 5.
1139 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1244 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1140 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1245 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1246 midnightbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1141 # Guess yes on Mac OS X >= 10.3. 1247 # Guess yes on Mac OS X >= 10.3.
1142 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1248 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1143 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1249 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
@@ -1166,8 +1272,12 @@ changequote(,)dnl
1166 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1272 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1167 # Guess yes on BeOS. 1273 # Guess yes on BeOS.
1168 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1274 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1169 # If we don't know, assume the worst. 1275 # Guess yes on Android.
1170 *) gl_cv_func_snprintf_truncation_c99="guessing no";; 1276 linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1277 # Guess no on native Windows.
1278 mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1279 # If we don't know, obey --enable-cross-guesses.
1280 *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";;
1171 esac 1281 esac
1172changequote([,])dnl 1282changequote([,])dnl
1173 ]) 1283 ])
@@ -1229,14 +1339,16 @@ int main ()
1229}]])], 1339}]])],
1230 [gl_cv_func_snprintf_retval_c99=yes], 1340 [gl_cv_func_snprintf_retval_c99=yes],
1231 [gl_cv_func_snprintf_retval_c99=no], 1341 [gl_cv_func_snprintf_retval_c99=no],
1232 [ 1342 [case "$host_os" in
1233changequote(,)dnl 1343changequote(,)dnl
1234 case "$host_os" in
1235 # Guess yes on glibc systems. 1344 # Guess yes on glibc systems.
1236 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1345 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1346 # Guess yes on musl systems.
1347 *-musl*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1237 # Guess yes on FreeBSD >= 5. 1348 # Guess yes on FreeBSD >= 5.
1238 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; 1349 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1239 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1350 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1351 midnightbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1240 # Guess yes on Mac OS X >= 10.3. 1352 # Guess yes on Mac OS X >= 10.3.
1241 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1353 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1242 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1354 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
@@ -1256,10 +1368,21 @@ changequote(,)dnl
1256 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1368 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1257 # Guess yes on BeOS. 1369 # Guess yes on BeOS.
1258 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1370 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1259 # If we don't know, assume the worst. 1371 # Guess yes on Android.
1260 *) gl_cv_func_snprintf_retval_c99="guessing no";; 1372 linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1261 esac
1262changequote([,])dnl 1373changequote([,])dnl
1374 # Guess yes on MSVC, no on mingw.
1375 mingw*) AC_EGREP_CPP([Known], [
1376#ifdef _MSC_VER
1377 Known
1378#endif
1379 ],
1380 [gl_cv_func_snprintf_retval_c99="guessing yes"],
1381 [gl_cv_func_snprintf_retval_c99="guessing no"])
1382 ;;
1383 # If we don't know, obey --enable-cross-guesses.
1384 *) gl_cv_func_snprintf_retval_c99="$gl_cross_guess_normal";;
1385 esac
1263 ]) 1386 ])
1264 ]) 1387 ])
1265]) 1388])
@@ -1311,13 +1434,24 @@ int main ()
1311 [gl_cv_func_snprintf_directive_n=yes], 1434 [gl_cv_func_snprintf_directive_n=yes],
1312 [gl_cv_func_snprintf_directive_n=no], 1435 [gl_cv_func_snprintf_directive_n=no],
1313 [ 1436 [
1314changequote(,)dnl
1315 case "$host_os" in 1437 case "$host_os" in
1316 # Guess yes on glibc systems. 1438 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
1317 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; 1439 *-gnu* | gnu*) AC_COMPILE_IFELSE(
1440 [AC_LANG_SOURCE(
1441 [[#if _FORTIFY_SOURCE >= 2
1442 error fail
1443 #endif
1444 ]])],
1445 [gl_cv_func_snprintf_directive_n="guessing yes"],
1446 [gl_cv_func_snprintf_directive_n="guessing no"])
1447 ;;
1448changequote(,)dnl
1449 # Guess yes on musl systems.
1450 *-musl*) gl_cv_func_snprintf_directive_n="guessing yes";;
1318 # Guess yes on FreeBSD >= 5. 1451 # Guess yes on FreeBSD >= 5.
1319 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; 1452 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";;
1320 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1453 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1454 midnightbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1321 # Guess yes on Mac OS X >= 10.3. 1455 # Guess yes on Mac OS X >= 10.3.
1322 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; 1456 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
1323 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; 1457 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
@@ -1339,10 +1473,14 @@ changequote(,)dnl
1339 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1473 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1340 # Guess yes on BeOS. 1474 # Guess yes on BeOS.
1341 beos*) gl_cv_func_snprintf_directive_n="guessing yes";; 1475 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
1342 # If we don't know, assume the worst. 1476 # Guess no on Android.
1343 *) gl_cv_func_snprintf_directive_n="guessing no";; 1477 linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";;
1344 esac 1478 # Guess no on native Windows.
1479 mingw*) gl_cv_func_snprintf_directive_n="guessing no";;
1480 # If we don't know, obey --enable-cross-guesses.
1481 *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";;
1345changequote([,])dnl 1482changequote([,])dnl
1483 esac
1346 ]) 1484 ])
1347 ]) 1485 ])
1348]) 1486])
@@ -1355,6 +1493,7 @@ dnl Result is gl_cv_func_snprintf_size1.
1355AC_DEFUN([gl_SNPRINTF_SIZE1], 1493AC_DEFUN([gl_SNPRINTF_SIZE1],
1356[ 1494[
1357 AC_REQUIRE([AC_PROG_CC]) 1495 AC_REQUIRE([AC_PROG_CC])
1496 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1358 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) 1497 AC_REQUIRE([gl_SNPRINTF_PRESENCE])
1359 AC_CACHE_CHECK([whether snprintf respects a size of 1], 1498 AC_CACHE_CHECK([whether snprintf respects a size of 1],
1360 [gl_cv_func_snprintf_size1], 1499 [gl_cv_func_snprintf_size1],
@@ -1384,7 +1523,14 @@ int main()
1384}]])], 1523}]])],
1385 [gl_cv_func_snprintf_size1=yes], 1524 [gl_cv_func_snprintf_size1=yes],
1386 [gl_cv_func_snprintf_size1=no], 1525 [gl_cv_func_snprintf_size1=no],
1387 [gl_cv_func_snprintf_size1="guessing yes"]) 1526 [case "$host_os" in
1527 # Guess yes on Android.
1528 linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;;
1529 # Guess yes on native Windows.
1530 mingw*) gl_cv_func_snprintf_size1="guessing yes" ;;
1531 *) gl_cv_func_snprintf_size1="guessing yes" ;;
1532 esac
1533 ])
1388 ]) 1534 ])
1389]) 1535])
1390 1536
@@ -1456,10 +1602,13 @@ int main()
1456changequote(,)dnl 1602changequote(,)dnl
1457 case "$host_os" in 1603 case "$host_os" in
1458 # Guess yes on glibc systems. 1604 # Guess yes on glibc systems.
1459 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1605 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1606 # Guess yes on musl systems.
1607 *-musl*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1460 # Guess yes on FreeBSD >= 5. 1608 # Guess yes on FreeBSD >= 5.
1461 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1609 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1462 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1610 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1611 midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1463 # Guess yes on Mac OS X >= 10.3. 1612 # Guess yes on Mac OS X >= 10.3.
1464 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1613 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1465 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1614 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
@@ -1480,10 +1629,12 @@ changequote(,)dnl
1480 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1629 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1481 # Guess yes on BeOS. 1630 # Guess yes on BeOS.
1482 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1631 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1483 # Guess yes on mingw. 1632 # Guess yes on Android.
1633 linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1634 # Guess yes on native Windows.
1484 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1635 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1485 # If we don't know, assume the worst. 1636 # If we don't know, obey --enable-cross-guesses.
1486 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1637 *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";;
1487 esac 1638 esac
1488changequote([,])dnl 1639changequote([,])dnl
1489 ]) 1640 ])
@@ -1539,14 +1690,19 @@ dnl
1539dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1690dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1540dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . 1691dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . .
1541dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . 1692dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . .
1693dnl FreeBSD 13.0 . . . . # . . . . . . . . # . . . . . .
1542dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . 1694dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . .
1695dnl Mac OS X 10.13.5 . . . # # . # . . . . . . . . . . # . .
1543dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . 1696dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . .
1544dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . 1697dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . .
1698dnl OpenBSD 6.0, 6.7 . . . . # . . . . . . . . # . . . . . .
1545dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . 1699dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . .
1546dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . 1700dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . .
1547dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . 1701dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . .
1548dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . 1702dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . .
1549dnl Solaris 11 2011-11 . . # # # . . # . . . # . . . . . . . . 1703dnl Solaris 11.4 . . # # # . . # . . . # . . . . . . . .
1704dnl Solaris 11.3 . . . . # . . # . . . . . . . . . . . .
1705dnl Solaris 11.0 . . # # # . . # . . . # . . . . . . . .
1550dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . 1706dnl Solaris 10 . . # # # . . # . . . # # . . . . . . .
1551dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . 1707dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . .
1552dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # 1708dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # #
@@ -1559,11 +1715,13 @@ dnl HP-UX 10.20 # . # . # # . ? . . # # . . .
1559dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . 1715dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . .
1560dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # 1716dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . #
1561dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # 1717dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # #
1718dnl NetBSD 9.0 . . . . # . . . . . . . . . . . . . . .
1562dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . 1719dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . .
1563dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? 1720dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ?
1564dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . 1721dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . .
1565dnl Haiku . . . # # # . # . . . . . ? . . ? . . . 1722dnl Haiku . . . # # # . # . . . . . ? . . ? . . .
1566dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . 1723dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . .
1724dnl Android 4.3 . . # # # # # # . # . # . # . . . # . .
1567dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . 1725dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . .
1568dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . 1726dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . .
1569dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . 1727dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . .
diff --git a/gl/m4/progtest.m4 b/gl/m4/progtest.m4
deleted file mode 100644
index 7b391232..00000000
--- a/gl/m4/progtest.m4
+++ /dev/null
@@ -1,91 +0,0 @@
1# progtest.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1996-2003, 2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
18
19AC_PREREQ([2.50])
20
21# Search path for a program which passes the given test.
22
23dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
24dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
25AC_DEFUN([AM_PATH_PROG_WITH_TEST],
26[
27# Prepare PATH_SEPARATOR.
28# The user is always right.
29if test "${PATH_SEPARATOR+set}" != set; then
30 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
31 # contains only /bin. Note that ksh looks also at the FPATH variable,
32 # so we have to set that as well for the test.
33 PATH_SEPARATOR=:
34 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
35 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
36 || PATH_SEPARATOR=';'
37 }
38fi
39
40# Find out how to test for executable files. Don't use a zero-byte file,
41# as systems may use methods other than mode bits to determine executability.
42cat >conf$$.file <<_ASEOF
43#! /bin/sh
44exit 0
45_ASEOF
46chmod +x conf$$.file
47if test -x conf$$.file >/dev/null 2>&1; then
48 ac_executable_p="test -x"
49else
50 ac_executable_p="test -f"
51fi
52rm -f conf$$.file
53
54# Extract the first word of "$2", so it can be a program name with args.
55set dummy $2; ac_word=[$]2
56AC_MSG_CHECKING([for $ac_word])
57AC_CACHE_VAL([ac_cv_path_$1],
58[case "[$]$1" in
59 [[\\/]]* | ?:[[\\/]]*)
60 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
61 ;;
62 *)
63 ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
64 for ac_dir in ifelse([$5], , $PATH, [$5]); do
65 IFS="$ac_save_IFS"
66 test -z "$ac_dir" && ac_dir=.
67 for ac_exec_ext in '' $ac_executable_extensions; do
68 if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
69 echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD
70 if [$3]; then
71 ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
72 break 2
73 fi
74 fi
75 done
76 done
77 IFS="$ac_save_IFS"
78dnl If no 4th arg is given, leave the cache variable unset,
79dnl so AC_PATH_PROGS will keep looking.
80ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
81])dnl
82 ;;
83esac])dnl
84$1="$ac_cv_path_$1"
85if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
86 AC_MSG_RESULT([$][$1])
87else
88 AC_MSG_RESULT([no])
89fi
90AC_SUBST([$1])dnl
91])
diff --git a/gl/m4/pthread_rwlock_rdlock.m4 b/gl/m4/pthread_rwlock_rdlock.m4
new file mode 100644
index 00000000..ae6a8853
--- /dev/null
+++ b/gl/m4/pthread_rwlock_rdlock.m4
@@ -0,0 +1,185 @@
1# pthread_rwlock_rdlock.m4 serial 4
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Inspired by
9dnl https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
10dnl by Intel Corporation.
11
12dnl Test whether in a situation where
13dnl - an rwlock is taken by a reader and has a writer waiting,
14dnl - an additional reader requests the lock,
15dnl - the waiting writer and the requesting reader threads have the same
16dnl priority,
17dnl the requesting reader thread gets blocked, so that at some point the
18dnl waiting writer can acquire the lock.
19dnl Without such a guarantee, when there a N readers and each of the readers
20dnl spends more than 1/Nth of the time with the lock held, there is a high
21dnl probability that the waiting writer will not get the lock in a given finite
22dnl time, a phenomenon called "writer starvation".
23dnl Without such a guarantee, applications have a hard time avoiding writer
24dnl starvation.
25dnl
26dnl POSIX:2017 makes this requirement only for implementations that support TPS
27dnl (Thread Priority Scheduling) and only for the scheduling policies SCHED_FIFO
28dnl and SCHED_RR, see
29dnl https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html
30dnl but this test verifies the guarantee regardless of TPS and regardless of
31dnl scheduling policy.
32dnl Glibc does not provide this guarantee (and never will on Linux), see
33dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701
34dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052
35AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER],
36[
37 AC_REQUIRE([gl_THREADLIB_EARLY])
38 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
39 AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader],
40 [gl_cv_pthread_rwlock_rdlock_prefer_writer],
41 [save_LIBS="$LIBS"
42 LIBS="$LIBS $LIBMULTITHREAD"
43 AC_RUN_IFELSE(
44 [AC_LANG_SOURCE([[
45#include <errno.h>
46#include <pthread.h>
47#include <stdlib.h>
48#include <unistd.h>
49
50#define SUCCEED() exit (0)
51#define FAILURE() exit (1)
52#define UNEXPECTED(n) (exit (10 + (n)))
53
54/* The main thread creates the waiting writer and the requesting reader threads
55 in the default way; this guarantees that they have the same priority.
56 We can reuse the main thread as first reader thread. */
57
58static pthread_rwlock_t lock;
59static pthread_t reader1;
60static pthread_t writer;
61static pthread_t reader2;
62static pthread_t timer;
63/* Used to pass control from writer to reader2 and from reader2 to timer,
64 as in a relay race.
65 Passing control from one running thread to another running thread
66 is most likely faster than to create the second thread. */
67static pthread_mutex_t baton;
68
69static void *
70timer_func (void *ignored)
71{
72 /* Step 13 (can be before or after step 12):
73 The timer thread takes the baton, then waits a moment to make sure
74 it can tell whether the second reader thread is blocked at step 12. */
75 if (pthread_mutex_lock (&baton))
76 UNEXPECTED (13);
77 usleep (100000);
78 /* By the time we get here, it's clear that the second reader thread is
79 blocked at step 12. This is the desired behaviour. */
80 SUCCEED ();
81}
82
83static void *
84reader2_func (void *ignored)
85{
86 int err;
87
88 /* Step 8 (can be before or after step 7):
89 The second reader thread takes the baton, then waits a moment to make sure
90 the writer thread has reached step 7. */
91 if (pthread_mutex_lock (&baton))
92 UNEXPECTED (8);
93 usleep (100000);
94 /* Step 9: The second reader thread requests the lock. */
95 err = pthread_rwlock_tryrdlock (&lock);
96 if (err == 0)
97 FAILURE ();
98 else if (err != EBUSY)
99 UNEXPECTED (9);
100 /* Step 10: Launch a timer, to test whether the next call blocks. */
101 if (pthread_create (&timer, NULL, timer_func, NULL))
102 UNEXPECTED (10);
103 /* Step 11: Release the baton. */
104 if (pthread_mutex_unlock (&baton))
105 UNEXPECTED (11);
106 /* Step 12: The second reader thread requests the lock. */
107 err = pthread_rwlock_rdlock (&lock);
108 if (err == 0)
109 FAILURE ();
110 else
111 UNEXPECTED (12);
112}
113
114static void *
115writer_func (void *ignored)
116{
117 /* Step 4: Take the baton, so that the second reader thread does not go ahead
118 too early. */
119 if (pthread_mutex_lock (&baton))
120 UNEXPECTED (4);
121 /* Step 5: Create the second reader thread. */
122 if (pthread_create (&reader2, NULL, reader2_func, NULL))
123 UNEXPECTED (5);
124 /* Step 6: Release the baton. */
125 if (pthread_mutex_unlock (&baton))
126 UNEXPECTED (6);
127 /* Step 7: The writer thread requests the lock. */
128 if (pthread_rwlock_wrlock (&lock))
129 UNEXPECTED (7);
130 return NULL;
131}
132
133int
134main ()
135{
136 reader1 = pthread_self ();
137
138 /* Step 1: The main thread initializes the lock and the baton. */
139 if (pthread_rwlock_init (&lock, NULL))
140 UNEXPECTED (1);
141 if (pthread_mutex_init (&baton, NULL))
142 UNEXPECTED (1);
143 /* Step 2: The main thread acquires the lock as a reader. */
144 if (pthread_rwlock_rdlock (&lock))
145 UNEXPECTED (2);
146 /* Step 3: Create the writer thread. */
147 if (pthread_create (&writer, NULL, writer_func, NULL))
148 UNEXPECTED (3);
149 /* Job done. Go to sleep. */
150 for (;;)
151 {
152 sleep (1);
153 }
154}
155]])],
156 [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes],
157 [gl_cv_pthread_rwlock_rdlock_prefer_writer=no],
158 [case "$host_os" in
159 # Guess no on glibc systems.
160 *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
161 # Guess no on musl systems.
162 *-musl*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
163 # Guess no on bionic systems.
164 *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
165 # Guess yes on native Windows with the mingw-w64 winpthreads library.
166 # Guess no on native Windows with the gnulib windows-rwlock module.
167 mingw*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
168 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"
169 else
170 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no"
171 fi
172 ;;
173 # If we don't know, obey --enable-cross-guesses.
174 *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;;
175 esac
176 ])
177 LIBS="$save_LIBS"
178 ])
179 case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in
180 *yes)
181 AC_DEFINE([HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], [1],
182 [Define if the 'pthread_rwlock_rdlock' function prefers a writer to a reader.])
183 ;;
184 esac
185])
diff --git a/gl/m4/read.m4 b/gl/m4/read.m4
deleted file mode 100644
index 81f0f3a9..00000000
--- a/gl/m4/read.m4
+++ /dev/null
@@ -1,26 +0,0 @@
1# read.m4 serial 4
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_READ],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([gl_MSVC_INVAL])
11 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
12 REPLACE_READ=1
13 fi
14 dnl This ifdef is just an optimization, to avoid performing a configure
15 dnl check whose result is not used. It does not make the test of
16 dnl GNULIB_UNISTD_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
17 m4_ifdef([gl_NONBLOCKING_IO], [
18 gl_NONBLOCKING_IO
19 if test $gl_cv_have_nonblocking != yes; then
20 REPLACE_READ=1
21 fi
22 ])
23])
24
25# Prerequisites of lib/read.c.
26AC_DEFUN([gl_PREREQ_READ], [:])
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
new file mode 100644
index 00000000..d22138fc
--- /dev/null
+++ b/gl/m4/realloc.m4
@@ -0,0 +1,63 @@
1# realloc.m4 serial 26
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# This is adapted with modifications from upstream Autoconf here:
8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455
9AC_DEFUN([_AC_FUNC_REALLOC_IF],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
12 AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull],
13 [ac_cv_func_realloc_0_nonnull],
14 [AC_RUN_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stdlib.h>
17 ]],
18 [[void *p = realloc (0, 0);
19 int result = !p;
20 free (p);
21 return result;]])
22 ],
23 [ac_cv_func_realloc_0_nonnull=yes],
24 [ac_cv_func_realloc_0_nonnull=no],
25 [case "$host_os" in
26 # Guess yes on platforms where we know the result.
27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
28 | gnu* | *-musl* | midnightbsd* \
29 | hpux* | solaris* | cygwin* | mingw* | msys* )
30 ac_cv_func_realloc_0_nonnull="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;;
33 esac
34 ])
35 ])
36 AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
37])# AC_FUNC_REALLOC
38
39# gl_FUNC_REALLOC_GNU
40# -------------------
41# Replace realloc if it is not compatible with GNU libc.
42AC_DEFUN([gl_FUNC_REALLOC_GNU],
43[
44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
45 AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
46 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
47 _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
48 fi
49])# gl_FUNC_REALLOC_GNU
50
51# gl_FUNC_REALLOC_POSIX
52# ---------------------
53# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
54# fails, and doesn't mess up with ptrdiff_t overflow),
55# and replace realloc if it is not.
56AC_DEFUN([gl_FUNC_REALLOC_POSIX],
57[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
60 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
61 REPLACE_REALLOC_FOR_REALLOC_POSIX=1
62 fi
63])
diff --git a/gl/m4/reallocarray.m4 b/gl/m4/reallocarray.m4
new file mode 100644
index 00000000..1607b7a9
--- /dev/null
+++ b/gl/m4/reallocarray.m4
@@ -0,0 +1,23 @@
1# reallocarray.m4 serial 3
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_REALLOCARRAY],
8[
9 dnl Persuade glibc <stdlib.h> to declare reallocarray.
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
13 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
14 AC_CHECK_FUNCS([reallocarray])
15 if test "$ac_cv_func_reallocarray" = no; then
16 HAVE_REALLOCARRAY=0
17 elif test "$gl_cv_malloc_ptrdiff" = no; then
18 REPLACE_REALLOCARRAY=1
19 fi
20])
21
22# Prerequisites of lib/reallocarray.c.
23AC_DEFUN([gl_PREREQ_REALLOCARRAY], [:])
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4
index 0945c11a..c89a1432 100644
--- a/gl/m4/regex.m4
+++ b/gl/m4/regex.m4
@@ -1,6 +1,6 @@
1# serial 64 1# serial 73
2 2
3# Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc. 3# Copyright (C) 1996-2001, 2003-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
@@ -13,6 +13,7 @@ AC_PREREQ([2.50])
13 13
14AC_DEFUN([gl_REGEX], 14AC_DEFUN([gl_REGEX],
15[ 15[
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16 AC_ARG_WITH([included-regex], 17 AC_ARG_WITH([included-regex],
17 [AS_HELP_STRING([--without-included-regex], 18 [AS_HELP_STRING([--without-included-regex],
18 [don't compile regex; this is the default on systems 19 [don't compile regex; this is the default on systems
@@ -28,6 +29,7 @@ AC_DEFUN([gl_REGEX],
28 # If cross compiling, assume the test would fail and use the included 29 # If cross compiling, assume the test would fail and use the included
29 # regex.c. 30 # regex.c.
30 AC_CHECK_DECLS_ONCE([alarm]) 31 AC_CHECK_DECLS_ONCE([alarm])
32 AC_CHECK_HEADERS_ONCE([malloc.h])
31 AC_CACHE_CHECK([for working re_compile_pattern], 33 AC_CACHE_CHECK([for working re_compile_pattern],
32 [gl_cv_func_re_compile_pattern_working], 34 [gl_cv_func_re_compile_pattern_working],
33 [AC_RUN_IFELSE( 35 [AC_RUN_IFELSE(
@@ -37,9 +39,19 @@ AC_DEFUN([gl_REGEX],
37 #include <locale.h> 39 #include <locale.h>
38 #include <limits.h> 40 #include <limits.h>
39 #include <string.h> 41 #include <string.h>
40 #if HAVE_DECL_ALARM 42
41 # include <unistd.h> 43 #if defined M_CHECK_ACTION || HAVE_DECL_ALARM
42 # include <signal.h> 44 # include <signal.h>
45 # include <unistd.h>
46 #endif
47
48 #if HAVE_MALLOC_H
49 # include <malloc.h>
50 #endif
51
52 #ifdef M_CHECK_ACTION
53 /* Exit with distinguishable exit code. */
54 static void sigabrt_no_core (int sig) { raise (SIGTERM); }
43 #endif 55 #endif
44 ]], 56 ]],
45 [[int result = 0; 57 [[int result = 0;
@@ -49,15 +61,22 @@ AC_DEFUN([gl_REGEX],
49 const char *s; 61 const char *s;
50 struct re_registers regs; 62 struct re_registers regs;
51 63
64 /* Some builds of glibc go into an infinite loop on this
65 test. Use alarm to force death, and mallopt to avoid
66 malloc recursion in diagnosing the corrupted heap. */
52#if HAVE_DECL_ALARM 67#if HAVE_DECL_ALARM
53 /* Some builds of glibc go into an infinite loop on this test. */
54 signal (SIGALRM, SIG_DFL); 68 signal (SIGALRM, SIG_DFL);
55 alarm (2); 69 alarm (2);
56#endif 70#endif
71#ifdef M_CHECK_ACTION
72 signal (SIGABRT, sigabrt_no_core);
73 mallopt (M_CHECK_ACTION, 2);
74#endif
75
57 if (setlocale (LC_ALL, "en_US.UTF-8")) 76 if (setlocale (LC_ALL, "en_US.UTF-8"))
58 { 77 {
59 { 78 {
60 /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html 79 /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
61 This test needs valgrind to catch the bug on Debian 80 This test needs valgrind to catch the bug on Debian
62 GNU/Linux 3.1 x86, but it might catch the bug better 81 GNU/Linux 3.1 x86, but it might catch the bug better
63 on other platforms and it shouldn't hurt to try the 82 on other platforms and it shouldn't hurt to try the
@@ -71,16 +90,20 @@ AC_DEFUN([gl_REGEX],
71 s = re_compile_pattern (pat, sizeof pat - 1, &regex); 90 s = re_compile_pattern (pat, sizeof pat - 1, &regex);
72 if (s) 91 if (s)
73 result |= 1; 92 result |= 1;
74 else if (re_search (&regex, data, sizeof data - 1, 93 else
75 0, sizeof data - 1, &regs) 94 {
76 != -1) 95 if (re_search (&regex, data, sizeof data - 1,
77 result |= 1; 96 0, sizeof data - 1, &regs)
97 != -1)
98 result |= 1;
99 regfree (&regex);
100 }
78 } 101 }
79 102
80 { 103 {
81 /* This test is from glibc bug 15078. 104 /* This test is from glibc bug 15078.
82 The test case is from Andreas Schwab in 105 The test case is from Andreas Schwab in
83 <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>. 106 <https://sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
84 */ 107 */
85 static char const pat[] = "[^x]x"; 108 static char const pat[] = "[^x]x";
86 static char const data[] = 109 static char const data[] =
@@ -105,6 +128,7 @@ AC_DEFUN([gl_REGEX],
105 0, sizeof data - 1, 0); 128 0, sizeof data - 1, 0);
106 if (i != 0 && i != 21) 129 if (i != 0 && i != 21)
107 result |= 1; 130 result |= 1;
131 regfree (&regex);
108 } 132 }
109 } 133 }
110 134
@@ -118,9 +142,13 @@ AC_DEFUN([gl_REGEX],
118 s = re_compile_pattern ("a[^x]b", 6, &regex); 142 s = re_compile_pattern ("a[^x]b", 6, &regex);
119 if (s) 143 if (s)
120 result |= 2; 144 result |= 2;
121 /* This should fail, but succeeds for glibc-2.5. */ 145 else
122 else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1) 146 {
123 result |= 2; 147 /* This should fail, but succeeds for glibc-2.5. */
148 if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
149 result |= 2;
150 regfree (&regex);
151 }
124 152
125 /* This regular expression is from Spencer ere test number 75 153 /* This regular expression is from Spencer ere test number 75
126 in grep-2.3. */ 154 in grep-2.3. */
@@ -132,7 +160,10 @@ AC_DEFUN([gl_REGEX],
132 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex); 160 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex);
133 /* This should fail with _Invalid character class name_ error. */ 161 /* This should fail with _Invalid character class name_ error. */
134 if (!s) 162 if (!s)
135 result |= 4; 163 {
164 result |= 4;
165 regfree (&regex);
166 }
136 167
137 /* Ensure that [b-a] is diagnosed as invalid, when 168 /* Ensure that [b-a] is diagnosed as invalid, when
138 using RE_NO_EMPTY_RANGES. */ 169 using RE_NO_EMPTY_RANGES. */
@@ -140,13 +171,18 @@ AC_DEFUN([gl_REGEX],
140 memset (&regex, 0, sizeof regex); 171 memset (&regex, 0, sizeof regex);
141 s = re_compile_pattern ("a[b-a]", 6, &regex); 172 s = re_compile_pattern ("a[b-a]", 6, &regex);
142 if (s == 0) 173 if (s == 0)
143 result |= 8; 174 {
175 result |= 8;
176 regfree (&regex);
177 }
144 178
145 /* This should succeed, but does not for glibc-2.1.3. */ 179 /* This should succeed, but does not for glibc-2.1.3. */
146 memset (&regex, 0, sizeof regex); 180 memset (&regex, 0, sizeof regex);
147 s = re_compile_pattern ("{1", 2, &regex); 181 s = re_compile_pattern ("{1", 2, &regex);
148 if (s) 182 if (s)
149 result |= 8; 183 result |= 8;
184 else
185 regfree (&regex);
150 186
151 /* The following example is derived from a problem report 187 /* The following example is derived from a problem report
152 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ 188 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
@@ -154,17 +190,35 @@ AC_DEFUN([gl_REGEX],
154 s = re_compile_pattern ("[an\371]*n", 7, &regex); 190 s = re_compile_pattern ("[an\371]*n", 7, &regex);
155 if (s) 191 if (s)
156 result |= 8; 192 result |= 8;
157 /* This should match, but does not for glibc-2.2.1. */ 193 else
158 else if (re_match (&regex, "an", 2, 0, &regs) != 2) 194 {
159 result |= 8; 195 /* This should match, but does not for glibc-2.2.1. */
196 if (re_match (&regex, "an", 2, 0, &regs) != 2)
197 result |= 8;
198 else
199 {
200 free (regs.start);
201 free (regs.end);
202 }
203 regfree (&regex);
204 }
160 205
161 memset (&regex, 0, sizeof regex); 206 memset (&regex, 0, sizeof regex);
162 s = re_compile_pattern ("x", 1, &regex); 207 s = re_compile_pattern ("x", 1, &regex);
163 if (s) 208 if (s)
164 result |= 8; 209 result |= 8;
165 /* glibc-2.2.93 does not work with a negative RANGE argument. */ 210 else
166 else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1) 211 {
167 result |= 8; 212 /* glibc-2.2.93 does not work with a negative RANGE argument. */
213 if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
214 result |= 8;
215 else
216 {
217 free (regs.start);
218 free (regs.end);
219 }
220 regfree (&regex);
221 }
168 222
169 /* The version of regex.c in older versions of gnulib 223 /* The version of regex.c in older versions of gnulib
170 ignored RE_ICASE. Detect that problem too. */ 224 ignored RE_ICASE. Detect that problem too. */
@@ -173,25 +227,89 @@ AC_DEFUN([gl_REGEX],
173 s = re_compile_pattern ("x", 1, &regex); 227 s = re_compile_pattern ("x", 1, &regex);
174 if (s) 228 if (s)
175 result |= 16; 229 result |= 16;
176 else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0) 230 else
177 result |= 16; 231 {
232 if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
233 result |= 16;
234 else
235 {
236 free (regs.start);
237 free (regs.end);
238 }
239 regfree (&regex);
240 }
178 241
179 /* Catch a bug reported by Vin Shelton in 242 /* Catch a bug reported by Vin Shelton in
180 http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html 243 https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html
181 */ 244 */
182 re_set_syntax (RE_SYNTAX_POSIX_BASIC 245 re_set_syntax (RE_SYNTAX_POSIX_BASIC
183 & ~RE_CONTEXT_INVALID_DUP 246 & ~RE_CONTEXT_INVALID_DUP
184 & ~RE_NO_EMPTY_RANGES); 247 & ~RE_NO_EMPTY_RANGES);
185 memset (&regex, 0, sizeof regex); 248 memset (&regex, 0, sizeof regex);
186 s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex); 249 s = re_compile_pattern ("[[:alnum:]_-]\\\\+\$", 16, &regex);
187 if (s) 250 if (s)
188 result |= 32; 251 result |= 32;
252 else
253 regfree (&regex);
189 254
190 /* REG_STARTEND was added to glibc on 2004-01-15. 255 /* REG_STARTEND was added to glibc on 2004-01-15.
191 Reject older versions. */ 256 Reject older versions. */
192 if (! REG_STARTEND) 257 if (! REG_STARTEND)
193 result |= 64; 258 result |= 64;
194 259
260 /* Matching with the compiled form of this regexp would provoke
261 an assertion failure prior to glibc-2.28:
262 regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed
263 With glibc-2.28, compilation fails and reports the invalid
264 back reference. */
265 re_set_syntax (RE_SYNTAX_POSIX_EGREP);
266 memset (&regex, 0, sizeof regex);
267 s = re_compile_pattern ("0|()0|\\\\1|0", 10, &regex);
268 if (!s)
269 {
270 memset (&regs, 0, sizeof regs);
271 i = re_search (&regex, "x", 1, 0, 1, &regs);
272 if (i != -1)
273 result |= 64;
274 if (0 <= i)
275 {
276 free (regs.start);
277 free (regs.end);
278 }
279 regfree (&regex);
280 }
281 else
282 {
283 if (strcmp (s, "Invalid back reference"))
284 result |= 64;
285 }
286
287 /* glibc bug 11053. */
288 re_set_syntax (RE_SYNTAX_POSIX_BASIC);
289 memset (&regex, 0, sizeof regex);
290 static char const pat_sub2[] = "\\\\(a*\\\\)*a*\\\\1";
291 s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, &regex);
292 if (s)
293 result |= 64;
294 else
295 {
296 memset (&regs, 0, sizeof regs);
297 static char const data[] = "a";
298 int datalen = sizeof data - 1;
299 i = re_search (&regex, data, datalen, 0, datalen, &regs);
300 if (i != 0)
301 result |= 64;
302 else if (regs.num_regs < 2)
303 result |= 64;
304 else if (! (regs.start[0] == 0 && regs.end[0] == 1))
305 result |= 64;
306 else if (! (regs.start[1] == 0 && regs.end[1] == 0))
307 result |= 64;
308 regfree (&regex);
309 free (regs.start);
310 free (regs.end);
311 }
312
195#if 0 313#if 0
196 /* It would be nice to reject hosts whose regoff_t values are too 314 /* It would be nice to reject hosts whose regoff_t values are too
197 narrow (including glibc on hosts with 64-bit ptrdiff_t and 315 narrow (including glibc on hosts with 64-bit ptrdiff_t and
@@ -206,13 +324,19 @@ AC_DEFUN([gl_REGEX],
206 324
207 return result; 325 return result;
208 ]])], 326 ]])],
209 [gl_cv_func_re_compile_pattern_working=yes], 327 [gl_cv_func_re_compile_pattern_working=yes],
210 [gl_cv_func_re_compile_pattern_working=no], 328 [gl_cv_func_re_compile_pattern_working=no],
211 dnl When crosscompiling, assume it is not working. 329 [case "$host_os" in
212 [gl_cv_func_re_compile_pattern_working=no])]) 330 # Guess no on native Windows.
213 case $gl_cv_func_re_compile_pattern_working in #( 331 mingw*) gl_cv_func_re_compile_pattern_working="guessing no" ;;
214 yes) ac_use_included_regex=no;; #( 332 # Otherwise obey --enable-cross-guesses.
215 no) ac_use_included_regex=yes;; 333 *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;;
334 esac
335 ])
336 ])
337 case "$gl_cv_func_re_compile_pattern_working" in #(
338 *yes) ac_use_included_regex=no;; #(
339 *no) ac_use_included_regex=yes;;
216 esac 340 esac
217 ;; 341 ;;
218 *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex]) 342 *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
@@ -266,8 +390,7 @@ AC_DEFUN([gl_PREREQ_REGEX],
266 AC_REQUIRE([AC_C_RESTRICT]) 390 AC_REQUIRE([AC_C_RESTRICT])
267 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 391 AC_REQUIRE([AC_TYPE_MBSTATE_T])
268 AC_REQUIRE([gl_EEMALLOC]) 392 AC_REQUIRE([gl_EEMALLOC])
269 AC_REQUIRE([gl_GLIBC21])
270 AC_CHECK_HEADERS([libintl.h]) 393 AC_CHECK_HEADERS([libintl.h])
271 AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll]) 394 AC_CHECK_FUNCS_ONCE([isblank iswctype])
272 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]]) 395 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
273]) 396])
diff --git a/gl/m4/safe-read.m4 b/gl/m4/safe-read.m4
deleted file mode 100644
index be5207a5..00000000
--- a/gl/m4/safe-read.m4
+++ /dev/null
@@ -1,12 +0,0 @@
1# safe-read.m4 serial 6
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Prerequisites of lib/safe-read.c.
9AC_DEFUN([gl_PREREQ_SAFE_READ],
10[
11 AC_REQUIRE([gt_TYPE_SSIZE_T])
12])
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
index 01c037a8..0f35b8b8 100644
--- a/gl/m4/servent.m4
+++ b/gl/m4/servent.m4
@@ -1,5 +1,5 @@
1# servent.m4 serial 2 1# servent.m4 serial 4
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,12 +10,12 @@ AC_DEFUN([gl_SERVENT],
10 dnl getservbyport() defined? 10 dnl getservbyport() defined?
11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(), 11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
12 dnl getprotobynumber() defined? 12 dnl getprotobynumber() defined?
13 dnl - On Solaris, they are in libsocket. Ignore libxnet. 13 dnl - On Solaris < 11.4, they are in libsocket. Ignore libxnet.
14 dnl - On Haiku, they are in libnetwork. 14 dnl - On Haiku, they are in libnetwork.
15 dnl - On BeOS, they are in libnet. 15 dnl - On BeOS, they are in libnet.
16 dnl - On native Windows, they are in ws2_32.dll. 16 dnl - On native Windows, they are in ws2_32.dll.
17 dnl - Otherwise they are in libc. 17 dnl - Otherwise they are in libc.
18 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 18 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
19 SERVENT_LIB= 19 SERVENT_LIB=
20 gl_saved_libs="$LIBS" 20 gl_saved_libs="$LIBS"
21 AC_SEARCH_LIBS([getservbyname], [socket network net], 21 AC_SEARCH_LIBS([getservbyname], [socket network net],
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index cb5351a0..16f9eb55 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,5 +1,5 @@
1# setenv.m4 serial 26 1# setenv.m4 serial 30
2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -35,10 +35,12 @@ AC_DEFUN([gl_FUNC_SETENV],
35 ]])], 35 ]])],
36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], 36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
37 [case "$host_os" in 37 [case "$host_os" in
38 # Guess yes on glibc systems. 38 # Guess yes on glibc systems.
39 *-gnu*) gl_cv_func_setenv_works="guessing yes" ;; 39 *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;;
40 # If we don't know, assume the worst. 40 # Guess yes on musl systems.
41 *) gl_cv_func_setenv_works="guessing no" ;; 41 *-musl*) gl_cv_func_setenv_works="guessing yes" ;;
42 # If we don't know, obey --enable-cross-guesses.
43 *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;;
42 esac 44 esac
43 ])]) 45 ])])
44 case "$gl_cv_func_setenv_works" in 46 case "$gl_cv_func_setenv_works" in
@@ -104,35 +106,39 @@ int unsetenv (const char *name);
104 dnl OpenBSD 4.7 unsetenv("") does not fail. 106 dnl OpenBSD 4.7 unsetenv("") does not fail.
105 AC_CACHE_CHECK([whether unsetenv obeys POSIX], 107 AC_CACHE_CHECK([whether unsetenv obeys POSIX],
106 [gl_cv_func_unsetenv_works], 108 [gl_cv_func_unsetenv_works],
107 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 109 [AC_RUN_IFELSE(
108 #include <stdlib.h> 110 [AC_LANG_PROGRAM([[
109 #include <errno.h> 111 #include <stdlib.h>
110 extern char **environ; 112 #include <errno.h>
111 ]], [[ 113 extern char **environ;
112 char entry1[] = "a=1"; 114 ]GL_MDA_DEFINES],
113 char entry2[] = "b=2"; 115 [[
114 char *env[] = { entry1, entry2, NULL }; 116 char entry1[] = "a=1";
115 if (putenv ((char *) "a=1")) return 1; 117 char entry2[] = "b=2";
116 if (putenv (entry2)) return 2; 118 char *env[] = { entry1, entry2, NULL };
117 entry2[0] = 'a'; 119 if (putenv ((char *) "a=1")) return 1;
118 unsetenv ("a"); 120 if (putenv (entry2)) return 2;
119 if (getenv ("a")) return 3; 121 entry2[0] = 'a';
120 if (!unsetenv ("") || errno != EINVAL) return 4; 122 unsetenv ("a");
121 entry2[0] = 'b'; 123 if (getenv ("a")) return 3;
122 environ = env; 124 if (!unsetenv ("") || errno != EINVAL) return 4;
123 if (!getenv ("a")) return 5; 125 entry2[0] = 'b';
124 entry2[0] = 'a'; 126 environ = env;
125 unsetenv ("a"); 127 if (!getenv ("a")) return 5;
126 if (getenv ("a")) return 6; 128 entry2[0] = 'a';
127 ]])], 129 unsetenv ("a");
128 [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], 130 if (getenv ("a")) return 6;
129 [case "$host_os" in 131 ]])],
130 # Guess yes on glibc systems. 132 [gl_cv_func_unsetenv_works=yes],
131 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; 133 [gl_cv_func_unsetenv_works=no],
132 # If we don't know, assume the worst. 134 [case "$host_os" in
133 *) gl_cv_func_unsetenv_works="guessing no" ;; 135 # Guess yes on glibc systems.
134 esac 136 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;;
135 ])]) 137 # If we don't know, obey --enable-cross-guesses.
138 *) gl_cv_func_unsetenv_works="$gl_cross_guess_normal" ;;
139 esac
140 ])
141 ])
136 case "$gl_cv_func_unsetenv_works" in 142 case "$gl_cv_func_unsetenv_works" in
137 *yes) ;; 143 *yes) ;;
138 *) 144 *)
diff --git a/gl/m4/setlocale_null.m4 b/gl/m4/setlocale_null.m4
new file mode 100644
index 00000000..032119d0
--- /dev/null
+++ b/gl/m4/setlocale_null.m4
@@ -0,0 +1,98 @@
1# setlocale_null.m4 serial 5
2dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PTHREADLIB])
11 AC_CHECK_HEADERS_ONCE([threads.h])
12
13 AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe],
14 [gl_cv_func_setlocale_null_all_mtsafe],
15 [case "$host_os" in
16 # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin.
17 *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku* | cygwin*)
18 gl_cv_func_setlocale_null_all_mtsafe=no ;;
19 # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows.
20 *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*)
21 gl_cv_func_setlocale_null_all_mtsafe=yes ;;
22 # If we don't know, obey --enable-cross-guesses.
23 *)
24 gl_cv_func_setlocale_null_all_mtsafe="$gl_cross_guess_normal" ;;
25 esac
26 ])
27 dnl On platforms without multithreading, there is no issue.
28 case "$host_os" in
29 mingw*) ;;
30 *)
31 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
32 gl_cv_func_setlocale_null_all_mtsafe="trivially yes"
33 fi
34 ;;
35 esac
36 case "$gl_cv_func_setlocale_null_all_mtsafe" in
37 *yes) SETLOCALE_NULL_ALL_MTSAFE=1 ;;
38 *) SETLOCALE_NULL_ALL_MTSAFE=0 ;;
39 esac
40 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ALL_MTSAFE], [$SETLOCALE_NULL_ALL_MTSAFE],
41 [Define to 1 if setlocale (LC_ALL, NULL) is multithread-safe.])
42
43 dnl This is about a single category (not LC_ALL).
44 AC_CACHE_CHECK([whether setlocale (category, NULL) is multithread-safe],
45 [gl_cv_func_setlocale_null_one_mtsafe],
46 [case "$host_os" in
47 # Guess no on OpenBSD, AIX.
48 openbsd* | aix*)
49 gl_cv_func_setlocale_null_one_mtsafe=no ;;
50 # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows.
51 *-gnu* | gnu* | *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw*)
52 gl_cv_func_setlocale_null_one_mtsafe=yes ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *)
55 gl_cv_func_setlocale_null_one_mtsafe="$gl_cross_guess_normal" ;;
56 esac
57 ])
58 dnl On platforms without multithreading, there is no issue.
59 case "$host_os" in
60 mingw*) ;;
61 *)
62 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
63 gl_cv_func_setlocale_null_one_mtsafe="trivially yes"
64 fi
65 ;;
66 esac
67 case "$gl_cv_func_setlocale_null_one_mtsafe" in
68 *yes) SETLOCALE_NULL_ONE_MTSAFE=1 ;;
69 *) SETLOCALE_NULL_ONE_MTSAFE=0 ;;
70 esac
71 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ONE_MTSAFE], [$SETLOCALE_NULL_ONE_MTSAFE],
72 [Define to 1 if setlocale (category, NULL) is multithread-safe.])
73
74 dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c.
75 if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then
76 case "$host_os" in
77 mingw*) LIB_SETLOCALE_NULL= ;;
78 *)
79 gl_WEAK_SYMBOLS
80 case "$gl_cv_have_weak" in
81 *yes) LIB_SETLOCALE_NULL= ;;
82 *) LIB_SETLOCALE_NULL="$LIBPTHREAD" ;;
83 esac
84 ;;
85 esac
86 else
87 LIB_SETLOCALE_NULL=
88 fi
89 dnl LIB_SETLOCALE_NULL is expected to be '-pthread' or '-lpthread' on AIX
90 dnl with gcc or xlc, and empty otherwise.
91 AC_SUBST([LIB_SETLOCALE_NULL])
92])
93
94# Prerequisites of lib/setlocale-lock.c.
95AC_DEFUN([gl_PREREQ_SETLOCALE_LOCK],
96[
97 gl_VISIBILITY
98])
diff --git a/gl/m4/sha256.m4 b/gl/m4/sha256.m4
new file mode 100644
index 00000000..4d1d1dda
--- /dev/null
+++ b/gl/m4/sha256.m4
@@ -0,0 +1,14 @@
1# sha256.m4 serial 8
2dnl Copyright (C) 2005, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SHA256],
8[
9 dnl Prerequisites of lib/sha256.c.
10 AC_REQUIRE([gl_BIGENDIAN])
11
12 dnl Determine HAVE_OPENSSL_SHA256 and LIB_CRYPTO
13 gl_CRYPTO_CHECK([SHA256])
14])
diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4
index 4b247abc..0763366d 100644
--- a/gl/m4/size_max.m4
+++ b/gl/m4/size_max.m4
@@ -1,17 +1,19 @@
1# size_max.m4 serial 10 1# size_max.m4 serial 12
2dnl Copyright (C) 2003, 2005-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ([2.61])
10
9AC_DEFUN([gl_SIZE_MAX], 11AC_DEFUN([gl_SIZE_MAX],
10[ 12[
11 AC_CHECK_HEADERS([stdint.h]) 13 AC_CHECK_HEADERS([stdint.h])
12 dnl First test whether the system already has SIZE_MAX. 14 dnl First test whether the system already has SIZE_MAX.
13 AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [ 15 AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [
14 gl_cv_size_max= 16 gl_cv_size_max=no
15 AC_EGREP_CPP([Found it], [ 17 AC_EGREP_CPP([Found it], [
16#include <limits.h> 18#include <limits.h>
17#if HAVE_STDINT_H 19#if HAVE_STDINT_H
@@ -21,7 +23,7 @@ AC_DEFUN([gl_SIZE_MAX],
21Found it 23Found it
22#endif 24#endif
23], [gl_cv_size_max=yes]) 25], [gl_cv_size_max=yes])
24 if test -z "$gl_cv_size_max"; then 26 if test $gl_cv_size_max != yes; then
25 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider 27 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
26 dnl than the type 'unsigned long'. Try hard to find a definition that can 28 dnl than the type 'unsigned long'. Try hard to find a definition that can
27 dnl be used in a preprocessor #if, i.e. doesn't contain a cast. 29 dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
@@ -71,9 +73,3 @@ Found it
71# undef SIZE_MAX 73# undef SIZE_MAX
72#endif]) 74#endif])
73]) 75])
74
75dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
76dnl Remove this when we can assume autoconf >= 2.61.
77m4_ifdef([AC_COMPUTE_INT], [], [
78 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
79])
diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4
index 3698e844..4b5fbdbf 100644
--- a/gl/m4/snprintf.m4
+++ b/gl/m4/snprintf.m4
@@ -1,5 +1,5 @@
1# snprintf.m4 serial 6 1# snprintf.m4 serial 7
2dnl Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,14 @@ AC_DEFUN([gl_REPLACE_SNPRINTF],
46 AC_LIBOBJ([snprintf]) 46 AC_LIBOBJ([snprintf])
47 if test $ac_cv_func_snprintf = yes; then 47 if test $ac_cv_func_snprintf = yes; then
48 REPLACE_SNPRINTF=1 48 REPLACE_SNPRINTF=1
49 else
50 AC_CHECK_DECLS_ONCE([snprintf])
51 if test $ac_cv_have_decl_snprintf = yes; then
52 dnl If the function is declared but does not appear to exist, it may be
53 dnl defined as an inline function. In order to avoid a conflict, we have
54 dnl to define rpl_snprintf, not snprintf.
55 REPLACE_SNPRINTF=1
56 fi
49 fi 57 fi
50 gl_PREREQ_SNPRINTF 58 gl_PREREQ_SNPRINTF
51]) 59])
diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4
index b08a72f6..a556af1e 100644
--- a/gl/m4/socketlib.m4
+++ b/gl/m4/socketlib.m4
@@ -1,5 +1,5 @@
1# socketlib.m4 serial 1 1# socketlib.m4 serial 3
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -14,21 +14,27 @@ AC_DEFUN([gl_SOCKETLIB],
14 LIBSOCKET= 14 LIBSOCKET=
15 if test $HAVE_WINSOCK2_H = 1; then 15 if test $HAVE_WINSOCK2_H = 1; then
16 dnl Native Windows API (not Cygwin). 16 dnl Native Windows API (not Cygwin).
17 AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32], 17 dnl If the function WSAStartup exists (declared in <winsock2.h> and
18 [gl_cv_func_wsastartup], [ 18 dnl defined through -lws2_32), we need to call it.
19 gl_save_LIBS="$LIBS" 19 AC_CACHE_CHECK([for WSAStartup],
20 LIBS="$LIBS -lws2_32" 20 [gl_cv_func_wsastartup], [
21 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 21 gl_save_LIBS="$LIBS"
22 LIBS="$LIBS -lws2_32"
23 AC_LINK_IFELSE(
24 [AC_LANG_PROGRAM([[
22#ifdef HAVE_WINSOCK2_H 25#ifdef HAVE_WINSOCK2_H
23# include <winsock2.h> 26# include <winsock2.h>
24#endif]], [[ 27#endif]], [[
25 WORD wVersionRequested = MAKEWORD(1, 1); 28 WORD wVersionRequested = MAKEWORD(1, 1);
26 WSADATA wsaData; 29 WSADATA wsaData;
27 int err = WSAStartup(wVersionRequested, &wsaData); 30 int err = WSAStartup(wVersionRequested, &wsaData);
28 WSACleanup ();]])], 31 WSACleanup ();
29 gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no) 32 ]])
30 LIBS="$gl_save_LIBS" 33 ],
31 ]) 34 [gl_cv_func_wsastartup=yes],
35 [gl_cv_func_wsastartup=no])
36 LIBS="$gl_save_LIBS"
37 ])
32 if test "$gl_cv_func_wsastartup" = "yes"; then 38 if test "$gl_cv_func_wsastartup" = "yes"; then
33 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) 39 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
34 LIBSOCKET='-lws2_32' 40 LIBSOCKET='-lws2_32'
@@ -38,6 +44,10 @@ AC_DEFUN([gl_SOCKETLIB],
38 dnl Solaris has most socket functions in libsocket. 44 dnl Solaris has most socket functions in libsocket.
39 dnl Haiku has most socket functions in libnetwork. 45 dnl Haiku has most socket functions in libnetwork.
40 dnl BeOS has most socket functions in libnet. 46 dnl BeOS has most socket functions in libnet.
47 dnl On HP-UX, do NOT link with libxnet, because in 64-bit mode this would
48 dnl break code (e.g. in libraries) that invokes accept(), getpeername(),
49 dnl getsockname(), getsockopt(), or recvfrom() with a 32-bit addrlen. See
50 dnl "man xopen_networking" for details.
41 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ 51 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
42 gl_cv_lib_socket= 52 gl_cv_lib_socket=
43 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4
index b407391c..ed9cb873 100644
--- a/gl/m4/sockets.m4
+++ b/gl/m4/sockets.m4
@@ -1,5 +1,5 @@
1# sockets.m4 serial 7 1# sockets.m4 serial 7
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4
index e3efd6ef..1c63a853 100644
--- a/gl/m4/socklen.m4
+++ b/gl/m4/socklen.m4
@@ -1,5 +1,5 @@
1# socklen.m4 serial 10 1# socklen.m4 serial 11
2dnl Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,8 +15,8 @@ dnl So we have to test to find something that will work.
15AC_DEFUN([gl_TYPE_SOCKLEN_T], 15AC_DEFUN([gl_TYPE_SOCKLEN_T],
16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl 16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
17 AC_CHECK_TYPE([socklen_t], , 17 AC_CHECK_TYPE([socklen_t], ,
18 [AC_MSG_CHECKING([for socklen_t equivalent]) 18 [AC_CACHE_CHECK([for socklen_t equivalent],
19 AC_CACHE_VAL([gl_cv_socklen_t_equiv], 19 [gl_cv_socklen_t_equiv],
20 [# Systems have either "struct sockaddr *" or 20 [# Systems have either "struct sockaddr *" or
21 # "void *" as the second argument to getpeername 21 # "void *" as the second argument to getpeername
22 gl_cv_socklen_t_equiv= 22 gl_cv_socklen_t_equiv=
@@ -34,11 +34,10 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
34 done 34 done
35 test "$gl_cv_socklen_t_equiv" != "" && break 35 test "$gl_cv_socklen_t_equiv" != "" && break
36 done 36 done
37 ]) 37 if test "$gl_cv_socklen_t_equiv" = ""; then
38 if test "$gl_cv_socklen_t_equiv" = ""; then 38 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
39 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) 39 fi
40 fi 40 ])
41 AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
42 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], 41 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
43 [type to use in place of socklen_t if not defined])], 42 [type to use in place of socklen_t if not defined])],
44 [gl_SOCKET_HEADERS])]) 43 [gl_SOCKET_HEADERS])])
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index 89557b18..6c6dc2f7 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -1,5 +1,5 @@
1# sockpfaf.m4 serial 8 1# sockpfaf.m4 serial 10
2dnl Copyright (C) 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -13,11 +13,11 @@ dnl From Bruno Haible.
13 13
14AC_DEFUN([gl_SOCKET_FAMILIES], 14AC_DEFUN([gl_SOCKET_FAMILIES],
15[ 15[
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 16 AC_REQUIRE([gl_SYS_SOCKET_H])
17 AC_CHECK_HEADERS_ONCE([netinet/in.h]) 17 AC_CHECK_HEADERS_ONCE([netinet/in.h])
18 18
19 AC_MSG_CHECKING([for IPv4 sockets]) 19 AC_CACHE_CHECK([for IPv4 sockets],
20 AC_CACHE_VAL([gl_cv_socket_ipv4], 20 [gl_cv_socket_ipv4],
21 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 21 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
22#ifdef HAVE_SYS_SOCKET_H 22#ifdef HAVE_SYS_SOCKET_H
23#include <sys/socket.h> 23#include <sys/socket.h>
@@ -31,13 +31,12 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
31[[int x = AF_INET; struct in_addr y; struct sockaddr_in z; 31[[int x = AF_INET; struct in_addr y; struct sockaddr_in z;
32 if (&x && &y && &z) return 0;]])], 32 if (&x && &y && &z) return 0;]])],
33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)]) 33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
34 AC_MSG_RESULT([$gl_cv_socket_ipv4])
35 if test $gl_cv_socket_ipv4 = yes; then 34 if test $gl_cv_socket_ipv4 = yes; then
36 AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.]) 35 AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.])
37 fi 36 fi
38 37
39 AC_MSG_CHECKING([for IPv6 sockets]) 38 AC_CACHE_CHECK([for IPv6 sockets],
40 AC_CACHE_VAL([gl_cv_socket_ipv6], 39 [gl_cv_socket_ipv6],
41 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 40 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
42#ifdef HAVE_SYS_SOCKET_H 41#ifdef HAVE_SYS_SOCKET_H
43#include <sys/socket.h> 42#include <sys/socket.h>
@@ -54,7 +53,6 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
54[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; 53[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
55 if (&x && &y && &z) return 0;]])], 54 if (&x && &y && &z) return 0;]])],
56 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)]) 55 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
57 AC_MSG_RESULT([$gl_cv_socket_ipv6])
58 if test $gl_cv_socket_ipv6 = yes; then 56 if test $gl_cv_socket_ipv6 = yes; then
59 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.]) 57 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
60 fi 58 fi
@@ -62,11 +60,11 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
62 60
63AC_DEFUN([gl_SOCKET_FAMILY_UNIX], 61AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
64[ 62[
65 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 63 AC_REQUIRE([gl_SYS_SOCKET_H])
66 AC_CHECK_HEADERS_ONCE([sys/un.h]) 64 AC_CHECK_HEADERS_ONCE([sys/un.h])
67 65
68 AC_MSG_CHECKING([for UNIX domain sockets]) 66 AC_CACHE_CHECK([for UNIX domain sockets],
69 AC_CACHE_VAL([gl_cv_socket_unix], 67 [gl_cv_socket_unix],
70 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 68 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
71#ifdef HAVE_SYS_SOCKET_H 69#ifdef HAVE_SYS_SOCKET_H
72#include <sys/socket.h> 70#include <sys/socket.h>
@@ -80,7 +78,6 @@ AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
80[[int x = AF_UNIX; struct sockaddr_un y; 78[[int x = AF_UNIX; struct sockaddr_un y;
81 if (&x && &y) return 0;]])], 79 if (&x && &y) return 0;]])],
82 gl_cv_socket_unix=yes, gl_cv_socket_unix=no)]) 80 gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
83 AC_MSG_RESULT([$gl_cv_socket_unix])
84 if test $gl_cv_socket_unix = yes; then 81 if test $gl_cv_socket_unix = yes; then
85 AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.]) 82 AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.])
86 fi 83 fi
diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4
index 63381343..1c12c33e 100644
--- a/gl/m4/ssize_t.m4
+++ b/gl/m4/ssize_t.m4
@@ -1,5 +1,5 @@
1# ssize_t.m4 serial 5 (gettext-0.18.2) 1# ssize_t.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2001-2003, 2006, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2003, 2006, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/stat-time.m4 b/gl/m4/stat-time.m4
new file mode 100644
index 00000000..40993d57
--- /dev/null
+++ b/gl/m4/stat-time.m4
@@ -0,0 +1,83 @@
1# Checks for stat-related time functions.
2
3# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2023 Free Software
4# Foundation, Inc.
5
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl From Paul Eggert.
11
12# st_atim.tv_nsec - Linux, Solaris, Cygwin
13# st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE
14# st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE
15# st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1)
16
17# st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway)
18# st_birthtim - Cygwin 1.7.0+
19
20AC_DEFUN([gl_STAT_TIME],
21[
22 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
23 AC_CHECK_HEADERS_ONCE([sys/time.h])
24
25 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec],
26 [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec],
27 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
29 [[
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #if HAVE_SYS_TIME_H
33 # include <sys/time.h>
34 #endif
35 #include <time.h>
36 struct timespec ts;
37 struct stat st;
38 ]],
39 [[
40 st.st_atim = ts;
41 ]])],
42 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes],
43 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])])
44 if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then
45 AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1],
46 [Define to 1 if the type of the st_atim member of a struct stat is
47 struct timespec.])
48 fi],
49 [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [],
50 [AC_CHECK_MEMBERS([struct stat.st_atimensec], [],
51 [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [],
52 [#include <sys/types.h>
53 #include <sys/stat.h>])],
54 [#include <sys/types.h>
55 #include <sys/stat.h>])],
56 [#include <sys/types.h>
57 #include <sys/stat.h>])],
58 [#include <sys/types.h>
59 #include <sys/stat.h>])
60])
61
62# Check for st_birthtime, a feature from UFS2 (FreeBSD, NetBSD, OpenBSD, etc.)
63# and NTFS (Cygwin).
64# There was a time when this field was named st_createtime (21 June
65# 2002 to 16 July 2002) But that window is very small and applied only
66# to development code, so systems still using that configuration are
67# not supported. See revisions 1.10 and 1.11 of FreeBSD's
68# src/sys/ufs/ufs/dinode.h.
69#
70AC_DEFUN([gl_STAT_BIRTHTIME],
71[
72 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
73 AC_CHECK_HEADERS_ONCE([sys/time.h])
74 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [],
75 [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [],
76 [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [],
77 [#include <sys/types.h>
78 #include <sys/stat.h>])],
79 [#include <sys/types.h>
80 #include <sys/stat.h>])],
81 [#include <sys/types.h>
82 #include <sys/stat.h>])
83])
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
new file mode 100644
index 00000000..4d241e27
--- /dev/null
+++ b/gl/m4/stat.m4
@@ -0,0 +1,85 @@
1# serial 18
2
3# Copyright (C) 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9AC_DEFUN([gl_FUNC_STAT],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13 AC_CHECK_FUNCS_ONCE([lstat])
14 case "$host_os" in
15 mingw*)
16 dnl On this platform, the original stat() returns st_atime, st_mtime,
17 dnl st_ctime values that are affected by the time zone.
18 REPLACE_STAT=1
19 ;;
20 *)
21 dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
22 dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
23 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
24 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
25 [gl_cv_func_stat_file_slash],
26 [touch conftest.tmp
27 # Assume that if we have lstat, we can also check symlinks.
28 if test $ac_cv_func_lstat = yes; then
29 ln -s conftest.tmp conftest.lnk
30 fi
31 AC_RUN_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[#include <sys/stat.h>
34]], [[int result = 0;
35 struct stat st;
36 if (!stat ("conftest.tmp/", &st))
37 result |= 1;
38#if HAVE_LSTAT
39 if (!stat ("conftest.lnk/", &st))
40 result |= 2;
41#endif
42 return result;
43 ]])],
44 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
45 [case "$host_os" in
46 # Guess yes on Linux systems.
47 linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;;
48 # Guess yes on glibc systems.
49 *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
50 # If we don't know, obey --enable-cross-guesses.
51 *) gl_cv_func_stat_file_slash="$gl_cross_guess_normal" ;;
52 esac
53 ])
54 rm -f conftest.tmp conftest.lnk])
55 case $gl_cv_func_stat_file_slash in
56 *no)
57 REPLACE_STAT=1
58 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
59 help when passed a file name with a trailing slash]);;
60 esac
61 case $host_os in
62 dnl Solaris stat can return a negative tv_nsec.
63 solaris*)
64 REPLACE_FSTAT=1 ;;
65 esac
66 ;;
67 esac
68])
69
70# Prerequisites of lib/stat.c and lib/stat-w32.c.
71AC_DEFUN([gl_PREREQ_STAT], [
72 AC_REQUIRE([gl_SYS_STAT_H])
73 AC_REQUIRE([gl_PREREQ_STAT_W32])
74 :
75])
76
77# Prerequisites of lib/stat-w32.c.
78AC_DEFUN([gl_PREREQ_STAT_W32], [
79 AC_REQUIRE([AC_CANONICAL_HOST])
80 case "$host_os" in
81 mingw*)
82 AC_CHECK_HEADERS([sdkddkver.h])
83 ;;
84 esac
85])
diff --git a/gl/m4/std-gnu11.m4 b/gl/m4/std-gnu11.m4
new file mode 100644
index 00000000..4179470e
--- /dev/null
+++ b/gl/m4/std-gnu11.m4
@@ -0,0 +1,829 @@
1# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*-
2
3# This implementation is taken from GNU Autoconf lib/autoconf/c.m4
4# commit 017d5ddd82854911f0119691d91ea8a1438824d6
5# dated Sun Apr 3 13:57:17 2016 -0700
6# This implementation will be obsolete once we can assume Autoconf 2.70
7# or later is installed everywhere a Gnulib program might be developed.
8
9m4_version_prereq([2.70], [], [
10
11
12# Copyright (C) 2001-2023 Free Software Foundation, Inc.
13
14# This program is free software; you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation, either version 3 of the License, or
17# (at your option) any later version.
18#
19# This program is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program. If not, see <https://www.gnu.org/licenses/>.
26
27# Written by David MacKenzie, with help from
28# Akim Demaille, Paul Eggert,
29# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
30# Roland McGrath, Noah Friedman, david d zuhn, and many others.
31
32
33# AC_PROG_CC([COMPILER ...])
34# --------------------------
35# COMPILER ... is a space separated list of C compilers to search for.
36# This just gives the user an opportunity to specify an alternative
37# search list for the C compiler.
38AC_DEFUN_ONCE([AC_PROG_CC],
39[AC_LANG_PUSH(C)dnl
40AC_ARG_VAR([CC], [C compiler command])dnl
41AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
42_AC_ARG_VAR_LDFLAGS()dnl
43_AC_ARG_VAR_LIBS()dnl
44_AC_ARG_VAR_CPPFLAGS()dnl
45m4_ifval([$1],
46 [AC_CHECK_TOOLS(CC, [$1])],
47[AC_CHECK_TOOL(CC, gcc)
48if test -z "$CC"; then
49 dnl Here we want:
50 dnl AC_CHECK_TOOL(CC, cc)
51 dnl but without the check for a tool without the prefix.
52 dnl Until the check is removed from there, copy the code:
53 if test -n "$ac_tool_prefix"; then
54 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
55 fi
56fi
57if test -z "$CC"; then
58 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
59fi
60if test -z "$CC"; then
61 AC_CHECK_TOOLS(CC, cl.exe)
62fi
63if test -z "$CC"; then
64 AC_CHECK_TOOL(CC, clang)
65fi
66])
67
68test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
69
70# Provide some information about the compiler.
71_AS_ECHO_LOG([checking for _AC_LANG compiler version])
72set X $ac_compile
73ac_compiler=$[2]
74for ac_option in --version -v -V -qversion -version; do
75 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
76done
77
78m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
79m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
80_AC_LANG_COMPILER_GNU
81if test $ac_compiler_gnu = yes; then
82 GCC=yes
83else
84 GCC=
85fi
86_AC_PROG_CC_G
87dnl
88dnl Set ac_prog_cc_stdc to the supported C version.
89dnl Also set the documented variable ac_cv_prog_cc_stdc;
90dnl its name was chosen when it was cached, but it is no longer cached.
91_AC_PROG_CC_C11([ac_prog_cc_stdc=c11
92 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
93 [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
94 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
95 [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
96 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
97 [ac_prog_cc_stdc=no
98 ac_cv_prog_cc_stdc=no])])])
99dnl
100AC_LANG_POP(C)dnl
101])# AC_PROG_CC
102
103
104
105# AC_PROG_CXX([LIST-OF-COMPILERS])
106# --------------------------------
107# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
108# for (if not specified, a default list is used). This just gives the
109# user an opportunity to specify an alternative search list for the C++
110# compiler.
111# aCC HP-UX C++ compiler much better than `CC', so test before.
112# FCC Fujitsu C++ compiler
113# KCC KAI C++ compiler
114# RCC Rational C++
115# xlC_r AIX C Set++ (with support for reentrant code)
116# xlC AIX C Set++
117AC_DEFUN([AC_PROG_CXX],
118[AC_LANG_PUSH(C++)dnl
119AC_ARG_VAR([CXX], [C++ compiler command])dnl
120AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
121_AC_ARG_VAR_LDFLAGS()dnl
122_AC_ARG_VAR_LIBS()dnl
123_AC_ARG_VAR_CPPFLAGS()dnl
124_AC_ARG_VAR_PRECIOUS([CCC])dnl
125if test -z "$CXX"; then
126 if test -n "$CCC"; then
127 CXX=$CCC
128 else
129 AC_CHECK_TOOLS(CXX,
130 [m4_default([$1],
131 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
132 g++)
133 fi
134fi
135# Provide some information about the compiler.
136_AS_ECHO_LOG([checking for _AC_LANG compiler version])
137set X $ac_compile
138ac_compiler=$[2]
139for ac_option in --version -v -V -qversion; do
140 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
141done
142
143m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
144m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
145_AC_LANG_COMPILER_GNU
146if test $ac_compiler_gnu = yes; then
147 GXX=yes
148else
149 GXX=
150fi
151_AC_PROG_CXX_G
152_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
153 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
154 ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11],
155 [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98
156 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
157 [ac_prog_cxx_stdcxx=no
158 ac_cv_prog_cxx_stdcxx=no])])
159AC_LANG_POP(C++)dnl
160])# AC_PROG_CXX
161
162
163# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
164# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
165# --------------------------------------------------------------
166# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
167# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
168# try again with each compiler option in the space-separated OPTION-LIST; if one
169# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
170# else ACTION-IF-UNAVAILABLE.
171AC_DEFUN([_AC_C_STD_TRY],
172[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
173AC_CACHE_VAL(ac_cv_prog_cc_$1,
174[ac_cv_prog_cc_$1=no
175ac_save_CC=$CC
176AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
177for ac_arg in '' $4
178do
179 CC="$ac_save_CC $ac_arg"
180 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
181 test "x$ac_cv_prog_cc_$1" != "xno" && break
182done
183rm -f conftest.$ac_ext
184CC=$ac_save_CC
185])# AC_CACHE_VAL
186ac_prog_cc_stdc_options=
187case "x$ac_cv_prog_cc_$1" in
188 x)
189 AC_MSG_RESULT([none needed]) ;;
190 xno)
191 AC_MSG_RESULT([unsupported]) ;;
192 *)
193 ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
194 CC=$CC$ac_prog_cc_stdc_options
195 AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
196esac
197AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
198])# _AC_C_STD_TRY
199
200# _AC_C_C99_TEST_HEADER
201# ---------------------
202# A C header suitable for testing for C99.
203AC_DEFUN([_AC_C_C99_TEST_HEADER],
204[[#include <stdarg.h>
205#include <stdbool.h>
206#include <stddef.h>
207#include <stdlib.h>
208#include <wchar.h>
209#include <stdio.h>
210
211// Check varargs macros. These examples are taken from C99 6.10.3.5.
212#define debug(...) fprintf (stderr, __VA_ARGS__)
213#define showlist(...) puts (#__VA_ARGS__)
214#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
215static void
216test_varargs_macros (void)
217{
218 int x = 1234;
219 int y = 5678;
220 debug ("Flag");
221 debug ("X = %d\n", x);
222 showlist (The first, second, and third items.);
223 report (x>y, "x is %d but y is %d", x, y);
224}
225
226// Check long long types.
227#define BIG64 18446744073709551615ull
228#define BIG32 4294967295ul
229#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
230#if !BIG_OK
231 your preprocessor is broken;
232#endif
233#if BIG_OK
234#else
235 your preprocessor is broken;
236#endif
237static long long int bignum = -9223372036854775807LL;
238static unsigned long long int ubignum = BIG64;
239
240struct incomplete_array
241{
242 int datasize;
243 double data[];
244};
245
246struct named_init {
247 int number;
248 const wchar_t *name;
249 double average;
250};
251
252typedef const char *ccp;
253
254static inline int
255test_restrict (ccp restrict text)
256{
257 // See if C++-style comments work.
258 // Iterate through items via the restricted pointer.
259 // Also check for declarations in for loops.
260 for (unsigned int i = 0; *(text+i) != '\0'; ++i)
261 continue;
262 return 0;
263}
264
265// Check varargs and va_copy.
266static bool
267test_varargs (const char *format, ...)
268{
269 va_list args;
270 va_start (args, format);
271 va_list args_copy;
272 va_copy (args_copy, args);
273
274 const char *str = "";
275 int number = 0;
276 float fnumber = 0;
277
278 while (*format)
279 {
280 switch (*format++)
281 {
282 case 's': // string
283 str = va_arg (args_copy, const char *);
284 break;
285 case 'd': // int
286 number = va_arg (args_copy, int);
287 break;
288 case 'f': // float
289 fnumber = va_arg (args_copy, double);
290 break;
291 default:
292 break;
293 }
294 }
295 va_end (args_copy);
296 va_end (args);
297
298 return *str && number && fnumber;
299}]])# _AC_C_C99_TEST_HEADER
300
301# _AC_C_C99_TEST_BODY
302# -------------------
303# A C body suitable for testing for C99, assuming the corresponding header.
304AC_DEFUN([_AC_C_C99_TEST_BODY],
305[[
306 // Check bool.
307 _Bool success = false;
308
309 // Check restrict.
310 if (test_restrict ("String literal") == 0)
311 success = true;
312 char *restrict newvar = "Another string";
313
314 // Check varargs.
315 success &= test_varargs ("s, d' f .", "string", 65, 34.234);
316 test_varargs_macros ();
317
318 // Check flexible array members.
319 struct incomplete_array *ia =
320 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
321 ia->datasize = 10;
322 for (int i = 0; i < ia->datasize; ++i)
323 ia->data[i] = i * 1.234;
324
325 // Check named initializers.
326 struct named_init ni = {
327 .number = 34,
328 .name = L"Test wide string",
329 .average = 543.34343,
330 };
331
332 ni.number = 58;
333
334 int dynamic_array[ni.number];
335 dynamic_array[ni.number - 1] = 543;
336
337 // work around unused variable warnings
338 return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
339 || dynamic_array[ni.number - 1] != 543);
340]])
341
342# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
343# ----------------------------------------------------------------
344# If the C compiler is not in ISO C99 mode by default, try to add an
345# option to output variable CC to make it so. This macro tries
346# various options that select ISO C99 on some system or another. It
347# considers the compiler to be in ISO C99 mode if it handles _Bool,
348# // comments, flexible array members, inline, long long int, mixed
349# code and declarations, named initialization of structs, restrict,
350# va_copy, varargs macros, variable declarations in for loops and
351# variable length arrays.
352AC_DEFUN([_AC_PROG_CC_C99],
353[_AC_C_STD_TRY([c99],
354[_AC_C_C99_TEST_HEADER],
355[_AC_C_C99_TEST_BODY],
356dnl Try
357dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
358dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
359dnl IBM XL C -qlanglvl=extc99
360dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
361dnl HP cc -AC99
362dnl Intel ICC -std=c99, -c99 (deprecated)
363dnl IRIX -c99
364dnl Solaris -D_STDC_C99=
365dnl cc's -xc99 option uses linker magic to define the external
366dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
367dnl behavior for C library functions. This is not wanted here,
368dnl because it means that a single module compiled with -xc99
369dnl alters C runtime behavior for the entire program, not for
370dnl just the module. Instead, define the (private) symbol
371dnl _STDC_C99, which suppresses a bogus failure in <stdbool.h>.
372dnl The resulting compiler passes the test case here, and that's
373dnl good enough. For more, please see the thread starting at:
374dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html
375dnl Tru64 -c99
376dnl with extended modes being tried first.
377[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
378])# _AC_PROG_CC_C99
379
380
381# _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
382# ----------------------------------------------------------------
383# If the C compiler is not in ISO C11 mode by default, try to add an
384# option to output variable CC to make it so. This macro tries
385# various options that select ISO C11 on some system or another. It
386# considers the compiler to be in ISO C11 mode if it handles _Alignas,
387# _Alignof, _Noreturn, _Static_assert, UTF-8 string literals,
388# duplicate typedefs, and anonymous structures and unions.
389AC_DEFUN([_AC_PROG_CC_C11],
390[_AC_C_STD_TRY([c11],
391[_AC_C_C99_TEST_HEADER[
392// Check _Alignas.
393char _Alignas (double) aligned_as_double;
394char _Alignas (0) no_special_alignment;
395extern char aligned_as_int;
396char _Alignas (0) _Alignas (int) aligned_as_int;
397
398// Check _Alignof.
399enum
400{
401 int_alignment = _Alignof (int),
402 int_array_alignment = _Alignof (int[100]),
403 char_alignment = _Alignof (char)
404};
405_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
406
407// Check _Noreturn.
408int _Noreturn does_not_return (void) { for (;;) continue; }
409
410// Check _Static_assert.
411struct test_static_assert
412{
413 int x;
414 _Static_assert (sizeof (int) <= sizeof (long int),
415 "_Static_assert does not work in struct");
416 long int y;
417};
418
419// Check UTF-8 literals.
420#define u8 syntax error!
421char const utf8_literal[] = u8"happens to be ASCII" "another string";
422
423// Check duplicate typedefs.
424typedef long *long_ptr;
425typedef long int *long_ptr;
426typedef long_ptr long_ptr;
427
428// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
429struct anonymous
430{
431 union {
432 struct { int i; int j; };
433 struct { int k; long int l; } w;
434 };
435 int m;
436} v1;
437]],
438[_AC_C_C99_TEST_BODY[
439 v1.i = 2;
440 v1.w.k = 5;
441 _Static_assert ((offsetof (struct anonymous, i)
442 == offsetof (struct anonymous, w.k)),
443 "Anonymous union alignment botch");
444]],
445dnl Try
446dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
447dnl with extended modes being tried first.
448dnl
449dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
450dnl of September 2012) does not pass the C11 test. For now, try extc1x when
451dnl compiling the C99 test instead, since it enables _Static_assert and
452dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
453dnl the C11 test in some future version of IBM XL C, we'll add it here,
454dnl preferably extc11.
455[[-std=gnu11]], [$1], [$2])[]dnl
456])# _AC_PROG_CC_C11
457
458
459# AC_PROG_CC_C89
460# --------------
461# Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
462# as that'd be incompatible with how Automake redefines AC_PROG_CC. See
463# <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>.
464AU_DEFUN([AC_PROG_CC_C89],
465 [AC_REQUIRE([AC_PROG_CC])],
466 [$0 is obsolete; use AC_PROG_CC]
467)
468
469# AC_PROG_CC_C99
470# --------------
471AU_DEFUN([AC_PROG_CC_C99],
472 [AC_REQUIRE([AC_PROG_CC])],
473 [$0 is obsolete; use AC_PROG_CC]
474)
475
476# AC_PROG_CC_STDC
477# ---------------
478AU_DEFUN([AC_PROG_CC_STDC],
479 [AC_REQUIRE([AC_PROG_CC])],
480 [$0 is obsolete; use AC_PROG_CC]
481)
482
483
484# AC_C_PROTOTYPES
485# ---------------
486# Check if the C compiler supports prototypes, included if it needs
487# options.
488AC_DEFUN([AC_C_PROTOTYPES],
489[AC_REQUIRE([AC_PROG_CC])dnl
490if test "$ac_prog_cc_stdc" != no; then
491 AC_DEFINE(PROTOTYPES, 1,
492 [Define to 1 if the C compiler supports function prototypes.])
493 AC_DEFINE(__PROTOTYPES, 1,
494 [Define like PROTOTYPES; this can be used by system headers.])
495fi
496])# AC_C_PROTOTYPES
497
498
499# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
500# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
501# ----------------------------------------------------------------
502# Check whether the C++ compiler accepts features of STANDARD (e.g
503# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
504# and TEST-BODY. If this fails, try again with each compiler option
505# in the space-separated OPTION-LIST; if one helps, append it to CXX.
506# If eventually successful, run ACTION-IF-AVAILABLE, else
507# ACTION-IF-UNAVAILABLE.
508AC_DEFUN([_AC_CXX_STD_TRY],
509[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
510AC_LANG_PUSH(C++)dnl
511AC_CACHE_VAL(ac_cv_prog_cxx_$1,
512[ac_cv_prog_cxx_$1=no
513ac_save_CXX=$CXX
514AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
515for ac_arg in '' $4
516do
517 CXX="$ac_save_CXX $ac_arg"
518 _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
519 test "x$ac_cv_prog_cxx_$1" != "xno" && break
520done
521rm -f conftest.$ac_ext
522CXX=$ac_save_CXX
523])# AC_CACHE_VAL
524ac_prog_cxx_stdcxx_options=
525case "x$ac_cv_prog_cxx_$1" in
526 x)
527 AC_MSG_RESULT([none needed]) ;;
528 xno)
529 AC_MSG_RESULT([unsupported]) ;;
530 *)
531 ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
532 CXX=$CXX$ac_prog_cxx_stdcxx_options
533 AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
534esac
535AC_LANG_POP(C++)dnl
536AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
537])# _AC_CXX_STD_TRY
538
539# _AC_CXX_CXX98_TEST_HEADER
540# -------------------------
541# A C++ header suitable for testing for CXX98.
542AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
543[[
544#include <algorithm>
545#include <cstdlib>
546#include <fstream>
547#include <iomanip>
548#include <iostream>
549#include <list>
550#include <map>
551#include <set>
552#include <sstream>
553#include <stdexcept>
554#include <string>
555#include <utility>
556#include <vector>
557
558namespace test {
559 typedef std::vector<std::string> string_vec;
560 typedef std::pair<int,bool> map_value;
561 typedef std::map<std::string,map_value> map_type;
562 typedef std::set<int> set_type;
563
564 template<typename T>
565 class printer {
566 public:
567 printer(std::ostringstream& os): os(os) {}
568 void operator() (T elem) { os << elem << std::endl; }
569 private:
570 std::ostringstream& os;
571 };
572}
573]])# _AC_CXX_CXX98_TEST_HEADER
574
575# _AC_CXX_CXX98_TEST_BODY
576# -----------------------
577# A C++ body suitable for testing for CXX98, assuming the corresponding header.
578AC_DEFUN([_AC_CXX_CXX98_TEST_BODY],
579[[
580
581try {
582 // Basic string.
583 std::string teststr("ASCII text");
584 teststr += " string";
585
586 // Simple vector.
587 test::string_vec testvec;
588 testvec.push_back(teststr);
589 testvec.push_back("foo");
590 testvec.push_back("bar");
591 if (testvec.size() != 3) {
592 throw std::runtime_error("vector size is not 1");
593 }
594
595 // Dump vector into stringstream and obtain string.
596 std::ostringstream os;
597 for (test::string_vec::const_iterator i = testvec.begin();
598 i != testvec.end(); ++i) {
599 if (i + 1 != testvec.end()) {
600 os << teststr << '\n';
601 }
602 }
603 // Check algorithms work.
604 std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os));
605 std::string os_out = os.str();
606
607 // Test pair and map.
608 test::map_type testmap;
609 testmap.insert(std::make_pair(std::string("key"),
610 std::make_pair(53,false)));
611
612 // Test set.
613 int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
614 test::set_type testset(values, values + sizeof(values)/sizeof(values[0]));
615 std::list<int> testlist(testset.begin(), testset.end());
616 std::copy(testset.begin(), testset.end(), std::back_inserter(testlist));
617} catch (const std::exception& e) {
618 std::cerr << "Caught exception: " << e.what() << std::endl;
619
620 // Test fstream
621 std::ofstream of("test.txt");
622 of << "Test ASCII text\n" << std::flush;
623 of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl;
624 of.close();
625}
626std::exit(0);
627]])
628
629# _AC_CXX_CXX11_TEST_HEADER
630# -------------------------
631# A C++ header suitable for testing for CXX11.
632AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER],
633[[
634#include <deque>
635#include <functional>
636#include <memory>
637#include <tuple>
638#include <array>
639#include <regex>
640#include <iostream>
641
642namespace cxx11test
643{
644 typedef std::shared_ptr<std::string> sptr;
645 typedef std::weak_ptr<std::string> wptr;
646
647 typedef std::tuple<std::string,int,double> tp;
648 typedef std::array<int, 20> int_array;
649
650 constexpr int get_val() { return 20; }
651
652 struct testinit
653 {
654 int i;
655 double d;
656 };
657
658 class delegate {
659 public:
660 delegate(int n) : n(n) {}
661 delegate(): delegate(2354) {}
662
663 virtual int getval() { return this->n; };
664 protected:
665 int n;
666 };
667
668 class overridden : public delegate {
669 public:
670 overridden(int n): delegate(n) {}
671 virtual int getval() override final { return this->n * 2; }
672 };
673
674 class nocopy {
675 public:
676 nocopy(int i): i(i) {}
677 nocopy() = default;
678 nocopy(const nocopy&) = delete;
679 nocopy & operator=(const nocopy&) = delete;
680 private:
681 int i;
682 };
683}
684]])# _AC_CXX_CXX11_TEST_HEADER
685
686# _AC_CXX_CXX11_TEST_BODY
687# -----------------------
688# A C++ body suitable for testing for CXX11, assuming the corresponding header.
689AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
690[[
691{
692 // Test auto and decltype
693 std::deque<int> d;
694 d.push_front(43);
695 d.push_front(484);
696 d.push_front(3);
697 d.push_front(844);
698 int total = 0;
699 for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }
700
701 auto a1 = 6538;
702 auto a2 = 48573953.4;
703 auto a3 = "String literal";
704
705 decltype(a2) a4 = 34895.034;
706}
707{
708 // Test constexpr
709 short sa[cxx11test::get_val()] = { 0 };
710}
711{
712 // Test initializer lists
713 cxx11test::testinit il = { 4323, 435234.23544 };
714}
715{
716 // Test range-based for and lambda
717 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
718 for (int &x : array) { x += 23; }
719 std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
720}
721{
722 using cxx11test::sptr;
723 using cxx11test::wptr;
724
725 sptr sp(new std::string("ASCII string"));
726 wptr wp(sp);
727 sptr sp2(wp);
728}
729{
730 cxx11test::tp tuple("test", 54, 45.53434);
731 double d = std::get<2>(tuple);
732 std::string s;
733 int i;
734 std::tie(s,i,d) = tuple;
735}
736{
737 static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
738 std::string testmatch("Test if this string matches");
739 bool match = std::regex_search(testmatch, filename_regex);
740}
741{
742 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
743 cxx11test::int_array::size_type size = array.size();
744}
745{
746 // Test constructor delegation
747 cxx11test::delegate d1;
748 cxx11test::delegate d2();
749 cxx11test::delegate d3(45);
750}
751{
752 // Test override and final
753 cxx11test::overridden o1(55464);
754}
755{
756 // Test nullptr
757 char *c = nullptr;
758}
759{
760 // Test template brackets
761 std::vector<std::pair<int,char*>> v1;
762}
763{
764 // Unicode literals
765 char const *utf8 = u8"UTF-8 string \u2500";
766 char16_t const *utf16 = u"UTF-8 string \u2500";
767 char32_t const *utf32 = U"UTF-32 string \u2500";
768}
769]])
770
771# _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
772# -------------------------------------------------------------------
773
774# If the C++ compiler is not in ISO C++98 mode by default, try to add
775# an option to output variable CXX to make it so. This macro tries
776# various options that select ISO C++98 on some system or another. It
777# considers the compiler to be in ISO C++98 mode if it handles basic
778# features of the std namespace including: string, containers (list,
779# map, set, vector), streams (fstreams, iostreams, stringstreams,
780# iomanip), pair, exceptions and algorithms.
781
782
783AC_DEFUN([_AC_PROG_CXX_CXX98],
784[_AC_CXX_STD_TRY([cxx98],
785[_AC_CXX_CXX98_TEST_HEADER],
786[_AC_CXX_CXX98_TEST_BODY],
787dnl Try
788dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98)
789dnl IBM XL C -qlanglvl=extended
790dnl HP aC++ -AA
791dnl Intel ICC -std=gnu++98
792dnl Solaris N/A (default)
793dnl Tru64 N/A (default, but -std gnu could be used)
794dnl with extended modes being tried first.
795[[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl
796])# _AC_PROG_CXX_CXX98
797
798# _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
799# -------------------------------------------------------------------
800# If the C++ compiler is not in ISO CXX11 mode by default, try to add
801# an option to output variable CXX to make it so. This macro tries
802# various options that select ISO C++11 on some system or another. It
803# considers the compiler to be in ISO C++11 mode if it handles all the
804# tests from the C++98 checks, plus the following: Language features
805# (auto, constexpr, decltype, default/deleted constructors, delegate
806# constructors, final, initializer lists, lambda functions, nullptr,
807# override, range-based for loops, template brackets without spaces,
808# unicode literals) and library features (array, memory (shared_ptr,
809# weak_ptr), regex and tuple types).
810AC_DEFUN([_AC_PROG_CXX_CXX11],
811[_AC_CXX_STD_TRY([cxx11],
812[_AC_CXX_CXX11_TEST_HEADER
813_AC_CXX_CXX98_TEST_HEADER],
814[_AC_CXX_CXX11_TEST_BODY
815_AC_CXX_CXX98_TEST_BODY],
816dnl Try
817dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants]
818dnl IBM XL C -qlanglvl=extended0x
819dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11)
820dnl HP aC++ -AA
821dnl Intel ICC -std=c++11 -std=c++0x
822dnl Solaris N/A (no support)
823dnl Tru64 N/A (no support)
824dnl with extended modes being tried first.
825[[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl
826])# _AC_PROG_CXX_CXX11
827
828
829])# m4_version_prereq
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
index 20be01aa..dc297175 100644
--- a/gl/m4/stdalign.m4
+++ b/gl/m4/stdalign.m4
@@ -1,6 +1,6 @@
1# Check for stdalign.h that conforms to C11. 1# Check for alignas and alignof that conform to C23.
2 2
3dnl Copyright 2011-2013 Free Software Foundation, Inc. 3dnl Copyright 2011-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -9,16 +9,23 @@ dnl with or without modifications, as long as this notice is preserved.
9 9
10AC_DEFUN([gl_STDALIGN_H], 10AC_DEFUN([gl_STDALIGN_H],
11[ 11[
12 AC_CACHE_CHECK([for working stdalign.h], 12 AC_CACHE_CHECK([for alignas and alignof],
13 [gl_cv_header_working_stdalign_h], 13 [gl_cv_header_working_stdalign_h],
14 [AC_COMPILE_IFELSE( 14 [gl_save_CFLAGS=$CFLAGS
15 for gl_working in "yes, keywords" "yes, <stdalign.h> macros"; do
16 AS_CASE([$gl_working],
17 [*stdalign.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_STDALIGN_H"])
18 AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM( 19 [AC_LANG_PROGRAM(
16 [[#include <stdalign.h> 20 [[#include <stdint.h>
21 #ifdef INCLUDE_STDALIGN_H
22 #include <stdalign.h>
23 #endif
17 #include <stddef.h> 24 #include <stddef.h>
18 25
19 /* Test that alignof yields a result consistent with offsetof. 26 /* Test that alignof yields a result consistent with offsetof.
20 This catches GCC bug 52023 27 This catches GCC bug 52023
21 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ 28 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
22 #ifdef __cplusplus 29 #ifdef __cplusplus
23 template <class t> struct alignof_helper { char a; t b; }; 30 template <class t> struct alignof_helper { char a; t b; };
24 # define ao(type) offsetof (alignof_helper<type>, b) 31 # define ao(type) offsetof (alignof_helper<type>, b)
@@ -29,25 +36,103 @@ AC_DEFUN([gl_STDALIGN_H],
29 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; 36 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
30 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; 37 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
31 38
32 /* Test _Alignas only on platforms where gnulib can help. */ 39 /* Test alignas only on platforms where gnulib can help. */
33 #if \ 40 #if \
34 ((defined __cplusplus && 201103 <= __cplusplus) \ 41 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \ 42 || (__TINYC__ && defined __attribute__) \
36 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 43 || (defined __APPLE__ && defined __MACH__ \
44 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
45 : __GNUC__) \
46 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
47 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \
48 || 1300 <= _MSC_VER)
37 struct alignas_test { char c; char alignas (8) alignas_8; }; 49 struct alignas_test { char c; char alignas (8) alignas_8; };
38 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 50 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
39 ? 1 : -1]; 51 ? 1 : -1];
40 #endif 52 #endif
41 ]])], 53 ]])],
42 [gl_cv_header_working_stdalign_h=yes], 54 [gl_cv_header_working_stdalign_h=$gl_working],
43 [gl_cv_header_working_stdalign_h=no])]) 55 [gl_cv_header_working_stdalign_h=no])
56
57 CFLAGS=$gl_save_CFLAGS
58 test "$gl_cv_header_working_stdalign_h" != no && break
59 done])
60
61 GL_GENERATE_STDALIGN_H=false
62 AS_CASE([$gl_cv_header_working_stdalign_h],
63 [no],
64 [GL_GENERATE_STDALIGN_H=true],
65 [yes*keyword*],
66 [AC_DEFINE([HAVE_C_ALIGNASOF], [1],
67 [Define to 1 if the alignas and alignof keywords work.])])
44 68
45 if test $gl_cv_header_working_stdalign_h = yes; then 69 AC_CHECK_HEADERS_ONCE([stdalign.h])
46 STDALIGN_H=''
47 else
48 STDALIGN_H='stdalign.h'
49 fi
50 70
51 AC_SUBST([STDALIGN_H]) 71 dnl The "zz" puts this toward config.h's end, to avoid potential
52 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) 72 dnl collisions with other definitions.
73 AH_VERBATIM([zzalignas],
74[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof
75# if HAVE_STDALIGN_H
76# include <stdalign.h>
77# else
78 /* Substitute. Keep consistent with gnulib/lib/stdalign.in.h. */
79# ifndef _GL_STDALIGN_H
80# define _GL_STDALIGN_H
81# undef _Alignas
82# undef _Alignof
83# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
84 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
85 && !defined __clang__) \
86 || (defined __clang__ && __clang_major__ < 8))
87# ifdef __cplusplus
88# if (201103 <= __cplusplus || defined _MSC_VER)
89# define _Alignof(type) alignof (type)
90# else
91 template <class __t> struct __alignof_helper { char __a; __t __b; };
92# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
93# define _GL_STDALIGN_NEEDS_STDDEF 1
94# endif
95# else
96# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
97# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
98# else
99# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
100# define _GL_STDALIGN_NEEDS_STDDEF 1
101# endif
102# endif
103# endif
104# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
105# define alignof _Alignof
106# endif
107# define __alignof_is_defined 1
108# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
109# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
110# define _Alignas(a) alignas (a)
111# elif (!defined __attribute__ \
112 && ((defined __APPLE__ && defined __MACH__ \
113 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
114 : __GNUC__ && !defined __ibmxl__) \
115 || (4 <= __clang_major__) \
116 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
117 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
118# define _Alignas(a) __attribute__ ((__aligned__ (a)))
119# elif 1300 <= _MSC_VER
120# define _Alignas(a) __declspec (align (a))
121# endif
122# endif
123# if ((defined _Alignas \
124 && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
125 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
126# define alignas _Alignas
127# endif
128# if (defined alignas \
129 || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
130# define __alignas_is_defined 1
131# endif
132# if _GL_STDALIGN_NEEDS_STDDEF
133# include <stddef.h>
134# endif
135# endif /* _GL_STDALIGN_H */
136# endif
137#endif])
53]) 138])
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4
deleted file mode 100644
index 80d5559a..00000000
--- a/gl/m4/stdbool.m4
+++ /dev/null
@@ -1,100 +0,0 @@
1# Check for stdbool.h that conforms to C99.
2
3dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8#serial 5
9
10# Prepare for substituting <stdbool.h> if it is not supported.
11
12AC_DEFUN([AM_STDBOOL_H],
13[
14 AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
15
16 # Define two additional variables used in the Makefile substitution.
17
18 if test "$ac_cv_header_stdbool_h" = yes; then
19 STDBOOL_H=''
20 else
21 STDBOOL_H='stdbool.h'
22 fi
23 AC_SUBST([STDBOOL_H])
24 AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
25
26 if test "$ac_cv_type__Bool" = yes; then
27 HAVE__BOOL=1
28 else
29 HAVE__BOOL=0
30 fi
31 AC_SUBST([HAVE__BOOL])
32])
33
34# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
35AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
36
37# This version of the macro is needed in autoconf <= 2.68.
38
39AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
40 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
41 [ac_cv_header_stdbool_h],
42 [AC_COMPILE_IFELSE(
43 [AC_LANG_PROGRAM(
44 [[
45 #include <stdbool.h>
46 #ifndef bool
47 "error: bool is not defined"
48 #endif
49 #ifndef false
50 "error: false is not defined"
51 #endif
52 #if false
53 "error: false is not 0"
54 #endif
55 #ifndef true
56 "error: true is not defined"
57 #endif
58 #if true != 1
59 "error: true is not 1"
60 #endif
61 #ifndef __bool_true_false_are_defined
62 "error: __bool_true_false_are_defined is not defined"
63 #endif
64
65 struct s { _Bool s: 1; _Bool t; } s;
66
67 char a[true == 1 ? 1 : -1];
68 char b[false == 0 ? 1 : -1];
69 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
70 char d[(bool) 0.5 == true ? 1 : -1];
71 /* See body of main program for 'e'. */
72 char f[(_Bool) 0.0 == false ? 1 : -1];
73 char g[true];
74 char h[sizeof (_Bool)];
75 char i[sizeof s.t];
76 enum { j = false, k = true, l = false * true, m = true * 256 };
77 /* The following fails for
78 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
79 _Bool n[m];
80 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
81 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
82 /* Catch a bug in an HP-UX C compiler. See
83 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
84 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
85 */
86 _Bool q = true;
87 _Bool *pq = &q;
88 ]],
89 [[
90 bool e = &s;
91 *pq |= q;
92 *pq |= ! q;
93 /* Refer to every declared value, to avoid compiler optimizations. */
94 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
95 + !m + !n + !o + !p + !q + !pq);
96 ]])],
97 [ac_cv_header_stdbool_h=yes],
98 [ac_cv_header_stdbool_h=no])])
99 AC_CHECK_TYPES([_Bool])
100])
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4
index 5da8ab1e..a2322ebb 100644
--- a/gl/m4/stddef_h.m4
+++ b/gl/m4/stddef_h.m4
@@ -1,19 +1,61 @@
1dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues. 1# stddef_h.m4 serial 13
2# stddef_h.m4 serial 4 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
7 6
8AC_DEFUN([gl_STDDEF_H], 7dnl A placeholder for <stddef.h>, for platforms that have issues.
8
9AC_DEFUN_ONCE([gl_STDDEF_H],
9[ 10[
10 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 11 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
11 AC_REQUIRE([gt_TYPE_WCHAR_T]) 12 AC_REQUIRE([gt_TYPE_WCHAR_T])
12 STDDEF_H= 13
14 dnl Persuade OpenBSD <stddef.h> to declare max_align_t.
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16
17 GL_GENERATE_STDDEF_H=false
18
19 dnl Test whether the type max_align_t exists and whether its alignment
20 dnl "is as great as is supported by the implementation in all contexts".
21 AC_CACHE_CHECK([for good max_align_t],
22 [gl_cv_type_max_align_t],
23 [AC_COMPILE_IFELSE(
24 [AC_LANG_PROGRAM(
25 [[/* On FreeBSD 12.0/x86, max_align_t defined by <stddef.h> has
26 the correct alignment with the default (wrong) definition of
27 _Alignof, but a wrong alignment as soon as we activate an
28 ISO C compliant _Alignof definition. */
29 #if ((defined __GNUC__ && 4 <= __GNUC__) || defined __clang__) && !defined __cplusplus
30 #define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
31 #endif
32 #include <stddef.h>
33 unsigned int s = sizeof (max_align_t);
34 #if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
35 int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];
36 int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1];
37 #endif
38 typedef struct { char a; max_align_t b; } max_helper;
39 typedef struct { char a; long b; } long_helper;
40 typedef struct { char a; double b; } double_helper;
41 typedef struct { char a; long double b; } long_double_helper;
42 int check3[2 * (offsetof (long_helper, b) <= offsetof (max_helper, b)) - 1];
43 int check4[2 * (offsetof (double_helper, b) <= offsetof (max_helper, b)) - 1];
44 int check5[2 * (offsetof (long_double_helper, b) <= offsetof (max_helper, b)) - 1];
45 ]])],
46 [gl_cv_type_max_align_t=yes],
47 [gl_cv_type_max_align_t=no])
48 ])
49 if test $gl_cv_type_max_align_t = no; then
50 HAVE_MAX_ALIGN_T=0
51 GL_GENERATE_STDDEF_H=true
52 fi
53
13 if test $gt_cv_c_wchar_t = no; then 54 if test $gt_cv_c_wchar_t = no; then
14 HAVE_WCHAR_T=0 55 HAVE_WCHAR_T=0
15 STDDEF_H=stddef.h 56 GL_GENERATE_STDDEF_H=true
16 fi 57 fi
58
17 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], 59 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
18 [gl_cv_decl_null_works], 60 [gl_cv_decl_null_works],
19 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> 61 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
@@ -23,25 +65,40 @@ AC_DEFUN([gl_STDDEF_H],
23 [gl_cv_decl_null_works=no])]) 65 [gl_cv_decl_null_works=no])])
24 if test $gl_cv_decl_null_works = no; then 66 if test $gl_cv_decl_null_works = no; then
25 REPLACE_NULL=1 67 REPLACE_NULL=1
26 STDDEF_H=stddef.h 68 GL_GENERATE_STDDEF_H=true
27 fi 69 fi
28 AC_SUBST([STDDEF_H]) 70
29 AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"]) 71 if $GL_GENERATE_STDDEF_H; then
30 if test -n "$STDDEF_H"; then
31 gl_NEXT_HEADERS([stddef.h]) 72 gl_NEXT_HEADERS([stddef.h])
32 fi 73 fi
33]) 74])
34 75
76# gl_STDDEF_MODULE_INDICATOR([modulename])
77# sets the shell variable that indicates the presence of the given module
78# to a C preprocessor expression that will evaluate to 1.
79# This macro invocation must not occur in macros that are AC_REQUIREd.
35AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], 80AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
36[ 81[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 82 dnl Ensure to expand the default settings once only.
38 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 83 gl_STDDEF_H_REQUIRE_DEFAULTS
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 84 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40]) 85])
41 86
87# Initializes the default values for AC_SUBSTed shell variables.
88# This macro must not be AC_REQUIREd. It must only be invoked, and only
89# outside of macros or in macros that are not AC_REQUIREd.
90AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS],
91[
92 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS], [
93 ])
94 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS])
95 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
96])
97
42AC_DEFUN([gl_STDDEF_H_DEFAULTS], 98AC_DEFUN([gl_STDDEF_H_DEFAULTS],
43[ 99[
44 dnl Assume proper GNU behavior unless another module says otherwise. 100 dnl Assume proper GNU behavior unless another module says otherwise.
45 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) 101 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
102 HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T])
46 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) 103 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
47]) 104])
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index 27cdcdb9..d6961b09 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,5 +1,5 @@
1# stdint.m4 serial 43 1# stdint.m4 serial 61
2dnl Copyright (C) 2001-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,25 +7,22 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl From Paul Eggert and Bruno Haible. 7dnl From Paul Eggert and Bruno Haible.
8dnl Test whether <stdint.h> is supported or must be substituted. 8dnl Test whether <stdint.h> is supported or must be substituted.
9 9
10AC_PREREQ([2.61])
11
10AC_DEFUN_ONCE([gl_STDINT_H], 12AC_DEFUN_ONCE([gl_STDINT_H],
11[ 13[
12 AC_PREREQ([2.59])dnl 14 AC_PREREQ([2.59])dnl
15 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 16
14 dnl Check for long long int and unsigned long long int. 17 AC_REQUIRE([gl_LIMITS_H])
15 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 18 AC_REQUIRE([gt_TYPE_WINT_T])
16 if test $ac_cv_type_long_long_int = yes; then 19
17 HAVE_LONG_LONG_INT=1 20 dnl For backward compatibility. Some packages may still be testing these
18 else 21 dnl macros.
19 HAVE_LONG_LONG_INT=0 22 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
20 fi 23 [Define to 1 if the system has the type 'long long int'.])
21 AC_SUBST([HAVE_LONG_LONG_INT]) 24 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
22 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) 25 [Define to 1 if the system has the type 'unsigned long long int'.])
23 if test $ac_cv_type_unsigned_long_long_int = yes; then
24 HAVE_UNSIGNED_LONG_LONG_INT=1
25 else
26 HAVE_UNSIGNED_LONG_LONG_INT=0
27 fi
28 AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
29 26
30 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does. 27 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
31 AC_CHECK_HEADERS_ONCE([wchar.h]) 28 AC_CHECK_HEADERS_ONCE([wchar.h])
@@ -37,7 +34,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
37 AC_SUBST([HAVE_WCHAR_H]) 34 AC_SUBST([HAVE_WCHAR_H])
38 35
39 dnl Check for <inttypes.h>. 36 dnl Check for <inttypes.h>.
40 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. 37 AC_CHECK_HEADERS_ONCE([inttypes.h])
41 if test $ac_cv_header_inttypes_h = yes; then 38 if test $ac_cv_header_inttypes_h = yes; then
42 HAVE_INTTYPES_H=1 39 HAVE_INTTYPES_H=1
43 else 40 else
@@ -46,7 +43,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
46 AC_SUBST([HAVE_INTTYPES_H]) 43 AC_SUBST([HAVE_INTTYPES_H])
47 44
48 dnl Check for <sys/types.h>. 45 dnl Check for <sys/types.h>.
49 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h. 46 AC_CHECK_HEADERS_ONCE([sys/types.h])
50 if test $ac_cv_header_sys_types_h = yes; then 47 if test $ac_cv_header_sys_types_h = yes; then
51 HAVE_SYS_TYPES_H=1 48 HAVE_SYS_TYPES_H=1
52 else 49 else
@@ -70,6 +67,8 @@ AC_DEFUN_ONCE([gl_STDINT_H],
70 AC_COMPILE_IFELSE([ 67 AC_COMPILE_IFELSE([
71 AC_LANG_PROGRAM([[ 68 AC_LANG_PROGRAM([[
72#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 69#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
70#define __STDC_CONSTANT_MACROS 1
71#define __STDC_LIMIT_MACROS 1
73#include <stdint.h> 72#include <stdint.h>
74/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */ 73/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */
75#if !(defined WCHAR_MIN && defined WCHAR_MAX) 74#if !(defined WCHAR_MIN && defined WCHAR_MAX)
@@ -150,6 +149,15 @@ uintptr_t h = UINTPTR_MAX;
150intmax_t i = INTMAX_MAX; 149intmax_t i = INTMAX_MAX;
151uintmax_t j = UINTMAX_MAX; 150uintmax_t j = UINTMAX_MAX;
152 151
152/* Check that SIZE_MAX has the correct type, if possible. */
153#if 201112 <= __STDC_VERSION__
154int k = _Generic (SIZE_MAX, size_t: 0);
155#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
156 || (0x5110 <= __SUNPRO_C && !__STDC__))
157extern size_t k;
158extern __typeof__ (SIZE_MAX) k;
159#endif
160
153#include <limits.h> /* for CHAR_BIT */ 161#include <limits.h> /* for CHAR_BIT */
154#define TYPE_MINIMUM(t) \ 162#define TYPE_MINIMUM(t) \
155 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) 163 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
@@ -162,7 +170,7 @@ struct s {
162 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) 170 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
163 && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) 171 && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
164 ? 1 : -1; 172 ? 1 : -1;
165 /* Detect bug in FreeBSD 6.0 / ia64. */ 173 /* Detect bug in FreeBSD 6.0/ia64 and FreeBSD 13.0/arm64. */
166 int check_SIG_ATOMIC: 174 int check_SIG_ATOMIC:
167 SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) 175 SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
168 && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) 176 && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
@@ -218,6 +226,8 @@ struct s {
218 AC_RUN_IFELSE([ 226 AC_RUN_IFELSE([
219 AC_LANG_PROGRAM([[ 227 AC_LANG_PROGRAM([[
220#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 228#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
229#define __STDC_CONSTANT_MACROS 1
230#define __STDC_LIMIT_MACROS 1
221#include <stdint.h> 231#include <stdint.h>
222] 232]
223gl_STDINT_INCLUDES 233gl_STDINT_INCLUDES
@@ -272,36 +282,88 @@ static const char *macro_values[] =
272]])], 282]])],
273 [gl_cv_header_working_stdint_h=yes], 283 [gl_cv_header_working_stdint_h=yes],
274 [], 284 [],
275 [dnl When cross-compiling, assume it works. 285 [case "$host_os" in
276 gl_cv_header_working_stdint_h=yes 286 # Guess yes on native Windows.
287 mingw*) gl_cv_header_working_stdint_h="guessing yes" ;;
288 # In general, assume it works.
289 *) gl_cv_header_working_stdint_h="guessing yes" ;;
290 esac
277 ]) 291 ])
278 ]) 292 ])
279 ]) 293 ])
280 fi 294 fi
281 if test "$gl_cv_header_working_stdint_h" = yes; then
282 STDINT_H=
283 else
284 dnl Check for <sys/inttypes.h>, and for
285 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
286 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
287 if test $ac_cv_header_sys_inttypes_h = yes; then
288 HAVE_SYS_INTTYPES_H=1
289 else
290 HAVE_SYS_INTTYPES_H=0
291 fi
292 AC_SUBST([HAVE_SYS_INTTYPES_H])
293 if test $ac_cv_header_sys_bitypes_h = yes; then
294 HAVE_SYS_BITYPES_H=1
295 else
296 HAVE_SYS_BITYPES_H=0
297 fi
298 AC_SUBST([HAVE_SYS_BITYPES_H])
299 295
300 gl_STDINT_TYPE_PROPERTIES 296 HAVE_C99_STDINT_H=0
301 STDINT_H=stdint.h 297 HAVE_SYS_BITYPES_H=0
302 fi 298 HAVE_SYS_INTTYPES_H=0
303 AC_SUBST([STDINT_H]) 299 GL_GENERATE_STDINT_H=true
304 AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) 300 case "$gl_cv_header_working_stdint_h" in
301 *yes)
302 HAVE_C99_STDINT_H=1
303 dnl Now see whether the system <stdint.h> works without
304 dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
305 dnl If not, there would be problems when stdint.h is included from C++.
306 AC_CACHE_CHECK([whether stdint.h works without ISO C predefines],
307 [gl_cv_header_stdint_without_STDC_macros],
308 [gl_cv_header_stdint_without_STDC_macros=no
309 AC_COMPILE_IFELSE([
310 AC_LANG_PROGRAM([[
311#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
312#include <stdint.h>
313]
314gl_STDINT_INCLUDES
315[
316intmax_t im = INTMAX_MAX;
317int32_t i32 = INT32_C (0x7fffffff);
318 ]])],
319 [gl_cv_header_stdint_without_STDC_macros=yes])
320 ])
321
322 if test $gl_cv_header_stdint_without_STDC_macros = no; then
323 AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
324 [Define to 1 if the system <stdint.h> predates C++11.])
325 AC_DEFINE([__STDC_LIMIT_MACROS], [1],
326 [Define to 1 if the system <stdint.h> predates C++11.])
327 fi
328 AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
329 [gl_cv_header_stdint_width],
330 [gl_cv_header_stdint_width=no
331 AC_COMPILE_IFELSE(
332 [AC_LANG_PROGRAM([[
333 /* Work if build is not clean. */
334 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
335 #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
336 #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
337 #endif
338 #include <stdint.h>
339 ]gl_STDINT_INCLUDES[
340 int iw = UINTMAX_WIDTH;
341 ]])],
342 [gl_cv_header_stdint_width=yes])])
343 if test "$gl_cv_header_stdint_width" = yes; then
344 GL_GENERATE_STDINT_H=false
345 fi
346 ;;
347 *)
348 dnl Check for <sys/inttypes.h>, and for
349 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
350 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
351 if test $ac_cv_header_sys_inttypes_h = yes; then
352 HAVE_SYS_INTTYPES_H=1
353 fi
354 if test $ac_cv_header_sys_bitypes_h = yes; then
355 HAVE_SYS_BITYPES_H=1
356 fi
357 gl_STDINT_TYPE_PROPERTIES
358 ;;
359 esac
360
361 dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
362 gl_REPLACE_LIMITS_H
363
364 AC_SUBST([HAVE_C99_STDINT_H])
365 AC_SUBST([HAVE_SYS_BITYPES_H])
366 AC_SUBST([HAVE_SYS_INTTYPES_H])
305]) 367])
306 368
307dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) 369dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
@@ -429,13 +491,9 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
429dnl gl_STDINT_INCLUDES 491dnl gl_STDINT_INCLUDES
430AC_DEFUN([gl_STDINT_INCLUDES], 492AC_DEFUN([gl_STDINT_INCLUDES],
431[[ 493[[
432 /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
433 included before <wchar.h>. */
434 #include <stddef.h> 494 #include <stddef.h>
435 #include <signal.h> 495 #include <signal.h>
436 #if HAVE_WCHAR_H 496 #if HAVE_WCHAR_H
437 # include <stdio.h>
438 # include <time.h>
439 # include <wchar.h> 497 # include <wchar.h>
440 #endif 498 #endif
441]]) 499]])
@@ -467,18 +525,7 @@ AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
467 dnl requirement that wint_t is "unchanged by default argument promotions". 525 dnl requirement that wint_t is "unchanged by default argument promotions".
468 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t. 526 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
469 dnl Set the variable BITSIZEOF_WINT_T accordingly. 527 dnl Set the variable BITSIZEOF_WINT_T accordingly.
470 if test $BITSIZEOF_WINT_T -lt 32; then 528 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
471 BITSIZEOF_WINT_T=32 529 BITSIZEOF_WINT_T=32
472 fi 530 fi
473]) 531])
474
475dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
476dnl Remove this when we can assume autoconf >= 2.61.
477m4_ifdef([AC_COMPUTE_INT], [], [
478 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
479])
480
481# Hey Emacs!
482# Local Variables:
483# indent-tabs-mode: nil
484# End:
diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4
index 511ab4e9..70349f6c 100644
--- a/gl/m4/stdint_h.m4
+++ b/gl/m4/stdint_h.m4
@@ -1,5 +1,5 @@
1# stdint_h.m4 serial 9 1# stdint_h.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index ebade067..94271e11 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,72 +1,71 @@
1# stdio_h.m4 serial 43 1# stdio_h.m4 serial 59
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_STDIO_H], 7AC_DEFUN_ONCE([gl_STDIO_H],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AH_VERBATIM([MINGW_ANSI_STDIO],
11[/* Use GNU style printf and scanf. */
12#ifndef __USE_MINGW_ANSI_STDIO
13# undef __USE_MINGW_ANSI_STDIO
14#endif
15])
16 AC_DEFINE([__USE_MINGW_ANSI_STDIO])
10 gl_NEXT_HEADERS([stdio.h]) 17 gl_NEXT_HEADERS([stdio.h])
11 18
12 dnl No need to create extra modules for these functions. Everyone who uses 19 dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and
13 dnl <stdio.h> likely needs them. 20 dnl inttypes.h behave like gnu instead of system; we must give our
14 GNULIB_FSCANF=1 21 dnl printf wrapper the right attribute to match.
15 gl_MODULE_INDICATOR([fscanf]) 22 AC_CACHE_CHECK([which flavor of printf attribute matches inttypes macros],
16 GNULIB_SCANF=1 23 [gl_cv_func_printf_attribute_flavor],
17 gl_MODULE_INDICATOR([scanf]) 24 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
18 GNULIB_FGETC=1 25 #define __STDC_FORMAT_MACROS 1
19 GNULIB_GETC=1 26 #include <stdio.h>
20 GNULIB_GETCHAR=1 27 #include <inttypes.h>
21 GNULIB_FGETS=1 28 /* For non-mingw systems, compilation will trivially succeed.
22 GNULIB_FREAD=1 29 For mingw, compilation will succeed for older mingw (system
23 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" 30 printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */
24 dnl "expected source file, required through AC_LIBSOURCES, not found". It is 31 #if (defined _WIN32 && ! defined __CYGWIN__) && \
25 dnl also an optimization, to avoid performing a configure check whose result 32 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
26 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING 33 extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1];
27 dnl or GNULIB_NONBLOCKING redundant. 34 #endif
35 ]])], [gl_cv_func_printf_attribute_flavor=system],
36 [gl_cv_func_printf_attribute_flavor=gnu])])
37 if test "$gl_cv_func_printf_attribute_flavor" = gnu; then
38 AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1],
39 [Define to 1 if printf and friends should be labeled with
40 attribute "__gnu_printf__" instead of "__printf__"])
41 fi
42
43 dnl This ifdef is an optimization, to avoid performing a configure check whose
44 dnl result is not used. But it does not make the test of
45 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
28 m4_ifdef([gl_NONBLOCKING_IO], [ 46 m4_ifdef([gl_NONBLOCKING_IO], [
29 gl_NONBLOCKING_IO 47 gl_NONBLOCKING_IO
30 if test $gl_cv_have_nonblocking != yes; then 48 if test $gl_cv_have_nonblocking != yes; then
31 REPLACE_STDIO_READ_FUNCS=1 49 REPLACE_STDIO_READ_FUNCS=1
32 AC_LIBOBJ([stdio-read])
33 fi 50 fi
34 ]) 51 ])
35 52
36 dnl No need to create extra modules for these functions. Everyone who uses 53 dnl This ifdef is an optimization, to avoid performing a configure check whose
37 dnl <stdio.h> likely needs them. 54 dnl result is not used. But it does not make the test of
38 GNULIB_FPRINTF=1 55 dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
39 GNULIB_PRINTF=1
40 GNULIB_VFPRINTF=1
41 GNULIB_VPRINTF=1
42 GNULIB_FPUTC=1
43 GNULIB_PUTC=1
44 GNULIB_PUTCHAR=1
45 GNULIB_FPUTS=1
46 GNULIB_PUTS=1
47 GNULIB_FWRITE=1
48 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
49 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
50 dnl also an optimization, to avoid performing a configure check whose result
51 dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
52 dnl GNULIB_SIGPIPE redundant.
53 m4_ifdef([gl_SIGNAL_SIGPIPE], [ 56 m4_ifdef([gl_SIGNAL_SIGPIPE], [
54 gl_SIGNAL_SIGPIPE 57 gl_SIGNAL_SIGPIPE
55 if test $gl_cv_header_signal_h_SIGPIPE != yes; then 58 if test $gl_cv_header_signal_h_SIGPIPE != yes; then
56 REPLACE_STDIO_WRITE_FUNCS=1 59 REPLACE_STDIO_WRITE_FUNCS=1
57 AC_LIBOBJ([stdio-write])
58 fi 60 fi
59 ]) 61 ])
60 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" 62 dnl This ifdef is an optimization, to avoid performing a configure check whose
61 dnl "expected source file, required through AC_LIBSOURCES, not found". It is 63 dnl result is not used. But it does not make the test of
62 dnl also an optimization, to avoid performing a configure check whose result 64 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
63 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
64 dnl or GNULIB_NONBLOCKING redundant.
65 m4_ifdef([gl_NONBLOCKING_IO], [ 65 m4_ifdef([gl_NONBLOCKING_IO], [
66 gl_NONBLOCKING_IO 66 gl_NONBLOCKING_IO
67 if test $gl_cv_have_nonblocking != yes; then 67 if test $gl_cv_have_nonblocking != yes; then
68 REPLACE_STDIO_WRITE_FUNCS=1 68 REPLACE_STDIO_WRITE_FUNCS=1
69 AC_LIBOBJ([stdio-write])
70 fi 69 fi
71 ]) 70 ])
72 71
@@ -76,73 +75,104 @@ AC_DEFUN([gl_STDIO_H],
76 gl_WARN_ON_USE_PREPARE([[#include <stdio.h> 75 gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
77 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen 76 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen
78 renameat snprintf tmpfile vdprintf vsnprintf]) 77 renameat snprintf tmpfile vdprintf vsnprintf])
78
79 AC_REQUIRE([AC_C_RESTRICT])
80
81 AC_CHECK_DECLS_ONCE([fcloseall])
82 if test $ac_cv_have_decl_fcloseall = no; then
83 HAVE_DECL_FCLOSEALL=0
84 fi
79]) 85])
80 86
87# gl_STDIO_MODULE_INDICATOR([modulename])
88# sets the shell variable that indicates the presence of the given module
89# to a C preprocessor expression that will evaluate to 1.
90# This macro invocation must not occur in macros that are AC_REQUIREd.
81AC_DEFUN([gl_STDIO_MODULE_INDICATOR], 91AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
82[ 92[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 93 dnl Ensure to expand the default settings once only.
84 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 94 gl_STDIO_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 95 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests. 96 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 97 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88]) 98])
89 99
100# Initializes the default values for AC_SUBSTed shell variables.
101# This macro must not be AC_REQUIREd. It must only be invoked, and only
102# outside of macros or in macros that are not AC_REQUIREd.
103AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
104[
105 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN_GNU])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTC])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTS])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREAD])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREOPEN])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSCANF])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEK])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEKO])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF_POSIX])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTC])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTCHAR])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTS])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMOVE])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAME])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX])
160 dnl Support Microsoft deprecated alias function names by default.
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FILENO], [1])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETW], [1])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTW], [1])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TEMPNAM], [1])
167 ])
168 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS])
169 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
170])
171
90AC_DEFUN([gl_STDIO_H_DEFAULTS], 172AC_DEFUN([gl_STDIO_H_DEFAULTS],
91[ 173[
92 GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF])
93 GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE])
94 GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN])
95 GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
96 GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC])
97 GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS])
98 GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
99 GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF])
100 GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
101 GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE])
102 GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC])
103 GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS])
104 GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD])
105 GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
106 GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF])
107 GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
108 GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
109 GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
110 GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
111 GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE])
112 GNULIB_GETC=0; AC_SUBST([GNULIB_GETC])
113 GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR])
114 GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
115 GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
116 GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
117 GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
118 GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE])
119 GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
120 GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN])
121 GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF])
122 GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX])
123 GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC])
124 GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR])
125 GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS])
126 GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE])
127 GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME])
128 GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT])
129 GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF])
130 GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
131 GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
132 GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING])
133 GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
134 GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
135 GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
136 GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF])
137 GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF])
138 GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
139 GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
140 GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
141 GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF])
142 GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX])
143 GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
144 GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
145 dnl Assume proper GNU behavior unless another module says otherwise. 174 dnl Assume proper GNU behavior unless another module says otherwise.
175 HAVE_DECL_FCLOSEALL=1; AC_SUBST([HAVE_DECL_FCLOSEALL])
146 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) 176 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE])
147 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) 177 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO])
148 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) 178 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO])
@@ -164,6 +194,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
164 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN]) 194 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN])
165 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) 195 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
166 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) 196 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
197 REPLACE_FOPEN_FOR_FOPEN_GNU=0; AC_SUBST([REPLACE_FOPEN_FOR_FOPEN_GNU])
167 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) 198 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
168 REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) 199 REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE])
169 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) 200 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index 2027ab3c..e96be22f 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,10 +1,10 @@
1# stdlib_h.m4 serial 42 1# stdlib_h.m4 serial 66
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_STDLIB_H], 7AC_DEFUN_ONCE([gl_STDLIB_H],
8[ 8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 gl_NEXT_HEADERS([stdlib.h]) 10 gl_NEXT_HEADERS([stdlib.h])
@@ -14,104 +14,187 @@ AC_DEFUN([gl_STDLIB_H],
14 dnl guaranteed by C89. 14 dnl guaranteed by C89.
15 gl_WARN_ON_USE_PREPARE([[#include <stdlib.h> 15 gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
16#if HAVE_SYS_LOADAVG_H 16#if HAVE_SYS_LOADAVG_H
17/* OpenIndiana has a bug: <sys/time.h> must be included before
18 <sys/loadavg.h>. */
19# include <sys/time.h>
17# include <sys/loadavg.h> 20# include <sys/loadavg.h>
18#endif 21#endif
19#if HAVE_RANDOM_H 22#if HAVE_RANDOM_H
20# include <random.h> 23# include <random.h>
21#endif 24#endif
22 ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt 25 ]], [_Exit aligned_alloc atoll canonicalize_file_name free
23 initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps 26 getloadavg getsubopt grantpt
24 posix_openpt ptsname ptsname_r random random_r realpath rpmatch 27 initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps
25 secure_getenv setenv setstate setstate_r srandom srandom_r 28 posix_memalign posix_openpt ptsname ptsname_r qsort_r
26 strtod strtoll strtoull unlockpt unsetenv]) 29 random random_r reallocarray realpath rpmatch secure_getenv setenv
30 setstate setstate_r srandom srandom_r
31 strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv])
32
33 AC_REQUIRE([AC_C_RESTRICT])
34
35 AC_CHECK_DECLS_ONCE([ecvt])
36 if test $ac_cv_have_decl_ecvt = no; then
37 HAVE_DECL_ECVT=0
38 fi
39 AC_CHECK_DECLS_ONCE([fcvt])
40 if test $ac_cv_have_decl_fcvt = no; then
41 HAVE_DECL_FCVT=0
42 fi
43 AC_CHECK_DECLS_ONCE([gcvt])
44 if test $ac_cv_have_decl_gcvt = no; then
45 HAVE_DECL_GCVT=0
46 fi
27]) 47])
28 48
49# gl_STDLIB_MODULE_INDICATOR([modulename])
50# sets the shell variable that indicates the presence of the given module
51# to a C preprocessor expression that will evaluate to 1.
52# This macro invocation must not occur in macros that are AC_REQUIREd.
29AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], 53AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
30[ 54[
31 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 55 dnl Ensure to expand the default settings once only.
32 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 56 gl_STDLIB_H_REQUIRE_DEFAULTS
33 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 57 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
34 dnl Define it also as a C macro, for the benefit of the unit tests. 58 dnl Define it also as a C macro, for the benefit of the unit tests.
35 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 59 gl_MODULE_INDICATOR_FOR_TESTS([$1])
36]) 60])
37 61
62# Initializes the default values for AC_SUBSTed shell variables.
63# This macro must not be AC_REQUIREd. It must only be invoked, and only
64# outside of macros or in macros that are not AC_REQUIREd.
65AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
66[
67 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [
68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT])
69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC])
70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL])
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU])
72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX])
73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME])
74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX])
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMPS])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMP])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMPS])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_MEMALIGN])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_OPENPT])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUL])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOULL])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYSTEM_POSIX])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLOCKPT])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNSETENV])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOMB])
111 dnl Support Microsoft deprecated alias function names by default.
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ECVT], [1])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCVT], [1])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GCVT], [1])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKTEMP], [1])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTENV], [1])
117 ])
118 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS])
119 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
120])
121
38AC_DEFUN([gl_STDLIB_H_DEFAULTS], 122AC_DEFUN([gl_STDLIB_H_DEFAULTS],
39[ 123[
40 GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT])
41 GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
42 GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
43 GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
44 GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
45 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
46 GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT])
47 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
48 GNULIB_MBTOWC=0; AC_SUBST([GNULIB_MBTOWC])
49 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
50 GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
51 GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
52 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
53 GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
54 GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT])
55 GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME])
56 GNULIB_PTSNAME_R=0; AC_SUBST([GNULIB_PTSNAME_R])
57 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
58 GNULIB_RANDOM=0; AC_SUBST([GNULIB_RANDOM])
59 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
60 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
61 GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH])
62 GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
63 GNULIB_SECURE_GETENV=0; AC_SUBST([GNULIB_SECURE_GETENV])
64 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
65 GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
66 GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
67 GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
68 GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX])
69 GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT])
70 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
71 GNULIB_WCTOMB=0; AC_SUBST([GNULIB_WCTOMB])
72 dnl Assume proper GNU behavior unless another module says otherwise. 124 dnl Assume proper GNU behavior unless another module says otherwise.
73 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) 125 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT])
126 HAVE_ALIGNED_ALLOC=1; AC_SUBST([HAVE_ALIGNED_ALLOC])
74 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) 127 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
75 HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) 128 HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
129 HAVE_DECL_ECVT=1; AC_SUBST([HAVE_DECL_ECVT])
130 HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT])
131 HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT])
76 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) 132 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
77 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) 133 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
78 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) 134 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
135 HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE])
136 HAVE_DECL_INITSTATE=1; AC_SUBST([HAVE_DECL_INITSTATE])
137 HAVE_MBTOWC=1; AC_SUBST([HAVE_MBTOWC])
79 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) 138 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
80 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) 139 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
81 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) 140 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
82 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) 141 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
83 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) 142 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
143 HAVE_POSIX_MEMALIGN=1; AC_SUBST([HAVE_POSIX_MEMALIGN])
84 HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT]) 144 HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT])
85 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) 145 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
86 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R]) 146 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R])
147 HAVE_QSORT_R=1; AC_SUBST([HAVE_QSORT_R])
87 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM]) 148 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM])
88 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H]) 149 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H])
89 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) 150 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
151 HAVE_REALLOCARRAY=1; AC_SUBST([HAVE_REALLOCARRAY])
90 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) 152 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
91 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) 153 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
92 HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV]) 154 HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV])
93 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) 155 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
94 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV]) 156 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV])
157 HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE])
158 HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE])
95 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) 159 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
160 HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL])
161 HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD])
96 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) 162 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
163 HAVE_STRTOUL=1; AC_SUBST([HAVE_STRTOUL])
97 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) 164 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
98 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) 165 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
99 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) 166 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
100 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) 167 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
101 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) 168 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
102 REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) 169 REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC])
170 REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
171 REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
103 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) 172 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
104 REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) 173 REPLACE_FREE=0; AC_SUBST([REPLACE_FREE])
174 REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE])
175 REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
176 REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
105 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) 177 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
106 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) 178 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
179 REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN])
107 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) 180 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME])
108 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) 181 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
109 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) 182 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
183 REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R])
184 REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM])
110 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) 185 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
111 REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) 186 REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU])
187 REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX])
188 REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY])
112 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) 189 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
113 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) 190 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
191 REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE])
114 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) 192 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
193 REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL])
194 REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD])
195 REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL])
196 REPLACE_STRTOUL=0; AC_SUBST([REPLACE_STRTOUL])
197 REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL])
115 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) 198 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
116 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) 199 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB])
117]) 200])
diff --git a/gl/m4/strcase.m4 b/gl/m4/strcase.m4
index 22bf57c9..3cf740d2 100644
--- a/gl/m4/strcase.m4
+++ b/gl/m4/strcase.m4
@@ -1,5 +1,5 @@
1# strcase.m4 serial 11 1# strcase.m4 serial 12
2dnl Copyright (C) 2002, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ AC_DEFUN([gl_STRCASE],
12 12
13AC_DEFUN([gl_FUNC_STRCASECMP], 13AC_DEFUN([gl_FUNC_STRCASECMP],
14[ 14[
15 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 15 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
16 AC_CHECK_FUNCS([strcasecmp]) 16 AC_CHECK_FUNCS([strcasecmp])
17 if test $ac_cv_func_strcasecmp = no; then 17 if test $ac_cv_func_strcasecmp = no; then
18 HAVE_STRCASECMP=0 18 HAVE_STRCASECMP=0
@@ -21,7 +21,7 @@ AC_DEFUN([gl_FUNC_STRCASECMP],
21 21
22AC_DEFUN([gl_FUNC_STRNCASECMP], 22AC_DEFUN([gl_FUNC_STRNCASECMP],
23[ 23[
24 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 24 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
25 AC_CHECK_FUNCS([strncasecmp]) 25 AC_CHECK_FUNCS([strncasecmp])
26 if test $ac_cv_func_strncasecmp = yes; then 26 if test $ac_cv_func_strncasecmp = yes; then
27 HAVE_STRNCASECMP=1 27 HAVE_STRNCASECMP=1
diff --git a/gl/m4/strcasestr.m4 b/gl/m4/strcasestr.m4
index 8681a6a4..971e0b23 100644
--- a/gl/m4/strcasestr.m4
+++ b/gl/m4/strcasestr.m4
@@ -1,5 +1,5 @@
1# strcasestr.m4 serial 21 1# strcasestr.m4 serial 28
2dnl Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl Check that strcasestr is present and works. 7dnl Check that strcasestr is present and works.
8AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE], 8AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
9[ 9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 10 AC_REQUIRE([gl_STRING_H_DEFAULTS])
11 11
12 dnl Persuade glibc <string.h> to declare strcasestr(). 12 dnl Persuade glibc <string.h> to declare strcasestr().
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -17,28 +17,38 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
17 if test $ac_cv_func_strcasestr = no; then 17 if test $ac_cv_func_strcasestr = no; then
18 HAVE_STRCASESTR=0 18 HAVE_STRCASESTR=0
19 else 19 else
20 if test "$gl_cv_func_memchr_works" != yes; then 20 if test $REPLACE_MEMCHR = 1; then
21 REPLACE_STRCASESTR=1 21 REPLACE_STRCASESTR=1
22 else 22 else
23 dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. 23 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
24 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637.
24 AC_CACHE_CHECK([whether strcasestr works], 25 AC_CACHE_CHECK([whether strcasestr works],
25 [gl_cv_func_strcasestr_works_always], 26 [gl_cv_func_strcasestr_works_always],
26 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 27 [AC_RUN_IFELSE(
27#include <string.h> /* for strcasestr */ 28 [AC_LANG_PROGRAM([[
29#include <string.h> /* for __GNU_LIBRARY__, strcasestr */
30#ifdef __GNU_LIBRARY__
31 #include <features.h>
32 #if __GLIBC__ == 2 && __GLIBC_MINOR__ == 28
33 Unlucky user
34 #endif
35#endif
28#define P "_EF_BF_BD" 36#define P "_EF_BF_BD"
29#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P 37#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
30#define NEEDLE P P P P P 38#define NEEDLE P P P P P
31]], [[return !!strcasestr (HAYSTACK, NEEDLE); 39]],
32 ]])], 40 [[return !!strcasestr (HAYSTACK, NEEDLE);
33 [gl_cv_func_strcasestr_works_always=yes], 41 ]])],
34 [gl_cv_func_strcasestr_works_always=no], 42 [gl_cv_func_strcasestr_works_always=yes],
35 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not 43 [gl_cv_func_strcasestr_works_always=no],
36 dnl affected, since it uses different source code for strcasestr 44 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
37 dnl than glibc. 45 dnl affected, since it uses different source code for strcasestr
38 dnl Assume that it works on all other platforms, even if it is not 46 dnl than glibc.
39 dnl linear. 47 dnl Assume that it works on all other platforms, even if it is not
40 AC_EGREP_CPP([Lucky user], 48 dnl linear.
41 [ 49 AC_EGREP_CPP([Lucky user],
50 [
51#include <string.h> /* for __GNU_LIBRARY__ */
42#ifdef __GNU_LIBRARY__ 52#ifdef __GNU_LIBRARY__
43 #include <features.h> 53 #include <features.h>
44 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ 54 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
@@ -53,10 +63,10 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
53#else 63#else
54 Lucky user 64 Lucky user
55#endif 65#endif
56 ], 66 ],
57 [gl_cv_func_strcasestr_works_always="guessing yes"], 67 [gl_cv_func_strcasestr_works_always="guessing yes"],
58 [gl_cv_func_strcasestr_works_always="guessing no"]) 68 [gl_cv_func_strcasestr_works_always="$gl_cross_guess_normal"])
59 ]) 69 ])
60 ]) 70 ])
61 case "$gl_cv_func_strcasestr_works_always" in 71 case "$gl_cv_func_strcasestr_works_always" in
62 *yes) ;; 72 *yes) ;;
@@ -80,7 +90,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR],
80#include <string.h> /* for strcasestr */ 90#include <string.h> /* for strcasestr */
81#include <stdlib.h> /* for malloc */ 91#include <stdlib.h> /* for malloc */
82#include <unistd.h> /* for alarm */ 92#include <unistd.h> /* for alarm */
83static void quit (int sig) { exit (sig + 128); } 93static void quit (int sig) { _exit (sig + 128); }
84]], [[ 94]], [[
85 int result = 0; 95 int result = 0;
86 size_t m = 1000000; 96 size_t m = 1000000;
@@ -102,6 +112,9 @@ static void quit (int sig) { exit (sig + 128); }
102 if (!strcasestr (haystack, needle)) 112 if (!strcasestr (haystack, needle))
103 result |= 1; 113 result |= 1;
104 } 114 }
115 /* Free allocated memory, in case some sanitizer is watching. */
116 free (haystack);
117 free (needle);
105 return result; 118 return result;
106 ]])], 119 ]])],
107 [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no], 120 [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
@@ -124,7 +137,7 @@ static void quit (int sig) { exit (sig + 128); }
124#endif 137#endif
125 ], 138 ],
126 [gl_cv_func_strcasestr_linear="guessing yes"], 139 [gl_cv_func_strcasestr_linear="guessing yes"],
127 [gl_cv_func_strcasestr_linear="guessing no"]) 140 [gl_cv_func_strcasestr_linear="$gl_cross_guess_normal"])
128 ]) 141 ])
129 ]) 142 ])
130 case "$gl_cv_func_strcasestr_linear" in 143 case "$gl_cv_func_strcasestr_linear" in
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index 3989844b..8879eb08 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,19 +1,19 @@
1# strerror.m4 serial 17 1# strerror.m4 serial 23
2dnl Copyright (C) 2002, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_STRERROR], 7AC_DEFUN([gl_FUNC_STRERROR],
8[ 8[
9 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 9 AC_REQUIRE([gl_STRING_H_DEFAULTS])
10 AC_REQUIRE([gl_HEADER_ERRNO_H]) 10 AC_REQUIRE([gl_HEADER_ERRNO_H])
11 AC_REQUIRE([gl_FUNC_STRERROR_0]) 11 AC_REQUIRE([gl_FUNC_STRERROR_0])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ 13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) 14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
15 ]) 15 ])
16 if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then 16 if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" = false:0; then
17 AC_CACHE_CHECK([for working strerror function], 17 AC_CACHE_CHECK([for working strerror function],
18 [gl_cv_func_working_strerror], 18 [gl_cv_func_working_strerror],
19 [AC_RUN_IFELSE( 19 [AC_RUN_IFELSE(
@@ -24,10 +24,12 @@ AC_DEFUN([gl_FUNC_STRERROR],
24 [gl_cv_func_working_strerror=yes], 24 [gl_cv_func_working_strerror=yes],
25 [gl_cv_func_working_strerror=no], 25 [gl_cv_func_working_strerror=no],
26 [case "$host_os" in 26 [case "$host_os" in
27 # Guess yes on glibc systems. 27 # Guess yes on glibc systems.
28 *-gnu*) gl_cv_func_working_strerror="guessing yes" ;; 28 *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;;
29 # If we don't know, assume the worst. 29 # Guess yes on musl systems.
30 *) gl_cv_func_working_strerror="guessing no" ;; 30 *-musl*) gl_cv_func_working_strerror="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;;
31 esac 33 esac
32 ]) 34 ])
33 ]) 35 ])
@@ -78,10 +80,14 @@ AC_DEFUN([gl_FUNC_STRERROR_0],
78 [gl_cv_func_strerror_0_works=yes], 80 [gl_cv_func_strerror_0_works=yes],
79 [gl_cv_func_strerror_0_works=no], 81 [gl_cv_func_strerror_0_works=no],
80 [case "$host_os" in 82 [case "$host_os" in
81 # Guess yes on glibc systems. 83 # Guess yes on glibc systems.
82 *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; 84 *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;;
83 # If we don't know, assume the worst. 85 # Guess yes on musl systems.
84 *) gl_cv_func_strerror_0_works="guessing no" ;; 86 *-musl*) gl_cv_func_strerror_0_works="guessing yes" ;;
87 # Guess yes on native Windows.
88 mingw*) gl_cv_func_strerror_0_works="guessing yes" ;;
89 # If we don't know, obey --enable-cross-guesses.
90 *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;;
85 esac 91 esac
86 ]) 92 ])
87 ]) 93 ])
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index cc5fbbb3..5da3cc25 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -1,25 +1,19 @@
1# Configure a GNU-like replacement for <string.h>. 1# Configure a GNU-like replacement for <string.h>.
2 2
3# Copyright (C) 2007-2013 Free Software Foundation, Inc. 3# Copyright (C) 2007-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6# with or without modifications, as long as this notice is preserved.
7 7
8# serial 21 8# serial 35
9 9
10# Written by Paul Eggert. 10# Written by Paul Eggert.
11 11
12AC_DEFUN([gl_HEADER_STRING_H], 12AC_DEFUN_ONCE([gl_STRING_H],
13[ 13[
14 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 14 dnl Ensure to expand the default settings once only, before all statements
15 dnl once only, before all statements that occur in other macros. 15 dnl that occur in other macros.
16 AC_REQUIRE([gl_HEADER_STRING_H_BODY]) 16 AC_REQUIRE([gl_STRING_H_DEFAULTS])
17])
18
19AC_DEFUN([gl_HEADER_STRING_H_BODY],
20[
21 AC_REQUIRE([AC_C_RESTRICT])
22 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
23 gl_NEXT_HEADERS([string.h]) 17 gl_NEXT_HEADERS([string.h])
24 18
25 dnl Check for declarations of anything we want to poison if the 19 dnl Check for declarations of anything we want to poison if the
@@ -27,66 +21,95 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
27 dnl guaranteed by C89. 21 dnl guaranteed by C89.
28 gl_WARN_ON_USE_PREPARE([[#include <string.h> 22 gl_WARN_ON_USE_PREPARE([[#include <string.h>
29 ]], 23 ]],
30 [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul 24 [explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit
25 rawmemchr stpcpy stpncpy strchrnul
31 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r 26 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
32 strerror_r strsignal strverscmp]) 27 strerror_r strerrorname_np sigabbrev_np sigdescr_np strsignal strverscmp])
28
29 AC_REQUIRE([AC_C_RESTRICT])
33]) 30])
34 31
32# gl_STRING_MODULE_INDICATOR([modulename])
33# sets the shell variable that indicates the presence of the given module
34# to a C preprocessor expression that will evaluate to 1.
35# This macro invocation must not occur in macros that are AC_REQUIREd.
35AC_DEFUN([gl_STRING_MODULE_INDICATOR], 36AC_DEFUN([gl_STRING_MODULE_INDICATOR],
36[ 37[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 38 dnl Ensure to expand the default settings once only.
38 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 39 gl_STRING_H_REQUIRE_DEFAULTS
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 40 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40 dnl Define it also as a C macro, for the benefit of the unit tests. 41 dnl Define it also as a C macro, for the benefit of the unit tests.
41 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 42 gl_MODULE_INDICATOR_FOR_TESTS([$1])
42]) 43])
43 44
44AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], 45# Initializes the default values for AC_SUBSTed shell variables.
46# This macro must not be AC_REQUIREd. It must only be invoked, and only
47# outside of macros or in macros that are not AC_REQUIREd.
48AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
45[ 49[
46 GNULIB_FFSL=0; AC_SUBST([GNULIB_FFSL]) 50 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS], [
47 GNULIB_FFSLL=0; AC_SUBST([GNULIB_FFSLL]) 51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPLICIT_BZERO])
48 GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) 52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSL])
49 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) 53 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSLL])
50 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) 54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMCHR])
51 GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) 55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMMEM])
52 GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR]) 56 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMPCPY])
53 GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) 57 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMRCHR])
54 GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) 58 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMSET_EXPLICIT])
55 GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) 59 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAWMEMCHR])
56 GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) 60 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPCPY])
57 GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) 61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY])
58 GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) 62 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL])
59 GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) 63 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP])
60 GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) 64 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT])
61 GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP]) 65 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP])
62 GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR]) 66 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN])
63 GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR]) 67 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK])
64 GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R]) 68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSEP])
65 GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN]) 69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR])
66 GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN]) 70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR])
67 GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR]) 71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R])
68 GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) 72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN])
69 GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) 73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN])
70 GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) 74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR])
71 GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) 75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRCHR])
72 GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) 76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSTR])
73 GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) 77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASECMP])
74 GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) 78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNCASECMP])
75 GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) 79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPCASECMP])
76 GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) 80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASESTR])
77 GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) 81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCSPN])
78 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) 82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPBRK])
79 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) 83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN])
80 GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) 84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP])
81 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) 85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R])
82 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) 86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR])
83 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) 87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSIGNAL])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRVERSCMP])
93 dnl Support Microsoft deprecated alias function names by default.
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MEMCCPY], [1])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_STRDUP], [1])
96 ])
97 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS])
98 dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
99 gl_STDLIB_H_REQUIRE_DEFAULTS
100 AC_REQUIRE([gl_STRING_H_DEFAULTS])
101])
102
103AC_DEFUN([gl_STRING_H_DEFAULTS],
104[
105 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
84 dnl Assume proper GNU behavior unless another module says otherwise. 106 dnl Assume proper GNU behavior unless another module says otherwise.
107 HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO])
85 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) 108 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL])
86 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL]) 109 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL])
87 HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
88 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) 110 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
89 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) 111 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
112 HAVE_MEMSET_EXPLICIT=1; AC_SUBST([HAVE_MEMSET_EXPLICIT])
90 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) 113 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
91 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) 114 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
92 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) 115 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
@@ -100,21 +123,26 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
100 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) 123 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
101 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) 124 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
102 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) 125 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
126 HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP])
127 HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP])
128 HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP])
103 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) 129 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
104 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) 130 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
131 REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL])
105 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) 132 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
106 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) 133 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
107 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) 134 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
135 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
108 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) 136 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
137 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
138 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
139 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
109 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) 140 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
110 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) 141 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
111 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) 142 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
112 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) 143 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
113 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) 144 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
114 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) 145 REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP])
115 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
116 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
117 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) 146 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
118 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
119 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) 147 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
120]) 148])
diff --git a/gl/m4/strings_h.m4 b/gl/m4/strings_h.m4
index 76ef2424..4c41221b 100644
--- a/gl/m4/strings_h.m4
+++ b/gl/m4/strings_h.m4
@@ -1,21 +1,16 @@
1# Configure a replacement for <strings.h>. 1# Configure a replacement for <strings.h>.
2# serial 6 2# serial 9
3 3
4# Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 4# Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
8 8
9AC_DEFUN([gl_HEADER_STRINGS_H], 9AC_DEFUN_ONCE([gl_STRINGS_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_HEADER_STRINGS_H_BODY]) 13 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
14])
15
16AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
17[
18 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
19 14
20 gl_CHECK_NEXT_HEADERS([strings.h]) 15 gl_CHECK_NEXT_HEADERS([strings.h])
21 if test $ac_cv_header_strings_h = yes; then 16 if test $ac_cv_header_strings_h = yes; then
@@ -35,16 +30,31 @@ AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
35 ]], [ffs strcasecmp strncasecmp]) 30 ]], [ffs strcasecmp strncasecmp])
36]) 31])
37 32
33# gl_STRINGS_MODULE_INDICATOR([modulename])
34# sets the shell variable that indicates the presence of the given module
35# to a C preprocessor expression that will evaluate to 1.
36# This macro invocation must not occur in macros that are AC_REQUIREd.
38AC_DEFUN([gl_STRINGS_MODULE_INDICATOR], 37AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
39[ 38[
40 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 39 dnl Ensure to expand the default settings once only.
41 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 40 gl_STRINGS_H_REQUIRE_DEFAULTS
42 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 41 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
43]) 42])
44 43
45AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS], 44# Initializes the default values for AC_SUBSTed shell variables.
45# This macro must not be AC_REQUIREd. It must only be invoked, and only
46# outside of macros or in macros that are not AC_REQUIREd.
47AC_DEFUN([gl_STRINGS_H_REQUIRE_DEFAULTS],
48[
49 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS])
51 ])
52 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS])
53 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
54])
55
56AC_DEFUN([gl_STRINGS_H_DEFAULTS],
46[ 57[
47 GNULIB_FFS=0; AC_SUBST([GNULIB_FFS])
48 dnl Assume proper GNU behavior unless another module says otherwise. 58 dnl Assume proper GNU behavior unless another module says otherwise.
49 HAVE_FFS=1; AC_SUBST([HAVE_FFS]) 59 HAVE_FFS=1; AC_SUBST([HAVE_FFS])
50 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) 60 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4
deleted file mode 100644
index a1f82743..00000000
--- a/gl/m4/strndup.m4
+++ /dev/null
@@ -1,55 +0,0 @@
1# strndup.m4 serial 21
2dnl Copyright (C) 2002-2003, 2005-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_STRNDUP],
8[
9 dnl Persuade glibc <string.h> to declare strndup().
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
14 AC_CHECK_DECLS_ONCE([strndup])
15 AC_CHECK_FUNCS_ONCE([strndup])
16 if test $ac_cv_have_decl_strndup = no; then
17 HAVE_DECL_STRNDUP=0
18 fi
19
20 if test $ac_cv_func_strndup = yes; then
21 HAVE_STRNDUP=1
22 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
23 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
24 [AC_RUN_IFELSE([
25 AC_LANG_PROGRAM([[#include <string.h>
26 #include <stdlib.h>]], [[
27#if !HAVE_DECL_STRNDUP
28 extern
29 #ifdef __cplusplus
30 "C"
31 #endif
32 char *strndup (const char *, size_t);
33#endif
34 char *s;
35 s = strndup ("some longer string", 15);
36 free (s);
37 s = strndup ("shorter string", 13);
38 return s[13] != '\0';]])],
39 [gl_cv_func_strndup_works=yes],
40 [gl_cv_func_strndup_works=no],
41 [
42changequote(,)dnl
43 case $host_os in
44 aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";;
45 *) gl_cv_func_strndup_works="guessing yes";;
46 esac
47changequote([,])dnl
48 ])])
49 case $gl_cv_func_strndup_works in
50 *no) REPLACE_STRNDUP=1 ;;
51 esac
52 else
53 HAVE_STRNDUP=0
54 fi
55])
diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4
deleted file mode 100644
index eae82b77..00000000
--- a/gl/m4/strnlen.m4
+++ /dev/null
@@ -1,30 +0,0 @@
1# strnlen.m4 serial 13
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_FUNC_STRNLEN],
9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
11
12 dnl Persuade glibc <string.h> to declare strnlen().
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
14
15 AC_CHECK_DECLS_ONCE([strnlen])
16 if test $ac_cv_have_decl_strnlen = no; then
17 HAVE_DECL_STRNLEN=0
18 else
19 m4_pushdef([AC_LIBOBJ], [:])
20 dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]).
21 AC_FUNC_STRNLEN
22 m4_popdef([AC_LIBOBJ])
23 if test $ac_cv_func_strnlen_working = no; then
24 REPLACE_STRNLEN=1
25 fi
26 fi
27])
28
29# Prerequisites of lib/strnlen.c.
30AC_DEFUN([gl_PREREQ_STRNLEN], [:])
diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4
index 825fdb81..e0da09a3 100644
--- a/gl/m4/strsep.m4
+++ b/gl/m4/strsep.m4
@@ -1,5 +1,5 @@
1# strsep.m4 serial 10 1# strsep.m4 serial 11
2dnl Copyright (C) 2002-2004, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_STRSEP],
12 dnl The strsep() declaration in lib/string.in.h uses 'restrict'. 12 dnl The strsep() declaration in lib/string.in.h uses 'restrict'.
13 AC_REQUIRE([AC_C_RESTRICT]) 13 AC_REQUIRE([AC_C_RESTRICT])
14 14
15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 15 AC_REQUIRE([gl_STRING_H_DEFAULTS])
16 AC_CHECK_FUNCS([strsep]) 16 AC_CHECK_FUNCS([strsep])
17 if test $ac_cv_func_strsep = no; then 17 if test $ac_cv_func_strsep = no; then
18 HAVE_STRSEP=0 18 HAVE_STRSEP=0
diff --git a/gl/m4/strstr.m4 b/gl/m4/strstr.m4
index c486bdb0..7de203a7 100644
--- a/gl/m4/strstr.m4
+++ b/gl/m4/strstr.m4
@@ -1,5 +1,5 @@
1# strstr.m4 serial 16 1# strstr.m4 serial 24
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,30 +7,40 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl Check that strstr works. 7dnl Check that strstr works.
8AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], 8AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
9[ 9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 10 AC_REQUIRE([gl_STRING_H_DEFAULTS])
11 AC_REQUIRE([gl_FUNC_MEMCHR]) 11 AC_REQUIRE([gl_FUNC_MEMCHR])
12 if test "$gl_cv_func_memchr_works" != yes; then 12 if test $REPLACE_MEMCHR = 1; then
13 REPLACE_STRSTR=1 13 REPLACE_STRSTR=1
14 else 14 else
15 dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. 15 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
16 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637.
16 AC_CACHE_CHECK([whether strstr works], 17 AC_CACHE_CHECK([whether strstr works],
17 [gl_cv_func_strstr_works_always], 18 [gl_cv_func_strstr_works_always],
18 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 19 [AC_RUN_IFELSE(
19#include <string.h> /* for strstr */ 20 [AC_LANG_PROGRAM([[
21#include <string.h> /* for __GNU_LIBRARY__, strstr */
22#ifdef __GNU_LIBRARY__
23 #include <features.h>
24 #if __GLIBC__ == 2 && __GLIBC_MINOR__ == 28
25 Unlucky user
26 #endif
27#endif
20#define P "_EF_BF_BD" 28#define P "_EF_BF_BD"
21#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P 29#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
22#define NEEDLE P P P P P 30#define NEEDLE P P P P P
23]], [[return !!strstr (HAYSTACK, NEEDLE); 31]],
24 ]])], 32 [[return !!strstr (HAYSTACK, NEEDLE);
25 [gl_cv_func_strstr_works_always=yes], 33 ]])],
26 [gl_cv_func_strstr_works_always=no], 34 [gl_cv_func_strstr_works_always=yes],
27 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not 35 [gl_cv_func_strstr_works_always=no],
28 dnl affected, since it uses different source code for strstr than 36 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
29 dnl glibc. 37 dnl affected, since it uses different source code for strstr than
30 dnl Assume that it works on all other platforms, even if it is not 38 dnl glibc.
31 dnl linear. 39 dnl Assume that it works on all other platforms, even if it is not
32 AC_EGREP_CPP([Lucky user], 40 dnl linear.
33 [ 41 AC_EGREP_CPP([Lucky user],
42 [
43#include <string.h> /* for __GNU_LIBRARY__ */
34#ifdef __GNU_LIBRARY__ 44#ifdef __GNU_LIBRARY__
35 #include <features.h> 45 #include <features.h>
36 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ 46 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
@@ -45,10 +55,10 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
45#else 55#else
46 Lucky user 56 Lucky user
47#endif 57#endif
48 ], 58 ],
49 [gl_cv_func_strstr_works_always="guessing yes"], 59 [gl_cv_func_strstr_works_always="guessing yes"],
50 [gl_cv_func_strstr_works_always="guessing no"]) 60 [gl_cv_func_strstr_works_always="$gl_cross_guess_normal"])
51 ]) 61 ])
52 ]) 62 ])
53 case "$gl_cv_func_strstr_works_always" in 63 case "$gl_cv_func_strstr_works_always" in
54 *yes) ;; 64 *yes) ;;
@@ -67,11 +77,17 @@ AC_DEFUN([gl_FUNC_STRSTR],
67 AC_CACHE_CHECK([whether strstr works in linear time], 77 AC_CACHE_CHECK([whether strstr works in linear time],
68 [gl_cv_func_strstr_linear], 78 [gl_cv_func_strstr_linear],
69 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 79 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
80#ifdef __MVS__
81/* z/OS does not deliver signals while strstr() is running (thanks to
82 restrictions on its LE runtime), which prevents us from limiting the
83 running time of this test. */
84# error "This test does not work properly on z/OS"
85#endif
70#include <signal.h> /* for signal */ 86#include <signal.h> /* for signal */
71#include <string.h> /* for strstr */ 87#include <string.h> /* for strstr */
72#include <stdlib.h> /* for malloc */ 88#include <stdlib.h> /* for malloc */
73#include <unistd.h> /* for alarm */ 89#include <unistd.h> /* for alarm */
74static void quit (int sig) { exit (sig + 128); } 90static void quit (int sig) { _exit (sig + 128); }
75]], [[ 91]], [[
76 int result = 0; 92 int result = 0;
77 size_t m = 1000000; 93 size_t m = 1000000;
@@ -93,6 +109,9 @@ static void quit (int sig) { exit (sig + 128); }
93 if (!strstr (haystack, needle)) 109 if (!strstr (haystack, needle))
94 result |= 1; 110 result |= 1;
95 } 111 }
112 /* Free allocated memory, in case some sanitizer is watching. */
113 free (haystack);
114 free (needle);
96 return result; 115 return result;
97 ]])], 116 ]])],
98 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no], 117 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
@@ -117,7 +136,7 @@ static void quit (int sig) { exit (sig + 128); }
117#endif 136#endif
118 ], 137 ],
119 [gl_cv_func_strstr_linear="guessing yes"], 138 [gl_cv_func_strstr_linear="guessing yes"],
120 [gl_cv_func_strstr_linear="guessing no"]) 139 [gl_cv_func_strstr_linear="$gl_cross_guess_normal"])
121 ]) 140 ])
122 ]) 141 ])
123 case "$gl_cv_func_strstr_linear" in 142 case "$gl_cv_func_strstr_linear" in
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4
index 94863776..98a10416 100644
--- a/gl/m4/sys_socket_h.m4
+++ b/gl/m4/sys_socket_h.m4
@@ -1,12 +1,12 @@
1# sys_socket_h.m4 serial 23 1# sys_socket_h.m4 serial 29
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Simon Josefsson. 7dnl From Simon Josefsson.
8 8
9AC_DEFUN([gl_HEADER_SYS_SOCKET], 9AC_DEFUN_ONCE([gl_SYS_SOCKET_H],
10[ 10[
11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
@@ -22,6 +22,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
22 ;; 22 ;;
23 esac 23 esac
24 24
25 GL_GENERATE_SYS_SOCKET_H=false
25 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], 26 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
26 [gl_cv_header_sys_socket_h_selfcontained], 27 [gl_cv_header_sys_socket_h_selfcontained],
27 [ 28 [
@@ -44,7 +45,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
44 [gl_cv_header_sys_socket_h_shut=no]) 45 [gl_cv_header_sys_socket_h_shut=no])
45 ]) 46 ])
46 if test $gl_cv_header_sys_socket_h_shut = no; then 47 if test $gl_cv_header_sys_socket_h_shut = no; then
47 SYS_SOCKET_H='sys/socket.h' 48 GL_GENERATE_SYS_SOCKET_H=true
48 fi 49 fi
49 fi 50 fi
50 fi 51 fi
@@ -83,7 +84,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
83 fi 84 fi
84 if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ 85 if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \
85 || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then 86 || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then
86 SYS_SOCKET_H='sys/socket.h' 87 GL_GENERATE_SYS_SOCKET_H=true
87 fi 88 fi
88 gl_PREREQ_SYS_H_WINSOCK2 89 gl_PREREQ_SYS_H_WINSOCK2
89 90
@@ -95,6 +96,8 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
95#include <sys/socket.h> 96#include <sys/socket.h>
96 ]], [socket connect accept bind getpeername getsockname getsockopt 97 ]], [socket connect accept bind getpeername getsockname getsockopt
97 listen recv send recvfrom sendto setsockopt shutdown accept4]) 98 listen recv send recvfrom sendto setsockopt shutdown accept4])
99
100 AC_REQUIRE([AC_C_RESTRICT])
98]) 101])
99 102
100AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], 103AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
@@ -104,17 +107,11 @@ AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
104 gl_CHECK_NEXT_HEADERS([sys/socket.h]) 107 gl_CHECK_NEXT_HEADERS([sys/socket.h])
105 if test $ac_cv_header_sys_socket_h = yes; then 108 if test $ac_cv_header_sys_socket_h = yes; then
106 HAVE_SYS_SOCKET_H=1 109 HAVE_SYS_SOCKET_H=1
107 HAVE_WS2TCPIP_H=0
108 else 110 else
109 HAVE_SYS_SOCKET_H=0 111 HAVE_SYS_SOCKET_H=0
110 if test $ac_cv_header_ws2tcpip_h = yes; then
111 HAVE_WS2TCPIP_H=1
112 else
113 HAVE_WS2TCPIP_H=0
114 fi
115 fi 112 fi
116 AC_SUBST([HAVE_SYS_SOCKET_H]) 113 AC_SUBST([HAVE_SYS_SOCKET_H])
117 AC_SUBST([HAVE_WS2TCPIP_H]) 114 gl_PREREQ_SYS_H_WS2TCPIP
118]) 115])
119 116
120# Common prerequisites of the <sys/socket.h> replacement and of the 117# Common prerequisites of the <sys/socket.h> replacement and of the
@@ -142,32 +139,65 @@ AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
142 AC_SUBST([HAVE_WINSOCK2_H]) 139 AC_SUBST([HAVE_WINSOCK2_H])
143]) 140])
144 141
142# Common prerequisites of the <sys/socket.h> replacement and of the
143# <arpa/inet.h> replacement.
144# Sets and substitutes HAVE_WS2TCPIP_H.
145AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP],
146[
147 AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
148 if test $ac_cv_header_sys_socket_h = yes; then
149 HAVE_WS2TCPIP_H=0
150 else
151 if test $ac_cv_header_ws2tcpip_h = yes; then
152 HAVE_WS2TCPIP_H=1
153 else
154 HAVE_WS2TCPIP_H=0
155 fi
156 fi
157 AC_SUBST([HAVE_WS2TCPIP_H])
158])
159
160# gl_SYS_SOCKET_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1.
163# This macro invocation must not occur in macros that are AC_REQUIREd.
145AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], 164AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR],
146[ 165[
147 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 166 dnl Ensure to expand the default settings once only.
148 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 167 gl_SYS_SOCKET_H_REQUIRE_DEFAULTS
149 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 168 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
150 dnl Define it also as a C macro, for the benefit of the unit tests. 169 dnl Define it also as a C macro, for the benefit of the unit tests.
151 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 170 gl_MODULE_INDICATOR_FOR_TESTS([$1])
152]) 171])
153 172
173# Initializes the default values for AC_SUBSTed shell variables.
174# This macro must not be AC_REQUIREd. It must only be invoked, and only
175# outside of macros or in macros that are not AC_REQUIREd.
176AC_DEFUN([gl_SYS_SOCKET_H_REQUIRE_DEFAULTS],
177[
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SOCKET])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CONNECT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BIND])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPEERNAME])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKNAME])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKOPT])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LISTEN])
187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECV])
188 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SEND])
189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECVFROM])
190 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SENDTO])
191 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETSOCKOPT])
192 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SHUTDOWN])
193 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT4])
194 ])
195 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS])
196 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
197])
198
154AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], 199AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
155[ 200[
156 GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET])
157 GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT])
158 GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT])
159 GNULIB_BIND=0; AC_SUBST([GNULIB_BIND])
160 GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME])
161 GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME])
162 GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT])
163 GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN])
164 GNULIB_RECV=0; AC_SUBST([GNULIB_RECV])
165 GNULIB_SEND=0; AC_SUBST([GNULIB_SEND])
166 GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM])
167 GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO])
168 GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT])
169 GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN])
170 GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4])
171 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) 201 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
172 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; 202 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1;
173 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) 203 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY])
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
new file mode 100644
index 00000000..ca57398a
--- /dev/null
+++ b/gl/m4/sys_stat_h.m4
@@ -0,0 +1,129 @@
1# sys_stat_h.m4 serial 42 -*- Autoconf -*-
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Eric Blake.
8dnl Provide a GNU-like <sys/stat.h>.
9
10AC_DEFUN_ONCE([gl_SYS_STAT_H],
11[
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13
14 dnl Check for broken stat macros.
15 AC_REQUIRE([AC_HEADER_STAT])
16
17 gl_CHECK_NEXT_HEADERS([sys/stat.h])
18
19 dnl Ensure the type mode_t gets defined.
20 AC_REQUIRE([AC_TYPE_MODE_T])
21
22 dnl Whether to enable precise timestamps in 'struct stat'.
23 m4_ifdef([gl_WINDOWS_STAT_TIMESPEC], [
24 AC_REQUIRE([gl_WINDOWS_STAT_TIMESPEC])
25 ], [
26 WINDOWS_STAT_TIMESPEC=0
27 ])
28 AC_SUBST([WINDOWS_STAT_TIMESPEC])
29
30 dnl Whether to ensure that struct stat.st_size is 64-bit wide.
31 m4_ifdef([gl_LARGEFILE], [
32 AC_REQUIRE([gl_LARGEFILE])
33 ], [
34 WINDOWS_64_BIT_ST_SIZE=0
35 ])
36 AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
37
38 dnl Define types that are supposed to be defined in <sys/types.h> or
39 dnl <sys/stat.h>.
40 AC_CHECK_TYPE([nlink_t], [],
41 [AC_DEFINE([nlink_t], [int],
42 [Define to the type of st_nlink in struct stat, or a supertype.])],
43 [#include <sys/types.h>
44 #include <sys/stat.h>])
45
46 dnl Check for declarations of anything we want to poison if the
47 dnl corresponding gnulib module is not in use.
48 gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
49 ]], [chmod fchmodat fstat fstatat futimens getumask lchmod lstat
50 mkdirat mkfifo mkfifoat mknod mknodat stat utimensat])
51
52 AC_REQUIRE([AC_C_RESTRICT])
53])
54
55# gl_SYS_STAT_MODULE_INDICATOR([modulename])
56# sets the shell variable that indicates the presence of the given module
57# to a C preprocessor expression that will evaluate to 1.
58# This macro invocation must not occur in macros that are AC_REQUIREd.
59AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
60[
61 dnl Ensure to expand the default settings once only.
62 gl_SYS_STAT_H_REQUIRE_DEFAULTS
63 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
64 dnl Define it also as a C macro, for the benefit of the unit tests.
65 gl_MODULE_INDICATOR_FOR_TESTS([$1])
66])
67
68# Initializes the default values for AC_SUBSTed shell variables.
69# This macro must not be AC_REQUIREd. It must only be invoked, and only
70# outside of macros or in macros that are not AC_REQUIREd.
71AC_DEFUN([gl_SYS_STAT_H_REQUIRE_DEFAULTS],
72[
73 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [
74 gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHMOD])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FUTIMENS])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUMASK])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHMOD])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSTAT])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIR])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIRAT])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFO])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFOAT])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNOD])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNODAT])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STAT])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UTIMENSAT])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OVERRIDES_STRUCT_STAT])
92 dnl Support Microsoft deprecated alias function names by default.
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHMOD], [1])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKDIR], [1])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UMASK], [1])
96 ])
97 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS])
98 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
99])
100
101AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
102[
103 dnl Assume proper GNU behavior unless another module says otherwise.
104 HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
105 HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
106 HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS])
107 HAVE_GETUMASK=1; AC_SUBST([HAVE_GETUMASK])
108 HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
109 HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT])
110 HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
111 HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO])
112 HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT])
113 HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD])
114 HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
115 HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT])
116 REPLACE_CHMOD=0; AC_SUBST([REPLACE_CHMOD])
117 REPLACE_FCHMODAT=0; AC_SUBST([REPLACE_FCHMODAT])
118 REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
119 REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
120 REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS])
121 REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
122 REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
123 REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO])
124 REPLACE_MKFIFOAT=0; AC_SUBST([REPLACE_MKFIFOAT])
125 REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD])
126 REPLACE_MKNODAT=0; AC_SUBST([REPLACE_MKNODAT])
127 REPLACE_STAT=0; AC_SUBST([REPLACE_STAT])
128 REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT])
129])
diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4
index d15c1b37..627671fb 100644
--- a/gl/m4/sys_types_h.m4
+++ b/gl/m4/sys_types_h.m4
@@ -1,5 +1,5 @@
1# sys_types_h.m4 serial 5 1# sys_types_h.m4 serial 13
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,6 +7,10 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN_ONCE([gl_SYS_TYPES_H], 7AC_DEFUN_ONCE([gl_SYS_TYPES_H],
8[ 8[
9 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) 9 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
10
11 dnl Use sane struct stat types in OpenVMS 8.2 and later.
12 AC_DEFINE([_USE_STD_STAT], 1, [For standard stat data types on VMS.])
13
10 gl_NEXT_HEADERS([sys/types.h]) 14 gl_NEXT_HEADERS([sys/types.h])
11 15
12 dnl Ensure the type pid_t gets defined. 16 dnl Ensure the type pid_t gets defined.
@@ -17,8 +21,50 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
17 21
18 dnl Whether to override the 'off_t' type. 22 dnl Whether to override the 'off_t' type.
19 AC_REQUIRE([gl_TYPE_OFF_T]) 23 AC_REQUIRE([gl_TYPE_OFF_T])
24
25 dnl Whether to override the 'dev_t' and 'ino_t' types.
26 m4_ifdef([gl_WINDOWS_STAT_INODES], [
27 AC_REQUIRE([gl_WINDOWS_STAT_INODES])
28 ], [
29 WINDOWS_STAT_INODES=0
30 ])
31 AC_SUBST([WINDOWS_STAT_INODES])
32])
33
34# Initializes the default values for AC_SUBSTed shell variables.
35# This macro must not be AC_REQUIREd. It must only be invoked, and only
36# outside of macros or in macros that are not AC_REQUIREd.
37AC_DEFUN([gl_SYS_TYPES_H_REQUIRE_DEFAULTS],
38[
39 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS], [
40 ])
41 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS])
42 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
20]) 43])
21 44
22AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], 45AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
23[ 46[
24]) 47])
48
49# This works around a buggy version in autoconf <= 2.69.
50# See <https://lists.gnu.org/r/autoconf/2016-08/msg00014.html>
51# The 2.70 version isn't quoted properly, so override it too.
52
53m4_version_prereq([2.70.1], [], [
54
55m4_undefine([AC_HEADER_MAJOR])
56AC_DEFUN([AC_HEADER_MAJOR],
57[AC_CHECK_HEADERS_ONCE([sys/types.h])
58AC_CHECK_HEADER([sys/mkdev.h],
59 [AC_DEFINE([MAJOR_IN_MKDEV], [1],
60 [Define to 1 if `major', `minor', and `makedev' are
61 declared in <mkdev.h>.])])
62if test $ac_cv_header_sys_mkdev_h = no; then
63 AC_CHECK_HEADER([sys/sysmacros.h],
64 [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
65 [Define to 1 if `major', `minor', and `makedev'
66 are declared in <sysmacros.h>.])])
67fi
68])# AC_HEADER_MAJOR
69
70])
diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4
index c75cbbd0..93a65d26 100644
--- a/gl/m4/sys_uio_h.m4
+++ b/gl/m4/sys_uio_h.m4
@@ -1,10 +1,10 @@
1# sys_uio_h.m4 serial 1 1# sys_uio_h.m4 serial 3
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_HEADER_SYS_UIO], 7AC_DEFUN_ONCE([gl_SYS_UIO_H],
8[ 8[
9 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
10 dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK. 10 dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK.
@@ -17,15 +17,30 @@ AC_DEFUN([gl_HEADER_SYS_UIO],
17 AC_SUBST([HAVE_SYS_UIO_H]) 17 AC_SUBST([HAVE_SYS_UIO_H])
18]) 18])
19 19
20# gl_SYS_UIO_MODULE_INDICATOR([modulename])
21# sets the shell variable that indicates the presence of the given module
22# to a C preprocessor expression that will evaluate to 1.
23# This macro invocation must not occur in macros that are AC_REQUIREd.
20AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR], 24AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR],
21[ 25[
22 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 26 dnl Ensure to expand the default settings once only.
23 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 27 gl_SYS_UIO_H_REQUIRE_DEFAULTS
24 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 28 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
25 dnl Define it also as a C macro, for the benefit of the unit tests. 29 dnl Define it also as a C macro, for the benefit of the unit tests.
26 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 30 gl_MODULE_INDICATOR_FOR_TESTS([$1])
27]) 31])
28 32
33# Initializes the default values for AC_SUBSTed shell variables.
34# This macro must not be AC_REQUIREd. It must only be invoked, and only
35# outside of macros or in macros that are not AC_REQUIREd.
36AC_DEFUN([gl_SYS_UIO_H_REQUIRE_DEFAULTS],
37[
38 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS], [
39 ])
40 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS])
41 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
42])
43
29AC_DEFUN([gl_SYS_UIO_H_DEFAULTS], 44AC_DEFUN([gl_SYS_UIO_H_DEFAULTS],
30[ 45[
31]) 46])
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index 26bdeb58..b536b047 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,11 +1,390 @@
1# threadlib.m4 serial 10 (gettext-0.18.2) 1# threadlib.m4 serial 32a
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ([2.60])
10
11dnl The general structure of the multithreading modules in gnulib is that we
12dnl have three set of modules:
13dnl
14dnl * POSIX API:
15dnl pthread, which combines
16dnl pthread-h
17dnl pthread-thread
18dnl pthread-once
19dnl pthread-mutex
20dnl pthread-rwlock
21dnl pthread-cond
22dnl pthread-tss
23dnl pthread-spin
24dnl sched_yield
25dnl
26dnl * ISO C API:
27dnl threads, which combines
28dnl threads-h
29dnl thrd
30dnl mtx
31dnl cnd
32dnl tss
33dnl
34dnl * Gnulib API, with an implementation that can be chosen at configure
35dnl time through the option --enable-threads=...
36dnl thread
37dnl lock
38dnl cond
39dnl tls
40dnl yield
41dnl
42dnl They are independent, except for the fact that
43dnl - the implementation of the ISO C API may use the POSIX (or some other
44dnl platform dependent) API,
45dnl - the implementation of the Gnulib API may use the POSIX or ISO C or
46dnl some other platform dependent API, depending on the --enable-threads
47dnl option.
48dnl
49dnl This file contains macros for all of these APIs!
50
51dnl ============================================================================
52dnl Macros for all thread APIs
53
54AC_DEFUN([gl_ANYTHREADLIB_EARLY],
55[
56 AC_REQUIRE([AC_CANONICAL_HOST])
57 if test -z "$gl_anythreadlib_early_done"; then
58 case "$host_os" in
59 osf*)
60 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
61 # groks <pthread.h>. cc also understands the flag -pthread, but
62 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
63 # 2. putting a flag into CPPFLAGS that has an effect on the linker
64 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
65 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
66 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
67 ;;
68 esac
69 # Some systems optimize for single-threaded programs by default, and
70 # need special flags to disable these optimizations. For example, the
71 # definition of 'errno' in <errno.h>.
72 case "$host_os" in
73 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
74 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
75 esac
76 gl_anythreadlib_early_done=done
77 fi
78])
79
80dnl Checks whether the compiler and linker support weak declarations of symbols.
81
82AC_DEFUN([gl_WEAK_SYMBOLS],
83[
84 AC_REQUIRE([AC_CANONICAL_HOST])
85 AC_CACHE_CHECK([whether imported symbols can be declared weak],
86 [gl_cv_have_weak],
87 [case "$host_os" in
88 cygwin*)
89 dnl On Cygwin 3.2.0 with gcc 10.2, the test below would succeed, but
90 dnl programs that use pthread_in_use() with weak symbol references
91 dnl crash miserably at runtime.
92 gl_cv_have_weak="guessing no"
93 ;;
94 *)
95 gl_cv_have_weak=no
96 dnl First, test whether the compiler accepts it syntactically.
97 AC_LINK_IFELSE(
98 [AC_LANG_PROGRAM(
99 [[extern void xyzzy ();
100#pragma weak xyzzy]],
101 [[xyzzy();]])],
102 [gl_cv_have_weak=maybe])
103 if test $gl_cv_have_weak = maybe; then
104 dnl Second, test whether it actually works. On Cygwin 1.7.2, with
105 dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
106 AC_RUN_IFELSE(
107 [AC_LANG_SOURCE([[
108#include <stdio.h>
109#pragma weak fputs
110int main ()
111{
112 return (fputs == NULL);
113}]])],
114 [gl_cv_have_weak=yes],
115 [gl_cv_have_weak=no],
116 [dnl When cross-compiling, assume that only ELF platforms support
117 dnl weak symbols.
118 AC_EGREP_CPP([Extensible Linking Format],
119 [#ifdef __ELF__
120 Extensible Linking Format
121 #endif
122 ],
123 [gl_cv_have_weak="guessing yes"],
124 [gl_cv_have_weak="guessing no"])
125 ])
126 fi
127 ;;
128 esac
129 dnl But when linking statically, weak symbols don't work.
130 case " $LDFLAGS " in
131 *" -static "*) gl_cv_have_weak=no ;;
132 esac
133 dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak
134 dnl symbol and linking against a shared library that has a dependency on
135 dnl the shared library that defines the symbol.
136 case "$gl_cv_have_weak" in
137 *yes)
138 case "$host_os" in
139 freebsd* | dragonfly* | midnightbsd*)
140 : > conftest1.c
141 $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1
142 cat <<EOF > conftest2.c
143#include <pthread.h>
144#pragma weak pthread_mutexattr_gettype
145int main ()
146{
147 return (pthread_mutexattr_gettype != NULL);
148}
149EOF
150 $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \
151 || gl_cv_have_weak=no
152 rm -f conftest1.c libempty.so conftest2.c conftest
153 ;;
154 esac
155 ;;
156 esac
157 ])
158 case "$gl_cv_have_weak" in
159 *yes)
160 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1],
161 [Define to 1 if the compiler and linker support weak declarations of symbols.])
162 ;;
163 esac
164])
165
166dnl ============================================================================
167dnl Macros for the POSIX API
168
169dnl gl_PTHREADLIB
170dnl -------------
171dnl Tests for the libraries needs for using the POSIX threads API.
172dnl Sets the variable LIBPTHREAD to the linker options for use in a Makefile.
173dnl Sets the variable LIBPMULTITHREAD, for programs that really need
174dnl multithread functionality. The difference between LIBPTHREAD and
175dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically
176dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not.
177dnl Sets the variable LIB_SCHED_YIELD to the linker options needed to use the
178dnl sched_yield() function.
179dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
180dnl multithread-safe programs.
181dnl Defines the C macro HAVE_PTHREAD_API if (at least parts of) the POSIX
182dnl threads API is available.
183
184dnl The guts of gl_PTHREADLIB. Needs to be expanded only once.
185
186AC_DEFUN([gl_PTHREADLIB_BODY],
187[
188 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
189 if test -z "$gl_pthreadlib_body_done"; then
190 gl_pthread_api=no
191 LIBPTHREAD=
192 LIBPMULTITHREAD=
193 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
194 # it groks <pthread.h>. It's added above, in gl_ANYTHREADLIB_EARLY.
195 AC_CHECK_HEADER([pthread.h],
196 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
197 if test "$gl_have_pthread_h" = yes; then
198 # Other possible tests:
199 # -lpthreads (FSU threads, PCthreads)
200 # -lgthreads
201 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
202 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
203 # the second one only in libpthread, and lock.c needs it.
204 #
205 # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
206 # needs -pthread for some reason. See:
207 # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html
208 save_LIBS=$LIBS
209 for gl_pthread in '' '-pthread'; do
210 LIBS="$LIBS $gl_pthread"
211 AC_LINK_IFELSE(
212 [AC_LANG_PROGRAM(
213 [[#include <pthread.h>
214 pthread_mutex_t m;
215 pthread_mutexattr_t ma;
216 ]],
217 [[pthread_mutex_lock (&m);
218 pthread_mutexattr_init (&ma);]])],
219 [gl_pthread_api=yes
220 LIBPTHREAD=$gl_pthread
221 LIBPMULTITHREAD=$gl_pthread])
222 LIBS=$save_LIBS
223 test $gl_pthread_api = yes && break
224 done
225 echo "$as_me:__oline__: gl_pthread_api=$gl_pthread_api" >&AS_MESSAGE_LOG_FD
226 echo "$as_me:__oline__: LIBPTHREAD=$LIBPTHREAD" >&AS_MESSAGE_LOG_FD
227
228 gl_pthread_in_glibc=no
229 # On Linux with glibc >= 2.34, libc contains the fully functional
230 # pthread functions.
231 case "$host_os" in
232 linux*)
233 AC_EGREP_CPP([Lucky user],
234 [#include <features.h>
235 #ifdef __GNU_LIBRARY__
236 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) || (__GLIBC__ > 2)
237 Lucky user
238 #endif
239 #endif
240 ],
241 [gl_pthread_in_glibc=yes],
242 [])
243 ;;
244 esac
245 echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD
246
247 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
248 # since it is defined as a macro on OSF/1.)
249 if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then
250 # The program links fine without libpthread. But it may actually
251 # need to link with libpthread in order to create multiple threads.
252 AC_CHECK_LIB([pthread], [pthread_kill],
253 [if test $gl_pthread_in_glibc = yes; then
254 LIBPMULTITHREAD=
255 else
256 LIBPMULTITHREAD=-lpthread
257 # On Solaris and HP-UX, most pthread functions exist also in libc.
258 # Therefore pthread_in_use() needs to actually try to create a
259 # thread: pthread_create from libc will fail, whereas
260 # pthread_create will actually create a thread.
261 # On Solaris 10 or newer, this test is no longer needed, because
262 # libc contains the fully functional pthread functions.
263 case "$host_os" in
264changequote(,)dnl
265 solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*)
266changequote([,])dnl
267 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
268 [Define if the pthread_in_use() detection is hard.])
269 esac
270 fi
271 ])
272 elif test $gl_pthread_api != yes; then
273 # Some library is needed. Try libpthread and libc_r.
274 AC_CHECK_LIB([pthread], [pthread_kill],
275 [gl_pthread_api=yes
276 LIBPTHREAD=-lpthread
277 LIBPMULTITHREAD=-lpthread])
278 if test $gl_pthread_api != yes; then
279 # For FreeBSD 4.
280 AC_CHECK_LIB([c_r], [pthread_kill],
281 [gl_pthread_api=yes
282 LIBPTHREAD=-lc_r
283 LIBPMULTITHREAD=-lc_r])
284 fi
285 fi
286 echo "$as_me:__oline__: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&AS_MESSAGE_LOG_FD
287 fi
288 AC_MSG_CHECKING([whether POSIX threads API is available])
289 AC_MSG_RESULT([$gl_pthread_api])
290 AC_SUBST([LIBPTHREAD])
291 AC_SUBST([LIBPMULTITHREAD])
292 if test $gl_pthread_api = yes; then
293 AC_DEFINE([HAVE_PTHREAD_API], [1],
294 [Define if you have the <pthread.h> header and the POSIX threads API.])
295 fi
296
297 dnl On some systems, sched_yield is in librt, rather than in libpthread.
298 AC_LINK_IFELSE(
299 [AC_LANG_PROGRAM(
300 [[#include <sched.h>]],
301 [[sched_yield ();]])],
302 [LIB_SCHED_YIELD=
303 ],
304 [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc.
305 AC_CHECK_LIB([rt], [sched_yield], [LIB_SCHED_YIELD=-lrt],
306 [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
307 AC_CHECK_LIB([posix4], [sched_yield], [LIB_SCHED_YIELD=-lposix4])])
308 ])
309 AC_SUBST([LIB_SCHED_YIELD])
310
311 gl_pthreadlib_body_done=done
312 fi
313])
314
315AC_DEFUN([gl_PTHREADLIB],
316[
317 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
318 gl_PTHREADLIB_BODY
319])
320
321dnl ============================================================================
322dnl Macros for the ISO C API
323
324dnl gl_STDTHREADLIB
325dnl ---------------
326dnl Tests for the libraries needs for using the ISO C threads API.
327dnl Sets the variable LIBSTDTHREAD to the linker options for use in a Makefile.
328dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
329dnl multithread-safe programs.
330dnl Defines the C macro HAVE_THREADS_H if (at least parts of) the ISO C threads
331dnl API is available.
332
333dnl The guts of gl_STDTHREADLIB. Needs to be expanded only once.
334
335AC_DEFUN([gl_STDTHREADLIB_BODY],
336[
337 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
338 AC_REQUIRE([AC_CANONICAL_HOST])
339 if test -z "$gl_stdthreadlib_body_done"; then
340 AC_CHECK_HEADERS_ONCE([threads.h])
341
342 case "$host_os" in
343 mingw*)
344 LIBSTDTHREAD=
345 ;;
346 *)
347 gl_PTHREADLIB_BODY
348 if test $ac_cv_header_threads_h = yes; then
349 dnl glibc >= 2.29 has thrd_create in libpthread.
350 dnl FreeBSD >= 10 has thrd_create in libstdthreads; this library depends
351 dnl on libpthread (for the symbol 'pthread_mutexattr_gettype').
352 dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in
353 dnl libc.
354 AC_CHECK_FUNCS([thrd_create])
355 if test $ac_cv_func_thrd_create = yes; then
356 LIBSTDTHREAD=
357 else
358 AC_CHECK_LIB([stdthreads], [thrd_create], [
359 LIBSTDTHREAD='-lstdthreads -lpthread'
360 ], [
361 dnl Guess that thrd_create is in libpthread.
362 LIBSTDTHREAD="$LIBPMULTITHREAD"
363 ])
364 fi
365 else
366 dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c.
367 LIBSTDTHREAD="$LIBPMULTITHREAD $LIB_SCHED_YIELD"
368 fi
369 ;;
370 esac
371 AC_SUBST([LIBSTDTHREAD])
372
373 AC_MSG_CHECKING([whether ISO C threads API is available])
374 AC_MSG_RESULT([$ac_cv_header_threads_h])
375 gl_stdthreadlib_body_done=done
376 fi
377])
378
379AC_DEFUN([gl_STDTHREADLIB],
380[
381 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
382 gl_STDTHREADLIB_BODY
383])
384
385dnl ============================================================================
386dnl Macros for the Gnulib API
387
9dnl gl_THREADLIB 388dnl gl_THREADLIB
10dnl ------------ 389dnl ------------
11dnl Tests for a multithreading library to be used. 390dnl Tests for a multithreading library to be used.
@@ -14,17 +393,25 @@ dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
14dnl default is 'no', otherwise it is system dependent. In both cases, the user 393dnl default is 'no', otherwise it is system dependent. In both cases, the user
15dnl can change the choice through the options --enable-threads=choice or 394dnl can change the choice through the options --enable-threads=choice or
16dnl --disable-threads. 395dnl --disable-threads.
17dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, 396dnl Defines at most one of the macros USE_ISOC_THREADS, USE_POSIX_THREADS,
18dnl USE_PTH_THREADS, USE_WINDOWS_THREADS 397dnl USE_ISOC_AND_POSIX_THREADS, USE_WINDOWS_THREADS.
398dnl The choice --enable-threads=isoc+posix is available only on platforms that
399dnl have both the ISO C and the POSIX threads APIs. It has the effect of using
400dnl the ISO C API for most things and the POSIX API only for creating and
401dnl controlling threads (because there is no equivalent to pthread_atfork in
402dnl the ISO C API).
19dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use 403dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
20dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with 404dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
21dnl libtool). 405dnl libtool).
22dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for 406dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
23dnl programs that really need multithread functionality. The difference 407dnl programs that really need multithread functionality. The difference
24dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak 408dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
25dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". 409dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not.
26dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for 410dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
27dnl multithread-safe programs. 411dnl multithread-safe programs.
412dnl Since support for GNU pth was removed, $LTLIBTHREAD and $LIBTHREAD have the
413dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the
414dnl same value. Only system libraries are needed.
28 415
29AC_DEFUN([gl_THREADLIB_EARLY], 416AC_DEFUN([gl_THREADLIB_EARLY],
30[ 417[
@@ -43,18 +430,15 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
43 430
44 AC_REQUIRE([AC_CANONICAL_HOST]) 431 AC_REQUIRE([AC_CANONICAL_HOST])
45 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. 432 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
46 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 433 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
47 dnl AC_GNU_SOURCE.
48 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
49 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
50 [AC_REQUIRE([AC_GNU_SOURCE])])
51 dnl Check for multithreading. 434 dnl Check for multithreading.
52 m4_ifdef([gl_THREADLIB_DEFAULT_NO], 435 m4_ifdef([gl_THREADLIB_DEFAULT_NO],
53 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], 436 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
54 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) 437 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
438 m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=])
55 AC_ARG_ENABLE([threads], 439 AC_ARG_ENABLE([threads],
56AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ 440AS_HELP_STRING([--enable-threads={isoc|posix|isoc+posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
57AC_HELP_STRING([--disable-threads], [build without multithread safety])]), 441AS_HELP_STRING([--disable-threads], [build without multithread safety])]),
58 [gl_use_threads=$enableval], 442 [gl_use_threads=$enableval],
59 [if test -n "$gl_use_threads_default"; then 443 [if test -n "$gl_use_threads_default"; then
60 gl_use_threads="$gl_use_threads_default" 444 gl_use_threads="$gl_use_threads_default"
@@ -64,41 +448,35 @@ changequote(,)dnl
64 dnl Disable multithreading by default on OSF/1, because it interferes 448 dnl Disable multithreading by default on OSF/1, because it interferes
65 dnl with fork()/exec(): When msgexec is linked with -lpthread, its 449 dnl with fork()/exec(): When msgexec is linked with -lpthread, its
66 dnl child process gets an endless segmentation fault inside execvp(). 450 dnl child process gets an endless segmentation fault inside execvp().
451 osf*) gl_use_threads=no ;;
67 dnl Disable multithreading by default on Cygwin 1.5.x, because it has 452 dnl Disable multithreading by default on Cygwin 1.5.x, because it has
68 dnl bugs that lead to endless loops or crashes. See 453 dnl bugs that lead to endless loops or crashes. See
69 dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>. 454 dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
70 osf*) gl_use_threads=no ;;
71 cygwin*) 455 cygwin*)
72 case `uname -r` in 456 case `uname -r` in
73 1.[0-5].*) gl_use_threads=no ;; 457 1.[0-5].*) gl_use_threads=no ;;
74 *) gl_use_threads=yes ;; 458 *) gl_use_threads=yes ;;
75 esac 459 esac
76 ;; 460 ;;
461 dnl Obey gl_AVOID_WINPTHREAD on mingw.
462 mingw*)
463 case "$gl_use_winpthreads_default" in
464 yes) gl_use_threads=posix ;;
465 no) gl_use_threads=windows ;;
466 *) gl_use_threads=yes ;;
467 esac
468 ;;
77 *) gl_use_threads=yes ;; 469 *) gl_use_threads=yes ;;
78 esac 470 esac
79changequote([,])dnl 471changequote([,])dnl
80 fi 472 fi
81 ]) 473 ])
82 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 474 if test "$gl_use_threads" = yes \
83 # For using <pthread.h>: 475 || test "$gl_use_threads" = isoc \
84 case "$host_os" in 476 || test "$gl_use_threads" = posix \
85 osf*) 477 || test "$gl_use_threads" = isoc+posix; then
86 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it 478 # For using <threads.h> or <pthread.h>:
87 # groks <pthread.h>. cc also understands the flag -pthread, but 479 gl_ANYTHREADLIB_EARLY
88 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
89 # 2. putting a flag into CPPFLAGS that has an effect on the linker
90 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
91 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
92 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
93 ;;
94 esac
95 # Some systems optimize for single-threaded programs by default, and
96 # need special flags to disable these optimizations. For example, the
97 # definition of 'errno' in <errno.h>.
98 case "$host_os" in
99 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
100 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
101 esac
102 fi 480 fi
103]) 481])
104 482
@@ -114,168 +492,69 @@ AC_DEFUN([gl_THREADLIB_BODY],
114 LTLIBMULTITHREAD= 492 LTLIBMULTITHREAD=
115 if test "$gl_use_threads" != no; then 493 if test "$gl_use_threads" != no; then
116 dnl Check whether the compiler and linker support weak declarations. 494 dnl Check whether the compiler and linker support weak declarations.
117 AC_CACHE_CHECK([whether imported symbols can be declared weak], 495 gl_WEAK_SYMBOLS
118 [gl_cv_have_weak], 496 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
119 [gl_cv_have_weak=no 497 dnl If we use weak symbols to implement pthread_in_use / pth_in_use /
120 dnl First, test whether the compiler accepts it syntactically. 498 dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create
121 AC_LINK_IFELSE( 499 dnl facility is in use.
122 [AC_LANG_PROGRAM( 500 AC_CHECK_HEADERS_ONCE([threads.h])
123 [[extern void xyzzy (); 501 :
124#pragma weak xyzzy]], 502 fi
125 [[xyzzy();]])], 503 if test "$gl_use_threads" = isoc || test "$gl_use_threads" = isoc+posix; then
126 [gl_cv_have_weak=maybe]) 504 AC_CHECK_HEADERS_ONCE([threads.h])
127 if test $gl_cv_have_weak = maybe; then 505 gl_have_isoc_threads="$ac_cv_header_threads_h"
128 dnl Second, test whether it actually works. On Cygwin 1.7.2, with 506 fi
129 dnl gcc 4.3, symbols declared weak always evaluate to the address 0. 507 if test "$gl_use_threads" = yes \
130 AC_RUN_IFELSE( 508 || test "$gl_use_threads" = posix \
131 [AC_LANG_SOURCE([[ 509 || test "$gl_use_threads" = isoc+posix; then
132#include <stdio.h> 510 gl_PTHREADLIB_BODY
133#pragma weak fputs 511 LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD
134int main () 512 LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD
135{ 513 if test $gl_pthread_api = yes; then
136 return (fputs == NULL); 514 if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then
137}]])], 515 gl_threads_api='isoc+posix'
138 [gl_cv_have_weak=yes], 516 AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1],
139 [gl_cv_have_weak=no], 517 [Define if the combination of the ISO C and POSIX multithreading APIs can be used.])
140 [dnl When cross-compiling, assume that only ELF platforms support 518 LIBTHREAD= LTLIBTHREAD=
141 dnl weak symbols.
142 AC_EGREP_CPP([Extensible Linking Format],
143 [#ifdef __ELF__
144 Extensible Linking Format
145 #endif
146 ],
147 [gl_cv_have_weak="guessing yes"],
148 [gl_cv_have_weak="guessing no"])
149 ])
150 fi
151 ])
152 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
153 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
154 # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
155 AC_CHECK_HEADER([pthread.h],
156 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
157 if test "$gl_have_pthread_h" = yes; then
158 # Other possible tests:
159 # -lpthreads (FSU threads, PCthreads)
160 # -lgthreads
161 gl_have_pthread=
162 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
163 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
164 # the second one only in libpthread, and lock.c needs it.
165 AC_LINK_IFELSE(
166 [AC_LANG_PROGRAM(
167 [[#include <pthread.h>]],
168 [[pthread_mutex_lock((pthread_mutex_t*)0);
169 pthread_mutexattr_init((pthread_mutexattr_t*)0);]])],
170 [gl_have_pthread=yes])
171 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
172 # since it is defined as a macro on OSF/1.)
173 if test -n "$gl_have_pthread"; then
174 # The program links fine without libpthread. But it may actually
175 # need to link with libpthread in order to create multiple threads.
176 AC_CHECK_LIB([pthread], [pthread_kill],
177 [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
178 # On Solaris and HP-UX, most pthread functions exist also in libc.
179 # Therefore pthread_in_use() needs to actually try to create a
180 # thread: pthread_create from libc will fail, whereas
181 # pthread_create will actually create a thread.
182 case "$host_os" in
183 solaris* | hpux*)
184 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
185 [Define if the pthread_in_use() detection is hard.])
186 esac
187 ])
188 else 519 else
189 # Some library is needed. Try libpthread and libc_r.
190 AC_CHECK_LIB([pthread], [pthread_kill],
191 [gl_have_pthread=yes
192 LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
193 LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
194 if test -z "$gl_have_pthread"; then
195 # For FreeBSD 4.
196 AC_CHECK_LIB([c_r], [pthread_kill],
197 [gl_have_pthread=yes
198 LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
199 LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
200 fi
201 fi
202 if test -n "$gl_have_pthread"; then
203 gl_threads_api=posix 520 gl_threads_api=posix
204 AC_DEFINE([USE_POSIX_THREADS], [1], 521 AC_DEFINE([USE_POSIX_THREADS], [1],
205 [Define if the POSIX multithreading library can be used.]) 522 [Define if the POSIX multithreading library can be used.])
206 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then 523 if test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"; then
524 AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1],
525 [Define if references to the POSIX multithreading library are satisfied by libc.])
526 else
207 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 527 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
208 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], 528 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
209 [Define if references to the POSIX multithreading library should be made weak.]) 529 [Define if references to the POSIX multithreading library should be made weak.])
210 LIBTHREAD= 530 LIBTHREAD= LTLIBTHREAD=
211 LTLIBTHREAD= 531 else
532 case "$host_os" in
533 freebsd* | dragonfly* | midnightbsd*)
534 if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then
535 dnl If weak symbols can't tell whether pthread_create(), pthread_key_create()
536 dnl etc. will succeed, we need a runtime test.
537 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
538 [Define if the pthread_in_use() detection is hard.])
539 fi
540 ;;
541 esac
212 fi 542 fi
213 fi 543 fi
214 fi 544 fi
215 fi 545 fi
216 fi 546 fi
217 if test -z "$gl_have_pthread"; then 547 if test $gl_threads_api = none; then
218 if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then 548 if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then
219 gl_have_solaristhread= 549 gl_STDTHREADLIB_BODY
220 gl_save_LIBS="$LIBS" 550 LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD
221 LIBS="$LIBS -lthread" 551 LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD
222 AC_LINK_IFELSE( 552 gl_threads_api=isoc
223 [AC_LANG_PROGRAM( 553 AC_DEFINE([USE_ISOC_THREADS], [1],
224 [[ 554 [Define if the ISO C multithreading library can be used.])
225#include <thread.h>
226#include <synch.h>
227 ]],
228 [[thr_self();]])],
229 [gl_have_solaristhread=yes])
230 LIBS="$gl_save_LIBS"
231 if test -n "$gl_have_solaristhread"; then
232 gl_threads_api=solaris
233 LIBTHREAD=-lthread
234 LTLIBTHREAD=-lthread
235 LIBMULTITHREAD="$LIBTHREAD"
236 LTLIBMULTITHREAD="$LTLIBTHREAD"
237 AC_DEFINE([USE_SOLARIS_THREADS], [1],
238 [Define if the old Solaris multithreading library can be used.])
239 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
240 AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
241 [Define if references to the old Solaris multithreading library should be made weak.])
242 LIBTHREAD=
243 LTLIBTHREAD=
244 fi
245 fi
246 fi 555 fi
247 fi 556 fi
248 if test "$gl_use_threads" = pth; then 557 if test $gl_threads_api = none; then
249 gl_save_CPPFLAGS="$CPPFLAGS"
250 AC_LIB_LINKFLAGS([pth])
251 gl_have_pth=
252 gl_save_LIBS="$LIBS"
253 LIBS="$LIBS $LIBPTH"
254 AC_LINK_IFELSE(
255 [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])],
256 [gl_have_pth=yes])
257 LIBS="$gl_save_LIBS"
258 if test -n "$gl_have_pth"; then
259 gl_threads_api=pth
260 LIBTHREAD="$LIBPTH"
261 LTLIBTHREAD="$LTLIBPTH"
262 LIBMULTITHREAD="$LIBTHREAD"
263 LTLIBMULTITHREAD="$LTLIBTHREAD"
264 AC_DEFINE([USE_PTH_THREADS], [1],
265 [Define if the GNU Pth multithreading library can be used.])
266 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
267 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
268 AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
269 [Define if references to the GNU Pth multithreading library should be made weak.])
270 LIBTHREAD=
271 LTLIBTHREAD=
272 fi
273 fi
274 else
275 CPPFLAGS="$gl_save_CPPFLAGS"
276 fi
277 fi
278 if test -z "$gl_have_pthread"; then
279 case "$gl_use_threads" in 558 case "$gl_use_threads" in
280 yes | windows | win32) # The 'win32' is for backward compatibility. 559 yes | windows | win32) # The 'win32' is for backward compatibility.
281 if { case "$host_os" in 560 if { case "$host_os" in
@@ -317,6 +596,21 @@ AC_DEFUN([gl_DISABLE_THREADS], [
317]) 596])
318 597
319 598
599dnl gl_AVOID_WINPTHREAD
600dnl -------------------
601dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the
602dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided.
603dnl The user can still override it at installation time, by using the
604dnl configure option '--enable-threads'.
605
606AC_DEFUN([gl_AVOID_WINPTHREAD], [
607 m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no])
608])
609
610
611dnl ============================================================================
612
613
320dnl Survey of platforms: 614dnl Survey of platforms:
321dnl 615dnl
322dnl Platform Available Compiler Supports test-lock 616dnl Platform Available Compiler Supports test-lock
@@ -324,7 +618,11 @@ dnl flavours option weak result
324dnl --------------- --------- --------- -------- --------- 618dnl --------------- --------- --------- -------- ---------
325dnl Linux 2.4/glibc posix -lpthread Y OK 619dnl Linux 2.4/glibc posix -lpthread Y OK
326dnl 620dnl
327dnl GNU Hurd/glibc posix 621dnl Linux/glibc 2.34 posix Y OK
622dnl
623dnl GNU Hurd/glibc posix -lpthread Y OK
624dnl
625dnl Ubuntu 14.04 posix -pthread Y OK
328dnl 626dnl
329dnl FreeBSD 5.3 posix -lc_r Y 627dnl FreeBSD 5.3 posix -lc_r Y
330dnl posix -lkse ? Y 628dnl posix -lkse ? Y
@@ -344,7 +642,6 @@ dnl
344dnl Mac OS X 10.[123] posix -lpthread Y OK 642dnl Mac OS X 10.[123] posix -lpthread Y OK
345dnl 643dnl
346dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK 644dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
347dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
348dnl 645dnl
349dnl HP-UX 11 posix -lpthread N (cc) OK 646dnl HP-UX 11 posix -lpthread N (cc) OK
350dnl Y (gcc) 647dnl Y (gcc)
@@ -358,8 +655,6 @@ dnl -lpthread (gcc) Y
358dnl 655dnl
359dnl Cygwin posix -lpthread Y OK 656dnl Cygwin posix -lpthread Y OK
360dnl 657dnl
361dnl Any of the above pth -lpth 0.0
362dnl
363dnl Mingw windows N OK 658dnl Mingw windows N OK
364dnl 659dnl
365dnl BeOS 5 -- 660dnl BeOS 5 --
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index 3b839005..f6bf3a4f 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -1,8 +1,8 @@
1# Configure a more-standard replacement for <time.h>. 1# Configure a more-standard replacement for <time.h>.
2 2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc. 3# Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc.
4 4
5# serial 7 5# serial 20
6 6
7# This file is free software; the Free Software Foundation 7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it, 8# gives unlimited permission to copy and/or distribute it,
@@ -10,23 +10,42 @@
10 10
11# Written by Paul Eggert and Jim Meyering. 11# Written by Paul Eggert and Jim Meyering.
12 12
13AC_DEFUN([gl_HEADER_TIME_H], 13AC_DEFUN_ONCE([gl_TIME_H],
14[ 14[
15 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 15 dnl Ensure to expand the default settings once only, before all statements
16 dnl once only, before all statements that occur in other macros. 16 dnl that occur in other macros.
17 AC_REQUIRE([gl_HEADER_TIME_H_BODY]) 17 AC_REQUIRE([gl_TIME_H_DEFAULTS])
18])
19 18
20AC_DEFUN([gl_HEADER_TIME_H_BODY],
21[
22 AC_REQUIRE([AC_C_RESTRICT])
23 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
24 gl_NEXT_HEADERS([time.h]) 19 gl_NEXT_HEADERS([time.h])
25 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) 20 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
21
22 dnl Check for declarations of anything we want to poison if the
23 dnl corresponding gnulib module is not in use.
24 gl_WARN_ON_USE_PREPARE([[
25#include <time.h>
26 ]], [asctime_r ctime_r])
27
28 AC_REQUIRE([AC_C_RESTRICT])
29
30 AC_CACHE_CHECK([for TIME_UTC in <time.h>],
31 [gl_cv_time_h_has_TIME_UTC],
32 [AC_COMPILE_IFELSE(
33 [AC_LANG_PROGRAM(
34 [[#include <time.h>
35 ]],
36 [[static int x = TIME_UTC; x++;]])],
37 [gl_cv_time_h_has_TIME_UTC=yes],
38 [gl_cv_time_h_has_TIME_UTC=no])])
39 if test $gl_cv_time_h_has_TIME_UTC = yes; then
40 TIME_H_DEFINES_TIME_UTC=1
41 else
42 TIME_H_DEFINES_TIME_UTC=0
43 fi
44 AC_SUBST([TIME_H_DEFINES_TIME_UTC])
26]) 45])
27 46
28dnl Check whether 'struct timespec' is declared 47dnl Check whether 'struct timespec' is declared
29dnl in time.h, sys/time.h, or pthread.h. 48dnl in time.h, sys/time.h, pthread.h, or unistd.h.
30 49
31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], 50AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
32[ 51[
@@ -44,6 +63,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
44 TIME_H_DEFINES_STRUCT_TIMESPEC=0 63 TIME_H_DEFINES_STRUCT_TIMESPEC=0
45 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 64 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
46 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 65 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
66 UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
47 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then 67 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
48 TIME_H_DEFINES_STRUCT_TIMESPEC=1 68 TIME_H_DEFINES_STRUCT_TIMESPEC=1
49 else 69 else
@@ -70,40 +90,94 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
70 [gl_cv_sys_struct_timespec_in_pthread_h=no])]) 90 [gl_cv_sys_struct_timespec_in_pthread_h=no])])
71 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then 91 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
72 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 92 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
93 else
94 AC_CACHE_CHECK([for struct timespec in <unistd.h>],
95 [gl_cv_sys_struct_timespec_in_unistd_h],
96 [AC_COMPILE_IFELSE(
97 [AC_LANG_PROGRAM(
98 [[#include <unistd.h>
99 ]],
100 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
101 [gl_cv_sys_struct_timespec_in_unistd_h=yes],
102 [gl_cv_sys_struct_timespec_in_unistd_h=no])])
103 if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then
104 UNISTD_H_DEFINES_STRUCT_TIMESPEC=1
105 fi
73 fi 106 fi
74 fi 107 fi
75 fi 108 fi
76 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) 109 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
77 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) 110 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
78 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) 111 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
112 AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
79]) 113])
80 114
115# gl_TIME_MODULE_INDICATOR([modulename])
116# sets the shell variable that indicates the presence of the given module
117# to a C preprocessor expression that will evaluate to 1.
118# This macro invocation must not occur in macros that are AC_REQUIREd.
81AC_DEFUN([gl_TIME_MODULE_INDICATOR], 119AC_DEFUN([gl_TIME_MODULE_INDICATOR],
82[ 120[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 121 dnl Ensure to expand the default settings once only.
84 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 122 gl_TIME_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 123 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests. 124 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 125 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88]) 126])
89 127
90AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], 128# Initializes the default values for AC_SUBSTed shell variables.
129# This macro must not be AC_REQUIREd. It must only be invoked, and only
130# outside of macros or in macros that are not AC_REQUIREd.
131AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS],
132[
133 m4_defun(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS], [
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CTIME])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKTIME])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALTIME])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET])
146 dnl Support Microsoft deprecated alias function names by default.
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1])
148 ])
149 m4_require(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS])
150 AC_REQUIRE([gl_TIME_H_DEFAULTS])
151])
152
153AC_DEFUN([gl_TIME_H_DEFAULTS],
91[ 154[
92 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
93 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
94 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
97 dnl Assume proper GNU behavior unless another module says otherwise. 155 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) 156 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) 157 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) 158 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 159 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
160 HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET])
161 HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES])
162 dnl Even GNU libc does not have timezone_t yet.
163 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
102 dnl If another module says to replace or to not replace, do that. 164 dnl If another module says to replace or to not replace, do that.
103 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 165 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
104 dnl this lets maintainers check for portability. 166 dnl this lets maintainers check for portability.
167 REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME])
105 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) 168 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
106 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) 169 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
107 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) 170 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
171 REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME])
108 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) 172 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
173 REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET])
174
175 dnl Hack so that the time module doesn't depend on the sys_time module.
176 dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
177 : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY])
178 dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
179 dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
180 dnl is no longer a big deal.
181 REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME])
182 REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME])
109]) 183])
diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4
index c388a831..adce438a 100644
--- a/gl/m4/time_r.m4
+++ b/gl/m4/time_r.m4
@@ -1,6 +1,6 @@
1dnl Reentrant time functions: localtime_r, gmtime_r. 1dnl Reentrant time functions: localtime_r, gmtime_r.
2 2
3dnl Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. 3dnl Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -12,12 +12,20 @@ AC_DEFUN([gl_TIME_R],
12 dnl Persuade glibc and Solaris <time.h> to declare localtime_r. 12 dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 14
15 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 15 AC_REQUIRE([gl_TIME_H_DEFAULTS])
16 AC_REQUIRE([AC_C_RESTRICT]) 16 AC_REQUIRE([AC_C_RESTRICT])
17 17
18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is 18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
19 dnl not defined. 19 dnl not defined.
20 AC_CHECK_DECLS([localtime_r], [], [], [[#include <time.h>]]) 20 AC_CHECK_DECLS([localtime_r], [], [],
21 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
22 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
23 been included before. */
24 #if defined __MINGW32__
25 # include <unistd.h>
26 #endif
27 #include <time.h>
28 ]])
21 if test $ac_cv_have_decl_localtime_r = no; then 29 if test $ac_cv_have_decl_localtime_r = no; then
22 HAVE_DECL_LOCALTIME_R=0 30 HAVE_DECL_LOCALTIME_R=0
23 fi 31 fi
@@ -29,7 +37,14 @@ AC_DEFUN([gl_TIME_R],
29 [gl_cv_time_r_posix], 37 [gl_cv_time_r_posix],
30 [AC_COMPILE_IFELSE( 38 [AC_COMPILE_IFELSE(
31 [AC_LANG_PROGRAM( 39 [AC_LANG_PROGRAM(
32 [[#include <time.h>]], 40 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
41 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
42 been included before. */
43 #if defined __MINGW32__
44 # include <unistd.h>
45 #endif
46 #include <time.h>
47 ]],
33 [[/* We don't need to append 'restrict's to the argument types, 48 [[/* We don't need to append 'restrict's to the argument types,
34 even though the POSIX signature has the 'restrict's, 49 even though the POSIX signature has the 'restrict's,
35 since C99 says they can't affect type compatibility. */ 50 since C99 says they can't affect type compatibility. */
@@ -49,6 +64,32 @@ AC_DEFUN([gl_TIME_R],
49 fi 64 fi
50 else 65 else
51 HAVE_LOCALTIME_R=0 66 HAVE_LOCALTIME_R=0
67 dnl On mingw, localtime_r() is defined as an inline function; use through a
68 dnl direct function call works but the use as a function pointer leads to a
69 dnl link error.
70 AC_CACHE_CHECK([whether localtime_r exists as an inline function],
71 [gl_cv_func_localtime_r_inline],
72 [AC_LINK_IFELSE(
73 [AC_LANG_PROGRAM(
74 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
75 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
76 been included before. */
77 #if defined __MINGW32__
78 # include <unistd.h>
79 #endif
80 #include <time.h>
81 ]],
82 [[time_t a;
83 struct tm r;
84 localtime_r (&a, &r);
85 ]])
86 ],
87 [gl_cv_func_localtime_r_inline=yes],
88 [gl_cv_func_localtime_r_inline=no])
89 ])
90 if test $gl_cv_func_localtime_r_inline = yes; then
91 REPLACE_LOCALTIME_R=1
92 fi
52 fi 93 fi
53]) 94])
54 95
diff --git a/gl/m4/timegm.m4 b/gl/m4/timegm.m4
index 997953c0..6079f1a3 100644
--- a/gl/m4/timegm.m4
+++ b/gl/m4/timegm.m4
@@ -1,17 +1,17 @@
1# timegm.m4 serial 11 1# timegm.m4 serial 13
2dnl Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_TIMEGM], 7AC_DEFUN([gl_FUNC_TIMEGM],
8[ 8[
9 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 9 AC_REQUIRE([gl_TIME_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_MKTIME]) 10 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
11 REPLACE_TIMEGM=0 11 REPLACE_TIMEGM=0
12 AC_CHECK_FUNCS_ONCE([timegm]) 12 AC_CHECK_FUNCS_ONCE([timegm])
13 if test $ac_cv_func_timegm = yes; then 13 if test $ac_cv_func_timegm = yes; then
14 if test $gl_cv_func_working_mktime = no; then 14 if test "$gl_cv_func_working_mktime" != yes; then
15 # Assume that timegm is buggy if mktime is. 15 # Assume that timegm is buggy if mktime is.
16 REPLACE_TIMEGM=1 16 REPLACE_TIMEGM=1
17 fi 17 fi
diff --git a/gl/m4/uintmax_t.m4 b/gl/m4/uintmax_t.m4
deleted file mode 100644
index c6ff8006..00000000
--- a/gl/m4/uintmax_t.m4
+++ /dev/null
@@ -1,30 +0,0 @@
1# uintmax_t.m4 serial 12
2dnl Copyright (C) 1997-2004, 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9AC_PREREQ([2.13])
10
11# Define uintmax_t to 'unsigned long' or 'unsigned long long'
12# if it is not already defined in <stdint.h> or <inttypes.h>.
13
14AC_DEFUN([gl_AC_TYPE_UINTMAX_T],
15[
16 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
17 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
18 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
19 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
20 test $ac_cv_type_unsigned_long_long_int = yes \
21 && ac_type='unsigned long long' \
22 || ac_type='unsigned long'
23 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
24 [Define to unsigned long or unsigned long long
25 if <stdint.h> and <inttypes.h> don't define.])
26 else
27 AC_DEFINE([HAVE_UINTMAX_T], [1],
28 [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
29 fi
30])
diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4
new file mode 100644
index 00000000..8977a346
--- /dev/null
+++ b/gl/m4/ungetc.m4
@@ -0,0 +1,73 @@
1# ungetc.m4 serial 10
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
8[
9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11
12 AC_CACHE_CHECK([whether ungetc works on arbitrary bytes],
13 [gl_cv_func_ungetc_works],
14 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
15#include <stdio.h>
16 ]], [[FILE *f;
17 if (!(f = fopen ("conftest.tmp", "w+")))
18 return 1;
19 if (fputs ("abc", f) < 0)
20 { fclose (f); return 2; }
21 rewind (f);
22 if (fgetc (f) != 'a')
23 { fclose (f); return 3; }
24 if (fgetc (f) != 'b')
25 { fclose (f); return 4; }
26 if (ungetc ('d', f) != 'd')
27 { fclose (f); return 5; }
28 if (ftell (f) != 1)
29 { fclose (f); return 6; }
30 if (fgetc (f) != 'd')
31 { fclose (f); return 7; }
32 if (ftell (f) != 2)
33 { fclose (f); return 8; }
34 if (fseek (f, 0, SEEK_CUR) != 0)
35 { fclose (f); return 9; }
36 if (ftell (f) != 2)
37 { fclose (f); return 10; }
38 if (fgetc (f) != 'c')
39 { fclose (f); return 11; }
40 fclose (f);
41 remove ("conftest.tmp");
42 ]])],
43 [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
44 [case "$host_os" in
45 # Guess yes on glibc systems.
46 *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;;
47 # Guess yes on musl systems.
48 *-musl*) gl_cv_func_ungetc_works="guessing yes" ;;
49 # Guess yes on bionic systems.
50 *-android*) gl_cv_func_ungetc_works="guessing yes" ;;
51 # Guess yes on native Windows.
52 mingw*) gl_cv_func_ungetc_works="guessing yes" ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;;
55 esac
56 ])
57 ])
58 gl_ftello_broken_after_ungetc=no
59 case "$gl_cv_func_ungetc_works" in
60 *yes) ;;
61 *)
62 dnl On macOS >= 10.15, where the above program fails with exit code 6,
63 dnl we fix it through an ftello override.
64 case "$host_os" in
65 darwin*) gl_ftello_broken_after_ungetc=yes ;;
66 *)
67 AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
68 [Define to 1 if ungetc is broken when used on arbitrary bytes.])
69 ;;
70 esac
71 ;;
72 esac
73])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 32dcfa58..f4384027 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,15 +1,15 @@
1# unistd_h.m4 serial 66 1# unistd_h.m4 serial 90
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Simon Josefsson, Bruno Haible. 7dnl Written by Simon Josefsson, Bruno Haible.
8 8
9AC_DEFUN([gl_UNISTD_H], 9AC_DEFUN_ONCE([gl_UNISTD_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
14 14
15 gl_CHECK_NEXT_HEADERS([unistd.h]) 15 gl_CHECK_NEXT_HEADERS([unistd.h])
@@ -37,150 +37,234 @@ AC_DEFUN([gl_UNISTD_H],
37# include <fcntl.h> 37# include <fcntl.h>
38# include <stdio.h> 38# include <stdio.h>
39# include <stdlib.h> 39# include <stdlib.h>
40# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 40# if defined _WIN32 && ! defined __CYGWIN__
41# include <io.h> 41# include <io.h>
42# endif 42# endif
43#endif 43#endif
44 ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat 44 ]], [access chdir chown copy_file_range dup dup2 dup3 environ euidaccess
45 fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups 45 execl execle execlp execv execve execvp execvpe
46 gethostname getlogin getlogin_r getpagesize 46 faccessat fchdir
47 fchownat fdatasync fsync ftruncate getcwd getdomainname getdtablesize
48 getentropy getgroups gethostname getlogin getlogin_r getpagesize getpass
47 getusershell setusershell endusershell 49 getusershell setusershell endusershell
48 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite 50 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
49 readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r 51 readlink readlinkat rmdir sethostname sleep symlink symlinkat
50 unlink unlinkat usleep]) 52 truncate ttyname_r unlink unlinkat usleep])
53
54 AC_REQUIRE([AC_C_RESTRICT])
55
56 AC_CHECK_DECLS_ONCE([execvpe])
57 if test $ac_cv_have_decl_execvpe = no; then
58 HAVE_DECL_EXECVPE=0
59 fi
51]) 60])
52 61
62# gl_UNISTD_MODULE_INDICATOR([modulename])
63# sets the shell variable that indicates the presence of the given module
64# to a C preprocessor expression that will evaluate to 1.
65# This macro invocation must not occur in macros that are AC_REQUIREd.
53AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], 66AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
54[ 67[
55 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 68 dnl Ensure to expand the default settings once only.
56 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 69 gl_UNISTD_H_REQUIRE_DEFAULTS
57 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 70 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
58 dnl Define it also as a C macro, for the benefit of the unit tests. 71 dnl Define it also as a C macro, for the benefit of the unit tests.
59 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 72 gl_MODULE_INDICATOR_FOR_TESTS([$1])
60]) 73])
61 74
75# Initializes the default values for AC_SUBSTed shell variables.
76# This macro must not be AC_REQUIREd. It must only be invoked, and only
77# outside of macros or in macros that are not AC_REQUIREd.
78AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS],
79[
80 m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS], [
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCESS])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHDIR])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHOWN])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSE])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPY_FILE_RANGE])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP2])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP3])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ENVIRON])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EUIDACCESS])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECL])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLE])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLP])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECV])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVE])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVP])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVPE])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FACCESSAT])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHDIR])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHOWNAT])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDATASYNC])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSYNC])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTRUNCATE])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCWD])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDOMAINNAME])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDTABLESIZE])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETENTROPY])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETGROUPS])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETHOSTNAME])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN_R])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS_GNU])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHOWN])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINK])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINKAT])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSEEK])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE2])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PREAD])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PWRITE])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READ])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINK])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINKAT])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RMDIR])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETHOSTNAME])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SLEEP])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINK])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINKAT])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCATE])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TTYNAME_R])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_NONBLOCKING])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_SIGPIPE])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINK])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINKAT])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_USLEEP])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WRITE])
144 dnl Support Microsoft deprecated alias function names by default.
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ACCESS], [1])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHDIR], [1])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CLOSE], [1])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP], [1])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP2], [1])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECL], [1])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLE], [1])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLP], [1])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECV], [1])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVE], [1])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVP], [1])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVPE], [1])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETCWD], [1])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETPID], [1])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ISATTY], [1])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LSEEK], [1])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_READ], [1])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_RMDIR], [1])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_SWAB], [1])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UNLINK], [1])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WRITE], [1])
166 ])
167 m4_require(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS])
168 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
169])
170
62AC_DEFUN([gl_UNISTD_H_DEFAULTS], 171AC_DEFUN([gl_UNISTD_H_DEFAULTS],
63[ 172[
64 GNULIB_CHDIR=0; AC_SUBST([GNULIB_CHDIR])
65 GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
66 GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
67 GNULIB_DUP=0; AC_SUBST([GNULIB_DUP])
68 GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
69 GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3])
70 GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
71 GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
72 GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT])
73 GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
74 GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT])
75 GNULIB_FDATASYNC=0; AC_SUBST([GNULIB_FDATASYNC])
76 GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
77 GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
78 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
79 GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
80 GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
81 GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
82 GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
83 GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
84 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
85 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
86 GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
87 GNULIB_GROUP_MEMBER=0; AC_SUBST([GNULIB_GROUP_MEMBER])
88 GNULIB_ISATTY=0; AC_SUBST([GNULIB_ISATTY])
89 GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
90 GNULIB_LINK=0; AC_SUBST([GNULIB_LINK])
91 GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
92 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
93 GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE])
94 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
95 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
96 GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE])
97 GNULIB_READ=0; AC_SUBST([GNULIB_READ])
98 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
99 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
100 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
101 GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME])
102 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
103 GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
104 GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
105 GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R])
106 GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
107 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
108 GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
109 GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
110 GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
111 GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
112 dnl Assume proper GNU behavior unless another module says otherwise. 173 dnl Assume proper GNU behavior unless another module says otherwise.
113 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) 174 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
114 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) 175 HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE])
115 HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) 176 HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
116 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) 177 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
117 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) 178 HAVE_EXECVPE=1; AC_SUBST([HAVE_EXECVPE])
118 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) 179 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
119 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) 180 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR])
120 HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC]) 181 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
121 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) 182 HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC])
122 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) 183 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
123 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) 184 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
124 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) 185 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
125 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) 186 HAVE_GETENTROPY=1; AC_SUBST([HAVE_GETENTROPY])
126 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) 187 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS])
127 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) 188 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
128 HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) 189 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN])
129 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) 190 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
130 HAVE_LINK=1; AC_SUBST([HAVE_LINK]) 191 HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS])
131 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) 192 HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER])
132 HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) 193 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
133 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) 194 HAVE_LINK=1; AC_SUBST([HAVE_LINK])
134 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) 195 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
135 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) 196 HAVE_PIPE=1; AC_SUBST([HAVE_PIPE])
136 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) 197 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
137 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) 198 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
138 HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) 199 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE])
139 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) 200 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
140 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) 201 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
141 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) 202 HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME])
142 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) 203 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
143 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) 204 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
144 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) 205 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
145 HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) 206 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
146 HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) 207 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
147 HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) 208 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
148 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) 209 HAVE_DECL_EXECVPE=1; AC_SUBST([HAVE_DECL_EXECVPE])
149 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) 210 HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR])
150 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) 211 HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC])
151 HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) 212 HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
152 HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) 213 HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN])
153 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) 214 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
154 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) 215 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
155 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) 216 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
156 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) 217 HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
157 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) 218 HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE])
158 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) 219 HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R])
159 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) 220 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
160 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) 221 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
161 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) 222 REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS])
162 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) 223 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
163 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) 224 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
164 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) 225 REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE])
165 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) 226 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
166 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) 227 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
167 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) 228 REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL])
168 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) 229 REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE])
169 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) 230 REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP])
170 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) 231 REPLACE_EXECV=0; AC_SUBST([REPLACE_EXECV])
171 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) 232 REPLACE_EXECVE=0; AC_SUBST([REPLACE_EXECVE])
172 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) 233 REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP])
173 REPLACE_READ=0; AC_SUBST([REPLACE_READ]) 234 REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE])
174 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) 235 REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT])
175 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) 236 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
176 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) 237 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
177 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) 238 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
178 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) 239 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
179 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) 240 REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
180 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) 241 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
181 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) 242 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
182 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) 243 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
183 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) 244 REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS])
245 REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
246 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
247 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
248 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
249 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
250 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
251 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
252 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
253 REPLACE_READ=0; AC_SUBST([REPLACE_READ])
254 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
255 REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT])
256 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
257 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
258 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
259 REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT])
260 REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE])
261 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R])
262 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
263 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
264 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP])
265 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
266 UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H])
267 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
184 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; 268 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
185 AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) 269 AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
186]) 270])
diff --git a/gl/m4/unlocked-io.m4 b/gl/m4/unlocked-io.m4
new file mode 100644
index 00000000..407c0bac
--- /dev/null
+++ b/gl/m4/unlocked-io.m4
@@ -0,0 +1,36 @@
1# unlocked-io.m4 serial 16
2
3# Copyright (C) 1998-2006, 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9dnl From Jim Meyering.
10dnl
11dnl See if the glibc *_unlocked I/O macros or functions are available.
12dnl Use only those *_unlocked macros or functions that are declared
13dnl (because some of them were declared in Solaris 2.5.1 but were removed
14dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
15dnl on Solaris 2.6).
16
17AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
18[
19 dnl Persuade glibc and Solaris <stdio.h> to declare
20 dnl fgets_unlocked(), fputs_unlocked() etc.
21 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
22
23 AC_CHECK_DECLS_ONCE([clearerr_unlocked])
24 AC_CHECK_DECLS_ONCE([feof_unlocked])
25 AC_CHECK_DECLS_ONCE([ferror_unlocked])
26 AC_CHECK_DECLS_ONCE([fflush_unlocked])
27 AC_CHECK_DECLS_ONCE([fgets_unlocked])
28 AC_CHECK_DECLS_ONCE([fputc_unlocked])
29 AC_CHECK_DECLS_ONCE([fputs_unlocked])
30 AC_CHECK_DECLS_ONCE([fread_unlocked])
31 AC_CHECK_DECLS_ONCE([fwrite_unlocked])
32 AC_CHECK_DECLS_ONCE([getc_unlocked])
33 AC_CHECK_DECLS_ONCE([getchar_unlocked])
34 AC_CHECK_DECLS_ONCE([putc_unlocked])
35 AC_CHECK_DECLS_ONCE([putchar_unlocked])
36])
diff --git a/gl/m4/vararrays.m4 b/gl/m4/vararrays.m4
new file mode 100644
index 00000000..fd6230c2
--- /dev/null
+++ b/gl/m4/vararrays.m4
@@ -0,0 +1,72 @@
1# Check for variable-length arrays.
2
3# serial 6
4
5# From Paul Eggert
6
7# Copyright (C) 2001, 2009-2023 Free Software Foundation, Inc.
8# This file is free software; the Free Software Foundation
9# gives unlimited permission to copy and/or distribute it,
10# with or without modifications, as long as this notice is preserved.
11
12m4_version_prereq([2.70], [], [
13
14# AC_C_VARARRAYS
15# --------------
16# Check whether the C compiler supports variable-length arrays.
17AC_DEFUN([AC_C_VARARRAYS],
18[
19 AC_CACHE_CHECK([for variable-length arrays],
20 ac_cv_c_vararrays,
21 [AC_EGREP_CPP([defined],
22 [#ifdef __STDC_NO_VLA__
23 defined
24 #endif
25 ],
26 [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[/* Test for VLA support. This test is partly inspired
30 from examples in the C standard. Use at least two VLA
31 functions to detect the GCC 3.4.3 bug described in:
32 https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
33 */
34 #ifdef __STDC_NO_VLA__
35 syntax error;
36 #else
37 extern int n;
38 int B[100];
39 int fvla (int m, int C[m][m]);
40
41 int
42 simple (int count, int all[static count])
43 {
44 return all[count - 1];
45 }
46
47 int
48 fvla (int m, int C[m][m])
49 {
50 typedef int VLA[m][m];
51 VLA x;
52 int D[m];
53 static int (*q)[m] = &B;
54 int (*s)[n] = q;
55 return C && &x[0][0] == &D[0] && &D[0] == s[0];
56 }
57 #endif
58 ]])],
59 [ac_cv_c_vararrays=yes],
60 [ac_cv_c_vararrays=no])])])
61 if test "$ac_cv_c_vararrays" = yes; then
62 dnl This is for compatibility with Autoconf 2.61-2.69.
63 AC_DEFINE([HAVE_C_VARARRAYS], 1,
64 [Define to 1 if C supports variable-length arrays.])
65 elif test "$ac_cv_c_vararrays" = no; then
66 AC_DEFINE([__STDC_NO_VLA__], 1,
67 [Define to 1 if C does not support variable-length arrays, and
68 if the compiler does not already define this.])
69 fi
70])
71
72])
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index d730e435..6361c843 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,5 +1,5 @@
1# vasnprintf.m4 serial 36 1# vasnprintf.m4 serial 38
2dnl Copyright (C) 2002-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -32,7 +32,6 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
32# Prerequisites of lib/printf-args.h, lib/printf-args.c. 32# Prerequisites of lib/printf-args.h, lib/printf-args.c.
33AC_DEFUN([gl_PREREQ_PRINTF_ARGS], 33AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
34[ 34[
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
36 AC_REQUIRE([gt_TYPE_WCHAR_T]) 35 AC_REQUIRE([gt_TYPE_WCHAR_T])
37 AC_REQUIRE([gt_TYPE_WINT_T]) 36 AC_REQUIRE([gt_TYPE_WINT_T])
38]) 37])
@@ -41,7 +40,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
41AC_DEFUN([gl_PREREQ_PRINTF_PARSE], 40AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
42[ 41[
43 AC_REQUIRE([gl_FEATURES_H]) 42 AC_REQUIRE([gl_FEATURES_H])
44 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
45 AC_REQUIRE([gt_TYPE_WCHAR_T]) 43 AC_REQUIRE([gt_TYPE_WCHAR_T])
46 AC_REQUIRE([gt_TYPE_WINT_T]) 44 AC_REQUIRE([gt_TYPE_WINT_T])
47 AC_REQUIRE([AC_TYPE_SIZE_T]) 45 AC_REQUIRE([AC_TYPE_SIZE_T])
@@ -56,7 +54,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
56AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], 54AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
57[ 55[
58 AC_REQUIRE([AC_FUNC_ALLOCA]) 56 AC_REQUIRE([AC_FUNC_ALLOCA])
59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
60 AC_REQUIRE([gt_TYPE_WCHAR_T]) 57 AC_REQUIRE([gt_TYPE_WCHAR_T])
61 AC_REQUIRE([gt_TYPE_WINT_T]) 58 AC_REQUIRE([gt_TYPE_WINT_T])
62 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) 59 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
@@ -77,6 +74,16 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
77 if the buffer had been large enough.]) 74 if the buffer had been large enough.])
78 ;; 75 ;;
79 esac 76 esac
77 dnl Additionally, the use of %n can be eliminated by assuming that snprintf
78 dnl always produces NUL-terminated strings (no truncation).
79 AC_REQUIRE([gl_SNPRINTF_TRUNCATION_C99])
80 case "$gl_cv_func_snprintf_truncation_c99" in
81 *yes)
82 AC_DEFINE([HAVE_SNPRINTF_TRUNCATION_C99], [1],
83 [Define if the string produced by the snprintf function is always NUL
84 terminated.])
85 ;;
86 esac
80]) 87])
81 88
82# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' 89# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4
index c214ff11..6e6156a7 100644
--- a/gl/m4/vasprintf.m4
+++ b/gl/m4/vasprintf.m4
@@ -1,5 +1,5 @@
1# vasprintf.m4 serial 6 1# vasprintf.m4 serial 6
2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4
index 6cbd7e5f..f0468e89 100644
--- a/gl/m4/visibility.m4
+++ b/gl/m4/visibility.m4
@@ -1,5 +1,5 @@
1# visibility.m4 serial 5 (gettext-0.18.2) 1# visibility.m4 serial 8
2dnl Copyright (C) 2005, 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -29,42 +29,47 @@ AC_DEFUN([gl_VISIBILITY],
29 dnl First, check whether -Werror can be added to the command line, or 29 dnl First, check whether -Werror can be added to the command line, or
30 dnl whether it leads to an error because of some other option that the 30 dnl whether it leads to an error because of some other option that the
31 dnl user has put into $CC $CFLAGS $CPPFLAGS. 31 dnl user has put into $CC $CFLAGS $CPPFLAGS.
32 AC_MSG_CHECKING([whether the -Werror option is usable]) 32 AC_CACHE_CHECK([whether the -Werror option is usable],
33 AC_CACHE_VAL([gl_cv_cc_vis_werror], [ 33 [gl_cv_cc_vis_werror],
34 gl_save_CFLAGS="$CFLAGS" 34 [gl_save_CFLAGS="$CFLAGS"
35 CFLAGS="$CFLAGS -Werror" 35 CFLAGS="$CFLAGS -Werror"
36 AC_COMPILE_IFELSE( 36 AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM([[]], [[]])], 37 [AC_LANG_PROGRAM([[]], [[]])],
38 [gl_cv_cc_vis_werror=yes], 38 [gl_cv_cc_vis_werror=yes],
39 [gl_cv_cc_vis_werror=no]) 39 [gl_cv_cc_vis_werror=no])
40 CFLAGS="$gl_save_CFLAGS"]) 40 CFLAGS="$gl_save_CFLAGS"
41 AC_MSG_RESULT([$gl_cv_cc_vis_werror]) 41 ])
42 dnl Now check whether visibility declarations are supported. 42 dnl Now check whether visibility declarations are supported.
43 AC_MSG_CHECKING([for simple visibility declarations]) 43 AC_CACHE_CHECK([for simple visibility declarations],
44 AC_CACHE_VAL([gl_cv_cc_visibility], [ 44 [gl_cv_cc_visibility],
45 gl_save_CFLAGS="$CFLAGS" 45 [gl_save_CFLAGS="$CFLAGS"
46 CFLAGS="$CFLAGS -fvisibility=hidden" 46 CFLAGS="$CFLAGS -fvisibility=hidden"
47 dnl We use the option -Werror and a function dummyfunc, because on some 47 dnl We use the option -Werror and a function dummyfunc, because on some
48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning 48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
49 dnl "visibility attribute not supported in this configuration; ignored" 49 dnl "visibility attribute not supported in this configuration; ignored"
50 dnl at the first function definition in every compilation unit, and we 50 dnl at the first function definition in every compilation unit, and we
51 dnl don't want to use the option in this case. 51 dnl don't want to use the option in this case.
52 if test $gl_cv_cc_vis_werror = yes; then 52 if test $gl_cv_cc_vis_werror = yes; then
53 CFLAGS="$CFLAGS -Werror" 53 CFLAGS="$CFLAGS -Werror"
54 fi 54 fi
55 AC_COMPILE_IFELSE( 55 AC_COMPILE_IFELSE(
56 [AC_LANG_PROGRAM( 56 [AC_LANG_PROGRAM(
57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; 57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
58 extern __attribute__((__visibility__("default"))) int exportedvar; 58 extern __attribute__((__visibility__("default"))) int exportedvar;
59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
60 extern __attribute__((__visibility__("default"))) int exportedfunc (void); 60 extern __attribute__((__visibility__("default"))) int exportedfunc (void);
61 void dummyfunc (void) {} 61 void dummyfunc (void);
62 ]], 62 int hiddenvar;
63 [[]])], 63 int exportedvar;
64 [gl_cv_cc_visibility=yes], 64 int hiddenfunc (void) { return 51; }
65 [gl_cv_cc_visibility=no]) 65 int exportedfunc (void) { return 1225736919; }
66 CFLAGS="$gl_save_CFLAGS"]) 66 void dummyfunc (void) {}
67 AC_MSG_RESULT([$gl_cv_cc_visibility]) 67 ]],
68 [[]])],
69 [gl_cv_cc_visibility=yes],
70 [gl_cv_cc_visibility=no])
71 CFLAGS="$gl_save_CFLAGS"
72 ])
68 if test $gl_cv_cc_visibility = yes; then 73 if test $gl_cv_cc_visibility = yes; then
69 CFLAG_VISIBILITY="-fvisibility=hidden" 74 CFLAG_VISIBILITY="-fvisibility=hidden"
70 HAVE_VISIBILITY=1 75 HAVE_VISIBILITY=1
diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4
index 4900764e..7fbb11c4 100644
--- a/gl/m4/vsnprintf.m4
+++ b/gl/m4/vsnprintf.m4
@@ -1,5 +1,5 @@
1# vsnprintf.m4 serial 6 1# vsnprintf.m4 serial 7
2dnl Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,14 @@ AC_DEFUN([gl_REPLACE_VSNPRINTF],
46 AC_LIBOBJ([vsnprintf]) 46 AC_LIBOBJ([vsnprintf])
47 if test $ac_cv_func_vsnprintf = yes; then 47 if test $ac_cv_func_vsnprintf = yes; then
48 REPLACE_VSNPRINTF=1 48 REPLACE_VSNPRINTF=1
49 else
50 AC_CHECK_DECLS_ONCE([vsnprintf])
51 if test $ac_cv_have_decl_vsnprintf = yes; then
52 dnl If the function is declared but does not appear to exist, it may be
53 dnl defined as an inline function. In order to avoid a conflict, we have
54 dnl to define rpl_vsnprintf, not vsnprintf.
55 REPLACE_VSNPRINTF=1
56 fi
49 fi 57 fi
50 gl_PREREQ_VSNPRINTF 58 gl_PREREQ_VSNPRINTF
51]) 59])
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4
index e43beebd..10649c5c 100644
--- a/gl/m4/warn-on-use.m4
+++ b/gl/m4/warn-on-use.m4
@@ -1,11 +1,13 @@
1# warn-on-use.m4 serial 5 1# warn-on-use.m4 serial 10
2dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) 7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
8# --------------------------------------- 8# ---------------------------------------
9# If the module 'posixcheck' is in use:
10#
9# For each whitespace-separated element in the list of NAMES, define 11# For each whitespace-separated element in the list of NAMES, define
10# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES 12# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
11# even after being undefined as a macro. 13# even after being undefined as a macro.
@@ -23,25 +25,38 @@ dnl with or without modifications, as long as this notice is preserved.
23# needing gl_WARN_ON_USE_PREPARE. 25# needing gl_WARN_ON_USE_PREPARE.
24AC_DEFUN([gl_WARN_ON_USE_PREPARE], 26AC_DEFUN([gl_WARN_ON_USE_PREPARE],
25[ 27[
26 m4_foreach_w([gl_decl], [$2], 28 m4_ifdef([gl_POSIXCHECK],
27 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), 29 [m4_foreach_w([gl_decl], [$2],
28 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after 30 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
29 undefining macros.])])dnl 31 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
30dnl FIXME: gl_Symbol must be used unquoted until we can assume 32 undefining macros.])])dnl
31dnl autoconf 2.64 or newer. 33 for gl_func in m4_flatten([$2]); do
32 for gl_func in m4_flatten([$2]); do 34 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
33 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl 35 dnl As a workaround to implicit built-in function declarations in
34 AC_CACHE_CHECK([whether $gl_func is declared without a macro], 36 dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead
35 gl_Symbol, 37 dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC
36 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], 38 dnl in zzgnulib.m4 is inactive, use the original ac_compile.
37[@%:@undef $gl_func 39 ac_save_ac_compile="$ac_compile"
38 (void) $gl_func;])], 40 if test -n "$ac_compile_for_check_decl"; then
39 [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) 41 ac_compile="$ac_compile_for_check_decl"
40 AS_VAR_IF(gl_Symbol, [yes], 42 fi
41 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) 43 AC_CACHE_CHECK([whether $gl_func is declared without a macro],
42 dnl shortcut - if the raw declaration exists, then set a cache 44 [gl_Symbol],
43 dnl variable to allow skipping any later AC_CHECK_DECL efforts 45 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
44 eval ac_cv_have_decl_$gl_func=yes]) 46[[#undef $gl_func
45 AS_VAR_POPDEF([gl_Symbol])dnl 47 (void) $gl_func;]])],
46 done 48 [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
49 ac_compile="$ac_save_ac_compile"
50 AS_VAR_IF([gl_Symbol], [yes],
51 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
52 dnl Shortcut for an AC_CHECK_DECL invocation that may come later:
53 dnl If the raw declaration exists with the given includes, then
54 dnl AC_CHECK_DECL with its many includes would see it as well.
55 dnl So, set a cache variable to allow skipping any later
56 dnl AC_CHECK_DECL invocation for $gl_func.
57 eval "ac_cv_have_decl_$gl_func=yes"
58 ])
59 AS_VAR_POPDEF([gl_Symbol])dnl
60 done
61 ])
47]) 62])
diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4
index bedb15a4..8ec66193 100644
--- a/gl/m4/wchar_h.m4
+++ b/gl/m4/wchar_h.m4
@@ -1,15 +1,15 @@
1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. 1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl Written by Eric Blake. 8dnl Written by Eric Blake.
9 9
10# wchar_h.m4 serial 39 10# wchar_h.m4 serial 55
11 11
12AC_DEFUN([gl_WCHAR_H], 12AC_DEFUN_ONCE([gl_WCHAR_H],
13[ 13[
14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) 15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
@@ -35,76 +35,82 @@ AC_DEFUN([gl_WCHAR_H],
35 fi 35 fi
36 AC_SUBST([HAVE_WINT_T]) 36 AC_SUBST([HAVE_WINT_T])
37 37
38 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
39
38 dnl Check for declarations of anything we want to poison if the 40 dnl Check for declarations of anything we want to poison if the
39 dnl corresponding gnulib module is not in use. 41 dnl corresponding gnulib module is not in use.
40 gl_WARN_ON_USE_PREPARE([[ 42 gl_WARN_ON_USE_PREPARE([[
41/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 43 #include <wchar.h>
42 <wchar.h>.
43 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
44 included before <wchar.h>. */
45#if !(defined __GLIBC__ && !defined __UCLIBC__)
46# include <stddef.h>
47# include <stdio.h>
48# include <time.h>
49#endif
50#include <wchar.h>
51 ]], 44 ]],
52 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb 45 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
53 wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset 46 wcsrtombs wcsnrtombs wcwidth
47 wmemchr wmemcmp wmemcpy wmemmove wmempcpy wmemset
54 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp 48 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
55 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr 49 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
56 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth 50 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth wcsftime
57 ]) 51 ])
52
53 AC_REQUIRE([AC_C_RESTRICT])
54
55 AC_CHECK_DECLS([wcsdup], [], [], [[
56 #include <wchar.h>
57 ]])
58 if test $ac_cv_have_decl_wcsdup = no; then
59 HAVE_DECL_WCSDUP=0
60 fi
58]) 61])
59 62
60dnl Check whether <wchar.h> is usable at all. 63dnl Check whether <wchar.h> is usable at all.
61AC_DEFUN([gl_WCHAR_H_INLINE_OK], 64AC_DEFUN([gl_WCHAR_H_INLINE_OK],
62[ 65[
63 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to 66 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
64 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022> 67 dnl 'gnu_inline'. See <https://sourceware.org/bugzilla/show_bug.cgi?id=4022>
65 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary, 68 dnl and <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
66 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and 69 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
67 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>. 70 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
71 AC_REQUIRE([AC_CANONICAL_HOST])
68 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly], 72 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
69 [gl_cv_header_wchar_h_correct_inline], 73 [gl_cv_header_wchar_h_correct_inline],
70 [gl_cv_header_wchar_h_correct_inline=yes 74 [gl_cv_header_wchar_h_correct_inline=yes
71 AC_LANG_CONFTEST([ 75 case "$host_os" in
72 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 76 *-gnu* | gnu*)
73/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 77 AC_LANG_CONFTEST([
74 <wchar.h>. 78 AC_LANG_SOURCE([[
75 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 79 #define wcstod renamed_wcstod
76 included before <wchar.h>. */ 80 #include <wchar.h>
77#include <stddef.h> 81 extern int zero (void);
78#include <stdio.h> 82 int main () { return zero(); }
79#include <time.h> 83 ]])])
80#include <wchar.h> 84 dnl Do not rename the object file from conftest.$ac_objext to
81extern int zero (void); 85 dnl conftest1.$ac_objext, as this will cause the link to fail on
82int main () { return zero(); } 86 dnl z/OS when using the XPLINK object format (due to duplicate
83]])]) 87 dnl CSECT names). Instead, temporarily redefine $ac_compile so
84 if AC_TRY_EVAL([ac_compile]); then 88 dnl that the object file has the latter name from the start.
85 mv conftest.$ac_objext conftest1.$ac_objext 89 save_ac_compile="$ac_compile"
86 AC_LANG_CONFTEST([ 90 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/`
87 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 91 if echo '#include "conftest.c"' >conftest1.c \
88/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 92 && AC_TRY_EVAL([ac_compile]); then
89 <wchar.h>. 93 AC_LANG_CONFTEST([
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 94 AC_LANG_SOURCE([[
91 included before <wchar.h>. */ 95 #define wcstod renamed_wcstod
92#include <stddef.h> 96 #include <wchar.h>
93#include <stdio.h> 97 int zero (void) { return 0; }
94#include <time.h> 98 ]])])
95#include <wchar.h> 99 dnl See note above about renaming object files.
96int zero (void) { return 0; } 100 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/`
97]])]) 101 if echo '#include "conftest.c"' >conftest2.c \
98 if AC_TRY_EVAL([ac_compile]); then 102 && AC_TRY_EVAL([ac_compile]); then
99 mv conftest.$ac_objext conftest2.$ac_objext 103 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
100 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then 104 :
101 : 105 else
102 else 106 gl_cv_header_wchar_h_correct_inline=no
103 gl_cv_header_wchar_h_correct_inline=no 107 fi
108 fi
104 fi 109 fi
105 fi 110 ac_compile="$save_ac_compile"
106 fi 111 rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext
107 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext 112 ;;
113 esac
108 ]) 114 ])
109 if test $gl_cv_header_wchar_h_correct_inline = no; then 115 if test $gl_cv_header_wchar_h_correct_inline = no; then
110 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). 116 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
@@ -112,63 +118,84 @@ This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
112C99 mode. You have four options: 118C99 mode. You have four options:
113 - Add the flag -fgnu89-inline to CC and reconfigure, or 119 - Add the flag -fgnu89-inline to CC and reconfigure, or
114 - Fix your include files, using parts of 120 - Fix your include files, using parts of
115 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or 121 <https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
116 - Use a gcc version older than 4.3, or 122 - Use a gcc version older than 4.3, or
117 - Don't use the flags -std=c99 or -std=gnu99. 123 - Don't use the flags -std=c99 or -std=gnu99.
118Configuration aborted.]) 124Configuration aborted.])
119 fi 125 fi
120]) 126])
121 127
128# gl_WCHAR_MODULE_INDICATOR([modulename])
129# sets the shell variable that indicates the presence of the given module
130# to a C preprocessor expression that will evaluate to 1.
131# This macro invocation must not occur in macros that are AC_REQUIREd.
122AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], 132AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
123[ 133[
124 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 134 dnl Ensure to expand the default settings once only.
125 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 135 gl_WCHAR_H_REQUIRE_DEFAULTS
126 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 136 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
127 dnl Define it also as a C macro, for the benefit of the unit tests. 137 dnl Define it also as a C macro, for the benefit of the unit tests.
128 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 138 gl_MODULE_INDICATOR_FOR_TESTS([$1])
129]) 139])
130 140
141# Initializes the default values for AC_SUBSTed shell variables.
142# This macro must not be AC_REQUIREd. It must only be invoked, and only
143# outside of macros or in macros that are not AC_REQUIREd.
144AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS],
145[
146 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS], [
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOWC])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOB])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSINIT])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOWC])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRLEN])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOWCS])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNRTOWCS])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCRTOMB])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRTOMBS])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNRTOMBS])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCWIDTH])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCHR])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCMP])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCPY])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMMOVE])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMPCPY])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMSET])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSLEN])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNLEN])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCPY])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPCPY])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCPY])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPNCPY])
170 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCAT])
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCAT])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCMP])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCMP])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCASECMP])
175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCASECMP])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCOLL])
177 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSXFRM])
178 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSDUP])
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCHR])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRCHR])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCSPN])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSPN])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSPBRK])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSTR])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSTOK])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSWIDTH])
187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSFTIME])
188 dnl Support Microsoft deprecated alias function names by default.
189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1])
190 ])
191 m4_require(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS])
192 dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
193 gl_STDLIB_H_REQUIRE_DEFAULTS
194 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
195])
196
131AC_DEFUN([gl_WCHAR_H_DEFAULTS], 197AC_DEFUN([gl_WCHAR_H_DEFAULTS],
132[ 198[
133 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
134 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
135 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
136 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
137 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
138 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
139 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
140 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
141 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
142 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
143 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
144 GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR])
145 GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP])
146 GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY])
147 GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE])
148 GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET])
149 GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN])
150 GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN])
151 GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY])
152 GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY])
153 GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY])
154 GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY])
155 GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT])
156 GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT])
157 GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP])
158 GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP])
159 GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP])
160 GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
161 GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL])
162 GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM])
163 GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP])
164 GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR])
165 GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR])
166 GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN])
167 GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN])
168 GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK])
169 GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR])
170 GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK])
171 GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH])
172 dnl Assume proper GNU behavior unless another module says otherwise. 199 dnl Assume proper GNU behavior unless another module says otherwise.
173 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) 200 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
174 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) 201 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
@@ -183,6 +210,7 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
183 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP]) 210 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP])
184 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY]) 211 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY])
185 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE]) 212 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE])
213 HAVE_WMEMPCPY=1; AC_SUBST([HAVE_WMEMPCPY])
186 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET]) 214 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET])
187 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN]) 215 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN])
188 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN]) 216 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN])
@@ -207,7 +235,9 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
207 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR]) 235 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR])
208 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK]) 236 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK])
209 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH]) 237 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH])
238 HAVE_WCSFTIME=1; AC_SUBST([HAVE_WCSFTIME])
210 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) 239 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
240 HAVE_DECL_WCSDUP=1; AC_SUBST([HAVE_DECL_WCSDUP])
211 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) 241 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
212 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) 242 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
213 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC]) 243 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
@@ -222,4 +252,6 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
222 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS]) 252 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
223 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) 253 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
224 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) 254 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
255 REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME])
256 REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK])
225]) 257])
diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4
index e1e1e699..50bde08a 100644
--- a/gl/m4/wchar_t.m4
+++ b/gl/m4/wchar_t.m4
@@ -1,5 +1,5 @@
1# wchar_t.m4 serial 4 (gettext-0.18.2) 1# wchar_t.m4 serial 4 (gettext-0.18.2)
2dnl Copyright (C) 2002-2003, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
index f56b5bae..d51b36e1 100644
--- a/gl/m4/wcrtomb.m4
+++ b/gl/m4/wcrtomb.m4
@@ -1,5 +1,5 @@
1# wcrtomb.m4 serial 11 1# wcrtomb.m4 serial 17
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,15 +15,8 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
15 if test $ac_cv_func_wcrtomb = no; then 15 if test $ac_cv_func_wcrtomb = no; then
16 HAVE_WCRTOMB=0 16 HAVE_WCRTOMB=0
17 AC_CHECK_DECLS([wcrtomb],,, [[ 17 AC_CHECK_DECLS([wcrtomb],,, [[
18/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 18 #include <wchar.h>
19 <wchar.h>. 19 ]])
20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
21 included before <wchar.h>. */
22#include <stddef.h>
23#include <stdio.h>
24#include <time.h>
25#include <wchar.h>
26]])
27 if test $ac_cv_have_decl_wcrtomb = yes; then 20 if test $ac_cv_have_decl_wcrtomb = yes; then
28 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although 21 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although
29 dnl it does not have the function. Avoid a collision with gnulib's 22 dnl it does not have the function. Avoid a collision with gnulib's
@@ -31,17 +24,56 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
31 REPLACE_WCRTOMB=1 24 REPLACE_WCRTOMB=1
32 fi 25 fi
33 else 26 else
34 if test $REPLACE_MBSTATE_T = 1; then 27 dnl We don't actually need to override wcrtomb when redefining the semantics
35 REPLACE_WCRTOMB=1 28 dnl of the mbstate_t type. Tested on 32-bit AIX.
36 else 29 dnl if test $REPLACE_MBSTATE_T = 1; then
37 dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes 30 dnl REPLACE_WCRTOMB=1
38 dnl returns 0 instead of 1. 31 dnl fi
32 if test $REPLACE_WCRTOMB = 0; then
33 dnl On Android 4.3, wcrtomb produces wrong characters in the C locale.
34 dnl On AIX 4.3, OSF/1 5.1 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL)
35 dnl sometimes returns 0 instead of 1.
39 AC_REQUIRE([AC_PROG_CC]) 36 AC_REQUIRE([AC_PROG_CC])
40 AC_REQUIRE([gt_LOCALE_FR]) 37 AC_REQUIRE([gt_LOCALE_FR])
41 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 38 AC_REQUIRE([gt_LOCALE_FR_UTF8])
42 AC_REQUIRE([gt_LOCALE_JA]) 39 AC_REQUIRE([gt_LOCALE_JA])
43 AC_REQUIRE([gt_LOCALE_ZH_CN]) 40 AC_REQUIRE([gt_LOCALE_ZH_CN])
44 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 41 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
42 AC_CACHE_CHECK([whether wcrtomb works in the C locale],
43 [gl_cv_func_wcrtomb_works],
44 [AC_RUN_IFELSE(
45 [AC_LANG_SOURCE([[
46#include <string.h>
47#include <stdlib.h>
48#include <wchar.h>
49int main ()
50{
51 mbstate_t state;
52 char out[64];
53 int count;
54 memset (&state, 0, sizeof (state));
55 out[0] = 'x';
56 count = wcrtomb (out, L'a', &state);
57 return !(count == 1 && out[0] == 'a');
58}]])],
59 [gl_cv_func_wcrtomb_works=yes],
60 [gl_cv_func_wcrtomb_works=no],
61 [case "$host_os" in
62 # Guess no on Android.
63 linux*-android*) gl_cv_func_wcrtomb_works="guessing no";;
64 # Guess yes otherwise.
65 *) gl_cv_func_wcrtomb_works="guessing yes";;
66 esac
67 ])
68 ])
69 case "$gl_cv_func_wcrtomb_works" in
70 *yes) ;;
71 *) AC_DEFINE([WCRTOMB_C_LOCALE_BUG], [1],
72 [Define if the wcrtomb function does not work in the C locale.])
73 REPLACE_WCRTOMB=1 ;;
74 esac
75 fi
76 if test $REPLACE_WCRTOMB = 0; then
45 AC_CACHE_CHECK([whether wcrtomb return value is correct], 77 AC_CACHE_CHECK([whether wcrtomb return value is correct],
46 [gl_cv_func_wcrtomb_retval], 78 [gl_cv_func_wcrtomb_retval],
47 [ 79 [
@@ -49,10 +81,10 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
49 dnl is present. 81 dnl is present.
50changequote(,)dnl 82changequote(,)dnl
51 case "$host_os" in 83 case "$host_os" in
52 # Guess no on AIX 4, OSF/1 and Solaris. 84 # Guess no on AIX 4, OSF/1, Solaris, native Windows.
53 aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; 85 aix4* | osf* | solaris* | mingw*) gl_cv_func_wcrtomb_retval="guessing no" ;;
54 # Guess yes otherwise. 86 # Guess yes otherwise.
55 *) gl_cv_func_wcrtomb_retval="guessing yes" ;; 87 *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
56 esac 88 esac
57changequote([,])dnl 89changequote([,])dnl
58 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then 90 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
@@ -60,14 +92,8 @@ changequote([,])dnl
60 [AC_LANG_SOURCE([[ 92 [AC_LANG_SOURCE([[
61#include <locale.h> 93#include <locale.h>
62#include <string.h> 94#include <string.h>
63/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
64 <wchar.h>.
65 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
66 included before <wchar.h>. */
67#include <stddef.h>
68#include <stdio.h>
69#include <time.h>
70#include <wchar.h> 95#include <wchar.h>
96#include <stdlib.h>
71int main () 97int main ()
72{ 98{
73 int result = 0; 99 int result = 0;
@@ -80,6 +106,12 @@ int main ()
80 { 106 {
81 if (wcrtomb (NULL, 0, NULL) != 1) 107 if (wcrtomb (NULL, 0, NULL) != 1)
82 result |= 2; 108 result |= 2;
109 {
110 wchar_t wc = (wchar_t) 0xBADFACE;
111 if (mbtowc (&wc, "\303\274", 2) == 2)
112 if (wcrtomb (NULL, wc, NULL) != 1)
113 result |= 2;
114 }
83 } 115 }
84 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 116 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
85 { 117 {
@@ -100,7 +132,9 @@ int main ()
100 ]) 132 ])
101 case "$gl_cv_func_wcrtomb_retval" in 133 case "$gl_cv_func_wcrtomb_retval" in
102 *yes) ;; 134 *yes) ;;
103 *) REPLACE_WCRTOMB=1 ;; 135 *) AC_DEFINE([WCRTOMB_RETVAL_BUG], [1],
136 [Define if the wcrtomb function has an incorrect return value.])
137 REPLACE_WCRTOMB=1 ;;
104 esac 138 esac
105 fi 139 fi
106 fi 140 fi
diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4
index 82ada0ee..6856a735 100644
--- a/gl/m4/wctype_h.m4
+++ b/gl/m4/wctype_h.m4
@@ -1,15 +1,15 @@
1# wctype_h.m4 serial 18 1# wctype_h.m4 serial 30
2 2
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it. 3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4 4
5dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 5dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
6dnl This file is free software; the Free Software Foundation 6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it, 7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved. 8dnl with or without modifications, as long as this notice is preserved.
9 9
10dnl Written by Paul Eggert. 10dnl Written by Paul Eggert.
11 11
12AC_DEFUN([gl_WCTYPE_H], 12AC_DEFUN_ONCE([gl_WCTYPE_H],
13[ 13[
14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) 14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
15 AC_REQUIRE([AC_PROG_CC]) 15 AC_REQUIRE([AC_PROG_CC])
@@ -30,6 +30,8 @@ AC_DEFUN([gl_WCTYPE_H],
30 fi 30 fi
31 AC_SUBST([HAVE_WINT_T]) 31 AC_SUBST([HAVE_WINT_T])
32 32
33 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
34
33 gl_CHECK_NEXT_HEADERS([wctype.h]) 35 gl_CHECK_NEXT_HEADERS([wctype.h])
34 if test $ac_cv_header_wctype_h = yes; then 36 if test $ac_cv_header_wctype_h = yes; then
35 if test $ac_cv_func_iswcntrl = yes; then 37 if test $ac_cv_func_iswcntrl = yes; then
@@ -39,22 +41,16 @@ AC_DEFUN([gl_WCTYPE_H],
39 [ 41 [
40 AC_RUN_IFELSE( 42 AC_RUN_IFELSE(
41 [AC_LANG_SOURCE([[ 43 [AC_LANG_SOURCE([[
42 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
43 included before <wchar.h>.
44 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
45 must be included before <wchar.h>. */
46 #include <stddef.h>
47 #include <stdio.h>
48 #include <time.h>
49 #include <wchar.h> 44 #include <wchar.h>
50 #include <wctype.h> 45 #include <wctype.h>
51 int main () { return iswprint ('x') == 0; } 46 int main () { return iswprint ('x') == 0; }
52 ]])], 47 ]])],
53 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no], 48 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
54 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> 49 [dnl Guess no on Linux libc5, yes otherwise.
50 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
55 #if __GNU_LIBRARY__ == 1 51 #if __GNU_LIBRARY__ == 1
56 Linux libc5 i18n is broken. 52 Linux libc5 i18n is broken.
57 #endif]], [])], 53 #endif]], [[]])],
58 [gl_cv_func_iswcntrl_works="guessing yes"], 54 [gl_cv_func_iswcntrl_works="guessing yes"],
59 [gl_cv_func_iswcntrl_works="guessing no"]) 55 [gl_cv_func_iswcntrl_works="guessing no"])
60 ]) 56 ])
@@ -66,10 +62,14 @@ AC_DEFUN([gl_WCTYPE_H],
66 fi 62 fi
67 AC_SUBST([HAVE_WCTYPE_H]) 63 AC_SUBST([HAVE_WCTYPE_H])
68 64
69 case "$gl_cv_func_iswcntrl_works" in 65 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
70 *yes) REPLACE_ISWCNTRL=0 ;; 66 REPLACE_ISWCNTRL=1
71 *) REPLACE_ISWCNTRL=1 ;; 67 else
72 esac 68 case "$gl_cv_func_iswcntrl_works" in
69 *yes) REPLACE_ISWCNTRL=0 ;;
70 *) REPLACE_ISWCNTRL=1 ;;
71 esac
72 fi
73 AC_SUBST([REPLACE_ISWCNTRL]) 73 AC_SUBST([REPLACE_ISWCNTRL])
74 74
75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then 75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
@@ -85,14 +85,7 @@ AC_DEFUN([gl_WCTYPE_H],
85 REPLACE_TOWLOWER=0 85 REPLACE_TOWLOWER=0
86 else 86 else
87 AC_CHECK_DECLS([towlower],,, 87 AC_CHECK_DECLS([towlower],,,
88 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 88 [[#include <wchar.h>
89 included before <wchar.h>.
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
91 must be included before <wchar.h>. */
92 #include <stddef.h>
93 #include <stdio.h>
94 #include <time.h>
95 #include <wchar.h>
96 #if HAVE_WCTYPE_H 89 #if HAVE_WCTYPE_H
97 # include <wctype.h> 90 # include <wctype.h>
98 #endif 91 #endif
@@ -121,14 +114,7 @@ AC_DEFUN([gl_WCTYPE_H],
121 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t], 114 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
122 [AC_COMPILE_IFELSE( 115 [AC_COMPILE_IFELSE(
123 [AC_LANG_PROGRAM( 116 [AC_LANG_PROGRAM(
124 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 117 [[#include <wchar.h>
125 included before <wchar.h>.
126 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
127 must be included before <wchar.h>. */
128 #include <stddef.h>
129 #include <stdio.h>
130 #include <time.h>
131 #include <wchar.h>
132 #if HAVE_WCTYPE_H 118 #if HAVE_WCTYPE_H
133 # include <wctype.h> 119 # include <wctype.h>
134 #endif 120 #endif
@@ -147,14 +133,7 @@ AC_DEFUN([gl_WCTYPE_H],
147 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t], 133 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
148 [AC_COMPILE_IFELSE( 134 [AC_COMPILE_IFELSE(
149 [AC_LANG_PROGRAM( 135 [AC_LANG_PROGRAM(
150 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 136 [[#include <wchar.h>
151 included before <wchar.h>.
152 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
153 must be included before <wchar.h>. */
154 #include <stddef.h>
155 #include <stdio.h>
156 #include <time.h>
157 #include <wchar.h>
158 #include <wctype.h> 137 #include <wctype.h>
159 wctrans_t a; 138 wctrans_t a;
160 ]], 139 ]],
@@ -169,14 +148,7 @@ AC_DEFUN([gl_WCTYPE_H],
169 dnl Check for declarations of anything we want to poison if the 148 dnl Check for declarations of anything we want to poison if the
170 dnl corresponding gnulib module is not in use. 149 dnl corresponding gnulib module is not in use.
171 gl_WARN_ON_USE_PREPARE([[ 150 gl_WARN_ON_USE_PREPARE([[
172/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
173 <wchar.h>.
174 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
175 included before <wchar.h>. */
176#if !(defined __GLIBC__ && !defined __UCLIBC__) 151#if !(defined __GLIBC__ && !defined __UCLIBC__)
177# include <stddef.h>
178# include <stdio.h>
179# include <time.h>
180# include <wchar.h> 152# include <wchar.h>
181#endif 153#endif
182#include <wctype.h> 154#include <wctype.h>
@@ -185,25 +157,44 @@ AC_DEFUN([gl_WCTYPE_H],
185 ]) 157 ])
186]) 158])
187 159
160# gl_WCTYPE_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1.
163# This macro invocation must not occur in macros that are AC_REQUIREd.
188AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR], 164AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
189[ 165[
190 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 166 dnl Ensure to expand the default settings once only.
191 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) 167 gl_WCTYPE_H_REQUIRE_DEFAULTS
192 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 168 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
193 dnl Define it also as a C macro, for the benefit of the unit tests. 169 dnl Define it also as a C macro, for the benefit of the unit tests.
194 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 170 gl_MODULE_INDICATOR_FOR_TESTS([$1])
195]) 171])
196 172
173# Initializes the default values for AC_SUBSTed shell variables.
174# This macro must not be AC_REQUIREd. It must only be invoked, and only
175# outside of macros or in macros that are not AC_REQUIREd.
176AC_DEFUN([gl_WCTYPE_H_REQUIRE_DEFAULTS],
177[
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTRANS])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOWCTRANS])
186 ])
187 m4_require(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS])
188 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
189])
190
197AC_DEFUN([gl_WCTYPE_H_DEFAULTS], 191AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
198[ 192[
199 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
200 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
201 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
202 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
203 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
204 dnl Assume proper GNU behavior unless another module says otherwise. 193 dnl Assume proper GNU behavior unless another module says otherwise.
205 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK]) 194 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
206 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T]) 195 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
207 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) 196 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
208 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) 197 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
198 REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT])
199 REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT])
209]) 200])
diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4
index d7cd3db9..dfd743b3 100644
--- a/gl/m4/wint_t.m4
+++ b/gl/m4/wint_t.m4
@@ -1,11 +1,12 @@
1# wint_t.m4 serial 5 (gettext-0.18.2) 1# wint_t.m4 serial 11
2dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8dnl Test whether <wchar.h> has the 'wint_t' type. 8dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
9dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
9dnl Prerequisite: AC_PROG_CC 10dnl Prerequisite: AC_PROG_CC
10 11
11AC_DEFUN([gt_TYPE_WINT_T], 12AC_DEFUN([gt_TYPE_WINT_T],
@@ -13,20 +14,44 @@ AC_DEFUN([gt_TYPE_WINT_T],
13 AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], 14 AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
14 [AC_COMPILE_IFELSE( 15 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM( 16 [AC_LANG_PROGRAM(
16 [[ 17 [[#include <wchar.h>
17/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
18 <wchar.h>.
19 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
20 before <wchar.h>. */
21#include <stddef.h>
22#include <stdio.h>
23#include <time.h>
24#include <wchar.h>
25 wint_t foo = (wchar_t)'\0';]], 18 wint_t foo = (wchar_t)'\0';]],
26 [[]])], 19 [[]])],
27 [gt_cv_c_wint_t=yes], 20 [gt_cv_c_wint_t=yes],
28 [gt_cv_c_wint_t=no])]) 21 [gt_cv_c_wint_t=no])])
29 if test $gt_cv_c_wint_t = yes; then 22 if test $gt_cv_c_wint_t = yes; then
30 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) 23 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
24
25 dnl Determine whether gnulib's <wchar.h> or <wctype.h> would, if present,
26 dnl override 'wint_t'.
27 AC_CACHE_CHECK([whether wint_t is large enough],
28 [gl_cv_type_wint_t_large_enough],
29 [AC_COMPILE_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[#include <wchar.h>
32 int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1];
33 ]])],
34 [gl_cv_type_wint_t_large_enough=yes],
35 [gl_cv_type_wint_t_large_enough=no])])
36 if test $gl_cv_type_wint_t_large_enough = no; then
37 GNULIBHEADERS_OVERRIDE_WINT_T=1
38 else
39 GNULIBHEADERS_OVERRIDE_WINT_T=0
40 fi
41 else
42 GNULIBHEADERS_OVERRIDE_WINT_T=0
43 fi
44 AC_SUBST([GNULIBHEADERS_OVERRIDE_WINT_T])
45])
46
47dnl Prerequisites of the 'wint_t' override.
48AC_DEFUN([gl_TYPE_WINT_T_PREREQ],
49[
50 AC_CHECK_HEADERS_ONCE([crtdefs.h])
51 if test $ac_cv_header_crtdefs_h = yes; then
52 HAVE_CRTDEFS_H=1
53 else
54 HAVE_CRTDEFS_H=0
31 fi 55 fi
56 AC_SUBST([HAVE_CRTDEFS_H])
32]) 57])
diff --git a/gl/m4/xalloc.m4 b/gl/m4/xalloc.m4
index 64ca7014..fc56f59a 100644
--- a/gl/m4/xalloc.m4
+++ b/gl/m4/xalloc.m4
@@ -1,5 +1,5 @@
1# xalloc.m4 serial 18 1# xalloc.m4 serial 18
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4
index 8ea9f2cd..649db9c5 100644
--- a/gl/m4/xsize.m4
+++ b/gl/m4/xsize.m4
@@ -1,5 +1,5 @@
1# xsize.m4 serial 5 1# xsize.m4 serial 5
2dnl Copyright (C) 2003-2004, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003-2004, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/xstrndup.m4 b/gl/m4/xstrndup.m4
deleted file mode 100644
index 4a9330bb..00000000
--- a/gl/m4/xstrndup.m4
+++ /dev/null
@@ -1,15 +0,0 @@
1# xstrndup.m4 serial 2
2dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_XSTRNDUP],
8[
9 gl_PREREQ_XSTRNDUP
10])
11
12# Prerequisites of lib/xstrndup.c.
13AC_DEFUN([gl_PREREQ_XSTRNDUP], [
14 :
15])
diff --git a/gl/m4/zzgnulib.m4 b/gl/m4/zzgnulib.m4
new file mode 100644
index 00000000..362102b6
--- /dev/null
+++ b/gl/m4/zzgnulib.m4
@@ -0,0 +1,23 @@
1# zzgnulib.m4 serial 1
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl This file must be named something that sorts after all other
8dnl package- or gnulib-provided .m4 files - at least for those packages
9dnl that redefine AC_PROG_CC.
10
11dnl Redefine AC_PROG_CC so that it ends with invocations of gl_COMPILER_CLANG
12dnl and gl_COMPILER_PREPARE_CHECK_DECL.
13m4_define([AC_PROG_CC],
14 m4_defn([AC_PROG_CC])[
15gl_COMPILER_CLANG
16gl_COMPILER_PREPARE_CHECK_DECL
17])
18
19# gl_ZZGNULIB
20# -----------
21# Witness macro that this file has been included. Needed to force
22# Automake to include this file after all other gnulib .m4 files.
23AC_DEFUN([gl_ZZGNULIB])
diff --git a/gl/malloc.c b/gl/malloc.c
index 908735d2..3ade35cb 100644
--- a/gl/malloc.c
+++ b/gl/malloc.c
@@ -1,51 +1,46 @@
1/* malloc() function that is glibc compatible. 1/* malloc() function that is glibc compatible.
2 2
3 Copyright (C) 1997-1998, 2006-2007, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 1997-1998, 2006-2007, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* written by Jim Meyering and Bruno Haible */ 18/* written by Jim Meyering and Bruno Haible */
19 19
20#define _GL_USE_STDLIB_ALLOC 1 20#define _GL_USE_STDLIB_ALLOC 1
21#include <config.h> 21#include <config.h>
22/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
23#ifdef malloc
24# define NEED_MALLOC_GNU 1
25# undef malloc
26/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */
27#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU
28# define NEED_MALLOC_GNU 1
29#endif
30 22
31#include <stdlib.h> 23#include <stdlib.h>
32 24
33#include <errno.h> 25#include <errno.h>
34 26
35/* Allocate an N-byte block of memory from the heap. 27#include "xalloc-oversized.h"
36 If N is zero, allocate a 1-byte block. */ 28
29/* Allocate an N-byte block of memory from the heap, even if N is 0. */
37 30
38void * 31void *
39rpl_malloc (size_t n) 32rpl_malloc (size_t n)
40{ 33{
41 void *result;
42
43#if NEED_MALLOC_GNU
44 if (n == 0) 34 if (n == 0)
45 n = 1; 35 n = 1;
46#endif
47 36
48 result = malloc (n); 37 if (xalloc_oversized (n, 1))
38 {
39 errno = ENOMEM;
40 return NULL;
41 }
42
43 void *result = malloc (n);
49 44
50#if !HAVE_MALLOC_POSIX 45#if !HAVE_MALLOC_POSIX
51 if (result == NULL) 46 if (result == NULL)
diff --git a/gl/malloc/dynarray-skeleton.c b/gl/malloc/dynarray-skeleton.c
new file mode 100644
index 00000000..580c278b
--- /dev/null
+++ b/gl/malloc/dynarray-skeleton.c
@@ -0,0 +1,528 @@
1/* Type-safe arrays which grow dynamically.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* Pre-processor macros which act as parameters:
20
21 DYNARRAY_STRUCT
22 The struct tag of dynamic array to be defined.
23 DYNARRAY_ELEMENT
24 The type name of the element type. Elements are copied
25 as if by memcpy, and can change address as the dynamic
26 array grows.
27 DYNARRAY_PREFIX
28 The prefix of the functions which are defined.
29
30 The following parameters are optional:
31
32 DYNARRAY_ELEMENT_FREE
33 DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
34 contents of elements. E is of type DYNARRAY_ELEMENT *.
35 DYNARRAY_ELEMENT_INIT
36 DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
37 element. E is of type DYNARRAY_ELEMENT *.
38 If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
39 defined, new elements are automatically zero-initialized.
40 Otherwise, new elements have undefined contents.
41 DYNARRAY_INITIAL_SIZE
42 The size of the statically allocated array (default:
43 at least 2, more elements if they fit into 128 bytes).
44 Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
45 there is no statically allocated array at, and all non-empty
46 arrays are heap-allocated.
47 DYNARRAY_FINAL_TYPE
48 The name of the type which holds the final array. If not
49 defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
50 must be a struct type, with members of type DYNARRAY_ELEMENT and
51 size_t at the start (in this order).
52
53 These macros are undefined after this header file has been
54 included.
55
56 The following types are provided (their members are private to the
57 dynarray implementation):
58
59 struct DYNARRAY_STRUCT
60
61 The following functions are provided:
62
63 void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *);
64 void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *);
65 bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *);
66 void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *);
67 size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *);
68 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *);
69 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *);
70 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t);
71 void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT);
72 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *);
73 bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t);
74 void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *);
75 void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *);
76
77 The following functions are provided are provided if the
78 prerequisites are met:
79
80 bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
81 DYNARRAY_FINAL_TYPE *);
82 (if DYNARRAY_FINAL_TYPE is defined)
83 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
84 size_t *);
85 (if DYNARRAY_FINAL_TYPE is not defined)
86*/
87
88#include <malloc/dynarray.h>
89
90#include <errno.h>
91#include <stdlib.h>
92#include <string.h>
93
94#ifndef DYNARRAY_STRUCT
95# error "DYNARRAY_STRUCT must be defined"
96#endif
97
98#ifndef DYNARRAY_ELEMENT
99# error "DYNARRAY_ELEMENT must be defined"
100#endif
101
102#ifndef DYNARRAY_PREFIX
103# error "DYNARRAY_PREFIX must be defined"
104#endif
105
106#ifdef DYNARRAY_INITIAL_SIZE
107# if DYNARRAY_INITIAL_SIZE < 0
108# error "DYNARRAY_INITIAL_SIZE must be non-negative"
109# endif
110# if DYNARRAY_INITIAL_SIZE > 0
111# define DYNARRAY_HAVE_SCRATCH 1
112# else
113# define DYNARRAY_HAVE_SCRATCH 0
114# endif
115#else
116/* Provide a reasonable default which limits the size of
117 DYNARRAY_STRUCT. */
118# define DYNARRAY_INITIAL_SIZE \
119 (sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT))
120# define DYNARRAY_HAVE_SCRATCH 1
121#endif
122
123/* Public type definitions. */
124
125/* All fields of this struct are private to the implementation. */
126struct DYNARRAY_STRUCT
127{
128 union
129 {
130 struct dynarray_header dynarray_abstract;
131 struct
132 {
133 /* These fields must match struct dynarray_header. */
134 size_t used;
135 size_t allocated;
136 DYNARRAY_ELEMENT *array;
137 } dynarray_header;
138 } u;
139
140#if DYNARRAY_HAVE_SCRATCH
141 /* Initial inline allocation. */
142 DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE];
143#endif
144};
145
146/* Internal use only: Helper macros. */
147
148/* Ensure macro-expansion of DYNARRAY_PREFIX. */
149#define DYNARRAY_CONCAT0(prefix, name) prefix##name
150#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
151#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
152
153/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
154 so that Gnulib does not change 'free' to 'rpl_free'. */
155#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
156
157/* Address of the scratch buffer if any. */
158#if DYNARRAY_HAVE_SCRATCH
159# define DYNARRAY_SCRATCH(list) (list)->scratch
160#else
161# define DYNARRAY_SCRATCH(list) NULL
162#endif
163
164/* Internal use only: Helper functions. */
165
166/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array
167 elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE
168 macro expansion. */
169static inline void
170DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
171 size_t __dynarray_used)
172{
173#ifdef DYNARRAY_ELEMENT_FREE
174 for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i)
175 DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]);
176#endif /* DYNARRAY_ELEMENT_FREE */
177}
178
179/* Internal function. Free the non-scratch array allocation. */
180static inline void
181DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
182{
183#if DYNARRAY_HAVE_SCRATCH
184 if (list->u.dynarray_header.array != list->scratch)
185 free (list->u.dynarray_header.array);
186#else
187 free (list->u.dynarray_header.array);
188#endif
189}
190
191/* Public functions. */
192
193/* Initialize a dynamic array object. This must be called before any
194 use of the object. */
195__attribute_nonnull__ ((1))
196static void
197DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
198{
199 list->u.dynarray_header.used = 0;
200 list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE;
201 list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
202}
203
204/* Deallocate the dynamic array and its elements. */
205__attribute_maybe_unused__ __attribute_nonnull__ ((1))
206static void
207DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
208{
209 DYNARRAY_NAME (free__elements__)
210 (list->u.dynarray_header.array, list->u.dynarray_header.used);
211 DYNARRAY_NAME (free__array__) (list);
212 DYNARRAY_NAME (init) (list);
213}
214
215/* Return true if the dynamic array is in an error state. */
216__attribute_nonnull__ ((1))
217static inline bool
218DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
219{
220 return list->u.dynarray_header.allocated == __dynarray_error_marker ();
221}
222
223/* Mark the dynamic array as failed. All elements are deallocated as
224 a side effect. */
225__attribute_nonnull__ ((1))
226static void
227DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
228{
229 DYNARRAY_NAME (free__elements__)
230 (list->u.dynarray_header.array, list->u.dynarray_header.used);
231 DYNARRAY_NAME (free__array__) (list);
232 list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
233 list->u.dynarray_header.used = 0;
234 list->u.dynarray_header.allocated = __dynarray_error_marker ();
235}
236
237/* Return the number of elements which have been added to the dynamic
238 array. */
239__attribute_nonnull__ ((1))
240static inline size_t
241DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
242{
243 return list->u.dynarray_header.used;
244}
245
246/* Return a pointer to the array element at INDEX. Terminate the
247 process if INDEX is out of bounds. */
248__attribute_nonnull__ ((1))
249static inline DYNARRAY_ELEMENT *
250DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
251{
252 if (__glibc_unlikely (index >= DYNARRAY_NAME (size) (list)))
253 __libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index);
254 return list->u.dynarray_header.array + index;
255}
256
257/* Return a pointer to the first array element, if any. For a
258 zero-length array, the pointer can be NULL even though the dynamic
259 array has not entered the failure state. */
260__attribute_nonnull__ ((1))
261static inline DYNARRAY_ELEMENT *
262DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
263{
264 return list->u.dynarray_header.array;
265}
266
267/* Return a pointer one element past the last array element. For a
268 zero-length array, the pointer can be NULL even though the dynamic
269 array has not entered the failure state. */
270__attribute_nonnull__ ((1))
271static inline DYNARRAY_ELEMENT *
272DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
273{
274 return list->u.dynarray_header.array + list->u.dynarray_header.used;
275}
276
277/* Internal function. Slow path for the add function below. */
278static void
279DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
280{
281 if (__glibc_unlikely
282 (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
283 DYNARRAY_SCRATCH (list),
284 sizeof (DYNARRAY_ELEMENT))))
285 {
286 DYNARRAY_NAME (mark_failed) (list);
287 return;
288 }
289
290 /* Copy the new element and increase the array length. */
291 list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
292}
293
294/* Add ITEM at the end of the array, enlarging it by one element.
295 Mark *LIST as failed if the dynamic array allocation size cannot be
296 increased. */
297__attribute_nonnull__ ((1))
298static inline void
299DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
300{
301 /* Do nothing in case of previous error. */
302 if (DYNARRAY_NAME (has_failed) (list))
303 return;
304
305 /* Enlarge the array if necessary. */
306 if (__glibc_unlikely (list->u.dynarray_header.used
307 == list->u.dynarray_header.allocated))
308 {
309 DYNARRAY_NAME (add__) (list, item);
310 return;
311 }
312
313 /* Copy the new element and increase the array length. */
314 list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
315}
316
317/* Internal function. Building block for the emplace functions below.
318 Assumes space for one more element in *LIST. */
319static inline DYNARRAY_ELEMENT *
320DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list)
321{
322 DYNARRAY_ELEMENT *result
323 = &list->u.dynarray_header.array[list->u.dynarray_header.used];
324 ++list->u.dynarray_header.used;
325#if defined (DYNARRAY_ELEMENT_INIT)
326 DYNARRAY_ELEMENT_INIT (result);
327#elif defined (DYNARRAY_ELEMENT_FREE)
328 memset (result, 0, sizeof (*result));
329#endif
330 return result;
331}
332
333/* Internal function. Slow path for the emplace function below. */
334static DYNARRAY_ELEMENT *
335DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
336{
337 if (__glibc_unlikely
338 (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
339 DYNARRAY_SCRATCH (list),
340 sizeof (DYNARRAY_ELEMENT))))
341 {
342 DYNARRAY_NAME (mark_failed) (list);
343 return NULL;
344 }
345 return DYNARRAY_NAME (emplace__tail__) (list);
346}
347
348/* Allocate a place for a new element in *LIST and return a pointer to
349 it. The pointer can be NULL if the dynamic array cannot be
350 enlarged due to a memory allocation failure. */
351__attribute_maybe_unused__ __attribute_warn_unused_result__
352__attribute_nonnull__ ((1))
353static
354/* Avoid inlining with the larger initialization code. */
355#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
356inline
357#endif
358DYNARRAY_ELEMENT *
359DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
360{
361 /* Do nothing in case of previous error. */
362 if (DYNARRAY_NAME (has_failed) (list))
363 return NULL;
364
365 /* Enlarge the array if necessary. */
366 if (__glibc_unlikely (list->u.dynarray_header.used
367 == list->u.dynarray_header.allocated))
368 return (DYNARRAY_NAME (emplace__) (list));
369 return DYNARRAY_NAME (emplace__tail__) (list);
370}
371
372/* Change the size of *LIST to SIZE. If SIZE is larger than the
373 existing size, new elements are added (which can be initialized).
374 Otherwise, the list is truncated, and elements are freed. Return
375 false on memory allocation failure (and mark *LIST as failed). */
376__attribute_maybe_unused__ __attribute_nonnull__ ((1))
377static bool
378DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
379{
380 if (size > list->u.dynarray_header.used)
381 {
382 bool ok;
383#if defined (DYNARRAY_ELEMENT_INIT)
384 /* The new elements have to be initialized. */
385 size_t old_size = list->u.dynarray_header.used;
386 ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
387 size, DYNARRAY_SCRATCH (list),
388 sizeof (DYNARRAY_ELEMENT));
389 if (ok)
390 for (size_t i = old_size; i < size; ++i)
391 {
392 DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
393 }
394#elif defined (DYNARRAY_ELEMENT_FREE)
395 /* Zero initialization is needed so that the elements can be
396 safely freed. */
397 ok = __libc_dynarray_resize_clear
398 (&list->u.dynarray_abstract, size,
399 DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT));
400#else
401 ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
402 size, DYNARRAY_SCRATCH (list),
403 sizeof (DYNARRAY_ELEMENT));
404#endif
405 if (__glibc_unlikely (!ok))
406 DYNARRAY_NAME (mark_failed) (list);
407 return ok;
408 }
409 else
410 {
411 /* The list has shrunk in size. Free the removed elements. */
412 DYNARRAY_NAME (free__elements__)
413 (list->u.dynarray_header.array + size,
414 list->u.dynarray_header.used - size);
415 list->u.dynarray_header.used = size;
416 return true;
417 }
418}
419
420/* Remove the last element of LIST if it is present. */
421__attribute_maybe_unused__ __attribute_nonnull__ ((1))
422static void
423DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
424{
425 /* used > 0 implies that the array is the non-failed state. */
426 if (list->u.dynarray_header.used > 0)
427 {
428 size_t new_length = list->u.dynarray_header.used - 1;
429#ifdef DYNARRAY_ELEMENT_FREE
430 DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]);
431#endif
432 list->u.dynarray_header.used = new_length;
433 }
434}
435
436/* Remove all elements from the list. The elements are freed, but the
437 list itself is not. */
438__attribute_maybe_unused__ __attribute_nonnull__ ((1))
439static void
440DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
441{
442 /* free__elements__ does nothing if the list is in the failed
443 state. */
444 DYNARRAY_NAME (free__elements__)
445 (list->u.dynarray_header.array, list->u.dynarray_header.used);
446 list->u.dynarray_header.used = 0;
447}
448
449#ifdef DYNARRAY_FINAL_TYPE
450/* Transfer the dynamic array to a permanent location at *RESULT.
451 Returns true on success on false on allocation failure. In either
452 case, *LIST is re-initialized and can be reused. A NULL pointer is
453 stored in *RESULT if LIST refers to an empty list. On success, the
454 pointer in *RESULT is heap-allocated and must be deallocated using
455 free. */
456__attribute_maybe_unused__ __attribute_warn_unused_result__
457__attribute_nonnull__ ((1, 2))
458static bool
459DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
460 DYNARRAY_FINAL_TYPE *result)
461{
462 struct dynarray_finalize_result res;
463 if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
464 DYNARRAY_SCRATCH (list),
465 sizeof (DYNARRAY_ELEMENT), &res))
466 {
467 /* On success, the result owns all the data. */
468 DYNARRAY_NAME (init) (list);
469 *result = (DYNARRAY_FINAL_TYPE) { res.array, res.length };
470 return true;
471 }
472 else
473 {
474 /* On error, we need to free all data. */
475 DYNARRAY_FREE (list);
476 errno = ENOMEM;
477 return false;
478 }
479}
480#else /* !DYNARRAY_FINAL_TYPE */
481/* Transfer the dynamic array to a heap-allocated array and return a
482 pointer to it. The pointer is NULL if memory allocation fails, or
483 if the array is empty, so this function should be used only for
484 arrays which are known not be empty (usually because they always
485 have a sentinel at the end). If LENGTHP is not NULL, the array
486 length is written to *LENGTHP. *LIST is re-initialized and can be
487 reused. */
488__attribute_maybe_unused__ __attribute_warn_unused_result__
489__attribute_nonnull__ ((1))
490static DYNARRAY_ELEMENT *
491DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
492{
493 struct dynarray_finalize_result res;
494 if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
495 DYNARRAY_SCRATCH (list),
496 sizeof (DYNARRAY_ELEMENT), &res))
497 {
498 /* On success, the result owns all the data. */
499 DYNARRAY_NAME (init) (list);
500 if (lengthp != NULL)
501 *lengthp = res.length;
502 return res.array;
503 }
504 else
505 {
506 /* On error, we need to free all data. */
507 DYNARRAY_FREE (list);
508 errno = ENOMEM;
509 return NULL;
510 }
511}
512#endif /* !DYNARRAY_FINAL_TYPE */
513
514/* Undo macro definitions. */
515
516#undef DYNARRAY_CONCAT0
517#undef DYNARRAY_CONCAT1
518#undef DYNARRAY_NAME
519#undef DYNARRAY_SCRATCH
520#undef DYNARRAY_HAVE_SCRATCH
521
522#undef DYNARRAY_STRUCT
523#undef DYNARRAY_ELEMENT
524#undef DYNARRAY_PREFIX
525#undef DYNARRAY_ELEMENT_FREE
526#undef DYNARRAY_ELEMENT_INIT
527#undef DYNARRAY_INITIAL_SIZE
528#undef DYNARRAY_FINAL_TYPE
diff --git a/gl/malloc/dynarray.h b/gl/malloc/dynarray.h
new file mode 100644
index 00000000..a9a3b085
--- /dev/null
+++ b/gl/malloc/dynarray.h
@@ -0,0 +1,177 @@
1/* Type-safe arrays which grow dynamically. Shared definitions.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* To use the dynarray facility, you need to include
20 <malloc/dynarray-skeleton.c> and define the parameter macros
21 documented in that file.
22
23 A minimal example which provides a growing list of integers can be
24 defined like this:
25
26 struct int_array
27 {
28 // Pointer to result array followed by its length,
29 // as required by DYNARRAY_FINAL_TYPE.
30 int *array;
31 size_t length;
32 };
33
34 #define DYNARRAY_STRUCT dynarray_int
35 #define DYNARRAY_ELEMENT int
36 #define DYNARRAY_PREFIX dynarray_int_
37 #define DYNARRAY_FINAL_TYPE struct int_array
38 #include <malloc/dynarray-skeleton.c>
39
40 To create a three-element array with elements 1, 2, 3, use this
41 code:
42
43 struct dynarray_int dyn;
44 dynarray_int_init (&dyn);
45 for (int i = 1; i <= 3; ++i)
46 {
47 int *place = dynarray_int_emplace (&dyn);
48 assert (place != NULL);
49 *place = i;
50 }
51 struct int_array result;
52 bool ok = dynarray_int_finalize (&dyn, &result);
53 assert (ok);
54 assert (result.length == 3);
55 assert (result.array[0] == 1);
56 assert (result.array[1] == 2);
57 assert (result.array[2] == 3);
58 free (result.array);
59
60 If the elements contain resources which must be freed, define
61 DYNARRAY_ELEMENT_FREE appropriately, like this:
62
63 struct str_array
64 {
65 char **array;
66 size_t length;
67 };
68
69 #define DYNARRAY_STRUCT dynarray_str
70 #define DYNARRAY_ELEMENT char *
71 #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
72 #define DYNARRAY_PREFIX dynarray_str_
73 #define DYNARRAY_FINAL_TYPE struct str_array
74 #include <malloc/dynarray-skeleton.c>
75
76 Compared to scratch buffers, dynamic arrays have the following
77 features:
78
79 - They have an element type, and are not just an untyped buffer of
80 bytes.
81
82 - When growing, previously stored elements are preserved. (It is
83 expected that scratch_buffer_grow_preserve and
84 scratch_buffer_set_array_size eventually go away because all
85 current users are moved to dynamic arrays.)
86
87 - Scratch buffers have a more aggressive growth policy because
88 growing them typically means a retry of an operation (across an
89 NSS service module boundary), which is expensive.
90
91 - For the same reason, scratch buffers have a much larger initial
92 stack allocation. */
93
94#ifndef _DYNARRAY_H
95#define _DYNARRAY_H
96
97#include <stddef.h>
98#include <string.h>
99
100struct dynarray_header
101{
102 size_t used;
103 size_t allocated;
104 void *array;
105};
106
107/* Marker used in the allocated member to indicate that an error was
108 encountered. */
109static inline size_t
110__dynarray_error_marker (void)
111{
112 return -1;
113}
114
115/* Internal function. See the has_failed function in
116 dynarray-skeleton.c. */
117static inline bool
118__dynarray_error (struct dynarray_header *list)
119{
120 return list->allocated == __dynarray_error_marker ();
121}
122
123/* Internal function. Enlarge the dynamically allocated area of the
124 array to make room for one more element. SCRATCH is a pointer to
125 the scratch area (which is not heap-allocated and must not be
126 freed). ELEMENT_SIZE is the size, in bytes, of one element.
127 Return false on failure, true on success. */
128bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
129 void *scratch, size_t element_size);
130
131/* Internal function. Enlarge the dynamically allocated area of the
132 array to make room for at least SIZE elements (which must be larger
133 than the existing used part of the dynamic array). SCRATCH is a
134 pointer to the scratch area (which is not heap-allocated and must
135 not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
136 Return false on failure, true on success. */
137bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
138 void *scratch, size_t element_size);
139
140/* Internal function. Like __libc_dynarray_resize, but clear the new
141 part of the dynamic array. */
142bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
143 void *scratch, size_t element_size);
144
145/* Internal type. */
146struct dynarray_finalize_result
147{
148 void *array;
149 size_t length;
150};
151
152/* Internal function. Copy the dynamically-allocated area to an
153 explicitly-sized heap allocation. SCRATCH is a pointer to the
154 embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
155 element type. On success, true is returned, and pointer and length
156 are written to *RESULT. On failure, false is returned. The caller
157 has to take care of some of the memory management; this function is
158 expected to be called from dynarray-skeleton.c. */
159bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
160 size_t element_size,
161 struct dynarray_finalize_result *result);
162
163
164/* Internal function. Terminate the process after an index error.
165 SIZE is the number of elements of the dynamic array. INDEX is the
166 lookup index which triggered the failure. */
167_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
168
169#ifndef _ISOMAC
170libc_hidden_proto (__libc_dynarray_emplace_enlarge)
171libc_hidden_proto (__libc_dynarray_resize)
172libc_hidden_proto (__libc_dynarray_resize_clear)
173libc_hidden_proto (__libc_dynarray_finalize)
174libc_hidden_proto (__libc_dynarray_at_failure)
175#endif
176
177#endif /* _DYNARRAY_H */
diff --git a/gl/malloc/dynarray_at_failure.c b/gl/malloc/dynarray_at_failure.c
new file mode 100644
index 00000000..ebc93109
--- /dev/null
+++ b/gl/malloc/dynarray_at_failure.c
@@ -0,0 +1,40 @@
1/* Report an dynamic array index out of bounds condition.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21# include <stdlib.h>
22#endif
23
24#include <dynarray.h>
25#include <stdio.h>
26
27void
28__libc_dynarray_at_failure (size_t size, size_t index)
29{
30#ifdef _LIBC
31 char buf[200];
32 __snprintf (buf, sizeof (buf), "Fatal glibc error: "
33 "array index %zu not less than array length %zu\n",
34 index, size);
35 __libc_fatal (buf);
36#else
37 abort ();
38#endif
39}
40libc_hidden_def (__libc_dynarray_at_failure)
diff --git a/gl/malloc/dynarray_emplace_enlarge.c b/gl/malloc/dynarray_emplace_enlarge.c
new file mode 100644
index 00000000..7da53931
--- /dev/null
+++ b/gl/malloc/dynarray_emplace_enlarge.c
@@ -0,0 +1,77 @@
1/* Increase the size of a dynamic array in preparation of an emplace operation.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <errno.h>
25#include <intprops.h>
26#include <stdlib.h>
27#include <string.h>
28
29bool
30__libc_dynarray_emplace_enlarge (struct dynarray_header *list,
31 void *scratch, size_t element_size)
32{
33 size_t new_allocated;
34 if (list->allocated == 0)
35 {
36 /* No scratch buffer provided. Choose a reasonable default
37 size. */
38 if (element_size < 4)
39 new_allocated = 16;
40 else if (element_size < 8)
41 new_allocated = 8;
42 else
43 new_allocated = 4;
44 }
45 else
46 /* Increase the allocated size, using an exponential growth
47 policy. */
48 {
49 new_allocated = list->allocated + list->allocated / 2 + 1;
50 if (new_allocated <= list->allocated)
51 {
52 /* Overflow. */
53 __set_errno (ENOMEM);
54 return false;
55 }
56 }
57
58 size_t new_size;
59 if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size))
60 return false;
61 void *new_array;
62 if (list->array == scratch)
63 {
64 /* The previous array was not heap-allocated. */
65 new_array = malloc (new_size);
66 if (new_array != NULL && list->array != NULL)
67 memcpy (new_array, list->array, list->used * element_size);
68 }
69 else
70 new_array = realloc (list->array, new_size);
71 if (new_array == NULL)
72 return false;
73 list->array = new_array;
74 list->allocated = new_allocated;
75 return true;
76}
77libc_hidden_def (__libc_dynarray_emplace_enlarge)
diff --git a/gl/malloc/dynarray_finalize.c b/gl/malloc/dynarray_finalize.c
new file mode 100644
index 00000000..673595a5
--- /dev/null
+++ b/gl/malloc/dynarray_finalize.c
@@ -0,0 +1,66 @@
1/* Copy the dynamically-allocated area to an explicitly-sized heap allocation.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <stdlib.h>
25#include <string.h>
26
27bool
28__libc_dynarray_finalize (struct dynarray_header *list,
29 void *scratch, size_t element_size,
30 struct dynarray_finalize_result *result)
31{
32 if (__dynarray_error (list))
33 /* The caller will reported the deferred error. */
34 return false;
35
36 size_t used = list->used;
37
38 /* Empty list. */
39 if (used == 0)
40 {
41 /* An empty list could still be backed by a heap-allocated
42 array. Free it if necessary. */
43 if (list->array != scratch)
44 free (list->array);
45 *result = (struct dynarray_finalize_result) { NULL, 0 };
46 return true;
47 }
48
49 size_t allocation_size = used * element_size;
50 void *heap_array = malloc (allocation_size);
51 if (heap_array != NULL)
52 {
53 /* The new array takes ownership of the strings. */
54 if (list->array != NULL)
55 memcpy (heap_array, list->array, allocation_size);
56 if (list->array != scratch)
57 free (list->array);
58 *result = (struct dynarray_finalize_result)
59 { .array = heap_array, .length = used };
60 return true;
61 }
62 else
63 /* The caller will perform the freeing operation. */
64 return false;
65}
66libc_hidden_def (__libc_dynarray_finalize)
diff --git a/gl/malloc/dynarray_resize.c b/gl/malloc/dynarray_resize.c
new file mode 100644
index 00000000..7ecd4de6
--- /dev/null
+++ b/gl/malloc/dynarray_resize.c
@@ -0,0 +1,68 @@
1/* Increase the size of a dynamic array.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <errno.h>
25#include <intprops.h>
26#include <stdlib.h>
27#include <string.h>
28
29bool
30__libc_dynarray_resize (struct dynarray_header *list, size_t size,
31 void *scratch, size_t element_size)
32{
33 /* The existing allocation provides sufficient room. */
34 if (size <= list->allocated)
35 {
36 list->used = size;
37 return true;
38 }
39
40 /* Otherwise, use size as the new allocation size. The caller is
41 expected to provide the final size of the array, so there is no
42 over-allocation here. */
43
44 size_t new_size_bytes;
45 if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes))
46 {
47 /* Overflow. */
48 __set_errno (ENOMEM);
49 return false;
50 }
51 void *new_array;
52 if (list->array == scratch)
53 {
54 /* The previous array was not heap-allocated. */
55 new_array = malloc (new_size_bytes);
56 if (new_array != NULL && list->array != NULL)
57 memcpy (new_array, list->array, list->used * element_size);
58 }
59 else
60 new_array = realloc (list->array, new_size_bytes);
61 if (new_array == NULL)
62 return false;
63 list->array = new_array;
64 list->allocated = size;
65 list->used = size;
66 return true;
67}
68libc_hidden_def (__libc_dynarray_resize)
diff --git a/gl/malloc/dynarray_resize_clear.c b/gl/malloc/dynarray_resize_clear.c
new file mode 100644
index 00000000..bb23c522
--- /dev/null
+++ b/gl/malloc/dynarray_resize_clear.c
@@ -0,0 +1,39 @@
1/* Increase the size of a dynamic array and clear the new part.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <string.h>
25
26bool
27__libc_dynarray_resize_clear (struct dynarray_header *list, size_t size,
28 void *scratch, size_t element_size)
29{
30 size_t old_size = list->used;
31 if (!__libc_dynarray_resize (list, size, scratch, element_size))
32 return false;
33 /* __libc_dynarray_resize already checked for overflow. */
34 char *array = list->array;
35 memset (array + (old_size * element_size), 0,
36 (size - old_size) * element_size);
37 return true;
38}
39libc_hidden_def (__libc_dynarray_resize_clear)
diff --git a/gl/malloca.c b/gl/malloca.c
index 311be569..f055b1e5 100644
--- a/gl/malloca.c
+++ b/gl/malloca.c
@@ -1,19 +1,19 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2003, 2006-2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#define _GL_USE_STDLIB_ALLOC 1 18#define _GL_USE_STDLIB_ALLOC 1
19#include <config.h> 19#include <config.h>
@@ -21,82 +21,56 @@
21/* Specification. */ 21/* Specification. */
22#include "malloca.h" 22#include "malloca.h"
23 23
24#include <stdint.h> 24#include <stdckdint.h>
25 25
26#include "verify.h" 26#include "idx.h"
27 27
28/* The speed critical point in this file is freea() applied to an alloca() 28/* The speed critical point in this file is freea() applied to an alloca()
29 result: it must be fast, to match the speed of alloca(). The speed of 29 result: it must be fast, to match the speed of alloca(). The speed of
30 mmalloca() and freea() in the other case are not critical, because they 30 mmalloca() and freea() in the other case are not critical, because they
31 are only invoked for big memory sizes. */ 31 are only invoked for big memory sizes.
32 32 Here we use a bit in the address as an indicator, an idea by Ondřej Bílka.
33#if HAVE_ALLOCA 33 malloca() can return three types of pointers:
34 34 - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation.
35/* Store the mmalloca() results in a hash table. This is needed to reliably 35 - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap
36 distinguish a mmalloca() result and an alloca() result. 36 allocation.
37 37 - NULL comes from a failed heap allocation. */
38 Although it is possible that the same pointer is returned by alloca() and 38
39 by mmalloca() at different times in the same application, it does not lead 39/* Type for holding very small pointer differences. */
40 to a bug in freea(), because: 40typedef unsigned char small_t;
41 - Before a pointer returned by alloca() can point into malloc()ed memory, 41/* Verify that it is wide enough. */
42 the function must return, and once this has happened the programmer must 42static_assert (2 * sa_alignment_max - 1 <= (small_t) -1);
43 not call freea() on it anyway.
44 - Before a pointer returned by mmalloca() can point into the stack, it
45 must be freed. The only function that can free it is freea(), and
46 when freea() frees it, it also removes it from the hash table. */
47
48#define MAGIC_NUMBER 0x1415fb4a
49#define MAGIC_SIZE sizeof (int)
50/* This is how the header info would look like without any alignment
51 considerations. */
52struct preliminary_header { void *next; int magic; };
53/* But the header's size must be a multiple of sa_alignment_max. */
54#define HEADER_SIZE \
55 (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max)
56union header {
57 void *next;
58 struct {
59 char room[HEADER_SIZE - MAGIC_SIZE];
60 int word;
61 } magic;
62};
63verify (HEADER_SIZE == sizeof (union header));
64/* We make the hash table quite big, so that during lookups the probability
65 of empty hash buckets is quite high. There is no need to make the hash
66 table resizable, because when the hash table gets filled so much that the
67 lookup becomes slow, it means that the application has memory leaks. */
68#define HASH_TABLE_SIZE 257
69static void * mmalloca_results[HASH_TABLE_SIZE];
70
71#endif
72 43
73void * 44void *
74mmalloca (size_t n) 45mmalloca (size_t n)
75{ 46{
76#if HAVE_ALLOCA 47#if HAVE_ALLOCA
77 /* Allocate one more word, that serves as an indicator for malloc()ed 48 /* Allocate one more word, used to determine the address to pass to freea(),
78 memory, so that freea() of an alloca() result is fast. */ 49 and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */
79 size_t nplus = n + HEADER_SIZE; 50 uintptr_t alignment2_mask = 2 * sa_alignment_max - 1;
80 51 int plus = sizeof (small_t) + alignment2_mask;
81 if (nplus >= n) 52 idx_t nplus;
53 if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))
82 { 54 {
83 void *p = malloc (nplus); 55 char *mem = (char *) malloc (nplus);
84 56
85 if (p != NULL) 57 if (mem != NULL)
86 { 58 {
87 size_t slot; 59 uintptr_t umem = (uintptr_t)mem, umemplus;
88 union header *h = p; 60 /* The ckd_add avoids signed integer overflow on
89 61 theoretical platforms where UINTPTR_MAX <= INT_MAX. */
90 p = h + 1; 62 ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
91 63 idx_t offset = ((umemplus & ~alignment2_mask)
92 /* Put a magic number into the indicator word. */ 64 + sa_alignment_max - umem);
93 h->magic.word = MAGIC_NUMBER; 65 void *vp = mem + offset;
94 66 small_t *p = vp;
95 /* Enter p into the hash table. */ 67 /* Here p >= mem + sizeof (small_t),
96 slot = (uintptr_t) p % HASH_TABLE_SIZE; 68 and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
97 h->next = mmalloca_results[slot]; 69 hence p + n <= mem + nplus.
98 mmalloca_results[slot] = p; 70 So, the memory range [p, p+n) lies in the allocated memory range
99 71 [mem, mem + nplus). */
72 p[-1] = offset;
73 /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
100 return p; 74 return p;
101 } 75 }
102 } 76 }
@@ -115,35 +89,24 @@ mmalloca (size_t n)
115void 89void
116freea (void *p) 90freea (void *p)
117{ 91{
118 /* mmalloca() may have returned NULL. */ 92 /* Check argument. */
119 if (p != NULL) 93 if ((uintptr_t) p & (sa_alignment_max - 1))
120 { 94 {
121 /* Attempt to quickly distinguish the mmalloca() result - which has 95 /* p was not the result of a malloca() call. Invalid argument. */
122 a magic indicator word - and the alloca() result - which has an 96 abort ();
123 uninitialized indicator word. It is for this test that sa_increment 97 }
124 additional bytes are allocated in the alloca() case. */ 98 /* Determine whether p was a non-NULL pointer returned by mmalloca(). */
125 if (((int *) p)[-1] == MAGIC_NUMBER) 99 if ((uintptr_t) p & sa_alignment_max)
126 { 100 {
127 /* Looks like a mmalloca() result. To see whether it really is one, 101 void *mem = (char *) p - ((small_t *) p)[-1];
128 perform a lookup in the hash table. */ 102 free (mem);
129 size_t slot = (uintptr_t) p % HASH_TABLE_SIZE;
130 void **chain = &mmalloca_results[slot];
131 for (; *chain != NULL;)
132 {
133 union header *h = p;
134 if (*chain == p)
135 {
136 /* Found it. Remove it from the hash table and free it. */
137 union header *p_begin = h - 1;
138 *chain = p_begin->next;
139 free (p_begin);
140 return;
141 }
142 h = *chain;
143 chain = &h[-1].next;
144 }
145 }
146 /* At this point, we know it was not a mmalloca() result. */
147 } 103 }
148} 104}
149#endif 105#endif
106
107/*
108 * Hey Emacs!
109 * Local Variables:
110 * coding: utf-8
111 * End:
112 */
diff --git a/gl/malloca.h b/gl/malloca.h
index 6fbe45ea..325c7277 100644
--- a/gl/malloca.h
+++ b/gl/malloca.h
@@ -1,19 +1,19 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2003-2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _MALLOCA_H 18#ifndef _MALLOCA_H
19#define _MALLOCA_H 19#define _MALLOCA_H
@@ -21,6 +21,9 @@
21#include <alloca.h> 21#include <alloca.h>
22#include <stddef.h> 22#include <stddef.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <stdint.h>
25
26#include "xalloc-oversized.h"
24 27
25 28
26#ifdef __cplusplus 29#ifdef __cplusplus
@@ -48,40 +51,37 @@ extern "C" {
48# define safe_alloca(N) ((void) (N), NULL) 51# define safe_alloca(N) ((void) (N), NULL)
49#endif 52#endif
50 53
54/* Free a block of memory allocated through malloca(). */
55#if HAVE_ALLOCA
56extern void freea (void *p);
57#else
58# define freea free
59#endif
60
51/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of 61/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of
52 memory allocated on the stack, that must be freed using freea() before 62 memory allocated on the stack, that must be freed using freea() before
53 the function returns. Upon failure, it returns NULL. */ 63 the function returns. Upon failure, it returns NULL. */
54#if HAVE_ALLOCA 64#if HAVE_ALLOCA
55# define malloca(N) \ 65# define malloca(N) \
56 ((N) < 4032 - sa_increment \ 66 ((N) < 4032 - (2 * sa_alignment_max - 1) \
57 ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ 67 ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
68 + (2 * sa_alignment_max - 1)) \
69 & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
58 : mmalloca (N)) 70 : mmalloca (N))
59#else 71#else
60# define malloca(N) \ 72# define malloca(N) \
61 mmalloca (N) 73 mmalloca (N)
62#endif 74#endif
63extern void * mmalloca (size_t n); 75extern void *mmalloca (size_t n)
64 76 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (freea, 1)
65/* Free a block of memory allocated through malloca(). */ 77 _GL_ATTRIBUTE_ALLOC_SIZE ((1));
66#if HAVE_ALLOCA
67extern void freea (void *p);
68#else
69# define freea free
70#endif
71 78
72/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). 79/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
73 It allocates an array of N objects, each with S bytes of memory, 80 It allocates an array of N objects, each with S bytes of memory,
74 on the stack. S must be positive and N must be nonnegative. 81 on the stack. N and S should be nonnegative and free of side effects.
75 The array must be freed using freea() before the function returns. */ 82 The array must be freed using freea() before the function returns. */
76#if 1 83#define nmalloca(n, s) \
77/* Cf. the definition of xalloc_oversized. */ 84 (xalloc_oversized (n, s) ? NULL : malloca ((n) * (size_t) (s)))
78# define nmalloca(n, s) \
79 ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
80 ? NULL \
81 : malloca ((n) * (s)))
82#else
83extern void * nmalloca (size_t n, size_t s);
84#endif
85 85
86 86
87#ifdef __cplusplus 87#ifdef __cplusplus
@@ -92,7 +92,7 @@ extern void * nmalloca (size_t n, size_t s);
92/* ------------------- Auxiliary, non-public definitions ------------------- */ 92/* ------------------- Auxiliary, non-public definitions ------------------- */
93 93
94/* Determine the alignment of a type at compile time. */ 94/* Determine the alignment of a type at compile time. */
95#if defined __GNUC__ || defined __IBM__ALIGNOF__ 95#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
96# define sa_alignof __alignof__ 96# define sa_alignof __alignof__
97#elif defined __cplusplus 97#elif defined __cplusplus
98 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; }; 98 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
@@ -115,19 +115,12 @@ enum
115 among all elementary types. */ 115 among all elementary types. */
116 sa_alignment_long = sa_alignof (long), 116 sa_alignment_long = sa_alignof (long),
117 sa_alignment_double = sa_alignof (double), 117 sa_alignment_double = sa_alignof (double),
118#if HAVE_LONG_LONG_INT
119 sa_alignment_longlong = sa_alignof (long long), 118 sa_alignment_longlong = sa_alignof (long long),
120#endif
121 sa_alignment_longdouble = sa_alignof (long double), 119 sa_alignment_longdouble = sa_alignof (long double),
122 sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) 120 sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
123#if HAVE_LONG_LONG_INT
124 | (sa_alignment_longlong - 1) 121 | (sa_alignment_longlong - 1)
125#endif
126 | (sa_alignment_longdouble - 1) 122 | (sa_alignment_longdouble - 1)
127 ) + 1, 123 ) + 1
128/* The increment that guarantees room for a magic word must be >= sizeof (int)
129 and a multiple of sa_alignment_max. */
130 sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max
131}; 124};
132 125
133#endif /* _MALLOCA_H */ 126#endif /* _MALLOCA_H */
diff --git a/gl/malloca.valgrind b/gl/malloca.valgrind
deleted file mode 100644
index 52f0a50f..00000000
--- a/gl/malloca.valgrind
+++ /dev/null
@@ -1,7 +0,0 @@
1# Suppress a valgrind message about use of uninitialized memory in freea().
2# This use is OK because it provides only a speedup.
3{
4 freea
5 Memcheck:Cond
6 fun:freea
7}
diff --git a/gl/math.c b/gl/math.c
index ddb2ded5..67cabbcf 100644
--- a/gl/math.c
+++ b/gl/math.c
@@ -1,3 +1,22 @@
1/* Inline functions for <math.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define _GL_MATH_INLINE _GL_EXTERN_INLINE 20#define _GL_MATH_INLINE _GL_EXTERN_INLINE
3#include "math.h" 21#include "math.h"
22typedef int dummy;
diff --git a/gl/math.in.h b/gl/math.in.h
index 7189819b..f3d58afc 100644
--- a/gl/math.in.h
+++ b/gl/math.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <math.h>. 1/* A GNU-like <math.h>.
2 2
3 Copyright (C) 2002-2003, 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_MATH_H 18#ifndef _@GUARD_PREFIX@_MATH_H
19 19
@@ -22,17 +22,50 @@
22#endif 22#endif
23@PRAGMA_COLUMNS@ 23@PRAGMA_COLUMNS@
24 24
25#if defined _GL_INCLUDING_MATH_H
26/* Special invocation convention:
27 - On FreeBSD 12.2 we have a sequence of nested includes
28 <math.h> -> <stdlib.h> -> <sys/wait.h> -> <sys/types.h> -> <sys/select.h>
29 -> <signal.h> -> <pthread.h> -> <stdlib.h> -> <math.h>
30 In this situation, the functions are not yet declared, therefore we cannot
31 provide the C++ aliases. */
32
33#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
34
35#else
36/* Normal invocation convention. */
37
25/* The include_next requires a split double-inclusion guard. */ 38/* The include_next requires a split double-inclusion guard. */
39#define _GL_INCLUDING_MATH_H
26#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ 40#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
41#undef _GL_INCLUDING_MATH_H
27 42
28#ifndef _@GUARD_PREFIX@_MATH_H 43#ifndef _@GUARD_PREFIX@_MATH_H
29#define _@GUARD_PREFIX@_MATH_H 44#define _@GUARD_PREFIX@_MATH_H
30 45
46/* On OpenVMS, NAN, INFINITY, and HUGEVAL macros are defined in <fp.h>. */
47#if defined __VMS && ! defined NAN
48# include <fp.h>
49#endif
50
51#ifndef _GL_INLINE_HEADER_BEGIN
52 #error "Please include config.h first."
53#endif
31_GL_INLINE_HEADER_BEGIN 54_GL_INLINE_HEADER_BEGIN
32#ifndef _GL_MATH_INLINE 55#ifndef _GL_MATH_INLINE
33# define _GL_MATH_INLINE _GL_INLINE 56# define _GL_MATH_INLINE _GL_INLINE
34#endif 57#endif
35 58
59/* The __attribute__ feature is available in gcc versions 2.5 and later.
60 The attribute __const__ was added in gcc 2.95. */
61#ifndef _GL_ATTRIBUTE_CONST
62# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__
63# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
64# else
65# define _GL_ATTRIBUTE_CONST /* empty */
66# endif
67#endif
68
36/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 69/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
37 70
38/* The definition of _GL_ARG_NONNULL is copied here. */ 71/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -59,22 +92,24 @@ _gl_cxx_ ## func ## l (long double l) \
59{ \ 92{ \
60 return func (l); \ 93 return func (l); \
61} 94}
62# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \ 95# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func,rpl_func,rettype) \
63inline int \ 96_GL_BEGIN_NAMESPACE \
64func (float f) \ 97inline rettype \
98rpl_func (float f) \
65{ \ 99{ \
66 return _gl_cxx_ ## func ## f (f); \ 100 return _gl_cxx_ ## func ## f (f); \
67} \ 101} \
68inline int \ 102inline rettype \
69func (double d) \ 103rpl_func (double d) \
70{ \ 104{ \
71 return _gl_cxx_ ## func ## d (d); \ 105 return _gl_cxx_ ## func ## d (d); \
72} \ 106} \
73inline int \ 107inline rettype \
74func (long double l) \ 108rpl_func (long double l) \
75{ \ 109{ \
76 return _gl_cxx_ ## func ## l (l); \ 110 return _gl_cxx_ ## func ## l (l); \
77} 111} \
112_GL_END_NAMESPACE
78#endif 113#endif
79 114
80/* Helper macros to define a portability warning for the 115/* Helper macros to define a portability warning for the
@@ -82,27 +117,27 @@ func (long double l) \
82 classification macros with an argument of real-floating (that is, 117 classification macros with an argument of real-floating (that is,
83 one of float, double, or long double). */ 118 one of float, double, or long double). */
84#define _GL_WARN_REAL_FLOATING_DECL(func) \ 119#define _GL_WARN_REAL_FLOATING_DECL(func) \
85_GL_MATH_INLINE int \ 120_GL_MATH_INLINE int \
86rpl_ ## func ## f (float f) \ 121_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \
87{ \ 122 "use gnulib module " #func " for portability") \
88 return func (f); \ 123rpl_ ## func ## f (float f) \
89} \ 124{ \
90_GL_MATH_INLINE int \ 125 return func (f); \
91rpl_ ## func ## d (double d) \ 126} \
92{ \ 127_GL_MATH_INLINE int \
93 return func (d); \ 128_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \
94} \ 129 "use gnulib module " #func " for portability") \
95_GL_MATH_INLINE int \ 130rpl_ ## func ## d (double d) \
96rpl_ ## func ## l (long double l) \ 131{ \
97{ \ 132 return func (d); \
98 return func (l); \ 133} \
99} \ 134_GL_MATH_INLINE int \
100_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \ 135_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \
101 "use gnulib module " #func " for portability"); \ 136 "use gnulib module " #func " for portability") \
102_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \ 137rpl_ ## func ## l (long double l) \
103 "use gnulib module " #func " for portability"); \ 138{ \
104_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \ 139 return func (l); \
105 "use gnulib module " #func " for portability") 140}
106#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \ 141#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
107 (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \ 142 (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \
108 : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \ 143 : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \
@@ -184,8 +219,17 @@ _NaN ()
184#endif 219#endif
185 220
186 221
187/* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */ 222#if defined FP_ILOGB0 && defined FP_ILOGBNAN
188#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN) 223 /* Ensure FP_ILOGB0 and FP_ILOGBNAN are correct. */
224# if defined __HAIKU__
225 /* Haiku: match what ilogb() does */
226# undef FP_ILOGB0
227# undef FP_ILOGBNAN
228# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
229# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
230# endif
231#else
232 /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
189# if defined __NetBSD__ || defined __sgi 233# if defined __NetBSD__ || defined __sgi
190 /* NetBSD, IRIX 6.5: match what ilogb() does */ 234 /* NetBSD, IRIX 6.5: match what ilogb() does */
191# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ 235# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
@@ -207,11 +251,20 @@ _NaN ()
207 251
208 252
209#if @GNULIB_ACOSF@ 253#if @GNULIB_ACOSF@
210# if !@HAVE_ACOSF@ 254# if @REPLACE_ACOSF@
211# undef acosf 255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
256# undef acosf
257# define acosf rpl_acosf
258# endif
259_GL_FUNCDECL_RPL (acosf, float, (float x));
260_GL_CXXALIAS_RPL (acosf, float, (float x));
261# else
262# if !@HAVE_ACOSF@
263# undef acosf
212_GL_FUNCDECL_SYS (acosf, float, (float x)); 264_GL_FUNCDECL_SYS (acosf, float, (float x));
213# endif 265# endif
214_GL_CXXALIAS_SYS (acosf, float, (float x)); 266_GL_CXXALIAS_SYS (acosf, float, (float x));
267# endif
215_GL_CXXALIASWARN (acosf); 268_GL_CXXALIASWARN (acosf);
216#elif defined GNULIB_POSIXCHECK 269#elif defined GNULIB_POSIXCHECK
217# undef acosf 270# undef acosf
@@ -227,7 +280,9 @@ _GL_WARN_ON_USE (acosf, "acosf is unportable - "
227_GL_FUNCDECL_SYS (acosl, long double, (long double x)); 280_GL_FUNCDECL_SYS (acosl, long double, (long double x));
228# endif 281# endif
229_GL_CXXALIAS_SYS (acosl, long double, (long double x)); 282_GL_CXXALIAS_SYS (acosl, long double, (long double x));
283# if __GLIBC__ >= 2
230_GL_CXXALIASWARN (acosl); 284_GL_CXXALIASWARN (acosl);
285# endif
231#elif defined GNULIB_POSIXCHECK 286#elif defined GNULIB_POSIXCHECK
232# undef acosl 287# undef acosl
233# if HAVE_RAW_DECL_ACOSL 288# if HAVE_RAW_DECL_ACOSL
@@ -238,11 +293,20 @@ _GL_WARN_ON_USE (acosl, "acosl is unportable - "
238 293
239 294
240#if @GNULIB_ASINF@ 295#if @GNULIB_ASINF@
241# if !@HAVE_ASINF@ 296# if @REPLACE_ASINF@
242# undef asinf 297# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
298# undef asinf
299# define asinf rpl_asinf
300# endif
301_GL_FUNCDECL_RPL (asinf, float, (float x));
302_GL_CXXALIAS_RPL (asinf, float, (float x));
303# else
304# if !@HAVE_ASINF@
305# undef asinf
243_GL_FUNCDECL_SYS (asinf, float, (float x)); 306_GL_FUNCDECL_SYS (asinf, float, (float x));
244# endif 307# endif
245_GL_CXXALIAS_SYS (asinf, float, (float x)); 308_GL_CXXALIAS_SYS (asinf, float, (float x));
309# endif
246_GL_CXXALIASWARN (asinf); 310_GL_CXXALIASWARN (asinf);
247#elif defined GNULIB_POSIXCHECK 311#elif defined GNULIB_POSIXCHECK
248# undef asinf 312# undef asinf
@@ -258,7 +322,9 @@ _GL_WARN_ON_USE (asinf, "asinf is unportable - "
258_GL_FUNCDECL_SYS (asinl, long double, (long double x)); 322_GL_FUNCDECL_SYS (asinl, long double, (long double x));
259# endif 323# endif
260_GL_CXXALIAS_SYS (asinl, long double, (long double x)); 324_GL_CXXALIAS_SYS (asinl, long double, (long double x));
325# if __GLIBC__ >= 2
261_GL_CXXALIASWARN (asinl); 326_GL_CXXALIASWARN (asinl);
327# endif
262#elif defined GNULIB_POSIXCHECK 328#elif defined GNULIB_POSIXCHECK
263# undef asinl 329# undef asinl
264# if HAVE_RAW_DECL_ASINL 330# if HAVE_RAW_DECL_ASINL
@@ -269,11 +335,20 @@ _GL_WARN_ON_USE (asinl, "asinl is unportable - "
269 335
270 336
271#if @GNULIB_ATANF@ 337#if @GNULIB_ATANF@
272# if !@HAVE_ATANF@ 338# if @REPLACE_ATANF@
273# undef atanf 339# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340# undef atanf
341# define atanf rpl_atanf
342# endif
343_GL_FUNCDECL_RPL (atanf, float, (float x));
344_GL_CXXALIAS_RPL (atanf, float, (float x));
345# else
346# if !@HAVE_ATANF@
347# undef atanf
274_GL_FUNCDECL_SYS (atanf, float, (float x)); 348_GL_FUNCDECL_SYS (atanf, float, (float x));
275# endif 349# endif
276_GL_CXXALIAS_SYS (atanf, float, (float x)); 350_GL_CXXALIAS_SYS (atanf, float, (float x));
351# endif
277_GL_CXXALIASWARN (atanf); 352_GL_CXXALIASWARN (atanf);
278#elif defined GNULIB_POSIXCHECK 353#elif defined GNULIB_POSIXCHECK
279# undef atanf 354# undef atanf
@@ -289,7 +364,9 @@ _GL_WARN_ON_USE (atanf, "atanf is unportable - "
289_GL_FUNCDECL_SYS (atanl, long double, (long double x)); 364_GL_FUNCDECL_SYS (atanl, long double, (long double x));
290# endif 365# endif
291_GL_CXXALIAS_SYS (atanl, long double, (long double x)); 366_GL_CXXALIAS_SYS (atanl, long double, (long double x));
367# if __GLIBC__ >= 2
292_GL_CXXALIASWARN (atanl); 368_GL_CXXALIASWARN (atanl);
369# endif
293#elif defined GNULIB_POSIXCHECK 370#elif defined GNULIB_POSIXCHECK
294# undef atanl 371# undef atanl
295# if HAVE_RAW_DECL_ATANL 372# if HAVE_RAW_DECL_ATANL
@@ -300,11 +377,20 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - "
300 377
301 378
302#if @GNULIB_ATAN2F@ 379#if @GNULIB_ATAN2F@
303# if !@HAVE_ATAN2F@ 380# if @REPLACE_ATAN2F@
304# undef atan2f 381# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
382# undef atan2f
383# define atan2f rpl_atan2f
384# endif
385_GL_FUNCDECL_RPL (atan2f, float, (float y, float x));
386_GL_CXXALIAS_RPL (atan2f, float, (float y, float x));
387# else
388# if !@HAVE_ATAN2F@
389# undef atan2f
305_GL_FUNCDECL_SYS (atan2f, float, (float y, float x)); 390_GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
306# endif 391# endif
307_GL_CXXALIAS_SYS (atan2f, float, (float y, float x)); 392_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
393# endif
308_GL_CXXALIASWARN (atan2f); 394_GL_CXXALIASWARN (atan2f);
309#elif defined GNULIB_POSIXCHECK 395#elif defined GNULIB_POSIXCHECK
310# undef atan2f 396# undef atan2f
@@ -343,7 +429,9 @@ _GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - "
343_GL_FUNCDECL_SYS (cbrt, double, (double x)); 429_GL_FUNCDECL_SYS (cbrt, double, (double x));
344# endif 430# endif
345_GL_CXXALIAS_SYS (cbrt, double, (double x)); 431_GL_CXXALIAS_SYS (cbrt, double, (double x));
346_GL_CXXALIASWARN (cbrt); 432# if __GLIBC__ >= 2
433_GL_CXXALIASWARN1 (cbrt, double, (double x));
434# endif
347#elif defined GNULIB_POSIXCHECK 435#elif defined GNULIB_POSIXCHECK
348# undef cbrt 436# undef cbrt
349# if HAVE_RAW_DECL_CBRT 437# if HAVE_RAW_DECL_CBRT
@@ -366,7 +454,9 @@ _GL_FUNCDECL_SYS (cbrtl, long double, (long double x));
366# endif 454# endif
367_GL_CXXALIAS_SYS (cbrtl, long double, (long double x)); 455_GL_CXXALIAS_SYS (cbrtl, long double, (long double x));
368# endif 456# endif
457# if __GLIBC__ >= 2
369_GL_CXXALIASWARN (cbrtl); 458_GL_CXXALIASWARN (cbrtl);
459# endif
370#elif defined GNULIB_POSIXCHECK 460#elif defined GNULIB_POSIXCHECK
371# undef cbrtl 461# undef cbrtl
372# if HAVE_RAW_DECL_CBRTL 462# if HAVE_RAW_DECL_CBRTL
@@ -403,6 +493,7 @@ _GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
403#if @GNULIB_CEIL@ 493#if @GNULIB_CEIL@
404# if @REPLACE_CEIL@ 494# if @REPLACE_CEIL@
405# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 495# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
496# undef ceil
406# define ceil rpl_ceil 497# define ceil rpl_ceil
407# endif 498# endif
408_GL_FUNCDECL_RPL (ceil, double, (double x)); 499_GL_FUNCDECL_RPL (ceil, double, (double x));
@@ -410,7 +501,9 @@ _GL_CXXALIAS_RPL (ceil, double, (double x));
410# else 501# else
411_GL_CXXALIAS_SYS (ceil, double, (double x)); 502_GL_CXXALIAS_SYS (ceil, double, (double x));
412# endif 503# endif
413_GL_CXXALIASWARN (ceil); 504# if __GLIBC__ >= 2
505_GL_CXXALIASWARN1 (ceil, double, (double x));
506# endif
414#endif 507#endif
415 508
416#if @GNULIB_CEILL@ 509#if @GNULIB_CEILL@
@@ -428,7 +521,9 @@ _GL_FUNCDECL_SYS (ceill, long double, (long double x));
428# endif 521# endif
429_GL_CXXALIAS_SYS (ceill, long double, (long double x)); 522_GL_CXXALIAS_SYS (ceill, long double, (long double x));
430# endif 523# endif
524# if __GLIBC__ >= 2
431_GL_CXXALIASWARN (ceill); 525_GL_CXXALIASWARN (ceill);
526# endif
432#elif defined GNULIB_POSIXCHECK 527#elif defined GNULIB_POSIXCHECK
433# undef ceill 528# undef ceill
434# if HAVE_RAW_DECL_CEILL 529# if HAVE_RAW_DECL_CEILL
@@ -440,6 +535,7 @@ _GL_WARN_ON_USE (ceill, "ceill is unportable - "
440 535
441#if @GNULIB_COPYSIGNF@ 536#if @GNULIB_COPYSIGNF@
442# if !@HAVE_DECL_COPYSIGNF@ 537# if !@HAVE_DECL_COPYSIGNF@
538# undef copysignf
443_GL_FUNCDECL_SYS (copysignf, float, (float x, float y)); 539_GL_FUNCDECL_SYS (copysignf, float, (float x, float y));
444# endif 540# endif
445_GL_CXXALIAS_SYS (copysignf, float, (float x, float y)); 541_GL_CXXALIAS_SYS (copysignf, float, (float x, float y));
@@ -457,7 +553,9 @@ _GL_WARN_ON_USE (copysignf, "copysignf is unportable - "
457_GL_FUNCDECL_SYS (copysign, double, (double x, double y)); 553_GL_FUNCDECL_SYS (copysign, double, (double x, double y));
458# endif 554# endif
459_GL_CXXALIAS_SYS (copysign, double, (double x, double y)); 555_GL_CXXALIAS_SYS (copysign, double, (double x, double y));
460_GL_CXXALIASWARN (copysign); 556# if __GLIBC__ >= 2
557_GL_CXXALIASWARN1 (copysign, double, (double x, double y));
558# endif
461#elif defined GNULIB_POSIXCHECK 559#elif defined GNULIB_POSIXCHECK
462# undef copysign 560# undef copysign
463# if HAVE_RAW_DECL_COPYSIGN 561# if HAVE_RAW_DECL_COPYSIGN
@@ -471,7 +569,9 @@ _GL_WARN_ON_USE (copysign, "copysign is unportable - "
471_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y)); 569_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y));
472# endif 570# endif
473_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y)); 571_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y));
572# if __GLIBC__ >= 2
474_GL_CXXALIASWARN (copysignl); 573_GL_CXXALIASWARN (copysignl);
574# endif
475#elif defined GNULIB_POSIXCHECK 575#elif defined GNULIB_POSIXCHECK
476# undef copysignl 576# undef copysignl
477# if HAVE_RAW_DECL_COPYSIGNL 577# if HAVE_RAW_DECL_COPYSIGNL
@@ -482,11 +582,20 @@ _GL_WARN_ON_USE (copysign, "copysignl is unportable - "
482 582
483 583
484#if @GNULIB_COSF@ 584#if @GNULIB_COSF@
485# if !@HAVE_COSF@ 585# if @REPLACE_COSF@
486# undef cosf 586# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
587# undef cosf
588# define cosf rpl_cosf
589# endif
590_GL_FUNCDECL_RPL (cosf, float, (float x));
591_GL_CXXALIAS_RPL (cosf, float, (float x));
592# else
593# if !@HAVE_COSF@
594# undef cosf
487_GL_FUNCDECL_SYS (cosf, float, (float x)); 595_GL_FUNCDECL_SYS (cosf, float, (float x));
488# endif 596# endif
489_GL_CXXALIAS_SYS (cosf, float, (float x)); 597_GL_CXXALIAS_SYS (cosf, float, (float x));
598# endif
490_GL_CXXALIASWARN (cosf); 599_GL_CXXALIASWARN (cosf);
491#elif defined GNULIB_POSIXCHECK 600#elif defined GNULIB_POSIXCHECK
492# undef cosf 601# undef cosf
@@ -502,7 +611,9 @@ _GL_WARN_ON_USE (cosf, "cosf is unportable - "
502_GL_FUNCDECL_SYS (cosl, long double, (long double x)); 611_GL_FUNCDECL_SYS (cosl, long double, (long double x));
503# endif 612# endif
504_GL_CXXALIAS_SYS (cosl, long double, (long double x)); 613_GL_CXXALIAS_SYS (cosl, long double, (long double x));
614# if __GLIBC__ >= 2
505_GL_CXXALIASWARN (cosl); 615_GL_CXXALIASWARN (cosl);
616# endif
506#elif defined GNULIB_POSIXCHECK 617#elif defined GNULIB_POSIXCHECK
507# undef cosl 618# undef cosl
508# if HAVE_RAW_DECL_COSL 619# if HAVE_RAW_DECL_COSL
@@ -513,11 +624,20 @@ _GL_WARN_ON_USE (cosl, "cosl is unportable - "
513 624
514 625
515#if @GNULIB_COSHF@ 626#if @GNULIB_COSHF@
516# if !@HAVE_COSHF@ 627# if @REPLACE_COSHF@
517# undef coshf 628# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
629# undef coshf
630# define coshf rpl_coshf
631# endif
632_GL_FUNCDECL_RPL (coshf, float, (float x));
633_GL_CXXALIAS_RPL (coshf, float, (float x));
634# else
635# if !@HAVE_COSHF@
636# undef coshf
518_GL_FUNCDECL_SYS (coshf, float, (float x)); 637_GL_FUNCDECL_SYS (coshf, float, (float x));
519# endif 638# endif
520_GL_CXXALIAS_SYS (coshf, float, (float x)); 639_GL_CXXALIAS_SYS (coshf, float, (float x));
640# endif
521_GL_CXXALIASWARN (coshf); 641_GL_CXXALIASWARN (coshf);
522#elif defined GNULIB_POSIXCHECK 642#elif defined GNULIB_POSIXCHECK
523# undef coshf 643# undef coshf
@@ -529,11 +649,20 @@ _GL_WARN_ON_USE (coshf, "coshf is unportable - "
529 649
530 650
531#if @GNULIB_EXPF@ 651#if @GNULIB_EXPF@
532# if !@HAVE_EXPF@ 652# if @REPLACE_EXPF@
533# undef expf 653# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
654# undef expf
655# define expf rpl_expf
656# endif
657_GL_FUNCDECL_RPL (expf, float, (float x));
658_GL_CXXALIAS_RPL (expf, float, (float x));
659# else
660# if !@HAVE_EXPF@
661# undef expf
534_GL_FUNCDECL_SYS (expf, float, (float x)); 662_GL_FUNCDECL_SYS (expf, float, (float x));
535# endif 663# endif
536_GL_CXXALIAS_SYS (expf, float, (float x)); 664_GL_CXXALIAS_SYS (expf, float, (float x));
665# endif
537_GL_CXXALIASWARN (expf); 666_GL_CXXALIASWARN (expf);
538#elif defined GNULIB_POSIXCHECK 667#elif defined GNULIB_POSIXCHECK
539# undef expf 668# undef expf
@@ -544,12 +673,23 @@ _GL_WARN_ON_USE (expf, "expf is unportable - "
544#endif 673#endif
545 674
546#if @GNULIB_EXPL@ 675#if @GNULIB_EXPL@
547# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@ 676# if @REPLACE_EXPL@
548# undef expl 677# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
678# undef expl
679# define expl rpl_expl
680# endif
681_GL_FUNCDECL_RPL (expl, long double, (long double x));
682_GL_CXXALIAS_RPL (expl, long double, (long double x));
683# else
684# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
685# undef expl
549_GL_FUNCDECL_SYS (expl, long double, (long double x)); 686_GL_FUNCDECL_SYS (expl, long double, (long double x));
550# endif 687# endif
551_GL_CXXALIAS_SYS (expl, long double, (long double x)); 688_GL_CXXALIAS_SYS (expl, long double, (long double x));
689# endif
690# if __GLIBC__ >= 2
552_GL_CXXALIASWARN (expl); 691_GL_CXXALIASWARN (expl);
692# endif
553#elif defined GNULIB_POSIXCHECK 693#elif defined GNULIB_POSIXCHECK
554# undef expl 694# undef expl
555# if HAVE_RAW_DECL_EXPL 695# if HAVE_RAW_DECL_EXPL
@@ -587,7 +727,9 @@ _GL_FUNCDECL_SYS (exp2, double, (double x));
587# endif 727# endif
588_GL_CXXALIAS_SYS (exp2, double, (double x)); 728_GL_CXXALIAS_SYS (exp2, double, (double x));
589# endif 729# endif
590_GL_CXXALIASWARN (exp2); 730# if __GLIBC__ >= 2
731_GL_CXXALIASWARN1 (exp2, double, (double x));
732# endif
591#elif defined GNULIB_POSIXCHECK 733#elif defined GNULIB_POSIXCHECK
592# undef exp2 734# undef exp2
593# if HAVE_RAW_DECL_EXP2 735# if HAVE_RAW_DECL_EXP2
@@ -611,7 +753,9 @@ _GL_FUNCDECL_SYS (exp2l, long double, (long double x));
611# endif 753# endif
612_GL_CXXALIAS_SYS (exp2l, long double, (long double x)); 754_GL_CXXALIAS_SYS (exp2l, long double, (long double x));
613# endif 755# endif
756# if __GLIBC__ >= 2
614_GL_CXXALIASWARN (exp2l); 757_GL_CXXALIASWARN (exp2l);
758# endif
615#elif defined GNULIB_POSIXCHECK 759#elif defined GNULIB_POSIXCHECK
616# undef exp2l 760# undef exp2l
617# if HAVE_RAW_DECL_EXP2L 761# if HAVE_RAW_DECL_EXP2L
@@ -658,7 +802,9 @@ _GL_FUNCDECL_SYS (expm1, double, (double x));
658# endif 802# endif
659_GL_CXXALIAS_SYS (expm1, double, (double x)); 803_GL_CXXALIAS_SYS (expm1, double, (double x));
660# endif 804# endif
661_GL_CXXALIASWARN (expm1); 805# if __GLIBC__ >= 2
806_GL_CXXALIASWARN1 (expm1, double, (double x));
807# endif
662#elif defined GNULIB_POSIXCHECK 808#elif defined GNULIB_POSIXCHECK
663# undef expm1 809# undef expm1
664# if HAVE_RAW_DECL_EXPM1 810# if HAVE_RAW_DECL_EXPM1
@@ -668,12 +814,25 @@ _GL_WARN_ON_USE (expm1, "expm1 is unportable - "
668#endif 814#endif
669 815
670#if @GNULIB_EXPM1L@ 816#if @GNULIB_EXPM1L@
671# if !@HAVE_DECL_EXPM1L@ 817# if @REPLACE_EXPM1L@
672# undef expm1l 818# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
819# undef expm1l
820# define expm1l rpl_expm1l
821# endif
822_GL_FUNCDECL_RPL (expm1l, long double, (long double x));
823_GL_CXXALIAS_RPL (expm1l, long double, (long double x));
824# else
825# if !@HAVE_DECL_EXPM1L@
826# undef expm1l
827# if !(defined __cplusplus && defined _AIX)
673_GL_FUNCDECL_SYS (expm1l, long double, (long double x)); 828_GL_FUNCDECL_SYS (expm1l, long double, (long double x));
674# endif 829# endif
830# endif
675_GL_CXXALIAS_SYS (expm1l, long double, (long double x)); 831_GL_CXXALIAS_SYS (expm1l, long double, (long double x));
832# endif
833# if __GLIBC__ >= 2
676_GL_CXXALIASWARN (expm1l); 834_GL_CXXALIASWARN (expm1l);
835# endif
677#elif defined GNULIB_POSIXCHECK 836#elif defined GNULIB_POSIXCHECK
678# undef expm1l 837# undef expm1l
679# if HAVE_RAW_DECL_EXPM1L 838# if HAVE_RAW_DECL_EXPM1L
@@ -689,7 +848,9 @@ _GL_WARN_ON_USE (expm1l, "expm1l is unportable - "
689_GL_FUNCDECL_SYS (fabsf, float, (float x)); 848_GL_FUNCDECL_SYS (fabsf, float, (float x));
690# endif 849# endif
691_GL_CXXALIAS_SYS (fabsf, float, (float x)); 850_GL_CXXALIAS_SYS (fabsf, float, (float x));
851# if __GLIBC__ >= 2
692_GL_CXXALIASWARN (fabsf); 852_GL_CXXALIASWARN (fabsf);
853# endif
693#elif defined GNULIB_POSIXCHECK 854#elif defined GNULIB_POSIXCHECK
694# undef fabsf 855# undef fabsf
695# if HAVE_RAW_DECL_FABSF 856# if HAVE_RAW_DECL_FABSF
@@ -713,7 +874,9 @@ _GL_FUNCDECL_SYS (fabsl, long double, (long double x));
713# endif 874# endif
714_GL_CXXALIAS_SYS (fabsl, long double, (long double x)); 875_GL_CXXALIAS_SYS (fabsl, long double, (long double x));
715# endif 876# endif
877# if __GLIBC__ >= 2
716_GL_CXXALIASWARN (fabsl); 878_GL_CXXALIASWARN (fabsl);
879# endif
717#elif defined GNULIB_POSIXCHECK 880#elif defined GNULIB_POSIXCHECK
718# undef fabsl 881# undef fabsl
719# if HAVE_RAW_DECL_FABSL 882# if HAVE_RAW_DECL_FABSL
@@ -750,6 +913,7 @@ _GL_WARN_ON_USE (floorf, "floorf is unportable - "
750#if @GNULIB_FLOOR@ 913#if @GNULIB_FLOOR@
751# if @REPLACE_FLOOR@ 914# if @REPLACE_FLOOR@
752# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 915# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
916# undef floor
753# define floor rpl_floor 917# define floor rpl_floor
754# endif 918# endif
755_GL_FUNCDECL_RPL (floor, double, (double x)); 919_GL_FUNCDECL_RPL (floor, double, (double x));
@@ -757,7 +921,9 @@ _GL_CXXALIAS_RPL (floor, double, (double x));
757# else 921# else
758_GL_CXXALIAS_SYS (floor, double, (double x)); 922_GL_CXXALIAS_SYS (floor, double, (double x));
759# endif 923# endif
760_GL_CXXALIASWARN (floor); 924# if __GLIBC__ >= 2
925_GL_CXXALIASWARN1 (floor, double, (double x));
926# endif
761#endif 927#endif
762 928
763#if @GNULIB_FLOORL@ 929#if @GNULIB_FLOORL@
@@ -775,7 +941,9 @@ _GL_FUNCDECL_SYS (floorl, long double, (long double x));
775# endif 941# endif
776_GL_CXXALIAS_SYS (floorl, long double, (long double x)); 942_GL_CXXALIAS_SYS (floorl, long double, (long double x));
777# endif 943# endif
944# if __GLIBC__ >= 2
778_GL_CXXALIASWARN (floorl); 945_GL_CXXALIASWARN (floorl);
946# endif
779#elif defined GNULIB_POSIXCHECK 947#elif defined GNULIB_POSIXCHECK
780# undef floorl 948# undef floorl
781# if HAVE_RAW_DECL_FLOORL 949# if HAVE_RAW_DECL_FLOORL
@@ -795,6 +963,7 @@ _GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z));
795_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z)); 963_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z));
796# else 964# else
797# if !@HAVE_FMAF@ 965# if !@HAVE_FMAF@
966# undef fmaf
798_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z)); 967_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z));
799# endif 968# endif
800_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z)); 969_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z));
@@ -818,11 +987,14 @@ _GL_FUNCDECL_RPL (fma, double, (double x, double y, double z));
818_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z)); 987_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z));
819# else 988# else
820# if !@HAVE_FMA@ 989# if !@HAVE_FMA@
990# undef fma
821_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z)); 991_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z));
822# endif 992# endif
823_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z)); 993_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z));
824# endif 994# endif
825_GL_CXXALIASWARN (fma); 995# if __GLIBC__ >= 2
996_GL_CXXALIASWARN1 (fma, double, (double x, double y, double z));
997# endif
826#elif defined GNULIB_POSIXCHECK 998#elif defined GNULIB_POSIXCHECK
827# undef fma 999# undef fma
828# if HAVE_RAW_DECL_FMA 1000# if HAVE_RAW_DECL_FMA
@@ -844,13 +1016,17 @@ _GL_CXXALIAS_RPL (fmal, long double,
844# else 1016# else
845# if !@HAVE_FMAL@ 1017# if !@HAVE_FMAL@
846# undef fmal 1018# undef fmal
1019# if !(defined __cplusplus && defined _AIX)
847_GL_FUNCDECL_SYS (fmal, long double, 1020_GL_FUNCDECL_SYS (fmal, long double,
848 (long double x, long double y, long double z)); 1021 (long double x, long double y, long double z));
1022# endif
849# endif 1023# endif
850_GL_CXXALIAS_SYS (fmal, long double, 1024_GL_CXXALIAS_SYS (fmal, long double,
851 (long double x, long double y, long double z)); 1025 (long double x, long double y, long double z));
852# endif 1026# endif
1027# if __GLIBC__ >= 2
853_GL_CXXALIASWARN (fmal); 1028_GL_CXXALIASWARN (fmal);
1029# endif
854#elif defined GNULIB_POSIXCHECK 1030#elif defined GNULIB_POSIXCHECK
855# undef fmal 1031# undef fmal
856# if HAVE_RAW_DECL_FMAL 1032# if HAVE_RAW_DECL_FMAL
@@ -895,7 +1071,9 @@ _GL_CXXALIAS_RPL (fmod, double, (double x, double y));
895# else 1071# else
896_GL_CXXALIAS_SYS (fmod, double, (double x, double y)); 1072_GL_CXXALIAS_SYS (fmod, double, (double x, double y));
897# endif 1073# endif
898_GL_CXXALIASWARN (fmod); 1074# if __GLIBC__ >= 2
1075_GL_CXXALIASWARN1 (fmod, double, (double x, double y));
1076# endif
899#elif defined GNULIB_POSIXCHECK 1077#elif defined GNULIB_POSIXCHECK
900# undef fmod 1078# undef fmod
901# if HAVE_RAW_DECL_FMOD 1079# if HAVE_RAW_DECL_FMOD
@@ -919,7 +1097,9 @@ _GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y));
919# endif 1097# endif
920_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y)); 1098_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y));
921# endif 1099# endif
1100# if __GLIBC__ >= 2
922_GL_CXXALIASWARN (fmodl); 1101_GL_CXXALIASWARN (fmodl);
1102# endif
923#elif defined GNULIB_POSIXCHECK 1103#elif defined GNULIB_POSIXCHECK
924# undef fmodl 1104# undef fmodl
925# if HAVE_RAW_DECL_FMODL 1105# if HAVE_RAW_DECL_FMODL
@@ -951,7 +1131,9 @@ _GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2)));
951# endif 1131# endif
952_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr)); 1132_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr));
953# endif 1133# endif
1134# if __GLIBC__ >= 2
954_GL_CXXALIASWARN (frexpf); 1135_GL_CXXALIASWARN (frexpf);
1136# endif
955#elif defined GNULIB_POSIXCHECK 1137#elif defined GNULIB_POSIXCHECK
956# undef frexpf 1138# undef frexpf
957# if HAVE_RAW_DECL_FREXPF 1139# if HAVE_RAW_DECL_FREXPF
@@ -970,6 +1152,7 @@ _GL_WARN_ON_USE (frexpf, "frexpf is unportable - "
970#if @GNULIB_FREXP@ 1152#if @GNULIB_FREXP@
971# if @REPLACE_FREXP@ 1153# if @REPLACE_FREXP@
972# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1154# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1155# undef frexp
973# define frexp rpl_frexp 1156# define frexp rpl_frexp
974# endif 1157# endif
975_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2))); 1158_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
@@ -977,7 +1160,9 @@ _GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
977# else 1160# else
978_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr)); 1161_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
979# endif 1162# endif
980_GL_CXXALIASWARN (frexp); 1163# if __GLIBC__ >= 2
1164_GL_CXXALIASWARN1 (frexp, double, (double x, int *expptr));
1165# endif
981#elif defined GNULIB_POSIXCHECK 1166#elif defined GNULIB_POSIXCHECK
982# undef frexp 1167# undef frexp
983/* Assume frexp is always declared. */ 1168/* Assume frexp is always declared. */
@@ -1010,7 +1195,9 @@ _GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr));
1010# endif 1195# endif
1011#endif 1196#endif
1012#if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@) 1197#if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@)
1198# if __GLIBC__ >= 2
1013_GL_CXXALIASWARN (frexpl); 1199_GL_CXXALIASWARN (frexpl);
1200# endif
1014#endif 1201#endif
1015#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK 1202#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
1016# undef frexpl 1203# undef frexpl
@@ -1036,7 +1223,9 @@ _GL_FUNCDECL_SYS (hypotf, float, (float x, float y));
1036# endif 1223# endif
1037_GL_CXXALIAS_SYS (hypotf, float, (float x, float y)); 1224_GL_CXXALIAS_SYS (hypotf, float, (float x, float y));
1038# endif 1225# endif
1226# if __GLIBC__ >= 2
1039_GL_CXXALIASWARN (hypotf); 1227_GL_CXXALIASWARN (hypotf);
1228# endif
1040#elif defined GNULIB_POSIXCHECK 1229#elif defined GNULIB_POSIXCHECK
1041# undef hypotf 1230# undef hypotf
1042# if HAVE_RAW_DECL_HYPOTF 1231# if HAVE_RAW_DECL_HYPOTF
@@ -1057,7 +1246,9 @@ _GL_CXXALIAS_RPL (hypot, double, (double x, double y));
1057# else 1246# else
1058_GL_CXXALIAS_SYS (hypot, double, (double x, double y)); 1247_GL_CXXALIAS_SYS (hypot, double, (double x, double y));
1059# endif 1248# endif
1060_GL_CXXALIASWARN (hypot); 1249# if __GLIBC__ >= 2
1250_GL_CXXALIASWARN1 (hypot, double, (double x, double y));
1251# endif
1061#elif defined GNULIB_POSIXCHECK 1252#elif defined GNULIB_POSIXCHECK
1062# undef hypot 1253# undef hypot
1063# if HAVE_RAW_DECL_HYPOT 1254# if HAVE_RAW_DECL_HYPOT
@@ -1081,7 +1272,9 @@ _GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y));
1081# endif 1272# endif
1082_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y)); 1273_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y));
1083# endif 1274# endif
1275# if __GLIBC__ >= 2
1084_GL_CXXALIASWARN (hypotl); 1276_GL_CXXALIASWARN (hypotl);
1277# endif
1085#elif defined GNULIB_POSIXCHECK 1278#elif defined GNULIB_POSIXCHECK
1086# undef hypotl 1279# undef hypotl
1087# if HAVE_RAW_DECL_HYPOTL 1280# if HAVE_RAW_DECL_HYPOTL
@@ -1128,7 +1321,9 @@ _GL_FUNCDECL_SYS (ilogb, int, (double x));
1128# endif 1321# endif
1129_GL_CXXALIAS_SYS (ilogb, int, (double x)); 1322_GL_CXXALIAS_SYS (ilogb, int, (double x));
1130# endif 1323# endif
1131_GL_CXXALIASWARN (ilogb); 1324# if __GLIBC__ >= 2
1325_GL_CXXALIASWARN1 (ilogb, int, (double x));
1326# endif
1132#elif defined GNULIB_POSIXCHECK 1327#elif defined GNULIB_POSIXCHECK
1133# undef ilogb 1328# undef ilogb
1134# if HAVE_RAW_DECL_ILOGB 1329# if HAVE_RAW_DECL_ILOGB
@@ -1138,11 +1333,23 @@ _GL_WARN_ON_USE (ilogb, "ilogb is unportable - "
1138#endif 1333#endif
1139 1334
1140#if @GNULIB_ILOGBL@ 1335#if @GNULIB_ILOGBL@
1141# if !@HAVE_ILOGBL@ 1336# if @REPLACE_ILOGBL@
1337# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1338# undef ilogbl
1339# define ilogbl rpl_ilogbl
1340# endif
1341_GL_FUNCDECL_RPL (ilogbl, int, (long double x));
1342_GL_CXXALIAS_RPL (ilogbl, int, (long double x));
1343# else
1344# if !@HAVE_ILOGBL@
1345# undef ilogbl
1142_GL_FUNCDECL_SYS (ilogbl, int, (long double x)); 1346_GL_FUNCDECL_SYS (ilogbl, int, (long double x));
1143# endif 1347# endif
1144_GL_CXXALIAS_SYS (ilogbl, int, (long double x)); 1348_GL_CXXALIAS_SYS (ilogbl, int, (long double x));
1349# endif
1350# if __GLIBC__ >= 2
1145_GL_CXXALIASWARN (ilogbl); 1351_GL_CXXALIASWARN (ilogbl);
1352# endif
1146#elif defined GNULIB_POSIXCHECK 1353#elif defined GNULIB_POSIXCHECK
1147# undef ilogbl 1354# undef ilogbl
1148# if HAVE_RAW_DECL_ILOGBL 1355# if HAVE_RAW_DECL_ILOGBL
@@ -1152,6 +1359,55 @@ _GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - "
1152#endif 1359#endif
1153 1360
1154 1361
1362#if @GNULIB_MDA_J0@
1363/* On native Windows, map 'j0' to '_j0', so that -loldnames is not
1364 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1365 platforms by defining GNULIB_NAMESPACE::j0 always. */
1366# if defined _WIN32 && !defined __CYGWIN__
1367# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1368# undef j0
1369# define j0 _j0
1370# endif
1371_GL_CXXALIAS_MDA (j0, double, (double x));
1372# else
1373_GL_CXXALIAS_SYS (j0, double, (double x));
1374# endif
1375_GL_CXXALIASWARN (j0);
1376#endif
1377
1378#if @GNULIB_MDA_J1@
1379/* On native Windows, map 'j1' to '_j1', so that -loldnames is not
1380 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1381 platforms by defining GNULIB_NAMESPACE::j1 always. */
1382# if defined _WIN32 && !defined __CYGWIN__
1383# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1384# undef j1
1385# define j1 _j1
1386# endif
1387_GL_CXXALIAS_MDA (j1, double, (double x));
1388# else
1389_GL_CXXALIAS_SYS (j1, double, (double x));
1390# endif
1391_GL_CXXALIASWARN (j1);
1392#endif
1393
1394#if @GNULIB_MDA_JN@
1395/* On native Windows, map 'jn' to '_jn', so that -loldnames is not
1396 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1397 platforms by defining GNULIB_NAMESPACE::jn always. */
1398# if defined _WIN32 && !defined __CYGWIN__
1399# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1400# undef jn
1401# define jn _jn
1402# endif
1403_GL_CXXALIAS_MDA (jn, double, (int n, double x));
1404# else
1405_GL_CXXALIAS_SYS (jn, double, (int n, double x));
1406# endif
1407_GL_CXXALIASWARN (jn);
1408#endif
1409
1410
1155/* Return x * 2^exp. */ 1411/* Return x * 2^exp. */
1156#if @GNULIB_LDEXPF@ 1412#if @GNULIB_LDEXPF@
1157# if !@HAVE_LDEXPF@ 1413# if !@HAVE_LDEXPF@
@@ -1159,7 +1415,9 @@ _GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - "
1159_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp)); 1415_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp));
1160# endif 1416# endif
1161_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp)); 1417_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp));
1418# if __GLIBC__ >= 2
1162_GL_CXXALIASWARN (ldexpf); 1419_GL_CXXALIASWARN (ldexpf);
1420# endif
1163#elif defined GNULIB_POSIXCHECK 1421#elif defined GNULIB_POSIXCHECK
1164# undef ldexpf 1422# undef ldexpf
1165# if HAVE_RAW_DECL_LDEXPF 1423# if HAVE_RAW_DECL_LDEXPF
@@ -1185,7 +1443,9 @@ _GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp));
1185# endif 1443# endif
1186#endif 1444#endif
1187#if @GNULIB_LDEXPL@ 1445#if @GNULIB_LDEXPL@
1446# if __GLIBC__ >= 2
1188_GL_CXXALIASWARN (ldexpl); 1447_GL_CXXALIASWARN (ldexpl);
1448# endif
1189#endif 1449#endif
1190#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK 1450#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
1191# undef ldexpl 1451# undef ldexpl
@@ -1231,7 +1491,9 @@ _GL_CXXALIAS_RPL (log, double, (double x));
1231# else 1491# else
1232_GL_CXXALIAS_SYS (log, double, (double x)); 1492_GL_CXXALIAS_SYS (log, double, (double x));
1233# endif 1493# endif
1234_GL_CXXALIASWARN (log); 1494# if __GLIBC__ >= 2
1495_GL_CXXALIASWARN1 (log, double, (double x));
1496# endif
1235#elif defined GNULIB_POSIXCHECK 1497#elif defined GNULIB_POSIXCHECK
1236# undef log 1498# undef log
1237# if HAVE_RAW_DECL_LOG 1499# if HAVE_RAW_DECL_LOG
@@ -1255,7 +1517,9 @@ _GL_FUNCDECL_SYS (logl, long double, (long double x));
1255# endif 1517# endif
1256_GL_CXXALIAS_SYS (logl, long double, (long double x)); 1518_GL_CXXALIAS_SYS (logl, long double, (long double x));
1257# endif 1519# endif
1520# if __GLIBC__ >= 2
1258_GL_CXXALIASWARN (logl); 1521_GL_CXXALIASWARN (logl);
1522# endif
1259#elif defined GNULIB_POSIXCHECK 1523#elif defined GNULIB_POSIXCHECK
1260# undef logl 1524# undef logl
1261# if HAVE_RAW_DECL_LOGL 1525# if HAVE_RAW_DECL_LOGL
@@ -1300,7 +1564,9 @@ _GL_CXXALIAS_RPL (log10, double, (double x));
1300# else 1564# else
1301_GL_CXXALIAS_SYS (log10, double, (double x)); 1565_GL_CXXALIAS_SYS (log10, double, (double x));
1302# endif 1566# endif
1303_GL_CXXALIASWARN (log10); 1567# if __GLIBC__ >= 2
1568_GL_CXXALIASWARN1 (log10, double, (double x));
1569# endif
1304#elif defined GNULIB_POSIXCHECK 1570#elif defined GNULIB_POSIXCHECK
1305# undef log10 1571# undef log10
1306# if HAVE_RAW_DECL_LOG10 1572# if HAVE_RAW_DECL_LOG10
@@ -1324,7 +1590,9 @@ _GL_FUNCDECL_SYS (log10l, long double, (long double x));
1324# endif 1590# endif
1325_GL_CXXALIAS_SYS (log10l, long double, (long double x)); 1591_GL_CXXALIAS_SYS (log10l, long double, (long double x));
1326# endif 1592# endif
1593# if __GLIBC__ >= 2
1327_GL_CXXALIASWARN (log10l); 1594_GL_CXXALIASWARN (log10l);
1595# endif
1328#elif defined GNULIB_POSIXCHECK 1596#elif defined GNULIB_POSIXCHECK
1329# undef log10l 1597# undef log10l
1330# if HAVE_RAW_DECL_LOG10L 1598# if HAVE_RAW_DECL_LOG10L
@@ -1371,7 +1639,9 @@ _GL_FUNCDECL_SYS (log1p, double, (double x));
1371# endif 1639# endif
1372_GL_CXXALIAS_SYS (log1p, double, (double x)); 1640_GL_CXXALIAS_SYS (log1p, double, (double x));
1373# endif 1641# endif
1374_GL_CXXALIASWARN (log1p); 1642# if __GLIBC__ >= 2
1643_GL_CXXALIASWARN1 (log1p, double, (double x));
1644# endif
1375#elif defined GNULIB_POSIXCHECK 1645#elif defined GNULIB_POSIXCHECK
1376# undef log1p 1646# undef log1p
1377# if HAVE_RAW_DECL_LOG1P 1647# if HAVE_RAW_DECL_LOG1P
@@ -1394,7 +1664,9 @@ _GL_FUNCDECL_SYS (log1pl, long double, (long double x));
1394# endif 1664# endif
1395_GL_CXXALIAS_SYS (log1pl, long double, (long double x)); 1665_GL_CXXALIAS_SYS (log1pl, long double, (long double x));
1396# endif 1666# endif
1667# if __GLIBC__ >= 2
1397_GL_CXXALIASWARN (log1pl); 1668_GL_CXXALIASWARN (log1pl);
1669# endif
1398#elif defined GNULIB_POSIXCHECK 1670#elif defined GNULIB_POSIXCHECK
1399# undef log1pl 1671# undef log1pl
1400# if HAVE_RAW_DECL_LOG1PL 1672# if HAVE_RAW_DECL_LOG1PL
@@ -1443,7 +1715,9 @@ _GL_FUNCDECL_SYS (log2, double, (double x));
1443# endif 1715# endif
1444_GL_CXXALIAS_SYS (log2, double, (double x)); 1716_GL_CXXALIAS_SYS (log2, double, (double x));
1445# endif 1717# endif
1446_GL_CXXALIASWARN (log2); 1718# if __GLIBC__ >= 2
1719_GL_CXXALIASWARN1 (log2, double, (double x));
1720# endif
1447#elif defined GNULIB_POSIXCHECK 1721#elif defined GNULIB_POSIXCHECK
1448# undef log2 1722# undef log2
1449# if HAVE_RAW_DECL_LOG2 1723# if HAVE_RAW_DECL_LOG2
@@ -1466,7 +1740,9 @@ _GL_FUNCDECL_SYS (log2l, long double, (long double x));
1466# endif 1740# endif
1467_GL_CXXALIAS_SYS (log2l, long double, (long double x)); 1741_GL_CXXALIAS_SYS (log2l, long double, (long double x));
1468# endif 1742# endif
1743# if __GLIBC__ >= 2
1469_GL_CXXALIASWARN (log2l); 1744_GL_CXXALIASWARN (log2l);
1745# endif
1470#elif defined GNULIB_POSIXCHECK 1746#elif defined GNULIB_POSIXCHECK
1471# undef log2l 1747# undef log2l
1472# if HAVE_RAW_DECL_LOG2L 1748# if HAVE_RAW_DECL_LOG2L
@@ -1513,7 +1789,9 @@ _GL_FUNCDECL_SYS (logb, double, (double x));
1513# endif 1789# endif
1514_GL_CXXALIAS_SYS (logb, double, (double x)); 1790_GL_CXXALIAS_SYS (logb, double, (double x));
1515# endif 1791# endif
1516_GL_CXXALIASWARN (logb); 1792# if __GLIBC__ >= 2
1793_GL_CXXALIASWARN1 (logb, double, (double x));
1794# endif
1517#elif defined GNULIB_POSIXCHECK 1795#elif defined GNULIB_POSIXCHECK
1518# undef logb 1796# undef logb
1519# if HAVE_RAW_DECL_LOGB 1797# if HAVE_RAW_DECL_LOGB
@@ -1536,7 +1814,9 @@ _GL_FUNCDECL_SYS (logbl, long double, (long double x));
1536# endif 1814# endif
1537_GL_CXXALIAS_SYS (logbl, long double, (long double x)); 1815_GL_CXXALIAS_SYS (logbl, long double, (long double x));
1538# endif 1816# endif
1817# if __GLIBC__ >= 2
1539_GL_CXXALIASWARN (logbl); 1818_GL_CXXALIASWARN (logbl);
1819# endif
1540#elif defined GNULIB_POSIXCHECK 1820#elif defined GNULIB_POSIXCHECK
1541# undef logbl 1821# undef logbl
1542# if HAVE_RAW_DECL_LOGBL 1822# if HAVE_RAW_DECL_LOGBL
@@ -1581,7 +1861,9 @@ _GL_CXXALIAS_RPL (modf, double, (double x, double *iptr));
1581# else 1861# else
1582_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr)); 1862_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr));
1583# endif 1863# endif
1584_GL_CXXALIASWARN (modf); 1864# if __GLIBC__ >= 2
1865_GL_CXXALIASWARN1 (modf, double, (double x, double *iptr));
1866# endif
1585#elif defined GNULIB_POSIXCHECK 1867#elif defined GNULIB_POSIXCHECK
1586# undef modf 1868# undef modf
1587# if HAVE_RAW_DECL_MODF 1869# if HAVE_RAW_DECL_MODF
@@ -1607,7 +1889,9 @@ _GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr)
1607# endif 1889# endif
1608_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr)); 1890_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr));
1609# endif 1891# endif
1892# if __GLIBC__ >= 2
1610_GL_CXXALIASWARN (modfl); 1893_GL_CXXALIASWARN (modfl);
1894# endif
1611#elif defined GNULIB_POSIXCHECK 1895#elif defined GNULIB_POSIXCHECK
1612# undef modfl 1896# undef modfl
1613# if HAVE_RAW_DECL_MODFL 1897# if HAVE_RAW_DECL_MODFL
@@ -1670,7 +1954,9 @@ _GL_FUNCDECL_SYS (remainder, double, (double x, double y));
1670# endif 1954# endif
1671_GL_CXXALIAS_SYS (remainder, double, (double x, double y)); 1955_GL_CXXALIAS_SYS (remainder, double, (double x, double y));
1672# endif 1956# endif
1673_GL_CXXALIASWARN (remainder); 1957# if __GLIBC__ >= 2
1958_GL_CXXALIASWARN1 (remainder, double, (double x, double y));
1959# endif
1674#elif defined GNULIB_POSIXCHECK 1960#elif defined GNULIB_POSIXCHECK
1675# undef remainder 1961# undef remainder
1676# if HAVE_RAW_DECL_REMAINDER 1962# if HAVE_RAW_DECL_REMAINDER
@@ -1690,11 +1976,15 @@ _GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y));
1690# else 1976# else
1691# if !@HAVE_DECL_REMAINDERL@ 1977# if !@HAVE_DECL_REMAINDERL@
1692# undef remainderl 1978# undef remainderl
1979# if !(defined __cplusplus && defined _AIX)
1693_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y)); 1980_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y));
1981# endif
1694# endif 1982# endif
1695_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y)); 1983_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
1696# endif 1984# endif
1985# if __GLIBC__ >= 2
1697_GL_CXXALIASWARN (remainderl); 1986_GL_CXXALIASWARN (remainderl);
1987# endif
1698#elif defined GNULIB_POSIXCHECK 1988#elif defined GNULIB_POSIXCHECK
1699# undef remainderl 1989# undef remainderl
1700# if HAVE_RAW_DECL_REMAINDERL 1990# if HAVE_RAW_DECL_REMAINDERL
@@ -1723,7 +2013,9 @@ _GL_WARN_ON_USE (rintf, "rintf is unportable - "
1723_GL_FUNCDECL_SYS (rint, double, (double x)); 2013_GL_FUNCDECL_SYS (rint, double, (double x));
1724# endif 2014# endif
1725_GL_CXXALIAS_SYS (rint, double, (double x)); 2015_GL_CXXALIAS_SYS (rint, double, (double x));
1726_GL_CXXALIASWARN (rint); 2016# if __GLIBC__ >= 2
2017_GL_CXXALIASWARN1 (rint, double, (double x));
2018# endif
1727#elif defined GNULIB_POSIXCHECK 2019#elif defined GNULIB_POSIXCHECK
1728# undef rint 2020# undef rint
1729# if HAVE_RAW_DECL_RINT 2021# if HAVE_RAW_DECL_RINT
@@ -1733,11 +2025,22 @@ _GL_WARN_ON_USE (rint, "rint is unportable - "
1733#endif 2025#endif
1734 2026
1735#if @GNULIB_RINTL@ 2027#if @GNULIB_RINTL@
1736# if !@HAVE_RINTL@ 2028# if @REPLACE_RINTL@
2029# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2030# undef rintl
2031# define rintl rpl_rintl
2032# endif
2033_GL_FUNCDECL_RPL (rintl, long double, (long double x));
2034_GL_CXXALIAS_RPL (rintl, long double, (long double x));
2035# else
2036# if !@HAVE_RINTL@
1737_GL_FUNCDECL_SYS (rintl, long double, (long double x)); 2037_GL_FUNCDECL_SYS (rintl, long double, (long double x));
1738# endif 2038# endif
1739_GL_CXXALIAS_SYS (rintl, long double, (long double x)); 2039_GL_CXXALIAS_SYS (rintl, long double, (long double x));
2040# endif
2041# if __GLIBC__ >= 2
1740_GL_CXXALIASWARN (rintl); 2042_GL_CXXALIASWARN (rintl);
2043# endif
1741#elif defined GNULIB_POSIXCHECK 2044#elif defined GNULIB_POSIXCHECK
1742# undef rintl 2045# undef rintl
1743# if HAVE_RAW_DECL_RINTL 2046# if HAVE_RAW_DECL_RINTL
@@ -1784,7 +2087,9 @@ _GL_FUNCDECL_SYS (round, double, (double x));
1784# endif 2087# endif
1785_GL_CXXALIAS_SYS (round, double, (double x)); 2088_GL_CXXALIAS_SYS (round, double, (double x));
1786# endif 2089# endif
1787_GL_CXXALIASWARN (round); 2090# if __GLIBC__ >= 2
2091_GL_CXXALIASWARN1 (round, double, (double x));
2092# endif
1788#elif defined GNULIB_POSIXCHECK 2093#elif defined GNULIB_POSIXCHECK
1789# undef round 2094# undef round
1790# if HAVE_RAW_DECL_ROUND 2095# if HAVE_RAW_DECL_ROUND
@@ -1804,11 +2109,15 @@ _GL_CXXALIAS_RPL (roundl, long double, (long double x));
1804# else 2109# else
1805# if !@HAVE_DECL_ROUNDL@ 2110# if !@HAVE_DECL_ROUNDL@
1806# undef roundl 2111# undef roundl
2112# if !(defined __cplusplus && defined _AIX)
1807_GL_FUNCDECL_SYS (roundl, long double, (long double x)); 2113_GL_FUNCDECL_SYS (roundl, long double, (long double x));
2114# endif
1808# endif 2115# endif
1809_GL_CXXALIAS_SYS (roundl, long double, (long double x)); 2116_GL_CXXALIAS_SYS (roundl, long double, (long double x));
1810# endif 2117# endif
2118# if __GLIBC__ >= 2
1811_GL_CXXALIASWARN (roundl); 2119_GL_CXXALIASWARN (roundl);
2120# endif
1812#elif defined GNULIB_POSIXCHECK 2121#elif defined GNULIB_POSIXCHECK
1813# undef roundl 2122# undef roundl
1814# if HAVE_RAW_DECL_ROUNDL 2123# if HAVE_RAW_DECL_ROUNDL
@@ -1819,11 +2128,20 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - "
1819 2128
1820 2129
1821#if @GNULIB_SINF@ 2130#if @GNULIB_SINF@
1822# if !@HAVE_SINF@ 2131# if @REPLACE_SINF@
1823# undef sinf 2132# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2133# undef sinf
2134# define sinf rpl_sinf
2135# endif
2136_GL_FUNCDECL_RPL (sinf, float, (float x));
2137_GL_CXXALIAS_RPL (sinf, float, (float x));
2138# else
2139# if !@HAVE_SINF@
2140# undef sinf
1824_GL_FUNCDECL_SYS (sinf, float, (float x)); 2141_GL_FUNCDECL_SYS (sinf, float, (float x));
1825# endif 2142# endif
1826_GL_CXXALIAS_SYS (sinf, float, (float x)); 2143_GL_CXXALIAS_SYS (sinf, float, (float x));
2144# endif
1827_GL_CXXALIASWARN (sinf); 2145_GL_CXXALIASWARN (sinf);
1828#elif defined GNULIB_POSIXCHECK 2146#elif defined GNULIB_POSIXCHECK
1829# undef sinf 2147# undef sinf
@@ -1839,7 +2157,9 @@ _GL_WARN_ON_USE (sinf, "sinf is unportable - "
1839_GL_FUNCDECL_SYS (sinl, long double, (long double x)); 2157_GL_FUNCDECL_SYS (sinl, long double, (long double x));
1840# endif 2158# endif
1841_GL_CXXALIAS_SYS (sinl, long double, (long double x)); 2159_GL_CXXALIAS_SYS (sinl, long double, (long double x));
2160# if __GLIBC__ >= 2
1842_GL_CXXALIASWARN (sinl); 2161_GL_CXXALIASWARN (sinl);
2162# endif
1843#elif defined GNULIB_POSIXCHECK 2163#elif defined GNULIB_POSIXCHECK
1844# undef sinl 2164# undef sinl
1845# if HAVE_RAW_DECL_SINL 2165# if HAVE_RAW_DECL_SINL
@@ -1850,11 +2170,20 @@ _GL_WARN_ON_USE (sinl, "sinl is unportable - "
1850 2170
1851 2171
1852#if @GNULIB_SINHF@ 2172#if @GNULIB_SINHF@
1853# if !@HAVE_SINHF@ 2173# if @REPLACE_SINHF@
1854# undef sinhf 2174# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2175# undef sinhf
2176# define sinhf rpl_sinhf
2177# endif
2178_GL_FUNCDECL_RPL (sinhf, float, (float x));
2179_GL_CXXALIAS_RPL (sinhf, float, (float x));
2180# else
2181# if !@HAVE_SINHF@
2182# undef sinhf
1855_GL_FUNCDECL_SYS (sinhf, float, (float x)); 2183_GL_FUNCDECL_SYS (sinhf, float, (float x));
1856# endif 2184# endif
1857_GL_CXXALIAS_SYS (sinhf, float, (float x)); 2185_GL_CXXALIAS_SYS (sinhf, float, (float x));
2186# endif
1858_GL_CXXALIASWARN (sinhf); 2187_GL_CXXALIASWARN (sinhf);
1859#elif defined GNULIB_POSIXCHECK 2188#elif defined GNULIB_POSIXCHECK
1860# undef sinhf 2189# undef sinhf
@@ -1866,11 +2195,20 @@ _GL_WARN_ON_USE (sinhf, "sinhf is unportable - "
1866 2195
1867 2196
1868#if @GNULIB_SQRTF@ 2197#if @GNULIB_SQRTF@
1869# if !@HAVE_SQRTF@ 2198# if @REPLACE_SQRTF@
1870# undef sqrtf 2199# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2200# undef sqrtf
2201# define sqrtf rpl_sqrtf
2202# endif
2203_GL_FUNCDECL_RPL (sqrtf, float, (float x));
2204_GL_CXXALIAS_RPL (sqrtf, float, (float x));
2205# else
2206# if !@HAVE_SQRTF@
2207# undef sqrtf
1871_GL_FUNCDECL_SYS (sqrtf, float, (float x)); 2208_GL_FUNCDECL_SYS (sqrtf, float, (float x));
1872# endif 2209# endif
1873_GL_CXXALIAS_SYS (sqrtf, float, (float x)); 2210_GL_CXXALIAS_SYS (sqrtf, float, (float x));
2211# endif
1874_GL_CXXALIASWARN (sqrtf); 2212_GL_CXXALIASWARN (sqrtf);
1875#elif defined GNULIB_POSIXCHECK 2213#elif defined GNULIB_POSIXCHECK
1876# undef sqrtf 2214# undef sqrtf
@@ -1895,7 +2233,9 @@ _GL_FUNCDECL_SYS (sqrtl, long double, (long double x));
1895# endif 2233# endif
1896_GL_CXXALIAS_SYS (sqrtl, long double, (long double x)); 2234_GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
1897# endif 2235# endif
2236# if __GLIBC__ >= 2
1898_GL_CXXALIASWARN (sqrtl); 2237_GL_CXXALIASWARN (sqrtl);
2238# endif
1899#elif defined GNULIB_POSIXCHECK 2239#elif defined GNULIB_POSIXCHECK
1900# undef sqrtl 2240# undef sqrtl
1901# if HAVE_RAW_DECL_SQRTL 2241# if HAVE_RAW_DECL_SQRTL
@@ -1906,11 +2246,20 @@ _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
1906 2246
1907 2247
1908#if @GNULIB_TANF@ 2248#if @GNULIB_TANF@
1909# if !@HAVE_TANF@ 2249# if @REPLACE_TANF@
1910# undef tanf 2250# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2251# undef tanf
2252# define tanf rpl_tanf
2253# endif
2254_GL_FUNCDECL_RPL (tanf, float, (float x));
2255_GL_CXXALIAS_RPL (tanf, float, (float x));
2256# else
2257# if !@HAVE_TANF@
2258# undef tanf
1911_GL_FUNCDECL_SYS (tanf, float, (float x)); 2259_GL_FUNCDECL_SYS (tanf, float, (float x));
1912# endif 2260# endif
1913_GL_CXXALIAS_SYS (tanf, float, (float x)); 2261_GL_CXXALIAS_SYS (tanf, float, (float x));
2262# endif
1914_GL_CXXALIASWARN (tanf); 2263_GL_CXXALIASWARN (tanf);
1915#elif defined GNULIB_POSIXCHECK 2264#elif defined GNULIB_POSIXCHECK
1916# undef tanf 2265# undef tanf
@@ -1926,7 +2275,9 @@ _GL_WARN_ON_USE (tanf, "tanf is unportable - "
1926_GL_FUNCDECL_SYS (tanl, long double, (long double x)); 2275_GL_FUNCDECL_SYS (tanl, long double, (long double x));
1927# endif 2276# endif
1928_GL_CXXALIAS_SYS (tanl, long double, (long double x)); 2277_GL_CXXALIAS_SYS (tanl, long double, (long double x));
2278# if __GLIBC__ >= 2
1929_GL_CXXALIASWARN (tanl); 2279_GL_CXXALIASWARN (tanl);
2280# endif
1930#elif defined GNULIB_POSIXCHECK 2281#elif defined GNULIB_POSIXCHECK
1931# undef tanl 2282# undef tanl
1932# if HAVE_RAW_DECL_TANL 2283# if HAVE_RAW_DECL_TANL
@@ -1937,11 +2288,20 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - "
1937 2288
1938 2289
1939#if @GNULIB_TANHF@ 2290#if @GNULIB_TANHF@
1940# if !@HAVE_TANHF@ 2291# if @REPLACE_TANHF@
1941# undef tanhf 2292# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2293# undef tanhf
2294# define tanhf rpl_tanhf
2295# endif
2296_GL_FUNCDECL_RPL (tanhf, float, (float x));
2297_GL_CXXALIAS_RPL (tanhf, float, (float x));
2298# else
2299# if !@HAVE_TANHF@
2300# undef tanhf
1942_GL_FUNCDECL_SYS (tanhf, float, (float x)); 2301_GL_FUNCDECL_SYS (tanhf, float, (float x));
1943# endif 2302# endif
1944_GL_CXXALIAS_SYS (tanhf, float, (float x)); 2303_GL_CXXALIAS_SYS (tanhf, float, (float x));
2304# endif
1945_GL_CXXALIASWARN (tanhf); 2305_GL_CXXALIASWARN (tanhf);
1946#elif defined GNULIB_POSIXCHECK 2306#elif defined GNULIB_POSIXCHECK
1947# undef tanhf 2307# undef tanhf
@@ -1955,6 +2315,7 @@ _GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
1955#if @GNULIB_TRUNCF@ 2315#if @GNULIB_TRUNCF@
1956# if @REPLACE_TRUNCF@ 2316# if @REPLACE_TRUNCF@
1957# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2317# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2318# undef truncf
1958# define truncf rpl_truncf 2319# define truncf rpl_truncf
1959# endif 2320# endif
1960_GL_FUNCDECL_RPL (truncf, float, (float x)); 2321_GL_FUNCDECL_RPL (truncf, float, (float x));
@@ -1977,6 +2338,7 @@ _GL_WARN_ON_USE (truncf, "truncf is unportable - "
1977#if @GNULIB_TRUNC@ 2338#if @GNULIB_TRUNC@
1978# if @REPLACE_TRUNC@ 2339# if @REPLACE_TRUNC@
1979# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2340# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2341# undef trunc
1980# define trunc rpl_trunc 2342# define trunc rpl_trunc
1981# endif 2343# endif
1982_GL_FUNCDECL_RPL (trunc, double, (double x)); 2344_GL_FUNCDECL_RPL (trunc, double, (double x));
@@ -1987,7 +2349,9 @@ _GL_FUNCDECL_SYS (trunc, double, (double x));
1987# endif 2349# endif
1988_GL_CXXALIAS_SYS (trunc, double, (double x)); 2350_GL_CXXALIAS_SYS (trunc, double, (double x));
1989# endif 2351# endif
1990_GL_CXXALIASWARN (trunc); 2352# if __GLIBC__ >= 2
2353_GL_CXXALIASWARN1 (trunc, double, (double x));
2354# endif
1991#elif defined GNULIB_POSIXCHECK 2355#elif defined GNULIB_POSIXCHECK
1992# undef trunc 2356# undef trunc
1993# if HAVE_RAW_DECL_TRUNC 2357# if HAVE_RAW_DECL_TRUNC
@@ -2010,7 +2374,9 @@ _GL_FUNCDECL_SYS (truncl, long double, (long double x));
2010# endif 2374# endif
2011_GL_CXXALIAS_SYS (truncl, long double, (long double x)); 2375_GL_CXXALIAS_SYS (truncl, long double, (long double x));
2012# endif 2376# endif
2377# if __GLIBC__ >= 2
2013_GL_CXXALIASWARN (truncl); 2378_GL_CXXALIASWARN (truncl);
2379# endif
2014#elif defined GNULIB_POSIXCHECK 2380#elif defined GNULIB_POSIXCHECK
2015# undef truncl 2381# undef truncl
2016# if HAVE_RAW_DECL_TRUNCL 2382# if HAVE_RAW_DECL_TRUNCL
@@ -2020,6 +2386,55 @@ _GL_WARN_ON_USE (truncl, "truncl is unportable - "
2020#endif 2386#endif
2021 2387
2022 2388
2389#if @GNULIB_MDA_Y0@
2390/* On native Windows, map 'y0' to '_y0', so that -loldnames is not
2391 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2392 platforms by defining GNULIB_NAMESPACE::y0 always. */
2393# if defined _WIN32 && !defined __CYGWIN__
2394# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2395# undef y0
2396# define y0 _y0
2397# endif
2398_GL_CXXALIAS_MDA (y0, double, (double x));
2399# else
2400_GL_CXXALIAS_SYS (y0, double, (double x));
2401# endif
2402_GL_CXXALIASWARN (y0);
2403#endif
2404
2405#if @GNULIB_MDA_Y1@
2406/* On native Windows, map 'y1' to '_y1', so that -loldnames is not
2407 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2408 platforms by defining GNULIB_NAMESPACE::y1 always. */
2409# if defined _WIN32 && !defined __CYGWIN__
2410# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2411# undef y1
2412# define y1 _y1
2413# endif
2414_GL_CXXALIAS_MDA (y1, double, (double x));
2415# else
2416_GL_CXXALIAS_SYS (y1, double, (double x));
2417# endif
2418_GL_CXXALIASWARN (y1);
2419#endif
2420
2421#if @GNULIB_MDA_YN@
2422/* On native Windows, map 'yn' to '_yn', so that -loldnames is not
2423 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2424 platforms by defining GNULIB_NAMESPACE::yn always. */
2425# if defined _WIN32 && !defined __CYGWIN__
2426# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2427# undef yn
2428# define yn _yn
2429# endif
2430_GL_CXXALIAS_MDA (yn, double, (int n, double x));
2431# else
2432_GL_CXXALIAS_SYS (yn, double, (int n, double x));
2433# endif
2434_GL_CXXALIASWARN (yn);
2435#endif
2436
2437
2023/* Definitions of function-like macros come here, after the function 2438/* Definitions of function-like macros come here, after the function
2024 declarations. */ 2439 declarations. */
2025 2440
@@ -2036,10 +2451,18 @@ _GL_EXTERN_C int gl_isfinitel (long double x);
2036 gl_isfinitef (x)) 2451 gl_isfinitef (x))
2037# endif 2452# endif
2038# ifdef __cplusplus 2453# ifdef __cplusplus
2039# ifdef isfinite 2454# if defined isfinite || defined GNULIB_NAMESPACE
2040_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) 2455_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
2041# undef isfinite 2456# undef isfinite
2042_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite) 2457# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__)))
2458 /* This platform's <cmath> possibly defines isfinite through a set of inline
2459 functions. */
2460_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
2461# define isfinite rpl_isfinite
2462# define GNULIB_NAMESPACE_LACKS_ISFINITE 1
2463# else
2464_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, isfinite, bool)
2465# endif
2043# endif 2466# endif
2044# endif 2467# endif
2045#elif defined GNULIB_POSIXCHECK 2468#elif defined GNULIB_POSIXCHECK
@@ -2063,10 +2486,18 @@ _GL_EXTERN_C int gl_isinfl (long double x);
2063 gl_isinff (x)) 2486 gl_isinff (x))
2064# endif 2487# endif
2065# ifdef __cplusplus 2488# ifdef __cplusplus
2066# ifdef isinf 2489# if defined isinf || defined GNULIB_NAMESPACE
2067_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) 2490_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
2068# undef isinf 2491# undef isinf
2069_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf) 2492# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__)))
2493 /* This platform's <cmath> possibly defines isinf through a set of inline
2494 functions. */
2495_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, rpl_isinf, bool)
2496# define isinf rpl_isinf
2497# define GNULIB_NAMESPACE_LACKS_ISINF 1
2498# else
2499_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, isinf, bool)
2500# endif
2070# endif 2501# endif
2071# endif 2502# endif
2072#elif defined GNULIB_POSIXCHECK 2503#elif defined GNULIB_POSIXCHECK
@@ -2083,10 +2514,11 @@ _GL_WARN_REAL_FLOATING_DECL (isinf);
2083# if @HAVE_ISNANF@ 2514# if @HAVE_ISNANF@
2084/* The original <math.h> included above provides a declaration of isnan macro 2515/* The original <math.h> included above provides a declaration of isnan macro
2085 or (older) isnanf function. */ 2516 or (older) isnanf function. */
2086# if __GNUC__ >= 4 2517# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2087 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2518 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
2519 GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */
2088# undef isnanf 2520# undef isnanf
2089# define isnanf(x) __builtin_isnanf ((float)(x)) 2521# define isnanf(x) __builtin_isnan ((float)(x))
2090# elif defined isnan 2522# elif defined isnan
2091# undef isnanf 2523# undef isnanf
2092# define isnanf(x) isnan ((float)(x)) 2524# define isnanf(x) isnan ((float)(x))
@@ -2106,8 +2538,8 @@ _GL_EXTERN_C int isnanf (float x);
2106# if @HAVE_ISNAND@ 2538# if @HAVE_ISNAND@
2107/* The original <math.h> included above provides a declaration of isnan 2539/* The original <math.h> included above provides a declaration of isnan
2108 macro. */ 2540 macro. */
2109# if __GNUC__ >= 4 2541# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2110 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2542 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */
2111# undef isnand 2543# undef isnand
2112# define isnand(x) __builtin_isnan ((double)(x)) 2544# define isnand(x) __builtin_isnan ((double)(x))
2113# else 2545# else
@@ -2127,10 +2559,11 @@ _GL_EXTERN_C int isnand (double x);
2127# if @HAVE_ISNANL@ 2559# if @HAVE_ISNANL@
2128/* The original <math.h> included above provides a declaration of isnan 2560/* The original <math.h> included above provides a declaration of isnan
2129 macro or (older) isnanl function. */ 2561 macro or (older) isnanl function. */
2130# if __GNUC__ >= 4 2562# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2131 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2563 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
2564 GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */
2132# undef isnanl 2565# undef isnanl
2133# define isnanl(x) __builtin_isnanl ((long double)(x)) 2566# define isnanl(x) __builtin_isnan ((long double)(x))
2134# elif defined isnan 2567# elif defined isnan
2135# undef isnanl 2568# undef isnanl
2136# define isnanl(x) isnan ((long double)(x)) 2569# define isnanl(x) isnan ((long double)(x))
@@ -2150,20 +2583,20 @@ _GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST;
2150 isnanf.h (e.g.) here, because those may end up being macros 2583 isnanf.h (e.g.) here, because those may end up being macros
2151 that recursively expand back to isnan. So use the gnulib 2584 that recursively expand back to isnan. So use the gnulib
2152 replacements for them directly. */ 2585 replacements for them directly. */
2153# if @HAVE_ISNANF@ && __GNUC__ >= 4 2586# if @HAVE_ISNANF@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
2154# define gl_isnan_f(x) __builtin_isnanf ((float)(x)) 2587# define gl_isnan_f(x) __builtin_isnan ((float)(x))
2155# else 2588# else
2156_GL_EXTERN_C int rpl_isnanf (float x); 2589_GL_EXTERN_C int rpl_isnanf (float x);
2157# define gl_isnan_f(x) rpl_isnanf (x) 2590# define gl_isnan_f(x) rpl_isnanf (x)
2158# endif 2591# endif
2159# if @HAVE_ISNAND@ && __GNUC__ >= 4 2592# if @HAVE_ISNAND@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
2160# define gl_isnan_d(x) __builtin_isnan ((double)(x)) 2593# define gl_isnan_d(x) __builtin_isnan ((double)(x))
2161# else 2594# else
2162_GL_EXTERN_C int rpl_isnand (double x); 2595_GL_EXTERN_C int rpl_isnand (double x);
2163# define gl_isnan_d(x) rpl_isnand (x) 2596# define gl_isnan_d(x) rpl_isnand (x)
2164# endif 2597# endif
2165# if @HAVE_ISNANL@ && __GNUC__ >= 4 2598# if @HAVE_ISNANL@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
2166# define gl_isnan_l(x) __builtin_isnanl ((long double)(x)) 2599# define gl_isnan_l(x) __builtin_isnan ((long double)(x))
2167# else 2600# else
2168_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; 2601_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
2169# define gl_isnan_l(x) rpl_isnanl (x) 2602# define gl_isnan_l(x) rpl_isnanl (x)
@@ -2173,18 +2606,26 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
2173 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ 2606 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
2174 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ 2607 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
2175 gl_isnan_f (x)) 2608 gl_isnan_f (x))
2176# elif __GNUC__ >= 4 2609# elif (__GNUC__ >= 4) || (__clang_major__ >= 4)
2177# undef isnan 2610# undef isnan
2178# define isnan(x) \ 2611# define isnan(x) \
2179 (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \ 2612 (sizeof (x) == sizeof (long double) ? __builtin_isnan ((long double)(x)) : \
2180 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \ 2613 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
2181 __builtin_isnanf ((float)(x))) 2614 __builtin_isnan ((float)(x)))
2182# endif 2615# endif
2183# ifdef __cplusplus 2616# ifdef __cplusplus
2184# ifdef isnan 2617# if defined isnan || defined GNULIB_NAMESPACE
2185_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) 2618_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
2186# undef isnan 2619# undef isnan
2187_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan) 2620# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__ && __clang_major__ < 12) || (defined __FreeBSD__ && (__clang_major__ < 7 || __clang_major__ >= 11)) || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__)))
2621 /* This platform's <cmath> possibly defines isnan through a set of inline
2622 functions. */
2623_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool)
2624# define isnan rpl_isnan
2625# define GNULIB_NAMESPACE_LACKS_ISNAN 1
2626# else
2627_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool)
2628# endif
2188# endif 2629# endif
2189# else 2630# else
2190/* Ensure isnan is a macro. */ 2631/* Ensure isnan is a macro. */
@@ -2202,20 +2643,21 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
2202 2643
2203 2644
2204#if @GNULIB_SIGNBIT@ 2645#if @GNULIB_SIGNBIT@
2205# if @REPLACE_SIGNBIT_USING_GCC@ 2646# if (@REPLACE_SIGNBIT_USING_BUILTINS@ \
2647 && (!defined __cplusplus || __cplusplus < 201103))
2206# undef signbit 2648# undef signbit
2207 /* GCC 4.0 and newer provides three built-ins for signbit. */ 2649 /* GCC >= 4.0 and clang provide three built-ins for signbit. */
2208# define signbit(x) \ 2650# define signbit(x) \
2209 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ 2651 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \
2210 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ 2652 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \
2211 __builtin_signbitf (x)) 2653 __builtin_signbitf (x))
2212# endif 2654# endif
2213# if @REPLACE_SIGNBIT@ 2655# if @REPLACE_SIGNBIT@ && !GNULIB_defined_signbit
2214# undef signbit 2656# undef signbit
2215_GL_EXTERN_C int gl_signbitf (float arg); 2657_GL_EXTERN_C int gl_signbitf (float arg);
2216_GL_EXTERN_C int gl_signbitd (double arg); 2658_GL_EXTERN_C int gl_signbitd (double arg);
2217_GL_EXTERN_C int gl_signbitl (long double arg); 2659_GL_EXTERN_C int gl_signbitl (long double arg);
2218# if __GNUC__ >= 2 && !defined __STRICT_ANSI__ 2660# if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
2219# define _GL_NUM_UINT_WORDS(type) \ 2661# define _GL_NUM_UINT_WORDS(type) \
2220 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) 2662 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
2221# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf 2663# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
@@ -2253,12 +2695,21 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
2253 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ 2695 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
2254 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ 2696 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
2255 gl_signbitf (x)) 2697 gl_signbitf (x))
2698# define GNULIB_defined_signbit 1
2256# endif 2699# endif
2257# ifdef __cplusplus 2700# ifdef __cplusplus
2258# ifdef signbit 2701# if defined signbit || defined GNULIB_NAMESPACE
2259_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) 2702_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
2260# undef signbit 2703# undef signbit
2261_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit) 2704# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__)))
2705 /* This platform's <cmath> possibly defines signbit through a set of inline
2706 functions. */
2707_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool)
2708# define signbit rpl_signbit
2709# define GNULIB_NAMESPACE_LACKS_SIGNBIT 1
2710# else
2711_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, signbit, bool)
2712# endif
2262# endif 2713# endif
2263# endif 2714# endif
2264#elif defined GNULIB_POSIXCHECK 2715#elif defined GNULIB_POSIXCHECK
@@ -2272,4 +2723,5 @@ _GL_WARN_REAL_FLOATING_DECL (signbit);
2272_GL_INLINE_HEADER_END 2723_GL_INLINE_HEADER_END
2273 2724
2274#endif /* _@GUARD_PREFIX@_MATH_H */ 2725#endif /* _@GUARD_PREFIX@_MATH_H */
2726#endif /* _GL_INCLUDING_MATH_H */
2275#endif /* _@GUARD_PREFIX@_MATH_H */ 2727#endif /* _@GUARD_PREFIX@_MATH_H */
diff --git a/gl/mbrtowc-impl-utf8.h b/gl/mbrtowc-impl-utf8.h
new file mode 100644
index 00000000..4fdd65d8
--- /dev/null
+++ b/gl/mbrtowc-impl-utf8.h
@@ -0,0 +1,138 @@
1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
18
19/* This file contains the part of the body of the mbrtowc and mbrtoc32 functions
20 that handles the special case of the UTF-8 encoding. */
21
22 /* Cf. unistr/u8-mbtouc.c. */
23 unsigned char c = (unsigned char) p[0];
24
25 if (c < 0x80)
26 {
27 if (pwc != NULL)
28 *pwc = c;
29 res = (c == 0 ? 0 : 1);
30 goto success;
31 }
32 if (c >= 0xc2)
33 {
34 if (c < 0xe0)
35 {
36 if (m == 1)
37 goto incomplete;
38 else /* m >= 2 */
39 {
40 unsigned char c2 = (unsigned char) p[1];
41
42 if ((c2 ^ 0x80) < 0x40)
43 {
44 if (pwc != NULL)
45 *pwc = ((unsigned int) (c & 0x1f) << 6)
46 | (unsigned int) (c2 ^ 0x80);
47 res = 2;
48 goto success;
49 }
50 }
51 }
52 else if (c < 0xf0)
53 {
54 if (m == 1)
55 goto incomplete;
56 else
57 {
58 unsigned char c2 = (unsigned char) p[1];
59
60 if ((c2 ^ 0x80) < 0x40
61 && (c >= 0xe1 || c2 >= 0xa0)
62 && (c != 0xed || c2 < 0xa0))
63 {
64 if (m == 2)
65 goto incomplete;
66 else /* m >= 3 */
67 {
68 unsigned char c3 = (unsigned char) p[2];
69
70 if ((c3 ^ 0x80) < 0x40)
71 {
72 unsigned int wc =
73 (((unsigned int) (c & 0x0f) << 12)
74 | ((unsigned int) (c2 ^ 0x80) << 6)
75 | (unsigned int) (c3 ^ 0x80));
76
77 if (FITS_IN_CHAR_TYPE (wc))
78 {
79 if (pwc != NULL)
80 *pwc = wc;
81 res = 3;
82 goto success;
83 }
84 }
85 }
86 }
87 }
88 }
89 else if (c <= 0xf4)
90 {
91 if (m == 1)
92 goto incomplete;
93 else
94 {
95 unsigned char c2 = (unsigned char) p[1];
96
97 if ((c2 ^ 0x80) < 0x40
98 && (c >= 0xf1 || c2 >= 0x90)
99 && (c < 0xf4 || (/* c == 0xf4 && */ c2 < 0x90)))
100 {
101 if (m == 2)
102 goto incomplete;
103 else
104 {
105 unsigned char c3 = (unsigned char) p[2];
106
107 if ((c3 ^ 0x80) < 0x40)
108 {
109 if (m == 3)
110 goto incomplete;
111 else /* m >= 4 */
112 {
113 unsigned char c4 = (unsigned char) p[3];
114
115 if ((c4 ^ 0x80) < 0x40)
116 {
117 unsigned int wc =
118 (((unsigned int) (c & 0x07) << 18)
119 | ((unsigned int) (c2 ^ 0x80) << 12)
120 | ((unsigned int) (c3 ^ 0x80) << 6)
121 | (unsigned int) (c4 ^ 0x80));
122
123 if (FITS_IN_CHAR_TYPE (wc))
124 {
125 if (pwc != NULL)
126 *pwc = wc;
127 res = 4;
128 goto success;
129 }
130 }
131 }
132 }
133 }
134 }
135 }
136 }
137 }
138 goto invalid;
diff --git a/gl/mbrtowc-impl.h b/gl/mbrtowc-impl.h
new file mode 100644
index 00000000..e9c04ed7
--- /dev/null
+++ b/gl/mbrtowc-impl.h
@@ -0,0 +1,262 @@
1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
18
19/* This file contains the body of the mbrtowc and mbrtoc32 functions,
20 when GNULIB_defined_mbstate_t is defined. */
21
22 char *pstate = (char *)ps;
23
24 if (s == NULL)
25 {
26 pwc = NULL;
27 s = "";
28 n = 1;
29 }
30
31 if (n == 0)
32 return (size_t)(-2);
33
34 /* Here n > 0. */
35
36 if (pstate == NULL)
37 pstate = internal_state;
38
39 {
40 size_t nstate = pstate[0];
41 char buf[4];
42 const char *p;
43 size_t m;
44 enc_t enc;
45 int res;
46
47 switch (nstate)
48 {
49 case 0:
50 p = s;
51 m = n;
52 break;
53 case 3:
54 buf[2] = pstate[3];
55 FALLTHROUGH;
56 case 2:
57 buf[1] = pstate[2];
58 FALLTHROUGH;
59 case 1:
60 buf[0] = pstate[1];
61 p = buf;
62 m = nstate;
63 buf[m++] = s[0];
64 if (n >= 2 && m < 4)
65 {
66 buf[m++] = s[1];
67 if (n >= 3 && m < 4)
68 buf[m++] = s[2];
69 }
70 break;
71 default:
72 errno = EINVAL;
73 return (size_t)(-1);
74 }
75
76 /* Here m > 0. */
77
78 enc = locale_encoding_classification ();
79
80 if (enc == enc_utf8) /* UTF-8 */
81 {
82 /* Achieve
83 - multi-thread safety and
84 - the ability to produce wide character values > WCHAR_MAX
85 by not calling mbtowc() at all. */
86#include "mbrtowc-impl-utf8.h"
87 }
88 else
89 {
90 /* The hidden internal state of mbtowc would make this function not
91 multi-thread safe. Achieve multi-thread safety through a lock. */
92 wchar_t wc;
93 res = mbtowc_with_lock (&wc, p, m);
94
95 if (res >= 0)
96 {
97 if ((wc == 0) != (res == 0))
98 abort ();
99 if (pwc != NULL)
100 *pwc = wc;
101 goto success;
102 }
103
104 /* mbtowc does not distinguish between invalid and incomplete multibyte
105 sequences. But mbrtowc needs to make this distinction.
106 There are two possible approaches:
107 - Use iconv() and its return value.
108 - Use built-in knowledge about the possible encodings.
109 Given the low quality of implementation of iconv() on the systems
110 that lack mbrtowc(), we use the second approach.
111 The possible encodings are:
112 - 8-bit encodings,
113 - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
114 - UTF-8 (already handled above).
115 Use specialized code for each. */
116 if (m >= 4 || m >= MB_CUR_MAX)
117 goto invalid;
118 /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
119 switch (enc)
120 {
121 /* As a reference for this code, you can use the GNU libiconv
122 implementation. Look for uses of the RET_TOOFEW macro. */
123
124 case enc_eucjp: /* EUC-JP */
125 {
126 if (m == 1)
127 {
128 unsigned char c = (unsigned char) p[0];
129
130 if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
131 goto incomplete;
132 }
133 if (m == 2)
134 {
135 unsigned char c = (unsigned char) p[0];
136
137 if (c == 0x8f)
138 {
139 unsigned char c2 = (unsigned char) p[1];
140
141 if (c2 >= 0xa1 && c2 < 0xff)
142 goto incomplete;
143 }
144 }
145 goto invalid;
146 }
147
148 case enc_94: /* EUC-KR, GB2312, BIG5 */
149 {
150 if (m == 1)
151 {
152 unsigned char c = (unsigned char) p[0];
153
154 if (c >= 0xa1 && c < 0xff)
155 goto incomplete;
156 }
157 goto invalid;
158 }
159
160 case enc_euctw: /* EUC-TW */
161 {
162 if (m == 1)
163 {
164 unsigned char c = (unsigned char) p[0];
165
166 if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
167 goto incomplete;
168 }
169 else /* m == 2 || m == 3 */
170 {
171 unsigned char c = (unsigned char) p[0];
172
173 if (c == 0x8e)
174 goto incomplete;
175 }
176 goto invalid;
177 }
178
179 case enc_gb18030: /* GB18030 */
180 {
181 if (m == 1)
182 {
183 unsigned char c = (unsigned char) p[0];
184
185 if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
186 goto incomplete;
187 }
188 else /* m == 2 || m == 3 */
189 {
190 unsigned char c = (unsigned char) p[0];
191
192 if (c >= 0x90 && c <= 0xe3)
193 {
194 unsigned char c2 = (unsigned char) p[1];
195
196 if (c2 >= 0x30 && c2 <= 0x39)
197 {
198 if (m == 2)
199 goto incomplete;
200 else /* m == 3 */
201 {
202 unsigned char c3 = (unsigned char) p[2];
203
204 if (c3 >= 0x81 && c3 <= 0xfe)
205 goto incomplete;
206 }
207 }
208 }
209 }
210 goto invalid;
211 }
212
213 case enc_sjis: /* SJIS */
214 {
215 if (m == 1)
216 {
217 unsigned char c = (unsigned char) p[0];
218
219 if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
220 || (c >= 0xf0 && c <= 0xf9))
221 goto incomplete;
222 }
223 goto invalid;
224 }
225
226 default:
227 /* An unknown multibyte encoding. */
228 goto incomplete;
229 }
230 }
231
232 success:
233 /* res >= 0 is the corrected return value of
234 mbtowc_with_lock (&wc, p, m). */
235 if (nstate >= (res > 0 ? res : 1))
236 abort ();
237 res -= nstate;
238 pstate[0] = 0;
239 return res;
240
241 incomplete:
242 {
243 size_t k = nstate;
244 /* Here 0 <= k < m < 4. */
245 pstate[++k] = s[0];
246 if (k < m)
247 {
248 pstate[++k] = s[1];
249 if (k < m)
250 pstate[++k] = s[2];
251 }
252 if (k != m)
253 abort ();
254 }
255 pstate[0] = m;
256 return (size_t)(-2);
257
258 invalid:
259 errno = EILSEQ;
260 /* The conversion state is undefined, says POSIX. */
261 return (size_t)(-1);
262 }
diff --git a/gl/mbrtowc.c b/gl/mbrtowc.c
index 5ee44aea..c1a689a2 100644
--- a/gl/mbrtowc.c
+++ b/gl/mbrtowc.c
@@ -1,19 +1,19 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -21,314 +21,66 @@
21#include <wchar.h> 21#include <wchar.h>
22 22
23#if GNULIB_defined_mbstate_t 23#if GNULIB_defined_mbstate_t
24/* Implement mbrtowc() on top of mbtowc(). */ 24/* Implement mbrtowc() on top of mbtowc() for the non-UTF-8 locales
25 and directly for the UTF-8 locales. */
25 26
26# include <errno.h> 27# include <errno.h>
28# include <stdint.h>
27# include <stdlib.h> 29# include <stdlib.h>
28 30
29# include "localcharset.h" 31# if defined _WIN32 && !defined __CYGWIN__
30# include "streq.h"
31# include "verify.h"
32 32
33# define WIN32_LEAN_AND_MEAN /* avoid including junk */
34# include <windows.h>
33 35
34verify (sizeof (mbstate_t) >= 4); 36# elif HAVE_PTHREAD_API
35 37
36static char internal_state[4]; 38# include <pthread.h>
39# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
40# include <threads.h>
41# pragma weak thrd_exit
42# define c11_threads_in_use() (thrd_exit != NULL)
43# else
44# define c11_threads_in_use() 0
45# endif
37 46
38size_t 47# elif HAVE_THREADS_H
39mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
40{
41 char *pstate = (char *)ps;
42
43 if (s == NULL)
44 {
45 pwc = NULL;
46 s = "";
47 n = 1;
48 }
49
50 if (n == 0)
51 return (size_t)(-2);
52 48
53 /* Here n > 0. */ 49# include <threads.h>
54 50
55 if (pstate == NULL)
56 pstate = internal_state;
57
58 {
59 size_t nstate = pstate[0];
60 char buf[4];
61 const char *p;
62 size_t m;
63
64 switch (nstate)
65 {
66 case 0:
67 p = s;
68 m = n;
69 break;
70 case 3:
71 buf[2] = pstate[3];
72 /*FALLTHROUGH*/
73 case 2:
74 buf[1] = pstate[2];
75 /*FALLTHROUGH*/
76 case 1:
77 buf[0] = pstate[1];
78 p = buf;
79 m = nstate;
80 buf[m++] = s[0];
81 if (n >= 2 && m < 4)
82 {
83 buf[m++] = s[1];
84 if (n >= 3 && m < 4)
85 buf[m++] = s[2];
86 }
87 break;
88 default:
89 errno = EINVAL;
90 return (size_t)(-1);
91 }
92
93 /* Here m > 0. */
94
95# if __GLIBC__ || defined __UCLIBC__
96 /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
97 mbtowc (NULL, NULL, 0);
98# endif 51# endif
99 {
100 int res = mbtowc (pwc, p, m);
101
102 if (res >= 0)
103 {
104 if (pwc != NULL && ((*pwc == 0) != (res == 0)))
105 abort ();
106 if (nstate >= (res > 0 ? res : 1))
107 abort ();
108 res -= nstate;
109 pstate[0] = 0;
110 return res;
111 }
112
113 /* mbtowc does not distinguish between invalid and incomplete multibyte
114 sequences. But mbrtowc needs to make this distinction.
115 There are two possible approaches:
116 - Use iconv() and its return value.
117 - Use built-in knowledge about the possible encodings.
118 Given the low quality of implementation of iconv() on the systems that
119 lack mbrtowc(), we use the second approach.
120 The possible encodings are:
121 - 8-bit encodings,
122 - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
123 - UTF-8.
124 Use specialized code for each. */
125 if (m >= 4 || m >= MB_CUR_MAX)
126 goto invalid;
127 /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
128 {
129 const char *encoding = locale_charset ();
130
131 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
132 {
133 /* Cf. unistr/u8-mblen.c. */
134 unsigned char c = (unsigned char) p[0];
135
136 if (c >= 0xc2)
137 {
138 if (c < 0xe0)
139 {
140 if (m == 1)
141 goto incomplete;
142 }
143 else if (c < 0xf0)
144 {
145 if (m == 1)
146 goto incomplete;
147 if (m == 2)
148 {
149 unsigned char c2 = (unsigned char) p[1];
150
151 if ((c2 ^ 0x80) < 0x40
152 && (c >= 0xe1 || c2 >= 0xa0)
153 && (c != 0xed || c2 < 0xa0))
154 goto incomplete;
155 }
156 }
157 else if (c <= 0xf4)
158 {
159 if (m == 1)
160 goto incomplete;
161 else /* m == 2 || m == 3 */
162 {
163 unsigned char c2 = (unsigned char) p[1];
164
165 if ((c2 ^ 0x80) < 0x40
166 && (c >= 0xf1 || c2 >= 0x90)
167 && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
168 {
169 if (m == 2)
170 goto incomplete;
171 else /* m == 3 */
172 {
173 unsigned char c3 = (unsigned char) p[2];
174
175 if ((c3 ^ 0x80) < 0x40)
176 goto incomplete;
177 }
178 }
179 }
180 }
181 }
182 goto invalid;
183 }
184
185 /* As a reference for this code, you can use the GNU libiconv
186 implementation. Look for uses of the RET_TOOFEW macro. */
187
188 if (STREQ_OPT (encoding,
189 "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
190 {
191 if (m == 1)
192 {
193 unsigned char c = (unsigned char) p[0];
194
195 if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
196 goto incomplete;
197 }
198 if (m == 2)
199 {
200 unsigned char c = (unsigned char) p[0];
201
202 if (c == 0x8f)
203 {
204 unsigned char c2 = (unsigned char) p[1];
205
206 if (c2 >= 0xa1 && c2 < 0xff)
207 goto incomplete;
208 }
209 }
210 goto invalid;
211 }
212 if (STREQ_OPT (encoding,
213 "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
214 || STREQ_OPT (encoding,
215 "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
216 || STREQ_OPT (encoding,
217 "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
218 {
219 if (m == 1)
220 {
221 unsigned char c = (unsigned char) p[0];
222
223 if (c >= 0xa1 && c < 0xff)
224 goto incomplete;
225 }
226 goto invalid;
227 }
228 if (STREQ_OPT (encoding,
229 "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
230 {
231 if (m == 1)
232 {
233 unsigned char c = (unsigned char) p[0];
234
235 if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
236 goto incomplete;
237 }
238 else /* m == 2 || m == 3 */
239 {
240 unsigned char c = (unsigned char) p[0];
241
242 if (c == 0x8e)
243 goto incomplete;
244 }
245 goto invalid;
246 }
247 if (STREQ_OPT (encoding,
248 "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
249 {
250 if (m == 1)
251 {
252 unsigned char c = (unsigned char) p[0];
253 52
254 if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) 53# include "attribute.h"
255 goto incomplete; 54# include "lc-charset-dispatch.h"
256 } 55# include "mbtowc-lock.h"
257 else /* m == 2 || m == 3 */
258 {
259 unsigned char c = (unsigned char) p[0];
260
261 if (c >= 0x90 && c <= 0xe3)
262 {
263 unsigned char c2 = (unsigned char) p[1];
264
265 if (c2 >= 0x30 && c2 <= 0x39)
266 {
267 if (m == 2)
268 goto incomplete;
269 else /* m == 3 */
270 {
271 unsigned char c3 = (unsigned char) p[2];
272
273 if (c3 >= 0x81 && c3 <= 0xfe)
274 goto incomplete;
275 }
276 }
277 }
278 }
279 goto invalid;
280 }
281 if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
282 {
283 if (m == 1)
284 {
285 unsigned char c = (unsigned char) p[0];
286 56
287 if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) 57static_assert (sizeof (mbstate_t) >= 4);
288 || (c >= 0xf0 && c <= 0xf9)) 58static char internal_state[4];
289 goto incomplete;
290 }
291 goto invalid;
292 }
293
294 /* An unknown multibyte encoding. */
295 goto incomplete;
296 }
297
298 incomplete:
299 {
300 size_t k = nstate;
301 /* Here 0 <= k < m < 4. */
302 pstate[++k] = s[0];
303 if (k < m)
304 {
305 pstate[++k] = s[1];
306 if (k < m)
307 pstate[++k] = s[2];
308 }
309 if (k != m)
310 abort ();
311 }
312 pstate[0] = m;
313 return (size_t)(-2);
314 59
315 invalid: 60size_t
316 errno = EILSEQ; 61mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
317 /* The conversion state is undefined, says POSIX. */ 62{
318 return (size_t)(-1); 63# define FITS_IN_CHAR_TYPE(wc) ((wc) <= WCHAR_MAX)
319 } 64# include "mbrtowc-impl.h"
320 }
321} 65}
322 66
323#else 67#else
324/* Override the system's mbrtowc() function. */ 68/* Override the system's mbrtowc() function. */
325 69
70# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
71# include "hard-locale.h"
72# include <locale.h>
73# endif
74
326# undef mbrtowc 75# undef mbrtowc
327 76
328size_t 77size_t
329rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) 78rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
330{ 79{
331# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG 80 size_t ret;
81 wchar_t wc;
82
83# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
332 if (s == NULL) 84 if (s == NULL)
333 { 85 {
334 pwc = NULL; 86 pwc = NULL;
@@ -337,6 +89,14 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
337 } 89 }
338# endif 90# endif
339 91
92# if MBRTOWC_EMPTY_INPUT_BUG
93 if (n == 0)
94 return (size_t) -2;
95# endif
96
97 if (! pwc)
98 pwc = &wc;
99
340# if MBRTOWC_RETVAL_BUG 100# if MBRTOWC_RETVAL_BUG
341 { 101 {
342 static mbstate_t internal_state; 102 static mbstate_t internal_state;
@@ -352,8 +112,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
352 size_t count = 0; 112 size_t count = 0;
353 for (; n > 0; s++, n--) 113 for (; n > 0; s++, n--)
354 { 114 {
355 wchar_t wc; 115 ret = mbrtowc (&wc, s, 1, ps);
356 size_t ret = mbrtowc (&wc, s, 1, ps);
357 116
358 if (ret == (size_t)(-1)) 117 if (ret == (size_t)(-1))
359 return (size_t)(-1); 118 return (size_t)(-1);
@@ -361,8 +120,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
361 if (ret != (size_t)(-2)) 120 if (ret != (size_t)(-2))
362 { 121 {
363 /* The multibyte character has been completed. */ 122 /* The multibyte character has been completed. */
364 if (pwc != NULL) 123 *pwc = wc;
365 *pwc = wc;
366 return (wc == 0 ? 0 : count); 124 return (wc == 0 ? 0 : count);
367 } 125 }
368 } 126 }
@@ -371,32 +129,29 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
371 } 129 }
372# endif 130# endif
373 131
374# if MBRTOWC_NUL_RETVAL_BUG 132# if MBRTOWC_STORES_INCOMPLETE_BUG
375 { 133 ret = mbrtowc (&wc, s, n, ps);
376 wchar_t wc; 134 if (ret < (size_t) -2 && pwc != NULL)
377 size_t ret = mbrtowc (&wc, s, n, ps); 135 *pwc = wc;
378
379 if (ret != (size_t)(-1) && ret != (size_t)(-2))
380 {
381 if (pwc != NULL)
382 *pwc = wc;
383 if (wc == 0)
384 ret = 0;
385 }
386 return ret;
387 }
388# else 136# else
389 { 137 ret = mbrtowc (pwc, s, n, ps);
390# if MBRTOWC_NULL_ARG1_BUG 138# endif
391 wchar_t dummy;
392 139
393 if (pwc == NULL) 140# if MBRTOWC_NUL_RETVAL_BUG
394 pwc = &dummy; 141 if (ret < (size_t) -2 && !*pwc)
395# endif 142 return 0;
143# endif
396 144
397 return mbrtowc (pwc, s, n, ps); 145# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
398 } 146 if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
147 {
148 unsigned char uc = *s;
149 *pwc = uc;
150 return 1;
151 }
399# endif 152# endif
153
154 return ret;
400} 155}
401 156
402#endif 157#endif
diff --git a/gl/mbsinit.c b/gl/mbsinit.c
index 26fbb7fa..6e600798 100644
--- a/gl/mbsinit.c
+++ b/gl/mbsinit.c
@@ -1,38 +1,27 @@
1/* Test for initial conversion state. 1/* Test for initial conversion state.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
20/* Specification. */ 20/* Specification. */
21#include <wchar.h> 21#include <wchar.h>
22 22
23#include "verify.h"
24 23
25#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 24#if GNULIB_defined_mbstate_t
26
27/* On native Windows, 'mbstate_t' is defined as 'int'. */
28
29int
30mbsinit (const mbstate_t *ps)
31{
32 return ps == NULL || *ps == 0;
33}
34
35#else
36 25
37/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() 26/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
38 and wcrtomb(), wcsrtombs(). 27 and wcrtomb(), wcsrtombs().
@@ -45,10 +34,11 @@ mbsinit (const mbstate_t *ps)
45 We define the meaning of mbstate_t as follows: 34 We define the meaning of mbstate_t as follows:
46 - In mb -> wc direction, mbstate_t's first byte contains the number of 35 - In mb -> wc direction, mbstate_t's first byte contains the number of
47 buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. 36 buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
37 See mbrtowc.c.
48 - In wc -> mb direction, mbstate_t contains no information. In other 38 - In wc -> mb direction, mbstate_t contains no information. In other
49 words, it is always in the initial state. */ 39 words, it is always in the initial state. */
50 40
51verify (sizeof (mbstate_t) >= 4); 41static_assert (sizeof (mbstate_t) >= 4);
52 42
53int 43int
54mbsinit (const mbstate_t *ps) 44mbsinit (const mbstate_t *ps)
@@ -58,4 +48,22 @@ mbsinit (const mbstate_t *ps)
58 return pstate == NULL || pstate[0] == 0; 48 return pstate == NULL || pstate[0] == 0;
59} 49}
60 50
51#else
52
53int
54mbsinit (const mbstate_t *ps)
55{
56# if defined _WIN32 && !defined __CYGWIN__
57 /* Native Windows. */
58 /* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4 bytes matter.
59 On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined as
60 an 8-byte struct, of which the first 4 bytes matter. */
61 return ps == NULL || *(const unsigned int *)ps == 0;
62# else
63 /* Minix, HP-UX 11.00, Solaris 2.6, Interix, ... */
64 /* Maybe this definition works, maybe not... */
65 return ps == NULL || *(const char *)ps == 0;
66# endif
67}
68
61#endif 69#endif
diff --git a/gl/mbtowc-impl.h b/gl/mbtowc-impl.h
index 767ab397..39b977be 100644
--- a/gl/mbtowc-impl.h
+++ b/gl/mbtowc-impl.h
@@ -1,19 +1,19 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* We don't need a static internal state, because the encoding is not state 18/* We don't need a static internal state, because the encoding is not state
19 dependent, and when mbrtowc returns (size_t)(-2). we throw the result 19 dependent, and when mbrtowc returns (size_t)(-2). we throw the result
diff --git a/gl/mbtowc-lock.c b/gl/mbtowc-lock.c
new file mode 100644
index 00000000..6ca6e10f
--- /dev/null
+++ b/gl/mbtowc-lock.c
@@ -0,0 +1,150 @@
1/* Return the internal lock used by mbrtowc and mbrtoc32.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
18
19#include <config.h>
20
21/* When it is known that the gl_get_mbtowc_lock function is defined
22 by a dependency library, it should not be defined here. */
23#if OMIT_MBTOWC_LOCK
24
25/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */
27typedef int dummy;
28
29#else
30
31/* This file defines the internal lock used by mbrtowc and mbrtoc32.
32 It is a separate compilation unit, so that only one copy of it is
33 present when linking statically. */
34
35/* Prohibit renaming this symbol. */
36# undef gl_get_mbtowc_lock
37
38/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */
40# ifndef DLL_EXPORTED
41# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport)
46# else
47# define DLL_EXPORTED
48# endif
49# endif
50
51# if defined _WIN32 && !defined __CYGWIN__
52
53# define WIN32_LEAN_AND_MEAN /* avoid including junk */
54# include <windows.h>
55
56# include "windows-initguard.h"
57
58/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
59 because the latter is not guaranteed to be a stable ABI in the future. */
60
61/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void);
63
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock;
66
67/* Returns the internal lock used by mbrtowc and mbrtoc32. */
68CRITICAL_SECTION *
69gl_get_mbtowc_lock (void)
70{
71 if (!guard.done)
72 {
73 if (InterlockedIncrement (&guard.started) == 0)
74 {
75 /* This thread is the first one to need the lock. Initialize it. */
76 InitializeCriticalSection (&lock);
77 guard.done = 1;
78 }
79 else
80 {
81 /* Don't let guard.started grow and wrap around. */
82 InterlockedDecrement (&guard.started);
83 /* Yield the CPU while waiting for another thread to finish
84 initializing this mutex. */
85 while (!guard.done)
86 Sleep (0);
87 }
88 }
89 return &lock;
90}
91
92# elif HAVE_PTHREAD_API
93
94# include <pthread.h>
95
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97
98/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void);
100
101/* Returns the internal lock used by mbrtowc and mbrtoc32. */
102pthread_mutex_t *
103gl_get_mbtowc_lock (void)
104{
105 return &mutex;
106}
107
108# elif HAVE_THREADS_H
109
110# include <threads.h>
111# include <stdlib.h>
112
113static int volatile init_needed = 1;
114static once_flag init_once = ONCE_FLAG_INIT;
115static mtx_t mutex;
116
117static void
118atomic_init (void)
119{
120 if (mtx_init (&mutex, mtx_plain) != thrd_success)
121 abort ();
122 init_needed = 0;
123}
124
125/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_mbtowc_lock (void);
127
128/* Returns the internal lock used by mbrtowc and mbrtoc32. */
129mtx_t *
130gl_get_mbtowc_lock (void)
131{
132 if (init_needed)
133 call_once (&init_once, atomic_init);
134 return &mutex;
135}
136
137# endif
138
139# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
140/* Make sure the '__declspec(dllimport)' in mbrtowc.c and mbrtoc32.c does not
141 cause a link failure when no DLLs are involved. */
142# if defined _WIN64 || defined _LP64
143# define IMP(x) __imp_##x
144# else
145# define IMP(x) _imp__##x
146# endif
147void * IMP(gl_get_mbtowc_lock) = &gl_get_mbtowc_lock;
148# endif
149
150#endif
diff --git a/gl/mbtowc-lock.h b/gl/mbtowc-lock.h
new file mode 100644
index 00000000..2dc22ace
--- /dev/null
+++ b/gl/mbtowc-lock.h
@@ -0,0 +1,125 @@
1/* Use the internal lock used by mbrtowc and mbrtoc32.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
18
19/* Use a lock, so that no two threads can invoke mbtowc at the same time. */
20
21static inline int
22mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
23{
24 /* Put the hidden internal state of mbtowc into its initial state.
25 This is needed at least with glibc, uClibc, and MSVC CRT.
26 See <https://sourceware.org/bugzilla/show_bug.cgi?id=9674>. */
27 mbtowc (NULL, NULL, 0);
28
29 return mbtowc (pwc, p, m);
30}
31
32/* Prohibit renaming this symbol. */
33#undef gl_get_mbtowc_lock
34
35#if GNULIB_MBRTOWC_SINGLE_THREAD
36
37/* All uses of this function are in a single thread. No locking needed. */
38
39static int
40mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
41{
42 return mbtowc_unlocked (pwc, p, m);
43}
44
45#elif defined _WIN32 && !defined __CYGWIN__
46
47extern __declspec(dllimport) CRITICAL_SECTION *gl_get_mbtowc_lock (void);
48
49static int
50mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
51{
52 CRITICAL_SECTION *lock = gl_get_mbtowc_lock ();
53 int ret;
54
55 EnterCriticalSection (lock);
56 ret = mbtowc_unlocked (pwc, p, m);
57 LeaveCriticalSection (lock);
58
59 return ret;
60}
61
62#elif HAVE_PTHREAD_API /* AIX, IRIX, Cygwin */
63
64extern
65# if defined _WIN32 || defined __CYGWIN__
66 __declspec(dllimport)
67# endif
68 pthread_mutex_t *gl_get_mbtowc_lock (void);
69
70# if HAVE_WEAK_SYMBOLS /* IRIX */
71
72 /* Avoid the need to link with '-lpthread'. */
73# pragma weak pthread_mutex_lock
74# pragma weak pthread_mutex_unlock
75
76 /* Determine whether libpthread is in use. */
77# pragma weak pthread_mutexattr_gettype
78 /* See the comments in lock.h. */
79# define pthread_in_use() \
80 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
81
82# else
83# define pthread_in_use() 1
84# endif
85
86static int
87mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
88{
89 if (pthread_in_use())
90 {
91 pthread_mutex_t *lock = gl_get_mbtowc_lock ();
92 int ret;
93
94 if (pthread_mutex_lock (lock))
95 abort ();
96 ret = mbtowc_unlocked (pwc, p, m);
97 if (pthread_mutex_unlock (lock))
98 abort ();
99
100 return ret;
101 }
102 else
103 return mbtowc_unlocked (pwc, p, m);
104}
105
106#elif HAVE_THREADS_H
107
108extern mtx_t *gl_get_mbtowc_lock (void);
109
110static int
111mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
112{
113 mtx_t *lock = gl_get_mbtowc_lock ();
114 int ret;
115
116 if (mtx_lock (lock) != thrd_success)
117 abort ();
118 ret = mbtowc_unlocked (pwc, p, m);
119 if (mtx_unlock (lock) != thrd_success)
120 abort ();
121
122 return ret;
123}
124
125#endif
diff --git a/gl/mbtowc.c b/gl/mbtowc.c
index 632f2e1d..8d9b06d2 100644
--- a/gl/mbtowc.c
+++ b/gl/mbtowc.c
@@ -1,19 +1,19 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/memchr.c b/gl/memchr.c
index 3db38a94..8e955793 100644
--- a/gl/memchr.c
+++ b/gl/memchr.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2013 1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2023
2 Free Software Foundation, Inc. 2 Free Software Foundation, Inc.
3 3
4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se), 4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
@@ -7,21 +7,21 @@
7 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), 7 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
8 and implemented by Roland McGrath (roland@ai.mit.edu). 8 and implemented by Roland McGrath (roland@ai.mit.edu).
9 9
10NOTE: The canonical source of this file is maintained with the GNU C Library. 10 NOTE: The canonical source of this file is maintained with the GNU C Library.
11Bugs can be reported to bug-glibc@prep.ai.mit.edu. 11 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
12 12
13This program is free software: you can redistribute it and/or modify it 13 This file is free software: you can redistribute it and/or modify
14under the terms of the GNU General Public License as published by the 14 it under the terms of the GNU Lesser General Public License as
15Free Software Foundation; either version 3 of the License, or any 15 published by the Free Software Foundation; either version 2.1 of the
16later version. 16 License, or (at your option) any later version.
17 17
18This program is distributed in the hope that it will be useful, 18 This file is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of 19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details. 21 GNU Lesser General Public License for more details.
22 22
23You should have received a copy of the GNU General Public License 23 You should have received a copy of the GNU Lesser General Public License
24along with this program. If not, see <http://www.gnu.org/licenses/>. */ 24 along with this program. If not, see <https://www.gnu.org/licenses/>. */
25 25
26#ifndef _LIBC 26#ifndef _LIBC
27# include <config.h> 27# include <config.h>
diff --git a/gl/memchr.valgrind b/gl/memchr.valgrind
index 60f247e1..97690f2c 100644
--- a/gl/memchr.valgrind
+++ b/gl/memchr.valgrind
@@ -1,4 +1,20 @@
1# Suppress a valgrind message about use of uninitialized memory in memchr(). 1# Suppress a valgrind message about use of uninitialized memory in memchr().
2
3# Copyright (C) 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as
7# published by the Free Software Foundation; either version 2.1 of the
8# License, or (at your option) any later version.
9#
10# This file is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this program. If not, see <https://www.gnu.org/licenses/>.
17
2# POSIX states that when the character is found, memchr must not read extra 18# POSIX states that when the character is found, memchr must not read extra
3# bytes in an overestimated length (for example, where memchr is used to 19# bytes in an overestimated length (for example, where memchr is used to
4# implement strnlen). However, we use a safe word read to provide a speedup. 20# implement strnlen). However, we use a safe word read to provide a speedup.
diff --git a/gl/minmax.h b/gl/minmax.h
new file mode 100644
index 00000000..1fbfc661
--- /dev/null
+++ b/gl/minmax.h
@@ -0,0 +1,60 @@
1/* MIN, MAX macros.
2 Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2023 Free Software
3 Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _MINMAX_H
19#define _MINMAX_H
20
21/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
22 (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
23 MIN, MAX macro redefinitions on some systems; the workaround is to
24 #include this file as the last one among the #include list. */
25
26/* Before we define the following symbols we get the <limits.h> file
27 since otherwise we get redefinitions on some systems if <limits.h> is
28 included after this file. Likewise for <sys/param.h>.
29 If more than one of these system headers define MIN and MAX, pick just
30 one of the headers (because the definitions most likely are the same). */
31#if HAVE_MINMAX_IN_LIMITS_H
32# include <limits.h>
33#elif HAVE_MINMAX_IN_SYS_PARAM_H
34# include <sys/param.h>
35#endif
36
37/* Note: MIN and MAX should be used with two arguments of the
38 same type. They might not return the minimum and maximum of their two
39 arguments, if the arguments have different types or have unusual
40 floating-point values. For example, on a typical host with 32-bit 'int',
41 64-bit 'long long', and 64-bit IEEE 754 'double' types:
42
43 MAX (-1, 2147483648) returns 4294967295.
44 MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
45 MAX (NaN, 0.0) returns 0.0.
46 MAX (+0.0, -0.0) returns -0.0.
47
48 and in each case the answer is in some sense bogus. */
49
50/* MAX(a,b) returns the maximum of A and B. */
51#ifndef MAX
52# define MAX(a,b) ((a) > (b) ? (a) : (b))
53#endif
54
55/* MIN(a,b) returns the minimum of A and B. */
56#ifndef MIN
57# define MIN(a,b) ((a) < (b) ? (a) : (b))
58#endif
59
60#endif /* _MINMAX_H */
diff --git a/gl/mktime-internal.h b/gl/mktime-internal.h
index 4287acf4..709c36bd 100644
--- a/gl/mktime-internal.h
+++ b/gl/mktime-internal.h
@@ -1,4 +1,79 @@
1#include <time.h> 1/* Internals of mktime and related functions
2time_t mktime_internal (struct tm *, 2 Copyright 2016-2023 Free Software Foundation, Inc.
3 struct tm * (*) (time_t const *, struct tm *), 3 This file is part of the GNU C Library.
4 time_t *); 4 Contributed by Paul Eggert <eggert@cs.ucla.edu>.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#ifndef _LIBC
21# include <time.h>
22#endif
23
24/* mktime_offset_t is a signed type wide enough to hold a UTC offset
25 in seconds, and used as part of the type of the offset-guess
26 argument to mktime_internal. In Glibc, it is always long int.
27 When in Gnulib, use time_t on platforms where time_t
28 is signed, to be compatible with platforms like BeOS that export
29 this implementation detail of mktime. On platforms where time_t is
30 unsigned, GNU and POSIX code can assume 'int' is at least 32 bits
31 which is wide enough for a UTC offset. */
32#ifdef _LIBC
33typedef long int mktime_offset_t;
34#elif defined TIME_T_IS_SIGNED
35typedef time_t mktime_offset_t;
36#else
37typedef int mktime_offset_t;
38#endif
39
40/* The source code uses identifiers like __time64_t for glibc
41 timestamps that can contain 64-bit values even when time_t is only
42 32 bits. These are just macros for the ordinary identifiers unless
43 compiling within glibc when time_t is 32 bits. */
44#if ! (defined _LIBC && __TIMESIZE != 64)
45# undef __time64_t
46# define __time64_t time_t
47# define __gmtime64_r __gmtime_r
48# define __localtime64_r __localtime_r
49# define __mktime64 mktime
50# define __timegm64 timegm
51#endif
52
53#ifndef _LIBC
54
55/* Although glibc source code uses leading underscores, Gnulib wants
56 ordinary names.
57
58 Portable standalone applications should supply a <time.h> that
59 declares a POSIX-compliant localtime_r, for the benefit of older
60 implementations that lack localtime_r or have a nonstandard one.
61 Similarly for gmtime_r. See the gnulib time_r module for one way
62 to implement this. */
63
64# undef __gmtime_r
65# undef __localtime_r
66# define __gmtime_r gmtime_r
67# define __localtime_r localtime_r
68
69# define __mktime_internal mktime_internal
70
71#endif
72
73/* Subroutine of mktime. Return the time_t representation of TP and
74 normalize TP, given that a struct tm * maps to a time_t as performed
75 by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */
76extern __time64_t __mktime_internal (struct tm *tp,
77 struct tm *(*func) (__time64_t const *,
78 struct tm *),
79 mktime_offset_t *offset) attribute_hidden;
diff --git a/gl/mktime.c b/gl/mktime.c
index e660a23c..94a4320e 100644
--- a/gl/mktime.c
+++ b/gl/mktime.c
@@ -1,28 +1,37 @@
1/* Convert a 'struct tm' to a time_t value. 1/* Convert a 'struct tm' to a time_t value.
2 Copyright (C) 1993-2013 Free Software Foundation, Inc. 2 Copyright (C) 1993-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@twinsun.com>. 4 Contributed by Paul Eggert <eggert@twinsun.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20/* Define this to have a standalone program to test this implementation of 20/* The following macros influence what gets defined when this file is compiled:
21 mktime. */ 21
22/* #define DEBUG 1 */ 22 Macro/expression Which gnulib module This compilation unit
23 should define
24
25 _LIBC (glibc proper) mktime
26
27 NEED_MKTIME_WORKING mktime rpl_mktime
28 || NEED_MKTIME_WINDOWS
29
30 NEED_MKTIME_INTERNAL mktime-internal mktime_internal
31 */
23 32
24#ifndef _LIBC 33#ifndef _LIBC
25# include <config.h> 34# include <libc-config.h>
26#endif 35#endif
27 36
28/* Assume that leap seconds are possible, unless told otherwise. 37/* Assume that leap seconds are possible, unless told otherwise.
@@ -34,115 +43,123 @@
34 43
35#include <time.h> 44#include <time.h>
36 45
46#include <errno.h>
37#include <limits.h> 47#include <limits.h>
48#include <stdbool.h>
49#include <stdlib.h>
50#include <string.h>
51
52#include <intprops.h>
53#include <verify.h>
54
55#ifndef NEED_MKTIME_INTERNAL
56# define NEED_MKTIME_INTERNAL 0
57#endif
58#ifndef NEED_MKTIME_WINDOWS
59# define NEED_MKTIME_WINDOWS 0
60#endif
61#ifndef NEED_MKTIME_WORKING
62# define NEED_MKTIME_WORKING 0
63#endif
64
65#include "mktime-internal.h"
38 66
39#include <string.h> /* For the real memcpy prototype. */ 67#if !defined _LIBC && (NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS)
40 68static void
41#if DEBUG 69my_tzset (void)
42# include <stdio.h> 70{
43# include <stdlib.h> 71# if NEED_MKTIME_WINDOWS
44/* Make it work even if the system's libc has its own mktime routine. */ 72 /* Rectify the value of the environment variable TZ.
45# undef mktime 73 There are four possible kinds of such values:
46# define mktime my_mktime 74 - Traditional US time zone names, e.g. "PST8PDT". Syntax: see
47#endif /* DEBUG */ 75 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset>
48 76 - Time zone names based on geography, that contain one or more
49/* Some of the code in this file assumes that signed integer overflow 77 slashes, e.g. "Europe/Moscow".
50 silently wraps around. This assumption can't easily be programmed 78 - Time zone names based on geography, without slashes, e.g.
51 around, nor can it be checked for portably at compile-time or 79 "Singapore".
52 easily eliminated at run-time. 80 - Time zone names that contain explicit DST rules. Syntax: see
53 81 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03>
54 Define WRAPV to 1 if the assumption is valid and if 82 The Microsoft CRT understands only the first kind. It produces incorrect
55 #pragma GCC optimize ("wrapv") 83 results if the value of TZ is of the other kinds.
56 does not trigger GCC bug 51793 84 But in a Cygwin environment, /etc/profile.d/tzset.sh sets TZ to a value
57 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>. 85 of the second kind for most geographies, or of the first kind in a few
58 Otherwise, define it to 0; this forces the use of slower code that, 86 other geographies. If it is of the second kind, neutralize it. For the
59 while not guaranteed by the C Standard, works on all production 87 Microsoft CRT, an absent or empty TZ means the time zone that the user
60 platforms that we know about. */ 88 has set in the Windows Control Panel.
61#ifndef WRAPV 89 If the value of TZ is of the third or fourth kind -- Cygwin programs
62# if (((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) \ 90 understand these syntaxes as well --, it does not matter whether we
63 && defined __GLIBC__) 91 neutralize it or not, since these values occur only when a Cygwin user
64# pragma GCC optimize ("wrapv") 92 has set TZ explicitly; this case is 1. rare and 2. under the user's
65# define WRAPV 1 93 responsibility. */
94 const char *tz = getenv ("TZ");
95 if (tz != NULL && strchr (tz, '/') != NULL)
96 _putenv ("TZ=");
66# else 97# else
67# define WRAPV 0 98 tzset ();
68# endif 99# endif
100}
101# undef __tzset
102# define __tzset() my_tzset ()
69#endif 103#endif
70 104
71/* Verify a requirement at compile-time (unlike assert, which is runtime). */ 105#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL
72#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } 106
107/* A signed type that can represent an integer number of years
108 multiplied by four times the number of seconds in a year. It is
109 needed when converting a tm_year value times the number of seconds
110 in a year. The factor of four comes because these products need
111 to be subtracted from each other, and sometimes with an offset
112 added to them, and then with another timestamp added, without
113 worrying about overflow.
73 114
74/* A signed type that is at least one bit wider than int. */ 115 Much of the code uses long_int to represent __time64_t values, to
75#if INT_MAX <= LONG_MAX / 2 116 lessen the hassle of dealing with platforms where __time64_t is
117 unsigned, and because long_int should suffice to represent all
118 __time64_t values that mktime can generate even on platforms where
119 __time64_t is wider than the int components of struct tm. */
120
121#if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60
76typedef long int long_int; 122typedef long int long_int;
77#else 123#else
78typedef long long int long_int; 124typedef long long int long_int;
79#endif 125#endif
80verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2); 126verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60);
81 127
82/* Shift A right by B bits portably, by dividing A by 2**B and 128/* Shift A right by B bits portably, by dividing A by 2**B and
83 truncating towards minus infinity. A and B should be free of side 129 truncating towards minus infinity. B should be in the range 0 <= B
84 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where 130 <= LONG_INT_BITS - 2, where LONG_INT_BITS is the number of useful
85 INT_BITS is the number of useful bits in an int. GNU code can 131 bits in a long_int. LONG_INT_BITS is at least 32.
86 assume that INT_BITS is at least 32.
87 132
88 ISO C99 says that A >> B is implementation-defined if A < 0. Some 133 ISO C99 says that A >> B is implementation-defined if A < 0. Some
89 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift 134 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
90 right in the usual way when A < 0, so SHR falls back on division if 135 right in the usual way when A < 0, so SHR falls back on division if
91 ordinary A >> B doesn't seem to be the usual signed shift. */ 136 ordinary A >> B doesn't seem to be the usual signed shift. */
92#define SHR(a, b) \
93 ((-1 >> 1 == -1 \
94 && (long_int) -1 >> 1 == -1 \
95 && ((time_t) -1 >> 1 == -1 || ! TYPE_SIGNED (time_t))) \
96 ? (a) >> (b) \
97 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
98
99/* The extra casts in the following macros work around compiler bugs,
100 e.g., in Cray C 5.0.3.0. */
101
102/* True if the arithmetic type T is an integer type. bool counts as
103 an integer. */
104#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
105
106/* True if negative values of the signed integer type T use two's
107 complement, or if T is an unsigned integer type. */
108#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
109
110/* True if the arithmetic type T is signed. */
111#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
112
113/* The maximum and minimum values for the integer type T. These
114 macros have undefined behavior if T is signed and has padding bits.
115 If this is a problem for you, please let us know how to fix it for
116 your host. */
117#define TYPE_MINIMUM(t) \
118 ((t) (! TYPE_SIGNED (t) \
119 ? (t) 0 \
120 : ~ TYPE_MAXIMUM (t)))
121#define TYPE_MAXIMUM(t) \
122 ((t) (! TYPE_SIGNED (t) \
123 ? (t) -1 \
124 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
125
126#ifndef TIME_T_MIN
127# define TIME_T_MIN TYPE_MINIMUM (time_t)
128#endif
129#ifndef TIME_T_MAX
130# define TIME_T_MAX TYPE_MAXIMUM (time_t)
131#endif
132#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1)
133 137
134verify (time_t_is_integer, TYPE_IS_INTEGER (time_t)); 138static long_int
135verify (twos_complement_arithmetic, 139shr (long_int a, int b)
136 (TYPE_TWOS_COMPLEMENT (int) 140{
137 && TYPE_TWOS_COMPLEMENT (long_int) 141 long_int one = 1;
138 && TYPE_TWOS_COMPLEMENT (time_t))); 142 return (-one >> 1 == -1
143 ? a >> b
144 : (a + (a < 0)) / (one << b) - (a < 0));
145}
146
147/* Bounds for the intersection of __time64_t and long_int. */
148
149static long_int const mktime_min
150 = ((TYPE_SIGNED (__time64_t)
151 && TYPE_MINIMUM (__time64_t) < TYPE_MINIMUM (long_int))
152 ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (__time64_t));
153static long_int const mktime_max
154 = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t)
155 ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t));
139 156
140#define EPOCH_YEAR 1970 157#define EPOCH_YEAR 1970
141#define TM_YEAR_BASE 1900 158#define TM_YEAR_BASE 1900
142verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0); 159verify (TM_YEAR_BASE % 100 == 0);
143 160
144/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */ 161/* Is YEAR + TM_YEAR_BASE a leap year? */
145static int 162static bool
146leapyear (long_int year) 163leapyear (long_int year)
147{ 164{
148 /* Don't add YEAR to TM_YEAR_BASE, as that might overflow. 165 /* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
@@ -166,20 +183,9 @@ const unsigned short int __mon_yday[2][13] =
166 }; 183 };
167 184
168 185
169#ifndef _LIBC 186/* Do the values A and B differ according to the rules for tm_isdst?
170/* Portable standalone applications should supply a <time.h> that 187 A and B differ if one is zero and the other positive. */
171 declares a POSIX-compliant localtime_r, for the benefit of older 188static bool
172 implementations that lack localtime_r or have a nonstandard one.
173 See the gnulib time_r module for one way to implement this. */
174# undef __localtime_r
175# define __localtime_r localtime_r
176# define __mktime_internal mktime_internal
177# include "mktime-internal.h"
178#endif
179
180/* Return 1 if the values A and B differ according to the rules for
181 tm_isdst: A and B differ if one is zero and the other positive. */
182static int
183isdst_differ (int a, int b) 189isdst_differ (int a, int b)
184{ 190{
185 return (!a != !b) && (0 <= a) && (0 <= b); 191 return (!a != !b) && (0 <= a) && (0 <= b);
@@ -187,171 +193,135 @@ isdst_differ (int a, int b)
187 193
188/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - 194/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
189 (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks 195 (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks
190 were not adjusted between the time stamps. 196 were not adjusted between the timestamps.
191 197
192 The YEAR values uses the same numbering as TP->tm_year. Values 198 The YEAR values uses the same numbering as TP->tm_year. Values
193 need not be in the usual range. However, YEAR1 must not be less 199 need not be in the usual range. However, YEAR1 - YEAR0 must not
194 than 2 * INT_MIN or greater than 2 * INT_MAX. 200 overflow even when multiplied by three times the number of seconds
201 in a year, and likewise for YDAY1 - YDAY0 and three times the
202 number of seconds in a day. */
195 203
196 The result may overflow. It is the caller's responsibility to 204static long_int
197 detect overflow. */
198
199static time_t
200ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, 205ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
201 int year0, int yday0, int hour0, int min0, int sec0) 206 int year0, int yday0, int hour0, int min0, int sec0)
202{ 207{
203 verify (C99_integer_division, -1 / 2 == 0); 208 verify (-1 / 2 == 0);
204 209
205 /* Compute intervening leap days correctly even if year is negative. 210 /* Compute intervening leap days correctly even if year is negative.
206 Take care to avoid integer overflow here. */ 211 Take care to avoid integer overflow here. */
207 int a4 = SHR (year1, 2) + SHR (TM_YEAR_BASE, 2) - ! (year1 & 3); 212 int a4 = shr (year1, 2) + shr (TM_YEAR_BASE, 2) - ! (year1 & 3);
208 int b4 = SHR (year0, 2) + SHR (TM_YEAR_BASE, 2) - ! (year0 & 3); 213 int b4 = shr (year0, 2) + shr (TM_YEAR_BASE, 2) - ! (year0 & 3);
209 int a100 = a4 / 25 - (a4 % 25 < 0); 214 int a100 = (a4 + (a4 < 0)) / 25 - (a4 < 0);
210 int b100 = b4 / 25 - (b4 % 25 < 0); 215 int b100 = (b4 + (b4 < 0)) / 25 - (b4 < 0);
211 int a400 = SHR (a100, 2); 216 int a400 = shr (a100, 2);
212 int b400 = SHR (b100, 2); 217 int b400 = shr (b100, 2);
213 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); 218 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
214 219
215 /* Compute the desired time in time_t precision. Overflow might 220 /* Compute the desired time without overflowing. */
216 occur here. */ 221 long_int years = year1 - year0;
217 time_t tyear1 = year1; 222 long_int days = 365 * years + yday1 - yday0 + intervening_leap_days;
218 time_t years = tyear1 - year0; 223 long_int hours = 24 * days + hour1 - hour0;
219 time_t days = 365 * years + yday1 - yday0 + intervening_leap_days; 224 long_int minutes = 60 * hours + min1 - min0;
220 time_t hours = 24 * days + hour1 - hour0; 225 long_int seconds = 60 * minutes + sec1 - sec0;
221 time_t minutes = 60 * hours + min1 - min0;
222 time_t seconds = 60 * minutes + sec1 - sec0;
223 return seconds; 226 return seconds;
224} 227}
225 228
226/* Return the average of A and B, even if A + B would overflow. */ 229/* Return the average of A and B, even if A + B would overflow.
227static time_t 230 Round toward positive infinity. */
228time_t_avg (time_t a, time_t b) 231static long_int
232long_int_avg (long_int a, long_int b)
229{ 233{
230 return SHR (a, 1) + SHR (b, 1) + (a & b & 1); 234 return shr (a, 1) + shr (b, 1) + ((a | b) & 1);
231} 235}
232 236
233/* Return 1 if A + B does not overflow. If time_t is unsigned and if 237/* Return a long_int value corresponding to (YEAR-YDAY HOUR:MIN:SEC)
234 B's top bit is set, assume that the sum represents A - -B, and 238 minus *TP seconds, assuming no clock adjustments occurred between
235 return 1 if the subtraction does not wrap around. */ 239 the two timestamps.
236static int
237time_t_add_ok (time_t a, time_t b)
238{
239 if (! TYPE_SIGNED (time_t))
240 {
241 time_t sum = a + b;
242 return (sum < a) == (TIME_T_MIDPOINT <= b);
243 }
244 else if (WRAPV)
245 {
246 time_t sum = a + b;
247 return (sum < a) == (b < 0);
248 }
249 else
250 {
251 time_t avg = time_t_avg (a, b);
252 return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2;
253 }
254}
255 240
256/* Return 1 if A + B does not overflow. */ 241 YEAR and YDAY must not be so large that multiplying them by three times the
257static int 242 number of seconds in a year (or day, respectively) would overflow long_int.
258time_t_int_add_ok (time_t a, int b) 243 *TP should be in the usual range. */
244static long_int
245tm_diff (long_int year, long_int yday, int hour, int min, int sec,
246 struct tm const *tp)
259{ 247{
260 verify (int_no_wider_than_time_t, INT_MAX <= TIME_T_MAX); 248 return ydhms_diff (year, yday, hour, min, sec,
261 if (WRAPV) 249 tp->tm_year, tp->tm_yday,
262 { 250 tp->tm_hour, tp->tm_min, tp->tm_sec);
263 time_t sum = a + b;
264 return (sum < a) == (b < 0);
265 }
266 else
267 {
268 int a_odd = a & 1;
269 time_t avg = SHR (a, 1) + (SHR (b, 1) + (a_odd & b));
270 return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2;
271 }
272} 251}
273 252
274/* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC), 253/* Use CONVERT to convert T to a struct tm value in *TM. T must be in
275 assuming that *T corresponds to *TP and that no clock adjustments 254 range for __time64_t. Return TM if successful, NULL (setting errno) on
276 occurred between *TP and the desired time. 255 failure. */
277 If TP is null, return a value not equal to *T; this avoids false matches. 256static struct tm *
278 If overflow occurs, yield the minimal or maximal value, except do not 257convert_time (struct tm *(*convert) (const __time64_t *, struct tm *),
279 yield a value equal to *T. */ 258 long_int t, struct tm *tm)
280static time_t
281guess_time_tm (long_int year, long_int yday, int hour, int min, int sec,
282 const time_t *t, const struct tm *tp)
283{ 259{
284 if (tp) 260 __time64_t x = t;
285 { 261 return convert (&x, tm);
286 time_t d = ydhms_diff (year, yday, hour, min, sec,
287 tp->tm_year, tp->tm_yday,
288 tp->tm_hour, tp->tm_min, tp->tm_sec);
289 if (time_t_add_ok (*t, d))
290 return *t + d;
291 }
292
293 /* Overflow occurred one way or another. Return the nearest result
294 that is actually in range, except don't report a zero difference
295 if the actual difference is nonzero, as that would cause a false
296 match; and don't oscillate between two values, as that would
297 confuse the spring-forward gap detector. */
298 return (*t < TIME_T_MIDPOINT
299 ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN)
300 : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX));
301} 262}
302 263
303/* Use CONVERT to convert *T to a broken down time in *TP. 264/* Use CONVERT to convert *T to a broken down time in *TP.
304 If *T is out of range for conversion, adjust it so that 265 If *T is out of range for conversion, adjust it so that
305 it is the nearest in-range value and then convert that. */ 266 it is the nearest in-range value and then convert that.
267 A value is in range if it fits in both __time64_t and long_int.
268 Return TP on success, NULL (setting errno) on failure. */
306static struct tm * 269static struct tm *
307ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), 270ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
308 time_t *t, struct tm *tp) 271 long_int *t, struct tm *tp)
309{ 272{
310 struct tm *r = convert (t, tp); 273 long_int t1 = (*t < mktime_min ? mktime_min
311 274 : *t <= mktime_max ? *t : mktime_max);
312 if (!r && *t) 275 struct tm *r = convert_time (convert, t1, tp);
276 if (r)
313 { 277 {
314 time_t bad = *t; 278 *t = t1;
315 time_t ok = 0; 279 return r;
280 }
281 if (errno != EOVERFLOW)
282 return NULL;
316 283
317 /* BAD is a known unconvertible time_t, and OK is a known good one. 284 long_int bad = t1;
318 Use binary search to narrow the range between BAD and OK until 285 long_int ok = 0;
319 they differ by 1. */ 286 struct tm oktm; oktm.tm_sec = -1;
320 while (bad != ok + (bad < 0 ? -1 : 1))
321 {
322 time_t mid = *t = time_t_avg (ok, bad);
323 r = convert (t, tp);
324 if (r)
325 ok = mid;
326 else
327 bad = mid;
328 }
329 287
330 if (!r && ok) 288 /* BAD is a known out-of-range value, and OK is a known in-range one.
331 { 289 Use binary search to narrow the range between BAD and OK until
332 /* The last conversion attempt failed; 290 they differ by 1. */
333 revert to the most recent successful attempt. */ 291 while (true)
334 *t = ok; 292 {
335 r = convert (t, tp); 293 long_int mid = long_int_avg (ok, bad);
336 } 294 if (mid == ok || mid == bad)
295 break;
296 if (convert_time (convert, mid, tp))
297 ok = mid, oktm = *tp;
298 else if (errno != EOVERFLOW)
299 return NULL;
300 else
301 bad = mid;
337 } 302 }
338 303
339 return r; 304 if (oktm.tm_sec < 0)
305 return NULL;
306 *t = ok;
307 *tp = oktm;
308 return tp;
340} 309}
341 310
342 311
343/* Convert *TP to a time_t value, inverting 312/* Convert *TP to a __time64_t value, inverting
344 the monotonic and mostly-unit-linear conversion function CONVERT. 313 the monotonic and mostly-unit-linear conversion function CONVERT.
345 Use *OFFSET to keep track of a guess at the offset of the result, 314 Use *OFFSET to keep track of a guess at the offset of the result,
346 compared to what the result would be for UTC without leap seconds. 315 compared to what the result would be for UTC without leap seconds.
347 If *OFFSET's guess is correct, only one CONVERT call is needed. 316 If *OFFSET's guess is correct, only one CONVERT call is needed.
317 If successful, set *TP to the canonicalized struct tm;
318 otherwise leave *TP alone, return ((time_t) -1) and set errno.
348 This function is external because it is used also by timegm.c. */ 319 This function is external because it is used also by timegm.c. */
349time_t 320__time64_t
350__mktime_internal (struct tm *tp, 321__mktime_internal (struct tm *tp,
351 struct tm *(*convert) (const time_t *, struct tm *), 322 struct tm *(*convert) (const __time64_t *, struct tm *),
352 time_t *offset) 323 mktime_offset_t *offset)
353{ 324{
354 time_t t, gt, t0, t1, t2;
355 struct tm tm; 325 struct tm tm;
356 326
357 /* The maximum number of probes (calls to CONVERT) should be enough 327 /* The maximum number of probes (calls to CONVERT) should be enough
@@ -371,7 +341,7 @@ __mktime_internal (struct tm *tp,
371 int isdst = tp->tm_isdst; 341 int isdst = tp->tm_isdst;
372 342
373 /* 1 if the previous probe was DST. */ 343 /* 1 if the previous probe was DST. */
374 int dst2; 344 int dst2 = 0;
375 345
376 /* Ensure that mon is in range, and set year accordingly. */ 346 /* Ensure that mon is in range, and set year accordingly. */
377 int mon_remainder = mon % 12; 347 int mon_remainder = mon % 12;
@@ -381,9 +351,7 @@ __mktime_internal (struct tm *tp,
381 long_int year = lyear_requested + mon_years; 351 long_int year = lyear_requested + mon_years;
382 352
383 /* The other values need not be in range: 353 /* The other values need not be in range:
384 the remaining code handles minor overflows correctly, 354 the remaining code handles overflows correctly. */
385 assuming int and time_t arithmetic wraps around.
386 Major overflows are caught at the end. */
387 355
388 /* Calculate day of year from year, month, and day of month. 356 /* Calculate day of year from year, month, and day of month.
389 The result need not be in range. */ 357 The result need not be in range. */
@@ -393,14 +361,15 @@ __mktime_internal (struct tm *tp,
393 long_int lmday = mday; 361 long_int lmday = mday;
394 long_int yday = mon_yday + lmday; 362 long_int yday = mon_yday + lmday;
395 363
396 time_t guessed_offset = *offset; 364 mktime_offset_t off = *offset;
365 int negative_offset_guess;
397 366
398 int sec_requested = sec; 367 int sec_requested = sec;
399 368
400 if (LEAP_SECONDS_POSSIBLE) 369 if (LEAP_SECONDS_POSSIBLE)
401 { 370 {
402 /* Handle out-of-range seconds specially, 371 /* Handle out-of-range seconds specially,
403 since ydhms_tm_diff assumes every minute has 60 seconds. */ 372 since ydhms_diff assumes every minute has 60 seconds. */
404 if (sec < 0) 373 if (sec < 0)
405 sec = 0; 374 sec = 0;
406 if (59 < sec) 375 if (59 < sec)
@@ -410,91 +379,47 @@ __mktime_internal (struct tm *tp,
410 /* Invert CONVERT by probing. First assume the same offset as last 379 /* Invert CONVERT by probing. First assume the same offset as last
411 time. */ 380 time. */
412 381
413 t0 = ydhms_diff (year, yday, hour, min, sec, 382 INT_SUBTRACT_WRAPV (0, off, &negative_offset_guess);
414 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset); 383 long_int t0 = ydhms_diff (year, yday, hour, min, sec,
384 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0,
385 negative_offset_guess);
386 long_int t = t0, t1 = t0, t2 = t0;
387
388 /* Repeatedly use the error to improve the guess. */
415 389
416 if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) 390 while (true)
417 { 391 {
418 /* time_t isn't large enough to rule out overflows, so check 392 if (! ranged_convert (convert, &t, &tm))
419 for major overflows. A gross check suffices, since if t0 393 return -1;
420 has overflowed, it is off by a multiple of TIME_T_MAX - 394 long_int dt = tm_diff (year, yday, hour, min, sec, &tm);
421 TIME_T_MIN + 1. So ignore any component of the difference 395 if (dt == 0)
422 that is bounded by a small value. */ 396 break;
423 397
424 /* Approximate log base 2 of the number of time units per 398 if (t == t1 && t != t2
425 biennium. A biennium is 2 years; use this unit instead of 399 && (tm.tm_isdst < 0
426 years to avoid integer overflow. For example, 2 average 400 || (isdst < 0
427 Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds, 401 ? dst2 <= (tm.tm_isdst != 0)
428 which is 63113904 seconds, and rint (log2 (63113904)) is 402 : (isdst != 0) != (tm.tm_isdst != 0))))
429 26. */ 403 /* We can't possibly find a match, as we are oscillating
430 int ALOG2_SECONDS_PER_BIENNIUM = 26; 404 between two values. The requested time probably falls
431 int ALOG2_MINUTES_PER_BIENNIUM = 20; 405 within a spring-forward gap of size DT. Follow the common
432 int ALOG2_HOURS_PER_BIENNIUM = 14; 406 practice in this case, which is to return a time that is DT
433 int ALOG2_DAYS_PER_BIENNIUM = 10; 407 away from the requested time, preferring a time whose
434 int LOG2_YEARS_PER_BIENNIUM = 1; 408 tm_isdst differs from the requested value. (If no tm_isdst
435 409 was requested and only one of the two values has a nonzero
436 int approx_requested_biennia = 410 tm_isdst, prefer that value.) In practice, this is more
437 (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM) 411 useful than returning -1. */
438 - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM) 412 goto offset_found;
439 + SHR (mday, ALOG2_DAYS_PER_BIENNIUM) 413
440 + SHR (hour, ALOG2_HOURS_PER_BIENNIUM) 414 remaining_probes--;
441 + SHR (min, ALOG2_MINUTES_PER_BIENNIUM) 415 if (remaining_probes == 0)
442 + (LEAP_SECONDS_POSSIBLE
443 ? 0
444 : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM)));
445
446 int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM);
447 int diff = approx_biennia - approx_requested_biennia;
448 int approx_abs_diff = diff < 0 ? -1 - diff : diff;
449
450 /* IRIX 4.0.5 cc miscalculates TIME_T_MIN / 3: it erroneously
451 gives a positive value of 715827882. Setting a variable
452 first then doing math on it seems to work.
453 (ghazi@caip.rutgers.edu) */
454 time_t time_t_max = TIME_T_MAX;
455 time_t time_t_min = TIME_T_MIN;
456 time_t overflow_threshold =
457 (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM;
458
459 if (overflow_threshold < approx_abs_diff)
460 { 416 {
461 /* Overflow occurred. Try repairing it; this might work if 417 __set_errno (EOVERFLOW);
462 the time zone offset is enough to undo the overflow. */ 418 return -1;
463 time_t repaired_t0 = -1 - t0;
464 approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM);
465 diff = approx_biennia - approx_requested_biennia;
466 approx_abs_diff = diff < 0 ? -1 - diff : diff;
467 if (overflow_threshold < approx_abs_diff)
468 return -1;
469 guessed_offset += repaired_t0 - t0;
470 t0 = repaired_t0;
471 } 419 }
472 }
473
474 /* Repeatedly use the error to improve the guess. */
475 420
476 for (t = t1 = t2 = t0, dst2 = 0; 421 t1 = t2, t2 = t, t += dt, dst2 = tm.tm_isdst != 0;
477 (gt = guess_time_tm (year, yday, hour, min, sec, &t, 422 }
478 ranged_convert (convert, &t, &tm)),
479 t != gt);
480 t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0)
481 if (t == t1 && t != t2
482 && (tm.tm_isdst < 0
483 || (isdst < 0
484 ? dst2 <= (tm.tm_isdst != 0)
485 : (isdst != 0) != (tm.tm_isdst != 0))))
486 /* We can't possibly find a match, as we are oscillating
487 between two values. The requested time probably falls
488 within a spring-forward gap of size GT - T. Follow the common
489 practice in this case, which is to return a time that is GT - T
490 away from the requested time, preferring a time whose
491 tm_isdst differs from the requested value. (If no tm_isdst
492 was requested and only one of the two values has a nonzero
493 tm_isdst, prefer that value.) In practice, this is more
494 useful than returning -1. */
495 goto offset_found;
496 else if (--remaining_probes == 0)
497 return -1;
498 423
499 /* We have a match. Check whether tm.tm_isdst has the requested 424 /* We have a match. Check whether tm.tm_isdst has the requested
500 value, if any. */ 425 value, if any. */
@@ -504,8 +429,13 @@ __mktime_internal (struct tm *tp,
504 time with the right value, and use its UTC offset. 429 time with the right value, and use its UTC offset.
505 430
506 Heuristic: probe the adjacent timestamps in both directions, 431 Heuristic: probe the adjacent timestamps in both directions,
507 looking for the desired isdst. This should work for all real 432 looking for the desired isdst. If none is found within a
508 time zone histories in the tz database. */ 433 reasonable duration bound, assume a one-hour DST difference.
434 This should work for all real time zone histories in the tz
435 database. */
436
437 /* +1 if we wanted standard time but got DST, -1 if the reverse. */
438 int dst_difference = (isdst == 0) - (tm.tm_isdst == 0);
509 439
510 /* Distance between probes when looking for a DST boundary. In 440 /* Distance between probes when looking for a DST boundary. In
511 tzdata2003a, the shortest period of DST is 601200 seconds 441 tzdata2003a, the shortest period of DST is 601200 seconds
@@ -516,12 +446,14 @@ __mktime_internal (struct tm *tp,
516 periods when probing. */ 446 periods when probing. */
517 int stride = 601200; 447 int stride = 601200;
518 448
519 /* The longest period of DST in tzdata2003a is 536454000 seconds 449 /* In TZDB 2021e, the longest period of DST (or of non-DST), in
520 (e.g., America/Jujuy starting 1946-10-01 01:00). The longest 450 which the DST (or adjacent DST) difference is not one hour,
521 period of non-DST is much longer, but it makes no real sense 451 is 457243209 seconds: e.g., America/Cambridge_Bay with leap
522 to search for more than a year of non-DST, so use the DST 452 seconds, starting 1965-10-31 00:00 in a switch from
523 max. */ 453 double-daylight time (-05) to standard time (-07), and
524 int duration_max = 536454000; 454 continuing to 1980-04-27 02:00 in a switch from standard time
455 (-07) to daylight time (-06). */
456 int duration_max = 457243209;
525 457
526 /* Search in both directions, so the maximum distance is half 458 /* Search in both directions, so the maximum distance is half
527 the duration; add the stride to avoid off-by-1 problems. */ 459 the duration; add the stride to avoid off-by-1 problems. */
@@ -531,211 +463,116 @@ __mktime_internal (struct tm *tp,
531 463
532 for (delta = stride; delta < delta_bound; delta += stride) 464 for (delta = stride; delta < delta_bound; delta += stride)
533 for (direction = -1; direction <= 1; direction += 2) 465 for (direction = -1; direction <= 1; direction += 2)
534 if (time_t_int_add_ok (t, delta * direction)) 466 {
535 { 467 long_int ot;
536 time_t ot = t + delta * direction; 468 if (! INT_ADD_WRAPV (t, delta * direction, &ot))
537 struct tm otm; 469 {
538 ranged_convert (convert, &ot, &otm); 470 struct tm otm;
539 if (! isdst_differ (isdst, otm.tm_isdst)) 471 if (! ranged_convert (convert, &ot, &otm))
540 { 472 return -1;
541 /* We found the desired tm_isdst. 473 if (! isdst_differ (isdst, otm.tm_isdst))
542 Extrapolate back to the desired time. */ 474 {
543 t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); 475 /* We found the desired tm_isdst.
544 ranged_convert (convert, &t, &tm); 476 Extrapolate back to the desired time. */
545 goto offset_found; 477 long_int gt = ot + tm_diff (year, yday, hour, min, sec,
546 } 478 &otm);
547 } 479 if (mktime_min <= gt && gt <= mktime_max)
480 {
481 if (convert_time (convert, gt, &tm))
482 {
483 t = gt;
484 goto offset_found;
485 }
486 if (errno != EOVERFLOW)
487 return -1;
488 }
489 }
490 }
491 }
492
493 /* No unusual DST offset was found nearby. Assume one-hour DST. */
494 t += 60 * 60 * dst_difference;
495 if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm))
496 goto offset_found;
497
498 __set_errno (EOVERFLOW);
499 return -1;
548 } 500 }
549 501
550 offset_found: 502 offset_found:
551 *offset = guessed_offset + t - t0; 503 /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS.
504 This is just a heuristic to speed up the next mktime call, and
505 correctness is unaffected if integer overflow occurs here. */
506 INT_SUBTRACT_WRAPV (t, t0, offset);
507 INT_SUBTRACT_WRAPV (*offset, negative_offset_guess, offset);
552 508
553 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) 509 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
554 { 510 {
555 /* Adjust time to reflect the tm_sec requested, not the normalized value. 511 /* Adjust time to reflect the tm_sec requested, not the normalized value.
556 Also, repair any damage from a false match due to a leap second. */ 512 Also, repair any damage from a false match due to a leap second. */
557 int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec; 513 long_int sec_adjustment = sec == 0 && tm.tm_sec == 60;
558 if (! time_t_int_add_ok (t, sec_requested)) 514 sec_adjustment -= sec;
559 return -1; 515 sec_adjustment += sec_requested;
560 t1 = t + sec_requested; 516 if (INT_ADD_WRAPV (t, sec_adjustment, &t)
561 if (! time_t_int_add_ok (t1, sec_adjustment)) 517 || ! (mktime_min <= t && t <= mktime_max))
562 return -1; 518 {
563 t2 = t1 + sec_adjustment; 519 __set_errno (EOVERFLOW);
564 if (! convert (&t2, &tm)) 520 return -1;
521 }
522 if (! convert_time (convert, t, &tm))
565 return -1; 523 return -1;
566 t = t2;
567 } 524 }
568 525
569 *tp = tm; 526 *tp = tm;
570 return t; 527 return t;
571} 528}
572 529
530#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL */
573 531
574/* FIXME: This should use a signed type wide enough to hold any UTC 532#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS
575 offset in seconds. 'int' should be good enough for GNU code. We
576 can't fix this unilaterally though, as other modules invoke
577 __mktime_internal. */
578static time_t localtime_offset;
579 533
580/* Convert *TP to a time_t value. */ 534/* Convert *TP to a __time64_t value. */
581time_t 535__time64_t
582mktime (struct tm *tp) 536__mktime64 (struct tm *tp)
583{ 537{
584#ifdef _LIBC
585 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the 538 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the
586 time zone names contained in the external variable 'tzname' shall 539 time zone names contained in the external variable 'tzname' shall
587 be set as if the tzset() function had been called. */ 540 be set as if the tzset() function had been called. */
588 __tzset (); 541 __tzset ();
589#endif
590 542
591 return __mktime_internal (tp, __localtime_r, &localtime_offset); 543# if defined _LIBC || NEED_MKTIME_WORKING
544 static mktime_offset_t localtime_offset;
545 return __mktime_internal (tp, __localtime64_r, &localtime_offset);
546# else
547# undef mktime
548 return mktime (tp);
549# endif
592} 550}
551#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */
593 552
594#ifdef weak_alias 553#if defined _LIBC && __TIMESIZE != 64
595weak_alias (mktime, timelocal)
596#endif
597
598#ifdef _LIBC
599libc_hidden_def (mktime)
600libc_hidden_weak (timelocal)
601#endif
602
603#if DEBUG
604 554
605static int 555libc_hidden_def (__mktime64)
606not_equal_tm (const struct tm *a, const struct tm *b)
607{
608 return ((a->tm_sec ^ b->tm_sec)
609 | (a->tm_min ^ b->tm_min)
610 | (a->tm_hour ^ b->tm_hour)
611 | (a->tm_mday ^ b->tm_mday)
612 | (a->tm_mon ^ b->tm_mon)
613 | (a->tm_year ^ b->tm_year)
614 | (a->tm_yday ^ b->tm_yday)
615 | isdst_differ (a->tm_isdst, b->tm_isdst));
616}
617 556
618static void 557time_t
619print_tm (const struct tm *tp) 558mktime (struct tm *tp)
620{
621 if (tp)
622 printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
623 tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
624 tp->tm_hour, tp->tm_min, tp->tm_sec,
625 tp->tm_yday, tp->tm_wday, tp->tm_isdst);
626 else
627 printf ("0");
628}
629
630static int
631check_result (time_t tk, struct tm tmk, time_t tl, const struct tm *lt)
632{
633 if (tk != tl || !lt || not_equal_tm (&tmk, lt))
634 {
635 printf ("mktime (");
636 print_tm (lt);
637 printf (")\nyields (");
638 print_tm (&tmk);
639 printf (") == %ld, should be %ld\n", (long int) tk, (long int) tl);
640 return 1;
641 }
642
643 return 0;
644}
645
646int
647main (int argc, char **argv)
648{ 559{
649 int status = 0; 560 struct tm tm = *tp;
650 struct tm tm, tmk, tml; 561 __time64_t t = __mktime64 (&tm);
651 struct tm *lt; 562 if (in_time_t_range (t))
652 time_t tk, tl, tl1;
653 char trailer;
654
655 if ((argc == 3 || argc == 4)
656 && (sscanf (argv[1], "%d-%d-%d%c",
657 &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
658 == 3)
659 && (sscanf (argv[2], "%d:%d:%d%c",
660 &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
661 == 3))
662 { 563 {
663 tm.tm_year -= TM_YEAR_BASE; 564 *tp = tm;
664 tm.tm_mon--; 565 return t;
665 tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]);
666 tmk = tm;
667 tl = mktime (&tmk);
668 lt = localtime (&tl);
669 if (lt)
670 {
671 tml = *lt;
672 lt = &tml;
673 }
674 printf ("mktime returns %ld == ", (long int) tl);
675 print_tm (&tmk);
676 printf ("\n");
677 status = check_result (tl, tmk, tl, lt);
678 } 566 }
679 else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0)) 567 else
680 { 568 {
681 time_t from = atol (argv[1]); 569 __set_errno (EOVERFLOW);
682 time_t by = atol (argv[2]); 570 return -1;
683 time_t to = atol (argv[3]);
684
685 if (argc == 4)
686 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
687 {
688 lt = localtime (&tl);
689 if (lt)
690 {
691 tmk = tml = *lt;
692 tk = mktime (&tmk);
693 status |= check_result (tk, tmk, tl, &tml);
694 }
695 else
696 {
697 printf ("localtime (%ld) yields 0\n", (long int) tl);
698 status = 1;
699 }
700 tl1 = tl + by;
701 if ((tl1 < tl) != (by < 0))
702 break;
703 }
704 else
705 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
706 {
707 /* Null benchmark. */
708 lt = localtime (&tl);
709 if (lt)
710 {
711 tmk = tml = *lt;
712 tk = tl;
713 status |= check_result (tk, tmk, tl, &tml);
714 }
715 else
716 {
717 printf ("localtime (%ld) yields 0\n", (long int) tl);
718 status = 1;
719 }
720 tl1 = tl + by;
721 if ((tl1 < tl) != (by < 0))
722 break;
723 }
724 } 571 }
725 else
726 printf ("Usage:\
727\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
728\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
729\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
730 argv[0], argv[0], argv[0]);
731
732 return status;
733} 572}
734 573
735#endif /* DEBUG */ 574#endif
736 575
737/* 576weak_alias (mktime, timelocal)
738Local Variables: 577libc_hidden_def (mktime)
739compile-command: "gcc -DDEBUG -I. -Wall -W -O2 -g mktime.c -o mktime" 578libc_hidden_weak (timelocal)
740End:
741*/
diff --git a/gl/mountlist.c b/gl/mountlist.c
index 30f42861..6d384812 100644
--- a/gl/mountlist.c
+++ b/gl/mountlist.c
@@ -1,10 +1,10 @@
1/* mountlist.c -- return a list of mounted file systems 1/* mountlist.c -- return a list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1997-2013 Free Software Foundation, Inc. 3 Copyright (C) 1991-1992, 1997-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -37,7 +37,13 @@
37# include <sys/param.h> 37# include <sys/param.h>
38#endif 38#endif
39 39
40#if defined MOUNTED_GETFSSTAT /* OSF_1 and Darwin1.3.x */ 40#if MAJOR_IN_MKDEV
41# include <sys/mkdev.h>
42#elif MAJOR_IN_SYSMACROS
43# include <sys/sysmacros.h>
44#endif
45
46#if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */
41# if HAVE_SYS_UCRED_H 47# if HAVE_SYS_UCRED_H
42# include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS, 48# include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS,
43 NGROUPS is used as an array dimension in ucred.h */ 49 NGROUPS is used as an array dimension in ucred.h */
@@ -56,102 +62,104 @@
56# endif 62# endif
57#endif /* MOUNTED_GETFSSTAT */ 63#endif /* MOUNTED_GETFSSTAT */
58 64
59#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ 65#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android,
66 also (obsolete) 4.3BSD, SunOS */
60# include <mntent.h> 67# include <mntent.h>
61# if !defined MOUNTED 68# include <sys/types.h>
69# if defined __ANDROID__ /* Android */
70 /* Bionic versions from between 2014-01-09 and 2015-01-08 define MOUNTED to
71 an incorrect value; older Bionic versions don't define it at all. */
72# undef MOUNTED
73# define MOUNTED "/proc/mounts"
74# elif !defined MOUNTED
62# if defined _PATH_MOUNTED /* GNU libc */ 75# if defined _PATH_MOUNTED /* GNU libc */
63# define MOUNTED _PATH_MOUNTED 76# define MOUNTED _PATH_MOUNTED
64# endif 77# endif
65# if defined MNT_MNTTAB /* HP-UX. */ 78# if defined MNT_MNTTAB /* HP-UX. */
66# define MOUNTED MNT_MNTTAB 79# define MOUNTED MNT_MNTTAB
67# endif 80# endif
68# if defined MNTTABNAME /* Dynix. */
69# define MOUNTED MNTTABNAME
70# endif
71# endif 81# endif
72#endif 82#endif
73 83
74#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ 84#ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
75# include <sys/mount.h> 85# include <sys/mount.h>
76#endif 86#endif
77 87
78#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ 88#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */
79# include <sys/statvfs.h> 89# include <sys/statvfs.h>
80#endif 90#endif
81 91
82#ifdef MOUNTED_GETMNT /* Ultrix. */ 92#ifdef MOUNTED_FS_STAT_DEV /* Haiku, also (obsolete) BeOS */
83# include <sys/mount.h>
84# include <sys/fs_types.h>
85#endif
86
87#ifdef MOUNTED_FS_STAT_DEV /* BeOS. */
88# include <fs_info.h> 93# include <fs_info.h>
89# include <dirent.h> 94# include <dirent.h>
90#endif 95#endif
91 96
92#ifdef MOUNTED_FREAD /* SVR2. */ 97#ifdef MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */
93# include <mnttab.h>
94#endif
95
96#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */
97# include <mnttab.h> 98# include <mnttab.h>
98# include <sys/fstyp.h> 99# include <sys/fstyp.h>
99# include <sys/statfs.h> 100# include <sys/statfs.h>
100#endif 101#endif
101 102
102#ifdef MOUNTED_LISTMNTENT 103#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */
103# include <mntent.h> 104# include <sys/mnttab.h>
104#endif 105#endif
105 106
106#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ 107#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */
107# include <sys/mnttab.h> 108# include <sys/mnttab.h>
108#endif 109#endif
109 110
110#ifdef MOUNTED_VMOUNT /* AIX. */ 111#ifdef MOUNTED_VMOUNT /* AIX */
111# include <fshelp.h> 112# include <fshelp.h>
112# include <sys/vfs.h> 113# include <sys/vfs.h>
113#endif 114#endif
114 115
115#ifdef MOUNTED_INTERIX_STATVFS /* Interix. */ 116#ifdef MOUNTED_INTERIX_STATVFS /* Interix */
116# include <sys/statvfs.h> 117# include <sys/statvfs.h>
117# include <dirent.h> 118# include <dirent.h>
118#endif 119#endif
119 120
120#ifdef DOLPHIN
121/* So special that it's not worth putting this in autoconf. */
122# undef MOUNTED_FREAD_FSTYP
123# define MOUNTED_GETMNTTBL
124#endif
125
126#if HAVE_SYS_MNTENT_H 121#if HAVE_SYS_MNTENT_H
127/* This is to get MNTOPT_IGNORE on e.g. SVR4. */ 122/* This is to get MNTOPT_IGNORE on e.g. SVR4. */
128# include <sys/mntent.h> 123# include <sys/mntent.h>
129#endif 124#endif
130 125
126#ifdef MOUNTED_GETMNTENT1
127# if !HAVE_SETMNTENT /* Android <= 4.4 */
128# define setmntent(fp,mode) fopen (fp, mode "e")
129# endif
130# if !HAVE_ENDMNTENT /* Android <= 4.4 */
131# define endmntent(fp) fclose (fp)
132# endif
133#endif
134
131#ifndef HAVE_HASMNTOPT 135#ifndef HAVE_HASMNTOPT
132# define hasmntopt(mnt, opt) ((char *) 0) 136# define hasmntopt(mnt, opt) ((char *) 0)
133#endif 137#endif
134 138
135#undef MNT_IGNORE 139#undef MNT_IGNORE
136#ifdef MNTOPT_IGNORE 140#ifdef MNTOPT_IGNORE
137# define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE) 141# if defined __sun && defined __SVR4
142/* Solaris defines hasmntopt(struct mnttab *, char *)
143 while it is otherwise hasmntopt(struct mnttab *, const char *). */
144# define MNT_IGNORE(M) hasmntopt (M, (char *) MNTOPT_IGNORE)
145# else
146# define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE)
147# endif
138#else 148#else
139# define MNT_IGNORE(M) 0 149# define MNT_IGNORE(M) 0
140#endif 150#endif
141 151
142#if USE_UNLOCKED_IO 152/* Each of the FILE streams in this file is only used in a single thread. */
143# include "unlocked-io.h" 153#include "unlocked-io.h"
144#endif
145
146/* The results of open() in this file are not used with fchdir,
147 therefore save some unnecessary work in fchdir.c. */
148#undef open
149#undef close
150 154
151/* The results of opendir() in this file are not used with dirfd and fchdir, 155/* The results of opendir() in this file are not used with dirfd and fchdir,
152 therefore save some unnecessary work in fchdir.c. */ 156 therefore save some unnecessary work in fchdir.c. */
153#undef opendir 157#ifdef GNULIB_defined_opendir
154#undef closedir 158# undef opendir
159#endif
160#ifdef GNULIB_defined_closedir
161# undef closedir
162#endif
155 163
156#define ME_DUMMY_0(Fs_name, Fs_type) \ 164#define ME_DUMMY_0(Fs_name, Fs_type) \
157 (strcmp (Fs_type, "autofs") == 0 \ 165 (strcmp (Fs_type, "autofs") == 0 \
@@ -161,6 +169,7 @@
161 || strcmp (Fs_type, "debugfs") == 0 \ 169 || strcmp (Fs_type, "debugfs") == 0 \
162 || strcmp (Fs_type, "devpts") == 0 \ 170 || strcmp (Fs_type, "devpts") == 0 \
163 || strcmp (Fs_type, "fusectl") == 0 \ 171 || strcmp (Fs_type, "fusectl") == 0 \
172 || strcmp (Fs_type, "fuse.portal") == 0 \
164 || strcmp (Fs_type, "mqueue") == 0 \ 173 || strcmp (Fs_type, "mqueue") == 0 \
165 || strcmp (Fs_type, "rpc_pipefs") == 0 \ 174 || strcmp (Fs_type, "rpc_pipefs") == 0 \
166 || strcmp (Fs_type, "sysfs") == 0 \ 175 || strcmp (Fs_type, "sysfs") == 0 \
@@ -176,10 +185,9 @@
176 we grant an exception to any with "bind" in its list of mount options. 185 we grant an exception to any with "bind" in its list of mount options.
177 I.e., those are *not* dummy entries. */ 186 I.e., those are *not* dummy entries. */
178#ifdef MOUNTED_GETMNTENT1 187#ifdef MOUNTED_GETMNTENT1
179# define ME_DUMMY(Fs_name, Fs_type, Fs_ent) \ 188# define ME_DUMMY(Fs_name, Fs_type, Bind) \
180 (ME_DUMMY_0 (Fs_name, Fs_type) \ 189 (ME_DUMMY_0 (Fs_name, Fs_type) \
181 || (strcmp (Fs_type, "none") == 0 \ 190 || (strcmp (Fs_type, "none") == 0 && !Bind))
182 && !hasmntopt (Fs_ent, "bind")))
183#else 191#else
184# define ME_DUMMY(Fs_name, Fs_type) \ 192# define ME_DUMMY(Fs_name, Fs_type) \
185 (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0) 193 (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
@@ -187,11 +195,14 @@
187 195
188#ifdef __CYGWIN__ 196#ifdef __CYGWIN__
189# include <windows.h> 197# include <windows.h>
198/* Don't assume that UNICODE is not defined. */
199# undef GetDriveType
200# define GetDriveType GetDriveTypeA
190# define ME_REMOTE me_remote 201# define ME_REMOTE me_remote
191/* All cygwin mount points include ':' or start with '//'; so it 202/* All cygwin mount points include ':' or start with '//'; so it
192 requires a native Windows call to determine remote disks. */ 203 requires a native Windows call to determine remote disks. */
193static bool 204static bool
194me_remote (char const *fs_name, char const *fs_type _GL_UNUSED) 205me_remote (char const *fs_name, _GL_UNUSED char const *fs_type)
195{ 206{
196 if (fs_name[0] && fs_name[1] == ':') 207 if (fs_name[0] && fs_name[1] == ':')
197 { 208 {
@@ -212,16 +223,30 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
212 223
213#ifndef ME_REMOTE 224#ifndef ME_REMOTE
214/* A file system is "remote" if its Fs_name contains a ':' 225/* A file system is "remote" if its Fs_name contains a ':'
215 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//'). */ 226 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//')
227 or if it is of any other of the listed types
228 or Fs_name is equal to "-hosts" (used by autofs to mount remote fs).
229 "VM" file systems like prl_fs or vboxsf are not considered remote here. */
216# define ME_REMOTE(Fs_name, Fs_type) \ 230# define ME_REMOTE(Fs_name, Fs_type) \
217 (strchr (Fs_name, ':') != NULL \ 231 (strchr (Fs_name, ':') != NULL \
218 || ((Fs_name)[0] == '/' \ 232 || ((Fs_name)[0] == '/' \
219 && (Fs_name)[1] == '/' \ 233 && (Fs_name)[1] == '/' \
220 && (strcmp (Fs_type, "smbfs") == 0 \ 234 && (strcmp (Fs_type, "smbfs") == 0 \
221 || strcmp (Fs_type, "cifs") == 0))) 235 || strcmp (Fs_type, "smb3") == 0 \
236 || strcmp (Fs_type, "cifs") == 0)) \
237 || strcmp (Fs_type, "acfs") == 0 \
238 || strcmp (Fs_type, "afs") == 0 \
239 || strcmp (Fs_type, "coda") == 0 \
240 || strcmp (Fs_type, "auristorfs") == 0 \
241 || strcmp (Fs_type, "fhgfs") == 0 \
242 || strcmp (Fs_type, "gpfs") == 0 \
243 || strcmp (Fs_type, "ibrix") == 0 \
244 || strcmp (Fs_type, "ocfs2") == 0 \
245 || strcmp (Fs_type, "vxfs") == 0 \
246 || strcmp ("-hosts", Fs_name) == 0)
222#endif 247#endif
223 248
224#if MOUNTED_GETMNTINFO 249#if MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
225 250
226# if ! HAVE_STRUCT_STATFS_F_FSTYPENAME 251# if ! HAVE_STRUCT_STATFS_F_FSTYPENAME
227static char * 252static char *
@@ -331,7 +356,7 @@ fsp_to_string (const struct statfs *fsp)
331 356
332#endif /* MOUNTED_GETMNTINFO */ 357#endif /* MOUNTED_GETMNTINFO */
333 358
334#ifdef MOUNTED_VMOUNT /* AIX. */ 359#ifdef MOUNTED_VMOUNT /* AIX */
335static char * 360static char *
336fstype_to_string (int t) 361fstype_to_string (int t)
337{ 362{
@@ -382,6 +407,46 @@ dev_from_mount_options (char const *mount_options)
382 407
383#endif 408#endif
384 409
410#if defined MOUNTED_GETMNTENT1 && (defined __linux__ || defined __ANDROID__) /* GNU/Linux, Android */
411
412/* Unescape the paths in mount tables.
413 STR is updated in place. */
414
415static void
416unescape_tab (char *str)
417{
418 size_t i, j = 0;
419 size_t len = strlen (str) + 1;
420 for (i = 0; i < len; i++)
421 {
422 if (str[i] == '\\' && (i + 4 < len)
423 && str[i + 1] >= '0' && str[i + 1] <= '3'
424 && str[i + 2] >= '0' && str[i + 2] <= '7'
425 && str[i + 3] >= '0' && str[i + 3] <= '7')
426 {
427 str[j++] = (str[i + 1] - '0') * 64 +
428 (str[i + 2] - '0') * 8 +
429 (str[i + 3] - '0');
430 i += 3;
431 }
432 else
433 str[j++] = str[i];
434 }
435}
436
437/* Find the next space in STR, terminate the string there in place,
438 and return that position. Otherwise return NULL. */
439
440static char *
441terminate_at_blank (char *str)
442{
443 char *s = strchr (str, ' ');
444 if (s)
445 *s = '\0';
446 return s;
447}
448#endif
449
385/* Return a list of the currently mounted file systems, or NULL on error. 450/* Return a list of the currently mounted file systems, or NULL on error.
386 Add each entry to the tail of the list so that they stay in order. 451 Add each entry to the tail of the list so that they stay in order.
387 If NEED_FS_TYPE is true, ensure that the file system type fields in 452 If NEED_FS_TYPE is true, ensure that the file system type fields in
@@ -395,69 +460,141 @@ read_file_system_list (bool need_fs_type)
395 struct mount_entry **mtail = &mount_list; 460 struct mount_entry **mtail = &mount_list;
396 (void) need_fs_type; 461 (void) need_fs_type;
397 462
398#ifdef MOUNTED_LISTMNTENT 463#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android,
464 also (obsolete) 4.3BSD, SunOS */
399 { 465 {
400 struct tabmntent *mntlist, *p; 466 FILE *fp;
401 struct mntent *mnt;
402 struct mount_entry *me;
403
404 /* the third and fourth arguments could be used to filter mounts,
405 but Crays doesn't seem to have any mounts that we want to
406 remove. Specifically, automount create normal NFS mounts.
407 */
408 467
409 if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0) 468# if defined __linux__ || defined __ANDROID__
410 return NULL; 469 /* Try parsing mountinfo first, as that make device IDs available.
411 for (p = mntlist; p; p = p->next) 470 Note we could use libmount routines to simplify this parsing a little
471 (and that code is in previous versions of this function), however
472 libmount depends on libselinux which pulls in many dependencies. */
473 char const *mountinfo = "/proc/self/mountinfo";
474 fp = fopen (mountinfo, "re");
475 if (fp != NULL)
412 { 476 {
413 mnt = p->ment; 477 char *line = NULL;
414 me = xmalloc (sizeof *me); 478 size_t buf_size = 0;
415 me->me_devname = xstrdup (mnt->mnt_fsname);
416 me->me_mountdir = xstrdup (mnt->mnt_dir);
417 me->me_type = xstrdup (mnt->mnt_type);
418 me->me_type_malloced = 1;
419 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
420 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
421 me->me_dev = -1;
422 *mtail = me;
423 mtail = &me->me_next;
424 }
425 freemntlist (mntlist);
426 }
427#endif
428 479
429#ifdef MOUNTED_GETMNTENT1 /* GNU/Linux, 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ 480 while (getline (&line, &buf_size, fp) != -1)
430 { 481 {
431 struct mntent *mnt; 482 unsigned int devmaj, devmin;
432 char const *table = MOUNTED; 483 int rc, mntroot_s;
433 FILE *fp;
434 484
435 fp = setmntent (table, "r"); 485 rc = sscanf(line, "%*u " /* id - discarded */
436 if (fp == NULL) 486 "%*u " /* parent - discarded */
437 return NULL; 487 "%u:%u " /* dev major:minor */
488 "%n", /* mountroot (start) */
489 &devmaj, &devmin,
490 &mntroot_s);
438 491
439 while ((mnt = getmntent (fp))) 492 if (rc != 2 && rc != 3) /* 3 if %n included in count. */
440 { 493 continue;
441 me = xmalloc (sizeof *me);
442 me->me_devname = xstrdup (mnt->mnt_fsname);
443 me->me_mountdir = xstrdup (mnt->mnt_dir);
444 me->me_type = xstrdup (mnt->mnt_type);
445 me->me_type_malloced = 1;
446 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, mnt);
447 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
448 me->me_dev = dev_from_mount_options (mnt->mnt_opts);
449 494
450 /* Add to the linked list. */ 495 /* find end of MNTROOT. */
451 *mtail = me; 496 char *mntroot = line + mntroot_s;
452 mtail = &me->me_next; 497 char *blank = terminate_at_blank (mntroot);
498 if (! blank)
499 continue;
500
501 /* find end of TARGET. */
502 char *target = blank + 1;
503 blank = terminate_at_blank (target);
504 if (! blank)
505 continue;
506
507 /* skip optional fields, terminated by " - " */
508 char *dash = strstr (blank + 1, " - ");
509 if (! dash)
510 continue;
511
512 /* advance past the " - " separator. */
513 char *fstype = dash + 3;
514 blank = terminate_at_blank (fstype);
515 if (! blank)
516 continue;
517
518 /* find end of SOURCE. */
519 char *source = blank + 1;
520 if (! terminate_at_blank (source))
521 continue;
522
523 /* manipulate the sub-strings in place. */
524 unescape_tab (source);
525 unescape_tab (target);
526 unescape_tab (mntroot);
527 unescape_tab (fstype);
528
529 me = xmalloc (sizeof *me);
530
531 me->me_devname = xstrdup (source);
532 me->me_mountdir = xstrdup (target);
533 me->me_mntroot = xstrdup (mntroot);
534 me->me_type = xstrdup (fstype);
535 me->me_type_malloced = 1;
536 me->me_dev = makedev (devmaj, devmin);
537 /* we pass "false" for the "Bind" option as that's only
538 significant when the Fs_type is "none" which will not be
539 the case when parsing "/proc/self/mountinfo", and only
540 applies for static /etc/mtab files. */
541 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, false);
542 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
543
544 /* Add to the linked list. */
545 *mtail = me;
546 mtail = &me->me_next;
547 }
548
549 free (line);
550
551 if (ferror (fp))
552 {
553 int saved_errno = errno;
554 fclose (fp);
555 errno = saved_errno;
556 goto free_then_fail;
557 }
558
559 if (fclose (fp) == EOF)
560 goto free_then_fail;
453 } 561 }
562 else /* fallback to /proc/self/mounts (/etc/mtab). */
563# endif /* __linux __ || __ANDROID__ */
564 {
565 struct mntent *mnt;
566 char const *table = MOUNTED;
454 567
455 if (endmntent (fp) == 0) 568 fp = setmntent (table, "r");
456 goto free_then_fail; 569 if (fp == NULL)
570 return NULL;
571
572 while ((mnt = getmntent (fp)))
573 {
574 bool bind = hasmntopt (mnt, "bind");
575
576 me = xmalloc (sizeof *me);
577 me->me_devname = xstrdup (mnt->mnt_fsname);
578 me->me_mountdir = xstrdup (mnt->mnt_dir);
579 me->me_mntroot = NULL;
580 me->me_type = xstrdup (mnt->mnt_type);
581 me->me_type_malloced = 1;
582 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, bind);
583 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
584 me->me_dev = dev_from_mount_options (mnt->mnt_opts);
585
586 /* Add to the linked list. */
587 *mtail = me;
588 mtail = &me->me_next;
589 }
590
591 if (endmntent (fp) == 0)
592 goto free_then_fail;
593 }
457 } 594 }
458#endif /* MOUNTED_GETMNTENT1. */ 595#endif /* MOUNTED_GETMNTENT1. */
459 596
460#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ 597#ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
461 { 598 {
462 struct statfs *fsp; 599 struct statfs *fsp;
463 int entries; 600 int entries;
@@ -472,6 +609,7 @@ read_file_system_list (bool need_fs_type)
472 me = xmalloc (sizeof *me); 609 me = xmalloc (sizeof *me);
473 me->me_devname = xstrdup (fsp->f_mntfromname); 610 me->me_devname = xstrdup (fsp->f_mntfromname);
474 me->me_mountdir = xstrdup (fsp->f_mntonname); 611 me->me_mountdir = xstrdup (fsp->f_mntonname);
612 me->me_mntroot = NULL;
475 me->me_type = fs_type; 613 me->me_type = fs_type;
476 me->me_type_malloced = 0; 614 me->me_type_malloced = 0;
477 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 615 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -485,7 +623,7 @@ read_file_system_list (bool need_fs_type)
485 } 623 }
486#endif /* MOUNTED_GETMNTINFO */ 624#endif /* MOUNTED_GETMNTINFO */
487 625
488#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ 626#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */
489 { 627 {
490 struct statvfs *fsp; 628 struct statvfs *fsp;
491 int entries; 629 int entries;
@@ -498,6 +636,7 @@ read_file_system_list (bool need_fs_type)
498 me = xmalloc (sizeof *me); 636 me = xmalloc (sizeof *me);
499 me->me_devname = xstrdup (fsp->f_mntfromname); 637 me->me_devname = xstrdup (fsp->f_mntfromname);
500 me->me_mountdir = xstrdup (fsp->f_mntonname); 638 me->me_mountdir = xstrdup (fsp->f_mntonname);
639 me->me_mntroot = NULL;
501 me->me_type = xstrdup (fsp->f_fstypename); 640 me->me_type = xstrdup (fsp->f_fstypename);
502 me->me_type_malloced = 1; 641 me->me_type_malloced = 1;
503 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 642 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -511,35 +650,7 @@ read_file_system_list (bool need_fs_type)
511 } 650 }
512#endif /* MOUNTED_GETMNTINFO2 */ 651#endif /* MOUNTED_GETMNTINFO2 */
513 652
514#ifdef MOUNTED_GETMNT /* Ultrix. */ 653#if defined MOUNTED_FS_STAT_DEV /* Haiku, also (obsolete) BeOS */
515 {
516 int offset = 0;
517 int val;
518 struct fs_data fsd;
519
520 while (errno = 0,
521 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
522 (char *) 0)))
523 {
524 me = xmalloc (sizeof *me);
525 me->me_devname = xstrdup (fsd.fd_req.devname);
526 me->me_mountdir = xstrdup (fsd.fd_req.path);
527 me->me_type = gt_names[fsd.fd_req.fstype];
528 me->me_type_malloced = 0;
529 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
530 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
531 me->me_dev = fsd.fd_req.dev;
532
533 /* Add to the linked list. */
534 *mtail = me;
535 mtail = &me->me_next;
536 }
537 if (val < 0)
538 goto free_then_fail;
539 }
540#endif /* MOUNTED_GETMNT. */
541
542#if defined MOUNTED_FS_STAT_DEV /* BeOS */
543 { 654 {
544 /* The next_dev() and fs_stat_dev() system calls give the list of 655 /* The next_dev() and fs_stat_dev() system calls give the list of
545 all file systems, including the information returned by statvfs() 656 all file systems, including the information returned by statvfs()
@@ -622,6 +733,7 @@ read_file_system_list (bool need_fs_type)
622 me->me_devname = xstrdup (fi.device_name[0] != '\0' 733 me->me_devname = xstrdup (fi.device_name[0] != '\0'
623 ? fi.device_name : fi.fsh_name); 734 ? fi.device_name : fi.fsh_name);
624 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); 735 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
736 me->me_mntroot = NULL;
625 me->me_type = xstrdup (fi.fsh_name); 737 me->me_type = xstrdup (fi.fsh_name);
626 me->me_type_malloced = 1; 738 me->me_type_malloced = 1;
627 me->me_dev = fi.dev; 739 me->me_dev = fi.dev;
@@ -644,7 +756,7 @@ read_file_system_list (bool need_fs_type)
644 } 756 }
645#endif /* MOUNTED_FS_STAT_DEV */ 757#endif /* MOUNTED_FS_STAT_DEV */
646 758
647#if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */ 759#if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */
648 { 760 {
649 int numsys, counter; 761 int numsys, counter;
650 size_t bufsize; 762 size_t bufsize;
@@ -671,6 +783,7 @@ read_file_system_list (bool need_fs_type)
671 me = xmalloc (sizeof *me); 783 me = xmalloc (sizeof *me);
672 me->me_devname = xstrdup (stats[counter].f_mntfromname); 784 me->me_devname = xstrdup (stats[counter].f_mntfromname);
673 me->me_mountdir = xstrdup (stats[counter].f_mntonname); 785 me->me_mountdir = xstrdup (stats[counter].f_mntonname);
786 me->me_mntroot = NULL;
674 me->me_type = xstrdup (FS_TYPE (stats[counter])); 787 me->me_type = xstrdup (FS_TYPE (stats[counter]));
675 me->me_type_malloced = 1; 788 me->me_type_malloced = 1;
676 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 789 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -686,31 +799,25 @@ read_file_system_list (bool need_fs_type)
686 } 799 }
687#endif /* MOUNTED_GETFSSTAT */ 800#endif /* MOUNTED_GETFSSTAT */
688 801
689#if defined MOUNTED_FREAD || defined MOUNTED_FREAD_FSTYP /* SVR[23]. */ 802#if defined MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */
690 { 803 {
691 struct mnttab mnt; 804 struct mnttab mnt;
692 char *table = "/etc/mnttab"; 805 char *table = "/etc/mnttab";
693 FILE *fp; 806 FILE *fp;
694 807
695 fp = fopen (table, "r"); 808 fp = fopen (table, "re");
696 if (fp == NULL) 809 if (fp == NULL)
697 return NULL; 810 return NULL;
698 811
699 while (fread (&mnt, sizeof mnt, 1, fp) > 0) 812 while (fread (&mnt, sizeof mnt, 1, fp) > 0)
700 { 813 {
701 me = xmalloc (sizeof *me); 814 me = xmalloc (sizeof *me);
702# ifdef GETFSTYP /* SVR3. */
703 me->me_devname = xstrdup (mnt.mt_dev); 815 me->me_devname = xstrdup (mnt.mt_dev);
704# else
705 me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
706 strcpy (me->me_devname, "/dev/");
707 strcpy (me->me_devname + 5, mnt.mt_dev);
708# endif
709 me->me_mountdir = xstrdup (mnt.mt_filsys); 816 me->me_mountdir = xstrdup (mnt.mt_filsys);
817 me->me_mntroot = NULL;
710 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ 818 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
711 me->me_type = ""; 819 me->me_type = "";
712 me->me_type_malloced = 0; 820 me->me_type_malloced = 0;
713# ifdef GETFSTYP /* SVR3. */
714 if (need_fs_type) 821 if (need_fs_type)
715 { 822 {
716 struct statfs fsd; 823 struct statfs fsd;
@@ -723,7 +830,6 @@ read_file_system_list (bool need_fs_type)
723 me->me_type_malloced = 1; 830 me->me_type_malloced = 1;
724 } 831 }
725 } 832 }
726# endif
727 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 833 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
728 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 834 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
729 835
@@ -744,34 +850,57 @@ read_file_system_list (bool need_fs_type)
744 if (fclose (fp) == EOF) 850 if (fclose (fp) == EOF)
745 goto free_then_fail; 851 goto free_then_fail;
746 } 852 }
747#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */ 853#endif /* MOUNTED_FREAD_FSTYP. */
748 854
749#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ 855#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */
750 { 856 {
751 struct mntent **mnttbl = getmnttbl (), **ent; 857 struct extmnttab mnt;
752 for (ent = mnttbl; *ent; ent++) 858 const char *table = MNTTAB;
859 FILE *fp;
860 int ret;
861
862 /* No locking is needed, because the contents of /etc/mnttab is generated
863 by the kernel. */
864
865 errno = 0;
866 fp = fopen (table, "re");
867 if (fp == NULL)
868 ret = errno;
869 else
753 { 870 {
754 me = xmalloc (sizeof *me); 871 while ((ret = getextmntent (fp, &mnt, 1)) == 0)
755 me->me_devname = xstrdup ((*ent)->mt_resource); 872 {
756 me->me_mountdir = xstrdup ((*ent)->mt_directory); 873 me = xmalloc (sizeof *me);
757 me->me_type = xstrdup ((*ent)->mt_fstype); 874 me->me_devname = xstrdup (mnt.mnt_special);
758 me->me_type_malloced = 1; 875 me->me_mountdir = xstrdup (mnt.mnt_mountp);
759 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 876 me->me_mntroot = NULL;
760 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 877 me->me_type = xstrdup (mnt.mnt_fstype);
761 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ 878 me->me_type_malloced = 1;
879 me->me_dummy = MNT_IGNORE (&mnt) != 0;
880 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
881 me->me_dev = makedev (mnt.mnt_major, mnt.mnt_minor);
762 882
763 /* Add to the linked list. */ 883 /* Add to the linked list. */
764 *mtail = me; 884 *mtail = me;
765 mtail = &me->me_next; 885 mtail = &me->me_next;
886 }
887
888 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
889 /* Here ret = -1 means success, ret >= 0 means failure. */
890 }
891
892 if (0 <= ret)
893 {
894 errno = ret;
895 goto free_then_fail;
766 } 896 }
767 endmnttbl ();
768 } 897 }
769#endif 898#endif /* MOUNTED_GETEXTMNTENT */
770 899
771#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ 900#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */
772 { 901 {
773 struct mnttab mnt; 902 struct mnttab mnt;
774 char *table = MNTTAB; 903 const char *table = MNTTAB;
775 FILE *fp; 904 FILE *fp;
776 int ret; 905 int ret;
777 int lockfd = -1; 906 int lockfd = -1;
@@ -784,7 +913,7 @@ read_file_system_list (bool need_fs_type)
784# ifndef MNTTAB_LOCK 913# ifndef MNTTAB_LOCK
785# define MNTTAB_LOCK "/etc/.mnttab.lock" 914# define MNTTAB_LOCK "/etc/.mnttab.lock"
786# endif 915# endif
787 lockfd = open (MNTTAB_LOCK, O_RDONLY); 916 lockfd = open (MNTTAB_LOCK, O_RDONLY | O_CLOEXEC);
788 if (0 <= lockfd) 917 if (0 <= lockfd)
789 { 918 {
790 struct flock flock; 919 struct flock flock;
@@ -806,7 +935,7 @@ read_file_system_list (bool need_fs_type)
806# endif 935# endif
807 936
808 errno = 0; 937 errno = 0;
809 fp = fopen (table, "r"); 938 fp = fopen (table, "re");
810 if (fp == NULL) 939 if (fp == NULL)
811 ret = errno; 940 ret = errno;
812 else 941 else
@@ -816,6 +945,7 @@ read_file_system_list (bool need_fs_type)
816 me = xmalloc (sizeof *me); 945 me = xmalloc (sizeof *me);
817 me->me_devname = xstrdup (mnt.mnt_special); 946 me->me_devname = xstrdup (mnt.mnt_special);
818 me->me_mountdir = xstrdup (mnt.mnt_mountp); 947 me->me_mountdir = xstrdup (mnt.mnt_mountp);
948 me->me_mntroot = NULL;
819 me->me_type = xstrdup (mnt.mnt_fstype); 949 me->me_type = xstrdup (mnt.mnt_fstype);
820 me->me_type_malloced = 1; 950 me->me_type_malloced = 1;
821 me->me_dummy = MNT_IGNORE (&mnt) != 0; 951 me->me_dummy = MNT_IGNORE (&mnt) != 0;
@@ -828,6 +958,7 @@ read_file_system_list (bool need_fs_type)
828 } 958 }
829 959
830 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; 960 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
961 /* Here ret = -1 means success, ret >= 0 means failure. */
831 } 962 }
832 963
833 if (0 <= lockfd && close (lockfd) != 0) 964 if (0 <= lockfd && close (lockfd) != 0)
@@ -841,26 +972,26 @@ read_file_system_list (bool need_fs_type)
841 } 972 }
842#endif /* MOUNTED_GETMNTENT2. */ 973#endif /* MOUNTED_GETMNTENT2. */
843 974
844#ifdef MOUNTED_VMOUNT /* AIX. */ 975#ifdef MOUNTED_VMOUNT /* AIX */
845 { 976 {
846 int bufsize; 977 int bufsize;
847 char *entries, *thisent; 978 void *entries;
979 char *thisent;
848 struct vmount *vmp; 980 struct vmount *vmp;
849 int n_entries; 981 int n_entries;
850 int i; 982 int i;
851 983
852 /* Ask how many bytes to allocate for the mounted file system info. */ 984 /* Ask how many bytes to allocate for the mounted file system info. */
853 if (mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize) != 0) 985 entries = &bufsize;
986 if (mntctl (MCTL_QUERY, sizeof bufsize, entries) != 0)
854 return NULL; 987 return NULL;
855 entries = xmalloc (bufsize); 988 entries = xmalloc (bufsize);
856 989
857 /* Get the list of mounted file systems. */ 990 /* Get the list of mounted file systems. */
858 n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries); 991 n_entries = mntctl (MCTL_QUERY, bufsize, entries);
859 if (n_entries < 0) 992 if (n_entries < 0)
860 { 993 {
861 int saved_errno = errno;
862 free (entries); 994 free (entries);
863 errno = saved_errno;
864 return NULL; 995 return NULL;
865 } 996 }
866 997
@@ -892,6 +1023,7 @@ read_file_system_list (bool need_fs_type)
892 vmp->vmt_data[VMT_OBJECT].vmt_off); 1023 vmp->vmt_data[VMT_OBJECT].vmt_off);
893 } 1024 }
894 me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); 1025 me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
1026 me->me_mntroot = NULL;
895 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); 1027 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
896 me->me_type_malloced = 1; 1028 me->me_type_malloced = 1;
897 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off; 1029 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
@@ -910,7 +1042,7 @@ read_file_system_list (bool need_fs_type)
910 } 1042 }
911#endif /* MOUNTED_VMOUNT. */ 1043#endif /* MOUNTED_VMOUNT. */
912 1044
913#ifdef MOUNTED_INTERIX_STATVFS 1045#ifdef MOUNTED_INTERIX_STATVFS /* Interix */
914 { 1046 {
915 DIR *dirp = opendir ("/dev/fs"); 1047 DIR *dirp = opendir ("/dev/fs");
916 char node[9 + NAME_MAX]; 1048 char node[9 + NAME_MAX];
@@ -924,6 +1056,8 @@ read_file_system_list (bool need_fs_type)
924 struct dirent entry; 1056 struct dirent entry;
925 struct dirent *result; 1057 struct dirent *result;
926 1058
1059 /* FIXME: readdir_r is planned to be withdrawn from POSIX and
1060 marked obsolescent in glibc. Use readdir instead. */
927 if (readdir_r (dirp, &entry, &result) || result == NULL) 1061 if (readdir_r (dirp, &entry, &result) || result == NULL)
928 break; 1062 break;
929 1063
@@ -935,6 +1069,7 @@ read_file_system_list (bool need_fs_type)
935 me = xmalloc (sizeof *me); 1069 me = xmalloc (sizeof *me);
936 me->me_devname = xstrdup (dev.f_mntfromname); 1070 me->me_devname = xstrdup (dev.f_mntfromname);
937 me->me_mountdir = xstrdup (dev.f_mntonname); 1071 me->me_mountdir = xstrdup (dev.f_mntonname);
1072 me->me_mntroot = NULL;
938 me->me_type = xstrdup (dev.f_fstypename); 1073 me->me_type = xstrdup (dev.f_fstypename);
939 me->me_type_malloced = 1; 1074 me->me_type_malloced = 1;
940 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 1075 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -946,6 +1081,7 @@ read_file_system_list (bool need_fs_type)
946 mtail = &me->me_next; 1081 mtail = &me->me_next;
947 } 1082 }
948 } 1083 }
1084 closedir (dirp);
949 } 1085 }
950#endif /* MOUNTED_INTERIX_STATVFS */ 1086#endif /* MOUNTED_INTERIX_STATVFS */
951 1087
@@ -953,7 +1089,7 @@ read_file_system_list (bool need_fs_type)
953 return mount_list; 1089 return mount_list;
954 1090
955 1091
956 free_then_fail: 1092 free_then_fail: _GL_UNUSED_LABEL;
957 { 1093 {
958 int saved_errno = errno; 1094 int saved_errno = errno;
959 *mtail = NULL; 1095 *mtail = NULL;
@@ -972,10 +1108,12 @@ read_file_system_list (bool need_fs_type)
972 1108
973/* Free a mount entry as returned from read_file_system_list (). */ 1109/* Free a mount entry as returned from read_file_system_list (). */
974 1110
975void free_mount_entry (struct mount_entry *me) 1111void
1112free_mount_entry (struct mount_entry *me)
976{ 1113{
977 free (me->me_devname); 1114 free (me->me_devname);
978 free (me->me_mountdir); 1115 free (me->me_mountdir);
1116 free (me->me_mntroot);
979 if (me->me_type_malloced) 1117 if (me->me_type_malloced)
980 free (me->me_type); 1118 free (me->me_type);
981 free (me); 1119 free (me);
diff --git a/gl/mountlist.h b/gl/mountlist.h
index 55877e23..aed7f887 100644
--- a/gl/mountlist.h
+++ b/gl/mountlist.h
@@ -1,11 +1,11 @@
1/* mountlist.h -- declarations for list of mounted file systems 1/* mountlist.h -- declarations for list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2013 Free Software 3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,12 +14,11 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef MOUNTLIST_H_ 19#ifndef MOUNTLIST_H_
20# define MOUNTLIST_H_ 20# define MOUNTLIST_H_
21 21
22# include <stdbool.h>
23# include <sys/types.h> 22# include <sys/types.h>
24 23
25/* A mount table entry. */ 24/* A mount table entry. */
@@ -27,15 +26,18 @@ struct mount_entry
27{ 26{
28 char *me_devname; /* Device node name, including "/dev/". */ 27 char *me_devname; /* Device node name, including "/dev/". */
29 char *me_mountdir; /* Mount point directory name. */ 28 char *me_mountdir; /* Mount point directory name. */
29 char *me_mntroot; /* Directory on filesystem of device used */
30 /* as root for the (bind) mount. */
30 char *me_type; /* "nfs", "4.2", etc. */ 31 char *me_type; /* "nfs", "4.2", etc. */
31 dev_t me_dev; /* Device number of me_mountdir. */ 32 dev_t me_dev; /* Device number of me_mountdir. */
32 unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */ 33 unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */
33 unsigned int me_remote : 1; /* Nonzero for remote fileystems. */ 34 unsigned int me_remote : 1; /* Nonzero for remote file systems. */
34 unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */ 35 unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
35 struct mount_entry *me_next; 36 struct mount_entry *me_next;
36}; 37};
37 38
38struct mount_entry *read_file_system_list (bool need_fs_type); 39struct mount_entry *read_file_system_list (bool need_fs_type)
40 _GL_ATTRIBUTE_MALLOC;
39void free_mount_entry (struct mount_entry *entry); 41void free_mount_entry (struct mount_entry *entry);
40 42
41#endif 43#endif
diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c
index 396031e4..c5149a8f 100644
--- a/gl/msvc-inval.c
+++ b/gl/msvc-inval.c
@@ -1,18 +1,18 @@
1/* Invalid parameter handler for MSVC runtime libraries. 1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/msvc-inval.h b/gl/msvc-inval.h
index dcb0353d..ed00461f 100644
--- a/gl/msvc-inval.h
+++ b/gl/msvc-inval.h
@@ -1,18 +1,18 @@
1/* Invalid parameter handler for MSVC runtime libraries. 1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _MSVC_INVAL_H 17#ifndef _MSVC_INVAL_H
18#define _MSVC_INVAL_H 18#define _MSVC_INVAL_H
@@ -95,7 +95,7 @@ extern void gl_msvc_inval_ensure_handler (void);
95 95
96/* Gnulib can define its own status codes, as described in the page 96/* Gnulib can define its own status codes, as described in the page
97 "Raising Software Exceptions" on microsoft.com 97 "Raising Software Exceptions" on microsoft.com
98 <http://msdn.microsoft.com/en-us/library/het71c37.aspx>. 98 <https://docs.microsoft.com/en-us/cpp/cpp/raising-software-exceptions>.
99 Our status codes are composed of 99 Our status codes are composed of
100 - 0xE0000000, mandatory for all user-defined status codes, 100 - 0xE0000000, mandatory for all user-defined status codes,
101 - 0x474E550, a API identifier ("GNU"), 101 - 0x474E550, a API identifier ("GNU"),
@@ -106,7 +106,7 @@ extern void gl_msvc_inval_ensure_handler (void);
106# if defined _MSC_VER 106# if defined _MSC_VER
107/* A compiler that supports __try/__except, as described in the page 107/* A compiler that supports __try/__except, as described in the page
108 "try-except statement" on microsoft.com 108 "try-except statement" on microsoft.com
109 <http://msdn.microsoft.com/en-us/library/s58ftw19.aspx>. 109 <https://docs.microsoft.com/en-us/cpp/cpp/try-except-statement>.
110 With __try/__except, we can use the multithread-safe exception handling. */ 110 With __try/__except, we can use the multithread-safe exception handling. */
111 111
112# ifdef __cplusplus 112# ifdef __cplusplus
diff --git a/gl/msvc-nothrow.c b/gl/msvc-nothrow.c
index 8d65472a..f729fe66 100644
--- a/gl/msvc-nothrow.c
+++ b/gl/msvc-nothrow.c
@@ -1,19 +1,19 @@
1/* Wrappers that don't throw invalid parameter notifications 1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries. 2 with MSVC runtime libraries.
3 Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -24,7 +24,9 @@
24#define WIN32_LEAN_AND_MEAN 24#define WIN32_LEAN_AND_MEAN
25#include <windows.h> 25#include <windows.h>
26 26
27#include "msvc-inval.h" 27#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
28# include "msvc-inval.h"
29#endif
28 30
29#undef _get_osfhandle 31#undef _get_osfhandle
30 32
diff --git a/gl/msvc-nothrow.h b/gl/msvc-nothrow.h
index 5f521813..82d3f6a2 100644
--- a/gl/msvc-nothrow.h
+++ b/gl/msvc-nothrow.h
@@ -1,19 +1,19 @@
1/* Wrappers that don't throw invalid parameter notifications 1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries. 2 with MSVC runtime libraries.
3 Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _MSVC_NOTHROW_H 18#ifndef _MSVC_NOTHROW_H
19#define _MSVC_NOTHROW_H 19#define _MSVC_NOTHROW_H
@@ -25,7 +25,7 @@
25 This file defines wrappers that turn such an invalid parameter notification 25 This file defines wrappers that turn such an invalid parameter notification
26 into an error code. */ 26 into an error code. */
27 27
28#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 28#if defined _WIN32 && ! defined __CYGWIN__
29 29
30/* Get original declaration of _get_osfhandle. */ 30/* Get original declaration of _get_osfhandle. */
31# include <io.h> 31# include <io.h>
diff --git a/gl/netdb.in.h b/gl/netdb.in.h
index 0da1800a..9549cd73 100644
--- a/gl/netdb.in.h
+++ b/gl/netdb.in.h
@@ -1,19 +1,19 @@
1/* Provide a netdb.h header file for systems lacking it (read: MinGW). 1/* Provide a netdb.h header file for systems lacking it (read: MinGW).
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* This file is supposed to be used on platforms that lack <netdb.h>. 18/* This file is supposed to be used on platforms that lack <netdb.h>.
19 It is intended to provide definitions and prototypes needed by an 19 It is intended to provide definitions and prototypes needed by an
@@ -158,33 +158,61 @@ struct addrinfo
158# endif 158# endif
159# endif 159# endif
160 160
161# if !@HAVE_DECL_GETADDRINFO@
162/* Translate name of a service location and/or a service name to set of 161/* Translate name of a service location and/or a service name to set of
163 socket addresses. 162 socket addresses.
164 For more details, see the POSIX:2001 specification 163 For more details, see the POSIX:2008 specification
165 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ 164 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>. */
165# if @REPLACE_GETADDRINFO@
166# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
167# undef getaddrinfo
168# define getaddrinfo rpl_getaddrinfo
169# endif
170_GL_FUNCDECL_RPL (getaddrinfo, int,
171 (const char *restrict nodename,
172 const char *restrict servname,
173 const struct addrinfo *restrict hints,
174 struct addrinfo **restrict res)
175 _GL_ARG_NONNULL ((4)));
176_GL_CXXALIAS_RPL (getaddrinfo, int,
177 (const char *restrict nodename,
178 const char *restrict servname,
179 const struct addrinfo *restrict hints,
180 struct addrinfo **restrict res));
181# else
182# if !@HAVE_DECL_GETADDRINFO@
166_GL_FUNCDECL_SYS (getaddrinfo, int, 183_GL_FUNCDECL_SYS (getaddrinfo, int,
167 (const char *restrict nodename, 184 (const char *restrict nodename,
168 const char *restrict servname, 185 const char *restrict servname,
169 const struct addrinfo *restrict hints, 186 const struct addrinfo *restrict hints,
170 struct addrinfo **restrict res) 187 struct addrinfo **restrict res)
171 _GL_ARG_NONNULL ((4))); 188 _GL_ARG_NONNULL ((4)));
172# endif 189# endif
173_GL_CXXALIAS_SYS (getaddrinfo, int, 190_GL_CXXALIAS_SYS (getaddrinfo, int,
174 (const char *restrict nodename, 191 (const char *restrict nodename,
175 const char *restrict servname, 192 const char *restrict servname,
176 const struct addrinfo *restrict hints, 193 const struct addrinfo *restrict hints,
177 struct addrinfo **restrict res)); 194 struct addrinfo **restrict res));
195# endif
178_GL_CXXALIASWARN (getaddrinfo); 196_GL_CXXALIASWARN (getaddrinfo);
179 197
180# if !@HAVE_DECL_FREEADDRINFO@
181/* Free 'addrinfo' structure AI including associated storage. 198/* Free 'addrinfo' structure AI including associated storage.
182 For more details, see the POSIX:2001 specification 199 For more details, see the POSIX:2008 specification
183 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ 200 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>. */
201# if @REPLACE_GETADDRINFO@
202# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
203# undef freeaddrinfo
204# define freeaddrinfo rpl_freeaddrinfo
205# endif
206_GL_FUNCDECL_RPL (freeaddrinfo, void, (struct addrinfo *ai)
207 _GL_ARG_NONNULL ((1)));
208_GL_CXXALIAS_RPL (freeaddrinfo, void, (struct addrinfo *ai));
209# else
210# if !@HAVE_DECL_FREEADDRINFO@
184_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai) 211_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai)
185 _GL_ARG_NONNULL ((1))); 212 _GL_ARG_NONNULL ((1)));
186# endif 213# endif
187_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai)); 214_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai));
215# endif
188_GL_CXXALIASWARN (freeaddrinfo); 216_GL_CXXALIASWARN (freeaddrinfo);
189 217
190# if @REPLACE_GAI_STRERROR@ 218# if @REPLACE_GAI_STRERROR@
@@ -197,18 +225,20 @@ _GL_CXXALIAS_RPL (gai_strerror, const char *, (int ecode));
197# else 225# else
198# if !@HAVE_DECL_GAI_STRERROR@ 226# if !@HAVE_DECL_GAI_STRERROR@
199/* Convert error return from getaddrinfo() to a string. 227/* Convert error return from getaddrinfo() to a string.
200 For more details, see the POSIX:2001 specification 228 For more details, see the POSIX:2008 specification
201 <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */ 229 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gai_strerror.html>. */
202_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode)); 230_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode));
203# endif 231# endif
204_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode)); 232_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode));
205# endif 233# endif
234# if __GLIBC__ >= 2
206_GL_CXXALIASWARN (gai_strerror); 235_GL_CXXALIASWARN (gai_strerror);
236# endif
207 237
208# if !@HAVE_DECL_GETNAMEINFO@ 238# if !@HAVE_DECL_GETNAMEINFO@
209/* Convert socket address to printable node and service names. 239/* Convert socket address to printable node and service names.
210 For more details, see the POSIX:2001 specification 240 For more details, see the POSIX:2008 specification
211 <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */ 241 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html>. */
212_GL_FUNCDECL_SYS (getnameinfo, int, 242_GL_FUNCDECL_SYS (getnameinfo, int,
213 (const struct sockaddr *restrict sa, socklen_t salen, 243 (const struct sockaddr *restrict sa, socklen_t salen,
214 char *restrict node, socklen_t nodelen, 244 char *restrict node, socklen_t nodelen,
diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h
index b456c4f9..f88923a3 100644
--- a/gl/netinet_in.in.h
+++ b/gl/netinet_in.in.h
@@ -1,18 +1,18 @@
1/* Substitute for <netinet/in.h>. 1/* Substitute for <netinet/in.h>.
2 Copyright (C) 2007-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _@GUARD_PREFIX@_NETINET_IN_H 17#ifndef _@GUARD_PREFIX@_NETINET_IN_H
18 18
diff --git a/gl/nl_langinfo-lock.c b/gl/nl_langinfo-lock.c
new file mode 100644
index 00000000..e5cdcd3e
--- /dev/null
+++ b/gl/nl_langinfo-lock.c
@@ -0,0 +1,150 @@
1/* Return the internal lock used by nl_langinfo.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
18
19#include <config.h>
20
21/* When it is known that the gl_get_nl_langinfo_lock function is defined
22 by a dependency library, it should not be defined here. */
23#if OMIT_NL_LANGINFO_LOCK
24
25/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */
27typedef int dummy;
28
29#else
30
31/* This file defines the internal lock used by nl_langinfo.
32 It is a separate compilation unit, so that only one copy of it is
33 present when linking statically. */
34
35/* Prohibit renaming this symbol. */
36# undef gl_get_nl_langinfo_lock
37
38/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */
40# ifndef DLL_EXPORTED
41# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport)
46# else
47# define DLL_EXPORTED
48# endif
49# endif
50
51# if defined _WIN32 && !defined __CYGWIN__
52
53# define WIN32_LEAN_AND_MEAN /* avoid including junk */
54# include <windows.h>
55
56# include "windows-initguard.h"
57
58/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
59 because the latter is not guaranteed to be a stable ABI in the future. */
60
61/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
63
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock;
66
67/* Returns the internal lock used by nl_langinfo. */
68CRITICAL_SECTION *
69gl_get_nl_langinfo_lock (void)
70{
71 if (!guard.done)
72 {
73 if (InterlockedIncrement (&guard.started) == 0)
74 {
75 /* This thread is the first one to need the lock. Initialize it. */
76 InitializeCriticalSection (&lock);
77 guard.done = 1;
78 }
79 else
80 {
81 /* Don't let guard.started grow and wrap around. */
82 InterlockedDecrement (&guard.started);
83 /* Yield the CPU while waiting for another thread to finish
84 initializing this mutex. */
85 while (!guard.done)
86 Sleep (0);
87 }
88 }
89 return &lock;
90}
91
92# elif HAVE_PTHREAD_API
93
94# include <pthread.h>
95
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97
98/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void);
100
101/* Returns the internal lock used by nl_langinfo. */
102pthread_mutex_t *
103gl_get_nl_langinfo_lock (void)
104{
105 return &mutex;
106}
107
108# elif HAVE_THREADS_H
109
110# include <threads.h>
111# include <stdlib.h>
112
113static int volatile init_needed = 1;
114static once_flag init_once = ONCE_FLAG_INIT;
115static mtx_t mutex;
116
117static void
118atomic_init (void)
119{
120 if (mtx_init (&mutex, mtx_plain) != thrd_success)
121 abort ();
122 init_needed = 0;
123}
124
125/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void);
127
128/* Returns the internal lock used by nl_langinfo. */
129mtx_t *
130gl_get_nl_langinfo_lock (void)
131{
132 if (init_needed)
133 call_once (&init_once, atomic_init);
134 return &mutex;
135}
136
137# endif
138
139# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
140/* Make sure the '__declspec(dllimport)' in nl_langinfo.c does not cause
141 a link failure when no DLLs are involved. */
142# if defined _WIN64 || defined _LP64
143# define IMP(x) __imp_##x
144# else
145# define IMP(x) _imp__##x
146# endif
147void * IMP(gl_get_nl_langinfo_lock) = &gl_get_nl_langinfo_lock;
148# endif
149
150#endif
diff --git a/gl/nl_langinfo.c b/gl/nl_langinfo.c
index 771c9533..131166fd 100644
--- a/gl/nl_langinfo.c
+++ b/gl/nl_langinfo.c
@@ -1,34 +1,278 @@
1/* nl_langinfo() replacement: query locale dependent information. 1/* nl_langinfo() replacement: query locale dependent information.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
20/* Specification. */ 20/* Specification. */
21#include <langinfo.h> 21#include <langinfo.h>
22 22
23#include <locale.h>
24#include <stdlib.h>
25#include <string.h>
26#if defined _WIN32 && ! defined __CYGWIN__
27# define WIN32_LEAN_AND_MEAN /* avoid including junk */
28# include <windows.h>
29# include <stdio.h>
30#endif
31
32#if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE
33# if defined _WIN32 && !defined __CYGWIN__
34
35# define WIN32_LEAN_AND_MEAN /* avoid including junk */
36# include <windows.h>
37
38# elif HAVE_PTHREAD_API
39
40# include <pthread.h>
41# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
42# include <threads.h>
43# pragma weak thrd_exit
44# define c11_threads_in_use() (thrd_exit != NULL)
45# else
46# define c11_threads_in_use() 0
47# endif
48
49# elif HAVE_THREADS_H
50
51# include <threads.h>
52
53# endif
54#endif
55
56/* nl_langinfo() must be multithread-safe. To achieve this without using
57 thread-local storage:
58 1. We use a specific static buffer for each possible argument.
59 So that different threads can call nl_langinfo with different arguments,
60 without interfering.
61 2. We use a simple strcpy or memcpy to fill this static buffer. Filling it
62 through, for example, strcpy + strcat would not be guaranteed to leave
63 the buffer's contents intact if another thread is currently accessing
64 it. If necessary, the contents is first assembled in a stack-allocated
65 buffer. */
66
67#if !REPLACE_NL_LANGINFO || GNULIB_defined_CODESET
68/* Return the codeset of the current locale, if this is easily deducible.
69 Otherwise, return "". */
70static char *
71ctype_codeset (void)
72{
73 static char result[2 + 10 + 1];
74 char buf[2 + 10 + 1];
75 char locale[SETLOCALE_NULL_MAX];
76 char *codeset;
77 size_t codesetlen;
78
79 if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale)))
80 locale[0] = '\0';
81
82 codeset = buf;
83 codeset[0] = '\0';
84
85 if (locale[0])
86 {
87 /* If the locale name contains an encoding after the dot, return it. */
88 char *dot = strchr (locale, '.');
89
90 if (dot)
91 {
92 /* Look for the possible @... trailer and remove it, if any. */
93 char *codeset_start = dot + 1;
94 char const *modifier = strchr (codeset_start, '@');
95
96 if (! modifier)
97 codeset = codeset_start;
98 else
99 {
100 codesetlen = modifier - codeset_start;
101 if (codesetlen < sizeof buf)
102 {
103 codeset = memcpy (buf, codeset_start, codesetlen);
104 codeset[codesetlen] = '\0';
105 }
106 }
107 }
108 }
109
110# if defined _WIN32 && ! defined __CYGWIN__
111 /* If setlocale is successful, it returns the number of the
112 codepage, as a string. Otherwise, fall back on Windows API
113 GetACP, which returns the locale's codepage as a number (although
114 this doesn't change according to what the 'setlocale' call specified).
115 Either way, prepend "CP" to make it a valid codeset name. */
116 codesetlen = strlen (codeset);
117 if (0 < codesetlen && codesetlen < sizeof buf - 2)
118 memmove (buf + 2, codeset, codesetlen + 1);
119 else
120 sprintf (buf + 2, "%u", GetACP ());
121 /* For a locale name such as "French_France.65001", in Windows 10,
122 setlocale now returns "French_France.utf8" instead. */
123 if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
124 return (char *) "UTF-8";
125 else
126 {
127 memcpy (buf, "CP", 2);
128 strcpy (result, buf);
129 return result;
130 }
131# else
132 strcpy (result, codeset);
133 return result;
134#endif
135}
136#endif
137
138
23#if REPLACE_NL_LANGINFO 139#if REPLACE_NL_LANGINFO
24 140
25/* Override nl_langinfo with support for added nl_item values. */ 141/* Override nl_langinfo with support for added nl_item values. */
26 142
27# include <locale.h>
28# include <string.h>
29
30# undef nl_langinfo 143# undef nl_langinfo
31 144
145/* Without locking, on Solaris 11.3, test-nl_langinfo-mt fails, with message
146 "thread5 disturbed by threadN!", even when threadN invokes only
147 nl_langinfo (CODESET);
148 nl_langinfo (CRNCYSTR);
149 Similarly on Solaris 10. */
150
151# if !NL_LANGINFO_MTSAFE /* Solaris */
152
153# define ITEMS (MAXSTRMSG + 1)
154# define MAX_RESULT_LEN 80
155
156static char *
157nl_langinfo_unlocked (nl_item item)
158{
159 static char result[ITEMS][MAX_RESULT_LEN];
160
161 /* The result of nl_langinfo is in storage that can be overwritten by
162 other calls to nl_langinfo. */
163 char *tmp = nl_langinfo (item);
164 if (item >= 0 && item < ITEMS && tmp != NULL)
165 {
166 size_t tmp_len = strlen (tmp);
167 if (tmp_len < MAX_RESULT_LEN)
168 strcpy (result[item], tmp);
169 else
170 {
171 /* Produce a truncated result. Oh well... */
172 result[item][MAX_RESULT_LEN - 1] = '\0';
173 memcpy (result[item], tmp, MAX_RESULT_LEN - 1);
174 }
175 return result[item];
176 }
177 else
178 return tmp;
179}
180
181/* Use a lock, so that no two threads can invoke nl_langinfo_unlocked
182 at the same time. */
183
184/* Prohibit renaming this symbol. */
185# undef gl_get_nl_langinfo_lock
186
187# if defined _WIN32 && !defined __CYGWIN__
188
189extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
190
191static char *
192nl_langinfo_with_lock (nl_item item)
193{
194 CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock ();
195 char *ret;
196
197 EnterCriticalSection (lock);
198 ret = nl_langinfo_unlocked (item);
199 LeaveCriticalSection (lock);
200
201 return ret;
202}
203
204# elif HAVE_PTHREAD_API
205
206extern
207# if defined _WIN32 || defined __CYGWIN__
208 __declspec(dllimport)
209# endif
210 pthread_mutex_t *gl_get_nl_langinfo_lock (void);
211
212# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */
213
214 /* Avoid the need to link with '-lpthread'. */
215# pragma weak pthread_mutex_lock
216# pragma weak pthread_mutex_unlock
217
218 /* Determine whether libpthread is in use. */
219# pragma weak pthread_mutexattr_gettype
220 /* See the comments in lock.h. */
221# define pthread_in_use() \
222 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
223
224# else
225# define pthread_in_use() 1
226# endif
227
228static char *
229nl_langinfo_with_lock (nl_item item)
230{
231 if (pthread_in_use())
232 {
233 pthread_mutex_t *lock = gl_get_nl_langinfo_lock ();
234 char *ret;
235
236 if (pthread_mutex_lock (lock))
237 abort ();
238 ret = nl_langinfo_unlocked (item);
239 if (pthread_mutex_unlock (lock))
240 abort ();
241
242 return ret;
243 }
244 else
245 return nl_langinfo_unlocked (item);
246}
247
248# elif HAVE_THREADS_H
249
250extern mtx_t *gl_get_nl_langinfo_lock (void);
251
252static char *
253nl_langinfo_with_lock (nl_item item)
254{
255 mtx_t *lock = gl_get_nl_langinfo_lock ();
256 char *ret;
257
258 if (mtx_lock (lock) != thrd_success)
259 abort ();
260 ret = nl_langinfo_unlocked (item);
261 if (mtx_unlock (lock) != thrd_success)
262 abort ();
263
264 return ret;
265}
266
267# endif
268
269# else
270
271/* On other platforms, no lock is needed. */
272# define nl_langinfo_with_lock nl_langinfo
273
274# endif
275
32char * 276char *
33rpl_nl_langinfo (nl_item item) 277rpl_nl_langinfo (nl_item item)
34{ 278{
@@ -36,47 +280,36 @@ rpl_nl_langinfo (nl_item item)
36 { 280 {
37# if GNULIB_defined_CODESET 281# if GNULIB_defined_CODESET
38 case CODESET: 282 case CODESET:
39 { 283 return ctype_codeset ();
40 const char *locale;
41 static char buf[2 + 10 + 1];
42
43 locale = setlocale (LC_CTYPE, NULL);
44 if (locale != NULL && locale[0] != '\0')
45 {
46 /* If the locale name contains an encoding after the dot, return
47 it. */
48 const char *dot = strchr (locale, '.');
49
50 if (dot != NULL)
51 {
52 const char *modifier;
53
54 dot++;
55 /* Look for the possible @... trailer and remove it, if any. */
56 modifier = strchr (dot, '@');
57 if (modifier == NULL)
58 return dot;
59 if (modifier - dot < sizeof (buf))
60 {
61 memcpy (buf, dot, modifier - dot);
62 buf [modifier - dot] = '\0';
63 return buf;
64 }
65 }
66 }
67 return "";
68 }
69# endif 284# endif
70# if GNULIB_defined_T_FMT_AMPM 285# if GNULIB_defined_T_FMT_AMPM
71 case T_FMT_AMPM: 286 case T_FMT_AMPM:
72 return "%I:%M:%S %p"; 287 return (char *) "%I:%M:%S %p";
288# endif
289# if GNULIB_defined_ALTMON
290 case ALTMON_1:
291 case ALTMON_2:
292 case ALTMON_3:
293 case ALTMON_4:
294 case ALTMON_5:
295 case ALTMON_6:
296 case ALTMON_7:
297 case ALTMON_8:
298 case ALTMON_9:
299 case ALTMON_10:
300 case ALTMON_11:
301 case ALTMON_12:
302 /* We don't ship the appropriate localizations with gnulib. Therefore,
303 treat ALTMON_i like MON_i. */
304 item = item - ALTMON_1 + MON_1;
305 break;
73# endif 306# endif
74# if GNULIB_defined_ERA 307# if GNULIB_defined_ERA
75 case ERA: 308 case ERA:
76 /* The format is not standardized. In glibc it is a sequence of strings 309 /* The format is not standardized. In glibc it is a sequence of strings
77 of the form "direction:offset:start_date:end_date:era_name:era_format" 310 of the form "direction:offset:start_date:end_date:era_name:era_format"
78 with an empty string at the end. */ 311 with an empty string at the end. */
79 return ""; 312 return (char *) "";
80 case ERA_D_FMT: 313 case ERA_D_FMT:
81 /* The %Ex conversion in strftime behaves like %x if the locale does not 314 /* The %Ex conversion in strftime behaves like %x if the locale does not
82 have an alternative time format. */ 315 have an alternative time format. */
@@ -95,176 +328,244 @@ rpl_nl_langinfo (nl_item item)
95 case ALT_DIGITS: 328 case ALT_DIGITS:
96 /* The format is not standardized. In glibc it is a sequence of 10 329 /* The format is not standardized. In glibc it is a sequence of 10
97 strings, appended in memory. */ 330 strings, appended in memory. */
98 return "\0\0\0\0\0\0\0\0\0\0"; 331 return (char *) "\0\0\0\0\0\0\0\0\0\0";
99# endif 332# endif
100# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS 333# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
101 case YESEXPR: 334 case YESEXPR:
102 return "^[yY]"; 335 return (char *) "^[yY]";
103 case NOEXPR: 336 case NOEXPR:
104 return "^[nN]"; 337 return (char *) "^[nN]";
105# endif 338# endif
106 default: 339 default:
107 break; 340 break;
108 } 341 }
109 return nl_langinfo (item); 342 return nl_langinfo_with_lock (item);
110} 343}
111 344
112#else 345#else
113 346
114/* Provide nl_langinfo from scratch. */ 347/* Provide nl_langinfo from scratch, either for native MS-Windows, or
115 348 for old Unix platforms without locales, such as Linux libc5 or
116# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 349 BeOS. */
117 350
118/* Native Windows platforms. */ 351# include <time.h>
119
120# define WIN32_LEAN_AND_MEAN /* avoid including junk */
121# include <windows.h>
122
123# include <stdio.h>
124
125# else
126
127/* An old Unix platform without locales, such as Linux libc5 or BeOS. */
128
129# endif
130
131# include <locale.h>
132 352
133char * 353char *
134nl_langinfo (nl_item item) 354nl_langinfo (nl_item item)
135{ 355{
356 char buf[100];
357 struct tm tmm = { 0 };
358
136 switch (item) 359 switch (item)
137 { 360 {
138 /* nl_langinfo items of the LC_CTYPE category */ 361 /* nl_langinfo items of the LC_CTYPE category */
139 case CODESET: 362 case CODESET:
140# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
141 { 363 {
142 static char buf[2 + 10 + 1]; 364 char *codeset = ctype_codeset ();
143 365 if (*codeset)
144 /* The Windows API has a function returning the locale's codepage as 366 return codeset;
145 a number. */
146 sprintf (buf, "CP%u", GetACP ());
147 return buf;
148 } 367 }
149# elif defined __BEOS__ 368# ifdef __BEOS__
150 return "UTF-8"; 369 return (char *) "UTF-8";
151# else 370# else
152 return "ISO-8859-1"; 371 return (char *) "ISO-8859-1";
153# endif 372# endif
154 /* nl_langinfo items of the LC_NUMERIC category */ 373 /* nl_langinfo items of the LC_NUMERIC category */
155 case RADIXCHAR: 374 case RADIXCHAR:
156 return localeconv () ->decimal_point; 375 return localeconv () ->decimal_point;
157 case THOUSEP: 376 case THOUSEP:
158 return localeconv () ->thousands_sep; 377 return localeconv () ->thousands_sep;
378# ifdef GROUPING
379 case GROUPING:
380 return localeconv () ->grouping;
381# endif
159 /* nl_langinfo items of the LC_TIME category. 382 /* nl_langinfo items of the LC_TIME category.
160 TODO: Really use the locale. */ 383 TODO: Really use the locale. */
161 case D_T_FMT: 384 case D_T_FMT:
162 case ERA_D_T_FMT: 385 case ERA_D_T_FMT:
163 return "%a %b %e %H:%M:%S %Y"; 386 return (char *) "%a %b %e %H:%M:%S %Y";
164 case D_FMT: 387 case D_FMT:
165 case ERA_D_FMT: 388 case ERA_D_FMT:
166 return "%m/%d/%y"; 389 return (char *) "%m/%d/%y";
167 case T_FMT: 390 case T_FMT:
168 case ERA_T_FMT: 391 case ERA_T_FMT:
169 return "%H:%M:%S"; 392 return (char *) "%H:%M:%S";
170 case T_FMT_AMPM: 393 case T_FMT_AMPM:
171 return "%I:%M:%S %p"; 394 return (char *) "%I:%M:%S %p";
172 case AM_STR: 395 case AM_STR:
173 return "AM"; 396 {
397 static char result[80];
398 if (!strftime (buf, sizeof result, "%p", &tmm))
399 return (char *) "AM";
400 strcpy (result, buf);
401 return result;
402 }
174 case PM_STR: 403 case PM_STR:
175 return "PM"; 404 {
405 static char result[80];
406 tmm.tm_hour = 12;
407 if (!strftime (buf, sizeof result, "%p", &tmm))
408 return (char *) "PM";
409 strcpy (result, buf);
410 return result;
411 }
176 case DAY_1: 412 case DAY_1:
177 return "Sunday";
178 case DAY_2: 413 case DAY_2:
179 return "Monday";
180 case DAY_3: 414 case DAY_3:
181 return "Tuesday";
182 case DAY_4: 415 case DAY_4:
183 return "Wednesday";
184 case DAY_5: 416 case DAY_5:
185 return "Thursday";
186 case DAY_6: 417 case DAY_6:
187 return "Friday";
188 case DAY_7: 418 case DAY_7:
189 return "Saturday"; 419 {
420 static char result[7][50];
421 static char const days[][sizeof "Wednesday"] = {
422 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
423 "Friday", "Saturday"
424 };
425 tmm.tm_wday = item - DAY_1;
426 if (!strftime (buf, sizeof result[0], "%A", &tmm))
427 return (char *) days[item - DAY_1];
428 strcpy (result[item - DAY_1], buf);
429 return result[item - DAY_1];
430 }
190 case ABDAY_1: 431 case ABDAY_1:
191 return "Sun";
192 case ABDAY_2: 432 case ABDAY_2:
193 return "Mon";
194 case ABDAY_3: 433 case ABDAY_3:
195 return "Tue";
196 case ABDAY_4: 434 case ABDAY_4:
197 return "Wed";
198 case ABDAY_5: 435 case ABDAY_5:
199 return "Thu";
200 case ABDAY_6: 436 case ABDAY_6:
201 return "Fri";
202 case ABDAY_7: 437 case ABDAY_7:
203 return "Sat"; 438 {
204 case MON_1: 439 static char result[7][30];
205 return "January"; 440 static char const abdays[][sizeof "Sun"] = {
206 case MON_2: 441 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
207 return "February"; 442 };
208 case MON_3: 443 tmm.tm_wday = item - ABDAY_1;
209 return "March"; 444 if (!strftime (buf, sizeof result[0], "%a", &tmm))
210 case MON_4: 445 return (char *) abdays[item - ABDAY_1];
211 return "April"; 446 strcpy (result[item - ABDAY_1], buf);
212 case MON_5: 447 return result[item - ABDAY_1];
213 return "May"; 448 }
214 case MON_6: 449 {
215 return "June"; 450 static char const months[][sizeof "September"] = {
216 case MON_7: 451 "January", "February", "March", "April", "May", "June", "July",
217 return "July"; 452 "September", "October", "November", "December"
218 case MON_8: 453 };
219 return "August"; 454 case MON_1:
220 case MON_9: 455 case MON_2:
221 return "September"; 456 case MON_3:
222 case MON_10: 457 case MON_4:
223 return "October"; 458 case MON_5:
224 case MON_11: 459 case MON_6:
225 return "November"; 460 case MON_7:
226 case MON_12: 461 case MON_8:
227 return "December"; 462 case MON_9:
463 case MON_10:
464 case MON_11:
465 case MON_12:
466 {
467 static char result[12][50];
468 tmm.tm_mon = item - MON_1;
469 if (!strftime (buf, sizeof result[0], "%B", &tmm))
470 return (char *) months[item - MON_1];
471 strcpy (result[item - MON_1], buf);
472 return result[item - MON_1];
473 }
474 case ALTMON_1:
475 case ALTMON_2:
476 case ALTMON_3:
477 case ALTMON_4:
478 case ALTMON_5:
479 case ALTMON_6:
480 case ALTMON_7:
481 case ALTMON_8:
482 case ALTMON_9:
483 case ALTMON_10:
484 case ALTMON_11:
485 case ALTMON_12:
486 {
487 static char result[12][50];
488 tmm.tm_mon = item - ALTMON_1;
489 /* The platforms without nl_langinfo() don't support strftime with
490 %OB. We don't even need to try. */
491 #if 0
492 if (!strftime (buf, sizeof result[0], "%OB", &tmm))
493 #endif
494 if (!strftime (buf, sizeof result[0], "%B", &tmm))
495 return (char *) months[item - ALTMON_1];
496 strcpy (result[item - ALTMON_1], buf);
497 return result[item - ALTMON_1];
498 }
499 }
228 case ABMON_1: 500 case ABMON_1:
229 return "Jan";
230 case ABMON_2: 501 case ABMON_2:
231 return "Feb";
232 case ABMON_3: 502 case ABMON_3:
233 return "Mar";
234 case ABMON_4: 503 case ABMON_4:
235 return "Apr";
236 case ABMON_5: 504 case ABMON_5:
237 return "May";
238 case ABMON_6: 505 case ABMON_6:
239 return "Jun";
240 case ABMON_7: 506 case ABMON_7:
241 return "Jul";
242 case ABMON_8: 507 case ABMON_8:
243 return "Aug";
244 case ABMON_9: 508 case ABMON_9:
245 return "Sep";
246 case ABMON_10: 509 case ABMON_10:
247 return "Oct";
248 case ABMON_11: 510 case ABMON_11:
249 return "Nov";
250 case ABMON_12: 511 case ABMON_12:
251 return "Dec"; 512 {
513 static char result[12][30];
514 static char const abmonths[][sizeof "Jan"] = {
515 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
516 "Sep", "Oct", "Nov", "Dec"
517 };
518 tmm.tm_mon = item - ABMON_1;
519 if (!strftime (buf, sizeof result[0], "%b", &tmm))
520 return (char *) abmonths[item - ABMON_1];
521 strcpy (result[item - ABMON_1], buf);
522 return result[item - ABMON_1];
523 }
252 case ERA: 524 case ERA:
253 return ""; 525 return (char *) "";
254 case ALT_DIGITS: 526 case ALT_DIGITS:
255 return "\0\0\0\0\0\0\0\0\0\0"; 527 return (char *) "\0\0\0\0\0\0\0\0\0\0";
256 /* nl_langinfo items of the LC_MONETARY category 528 /* nl_langinfo items of the LC_MONETARY category. */
257 TODO: Really use the locale. */
258 case CRNCYSTR: 529 case CRNCYSTR:
259 return "-"; 530 return localeconv () ->currency_symbol;
531# ifdef INT_CURR_SYMBOL
532 case INT_CURR_SYMBOL:
533 return localeconv () ->int_curr_symbol;
534 case MON_DECIMAL_POINT:
535 return localeconv () ->mon_decimal_point;
536 case MON_THOUSANDS_SEP:
537 return localeconv () ->mon_thousands_sep;
538 case MON_GROUPING:
539 return localeconv () ->mon_grouping;
540 case POSITIVE_SIGN:
541 return localeconv () ->positive_sign;
542 case NEGATIVE_SIGN:
543 return localeconv () ->negative_sign;
544 case FRAC_DIGITS:
545 return & localeconv () ->frac_digits;
546 case INT_FRAC_DIGITS:
547 return & localeconv () ->int_frac_digits;
548 case P_CS_PRECEDES:
549 return & localeconv () ->p_cs_precedes;
550 case N_CS_PRECEDES:
551 return & localeconv () ->n_cs_precedes;
552 case P_SEP_BY_SPACE:
553 return & localeconv () ->p_sep_by_space;
554 case N_SEP_BY_SPACE:
555 return & localeconv () ->n_sep_by_space;
556 case P_SIGN_POSN:
557 return & localeconv () ->p_sign_posn;
558 case N_SIGN_POSN:
559 return & localeconv () ->n_sign_posn;
560# endif
260 /* nl_langinfo items of the LC_MESSAGES category 561 /* nl_langinfo items of the LC_MESSAGES category
261 TODO: Really use the locale. */ 562 TODO: Really use the locale. */
262 case YESEXPR: 563 case YESEXPR:
263 return "^[yY]"; 564 return (char *) "^[yY]";
264 case NOEXPR: 565 case NOEXPR:
265 return "^[nN]"; 566 return (char *) "^[nN]";
266 default: 567 default:
267 return ""; 568 return (char *) "";
268 } 569 }
269} 570}
270 571
diff --git a/gl/open.c b/gl/open.c
new file mode 100644
index 00000000..7ec8fdc3
--- /dev/null
+++ b/gl/open.c
@@ -0,0 +1,209 @@
1/* Open a descriptor to a file.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18
19/* If the user's config.h happens to include <fcntl.h>, let it include only
20 the system's <fcntl.h> here, so that orig_open doesn't recurse to
21 rpl_open. */
22#define __need_system_fcntl_h
23#include <config.h>
24
25/* Get the original definition of open. It might be defined as a macro. */
26#include <fcntl.h>
27#include <sys/types.h>
28#undef __need_system_fcntl_h
29
30static int
31orig_open (const char *filename, int flags, mode_t mode)
32{
33#if defined _WIN32 && !defined __CYGWIN__
34 return _open (filename, flags, mode);
35#else
36 return open (filename, flags, mode);
37#endif
38}
39
40/* Specification. */
41/* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates
42 this include because of the preliminary #include <fcntl.h> above. */
43#include "fcntl.h"
44
45#include "cloexec.h"
46
47#include <errno.h>
48#include <stdarg.h>
49#include <string.h>
50#include <sys/types.h>
51#include <sys/stat.h>
52#include <unistd.h>
53
54#ifndef REPLACE_OPEN_DIRECTORY
55# define REPLACE_OPEN_DIRECTORY 0
56#endif
57
58int
59open (const char *filename, int flags, ...)
60{
61 /* 0 = unknown, 1 = yes, -1 = no. */
62#if GNULIB_defined_O_CLOEXEC
63 int have_cloexec = -1;
64#else
65 static int have_cloexec;
66#endif
67
68 mode_t mode;
69 int fd;
70
71 mode = 0;
72 if (flags & O_CREAT)
73 {
74 va_list arg;
75 va_start (arg, flags);
76
77 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
78 creates crashing code when 'mode_t' is smaller than 'int'. */
79 mode = va_arg (arg, PROMOTED_MODE_T);
80
81 va_end (arg);
82 }
83
84#if GNULIB_defined_O_NONBLOCK
85 /* The only known platform that lacks O_NONBLOCK is mingw, but it
86 also lacks named pipes and Unix sockets, which are the only two
87 file types that require non-blocking handling in open().
88 Therefore, it is safe to ignore O_NONBLOCK here. It is handy
89 that mingw also lacks openat(), so that is also covered here. */
90 flags &= ~O_NONBLOCK;
91#endif
92
93#if defined _WIN32 && ! defined __CYGWIN__
94 if (strcmp (filename, "/dev/null") == 0)
95 filename = "NUL";
96#endif
97
98#if OPEN_TRAILING_SLASH_BUG
99 /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename
100 ends in a slash, as POSIX says such a filename must name a directory
101 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
102 "A pathname that contains at least one non-<slash> character and that
103 ends with one or more trailing <slash> characters shall not be resolved
104 successfully unless the last pathname component before the trailing
105 <slash> characters names an existing directory"
106 If the named file already exists as a directory, then
107 - if O_CREAT is specified, open() must fail because of the semantics
108 of O_CREAT,
109 - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
110 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html>
111 says that it fails with errno = EISDIR in this case.
112 If the named file does not exist or does not name a directory, then
113 - if O_CREAT is specified, open() must fail since open() cannot create
114 directories,
115 - if O_WRONLY or O_RDWR is specified, open() must fail because the
116 file does not contain a '.' directory. */
117 if ((flags & O_CREAT)
118 || (flags & O_ACCMODE) == O_RDWR
119 || (flags & O_ACCMODE) == O_WRONLY)
120 {
121 size_t len = strlen (filename);
122 if (len > 0 && filename[len - 1] == '/')
123 {
124 errno = EISDIR;
125 return -1;
126 }
127 }
128#endif
129
130 fd = orig_open (filename,
131 flags & ~(have_cloexec < 0 ? O_CLOEXEC : 0), mode);
132
133 if (flags & O_CLOEXEC)
134 {
135 if (! have_cloexec)
136 {
137 if (0 <= fd)
138 have_cloexec = 1;
139 else if (errno == EINVAL)
140 {
141 fd = orig_open (filename, flags & ~O_CLOEXEC, mode);
142 have_cloexec = -1;
143 }
144 }
145 if (have_cloexec < 0 && 0 <= fd)
146 set_cloexec_flag (fd, true);
147 }
148
149
150#if REPLACE_FCHDIR
151 /* Implementing fchdir and fdopendir requires the ability to open a
152 directory file descriptor. If open doesn't support that (as on
153 mingw), we use a dummy file that behaves the same as directories
154 on Linux (ie. always reports EOF on attempts to read()), and
155 override fstat() in fchdir.c to hide the fact that we have a
156 dummy. */
157 if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
158 && ((flags & O_ACCMODE) == O_RDONLY
159 || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH)))
160 {
161 struct stat statbuf;
162 if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
163 {
164 /* Maximum recursion depth of 1. */
165 fd = open ("/dev/null", flags, mode);
166 if (0 <= fd)
167 fd = _gl_register_fd (fd, filename);
168 }
169 else
170 errno = EACCES;
171 }
172#endif
173
174#if OPEN_TRAILING_SLASH_BUG
175 /* If the filename ends in a slash and fd does not refer to a directory,
176 then fail.
177 Rationale: POSIX says such a filename must name a directory
178 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
179 "A pathname that contains at least one non-<slash> character and that
180 ends with one or more trailing <slash> characters shall not be resolved
181 successfully unless the last pathname component before the trailing
182 <slash> characters names an existing directory"
183 If the named file without the slash is not a directory, open() must fail
184 with ENOTDIR. */
185 if (fd >= 0)
186 {
187 /* We know len is positive, since open did not fail with ENOENT. */
188 size_t len = strlen (filename);
189 if (filename[len - 1] == '/')
190 {
191 struct stat statbuf;
192
193 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
194 {
195 close (fd);
196 errno = ENOTDIR;
197 return -1;
198 }
199 }
200 }
201#endif
202
203#if REPLACE_FCHDIR
204 if (!REPLACE_OPEN_DIRECTORY && 0 <= fd)
205 fd = _gl_register_fd (fd, filename);
206#endif
207
208 return fd;
209}
diff --git a/gl/pathmax.h b/gl/pathmax.h
new file mode 100644
index 00000000..0dd8f3bc
--- /dev/null
+++ b/gl/pathmax.h
@@ -0,0 +1,83 @@
1/* Define PATH_MAX somehow. Requires sys/types.h.
2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2023 Free Software
3 Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _PATHMAX_H
19# define _PATHMAX_H
20
21/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
22 including the terminating NUL byte.
23 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
24 PATH_MAX is not defined on systems which have no limit on filename length,
25 such as GNU/Hurd.
26
27 This file does *not* define PATH_MAX always. Programs that use this file
28 can handle the GNU/Hurd case in several ways:
29 - Either with a package-wide handling, or with a per-file handling,
30 - Either through a
31 #ifdef PATH_MAX
32 or through a fallback like
33 #ifndef PATH_MAX
34 # define PATH_MAX 8192
35 #endif
36 or through a fallback like
37 #ifndef PATH_MAX
38 # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
39 #endif
40 */
41
42# include <unistd.h>
43
44# include <limits.h>
45
46# ifndef _POSIX_PATH_MAX
47# define _POSIX_PATH_MAX 256
48# endif
49
50/* Don't include sys/param.h if it already has been. */
51# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
52# include <sys/param.h>
53# endif
54
55# if !defined PATH_MAX && defined MAXPATHLEN
56# define PATH_MAX MAXPATHLEN
57# endif
58
59# ifdef __hpux
60/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
61 *not* including the terminating NUL byte, and is set to 1023.
62 Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
63 not defined at all any more. */
64# undef PATH_MAX
65# define PATH_MAX 1024
66# endif
67
68# if defined _WIN32 && ! defined __CYGWIN__
69/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
70 section "Maximum Path Length Limitation",
71 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation>
72 explains that the maximum size of a filename, including the terminating
73 NUL byte, is 260 = 3 + 256 + 1.
74 This is the same value as
75 - FILENAME_MAX in <stdio.h>,
76 - _MAX_PATH in <stdlib.h>,
77 - MAX_PATH in <windef.h>.
78 Undefine the original value, because mingw's <limits.h> gets it wrong. */
79# undef PATH_MAX
80# define PATH_MAX 260
81# endif
82
83#endif /* _PATHMAX_H */
diff --git a/gl/printf-args.c b/gl/printf-args.c
index c27e6bc6..5e14f654 100644
--- a/gl/printf-args.c
+++ b/gl/printf-args.c
@@ -1,19 +1,19 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2013 Free Software 2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* This file can be parametrized with the following macros: 18/* This file can be parametrized with the following macros:
19 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. 19 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
@@ -65,14 +65,12 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
65 case TYPE_ULONGINT: 65 case TYPE_ULONGINT:
66 ap->a.a_ulongint = va_arg (args, unsigned long int); 66 ap->a.a_ulongint = va_arg (args, unsigned long int);
67 break; 67 break;
68#if HAVE_LONG_LONG_INT
69 case TYPE_LONGLONGINT: 68 case TYPE_LONGLONGINT:
70 ap->a.a_longlongint = va_arg (args, long long int); 69 ap->a.a_longlongint = va_arg (args, long long int);
71 break; 70 break;
72 case TYPE_ULONGLONGINT: 71 case TYPE_ULONGLONGINT:
73 ap->a.a_ulonglongint = va_arg (args, unsigned long long int); 72 ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
74 break; 73 break;
75#endif
76 case TYPE_DOUBLE: 74 case TYPE_DOUBLE:
77 ap->a.a_double = va_arg (args, double); 75 ap->a.a_double = va_arg (args, double);
78 break; 76 break;
@@ -135,11 +133,9 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
135 case TYPE_COUNT_LONGINT_POINTER: 133 case TYPE_COUNT_LONGINT_POINTER:
136 ap->a.a_count_longint_pointer = va_arg (args, long int *); 134 ap->a.a_count_longint_pointer = va_arg (args, long int *);
137 break; 135 break;
138#if HAVE_LONG_LONG_INT
139 case TYPE_COUNT_LONGLONGINT_POINTER: 136 case TYPE_COUNT_LONGLONGINT_POINTER:
140 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); 137 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
141 break; 138 break;
142#endif
143#if ENABLE_UNISTDIO 139#if ENABLE_UNISTDIO
144 /* The unistdio extensions. */ 140 /* The unistdio extensions. */
145 case TYPE_U8_STRING: 141 case TYPE_U8_STRING:
diff --git a/gl/printf-args.h b/gl/printf-args.h
index 2a9c2a3f..f303cb19 100644
--- a/gl/printf-args.h
+++ b/gl/printf-args.h
@@ -1,19 +1,19 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2013 Free Software 2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _PRINTF_ARGS_H 18#ifndef _PRINTF_ARGS_H
19#define _PRINTF_ARGS_H 19#define _PRINTF_ARGS_H
@@ -57,10 +57,8 @@ typedef enum
57 TYPE_UINT, 57 TYPE_UINT,
58 TYPE_LONGINT, 58 TYPE_LONGINT,
59 TYPE_ULONGINT, 59 TYPE_ULONGINT,
60#if HAVE_LONG_LONG_INT
61 TYPE_LONGLONGINT, 60 TYPE_LONGLONGINT,
62 TYPE_ULONGLONGINT, 61 TYPE_ULONGLONGINT,
63#endif
64 TYPE_DOUBLE, 62 TYPE_DOUBLE,
65 TYPE_LONGDOUBLE, 63 TYPE_LONGDOUBLE,
66 TYPE_CHAR, 64 TYPE_CHAR,
@@ -75,10 +73,8 @@ typedef enum
75 TYPE_COUNT_SCHAR_POINTER, 73 TYPE_COUNT_SCHAR_POINTER,
76 TYPE_COUNT_SHORT_POINTER, 74 TYPE_COUNT_SHORT_POINTER,
77 TYPE_COUNT_INT_POINTER, 75 TYPE_COUNT_INT_POINTER,
78 TYPE_COUNT_LONGINT_POINTER 76 TYPE_COUNT_LONGINT_POINTER,
79#if HAVE_LONG_LONG_INT 77 TYPE_COUNT_LONGLONGINT_POINTER
80, TYPE_COUNT_LONGLONGINT_POINTER
81#endif
82#if ENABLE_UNISTDIO 78#if ENABLE_UNISTDIO
83 /* The unistdio extensions. */ 79 /* The unistdio extensions. */
84, TYPE_U8_STRING 80, TYPE_U8_STRING
@@ -101,10 +97,8 @@ typedef struct
101 unsigned int a_uint; 97 unsigned int a_uint;
102 long int a_longint; 98 long int a_longint;
103 unsigned long int a_ulongint; 99 unsigned long int a_ulongint;
104#if HAVE_LONG_LONG_INT
105 long long int a_longlongint; 100 long long int a_longlongint;
106 unsigned long long int a_ulonglongint; 101 unsigned long long int a_ulonglongint;
107#endif
108 float a_float; 102 float a_float;
109 double a_double; 103 double a_double;
110 long double a_longdouble; 104 long double a_longdouble;
@@ -121,9 +115,7 @@ typedef struct
121 short * a_count_short_pointer; 115 short * a_count_short_pointer;
122 int * a_count_int_pointer; 116 int * a_count_int_pointer;
123 long int * a_count_longint_pointer; 117 long int * a_count_longint_pointer;
124#if HAVE_LONG_LONG_INT
125 long long int * a_count_longlongint_pointer; 118 long long int * a_count_longlongint_pointer;
126#endif
127#if ENABLE_UNISTDIO 119#if ENABLE_UNISTDIO
128 /* The unistdio extensions. */ 120 /* The unistdio extensions. */
129 const uint8_t * a_u8_string; 121 const uint8_t * a_u8_string;
diff --git a/gl/printf-parse.c b/gl/printf-parse.c
index 23cacc1d..3040749a 100644
--- a/gl/printf-parse.c
+++ b/gl/printf-parse.c
@@ -1,18 +1,18 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999-2000, 2002-2003, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999-2000, 2002-2003, 2006-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* This file can be parametrized with the following macros: 17/* This file can be parametrized with the following macros:
18 CHAR_T The element type of the format string. 18 CHAR_T The element type of the format string.
@@ -48,16 +48,7 @@
48#include <stddef.h> 48#include <stddef.h>
49 49
50/* Get intmax_t. */ 50/* Get intmax_t. */
51#if defined IN_LIBINTL || defined IN_LIBASPRINTF 51#include <stdint.h>
52# if HAVE_STDINT_H_WITH_UINTMAX
53# include <stdint.h>
54# endif
55# if HAVE_INTTYPES_H_WITH_UINTMAX
56# include <inttypes.h>
57# endif
58#else
59# include <stdint.h>
60#endif
61 52
62/* malloc(), realloc(), free(). */ 53/* malloc(), realloc(), free(). */
63#include <stdlib.h> 54#include <stdlib.h>
@@ -419,7 +410,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
419 cp++; 410 cp++;
420 } 411 }
421#endif 412#endif
422#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 413#if defined _WIN32 && ! defined __CYGWIN__
423 /* On native Windows, PRIdMAX is defined as "I64d". 414 /* On native Windows, PRIdMAX is defined as "I64d".
424 We cannot change it to "lld" because PRIdMAX must also 415 We cannot change it to "lld" because PRIdMAX must also
425 be understood by the system's printf routines. */ 416 be understood by the system's printf routines. */
@@ -447,14 +438,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
447 switch (c) 438 switch (c)
448 { 439 {
449 case 'd': case 'i': 440 case 'd': case 'i':
450#if HAVE_LONG_LONG_INT 441 /* If 'long long' is larger than 'long': */
451 /* If 'long long' exists and is larger than 'long': */
452 if (flags >= 16 || (flags & 4)) 442 if (flags >= 16 || (flags & 4))
453 type = TYPE_LONGLONGINT; 443 type = TYPE_LONGLONGINT;
454 else 444 else
455#endif 445 /* If 'long long' is the same as 'long', we parse "lld" into
456 /* If 'long long' exists and is the same as 'long', we parse 446 TYPE_LONGINT. */
457 "lld" into TYPE_LONGINT. */
458 if (flags >= 8) 447 if (flags >= 8)
459 type = TYPE_LONGINT; 448 type = TYPE_LONGINT;
460 else if (flags & 2) 449 else if (flags & 2)
@@ -465,14 +454,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
465 type = TYPE_INT; 454 type = TYPE_INT;
466 break; 455 break;
467 case 'o': case 'u': case 'x': case 'X': 456 case 'o': case 'u': case 'x': case 'X':
468#if HAVE_LONG_LONG_INT 457 /* If 'unsigned long long' is larger than 'unsigned long': */
469 /* If 'long long' exists and is larger than 'long': */
470 if (flags >= 16 || (flags & 4)) 458 if (flags >= 16 || (flags & 4))
471 type = TYPE_ULONGLONGINT; 459 type = TYPE_ULONGLONGINT;
472 else 460 else
473#endif 461 /* If 'unsigned long long' is the same as 'unsigned long', we
474 /* If 'unsigned long long' exists and is the same as 462 parse "llu" into TYPE_ULONGINT. */
475 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
476 if (flags >= 8) 463 if (flags >= 8)
477 type = TYPE_ULONGINT; 464 type = TYPE_ULONGINT;
478 else if (flags & 2) 465 else if (flags & 2)
@@ -525,14 +512,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
525 type = TYPE_POINTER; 512 type = TYPE_POINTER;
526 break; 513 break;
527 case 'n': 514 case 'n':
528#if HAVE_LONG_LONG_INT 515 /* If 'long long' is larger than 'long': */
529 /* If 'long long' exists and is larger than 'long': */
530 if (flags >= 16 || (flags & 4)) 516 if (flags >= 16 || (flags & 4))
531 type = TYPE_COUNT_LONGLONGINT_POINTER; 517 type = TYPE_COUNT_LONGLONGINT_POINTER;
532 else 518 else
533#endif 519 /* If 'long long' is the same as 'long', we parse "lln" into
534 /* If 'long long' exists and is the same as 'long', we parse 520 TYPE_COUNT_LONGINT_POINTER. */
535 "lln" into TYPE_COUNT_LONGINT_POINTER. */
536 if (flags >= 8) 521 if (flags >= 8)
537 type = TYPE_COUNT_LONGINT_POINTER; 522 type = TYPE_COUNT_LONGINT_POINTER;
538 else if (flags & 2) 523 else if (flags & 2)
diff --git a/gl/printf-parse.h b/gl/printf-parse.h
index d8474bee..1f86e32c 100644
--- a/gl/printf-parse.h
+++ b/gl/printf-parse.h
@@ -1,19 +1,19 @@
1/* Parse printf format string. 1/* Parse printf format string.
2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2013 Free Software 2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _PRINTF_PARSE_H 18#ifndef _PRINTF_PARSE_H
19#define _PRINTF_PARSE_H 19#define _PRINTF_PARSE_H
diff --git a/gl/read.c b/gl/read.c
deleted file mode 100644
index 0fe0306f..00000000
--- a/gl/read.c
+++ /dev/null
@@ -1,85 +0,0 @@
1/* POSIX compatible read() function.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <unistd.h>
22
23#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
24
25# include <errno.h>
26# include <io.h>
27
28# define WIN32_LEAN_AND_MEAN /* avoid including junk */
29# include <windows.h>
30
31# include "msvc-inval.h"
32# include "msvc-nothrow.h"
33
34# undef read
35
36# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
37static ssize_t
38read_nothrow (int fd, void *buf, size_t count)
39{
40 ssize_t result;
41
42 TRY_MSVC_INVAL
43 {
44 result = read (fd, buf, count);
45 }
46 CATCH_MSVC_INVAL
47 {
48 result = -1;
49 errno = EBADF;
50 }
51 DONE_MSVC_INVAL;
52
53 return result;
54}
55# else
56# define read_nothrow read
57# endif
58
59ssize_t
60rpl_read (int fd, void *buf, size_t count)
61{
62 ssize_t ret = read_nothrow (fd, buf, count);
63
64# if GNULIB_NONBLOCKING
65 if (ret < 0
66 && GetLastError () == ERROR_NO_DATA)
67 {
68 HANDLE h = (HANDLE) _get_osfhandle (fd);
69 if (GetFileType (h) == FILE_TYPE_PIPE)
70 {
71 /* h is a pipe or socket. */
72 DWORD state;
73 if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL, NULL, 0)
74 && (state & PIPE_NOWAIT) != 0)
75 /* h is a pipe in non-blocking mode.
76 Change errno from EINVAL to EAGAIN. */
77 errno = EAGAIN;
78 }
79 }
80# endif
81
82 return ret;
83}
84
85#endif
diff --git a/gl/realloc.c b/gl/realloc.c
new file mode 100644
index 00000000..1063eb09
--- /dev/null
+++ b/gl/realloc.c
@@ -0,0 +1,63 @@
1/* realloc() function that is glibc compatible.
2
3 Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2023 Free Software
4 Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* written by Jim Meyering and Bruno Haible */
20
21#include <config.h>
22
23#include <stdlib.h>
24
25#include <errno.h>
26
27#include "xalloc-oversized.h"
28
29/* Call the system's realloc below. This file does not define
30 _GL_USE_STDLIB_ALLOC because it needs Gnulib's malloc if present. */
31#undef realloc
32
33/* Change the size of an allocated block of memory P to N bytes,
34 with error checking. If P is NULL, use malloc. Otherwise if N is zero,
35 free P and return NULL. */
36
37void *
38rpl_realloc (void *p, size_t n)
39{
40 if (p == NULL)
41 return malloc (n);
42
43 if (n == 0)
44 {
45 free (p);
46 return NULL;
47 }
48
49 if (xalloc_oversized (n, 1))
50 {
51 errno = ENOMEM;
52 return NULL;
53 }
54
55 void *result = realloc (p, n);
56
57#if !HAVE_MALLOC_POSIX
58 if (result == NULL)
59 errno = ENOMEM;
60#endif
61
62 return result;
63}
diff --git a/gl/reallocarray.c b/gl/reallocarray.c
new file mode 100644
index 00000000..8c99250f
--- /dev/null
+++ b/gl/reallocarray.c
@@ -0,0 +1,38 @@
1/* reallocarray function that is glibc compatible.
2
3 Copyright (C) 2017-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Darshit Shah */
19
20#include <config.h>
21
22#include <stdckdint.h>
23#include <stdlib.h>
24#include <errno.h>
25
26void *
27reallocarray (void *ptr, size_t nmemb, size_t size)
28{
29 size_t nbytes;
30 if (ckd_mul (&nbytes, nmemb, size))
31 {
32 errno = ENOMEM;
33 return NULL;
34 }
35
36 /* Rely on the semantics of GNU realloc. */
37 return realloc (ptr, nbytes);
38}
diff --git a/gl/ref-add.sin b/gl/ref-add.sin
deleted file mode 100644
index 112bcdc64..00000000
--- a/gl/ref-add.sin
+++ /dev/null
@@ -1,29 +0,0 @@
1# Add this package to a list of references stored in a text file.
2#
3# Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, see <http://www.gnu.org/licenses/>.
17#
18# Written by Bruno Haible <haible@clisp.cons.org>.
19#
20/^# Packages using this file: / {
21 s/# Packages using this file://
22 ta
23 :a
24 s/ @PACKAGE@ / @PACKAGE@ /
25 tb
26 s/ $/ @PACKAGE@ /
27 :b
28 s/^/# Packages using this file:/
29}
diff --git a/gl/ref-del.sin b/gl/ref-del.sin
deleted file mode 100644
index 6f738684..00000000
--- a/gl/ref-del.sin
+++ /dev/null
@@ -1,24 +0,0 @@
1# Remove this package from a list of references stored in a text file.
2#
3# Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, see <http://www.gnu.org/licenses/>.
17#
18# Written by Bruno Haible <haible@clisp.cons.org>.
19#
20/^# Packages using this file: / {
21 s/# Packages using this file://
22 s/ @PACKAGE@ / /
23 s/^/# Packages using this file:/
24}
diff --git a/gl/regcomp.c b/gl/regcomp.c
index f0b2e522..89478396 100644
--- a/gl/regcomp.c
+++ b/gl/regcomp.c
@@ -1,21 +1,25 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19
20#ifdef _LIBC
21# include <locale/weight.h>
22#endif
19 23
20static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, 24static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
21 size_t length, reg_syntax_t syntax); 25 size_t length, reg_syntax_t syntax);
@@ -23,14 +27,10 @@ static void re_compile_fastmap_iter (regex_t *bufp,
23 const re_dfastate_t *init_state, 27 const re_dfastate_t *init_state,
24 char *fastmap); 28 char *fastmap);
25static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); 29static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
26#ifdef RE_ENABLE_I18N
27static void free_charset (re_charset_t *cset); 30static void free_charset (re_charset_t *cset);
28#endif /* RE_ENABLE_I18N */
29static void free_workarea_compile (regex_t *preg); 31static void free_workarea_compile (regex_t *preg);
30static reg_errcode_t create_initial_state (re_dfa_t *dfa); 32static reg_errcode_t create_initial_state (re_dfa_t *dfa);
31#ifdef RE_ENABLE_I18N
32static void optimize_utf8 (re_dfa_t *dfa); 33static void optimize_utf8 (re_dfa_t *dfa);
33#endif
34static reg_errcode_t analyze (regex_t *preg); 34static reg_errcode_t analyze (regex_t *preg);
35static reg_errcode_t preorder (bin_tree_t *root, 35static reg_errcode_t preorder (bin_tree_t *root,
36 reg_errcode_t (fn (void *, bin_tree_t *)), 36 reg_errcode_t (fn (void *, bin_tree_t *)),
@@ -55,7 +55,7 @@ static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
55static Idx fetch_number (re_string_t *input, re_token_t *token, 55static Idx fetch_number (re_string_t *input, re_token_t *token,
56 reg_syntax_t syntax); 56 reg_syntax_t syntax);
57static int peek_token (re_token_t *token, re_string_t *input, 57static int peek_token (re_token_t *token, re_string_t *input,
58 reg_syntax_t syntax) internal_function; 58 reg_syntax_t syntax);
59static bin_tree_t *parse (re_string_t *regexp, regex_t *preg, 59static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
60 reg_syntax_t syntax, reg_errcode_t *err); 60 reg_syntax_t syntax, reg_errcode_t *err);
61static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg, 61static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
@@ -85,7 +85,6 @@ static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
85static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, 85static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
86 re_string_t *regexp, 86 re_string_t *regexp,
87 re_token_t *token); 87 re_token_t *token);
88#ifdef RE_ENABLE_I18N
89static reg_errcode_t build_equiv_class (bitset_t sbcset, 88static reg_errcode_t build_equiv_class (bitset_t sbcset,
90 re_charset_t *mbcset, 89 re_charset_t *mbcset,
91 Idx *equiv_class_alloc, 90 Idx *equiv_class_alloc,
@@ -96,14 +95,6 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
96 Idx *char_class_alloc, 95 Idx *char_class_alloc,
97 const char *class_name, 96 const char *class_name,
98 reg_syntax_t syntax); 97 reg_syntax_t syntax);
99#else /* not RE_ENABLE_I18N */
100static reg_errcode_t build_equiv_class (bitset_t sbcset,
101 const unsigned char *name);
102static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
103 bitset_t sbcset,
104 const char *class_name,
105 reg_syntax_t syntax);
106#endif /* not RE_ENABLE_I18N */
107static bin_tree_t *build_charclass_op (re_dfa_t *dfa, 98static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
108 RE_TRANSLATE_TYPE trans, 99 RE_TRANSLATE_TYPE trans,
109 const char *class_name, 100 const char *class_name,
@@ -149,9 +140,9 @@ static const char __re_error_msgid[] =
149 gettext_noop ("Invalid back reference") /* REG_ESUBREG */ 140 gettext_noop ("Invalid back reference") /* REG_ESUBREG */
150 "\0" 141 "\0"
151#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") 142#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
152 gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */ 143 gettext_noop ("Unmatched [, [^, [:, [., or [=") /* REG_EBRACK */
153 "\0" 144 "\0"
154#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^") 145#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [, [^, [:, [., or [=")
155 gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ 146 gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
156 "\0" 147 "\0"
157#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") 148#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
@@ -209,17 +200,9 @@ static const size_t __re_error_msgid_idx[] =
209 Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields 200 Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields
210 are set in BUFP on entry. */ 201 are set in BUFP on entry. */
211 202
212#ifdef _LIBC
213const char *
214re_compile_pattern (pattern, length, bufp)
215 const char *pattern;
216 size_t length;
217 struct re_pattern_buffer *bufp;
218#else /* size_t might promote */
219const char * 203const char *
220re_compile_pattern (const char *pattern, size_t length, 204re_compile_pattern (const char *pattern, size_t length,
221 struct re_pattern_buffer *bufp) 205 struct re_pattern_buffer *bufp)
222#endif
223{ 206{
224 reg_errcode_t ret; 207 reg_errcode_t ret;
225 208
@@ -237,9 +220,7 @@ re_compile_pattern (const char *pattern, size_t length,
237 return NULL; 220 return NULL;
238 return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); 221 return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
239} 222}
240#ifdef _LIBC
241weak_alias (__re_compile_pattern, re_compile_pattern) 223weak_alias (__re_compile_pattern, re_compile_pattern)
242#endif
243 224
244/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can 225/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can
245 also be assigned to arbitrarily: each pattern buffer stores its own 226 also be assigned to arbitrarily: each pattern buffer stores its own
@@ -257,21 +238,17 @@ reg_syntax_t re_syntax_options;
257 defined in regex.h. We return the old syntax. */ 238 defined in regex.h. We return the old syntax. */
258 239
259reg_syntax_t 240reg_syntax_t
260re_set_syntax (syntax) 241re_set_syntax (reg_syntax_t syntax)
261 reg_syntax_t syntax;
262{ 242{
263 reg_syntax_t ret = re_syntax_options; 243 reg_syntax_t ret = re_syntax_options;
264 244
265 re_syntax_options = syntax; 245 re_syntax_options = syntax;
266 return ret; 246 return ret;
267} 247}
268#ifdef _LIBC
269weak_alias (__re_set_syntax, re_set_syntax) 248weak_alias (__re_set_syntax, re_set_syntax)
270#endif
271 249
272int 250int
273re_compile_fastmap (bufp) 251re_compile_fastmap (struct re_pattern_buffer *bufp)
274 struct re_pattern_buffer *bufp;
275{ 252{
276 re_dfa_t *dfa = bufp->buffer; 253 re_dfa_t *dfa = bufp->buffer;
277 char *fastmap = bufp->fastmap; 254 char *fastmap = bufp->fastmap;
@@ -287,12 +264,9 @@ re_compile_fastmap (bufp)
287 bufp->fastmap_accurate = 1; 264 bufp->fastmap_accurate = 1;
288 return 0; 265 return 0;
289} 266}
290#ifdef _LIBC
291weak_alias (__re_compile_fastmap, re_compile_fastmap) 267weak_alias (__re_compile_fastmap, re_compile_fastmap)
292#endif
293 268
294static inline void 269static __always_inline void
295__attribute__ ((always_inline))
296re_set_fastmap (char *fastmap, bool icase, int ch) 270re_set_fastmap (char *fastmap, bool icase, int ch)
297{ 271{
298 fastmap[ch] = 1; 272 fastmap[ch] = 1;
@@ -318,7 +292,6 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
318 if (type == CHARACTER) 292 if (type == CHARACTER)
319 { 293 {
320 re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); 294 re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
321#ifdef RE_ENABLE_I18N
322 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) 295 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
323 { 296 {
324 unsigned char buf[MB_LEN_MAX]; 297 unsigned char buf[MB_LEN_MAX];
@@ -335,11 +308,10 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
335 memset (&state, '\0', sizeof (state)); 308 memset (&state, '\0', sizeof (state));
336 if (__mbrtowc (&wc, (const char *) buf, p - buf, 309 if (__mbrtowc (&wc, (const char *) buf, p - buf,
337 &state) == p - buf 310 &state) == p - buf
338 && (__wcrtomb ((char *) buf, towlower (wc), &state) 311 && (__wcrtomb ((char *) buf, __towlower (wc), &state)
339 != (size_t) -1)) 312 != (size_t) -1))
340 re_set_fastmap (fastmap, false, buf[0]); 313 re_set_fastmap (fastmap, false, buf[0]);
341 } 314 }
342#endif
343 } 315 }
344 else if (type == SIMPLE_BRACKET) 316 else if (type == SIMPLE_BRACKET)
345 { 317 {
@@ -353,13 +325,12 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
353 re_set_fastmap (fastmap, icase, ch); 325 re_set_fastmap (fastmap, icase, ch);
354 } 326 }
355 } 327 }
356#ifdef RE_ENABLE_I18N
357 else if (type == COMPLEX_BRACKET) 328 else if (type == COMPLEX_BRACKET)
358 { 329 {
359 re_charset_t *cset = dfa->nodes[node].opr.mbcset; 330 re_charset_t *cset = dfa->nodes[node].opr.mbcset;
360 Idx i; 331 Idx i;
361 332
362# ifdef _LIBC 333#ifdef _LIBC
363 /* See if we have to try all bytes which start multiple collation 334 /* See if we have to try all bytes which start multiple collation
364 elements. 335 elements.
365 e.g. In da_DK, we want to catch 'a' since "aa" is a valid 336 e.g. In da_DK, we want to catch 'a' since "aa" is a valid
@@ -375,7 +346,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
375 if (table[i] < 0) 346 if (table[i] < 0)
376 re_set_fastmap (fastmap, icase, i); 347 re_set_fastmap (fastmap, icase, i);
377 } 348 }
378# endif /* _LIBC */ 349#endif /* _LIBC */
379 350
380 /* See if we have to start the match at all multibyte characters, 351 /* See if we have to start the match at all multibyte characters,
381 i.e. where we would not find an invalid sequence. This only 352 i.e. where we would not find an invalid sequence. This only
@@ -383,9 +354,9 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
383 sets, the SIMPLE_BRACKET again suffices. */ 354 sets, the SIMPLE_BRACKET again suffices. */
384 if (dfa->mb_cur_max > 1 355 if (dfa->mb_cur_max > 1
385 && (cset->nchar_classes || cset->non_match || cset->nranges 356 && (cset->nchar_classes || cset->non_match || cset->nranges
386# ifdef _LIBC 357#ifdef _LIBC
387 || cset->nequiv_classes 358 || cset->nequiv_classes
388# endif /* _LIBC */ 359#endif /* _LIBC */
389 )) 360 ))
390 { 361 {
391 unsigned char c = 0; 362 unsigned char c = 0;
@@ -411,19 +382,14 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
411 re_set_fastmap (fastmap, icase, *(unsigned char *) buf); 382 re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
412 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) 383 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
413 { 384 {
414 if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state) 385 if (__wcrtomb (buf, __towlower (cset->mbchars[i]), &state)
415 != (size_t) -1) 386 != (size_t) -1)
416 re_set_fastmap (fastmap, false, *(unsigned char *) buf); 387 re_set_fastmap (fastmap, false, *(unsigned char *) buf);
417 } 388 }
418 } 389 }
419 } 390 }
420 } 391 }
421#endif /* RE_ENABLE_I18N */ 392 else if (type == OP_PERIOD || type == OP_UTF8_PERIOD || type == END_OF_RE)
422 else if (type == OP_PERIOD
423#ifdef RE_ENABLE_I18N
424 || type == OP_UTF8_PERIOD
425#endif /* RE_ENABLE_I18N */
426 || type == END_OF_RE)
427 { 393 {
428 memset (fastmap, '\1', sizeof (char) * SBC_MAX); 394 memset (fastmap, '\1', sizeof (char) * SBC_MAX);
429 if (type == END_OF_RE) 395 if (type == END_OF_RE)
@@ -470,10 +436,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
470 the return codes and their meanings.) */ 436 the return codes and their meanings.) */
471 437
472int 438int
473regcomp (preg, pattern, cflags) 439regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
474 regex_t *_Restrict_ preg;
475 const char *_Restrict_ pattern;
476 int cflags;
477{ 440{
478 reg_errcode_t ret; 441 reg_errcode_t ret;
479 reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED 442 reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
@@ -485,7 +448,7 @@ regcomp (preg, pattern, cflags)
485 448
486 /* Try to allocate space for the fastmap. */ 449 /* Try to allocate space for the fastmap. */
487 preg->fastmap = re_malloc (char, SBC_MAX); 450 preg->fastmap = re_malloc (char, SBC_MAX);
488 if (BE (preg->fastmap == NULL, 0)) 451 if (__glibc_unlikely (preg->fastmap == NULL))
489 return REG_ESPACE; 452 return REG_ESPACE;
490 453
491 syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; 454 syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
@@ -511,7 +474,7 @@ regcomp (preg, pattern, cflags)
511 ret = REG_EPAREN; 474 ret = REG_EPAREN;
512 475
513 /* We have already checked preg->fastmap != NULL. */ 476 /* We have already checked preg->fastmap != NULL. */
514 if (BE (ret == REG_NOERROR, 1)) 477 if (__glibc_likely (ret == REG_NOERROR))
515 /* Compute the fastmap now, since regexec cannot modify the pattern 478 /* Compute the fastmap now, since regexec cannot modify the pattern
516 buffer. This function never fails in this implementation. */ 479 buffer. This function never fails in this implementation. */
517 (void) re_compile_fastmap (preg); 480 (void) re_compile_fastmap (preg);
@@ -524,32 +487,21 @@ regcomp (preg, pattern, cflags)
524 487
525 return (int) ret; 488 return (int) ret;
526} 489}
527#ifdef _LIBC 490libc_hidden_def (__regcomp)
528weak_alias (__regcomp, regcomp) 491weak_alias (__regcomp, regcomp)
529#endif
530 492
531/* Returns a message corresponding to an error code, ERRCODE, returned 493/* Returns a message corresponding to an error code, ERRCODE, returned
532 from either regcomp or regexec. We don't use PREG here. */ 494 from either regcomp or regexec. We don't use PREG here. */
533 495
534#ifdef _LIBC
535size_t
536regerror (errcode, preg, errbuf, errbuf_size)
537 int errcode;
538 const regex_t *_Restrict_ preg;
539 char *_Restrict_ errbuf;
540 size_t errbuf_size;
541#else /* size_t might promote */
542size_t 496size_t
543regerror (int errcode, const regex_t *_Restrict_ preg, 497regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
544 char *_Restrict_ errbuf, size_t errbuf_size) 498 size_t errbuf_size)
545#endif
546{ 499{
547 const char *msg; 500 const char *msg;
548 size_t msg_size; 501 size_t msg_size;
502 int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0];
549 503
550 if (BE (errcode < 0 504 if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes))
551 || errcode >= (int) (sizeof (__re_error_msgid_idx)
552 / sizeof (__re_error_msgid_idx[0])), 0))
553 /* Only error codes returned by the rest of the code should be passed 505 /* Only error codes returned by the rest of the code should be passed
554 to this routine. If we are given anything else, or if other regex 506 to this routine. If we are given anything else, or if other regex
555 code generates an invalid error code, then the program has a bug. 507 code generates an invalid error code, then the program has a bug.
@@ -560,10 +512,10 @@ regerror (int errcode, const regex_t *_Restrict_ preg,
560 512
561 msg_size = strlen (msg) + 1; /* Includes the null. */ 513 msg_size = strlen (msg) + 1; /* Includes the null. */
562 514
563 if (BE (errbuf_size != 0, 1)) 515 if (__glibc_likely (errbuf_size != 0))
564 { 516 {
565 size_t cpy_size = msg_size; 517 size_t cpy_size = msg_size;
566 if (BE (msg_size > errbuf_size, 0)) 518 if (__glibc_unlikely (msg_size > errbuf_size))
567 { 519 {
568 cpy_size = errbuf_size - 1; 520 cpy_size = errbuf_size - 1;
569 errbuf[cpy_size] = '\0'; 521 errbuf[cpy_size] = '\0';
@@ -573,12 +525,9 @@ regerror (int errcode, const regex_t *_Restrict_ preg,
573 525
574 return msg_size; 526 return msg_size;
575} 527}
576#ifdef _LIBC
577weak_alias (__regerror, regerror) 528weak_alias (__regerror, regerror)
578#endif
579 529
580 530
581#ifdef RE_ENABLE_I18N
582/* This static array is used for the map to single-byte characters when 531/* This static array is used for the map to single-byte characters when
583 UTF-8 is used. Otherwise we would allocate memory just to initialize 532 UTF-8 is used. Otherwise we would allocate memory just to initialize
584 it the same all the time. UTF-8 is the preferred encoding so this is 533 it the same all the time. UTF-8 is the preferred encoding so this is
@@ -586,25 +535,24 @@ weak_alias (__regerror, regerror)
586static const bitset_t utf8_sb_map = 535static const bitset_t utf8_sb_map =
587{ 536{
588 /* Set the first 128 bits. */ 537 /* Set the first 128 bits. */
589# if defined __GNUC__ && !defined __STRICT_ANSI__ 538#if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
590 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX 539 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
591# else 540#else
592# if 4 * BITSET_WORD_BITS < ASCII_CHARS 541# if 4 * BITSET_WORD_BITS < ASCII_CHARS
593# error "bitset_word_t is narrower than 32 bits" 542# error "bitset_word_t is narrower than 32 bits"
594# elif 3 * BITSET_WORD_BITS < ASCII_CHARS 543# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
595 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, 544 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
596# elif 2 * BITSET_WORD_BITS < ASCII_CHARS 545# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
597 BITSET_WORD_MAX, BITSET_WORD_MAX, 546 BITSET_WORD_MAX, BITSET_WORD_MAX,
598# elif 1 * BITSET_WORD_BITS < ASCII_CHARS 547# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
599 BITSET_WORD_MAX, 548 BITSET_WORD_MAX,
600# endif 549# endif
601 (BITSET_WORD_MAX 550 (BITSET_WORD_MAX
602 >> (SBC_MAX % BITSET_WORD_BITS == 0 551 >> (SBC_MAX % BITSET_WORD_BITS == 0
603 ? 0 552 ? 0
604 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS)) 553 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
605# endif
606};
607#endif 554#endif
555};
608 556
609 557
610static void 558static void
@@ -642,10 +590,8 @@ free_dfa_content (re_dfa_t *dfa)
642 re_free (entry->array); 590 re_free (entry->array);
643 } 591 }
644 re_free (dfa->state_table); 592 re_free (dfa->state_table);
645#ifdef RE_ENABLE_I18N
646 if (dfa->sb_char != utf8_sb_map) 593 if (dfa->sb_char != utf8_sb_map)
647 re_free (dfa->sb_char); 594 re_free (dfa->sb_char);
648#endif
649 re_free (dfa->subexp_map); 595 re_free (dfa->subexp_map);
650#ifdef DEBUG 596#ifdef DEBUG
651 re_free (dfa->re_str); 597 re_free (dfa->re_str);
@@ -658,11 +604,10 @@ free_dfa_content (re_dfa_t *dfa)
658/* Free dynamically allocated space used by PREG. */ 604/* Free dynamically allocated space used by PREG. */
659 605
660void 606void
661regfree (preg) 607regfree (regex_t *preg)
662 regex_t *preg;
663{ 608{
664 re_dfa_t *dfa = preg->buffer; 609 re_dfa_t *dfa = preg->buffer;
665 if (BE (dfa != NULL, 1)) 610 if (__glibc_likely (dfa != NULL))
666 { 611 {
667 lock_fini (dfa->lock); 612 lock_fini (dfa->lock);
668 free_dfa_content (dfa); 613 free_dfa_content (dfa);
@@ -676,9 +621,8 @@ regfree (preg)
676 re_free (preg->translate); 621 re_free (preg->translate);
677 preg->translate = NULL; 622 preg->translate = NULL;
678} 623}
679#ifdef _LIBC 624libc_hidden_def (__regfree)
680weak_alias (__regfree, regfree) 625weak_alias (__regfree, regfree)
681#endif
682 626
683/* Entry points compatible with 4.2 BSD regex library. We don't define 627/* Entry points compatible with 4.2 BSD regex library. We don't define
684 them unless specifically requested. */ 628 them unless specifically requested. */
@@ -695,8 +639,7 @@ char *
695 regcomp/regexec above without link errors. */ 639 regcomp/regexec above without link errors. */
696weak_function 640weak_function
697# endif 641# endif
698re_comp (s) 642re_comp (const char *s)
699 const char *s;
700{ 643{
701 reg_errcode_t ret; 644 reg_errcode_t ret;
702 char *fastmap; 645 char *fastmap;
@@ -719,7 +662,7 @@ re_comp (s)
719 662
720 if (re_comp_buf.fastmap == NULL) 663 if (re_comp_buf.fastmap == NULL)
721 { 664 {
722 re_comp_buf.fastmap = (char *) malloc (SBC_MAX); 665 re_comp_buf.fastmap = re_malloc (char, SBC_MAX);
723 if (re_comp_buf.fastmap == NULL) 666 if (re_comp_buf.fastmap == NULL)
724 return (char *) gettext (__re_error_msgid 667 return (char *) gettext (__re_error_msgid
725 + __re_error_msgid_idx[(int) REG_ESPACE]); 668 + __re_error_msgid_idx[(int) REG_ESPACE]);
@@ -772,7 +715,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
772 715
773 /* Initialize the dfa. */ 716 /* Initialize the dfa. */
774 dfa = preg->buffer; 717 dfa = preg->buffer;
775 if (BE (preg->allocated < sizeof (re_dfa_t), 0)) 718 if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t)))
776 { 719 {
777 /* If zero allocated, but buffer is non-null, try to realloc 720 /* If zero allocated, but buffer is non-null, try to realloc
778 enough space. This loses if buffer's address is bogus, but 721 enough space. This loses if buffer's address is bogus, but
@@ -787,9 +730,9 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
787 preg->used = sizeof (re_dfa_t); 730 preg->used = sizeof (re_dfa_t);
788 731
789 err = init_dfa (dfa, length); 732 err = init_dfa (dfa, length);
790 if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0)) 733 if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0))
791 err = REG_ESPACE; 734 err = REG_ESPACE;
792 if (BE (err != REG_NOERROR, 0)) 735 if (__glibc_unlikely (err != REG_NOERROR))
793 { 736 {
794 free_dfa_content (dfa); 737 free_dfa_content (dfa);
795 preg->buffer = NULL; 738 preg->buffer = NULL;
@@ -804,7 +747,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
804 747
805 err = re_string_construct (&regexp, pattern, length, preg->translate, 748 err = re_string_construct (&regexp, pattern, length, preg->translate,
806 (syntax & RE_ICASE) != 0, dfa); 749 (syntax & RE_ICASE) != 0, dfa);
807 if (BE (err != REG_NOERROR, 0)) 750 if (__glibc_unlikely (err != REG_NOERROR))
808 { 751 {
809 re_compile_internal_free_return: 752 re_compile_internal_free_return:
810 free_workarea_compile (preg); 753 free_workarea_compile (preg);
@@ -819,19 +762,17 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
819 /* Parse the regular expression, and build a structure tree. */ 762 /* Parse the regular expression, and build a structure tree. */
820 preg->re_nsub = 0; 763 preg->re_nsub = 0;
821 dfa->str_tree = parse (&regexp, preg, syntax, &err); 764 dfa->str_tree = parse (&regexp, preg, syntax, &err);
822 if (BE (dfa->str_tree == NULL, 0)) 765 if (__glibc_unlikely (dfa->str_tree == NULL))
823 goto re_compile_internal_free_return; 766 goto re_compile_internal_free_return;
824 767
825 /* Analyze the tree and create the nfa. */ 768 /* Analyze the tree and create the nfa. */
826 err = analyze (preg); 769 err = analyze (preg);
827 if (BE (err != REG_NOERROR, 0)) 770 if (__glibc_unlikely (err != REG_NOERROR))
828 goto re_compile_internal_free_return; 771 goto re_compile_internal_free_return;
829 772
830#ifdef RE_ENABLE_I18N
831 /* If possible, do searching in single byte encoding to speed things up. */ 773 /* If possible, do searching in single byte encoding to speed things up. */
832 if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) 774 if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
833 optimize_utf8 (dfa); 775 optimize_utf8 (dfa);
834#endif
835 776
836 /* Then create the initial state of the dfa. */ 777 /* Then create the initial state of the dfa. */
837 err = create_initial_state (dfa); 778 err = create_initial_state (dfa);
@@ -840,7 +781,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
840 free_workarea_compile (preg); 781 free_workarea_compile (preg);
841 re_string_destruct (&regexp); 782 re_string_destruct (&regexp);
842 783
843 if (BE (err != REG_NOERROR, 0)) 784 if (__glibc_unlikely (err != REG_NOERROR))
844 { 785 {
845 lock_fini (dfa->lock); 786 lock_fini (dfa->lock);
846 free_dfa_content (dfa); 787 free_dfa_content (dfa);
@@ -861,11 +802,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
861#ifndef _LIBC 802#ifndef _LIBC
862 const char *codeset_name; 803 const char *codeset_name;
863#endif 804#endif
864#ifdef RE_ENABLE_I18N
865 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); 805 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
866#else
867 size_t max_i18n_object_size = 0;
868#endif
869 size_t max_object_size = 806 size_t max_object_size =
870 MAX (sizeof (struct re_state_table_entry), 807 MAX (sizeof (struct re_state_table_entry),
871 MAX (sizeof (re_token_t), 808 MAX (sizeof (re_token_t),
@@ -882,7 +819,8 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
882 calculation below, and for similar doubling calculations 819 calculation below, and for similar doubling calculations
883 elsewhere. And it's <= rather than <, because some of the 820 elsewhere. And it's <= rather than <, because some of the
884 doubling calculations add 1 afterwards. */ 821 doubling calculations add 1 afterwards. */
885 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0)) 822 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2
823 <= pat_len))
886 return REG_ESPACE; 824 return REG_ESPACE;
887 825
888 dfa->nodes_alloc = pat_len + 1; 826 dfa->nodes_alloc = pat_len + 1;
@@ -916,7 +854,6 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
916 dfa->map_notascii = 0; 854 dfa->map_notascii = 0;
917#endif 855#endif
918 856
919#ifdef RE_ENABLE_I18N
920 if (dfa->mb_cur_max > 1) 857 if (dfa->mb_cur_max > 1)
921 { 858 {
922 if (dfa->is_utf8) 859 if (dfa->is_utf8)
@@ -926,7 +863,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
926 int i, j, ch; 863 int i, j, ch;
927 864
928 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 865 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
929 if (BE (dfa->sb_char == NULL, 0)) 866 if (__glibc_unlikely (dfa->sb_char == NULL))
930 return REG_ESPACE; 867 return REG_ESPACE;
931 868
932 /* Set the bits corresponding to single byte chars. */ 869 /* Set the bits corresponding to single byte chars. */
@@ -936,16 +873,15 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
936 wint_t wch = __btowc (ch); 873 wint_t wch = __btowc (ch);
937 if (wch != WEOF) 874 if (wch != WEOF)
938 dfa->sb_char[i] |= (bitset_word_t) 1 << j; 875 dfa->sb_char[i] |= (bitset_word_t) 1 << j;
939# ifndef _LIBC 876#ifndef _LIBC
940 if (isascii (ch) && wch != ch) 877 if (isascii (ch) && wch != ch)
941 dfa->map_notascii = 1; 878 dfa->map_notascii = 1;
942# endif 879#endif
943 } 880 }
944 } 881 }
945 } 882 }
946#endif
947 883
948 if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) 884 if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
949 return REG_ESPACE; 885 return REG_ESPACE;
950 return REG_NOERROR; 886 return REG_NOERROR;
951} 887}
@@ -955,14 +891,13 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
955 character used by some operators like "\<", "\>", etc. */ 891 character used by some operators like "\<", "\>", etc. */
956 892
957static void 893static void
958internal_function
959init_word_char (re_dfa_t *dfa) 894init_word_char (re_dfa_t *dfa)
960{ 895{
961 int i = 0; 896 int i = 0;
962 int j; 897 int j;
963 int ch = 0; 898 int ch = 0;
964 dfa->word_ops_used = 1; 899 dfa->word_ops_used = 1;
965 if (BE (dfa->map_notascii == 0, 1)) 900 if (__glibc_likely (dfa->map_notascii == 0))
966 { 901 {
967 bitset_word_t bits0 = 0x00000000; 902 bitset_word_t bits0 = 0x00000000;
968 bitset_word_t bits1 = 0x03ff0000; 903 bitset_word_t bits1 = 0x03ff0000;
@@ -970,6 +905,7 @@ init_word_char (re_dfa_t *dfa)
970 bitset_word_t bits3 = 0x07fffffe; 905 bitset_word_t bits3 = 0x07fffffe;
971 if (BITSET_WORD_BITS == 64) 906 if (BITSET_WORD_BITS == 64)
972 { 907 {
908 /* Pacify gcc -Woverflow on 32-bit platformns. */
973 dfa->word_char[0] = bits1 << 31 << 1 | bits0; 909 dfa->word_char[0] = bits1 << 31 << 1 | bits0;
974 dfa->word_char[1] = bits3 << 31 << 1 | bits2; 910 dfa->word_char[1] = bits3 << 31 << 1 | bits2;
975 i = 2; 911 i = 2;
@@ -986,7 +922,7 @@ init_word_char (re_dfa_t *dfa)
986 goto general_case; 922 goto general_case;
987 ch = 128; 923 ch = 128;
988 924
989 if (BE (dfa->is_utf8, 1)) 925 if (__glibc_likely (dfa->is_utf8))
990 { 926 {
991 memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); 927 memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8);
992 return; 928 return;
@@ -1033,7 +969,7 @@ create_initial_state (re_dfa_t *dfa)
1033 first = dfa->str_tree->first->node_idx; 969 first = dfa->str_tree->first->node_idx;
1034 dfa->init_node = first; 970 dfa->init_node = first;
1035 err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); 971 err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
1036 if (BE (err != REG_NOERROR, 0)) 972 if (__glibc_unlikely (err != REG_NOERROR))
1037 return err; 973 return err;
1038 974
1039 /* The back-references which are in initial states can epsilon transit, 975 /* The back-references which are in initial states can epsilon transit,
@@ -1077,7 +1013,7 @@ create_initial_state (re_dfa_t *dfa)
1077 /* It must be the first time to invoke acquire_state. */ 1013 /* It must be the first time to invoke acquire_state. */
1078 dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); 1014 dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
1079 /* We don't check ERR here, since the initial state must not be NULL. */ 1015 /* We don't check ERR here, since the initial state must not be NULL. */
1080 if (BE (dfa->init_state == NULL, 0)) 1016 if (__glibc_unlikely (dfa->init_state == NULL))
1081 return err; 1017 return err;
1082 if (dfa->init_state->has_constraint) 1018 if (dfa->init_state->has_constraint)
1083 { 1019 {
@@ -1089,8 +1025,9 @@ create_initial_state (re_dfa_t *dfa)
1089 &init_nodes, 1025 &init_nodes,
1090 CONTEXT_NEWLINE 1026 CONTEXT_NEWLINE
1091 | CONTEXT_BEGBUF); 1027 | CONTEXT_BEGBUF);
1092 if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL 1028 if (__glibc_unlikely (dfa->init_state_word == NULL
1093 || dfa->init_state_begbuf == NULL, 0)) 1029 || dfa->init_state_nl == NULL
1030 || dfa->init_state_begbuf == NULL))
1094 return err; 1031 return err;
1095 } 1032 }
1096 else 1033 else
@@ -1101,7 +1038,6 @@ create_initial_state (re_dfa_t *dfa)
1101 return REG_NOERROR; 1038 return REG_NOERROR;
1102} 1039}
1103 1040
1104#ifdef RE_ENABLE_I18N
1105/* If it is possible to do searching in single byte encoding instead of UTF-8 1041/* If it is possible to do searching in single byte encoding instead of UTF-8
1106 to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change 1042 to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
1107 DFA nodes where needed. */ 1043 DFA nodes where needed. */
@@ -1181,7 +1117,6 @@ optimize_utf8 (re_dfa_t *dfa)
1181 dfa->is_utf8 = 0; 1117 dfa->is_utf8 = 0;
1182 dfa->has_mb_node = dfa->nbackref > 0 || has_period; 1118 dfa->has_mb_node = dfa->nbackref > 0 || has_period;
1183} 1119}
1184#endif
1185 1120
1186/* Analyze the structure tree, and calculate "first", "next", "edest", 1121/* Analyze the structure tree, and calculate "first", "next", "edest",
1187 "eclosure", and "inveclosure". */ 1122 "eclosure", and "inveclosure". */
@@ -1197,8 +1132,8 @@ analyze (regex_t *preg)
1197 dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); 1132 dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc);
1198 dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); 1133 dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
1199 dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); 1134 dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
1200 if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL 1135 if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL
1201 || dfa->eclosures == NULL, 0)) 1136 || dfa->edests == NULL || dfa->eclosures == NULL))
1202 return REG_ESPACE; 1137 return REG_ESPACE;
1203 1138
1204 dfa->subexp_map = re_malloc (Idx, preg->re_nsub); 1139 dfa->subexp_map = re_malloc (Idx, preg->re_nsub);
@@ -1213,23 +1148,23 @@ analyze (regex_t *preg)
1213 break; 1148 break;
1214 if (i == preg->re_nsub) 1149 if (i == preg->re_nsub)
1215 { 1150 {
1216 free (dfa->subexp_map); 1151 re_free (dfa->subexp_map);
1217 dfa->subexp_map = NULL; 1152 dfa->subexp_map = NULL;
1218 } 1153 }
1219 } 1154 }
1220 1155
1221 ret = postorder (dfa->str_tree, lower_subexps, preg); 1156 ret = postorder (dfa->str_tree, lower_subexps, preg);
1222 if (BE (ret != REG_NOERROR, 0)) 1157 if (__glibc_unlikely (ret != REG_NOERROR))
1223 return ret; 1158 return ret;
1224 ret = postorder (dfa->str_tree, calc_first, dfa); 1159 ret = postorder (dfa->str_tree, calc_first, dfa);
1225 if (BE (ret != REG_NOERROR, 0)) 1160 if (__glibc_unlikely (ret != REG_NOERROR))
1226 return ret; 1161 return ret;
1227 preorder (dfa->str_tree, calc_next, dfa); 1162 preorder (dfa->str_tree, calc_next, dfa);
1228 ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); 1163 ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
1229 if (BE (ret != REG_NOERROR, 0)) 1164 if (__glibc_unlikely (ret != REG_NOERROR))
1230 return ret; 1165 return ret;
1231 ret = calc_eclosure (dfa); 1166 ret = calc_eclosure (dfa);
1232 if (BE (ret != REG_NOERROR, 0)) 1167 if (__glibc_unlikely (ret != REG_NOERROR))
1233 return ret; 1168 return ret;
1234 1169
1235 /* We only need this during the prune_impossible_nodes pass in regexec.c; 1170 /* We only need this during the prune_impossible_nodes pass in regexec.c;
@@ -1238,7 +1173,7 @@ analyze (regex_t *preg)
1238 || dfa->nbackref) 1173 || dfa->nbackref)
1239 { 1174 {
1240 dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); 1175 dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
1241 if (BE (dfa->inveclosures == NULL, 0)) 1176 if (__glibc_unlikely (dfa->inveclosures == NULL))
1242 return REG_ESPACE; 1177 return REG_ESPACE;
1243 ret = calc_inveclosure (dfa); 1178 ret = calc_inveclosure (dfa);
1244 } 1179 }
@@ -1268,7 +1203,7 @@ postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
1268 do 1203 do
1269 { 1204 {
1270 reg_errcode_t err = fn (extra, node); 1205 reg_errcode_t err = fn (extra, node);
1271 if (BE (err != REG_NOERROR, 0)) 1206 if (__glibc_unlikely (err != REG_NOERROR))
1272 return err; 1207 return err;
1273 if (node->parent == NULL) 1208 if (node->parent == NULL)
1274 return REG_NOERROR; 1209 return REG_NOERROR;
@@ -1290,7 +1225,7 @@ preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
1290 for (node = root; ; ) 1225 for (node = root; ; )
1291 { 1226 {
1292 reg_errcode_t err = fn (extra, node); 1227 reg_errcode_t err = fn (extra, node);
1293 if (BE (err != REG_NOERROR, 0)) 1228 if (__glibc_unlikely (err != REG_NOERROR))
1294 return err; 1229 return err;
1295 1230
1296 /* Go to the left node, or up and to the right. */ 1231 /* Go to the left node, or up and to the right. */
@@ -1391,7 +1326,8 @@ lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
1391 cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); 1326 cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
1392 tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; 1327 tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
1393 tree = create_tree (dfa, op, tree1, CONCAT); 1328 tree = create_tree (dfa, op, tree1, CONCAT);
1394 if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) 1329 if (__glibc_unlikely (tree == NULL || tree1 == NULL
1330 || op == NULL || cls == NULL))
1395 { 1331 {
1396 *err = REG_ESPACE; 1332 *err = REG_ESPACE;
1397 return NULL; 1333 return NULL;
@@ -1417,7 +1353,7 @@ calc_first (void *extra, bin_tree_t *node)
1417 { 1353 {
1418 node->first = node; 1354 node->first = node;
1419 node->node_idx = re_dfa_add_node (dfa, node->token); 1355 node->node_idx = re_dfa_add_node (dfa, node->token);
1420 if (BE (node->node_idx == REG_MISSING, 0)) 1356 if (__glibc_unlikely (node->node_idx == -1))
1421 return REG_ESPACE; 1357 return REG_ESPACE;
1422 if (node->token.type == ANCHOR) 1358 if (node->token.type == ANCHOR)
1423 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; 1359 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
@@ -1462,7 +1398,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1462 break; 1398 break;
1463 1399
1464 case END_OF_RE: 1400 case END_OF_RE:
1465 assert (node->next == NULL); 1401 DEBUG_ASSERT (node->next == NULL);
1466 break; 1402 break;
1467 1403
1468 case OP_DUP_ASTERISK: 1404 case OP_DUP_ASTERISK:
@@ -1478,8 +1414,8 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1478 right = node->right->first->node_idx; 1414 right = node->right->first->node_idx;
1479 else 1415 else
1480 right = node->next->node_idx; 1416 right = node->next->node_idx;
1481 assert (REG_VALID_INDEX (left)); 1417 DEBUG_ASSERT (left > -1);
1482 assert (REG_VALID_INDEX (right)); 1418 DEBUG_ASSERT (right > -1);
1483 err = re_node_set_init_2 (dfa->edests + idx, left, right); 1419 err = re_node_set_init_2 (dfa->edests + idx, left, right);
1484 } 1420 }
1485 break; 1421 break;
@@ -1497,7 +1433,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1497 break; 1433 break;
1498 1434
1499 default: 1435 default:
1500 assert (!IS_EPSILON_NODE (node->token.type)); 1436 DEBUG_ASSERT (!IS_EPSILON_NODE (node->token.type));
1501 dfa->nexts[idx] = node->next->node_idx; 1437 dfa->nexts[idx] = node->next->node_idx;
1502 break; 1438 break;
1503 } 1439 }
@@ -1510,7 +1446,6 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1510 to their own constraint. */ 1446 to their own constraint. */
1511 1447
1512static reg_errcode_t 1448static reg_errcode_t
1513internal_function
1514duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, 1449duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1515 Idx root_node, unsigned int init_constraint) 1450 Idx root_node, unsigned int init_constraint)
1516{ 1451{
@@ -1529,11 +1464,11 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1529 org_dest = dfa->nexts[org_node]; 1464 org_dest = dfa->nexts[org_node];
1530 re_node_set_empty (dfa->edests + clone_node); 1465 re_node_set_empty (dfa->edests + clone_node);
1531 clone_dest = duplicate_node (dfa, org_dest, constraint); 1466 clone_dest = duplicate_node (dfa, org_dest, constraint);
1532 if (BE (clone_dest == REG_MISSING, 0)) 1467 if (__glibc_unlikely (clone_dest == -1))
1533 return REG_ESPACE; 1468 return REG_ESPACE;
1534 dfa->nexts[clone_node] = dfa->nexts[org_node]; 1469 dfa->nexts[clone_node] = dfa->nexts[org_node];
1535 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1470 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1536 if (BE (! ok, 0)) 1471 if (__glibc_unlikely (! ok))
1537 return REG_ESPACE; 1472 return REG_ESPACE;
1538 } 1473 }
1539 else if (dfa->edests[org_node].nelem == 0) 1474 else if (dfa->edests[org_node].nelem == 0)
@@ -1555,17 +1490,17 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1555 if (org_node == root_node && clone_node != org_node) 1490 if (org_node == root_node && clone_node != org_node)
1556 { 1491 {
1557 ok = re_node_set_insert (dfa->edests + clone_node, org_dest); 1492 ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
1558 if (BE (! ok, 0)) 1493 if (__glibc_unlikely (! ok))
1559 return REG_ESPACE; 1494 return REG_ESPACE;
1560 break; 1495 break;
1561 } 1496 }
1562 /* In case the node has another constraint, append it. */ 1497 /* In case the node has another constraint, append it. */
1563 constraint |= dfa->nodes[org_node].constraint; 1498 constraint |= dfa->nodes[org_node].constraint;
1564 clone_dest = duplicate_node (dfa, org_dest, constraint); 1499 clone_dest = duplicate_node (dfa, org_dest, constraint);
1565 if (BE (clone_dest == REG_MISSING, 0)) 1500 if (__glibc_unlikely (clone_dest == -1))
1566 return REG_ESPACE; 1501 return REG_ESPACE;
1567 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1502 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1568 if (BE (! ok, 0)) 1503 if (__glibc_unlikely (! ok))
1569 return REG_ESPACE; 1504 return REG_ESPACE;
1570 } 1505 }
1571 else /* dfa->edests[org_node].nelem == 2 */ 1506 else /* dfa->edests[org_node].nelem == 2 */
@@ -1576,19 +1511,19 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1576 re_node_set_empty (dfa->edests + clone_node); 1511 re_node_set_empty (dfa->edests + clone_node);
1577 /* Search for a duplicated node which satisfies the constraint. */ 1512 /* Search for a duplicated node which satisfies the constraint. */
1578 clone_dest = search_duplicated_node (dfa, org_dest, constraint); 1513 clone_dest = search_duplicated_node (dfa, org_dest, constraint);
1579 if (clone_dest == REG_MISSING) 1514 if (clone_dest == -1)
1580 { 1515 {
1581 /* There is no such duplicated node, create a new one. */ 1516 /* There is no such duplicated node, create a new one. */
1582 reg_errcode_t err; 1517 reg_errcode_t err;
1583 clone_dest = duplicate_node (dfa, org_dest, constraint); 1518 clone_dest = duplicate_node (dfa, org_dest, constraint);
1584 if (BE (clone_dest == REG_MISSING, 0)) 1519 if (__glibc_unlikely (clone_dest == -1))
1585 return REG_ESPACE; 1520 return REG_ESPACE;
1586 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1521 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1587 if (BE (! ok, 0)) 1522 if (__glibc_unlikely (! ok))
1588 return REG_ESPACE; 1523 return REG_ESPACE;
1589 err = duplicate_node_closure (dfa, org_dest, clone_dest, 1524 err = duplicate_node_closure (dfa, org_dest, clone_dest,
1590 root_node, constraint); 1525 root_node, constraint);
1591 if (BE (err != REG_NOERROR, 0)) 1526 if (__glibc_unlikely (err != REG_NOERROR))
1592 return err; 1527 return err;
1593 } 1528 }
1594 else 1529 else
@@ -1596,16 +1531,16 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1596 /* There is a duplicated node which satisfies the constraint, 1531 /* There is a duplicated node which satisfies the constraint,
1597 use it to avoid infinite loop. */ 1532 use it to avoid infinite loop. */
1598 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1533 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1599 if (BE (! ok, 0)) 1534 if (__glibc_unlikely (! ok))
1600 return REG_ESPACE; 1535 return REG_ESPACE;
1601 } 1536 }
1602 1537
1603 org_dest = dfa->edests[org_node].elems[1]; 1538 org_dest = dfa->edests[org_node].elems[1];
1604 clone_dest = duplicate_node (dfa, org_dest, constraint); 1539 clone_dest = duplicate_node (dfa, org_dest, constraint);
1605 if (BE (clone_dest == REG_MISSING, 0)) 1540 if (__glibc_unlikely (clone_dest == -1))
1606 return REG_ESPACE; 1541 return REG_ESPACE;
1607 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1542 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1608 if (BE (! ok, 0)) 1543 if (__glibc_unlikely (! ok))
1609 return REG_ESPACE; 1544 return REG_ESPACE;
1610 } 1545 }
1611 org_node = org_dest; 1546 org_node = org_dest;
@@ -1628,18 +1563,18 @@ search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
1628 && constraint == dfa->nodes[idx].constraint) 1563 && constraint == dfa->nodes[idx].constraint)
1629 return idx; /* Found. */ 1564 return idx; /* Found. */
1630 } 1565 }
1631 return REG_MISSING; /* Not found. */ 1566 return -1; /* Not found. */
1632} 1567}
1633 1568
1634/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. 1569/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
1635 Return the index of the new node, or REG_MISSING if insufficient storage is 1570 Return the index of the new node, or -1 if insufficient storage is
1636 available. */ 1571 available. */
1637 1572
1638static Idx 1573static Idx
1639duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) 1574duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
1640{ 1575{
1641 Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); 1576 Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
1642 if (BE (dup_idx != REG_MISSING, 1)) 1577 if (__glibc_likely (dup_idx != -1))
1643 { 1578 {
1644 dfa->nodes[dup_idx].constraint = constraint; 1579 dfa->nodes[dup_idx].constraint = constraint;
1645 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; 1580 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
@@ -1665,7 +1600,7 @@ calc_inveclosure (re_dfa_t *dfa)
1665 for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) 1600 for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
1666 { 1601 {
1667 ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); 1602 ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
1668 if (BE (! ok, 0)) 1603 if (__glibc_unlikely (! ok))
1669 return REG_ESPACE; 1604 return REG_ESPACE;
1670 } 1605 }
1671 } 1606 }
@@ -1680,9 +1615,7 @@ calc_eclosure (re_dfa_t *dfa)
1680{ 1615{
1681 Idx node_idx; 1616 Idx node_idx;
1682 bool incomplete; 1617 bool incomplete;
1683#ifdef DEBUG 1618 DEBUG_ASSERT (dfa->nodes_len > 0);
1684 assert (dfa->nodes_len > 0);
1685#endif
1686 incomplete = false; 1619 incomplete = false;
1687 /* For each nodes, calculate epsilon closure. */ 1620 /* For each nodes, calculate epsilon closure. */
1688 for (node_idx = 0; ; ++node_idx) 1621 for (node_idx = 0; ; ++node_idx)
@@ -1697,16 +1630,14 @@ calc_eclosure (re_dfa_t *dfa)
1697 node_idx = 0; 1630 node_idx = 0;
1698 } 1631 }
1699 1632
1700#ifdef DEBUG 1633 DEBUG_ASSERT (dfa->eclosures[node_idx].nelem != -1);
1701 assert (dfa->eclosures[node_idx].nelem != REG_MISSING);
1702#endif
1703 1634
1704 /* If we have already calculated, skip it. */ 1635 /* If we have already calculated, skip it. */
1705 if (dfa->eclosures[node_idx].nelem != 0) 1636 if (dfa->eclosures[node_idx].nelem != 0)
1706 continue; 1637 continue;
1707 /* Calculate epsilon closure of 'node_idx'. */ 1638 /* Calculate epsilon closure of 'node_idx'. */
1708 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); 1639 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
1709 if (BE (err != REG_NOERROR, 0)) 1640 if (__glibc_unlikely (err != REG_NOERROR))
1710 return err; 1641 return err;
1711 1642
1712 if (dfa->eclosures[node_idx].nelem == 0) 1643 if (dfa->eclosures[node_idx].nelem == 0)
@@ -1726,15 +1657,17 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1726 reg_errcode_t err; 1657 reg_errcode_t err;
1727 Idx i; 1658 Idx i;
1728 re_node_set eclosure; 1659 re_node_set eclosure;
1729 bool ok;
1730 bool incomplete = false; 1660 bool incomplete = false;
1731 err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); 1661 err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
1732 if (BE (err != REG_NOERROR, 0)) 1662 if (__glibc_unlikely (err != REG_NOERROR))
1733 return err; 1663 return err;
1734 1664
1665 /* An epsilon closure includes itself. */
1666 eclosure.elems[eclosure.nelem++] = node;
1667
1735 /* This indicates that we are calculating this node now. 1668 /* This indicates that we are calculating this node now.
1736 We reference this value to avoid infinite loop. */ 1669 We reference this value to avoid infinite loop. */
1737 dfa->eclosures[node].nelem = REG_MISSING; 1670 dfa->eclosures[node].nelem = -1;
1738 1671
1739 /* If the current node has constraints, duplicate all nodes 1672 /* If the current node has constraints, duplicate all nodes
1740 since they must inherit the constraints. */ 1673 since they must inherit the constraints. */
@@ -1744,7 +1677,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1744 { 1677 {
1745 err = duplicate_node_closure (dfa, node, node, node, 1678 err = duplicate_node_closure (dfa, node, node, node,
1746 dfa->nodes[node].constraint); 1679 dfa->nodes[node].constraint);
1747 if (BE (err != REG_NOERROR, 0)) 1680 if (__glibc_unlikely (err != REG_NOERROR))
1748 return err; 1681 return err;
1749 } 1682 }
1750 1683
@@ -1756,7 +1689,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1756 Idx edest = dfa->edests[node].elems[i]; 1689 Idx edest = dfa->edests[node].elems[i];
1757 /* If calculating the epsilon closure of 'edest' is in progress, 1690 /* If calculating the epsilon closure of 'edest' is in progress,
1758 return intermediate result. */ 1691 return intermediate result. */
1759 if (dfa->eclosures[edest].nelem == REG_MISSING) 1692 if (dfa->eclosures[edest].nelem == -1)
1760 { 1693 {
1761 incomplete = true; 1694 incomplete = true;
1762 continue; 1695 continue;
@@ -1766,14 +1699,14 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1766 if (dfa->eclosures[edest].nelem == 0) 1699 if (dfa->eclosures[edest].nelem == 0)
1767 { 1700 {
1768 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); 1701 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
1769 if (BE (err != REG_NOERROR, 0)) 1702 if (__glibc_unlikely (err != REG_NOERROR))
1770 return err; 1703 return err;
1771 } 1704 }
1772 else 1705 else
1773 eclosure_elem = dfa->eclosures[edest]; 1706 eclosure_elem = dfa->eclosures[edest];
1774 /* Merge the epsilon closure of 'edest'. */ 1707 /* Merge the epsilon closure of 'edest'. */
1775 err = re_node_set_merge (&eclosure, &eclosure_elem); 1708 err = re_node_set_merge (&eclosure, &eclosure_elem);
1776 if (BE (err != REG_NOERROR, 0)) 1709 if (__glibc_unlikely (err != REG_NOERROR))
1777 return err; 1710 return err;
1778 /* If the epsilon closure of 'edest' is incomplete, 1711 /* If the epsilon closure of 'edest' is incomplete,
1779 the epsilon closure of this node is also incomplete. */ 1712 the epsilon closure of this node is also incomplete. */
@@ -1784,10 +1717,6 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1784 } 1717 }
1785 } 1718 }
1786 1719
1787 /* An epsilon closure includes itself. */
1788 ok = re_node_set_insert (&eclosure, node);
1789 if (BE (! ok, 0))
1790 return REG_ESPACE;
1791 if (incomplete && !root) 1720 if (incomplete && !root)
1792 dfa->eclosures[node].nelem = 0; 1721 dfa->eclosures[node].nelem = 0;
1793 else 1722 else
@@ -1802,7 +1731,6 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1802 We must not use this function inside bracket expressions. */ 1731 We must not use this function inside bracket expressions. */
1803 1732
1804static void 1733static void
1805internal_function
1806fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax) 1734fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
1807{ 1735{
1808 re_string_skip_bytes (input, peek_token (result, input, syntax)); 1736 re_string_skip_bytes (input, peek_token (result, input, syntax));
@@ -1812,7 +1740,6 @@ fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
1812 We must not use this function inside bracket expressions. */ 1740 We must not use this function inside bracket expressions. */
1813 1741
1814static int 1742static int
1815internal_function
1816peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) 1743peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1817{ 1744{
1818 unsigned char c; 1745 unsigned char c;
@@ -1827,16 +1754,14 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1827 token->opr.c = c; 1754 token->opr.c = c;
1828 1755
1829 token->word_char = 0; 1756 token->word_char = 0;
1830#ifdef RE_ENABLE_I18N
1831 token->mb_partial = 0; 1757 token->mb_partial = 0;
1832 if (input->mb_cur_max > 1 && 1758 if (input->mb_cur_max > 1
1833 !re_string_first_byte (input, re_string_cur_idx (input))) 1759 && !re_string_first_byte (input, re_string_cur_idx (input)))
1834 { 1760 {
1835 token->type = CHARACTER; 1761 token->type = CHARACTER;
1836 token->mb_partial = 1; 1762 token->mb_partial = 1;
1837 return 1; 1763 return 1;
1838 } 1764 }
1839#endif
1840 if (c == '\\') 1765 if (c == '\\')
1841 { 1766 {
1842 unsigned char c2; 1767 unsigned char c2;
@@ -1849,7 +1774,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1849 c2 = re_string_peek_byte_case (input, 1); 1774 c2 = re_string_peek_byte_case (input, 1);
1850 token->opr.c = c2; 1775 token->opr.c = c2;
1851 token->type = CHARACTER; 1776 token->type = CHARACTER;
1852#ifdef RE_ENABLE_I18N
1853 if (input->mb_cur_max > 1) 1777 if (input->mb_cur_max > 1)
1854 { 1778 {
1855 wint_t wc = re_string_wchar_at (input, 1779 wint_t wc = re_string_wchar_at (input,
@@ -1857,7 +1781,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1857 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; 1781 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
1858 } 1782 }
1859 else 1783 else
1860#endif
1861 token->word_char = IS_WORD_CHAR (c2) != 0; 1784 token->word_char = IS_WORD_CHAR (c2) != 0;
1862 1785
1863 switch (c2) 1786 switch (c2)
@@ -1963,14 +1886,12 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1963 } 1886 }
1964 1887
1965 token->type = CHARACTER; 1888 token->type = CHARACTER;
1966#ifdef RE_ENABLE_I18N
1967 if (input->mb_cur_max > 1) 1889 if (input->mb_cur_max > 1)
1968 { 1890 {
1969 wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); 1891 wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
1970 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; 1892 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
1971 } 1893 }
1972 else 1894 else
1973#endif
1974 token->word_char = IS_WORD_CHAR (token->opr.c); 1895 token->word_char = IS_WORD_CHAR (token->opr.c);
1975 1896
1976 switch (c) 1897 switch (c)
@@ -2017,8 +1938,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2017 token->type = OP_PERIOD; 1938 token->type = OP_PERIOD;
2018 break; 1939 break;
2019 case '^': 1940 case '^':
2020 if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && 1941 if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE))
2021 re_string_cur_idx (input) != 0) 1942 && re_string_cur_idx (input) != 0)
2022 { 1943 {
2023 char prev = re_string_peek_byte (input, -1); 1944 char prev = re_string_peek_byte (input, -1);
2024 if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') 1945 if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
@@ -2028,8 +1949,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2028 token->opr.ctx_type = LINE_FIRST; 1949 token->opr.ctx_type = LINE_FIRST;
2029 break; 1950 break;
2030 case '$': 1951 case '$':
2031 if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && 1952 if (!(syntax & RE_CONTEXT_INDEP_ANCHORS)
2032 re_string_cur_idx (input) + 1 != re_string_length (input)) 1953 && re_string_cur_idx (input) + 1 != re_string_length (input))
2033 { 1954 {
2034 re_token_t next; 1955 re_token_t next;
2035 re_string_skip_bytes (input, 1); 1956 re_string_skip_bytes (input, 1);
@@ -2051,7 +1972,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2051 We must not use this function out of bracket expressions. */ 1972 We must not use this function out of bracket expressions. */
2052 1973
2053static int 1974static int
2054internal_function
2055peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) 1975peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2056{ 1976{
2057 unsigned char c; 1977 unsigned char c;
@@ -2063,14 +1983,12 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2063 c = re_string_peek_byte (input, 0); 1983 c = re_string_peek_byte (input, 0);
2064 token->opr.c = c; 1984 token->opr.c = c;
2065 1985
2066#ifdef RE_ENABLE_I18N 1986 if (input->mb_cur_max > 1
2067 if (input->mb_cur_max > 1 && 1987 && !re_string_first_byte (input, re_string_cur_idx (input)))
2068 !re_string_first_byte (input, re_string_cur_idx (input)))
2069 { 1988 {
2070 token->type = CHARACTER; 1989 token->type = CHARACTER;
2071 return 1; 1990 return 1;
2072 } 1991 }
2073#endif /* RE_ENABLE_I18N */
2074 1992
2075 if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) 1993 if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
2076 && re_string_cur_idx (input) + 1 < re_string_length (input)) 1994 && re_string_cur_idx (input) + 1 < re_string_length (input))
@@ -2098,16 +2016,18 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2098 case '.': 2016 case '.':
2099 token->type = OP_OPEN_COLL_ELEM; 2017 token->type = OP_OPEN_COLL_ELEM;
2100 break; 2018 break;
2019
2101 case '=': 2020 case '=':
2102 token->type = OP_OPEN_EQUIV_CLASS; 2021 token->type = OP_OPEN_EQUIV_CLASS;
2103 break; 2022 break;
2023
2104 case ':': 2024 case ':':
2105 if (syntax & RE_CHAR_CLASSES) 2025 if (syntax & RE_CHAR_CLASSES)
2106 { 2026 {
2107 token->type = OP_OPEN_CHAR_CLASS; 2027 token->type = OP_OPEN_CHAR_CLASS;
2108 break; 2028 break;
2109 } 2029 }
2110 /* else fall through. */ 2030 FALLTHROUGH;
2111 default: 2031 default:
2112 token->type = CHARACTER; 2032 token->type = CHARACTER;
2113 token->opr.c = c; 2033 token->opr.c = c;
@@ -2118,15 +2038,25 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2118 } 2038 }
2119 switch (c) 2039 switch (c)
2120 { 2040 {
2121 case '-':
2122 token->type = OP_CHARSET_RANGE;
2123 break;
2124 case ']': 2041 case ']':
2125 token->type = OP_CLOSE_BRACKET; 2042 token->type = OP_CLOSE_BRACKET;
2126 break; 2043 break;
2127 case '^': 2044 case '^':
2128 token->type = OP_NON_MATCH_LIST; 2045 token->type = OP_NON_MATCH_LIST;
2129 break; 2046 break;
2047 case '-':
2048 /* In V7 Unix grep and Unix awk and mawk, [...---...]
2049 (3 adjacent minus signs) stands for a single minus sign.
2050 Support that without breaking anything else. */
2051 if (! (re_string_cur_idx (input) + 2 < re_string_length (input)
2052 && re_string_peek_byte (input, 1) == '-'
2053 && re_string_peek_byte (input, 2) == '-'))
2054 {
2055 token->type = OP_CHARSET_RANGE;
2056 break;
2057 }
2058 re_string_skip_bytes (input, 2);
2059 FALLTHROUGH;
2130 default: 2060 default:
2131 token->type = CHARACTER; 2061 token->type = CHARACTER;
2132 } 2062 }
@@ -2157,14 +2087,14 @@ parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
2157 dfa->syntax = syntax; 2087 dfa->syntax = syntax;
2158 fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE); 2088 fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
2159 tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err); 2089 tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err);
2160 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2090 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2161 return NULL; 2091 return NULL;
2162 eor = create_tree (dfa, NULL, NULL, END_OF_RE); 2092 eor = create_tree (dfa, NULL, NULL, END_OF_RE);
2163 if (tree != NULL) 2093 if (tree != NULL)
2164 root = create_tree (dfa, tree, eor, CONCAT); 2094 root = create_tree (dfa, tree, eor, CONCAT);
2165 else 2095 else
2166 root = eor; 2096 root = eor;
2167 if (BE (eor == NULL || root == NULL, 0)) 2097 if (__glibc_unlikely (eor == NULL || root == NULL))
2168 { 2098 {
2169 *err = REG_ESPACE; 2099 *err = REG_ESPACE;
2170 return NULL; 2100 return NULL;
@@ -2187,8 +2117,9 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2187{ 2117{
2188 re_dfa_t *dfa = preg->buffer; 2118 re_dfa_t *dfa = preg->buffer;
2189 bin_tree_t *tree, *branch = NULL; 2119 bin_tree_t *tree, *branch = NULL;
2120 bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
2190 tree = parse_branch (regexp, preg, token, syntax, nest, err); 2121 tree = parse_branch (regexp, preg, token, syntax, nest, err);
2191 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2122 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2192 return NULL; 2123 return NULL;
2193 2124
2194 while (token->type == OP_ALT) 2125 while (token->type == OP_ALT)
@@ -2197,14 +2128,21 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2197 if (token->type != OP_ALT && token->type != END_OF_RE 2128 if (token->type != OP_ALT && token->type != END_OF_RE
2198 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) 2129 && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
2199 { 2130 {
2131 bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
2132 dfa->completed_bkref_map = initial_bkref_map;
2200 branch = parse_branch (regexp, preg, token, syntax, nest, err); 2133 branch = parse_branch (regexp, preg, token, syntax, nest, err);
2201 if (BE (*err != REG_NOERROR && branch == NULL, 0)) 2134 if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL))
2202 return NULL; 2135 {
2136 if (tree != NULL)
2137 postorder (tree, free_tree, NULL);
2138 return NULL;
2139 }
2140 dfa->completed_bkref_map |= accumulated_bkref_map;
2203 } 2141 }
2204 else 2142 else
2205 branch = NULL; 2143 branch = NULL;
2206 tree = create_tree (dfa, tree, branch, OP_ALT); 2144 tree = create_tree (dfa, tree, branch, OP_ALT);
2207 if (BE (tree == NULL, 0)) 2145 if (__glibc_unlikely (tree == NULL))
2208 { 2146 {
2209 *err = REG_ESPACE; 2147 *err = REG_ESPACE;
2210 return NULL; 2148 return NULL;
@@ -2229,14 +2167,14 @@ parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
2229 bin_tree_t *tree, *expr; 2167 bin_tree_t *tree, *expr;
2230 re_dfa_t *dfa = preg->buffer; 2168 re_dfa_t *dfa = preg->buffer;
2231 tree = parse_expression (regexp, preg, token, syntax, nest, err); 2169 tree = parse_expression (regexp, preg, token, syntax, nest, err);
2232 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2170 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2233 return NULL; 2171 return NULL;
2234 2172
2235 while (token->type != OP_ALT && token->type != END_OF_RE 2173 while (token->type != OP_ALT && token->type != END_OF_RE
2236 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) 2174 && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
2237 { 2175 {
2238 expr = parse_expression (regexp, preg, token, syntax, nest, err); 2176 expr = parse_expression (regexp, preg, token, syntax, nest, err);
2239 if (BE (*err != REG_NOERROR && expr == NULL, 0)) 2177 if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL))
2240 { 2178 {
2241 if (tree != NULL) 2179 if (tree != NULL)
2242 postorder (tree, free_tree, NULL); 2180 postorder (tree, free_tree, NULL);
@@ -2277,12 +2215,11 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2277 { 2215 {
2278 case CHARACTER: 2216 case CHARACTER:
2279 tree = create_token_tree (dfa, NULL, NULL, token); 2217 tree = create_token_tree (dfa, NULL, NULL, token);
2280 if (BE (tree == NULL, 0)) 2218 if (__glibc_unlikely (tree == NULL))
2281 { 2219 {
2282 *err = REG_ESPACE; 2220 *err = REG_ESPACE;
2283 return NULL; 2221 return NULL;
2284 } 2222 }
2285#ifdef RE_ENABLE_I18N
2286 if (dfa->mb_cur_max > 1) 2223 if (dfa->mb_cur_max > 1)
2287 { 2224 {
2288 while (!re_string_eoi (regexp) 2225 while (!re_string_eoi (regexp)
@@ -2292,34 +2229,36 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2292 fetch_token (token, regexp, syntax); 2229 fetch_token (token, regexp, syntax);
2293 mbc_remain = create_token_tree (dfa, NULL, NULL, token); 2230 mbc_remain = create_token_tree (dfa, NULL, NULL, token);
2294 tree = create_tree (dfa, tree, mbc_remain, CONCAT); 2231 tree = create_tree (dfa, tree, mbc_remain, CONCAT);
2295 if (BE (mbc_remain == NULL || tree == NULL, 0)) 2232 if (__glibc_unlikely (mbc_remain == NULL || tree == NULL))
2296 { 2233 {
2297 *err = REG_ESPACE; 2234 *err = REG_ESPACE;
2298 return NULL; 2235 return NULL;
2299 } 2236 }
2300 } 2237 }
2301 } 2238 }
2302#endif
2303 break; 2239 break;
2240
2304 case OP_OPEN_SUBEXP: 2241 case OP_OPEN_SUBEXP:
2305 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); 2242 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
2306 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2243 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2307 return NULL; 2244 return NULL;
2308 break; 2245 break;
2246
2309 case OP_OPEN_BRACKET: 2247 case OP_OPEN_BRACKET:
2310 tree = parse_bracket_exp (regexp, dfa, token, syntax, err); 2248 tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
2311 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2249 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2312 return NULL; 2250 return NULL;
2313 break; 2251 break;
2252
2314 case OP_BACK_REF: 2253 case OP_BACK_REF:
2315 if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) 2254 if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx)))
2316 { 2255 {
2317 *err = REG_ESUBREG; 2256 *err = REG_ESUBREG;
2318 return NULL; 2257 return NULL;
2319 } 2258 }
2320 dfa->used_bkref_map |= 1 << token->opr.idx; 2259 dfa->used_bkref_map |= 1 << token->opr.idx;
2321 tree = create_token_tree (dfa, NULL, NULL, token); 2260 tree = create_token_tree (dfa, NULL, NULL, token);
2322 if (BE (tree == NULL, 0)) 2261 if (__glibc_unlikely (tree == NULL))
2323 { 2262 {
2324 *err = REG_ESPACE; 2263 *err = REG_ESPACE;
2325 return NULL; 2264 return NULL;
@@ -2327,13 +2266,14 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2327 ++dfa->nbackref; 2266 ++dfa->nbackref;
2328 dfa->has_mb_node = 1; 2267 dfa->has_mb_node = 1;
2329 break; 2268 break;
2269
2330 case OP_OPEN_DUP_NUM: 2270 case OP_OPEN_DUP_NUM:
2331 if (syntax & RE_CONTEXT_INVALID_DUP) 2271 if (syntax & RE_CONTEXT_INVALID_DUP)
2332 { 2272 {
2333 *err = REG_BADRPT; 2273 *err = REG_BADRPT;
2334 return NULL; 2274 return NULL;
2335 } 2275 }
2336 /* FALLTHROUGH */ 2276 FALLTHROUGH;
2337 case OP_DUP_ASTERISK: 2277 case OP_DUP_ASTERISK:
2338 case OP_DUP_PLUS: 2278 case OP_DUP_PLUS:
2339 case OP_DUP_QUESTION: 2279 case OP_DUP_QUESTION:
@@ -2347,15 +2287,15 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2347 fetch_token (token, regexp, syntax); 2287 fetch_token (token, regexp, syntax);
2348 return parse_expression (regexp, preg, token, syntax, nest, err); 2288 return parse_expression (regexp, preg, token, syntax, nest, err);
2349 } 2289 }
2350 /* else fall through */ 2290 FALLTHROUGH;
2351 case OP_CLOSE_SUBEXP: 2291 case OP_CLOSE_SUBEXP:
2352 if ((token->type == OP_CLOSE_SUBEXP) && 2292 if ((token->type == OP_CLOSE_SUBEXP)
2353 !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) 2293 && !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
2354 { 2294 {
2355 *err = REG_ERPAREN; 2295 *err = REG_ERPAREN;
2356 return NULL; 2296 return NULL;
2357 } 2297 }
2358 /* else fall through */ 2298 FALLTHROUGH;
2359 case OP_CLOSE_DUP_NUM: 2299 case OP_CLOSE_DUP_NUM:
2360 /* We treat it as a normal character. */ 2300 /* We treat it as a normal character. */
2361 2301
@@ -2364,12 +2304,13 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2364 /* mb_partial and word_char bits should be initialized already 2304 /* mb_partial and word_char bits should be initialized already
2365 by peek_token. */ 2305 by peek_token. */
2366 tree = create_token_tree (dfa, NULL, NULL, token); 2306 tree = create_token_tree (dfa, NULL, NULL, token);
2367 if (BE (tree == NULL, 0)) 2307 if (__glibc_unlikely (tree == NULL))
2368 { 2308 {
2369 *err = REG_ESPACE; 2309 *err = REG_ESPACE;
2370 return NULL; 2310 return NULL;
2371 } 2311 }
2372 break; 2312 break;
2313
2373 case ANCHOR: 2314 case ANCHOR:
2374 if ((token->opr.ctx_type 2315 if ((token->opr.ctx_type
2375 & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST)) 2316 & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
@@ -2393,7 +2334,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2393 } 2334 }
2394 tree_last = create_token_tree (dfa, NULL, NULL, token); 2335 tree_last = create_token_tree (dfa, NULL, NULL, token);
2395 tree = create_tree (dfa, tree_first, tree_last, OP_ALT); 2336 tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
2396 if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) 2337 if (__glibc_unlikely (tree_first == NULL || tree_last == NULL
2338 || tree == NULL))
2397 { 2339 {
2398 *err = REG_ESPACE; 2340 *err = REG_ESPACE;
2399 return NULL; 2341 return NULL;
@@ -2402,7 +2344,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2402 else 2344 else
2403 { 2345 {
2404 tree = create_token_tree (dfa, NULL, NULL, token); 2346 tree = create_token_tree (dfa, NULL, NULL, token);
2405 if (BE (tree == NULL, 0)) 2347 if (__glibc_unlikely (tree == NULL))
2406 { 2348 {
2407 *err = REG_ESPACE; 2349 *err = REG_ESPACE;
2408 return NULL; 2350 return NULL;
@@ -2414,9 +2356,10 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2414 it must not be "<ANCHOR(^)><REPEAT(*)>". */ 2356 it must not be "<ANCHOR(^)><REPEAT(*)>". */
2415 fetch_token (token, regexp, syntax); 2357 fetch_token (token, regexp, syntax);
2416 return tree; 2358 return tree;
2359
2417 case OP_PERIOD: 2360 case OP_PERIOD:
2418 tree = create_token_tree (dfa, NULL, NULL, token); 2361 tree = create_token_tree (dfa, NULL, NULL, token);
2419 if (BE (tree == NULL, 0)) 2362 if (__glibc_unlikely (tree == NULL))
2420 { 2363 {
2421 *err = REG_ESPACE; 2364 *err = REG_ESPACE;
2422 return NULL; 2365 return NULL;
@@ -2424,35 +2367,38 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2424 if (dfa->mb_cur_max > 1) 2367 if (dfa->mb_cur_max > 1)
2425 dfa->has_mb_node = 1; 2368 dfa->has_mb_node = 1;
2426 break; 2369 break;
2370
2427 case OP_WORD: 2371 case OP_WORD:
2428 case OP_NOTWORD: 2372 case OP_NOTWORD:
2429 tree = build_charclass_op (dfa, regexp->trans, 2373 tree = build_charclass_op (dfa, regexp->trans,
2430 "alnum", 2374 "alnum",
2431 "_", 2375 "_",
2432 token->type == OP_NOTWORD, err); 2376 token->type == OP_NOTWORD, err);
2433 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2377 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2434 return NULL; 2378 return NULL;
2435 break; 2379 break;
2380
2436 case OP_SPACE: 2381 case OP_SPACE:
2437 case OP_NOTSPACE: 2382 case OP_NOTSPACE:
2438 tree = build_charclass_op (dfa, regexp->trans, 2383 tree = build_charclass_op (dfa, regexp->trans,
2439 "space", 2384 "space",
2440 "", 2385 "",
2441 token->type == OP_NOTSPACE, err); 2386 token->type == OP_NOTSPACE, err);
2442 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2387 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2443 return NULL; 2388 return NULL;
2444 break; 2389 break;
2390
2445 case OP_ALT: 2391 case OP_ALT:
2446 case END_OF_RE: 2392 case END_OF_RE:
2447 return NULL; 2393 return NULL;
2394
2448 case BACK_SLASH: 2395 case BACK_SLASH:
2449 *err = REG_EESCAPE; 2396 *err = REG_EESCAPE;
2450 return NULL; 2397 return NULL;
2398
2451 default: 2399 default:
2452 /* Must not happen? */ 2400 /* Must not happen? */
2453#ifdef DEBUG 2401 DEBUG_ASSERT (false);
2454 assert (0);
2455#endif
2456 return NULL; 2402 return NULL;
2457 } 2403 }
2458 fetch_token (token, regexp, syntax); 2404 fetch_token (token, regexp, syntax);
@@ -2460,14 +2406,22 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2460 while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS 2406 while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
2461 || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) 2407 || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
2462 { 2408 {
2463 tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); 2409 bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
2464 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2410 syntax, err);
2465 return NULL; 2411 if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL))
2412 {
2413 if (tree != NULL)
2414 postorder (tree, free_tree, NULL);
2415 return NULL;
2416 }
2417 tree = dup_tree;
2466 /* In BRE consecutive duplications are not allowed. */ 2418 /* In BRE consecutive duplications are not allowed. */
2467 if ((syntax & RE_CONTEXT_INVALID_DUP) 2419 if ((syntax & RE_CONTEXT_INVALID_DUP)
2468 && (token->type == OP_DUP_ASTERISK 2420 && (token->type == OP_DUP_ASTERISK
2469 || token->type == OP_OPEN_DUP_NUM)) 2421 || token->type == OP_OPEN_DUP_NUM))
2470 { 2422 {
2423 if (tree != NULL)
2424 postorder (tree, free_tree, NULL);
2471 *err = REG_BADRPT; 2425 *err = REG_BADRPT;
2472 return NULL; 2426 return NULL;
2473 } 2427 }
@@ -2500,13 +2454,14 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2500 else 2454 else
2501 { 2455 {
2502 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); 2456 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
2503 if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) 2457 if (__glibc_unlikely (*err == REG_NOERROR
2458 && token->type != OP_CLOSE_SUBEXP))
2504 { 2459 {
2505 if (tree != NULL) 2460 if (tree != NULL)
2506 postorder (tree, free_tree, NULL); 2461 postorder (tree, free_tree, NULL);
2507 *err = REG_EPAREN; 2462 *err = REG_EPAREN;
2508 } 2463 }
2509 if (BE (*err != REG_NOERROR, 0)) 2464 if (__glibc_unlikely (*err != REG_NOERROR))
2510 return NULL; 2465 return NULL;
2511 } 2466 }
2512 2467
@@ -2514,7 +2469,7 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2514 dfa->completed_bkref_map |= 1 << cur_nsub; 2469 dfa->completed_bkref_map |= 1 << cur_nsub;
2515 2470
2516 tree = create_tree (dfa, tree, NULL, SUBEXP); 2471 tree = create_tree (dfa, tree, NULL, SUBEXP);
2517 if (BE (tree == NULL, 0)) 2472 if (__glibc_unlikely (tree == NULL))
2518 { 2473 {
2519 *err = REG_ESPACE; 2474 *err = REG_ESPACE;
2520 return NULL; 2475 return NULL;
@@ -2537,7 +2492,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2537 { 2492 {
2538 end = 0; 2493 end = 0;
2539 start = fetch_number (regexp, token, syntax); 2494 start = fetch_number (regexp, token, syntax);
2540 if (start == REG_MISSING) 2495 if (start == -1)
2541 { 2496 {
2542 if (token->type == CHARACTER && token->opr.c == ',') 2497 if (token->type == CHARACTER && token->opr.c == ',')
2543 start = 0; /* We treat "{,m}" as "{0,m}". */ 2498 start = 0; /* We treat "{,m}" as "{0,m}". */
@@ -2547,17 +2502,17 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2547 return NULL; 2502 return NULL;
2548 } 2503 }
2549 } 2504 }
2550 if (BE (start != REG_ERROR, 1)) 2505 if (__glibc_likely (start != -2))
2551 { 2506 {
2552 /* We treat "{n}" as "{n,n}". */ 2507 /* We treat "{n}" as "{n,n}". */
2553 end = ((token->type == OP_CLOSE_DUP_NUM) ? start 2508 end = ((token->type == OP_CLOSE_DUP_NUM) ? start
2554 : ((token->type == CHARACTER && token->opr.c == ',') 2509 : ((token->type == CHARACTER && token->opr.c == ',')
2555 ? fetch_number (regexp, token, syntax) : REG_ERROR)); 2510 ? fetch_number (regexp, token, syntax) : -2));
2556 } 2511 }
2557 if (BE (start == REG_ERROR || end == REG_ERROR, 0)) 2512 if (__glibc_unlikely (start == -2 || end == -2))
2558 { 2513 {
2559 /* Invalid sequence. */ 2514 /* Invalid sequence. */
2560 if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) 2515 if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD)))
2561 { 2516 {
2562 if (token->type == END_OF_RE) 2517 if (token->type == END_OF_RE)
2563 *err = REG_EBRACE; 2518 *err = REG_EBRACE;
@@ -2576,15 +2531,15 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2576 return elem; 2531 return elem;
2577 } 2532 }
2578 2533
2579 if (BE ((end != REG_MISSING && start > end) 2534 if (__glibc_unlikely ((end != -1 && start > end)
2580 || token->type != OP_CLOSE_DUP_NUM, 0)) 2535 || token->type != OP_CLOSE_DUP_NUM))
2581 { 2536 {
2582 /* First number greater than second. */ 2537 /* First number greater than second. */
2583 *err = REG_BADBR; 2538 *err = REG_BADBR;
2584 return NULL; 2539 return NULL;
2585 } 2540 }
2586 2541
2587 if (BE (RE_DUP_MAX < (end == REG_MISSING ? start : end), 0)) 2542 if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end)))
2588 { 2543 {
2589 *err = REG_ESIZE; 2544 *err = REG_ESIZE;
2590 return NULL; 2545 return NULL;
@@ -2593,28 +2548,28 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2593 else 2548 else
2594 { 2549 {
2595 start = (token->type == OP_DUP_PLUS) ? 1 : 0; 2550 start = (token->type == OP_DUP_PLUS) ? 1 : 0;
2596 end = (token->type == OP_DUP_QUESTION) ? 1 : REG_MISSING; 2551 end = (token->type == OP_DUP_QUESTION) ? 1 : -1;
2597 } 2552 }
2598 2553
2599 fetch_token (token, regexp, syntax); 2554 fetch_token (token, regexp, syntax);
2600 2555
2601 if (BE (elem == NULL, 0)) 2556 if (__glibc_unlikely (elem == NULL))
2602 return NULL; 2557 return NULL;
2603 if (BE (start == 0 && end == 0, 0)) 2558 if (__glibc_unlikely (start == 0 && end == 0))
2604 { 2559 {
2605 postorder (elem, free_tree, NULL); 2560 postorder (elem, free_tree, NULL);
2606 return NULL; 2561 return NULL;
2607 } 2562 }
2608 2563
2609 /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */ 2564 /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */
2610 if (BE (start > 0, 0)) 2565 if (__glibc_unlikely (start > 0))
2611 { 2566 {
2612 tree = elem; 2567 tree = elem;
2613 for (i = 2; i <= start; ++i) 2568 for (i = 2; i <= start; ++i)
2614 { 2569 {
2615 elem = duplicate_tree (elem, dfa); 2570 elem = duplicate_tree (elem, dfa);
2616 tree = create_tree (dfa, tree, elem, CONCAT); 2571 tree = create_tree (dfa, tree, elem, CONCAT);
2617 if (BE (elem == NULL || tree == NULL, 0)) 2572 if (__glibc_unlikely (elem == NULL || tree == NULL))
2618 goto parse_dup_op_espace; 2573 goto parse_dup_op_espace;
2619 } 2574 }
2620 2575
@@ -2623,6 +2578,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2623 2578
2624 /* Duplicate ELEM before it is marked optional. */ 2579 /* Duplicate ELEM before it is marked optional. */
2625 elem = duplicate_tree (elem, dfa); 2580 elem = duplicate_tree (elem, dfa);
2581 if (__glibc_unlikely (elem == NULL))
2582 goto parse_dup_op_espace;
2626 old_tree = tree; 2583 old_tree = tree;
2627 } 2584 }
2628 else 2585 else
@@ -2635,27 +2592,23 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2635 } 2592 }
2636 2593
2637 tree = create_tree (dfa, elem, NULL, 2594 tree = create_tree (dfa, elem, NULL,
2638 (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT)); 2595 (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
2639 if (BE (tree == NULL, 0)) 2596 if (__glibc_unlikely (tree == NULL))
2640 goto parse_dup_op_espace; 2597 goto parse_dup_op_espace;
2641 2598
2642/* From gnulib's "intprops.h": 2599 /* This loop is actually executed only when end != -1,
2643 True if the arithmetic type T is signed. */
2644#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
2645
2646 /* This loop is actually executed only when end != REG_MISSING,
2647 to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have 2600 to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
2648 already created the start+1-th copy. */ 2601 already created the start+1-th copy. */
2649 if (TYPE_SIGNED (Idx) || end != REG_MISSING) 2602 if (TYPE_SIGNED (Idx) || end != -1)
2650 for (i = start + 2; i <= end; ++i) 2603 for (i = start + 2; i <= end; ++i)
2651 { 2604 {
2652 elem = duplicate_tree (elem, dfa); 2605 elem = duplicate_tree (elem, dfa);
2653 tree = create_tree (dfa, tree, elem, CONCAT); 2606 tree = create_tree (dfa, tree, elem, CONCAT);
2654 if (BE (elem == NULL || tree == NULL, 0)) 2607 if (__glibc_unlikely (elem == NULL || tree == NULL))
2655 goto parse_dup_op_espace; 2608 goto parse_dup_op_espace;
2656 2609
2657 tree = create_tree (dfa, tree, NULL, OP_ALT); 2610 tree = create_tree (dfa, tree, NULL, OP_ALT);
2658 if (BE (tree == NULL, 0)) 2611 if (__glibc_unlikely (tree == NULL))
2659 goto parse_dup_op_espace; 2612 goto parse_dup_op_espace;
2660 } 2613 }
2661 2614
@@ -2674,146 +2627,131 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2674#define BRACKET_NAME_BUF_SIZE 32 2627#define BRACKET_NAME_BUF_SIZE 32
2675 2628
2676#ifndef _LIBC 2629#ifndef _LIBC
2677 /* Local function for parse_bracket_exp only used in case of NOT _LIBC. 2630
2678 Build the range expression which starts from START_ELEM, and ends 2631/* Convert the byte B to the corresponding wide character. In a
2679 at END_ELEM. The result are written to MBCSET and SBCSET. 2632 unibyte locale, treat B as itself. In a multibyte locale, return
2680 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2633 WEOF if B is an encoding error. */
2681 mbcset->range_ends, is a pointer argument since we may 2634static wint_t
2682 update it. */ 2635parse_byte (unsigned char b, re_dfa_t const *dfa)
2636{
2637 return dfa->mb_cur_max > 1 ? __btowc (b) : b;
2638}
2639
2640/* Local function for parse_bracket_exp used in _LIBC environment.
2641 Build the range expression which starts from START_ELEM, and ends
2642 at END_ELEM. The result are written to MBCSET and SBCSET.
2643 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2644 mbcset->range_ends, is a pointer argument since we may
2645 update it. */
2683 2646
2684static reg_errcode_t 2647static reg_errcode_t
2685internal_function 2648build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
2686# ifdef RE_ENABLE_I18N 2649 bracket_elem_t *start_elem, bracket_elem_t *end_elem,
2687build_range_exp (const reg_syntax_t syntax, 2650 re_dfa_t *dfa, reg_syntax_t syntax, uint_fast32_t nrules,
2688 bitset_t sbcset, 2651 const unsigned char *collseqmb, const char *collseqwc,
2689 re_charset_t *mbcset, 2652 int_fast32_t table_size, const void *symb_table,
2690 Idx *range_alloc, 2653 const unsigned char *extra)
2691 const bracket_elem_t *start_elem,
2692 const bracket_elem_t *end_elem)
2693# else /* not RE_ENABLE_I18N */
2694build_range_exp (const reg_syntax_t syntax,
2695 bitset_t sbcset,
2696 const bracket_elem_t *start_elem,
2697 const bracket_elem_t *end_elem)
2698# endif /* not RE_ENABLE_I18N */
2699{ 2654{
2700 unsigned int start_ch, end_ch;
2701 /* Equivalence Classes and Character Classes can't be a range start/end. */ 2655 /* Equivalence Classes and Character Classes can't be a range start/end. */
2702 if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS 2656 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2703 || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 2657 || start_elem->type == CHAR_CLASS
2704 0)) 2658 || end_elem->type == EQUIV_CLASS
2659 || end_elem->type == CHAR_CLASS))
2705 return REG_ERANGE; 2660 return REG_ERANGE;
2706 2661
2707 /* We can handle no multi character collating elements without libc 2662 /* We can handle no multi character collating elements without libc
2708 support. */ 2663 support. */
2709 if (BE ((start_elem->type == COLL_SYM 2664 if (__glibc_unlikely ((start_elem->type == COLL_SYM
2710 && strlen ((char *) start_elem->opr.name) > 1) 2665 && strlen ((char *) start_elem->opr.name) > 1)
2711 || (end_elem->type == COLL_SYM 2666 || (end_elem->type == COLL_SYM
2712 && strlen ((char *) end_elem->opr.name) > 1), 0)) 2667 && strlen ((char *) end_elem->opr.name) > 1)))
2713 return REG_ECOLLATE; 2668 return REG_ECOLLATE;
2714 2669
2715# ifdef RE_ENABLE_I18N 2670 unsigned int
2716 {
2717 wchar_t wc;
2718 wint_t start_wc;
2719 wint_t end_wc;
2720
2721 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch 2671 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
2722 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] 2672 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
2723 : 0)); 2673 : 0)),
2724 end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch 2674 end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
2725 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] 2675 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
2726 : 0)); 2676 : 0));
2677 wint_t
2727 start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) 2678 start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
2728 ? __btowc (start_ch) : start_elem->opr.wch); 2679 ? parse_byte (start_ch, dfa) : start_elem->opr.wch),
2729 end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) 2680 end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
2730 ? __btowc (end_ch) : end_elem->opr.wch); 2681 ? parse_byte (end_ch, dfa) : end_elem->opr.wch);
2731 if (start_wc == WEOF || end_wc == WEOF)
2732 return REG_ECOLLATE;
2733 else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
2734 return REG_ERANGE;
2735
2736 /* Got valid collation sequence values, add them as a new entry.
2737 However, for !_LIBC we have no collation elements: if the
2738 character set is single byte, the single byte character set
2739 that we build below suffices. parse_bracket_exp passes
2740 no MBCSET if dfa->mb_cur_max == 1. */
2741 if (mbcset)
2742 {
2743 /* Check the space of the arrays. */
2744 if (BE (*range_alloc == mbcset->nranges, 0))
2745 {
2746 /* There is not enough space, need realloc. */
2747 wchar_t *new_array_start, *new_array_end;
2748 Idx new_nranges;
2749
2750 /* +1 in case of mbcset->nranges is 0. */
2751 new_nranges = 2 * mbcset->nranges + 1;
2752 /* Use realloc since mbcset->range_starts and mbcset->range_ends
2753 are NULL if *range_alloc == 0. */
2754 new_array_start = re_realloc (mbcset->range_starts, wchar_t,
2755 new_nranges);
2756 new_array_end = re_realloc (mbcset->range_ends, wchar_t,
2757 new_nranges);
2758 2682
2759 if (BE (new_array_start == NULL || new_array_end == NULL, 0)) 2683 if (start_wc == WEOF || end_wc == WEOF)
2760 return REG_ESPACE; 2684 return REG_ECOLLATE;
2685 else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2686 && start_wc > end_wc))
2687 return REG_ERANGE;
2761 2688
2762 mbcset->range_starts = new_array_start; 2689 /* Got valid collation sequence values, add them as a new entry.
2763 mbcset->range_ends = new_array_end; 2690 However, for !_LIBC we have no collation elements: if the
2764 *range_alloc = new_nranges; 2691 character set is single byte, the single byte character set
2765 } 2692 that we build below suffices. parse_bracket_exp passes
2693 no MBCSET if dfa->mb_cur_max == 1. */
2694 if (dfa->mb_cur_max > 1)
2695 {
2696 /* Check the space of the arrays. */
2697 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2698 {
2699 /* There is not enough space, need realloc. */
2700 wchar_t *new_array_start, *new_array_end;
2701 Idx new_nranges;
2766 2702
2767 mbcset->range_starts[mbcset->nranges] = start_wc; 2703 /* +1 in case of mbcset->nranges is 0. */
2768 mbcset->range_ends[mbcset->nranges++] = end_wc; 2704 new_nranges = 2 * mbcset->nranges + 1;
2769 } 2705 /* Use realloc since mbcset->range_starts and mbcset->range_ends
2706 are NULL if *range_alloc == 0. */
2707 new_array_start = re_realloc (mbcset->range_starts, wchar_t,
2708 new_nranges);
2709 new_array_end = re_realloc (mbcset->range_ends, wchar_t,
2710 new_nranges);
2711
2712 if (__glibc_unlikely (new_array_start == NULL
2713 || new_array_end == NULL))
2714 {
2715 re_free (new_array_start);
2716 re_free (new_array_end);
2717 return REG_ESPACE;
2718 }
2719
2720 mbcset->range_starts = new_array_start;
2721 mbcset->range_ends = new_array_end;
2722 *range_alloc = new_nranges;
2723 }
2724
2725 mbcset->range_starts[mbcset->nranges] = start_wc;
2726 mbcset->range_ends[mbcset->nranges++] = end_wc;
2727 }
2728
2729 /* Build the table for single byte characters. */
2730 for (wchar_t wc = 0; wc < SBC_MAX; ++wc)
2731 {
2732 if (start_wc <= wc && wc <= end_wc)
2733 bitset_set (sbcset, wc);
2734 }
2770 2735
2771 /* Build the table for single byte characters. */
2772 for (wc = 0; wc < SBC_MAX; ++wc)
2773 {
2774 if (start_wc <= wc && wc <= end_wc)
2775 bitset_set (sbcset, wc);
2776 }
2777 }
2778# else /* not RE_ENABLE_I18N */
2779 {
2780 unsigned int ch;
2781 start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
2782 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
2783 : 0));
2784 end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
2785 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
2786 : 0));
2787 if (start_ch > end_ch)
2788 return REG_ERANGE;
2789 /* Build the table for single byte characters. */
2790 for (ch = 0; ch < SBC_MAX; ++ch)
2791 if (start_ch <= ch && ch <= end_ch)
2792 bitset_set (sbcset, ch);
2793 }
2794# endif /* not RE_ENABLE_I18N */
2795 return REG_NOERROR; 2736 return REG_NOERROR;
2796} 2737}
2797#endif /* not _LIBC */ 2738#endif /* not _LIBC */
2798 2739
2799#ifndef _LIBC 2740#ifndef _LIBC
2800/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.. 2741/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.
2801 Build the collating element which is represented by NAME. 2742 Build the collating element which is represented by NAME.
2802 The result are written to MBCSET and SBCSET. 2743 The result are written to MBCSET and SBCSET.
2803 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a 2744 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
2804 pointer argument since we may update it. */ 2745 pointer argument since we may update it. */
2805 2746
2806static reg_errcode_t 2747static reg_errcode_t
2807internal_function
2808# ifdef RE_ENABLE_I18N
2809build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, 2748build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2810 Idx *coll_sym_alloc, const unsigned char *name) 2749 Idx *coll_sym_alloc, const unsigned char *name,
2811# else /* not RE_ENABLE_I18N */ 2750 uint_fast32_t nrules, int_fast32_t table_size,
2812build_collating_symbol (bitset_t sbcset, const unsigned char *name) 2751 const void *symb_table, const unsigned char *extra)
2813# endif /* not RE_ENABLE_I18N */
2814{ 2752{
2815 size_t name_len = strlen ((const char *) name); 2753 size_t name_len = strlen ((const char *) name);
2816 if (BE (name_len != 1, 0)) 2754 if (__glibc_unlikely (name_len != 1))
2817 return REG_ECOLLATE; 2755 return REG_ECOLLATE;
2818 else 2756 else
2819 { 2757 {
@@ -2823,267 +2761,280 @@ build_collating_symbol (bitset_t sbcset, const unsigned char *name)
2823} 2761}
2824#endif /* not _LIBC */ 2762#endif /* not _LIBC */
2825 2763
2826/* This function parse bracket expression like "[abc]", "[a-c]",
2827 "[[.a-a.]]" etc. */
2828
2829static bin_tree_t *
2830parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2831 reg_syntax_t syntax, reg_errcode_t *err)
2832{
2833#ifdef _LIBC 2764#ifdef _LIBC
2834 const unsigned char *collseqmb; 2765/* Local function for parse_bracket_exp used in _LIBC environment.
2835 const char *collseqwc; 2766 Seek the collating symbol entry corresponding to NAME.
2836 uint32_t nrules; 2767 Return the index of the symbol in the SYMB_TABLE,
2837 int32_t table_size; 2768 or -1 if not found. */
2838 const int32_t *symb_table; 2769
2839 const unsigned char *extra; 2770static __always_inline int32_t
2840 2771seek_collating_symbol_entry (const unsigned char *name, size_t name_len,
2841 /* Local function for parse_bracket_exp used in _LIBC environment. 2772 const int32_t *symb_table,
2842 Seek the collating symbol entry corresponding to NAME. 2773 int_fast32_t table_size,
2843 Return the index of the symbol in the SYMB_TABLE, 2774 const unsigned char *extra)
2844 or -1 if not found. */ 2775{
2845 2776 int_fast32_t elem;
2846 auto inline int32_t
2847 __attribute__ ((always_inline))
2848 seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
2849 {
2850 int32_t elem;
2851
2852 for (elem = 0; elem < table_size; elem++)
2853 if (symb_table[2 * elem] != 0)
2854 {
2855 int32_t idx = symb_table[2 * elem + 1];
2856 /* Skip the name of collating element name. */
2857 idx += 1 + extra[idx];
2858 if (/* Compare the length of the name. */
2859 name_len == extra[idx]
2860 /* Compare the name. */
2861 && memcmp (name, &extra[idx + 1], name_len) == 0)
2862 /* Yep, this is the entry. */
2863 return elem;
2864 }
2865 return -1;
2866 }
2867 2777
2868 /* Local function for parse_bracket_exp used in _LIBC environment. 2778 for (elem = 0; elem < table_size; elem++)
2869 Look up the collation sequence value of BR_ELEM. 2779 if (symb_table[2 * elem] != 0)
2870 Return the value if succeeded, UINT_MAX otherwise. */ 2780 {
2781 int32_t idx = symb_table[2 * elem + 1];
2782 /* Skip the name of collating element name. */
2783 idx += 1 + extra[idx];
2784 if (/* Compare the length of the name. */
2785 name_len == extra[idx]
2786 /* Compare the name. */
2787 && memcmp (name, &extra[idx + 1], name_len) == 0)
2788 /* Yep, this is the entry. */
2789 return elem;
2790 }
2791 return -1;
2792}
2871 2793
2872 auto inline unsigned int 2794/* Local function for parse_bracket_exp used in _LIBC environment.
2873 __attribute__ ((always_inline)) 2795 Look up the collation sequence value of BR_ELEM.
2874 lookup_collation_sequence_value (bracket_elem_t *br_elem) 2796 Return the value if succeeded, UINT_MAX otherwise. */
2797
2798static __always_inline unsigned int
2799lookup_collation_sequence_value (bracket_elem_t *br_elem, uint32_t nrules,
2800 const unsigned char *collseqmb,
2801 const char *collseqwc,
2802 int_fast32_t table_size,
2803 const int32_t *symb_table,
2804 const unsigned char *extra)
2805{
2806 if (br_elem->type == SB_CHAR)
2875 { 2807 {
2876 if (br_elem->type == SB_CHAR) 2808 /* if (MB_CUR_MAX == 1) */
2877 { 2809 if (nrules == 0)
2878 /* 2810 return collseqmb[br_elem->opr.ch];
2879 if (MB_CUR_MAX == 1) 2811 else
2880 */
2881 if (nrules == 0)
2882 return collseqmb[br_elem->opr.ch];
2883 else
2884 {
2885 wint_t wc = __btowc (br_elem->opr.ch);
2886 return __collseq_table_lookup (collseqwc, wc);
2887 }
2888 }
2889 else if (br_elem->type == MB_CHAR)
2890 { 2812 {
2891 if (nrules != 0) 2813 wint_t wc = __btowc (br_elem->opr.ch);
2892 return __collseq_table_lookup (collseqwc, br_elem->opr.wch); 2814 return __collseq_table_lookup (collseqwc, wc);
2893 } 2815 }
2894 else if (br_elem->type == COLL_SYM) 2816 }
2817 else if (br_elem->type == MB_CHAR)
2818 {
2819 if (nrules != 0)
2820 return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
2821 }
2822 else if (br_elem->type == COLL_SYM)
2823 {
2824 size_t sym_name_len = strlen ((char *) br_elem->opr.name);
2825 if (nrules != 0)
2895 { 2826 {
2896 size_t sym_name_len = strlen ((char *) br_elem->opr.name); 2827 int32_t elem, idx;
2897 if (nrules != 0) 2828 elem = seek_collating_symbol_entry (br_elem->opr.name,
2829 sym_name_len,
2830 symb_table, table_size,
2831 extra);
2832 if (elem != -1)
2898 { 2833 {
2899 int32_t elem, idx; 2834 /* We found the entry. */
2900 elem = seek_collating_symbol_entry (br_elem->opr.name, 2835 idx = symb_table[2 * elem + 1];
2901 sym_name_len); 2836 /* Skip the name of collating element name. */
2902 if (elem != -1) 2837 idx += 1 + extra[idx];
2903 { 2838 /* Skip the byte sequence of the collating element. */
2904 /* We found the entry. */ 2839 idx += 1 + extra[idx];
2905 idx = symb_table[2 * elem + 1]; 2840 /* Adjust for the alignment. */
2906 /* Skip the name of collating element name. */ 2841 idx = (idx + 3) & ~3;
2907 idx += 1 + extra[idx]; 2842 /* Skip the multibyte collation sequence value. */
2908 /* Skip the byte sequence of the collating element. */ 2843 idx += sizeof (unsigned int);
2909 idx += 1 + extra[idx]; 2844 /* Skip the wide char sequence of the collating element. */
2910 /* Adjust for the alignment. */ 2845 idx += sizeof (unsigned int) *
2911 idx = (idx + 3) & ~3; 2846 (1 + *(unsigned int *) (extra + idx));
2912 /* Skip the multibyte collation sequence value. */ 2847 /* Return the collation sequence value. */
2913 idx += sizeof (unsigned int); 2848 return *(unsigned int *) (extra + idx);
2914 /* Skip the wide char sequence of the collating element. */
2915 idx += sizeof (unsigned int) *
2916 (1 + *(unsigned int *) (extra + idx));
2917 /* Return the collation sequence value. */
2918 return *(unsigned int *) (extra + idx);
2919 }
2920 else if (sym_name_len == 1)
2921 {
2922 /* No valid character. Match it as a single byte
2923 character. */
2924 return collseqmb[br_elem->opr.name[0]];
2925 }
2926 } 2849 }
2927 else if (sym_name_len == 1) 2850 else if (sym_name_len == 1)
2928 return collseqmb[br_elem->opr.name[0]]; 2851 {
2852 /* No valid character. Match it as a single byte
2853 character. */
2854 return collseqmb[br_elem->opr.name[0]];
2855 }
2929 } 2856 }
2930 return UINT_MAX; 2857 else if (sym_name_len == 1)
2858 return collseqmb[br_elem->opr.name[0]];
2931 } 2859 }
2860 return UINT_MAX;
2861}
2932 2862
2933 /* Local function for parse_bracket_exp used in _LIBC environment. 2863/* Local function for parse_bracket_exp used in _LIBC environment.
2934 Build the range expression which starts from START_ELEM, and ends 2864 Build the range expression which starts from START_ELEM, and ends
2935 at END_ELEM. The result are written to MBCSET and SBCSET. 2865 at END_ELEM. The result are written to MBCSET and SBCSET.
2936 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2866 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2937 mbcset->range_ends, is a pointer argument since we may 2867 mbcset->range_ends, is a pointer argument since we may
2938 update it. */ 2868 update it. */
2939 2869
2940 auto inline reg_errcode_t 2870static __always_inline reg_errcode_t
2941 __attribute__ ((always_inline)) 2871build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
2942 build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, 2872 bracket_elem_t *start_elem, bracket_elem_t *end_elem,
2943 bracket_elem_t *start_elem, bracket_elem_t *end_elem) 2873 re_dfa_t *dfa, reg_syntax_t syntax, uint32_t nrules,
2944 { 2874 const unsigned char *collseqmb, const char *collseqwc,
2945 unsigned int ch; 2875 int_fast32_t table_size, const int32_t *symb_table,
2946 uint32_t start_collseq; 2876 const unsigned char *extra)
2947 uint32_t end_collseq; 2877{
2948 2878 unsigned int ch;
2949 /* Equivalence Classes and Character Classes can't be a range 2879 uint32_t start_collseq;
2950 start/end. */ 2880 uint32_t end_collseq;
2951 if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS 2881
2952 || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 2882 /* Equivalence Classes and Character Classes can't be a range
2953 0)) 2883 start/end. */
2954 return REG_ERANGE; 2884 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2885 || start_elem->type == CHAR_CLASS
2886 || end_elem->type == EQUIV_CLASS
2887 || end_elem->type == CHAR_CLASS))
2888 return REG_ERANGE;
2955 2889
2956 /* FIXME: Implement rational ranges here, too. */ 2890 /* FIXME: Implement rational ranges here, too. */
2957 start_collseq = lookup_collation_sequence_value (start_elem); 2891 start_collseq = lookup_collation_sequence_value (start_elem, nrules, collseqmb, collseqwc,
2958 end_collseq = lookup_collation_sequence_value (end_elem); 2892 table_size, symb_table, extra);
2959 /* Check start/end collation sequence values. */ 2893 end_collseq = lookup_collation_sequence_value (end_elem, nrules, collseqmb, collseqwc,
2960 if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) 2894 table_size, symb_table, extra);
2961 return REG_ECOLLATE; 2895 /* Check start/end collation sequence values. */
2962 if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) 2896 if (__glibc_unlikely (start_collseq == UINT_MAX
2963 return REG_ERANGE; 2897 || end_collseq == UINT_MAX))
2898 return REG_ECOLLATE;
2899 if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2900 && start_collseq > end_collseq))
2901 return REG_ERANGE;
2964 2902
2965 /* Got valid collation sequence values, add them as a new entry. 2903 /* Got valid collation sequence values, add them as a new entry.
2966 However, if we have no collation elements, and the character set 2904 However, if we have no collation elements, and the character set
2967 is single byte, the single byte character set that we 2905 is single byte, the single byte character set that we
2968 build below suffices. */ 2906 build below suffices. */
2969 if (nrules > 0 || dfa->mb_cur_max > 1) 2907 if (nrules > 0 || dfa->mb_cur_max > 1)
2908 {
2909 /* Check the space of the arrays. */
2910 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2970 { 2911 {
2971 /* Check the space of the arrays. */ 2912 /* There is not enough space, need realloc. */
2972 if (BE (*range_alloc == mbcset->nranges, 0)) 2913 uint32_t *new_array_start;
2973 { 2914 uint32_t *new_array_end;
2974 /* There is not enough space, need realloc. */ 2915 int new_nranges;
2975 uint32_t *new_array_start;
2976 uint32_t *new_array_end;
2977 Idx new_nranges;
2978
2979 /* +1 in case of mbcset->nranges is 0. */
2980 new_nranges = 2 * mbcset->nranges + 1;
2981 new_array_start = re_realloc (mbcset->range_starts, uint32_t,
2982 new_nranges);
2983 new_array_end = re_realloc (mbcset->range_ends, uint32_t,
2984 new_nranges);
2985
2986 if (BE (new_array_start == NULL || new_array_end == NULL, 0))
2987 return REG_ESPACE;
2988 2916
2989 mbcset->range_starts = new_array_start; 2917 /* +1 in case of mbcset->nranges is 0. */
2990 mbcset->range_ends = new_array_end; 2918 new_nranges = 2 * mbcset->nranges + 1;
2991 *range_alloc = new_nranges; 2919 new_array_start = re_realloc (mbcset->range_starts, uint32_t,
2992 } 2920 new_nranges);
2921 new_array_end = re_realloc (mbcset->range_ends, uint32_t,
2922 new_nranges);
2993 2923
2994 mbcset->range_starts[mbcset->nranges] = start_collseq; 2924 if (__glibc_unlikely (new_array_start == NULL
2995 mbcset->range_ends[mbcset->nranges++] = end_collseq; 2925 || new_array_end == NULL))
2996 } 2926 return REG_ESPACE;
2997 2927
2998 /* Build the table for single byte characters. */ 2928 mbcset->range_starts = new_array_start;
2999 for (ch = 0; ch < SBC_MAX; ch++) 2929 mbcset->range_ends = new_array_end;
3000 { 2930 *range_alloc = new_nranges;
3001 uint32_t ch_collseq;
3002 /*
3003 if (MB_CUR_MAX == 1)
3004 */
3005 if (nrules == 0)
3006 ch_collseq = collseqmb[ch];
3007 else
3008 ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
3009 if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
3010 bitset_set (sbcset, ch);
3011 } 2931 }
3012 return REG_NOERROR; 2932
2933 mbcset->range_starts[mbcset->nranges] = start_collseq;
2934 mbcset->range_ends[mbcset->nranges++] = end_collseq;
3013 } 2935 }
3014 2936
3015 /* Local function for parse_bracket_exp used in _LIBC environment. 2937 /* Build the table for single byte characters. */
3016 Build the collating element which is represented by NAME. 2938 for (ch = 0; ch < SBC_MAX; ch++)
3017 The result are written to MBCSET and SBCSET. 2939 {
3018 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a 2940 uint32_t ch_collseq;
3019 pointer argument since we may update it. */ 2941 /* if (MB_CUR_MAX == 1) */
2942 if (nrules == 0)
2943 ch_collseq = collseqmb[ch];
2944 else
2945 ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
2946 if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
2947 bitset_set (sbcset, ch);
2948 }
2949 return REG_NOERROR;
2950}
3020 2951
3021 auto inline reg_errcode_t 2952/* Local function for parse_bracket_exp used in _LIBC environment.
3022 __attribute__ ((always_inline)) 2953 Build the collating element which is represented by NAME.
3023 build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, 2954 The result are written to MBCSET and SBCSET.
3024 Idx *coll_sym_alloc, const unsigned char *name) 2955 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
2956 pointer argument since we may update it. */
2957
2958static __always_inline reg_errcode_t
2959build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2960 Idx *coll_sym_alloc, const unsigned char *name,
2961 uint_fast32_t nrules, int_fast32_t table_size,
2962 const int32_t *symb_table, const unsigned char *extra)
2963{
2964 int32_t elem, idx;
2965 size_t name_len = strlen ((const char *) name);
2966 if (nrules != 0)
3025 { 2967 {
3026 int32_t elem, idx; 2968 elem = seek_collating_symbol_entry (name, name_len, symb_table,
3027 size_t name_len = strlen ((const char *) name); 2969 table_size, extra);
3028 if (nrules != 0) 2970 if (elem != -1)
3029 { 2971 {
3030 elem = seek_collating_symbol_entry (name, name_len); 2972 /* We found the entry. */
3031 if (elem != -1) 2973 idx = symb_table[2 * elem + 1];
3032 { 2974 /* Skip the name of collating element name. */
3033 /* We found the entry. */ 2975 idx += 1 + extra[idx];
3034 idx = symb_table[2 * elem + 1]; 2976 }
3035 /* Skip the name of collating element name. */ 2977 else if (name_len == 1)
3036 idx += 1 + extra[idx]; 2978 {
3037 } 2979 /* No valid character, treat it as a normal
3038 else if (name_len == 1) 2980 character. */
3039 { 2981 bitset_set (sbcset, name[0]);
3040 /* No valid character, treat it as a normal
3041 character. */
3042 bitset_set (sbcset, name[0]);
3043 return REG_NOERROR;
3044 }
3045 else
3046 return REG_ECOLLATE;
3047
3048 /* Got valid collation sequence, add it as a new entry. */
3049 /* Check the space of the arrays. */
3050 if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0))
3051 {
3052 /* Not enough, realloc it. */
3053 /* +1 in case of mbcset->ncoll_syms is 0. */
3054 Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
3055 /* Use realloc since mbcset->coll_syms is NULL
3056 if *alloc == 0. */
3057 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3058 new_coll_sym_alloc);
3059 if (BE (new_coll_syms == NULL, 0))
3060 return REG_ESPACE;
3061 mbcset->coll_syms = new_coll_syms;
3062 *coll_sym_alloc = new_coll_sym_alloc;
3063 }
3064 mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
3065 return REG_NOERROR; 2982 return REG_NOERROR;
3066 } 2983 }
3067 else 2984 else
2985 return REG_ECOLLATE;
2986
2987 /* Got valid collation sequence, add it as a new entry. */
2988 /* Check the space of the arrays. */
2989 if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
3068 { 2990 {
3069 if (BE (name_len != 1, 0)) 2991 /* Not enough, realloc it. */
3070 return REG_ECOLLATE; 2992 /* +1 in case of mbcset->ncoll_syms is 0. */
3071 else 2993 int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
3072 { 2994 /* Use realloc since mbcset->coll_syms is NULL
3073 bitset_set (sbcset, name[0]); 2995 if *alloc == 0. */
3074 return REG_NOERROR; 2996 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3075 } 2997 new_coll_sym_alloc);
2998 if (__glibc_unlikely (new_coll_syms == NULL))
2999 return REG_ESPACE;
3000 mbcset->coll_syms = new_coll_syms;
3001 *coll_sym_alloc = new_coll_sym_alloc;
3076 } 3002 }
3003 mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
3004 return REG_NOERROR;
3077 } 3005 }
3078#endif 3006 else
3007 {
3008 if (__glibc_unlikely (name_len != 1))
3009 return REG_ECOLLATE;
3010 else
3011 {
3012 bitset_set (sbcset, name[0]);
3013 return REG_NOERROR;
3014 }
3015 }
3016}
3017#endif /* _LIBC */
3018
3019/* This function parse bracket expression like "[abc]", "[a-c]",
3020 "[[.a-a.]]" etc. */
3021
3022static bin_tree_t *
3023parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3024 reg_syntax_t syntax, reg_errcode_t *err)
3025{
3026 const unsigned char *collseqmb = NULL;
3027 const char *collseqwc = NULL;
3028 uint_fast32_t nrules = 0;
3029 int_fast32_t table_size = 0;
3030 const void *symb_table = NULL;
3031 const unsigned char *extra = NULL;
3079 3032
3080 re_token_t br_token; 3033 re_token_t br_token;
3081 re_bitset_ptr_t sbcset; 3034 re_bitset_ptr_t sbcset;
3082#ifdef RE_ENABLE_I18N
3083 re_charset_t *mbcset; 3035 re_charset_t *mbcset;
3084 Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; 3036 Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
3085 Idx equiv_class_alloc = 0, char_class_alloc = 0; 3037 Idx equiv_class_alloc = 0, char_class_alloc = 0;
3086#endif /* not RE_ENABLE_I18N */
3087 bool non_match = false; 3038 bool non_match = false;
3088 bin_tree_t *work_tree; 3039 bin_tree_t *work_tree;
3089 int token_len; 3040 int token_len;
@@ -3099,47 +3050,36 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3099 */ 3050 */
3100 collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); 3051 collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
3101 table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); 3052 table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
3102 symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, 3053 symb_table = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB);
3103 _NL_COLLATE_SYMB_TABLEMB);
3104 extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, 3054 extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
3105 _NL_COLLATE_SYMB_EXTRAMB); 3055 _NL_COLLATE_SYMB_EXTRAMB);
3106 } 3056 }
3107#endif 3057#endif
3108 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3058 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
3109#ifdef RE_ENABLE_I18N
3110 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3059 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3111#endif /* RE_ENABLE_I18N */ 3060 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
3112#ifdef RE_ENABLE_I18N
3113 if (BE (sbcset == NULL || mbcset == NULL, 0))
3114#else
3115 if (BE (sbcset == NULL, 0))
3116#endif /* RE_ENABLE_I18N */
3117 { 3061 {
3118 re_free (sbcset); 3062 re_free (sbcset);
3119#ifdef RE_ENABLE_I18N
3120 re_free (mbcset); 3063 re_free (mbcset);
3121#endif
3122 *err = REG_ESPACE; 3064 *err = REG_ESPACE;
3123 return NULL; 3065 return NULL;
3124 } 3066 }
3125 3067
3126 token_len = peek_token_bracket (token, regexp, syntax); 3068 token_len = peek_token_bracket (token, regexp, syntax);
3127 if (BE (token->type == END_OF_RE, 0)) 3069 if (__glibc_unlikely (token->type == END_OF_RE))
3128 { 3070 {
3129 *err = REG_BADPAT; 3071 *err = REG_BADPAT;
3130 goto parse_bracket_exp_free_return; 3072 goto parse_bracket_exp_free_return;
3131 } 3073 }
3132 if (token->type == OP_NON_MATCH_LIST) 3074 if (token->type == OP_NON_MATCH_LIST)
3133 { 3075 {
3134#ifdef RE_ENABLE_I18N
3135 mbcset->non_match = 1; 3076 mbcset->non_match = 1;
3136#endif /* not RE_ENABLE_I18N */
3137 non_match = true; 3077 non_match = true;
3138 if (syntax & RE_HAT_LISTS_NOT_NEWLINE) 3078 if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
3139 bitset_set (sbcset, '\n'); 3079 bitset_set (sbcset, '\n');
3140 re_string_skip_bytes (regexp, token_len); /* Skip a token. */ 3080 re_string_skip_bytes (regexp, token_len); /* Skip a token. */
3141 token_len = peek_token_bracket (token, regexp, syntax); 3081 token_len = peek_token_bracket (token, regexp, syntax);
3142 if (BE (token->type == END_OF_RE, 0)) 3082 if (__glibc_unlikely (token->type == END_OF_RE))
3143 { 3083 {
3144 *err = REG_BADPAT; 3084 *err = REG_BADPAT;
3145 goto parse_bracket_exp_free_return; 3085 goto parse_bracket_exp_free_return;
@@ -3161,9 +3101,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3161 re_token_t token2; 3101 re_token_t token2;
3162 3102
3163 start_elem.opr.name = start_name_buf; 3103 start_elem.opr.name = start_name_buf;
3104 start_elem.type = COLL_SYM;
3164 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, 3105 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
3165 syntax, first_round); 3106 syntax, first_round);
3166 if (BE (ret != REG_NOERROR, 0)) 3107 if (__glibc_unlikely (ret != REG_NOERROR))
3167 { 3108 {
3168 *err = ret; 3109 *err = ret;
3169 goto parse_bracket_exp_free_return; 3110 goto parse_bracket_exp_free_return;
@@ -3176,7 +3117,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3176 /* Do not check for ranges if we know they are not allowed. */ 3117 /* Do not check for ranges if we know they are not allowed. */
3177 if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) 3118 if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
3178 { 3119 {
3179 if (BE (token->type == END_OF_RE, 0)) 3120 if (__glibc_unlikely (token->type == END_OF_RE))
3180 { 3121 {
3181 *err = REG_EBRACK; 3122 *err = REG_EBRACK;
3182 goto parse_bracket_exp_free_return; 3123 goto parse_bracket_exp_free_return;
@@ -3185,7 +3126,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3185 { 3126 {
3186 re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ 3127 re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
3187 token_len2 = peek_token_bracket (&token2, regexp, syntax); 3128 token_len2 = peek_token_bracket (&token2, regexp, syntax);
3188 if (BE (token2.type == END_OF_RE, 0)) 3129 if (__glibc_unlikely (token2.type == END_OF_RE))
3189 { 3130 {
3190 *err = REG_EBRACK; 3131 *err = REG_EBRACK;
3191 goto parse_bracket_exp_free_return; 3132 goto parse_bracket_exp_free_return;
@@ -3204,9 +3145,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3204 if (is_range_exp == true) 3145 if (is_range_exp == true)
3205 { 3146 {
3206 end_elem.opr.name = end_name_buf; 3147 end_elem.opr.name = end_name_buf;
3148 end_elem.type = COLL_SYM;
3207 ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, 3149 ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
3208 dfa, syntax, true); 3150 dfa, syntax, true);
3209 if (BE (ret != REG_NOERROR, 0)) 3151 if (__glibc_unlikely (ret != REG_NOERROR))
3210 { 3152 {
3211 *err = ret; 3153 *err = ret;
3212 goto parse_bracket_exp_free_return; 3154 goto parse_bracket_exp_free_return;
@@ -3214,19 +3156,11 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3214 3156
3215 token_len = peek_token_bracket (token, regexp, syntax); 3157 token_len = peek_token_bracket (token, regexp, syntax);
3216 3158
3217#ifdef _LIBC
3218 *err = build_range_exp (sbcset, mbcset, &range_alloc, 3159 *err = build_range_exp (sbcset, mbcset, &range_alloc,
3219 &start_elem, &end_elem); 3160 &start_elem, &end_elem,
3220#else 3161 dfa, syntax, nrules, collseqmb, collseqwc,
3221# ifdef RE_ENABLE_I18N 3162 table_size, symb_table, extra);
3222 *err = build_range_exp (syntax, sbcset, 3163 if (__glibc_unlikely (*err != REG_NOERROR))
3223 dfa->mb_cur_max > 1 ? mbcset : NULL,
3224 &range_alloc, &start_elem, &end_elem);
3225# else
3226 *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
3227# endif
3228#endif /* RE_ENABLE_I18N */
3229 if (BE (*err != REG_NOERROR, 0))
3230 goto parse_bracket_exp_free_return; 3164 goto parse_bracket_exp_free_return;
3231 } 3165 }
3232 else 3166 else
@@ -3236,10 +3170,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3236 case SB_CHAR: 3170 case SB_CHAR:
3237 bitset_set (sbcset, start_elem.opr.ch); 3171 bitset_set (sbcset, start_elem.opr.ch);
3238 break; 3172 break;
3239#ifdef RE_ENABLE_I18N
3240 case MB_CHAR: 3173 case MB_CHAR:
3241 /* Check whether the array has enough space. */ 3174 /* Check whether the array has enough space. */
3242 if (BE (mbchar_alloc == mbcset->nmbchars, 0)) 3175 if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
3243 { 3176 {
3244 wchar_t *new_mbchars; 3177 wchar_t *new_mbchars;
3245 /* Not enough, realloc it. */ 3178 /* Not enough, realloc it. */
@@ -3248,47 +3181,41 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3248 /* Use realloc since array is NULL if *alloc == 0. */ 3181 /* Use realloc since array is NULL if *alloc == 0. */
3249 new_mbchars = re_realloc (mbcset->mbchars, wchar_t, 3182 new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
3250 mbchar_alloc); 3183 mbchar_alloc);
3251 if (BE (new_mbchars == NULL, 0)) 3184 if (__glibc_unlikely (new_mbchars == NULL))
3252 goto parse_bracket_exp_espace; 3185 goto parse_bracket_exp_espace;
3253 mbcset->mbchars = new_mbchars; 3186 mbcset->mbchars = new_mbchars;
3254 } 3187 }
3255 mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; 3188 mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
3256 break; 3189 break;
3257#endif /* RE_ENABLE_I18N */
3258 case EQUIV_CLASS: 3190 case EQUIV_CLASS:
3259 *err = build_equiv_class (sbcset, 3191 *err = build_equiv_class (sbcset,
3260#ifdef RE_ENABLE_I18N
3261 mbcset, &equiv_class_alloc, 3192 mbcset, &equiv_class_alloc,
3262#endif /* RE_ENABLE_I18N */
3263 start_elem.opr.name); 3193 start_elem.opr.name);
3264 if (BE (*err != REG_NOERROR, 0)) 3194 if (__glibc_unlikely (*err != REG_NOERROR))
3265 goto parse_bracket_exp_free_return; 3195 goto parse_bracket_exp_free_return;
3266 break; 3196 break;
3267 case COLL_SYM: 3197 case COLL_SYM:
3268 *err = build_collating_symbol (sbcset, 3198 *err = build_collating_symbol (sbcset,
3269#ifdef RE_ENABLE_I18N
3270 mbcset, &coll_sym_alloc, 3199 mbcset, &coll_sym_alloc,
3271#endif /* RE_ENABLE_I18N */ 3200 start_elem.opr.name,
3272 start_elem.opr.name); 3201 nrules, table_size, symb_table, extra);
3273 if (BE (*err != REG_NOERROR, 0)) 3202 if (__glibc_unlikely (*err != REG_NOERROR))
3274 goto parse_bracket_exp_free_return; 3203 goto parse_bracket_exp_free_return;
3275 break; 3204 break;
3276 case CHAR_CLASS: 3205 case CHAR_CLASS:
3277 *err = build_charclass (regexp->trans, sbcset, 3206 *err = build_charclass (regexp->trans, sbcset,
3278#ifdef RE_ENABLE_I18N
3279 mbcset, &char_class_alloc, 3207 mbcset, &char_class_alloc,
3280#endif /* RE_ENABLE_I18N */
3281 (const char *) start_elem.opr.name, 3208 (const char *) start_elem.opr.name,
3282 syntax); 3209 syntax);
3283 if (BE (*err != REG_NOERROR, 0)) 3210 if (__glibc_unlikely (*err != REG_NOERROR))
3284 goto parse_bracket_exp_free_return; 3211 goto parse_bracket_exp_free_return;
3285 break; 3212 break;
3286 default: 3213 default:
3287 assert (0); 3214 DEBUG_ASSERT (false);
3288 break; 3215 break;
3289 } 3216 }
3290 } 3217 }
3291 if (BE (token->type == END_OF_RE, 0)) 3218 if (__glibc_unlikely (token->type == END_OF_RE))
3292 { 3219 {
3293 *err = REG_EBRACK; 3220 *err = REG_EBRACK;
3294 goto parse_bracket_exp_free_return; 3221 goto parse_bracket_exp_free_return;
@@ -3303,7 +3230,6 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3303 if (non_match) 3230 if (non_match)
3304 bitset_not (sbcset); 3231 bitset_not (sbcset);
3305 3232
3306#ifdef RE_ENABLE_I18N
3307 /* Ensure only single byte characters are set. */ 3233 /* Ensure only single byte characters are set. */
3308 if (dfa->mb_cur_max > 1) 3234 if (dfa->mb_cur_max > 1)
3309 bitset_mask (sbcset, dfa->sb_char); 3235 bitset_mask (sbcset, dfa->sb_char);
@@ -3319,7 +3245,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3319 br_token.type = COMPLEX_BRACKET; 3245 br_token.type = COMPLEX_BRACKET;
3320 br_token.opr.mbcset = mbcset; 3246 br_token.opr.mbcset = mbcset;
3321 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3247 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3322 if (BE (mbc_tree == NULL, 0)) 3248 if (__glibc_unlikely (mbc_tree == NULL))
3323 goto parse_bracket_exp_espace; 3249 goto parse_bracket_exp_espace;
3324 for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) 3250 for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
3325 if (sbcset[sbc_idx]) 3251 if (sbcset[sbc_idx])
@@ -3332,12 +3258,12 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3332 br_token.type = SIMPLE_BRACKET; 3258 br_token.type = SIMPLE_BRACKET;
3333 br_token.opr.sbcset = sbcset; 3259 br_token.opr.sbcset = sbcset;
3334 work_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3260 work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3335 if (BE (work_tree == NULL, 0)) 3261 if (__glibc_unlikely (work_tree == NULL))
3336 goto parse_bracket_exp_espace; 3262 goto parse_bracket_exp_espace;
3337 3263
3338 /* Then join them by ALT node. */ 3264 /* Then join them by ALT node. */
3339 work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); 3265 work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
3340 if (BE (work_tree == NULL, 0)) 3266 if (__glibc_unlikely (work_tree == NULL))
3341 goto parse_bracket_exp_espace; 3267 goto parse_bracket_exp_espace;
3342 } 3268 }
3343 else 3269 else
@@ -3347,16 +3273,13 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3347 } 3273 }
3348 } 3274 }
3349 else 3275 else
3350#endif /* not RE_ENABLE_I18N */
3351 { 3276 {
3352#ifdef RE_ENABLE_I18N
3353 free_charset (mbcset); 3277 free_charset (mbcset);
3354#endif
3355 /* Build a tree for simple bracket. */ 3278 /* Build a tree for simple bracket. */
3356 br_token.type = SIMPLE_BRACKET; 3279 br_token.type = SIMPLE_BRACKET;
3357 br_token.opr.sbcset = sbcset; 3280 br_token.opr.sbcset = sbcset;
3358 work_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3281 work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3359 if (BE (work_tree == NULL, 0)) 3282 if (__glibc_unlikely (work_tree == NULL))
3360 goto parse_bracket_exp_espace; 3283 goto parse_bracket_exp_espace;
3361 } 3284 }
3362 return work_tree; 3285 return work_tree;
@@ -3365,9 +3288,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3365 *err = REG_ESPACE; 3288 *err = REG_ESPACE;
3366 parse_bracket_exp_free_return: 3289 parse_bracket_exp_free_return:
3367 re_free (sbcset); 3290 re_free (sbcset);
3368#ifdef RE_ENABLE_I18N
3369 free_charset (mbcset); 3291 free_charset (mbcset);
3370#endif /* RE_ENABLE_I18N */
3371 return NULL; 3292 return NULL;
3372} 3293}
3373 3294
@@ -3378,7 +3299,6 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3378 re_token_t *token, int token_len, re_dfa_t *dfa, 3299 re_token_t *token, int token_len, re_dfa_t *dfa,
3379 reg_syntax_t syntax, bool accept_hyphen) 3300 reg_syntax_t syntax, bool accept_hyphen)
3380{ 3301{
3381#ifdef RE_ENABLE_I18N
3382 int cur_char_size; 3302 int cur_char_size;
3383 cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); 3303 cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
3384 if (cur_char_size > 1) 3304 if (cur_char_size > 1)
@@ -3388,12 +3308,11 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3388 re_string_skip_bytes (regexp, cur_char_size); 3308 re_string_skip_bytes (regexp, cur_char_size);
3389 return REG_NOERROR; 3309 return REG_NOERROR;
3390 } 3310 }
3391#endif /* RE_ENABLE_I18N */
3392 re_string_skip_bytes (regexp, token_len); /* Skip a token. */ 3311 re_string_skip_bytes (regexp, token_len); /* Skip a token. */
3393 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS 3312 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
3394 || token->type == OP_OPEN_EQUIV_CLASS) 3313 || token->type == OP_OPEN_EQUIV_CLASS)
3395 return parse_bracket_symbol (elem, regexp, token); 3314 return parse_bracket_symbol (elem, regexp, token);
3396 if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) 3315 if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen)
3397 { 3316 {
3398 /* A '-' must only appear as anything but a range indicator before 3317 /* A '-' must only appear as anything but a range indicator before
3399 the closing bracket. Everything else is an error. */ 3318 the closing bracket. Everything else is an error. */
@@ -3461,12 +3380,8 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
3461 is a pointer argument since we may update it. */ 3380 is a pointer argument since we may update it. */
3462 3381
3463static reg_errcode_t 3382static reg_errcode_t
3464#ifdef RE_ENABLE_I18N
3465build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, 3383build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
3466 Idx *equiv_class_alloc, const unsigned char *name) 3384 Idx *equiv_class_alloc, const unsigned char *name)
3467#else /* not RE_ENABLE_I18N */
3468build_equiv_class (bitset_t sbcset, const unsigned char *name)
3469#endif /* not RE_ENABLE_I18N */
3470{ 3385{
3471#ifdef _LIBC 3386#ifdef _LIBC
3472 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3387 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -3478,8 +3393,6 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3478 int32_t idx1, idx2; 3393 int32_t idx1, idx2;
3479 unsigned int ch; 3394 unsigned int ch;
3480 size_t len; 3395 size_t len;
3481 /* This #include defines a local function! */
3482# include <locale/weight.h>
3483 /* Calculate the index for equivalence class. */ 3396 /* Calculate the index for equivalence class. */
3484 cp = name; 3397 cp = name;
3485 table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); 3398 table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
@@ -3489,8 +3402,8 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3489 _NL_COLLATE_EXTRAMB); 3402 _NL_COLLATE_EXTRAMB);
3490 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, 3403 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
3491 _NL_COLLATE_INDIRECTMB); 3404 _NL_COLLATE_INDIRECTMB);
3492 idx1 = findidx (&cp, -1); 3405 idx1 = findidx (table, indirect, extra, &cp, -1);
3493 if (BE (idx1 == 0 || *cp != '\0', 0)) 3406 if (__glibc_unlikely (idx1 == 0 || *cp != '\0'))
3494 /* This isn't a valid character. */ 3407 /* This isn't a valid character. */
3495 return REG_ECOLLATE; 3408 return REG_ECOLLATE;
3496 3409
@@ -3500,7 +3413,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3500 { 3413 {
3501 char_buf[0] = ch; 3414 char_buf[0] = ch;
3502 cp = char_buf; 3415 cp = char_buf;
3503 idx2 = findidx (&cp, 1); 3416 idx2 = findidx (table, indirect, extra, &cp, 1);
3504/* 3417/*
3505 idx2 = table[ch]; 3418 idx2 = table[ch];
3506*/ 3419*/
@@ -3509,21 +3422,13 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3509 continue; 3422 continue;
3510 /* Compare only if the length matches and the collation rule 3423 /* Compare only if the length matches and the collation rule
3511 index is the same. */ 3424 index is the same. */
3512 if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)) 3425 if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)
3513 { 3426 && memcmp (weights + (idx1 & 0xffffff) + 1,
3514 int cnt = 0; 3427 weights + (idx2 & 0xffffff) + 1, len) == 0)
3515 3428 bitset_set (sbcset, ch);
3516 while (cnt <= len &&
3517 weights[(idx1 & 0xffffff) + 1 + cnt]
3518 == weights[(idx2 & 0xffffff) + 1 + cnt])
3519 ++cnt;
3520
3521 if (cnt > len)
3522 bitset_set (sbcset, ch);
3523 }
3524 } 3429 }
3525 /* Check whether the array has enough space. */ 3430 /* Check whether the array has enough space. */
3526 if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) 3431 if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes))
3527 { 3432 {
3528 /* Not enough, realloc it. */ 3433 /* Not enough, realloc it. */
3529 /* +1 in case of mbcset->nequiv_classes is 0. */ 3434 /* +1 in case of mbcset->nequiv_classes is 0. */
@@ -3532,7 +3437,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3532 int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, 3437 int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
3533 int32_t, 3438 int32_t,
3534 new_equiv_class_alloc); 3439 new_equiv_class_alloc);
3535 if (BE (new_equiv_classes == NULL, 0)) 3440 if (__glibc_unlikely (new_equiv_classes == NULL))
3536 return REG_ESPACE; 3441 return REG_ESPACE;
3537 mbcset->equiv_classes = new_equiv_classes; 3442 mbcset->equiv_classes = new_equiv_classes;
3538 *equiv_class_alloc = new_equiv_class_alloc; 3443 *equiv_class_alloc = new_equiv_class_alloc;
@@ -3542,7 +3447,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3542 else 3447 else
3543#endif /* _LIBC */ 3448#endif /* _LIBC */
3544 { 3449 {
3545 if (BE (strlen ((const char *) name) != 1, 0)) 3450 if (__glibc_unlikely (strlen ((const char *) name) != 1))
3546 return REG_ECOLLATE; 3451 return REG_ECOLLATE;
3547 bitset_set (sbcset, *name); 3452 bitset_set (sbcset, *name);
3548 } 3453 }
@@ -3556,14 +3461,9 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3556 is a pointer argument since we may update it. */ 3461 is a pointer argument since we may update it. */
3557 3462
3558static reg_errcode_t 3463static reg_errcode_t
3559#ifdef RE_ENABLE_I18N
3560build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, 3464build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3561 re_charset_t *mbcset, Idx *char_class_alloc, 3465 re_charset_t *mbcset, Idx *char_class_alloc,
3562 const char *class_name, reg_syntax_t syntax) 3466 const char *class_name, reg_syntax_t syntax)
3563#else /* not RE_ENABLE_I18N */
3564build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3565 const char *class_name, reg_syntax_t syntax)
3566#endif /* not RE_ENABLE_I18N */
3567{ 3467{
3568 int i; 3468 int i;
3569 const char *name = class_name; 3469 const char *name = class_name;
@@ -3574,9 +3474,8 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3574 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) 3474 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
3575 name = "alpha"; 3475 name = "alpha";
3576 3476
3577#ifdef RE_ENABLE_I18N
3578 /* Check the space of the arrays. */ 3477 /* Check the space of the arrays. */
3579 if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) 3478 if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
3580 { 3479 {
3581 /* Not enough, realloc it. */ 3480 /* Not enough, realloc it. */
3582 /* +1 in case of mbcset->nchar_classes is 0. */ 3481 /* +1 in case of mbcset->nchar_classes is 0. */
@@ -3584,17 +3483,16 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3584 /* Use realloc since array is NULL if *alloc == 0. */ 3483 /* Use realloc since array is NULL if *alloc == 0. */
3585 wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, 3484 wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
3586 new_char_class_alloc); 3485 new_char_class_alloc);
3587 if (BE (new_char_classes == NULL, 0)) 3486 if (__glibc_unlikely (new_char_classes == NULL))
3588 return REG_ESPACE; 3487 return REG_ESPACE;
3589 mbcset->char_classes = new_char_classes; 3488 mbcset->char_classes = new_char_classes;
3590 *char_class_alloc = new_char_class_alloc; 3489 *char_class_alloc = new_char_class_alloc;
3591 } 3490 }
3592 mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name); 3491 mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
3593#endif /* RE_ENABLE_I18N */
3594 3492
3595#define BUILD_CHARCLASS_LOOP(ctype_func) \ 3493#define BUILD_CHARCLASS_LOOP(ctype_func) \
3596 do { \ 3494 do { \
3597 if (BE (trans != NULL, 0)) \ 3495 if (__glibc_unlikely (trans != NULL)) \
3598 { \ 3496 { \
3599 for (i = 0; i < SBC_MAX; ++i) \ 3497 for (i = 0; i < SBC_MAX; ++i) \
3600 if (ctype_func (i)) \ 3498 if (ctype_func (i)) \
@@ -3645,49 +3543,33 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3645 reg_errcode_t *err) 3543 reg_errcode_t *err)
3646{ 3544{
3647 re_bitset_ptr_t sbcset; 3545 re_bitset_ptr_t sbcset;
3648#ifdef RE_ENABLE_I18N
3649 re_charset_t *mbcset; 3546 re_charset_t *mbcset;
3650 Idx alloc = 0; 3547 Idx alloc = 0;
3651#endif /* not RE_ENABLE_I18N */
3652 reg_errcode_t ret; 3548 reg_errcode_t ret;
3653 re_token_t br_token;
3654 bin_tree_t *tree; 3549 bin_tree_t *tree;
3655 3550
3656 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3551 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
3657#ifdef RE_ENABLE_I18N 3552 if (__glibc_unlikely (sbcset == NULL))
3658 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3659#endif /* RE_ENABLE_I18N */
3660
3661#ifdef RE_ENABLE_I18N
3662 if (BE (sbcset == NULL || mbcset == NULL, 0))
3663#else /* not RE_ENABLE_I18N */
3664 if (BE (sbcset == NULL, 0))
3665#endif /* not RE_ENABLE_I18N */
3666 { 3553 {
3667 *err = REG_ESPACE; 3554 *err = REG_ESPACE;
3668 return NULL; 3555 return NULL;
3669 } 3556 }
3670 3557 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3671 if (non_match) 3558 if (__glibc_unlikely (mbcset == NULL))
3672 { 3559 {
3673#ifdef RE_ENABLE_I18N 3560 re_free (sbcset);
3674 mbcset->non_match = 1; 3561 *err = REG_ESPACE;
3675#endif /* not RE_ENABLE_I18N */ 3562 return NULL;
3676 } 3563 }
3564 mbcset->non_match = non_match;
3677 3565
3678 /* We don't care the syntax in this case. */ 3566 /* We don't care the syntax in this case. */
3679 ret = build_charclass (trans, sbcset, 3567 ret = build_charclass (trans, sbcset, mbcset, &alloc, class_name, 0);
3680#ifdef RE_ENABLE_I18N
3681 mbcset, &alloc,
3682#endif /* RE_ENABLE_I18N */
3683 class_name, 0);
3684 3568
3685 if (BE (ret != REG_NOERROR, 0)) 3569 if (__glibc_unlikely (ret != REG_NOERROR))
3686 { 3570 {
3687 re_free (sbcset); 3571 re_free (sbcset);
3688#ifdef RE_ENABLE_I18N
3689 free_charset (mbcset); 3572 free_charset (mbcset);
3690#endif /* RE_ENABLE_I18N */
3691 *err = ret; 3573 *err = ret;
3692 return NULL; 3574 return NULL;
3693 } 3575 }
@@ -3699,20 +3581,16 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3699 if (non_match) 3581 if (non_match)
3700 bitset_not (sbcset); 3582 bitset_not (sbcset);
3701 3583
3702#ifdef RE_ENABLE_I18N
3703 /* Ensure only single byte characters are set. */ 3584 /* Ensure only single byte characters are set. */
3704 if (dfa->mb_cur_max > 1) 3585 if (dfa->mb_cur_max > 1)
3705 bitset_mask (sbcset, dfa->sb_char); 3586 bitset_mask (sbcset, dfa->sb_char);
3706#endif
3707 3587
3708 /* Build a tree for simple bracket. */ 3588 /* Build a tree for simple bracket. */
3709 br_token.type = SIMPLE_BRACKET; 3589 re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
3710 br_token.opr.sbcset = sbcset;
3711 tree = create_token_tree (dfa, NULL, NULL, &br_token); 3590 tree = create_token_tree (dfa, NULL, NULL, &br_token);
3712 if (BE (tree == NULL, 0)) 3591 if (__glibc_unlikely (tree == NULL))
3713 goto build_word_op_espace; 3592 goto build_word_op_espace;
3714 3593
3715#ifdef RE_ENABLE_I18N
3716 if (dfa->mb_cur_max > 1) 3594 if (dfa->mb_cur_max > 1)
3717 { 3595 {
3718 bin_tree_t *mbc_tree; 3596 bin_tree_t *mbc_tree;
@@ -3721,11 +3599,11 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3721 br_token.opr.mbcset = mbcset; 3599 br_token.opr.mbcset = mbcset;
3722 dfa->has_mb_node = 1; 3600 dfa->has_mb_node = 1;
3723 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3601 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3724 if (BE (mbc_tree == NULL, 0)) 3602 if (__glibc_unlikely (mbc_tree == NULL))
3725 goto build_word_op_espace; 3603 goto build_word_op_espace;
3726 /* Then join them by ALT node. */ 3604 /* Then join them by ALT node. */
3727 tree = create_tree (dfa, tree, mbc_tree, OP_ALT); 3605 tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
3728 if (BE (mbc_tree != NULL, 1)) 3606 if (__glibc_likely (mbc_tree != NULL))
3729 return tree; 3607 return tree;
3730 } 3608 }
3731 else 3609 else
@@ -3733,63 +3611,55 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3733 free_charset (mbcset); 3611 free_charset (mbcset);
3734 return tree; 3612 return tree;
3735 } 3613 }
3736#else /* not RE_ENABLE_I18N */
3737 return tree;
3738#endif /* not RE_ENABLE_I18N */
3739 3614
3740 build_word_op_espace: 3615 build_word_op_espace:
3741 re_free (sbcset); 3616 re_free (sbcset);
3742#ifdef RE_ENABLE_I18N
3743 free_charset (mbcset); 3617 free_charset (mbcset);
3744#endif /* RE_ENABLE_I18N */
3745 *err = REG_ESPACE; 3618 *err = REG_ESPACE;
3746 return NULL; 3619 return NULL;
3747} 3620}
3748 3621
3749/* This is intended for the expressions like "a{1,3}". 3622/* This is intended for the expressions like "a{1,3}".
3750 Fetch a number from 'input', and return the number. 3623 Fetch a number from 'input', and return the number.
3751 Return REG_MISSING if the number field is empty like "{,1}". 3624 Return -1 if the number field is empty like "{,1}".
3752 Return RE_DUP_MAX + 1 if the number field is too large. 3625 Return RE_DUP_MAX + 1 if the number field is too large.
3753 Return REG_ERROR if an error occurred. */ 3626 Return -2 if an error occurred. */
3754 3627
3755static Idx 3628static Idx
3756fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) 3629fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
3757{ 3630{
3758 Idx num = REG_MISSING; 3631 Idx num = -1;
3759 unsigned char c; 3632 unsigned char c;
3760 while (1) 3633 while (1)
3761 { 3634 {
3762 fetch_token (token, input, syntax); 3635 fetch_token (token, input, syntax);
3763 c = token->opr.c; 3636 c = token->opr.c;
3764 if (BE (token->type == END_OF_RE, 0)) 3637 if (__glibc_unlikely (token->type == END_OF_RE))
3765 return REG_ERROR; 3638 return -2;
3766 if (token->type == OP_CLOSE_DUP_NUM || c == ',') 3639 if (token->type == OP_CLOSE_DUP_NUM || c == ',')
3767 break; 3640 break;
3768 num = ((token->type != CHARACTER || c < '0' || '9' < c 3641 num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
3769 || num == REG_ERROR) 3642 ? -2
3770 ? REG_ERROR 3643 : num == -1
3771 : num == REG_MISSING
3772 ? c - '0' 3644 ? c - '0'
3773 : MIN (RE_DUP_MAX + 1, num * 10 + c - '0')); 3645 : MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
3774 } 3646 }
3775 return num; 3647 return num;
3776} 3648}
3777 3649
3778#ifdef RE_ENABLE_I18N
3779static void 3650static void
3780free_charset (re_charset_t *cset) 3651free_charset (re_charset_t *cset)
3781{ 3652{
3782 re_free (cset->mbchars); 3653 re_free (cset->mbchars);
3783# ifdef _LIBC 3654#ifdef _LIBC
3784 re_free (cset->coll_syms); 3655 re_free (cset->coll_syms);
3785 re_free (cset->equiv_classes); 3656 re_free (cset->equiv_classes);
3657#endif
3786 re_free (cset->range_starts); 3658 re_free (cset->range_starts);
3787 re_free (cset->range_ends); 3659 re_free (cset->range_ends);
3788# endif
3789 re_free (cset->char_classes); 3660 re_free (cset->char_classes);
3790 re_free (cset); 3661 re_free (cset);
3791} 3662}
3792#endif /* RE_ENABLE_I18N */
3793 3663
3794/* Functions for binary tree operation. */ 3664/* Functions for binary tree operation. */
3795 3665
@@ -3799,8 +3669,7 @@ static bin_tree_t *
3799create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, 3669create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3800 re_token_type_t type) 3670 re_token_type_t type)
3801{ 3671{
3802 re_token_t t; 3672 re_token_t t = { .type = type };
3803 t.type = type;
3804 return create_token_tree (dfa, left, right, &t); 3673 return create_token_tree (dfa, left, right, &t);
3805} 3674}
3806 3675
@@ -3809,7 +3678,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3809 const re_token_t *token) 3678 const re_token_t *token)
3810{ 3679{
3811 bin_tree_t *tree; 3680 bin_tree_t *tree;
3812 if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) 3681 if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE))
3813 { 3682 {
3814 bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); 3683 bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
3815 3684
@@ -3829,7 +3698,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3829 tree->token.opt_subexp = 0; 3698 tree->token.opt_subexp = 0;
3830 tree->first = NULL; 3699 tree->first = NULL;
3831 tree->next = NULL; 3700 tree->next = NULL;
3832 tree->node_idx = REG_MISSING; 3701 tree->node_idx = -1;
3833 3702
3834 if (left != NULL) 3703 if (left != NULL)
3835 left->parent = tree; 3704 left->parent = tree;
@@ -3856,13 +3725,10 @@ mark_opt_subexp (void *extra, bin_tree_t *node)
3856static void 3725static void
3857free_token (re_token_t *node) 3726free_token (re_token_t *node)
3858{ 3727{
3859#ifdef RE_ENABLE_I18N
3860 if (node->type == COMPLEX_BRACKET && node->duplicated == 0) 3728 if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
3861 free_charset (node->opr.mbcset); 3729 free_charset (node->opr.mbcset);
3862 else 3730 else if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
3863#endif /* RE_ENABLE_I18N */ 3731 re_free (node->opr.sbcset);
3864 if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
3865 re_free (node->opr.sbcset);
3866} 3732}
3867 3733
3868/* Worker function for tree walking. Free the allocated memory inside NODE 3734/* Worker function for tree walking. Free the allocated memory inside NODE
diff --git a/gl/regex.c b/gl/regex.c
index 5a0332e0..3beb0deb 100644
--- a/gl/regex.c
+++ b/gl/regex.c
@@ -1,29 +1,32 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19
20#define __STDC_WANT_IEC_60559_BFP_EXT__
19 21
20#ifndef _LIBC 22#ifndef _LIBC
21# include <config.h> 23# include <libc-config.h>
22 24
23# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ 25# if __GNUC_PREREQ (4, 6)
24# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" 26# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
27# pragma GCC diagnostic ignored "-Wvla"
25# endif 28# endif
26# if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ 29# if __GNUC_PREREQ (4, 3)
27# pragma GCC diagnostic ignored "-Wold-style-definition" 30# pragma GCC diagnostic ignored "-Wold-style-definition"
28# pragma GCC diagnostic ignored "-Wtype-limits" 31# pragma GCC diagnostic ignored "-Wtype-limits"
29# endif 32# endif
diff --git a/gl/regex.h b/gl/regex.h
index 854c6eda..9ef0252f 100644
--- a/gl/regex.h
+++ b/gl/regex.h
@@ -1,22 +1,21 @@
1/* Definitions for data structures and routines for the regular 1/* Definitions for data structures and routines for the regular
2 expression library. 2 expression library.
3 Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software 3 Copyright (C) 1985, 1989-2023 Free Software Foundation, Inc.
4 Foundation, Inc.
5 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
6 5
7 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
10 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
11 10
12 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 14 Lesser General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
20 19
21#ifndef _REGEX_H 20#ifndef _REGEX_H
22#define _REGEX_H 1 21#define _REGEX_H 1
@@ -42,11 +41,6 @@ extern "C" {
42 supported within glibc itself, and glibc users should not define 41 supported within glibc itself, and glibc users should not define
43 _REGEX_LARGE_OFFSETS. */ 42 _REGEX_LARGE_OFFSETS. */
44 43
45/* The type of nonnegative object indexes. Traditionally, GNU regex
46 uses 'int' for these. Code that uses __re_idx_t should work
47 regardless of whether the type is signed. */
48typedef size_t __re_idx_t;
49
50/* The type of object sizes. */ 44/* The type of object sizes. */
51typedef size_t __re_size_t; 45typedef size_t __re_size_t;
52 46
@@ -58,7 +52,6 @@ typedef size_t __re_long_size_t;
58 52
59/* The traditional GNU regex implementation mishandles strings longer 53/* The traditional GNU regex implementation mishandles strings longer
60 than INT_MAX. */ 54 than INT_MAX. */
61typedef int __re_idx_t;
62typedef unsigned int __re_size_t; 55typedef unsigned int __re_size_t;
63typedef unsigned long int __re_long_size_t; 56typedef unsigned long int __re_long_size_t;
64 57
@@ -244,19 +237,16 @@ extern reg_syntax_t re_syntax_options;
244 | RE_INVALID_INTERVAL_ORD) 237 | RE_INVALID_INTERVAL_ORD)
245 238
246# define RE_SYNTAX_GREP \ 239# define RE_SYNTAX_GREP \
247 (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ 240 ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT) \
248 | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ 241 & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL))
249 | RE_NEWLINE_ALT)
250 242
251# define RE_SYNTAX_EGREP \ 243# define RE_SYNTAX_EGREP \
252 (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ 244 ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \
253 | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ 245 & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL))
254 | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
255 | RE_NO_BK_VBAR)
256 246
247/* POSIX grep -E behavior is no longer incompatible with GNU. */
257# define RE_SYNTAX_POSIX_EGREP \ 248# define RE_SYNTAX_POSIX_EGREP \
258 (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ 249 RE_SYNTAX_EGREP
259 | RE_INVALID_INTERVAL_ORD)
260 250
261/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ 251/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
262# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC 252# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
@@ -491,7 +481,8 @@ typedef struct re_pattern_buffer regex_t;
491#ifdef _REGEX_LARGE_OFFSETS 481#ifdef _REGEX_LARGE_OFFSETS
492/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as 482/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as
493 ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t 483 ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t
494 is wider than ssize_t, so ssize_t is safe. */ 484 is wider than ssize_t, so ssize_t is safe. ptrdiff_t is not
485 visible here, so use ssize_t. */
495typedef ssize_t regoff_t; 486typedef ssize_t regoff_t;
496#else 487#else
497/* The traditional GNU regex implementation mishandles strings longer 488/* The traditional GNU regex implementation mishandles strings longer
@@ -531,6 +522,30 @@ typedef struct
531 522
532/* Declarations for routines. */ 523/* Declarations for routines. */
533 524
525#ifndef _REGEX_NELTS
526# if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
527 && !defined __STDC_NO_VLA__)
528# define _REGEX_NELTS(n) n
529# else
530# define _REGEX_NELTS(n)
531# endif
532#endif
533
534#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
535# pragma GCC diagnostic push
536# pragma GCC diagnostic ignored "-Wvla"
537#endif
538
539#ifndef _Attr_access_
540# ifdef __attr_access
541# define _Attr_access_(arg) __attr_access (arg)
542# elif defined __GNUC__ && 10 <= __GNUC__
543# define _Attr_access_(x) __attribute__ ((__access__ x))
544# else
545# define _Attr_access_(x)
546# endif
547#endif
548
534#ifdef __USE_GNU 549#ifdef __USE_GNU
535/* Sets the current default syntax to SYNTAX, and return the old syntax. 550/* Sets the current default syntax to SYNTAX, and return the old syntax.
536 You can also simply assign to the 're_syntax_options' variable. */ 551 You can also simply assign to the 're_syntax_options' variable. */
@@ -541,11 +556,12 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
541 BUFFER. Return NULL if successful, and an error string if not. 556 BUFFER. Return NULL if successful, and an error string if not.
542 557
543 To free the allocated storage, you must call 'regfree' on BUFFER. 558 To free the allocated storage, you must call 'regfree' on BUFFER.
544 Note that the translate table must either have been initialised by 559 Note that the translate table must either have been initialized by
545 'regcomp', with a malloc'ed value, or set to NULL before calling 560 'regcomp', with a malloc'ed value, or set to NULL before calling
546 'regfree'. */ 561 'regfree'. */
547extern const char *re_compile_pattern (const char *__pattern, size_t __length, 562extern const char *re_compile_pattern (const char *__pattern, size_t __length,
548 struct re_pattern_buffer *__buffer); 563 struct re_pattern_buffer *__buffer)
564 _Attr_access_ ((__read_only__, 1, 2));
549 565
550 566
551/* Compile a fastmap for the compiled pattern in BUFFER; used to 567/* Compile a fastmap for the compiled pattern in BUFFER; used to
@@ -560,34 +576,40 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
560 match, or -2 for an internal error. Also return register 576 match, or -2 for an internal error. Also return register
561 information in REGS (if REGS and BUFFER->no_sub are nonzero). */ 577 information in REGS (if REGS and BUFFER->no_sub are nonzero). */
562extern regoff_t re_search (struct re_pattern_buffer *__buffer, 578extern regoff_t re_search (struct re_pattern_buffer *__buffer,
563 const char *__string, __re_idx_t __length, 579 const char *__String, regoff_t __length,
564 __re_idx_t __start, regoff_t __range, 580 regoff_t __start, regoff_t __range,
565 struct re_registers *__regs); 581 struct re_registers *__regs)
582 _Attr_access_ ((__read_only__, 2, 3));
566 583
567 584
568/* Like 're_search', but search in the concatenation of STRING1 and 585/* Like 're_search', but search in the concatenation of STRING1 and
569 STRING2. Also, stop searching at index START + STOP. */ 586 STRING2. Also, stop searching at index START + STOP. */
570extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, 587extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
571 const char *__string1, __re_idx_t __length1, 588 const char *__string1, regoff_t __length1,
572 const char *__string2, __re_idx_t __length2, 589 const char *__string2, regoff_t __length2,
573 __re_idx_t __start, regoff_t __range, 590 regoff_t __start, regoff_t __range,
574 struct re_registers *__regs, 591 struct re_registers *__regs,
575 __re_idx_t __stop); 592 regoff_t __stop)
593 _Attr_access_ ((__read_only__, 2, 3))
594 _Attr_access_ ((__read_only__, 4, 5));
576 595
577 596
578/* Like 're_search', but return how many characters in STRING the regexp 597/* Like 're_search', but return how many characters in STRING the regexp
579 in BUFFER matched, starting at position START. */ 598 in BUFFER matched, starting at position START. */
580extern regoff_t re_match (struct re_pattern_buffer *__buffer, 599extern regoff_t re_match (struct re_pattern_buffer *__buffer,
581 const char *__string, __re_idx_t __length, 600 const char *__String, regoff_t __length,
582 __re_idx_t __start, struct re_registers *__regs); 601 regoff_t __start, struct re_registers *__regs)
602 _Attr_access_ ((__read_only__, 2, 3));
583 603
584 604
585/* Relates to 're_match' as 're_search_2' relates to 're_search'. */ 605/* Relates to 're_match' as 're_search_2' relates to 're_search'. */
586extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, 606extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
587 const char *__string1, __re_idx_t __length1, 607 const char *__string1, regoff_t __length1,
588 const char *__string2, __re_idx_t __length2, 608 const char *__string2, regoff_t __length2,
589 __re_idx_t __start, struct re_registers *__regs, 609 regoff_t __start, struct re_registers *__regs,
590 __re_idx_t __stop); 610 regoff_t __stop)
611 _Attr_access_ ((__read_only__, 2, 3))
612 _Attr_access_ ((__read_only__, 4, 5));
591 613
592 614
593/* Set REGS to hold NUM_REGS registers, storing them in STARTS and 615/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -608,36 +630,41 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,
608 regoff_t *__starts, regoff_t *__ends); 630 regoff_t *__starts, regoff_t *__ends);
609#endif /* Use GNU */ 631#endif /* Use GNU */
610 632
611#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD) 633#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC)
612# ifndef _CRAY
613/* 4.2 bsd compatibility. */ 634/* 4.2 bsd compatibility. */
614extern char *re_comp (const char *); 635extern char *re_comp (const char *);
615extern int re_exec (const char *); 636extern int re_exec (const char *);
616# endif
617#endif 637#endif
618 638
619/* GCC 2.95 and later have "__restrict"; C99 compilers have 639/* For plain 'restrict', use glibc's __restrict if defined.
640 Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
620 "restrict", and "configure" may have defined "restrict". 641 "restrict", and "configure" may have defined "restrict".
621 Other compilers use __restrict, __restrict__, and _Restrict, and 642 Other compilers use __restrict, __restrict__, and _Restrict, and
622 'configure' might #define 'restrict' to those words, so pick a 643 'configure' might #define 'restrict' to those words, so pick a
623 different name. */ 644 different name. */
624#ifndef _Restrict_ 645#ifndef _Restrict_
625# if 199901L <= __STDC_VERSION__ 646# if defined __restrict \
626# define _Restrict_ restrict 647 || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
627# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) 648 || __clang_major__ >= 3
628# define _Restrict_ __restrict 649# define _Restrict_ __restrict
650# elif 199901L <= __STDC_VERSION__ || defined restrict
651# define _Restrict_ restrict
629# else 652# else
630# define _Restrict_ 653# define _Restrict_
631# endif 654# endif
632#endif 655#endif
633/* gcc 3.1 and up support the [restrict] syntax. Don't trust 656/* For the ISO C99 syntax
634 sys/cdefs.h's definition of __restrict_arr, though, as it 657 array_name[restrict]
635 mishandles gcc -ansi -pedantic. */ 658 use glibc's __restrict_arr if available.
659 Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode).
660 Other ISO C99 compilers support it as well. */
636#ifndef _Restrict_arr_ 661#ifndef _Restrict_arr_
637# if ((199901L <= __STDC_VERSION__ \ 662# ifdef __restrict_arr
638 || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ 663# define _Restrict_arr_ __restrict_arr
639 && !defined __STRICT_ANSI__)) \ 664# elif ((199901L <= __STDC_VERSION__ \
640 && !defined __GNUG__) 665 || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
666 || __clang_major__ >= 3) \
667 && !defined __cplusplus)
641# define _Restrict_arr_ _Restrict_ 668# define _Restrict_arr_ _Restrict_
642# else 669# else
643# define _Restrict_arr_ 670# define _Restrict_arr_
@@ -650,15 +677,20 @@ extern int regcomp (regex_t *_Restrict_ __preg,
650 int __cflags); 677 int __cflags);
651 678
652extern int regexec (const regex_t *_Restrict_ __preg, 679extern int regexec (const regex_t *_Restrict_ __preg,
653 const char *_Restrict_ __string, size_t __nmatch, 680 const char *_Restrict_ __String, size_t __nmatch,
654 regmatch_t __pmatch[_Restrict_arr_], 681 regmatch_t __pmatch[_Restrict_arr_
682 _REGEX_NELTS (__nmatch)],
655 int __eflags); 683 int __eflags);
656 684
657extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, 685extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
658 char *_Restrict_ __errbuf, size_t __errbuf_size); 686 char *_Restrict_ __errbuf, size_t __errbuf_size)
687 _Attr_access_ ((__write_only__, 3, 4));
659 688
660extern void regfree (regex_t *__preg); 689extern void regfree (regex_t *__preg);
661 690
691#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
692# pragma GCC diagnostic pop
693#endif
662 694
663#ifdef __cplusplus 695#ifdef __cplusplus
664} 696}
diff --git a/gl/regex_internal.c b/gl/regex_internal.c
index 899b0ae6..998a19b7 100644
--- a/gl/regex_internal.c
+++ b/gl/regex_internal.c
@@ -1,33 +1,41 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20static void re_string_construct_common (const char *str, Idx len, 20static void re_string_construct_common (const char *str, Idx len,
21 re_string_t *pstr, 21 re_string_t *pstr,
22 RE_TRANSLATE_TYPE trans, bool icase, 22 RE_TRANSLATE_TYPE trans, bool icase,
23 const re_dfa_t *dfa) internal_function; 23 const re_dfa_t *dfa);
24static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, 24static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
25 const re_node_set *nodes, 25 const re_node_set *nodes,
26 re_hashval_t hash) internal_function; 26 re_hashval_t hash);
27static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, 27static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
28 const re_node_set *nodes, 28 const re_node_set *nodes,
29 unsigned int context, 29 unsigned int context,
30 re_hashval_t hash) internal_function; 30 re_hashval_t hash);
31static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
32 Idx new_buf_len);
33static void build_wcs_buffer (re_string_t *pstr);
34static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr);
35static void build_upper_buffer (re_string_t *pstr);
36static void re_string_translate_buffer (re_string_t *pstr);
37static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
38 int eflags) __attribute__ ((pure));
31 39
32/* Functions for string operation. */ 40/* Functions for string operation. */
33 41
@@ -35,7 +43,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
35 re_string_reconstruct before using the object. */ 43 re_string_reconstruct before using the object. */
36 44
37static reg_errcode_t 45static reg_errcode_t
38internal_function __attribute_warn_unused_result__ 46__attribute_warn_unused_result__
39re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, 47re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
40 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) 48 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
41{ 49{
@@ -49,7 +57,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
49 re_string_construct_common (str, len, pstr, trans, icase, dfa); 57 re_string_construct_common (str, len, pstr, trans, icase, dfa);
50 58
51 ret = re_string_realloc_buffers (pstr, init_buf_len); 59 ret = re_string_realloc_buffers (pstr, init_buf_len);
52 if (BE (ret != REG_NOERROR, 0)) 60 if (__glibc_unlikely (ret != REG_NOERROR))
53 return ret; 61 return ret;
54 62
55 pstr->word_char = dfa->word_char; 63 pstr->word_char = dfa->word_char;
@@ -63,7 +71,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
63/* This function allocate the buffers, and initialize them. */ 71/* This function allocate the buffers, and initialize them. */
64 72
65static reg_errcode_t 73static reg_errcode_t
66internal_function __attribute_warn_unused_result__ 74__attribute_warn_unused_result__
67re_string_construct (re_string_t *pstr, const char *str, Idx len, 75re_string_construct (re_string_t *pstr, const char *str, Idx len,
68 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) 76 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
69{ 77{
@@ -74,41 +82,37 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
74 if (len > 0) 82 if (len > 0)
75 { 83 {
76 ret = re_string_realloc_buffers (pstr, len + 1); 84 ret = re_string_realloc_buffers (pstr, len + 1);
77 if (BE (ret != REG_NOERROR, 0)) 85 if (__glibc_unlikely (ret != REG_NOERROR))
78 return ret; 86 return ret;
79 } 87 }
80 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; 88 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
81 89
82 if (icase) 90 if (icase)
83 { 91 {
84#ifdef RE_ENABLE_I18N
85 if (dfa->mb_cur_max > 1) 92 if (dfa->mb_cur_max > 1)
86 { 93 {
87 while (1) 94 while (1)
88 { 95 {
89 ret = build_wcs_upper_buffer (pstr); 96 ret = build_wcs_upper_buffer (pstr);
90 if (BE (ret != REG_NOERROR, 0)) 97 if (__glibc_unlikely (ret != REG_NOERROR))
91 return ret; 98 return ret;
92 if (pstr->valid_raw_len >= len) 99 if (pstr->valid_raw_len >= len)
93 break; 100 break;
94 if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) 101 if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
95 break; 102 break;
96 ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); 103 ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
97 if (BE (ret != REG_NOERROR, 0)) 104 if (__glibc_unlikely (ret != REG_NOERROR))
98 return ret; 105 return ret;
99 } 106 }
100 } 107 }
101 else 108 else
102#endif /* RE_ENABLE_I18N */
103 build_upper_buffer (pstr); 109 build_upper_buffer (pstr);
104 } 110 }
105 else 111 else
106 { 112 {
107#ifdef RE_ENABLE_I18N
108 if (dfa->mb_cur_max > 1) 113 if (dfa->mb_cur_max > 1)
109 build_wcs_buffer (pstr); 114 build_wcs_buffer (pstr);
110 else 115 else
111#endif /* RE_ENABLE_I18N */
112 { 116 {
113 if (trans != NULL) 117 if (trans != NULL)
114 re_string_translate_buffer (pstr); 118 re_string_translate_buffer (pstr);
@@ -126,37 +130,36 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
126/* Helper functions for re_string_allocate, and re_string_construct. */ 130/* Helper functions for re_string_allocate, and re_string_construct. */
127 131
128static reg_errcode_t 132static reg_errcode_t
129internal_function __attribute_warn_unused_result__ 133__attribute_warn_unused_result__
130re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) 134re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
131{ 135{
132#ifdef RE_ENABLE_I18N
133 if (pstr->mb_cur_max > 1) 136 if (pstr->mb_cur_max > 1)
134 { 137 {
135 wint_t *new_wcs; 138 wint_t *new_wcs;
136 139
137 /* Avoid overflow in realloc. */ 140 /* Avoid overflow in realloc. */
138 const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx)); 141 const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx));
139 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0)) 142 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
143 < new_buf_len))
140 return REG_ESPACE; 144 return REG_ESPACE;
141 145
142 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); 146 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
143 if (BE (new_wcs == NULL, 0)) 147 if (__glibc_unlikely (new_wcs == NULL))
144 return REG_ESPACE; 148 return REG_ESPACE;
145 pstr->wcs = new_wcs; 149 pstr->wcs = new_wcs;
146 if (pstr->offsets != NULL) 150 if (pstr->offsets != NULL)
147 { 151 {
148 Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len); 152 Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len);
149 if (BE (new_offsets == NULL, 0)) 153 if (__glibc_unlikely (new_offsets == NULL))
150 return REG_ESPACE; 154 return REG_ESPACE;
151 pstr->offsets = new_offsets; 155 pstr->offsets = new_offsets;
152 } 156 }
153 } 157 }
154#endif /* RE_ENABLE_I18N */
155 if (pstr->mbs_allocated) 158 if (pstr->mbs_allocated)
156 { 159 {
157 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, 160 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
158 new_buf_len); 161 new_buf_len);
159 if (BE (new_mbs == NULL, 0)) 162 if (__glibc_unlikely (new_mbs == NULL))
160 return REG_ESPACE; 163 return REG_ESPACE;
161 pstr->mbs = new_mbs; 164 pstr->mbs = new_mbs;
162 } 165 }
@@ -166,7 +169,6 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
166 169
167 170
168static void 171static void
169internal_function
170re_string_construct_common (const char *str, Idx len, re_string_t *pstr, 172re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
171 RE_TRANSLATE_TYPE trans, bool icase, 173 RE_TRANSLATE_TYPE trans, bool icase,
172 const re_dfa_t *dfa) 174 const re_dfa_t *dfa)
@@ -184,7 +186,6 @@ re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
184 pstr->raw_stop = pstr->stop; 186 pstr->raw_stop = pstr->stop;
185} 187}
186 188
187#ifdef RE_ENABLE_I18N
188 189
189/* Build wide character buffer PSTR->WCS. 190/* Build wide character buffer PSTR->WCS.
190 If the byte sequence of the string are: 191 If the byte sequence of the string are:
@@ -198,12 +199,11 @@ re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
198 built and starts from PSTR->VALID_LEN. */ 199 built and starts from PSTR->VALID_LEN. */
199 200
200static void 201static void
201internal_function
202build_wcs_buffer (re_string_t *pstr) 202build_wcs_buffer (re_string_t *pstr)
203{ 203{
204#ifdef _LIBC 204#ifdef _LIBC
205 unsigned char buf[MB_LEN_MAX]; 205 unsigned char buf[MB_LEN_MAX];
206 assert (MB_LEN_MAX >= pstr->mb_cur_max); 206 DEBUG_ASSERT (MB_LEN_MAX >= pstr->mb_cur_max);
207#else 207#else
208 unsigned char buf[64]; 208 unsigned char buf[64];
209#endif 209#endif
@@ -222,7 +222,7 @@ build_wcs_buffer (re_string_t *pstr)
222 remain_len = end_idx - byte_idx; 222 remain_len = end_idx - byte_idx;
223 prev_st = pstr->cur_state; 223 prev_st = pstr->cur_state;
224 /* Apply the translation if we need. */ 224 /* Apply the translation if we need. */
225 if (BE (pstr->trans != NULL, 0)) 225 if (__glibc_unlikely (pstr->trans != NULL))
226 { 226 {
227 int i, ch; 227 int i, ch;
228 228
@@ -236,17 +236,18 @@ build_wcs_buffer (re_string_t *pstr)
236 else 236 else
237 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; 237 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
238 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); 238 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
239 if (BE (mbclen == (size_t) -1 || mbclen == 0 239 if (__glibc_unlikely (mbclen == (size_t) -1 || mbclen == 0
240 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0)) 240 || (mbclen == (size_t) -2
241 && pstr->bufs_len >= pstr->len)))
241 { 242 {
242 /* We treat these cases as a singlebyte character. */ 243 /* We treat these cases as a singlebyte character. */
243 mbclen = 1; 244 mbclen = 1;
244 wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; 245 wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
245 if (BE (pstr->trans != NULL, 0)) 246 if (__glibc_unlikely (pstr->trans != NULL))
246 wc = pstr->trans[wc]; 247 wc = pstr->trans[wc];
247 pstr->cur_state = prev_st; 248 pstr->cur_state = prev_st;
248 } 249 }
249 else if (BE (mbclen == (size_t) -2, 0)) 250 else if (__glibc_unlikely (mbclen == (size_t) -2))
250 { 251 {
251 /* The buffer doesn't have enough space, finish to build. */ 252 /* The buffer doesn't have enough space, finish to build. */
252 pstr->cur_state = prev_st; 253 pstr->cur_state = prev_st;
@@ -267,7 +268,7 @@ build_wcs_buffer (re_string_t *pstr)
267 but for REG_ICASE. */ 268 but for REG_ICASE. */
268 269
269static reg_errcode_t 270static reg_errcode_t
270internal_function __attribute_warn_unused_result__ 271__attribute_warn_unused_result__
271build_wcs_upper_buffer (re_string_t *pstr) 272build_wcs_upper_buffer (re_string_t *pstr)
272{ 273{
273 mbstate_t prev_st; 274 mbstate_t prev_st;
@@ -275,7 +276,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
275 size_t mbclen; 276 size_t mbclen;
276#ifdef _LIBC 277#ifdef _LIBC
277 char buf[MB_LEN_MAX]; 278 char buf[MB_LEN_MAX];
278 assert (MB_LEN_MAX >= pstr->mb_cur_max); 279 DEBUG_ASSERT (pstr->mb_cur_max <= MB_LEN_MAX);
279#else 280#else
280 char buf[64]; 281 char buf[64];
281#endif 282#endif
@@ -290,18 +291,20 @@ build_wcs_upper_buffer (re_string_t *pstr)
290 while (byte_idx < end_idx) 291 while (byte_idx < end_idx)
291 { 292 {
292 wchar_t wc; 293 wchar_t wc;
294 unsigned char ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
293 295
294 if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) 296 if (isascii (ch) && mbsinit (&pstr->cur_state))
295 && mbsinit (&pstr->cur_state))
296 { 297 {
297 /* In case of a singlebyte character. */
298 pstr->mbs[byte_idx]
299 = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
300 /* The next step uses the assumption that wchar_t is encoded 298 /* The next step uses the assumption that wchar_t is encoded
301 ASCII-safe: all ASCII values can be converted like this. */ 299 ASCII-safe: all ASCII values can be converted like this. */
302 pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx]; 300 wchar_t wcu = __towupper (ch);
303 ++byte_idx; 301 if (isascii (wcu))
304 continue; 302 {
303 pstr->mbs[byte_idx] = wcu;
304 pstr->wcs[byte_idx] = wcu;
305 byte_idx++;
306 continue;
307 }
305 } 308 }
306 309
307 remain_len = end_idx - byte_idx; 310 remain_len = end_idx - byte_idx;
@@ -309,16 +312,15 @@ build_wcs_upper_buffer (re_string_t *pstr)
309 mbclen = __mbrtowc (&wc, 312 mbclen = __mbrtowc (&wc,
310 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx 313 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
311 + byte_idx), remain_len, &pstr->cur_state); 314 + byte_idx), remain_len, &pstr->cur_state);
312 if (BE (mbclen < (size_t) -2, 1)) 315 if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
313 { 316 {
314 wchar_t wcu = wc; 317 wchar_t wcu = __towupper (wc);
315 if (iswlower (wc)) 318 if (wcu != wc)
316 { 319 {
317 size_t mbcdlen; 320 size_t mbcdlen;
318 321
319 wcu = towupper (wc); 322 mbcdlen = __wcrtomb (buf, wcu, &prev_st);
320 mbcdlen = wcrtomb (buf, wcu, &prev_st); 323 if (__glibc_likely (mbclen == mbcdlen))
321 if (BE (mbclen == mbcdlen, 1))
322 memcpy (pstr->mbs + byte_idx, buf, mbclen); 324 memcpy (pstr->mbs + byte_idx, buf, mbclen);
323 else 325 else
324 { 326 {
@@ -339,11 +341,10 @@ build_wcs_upper_buffer (re_string_t *pstr)
339 { 341 {
340 /* It is an invalid character, an incomplete character 342 /* It is an invalid character, an incomplete character
341 at the end of the string, or '\0'. Just use the byte. */ 343 at the end of the string, or '\0'. Just use the byte. */
342 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
343 pstr->mbs[byte_idx] = ch; 344 pstr->mbs[byte_idx] = ch;
344 /* And also cast it to wide char. */ 345 /* And also cast it to wide char. */
345 pstr->wcs[byte_idx++] = (wchar_t) ch; 346 pstr->wcs[byte_idx++] = (wchar_t) ch;
346 if (BE (mbclen == (size_t) -1, 0)) 347 if (__glibc_unlikely (mbclen == (size_t) -1))
347 pstr->cur_state = prev_st; 348 pstr->cur_state = prev_st;
348 } 349 }
349 else 350 else
@@ -365,7 +366,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
365 offsets_needed: 366 offsets_needed:
366 remain_len = end_idx - byte_idx; 367 remain_len = end_idx - byte_idx;
367 prev_st = pstr->cur_state; 368 prev_st = pstr->cur_state;
368 if (BE (pstr->trans != NULL, 0)) 369 if (__glibc_unlikely (pstr->trans != NULL))
369 { 370 {
370 int i, ch; 371 int i, ch;
371 372
@@ -379,16 +380,15 @@ build_wcs_upper_buffer (re_string_t *pstr)
379 else 380 else
380 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; 381 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
381 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); 382 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
382 if (BE (mbclen < (size_t) -2, 1)) 383 if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
383 { 384 {
384 wchar_t wcu = wc; 385 wchar_t wcu = __towupper (wc);
385 if (iswlower (wc)) 386 if (wcu != wc)
386 { 387 {
387 size_t mbcdlen; 388 size_t mbcdlen;
388 389
389 wcu = towupper (wc); 390 mbcdlen = __wcrtomb ((char *) buf, wcu, &prev_st);
390 mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st); 391 if (__glibc_likely (mbclen == mbcdlen))
391 if (BE (mbclen == mbcdlen, 1))
392 memcpy (pstr->mbs + byte_idx, buf, mbclen); 392 memcpy (pstr->mbs + byte_idx, buf, mbclen);
393 else if (mbcdlen != (size_t) -1) 393 else if (mbcdlen != (size_t) -1)
394 { 394 {
@@ -438,7 +438,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
438 else 438 else
439 memcpy (pstr->mbs + byte_idx, p, mbclen); 439 memcpy (pstr->mbs + byte_idx, p, mbclen);
440 440
441 if (BE (pstr->offsets_needed != 0, 0)) 441 if (__glibc_unlikely (pstr->offsets_needed != 0))
442 { 442 {
443 size_t i; 443 size_t i;
444 for (i = 0; i < mbclen; ++i) 444 for (i = 0; i < mbclen; ++i)
@@ -457,17 +457,17 @@ build_wcs_upper_buffer (re_string_t *pstr)
457 /* It is an invalid character or '\0'. Just use the byte. */ 457 /* It is an invalid character or '\0'. Just use the byte. */
458 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; 458 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
459 459
460 if (BE (pstr->trans != NULL, 0)) 460 if (__glibc_unlikely (pstr->trans != NULL))
461 ch = pstr->trans [ch]; 461 ch = pstr->trans [ch];
462 pstr->mbs[byte_idx] = ch; 462 pstr->mbs[byte_idx] = ch;
463 463
464 if (BE (pstr->offsets_needed != 0, 0)) 464 if (__glibc_unlikely (pstr->offsets_needed != 0))
465 pstr->offsets[byte_idx] = src_idx; 465 pstr->offsets[byte_idx] = src_idx;
466 ++src_idx; 466 ++src_idx;
467 467
468 /* And also cast it to wide char. */ 468 /* And also cast it to wide char. */
469 pstr->wcs[byte_idx++] = (wchar_t) ch; 469 pstr->wcs[byte_idx++] = (wchar_t) ch;
470 if (BE (mbclen == (size_t) -1, 0)) 470 if (__glibc_unlikely (mbclen == (size_t) -1))
471 pstr->cur_state = prev_st; 471 pstr->cur_state = prev_st;
472 } 472 }
473 else 473 else
@@ -486,7 +486,6 @@ build_wcs_upper_buffer (re_string_t *pstr)
486 Return the index. */ 486 Return the index. */
487 487
488static Idx 488static Idx
489internal_function
490re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) 489re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
491{ 490{
492 mbstate_t prev_st; 491 mbstate_t prev_st;
@@ -503,7 +502,8 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
503 prev_st = pstr->cur_state; 502 prev_st = pstr->cur_state;
504 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, 503 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
505 remain_len, &pstr->cur_state); 504 remain_len, &pstr->cur_state);
506 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) 505 if (__glibc_unlikely (mbclen == (size_t) -2 || mbclen == (size_t) -1
506 || mbclen == 0))
507 { 507 {
508 /* We treat these cases as a single byte character. */ 508 /* We treat these cases as a single byte character. */
509 if (mbclen == 0 || remain_len == 0) 509 if (mbclen == 0 || remain_len == 0)
@@ -521,13 +521,11 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
521 *last_wc = wc; 521 *last_wc = wc;
522 return rawbuf_idx; 522 return rawbuf_idx;
523} 523}
524#endif /* RE_ENABLE_I18N */
525 524
526/* Build the buffer PSTR->MBS, and apply the translation if we need. 525/* Build the buffer PSTR->MBS, and apply the translation if we need.
527 This function is used in case of REG_ICASE. */ 526 This function is used in case of REG_ICASE. */
528 527
529static void 528static void
530internal_function
531build_upper_buffer (re_string_t *pstr) 529build_upper_buffer (re_string_t *pstr)
532{ 530{
533 Idx char_idx, end_idx; 531 Idx char_idx, end_idx;
@@ -536,12 +534,9 @@ build_upper_buffer (re_string_t *pstr)
536 for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) 534 for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
537 { 535 {
538 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; 536 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
539 if (BE (pstr->trans != NULL, 0)) 537 if (__glibc_unlikely (pstr->trans != NULL))
540 ch = pstr->trans[ch]; 538 ch = pstr->trans[ch];
541 if (islower (ch)) 539 pstr->mbs[char_idx] = toupper (ch);
542 pstr->mbs[char_idx] = toupper (ch);
543 else
544 pstr->mbs[char_idx] = ch;
545 } 540 }
546 pstr->valid_len = char_idx; 541 pstr->valid_len = char_idx;
547 pstr->valid_raw_len = char_idx; 542 pstr->valid_raw_len = char_idx;
@@ -550,7 +545,6 @@ build_upper_buffer (re_string_t *pstr)
550/* Apply TRANS to the buffer in PSTR. */ 545/* Apply TRANS to the buffer in PSTR. */
551 546
552static void 547static void
553internal_function
554re_string_translate_buffer (re_string_t *pstr) 548re_string_translate_buffer (re_string_t *pstr)
555{ 549{
556 Idx buf_idx, end_idx; 550 Idx buf_idx, end_idx;
@@ -571,20 +565,18 @@ re_string_translate_buffer (re_string_t *pstr)
571 convert to upper case in case of REG_ICASE, apply translation. */ 565 convert to upper case in case of REG_ICASE, apply translation. */
572 566
573static reg_errcode_t 567static reg_errcode_t
574internal_function __attribute_warn_unused_result__ 568__attribute_warn_unused_result__
575re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) 569re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
576{ 570{
577 Idx offset; 571 Idx offset;
578 572
579 if (BE (pstr->raw_mbs_idx <= idx, 0)) 573 if (__glibc_unlikely (pstr->raw_mbs_idx <= idx))
580 offset = idx - pstr->raw_mbs_idx; 574 offset = idx - pstr->raw_mbs_idx;
581 else 575 else
582 { 576 {
583 /* Reset buffer. */ 577 /* Reset buffer. */
584#ifdef RE_ENABLE_I18N
585 if (pstr->mb_cur_max > 1) 578 if (pstr->mb_cur_max > 1)
586 memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); 579 memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
587#endif /* RE_ENABLE_I18N */
588 pstr->len = pstr->raw_len; 580 pstr->len = pstr->raw_len;
589 pstr->stop = pstr->raw_stop; 581 pstr->stop = pstr->raw_stop;
590 pstr->valid_len = 0; 582 pstr->valid_len = 0;
@@ -598,14 +590,13 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
598 offset = idx; 590 offset = idx;
599 } 591 }
600 592
601 if (BE (offset != 0, 1)) 593 if (__glibc_likely (offset != 0))
602 { 594 {
603 /* Should the already checked characters be kept? */ 595 /* Should the already checked characters be kept? */
604 if (BE (offset < pstr->valid_raw_len, 1)) 596 if (__glibc_likely (offset < pstr->valid_raw_len))
605 { 597 {
606 /* Yes, move them to the front of the buffer. */ 598 /* Yes, move them to the front of the buffer. */
607#ifdef RE_ENABLE_I18N 599 if (__glibc_unlikely (pstr->offsets_needed))
608 if (BE (pstr->offsets_needed, 0))
609 { 600 {
610 Idx low = 0, high = pstr->valid_len, mid; 601 Idx low = 0, high = pstr->valid_len, mid;
611 do 602 do
@@ -668,40 +659,32 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
668 } 659 }
669 } 660 }
670 else 661 else
671#endif
672 { 662 {
673 pstr->tip_context = re_string_context_at (pstr, offset - 1, 663 pstr->tip_context = re_string_context_at (pstr, offset - 1,
674 eflags); 664 eflags);
675#ifdef RE_ENABLE_I18N
676 if (pstr->mb_cur_max > 1) 665 if (pstr->mb_cur_max > 1)
677 memmove (pstr->wcs, pstr->wcs + offset, 666 memmove (pstr->wcs, pstr->wcs + offset,
678 (pstr->valid_len - offset) * sizeof (wint_t)); 667 (pstr->valid_len - offset) * sizeof (wint_t));
679#endif /* RE_ENABLE_I18N */ 668 if (__glibc_unlikely (pstr->mbs_allocated))
680 if (BE (pstr->mbs_allocated, 0))
681 memmove (pstr->mbs, pstr->mbs + offset, 669 memmove (pstr->mbs, pstr->mbs + offset,
682 pstr->valid_len - offset); 670 pstr->valid_len - offset);
683 pstr->valid_len -= offset; 671 pstr->valid_len -= offset;
684 pstr->valid_raw_len -= offset; 672 pstr->valid_raw_len -= offset;
685#if DEBUG 673 DEBUG_ASSERT (pstr->valid_len > 0);
686 assert (pstr->valid_len > 0);
687#endif
688 } 674 }
689 } 675 }
690 else 676 else
691 { 677 {
692#ifdef RE_ENABLE_I18N
693 /* No, skip all characters until IDX. */ 678 /* No, skip all characters until IDX. */
694 Idx prev_valid_len = pstr->valid_len; 679 Idx prev_valid_len = pstr->valid_len;
695 680
696 if (BE (pstr->offsets_needed, 0)) 681 if (__glibc_unlikely (pstr->offsets_needed))
697 { 682 {
698 pstr->len = pstr->raw_len - idx + offset; 683 pstr->len = pstr->raw_len - idx + offset;
699 pstr->stop = pstr->raw_stop - idx + offset; 684 pstr->stop = pstr->raw_stop - idx + offset;
700 pstr->offsets_needed = 0; 685 pstr->offsets_needed = 0;
701 } 686 }
702#endif
703 pstr->valid_len = 0; 687 pstr->valid_len = 0;
704#ifdef RE_ENABLE_I18N
705 if (pstr->mb_cur_max > 1) 688 if (pstr->mb_cur_max > 1)
706 { 689 {
707 Idx wcs_idx; 690 Idx wcs_idx;
@@ -721,7 +704,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
721#ifdef _LIBC 704#ifdef _LIBC
722 /* We know the wchar_t encoding is UCS4, so for the simple 705 /* We know the wchar_t encoding is UCS4, so for the simple
723 case, ASCII characters, skip the conversion step. */ 706 case, ASCII characters, skip the conversion step. */
724 if (isascii (*p) && BE (pstr->trans == NULL, 1)) 707 if (isascii (*p) && __glibc_likely (pstr->trans == NULL))
725 { 708 {
726 memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); 709 memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
727 /* pstr->valid_len = 0; */ 710 /* pstr->valid_len = 0; */
@@ -739,7 +722,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
739 size_t mbclen; 722 size_t mbclen;
740 723
741 const unsigned char *pp = p; 724 const unsigned char *pp = p;
742 if (BE (pstr->trans != NULL, 0)) 725 if (__glibc_unlikely (pstr->trans != NULL))
743 { 726 {
744 int i = mlen < 6 ? mlen : 6; 727 int i = mlen < 6 ? mlen : 6;
745 while (--i >= 0) 728 while (--i >= 0)
@@ -769,13 +752,13 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
769 pstr->tip_context 752 pstr->tip_context
770 = re_string_context_at (pstr, prev_valid_len - 1, eflags); 753 = re_string_context_at (pstr, prev_valid_len - 1, eflags);
771 else 754 else
772 pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) 755 pstr->tip_context = ((__glibc_unlikely (pstr->word_ops_used != 0)
773 && IS_WIDE_WORD_CHAR (wc)) 756 && IS_WIDE_WORD_CHAR (wc))
774 ? CONTEXT_WORD 757 ? CONTEXT_WORD
775 : ((IS_WIDE_NEWLINE (wc) 758 : ((IS_WIDE_NEWLINE (wc)
776 && pstr->newline_anchor) 759 && pstr->newline_anchor)
777 ? CONTEXT_NEWLINE : 0)); 760 ? CONTEXT_NEWLINE : 0));
778 if (BE (pstr->valid_len, 0)) 761 if (__glibc_unlikely (pstr->valid_len))
779 { 762 {
780 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) 763 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
781 pstr->wcs[wcs_idx] = WEOF; 764 pstr->wcs[wcs_idx] = WEOF;
@@ -785,7 +768,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
785 pstr->valid_raw_len = pstr->valid_len; 768 pstr->valid_raw_len = pstr->valid_len;
786 } 769 }
787 else 770 else
788#endif /* RE_ENABLE_I18N */
789 { 771 {
790 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; 772 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
791 pstr->valid_raw_len = 0; 773 pstr->valid_raw_len = 0;
@@ -797,7 +779,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
797 ? CONTEXT_NEWLINE : 0)); 779 ? CONTEXT_NEWLINE : 0));
798 } 780 }
799 } 781 }
800 if (!BE (pstr->mbs_allocated, 0)) 782 if (!__glibc_unlikely (pstr->mbs_allocated))
801 pstr->mbs += offset; 783 pstr->mbs += offset;
802 } 784 }
803 pstr->raw_mbs_idx = idx; 785 pstr->raw_mbs_idx = idx;
@@ -805,21 +787,19 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
805 pstr->stop -= offset; 787 pstr->stop -= offset;
806 788
807 /* Then build the buffers. */ 789 /* Then build the buffers. */
808#ifdef RE_ENABLE_I18N
809 if (pstr->mb_cur_max > 1) 790 if (pstr->mb_cur_max > 1)
810 { 791 {
811 if (pstr->icase) 792 if (pstr->icase)
812 { 793 {
813 reg_errcode_t ret = build_wcs_upper_buffer (pstr); 794 reg_errcode_t ret = build_wcs_upper_buffer (pstr);
814 if (BE (ret != REG_NOERROR, 0)) 795 if (__glibc_unlikely (ret != REG_NOERROR))
815 return ret; 796 return ret;
816 } 797 }
817 else 798 else
818 build_wcs_buffer (pstr); 799 build_wcs_buffer (pstr);
819 } 800 }
820 else 801 else
821#endif /* RE_ENABLE_I18N */ 802 if (__glibc_unlikely (pstr->mbs_allocated))
822 if (BE (pstr->mbs_allocated, 0))
823 { 803 {
824 if (pstr->icase) 804 if (pstr->icase)
825 build_upper_buffer (pstr); 805 build_upper_buffer (pstr);
@@ -834,50 +814,42 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
834} 814}
835 815
836static unsigned char 816static unsigned char
837internal_function __attribute__ ((pure)) 817__attribute__ ((pure))
838re_string_peek_byte_case (const re_string_t *pstr, Idx idx) 818re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
839{ 819{
840 int ch; 820 int ch;
841 Idx off; 821 Idx off;
842 822
843 /* Handle the common (easiest) cases first. */ 823 /* Handle the common (easiest) cases first. */
844 if (BE (!pstr->mbs_allocated, 1)) 824 if (__glibc_likely (!pstr->mbs_allocated))
845 return re_string_peek_byte (pstr, idx); 825 return re_string_peek_byte (pstr, idx);
846 826
847#ifdef RE_ENABLE_I18N
848 if (pstr->mb_cur_max > 1 827 if (pstr->mb_cur_max > 1
849 && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) 828 && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
850 return re_string_peek_byte (pstr, idx); 829 return re_string_peek_byte (pstr, idx);
851#endif
852 830
853 off = pstr->cur_idx + idx; 831 off = pstr->cur_idx + idx;
854#ifdef RE_ENABLE_I18N
855 if (pstr->offsets_needed) 832 if (pstr->offsets_needed)
856 off = pstr->offsets[off]; 833 off = pstr->offsets[off];
857#endif
858 834
859 ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; 835 ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
860 836
861#ifdef RE_ENABLE_I18N
862 /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I 837 /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
863 this function returns CAPITAL LETTER I instead of first byte of 838 this function returns CAPITAL LETTER I instead of first byte of
864 DOTLESS SMALL LETTER I. The latter would confuse the parser, 839 DOTLESS SMALL LETTER I. The latter would confuse the parser,
865 since peek_byte_case doesn't advance cur_idx in any way. */ 840 since peek_byte_case doesn't advance cur_idx in any way. */
866 if (pstr->offsets_needed && !isascii (ch)) 841 if (pstr->offsets_needed && !isascii (ch))
867 return re_string_peek_byte (pstr, idx); 842 return re_string_peek_byte (pstr, idx);
868#endif
869 843
870 return ch; 844 return ch;
871} 845}
872 846
873static unsigned char 847static unsigned char
874internal_function
875re_string_fetch_byte_case (re_string_t *pstr) 848re_string_fetch_byte_case (re_string_t *pstr)
876{ 849{
877 if (BE (!pstr->mbs_allocated, 1)) 850 if (__glibc_likely (!pstr->mbs_allocated))
878 return re_string_fetch_byte (pstr); 851 return re_string_fetch_byte (pstr);
879 852
880#ifdef RE_ENABLE_I18N
881 if (pstr->offsets_needed) 853 if (pstr->offsets_needed)
882 { 854 {
883 Idx off; 855 Idx off;
@@ -903,19 +875,15 @@ re_string_fetch_byte_case (re_string_t *pstr)
903 re_string_char_size_at (pstr, pstr->cur_idx)); 875 re_string_char_size_at (pstr, pstr->cur_idx));
904 return ch; 876 return ch;
905 } 877 }
906#endif
907 878
908 return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; 879 return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
909} 880}
910 881
911static void 882static void
912internal_function
913re_string_destruct (re_string_t *pstr) 883re_string_destruct (re_string_t *pstr)
914{ 884{
915#ifdef RE_ENABLE_I18N
916 re_free (pstr->wcs); 885 re_free (pstr->wcs);
917 re_free (pstr->offsets); 886 re_free (pstr->offsets);
918#endif /* RE_ENABLE_I18N */
919 if (pstr->mbs_allocated) 887 if (pstr->mbs_allocated)
920 re_free (pstr->mbs); 888 re_free (pstr->mbs);
921} 889}
@@ -923,40 +891,35 @@ re_string_destruct (re_string_t *pstr)
923/* Return the context at IDX in INPUT. */ 891/* Return the context at IDX in INPUT. */
924 892
925static unsigned int 893static unsigned int
926internal_function
927re_string_context_at (const re_string_t *input, Idx idx, int eflags) 894re_string_context_at (const re_string_t *input, Idx idx, int eflags)
928{ 895{
929 int c; 896 int c;
930 if (BE (! REG_VALID_INDEX (idx), 0)) 897 if (__glibc_unlikely (idx < 0))
931 /* In this case, we use the value stored in input->tip_context, 898 /* In this case, we use the value stored in input->tip_context,
932 since we can't know the character in input->mbs[-1] here. */ 899 since we can't know the character in input->mbs[-1] here. */
933 return input->tip_context; 900 return input->tip_context;
934 if (BE (idx == input->len, 0)) 901 if (__glibc_unlikely (idx == input->len))
935 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF 902 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
936 : CONTEXT_NEWLINE | CONTEXT_ENDBUF); 903 : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
937#ifdef RE_ENABLE_I18N
938 if (input->mb_cur_max > 1) 904 if (input->mb_cur_max > 1)
939 { 905 {
940 wint_t wc; 906 wint_t wc;
941 Idx wc_idx = idx; 907 Idx wc_idx = idx;
942 while(input->wcs[wc_idx] == WEOF) 908 while(input->wcs[wc_idx] == WEOF)
943 { 909 {
944#ifdef DEBUG 910 DEBUG_ASSERT (wc_idx >= 0);
945 /* It must not happen. */
946 assert (REG_VALID_INDEX (wc_idx));
947#endif
948 --wc_idx; 911 --wc_idx;
949 if (! REG_VALID_INDEX (wc_idx)) 912 if (wc_idx < 0)
950 return input->tip_context; 913 return input->tip_context;
951 } 914 }
952 wc = input->wcs[wc_idx]; 915 wc = input->wcs[wc_idx];
953 if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) 916 if (__glibc_unlikely (input->word_ops_used != 0)
917 && IS_WIDE_WORD_CHAR (wc))
954 return CONTEXT_WORD; 918 return CONTEXT_WORD;
955 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor 919 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
956 ? CONTEXT_NEWLINE : 0); 920 ? CONTEXT_NEWLINE : 0);
957 } 921 }
958 else 922 else
959#endif
960 { 923 {
961 c = re_string_byte_at (input, idx); 924 c = re_string_byte_at (input, idx);
962 if (bitset_contain (input->word_char, c)) 925 if (bitset_contain (input->word_char, c))
@@ -968,25 +931,26 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
968/* Functions for set operation. */ 931/* Functions for set operation. */
969 932
970static reg_errcode_t 933static reg_errcode_t
971internal_function __attribute_warn_unused_result__ 934__attribute_warn_unused_result__
972re_node_set_alloc (re_node_set *set, Idx size) 935re_node_set_alloc (re_node_set *set, Idx size)
973{ 936{
974 set->alloc = size; 937 set->alloc = size;
975 set->nelem = 0; 938 set->nelem = 0;
976 set->elems = re_malloc (Idx, size); 939 set->elems = re_malloc (Idx, size);
977 if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0)) 940 if (__glibc_unlikely (set->elems == NULL)
941 && (MALLOC_0_IS_NONNULL || size != 0))
978 return REG_ESPACE; 942 return REG_ESPACE;
979 return REG_NOERROR; 943 return REG_NOERROR;
980} 944}
981 945
982static reg_errcode_t 946static reg_errcode_t
983internal_function __attribute_warn_unused_result__ 947__attribute_warn_unused_result__
984re_node_set_init_1 (re_node_set *set, Idx elem) 948re_node_set_init_1 (re_node_set *set, Idx elem)
985{ 949{
986 set->alloc = 1; 950 set->alloc = 1;
987 set->nelem = 1; 951 set->nelem = 1;
988 set->elems = re_malloc (Idx, 1); 952 set->elems = re_malloc (Idx, 1);
989 if (BE (set->elems == NULL, 0)) 953 if (__glibc_unlikely (set->elems == NULL))
990 { 954 {
991 set->alloc = set->nelem = 0; 955 set->alloc = set->nelem = 0;
992 return REG_ESPACE; 956 return REG_ESPACE;
@@ -996,12 +960,12 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
996} 960}
997 961
998static reg_errcode_t 962static reg_errcode_t
999internal_function __attribute_warn_unused_result__ 963__attribute_warn_unused_result__
1000re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) 964re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
1001{ 965{
1002 set->alloc = 2; 966 set->alloc = 2;
1003 set->elems = re_malloc (Idx, 2); 967 set->elems = re_malloc (Idx, 2);
1004 if (BE (set->elems == NULL, 0)) 968 if (__glibc_unlikely (set->elems == NULL))
1005 return REG_ESPACE; 969 return REG_ESPACE;
1006 if (elem1 == elem2) 970 if (elem1 == elem2)
1007 { 971 {
@@ -1026,7 +990,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
1026} 990}
1027 991
1028static reg_errcode_t 992static reg_errcode_t
1029internal_function __attribute_warn_unused_result__ 993__attribute_warn_unused_result__
1030re_node_set_init_copy (re_node_set *dest, const re_node_set *src) 994re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
1031{ 995{
1032 dest->nelem = src->nelem; 996 dest->nelem = src->nelem;
@@ -1034,7 +998,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
1034 { 998 {
1035 dest->alloc = dest->nelem; 999 dest->alloc = dest->nelem;
1036 dest->elems = re_malloc (Idx, dest->alloc); 1000 dest->elems = re_malloc (Idx, dest->alloc);
1037 if (BE (dest->elems == NULL, 0)) 1001 if (__glibc_unlikely (dest->elems == NULL))
1038 { 1002 {
1039 dest->alloc = dest->nelem = 0; 1003 dest->alloc = dest->nelem = 0;
1040 return REG_ESPACE; 1004 return REG_ESPACE;
@@ -1051,7 +1015,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
1051 Note: We assume dest->elems is NULL, when dest->alloc is 0. */ 1015 Note: We assume dest->elems is NULL, when dest->alloc is 0. */
1052 1016
1053static reg_errcode_t 1017static reg_errcode_t
1054internal_function __attribute_warn_unused_result__ 1018__attribute_warn_unused_result__
1055re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, 1019re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1056 const re_node_set *src2) 1020 const re_node_set *src2)
1057{ 1021{
@@ -1065,7 +1029,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1065 { 1029 {
1066 Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; 1030 Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
1067 Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); 1031 Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
1068 if (BE (new_elems == NULL, 0)) 1032 if (__glibc_unlikely (new_elems == NULL))
1069 return REG_ESPACE; 1033 return REG_ESPACE;
1070 dest->elems = new_elems; 1034 dest->elems = new_elems;
1071 dest->alloc = new_alloc; 1035 dest->alloc = new_alloc;
@@ -1082,25 +1046,25 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1082 if (src1->elems[i1] == src2->elems[i2]) 1046 if (src1->elems[i1] == src2->elems[i2])
1083 { 1047 {
1084 /* Try to find the item in DEST. Maybe we could binary search? */ 1048 /* Try to find the item in DEST. Maybe we could binary search? */
1085 while (REG_VALID_INDEX (id) && dest->elems[id] > src1->elems[i1]) 1049 while (id >= 0 && dest->elems[id] > src1->elems[i1])
1086 --id; 1050 --id;
1087 1051
1088 if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1]) 1052 if (id < 0 || dest->elems[id] != src1->elems[i1])
1089 dest->elems[--sbase] = src1->elems[i1]; 1053 dest->elems[--sbase] = src1->elems[i1];
1090 1054
1091 if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2)) 1055 if (--i1 < 0 || --i2 < 0)
1092 break; 1056 break;
1093 } 1057 }
1094 1058
1095 /* Lower the highest of the two items. */ 1059 /* Lower the highest of the two items. */
1096 else if (src1->elems[i1] < src2->elems[i2]) 1060 else if (src1->elems[i1] < src2->elems[i2])
1097 { 1061 {
1098 if (! REG_VALID_INDEX (--i2)) 1062 if (--i2 < 0)
1099 break; 1063 break;
1100 } 1064 }
1101 else 1065 else
1102 { 1066 {
1103 if (! REG_VALID_INDEX (--i1)) 1067 if (--i1 < 0)
1104 break; 1068 break;
1105 } 1069 }
1106 } 1070 }
@@ -1113,7 +1077,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1113 DEST elements are already in place; this is more or 1077 DEST elements are already in place; this is more or
1114 less the same loop that is in re_node_set_merge. */ 1078 less the same loop that is in re_node_set_merge. */
1115 dest->nelem += delta; 1079 dest->nelem += delta;
1116 if (delta > 0 && REG_VALID_INDEX (id)) 1080 if (delta > 0 && id >= 0)
1117 for (;;) 1081 for (;;)
1118 { 1082 {
1119 if (dest->elems[is] > dest->elems[id]) 1083 if (dest->elems[is] > dest->elems[id])
@@ -1127,7 +1091,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1127 { 1091 {
1128 /* Slide from the bottom. */ 1092 /* Slide from the bottom. */
1129 dest->elems[id + delta] = dest->elems[id]; 1093 dest->elems[id + delta] = dest->elems[id];
1130 if (! REG_VALID_INDEX (--id)) 1094 if (--id < 0)
1131 break; 1095 break;
1132 } 1096 }
1133 } 1097 }
@@ -1142,7 +1106,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1142 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ 1106 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
1143 1107
1144static reg_errcode_t 1108static reg_errcode_t
1145internal_function __attribute_warn_unused_result__ 1109__attribute_warn_unused_result__
1146re_node_set_init_union (re_node_set *dest, const re_node_set *src1, 1110re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
1147 const re_node_set *src2) 1111 const re_node_set *src2)
1148{ 1112{
@@ -1151,7 +1115,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
1151 { 1115 {
1152 dest->alloc = src1->nelem + src2->nelem; 1116 dest->alloc = src1->nelem + src2->nelem;
1153 dest->elems = re_malloc (Idx, dest->alloc); 1117 dest->elems = re_malloc (Idx, dest->alloc);
1154 if (BE (dest->elems == NULL, 0)) 1118 if (__glibc_unlikely (dest->elems == NULL))
1155 return REG_ESPACE; 1119 return REG_ESPACE;
1156 } 1120 }
1157 else 1121 else
@@ -1195,7 +1159,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
1195 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ 1159 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
1196 1160
1197static reg_errcode_t 1161static reg_errcode_t
1198internal_function __attribute_warn_unused_result__ 1162__attribute_warn_unused_result__
1199re_node_set_merge (re_node_set *dest, const re_node_set *src) 1163re_node_set_merge (re_node_set *dest, const re_node_set *src)
1200{ 1164{
1201 Idx is, id, sbase, delta; 1165 Idx is, id, sbase, delta;
@@ -1205,14 +1169,18 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1205 { 1169 {
1206 Idx new_alloc = 2 * (src->nelem + dest->alloc); 1170 Idx new_alloc = 2 * (src->nelem + dest->alloc);
1207 Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc); 1171 Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc);
1208 if (BE (new_buffer == NULL, 0)) 1172 if (__glibc_unlikely (new_buffer == NULL))
1209 return REG_ESPACE; 1173 return REG_ESPACE;
1210 dest->elems = new_buffer; 1174 dest->elems = new_buffer;
1211 dest->alloc = new_alloc; 1175 dest->alloc = new_alloc;
1212 } 1176 }
1213 1177
1214 if (BE (dest->nelem == 0, 0)) 1178 if (__glibc_unlikely (dest->nelem == 0))
1215 { 1179 {
1180 /* Although we already guaranteed above that dest->alloc != 0 and
1181 therefore dest->elems != NULL, add a debug assertion to pacify
1182 GCC 11.2.1's -fanalyzer. */
1183 DEBUG_ASSERT (dest->elems);
1216 dest->nelem = src->nelem; 1184 dest->nelem = src->nelem;
1217 memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); 1185 memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
1218 return REG_NOERROR; 1186 return REG_NOERROR;
@@ -1221,8 +1189,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1221 /* Copy into the top of DEST the items of SRC that are not 1189 /* Copy into the top of DEST the items of SRC that are not
1222 found in DEST. Maybe we could binary search in DEST? */ 1190 found in DEST. Maybe we could binary search in DEST? */
1223 for (sbase = dest->nelem + 2 * src->nelem, 1191 for (sbase = dest->nelem + 2 * src->nelem,
1224 is = src->nelem - 1, id = dest->nelem - 1; 1192 is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
1225 REG_VALID_INDEX (is) && REG_VALID_INDEX (id); )
1226 { 1193 {
1227 if (dest->elems[id] == src->elems[is]) 1194 if (dest->elems[id] == src->elems[is])
1228 is--, id--; 1195 is--, id--;
@@ -1232,7 +1199,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1232 --id; 1199 --id;
1233 } 1200 }
1234 1201
1235 if (REG_VALID_INDEX (is)) 1202 if (is >= 0)
1236 { 1203 {
1237 /* If DEST is exhausted, the remaining items of SRC must be unique. */ 1204 /* If DEST is exhausted, the remaining items of SRC must be unique. */
1238 sbase -= is + 1; 1205 sbase -= is + 1;
@@ -1261,7 +1228,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1261 { 1228 {
1262 /* Slide from the bottom. */ 1229 /* Slide from the bottom. */
1263 dest->elems[id + delta] = dest->elems[id]; 1230 dest->elems[id + delta] = dest->elems[id];
1264 if (! REG_VALID_INDEX (--id)) 1231 if (--id < 0)
1265 { 1232 {
1266 /* Copy remaining SRC elements. */ 1233 /* Copy remaining SRC elements. */
1267 memcpy (dest->elems, dest->elems + sbase, 1234 memcpy (dest->elems, dest->elems + sbase,
@@ -1279,17 +1246,20 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1279 Return true if successful. */ 1246 Return true if successful. */
1280 1247
1281static bool 1248static bool
1282internal_function __attribute_warn_unused_result__ 1249__attribute_warn_unused_result__
1283re_node_set_insert (re_node_set *set, Idx elem) 1250re_node_set_insert (re_node_set *set, Idx elem)
1284{ 1251{
1285 Idx idx; 1252 Idx idx;
1286 /* In case the set is empty. */ 1253 /* In case the set is empty. */
1287 if (set->alloc == 0) 1254 if (set->alloc == 0)
1288 return BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1); 1255 return __glibc_likely (re_node_set_init_1 (set, elem) == REG_NOERROR);
1289 1256
1290 if (BE (set->nelem, 0) == 0) 1257 if (__glibc_unlikely (set->nelem) == 0)
1291 { 1258 {
1292 /* We already guaranteed above that set->alloc != 0. */ 1259 /* Although we already guaranteed above that set->alloc != 0 and
1260 therefore set->elems != NULL, add a debug assertion to pacify
1261 GCC 11.2 -fanalyzer. */
1262 DEBUG_ASSERT (set->elems);
1293 set->elems[0] = elem; 1263 set->elems[0] = elem;
1294 ++set->nelem; 1264 ++set->nelem;
1295 return true; 1265 return true;
@@ -1301,7 +1271,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
1301 Idx *new_elems; 1271 Idx *new_elems;
1302 set->alloc = set->alloc * 2; 1272 set->alloc = set->alloc * 2;
1303 new_elems = re_realloc (set->elems, Idx, set->alloc); 1273 new_elems = re_realloc (set->elems, Idx, set->alloc);
1304 if (BE (new_elems == NULL, 0)) 1274 if (__glibc_unlikely (new_elems == NULL))
1305 return false; 1275 return false;
1306 set->elems = new_elems; 1276 set->elems = new_elems;
1307 } 1277 }
@@ -1310,7 +1280,6 @@ re_node_set_insert (re_node_set *set, Idx elem)
1310 first element separately to skip a check in the inner loop. */ 1280 first element separately to skip a check in the inner loop. */
1311 if (elem < set->elems[0]) 1281 if (elem < set->elems[0])
1312 { 1282 {
1313 idx = 0;
1314 for (idx = set->nelem; idx > 0; idx--) 1283 for (idx = set->nelem; idx > 0; idx--)
1315 set->elems[idx] = set->elems[idx - 1]; 1284 set->elems[idx] = set->elems[idx - 1];
1316 } 1285 }
@@ -1318,6 +1287,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
1318 { 1287 {
1319 for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) 1288 for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
1320 set->elems[idx] = set->elems[idx - 1]; 1289 set->elems[idx] = set->elems[idx - 1];
1290 DEBUG_ASSERT (set->elems[idx - 1] < elem);
1321 } 1291 }
1322 1292
1323 /* Insert the new element. */ 1293 /* Insert the new element. */
@@ -1331,7 +1301,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
1331 Return true if successful. */ 1301 Return true if successful. */
1332 1302
1333static bool 1303static bool
1334internal_function __attribute_warn_unused_result__ 1304__attribute_warn_unused_result__
1335re_node_set_insert_last (re_node_set *set, Idx elem) 1305re_node_set_insert_last (re_node_set *set, Idx elem)
1336{ 1306{
1337 /* Realloc if we need. */ 1307 /* Realloc if we need. */
@@ -1340,7 +1310,7 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
1340 Idx *new_elems; 1310 Idx *new_elems;
1341 set->alloc = (set->alloc + 1) * 2; 1311 set->alloc = (set->alloc + 1) * 2;
1342 new_elems = re_realloc (set->elems, Idx, set->alloc); 1312 new_elems = re_realloc (set->elems, Idx, set->alloc);
1343 if (BE (new_elems == NULL, 0)) 1313 if (__glibc_unlikely (new_elems == NULL))
1344 return false; 1314 return false;
1345 set->elems = new_elems; 1315 set->elems = new_elems;
1346 } 1316 }
@@ -1354,13 +1324,13 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
1354 Return true if SET1 and SET2 are equivalent. */ 1324 Return true if SET1 and SET2 are equivalent. */
1355 1325
1356static bool 1326static bool
1357internal_function __attribute__ ((pure)) 1327__attribute__ ((pure))
1358re_node_set_compare (const re_node_set *set1, const re_node_set *set2) 1328re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
1359{ 1329{
1360 Idx i; 1330 Idx i;
1361 if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem) 1331 if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
1362 return false; 1332 return false;
1363 for (i = set1->nelem ; REG_VALID_INDEX (--i) ; ) 1333 for (i = set1->nelem ; --i >= 0 ; )
1364 if (set1->elems[i] != set2->elems[i]) 1334 if (set1->elems[i] != set2->elems[i])
1365 return false; 1335 return false;
1366 return true; 1336 return true;
@@ -1369,11 +1339,11 @@ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
1369/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ 1339/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
1370 1340
1371static Idx 1341static Idx
1372internal_function __attribute__ ((pure)) 1342__attribute__ ((pure))
1373re_node_set_contains (const re_node_set *set, Idx elem) 1343re_node_set_contains (const re_node_set *set, Idx elem)
1374{ 1344{
1375 __re_size_t idx, right, mid; 1345 __re_size_t idx, right, mid;
1376 if (! REG_VALID_NONZERO_INDEX (set->nelem)) 1346 if (set->nelem <= 0)
1377 return 0; 1347 return 0;
1378 1348
1379 /* Binary search the element. */ 1349 /* Binary search the element. */
@@ -1391,7 +1361,6 @@ re_node_set_contains (const re_node_set *set, Idx elem)
1391} 1361}
1392 1362
1393static void 1363static void
1394internal_function
1395re_node_set_remove_at (re_node_set *set, Idx idx) 1364re_node_set_remove_at (re_node_set *set, Idx idx)
1396{ 1365{
1397 if (idx < 0 || idx >= set->nelem) 1366 if (idx < 0 || idx >= set->nelem)
@@ -1403,13 +1372,12 @@ re_node_set_remove_at (re_node_set *set, Idx idx)
1403 1372
1404 1373
1405/* Add the token TOKEN to dfa->nodes, and return the index of the token. 1374/* Add the token TOKEN to dfa->nodes, and return the index of the token.
1406 Or return REG_MISSING if an error occurred. */ 1375 Or return -1 if an error occurred. */
1407 1376
1408static Idx 1377static Idx
1409internal_function
1410re_dfa_add_node (re_dfa_t *dfa, re_token_t token) 1378re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1411{ 1379{
1412 if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) 1380 if (__glibc_unlikely (dfa->nodes_len >= dfa->nodes_alloc))
1413 { 1381 {
1414 size_t new_nodes_alloc = dfa->nodes_alloc * 2; 1382 size_t new_nodes_alloc = dfa->nodes_alloc * 2;
1415 Idx *new_nexts, *new_indices; 1383 Idx *new_nexts, *new_indices;
@@ -1420,41 +1388,43 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1420 const size_t max_object_size = MAX (sizeof (re_token_t), 1388 const size_t max_object_size = MAX (sizeof (re_token_t),
1421 MAX (sizeof (re_node_set), 1389 MAX (sizeof (re_node_set),
1422 sizeof (Idx))); 1390 sizeof (Idx)));
1423 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0)) 1391 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
1424 return REG_MISSING; 1392 < new_nodes_alloc))
1393 return -1;
1425 1394
1426 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); 1395 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
1427 if (BE (new_nodes == NULL, 0)) 1396 if (__glibc_unlikely (new_nodes == NULL))
1428 return REG_MISSING; 1397 return -1;
1429 dfa->nodes = new_nodes; 1398 dfa->nodes = new_nodes;
1399 dfa->nodes_alloc = new_nodes_alloc;
1430 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc); 1400 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
1401 if (new_nexts != NULL)
1402 dfa->nexts = new_nexts;
1431 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc); 1403 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
1404 if (new_indices != NULL)
1405 dfa->org_indices = new_indices;
1432 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); 1406 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
1407 if (new_edests != NULL)
1408 dfa->edests = new_edests;
1433 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); 1409 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
1434 if (BE (new_nexts == NULL || new_indices == NULL 1410 if (new_eclosures != NULL)
1435 || new_edests == NULL || new_eclosures == NULL, 0)) 1411 dfa->eclosures = new_eclosures;
1436 return REG_MISSING; 1412 if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL
1437 dfa->nexts = new_nexts; 1413 || new_edests == NULL || new_eclosures == NULL))
1438 dfa->org_indices = new_indices; 1414 return -1;
1439 dfa->edests = new_edests;
1440 dfa->eclosures = new_eclosures;
1441 dfa->nodes_alloc = new_nodes_alloc;
1442 } 1415 }
1443 dfa->nodes[dfa->nodes_len] = token; 1416 dfa->nodes[dfa->nodes_len] = token;
1444 dfa->nodes[dfa->nodes_len].constraint = 0; 1417 dfa->nodes[dfa->nodes_len].constraint = 0;
1445#ifdef RE_ENABLE_I18N
1446 dfa->nodes[dfa->nodes_len].accept_mb = 1418 dfa->nodes[dfa->nodes_len].accept_mb =
1447 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1) 1419 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
1448 || token.type == COMPLEX_BRACKET); 1420 || token.type == COMPLEX_BRACKET);
1449#endif 1421 dfa->nexts[dfa->nodes_len] = -1;
1450 dfa->nexts[dfa->nodes_len] = REG_MISSING;
1451 re_node_set_init_empty (dfa->edests + dfa->nodes_len); 1422 re_node_set_init_empty (dfa->edests + dfa->nodes_len);
1452 re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); 1423 re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
1453 return dfa->nodes_len++; 1424 return dfa->nodes_len++;
1454} 1425}
1455 1426
1456static re_hashval_t 1427static re_hashval_t
1457internal_function
1458calc_state_hash (const re_node_set *nodes, unsigned int context) 1428calc_state_hash (const re_node_set *nodes, unsigned int context)
1459{ 1429{
1460 re_hashval_t hash = nodes->nelem + context; 1430 re_hashval_t hash = nodes->nelem + context;
@@ -1474,7 +1444,7 @@ calc_state_hash (const re_node_set *nodes, unsigned int context)
1474 optimization. */ 1444 optimization. */
1475 1445
1476static re_dfastate_t * 1446static re_dfastate_t *
1477internal_function __attribute_warn_unused_result__ 1447__attribute_warn_unused_result__
1478re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, 1448re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1479 const re_node_set *nodes) 1449 const re_node_set *nodes)
1480{ 1450{
@@ -1482,11 +1452,11 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1482 re_dfastate_t *new_state; 1452 re_dfastate_t *new_state;
1483 struct re_state_table_entry *spot; 1453 struct re_state_table_entry *spot;
1484 Idx i; 1454 Idx i;
1485#ifdef lint 1455#if defined GCC_LINT || defined lint
1486 /* Suppress bogus uninitialized-variable warnings. */ 1456 /* Suppress bogus uninitialized-variable warnings. */
1487 *err = REG_NOERROR; 1457 *err = REG_NOERROR;
1488#endif 1458#endif
1489 if (BE (nodes->nelem == 0, 0)) 1459 if (__glibc_unlikely (nodes->nelem == 0))
1490 { 1460 {
1491 *err = REG_NOERROR; 1461 *err = REG_NOERROR;
1492 return NULL; 1462 return NULL;
@@ -1505,7 +1475,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1505 1475
1506 /* There are no appropriate state in the dfa, create the new one. */ 1476 /* There are no appropriate state in the dfa, create the new one. */
1507 new_state = create_ci_newstate (dfa, nodes, hash); 1477 new_state = create_ci_newstate (dfa, nodes, hash);
1508 if (BE (new_state == NULL, 0)) 1478 if (__glibc_unlikely (new_state == NULL))
1509 *err = REG_ESPACE; 1479 *err = REG_ESPACE;
1510 1480
1511 return new_state; 1481 return new_state;
@@ -1522,7 +1492,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1522 optimization. */ 1492 optimization. */
1523 1493
1524static re_dfastate_t * 1494static re_dfastate_t *
1525internal_function __attribute_warn_unused_result__ 1495__attribute_warn_unused_result__
1526re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, 1496re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1527 const re_node_set *nodes, unsigned int context) 1497 const re_node_set *nodes, unsigned int context)
1528{ 1498{
@@ -1530,7 +1500,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1530 re_dfastate_t *new_state; 1500 re_dfastate_t *new_state;
1531 struct re_state_table_entry *spot; 1501 struct re_state_table_entry *spot;
1532 Idx i; 1502 Idx i;
1533#ifdef lint 1503#if defined GCC_LINT || defined lint
1534 /* Suppress bogus uninitialized-variable warnings. */ 1504 /* Suppress bogus uninitialized-variable warnings. */
1535 *err = REG_NOERROR; 1505 *err = REG_NOERROR;
1536#endif 1506#endif
@@ -1552,7 +1522,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1552 } 1522 }
1553 /* There are no appropriate state in 'dfa', create the new one. */ 1523 /* There are no appropriate state in 'dfa', create the new one. */
1554 new_state = create_cd_newstate (dfa, nodes, context, hash); 1524 new_state = create_cd_newstate (dfa, nodes, context, hash);
1555 if (BE (new_state == NULL, 0)) 1525 if (__glibc_unlikely (new_state == NULL))
1556 *err = REG_ESPACE; 1526 *err = REG_ESPACE;
1557 1527
1558 return new_state; 1528 return new_state;
@@ -1573,7 +1543,7 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1573 1543
1574 newstate->hash = hash; 1544 newstate->hash = hash;
1575 err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); 1545 err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
1576 if (BE (err != REG_NOERROR, 0)) 1546 if (__glibc_unlikely (err != REG_NOERROR))
1577 return REG_ESPACE; 1547 return REG_ESPACE;
1578 for (i = 0; i < newstate->nodes.nelem; i++) 1548 for (i = 0; i < newstate->nodes.nelem; i++)
1579 { 1549 {
@@ -1584,12 +1554,12 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1584 } 1554 }
1585 1555
1586 spot = dfa->state_table + (hash & dfa->state_hash_mask); 1556 spot = dfa->state_table + (hash & dfa->state_hash_mask);
1587 if (BE (spot->alloc <= spot->num, 0)) 1557 if (__glibc_unlikely (spot->alloc <= spot->num))
1588 { 1558 {
1589 Idx new_alloc = 2 * spot->num + 2; 1559 Idx new_alloc = 2 * spot->num + 2;
1590 re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, 1560 re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
1591 new_alloc); 1561 new_alloc);
1592 if (BE (new_array == NULL, 0)) 1562 if (__glibc_unlikely (new_array == NULL))
1593 return REG_ESPACE; 1563 return REG_ESPACE;
1594 spot->array = new_array; 1564 spot->array = new_array;
1595 spot->alloc = new_alloc; 1565 spot->alloc = new_alloc;
@@ -1618,7 +1588,7 @@ free_state (re_dfastate_t *state)
1618 Return the new state if succeeded, otherwise return NULL. */ 1588 Return the new state if succeeded, otherwise return NULL. */
1619 1589
1620static re_dfastate_t * 1590static re_dfastate_t *
1621internal_function __attribute_warn_unused_result__ 1591__attribute_warn_unused_result__
1622create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, 1592create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1623 re_hashval_t hash) 1593 re_hashval_t hash)
1624{ 1594{
@@ -1627,10 +1597,10 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1627 re_dfastate_t *newstate; 1597 re_dfastate_t *newstate;
1628 1598
1629 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1599 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
1630 if (BE (newstate == NULL, 0)) 1600 if (__glibc_unlikely (newstate == NULL))
1631 return NULL; 1601 return NULL;
1632 err = re_node_set_init_copy (&newstate->nodes, nodes); 1602 err = re_node_set_init_copy (&newstate->nodes, nodes);
1633 if (BE (err != REG_NOERROR, 0)) 1603 if (__glibc_unlikely (err != REG_NOERROR))
1634 { 1604 {
1635 re_free (newstate); 1605 re_free (newstate);
1636 return NULL; 1606 return NULL;
@@ -1643,9 +1613,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1643 re_token_type_t type = node->type; 1613 re_token_type_t type = node->type;
1644 if (type == CHARACTER && !node->constraint) 1614 if (type == CHARACTER && !node->constraint)
1645 continue; 1615 continue;
1646#ifdef RE_ENABLE_I18N
1647 newstate->accept_mb |= node->accept_mb; 1616 newstate->accept_mb |= node->accept_mb;
1648#endif /* RE_ENABLE_I18N */
1649 1617
1650 /* If the state has the halt node, the state is a halt state. */ 1618 /* If the state has the halt node, the state is a halt state. */
1651 if (type == END_OF_RE) 1619 if (type == END_OF_RE)
@@ -1656,7 +1624,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1656 newstate->has_constraint = 1; 1624 newstate->has_constraint = 1;
1657 } 1625 }
1658 err = register_state (dfa, newstate, hash); 1626 err = register_state (dfa, newstate, hash);
1659 if (BE (err != REG_NOERROR, 0)) 1627 if (__glibc_unlikely (err != REG_NOERROR))
1660 { 1628 {
1661 free_state (newstate); 1629 free_state (newstate);
1662 newstate = NULL; 1630 newstate = NULL;
@@ -1668,7 +1636,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1668 Return the new state if succeeded, otherwise return NULL. */ 1636 Return the new state if succeeded, otherwise return NULL. */
1669 1637
1670static re_dfastate_t * 1638static re_dfastate_t *
1671internal_function __attribute_warn_unused_result__ 1639__attribute_warn_unused_result__
1672create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, 1640create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1673 unsigned int context, re_hashval_t hash) 1641 unsigned int context, re_hashval_t hash)
1674{ 1642{
@@ -1677,10 +1645,10 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1677 re_dfastate_t *newstate; 1645 re_dfastate_t *newstate;
1678 1646
1679 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1647 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
1680 if (BE (newstate == NULL, 0)) 1648 if (__glibc_unlikely (newstate == NULL))
1681 return NULL; 1649 return NULL;
1682 err = re_node_set_init_copy (&newstate->nodes, nodes); 1650 err = re_node_set_init_copy (&newstate->nodes, nodes);
1683 if (BE (err != REG_NOERROR, 0)) 1651 if (__glibc_unlikely (err != REG_NOERROR))
1684 { 1652 {
1685 re_free (newstate); 1653 re_free (newstate);
1686 return NULL; 1654 return NULL;
@@ -1697,9 +1665,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1697 1665
1698 if (type == CHARACTER && !constraint) 1666 if (type == CHARACTER && !constraint)
1699 continue; 1667 continue;
1700#ifdef RE_ENABLE_I18N
1701 newstate->accept_mb |= node->accept_mb; 1668 newstate->accept_mb |= node->accept_mb;
1702#endif /* RE_ENABLE_I18N */
1703 1669
1704 /* If the state has the halt node, the state is a halt state. */ 1670 /* If the state has the halt node, the state is a halt state. */
1705 if (type == END_OF_RE) 1671 if (type == END_OF_RE)
@@ -1711,15 +1677,19 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1711 { 1677 {
1712 if (newstate->entrance_nodes == &newstate->nodes) 1678 if (newstate->entrance_nodes == &newstate->nodes)
1713 { 1679 {
1714 newstate->entrance_nodes = re_malloc (re_node_set, 1); 1680 re_node_set *entrance_nodes = re_malloc (re_node_set, 1);
1715 if (BE (newstate->entrance_nodes == NULL, 0)) 1681 if (__glibc_unlikely (entrance_nodes == NULL))
1716 { 1682 {
1717 free_state (newstate); 1683 free_state (newstate);
1718 return NULL; 1684 return NULL;
1719 } 1685 }
1686 newstate->entrance_nodes = entrance_nodes;
1720 if (re_node_set_init_copy (newstate->entrance_nodes, nodes) 1687 if (re_node_set_init_copy (newstate->entrance_nodes, nodes)
1721 != REG_NOERROR) 1688 != REG_NOERROR)
1722 return NULL; 1689 {
1690 free_state (newstate);
1691 return NULL;
1692 }
1723 nctx_nodes = 0; 1693 nctx_nodes = 0;
1724 newstate->has_constraint = 1; 1694 newstate->has_constraint = 1;
1725 } 1695 }
@@ -1732,7 +1702,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1732 } 1702 }
1733 } 1703 }
1734 err = register_state (dfa, newstate, hash); 1704 err = register_state (dfa, newstate, hash);
1735 if (BE (err != REG_NOERROR, 0)) 1705 if (__glibc_unlikely (err != REG_NOERROR))
1736 { 1706 {
1737 free_state (newstate); 1707 free_state (newstate);
1738 newstate = NULL; 1708 newstate = NULL;
diff --git a/gl/regex_internal.h b/gl/regex_internal.h
index a2b8f16f..149ec2e8 100644
--- a/gl/regex_internal.h
+++ b/gl/regex_internal.h
@@ -1,26 +1,25 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20#ifndef _REGEX_INTERNAL_H 20#ifndef _REGEX_INTERNAL_H
21#define _REGEX_INTERNAL_H 1 21#define _REGEX_INTERNAL_H 1
22 22
23#include <assert.h>
24#include <ctype.h> 23#include <ctype.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <stdlib.h> 25#include <stdlib.h>
@@ -30,39 +29,37 @@
30#include <locale.h> 29#include <locale.h>
31#include <wchar.h> 30#include <wchar.h>
32#include <wctype.h> 31#include <wctype.h>
33#include <stdbool.h>
34#include <stdint.h> 32#include <stdint.h>
35 33
34#ifndef _LIBC
35# include <dynarray.h>
36#endif
37
38#include <intprops.h>
39#include <verify.h>
40
41#if defined DEBUG && DEBUG != 0
42# include <assert.h>
43# define DEBUG_ASSERT(x) assert (x)
44#else
45# define DEBUG_ASSERT(x) assume (x)
46#endif
47
36#ifdef _LIBC 48#ifdef _LIBC
37# include <bits/libc-lock.h> 49# include <libc-lock.h>
38# define lock_define(name) __libc_lock_define (, name) 50# define lock_define(name) __libc_lock_define (, name)
39# define lock_init(lock) (__libc_lock_init (lock), 0) 51# define lock_init(lock) (__libc_lock_init (lock), 0)
40# define lock_fini(lock) 0 52# define lock_fini(lock) ((void) 0)
41# define lock_lock(lock) __libc_lock_lock (lock) 53# define lock_lock(lock) __libc_lock_lock (lock)
42# define lock_unlock(lock) __libc_lock_unlock (lock) 54# define lock_unlock(lock) __libc_lock_unlock (lock)
43#elif defined GNULIB_LOCK 55#elif defined GNULIB_LOCK && !defined GNULIB_REGEX_SINGLE_THREAD
44# include "glthread/lock.h" 56# include "glthread/lock.h"
45 /* Use gl_lock_define if empty macro arguments are known to work. 57# define lock_define(name) gl_lock_define (, name)
46 Otherwise, fall back on less-portable substitutes. */
47# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
48 || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
49# define lock_define(name) gl_lock_define (, name)
50# elif USE_POSIX_THREADS
51# define lock_define(name) pthread_mutex_t name;
52# elif USE_PTH_THREADS
53# define lock_define(name) pth_mutex_t name;
54# elif USE_SOLARIS_THREADS
55# define lock_define(name) mutex_t name;
56# elif USE_WINDOWS_THREADS
57# define lock_define(name) gl_lock_t name;
58# else
59# define lock_define(name)
60# endif
61# define lock_init(lock) glthread_lock_init (&(lock)) 58# define lock_init(lock) glthread_lock_init (&(lock))
62# define lock_fini(lock) glthread_lock_destroy (&(lock)) 59# define lock_fini(lock) glthread_lock_destroy (&(lock))
63# define lock_lock(lock) glthread_lock_lock (&(lock)) 60# define lock_lock(lock) glthread_lock_lock (&(lock))
64# define lock_unlock(lock) glthread_lock_unlock (&(lock)) 61# define lock_unlock(lock) glthread_lock_unlock (&(lock))
65#elif defined GNULIB_PTHREAD 62#elif defined GNULIB_PTHREAD && !defined GNULIB_REGEX_SINGLE_THREAD
66# include <pthread.h> 63# include <pthread.h>
67# define lock_define(name) pthread_mutex_t name; 64# define lock_define(name) pthread_mutex_t name;
68# define lock_init(lock) pthread_mutex_init (&(lock), 0) 65# define lock_init(lock) pthread_mutex_init (&(lock), 0)
@@ -83,11 +80,18 @@
83# define isblank(ch) ((ch) == ' ' || (ch) == '\t') 80# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
84#endif 81#endif
85 82
83/* regex code assumes isascii has its usual numeric meaning,
84 even if the portable character set uses EBCDIC encoding,
85 and even if wint_t is wider than int. */
86#ifndef _LIBC
87# undef isascii
88# define isascii(c) (((c) & ~0x7f) == 0)
89#endif
90
86#ifdef _LIBC 91#ifdef _LIBC
87# ifndef _RE_DEFINE_LOCALE_FUNCTIONS 92# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
88# define _RE_DEFINE_LOCALE_FUNCTIONS 1 93# define _RE_DEFINE_LOCALE_FUNCTIONS 1
89# include <locale/localeinfo.h> 94# include <locale/localeinfo.h>
90# include <locale/elem-hash.h>
91# include <locale/coll-lookup.h> 95# include <locale/coll-lookup.h>
92# endif 96# endif
93#endif 97#endif
@@ -101,6 +105,7 @@
101 __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) 105 __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
102# endif 106# endif
103#else 107#else
108# undef gettext
104# define gettext(msgid) (msgid) 109# define gettext(msgid) (msgid)
105#endif 110#endif
106 111
@@ -110,16 +115,6 @@
110# define gettext_noop(String) String 115# define gettext_noop(String) String
111#endif 116#endif
112 117
113#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
114# define RE_ENABLE_I18N
115#endif
116
117#if __GNUC__ >= 3
118# define BE(expr, val) __builtin_expect (expr, val)
119#else
120# define BE(expr, val) (expr)
121#endif
122
123/* Number of ASCII characters. */ 118/* Number of ASCII characters. */
124#define ASCII_CHARS 0x80 119#define ASCII_CHARS 0x80
125 120
@@ -135,45 +130,60 @@
135/* Rename to standard API for using out of glibc. */ 130/* Rename to standard API for using out of glibc. */
136#ifndef _LIBC 131#ifndef _LIBC
137# undef __wctype 132# undef __wctype
133# undef __iswalnum
138# undef __iswctype 134# undef __iswctype
135# undef __towlower
136# undef __towupper
139# define __wctype wctype 137# define __wctype wctype
138# define __iswalnum iswalnum
140# define __iswctype iswctype 139# define __iswctype iswctype
140# define __towlower towlower
141# define __towupper towupper
141# define __btowc btowc 142# define __btowc btowc
142# define __mbrtowc mbrtowc 143# define __mbrtowc mbrtowc
143# define __wcrtomb wcrtomb 144# define __wcrtomb wcrtomb
144# define __regfree regfree 145# define __regfree regfree
145# define attribute_hidden
146#endif /* not _LIBC */ 146#endif /* not _LIBC */
147 147
148#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1) 148/* Types related to integers. Unless protected by #ifdef _LIBC, the
149# define __attribute__(arg) 149 regex code should avoid exact-width types like int32_t and uint64_t
150#endif 150 as some non-GCC platforms lack them, an issue when this code is
151 used in Gnulib. */
151 152
152typedef __re_idx_t Idx; 153#ifndef SSIZE_MAX
153#ifdef _REGEX_LARGE_OFFSETS 154# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
154# define IDX_MAX (SIZE_MAX - 2)
155#else
156# define IDX_MAX INT_MAX
157#endif 155#endif
158 156#ifndef ULONG_WIDTH
159/* Special return value for failure to match. */ 157# define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX)
160#define REG_MISSING ((Idx) -1) 158/* The number of usable bits in an unsigned integer type with maximum
161 159 value MAX, as an int expression suitable in #if. Cover all known
162/* Special return value for internal error. */ 160 practical hosts. This implementation exploits the fact that MAX is
163#define REG_ERROR ((Idx) -2) 161 1 less than a power of 2, and merely counts the number of 1 bits in
164 162 MAX; "COBn" means "count the number of 1 bits in the low-order n bits". */
165/* Test whether N is a valid index, and is not one of the above. */ 163# define REGEX_UINTEGER_WIDTH(max) REGEX_COB128 (max)
166#ifdef _REGEX_LARGE_OFFSETS 164# define REGEX_COB128(n) (REGEX_COB64 ((n) >> 31 >> 31 >> 2) + REGEX_COB64 (n))
167# define REG_VALID_INDEX(n) ((Idx) (n) < REG_ERROR) 165# define REGEX_COB64(n) (REGEX_COB32 ((n) >> 31 >> 1) + REGEX_COB32 (n))
168#else 166# define REGEX_COB32(n) (REGEX_COB16 ((n) >> 16) + REGEX_COB16 (n))
169# define REG_VALID_INDEX(n) (0 <= (n)) 167# define REGEX_COB16(n) (REGEX_COB8 ((n) >> 8) + REGEX_COB8 (n))
168# define REGEX_COB8(n) (REGEX_COB4 ((n) >> 4) + REGEX_COB4 (n))
169# define REGEX_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + ((n) & 1))
170# if ULONG_MAX / 2 + 1 != 1ul << (ULONG_WIDTH - 1)
171# error "ULONG_MAX out of range"
172# endif
170#endif 173#endif
171 174
172/* Test whether N is a valid nonzero index. */ 175/* The type of indexes into strings. This is signed, not size_t,
176 since the API requires indexes to fit in regoff_t anyway, and using
177 signed integers makes the code a bit smaller and presumably faster.
178 The traditional GNU regex implementation uses int for indexes.
179 The POSIX-compatible implementation uses a possibly-wider type.
180 The name 'Idx' is three letters to minimize the hassle of
181 reindenting a lot of regex code that formerly used 'int'. */
182typedef regoff_t Idx;
173#ifdef _REGEX_LARGE_OFFSETS 183#ifdef _REGEX_LARGE_OFFSETS
174# define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1)) 184# define IDX_MAX SSIZE_MAX
175#else 185#else
176# define REG_VALID_NONZERO_INDEX(n) (0 < (n)) 186# define IDX_MAX INT_MAX
177#endif 187#endif
178 188
179/* A hash value, suitable for computing hash tables. */ 189/* A hash value, suitable for computing hash tables. */
@@ -184,36 +194,8 @@ typedef __re_size_t re_hashval_t;
184typedef unsigned long int bitset_word_t; 194typedef unsigned long int bitset_word_t;
185/* All bits set in a bitset_word_t. */ 195/* All bits set in a bitset_word_t. */
186#define BITSET_WORD_MAX ULONG_MAX 196#define BITSET_WORD_MAX ULONG_MAX
187 197/* Number of bits in a bitset_word_t. */
188/* Number of bits in a bitset_word_t. For portability to hosts with 198#define BITSET_WORD_BITS ULONG_WIDTH
189 padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)';
190 instead, deduce it directly from BITSET_WORD_MAX. Avoid
191 greater-than-32-bit integers and unconditional shifts by more than
192 31 bits, as they're not portable. */
193#if BITSET_WORD_MAX == 0xffffffffUL
194# define BITSET_WORD_BITS 32
195#elif BITSET_WORD_MAX >> 31 >> 4 == 1
196# define BITSET_WORD_BITS 36
197#elif BITSET_WORD_MAX >> 31 >> 16 == 1
198# define BITSET_WORD_BITS 48
199#elif BITSET_WORD_MAX >> 31 >> 28 == 1
200# define BITSET_WORD_BITS 60
201#elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1
202# define BITSET_WORD_BITS 64
203#elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1
204# define BITSET_WORD_BITS 72
205#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1
206# define BITSET_WORD_BITS 128
207#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1
208# define BITSET_WORD_BITS 256
209#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1
210# define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */
211# if BITSET_WORD_BITS <= SBC_MAX
212# error "Invalid SBC_MAX"
213# endif
214#else
215# error "Add case for new bitset_word_t size"
216#endif
217 199
218/* Number of bitset_word_t values in a bitset_t. */ 200/* Number of bitset_word_t values in a bitset_t. */
219#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) 201#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
@@ -264,10 +246,8 @@ typedef enum
264 SIMPLE_BRACKET = 3, 246 SIMPLE_BRACKET = 3,
265 OP_BACK_REF = 4, 247 OP_BACK_REF = 4,
266 OP_PERIOD = 5, 248 OP_PERIOD = 5,
267#ifdef RE_ENABLE_I18N
268 COMPLEX_BRACKET = 6, 249 COMPLEX_BRACKET = 6,
269 OP_UTF8_PERIOD = 7, 250 OP_UTF8_PERIOD = 7,
270#endif /* RE_ENABLE_I18N */
271 251
272 /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used 252 /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
273 when the debugger shows values of this enum type. */ 253 when the debugger shows values of this enum type. */
@@ -305,30 +285,29 @@ typedef enum
305 285
306} re_token_type_t; 286} re_token_type_t;
307 287
308#ifdef RE_ENABLE_I18N
309typedef struct 288typedef struct
310{ 289{
311 /* Multibyte characters. */ 290 /* Multibyte characters. */
312 wchar_t *mbchars; 291 wchar_t *mbchars;
313 292
293#ifdef _LIBC
314 /* Collating symbols. */ 294 /* Collating symbols. */
315# ifdef _LIBC
316 int32_t *coll_syms; 295 int32_t *coll_syms;
317# endif 296#endif
318 297
298#ifdef _LIBC
319 /* Equivalence classes. */ 299 /* Equivalence classes. */
320# ifdef _LIBC
321 int32_t *equiv_classes; 300 int32_t *equiv_classes;
322# endif 301#endif
323 302
324 /* Range expressions. */ 303 /* Range expressions. */
325# ifdef _LIBC 304#ifdef _LIBC
326 uint32_t *range_starts; 305 uint32_t *range_starts;
327 uint32_t *range_ends; 306 uint32_t *range_ends;
328# else /* not _LIBC */ 307#else
329 wchar_t *range_starts; 308 wchar_t *range_starts;
330 wchar_t *range_ends; 309 wchar_t *range_ends;
331# endif /* not _LIBC */ 310#endif
332 311
333 /* Character classes. */ 312 /* Character classes. */
334 wctype_t *char_classes; 313 wctype_t *char_classes;
@@ -351,7 +330,6 @@ typedef struct
351 /* # of character classes. */ 330 /* # of character classes. */
352 Idx nchar_classes; 331 Idx nchar_classes;
353} re_charset_t; 332} re_charset_t;
354#endif /* RE_ENABLE_I18N */
355 333
356typedef struct 334typedef struct
357{ 335{
@@ -359,13 +337,11 @@ typedef struct
359 { 337 {
360 unsigned char c; /* for CHARACTER */ 338 unsigned char c; /* for CHARACTER */
361 re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ 339 re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
362#ifdef RE_ENABLE_I18N
363 re_charset_t *mbcset; /* for COMPLEX_BRACKET */ 340 re_charset_t *mbcset; /* for COMPLEX_BRACKET */
364#endif /* RE_ENABLE_I18N */
365 Idx idx; /* for BACK_REF */ 341 Idx idx; /* for BACK_REF */
366 re_context_type ctx_type; /* for ANCHOR */ 342 re_context_type ctx_type; /* for ANCHOR */
367 } opr; 343 } opr;
368#if __GNUC__ >= 2 && !defined __STRICT_ANSI__ 344#if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
369 re_token_type_t type : 8; 345 re_token_type_t type : 8;
370#else 346#else
371 re_token_type_t type; 347 re_token_type_t type;
@@ -373,12 +349,10 @@ typedef struct
373 unsigned int constraint : 10; /* context constraint */ 349 unsigned int constraint : 10; /* context constraint */
374 unsigned int duplicated : 1; 350 unsigned int duplicated : 1;
375 unsigned int opt_subexp : 1; 351 unsigned int opt_subexp : 1;
376#ifdef RE_ENABLE_I18N
377 unsigned int accept_mb : 1; 352 unsigned int accept_mb : 1;
378 /* These 2 bits can be moved into the union if needed (e.g. if running out 353 /* These 2 bits can be moved into the union if needed (e.g. if running out
379 of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ 354 of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
380 unsigned int mb_partial : 1; 355 unsigned int mb_partial : 1;
381#endif
382 unsigned int word_char : 1; 356 unsigned int word_char : 1;
383} re_token_t; 357} re_token_t;
384 358
@@ -393,12 +367,10 @@ struct re_string_t
393 REG_ICASE, upper cases of the string are stored, otherwise MBS points 367 REG_ICASE, upper cases of the string are stored, otherwise MBS points
394 the same address that RAW_MBS points. */ 368 the same address that RAW_MBS points. */
395 unsigned char *mbs; 369 unsigned char *mbs;
396#ifdef RE_ENABLE_I18N
397 /* Store the wide character string which is corresponding to MBS. */ 370 /* Store the wide character string which is corresponding to MBS. */
398 wint_t *wcs; 371 wint_t *wcs;
399 Idx *offsets; 372 Idx *offsets;
400 mbstate_t cur_state; 373 mbstate_t cur_state;
401#endif
402 /* Index in RAW_MBS. Each character mbs[i] corresponds to 374 /* Index in RAW_MBS. Each character mbs[i] corresponds to
403 raw_mbs[raw_mbs_idx + i]. */ 375 raw_mbs[raw_mbs_idx + i]. */
404 Idx raw_mbs_idx; 376 Idx raw_mbs_idx;
@@ -446,24 +418,9 @@ struct re_dfa_t;
446typedef struct re_dfa_t re_dfa_t; 418typedef struct re_dfa_t re_dfa_t;
447 419
448#ifndef _LIBC 420#ifndef _LIBC
449# define internal_function 421# define IS_IN(libc) false
450#endif 422#endif
451 423
452#ifndef NOT_IN_libc
453static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
454 Idx new_buf_len)
455 internal_function;
456# ifdef RE_ENABLE_I18N
457static void build_wcs_buffer (re_string_t *pstr) internal_function;
458static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr)
459 internal_function;
460# endif /* RE_ENABLE_I18N */
461static void build_upper_buffer (re_string_t *pstr) internal_function;
462static void re_string_translate_buffer (re_string_t *pstr) internal_function;
463static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
464 int eflags)
465 internal_function __attribute__ ((pure));
466#endif
467#define re_string_peek_byte(pstr, offset) \ 424#define re_string_peek_byte(pstr, offset) \
468 ((pstr)->mbs[(pstr)->cur_idx + offset]) 425 ((pstr)->mbs[(pstr)->cur_idx + offset])
469#define re_string_fetch_byte(pstr) \ 426#define re_string_fetch_byte(pstr) \
@@ -481,25 +438,6 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
481#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) 438#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
482#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) 439#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
483 440
484#if defined _LIBC || HAVE_ALLOCA
485# include <alloca.h>
486#endif
487
488#ifndef _LIBC
489# if HAVE_ALLOCA
490/* The OS usually guarantees only one guard page at the bottom of the stack,
491 and a page size can be as small as 4096 bytes. So we cannot safely
492 allocate anything larger than 4096 bytes. Also care for the possibility
493 of a few compiler-allocated temporary stack slots. */
494# define __libc_use_alloca(n) ((n) < 4032)
495# else
496/* alloca is implemented with malloc, so just use malloc. */
497# define __libc_use_alloca(n) 0
498# undef alloca
499# define alloca(n) malloc (n)
500# endif
501#endif
502
503#ifdef _LIBC 441#ifdef _LIBC
504# define MALLOC_0_IS_NONNULL 1 442# define MALLOC_0_IS_NONNULL 1
505#elif !defined MALLOC_0_IS_NONNULL 443#elif !defined MALLOC_0_IS_NONNULL
@@ -556,7 +494,7 @@ typedef struct bin_tree_storage_t bin_tree_storage_t;
556 494
557#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') 495#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
558#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) 496#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
559#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_') 497#define IS_WIDE_WORD_CHAR(ch) (__iswalnum (ch) || (ch) == L'_')
560#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) 498#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
561 499
562#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ 500#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
@@ -636,20 +574,15 @@ struct re_backref_cache_entry
636 Idx str_idx; 574 Idx str_idx;
637 Idx subexp_from; 575 Idx subexp_from;
638 Idx subexp_to; 576 Idx subexp_to;
577 bitset_word_t eps_reachable_subexps_map;
639 char more; 578 char more;
640 char unused;
641 unsigned short int eps_reachable_subexps_map;
642}; 579};
643 580
644typedef struct 581typedef struct
645{ 582{
646 /* The string object corresponding to the input string. */ 583 /* The string object corresponding to the input string. */
647 re_string_t input; 584 re_string_t input;
648#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
649 const re_dfa_t *const dfa; 585 const re_dfa_t *const dfa;
650#else
651 const re_dfa_t *dfa;
652#endif
653 /* EFLAGS of the argument of regexec. */ 586 /* EFLAGS of the argument of regexec. */
654 int eflags; 587 int eflags;
655 /* Where the matching ends. */ 588 /* Where the matching ends. */
@@ -769,31 +702,31 @@ typedef struct
769 702
770/* Functions for bitset_t operation. */ 703/* Functions for bitset_t operation. */
771 704
772static void 705static inline void
773bitset_set (bitset_t set, Idx i) 706bitset_set (bitset_t set, Idx i)
774{ 707{
775 set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS; 708 set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
776} 709}
777 710
778static void 711static inline void
779bitset_clear (bitset_t set, Idx i) 712bitset_clear (bitset_t set, Idx i)
780{ 713{
781 set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS); 714 set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
782} 715}
783 716
784static bool 717static inline bool
785bitset_contain (const bitset_t set, Idx i) 718bitset_contain (const bitset_t set, Idx i)
786{ 719{
787 return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1; 720 return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
788} 721}
789 722
790static void 723static inline void
791bitset_empty (bitset_t set) 724bitset_empty (bitset_t set)
792{ 725{
793 memset (set, '\0', sizeof (bitset_t)); 726 memset (set, '\0', sizeof (bitset_t));
794} 727}
795 728
796static void 729static inline void
797bitset_set_all (bitset_t set) 730bitset_set_all (bitset_t set)
798{ 731{
799 memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS)); 732 memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
@@ -802,13 +735,13 @@ bitset_set_all (bitset_t set)
802 ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1; 735 ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
803} 736}
804 737
805static void 738static inline void
806bitset_copy (bitset_t dest, const bitset_t src) 739bitset_copy (bitset_t dest, const bitset_t src)
807{ 740{
808 memcpy (dest, src, sizeof (bitset_t)); 741 memcpy (dest, src, sizeof (bitset_t));
809} 742}
810 743
811static void __attribute__ ((unused)) 744static inline void
812bitset_not (bitset_t set) 745bitset_not (bitset_t set)
813{ 746{
814 int bitset_i; 747 int bitset_i;
@@ -820,7 +753,7 @@ bitset_not (bitset_t set)
820 & ~set[BITSET_WORDS - 1]); 753 & ~set[BITSET_WORDS - 1]);
821} 754}
822 755
823static void __attribute__ ((unused)) 756static inline void
824bitset_merge (bitset_t dest, const bitset_t src) 757bitset_merge (bitset_t dest, const bitset_t src)
825{ 758{
826 int bitset_i; 759 int bitset_i;
@@ -828,7 +761,7 @@ bitset_merge (bitset_t dest, const bitset_t src)
828 dest[bitset_i] |= src[bitset_i]; 761 dest[bitset_i] |= src[bitset_i];
829} 762}
830 763
831static void __attribute__ ((unused)) 764static inline void
832bitset_mask (bitset_t dest, const bitset_t src) 765bitset_mask (bitset_t dest, const bitset_t src)
833{ 766{
834 int bitset_i; 767 int bitset_i;
@@ -836,10 +769,9 @@ bitset_mask (bitset_t dest, const bitset_t src)
836 dest[bitset_i] &= src[bitset_i]; 769 dest[bitset_i] &= src[bitset_i];
837} 770}
838 771
839#ifdef RE_ENABLE_I18N
840/* Functions for re_string. */ 772/* Functions for re_string. */
841static int 773static int
842internal_function __attribute__ ((pure, unused)) 774__attribute__ ((pure, unused))
843re_string_char_size_at (const re_string_t *pstr, Idx idx) 775re_string_char_size_at (const re_string_t *pstr, Idx idx)
844{ 776{
845 int byte_idx; 777 int byte_idx;
@@ -852,7 +784,7 @@ re_string_char_size_at (const re_string_t *pstr, Idx idx)
852} 784}
853 785
854static wint_t 786static wint_t
855internal_function __attribute__ ((pure, unused)) 787__attribute__ ((pure, unused))
856re_string_wchar_at (const re_string_t *pstr, Idx idx) 788re_string_wchar_at (const re_string_t *pstr, Idx idx)
857{ 789{
858 if (pstr->mb_cur_max == 1) 790 if (pstr->mb_cur_max == 1)
@@ -860,15 +792,17 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
860 return (wint_t) pstr->wcs[idx]; 792 return (wint_t) pstr->wcs[idx];
861} 793}
862 794
863# ifndef NOT_IN_libc 795#ifdef _LIBC
796# include <locale/weight.h>
797#endif
798
864static int 799static int
865internal_function __attribute__ ((pure, unused)) 800__attribute__ ((pure, unused))
866re_string_elem_size_at (const re_string_t *pstr, Idx idx) 801re_string_elem_size_at (const re_string_t *pstr, Idx idx)
867{ 802{
868# ifdef _LIBC 803#ifdef _LIBC
869 const unsigned char *p, *extra; 804 const unsigned char *p, *extra;
870 const int32_t *table, *indirect; 805 const int32_t *table, *indirect;
871# include <locale/weight.h>
872 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 806 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
873 807
874 if (nrules != 0) 808 if (nrules != 0)
@@ -879,31 +813,22 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
879 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, 813 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
880 _NL_COLLATE_INDIRECTMB); 814 _NL_COLLATE_INDIRECTMB);
881 p = pstr->mbs + idx; 815 p = pstr->mbs + idx;
882 findidx (&p, pstr->len - idx); 816 findidx (table, indirect, extra, &p, pstr->len - idx);
883 return p - pstr->mbs - idx; 817 return p - pstr->mbs - idx;
884 } 818 }
885 else 819#endif /* _LIBC */
886# endif /* _LIBC */ 820
887 return 1; 821 return 1;
888} 822}
889# endif
890#endif /* RE_ENABLE_I18N */
891 823
892#ifndef __GNUC_PREREQ 824#ifdef _LIBC
893# if defined __GNUC__ && defined __GNUC_MINOR__ 825# if __GNUC__ >= 7
894# define __GNUC_PREREQ(maj, min) \ 826# define FALLTHROUGH __attribute__ ((__fallthrough__))
895 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
896# else 827# else
897# define __GNUC_PREREQ(maj, min) 0 828# define FALLTHROUGH ((void) 0)
898# endif 829# endif
899#endif
900
901#if __GNUC_PREREQ (3,4)
902# undef __attribute_warn_unused_result__
903# define __attribute_warn_unused_result__ \
904 __attribute__ ((__warn_unused_result__))
905#else 830#else
906# define __attribute_warn_unused_result__ /* empty */ 831# include "attribute.h"
907#endif 832#endif
908 833
909#endif /* _REGEX_INTERNAL_H */ 834#endif /* _REGEX_INTERNAL_H */
diff --git a/gl/regexec.c b/gl/regexec.c
index d29d442b..13e0349e 100644
--- a/gl/regexec.c
+++ b/gl/regexec.c
@@ -1,206 +1,170 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, 20static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
21 Idx n) internal_function; 21 Idx n);
22static void match_ctx_clean (re_match_context_t *mctx) internal_function; 22static void match_ctx_clean (re_match_context_t *mctx);
23static void match_ctx_free (re_match_context_t *cache) internal_function; 23static void match_ctx_free (re_match_context_t *cache);
24static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node, 24static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node,
25 Idx str_idx, Idx from, Idx to) 25 Idx str_idx, Idx from, Idx to);
26 internal_function; 26static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx);
27static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
28 internal_function;
29static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node, 27static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
30 Idx str_idx) internal_function; 28 Idx str_idx);
31static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop, 29static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
32 Idx node, Idx str_idx) 30 Idx node, Idx str_idx);
33 internal_function;
34static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, 31static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
35 re_dfastate_t **limited_sts, Idx last_node, 32 re_dfastate_t **limited_sts, Idx last_node,
36 Idx last_str_idx) 33 Idx last_str_idx);
37 internal_function;
38static reg_errcode_t re_search_internal (const regex_t *preg, 34static reg_errcode_t re_search_internal (const regex_t *preg,
39 const char *string, Idx length, 35 const char *string, Idx length,
40 Idx start, Idx last_start, Idx stop, 36 Idx start, Idx last_start, Idx stop,
41 size_t nmatch, regmatch_t pmatch[], 37 size_t nmatch, regmatch_t pmatch[],
42 int eflags) internal_function; 38 int eflags);
43static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp, 39static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp,
44 const char *string1, Idx length1, 40 const char *string1, Idx length1,
45 const char *string2, Idx length2, 41 const char *string2, Idx length2,
46 Idx start, regoff_t range, 42 Idx start, regoff_t range,
47 struct re_registers *regs, 43 struct re_registers *regs,
48 Idx stop, bool ret_len) internal_function; 44 Idx stop, bool ret_len);
49static regoff_t re_search_stub (struct re_pattern_buffer *bufp, 45static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
50 const char *string, Idx length, Idx start, 46 const char *string, Idx length, Idx start,
51 regoff_t range, Idx stop, 47 regoff_t range, Idx stop,
52 struct re_registers *regs, 48 struct re_registers *regs,
53 bool ret_len) internal_function; 49 bool ret_len);
54static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, 50static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
55 Idx nregs, int regs_allocated) internal_function; 51 Idx nregs, int regs_allocated);
56static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) 52static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx);
57 internal_function;
58static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match, 53static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
59 Idx *p_match_first) internal_function; 54 Idx *p_match_first);
60static Idx check_halt_state_context (const re_match_context_t *mctx, 55static Idx check_halt_state_context (const re_match_context_t *mctx,
61 const re_dfastate_t *state, Idx idx) 56 const re_dfastate_t *state, Idx idx);
62 internal_function;
63static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, 57static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
64 regmatch_t *prev_idx_match, Idx cur_node, 58 regmatch_t *prev_idx_match, Idx cur_node,
65 Idx cur_idx, Idx nmatch) internal_function; 59 Idx cur_idx, Idx nmatch);
66static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, 60static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
67 Idx str_idx, Idx dest_node, Idx nregs, 61 Idx str_idx, Idx dest_node, Idx nregs,
68 regmatch_t *regs, 62 regmatch_t *regs, regmatch_t *prevregs,
69 re_node_set *eps_via_nodes) 63 re_node_set *eps_via_nodes);
70 internal_function;
71static reg_errcode_t set_regs (const regex_t *preg, 64static reg_errcode_t set_regs (const regex_t *preg,
72 const re_match_context_t *mctx, 65 const re_match_context_t *mctx,
73 size_t nmatch, regmatch_t *pmatch, 66 size_t nmatch, regmatch_t *pmatch,
74 bool fl_backtrack) internal_function; 67 bool fl_backtrack);
75static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) 68static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs);
76 internal_function;
77 69
78#ifdef RE_ENABLE_I18N
79static int sift_states_iter_mb (const re_match_context_t *mctx, 70static int sift_states_iter_mb (const re_match_context_t *mctx,
80 re_sift_context_t *sctx, 71 re_sift_context_t *sctx,
81 Idx node_idx, Idx str_idx, Idx max_str_idx) 72 Idx node_idx, Idx str_idx, Idx max_str_idx);
82 internal_function;
83#endif /* RE_ENABLE_I18N */
84static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, 73static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
85 re_sift_context_t *sctx) 74 re_sift_context_t *sctx);
86 internal_function;
87static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, 75static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
88 re_sift_context_t *sctx, Idx str_idx, 76 re_sift_context_t *sctx, Idx str_idx,
89 re_node_set *cur_dest) 77 re_node_set *cur_dest);
90 internal_function;
91static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, 78static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
92 re_sift_context_t *sctx, 79 re_sift_context_t *sctx,
93 Idx str_idx, 80 Idx str_idx,
94 re_node_set *dest_nodes) 81 re_node_set *dest_nodes);
95 internal_function;
96static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, 82static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
97 re_node_set *dest_nodes, 83 re_node_set *dest_nodes,
98 const re_node_set *candidates) 84 const re_node_set *candidates);
99 internal_function;
100static bool check_dst_limits (const re_match_context_t *mctx, 85static bool check_dst_limits (const re_match_context_t *mctx,
101 const re_node_set *limits, 86 const re_node_set *limits,
102 Idx dst_node, Idx dst_idx, Idx src_node, 87 Idx dst_node, Idx dst_idx, Idx src_node,
103 Idx src_idx) internal_function; 88 Idx src_idx);
104static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, 89static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
105 int boundaries, Idx subexp_idx, 90 int boundaries, Idx subexp_idx,
106 Idx from_node, Idx bkref_idx) 91 Idx from_node, Idx bkref_idx);
107 internal_function;
108static int check_dst_limits_calc_pos (const re_match_context_t *mctx, 92static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
109 Idx limit, Idx subexp_idx, 93 Idx limit, Idx subexp_idx,
110 Idx node, Idx str_idx, 94 Idx node, Idx str_idx,
111 Idx bkref_idx) internal_function; 95 Idx bkref_idx);
112static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, 96static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa,
113 re_node_set *dest_nodes, 97 re_node_set *dest_nodes,
114 const re_node_set *candidates, 98 const re_node_set *candidates,
115 re_node_set *limits, 99 re_node_set *limits,
116 struct re_backref_cache_entry *bkref_ents, 100 struct re_backref_cache_entry *bkref_ents,
117 Idx str_idx) internal_function; 101 Idx str_idx);
118static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, 102static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
119 re_sift_context_t *sctx, 103 re_sift_context_t *sctx,
120 Idx str_idx, const re_node_set *candidates) 104 Idx str_idx, const re_node_set *candidates);
121 internal_function;
122static reg_errcode_t merge_state_array (const re_dfa_t *dfa, 105static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
123 re_dfastate_t **dst, 106 re_dfastate_t **dst,
124 re_dfastate_t **src, Idx num) 107 re_dfastate_t **src, Idx num);
125 internal_function;
126static re_dfastate_t *find_recover_state (reg_errcode_t *err, 108static re_dfastate_t *find_recover_state (reg_errcode_t *err,
127 re_match_context_t *mctx) internal_function; 109 re_match_context_t *mctx);
128static re_dfastate_t *transit_state (reg_errcode_t *err, 110static re_dfastate_t *transit_state (reg_errcode_t *err,
129 re_match_context_t *mctx, 111 re_match_context_t *mctx,
130 re_dfastate_t *state) internal_function; 112 re_dfastate_t *state);
131static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, 113static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
132 re_match_context_t *mctx, 114 re_match_context_t *mctx,
133 re_dfastate_t *next_state) 115 re_dfastate_t *next_state);
134 internal_function;
135static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, 116static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
136 re_node_set *cur_nodes, 117 re_node_set *cur_nodes,
137 Idx str_idx) internal_function; 118 Idx str_idx);
138#if 0 119#if 0
139static re_dfastate_t *transit_state_sb (reg_errcode_t *err, 120static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
140 re_match_context_t *mctx, 121 re_match_context_t *mctx,
141 re_dfastate_t *pstate) 122 re_dfastate_t *pstate);
142 internal_function;
143#endif 123#endif
144#ifdef RE_ENABLE_I18N
145static reg_errcode_t transit_state_mb (re_match_context_t *mctx, 124static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
146 re_dfastate_t *pstate) 125 re_dfastate_t *pstate);
147 internal_function;
148#endif /* RE_ENABLE_I18N */
149static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, 126static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
150 const re_node_set *nodes) 127 const re_node_set *nodes);
151 internal_function;
152static reg_errcode_t get_subexp (re_match_context_t *mctx, 128static reg_errcode_t get_subexp (re_match_context_t *mctx,
153 Idx bkref_node, Idx bkref_str_idx) 129 Idx bkref_node, Idx bkref_str_idx);
154 internal_function;
155static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, 130static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
156 const re_sub_match_top_t *sub_top, 131 const re_sub_match_top_t *sub_top,
157 re_sub_match_last_t *sub_last, 132 re_sub_match_last_t *sub_last,
158 Idx bkref_node, Idx bkref_str) 133 Idx bkref_node, Idx bkref_str);
159 internal_function;
160static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, 134static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
161 Idx subexp_idx, int type) internal_function; 135 Idx subexp_idx, int type);
162static reg_errcode_t check_arrival (re_match_context_t *mctx, 136static reg_errcode_t check_arrival (re_match_context_t *mctx,
163 state_array_t *path, Idx top_node, 137 state_array_t *path, Idx top_node,
164 Idx top_str, Idx last_node, Idx last_str, 138 Idx top_str, Idx last_node, Idx last_str,
165 int type) internal_function; 139 int type);
166static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, 140static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
167 Idx str_idx, 141 Idx str_idx,
168 re_node_set *cur_nodes, 142 re_node_set *cur_nodes,
169 re_node_set *next_nodes) 143 re_node_set *next_nodes);
170 internal_function;
171static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, 144static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
172 re_node_set *cur_nodes, 145 re_node_set *cur_nodes,
173 Idx ex_subexp, int type) 146 Idx ex_subexp, int type);
174 internal_function;
175static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, 147static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
176 re_node_set *dst_nodes, 148 re_node_set *dst_nodes,
177 Idx target, Idx ex_subexp, 149 Idx target, Idx ex_subexp,
178 int type) internal_function; 150 int type);
179static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, 151static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
180 re_node_set *cur_nodes, Idx cur_str, 152 re_node_set *cur_nodes, Idx cur_str,
181 Idx subexp_num, int type) 153 Idx subexp_num, int type);
182 internal_function; 154static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state);
183static bool build_trtable (const re_dfa_t *dfa,
184 re_dfastate_t *state) internal_function;
185#ifdef RE_ENABLE_I18N
186static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, 155static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
187 const re_string_t *input, Idx idx) 156 const re_string_t *input, Idx idx);
188 internal_function; 157#ifdef _LIBC
189# ifdef _LIBC
190static unsigned int find_collation_sequence_value (const unsigned char *mbs, 158static unsigned int find_collation_sequence_value (const unsigned char *mbs,
191 size_t name_len) 159 size_t name_len);
192 internal_function; 160#endif
193# endif /* _LIBC */
194#endif /* RE_ENABLE_I18N */
195static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa, 161static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
196 const re_dfastate_t *state, 162 const re_dfastate_t *state,
197 re_node_set *states_node, 163 re_node_set *states_node,
198 bitset_t *states_ch) internal_function; 164 bitset_t *states_ch);
199static bool check_node_accept (const re_match_context_t *mctx, 165static bool check_node_accept (const re_match_context_t *mctx,
200 const re_token_t *node, Idx idx) 166 const re_token_t *node, Idx idx);
201 internal_function; 167static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
202static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
203 internal_function;
204 168
205/* Entry point for POSIX code. */ 169/* Entry point for POSIX code. */
206 170
@@ -216,15 +180,12 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
216 REG_NOTBOL is set, then ^ does not match at the beginning of the 180 REG_NOTBOL is set, then ^ does not match at the beginning of the
217 string; if REG_NOTEOL is set, then $ does not match at the end. 181 string; if REG_NOTEOL is set, then $ does not match at the end.
218 182
219 We return 0 if we find a match and REG_NOMATCH if not. */ 183 Return 0 if a match is found, REG_NOMATCH if not, REG_BADPAT if
184 EFLAGS is invalid. */
220 185
221int 186int
222regexec (preg, string, nmatch, pmatch, eflags) 187regexec (const regex_t *__restrict preg, const char *__restrict string,
223 const regex_t *_Restrict_ preg; 188 size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
224 const char *_Restrict_ string;
225 size_t nmatch;
226 regmatch_t pmatch[_Restrict_arr_];
227 int eflags;
228{ 189{
229 reg_errcode_t err; 190 reg_errcode_t err;
230 Idx start, length; 191 Idx start, length;
@@ -256,6 +217,8 @@ regexec (preg, string, nmatch, pmatch, eflags)
256} 217}
257 218
258#ifdef _LIBC 219#ifdef _LIBC
220libc_hidden_def (__regexec)
221
259# include <shlib-compat.h> 222# include <shlib-compat.h>
260versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4); 223versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
261 224
@@ -264,9 +227,9 @@ __typeof__ (__regexec) __compat_regexec;
264 227
265int 228int
266attribute_compat_text_section 229attribute_compat_text_section
267__compat_regexec (const regex_t *_Restrict_ preg, 230__compat_regexec (const regex_t *__restrict preg,
268 const char *_Restrict_ string, size_t nmatch, 231 const char *__restrict string, size_t nmatch,
269 regmatch_t pmatch[], int eflags) 232 regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
270{ 233{
271 return regexec (preg, string, nmatch, pmatch, 234 return regexec (preg, string, nmatch, pmatch,
272 eflags & (REG_NOTBOL | REG_NOTEOL)); 235 eflags & (REG_NOTBOL | REG_NOTEOL));
@@ -301,15 +264,12 @@ compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
301 strings.) 264 strings.)
302 265
303 On success, re_match* functions return the length of the match, re_search* 266 On success, re_match* functions return the length of the match, re_search*
304 return the position of the start of the match. Return value -1 means no 267 return the position of the start of the match. They return -1 on
305 match was found and -2 indicates an internal error. */ 268 match failure, -2 on error. */
306 269
307regoff_t 270regoff_t
308re_match (bufp, string, length, start, regs) 271re_match (struct re_pattern_buffer *bufp, const char *string, Idx length,
309 struct re_pattern_buffer *bufp; 272 Idx start, struct re_registers *regs)
310 const char *string;
311 Idx length, start;
312 struct re_registers *regs;
313{ 273{
314 return re_search_stub (bufp, string, length, start, 0, length, regs, true); 274 return re_search_stub (bufp, string, length, start, 0, length, regs, true);
315} 275}
@@ -318,12 +278,8 @@ weak_alias (__re_match, re_match)
318#endif 278#endif
319 279
320regoff_t 280regoff_t
321re_search (bufp, string, length, start, range, regs) 281re_search (struct re_pattern_buffer *bufp, const char *string, Idx length,
322 struct re_pattern_buffer *bufp; 282 Idx start, regoff_t range, struct re_registers *regs)
323 const char *string;
324 Idx length, start;
325 regoff_t range;
326 struct re_registers *regs;
327{ 283{
328 return re_search_stub (bufp, string, length, start, range, length, regs, 284 return re_search_stub (bufp, string, length, start, range, length, regs,
329 false); 285 false);
@@ -333,11 +289,9 @@ weak_alias (__re_search, re_search)
333#endif 289#endif
334 290
335regoff_t 291regoff_t
336re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop) 292re_match_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
337 struct re_pattern_buffer *bufp; 293 const char *string2, Idx length2, Idx start,
338 const char *string1, *string2; 294 struct re_registers *regs, Idx stop)
339 Idx length1, length2, start, stop;
340 struct re_registers *regs;
341{ 295{
342 return re_search_2_stub (bufp, string1, length1, string2, length2, 296 return re_search_2_stub (bufp, string1, length1, string2, length2,
343 start, 0, regs, stop, true); 297 start, 0, regs, stop, true);
@@ -347,12 +301,9 @@ weak_alias (__re_match_2, re_match_2)
347#endif 301#endif
348 302
349regoff_t 303regoff_t
350re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop) 304re_search_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
351 struct re_pattern_buffer *bufp; 305 const char *string2, Idx length2, Idx start, regoff_t range,
352 const char *string1, *string2; 306 struct re_registers *regs, Idx stop)
353 Idx length1, length2, start, stop;
354 regoff_t range;
355 struct re_registers *regs;
356{ 307{
357 return re_search_2_stub (bufp, string1, length1, string2, length2, 308 return re_search_2_stub (bufp, string1, length1, string2, length2,
358 start, range, regs, stop, false); 309 start, range, regs, stop, false);
@@ -362,18 +313,18 @@ weak_alias (__re_search_2, re_search_2)
362#endif 313#endif
363 314
364static regoff_t 315static regoff_t
365re_search_2_stub (struct re_pattern_buffer *bufp, 316re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
366 const char *string1, Idx length1, 317 Idx length1, const char *string2, Idx length2, Idx start,
367 const char *string2, Idx length2, 318 regoff_t range, struct re_registers *regs,
368 Idx start, regoff_t range, struct re_registers *regs,
369 Idx stop, bool ret_len) 319 Idx stop, bool ret_len)
370{ 320{
371 const char *str; 321 const char *str;
372 regoff_t rval; 322 regoff_t rval;
373 Idx len = length1 + length2; 323 Idx len;
374 char *s = NULL; 324 char *s = NULL;
375 325
376 if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) 326 if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
327 || INT_ADD_WRAPV (length1, length2, &len))))
377 return -2; 328 return -2;
378 329
379 /* Concatenate the strings. */ 330 /* Concatenate the strings. */
@@ -382,7 +333,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
382 { 333 {
383 s = re_malloc (char, len); 334 s = re_malloc (char, len);
384 335
385 if (BE (s == NULL, 0)) 336 if (__glibc_unlikely (s == NULL))
386 return -2; 337 return -2;
387#ifdef _LIBC 338#ifdef _LIBC
388 memcpy (__mempcpy (s, string1, length1), string2, length2); 339 memcpy (__mempcpy (s, string1, length1), string2, length2);
@@ -409,8 +360,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
409 otherwise the position of the match is returned. */ 360 otherwise the position of the match is returned. */
410 361
411static regoff_t 362static regoff_t
412re_search_stub (struct re_pattern_buffer *bufp, 363re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
413 const char *string, Idx length,
414 Idx start, regoff_t range, Idx stop, struct re_registers *regs, 364 Idx start, regoff_t range, Idx stop, struct re_registers *regs,
415 bool ret_len) 365 bool ret_len)
416{ 366{
@@ -423,11 +373,13 @@ re_search_stub (struct re_pattern_buffer *bufp,
423 Idx last_start = start + range; 373 Idx last_start = start + range;
424 374
425 /* Check for out-of-range. */ 375 /* Check for out-of-range. */
426 if (BE (start < 0 || start > length, 0)) 376 if (__glibc_unlikely (start < 0 || start > length))
427 return -1; 377 return -1;
428 if (BE (length < last_start || (0 <= range && last_start < start), 0)) 378 if (__glibc_unlikely (length < last_start
379 || (0 <= range && last_start < start)))
429 last_start = length; 380 last_start = length;
430 else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) 381 else if (__glibc_unlikely (last_start < 0
382 || (range < 0 && start <= last_start)))
431 last_start = 0; 383 last_start = 0;
432 384
433 lock_lock (dfa->lock); 385 lock_lock (dfa->lock);
@@ -439,17 +391,17 @@ re_search_stub (struct re_pattern_buffer *bufp,
439 if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate) 391 if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate)
440 re_compile_fastmap (bufp); 392 re_compile_fastmap (bufp);
441 393
442 if (BE (bufp->no_sub, 0)) 394 if (__glibc_unlikely (bufp->no_sub))
443 regs = NULL; 395 regs = NULL;
444 396
445 /* We need at least 1 register. */ 397 /* We need at least 1 register. */
446 if (regs == NULL) 398 if (regs == NULL)
447 nregs = 1; 399 nregs = 1;
448 else if (BE (bufp->regs_allocated == REGS_FIXED 400 else if (__glibc_unlikely (bufp->regs_allocated == REGS_FIXED
449 && regs->num_regs <= bufp->re_nsub, 0)) 401 && regs->num_regs <= bufp->re_nsub))
450 { 402 {
451 nregs = regs->num_regs; 403 nregs = regs->num_regs;
452 if (BE (nregs < 1, 0)) 404 if (__glibc_unlikely (nregs < 1))
453 { 405 {
454 /* Nothing can be copied to regs. */ 406 /* Nothing can be copied to regs. */
455 regs = NULL; 407 regs = NULL;
@@ -459,7 +411,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
459 else 411 else
460 nregs = bufp->re_nsub + 1; 412 nregs = bufp->re_nsub + 1;
461 pmatch = re_malloc (regmatch_t, nregs); 413 pmatch = re_malloc (regmatch_t, nregs);
462 if (BE (pmatch == NULL, 0)) 414 if (__glibc_unlikely (pmatch == NULL))
463 { 415 {
464 rval = -2; 416 rval = -2;
465 goto out; 417 goto out;
@@ -478,15 +430,15 @@ re_search_stub (struct re_pattern_buffer *bufp,
478 /* If caller wants register contents data back, copy them. */ 430 /* If caller wants register contents data back, copy them. */
479 bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, 431 bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
480 bufp->regs_allocated); 432 bufp->regs_allocated);
481 if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0)) 433 if (__glibc_unlikely (bufp->regs_allocated == REGS_UNALLOCATED))
482 rval = -2; 434 rval = -2;
483 } 435 }
484 436
485 if (BE (rval == 0, 1)) 437 if (__glibc_likely (rval == 0))
486 { 438 {
487 if (ret_len) 439 if (ret_len)
488 { 440 {
489 assert (pmatch[0].rm_so == start); 441 DEBUG_ASSERT (pmatch[0].rm_so == start);
490 rval = pmatch[0].rm_eo - start; 442 rval = pmatch[0].rm_eo - start;
491 } 443 }
492 else 444 else
@@ -512,10 +464,10 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
512 if (regs_allocated == REGS_UNALLOCATED) 464 if (regs_allocated == REGS_UNALLOCATED)
513 { /* No. So allocate them with malloc. */ 465 { /* No. So allocate them with malloc. */
514 regs->start = re_malloc (regoff_t, need_regs); 466 regs->start = re_malloc (regoff_t, need_regs);
515 if (BE (regs->start == NULL, 0)) 467 if (__glibc_unlikely (regs->start == NULL))
516 return REGS_UNALLOCATED; 468 return REGS_UNALLOCATED;
517 regs->end = re_malloc (regoff_t, need_regs); 469 regs->end = re_malloc (regoff_t, need_regs);
518 if (BE (regs->end == NULL, 0)) 470 if (__glibc_unlikely (regs->end == NULL))
519 { 471 {
520 re_free (regs->start); 472 re_free (regs->start);
521 return REGS_UNALLOCATED; 473 return REGS_UNALLOCATED;
@@ -526,14 +478,14 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
526 { /* Yes. If we need more elements than were already 478 { /* Yes. If we need more elements than were already
527 allocated, reallocate them. If we need fewer, just 479 allocated, reallocate them. If we need fewer, just
528 leave it alone. */ 480 leave it alone. */
529 if (BE (need_regs > regs->num_regs, 0)) 481 if (__glibc_unlikely (need_regs > regs->num_regs))
530 { 482 {
531 regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); 483 regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
532 regoff_t *new_end; 484 regoff_t *new_end;
533 if (BE (new_start == NULL, 0)) 485 if (__glibc_unlikely (new_start == NULL))
534 return REGS_UNALLOCATED; 486 return REGS_UNALLOCATED;
535 new_end = re_realloc (regs->end, regoff_t, need_regs); 487 new_end = re_realloc (regs->end, regoff_t, need_regs);
536 if (BE (new_end == NULL, 0)) 488 if (__glibc_unlikely (new_end == NULL))
537 { 489 {
538 re_free (new_start); 490 re_free (new_start);
539 return REGS_UNALLOCATED; 491 return REGS_UNALLOCATED;
@@ -545,9 +497,9 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
545 } 497 }
546 else 498 else
547 { 499 {
548 assert (regs_allocated == REGS_FIXED); 500 DEBUG_ASSERT (regs_allocated == REGS_FIXED);
549 /* This function may not be called with REGS_FIXED and nregs too big. */ 501 /* This function may not be called with REGS_FIXED and nregs too big. */
550 assert (regs->num_regs >= nregs); 502 DEBUG_ASSERT (nregs <= regs->num_regs);
551 rval = REGS_FIXED; 503 rval = REGS_FIXED;
552 } 504 }
553 505
@@ -577,11 +529,8 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
577 freeing the old data. */ 529 freeing the old data. */
578 530
579void 531void
580re_set_registers (bufp, regs, num_regs, starts, ends) 532re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
581 struct re_pattern_buffer *bufp; 533 __re_size_t num_regs, regoff_t *starts, regoff_t *ends)
582 struct re_registers *regs;
583 __re_size_t num_regs;
584 regoff_t *starts, *ends;
585{ 534{
586 if (num_regs) 535 if (num_regs)
587 { 536 {
@@ -609,8 +558,7 @@ int
609# ifdef _LIBC 558# ifdef _LIBC
610weak_function 559weak_function
611# endif 560# endif
612re_exec (s) 561re_exec (const char *s)
613 const char *s;
614{ 562{
615 return 0 == regexec (&re_comp_buf, s, 0, NULL, 0); 563 return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
616} 564}
@@ -629,11 +577,9 @@ re_exec (s)
629 577
630static reg_errcode_t 578static reg_errcode_t
631__attribute_warn_unused_result__ 579__attribute_warn_unused_result__
632re_search_internal (const regex_t *preg, 580re_search_internal (const regex_t *preg, const char *string, Idx length,
633 const char *string, Idx length, 581 Idx start, Idx last_start, Idx stop, size_t nmatch,
634 Idx start, Idx last_start, Idx stop, 582 regmatch_t pmatch[], int eflags)
635 size_t nmatch, regmatch_t pmatch[],
636 int eflags)
637{ 583{
638 reg_errcode_t err; 584 reg_errcode_t err;
639 const re_dfa_t *dfa = preg->buffer; 585 const re_dfa_t *dfa = preg->buffer;
@@ -642,38 +588,28 @@ re_search_internal (const regex_t *preg,
642 bool fl_longest_match; 588 bool fl_longest_match;
643 int match_kind; 589 int match_kind;
644 Idx match_first; 590 Idx match_first;
645 Idx match_last = REG_MISSING; 591 Idx match_last = -1;
646 Idx extra_nmatch; 592 Idx extra_nmatch;
647 bool sb; 593 bool sb;
648 int ch; 594 int ch;
649#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
650 re_match_context_t mctx = { .dfa = dfa }; 595 re_match_context_t mctx = { .dfa = dfa };
651#else
652 re_match_context_t mctx;
653#endif
654 char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate 596 char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate
655 && start != last_start && !preg->can_be_null) 597 && start != last_start && !preg->can_be_null)
656 ? preg->fastmap : NULL); 598 ? preg->fastmap : NULL);
657 RE_TRANSLATE_TYPE t = preg->translate; 599 RE_TRANSLATE_TYPE t = preg->translate;
658 600
659#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
660 memset (&mctx, '\0', sizeof (re_match_context_t));
661 mctx.dfa = dfa;
662#endif
663
664 extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; 601 extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
665 nmatch -= extra_nmatch; 602 nmatch -= extra_nmatch;
666 603
667 /* Check if the DFA haven't been compiled. */ 604 /* Check if the DFA haven't been compiled. */
668 if (BE (preg->used == 0 || dfa->init_state == NULL 605 if (__glibc_unlikely (preg->used == 0 || dfa->init_state == NULL
669 || dfa->init_state_word == NULL || dfa->init_state_nl == NULL 606 || dfa->init_state_word == NULL
670 || dfa->init_state_begbuf == NULL, 0)) 607 || dfa->init_state_nl == NULL
608 || dfa->init_state_begbuf == NULL))
671 return REG_NOMATCH; 609 return REG_NOMATCH;
672 610
673#ifdef DEBUG
674 /* We assume front-end functions already check them. */ 611 /* We assume front-end functions already check them. */
675 assert (0 <= last_start && last_start <= length); 612 DEBUG_ASSERT (0 <= last_start && last_start <= length);
676#endif
677 613
678 /* If initial states with non-begbuf contexts have no elements, 614 /* If initial states with non-begbuf contexts have no elements,
679 the regex must be anchored. If preg->newline_anchor is set, 615 the regex must be anchored. If preg->newline_anchor is set,
@@ -694,14 +630,14 @@ re_search_internal (const regex_t *preg,
694 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, 630 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
695 preg->translate, (preg->syntax & RE_ICASE) != 0, 631 preg->translate, (preg->syntax & RE_ICASE) != 0,
696 dfa); 632 dfa);
697 if (BE (err != REG_NOERROR, 0)) 633 if (__glibc_unlikely (err != REG_NOERROR))
698 goto free_return; 634 goto free_return;
699 mctx.input.stop = stop; 635 mctx.input.stop = stop;
700 mctx.input.raw_stop = stop; 636 mctx.input.raw_stop = stop;
701 mctx.input.newline_anchor = preg->newline_anchor; 637 mctx.input.newline_anchor = preg->newline_anchor;
702 638
703 err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); 639 err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
704 if (BE (err != REG_NOERROR, 0)) 640 if (__glibc_unlikely (err != REG_NOERROR))
705 goto free_return; 641 goto free_return;
706 642
707 /* We will log all the DFA states through which the dfa pass, 643 /* We will log all the DFA states through which the dfa pass,
@@ -711,22 +647,20 @@ re_search_internal (const regex_t *preg,
711 if (nmatch > 1 || dfa->has_mb_node) 647 if (nmatch > 1 || dfa->has_mb_node)
712 { 648 {
713 /* Avoid overflow. */ 649 /* Avoid overflow. */
714 if (BE ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) 650 if (__glibc_unlikely ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
715 <= mctx.input.bufs_len), 0)) 651 <= mctx.input.bufs_len)))
716 { 652 {
717 err = REG_ESPACE; 653 err = REG_ESPACE;
718 goto free_return; 654 goto free_return;
719 } 655 }
720 656
721 mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); 657 mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
722 if (BE (mctx.state_log == NULL, 0)) 658 if (__glibc_unlikely (mctx.state_log == NULL))
723 { 659 {
724 err = REG_ESPACE; 660 err = REG_ESPACE;
725 goto free_return; 661 goto free_return;
726 } 662 }
727 } 663 }
728 else
729 mctx.state_log = NULL;
730 664
731 match_first = start; 665 match_first = start;
732 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF 666 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
@@ -763,19 +697,19 @@ re_search_internal (const regex_t *preg,
763 697
764 case 7: 698 case 7:
765 /* Fastmap with single-byte translation, match forward. */ 699 /* Fastmap with single-byte translation, match forward. */
766 while (BE (match_first < right_lim, 1) 700 while (__glibc_likely (match_first < right_lim)
767 && !fastmap[t[(unsigned char) string[match_first]]]) 701 && !fastmap[t[(unsigned char) string[match_first]]])
768 ++match_first; 702 ++match_first;
769 goto forward_match_found_start_or_reached_end; 703 goto forward_match_found_start_or_reached_end;
770 704
771 case 6: 705 case 6:
772 /* Fastmap without translation, match forward. */ 706 /* Fastmap without translation, match forward. */
773 while (BE (match_first < right_lim, 1) 707 while (__glibc_likely (match_first < right_lim)
774 && !fastmap[(unsigned char) string[match_first]]) 708 && !fastmap[(unsigned char) string[match_first]])
775 ++match_first; 709 ++match_first;
776 710
777 forward_match_found_start_or_reached_end: 711 forward_match_found_start_or_reached_end:
778 if (BE (match_first == right_lim, 0)) 712 if (__glibc_unlikely (match_first == right_lim))
779 { 713 {
780 ch = match_first >= length 714 ch = match_first >= length
781 ? 0 : (unsigned char) string[match_first]; 715 ? 0 : (unsigned char) string[match_first];
@@ -808,19 +742,19 @@ re_search_internal (const regex_t *preg,
808 /* If MATCH_FIRST is out of the valid range, reconstruct the 742 /* If MATCH_FIRST is out of the valid range, reconstruct the
809 buffers. */ 743 buffers. */
810 __re_size_t offset = match_first - mctx.input.raw_mbs_idx; 744 __re_size_t offset = match_first - mctx.input.raw_mbs_idx;
811 if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0)) 745 if (__glibc_unlikely (offset
746 >= (__re_size_t) mctx.input.valid_raw_len))
812 { 747 {
813 err = re_string_reconstruct (&mctx.input, match_first, 748 err = re_string_reconstruct (&mctx.input, match_first,
814 eflags); 749 eflags);
815 if (BE (err != REG_NOERROR, 0)) 750 if (__glibc_unlikely (err != REG_NOERROR))
816 goto free_return; 751 goto free_return;
817 752
818 offset = match_first - mctx.input.raw_mbs_idx; 753 offset = match_first - mctx.input.raw_mbs_idx;
819 } 754 }
820 /* If MATCH_FIRST is out of the buffer, leave it as '\0'. 755 /* Use buffer byte if OFFSET is in buffer, otherwise '\0'. */
821 Note that MATCH_FIRST must not be smaller than 0. */ 756 ch = (offset < mctx.input.valid_len
822 ch = (match_first >= length 757 ? re_string_byte_at (&mctx.input, offset) : 0);
823 ? 0 : re_string_byte_at (&mctx.input, offset));
824 if (fastmap[ch]) 758 if (fastmap[ch])
825 break; 759 break;
826 match_first += incr; 760 match_first += incr;
@@ -836,24 +770,22 @@ re_search_internal (const regex_t *preg,
836 /* Reconstruct the buffers so that the matcher can assume that 770 /* Reconstruct the buffers so that the matcher can assume that
837 the matching starts from the beginning of the buffer. */ 771 the matching starts from the beginning of the buffer. */
838 err = re_string_reconstruct (&mctx.input, match_first, eflags); 772 err = re_string_reconstruct (&mctx.input, match_first, eflags);
839 if (BE (err != REG_NOERROR, 0)) 773 if (__glibc_unlikely (err != REG_NOERROR))
840 goto free_return; 774 goto free_return;
841 775
842#ifdef RE_ENABLE_I18N 776 /* Don't consider this char as a possible match start if it part,
843 /* Don't consider this char as a possible match start if it part, 777 yet isn't the head, of a multibyte character. */
844 yet isn't the head, of a multibyte character. */
845 if (!sb && !re_string_first_byte (&mctx.input, 0)) 778 if (!sb && !re_string_first_byte (&mctx.input, 0))
846 continue; 779 continue;
847#endif
848 780
849 /* It seems to be appropriate one, then use the matcher. */ 781 /* It seems to be appropriate one, then use the matcher. */
850 /* We assume that the matching starts from 0. */ 782 /* We assume that the matching starts from 0. */
851 mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; 783 mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
852 match_last = check_matching (&mctx, fl_longest_match, 784 match_last = check_matching (&mctx, fl_longest_match,
853 start <= last_start ? &match_first : NULL); 785 start <= last_start ? &match_first : NULL);
854 if (match_last != REG_MISSING) 786 if (match_last != -1)
855 { 787 {
856 if (BE (match_last == REG_ERROR, 0)) 788 if (__glibc_unlikely (match_last == -2))
857 { 789 {
858 err = REG_ESPACE; 790 err = REG_ESPACE;
859 goto free_return; 791 goto free_return;
@@ -873,9 +805,9 @@ re_search_internal (const regex_t *preg,
873 err = prune_impossible_nodes (&mctx); 805 err = prune_impossible_nodes (&mctx);
874 if (err == REG_NOERROR) 806 if (err == REG_NOERROR)
875 break; 807 break;
876 if (BE (err != REG_NOMATCH, 0)) 808 if (__glibc_unlikely (err != REG_NOMATCH))
877 goto free_return; 809 goto free_return;
878 match_last = REG_MISSING; 810 match_last = -1;
879 } 811 }
880 else 812 else
881 break; /* We found a match. */ 813 break; /* We found a match. */
@@ -885,10 +817,8 @@ re_search_internal (const regex_t *preg,
885 match_ctx_clean (&mctx); 817 match_ctx_clean (&mctx);
886 } 818 }
887 819
888#ifdef DEBUG 820 DEBUG_ASSERT (match_last != -1);
889 assert (match_last != REG_MISSING); 821 DEBUG_ASSERT (err == REG_NOERROR);
890 assert (err == REG_NOERROR);
891#endif
892 822
893 /* Set pmatch[] if we need. */ 823 /* Set pmatch[] if we need. */
894 if (nmatch > 0) 824 if (nmatch > 0)
@@ -910,7 +840,7 @@ re_search_internal (const regex_t *preg,
910 { 840 {
911 err = set_regs (preg, &mctx, nmatch, pmatch, 841 err = set_regs (preg, &mctx, nmatch, pmatch,
912 dfa->has_plural_match && dfa->nbackref > 0); 842 dfa->has_plural_match && dfa->nbackref > 0);
913 if (BE (err != REG_NOERROR, 0)) 843 if (__glibc_unlikely (err != REG_NOERROR))
914 goto free_return; 844 goto free_return;
915 } 845 }
916 846
@@ -920,8 +850,7 @@ re_search_internal (const regex_t *preg,
920 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) 850 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
921 if (pmatch[reg_idx].rm_so != -1) 851 if (pmatch[reg_idx].rm_so != -1)
922 { 852 {
923#ifdef RE_ENABLE_I18N 853 if (__glibc_unlikely (mctx.input.offsets_needed != 0))
924 if (BE (mctx.input.offsets_needed != 0, 0))
925 { 854 {
926 pmatch[reg_idx].rm_so = 855 pmatch[reg_idx].rm_so =
927 (pmatch[reg_idx].rm_so == mctx.input.valid_len 856 (pmatch[reg_idx].rm_so == mctx.input.valid_len
@@ -932,9 +861,6 @@ re_search_internal (const regex_t *preg,
932 ? mctx.input.valid_raw_len 861 ? mctx.input.valid_raw_len
933 : mctx.input.offsets[pmatch[reg_idx].rm_eo]); 862 : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
934 } 863 }
935#else
936 assert (mctx.input.offsets_needed == 0);
937#endif
938 pmatch[reg_idx].rm_so += match_first; 864 pmatch[reg_idx].rm_so += match_first;
939 pmatch[reg_idx].rm_eo += match_first; 865 pmatch[reg_idx].rm_eo += match_first;
940 } 866 }
@@ -973,18 +899,17 @@ prune_impossible_nodes (re_match_context_t *mctx)
973 re_dfastate_t **sifted_states; 899 re_dfastate_t **sifted_states;
974 re_dfastate_t **lim_states = NULL; 900 re_dfastate_t **lim_states = NULL;
975 re_sift_context_t sctx; 901 re_sift_context_t sctx;
976#ifdef DEBUG 902 DEBUG_ASSERT (mctx->state_log != NULL);
977 assert (mctx->state_log != NULL);
978#endif
979 match_last = mctx->match_last; 903 match_last = mctx->match_last;
980 halt_node = mctx->last_node; 904 halt_node = mctx->last_node;
981 905
982 /* Avoid overflow. */ 906 /* Avoid overflow. */
983 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= match_last, 0)) 907 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
908 <= match_last))
984 return REG_ESPACE; 909 return REG_ESPACE;
985 910
986 sifted_states = re_malloc (re_dfastate_t *, match_last + 1); 911 sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
987 if (BE (sifted_states == NULL, 0)) 912 if (__glibc_unlikely (sifted_states == NULL))
988 { 913 {
989 ret = REG_ESPACE; 914 ret = REG_ESPACE;
990 goto free_return; 915 goto free_return;
@@ -992,7 +917,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
992 if (dfa->nbackref) 917 if (dfa->nbackref)
993 { 918 {
994 lim_states = re_malloc (re_dfastate_t *, match_last + 1); 919 lim_states = re_malloc (re_dfastate_t *, match_last + 1);
995 if (BE (lim_states == NULL, 0)) 920 if (__glibc_unlikely (lim_states == NULL))
996 { 921 {
997 ret = REG_ESPACE; 922 ret = REG_ESPACE;
998 goto free_return; 923 goto free_return;
@@ -1005,14 +930,14 @@ prune_impossible_nodes (re_match_context_t *mctx)
1005 match_last); 930 match_last);
1006 ret = sift_states_backward (mctx, &sctx); 931 ret = sift_states_backward (mctx, &sctx);
1007 re_node_set_free (&sctx.limits); 932 re_node_set_free (&sctx.limits);
1008 if (BE (ret != REG_NOERROR, 0)) 933 if (__glibc_unlikely (ret != REG_NOERROR))
1009 goto free_return; 934 goto free_return;
1010 if (sifted_states[0] != NULL || lim_states[0] != NULL) 935 if (sifted_states[0] != NULL || lim_states[0] != NULL)
1011 break; 936 break;
1012 do 937 do
1013 { 938 {
1014 --match_last; 939 --match_last;
1015 if (! REG_VALID_INDEX (match_last)) 940 if (match_last < 0)
1016 { 941 {
1017 ret = REG_NOMATCH; 942 ret = REG_NOMATCH;
1018 goto free_return; 943 goto free_return;
@@ -1027,7 +952,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
1027 match_last + 1); 952 match_last + 1);
1028 re_free (lim_states); 953 re_free (lim_states);
1029 lim_states = NULL; 954 lim_states = NULL;
1030 if (BE (ret != REG_NOERROR, 0)) 955 if (__glibc_unlikely (ret != REG_NOERROR))
1031 goto free_return; 956 goto free_return;
1032 } 957 }
1033 else 958 else
@@ -1035,7 +960,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
1035 sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); 960 sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
1036 ret = sift_states_backward (mctx, &sctx); 961 ret = sift_states_backward (mctx, &sctx);
1037 re_node_set_free (&sctx.limits); 962 re_node_set_free (&sctx.limits);
1038 if (BE (ret != REG_NOERROR, 0)) 963 if (__glibc_unlikely (ret != REG_NOERROR))
1039 goto free_return; 964 goto free_return;
1040 if (sifted_states[0] == NULL) 965 if (sifted_states[0] == NULL)
1041 { 966 {
@@ -1059,8 +984,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
1059 We must select appropriate initial state depending on the context, 984 We must select appropriate initial state depending on the context,
1060 since initial states may have constraints like "\<", "^", etc.. */ 985 since initial states may have constraints like "\<", "^", etc.. */
1061 986
1062static inline re_dfastate_t * 987static __always_inline re_dfastate_t *
1063__attribute__ ((always_inline)) internal_function
1064acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, 988acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1065 Idx idx) 989 Idx idx)
1066{ 990{
@@ -1093,8 +1017,8 @@ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1093} 1017}
1094 1018
1095/* Check whether the regular expression match input string INPUT or not, 1019/* Check whether the regular expression match input string INPUT or not,
1096 and return the index where the matching end. Return REG_MISSING if 1020 and return the index where the matching end. Return -1 if
1097 there is no match, and return REG_ERROR in case of an error. 1021 there is no match, and return -2 in case of an error.
1098 FL_LONGEST_MATCH means we want the POSIX longest matching. 1022 FL_LONGEST_MATCH means we want the POSIX longest matching.
1099 If P_MATCH_FIRST is not NULL, and the match fails, it is set to the 1023 If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
1100 next place where we may want to try matching. 1024 next place where we may want to try matching.
@@ -1102,14 +1026,14 @@ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1102 index of the buffer. */ 1026 index of the buffer. */
1103 1027
1104static Idx 1028static Idx
1105internal_function __attribute_warn_unused_result__ 1029__attribute_warn_unused_result__
1106check_matching (re_match_context_t *mctx, bool fl_longest_match, 1030check_matching (re_match_context_t *mctx, bool fl_longest_match,
1107 Idx *p_match_first) 1031 Idx *p_match_first)
1108{ 1032{
1109 const re_dfa_t *const dfa = mctx->dfa; 1033 const re_dfa_t *const dfa = mctx->dfa;
1110 reg_errcode_t err; 1034 reg_errcode_t err;
1111 Idx match = 0; 1035 Idx match = 0;
1112 Idx match_last = REG_MISSING; 1036 Idx match_last = -1;
1113 Idx cur_str_idx = re_string_cur_idx (&mctx->input); 1037 Idx cur_str_idx = re_string_cur_idx (&mctx->input);
1114 re_dfastate_t *cur_state; 1038 re_dfastate_t *cur_state;
1115 bool at_init_state = p_match_first != NULL; 1039 bool at_init_state = p_match_first != NULL;
@@ -1118,10 +1042,10 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1118 err = REG_NOERROR; 1042 err = REG_NOERROR;
1119 cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); 1043 cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
1120 /* An initial state must not be NULL (invalid). */ 1044 /* An initial state must not be NULL (invalid). */
1121 if (BE (cur_state == NULL, 0)) 1045 if (__glibc_unlikely (cur_state == NULL))
1122 { 1046 {
1123 assert (err == REG_ESPACE); 1047 DEBUG_ASSERT (err == REG_ESPACE);
1124 return REG_ERROR; 1048 return -2;
1125 } 1049 }
1126 1050
1127 if (mctx->state_log != NULL) 1051 if (mctx->state_log != NULL)
@@ -1130,24 +1054,24 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1130 1054
1131 /* Check OP_OPEN_SUBEXP in the initial state in case that we use them 1055 /* Check OP_OPEN_SUBEXP in the initial state in case that we use them
1132 later. E.g. Processing back references. */ 1056 later. E.g. Processing back references. */
1133 if (BE (dfa->nbackref, 0)) 1057 if (__glibc_unlikely (dfa->nbackref))
1134 { 1058 {
1135 at_init_state = false; 1059 at_init_state = false;
1136 err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); 1060 err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
1137 if (BE (err != REG_NOERROR, 0)) 1061 if (__glibc_unlikely (err != REG_NOERROR))
1138 return err; 1062 return err;
1139 1063
1140 if (cur_state->has_backref) 1064 if (cur_state->has_backref)
1141 { 1065 {
1142 err = transit_state_bkref (mctx, &cur_state->nodes); 1066 err = transit_state_bkref (mctx, &cur_state->nodes);
1143 if (BE (err != REG_NOERROR, 0)) 1067 if (__glibc_unlikely (err != REG_NOERROR))
1144 return err; 1068 return err;
1145 } 1069 }
1146 } 1070 }
1147 } 1071 }
1148 1072
1149 /* If the RE accepts NULL string. */ 1073 /* If the RE accepts NULL string. */
1150 if (BE (cur_state->halt, 0)) 1074 if (__glibc_unlikely (cur_state->halt))
1151 { 1075 {
1152 if (!cur_state->has_constraint 1076 if (!cur_state->has_constraint
1153 || check_halt_state_context (mctx, cur_state, cur_str_idx)) 1077 || check_halt_state_context (mctx, cur_state, cur_str_idx))
@@ -1167,16 +1091,16 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1167 re_dfastate_t *old_state = cur_state; 1091 re_dfastate_t *old_state = cur_state;
1168 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1; 1092 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
1169 1093
1170 if ((BE (next_char_idx >= mctx->input.bufs_len, 0) 1094 if ((__glibc_unlikely (next_char_idx >= mctx->input.bufs_len)
1171 && mctx->input.bufs_len < mctx->input.len) 1095 && mctx->input.bufs_len < mctx->input.len)
1172 || (BE (next_char_idx >= mctx->input.valid_len, 0) 1096 || (__glibc_unlikely (next_char_idx >= mctx->input.valid_len)
1173 && mctx->input.valid_len < mctx->input.len)) 1097 && mctx->input.valid_len < mctx->input.len))
1174 { 1098 {
1175 err = extend_buffers (mctx, next_char_idx + 1); 1099 err = extend_buffers (mctx, next_char_idx + 1);
1176 if (BE (err != REG_NOERROR, 0)) 1100 if (__glibc_unlikely (err != REG_NOERROR))
1177 { 1101 {
1178 assert (err == REG_ESPACE); 1102 DEBUG_ASSERT (err == REG_ESPACE);
1179 return REG_ERROR; 1103 return -2;
1180 } 1104 }
1181 } 1105 }
1182 1106
@@ -1189,8 +1113,8 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1189 /* Reached the invalid state or an error. Try to recover a valid 1113 /* Reached the invalid state or an error. Try to recover a valid
1190 state using the state log, if available and if we have not 1114 state using the state log, if available and if we have not
1191 already found a valid (even if not the longest) match. */ 1115 already found a valid (even if not the longest) match. */
1192 if (BE (err != REG_NOERROR, 0)) 1116 if (__glibc_unlikely (err != REG_NOERROR))
1193 return REG_ERROR; 1117 return -2;
1194 1118
1195 if (mctx->state_log == NULL 1119 if (mctx->state_log == NULL
1196 || (match && !fl_longest_match) 1120 || (match && !fl_longest_match)
@@ -1198,7 +1122,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1198 break; 1122 break;
1199 } 1123 }
1200 1124
1201 if (BE (at_init_state, 0)) 1125 if (__glibc_unlikely (at_init_state))
1202 { 1126 {
1203 if (old_state == cur_state) 1127 if (old_state == cur_state)
1204 next_start_idx = next_char_idx; 1128 next_start_idx = next_char_idx;
@@ -1235,7 +1159,6 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1235/* Check NODE match the current context. */ 1159/* Check NODE match the current context. */
1236 1160
1237static bool 1161static bool
1238internal_function
1239check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context) 1162check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
1240{ 1163{
1241 re_token_type_t type = dfa->nodes[node].type; 1164 re_token_type_t type = dfa->nodes[node].type;
@@ -1254,15 +1177,12 @@ check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
1254 match the context, return the node. */ 1177 match the context, return the node. */
1255 1178
1256static Idx 1179static Idx
1257internal_function
1258check_halt_state_context (const re_match_context_t *mctx, 1180check_halt_state_context (const re_match_context_t *mctx,
1259 const re_dfastate_t *state, Idx idx) 1181 const re_dfastate_t *state, Idx idx)
1260{ 1182{
1261 Idx i; 1183 Idx i;
1262 unsigned int context; 1184 unsigned int context;
1263#ifdef DEBUG 1185 DEBUG_ASSERT (state->halt);
1264 assert (state->halt);
1265#endif
1266 context = re_string_context_at (&mctx->input, idx, mctx->eflags); 1186 context = re_string_context_at (&mctx->input, idx, mctx->eflags);
1267 for (i = 0; i < state->nodes.nelem; ++i) 1187 for (i = 0; i < state->nodes.nelem; ++i)
1268 if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) 1188 if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
@@ -1273,33 +1193,35 @@ check_halt_state_context (const re_match_context_t *mctx,
1273/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA 1193/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA
1274 corresponding to the DFA). 1194 corresponding to the DFA).
1275 Return the destination node, and update EPS_VIA_NODES; 1195 Return the destination node, and update EPS_VIA_NODES;
1276 return REG_MISSING in case of errors. */ 1196 return -1 on match failure, -2 on error. */
1277 1197
1278static Idx 1198static Idx
1279internal_function
1280proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs, 1199proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1200 regmatch_t *prevregs,
1281 Idx *pidx, Idx node, re_node_set *eps_via_nodes, 1201 Idx *pidx, Idx node, re_node_set *eps_via_nodes,
1282 struct re_fail_stack_t *fs) 1202 struct re_fail_stack_t *fs)
1283{ 1203{
1284 const re_dfa_t *const dfa = mctx->dfa; 1204 const re_dfa_t *const dfa = mctx->dfa;
1285 Idx i;
1286 bool ok;
1287 if (IS_EPSILON_NODE (dfa->nodes[node].type)) 1205 if (IS_EPSILON_NODE (dfa->nodes[node].type))
1288 { 1206 {
1289 re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; 1207 re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
1290 re_node_set *edests = &dfa->edests[node]; 1208 re_node_set *edests = &dfa->edests[node];
1291 Idx dest_node; 1209
1292 ok = re_node_set_insert (eps_via_nodes, node); 1210 if (! re_node_set_contains (eps_via_nodes, node))
1293 if (BE (! ok, 0)) 1211 {
1294 return REG_ERROR; 1212 bool ok = re_node_set_insert (eps_via_nodes, node);
1295 /* Pick up a valid destination, or return REG_MISSING if none 1213 if (__glibc_unlikely (! ok))
1296 is found. */ 1214 return -2;
1297 for (dest_node = REG_MISSING, i = 0; i < edests->nelem; ++i) 1215 }
1216
1217 /* Pick a valid destination, or return -1 if none is found. */
1218 Idx dest_node = -1;
1219 for (Idx i = 0; i < edests->nelem; i++)
1298 { 1220 {
1299 Idx candidate = edests->elems[i]; 1221 Idx candidate = edests->elems[i];
1300 if (!re_node_set_contains (cur_nodes, candidate)) 1222 if (!re_node_set_contains (cur_nodes, candidate))
1301 continue; 1223 continue;
1302 if (dest_node == REG_MISSING) 1224 if (dest_node == -1)
1303 dest_node = candidate; 1225 dest_node = candidate;
1304 1226
1305 else 1227 else
@@ -1312,8 +1234,8 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1312 /* Otherwise, push the second epsilon-transition on the fail stack. */ 1234 /* Otherwise, push the second epsilon-transition on the fail stack. */
1313 else if (fs != NULL 1235 else if (fs != NULL
1314 && push_fail_stack (fs, *pidx, candidate, nregs, regs, 1236 && push_fail_stack (fs, *pidx, candidate, nregs, regs,
1315 eps_via_nodes)) 1237 prevregs, eps_via_nodes))
1316 return REG_ERROR; 1238 return -2;
1317 1239
1318 /* We know we are going to exit. */ 1240 /* We know we are going to exit. */
1319 break; 1241 break;
@@ -1326,34 +1248,36 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1326 Idx naccepted = 0; 1248 Idx naccepted = 0;
1327 re_token_type_t type = dfa->nodes[node].type; 1249 re_token_type_t type = dfa->nodes[node].type;
1328 1250
1329#ifdef RE_ENABLE_I18N
1330 if (dfa->nodes[node].accept_mb) 1251 if (dfa->nodes[node].accept_mb)
1331 naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); 1252 naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
1332 else 1253 else if (type == OP_BACK_REF)
1333#endif /* RE_ENABLE_I18N */
1334 if (type == OP_BACK_REF)
1335 { 1254 {
1336 Idx subexp_idx = dfa->nodes[node].opr.idx + 1; 1255 Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
1337 naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; 1256 if (subexp_idx < nregs)
1257 naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
1338 if (fs != NULL) 1258 if (fs != NULL)
1339 { 1259 {
1340 if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1) 1260 if (subexp_idx >= nregs
1341 return REG_MISSING; 1261 || regs[subexp_idx].rm_so == -1
1262 || regs[subexp_idx].rm_eo == -1)
1263 return -1;
1342 else if (naccepted) 1264 else if (naccepted)
1343 { 1265 {
1344 char *buf = (char *) re_string_get_buffer (&mctx->input); 1266 char *buf = (char *) re_string_get_buffer (&mctx->input);
1345 if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, 1267 if (mctx->input.valid_len - *pidx < naccepted
1346 naccepted) != 0) 1268 || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
1347 return REG_MISSING; 1269 naccepted)
1270 != 0))
1271 return -1;
1348 } 1272 }
1349 } 1273 }
1350 1274
1351 if (naccepted == 0) 1275 if (naccepted == 0)
1352 { 1276 {
1353 Idx dest_node; 1277 Idx dest_node;
1354 ok = re_node_set_insert (eps_via_nodes, node); 1278 bool ok = re_node_set_insert (eps_via_nodes, node);
1355 if (BE (! ok, 0)) 1279 if (__glibc_unlikely (! ok))
1356 return REG_ERROR; 1280 return -2;
1357 dest_node = dfa->edests[node].elems[0]; 1281 dest_node = dfa->edests[node].elems[0];
1358 if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, 1282 if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
1359 dest_node)) 1283 dest_node))
@@ -1369,26 +1293,27 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1369 if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL 1293 if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
1370 || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, 1294 || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
1371 dest_node))) 1295 dest_node)))
1372 return REG_MISSING; 1296 return -1;
1373 re_node_set_empty (eps_via_nodes); 1297 re_node_set_empty (eps_via_nodes);
1374 return dest_node; 1298 return dest_node;
1375 } 1299 }
1376 } 1300 }
1377 return REG_MISSING; 1301 return -1;
1378} 1302}
1379 1303
1380static reg_errcode_t 1304static reg_errcode_t
1381internal_function __attribute_warn_unused_result__ 1305__attribute_warn_unused_result__
1382push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node, 1306push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
1383 Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes) 1307 Idx nregs, regmatch_t *regs, regmatch_t *prevregs,
1308 re_node_set *eps_via_nodes)
1384{ 1309{
1385 reg_errcode_t err; 1310 reg_errcode_t err;
1386 Idx num = fs->num++; 1311 Idx num = fs->num;
1387 if (fs->num == fs->alloc) 1312 if (num == fs->alloc)
1388 { 1313 {
1389 struct re_fail_stack_ent_t *new_array; 1314 struct re_fail_stack_ent_t *new_array;
1390 new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t) 1315 new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,
1391 * fs->alloc * 2)); 1316 fs->alloc * 2);
1392 if (new_array == NULL) 1317 if (new_array == NULL)
1393 return REG_ESPACE; 1318 return REG_ESPACE;
1394 fs->alloc *= 2; 1319 fs->alloc *= 2;
@@ -1396,36 +1321,47 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
1396 } 1321 }
1397 fs->stack[num].idx = str_idx; 1322 fs->stack[num].idx = str_idx;
1398 fs->stack[num].node = dest_node; 1323 fs->stack[num].node = dest_node;
1399 fs->stack[num].regs = re_malloc (regmatch_t, nregs); 1324 fs->stack[num].regs = re_malloc (regmatch_t, 2 * nregs);
1400 if (fs->stack[num].regs == NULL) 1325 if (fs->stack[num].regs == NULL)
1401 return REG_ESPACE; 1326 return REG_ESPACE;
1327 fs->num = num + 1;
1402 memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); 1328 memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
1329 memcpy (fs->stack[num].regs + nregs, prevregs, sizeof (regmatch_t) * nregs);
1403 err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); 1330 err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
1404 return err; 1331 return err;
1405} 1332}
1406 1333
1407static Idx 1334static Idx
1408internal_function
1409pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs, 1335pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
1410 regmatch_t *regs, re_node_set *eps_via_nodes) 1336 regmatch_t *regs, regmatch_t *prevregs,
1337 re_node_set *eps_via_nodes)
1411{ 1338{
1339 if (fs == NULL || fs->num == 0)
1340 return -1;
1412 Idx num = --fs->num; 1341 Idx num = --fs->num;
1413 assert (REG_VALID_INDEX (num));
1414 *pidx = fs->stack[num].idx; 1342 *pidx = fs->stack[num].idx;
1415 memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); 1343 memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
1344 memcpy (prevregs, fs->stack[num].regs + nregs, sizeof (regmatch_t) * nregs);
1416 re_node_set_free (eps_via_nodes); 1345 re_node_set_free (eps_via_nodes);
1417 re_free (fs->stack[num].regs); 1346 re_free (fs->stack[num].regs);
1418 *eps_via_nodes = fs->stack[num].eps_via_nodes; 1347 *eps_via_nodes = fs->stack[num].eps_via_nodes;
1348 DEBUG_ASSERT (0 <= fs->stack[num].node);
1419 return fs->stack[num].node; 1349 return fs->stack[num].node;
1420} 1350}
1421 1351
1352
1353#define DYNARRAY_STRUCT regmatch_list
1354#define DYNARRAY_ELEMENT regmatch_t
1355#define DYNARRAY_PREFIX regmatch_list_
1356#include <malloc/dynarray-skeleton.c>
1357
1422/* Set the positions where the subexpressions are starts/ends to registers 1358/* Set the positions where the subexpressions are starts/ends to registers
1423 PMATCH. 1359 PMATCH.
1424 Note: We assume that pmatch[0] is already set, and 1360 Note: We assume that pmatch[0] is already set, and
1425 pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */ 1361 pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
1426 1362
1427static reg_errcode_t 1363static reg_errcode_t
1428internal_function __attribute_warn_unused_result__ 1364__attribute_warn_unused_result__
1429set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, 1365set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1430 regmatch_t *pmatch, bool fl_backtrack) 1366 regmatch_t *pmatch, bool fl_backtrack)
1431{ 1367{
@@ -1434,13 +1370,11 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1434 re_node_set eps_via_nodes; 1370 re_node_set eps_via_nodes;
1435 struct re_fail_stack_t *fs; 1371 struct re_fail_stack_t *fs;
1436 struct re_fail_stack_t fs_body = { 0, 2, NULL }; 1372 struct re_fail_stack_t fs_body = { 0, 2, NULL };
1437 regmatch_t *prev_idx_match; 1373 struct regmatch_list prev_match;
1438 bool prev_idx_match_malloced = false; 1374 regmatch_list_init (&prev_match);
1439 1375
1440#ifdef DEBUG 1376 DEBUG_ASSERT (nmatch > 1);
1441 assert (nmatch > 1); 1377 DEBUG_ASSERT (mctx->state_log != NULL);
1442 assert (mctx->state_log != NULL);
1443#endif
1444 if (fl_backtrack) 1378 if (fl_backtrack)
1445 { 1379 {
1446 fs = &fs_body; 1380 fs = &fs_body;
@@ -1454,85 +1388,73 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1454 cur_node = dfa->init_node; 1388 cur_node = dfa->init_node;
1455 re_node_set_init_empty (&eps_via_nodes); 1389 re_node_set_init_empty (&eps_via_nodes);
1456 1390
1457 if (__libc_use_alloca (nmatch * sizeof (regmatch_t))) 1391 if (!regmatch_list_resize (&prev_match, nmatch))
1458 prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t));
1459 else
1460 { 1392 {
1461 prev_idx_match = re_malloc (regmatch_t, nmatch); 1393 regmatch_list_free (&prev_match);
1462 if (prev_idx_match == NULL) 1394 free_fail_stack_return (fs);
1463 { 1395 return REG_ESPACE;
1464 free_fail_stack_return (fs);
1465 return REG_ESPACE;
1466 }
1467 prev_idx_match_malloced = true;
1468 } 1396 }
1397 regmatch_t *prev_idx_match = regmatch_list_begin (&prev_match);
1469 memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); 1398 memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
1470 1399
1471 for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) 1400 for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
1472 { 1401 {
1473 update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); 1402 update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
1474 1403
1475 if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node) 1404 if ((idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
1405 || (fs && re_node_set_contains (&eps_via_nodes, cur_node)))
1476 { 1406 {
1477 Idx reg_idx; 1407 Idx reg_idx;
1408 cur_node = -1;
1478 if (fs) 1409 if (fs)
1479 { 1410 {
1480 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) 1411 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
1481 if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1) 1412 if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
1482 break; 1413 {
1483 if (reg_idx == nmatch) 1414 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
1484 { 1415 prev_idx_match, &eps_via_nodes);
1485 re_node_set_free (&eps_via_nodes); 1416 break;
1486 if (prev_idx_match_malloced) 1417 }
1487 re_free (prev_idx_match);
1488 return free_fail_stack_return (fs);
1489 }
1490 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
1491 &eps_via_nodes);
1492 } 1418 }
1493 else 1419 if (cur_node < 0)
1494 { 1420 {
1495 re_node_set_free (&eps_via_nodes); 1421 re_node_set_free (&eps_via_nodes);
1496 if (prev_idx_match_malloced) 1422 regmatch_list_free (&prev_match);
1497 re_free (prev_idx_match); 1423 return free_fail_stack_return (fs);
1498 return REG_NOERROR;
1499 } 1424 }
1500 } 1425 }
1501 1426
1502 /* Proceed to next node. */ 1427 /* Proceed to next node. */
1503 cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node, 1428 cur_node = proceed_next_node (mctx, nmatch, pmatch, prev_idx_match,
1429 &idx, cur_node,
1504 &eps_via_nodes, fs); 1430 &eps_via_nodes, fs);
1505 1431
1506 if (BE (! REG_VALID_INDEX (cur_node), 0)) 1432 if (__glibc_unlikely (cur_node < 0))
1507 { 1433 {
1508 if (BE (cur_node == REG_ERROR, 0)) 1434 if (__glibc_unlikely (cur_node == -2))
1509 { 1435 {
1510 re_node_set_free (&eps_via_nodes); 1436 re_node_set_free (&eps_via_nodes);
1511 if (prev_idx_match_malloced) 1437 regmatch_list_free (&prev_match);
1512 re_free (prev_idx_match);
1513 free_fail_stack_return (fs); 1438 free_fail_stack_return (fs);
1514 return REG_ESPACE; 1439 return REG_ESPACE;
1515 } 1440 }
1516 if (fs) 1441 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
1517 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, 1442 prev_idx_match, &eps_via_nodes);
1518 &eps_via_nodes); 1443 if (cur_node < 0)
1519 else
1520 { 1444 {
1521 re_node_set_free (&eps_via_nodes); 1445 re_node_set_free (&eps_via_nodes);
1522 if (prev_idx_match_malloced) 1446 regmatch_list_free (&prev_match);
1523 re_free (prev_idx_match); 1447 free_fail_stack_return (fs);
1524 return REG_NOMATCH; 1448 return REG_NOMATCH;
1525 } 1449 }
1526 } 1450 }
1527 } 1451 }
1528 re_node_set_free (&eps_via_nodes); 1452 re_node_set_free (&eps_via_nodes);
1529 if (prev_idx_match_malloced) 1453 regmatch_list_free (&prev_match);
1530 re_free (prev_idx_match);
1531 return free_fail_stack_return (fs); 1454 return free_fail_stack_return (fs);
1532} 1455}
1533 1456
1534static reg_errcode_t 1457static reg_errcode_t
1535internal_function
1536free_fail_stack_return (struct re_fail_stack_t *fs) 1458free_fail_stack_return (struct re_fail_stack_t *fs)
1537{ 1459{
1538 if (fs) 1460 if (fs)
@@ -1549,7 +1471,6 @@ free_fail_stack_return (struct re_fail_stack_t *fs)
1549} 1471}
1550 1472
1551static void 1473static void
1552internal_function
1553update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, 1474update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
1554 regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch) 1475 regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch)
1555{ 1476{
@@ -1567,10 +1488,10 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
1567 } 1488 }
1568 else if (type == OP_CLOSE_SUBEXP) 1489 else if (type == OP_CLOSE_SUBEXP)
1569 { 1490 {
1491 /* We are at the last node of this sub expression. */
1570 Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; 1492 Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
1571 if (reg_num < nmatch) 1493 if (reg_num < nmatch)
1572 { 1494 {
1573 /* We are at the last node of this sub expression. */
1574 if (pmatch[reg_num].rm_so < cur_idx) 1495 if (pmatch[reg_num].rm_so < cur_idx)
1575 { 1496 {
1576 pmatch[reg_num].rm_eo = cur_idx; 1497 pmatch[reg_num].rm_eo = cur_idx;
@@ -1621,7 +1542,6 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
1621 ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) 1542 ((state) != NULL && re_node_set_contains (&(state)->nodes, node))
1622 1543
1623static reg_errcode_t 1544static reg_errcode_t
1624internal_function
1625sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) 1545sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1626{ 1546{
1627 reg_errcode_t err; 1547 reg_errcode_t err;
@@ -1629,17 +1549,15 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1629 Idx str_idx = sctx->last_str_idx; 1549 Idx str_idx = sctx->last_str_idx;
1630 re_node_set cur_dest; 1550 re_node_set cur_dest;
1631 1551
1632#ifdef DEBUG 1552 DEBUG_ASSERT (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
1633 assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
1634#endif
1635 1553
1636 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon 1554 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon
1637 transit to the last_node and the last_node itself. */ 1555 transit to the last_node and the last_node itself. */
1638 err = re_node_set_init_1 (&cur_dest, sctx->last_node); 1556 err = re_node_set_init_1 (&cur_dest, sctx->last_node);
1639 if (BE (err != REG_NOERROR, 0)) 1557 if (__glibc_unlikely (err != REG_NOERROR))
1640 return err; 1558 return err;
1641 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); 1559 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1642 if (BE (err != REG_NOERROR, 0)) 1560 if (__glibc_unlikely (err != REG_NOERROR))
1643 goto free_return; 1561 goto free_return;
1644 1562
1645 /* Then check each states in the state_log. */ 1563 /* Then check each states in the state_log. */
@@ -1660,7 +1578,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1660 if (mctx->state_log[str_idx]) 1578 if (mctx->state_log[str_idx])
1661 { 1579 {
1662 err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); 1580 err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
1663 if (BE (err != REG_NOERROR, 0)) 1581 if (__glibc_unlikely (err != REG_NOERROR))
1664 goto free_return; 1582 goto free_return;
1665 } 1583 }
1666 1584
@@ -1669,7 +1587,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1669 - It is in CUR_SRC. 1587 - It is in CUR_SRC.
1670 And update state_log. */ 1588 And update state_log. */
1671 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); 1589 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1672 if (BE (err != REG_NOERROR, 0)) 1590 if (__glibc_unlikely (err != REG_NOERROR))
1673 goto free_return; 1591 goto free_return;
1674 } 1592 }
1675 err = REG_NOERROR; 1593 err = REG_NOERROR;
@@ -1679,7 +1597,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1679} 1597}
1680 1598
1681static reg_errcode_t 1599static reg_errcode_t
1682internal_function __attribute_warn_unused_result__ 1600__attribute_warn_unused_result__
1683build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, 1601build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1684 Idx str_idx, re_node_set *cur_dest) 1602 Idx str_idx, re_node_set *cur_dest)
1685{ 1603{
@@ -1699,17 +1617,12 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1699 Idx prev_node = cur_src->elems[i]; 1617 Idx prev_node = cur_src->elems[i];
1700 int naccepted = 0; 1618 int naccepted = 0;
1701 bool ok; 1619 bool ok;
1620 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[prev_node].type));
1702 1621
1703#ifdef DEBUG
1704 re_token_type_t type = dfa->nodes[prev_node].type;
1705 assert (!IS_EPSILON_NODE (type));
1706#endif
1707#ifdef RE_ENABLE_I18N
1708 /* If the node may accept "multi byte". */ 1622 /* If the node may accept "multi byte". */
1709 if (dfa->nodes[prev_node].accept_mb) 1623 if (dfa->nodes[prev_node].accept_mb)
1710 naccepted = sift_states_iter_mb (mctx, sctx, prev_node, 1624 naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
1711 str_idx, sctx->last_str_idx); 1625 str_idx, sctx->last_str_idx);
1712#endif /* RE_ENABLE_I18N */
1713 1626
1714 /* We don't check backreferences here. 1627 /* We don't check backreferences here.
1715 See update_cur_sifted_state(). */ 1628 See update_cur_sifted_state(). */
@@ -1731,7 +1644,7 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1731 continue; 1644 continue;
1732 } 1645 }
1733 ok = re_node_set_insert (cur_dest, prev_node); 1646 ok = re_node_set_insert (cur_dest, prev_node);
1734 if (BE (! ok, 0)) 1647 if (__glibc_unlikely (! ok))
1735 return REG_ESPACE; 1648 return REG_ESPACE;
1736 } 1649 }
1737 1650
@@ -1741,7 +1654,6 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1741/* Helper functions. */ 1654/* Helper functions. */
1742 1655
1743static reg_errcode_t 1656static reg_errcode_t
1744internal_function
1745clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx) 1657clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1746{ 1658{
1747 Idx top = mctx->state_log_top; 1659 Idx top = mctx->state_log_top;
@@ -1753,12 +1665,13 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1753 { 1665 {
1754 reg_errcode_t err; 1666 reg_errcode_t err;
1755 err = extend_buffers (mctx, next_state_log_idx + 1); 1667 err = extend_buffers (mctx, next_state_log_idx + 1);
1756 if (BE (err != REG_NOERROR, 0)) 1668 if (__glibc_unlikely (err != REG_NOERROR))
1757 return err; 1669 return err;
1758 } 1670 }
1759 1671
1760 if (top < next_state_log_idx) 1672 if (top < next_state_log_idx)
1761 { 1673 {
1674 DEBUG_ASSERT (mctx->state_log != NULL);
1762 memset (mctx->state_log + top + 1, '\0', 1675 memset (mctx->state_log + top + 1, '\0',
1763 sizeof (re_dfastate_t *) * (next_state_log_idx - top)); 1676 sizeof (re_dfastate_t *) * (next_state_log_idx - top));
1764 mctx->state_log_top = next_state_log_idx; 1677 mctx->state_log_top = next_state_log_idx;
@@ -1767,7 +1680,6 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1767} 1680}
1768 1681
1769static reg_errcode_t 1682static reg_errcode_t
1770internal_function
1771merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, 1683merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
1772 re_dfastate_t **src, Idx num) 1684 re_dfastate_t **src, Idx num)
1773{ 1685{
@@ -1782,11 +1694,11 @@ merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
1782 re_node_set merged_set; 1694 re_node_set merged_set;
1783 err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, 1695 err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
1784 &src[st_idx]->nodes); 1696 &src[st_idx]->nodes);
1785 if (BE (err != REG_NOERROR, 0)) 1697 if (__glibc_unlikely (err != REG_NOERROR))
1786 return err; 1698 return err;
1787 dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); 1699 dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
1788 re_node_set_free (&merged_set); 1700 re_node_set_free (&merged_set);
1789 if (BE (err != REG_NOERROR, 0)) 1701 if (__glibc_unlikely (err != REG_NOERROR))
1790 return err; 1702 return err;
1791 } 1703 }
1792 } 1704 }
@@ -1794,7 +1706,6 @@ merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
1794} 1706}
1795 1707
1796static reg_errcode_t 1708static reg_errcode_t
1797internal_function
1798update_cur_sifted_state (const re_match_context_t *mctx, 1709update_cur_sifted_state (const re_match_context_t *mctx,
1799 re_sift_context_t *sctx, Idx str_idx, 1710 re_sift_context_t *sctx, Idx str_idx,
1800 re_node_set *dest_nodes) 1711 re_node_set *dest_nodes)
@@ -1814,7 +1725,7 @@ update_cur_sifted_state (const re_match_context_t *mctx,
1814 /* At first, add the nodes which can epsilon transit to a node in 1725 /* At first, add the nodes which can epsilon transit to a node in
1815 DEST_NODE. */ 1726 DEST_NODE. */
1816 err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); 1727 err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
1817 if (BE (err != REG_NOERROR, 0)) 1728 if (__glibc_unlikely (err != REG_NOERROR))
1818 return err; 1729 return err;
1819 1730
1820 /* Then, check the limitations in the current sift_context. */ 1731 /* Then, check the limitations in the current sift_context. */
@@ -1822,27 +1733,27 @@ update_cur_sifted_state (const re_match_context_t *mctx,
1822 { 1733 {
1823 err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, 1734 err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
1824 mctx->bkref_ents, str_idx); 1735 mctx->bkref_ents, str_idx);
1825 if (BE (err != REG_NOERROR, 0)) 1736 if (__glibc_unlikely (err != REG_NOERROR))
1826 return err; 1737 return err;
1827 } 1738 }
1828 } 1739 }
1829 1740
1830 sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); 1741 sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
1831 if (BE (err != REG_NOERROR, 0)) 1742 if (__glibc_unlikely (err != REG_NOERROR))
1832 return err; 1743 return err;
1833 } 1744 }
1834 1745
1835 if (candidates && mctx->state_log[str_idx]->has_backref) 1746 if (candidates && mctx->state_log[str_idx]->has_backref)
1836 { 1747 {
1837 err = sift_states_bkref (mctx, sctx, str_idx, candidates); 1748 err = sift_states_bkref (mctx, sctx, str_idx, candidates);
1838 if (BE (err != REG_NOERROR, 0)) 1749 if (__glibc_unlikely (err != REG_NOERROR))
1839 return err; 1750 return err;
1840 } 1751 }
1841 return REG_NOERROR; 1752 return REG_NOERROR;
1842} 1753}
1843 1754
1844static reg_errcode_t 1755static reg_errcode_t
1845internal_function __attribute_warn_unused_result__ 1756__attribute_warn_unused_result__
1846add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, 1757add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
1847 const re_node_set *candidates) 1758 const re_node_set *candidates)
1848{ 1759{
@@ -1850,19 +1761,19 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
1850 Idx i; 1761 Idx i;
1851 1762
1852 re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); 1763 re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
1853 if (BE (err != REG_NOERROR, 0)) 1764 if (__glibc_unlikely (err != REG_NOERROR))
1854 return err; 1765 return err;
1855 1766
1856 if (!state->inveclosure.alloc) 1767 if (!state->inveclosure.alloc)
1857 { 1768 {
1858 err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); 1769 err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
1859 if (BE (err != REG_NOERROR, 0)) 1770 if (__glibc_unlikely (err != REG_NOERROR))
1860 return REG_ESPACE; 1771 return REG_ESPACE;
1861 for (i = 0; i < dest_nodes->nelem; i++) 1772 for (i = 0; i < dest_nodes->nelem; i++)
1862 { 1773 {
1863 err = re_node_set_merge (&state->inveclosure, 1774 err = re_node_set_merge (&state->inveclosure,
1864 dfa->inveclosures + dest_nodes->elems[i]); 1775 dfa->inveclosures + dest_nodes->elems[i]);
1865 if (BE (err != REG_NOERROR, 0)) 1776 if (__glibc_unlikely (err != REG_NOERROR))
1866 return REG_ESPACE; 1777 return REG_ESPACE;
1867 } 1778 }
1868 } 1779 }
@@ -1871,7 +1782,6 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
1871} 1782}
1872 1783
1873static reg_errcode_t 1784static reg_errcode_t
1874internal_function
1875sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes, 1785sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
1876 const re_node_set *candidates) 1786 const re_node_set *candidates)
1877{ 1787{
@@ -1889,16 +1799,16 @@ sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
1889 { 1799 {
1890 Idx edst1 = dfa->edests[cur_node].elems[0]; 1800 Idx edst1 = dfa->edests[cur_node].elems[0];
1891 Idx edst2 = ((dfa->edests[cur_node].nelem > 1) 1801 Idx edst2 = ((dfa->edests[cur_node].nelem > 1)
1892 ? dfa->edests[cur_node].elems[1] : REG_MISSING); 1802 ? dfa->edests[cur_node].elems[1] : -1);
1893 if ((!re_node_set_contains (inv_eclosure, edst1) 1803 if ((!re_node_set_contains (inv_eclosure, edst1)
1894 && re_node_set_contains (dest_nodes, edst1)) 1804 && re_node_set_contains (dest_nodes, edst1))
1895 || (REG_VALID_NONZERO_INDEX (edst2) 1805 || (edst2 > 0
1896 && !re_node_set_contains (inv_eclosure, edst2) 1806 && !re_node_set_contains (inv_eclosure, edst2)
1897 && re_node_set_contains (dest_nodes, edst2))) 1807 && re_node_set_contains (dest_nodes, edst2)))
1898 { 1808 {
1899 err = re_node_set_add_intersect (&except_nodes, candidates, 1809 err = re_node_set_add_intersect (&except_nodes, candidates,
1900 dfa->inveclosures + cur_node); 1810 dfa->inveclosures + cur_node);
1901 if (BE (err != REG_NOERROR, 0)) 1811 if (__glibc_unlikely (err != REG_NOERROR))
1902 { 1812 {
1903 re_node_set_free (&except_nodes); 1813 re_node_set_free (&except_nodes);
1904 return err; 1814 return err;
@@ -1920,7 +1830,6 @@ sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
1920} 1830}
1921 1831
1922static bool 1832static bool
1923internal_function
1924check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits, 1833check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
1925 Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx) 1834 Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx)
1926{ 1835{
@@ -1956,7 +1865,6 @@ check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
1956} 1865}
1957 1866
1958static int 1867static int
1959internal_function
1960check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, 1868check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
1961 Idx subexp_idx, Idx from_node, Idx bkref_idx) 1869 Idx subexp_idx, Idx from_node, Idx bkref_idx)
1962{ 1870{
@@ -1972,7 +1880,7 @@ check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
1972 switch (dfa->nodes[node].type) 1880 switch (dfa->nodes[node].type)
1973 { 1881 {
1974 case OP_BACK_REF: 1882 case OP_BACK_REF:
1975 if (bkref_idx != REG_MISSING) 1883 if (bkref_idx != -1)
1976 { 1884 {
1977 struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx; 1885 struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
1978 do 1886 do
@@ -2038,7 +1946,6 @@ check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
2038} 1946}
2039 1947
2040static int 1948static int
2041internal_function
2042check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit, 1949check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
2043 Idx subexp_idx, Idx from_node, Idx str_idx, 1950 Idx subexp_idx, Idx from_node, Idx str_idx,
2044 Idx bkref_idx) 1951 Idx bkref_idx)
@@ -2068,7 +1975,6 @@ check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
2068 which are against limitations from DEST_NODES. */ 1975 which are against limitations from DEST_NODES. */
2069 1976
2070static reg_errcode_t 1977static reg_errcode_t
2071internal_function
2072check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, 1978check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2073 const re_node_set *candidates, re_node_set *limits, 1979 const re_node_set *candidates, re_node_set *limits,
2074 struct re_backref_cache_entry *bkref_ents, Idx str_idx) 1980 struct re_backref_cache_entry *bkref_ents, Idx str_idx)
@@ -2088,8 +1994,8 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2088 subexp_idx = dfa->nodes[ent->node].opr.idx; 1994 subexp_idx = dfa->nodes[ent->node].opr.idx;
2089 if (ent->subexp_to == str_idx) 1995 if (ent->subexp_to == str_idx)
2090 { 1996 {
2091 Idx ops_node = REG_MISSING; 1997 Idx ops_node = -1;
2092 Idx cls_node = REG_MISSING; 1998 Idx cls_node = -1;
2093 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) 1999 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
2094 { 2000 {
2095 Idx node = dest_nodes->elems[node_idx]; 2001 Idx node = dest_nodes->elems[node_idx];
@@ -2104,16 +2010,16 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2104 2010
2105 /* Check the limitation of the open subexpression. */ 2011 /* Check the limitation of the open subexpression. */
2106 /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */ 2012 /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */
2107 if (REG_VALID_INDEX (ops_node)) 2013 if (ops_node >= 0)
2108 { 2014 {
2109 err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, 2015 err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
2110 candidates); 2016 candidates);
2111 if (BE (err != REG_NOERROR, 0)) 2017 if (__glibc_unlikely (err != REG_NOERROR))
2112 return err; 2018 return err;
2113 } 2019 }
2114 2020
2115 /* Check the limitation of the close subexpression. */ 2021 /* Check the limitation of the close subexpression. */
2116 if (REG_VALID_INDEX (cls_node)) 2022 if (cls_node >= 0)
2117 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) 2023 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
2118 { 2024 {
2119 Idx node = dest_nodes->elems[node_idx]; 2025 Idx node = dest_nodes->elems[node_idx];
@@ -2126,7 +2032,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2126 Remove it form the current sifted state. */ 2032 Remove it form the current sifted state. */
2127 err = sub_epsilon_src_nodes (dfa, node, dest_nodes, 2033 err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
2128 candidates); 2034 candidates);
2129 if (BE (err != REG_NOERROR, 0)) 2035 if (__glibc_unlikely (err != REG_NOERROR))
2130 return err; 2036 return err;
2131 --node_idx; 2037 --node_idx;
2132 } 2038 }
@@ -2146,7 +2052,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2146 Remove it form the current sifted state. */ 2052 Remove it form the current sifted state. */
2147 err = sub_epsilon_src_nodes (dfa, node, dest_nodes, 2053 err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
2148 candidates); 2054 candidates);
2149 if (BE (err != REG_NOERROR, 0)) 2055 if (__glibc_unlikely (err != REG_NOERROR))
2150 return err; 2056 return err;
2151 } 2057 }
2152 } 2058 }
@@ -2156,7 +2062,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2156} 2062}
2157 2063
2158static reg_errcode_t 2064static reg_errcode_t
2159internal_function __attribute_warn_unused_result__ 2065__attribute_warn_unused_result__
2160sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, 2066sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2161 Idx str_idx, const re_node_set *candidates) 2067 Idx str_idx, const re_node_set *candidates)
2162{ 2068{
@@ -2166,7 +2072,7 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2166 re_sift_context_t local_sctx; 2072 re_sift_context_t local_sctx;
2167 Idx first_idx = search_cur_bkref_entry (mctx, str_idx); 2073 Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
2168 2074
2169 if (first_idx == REG_MISSING) 2075 if (first_idx == -1)
2170 return REG_NOERROR; 2076 return REG_NOERROR;
2171 2077
2172 local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */ 2078 local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */
@@ -2212,27 +2118,27 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2212 { 2118 {
2213 local_sctx = *sctx; 2119 local_sctx = *sctx;
2214 err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); 2120 err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
2215 if (BE (err != REG_NOERROR, 0)) 2121 if (__glibc_unlikely (err != REG_NOERROR))
2216 goto free_return; 2122 goto free_return;
2217 } 2123 }
2218 local_sctx.last_node = node; 2124 local_sctx.last_node = node;
2219 local_sctx.last_str_idx = str_idx; 2125 local_sctx.last_str_idx = str_idx;
2220 ok = re_node_set_insert (&local_sctx.limits, enabled_idx); 2126 ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
2221 if (BE (! ok, 0)) 2127 if (__glibc_unlikely (! ok))
2222 { 2128 {
2223 err = REG_ESPACE; 2129 err = REG_ESPACE;
2224 goto free_return; 2130 goto free_return;
2225 } 2131 }
2226 cur_state = local_sctx.sifted_states[str_idx]; 2132 cur_state = local_sctx.sifted_states[str_idx];
2227 err = sift_states_backward (mctx, &local_sctx); 2133 err = sift_states_backward (mctx, &local_sctx);
2228 if (BE (err != REG_NOERROR, 0)) 2134 if (__glibc_unlikely (err != REG_NOERROR))
2229 goto free_return; 2135 goto free_return;
2230 if (sctx->limited_states != NULL) 2136 if (sctx->limited_states != NULL)
2231 { 2137 {
2232 err = merge_state_array (dfa, sctx->limited_states, 2138 err = merge_state_array (dfa, sctx->limited_states,
2233 local_sctx.sifted_states, 2139 local_sctx.sifted_states,
2234 str_idx + 1); 2140 str_idx + 1);
2235 if (BE (err != REG_NOERROR, 0)) 2141 if (__glibc_unlikely (err != REG_NOERROR))
2236 goto free_return; 2142 goto free_return;
2237 } 2143 }
2238 local_sctx.sifted_states[str_idx] = cur_state; 2144 local_sctx.sifted_states[str_idx] = cur_state;
@@ -2254,9 +2160,7 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2254} 2160}
2255 2161
2256 2162
2257#ifdef RE_ENABLE_I18N
2258static int 2163static int
2259internal_function
2260sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, 2164sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2261 Idx node_idx, Idx str_idx, Idx max_str_idx) 2165 Idx node_idx, Idx str_idx, Idx max_str_idx)
2262{ 2166{
@@ -2264,44 +2168,41 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2264 int naccepted; 2168 int naccepted;
2265 /* Check the node can accept "multi byte". */ 2169 /* Check the node can accept "multi byte". */
2266 naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); 2170 naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
2267 if (naccepted > 0 && str_idx + naccepted <= max_str_idx && 2171 if (naccepted > 0 && str_idx + naccepted <= max_str_idx
2268 !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], 2172 && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
2269 dfa->nexts[node_idx])) 2173 dfa->nexts[node_idx]))
2270 /* The node can't accept the "multi byte", or the 2174 /* The node can't accept the "multi byte", or the
2271 destination was already thrown away, then the node 2175 destination was already thrown away, then the node
2272 could't accept the current input "multi byte". */ 2176 couldn't accept the current input "multi byte". */
2273 naccepted = 0; 2177 naccepted = 0;
2274 /* Otherwise, it is sure that the node could accept 2178 /* Otherwise, it is sure that the node could accept
2275 'naccepted' bytes input. */ 2179 'naccepted' bytes input. */
2276 return naccepted; 2180 return naccepted;
2277} 2181}
2278#endif /* RE_ENABLE_I18N */
2279
2280 2182
2281/* Functions for state transition. */ 2183/* Functions for state transition. */
2282 2184
2283/* Return the next state to which the current state STATE will transit by 2185/* Return the next state to which the current state STATE will transit by
2284 accepting the current input byte, and update STATE_LOG if necessary. 2186 accepting the current input byte, and update STATE_LOG if necessary.
2187 Return NULL on failure.
2285 If STATE can accept a multibyte char/collating element/back reference 2188 If STATE can accept a multibyte char/collating element/back reference
2286 update the destination of STATE_LOG. */ 2189 update the destination of STATE_LOG. */
2287 2190
2288static re_dfastate_t * 2191static re_dfastate_t *
2289internal_function __attribute_warn_unused_result__ 2192__attribute_warn_unused_result__
2290transit_state (reg_errcode_t *err, re_match_context_t *mctx, 2193transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2291 re_dfastate_t *state) 2194 re_dfastate_t *state)
2292{ 2195{
2293 re_dfastate_t **trtable; 2196 re_dfastate_t **trtable;
2294 unsigned char ch; 2197 unsigned char ch;
2295 2198
2296#ifdef RE_ENABLE_I18N
2297 /* If the current state can accept multibyte. */ 2199 /* If the current state can accept multibyte. */
2298 if (BE (state->accept_mb, 0)) 2200 if (__glibc_unlikely (state->accept_mb))
2299 { 2201 {
2300 *err = transit_state_mb (mctx, state); 2202 *err = transit_state_mb (mctx, state);
2301 if (BE (*err != REG_NOERROR, 0)) 2203 if (__glibc_unlikely (*err != REG_NOERROR))
2302 return NULL; 2204 return NULL;
2303 } 2205 }
2304#endif /* RE_ENABLE_I18N */
2305 2206
2306 /* Then decide the next state with the single byte. */ 2207 /* Then decide the next state with the single byte. */
2307#if 0 2208#if 0
@@ -2315,11 +2216,11 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2315 for (;;) 2216 for (;;)
2316 { 2217 {
2317 trtable = state->trtable; 2218 trtable = state->trtable;
2318 if (BE (trtable != NULL, 1)) 2219 if (__glibc_likely (trtable != NULL))
2319 return trtable[ch]; 2220 return trtable[ch];
2320 2221
2321 trtable = state->word_trtable; 2222 trtable = state->word_trtable;
2322 if (BE (trtable != NULL, 1)) 2223 if (__glibc_likely (trtable != NULL))
2323 { 2224 {
2324 unsigned int context; 2225 unsigned int context;
2325 context 2226 context
@@ -2344,7 +2245,6 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2344 2245
2345/* Update the state_log if we need */ 2246/* Update the state_log if we need */
2346static re_dfastate_t * 2247static re_dfastate_t *
2347internal_function
2348merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, 2248merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2349 re_dfastate_t *next_state) 2249 re_dfastate_t *next_state)
2350{ 2250{
@@ -2376,7 +2276,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2376 table_nodes = next_state->entrance_nodes; 2276 table_nodes = next_state->entrance_nodes;
2377 *err = re_node_set_init_union (&next_nodes, table_nodes, 2277 *err = re_node_set_init_union (&next_nodes, table_nodes,
2378 log_nodes); 2278 log_nodes);
2379 if (BE (*err != REG_NOERROR, 0)) 2279 if (__glibc_unlikely (*err != REG_NOERROR))
2380 return NULL; 2280 return NULL;
2381 } 2281 }
2382 else 2282 else
@@ -2396,21 +2296,21 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2396 re_node_set_free (&next_nodes); 2296 re_node_set_free (&next_nodes);
2397 } 2297 }
2398 2298
2399 if (BE (dfa->nbackref, 0) && next_state != NULL) 2299 if (__glibc_unlikely (dfa->nbackref) && next_state != NULL)
2400 { 2300 {
2401 /* Check OP_OPEN_SUBEXP in the current state in case that we use them 2301 /* Check OP_OPEN_SUBEXP in the current state in case that we use them
2402 later. We must check them here, since the back references in the 2302 later. We must check them here, since the back references in the
2403 next state might use them. */ 2303 next state might use them. */
2404 *err = check_subexp_matching_top (mctx, &next_state->nodes, 2304 *err = check_subexp_matching_top (mctx, &next_state->nodes,
2405 cur_idx); 2305 cur_idx);
2406 if (BE (*err != REG_NOERROR, 0)) 2306 if (__glibc_unlikely (*err != REG_NOERROR))
2407 return NULL; 2307 return NULL;
2408 2308
2409 /* If the next state has back references. */ 2309 /* If the next state has back references. */
2410 if (next_state->has_backref) 2310 if (next_state->has_backref)
2411 { 2311 {
2412 *err = transit_state_bkref (mctx, &next_state->nodes); 2312 *err = transit_state_bkref (mctx, &next_state->nodes);
2413 if (BE (*err != REG_NOERROR, 0)) 2313 if (__glibc_unlikely (*err != REG_NOERROR))
2414 return NULL; 2314 return NULL;
2415 next_state = mctx->state_log[cur_idx]; 2315 next_state = mctx->state_log[cur_idx];
2416 } 2316 }
@@ -2423,7 +2323,6 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2423 multi-byte match, then look in the log for a state 2323 multi-byte match, then look in the log for a state
2424 from which to restart matching. */ 2324 from which to restart matching. */
2425static re_dfastate_t * 2325static re_dfastate_t *
2426internal_function
2427find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) 2326find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
2428{ 2327{
2429 re_dfastate_t *cur_state; 2328 re_dfastate_t *cur_state;
@@ -2454,7 +2353,6 @@ find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
2454 corresponding back references. */ 2353 corresponding back references. */
2455 2354
2456static reg_errcode_t 2355static reg_errcode_t
2457internal_function
2458check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, 2356check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2459 Idx str_idx) 2357 Idx str_idx)
2460{ 2358{
@@ -2476,7 +2374,7 @@ check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2476 & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) 2374 & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
2477 { 2375 {
2478 err = match_ctx_add_subtop (mctx, node, str_idx); 2376 err = match_ctx_add_subtop (mctx, node, str_idx);
2479 if (BE (err != REG_NOERROR, 0)) 2377 if (__glibc_unlikely (err != REG_NOERROR))
2480 return err; 2378 return err;
2481 } 2379 }
2482 } 2380 }
@@ -2485,7 +2383,7 @@ check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2485 2383
2486#if 0 2384#if 0
2487/* Return the next state to which the current state STATE will transit by 2385/* Return the next state to which the current state STATE will transit by
2488 accepting the current input byte. */ 2386 accepting the current input byte. Return NULL on failure. */
2489 2387
2490static re_dfastate_t * 2388static re_dfastate_t *
2491transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, 2389transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
@@ -2498,7 +2396,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2498 unsigned int context; 2396 unsigned int context;
2499 2397
2500 *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); 2398 *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
2501 if (BE (*err != REG_NOERROR, 0)) 2399 if (__glibc_unlikely (*err != REG_NOERROR))
2502 return NULL; 2400 return NULL;
2503 for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) 2401 for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
2504 { 2402 {
@@ -2507,7 +2405,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2507 { 2405 {
2508 *err = re_node_set_merge (&next_nodes, 2406 *err = re_node_set_merge (&next_nodes,
2509 dfa->eclosures + dfa->nexts[cur_node]); 2407 dfa->eclosures + dfa->nexts[cur_node]);
2510 if (BE (*err != REG_NOERROR, 0)) 2408 if (__glibc_unlikely (*err != REG_NOERROR))
2511 { 2409 {
2512 re_node_set_free (&next_nodes); 2410 re_node_set_free (&next_nodes);
2513 return NULL; 2411 return NULL;
@@ -2525,9 +2423,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2525} 2423}
2526#endif 2424#endif
2527 2425
2528#ifdef RE_ENABLE_I18N
2529static reg_errcode_t 2426static reg_errcode_t
2530internal_function
2531transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) 2427transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2532{ 2428{
2533 const re_dfa_t *const dfa = mctx->dfa; 2429 const re_dfa_t *const dfa = mctx->dfa;
@@ -2567,11 +2463,9 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2567 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted 2463 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
2568 : mctx->max_mb_elem_len); 2464 : mctx->max_mb_elem_len);
2569 err = clean_state_log_if_needed (mctx, dest_idx); 2465 err = clean_state_log_if_needed (mctx, dest_idx);
2570 if (BE (err != REG_NOERROR, 0)) 2466 if (__glibc_unlikely (err != REG_NOERROR))
2571 return err; 2467 return err;
2572#ifdef DEBUG 2468 DEBUG_ASSERT (dfa->nexts[cur_node_idx] != -1);
2573 assert (dfa->nexts[cur_node_idx] != REG_MISSING);
2574#endif
2575 new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; 2469 new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
2576 2470
2577 dest_state = mctx->state_log[dest_idx]; 2471 dest_state = mctx->state_log[dest_idx];
@@ -2581,7 +2475,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2581 { 2475 {
2582 err = re_node_set_init_union (&dest_nodes, 2476 err = re_node_set_init_union (&dest_nodes,
2583 dest_state->entrance_nodes, new_nodes); 2477 dest_state->entrance_nodes, new_nodes);
2584 if (BE (err != REG_NOERROR, 0)) 2478 if (__glibc_unlikely (err != REG_NOERROR))
2585 return err; 2479 return err;
2586 } 2480 }
2587 context = re_string_context_at (&mctx->input, dest_idx - 1, 2481 context = re_string_context_at (&mctx->input, dest_idx - 1,
@@ -2590,15 +2484,14 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2590 = re_acquire_state_context (&err, dfa, &dest_nodes, context); 2484 = re_acquire_state_context (&err, dfa, &dest_nodes, context);
2591 if (dest_state != NULL) 2485 if (dest_state != NULL)
2592 re_node_set_free (&dest_nodes); 2486 re_node_set_free (&dest_nodes);
2593 if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0)) 2487 if (__glibc_unlikely (mctx->state_log[dest_idx] == NULL
2488 && err != REG_NOERROR))
2594 return err; 2489 return err;
2595 } 2490 }
2596 return REG_NOERROR; 2491 return REG_NOERROR;
2597} 2492}
2598#endif /* RE_ENABLE_I18N */
2599 2493
2600static reg_errcode_t 2494static reg_errcode_t
2601internal_function
2602transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) 2495transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2603{ 2496{
2604 const re_dfa_t *const dfa = mctx->dfa; 2497 const re_dfa_t *const dfa = mctx->dfa;
@@ -2630,14 +2523,12 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2630 Check the substring which the substring matched. */ 2523 Check the substring which the substring matched. */
2631 bkc_idx = mctx->nbkref_ents; 2524 bkc_idx = mctx->nbkref_ents;
2632 err = get_subexp (mctx, node_idx, cur_str_idx); 2525 err = get_subexp (mctx, node_idx, cur_str_idx);
2633 if (BE (err != REG_NOERROR, 0)) 2526 if (__glibc_unlikely (err != REG_NOERROR))
2634 goto free_return; 2527 goto free_return;
2635 2528
2636 /* And add the epsilon closures (which is 'new_dest_nodes') of 2529 /* And add the epsilon closures (which is 'new_dest_nodes') of
2637 the backreference to appropriate state_log. */ 2530 the backreference to appropriate state_log. */
2638#ifdef DEBUG 2531 DEBUG_ASSERT (dfa->nexts[node_idx] != -1);
2639 assert (dfa->nexts[node_idx] != REG_MISSING);
2640#endif
2641 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) 2532 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
2642 { 2533 {
2643 Idx subexp_len; 2534 Idx subexp_len;
@@ -2663,8 +2554,8 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2663 mctx->state_log[dest_str_idx] 2554 mctx->state_log[dest_str_idx]
2664 = re_acquire_state_context (&err, dfa, new_dest_nodes, 2555 = re_acquire_state_context (&err, dfa, new_dest_nodes,
2665 context); 2556 context);
2666 if (BE (mctx->state_log[dest_str_idx] == NULL 2557 if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
2667 && err != REG_NOERROR, 0)) 2558 && err != REG_NOERROR))
2668 goto free_return; 2559 goto free_return;
2669 } 2560 }
2670 else 2561 else
@@ -2673,7 +2564,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2673 err = re_node_set_init_union (&dest_nodes, 2564 err = re_node_set_init_union (&dest_nodes,
2674 dest_state->entrance_nodes, 2565 dest_state->entrance_nodes,
2675 new_dest_nodes); 2566 new_dest_nodes);
2676 if (BE (err != REG_NOERROR, 0)) 2567 if (__glibc_unlikely (err != REG_NOERROR))
2677 { 2568 {
2678 re_node_set_free (&dest_nodes); 2569 re_node_set_free (&dest_nodes);
2679 goto free_return; 2570 goto free_return;
@@ -2681,8 +2572,8 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2681 mctx->state_log[dest_str_idx] 2572 mctx->state_log[dest_str_idx]
2682 = re_acquire_state_context (&err, dfa, &dest_nodes, context); 2573 = re_acquire_state_context (&err, dfa, &dest_nodes, context);
2683 re_node_set_free (&dest_nodes); 2574 re_node_set_free (&dest_nodes);
2684 if (BE (mctx->state_log[dest_str_idx] == NULL 2575 if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
2685 && err != REG_NOERROR, 0)) 2576 && err != REG_NOERROR))
2686 goto free_return; 2577 goto free_return;
2687 } 2578 }
2688 /* We need to check recursively if the backreference can epsilon 2579 /* We need to check recursively if the backreference can epsilon
@@ -2692,10 +2583,10 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2692 { 2583 {
2693 err = check_subexp_matching_top (mctx, new_dest_nodes, 2584 err = check_subexp_matching_top (mctx, new_dest_nodes,
2694 cur_str_idx); 2585 cur_str_idx);
2695 if (BE (err != REG_NOERROR, 0)) 2586 if (__glibc_unlikely (err != REG_NOERROR))
2696 goto free_return; 2587 goto free_return;
2697 err = transit_state_bkref (mctx, new_dest_nodes); 2588 err = transit_state_bkref (mctx, new_dest_nodes);
2698 if (BE (err != REG_NOERROR, 0)) 2589 if (__glibc_unlikely (err != REG_NOERROR))
2699 goto free_return; 2590 goto free_return;
2700 } 2591 }
2701 } 2592 }
@@ -2712,7 +2603,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2712 delay these checking for prune_impossible_nodes(). */ 2603 delay these checking for prune_impossible_nodes(). */
2713 2604
2714static reg_errcode_t 2605static reg_errcode_t
2715internal_function __attribute_warn_unused_result__ 2606__attribute_warn_unused_result__
2716get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) 2607get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2717{ 2608{
2718 const re_dfa_t *const dfa = mctx->dfa; 2609 const re_dfa_t *const dfa = mctx->dfa;
@@ -2720,7 +2611,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2720 const char *buf = (const char *) re_string_get_buffer (&mctx->input); 2611 const char *buf = (const char *) re_string_get_buffer (&mctx->input);
2721 /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ 2612 /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */
2722 Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); 2613 Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
2723 if (cache_idx != REG_MISSING) 2614 if (cache_idx != -1)
2724 { 2615 {
2725 const struct re_backref_cache_entry *entry 2616 const struct re_backref_cache_entry *entry
2726 = mctx->bkref_ents + cache_idx; 2617 = mctx->bkref_ents + cache_idx;
@@ -2756,7 +2647,8 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2756 at the back reference? */ 2647 at the back reference? */
2757 if (sl_str_diff > 0) 2648 if (sl_str_diff > 0)
2758 { 2649 {
2759 if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) 2650 if (__glibc_unlikely (bkref_str_off + sl_str_diff
2651 > mctx->input.valid_len))
2760 { 2652 {
2761 /* Not enough chars for a successful match. */ 2653 /* Not enough chars for a successful match. */
2762 if (bkref_str_off + sl_str_diff > mctx->input.len) 2654 if (bkref_str_off + sl_str_diff > mctx->input.len)
@@ -2765,7 +2657,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2765 err = clean_state_log_if_needed (mctx, 2657 err = clean_state_log_if_needed (mctx,
2766 bkref_str_off 2658 bkref_str_off
2767 + sl_str_diff); 2659 + sl_str_diff);
2768 if (BE (err != REG_NOERROR, 0)) 2660 if (__glibc_unlikely (err != REG_NOERROR))
2769 return err; 2661 return err;
2770 buf = (const char *) re_string_get_buffer (&mctx->input); 2662 buf = (const char *) re_string_get_buffer (&mctx->input);
2771 } 2663 }
@@ -2784,7 +2676,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2784 2676
2785 if (err == REG_NOMATCH) 2677 if (err == REG_NOMATCH)
2786 continue; 2678 continue;
2787 if (BE (err != REG_NOERROR, 0)) 2679 if (__glibc_unlikely (err != REG_NOERROR))
2788 return err; 2680 return err;
2789 } 2681 }
2790 2682
@@ -2803,14 +2695,14 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2803 at the back reference? */ 2695 at the back reference? */
2804 if (sl_str_off > 0) 2696 if (sl_str_off > 0)
2805 { 2697 {
2806 if (BE (bkref_str_off >= mctx->input.valid_len, 0)) 2698 if (__glibc_unlikely (bkref_str_off >= mctx->input.valid_len))
2807 { 2699 {
2808 /* If we are at the end of the input, we cannot match. */ 2700 /* If we are at the end of the input, we cannot match. */
2809 if (bkref_str_off >= mctx->input.len) 2701 if (bkref_str_off >= mctx->input.len)
2810 break; 2702 break;
2811 2703
2812 err = extend_buffers (mctx, bkref_str_off + 1); 2704 err = extend_buffers (mctx, bkref_str_off + 1);
2813 if (BE (err != REG_NOERROR, 0)) 2705 if (__glibc_unlikely (err != REG_NOERROR))
2814 return err; 2706 return err;
2815 2707
2816 buf = (const char *) re_string_get_buffer (&mctx->input); 2708 buf = (const char *) re_string_get_buffer (&mctx->input);
@@ -2825,7 +2717,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2825 nodes = &mctx->state_log[sl_str]->nodes; 2717 nodes = &mctx->state_log[sl_str]->nodes;
2826 cls_node = find_subexp_node (dfa, nodes, subexp_num, 2718 cls_node = find_subexp_node (dfa, nodes, subexp_num,
2827 OP_CLOSE_SUBEXP); 2719 OP_CLOSE_SUBEXP);
2828 if (cls_node == REG_MISSING) 2720 if (cls_node == -1)
2829 continue; /* No. */ 2721 continue; /* No. */
2830 if (sub_top->path == NULL) 2722 if (sub_top->path == NULL)
2831 { 2723 {
@@ -2841,15 +2733,18 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2841 OP_CLOSE_SUBEXP); 2733 OP_CLOSE_SUBEXP);
2842 if (err == REG_NOMATCH) 2734 if (err == REG_NOMATCH)
2843 continue; 2735 continue;
2844 if (BE (err != REG_NOERROR, 0)) 2736 if (__glibc_unlikely (err != REG_NOERROR))
2845 return err; 2737 return err;
2846 sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); 2738 sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
2847 if (BE (sub_last == NULL, 0)) 2739 if (__glibc_unlikely (sub_last == NULL))
2848 return REG_ESPACE; 2740 return REG_ESPACE;
2849 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, 2741 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
2850 bkref_str_idx); 2742 bkref_str_idx);
2743 buf = (const char *) re_string_get_buffer (&mctx->input);
2851 if (err == REG_NOMATCH) 2744 if (err == REG_NOMATCH)
2852 continue; 2745 continue;
2746 if (__glibc_unlikely (err != REG_NOERROR))
2747 return err;
2853 } 2748 }
2854 } 2749 }
2855 return REG_NOERROR; 2750 return REG_NOERROR;
@@ -2862,7 +2757,6 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2862 and SUB_LAST. */ 2757 and SUB_LAST. */
2863 2758
2864static reg_errcode_t 2759static reg_errcode_t
2865internal_function
2866get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, 2760get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2867 re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str) 2761 re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str)
2868{ 2762{
@@ -2876,7 +2770,7 @@ get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2876 return err; 2770 return err;
2877 err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, 2771 err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
2878 sub_last->str_idx); 2772 sub_last->str_idx);
2879 if (BE (err != REG_NOERROR, 0)) 2773 if (__glibc_unlikely (err != REG_NOERROR))
2880 return err; 2774 return err;
2881 to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; 2775 to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
2882 return clean_state_log_if_needed (mctx, to_idx); 2776 return clean_state_log_if_needed (mctx, to_idx);
@@ -2891,7 +2785,6 @@ get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2891 E.g. RE: (a){2} */ 2785 E.g. RE: (a){2} */
2892 2786
2893static Idx 2787static Idx
2894internal_function
2895find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, 2788find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
2896 Idx subexp_idx, int type) 2789 Idx subexp_idx, int type)
2897{ 2790{
@@ -2904,16 +2797,17 @@ find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
2904 && node->opr.idx == subexp_idx) 2797 && node->opr.idx == subexp_idx)
2905 return cls_node; 2798 return cls_node;
2906 } 2799 }
2907 return REG_MISSING; 2800 return -1;
2908} 2801}
2909 2802
2910/* Check whether the node TOP_NODE at TOP_STR can arrive to the node 2803/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
2911 LAST_NODE at LAST_STR. We record the path onto PATH since it will be 2804 LAST_NODE at LAST_STR. We record the path onto PATH since it will be
2912 heavily reused. 2805 heavily reused.
2913 Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */ 2806 Return REG_NOERROR if it can arrive, REG_NOMATCH if it cannot,
2807 REG_ESPACE if memory is exhausted. */
2914 2808
2915static reg_errcode_t 2809static reg_errcode_t
2916internal_function __attribute_warn_unused_result__ 2810__attribute_warn_unused_result__
2917check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node, 2811check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2918 Idx top_str, Idx last_node, Idx last_str, int type) 2812 Idx top_str, Idx last_node, Idx last_str, int type)
2919{ 2813{
@@ -2927,19 +2821,19 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2927 2821
2928 subexp_num = dfa->nodes[top_node].opr.idx; 2822 subexp_num = dfa->nodes[top_node].opr.idx;
2929 /* Extend the buffer if we need. */ 2823 /* Extend the buffer if we need. */
2930 if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0)) 2824 if (__glibc_unlikely (path->alloc < last_str + mctx->max_mb_elem_len + 1))
2931 { 2825 {
2932 re_dfastate_t **new_array; 2826 re_dfastate_t **new_array;
2933 Idx old_alloc = path->alloc; 2827 Idx old_alloc = path->alloc;
2934 Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1; 2828 Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1;
2935 Idx new_alloc; 2829 Idx new_alloc;
2936 if (BE (IDX_MAX - old_alloc < incr_alloc, 0)) 2830 if (__glibc_unlikely (IDX_MAX - old_alloc < incr_alloc))
2937 return REG_ESPACE; 2831 return REG_ESPACE;
2938 new_alloc = old_alloc + incr_alloc; 2832 new_alloc = old_alloc + incr_alloc;
2939 if (BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0)) 2833 if (__glibc_unlikely (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc))
2940 return REG_ESPACE; 2834 return REG_ESPACE;
2941 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc); 2835 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
2942 if (BE (new_array == NULL, 0)) 2836 if (__glibc_unlikely (new_array == NULL))
2943 return REG_ESPACE; 2837 return REG_ESPACE;
2944 path->array = new_array; 2838 path->array = new_array;
2945 path->alloc = new_alloc; 2839 path->alloc = new_alloc;
@@ -2960,10 +2854,10 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2960 if (str_idx == top_str) 2854 if (str_idx == top_str)
2961 { 2855 {
2962 err = re_node_set_init_1 (&next_nodes, top_node); 2856 err = re_node_set_init_1 (&next_nodes, top_node);
2963 if (BE (err != REG_NOERROR, 0)) 2857 if (__glibc_unlikely (err != REG_NOERROR))
2964 return err; 2858 return err;
2965 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); 2859 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
2966 if (BE (err != REG_NOERROR, 0)) 2860 if (__glibc_unlikely (err != REG_NOERROR))
2967 { 2861 {
2968 re_node_set_free (&next_nodes); 2862 re_node_set_free (&next_nodes);
2969 return err; 2863 return err;
@@ -2975,7 +2869,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2975 if (cur_state && cur_state->has_backref) 2869 if (cur_state && cur_state->has_backref)
2976 { 2870 {
2977 err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); 2871 err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
2978 if (BE (err != REG_NOERROR, 0)) 2872 if (__glibc_unlikely (err != REG_NOERROR))
2979 return err; 2873 return err;
2980 } 2874 }
2981 else 2875 else
@@ -2987,14 +2881,14 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2987 { 2881 {
2988 err = expand_bkref_cache (mctx, &next_nodes, str_idx, 2882 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
2989 subexp_num, type); 2883 subexp_num, type);
2990 if (BE (err != REG_NOERROR, 0)) 2884 if (__glibc_unlikely (err != REG_NOERROR))
2991 { 2885 {
2992 re_node_set_free (&next_nodes); 2886 re_node_set_free (&next_nodes);
2993 return err; 2887 return err;
2994 } 2888 }
2995 } 2889 }
2996 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); 2890 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
2997 if (BE (cur_state == NULL && err != REG_NOERROR, 0)) 2891 if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
2998 { 2892 {
2999 re_node_set_free (&next_nodes); 2893 re_node_set_free (&next_nodes);
3000 return err; 2894 return err;
@@ -3009,7 +2903,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3009 { 2903 {
3010 err = re_node_set_merge (&next_nodes, 2904 err = re_node_set_merge (&next_nodes,
3011 &mctx->state_log[str_idx + 1]->nodes); 2905 &mctx->state_log[str_idx + 1]->nodes);
3012 if (BE (err != REG_NOERROR, 0)) 2906 if (__glibc_unlikely (err != REG_NOERROR))
3013 { 2907 {
3014 re_node_set_free (&next_nodes); 2908 re_node_set_free (&next_nodes);
3015 return err; 2909 return err;
@@ -3020,7 +2914,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3020 err = check_arrival_add_next_nodes (mctx, str_idx, 2914 err = check_arrival_add_next_nodes (mctx, str_idx,
3021 &cur_state->non_eps_nodes, 2915 &cur_state->non_eps_nodes,
3022 &next_nodes); 2916 &next_nodes);
3023 if (BE (err != REG_NOERROR, 0)) 2917 if (__glibc_unlikely (err != REG_NOERROR))
3024 { 2918 {
3025 re_node_set_free (&next_nodes); 2919 re_node_set_free (&next_nodes);
3026 return err; 2920 return err;
@@ -3030,14 +2924,14 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3030 if (next_nodes.nelem) 2924 if (next_nodes.nelem)
3031 { 2925 {
3032 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); 2926 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
3033 if (BE (err != REG_NOERROR, 0)) 2927 if (__glibc_unlikely (err != REG_NOERROR))
3034 { 2928 {
3035 re_node_set_free (&next_nodes); 2929 re_node_set_free (&next_nodes);
3036 return err; 2930 return err;
3037 } 2931 }
3038 err = expand_bkref_cache (mctx, &next_nodes, str_idx, 2932 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
3039 subexp_num, type); 2933 subexp_num, type);
3040 if (BE (err != REG_NOERROR, 0)) 2934 if (__glibc_unlikely (err != REG_NOERROR))
3041 { 2935 {
3042 re_node_set_free (&next_nodes); 2936 re_node_set_free (&next_nodes);
3043 return err; 2937 return err;
@@ -3045,7 +2939,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3045 } 2939 }
3046 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); 2940 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
3047 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); 2941 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
3048 if (BE (cur_state == NULL && err != REG_NOERROR, 0)) 2942 if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
3049 { 2943 {
3050 re_node_set_free (&next_nodes); 2944 re_node_set_free (&next_nodes);
3051 return err; 2945 return err;
@@ -3078,27 +2972,22 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3078 Can't we unify them? */ 2972 Can't we unify them? */
3079 2973
3080static reg_errcode_t 2974static reg_errcode_t
3081internal_function __attribute_warn_unused_result__ 2975__attribute_warn_unused_result__
3082check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx, 2976check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3083 re_node_set *cur_nodes, re_node_set *next_nodes) 2977 re_node_set *cur_nodes, re_node_set *next_nodes)
3084{ 2978{
3085 const re_dfa_t *const dfa = mctx->dfa; 2979 const re_dfa_t *const dfa = mctx->dfa;
3086 bool ok; 2980 bool ok;
3087 Idx cur_idx; 2981 Idx cur_idx;
3088#ifdef RE_ENABLE_I18N
3089 reg_errcode_t err = REG_NOERROR; 2982 reg_errcode_t err = REG_NOERROR;
3090#endif
3091 re_node_set union_set; 2983 re_node_set union_set;
3092 re_node_set_init_empty (&union_set); 2984 re_node_set_init_empty (&union_set);
3093 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) 2985 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
3094 { 2986 {
3095 int naccepted = 0; 2987 int naccepted = 0;
3096 Idx cur_node = cur_nodes->elems[cur_idx]; 2988 Idx cur_node = cur_nodes->elems[cur_idx];
3097#ifdef DEBUG 2989 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[cur_node].type));
3098 re_token_type_t type = dfa->nodes[cur_node].type; 2990
3099 assert (!IS_EPSILON_NODE (type));
3100#endif
3101#ifdef RE_ENABLE_I18N
3102 /* If the node may accept "multi byte". */ 2991 /* If the node may accept "multi byte". */
3103 if (dfa->nodes[cur_node].accept_mb) 2992 if (dfa->nodes[cur_node].accept_mb)
3104 { 2993 {
@@ -3114,34 +3003,34 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3114 if (dest_state) 3003 if (dest_state)
3115 { 3004 {
3116 err = re_node_set_merge (&union_set, &dest_state->nodes); 3005 err = re_node_set_merge (&union_set, &dest_state->nodes);
3117 if (BE (err != REG_NOERROR, 0)) 3006 if (__glibc_unlikely (err != REG_NOERROR))
3118 { 3007 {
3119 re_node_set_free (&union_set); 3008 re_node_set_free (&union_set);
3120 return err; 3009 return err;
3121 } 3010 }
3122 } 3011 }
3123 ok = re_node_set_insert (&union_set, next_node); 3012 ok = re_node_set_insert (&union_set, next_node);
3124 if (BE (! ok, 0)) 3013 if (__glibc_unlikely (! ok))
3125 { 3014 {
3126 re_node_set_free (&union_set); 3015 re_node_set_free (&union_set);
3127 return REG_ESPACE; 3016 return REG_ESPACE;
3128 } 3017 }
3129 mctx->state_log[next_idx] = re_acquire_state (&err, dfa, 3018 mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
3130 &union_set); 3019 &union_set);
3131 if (BE (mctx->state_log[next_idx] == NULL 3020 if (__glibc_unlikely (mctx->state_log[next_idx] == NULL
3132 && err != REG_NOERROR, 0)) 3021 && err != REG_NOERROR))
3133 { 3022 {
3134 re_node_set_free (&union_set); 3023 re_node_set_free (&union_set);
3135 return err; 3024 return err;
3136 } 3025 }
3137 } 3026 }
3138 } 3027 }
3139#endif /* RE_ENABLE_I18N */ 3028
3140 if (naccepted 3029 if (naccepted
3141 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) 3030 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
3142 { 3031 {
3143 ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); 3032 ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
3144 if (BE (! ok, 0)) 3033 if (__glibc_unlikely (! ok))
3145 { 3034 {
3146 re_node_set_free (&union_set); 3035 re_node_set_free (&union_set);
3147 return REG_ESPACE; 3036 return REG_ESPACE;
@@ -3159,18 +3048,15 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3159*/ 3048*/
3160 3049
3161static reg_errcode_t 3050static reg_errcode_t
3162internal_function
3163check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, 3051check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3164 Idx ex_subexp, int type) 3052 Idx ex_subexp, int type)
3165{ 3053{
3166 reg_errcode_t err; 3054 reg_errcode_t err;
3167 Idx idx, outside_node; 3055 Idx idx, outside_node;
3168 re_node_set new_nodes; 3056 re_node_set new_nodes;
3169#ifdef DEBUG 3057 DEBUG_ASSERT (cur_nodes->nelem);
3170 assert (cur_nodes->nelem);
3171#endif
3172 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); 3058 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
3173 if (BE (err != REG_NOERROR, 0)) 3059 if (__glibc_unlikely (err != REG_NOERROR))
3174 return err; 3060 return err;
3175 /* Create a new node set NEW_NODES with the nodes which are epsilon 3061 /* Create a new node set NEW_NODES with the nodes which are epsilon
3176 closures of the node in CUR_NODES. */ 3062 closures of the node in CUR_NODES. */
@@ -3180,11 +3066,11 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3180 Idx cur_node = cur_nodes->elems[idx]; 3066 Idx cur_node = cur_nodes->elems[idx];
3181 const re_node_set *eclosure = dfa->eclosures + cur_node; 3067 const re_node_set *eclosure = dfa->eclosures + cur_node;
3182 outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); 3068 outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
3183 if (outside_node == REG_MISSING) 3069 if (outside_node == -1)
3184 { 3070 {
3185 /* There are no problematic nodes, just merge them. */ 3071 /* There are no problematic nodes, just merge them. */
3186 err = re_node_set_merge (&new_nodes, eclosure); 3072 err = re_node_set_merge (&new_nodes, eclosure);
3187 if (BE (err != REG_NOERROR, 0)) 3073 if (__glibc_unlikely (err != REG_NOERROR))
3188 { 3074 {
3189 re_node_set_free (&new_nodes); 3075 re_node_set_free (&new_nodes);
3190 return err; 3076 return err;
@@ -3195,7 +3081,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3195 /* There are problematic nodes, re-calculate incrementally. */ 3081 /* There are problematic nodes, re-calculate incrementally. */
3196 err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, 3082 err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
3197 ex_subexp, type); 3083 ex_subexp, type);
3198 if (BE (err != REG_NOERROR, 0)) 3084 if (__glibc_unlikely (err != REG_NOERROR))
3199 { 3085 {
3200 re_node_set_free (&new_nodes); 3086 re_node_set_free (&new_nodes);
3201 return err; 3087 return err;
@@ -3212,7 +3098,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3212 problematic append it to DST_NODES. */ 3098 problematic append it to DST_NODES. */
3213 3099
3214static reg_errcode_t 3100static reg_errcode_t
3215internal_function __attribute_warn_unused_result__ 3101__attribute_warn_unused_result__
3216check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, 3102check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3217 Idx target, Idx ex_subexp, int type) 3103 Idx target, Idx ex_subexp, int type)
3218{ 3104{
@@ -3227,13 +3113,13 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3227 if (type == OP_CLOSE_SUBEXP) 3113 if (type == OP_CLOSE_SUBEXP)
3228 { 3114 {
3229 ok = re_node_set_insert (dst_nodes, cur_node); 3115 ok = re_node_set_insert (dst_nodes, cur_node);
3230 if (BE (! ok, 0)) 3116 if (__glibc_unlikely (! ok))
3231 return REG_ESPACE; 3117 return REG_ESPACE;
3232 } 3118 }
3233 break; 3119 break;
3234 } 3120 }
3235 ok = re_node_set_insert (dst_nodes, cur_node); 3121 ok = re_node_set_insert (dst_nodes, cur_node);
3236 if (BE (! ok, 0)) 3122 if (__glibc_unlikely (! ok))
3237 return REG_ESPACE; 3123 return REG_ESPACE;
3238 if (dfa->edests[cur_node].nelem == 0) 3124 if (dfa->edests[cur_node].nelem == 0)
3239 break; 3125 break;
@@ -3243,7 +3129,7 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3243 err = check_arrival_expand_ecl_sub (dfa, dst_nodes, 3129 err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
3244 dfa->edests[cur_node].elems[1], 3130 dfa->edests[cur_node].elems[1],
3245 ex_subexp, type); 3131 ex_subexp, type);
3246 if (BE (err != REG_NOERROR, 0)) 3132 if (__glibc_unlikely (err != REG_NOERROR))
3247 return err; 3133 return err;
3248 } 3134 }
3249 cur_node = dfa->edests[cur_node].elems[0]; 3135 cur_node = dfa->edests[cur_node].elems[0];
@@ -3257,7 +3143,7 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3257 in MCTX->BKREF_ENTS. */ 3143 in MCTX->BKREF_ENTS. */
3258 3144
3259static reg_errcode_t 3145static reg_errcode_t
3260internal_function __attribute_warn_unused_result__ 3146__attribute_warn_unused_result__
3261expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, 3147expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3262 Idx cur_str, Idx subexp_num, int type) 3148 Idx cur_str, Idx subexp_num, int type)
3263{ 3149{
@@ -3266,7 +3152,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3266 Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str); 3152 Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
3267 struct re_backref_cache_entry *ent; 3153 struct re_backref_cache_entry *ent;
3268 3154
3269 if (cache_idx_start == REG_MISSING) 3155 if (cache_idx_start == -1)
3270 return REG_NOERROR; 3156 return REG_NOERROR;
3271 3157
3272 restart: 3158 restart:
@@ -3295,8 +3181,8 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3295 err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); 3181 err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
3296 err3 = re_node_set_merge (cur_nodes, &new_dests); 3182 err3 = re_node_set_merge (cur_nodes, &new_dests);
3297 re_node_set_free (&new_dests); 3183 re_node_set_free (&new_dests);
3298 if (BE (err != REG_NOERROR || err2 != REG_NOERROR 3184 if (__glibc_unlikely (err != REG_NOERROR || err2 != REG_NOERROR
3299 || err3 != REG_NOERROR, 0)) 3185 || err3 != REG_NOERROR))
3300 { 3186 {
3301 err = (err != REG_NOERROR ? err 3187 err = (err != REG_NOERROR ? err
3302 : (err2 != REG_NOERROR ? err2 : err3)); 3188 : (err2 != REG_NOERROR ? err2 : err3));
@@ -3318,7 +3204,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3318 err = re_node_set_init_copy (&union_set, 3204 err = re_node_set_init_copy (&union_set,
3319 &mctx->state_log[to_idx]->nodes); 3205 &mctx->state_log[to_idx]->nodes);
3320 ok = re_node_set_insert (&union_set, next_node); 3206 ok = re_node_set_insert (&union_set, next_node);
3321 if (BE (err != REG_NOERROR || ! ok, 0)) 3207 if (__glibc_unlikely (err != REG_NOERROR || ! ok))
3322 { 3208 {
3323 re_node_set_free (&union_set); 3209 re_node_set_free (&union_set);
3324 err = err != REG_NOERROR ? err : REG_ESPACE; 3210 err = err != REG_NOERROR ? err : REG_ESPACE;
@@ -3328,13 +3214,13 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3328 else 3214 else
3329 { 3215 {
3330 err = re_node_set_init_1 (&union_set, next_node); 3216 err = re_node_set_init_1 (&union_set, next_node);
3331 if (BE (err != REG_NOERROR, 0)) 3217 if (__glibc_unlikely (err != REG_NOERROR))
3332 return err; 3218 return err;
3333 } 3219 }
3334 mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); 3220 mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
3335 re_node_set_free (&union_set); 3221 re_node_set_free (&union_set);
3336 if (BE (mctx->state_log[to_idx] == NULL 3222 if (__glibc_unlikely (mctx->state_log[to_idx] == NULL
3337 && err != REG_NOERROR, 0)) 3223 && err != REG_NOERROR))
3338 return err; 3224 return err;
3339 } 3225 }
3340 } 3226 }
@@ -3345,8 +3231,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3345/* Build transition table for the state. 3231/* Build transition table for the state.
3346 Return true if successful. */ 3232 Return true if successful. */
3347 3233
3348static bool 3234static bool __attribute_noinline__
3349internal_function
3350build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) 3235build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3351{ 3236{
3352 reg_errcode_t err; 3237 reg_errcode_t err;
@@ -3354,36 +3239,20 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3354 int ch; 3239 int ch;
3355 bool need_word_trtable = false; 3240 bool need_word_trtable = false;
3356 bitset_word_t elem, mask; 3241 bitset_word_t elem, mask;
3357 bool dests_node_malloced = false;
3358 bool dest_states_malloced = false;
3359 Idx ndests; /* Number of the destination states from 'state'. */ 3242 Idx ndests; /* Number of the destination states from 'state'. */
3360 re_dfastate_t **trtable; 3243 re_dfastate_t **trtable;
3361 re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl; 3244 re_dfastate_t *dest_states[SBC_MAX];
3362 re_node_set follows, *dests_node; 3245 re_dfastate_t *dest_states_word[SBC_MAX];
3363 bitset_t *dests_ch; 3246 re_dfastate_t *dest_states_nl[SBC_MAX];
3247 re_node_set follows;
3364 bitset_t acceptable; 3248 bitset_t acceptable;
3365 3249
3366 struct dests_alloc
3367 {
3368 re_node_set dests_node[SBC_MAX];
3369 bitset_t dests_ch[SBC_MAX];
3370 } *dests_alloc;
3371
3372 /* We build DFA states which corresponds to the destination nodes 3250 /* We build DFA states which corresponds to the destination nodes
3373 from 'state'. 'dests_node[i]' represents the nodes which i-th 3251 from 'state'. 'dests_node[i]' represents the nodes which i-th
3374 destination state contains, and 'dests_ch[i]' represents the 3252 destination state contains, and 'dests_ch[i]' represents the
3375 characters which i-th destination state accepts. */ 3253 characters which i-th destination state accepts. */
3376 if (__libc_use_alloca (sizeof (struct dests_alloc))) 3254 re_node_set dests_node[SBC_MAX];
3377 dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc)); 3255 bitset_t dests_ch[SBC_MAX];
3378 else
3379 {
3380 dests_alloc = re_malloc (struct dests_alloc, 1);
3381 if (BE (dests_alloc == NULL, 0))
3382 return false;
3383 dests_node_malloced = true;
3384 }
3385 dests_node = dests_alloc->dests_node;
3386 dests_ch = dests_alloc->dests_ch;
3387 3256
3388 /* Initialize transition table. */ 3257 /* Initialize transition table. */
3389 state->word_trtable = state->trtable = NULL; 3258 state->word_trtable = state->trtable = NULL;
@@ -3391,16 +3260,14 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3391 /* At first, group all nodes belonging to 'state' into several 3260 /* At first, group all nodes belonging to 'state' into several
3392 destinations. */ 3261 destinations. */
3393 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); 3262 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
3394 if (BE (! REG_VALID_NONZERO_INDEX (ndests), 0)) 3263 if (__glibc_unlikely (ndests <= 0))
3395 { 3264 {
3396 if (dests_node_malloced)
3397 free (dests_alloc);
3398 /* Return false in case of an error, true otherwise. */ 3265 /* Return false in case of an error, true otherwise. */
3399 if (ndests == 0) 3266 if (ndests == 0)
3400 { 3267 {
3401 state->trtable = (re_dfastate_t **) 3268 state->trtable = (re_dfastate_t **)
3402 calloc (sizeof (re_dfastate_t *), SBC_MAX); 3269 calloc (sizeof (re_dfastate_t *), SBC_MAX);
3403 if (BE (state->trtable == NULL, 0)) 3270 if (__glibc_unlikely (state->trtable == NULL))
3404 return false; 3271 return false;
3405 return true; 3272 return true;
3406 } 3273 }
@@ -3408,40 +3275,15 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3408 } 3275 }
3409 3276
3410 err = re_node_set_alloc (&follows, ndests + 1); 3277 err = re_node_set_alloc (&follows, ndests + 1);
3411 if (BE (err != REG_NOERROR, 0)) 3278 if (__glibc_unlikely (err != REG_NOERROR))
3412 goto out_free;
3413
3414 /* Avoid arithmetic overflow in size calculation. */
3415 if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
3416 / (3 * sizeof (re_dfastate_t *)))
3417 < ndests),
3418 0))
3419 goto out_free;
3420
3421 if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
3422 + ndests * 3 * sizeof (re_dfastate_t *)))
3423 dest_states = (re_dfastate_t **)
3424 alloca (ndests * 3 * sizeof (re_dfastate_t *));
3425 else
3426 { 3279 {
3427 dest_states = (re_dfastate_t **) 3280 out_free:
3428 malloc (ndests * 3 * sizeof (re_dfastate_t *)); 3281 re_node_set_free (&follows);
3429 if (BE (dest_states == NULL, 0)) 3282 for (i = 0; i < ndests; ++i)
3430 { 3283 re_node_set_free (dests_node + i);
3431out_free: 3284 return false;
3432 if (dest_states_malloced)
3433 free (dest_states);
3434 re_node_set_free (&follows);
3435 for (i = 0; i < ndests; ++i)
3436 re_node_set_free (dests_node + i);
3437 if (dests_node_malloced)
3438 free (dests_alloc);
3439 return false;
3440 }
3441 dest_states_malloced = true;
3442 } 3285 }
3443 dest_states_word = dest_states + ndests; 3286
3444 dest_states_nl = dest_states_word + ndests;
3445 bitset_empty (acceptable); 3287 bitset_empty (acceptable);
3446 3288
3447 /* Then build the states for all destinations. */ 3289 /* Then build the states for all destinations. */
@@ -3453,15 +3295,15 @@ out_free:
3453 for (j = 0; j < dests_node[i].nelem; ++j) 3295 for (j = 0; j < dests_node[i].nelem; ++j)
3454 { 3296 {
3455 next_node = dfa->nexts[dests_node[i].elems[j]]; 3297 next_node = dfa->nexts[dests_node[i].elems[j]];
3456 if (next_node != REG_MISSING) 3298 if (next_node != -1)
3457 { 3299 {
3458 err = re_node_set_merge (&follows, dfa->eclosures + next_node); 3300 err = re_node_set_merge (&follows, dfa->eclosures + next_node);
3459 if (BE (err != REG_NOERROR, 0)) 3301 if (__glibc_unlikely (err != REG_NOERROR))
3460 goto out_free; 3302 goto out_free;
3461 } 3303 }
3462 } 3304 }
3463 dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); 3305 dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
3464 if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0)) 3306 if (__glibc_unlikely (dest_states[i] == NULL && err != REG_NOERROR))
3465 goto out_free; 3307 goto out_free;
3466 /* If the new state has context constraint, 3308 /* If the new state has context constraint,
3467 build appropriate states for these contexts. */ 3309 build appropriate states for these contexts. */
@@ -3469,7 +3311,8 @@ out_free:
3469 { 3311 {
3470 dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, 3312 dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
3471 CONTEXT_WORD); 3313 CONTEXT_WORD);
3472 if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0)) 3314 if (__glibc_unlikely (dest_states_word[i] == NULL
3315 && err != REG_NOERROR))
3473 goto out_free; 3316 goto out_free;
3474 3317
3475 if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) 3318 if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
@@ -3477,7 +3320,7 @@ out_free:
3477 3320
3478 dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, 3321 dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
3479 CONTEXT_NEWLINE); 3322 CONTEXT_NEWLINE);
3480 if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) 3323 if (__glibc_unlikely (dest_states_nl[i] == NULL && err != REG_NOERROR))
3481 goto out_free; 3324 goto out_free;
3482 } 3325 }
3483 else 3326 else
@@ -3488,7 +3331,7 @@ out_free:
3488 bitset_merge (acceptable, dests_ch[i]); 3331 bitset_merge (acceptable, dests_ch[i]);
3489 } 3332 }
3490 3333
3491 if (!BE (need_word_trtable, 0)) 3334 if (!__glibc_unlikely (need_word_trtable))
3492 { 3335 {
3493 /* We don't care about whether the following character is a word 3336 /* We don't care about whether the following character is a word
3494 character, or we are in a single-byte character set so we can 3337 character, or we are in a single-byte character set so we can
@@ -3496,7 +3339,7 @@ out_free:
3496 256-entry transition table. */ 3339 256-entry transition table. */
3497 trtable = state->trtable = 3340 trtable = state->trtable =
3498 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); 3341 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
3499 if (BE (trtable == NULL, 0)) 3342 if (__glibc_unlikely (trtable == NULL))
3500 goto out_free; 3343 goto out_free;
3501 3344
3502 /* For all characters ch...: */ 3345 /* For all characters ch...: */
@@ -3504,7 +3347,7 @@ out_free:
3504 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; 3347 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
3505 elem; 3348 elem;
3506 mask <<= 1, elem >>= 1, ++ch) 3349 mask <<= 1, elem >>= 1, ++ch)
3507 if (BE (elem & 1, 0)) 3350 if (__glibc_unlikely (elem & 1))
3508 { 3351 {
3509 /* There must be exactly one destination which accepts 3352 /* There must be exactly one destination which accepts
3510 character ch. See group_nodes_into_DFAstates. */ 3353 character ch. See group_nodes_into_DFAstates. */
@@ -3527,7 +3370,7 @@ out_free:
3527 starting at trtable[SBC_MAX]. */ 3370 starting at trtable[SBC_MAX]. */
3528 trtable = state->word_trtable = 3371 trtable = state->word_trtable =
3529 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); 3372 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
3530 if (BE (trtable == NULL, 0)) 3373 if (__glibc_unlikely (trtable == NULL))
3531 goto out_free; 3374 goto out_free;
3532 3375
3533 /* For all characters ch...: */ 3376 /* For all characters ch...: */
@@ -3535,7 +3378,7 @@ out_free:
3535 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; 3378 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
3536 elem; 3379 elem;
3537 mask <<= 1, elem >>= 1, ++ch) 3380 mask <<= 1, elem >>= 1, ++ch)
3538 if (BE (elem & 1, 0)) 3381 if (__glibc_unlikely (elem & 1))
3539 { 3382 {
3540 /* There must be exactly one destination which accepts 3383 /* There must be exactly one destination which accepts
3541 character ch. See group_nodes_into_DFAstates. */ 3384 character ch. See group_nodes_into_DFAstates. */
@@ -3565,26 +3408,19 @@ out_free:
3565 } 3408 }
3566 } 3409 }
3567 3410
3568 if (dest_states_malloced)
3569 free (dest_states);
3570
3571 re_node_set_free (&follows); 3411 re_node_set_free (&follows);
3572 for (i = 0; i < ndests; ++i) 3412 for (i = 0; i < ndests; ++i)
3573 re_node_set_free (dests_node + i); 3413 re_node_set_free (dests_node + i);
3574
3575 if (dests_node_malloced)
3576 free (dests_alloc);
3577
3578 return true; 3414 return true;
3579} 3415}
3580 3416
3581/* Group all nodes belonging to STATE into several destinations. 3417/* Group all nodes belonging to STATE into several destinations.
3582 Then for all destinations, set the nodes belonging to the destination 3418 Then for all destinations, set the nodes belonging to the destination
3583 to DESTS_NODE[i] and set the characters accepted by the destination 3419 to DESTS_NODE[i] and set the characters accepted by the destination
3584 to DEST_CH[i]. This function return the number of destinations. */ 3420 to DEST_CH[i]. Return the number of destinations if successful,
3421 -1 on internal error. */
3585 3422
3586static Idx 3423static Idx
3587internal_function
3588group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, 3424group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3589 re_node_set *dests_node, bitset_t *dests_ch) 3425 re_node_set *dests_node, bitset_t *dests_ch)
3590{ 3426{
@@ -3613,18 +3449,15 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3613 } 3449 }
3614 else if (type == OP_PERIOD) 3450 else if (type == OP_PERIOD)
3615 { 3451 {
3616#ifdef RE_ENABLE_I18N
3617 if (dfa->mb_cur_max > 1) 3452 if (dfa->mb_cur_max > 1)
3618 bitset_merge (accepts, dfa->sb_char); 3453 bitset_merge (accepts, dfa->sb_char);
3619 else 3454 else
3620#endif
3621 bitset_set_all (accepts); 3455 bitset_set_all (accepts);
3622 if (!(dfa->syntax & RE_DOT_NEWLINE)) 3456 if (!(dfa->syntax & RE_DOT_NEWLINE))
3623 bitset_clear (accepts, '\n'); 3457 bitset_clear (accepts, '\n');
3624 if (dfa->syntax & RE_DOT_NOT_NULL) 3458 if (dfa->syntax & RE_DOT_NOT_NULL)
3625 bitset_clear (accepts, '\0'); 3459 bitset_clear (accepts, '\0');
3626 } 3460 }
3627#ifdef RE_ENABLE_I18N
3628 else if (type == OP_UTF8_PERIOD) 3461 else if (type == OP_UTF8_PERIOD)
3629 { 3462 {
3630 if (ASCII_CHARS % BITSET_WORD_BITS == 0) 3463 if (ASCII_CHARS % BITSET_WORD_BITS == 0)
@@ -3636,7 +3469,6 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3636 if (dfa->syntax & RE_DOT_NOT_NULL) 3469 if (dfa->syntax & RE_DOT_NOT_NULL)
3637 bitset_clear (accepts, '\0'); 3470 bitset_clear (accepts, '\0');
3638 } 3471 }
3639#endif
3640 else 3472 else
3641 continue; 3473 continue;
3642 3474
@@ -3667,12 +3499,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3667 bitset_empty (accepts); 3499 bitset_empty (accepts);
3668 continue; 3500 continue;
3669 } 3501 }
3670#ifdef RE_ENABLE_I18N
3671 if (dfa->mb_cur_max > 1) 3502 if (dfa->mb_cur_max > 1)
3672 for (j = 0; j < BITSET_WORDS; ++j) 3503 for (j = 0; j < BITSET_WORDS; ++j)
3673 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); 3504 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
3674 else 3505 else
3675#endif
3676 for (j = 0; j < BITSET_WORDS; ++j) 3506 for (j = 0; j < BITSET_WORDS; ++j)
3677 any_set |= (accepts[j] &= dfa->word_char[j]); 3507 any_set |= (accepts[j] &= dfa->word_char[j]);
3678 if (!any_set) 3508 if (!any_set)
@@ -3686,12 +3516,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3686 bitset_empty (accepts); 3516 bitset_empty (accepts);
3687 continue; 3517 continue;
3688 } 3518 }
3689#ifdef RE_ENABLE_I18N
3690 if (dfa->mb_cur_max > 1) 3519 if (dfa->mb_cur_max > 1)
3691 for (j = 0; j < BITSET_WORDS; ++j) 3520 for (j = 0; j < BITSET_WORDS; ++j)
3692 any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); 3521 any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
3693 else 3522 else
3694#endif
3695 for (j = 0; j < BITSET_WORDS; ++j) 3523 for (j = 0; j < BITSET_WORDS; ++j)
3696 any_set |= (accepts[j] &= ~dfa->word_char[j]); 3524 any_set |= (accepts[j] &= ~dfa->word_char[j]);
3697 if (!any_set) 3525 if (!any_set)
@@ -3735,14 +3563,14 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3735 bitset_copy (dests_ch[ndests], remains); 3563 bitset_copy (dests_ch[ndests], remains);
3736 bitset_copy (dests_ch[j], intersec); 3564 bitset_copy (dests_ch[j], intersec);
3737 err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); 3565 err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
3738 if (BE (err != REG_NOERROR, 0)) 3566 if (__glibc_unlikely (err != REG_NOERROR))
3739 goto error_return; 3567 goto error_return;
3740 ++ndests; 3568 ++ndests;
3741 } 3569 }
3742 3570
3743 /* Put the position in the current group. */ 3571 /* Put the position in the current group. */
3744 ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); 3572 ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
3745 if (BE (! ok, 0)) 3573 if (__glibc_unlikely (! ok))
3746 goto error_return; 3574 goto error_return;
3747 3575
3748 /* If all characters are consumed, go to next node. */ 3576 /* If all characters are consumed, go to next node. */
@@ -3754,20 +3582,20 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3754 { 3582 {
3755 bitset_copy (dests_ch[ndests], accepts); 3583 bitset_copy (dests_ch[ndests], accepts);
3756 err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); 3584 err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
3757 if (BE (err != REG_NOERROR, 0)) 3585 if (__glibc_unlikely (err != REG_NOERROR))
3758 goto error_return; 3586 goto error_return;
3759 ++ndests; 3587 ++ndests;
3760 bitset_empty (accepts); 3588 bitset_empty (accepts);
3761 } 3589 }
3762 } 3590 }
3591 assume (ndests <= SBC_MAX);
3763 return ndests; 3592 return ndests;
3764 error_return: 3593 error_return:
3765 for (j = 0; j < ndests; ++j) 3594 for (j = 0; j < ndests; ++j)
3766 re_node_set_free (dests_node + j); 3595 re_node_set_free (dests_node + j);
3767 return REG_MISSING; 3596 return -1;
3768} 3597}
3769 3598
3770#ifdef RE_ENABLE_I18N
3771/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts. 3599/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts.
3772 Return the number of the bytes the node accepts. 3600 Return the number of the bytes the node accepts.
3773 STR_IDX is the current index of the input string. 3601 STR_IDX is the current index of the input string.
@@ -3776,8 +3604,11 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3776 one collating element like '.', '[a-z]', opposite to the other nodes 3604 one collating element like '.', '[a-z]', opposite to the other nodes
3777 can only accept one byte. */ 3605 can only accept one byte. */
3778 3606
3607#ifdef _LIBC
3608# include <locale/weight.h>
3609#endif
3610
3779static int 3611static int
3780internal_function
3781check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, 3612check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3782 const re_string_t *input, Idx str_idx) 3613 const re_string_t *input, Idx str_idx)
3783{ 3614{
@@ -3785,10 +3616,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3785 int char_len, elem_len; 3616 int char_len, elem_len;
3786 Idx i; 3617 Idx i;
3787 3618
3788 if (BE (node->type == OP_UTF8_PERIOD, 0)) 3619 if (__glibc_unlikely (node->type == OP_UTF8_PERIOD))
3789 { 3620 {
3790 unsigned char c = re_string_byte_at (input, str_idx), d; 3621 unsigned char c = re_string_byte_at (input, str_idx), d;
3791 if (BE (c < 0xc2, 1)) 3622 if (__glibc_likely (c < 0xc2))
3792 return 0; 3623 return 0;
3793 3624
3794 if (str_idx + 2 > input->len) 3625 if (str_idx + 2 > input->len)
@@ -3844,10 +3675,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3844 /* FIXME: I don't think this if is needed, as both '\n' 3675 /* FIXME: I don't think this if is needed, as both '\n'
3845 and '\0' are char_len == 1. */ 3676 and '\0' are char_len == 1. */
3846 /* '.' accepts any one character except the following two cases. */ 3677 /* '.' accepts any one character except the following two cases. */
3847 if ((!(dfa->syntax & RE_DOT_NEWLINE) && 3678 if ((!(dfa->syntax & RE_DOT_NEWLINE)
3848 re_string_byte_at (input, str_idx) == '\n') || 3679 && re_string_byte_at (input, str_idx) == '\n')
3849 ((dfa->syntax & RE_DOT_NOT_NULL) && 3680 || ((dfa->syntax & RE_DOT_NOT_NULL)
3850 re_string_byte_at (input, str_idx) == '\0')) 3681 && re_string_byte_at (input, str_idx) == '\0'))
3851 return 0; 3682 return 0;
3852 return char_len; 3683 return char_len;
3853 } 3684 }
@@ -3859,12 +3690,12 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3859 if (node->type == COMPLEX_BRACKET) 3690 if (node->type == COMPLEX_BRACKET)
3860 { 3691 {
3861 const re_charset_t *cset = node->opr.mbcset; 3692 const re_charset_t *cset = node->opr.mbcset;
3862# ifdef _LIBC 3693#ifdef _LIBC
3863 const unsigned char *pin 3694 const unsigned char *pin
3864 = ((const unsigned char *) re_string_get_buffer (input) + str_idx); 3695 = ((const unsigned char *) re_string_get_buffer (input) + str_idx);
3865 Idx j; 3696 Idx j;
3866 uint32_t nrules; 3697 uint32_t nrules;
3867# endif /* _LIBC */ 3698#endif
3868 int match_len = 0; 3699 int match_len = 0;
3869 wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) 3700 wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
3870 ? re_string_wchar_at (input, str_idx) : 0); 3701 ? re_string_wchar_at (input, str_idx) : 0);
@@ -3887,7 +3718,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3887 } 3718 }
3888 } 3719 }
3889 3720
3890# ifdef _LIBC 3721#ifdef _LIBC
3891 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3722 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
3892 if (nrules != 0) 3723 if (nrules != 0)
3893 { 3724 {
@@ -3895,8 +3726,6 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3895 const int32_t *table, *indirect; 3726 const int32_t *table, *indirect;
3896 const unsigned char *weights, *extra; 3727 const unsigned char *weights, *extra;
3897 const char *collseqwc; 3728 const char *collseqwc;
3898 /* This #include defines a local function! */
3899# include <locale/weight.h>
3900 3729
3901 /* match with collating_symbol? */ 3730 /* match with collating_symbol? */
3902 if (cset->ncoll_syms) 3731 if (cset->ncoll_syms)
@@ -3953,35 +3782,32 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3953 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); 3782 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
3954 indirect = (const int32_t *) 3783 indirect = (const int32_t *)
3955 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); 3784 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
3956 int32_t idx = findidx (&cp, elem_len); 3785 int32_t idx = findidx (table, indirect, extra, &cp, elem_len);
3786 int32_t rule = idx >> 24;
3787 idx &= 0xffffff;
3957 if (idx > 0) 3788 if (idx > 0)
3958 for (i = 0; i < cset->nequiv_classes; ++i) 3789 {
3959 { 3790 size_t weight_len = weights[idx];
3960 int32_t equiv_class_idx = cset->equiv_classes[i]; 3791 for (i = 0; i < cset->nequiv_classes; ++i)
3961 size_t weight_len = weights[idx & 0xffffff]; 3792 {
3962 if (weight_len == weights[equiv_class_idx & 0xffffff] 3793 int32_t equiv_class_idx = cset->equiv_classes[i];
3963 && (idx >> 24) == (equiv_class_idx >> 24)) 3794 int32_t equiv_class_rule = equiv_class_idx >> 24;
3964 { 3795 equiv_class_idx &= 0xffffff;
3965 Idx cnt = 0; 3796 if (weights[equiv_class_idx] == weight_len
3966 3797 && equiv_class_rule == rule
3967 idx &= 0xffffff; 3798 && memcmp (weights + idx + 1,
3968 equiv_class_idx &= 0xffffff; 3799 weights + equiv_class_idx + 1,
3969 3800 weight_len) == 0)
3970 while (cnt <= weight_len 3801 {
3971 && (weights[equiv_class_idx + 1 + cnt] 3802 match_len = elem_len;
3972 == weights[idx + 1 + cnt])) 3803 goto check_node_accept_bytes_match;
3973 ++cnt; 3804 }
3974 if (cnt > weight_len) 3805 }
3975 { 3806 }
3976 match_len = elem_len;
3977 goto check_node_accept_bytes_match;
3978 }
3979 }
3980 }
3981 } 3807 }
3982 } 3808 }
3983 else 3809 else
3984# endif /* _LIBC */ 3810#endif /* _LIBC */
3985 { 3811 {
3986 /* match with range expression? */ 3812 /* match with range expression? */
3987 for (i = 0; i < cset->nranges; ++i) 3813 for (i = 0; i < cset->nranges; ++i)
@@ -4007,9 +3833,8 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
4007 return 0; 3833 return 0;
4008} 3834}
4009 3835
4010# ifdef _LIBC 3836#ifdef _LIBC
4011static unsigned int 3837static unsigned int
4012internal_function
4013find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) 3838find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
4014{ 3839{
4015 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3840 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -4066,14 +3891,12 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
4066 return UINT_MAX; 3891 return UINT_MAX;
4067 } 3892 }
4068} 3893}
4069# endif /* _LIBC */ 3894#endif /* _LIBC */
4070#endif /* RE_ENABLE_I18N */
4071 3895
4072/* Check whether the node accepts the byte which is IDX-th 3896/* Check whether the node accepts the byte which is IDX-th
4073 byte of the INPUT. */ 3897 byte of the INPUT. */
4074 3898
4075static bool 3899static bool
4076internal_function
4077check_node_accept (const re_match_context_t *mctx, const re_token_t *node, 3900check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4078 Idx idx) 3901 Idx idx)
4079{ 3902{
@@ -4091,12 +3914,10 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4091 return false; 3914 return false;
4092 break; 3915 break;
4093 3916
4094#ifdef RE_ENABLE_I18N
4095 case OP_UTF8_PERIOD: 3917 case OP_UTF8_PERIOD:
4096 if (ch >= ASCII_CHARS) 3918 if (ch >= ASCII_CHARS)
4097 return false; 3919 return false;
4098 /* FALLTHROUGH */ 3920 FALLTHROUGH;
4099#endif
4100 case OP_PERIOD: 3921 case OP_PERIOD:
4101 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) 3922 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
4102 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) 3923 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
@@ -4123,22 +3944,22 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4123/* Extend the buffers, if the buffers have run out. */ 3944/* Extend the buffers, if the buffers have run out. */
4124 3945
4125static reg_errcode_t 3946static reg_errcode_t
4126internal_function __attribute_warn_unused_result__ 3947__attribute_warn_unused_result__
4127extend_buffers (re_match_context_t *mctx, int min_len) 3948extend_buffers (re_match_context_t *mctx, int min_len)
4128{ 3949{
4129 reg_errcode_t ret; 3950 reg_errcode_t ret;
4130 re_string_t *pstr = &mctx->input; 3951 re_string_t *pstr = &mctx->input;
4131 3952
4132 /* Avoid overflow. */ 3953 /* Avoid overflow. */
4133 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2 3954 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
4134 <= pstr->bufs_len, 0)) 3955 <= pstr->bufs_len))
4135 return REG_ESPACE; 3956 return REG_ESPACE;
4136 3957
4137 /* Double the lengths of the buffers, but allocate at least MIN_LEN. */ 3958 /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
4138 ret = re_string_realloc_buffers (pstr, 3959 ret = re_string_realloc_buffers (pstr,
4139 MAX (min_len, 3960 MAX (min_len,
4140 MIN (pstr->len, pstr->bufs_len * 2))); 3961 MIN (pstr->len, pstr->bufs_len * 2)));
4141 if (BE (ret != REG_NOERROR, 0)) 3962 if (__glibc_unlikely (ret != REG_NOERROR))
4142 return ret; 3963 return ret;
4143 3964
4144 if (mctx->state_log != NULL) 3965 if (mctx->state_log != NULL)
@@ -4149,7 +3970,7 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4149 does not have the right size. */ 3970 does not have the right size. */
4150 re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, 3971 re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
4151 pstr->bufs_len + 1); 3972 pstr->bufs_len + 1);
4152 if (BE (new_array == NULL, 0)) 3973 if (__glibc_unlikely (new_array == NULL))
4153 return REG_ESPACE; 3974 return REG_ESPACE;
4154 mctx->state_log = new_array; 3975 mctx->state_log = new_array;
4155 } 3976 }
@@ -4157,24 +3978,20 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4157 /* Then reconstruct the buffers. */ 3978 /* Then reconstruct the buffers. */
4158 if (pstr->icase) 3979 if (pstr->icase)
4159 { 3980 {
4160#ifdef RE_ENABLE_I18N
4161 if (pstr->mb_cur_max > 1) 3981 if (pstr->mb_cur_max > 1)
4162 { 3982 {
4163 ret = build_wcs_upper_buffer (pstr); 3983 ret = build_wcs_upper_buffer (pstr);
4164 if (BE (ret != REG_NOERROR, 0)) 3984 if (__glibc_unlikely (ret != REG_NOERROR))
4165 return ret; 3985 return ret;
4166 } 3986 }
4167 else 3987 else
4168#endif /* RE_ENABLE_I18N */
4169 build_upper_buffer (pstr); 3988 build_upper_buffer (pstr);
4170 } 3989 }
4171 else 3990 else
4172 { 3991 {
4173#ifdef RE_ENABLE_I18N
4174 if (pstr->mb_cur_max > 1) 3992 if (pstr->mb_cur_max > 1)
4175 build_wcs_buffer (pstr); 3993 build_wcs_buffer (pstr);
4176 else 3994 else
4177#endif /* RE_ENABLE_I18N */
4178 { 3995 {
4179 if (pstr->trans != NULL) 3996 if (pstr->trans != NULL)
4180 re_string_translate_buffer (pstr); 3997 re_string_translate_buffer (pstr);
@@ -4189,23 +4006,23 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4189/* Initialize MCTX. */ 4006/* Initialize MCTX. */
4190 4007
4191static reg_errcode_t 4008static reg_errcode_t
4192internal_function __attribute_warn_unused_result__ 4009__attribute_warn_unused_result__
4193match_ctx_init (re_match_context_t *mctx, int eflags, Idx n) 4010match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
4194{ 4011{
4195 mctx->eflags = eflags; 4012 mctx->eflags = eflags;
4196 mctx->match_last = REG_MISSING; 4013 mctx->match_last = -1;
4197 if (n > 0) 4014 if (n > 0)
4198 { 4015 {
4199 /* Avoid overflow. */ 4016 /* Avoid overflow. */
4200 size_t max_object_size = 4017 size_t max_object_size =
4201 MAX (sizeof (struct re_backref_cache_entry), 4018 MAX (sizeof (struct re_backref_cache_entry),
4202 sizeof (re_sub_match_top_t *)); 4019 sizeof (re_sub_match_top_t *));
4203 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n, 0)) 4020 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n))
4204 return REG_ESPACE; 4021 return REG_ESPACE;
4205 4022
4206 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); 4023 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
4207 mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); 4024 mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
4208 if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) 4025 if (__glibc_unlikely (mctx->bkref_ents == NULL || mctx->sub_tops == NULL))
4209 return REG_ESPACE; 4026 return REG_ESPACE;
4210 } 4027 }
4211 /* Already zero-ed by the caller. 4028 /* Already zero-ed by the caller.
@@ -4224,7 +4041,6 @@ match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
4224 of the input, or changes the input string. */ 4041 of the input, or changes the input string. */
4225 4042
4226static void 4043static void
4227internal_function
4228match_ctx_clean (re_match_context_t *mctx) 4044match_ctx_clean (re_match_context_t *mctx)
4229{ 4045{
4230 Idx st_idx; 4046 Idx st_idx;
@@ -4244,7 +4060,7 @@ match_ctx_clean (re_match_context_t *mctx)
4244 re_free (top->path->array); 4060 re_free (top->path->array);
4245 re_free (top->path); 4061 re_free (top->path);
4246 } 4062 }
4247 free (top); 4063 re_free (top);
4248 } 4064 }
4249 4065
4250 mctx->nsub_tops = 0; 4066 mctx->nsub_tops = 0;
@@ -4254,7 +4070,6 @@ match_ctx_clean (re_match_context_t *mctx)
4254/* Free all the memory associated with MCTX. */ 4070/* Free all the memory associated with MCTX. */
4255 4071
4256static void 4072static void
4257internal_function
4258match_ctx_free (re_match_context_t *mctx) 4073match_ctx_free (re_match_context_t *mctx)
4259{ 4074{
4260 /* First, free all the memory associated with MCTX->SUB_TOPS. */ 4075 /* First, free all the memory associated with MCTX->SUB_TOPS. */
@@ -4269,7 +4084,7 @@ match_ctx_free (re_match_context_t *mctx)
4269*/ 4084*/
4270 4085
4271static reg_errcode_t 4086static reg_errcode_t
4272internal_function __attribute_warn_unused_result__ 4087__attribute_warn_unused_result__
4273match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from, 4088match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4274 Idx to) 4089 Idx to)
4275{ 4090{
@@ -4278,7 +4093,7 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4278 struct re_backref_cache_entry* new_entry; 4093 struct re_backref_cache_entry* new_entry;
4279 new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, 4094 new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
4280 mctx->abkref_ents * 2); 4095 mctx->abkref_ents * 2);
4281 if (BE (new_entry == NULL, 0)) 4096 if (__glibc_unlikely (new_entry == NULL))
4282 { 4097 {
4283 re_free (mctx->bkref_ents); 4098 re_free (mctx->bkref_ents);
4284 return REG_ESPACE; 4099 return REG_ESPACE;
@@ -4314,11 +4129,10 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4314 return REG_NOERROR; 4129 return REG_NOERROR;
4315} 4130}
4316 4131
4317/* Return the first entry with the same str_idx, or REG_MISSING if none is 4132/* Return the first entry with the same str_idx, or -1 if none is
4318 found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */ 4133 found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
4319 4134
4320static Idx 4135static Idx
4321internal_function
4322search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx) 4136search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
4323{ 4137{
4324 Idx left, right, mid, last; 4138 Idx left, right, mid, last;
@@ -4334,33 +4148,31 @@ search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
4334 if (left < last && mctx->bkref_ents[left].str_idx == str_idx) 4148 if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
4335 return left; 4149 return left;
4336 else 4150 else
4337 return REG_MISSING; 4151 return -1;
4338} 4152}
4339 4153
4340/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches 4154/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
4341 at STR_IDX. */ 4155 at STR_IDX. */
4342 4156
4343static reg_errcode_t 4157static reg_errcode_t
4344internal_function __attribute_warn_unused_result__ 4158__attribute_warn_unused_result__
4345match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx) 4159match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
4346{ 4160{
4347#ifdef DEBUG 4161 DEBUG_ASSERT (mctx->sub_tops != NULL);
4348 assert (mctx->sub_tops != NULL); 4162 DEBUG_ASSERT (mctx->asub_tops > 0);
4349 assert (mctx->asub_tops > 0); 4163 if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops))
4350#endif
4351 if (BE (mctx->nsub_tops == mctx->asub_tops, 0))
4352 { 4164 {
4353 Idx new_asub_tops = mctx->asub_tops * 2; 4165 Idx new_asub_tops = mctx->asub_tops * 2;
4354 re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, 4166 re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
4355 re_sub_match_top_t *, 4167 re_sub_match_top_t *,
4356 new_asub_tops); 4168 new_asub_tops);
4357 if (BE (new_array == NULL, 0)) 4169 if (__glibc_unlikely (new_array == NULL))
4358 return REG_ESPACE; 4170 return REG_ESPACE;
4359 mctx->sub_tops = new_array; 4171 mctx->sub_tops = new_array;
4360 mctx->asub_tops = new_asub_tops; 4172 mctx->asub_tops = new_asub_tops;
4361 } 4173 }
4362 mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); 4174 mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
4363 if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0)) 4175 if (__glibc_unlikely (mctx->sub_tops[mctx->nsub_tops] == NULL))
4364 return REG_ESPACE; 4176 return REG_ESPACE;
4365 mctx->sub_tops[mctx->nsub_tops]->node = node; 4177 mctx->sub_tops[mctx->nsub_tops]->node = node;
4366 mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; 4178 mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
@@ -4368,26 +4180,26 @@ match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
4368} 4180}
4369 4181
4370/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches 4182/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches
4371 at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */ 4183 at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP.
4184 Return the new entry if successful, NULL if memory is exhausted. */
4372 4185
4373static re_sub_match_last_t * 4186static re_sub_match_last_t *
4374internal_function
4375match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx) 4187match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
4376{ 4188{
4377 re_sub_match_last_t *new_entry; 4189 re_sub_match_last_t *new_entry;
4378 if (BE (subtop->nlasts == subtop->alasts, 0)) 4190 if (__glibc_unlikely (subtop->nlasts == subtop->alasts))
4379 { 4191 {
4380 Idx new_alasts = 2 * subtop->alasts + 1; 4192 Idx new_alasts = 2 * subtop->alasts + 1;
4381 re_sub_match_last_t **new_array = re_realloc (subtop->lasts, 4193 re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
4382 re_sub_match_last_t *, 4194 re_sub_match_last_t *,
4383 new_alasts); 4195 new_alasts);
4384 if (BE (new_array == NULL, 0)) 4196 if (__glibc_unlikely (new_array == NULL))
4385 return NULL; 4197 return NULL;
4386 subtop->lasts = new_array; 4198 subtop->lasts = new_array;
4387 subtop->alasts = new_alasts; 4199 subtop->alasts = new_alasts;
4388 } 4200 }
4389 new_entry = calloc (1, sizeof (re_sub_match_last_t)); 4201 new_entry = calloc (1, sizeof (re_sub_match_last_t));
4390 if (BE (new_entry != NULL, 1)) 4202 if (__glibc_likely (new_entry != NULL))
4391 { 4203 {
4392 subtop->lasts[subtop->nlasts] = new_entry; 4204 subtop->lasts[subtop->nlasts] = new_entry;
4393 new_entry->node = node; 4205 new_entry->node = node;
@@ -4398,7 +4210,6 @@ match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
4398} 4210}
4399 4211
4400static void 4212static void
4401internal_function
4402sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, 4213sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
4403 re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx) 4214 re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx)
4404{ 4215{
diff --git a/gl/safe-read.c b/gl/safe-read.c
deleted file mode 100644
index 6a48c0cc..00000000
--- a/gl/safe-read.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/* An interface to read and write that retries after interrupts.
2
3 Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2013 Free Software
4 Foundation, Inc.
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include <config.h>
20
21/* Specification. */
22#ifdef SAFE_WRITE
23# include "safe-write.h"
24#else
25# include "safe-read.h"
26#endif
27
28/* Get ssize_t. */
29#include <sys/types.h>
30#include <unistd.h>
31
32#include <errno.h>
33
34#ifdef EINTR
35# define IS_EINTR(x) ((x) == EINTR)
36#else
37# define IS_EINTR(x) 0
38#endif
39
40#include <limits.h>
41
42#ifdef SAFE_WRITE
43# define safe_rw safe_write
44# define rw write
45#else
46# define safe_rw safe_read
47# define rw read
48# undef const
49# define const /* empty */
50#endif
51
52/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
53 interrupted. Return the actual number of bytes read(written), zero for EOF,
54 or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */
55size_t
56safe_rw (int fd, void const *buf, size_t count)
57{
58 /* Work around a bug in Tru64 5.1. Attempting to read more than
59 INT_MAX bytes fails with errno == EINVAL. See
60 <http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
61 When decreasing COUNT, keep it block-aligned. */
62 enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
63
64 for (;;)
65 {
66 ssize_t result = rw (fd, buf, count);
67
68 if (0 <= result)
69 return result;
70 else if (IS_EINTR (errno))
71 continue;
72 else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
73 count = BUGGY_READ_MAXIMUM;
74 else
75 return result;
76 }
77}
diff --git a/gl/safe-read.h b/gl/safe-read.h
deleted file mode 100644
index 992b7a6a..00000000
--- a/gl/safe-read.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/* An interface to read() that retries after interrupts.
2 Copyright (C) 2002, 2006, 2009-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* Some system calls may be interrupted and fail with errno = EINTR in the
18 following situations:
19 - The process is stopped and restarted (signal SIGSTOP and SIGCONT, user
20 types Ctrl-Z) on some platforms: Mac OS X.
21 - The process receives a signal for which a signal handler was installed
22 with sigaction() with an sa_flags field that does not contain
23 SA_RESTART.
24 - The process receives a signal for which a signal handler was installed
25 with signal() and for which no call to siginterrupt(sig,0) was done,
26 on some platforms: AIX, HP-UX, IRIX, OSF/1, Solaris.
27
28 This module provides a wrapper around read() that handles EINTR. */
29
30#include <stddef.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36
37#define SAFE_READ_ERROR ((size_t) -1)
38
39/* Read up to COUNT bytes at BUF from descriptor FD, retrying if interrupted.
40 Return the actual number of bytes read, zero for EOF, or SAFE_READ_ERROR
41 upon error. */
42extern size_t safe_read (int fd, void *buf, size_t count);
43
44
45#ifdef __cplusplus
46}
47#endif
diff --git a/gl/setenv.c b/gl/setenv.c
index 995a0f26..f0b88996 100644
--- a/gl/setenv.c
+++ b/gl/setenv.c
@@ -1,18 +1,18 @@
1/* Copyright (C) 1992, 1995-2003, 2005-2013 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2003, 2005-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#if !_LIBC 17#if !_LIBC
18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
@@ -72,7 +72,7 @@ __libc_lock_define_initialized (static, envlock)
72 values are from a small set. Outside glibc this will eat up all 72 values are from a small set. Outside glibc this will eat up all
73 memory after a while. */ 73 memory after a while. */
74#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \ 74#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \
75 && defined __GNUC__) 75 && (defined __GNUC__ || defined __clang__))
76# define USE_TSEARCH 1 76# define USE_TSEARCH 1
77# include <search.h> 77# include <search.h>
78typedef int (*compar_fn_t) (const void *, const void *); 78typedef int (*compar_fn_t) (const void *, const void *);
diff --git a/gl/setlocale-lock.c b/gl/setlocale-lock.c
new file mode 100644
index 00000000..b70ba09b
--- /dev/null
+++ b/gl/setlocale-lock.c
@@ -0,0 +1,150 @@
1/* Return the internal lock used by setlocale_null_r.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#include <config.h>
20
21/* When it is known that the gl_get_setlocale_null_lock function is defined
22 by a dependency library, it should not be defined here. */
23#if OMIT_SETLOCALE_LOCK
24
25/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */
27typedef int dummy;
28
29#else
30
31/* This file defines the internal lock used by setlocale_null_r.
32 It is a separate compilation unit, so that only one copy of it is
33 present when linking statically. */
34
35/* Prohibit renaming this symbol. */
36# undef gl_get_setlocale_null_lock
37
38/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */
40# ifndef DLL_EXPORTED
41# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport)
46# else
47# define DLL_EXPORTED
48# endif
49# endif
50
51# if defined _WIN32 && !defined __CYGWIN__
52
53# define WIN32_LEAN_AND_MEAN /* avoid including junk */
54# include <windows.h>
55
56# include "windows-initguard.h"
57
58/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
59 because the latter is not guaranteed to be a stable ABI in the future. */
60
61/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
63
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock;
66
67/* Returns the internal lock used by setlocale_null_r. */
68CRITICAL_SECTION *
69gl_get_setlocale_null_lock (void)
70{
71 if (!guard.done)
72 {
73 if (InterlockedIncrement (&guard.started) == 0)
74 {
75 /* This thread is the first one to need the lock. Initialize it. */
76 InitializeCriticalSection (&lock);
77 guard.done = 1;
78 }
79 else
80 {
81 /* Don't let guard.started grow and wrap around. */
82 InterlockedDecrement (&guard.started);
83 /* Yield the CPU while waiting for another thread to finish
84 initializing this mutex. */
85 while (!guard.done)
86 Sleep (0);
87 }
88 }
89 return &lock;
90}
91
92# elif HAVE_PTHREAD_API
93
94# include <pthread.h>
95
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97
98/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void);
100
101/* Returns the internal lock used by setlocale_null_r. */
102pthread_mutex_t *
103gl_get_setlocale_null_lock (void)
104{
105 return &mutex;
106}
107
108# elif HAVE_THREADS_H
109
110# include <threads.h>
111# include <stdlib.h>
112
113static int volatile init_needed = 1;
114static once_flag init_once = ONCE_FLAG_INIT;
115static mtx_t mutex;
116
117static void
118atomic_init (void)
119{
120 if (mtx_init (&mutex, mtx_plain) != thrd_success)
121 abort ();
122 init_needed = 0;
123}
124
125/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_setlocale_null_lock (void);
127
128/* Returns the internal lock used by setlocale_null_r. */
129mtx_t *
130gl_get_setlocale_null_lock (void)
131{
132 if (init_needed)
133 call_once (&init_once, atomic_init);
134 return &mutex;
135}
136
137# endif
138
139# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
140/* Make sure the '__declspec(dllimport)' in setlocale_null.c does not cause
141 a link failure when no DLLs are involved. */
142# if defined _WIN64 || defined _LP64
143# define IMP(x) __imp_##x
144# else
145# define IMP(x) _imp__##x
146# endif
147void * IMP(gl_get_setlocale_null_lock) = &gl_get_setlocale_null_lock;
148# endif
149
150#endif
diff --git a/gl/setlocale_null.c b/gl/setlocale_null.c
new file mode 100644
index 00000000..6ac563db
--- /dev/null
+++ b/gl/setlocale_null.c
@@ -0,0 +1,411 @@
1/* Query the name of the current global locale.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#include <config.h>
20
21/* Specification. */
22#include "setlocale_null.h"
23
24#include <errno.h>
25#include <locale.h>
26#include <stdlib.h>
27#include <string.h>
28#if defined _WIN32 && !defined __CYGWIN__
29# include <wchar.h>
30#endif
31
32#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE)
33# if defined _WIN32 && !defined __CYGWIN__
34
35# define WIN32_LEAN_AND_MEAN /* avoid including junk */
36# include <windows.h>
37
38# elif HAVE_PTHREAD_API
39
40# include <pthread.h>
41# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
42# include <threads.h>
43# pragma weak thrd_exit
44# define c11_threads_in_use() (thrd_exit != NULL)
45# else
46# define c11_threads_in_use() 0
47# endif
48
49# elif HAVE_THREADS_H
50
51# include <threads.h>
52
53# endif
54#endif
55
56/* Use the system's setlocale() function, not the gnulib override, here. */
57#undef setlocale
58
59static const char *
60setlocale_null_androidfix (int category)
61{
62 const char *result = setlocale (category, NULL);
63
64#ifdef __ANDROID__
65 if (result == NULL)
66 switch (category)
67 {
68 case LC_CTYPE:
69 case LC_NUMERIC:
70 case LC_TIME:
71 case LC_COLLATE:
72 case LC_MONETARY:
73 case LC_MESSAGES:
74 case LC_ALL:
75 case LC_PAPER:
76 case LC_NAME:
77 case LC_ADDRESS:
78 case LC_TELEPHONE:
79 case LC_MEASUREMENT:
80 result = "C";
81 break;
82 default:
83 break;
84 }
85#endif
86
87 return result;
88}
89
90static int
91setlocale_null_unlocked (int category, char *buf, size_t bufsize)
92{
93#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER
94 /* On native Windows, nowadays, the setlocale() implementation is based
95 on _wsetlocale() and uses malloc() for the result. We are better off
96 using _wsetlocale() directly. */
97 const wchar_t *result = _wsetlocale (category, NULL);
98
99 if (result == NULL)
100 {
101 /* CATEGORY is invalid. */
102 if (bufsize > 0)
103 /* Return an empty string in BUF.
104 This is a convenience for callers that don't want to write explicit
105 code for handling EINVAL. */
106 buf[0] = '\0';
107 return EINVAL;
108 }
109 else
110 {
111 size_t length = wcslen (result);
112 if (length < bufsize)
113 {
114 size_t i;
115
116 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
117 for (i = 0; i <= length; i++)
118 buf[i] = result[i];
119
120 return 0;
121 }
122 else
123 {
124 if (bufsize > 0)
125 {
126 /* Return a truncated result in BUF.
127 This is a convenience for callers that don't want to write
128 explicit code for handling ERANGE. */
129 size_t i;
130
131 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
132 for (i = 0; i < bufsize; i++)
133 buf[i] = result[i];
134 buf[bufsize - 1] = '\0';
135 }
136 return ERANGE;
137 }
138 }
139#else
140 const char *result = setlocale_null_androidfix (category);
141
142 if (result == NULL)
143 {
144 /* CATEGORY is invalid. */
145 if (bufsize > 0)
146 /* Return an empty string in BUF.
147 This is a convenience for callers that don't want to write explicit
148 code for handling EINVAL. */
149 buf[0] = '\0';
150 return EINVAL;
151 }
152 else
153 {
154 size_t length = strlen (result);
155 if (length < bufsize)
156 {
157 memcpy (buf, result, length + 1);
158 return 0;
159 }
160 else
161 {
162 if (bufsize > 0)
163 {
164 /* Return a truncated result in BUF.
165 This is a convenience for callers that don't want to write
166 explicit code for handling ERANGE. */
167 memcpy (buf, result, bufsize - 1);
168 buf[bufsize - 1] = '\0';
169 }
170 return ERANGE;
171 }
172 }
173#endif
174}
175
176#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */
177
178/* Use a lock, so that no two threads can invoke setlocale_null_unlocked
179 at the same time. */
180
181/* Prohibit renaming this symbol. */
182# undef gl_get_setlocale_null_lock
183
184# if defined _WIN32 && !defined __CYGWIN__
185
186extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
187
188static int
189setlocale_null_with_lock (int category, char *buf, size_t bufsize)
190{
191 CRITICAL_SECTION *lock = gl_get_setlocale_null_lock ();
192 int ret;
193
194 EnterCriticalSection (lock);
195 ret = setlocale_null_unlocked (category, buf, bufsize);
196 LeaveCriticalSection (lock);
197
198 return ret;
199}
200
201# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */
202
203extern
204# if defined _WIN32 || defined __CYGWIN__
205 __declspec(dllimport)
206# endif
207 pthread_mutex_t *gl_get_setlocale_null_lock (void);
208
209# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */
210
211 /* Avoid the need to link with '-lpthread'. */
212# pragma weak pthread_mutex_lock
213# pragma weak pthread_mutex_unlock
214
215 /* Determine whether libpthread is in use. */
216# pragma weak pthread_mutexattr_gettype
217 /* See the comments in lock.h. */
218# define pthread_in_use() \
219 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
220
221# else
222# define pthread_in_use() 1
223# endif
224
225static int
226setlocale_null_with_lock (int category, char *buf, size_t bufsize)
227{
228 if (pthread_in_use())
229 {
230 pthread_mutex_t *lock = gl_get_setlocale_null_lock ();
231 int ret;
232
233 if (pthread_mutex_lock (lock))
234 abort ();
235 ret = setlocale_null_unlocked (category, buf, bufsize);
236 if (pthread_mutex_unlock (lock))
237 abort ();
238
239 return ret;
240 }
241 else
242 return setlocale_null_unlocked (category, buf, bufsize);
243}
244
245# elif HAVE_THREADS_H
246
247extern mtx_t *gl_get_setlocale_null_lock (void);
248
249static int
250setlocale_null_with_lock (int category, char *buf, size_t bufsize)
251{
252 mtx_t *lock = gl_get_setlocale_null_lock ();
253 int ret;
254
255 if (mtx_lock (lock) != thrd_success)
256 abort ();
257 ret = setlocale_null_unlocked (category, buf, bufsize);
258 if (mtx_unlock (lock) != thrd_success)
259 abort ();
260
261 return ret;
262}
263
264# endif
265
266#endif
267
268int
269setlocale_null_r (int category, char *buf, size_t bufsize)
270{
271#if SETLOCALE_NULL_ALL_MTSAFE
272# if SETLOCALE_NULL_ONE_MTSAFE
273
274 return setlocale_null_unlocked (category, buf, bufsize);
275
276# else
277
278 if (category == LC_ALL)
279 return setlocale_null_unlocked (category, buf, bufsize);
280 else
281 return setlocale_null_with_lock (category, buf, bufsize);
282
283# endif
284#else
285# if SETLOCALE_NULL_ONE_MTSAFE
286
287 if (category == LC_ALL)
288 return setlocale_null_with_lock (category, buf, bufsize);
289 else
290 return setlocale_null_unlocked (category, buf, bufsize);
291
292# else
293
294 return setlocale_null_with_lock (category, buf, bufsize);
295
296# endif
297#endif
298}
299
300const char *
301setlocale_null (int category)
302{
303#if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE
304 return setlocale_null_androidfix (category);
305#else
306
307 /* This call must be multithread-safe. To achieve this without using
308 thread-local storage:
309 1. We use a specific static buffer for each possible CATEGORY
310 argument. So that different threads can call setlocale_mtsafe
311 with different CATEGORY arguments, without interfering.
312 2. We use a simple strcpy or memcpy to fill this static buffer.
313 Filling it through, for example, strcpy + strcat would not be
314 guaranteed to leave the buffer's contents intact if another thread
315 is currently accessing it. If necessary, the contents is first
316 assembled in a stack-allocated buffer. */
317 if (category == LC_ALL)
318 {
319# if SETLOCALE_NULL_ALL_MTSAFE
320 return setlocale_null_androidfix (LC_ALL);
321# else
322 char buf[SETLOCALE_NULL_ALL_MAX];
323 static char resultbuf[SETLOCALE_NULL_ALL_MAX];
324
325 if (setlocale_null_r (LC_ALL, buf, sizeof (buf)))
326 return "C";
327 strcpy (resultbuf, buf);
328 return resultbuf;
329# endif
330 }
331 else
332 {
333# if SETLOCALE_NULL_ONE_MTSAFE
334 return setlocale_null_androidfix (category);
335# else
336 enum
337 {
338 LC_CTYPE_INDEX,
339 LC_NUMERIC_INDEX,
340 LC_TIME_INDEX,
341 LC_COLLATE_INDEX,
342 LC_MONETARY_INDEX,
343 LC_MESSAGES_INDEX,
344# ifdef LC_PAPER
345 LC_PAPER_INDEX,
346# endif
347# ifdef LC_NAME
348 LC_NAME_INDEX,
349# endif
350# ifdef LC_ADDRESS
351 LC_ADDRESS_INDEX,
352# endif
353# ifdef LC_TELEPHONE
354 LC_TELEPHONE_INDEX,
355# endif
356# ifdef LC_MEASUREMENT
357 LC_MEASUREMENT_INDEX,
358# endif
359# ifdef LC_IDENTIFICATION
360 LC_IDENTIFICATION_INDEX,
361# endif
362 LC_INDICES_COUNT
363 }
364 i;
365 char buf[SETLOCALE_NULL_MAX];
366 static char resultbuf[LC_INDICES_COUNT][SETLOCALE_NULL_MAX];
367 int err;
368
369 err = setlocale_null_r (category, buf, sizeof (buf));
370 if (err == EINVAL)
371 return NULL;
372 if (err)
373 return "C";
374
375 switch (category)
376 {
377 case LC_CTYPE: i = LC_CTYPE_INDEX; break;
378 case LC_NUMERIC: i = LC_NUMERIC_INDEX; break;
379 case LC_TIME: i = LC_TIME_INDEX; break;
380 case LC_COLLATE: i = LC_COLLATE_INDEX; break;
381 case LC_MONETARY: i = LC_MONETARY_INDEX; break;
382 case LC_MESSAGES: i = LC_MESSAGES_INDEX; break;
383# ifdef LC_PAPER
384 case LC_PAPER: i = LC_PAPER_INDEX; break;
385# endif
386# ifdef LC_NAME
387 case LC_NAME: i = LC_NAME_INDEX; break;
388# endif
389# ifdef LC_ADDRESS
390 case LC_ADDRESS: i = LC_ADDRESS_INDEX; break;
391# endif
392# ifdef LC_TELEPHONE
393 case LC_TELEPHONE: i = LC_TELEPHONE_INDEX; break;
394# endif
395# ifdef LC_MEASUREMENT
396 case LC_MEASUREMENT: i = LC_MEASUREMENT_INDEX; break;
397# endif
398# ifdef LC_IDENTIFICATION
399 case LC_IDENTIFICATION: i = LC_IDENTIFICATION_INDEX; break;
400# endif
401 default:
402 /* If you get here, a #ifdef LC_xxx is missing. */
403 abort ();
404 }
405
406 strcpy (resultbuf[i], buf);
407 return resultbuf[i];
408# endif
409 }
410#endif
411}
diff --git a/gl/setlocale_null.h b/gl/setlocale_null.h
new file mode 100644
index 00000000..c740fa0f
--- /dev/null
+++ b/gl/setlocale_null.h
@@ -0,0 +1,82 @@
1/* Query the name of the current global locale.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#ifndef _SETLOCALE_NULL_H
20#define _SETLOCALE_NULL_H
21
22#include <stddef.h>
23
24#include "arg-nonnull.h"
25
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31
32/* Recommended size of a buffer for a locale name for a single category.
33 On glibc systems, you can have locale names that are relative file names;
34 assume a maximum length 256.
35 In native Windows, in 2018 the longest locale name was of length 58
36 ("FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251"). */
37#define SETLOCALE_NULL_MAX (256+1)
38
39/* Recommended size of a buffer for a locale name with all categories.
40 On glibc systems, you can have locale names that are relative file names;
41 assume maximum length 256 for each. There are 12 categories; so, the
42 maximum total length is 148+12*256.
43 In native Windows, there are 5 categories, and the maximum total length is
44 55+5*58. */
45#define SETLOCALE_NULL_ALL_MAX (148+12*256+1)
46
47/* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL),
48 except that
49 - it is guaranteed to be multithread-safe,
50 - it returns the resulting locale category name or locale name in the
51 user-supplied buffer BUF, which must be BUFSIZE bytes long.
52 The recommended minimum buffer size is
53 - SETLOCALE_NULL_MAX for CATEGORY != LC_ALL, and
54 - SETLOCALE_NULL_ALL_MAX for CATEGORY == LC_ALL.
55 The return value is an error code: 0 if the call is successful, EINVAL if
56 CATEGORY is invalid, or ERANGE if BUFSIZE is smaller than the length needed
57 size (including the trailing NUL byte). In the latter case, a truncated
58 result is returned in BUF, but still NUL-terminated if BUFSIZE > 0.
59 For this call to be multithread-safe, *all* calls to
60 setlocale (CATEGORY, NULL) in all other threads must have been converted
61 to use setlocale_null_r or setlocale_null as well, and the other threads
62 must not make other setlocale invocations (since changing the global locale
63 has side effects on all threads). */
64extern int setlocale_null_r (int category, char *buf, size_t bufsize)
65 _GL_ARG_NONNULL ((2));
66
67/* setlocale_null (CATEGORY) is like setlocale (CATEGORY, NULL), except that
68 it is guaranteed to be multithread-safe.
69 The return value is NULL if CATEGORY is invalid.
70 For this call to be multithread-safe, *all* calls to
71 setlocale (CATEGORY, NULL) in all other threads must have been converted
72 to use setlocale_null_r or setlocale_null as well, and the other threads
73 must not make other setlocale invocations (since changing the global locale
74 has side effects on all threads). */
75extern const char *setlocale_null (int category);
76
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif /* _SETLOCALE_NULL_H */
diff --git a/gl/sha1.c b/gl/sha1.c
deleted file mode 100644
index 778389af..00000000
--- a/gl/sha1.c
+++ /dev/null
@@ -1,426 +0,0 @@
1/* sha1.c - Functions to compute SHA1 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-1.
3
4 Copyright (C) 2000-2001, 2003-2006, 2008-2013 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18
19/* Written by Scott G. Miller
20 Credits:
21 Robert Klep <robert@ilse.nl> -- Expansion function fix
22*/
23
24#include <config.h>
25
26#include "sha1.h"
27
28#include <stdalign.h>
29#include <stdint.h>
30#include <stdlib.h>
31#include <string.h>
32
33#if USE_UNLOCKED_IO
34# include "unlocked-io.h"
35#endif
36
37#ifdef WORDS_BIGENDIAN
38# define SWAP(n) (n)
39#else
40# define SWAP(n) \
41 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
42#endif
43
44#define BLOCKSIZE 32768
45#if BLOCKSIZE % 64 != 0
46# error "invalid BLOCKSIZE"
47#endif
48
49/* This array contains the bytes used to pad the buffer to the next
50 64-byte boundary. (RFC 1321, 3.1: Step 1) */
51static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
52
53
54/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
55 initialize it to the start constants of the SHA1 algorithm. This
56 must be called before using hash in the call to sha1_hash. */
57void
58sha1_init_ctx (struct sha1_ctx *ctx)
59{
60 ctx->A = 0x67452301;
61 ctx->B = 0xefcdab89;
62 ctx->C = 0x98badcfe;
63 ctx->D = 0x10325476;
64 ctx->E = 0xc3d2e1f0;
65
66 ctx->total[0] = ctx->total[1] = 0;
67 ctx->buflen = 0;
68}
69
70/* Copy the 4 byte value from v into the memory location pointed to by *cp,
71 If your architecture allows unaligned access this is equivalent to
72 * (uint32_t *) cp = v */
73static void
74set_uint32 (char *cp, uint32_t v)
75{
76 memcpy (cp, &v, sizeof v);
77}
78
79/* Put result from CTX in first 20 bytes following RESBUF. The result
80 must be in little endian byte order. */
81void *
82sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
83{
84 char *r = resbuf;
85 set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
86 set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
87 set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
88 set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
89 set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E));
90
91 return resbuf;
92}
93
94/* Process the remaining bytes in the internal buffer and the usual
95 prolog according to the standard and write the result to RESBUF. */
96void *
97sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
98{
99 /* Take yet unprocessed bytes into account. */
100 uint32_t bytes = ctx->buflen;
101 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
102
103 /* Now count remaining bytes. */
104 ctx->total[0] += bytes;
105 if (ctx->total[0] < bytes)
106 ++ctx->total[1];
107
108 /* Put the 64-bit file length in *bits* at the end of the buffer. */
109 ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
110 ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
111
112 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
113
114 /* Process last bytes. */
115 sha1_process_block (ctx->buffer, size * 4, ctx);
116
117 return sha1_read_ctx (ctx, resbuf);
118}
119
120/* Compute SHA1 message digest for bytes read from STREAM. The
121 resulting message digest number will be written into the 16 bytes
122 beginning at RESBLOCK. */
123int
124sha1_stream (FILE *stream, void *resblock)
125{
126 struct sha1_ctx ctx;
127 size_t sum;
128
129 char *buffer = malloc (BLOCKSIZE + 72);
130 if (!buffer)
131 return 1;
132
133 /* Initialize the computation context. */
134 sha1_init_ctx (&ctx);
135
136 /* Iterate over full file contents. */
137 while (1)
138 {
139 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
140 computation function processes the whole buffer so that with the
141 next round of the loop another block can be read. */
142 size_t n;
143 sum = 0;
144
145 /* Read block. Take care for partial reads. */
146 while (1)
147 {
148 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
149
150 sum += n;
151
152 if (sum == BLOCKSIZE)
153 break;
154
155 if (n == 0)
156 {
157 /* Check for the error flag IFF N == 0, so that we don't
158 exit the loop after a partial read due to e.g., EAGAIN
159 or EWOULDBLOCK. */
160 if (ferror (stream))
161 {
162 free (buffer);
163 return 1;
164 }
165 goto process_partial_block;
166 }
167
168 /* We've read at least one byte, so ignore errors. But always
169 check for EOF, since feof may be true even though N > 0.
170 Otherwise, we could end up calling fread after EOF. */
171 if (feof (stream))
172 goto process_partial_block;
173 }
174
175 /* Process buffer with BLOCKSIZE bytes. Note that
176 BLOCKSIZE % 64 == 0
177 */
178 sha1_process_block (buffer, BLOCKSIZE, &ctx);
179 }
180
181 process_partial_block:;
182
183 /* Process any remaining bytes. */
184 if (sum > 0)
185 sha1_process_bytes (buffer, sum, &ctx);
186
187 /* Construct result in desired memory. */
188 sha1_finish_ctx (&ctx, resblock);
189 free (buffer);
190 return 0;
191}
192
193/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
194 result is always in little endian byte order, so that a byte-wise
195 output yields to the wanted ASCII representation of the message
196 digest. */
197void *
198sha1_buffer (const char *buffer, size_t len, void *resblock)
199{
200 struct sha1_ctx ctx;
201
202 /* Initialize the computation context. */
203 sha1_init_ctx (&ctx);
204
205 /* Process whole buffer but last len % 64 bytes. */
206 sha1_process_bytes (buffer, len, &ctx);
207
208 /* Put result in desired memory area. */
209 return sha1_finish_ctx (&ctx, resblock);
210}
211
212void
213sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
214{
215 /* When we already have some bits in our internal buffer concatenate
216 both inputs first. */
217 if (ctx->buflen != 0)
218 {
219 size_t left_over = ctx->buflen;
220 size_t add = 128 - left_over > len ? len : 128 - left_over;
221
222 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
223 ctx->buflen += add;
224
225 if (ctx->buflen > 64)
226 {
227 sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
228
229 ctx->buflen &= 63;
230 /* The regions in the following copy operation cannot overlap. */
231 memcpy (ctx->buffer,
232 &((char *) ctx->buffer)[(left_over + add) & ~63],
233 ctx->buflen);
234 }
235
236 buffer = (const char *) buffer + add;
237 len -= add;
238 }
239
240 /* Process available complete blocks. */
241 if (len >= 64)
242 {
243#if !_STRING_ARCH_unaligned
244# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
245 if (UNALIGNED_P (buffer))
246 while (len > 64)
247 {
248 sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
249 buffer = (const char *) buffer + 64;
250 len -= 64;
251 }
252 else
253#endif
254 {
255 sha1_process_block (buffer, len & ~63, ctx);
256 buffer = (const char *) buffer + (len & ~63);
257 len &= 63;
258 }
259 }
260
261 /* Move remaining bytes in internal buffer. */
262 if (len > 0)
263 {
264 size_t left_over = ctx->buflen;
265
266 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
267 left_over += len;
268 if (left_over >= 64)
269 {
270 sha1_process_block (ctx->buffer, 64, ctx);
271 left_over -= 64;
272 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
273 }
274 ctx->buflen = left_over;
275 }
276}
277
278/* --- Code below is the primary difference between md5.c and sha1.c --- */
279
280/* SHA1 round constants */
281#define K1 0x5a827999
282#define K2 0x6ed9eba1
283#define K3 0x8f1bbcdc
284#define K4 0xca62c1d6
285
286/* Round functions. Note that F2 is the same as F4. */
287#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
288#define F2(B,C,D) (B ^ C ^ D)
289#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
290#define F4(B,C,D) (B ^ C ^ D)
291
292/* Process LEN bytes of BUFFER, accumulating context into CTX.
293 It is assumed that LEN % 64 == 0.
294 Most of this code comes from GnuPG's cipher/sha1.c. */
295
296void
297sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
298{
299 const uint32_t *words = buffer;
300 size_t nwords = len / sizeof (uint32_t);
301 const uint32_t *endp = words + nwords;
302 uint32_t x[16];
303 uint32_t a = ctx->A;
304 uint32_t b = ctx->B;
305 uint32_t c = ctx->C;
306 uint32_t d = ctx->D;
307 uint32_t e = ctx->E;
308 uint32_t lolen = len;
309
310 /* First increment the byte count. RFC 1321 specifies the possible
311 length of the file up to 2^64 bits. Here we only compute the
312 number of bytes. Do a double word increment. */
313 ctx->total[0] += lolen;
314 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
315
316#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
317
318#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
319 ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
320 , (x[I&0x0f] = rol(tm, 1)) )
321
322#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
323 + F( B, C, D ) \
324 + K \
325 + M; \
326 B = rol( B, 30 ); \
327 } while(0)
328
329 while (words < endp)
330 {
331 uint32_t tm;
332 int t;
333 for (t = 0; t < 16; t++)
334 {
335 x[t] = SWAP (*words);
336 words++;
337 }
338
339 R( a, b, c, d, e, F1, K1, x[ 0] );
340 R( e, a, b, c, d, F1, K1, x[ 1] );
341 R( d, e, a, b, c, F1, K1, x[ 2] );
342 R( c, d, e, a, b, F1, K1, x[ 3] );
343 R( b, c, d, e, a, F1, K1, x[ 4] );
344 R( a, b, c, d, e, F1, K1, x[ 5] );
345 R( e, a, b, c, d, F1, K1, x[ 6] );
346 R( d, e, a, b, c, F1, K1, x[ 7] );
347 R( c, d, e, a, b, F1, K1, x[ 8] );
348 R( b, c, d, e, a, F1, K1, x[ 9] );
349 R( a, b, c, d, e, F1, K1, x[10] );
350 R( e, a, b, c, d, F1, K1, x[11] );
351 R( d, e, a, b, c, F1, K1, x[12] );
352 R( c, d, e, a, b, F1, K1, x[13] );
353 R( b, c, d, e, a, F1, K1, x[14] );
354 R( a, b, c, d, e, F1, K1, x[15] );
355 R( e, a, b, c, d, F1, K1, M(16) );
356 R( d, e, a, b, c, F1, K1, M(17) );
357 R( c, d, e, a, b, F1, K1, M(18) );
358 R( b, c, d, e, a, F1, K1, M(19) );
359 R( a, b, c, d, e, F2, K2, M(20) );
360 R( e, a, b, c, d, F2, K2, M(21) );
361 R( d, e, a, b, c, F2, K2, M(22) );
362 R( c, d, e, a, b, F2, K2, M(23) );
363 R( b, c, d, e, a, F2, K2, M(24) );
364 R( a, b, c, d, e, F2, K2, M(25) );
365 R( e, a, b, c, d, F2, K2, M(26) );
366 R( d, e, a, b, c, F2, K2, M(27) );
367 R( c, d, e, a, b, F2, K2, M(28) );
368 R( b, c, d, e, a, F2, K2, M(29) );
369 R( a, b, c, d, e, F2, K2, M(30) );
370 R( e, a, b, c, d, F2, K2, M(31) );
371 R( d, e, a, b, c, F2, K2, M(32) );
372 R( c, d, e, a, b, F2, K2, M(33) );
373 R( b, c, d, e, a, F2, K2, M(34) );
374 R( a, b, c, d, e, F2, K2, M(35) );
375 R( e, a, b, c, d, F2, K2, M(36) );
376 R( d, e, a, b, c, F2, K2, M(37) );
377 R( c, d, e, a, b, F2, K2, M(38) );
378 R( b, c, d, e, a, F2, K2, M(39) );
379 R( a, b, c, d, e, F3, K3, M(40) );
380 R( e, a, b, c, d, F3, K3, M(41) );
381 R( d, e, a, b, c, F3, K3, M(42) );
382 R( c, d, e, a, b, F3, K3, M(43) );
383 R( b, c, d, e, a, F3, K3, M(44) );
384 R( a, b, c, d, e, F3, K3, M(45) );
385 R( e, a, b, c, d, F3, K3, M(46) );
386 R( d, e, a, b, c, F3, K3, M(47) );
387 R( c, d, e, a, b, F3, K3, M(48) );
388 R( b, c, d, e, a, F3, K3, M(49) );
389 R( a, b, c, d, e, F3, K3, M(50) );
390 R( e, a, b, c, d, F3, K3, M(51) );
391 R( d, e, a, b, c, F3, K3, M(52) );
392 R( c, d, e, a, b, F3, K3, M(53) );
393 R( b, c, d, e, a, F3, K3, M(54) );
394 R( a, b, c, d, e, F3, K3, M(55) );
395 R( e, a, b, c, d, F3, K3, M(56) );
396 R( d, e, a, b, c, F3, K3, M(57) );
397 R( c, d, e, a, b, F3, K3, M(58) );
398 R( b, c, d, e, a, F3, K3, M(59) );
399 R( a, b, c, d, e, F4, K4, M(60) );
400 R( e, a, b, c, d, F4, K4, M(61) );
401 R( d, e, a, b, c, F4, K4, M(62) );
402 R( c, d, e, a, b, F4, K4, M(63) );
403 R( b, c, d, e, a, F4, K4, M(64) );
404 R( a, b, c, d, e, F4, K4, M(65) );
405 R( e, a, b, c, d, F4, K4, M(66) );
406 R( d, e, a, b, c, F4, K4, M(67) );
407 R( c, d, e, a, b, F4, K4, M(68) );
408 R( b, c, d, e, a, F4, K4, M(69) );
409 R( a, b, c, d, e, F4, K4, M(70) );
410 R( e, a, b, c, d, F4, K4, M(71) );
411 R( d, e, a, b, c, F4, K4, M(72) );
412 R( c, d, e, a, b, F4, K4, M(73) );
413 R( b, c, d, e, a, F4, K4, M(74) );
414 R( a, b, c, d, e, F4, K4, M(75) );
415 R( e, a, b, c, d, F4, K4, M(76) );
416 R( d, e, a, b, c, F4, K4, M(77) );
417 R( c, d, e, a, b, F4, K4, M(78) );
418 R( b, c, d, e, a, F4, K4, M(79) );
419
420 a = ctx->A += a;
421 b = ctx->B += b;
422 c = ctx->C += c;
423 d = ctx->D += d;
424 e = ctx->E += e;
425 }
426}
diff --git a/gl/sha1.h b/gl/sha1.h
deleted file mode 100644
index ddd386f9..00000000
--- a/gl/sha1.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/* Declarations of functions and data types used for SHA1 sum
2 library functions.
3 Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2013 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef SHA1_H
20# define SHA1_H 1
21
22# include <stdio.h>
23# include <stdint.h>
24
25# ifdef __cplusplus
26extern "C" {
27# endif
28
29#define SHA1_DIGEST_SIZE 20
30
31/* Structure to save state of computation between the single steps. */
32struct sha1_ctx
33{
34 uint32_t A;
35 uint32_t B;
36 uint32_t C;
37 uint32_t D;
38 uint32_t E;
39
40 uint32_t total[2];
41 uint32_t buflen;
42 uint32_t buffer[32];
43};
44
45
46/* Initialize structure containing state of computation. */
47extern void sha1_init_ctx (struct sha1_ctx *ctx);
48
49/* Starting with the result of former calls of this function (or the
50 initialization function update the context for the next LEN bytes
51 starting at BUFFER.
52 It is necessary that LEN is a multiple of 64!!! */
53extern void sha1_process_block (const void *buffer, size_t len,
54 struct sha1_ctx *ctx);
55
56/* Starting with the result of former calls of this function (or the
57 initialization function update the context for the next LEN bytes
58 starting at BUFFER.
59 It is NOT required that LEN is a multiple of 64. */
60extern void sha1_process_bytes (const void *buffer, size_t len,
61 struct sha1_ctx *ctx);
62
63/* Process the remaining bytes in the buffer and put result from CTX
64 in first 20 bytes following RESBUF. The result is always in little
65 endian byte order, so that a byte-wise output yields to the wanted
66 ASCII representation of the message digest. */
67extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
68
69
70/* Put result from CTX in first 20 bytes following RESBUF. The result is
71 always in little endian byte order, so that a byte-wise output yields
72 to the wanted ASCII representation of the message digest. */
73extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
74
75
76/* Compute SHA1 message digest for bytes read from STREAM. The
77 resulting message digest number will be written into the 20 bytes
78 beginning at RESBLOCK. */
79extern int sha1_stream (FILE *stream, void *resblock);
80
81/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
82 result is always in little endian byte order, so that a byte-wise
83 output yields to the wanted ASCII representation of the message
84 digest. */
85extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
86
87# ifdef __cplusplus
88}
89# endif
90
91#endif
diff --git a/gl/sha256-stream.c b/gl/sha256-stream.c
new file mode 100644
index 00000000..0e83380a
--- /dev/null
+++ b/gl/sha256-stream.c
@@ -0,0 +1,145 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2.
3
4 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* Written by David Madore, considerably copypasting from
20 Scott G. Miller's sha1.c
21*/
22
23#include <config.h>
24
25/* Specification. */
26#if HAVE_OPENSSL_SHA256
27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
28#endif
29#include "sha256.h"
30
31#include <stdlib.h>
32
33#if USE_UNLOCKED_IO
34# include "unlocked-io.h"
35#endif
36
37#include "af_alg.h"
38
39#define BLOCKSIZE 32768
40#if BLOCKSIZE % 64 != 0
41# error "invalid BLOCKSIZE"
42#endif
43
44/* Compute message digest for bytes read from STREAM using algorithm ALG.
45 Write the message digest into RESBLOCK, which contains HASHLEN bytes.
46 The initial and finishing operations are INIT_CTX and FINISH_CTX.
47 Return zero if and only if successful. */
48static int
49shaxxx_stream (FILE *stream, char const *alg, void *resblock,
50 ssize_t hashlen, void (*init_ctx) (struct sha256_ctx *),
51 void *(*finish_ctx) (struct sha256_ctx *, void *))
52{
53 switch (afalg_stream (stream, alg, resblock, hashlen))
54 {
55 case 0: return 0;
56 case -EIO: return 1;
57 }
58
59 char *buffer = malloc (BLOCKSIZE + 72);
60 if (!buffer)
61 return 1;
62
63 struct sha256_ctx ctx;
64 init_ctx (&ctx);
65 size_t sum;
66
67 /* Iterate over full file contents. */
68 while (1)
69 {
70 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
71 computation function processes the whole buffer so that with the
72 next round of the loop another block can be read. */
73 size_t n;
74 sum = 0;
75
76 /* Read block. Take care for partial reads. */
77 while (1)
78 {
79 /* Either process a partial fread() from this loop,
80 or the fread() in afalg_stream may have gotten EOF.
81 We need to avoid a subsequent fread() as EOF may
82 not be sticky. For details of such systems, see:
83 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */
84 if (feof (stream))
85 goto process_partial_block;
86
87 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
88
89 sum += n;
90
91 if (sum == BLOCKSIZE)
92 break;
93
94 if (n == 0)
95 {
96 /* Check for the error flag IFF N == 0, so that we don't
97 exit the loop after a partial read due to e.g., EAGAIN
98 or EWOULDBLOCK. */
99 if (ferror (stream))
100 {
101 free (buffer);
102 return 1;
103 }
104 goto process_partial_block;
105 }
106 }
107
108 /* Process buffer with BLOCKSIZE bytes. Note that
109 BLOCKSIZE % 64 == 0
110 */
111 sha256_process_block (buffer, BLOCKSIZE, &ctx);
112 }
113
114 process_partial_block:;
115
116 /* Process any remaining bytes. */
117 if (sum > 0)
118 sha256_process_bytes (buffer, sum, &ctx);
119
120 /* Construct result in desired memory. */
121 finish_ctx (&ctx, resblock);
122 free (buffer);
123 return 0;
124}
125
126int
127sha256_stream (FILE *stream, void *resblock)
128{
129 return shaxxx_stream (stream, "sha256", resblock, SHA256_DIGEST_SIZE,
130 sha256_init_ctx, sha256_finish_ctx);
131}
132
133int
134sha224_stream (FILE *stream, void *resblock)
135{
136 return shaxxx_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE,
137 sha224_init_ctx, sha224_finish_ctx);
138}
139
140/*
141 * Hey Emacs!
142 * Local Variables:
143 * coding: utf-8
144 * End:
145 */
diff --git a/gl/sha256.c b/gl/sha256.c
new file mode 100644
index 00000000..e5fea02b
--- /dev/null
+++ b/gl/sha256.c
@@ -0,0 +1,432 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2.
3
4 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* Written by David Madore, considerably copypasting from
20 Scott G. Miller's sha1.c
21*/
22
23#include <config.h>
24
25/* Specification. */
26#if HAVE_OPENSSL_SHA256
27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
28#endif
29#include "sha256.h"
30
31#include <stdint.h>
32#include <string.h>
33
34#include <byteswap.h>
35#ifdef WORDS_BIGENDIAN
36# define SWAP(n) (n)
37#else
38# define SWAP(n) bswap_32 (n)
39#endif
40
41#if ! HAVE_OPENSSL_SHA256
42
43/* This array contains the bytes used to pad the buffer to the next
44 64-byte boundary. */
45static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
46
47
48/*
49 Takes a pointer to a 256 bit block of data (eight 32 bit ints) and
50 initializes it to the start constants of the SHA256 algorithm. This
51 must be called before using hash in the call to sha256_hash
52*/
53void
54sha256_init_ctx (struct sha256_ctx *ctx)
55{
56 ctx->state[0] = 0x6a09e667UL;
57 ctx->state[1] = 0xbb67ae85UL;
58 ctx->state[2] = 0x3c6ef372UL;
59 ctx->state[3] = 0xa54ff53aUL;
60 ctx->state[4] = 0x510e527fUL;
61 ctx->state[5] = 0x9b05688cUL;
62 ctx->state[6] = 0x1f83d9abUL;
63 ctx->state[7] = 0x5be0cd19UL;
64
65 ctx->total[0] = ctx->total[1] = 0;
66 ctx->buflen = 0;
67}
68
69void
70sha224_init_ctx (struct sha256_ctx *ctx)
71{
72 ctx->state[0] = 0xc1059ed8UL;
73 ctx->state[1] = 0x367cd507UL;
74 ctx->state[2] = 0x3070dd17UL;
75 ctx->state[3] = 0xf70e5939UL;
76 ctx->state[4] = 0xffc00b31UL;
77 ctx->state[5] = 0x68581511UL;
78 ctx->state[6] = 0x64f98fa7UL;
79 ctx->state[7] = 0xbefa4fa4UL;
80
81 ctx->total[0] = ctx->total[1] = 0;
82 ctx->buflen = 0;
83}
84
85/* Copy the value from v into the memory location pointed to by *CP,
86 If your architecture allows unaligned access, this is equivalent to
87 * (__typeof__ (v) *) cp = v */
88static void
89set_uint32 (char *cp, uint32_t v)
90{
91 memcpy (cp, &v, sizeof v);
92}
93
94/* Put result from CTX in first 32 bytes following RESBUF.
95 The result must be in little endian byte order. */
96void *
97sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
98{
99 int i;
100 char *r = resbuf;
101
102 for (i = 0; i < 8; i++)
103 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
104
105 return resbuf;
106}
107
108void *
109sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
110{
111 int i;
112 char *r = resbuf;
113
114 for (i = 0; i < 7; i++)
115 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
116
117 return resbuf;
118}
119
120/* Process the remaining bytes in the internal buffer and the usual
121 prolog according to the standard and write the result to RESBUF. */
122static void
123sha256_conclude_ctx (struct sha256_ctx *ctx)
124{
125 /* Take yet unprocessed bytes into account. */
126 size_t bytes = ctx->buflen;
127 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
128
129 /* Now count remaining bytes. */
130 ctx->total[0] += bytes;
131 if (ctx->total[0] < bytes)
132 ++ctx->total[1];
133
134 /* Put the 64-bit file length in *bits* at the end of the buffer.
135 Use set_uint32 rather than a simple assignment, to avoid risk of
136 unaligned access. */
137 set_uint32 ((char *) &ctx->buffer[size - 2],
138 SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)));
139 set_uint32 ((char *) &ctx->buffer[size - 1],
140 SWAP (ctx->total[0] << 3));
141
142 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
143
144 /* Process last bytes. */
145 sha256_process_block (ctx->buffer, size * 4, ctx);
146}
147
148void *
149sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
150{
151 sha256_conclude_ctx (ctx);
152 return sha256_read_ctx (ctx, resbuf);
153}
154
155void *
156sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
157{
158 sha256_conclude_ctx (ctx);
159 return sha224_read_ctx (ctx, resbuf);
160}
161
162/* Compute SHA256 message digest for LEN bytes beginning at BUFFER. The
163 result is always in little endian byte order, so that a byte-wise
164 output yields to the wanted ASCII representation of the message
165 digest. */
166void *
167sha256_buffer (const char *buffer, size_t len, void *resblock)
168{
169 struct sha256_ctx ctx;
170
171 /* Initialize the computation context. */
172 sha256_init_ctx (&ctx);
173
174 /* Process whole buffer but last len % 64 bytes. */
175 sha256_process_bytes (buffer, len, &ctx);
176
177 /* Put result in desired memory area. */
178 return sha256_finish_ctx (&ctx, resblock);
179}
180
181void *
182sha224_buffer (const char *buffer, size_t len, void *resblock)
183{
184 struct sha256_ctx ctx;
185
186 /* Initialize the computation context. */
187 sha224_init_ctx (&ctx);
188
189 /* Process whole buffer but last len % 64 bytes. */
190 sha256_process_bytes (buffer, len, &ctx);
191
192 /* Put result in desired memory area. */
193 return sha224_finish_ctx (&ctx, resblock);
194}
195
196void
197sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
198{
199 /* When we already have some bits in our internal buffer concatenate
200 both inputs first. */
201 if (ctx->buflen != 0)
202 {
203 size_t left_over = ctx->buflen;
204 size_t add = 128 - left_over > len ? len : 128 - left_over;
205
206 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
207 ctx->buflen += add;
208
209 if (ctx->buflen > 64)
210 {
211 sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
212
213 ctx->buflen &= 63;
214 /* The regions in the following copy operation cannot overlap,
215 because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
216 memcpy (ctx->buffer,
217 &((char *) ctx->buffer)[(left_over + add) & ~63],
218 ctx->buflen);
219 }
220
221 buffer = (const char *) buffer + add;
222 len -= add;
223 }
224
225 /* Process available complete blocks. */
226 if (len >= 64)
227 {
228#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
229# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
230 if (UNALIGNED_P (buffer))
231 while (len > 64)
232 {
233 sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
234 buffer = (const char *) buffer + 64;
235 len -= 64;
236 }
237 else
238#endif
239 {
240 sha256_process_block (buffer, len & ~63, ctx);
241 buffer = (const char *) buffer + (len & ~63);
242 len &= 63;
243 }
244 }
245
246 /* Move remaining bytes in internal buffer. */
247 if (len > 0)
248 {
249 size_t left_over = ctx->buflen;
250
251 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
252 left_over += len;
253 if (left_over >= 64)
254 {
255 sha256_process_block (ctx->buffer, 64, ctx);
256 left_over -= 64;
257 /* The regions in the following copy operation cannot overlap,
258 because left_over ≤ 64. */
259 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
260 }
261 ctx->buflen = left_over;
262 }
263}
264
265/* --- Code below is the primary difference between sha1.c and sha256.c --- */
266
267/* SHA256 round constants */
268#define K(I) sha256_round_constants[I]
269static const uint32_t sha256_round_constants[64] = {
270 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
271 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
272 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
273 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
274 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
275 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
276 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
277 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
278 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
279 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
280 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
281 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
282 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
283 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
284 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
285 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL,
286};
287
288/* Round functions. */
289#define F2(A,B,C) ( ( A & B ) | ( C & ( A | B ) ) )
290#define F1(E,F,G) ( G ^ ( E & ( F ^ G ) ) )
291
292/* Process LEN bytes of BUFFER, accumulating context into CTX.
293 It is assumed that LEN % 64 == 0.
294 Most of this code comes from GnuPG's cipher/sha1.c. */
295
296void
297sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
298{
299 const uint32_t *words = buffer;
300 size_t nwords = len / sizeof (uint32_t);
301 const uint32_t *endp = words + nwords;
302 uint32_t x[16];
303 uint32_t a = ctx->state[0];
304 uint32_t b = ctx->state[1];
305 uint32_t c = ctx->state[2];
306 uint32_t d = ctx->state[3];
307 uint32_t e = ctx->state[4];
308 uint32_t f = ctx->state[5];
309 uint32_t g = ctx->state[6];
310 uint32_t h = ctx->state[7];
311 uint32_t lolen = len;
312
313 /* First increment the byte count. FIPS PUB 180-2 specifies the possible
314 length of the file up to 2^64 bits. Here we only compute the
315 number of bytes. Do a double word increment. */
316 ctx->total[0] += lolen;
317 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
318
319#define rol(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
320#define S0(x) (rol(x,25)^rol(x,14)^(x>>3))
321#define S1(x) (rol(x,15)^rol(x,13)^(x>>10))
322#define SS0(x) (rol(x,30)^rol(x,19)^rol(x,10))
323#define SS1(x) (rol(x,26)^rol(x,21)^rol(x,7))
324
325#define M(I) ( tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] \
326 + S0(x[(I-15)&0x0f]) + x[I&0x0f] \
327 , x[I&0x0f] = tm )
328
329#define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \
330 t1 = H + SS1(E) \
331 + F1(E,F,G) \
332 + K \
333 + M; \
334 D += t1; H = t0 + t1; \
335 } while(0)
336
337 while (words < endp)
338 {
339 uint32_t tm;
340 uint32_t t0, t1;
341 int t;
342 /* FIXME: see sha1.c for a better implementation. */
343 for (t = 0; t < 16; t++)
344 {
345 x[t] = SWAP (*words);
346 words++;
347 }
348
349 R( a, b, c, d, e, f, g, h, K( 0), x[ 0] );
350 R( h, a, b, c, d, e, f, g, K( 1), x[ 1] );
351 R( g, h, a, b, c, d, e, f, K( 2), x[ 2] );
352 R( f, g, h, a, b, c, d, e, K( 3), x[ 3] );
353 R( e, f, g, h, a, b, c, d, K( 4), x[ 4] );
354 R( d, e, f, g, h, a, b, c, K( 5), x[ 5] );
355 R( c, d, e, f, g, h, a, b, K( 6), x[ 6] );
356 R( b, c, d, e, f, g, h, a, K( 7), x[ 7] );
357 R( a, b, c, d, e, f, g, h, K( 8), x[ 8] );
358 R( h, a, b, c, d, e, f, g, K( 9), x[ 9] );
359 R( g, h, a, b, c, d, e, f, K(10), x[10] );
360 R( f, g, h, a, b, c, d, e, K(11), x[11] );
361 R( e, f, g, h, a, b, c, d, K(12), x[12] );
362 R( d, e, f, g, h, a, b, c, K(13), x[13] );
363 R( c, d, e, f, g, h, a, b, K(14), x[14] );
364 R( b, c, d, e, f, g, h, a, K(15), x[15] );
365 R( a, b, c, d, e, f, g, h, K(16), M(16) );
366 R( h, a, b, c, d, e, f, g, K(17), M(17) );
367 R( g, h, a, b, c, d, e, f, K(18), M(18) );
368 R( f, g, h, a, b, c, d, e, K(19), M(19) );
369 R( e, f, g, h, a, b, c, d, K(20), M(20) );
370 R( d, e, f, g, h, a, b, c, K(21), M(21) );
371 R( c, d, e, f, g, h, a, b, K(22), M(22) );
372 R( b, c, d, e, f, g, h, a, K(23), M(23) );
373 R( a, b, c, d, e, f, g, h, K(24), M(24) );
374 R( h, a, b, c, d, e, f, g, K(25), M(25) );
375 R( g, h, a, b, c, d, e, f, K(26), M(26) );
376 R( f, g, h, a, b, c, d, e, K(27), M(27) );
377 R( e, f, g, h, a, b, c, d, K(28), M(28) );
378 R( d, e, f, g, h, a, b, c, K(29), M(29) );
379 R( c, d, e, f, g, h, a, b, K(30), M(30) );
380 R( b, c, d, e, f, g, h, a, K(31), M(31) );
381 R( a, b, c, d, e, f, g, h, K(32), M(32) );
382 R( h, a, b, c, d, e, f, g, K(33), M(33) );
383 R( g, h, a, b, c, d, e, f, K(34), M(34) );
384 R( f, g, h, a, b, c, d, e, K(35), M(35) );
385 R( e, f, g, h, a, b, c, d, K(36), M(36) );
386 R( d, e, f, g, h, a, b, c, K(37), M(37) );
387 R( c, d, e, f, g, h, a, b, K(38), M(38) );
388 R( b, c, d, e, f, g, h, a, K(39), M(39) );
389 R( a, b, c, d, e, f, g, h, K(40), M(40) );
390 R( h, a, b, c, d, e, f, g, K(41), M(41) );
391 R( g, h, a, b, c, d, e, f, K(42), M(42) );
392 R( f, g, h, a, b, c, d, e, K(43), M(43) );
393 R( e, f, g, h, a, b, c, d, K(44), M(44) );
394 R( d, e, f, g, h, a, b, c, K(45), M(45) );
395 R( c, d, e, f, g, h, a, b, K(46), M(46) );
396 R( b, c, d, e, f, g, h, a, K(47), M(47) );
397 R( a, b, c, d, e, f, g, h, K(48), M(48) );
398 R( h, a, b, c, d, e, f, g, K(49), M(49) );
399 R( g, h, a, b, c, d, e, f, K(50), M(50) );
400 R( f, g, h, a, b, c, d, e, K(51), M(51) );
401 R( e, f, g, h, a, b, c, d, K(52), M(52) );
402 R( d, e, f, g, h, a, b, c, K(53), M(53) );
403 R( c, d, e, f, g, h, a, b, K(54), M(54) );
404 R( b, c, d, e, f, g, h, a, K(55), M(55) );
405 R( a, b, c, d, e, f, g, h, K(56), M(56) );
406 R( h, a, b, c, d, e, f, g, K(57), M(57) );
407 R( g, h, a, b, c, d, e, f, K(58), M(58) );
408 R( f, g, h, a, b, c, d, e, K(59), M(59) );
409 R( e, f, g, h, a, b, c, d, K(60), M(60) );
410 R( d, e, f, g, h, a, b, c, K(61), M(61) );
411 R( c, d, e, f, g, h, a, b, K(62), M(62) );
412 R( b, c, d, e, f, g, h, a, K(63), M(63) );
413
414 a = ctx->state[0] += a;
415 b = ctx->state[1] += b;
416 c = ctx->state[2] += c;
417 d = ctx->state[3] += d;
418 e = ctx->state[4] += e;
419 f = ctx->state[5] += f;
420 g = ctx->state[6] += g;
421 h = ctx->state[7] += h;
422 }
423}
424
425#endif
426
427/*
428 * Hey Emacs!
429 * Local Variables:
430 * coding: utf-8
431 * End:
432 */
diff --git a/gl/sha256.h b/gl/sha256.h
new file mode 100644
index 00000000..2879477e
--- /dev/null
+++ b/gl/sha256.h
@@ -0,0 +1,121 @@
1/* Declarations of functions and data types used for SHA256 and SHA224 sum
2 library functions.
3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef SHA256_H
19# define SHA256_H 1
20
21# include <stdio.h>
22# include <stdint.h>
23
24# if HAVE_OPENSSL_SHA256
25# ifndef OPENSSL_API_COMPAT
26# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
27# endif
28# include <openssl/sha.h>
29# endif
30
31# ifdef __cplusplus
32extern "C" {
33# endif
34
35enum { SHA224_DIGEST_SIZE = 224 / 8 };
36enum { SHA256_DIGEST_SIZE = 256 / 8 };
37
38# if HAVE_OPENSSL_SHA256
39# define GL_OPENSSL_NAME 224
40# include "gl_openssl.h"
41# define GL_OPENSSL_NAME 256
42# include "gl_openssl.h"
43# else
44/* Structure to save state of computation between the single steps. */
45struct sha256_ctx
46{
47 uint32_t state[8];
48
49 uint32_t total[2];
50 size_t buflen; /* ≥ 0, ≤ 128 */
51 uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
52};
53
54/* Initialize structure containing state of computation. */
55extern void sha256_init_ctx (struct sha256_ctx *ctx);
56extern void sha224_init_ctx (struct sha256_ctx *ctx);
57
58/* Starting with the result of former calls of this function (or the
59 initialization function update the context for the next LEN bytes
60 starting at BUFFER.
61 It is necessary that LEN is a multiple of 64!!! */
62extern void sha256_process_block (const void *buffer, size_t len,
63 struct sha256_ctx *ctx);
64
65/* Starting with the result of former calls of this function (or the
66 initialization function update the context for the next LEN bytes
67 starting at BUFFER.
68 It is NOT required that LEN is a multiple of 64. */
69extern void sha256_process_bytes (const void *buffer, size_t len,
70 struct sha256_ctx *ctx);
71
72/* Process the remaining bytes in the buffer and put result from CTX
73 in first 32 (28) bytes following RESBUF. The result is always in little
74 endian byte order, so that a byte-wise output yields to the wanted
75 ASCII representation of the message digest. */
76extern void *sha256_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
77extern void *sha224_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
78
79
80/* Put result from CTX in first 32 (28) bytes following RESBUF. The result is
81 always in little endian byte order, so that a byte-wise output yields
82 to the wanted ASCII representation of the message digest. */
83extern void *sha256_read_ctx (const struct sha256_ctx *ctx,
84 void *restrict resbuf);
85extern void *sha224_read_ctx (const struct sha256_ctx *ctx,
86 void *restrict resbuf);
87
88
89/* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER.
90 The result is always in little endian byte order, so that a byte-wise
91 output yields to the wanted ASCII representation of the message
92 digest. */
93extern void *sha256_buffer (const char *buffer, size_t len,
94 void *restrict resblock);
95extern void *sha224_buffer (const char *buffer, size_t len,
96 void *restrict resblock);
97
98# endif
99
100/* Compute SHA256 (SHA224) message digest for bytes read from STREAM.
101 STREAM is an open file stream. Regular files are handled more efficiently.
102 The contents of STREAM from its current position to its end will be read.
103 The case that the last operation on STREAM was an 'ungetc' is not supported.
104 The resulting message digest number will be written into the 32 (28) bytes
105 beginning at RESBLOCK. */
106extern int sha256_stream (FILE *stream, void *resblock);
107extern int sha224_stream (FILE *stream, void *resblock);
108
109
110# ifdef __cplusplus
111}
112# endif
113
114#endif
115
116/*
117 * Hey Emacs!
118 * Local Variables:
119 * coding: utf-8
120 * End:
121 */
diff --git a/gl/size_max.h b/gl/size_max.h
index 5f331240..48af0250 100644
--- a/gl/size_max.h
+++ b/gl/size_max.h
@@ -1,19 +1,19 @@
1/* size_max.h -- declare SIZE_MAX through system headers 1/* size_max.h -- declare SIZE_MAX through system headers
2 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef GNULIB_SIZE_MAX_H 18#ifndef GNULIB_SIZE_MAX_H
19#define GNULIB_SIZE_MAX_H 19#define GNULIB_SIZE_MAX_H
diff --git a/gl/snprintf.c b/gl/snprintf.c
index 9c4ab3f2..cdff3149 100644
--- a/gl/snprintf.c
+++ b/gl/snprintf.c
@@ -1,19 +1,19 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Paul Eggert. 3 Written by Simon Josefsson and Paul Eggert.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/sockets.c b/gl/sockets.c
index ae961482..ca99db8b 100644
--- a/gl/sockets.c
+++ b/gl/sockets.c
@@ -1,19 +1,19 @@
1/* sockets.c --- wrappers for Windows socket functions 1/* sockets.c --- wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Simon Josefsson */ 18/* Written by Simon Josefsson */
19 19
@@ -28,7 +28,11 @@
28# include <sys/socket.h> 28# include <sys/socket.h>
29 29
30# include "fd-hook.h" 30# include "fd-hook.h"
31# include "msvc-nothrow.h" 31# if GNULIB_MSVC_NOTHROW
32# include "msvc-nothrow.h"
33# else
34# include <io.h>
35# endif
32 36
33/* Get set_winsock_errno, FD_TO_SOCKET etc. */ 37/* Get set_winsock_errno, FD_TO_SOCKET etc. */
34# include "w32sock.h" 38# include "w32sock.h"
@@ -109,7 +113,7 @@ static int initialized_sockets_version /* = 0 */;
109#endif /* WINDOWS_SOCKETS */ 113#endif /* WINDOWS_SOCKETS */
110 114
111int 115int
112gl_sockets_startup (int version _GL_UNUSED) 116gl_sockets_startup (_GL_UNUSED int version)
113{ 117{
114#if WINDOWS_SOCKETS 118#if WINDOWS_SOCKETS
115 if (version > initialized_sockets_version) 119 if (version > initialized_sockets_version)
@@ -121,8 +125,11 @@ gl_sockets_startup (int version _GL_UNUSED)
121 if (err != 0) 125 if (err != 0)
122 return 1; 126 return 1;
123 127
124 if (data.wVersion < version) 128 if (data.wVersion != version)
125 return 2; 129 {
130 WSACleanup ();
131 return 2;
132 }
126 133
127 if (initialized_sockets_version == 0) 134 if (initialized_sockets_version == 0)
128 register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket, 135 register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket,
diff --git a/gl/sockets.h b/gl/sockets.h
index 1570ad84..a0b1601d 100644
--- a/gl/sockets.h
+++ b/gl/sockets.h
@@ -1,39 +1,39 @@
1/* sockets.h - wrappers for Windows socket functions 1/* sockets.h - wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Simon Josefsson */ 18/* Written by Simon Josefsson */
19 19
20#ifndef SOCKETS_H 20#ifndef SOCKETS_H
21# define SOCKETS_H 1 21#define SOCKETS_H 1
22 22
23#define SOCKETS_1_0 0x100 /* don't use - does not work on Windows XP */ 23#define SOCKETS_1_0 0x0001
24#define SOCKETS_1_1 0x101 24#define SOCKETS_1_1 0x0101
25#define SOCKETS_2_0 0x200 /* don't use - does not work on Windows XP */ 25#define SOCKETS_2_0 0x0002
26#define SOCKETS_2_1 0x201 26#define SOCKETS_2_1 0x0102
27#define SOCKETS_2_2 0x202 27#define SOCKETS_2_2 0x0202
28 28
29int gl_sockets_startup (int version) 29int gl_sockets_startup (int version)
30#if !WINDOWS_SOCKETS 30#ifndef WINDOWS_SOCKETS
31 _GL_ATTRIBUTE_CONST 31 _GL_ATTRIBUTE_CONST
32#endif 32#endif
33 ; 33 ;
34 34
35int gl_sockets_cleanup (void) 35int gl_sockets_cleanup (void)
36#if !WINDOWS_SOCKETS 36#ifndef WINDOWS_SOCKETS
37 _GL_ATTRIBUTE_CONST 37 _GL_ATTRIBUTE_CONST
38#endif 38#endif
39 ; 39 ;
@@ -41,11 +41,15 @@ int gl_sockets_cleanup (void)
41/* This function is useful it you create a socket using gnulib's 41/* This function is useful it you create a socket using gnulib's
42 Winsock wrappers but needs to pass on the socket handle to some 42 Winsock wrappers but needs to pass on the socket handle to some
43 other library that only accepts sockets. */ 43 other library that only accepts sockets. */
44#if WINDOWS_SOCKETS 44#ifdef WINDOWS_SOCKETS
45 45
46#include <sys/socket.h> 46# include <sys/socket.h>
47 47
48#include "msvc-nothrow.h" 48# if GNULIB_MSVC_NOTHROW
49# include "msvc-nothrow.h"
50# else
51# include <io.h>
52# endif
49 53
50static inline SOCKET 54static inline SOCKET
51gl_fd_to_handle (int fd) 55gl_fd_to_handle (int fd)
@@ -55,7 +59,7 @@ gl_fd_to_handle (int fd)
55 59
56#else 60#else
57 61
58#define gl_fd_to_handle(x) (x) 62# define gl_fd_to_handle(x) (x)
59 63
60#endif /* WINDOWS_SOCKETS */ 64#endif /* WINDOWS_SOCKETS */
61 65
diff --git a/gl/stat-time.c b/gl/stat-time.c
new file mode 100644
index 00000000..bc282232
--- /dev/null
+++ b/gl/stat-time.c
@@ -0,0 +1,21 @@
1/* stat-related time functions.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE
21#include "stat-time.h"
diff --git a/gl/stat-time.h b/gl/stat-time.h
new file mode 100644
index 00000000..92aa1e64
--- /dev/null
+++ b/gl/stat-time.h
@@ -0,0 +1,251 @@
1/* stat-related time functions.
2
3 Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20#ifndef STAT_TIME_H
21#define STAT_TIME_H 1
22
23#include <errno.h>
24#include <stdckdint.h>
25#include <stddef.h>
26#include <sys/stat.h>
27#include <time.h>
28
29#ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31#endif
32_GL_INLINE_HEADER_BEGIN
33#ifndef _GL_STAT_TIME_INLINE
34# define _GL_STAT_TIME_INLINE _GL_INLINE
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type
42 struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST,
43 ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST,
44 if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim
45 for access, status change, data modification, or birth (creation)
46 time respectively.
47
48 These macros are private to stat-time.h. */
49#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
50# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
51# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
52# else
53# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
54# endif
55#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
56# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec)
57#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
58# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec)
59#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
60# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec)
61#endif
62
63/* Return the nanosecond component of *ST's access time. */
64_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
65get_stat_atime_ns (struct stat const *st)
66{
67# if defined STAT_TIMESPEC
68 return STAT_TIMESPEC (st, st_atim).tv_nsec;
69# elif defined STAT_TIMESPEC_NS
70 return STAT_TIMESPEC_NS (st, st_atim);
71# else
72 return 0;
73# endif
74}
75
76/* Return the nanosecond component of *ST's status change time. */
77_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
78get_stat_ctime_ns (struct stat const *st)
79{
80# if defined STAT_TIMESPEC
81 return STAT_TIMESPEC (st, st_ctim).tv_nsec;
82# elif defined STAT_TIMESPEC_NS
83 return STAT_TIMESPEC_NS (st, st_ctim);
84# else
85 return 0;
86# endif
87}
88
89/* Return the nanosecond component of *ST's data modification time. */
90_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
91get_stat_mtime_ns (struct stat const *st)
92{
93# if defined STAT_TIMESPEC
94 return STAT_TIMESPEC (st, st_mtim).tv_nsec;
95# elif defined STAT_TIMESPEC_NS
96 return STAT_TIMESPEC_NS (st, st_mtim);
97# else
98 return 0;
99# endif
100}
101
102/* Return the nanosecond component of *ST's birth time. */
103_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
104get_stat_birthtime_ns (_GL_UNUSED struct stat const *st)
105{
106# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
107 return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
108# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
109 return STAT_TIMESPEC_NS (st, st_birthtim);
110# else
111 return 0;
112# endif
113}
114
115/* Return *ST's access time. */
116_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
117get_stat_atime (struct stat const *st)
118{
119#ifdef STAT_TIMESPEC
120 return STAT_TIMESPEC (st, st_atim);
121#else
122 struct timespec t;
123 t.tv_sec = st->st_atime;
124 t.tv_nsec = get_stat_atime_ns (st);
125 return t;
126#endif
127}
128
129/* Return *ST's status change time. */
130_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
131get_stat_ctime (struct stat const *st)
132{
133#ifdef STAT_TIMESPEC
134 return STAT_TIMESPEC (st, st_ctim);
135#else
136 struct timespec t;
137 t.tv_sec = st->st_ctime;
138 t.tv_nsec = get_stat_ctime_ns (st);
139 return t;
140#endif
141}
142
143/* Return *ST's data modification time. */
144_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
145get_stat_mtime (struct stat const *st)
146{
147#ifdef STAT_TIMESPEC
148 return STAT_TIMESPEC (st, st_mtim);
149#else
150 struct timespec t;
151 t.tv_sec = st->st_mtime;
152 t.tv_nsec = get_stat_mtime_ns (st);
153 return t;
154#endif
155}
156
157/* Return *ST's birth time, if available; otherwise return a value
158 with tv_sec and tv_nsec both equal to -1. */
159_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
160get_stat_birthtime (_GL_UNUSED struct stat const *st)
161{
162 struct timespec t;
163
164#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
165 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
166 t = STAT_TIMESPEC (st, st_birthtim);
167#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
168 t.tv_sec = st->st_birthtime;
169 t.tv_nsec = st->st_birthtimensec;
170#elif defined _WIN32 && ! defined __CYGWIN__
171 /* Native Windows platforms (but not Cygwin) put the "file creation
172 time" in st_ctime (!). See
173 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions>. */
174# if _GL_WINDOWS_STAT_TIMESPEC
175 t = st->st_ctim;
176# else
177 t.tv_sec = st->st_ctime;
178 t.tv_nsec = 0;
179# endif
180#else
181 /* Birth time is not supported. */
182 t.tv_sec = -1;
183 t.tv_nsec = -1;
184#endif
185
186#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
187 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \
188 || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
189 /* FreeBSD and NetBSD sometimes signal the absence of knowledge by
190 using zero. Attempt to work around this problem. Alas, this can
191 report failure even for valid timestamps. Also, NetBSD
192 sometimes returns junk in the birth time fields; work around this
193 bug if it is detected. */
194 if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
195 {
196 t.tv_sec = -1;
197 t.tv_nsec = -1;
198 }
199#endif
200
201 return t;
202}
203
204/* If a stat-like function returned RESULT, normalize the timestamps
205 in *ST, in case this platform suffers from the Solaris 11 bug where
206 tv_nsec might be negative. Return the adjusted RESULT, setting
207 errno to EOVERFLOW if normalization overflowed. This function
208 is intended to be private to this .h file. */
209_GL_STAT_TIME_INLINE int
210stat_time_normalize (int result, _GL_UNUSED struct stat *st)
211{
212#if defined __sun && defined STAT_TIMESPEC
213 if (result == 0)
214 {
215 long int timespec_hz = 1000000000;
216 short int const ts_off[] = { offsetof (struct stat, st_atim),
217 offsetof (struct stat, st_mtim),
218 offsetof (struct stat, st_ctim) };
219 int i;
220 for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
221 {
222 struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
223 long int q = ts->tv_nsec / timespec_hz;
224 long int r = ts->tv_nsec % timespec_hz;
225 if (r < 0)
226 {
227 r += timespec_hz;
228 q--;
229 }
230 ts->tv_nsec = r;
231 /* Overflow is possible, as Solaris 11 stat can yield
232 tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000.
233 INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
234 if (ckd_add (&ts->tv_sec, q, ts->tv_sec))
235 {
236 errno = EOVERFLOW;
237 return -1;
238 }
239 }
240 }
241#endif
242 return result;
243}
244
245#ifdef __cplusplus
246}
247#endif
248
249_GL_INLINE_HEADER_END
250
251#endif
diff --git a/gl/stat-w32.c b/gl/stat-w32.c
new file mode 100644
index 00000000..2f011975
--- /dev/null
+++ b/gl/stat-w32.c
@@ -0,0 +1,460 @@
1/* Core of implementation of fstat and stat for native Windows.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible. */
18
19#include <config.h>
20
21#if defined _WIN32 && ! defined __CYGWIN__
22
23/* Attempt to make <windows.h> define FILE_ID_INFO.
24 But ensure that the redefinition of _WIN32_WINNT does not make us assume
25 Windows Vista or newer when building for an older version of Windows. */
26#if HAVE_SDKDDKVER_H
27# include <sdkddkver.h>
28# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
29# define WIN32_ASSUME_VISTA 1
30# else
31# define WIN32_ASSUME_VISTA 0
32# endif
33# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
34# undef _WIN32_WINNT
35# define _WIN32_WINNT _WIN32_WINNT_WIN8
36# endif
37#else
38# define WIN32_ASSUME_VISTA (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
39#endif
40
41#include <sys/types.h>
42#include <sys/stat.h>
43#include <errno.h>
44#include <limits.h>
45#include <string.h>
46#include <unistd.h>
47#include <windows.h>
48
49/* Specification. */
50#include "stat-w32.h"
51
52#include "pathmax.h"
53
54/* Don't assume that UNICODE is not defined. */
55#undef LoadLibrary
56#define LoadLibrary LoadLibraryA
57#undef GetFinalPathNameByHandle
58#define GetFinalPathNameByHandle GetFinalPathNameByHandleA
59
60/* Older mingw headers do not define VOLUME_NAME_NONE. */
61#ifndef VOLUME_NAME_NONE
62# define VOLUME_NAME_NONE 4
63#endif
64
65#if !WIN32_ASSUME_VISTA
66
67/* Avoid warnings from gcc -Wcast-function-type. */
68# define GetProcAddress \
69 (void *) GetProcAddress
70
71# if _GL_WINDOWS_STAT_INODES == 2
72/* GetFileInformationByHandleEx was introduced only in Windows Vista. */
73typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,
74 FILE_INFO_BY_HANDLE_CLASS fiClass,
75 LPVOID lpBuffer,
76 DWORD dwBufferSize);
77static GetFileInformationByHandleExFuncType GetFileInformationByHandleExFunc = NULL;
78# endif
79/* GetFinalPathNameByHandle was introduced only in Windows Vista. */
80typedef DWORD (WINAPI * GetFinalPathNameByHandleFuncType) (HANDLE hFile,
81 LPSTR lpFilePath,
82 DWORD lenFilePath,
83 DWORD dwFlags);
84static GetFinalPathNameByHandleFuncType GetFinalPathNameByHandleFunc = NULL;
85static BOOL initialized = FALSE;
86
87static void
88initialize (void)
89{
90 HMODULE kernel32 = LoadLibrary ("kernel32.dll");
91 if (kernel32 != NULL)
92 {
93# if _GL_WINDOWS_STAT_INODES == 2
94 GetFileInformationByHandleExFunc =
95 (GetFileInformationByHandleExFuncType) GetProcAddress (kernel32, "GetFileInformationByHandleEx");
96# endif
97 GetFinalPathNameByHandleFunc =
98 (GetFinalPathNameByHandleFuncType) GetProcAddress (kernel32, "GetFinalPathNameByHandleA");
99 }
100 initialized = TRUE;
101}
102
103#else
104
105# define GetFileInformationByHandleExFunc GetFileInformationByHandleEx
106# define GetFinalPathNameByHandleFunc GetFinalPathNameByHandle
107
108#endif
109
110/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
111#if _GL_WINDOWS_STAT_TIMESPEC
112struct timespec
113_gl_convert_FILETIME_to_timespec (const FILETIME *ft)
114{
115 struct timespec result;
116 /* FILETIME: <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime> */
117 unsigned long long since_1601 =
118 ((unsigned long long) ft->dwHighDateTime << 32)
119 | (unsigned long long) ft->dwLowDateTime;
120 if (since_1601 == 0)
121 {
122 result.tv_sec = 0;
123 result.tv_nsec = 0;
124 }
125 else
126 {
127 /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
128 leap years, in total 134774 days. */
129 unsigned long long since_1970 =
130 since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
131 result.tv_sec = since_1970 / (unsigned long long) 10000000;
132 result.tv_nsec = (unsigned long) (since_1970 % (unsigned long long) 10000000) * 100;
133 }
134 return result;
135}
136#else
137time_t
138_gl_convert_FILETIME_to_POSIX (const FILETIME *ft)
139{
140 /* FILETIME: <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime> */
141 unsigned long long since_1601 =
142 ((unsigned long long) ft->dwHighDateTime << 32)
143 | (unsigned long long) ft->dwLowDateTime;
144 if (since_1601 == 0)
145 return 0;
146 else
147 {
148 /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
149 leap years, in total 134774 days. */
150 unsigned long long since_1970 =
151 since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
152 return since_1970 / (unsigned long long) 10000000;
153 }
154}
155#endif
156
157/* Fill *BUF with information about the file designated by H.
158 PATH is the file name, if known, otherwise NULL.
159 Return 0 if successful, or -1 with errno set upon failure. */
160int
161_gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
162{
163 /* GetFileType
164 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfiletype> */
165 DWORD type = GetFileType (h);
166 if (type == FILE_TYPE_DISK)
167 {
168#if !WIN32_ASSUME_VISTA
169 if (!initialized)
170 initialize ();
171#endif
172
173 /* st_mode can be determined through
174 GetFileAttributesEx
175 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileattributesexa>
176 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_win32_file_attribute_data>
177 or through
178 GetFileInformationByHandle
179 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
180 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
181 or through
182 GetFileInformationByHandleEx with argument FileBasicInfo
183 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
184 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_basic_info>
185 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
186 BY_HANDLE_FILE_INFORMATION info;
187 if (! GetFileInformationByHandle (h, &info))
188 goto failed;
189
190 /* Test for error conditions before starting to fill *buf. */
191 if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
192 {
193 errno = EOVERFLOW;
194 return -1;
195 }
196
197#if _GL_WINDOWS_STAT_INODES
198 /* st_ino can be determined through
199 GetFileInformationByHandle
200 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
201 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
202 as 64 bits, or through
203 GetFileInformationByHandleEx with argument FileIdInfo
204 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
205 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_id_info>
206 as 128 bits.
207 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_WIN8 or higher. */
208 /* Experiments show that GetFileInformationByHandleEx does not provide
209 much more information than GetFileInformationByHandle:
210 * The dwVolumeSerialNumber from GetFileInformationByHandle is equal
211 to the low 32 bits of the 64-bit VolumeSerialNumber from
212 GetFileInformationByHandleEx, and is apparently sufficient for
213 identifying the device.
214 * The nFileIndex from GetFileInformationByHandle is equal to the low
215 64 bits of the 128-bit FileId from GetFileInformationByHandleEx,
216 and the high 64 bits of this 128-bit FileId are zero.
217 * On a FAT file system, GetFileInformationByHandleEx fails with error
218 ERROR_INVALID_PARAMETER, whereas GetFileInformationByHandle
219 succeeds.
220 * On a CIFS/SMB file system, GetFileInformationByHandleEx fails with
221 error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle
222 succeeds. */
223# if _GL_WINDOWS_STAT_INODES == 2
224 if (GetFileInformationByHandleExFunc != NULL)
225 {
226 FILE_ID_INFO id;
227 if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id)))
228 {
229 buf->st_dev = id.VolumeSerialNumber;
230 static_assert (sizeof (ino_t) == sizeof (id.FileId));
231 memcpy (&buf->st_ino, &id.FileId, sizeof (ino_t));
232 goto ino_done;
233 }
234 else
235 {
236 switch (GetLastError ())
237 {
238 case ERROR_INVALID_PARAMETER: /* older Windows version, or FAT */
239 case ERROR_INVALID_LEVEL: /* CIFS/SMB file system */
240 goto fallback;
241 default:
242 goto failed;
243 }
244 }
245 }
246 fallback: ;
247 /* Fallback for older Windows versions. */
248 buf->st_dev = info.dwVolumeSerialNumber;
249 buf->st_ino._gl_ino[0] = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
250 buf->st_ino._gl_ino[1] = 0;
251 ino_done: ;
252# else /* _GL_WINDOWS_STAT_INODES == 1 */
253 buf->st_dev = info.dwVolumeSerialNumber;
254 buf->st_ino = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
255# endif
256#else
257 /* st_ino is not wide enough for identifying a file on a device.
258 Without st_ino, st_dev is pointless. */
259 buf->st_dev = 0;
260 buf->st_ino = 0;
261#endif
262
263 /* st_mode. */
264 unsigned int mode =
265 /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
266 ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
267 | S_IREAD_UGO
268 | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
269 if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
270 {
271 /* Determine whether the file is executable by looking at the file
272 name suffix.
273 If the file name is already known, use it. Otherwise, for
274 non-empty files, it can be determined through
275 GetFinalPathNameByHandle
276 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea>
277 or through
278 GetFileInformationByHandleEx with argument FileNameInfo
279 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
280 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_name_info>
281 Both require -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
282 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
283 {
284 char fpath[PATH_MAX];
285 if (path != NULL
286 || (GetFinalPathNameByHandleFunc != NULL
287 && GetFinalPathNameByHandleFunc (h, fpath, sizeof (fpath), VOLUME_NAME_NONE)
288 < sizeof (fpath)
289 && (path = fpath, 1)))
290 {
291 const char *last_dot = NULL;
292 const char *p;
293 for (p = path; *p != '\0'; p++)
294 if (*p == '.')
295 last_dot = p;
296 if (last_dot != NULL)
297 {
298 const char *suffix = last_dot + 1;
299 if (_stricmp (suffix, "exe") == 0
300 || _stricmp (suffix, "bat") == 0
301 || _stricmp (suffix, "cmd") == 0
302 || _stricmp (suffix, "com") == 0)
303 mode |= S_IEXEC_UGO;
304 }
305 }
306 else
307 /* Cannot determine file name. Pretend that it is executable. */
308 mode |= S_IEXEC_UGO;
309 }
310 }
311 buf->st_mode = mode;
312
313 /* st_nlink can be determined through
314 GetFileInformationByHandle
315 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
316 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
317 or through
318 GetFileInformationByHandleEx with argument FileStandardInfo
319 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
320 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_standard_info>
321 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
322 buf->st_nlink = (info.nNumberOfLinks > SHRT_MAX ? SHRT_MAX : info.nNumberOfLinks);
323
324 /* There's no easy way to map the Windows SID concept to an integer. */
325 buf->st_uid = 0;
326 buf->st_gid = 0;
327
328 /* st_rdev is irrelevant for normal files and directories. */
329 buf->st_rdev = 0;
330
331 /* st_size can be determined through
332 GetFileSizeEx
333 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfilesizeex>
334 or through
335 GetFileAttributesEx
336 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileattributesexa>
337 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_win32_file_attribute_data>
338 or through
339 GetFileInformationByHandle
340 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
341 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
342 or through
343 GetFileInformationByHandleEx with argument FileStandardInfo
344 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
345 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_standard_info>
346 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
347 if (sizeof (buf->st_size) <= 4)
348 /* Range check already done above. */
349 buf->st_size = info.nFileSizeLow;
350 else
351 buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
352
353 /* st_atime, st_mtime, st_ctime can be determined through
354 GetFileTime
355 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfiletime>
356 or through
357 GetFileAttributesEx
358 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileattributesexa>
359 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_win32_file_attribute_data>
360 or through
361 GetFileInformationByHandle
362 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
363 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
364 or through
365 GetFileInformationByHandleEx with argument FileBasicInfo
366 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
367 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_basic_info>
368 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
369#if _GL_WINDOWS_STAT_TIMESPEC
370 buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
371 buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
372 buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
373#else
374 buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
375 buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
376 buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
377#endif
378
379 return 0;
380 }
381 else if (type == FILE_TYPE_CHAR || type == FILE_TYPE_PIPE)
382 {
383 buf->st_dev = 0;
384#if _GL_WINDOWS_STAT_INODES == 2
385 buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
386#else
387 buf->st_ino = 0;
388#endif
389 buf->st_mode = (type == FILE_TYPE_PIPE ? _S_IFIFO : _S_IFCHR);
390 buf->st_nlink = 1;
391 buf->st_uid = 0;
392 buf->st_gid = 0;
393 buf->st_rdev = 0;
394 if (type == FILE_TYPE_PIPE)
395 {
396 /* PeekNamedPipe
397 <https://msdn.microsoft.com/en-us/library/aa365779.aspx> */
398 DWORD bytes_available;
399 if (PeekNamedPipe (h, NULL, 0, NULL, &bytes_available, NULL))
400 buf->st_size = bytes_available;
401 else
402 buf->st_size = 0;
403 }
404 else
405 buf->st_size = 0;
406#if _GL_WINDOWS_STAT_TIMESPEC
407 buf->st_atim.tv_sec = 0; buf->st_atim.tv_nsec = 0;
408 buf->st_mtim.tv_sec = 0; buf->st_mtim.tv_nsec = 0;
409 buf->st_ctim.tv_sec = 0; buf->st_ctim.tv_nsec = 0;
410#else
411 buf->st_atime = 0;
412 buf->st_mtime = 0;
413 buf->st_ctime = 0;
414#endif
415 return 0;
416 }
417 else
418 {
419 errno = ENOENT;
420 return -1;
421 }
422
423 failed:
424 {
425 DWORD error = GetLastError ();
426 #if 0
427 fprintf (stderr, "_gl_fstat_by_handle error 0x%x\n", (unsigned int) error);
428 #endif
429 switch (error)
430 {
431 case ERROR_ACCESS_DENIED:
432 case ERROR_SHARING_VIOLATION:
433 errno = EACCES;
434 break;
435
436 case ERROR_OUTOFMEMORY:
437 errno = ENOMEM;
438 break;
439
440 case ERROR_WRITE_FAULT:
441 case ERROR_READ_FAULT:
442 case ERROR_GEN_FAILURE:
443 errno = EIO;
444 break;
445
446 default:
447 errno = EINVAL;
448 break;
449 }
450 return -1;
451 }
452}
453
454#else
455
456/* This declaration is solely to ensure that after preprocessing
457 this file is never empty. */
458typedef int dummy;
459
460#endif
diff --git a/gl/stat-w32.h b/gl/stat-w32.h
new file mode 100644
index 00000000..c6738749
--- /dev/null
+++ b/gl/stat-w32.h
@@ -0,0 +1,37 @@
1/* Core of implementation of fstat and stat for native Windows.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _STAT_W32_H
18#define _STAT_W32_H 1
19
20/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
21#if _GL_WINDOWS_STAT_TIMESPEC
22extern struct timespec _gl_convert_FILETIME_to_timespec (const FILETIME *ft);
23#else
24extern time_t _gl_convert_FILETIME_to_POSIX (const FILETIME *ft);
25#endif
26
27/* Fill *BUF with information about the file designated by H.
28 PATH is the file name, if known, otherwise NULL.
29 Return 0 if successful, or -1 with errno set upon failure. */
30extern int _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf);
31
32/* Bitmasks for st_mode. */
33#define S_IREAD_UGO (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
34#define S_IWRITE_UGO (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
35#define S_IEXEC_UGO (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6))
36
37#endif /* _STAT_W32_H */
diff --git a/gl/stat.c b/gl/stat.c
new file mode 100644
index 00000000..7987e265
--- /dev/null
+++ b/gl/stat.c
@@ -0,0 +1,438 @@
1/* Work around platform bugs in stat.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Eric Blake and Bruno Haible. */
18
19/* If the user's config.h happens to include <sys/stat.h>, let it include only
20 the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
21 rpl_stat. */
22#define __need_system_sys_stat_h
23#include <config.h>
24
25/* Get the original definition of stat. It might be defined as a macro. */
26#include <sys/types.h>
27#include <sys/stat.h>
28#undef __need_system_sys_stat_h
29
30#if defined _WIN32 && ! defined __CYGWIN__
31# define WINDOWS_NATIVE
32#endif
33
34#if !defined WINDOWS_NATIVE
35
36static int
37orig_stat (const char *filename, struct stat *buf)
38{
39 return stat (filename, buf);
40}
41
42#endif
43
44/* Specification. */
45#ifdef __osf__
46/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
47 eliminates this include because of the preliminary #include <sys/stat.h>
48 above. */
49# include "sys/stat.h"
50#else
51# include <sys/stat.h>
52#endif
53
54#include "stat-time.h"
55
56#include <errno.h>
57#include <limits.h>
58#include <string.h>
59#include "filename.h"
60#include "malloca.h"
61
62#ifdef WINDOWS_NATIVE
63# define WIN32_LEAN_AND_MEAN
64# include <windows.h>
65# include "stat-w32.h"
66/* Don't assume that UNICODE is not defined. */
67# undef WIN32_FIND_DATA
68# define WIN32_FIND_DATA WIN32_FIND_DATAA
69# undef CreateFile
70# define CreateFile CreateFileA
71# undef FindFirstFile
72# define FindFirstFile FindFirstFileA
73#endif
74
75#ifdef WINDOWS_NATIVE
76/* Return TRUE if the given file name denotes an UNC root. */
77static BOOL
78is_unc_root (const char *rname)
79{
80 /* Test whether it has the syntax '\\server\share'. */
81 if (ISSLASH (rname[0]) && ISSLASH (rname[1]))
82 {
83 /* It starts with two slashes. Find the next slash. */
84 const char *p = rname + 2;
85 const char *q = p;
86 while (*q != '\0' && !ISSLASH (*q))
87 q++;
88 if (q > p && *q != '\0')
89 {
90 /* Found the next slash at q. */
91 q++;
92 const char *r = q;
93 while (*r != '\0' && !ISSLASH (*r))
94 r++;
95 if (r > q && *r == '\0')
96 return TRUE;
97 }
98 }
99 return FALSE;
100}
101#endif
102
103/* Store information about NAME into ST. Work around bugs with
104 trailing slashes. Mingw has other bugs (such as st_ino always
105 being 0 on success) which this wrapper does not work around. But
106 at least this implementation provides the ability to emulate fchdir
107 correctly. */
108
109int
110rpl_stat (char const *name, struct stat *buf)
111{
112#ifdef WINDOWS_NATIVE
113 /* Fill the fields ourselves, because the original stat function returns
114 values for st_atime, st_mtime, st_ctime that depend on the current time
115 zone. See
116 <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
117 /* XXX Should we convert to wchar_t* and prepend '\\?\', in order to work
118 around length limitations
119 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file> ? */
120
121 /* POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>
122 specifies: "More than two leading <slash> characters shall be treated as
123 a single <slash> character." */
124 if (ISSLASH (name[0]) && ISSLASH (name[1]) && ISSLASH (name[2]))
125 {
126 name += 2;
127 while (ISSLASH (name[1]))
128 name++;
129 }
130
131 size_t len = strlen (name);
132 size_t drive_prefix_len = (HAS_DEVICE (name) ? 2 : 0);
133
134 /* Remove trailing slashes (except the very first one, at position
135 drive_prefix_len), but remember their presence. */
136 size_t rlen;
137 bool check_dir = false;
138
139 rlen = len;
140 while (rlen > drive_prefix_len && ISSLASH (name[rlen-1]))
141 {
142 check_dir = true;
143 if (rlen == drive_prefix_len + 1)
144 break;
145 rlen--;
146 }
147
148 /* Handle '' and 'C:'. */
149 if (!check_dir && rlen == drive_prefix_len)
150 {
151 errno = ENOENT;
152 return -1;
153 }
154
155 /* Handle '\\'. */
156 if (rlen == 1 && ISSLASH (name[0]) && len >= 2)
157 {
158 errno = ENOENT;
159 return -1;
160 }
161
162 const char *rname;
163 char *malloca_rname;
164 if (rlen == len)
165 {
166 rname = name;
167 malloca_rname = NULL;
168 }
169 else
170 {
171 malloca_rname = malloca (rlen + 1);
172 if (malloca_rname == NULL)
173 {
174 errno = ENOMEM;
175 return -1;
176 }
177 memcpy (malloca_rname, name, rlen);
178 malloca_rname[rlen] = '\0';
179 rname = malloca_rname;
180 }
181
182 /* There are two ways to get at the requested information:
183 - by scanning the parent directory and examining the relevant
184 directory entry,
185 - by opening the file directly.
186 The first approach fails for root directories (e.g. 'C:\') and
187 UNC root directories (e.g. '\\server\share').
188 The second approach fails for some system files (e.g. 'C:\pagefile.sys'
189 and 'C:\hiberfil.sys'): ERROR_SHARING_VIOLATION.
190 The second approach gives more information (in particular, correct
191 st_dev, st_ino, st_nlink fields).
192 So we use the second approach and, as a fallback except for root and
193 UNC root directories, also the first approach. */
194 {
195 int ret;
196
197 {
198 /* Approach based on the file. */
199
200 /* Open a handle to the file.
201 CreateFile
202 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea>
203 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/creating-and-opening-files> */
204 HANDLE h =
205 CreateFile (rname,
206 FILE_READ_ATTRIBUTES,
207 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
208 NULL,
209 OPEN_EXISTING,
210 /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only
211 in case as different) makes sense only when applied to *all*
212 filesystem operations. */
213 FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */,
214 NULL);
215 if (h != INVALID_HANDLE_VALUE)
216 {
217 ret = _gl_fstat_by_handle (h, rname, buf);
218 CloseHandle (h);
219 goto done;
220 }
221 }
222
223 /* Test for root and UNC root directories. */
224 if ((rlen == drive_prefix_len + 1 && ISSLASH (rname[drive_prefix_len]))
225 || is_unc_root (rname))
226 goto failed;
227
228 /* Fallback. */
229 {
230 /* Approach based on the directory entry. */
231
232 if (strchr (rname, '?') != NULL || strchr (rname, '*') != NULL)
233 {
234 /* Other Windows API functions would fail with error
235 ERROR_INVALID_NAME. */
236 if (malloca_rname != NULL)
237 freea (malloca_rname);
238 errno = ENOENT;
239 return -1;
240 }
241
242 /* Get the details about the directory entry. This can be done through
243 FindFirstFile
244 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findfirstfilea>
245 <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-_win32_find_dataa>
246 or through
247 FindFirstFileEx with argument FindExInfoBasic
248 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findfirstfileexa>
249 <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ne-minwinbase-findex_info_levels>
250 <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-_win32_find_dataa> */
251 WIN32_FIND_DATA info;
252 HANDLE h = FindFirstFile (rname, &info);
253 if (h == INVALID_HANDLE_VALUE)
254 goto failed;
255
256 /* Test for error conditions before starting to fill *buf. */
257 if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
258 {
259 FindClose (h);
260 if (malloca_rname != NULL)
261 freea (malloca_rname);
262 errno = EOVERFLOW;
263 return -1;
264 }
265
266# if _GL_WINDOWS_STAT_INODES
267 buf->st_dev = 0;
268# if _GL_WINDOWS_STAT_INODES == 2
269 buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
270# else /* _GL_WINDOWS_STAT_INODES == 1 */
271 buf->st_ino = 0;
272# endif
273# else
274 /* st_ino is not wide enough for identifying a file on a device.
275 Without st_ino, st_dev is pointless. */
276 buf->st_dev = 0;
277 buf->st_ino = 0;
278# endif
279
280 /* st_mode. */
281 unsigned int mode =
282 /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
283 ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
284 | S_IREAD_UGO
285 | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
286 if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
287 {
288 /* Determine whether the file is executable by looking at the file
289 name suffix. */
290 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
291 {
292 const char *last_dot = NULL;
293 const char *p;
294 for (p = info.cFileName; *p != '\0'; p++)
295 if (*p == '.')
296 last_dot = p;
297 if (last_dot != NULL)
298 {
299 const char *suffix = last_dot + 1;
300 if (_stricmp (suffix, "exe") == 0
301 || _stricmp (suffix, "bat") == 0
302 || _stricmp (suffix, "cmd") == 0
303 || _stricmp (suffix, "com") == 0)
304 mode |= S_IEXEC_UGO;
305 }
306 }
307 }
308 buf->st_mode = mode;
309
310 /* st_nlink. Ignore hard links here. */
311 buf->st_nlink = 1;
312
313 /* There's no easy way to map the Windows SID concept to an integer. */
314 buf->st_uid = 0;
315 buf->st_gid = 0;
316
317 /* st_rdev is irrelevant for normal files and directories. */
318 buf->st_rdev = 0;
319
320 /* st_size. */
321 if (sizeof (buf->st_size) <= 4)
322 /* Range check already done above. */
323 buf->st_size = info.nFileSizeLow;
324 else
325 buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
326
327 /* st_atime, st_mtime, st_ctime. */
328# if _GL_WINDOWS_STAT_TIMESPEC
329 buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
330 buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
331 buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
332# else
333 buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
334 buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
335 buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
336# endif
337
338 FindClose (h);
339
340 ret = 0;
341 }
342
343 done:
344 if (ret >= 0 && check_dir && !S_ISDIR (buf->st_mode))
345 {
346 errno = ENOTDIR;
347 ret = -1;
348 }
349 if (malloca_rname != NULL)
350 {
351 int saved_errno = errno;
352 freea (malloca_rname);
353 errno = saved_errno;
354 }
355 return ret;
356 }
357
358 failed:
359 {
360 DWORD error = GetLastError ();
361 #if 0
362 fprintf (stderr, "rpl_stat error 0x%x\n", (unsigned int) error);
363 #endif
364
365 if (malloca_rname != NULL)
366 freea (malloca_rname);
367
368 switch (error)
369 {
370 /* Some of these errors probably cannot happen with the specific flags
371 that we pass to CreateFile. But who knows... */
372 case ERROR_FILE_NOT_FOUND: /* The last component of rname does not exist. */
373 case ERROR_PATH_NOT_FOUND: /* Some directory component in rname does not exist. */
374 case ERROR_BAD_PATHNAME: /* rname is such as '\\server'. */
375 case ERROR_BAD_NET_NAME: /* rname is such as '\\server\nonexistentshare'. */
376 case ERROR_INVALID_NAME: /* rname contains wildcards, misplaced colon, etc. */
377 case ERROR_DIRECTORY:
378 errno = ENOENT;
379 break;
380
381 case ERROR_ACCESS_DENIED: /* rname is such as 'C:\System Volume Information\foo'. */
382 case ERROR_SHARING_VIOLATION: /* rname is such as 'C:\pagefile.sys' (second approach only). */
383 /* XXX map to EACCES or EPERM? */
384 errno = EACCES;
385 break;
386
387 case ERROR_OUTOFMEMORY:
388 errno = ENOMEM;
389 break;
390
391 case ERROR_WRITE_PROTECT:
392 errno = EROFS;
393 break;
394
395 case ERROR_WRITE_FAULT:
396 case ERROR_READ_FAULT:
397 case ERROR_GEN_FAILURE:
398 errno = EIO;
399 break;
400
401 case ERROR_BUFFER_OVERFLOW:
402 case ERROR_FILENAME_EXCED_RANGE:
403 errno = ENAMETOOLONG;
404 break;
405
406 case ERROR_DELETE_PENDING: /* XXX map to EACCES or EPERM? */
407 errno = EPERM;
408 break;
409
410 default:
411 errno = EINVAL;
412 break;
413 }
414
415 return -1;
416 }
417#else
418 int result = orig_stat (name, buf);
419 if (result == 0)
420 {
421# if REPLACE_FUNC_STAT_FILE
422 /* Solaris 9 mistakenly succeeds when given a non-directory with a
423 trailing slash. */
424 if (!S_ISDIR (buf->st_mode))
425 {
426 size_t len = strlen (name);
427 if (ISSLASH (name[len - 1]))
428 {
429 errno = ENOTDIR;
430 return -1;
431 }
432 }
433# endif /* REPLACE_FUNC_STAT_FILE */
434 result = stat_time_normalize (result, buf);
435 }
436 return result;
437#endif
438}
diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h
index 7254a3de..7f9dbb46 100644
--- a/gl/stdalign.in.h
+++ b/gl/stdalign.in.h
@@ -1,19 +1,19 @@
1/* A substitute for ISO C11 <stdalign.h>. 1/* A substitute for ISO C11 <stdalign.h>.
2 2
3 Copyright 2011-2013 Free Software Foundation, Inc. 3 Copyright 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paul Eggert and Bruno Haible. */ 18/* Written by Paul Eggert and Bruno Haible. */
19 19
@@ -34,17 +34,15 @@
34 requirement of a structure member (i.e., slot or field) that is of 34 requirement of a structure member (i.e., slot or field) that is of
35 type TYPE, as an integer constant expression. 35 type TYPE, as an integer constant expression.
36 36
37 This differs from GCC's __alignof__ operator, which can yield a 37 This differs from GCC's and clang's __alignof__ operator, which can
38 better-performing alignment for an object of that type. For 38 yield a better-performing alignment for an object of that type. For
39 example, on x86 with GCC, __alignof__ (double) and __alignof__ 39 example, on x86 with GCC and on Linux/x86 with clang,
40 (long long) are 8, whereas alignof (double) and alignof (long long) 40 __alignof__ (double) and __alignof__ (long long) are 8, whereas
41 are 4 unless the option '-malign-double' is used. 41 alignof (double) and alignof (long long) are 4 unless the option
42 '-malign-double' is used.
42 43
43 The result cannot be used as a value for an 'enum' constant, if you 44 The result cannot be used as a value for an 'enum' constant, if you
44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. 45 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
45
46 Include <stddef.h> for offsetof. */
47#include <stddef.h>
48 46
49/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other 47/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
50 standard headers, defines conflicting implementations of _Alignas 48 standard headers, defines conflicting implementations of _Alignas
@@ -52,19 +50,33 @@
52#undef _Alignas 50#undef _Alignas
53#undef _Alignof 51#undef _Alignof
54 52
55#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 53/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
54 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
55 clang versions < 8.0.0 have the same bug. */
56#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
57 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
58 && !defined __clang__) \
59 || (defined __clang__ && __clang_major__ < 8))
56# ifdef __cplusplus 60# ifdef __cplusplus
57# if 201103 <= __cplusplus 61# if (201103 <= __cplusplus || defined _MSC_VER)
58# define _Alignof(type) alignof (type) 62# define _Alignof(type) alignof (type)
59# else 63# else
60 template <class __t> struct __alignof_helper { char __a; __t __b; }; 64 template <class __t> struct __alignof_helper { char __a; __t __b; };
61# define _Alignof(type) offsetof (__alignof_helper<type>, __b) 65# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
66# define _GL_STDALIGN_NEEDS_STDDEF 1
62# endif 67# endif
63# else 68# else
64# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) 69# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
70# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
71# else
72# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
73# define _GL_STDALIGN_NEEDS_STDDEF 1
74# endif
65# endif 75# endif
66#endif 76#endif
67#define alignof _Alignof 77#if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
78# define alignof _Alignof
79#endif
68#define __alignof_is_defined 1 80#define __alignof_is_defined 1
69 81
70/* alignas (A), also known as _Alignas (A), aligns a variable or type 82/* alignas (A), also known as _Alignas (A), aligns a variable or type
@@ -93,17 +105,33 @@
93 */ 105 */
94 106
95#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 107#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
96# if defined __cplusplus && 201103 <= __cplusplus 108# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
97# define _Alignas(a) alignas (a) 109# define _Alignas(a) alignas (a)
98# elif __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C 110# elif (!defined __attribute__ \
111 && ((defined __APPLE__ && defined __MACH__ \
112 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
113 : __GNUC__ && !defined __ibmxl__) \
114 || (4 <= __clang_major__) \
115 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
116 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
99# define _Alignas(a) __attribute__ ((__aligned__ (a))) 117# define _Alignas(a) __attribute__ ((__aligned__ (a)))
100# elif 1300 <= _MSC_VER 118# elif 1300 <= _MSC_VER
101# define _Alignas(a) __declspec (align (a)) 119# define _Alignas(a) __declspec (align (a))
102# endif 120# endif
103#endif 121#endif
104#if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__) 122#if ((defined _Alignas \
123 && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
124 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
105# define alignas _Alignas 125# define alignas _Alignas
126#endif
127#if (defined alignas \
128 || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
106# define __alignas_is_defined 1 129# define __alignas_is_defined 1
107#endif 130#endif
108 131
132/* Include <stddef.h> if needed for offsetof. */
133#if _GL_STDALIGN_NEEDS_STDDEF
134# include <stddef.h>
135#endif
136
109#endif /* _GL_STDALIGN_H */ 137#endif /* _GL_STDALIGN_H */
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h
deleted file mode 100644
index 7c157727..00000000
--- a/gl/stdbool.in.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc.
2 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _GL_STDBOOL_H
18#define _GL_STDBOOL_H
19
20/* ISO C 99 <stdbool.h> for platforms that lack it. */
21
22/* Usage suggestions:
23
24 Programs that use <stdbool.h> should be aware of some limitations
25 and standards compliance issues.
26
27 Standards compliance:
28
29 - <stdbool.h> must be #included before 'bool', 'false', 'true'
30 can be used.
31
32 - You cannot assume that sizeof (bool) == 1.
33
34 - Programs should not undefine the macros bool, true, and false,
35 as C99 lists that as an "obsolescent feature".
36
37 Limitations of this substitute, when used in a C89 environment:
38
39 - <stdbool.h> must be #included before the '_Bool' type can be used.
40
41 - You cannot assume that _Bool is a typedef; it might be a macro.
42
43 - Bit-fields of type 'bool' are not supported. Portable code
44 should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
45
46 - In C99, casts and automatic conversions to '_Bool' or 'bool' are
47 performed in such a way that every nonzero value gets converted
48 to 'true', and zero gets converted to 'false'. This doesn't work
49 with this substitute. With this substitute, only the values 0 and 1
50 give the expected result when converted to _Bool' or 'bool'.
51
52 - C99 allows the use of (_Bool)0.0 in constant expressions, but
53 this substitute cannot always provide this property.
54
55 Also, it is suggested that programs use 'bool' rather than '_Bool';
56 this isn't required, but 'bool' is more common. */
57
58
59/* 7.16. Boolean type and values */
60
61/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
62 definitions below, but temporarily we have to #undef them. */
63#if defined __BEOS__ && !defined __HAIKU__
64# include <OS.h> /* defines bool but not _Bool */
65# undef false
66# undef true
67#endif
68
69#ifdef __cplusplus
70# define _Bool bool
71# define bool bool
72#else
73# if defined __BEOS__ && !defined __HAIKU__
74 /* A compiler known to have 'bool'. */
75 /* If the compiler already has both 'bool' and '_Bool', we can assume they
76 are the same types. */
77# if !@HAVE__BOOL@
78typedef bool _Bool;
79# endif
80# else
81# if !defined __GNUC__
82 /* If @HAVE__BOOL@:
83 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
84 the built-in _Bool type is used. See
85 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
86 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
87 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
88 Similar bugs are likely with other compilers as well; this file
89 wouldn't be used if <stdbool.h> was working.
90 So we override the _Bool type.
91 If !@HAVE__BOOL@:
92 Need to define _Bool ourselves. As 'signed char' or as an enum type?
93 Use of a typedef, with SunPRO C, leads to a stupid
94 "warning: _Bool is a keyword in ISO C99".
95 Use of an enum type, with IRIX cc, leads to a stupid
96 "warning(1185): enumerated type mixed with another type".
97 Even the existence of an enum type, without a typedef,
98 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
99 The only benefit of the enum, debuggability, is not important
100 with these compilers. So use 'signed char' and no enum. */
101# define _Bool signed char
102# else
103 /* With this compiler, trust the _Bool type if the compiler has it. */
104# if !@HAVE__BOOL@
105 /* For the sake of symbolic names in gdb, define true and false as
106 enum constants, not only as macros.
107 It is tempting to write
108 typedef enum { false = 0, true = 1 } _Bool;
109 so that gdb prints values of type 'bool' symbolically. But then
110 values of type '_Bool' might promote to 'int' or 'unsigned int'
111 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
112 (see ISO C 99 6.3.1.1.(2)). So add a negative value to the
113 enum; this ensures that '_Bool' promotes to 'int'. */
114typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
115# endif
116# endif
117# endif
118# define bool _Bool
119#endif
120
121/* The other macros must be usable in preprocessor directives. */
122#ifdef __cplusplus
123# define false false
124# define true true
125#else
126# define false 0
127# define true 1
128#endif
129
130#define __bool_true_false_are_defined 1
131
132#endif /* _GL_STDBOOL_H */
diff --git a/gl/stdckdint.in.h b/gl/stdckdint.in.h
new file mode 100644
index 00000000..71bab5f0
--- /dev/null
+++ b/gl/stdckdint.in.h
@@ -0,0 +1,35 @@
1/* stdckdint.h -- checked integer arithmetic
2
3 Copyright 2022-2023 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_STDCKDINT_H
19#define _GL_STDCKDINT_H
20
21#include "intprops-internal.h"
22
23/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
24 Return 1 if the result overflows, 0 otherwise.
25 A, B, and *R can have any integer type other than char, bool, a
26 bit-precise integer type, or an enumeration type.
27
28 These are like the standard macros introduced in C23, except that
29 arguments should not have side effects. */
30
31#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
32#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
33#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
34
35#endif /* _GL_STDCKDINT_H */
diff --git a/gl/stddef.in.h b/gl/stddef.in.h
index 40f0536a..6eadcc3d 100644
--- a/gl/stddef.in.h
+++ b/gl/stddef.in.h
@@ -1,25 +1,25 @@
1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. 1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
2 2
3 Copyright (C) 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
19 19
20/* 20/*
21 * POSIX 2008 <stddef.h> for platforms that have issues. 21 * POSIX 2008 <stddef.h> for platforms that have issues.
22 * <http://www.opengroup.org/susv3xbd/stddef.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
23 */ 23 */
24 24
25#if __GNUC__ >= 3 25#if __GNUC__ >= 3
@@ -39,10 +39,16 @@
39 39
40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) 40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
41# ifdef __need_wint_t 41# ifdef __need_wint_t
42# undef _@GUARD_PREFIX@_STDDEF_H
43# define _GL_STDDEF_WINT_T 42# define _GL_STDDEF_WINT_T
44# endif 43# endif
45# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 44# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
45 /* On TinyCC, make sure that the macros that indicate the special invocation
46 convention get undefined. */
47# undef __need_wchar_t
48# undef __need_size_t
49# undef __need_ptrdiff_t
50# undef __need_NULL
51# undef __need_wint_t
46# endif 52# endif
47 53
48#else 54#else
@@ -50,37 +56,92 @@
50 56
51# ifndef _@GUARD_PREFIX@_STDDEF_H 57# ifndef _@GUARD_PREFIX@_STDDEF_H
52 58
59/* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
60 type with alignment 4, but 'long' has alignment 8. */
61# if defined _AIX && defined __LP64__
62# if !GNULIB_defined_max_align_t
63# ifdef _MAX_ALIGN_T
64/* /usr/include/stddef.h has already defined max_align_t. Override it. */
65typedef long rpl_max_align_t;
66# define max_align_t rpl_max_align_t
67# else
68/* Prevent /usr/include/stddef.h from defining max_align_t. */
69typedef long max_align_t;
70# define _MAX_ALIGN_T
71# endif
72# define GNULIB_defined_max_align_t 1
73# endif
74# endif
75
53/* The include_next requires a split double-inclusion guard. */ 76/* The include_next requires a split double-inclusion guard. */
54 77
55# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 78# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
56 79
57# ifndef _@GUARD_PREFIX@_STDDEF_H
58# define _@GUARD_PREFIX@_STDDEF_H
59
60/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ 80/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
61#if @REPLACE_NULL@ 81# if (@REPLACE_NULL@ \
62# undef NULL 82 && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T))
63# ifdef __cplusplus 83# undef NULL
84# ifdef __cplusplus
64 /* ISO C++ says that the macro NULL must expand to an integer constant 85 /* ISO C++ says that the macro NULL must expand to an integer constant
65 expression, hence '((void *) 0)' is not allowed in C++. */ 86 expression, hence '((void *) 0)' is not allowed in C++. */
66# if __GNUG__ >= 3 87# if __GNUG__ >= 3
67 /* GNU C++ has a __null macro that behaves like an integer ('int' or 88 /* GNU C++ has a __null macro that behaves like an integer ('int' or
68 'long') but has the same size as a pointer. Use that, to avoid 89 'long') but has the same size as a pointer. Use that, to avoid
69 warnings. */ 90 warnings. */
70# define NULL __null 91# define NULL __null
71# else 92# else
72# define NULL 0L 93# define NULL 0L
94# endif
95# else
96# define NULL ((void *) 0)
97# endif
73# endif 98# endif
74# else 99
75# define NULL ((void *) 0) 100# ifndef _@GUARD_PREFIX@_STDDEF_H
76# endif 101# define _@GUARD_PREFIX@_STDDEF_H
77#endif
78 102
79/* Some platforms lack wchar_t. */ 103/* Some platforms lack wchar_t. */
80#if !@HAVE_WCHAR_T@ 104#if !@HAVE_WCHAR_T@
81# define wchar_t int 105# define wchar_t int
82#endif 106#endif
83 107
108/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is
109 a hack in case the configure-time test was done with g++ even though
110 we are currently compiling with gcc.
111 On MSVC, max_align_t is defined only in C++ mode, after <cstddef> was
112 included. Its definition is good since it has an alignment of 8 (on x86
113 and x86_64).
114 Similarly on OS/2 kLIBC. */
115#if (defined _MSC_VER || (defined __KLIBC__ && !defined __LIBCN__)) \
116 && defined __cplusplus
117# include <cstddef>
118#else
119# if ! (@HAVE_MAX_ALIGN_T@ || (defined _GCC_MAX_ALIGN_T && !defined __clang__))
120# if !GNULIB_defined_max_align_t
121/* On the x86, the maximum storage alignment of double, long, etc. is 4,
122 but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
123 and the C11 standard allows this. Work around this problem by
124 using __alignof__ (which returns 8 for double) rather than _Alignof
125 (which returns 4), and align each union member accordingly. */
126# if defined __GNUC__ || (__clang_major__ >= 4)
127# define _GL_STDDEF_ALIGNAS(type) \
128 __attribute__ ((__aligned__ (__alignof__ (type))))
129# else
130# define _GL_STDDEF_ALIGNAS(type) /* */
131# endif
132typedef union
133{
134 char *__p _GL_STDDEF_ALIGNAS (char *);
135 double __d _GL_STDDEF_ALIGNAS (double);
136 long double __ld _GL_STDDEF_ALIGNAS (long double);
137 long int __i _GL_STDDEF_ALIGNAS (long int);
138} rpl_max_align_t;
139# define max_align_t rpl_max_align_t
140# define GNULIB_defined_max_align_t 1
141# endif
142# endif
143#endif
144
84# endif /* _@GUARD_PREFIX@_STDDEF_H */ 145# endif /* _@GUARD_PREFIX@_STDDEF_H */
85# endif /* _@GUARD_PREFIX@_STDDEF_H */ 146# endif /* _@GUARD_PREFIX@_STDDEF_H */
86#endif /* __need_XXX */ 147#endif /* __need_XXX */
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index 2db8b2e3..5ddc644b 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -1,23 +1,23 @@
1/* Copyright (C) 2001-2002, 2004-2013 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2002, 2004-2023 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. 2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* 18/*
19 * ISO C 99 <stdint.h> for platforms that lack it. 19 * ISO C 99 <stdint.h> for platforms that lack it.
20 * <http://www.opengroup.org/susv3xbd/stdint.h.html> 20 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html>
21 */ 21 */
22 22
23#ifndef _@GUARD_PREFIX@_STDINT_H 23#ifndef _@GUARD_PREFIX@_STDINT_H
@@ -38,8 +38,7 @@
38 other system header files; just include the system's <stdint.h>. 38 other system header files; just include the system's <stdint.h>.
39 Ideally we should test __BIONIC__ here, but it is only defined after 39 Ideally we should test __BIONIC__ here, but it is only defined after
40 <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */ 40 <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
41#if defined __ANDROID__ \ 41#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H
42 && defined _SYS_TYPES_H_ && !defined __need_size_t
43# @INCLUDE_NEXT@ @NEXT_STDINT_H@ 42# @INCLUDE_NEXT@ @NEXT_STDINT_H@
44#else 43#else
45 44
@@ -80,54 +79,65 @@
80#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H 79#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
81#define _@GUARD_PREFIX@_STDINT_H 80#define _@GUARD_PREFIX@_STDINT_H
82 81
82/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
83 LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
84#include <limits.h>
85
86/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
87 wint_t. */
88#if @GNULIBHEADERS_OVERRIDE_WINT_T@
89# undef WINT_MIN
90# undef WINT_MAX
91# define WINT_MIN 0x0U
92# define WINT_MAX 0xffffffffU
93#endif
94
95#if ! @HAVE_C99_STDINT_H@
96
83/* <sys/types.h> defines some of the stdint.h types as well, on glibc, 97/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
84 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). 98 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
85 AIX 5.2 <sys/types.h> isn't needed and causes troubles. 99 AIX 5.2 <sys/types.h> isn't needed and causes troubles.
86 Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but 100 Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
87 relies on the system <stdint.h> definitions, so include 101 relies on the system <stdint.h> definitions, so include
88 <sys/types.h> after @NEXT_STDINT_H@. */ 102 <sys/types.h> after @NEXT_STDINT_H@. */
89#if @HAVE_SYS_TYPES_H@ && ! defined _AIX 103# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
90# include <sys/types.h> 104# include <sys/types.h>
91#endif 105# endif
92
93/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
94 LONG_MIN, LONG_MAX, ULONG_MAX. */
95#include <limits.h>
96 106
97#if @HAVE_INTTYPES_H@ 107# if @HAVE_INTTYPES_H@
98 /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines 108 /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
99 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. 109 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
100 <inttypes.h> also defines intptr_t and uintptr_t. */ 110 <inttypes.h> also defines intptr_t and uintptr_t. */
101# include <inttypes.h> 111# include <inttypes.h>
102#elif @HAVE_SYS_INTTYPES_H@ 112# elif @HAVE_SYS_INTTYPES_H@
103 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and 113 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
104 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ 114 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
105# include <sys/inttypes.h> 115# include <sys/inttypes.h>
106#endif 116# endif
107 117
108#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ 118# if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
109 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines 119 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
110 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is 120 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
111 included by <sys/types.h>. */ 121 included by <sys/types.h>. */
112# include <sys/bitypes.h> 122# include <sys/bitypes.h>
113#endif 123# endif
114 124
115#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 125# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
116 126
117/* Minimum and maximum values for an integer type under the usual assumption. 127/* Minimum and maximum values for an integer type under the usual assumption.
118 Return an unspecified value if BITS == 0, adding a check to pacify 128 Return an unspecified value if BITS == 0, adding a check to pacify
119 picky compilers. */ 129 picky compilers. */
120 130
121#define _STDINT_MIN(signed, bits, zero) \ 131/* These are separate macros, because if you try to merge these macros into
122 ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) 132 a single one, HP-UX cc rejects the resulting expression in constant
133 expressions. */
134# define _STDINT_UNSIGNED_MIN(bits, zero) \
135 (zero)
136# define _STDINT_SIGNED_MIN(bits, zero) \
137 (~ _STDINT_MAX (1, bits, zero))
123 138
124#define _STDINT_MAX(signed, bits, zero) \ 139# define _STDINT_MAX(signed, bits, zero) \
125 ((signed) \ 140 (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
126 ? ~ _STDINT_MIN (signed, bits, zero) \
127 : /* The expression for the unsigned case. The subtraction of (signed) \
128 is a nop in the unsigned case and avoids "signed integer overflow" \
129 warnings in the signed case. */ \
130 ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
131 141
132#if !GNULIB_defined_stdint_types 142#if !GNULIB_defined_stdint_types
133 143
@@ -136,26 +146,26 @@
136/* Here we assume a standard architecture where the hardware integer 146/* Here we assume a standard architecture where the hardware integer
137 types have 8, 16, 32, optionally 64 bits. */ 147 types have 8, 16, 32, optionally 64 bits. */
138 148
139#undef int8_t 149# undef int8_t
140#undef uint8_t 150# undef uint8_t
141typedef signed char gl_int8_t; 151typedef signed char gl_int8_t;
142typedef unsigned char gl_uint8_t; 152typedef unsigned char gl_uint8_t;
143#define int8_t gl_int8_t 153# define int8_t gl_int8_t
144#define uint8_t gl_uint8_t 154# define uint8_t gl_uint8_t
145 155
146#undef int16_t 156# undef int16_t
147#undef uint16_t 157# undef uint16_t
148typedef short int gl_int16_t; 158typedef short int gl_int16_t;
149typedef unsigned short int gl_uint16_t; 159typedef unsigned short int gl_uint16_t;
150#define int16_t gl_int16_t 160# define int16_t gl_int16_t
151#define uint16_t gl_uint16_t 161# define uint16_t gl_uint16_t
152 162
153#undef int32_t 163# undef int32_t
154#undef uint32_t 164# undef uint32_t
155typedef int gl_int32_t; 165typedef int gl_int32_t;
156typedef unsigned int gl_uint32_t; 166typedef unsigned int gl_uint32_t;
157#define int32_t gl_int32_t 167# define int32_t gl_int32_t
158#define uint32_t gl_uint32_t 168# define uint32_t gl_uint32_t
159 169
160/* If the system defines INT64_MAX, assume int64_t works. That way, 170/* If the system defines INT64_MAX, assume int64_t works. That way,
161 if the underlying platform defines int64_t to be a 64-bit long long 171 if the underlying platform defines int64_t to be a 64-bit long long
@@ -163,54 +173,54 @@ typedef unsigned int gl_uint32_t;
163 int, which would mess up C++ name mangling. We must use #ifdef 173 int, which would mess up C++ name mangling. We must use #ifdef
164 rather than #if, to avoid an error with HP-UX 10.20 cc. */ 174 rather than #if, to avoid an error with HP-UX 10.20 cc. */
165 175
166#ifdef INT64_MAX 176# ifdef INT64_MAX
167# define GL_INT64_T 177# define GL_INT64_T
168#else 178# else
169/* Do not undefine int64_t if gnulib is not being used with 64-bit 179/* Do not undefine int64_t if gnulib is not being used with 64-bit
170 types, since otherwise it breaks platforms like Tandem/NSK. */ 180 types, since otherwise it breaks platforms like Tandem/NSK. */
171# if LONG_MAX >> 31 >> 31 == 1 181# if LONG_MAX >> 31 >> 31 == 1
172# undef int64_t 182# undef int64_t
173typedef long int gl_int64_t; 183typedef long int gl_int64_t;
174# define int64_t gl_int64_t 184# define int64_t gl_int64_t
175# define GL_INT64_T 185# define GL_INT64_T
176# elif defined _MSC_VER 186# elif defined _MSC_VER
177# undef int64_t 187# undef int64_t
178typedef __int64 gl_int64_t; 188typedef __int64 gl_int64_t;
179# define int64_t gl_int64_t 189# define int64_t gl_int64_t
180# define GL_INT64_T 190# define GL_INT64_T
181# elif @HAVE_LONG_LONG_INT@ 191# else
182# undef int64_t 192# undef int64_t
183typedef long long int gl_int64_t; 193typedef long long int gl_int64_t;
184# define int64_t gl_int64_t 194# define int64_t gl_int64_t
185# define GL_INT64_T 195# define GL_INT64_T
196# endif
186# endif 197# endif
187#endif
188 198
189#ifdef UINT64_MAX 199# ifdef UINT64_MAX
190# define GL_UINT64_T
191#else
192# if ULONG_MAX >> 31 >> 31 >> 1 == 1
193# undef uint64_t
194typedef unsigned long int gl_uint64_t;
195# define uint64_t gl_uint64_t
196# define GL_UINT64_T 200# define GL_UINT64_T
197# elif defined _MSC_VER 201# else
198# undef uint64_t 202# if ULONG_MAX >> 31 >> 31 >> 1 == 1
203# undef uint64_t
204typedef unsigned long int gl_uint64_t;
205# define uint64_t gl_uint64_t
206# define GL_UINT64_T
207# elif defined _MSC_VER
208# undef uint64_t
199typedef unsigned __int64 gl_uint64_t; 209typedef unsigned __int64 gl_uint64_t;
200# define uint64_t gl_uint64_t 210# define uint64_t gl_uint64_t
201# define GL_UINT64_T 211# define GL_UINT64_T
202# elif @HAVE_UNSIGNED_LONG_LONG_INT@ 212# else
203# undef uint64_t 213# undef uint64_t
204typedef unsigned long long int gl_uint64_t; 214typedef unsigned long long int gl_uint64_t;
205# define uint64_t gl_uint64_t 215# define uint64_t gl_uint64_t
206# define GL_UINT64_T 216# define GL_UINT64_T
217# endif
207# endif 218# endif
208#endif
209 219
210/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ 220/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
211#define _UINT8_T 221# define _UINT8_T
212#define _UINT32_T 222# define _UINT32_T
213#define _UINT64_T 223# define _UINT64_T
214 224
215 225
216/* 7.18.1.2. Minimum-width integer types */ 226/* 7.18.1.2. Minimum-width integer types */
@@ -219,26 +229,26 @@ typedef unsigned long long int gl_uint64_t;
219 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 229 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
220 are the same as the corresponding N_t types. */ 230 are the same as the corresponding N_t types. */
221 231
222#undef int_least8_t 232# undef int_least8_t
223#undef uint_least8_t 233# undef uint_least8_t
224#undef int_least16_t 234# undef int_least16_t
225#undef uint_least16_t 235# undef uint_least16_t
226#undef int_least32_t 236# undef int_least32_t
227#undef uint_least32_t 237# undef uint_least32_t
228#undef int_least64_t 238# undef int_least64_t
229#undef uint_least64_t 239# undef uint_least64_t
230#define int_least8_t int8_t 240# define int_least8_t int8_t
231#define uint_least8_t uint8_t 241# define uint_least8_t uint8_t
232#define int_least16_t int16_t 242# define int_least16_t int16_t
233#define uint_least16_t uint16_t 243# define uint_least16_t uint16_t
234#define int_least32_t int32_t 244# define int_least32_t int32_t
235#define uint_least32_t uint32_t 245# define uint_least32_t uint32_t
236#ifdef GL_INT64_T 246# ifdef GL_INT64_T
237# define int_least64_t int64_t 247# define int_least64_t int64_t
238#endif 248# endif
239#ifdef GL_UINT64_T 249# ifdef GL_UINT64_T
240# define uint_least64_t uint64_t 250# define uint_least64_t uint64_t
241#endif 251# endif
242 252
243/* 7.18.1.3. Fastest minimum-width integer types */ 253/* 7.18.1.3. Fastest minimum-width integer types */
244 254
@@ -251,50 +261,64 @@ typedef unsigned long long int gl_uint64_t;
251 uses types consistent with glibc, as that lessens the chance of 261 uses types consistent with glibc, as that lessens the chance of
252 incompatibility with older GNU hosts. */ 262 incompatibility with older GNU hosts. */
253 263
254#undef int_fast8_t 264# undef int_fast8_t
255#undef uint_fast8_t 265# undef uint_fast8_t
256#undef int_fast16_t 266# undef int_fast16_t
257#undef uint_fast16_t 267# undef uint_fast16_t
258#undef int_fast32_t 268# undef int_fast32_t
259#undef uint_fast32_t 269# undef uint_fast32_t
260#undef int_fast64_t 270# undef int_fast64_t
261#undef uint_fast64_t 271# undef uint_fast64_t
262typedef signed char gl_int_fast8_t; 272typedef signed char gl_int_fast8_t;
263typedef unsigned char gl_uint_fast8_t; 273typedef unsigned char gl_uint_fast8_t;
264 274
265#ifdef __sun 275# ifdef __sun
266/* Define types compatible with SunOS 5.10, so that code compiled under 276/* Define types compatible with SunOS 5.10, so that code compiled under
267 earlier SunOS versions works with code compiled under SunOS 5.10. */ 277 earlier SunOS versions works with code compiled under SunOS 5.10. */
268typedef int gl_int_fast32_t; 278typedef int gl_int_fast32_t;
269typedef unsigned int gl_uint_fast32_t; 279typedef unsigned int gl_uint_fast32_t;
270#else 280# else
271typedef long int gl_int_fast32_t; 281typedef long int gl_int_fast32_t;
272typedef unsigned long int gl_uint_fast32_t; 282typedef unsigned long int gl_uint_fast32_t;
273#endif 283# endif
274typedef gl_int_fast32_t gl_int_fast16_t; 284typedef gl_int_fast32_t gl_int_fast16_t;
275typedef gl_uint_fast32_t gl_uint_fast16_t; 285typedef gl_uint_fast32_t gl_uint_fast16_t;
276 286
277#define int_fast8_t gl_int_fast8_t 287# define int_fast8_t gl_int_fast8_t
278#define uint_fast8_t gl_uint_fast8_t 288# define uint_fast8_t gl_uint_fast8_t
279#define int_fast16_t gl_int_fast16_t 289# define int_fast16_t gl_int_fast16_t
280#define uint_fast16_t gl_uint_fast16_t 290# define uint_fast16_t gl_uint_fast16_t
281#define int_fast32_t gl_int_fast32_t 291# define int_fast32_t gl_int_fast32_t
282#define uint_fast32_t gl_uint_fast32_t 292# define uint_fast32_t gl_uint_fast32_t
283#ifdef GL_INT64_T 293# ifdef GL_INT64_T
284# define int_fast64_t int64_t 294# define int_fast64_t int64_t
285#endif 295# endif
286#ifdef GL_UINT64_T 296# ifdef GL_UINT64_T
287# define uint_fast64_t uint64_t 297# define uint_fast64_t uint64_t
288#endif 298# endif
289 299
290/* 7.18.1.4. Integer types capable of holding object pointers */ 300/* 7.18.1.4. Integer types capable of holding object pointers */
291 301
292#undef intptr_t 302/* kLIBC's <stdint.h> defines _INTPTR_T_DECLARED and needs its own
293#undef uintptr_t 303 definitions of intptr_t and uintptr_t (which use int and unsigned)
304 to avoid clashes with declarations of system functions like sbrk.
305 Similarly, MinGW WSL-5.4.1 <stdint.h> needs its own intptr_t and
306 uintptr_t to avoid conflicting declarations of system functions like
307 _findclose in <io.h>. */
308# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
309 || defined __MINGW32__)
310# undef intptr_t
311# undef uintptr_t
312# ifdef _WIN64
313typedef long long int gl_intptr_t;
314typedef unsigned long long int gl_uintptr_t;
315# else
294typedef long int gl_intptr_t; 316typedef long int gl_intptr_t;
295typedef unsigned long int gl_uintptr_t; 317typedef unsigned long int gl_uintptr_t;
296#define intptr_t gl_intptr_t 318# endif
297#define uintptr_t gl_uintptr_t 319# define intptr_t gl_intptr_t
320# define uintptr_t gl_uintptr_t
321# endif
298 322
299/* 7.18.1.5. Greatest-width integer types */ 323/* 7.18.1.5. Greatest-width integer types */
300 324
@@ -305,33 +329,33 @@ typedef unsigned long int gl_uintptr_t;
305 similarly for UINTMAX_MAX and uintmax_t. This avoids problems with 329 similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
306 assuming one type where another is used by the system. */ 330 assuming one type where another is used by the system. */
307 331
308#ifndef INTMAX_MAX 332# ifndef INTMAX_MAX
309# undef INTMAX_C 333# undef INTMAX_C
310# undef intmax_t 334# undef intmax_t
311# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 335# if LONG_MAX >> 30 == 1
312typedef long long int gl_intmax_t; 336typedef long long int gl_intmax_t;
313# define intmax_t gl_intmax_t 337# define intmax_t gl_intmax_t
314# elif defined GL_INT64_T 338# elif defined GL_INT64_T
315# define intmax_t int64_t 339# define intmax_t int64_t
316# else 340# else
317typedef long int gl_intmax_t; 341typedef long int gl_intmax_t;
318# define intmax_t gl_intmax_t 342# define intmax_t gl_intmax_t
343# endif
319# endif 344# endif
320#endif
321 345
322#ifndef UINTMAX_MAX 346# ifndef UINTMAX_MAX
323# undef UINTMAX_C 347# undef UINTMAX_C
324# undef uintmax_t 348# undef uintmax_t
325# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 349# if ULONG_MAX >> 31 == 1
326typedef unsigned long long int gl_uintmax_t; 350typedef unsigned long long int gl_uintmax_t;
327# define uintmax_t gl_uintmax_t 351# define uintmax_t gl_uintmax_t
328# elif defined GL_UINT64_T 352# elif defined GL_UINT64_T
329# define uintmax_t uint64_t 353# define uintmax_t uint64_t
330# else 354# else
331typedef unsigned long int gl_uintmax_t; 355typedef unsigned long int gl_uintmax_t;
332# define uintmax_t gl_uintmax_t 356# define uintmax_t gl_uintmax_t
357# endif
333# endif 358# endif
334#endif
335 359
336/* Verify that intmax_t and uintmax_t have the same size. Too much code 360/* Verify that intmax_t and uintmax_t have the same size. Too much code
337 breaks if this is not the case. If this check fails, the reason is likely 361 breaks if this is not the case. If this check fails, the reason is likely
@@ -339,8 +363,8 @@ typedef unsigned long int gl_uintmax_t;
339typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) 363typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
340 ? 1 : -1]; 364 ? 1 : -1];
341 365
342#define GNULIB_defined_stdint_types 1 366# define GNULIB_defined_stdint_types 1
343#endif /* !GNULIB_defined_stdint_types */ 367# endif /* !GNULIB_defined_stdint_types */
344 368
345/* 7.18.2. Limits of specified-width integer types */ 369/* 7.18.2. Limits of specified-width integer types */
346 370
@@ -349,37 +373,37 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
349/* Here we assume a standard architecture where the hardware integer 373/* Here we assume a standard architecture where the hardware integer
350 types have 8, 16, 32, optionally 64 bits. */ 374 types have 8, 16, 32, optionally 64 bits. */
351 375
352#undef INT8_MIN 376# undef INT8_MIN
353#undef INT8_MAX 377# undef INT8_MAX
354#undef UINT8_MAX 378# undef UINT8_MAX
355#define INT8_MIN (~ INT8_MAX) 379# define INT8_MIN (~ INT8_MAX)
356#define INT8_MAX 127 380# define INT8_MAX 127
357#define UINT8_MAX 255 381# define UINT8_MAX 255
358 382
359#undef INT16_MIN 383# undef INT16_MIN
360#undef INT16_MAX 384# undef INT16_MAX
361#undef UINT16_MAX 385# undef UINT16_MAX
362#define INT16_MIN (~ INT16_MAX) 386# define INT16_MIN (~ INT16_MAX)
363#define INT16_MAX 32767 387# define INT16_MAX 32767
364#define UINT16_MAX 65535 388# define UINT16_MAX 65535
365 389
366#undef INT32_MIN 390# undef INT32_MIN
367#undef INT32_MAX 391# undef INT32_MAX
368#undef UINT32_MAX 392# undef UINT32_MAX
369#define INT32_MIN (~ INT32_MAX) 393# define INT32_MIN (~ INT32_MAX)
370#define INT32_MAX 2147483647 394# define INT32_MAX 2147483647
371#define UINT32_MAX 4294967295U 395# define UINT32_MAX 4294967295U
372 396
373#if defined GL_INT64_T && ! defined INT64_MAX 397# if defined GL_INT64_T && ! defined INT64_MAX
374/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 398/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
375 evaluates the latter incorrectly in preprocessor expressions. */ 399 evaluates the latter incorrectly in preprocessor expressions. */
376# define INT64_MIN (- INTMAX_C (1) << 63) 400# define INT64_MIN (- INTMAX_C (1) << 63)
377# define INT64_MAX INTMAX_C (9223372036854775807) 401# define INT64_MAX INTMAX_C (9223372036854775807)
378#endif 402# endif
379 403
380#if defined GL_UINT64_T && ! defined UINT64_MAX 404# if defined GL_UINT64_T && ! defined UINT64_MAX
381# define UINT64_MAX UINTMAX_C (18446744073709551615) 405# define UINT64_MAX UINTMAX_C (18446744073709551615)
382#endif 406# endif
383 407
384/* 7.18.2.2. Limits of minimum-width integer types */ 408/* 7.18.2.2. Limits of minimum-width integer types */
385 409
@@ -387,38 +411,38 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
387 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 411 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
388 are the same as the corresponding N_t types. */ 412 are the same as the corresponding N_t types. */
389 413
390#undef INT_LEAST8_MIN 414# undef INT_LEAST8_MIN
391#undef INT_LEAST8_MAX 415# undef INT_LEAST8_MAX
392#undef UINT_LEAST8_MAX 416# undef UINT_LEAST8_MAX
393#define INT_LEAST8_MIN INT8_MIN 417# define INT_LEAST8_MIN INT8_MIN
394#define INT_LEAST8_MAX INT8_MAX 418# define INT_LEAST8_MAX INT8_MAX
395#define UINT_LEAST8_MAX UINT8_MAX 419# define UINT_LEAST8_MAX UINT8_MAX
396 420
397#undef INT_LEAST16_MIN 421# undef INT_LEAST16_MIN
398#undef INT_LEAST16_MAX 422# undef INT_LEAST16_MAX
399#undef UINT_LEAST16_MAX 423# undef UINT_LEAST16_MAX
400#define INT_LEAST16_MIN INT16_MIN 424# define INT_LEAST16_MIN INT16_MIN
401#define INT_LEAST16_MAX INT16_MAX 425# define INT_LEAST16_MAX INT16_MAX
402#define UINT_LEAST16_MAX UINT16_MAX 426# define UINT_LEAST16_MAX UINT16_MAX
403 427
404#undef INT_LEAST32_MIN 428# undef INT_LEAST32_MIN
405#undef INT_LEAST32_MAX 429# undef INT_LEAST32_MAX
406#undef UINT_LEAST32_MAX 430# undef UINT_LEAST32_MAX
407#define INT_LEAST32_MIN INT32_MIN 431# define INT_LEAST32_MIN INT32_MIN
408#define INT_LEAST32_MAX INT32_MAX 432# define INT_LEAST32_MAX INT32_MAX
409#define UINT_LEAST32_MAX UINT32_MAX 433# define UINT_LEAST32_MAX UINT32_MAX
410 434
411#undef INT_LEAST64_MIN 435# undef INT_LEAST64_MIN
412#undef INT_LEAST64_MAX 436# undef INT_LEAST64_MAX
413#ifdef GL_INT64_T 437# ifdef GL_INT64_T
414# define INT_LEAST64_MIN INT64_MIN 438# define INT_LEAST64_MIN INT64_MIN
415# define INT_LEAST64_MAX INT64_MAX 439# define INT_LEAST64_MAX INT64_MAX
416#endif 440# endif
417 441
418#undef UINT_LEAST64_MAX 442# undef UINT_LEAST64_MAX
419#ifdef GL_UINT64_T 443# ifdef GL_UINT64_T
420# define UINT_LEAST64_MAX UINT64_MAX 444# define UINT_LEAST64_MAX UINT64_MAX
421#endif 445# endif
422 446
423/* 7.18.2.3. Limits of fastest minimum-width integer types */ 447/* 7.18.2.3. Limits of fastest minimum-width integer types */
424 448
@@ -426,117 +450,127 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
426 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 450 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
427 are taken from the same list of types. */ 451 are taken from the same list of types. */
428 452
429#undef INT_FAST8_MIN 453# undef INT_FAST8_MIN
430#undef INT_FAST8_MAX 454# undef INT_FAST8_MAX
431#undef UINT_FAST8_MAX 455# undef UINT_FAST8_MAX
432#define INT_FAST8_MIN SCHAR_MIN 456# define INT_FAST8_MIN SCHAR_MIN
433#define INT_FAST8_MAX SCHAR_MAX 457# define INT_FAST8_MAX SCHAR_MAX
434#define UINT_FAST8_MAX UCHAR_MAX 458# define UINT_FAST8_MAX UCHAR_MAX
435 459
436#undef INT_FAST16_MIN 460# undef INT_FAST16_MIN
437#undef INT_FAST16_MAX 461# undef INT_FAST16_MAX
438#undef UINT_FAST16_MAX 462# undef UINT_FAST16_MAX
439#define INT_FAST16_MIN INT_FAST32_MIN 463# define INT_FAST16_MIN INT_FAST32_MIN
440#define INT_FAST16_MAX INT_FAST32_MAX 464# define INT_FAST16_MAX INT_FAST32_MAX
441#define UINT_FAST16_MAX UINT_FAST32_MAX 465# define UINT_FAST16_MAX UINT_FAST32_MAX
442 466
443#undef INT_FAST32_MIN 467# undef INT_FAST32_MIN
444#undef INT_FAST32_MAX 468# undef INT_FAST32_MAX
445#undef UINT_FAST32_MAX 469# undef UINT_FAST32_MAX
446#ifdef __sun 470# ifdef __sun
447# define INT_FAST32_MIN INT_MIN 471# define INT_FAST32_MIN INT_MIN
448# define INT_FAST32_MAX INT_MAX 472# define INT_FAST32_MAX INT_MAX
449# define UINT_FAST32_MAX UINT_MAX 473# define UINT_FAST32_MAX UINT_MAX
450#else 474# else
451# define INT_FAST32_MIN LONG_MIN 475# define INT_FAST32_MIN LONG_MIN
452# define INT_FAST32_MAX LONG_MAX 476# define INT_FAST32_MAX LONG_MAX
453# define UINT_FAST32_MAX ULONG_MAX 477# define UINT_FAST32_MAX ULONG_MAX
454#endif 478# endif
455 479
456#undef INT_FAST64_MIN 480# undef INT_FAST64_MIN
457#undef INT_FAST64_MAX 481# undef INT_FAST64_MAX
458#ifdef GL_INT64_T 482# ifdef GL_INT64_T
459# define INT_FAST64_MIN INT64_MIN 483# define INT_FAST64_MIN INT64_MIN
460# define INT_FAST64_MAX INT64_MAX 484# define INT_FAST64_MAX INT64_MAX
461#endif 485# endif
462 486
463#undef UINT_FAST64_MAX 487# undef UINT_FAST64_MAX
464#ifdef GL_UINT64_T 488# ifdef GL_UINT64_T
465# define UINT_FAST64_MAX UINT64_MAX 489# define UINT_FAST64_MAX UINT64_MAX
466#endif 490# endif
467 491
468/* 7.18.2.4. Limits of integer types capable of holding object pointers */ 492/* 7.18.2.4. Limits of integer types capable of holding object pointers */
469 493
470#undef INTPTR_MIN 494# undef INTPTR_MIN
471#undef INTPTR_MAX 495# undef INTPTR_MAX
472#undef UINTPTR_MAX 496# undef UINTPTR_MAX
473#define INTPTR_MIN LONG_MIN 497# ifdef _WIN64
474#define INTPTR_MAX LONG_MAX 498# define INTPTR_MIN LLONG_MIN
475#define UINTPTR_MAX ULONG_MAX 499# define INTPTR_MAX LLONG_MAX
500# define UINTPTR_MAX ULLONG_MAX
501# else
502# define INTPTR_MIN LONG_MIN
503# define INTPTR_MAX LONG_MAX
504# define UINTPTR_MAX ULONG_MAX
505# endif
476 506
477/* 7.18.2.5. Limits of greatest-width integer types */ 507/* 7.18.2.5. Limits of greatest-width integer types */
478 508
479#ifndef INTMAX_MAX 509# ifndef INTMAX_MAX
480# undef INTMAX_MIN 510# undef INTMAX_MIN
481# ifdef INT64_MAX 511# ifdef INT64_MAX
482# define INTMAX_MIN INT64_MIN 512# define INTMAX_MIN INT64_MIN
483# define INTMAX_MAX INT64_MAX 513# define INTMAX_MAX INT64_MAX
484# else 514# else
485# define INTMAX_MIN INT32_MIN 515# define INTMAX_MIN INT32_MIN
486# define INTMAX_MAX INT32_MAX 516# define INTMAX_MAX INT32_MAX
517# endif
487# endif 518# endif
488#endif
489 519
490#ifndef UINTMAX_MAX 520# ifndef UINTMAX_MAX
491# ifdef UINT64_MAX 521# ifdef UINT64_MAX
492# define UINTMAX_MAX UINT64_MAX 522# define UINTMAX_MAX UINT64_MAX
493# else 523# else
494# define UINTMAX_MAX UINT32_MAX 524# define UINTMAX_MAX UINT32_MAX
525# endif
495# endif 526# endif
496#endif
497 527
498/* 7.18.3. Limits of other integer types */ 528/* 7.18.3. Limits of other integer types */
499 529
500/* ptrdiff_t limits */ 530/* ptrdiff_t limits */
501#undef PTRDIFF_MIN 531# undef PTRDIFF_MIN
502#undef PTRDIFF_MAX 532# undef PTRDIFF_MAX
503#if @APPLE_UNIVERSAL_BUILD@ 533# if @APPLE_UNIVERSAL_BUILD@
504# ifdef _LP64 534# ifdef _LP64
505# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l) 535# define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l)
506# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) 536# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
537# else
538# define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0)
539# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
540# endif
507# else 541# else
508# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0) 542# define PTRDIFF_MIN \
509# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) 543 _STDINT_SIGNED_MIN (@BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
510# endif 544# define PTRDIFF_MAX \
511#else
512# define PTRDIFF_MIN \
513 _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
514# define PTRDIFF_MAX \
515 _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) 545 _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
516#endif 546# endif
517 547
518/* sig_atomic_t limits */ 548/* sig_atomic_t limits */
519#undef SIG_ATOMIC_MIN 549# undef SIG_ATOMIC_MIN
520#undef SIG_ATOMIC_MAX 550# undef SIG_ATOMIC_MAX
521#define SIG_ATOMIC_MIN \ 551# if @HAVE_SIGNED_SIG_ATOMIC_T@
522 _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ 552# define SIG_ATOMIC_MIN \
523 0@SIG_ATOMIC_T_SUFFIX@) 553 _STDINT_SIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
524#define SIG_ATOMIC_MAX \ 554# else
555# define SIG_ATOMIC_MIN \
556 _STDINT_UNSIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
557# endif
558# define SIG_ATOMIC_MAX \
525 _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ 559 _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
526 0@SIG_ATOMIC_T_SUFFIX@) 560 0@SIG_ATOMIC_T_SUFFIX@)
527 561
528 562
529/* size_t limit */ 563/* size_t limit */
530#undef SIZE_MAX 564# undef SIZE_MAX
531#if @APPLE_UNIVERSAL_BUILD@ 565# if @APPLE_UNIVERSAL_BUILD@
532# ifdef _LP64 566# ifdef _LP64
533# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) 567# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
568# else
569# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
570# endif
534# else 571# else
535# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) 572# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
536# endif 573# endif
537#else
538# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
539#endif
540 574
541/* wchar_t limits */ 575/* wchar_t limits */
542/* Get WCHAR_MIN, WCHAR_MAX. 576/* Get WCHAR_MIN, WCHAR_MAX.
@@ -544,30 +578,39 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
544 sequence of nested includes 578 sequence of nested includes
545 <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes 579 <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
546 <stdint.h> and assumes its types are already defined. */ 580 <stdint.h> and assumes its types are already defined. */
547#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) 581# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
548 /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 582# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
549 included before <wchar.h>. */ 583# include <wchar.h>
550# include <stddef.h> 584# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
551# include <stdio.h> 585# endif
552# include <time.h> 586# undef WCHAR_MIN
553# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 587# undef WCHAR_MAX
554# include <wchar.h> 588# if @HAVE_SIGNED_WCHAR_T@
555# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 589# define WCHAR_MIN \
556#endif 590 _STDINT_SIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
557#undef WCHAR_MIN 591# else
558#undef WCHAR_MAX 592# define WCHAR_MIN \
559#define WCHAR_MIN \ 593 _STDINT_UNSIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
560 _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) 594# endif
561#define WCHAR_MAX \ 595# define WCHAR_MAX \
562 _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) 596 _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
563 597
564/* wint_t limits */ 598/* wint_t limits */
565#undef WINT_MIN 599/* If gnulib's <wchar.h> or <wctype.h> overrides wint_t, @WINT_T_SUFFIX@ is not
566#undef WINT_MAX 600 accurate, therefore use the definitions from above. */
567#define WINT_MIN \ 601# if !@GNULIBHEADERS_OVERRIDE_WINT_T@
568 _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 602# undef WINT_MIN
569#define WINT_MAX \ 603# undef WINT_MAX
570 _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 604# if @HAVE_SIGNED_WINT_T@
605# define WINT_MIN \
606 _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
607# else
608# define WINT_MIN \
609 _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
610# endif
611# define WINT_MAX \
612 _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
613# endif
571 614
572/* 7.18.4. Macros for integer constants */ 615/* 7.18.4. Macros for integer constants */
573 616
@@ -577,59 +620,120 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
577/* Here we assume a standard architecture where the hardware integer 620/* Here we assume a standard architecture where the hardware integer
578 types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ 621 types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
579 622
580#undef INT8_C 623# undef INT8_C
581#undef UINT8_C 624# undef UINT8_C
582#define INT8_C(x) x 625# define INT8_C(x) x
583#define UINT8_C(x) x 626# define UINT8_C(x) x
584
585#undef INT16_C
586#undef UINT16_C
587#define INT16_C(x) x
588#define UINT16_C(x) x
589
590#undef INT32_C
591#undef UINT32_C
592#define INT32_C(x) x
593#define UINT32_C(x) x ## U
594
595#undef INT64_C
596#undef UINT64_C
597#if LONG_MAX >> 31 >> 31 == 1
598# define INT64_C(x) x##L
599#elif defined _MSC_VER
600# define INT64_C(x) x##i64
601#elif @HAVE_LONG_LONG_INT@
602# define INT64_C(x) x##LL
603#endif
604#if ULONG_MAX >> 31 >> 31 >> 1 == 1
605# define UINT64_C(x) x##UL
606#elif defined _MSC_VER
607# define UINT64_C(x) x##ui64
608#elif @HAVE_UNSIGNED_LONG_LONG_INT@
609# define UINT64_C(x) x##ULL
610#endif
611 627
612/* 7.18.4.2. Macros for greatest-width integer constants */ 628# undef INT16_C
629# undef UINT16_C
630# define INT16_C(x) x
631# define UINT16_C(x) x
632
633# undef INT32_C
634# undef UINT32_C
635# define INT32_C(x) x
636# define UINT32_C(x) x ## U
613 637
614#ifndef INTMAX_C 638# undef INT64_C
615# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 639# undef UINT64_C
616# define INTMAX_C(x) x##LL 640# if LONG_MAX >> 31 >> 31 == 1
617# elif defined GL_INT64_T 641# define INT64_C(x) x##L
618# define INTMAX_C(x) INT64_C(x) 642# elif defined _MSC_VER
643# define INT64_C(x) x##i64
619# else 644# else
620# define INTMAX_C(x) x##L 645# define INT64_C(x) x##LL
621# endif 646# endif
622#endif 647# if ULONG_MAX >> 31 >> 31 >> 1 == 1
623 648# define UINT64_C(x) x##UL
624#ifndef UINTMAX_C 649# elif defined _MSC_VER
625# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 650# define UINT64_C(x) x##ui64
626# define UINTMAX_C(x) x##ULL
627# elif defined GL_UINT64_T
628# define UINTMAX_C(x) UINT64_C(x)
629# else 651# else
630# define UINTMAX_C(x) x##UL 652# define UINT64_C(x) x##ULL
631# endif 653# endif
632#endif 654
655/* 7.18.4.2. Macros for greatest-width integer constants */
656
657# ifndef INTMAX_C
658# if LONG_MAX >> 30 == 1
659# define INTMAX_C(x) x##LL
660# elif defined GL_INT64_T
661# define INTMAX_C(x) INT64_C(x)
662# else
663# define INTMAX_C(x) x##L
664# endif
665# endif
666
667# ifndef UINTMAX_C
668# if ULONG_MAX >> 31 == 1
669# define UINTMAX_C(x) x##ULL
670# elif defined GL_UINT64_T
671# define UINTMAX_C(x) UINT64_C(x)
672# else
673# define UINTMAX_C(x) x##UL
674# endif
675# endif
676
677#endif /* !@HAVE_C99_STDINT_H@ */
678
679/* Macros specified by ISO/IEC TS 18661-1:2014. */
680
681#if (!defined UINTMAX_WIDTH \
682 && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
683# ifdef INT8_MAX
684# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
685# endif
686# ifdef UINT8_MAX
687# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
688# endif
689# ifdef INT16_MAX
690# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
691# endif
692# ifdef UINT16_MAX
693# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
694# endif
695# ifdef INT32_MAX
696# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
697# endif
698# ifdef UINT32_MAX
699# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
700# endif
701# ifdef INT64_MAX
702# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
703# endif
704# ifdef UINT64_MAX
705# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
706# endif
707# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
708# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
709# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
710# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
711# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
712# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
713# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
714# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
715# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
716# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
717# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
718# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
719# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
720# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
721# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
722# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
723# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
724# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
725# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
726# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
727# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
728# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
729# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
730# ifdef WINT_MAX
731# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
732# endif
733# ifdef SIG_ATOMIC_MAX
734# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
735# endif
736#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
633 737
634#endif /* _@GUARD_PREFIX@_STDINT_H */ 738#endif /* _@GUARD_PREFIX@_STDINT_H */
635#endif /* !(defined __ANDROID__ && ...) */ 739#endif /* !(defined __ANDROID__ && ...) */
diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h
new file mode 100644
index 00000000..46608bed
--- /dev/null
+++ b/gl/stdio-impl.h
@@ -0,0 +1,218 @@
1/* Implementation details of FILE streams.
2 Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Many stdio implementations have the same logic and therefore can share
18 the same implementation of stdio extension API, except that some fields
19 have different naming conventions, or their access requires some casts. */
20
21/* Glibc 2.28 made _IO_UNBUFFERED and _IO_IN_BACKUP private. For now, work
22 around this problem by defining them ourselves. FIXME: Do not rely on glibc
23 internals. */
24#if defined _IO_EOF_SEEN
25# if !defined _IO_UNBUFFERED
26# define _IO_UNBUFFERED 0x2
27# endif
28# if !defined _IO_IN_BACKUP
29# define _IO_IN_BACKUP 0x100
30# endif
31#endif
32
33/* BSD stdio derived implementations. */
34
35#if defined __NetBSD__ /* NetBSD */
36/* Get __NetBSD_Version__. */
37# include <sys/param.h>
38#endif
39
40#include <errno.h> /* For detecting Plan9. */
41
42#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
43 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
44
45# if defined __DragonFly__ /* DragonFly */
46 /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>. */
47# define fp_ ((struct { struct __FILE_public pub; \
48 struct { unsigned char *_base; int _size; } _bf; \
49 void *cookie; \
50 void *_close; \
51 void *_read; \
52 void *_seek; \
53 void *_write; \
54 struct { unsigned char *_base; int _size; } _ub; \
55 int _ur; \
56 unsigned char _ubuf[3]; \
57 unsigned char _nbuf[1]; \
58 struct { unsigned char *_base; int _size; } _lb; \
59 int _blksize; \
60 fpos_t _offset; \
61 /* More fields, not relevant here. */ \
62 } *) fp)
63 /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>. */
64# define _p pub._p
65# define _flags pub._flags
66# define _r pub._r
67# define _w pub._w
68# elif defined __ANDROID__ /* Android */
69# ifdef __LP64__
70# define _gl_flags_file_t int
71# else
72# define _gl_flags_file_t short
73# endif
74# ifdef __LP64__
75# define _gl_file_offset_t int64_t
76# else
77 /* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */
78# define _gl_file_offset_t __kernel_off_t
79# endif
80 /* Up to this commit from 2015-10-12
81 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
82 the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
83 see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
84 and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
85 After this commit, the innards of FILE are hidden. */
86# define fp_ ((struct { unsigned char *_p; \
87 int _r; \
88 int _w; \
89 _gl_flags_file_t _flags; \
90 _gl_flags_file_t _file; \
91 struct { unsigned char *_base; size_t _size; } _bf; \
92 int _lbfsize; \
93 void *_cookie; \
94 void *_close; \
95 void *_read; \
96 void *_seek; \
97 void *_write; \
98 struct { unsigned char *_base; size_t _size; } _ext; \
99 unsigned char *_up; \
100 int _ur; \
101 unsigned char _ubuf[3]; \
102 unsigned char _nbuf[1]; \
103 struct { unsigned char *_base; size_t _size; } _lb; \
104 int _blksize; \
105 _gl_file_offset_t _offset; \
106 /* More fields, not relevant here. */ \
107 } *) fp)
108# else
109# define fp_ fp
110# endif
111
112# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
113 /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
114 and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
115 and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
116 struct __sfileext
117 {
118 struct __sbuf _ub; /* ungetc buffer */
119 /* More fields, not relevant here. */
120 };
121# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
122# elif defined __ANDROID__ /* Android */
123 struct __sfileext
124 {
125 struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
126 /* More fields, not relevant here. */
127 };
128# define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub
129# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
130# define fp_ub fp_->_ub
131# endif
132
133# define HASUB(fp) (fp_ub._base != NULL)
134
135# if defined __ANDROID__ /* Android */
136 /* Needed after this commit from 2016-01-25
137 <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */
138# ifndef __SEOF
139# define __SLBF 1
140# define __SNBF 2
141# define __SRD 4
142# define __SWR 8
143# define __SRW 0x10
144# define __SEOF 0x20
145# define __SERR 0x40
146# endif
147# ifndef __SOFF
148# define __SOFF 0x1000
149# endif
150# endif
151
152#endif
153
154
155/* SystemV derived implementations. */
156
157#ifdef __TANDEM /* NonStop Kernel */
158# ifndef _IOERR
159/* These values were determined by the program 'stdioext-flags' at
160 <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
161# define _IOERR 0x40
162# define _IOREAD 0x80
163# define _IOWRT 0x4
164# define _IORW 0x100
165# endif
166#endif
167
168#if defined _IOERR
169
170# if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
171# define fp_ ((struct { unsigned char *_ptr; \
172 unsigned char *_base; \
173 unsigned char *_end; \
174 long _cnt; \
175 int _file; \
176 unsigned int _flag; \
177 } *) fp)
178# elif defined __VMS /* OpenVMS */
179# define fp_ ((struct _iobuf *) fp)
180# else
181# define fp_ fp
182# endif
183
184# if defined _SCO_DS || (defined __SCO_VERSION__ || defined __sysv5__) /* OpenServer 5, OpenServer 6, UnixWare 7 */
185# define _cnt __cnt
186# define _ptr __ptr
187# define _base __base
188# define _flag __flag
189# endif
190
191#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */
192
193/* <stdio.h> does not define the innards of FILE any more. */
194# define WINDOWS_OPAQUE_FILE
195
196struct _gl_real_FILE
197{
198 /* Note: Compared to older Windows and to mingw, it has the fields
199 _base and _cnt swapped. */
200 unsigned char *_ptr;
201 unsigned char *_base;
202 int _cnt;
203 int _flag;
204 int _file;
205 int _charbuf;
206 int _bufsiz;
207};
208# define fp_ ((struct _gl_real_FILE *) fp)
209
210/* These values were determined by a program similar to the one at
211 <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
212# define _IOREAD 0x1
213# define _IOWRT 0x2
214# define _IORW 0x4
215# define _IOEOF 0x8
216# define _IOERR 0x10
217
218#endif
diff --git a/gl/stdio-read.c b/gl/stdio-read.c
new file mode 100644
index 00000000..6e2984c5
--- /dev/null
+++ b/gl/stdio-read.c
@@ -0,0 +1,168 @@
1/* POSIX compatible FILE stream read function.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <stdio.h>
22
23/* Replace these functions only if module 'nonblocking' is requested. */
24#if GNULIB_NONBLOCKING
25
26/* On native Windows platforms, when read() is called on a non-blocking pipe
27 with an empty buffer, ReadFile() fails with error GetLastError() =
28 ERROR_NO_DATA, and read() in consequence fails with error EINVAL. This
29 read() function is at the basis of the function which fills the buffer of
30 a FILE stream. */
31
32# if defined _WIN32 && ! defined __CYGWIN__
33
34# include <errno.h>
35# include <io.h>
36
37# define WIN32_LEAN_AND_MEAN /* avoid including junk */
38# include <windows.h>
39
40# if GNULIB_MSVC_NOTHROW
41# include "msvc-nothrow.h"
42# else
43# include <io.h>
44# endif
45
46/* Don't assume that UNICODE is not defined. */
47# undef GetNamedPipeHandleState
48# define GetNamedPipeHandleState GetNamedPipeHandleStateA
49
50# define CALL_WITH_ERRNO_FIX(RETTYPE, EXPRESSION, FAILED) \
51 if (ferror (stream)) \
52 return (EXPRESSION); \
53 else \
54 { \
55 RETTYPE ret; \
56 SetLastError (0); \
57 ret = (EXPRESSION); \
58 if (FAILED) \
59 { \
60 if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \
61 { \
62 int fd = fileno (stream); \
63 if (fd >= 0) \
64 { \
65 HANDLE h = (HANDLE) _get_osfhandle (fd); \
66 if (GetFileType (h) == FILE_TYPE_PIPE) \
67 { \
68 /* h is a pipe or socket. */ \
69 DWORD state; \
70 if (GetNamedPipeHandleState (h, &state, NULL, NULL, \
71 NULL, NULL, 0) \
72 && (state & PIPE_NOWAIT) != 0) \
73 /* h is a pipe in non-blocking mode. \
74 Change errno from EINVAL to EAGAIN. */ \
75 errno = EAGAIN; \
76 } \
77 } \
78 } \
79 } \
80 return ret; \
81 }
82
83/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
84 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
85# if GNULIB_SCANF
86int
87scanf (const char *format, ...)
88{
89 int retval;
90 va_list args;
91
92 va_start (args, format);
93 retval = vfscanf (stdin, format, args);
94 va_end (args);
95
96 return retval;
97}
98# endif
99
100/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
101 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
102# if GNULIB_FSCANF
103int
104fscanf (FILE *stream, const char *format, ...)
105{
106 int retval;
107 va_list args;
108
109 va_start (args, format);
110 retval = vfscanf (stream, format, args);
111 va_end (args);
112
113 return retval;
114}
115# endif
116
117/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
118 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
119# if GNULIB_VSCANF
120int
121vscanf (const char *format, va_list args)
122{
123 return vfscanf (stdin, format, args);
124}
125# endif
126
127/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
128 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
129# if GNULIB_VFSCANF
130int
131vfscanf (FILE *stream, const char *format, va_list args)
132#undef vfscanf
133{
134 CALL_WITH_ERRNO_FIX (int, vfscanf (stream, format, args), ret == EOF)
135}
136# endif
137
138int
139getchar (void)
140{
141 return fgetc (stdin);
142}
143
144int
145fgetc (FILE *stream)
146#undef fgetc
147{
148 CALL_WITH_ERRNO_FIX (int, fgetc (stream), ret == EOF)
149}
150
151char *
152fgets (char *s, int n, FILE *stream)
153#undef fgets
154{
155 CALL_WITH_ERRNO_FIX (char *, fgets (s, n, stream), ret == NULL)
156}
157
158/* We intentionally don't bother to fix gets. */
159
160size_t
161fread (void *ptr, size_t s, size_t n, FILE *stream)
162#undef fread
163{
164 CALL_WITH_ERRNO_FIX (size_t, fread (ptr, s, n, stream), ret < n)
165}
166
167# endif
168#endif
diff --git a/gl/stdio-write.c b/gl/stdio-write.c
new file mode 100644
index 00000000..9cf36cca
--- /dev/null
+++ b/gl/stdio-write.c
@@ -0,0 +1,206 @@
1/* POSIX compatible FILE stream write function.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <stdio.h>
22
23/* Replace these functions only if module 'nonblocking' or module 'sigpipe' is
24 requested. */
25#if GNULIB_NONBLOCKING || GNULIB_SIGPIPE
26
27/* On native Windows platforms, SIGPIPE does not exist. When write() is
28 called on a pipe with no readers, WriteFile() fails with error
29 GetLastError() = ERROR_NO_DATA, and write() in consequence fails with
30 error EINVAL. This write() function is at the basis of the function
31 which flushes the buffer of a FILE stream. */
32
33# if defined _WIN32 && ! defined __CYGWIN__
34
35# include <errno.h>
36# include <signal.h>
37# include <io.h>
38
39# define WIN32_LEAN_AND_MEAN /* avoid including junk */
40# include <windows.h>
41
42# if GNULIB_MSVC_NOTHROW
43# include "msvc-nothrow.h"
44# else
45# include <io.h>
46# endif
47
48/* Don't assume that UNICODE is not defined. */
49# undef GetNamedPipeHandleState
50# define GetNamedPipeHandleState GetNamedPipeHandleStateA
51
52# if GNULIB_NONBLOCKING
53# define CLEAR_ERRNO \
54 errno = 0;
55# define HANDLE_ENOSPC \
56 if (errno == ENOSPC && ferror (stream)) \
57 { \
58 int fd = fileno (stream); \
59 if (fd >= 0) \
60 { \
61 HANDLE h = (HANDLE) _get_osfhandle (fd); \
62 if (GetFileType (h) == FILE_TYPE_PIPE) \
63 { \
64 /* h is a pipe or socket. */ \
65 DWORD state; \
66 if (GetNamedPipeHandleState (h, &state, NULL, NULL, \
67 NULL, NULL, 0) \
68 && (state & PIPE_NOWAIT) != 0) \
69 /* h is a pipe in non-blocking mode. \
70 Change errno from ENOSPC to EAGAIN. */ \
71 errno = EAGAIN; \
72 } \
73 } \
74 } \
75 else
76# else
77# define CLEAR_ERRNO
78# define HANDLE_ENOSPC
79# endif
80
81# if GNULIB_SIGPIPE
82# define CLEAR_LastError \
83 SetLastError (0);
84# define HANDLE_ERROR_NO_DATA \
85 if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \
86 { \
87 int fd = fileno (stream); \
88 if (fd >= 0 \
89 && GetFileType ((HANDLE) _get_osfhandle (fd)) \
90 == FILE_TYPE_PIPE) \
91 { \
92 /* Try to raise signal SIGPIPE. */ \
93 raise (SIGPIPE); \
94 /* If it is currently blocked or ignored, change errno from \
95 EINVAL to EPIPE. */ \
96 errno = EPIPE; \
97 } \
98 } \
99 else
100# else
101# define CLEAR_LastError
102# define HANDLE_ERROR_NO_DATA
103# endif
104
105# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
106 if (ferror (stream)) \
107 return (EXPRESSION); \
108 else \
109 { \
110 RETTYPE ret; \
111 CLEAR_ERRNO \
112 CLEAR_LastError \
113 ret = (EXPRESSION); \
114 if (FAILED) \
115 { \
116 HANDLE_ENOSPC \
117 HANDLE_ERROR_NO_DATA \
118 ; \
119 } \
120 return ret; \
121 }
122
123# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
124int
125printf (const char *format, ...)
126{
127 int retval;
128 va_list args;
129
130 va_start (args, format);
131 retval = vfprintf (stdout, format, args);
132 va_end (args);
133
134 return retval;
135}
136# endif
137
138# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
139int
140fprintf (FILE *stream, const char *format, ...)
141{
142 int retval;
143 va_list args;
144
145 va_start (args, format);
146 retval = vfprintf (stream, format, args);
147 va_end (args);
148
149 return retval;
150}
151# endif
152
153# if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */
154int
155vprintf (const char *format, va_list args)
156{
157 return vfprintf (stdout, format, args);
158}
159# endif
160
161# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */
162int
163vfprintf (FILE *stream, const char *format, va_list args)
164#undef vfprintf
165{
166 CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF)
167}
168# endif
169
170int
171putchar (int c)
172{
173 return fputc (c, stdout);
174}
175
176int
177fputc (int c, FILE *stream)
178#undef fputc
179{
180 CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF)
181}
182
183int
184fputs (const char *string, FILE *stream)
185#undef fputs
186{
187 CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF)
188}
189
190int
191puts (const char *string)
192#undef puts
193{
194 FILE *stream = stdout;
195 CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF)
196}
197
198size_t
199fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
200#undef fwrite
201{
202 CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n)
203}
204
205# endif
206#endif
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 06cbad00..59cbea3d 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <stdio.h>. 1/* A GNU-like <stdio.h>.
2 2
3 Copyright (C) 2004, 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
@@ -56,36 +56,103 @@
56 May also define off_t to a 64-bit type on native Windows. */ 56 May also define off_t to a 64-bit type on native Windows. */
57#include <sys/types.h> 57#include <sys/types.h>
58 58
59/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
60/* But in any case avoid namespace pollution on glibc systems. */
61#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
62 && ! defined __GLIBC__
63# include <unistd.h>
64#endif
65
66/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
67/* But in any case avoid namespace pollution on glibc systems. */
68#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
69 && ! defined __GLIBC__
70# include <sys/stat.h>
71#endif
72
73/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
74 it before we #define perror rpl_perror. */
75/* But in any case avoid namespace pollution on glibc systems. */
76#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
77 && (defined _WIN32 && ! defined __CYGWIN__) \
78 && ! defined __GLIBC__
79# include <stdlib.h>
80#endif
81
82/* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
83 it before we #define remove rpl_remove. */
84/* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
85 it before we #define rename rpl_rename. */
86/* But in any case avoid namespace pollution on glibc systems. */
87#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
88 && (defined _WIN32 && ! defined __CYGWIN__) \
89 && ! defined __GLIBC__
90# include <io.h>
91#endif
92
93
94/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
95 that can be freed by passing them as the Ith argument to the
96 function F. */
97#ifndef _GL_ATTRIBUTE_DEALLOC
98# if __GNUC__ >= 11
99# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
100# else
101# define _GL_ATTRIBUTE_DEALLOC(f, i)
102# endif
103#endif
104
59/* The __attribute__ feature is available in gcc versions 2.5 and later. 105/* The __attribute__ feature is available in gcc versions 2.5 and later.
60 The __-protected variants of the attributes 'format' and 'printf' are 106 The __-protected variants of the attributes 'format' and 'printf' are
61 accepted by gcc versions 2.6.4 (effectively 2.7) and later. 107 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
62 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because 108 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
63 gnulib and libintl do '#define printf __printf__' when they override 109 gnulib and libintl do '#define printf __printf__' when they override
64 the 'printf' function. */ 110 the 'printf' function. */
65#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 111#ifndef _GL_ATTRIBUTE_FORMAT
66# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) 112# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
113# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
114# else
115# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
116# endif
117#endif
118
119/* An __attribute__ __format__ specifier for a function that takes a format
120 string and arguments, where the format string directives are the ones
121 standardized by ISO C99 and POSIX.
122 _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
123/* __gnu_printf__ is supported in GCC >= 4.4. */
124#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
125# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
67#else 126#else
68# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ 127# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
69#endif 128#endif
70 129
71/* _GL_ATTRIBUTE_FORMAT_PRINTF 130/* An __attribute__ __format__ specifier for a function that takes a format
131 string and arguments, where the format string directives are the ones of the
132 system printf(), rather than the ones standardized by ISO C99 and POSIX.
133 _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM */
134/* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to
135 the standards. The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates
136 whether this change is effective. On older mingw, it is not. */
137#if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
138# define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
139#else
140# define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__
141#endif
142
143/* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
72 indicates to GCC that the function takes a format string and arguments, 144 indicates to GCC that the function takes a format string and arguments,
73 where the format string directives are the ones standardized by ISO C99 145 where the format string directives are the ones standardized by ISO C99
74 and POSIX. */ 146 and POSIX. */
75#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 147#define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
76# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 148 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument))
77 _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
78#else
79# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
80 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
81#endif
82 149
83/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF, 150/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD,
84 except that it indicates to GCC that the supported format string directives 151 except that it indicates to GCC that the supported format string directives
85 are the ones of the system printf(), rather than the ones standardized by 152 are the ones of the system printf(), rather than the ones standardized by
86 ISO C99 and POSIX. */ 153 ISO C99 and POSIX. */
87#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ 154#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
88 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) 155 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument))
89 156
90/* _GL_ATTRIBUTE_FORMAT_SCANF 157/* _GL_ATTRIBUTE_FORMAT_SCANF
91 indicates to GCC that the function takes a format string and arguments, 158 indicates to GCC that the function takes a format string and arguments,
@@ -106,14 +173,6 @@
106#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \ 173#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
107 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) 174 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
108 175
109/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */
110/* But in any case avoid namespace pollution on glibc systems. */
111#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
112 && ! defined __GLIBC__
113# include <unistd.h>
114#endif
115
116
117/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 176/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
118 177
119/* The definition of _GL_ARG_NONNULL is copied here. */ 178/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -124,23 +183,32 @@
124#define _GL_STDIO_STRINGIZE(token) #token 183#define _GL_STDIO_STRINGIZE(token) #token
125#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) 184#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
126 185
186/* When also using extern inline, suppress the use of static inline in
187 standard headers of problematic Apple configurations, as Libc at
188 least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
189 <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
190 Perhaps Apple will fix this some day. */
191#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
192 && defined __GNUC__ && defined __STDC__)
193# undef putc_unlocked
194#endif
127 195
128#if @GNULIB_DPRINTF@ 196#if @GNULIB_DPRINTF@
129# if @REPLACE_DPRINTF@ 197# if @REPLACE_DPRINTF@
130# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 198# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
131# define dprintf rpl_dprintf 199# define dprintf rpl_dprintf
132# endif 200# endif
133_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) 201_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...)
134 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 202 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
135 _GL_ARG_NONNULL ((2))); 203 _GL_ARG_NONNULL ((2)));
136_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); 204_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
137# else 205# else
138# if !@HAVE_DPRINTF@ 206# if !@HAVE_DPRINTF@
139_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) 207_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
140 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 208 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
141 _GL_ARG_NONNULL ((2))); 209 _GL_ARG_NONNULL ((2)));
142# endif 210# endif
143_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); 211_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
144# endif 212# endif
145_GL_CXXALIASWARN (dprintf); 213_GL_CXXALIASWARN (dprintf);
146#elif defined GNULIB_POSIXCHECK 214#elif defined GNULIB_POSIXCHECK
@@ -162,7 +230,9 @@ _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
162# else 230# else
163_GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); 231_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
164# endif 232# endif
233# if __GLIBC__ >= 2
165_GL_CXXALIASWARN (fclose); 234_GL_CXXALIASWARN (fclose);
235# endif
166#elif defined GNULIB_POSIXCHECK 236#elif defined GNULIB_POSIXCHECK
167# undef fclose 237# undef fclose
168/* Assume fclose is always declared. */ 238/* Assume fclose is always declared. */
@@ -170,24 +240,84 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
170 "use gnulib module fclose for portable POSIX compliance"); 240 "use gnulib module fclose for portable POSIX compliance");
171#endif 241#endif
172 242
243#if @GNULIB_MDA_FCLOSEALL@
244/* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is
245 not required. In C++ with GNULIB_NAMESPACE, avoid differences between
246 platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have
247 it. */
248# if defined _WIN32 && !defined __CYGWIN__
249# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
250# undef fcloseall
251# define fcloseall _fcloseall
252# endif
253_GL_CXXALIAS_MDA (fcloseall, int, (void));
254# else
255# if @HAVE_DECL_FCLOSEALL@
256# if defined __FreeBSD__ || defined __DragonFly__
257_GL_CXXALIAS_SYS (fcloseall, void, (void));
258# else
259_GL_CXXALIAS_SYS (fcloseall, int, (void));
260# endif
261# endif
262# endif
263# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCLOSEALL@
264_GL_CXXALIASWARN (fcloseall);
265# endif
266#endif
267
173#if @GNULIB_FDOPEN@ 268#if @GNULIB_FDOPEN@
174# if @REPLACE_FDOPEN@ 269# if @REPLACE_FDOPEN@
175# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 270# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176# undef fdopen 271# undef fdopen
177# define fdopen rpl_fdopen 272# define fdopen rpl_fdopen
178# endif 273# endif
179_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) 274_GL_FUNCDECL_RPL (fdopen, FILE *,
180 _GL_ARG_NONNULL ((2))); 275 (int fd, const char *mode)
276 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
181_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); 277_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
278# elif defined _WIN32 && !defined __CYGWIN__
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# undef fdopen
281# define fdopen _fdopen
282# endif
283_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
182# else 284# else
285# if __GNUC__ >= 11
286/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
287_GL_FUNCDECL_SYS (fdopen, FILE *,
288 (int fd, const char *mode)
289 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
290# endif
183_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); 291_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
184# endif 292# endif
185_GL_CXXALIASWARN (fdopen); 293_GL_CXXALIASWARN (fdopen);
186#elif defined GNULIB_POSIXCHECK 294#else
187# undef fdopen 295# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
296/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
297_GL_FUNCDECL_SYS (fdopen, FILE *,
298 (int fd, const char *mode)
299 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
300# endif
301# if defined GNULIB_POSIXCHECK
302# undef fdopen
188/* Assume fdopen is always declared. */ 303/* Assume fdopen is always declared. */
189_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " 304_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
190 "use gnulib module fdopen for portability"); 305 "use gnulib module fdopen for portability");
306# elif @GNULIB_MDA_FDOPEN@
307/* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
308 required. In C++ with GNULIB_NAMESPACE, avoid differences between
309 platforms by defining GNULIB_NAMESPACE::fdopen always. */
310# if defined _WIN32 && !defined __CYGWIN__
311# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312# undef fdopen
313# define fdopen _fdopen
314# endif
315_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
316# else
317_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
318# endif
319_GL_CXXALIASWARN (fdopen);
320# endif
191#endif 321#endif
192 322
193#if @GNULIB_FFLUSH@ 323#if @GNULIB_FFLUSH@
@@ -206,7 +336,9 @@ _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
206# else 336# else
207_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); 337_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
208# endif 338# endif
339# if __GLIBC__ >= 2
209_GL_CXXALIASWARN (fflush); 340_GL_CXXALIASWARN (fflush);
341# endif
210#elif defined GNULIB_POSIXCHECK 342#elif defined GNULIB_POSIXCHECK
211# undef fflush 343# undef fflush
212/* Assume fflush is always declared. */ 344/* Assume fflush is always declared. */
@@ -225,7 +357,9 @@ _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
225# else 357# else
226_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); 358_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
227# endif 359# endif
360# if __GLIBC__ >= 2
228_GL_CXXALIASWARN (fgetc); 361_GL_CXXALIASWARN (fgetc);
362# endif
229#endif 363#endif
230 364
231#if @GNULIB_FGETS@ 365#if @GNULIB_FGETS@
@@ -234,33 +368,74 @@ _GL_CXXALIASWARN (fgetc);
234# undef fgets 368# undef fgets
235# define fgets rpl_fgets 369# define fgets rpl_fgets
236# endif 370# endif
237_GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream) 371_GL_FUNCDECL_RPL (fgets, char *,
238 _GL_ARG_NONNULL ((1, 3))); 372 (char *restrict s, int n, FILE *restrict stream)
239_GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream)); 373 _GL_ARG_NONNULL ((1, 3)));
374_GL_CXXALIAS_RPL (fgets, char *,
375 (char *restrict s, int n, FILE *restrict stream));
240# else 376# else
241_GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream)); 377_GL_CXXALIAS_SYS (fgets, char *,
378 (char *restrict s, int n, FILE *restrict stream));
242# endif 379# endif
380# if __GLIBC__ >= 2
243_GL_CXXALIASWARN (fgets); 381_GL_CXXALIASWARN (fgets);
382# endif
383#endif
384
385#if @GNULIB_MDA_FILENO@
386/* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not
387 required. In C++ with GNULIB_NAMESPACE, avoid differences between
388 platforms by defining GNULIB_NAMESPACE::fileno always. */
389# if defined _WIN32 && !defined __CYGWIN__
390# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
391# undef fileno
392# define fileno _fileno
393# endif
394_GL_CXXALIAS_MDA (fileno, int, (FILE *restrict stream));
395# else
396_GL_CXXALIAS_SYS (fileno, int, (FILE *restrict stream));
397# endif
398_GL_CXXALIASWARN (fileno);
244#endif 399#endif
245 400
246#if @GNULIB_FOPEN@ 401#if @GNULIB_FOPEN@
247# if @REPLACE_FOPEN@ 402# if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
403 || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
248# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 404# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
249# undef fopen 405# undef fopen
250# define fopen rpl_fopen 406# define fopen rpl_fopen
251# endif 407# endif
252_GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) 408_GL_FUNCDECL_RPL (fopen, FILE *,
253 _GL_ARG_NONNULL ((1, 2))); 409 (const char *restrict filename, const char *restrict mode)
254_GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); 410 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
411_GL_CXXALIAS_RPL (fopen, FILE *,
412 (const char *restrict filename, const char *restrict mode));
255# else 413# else
256_GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); 414# if __GNUC__ >= 11
415/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
416_GL_FUNCDECL_SYS (fopen, FILE *,
417 (const char *restrict filename, const char *restrict mode)
418 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
419# endif
420_GL_CXXALIAS_SYS (fopen, FILE *,
421 (const char *restrict filename, const char *restrict mode));
257# endif 422# endif
423# if __GLIBC__ >= 2
258_GL_CXXALIASWARN (fopen); 424_GL_CXXALIASWARN (fopen);
259#elif defined GNULIB_POSIXCHECK 425# endif
260# undef fopen 426#else
427# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen
428/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
429_GL_FUNCDECL_SYS (fopen, FILE *,
430 (const char *restrict filename, const char *restrict mode)
431 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
432# endif
433# if defined GNULIB_POSIXCHECK
434# undef fopen
261/* Assume fopen is always declared. */ 435/* Assume fopen is always declared. */
262_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " 436_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
263 "use gnulib module fopen for portability"); 437 "use gnulib module fopen for portability");
438# endif
264#endif 439#endif
265 440
266#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ 441#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
@@ -271,19 +446,25 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian
271# endif 446# endif
272# define GNULIB_overrides_fprintf 1 447# define GNULIB_overrides_fprintf 1
273# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 448# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
274_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 449_GL_FUNCDECL_RPL (fprintf, int,
275 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 450 (FILE *restrict fp, const char *restrict format, ...)
276 _GL_ARG_NONNULL ((1, 2))); 451 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
452 _GL_ARG_NONNULL ((1, 2)));
277# else 453# else
278_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 454_GL_FUNCDECL_RPL (fprintf, int,
279 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) 455 (FILE *restrict fp, const char *restrict format, ...)
280 _GL_ARG_NONNULL ((1, 2))); 456 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
457 _GL_ARG_NONNULL ((1, 2)));
281# endif 458# endif
282_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); 459_GL_CXXALIAS_RPL (fprintf, int,
460 (FILE *restrict fp, const char *restrict format, ...));
283# else 461# else
284_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); 462_GL_CXXALIAS_SYS (fprintf, int,
463 (FILE *restrict fp, const char *restrict format, ...));
285# endif 464# endif
465# if __GLIBC__ >= 2
286_GL_CXXALIASWARN (fprintf); 466_GL_CXXALIASWARN (fprintf);
467# endif
287#endif 468#endif
288#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 469#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
289# if !GNULIB_overrides_fprintf 470# if !GNULIB_overrides_fprintf
@@ -334,7 +515,9 @@ _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
334# else 515# else
335_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); 516_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
336# endif 517# endif
518# if __GLIBC__ >= 2
337_GL_CXXALIASWARN (fputc); 519_GL_CXXALIASWARN (fputc);
520# endif
338#endif 521#endif
339 522
340#if @GNULIB_FPUTS@ 523#if @GNULIB_FPUTS@
@@ -343,13 +526,18 @@ _GL_CXXALIASWARN (fputc);
343# undef fputs 526# undef fputs
344# define fputs rpl_fputs 527# define fputs rpl_fputs
345# endif 528# endif
346_GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) 529_GL_FUNCDECL_RPL (fputs, int,
347 _GL_ARG_NONNULL ((1, 2))); 530 (const char *restrict string, FILE *restrict stream)
348_GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); 531 _GL_ARG_NONNULL ((1, 2)));
532_GL_CXXALIAS_RPL (fputs, int,
533 (const char *restrict string, FILE *restrict stream));
349# else 534# else
350_GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); 535_GL_CXXALIAS_SYS (fputs, int,
536 (const char *restrict string, FILE *restrict stream));
351# endif 537# endif
538# if __GLIBC__ >= 2
352_GL_CXXALIASWARN (fputs); 539_GL_CXXALIASWARN (fputs);
540# endif
353#endif 541#endif
354 542
355#if @GNULIB_FREAD@ 543#if @GNULIB_FREAD@
@@ -358,13 +546,21 @@ _GL_CXXALIASWARN (fputs);
358# undef fread 546# undef fread
359# define fread rpl_fread 547# define fread rpl_fread
360# endif 548# endif
361_GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream) 549_GL_FUNCDECL_RPL (fread, size_t,
362 _GL_ARG_NONNULL ((4))); 550 (void *restrict ptr, size_t s, size_t n,
363_GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); 551 FILE *restrict stream)
552 _GL_ARG_NONNULL ((4)));
553_GL_CXXALIAS_RPL (fread, size_t,
554 (void *restrict ptr, size_t s, size_t n,
555 FILE *restrict stream));
364# else 556# else
365_GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); 557_GL_CXXALIAS_SYS (fread, size_t,
558 (void *restrict ptr, size_t s, size_t n,
559 FILE *restrict stream));
366# endif 560# endif
561# if __GLIBC__ >= 2
367_GL_CXXALIASWARN (fread); 562_GL_CXXALIASWARN (fread);
563# endif
368#endif 564#endif
369 565
370#if @GNULIB_FREOPEN@ 566#if @GNULIB_FREOPEN@
@@ -374,15 +570,20 @@ _GL_CXXALIASWARN (fread);
374# define freopen rpl_freopen 570# define freopen rpl_freopen
375# endif 571# endif
376_GL_FUNCDECL_RPL (freopen, FILE *, 572_GL_FUNCDECL_RPL (freopen, FILE *,
377 (const char *filename, const char *mode, FILE *stream) 573 (const char *restrict filename, const char *restrict mode,
574 FILE *restrict stream)
378 _GL_ARG_NONNULL ((2, 3))); 575 _GL_ARG_NONNULL ((2, 3)));
379_GL_CXXALIAS_RPL (freopen, FILE *, 576_GL_CXXALIAS_RPL (freopen, FILE *,
380 (const char *filename, const char *mode, FILE *stream)); 577 (const char *restrict filename, const char *restrict mode,
578 FILE *restrict stream));
381# else 579# else
382_GL_CXXALIAS_SYS (freopen, FILE *, 580_GL_CXXALIAS_SYS (freopen, FILE *,
383 (const char *filename, const char *mode, FILE *stream)); 581 (const char *restrict filename, const char *restrict mode,
582 FILE *restrict stream));
384# endif 583# endif
584# if __GLIBC__ >= 2
385_GL_CXXALIASWARN (freopen); 585_GL_CXXALIASWARN (freopen);
586# endif
386#elif defined GNULIB_POSIXCHECK 587#elif defined GNULIB_POSIXCHECK
387# undef freopen 588# undef freopen
388/* Assume freopen is always declared. */ 589/* Assume freopen is always declared. */
@@ -397,14 +598,19 @@ _GL_WARN_ON_USE (freopen,
397# undef fscanf 598# undef fscanf
398# define fscanf rpl_fscanf 599# define fscanf rpl_fscanf
399# endif 600# endif
400_GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...) 601_GL_FUNCDECL_RPL (fscanf, int,
401 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) 602 (FILE *restrict stream, const char *restrict format, ...)
402 _GL_ARG_NONNULL ((1, 2))); 603 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
403_GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...)); 604 _GL_ARG_NONNULL ((1, 2)));
605_GL_CXXALIAS_RPL (fscanf, int,
606 (FILE *restrict stream, const char *restrict format, ...));
404# else 607# else
405_GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...)); 608_GL_CXXALIAS_SYS (fscanf, int,
609 (FILE *restrict stream, const char *restrict format, ...));
406# endif 610# endif
611# if __GLIBC__ >= 2
407_GL_CXXALIASWARN (fscanf); 612_GL_CXXALIASWARN (fscanf);
613# endif
408#endif 614#endif
409 615
410 616
@@ -455,7 +661,9 @@ _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
455# else 661# else
456_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); 662_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
457# endif 663# endif
664# if __GLIBC__ >= 2
458_GL_CXXALIASWARN (fseek); 665_GL_CXXALIASWARN (fseek);
666# endif
459#endif 667#endif
460 668
461#if @GNULIB_FSEEKO@ 669#if @GNULIB_FSEEKO@
@@ -518,7 +726,9 @@ _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
518# else 726# else
519_GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); 727_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
520# endif 728# endif
729# if __GLIBC__ >= 2
521_GL_CXXALIASWARN (ftell); 730_GL_CXXALIASWARN (ftell);
731# endif
522#endif 732#endif
523 733
524#if @GNULIB_FTELLO@ 734#if @GNULIB_FTELLO@
@@ -567,16 +777,19 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
567# define fwrite rpl_fwrite 777# define fwrite rpl_fwrite
568# endif 778# endif
569_GL_FUNCDECL_RPL (fwrite, size_t, 779_GL_FUNCDECL_RPL (fwrite, size_t,
570 (const void *ptr, size_t s, size_t n, FILE *stream) 780 (const void *restrict ptr, size_t s, size_t n,
781 FILE *restrict stream)
571 _GL_ARG_NONNULL ((1, 4))); 782 _GL_ARG_NONNULL ((1, 4)));
572_GL_CXXALIAS_RPL (fwrite, size_t, 783_GL_CXXALIAS_RPL (fwrite, size_t,
573 (const void *ptr, size_t s, size_t n, FILE *stream)); 784 (const void *restrict ptr, size_t s, size_t n,
785 FILE *restrict stream));
574# else 786# else
575_GL_CXXALIAS_SYS (fwrite, size_t, 787_GL_CXXALIAS_SYS (fwrite, size_t,
576 (const void *ptr, size_t s, size_t n, FILE *stream)); 788 (const void *restrict ptr, size_t s, size_t n,
789 FILE *restrict stream));
577 790
578/* Work around bug 11959 when fortifying glibc 2.4 through 2.15 791/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
579 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>, 792 <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
580 which sometimes causes an unwanted diagnostic for fwrite calls. 793 which sometimes causes an unwanted diagnostic for fwrite calls.
581 This affects only function declaration attributes under certain 794 This affects only function declaration attributes under certain
582 versions of gcc and clang, and is not needed for C++. */ 795 versions of gcc and clang, and is not needed for C++. */
@@ -598,7 +811,9 @@ extern size_t __REDIRECT (rpl_fwrite_unlocked,
598# define fwrite_unlocked rpl_fwrite_unlocked 811# define fwrite_unlocked rpl_fwrite_unlocked
599# endif 812# endif
600# endif 813# endif
814# if __GLIBC__ >= 2
601_GL_CXXALIASWARN (fwrite); 815_GL_CXXALIASWARN (fwrite);
816# endif
602#endif 817#endif
603 818
604#if @GNULIB_GETC@ 819#if @GNULIB_GETC@
@@ -612,7 +827,9 @@ _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
612# else 827# else
613_GL_CXXALIAS_SYS (getc, int, (FILE *stream)); 828_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
614# endif 829# endif
830# if __GLIBC__ >= 2
615_GL_CXXALIASWARN (getc); 831_GL_CXXALIASWARN (getc);
832# endif
616#endif 833#endif
617 834
618#if @GNULIB_GETCHAR@ 835#if @GNULIB_GETCHAR@
@@ -626,7 +843,9 @@ _GL_CXXALIAS_RPL (getchar, int, (void));
626# else 843# else
627_GL_CXXALIAS_SYS (getchar, int, (void)); 844_GL_CXXALIAS_SYS (getchar, int, (void));
628# endif 845# endif
846# if __GLIBC__ >= 2
629_GL_CXXALIASWARN (getchar); 847_GL_CXXALIASWARN (getchar);
848# endif
630#endif 849#endif
631 850
632#if @GNULIB_GETDELIM@ 851#if @GNULIB_GETDELIM@
@@ -642,22 +861,26 @@ _GL_CXXALIASWARN (getchar);
642# define getdelim rpl_getdelim 861# define getdelim rpl_getdelim
643# endif 862# endif
644_GL_FUNCDECL_RPL (getdelim, ssize_t, 863_GL_FUNCDECL_RPL (getdelim, ssize_t,
645 (char **lineptr, size_t *linesize, int delimiter, 864 (char **restrict lineptr, size_t *restrict linesize,
646 FILE *stream) 865 int delimiter,
866 FILE *restrict stream)
647 _GL_ARG_NONNULL ((1, 2, 4))); 867 _GL_ARG_NONNULL ((1, 2, 4)));
648_GL_CXXALIAS_RPL (getdelim, ssize_t, 868_GL_CXXALIAS_RPL (getdelim, ssize_t,
649 (char **lineptr, size_t *linesize, int delimiter, 869 (char **restrict lineptr, size_t *restrict linesize,
650 FILE *stream)); 870 int delimiter,
871 FILE *restrict stream));
651# else 872# else
652# if !@HAVE_DECL_GETDELIM@ 873# if !@HAVE_DECL_GETDELIM@
653_GL_FUNCDECL_SYS (getdelim, ssize_t, 874_GL_FUNCDECL_SYS (getdelim, ssize_t,
654 (char **lineptr, size_t *linesize, int delimiter, 875 (char **restrict lineptr, size_t *restrict linesize,
655 FILE *stream) 876 int delimiter,
877 FILE *restrict stream)
656 _GL_ARG_NONNULL ((1, 2, 4))); 878 _GL_ARG_NONNULL ((1, 2, 4)));
657# endif 879# endif
658_GL_CXXALIAS_SYS (getdelim, ssize_t, 880_GL_CXXALIAS_SYS (getdelim, ssize_t,
659 (char **lineptr, size_t *linesize, int delimiter, 881 (char **restrict lineptr, size_t *restrict linesize,
660 FILE *stream)); 882 int delimiter,
883 FILE *restrict stream));
661# endif 884# endif
662_GL_CXXALIASWARN (getdelim); 885_GL_CXXALIASWARN (getdelim);
663#elif defined GNULIB_POSIXCHECK 886#elif defined GNULIB_POSIXCHECK
@@ -681,18 +904,22 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
681# define getline rpl_getline 904# define getline rpl_getline
682# endif 905# endif
683_GL_FUNCDECL_RPL (getline, ssize_t, 906_GL_FUNCDECL_RPL (getline, ssize_t,
684 (char **lineptr, size_t *linesize, FILE *stream) 907 (char **restrict lineptr, size_t *restrict linesize,
908 FILE *restrict stream)
685 _GL_ARG_NONNULL ((1, 2, 3))); 909 _GL_ARG_NONNULL ((1, 2, 3)));
686_GL_CXXALIAS_RPL (getline, ssize_t, 910_GL_CXXALIAS_RPL (getline, ssize_t,
687 (char **lineptr, size_t *linesize, FILE *stream)); 911 (char **restrict lineptr, size_t *restrict linesize,
912 FILE *restrict stream));
688# else 913# else
689# if !@HAVE_DECL_GETLINE@ 914# if !@HAVE_DECL_GETLINE@
690_GL_FUNCDECL_SYS (getline, ssize_t, 915_GL_FUNCDECL_SYS (getline, ssize_t,
691 (char **lineptr, size_t *linesize, FILE *stream) 916 (char **restrict lineptr, size_t *restrict linesize,
917 FILE *restrict stream)
692 _GL_ARG_NONNULL ((1, 2, 3))); 918 _GL_ARG_NONNULL ((1, 2, 3)));
693# endif 919# endif
694_GL_CXXALIAS_SYS (getline, ssize_t, 920_GL_CXXALIAS_SYS (getline, ssize_t,
695 (char **lineptr, size_t *linesize, FILE *stream)); 921 (char **restrict lineptr, size_t *restrict linesize,
922 FILE *restrict stream));
696# endif 923# endif
697# if @HAVE_DECL_GETLINE@ 924# if @HAVE_DECL_GETLINE@
698_GL_CXXALIASWARN (getline); 925_GL_CXXALIASWARN (getline);
@@ -709,10 +936,25 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
709 so any use of gets warrants an unconditional warning; besides, C11 936 so any use of gets warrants an unconditional warning; besides, C11
710 removed it. */ 937 removed it. */
711#undef gets 938#undef gets
712#if HAVE_RAW_DECL_GETS 939#if HAVE_RAW_DECL_GETS && !defined __cplusplus
713_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 940_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
714#endif 941#endif
715 942
943#if @GNULIB_MDA_GETW@
944/* On native Windows, map 'getw' to '_getw', so that -loldnames is not
945 required. In C++ with GNULIB_NAMESPACE, avoid differences between
946 platforms by defining GNULIB_NAMESPACE::getw always. */
947# if defined _WIN32 && !defined __CYGWIN__
948# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
949# undef getw
950# define getw _getw
951# endif
952_GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
953# else
954_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
955# endif
956_GL_CXXALIASWARN (getw);
957#endif
716 958
717#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ 959#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
718struct obstack; 960struct obstack;
@@ -727,7 +969,7 @@ struct obstack;
727# endif 969# endif
728_GL_FUNCDECL_RPL (obstack_printf, int, 970_GL_FUNCDECL_RPL (obstack_printf, int,
729 (struct obstack *obs, const char *format, ...) 971 (struct obstack *obs, const char *format, ...)
730 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 972 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
731 _GL_ARG_NONNULL ((1, 2))); 973 _GL_ARG_NONNULL ((1, 2)));
732_GL_CXXALIAS_RPL (obstack_printf, int, 974_GL_CXXALIAS_RPL (obstack_printf, int,
733 (struct obstack *obs, const char *format, ...)); 975 (struct obstack *obs, const char *format, ...));
@@ -735,7 +977,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int,
735# if !@HAVE_DECL_OBSTACK_PRINTF@ 977# if !@HAVE_DECL_OBSTACK_PRINTF@
736_GL_FUNCDECL_SYS (obstack_printf, int, 978_GL_FUNCDECL_SYS (obstack_printf, int,
737 (struct obstack *obs, const char *format, ...) 979 (struct obstack *obs, const char *format, ...)
738 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 980 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
739 _GL_ARG_NONNULL ((1, 2))); 981 _GL_ARG_NONNULL ((1, 2)));
740# endif 982# endif
741_GL_CXXALIAS_SYS (obstack_printf, int, 983_GL_CXXALIAS_SYS (obstack_printf, int,
@@ -748,7 +990,7 @@ _GL_CXXALIASWARN (obstack_printf);
748# endif 990# endif
749_GL_FUNCDECL_RPL (obstack_vprintf, int, 991_GL_FUNCDECL_RPL (obstack_vprintf, int,
750 (struct obstack *obs, const char *format, va_list args) 992 (struct obstack *obs, const char *format, va_list args)
751 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 993 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
752 _GL_ARG_NONNULL ((1, 2))); 994 _GL_ARG_NONNULL ((1, 2)));
753_GL_CXXALIAS_RPL (obstack_vprintf, int, 995_GL_CXXALIAS_RPL (obstack_vprintf, int,
754 (struct obstack *obs, const char *format, va_list args)); 996 (struct obstack *obs, const char *format, va_list args));
@@ -756,7 +998,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int,
756# if !@HAVE_DECL_OBSTACK_PRINTF@ 998# if !@HAVE_DECL_OBSTACK_PRINTF@
757_GL_FUNCDECL_SYS (obstack_vprintf, int, 999_GL_FUNCDECL_SYS (obstack_vprintf, int,
758 (struct obstack *obs, const char *format, va_list args) 1000 (struct obstack *obs, const char *format, va_list args)
759 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1001 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
760 _GL_ARG_NONNULL ((1, 2))); 1002 _GL_ARG_NONNULL ((1, 2)));
761# endif 1003# endif
762_GL_CXXALIAS_SYS (obstack_vprintf, int, 1004_GL_CXXALIAS_SYS (obstack_vprintf, int,
@@ -792,7 +1034,9 @@ _GL_CXXALIAS_RPL (perror, void, (const char *string));
792# else 1034# else
793_GL_CXXALIAS_SYS (perror, void, (const char *string)); 1035_GL_CXXALIAS_SYS (perror, void, (const char *string));
794# endif 1036# endif
1037# if __GLIBC__ >= 2
795_GL_CXXALIASWARN (perror); 1038_GL_CXXALIASWARN (perror);
1039# endif
796#elif defined GNULIB_POSIXCHECK 1040#elif defined GNULIB_POSIXCHECK
797# undef perror 1041# undef perror
798/* Assume perror is always declared. */ 1042/* Assume perror is always declared. */
@@ -806,43 +1050,53 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
806# undef popen 1050# undef popen
807# define popen rpl_popen 1051# define popen rpl_popen
808# endif 1052# endif
809_GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) 1053_GL_FUNCDECL_RPL (popen, FILE *,
810 _GL_ARG_NONNULL ((1, 2))); 1054 (const char *cmd, const char *mode)
1055 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
811_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 1056_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
812# else 1057# else
813# if !@HAVE_POPEN@ 1058# if !@HAVE_POPEN@ || __GNUC__ >= 11
814_GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) 1059_GL_FUNCDECL_SYS (popen, FILE *,
815 _GL_ARG_NONNULL ((1, 2))); 1060 (const char *cmd, const char *mode)
1061 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
816# endif 1062# endif
817_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 1063_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
818# endif 1064# endif
819_GL_CXXALIASWARN (popen); 1065_GL_CXXALIASWARN (popen);
820#elif defined GNULIB_POSIXCHECK 1066#else
821# undef popen 1067# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen
822# if HAVE_RAW_DECL_POPEN 1068/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1069_GL_FUNCDECL_SYS (popen, FILE *,
1070 (const char *cmd, const char *mode)
1071 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
1072# endif
1073# if defined GNULIB_POSIXCHECK
1074# undef popen
1075# if HAVE_RAW_DECL_POPEN
823_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " 1076_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
824 "use gnulib module popen or pipe for more portability"); 1077 "use gnulib module popen or pipe for more portability");
1078# endif
825# endif 1079# endif
826#endif 1080#endif
827 1081
828#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 1082#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
829# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 1083# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
830 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1084 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
831# if defined __GNUC__ 1085# if defined __GNUC__ || defined __clang__
832# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1086# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
833/* Don't break __attribute__((format(printf,M,N))). */ 1087/* Don't break __attribute__((format(printf,M,N))). */
834# define printf __printf__ 1088# define printf __printf__
835# endif 1089# endif
836# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 1090# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
837_GL_FUNCDECL_RPL_1 (__printf__, int, 1091_GL_FUNCDECL_RPL_1 (__printf__, int,
838 (const char *format, ...) 1092 (const char *restrict format, ...)
839 __asm__ (@ASM_SYMBOL_PREFIX@ 1093 __asm__ (@ASM_SYMBOL_PREFIX@
840 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1094 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
841 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) 1095 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
842 _GL_ARG_NONNULL ((1))); 1096 _GL_ARG_NONNULL ((1)));
843# else 1097# else
844_GL_FUNCDECL_RPL_1 (__printf__, int, 1098_GL_FUNCDECL_RPL_1 (__printf__, int,
845 (const char *format, ...) 1099 (const char *restrict format, ...)
846 __asm__ (@ASM_SYMBOL_PREFIX@ 1100 __asm__ (@ASM_SYMBOL_PREFIX@
847 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1101 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
848 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) 1102 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
@@ -854,16 +1108,18 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
854# define printf rpl_printf 1108# define printf rpl_printf
855# endif 1109# endif
856_GL_FUNCDECL_RPL (printf, int, 1110_GL_FUNCDECL_RPL (printf, int,
857 (const char *format, ...) 1111 (const char *restrict format, ...)
858 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) 1112 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
859 _GL_ARG_NONNULL ((1))); 1113 _GL_ARG_NONNULL ((1)));
860_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); 1114_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
861# endif 1115# endif
862# define GNULIB_overrides_printf 1 1116# define GNULIB_overrides_printf 1
863# else 1117# else
864_GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); 1118_GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
865# endif 1119# endif
1120# if __GLIBC__ >= 2
866_GL_CXXALIASWARN (printf); 1121_GL_CXXALIASWARN (printf);
1122# endif
867#endif 1123#endif
868#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1124#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
869# if !GNULIB_overrides_printf 1125# if !GNULIB_overrides_printf
@@ -886,7 +1142,9 @@ _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
886# else 1142# else
887_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); 1143_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
888# endif 1144# endif
1145# if __GLIBC__ >= 2
889_GL_CXXALIASWARN (putc); 1146_GL_CXXALIASWARN (putc);
1147# endif
890#endif 1148#endif
891 1149
892#if @GNULIB_PUTCHAR@ 1150#if @GNULIB_PUTCHAR@
@@ -900,7 +1158,9 @@ _GL_CXXALIAS_RPL (putchar, int, (int c));
900# else 1158# else
901_GL_CXXALIAS_SYS (putchar, int, (int c)); 1159_GL_CXXALIAS_SYS (putchar, int, (int c));
902# endif 1160# endif
1161# if __GLIBC__ >= 2
903_GL_CXXALIASWARN (putchar); 1162_GL_CXXALIASWARN (putchar);
1163# endif
904#endif 1164#endif
905 1165
906#if @GNULIB_PUTS@ 1166#if @GNULIB_PUTS@
@@ -914,7 +1174,25 @@ _GL_CXXALIAS_RPL (puts, int, (const char *string));
914# else 1174# else
915_GL_CXXALIAS_SYS (puts, int, (const char *string)); 1175_GL_CXXALIAS_SYS (puts, int, (const char *string));
916# endif 1176# endif
1177# if __GLIBC__ >= 2
917_GL_CXXALIASWARN (puts); 1178_GL_CXXALIASWARN (puts);
1179# endif
1180#endif
1181
1182#if @GNULIB_MDA_PUTW@
1183/* On native Windows, map 'putw' to '_putw', so that -loldnames is not
1184 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1185 platforms by defining GNULIB_NAMESPACE::putw always. */
1186# if defined _WIN32 && !defined __CYGWIN__
1187# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1188# undef putw
1189# define putw _putw
1190# endif
1191_GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
1192# else
1193_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
1194# endif
1195_GL_CXXALIASWARN (putw);
918#endif 1196#endif
919 1197
920#if @GNULIB_REMOVE@ 1198#if @GNULIB_REMOVE@
@@ -928,7 +1206,9 @@ _GL_CXXALIAS_RPL (remove, int, (const char *name));
928# else 1206# else
929_GL_CXXALIAS_SYS (remove, int, (const char *name)); 1207_GL_CXXALIAS_SYS (remove, int, (const char *name));
930# endif 1208# endif
1209# if __GLIBC__ >= 2
931_GL_CXXALIASWARN (remove); 1210_GL_CXXALIASWARN (remove);
1211# endif
932#elif defined GNULIB_POSIXCHECK 1212#elif defined GNULIB_POSIXCHECK
933# undef remove 1213# undef remove
934/* Assume remove is always declared. */ 1214/* Assume remove is always declared. */
@@ -951,7 +1231,9 @@ _GL_CXXALIAS_RPL (rename, int,
951_GL_CXXALIAS_SYS (rename, int, 1231_GL_CXXALIAS_SYS (rename, int,
952 (const char *old_filename, const char *new_filename)); 1232 (const char *old_filename, const char *new_filename));
953# endif 1233# endif
1234# if __GLIBC__ >= 2
954_GL_CXXALIASWARN (rename); 1235_GL_CXXALIASWARN (rename);
1236# endif
955#elif defined GNULIB_POSIXCHECK 1237#elif defined GNULIB_POSIXCHECK
956# undef rename 1238# undef rename
957/* Assume rename is always declared. */ 1239/* Assume rename is always declared. */
@@ -990,33 +1272,35 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
990 1272
991#if @GNULIB_SCANF@ 1273#if @GNULIB_SCANF@
992# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ 1274# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
993# if defined __GNUC__ 1275# if defined __GNUC__ || defined __clang__
994# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1276# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
995# undef scanf 1277# undef scanf
996/* Don't break __attribute__((format(scanf,M,N))). */ 1278/* Don't break __attribute__((format(scanf,M,N))). */
997# define scanf __scanf__ 1279# define scanf __scanf__
998# endif 1280# endif
999_GL_FUNCDECL_RPL_1 (__scanf__, int, 1281_GL_FUNCDECL_RPL_1 (__scanf__, int,
1000 (const char *format, ...) 1282 (const char *restrict format, ...)
1001 __asm__ (@ASM_SYMBOL_PREFIX@ 1283 __asm__ (@ASM_SYMBOL_PREFIX@
1002 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) 1284 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
1003 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1285 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1004 _GL_ARG_NONNULL ((1))); 1286 _GL_ARG_NONNULL ((1)));
1005_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...)); 1287_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
1006# else 1288# else
1007# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1289# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1008# undef scanf 1290# undef scanf
1009# define scanf rpl_scanf 1291# define scanf rpl_scanf
1010# endif 1292# endif
1011_GL_FUNCDECL_RPL (scanf, int, (const char *format, ...) 1293_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...)
1012 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1294 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1013 _GL_ARG_NONNULL ((1))); 1295 _GL_ARG_NONNULL ((1)));
1014_GL_CXXALIAS_RPL (scanf, int, (const char *format, ...)); 1296_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
1015# endif 1297# endif
1016# else 1298# else
1017_GL_CXXALIAS_SYS (scanf, int, (const char *format, ...)); 1299_GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...));
1018# endif 1300# endif
1301# if __GLIBC__ >= 2
1019_GL_CXXALIASWARN (scanf); 1302_GL_CXXALIASWARN (scanf);
1303# endif
1020#endif 1304#endif
1021 1305
1022#if @GNULIB_SNPRINTF@ 1306#if @GNULIB_SNPRINTF@
@@ -1024,23 +1308,30 @@ _GL_CXXALIASWARN (scanf);
1024# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1308# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1025# define snprintf rpl_snprintf 1309# define snprintf rpl_snprintf
1026# endif 1310# endif
1311# define GNULIB_overrides_snprintf 1
1027_GL_FUNCDECL_RPL (snprintf, int, 1312_GL_FUNCDECL_RPL (snprintf, int,
1028 (char *str, size_t size, const char *format, ...) 1313 (char *restrict str, size_t size,
1029 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) 1314 const char *restrict format, ...)
1315 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1030 _GL_ARG_NONNULL ((3))); 1316 _GL_ARG_NONNULL ((3)));
1031_GL_CXXALIAS_RPL (snprintf, int, 1317_GL_CXXALIAS_RPL (snprintf, int,
1032 (char *str, size_t size, const char *format, ...)); 1318 (char *restrict str, size_t size,
1319 const char *restrict format, ...));
1033# else 1320# else
1034# if !@HAVE_DECL_SNPRINTF@ 1321# if !@HAVE_DECL_SNPRINTF@
1035_GL_FUNCDECL_SYS (snprintf, int, 1322_GL_FUNCDECL_SYS (snprintf, int,
1036 (char *str, size_t size, const char *format, ...) 1323 (char *restrict str, size_t size,
1037 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) 1324 const char *restrict format, ...)
1325 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1038 _GL_ARG_NONNULL ((3))); 1326 _GL_ARG_NONNULL ((3)));
1039# endif 1327# endif
1040_GL_CXXALIAS_SYS (snprintf, int, 1328_GL_CXXALIAS_SYS (snprintf, int,
1041 (char *str, size_t size, const char *format, ...)); 1329 (char *restrict str, size_t size,
1330 const char *restrict format, ...));
1042# endif 1331# endif
1332# if __GLIBC__ >= 2
1043_GL_CXXALIASWARN (snprintf); 1333_GL_CXXALIASWARN (snprintf);
1334# endif
1044#elif defined GNULIB_POSIXCHECK 1335#elif defined GNULIB_POSIXCHECK
1045# undef snprintf 1336# undef snprintf
1046# if HAVE_RAW_DECL_SNPRINTF 1337# if HAVE_RAW_DECL_SNPRINTF
@@ -1063,14 +1354,20 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1063# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1354# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1064# define sprintf rpl_sprintf 1355# define sprintf rpl_sprintf
1065# endif 1356# endif
1066_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) 1357# define GNULIB_overrides_sprintf 1
1067 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 1358_GL_FUNCDECL_RPL (sprintf, int,
1068 _GL_ARG_NONNULL ((1, 2))); 1359 (char *restrict str, const char *restrict format, ...)
1069_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); 1360 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1361 _GL_ARG_NONNULL ((1, 2)));
1362_GL_CXXALIAS_RPL (sprintf, int,
1363 (char *restrict str, const char *restrict format, ...));
1070# else 1364# else
1071_GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); 1365_GL_CXXALIAS_SYS (sprintf, int,
1366 (char *restrict str, const char *restrict format, ...));
1072# endif 1367# endif
1368# if __GLIBC__ >= 2
1073_GL_CXXALIASWARN (sprintf); 1369_GL_CXXALIASWARN (sprintf);
1370# endif
1074#elif defined GNULIB_POSIXCHECK 1371#elif defined GNULIB_POSIXCHECK
1075# undef sprintf 1372# undef sprintf
1076/* Assume sprintf is always declared. */ 1373/* Assume sprintf is always declared. */
@@ -1079,22 +1376,53 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1079 "POSIX compliance"); 1376 "POSIX compliance");
1080#endif 1377#endif
1081 1378
1379#if @GNULIB_MDA_TEMPNAM@
1380/* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not
1381 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1382 platforms by defining GNULIB_NAMESPACE::tempnam always. */
1383# if defined _WIN32 && !defined __CYGWIN__
1384# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1385# undef tempnam
1386# define tempnam _tempnam
1387# endif
1388_GL_CXXALIAS_MDA (tempnam, char *, (const char *dir, const char *prefix));
1389# else
1390_GL_CXXALIAS_SYS (tempnam, char *, (const char *dir, const char *prefix));
1391# endif
1392_GL_CXXALIASWARN (tempnam);
1393#endif
1394
1082#if @GNULIB_TMPFILE@ 1395#if @GNULIB_TMPFILE@
1083# if @REPLACE_TMPFILE@ 1396# if @REPLACE_TMPFILE@
1084# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1397# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085# define tmpfile rpl_tmpfile 1398# define tmpfile rpl_tmpfile
1086# endif 1399# endif
1087_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); 1400_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
1401 _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1088_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); 1402_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1089# else 1403# else
1404# if __GNUC__ >= 11
1405/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1406_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1407 _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1408# endif
1090_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); 1409_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1091# endif 1410# endif
1411# if __GLIBC__ >= 2
1092_GL_CXXALIASWARN (tmpfile); 1412_GL_CXXALIASWARN (tmpfile);
1093#elif defined GNULIB_POSIXCHECK 1413# endif
1094# undef tmpfile 1414#else
1095# if HAVE_RAW_DECL_TMPFILE 1415# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
1416/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1417_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1418 _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1419# endif
1420# if defined GNULIB_POSIXCHECK
1421# undef tmpfile
1422# if HAVE_RAW_DECL_TMPFILE
1096_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " 1423_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1097 "use gnulib module tmpfile for portability"); 1424 "use gnulib module tmpfile for portability");
1425# endif
1098# endif 1426# endif
1099#endif 1427#endif
1100 1428
@@ -1107,9 +1435,10 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1107# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1435# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1108# define asprintf rpl_asprintf 1436# define asprintf rpl_asprintf
1109# endif 1437# endif
1438# define GNULIB_overrides_asprintf
1110_GL_FUNCDECL_RPL (asprintf, int, 1439_GL_FUNCDECL_RPL (asprintf, int,
1111 (char **result, const char *format, ...) 1440 (char **result, const char *format, ...)
1112 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 1441 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1113 _GL_ARG_NONNULL ((1, 2))); 1442 _GL_ARG_NONNULL ((1, 2)));
1114_GL_CXXALIAS_RPL (asprintf, int, 1443_GL_CXXALIAS_RPL (asprintf, int,
1115 (char **result, const char *format, ...)); 1444 (char **result, const char *format, ...));
@@ -1117,7 +1446,7 @@ _GL_CXXALIAS_RPL (asprintf, int,
1117# if !@HAVE_VASPRINTF@ 1446# if !@HAVE_VASPRINTF@
1118_GL_FUNCDECL_SYS (asprintf, int, 1447_GL_FUNCDECL_SYS (asprintf, int,
1119 (char **result, const char *format, ...) 1448 (char **result, const char *format, ...)
1120 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 1449 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1121 _GL_ARG_NONNULL ((1, 2))); 1450 _GL_ARG_NONNULL ((1, 2)));
1122# endif 1451# endif
1123_GL_CXXALIAS_SYS (asprintf, int, 1452_GL_CXXALIAS_SYS (asprintf, int,
@@ -1128,9 +1457,10 @@ _GL_CXXALIASWARN (asprintf);
1128# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1457# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1129# define vasprintf rpl_vasprintf 1458# define vasprintf rpl_vasprintf
1130# endif 1459# endif
1460# define GNULIB_overrides_vasprintf 1
1131_GL_FUNCDECL_RPL (vasprintf, int, 1461_GL_FUNCDECL_RPL (vasprintf, int,
1132 (char **result, const char *format, va_list args) 1462 (char **result, const char *format, va_list args)
1133 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1463 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1134 _GL_ARG_NONNULL ((1, 2))); 1464 _GL_ARG_NONNULL ((1, 2)));
1135_GL_CXXALIAS_RPL (vasprintf, int, 1465_GL_CXXALIAS_RPL (vasprintf, int,
1136 (char **result, const char *format, va_list args)); 1466 (char **result, const char *format, va_list args));
@@ -1138,7 +1468,7 @@ _GL_CXXALIAS_RPL (vasprintf, int,
1138# if !@HAVE_VASPRINTF@ 1468# if !@HAVE_VASPRINTF@
1139_GL_FUNCDECL_SYS (vasprintf, int, 1469_GL_FUNCDECL_SYS (vasprintf, int,
1140 (char **result, const char *format, va_list args) 1470 (char **result, const char *format, va_list args)
1141 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1471 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1142 _GL_ARG_NONNULL ((1, 2))); 1472 _GL_ARG_NONNULL ((1, 2)));
1143# endif 1473# endif
1144_GL_CXXALIAS_SYS (vasprintf, int, 1474_GL_CXXALIAS_SYS (vasprintf, int,
@@ -1152,22 +1482,27 @@ _GL_CXXALIASWARN (vasprintf);
1152# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1482# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1153# define vdprintf rpl_vdprintf 1483# define vdprintf rpl_vdprintf
1154# endif 1484# endif
1155_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) 1485_GL_FUNCDECL_RPL (vdprintf, int,
1156 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1486 (int fd, const char *restrict format, va_list args)
1157 _GL_ARG_NONNULL ((2))); 1487 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1158_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); 1488 _GL_ARG_NONNULL ((2)));
1489_GL_CXXALIAS_RPL (vdprintf, int,
1490 (int fd, const char *restrict format, va_list args));
1159# else 1491# else
1160# if !@HAVE_VDPRINTF@ 1492# if !@HAVE_VDPRINTF@
1161_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) 1493_GL_FUNCDECL_SYS (vdprintf, int,
1162 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1494 (int fd, const char *restrict format, va_list args)
1163 _GL_ARG_NONNULL ((2))); 1495 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1496 _GL_ARG_NONNULL ((2)));
1164# endif 1497# endif
1165/* Need to cast, because on Solaris, the third parameter will likely be 1498/* Need to cast, because on Solaris, the third parameter will likely be
1166 __va_list args. */ 1499 __va_list args. */
1167_GL_CXXALIAS_SYS_CAST (vdprintf, int, 1500_GL_CXXALIAS_SYS_CAST (vdprintf, int,
1168 (int fd, const char *format, va_list args)); 1501 (int fd, const char *restrict format, va_list args));
1169# endif 1502# endif
1503# if __GLIBC__ >= 2
1170_GL_CXXALIASWARN (vdprintf); 1504_GL_CXXALIASWARN (vdprintf);
1505# endif
1171#elif defined GNULIB_POSIXCHECK 1506#elif defined GNULIB_POSIXCHECK
1172# undef vdprintf 1507# undef vdprintf
1173# if HAVE_RAW_DECL_VDPRINTF 1508# if HAVE_RAW_DECL_VDPRINTF
@@ -1184,23 +1519,32 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1184# endif 1519# endif
1185# define GNULIB_overrides_vfprintf 1 1520# define GNULIB_overrides_vfprintf 1
1186# if @GNULIB_VFPRINTF_POSIX@ 1521# if @GNULIB_VFPRINTF_POSIX@
1187_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 1522_GL_FUNCDECL_RPL (vfprintf, int,
1188 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1523 (FILE *restrict fp,
1189 _GL_ARG_NONNULL ((1, 2))); 1524 const char *restrict format, va_list args)
1525 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1526 _GL_ARG_NONNULL ((1, 2)));
1190# else 1527# else
1191_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 1528_GL_FUNCDECL_RPL (vfprintf, int,
1192 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) 1529 (FILE *restrict fp,
1193 _GL_ARG_NONNULL ((1, 2))); 1530 const char *restrict format, va_list args)
1531 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1532 _GL_ARG_NONNULL ((1, 2)));
1194# endif 1533# endif
1195_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); 1534_GL_CXXALIAS_RPL (vfprintf, int,
1535 (FILE *restrict fp,
1536 const char *restrict format, va_list args));
1196# else 1537# else
1197/* Need to cast, because on Solaris, the third parameter is 1538/* Need to cast, because on Solaris, the third parameter is
1198 __va_list args 1539 __va_list args
1199 and GCC's fixincludes did not change this to __gnuc_va_list. */ 1540 and GCC's fixincludes did not change this to __gnuc_va_list. */
1200_GL_CXXALIAS_SYS_CAST (vfprintf, int, 1541_GL_CXXALIAS_SYS_CAST (vfprintf, int,
1201 (FILE *fp, const char *format, va_list args)); 1542 (FILE *restrict fp,
1543 const char *restrict format, va_list args));
1202# endif 1544# endif
1545# if __GLIBC__ >= 2
1203_GL_CXXALIASWARN (vfprintf); 1546_GL_CXXALIASWARN (vfprintf);
1547# endif
1204#endif 1548#endif
1205#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1549#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1206# if !GNULIB_overrides_vfprintf 1550# if !GNULIB_overrides_vfprintf
@@ -1219,16 +1563,21 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1219# define vfscanf rpl_vfscanf 1563# define vfscanf rpl_vfscanf
1220# endif 1564# endif
1221_GL_FUNCDECL_RPL (vfscanf, int, 1565_GL_FUNCDECL_RPL (vfscanf, int,
1222 (FILE *stream, const char *format, va_list args) 1566 (FILE *restrict stream,
1567 const char *restrict format, va_list args)
1223 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) 1568 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1224 _GL_ARG_NONNULL ((1, 2))); 1569 _GL_ARG_NONNULL ((1, 2)));
1225_GL_CXXALIAS_RPL (vfscanf, int, 1570_GL_CXXALIAS_RPL (vfscanf, int,
1226 (FILE *stream, const char *format, va_list args)); 1571 (FILE *restrict stream,
1572 const char *restrict format, va_list args));
1227# else 1573# else
1228_GL_CXXALIAS_SYS (vfscanf, int, 1574_GL_CXXALIAS_SYS (vfscanf, int,
1229 (FILE *stream, const char *format, va_list args)); 1575 (FILE *restrict stream,
1576 const char *restrict format, va_list args));
1230# endif 1577# endif
1578# if __GLIBC__ >= 2
1231_GL_CXXALIASWARN (vfscanf); 1579_GL_CXXALIASWARN (vfscanf);
1580# endif
1232#endif 1581#endif
1233 1582
1234#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ 1583#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
@@ -1239,22 +1588,25 @@ _GL_CXXALIASWARN (vfscanf);
1239# endif 1588# endif
1240# define GNULIB_overrides_vprintf 1 1589# define GNULIB_overrides_vprintf 1
1241# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 1590# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1242_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 1591_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1243 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0) 1592 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1244 _GL_ARG_NONNULL ((1))); 1593 _GL_ARG_NONNULL ((1)));
1245# else 1594# else
1246_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 1595_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1247 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) 1596 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1248 _GL_ARG_NONNULL ((1))); 1597 _GL_ARG_NONNULL ((1)));
1249# endif 1598# endif
1250_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); 1599_GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args));
1251# else 1600# else
1252/* Need to cast, because on Solaris, the second parameter is 1601/* Need to cast, because on Solaris, the second parameter is
1253 __va_list args 1602 __va_list args
1254 and GCC's fixincludes did not change this to __gnuc_va_list. */ 1603 and GCC's fixincludes did not change this to __gnuc_va_list. */
1255_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); 1604_GL_CXXALIAS_SYS_CAST (vprintf, int,
1605 (const char *restrict format, va_list args));
1256# endif 1606# endif
1607# if __GLIBC__ >= 2
1257_GL_CXXALIASWARN (vprintf); 1608_GL_CXXALIASWARN (vprintf);
1609# endif
1258#endif 1610#endif
1259#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1611#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1260# if !GNULIB_overrides_vprintf 1612# if !GNULIB_overrides_vprintf
@@ -1272,14 +1624,16 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1272# undef vscanf 1624# undef vscanf
1273# define vscanf rpl_vscanf 1625# define vscanf rpl_vscanf
1274# endif 1626# endif
1275_GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args) 1627_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args)
1276 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) 1628 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1277 _GL_ARG_NONNULL ((1))); 1629 _GL_ARG_NONNULL ((1)));
1278_GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args)); 1630_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
1279# else 1631# else
1280_GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args)); 1632_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
1281# endif 1633# endif
1634# if __GLIBC__ >= 2
1282_GL_CXXALIASWARN (vscanf); 1635_GL_CXXALIASWARN (vscanf);
1636# endif
1283#endif 1637#endif
1284 1638
1285#if @GNULIB_VSNPRINTF@ 1639#if @GNULIB_VSNPRINTF@
@@ -1287,23 +1641,30 @@ _GL_CXXALIASWARN (vscanf);
1287# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1641# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1288# define vsnprintf rpl_vsnprintf 1642# define vsnprintf rpl_vsnprintf
1289# endif 1643# endif
1644# define GNULIB_overrides_vsnprintf 1
1290_GL_FUNCDECL_RPL (vsnprintf, int, 1645_GL_FUNCDECL_RPL (vsnprintf, int,
1291 (char *str, size_t size, const char *format, va_list args) 1646 (char *restrict str, size_t size,
1292 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) 1647 const char *restrict format, va_list args)
1648 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1293 _GL_ARG_NONNULL ((3))); 1649 _GL_ARG_NONNULL ((3)));
1294_GL_CXXALIAS_RPL (vsnprintf, int, 1650_GL_CXXALIAS_RPL (vsnprintf, int,
1295 (char *str, size_t size, const char *format, va_list args)); 1651 (char *restrict str, size_t size,
1652 const char *restrict format, va_list args));
1296# else 1653# else
1297# if !@HAVE_DECL_VSNPRINTF@ 1654# if !@HAVE_DECL_VSNPRINTF@
1298_GL_FUNCDECL_SYS (vsnprintf, int, 1655_GL_FUNCDECL_SYS (vsnprintf, int,
1299 (char *str, size_t size, const char *format, va_list args) 1656 (char *restrict str, size_t size,
1300 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) 1657 const char *restrict format, va_list args)
1658 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1301 _GL_ARG_NONNULL ((3))); 1659 _GL_ARG_NONNULL ((3)));
1302# endif 1660# endif
1303_GL_CXXALIAS_SYS (vsnprintf, int, 1661_GL_CXXALIAS_SYS (vsnprintf, int,
1304 (char *str, size_t size, const char *format, va_list args)); 1662 (char *restrict str, size_t size,
1663 const char *restrict format, va_list args));
1305# endif 1664# endif
1665# if __GLIBC__ >= 2
1306_GL_CXXALIASWARN (vsnprintf); 1666_GL_CXXALIASWARN (vsnprintf);
1667# endif
1307#elif defined GNULIB_POSIXCHECK 1668#elif defined GNULIB_POSIXCHECK
1308# undef vsnprintf 1669# undef vsnprintf
1309# if HAVE_RAW_DECL_VSNPRINTF 1670# if HAVE_RAW_DECL_VSNPRINTF
@@ -1317,20 +1678,26 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1317# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1678# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1318# define vsprintf rpl_vsprintf 1679# define vsprintf rpl_vsprintf
1319# endif 1680# endif
1681# define GNULIB_overrides_vsprintf 1
1320_GL_FUNCDECL_RPL (vsprintf, int, 1682_GL_FUNCDECL_RPL (vsprintf, int,
1321 (char *str, const char *format, va_list args) 1683 (char *restrict str,
1322 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1684 const char *restrict format, va_list args)
1685 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1323 _GL_ARG_NONNULL ((1, 2))); 1686 _GL_ARG_NONNULL ((1, 2)));
1324_GL_CXXALIAS_RPL (vsprintf, int, 1687_GL_CXXALIAS_RPL (vsprintf, int,
1325 (char *str, const char *format, va_list args)); 1688 (char *restrict str,
1689 const char *restrict format, va_list args));
1326# else 1690# else
1327/* Need to cast, because on Solaris, the third parameter is 1691/* Need to cast, because on Solaris, the third parameter is
1328 __va_list args 1692 __va_list args
1329 and GCC's fixincludes did not change this to __gnuc_va_list. */ 1693 and GCC's fixincludes did not change this to __gnuc_va_list. */
1330_GL_CXXALIAS_SYS_CAST (vsprintf, int, 1694_GL_CXXALIAS_SYS_CAST (vsprintf, int,
1331 (char *str, const char *format, va_list args)); 1695 (char *restrict str,
1696 const char *restrict format, va_list args));
1332# endif 1697# endif
1698# if __GLIBC__ >= 2
1333_GL_CXXALIASWARN (vsprintf); 1699_GL_CXXALIASWARN (vsprintf);
1700# endif
1334#elif defined GNULIB_POSIXCHECK 1701#elif defined GNULIB_POSIXCHECK
1335# undef vsprintf 1702# undef vsprintf
1336/* Assume vsprintf is always declared. */ 1703/* Assume vsprintf is always declared. */
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index c9552480..b79e5f70 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
@@ -47,11 +47,14 @@
47 47
48/* Solaris declares getloadavg() in <sys/loadavg.h>. */ 48/* Solaris declares getloadavg() in <sys/loadavg.h>. */
49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ 49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
50/* OpenIndiana has a bug: <sys/time.h> must be included before
51 <sys/loadavg.h>. */
52# include <sys/time.h>
50# include <sys/loadavg.h> 53# include <sys/loadavg.h>
51#endif 54#endif
52 55
53/* Native Windows platforms declare mktemp() in <io.h>. */ 56/* Native Windows platforms declare _mktemp() in <io.h>. */
54#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 57#if defined _WIN32 && !defined __CYGWIN__
55# include <io.h> 58# include <io.h>
56#endif 59#endif
57 60
@@ -87,20 +90,52 @@ struct random_data
87# endif 90# endif
88#endif 91#endif
89 92
90#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 93#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
91/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */ 94/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
92/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */ 95/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
96/* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
93/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ 97/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
94/* But avoid namespace pollution on glibc systems and native Windows. */ 98/* But avoid namespace pollution on glibc systems and native Windows. */
95# include <unistd.h> 99# include <unistd.h>
96#endif 100#endif
97 101
102/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
103 that can be freed by passing them as the Ith argument to the
104 function F. */
105#ifndef _GL_ATTRIBUTE_DEALLOC
106# if __GNUC__ >= 11
107# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
108# else
109# define _GL_ATTRIBUTE_DEALLOC(f, i)
110# endif
111#endif
112
113/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
114 can be freed via 'free'; it can be used only after declaring 'free'. */
115/* Applies to: functions. Cannot be used on inline functions. */
116#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
117# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
118#endif
119
120/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
121 allocated memory. */
122/* Applies to: functions. */
123#ifndef _GL_ATTRIBUTE_MALLOC
124# if __GNUC__ >= 3 || defined __clang__
125# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
126# else
127# define _GL_ATTRIBUTE_MALLOC
128# endif
129#endif
130
98/* The __attribute__ feature is available in gcc versions 2.5 and later. 131/* The __attribute__ feature is available in gcc versions 2.5 and later.
99 The attribute __pure__ was added in gcc 2.96. */ 132 The attribute __pure__ was added in gcc 2.96. */
100#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 133#ifndef _GL_ATTRIBUTE_PURE
101# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 134# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
102#else 135# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
103# define _GL_ATTRIBUTE_PURE /* empty */ 136# else
137# define _GL_ATTRIBUTE_PURE /* empty */
138# endif
104#endif 139#endif
105 140
106/* The definition of _Noreturn is copied here. */ 141/* The definition of _Noreturn is copied here. */
@@ -143,6 +178,73 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
143#endif 178#endif
144 179
145 180
181#if @GNULIB_FREE_POSIX@
182# if @REPLACE_FREE@
183# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184# undef free
185# define free rpl_free
186# endif
187# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
188_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ());
189# else
190_GL_FUNCDECL_RPL (free, void, (void *ptr));
191# endif
192_GL_CXXALIAS_RPL (free, void, (void *ptr));
193# else
194_GL_CXXALIAS_SYS (free, void, (void *ptr));
195# endif
196# if __GLIBC__ >= 2
197_GL_CXXALIASWARN (free);
198# endif
199#elif defined GNULIB_POSIXCHECK
200# undef free
201/* Assume free is always declared. */
202_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - "
203 "use gnulib module free for portability");
204#endif
205
206
207/* Allocate memory with indefinite extent and specified alignment. */
208#if @GNULIB_ALIGNED_ALLOC@
209# if @REPLACE_ALIGNED_ALLOC@
210# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
211# undef aligned_alloc
212# define aligned_alloc rpl_aligned_alloc
213# endif
214_GL_FUNCDECL_RPL (aligned_alloc, void *,
215 (size_t alignment, size_t size)
216 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
217_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
218# else
219# if @HAVE_ALIGNED_ALLOC@
220# if __GNUC__ >= 11
221/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
222_GL_FUNCDECL_SYS (aligned_alloc, void *,
223 (size_t alignment, size_t size)
224 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
225# endif
226_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
227# endif
228# endif
229# if (__GLIBC__ >= 2) && @HAVE_ALIGNED_ALLOC@
230_GL_CXXALIASWARN (aligned_alloc);
231# endif
232#else
233# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc
234/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
235_GL_FUNCDECL_SYS (aligned_alloc, void *,
236 (size_t alignment, size_t size)
237 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
238# endif
239# if defined GNULIB_POSIXCHECK
240# undef aligned_alloc
241# if HAVE_RAW_DECL_ALIGNED_ALLOC
242_GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
243 "use gnulib module aligned_alloc for portability");
244# endif
245# endif
246#endif
247
146#if @GNULIB_ATOLL@ 248#if @GNULIB_ATOLL@
147/* Parse a signed decimal integer. 249/* Parse a signed decimal integer.
148 Returns the value of the integer. Errors are not detected. */ 250 Returns the value of the integer. Errors are not detected. */
@@ -162,22 +264,41 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
162#endif 264#endif
163 265
164#if @GNULIB_CALLOC_POSIX@ 266#if @GNULIB_CALLOC_POSIX@
165# if @REPLACE_CALLOC@ 267# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \
268 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
166# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 269# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
167# undef calloc 270# undef calloc
168# define calloc rpl_calloc 271# define calloc rpl_calloc
169# endif 272# endif
170_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size)); 273_GL_FUNCDECL_RPL (calloc, void *,
274 (size_t nmemb, size_t size)
275 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
171_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); 276_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
172# else 277# else
278# if __GNUC__ >= 11
279/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
280_GL_FUNCDECL_SYS (calloc, void *,
281 (size_t nmemb, size_t size)
282 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
283# endif
173_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); 284_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
174# endif 285# endif
286# if __GLIBC__ >= 2
175_GL_CXXALIASWARN (calloc); 287_GL_CXXALIASWARN (calloc);
176#elif defined GNULIB_POSIXCHECK 288# endif
177# undef calloc 289#else
290# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc
291/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
292_GL_FUNCDECL_SYS (calloc, void *,
293 (size_t nmemb, size_t size)
294 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
295# endif
296# if defined GNULIB_POSIXCHECK
297# undef calloc
178/* Assume calloc is always declared. */ 298/* Assume calloc is always declared. */
179_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " 299_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
180 "use gnulib module calloc-posix for portability"); 300 "use gnulib module calloc-posix for portability");
301# endif
181#endif 302#endif
182 303
183#if @GNULIB_CANONICALIZE_FILE_NAME@ 304#if @GNULIB_CANONICALIZE_FILE_NAME@
@@ -185,23 +306,108 @@ _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
185# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 306# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
186# define canonicalize_file_name rpl_canonicalize_file_name 307# define canonicalize_file_name rpl_canonicalize_file_name
187# endif 308# endif
188_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name) 309_GL_FUNCDECL_RPL (canonicalize_file_name, char *,
189 _GL_ARG_NONNULL ((1))); 310 (const char *name)
311 _GL_ARG_NONNULL ((1))
312 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
190_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); 313_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
191# else 314# else
192# if !@HAVE_CANONICALIZE_FILE_NAME@ 315# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11
193_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) 316_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
194 _GL_ARG_NONNULL ((1))); 317 (const char *name)
318 _GL_ARG_NONNULL ((1))
319 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
195# endif 320# endif
196_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); 321_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
197# endif 322# endif
323# ifndef GNULIB_defined_canonicalize_file_name
324# define GNULIB_defined_canonicalize_file_name \
325 (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@)
326# endif
198_GL_CXXALIASWARN (canonicalize_file_name); 327_GL_CXXALIASWARN (canonicalize_file_name);
199#elif defined GNULIB_POSIXCHECK 328#else
200# undef canonicalize_file_name 329# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name
201# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME 330/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
331 rpl_free. */
332_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
333 (const char *name)
334 _GL_ARG_NONNULL ((1))
335 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
336# endif
337# if defined GNULIB_POSIXCHECK
338# undef canonicalize_file_name
339# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
202_GL_WARN_ON_USE (canonicalize_file_name, 340_GL_WARN_ON_USE (canonicalize_file_name,
203 "canonicalize_file_name is unportable - " 341 "canonicalize_file_name is unportable - "
204 "use gnulib module canonicalize-lgpl for portability"); 342 "use gnulib module canonicalize-lgpl for portability");
343# endif
344# endif
345#endif
346
347#if @GNULIB_MDA_ECVT@
348/* On native Windows, map 'ecvt' to '_ecvt', so that -loldnames is not
349 required. In C++ with GNULIB_NAMESPACE, avoid differences between
350 platforms by defining GNULIB_NAMESPACE::ecvt on all platforms that have
351 it. */
352# if defined _WIN32 && !defined __CYGWIN__
353# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
354# undef ecvt
355# define ecvt _ecvt
356# endif
357_GL_CXXALIAS_MDA (ecvt, char *,
358 (double number, int ndigits, int *decptp, int *signp));
359# else
360# if @HAVE_DECL_ECVT@
361_GL_CXXALIAS_SYS (ecvt, char *,
362 (double number, int ndigits, int *decptp, int *signp));
363# endif
364# endif
365# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_ECVT@
366_GL_CXXALIASWARN (ecvt);
367# endif
368#endif
369
370#if @GNULIB_MDA_FCVT@
371/* On native Windows, map 'fcvt' to '_fcvt', so that -loldnames is not
372 required. In C++ with GNULIB_NAMESPACE, avoid differences between
373 platforms by defining GNULIB_NAMESPACE::fcvt on all platforms that have
374 it. */
375# if defined _WIN32 && !defined __CYGWIN__
376# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
377# undef fcvt
378# define fcvt _fcvt
379# endif
380_GL_CXXALIAS_MDA (fcvt, char *,
381 (double number, int ndigits, int *decptp, int *signp));
382# else
383# if @HAVE_DECL_FCVT@
384_GL_CXXALIAS_SYS (fcvt, char *,
385 (double number, int ndigits, int *decptp, int *signp));
386# endif
387# endif
388# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCVT@
389_GL_CXXALIASWARN (fcvt);
390# endif
391#endif
392
393#if @GNULIB_MDA_GCVT@
394/* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not
395 required. In C++ with GNULIB_NAMESPACE, avoid differences between
396 platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have
397 it. */
398# if defined _WIN32 && !defined __CYGWIN__
399# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
400# undef gcvt
401# define gcvt _gcvt
402# endif
403_GL_CXXALIAS_MDA (gcvt, char *, (double number, int ndigits, char *buf));
404# else
405# if @HAVE_DECL_GCVT@
406_GL_CXXALIAS_SYS (gcvt, char *, (double number, int ndigits, char *buf));
407# endif
408# endif
409# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_GCVT@
410_GL_CXXALIASWARN (gcvt);
205# endif 411# endif
206#endif 412#endif
207 413
@@ -234,8 +440,8 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
234 element (or NULL if it doesn't contain an "=" sign), 440 element (or NULL if it doesn't contain an "=" sign),
235 - It returns the index of the "token" in the given array of tokens. 441 - It returns the index of the "token" in the given array of tokens.
236 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. 442 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
237 For more details see the POSIX:2001 specification. 443 For more details see the POSIX specification.
238 http://www.opengroup.org/susv3xsh/getsubopt.html */ 444 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
239# if !@HAVE_GETSUBOPT@ 445# if !@HAVE_GETSUBOPT@
240_GL_FUNCDECL_SYS (getsubopt, int, 446_GL_FUNCDECL_SYS (getsubopt, int,
241 (char **optionp, char *const *tokens, char **valuep) 447 (char **optionp, char *const *tokens, char **valuep)
@@ -273,23 +479,42 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
273 by never specifying a zero size), so it does not need malloc or 479 by never specifying a zero size), so it does not need malloc or
274 realloc to be redefined. */ 480 realloc to be redefined. */
275#if @GNULIB_MALLOC_POSIX@ 481#if @GNULIB_MALLOC_POSIX@
276# if @REPLACE_MALLOC@ 482# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \
483 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
277# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 484# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
278 || _GL_USE_STDLIB_ALLOC) 485 || _GL_USE_STDLIB_ALLOC)
279# undef malloc 486# undef malloc
280# define malloc rpl_malloc 487# define malloc rpl_malloc
281# endif 488# endif
282_GL_FUNCDECL_RPL (malloc, void *, (size_t size)); 489_GL_FUNCDECL_RPL (malloc, void *,
490 (size_t size)
491 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
283_GL_CXXALIAS_RPL (malloc, void *, (size_t size)); 492_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
284# else 493# else
494# if __GNUC__ >= 11
495/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
496_GL_FUNCDECL_SYS (malloc, void *,
497 (size_t size)
498 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
499# endif
285_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); 500_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
286# endif 501# endif
502# if __GLIBC__ >= 2
287_GL_CXXALIASWARN (malloc); 503_GL_CXXALIASWARN (malloc);
288#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 504# endif
289# undef malloc 505#else
506# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc
507/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
508_GL_FUNCDECL_SYS (malloc, void *,
509 (size_t size)
510 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
511# endif
512# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
513# undef malloc
290/* Assume malloc is always declared. */ 514/* Assume malloc is always declared. */
291_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " 515_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
292 "use gnulib module malloc-posix for portability"); 516 "use gnulib module malloc-posix for portability");
517# endif
293#endif 518#endif
294 519
295/* Convert a multibyte character to a wide character. */ 520/* Convert a multibyte character to a wide character. */
@@ -299,12 +524,27 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
299# undef mbtowc 524# undef mbtowc
300# define mbtowc rpl_mbtowc 525# define mbtowc rpl_mbtowc
301# endif 526# endif
302_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); 527_GL_FUNCDECL_RPL (mbtowc, int,
303_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); 528 (wchar_t *restrict pwc, const char *restrict s, size_t n));
529_GL_CXXALIAS_RPL (mbtowc, int,
530 (wchar_t *restrict pwc, const char *restrict s, size_t n));
304# else 531# else
305_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); 532# if !@HAVE_MBTOWC@
533_GL_FUNCDECL_SYS (mbtowc, int,
534 (wchar_t *restrict pwc, const char *restrict s, size_t n));
535# endif
536_GL_CXXALIAS_SYS (mbtowc, int,
537 (wchar_t *restrict pwc, const char *restrict s, size_t n));
306# endif 538# endif
539# if __GLIBC__ >= 2
307_GL_CXXALIASWARN (mbtowc); 540_GL_CXXALIASWARN (mbtowc);
541# endif
542#elif defined GNULIB_POSIXCHECK
543# undef mbtowc
544# if HAVE_RAW_DECL_MBTOWC
545_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
546 "use gnulib module mbtowc for portability");
547# endif
308#endif 548#endif
309 549
310#if @GNULIB_MKDTEMP@ 550#if @GNULIB_MKDTEMP@
@@ -439,6 +679,51 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
439# endif 679# endif
440#endif 680#endif
441 681
682#if @GNULIB_MDA_MKTEMP@
683/* On native Windows, map 'mktemp' to '_mktemp', so that -loldnames is not
684 required. In C++ with GNULIB_NAMESPACE, avoid differences between
685 platforms by defining GNULIB_NAMESPACE::mktemp always. */
686# if defined _WIN32 && !defined __CYGWIN__
687# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
688# undef mktemp
689# define mktemp _mktemp
690# endif
691_GL_CXXALIAS_MDA (mktemp, char *, (char * /*template*/));
692# else
693_GL_CXXALIAS_SYS (mktemp, char *, (char * /*template*/));
694# endif
695_GL_CXXALIASWARN (mktemp);
696#endif
697
698/* Allocate memory with indefinite extent and specified alignment. */
699#if @GNULIB_POSIX_MEMALIGN@
700# if @REPLACE_POSIX_MEMALIGN@
701# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
702# undef posix_memalign
703# define posix_memalign rpl_posix_memalign
704# endif
705_GL_FUNCDECL_RPL (posix_memalign, int,
706 (void **memptr, size_t alignment, size_t size)
707 _GL_ARG_NONNULL ((1)));
708_GL_CXXALIAS_RPL (posix_memalign, int,
709 (void **memptr, size_t alignment, size_t size));
710# else
711# if @HAVE_POSIX_MEMALIGN@
712_GL_CXXALIAS_SYS (posix_memalign, int,
713 (void **memptr, size_t alignment, size_t size));
714# endif
715# endif
716# if @HAVE_POSIX_MEMALIGN@
717_GL_CXXALIASWARN (posix_memalign);
718# endif
719#elif defined GNULIB_POSIXCHECK
720# undef posix_memalign
721# if HAVE_RAW_DECL_POSIX_MEMALIGN
722_GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
723 "use gnulib module posix_memalign for portability");
724# endif
725#endif
726
442#if @GNULIB_POSIX_OPENPT@ 727#if @GNULIB_POSIX_OPENPT@
443/* Return an FD open to the master side of a pseudo-terminal. Flags should 728/* Return an FD open to the master side of a pseudo-terminal. Flags should
444 include O_RDWR, and may also include O_NOCTTY. */ 729 include O_RDWR, and may also include O_NOCTTY. */
@@ -497,6 +782,9 @@ _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
497# endif 782# endif
498_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); 783_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
499# endif 784# endif
785# ifndef GNULIB_defined_ptsname_r
786# define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@)
787# endif
500_GL_CXXALIASWARN (ptsname_r); 788_GL_CXXALIASWARN (ptsname_r);
501#elif defined GNULIB_POSIXCHECK 789#elif defined GNULIB_POSIXCHECK
502# undef ptsname_r 790# undef ptsname_r
@@ -514,12 +802,78 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
514# endif 802# endif
515_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); 803_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
516_GL_CXXALIAS_RPL (putenv, int, (char *string)); 804_GL_CXXALIAS_RPL (putenv, int, (char *string));
805# elif defined _WIN32 && !defined __CYGWIN__
806# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
807# undef putenv
808# define putenv _putenv
809# endif
810_GL_CXXALIAS_MDA (putenv, int, (char *string));
811# else
812_GL_CXXALIAS_SYS (putenv, int, (char *string));
813# endif
814_GL_CXXALIASWARN (putenv);
815#elif @GNULIB_MDA_PUTENV@
816/* On native Windows, map 'putenv' to '_putenv', so that -loldnames is not
817 required. In C++ with GNULIB_NAMESPACE, avoid differences between
818 platforms by defining GNULIB_NAMESPACE::putenv always. */
819# if defined _WIN32 && !defined __CYGWIN__
820# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
821# undef putenv
822# define putenv _putenv
823# endif
824/* Need to cast, because on mingw, the parameter is either
825 'const char *string' or 'char *string'. */
826_GL_CXXALIAS_MDA_CAST (putenv, int, (char *string));
517# else 827# else
518_GL_CXXALIAS_SYS (putenv, int, (char *string)); 828_GL_CXXALIAS_SYS (putenv, int, (char *string));
519# endif 829# endif
520_GL_CXXALIASWARN (putenv); 830_GL_CXXALIASWARN (putenv);
521#endif 831#endif
522 832
833#if @GNULIB_QSORT_R@
834/* Sort an array of NMEMB elements, starting at address BASE, each element
835 occupying SIZE bytes, in ascending order according to the comparison
836 function COMPARE. */
837# ifdef __cplusplus
838extern "C" {
839# endif
840# if !GNULIB_defined_qsort_r_fn_types
841typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *);
842# define GNULIB_defined_qsort_r_fn_types 1
843# endif
844# ifdef __cplusplus
845}
846# endif
847# if @REPLACE_QSORT_R@
848# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
849# undef qsort_r
850# define qsort_r rpl_qsort_r
851# endif
852_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
853 _gl_qsort_r_compar_fn compare,
854 void *arg) _GL_ARG_NONNULL ((1, 4)));
855_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
856 _gl_qsort_r_compar_fn compare,
857 void *arg));
858# else
859# if !@HAVE_QSORT_R@
860_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
861 _gl_qsort_r_compar_fn compare,
862 void *arg) _GL_ARG_NONNULL ((1, 4)));
863# endif
864_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
865 _gl_qsort_r_compar_fn compare,
866 void *arg));
867# endif
868_GL_CXXALIASWARN (qsort_r);
869#elif defined GNULIB_POSIXCHECK
870# undef qsort_r
871# if HAVE_RAW_DECL_QSORT_R
872_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
873 "use gnulib module qsort_r for portability");
874# endif
875#endif
876
523 877
524#if @GNULIB_RANDOM_R@ 878#if @GNULIB_RANDOM_R@
525# if !@HAVE_RANDOM_R@ 879# if !@HAVE_RANDOM_R@
@@ -531,10 +885,21 @@ _GL_CXXALIASWARN (putenv);
531 885
532 886
533#if @GNULIB_RANDOM@ 887#if @GNULIB_RANDOM@
534# if !@HAVE_RANDOM@ 888# if @REPLACE_RANDOM@
889# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
890# undef random
891# define random rpl_random
892# endif
893_GL_FUNCDECL_RPL (random, long, (void));
894_GL_CXXALIAS_RPL (random, long, (void));
895# else
896# if !@HAVE_RANDOM@
535_GL_FUNCDECL_SYS (random, long, (void)); 897_GL_FUNCDECL_SYS (random, long, (void));
898# endif
899/* Need to cast, because on Haiku, the return type is
900 int. */
901_GL_CXXALIAS_SYS_CAST (random, long, (void));
536# endif 902# endif
537_GL_CXXALIAS_SYS (random, long, (void));
538_GL_CXXALIASWARN (random); 903_GL_CXXALIASWARN (random);
539#elif defined GNULIB_POSIXCHECK 904#elif defined GNULIB_POSIXCHECK
540# undef random 905# undef random
@@ -545,10 +910,21 @@ _GL_WARN_ON_USE (random, "random is unportable - "
545#endif 910#endif
546 911
547#if @GNULIB_RANDOM@ 912#if @GNULIB_RANDOM@
548# if !@HAVE_RANDOM@ 913# if @REPLACE_RANDOM@
914# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
915# undef srandom
916# define srandom rpl_srandom
917# endif
918_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed));
919_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
920# else
921# if !@HAVE_RANDOM@
549_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); 922_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
923# endif
924/* Need to cast, because on FreeBSD, the first parameter is
925 unsigned long seed. */
926_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
550# endif 927# endif
551_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
552_GL_CXXALIASWARN (srandom); 928_GL_CXXALIASWARN (srandom);
553#elif defined GNULIB_POSIXCHECK 929#elif defined GNULIB_POSIXCHECK
554# undef srandom 930# undef srandom
@@ -559,31 +935,56 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - "
559#endif 935#endif
560 936
561#if @GNULIB_RANDOM@ 937#if @GNULIB_RANDOM@
562# if !@HAVE_RANDOM@ 938# if @REPLACE_INITSTATE@
939# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
940# undef initstate
941# define initstate rpl_initstate
942# endif
943_GL_FUNCDECL_RPL (initstate, char *,
944 (unsigned int seed, char *buf, size_t buf_size)
945 _GL_ARG_NONNULL ((2)));
946_GL_CXXALIAS_RPL (initstate, char *,
947 (unsigned int seed, char *buf, size_t buf_size));
948# else
949# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
563_GL_FUNCDECL_SYS (initstate, char *, 950_GL_FUNCDECL_SYS (initstate, char *,
564 (unsigned int seed, char *buf, size_t buf_size) 951 (unsigned int seed, char *buf, size_t buf_size)
565 _GL_ARG_NONNULL ((2))); 952 _GL_ARG_NONNULL ((2)));
953# endif
954/* Need to cast, because on FreeBSD, the first parameter is
955 unsigned long seed. */
956_GL_CXXALIAS_SYS_CAST (initstate, char *,
957 (unsigned int seed, char *buf, size_t buf_size));
566# endif 958# endif
567_GL_CXXALIAS_SYS (initstate, char *,
568 (unsigned int seed, char *buf, size_t buf_size));
569_GL_CXXALIASWARN (initstate); 959_GL_CXXALIASWARN (initstate);
570#elif defined GNULIB_POSIXCHECK 960#elif defined GNULIB_POSIXCHECK
571# undef initstate 961# undef initstate
572# if HAVE_RAW_DECL_INITSTATE_R 962# if HAVE_RAW_DECL_INITSTATE
573_GL_WARN_ON_USE (initstate, "initstate is unportable - " 963_GL_WARN_ON_USE (initstate, "initstate is unportable - "
574 "use gnulib module random for portability"); 964 "use gnulib module random for portability");
575# endif 965# endif
576#endif 966#endif
577 967
578#if @GNULIB_RANDOM@ 968#if @GNULIB_RANDOM@
579# if !@HAVE_RANDOM@ 969# if @REPLACE_SETSTATE@
970# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
971# undef setstate
972# define setstate rpl_setstate
973# endif
974_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
975_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
976# else
977# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
580_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); 978_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
979# endif
980/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
981 is const char *arg_state. */
982_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
581# endif 983# endif
582_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
583_GL_CXXALIASWARN (setstate); 984_GL_CXXALIASWARN (setstate);
584#elif defined GNULIB_POSIXCHECK 985#elif defined GNULIB_POSIXCHECK
585# undef setstate 986# undef setstate
586# if HAVE_RAW_DECL_SETSTATE_R 987# if HAVE_RAW_DECL_SETSTATE
587_GL_WARN_ON_USE (setstate, "setstate is unportable - " 988_GL_WARN_ON_USE (setstate, "setstate is unportable - "
588 "use gnulib module random for portability"); 989 "use gnulib module random for portability");
589# endif 990# endif
@@ -664,9 +1065,11 @@ _GL_FUNCDECL_SYS (initstate_r, int,
664 struct random_data *rand_state) 1065 struct random_data *rand_state)
665 _GL_ARG_NONNULL ((2, 4))); 1066 _GL_ARG_NONNULL ((2, 4)));
666# endif 1067# endif
667_GL_CXXALIAS_SYS (initstate_r, int, 1068/* Need to cast, because on Haiku, the third parameter is
668 (unsigned int seed, char *buf, size_t buf_size, 1069 unsigned long buf_size. */
669 struct random_data *rand_state)); 1070_GL_CXXALIAS_SYS_CAST (initstate_r, int,
1071 (unsigned int seed, char *buf, size_t buf_size,
1072 struct random_data *rand_state));
670# endif 1073# endif
671_GL_CXXALIASWARN (initstate_r); 1074_GL_CXXALIASWARN (initstate_r);
672#elif defined GNULIB_POSIXCHECK 1075#elif defined GNULIB_POSIXCHECK
@@ -694,8 +1097,10 @@ _GL_FUNCDECL_SYS (setstate_r, int,
694 (char *arg_state, struct random_data *rand_state) 1097 (char *arg_state, struct random_data *rand_state)
695 _GL_ARG_NONNULL ((1, 2))); 1098 _GL_ARG_NONNULL ((1, 2)));
696# endif 1099# endif
697_GL_CXXALIAS_SYS (setstate_r, int, 1100/* Need to cast, because on Haiku, the first parameter is
698 (char *arg_state, struct random_data *rand_state)); 1101 void *arg_state. */
1102_GL_CXXALIAS_SYS_CAST (setstate_r, int,
1103 (char *arg_state, struct random_data *rand_state));
699# endif 1104# endif
700_GL_CXXALIASWARN (setstate_r); 1105_GL_CXXALIASWARN (setstate_r);
701#elif defined GNULIB_POSIXCHECK 1106#elif defined GNULIB_POSIXCHECK
@@ -708,23 +1113,67 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
708 1113
709 1114
710#if @GNULIB_REALLOC_POSIX@ 1115#if @GNULIB_REALLOC_POSIX@
711# if @REPLACE_REALLOC@ 1116# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \
1117 || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@)
712# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 1118# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
713 || _GL_USE_STDLIB_ALLOC) 1119 || _GL_USE_STDLIB_ALLOC)
714# undef realloc 1120# undef realloc
715# define realloc rpl_realloc 1121# define realloc rpl_realloc
716# endif 1122# endif
717_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); 1123_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)
1124 _GL_ATTRIBUTE_DEALLOC_FREE);
718_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); 1125_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
719# else 1126# else
1127# if __GNUC__ >= 11
1128/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1129_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
1130 _GL_ATTRIBUTE_DEALLOC_FREE);
1131# endif
720_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); 1132_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
721# endif 1133# endif
1134# if __GLIBC__ >= 2
722_GL_CXXALIASWARN (realloc); 1135_GL_CXXALIASWARN (realloc);
723#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 1136# endif
724# undef realloc 1137#else
1138# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc
1139/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1140_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
1141 _GL_ATTRIBUTE_DEALLOC_FREE);
1142# endif
1143# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1144# undef realloc
725/* Assume realloc is always declared. */ 1145/* Assume realloc is always declared. */
726_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " 1146_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
727 "use gnulib module realloc-posix for portability"); 1147 "use gnulib module realloc-posix for portability");
1148# endif
1149#endif
1150
1151
1152#if @GNULIB_REALLOCARRAY@
1153# if @REPLACE_REALLOCARRAY@
1154# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1155# undef reallocarray
1156# define reallocarray rpl_reallocarray
1157# endif
1158_GL_FUNCDECL_RPL (reallocarray, void *,
1159 (void *ptr, size_t nmemb, size_t size));
1160_GL_CXXALIAS_RPL (reallocarray, void *,
1161 (void *ptr, size_t nmemb, size_t size));
1162# else
1163# if ! @HAVE_REALLOCARRAY@
1164_GL_FUNCDECL_SYS (reallocarray, void *,
1165 (void *ptr, size_t nmemb, size_t size));
1166# endif
1167_GL_CXXALIAS_SYS (reallocarray, void *,
1168 (void *ptr, size_t nmemb, size_t size));
1169# endif
1170_GL_CXXALIASWARN (reallocarray);
1171#elif defined GNULIB_POSIXCHECK
1172# undef reallocarray
1173# if HAVE_RAW_DECL_REALLOCARRAY
1174_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
1175 "use gnulib module reallocarray for portability");
1176# endif
728#endif 1177#endif
729 1178
730#if @GNULIB_REALPATH@ 1179#if @GNULIB_REALPATH@
@@ -732,15 +1181,19 @@ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
732# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1181# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
733# define realpath rpl_realpath 1182# define realpath rpl_realpath
734# endif 1183# endif
735_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) 1184_GL_FUNCDECL_RPL (realpath, char *,
736 _GL_ARG_NONNULL ((1))); 1185 (const char *restrict name, char *restrict resolved)
737_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); 1186 _GL_ARG_NONNULL ((1)));
1187_GL_CXXALIAS_RPL (realpath, char *,
1188 (const char *restrict name, char *restrict resolved));
738# else 1189# else
739# if !@HAVE_REALPATH@ 1190# if !@HAVE_REALPATH@
740_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) 1191_GL_FUNCDECL_SYS (realpath, char *,
741 _GL_ARG_NONNULL ((1))); 1192 (const char *restrict name, char *restrict resolved)
1193 _GL_ARG_NONNULL ((1)));
742# endif 1194# endif
743_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); 1195_GL_CXXALIAS_SYS (realpath, char *,
1196 (const char *restrict name, char *restrict resolved));
744# endif 1197# endif
745_GL_CXXALIASWARN (realpath); 1198_GL_CXXALIASWARN (realpath);
746#elif defined GNULIB_POSIXCHECK 1199#elif defined GNULIB_POSIXCHECK
@@ -822,17 +1275,24 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - "
822# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1275# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
823# define strtod rpl_strtod 1276# define strtod rpl_strtod
824# endif 1277# endif
825_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) 1278# define GNULIB_defined_strtod_function 1
826 _GL_ARG_NONNULL ((1))); 1279_GL_FUNCDECL_RPL (strtod, double,
827_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); 1280 (const char *restrict str, char **restrict endp)
1281 _GL_ARG_NONNULL ((1)));
1282_GL_CXXALIAS_RPL (strtod, double,
1283 (const char *restrict str, char **restrict endp));
828# else 1284# else
829# if !@HAVE_STRTOD@ 1285# if !@HAVE_STRTOD@
830_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) 1286_GL_FUNCDECL_SYS (strtod, double,
831 _GL_ARG_NONNULL ((1))); 1287 (const char *restrict str, char **restrict endp)
1288 _GL_ARG_NONNULL ((1)));
832# endif 1289# endif
833_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); 1290_GL_CXXALIAS_SYS (strtod, double,
1291 (const char *restrict str, char **restrict endp));
834# endif 1292# endif
1293# if __GLIBC__ >= 2
835_GL_CXXALIASWARN (strtod); 1294_GL_CXXALIASWARN (strtod);
1295# endif
836#elif defined GNULIB_POSIXCHECK 1296#elif defined GNULIB_POSIXCHECK
837# undef strtod 1297# undef strtod
838# if HAVE_RAW_DECL_STRTOD 1298# if HAVE_RAW_DECL_STRTOD
@@ -841,6 +1301,79 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
841# endif 1301# endif
842#endif 1302#endif
843 1303
1304#if @GNULIB_STRTOLD@
1305 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
1306# if @REPLACE_STRTOLD@
1307# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1308# define strtold rpl_strtold
1309# endif
1310# define GNULIB_defined_strtold_function 1
1311_GL_FUNCDECL_RPL (strtold, long double,
1312 (const char *restrict str, char **restrict endp)
1313 _GL_ARG_NONNULL ((1)));
1314_GL_CXXALIAS_RPL (strtold, long double,
1315 (const char *restrict str, char **restrict endp));
1316# else
1317# if !@HAVE_STRTOLD@
1318_GL_FUNCDECL_SYS (strtold, long double,
1319 (const char *restrict str, char **restrict endp)
1320 _GL_ARG_NONNULL ((1)));
1321# endif
1322_GL_CXXALIAS_SYS (strtold, long double,
1323 (const char *restrict str, char **restrict endp));
1324# endif
1325_GL_CXXALIASWARN (strtold);
1326#elif defined GNULIB_POSIXCHECK
1327# undef strtold
1328# if HAVE_RAW_DECL_STRTOLD
1329_GL_WARN_ON_USE (strtold, "strtold is unportable - "
1330 "use gnulib module strtold for portability");
1331# endif
1332#endif
1333
1334#if @GNULIB_STRTOL@
1335/* Parse a signed integer whose textual representation starts at STRING.
1336 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1337 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1338 "0x").
1339 If ENDPTR is not NULL, the address of the first byte after the integer is
1340 stored in *ENDPTR.
1341 Upon overflow, the return value is LONG_MAX or LONG_MIN, and errno is set
1342 to ERANGE. */
1343# if @REPLACE_STRTOL@
1344# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1345# define strtol rpl_strtol
1346# endif
1347# define GNULIB_defined_strtol_function 1
1348_GL_FUNCDECL_RPL (strtol, long,
1349 (const char *restrict string, char **restrict endptr,
1350 int base)
1351 _GL_ARG_NONNULL ((1)));
1352_GL_CXXALIAS_RPL (strtol, long,
1353 (const char *restrict string, char **restrict endptr,
1354 int base));
1355# else
1356# if !@HAVE_STRTOL@
1357_GL_FUNCDECL_SYS (strtol, long,
1358 (const char *restrict string, char **restrict endptr,
1359 int base)
1360 _GL_ARG_NONNULL ((1)));
1361# endif
1362_GL_CXXALIAS_SYS (strtol, long,
1363 (const char *restrict string, char **restrict endptr,
1364 int base));
1365# endif
1366# if __GLIBC__ >= 2
1367_GL_CXXALIASWARN (strtol);
1368# endif
1369#elif defined GNULIB_POSIXCHECK
1370# undef strtol
1371# if HAVE_RAW_DECL_STRTOL
1372_GL_WARN_ON_USE (strtol, "strtol is unportable - "
1373 "use gnulib module strtol for portability");
1374# endif
1375#endif
1376
844#if @GNULIB_STRTOLL@ 1377#if @GNULIB_STRTOLL@
845/* Parse a signed integer whose textual representation starts at STRING. 1378/* Parse a signed integer whose textual representation starts at STRING.
846 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, 1379 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
@@ -850,13 +1383,29 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
850 stored in *ENDPTR. 1383 stored in *ENDPTR.
851 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set 1384 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
852 to ERANGE. */ 1385 to ERANGE. */
853# if !@HAVE_STRTOLL@ 1386# if @REPLACE_STRTOLL@
1387# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1388# define strtoll rpl_strtoll
1389# endif
1390# define GNULIB_defined_strtoll_function 1
1391_GL_FUNCDECL_RPL (strtoll, long long,
1392 (const char *restrict string, char **restrict endptr,
1393 int base)
1394 _GL_ARG_NONNULL ((1)));
1395_GL_CXXALIAS_RPL (strtoll, long long,
1396 (const char *restrict string, char **restrict endptr,
1397 int base));
1398# else
1399# if !@HAVE_STRTOLL@
854_GL_FUNCDECL_SYS (strtoll, long long, 1400_GL_FUNCDECL_SYS (strtoll, long long,
855 (const char *string, char **endptr, int base) 1401 (const char *restrict string, char **restrict endptr,
1402 int base)
856 _GL_ARG_NONNULL ((1))); 1403 _GL_ARG_NONNULL ((1)));
857# endif 1404# endif
858_GL_CXXALIAS_SYS (strtoll, long long, 1405_GL_CXXALIAS_SYS (strtoll, long long,
859 (const char *string, char **endptr, int base)); 1406 (const char *restrict string, char **restrict endptr,
1407 int base));
1408# endif
860_GL_CXXALIASWARN (strtoll); 1409_GL_CXXALIASWARN (strtoll);
861#elif defined GNULIB_POSIXCHECK 1410#elif defined GNULIB_POSIXCHECK
862# undef strtoll 1411# undef strtoll
@@ -866,6 +1415,48 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
866# endif 1415# endif
867#endif 1416#endif
868 1417
1418#if @GNULIB_STRTOUL@
1419/* Parse an unsigned integer whose textual representation starts at STRING.
1420 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1421 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1422 "0x").
1423 If ENDPTR is not NULL, the address of the first byte after the integer is
1424 stored in *ENDPTR.
1425 Upon overflow, the return value is ULONG_MAX, and errno is set to ERANGE. */
1426# if @REPLACE_STRTOUL@
1427# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1428# define strtoul rpl_strtoul
1429# endif
1430# define GNULIB_defined_strtoul_function 1
1431_GL_FUNCDECL_RPL (strtoul, unsigned long,
1432 (const char *restrict string, char **restrict endptr,
1433 int base)
1434 _GL_ARG_NONNULL ((1)));
1435_GL_CXXALIAS_RPL (strtoul, unsigned long,
1436 (const char *restrict string, char **restrict endptr,
1437 int base));
1438# else
1439# if !@HAVE_STRTOUL@
1440_GL_FUNCDECL_SYS (strtoul, unsigned long,
1441 (const char *restrict string, char **restrict endptr,
1442 int base)
1443 _GL_ARG_NONNULL ((1)));
1444# endif
1445_GL_CXXALIAS_SYS (strtoul, unsigned long,
1446 (const char *restrict string, char **restrict endptr,
1447 int base));
1448# endif
1449# if __GLIBC__ >= 2
1450_GL_CXXALIASWARN (strtoul);
1451# endif
1452#elif defined GNULIB_POSIXCHECK
1453# undef strtoul
1454# if HAVE_RAW_DECL_STRTOUL
1455_GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
1456 "use gnulib module strtoul for portability");
1457# endif
1458#endif
1459
869#if @GNULIB_STRTOULL@ 1460#if @GNULIB_STRTOULL@
870/* Parse an unsigned integer whose textual representation starts at STRING. 1461/* Parse an unsigned integer whose textual representation starts at STRING.
871 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, 1462 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
@@ -875,13 +1466,29 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
875 stored in *ENDPTR. 1466 stored in *ENDPTR.
876 Upon overflow, the return value is ULLONG_MAX, and errno is set to 1467 Upon overflow, the return value is ULLONG_MAX, and errno is set to
877 ERANGE. */ 1468 ERANGE. */
878# if !@HAVE_STRTOULL@ 1469# if @REPLACE_STRTOULL@
1470# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1471# define strtoull rpl_strtoull
1472# endif
1473# define GNULIB_defined_strtoull_function 1
1474_GL_FUNCDECL_RPL (strtoull, unsigned long long,
1475 (const char *restrict string, char **restrict endptr,
1476 int base)
1477 _GL_ARG_NONNULL ((1)));
1478_GL_CXXALIAS_RPL (strtoull, unsigned long long,
1479 (const char *restrict string, char **restrict endptr,
1480 int base));
1481# else
1482# if !@HAVE_STRTOULL@
879_GL_FUNCDECL_SYS (strtoull, unsigned long long, 1483_GL_FUNCDECL_SYS (strtoull, unsigned long long,
880 (const char *string, char **endptr, int base) 1484 (const char *restrict string, char **restrict endptr,
1485 int base)
881 _GL_ARG_NONNULL ((1))); 1486 _GL_ARG_NONNULL ((1)));
882# endif 1487# endif
883_GL_CXXALIAS_SYS (strtoull, unsigned long long, 1488_GL_CXXALIAS_SYS (strtoull, unsigned long long,
884 (const char *string, char **endptr, int base)); 1489 (const char *restrict string, char **restrict endptr,
1490 int base));
1491# endif
885_GL_CXXALIASWARN (strtoull); 1492_GL_CXXALIASWARN (strtoull);
886#elif defined GNULIB_POSIXCHECK 1493#elif defined GNULIB_POSIXCHECK
887# undef strtoull 1494# undef strtoull
@@ -945,7 +1552,9 @@ _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
945# else 1552# else
946_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); 1553_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
947# endif 1554# endif
1555# if __GLIBC__ >= 2
948_GL_CXXALIASWARN (wctomb); 1556_GL_CXXALIASWARN (wctomb);
1557# endif
949#endif 1558#endif
950 1559
951 1560
diff --git a/gl/str-two-way.h b/gl/str-two-way.h
index 707145db..dfe70224 100644
--- a/gl/str-two-way.h
+++ b/gl/str-two-way.h
@@ -1,24 +1,24 @@
1/* Byte-wise substring search, using the Two-Way algorithm. 1/* Byte-wise substring search, using the Two-Way algorithm.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Written by Eric Blake <ebb9@byu.net>, 2008. 4 Written by Eric Blake <ebb9@byu.net>, 2008.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU Lesser General Public License
17 with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* Before including this file, you need to include <config.h> and 19/* Before including this file, you need to include <config.h> and
20 <string.h>, and define: 20 <string.h>, and define:
21 RESULT_TYPE A macro that expands to the return type. 21 RETURN_TYPE A macro that expands to the return type.
22 AVAILABLE(h, h_l, j, n_l) 22 AVAILABLE(h, h_l, j, n_l)
23 A macro that returns nonzero if there are 23 A macro that returns nonzero if there are
24 at least N_L bytes left starting at H[J]. 24 at least N_L bytes left starting at H[J].
@@ -49,9 +49,9 @@
49 character shift table similar to the Boyer-Moore algorithm to 49 character shift table similar to the Boyer-Moore algorithm to
50 achieve improved (potentially sub-linear) performance. 50 achieve improved (potentially sub-linear) performance.
51 51
52 See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260, 52 See https://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260,
53 http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm, 53 https://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm,
54 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf 54 https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf
55*/ 55*/
56 56
57/* Point at which computing a bad-byte shift table is likely to be 57/* Point at which computing a bad-byte shift table is likely to be
@@ -231,7 +231,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
231 most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. 231 most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
232 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * 232 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
233 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ 233 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */
234static RETURN_TYPE 234static RETURN_TYPE _GL_ATTRIBUTE_PURE
235two_way_short_needle (const unsigned char *haystack, size_t haystack_len, 235two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
236 const unsigned char *needle, size_t needle_len) 236 const unsigned char *needle, size_t needle_len)
237{ 237{
@@ -325,7 +325,7 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
325 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * 325 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
326 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and 326 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
327 sublinear performance is not possible. */ 327 sublinear performance is not possible. */
328static RETURN_TYPE 328static RETURN_TYPE _GL_ATTRIBUTE_PURE
329two_way_long_needle (const unsigned char *haystack, size_t haystack_len, 329two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
330 const unsigned char *needle, size_t needle_len) 330 const unsigned char *needle, size_t needle_len)
331{ 331{
diff --git a/gl/strcasecmp.c b/gl/strcasecmp.c
index 0f0a742f..3a5ce3e1 100644
--- a/gl/strcasecmp.c
+++ b/gl/strcasecmp.c
@@ -1,18 +1,18 @@
1/* Case-insensitive string comparison function. 1/* Case-insensitive string comparison function.
2 Copyright (C) 1998-1999, 2005-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
@@ -58,5 +58,5 @@ strcasecmp (const char *s1, const char *s2)
58 /* On machines where 'char' and 'int' are types of the same size, the 58 /* On machines where 'char' and 'int' are types of the same size, the
59 difference of two 'unsigned char' values - including the sign bit - 59 difference of two 'unsigned char' values - including the sign bit -
60 doesn't fit in an 'int'. */ 60 doesn't fit in an 'int'. */
61 return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); 61 return _GL_CMP (c1, c2);
62} 62}
diff --git a/gl/strcasestr.c b/gl/strcasestr.c
index 53474a45..8eea435c 100644
--- a/gl/strcasestr.c
+++ b/gl/strcasestr.c
@@ -1,19 +1,19 @@
1/* Case-insensitive searching in a string. 1/* Case-insensitive searching in a string.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2005. 3 Written by Bruno Haible <bruno@clisp.org>, 2005.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -21,7 +21,6 @@
21#include <string.h> 21#include <string.h>
22 22
23#include <ctype.h> 23#include <ctype.h>
24#include <stdbool.h>
25#include <strings.h> 24#include <strings.h>
26 25
27#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) 26#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
diff --git a/gl/streq.h b/gl/streq.h
index 12c1867c..712948eb 100644
--- a/gl/streq.h
+++ b/gl/streq.h
@@ -1,18 +1,18 @@
1/* Optimized string comparison. 1/* Optimized string comparison.
2 Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2001-2002, 2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This file is free software: you can redistribute it and/or modify
5 under the terms of the GNU General Public License as published 5 it under the terms of the GNU Lesser General Public License as
6 by the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>. */ 17/* Written by Bruno Haible <bruno@clisp.org>. */
18 18
@@ -29,7 +29,7 @@
29 29
30/* Help GCC to generate good code for string comparisons with 30/* Help GCC to generate good code for string comparisons with
31 immediate strings. */ 31 immediate strings. */
32#if defined (__GNUC__) && defined (__OPTIMIZE__) 32#if (defined __GNUC__ || defined __clang__) && defined __OPTIMIZE__
33 33
34static inline int 34static inline int
35streq9 (const char *s1, const char *s2) 35streq9 (const char *s1, const char *s2)
diff --git a/gl/strerror-override.c b/gl/strerror-override.c
index d0ed2fb8..cddaa4a9 100644
--- a/gl/strerror-override.c
+++ b/gl/strerror-override.c
@@ -1,19 +1,19 @@
1/* strerror-override.c --- POSIX compatible system error routine 1/* strerror-override.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2010-2013 Free Software Foundation, Inc. 3 Copyright (C) 2010-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ 18/* Written by Bruno Haible <bruno@clisp.org>, 2010. */
19 19
@@ -29,6 +29,8 @@
29# endif 29# endif
30#endif 30#endif
31 31
32#if !GNULIB_defined_strerror_override_macro
33
32/* If ERRNUM maps to an errno value defined by gnulib, return a string 34/* If ERRNUM maps to an errno value defined by gnulib, return a string
33 describing the error. Otherwise return NULL. */ 35 describing the error. Otherwise return NULL. */
34const char * 36const char *
@@ -37,12 +39,12 @@ strerror_override (int errnum)
37 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ 39 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
38 switch (errnum) 40 switch (errnum)
39 { 41 {
40#if REPLACE_STRERROR_0 42# if REPLACE_STRERROR_0
41 case 0: 43 case 0:
42 return "Success"; 44 return "Success";
43#endif 45# endif
44 46
45#if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */ 47# if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
46 case EINPROGRESS: 48 case EINPROGRESS:
47 return "Operation now in progress"; 49 return "Operation now in progress";
48 case EALREADY: 50 case EALREADY:
@@ -89,8 +91,8 @@ strerror_override (int errnum)
89 return "No route to host"; 91 return "No route to host";
90 case EWOULDBLOCK: 92 case EWOULDBLOCK:
91 return "Operation would block"; 93 return "Operation would block";
92#endif 94# endif
93#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */ 95# if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
94 case ETXTBSY: 96 case ETXTBSY:
95 return "Text file busy"; 97 return "Text file busy";
96 case ENODATA: 98 case ENODATA:
@@ -103,8 +105,8 @@ strerror_override (int errnum)
103 return "Timer expired"; 105 return "Timer expired";
104 case EOTHER: 106 case EOTHER:
105 return "Other error"; 107 return "Other error";
106#endif 108# endif
107#if GNULIB_defined_EWINSOCK /* native Windows platforms */ 109# if GNULIB_defined_EWINSOCK /* native Windows platforms */
108 case ESOCKTNOSUPPORT: 110 case ESOCKTNOSUPPORT:
109 return "Socket type not supported"; 111 return "Socket type not supported";
110 case EPFNOSUPPORT: 112 case EPFNOSUPPORT:
@@ -125,7 +127,7 @@ strerror_override (int errnum)
125 return "Stale NFS file handle"; 127 return "Stale NFS file handle";
126 case EREMOTE: 128 case EREMOTE:
127 return "Object is remote"; 129 return "Object is remote";
128# if HAVE_WINSOCK2_H 130# if HAVE_WINSOCK2_H
129 /* WSA_INVALID_HANDLE maps to EBADF */ 131 /* WSA_INVALID_HANDLE maps to EBADF */
130 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ 132 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
131 /* WSA_INVALID_PARAMETER maps to EINVAL */ 133 /* WSA_INVALID_PARAMETER maps to EINVAL */
@@ -213,90 +215,92 @@ strerror_override (int errnum)
213 case WSANO_DATA: 215 case WSANO_DATA:
214 return "Valid name, no data record of requested type"; 216 return "Valid name, no data record of requested type";
215 /* WSA_QOS_* omitted */ 217 /* WSA_QOS_* omitted */
218# endif
216# endif 219# endif
217#endif
218 220
219#if GNULIB_defined_ENOMSG 221# if GNULIB_defined_ENOMSG
220 case ENOMSG: 222 case ENOMSG:
221 return "No message of desired type"; 223 return "No message of desired type";
222#endif 224# endif
223 225
224#if GNULIB_defined_EIDRM 226# if GNULIB_defined_EIDRM
225 case EIDRM: 227 case EIDRM:
226 return "Identifier removed"; 228 return "Identifier removed";
227#endif 229# endif
228 230
229#if GNULIB_defined_ENOLINK 231# if GNULIB_defined_ENOLINK
230 case ENOLINK: 232 case ENOLINK:
231 return "Link has been severed"; 233 return "Link has been severed";
232#endif 234# endif
233 235
234#if GNULIB_defined_EPROTO 236# if GNULIB_defined_EPROTO
235 case EPROTO: 237 case EPROTO:
236 return "Protocol error"; 238 return "Protocol error";
237#endif 239# endif
238 240
239#if GNULIB_defined_EMULTIHOP 241# if GNULIB_defined_EMULTIHOP
240 case EMULTIHOP: 242 case EMULTIHOP:
241 return "Multihop attempted"; 243 return "Multihop attempted";
242#endif 244# endif
243 245
244#if GNULIB_defined_EBADMSG 246# if GNULIB_defined_EBADMSG
245 case EBADMSG: 247 case EBADMSG:
246 return "Bad message"; 248 return "Bad message";
247#endif 249# endif
248 250
249#if GNULIB_defined_EOVERFLOW 251# if GNULIB_defined_EOVERFLOW
250 case EOVERFLOW: 252 case EOVERFLOW:
251 return "Value too large for defined data type"; 253 return "Value too large for defined data type";
252#endif 254# endif
253 255
254#if GNULIB_defined_ENOTSUP 256# if GNULIB_defined_ENOTSUP
255 case ENOTSUP: 257 case ENOTSUP:
256 return "Not supported"; 258 return "Not supported";
257#endif 259# endif
258 260
259#if GNULIB_defined_ENETRESET 261# if GNULIB_defined_ENETRESET
260 case ENETRESET: 262 case ENETRESET:
261 return "Network dropped connection on reset"; 263 return "Network dropped connection on reset";
262#endif 264# endif
263 265
264#if GNULIB_defined_ECONNABORTED 266# if GNULIB_defined_ECONNABORTED
265 case ECONNABORTED: 267 case ECONNABORTED:
266 return "Software caused connection abort"; 268 return "Software caused connection abort";
267#endif 269# endif
268 270
269#if GNULIB_defined_ESTALE 271# if GNULIB_defined_ESTALE
270 case ESTALE: 272 case ESTALE:
271 return "Stale NFS file handle"; 273 return "Stale NFS file handle";
272#endif 274# endif
273 275
274#if GNULIB_defined_EDQUOT 276# if GNULIB_defined_EDQUOT
275 case EDQUOT: 277 case EDQUOT:
276 return "Disk quota exceeded"; 278 return "Disk quota exceeded";
277#endif 279# endif
278 280
279#if GNULIB_defined_ECANCELED 281# if GNULIB_defined_ECANCELED
280 case ECANCELED: 282 case ECANCELED:
281 return "Operation canceled"; 283 return "Operation canceled";
282#endif 284# endif
283 285
284#if GNULIB_defined_EOWNERDEAD 286# if GNULIB_defined_EOWNERDEAD
285 case EOWNERDEAD: 287 case EOWNERDEAD:
286 return "Owner died"; 288 return "Owner died";
287#endif 289# endif
288 290
289#if GNULIB_defined_ENOTRECOVERABLE 291# if GNULIB_defined_ENOTRECOVERABLE
290 case ENOTRECOVERABLE: 292 case ENOTRECOVERABLE:
291 return "State not recoverable"; 293 return "State not recoverable";
292#endif 294# endif
293 295
294#if GNULIB_defined_EILSEQ 296# if GNULIB_defined_EILSEQ
295 case EILSEQ: 297 case EILSEQ:
296 return "Invalid or incomplete multibyte or wide character"; 298 return "Invalid or incomplete multibyte or wide character";
297#endif 299# endif
298 300
299 default: 301 default:
300 return NULL; 302 return NULL;
301 } 303 }
302} 304}
305
306#endif
diff --git a/gl/strerror-override.h b/gl/strerror-override.h
index 3b8f24b9..388cc282 100644
--- a/gl/strerror-override.h
+++ b/gl/strerror-override.h
@@ -1,19 +1,19 @@
1/* strerror-override.h --- POSIX compatible system error routine 1/* strerror-override.h --- POSIX compatible system error routine
2 2
3 Copyright (C) 2010-2013 Free Software Foundation, Inc. 3 Copyright (C) 2010-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _GL_STRERROR_OVERRIDE_H 18#ifndef _GL_STRERROR_OVERRIDE_H
19# define _GL_STRERROR_OVERRIDE_H 19# define _GL_STRERROR_OVERRIDE_H
@@ -48,9 +48,10 @@
48 || GNULIB_defined_EOWNERDEAD \ 48 || GNULIB_defined_EOWNERDEAD \
49 || GNULIB_defined_ENOTRECOVERABLE \ 49 || GNULIB_defined_ENOTRECOVERABLE \
50 || GNULIB_defined_EILSEQ 50 || GNULIB_defined_EILSEQ
51extern const char *strerror_override (int errnum); 51extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
52# else 52# else
53# define strerror_override(ignored) NULL 53# define strerror_override(ignored) NULL
54# define GNULIB_defined_strerror_override_macro 1
54# endif 55# endif
55 56
56#endif /* _GL_STRERROR_OVERRIDE_H */ 57#endif /* _GL_STRERROR_OVERRIDE_H */
diff --git a/gl/strerror.c b/gl/strerror.c
index 80a2f2ee..d754f601 100644
--- a/gl/strerror.c
+++ b/gl/strerror.c
@@ -1,19 +1,19 @@
1/* strerror.c --- POSIX compatible system error routine 1/* strerror.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -27,7 +27,6 @@
27 27
28#include "intprops.h" 28#include "intprops.h"
29#include "strerror-override.h" 29#include "strerror-override.h"
30#include "verify.h"
31 30
32/* Use the system functions, not the gnulib overrides in this file. */ 31/* Use the system functions, not the gnulib overrides in this file. */
33#undef sprintf 32#undef sprintf
@@ -55,7 +54,7 @@ strerror (int n)
55 if (!msg || !*msg) 54 if (!msg || !*msg)
56 { 55 {
57 static char const fmt[] = "Unknown error %d"; 56 static char const fmt[] = "Unknown error %d";
58 verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n)); 57 static_assert (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n));
59 sprintf (buf, fmt, n); 58 sprintf (buf, fmt, n);
60 errno = EINVAL; 59 errno = EINVAL;
61 return buf; 60 return buf;
@@ -66,5 +65,6 @@ strerror (int n)
66 if (sizeof buf <= len) 65 if (sizeof buf <= len)
67 abort (); 66 abort ();
68 67
69 return memcpy (buf, msg, len + 1); 68 memcpy (buf, msg, len + 1);
69 return buf;
70} 70}
diff --git a/gl/string.in.h b/gl/string.in.h
index d7a6c9c9..e993b2fb 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -1,30 +1,46 @@
1/* A GNU-like <string.h>. 1/* A GNU-like <string.h>.
2 2
3 Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _@GUARD_PREFIX@_STRING_H
19 17
20#if __GNUC__ >= 3 18#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
22#endif 20#endif
23@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
24 22
23#if defined _GL_ALREADY_INCLUDING_STRING_H
24/* Special invocation convention:
25 - On OS X/NetBSD we have a sequence of nested includes
26 <string.h> -> <strings.h> -> "string.h"
27 In this situation system _chk variants due to -D_FORTIFY_SOURCE
28 might be used after any replacements defined here. */
29
30#@INCLUDE_NEXT@ @NEXT_STRING_H@
31
32#else
33/* Normal invocation convention. */
34
35#ifndef _@GUARD_PREFIX@_STRING_H
36
37#define _GL_ALREADY_INCLUDING_STRING_H
38
25/* The include_next requires a split double-inclusion guard. */ 39/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_STRING_H@ 40#@INCLUDE_NEXT@ @NEXT_STRING_H@
27 41
42#undef _GL_ALREADY_INCLUDING_STRING_H
43
28#ifndef _@GUARD_PREFIX@_STRING_H 44#ifndef _@GUARD_PREFIX@_STRING_H
29#define _@GUARD_PREFIX@_STRING_H 45#define _@GUARD_PREFIX@_STRING_H
30 46
@@ -36,14 +52,6 @@
36# include <wchar.h> 52# include <wchar.h>
37#endif 53#endif
38 54
39/* The __attribute__ feature is available in gcc versions 2.5 and later.
40 The attribute __pure__ was added in gcc 2.96. */
41#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
42# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
43#else
44# define _GL_ATTRIBUTE_PURE /* empty */
45#endif
46
47/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ 55/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
48/* But in any case avoid namespace pollution on glibc systems. */ 56/* But in any case avoid namespace pollution on glibc systems. */
49#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ 57#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
@@ -51,12 +59,122 @@
51# include <unistd.h> 59# include <unistd.h>
52#endif 60#endif
53 61
62/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */
63/* But in any case avoid namespace pollution on glibc systems. */
64#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
65 && defined _AIX) \
66 && ! defined __GLIBC__
67# include <strings.h>
68#endif
69
70/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
71 that can be freed by passing them as the Ith argument to the
72 function F. */
73#ifndef _GL_ATTRIBUTE_DEALLOC
74# if __GNUC__ >= 11
75# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
76# else
77# define _GL_ATTRIBUTE_DEALLOC(f, i)
78# endif
79#endif
80
81/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
82 can be freed via 'free'; it can be used only after declaring 'free'. */
83/* Applies to: functions. Cannot be used on inline functions. */
84#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
85# if defined __cplusplus && defined __GNUC__ && !defined __clang__
86/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
87# define _GL_ATTRIBUTE_DEALLOC_FREE \
88 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
89# else
90# define _GL_ATTRIBUTE_DEALLOC_FREE \
91 _GL_ATTRIBUTE_DEALLOC (free, 1)
92# endif
93#endif
94
95/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
96 allocated memory. */
97/* Applies to: functions. */
98#ifndef _GL_ATTRIBUTE_MALLOC
99# if __GNUC__ >= 3 || defined __clang__
100# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
101# else
102# define _GL_ATTRIBUTE_MALLOC
103# endif
104#endif
105
106/* The __attribute__ feature is available in gcc versions 2.5 and later.
107 The attribute __pure__ was added in gcc 2.96. */
108#ifndef _GL_ATTRIBUTE_PURE
109# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
110# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
111# else
112# define _GL_ATTRIBUTE_PURE /* empty */
113# endif
114#endif
115
54/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 116/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55 117
56/* The definition of _GL_ARG_NONNULL is copied here. */ 118/* The definition of _GL_ARG_NONNULL is copied here. */
57 119
58/* The definition of _GL_WARN_ON_USE is copied here. */ 120/* The definition of _GL_WARN_ON_USE is copied here. */
59 121
122/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
123 been included yet. */
124#if @GNULIB_FREE_POSIX@
125# if (@REPLACE_FREE@ && !defined free \
126 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
127/* We can't do '#define free rpl_free' here. */
128_GL_EXTERN_C void rpl_free (void *);
129# undef _GL_ATTRIBUTE_DEALLOC_FREE
130# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
131# else
132# if defined _MSC_VER && !defined free
133_GL_EXTERN_C
134# if defined _DLL
135 __declspec (dllimport)
136# endif
137 void __cdecl free (void *);
138# else
139# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
140_GL_EXTERN_C void free (void *) throw ();
141# else
142_GL_EXTERN_C void free (void *);
143# endif
144# endif
145# endif
146#else
147# if defined _MSC_VER && !defined free
148_GL_EXTERN_C
149# if defined _DLL
150 __declspec (dllimport)
151# endif
152 void __cdecl free (void *);
153# else
154# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
155_GL_EXTERN_C void free (void *) throw ();
156# else
157_GL_EXTERN_C void free (void *);
158# endif
159# endif
160#endif
161
162/* Clear a block of memory. The compiler will not delete a call to
163 this function, even if the block is dead after the call. */
164#if @GNULIB_EXPLICIT_BZERO@
165# if ! @HAVE_EXPLICIT_BZERO@
166_GL_FUNCDECL_SYS (explicit_bzero, void,
167 (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
168# endif
169_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
170_GL_CXXALIASWARN (explicit_bzero);
171#elif defined GNULIB_POSIXCHECK
172# undef explicit_bzero
173# if HAVE_RAW_DECL_EXPLICIT_BZERO
174_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
175 "use gnulib module explicit_bzero for portability");
176# endif
177#endif
60 178
61/* Find the index of the least-significant set bit. */ 179/* Find the index of the least-significant set bit. */
62#if @GNULIB_FFSL@ 180#if @GNULIB_FFSL@
@@ -75,10 +193,18 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
75 193
76/* Find the index of the least-significant set bit. */ 194/* Find the index of the least-significant set bit. */
77#if @GNULIB_FFSLL@ 195#if @GNULIB_FFSLL@
78# if !@HAVE_FFSLL@ 196# if @REPLACE_FFSLL@
197# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198# define ffsll rpl_ffsll
199# endif
200_GL_FUNCDECL_RPL (ffsll, int, (long long int i));
201_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
202# else
203# if !@HAVE_FFSLL@
79_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); 204_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
80# endif 205# endif
81_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); 206_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
207# endif
82_GL_CXXALIASWARN (ffsll); 208_GL_CXXALIASWARN (ffsll);
83#elif defined GNULIB_POSIXCHECK 209#elif defined GNULIB_POSIXCHECK
84# undef ffsll 210# undef ffsll
@@ -88,10 +214,30 @@ _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
88#endif 214#endif
89 215
90 216
217#if @GNULIB_MDA_MEMCCPY@
218/* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not
219 required. In C++ with GNULIB_NAMESPACE, avoid differences between
220 platforms by defining GNULIB_NAMESPACE::memccpy always. */
221# if defined _WIN32 && !defined __CYGWIN__
222# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
223# undef memccpy
224# define memccpy _memccpy
225# endif
226_GL_CXXALIAS_MDA (memccpy, void *,
227 (void *dest, const void *src, int c, size_t n));
228# else
229_GL_CXXALIAS_SYS (memccpy, void *,
230 (void *dest, const void *src, int c, size_t n));
231# endif
232_GL_CXXALIASWARN (memccpy);
233#endif
234
235
91/* Return the first instance of C within N bytes of S, or NULL. */ 236/* Return the first instance of C within N bytes of S, or NULL. */
92#if @GNULIB_MEMCHR@ 237#if @GNULIB_MEMCHR@
93# if @REPLACE_MEMCHR@ 238# if @REPLACE_MEMCHR@
94# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 239# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
240# undef memchr
95# define memchr rpl_memchr 241# define memchr rpl_memchr
96# endif 242# endif
97_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) 243_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
@@ -99,11 +245,6 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
99 _GL_ARG_NONNULL ((1))); 245 _GL_ARG_NONNULL ((1)));
100_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); 246_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
101# else 247# else
102# if ! @HAVE_MEMCHR@
103_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
104 _GL_ATTRIBUTE_PURE
105 _GL_ARG_NONNULL ((1)));
106# endif
107 /* On some systems, this function is defined as an overloaded function: 248 /* On some systems, this function is defined as an overloaded function:
108 extern "C" { const void * std::memchr (const void *, int, size_t); } 249 extern "C" { const void * std::memchr (const void *, int, size_t); }
109 extern "C++" { void * std::memchr (void *, int, size_t); } */ 250 extern "C++" { void * std::memchr (void *, int, size_t); } */
@@ -112,11 +253,12 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
112 void const *, (void const *__s, int __c, size_t __n)); 253 void const *, (void const *__s, int __c, size_t __n));
113# endif 254# endif
114# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 255# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 256 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
116_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); 257 || defined __clang__)
258_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ());
117_GL_CXXALIASWARN1 (memchr, void const *, 259_GL_CXXALIASWARN1 (memchr, void const *,
118 (void const *__s, int __c, size_t __n)); 260 (void const *__s, int __c, size_t __n) throw ());
119# else 261# elif __GLIBC__ >= 2
120_GL_CXXALIASWARN (memchr); 262_GL_CXXALIASWARN (memchr);
121# endif 263# endif
122#elif defined GNULIB_POSIXCHECK 264#elif defined GNULIB_POSIXCHECK
@@ -197,9 +339,10 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
197 void *, (void const *, int, size_t), 339 void *, (void const *, int, size_t),
198 void const *, (void const *, int, size_t)); 340 void const *, (void const *, int, size_t));
199# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 341# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 342 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
201_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 343 || defined __clang__)
202_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); 344_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ());
345_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ());
203# else 346# else
204_GL_CXXALIASWARN (memrchr); 347_GL_CXXALIASWARN (memrchr);
205# endif 348# endif
@@ -211,6 +354,23 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
211# endif 354# endif
212#endif 355#endif
213 356
357/* Overwrite a block of memory. The compiler will not optimize
358 effects away, even if the block is dead after the call. */
359#if @GNULIB_MEMSET_EXPLICIT@
360# if ! @HAVE_MEMSET_EXPLICIT@
361_GL_FUNCDECL_SYS (memset_explicit, void *,
362 (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1)));
363# endif
364_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
365_GL_CXXALIASWARN (memset_explicit);
366#elif defined GNULIB_POSIXCHECK
367# undef memset_explicit
368# if HAVE_RAW_DECL_MEMSET_EXPLICIT
369_GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - "
370 "use gnulib module memset_explicit for portability");
371# endif
372#endif
373
214/* Find the first occurrence of C in S. More efficient than 374/* Find the first occurrence of C in S. More efficient than
215 memchr(S,C,N), at the expense of undefined behavior if C does not 375 memchr(S,C,N), at the expense of undefined behavior if C does not
216 occur within N bytes. */ 376 occur within N bytes. */
@@ -227,9 +387,11 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
227 void *, (void const *__s, int __c_in), 387 void *, (void const *__s, int __c_in),
228 void const *, (void const *__s, int __c_in)); 388 void const *, (void const *__s, int __c_in));
229# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 389# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 390 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
231_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 391 || defined __clang__)
232_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); 392_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ());
393_GL_CXXALIASWARN1 (rawmemchr, void const *,
394 (void const *__s, int __c_in) throw ());
233# else 395# else
234_GL_CXXALIASWARN (rawmemchr); 396_GL_CXXALIASWARN (rawmemchr);
235# endif 397# endif
@@ -299,9 +461,11 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
299 GB18030 and the character to be searched is a digit. */ 461 GB18030 and the character to be searched is a digit. */
300# undef strchr 462# undef strchr
301/* Assume strchr is always declared. */ 463/* Assume strchr is always declared. */
302_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " 464_GL_WARN_ON_USE_CXX (strchr,
303 "in some multibyte locales - " 465 const char *, char *, (const char *, int),
304 "use mbschr if you care about internationalization"); 466 "strchr cannot work correctly on character strings "
467 "in some multibyte locales - "
468 "use mbschr if you care about internationalization");
305#endif 469#endif
306 470
307/* Find the first occurrence of C in S or the final NUL byte. */ 471/* Find the first occurrence of C in S or the final NUL byte. */
@@ -329,9 +493,11 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
329 char const *, (char const *__s, int __c_in)); 493 char const *, (char const *__s, int __c_in));
330# endif 494# endif
331# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 495# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 496 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
333_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 497 || defined __clang__)
334_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); 498_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ());
499_GL_CXXALIASWARN1 (strchrnul, char const *,
500 (char const *__s, int __c_in) throw ());
335# else 501# else
336_GL_CXXALIASWARN (strchrnul); 502_GL_CXXALIASWARN (strchrnul);
337# endif 503# endif
@@ -350,24 +516,62 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
350# undef strdup 516# undef strdup
351# define strdup rpl_strdup 517# define strdup rpl_strdup
352# endif 518# endif
353_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 519_GL_FUNCDECL_RPL (strdup, char *,
520 (char const *__s)
521 _GL_ARG_NONNULL ((1))
522 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
354_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 523_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
524# elif defined _WIN32 && !defined __CYGWIN__
525# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
526# undef strdup
527# define strdup _strdup
528# endif
529_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
355# else 530# else
356# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 531# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
357 /* strdup exists as a function and as a macro. Get rid of the macro. */ 532 /* strdup exists as a function and as a macro. Get rid of the macro. */
358# undef strdup 533# undef strdup
359# endif 534# endif
360# if !(@HAVE_DECL_STRDUP@ || defined strdup) 535# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup
361_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 536_GL_FUNCDECL_SYS (strdup, char *,
537 (char const *__s)
538 _GL_ARG_NONNULL ((1))
539 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
362# endif 540# endif
363_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 541_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
364# endif 542# endif
365_GL_CXXALIASWARN (strdup); 543_GL_CXXALIASWARN (strdup);
366#elif defined GNULIB_POSIXCHECK 544#else
367# undef strdup 545# if __GNUC__ >= 11 && !defined strdup
368# if HAVE_RAW_DECL_STRDUP 546/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */
547_GL_FUNCDECL_SYS (strdup, char *,
548 (char const *__s)
549 _GL_ARG_NONNULL ((1))
550 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
551# endif
552# if defined GNULIB_POSIXCHECK
553# undef strdup
554# if HAVE_RAW_DECL_STRDUP
369_GL_WARN_ON_USE (strdup, "strdup is unportable - " 555_GL_WARN_ON_USE (strdup, "strdup is unportable - "
370 "use gnulib module strdup for portability"); 556 "use gnulib module strdup for portability");
557# endif
558# elif @GNULIB_MDA_STRDUP@
559/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
560 required. In C++ with GNULIB_NAMESPACE, avoid differences between
561 platforms by defining GNULIB_NAMESPACE::strdup always. */
562# if defined _WIN32 && !defined __CYGWIN__
563# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
564# undef strdup
565# define strdup _strdup
566# endif
567_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
568# else
569# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
570# undef strdup
571# endif
572_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
573# endif
574_GL_CXXALIASWARN (strdup);
371# endif 575# endif
372#endif 576#endif
373 577
@@ -378,13 +582,18 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - "
378# undef strncat 582# undef strncat
379# define strncat rpl_strncat 583# define strncat rpl_strncat
380# endif 584# endif
381_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) 585_GL_FUNCDECL_RPL (strncat, char *,
382 _GL_ARG_NONNULL ((1, 2))); 586 (char *restrict dest, const char *restrict src, size_t n)
383_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); 587 _GL_ARG_NONNULL ((1, 2)));
588_GL_CXXALIAS_RPL (strncat, char *,
589 (char *restrict dest, const char *restrict src, size_t n));
384# else 590# else
385_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); 591_GL_CXXALIAS_SYS (strncat, char *,
592 (char *restrict dest, const char *restrict src, size_t n));
386# endif 593# endif
594# if __GLIBC__ >= 2
387_GL_CXXALIASWARN (strncat); 595_GL_CXXALIASWARN (strncat);
596# endif
388#elif defined GNULIB_POSIXCHECK 597#elif defined GNULIB_POSIXCHECK
389# undef strncat 598# undef strncat
390# if HAVE_RAW_DECL_STRNCAT 599# if HAVE_RAW_DECL_STRNCAT
@@ -400,22 +609,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
400# undef strndup 609# undef strndup
401# define strndup rpl_strndup 610# define strndup rpl_strndup
402# endif 611# endif
403_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) 612_GL_FUNCDECL_RPL (strndup, char *,
404 _GL_ARG_NONNULL ((1))); 613 (char const *__s, size_t __n)
405_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); 614 _GL_ARG_NONNULL ((1))
615 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
616_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
406# else 617# else
407# if ! @HAVE_DECL_STRNDUP@ 618# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
408_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) 619_GL_FUNCDECL_SYS (strndup, char *,
409 _GL_ARG_NONNULL ((1))); 620 (char const *__s, size_t __n)
621 _GL_ARG_NONNULL ((1))
622 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
410# endif 623# endif
411_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); 624_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
412# endif 625# endif
413_GL_CXXALIASWARN (strndup); 626_GL_CXXALIASWARN (strndup);
414#elif defined GNULIB_POSIXCHECK 627#else
415# undef strndup 628# if __GNUC__ >= 11 && !defined strndup
416# if HAVE_RAW_DECL_STRNDUP 629/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
630_GL_FUNCDECL_SYS (strndup, char *,
631 (char const *__s, size_t __n)
632 _GL_ARG_NONNULL ((1))
633 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
634# endif
635# if defined GNULIB_POSIXCHECK
636# undef strndup
637# if HAVE_RAW_DECL_STRNDUP
417_GL_WARN_ON_USE (strndup, "strndup is unportable - " 638_GL_WARN_ON_USE (strndup, "strndup is unportable - "
418 "use gnulib module strndup for portability"); 639 "use gnulib module strndup for portability");
640# endif
419# endif 641# endif
420#endif 642#endif
421 643
@@ -428,17 +650,17 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
428# undef strnlen 650# undef strnlen
429# define strnlen rpl_strnlen 651# define strnlen rpl_strnlen
430# endif 652# endif
431_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) 653_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
432 _GL_ATTRIBUTE_PURE 654 _GL_ATTRIBUTE_PURE
433 _GL_ARG_NONNULL ((1))); 655 _GL_ARG_NONNULL ((1)));
434_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); 656_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
435# else 657# else
436# if ! @HAVE_DECL_STRNLEN@ 658# if ! @HAVE_DECL_STRNLEN@
437_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) 659_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
438 _GL_ATTRIBUTE_PURE 660 _GL_ATTRIBUTE_PURE
439 _GL_ARG_NONNULL ((1))); 661 _GL_ARG_NONNULL ((1)));
440# endif 662# endif
441_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); 663_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
442# endif 664# endif
443_GL_CXXALIASWARN (strnlen); 665_GL_CXXALIASWARN (strnlen);
444#elif defined GNULIB_POSIXCHECK 666#elif defined GNULIB_POSIXCHECK
@@ -475,11 +697,12 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
475 char *, (char const *__s, char const *__accept), 697 char *, (char const *__s, char const *__accept),
476 const char *, (char const *__s, char const *__accept)); 698 const char *, (char const *__s, char const *__accept));
477# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 699# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 700 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
479_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 701 || defined __clang__)
702_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
480_GL_CXXALIASWARN1 (strpbrk, char const *, 703_GL_CXXALIASWARN1 (strpbrk, char const *,
481 (char const *__s, char const *__accept)); 704 (char const *__s, char const *__accept) throw ());
482# else 705# elif __GLIBC__ >= 2
483_GL_CXXALIASWARN (strpbrk); 706_GL_CXXALIASWARN (strpbrk);
484# endif 707# endif
485# if defined GNULIB_POSIXCHECK 708# if defined GNULIB_POSIXCHECK
@@ -488,15 +711,19 @@ _GL_CXXALIASWARN (strpbrk);
488 locale encoding is GB18030 and one of the characters to be searched is a 711 locale encoding is GB18030 and one of the characters to be searched is a
489 digit. */ 712 digit. */
490# undef strpbrk 713# undef strpbrk
491_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " 714_GL_WARN_ON_USE_CXX (strpbrk,
492 "in multibyte locales - " 715 const char *, char *, (const char *, const char *),
493 "use mbspbrk if you care about internationalization"); 716 "strpbrk cannot work correctly on character strings "
717 "in multibyte locales - "
718 "use mbspbrk if you care about internationalization");
494# endif 719# endif
495#elif defined GNULIB_POSIXCHECK 720#elif defined GNULIB_POSIXCHECK
496# undef strpbrk 721# undef strpbrk
497# if HAVE_RAW_DECL_STRPBRK 722# if HAVE_RAW_DECL_STRPBRK
498_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " 723_GL_WARN_ON_USE_CXX (strpbrk,
499 "use gnulib module strpbrk for portability"); 724 const char *, char *, (const char *, const char *),
725 "strpbrk is unportable - "
726 "use gnulib module strpbrk for portability");
500# endif 727# endif
501#endif 728#endif
502 729
@@ -515,9 +742,11 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
515 GB18030 and the character to be searched is a digit. */ 742 GB18030 and the character to be searched is a digit. */
516# undef strrchr 743# undef strrchr
517/* Assume strrchr is always declared. */ 744/* Assume strrchr is always declared. */
518_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " 745_GL_WARN_ON_USE_CXX (strrchr,
519 "in some multibyte locales - " 746 const char *, char *, (const char *, int),
520 "use mbsrchr if you care about internationalization"); 747 "strrchr cannot work correctly on character strings "
748 "in some multibyte locales - "
749 "use mbsrchr if you care about internationalization");
521#endif 750#endif
522 751
523/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. 752/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -577,11 +806,13 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
577 const char *, (const char *haystack, const char *needle)); 806 const char *, (const char *haystack, const char *needle));
578# endif 807# endif
579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 808# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 809 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
581_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 810 || defined __clang__)
811_GL_CXXALIASWARN1 (strstr, char *,
812 (char *haystack, const char *needle) throw ());
582_GL_CXXALIASWARN1 (strstr, const char *, 813_GL_CXXALIASWARN1 (strstr, const char *,
583 (const char *haystack, const char *needle)); 814 (const char *haystack, const char *needle) throw ());
584# else 815# elif __GLIBC__ >= 2
585_GL_CXXALIASWARN (strstr); 816_GL_CXXALIASWARN (strstr);
586# endif 817# endif
587#elif defined GNULIB_POSIXCHECK 818#elif defined GNULIB_POSIXCHECK
@@ -626,10 +857,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
626 const char *, (const char *haystack, const char *needle)); 857 const char *, (const char *haystack, const char *needle));
627# endif 858# endif
628# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 859# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 860 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
630_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 861 || defined __clang__)
862_GL_CXXALIASWARN1 (strcasestr, char *,
863 (char *haystack, const char *needle) throw ());
631_GL_CXXALIASWARN1 (strcasestr, const char *, 864_GL_CXXALIASWARN1 (strcasestr, const char *,
632 (const char *haystack, const char *needle)); 865 (const char *haystack, const char *needle) throw ());
633# else 866# else
634_GL_CXXALIASWARN (strcasestr); 867_GL_CXXALIASWARN (strcasestr);
635# endif 868# endif
@@ -660,7 +893,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
660 This is a variant of strtok() that is multithread-safe. 893 This is a variant of strtok() that is multithread-safe.
661 894
662 For the POSIX documentation for this function, see: 895 For the POSIX documentation for this function, see:
663 http://www.opengroup.org/susv3xsh/strtok.html 896 https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
664 897
665 Caveat: It modifies the original string. 898 Caveat: It modifies the original string.
666 Caveat: These functions cannot be used on constant strings. 899 Caveat: These functions cannot be used on constant strings.
@@ -734,7 +967,9 @@ _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
734 _GL_ARG_NONNULL ((1))); 967 _GL_ARG_NONNULL ((1)));
735_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 968_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
736# endif 969# endif
970# if __GLIBC__ >= 2
737_GL_CXXALIASWARN (mbslen); 971_GL_CXXALIASWARN (mbslen);
972# endif
738#endif 973#endif
739 974
740#if @GNULIB_MBSNLEN@ 975#if @GNULIB_MBSNLEN@
@@ -931,7 +1166,8 @@ _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
931 Caveat: The identity of the delimiting character is lost. 1166 Caveat: The identity of the delimiting character is lost.
932 1167
933 See also mbssep(). */ 1168 See also mbssep(). */
934_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) 1169_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1170 char **save_ptr)
935 _GL_ARG_NONNULL ((2, 3)); 1171 _GL_ARG_NONNULL ((2, 3));
936#endif 1172#endif
937 1173
@@ -947,7 +1183,9 @@ _GL_CXXALIAS_RPL (strerror, char *, (int));
947# else 1183# else
948_GL_CXXALIAS_SYS (strerror, char *, (int)); 1184_GL_CXXALIAS_SYS (strerror, char *, (int));
949# endif 1185# endif
1186# if __GLIBC__ >= 2
950_GL_CXXALIASWARN (strerror); 1187_GL_CXXALIASWARN (strerror);
1188# endif
951#elif defined GNULIB_POSIXCHECK 1189#elif defined GNULIB_POSIXCHECK
952# undef strerror 1190# undef strerror
953/* Assume strerror is always declared. */ 1191/* Assume strerror is always declared. */
@@ -984,6 +1222,60 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
984# endif 1222# endif
985#endif 1223#endif
986 1224
1225/* Return the name of the system error code ERRNUM. */
1226#if @GNULIB_STRERRORNAME_NP@
1227# if @REPLACE_STRERRORNAME_NP@
1228# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1229# undef strerrorname_np
1230# define strerrorname_np rpl_strerrorname_np
1231# endif
1232_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum));
1233_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1234# else
1235# if !@HAVE_STRERRORNAME_NP@
1236_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum));
1237# endif
1238_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1239# endif
1240_GL_CXXALIASWARN (strerrorname_np);
1241#elif defined GNULIB_POSIXCHECK
1242# undef strerrorname_np
1243# if HAVE_RAW_DECL_STRERRORNAME_NP
1244_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1245 "use gnulib module strerrorname_np for portability");
1246# endif
1247#endif
1248
1249/* Return an abbreviation string for the signal number SIG. */
1250#if @GNULIB_SIGABBREV_NP@
1251# if ! @HAVE_SIGABBREV_NP@
1252_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig));
1253# endif
1254_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1255_GL_CXXALIASWARN (sigabbrev_np);
1256#elif defined GNULIB_POSIXCHECK
1257# undef sigabbrev_np
1258# if HAVE_RAW_DECL_SIGABBREV_NP
1259_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1260 "use gnulib module sigabbrev_np for portability");
1261# endif
1262#endif
1263
1264/* Return an English description string for the signal number SIG. */
1265#if @GNULIB_SIGDESCR_NP@
1266# if ! @HAVE_SIGDESCR_NP@
1267_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig));
1268# endif
1269_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1270_GL_CXXALIASWARN (sigdescr_np);
1271#elif defined GNULIB_POSIXCHECK
1272# undef sigdescr_np
1273# if HAVE_RAW_DECL_SIGDESCR_NP
1274_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1275 "use gnulib module sigdescr_np for portability");
1276# endif
1277#endif
1278
987#if @GNULIB_STRSIGNAL@ 1279#if @GNULIB_STRSIGNAL@
988# if @REPLACE_STRSIGNAL@ 1280# if @REPLACE_STRSIGNAL@
989# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1281# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1027,3 +1319,4 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1027 1319
1028#endif /* _@GUARD_PREFIX@_STRING_H */ 1320#endif /* _@GUARD_PREFIX@_STRING_H */
1029#endif /* _@GUARD_PREFIX@_STRING_H */ 1321#endif /* _@GUARD_PREFIX@_STRING_H */
1322#endif
diff --git a/gl/strings.in.h b/gl/strings.in.h
index 4469f86c..2cfe8b16 100644
--- a/gl/strings.in.h
+++ b/gl/strings.in.h
@@ -1,19 +1,19 @@
1/* A substitute <strings.h>. 1/* A substitute <strings.h>.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_STRINGS_H 18#ifndef _@GUARD_PREFIX@_STRINGS_H
19 19
diff --git a/gl/stripslash.c b/gl/stripslash.c
index 0e452a95..fe46a9c1 100644
--- a/gl/stripslash.c
+++ b/gl/stripslash.c
@@ -1,20 +1,20 @@
1/* stripslash.c -- remove redundant trailing slashes from a file name 1/* stripslash.c -- remove redundant trailing slashes from a file name
2 2
3 Copyright (C) 1990, 2001, 2003-2006, 2009-2013 Free Software Foundation, 3 Copyright (C) 1990, 2001, 2003-2006, 2009-2023 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/strncasecmp.c b/gl/strncasecmp.c
index 35840bc0..c5c2cd35 100644
--- a/gl/strncasecmp.c
+++ b/gl/strncasecmp.c
@@ -1,18 +1,18 @@
1/* strncasecmp.c -- case insensitive string comparator 1/* strncasecmp.c -- case insensitive string comparator
2 Copyright (C) 1998-1999, 2005-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
@@ -58,5 +58,5 @@ strncasecmp (const char *s1, const char *s2, size_t n)
58 /* On machines where 'char' and 'int' are types of the same size, the 58 /* On machines where 'char' and 'int' are types of the same size, the
59 difference of two 'unsigned char' values - including the sign bit - 59 difference of two 'unsigned char' values - including the sign bit -
60 doesn't fit in an 'int'. */ 60 doesn't fit in an 'int'. */
61 return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); 61 return _GL_CMP (c1, c2);
62} 62}
diff --git a/gl/strndup.c b/gl/strndup.c
deleted file mode 100644
index e60268b8..00000000
--- a/gl/strndup.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/* A replacement function, for systems that lack strndup.
2
3 Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2013 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18
19#include <config.h>
20
21#include <string.h>
22
23#include <stdlib.h>
24
25char *
26strndup (char const *s, size_t n)
27{
28 size_t len = strnlen (s, n);
29 char *new = malloc (len + 1);
30
31 if (new == NULL)
32 return NULL;
33
34 new[len] = '\0';
35 return memcpy (new, s, len);
36}
diff --git a/gl/strnlen.c b/gl/strnlen.c
deleted file mode 100644
index 57fdfe77..00000000
--- a/gl/strnlen.c
+++ /dev/null
@@ -1,30 +0,0 @@
1/* Find the length of STRING, but scan at most MAXLEN characters.
2 Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc.
3 Written by Simon Josefsson.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20#include <string.h>
21
22/* Find the length of STRING, but scan at most MAXLEN characters.
23 If no '\0' terminator is found in that many characters, return MAXLEN. */
24
25size_t
26strnlen (const char *string, size_t maxlen)
27{
28 const char *end = memchr (string, '\0', maxlen);
29 return end ? (size_t) (end - string) : maxlen;
30}
diff --git a/gl/strsep.c b/gl/strsep.c
index c51ac0d4..8e9708a3 100644
--- a/gl/strsep.c
+++ b/gl/strsep.c
@@ -1,19 +1,19 @@
1/* Copyright (C) 2004, 2007, 2009-2013 Free Software Foundation, Inc. 1/* Copyright (C) 2004, 2007, 2009-2023 Free Software Foundation, Inc.
2 2
3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifdef HAVE_CONFIG_H 18#ifdef HAVE_CONFIG_H
19# include <config.h> 19# include <config.h>
diff --git a/gl/strstr.c b/gl/strstr.c
index b91acec7..574f4d50 100644
--- a/gl/strstr.c
+++ b/gl/strstr.c
@@ -1,19 +1,19 @@
1/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2013 Free Software 1/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2023 Free Software
2 Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* This particular implementation was written by Eric Blake, 2008. */ 18/* This particular implementation was written by Eric Blake, 2008. */
19 19
@@ -24,12 +24,6 @@
24/* Specification of strstr. */ 24/* Specification of strstr. */
25#include <string.h> 25#include <string.h>
26 26
27#include <stdbool.h>
28
29#ifndef _LIBC
30# define __builtin_expect(expr, val) (expr)
31#endif
32
33#define RETURN_TYPE char * 27#define RETURN_TYPE char *
34#define AVAILABLE(h, h_l, j, n_l) \ 28#define AVAILABLE(h, h_l, j, n_l) \
35 (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ 29 (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \
diff --git a/gl/sys-limits.h b/gl/sys-limits.h
new file mode 100644
index 00000000..0e9556d6
--- /dev/null
+++ b/gl/sys-limits.h
@@ -0,0 +1,42 @@
1/* System call limits
2
3 Copyright 2018-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_SYS_LIMITS_H
19#define _GL_SYS_LIMITS_H
20
21#include <limits.h>
22
23/* Maximum number of bytes to read or write in a single system call.
24 This can be useful for system calls like sendfile on GNU/Linux,
25 which do not handle more than MAX_RW_COUNT bytes correctly.
26 The Linux kernel MAX_RW_COUNT is at least INT_MAX >> 20 << 20,
27 where the 20 comes from the Hexagon port with 1 MiB pages; use that
28 as an approximation, as the exact value may not be available to us.
29
30 Using this also works around a serious Linux bug before 2.6.16; see
31 <https://bugzilla.redhat.com/show_bug.cgi?id=612839>.
32
33 Using this also works around a Tru64 5.1 bug, where attempting
34 to read INT_MAX bytes fails with errno == EINVAL. See
35 <https://lists.gnu.org/r/bug-gnu-utils/2002-04/msg00010.html>.
36
37 Using this is likely to work around similar bugs in other operating
38 systems. */
39
40enum { SYS_BUFSIZE_MAX = INT_MAX >> 20 << 20 };
41
42#endif
diff --git a/gl/sys_socket.c b/gl/sys_socket.c
index 3f017f8f..b7388cec 100644
--- a/gl/sys_socket.c
+++ b/gl/sys_socket.c
@@ -1,3 +1,22 @@
1/* Inline functions for <sys/socket.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE 20#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE
3#include "sys/socket.h" 21#include "sys/socket.h"
22typedef int dummy;
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index b4cf0c39..6705593f 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -1,20 +1,20 @@
1/* Provide a sys/socket header file for systems lacking it (read: MinGW) 1/* Provide a sys/socket header file for systems lacking it (read: MinGW)
2 and for systems where it is incomplete. 2 and for systems where it is incomplete.
3 Copyright (C) 2005-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2023 Free Software Foundation, Inc.
4 Written by Simon Josefsson. 4 Written by Simon Josefsson.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* This file is supposed to be used on platforms that lack <sys/socket.h>, 19/* This file is supposed to be used on platforms that lack <sys/socket.h>,
20 on platforms where <sys/socket.h> cannot be included standalone, and on 20 on platforms where <sys/socket.h> cannot be included standalone, and on
@@ -63,6 +63,9 @@
63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H 63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
64#define _@GUARD_PREFIX@_SYS_SOCKET_H 64#define _@GUARD_PREFIX@_SYS_SOCKET_H
65 65
66#ifndef _GL_INLINE_HEADER_BEGIN
67 #error "Please include config.h first."
68#endif
66_GL_INLINE_HEADER_BEGIN 69_GL_INLINE_HEADER_BEGIN
67#ifndef _GL_SYS_SOCKET_INLINE 70#ifndef _GL_SYS_SOCKET_INLINE
68# define _GL_SYS_SOCKET_INLINE _GL_INLINE 71# define _GL_SYS_SOCKET_INLINE _GL_INLINE
@@ -76,7 +79,12 @@ _GL_INLINE_HEADER_BEGIN
76 79
77#if !@HAVE_SA_FAMILY_T@ 80#if !@HAVE_SA_FAMILY_T@
78# if !GNULIB_defined_sa_family_t 81# if !GNULIB_defined_sa_family_t
82/* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */
83# if !defined __KLIBC__ || defined TCPV40HDRS
79typedef unsigned short sa_family_t; 84typedef unsigned short sa_family_t;
85# else
86typedef unsigned char sa_family_t;
87# endif
80# define GNULIB_defined_sa_family_t 1 88# define GNULIB_defined_sa_family_t 1
81# endif 89# endif
82#endif 90#endif
@@ -89,7 +97,6 @@ typedef unsigned short sa_family_t;
89# endif 97# endif
90# endif 98# endif
91#else 99#else
92# include <stdalign.h>
93/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on 100/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
94 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ 101 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
95# define __ss_aligntype unsigned long int 102# define __ss_aligntype unsigned long int
@@ -133,6 +140,15 @@ struct sockaddr_storage
133# define SHUT_RDWR 2 140# define SHUT_RDWR 2
134# endif 141# endif
135 142
143# ifdef __VMS /* OpenVMS */
144# ifndef CMSG_SPACE
145# define CMSG_SPACE(length) _CMSG_SPACE(length)
146# endif
147# ifndef CMSG_LEN
148# define CMSG_LEN(length) _CMSG_LEN(length)
149# endif
150# endif
151
136#else 152#else
137 153
138# ifdef __CYGWIN__ 154# ifdef __CYGWIN__
@@ -152,7 +168,7 @@ struct sockaddr_storage
152 code may not run on older Windows releases then. My Windows 2000 168 code may not run on older Windows releases then. My Windows 2000
153 box was not able to run the code, for example. The situation is 169 box was not able to run the code, for example. The situation is
154 slightly confusing because 170 slightly confusing because
155 <http://msdn.microsoft.com/en-us/library/ms738520> 171 <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
156 suggests that getaddrinfo should be available on all Windows 172 suggests that getaddrinfo should be available on all Windows
157 releases. */ 173 releases. */
158 174
@@ -178,12 +194,7 @@ struct sockaddr_storage
178/* Include headers needed by the emulation code. */ 194/* Include headers needed by the emulation code. */
179# include <sys/types.h> 195# include <sys/types.h>
180# include <io.h> 196# include <io.h>
181 197/* If these headers don't define socklen_t, <config.h> does. */
182# if !GNULIB_defined_socklen_t
183typedef int socklen_t;
184# define GNULIB_defined_socklen_t 1
185# endif
186
187# endif 198# endif
188 199
189/* Rudimentary 'struct msghdr'; this works as long as you don't try to 200/* Rudimentary 'struct msghdr'; this works as long as you don't try to
@@ -198,6 +209,15 @@ struct msghdr {
198 209
199#endif 210#endif
200 211
212/* Ensure SO_REUSEPORT is defined. */
213/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
214 https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
215 and https://lwn.net/Articles/542629/
216 */
217#ifndef SO_REUSEPORT
218# define SO_REUSEPORT SO_REUSEADDR
219#endif
220
201/* Fix some definitions from <winsock2.h>. */ 221/* Fix some definitions from <winsock2.h>. */
202 222
203#if @HAVE_WINSOCK2_H@ 223#if @HAVE_WINSOCK2_H@
@@ -235,7 +255,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
235# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
236# undef close 256# undef close
237# define close close_used_without_including_unistd_h 257# define close close_used_without_including_unistd_h
238# else 258# elif !defined __clang__
239 _GL_WARN_ON_USE (close, 259 _GL_WARN_ON_USE (close,
240 "close() used without including <unistd.h>"); 260 "close() used without including <unistd.h>");
241# endif 261# endif
@@ -320,14 +340,20 @@ _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
320# define accept rpl_accept 340# define accept rpl_accept
321# endif 341# endif
322_GL_FUNCDECL_RPL (accept, int, 342_GL_FUNCDECL_RPL (accept, int,
323 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 343 (int fd,
344 struct sockaddr *restrict addr,
345 socklen_t *restrict addrlen));
324_GL_CXXALIAS_RPL (accept, int, 346_GL_CXXALIAS_RPL (accept, int,
325 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 347 (int fd,
348 struct sockaddr *restrict addr,
349 socklen_t *restrict addrlen));
326# else 350# else
327/* Need to cast, because on Solaris 10 systems, the third parameter is 351/* Need to cast, because on Solaris 10 systems, the third parameter is
328 void *addrlen. */ 352 void *addrlen. */
329_GL_CXXALIAS_SYS_CAST (accept, int, 353_GL_CXXALIAS_SYS_CAST (accept, int,
330 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 354 (int fd,
355 struct sockaddr *restrict addr,
356 socklen_t *restrict addrlen));
331# endif 357# endif
332_GL_CXXALIASWARN (accept); 358_GL_CXXALIASWARN (accept);
333#elif @HAVE_WINSOCK2_H@ 359#elif @HAVE_WINSOCK2_H@
@@ -378,15 +404,18 @@ _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
378# define getpeername rpl_getpeername 404# define getpeername rpl_getpeername
379# endif 405# endif
380_GL_FUNCDECL_RPL (getpeername, int, 406_GL_FUNCDECL_RPL (getpeername, int,
381 (int fd, struct sockaddr *addr, socklen_t *addrlen) 407 (int fd, struct sockaddr *restrict addr,
408 socklen_t *restrict addrlen)
382 _GL_ARG_NONNULL ((2, 3))); 409 _GL_ARG_NONNULL ((2, 3)));
383_GL_CXXALIAS_RPL (getpeername, int, 410_GL_CXXALIAS_RPL (getpeername, int,
384 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 411 (int fd, struct sockaddr *restrict addr,
412 socklen_t *restrict addrlen));
385# else 413# else
386/* Need to cast, because on Solaris 10 systems, the third parameter is 414/* Need to cast, because on Solaris 10 systems, the third parameter is
387 void *addrlen. */ 415 void *addrlen. */
388_GL_CXXALIAS_SYS_CAST (getpeername, int, 416_GL_CXXALIAS_SYS_CAST (getpeername, int,
389 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 417 (int fd, struct sockaddr *restrict addr,
418 socklen_t *restrict addrlen));
390# endif 419# endif
391_GL_CXXALIASWARN (getpeername); 420_GL_CXXALIASWARN (getpeername);
392#elif @HAVE_WINSOCK2_H@ 421#elif @HAVE_WINSOCK2_H@
@@ -407,15 +436,18 @@ _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
407# define getsockname rpl_getsockname 436# define getsockname rpl_getsockname
408# endif 437# endif
409_GL_FUNCDECL_RPL (getsockname, int, 438_GL_FUNCDECL_RPL (getsockname, int,
410 (int fd, struct sockaddr *addr, socklen_t *addrlen) 439 (int fd, struct sockaddr *restrict addr,
440 socklen_t *restrict addrlen)
411 _GL_ARG_NONNULL ((2, 3))); 441 _GL_ARG_NONNULL ((2, 3)));
412_GL_CXXALIAS_RPL (getsockname, int, 442_GL_CXXALIAS_RPL (getsockname, int,
413 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 443 (int fd, struct sockaddr *restrict addr,
444 socklen_t *restrict addrlen));
414# else 445# else
415/* Need to cast, because on Solaris 10 systems, the third parameter is 446/* Need to cast, because on Solaris 10 systems, the third parameter is
416 void *addrlen. */ 447 void *addrlen. */
417_GL_CXXALIAS_SYS_CAST (getsockname, int, 448_GL_CXXALIAS_SYS_CAST (getsockname, int,
418 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 449 (int fd, struct sockaddr *restrict addr,
450 socklen_t *restrict addrlen));
419# endif 451# endif
420_GL_CXXALIASWARN (getsockname); 452_GL_CXXALIASWARN (getsockname);
421#elif @HAVE_WINSOCK2_H@ 453#elif @HAVE_WINSOCK2_H@
@@ -435,16 +467,19 @@ _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
435# undef getsockopt 467# undef getsockopt
436# define getsockopt rpl_getsockopt 468# define getsockopt rpl_getsockopt
437# endif 469# endif
438_GL_FUNCDECL_RPL (getsockopt, int, (int fd, int level, int optname, 470_GL_FUNCDECL_RPL (getsockopt, int,
439 void *optval, socklen_t *optlen) 471 (int fd, int level, int optname,
440 _GL_ARG_NONNULL ((4, 5))); 472 void *restrict optval, socklen_t *restrict optlen)
441_GL_CXXALIAS_RPL (getsockopt, int, (int fd, int level, int optname, 473 _GL_ARG_NONNULL ((4, 5)));
442 void *optval, socklen_t *optlen)); 474_GL_CXXALIAS_RPL (getsockopt, int,
475 (int fd, int level, int optname,
476 void *restrict optval, socklen_t *restrict optlen));
443# else 477# else
444/* Need to cast, because on Solaris 10 systems, the fifth parameter is 478/* Need to cast, because on Solaris 10 systems, the fifth parameter is
445 void *optlen. */ 479 void *optlen. */
446_GL_CXXALIAS_SYS_CAST (getsockopt, int, (int fd, int level, int optname, 480_GL_CXXALIAS_SYS_CAST (getsockopt, int,
447 void *optval, socklen_t *optlen)); 481 (int fd, int level, int optname,
482 void *restrict optval, socklen_t *restrict optlen));
448# endif 483# endif
449_GL_CXXALIASWARN (getsockopt); 484_GL_CXXALIASWARN (getsockopt);
450#elif @HAVE_WINSOCK2_H@ 485#elif @HAVE_WINSOCK2_H@
@@ -491,7 +526,10 @@ _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
491 _GL_ARG_NONNULL ((2))); 526 _GL_ARG_NONNULL ((2)));
492_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); 527_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
493# else 528# else
494_GL_CXXALIAS_SYS (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); 529/* Need to cast, because on HP-UX 11.31 the return type may be
530 int,
531 depending on compiler options. */
532_GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
495# endif 533# endif
496_GL_CXXALIASWARN (recv); 534_GL_CXXALIASWARN (recv);
497#elif @HAVE_WINSOCK2_H@ 535#elif @HAVE_WINSOCK2_H@
@@ -517,8 +555,11 @@ _GL_FUNCDECL_RPL (send, ssize_t,
517_GL_CXXALIAS_RPL (send, ssize_t, 555_GL_CXXALIAS_RPL (send, ssize_t,
518 (int fd, const void *buf, size_t len, int flags)); 556 (int fd, const void *buf, size_t len, int flags));
519# else 557# else
520_GL_CXXALIAS_SYS (send, ssize_t, 558/* Need to cast, because on HP-UX 11.31 the return type may be
521 (int fd, const void *buf, size_t len, int flags)); 559 int,
560 depending on compiler options. */
561_GL_CXXALIAS_SYS_CAST (send, ssize_t,
562 (int fd, const void *buf, size_t len, int flags));
522# endif 563# endif
523_GL_CXXALIASWARN (send); 564_GL_CXXALIASWARN (send);
524#elif @HAVE_WINSOCK2_H@ 565#elif @HAVE_WINSOCK2_H@
@@ -539,18 +580,21 @@ _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
539# define recvfrom rpl_recvfrom 580# define recvfrom rpl_recvfrom
540# endif 581# endif
541_GL_FUNCDECL_RPL (recvfrom, ssize_t, 582_GL_FUNCDECL_RPL (recvfrom, ssize_t,
542 (int fd, void *buf, size_t len, int flags, 583 (int fd, void *restrict buf, size_t len, int flags,
543 struct sockaddr *from, socklen_t *fromlen) 584 struct sockaddr *restrict from,
585 socklen_t *restrict fromlen)
544 _GL_ARG_NONNULL ((2))); 586 _GL_ARG_NONNULL ((2)));
545_GL_CXXALIAS_RPL (recvfrom, ssize_t, 587_GL_CXXALIAS_RPL (recvfrom, ssize_t,
546 (int fd, void *buf, size_t len, int flags, 588 (int fd, void *restrict buf, size_t len, int flags,
547 struct sockaddr *from, socklen_t *fromlen)); 589 struct sockaddr *restrict from,
590 socklen_t *restrict fromlen));
548# else 591# else
549/* Need to cast, because on Solaris 10 systems, the sixth parameter is 592/* Need to cast, because on Solaris 10 systems, the sixth parameter is
550 void *fromlen. */ 593 void *fromlen. */
551_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, 594_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
552 (int fd, void *buf, size_t len, int flags, 595 (int fd, void *restrict buf, size_t len, int flags,
553 struct sockaddr *from, socklen_t *fromlen)); 596 struct sockaddr *restrict from,
597 socklen_t *restrict fromlen));
554# endif 598# endif
555_GL_CXXALIASWARN (recvfrom); 599_GL_CXXALIASWARN (recvfrom);
556#elif @HAVE_WINSOCK2_H@ 600#elif @HAVE_WINSOCK2_H@
@@ -654,7 +698,7 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
654 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) 698 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
655 and O_TEXT, O_BINARY (defined in "binary-io.h"). 699 and O_TEXT, O_BINARY (defined in "binary-io.h").
656 See also the Linux man page at 700 See also the Linux man page at
657 <http://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */ 701 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
658# if @HAVE_ACCEPT4@ 702# if @HAVE_ACCEPT4@
659# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 703# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
660# define accept4 rpl_accept4 704# define accept4 rpl_accept4
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
new file mode 100644
index 00000000..096887c0
--- /dev/null
+++ b/gl/sys_stat.in.h
@@ -0,0 +1,954 @@
1/* Provide a more complete sys/stat.h header file.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
18
19/* This file is supposed to be used on platforms where <sys/stat.h> is
20 incomplete. It is intended to provide definitions and prototypes
21 needed by an application. Start with what the system provides. */
22
23#if __GNUC__ >= 3
24@PRAGMA_SYSTEM_HEADER@
25#endif
26@PRAGMA_COLUMNS@
27
28#if defined __need_system_sys_stat_h
29/* Special invocation convention. */
30
31#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
32
33#else
34/* Normal invocation convention. */
35
36#ifndef _@GUARD_PREFIX@_SYS_STAT_H
37
38/* Get nlink_t.
39 May also define off_t to a 64-bit type on native Windows. */
40#include <sys/types.h>
41
42/* Get struct timespec. */
43#include <time.h>
44
45/* The include_next requires a split double-inclusion guard. */
46#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
47
48#ifndef _@GUARD_PREFIX@_SYS_STAT_H
49#define _@GUARD_PREFIX@_SYS_STAT_H
50
51/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52
53/* The definition of _GL_ARG_NONNULL is copied here. */
54
55/* The definition of _GL_WARN_ON_USE is copied here. */
56
57/* Before doing "#define mknod rpl_mknod" below, we need to include all
58 headers that may declare mknod(). OS/2 kLIBC declares mknod() in
59 <unistd.h>, not in <sys/stat.h>. */
60#ifdef __KLIBC__
61# include <unistd.h>
62#endif
63
64/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
65 headers that may declare mkdir(). Native Windows platforms declare mkdir
66 in <io.h> and/or <direct.h>, not in <sys/stat.h>. */
67#if defined _WIN32 && ! defined __CYGWIN__
68# include <io.h> /* mingw32, mingw64 */
69# include <direct.h> /* mingw64, MSVC 9 */
70#endif
71
72/* Native Windows platforms declare umask() in <io.h>. */
73#if 0 && (defined _WIN32 && ! defined __CYGWIN__)
74# include <io.h>
75#endif
76
77/* Large File Support on native Windows. */
78#if @WINDOWS_64_BIT_ST_SIZE@
79# define stat _stati64
80#endif
81
82/* Optionally, override 'struct stat' on native Windows. */
83#if @GNULIB_OVERRIDES_STRUCT_STAT@
84
85# undef stat
86# if @GNULIB_STAT@
87# define stat rpl_stat
88# else
89 /* Provoke a clear link error if stat() is used as a function and
90 module 'stat' is not in use. */
91# define stat stat_used_without_requesting_gnulib_module_stat
92# endif
93
94# if !GNULIB_defined_struct_stat
95struct stat
96{
97 dev_t st_dev;
98 ino_t st_ino;
99 mode_t st_mode;
100 nlink_t st_nlink;
101# if 0
102 uid_t st_uid;
103# else /* uid_t is not defined by default on native Windows. */
104 short st_uid;
105# endif
106# if 0
107 gid_t st_gid;
108# else /* gid_t is not defined by default on native Windows. */
109 short st_gid;
110# endif
111 dev_t st_rdev;
112 off_t st_size;
113# if 0
114 blksize_t st_blksize;
115 blkcnt_t st_blocks;
116# endif
117
118# if @WINDOWS_STAT_TIMESPEC@
119 struct timespec st_atim;
120 struct timespec st_mtim;
121 struct timespec st_ctim;
122# else
123 time_t st_atime;
124 time_t st_mtime;
125 time_t st_ctime;
126# endif
127};
128# if @WINDOWS_STAT_TIMESPEC@
129# define st_atime st_atim.tv_sec
130# define st_mtime st_mtim.tv_sec
131# define st_ctime st_ctim.tv_sec
132 /* Indicator, for gnulib internal purposes. */
133# define _GL_WINDOWS_STAT_TIMESPEC 1
134# endif
135# define GNULIB_defined_struct_stat 1
136# endif
137
138/* Other possible values of st_mode. */
139# if 0
140# define _S_IFBLK 0x6000
141# endif
142# if 0
143# define _S_IFLNK 0xA000
144# endif
145# if 0
146# define _S_IFSOCK 0xC000
147# endif
148
149#endif
150
151#ifndef S_IFIFO
152# ifdef _S_IFIFO
153# define S_IFIFO _S_IFIFO
154# endif
155#endif
156
157#ifndef S_IFMT
158# define S_IFMT 0170000
159#endif
160
161#if STAT_MACROS_BROKEN
162# undef S_ISBLK
163# undef S_ISCHR
164# undef S_ISDIR
165# undef S_ISFIFO
166# undef S_ISLNK
167# undef S_ISNAM
168# undef S_ISMPB
169# undef S_ISMPC
170# undef S_ISNWK
171# undef S_ISREG
172# undef S_ISSOCK
173#endif
174
175#ifndef S_ISBLK
176# ifdef S_IFBLK
177# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
178# else
179# define S_ISBLK(m) 0
180# endif
181#endif
182
183#ifndef S_ISCHR
184# ifdef S_IFCHR
185# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
186# else
187# define S_ISCHR(m) 0
188# endif
189#endif
190
191#ifndef S_ISDIR
192# ifdef S_IFDIR
193# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
194# else
195# define S_ISDIR(m) 0
196# endif
197#endif
198
199#ifndef S_ISDOOR /* Solaris 2.5 and up */
200# define S_ISDOOR(m) 0
201#endif
202
203#ifndef S_ISFIFO
204# ifdef S_IFIFO
205# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
206# else
207# define S_ISFIFO(m) 0
208# endif
209#endif
210
211#ifndef S_ISLNK
212# ifdef S_IFLNK
213# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
214# else
215# define S_ISLNK(m) 0
216# endif
217#endif
218
219#ifndef S_ISMPB /* V7 */
220# ifdef S_IFMPB
221# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
222# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
223# else
224# define S_ISMPB(m) 0
225# define S_ISMPC(m) 0
226# endif
227#endif
228
229#ifndef S_ISMPX /* AIX */
230# define S_ISMPX(m) 0
231#endif
232
233#ifndef S_ISNAM /* Xenix */
234# ifdef S_IFNAM
235# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
236# else
237# define S_ISNAM(m) 0
238# endif
239#endif
240
241#ifndef S_ISNWK /* HP/UX */
242# ifdef S_IFNWK
243# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
244# else
245# define S_ISNWK(m) 0
246# endif
247#endif
248
249#ifndef S_ISPORT /* Solaris 10 and up */
250# define S_ISPORT(m) 0
251#endif
252
253#ifndef S_ISREG
254# ifdef S_IFREG
255# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
256# else
257# define S_ISREG(m) 0
258# endif
259#endif
260
261#ifndef S_ISSOCK
262# ifdef S_IFSOCK
263# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
264# else
265# define S_ISSOCK(m) 0
266# endif
267#endif
268
269
270#ifndef S_TYPEISMQ
271# define S_TYPEISMQ(p) 0
272#endif
273
274#ifndef S_TYPEISTMO
275# define S_TYPEISTMO(p) 0
276#endif
277
278
279#ifndef S_TYPEISSEM
280# ifdef S_INSEM
281# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
282# else
283# define S_TYPEISSEM(p) 0
284# endif
285#endif
286
287#ifndef S_TYPEISSHM
288# ifdef S_INSHD
289# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
290# else
291# define S_TYPEISSHM(p) 0
292# endif
293#endif
294
295/* high performance ("contiguous data") */
296#ifndef S_ISCTG
297# define S_ISCTG(p) 0
298#endif
299
300/* Cray DMF (data migration facility): off line, with data */
301#ifndef S_ISOFD
302# define S_ISOFD(p) 0
303#endif
304
305/* Cray DMF (data migration facility): off line, with no data */
306#ifndef S_ISOFL
307# define S_ISOFL(p) 0
308#endif
309
310/* 4.4BSD whiteout */
311#ifndef S_ISWHT
312# define S_ISWHT(m) 0
313#endif
314
315/* If any of the following are undefined,
316 define them to their de facto standard values. */
317#if !S_ISUID
318# define S_ISUID 04000
319#endif
320#if !S_ISGID
321# define S_ISGID 02000
322#endif
323
324/* S_ISVTX is a common extension to POSIX. */
325#ifndef S_ISVTX
326# define S_ISVTX 01000
327#endif
328
329#if !S_IRUSR && S_IREAD
330# define S_IRUSR S_IREAD
331#endif
332#if !S_IRUSR
333# define S_IRUSR 00400
334#endif
335#if !S_IRGRP
336# define S_IRGRP (S_IRUSR >> 3)
337#endif
338#if !S_IROTH
339# define S_IROTH (S_IRUSR >> 6)
340#endif
341
342#if !S_IWUSR && S_IWRITE
343# define S_IWUSR S_IWRITE
344#endif
345#if !S_IWUSR
346# define S_IWUSR 00200
347#endif
348#if !S_IWGRP
349# define S_IWGRP (S_IWUSR >> 3)
350#endif
351#if !S_IWOTH
352# define S_IWOTH (S_IWUSR >> 6)
353#endif
354
355#if !S_IXUSR && S_IEXEC
356# define S_IXUSR S_IEXEC
357#endif
358#if !S_IXUSR
359# define S_IXUSR 00100
360#endif
361#if !S_IXGRP
362# define S_IXGRP (S_IXUSR >> 3)
363#endif
364#if !S_IXOTH
365# define S_IXOTH (S_IXUSR >> 6)
366#endif
367
368#if !S_IRWXU
369# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
370#endif
371#if !S_IRWXG
372# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
373#endif
374#if !S_IRWXO
375# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
376#endif
377
378/* Although S_IXUGO and S_IRWXUGO are not specified by POSIX and are
379 not implemented in GNU/Linux, some Gnulib-using apps use the macros. */
380#if !S_IXUGO
381# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
382#endif
383#ifndef S_IRWXUGO
384# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
385#endif
386
387/* Macros for futimens and utimensat. */
388#ifndef UTIME_NOW
389# define UTIME_NOW (-1)
390# define UTIME_OMIT (-2)
391#endif
392
393
394#if @GNULIB_CHMOD@
395# if @REPLACE_CHMOD@
396# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
397# undef chmod
398# define chmod rpl_chmod
399# endif
400_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode)
401 _GL_ARG_NONNULL ((1)));
402_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
403# elif defined _WIN32 && !defined __CYGWIN__
404# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
405# undef chmod
406# define chmod _chmod
407# endif
408/* Need to cast, because in mingw the last argument is 'int mode'. */
409_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
410# else
411_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
412# endif
413_GL_CXXALIASWARN (chmod);
414#elif defined GNULIB_POSIXCHECK
415# undef chmod
416# if HAVE_RAW_DECL_CHMOD
417_GL_WARN_ON_USE (chmod, "chmod has portability problems - "
418 "use gnulib module chmod for portability");
419# endif
420#elif @GNULIB_MDA_CHMOD@
421/* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
422 required. In C++ with GNULIB_NAMESPACE, avoid differences between
423 platforms by defining GNULIB_NAMESPACE::chmod always. */
424# if defined _WIN32 && !defined __CYGWIN__
425# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
426# undef chmod
427# define chmod _chmod
428# endif
429/* Need to cast, because in mingw the last argument is 'int mode'. */
430_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
431# else
432_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
433# endif
434_GL_CXXALIASWARN (chmod);
435#endif
436
437
438#if @GNULIB_FCHMODAT@
439# if @REPLACE_FCHMODAT@
440# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
441# undef fchmodat
442# define fchmodat rpl_fchmodat
443# endif
444_GL_FUNCDECL_RPL (fchmodat, int,
445 (int fd, char const *file, mode_t mode, int flag)
446 _GL_ARG_NONNULL ((2)));
447_GL_CXXALIAS_RPL (fchmodat, int,
448 (int fd, char const *file, mode_t mode, int flag));
449# else
450# if !@HAVE_FCHMODAT@
451_GL_FUNCDECL_SYS (fchmodat, int,
452 (int fd, char const *file, mode_t mode, int flag)
453 _GL_ARG_NONNULL ((2)));
454# endif
455_GL_CXXALIAS_SYS (fchmodat, int,
456 (int fd, char const *file, mode_t mode, int flag));
457# endif
458_GL_CXXALIASWARN (fchmodat);
459#elif defined GNULIB_POSIXCHECK
460# undef fchmodat
461# if HAVE_RAW_DECL_FCHMODAT
462_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
463 "use gnulib module openat for portability");
464# endif
465#endif
466
467
468#if @GNULIB_FSTAT@
469# if @REPLACE_FSTAT@
470# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
471# undef fstat
472# define fstat rpl_fstat
473# endif
474_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
475_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
476# else
477_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
478# endif
479# if __GLIBC__ >= 2
480_GL_CXXALIASWARN (fstat);
481# endif
482#elif @GNULIB_OVERRIDES_STRUCT_STAT@
483# undef fstat
484# define fstat fstat_used_without_requesting_gnulib_module_fstat
485#elif @WINDOWS_64_BIT_ST_SIZE@
486/* Above, we define stat to _stati64. */
487# define fstat _fstati64
488#elif defined GNULIB_POSIXCHECK
489# undef fstat
490# if HAVE_RAW_DECL_FSTAT
491_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
492 "use gnulib module fstat for portability");
493# endif
494#endif
495
496
497#if @GNULIB_FSTATAT@
498# if @REPLACE_FSTATAT@
499# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500# undef fstatat
501# define fstatat rpl_fstatat
502# endif
503_GL_FUNCDECL_RPL (fstatat, int,
504 (int fd, char const *restrict name, struct stat *restrict st,
505 int flags)
506 _GL_ARG_NONNULL ((2, 3)));
507_GL_CXXALIAS_RPL (fstatat, int,
508 (int fd, char const *restrict name, struct stat *restrict st,
509 int flags));
510# else
511# if !@HAVE_FSTATAT@
512_GL_FUNCDECL_SYS (fstatat, int,
513 (int fd, char const *restrict name, struct stat *restrict st,
514 int flags)
515 _GL_ARG_NONNULL ((2, 3)));
516# endif
517_GL_CXXALIAS_SYS (fstatat, int,
518 (int fd, char const *restrict name, struct stat *restrict st,
519 int flags));
520# endif
521_GL_CXXALIASWARN (fstatat);
522#elif @GNULIB_OVERRIDES_STRUCT_STAT@
523# undef fstatat
524# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
525#elif defined GNULIB_POSIXCHECK
526# undef fstatat
527# if HAVE_RAW_DECL_FSTATAT
528_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
529 "use gnulib module openat for portability");
530# endif
531#endif
532
533
534#if @GNULIB_FUTIMENS@
535/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
536 implementation relies on futimesat, which on Solaris 10 makes an invocation
537 to futimens that is meant to invoke the libc's futimens(), not gnulib's
538 futimens(). */
539# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
540# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
541# undef futimens
542# define futimens rpl_futimens
543# endif
544_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
545_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
546# else
547# if !@HAVE_FUTIMENS@
548_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
549# endif
550_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
551# endif
552# if @HAVE_FUTIMENS@
553_GL_CXXALIASWARN (futimens);
554# endif
555#elif defined GNULIB_POSIXCHECK
556# undef futimens
557# if HAVE_RAW_DECL_FUTIMENS
558_GL_WARN_ON_USE (futimens, "futimens is not portable - "
559 "use gnulib module futimens for portability");
560# endif
561#endif
562
563
564#if @GNULIB_GETUMASK@
565# if !@HAVE_GETUMASK@
566_GL_FUNCDECL_SYS (getumask, mode_t, (void));
567# endif
568_GL_CXXALIAS_SYS (getumask, mode_t, (void));
569# if @HAVE_GETUMASK@
570_GL_CXXALIASWARN (getumask);
571# endif
572#elif defined GNULIB_POSIXCHECK
573# undef getumask
574# if HAVE_RAW_DECL_GETUMASK
575_GL_WARN_ON_USE (getumask, "getumask is not portable - "
576 "use gnulib module getumask for portability");
577# endif
578#endif
579
580
581#if @GNULIB_LCHMOD@
582/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
583 denotes a symbolic link. */
584# if !@HAVE_LCHMOD@ || defined __hpux
585_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
586 _GL_ARG_NONNULL ((1)));
587# endif
588_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
589_GL_CXXALIASWARN (lchmod);
590#elif defined GNULIB_POSIXCHECK
591# undef lchmod
592# if HAVE_RAW_DECL_LCHMOD
593_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
594 "use gnulib module lchmod for portability");
595# endif
596#endif
597
598
599#if @GNULIB_MKDIR@
600# if @REPLACE_MKDIR@
601# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602# undef mkdir
603# define mkdir rpl_mkdir
604# endif
605_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
606 _GL_ARG_NONNULL ((1)));
607_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
608# elif defined _WIN32 && !defined __CYGWIN__
609/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
610 Additionally, it declares _mkdir (and depending on compile flags, an
611 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
612 which are included above. */
613# if !GNULIB_defined_rpl_mkdir
614static int
615rpl_mkdir (char const *name, mode_t mode)
616{
617 return _mkdir (name);
618}
619# define GNULIB_defined_rpl_mkdir 1
620# endif
621# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
622# undef mkdir
623# define mkdir rpl_mkdir
624# endif
625_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
626# else
627_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
628# endif
629_GL_CXXALIASWARN (mkdir);
630#elif defined GNULIB_POSIXCHECK
631# undef mkdir
632# if HAVE_RAW_DECL_MKDIR
633_GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
634 "use gnulib module mkdir for portability");
635# endif
636#elif @GNULIB_MDA_MKDIR@
637/* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
638 required. In C++ with GNULIB_NAMESPACE, avoid differences between
639 platforms by defining GNULIB_NAMESPACE::mkdir always. */
640# if defined _WIN32 && !defined __CYGWIN__
641# if !GNULIB_defined_rpl_mkdir
642static int
643rpl_mkdir (char const *name, mode_t mode)
644{
645 return _mkdir (name);
646}
647# define GNULIB_defined_rpl_mkdir 1
648# endif
649# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650# undef mkdir
651# define mkdir rpl_mkdir
652# endif
653_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
654# else
655_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
656# endif
657_GL_CXXALIASWARN (mkdir);
658#endif
659
660
661#if @GNULIB_MKDIRAT@
662# if !@HAVE_MKDIRAT@
663_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
664 _GL_ARG_NONNULL ((2)));
665# endif
666_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
667_GL_CXXALIASWARN (mkdirat);
668#elif defined GNULIB_POSIXCHECK
669# undef mkdirat
670# if HAVE_RAW_DECL_MKDIRAT
671_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
672 "use gnulib module openat for portability");
673# endif
674#endif
675
676
677#if @GNULIB_MKFIFO@
678# if @REPLACE_MKFIFO@
679# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
680# undef mkfifo
681# define mkfifo rpl_mkfifo
682# endif
683_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
684 _GL_ARG_NONNULL ((1)));
685_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
686# else
687# if !@HAVE_MKFIFO@
688_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
689 _GL_ARG_NONNULL ((1)));
690# endif
691_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
692# endif
693_GL_CXXALIASWARN (mkfifo);
694#elif defined GNULIB_POSIXCHECK
695# undef mkfifo
696# if HAVE_RAW_DECL_MKFIFO
697_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
698 "use gnulib module mkfifo for portability");
699# endif
700#endif
701
702
703#if @GNULIB_MKFIFOAT@
704# if @REPLACE_MKFIFOAT@
705# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706# undef mkfifoat
707# define mkfifoat rpl_mkfifoat
708# endif
709_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)
710 _GL_ARG_NONNULL ((2)));
711_GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
712# else
713# if !@HAVE_MKFIFOAT@
714_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
715 _GL_ARG_NONNULL ((2)));
716# endif
717_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
718# endif
719_GL_CXXALIASWARN (mkfifoat);
720#elif defined GNULIB_POSIXCHECK
721# undef mkfifoat
722# if HAVE_RAW_DECL_MKFIFOAT
723_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
724 "use gnulib module mkfifoat for portability");
725# endif
726#endif
727
728
729#if @GNULIB_MKNOD@
730# if @REPLACE_MKNOD@
731# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
732# undef mknod
733# define mknod rpl_mknod
734# endif
735_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
736 _GL_ARG_NONNULL ((1)));
737_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
738# else
739# if !@HAVE_MKNOD@
740_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
741 _GL_ARG_NONNULL ((1)));
742# endif
743/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
744_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
745# endif
746_GL_CXXALIASWARN (mknod);
747#elif defined GNULIB_POSIXCHECK
748# undef mknod
749# if HAVE_RAW_DECL_MKNOD
750_GL_WARN_ON_USE (mknod, "mknod is not portable - "
751 "use gnulib module mknod for portability");
752# endif
753#endif
754
755
756#if @GNULIB_MKNODAT@
757# if @REPLACE_MKNODAT@
758# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
759# undef mknodat
760# define mknodat rpl_mknodat
761# endif
762_GL_FUNCDECL_RPL (mknodat, int,
763 (int fd, char const *file, mode_t mode, dev_t dev)
764 _GL_ARG_NONNULL ((2)));
765_GL_CXXALIAS_RPL (mknodat, int,
766 (int fd, char const *file, mode_t mode, dev_t dev));
767# else
768# if !@HAVE_MKNODAT@
769_GL_FUNCDECL_SYS (mknodat, int,
770 (int fd, char const *file, mode_t mode, dev_t dev)
771 _GL_ARG_NONNULL ((2)));
772# endif
773_GL_CXXALIAS_SYS (mknodat, int,
774 (int fd, char const *file, mode_t mode, dev_t dev));
775# endif
776_GL_CXXALIASWARN (mknodat);
777#elif defined GNULIB_POSIXCHECK
778# undef mknodat
779# if HAVE_RAW_DECL_MKNODAT
780_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
781 "use gnulib module mkfifoat for portability");
782# endif
783#endif
784
785
786#if @GNULIB_STAT@
787# if @REPLACE_STAT@
788# if !@GNULIB_OVERRIDES_STRUCT_STAT@
789 /* We can't use the object-like #define stat rpl_stat, because of
790 struct stat. This means that rpl_stat will not be used if the user
791 does (stat)(a,b). Oh well. */
792# if defined _AIX && defined stat && defined _LARGE_FILES
793 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
794 so we have to replace stat64() instead of stat(). */
795# undef stat64
796# define stat64(name, st) rpl_stat (name, st)
797# elif @WINDOWS_64_BIT_ST_SIZE@
798 /* Above, we define stat to _stati64. */
799# if defined __MINGW32__ && defined _stati64
800# ifndef _USE_32BIT_TIME_T
801 /* The system headers define _stati64 to _stat64. */
802# undef _stat64
803# define _stat64(name, st) rpl_stat (name, st)
804# endif
805# elif defined _MSC_VER && defined _stati64
806# ifdef _USE_32BIT_TIME_T
807 /* The system headers define _stati64 to _stat32i64. */
808# undef _stat32i64
809# define _stat32i64(name, st) rpl_stat (name, st)
810# else
811 /* The system headers define _stati64 to _stat64. */
812# undef _stat64
813# define _stat64(name, st) rpl_stat (name, st)
814# endif
815# else
816# undef _stati64
817# define _stati64(name, st) rpl_stat (name, st)
818# endif
819# elif defined __MINGW32__ && defined stat
820# ifdef _USE_32BIT_TIME_T
821 /* The system headers define stat to _stat32i64. */
822# undef _stat32i64
823# define _stat32i64(name, st) rpl_stat (name, st)
824# else
825 /* The system headers define stat to _stat64. */
826# undef _stat64
827# define _stat64(name, st) rpl_stat (name, st)
828# endif
829# elif defined _MSC_VER && defined stat
830# ifdef _USE_32BIT_TIME_T
831 /* The system headers define stat to _stat32. */
832# undef _stat32
833# define _stat32(name, st) rpl_stat (name, st)
834# else
835 /* The system headers define stat to _stat64i32. */
836# undef _stat64i32
837# define _stat64i32(name, st) rpl_stat (name, st)
838# endif
839# else /* !(_AIX || __MINGW32__ || _MSC_VER) */
840# undef stat
841# define stat(name, st) rpl_stat (name, st)
842# endif /* !_LARGE_FILES */
843# endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
844_GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf)
845 _GL_ARG_NONNULL ((1, 2));
846# endif
847#elif @GNULIB_OVERRIDES_STRUCT_STAT@
848/* see above:
849 #define stat stat_used_without_requesting_gnulib_module_stat
850 */
851#elif defined GNULIB_POSIXCHECK
852# undef stat
853# if HAVE_RAW_DECL_STAT
854_GL_WARN_ON_USE (stat, "stat is unportable - "
855 "use gnulib module stat for portability");
856# endif
857#endif
858
859
860#if @GNULIB_LSTAT@
861# if ! @HAVE_LSTAT@
862/* mingw does not support symlinks, therefore it does not have lstat. But
863 without links, stat does just fine. */
864# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
865# define lstat stat
866# endif
867_GL_CXXALIAS_RPL_1 (lstat, stat, int,
868 (const char *restrict name, struct stat *restrict buf));
869# elif @REPLACE_LSTAT@
870# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
871# undef lstat
872# define lstat rpl_lstat
873# endif
874_GL_FUNCDECL_RPL (lstat, int,
875 (const char *restrict name, struct stat *restrict buf)
876 _GL_ARG_NONNULL ((1, 2)));
877_GL_CXXALIAS_RPL (lstat, int,
878 (const char *restrict name, struct stat *restrict buf));
879# else
880_GL_CXXALIAS_SYS (lstat, int,
881 (const char *restrict name, struct stat *restrict buf));
882# endif
883# if @HAVE_LSTAT@
884_GL_CXXALIASWARN (lstat);
885# endif
886#elif @GNULIB_OVERRIDES_STRUCT_STAT@
887# undef lstat
888# define lstat lstat_used_without_requesting_gnulib_module_lstat
889#elif defined GNULIB_POSIXCHECK
890# undef lstat
891# if HAVE_RAW_DECL_LSTAT
892_GL_WARN_ON_USE (lstat, "lstat is unportable - "
893 "use gnulib module lstat for portability");
894# endif
895#endif
896
897
898#if @GNULIB_MDA_UMASK@
899/* On native Windows, map 'umask' to '_umask', so that -loldnames is not
900 required. In C++ with GNULIB_NAMESPACE, avoid differences between
901 platforms by defining GNULIB_NAMESPACE::umask always. */
902# if defined _WIN32 && !defined __CYGWIN__
903# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
904# undef umask
905# define umask _umask
906# endif
907/* Need to cast, because in mingw the last argument is 'int mode'. */
908_GL_CXXALIAS_MDA_CAST (umask, mode_t, (mode_t mask));
909# else
910_GL_CXXALIAS_SYS (umask, mode_t, (mode_t mask));
911# endif
912_GL_CXXALIASWARN (umask);
913#endif
914
915
916#if @GNULIB_UTIMENSAT@
917/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
918 implementation relies on futimesat, which on Solaris 10 makes an invocation
919 to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
920 utimensat(). */
921# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
922# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
923# undef utimensat
924# define utimensat rpl_utimensat
925# endif
926_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
927 struct timespec const times[2], int flag)
928 _GL_ARG_NONNULL ((2)));
929_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
930 struct timespec const times[2], int flag));
931# else
932# if !@HAVE_UTIMENSAT@
933_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
934 struct timespec const times[2], int flag)
935 _GL_ARG_NONNULL ((2)));
936# endif
937_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
938 struct timespec const times[2], int flag));
939# endif
940# if @HAVE_UTIMENSAT@
941_GL_CXXALIASWARN (utimensat);
942# endif
943#elif defined GNULIB_POSIXCHECK
944# undef utimensat
945# if HAVE_RAW_DECL_UTIMENSAT
946_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
947 "use gnulib module utimensat for portability");
948# endif
949#endif
950
951
952#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
953#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
954#endif
diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h
index d7da3562..082a6c67 100644
--- a/gl/sys_types.in.h
+++ b/gl/sys_types.in.h
@@ -1,29 +1,42 @@
1/* Provide a more complete sys/types.h. 1/* Provide a more complete sys/types.h.
2 2
3 Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined _WIN32 && !defined __CYGWIN__ \
24 && (defined __need_off_t || defined __need___off64_t \
25 || defined __need_ssize_t || defined __need_time_t)
26
27/* Special invocation convention inside mingw header files. */
28
29#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
30
31#else
32/* Normal invocation convention. */
33
23#ifndef _@GUARD_PREFIX@_SYS_TYPES_H 34#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
24 35
25/* The include_next requires a split double-inclusion guard. */ 36/* The include_next requires a split double-inclusion guard. */
37# define _GL_INCLUDING_SYS_TYPES_H
26#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ 38#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
39# undef _GL_INCLUDING_SYS_TYPES_H
27 40
28#ifndef _@GUARD_PREFIX@_SYS_TYPES_H 41#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
29#define _@GUARD_PREFIX@_SYS_TYPES_H 42#define _@GUARD_PREFIX@_SYS_TYPES_H
@@ -40,12 +53,54 @@
40# define _GL_WINDOWS_64_BIT_OFF_T 1 53# define _GL_WINDOWS_64_BIT_OFF_T 1
41#endif 54#endif
42 55
56/* Override dev_t and ino_t if distinguishable inodes support is requested
57 on native Windows. */
58#if @WINDOWS_STAT_INODES@
59
60# if @WINDOWS_STAT_INODES@ == 2
61/* Experimental, not useful in Windows 10. */
62
63/* Define dev_t to a 64-bit type. */
64# if !defined GNULIB_defined_dev_t
65typedef unsigned long long int rpl_dev_t;
66# undef dev_t
67# define dev_t rpl_dev_t
68# define GNULIB_defined_dev_t 1
69# endif
70
71/* Define ino_t to a 128-bit type. */
72# if !defined GNULIB_defined_ino_t
73/* MSVC does not have a 128-bit integer type.
74 GCC has a 128-bit integer type __int128, but only on 64-bit targets. */
75typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t;
76# undef ino_t
77# define ino_t rpl_ino_t
78# define GNULIB_defined_ino_t 1
79# endif
80
81# else /* @WINDOWS_STAT_INODES@ == 1 */
82
83/* Define ino_t to a 64-bit type. */
84# if !defined GNULIB_defined_ino_t
85typedef unsigned long long int rpl_ino_t;
86# undef ino_t
87# define ino_t rpl_ino_t
88# define GNULIB_defined_ino_t 1
89# endif
90
91# endif
92
93/* Indicator, for gnulib internal purposes. */
94# define _GL_WINDOWS_STAT_INODES @WINDOWS_STAT_INODES@
95
96#endif
97
43/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */ 98/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
44/* But avoid namespace pollution on glibc systems. */ 99/* But avoid namespace pollution on glibc systems. */
45#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \ 100#if (defined _WIN32 && ! defined __CYGWIN__) && ! defined __GLIBC__
46 && ! defined __GLIBC__
47# include <stddef.h> 101# include <stddef.h>
48#endif 102#endif
49 103
50#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ 104#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
51#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ 105#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
106#endif /* __need_XXX */
diff --git a/gl/sys_uio.in.h b/gl/sys_uio.in.h
index fef19dc3..64c4fb6d 100644
--- a/gl/sys_uio.in.h
+++ b/gl/sys_uio.in.h
@@ -1,18 +1,18 @@
1/* Substitute for <sys/uio.h>. 1/* Substitute for <sys/uio.h>.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17# if __GNUC__ >= 3 17# if __GNUC__ >= 3
18@PRAGMA_SYSTEM_HEADER@ 18@PRAGMA_SYSTEM_HEADER@
diff --git a/gl/time.in.h b/gl/time.in.h
index 8ced7947..50c9b30b 100644
--- a/gl/time.in.h
+++ b/gl/time.in.h
@@ -1,19 +1,19 @@
1/* A more-standard <time.h>. 1/* A more-standard <time.h>.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
@@ -22,11 +22,13 @@
22 22
23/* Don't get in the way of glibc when it includes time.h merely to 23/* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the 24 declare a few standard symbols, rather than to declare all the
25 symbols. Also, Solaris 8 <time.h> eventually includes itself 25 symbols. (However, skip this for MinGW as it treats __need_time_t
26 incompatibly.) Also, Solaris 8 <time.h> eventually includes itself
26 recursively; if that is happening, just include the system <time.h> 27 recursively; if that is happening, just include the system <time.h>
27 without adding our own declarations. */ 28 without adding our own declarations. */
28#if (defined __need_time_t || defined __need_clock_t \ 29#if (((defined __need_time_t || defined __need_clock_t \
29 || defined __need_timespec \ 30 || defined __need_timespec) \
31 && !defined __MINGW32__) \
30 || defined _@GUARD_PREFIX@_TIME_H) 32 || defined _@GUARD_PREFIX@_TIME_H)
31 33
32# @INCLUDE_NEXT@ @NEXT_TIME_H@ 34# @INCLUDE_NEXT@ @NEXT_TIME_H@
@@ -35,6 +37,12 @@
35 37
36# define _@GUARD_PREFIX@_TIME_H 38# define _@GUARD_PREFIX@_TIME_H
37 39
40/* mingw's <time.h> provides the functions asctime_r, ctime_r, gmtime_r,
41 localtime_r only if <unistd.h> or <pthread.h> has been included before. */
42# if defined __MINGW32__
43# include <unistd.h>
44# endif
45
38# @INCLUDE_NEXT@ @NEXT_TIME_H@ 46# @INCLUDE_NEXT@ @NEXT_TIME_H@
39 47
40/* NetBSD 5.0 mis-defines NULL. */ 48/* NetBSD 5.0 mis-defines NULL. */
@@ -46,22 +54,17 @@
46 54
47/* The definition of _GL_WARN_ON_USE is copied here. */ 55/* The definition of _GL_WARN_ON_USE is copied here. */
48 56
49/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). 57/* Some systems don't define struct timespec (e.g., AIX 4.1).
50 Or they define it with the wrong member names or define it in <sys/time.h> 58 Or they define it with the wrong member names or define it in <sys/time.h>
51 (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the 59 (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it,
52 pthreads-win32 library defines it in <pthread.h>. */ 60 but the pthreads-win32 library defines it in <pthread.h>. */
53# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ 61# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
54# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ 62# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
55# include <sys/time.h> 63# include <sys/time.h>
56# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ 64# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
57# include <pthread.h> 65# include <pthread.h>
58/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */ 66# elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
59# undef asctime_r 67# include <unistd.h>
60# undef ctime_r
61# undef gmtime_r
62# undef localtime_r
63# undef rand_r
64# undef strtok_r
65# else 68# else
66 69
67# ifdef __cplusplus 70# ifdef __cplusplus
@@ -87,8 +90,8 @@ struct timespec
87# endif 90# endif
88 91
89# if !GNULIB_defined_struct_time_t_must_be_integral 92# if !GNULIB_defined_struct_time_t_must_be_integral
90/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires 93/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
91 time_t to be an integer type, even though C99 permits floating 94 requires time_t to be an integer type, even though C99 permits floating
92 point. We don't know of any implementation that uses floating 95 point. We don't know of any implementation that uses floating
93 point, and it is much easier to write code that doesn't have to 96 point, and it is much easier to write code that doesn't have to
94 worry about that corner case, so we force the issue. */ 97 worry about that corner case, so we force the issue. */
@@ -98,9 +101,39 @@ struct __time_t_must_be_integral {
98# define GNULIB_defined_struct_time_t_must_be_integral 1 101# define GNULIB_defined_struct_time_t_must_be_integral 1
99# endif 102# endif
100 103
104/* Define TIME_UTC, a positive integer constant used for timespec_get(). */
105# if ! @TIME_H_DEFINES_TIME_UTC@
106# if !GNULIB_defined_TIME_UTC
107# define TIME_UTC 1
108# define GNULIB_defined_TIME_UTC 1
109# endif
110# endif
111
112/* Set *TS to the current time, and return BASE.
113 Upon failure, return 0. */
114# if @GNULIB_TIMESPEC_GET@
115# if ! @HAVE_TIMESPEC_GET@
116_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
117 _GL_ARG_NONNULL ((1)));
118# endif
119_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
120_GL_CXXALIASWARN (timespec_get);
121# endif
122
123/* Set *TS to the current time resolution, and return BASE.
124 Upon failure, return 0. */
125# if @GNULIB_TIMESPEC_GETRES@
126# if ! @HAVE_TIMESPEC_GETRES@
127_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base)
128 _GL_ARG_NONNULL ((1)));
129# endif
130_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
131_GL_CXXALIASWARN (timespec_getres);
132# endif
133
101/* Sleep for at least RQTP seconds unless interrupted, If interrupted, 134/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
102 return -1 and store the remaining time into RMTP. See 135 return -1 and store the remaining time into RMTP. See
103 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */ 136 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */
104# if @GNULIB_NANOSLEEP@ 137# if @GNULIB_NANOSLEEP@
105# if @REPLACE_NANOSLEEP@ 138# if @REPLACE_NANOSLEEP@
106# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 139# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -123,6 +156,41 @@ _GL_CXXALIAS_SYS (nanosleep, int,
123_GL_CXXALIASWARN (nanosleep); 156_GL_CXXALIASWARN (nanosleep);
124# endif 157# endif
125 158
159/* Initialize time conversion information. */
160# if @GNULIB_TZSET@
161# if @REPLACE_TZSET@
162# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163# undef tzset
164# define tzset rpl_tzset
165# endif
166_GL_FUNCDECL_RPL (tzset, void, (void));
167_GL_CXXALIAS_RPL (tzset, void, (void));
168# elif defined _WIN32 && !defined __CYGWIN__
169# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
170# undef tzset
171# define tzset _tzset
172# endif
173_GL_CXXALIAS_MDA (tzset, void, (void));
174# else
175_GL_CXXALIAS_SYS (tzset, void, (void));
176# endif
177_GL_CXXALIASWARN (tzset);
178# elif @GNULIB_MDA_TZSET@
179/* On native Windows, map 'tzset' to '_tzset', so that -loldnames is not
180 required. In C++ with GNULIB_NAMESPACE, avoid differences between
181 platforms by defining GNULIB_NAMESPACE::tzset always. */
182# if defined _WIN32 && !defined __CYGWIN__
183# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184# undef tzset
185# define tzset _tzset
186# endif
187_GL_CXXALIAS_MDA (tzset, void, (void));
188# else
189_GL_CXXALIAS_SYS (tzset, void, (void));
190# endif
191_GL_CXXALIASWARN (tzset);
192# endif
193
126/* Return the 'time_t' representation of TP and normalize TP. */ 194/* Return the 'time_t' representation of TP and normalize TP. */
127# if @GNULIB_MKTIME@ 195# if @GNULIB_MKTIME@
128# if @REPLACE_MKTIME@ 196# if @REPLACE_MKTIME@
@@ -134,12 +202,14 @@ _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
134# else 202# else
135_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); 203_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
136# endif 204# endif
205# if __GLIBC__ >= 2
137_GL_CXXALIASWARN (mktime); 206_GL_CXXALIASWARN (mktime);
207# endif
138# endif 208# endif
139 209
140/* Convert TIMER to RESULT, assuming local time and UTC respectively. See 210/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
141 <http://www.opengroup.org/susv3xsh/localtime_r.html> and 211 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html> and
142 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */ 212 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html>. */
143# if @GNULIB_TIME_R@ 213# if @GNULIB_TIME_R@
144# if @REPLACE_LOCALTIME_R@ 214# if @REPLACE_LOCALTIME_R@
145# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 215# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -187,9 +257,44 @@ _GL_CXXALIASWARN (gmtime_r);
187# endif 257# endif
188# endif 258# endif
189 259
190/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store 260/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
261 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html> and
262 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html>. */
263# if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
264# if @REPLACE_LOCALTIME@
265# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
266# undef localtime
267# define localtime rpl_localtime
268# endif
269_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
270 _GL_ARG_NONNULL ((1)));
271_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
272# else
273_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
274# endif
275# if __GLIBC__ >= 2
276_GL_CXXALIASWARN (localtime);
277# endif
278# endif
279
280# if 0 || @REPLACE_GMTIME@
281# if @REPLACE_GMTIME@
282# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
283# undef gmtime
284# define gmtime rpl_gmtime
285# endif
286_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
287 _GL_ARG_NONNULL ((1)));
288_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
289# else
290_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
291# endif
292_GL_CXXALIASWARN (gmtime);
293# endif
294
295/* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
191 the resulting broken-down time into TM. See 296 the resulting broken-down time into TM. See
192 <http://www.opengroup.org/susv3xsh/strptime.html>. */ 297 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html>. */
193# if @GNULIB_STRPTIME@ 298# if @GNULIB_STRPTIME@
194# if ! @HAVE_STRPTIME@ 299# if ! @HAVE_STRPTIME@
195_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, 300_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
@@ -203,6 +308,106 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
203_GL_CXXALIASWARN (strptime); 308_GL_CXXALIASWARN (strptime);
204# endif 309# endif
205 310
311/* Convert *TP to a date and time string. See
312 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
313# if @GNULIB_CTIME@
314# if @REPLACE_CTIME@
315# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316# define ctime rpl_ctime
317# endif
318_GL_ATTRIBUTE_DEPRECATED
319_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
320 _GL_ARG_NONNULL ((1)));
321_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
322# else
323_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
324# endif
325# if __GLIBC__ >= 2
326_GL_CXXALIASWARN (ctime);
327# endif
328# endif
329
330/* Convert *TP to a date and time string. See
331 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
332# if @GNULIB_STRFTIME@
333# if @REPLACE_STRFTIME@
334# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
335# define strftime rpl_strftime
336# endif
337_GL_FUNCDECL_RPL (strftime, size_t,
338 (char *restrict __buf, size_t __bufsize,
339 const char *restrict __fmt, const struct tm *restrict __tp)
340 _GL_ARG_NONNULL ((1, 3, 4)));
341_GL_CXXALIAS_RPL (strftime, size_t,
342 (char *restrict __buf, size_t __bufsize,
343 const char *restrict __fmt, const struct tm *restrict __tp));
344# else
345_GL_CXXALIAS_SYS (strftime, size_t,
346 (char *restrict __buf, size_t __bufsize,
347 const char *restrict __fmt, const struct tm *restrict __tp));
348# endif
349# if __GLIBC__ >= 2
350_GL_CXXALIASWARN (strftime);
351# endif
352# endif
353
354# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
355/* Functions that use a first-class time zone data type, instead of
356 relying on an implicit global time zone.
357 Inspired by NetBSD. */
358
359/* Represents a time zone.
360 (timezone_t) NULL stands for UTC. */
361typedef struct tm_zone *timezone_t;
362
363/* tzalloc (name)
364 Returns a time zone object for the given time zone NAME. This object
365 represents the time zone that other functions would use it the TZ
366 environment variable was set to NAME.
367 If NAME is NULL, the result represents the time zone that other functions
368 would use it the TZ environment variable was unset.
369 May return NULL if NAME is invalid (this is platform dependent) or
370 upon memory allocation failure. */
371_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
372_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
373
374/* tzfree (tz)
375 Frees a time zone object.
376 The argument must have been returned by tzalloc(). */
377_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
378_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
379
380/* localtime_rz (tz, &t, &result)
381 Converts an absolute time T to a broken-down time RESULT, assuming the
382 time zone TZ.
383 This function is like 'localtime_r', but relies on the argument TZ instead
384 of an implicit global time zone. */
385_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
386 (timezone_t __tz, time_t const *restrict __timer,
387 struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
388_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
389 (timezone_t __tz, time_t const *restrict __timer,
390 struct tm *restrict __result));
391
392/* mktime_z (tz, &tm)
393 Normalizes the broken-down time TM and converts it to an absolute time,
394 assuming the time zone TZ. Returns the absolute time.
395 This function is like 'mktime', but relies on the argument TZ instead
396 of an implicit global time zone. */
397_GL_FUNCDECL_SYS (mktime_z, time_t,
398 (timezone_t __tz, struct tm *restrict __tm)
399 _GL_ARG_NONNULL ((2)));
400_GL_CXXALIAS_SYS (mktime_z, time_t,
401 (timezone_t __tz, struct tm *restrict __tm));
402
403/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z'
404 in the 'tm_zone' member of 'struct tm') are valid as long as
405 - the 'struct tm' argument is not destroyed or overwritten,
406 and
407 - the 'timezone_t' argument is not freed through tzfree(). */
408
409# endif
410
206/* Convert TM to a time_t value, assuming UTC. */ 411/* Convert TM to a time_t value, assuming UTC. */
207# if @GNULIB_TIMEGM@ 412# if @GNULIB_TIMEGM@
208# if @REPLACE_TIMEGM@ 413# if @REPLACE_TIMEGM@
@@ -231,18 +436,22 @@ _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
231# endif 436# endif
232# if defined GNULIB_POSIXCHECK 437# if defined GNULIB_POSIXCHECK
233# undef asctime_r 438# undef asctime_r
234_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " 439# if HAVE_RAW_DECL_ASCTIME_R
440_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
235 "better use strftime (or even sprintf) instead"); 441 "better use strftime (or even sprintf) instead");
442# endif
236# endif 443# endif
237# if defined GNULIB_POSIXCHECK 444# if defined GNULIB_POSIXCHECK
238# undef ctime 445# undef ctime
239_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " 446_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
240 "better use strftime (or even sprintf) instead"); 447 "better use strftime (or even sprintf) instead");
241# endif 448# endif
242# if defined GNULIB_POSIXCHECK 449# if defined GNULIB_POSIXCHECK
243# undef ctime_r 450# undef ctime_r
244_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " 451# if HAVE_RAW_DECL_CTIME_R
452_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
245 "better use strftime (or even sprintf) instead"); 453 "better use strftime (or even sprintf) instead");
454# endif
246# endif 455# endif
247 456
248#endif 457#endif
diff --git a/gl/time_r.c b/gl/time_r.c
index 98662998..97be4fd0 100644
--- a/gl/time_r.c
+++ b/gl/time_r.c
@@ -1,19 +1,19 @@
1/* Reentrant time functions like localtime_r. 1/* Reentrant time functions like localtime_r.
2 2
3 Copyright (C) 2003, 2006-2007, 2010-2013 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2006-2007, 2010-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paul Eggert. */ 18/* Written by Paul Eggert. */
19 19
diff --git a/gl/timegm.c b/gl/timegm.c
index 6338baa3..b47025a0 100644
--- a/gl/timegm.c
+++ b/gl/timegm.c
@@ -1,38 +1,58 @@
1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC. 1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
2 2
3 Copyright (C) 1994, 1997, 2003-2004, 2006-2007, 2009-2013 Free Software 3 Copyright (C) 1994-2023 Free Software Foundation, Inc.
4 Foundation, Inc. This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
9 any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifndef _LIBC 20#ifndef _LIBC
20# include <config.h> 21# include <libc-config.h>
21#endif 22#endif
22 23
23#include <time.h> 24#include <time.h>
25#include <errno.h>
24 26
25#ifndef _LIBC 27#include "mktime-internal.h"
26# undef __gmtime_r 28
27# define __gmtime_r gmtime_r 29__time64_t
28# define __mktime_internal mktime_internal 30__timegm64 (struct tm *tmp)
29# include "mktime-internal.h" 31{
30#endif 32 static mktime_offset_t gmtime_offset;
33 tmp->tm_isdst = 0;
34 return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset);
35}
36
37#if defined _LIBC && __TIMESIZE != 64
38
39libc_hidden_def (__timegm64)
31 40
32time_t 41time_t
33timegm (struct tm *tmp) 42timegm (struct tm *tmp)
34{ 43{
35 static time_t gmtime_offset; 44 struct tm tm = *tmp;
36 tmp->tm_isdst = 0; 45 __time64_t t = __timegm64 (&tm);
37 return __mktime_internal (tmp, __gmtime_r, &gmtime_offset); 46 if (in_time_t_range (t))
47 {
48 *tmp = tm;
49 return t;
50 }
51 else
52 {
53 __set_errno (EOVERFLOW);
54 return -1;
55 }
38} 56}
57
58#endif
diff --git a/gl/unistd.c b/gl/unistd.c
index 6c6a8e26..be7a8255 100644
--- a/gl/unistd.c
+++ b/gl/unistd.c
@@ -1,3 +1,22 @@
1/* Inline functions for <unistd.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE 20#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
3#include "unistd.h" 21#include "unistd.h"
22typedef int dummy;
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 2ea9af43..4812fdb1 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -1,18 +1,18 @@
1/* Substitute for and wrapper around <unistd.h>. 1/* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc. 2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _@GUARD_PREFIX@_UNISTD_H 17#ifndef _@GUARD_PREFIX@_UNISTD_H
18 18
@@ -21,9 +21,23 @@
21#endif 21#endif
22@PRAGMA_COLUMNS@ 22@PRAGMA_COLUMNS@
23 23
24#if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H
25/* Special invocation convention:
26 - On Mac OS X 10.3.9 we have a sequence of nested includes
27 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases. */
30
31#@INCLUDE_NEXT@ @NEXT_UNISTD_H@
32
33#else
34/* Normal invocation convention. */
35
24/* The include_next requires a split double-inclusion guard. */ 36/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_UNISTD_H@ 37#if @HAVE_UNISTD_H@
38# define _GL_INCLUDING_UNISTD_H
26# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ 39# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40# undef _GL_INCLUDING_UNISTD_H
27#endif 41#endif
28 42
29/* Get all possible declarations of gethostname(). */ 43/* Get all possible declarations of gethostname(). */
@@ -38,21 +52,30 @@
38#define _@GUARD_PREFIX@_UNISTD_H 52#define _@GUARD_PREFIX@_UNISTD_H
39 53
40/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ 54/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
41#include <stddef.h> 55/* But avoid namespace pollution on glibc systems. */
56#ifndef __GLIBC__
57# include <stddef.h>
58#endif
42 59
43/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */ 60/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61/* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
62 it before we #define unlink rpl_unlink. */
44/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */ 63/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
45/* But avoid namespace pollution on glibc systems. */ 64/* But avoid namespace pollution on glibc systems. */
46#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ 65#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
66 || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
67 && (defined _WIN32 && ! defined __CYGWIN__)) \
47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ 68 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \ 69 && defined __CYGWIN__)) \
49 && ! defined __GLIBC__ 70 && ! defined __GLIBC__
50# include <stdio.h> 71# include <stdio.h>
51#endif 72#endif
52 73
53/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ 74/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
75 <unistd.h>. */
54/* But avoid namespace pollution on glibc systems. */ 76/* But avoid namespace pollution on glibc systems. */
55#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ 77#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
78 && (defined __CYGWIN__ || defined __ANDROID__) \
56 && ! defined __GLIBC__ 79 && ! defined __GLIBC__
57# include <fcntl.h> 80# include <fcntl.h>
58#endif 81#endif
@@ -70,20 +93,18 @@
70# undef __need_system_stdlib_h 93# undef __need_system_stdlib_h
71#endif 94#endif
72 95
73/* Native Windows platforms declare chdir, getcwd, rmdir in 96/* Native Windows platforms declare _chdir, _getcwd, _rmdir in
74 <io.h> and/or <direct.h>, not in <unistd.h>. 97 <io.h> and/or <direct.h>, not in <unistd.h>.
75 They also declare access(), chmod(), close(), dup(), dup2(), isatty(), 98 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
76 lseek(), read(), unlink(), write() in <io.h>. */ 99 _lseek(), _read(), _unlink(), _write() in <io.h>. */
77#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \ 100#if defined _WIN32 && !defined __CYGWIN__
78 || defined GNULIB_POSIXCHECK) \
79 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
80# include <io.h> /* mingw32, mingw64 */
81# include <direct.h> /* mingw64, MSVC 9 */
82#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
83 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
84 || defined GNULIB_POSIXCHECK) \
85 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
86# include <io.h> 101# include <io.h>
102# include <direct.h>
103#endif
104
105/* Native Windows platforms declare _execl*, _execv* in <process.h>. */
106#if defined _WIN32 && !defined __CYGWIN__
107# include <process.h>
87#endif 108#endif
88 109
89/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. 110/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
@@ -95,31 +116,28 @@
95# include <netdb.h> 116# include <netdb.h>
96#endif 117#endif
97 118
98/* MSVC defines off_t in <sys/types.h>. 119/* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
99 May also define off_t to a 64-bit type on native Windows. */ 120 <sys/random.h>, not in <unistd.h>. */
100#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@ 121/* But avoid namespace pollution on glibc systems. */
101/* Get off_t. */ 122#if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
102# include <sys/types.h> 123 && ((defined __APPLE__ && defined __MACH__) || defined __sun \
103#endif 124 || defined __ANDROID__) \
104 125 && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
105#if (@GNULIB_READ@ || @GNULIB_WRITE@ \ 126 && !defined __GLIBC__
106 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ 127# include <sys/random.h>
107 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
108/* Get ssize_t. */
109# include <sys/types.h>
110#endif 128#endif
111 129
112/* Get getopt(), optarg, optind, opterr, optopt. 130/* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
113 But avoid namespace pollution on glibc systems. */ 131/* But avoid namespace pollution on glibc systems. */
114#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT 132#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
115# define __need_getopt 133 && !defined __GLIBC__
116# include <getopt.h> 134# include <sys/stat.h>
117#endif 135#endif
118 136
119_GL_INLINE_HEADER_BEGIN 137/* MSVC defines off_t in <sys/types.h>.
120#ifndef _GL_UNISTD_INLINE 138 May also define off_t to a 64-bit type on native Windows. */
121# define _GL_UNISTD_INLINE _GL_INLINE 139/* Get off_t, ssize_t, mode_t. */
122#endif 140#include <sys/types.h>
123 141
124/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 142/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
125 143
@@ -128,6 +146,20 @@ _GL_INLINE_HEADER_BEGIN
128/* The definition of _GL_WARN_ON_USE is copied here. */ 146/* The definition of _GL_WARN_ON_USE is copied here. */
129 147
130 148
149/* Get getopt(), optarg, optind, opterr, optopt. */
150#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
151# include <getopt-cdefs.h>
152# include <getopt-pfx-core.h>
153#endif
154
155#ifndef _GL_INLINE_HEADER_BEGIN
156 #error "Please include config.h first."
157#endif
158_GL_INLINE_HEADER_BEGIN
159#ifndef _GL_UNISTD_INLINE
160# define _GL_UNISTD_INLINE _GL_INLINE
161#endif
162
131/* Hide some function declarations from <winsock2.h>. */ 163/* Hide some function declarations from <winsock2.h>. */
132 164
133#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ 165#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
@@ -227,15 +259,61 @@ _GL_INLINE_HEADER_BEGIN
227/* Declare overridden functions. */ 259/* Declare overridden functions. */
228 260
229 261
230#if defined GNULIB_POSIXCHECK 262#if @GNULIB_ACCESS@
263# if @REPLACE_ACCESS@
264# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
265# undef access
266# define access rpl_access
267# endif
268_GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
269 _GL_ARG_NONNULL ((1)));
270_GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
271# elif defined _WIN32 && !defined __CYGWIN__
272# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273# undef access
274# define access _access
275# endif
276_GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
277# else
278_GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
279# endif
280_GL_CXXALIASWARN (access);
281#elif defined GNULIB_POSIXCHECK
282# undef access
283# if HAVE_RAW_DECL_ACCESS
231/* The access() function is a security risk. */ 284/* The access() function is a security risk. */
232_GL_WARN_ON_USE (access, "the access function is a security risk - " 285_GL_WARN_ON_USE (access, "access does not always support X_OK - "
286 "use gnulib module access for portability; "
287 "also, this function is a security risk - "
233 "use the gnulib module faccessat instead"); 288 "use the gnulib module faccessat instead");
289# endif
290#elif @GNULIB_MDA_ACCESS@
291/* On native Windows, map 'access' to '_access', so that -loldnames is not
292 required. In C++ with GNULIB_NAMESPACE, avoid differences between
293 platforms by defining GNULIB_NAMESPACE::access always. */
294# if defined _WIN32 && !defined __CYGWIN__
295# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
296# undef access
297# define access _access
298# endif
299_GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
300# else
301_GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
302# endif
303_GL_CXXALIASWARN (access);
234#endif 304#endif
235 305
236 306
237#if @GNULIB_CHDIR@ 307#if @GNULIB_CHDIR@
308# if defined _WIN32 && !defined __CYGWIN__
309# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310# undef chdir
311# define chdir _chdir
312# endif
313_GL_CXXALIAS_MDA (chdir, int, (const char *file));
314# else
238_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); 315_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
316# endif
239_GL_CXXALIASWARN (chdir); 317_GL_CXXALIASWARN (chdir);
240#elif defined GNULIB_POSIXCHECK 318#elif defined GNULIB_POSIXCHECK
241# undef chdir 319# undef chdir
@@ -243,6 +321,20 @@ _GL_CXXALIASWARN (chdir);
243_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - " 321_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
244 "use gnulib module chdir for portability"); 322 "use gnulib module chdir for portability");
245# endif 323# endif
324#elif @GNULIB_MDA_CHDIR@
325/* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not
326 required. In C++ with GNULIB_NAMESPACE, avoid differences between
327 platforms by defining GNULIB_NAMESPACE::chdir always. */
328# if defined _WIN32 && !defined __CYGWIN__
329# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330# undef chdir
331# define chdir _chdir
332# endif
333_GL_CXXALIAS_MDA (chdir, int, (const char *file));
334# else
335_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
336# endif
337_GL_CXXALIASWARN (chdir);
246#endif 338#endif
247 339
248 340
@@ -251,7 +343,7 @@ _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
251 to GID (if GID is not -1). Follow symbolic links. 343 to GID (if GID is not -1). Follow symbolic links.
252 Return 0 if successful, otherwise -1 and errno set. 344 Return 0 if successful, otherwise -1 and errno set.
253 See the POSIX:2008 specification 345 See the POSIX:2008 specification
254 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */ 346 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
255# if @REPLACE_CHOWN@ 347# if @REPLACE_CHOWN@
256# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 348# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257# undef chown 349# undef chown
@@ -287,6 +379,12 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
287# endif 379# endif
288_GL_FUNCDECL_RPL (close, int, (int fd)); 380_GL_FUNCDECL_RPL (close, int, (int fd));
289_GL_CXXALIAS_RPL (close, int, (int fd)); 381_GL_CXXALIAS_RPL (close, int, (int fd));
382# elif defined _WIN32 && !defined __CYGWIN__
383# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
384# undef close
385# define close _close
386# endif
387_GL_CXXALIAS_MDA (close, int, (int fd));
290# else 388# else
291_GL_CXXALIAS_SYS (close, int, (int fd)); 389_GL_CXXALIAS_SYS (close, int, (int fd));
292# endif 390# endif
@@ -299,6 +397,53 @@ _GL_CXXALIASWARN (close);
299/* Assume close is always declared. */ 397/* Assume close is always declared. */
300_GL_WARN_ON_USE (close, "close does not portably work on sockets - " 398_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
301 "use gnulib module close for portability"); 399 "use gnulib module close for portability");
400#elif @GNULIB_MDA_CLOSE@
401/* On native Windows, map 'close' to '_close', so that -loldnames is not
402 required. In C++ with GNULIB_NAMESPACE, avoid differences between
403 platforms by defining GNULIB_NAMESPACE::close always. */
404# if defined _WIN32 && !defined __CYGWIN__
405# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
406# undef close
407# define close _close
408# endif
409_GL_CXXALIAS_MDA (close, int, (int fd));
410# else
411_GL_CXXALIAS_SYS (close, int, (int fd));
412# endif
413_GL_CXXALIASWARN (close);
414#endif
415
416
417#if @GNULIB_COPY_FILE_RANGE@
418# if @REPLACE_COPY_FILE_RANGE@
419# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
420# undef copy_file_range
421# define copy_file_range rpl_copy_file_range
422# endif
423_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
424 int ofd, off_t *opos,
425 size_t len, unsigned flags));
426_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
427 int ofd, off_t *opos,
428 size_t len, unsigned flags));
429# else
430# if !@HAVE_COPY_FILE_RANGE@
431_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
432 int ofd, off_t *opos,
433 size_t len, unsigned flags));
434# endif
435_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
436 int ofd, off_t *opos,
437 size_t len, unsigned flags));
438# endif
439_GL_CXXALIASWARN (copy_file_range);
440#elif defined GNULIB_POSIXCHECK
441# undef copy_file_range
442# if HAVE_RAW_DECL_COPY_FILE_RANGE
443_GL_WARN_ON_USE (copy_file_range,
444 "copy_file_range is unportable - "
445 "use gnulib module copy_file_range for portability");
446# endif
302#endif 447#endif
303 448
304 449
@@ -309,6 +454,12 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
309# endif 454# endif
310_GL_FUNCDECL_RPL (dup, int, (int oldfd)); 455_GL_FUNCDECL_RPL (dup, int, (int oldfd));
311_GL_CXXALIAS_RPL (dup, int, (int oldfd)); 456_GL_CXXALIAS_RPL (dup, int, (int oldfd));
457# elif defined _WIN32 && !defined __CYGWIN__
458# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
459# undef dup
460# define dup _dup
461# endif
462_GL_CXXALIAS_MDA (dup, int, (int oldfd));
312# else 463# else
313_GL_CXXALIAS_SYS (dup, int, (int oldfd)); 464_GL_CXXALIAS_SYS (dup, int, (int oldfd));
314# endif 465# endif
@@ -319,6 +470,20 @@ _GL_CXXALIASWARN (dup);
319_GL_WARN_ON_USE (dup, "dup is unportable - " 470_GL_WARN_ON_USE (dup, "dup is unportable - "
320 "use gnulib module dup for portability"); 471 "use gnulib module dup for portability");
321# endif 472# endif
473#elif @GNULIB_MDA_DUP@
474/* On native Windows, map 'dup' to '_dup', so that -loldnames is not
475 required. In C++ with GNULIB_NAMESPACE, avoid differences between
476 platforms by defining GNULIB_NAMESPACE::dup always. */
477# if defined _WIN32 && !defined __CYGWIN__
478# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
479# undef dup
480# define dup _dup
481# endif
482_GL_CXXALIAS_MDA (dup, int, (int oldfd));
483# else
484_GL_CXXALIAS_SYS (dup, int, (int oldfd));
485# endif
486_GL_CXXALIASWARN (dup);
322#endif 487#endif
323 488
324 489
@@ -327,17 +492,20 @@ _GL_WARN_ON_USE (dup, "dup is unportable - "
327 NEWFD = OLDFD, otherwise close NEWFD first if it is open. 492 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
328 Return newfd if successful, otherwise -1 and errno set. 493 Return newfd if successful, otherwise -1 and errno set.
329 See the POSIX:2008 specification 494 See the POSIX:2008 specification
330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */ 495 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
331# if @REPLACE_DUP2@ 496# if @REPLACE_DUP2@
332# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 497# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
333# define dup2 rpl_dup2 498# define dup2 rpl_dup2
334# endif 499# endif
335_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); 500_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
336_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); 501_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
337# else 502# elif defined _WIN32 && !defined __CYGWIN__
338# if !@HAVE_DUP2@ 503# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); 504# undef dup2
505# define dup2 _dup2
340# endif 506# endif
507_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
508# else
341_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); 509_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
342# endif 510# endif
343_GL_CXXALIASWARN (dup2); 511_GL_CXXALIASWARN (dup2);
@@ -347,6 +515,20 @@ _GL_CXXALIASWARN (dup2);
347_GL_WARN_ON_USE (dup2, "dup2 is unportable - " 515_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
348 "use gnulib module dup2 for portability"); 516 "use gnulib module dup2 for portability");
349# endif 517# endif
518#elif @GNULIB_MDA_DUP2@
519/* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
520 required. In C++ with GNULIB_NAMESPACE, avoid differences between
521 platforms by defining GNULIB_NAMESPACE::dup2 always. */
522# if defined _WIN32 && !defined __CYGWIN__
523# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
524# undef dup2
525# define dup2 _dup2
526# endif
527_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
528# else
529_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
530# endif
531_GL_CXXALIASWARN (dup2);
350#endif 532#endif
351 533
352 534
@@ -358,7 +540,7 @@ _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
358 Close NEWFD first if it is open. 540 Close NEWFD first if it is open.
359 Return newfd if successful, otherwise -1 and errno set. 541 Return newfd if successful, otherwise -1 and errno set.
360 See the Linux man page at 542 See the Linux man page at
361 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ 543 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
362# if @HAVE_DUP3@ 544# if @HAVE_DUP3@
363# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 545# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
364# define dup3 rpl_dup3 546# define dup3 rpl_dup3
@@ -380,10 +562,23 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
380 562
381 563
382#if @GNULIB_ENVIRON@ 564#if @GNULIB_ENVIRON@
565# if defined __CYGWIN__ && !defined __i386__
566/* The 'environ' variable is defined in a DLL. Therefore its declaration needs
567 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
568 This leads to a link error on 64-bit Cygwin when the option
569 -Wl,--disable-auto-import is in use. */
570_GL_EXTERN_C __declspec(dllimport) char **environ;
571# endif
383# if !@HAVE_DECL_ENVIRON@ 572# if !@HAVE_DECL_ENVIRON@
384/* Set of environment variables and values. An array of strings of the form 573/* Set of environment variables and values. An array of strings of the form
385 "VARIABLE=VALUE", terminated with a NULL. */ 574 "VARIABLE=VALUE", terminated with a NULL. */
386# if defined __APPLE__ && defined __MACH__ 575# if defined __APPLE__ && defined __MACH__
576# include <TargetConditionals.h>
577# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
578# define _GL_USE_CRT_EXTERNS
579# endif
580# endif
581# ifdef _GL_USE_CRT_EXTERNS
387# include <crt_externs.h> 582# include <crt_externs.h>
388# define environ (*_NSGetEnviron ()) 583# define environ (*_NSGetEnviron ())
389# else 584# else
@@ -399,12 +594,12 @@ extern char **environ;
399#elif defined GNULIB_POSIXCHECK 594#elif defined GNULIB_POSIXCHECK
400# if HAVE_RAW_DECL_ENVIRON 595# if HAVE_RAW_DECL_ENVIRON
401_GL_UNISTD_INLINE char *** 596_GL_UNISTD_INLINE char ***
597_GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
598 "use gnulib module environ for portability")
402rpl_environ (void) 599rpl_environ (void)
403{ 600{
404 return &environ; 601 return &environ;
405} 602}
406_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
407 "use gnulib module environ for portability");
408# undef environ 603# undef environ
409# define environ (*rpl_environ ()) 604# define environ (*rpl_environ ())
410# endif 605# endif
@@ -434,14 +629,302 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
434#endif 629#endif
435 630
436 631
632#if @GNULIB_EXECL@
633# if @REPLACE_EXECL@
634# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
635# undef execl
636# define execl rpl_execl
637# endif
638_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...)
639 _GL_ARG_NONNULL ((1)));
640_GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
641# else
642_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
643# endif
644_GL_CXXALIASWARN (execl);
645#elif defined GNULIB_POSIXCHECK
646# undef execl
647# if HAVE_RAW_DECL_EXECL
648_GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
649 "use gnulib module execl for portability");
650# endif
651#elif @GNULIB_MDA_EXECL@
652/* On native Windows, map 'execl' to '_execl', so that -loldnames is not
653 required. In C++ with GNULIB_NAMESPACE, avoid differences between
654 platforms by defining GNULIB_NAMESPACE::execl always. */
655# if defined _WIN32 && !defined __CYGWIN__
656# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
657# undef execl
658# define execl _execl
659# endif
660_GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...));
661# else
662_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
663# endif
664_GL_CXXALIASWARN (execl);
665#endif
666
667#if @GNULIB_EXECLE@
668# if @REPLACE_EXECLE@
669# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
670# undef execle
671# define execle rpl_execle
672# endif
673_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...)
674 _GL_ARG_NONNULL ((1)));
675_GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
676# else
677_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
678# endif
679_GL_CXXALIASWARN (execle);
680#elif defined GNULIB_POSIXCHECK
681# undef execle
682# if HAVE_RAW_DECL_EXECLE
683_GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
684 "use gnulib module execle for portability");
685# endif
686#elif @GNULIB_MDA_EXECLE@
687/* On native Windows, map 'execle' to '_execle', so that -loldnames is not
688 required. In C++ with GNULIB_NAMESPACE, avoid differences between
689 platforms by defining GNULIB_NAMESPACE::execle always. */
690# if defined _WIN32 && !defined __CYGWIN__
691# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
692# undef execle
693# define execle _execle
694# endif
695_GL_CXXALIAS_MDA (execle, intptr_t,
696 (const char *program, const char *arg, ...));
697# else
698_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
699# endif
700_GL_CXXALIASWARN (execle);
701#endif
702
703#if @GNULIB_EXECLP@
704# if @REPLACE_EXECLP@
705# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706# undef execlp
707# define execlp rpl_execlp
708# endif
709_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...)
710 _GL_ARG_NONNULL ((1)));
711_GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
712# else
713_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
714# endif
715_GL_CXXALIASWARN (execlp);
716#elif defined GNULIB_POSIXCHECK
717# undef execlp
718# if HAVE_RAW_DECL_EXECLP
719_GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
720 "use gnulib module execlp for portability");
721# endif
722#elif @GNULIB_MDA_EXECLP@
723/* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
724 required. In C++ with GNULIB_NAMESPACE, avoid differences between
725 platforms by defining GNULIB_NAMESPACE::execlp always. */
726# if defined _WIN32 && !defined __CYGWIN__
727# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
728# undef execlp
729# define execlp _execlp
730# endif
731_GL_CXXALIAS_MDA (execlp, intptr_t,
732 (const char *program, const char *arg, ...));
733# else
734_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
735# endif
736_GL_CXXALIASWARN (execlp);
737#endif
738
739
740#if @GNULIB_EXECV@
741# if @REPLACE_EXECV@
742# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
743# undef execv
744# define execv rpl_execv
745# endif
746_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv)
747 _GL_ARG_NONNULL ((1, 2)));
748_GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
749# else
750_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
751# endif
752_GL_CXXALIASWARN (execv);
753#elif defined GNULIB_POSIXCHECK
754# undef execv
755# if HAVE_RAW_DECL_EXECV
756_GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
757 "use gnulib module execv for portability");
758# endif
759#elif @GNULIB_MDA_EXECV@
760/* On native Windows, map 'execv' to '_execv', so that -loldnames is not
761 required. In C++ with GNULIB_NAMESPACE, avoid differences between
762 platforms by defining GNULIB_NAMESPACE::execv always. */
763# if defined _WIN32 && !defined __CYGWIN__
764# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765# undef execv
766# define execv _execv
767# endif
768_GL_CXXALIAS_MDA_CAST (execv, intptr_t,
769 (const char *program, char * const *argv));
770# else
771_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
772# endif
773_GL_CXXALIASWARN (execv);
774#endif
775
776#if @GNULIB_EXECVE@
777# if @REPLACE_EXECVE@
778# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
779# undef execve
780# define execve rpl_execve
781# endif
782_GL_FUNCDECL_RPL (execve, int,
783 (const char *program, char * const *argv, char * const *env)
784 _GL_ARG_NONNULL ((1, 2)));
785_GL_CXXALIAS_RPL (execve, int,
786 (const char *program, char * const *argv, char * const *env));
787# else
788_GL_CXXALIAS_SYS (execve, int,
789 (const char *program, char * const *argv, char * const *env));
790# endif
791_GL_CXXALIASWARN (execve);
792#elif defined GNULIB_POSIXCHECK
793# undef execve
794# if HAVE_RAW_DECL_EXECVE
795_GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
796 "use gnulib module execve for portability");
797# endif
798#elif @GNULIB_MDA_EXECVE@
799/* On native Windows, map 'execve' to '_execve', so that -loldnames is not
800 required. In C++ with GNULIB_NAMESPACE, avoid differences between
801 platforms by defining GNULIB_NAMESPACE::execve always. */
802# if defined _WIN32 && !defined __CYGWIN__
803# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
804# undef execve
805# define execve _execve
806# endif
807_GL_CXXALIAS_MDA_CAST (execve, intptr_t,
808 (const char *program, char * const *argv,
809 char * const *env));
810# else
811_GL_CXXALIAS_SYS (execve, int,
812 (const char *program, char * const *argv, char * const *env));
813# endif
814_GL_CXXALIASWARN (execve);
815#endif
816
817#if @GNULIB_EXECVP@
818# if @REPLACE_EXECVP@
819# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
820# undef execvp
821# define execvp rpl_execvp
822# endif
823_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv)
824 _GL_ARG_NONNULL ((1, 2)));
825_GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
826# else
827_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
828# endif
829_GL_CXXALIASWARN (execvp);
830#elif defined GNULIB_POSIXCHECK
831# undef execvp
832# if HAVE_RAW_DECL_EXECVP
833_GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
834 "use gnulib module execvp for portability");
835# endif
836#elif @GNULIB_MDA_EXECVP@
837/* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
838 required. In C++ with GNULIB_NAMESPACE, avoid differences between
839 platforms by defining GNULIB_NAMESPACE::execvp always. */
840# if defined _WIN32 && !defined __CYGWIN__
841# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
842# undef execvp
843# define execvp _execvp
844# endif
845_GL_CXXALIAS_MDA_CAST (execvp, intptr_t,
846 (const char *program, char * const *argv));
847# else
848_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
849# endif
850_GL_CXXALIASWARN (execvp);
851#endif
852
853#if @GNULIB_EXECVPE@
854# if @REPLACE_EXECVPE@
855# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
856# undef execvpe
857# define execvpe rpl_execvpe
858# endif
859_GL_FUNCDECL_RPL (execvpe, int,
860 (const char *program, char * const *argv, char * const *env)
861 _GL_ARG_NONNULL ((1, 2)));
862_GL_CXXALIAS_RPL (execvpe, int,
863 (const char *program, char * const *argv, char * const *env));
864# else
865# if !@HAVE_DECL_EXECVPE@
866_GL_FUNCDECL_SYS (execvpe, int,
867 (const char *program, char * const *argv, char * const *env)
868 _GL_ARG_NONNULL ((1, 2)));
869# endif
870_GL_CXXALIAS_SYS (execvpe, int,
871 (const char *program, char * const *argv, char * const *env));
872# endif
873_GL_CXXALIASWARN (execvpe);
874#elif defined GNULIB_POSIXCHECK
875# undef execvpe
876# if HAVE_RAW_DECL_EXECVPE
877_GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
878 "use gnulib module execvpe for portability");
879# endif
880#elif @GNULIB_MDA_EXECVPE@
881/* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
882 required. In C++ with GNULIB_NAMESPACE, avoid differences between
883 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
884 it. */
885# if defined _WIN32 && !defined __CYGWIN__
886# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
887# undef execvpe
888# define execvpe _execvpe
889# endif
890_GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
891 (const char *program, char * const *argv,
892 char * const *env));
893# elif @HAVE_EXECVPE@
894# if !@HAVE_DECL_EXECVPE@
895_GL_FUNCDECL_SYS (execvpe, int,
896 (const char *program, char * const *argv, char * const *env)
897 _GL_ARG_NONNULL ((1, 2)));
898# endif
899_GL_CXXALIAS_SYS (execvpe, int,
900 (const char *program, char * const *argv, char * const *env));
901# endif
902# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
903_GL_CXXALIASWARN (execvpe);
904# endif
905#endif
906
907
437#if @GNULIB_FACCESSAT@ 908#if @GNULIB_FACCESSAT@
438# if !@HAVE_FACCESSAT@ 909# if @REPLACE_FACCESSAT@
910# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
911# undef faccessat
912# define faccessat rpl_faccessat
913# endif
914_GL_FUNCDECL_RPL (faccessat, int,
915 (int fd, char const *name, int mode, int flag)
916 _GL_ARG_NONNULL ((2)));
917_GL_CXXALIAS_RPL (faccessat, int,
918 (int fd, char const *name, int mode, int flag));
919# else
920# if !@HAVE_FACCESSAT@
439_GL_FUNCDECL_SYS (faccessat, int, 921_GL_FUNCDECL_SYS (faccessat, int,
440 (int fd, char const *file, int mode, int flag) 922 (int fd, char const *file, int mode, int flag)
441 _GL_ARG_NONNULL ((2))); 923 _GL_ARG_NONNULL ((2)));
442# endif 924# endif
443_GL_CXXALIAS_SYS (faccessat, int, 925_GL_CXXALIAS_SYS (faccessat, int,
444 (int fd, char const *file, int mode, int flag)); 926 (int fd, char const *file, int mode, int flag));
927# endif
445_GL_CXXALIASWARN (faccessat); 928_GL_CXXALIASWARN (faccessat);
446#elif defined GNULIB_POSIXCHECK 929#elif defined GNULIB_POSIXCHECK
447# undef faccessat 930# undef faccessat
@@ -457,7 +940,7 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
457 the given file descriptor is open. 940 the given file descriptor is open.
458 Return 0 if successful, otherwise -1 and errno set. 941 Return 0 if successful, otherwise -1 and errno set.
459 See the POSIX:2008 specification 942 See the POSIX:2008 specification
460 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ 943 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
461# if ! @HAVE_FCHDIR@ 944# if ! @HAVE_FCHDIR@
462_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); 945_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
463 946
@@ -509,7 +992,7 @@ _GL_CXXALIASWARN (fchownat);
509# undef fchownat 992# undef fchownat
510# if HAVE_RAW_DECL_FCHOWNAT 993# if HAVE_RAW_DECL_FCHOWNAT
511_GL_WARN_ON_USE (fchownat, "fchownat is not portable - " 994_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
512 "use gnulib module openat for portability"); 995 "use gnulib module fchownat for portability");
513# endif 996# endif
514#endif 997#endif
515 998
@@ -518,7 +1001,7 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
518/* Synchronize changes to a file. 1001/* Synchronize changes to a file.
519 Return 0 if successful, otherwise -1 and errno set. 1002 Return 0 if successful, otherwise -1 and errno set.
520 See POSIX:2008 specification 1003 See POSIX:2008 specification
521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ 1004 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
522# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ 1005# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
523_GL_FUNCDECL_SYS (fdatasync, int, (int fd)); 1006_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
524# endif 1007# endif
@@ -537,7 +1020,7 @@ _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
537/* Synchronize changes, including metadata, to a file. 1020/* Synchronize changes, including metadata, to a file.
538 Return 0 if successful, otherwise -1 and errno set. 1021 Return 0 if successful, otherwise -1 and errno set.
539 See POSIX:2008 specification 1022 See POSIX:2008 specification
540 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ 1023 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
541# if !@HAVE_FSYNC@ 1024# if !@HAVE_FSYNC@
542_GL_FUNCDECL_SYS (fsync, int, (int fd)); 1025_GL_FUNCDECL_SYS (fsync, int, (int fd));
543# endif 1026# endif
@@ -556,7 +1039,7 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
556/* Change the size of the file to which FD is opened to become equal to LENGTH. 1039/* Change the size of the file to which FD is opened to become equal to LENGTH.
557 Return 0 if successful, otherwise -1 and errno set. 1040 Return 0 if successful, otherwise -1 and errno set.
558 See the POSIX:2008 specification 1041 See the POSIX:2008 specification
559 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */ 1042 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
560# if @REPLACE_FTRUNCATE@ 1043# if @REPLACE_FTRUNCATE@
561# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1044# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
562# undef ftruncate 1045# undef ftruncate
@@ -586,7 +1069,7 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
586 Return BUF if successful, or NULL if the directory couldn't be determined 1069 Return BUF if successful, or NULL if the directory couldn't be determined
587 or SIZE was too small. 1070 or SIZE was too small.
588 See the POSIX:2008 specification 1071 See the POSIX:2008 specification
589 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. 1072 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
590 Additionally, the gnulib module 'getcwd' guarantees the following GNU 1073 Additionally, the gnulib module 'getcwd' guarantees the following GNU
591 extension: If BUF is NULL, an array is allocated with 'malloc'; the array 1074 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
592 is SIZE bytes long, unless SIZE == 0, in which case it is as big as 1075 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
@@ -597,6 +1080,12 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
597# endif 1080# endif
598_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); 1081_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
599_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); 1082_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1083# elif defined _WIN32 && !defined __CYGWIN__
1084# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085# undef getcwd
1086# define getcwd _getcwd
1087# endif
1088_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
600# else 1089# else
601/* Need to cast, because on mingw, the second parameter is 1090/* Need to cast, because on mingw, the second parameter is
602 int size. */ 1091 int size. */
@@ -609,6 +1098,22 @@ _GL_CXXALIASWARN (getcwd);
609_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " 1098_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
610 "use gnulib module getcwd for portability"); 1099 "use gnulib module getcwd for portability");
611# endif 1100# endif
1101#elif @GNULIB_MDA_GETCWD@
1102/* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1103 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1104 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1105# if defined _WIN32 && !defined __CYGWIN__
1106# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1107# undef getcwd
1108# define getcwd _getcwd
1109# endif
1110/* Need to cast, because on mingw, the second parameter is either
1111 'int size' or 'size_t size'. */
1112_GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size));
1113# else
1114_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1115# endif
1116_GL_CXXALIASWARN (getcwd);
612#endif 1117#endif
613 1118
614 1119
@@ -638,7 +1143,9 @@ _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
638# endif 1143# endif
639_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); 1144_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
640# endif 1145# endif
1146# if __GLIBC__ >= 2
641_GL_CXXALIASWARN (getdomainname); 1147_GL_CXXALIASWARN (getdomainname);
1148# endif
642#elif defined GNULIB_POSIXCHECK 1149#elif defined GNULIB_POSIXCHECK
643# undef getdomainname 1150# undef getdomainname
644# if HAVE_RAW_DECL_GETDOMAINNAME 1151# if HAVE_RAW_DECL_GETDOMAINNAME
@@ -651,10 +1158,21 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
651#if @GNULIB_GETDTABLESIZE@ 1158#if @GNULIB_GETDTABLESIZE@
652/* Return the maximum number of file descriptors in the current process. 1159/* Return the maximum number of file descriptors in the current process.
653 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ 1160 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
654# if !@HAVE_GETDTABLESIZE@ 1161# if @REPLACE_GETDTABLESIZE@
1162# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1163# undef getdtablesize
1164# define getdtablesize rpl_getdtablesize
1165# endif
1166_GL_FUNCDECL_RPL (getdtablesize, int, (void));
1167_GL_CXXALIAS_RPL (getdtablesize, int, (void));
1168# else
1169# if !@HAVE_GETDTABLESIZE@
655_GL_FUNCDECL_SYS (getdtablesize, int, (void)); 1170_GL_FUNCDECL_SYS (getdtablesize, int, (void));
1171# endif
1172/* Need to cast, because on AIX, the parameter list is
1173 (...). */
1174_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
656# endif 1175# endif
657_GL_CXXALIAS_SYS (getdtablesize, int, (void));
658_GL_CXXALIASWARN (getdtablesize); 1176_GL_CXXALIASWARN (getdtablesize);
659#elif defined GNULIB_POSIXCHECK 1177#elif defined GNULIB_POSIXCHECK
660# undef getdtablesize 1178# undef getdtablesize
@@ -665,6 +1183,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
665#endif 1183#endif
666 1184
667 1185
1186#if @GNULIB_GETENTROPY@
1187/* Fill a buffer with random bytes. */
1188# if !@HAVE_GETENTROPY@
1189_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
1190# endif
1191_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
1192_GL_CXXALIASWARN (getentropy);
1193#elif defined GNULIB_POSIXCHECK
1194# undef getentropy
1195# if HAVE_RAW_DECL_GETENTROPY
1196_GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1197 "use gnulib module getentropy for portability");
1198# endif
1199#endif
1200
1201
668#if @GNULIB_GETGROUPS@ 1202#if @GNULIB_GETGROUPS@
669/* Return the supplemental groups that the current process belongs to. 1203/* Return the supplemental groups that the current process belongs to.
670 It is unspecified whether the effective group id is in the list. 1204 It is unspecified whether the effective group id is in the list.
@@ -737,14 +1271,14 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
737/* Returns the user's login name, or NULL if it cannot be found. Upon error, 1271/* Returns the user's login name, or NULL if it cannot be found. Upon error,
738 returns NULL with errno set. 1272 returns NULL with errno set.
739 1273
740 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1274 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
741 1275
742 Most programs don't need to use this function, because the information is 1276 Most programs don't need to use this function, because the information is
743 available through environment variables: 1277 available through environment variables:
744 ${LOGNAME-$USER} on Unix platforms, 1278 ${LOGNAME-$USER} on Unix platforms,
745 $USERNAME on native Windows platforms. 1279 $USERNAME on native Windows platforms.
746 */ 1280 */
747# if !@HAVE_GETLOGIN@ 1281# if !@HAVE_DECL_GETLOGIN@
748_GL_FUNCDECL_SYS (getlogin, char *, (void)); 1282_GL_FUNCDECL_SYS (getlogin, char *, (void));
749# endif 1283# endif
750_GL_CXXALIAS_SYS (getlogin, char *, (void)); 1284_GL_CXXALIAS_SYS (getlogin, char *, (void));
@@ -766,7 +1300,7 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
766 the case that the login name cannot be found but no specific error is 1300 the case that the login name cannot be found but no specific error is
767 provided (this case is hopefully rare but is left open by the POSIX spec). 1301 provided (this case is hopefully rare but is left open by the POSIX spec).
768 1302
769 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1303 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
770 1304
771 Most programs don't need to use this function, because the information is 1305 Most programs don't need to use this function, because the information is
772 available through environment variables: 1306 available through environment variables:
@@ -807,6 +1341,11 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
807_GL_FUNCDECL_RPL (getpagesize, int, (void)); 1341_GL_FUNCDECL_RPL (getpagesize, int, (void));
808_GL_CXXALIAS_RPL (getpagesize, int, (void)); 1342_GL_CXXALIAS_RPL (getpagesize, int, (void));
809# else 1343# else
1344/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1345 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1346# if defined __hpux
1347_GL_FUNCDECL_SYS (getpagesize, int, (void));
1348# endif
810# if !@HAVE_GETPAGESIZE@ 1349# if !@HAVE_GETPAGESIZE@
811# if !defined getpagesize 1350# if !defined getpagesize
812/* This is for POSIX systems. */ 1351/* This is for POSIX systems. */
@@ -881,6 +1420,54 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
881#endif 1420#endif
882 1421
883 1422
1423#if @GNULIB_GETPASS@
1424/* Function getpass() from module 'getpass':
1425 Read a password from /dev/tty or stdin.
1426 Function getpass() from module 'getpass-gnu':
1427 Read a password of arbitrary length from /dev/tty or stdin. */
1428# if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1429 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1430# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1431# undef getpass
1432# define getpass rpl_getpass
1433# endif
1434_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1435 _GL_ARG_NONNULL ((1)));
1436_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1437# else
1438# if !@HAVE_GETPASS@
1439_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1440 _GL_ARG_NONNULL ((1)));
1441# endif
1442_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1443# endif
1444_GL_CXXALIASWARN (getpass);
1445#elif defined GNULIB_POSIXCHECK
1446# undef getpass
1447# if HAVE_RAW_DECL_GETPASS
1448_GL_WARN_ON_USE (getpass, "getpass is unportable - "
1449 "use gnulib module getpass or getpass-gnu for portability");
1450# endif
1451#endif
1452
1453
1454#if @GNULIB_MDA_GETPID@
1455/* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1456 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1457 platforms by defining GNULIB_NAMESPACE::getpid always. */
1458# if defined _WIN32 && !defined __CYGWIN__
1459# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1460# undef getpid
1461# define getpid _getpid
1462# endif
1463_GL_CXXALIAS_MDA (getpid, int, (void));
1464# else
1465_GL_CXXALIAS_SYS (getpid, pid_t, (void));
1466# endif
1467_GL_CXXALIASWARN (getpid);
1468#endif
1469
1470
884#if @GNULIB_GETUSERSHELL@ 1471#if @GNULIB_GETUSERSHELL@
885/* Return the next valid login shell on the system, or NULL when the end of 1472/* Return the next valid login shell on the system, or NULL when the end of
886 the list has been reached. */ 1473 the list has been reached. */
@@ -951,8 +1538,15 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
951# undef isatty 1538# undef isatty
952# define isatty rpl_isatty 1539# define isatty rpl_isatty
953# endif 1540# endif
1541# define GNULIB_defined_isatty 1
954_GL_FUNCDECL_RPL (isatty, int, (int fd)); 1542_GL_FUNCDECL_RPL (isatty, int, (int fd));
955_GL_CXXALIAS_RPL (isatty, int, (int fd)); 1543_GL_CXXALIAS_RPL (isatty, int, (int fd));
1544# elif defined _WIN32 && !defined __CYGWIN__
1545# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1546# undef isatty
1547# define isatty _isatty
1548# endif
1549_GL_CXXALIAS_MDA (isatty, int, (int fd));
956# else 1550# else
957_GL_CXXALIAS_SYS (isatty, int, (int fd)); 1551_GL_CXXALIAS_SYS (isatty, int, (int fd));
958# endif 1552# endif
@@ -963,6 +1557,20 @@ _GL_CXXALIASWARN (isatty);
963_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " 1557_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
964 "use gnulib module isatty for portability"); 1558 "use gnulib module isatty for portability");
965# endif 1559# endif
1560#elif @GNULIB_MDA_ISATTY@
1561/* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1562 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1563 platforms by defining GNULIB_NAMESPACE::isatty always. */
1564# if defined _WIN32 && !defined __CYGWIN__
1565# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1566# undef isatty
1567# define isatty _isatty
1568# endif
1569_GL_CXXALIAS_MDA (isatty, int, (int fd));
1570# else
1571_GL_CXXALIAS_SYS (isatty, int, (int fd));
1572# endif
1573_GL_CXXALIASWARN (isatty);
966#endif 1574#endif
967 1575
968 1576
@@ -971,7 +1579,7 @@ _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
971 to GID (if GID is not -1). Do not follow symbolic links. 1579 to GID (if GID is not -1). Do not follow symbolic links.
972 Return 0 if successful, otherwise -1 and errno set. 1580 Return 0 if successful, otherwise -1 and errno set.
973 See the POSIX:2008 specification 1581 See the POSIX:2008 specification
974 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ 1582 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
975# if @REPLACE_LCHOWN@ 1583# if @REPLACE_LCHOWN@
976# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1584# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977# undef lchown 1585# undef lchown
@@ -1001,7 +1609,7 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1001/* Create a new hard link for an existing file. 1609/* Create a new hard link for an existing file.
1002 Return 0 if successful, otherwise -1 and errno set. 1610 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification 1611 See POSIX:2008 specification
1004 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ 1612 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1005# if @REPLACE_LINK@ 1613# if @REPLACE_LINK@
1006# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1614# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1007# define link rpl_link 1615# define link rpl_link
@@ -1067,13 +1675,19 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1067/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. 1675/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1068 Return the new offset if successful, otherwise -1 and errno set. 1676 Return the new offset if successful, otherwise -1 and errno set.
1069 See the POSIX:2008 specification 1677 See the POSIX:2008 specification
1070 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ 1678 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1071# if @REPLACE_LSEEK@ 1679# if @REPLACE_LSEEK@
1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1680# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073# define lseek rpl_lseek 1681# define lseek rpl_lseek
1074# endif 1682# endif
1075_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1683_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1076_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1684_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1685# elif defined _WIN32 && !defined __CYGWIN__
1686# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1687# undef lseek
1688# define lseek _lseek
1689# endif
1690_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1077# else 1691# else
1078_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); 1692_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1079# endif 1693# endif
@@ -1084,6 +1698,20 @@ _GL_CXXALIASWARN (lseek);
1084_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " 1698_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1085 "systems - use gnulib module lseek for portability"); 1699 "systems - use gnulib module lseek for portability");
1086# endif 1700# endif
1701#elif @GNULIB_MDA_LSEEK@
1702/* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1703 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1704 platforms by defining GNULIB_NAMESPACE::lseek always. */
1705# if defined _WIN32 && !defined __CYGWIN__
1706# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1707# undef lseek
1708# define lseek _lseek
1709# endif
1710_GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1711# else
1712_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1713# endif
1714_GL_CXXALIASWARN (lseek);
1087#endif 1715#endif
1088 1716
1089 1717
@@ -1113,7 +1741,7 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1113 Store the read-end as fd[0] and the write-end as fd[1]. 1741 Store the read-end as fd[0] and the write-end as fd[1].
1114 Return 0 upon success, or -1 with errno set upon failure. 1742 Return 0 upon success, or -1 with errno set upon failure.
1115 See also the Linux man page at 1743 See also the Linux man page at
1116 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ 1744 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1117# if @HAVE_PIPE2@ 1745# if @HAVE_PIPE2@
1118# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1746# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119# define pipe2 rpl_pipe2 1747# define pipe2 rpl_pipe2
@@ -1139,7 +1767,7 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1139 Return the number of bytes placed into BUF if successful, otherwise 1767 Return the number of bytes placed into BUF if successful, otherwise
1140 set errno and return -1. 0 indicates EOF. 1768 set errno and return -1. 0 indicates EOF.
1141 See the POSIX:2008 specification 1769 See the POSIX:2008 specification
1142 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ 1770 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1143# if @REPLACE_PREAD@ 1771# if @REPLACE_PREAD@
1144# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1772# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145# undef pread 1773# undef pread
@@ -1174,7 +1802,7 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1174 Return the number of bytes written if successful, otherwise 1802 Return the number of bytes written if successful, otherwise
1175 set errno and return -1. 0 indicates nothing written. See the 1803 set errno and return -1. 0 indicates nothing written. See the
1176 POSIX:2008 specification 1804 POSIX:2008 specification
1177 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ 1805 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1178# if @REPLACE_PWRITE@ 1806# if @REPLACE_PWRITE@
1179# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1807# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1180# undef pwrite 1808# undef pwrite
@@ -1207,7 +1835,7 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1207#if @GNULIB_READ@ 1835#if @GNULIB_READ@
1208/* Read up to COUNT bytes from file descriptor FD into the buffer starting 1836/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1209 at BUF. See the POSIX:2008 specification 1837 at BUF. See the POSIX:2008 specification
1210 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ 1838 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1211# if @REPLACE_READ@ 1839# if @REPLACE_READ@
1212# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1840# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1213# undef read 1841# undef read
@@ -1216,11 +1844,32 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1216_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) 1844_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1217 _GL_ARG_NONNULL ((2))); 1845 _GL_ARG_NONNULL ((2)));
1218_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); 1846_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1847# elif defined _WIN32 && !defined __CYGWIN__
1848# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1849# undef read
1850# define read _read
1851# endif
1852_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1853# else
1854_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1855# endif
1856_GL_CXXALIASWARN (read);
1857#elif @GNULIB_MDA_READ@
1858/* On native Windows, map 'read' to '_read', so that -loldnames is not
1859 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1860 platforms by defining GNULIB_NAMESPACE::read always. */
1861# if defined _WIN32 && !defined __CYGWIN__
1862# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1863# undef read
1864# define read _read
1865# endif
1866# ifdef __MINGW32__
1867_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1868# else
1869_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1870# endif
1219# else 1871# else
1220/* Need to cast, because on mingw, the third parameter is 1872_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1221 unsigned int count
1222 and the return type is 'int'. */
1223_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1224# endif 1873# endif
1225_GL_CXXALIASWARN (read); 1874_GL_CXXALIASWARN (read);
1226#endif 1875#endif
@@ -1231,24 +1880,28 @@ _GL_CXXALIASWARN (read);
1231 bytes of it into BUF. Return the number of bytes placed into BUF if 1880 bytes of it into BUF. Return the number of bytes placed into BUF if
1232 successful, otherwise -1 and errno set. 1881 successful, otherwise -1 and errno set.
1233 See the POSIX:2008 specification 1882 See the POSIX:2008 specification
1234 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ 1883 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1235# if @REPLACE_READLINK@ 1884# if @REPLACE_READLINK@
1236# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1885# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237# define readlink rpl_readlink 1886# define readlink rpl_readlink
1238# endif 1887# endif
1239_GL_FUNCDECL_RPL (readlink, ssize_t, 1888_GL_FUNCDECL_RPL (readlink, ssize_t,
1240 (const char *file, char *buf, size_t bufsize) 1889 (const char *restrict file,
1890 char *restrict buf, size_t bufsize)
1241 _GL_ARG_NONNULL ((1, 2))); 1891 _GL_ARG_NONNULL ((1, 2)));
1242_GL_CXXALIAS_RPL (readlink, ssize_t, 1892_GL_CXXALIAS_RPL (readlink, ssize_t,
1243 (const char *file, char *buf, size_t bufsize)); 1893 (const char *restrict file,
1894 char *restrict buf, size_t bufsize));
1244# else 1895# else
1245# if !@HAVE_READLINK@ 1896# if !@HAVE_READLINK@
1246_GL_FUNCDECL_SYS (readlink, ssize_t, 1897_GL_FUNCDECL_SYS (readlink, ssize_t,
1247 (const char *file, char *buf, size_t bufsize) 1898 (const char *restrict file,
1899 char *restrict buf, size_t bufsize)
1248 _GL_ARG_NONNULL ((1, 2))); 1900 _GL_ARG_NONNULL ((1, 2)));
1249# endif 1901# endif
1250_GL_CXXALIAS_SYS (readlink, ssize_t, 1902_GL_CXXALIAS_SYS (readlink, ssize_t,
1251 (const char *file, char *buf, size_t bufsize)); 1903 (const char *restrict file,
1904 char *restrict buf, size_t bufsize));
1252# endif 1905# endif
1253_GL_CXXALIASWARN (readlink); 1906_GL_CXXALIASWARN (readlink);
1254#elif defined GNULIB_POSIXCHECK 1907#elif defined GNULIB_POSIXCHECK
@@ -1261,13 +1914,28 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1261 1914
1262 1915
1263#if @GNULIB_READLINKAT@ 1916#if @GNULIB_READLINKAT@
1264# if !@HAVE_READLINKAT@ 1917# if @REPLACE_READLINKAT@
1918# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1919# define readlinkat rpl_readlinkat
1920# endif
1921_GL_FUNCDECL_RPL (readlinkat, ssize_t,
1922 (int fd, char const *restrict file,
1923 char *restrict buf, size_t len)
1924 _GL_ARG_NONNULL ((2, 3)));
1925_GL_CXXALIAS_RPL (readlinkat, ssize_t,
1926 (int fd, char const *restrict file,
1927 char *restrict buf, size_t len));
1928# else
1929# if !@HAVE_READLINKAT@
1265_GL_FUNCDECL_SYS (readlinkat, ssize_t, 1930_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1266 (int fd, char const *file, char *buf, size_t len) 1931 (int fd, char const *restrict file,
1932 char *restrict buf, size_t len)
1267 _GL_ARG_NONNULL ((2, 3))); 1933 _GL_ARG_NONNULL ((2, 3)));
1268# endif 1934# endif
1269_GL_CXXALIAS_SYS (readlinkat, ssize_t, 1935_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1270 (int fd, char const *file, char *buf, size_t len)); 1936 (int fd, char const *restrict file,
1937 char *restrict buf, size_t len));
1938# endif
1271_GL_CXXALIASWARN (readlinkat); 1939_GL_CXXALIASWARN (readlinkat);
1272#elif defined GNULIB_POSIXCHECK 1940#elif defined GNULIB_POSIXCHECK
1273# undef readlinkat 1941# undef readlinkat
@@ -1286,6 +1954,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1286# endif 1954# endif
1287_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); 1955_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1288_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); 1956_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1957# elif defined _WIN32 && !defined __CYGWIN__
1958# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1959# undef rmdir
1960# define rmdir _rmdir
1961# endif
1962_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1289# else 1963# else
1290_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); 1964_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1291# endif 1965# endif
@@ -1296,6 +1970,20 @@ _GL_CXXALIASWARN (rmdir);
1296_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " 1970_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1297 "use gnulib module rmdir for portability"); 1971 "use gnulib module rmdir for portability");
1298# endif 1972# endif
1973#elif @GNULIB_MDA_RMDIR@
1974/* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1975 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1976 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1977# if defined _WIN32 && !defined __CYGWIN__
1978# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1979# undef rmdir
1980# define rmdir _rmdir
1981# endif
1982_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1983# else
1984_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1985# endif
1986_GL_CXXALIASWARN (rmdir);
1299#endif 1987#endif
1300 1988
1301 1989
@@ -1330,7 +2018,7 @@ _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1330/* Pause the execution of the current thread for N seconds. 2018/* Pause the execution of the current thread for N seconds.
1331 Returns the number of seconds left to sleep. 2019 Returns the number of seconds left to sleep.
1332 See the POSIX:2008 specification 2020 See the POSIX:2008 specification
1333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ 2021 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1334# if @REPLACE_SLEEP@ 2022# if @REPLACE_SLEEP@
1335# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2023# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1336# undef sleep 2024# undef sleep
@@ -1354,6 +2042,31 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1354#endif 2042#endif
1355 2043
1356 2044
2045#if @GNULIB_MDA_SWAB@
2046/* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2047 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2048 platforms by defining GNULIB_NAMESPACE::swab always. */
2049# if defined _WIN32 && !defined __CYGWIN__
2050# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2051# undef swab
2052# define swab _swab
2053# endif
2054/* Need to cast, because in old mingw the arguments are
2055 (const char *from, char *to, size_t n). */
2056_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2057# else
2058# if defined __hpux /* HP-UX */
2059_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2060# elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */
2061_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2062# else
2063_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2064# endif
2065# endif
2066_GL_CXXALIASWARN (swab);
2067#endif
2068
2069
1357#if @GNULIB_SYMLINK@ 2070#if @GNULIB_SYMLINK@
1358# if @REPLACE_SYMLINK@ 2071# if @REPLACE_SYMLINK@
1359# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2072# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1381,13 +2094,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1381 2094
1382 2095
1383#if @GNULIB_SYMLINKAT@ 2096#if @GNULIB_SYMLINKAT@
1384# if !@HAVE_SYMLINKAT@ 2097# if @REPLACE_SYMLINKAT@
2098# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2099# undef symlinkat
2100# define symlinkat rpl_symlinkat
2101# endif
2102_GL_FUNCDECL_RPL (symlinkat, int,
2103 (char const *contents, int fd, char const *file)
2104 _GL_ARG_NONNULL ((1, 3)));
2105_GL_CXXALIAS_RPL (symlinkat, int,
2106 (char const *contents, int fd, char const *file));
2107# else
2108# if !@HAVE_SYMLINKAT@
1385_GL_FUNCDECL_SYS (symlinkat, int, 2109_GL_FUNCDECL_SYS (symlinkat, int,
1386 (char const *contents, int fd, char const *file) 2110 (char const *contents, int fd, char const *file)
1387 _GL_ARG_NONNULL ((1, 3))); 2111 _GL_ARG_NONNULL ((1, 3)));
1388# endif 2112# endif
1389_GL_CXXALIAS_SYS (symlinkat, int, 2113_GL_CXXALIAS_SYS (symlinkat, int,
1390 (char const *contents, int fd, char const *file)); 2114 (char const *contents, int fd, char const *file));
2115# endif
1391_GL_CXXALIASWARN (symlinkat); 2116_GL_CXXALIASWARN (symlinkat);
1392#elif defined GNULIB_POSIXCHECK 2117#elif defined GNULIB_POSIXCHECK
1393# undef symlinkat 2118# undef symlinkat
@@ -1398,6 +2123,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1398#endif 2123#endif
1399 2124
1400 2125
2126#if @GNULIB_TRUNCATE@
2127/* Change the size of the file designated by FILENAME to become equal to LENGTH.
2128 Return 0 if successful, otherwise -1 and errno set.
2129 See the POSIX:2008 specification
2130 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2131# if @REPLACE_TRUNCATE@
2132# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2133# undef truncate
2134# define truncate rpl_truncate
2135# endif
2136_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2137 _GL_ARG_NONNULL ((1)));
2138_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2139# else
2140# if !@HAVE_DECL_TRUNCATE@
2141_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2142 _GL_ARG_NONNULL ((1)));
2143# endif
2144_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2145# endif
2146_GL_CXXALIASWARN (truncate);
2147#elif defined GNULIB_POSIXCHECK
2148# undef truncate
2149# if HAVE_RAW_DECL_TRUNCATE
2150_GL_WARN_ON_USE (truncate, "truncate is unportable - "
2151 "use gnulib module truncate for portability");
2152# endif
2153#endif
2154
2155
1401#if @GNULIB_TTYNAME_R@ 2156#if @GNULIB_TTYNAME_R@
1402/* Store at most BUFLEN characters of the pathname of the terminal FD is 2157/* Store at most BUFLEN characters of the pathname of the terminal FD is
1403 open on in BUF. Return 0 on success, otherwise an error number. */ 2158 open on in BUF. Return 0 on success, otherwise an error number. */
@@ -1436,6 +2191,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1436# endif 2191# endif
1437_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); 2192_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1438_GL_CXXALIAS_RPL (unlink, int, (char const *file)); 2193_GL_CXXALIAS_RPL (unlink, int, (char const *file));
2194# elif defined _WIN32 && !defined __CYGWIN__
2195# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2196# undef unlink
2197# define unlink _unlink
2198# endif
2199_GL_CXXALIAS_MDA (unlink, int, (char const *file));
1439# else 2200# else
1440_GL_CXXALIAS_SYS (unlink, int, (char const *file)); 2201_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1441# endif 2202# endif
@@ -1446,6 +2207,20 @@ _GL_CXXALIASWARN (unlink);
1446_GL_WARN_ON_USE (unlink, "unlink is not portable - " 2207_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1447 "use gnulib module unlink for portability"); 2208 "use gnulib module unlink for portability");
1448# endif 2209# endif
2210#elif @GNULIB_MDA_UNLINK@
2211/* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2212 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2213 platforms by defining GNULIB_NAMESPACE::unlink always. */
2214# if defined _WIN32 && !defined __CYGWIN__
2215# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2216# undef unlink
2217# define unlink _unlink
2218# endif
2219_GL_CXXALIAS_MDA (unlink, int, (char const *file));
2220# else
2221_GL_CXXALIAS_SYS (unlink, int, (char const *file));
2222# endif
2223_GL_CXXALIASWARN (unlink);
1449#endif 2224#endif
1450 2225
1451 2226
@@ -1470,7 +2245,7 @@ _GL_CXXALIASWARN (unlinkat);
1470# undef unlinkat 2245# undef unlinkat
1471# if HAVE_RAW_DECL_UNLINKAT 2246# if HAVE_RAW_DECL_UNLINKAT
1472_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " 2247_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1473 "use gnulib module openat for portability"); 2248 "use gnulib module unlinkat for portability");
1474# endif 2249# endif
1475#endif 2250#endif
1476 2251
@@ -1479,7 +2254,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1479/* Pause the execution of the current thread for N microseconds. 2254/* Pause the execution of the current thread for N microseconds.
1480 Returns 0 on completion, or -1 on range error. 2255 Returns 0 on completion, or -1 on range error.
1481 See the POSIX:2001 specification 2256 See the POSIX:2001 specification
1482 <http://www.opengroup.org/susv3xsh/usleep.html>. */ 2257 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
1483# if @REPLACE_USLEEP@ 2258# if @REPLACE_USLEEP@
1484# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2259# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1485# undef usleep 2260# undef usleep
@@ -1491,7 +2266,9 @@ _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1491# if !@HAVE_USLEEP@ 2266# if !@HAVE_USLEEP@
1492_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); 2267_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1493# endif 2268# endif
1494_GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); 2269/* Need to cast, because on Haiku, the first parameter is
2270 unsigned int n. */
2271_GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
1495# endif 2272# endif
1496_GL_CXXALIASWARN (usleep); 2273_GL_CXXALIASWARN (usleep);
1497#elif defined GNULIB_POSIXCHECK 2274#elif defined GNULIB_POSIXCHECK
@@ -1506,7 +2283,7 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1506#if @GNULIB_WRITE@ 2283#if @GNULIB_WRITE@
1507/* Write up to COUNT bytes starting at BUF to file descriptor FD. 2284/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1508 See the POSIX:2008 specification 2285 See the POSIX:2008 specification
1509 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ 2286 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1510# if @REPLACE_WRITE@ 2287# if @REPLACE_WRITE@
1511# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2288# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1512# undef write 2289# undef write
@@ -1515,11 +2292,32 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1515_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) 2292_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1516 _GL_ARG_NONNULL ((2))); 2293 _GL_ARG_NONNULL ((2)));
1517_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 2294_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2295# elif defined _WIN32 && !defined __CYGWIN__
2296# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2297# undef write
2298# define write _write
2299# endif
2300_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
2301# else
2302_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2303# endif
2304_GL_CXXALIASWARN (write);
2305#elif @GNULIB_MDA_WRITE@
2306/* On native Windows, map 'write' to '_write', so that -loldnames is not
2307 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2308 platforms by defining GNULIB_NAMESPACE::write always. */
2309# if defined _WIN32 && !defined __CYGWIN__
2310# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2311# undef write
2312# define write _write
2313# endif
2314# ifdef __MINGW32__
2315_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
2316# else
2317_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2318# endif
1518# else 2319# else
1519/* Need to cast, because on mingw, the third parameter is 2320_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
1520 unsigned int count
1521 and the return type is 'int'. */
1522_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1523# endif 2321# endif
1524_GL_CXXALIASWARN (write); 2322_GL_CXXALIASWARN (write);
1525#endif 2323#endif
@@ -1527,4 +2325,5 @@ _GL_CXXALIASWARN (write);
1527_GL_INLINE_HEADER_END 2325_GL_INLINE_HEADER_END
1528 2326
1529#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2327#endif /* _@GUARD_PREFIX@_UNISTD_H */
2328#endif /* _GL_INCLUDING_UNISTD_H */
1530#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2329#endif /* _@GUARD_PREFIX@_UNISTD_H */
diff --git a/gl/unlocked-io.h b/gl/unlocked-io.h
new file mode 100644
index 00000000..fdef624a
--- /dev/null
+++ b/gl/unlocked-io.h
@@ -0,0 +1,136 @@
1/* Prefer faster, non-thread-safe stdio functions if available.
2
3 Copyright (C) 2001-2004, 2009-2023 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Jim Meyering. */
19
20#ifndef UNLOCKED_IO_H
21# define UNLOCKED_IO_H 1
22
23/* These are wrappers for functions/macros from the GNU C library, and
24 from other C libraries supporting POSIX's optional thread-safe functions.
25
26 The standard I/O functions are thread-safe. These *_unlocked ones are
27 more efficient but not thread-safe. That they're not thread-safe is
28 fine since all of the applications in this package are single threaded.
29
30 Also, some code that is shared with the GNU C library may invoke
31 the *_unlocked functions directly. On hosts that lack those
32 functions, invoke the non-thread-safe versions instead. */
33
34# include <stdio.h>
35
36# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked
37# undef clearerr
38# define clearerr(x) clearerr_unlocked (x)
39# else
40# define clearerr_unlocked(x) clearerr (x)
41# endif
42
43# if HAVE_DECL_FEOF_UNLOCKED || defined feof_unlocked
44# undef feof
45# define feof(x) feof_unlocked (x)
46# else
47# define feof_unlocked(x) feof (x)
48# endif
49
50# if HAVE_DECL_FERROR_UNLOCKED || defined ferror_unlocked
51# undef ferror
52# define ferror(x) ferror_unlocked (x)
53# else
54# define ferror_unlocked(x) ferror (x)
55# endif
56
57# if HAVE_DECL_FFLUSH_UNLOCKED || defined fflush_unlocked
58# undef fflush
59# define fflush(x) fflush_unlocked (x)
60# else
61# define fflush_unlocked(x) fflush (x)
62# endif
63
64# if HAVE_DECL_FGETS_UNLOCKED || defined fgets_unlocked
65# undef fgets
66# define fgets(x,y,z) fgets_unlocked (x,y,z)
67# else
68# define fgets_unlocked(x,y,z) fgets (x,y,z)
69# endif
70
71# if HAVE_DECL_FPUTC_UNLOCKED || defined fputc_unlocked
72# undef fputc
73# define fputc(x,y) fputc_unlocked (x,y)
74# else
75# define fputc_unlocked(x,y) fputc (x,y)
76# endif
77
78# if HAVE_DECL_FPUTS_UNLOCKED || defined fputs_unlocked
79# undef fputs
80# define fputs(x,y) fputs_unlocked (x,y)
81# else
82# define fputs_unlocked(x,y) fputs (x,y)
83# endif
84
85# if HAVE_DECL_FREAD_UNLOCKED || defined fread_unlocked
86# undef fread
87# define fread(w,x,y,z) fread_unlocked (w,x,y,z)
88# else
89# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
90# endif
91
92# if HAVE_DECL_FWRITE_UNLOCKED || defined fwrite_unlocked
93# undef fwrite
94# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
95# else
96# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
97# endif
98
99# if HAVE_DECL_GETC_UNLOCKED || defined get_unlocked
100# undef getc
101# define getc(x) getc_unlocked (x)
102# else
103# define getc_unlocked(x) getc (x)
104# endif
105
106# if HAVE_DECL_GETCHAR_UNLOCKED || defined getchar_unlocked
107# undef getchar
108# define getchar() getchar_unlocked ()
109# else
110# define getchar_unlocked() getchar ()
111# endif
112
113# if HAVE_DECL_PUTC_UNLOCKED || defined putc_unlocked
114# undef putc
115# define putc(x,y) putc_unlocked (x,y)
116# else
117# define putc_unlocked(x,y) putc (x,y)
118# endif
119
120# if HAVE_DECL_PUTCHAR_UNLOCKED || defined putchar_unlocked
121# undef putchar
122# define putchar(x) putchar_unlocked (x)
123# else
124# define putchar_unlocked(x) putchar (x)
125# endif
126
127# undef flockfile
128# define flockfile(x) ((void) 0)
129
130# undef ftrylockfile
131# define ftrylockfile(x) 0
132
133# undef funlockfile
134# define funlockfile(x) ((void) 0)
135
136#endif /* UNLOCKED_IO_H */
diff --git a/gl/unsetenv.c b/gl/unsetenv.c
index c58c82f4..e5489490 100644
--- a/gl/unsetenv.c
+++ b/gl/unsetenv.c
@@ -1,18 +1,18 @@
1/* Copyright (C) 1992, 1995-2002, 2005-2013 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2002, 2005-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 17/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
18 optimizes away the name == NULL test below. */ 18 optimizes away the name == NULL test below. */
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index 5267b1bb..277c39e3 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -1,18 +1,18 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 1999, 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* This file can be parametrized with the following macros: 17/* This file can be parametrized with the following macros:
18 VASNPRINTF The name of the function being defined. 18 VASNPRINTF The name of the function being defined.
@@ -41,7 +41,14 @@
41 DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[]. 41 DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[].
42 DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t. 42 DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t.
43 DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t. 43 DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t.
44 DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. */ 44 DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t.
45 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
46 ENABLE_WCHAR_FALLBACK Set to 1 to avoid EILSEQ during conversion of wide
47 characters (wchar_t) and wide character strings
48 (wchar_t[]) to multibyte sequences. The fallback is the
49 hexadecimal escape syntax (\unnnn or \Unnnnnnnn) or,
50 if wchar_t is not Unicode encoded, \wnnnn or \Wnnnnnnnn.
51 */
45 52
46/* Tell glibc's <stdio.h> to provide a prototype for snprintf(). 53/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
47 This must come before <config.h> because <config.h> may include 54 This must come before <config.h> because <config.h> may include
@@ -53,10 +60,16 @@
53#ifndef VASNPRINTF 60#ifndef VASNPRINTF
54# include <config.h> 61# include <config.h>
55#endif 62#endif
56#ifndef IN_LIBINTL 63
57# include <alloca.h> 64/* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's
65 use of CHECK macros expands to code that is too complicated for gcc
66 -fanalyzer. Suppress the resulting bogus warnings. */
67#if 10 <= __GNUC__
68# pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
58#endif 69#endif
59 70
71#include <alloca.h>
72
60/* Specification. */ 73/* Specification. */
61#ifndef VASNPRINTF 74#ifndef VASNPRINTF
62# if WIDE_CHAR_VERSION 75# if WIDE_CHAR_VERSION
@@ -70,6 +83,7 @@
70#include <stdio.h> /* snprintf(), sprintf() */ 83#include <stdio.h> /* snprintf(), sprintf() */
71#include <stdlib.h> /* abort(), malloc(), realloc(), free() */ 84#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
72#include <string.h> /* memcpy(), strlen() */ 85#include <string.h> /* memcpy(), strlen() */
86#include <wchar.h> /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb() */
73#include <errno.h> /* errno */ 87#include <errno.h> /* errno */
74#include <limits.h> /* CHAR_BIT */ 88#include <limits.h> /* CHAR_BIT */
75#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ 89#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
@@ -87,7 +101,7 @@
87/* Checked size_t computations. */ 101/* Checked size_t computations. */
88#include "xsize.h" 102#include "xsize.h"
89 103
90#include "verify.h" 104#include "attribute.h"
91 105
92#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 106#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
93# include <math.h> 107# include <math.h>
@@ -156,6 +170,7 @@
156# define SNPRINTF snwprintf 170# define SNPRINTF snwprintf
157# else 171# else
158# define SNPRINTF _snwprintf 172# define SNPRINTF _snwprintf
173# define USE_MSVC__SNPRINTF 1
159# endif 174# endif
160# else 175# else
161 /* Unix. */ 176 /* Unix. */
@@ -181,7 +196,9 @@
181 /* Here we need to call the native snprintf, not rpl_snprintf. */ 196 /* Here we need to call the native snprintf, not rpl_snprintf. */
182# undef snprintf 197# undef snprintf
183# else 198# else
199 /* MSVC versions < 14 did not have snprintf, only _snprintf. */
184# define SNPRINTF _snprintf 200# define SNPRINTF _snprintf
201# define USE_MSVC__SNPRINTF 1
185# endif 202# endif
186# else 203# else
187 /* Unix. */ 204 /* Unix. */
@@ -195,7 +212,7 @@
195 212
196/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized" 213/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized"
197 warnings in this file. Use -Dlint to suppress them. */ 214 warnings in this file. Use -Dlint to suppress them. */
198#ifdef lint 215#if defined GCC_LINT || defined lint
199# define IF_LINT(Code) Code 216# define IF_LINT(Code) Code
200#else 217#else
201# define IF_LINT(Code) /* empty */ 218# define IF_LINT(Code) /* empty */
@@ -208,7 +225,7 @@
208#undef remainder 225#undef remainder
209#define remainder rem 226#define remainder rem
210 227
211#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION 228#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && !WIDE_CHAR_VERSION
212# if (HAVE_STRNLEN && !defined _AIX) 229# if (HAVE_STRNLEN && !defined _AIX)
213# define local_strnlen strnlen 230# define local_strnlen strnlen
214# else 231# else
@@ -224,7 +241,7 @@ local_strnlen (const char *string, size_t maxlen)
224# endif 241# endif
225#endif 242#endif
226 243
227#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T 244#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
228# if HAVE_WCSLEN 245# if HAVE_WCSLEN
229# define local_wcslen wcslen 246# define local_wcslen wcslen
230# else 247# else
@@ -247,7 +264,7 @@ local_wcslen (const wchar_t *s)
247# endif 264# endif
248#endif 265#endif
249 266
250#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION 267#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
251# if HAVE_WCSNLEN 268# if HAVE_WCSNLEN
252# define local_wcsnlen wcsnlen 269# define local_wcsnlen wcsnlen
253# else 270# else
@@ -266,6 +283,74 @@ local_wcsnlen (const wchar_t *s, size_t maxlen)
266# endif 283# endif
267#endif 284#endif
268 285
286#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || (ENABLE_WCHAR_FALLBACK && HAVE_WINT_T)) && !WIDE_CHAR_VERSION
287# if ENABLE_WCHAR_FALLBACK
288static size_t
289wctomb_fallback (char *s, wchar_t wc)
290{
291 static char hex[16] = "0123456789ABCDEF";
292
293 s[0] = '\\';
294 if (sizeof (wchar_t) > 2 && wc > 0xffff)
295 {
296# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__)
297 s[1] = 'U';
298# else
299 s[1] = 'W';
300# endif
301 s[2] = hex[(wc & 0xf0000000U) >> 28];
302 s[3] = hex[(wc & 0xf000000U) >> 24];
303 s[4] = hex[(wc & 0xf00000U) >> 20];
304 s[5] = hex[(wc & 0xf0000U) >> 16];
305 s[6] = hex[(wc & 0xf000U) >> 12];
306 s[7] = hex[(wc & 0xf00U) >> 8];
307 s[8] = hex[(wc & 0xf0U) >> 4];
308 s[9] = hex[wc & 0xfU];
309 return 10;
310 }
311 else
312 {
313# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__)
314 s[1] = 'u';
315# else
316 s[1] = 'w';
317# endif
318 s[2] = hex[(wc & 0xf000U) >> 12];
319 s[3] = hex[(wc & 0xf00U) >> 8];
320 s[4] = hex[(wc & 0xf0U) >> 4];
321 s[5] = hex[wc & 0xfU];
322 return 6;
323 }
324}
325# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
326static size_t
327local_wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
328{
329 size_t count = wcrtomb (s, wc, ps);
330 if (count == (size_t)(-1))
331 count = wctomb_fallback (s, wc);
332 return count;
333}
334# else
335static int
336local_wctomb (char *s, wchar_t wc)
337{
338 int count = wctomb (s, wc);
339 if (count < 0)
340 count = wctomb_fallback (s, wc);
341 return count;
342}
343# define local_wcrtomb(S, WC, PS) local_wctomb ((S), (WC))
344# endif
345# else
346# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
347# define local_wcrtomb(S, WC, PS) wcrtomb ((S), (WC), (PS))
348# else
349# define local_wcrtomb(S, WC, PS) wctomb ((S), (WC))
350# endif
351# endif
352#endif
353
269#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL 354#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
270/* Determine the decimal-point character according to the current locale. */ 355/* Determine the decimal-point character according to the current locale. */
271# ifndef decimal_point_char_defined 356# ifndef decimal_point_char_defined
@@ -323,11 +408,11 @@ is_infinite_or_zerol (long double x)
323 408
324typedef unsigned int mp_limb_t; 409typedef unsigned int mp_limb_t;
325# define GMP_LIMB_BITS 32 410# define GMP_LIMB_BITS 32
326verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS); 411static_assert (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
327 412
328typedef unsigned long long mp_twolimb_t; 413typedef unsigned long long mp_twolimb_t;
329# define GMP_TWOLIMB_BITS 64 414# define GMP_TWOLIMB_BITS 64
330verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS); 415static_assert (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
331 416
332/* Representation of a bignum >= 0. */ 417/* Representation of a bignum >= 0. */
333typedef struct 418typedef struct
@@ -554,7 +639,8 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
554 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ 639 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
555 /* Determine s = GMP_LIMB_BITS - integer_length (msd). 640 /* Determine s = GMP_LIMB_BITS - integer_length (msd).
556 Code copied from gnulib's integer_length.c. */ 641 Code copied from gnulib's integer_length.c. */
557# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 642# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) \
643 || (__clang_major__ >= 4)
558 s = __builtin_clz (msd); 644 s = __builtin_clz (msd);
559# else 645# else
560# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT 646# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
@@ -829,8 +915,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
829 q_ptr[q_len++] = 1; 915 q_ptr[q_len++] = 1;
830 } 916 }
831 keep_q: 917 keep_q:
832 if (tmp_roomptr != NULL) 918 free (tmp_roomptr);
833 free (tmp_roomptr);
834 q->limbs = q_ptr; 919 q->limbs = q_ptr;
835 q->nlimbs = q_len; 920 q->nlimbs = q_len;
836 return roomptr; 921 return roomptr;
@@ -849,7 +934,9 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
849 size_t a_len = a.nlimbs; 934 size_t a_len = a.nlimbs;
850 /* 0.03345 is slightly larger than log(2)/(9*log(10)). */ 935 /* 0.03345 is slightly larger than log(2)/(9*log(10)). */
851 size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1); 936 size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);
852 char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes)); 937 /* We need extra_zeroes bytes for zeroes, followed by c_len bytes for the
938 digits of a, followed by 1 byte for the terminating NUL. */
939 char *c_ptr = (char *) malloc (xsum (xsum (extra_zeroes, c_len), 1));
853 if (c_ptr != NULL) 940 if (c_ptr != NULL)
854 { 941 {
855 char *d_ptr = c_ptr; 942 char *d_ptr = c_ptr;
@@ -1517,7 +1604,7 @@ is_borderline (const char *digits, size_t precision)
1517 1604
1518#endif 1605#endif
1519 1606
1520#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 1607#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
1521 1608
1522/* Use a different function name, to make it possible that the 'wchar_t' 1609/* Use a different function name, to make it possible that the 'wchar_t'
1523 parametrization and the 'char' parametrization get compiled in the same 1610 parametrization and the 'char' parametrization get compiled in the same
@@ -1540,16 +1627,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1540 switch (conversion) 1627 switch (conversion)
1541 { 1628 {
1542 case 'd': case 'i': case 'u': 1629 case 'd': case 'i': case 'u':
1543# if HAVE_LONG_LONG_INT
1544 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 1630 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1545 tmp_length = 1631 tmp_length =
1546 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 1632 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1547 * 0.30103 /* binary -> decimal */ 1633 * 0.30103 /* binary -> decimal */
1548 ) 1634 )
1549 + 1; /* turn floor into ceil */ 1635 + 1; /* turn floor into ceil */
1550 else 1636 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1551# endif
1552 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1553 tmp_length = 1637 tmp_length =
1554 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 1638 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1555 * 0.30103 /* binary -> decimal */ 1639 * 0.30103 /* binary -> decimal */
@@ -1570,16 +1654,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1570 break; 1654 break;
1571 1655
1572 case 'o': 1656 case 'o':
1573# if HAVE_LONG_LONG_INT
1574 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 1657 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1575 tmp_length = 1658 tmp_length =
1576 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 1659 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1577 * 0.333334 /* binary -> octal */ 1660 * 0.333334 /* binary -> octal */
1578 ) 1661 )
1579 + 1; /* turn floor into ceil */ 1662 + 1; /* turn floor into ceil */
1580 else 1663 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1581# endif
1582 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1583 tmp_length = 1664 tmp_length =
1584 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 1665 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1585 * 0.333334 /* binary -> octal */ 1666 * 0.333334 /* binary -> octal */
@@ -1598,16 +1679,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1598 break; 1679 break;
1599 1680
1600 case 'x': case 'X': 1681 case 'x': case 'X':
1601# if HAVE_LONG_LONG_INT
1602 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 1682 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1603 tmp_length = 1683 tmp_length =
1604 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 1684 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1605 * 0.25 /* binary -> hexadecimal */ 1685 * 0.25 /* binary -> hexadecimal */
1606 ) 1686 )
1607 + 1; /* turn floor into ceil */ 1687 + 1; /* turn floor into ceil */
1608 else 1688 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1609# endif
1610 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1611 tmp_length = 1689 tmp_length =
1612 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 1690 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1613 * 0.25 /* binary -> hexadecimal */ 1691 * 0.25 /* binary -> hexadecimal */
@@ -1673,7 +1751,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1673 case 'c': 1751 case 'c':
1674# if HAVE_WINT_T && !WIDE_CHAR_VERSION 1752# if HAVE_WINT_T && !WIDE_CHAR_VERSION
1675 if (type == TYPE_WIDE_CHAR) 1753 if (type == TYPE_WIDE_CHAR)
1676 tmp_length = MB_CUR_MAX; 1754 {
1755 tmp_length = MB_CUR_MAX;
1756# if ENABLE_WCHAR_FALLBACK
1757 if (tmp_length < (sizeof (wchar_t) > 2 ? 10 : 6))
1758 tmp_length = (sizeof (wchar_t) > 2 ? 10 : 6);
1759# endif
1760 }
1677 else 1761 else
1678# endif 1762# endif
1679 tmp_length = 1; 1763 tmp_length = 1;
@@ -1780,6 +1864,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1780 /* errno is already set. */ 1864 /* errno is already set. */
1781 return NULL; 1865 return NULL;
1782 1866
1867 /* Frees the memory allocated by this function. Preserves errno. */
1783#define CLEANUP() \ 1868#define CLEANUP() \
1784 if (d.dir != d.direct_alloc_dir) \ 1869 if (d.dir != d.direct_alloc_dir) \
1785 free (d.dir); \ 1870 free (d.dir); \
@@ -1787,11 +1872,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1787 free (a.arg); 1872 free (a.arg);
1788 1873
1789 if (PRINTF_FETCHARGS (args, &a) < 0) 1874 if (PRINTF_FETCHARGS (args, &a) < 0)
1790 { 1875 goto fail_1_with_EINVAL;
1791 CLEANUP ();
1792 errno = EINVAL;
1793 return NULL;
1794 }
1795 1876
1796 { 1877 {
1797 size_t buf_neededlength; 1878 size_t buf_neededlength;
@@ -1827,24 +1908,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1827 buf_malloced = buf; 1908 buf_malloced = buf;
1828 } 1909 }
1829 1910
1830 if (resultbuf != NULL) 1911 result = resultbuf;
1831 { 1912 allocated = (resultbuf != NULL ? *lengthp : 0);
1832 result = resultbuf;
1833 allocated = *lengthp;
1834 }
1835 else
1836 {
1837 result = NULL;
1838 allocated = 0;
1839 }
1840 length = 0; 1913 length = 0;
1841 /* Invariants: 1914 /* Invariants:
1842 result is either == resultbuf or == NULL or malloc-allocated. 1915 result is either == resultbuf or malloc-allocated.
1916 If result == NULL, resultbuf is == NULL as well.
1843 If length > 0, then result != NULL. */ 1917 If length > 0, then result != NULL. */
1844 1918
1845 /* Ensures that allocated >= needed. Aborts through a jump to 1919 /* Ensures that allocated >= needed. Aborts through a jump to
1846 out_of_memory if needed is SIZE_MAX or otherwise too big. */ 1920 out_of_memory if needed is SIZE_MAX or otherwise too big. */
1847#define ENSURE_ALLOCATION(needed) \ 1921#define ENSURE_ALLOCATION_ELSE(needed, oom_statement) \
1848 if ((needed) > allocated) \ 1922 if ((needed) > allocated) \
1849 { \ 1923 { \
1850 size_t memory_size; \ 1924 size_t memory_size; \
@@ -1855,17 +1929,19 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1855 allocated = (needed); \ 1929 allocated = (needed); \
1856 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ 1930 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
1857 if (size_overflow_p (memory_size)) \ 1931 if (size_overflow_p (memory_size)) \
1858 goto out_of_memory; \ 1932 oom_statement \
1859 if (result == resultbuf || result == NULL) \ 1933 if (result == resultbuf) \
1860 memory = (DCHAR_T *) malloc (memory_size); \ 1934 memory = (DCHAR_T *) malloc (memory_size); \
1861 else \ 1935 else \
1862 memory = (DCHAR_T *) realloc (result, memory_size); \ 1936 memory = (DCHAR_T *) realloc (result, memory_size); \
1863 if (memory == NULL) \ 1937 if (memory == NULL) \
1864 goto out_of_memory; \ 1938 oom_statement \
1865 if (result == resultbuf && length > 0) \ 1939 if (result == resultbuf && length > 0) \
1866 DCHAR_CPY (memory, result, length); \ 1940 DCHAR_CPY (memory, result, length); \
1867 result = memory; \ 1941 result = memory; \
1868 } 1942 }
1943#define ENSURE_ALLOCATION(needed) \
1944 ENSURE_ALLOCATION_ELSE((needed), goto out_of_memory; )
1869 1945
1870 for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) 1946 for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
1871 { 1947 {
@@ -1886,7 +1962,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1886 else 1962 else
1887 { 1963 {
1888 do 1964 do
1889 result[length++] = (unsigned char) *cp++; 1965 result[length++] = *cp++;
1890 while (--n > 0); 1966 while (--n > 0);
1891 } 1967 }
1892 } 1968 }
@@ -1926,11 +2002,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1926 case TYPE_COUNT_LONGINT_POINTER: 2002 case TYPE_COUNT_LONGINT_POINTER:
1927 *a.arg[dp->arg_index].a.a_count_longint_pointer = length; 2003 *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
1928 break; 2004 break;
1929#if HAVE_LONG_LONG_INT
1930 case TYPE_COUNT_LONGLONGINT_POINTER: 2005 case TYPE_COUNT_LONGLONGINT_POINTER:
1931 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; 2006 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
1932 break; 2007 break;
1933#endif
1934 default: 2008 default:
1935 abort (); 2009 abort ();
1936 } 2010 }
@@ -1957,15 +2031,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1957 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 2031 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
1958 abort (); 2032 abort ();
1959 arg = a.arg[dp->width_arg_index].a.a_int; 2033 arg = a.arg[dp->width_arg_index].a.a_int;
2034 width = arg;
1960 if (arg < 0) 2035 if (arg < 0)
1961 { 2036 {
1962 /* "A negative field width is taken as a '-' flag 2037 /* "A negative field width is taken as a '-' flag
1963 followed by a positive field width." */ 2038 followed by a positive field width." */
1964 flags |= FLAG_LEFT; 2039 flags |= FLAG_LEFT;
1965 width = (unsigned int) (-arg); 2040 width = -width;
1966 } 2041 }
1967 else
1968 width = arg;
1969 } 2042 }
1970 else 2043 else
1971 { 2044 {
@@ -2027,15 +2100,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2027 if (count == 0) 2100 if (count == 0)
2028 break; 2101 break;
2029 if (count < 0) 2102 if (count < 0)
2030 { 2103 goto fail_with_EILSEQ;
2031 if (!(result == resultbuf || result == NULL))
2032 free (result);
2033 if (buf_malloced != NULL)
2034 free (buf_malloced);
2035 CLEANUP ();
2036 errno = EILSEQ;
2037 return NULL;
2038 }
2039 arg_end += count; 2104 arg_end += count;
2040 characters++; 2105 characters++;
2041 } 2106 }
@@ -2052,15 +2117,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2052 if (count == 0) 2117 if (count == 0)
2053 break; 2118 break;
2054 if (count < 0) 2119 if (count < 0)
2055 { 2120 goto fail_with_EILSEQ;
2056 if (!(result == resultbuf || result == NULL))
2057 free (result);
2058 if (buf_malloced != NULL)
2059 free (buf_malloced);
2060 CLEANUP ();
2061 errno = EILSEQ;
2062 return NULL;
2063 }
2064 arg_end += count; 2121 arg_end += count;
2065 characters++; 2122 characters++;
2066 } 2123 }
@@ -2073,8 +2130,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2073 characters = 0; 2130 characters = 0;
2074 } 2131 }
2075 2132
2076 if (has_width && width > characters 2133 if (characters < width && !(dp->flags & FLAG_LEFT))
2077 && !(dp->flags & FLAG_LEFT))
2078 { 2134 {
2079 size_t n = width - characters; 2135 size_t n = width - characters;
2080 ENSURE_ALLOCATION (xsum (length, n)); 2136 ENSURE_ALLOCATION (xsum (length, n));
@@ -2107,19 +2163,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2107 converted, &converted_len); 2163 converted, &converted_len);
2108# endif 2164# endif
2109 if (converted == NULL) 2165 if (converted == NULL)
2110 { 2166 goto fail_with_errno;
2111 int saved_errno = errno;
2112 if (!(result == resultbuf || result == NULL))
2113 free (result);
2114 if (buf_malloced != NULL)
2115 free (buf_malloced);
2116 CLEANUP ();
2117 errno = saved_errno;
2118 return NULL;
2119 }
2120 if (converted != result + length) 2167 if (converted != result + length)
2121 { 2168 {
2122 ENSURE_ALLOCATION (xsum (length, converted_len)); 2169 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2170 { free (converted); goto out_of_memory; });
2123 DCHAR_CPY (result + length, converted, converted_len); 2171 DCHAR_CPY (result + length, converted, converted_len);
2124 free (converted); 2172 free (converted);
2125 } 2173 }
@@ -2127,8 +2175,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2127 } 2175 }
2128# endif 2176# endif
2129 2177
2130 if (has_width && width > characters 2178 if (characters < width && (dp->flags & FLAG_LEFT))
2131 && (dp->flags & FLAG_LEFT))
2132 { 2179 {
2133 size_t n = width - characters; 2180 size_t n = width - characters;
2134 ENSURE_ALLOCATION (xsum (length, n)); 2181 ENSURE_ALLOCATION (xsum (length, n));
@@ -2155,15 +2202,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2155 if (count == 0) 2202 if (count == 0)
2156 break; 2203 break;
2157 if (count < 0) 2204 if (count < 0)
2158 { 2205 goto fail_with_EILSEQ;
2159 if (!(result == resultbuf || result == NULL))
2160 free (result);
2161 if (buf_malloced != NULL)
2162 free (buf_malloced);
2163 CLEANUP ();
2164 errno = EILSEQ;
2165 return NULL;
2166 }
2167 arg_end += count; 2206 arg_end += count;
2168 characters++; 2207 characters++;
2169 } 2208 }
@@ -2180,15 +2219,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2180 if (count == 0) 2219 if (count == 0)
2181 break; 2220 break;
2182 if (count < 0) 2221 if (count < 0)
2183 { 2222 goto fail_with_EILSEQ;
2184 if (!(result == resultbuf || result == NULL))
2185 free (result);
2186 if (buf_malloced != NULL)
2187 free (buf_malloced);
2188 CLEANUP ();
2189 errno = EILSEQ;
2190 return NULL;
2191 }
2192 arg_end += count; 2223 arg_end += count;
2193 characters++; 2224 characters++;
2194 } 2225 }
@@ -2201,8 +2232,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2201 characters = 0; 2232 characters = 0;
2202 } 2233 }
2203 2234
2204 if (has_width && width > characters 2235 if (characters < width && !(dp->flags & FLAG_LEFT))
2205 && !(dp->flags & FLAG_LEFT))
2206 { 2236 {
2207 size_t n = width - characters; 2237 size_t n = width - characters;
2208 ENSURE_ALLOCATION (xsum (length, n)); 2238 ENSURE_ALLOCATION (xsum (length, n));
@@ -2235,19 +2265,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2235 converted, &converted_len); 2265 converted, &converted_len);
2236# endif 2266# endif
2237 if (converted == NULL) 2267 if (converted == NULL)
2238 { 2268 goto fail_with_errno;
2239 int saved_errno = errno;
2240 if (!(result == resultbuf || result == NULL))
2241 free (result);
2242 if (buf_malloced != NULL)
2243 free (buf_malloced);
2244 CLEANUP ();
2245 errno = saved_errno;
2246 return NULL;
2247 }
2248 if (converted != result + length) 2269 if (converted != result + length)
2249 { 2270 {
2250 ENSURE_ALLOCATION (xsum (length, converted_len)); 2271 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2272 { free (converted); goto out_of_memory; });
2251 DCHAR_CPY (result + length, converted, converted_len); 2273 DCHAR_CPY (result + length, converted, converted_len);
2252 free (converted); 2274 free (converted);
2253 } 2275 }
@@ -2255,8 +2277,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2255 } 2277 }
2256# endif 2278# endif
2257 2279
2258 if (has_width && width > characters 2280 if (characters < width && (dp->flags & FLAG_LEFT))
2259 && (dp->flags & FLAG_LEFT))
2260 { 2281 {
2261 size_t n = width - characters; 2282 size_t n = width - characters;
2262 ENSURE_ALLOCATION (xsum (length, n)); 2283 ENSURE_ALLOCATION (xsum (length, n));
@@ -2283,15 +2304,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2283 if (count == 0) 2304 if (count == 0)
2284 break; 2305 break;
2285 if (count < 0) 2306 if (count < 0)
2286 { 2307 goto fail_with_EILSEQ;
2287 if (!(result == resultbuf || result == NULL))
2288 free (result);
2289 if (buf_malloced != NULL)
2290 free (buf_malloced);
2291 CLEANUP ();
2292 errno = EILSEQ;
2293 return NULL;
2294 }
2295 arg_end += count; 2308 arg_end += count;
2296 characters++; 2309 characters++;
2297 } 2310 }
@@ -2308,15 +2321,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2308 if (count == 0) 2321 if (count == 0)
2309 break; 2322 break;
2310 if (count < 0) 2323 if (count < 0)
2311 { 2324 goto fail_with_EILSEQ;
2312 if (!(result == resultbuf || result == NULL))
2313 free (result);
2314 if (buf_malloced != NULL)
2315 free (buf_malloced);
2316 CLEANUP ();
2317 errno = EILSEQ;
2318 return NULL;
2319 }
2320 arg_end += count; 2325 arg_end += count;
2321 characters++; 2326 characters++;
2322 } 2327 }
@@ -2329,8 +2334,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2329 characters = 0; 2334 characters = 0;
2330 } 2335 }
2331 2336
2332 if (has_width && width > characters 2337 if (characters < width && !(dp->flags & FLAG_LEFT))
2333 && !(dp->flags & FLAG_LEFT))
2334 { 2338 {
2335 size_t n = width - characters; 2339 size_t n = width - characters;
2336 ENSURE_ALLOCATION (xsum (length, n)); 2340 ENSURE_ALLOCATION (xsum (length, n));
@@ -2363,19 +2367,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2363 converted, &converted_len); 2367 converted, &converted_len);
2364# endif 2368# endif
2365 if (converted == NULL) 2369 if (converted == NULL)
2366 { 2370 goto fail_with_errno;
2367 int saved_errno = errno;
2368 if (!(result == resultbuf || result == NULL))
2369 free (result);
2370 if (buf_malloced != NULL)
2371 free (buf_malloced);
2372 CLEANUP ();
2373 errno = saved_errno;
2374 return NULL;
2375 }
2376 if (converted != result + length) 2371 if (converted != result + length)
2377 { 2372 {
2378 ENSURE_ALLOCATION (xsum (length, converted_len)); 2373 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2374 { free (converted); goto out_of_memory; });
2379 DCHAR_CPY (result + length, converted, converted_len); 2375 DCHAR_CPY (result + length, converted, converted_len);
2380 free (converted); 2376 free (converted);
2381 } 2377 }
@@ -2383,8 +2379,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2383 } 2379 }
2384# endif 2380# endif
2385 2381
2386 if (has_width && width > characters 2382 if (characters < width && (dp->flags & FLAG_LEFT))
2387 && (dp->flags & FLAG_LEFT))
2388 { 2383 {
2389 size_t n = width - characters; 2384 size_t n = width - characters;
2390 ENSURE_ALLOCATION (xsum (length, n)); 2385 ENSURE_ALLOCATION (xsum (length, n));
@@ -2399,7 +2394,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2399 } 2394 }
2400 } 2395 }
2401#endif 2396#endif
2402#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T 2397#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T
2403 else if (dp->conversion == 's' 2398 else if (dp->conversion == 's'
2404# if WIDE_CHAR_VERSION 2399# if WIDE_CHAR_VERSION
2405 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING 2400 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
@@ -2435,15 +2430,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2435 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 2430 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2436 abort (); 2431 abort ();
2437 arg = a.arg[dp->width_arg_index].a.a_int; 2432 arg = a.arg[dp->width_arg_index].a.a_int;
2433 width = arg;
2438 if (arg < 0) 2434 if (arg < 0)
2439 { 2435 {
2440 /* "A negative field width is taken as a '-' flag 2436 /* "A negative field width is taken as a '-' flag
2441 followed by a positive field width." */ 2437 followed by a positive field width." */
2442 flags |= FLAG_LEFT; 2438 flags |= FLAG_LEFT;
2443 width = (unsigned int) (-arg); 2439 width = -width;
2444 } 2440 }
2445 else
2446 width = arg;
2447 } 2441 }
2448 else 2442 else
2449 { 2443 {
@@ -2515,16 +2509,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2515 /* Found the terminating NUL. */ 2509 /* Found the terminating NUL. */
2516 break; 2510 break;
2517 if (count < 0) 2511 if (count < 0)
2518 { 2512 /* Invalid or incomplete multibyte character. */
2519 /* Invalid or incomplete multibyte character. */ 2513 goto fail_with_EILSEQ;
2520 if (!(result == resultbuf || result == NULL))
2521 free (result);
2522 if (buf_malloced != NULL)
2523 free (buf_malloced);
2524 CLEANUP ();
2525 errno = EILSEQ;
2526 return NULL;
2527 }
2528 arg_end += count; 2514 arg_end += count;
2529 characters++; 2515 characters++;
2530 } 2516 }
@@ -2551,16 +2537,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2551 /* Found the terminating NUL. */ 2537 /* Found the terminating NUL. */
2552 break; 2538 break;
2553 if (count < 0) 2539 if (count < 0)
2554 { 2540 /* Invalid or incomplete multibyte character. */
2555 /* Invalid or incomplete multibyte character. */ 2541 goto fail_with_EILSEQ;
2556 if (!(result == resultbuf || result == NULL))
2557 free (result);
2558 if (buf_malloced != NULL)
2559 free (buf_malloced);
2560 CLEANUP ();
2561 errno = EILSEQ;
2562 return NULL;
2563 }
2564 arg_end += count; 2542 arg_end += count;
2565 characters++; 2543 characters++;
2566 } 2544 }
@@ -2573,8 +2551,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2573 characters = 0; 2551 characters = 0;
2574 } 2552 }
2575 2553
2576 if (has_width && width > characters 2554 if (characters < width && !(dp->flags & FLAG_LEFT))
2577 && !(dp->flags & FLAG_LEFT))
2578 { 2555 {
2579 size_t n = width - characters; 2556 size_t n = width - characters;
2580 ENSURE_ALLOCATION (xsum (length, n)); 2557 ENSURE_ALLOCATION (xsum (length, n));
@@ -2635,8 +2612,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2635 } 2612 }
2636 } 2613 }
2637 2614
2638 if (has_width && width > characters 2615 if (characters < width && (dp->flags & FLAG_LEFT))
2639 && (dp->flags & FLAG_LEFT))
2640 { 2616 {
2641 size_t n = width - characters; 2617 size_t n = width - characters;
2642 ENSURE_ALLOCATION (xsum (length, n)); 2618 ENSURE_ALLOCATION (xsum (length, n));
@@ -2652,7 +2628,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2652 size_t characters; 2628 size_t characters;
2653# if !DCHAR_IS_TCHAR 2629# if !DCHAR_IS_TCHAR
2654 /* This code assumes that TCHAR_T is 'char'. */ 2630 /* This code assumes that TCHAR_T is 'char'. */
2655 verify (sizeof (TCHAR_T) == 1); 2631 static_assert (sizeof (TCHAR_T) == 1);
2656 TCHAR_T *tmpsrc; 2632 TCHAR_T *tmpsrc;
2657 DCHAR_T *tmpdst; 2633 DCHAR_T *tmpdst;
2658 size_t tmpdst_len; 2634 size_t tmpdst_len;
@@ -2677,23 +2653,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2677 if (*arg_end == 0) 2653 if (*arg_end == 0)
2678 /* Found the terminating null wide character. */ 2654 /* Found the terminating null wide character. */
2679 break; 2655 break;
2680# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2656 count = local_wcrtomb (cbuf, *arg_end, &state);
2681 count = wcrtomb (cbuf, *arg_end, &state);
2682# else
2683 count = wctomb (cbuf, *arg_end);
2684# endif
2685 if (count < 0) 2657 if (count < 0)
2686 { 2658 /* Cannot convert. */
2687 /* Cannot convert. */ 2659 goto fail_with_EILSEQ;
2688 if (!(result == resultbuf || result == NULL)) 2660 if (precision < (unsigned int) count)
2689 free (result);
2690 if (buf_malloced != NULL)
2691 free (buf_malloced);
2692 CLEANUP ();
2693 errno = EILSEQ;
2694 return NULL;
2695 }
2696 if (precision < count)
2697 break; 2661 break;
2698 arg_end++; 2662 arg_end++;
2699 characters += count; 2663 characters += count;
@@ -2722,22 +2686,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2722 if (*arg_end == 0) 2686 if (*arg_end == 0)
2723 /* Found the terminating null wide character. */ 2687 /* Found the terminating null wide character. */
2724 break; 2688 break;
2725# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2689 count = local_wcrtomb (cbuf, *arg_end, &state);
2726 count = wcrtomb (cbuf, *arg_end, &state);
2727# else
2728 count = wctomb (cbuf, *arg_end);
2729# endif
2730 if (count < 0) 2690 if (count < 0)
2731 { 2691 /* Cannot convert. */
2732 /* Cannot convert. */ 2692 goto fail_with_EILSEQ;
2733 if (!(result == resultbuf || result == NULL))
2734 free (result);
2735 if (buf_malloced != NULL)
2736 free (buf_malloced);
2737 CLEANUP ();
2738 errno = EILSEQ;
2739 return NULL;
2740 }
2741 arg_end++; 2693 arg_end++;
2742 characters += count; 2694 characters += count;
2743 } 2695 }
@@ -2771,11 +2723,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2771 2723
2772 if (*arg == 0) 2724 if (*arg == 0)
2773 abort (); 2725 abort ();
2774# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2726 count = local_wcrtomb (cbuf, *arg, &state);
2775 count = wcrtomb (cbuf, *arg, &state);
2776# else
2777 count = wctomb (cbuf, *arg);
2778# endif
2779 if (count <= 0) 2727 if (count <= 0)
2780 /* Inconsistency. */ 2728 /* Inconsistency. */
2781 abort (); 2729 abort ();
@@ -2797,15 +2745,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2797 NULL, &tmpdst_len); 2745 NULL, &tmpdst_len);
2798 if (tmpdst == NULL) 2746 if (tmpdst == NULL)
2799 { 2747 {
2800 int saved_errno = errno;
2801 free (tmpsrc); 2748 free (tmpsrc);
2802 if (!(result == resultbuf || result == NULL)) 2749 goto fail_with_errno;
2803 free (result);
2804 if (buf_malloced != NULL)
2805 free (buf_malloced);
2806 CLEANUP ();
2807 errno = saved_errno;
2808 return NULL;
2809 } 2750 }
2810 free (tmpsrc); 2751 free (tmpsrc);
2811# endif 2752# endif
@@ -2827,8 +2768,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2827 /* w doesn't matter. */ 2768 /* w doesn't matter. */
2828 w = 0; 2769 w = 0;
2829 2770
2830 if (has_width && width > w 2771 if (w < width && !(dp->flags & FLAG_LEFT))
2831 && !(dp->flags & FLAG_LEFT))
2832 { 2772 {
2833 size_t n = width - w; 2773 size_t n = width - w;
2834 ENSURE_ALLOCATION (xsum (length, n)); 2774 ENSURE_ALLOCATION (xsum (length, n));
@@ -2853,11 +2793,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2853 2793
2854 if (*arg == 0) 2794 if (*arg == 0)
2855 abort (); 2795 abort ();
2856# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2796 count = local_wcrtomb (cbuf, *arg, &state);
2857 count = wcrtomb (cbuf, *arg, &state);
2858# else
2859 count = wctomb (cbuf, *arg);
2860# endif
2861 if (count <= 0) 2797 if (count <= 0)
2862 /* Inconsistency. */ 2798 /* Inconsistency. */
2863 abort (); 2799 abort ();
@@ -2882,22 +2818,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2882 2818
2883 if (*arg == 0) 2819 if (*arg == 0)
2884 abort (); 2820 abort ();
2885# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2821 count = local_wcrtomb (cbuf, *arg, &state);
2886 count = wcrtomb (cbuf, *arg, &state);
2887# else
2888 count = wctomb (cbuf, *arg);
2889# endif
2890 if (count <= 0) 2822 if (count <= 0)
2891 { 2823 /* Cannot convert. */
2892 /* Cannot convert. */ 2824 goto fail_with_EILSEQ;
2893 if (!(result == resultbuf || result == NULL))
2894 free (result);
2895 if (buf_malloced != NULL)
2896 free (buf_malloced);
2897 CLEANUP ();
2898 errno = EILSEQ;
2899 return NULL;
2900 }
2901 ENSURE_ALLOCATION (xsum (length, count)); 2825 ENSURE_ALLOCATION (xsum (length, count));
2902 memcpy (result + length, cbuf, count); 2826 memcpy (result + length, cbuf, count);
2903 length += count; 2827 length += count;
@@ -2905,14 +2829,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2905 } 2829 }
2906 } 2830 }
2907# else 2831# else
2908 ENSURE_ALLOCATION (xsum (length, tmpdst_len)); 2832 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
2833 { free (tmpdst); goto out_of_memory; });
2909 DCHAR_CPY (result + length, tmpdst, tmpdst_len); 2834 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
2910 free (tmpdst); 2835 free (tmpdst);
2911 length += tmpdst_len; 2836 length += tmpdst_len;
2912# endif 2837# endif
2913 2838
2914 if (has_width && width > w 2839 if (w < width && (dp->flags & FLAG_LEFT))
2915 && (dp->flags & FLAG_LEFT))
2916 { 2840 {
2917 size_t n = width - w; 2841 size_t n = width - w;
2918 ENSURE_ALLOCATION (xsum (length, n)); 2842 ENSURE_ALLOCATION (xsum (length, n));
@@ -2923,6 +2847,202 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2923# endif 2847# endif
2924 } 2848 }
2925#endif 2849#endif
2850#if ENABLE_WCHAR_FALLBACK && HAVE_WINT_T && !WIDE_CHAR_VERSION
2851 else if (dp->conversion == 'c'
2852 && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR)
2853 {
2854 /* Implement the 'lc' directive ourselves, in order to provide
2855 the fallback that avoids EILSEQ. */
2856 int flags = dp->flags;
2857 int has_width;
2858 size_t width;
2859
2860 has_width = 0;
2861 width = 0;
2862 if (dp->width_start != dp->width_end)
2863 {
2864 if (dp->width_arg_index != ARG_NONE)
2865 {
2866 int arg;
2867
2868 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2869 abort ();
2870 arg = a.arg[dp->width_arg_index].a.a_int;
2871 width = arg;
2872 if (arg < 0)
2873 {
2874 /* "A negative field width is taken as a '-' flag
2875 followed by a positive field width." */
2876 flags |= FLAG_LEFT;
2877 width = -width;
2878 }
2879 }
2880 else
2881 {
2882 const FCHAR_T *digitp = dp->width_start;
2883
2884 do
2885 width = xsum (xtimes (width, 10), *digitp++ - '0');
2886 while (digitp != dp->width_end);
2887 }
2888 has_width = 1;
2889 }
2890
2891 /* %lc in vasnprintf. See the specification of fprintf. */
2892 {
2893 wchar_t arg = (wchar_t) a.arg[dp->arg_index].a.a_wide_char;
2894 size_t characters;
2895# if !DCHAR_IS_TCHAR
2896 /* This code assumes that TCHAR_T is 'char'. */
2897 static_assert (sizeof (TCHAR_T) == 1);
2898 TCHAR_T tmpsrc[64]; /* Assume MB_CUR_MAX <= 64. */
2899 DCHAR_T *tmpdst;
2900 size_t tmpdst_len;
2901# endif
2902 size_t w;
2903
2904# if DCHAR_IS_TCHAR
2905 if (has_width)
2906# endif
2907 {
2908 /* Count the number of bytes. */
2909 characters = 0;
2910 if (arg != 0)
2911 {
2912 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2913 int count;
2914# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2915 mbstate_t state;
2916 memset (&state, '\0', sizeof (mbstate_t));
2917# endif
2918
2919 count = local_wcrtomb (cbuf, arg, &state);
2920 if (count < 0)
2921 /* Inconsistency. */
2922 abort ();
2923 characters = count;
2924 }
2925 }
2926# if DCHAR_IS_TCHAR
2927 else
2928 {
2929 /* The number of bytes doesn't matter. */
2930 characters = 0;
2931 }
2932# endif
2933
2934# if !DCHAR_IS_TCHAR
2935 /* Convert the string into a piece of temporary memory. */
2936 if (characters > 0) /* implies arg != 0 */
2937 {
2938 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2939 int count;
2940# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2941 mbstate_t state;
2942 memset (&state, '\0', sizeof (mbstate_t));
2943# endif
2944
2945 count = local_wcrtomb (cbuf, arg, &state);
2946 if (count <= 0)
2947 /* Inconsistency. */
2948 abort ();
2949 memcpy (tmpsrc, cbuf, count);
2950 }
2951
2952 /* Convert from TCHAR_T[] to DCHAR_T[]. */
2953 tmpdst =
2954 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2955 iconveh_question_mark,
2956 tmpsrc, characters,
2957 NULL,
2958 NULL, &tmpdst_len);
2959 if (tmpdst == NULL)
2960 goto fail_with_errno;
2961# endif
2962
2963 if (has_width)
2964 {
2965# if ENABLE_UNISTDIO
2966 /* Outside POSIX, it's preferable to compare the width
2967 against the number of _characters_ of the converted
2968 value. */
2969 w = DCHAR_MBSNLEN (result + length, characters);
2970# else
2971 /* The width is compared against the number of _bytes_
2972 of the converted value, says POSIX. */
2973 w = characters;
2974# endif
2975 }
2976 else
2977 /* w doesn't matter. */
2978 w = 0;
2979
2980 if (w < width && !(dp->flags & FLAG_LEFT))
2981 {
2982 size_t n = width - w;
2983 ENSURE_ALLOCATION (xsum (length, n));
2984 DCHAR_SET (result + length, ' ', n);
2985 length += n;
2986 }
2987
2988# if DCHAR_IS_TCHAR
2989 if (has_width)
2990 {
2991 /* We know the number of bytes in advance. */
2992 ENSURE_ALLOCATION (xsum (length, characters));
2993 if (characters > 0) /* implies arg != 0 */
2994 {
2995 int count;
2996# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2997 mbstate_t state;
2998 memset (&state, '\0', sizeof (mbstate_t));
2999# endif
3000
3001 count = local_wcrtomb (result + length, arg, &state);
3002 if (count <= 0)
3003 /* Inconsistency. */
3004 abort ();
3005 length += count;
3006 }
3007 }
3008 else
3009 {
3010 if (arg != 0)
3011 {
3012 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3013 int count;
3014# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
3015 mbstate_t state;
3016 memset (&state, '\0', sizeof (mbstate_t));
3017# endif
3018
3019 count = local_wcrtomb (cbuf, arg, &state);
3020 if (count <= 0)
3021 /* Inconsistency. */
3022 abort ();
3023 ENSURE_ALLOCATION (xsum (length, count));
3024 memcpy (result + length, cbuf, count);
3025 length += count;
3026 }
3027 }
3028# else
3029 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
3030 { free (tmpdst); goto out_of_memory; });
3031 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
3032 free (tmpdst);
3033 length += tmpdst_len;
3034# endif
3035
3036 if (w < width && (dp->flags & FLAG_LEFT))
3037 {
3038 size_t n = width - w;
3039 ENSURE_ALLOCATION (xsum (length, n));
3040 DCHAR_SET (result + length, ' ', n);
3041 length += n;
3042 }
3043 }
3044 }
3045#endif
2926#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL 3046#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
2927 else if ((dp->conversion == 'a' || dp->conversion == 'A') 3047 else if ((dp->conversion == 'a' || dp->conversion == 'A')
2928# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) 3048# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
@@ -2939,17 +3059,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2939 { 3059 {
2940 arg_type type = a.arg[dp->arg_index].type; 3060 arg_type type = a.arg[dp->arg_index].type;
2941 int flags = dp->flags; 3061 int flags = dp->flags;
2942 int has_width;
2943 size_t width; 3062 size_t width;
2944 int has_precision; 3063 int has_precision;
2945 size_t precision; 3064 size_t precision;
2946 size_t tmp_length; 3065 size_t tmp_length;
3066 size_t count;
2947 DCHAR_T tmpbuf[700]; 3067 DCHAR_T tmpbuf[700];
2948 DCHAR_T *tmp; 3068 DCHAR_T *tmp;
2949 DCHAR_T *pad_ptr; 3069 DCHAR_T *pad_ptr;
2950 DCHAR_T *p; 3070 DCHAR_T *p;
2951 3071
2952 has_width = 0;
2953 width = 0; 3072 width = 0;
2954 if (dp->width_start != dp->width_end) 3073 if (dp->width_start != dp->width_end)
2955 { 3074 {
@@ -2960,15 +3079,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2960 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 3079 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2961 abort (); 3080 abort ();
2962 arg = a.arg[dp->width_arg_index].a.a_int; 3081 arg = a.arg[dp->width_arg_index].a.a_int;
3082 width = arg;
2963 if (arg < 0) 3083 if (arg < 0)
2964 { 3084 {
2965 /* "A negative field width is taken as a '-' flag 3085 /* "A negative field width is taken as a '-' flag
2966 followed by a positive field width." */ 3086 followed by a positive field width." */
2967 flags |= FLAG_LEFT; 3087 flags |= FLAG_LEFT;
2968 width = (unsigned int) (-arg); 3088 width = -width;
2969 } 3089 }
2970 else
2971 width = arg;
2972 } 3090 }
2973 else 3091 else
2974 { 3092 {
@@ -2978,7 +3096,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2978 width = xsum (xtimes (width, 10), *digitp++ - '0'); 3096 width = xsum (xtimes (width, 10), *digitp++ - '0');
2979 while (digitp != dp->width_end); 3097 while (digitp != dp->width_end);
2980 } 3098 }
2981 has_width = 1;
2982 } 3099 }
2983 3100
2984 has_precision = 0; 3101 has_precision = 0;
@@ -3354,11 +3471,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3354 abort (); 3471 abort ();
3355# endif 3472# endif
3356 } 3473 }
3474
3357 /* The generated string now extends from tmp to p, with the 3475 /* The generated string now extends from tmp to p, with the
3358 zero padding insertion point being at pad_ptr. */ 3476 zero padding insertion point being at pad_ptr. */
3359 if (has_width && p - tmp < width) 3477 count = p - tmp;
3478
3479 if (count < width)
3360 { 3480 {
3361 size_t pad = width - (p - tmp); 3481 size_t pad = width - count;
3362 DCHAR_T *end = p + pad; 3482 DCHAR_T *end = p + pad;
3363 3483
3364 if (flags & FLAG_LEFT) 3484 if (flags & FLAG_LEFT)
@@ -3391,28 +3511,26 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3391 p = end; 3511 p = end;
3392 } 3512 }
3393 3513
3394 { 3514 count = p - tmp;
3395 size_t count = p - tmp;
3396 3515
3397 if (count >= tmp_length) 3516 if (count >= tmp_length)
3398 /* tmp_length was incorrectly calculated - fix the 3517 /* tmp_length was incorrectly calculated - fix the
3399 code above! */ 3518 code above! */
3400 abort (); 3519 abort ();
3401 3520
3402 /* Make room for the result. */ 3521 /* Make room for the result. */
3403 if (count >= allocated - length) 3522 if (count >= allocated - length)
3404 { 3523 {
3405 size_t n = xsum (length, count); 3524 size_t n = xsum (length, count);
3406 3525
3407 ENSURE_ALLOCATION (n); 3526 ENSURE_ALLOCATION (n);
3408 } 3527 }
3409 3528
3410 /* Append the result. */ 3529 /* Append the result. */
3411 memcpy (result + length, tmp, count * sizeof (DCHAR_T)); 3530 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
3412 if (tmp != tmpbuf) 3531 if (tmp != tmpbuf)
3413 free (tmp); 3532 free (tmp);
3414 length += count; 3533 length += count;
3415 }
3416 } 3534 }
3417#endif 3535#endif
3418#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 3536#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
@@ -3446,8 +3564,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3446 arg_type type = a.arg[dp->arg_index].type; 3564 arg_type type = a.arg[dp->arg_index].type;
3447# endif 3565# endif
3448 int flags = dp->flags; 3566 int flags = dp->flags;
3449 int has_width;
3450 size_t width; 3567 size_t width;
3568 size_t count;
3451 int has_precision; 3569 int has_precision;
3452 size_t precision; 3570 size_t precision;
3453 size_t tmp_length; 3571 size_t tmp_length;
@@ -3456,7 +3574,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3456 DCHAR_T *pad_ptr; 3574 DCHAR_T *pad_ptr;
3457 DCHAR_T *p; 3575 DCHAR_T *p;
3458 3576
3459 has_width = 0;
3460 width = 0; 3577 width = 0;
3461 if (dp->width_start != dp->width_end) 3578 if (dp->width_start != dp->width_end)
3462 { 3579 {
@@ -3467,15 +3584,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3467 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 3584 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3468 abort (); 3585 abort ();
3469 arg = a.arg[dp->width_arg_index].a.a_int; 3586 arg = a.arg[dp->width_arg_index].a.a_int;
3587 width = arg;
3470 if (arg < 0) 3588 if (arg < 0)
3471 { 3589 {
3472 /* "A negative field width is taken as a '-' flag 3590 /* "A negative field width is taken as a '-' flag
3473 followed by a positive field width." */ 3591 followed by a positive field width." */
3474 flags |= FLAG_LEFT; 3592 flags |= FLAG_LEFT;
3475 width = (unsigned int) (-arg); 3593 width = -width;
3476 } 3594 }
3477 else
3478 width = arg;
3479 } 3595 }
3480 else 3596 else
3481 { 3597 {
@@ -3485,7 +3601,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3485 width = xsum (xtimes (width, 10), *digitp++ - '0'); 3601 width = xsum (xtimes (width, 10), *digitp++ - '0');
3486 while (digitp != dp->width_end); 3602 while (digitp != dp->width_end);
3487 } 3603 }
3488 has_width = 1;
3489 } 3604 }
3490 3605
3491 has_precision = 0; 3606 has_precision = 0;
@@ -3925,9 +4040,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3925 digits without trailing zeroes. */ 4040 digits without trailing zeroes. */
3926 if (exponent >= 0) 4041 if (exponent >= 0)
3927 { 4042 {
3928 size_t count = exponent + 1; 4043 size_t ecount = exponent + 1;
3929 /* Note: count <= precision = ndigits. */ 4044 /* Note: count <= precision = ndigits. */
3930 for (; count > 0; count--) 4045 for (; ecount > 0; ecount--)
3931 *p++ = digits[--ndigits]; 4046 *p++ = digits[--ndigits];
3932 if ((flags & FLAG_ALT) || ndigits > nzeroes) 4047 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3933 { 4048 {
@@ -3941,10 +4056,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3941 } 4056 }
3942 else 4057 else
3943 { 4058 {
3944 size_t count = -exponent - 1; 4059 size_t ecount = -exponent - 1;
3945 *p++ = '0'; 4060 *p++ = '0';
3946 *p++ = decimal_point_char (); 4061 *p++ = decimal_point_char ();
3947 for (; count > 0; count--) 4062 for (; ecount > 0; ecount--)
3948 *p++ = '0'; 4063 *p++ = '0';
3949 while (ndigits > nzeroes) 4064 while (ndigits > nzeroes)
3950 { 4065 {
@@ -4249,7 +4364,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4249 static const wchar_t decimal_format[] = 4364 static const wchar_t decimal_format[] =
4250 /* Produce the same number of exponent digits 4365 /* Produce the same number of exponent digits
4251 as the native printf implementation. */ 4366 as the native printf implementation. */
4252# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4367# if defined _WIN32 && ! defined __CYGWIN__
4253 { '%', '+', '.', '3', 'd', '\0' }; 4368 { '%', '+', '.', '3', 'd', '\0' };
4254# else 4369# else
4255 { '%', '+', '.', '2', 'd', '\0' }; 4370 { '%', '+', '.', '2', 'd', '\0' };
@@ -4263,7 +4378,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4263 static const char decimal_format[] = 4378 static const char decimal_format[] =
4264 /* Produce the same number of exponent digits 4379 /* Produce the same number of exponent digits
4265 as the native printf implementation. */ 4380 as the native printf implementation. */
4266# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4381# if defined _WIN32 && ! defined __CYGWIN__
4267 "%+.3d"; 4382 "%+.3d";
4268# else 4383# else
4269 "%+.2d"; 4384 "%+.2d";
@@ -4395,9 +4510,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4395 digits without trailing zeroes. */ 4510 digits without trailing zeroes. */
4396 if (exponent >= 0) 4511 if (exponent >= 0)
4397 { 4512 {
4398 size_t count = exponent + 1; 4513 size_t ecount = exponent + 1;
4399 /* Note: count <= precision = ndigits. */ 4514 /* Note: ecount <= precision = ndigits. */
4400 for (; count > 0; count--) 4515 for (; ecount > 0; ecount--)
4401 *p++ = digits[--ndigits]; 4516 *p++ = digits[--ndigits];
4402 if ((flags & FLAG_ALT) || ndigits > nzeroes) 4517 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4403 { 4518 {
@@ -4411,10 +4526,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4411 } 4526 }
4412 else 4527 else
4413 { 4528 {
4414 size_t count = -exponent - 1; 4529 size_t ecount = -exponent - 1;
4415 *p++ = '0'; 4530 *p++ = '0';
4416 *p++ = decimal_point_char (); 4531 *p++ = decimal_point_char ();
4417 for (; count > 0; count--) 4532 for (; ecount > 0; ecount--)
4418 *p++ = '0'; 4533 *p++ = '0';
4419 while (ndigits > nzeroes) 4534 while (ndigits > nzeroes)
4420 { 4535 {
@@ -4442,7 +4557,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4442 static const wchar_t decimal_format[] = 4557 static const wchar_t decimal_format[] =
4443 /* Produce the same number of exponent digits 4558 /* Produce the same number of exponent digits
4444 as the native printf implementation. */ 4559 as the native printf implementation. */
4445# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4560# if defined _WIN32 && ! defined __CYGWIN__
4446 { '%', '+', '.', '3', 'd', '\0' }; 4561 { '%', '+', '.', '3', 'd', '\0' };
4447# else 4562# else
4448 { '%', '+', '.', '2', 'd', '\0' }; 4563 { '%', '+', '.', '2', 'd', '\0' };
@@ -4456,7 +4571,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4456 static const char decimal_format[] = 4571 static const char decimal_format[] =
4457 /* Produce the same number of exponent digits 4572 /* Produce the same number of exponent digits
4458 as the native printf implementation. */ 4573 as the native printf implementation. */
4459# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4574# if defined _WIN32 && ! defined __CYGWIN__
4460 "%+.3d"; 4575 "%+.3d";
4461# else 4576# else
4462 "%+.2d"; 4577 "%+.2d";
@@ -4514,7 +4629,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4514 *p++ = '+'; 4629 *p++ = '+';
4515 /* Produce the same number of exponent digits as 4630 /* Produce the same number of exponent digits as
4516 the native printf implementation. */ 4631 the native printf implementation. */
4517# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4632# if defined _WIN32 && ! defined __CYGWIN__
4518 *p++ = '0'; 4633 *p++ = '0';
4519# endif 4634# endif
4520 *p++ = '0'; 4635 *p++ = '0';
@@ -4542,9 +4657,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4542 4657
4543 /* The generated string now extends from tmp to p, with the 4658 /* The generated string now extends from tmp to p, with the
4544 zero padding insertion point being at pad_ptr. */ 4659 zero padding insertion point being at pad_ptr. */
4545 if (has_width && p - tmp < width) 4660 count = p - tmp;
4661
4662 if (count < width)
4546 { 4663 {
4547 size_t pad = width - (p - tmp); 4664 size_t pad = width - count;
4548 DCHAR_T *end = p + pad; 4665 DCHAR_T *end = p + pad;
4549 4666
4550 if (flags & FLAG_LEFT) 4667 if (flags & FLAG_LEFT)
@@ -4577,39 +4694,39 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4577 p = end; 4694 p = end;
4578 } 4695 }
4579 4696
4580 { 4697 count = p - tmp;
4581 size_t count = p - tmp;
4582 4698
4583 if (count >= tmp_length) 4699 if (count >= tmp_length)
4584 /* tmp_length was incorrectly calculated - fix the 4700 /* tmp_length was incorrectly calculated - fix the
4585 code above! */ 4701 code above! */
4586 abort (); 4702 abort ();
4587 4703
4588 /* Make room for the result. */ 4704 /* Make room for the result. */
4589 if (count >= allocated - length) 4705 if (count >= allocated - length)
4590 { 4706 {
4591 size_t n = xsum (length, count); 4707 size_t n = xsum (length, count);
4592 4708
4593 ENSURE_ALLOCATION (n); 4709 ENSURE_ALLOCATION (n);
4594 } 4710 }
4595 4711
4596 /* Append the result. */ 4712 /* Append the result. */
4597 memcpy (result + length, tmp, count * sizeof (DCHAR_T)); 4713 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
4598 if (tmp != tmpbuf) 4714 if (tmp != tmpbuf)
4599 free (tmp); 4715 free (tmp);
4600 length += count; 4716 length += count;
4601 }
4602 } 4717 }
4603#endif 4718#endif
4604 else 4719 else
4605 { 4720 {
4606 arg_type type = a.arg[dp->arg_index].type; 4721 arg_type type = a.arg[dp->arg_index].type;
4607 int flags = dp->flags; 4722 int flags = dp->flags;
4608#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 4723#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4609 int has_width; 4724 int has_width;
4725#endif
4726#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4610 size_t width; 4727 size_t width;
4611#endif 4728#endif
4612#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION 4729#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
4613 int has_precision; 4730 int has_precision;
4614 size_t precision; 4731 size_t precision;
4615#endif 4732#endif
@@ -4635,8 +4752,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4635 TCHAR_T *tmp; 4752 TCHAR_T *tmp;
4636#endif 4753#endif
4637 4754
4638#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 4755#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4639 has_width = 0; 4756 has_width = 0;
4757#endif
4758#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4640 width = 0; 4759 width = 0;
4641 if (dp->width_start != dp->width_end) 4760 if (dp->width_start != dp->width_end)
4642 { 4761 {
@@ -4647,15 +4766,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4647 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 4766 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4648 abort (); 4767 abort ();
4649 arg = a.arg[dp->width_arg_index].a.a_int; 4768 arg = a.arg[dp->width_arg_index].a.a_int;
4769 width = arg;
4650 if (arg < 0) 4770 if (arg < 0)
4651 { 4771 {
4652 /* "A negative field width is taken as a '-' flag 4772 /* "A negative field width is taken as a '-' flag
4653 followed by a positive field width." */ 4773 followed by a positive field width." */
4654 flags |= FLAG_LEFT; 4774 flags |= FLAG_LEFT;
4655 width = (unsigned int) (-arg); 4775 width = -width;
4656 } 4776 }
4657 else
4658 width = arg;
4659 } 4777 }
4660 else 4778 else
4661 { 4779 {
@@ -4665,11 +4783,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4665 width = xsum (xtimes (width, 10), *digitp++ - '0'); 4783 width = xsum (xtimes (width, 10), *digitp++ - '0');
4666 while (digitp != dp->width_end); 4784 while (digitp != dp->width_end);
4667 } 4785 }
4786#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4668 has_width = 1; 4787 has_width = 1;
4788#endif
4669 } 4789 }
4670#endif 4790#endif
4671 4791
4672#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION 4792#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
4673 has_precision = 0; 4793 has_precision = 0;
4674 precision = 6; 4794 precision = 6;
4675 if (dp->precision_start != dp->precision_end) 4795 if (dp->precision_start != dp->precision_end)
@@ -4805,7 +4925,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4805 { 4925 {
4806 const FCHAR_T *mp = dp->width_start; 4926 const FCHAR_T *mp = dp->width_start;
4807 do 4927 do
4808 *fbp++ = (unsigned char) *mp++; 4928 *fbp++ = *mp++;
4809 while (--n > 0); 4929 while (--n > 0);
4810 } 4930 }
4811 } 4931 }
@@ -4826,7 +4946,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4826 { 4946 {
4827 const FCHAR_T *mp = dp->precision_start; 4947 const FCHAR_T *mp = dp->precision_start;
4828 do 4948 do
4829 *fbp++ = (unsigned char) *mp++; 4949 *fbp++ = *mp++;
4830 while (--n > 0); 4950 while (--n > 0);
4831 } 4951 }
4832 } 4952 }
@@ -4834,19 +4954,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4834 4954
4835 switch (type) 4955 switch (type)
4836 { 4956 {
4837#if HAVE_LONG_LONG_INT
4838 case TYPE_LONGLONGINT: 4957 case TYPE_LONGLONGINT:
4839 case TYPE_ULONGLONGINT: 4958 case TYPE_ULONGLONGINT:
4840# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4959#if defined _WIN32 && ! defined __CYGWIN__
4841 *fbp++ = 'I'; 4960 *fbp++ = 'I';
4842 *fbp++ = '6'; 4961 *fbp++ = '6';
4843 *fbp++ = '4'; 4962 *fbp++ = '4';
4844 break; 4963 break;
4845# else 4964#else
4846 *fbp++ = 'l'; 4965 *fbp++ = 'l';
4847 /*FALLTHROUGH*/
4848# endif
4849#endif 4966#endif
4967 FALLTHROUGH;
4850 case TYPE_LONGINT: 4968 case TYPE_LONGINT:
4851 case TYPE_ULONGINT: 4969 case TYPE_ULONGINT:
4852#if HAVE_WINT_T 4970#if HAVE_WINT_T
@@ -4870,20 +4988,32 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4870#endif 4988#endif
4871 *fbp = dp->conversion; 4989 *fbp = dp->conversion;
4872#if USE_SNPRINTF 4990#if USE_SNPRINTF
4873# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) 4991# if ((HAVE_SNPRINTF_RETVAL_C99 && HAVE_SNPRINTF_TRUNCATION_C99) \
4874 fbp[1] = '%'; 4992 || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
4875 fbp[2] = 'n'; 4993 && !defined __UCLIBC__) \
4876 fbp[3] = '\0'; 4994 || (defined __APPLE__ && defined __MACH__) \
4877# else 4995 || defined __ANDROID__ \
4878 /* On glibc2 systems from glibc >= 2.3 - probably also older 4996 || (defined _WIN32 && ! defined __CYGWIN__))
4879 ones - we know that snprintf's return value conforms to 4997 /* On systems where we know that snprintf's return value
4880 ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and 4998 conforms to ISO C 99 (HAVE_SNPRINTF_RETVAL_C99) and that
4881 gl_SNPRINTF_TRUNCATION_C99 pass. 4999 snprintf always produces NUL-terminated strings
4882 Therefore we can avoid using %n in this situation. 5000 (HAVE_SNPRINTF_TRUNCATION_C99), it is possible to avoid
4883 On glibc2 systems from 2004-10-18 or newer, the use of %n 5001 using %n. And it is desirable to do so, because more and
4884 in format strings in writable memory may crash the program 5002 more platforms no longer support %n, for "security reasons".
4885 (if compiled with _FORTIFY_SOURCE=2), so we should avoid it 5003 In particular, the following platforms:
4886 in this situation. */ 5004 - On glibc2 systems from 2004-10-18 or newer, the use of
5005 %n in format strings in writable memory may crash the
5006 program (if compiled with _FORTIFY_SOURCE=2).
5007 - On Mac OS X 10.13 or newer, the use of %n in format
5008 strings in writable memory by default crashes the
5009 program.
5010 - On Android, starting on 2018-03-07, the use of %n in
5011 format strings produces a fatal error (see
5012 <https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>).
5013 On these platforms, HAVE_SNPRINTF_RETVAL_C99 and
5014 HAVE_SNPRINTF_TRUNCATION_C99 are 1. We have listed them
5015 explicitly in the condition above, in case of cross-
5016 compilation (just to be sure). */
4887 /* On native Windows systems (such as mingw), we can avoid using 5017 /* On native Windows systems (such as mingw), we can avoid using
4888 %n because: 5018 %n because:
4889 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, 5019 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
@@ -4896,10 +5026,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4896 On native Windows systems (such as mingw) where the OS is 5026 On native Windows systems (such as mingw) where the OS is
4897 Windows Vista, the use of %n in format strings by default 5027 Windows Vista, the use of %n in format strings by default
4898 crashes the program. See 5028 crashes the program. See
4899 <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and 5029 <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
4900 <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx> 5030 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
4901 So we should avoid %n in this situation. */ 5031 So we should avoid %n in this situation. */
4902 fbp[1] = '\0'; 5032 fbp[1] = '\0';
5033# else /* AIX <= 5.1, HP-UX, IRIX, OSF/1, Solaris <= 9, BeOS */
5034 fbp[1] = '%';
5035 fbp[2] = 'n';
5036 fbp[3] = '\0';
4903# endif 5037# endif
4904#else 5038#else
4905 fbp[1] = '\0'; 5039 fbp[1] = '\0';
@@ -5043,7 +5177,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5043 SNPRINTF_BUF (arg); 5177 SNPRINTF_BUF (arg);
5044 } 5178 }
5045 break; 5179 break;
5046#if HAVE_LONG_LONG_INT
5047 case TYPE_LONGLONGINT: 5180 case TYPE_LONGLONGINT:
5048 { 5181 {
5049 long long int arg = a.arg[dp->arg_index].a.a_longlongint; 5182 long long int arg = a.arg[dp->arg_index].a.a_longlongint;
@@ -5056,7 +5189,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5056 SNPRINTF_BUF (arg); 5189 SNPRINTF_BUF (arg);
5057 } 5190 }
5058 break; 5191 break;
5059#endif
5060 case TYPE_DOUBLE: 5192 case TYPE_DOUBLE:
5061 { 5193 {
5062 double arg = a.arg[dp->arg_index].a.a_double; 5194 double arg = a.arg[dp->arg_index].a.a_double;
@@ -5116,7 +5248,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5116 { 5248 {
5117 /* Verify that snprintf() has NUL-terminated its 5249 /* Verify that snprintf() has NUL-terminated its
5118 result. */ 5250 result. */
5119 if (count < maxlen 5251 if ((unsigned int) count < maxlen
5120 && ((TCHAR_T *) (result + length)) [count] != '\0') 5252 && ((TCHAR_T *) (result + length)) [count] != '\0')
5121 abort (); 5253 abort ();
5122 /* Portability hack. */ 5254 /* Portability hack. */
@@ -5139,7 +5271,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5139 /* Look at the snprintf() return value. */ 5271 /* Look at the snprintf() return value. */
5140 if (retcount < 0) 5272 if (retcount < 0)
5141 { 5273 {
5142# if !HAVE_SNPRINTF_RETVAL_C99 5274# if !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
5143 /* HP-UX 10.20 snprintf() is doubly deficient: 5275 /* HP-UX 10.20 snprintf() is doubly deficient:
5144 It doesn't understand the '%n' directive, 5276 It doesn't understand the '%n' directive,
5145 *and* it returns -1 (rather than the length 5277 *and* it returns -1 (rather than the length
@@ -5153,7 +5285,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5153 size_t tmp_length = 5285 size_t tmp_length =
5154 MAX_ROOM_NEEDED (&a, dp->arg_index, 5286 MAX_ROOM_NEEDED (&a, dp->arg_index,
5155 dp->conversion, type, flags, 5287 dp->conversion, type, flags,
5156 has_width ? width : 0, 5288 width,
5157 has_precision, 5289 has_precision,
5158 precision, pad_ourselves); 5290 precision, pad_ourselves);
5159 5291
@@ -5188,22 +5320,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5188 /* Attempt to handle failure. */ 5320 /* Attempt to handle failure. */
5189 if (count < 0) 5321 if (count < 0)
5190 { 5322 {
5191 /* SNPRINTF or sprintf failed. Save and use the errno 5323 /* SNPRINTF or sprintf failed. Use the errno that it
5192 that it has set, if any. */ 5324 has set, if any. */
5193 int saved_errno = errno; 5325 if (errno == 0)
5194 5326 {
5195 if (!(result == resultbuf || result == NULL)) 5327 if (dp->conversion == 'c' || dp->conversion == 's')
5196 free (result); 5328 errno = EILSEQ;
5197 if (buf_malloced != NULL) 5329 else
5198 free (buf_malloced); 5330 errno = EINVAL;
5199 CLEANUP (); 5331 }
5200 errno = 5332
5201 (saved_errno != 0 5333 goto fail_with_errno;
5202 ? saved_errno
5203 : (dp->conversion == 'c' || dp->conversion == 's'
5204 ? EILSEQ
5205 : EINVAL));
5206 return NULL;
5207 } 5334 }
5208 5335
5209#if USE_SNPRINTF 5336#if USE_SNPRINTF
@@ -5324,7 +5451,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5324 DCHAR_T *tmpdst; 5451 DCHAR_T *tmpdst;
5325 size_t tmpdst_len; 5452 size_t tmpdst_len;
5326 /* This code assumes that TCHAR_T is 'char'. */ 5453 /* This code assumes that TCHAR_T is 'char'. */
5327 verify (sizeof (TCHAR_T) == 1); 5454 static_assert (sizeof (TCHAR_T) == 1);
5328# if USE_SNPRINTF 5455# if USE_SNPRINTF
5329 tmpsrc = (TCHAR_T *) (result + length); 5456 tmpsrc = (TCHAR_T *) (result + length);
5330# else 5457# else
@@ -5337,17 +5464,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5337 NULL, 5464 NULL,
5338 NULL, &tmpdst_len); 5465 NULL, &tmpdst_len);
5339 if (tmpdst == NULL) 5466 if (tmpdst == NULL)
5340 { 5467 goto fail_with_errno;
5341 int saved_errno = errno; 5468 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
5342 if (!(result == resultbuf || result == NULL)) 5469 { free (tmpdst); goto out_of_memory; });
5343 free (result);
5344 if (buf_malloced != NULL)
5345 free (buf_malloced);
5346 CLEANUP ();
5347 errno = saved_errno;
5348 return NULL;
5349 }
5350 ENSURE_ALLOCATION (xsum (length, tmpdst_len));
5351 DCHAR_CPY (result + length, tmpdst, tmpdst_len); 5470 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
5352 free (tmpdst); 5471 free (tmpdst);
5353 count = tmpdst_len; 5472 count = tmpdst_len;
@@ -5391,7 +5510,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5391 tmpsrc += count; 5510 tmpsrc += count;
5392 tmpdst += count; 5511 tmpdst += count;
5393 for (n = count; n > 0; n--) 5512 for (n = count; n > 0; n--)
5394 *--tmpdst = (unsigned char) *--tmpsrc; 5513 *--tmpdst = *--tmpsrc;
5395 } 5514 }
5396 } 5515 }
5397#endif 5516#endif
@@ -5570,25 +5689,40 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5570 5689
5571#if USE_SNPRINTF 5690#if USE_SNPRINTF
5572 overflow: 5691 overflow:
5573 if (!(result == resultbuf || result == NULL))
5574 free (result);
5575 if (buf_malloced != NULL)
5576 free (buf_malloced);
5577 CLEANUP ();
5578 errno = EOVERFLOW; 5692 errno = EOVERFLOW;
5579 return NULL; 5693 goto fail_with_errno;
5580#endif 5694#endif
5581 5695
5582 out_of_memory: 5696 out_of_memory:
5583 if (!(result == resultbuf || result == NULL)) 5697 errno = ENOMEM;
5698 goto fail_with_errno;
5699
5700#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T)
5701 fail_with_EILSEQ:
5702 errno = EILSEQ;
5703 goto fail_with_errno;
5704#endif
5705
5706 fail_with_errno:
5707 if (result != resultbuf)
5584 free (result); 5708 free (result);
5585 if (buf_malloced != NULL) 5709 if (buf_malloced != NULL)
5586 free (buf_malloced); 5710 free (buf_malloced);
5587 out_of_memory_1:
5588 CLEANUP (); 5711 CLEANUP ();
5589 errno = ENOMEM;
5590 return NULL; 5712 return NULL;
5591 } 5713 }
5714
5715 out_of_memory_1:
5716 errno = ENOMEM;
5717 goto fail_1_with_errno;
5718
5719 fail_1_with_EINVAL:
5720 errno = EINVAL;
5721 goto fail_1_with_errno;
5722
5723 fail_1_with_errno:
5724 CLEANUP ();
5725 return NULL;
5592} 5726}
5593 5727
5594#undef MAX_ROOM_NEEDED 5728#undef MAX_ROOM_NEEDED
diff --git a/gl/vasnprintf.h b/gl/vasnprintf.h
index 7658f505..f69649fb 100644
--- a/gl/vasnprintf.h
+++ b/gl/vasnprintf.h
@@ -1,18 +1,18 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _VASNPRINTF_H 17#ifndef _VASNPRINTF_H
18#define _VASNPRINTF_H 18#define _VASNPRINTF_H
@@ -23,17 +23,8 @@
23/* Get size_t. */ 23/* Get size_t. */
24#include <stddef.h> 24#include <stddef.h>
25 25
26/* The __attribute__ feature is available in gcc versions 2.5 and later. 26/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD. */
27 The __-protected variants of the attributes 'format' and 'printf' are 27#include <stdio.h>
28 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
29 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
30 gnulib and libintl do '#define printf __printf__' when they override
31 the 'printf' function. */
32#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
33# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
34#else
35# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
36#endif
37 28
38#ifdef __cplusplus 29#ifdef __cplusplus
39extern "C" { 30extern "C" {
@@ -67,10 +58,12 @@ extern "C" {
67# define asnprintf rpl_asnprintf 58# define asnprintf rpl_asnprintf
68# define vasnprintf rpl_vasnprintf 59# define vasnprintf rpl_vasnprintf
69#endif 60#endif
70extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 61extern char * asnprintf (char *restrict resultbuf, size_t *lengthp,
71 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); 62 const char *format, ...)
72extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) 63 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4));
73 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0)); 64extern char * vasnprintf (char *restrict resultbuf, size_t *lengthp,
65 const char *format, va_list args)
66 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
74 67
75#ifdef __cplusplus 68#ifdef __cplusplus
76} 69}
diff --git a/gl/vasprintf.c b/gl/vasprintf.c
index d0d4a11b..d2878cd9 100644
--- a/gl/vasprintf.c
+++ b/gl/vasprintf.c
@@ -1,18 +1,18 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/verify.h b/gl/verify.h
index d42d0750..b63cb264 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -1,19 +1,19 @@
1/* Compile-time assert-like macros. 1/* Compile-time assert-like macros.
2 2
3 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ 18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
19 19
@@ -21,31 +21,32 @@
21#define _GL_VERIFY_H 21#define _GL_VERIFY_H
22 22
23 23
24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. 24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC)
25 This is supported by GCC 4.6.0 and later, in C mode, and its use 25 works as per C11. This is supported by GCC 4.6.0+ and by clang 4+.
26 here generates easier-to-read diagnostics when verify (R) fails.
27 26
28 Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11. 27 Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
29 This will likely be supported by future GCC versions, in C++ mode. 28 per C23. This is supported by GCC 9.1+.
30 29
31 Use this only with GCC. If we were willing to slow 'configure' 30 Support compilers claiming conformance to the relevant standard,
32 down we could also use it with other compilers, but since this 31 and also support GCC when not pedantic. If we were willing to slow
33 affects only the quality of diagnostics, why bother? */ 32 'configure' down we could also use it with other compilers, but
34#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ 33 since this affects only the quality of diagnostics, why bother? */
35 && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ 34#ifndef __cplusplus
36 && !defined __cplusplus) 35# if (201112 <= __STDC_VERSION__ \
37# define _GL_HAVE__STATIC_ASSERT 1 36 || (!defined __STRICT_ANSI__ \
38#endif 37 && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__)))
39/* The condition (99 < __GNUC__) is temporary, until we know about the 38# define _GL_HAVE__STATIC_ASSERT 1
40 first G++ release that supports static_assert. */ 39# endif
41#if (99 < __GNUC__) && defined __cplusplus 40# if (202311 <= __STDC_VERSION__ \
42# define _GL_HAVE_STATIC_ASSERT 1 41 || (!defined __STRICT_ANSI__ && 9 <= __GNUC__))
42# define _GL_HAVE__STATIC_ASSERT1 1
43# endif
43#endif 44#endif
44 45
45/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other 46/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
46 system headers, defines a conflicting _Static_assert that is no 47 system headers, defines a conflicting _Static_assert that is no
47 better than ours; override it. */ 48 better than ours; override it. */
48#ifndef _GL_HAVE_STATIC_ASSERT 49#ifndef _GL_HAVE__STATIC_ASSERT
49# include <stddef.h> 50# include <stddef.h>
50# undef _Static_assert 51# undef _Static_assert
51#endif 52#endif
@@ -143,9 +144,9 @@
143 which do not support _Static_assert, also do not warn about the 144 which do not support _Static_assert, also do not warn about the
144 last declaration mentioned above. 145 last declaration mentioned above.
145 146
146 * GCC warns if -Wnested-externs is enabled and verify() is used 147 * GCC warns if -Wnested-externs is enabled and 'verify' is used
147 within a function body; but inside a function, you can always 148 within a function body; but inside a function, you can always
148 arrange to use verify_expr() instead. 149 arrange to use verify_expr instead.
149 150
150 * In C++, any struct definition inside sizeof is invalid. 151 * In C++, any struct definition inside sizeof is invalid.
151 Use a template type to work around the problem. */ 152 Use a template type to work around the problem. */
@@ -197,48 +198,95 @@ template <int w>
197#endif 198#endif
198 199
199/* Verify requirement R at compile-time, as a declaration without a 200/* Verify requirement R at compile-time, as a declaration without a
200 trailing ';'. If R is false, fail at compile-time, preferably 201 trailing ';'. If R is false, fail at compile-time.
201 with a diagnostic that includes the string-literal DIAGNOSTIC. 202
203 This macro requires three or more arguments but uses at most the first
204 two, so that the _Static_assert macro optionally defined below supports
205 both the C11 two-argument syntax and the C23 one-argument syntax.
202 206
203 Unfortunately, unlike C11, this implementation must appear as an 207 Unfortunately, unlike C11, this implementation must appear as an
204 ordinary declaration, and cannot appear inside struct { ... }. */ 208 ordinary declaration, and cannot appear inside struct { ... }. */
205 209
206#ifdef _GL_HAVE__STATIC_ASSERT 210#if 202311 <= __STDC_VERSION__ || 200410 <= __cpp_static_assert
207# define _GL_VERIFY _Static_assert 211# define _GL_VERIFY(R, DIAGNOSTIC, ...) static_assert (R, DIAGNOSTIC)
212#elif defined _GL_HAVE__STATIC_ASSERT
213# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
208#else 214#else
209# define _GL_VERIFY(R, DIAGNOSTIC) \ 215# define _GL_VERIFY(R, DIAGNOSTIC, ...) \
210 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ 216 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
211 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] 217 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
218# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
219# pragma GCC diagnostic ignored "-Wnested-externs"
220# endif
212#endif 221#endif
213 222
214/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ 223/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
215#ifdef _GL_STATIC_ASSERT_H 224#ifdef _GL_STATIC_ASSERT_H
216# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert 225# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert
217# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) 226# if !defined _MSC_VER || defined __clang__
227# define _Static_assert(...) \
228 _GL_VERIFY (__VA_ARGS__, "static assertion failed", -)
229# else
230 /* Work around MSVC preprocessor incompatibility with ISO C; see
231 <https://stackoverflow.com/questions/5134523/>. */
232# define _Static_assert(R, ...) \
233 _GL_VERIFY ((R), "static assertion failed", -)
234# endif
218# endif 235# endif
219# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert 236# if (!defined static_assert \
220# define static_assert _Static_assert /* C11 requires this #define. */ 237 && __STDC_VERSION__ < 202311 \
238 && (!defined __cplusplus \
239 || (__cpp_static_assert < 201411 \
240 && __GNUG__ < 6 && __clang_major__ < 6)))
241# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
242/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
243 the one-argument static_assert, and it does not support _Static_assert.
244 We have to play preprocessor tricks to distinguish the two cases.
245 Since the MSVC preprocessor is not ISO C compliant (see above),.
246 the solution is specific to MSVC. */
247# define _GL_EXPAND(x) x
248# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
249# define _GL_SA2 static_assert
250# define _GL_SA3 static_assert
251# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
252# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__)
253# else
254# define static_assert _Static_assert /* C11 requires this #define. */
255# endif
221# endif 256# endif
222#endif 257#endif
223 258
224/* @assert.h omit start@ */ 259/* @assert.h omit start@ */
225 260
261#if defined __clang_major__ && __clang_major__ < 5
262# define _GL_HAS_BUILTIN_TRAP 0
263#elif 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
264# define _GL_HAS_BUILTIN_TRAP 1
265#elif defined __has_builtin
266# define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap)
267#else
268# define _GL_HAS_BUILTIN_TRAP 0
269#endif
270
271#if defined __clang_major__ && __clang_major__ < 5
272# define _GL_HAS_BUILTIN_UNREACHABLE 0
273#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
274# define _GL_HAS_BUILTIN_UNREACHABLE 1
275#elif defined __has_builtin
276# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
277#else
278# define _GL_HAS_BUILTIN_UNREACHABLE 0
279#endif
280
226/* Each of these macros verifies that its argument R is nonzero. To 281/* Each of these macros verifies that its argument R is nonzero. To
227 be portable, R should be an integer constant expression. Unlike 282 be portable, R should be an integer constant expression. Unlike
228 assert (R), there is no run-time overhead. 283 assert (R), there is no run-time overhead.
229 284
230 There are two macros, since no single macro can be used in all 285 There are two macros, since no single macro can be used in all
231 contexts in C. verify_true (R) is for scalar contexts, including 286 contexts in C. verify_expr (R, E) is for scalar contexts, including
232 integer constant expression contexts. verify (R) is for declaration 287 integer constant expression contexts. verify (R) is for declaration
233 contexts, e.g., the top level. */ 288 contexts, e.g., the top level. */
234 289
235/* Verify requirement R at compile-time, as an integer constant expression.
236 Return 1. This is equivalent to verify_expr (R, 1).
237
238 verify_true is obsolescent; please use verify_expr instead. */
239
240#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
241
242/* Verify requirement R at compile-time. Return the value of the 290/* Verify requirement R at compile-time. Return the value of the
243 expression E. */ 291 expression E. */
244 292
@@ -246,9 +294,56 @@ template <int w>
246 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) 294 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
247 295
248/* Verify requirement R at compile-time, as a declaration without a 296/* Verify requirement R at compile-time, as a declaration without a
249 trailing ';'. */ 297 trailing ';'. verify (R) acts like static_assert (R) except that
298 it is portable to C11/C++14 and earlier, it can issue better
299 diagnostics, and its name is shorter and may be more convenient. */
300
301#ifdef __PGI
302/* PGI barfs if R is long. */
303# define verify(R) _GL_VERIFY (R, "verify (...)", -)
304#else
305# define verify(R) _GL_VERIFY (R, "verify (" #R ")", -)
306#endif
250 307
251#define verify(R) _GL_VERIFY (R, "verify (" #R ")") 308/* Assume that R always holds. Behavior is undefined if R is false,
309 fails to evaluate, or has side effects.
310
311 'assume (R)' is a directive from the programmer telling the
312 compiler that R is true so the compiler needn't generate code to
313 test R. This is why 'assume' is in verify.h: it's related to
314 static checking (in this case, static checking done by the
315 programmer), not dynamic checking.
316
317 'assume (R)' can affect compilation of all the code, not just code
318 that happens to be executed after the assume (R) is "executed".
319 For example, if the code mistakenly does 'assert (R); assume (R);'
320 the compiler is entitled to optimize away the 'assert (R)'.
321
322 Although assuming R can help a compiler generate better code or
323 diagnostics, performance can suffer if R uses hard-to-optimize
324 features such as function calls not inlined by the compiler.
325
326 Avoid Clang's __builtin_assume, as it breaks GNU Emacs master
327 as of 2020-08-23T21:09:49Z!eggert@cs.ucla.edu; see
328 <https://bugs.gnu.org/43152#71>. It's not known whether this breakage
329 is a Clang bug or an Emacs bug; play it safe for now. */
330
331#if _GL_HAS_BUILTIN_UNREACHABLE
332# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
333#elif 1200 <= _MSC_VER
334# define assume(R) __assume (R)
335#elif 202311 <= __STDC_VERSION__
336# include <stddef.h>
337# define assume(R) ((R) ? (void) 0 : unreachable ())
338#elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP
339 /* Doing it this way helps various packages when configured with
340 --enable-gcc-warnings, which compiles with -Dlint. It's nicer
341 if 'assume' silences warnings with GCC 3.4 through GCC 4.4.7 (2012). */
342# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
343#else
344 /* Some older tools grok NOTREACHED, e.g., Oracle Studio 12.6 (2017). */
345# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0)
346#endif
252 347
253/* @assert.h omit end@ */ 348/* @assert.h omit end@ */
254 349
diff --git a/gl/vsnprintf.c b/gl/vsnprintf.c
index 7d4dfbed..acd4e2d4 100644
--- a/gl/vsnprintf.c
+++ b/gl/vsnprintf.c
@@ -1,19 +1,19 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifdef HAVE_CONFIG_H 18#ifdef HAVE_CONFIG_H
19# include <config.h> 19# include <config.h>
diff --git a/gl/w32sock.h b/gl/w32sock.h
index 44f3a1a0..84e46e33 100644
--- a/gl/w32sock.h
+++ b/gl/w32sock.h
@@ -1,19 +1,19 @@
1/* w32sock.h --- internal auxiliary functions for Windows socket functions 1/* w32sock.h --- internal auxiliary functions for Windows socket functions
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paolo Bonzini */ 18/* Written by Paolo Bonzini */
19 19
@@ -26,7 +26,11 @@
26#include <io.h> 26#include <io.h>
27 27
28/* Get _get_osfhandle(). */ 28/* Get _get_osfhandle(). */
29#include "msvc-nothrow.h" 29#if GNULIB_MSVC_NOTHROW
30# include "msvc-nothrow.h"
31#else
32# include <io.h>
33#endif
30 34
31#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) 35#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
32#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY)) 36#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY))
diff --git a/gl/warn-on-use.h b/gl/warn-on-use.h
new file mode 100644
index 00000000..30756034
--- /dev/null
+++ b/gl/warn-on-use.h
@@ -0,0 +1,149 @@
1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
18 for FUNCTION which will then trigger a compiler warning containing
19 the text of "literal string" anywhere that function is called, if
20 supported by the compiler. If the compiler does not support this
21 feature, the macro expands to an unused extern declaration.
22
23 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
24 attribute used in _GL_WARN_ON_USE. If the compiler does not support
25 this feature, it expands to empty.
26
27 These macros are useful for marking a function as a potential
28 portability trap, with the intent that "literal string" include
29 instructions on the replacement function that should be used
30 instead.
31 _GL_WARN_ON_USE is for functions with 'extern' linkage.
32 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
33 linkage.
34
35 However, one of the reasons that a function is a portability trap is
36 if it has the wrong signature. Declaring FUNCTION with a different
37 signature in C is a compilation error, so this macro must use the
38 same type as any existing declaration so that programs that avoid
39 the problematic FUNCTION do not fail to compile merely because they
40 included a header that poisoned the function. But this implies that
41 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
42 have a declaration. Use of this macro implies that there must not
43 be any other macro hiding the declaration of FUNCTION; but
44 undefining FUNCTION first is part of the poisoning process anyway
45 (although for symbols that are provided only via a macro, the result
46 is a compilation error rather than a warning containing
47 "literal string"). Also note that in C++, it is only safe to use if
48 FUNCTION has no overloads.
49
50 For an example, it is possible to poison 'getline' by:
51 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
52 [getline]) in configure.ac, which potentially defines
53 HAVE_RAW_DECL_GETLINE
54 - adding this code to a header that wraps the system <stdio.h>:
55 #undef getline
56 #if HAVE_RAW_DECL_GETLINE
57 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
58 "not universally present; use the gnulib module getline");
59 #endif
60
61 It is not possible to directly poison global variables. But it is
62 possible to write a wrapper accessor function, and poison that
63 (less common usage, like &environ, will cause a compilation error
64 rather than issue the nice warning, but the end result of informing
65 the developer about their portability problem is still achieved):
66 #if HAVE_RAW_DECL_ENVIRON
67 static char ***
68 rpl_environ (void) { return &environ; }
69 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
70 # undef environ
71 # define environ (*rpl_environ ())
72 #endif
73 or better (avoiding contradictory use of 'static' and 'extern'):
74 #if HAVE_RAW_DECL_ENVIRON
75 static char ***
76 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
77 rpl_environ (void) { return &environ; }
78 # undef environ
79 # define environ (*rpl_environ ())
80 #endif
81 */
82#ifndef _GL_WARN_ON_USE
83
84# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
85/* A compiler attribute is available in gcc versions 4.3.0 and later. */
86# define _GL_WARN_ON_USE(function, message) \
87_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
88# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
89 __attribute__ ((__warning__ (message)))
90# elif __clang_major__ >= 4
91/* Another compiler attribute is available in clang. */
92# define _GL_WARN_ON_USE(function, message) \
93_GL_WARN_EXTERN_C __typeof__ (function) function \
94 __attribute__ ((__diagnose_if__ (1, message, "warning")))
95# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
96 __attribute__ ((__diagnose_if__ (1, message, "warning")))
97# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
98/* Verify the existence of the function. */
99# define _GL_WARN_ON_USE(function, message) \
100_GL_WARN_EXTERN_C __typeof__ (function) function
101# define _GL_WARN_ON_USE_ATTRIBUTE(message)
102# else /* Unsupported. */
103# define _GL_WARN_ON_USE(function, message) \
104_GL_WARN_EXTERN_C int _gl_warn_on_use
105# define _GL_WARN_ON_USE_ATTRIBUTE(message)
106# endif
107#endif
108
109/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
110 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
111 function is declared with the given prototype, consisting of return type,
112 parameters, and attributes.
113 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
114 not work in this case. */
115#ifndef _GL_WARN_ON_USE_CXX
116# if !defined __cplusplus
117# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
118 _GL_WARN_ON_USE (function, msg)
119# else
120# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
121/* A compiler attribute is available in gcc versions 4.3.0 and later. */
122# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
123extern rettype_gcc function parameters_and_attributes \
124 __attribute__ ((__warning__ (msg)))
125# elif __clang_major__ >= 4
126/* Another compiler attribute is available in clang. */
127# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
128extern rettype_clang function parameters_and_attributes \
129 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
130# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
131/* Verify the existence of the function. */
132# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
133extern rettype_gcc function parameters_and_attributes
134# else /* Unsupported. */
135# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
136_GL_WARN_EXTERN_C int _gl_warn_on_use
137# endif
138# endif
139#endif
140
141/* _GL_WARN_EXTERN_C declaration;
142 performs the declaration with C linkage. */
143#ifndef _GL_WARN_EXTERN_C
144# if defined __cplusplus
145# define _GL_WARN_EXTERN_C extern "C"
146# else
147# define _GL_WARN_EXTERN_C extern
148# endif
149#endif
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index b6e43627..09c9185f 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -1,25 +1,25 @@
1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues. 1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
19 19
20/* 20/*
21 * ISO C 99 <wchar.h> for platforms that have issues. 21 * ISO C 99 <wchar.h> for platforms that have issues.
22 * <http://www.opengroup.org/susv3xbd/wchar.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
23 * 23 *
24 * For now, this just ensures proper prerequisite inclusion order and 24 * For now, this just ensures proper prerequisite inclusion order and
25 * the declaration of wcwidth(). 25 * the declaration of wcwidth().
@@ -30,15 +30,24 @@
30#endif 30#endif
31@PRAGMA_COLUMNS@ 31@PRAGMA_COLUMNS@
32 32
33#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H 33#if (((defined __need_mbstate_t || defined __need_wint_t) \
34 && !defined __MINGW32__) \
35 || (defined __hpux \
36 && ((defined _INTTYPES_INCLUDED \
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
40 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
34/* Special invocation convention: 41/* Special invocation convention:
35 - Inside glibc and uClibc header files. 42 - Inside glibc and uClibc header files, but not MinGW.
36 - On HP-UX 11.00 we have a sequence of nested includes 43 - On HP-UX 11.00 we have a sequence of nested includes
37 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>, 44 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
38 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h> 45 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
39 and once directly. In both situations 'wint_t' is not yet defined, 46 and once directly. In both situations 'wint_t' is not yet defined,
40 therefore we cannot provide the function overrides; instead include only 47 therefore we cannot provide the function overrides; instead include only
41 the system's <wchar.h>. 48 the system's <wchar.h>.
49 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
50 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
42 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and 51 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
43 the latter includes <wchar.h>. But here, we have no way to detect whether 52 the latter includes <wchar.h>. But here, we have no way to detect whether
44 <wctype.h> is completely included or is still being included. */ 53 <wctype.h> is completely included or is still being included. */
@@ -56,20 +65,12 @@
56# include <features.h> /* for __GLIBC__ */ 65# include <features.h> /* for __GLIBC__ */
57#endif 66#endif
58 67
59/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 68/* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
60 <wchar.h>.
61 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
62 included before <wchar.h>.
63 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
64 by <stddef.h>. 69 by <stddef.h>.
65 But avoid namespace pollution on glibc systems. */ 70 But avoid namespace pollution on glibc systems. */
66#if !(defined __GLIBC__ && !defined __UCLIBC__) 71#if !(defined __GLIBC__ && !defined __UCLIBC__)
67# include <stddef.h> 72# include <stddef.h>
68#endif 73#endif
69#ifndef __GLIBC__
70# include <stdio.h>
71# include <time.h>
72#endif
73 74
74/* Include the original <wchar.h> if it exists. 75/* Include the original <wchar.h> if it exists.
75 Some builds of uClibc lack it. */ 76 Some builds of uClibc lack it. */
@@ -83,12 +84,50 @@
83#ifndef _@GUARD_PREFIX@_WCHAR_H 84#ifndef _@GUARD_PREFIX@_WCHAR_H
84#define _@GUARD_PREFIX@_WCHAR_H 85#define _@GUARD_PREFIX@_WCHAR_H
85 86
87/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
88 that can be freed by passing them as the Ith argument to the
89 function F. */
90#ifndef _GL_ATTRIBUTE_DEALLOC
91# if __GNUC__ >= 11
92# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
93# else
94# define _GL_ATTRIBUTE_DEALLOC(f, i)
95# endif
96#endif
97
98/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
99 can be freed via 'free'; it can be used only after declaring 'free'. */
100/* Applies to: functions. Cannot be used on inline functions. */
101#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
102# if defined __cplusplus && defined __GNUC__ && !defined __clang__
103/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
104# define _GL_ATTRIBUTE_DEALLOC_FREE \
105 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
106# else
107# define _GL_ATTRIBUTE_DEALLOC_FREE \
108 _GL_ATTRIBUTE_DEALLOC (free, 1)
109# endif
110#endif
111
112/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
113 allocated memory. */
114/* Applies to: functions. */
115#ifndef _GL_ATTRIBUTE_MALLOC
116# if __GNUC__ >= 3 || defined __clang__
117# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
118# else
119# define _GL_ATTRIBUTE_MALLOC
120# endif
121#endif
122
86/* The __attribute__ feature is available in gcc versions 2.5 and later. 123/* The __attribute__ feature is available in gcc versions 2.5 and later.
87 The attribute __pure__ was added in gcc 2.96. */ 124 The attribute __pure__ was added in gcc 2.96. */
88#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 125#ifndef _GL_ATTRIBUTE_PURE
89# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 126# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
90#else 127# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
91# define _GL_ATTRIBUTE_PURE /* empty */ 128# else
129# define _GL_ATTRIBUTE_PURE /* empty */
130# endif
92#endif 131#endif
93 132
94/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 133/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -105,12 +144,16 @@
105# define WEOF -1 144# define WEOF -1
106# endif 145# endif
107#else 146#else
108/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>. 147/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
109 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be 148 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
110 "unchanged by default argument promotions". Override it. */ 149 wint_t must be "unchanged by default argument promotions". Override it. */
111# if defined _MSC_VER 150# if @GNULIBHEADERS_OVERRIDE_WINT_T@
112# if !GNULIB_defined_wint_t 151# if !GNULIB_defined_wint_t
113# include <crtdefs.h> 152# if @HAVE_CRTDEFS_H@
153# include <crtdefs.h>
154# else
155# include <stddef.h>
156# endif
114typedef unsigned int rpl_wint_t; 157typedef unsigned int rpl_wint_t;
115# undef wint_t 158# undef wint_t
116# define wint_t rpl_wint_t 159# define wint_t rpl_wint_t
@@ -125,16 +168,59 @@ typedef unsigned int rpl_wint_t;
125 168
126/* Override mbstate_t if it is too small. 169/* Override mbstate_t if it is too small.
127 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for 170 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
128 implementing mbrtowc for encodings like UTF-8. */ 171 implementing mbrtowc for encodings like UTF-8.
129#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ 172 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
173 large enough and overriding it would cause problems in C++ mode. */
174#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
130# if !GNULIB_defined_mbstate_t 175# if !GNULIB_defined_mbstate_t
176# if !(defined _AIX || defined _MSC_VER)
131typedef int rpl_mbstate_t; 177typedef int rpl_mbstate_t;
132# undef mbstate_t 178# undef mbstate_t
133# define mbstate_t rpl_mbstate_t 179# define mbstate_t rpl_mbstate_t
180# endif
134# define GNULIB_defined_mbstate_t 1 181# define GNULIB_defined_mbstate_t 1
135# endif 182# endif
136#endif 183#endif
137 184
185/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
186 been included yet. */
187#if @GNULIB_FREE_POSIX@
188# if (@REPLACE_FREE@ && !defined free \
189 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
190/* We can't do '#define free rpl_free' here. */
191_GL_EXTERN_C void rpl_free (void *);
192# undef _GL_ATTRIBUTE_DEALLOC_FREE
193# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
194# else
195# if defined _MSC_VER && !defined free
196_GL_EXTERN_C
197# if defined _DLL
198 __declspec (dllimport)
199# endif
200 void __cdecl free (void *);
201# else
202# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
203_GL_EXTERN_C void free (void *) throw ();
204# else
205_GL_EXTERN_C void free (void *);
206# endif
207# endif
208# endif
209#else
210# if defined _MSC_VER && !defined free
211_GL_EXTERN_C
212# if defined _DLL
213 __declspec (dllimport)
214# endif
215 void __cdecl free (void *);
216# else
217# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
218_GL_EXTERN_C void free (void *) throw ();
219# else
220_GL_EXTERN_C void free (void *);
221# endif
222# endif
223#endif
138 224
139/* Convert a single-byte character to a wide character. */ 225/* Convert a single-byte character to a wide character. */
140#if @GNULIB_BTOWC@ 226#if @GNULIB_BTOWC@
@@ -149,9 +235,12 @@ _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
149# if !@HAVE_BTOWC@ 235# if !@HAVE_BTOWC@
150_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); 236_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
151# endif 237# endif
152_GL_CXXALIAS_SYS (btowc, wint_t, (int c)); 238/* Need to cast, because on mingw, the return type is 'unsigned short'. */
239_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
153# endif 240# endif
241# if __GLIBC__ >= 2
154_GL_CXXALIASWARN (btowc); 242_GL_CXXALIASWARN (btowc);
243# endif
155#elif defined GNULIB_POSIXCHECK 244#elif defined GNULIB_POSIXCHECK
156# undef btowc 245# undef btowc
157# if HAVE_RAW_DECL_BTOWC 246# if HAVE_RAW_DECL_BTOWC
@@ -177,7 +266,9 @@ _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
177# endif 266# endif
178_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); 267_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
179# endif 268# endif
269# if __GLIBC__ >= 2
180_GL_CXXALIASWARN (wctob); 270_GL_CXXALIASWARN (wctob);
271# endif
181#elif defined GNULIB_POSIXCHECK 272#elif defined GNULIB_POSIXCHECK
182# undef wctob 273# undef wctob
183# if HAVE_RAW_DECL_WCTOB 274# if HAVE_RAW_DECL_WCTOB
@@ -202,7 +293,9 @@ _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
202# endif 293# endif
203_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); 294_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
204# endif 295# endif
296# if __GLIBC__ >= 2
205_GL_CXXALIASWARN (mbsinit); 297_GL_CXXALIASWARN (mbsinit);
298# endif
206#elif defined GNULIB_POSIXCHECK 299#elif defined GNULIB_POSIXCHECK
207# undef mbsinit 300# undef mbsinit
208# if HAVE_RAW_DECL_MBSINIT 301# if HAVE_RAW_DECL_MBSINIT
@@ -220,18 +313,24 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
220# define mbrtowc rpl_mbrtowc 313# define mbrtowc rpl_mbrtowc
221# endif 314# endif
222_GL_FUNCDECL_RPL (mbrtowc, size_t, 315_GL_FUNCDECL_RPL (mbrtowc, size_t,
223 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 316 (wchar_t *restrict pwc, const char *restrict s, size_t n,
317 mbstate_t *restrict ps));
224_GL_CXXALIAS_RPL (mbrtowc, size_t, 318_GL_CXXALIAS_RPL (mbrtowc, size_t,
225 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 319 (wchar_t *restrict pwc, const char *restrict s, size_t n,
320 mbstate_t *restrict ps));
226# else 321# else
227# if !@HAVE_MBRTOWC@ 322# if !@HAVE_MBRTOWC@
228_GL_FUNCDECL_SYS (mbrtowc, size_t, 323_GL_FUNCDECL_SYS (mbrtowc, size_t,
229 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 324 (wchar_t *restrict pwc, const char *restrict s, size_t n,
325 mbstate_t *restrict ps));
230# endif 326# endif
231_GL_CXXALIAS_SYS (mbrtowc, size_t, 327_GL_CXXALIAS_SYS (mbrtowc, size_t,
232 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 328 (wchar_t *restrict pwc, const char *restrict s, size_t n,
329 mbstate_t *restrict ps));
233# endif 330# endif
331# if __GLIBC__ >= 2
234_GL_CXXALIASWARN (mbrtowc); 332_GL_CXXALIASWARN (mbrtowc);
333# endif
235#elif defined GNULIB_POSIXCHECK 334#elif defined GNULIB_POSIXCHECK
236# undef mbrtowc 335# undef mbrtowc
237# if HAVE_RAW_DECL_MBRTOWC 336# if HAVE_RAW_DECL_MBRTOWC
@@ -248,15 +347,21 @@ _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
248# undef mbrlen 347# undef mbrlen
249# define mbrlen rpl_mbrlen 348# define mbrlen rpl_mbrlen
250# endif 349# endif
251_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 350_GL_FUNCDECL_RPL (mbrlen, size_t,
252_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 351 (const char *restrict s, size_t n, mbstate_t *restrict ps));
352_GL_CXXALIAS_RPL (mbrlen, size_t,
353 (const char *restrict s, size_t n, mbstate_t *restrict ps));
253# else 354# else
254# if !@HAVE_MBRLEN@ 355# if !@HAVE_MBRLEN@
255_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 356_GL_FUNCDECL_SYS (mbrlen, size_t,
357 (const char *restrict s, size_t n, mbstate_t *restrict ps));
256# endif 358# endif
257_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 359_GL_CXXALIAS_SYS (mbrlen, size_t,
360 (const char *restrict s, size_t n, mbstate_t *restrict ps));
258# endif 361# endif
362# if __GLIBC__ >= 2
259_GL_CXXALIASWARN (mbrlen); 363_GL_CXXALIASWARN (mbrlen);
364# endif
260#elif defined GNULIB_POSIXCHECK 365#elif defined GNULIB_POSIXCHECK
261# undef mbrlen 366# undef mbrlen
262# if HAVE_RAW_DECL_MBRLEN 367# if HAVE_RAW_DECL_MBRLEN
@@ -274,22 +379,30 @@ _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
274# define mbsrtowcs rpl_mbsrtowcs 379# define mbsrtowcs rpl_mbsrtowcs
275# endif 380# endif
276_GL_FUNCDECL_RPL (mbsrtowcs, size_t, 381_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
277 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) 382 (wchar_t *restrict dest,
383 const char **restrict srcp, size_t len,
384 mbstate_t *restrict ps)
278 _GL_ARG_NONNULL ((2))); 385 _GL_ARG_NONNULL ((2)));
279_GL_CXXALIAS_RPL (mbsrtowcs, size_t, 386_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
280 (wchar_t *dest, const char **srcp, size_t len, 387 (wchar_t *restrict dest,
281 mbstate_t *ps)); 388 const char **restrict srcp, size_t len,
389 mbstate_t *restrict ps));
282# else 390# else
283# if !@HAVE_MBSRTOWCS@ 391# if !@HAVE_MBSRTOWCS@
284_GL_FUNCDECL_SYS (mbsrtowcs, size_t, 392_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
285 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) 393 (wchar_t *restrict dest,
394 const char **restrict srcp, size_t len,
395 mbstate_t *restrict ps)
286 _GL_ARG_NONNULL ((2))); 396 _GL_ARG_NONNULL ((2)));
287# endif 397# endif
288_GL_CXXALIAS_SYS (mbsrtowcs, size_t, 398_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
289 (wchar_t *dest, const char **srcp, size_t len, 399 (wchar_t *restrict dest,
290 mbstate_t *ps)); 400 const char **restrict srcp, size_t len,
401 mbstate_t *restrict ps));
291# endif 402# endif
403# if __GLIBC__ >= 2
292_GL_CXXALIASWARN (mbsrtowcs); 404_GL_CXXALIASWARN (mbsrtowcs);
405# endif
293#elif defined GNULIB_POSIXCHECK 406#elif defined GNULIB_POSIXCHECK
294# undef mbsrtowcs 407# undef mbsrtowcs
295# if HAVE_RAW_DECL_MBSRTOWCS 408# if HAVE_RAW_DECL_MBSRTOWCS
@@ -307,22 +420,26 @@ _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
307# define mbsnrtowcs rpl_mbsnrtowcs 420# define mbsnrtowcs rpl_mbsnrtowcs
308# endif 421# endif
309_GL_FUNCDECL_RPL (mbsnrtowcs, size_t, 422_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
310 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 423 (wchar_t *restrict dest,
311 mbstate_t *ps) 424 const char **restrict srcp, size_t srclen, size_t len,
425 mbstate_t *restrict ps)
312 _GL_ARG_NONNULL ((2))); 426 _GL_ARG_NONNULL ((2)));
313_GL_CXXALIAS_RPL (mbsnrtowcs, size_t, 427_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
314 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 428 (wchar_t *restrict dest,
315 mbstate_t *ps)); 429 const char **restrict srcp, size_t srclen, size_t len,
430 mbstate_t *restrict ps));
316# else 431# else
317# if !@HAVE_MBSNRTOWCS@ 432# if !@HAVE_MBSNRTOWCS@
318_GL_FUNCDECL_SYS (mbsnrtowcs, size_t, 433_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
319 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 434 (wchar_t *restrict dest,
320 mbstate_t *ps) 435 const char **restrict srcp, size_t srclen, size_t len,
436 mbstate_t *restrict ps)
321 _GL_ARG_NONNULL ((2))); 437 _GL_ARG_NONNULL ((2)));
322# endif 438# endif
323_GL_CXXALIAS_SYS (mbsnrtowcs, size_t, 439_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
324 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 440 (wchar_t *restrict dest,
325 mbstate_t *ps)); 441 const char **restrict srcp, size_t srclen, size_t len,
442 mbstate_t *restrict ps));
326# endif 443# endif
327_GL_CXXALIASWARN (mbsnrtowcs); 444_GL_CXXALIASWARN (mbsnrtowcs);
328#elif defined GNULIB_POSIXCHECK 445#elif defined GNULIB_POSIXCHECK
@@ -341,15 +458,21 @@ _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
341# undef wcrtomb 458# undef wcrtomb
342# define wcrtomb rpl_wcrtomb 459# define wcrtomb rpl_wcrtomb
343# endif 460# endif
344_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 461_GL_FUNCDECL_RPL (wcrtomb, size_t,
345_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 462 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
463_GL_CXXALIAS_RPL (wcrtomb, size_t,
464 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
346# else 465# else
347# if !@HAVE_WCRTOMB@ 466# if !@HAVE_WCRTOMB@
348_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 467_GL_FUNCDECL_SYS (wcrtomb, size_t,
468 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
349# endif 469# endif
350_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 470_GL_CXXALIAS_SYS (wcrtomb, size_t,
471 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
351# endif 472# endif
473# if __GLIBC__ >= 2
352_GL_CXXALIASWARN (wcrtomb); 474_GL_CXXALIASWARN (wcrtomb);
475# endif
353#elif defined GNULIB_POSIXCHECK 476#elif defined GNULIB_POSIXCHECK
354# undef wcrtomb 477# undef wcrtomb
355# if HAVE_RAW_DECL_WCRTOMB 478# if HAVE_RAW_DECL_WCRTOMB
@@ -367,22 +490,30 @@ _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
367# define wcsrtombs rpl_wcsrtombs 490# define wcsrtombs rpl_wcsrtombs
368# endif 491# endif
369_GL_FUNCDECL_RPL (wcsrtombs, size_t, 492_GL_FUNCDECL_RPL (wcsrtombs, size_t,
370 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) 493 (char *restrict dest, const wchar_t **restrict srcp,
494 size_t len,
495 mbstate_t *restrict ps)
371 _GL_ARG_NONNULL ((2))); 496 _GL_ARG_NONNULL ((2)));
372_GL_CXXALIAS_RPL (wcsrtombs, size_t, 497_GL_CXXALIAS_RPL (wcsrtombs, size_t,
373 (char *dest, const wchar_t **srcp, size_t len, 498 (char *restrict dest, const wchar_t **restrict srcp,
374 mbstate_t *ps)); 499 size_t len,
500 mbstate_t *restrict ps));
375# else 501# else
376# if !@HAVE_WCSRTOMBS@ 502# if !@HAVE_WCSRTOMBS@
377_GL_FUNCDECL_SYS (wcsrtombs, size_t, 503_GL_FUNCDECL_SYS (wcsrtombs, size_t,
378 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) 504 (char *restrict dest, const wchar_t **restrict srcp,
505 size_t len,
506 mbstate_t *restrict ps)
379 _GL_ARG_NONNULL ((2))); 507 _GL_ARG_NONNULL ((2)));
380# endif 508# endif
381_GL_CXXALIAS_SYS (wcsrtombs, size_t, 509_GL_CXXALIAS_SYS (wcsrtombs, size_t,
382 (char *dest, const wchar_t **srcp, size_t len, 510 (char *restrict dest, const wchar_t **restrict srcp,
383 mbstate_t *ps)); 511 size_t len,
512 mbstate_t *restrict ps));
384# endif 513# endif
514# if __GLIBC__ >= 2
385_GL_CXXALIASWARN (wcsrtombs); 515_GL_CXXALIASWARN (wcsrtombs);
516# endif
386#elif defined GNULIB_POSIXCHECK 517#elif defined GNULIB_POSIXCHECK
387# undef wcsrtombs 518# undef wcsrtombs
388# if HAVE_RAW_DECL_WCSRTOMBS 519# if HAVE_RAW_DECL_WCSRTOMBS
@@ -400,24 +531,34 @@ _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
400# define wcsnrtombs rpl_wcsnrtombs 531# define wcsnrtombs rpl_wcsnrtombs
401# endif 532# endif
402_GL_FUNCDECL_RPL (wcsnrtombs, size_t, 533_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
403 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 534 (char *restrict dest,
404 mbstate_t *ps) 535 const wchar_t **restrict srcp, size_t srclen,
536 size_t len,
537 mbstate_t *restrict ps)
405 _GL_ARG_NONNULL ((2))); 538 _GL_ARG_NONNULL ((2)));
406_GL_CXXALIAS_RPL (wcsnrtombs, size_t, 539_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
407 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 540 (char *restrict dest,
408 mbstate_t *ps)); 541 const wchar_t **restrict srcp, size_t srclen,
542 size_t len,
543 mbstate_t *restrict ps));
409# else 544# else
410# if !@HAVE_WCSNRTOMBS@ 545# if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
411_GL_FUNCDECL_SYS (wcsnrtombs, size_t, 546_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
412 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 547 (char *restrict dest,
413 mbstate_t *ps) 548 const wchar_t **restrict srcp, size_t srclen,
549 size_t len,
550 mbstate_t *restrict ps)
414 _GL_ARG_NONNULL ((2))); 551 _GL_ARG_NONNULL ((2)));
415# endif 552# endif
416_GL_CXXALIAS_SYS (wcsnrtombs, size_t, 553_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
417 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 554 (char *restrict dest,
418 mbstate_t *ps)); 555 const wchar_t **restrict srcp, size_t srclen,
556 size_t len,
557 mbstate_t *restrict ps));
419# endif 558# endif
559# if __GLIBC__ >= 2
420_GL_CXXALIASWARN (wcsnrtombs); 560_GL_CXXALIASWARN (wcsnrtombs);
561# endif
421#elif defined GNULIB_POSIXCHECK 562#elif defined GNULIB_POSIXCHECK
422# undef wcsnrtombs 563# undef wcsnrtombs
423# if HAVE_RAW_DECL_WCSNRTOMBS 564# if HAVE_RAW_DECL_WCSNRTOMBS
@@ -443,7 +584,9 @@ _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
443# endif 584# endif
444_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); 585_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
445# endif 586# endif
587# if __GLIBC__ >= 2
446_GL_CXXALIASWARN (wcwidth); 588_GL_CXXALIASWARN (wcwidth);
589# endif
447#elif defined GNULIB_POSIXCHECK 590#elif defined GNULIB_POSIXCHECK
448# undef wcwidth 591# undef wcwidth
449# if HAVE_RAW_DECL_WCWIDTH 592# if HAVE_RAW_DECL_WCWIDTH
@@ -472,7 +615,7 @@ _GL_CXXALIAS_SYS_CAST2 (wmemchr,
472_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 615_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
473_GL_CXXALIASWARN1 (wmemchr, const wchar_t *, 616_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
474 (const wchar_t *s, wchar_t c, size_t n)); 617 (const wchar_t *s, wchar_t c, size_t n));
475# else 618# elif __GLIBC__ >= 2
476_GL_CXXALIASWARN (wmemchr); 619_GL_CXXALIASWARN (wmemchr);
477# endif 620# endif
478#elif defined GNULIB_POSIXCHECK 621#elif defined GNULIB_POSIXCHECK
@@ -493,7 +636,9 @@ _GL_FUNCDECL_SYS (wmemcmp, int,
493# endif 636# endif
494_GL_CXXALIAS_SYS (wmemcmp, int, 637_GL_CXXALIAS_SYS (wmemcmp, int,
495 (const wchar_t *s1, const wchar_t *s2, size_t n)); 638 (const wchar_t *s1, const wchar_t *s2, size_t n));
639# if __GLIBC__ >= 2
496_GL_CXXALIASWARN (wmemcmp); 640_GL_CXXALIASWARN (wmemcmp);
641# endif
497#elif defined GNULIB_POSIXCHECK 642#elif defined GNULIB_POSIXCHECK
498# undef wmemcmp 643# undef wmemcmp
499# if HAVE_RAW_DECL_WMEMCMP 644# if HAVE_RAW_DECL_WMEMCMP
@@ -507,11 +652,15 @@ _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
507#if @GNULIB_WMEMCPY@ 652#if @GNULIB_WMEMCPY@
508# if !@HAVE_WMEMCPY@ 653# if !@HAVE_WMEMCPY@
509_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, 654_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
510 (wchar_t *dest, const wchar_t *src, size_t n)); 655 (wchar_t *restrict dest,
656 const wchar_t *restrict src, size_t n));
511# endif 657# endif
512_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, 658_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
513 (wchar_t *dest, const wchar_t *src, size_t n)); 659 (wchar_t *restrict dest,
660 const wchar_t *restrict src, size_t n));
661# if __GLIBC__ >= 2
514_GL_CXXALIASWARN (wmemcpy); 662_GL_CXXALIASWARN (wmemcpy);
663# endif
515#elif defined GNULIB_POSIXCHECK 664#elif defined GNULIB_POSIXCHECK
516# undef wmemcpy 665# undef wmemcpy
517# if HAVE_RAW_DECL_WMEMCPY 666# if HAVE_RAW_DECL_WMEMCPY
@@ -530,7 +679,9 @@ _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
530# endif 679# endif
531_GL_CXXALIAS_SYS (wmemmove, wchar_t *, 680_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
532 (wchar_t *dest, const wchar_t *src, size_t n)); 681 (wchar_t *dest, const wchar_t *src, size_t n));
682# if __GLIBC__ >= 2
533_GL_CXXALIASWARN (wmemmove); 683_GL_CXXALIASWARN (wmemmove);
684# endif
534#elif defined GNULIB_POSIXCHECK 685#elif defined GNULIB_POSIXCHECK
535# undef wmemmove 686# undef wmemmove
536# if HAVE_RAW_DECL_WMEMMOVE 687# if HAVE_RAW_DECL_WMEMMOVE
@@ -540,13 +691,38 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
540#endif 691#endif
541 692
542 693
694/* Copy N wide characters of SRC to DEST.
695 Return pointer to wide characters after the last written wide character. */
696#if @GNULIB_WMEMPCPY@
697# if !@HAVE_WMEMPCPY@
698_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
699 (wchar_t *restrict dest,
700 const wchar_t *restrict src, size_t n));
701# endif
702_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
703 (wchar_t *restrict dest,
704 const wchar_t *restrict src, size_t n));
705# if __GLIBC__ >= 2
706_GL_CXXALIASWARN (wmempcpy);
707# endif
708#elif defined GNULIB_POSIXCHECK
709# undef wmempcpy
710# if HAVE_RAW_DECL_WMEMPCPY
711_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
712 "use gnulib module wmempcpy for portability");
713# endif
714#endif
715
716
543/* Set N wide characters of S to C. */ 717/* Set N wide characters of S to C. */
544#if @GNULIB_WMEMSET@ 718#if @GNULIB_WMEMSET@
545# if !@HAVE_WMEMSET@ 719# if !@HAVE_WMEMSET@
546_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 720_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
547# endif 721# endif
548_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 722_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
723# if __GLIBC__ >= 2
549_GL_CXXALIASWARN (wmemset); 724_GL_CXXALIASWARN (wmemset);
725# endif
550#elif defined GNULIB_POSIXCHECK 726#elif defined GNULIB_POSIXCHECK
551# undef wmemset 727# undef wmemset
552# if HAVE_RAW_DECL_WMEMSET 728# if HAVE_RAW_DECL_WMEMSET
@@ -562,7 +738,9 @@ _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
562_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); 738_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
563# endif 739# endif
564_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); 740_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
741# if __GLIBC__ >= 2
565_GL_CXXALIASWARN (wcslen); 742_GL_CXXALIASWARN (wcslen);
743# endif
566#elif defined GNULIB_POSIXCHECK 744#elif defined GNULIB_POSIXCHECK
567# undef wcslen 745# undef wcslen
568# if HAVE_RAW_DECL_WCSLEN 746# if HAVE_RAW_DECL_WCSLEN
@@ -574,7 +752,10 @@ _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
574 752
575/* Return the number of wide characters in S, but at most MAXLEN. */ 753/* Return the number of wide characters in S, but at most MAXLEN. */
576#if @GNULIB_WCSNLEN@ 754#if @GNULIB_WCSNLEN@
577# if !@HAVE_WCSNLEN@ 755/* On Solaris 11.3, the header files declare the function in the std::
756 namespace, not in the global namespace. So, force a declaration in
757 the global namespace. */
758# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
578_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) 759_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
579 _GL_ATTRIBUTE_PURE); 760 _GL_ATTRIBUTE_PURE);
580# endif 761# endif
@@ -592,10 +773,14 @@ _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
592/* Copy SRC to DEST. */ 773/* Copy SRC to DEST. */
593#if @GNULIB_WCSCPY@ 774#if @GNULIB_WCSCPY@
594# if !@HAVE_WCSCPY@ 775# if !@HAVE_WCSCPY@
595_GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 776_GL_FUNCDECL_SYS (wcscpy, wchar_t *,
777 (wchar_t *restrict dest, const wchar_t *restrict src));
596# endif 778# endif
597_GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 779_GL_CXXALIAS_SYS (wcscpy, wchar_t *,
780 (wchar_t *restrict dest, const wchar_t *restrict src));
781# if __GLIBC__ >= 2
598_GL_CXXALIASWARN (wcscpy); 782_GL_CXXALIASWARN (wcscpy);
783# endif
599#elif defined GNULIB_POSIXCHECK 784#elif defined GNULIB_POSIXCHECK
600# undef wcscpy 785# undef wcscpy
601# if HAVE_RAW_DECL_WCSCPY 786# if HAVE_RAW_DECL_WCSCPY
@@ -607,10 +792,15 @@ _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
607 792
608/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */ 793/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
609#if @GNULIB_WCPCPY@ 794#if @GNULIB_WCPCPY@
610# if !@HAVE_WCPCPY@ 795/* On Solaris 11.3, the header files declare the function in the std::
611_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 796 namespace, not in the global namespace. So, force a declaration in
612# endif 797 the global namespace. */
613_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 798# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
799_GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
800 (wchar_t *restrict dest, const wchar_t *restrict src));
801# endif
802_GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
803 (wchar_t *restrict dest, const wchar_t *restrict src));
614_GL_CXXALIASWARN (wcpcpy); 804_GL_CXXALIASWARN (wcpcpy);
615#elif defined GNULIB_POSIXCHECK 805#elif defined GNULIB_POSIXCHECK
616# undef wcpcpy 806# undef wcpcpy
@@ -625,11 +815,15 @@ _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
625#if @GNULIB_WCSNCPY@ 815#if @GNULIB_WCSNCPY@
626# if !@HAVE_WCSNCPY@ 816# if !@HAVE_WCSNCPY@
627_GL_FUNCDECL_SYS (wcsncpy, wchar_t *, 817_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
628 (wchar_t *dest, const wchar_t *src, size_t n)); 818 (wchar_t *restrict dest,
819 const wchar_t *restrict src, size_t n));
629# endif 820# endif
630_GL_CXXALIAS_SYS (wcsncpy, wchar_t *, 821_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
631 (wchar_t *dest, const wchar_t *src, size_t n)); 822 (wchar_t *restrict dest,
823 const wchar_t *restrict src, size_t n));
824# if __GLIBC__ >= 2
632_GL_CXXALIASWARN (wcsncpy); 825_GL_CXXALIASWARN (wcsncpy);
826# endif
633#elif defined GNULIB_POSIXCHECK 827#elif defined GNULIB_POSIXCHECK
634# undef wcsncpy 828# undef wcsncpy
635# if HAVE_RAW_DECL_WCSNCPY 829# if HAVE_RAW_DECL_WCSNCPY
@@ -642,12 +836,17 @@ _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
642/* Copy no more than N characters of SRC to DEST, returning the address of 836/* Copy no more than N characters of SRC to DEST, returning the address of
643 the last character written into DEST. */ 837 the last character written into DEST. */
644#if @GNULIB_WCPNCPY@ 838#if @GNULIB_WCPNCPY@
645# if !@HAVE_WCPNCPY@ 839/* On Solaris 11.3, the header files declare the function in the std::
840 namespace, not in the global namespace. So, force a declaration in
841 the global namespace. */
842# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
646_GL_FUNCDECL_SYS (wcpncpy, wchar_t *, 843_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
647 (wchar_t *dest, const wchar_t *src, size_t n)); 844 (wchar_t *restrict dest,
845 const wchar_t *restrict src, size_t n));
648# endif 846# endif
649_GL_CXXALIAS_SYS (wcpncpy, wchar_t *, 847_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
650 (wchar_t *dest, const wchar_t *src, size_t n)); 848 (wchar_t *restrict dest,
849 const wchar_t *restrict src, size_t n));
651_GL_CXXALIASWARN (wcpncpy); 850_GL_CXXALIASWARN (wcpncpy);
652#elif defined GNULIB_POSIXCHECK 851#elif defined GNULIB_POSIXCHECK
653# undef wcpncpy 852# undef wcpncpy
@@ -661,10 +860,14 @@ _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
661/* Append SRC onto DEST. */ 860/* Append SRC onto DEST. */
662#if @GNULIB_WCSCAT@ 861#if @GNULIB_WCSCAT@
663# if !@HAVE_WCSCAT@ 862# if !@HAVE_WCSCAT@
664_GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); 863_GL_FUNCDECL_SYS (wcscat, wchar_t *,
864 (wchar_t *restrict dest, const wchar_t *restrict src));
665# endif 865# endif
666_GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); 866_GL_CXXALIAS_SYS (wcscat, wchar_t *,
867 (wchar_t *restrict dest, const wchar_t *restrict src));
868# if __GLIBC__ >= 2
667_GL_CXXALIASWARN (wcscat); 869_GL_CXXALIASWARN (wcscat);
870# endif
668#elif defined GNULIB_POSIXCHECK 871#elif defined GNULIB_POSIXCHECK
669# undef wcscat 872# undef wcscat
670# if HAVE_RAW_DECL_WCSCAT 873# if HAVE_RAW_DECL_WCSCAT
@@ -678,11 +881,15 @@ _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
678#if @GNULIB_WCSNCAT@ 881#if @GNULIB_WCSNCAT@
679# if !@HAVE_WCSNCAT@ 882# if !@HAVE_WCSNCAT@
680_GL_FUNCDECL_SYS (wcsncat, wchar_t *, 883_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
681 (wchar_t *dest, const wchar_t *src, size_t n)); 884 (wchar_t *restrict dest, const wchar_t *restrict src,
885 size_t n));
682# endif 886# endif
683_GL_CXXALIAS_SYS (wcsncat, wchar_t *, 887_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
684 (wchar_t *dest, const wchar_t *src, size_t n)); 888 (wchar_t *restrict dest, const wchar_t *restrict src,
889 size_t n));
890# if __GLIBC__ >= 2
685_GL_CXXALIASWARN (wcsncat); 891_GL_CXXALIASWARN (wcsncat);
892# endif
686#elif defined GNULIB_POSIXCHECK 893#elif defined GNULIB_POSIXCHECK
687# undef wcsncat 894# undef wcsncat
688# if HAVE_RAW_DECL_WCSNCAT 895# if HAVE_RAW_DECL_WCSNCAT
@@ -699,7 +906,9 @@ _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
699 _GL_ATTRIBUTE_PURE); 906 _GL_ATTRIBUTE_PURE);
700# endif 907# endif
701_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); 908_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
909# if __GLIBC__ >= 2
702_GL_CXXALIASWARN (wcscmp); 910_GL_CXXALIASWARN (wcscmp);
911# endif
703#elif defined GNULIB_POSIXCHECK 912#elif defined GNULIB_POSIXCHECK
704# undef wcscmp 913# undef wcscmp
705# if HAVE_RAW_DECL_WCSCMP 914# if HAVE_RAW_DECL_WCSCMP
@@ -718,7 +927,9 @@ _GL_FUNCDECL_SYS (wcsncmp, int,
718# endif 927# endif
719_GL_CXXALIAS_SYS (wcsncmp, int, 928_GL_CXXALIAS_SYS (wcsncmp, int,
720 (const wchar_t *s1, const wchar_t *s2, size_t n)); 929 (const wchar_t *s1, const wchar_t *s2, size_t n));
930# if __GLIBC__ >= 2
721_GL_CXXALIASWARN (wcsncmp); 931_GL_CXXALIASWARN (wcsncmp);
932# endif
722#elif defined GNULIB_POSIXCHECK 933#elif defined GNULIB_POSIXCHECK
723# undef wcsncmp 934# undef wcsncmp
724# if HAVE_RAW_DECL_WCSNCMP 935# if HAVE_RAW_DECL_WCSNCMP
@@ -730,7 +941,10 @@ _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
730 941
731/* Compare S1 and S2, ignoring case. */ 942/* Compare S1 and S2, ignoring case. */
732#if @GNULIB_WCSCASECMP@ 943#if @GNULIB_WCSCASECMP@
733# if !@HAVE_WCSCASECMP@ 944/* On Solaris 11.3, the header files declare the function in the std::
945 namespace, not in the global namespace. So, force a declaration in
946 the global namespace. */
947# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
734_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) 948_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
735 _GL_ATTRIBUTE_PURE); 949 _GL_ATTRIBUTE_PURE);
736# endif 950# endif
@@ -747,7 +961,10 @@ _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
747 961
748/* Compare no more than N chars of S1 and S2, ignoring case. */ 962/* Compare no more than N chars of S1 and S2, ignoring case. */
749#if @GNULIB_WCSNCASECMP@ 963#if @GNULIB_WCSNCASECMP@
750# if !@HAVE_WCSNCASECMP@ 964/* On Solaris 11.3, the header files declare the function in the std::
965 namespace, not in the global namespace. So, force a declaration in
966 the global namespace. */
967# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
751_GL_FUNCDECL_SYS (wcsncasecmp, int, 968_GL_FUNCDECL_SYS (wcsncasecmp, int,
752 (const wchar_t *s1, const wchar_t *s2, size_t n) 969 (const wchar_t *s1, const wchar_t *s2, size_t n)
753 _GL_ATTRIBUTE_PURE); 970 _GL_ATTRIBUTE_PURE);
@@ -771,7 +988,9 @@ _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
771_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 988_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
772# endif 989# endif
773_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 990_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
991# if __GLIBC__ >= 2
774_GL_CXXALIASWARN (wcscoll); 992_GL_CXXALIASWARN (wcscoll);
993# endif
775#elif defined GNULIB_POSIXCHECK 994#elif defined GNULIB_POSIXCHECK
776# undef wcscoll 995# undef wcscoll
777# if HAVE_RAW_DECL_WCSCOLL 996# if HAVE_RAW_DECL_WCSCOLL
@@ -786,10 +1005,14 @@ _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
786 original strings. */ 1005 original strings. */
787#if @GNULIB_WCSXFRM@ 1006#if @GNULIB_WCSXFRM@
788# if !@HAVE_WCSXFRM@ 1007# if !@HAVE_WCSXFRM@
789_GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); 1008_GL_FUNCDECL_SYS (wcsxfrm, size_t,
1009 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
790# endif 1010# endif
791_GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); 1011_GL_CXXALIAS_SYS (wcsxfrm, size_t,
1012 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
1013# if __GLIBC__ >= 2
792_GL_CXXALIASWARN (wcsxfrm); 1014_GL_CXXALIASWARN (wcsxfrm);
1015# endif
793#elif defined GNULIB_POSIXCHECK 1016#elif defined GNULIB_POSIXCHECK
794# undef wcsxfrm 1017# undef wcsxfrm
795# if HAVE_RAW_DECL_WCSXFRM 1018# if HAVE_RAW_DECL_WCSXFRM
@@ -801,16 +1024,58 @@ _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
801 1024
802/* Duplicate S, returning an identical malloc'd string. */ 1025/* Duplicate S, returning an identical malloc'd string. */
803#if @GNULIB_WCSDUP@ 1026#if @GNULIB_WCSDUP@
804# if !@HAVE_WCSDUP@ 1027# if defined _WIN32 && !defined __CYGWIN__
805_GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1028# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
806# endif 1029# undef wcsdup
1030# define wcsdup _wcsdup
1031# endif
1032_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1033# else
1034/* On Solaris 11.3, the header files declare the function in the std::
1035 namespace, not in the global namespace. So, force a declaration in
1036 the global namespace. */
1037# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11
1038_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1039 (const wchar_t *s)
1040 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1041# endif
807_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1042_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1043# endif
808_GL_CXXALIASWARN (wcsdup); 1044_GL_CXXALIASWARN (wcsdup);
809#elif defined GNULIB_POSIXCHECK 1045#else
810# undef wcsdup 1046# if __GNUC__ >= 11 && !defined wcsdup
811# if HAVE_RAW_DECL_WCSDUP 1047/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1048_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1049 (const wchar_t *s)
1050 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1051# endif
1052# if defined GNULIB_POSIXCHECK
1053# undef wcsdup
1054# if HAVE_RAW_DECL_WCSDUP
812_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " 1055_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
813 "use gnulib module wcsdup for portability"); 1056 "use gnulib module wcsdup for portability");
1057# endif
1058# elif @GNULIB_MDA_WCSDUP@
1059/* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
1060 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1061 platforms by defining GNULIB_NAMESPACE::wcsdup always. */
1062# if defined _WIN32 && !defined __CYGWIN__
1063# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1064# undef wcsdup
1065# define wcsdup _wcsdup
1066# endif
1067_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1068# else
1069_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1070 (const wchar_t *s)
1071 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1072# if @HAVE_DECL_WCSDUP@
1073_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1074# endif
1075# endif
1076# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
1077_GL_CXXALIASWARN (wcsdup);
1078# endif
814# endif 1079# endif
815#endif 1080#endif
816 1081
@@ -833,7 +1098,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcschr,
833 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1098 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
834_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1099_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
835_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1100_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
836# else 1101# elif __GLIBC__ >= 2
837_GL_CXXALIASWARN (wcschr); 1102_GL_CXXALIASWARN (wcschr);
838# endif 1103# endif
839#elif defined GNULIB_POSIXCHECK 1104#elif defined GNULIB_POSIXCHECK
@@ -863,7 +1128,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
863 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1128 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
864_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1129_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
865_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1130_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
866# else 1131# elif __GLIBC__ >= 2
867_GL_CXXALIASWARN (wcsrchr); 1132_GL_CXXALIASWARN (wcsrchr);
868# endif 1133# endif
869#elif defined GNULIB_POSIXCHECK 1134#elif defined GNULIB_POSIXCHECK
@@ -883,7 +1148,9 @@ _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
883 _GL_ATTRIBUTE_PURE); 1148 _GL_ATTRIBUTE_PURE);
884# endif 1149# endif
885_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); 1150_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
1151# if __GLIBC__ >= 2
886_GL_CXXALIASWARN (wcscspn); 1152_GL_CXXALIASWARN (wcscspn);
1153# endif
887#elif defined GNULIB_POSIXCHECK 1154#elif defined GNULIB_POSIXCHECK
888# undef wcscspn 1155# undef wcscspn
889# if HAVE_RAW_DECL_WCSCSPN 1156# if HAVE_RAW_DECL_WCSCSPN
@@ -901,7 +1168,9 @@ _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
901 _GL_ATTRIBUTE_PURE); 1168 _GL_ATTRIBUTE_PURE);
902# endif 1169# endif
903_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); 1170_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
1171# if __GLIBC__ >= 2
904_GL_CXXALIASWARN (wcsspn); 1172_GL_CXXALIASWARN (wcsspn);
1173# endif
905#elif defined GNULIB_POSIXCHECK 1174#elif defined GNULIB_POSIXCHECK
906# undef wcsspn 1175# undef wcsspn
907# if HAVE_RAW_DECL_WCSSPN 1176# if HAVE_RAW_DECL_WCSSPN
@@ -932,7 +1201,7 @@ _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
932 (wchar_t *wcs, const wchar_t *accept)); 1201 (wchar_t *wcs, const wchar_t *accept));
933_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, 1202_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
934 (const wchar_t *wcs, const wchar_t *accept)); 1203 (const wchar_t *wcs, const wchar_t *accept));
935# else 1204# elif __GLIBC__ >= 2
936_GL_CXXALIASWARN (wcspbrk); 1205_GL_CXXALIASWARN (wcspbrk);
937# endif 1206# endif
938#elif defined GNULIB_POSIXCHECK 1207#elif defined GNULIB_POSIXCHECK
@@ -948,7 +1217,8 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
948#if @GNULIB_WCSSTR@ 1217#if @GNULIB_WCSSTR@
949# if !@HAVE_WCSSTR@ 1218# if !@HAVE_WCSSTR@
950_GL_FUNCDECL_SYS (wcsstr, wchar_t *, 1219_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
951 (const wchar_t *haystack, const wchar_t *needle) 1220 (const wchar_t *restrict haystack,
1221 const wchar_t *restrict needle)
952 _GL_ATTRIBUTE_PURE); 1222 _GL_ATTRIBUTE_PURE);
953# endif 1223# endif
954 /* On some systems, this function is defined as an overloaded function: 1224 /* On some systems, this function is defined as an overloaded function:
@@ -957,15 +1227,19 @@ _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
957 wchar_t * std::wcsstr (wchar_t *, const wchar_t *); 1227 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
958 } */ 1228 } */
959_GL_CXXALIAS_SYS_CAST2 (wcsstr, 1229_GL_CXXALIAS_SYS_CAST2 (wcsstr,
960 wchar_t *, (const wchar_t *, const wchar_t *), 1230 wchar_t *,
961 const wchar_t *, (const wchar_t *, const wchar_t *)); 1231 (const wchar_t *restrict, const wchar_t *restrict),
1232 const wchar_t *,
1233 (const wchar_t *restrict, const wchar_t *restrict));
962# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1234# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
963 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1235 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
964_GL_CXXALIASWARN1 (wcsstr, wchar_t *, 1236_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
965 (wchar_t *haystack, const wchar_t *needle)); 1237 (wchar_t *restrict haystack,
1238 const wchar_t *restrict needle));
966_GL_CXXALIASWARN1 (wcsstr, const wchar_t *, 1239_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
967 (const wchar_t *haystack, const wchar_t *needle)); 1240 (const wchar_t *restrict haystack,
968# else 1241 const wchar_t *restrict needle));
1242# elif __GLIBC__ >= 2
969_GL_CXXALIASWARN (wcsstr); 1243_GL_CXXALIASWARN (wcsstr);
970# endif 1244# endif
971#elif defined GNULIB_POSIXCHECK 1245#elif defined GNULIB_POSIXCHECK
@@ -979,13 +1253,30 @@ _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
979 1253
980/* Divide WCS into tokens separated by characters in DELIM. */ 1254/* Divide WCS into tokens separated by characters in DELIM. */
981#if @GNULIB_WCSTOK@ 1255#if @GNULIB_WCSTOK@
982# if !@HAVE_WCSTOK@ 1256# if @REPLACE_WCSTOK@
1257# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1258# undef wcstok
1259# define wcstok rpl_wcstok
1260# endif
1261_GL_FUNCDECL_RPL (wcstok, wchar_t *,
1262 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1263 wchar_t **restrict ptr));
1264_GL_CXXALIAS_RPL (wcstok, wchar_t *,
1265 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1266 wchar_t **restrict ptr));
1267# else
1268# if !@HAVE_WCSTOK@
983_GL_FUNCDECL_SYS (wcstok, wchar_t *, 1269_GL_FUNCDECL_SYS (wcstok, wchar_t *,
984 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); 1270 (wchar_t *restrict wcs, const wchar_t *restrict delim,
985# endif 1271 wchar_t **restrict ptr));
1272# endif
986_GL_CXXALIAS_SYS (wcstok, wchar_t *, 1273_GL_CXXALIAS_SYS (wcstok, wchar_t *,
987 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); 1274 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1275 wchar_t **restrict ptr));
1276# endif
1277# if __GLIBC__ >= 2
988_GL_CXXALIASWARN (wcstok); 1278_GL_CXXALIASWARN (wcstok);
1279# endif
989#elif defined GNULIB_POSIXCHECK 1280#elif defined GNULIB_POSIXCHECK
990# undef wcstok 1281# undef wcstok
991# if HAVE_RAW_DECL_WCSTOK 1282# if HAVE_RAW_DECL_WCSTOK
@@ -1013,7 +1304,9 @@ _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1013# endif 1304# endif
1014_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); 1305_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1015# endif 1306# endif
1307# if __GLIBC__ >= 2
1016_GL_CXXALIASWARN (wcswidth); 1308_GL_CXXALIASWARN (wcswidth);
1309# endif
1017#elif defined GNULIB_POSIXCHECK 1310#elif defined GNULIB_POSIXCHECK
1018# undef wcswidth 1311# undef wcswidth
1019# if HAVE_RAW_DECL_WCSWIDTH 1312# if HAVE_RAW_DECL_WCSWIDTH
@@ -1023,6 +1316,48 @@ _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1023#endif 1316#endif
1024 1317
1025 1318
1319/* Convert *TP to a date and time wide string. See
1320 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1321#if @GNULIB_WCSFTIME@
1322# if @REPLACE_WCSFTIME@
1323# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1324# undef wcsftime
1325# define wcsftime rpl_wcsftime
1326# endif
1327_GL_FUNCDECL_RPL (wcsftime, size_t,
1328 (wchar_t *restrict __buf, size_t __bufsize,
1329 const wchar_t *restrict __fmt,
1330 const struct tm *restrict __tp)
1331 _GL_ARG_NONNULL ((1, 3, 4)));
1332_GL_CXXALIAS_RPL (wcsftime, size_t,
1333 (wchar_t *restrict __buf, size_t __bufsize,
1334 const wchar_t *restrict __fmt,
1335 const struct tm *restrict __tp));
1336# else
1337# if !@HAVE_WCSFTIME@
1338_GL_FUNCDECL_SYS (wcsftime, size_t,
1339 (wchar_t *restrict __buf, size_t __bufsize,
1340 const wchar_t *restrict __fmt,
1341 const struct tm *restrict __tp)
1342 _GL_ARG_NONNULL ((1, 3, 4)));
1343# endif
1344_GL_CXXALIAS_SYS (wcsftime, size_t,
1345 (wchar_t *restrict __buf, size_t __bufsize,
1346 const wchar_t *restrict __fmt,
1347 const struct tm *restrict __tp));
1348# endif
1349# if __GLIBC__ >= 2
1350_GL_CXXALIASWARN (wcsftime);
1351# endif
1352#elif defined GNULIB_POSIXCHECK
1353# undef wcsftime
1354# if HAVE_RAW_DECL_WCSFTIME
1355_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1356 "use gnulib module wcsftime for portability");
1357# endif
1358#endif
1359
1360
1026#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1361#endif /* _@GUARD_PREFIX@_WCHAR_H */
1027#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1362#endif /* _@GUARD_PREFIX@_WCHAR_H */
1028#endif 1363#endif
diff --git a/gl/wcrtomb.c b/gl/wcrtomb.c
index da42809b..48a6c8eb 100644
--- a/gl/wcrtomb.c
+++ b/gl/wcrtomb.c
@@ -1,19 +1,19 @@
1/* Convert wide character to multibyte character. 1/* Convert wide character to multibyte character.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -26,20 +26,46 @@
26 26
27size_t 27size_t
28wcrtomb (char *s, wchar_t wc, mbstate_t *ps) 28wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
29#undef wcrtomb
29{ 30{
30 /* This implementation of wcrtomb on top of wctomb() supports only 31 /* This implementation of wcrtomb supports only stateless encodings.
31 stateless encodings. ps must be in the initial state. */ 32 ps must be in the initial state. */
32 if (ps != NULL && !mbsinit (ps)) 33 if (ps != NULL && !mbsinit (ps))
33 { 34 {
34 errno = EINVAL; 35 errno = EINVAL;
35 return (size_t)(-1); 36 return (size_t)(-1);
36 } 37 }
37 38
39#if !HAVE_WCRTOMB /* IRIX 6.5 */ \
40 || WCRTOMB_RETVAL_BUG /* Solaris 11.3, MSVC */ \
41 || WCRTOMB_C_LOCALE_BUG /* Android */
38 if (s == NULL) 42 if (s == NULL)
39 /* We know the NUL wide character corresponds to the NUL character. */ 43 /* We know the NUL wide character corresponds to the NUL character. */
40 return 1; 44 return 1;
41 else 45 else
46#endif
42 { 47 {
48#if HAVE_WCRTOMB
49# if WCRTOMB_C_LOCALE_BUG /* Android */
50 /* Implement consistently with mbrtowc(): through a 1:1 correspondence,
51 as in ISO-8859-1. */
52 if (wc >= 0 && wc <= 0xff)
53 {
54 *s = (unsigned char) wc;
55 return 1;
56 }
57 else
58 {
59 errno = EILSEQ;
60 return (size_t)(-1);
61 }
62# else
63 return wcrtomb (s, wc, ps);
64# endif
65#else /* IRIX 6.5 */
66 /* Fallback for platforms that don't have wcrtomb().
67 Implement on top of wctomb().
68 This code is not multithread-safe. */
43 int ret = wctomb (s, wc); 69 int ret = wctomb (s, wc);
44 70
45 if (ret >= 0) 71 if (ret >= 0)
@@ -49,5 +75,6 @@ wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
49 errno = EILSEQ; 75 errno = EILSEQ;
50 return (size_t)(-1); 76 return (size_t)(-1);
51 } 77 }
78#endif
52 } 79 }
53} 80}
diff --git a/gl/wctype-h.c b/gl/wctype-h.c
index bb5f847e..7d3e14a6 100644
--- a/gl/wctype-h.c
+++ b/gl/wctype-h.c
@@ -1,4 +1,23 @@
1/* Inline functions for <wctype.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1/* Normally this would be wctype.c, but that name's already taken. */ 18/* Normally this would be wctype.c, but that name's already taken. */
19
2#include <config.h> 20#include <config.h>
21
3#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE 22#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE
4#include "wctype.h" 23#include "wctype.h"
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
index a7c07d1e..f6e474d3 100644
--- a/gl/wctype.in.h
+++ b/gl/wctype.in.h
@@ -1,54 +1,61 @@
1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it. 1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
2 2
3 Copyright (C) 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Bruno Haible and Paul Eggert. */ 18/* Written by Bruno Haible and Paul Eggert. */
19 19
20/* 20/*
21 * ISO C 99 <wctype.h> for platforms that lack it. 21 * ISO C 99 <wctype.h> for platforms that lack it.
22 * <http://www.opengroup.org/susv3xbd/wctype.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wctype.h.html>
23 * 23 *
24 * iswctype, towctrans, towlower, towupper, wctrans, wctype, 24 * iswctype, towctrans, towlower, towupper, wctrans, wctype,
25 * wctrans_t, and wctype_t are not yet implemented. 25 * wctrans_t, and wctype_t are not yet implemented.
26 */ 26 */
27 27
28#ifndef _@GUARD_PREFIX@_WCTYPE_H
29
30#if __GNUC__ >= 3 28#if __GNUC__ >= 3
31@PRAGMA_SYSTEM_HEADER@ 29@PRAGMA_SYSTEM_HEADER@
32#endif 30#endif
33@PRAGMA_COLUMNS@ 31@PRAGMA_COLUMNS@
34 32
33#if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)
34
35/* Special invocation convention:
36 - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of
37 <wctype.h> is being processed, which doesn't include the idempotency
38 guard. */
39
40#@INCLUDE_NEXT@ @NEXT_WCTYPE_H@
41
42#else
43/* Normal invocation convention. */
44
45#ifndef _@GUARD_PREFIX@_WCTYPE_H
46
35#if @HAVE_WINT_T@ 47#if @HAVE_WINT_T@
36/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. 48/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
37 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
38 <wchar.h>.
39 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
40 included before <wchar.h>. */
41# include <stddef.h>
42# include <stdio.h>
43# include <time.h>
44# include <wchar.h> 49# include <wchar.h>
45#endif 50#endif
46 51
47/* mingw has declarations of towupper and towlower in <ctype.h> as 52/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
48 well <wctype.h>. Include <ctype.h> in advance to avoid rpl_ prefix 53 isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>. Include
49 being added to the declarations. */ 54 <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
50#ifdef __MINGW32__ 55 declarations. */
56#if defined _WIN32 && ! defined __CYGWIN__
51# include <ctype.h> 57# include <ctype.h>
58# include <wchar.h>
52#endif 59#endif
53 60
54/* Include the original <wctype.h> if it exists. 61/* Include the original <wctype.h> if it exists.
@@ -61,6 +68,9 @@
61#ifndef _@GUARD_PREFIX@_WCTYPE_H 68#ifndef _@GUARD_PREFIX@_WCTYPE_H
62#define _@GUARD_PREFIX@_WCTYPE_H 69#define _@GUARD_PREFIX@_WCTYPE_H
63 70
71#ifndef _GL_INLINE_HEADER_BEGIN
72 #error "Please include config.h first."
73#endif
64_GL_INLINE_HEADER_BEGIN 74_GL_INLINE_HEADER_BEGIN
65#ifndef _GL_WCTYPE_INLINE 75#ifndef _GL_WCTYPE_INLINE
66# define _GL_WCTYPE_INLINE _GL_INLINE 76# define _GL_WCTYPE_INLINE _GL_INLINE
@@ -90,12 +100,16 @@ _GL_INLINE_HEADER_BEGIN
90# define WEOF -1 100# define WEOF -1
91# endif 101# endif
92#else 102#else
93/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>. 103/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
94 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be 104 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
95 "unchanged by default argument promotions". Override it. */ 105 wint_t must be "unchanged by default argument promotions". Override it. */
96# if defined _MSC_VER 106# if @GNULIBHEADERS_OVERRIDE_WINT_T@
97# if !GNULIB_defined_wint_t 107# if !GNULIB_defined_wint_t
98# include <crtdefs.h> 108# if @HAVE_CRTDEFS_H@
109# include <crtdefs.h>
110# else
111# include <stddef.h>
112# endif
99typedef unsigned int rpl_wint_t; 113typedef unsigned int rpl_wint_t;
100# undef wint_t 114# undef wint_t
101# define wint_t rpl_wint_t 115# define wint_t rpl_wint_t
@@ -112,33 +126,116 @@ typedef unsigned int rpl_wint_t;
112 126
113/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. 127/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
114 Linux libc5 has <wctype.h> and the functions but they are broken. 128 Linux libc5 has <wctype.h> and the functions but they are broken.
129 mingw and MSVC have <wctype.h> and the functions but they take a wchar_t
130 as argument, not an rpl_wint_t.
115 Assume all 11 functions (all isw* except iswblank) are implemented the 131 Assume all 11 functions (all isw* except iswblank) are implemented the
116 same way, or not at all. */ 132 same way, or not at all. */
117# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ 133# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
118 134
119/* IRIX 5.3 has macros but no functions, its isw* macros refer to an 135# if @GNULIBHEADERS_OVERRIDE_WINT_T@ /* implies @REPLACE_ISWCNTRL@ */
120 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they 136
121 refer to system functions like _iswctype that are not in the 137_GL_WCTYPE_INLINE int
122 standard C library. Rather than try to get ancient buggy 138rpl_iswalnum (wint_t wc)
123 implementations like this to work, just disable them. */ 139{
124# undef iswalnum 140 return ((wchar_t) wc == wc ? iswalnum ((wchar_t) wc) : 0);
125# undef iswalpha 141}
126# undef iswblank 142
127# undef iswcntrl 143_GL_WCTYPE_INLINE int
128# undef iswdigit 144rpl_iswalpha (wint_t wc)
129# undef iswgraph 145{
130# undef iswlower 146 return ((wchar_t) wc == wc ? iswalpha ((wchar_t) wc) : 0);
131# undef iswprint 147}
132# undef iswpunct 148
133# undef iswspace 149_GL_WCTYPE_INLINE int
134# undef iswupper 150rpl_iswblank (wint_t wc)
135# undef iswxdigit 151{
136# undef towlower 152 return ((wchar_t) wc == wc ? iswblank ((wchar_t) wc) : 0);
137# undef towupper 153}
154
155_GL_WCTYPE_INLINE int
156rpl_iswcntrl (wint_t wc)
157{
158 return ((wchar_t) wc == wc ? iswcntrl ((wchar_t) wc) : 0);
159}
160
161_GL_WCTYPE_INLINE int
162rpl_iswdigit (wint_t wc)
163{
164 return ((wchar_t) wc == wc ? wc >= '0' && wc <= '9' : 0);
165}
166
167_GL_WCTYPE_INLINE int
168rpl_iswgraph (wint_t wc)
169{
170 return ((wchar_t) wc == wc ? iswgraph ((wchar_t) wc) : 0);
171}
172
173_GL_WCTYPE_INLINE int
174rpl_iswlower (wint_t wc)
175{
176 return ((wchar_t) wc == wc ? iswlower ((wchar_t) wc) : 0);
177}
178
179_GL_WCTYPE_INLINE int
180rpl_iswprint (wint_t wc)
181{
182 return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0);
183}
184
185_GL_WCTYPE_INLINE int
186rpl_iswpunct (wint_t wc)
187{
188 return ((wchar_t) wc == wc ? iswpunct ((wchar_t) wc) : 0);
189}
190
191_GL_WCTYPE_INLINE int
192rpl_iswspace (wint_t wc)
193{
194 return ((wchar_t) wc == wc ? iswspace ((wchar_t) wc) : 0);
195}
196
197_GL_WCTYPE_INLINE int
198rpl_iswupper (wint_t wc)
199{
200 return ((wchar_t) wc == wc ? iswupper ((wchar_t) wc) : 0);
201}
202
203_GL_WCTYPE_INLINE int
204rpl_iswxdigit (wint_t wc)
205{
206 return ((wchar_t) wc == wc
207 ? (wc >= '0' && wc <= '9')
208 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')
209 : 0);
210}
211
212_GL_WCTYPE_INLINE wint_t
213rpl_towlower (wint_t wc)
214{
215 return ((wchar_t) wc == wc ? (wchar_t) towlower ((wchar_t) wc) : wc);
216}
217
218_GL_WCTYPE_INLINE wint_t
219rpl_towupper (wint_t wc)
220{
221 return ((wchar_t) wc == wc ? (wchar_t) towupper ((wchar_t) wc) : wc);
222}
138 223
139/* Linux libc5 has <wctype.h> and the functions but they are broken. */
140# if @REPLACE_ISWCNTRL@
141# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 224# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
225# undef iswalnum
226# undef iswalpha
227# undef iswblank
228# undef iswcntrl
229# undef iswdigit
230# undef iswgraph
231# undef iswlower
232# undef iswprint
233# undef iswpunct
234# undef iswspace
235# undef iswupper
236# undef iswxdigit
237# undef towlower
238# undef towupper
142# define iswalnum rpl_iswalnum 239# define iswalnum rpl_iswalnum
143# define iswalpha rpl_iswalpha 240# define iswalpha rpl_iswalpha
144# define iswblank rpl_iswblank 241# define iswblank rpl_iswblank
@@ -151,21 +248,62 @@ typedef unsigned int rpl_wint_t;
151# define iswspace rpl_iswspace 248# define iswspace rpl_iswspace
152# define iswupper rpl_iswupper 249# define iswupper rpl_iswupper
153# define iswxdigit rpl_iswxdigit 250# define iswxdigit rpl_iswxdigit
154# endif
155# endif
156# if @REPLACE_TOWLOWER@
157# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
158# define towlower rpl_towlower 251# define towlower rpl_towlower
159# define towupper rpl_towupper 252# define towupper rpl_towupper
160# endif 253# endif
161# endif 254
255# else
256
257/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
258 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
259 refer to system functions like _iswctype that are not in the
260 standard C library. Rather than try to get ancient buggy
261 implementations like this to work, just disable them. */
262# undef iswalnum
263# undef iswalpha
264# undef iswblank
265# undef iswcntrl
266# undef iswdigit
267# undef iswgraph
268# undef iswlower
269# undef iswprint
270# undef iswpunct
271# undef iswspace
272# undef iswupper
273# undef iswxdigit
274# undef towlower
275# undef towupper
276
277/* Linux libc5 has <wctype.h> and the functions but they are broken. */
278# if @REPLACE_ISWCNTRL@
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# define iswalnum rpl_iswalnum
281# define iswalpha rpl_iswalpha
282# define iswblank rpl_iswblank
283# define iswcntrl rpl_iswcntrl
284# define iswdigit rpl_iswdigit
285# define iswgraph rpl_iswgraph
286# define iswlower rpl_iswlower
287# define iswprint rpl_iswprint
288# define iswpunct rpl_iswpunct
289# define iswspace rpl_iswspace
290# define iswupper rpl_iswupper
291# define iswxdigit rpl_iswxdigit
292# endif
293# endif
294# if @REPLACE_TOWLOWER@
295# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
296# define towlower rpl_towlower
297# define towupper rpl_towupper
298# endif
299# endif
162 300
163_GL_WCTYPE_INLINE int 301_GL_WCTYPE_INLINE int
164# if @REPLACE_ISWCNTRL@ 302# if @REPLACE_ISWCNTRL@
165rpl_iswalnum 303rpl_iswalnum
166# else 304# else
167iswalnum 305iswalnum
168# endif 306# endif
169 (wint_t wc) 307 (wint_t wc)
170{ 308{
171 return ((wc >= '0' && wc <= '9') 309 return ((wc >= '0' && wc <= '9')
@@ -173,88 +311,88 @@ iswalnum
173} 311}
174 312
175_GL_WCTYPE_INLINE int 313_GL_WCTYPE_INLINE int
176# if @REPLACE_ISWCNTRL@ 314# if @REPLACE_ISWCNTRL@
177rpl_iswalpha 315rpl_iswalpha
178# else 316# else
179iswalpha 317iswalpha
180# endif 318# endif
181 (wint_t wc) 319 (wint_t wc)
182{ 320{
183 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; 321 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
184} 322}
185 323
186_GL_WCTYPE_INLINE int 324_GL_WCTYPE_INLINE int
187# if @REPLACE_ISWCNTRL@ 325# if @REPLACE_ISWCNTRL@
188rpl_iswblank 326rpl_iswblank
189# else 327# else
190iswblank 328iswblank
191# endif 329# endif
192 (wint_t wc) 330 (wint_t wc)
193{ 331{
194 return wc == ' ' || wc == '\t'; 332 return wc == ' ' || wc == '\t';
195} 333}
196 334
197_GL_WCTYPE_INLINE int 335_GL_WCTYPE_INLINE int
198# if @REPLACE_ISWCNTRL@ 336# if @REPLACE_ISWCNTRL@
199rpl_iswcntrl 337rpl_iswcntrl
200# else 338# else
201iswcntrl 339iswcntrl
202# endif 340# endif
203 (wint_t wc) 341 (wint_t wc)
204{ 342{
205 return (wc & ~0x1f) == 0 || wc == 0x7f; 343 return (wc & ~0x1f) == 0 || wc == 0x7f;
206} 344}
207 345
208_GL_WCTYPE_INLINE int 346_GL_WCTYPE_INLINE int
209# if @REPLACE_ISWCNTRL@ 347# if @REPLACE_ISWDIGIT@
210rpl_iswdigit 348rpl_iswdigit
211# else 349# else
212iswdigit 350iswdigit
213# endif 351# endif
214 (wint_t wc) 352 (wint_t wc)
215{ 353{
216 return wc >= '0' && wc <= '9'; 354 return wc >= '0' && wc <= '9';
217} 355}
218 356
219_GL_WCTYPE_INLINE int 357_GL_WCTYPE_INLINE int
220# if @REPLACE_ISWCNTRL@ 358# if @REPLACE_ISWCNTRL@
221rpl_iswgraph 359rpl_iswgraph
222# else 360# else
223iswgraph 361iswgraph
224# endif 362# endif
225 (wint_t wc) 363 (wint_t wc)
226{ 364{
227 return wc >= '!' && wc <= '~'; 365 return wc >= '!' && wc <= '~';
228} 366}
229 367
230_GL_WCTYPE_INLINE int 368_GL_WCTYPE_INLINE int
231# if @REPLACE_ISWCNTRL@ 369# if @REPLACE_ISWCNTRL@
232rpl_iswlower 370rpl_iswlower
233# else 371# else
234iswlower 372iswlower
235# endif 373# endif
236 (wint_t wc) 374 (wint_t wc)
237{ 375{
238 return wc >= 'a' && wc <= 'z'; 376 return wc >= 'a' && wc <= 'z';
239} 377}
240 378
241_GL_WCTYPE_INLINE int 379_GL_WCTYPE_INLINE int
242# if @REPLACE_ISWCNTRL@ 380# if @REPLACE_ISWCNTRL@
243rpl_iswprint 381rpl_iswprint
244# else 382# else
245iswprint 383iswprint
246# endif 384# endif
247 (wint_t wc) 385 (wint_t wc)
248{ 386{
249 return wc >= ' ' && wc <= '~'; 387 return wc >= ' ' && wc <= '~';
250} 388}
251 389
252_GL_WCTYPE_INLINE int 390_GL_WCTYPE_INLINE int
253# if @REPLACE_ISWCNTRL@ 391# if @REPLACE_ISWCNTRL@
254rpl_iswpunct 392rpl_iswpunct
255# else 393# else
256iswpunct 394iswpunct
257# endif 395# endif
258 (wint_t wc) 396 (wint_t wc)
259{ 397{
260 return (wc >= '!' && wc <= '~' 398 return (wc >= '!' && wc <= '~'
@@ -263,11 +401,11 @@ iswpunct
263} 401}
264 402
265_GL_WCTYPE_INLINE int 403_GL_WCTYPE_INLINE int
266# if @REPLACE_ISWCNTRL@ 404# if @REPLACE_ISWCNTRL@
267rpl_iswspace 405rpl_iswspace
268# else 406# else
269iswspace 407iswspace
270# endif 408# endif
271 (wint_t wc) 409 (wint_t wc)
272{ 410{
273 return (wc == ' ' || wc == '\t' 411 return (wc == ' ' || wc == '\t'
@@ -275,22 +413,22 @@ iswspace
275} 413}
276 414
277_GL_WCTYPE_INLINE int 415_GL_WCTYPE_INLINE int
278# if @REPLACE_ISWCNTRL@ 416# if @REPLACE_ISWCNTRL@
279rpl_iswupper 417rpl_iswupper
280# else 418# else
281iswupper 419iswupper
282# endif 420# endif
283 (wint_t wc) 421 (wint_t wc)
284{ 422{
285 return wc >= 'A' && wc <= 'Z'; 423 return wc >= 'A' && wc <= 'Z';
286} 424}
287 425
288_GL_WCTYPE_INLINE int 426_GL_WCTYPE_INLINE int
289# if @REPLACE_ISWCNTRL@ 427# if @REPLACE_ISWXDIGIT@
290rpl_iswxdigit 428rpl_iswxdigit
291# else 429# else
292iswxdigit 430iswxdigit
293# endif 431# endif
294 (wint_t wc) 432 (wint_t wc)
295{ 433{
296 return ((wc >= '0' && wc <= '9') 434 return ((wc >= '0' && wc <= '9')
@@ -298,42 +436,67 @@ iswxdigit
298} 436}
299 437
300_GL_WCTYPE_INLINE wint_t 438_GL_WCTYPE_INLINE wint_t
301# if @REPLACE_TOWLOWER@ 439# if @REPLACE_TOWLOWER@
302rpl_towlower 440rpl_towlower
303# else 441# else
304towlower 442towlower
305# endif 443# endif
306 (wint_t wc) 444 (wint_t wc)
307{ 445{
308 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); 446 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
309} 447}
310 448
311_GL_WCTYPE_INLINE wint_t 449_GL_WCTYPE_INLINE wint_t
312# if @REPLACE_TOWLOWER@ 450# if @REPLACE_TOWLOWER@
313rpl_towupper 451rpl_towupper
314# else 452# else
315towupper 453towupper
316# endif 454# endif
317 (wint_t wc) 455 (wint_t wc)
318{ 456{
319 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); 457 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
320} 458}
321 459
322# elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@) 460# endif
323/* Only the iswblank function is missing. */
324 461
325# if @REPLACE_ISWBLANK@ 462# else
326# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 463/* Only some of the functions are missing or broken. */
327# define iswblank rpl_iswblank 464
328# endif 465# if @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
466/* Only the iswblank function is missing. */
467# if @REPLACE_ISWBLANK@
468# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
469# define iswblank rpl_iswblank
470# endif
329_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); 471_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
330# else 472# else
331_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); 473_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
474# endif
475# endif
476
477# if @GNULIB_ISWDIGIT@
478# if @REPLACE_ISWDIGIT@
479# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
480# undef iswdigit
481# define iswdigit rpl_iswdigit
482# endif
483_GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc));
484# endif
485# endif
486
487# if @GNULIB_ISWXDIGIT@
488# if @REPLACE_ISWXDIGIT@
489# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
490# undef iswxdigit
491# define iswxdigit rpl_iswxdigit
492# endif
493_GL_FUNCDECL_RPL (iswxdigit, int, (wint_t wc));
494# endif
332# endif 495# endif
333 496
334# endif 497# endif
335 498
336# if defined __MINGW32__ 499# if defined __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@
337 500
338/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. 501/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
339 The functions towlower and towupper are implemented in the MSVCRT library 502 The functions towlower and towupper are implemented in the MSVCRT library
@@ -366,36 +529,71 @@ rpl_towupper (wint_t wc)
366# define towupper rpl_towupper 529# define towupper rpl_towupper
367# endif 530# endif
368 531
369# endif /* __MINGW32__ */ 532# endif /* __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@ */
370 533
371# define GNULIB_defined_wctype_functions 1 534# define GNULIB_defined_wctype_functions 1
372#endif 535#endif
373 536
374#if @REPLACE_ISWCNTRL@ 537#if @REPLACE_ISWCNTRL@
375_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); 538_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
376_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
377_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
378_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
379_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
380_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
381_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
382_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
383_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
384_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
385_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
386#else 539#else
387_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); 540_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
541#endif
542#if @REPLACE_ISWCNTRL@
543_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
544#else
388_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); 545_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
546#endif
547#if @REPLACE_ISWCNTRL@
548_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
549#else
389_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); 550_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
551#endif
552#if @GNULIB_ISWDIGIT@
553# if @REPLACE_ISWDIGIT@
554_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
555# else
390_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); 556_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
557# endif
558#endif
559#if @REPLACE_ISWCNTRL@
560_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
561#else
391_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); 562_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
563#endif
564#if @REPLACE_ISWCNTRL@
565_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
566#else
392_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); 567_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
568#endif
569#if @REPLACE_ISWCNTRL@
570_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
571#else
393_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); 572_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
573#endif
574#if @REPLACE_ISWCNTRL@
575_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
576#else
394_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); 577_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
578#endif
579#if @REPLACE_ISWCNTRL@
580_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
581#else
395_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); 582_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
583#endif
584#if @REPLACE_ISWCNTRL@
585_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
586#else
396_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); 587_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
588#endif
589#if @GNULIB_ISWXDIGIT@
590# if @REPLACE_ISWXDIGIT@
591_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
592# else
397_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); 593_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
594# endif
398#endif 595#endif
596#if __GLIBC__ >= 2
399_GL_CXXALIASWARN (iswalnum); 597_GL_CXXALIASWARN (iswalnum);
400_GL_CXXALIASWARN (iswalpha); 598_GL_CXXALIASWARN (iswalpha);
401_GL_CXXALIASWARN (iswcntrl); 599_GL_CXXALIASWARN (iswcntrl);
@@ -407,6 +605,7 @@ _GL_CXXALIASWARN (iswpunct);
407_GL_CXXALIASWARN (iswspace); 605_GL_CXXALIASWARN (iswspace);
408_GL_CXXALIASWARN (iswupper); 606_GL_CXXALIASWARN (iswupper);
409_GL_CXXALIASWARN (iswxdigit); 607_GL_CXXALIASWARN (iswxdigit);
608#endif
410 609
411#if @GNULIB_ISWBLANK@ 610#if @GNULIB_ISWBLANK@
412# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@ 611# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
@@ -414,7 +613,9 @@ _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
414# else 613# else
415_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); 614_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
416# endif 615# endif
616# if __GLIBC__ >= 2
417_GL_CXXALIASWARN (iswblank); 617_GL_CXXALIASWARN (iswblank);
618# endif
418#endif 619#endif
419 620
420#if !@HAVE_WCTYPE_T@ 621#if !@HAVE_WCTYPE_T@
@@ -430,7 +631,9 @@ typedef void * wctype_t;
430_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); 631_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
431# endif 632# endif
432_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); 633_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
634# if __GLIBC__ >= 2
433_GL_CXXALIASWARN (wctype); 635_GL_CXXALIASWARN (wctype);
636# endif
434#elif defined GNULIB_POSIXCHECK 637#elif defined GNULIB_POSIXCHECK
435# undef wctype 638# undef wctype
436# if HAVE_RAW_DECL_WCTYPE 639# if HAVE_RAW_DECL_WCTYPE
@@ -443,11 +646,22 @@ _GL_WARN_ON_USE (wctype, "wctype is unportable - "
443 The argument WC must be either a wchar_t value or WEOF. 646 The argument WC must be either a wchar_t value or WEOF.
444 The argument DESC must have been returned by the wctype() function. */ 647 The argument DESC must have been returned by the wctype() function. */
445#if @GNULIB_ISWCTYPE@ 648#if @GNULIB_ISWCTYPE@
446# if !@HAVE_WCTYPE_T@ 649# if @GNULIBHEADERS_OVERRIDE_WINT_T@
650# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
651# undef iswctype
652# define iswctype rpl_iswctype
653# endif
654_GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc));
655_GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc));
656# else
657# if !@HAVE_WCTYPE_T@
447_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); 658_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
448# endif 659# endif
449_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); 660_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
661# endif
662# if __GLIBC__ >= 2
450_GL_CXXALIASWARN (iswctype); 663_GL_CXXALIASWARN (iswctype);
664# endif
451#elif defined GNULIB_POSIXCHECK 665#elif defined GNULIB_POSIXCHECK
452# undef iswctype 666# undef iswctype
453# if HAVE_RAW_DECL_ISWCTYPE 667# if HAVE_RAW_DECL_ISWCTYPE
@@ -463,8 +677,10 @@ _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
463_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); 677_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
464_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); 678_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
465#endif 679#endif
680#if __GLIBC__ >= 2
466_GL_CXXALIASWARN (towlower); 681_GL_CXXALIASWARN (towlower);
467_GL_CXXALIASWARN (towupper); 682_GL_CXXALIASWARN (towupper);
683#endif
468 684
469#if !@HAVE_WCTRANS_T@ 685#if !@HAVE_WCTRANS_T@
470# if !GNULIB_defined_wctrans_t 686# if !GNULIB_defined_wctrans_t
@@ -479,7 +695,9 @@ typedef void * wctrans_t;
479_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); 695_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
480# endif 696# endif
481_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); 697_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
698# if __GLIBC__ >= 2
482_GL_CXXALIASWARN (wctrans); 699_GL_CXXALIASWARN (wctrans);
700# endif
483#elif defined GNULIB_POSIXCHECK 701#elif defined GNULIB_POSIXCHECK
484# undef wctrans 702# undef wctrans
485# if HAVE_RAW_DECL_WCTRANS 703# if HAVE_RAW_DECL_WCTRANS
@@ -496,7 +714,9 @@ _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
496_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); 714_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
497# endif 715# endif
498_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); 716_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
717# if __GLIBC__ >= 2
499_GL_CXXALIASWARN (towctrans); 718_GL_CXXALIASWARN (towctrans);
719# endif
500#elif defined GNULIB_POSIXCHECK 720#elif defined GNULIB_POSIXCHECK
501# undef towctrans 721# undef towctrans
502# if HAVE_RAW_DECL_TOWCTRANS 722# if HAVE_RAW_DECL_TOWCTRANS
@@ -509,3 +729,4 @@ _GL_INLINE_HEADER_END
509 729
510#endif /* _@GUARD_PREFIX@_WCTYPE_H */ 730#endif /* _@GUARD_PREFIX@_WCTYPE_H */
511#endif /* _@GUARD_PREFIX@_WCTYPE_H */ 731#endif /* _@GUARD_PREFIX@_WCTYPE_H */
732#endif
diff --git a/gl/windows-initguard.h b/gl/windows-initguard.h
new file mode 100644
index 00000000..9d36f53c
--- /dev/null
+++ b/gl/windows-initguard.h
@@ -0,0 +1,35 @@
1/* Init guards, somewhat like spinlocks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_INITGUARD_H
21#define _WINDOWS_INITGUARD_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26typedef struct
27 {
28 volatile int done;
29 volatile LONG started;
30 }
31 glwthread_initguard_t;
32
33#define GLWTHREAD_INITGUARD_INIT { 0, -1 }
34
35#endif /* _WINDOWS_INITGUARD_H */
diff --git a/gl/windows-mutex.c b/gl/windows-mutex.c
new file mode 100644
index 00000000..ab7258c9
--- /dev/null
+++ b/gl/windows-mutex.c
@@ -0,0 +1,95 @@
1/* Plain mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-mutex.h"
24
25#include <errno.h>
26
27void
28glwthread_mutex_init (glwthread_mutex_t *mutex)
29{
30 InitializeCriticalSection (&mutex->lock);
31 mutex->guard.done = 1;
32}
33
34int
35glwthread_mutex_lock (glwthread_mutex_t *mutex)
36{
37 if (!mutex->guard.done)
38 {
39 if (InterlockedIncrement (&mutex->guard.started) == 0)
40 /* This thread is the first one to need this mutex. Initialize it. */
41 glwthread_mutex_init (mutex);
42 else
43 {
44 /* Don't let mutex->guard.started grow and wrap around. */
45 InterlockedDecrement (&mutex->guard.started);
46 /* Yield the CPU while waiting for another thread to finish
47 initializing this mutex. */
48 while (!mutex->guard.done)
49 Sleep (0);
50 }
51 }
52 EnterCriticalSection (&mutex->lock);
53 return 0;
54}
55
56int
57glwthread_mutex_trylock (glwthread_mutex_t *mutex)
58{
59 if (!mutex->guard.done)
60 {
61 if (InterlockedIncrement (&mutex->guard.started) == 0)
62 /* This thread is the first one to need this mutex. Initialize it. */
63 glwthread_mutex_init (mutex);
64 else
65 {
66 /* Don't let mutex->guard.started grow and wrap around. */
67 InterlockedDecrement (&mutex->guard.started);
68 /* Let another thread finish initializing this mutex, and let it also
69 lock this mutex. */
70 return EBUSY;
71 }
72 }
73 if (!TryEnterCriticalSection (&mutex->lock))
74 return EBUSY;
75 return 0;
76}
77
78int
79glwthread_mutex_unlock (glwthread_mutex_t *mutex)
80{
81 if (!mutex->guard.done)
82 return EINVAL;
83 LeaveCriticalSection (&mutex->lock);
84 return 0;
85}
86
87int
88glwthread_mutex_destroy (glwthread_mutex_t *mutex)
89{
90 if (!mutex->guard.done)
91 return EINVAL;
92 DeleteCriticalSection (&mutex->lock);
93 mutex->guard.done = 0;
94 return 0;
95}
diff --git a/gl/windows-mutex.h b/gl/windows-mutex.h
new file mode 100644
index 00000000..039eb707
--- /dev/null
+++ b/gl/windows-mutex.h
@@ -0,0 +1,51 @@
1/* Plain mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_MUTEX_H
21#define _WINDOWS_MUTEX_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26#include "windows-initguard.h"
27
28typedef struct
29 {
30 glwthread_initguard_t guard; /* protects the initialization */
31 CRITICAL_SECTION lock;
32 }
33 glwthread_mutex_t;
34
35#define GLWTHREAD_MUTEX_INIT { GLWTHREAD_INITGUARD_INIT }
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41extern void glwthread_mutex_init (glwthread_mutex_t *mutex);
42extern int glwthread_mutex_lock (glwthread_mutex_t *mutex);
43extern int glwthread_mutex_trylock (glwthread_mutex_t *mutex);
44extern int glwthread_mutex_unlock (glwthread_mutex_t *mutex);
45extern int glwthread_mutex_destroy (glwthread_mutex_t *mutex);
46
47#ifdef __cplusplus
48}
49#endif
50
51#endif /* _WINDOWS_MUTEX_H */
diff --git a/gl/windows-once.c b/gl/windows-once.c
new file mode 100644
index 00000000..0d28281f
--- /dev/null
+++ b/gl/windows-once.c
@@ -0,0 +1,62 @@
1/* Once-only control (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-once.h"
24
25#include <stdlib.h>
26
27void
28glwthread_once (glwthread_once_t *once_control, void (*initfunction) (void))
29{
30 if (once_control->inited <= 0)
31 {
32 if (InterlockedIncrement (&once_control->started) == 0)
33 {
34 /* This thread is the first one to come to this once_control. */
35 InitializeCriticalSection (&once_control->lock);
36 EnterCriticalSection (&once_control->lock);
37 once_control->inited = 0;
38 initfunction ();
39 once_control->inited = 1;
40 LeaveCriticalSection (&once_control->lock);
41 }
42 else
43 {
44 /* Don't let once_control->started grow and wrap around. */
45 InterlockedDecrement (&once_control->started);
46 /* Some other thread has already started the initialization.
47 Yield the CPU while waiting for the other thread to finish
48 initializing and taking the lock. */
49 while (once_control->inited < 0)
50 Sleep (0);
51 if (once_control->inited <= 0)
52 {
53 /* Take the lock. This blocks until the other thread has
54 finished calling the initfunction. */
55 EnterCriticalSection (&once_control->lock);
56 LeaveCriticalSection (&once_control->lock);
57 if (!(once_control->inited > 0))
58 abort ();
59 }
60 }
61 }
62}
diff --git a/gl/windows-once.h b/gl/windows-once.h
new file mode 100644
index 00000000..54885680
--- /dev/null
+++ b/gl/windows-once.h
@@ -0,0 +1,47 @@
1/* Once-only control (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_ONCE_H
21#define _WINDOWS_ONCE_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26typedef struct
27 {
28 volatile int inited;
29 volatile LONG started;
30 CRITICAL_SECTION lock;
31 }
32 glwthread_once_t;
33
34#define GLWTHREAD_ONCE_INIT { -1, -1 }
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40extern void glwthread_once (glwthread_once_t *once_control,
41 void (*initfunction) (void));
42
43#ifdef __cplusplus
44}
45#endif
46
47#endif /* _WINDOWS_ONCE_H */
diff --git a/gl/windows-recmutex.c b/gl/windows-recmutex.c
new file mode 100644
index 00000000..a8ce9a04
--- /dev/null
+++ b/gl/windows-recmutex.c
@@ -0,0 +1,127 @@
1/* Plain recursive mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-recmutex.h"
24
25#include <errno.h>
26
27void
28glwthread_recmutex_init (glwthread_recmutex_t *mutex)
29{
30 mutex->owner = 0;
31 mutex->depth = 0;
32 InitializeCriticalSection (&mutex->lock);
33 mutex->guard.done = 1;
34}
35
36int
37glwthread_recmutex_lock (glwthread_recmutex_t *mutex)
38{
39 if (!mutex->guard.done)
40 {
41 if (InterlockedIncrement (&mutex->guard.started) == 0)
42 /* This thread is the first one to need this mutex. Initialize it. */
43 glwthread_recmutex_init (mutex);
44 else
45 {
46 /* Don't let mutex->guard.started grow and wrap around. */
47 InterlockedDecrement (&mutex->guard.started);
48 /* Yield the CPU while waiting for another thread to finish
49 initializing this mutex. */
50 while (!mutex->guard.done)
51 Sleep (0);
52 }
53 }
54 {
55 DWORD self = GetCurrentThreadId ();
56 if (mutex->owner != self)
57 {
58 EnterCriticalSection (&mutex->lock);
59 mutex->owner = self;
60 }
61 if (++(mutex->depth) == 0) /* wraparound? */
62 {
63 mutex->depth--;
64 return EAGAIN;
65 }
66 }
67 return 0;
68}
69
70int
71glwthread_recmutex_trylock (glwthread_recmutex_t *mutex)
72{
73 if (!mutex->guard.done)
74 {
75 if (InterlockedIncrement (&mutex->guard.started) == 0)
76 /* This thread is the first one to need this mutex. Initialize it. */
77 glwthread_recmutex_init (mutex);
78 else
79 {
80 /* Don't let mutex->guard.started grow and wrap around. */
81 InterlockedDecrement (&mutex->guard.started);
82 /* Let another thread finish initializing this mutex, and let it also
83 lock this mutex. */
84 return EBUSY;
85 }
86 }
87 {
88 DWORD self = GetCurrentThreadId ();
89 if (mutex->owner != self)
90 {
91 if (!TryEnterCriticalSection (&mutex->lock))
92 return EBUSY;
93 mutex->owner = self;
94 }
95 if (++(mutex->depth) == 0) /* wraparound? */
96 {
97 mutex->depth--;
98 return EAGAIN;
99 }
100 }
101 return 0;
102}
103
104int
105glwthread_recmutex_unlock (glwthread_recmutex_t *mutex)
106{
107 if (mutex->owner != GetCurrentThreadId ())
108 return EPERM;
109 if (mutex->depth == 0)
110 return EINVAL;
111 if (--(mutex->depth) == 0)
112 {
113 mutex->owner = 0;
114 LeaveCriticalSection (&mutex->lock);
115 }
116 return 0;
117}
118
119int
120glwthread_recmutex_destroy (glwthread_recmutex_t *mutex)
121{
122 if (mutex->owner != 0)
123 return EBUSY;
124 DeleteCriticalSection (&mutex->lock);
125 mutex->guard.done = 0;
126 return 0;
127}
diff --git a/gl/windows-recmutex.h b/gl/windows-recmutex.h
new file mode 100644
index 00000000..08ff4597
--- /dev/null
+++ b/gl/windows-recmutex.h
@@ -0,0 +1,57 @@
1/* Plain recursive mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_RECMUTEX_H
21#define _WINDOWS_RECMUTEX_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26#include "windows-initguard.h"
27
28/* The native Windows documentation says that CRITICAL_SECTION already
29 implements a recursive lock. But we need not rely on it: It's easy to
30 implement a recursive lock without this assumption. */
31
32typedef struct
33 {
34 glwthread_initguard_t guard; /* protects the initialization */
35 DWORD owner;
36 unsigned long depth;
37 CRITICAL_SECTION lock;
38 }
39 glwthread_recmutex_t;
40
41#define GLWTHREAD_RECMUTEX_INIT { GLWTHREAD_INITGUARD_INIT, 0, 0 }
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47extern void glwthread_recmutex_init (glwthread_recmutex_t *mutex);
48extern int glwthread_recmutex_lock (glwthread_recmutex_t *mutex);
49extern int glwthread_recmutex_trylock (glwthread_recmutex_t *mutex);
50extern int glwthread_recmutex_unlock (glwthread_recmutex_t *mutex);
51extern int glwthread_recmutex_destroy (glwthread_recmutex_t *mutex);
52
53#ifdef __cplusplus
54}
55#endif
56
57#endif /* _WINDOWS_RECMUTEX_H */
diff --git a/gl/windows-rwlock.c b/gl/windows-rwlock.c
new file mode 100644
index 00000000..7cbd7bb1
--- /dev/null
+++ b/gl/windows-rwlock.c
@@ -0,0 +1,377 @@
1/* Read-write locks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-rwlock.h"
24
25#include <errno.h>
26#include <stdlib.h>
27
28/* Don't assume that UNICODE is not defined. */
29#undef CreateEvent
30#define CreateEvent CreateEventA
31
32/* In this file, the waitqueues are implemented as circular arrays. */
33#define glwthread_waitqueue_t glwthread_carray_waitqueue_t
34
35static void
36glwthread_waitqueue_init (glwthread_waitqueue_t *wq)
37{
38 wq->array = NULL;
39 wq->count = 0;
40 wq->alloc = 0;
41 wq->offset = 0;
42}
43
44/* Enqueues the current thread, represented by an event, in a wait queue.
45 Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
46static HANDLE
47glwthread_waitqueue_add (glwthread_waitqueue_t *wq)
48{
49 HANDLE event;
50 unsigned int index;
51
52 if (wq->count == wq->alloc)
53 {
54 unsigned int new_alloc = 2 * wq->alloc + 1;
55 HANDLE *new_array =
56 (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
57 if (new_array == NULL)
58 /* No more memory. */
59 return INVALID_HANDLE_VALUE;
60 /* Now is a good opportunity to rotate the array so that its contents
61 starts at offset 0. */
62 if (wq->offset > 0)
63 {
64 unsigned int old_count = wq->count;
65 unsigned int old_alloc = wq->alloc;
66 unsigned int old_offset = wq->offset;
67 unsigned int i;
68 if (old_offset + old_count > old_alloc)
69 {
70 unsigned int limit = old_offset + old_count - old_alloc;
71 for (i = 0; i < limit; i++)
72 new_array[old_alloc + i] = new_array[i];
73 }
74 for (i = 0; i < old_count; i++)
75 new_array[i] = new_array[old_offset + i];
76 wq->offset = 0;
77 }
78 wq->array = new_array;
79 wq->alloc = new_alloc;
80 }
81 /* Whether the created event is a manual-reset one or an auto-reset one,
82 does not matter, since we will wait on it only once. */
83 event = CreateEvent (NULL, TRUE, FALSE, NULL);
84 if (event == INVALID_HANDLE_VALUE)
85 /* No way to allocate an event. */
86 return INVALID_HANDLE_VALUE;
87 index = wq->offset + wq->count;
88 if (index >= wq->alloc)
89 index -= wq->alloc;
90 wq->array[index] = event;
91 wq->count++;
92 return event;
93}
94
95/* Notifies the first thread from a wait queue and dequeues it. */
96static void
97glwthread_waitqueue_notify_first (glwthread_waitqueue_t *wq)
98{
99 SetEvent (wq->array[wq->offset + 0]);
100 wq->offset++;
101 wq->count--;
102 if (wq->count == 0 || wq->offset == wq->alloc)
103 wq->offset = 0;
104}
105
106/* Notifies all threads from a wait queue and dequeues them all. */
107static void
108glwthread_waitqueue_notify_all (glwthread_waitqueue_t *wq)
109{
110 unsigned int i;
111
112 for (i = 0; i < wq->count; i++)
113 {
114 unsigned int index = wq->offset + i;
115 if (index >= wq->alloc)
116 index -= wq->alloc;
117 SetEvent (wq->array[index]);
118 }
119 wq->count = 0;
120 wq->offset = 0;
121}
122
123void
124glwthread_rwlock_init (glwthread_rwlock_t *lock)
125{
126 InitializeCriticalSection (&lock->lock);
127 glwthread_waitqueue_init (&lock->waiting_readers);
128 glwthread_waitqueue_init (&lock->waiting_writers);
129 lock->runcount = 0;
130 lock->guard.done = 1;
131}
132
133int
134glwthread_rwlock_rdlock (glwthread_rwlock_t *lock)
135{
136 if (!lock->guard.done)
137 {
138 if (InterlockedIncrement (&lock->guard.started) == 0)
139 /* This thread is the first one to need this lock. Initialize it. */
140 glwthread_rwlock_init (lock);
141 else
142 {
143 /* Don't let lock->guard.started grow and wrap around. */
144 InterlockedDecrement (&lock->guard.started);
145 /* Yield the CPU while waiting for another thread to finish
146 initializing this lock. */
147 while (!lock->guard.done)
148 Sleep (0);
149 }
150 }
151 EnterCriticalSection (&lock->lock);
152 /* Test whether only readers are currently running, and whether the runcount
153 field will not overflow, and whether no writer is waiting. The latter
154 condition is because POSIX recommends that "write locks shall take
155 precedence over read locks", to avoid "writer starvation". */
156 if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0))
157 {
158 /* This thread has to wait for a while. Enqueue it among the
159 waiting_readers. */
160 HANDLE event = glwthread_waitqueue_add (&lock->waiting_readers);
161 if (event != INVALID_HANDLE_VALUE)
162 {
163 DWORD result;
164 LeaveCriticalSection (&lock->lock);
165 /* Wait until another thread signals this event. */
166 result = WaitForSingleObject (event, INFINITE);
167 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
168 abort ();
169 CloseHandle (event);
170 /* The thread which signalled the event already did the bookkeeping:
171 removed us from the waiting_readers, incremented lock->runcount. */
172 if (!(lock->runcount > 0))
173 abort ();
174 return 0;
175 }
176 else
177 {
178 /* Allocation failure. Weird. */
179 do
180 {
181 LeaveCriticalSection (&lock->lock);
182 Sleep (1);
183 EnterCriticalSection (&lock->lock);
184 }
185 while (!(lock->runcount + 1 > 0));
186 }
187 }
188 lock->runcount++;
189 LeaveCriticalSection (&lock->lock);
190 return 0;
191}
192
193int
194glwthread_rwlock_wrlock (glwthread_rwlock_t *lock)
195{
196 if (!lock->guard.done)
197 {
198 if (InterlockedIncrement (&lock->guard.started) == 0)
199 /* This thread is the first one to need this lock. Initialize it. */
200 glwthread_rwlock_init (lock);
201 else
202 {
203 /* Don't let lock->guard.started grow and wrap around. */
204 InterlockedDecrement (&lock->guard.started);
205 /* Yield the CPU while waiting for another thread to finish
206 initializing this lock. */
207 while (!lock->guard.done)
208 Sleep (0);
209 }
210 }
211 EnterCriticalSection (&lock->lock);
212 /* Test whether no readers or writers are currently running. */
213 if (!(lock->runcount == 0))
214 {
215 /* This thread has to wait for a while. Enqueue it among the
216 waiting_writers. */
217 HANDLE event = glwthread_waitqueue_add (&lock->waiting_writers);
218 if (event != INVALID_HANDLE_VALUE)
219 {
220 DWORD result;
221 LeaveCriticalSection (&lock->lock);
222 /* Wait until another thread signals this event. */
223 result = WaitForSingleObject (event, INFINITE);
224 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
225 abort ();
226 CloseHandle (event);
227 /* The thread which signalled the event already did the bookkeeping:
228 removed us from the waiting_writers, set lock->runcount = -1. */
229 if (!(lock->runcount == -1))
230 abort ();
231 return 0;
232 }
233 else
234 {
235 /* Allocation failure. Weird. */
236 do
237 {
238 LeaveCriticalSection (&lock->lock);
239 Sleep (1);
240 EnterCriticalSection (&lock->lock);
241 }
242 while (!(lock->runcount == 0));
243 }
244 }
245 lock->runcount--; /* runcount becomes -1 */
246 LeaveCriticalSection (&lock->lock);
247 return 0;
248}
249
250int
251glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock)
252{
253 if (!lock->guard.done)
254 {
255 if (InterlockedIncrement (&lock->guard.started) == 0)
256 /* This thread is the first one to need this lock. Initialize it. */
257 glwthread_rwlock_init (lock);
258 else
259 {
260 /* Don't let lock->guard.started grow and wrap around. */
261 InterlockedDecrement (&lock->guard.started);
262 /* Yield the CPU while waiting for another thread to finish
263 initializing this lock. */
264 while (!lock->guard.done)
265 Sleep (0);
266 }
267 }
268 /* It's OK to wait for this critical section, because it is never taken for a
269 long time. */
270 EnterCriticalSection (&lock->lock);
271 /* Test whether only readers are currently running, and whether the runcount
272 field will not overflow, and whether no writer is waiting. The latter
273 condition is because POSIX recommends that "write locks shall take
274 precedence over read locks", to avoid "writer starvation". */
275 if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0))
276 {
277 /* This thread would have to wait for a while. Return instead. */
278 LeaveCriticalSection (&lock->lock);
279 return EBUSY;
280 }
281 lock->runcount++;
282 LeaveCriticalSection (&lock->lock);
283 return 0;
284}
285
286int
287glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock)
288{
289 if (!lock->guard.done)
290 {
291 if (InterlockedIncrement (&lock->guard.started) == 0)
292 /* This thread is the first one to need this lock. Initialize it. */
293 glwthread_rwlock_init (lock);
294 else
295 {
296 /* Don't let lock->guard.started grow and wrap around. */
297 InterlockedDecrement (&lock->guard.started);
298 /* Yield the CPU while waiting for another thread to finish
299 initializing this lock. */
300 while (!lock->guard.done)
301 Sleep (0);
302 }
303 }
304 /* It's OK to wait for this critical section, because it is never taken for a
305 long time. */
306 EnterCriticalSection (&lock->lock);
307 /* Test whether no readers or writers are currently running. */
308 if (!(lock->runcount == 0))
309 {
310 /* This thread would have to wait for a while. Return instead. */
311 LeaveCriticalSection (&lock->lock);
312 return EBUSY;
313 }
314 lock->runcount--; /* runcount becomes -1 */
315 LeaveCriticalSection (&lock->lock);
316 return 0;
317}
318
319int
320glwthread_rwlock_unlock (glwthread_rwlock_t *lock)
321{
322 if (!lock->guard.done)
323 return EINVAL;
324 EnterCriticalSection (&lock->lock);
325 if (lock->runcount < 0)
326 {
327 /* Drop a writer lock. */
328 if (!(lock->runcount == -1))
329 abort ();
330 lock->runcount = 0;
331 }
332 else
333 {
334 /* Drop a reader lock. */
335 if (!(lock->runcount > 0))
336 {
337 LeaveCriticalSection (&lock->lock);
338 return EPERM;
339 }
340 lock->runcount--;
341 }
342 if (lock->runcount == 0)
343 {
344 /* POSIX recommends that "write locks shall take precedence over read
345 locks", to avoid "writer starvation". */
346 if (lock->waiting_writers.count > 0)
347 {
348 /* Wake up one of the waiting writers. */
349 lock->runcount--;
350 glwthread_waitqueue_notify_first (&lock->waiting_writers);
351 }
352 else
353 {
354 /* Wake up all waiting readers. */
355 lock->runcount += lock->waiting_readers.count;
356 glwthread_waitqueue_notify_all (&lock->waiting_readers);
357 }
358 }
359 LeaveCriticalSection (&lock->lock);
360 return 0;
361}
362
363int
364glwthread_rwlock_destroy (glwthread_rwlock_t *lock)
365{
366 if (!lock->guard.done)
367 return EINVAL;
368 if (lock->runcount != 0)
369 return EBUSY;
370 DeleteCriticalSection (&lock->lock);
371 if (lock->waiting_readers.array != NULL)
372 free (lock->waiting_readers.array);
373 if (lock->waiting_writers.array != NULL)
374 free (lock->waiting_writers.array);
375 lock->guard.done = 0;
376 return 0;
377}
diff --git a/gl/windows-rwlock.h b/gl/windows-rwlock.h
new file mode 100644
index 00000000..fe8381e8
--- /dev/null
+++ b/gl/windows-rwlock.h
@@ -0,0 +1,68 @@
1/* Read-write locks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_RWLOCK_H
21#define _WINDOWS_RWLOCK_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26#include "windows-initguard.h"
27
28/* It is impossible to implement read-write locks using plain locks, without
29 introducing an extra thread dedicated to managing read-write locks.
30 Therefore here we need to use the low-level Event type. */
31
32typedef struct
33 {
34 HANDLE *array; /* array of waiting threads, each represented by an event */
35 unsigned int count; /* number of waiting threads */
36 unsigned int alloc; /* length of allocated array */
37 unsigned int offset; /* index of first waiting thread in array */
38 }
39 glwthread_carray_waitqueue_t;
40typedef struct
41 {
42 glwthread_initguard_t guard; /* protects the initialization */
43 CRITICAL_SECTION lock; /* protects the remaining fields */
44 glwthread_carray_waitqueue_t waiting_readers; /* waiting readers */
45 glwthread_carray_waitqueue_t waiting_writers; /* waiting writers */
46 int runcount; /* number of readers running, or -1 when a writer runs */
47 }
48 glwthread_rwlock_t;
49
50#define GLWTHREAD_RWLOCK_INIT { GLWTHREAD_INITGUARD_INIT }
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56extern void glwthread_rwlock_init (glwthread_rwlock_t *lock);
57extern int glwthread_rwlock_rdlock (glwthread_rwlock_t *lock);
58extern int glwthread_rwlock_wrlock (glwthread_rwlock_t *lock);
59extern int glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock);
60extern int glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock);
61extern int glwthread_rwlock_unlock (glwthread_rwlock_t *lock);
62extern int glwthread_rwlock_destroy (glwthread_rwlock_t *lock);
63
64#ifdef __cplusplus
65}
66#endif
67
68#endif /* _WINDOWS_RWLOCK_H */
diff --git a/gl/xalloc-die.c b/gl/xalloc-die.c
index daa403b9..7605eee1 100644
--- a/gl/xalloc-die.c
+++ b/gl/xalloc-die.c
@@ -1,11 +1,11 @@
1/* Report a memory allocation failure and exit. 1/* Report a memory allocation failure and exit.
2 2
3 Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2013 Free Software 3 Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/xalloc-oversized.h b/gl/xalloc-oversized.h
index a971c78a..5dbdfb55 100644
--- a/gl/xalloc-oversized.h
+++ b/gl/xalloc-oversized.h
@@ -1,38 +1,65 @@
1/* xalloc-oversized.h -- memory allocation size checking 1/* xalloc-oversized.h -- memory allocation size checking
2 2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef XALLOC_OVERSIZED_H_ 18#ifndef XALLOC_OVERSIZED_H_
19# define XALLOC_OVERSIZED_H_ 19#define XALLOC_OVERSIZED_H_
20 20
21# include <stddef.h> 21#include <stddef.h>
22 22#include <stdint.h>
23/* Return 1 if an array of N objects, each of size S, cannot exist due 23
24 to size arithmetic overflow. S must be positive and N must be 24/* True if N * S does not fit into both ptrdiff_t and size_t.
25 nonnegative. This is a macro, not a function, so that it 25 N and S should be nonnegative and free of side effects.
26 works correctly even when SIZE_MAX < N. 26 This expands to a constant expression if N and S are both constants.
27 27 By gnulib convention, SIZE_MAX represents overflow in size_t
28 By gnulib convention, SIZE_MAX represents overflow in size 28 calculations, so the conservative size_t-based dividend to use here
29 calculations, so the conservative dividend to use here is 29 is SIZE_MAX - 1. */
30 SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. 30#define __xalloc_oversized(n, s) \
31 However, malloc (SIZE_MAX) fails on all known hosts where 31 ((s) != 0 \
32 sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for 32 && ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) \
33 exactly-SIZE_MAX allocations on such hosts; this avoids a test and 33 < (n)))
34 branch when S is known to be 1. */ 34
35/* Return 1 if and only if an array of N objects, each of size S,
36 cannot exist reliably because its total size in bytes would exceed
37 MIN (PTRDIFF_MAX, SIZE_MAX - 1).
38
39 N and S should be nonnegative and free of side effects.
40
41 Warning: (xalloc_oversized (N, S) ? NULL : malloc (N * S)) can
42 misbehave if N and S are both narrower than ptrdiff_t and size_t,
43 and can be rewritten as (xalloc_oversized (N, S) ? NULL
44 : malloc (N * (size_t) S)).
45
46 This is a macro, not a function, so that it works even if an
47 argument exceeds MAX (PTRDIFF_MAX, SIZE_MAX). */
48#if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX
35# define xalloc_oversized(n, s) \ 49# define xalloc_oversized(n, s) \
36 ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) 50 __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1)
51#elif (5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ \
52 && PTRDIFF_MAX < SIZE_MAX)
53# define xalloc_oversized(n, s) \
54 (__builtin_constant_p (n) && __builtin_constant_p (s) \
55 ? __xalloc_oversized (n, s) \
56 : ({ ptrdiff_t __xalloc_count; \
57 __builtin_mul_overflow (n, s, &__xalloc_count); }))
58
59/* Other compilers use integer division; this may be slower but is
60 more portable. */
61#else
62# define xalloc_oversized(n, s) __xalloc_oversized (n, s)
63#endif
37 64
38#endif /* !XALLOC_OVERSIZED_H_ */ 65#endif /* !XALLOC_OVERSIZED_H_ */
diff --git a/gl/xalloc.h b/gl/xalloc.h
index da7c4b6b..f373c2fe 100644
--- a/gl/xalloc.h
+++ b/gl/xalloc.h
@@ -1,10 +1,10 @@
1/* xalloc.h -- malloc with out-of-memory checking 1/* xalloc.h -- malloc with out-of-memory checking
2 2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
@@ -13,57 +13,92 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef XALLOC_H_ 18#ifndef XALLOC_H_
19#define XALLOC_H_ 19#define XALLOC_H_
20 20
21#include <stddef.h> 21#include <stddef.h>
22#include <stdlib.h>
22 23
23#include "xalloc-oversized.h" 24#if GNULIB_XALLOC
25# include "idx.h"
26#endif
24 27
28#ifndef _GL_INLINE_HEADER_BEGIN
29 #error "Please include config.h first."
30#endif
25_GL_INLINE_HEADER_BEGIN 31_GL_INLINE_HEADER_BEGIN
26#ifndef XALLOC_INLINE 32#ifndef XALLOC_INLINE
27# define XALLOC_INLINE _GL_INLINE 33# define XALLOC_INLINE _GL_INLINE
28#endif 34#endif
29 35
36
30#ifdef __cplusplus 37#ifdef __cplusplus
31extern "C" { 38extern "C" {
32#endif 39#endif
33 40
34 41
35#if __GNUC__ >= 3 42#if GNULIB_XALLOC_DIE
36# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
37#else
38# define _GL_ATTRIBUTE_MALLOC
39#endif
40
41#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
42# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
43#else
44# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
45#endif
46 43
47/* This function is always triggered when memory is exhausted. 44/* This function is always triggered when memory is exhausted.
48 It must be defined by the application, either explicitly 45 It must be defined by the application, either explicitly
49 or by using gnulib's xalloc-die module. This is the 46 or by using gnulib's xalloc-die module. This is the
50 function to call when one wants the program to die because of a 47 function to call when one wants the program to die because of a
51 memory allocation failure. */ 48 memory allocation failure. */
52extern _Noreturn void xalloc_die (void); 49/*extern*/ _Noreturn void xalloc_die (void);
50
51#endif /* GNULIB_XALLOC_DIE */
52
53#if GNULIB_XALLOC
53 54
54void *xmalloc (size_t s) 55void *xmalloc (size_t s)
55 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); 56 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
57 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
58void *ximalloc (idx_t s)
59 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
60 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
61void *xinmalloc (idx_t n, idx_t s)
62 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
63 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
56void *xzalloc (size_t s) 64void *xzalloc (size_t s)
57 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); 65 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
66 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
67void *xizalloc (idx_t s)
68 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
69 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
58void *xcalloc (size_t n, size_t s) 70void *xcalloc (size_t n, size_t s)
59 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); 71 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
72 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
73void *xicalloc (idx_t n, idx_t s)
74 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
75 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
60void *xrealloc (void *p, size_t s) 76void *xrealloc (void *p, size_t s)
61 _GL_ATTRIBUTE_ALLOC_SIZE ((2)); 77 _GL_ATTRIBUTE_ALLOC_SIZE ((2));
62void *x2realloc (void *p, size_t *pn); 78void *xirealloc (void *p, idx_t s)
79 _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
80void *xreallocarray (void *p, size_t n, size_t s)
81 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
82void *xireallocarray (void *p, idx_t n, idx_t s)
83 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)) _GL_ATTRIBUTE_RETURNS_NONNULL;
84void *x2realloc (void *p, size_t *ps) /* superseded by xpalloc */
85 _GL_ATTRIBUTE_RETURNS_NONNULL;
86void *x2nrealloc (void *p, size_t *pn, size_t s) /* superseded by xpalloc */
87 _GL_ATTRIBUTE_RETURNS_NONNULL;
88void *xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
89 _GL_ATTRIBUTE_RETURNS_NONNULL;
63void *xmemdup (void const *p, size_t s) 90void *xmemdup (void const *p, size_t s)
64 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2)); 91 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
92 _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
93void *ximemdup (void const *p, idx_t s)
94 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
95 _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
96char *ximemdup0 (void const *p, idx_t s)
97 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
98 _GL_ATTRIBUTE_RETURNS_NONNULL;
65char *xstrdup (char const *str) 99char *xstrdup (char const *str)
66 _GL_ATTRIBUTE_MALLOC; 100 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
101 _GL_ATTRIBUTE_RETURNS_NONNULL;
67 102
68/* In the following macros, T must be an elementary or structure/union or 103/* In the following macros, T must be an elementary or structure/union or
69 typedef'ed type, or a pointer to such a type. To apply one of the 104 typedef'ed type, or a pointer to such a type. To apply one of the
@@ -72,153 +107,60 @@ char *xstrdup (char const *str)
72 107
73/* Allocate an object of type T dynamically, with error checking. */ 108/* Allocate an object of type T dynamically, with error checking. */
74/* extern t *XMALLOC (typename t); */ 109/* extern t *XMALLOC (typename t); */
75#define XMALLOC(t) ((t *) xmalloc (sizeof (t))) 110# define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
76 111
77/* Allocate memory for N elements of type T, with error checking. */ 112/* Allocate memory for N elements of type T, with error checking. */
78/* extern t *XNMALLOC (size_t n, typename t); */ 113/* extern t *XNMALLOC (size_t n, typename t); */
79#define XNMALLOC(n, t) \ 114# define XNMALLOC(n, t) \
80 ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t)))) 115 ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
81 116
82/* Allocate an object of type T dynamically, with error checking, 117/* Allocate an object of type T dynamically, with error checking,
83 and zero it. */ 118 and zero it. */
84/* extern t *XZALLOC (typename t); */ 119/* extern t *XZALLOC (typename t); */
85#define XZALLOC(t) ((t *) xzalloc (sizeof (t))) 120# define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
86 121
87/* Allocate memory for N elements of type T, with error checking, 122/* Allocate memory for N elements of type T, with error checking,
88 and zero it. */ 123 and zero it. */
89/* extern t *XCALLOC (size_t n, typename t); */ 124/* extern t *XCALLOC (size_t n, typename t); */
90#define XCALLOC(n, t) \ 125# define XCALLOC(n, t) \
91 ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t)))) 126 ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
92 127
93 128
94/* Allocate an array of N objects, each with S bytes of memory, 129/* Allocate an array of N objects, each with S bytes of memory,
95 dynamically, with error checking. S must be nonzero. */ 130 dynamically, with error checking. S must be nonzero. */
96 131
97XALLOC_INLINE void *xnmalloc (size_t n, size_t s) 132void *xnmalloc (size_t n, size_t s)
98 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); 133 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
99XALLOC_INLINE void * 134 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
100xnmalloc (size_t n, size_t s)
101{
102 if (xalloc_oversized (n, s))
103 xalloc_die ();
104 return xmalloc (n * s);
105}
106 135
136/* FIXME: Deprecate this in favor of xreallocarray? */
107/* Change the size of an allocated block of memory P to an array of N 137/* Change the size of an allocated block of memory P to an array of N
108 objects each of S bytes, with error checking. S must be nonzero. */ 138 objects each of S bytes, with error checking. S must be nonzero. */
109 139
110XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s) 140XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s)
111 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); 141 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
112XALLOC_INLINE void * 142XALLOC_INLINE void *
113xnrealloc (void *p, size_t n, size_t s) 143xnrealloc (void *p, size_t n, size_t s)
114{ 144{
115 if (xalloc_oversized (n, s)) 145 return xreallocarray (p, n, s);
116 xalloc_die ();
117 return xrealloc (p, n * s);
118}
119
120/* If P is null, allocate a block of at least *PN such objects;
121 otherwise, reallocate P so that it contains more than *PN objects
122 each of S bytes. *PN must be nonzero unless P is null, and S must
123 be nonzero. Set *PN to the new number of objects, and return the
124 pointer to the new block. *PN is never set to zero, and the
125 returned pointer is never null.
126
127 Repeated reallocations are guaranteed to make progress, either by
128 allocating an initial block with a nonzero size, or by allocating a
129 larger block.
130
131 In the following implementation, nonzero sizes are increased by a
132 factor of approximately 1.5 so that repeated reallocations have
133 O(N) overall cost rather than O(N**2) cost, but the
134 specification for this function does not guarantee that rate.
135
136 Here is an example of use:
137
138 int *p = NULL;
139 size_t used = 0;
140 size_t allocated = 0;
141
142 void
143 append_int (int value)
144 {
145 if (used == allocated)
146 p = x2nrealloc (p, &allocated, sizeof *p);
147 p[used++] = value;
148 }
149
150 This causes x2nrealloc to allocate a block of some nonzero size the
151 first time it is called.
152
153 To have finer-grained control over the initial size, set *PN to a
154 nonzero value before calling this function with P == NULL. For
155 example:
156
157 int *p = NULL;
158 size_t used = 0;
159 size_t allocated = 0;
160 size_t allocated1 = 1000;
161
162 void
163 append_int (int value)
164 {
165 if (used == allocated)
166 {
167 p = x2nrealloc (p, &allocated1, sizeof *p);
168 allocated = allocated1;
169 }
170 p[used++] = value;
171 }
172
173 */
174
175XALLOC_INLINE void *
176x2nrealloc (void *p, size_t *pn, size_t s)
177{
178 size_t n = *pn;
179
180 if (! p)
181 {
182 if (! n)
183 {
184 /* The approximate size to use for initial small allocation
185 requests, when the invoking code specifies an old size of
186 zero. This is the largest "small" request for the GNU C
187 library malloc. */
188 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
189
190 n = DEFAULT_MXFAST / s;
191 n += !n;
192 }
193 }
194 else
195 {
196 /* Set N = ceil (1.5 * N) so that progress is made if N == 1.
197 Check for overflow, so that N * S stays in size_t range.
198 The check is slightly conservative, but an exact check isn't
199 worth the trouble. */
200 if ((size_t) -1 / 3 * 2 / s <= n)
201 xalloc_die ();
202 n += (n + 1) / 2;
203 }
204
205 *pn = n;
206 return xrealloc (p, n * s);
207} 146}
208 147
209/* Return a pointer to a new buffer of N bytes. This is like xmalloc, 148/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
210 except it returns char *. */ 149 except it returns char *. */
211 150
212XALLOC_INLINE char *xcharalloc (size_t n) 151char *xcharalloc (size_t n)
213 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); 152 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
214XALLOC_INLINE char * 153 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
215xcharalloc (size_t n) 154
216{ 155#endif /* GNULIB_XALLOC */
217 return XNMALLOC (n, char); 156
218}
219 157
220#ifdef __cplusplus 158#ifdef __cplusplus
221} 159}
160#endif
161
162
163#if GNULIB_XALLOC && defined __cplusplus
222 164
223/* C++ does not allow conversions from void * to other pointer types 165/* C++ does not allow conversions from void * to other pointer types
224 without a cast. Use templates to work around the problem when 166 without a cast. Use templates to work around the problem when
@@ -231,9 +173,16 @@ xrealloc (T *p, size_t s)
231} 173}
232 174
233template <typename T> inline T * 175template <typename T> inline T *
176xreallocarray (T *p, size_t n, size_t s)
177{
178 return (T *) xreallocarray ((void *) p, n, s);
179}
180
181/* FIXME: Deprecate this in favor of xreallocarray? */
182template <typename T> inline T *
234xnrealloc (T *p, size_t n, size_t s) 183xnrealloc (T *p, size_t n, size_t s)
235{ 184{
236 return (T *) xnrealloc ((void *) p, n, s); 185 return xreallocarray (p, n, s);
237} 186}
238 187
239template <typename T> inline T * 188template <typename T> inline T *
@@ -254,7 +203,9 @@ xmemdup (T const *p, size_t s)
254 return (T *) xmemdup ((void const *) p, s); 203 return (T *) xmemdup ((void const *) p, s);
255} 204}
256 205
257#endif 206#endif /* GNULIB_XALLOC && C++ */
207
258 208
209_GL_INLINE_HEADER_END
259 210
260#endif /* !XALLOC_H_ */ 211#endif /* !XALLOC_H_ */
diff --git a/gl/xmalloc.c b/gl/xmalloc.c
index 57e34b7c..289cbd05 100644
--- a/gl/xmalloc.c
+++ b/gl/xmalloc.c
@@ -1,10 +1,10 @@
1/* xmalloc.c -- malloc with out of memory checking 1/* xmalloc.c -- malloc with out of memory checking
2 2
3 Copyright (C) 1990-2000, 2002-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2002-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -21,59 +21,256 @@
21 21
22#include "xalloc.h" 22#include "xalloc.h"
23 23
24#include "ialloc.h"
25#include "minmax.h"
26
27#include <stdckdint.h>
24#include <stdlib.h> 28#include <stdlib.h>
29#include <stdint.h>
25#include <string.h> 30#include <string.h>
26 31
27/* 1 if calloc is known to be compatible with GNU calloc. This 32static void * _GL_ATTRIBUTE_PURE
28 matters if we are not also using the calloc module, which defines 33nonnull (void *p)
29 HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */ 34{
30#if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) 35 if (!p)
31enum { HAVE_GNU_CALLOC = 1 }; 36 xalloc_die ();
32#else 37 return p;
33enum { HAVE_GNU_CALLOC = 0 }; 38}
34#endif
35 39
36/* Allocate N bytes of memory dynamically, with error checking. */ 40/* Allocate S bytes of memory dynamically, with error checking. */
37 41
38void * 42void *
39xmalloc (size_t n) 43xmalloc (size_t s)
40{ 44{
41 void *p = malloc (n); 45 return nonnull (malloc (s));
42 if (!p && n != 0) 46}
43 xalloc_die (); 47
44 return p; 48void *
49ximalloc (idx_t s)
50{
51 return nonnull (imalloc (s));
45} 52}
46 53
47/* Change the size of an allocated block of memory P to N bytes, 54char *
55xcharalloc (size_t n)
56{
57 return XNMALLOC (n, char);
58}
59
60/* Change the size of an allocated block of memory P to S bytes,
48 with error checking. */ 61 with error checking. */
49 62
50void * 63void *
51xrealloc (void *p, size_t n) 64xrealloc (void *p, size_t s)
65{
66 void *r = realloc (p, s);
67 if (!r && (!p || s))
68 xalloc_die ();
69 return r;
70}
71
72void *
73xirealloc (void *p, idx_t s)
74{
75 return nonnull (irealloc (p, s));
76}
77
78/* Change the size of an allocated block of memory P to an array of N
79 objects each of S bytes, with error checking. */
80
81void *
82xreallocarray (void *p, size_t n, size_t s)
83{
84 void *r = reallocarray (p, n, s);
85 if (!r && (!p || (n && s)))
86 xalloc_die ();
87 return r;
88}
89
90void *
91xireallocarray (void *p, idx_t n, idx_t s)
92{
93 return nonnull (ireallocarray (p, n, s));
94}
95
96/* Allocate an array of N objects, each with S bytes of memory,
97 dynamically, with error checking. S must be nonzero. */
98
99void *
100xnmalloc (size_t n, size_t s)
101{
102 return xreallocarray (NULL, n, s);
103}
104
105void *
106xinmalloc (idx_t n, idx_t s)
107{
108 return xireallocarray (NULL, n, s);
109}
110
111/* If P is null, allocate a block of at least *PS bytes; otherwise,
112 reallocate P so that it contains more than *PS bytes. *PS must be
113 nonzero unless P is null. Set *PS to the new block's size, and
114 return the pointer to the new block. *PS is never set to zero, and
115 the returned pointer is never null. */
116
117void *
118x2realloc (void *p, size_t *ps)
119{
120 return x2nrealloc (p, ps, 1);
121}
122
123/* If P is null, allocate a block of at least *PN such objects;
124 otherwise, reallocate P so that it contains more than *PN objects
125 each of S bytes. S must be nonzero. Set *PN to the new number of
126 objects, and return the pointer to the new block. *PN is never set
127 to zero, and the returned pointer is never null.
128
129 Repeated reallocations are guaranteed to make progress, either by
130 allocating an initial block with a nonzero size, or by allocating a
131 larger block.
132
133 In the following implementation, nonzero sizes are increased by a
134 factor of approximately 1.5 so that repeated reallocations have
135 O(N) overall cost rather than O(N**2) cost, but the
136 specification for this function does not guarantee that rate.
137
138 Here is an example of use:
139
140 int *p = NULL;
141 size_t used = 0;
142 size_t allocated = 0;
143
144 void
145 append_int (int value)
146 {
147 if (used == allocated)
148 p = x2nrealloc (p, &allocated, sizeof *p);
149 p[used++] = value;
150 }
151
152 This causes x2nrealloc to allocate a block of some nonzero size the
153 first time it is called.
154
155 To have finer-grained control over the initial size, set *PN to a
156 nonzero value before calling this function with P == NULL. For
157 example:
158
159 int *p = NULL;
160 size_t used = 0;
161 size_t allocated = 0;
162 size_t allocated1 = 1000;
163
164 void
165 append_int (int value)
166 {
167 if (used == allocated)
168 {
169 p = x2nrealloc (p, &allocated1, sizeof *p);
170 allocated = allocated1;
171 }
172 p[used++] = value;
173 }
174
175 */
176
177void *
178x2nrealloc (void *p, size_t *pn, size_t s)
52{ 179{
53 if (!n && p) 180 size_t n = *pn;
181
182 if (! p)
54 { 183 {
55 /* The GNU and C99 realloc behaviors disagree here. Act like 184 if (! n)
56 GNU, even if the underlying realloc is C99. */ 185 {
57 free (p); 186 /* The approximate size to use for initial small allocation
58 return NULL; 187 requests, when the invoking code specifies an old size of
188 zero. This is the largest "small" request for the GNU C
189 library malloc. */
190 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
191
192 n = DEFAULT_MXFAST / s;
193 n += !n;
194 }
195 }
196 else
197 {
198 /* Set N = floor (1.5 * N) + 1 to make progress even if N == 0. */
199 if (ckd_add (&n, n, (n >> 1) + 1))
200 xalloc_die ();
59 } 201 }
60 202
61 p = realloc (p, n); 203 p = xreallocarray (p, n, s);
62 if (!p && n) 204 *pn = n;
63 xalloc_die ();
64 return p; 205 return p;
65} 206}
66 207
67/* If P is null, allocate a block of at least *PN bytes; otherwise, 208/* Grow PA, which points to an array of *PN items, and return the
68 reallocate P so that it contains more than *PN bytes. *PN must be 209 location of the reallocated array, updating *PN to reflect its
69 nonzero unless P is null. Set *PN to the new block's size, and 210 new size. The new array will contain at least N_INCR_MIN more
70 return the pointer to the new block. *PN is never set to zero, and 211 items, but will not contain more than N_MAX items total.
71 the returned pointer is never null. */ 212 S is the size of each item, in bytes.
213
214 S and N_INCR_MIN must be positive. *PN must be
215 nonnegative. If N_MAX is -1, it is treated as if it were
216 infinity.
217
218 If PA is null, then allocate a new array instead of reallocating
219 the old one.
220
221 Thus, to grow an array A without saving its old contents, do
222 { free (A); A = xpalloc (NULL, &AITEMS, ...); }. */
72 223
73void * 224void *
74x2realloc (void *p, size_t *pn) 225xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
75{ 226{
76 return x2nrealloc (p, pn, 1); 227 idx_t n0 = *pn;
228
229 /* The approximate size to use for initial small allocation
230 requests. This is the largest "small" request for the GNU C
231 library malloc. */
232 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
233
234 /* If the array is tiny, grow it to about (but no greater than)
235 DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%.
236 Adjust the growth according to three constraints: N_INCR_MIN,
237 N_MAX, and what the C language can represent safely. */
238
239 idx_t n;
240 if (ckd_add (&n, n0, n0 >> 1))
241 n = IDX_MAX;
242 if (0 <= n_max && n_max < n)
243 n = n_max;
244
245 /* NBYTES is of a type suitable for holding the count of bytes in an object.
246 This is typically idx_t, but it should be size_t on (theoretical?)
247 platforms where SIZE_MAX < IDX_MAX so xpalloc does not pass
248 values greater than SIZE_MAX to xrealloc. */
249#if IDX_MAX <= SIZE_MAX
250 idx_t nbytes;
251#else
252 size_t nbytes;
253#endif
254 idx_t adjusted_nbytes
255 = (ckd_mul (&nbytes, n, s)
256 ? MIN (IDX_MAX, SIZE_MAX)
257 : nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0);
258 if (adjusted_nbytes)
259 {
260 n = adjusted_nbytes / s;
261 nbytes = adjusted_nbytes - adjusted_nbytes % s;
262 }
263
264 if (! pa)
265 *pn = 0;
266 if (n - n0 < n_incr_min
267 && (ckd_add (&n, n0, n_incr_min)
268 || (0 <= n_max && n_max < n)
269 || ckd_mul (&nbytes, n, s)))
270 xalloc_die ();
271 pa = xrealloc (pa, nbytes);
272 *pn = n;
273 return pa;
77} 274}
78 275
79/* Allocate S bytes of zeroed memory dynamically, with error checking. 276/* Allocate S bytes of zeroed memory dynamically, with error checking.
@@ -83,7 +280,13 @@ x2realloc (void *p, size_t *pn)
83void * 280void *
84xzalloc (size_t s) 281xzalloc (size_t s)
85{ 282{
86 return memset (xmalloc (s), 0, s); 283 return xcalloc (s, 1);
284}
285
286void *
287xizalloc (idx_t s)
288{
289 return xicalloc (s, 1);
87} 290}
88 291
89/* Allocate zeroed memory for N elements of S bytes, with error 292/* Allocate zeroed memory for N elements of S bytes, with error
@@ -92,15 +295,13 @@ xzalloc (size_t s)
92void * 295void *
93xcalloc (size_t n, size_t s) 296xcalloc (size_t n, size_t s)
94{ 297{
95 void *p; 298 return nonnull (calloc (n, s));
96 /* Test for overflow, since some calloc implementations don't have 299}
97 proper overflow checks. But omit overflow and size-zero tests if 300
98 HAVE_GNU_CALLOC, since GNU calloc catches overflow and never 301void *
99 returns NULL if successful. */ 302xicalloc (idx_t n, idx_t s)
100 if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s)) 303{
101 || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0))) 304 return nonnull (icalloc (n, s));
102 xalloc_die ();
103 return p;
104} 305}
105 306
106/* Clone an object P of size S, with error checking. There's no need 307/* Clone an object P of size S, with error checking. There's no need
@@ -113,6 +314,23 @@ xmemdup (void const *p, size_t s)
113 return memcpy (xmalloc (s), p, s); 314 return memcpy (xmalloc (s), p, s);
114} 315}
115 316
317void *
318ximemdup (void const *p, idx_t s)
319{
320 return memcpy (ximalloc (s), p, s);
321}
322
323/* Clone an object P of size S, with error checking. Append
324 a terminating NUL byte. */
325
326char *
327ximemdup0 (void const *p, idx_t s)
328{
329 char *result = ximalloc (s + 1);
330 result[s] = 0;
331 return memcpy (result, p, s);
332}
333
116/* Clone STRING. */ 334/* Clone STRING. */
117 335
118char * 336char *
diff --git a/gl/xsize.c b/gl/xsize.c
index 4b4914c2..279ae824 100644
--- a/gl/xsize.c
+++ b/gl/xsize.c
@@ -1,3 +1,21 @@
1/* Checked size_t computations.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define XSIZE_INLINE _GL_EXTERN_INLINE 20#define XSIZE_INLINE _GL_EXTERN_INLINE
3#include "xsize.h" 21#include "xsize.h"
diff --git a/gl/xsize.h b/gl/xsize.h
index 2922f353..1ec78e77 100644
--- a/gl/xsize.h
+++ b/gl/xsize.h
@@ -1,19 +1,19 @@
1/* xsize.h -- Checked size_t computations. 1/* xsize.h -- Checked size_t computations.
2 2
3 Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _XSIZE_H 18#ifndef _XSIZE_H
19#define _XSIZE_H 19#define _XSIZE_H
@@ -27,6 +27,12 @@
27# include <stdint.h> 27# include <stdint.h>
28#endif 28#endif
29 29
30/* Get ATTRIBUTE_PURE. */
31#include "attribute.h"
32
33#ifndef _GL_INLINE_HEADER_BEGIN
34 #error "Please include config.h first."
35#endif
30_GL_INLINE_HEADER_BEGIN 36_GL_INLINE_HEADER_BEGIN
31#ifndef XSIZE_INLINE 37#ifndef XSIZE_INLINE
32# define XSIZE_INLINE _GL_INLINE 38# define XSIZE_INLINE _GL_INLINE
@@ -53,10 +59,7 @@ _GL_INLINE_HEADER_BEGIN
53 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) 59 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
54 60
55/* Sum of two sizes, with overflow check. */ 61/* Sum of two sizes, with overflow check. */
56XSIZE_INLINE size_t 62XSIZE_INLINE size_t ATTRIBUTE_PURE
57#if __GNUC__ >= 3
58__attribute__ ((__pure__))
59#endif
60xsum (size_t size1, size_t size2) 63xsum (size_t size1, size_t size2)
61{ 64{
62 size_t sum = size1 + size2; 65 size_t sum = size1 + size2;
@@ -64,30 +67,21 @@ xsum (size_t size1, size_t size2)
64} 67}
65 68
66/* Sum of three sizes, with overflow check. */ 69/* Sum of three sizes, with overflow check. */
67XSIZE_INLINE size_t 70XSIZE_INLINE size_t ATTRIBUTE_PURE
68#if __GNUC__ >= 3
69__attribute__ ((__pure__))
70#endif
71xsum3 (size_t size1, size_t size2, size_t size3) 71xsum3 (size_t size1, size_t size2, size_t size3)
72{ 72{
73 return xsum (xsum (size1, size2), size3); 73 return xsum (xsum (size1, size2), size3);
74} 74}
75 75
76/* Sum of four sizes, with overflow check. */ 76/* Sum of four sizes, with overflow check. */
77XSIZE_INLINE size_t 77XSIZE_INLINE size_t ATTRIBUTE_PURE
78#if __GNUC__ >= 3
79__attribute__ ((__pure__))
80#endif
81xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) 78xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
82{ 79{
83 return xsum (xsum (xsum (size1, size2), size3), size4); 80 return xsum (xsum (xsum (size1, size2), size3), size4);
84} 81}
85 82
86/* Maximum of two sizes, with overflow check. */ 83/* Maximum of two sizes, with overflow check. */
87XSIZE_INLINE size_t 84XSIZE_INLINE size_t ATTRIBUTE_PURE
88#if __GNUC__ >= 3
89__attribute__ ((__pure__))
90#endif
91xmax (size_t size1, size_t size2) 85xmax (size_t size1, size_t size2)
92{ 86{
93 /* No explicit check is needed here, because for any n: 87 /* No explicit check is needed here, because for any n:
diff --git a/gl/xstrndup.c b/gl/xstrndup.c
deleted file mode 100644
index eae92d03..00000000
--- a/gl/xstrndup.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/* Duplicate a bounded initial segment of a string, with out-of-memory
2 checking.
3 Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "xstrndup.h"
22
23#include <string.h>
24#include "xalloc.h"
25
26/* Return a newly allocated copy of at most N bytes of STRING.
27 In other words, return a copy of the initial segment of length N of
28 STRING. */
29char *
30xstrndup (const char *string, size_t n)
31{
32 char *s = strndup (string, n);
33 if (! s)
34 xalloc_die ();
35 return s;
36}
diff --git a/gl/xstrndup.h b/gl/xstrndup.h
deleted file mode 100644
index 59673b04..00000000
--- a/gl/xstrndup.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/* Duplicate a bounded initial segment of a string, with out-of-memory
2 checking.
3 Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <stddef.h>
19
20/* Return a newly allocated copy of at most N bytes of STRING.
21 In other words, return a copy of the initial segment of length N of
22 STRING. */
23extern char *xstrndup (const char *string, size_t n);
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 01d73a64..1a47395d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -7,7 +7,7 @@ noinst_LIBRARIES = libmonitoringplug.a
7AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" \ 7AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" \
8 -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins 8 -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
9 9
10libmonitoringplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c 10libmonitoringplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c maxfd.c
11EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h parse_ini.h extra_opts.h 11EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h parse_ini.h extra_opts.h
12 12
13if USE_PARSE_INI 13if USE_PARSE_INI
diff --git a/lib/maxfd.c b/lib/maxfd.c
new file mode 100644
index 00000000..529b3568
--- /dev/null
+++ b/lib/maxfd.c
@@ -0,0 +1,26 @@
1#include "./maxfd.h"
2#include <errno.h>
3
4long mp_open_max (void) {
5 long maxfd = 0L;
6 /* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
7 * If that fails and the macro isn't defined, we fall back to an educated
8 * guess. There's no guarantee that our guess is adequate and the program
9 * will die with SIGSEGV if it isn't and the upper boundary is breached. */
10
11#ifdef _SC_OPEN_MAX
12 errno = 0;
13 if ((maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
14 if (errno == 0)
15 maxfd = DEFAULT_MAXFD; /* it's indeterminate */
16 else
17 die (STATE_UNKNOWN, _("sysconf error for _SC_OPEN_MAX\n"));
18 }
19#elif defined(OPEN_MAX)
20 return OPEN_MAX
21#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
22 return DEFAULT_MAXFD;
23#endif
24
25 return(maxfd);
26}
diff --git a/lib/maxfd.h b/lib/maxfd.h
new file mode 100644
index 00000000..45218d0f
--- /dev/null
+++ b/lib/maxfd.h
@@ -0,0 +1,9 @@
1#ifndef _MAXFD_
2#define _MAXFD_
3
4#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */
5#define MAXFD_LIMIT 8192 /* upper limit of open files */
6
7long mp_open_max (void);
8
9#endif // _MAXFD_
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index 25abc89b..547af433 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -78,7 +78,7 @@ static char *default_file_in_path(void);
78/* 78/*
79 * Parse_locator decomposes a string of the form 79 * Parse_locator decomposes a string of the form
80 * [stanza][@filename] 80 * [stanza][@filename]
81 * into its seperate parts. 81 * into its separate parts.
82 */ 82 */
83static void 83static void
84parse_locator(const char *locator, const char *def_stanza, np_ini_info *i) 84parse_locator(const char *locator, const char *def_stanza, np_ini_info *i)
@@ -169,7 +169,7 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
169 if (isspace(c)) 169 if (isspace(c))
170 continue; 170 continue;
171 switch (c) { 171 switch (c) {
172 /* globble up coment lines */ 172 /* globble up comment lines */
173 case ';': 173 case ';':
174 case '#': 174 case '#':
175 GOBBLE_TO(f, c, '\n'); 175 GOBBLE_TO(f, c, '\n');
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index a8d7adee..31d79df6 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -27,7 +27,7 @@ endif
27 27
28AM_CFLAGS = -g -I$(top_srcdir)/lib -I$(top_srcdir)/gl $(tap_cflags) 28AM_CFLAGS = -g -I$(top_srcdir)/lib -I$(top_srcdir)/gl $(tap_cflags)
29AM_LDFLAGS = $(tap_ldflags) -ltap 29AM_LDFLAGS = $(tap_ldflags) -ltap
30LDADD = $(top_srcdir)/lib/libmonitoringplug.a $(top_srcdir)/gl/libgnu.a 30LDADD = $(top_srcdir)/lib/libmonitoringplug.a $(top_srcdir)/gl/libgnu.a $(LIB_CRYPTO)
31 31
32SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c 32SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c
33 33
diff --git a/lib/tests/test_cmd.c b/lib/tests/test_cmd.c
index 29ca42ac..4bb60aac 100644
--- a/lib/tests/test_cmd.c
+++ b/lib/tests/test_cmd.c
@@ -176,14 +176,14 @@ main (int argc, char **argv)
176 ok (result == UNSET, "(initialised) Checking exit code is reset"); 176 ok (result == UNSET, "(initialised) Checking exit code is reset");
177 177
178 command = (char *)malloc(COMMAND_LINE); 178 command = (char *)malloc(COMMAND_LINE);
179 strcpy(command, "/bin/echo3456 non-existant command"); 179 strcpy(command, "/bin/echo3456 non-existent command");
180 result = cmd_run (command, &chld_out, &chld_err, 0); 180 result = cmd_run (command, &chld_out, &chld_err, 0);
181 181
182 ok (chld_out.lines == 0, 182 ok (chld_out.lines == 0,
183 "Non existant command, so no output"); 183 "Non existent command, so no output");
184 ok (chld_err.lines == 0, 184 ok (chld_err.lines == 0,
185 "No stderr either"); 185 "No stderr either");
186 ok (result == 3, "Get return code 3 (?) for non-existant command"); 186 ok (result == 3, "Get return code 3 (?) for non-existent command");
187 187
188 188
189 /* ensure everything is empty again */ 189 /* ensure everything is empty again */
@@ -192,14 +192,14 @@ main (int argc, char **argv)
192 result = UNSET; 192 result = UNSET;
193 193
194 command = (char *)malloc(COMMAND_LINE); 194 command = (char *)malloc(COMMAND_LINE);
195 strcpy(command, "/bin/sh non-existant-file"); 195 strcpy(command, "/bin/sh non-existent-file");
196 result = cmd_run (command, &chld_out, &chld_err, 0); 196 result = cmd_run (command, &chld_out, &chld_err, 0);
197 197
198 ok (chld_out.lines == 0, 198 ok (chld_out.lines == 0,
199 "/bin/sh returns no stdout when file is missing..."); 199 "/bin/sh returns no stdout when file is missing...");
200 ok (chld_err.lines == 1, 200 ok (chld_err.lines == 1,
201 "...but does give an error line"); 201 "...but does give an error line");
202 ok (strstr(chld_err.line[0],"non-existant-file") != NULL, "And missing filename is in error message"); 202 ok (strstr(chld_err.line[0],"non-existent-file") != NULL, "And missing filename is in error message");
203 ok (result != 0, "Get non-zero return code from /bin/sh"); 203 ok (result != 0, "Get non-zero return code from /bin/sh");
204 204
205 205
@@ -219,11 +219,11 @@ main (int argc, char **argv)
219 result = UNSET; 219 result = UNSET;
220 220
221 command = (char *)malloc(COMMAND_LINE); 221 command = (char *)malloc(COMMAND_LINE);
222 strcpy(command, "/bin/non-existant-command"); 222 strcpy(command, "/bin/non-existent-command");
223 result = cmd_run (command, &chld_out, &chld_err, 0); 223 result = cmd_run (command, &chld_out, &chld_err, 0);
224 224
225 ok (chld_out.lines == 0, 225 ok (chld_out.lines == 0,
226 "/bin/non-existant-command returns no stdout..."); 226 "/bin/non-existent-command returns no stdout...");
227 ok (chld_err.lines == 0, 227 ok (chld_err.lines == 0,
228 "...and no stderr output either"); 228 "...and no stderr output either");
229 ok (result == 3, "Get return code 3 = UNKNOWN when command does not exist"); 229 ok (result == 3, "Get return code 3 = UNKNOWN when command does not exist");
diff --git a/lib/tests/test_disk.c b/lib/tests/test_disk.c
index f6477ac4..9bd68c7a 100644
--- a/lib/tests/test_disk.c
+++ b/lib/tests/test_disk.c
@@ -88,10 +88,10 @@ main (int argc, char **argv)
88 cflags, 3,strdup("regex on dev names:")); 88 cflags, 3,strdup("regex on dev names:"));
89 np_test_mount_entry_regex(dummy_mount_list, strdup("/foo"), 89 np_test_mount_entry_regex(dummy_mount_list, strdup("/foo"),
90 cflags, 0, 90 cflags, 0,
91 strdup("regex on non existant dev/path:")); 91 strdup("regex on non existent dev/path:"));
92 np_test_mount_entry_regex(dummy_mount_list, strdup("/Foo"), 92 np_test_mount_entry_regex(dummy_mount_list, strdup("/Foo"),
93 cflags | REG_ICASE,0, 93 cflags | REG_ICASE,0,
94 strdup("regi on non existant dev/path:")); 94 strdup("regi on non existent dev/path:"));
95 np_test_mount_entry_regex(dummy_mount_list, strdup("/c.t0"), 95 np_test_mount_entry_regex(dummy_mount_list, strdup("/c.t0"),
96 cflags, 3, 96 cflags, 3,
97 strdup("partial devname regex match:")); 97 strdup("partial devname regex match:"));
diff --git a/lib/tests/test_ini3.t b/lib/tests/test_ini3.t
index a2ca94a4..41169dbc 100755
--- a/lib/tests/test_ini3.t
+++ b/lib/tests/test_ini3.t
@@ -10,7 +10,7 @@ if (! -e "./test_ini3") {
10# array of argument arrays 10# array of argument arrays
11# - First value is the expected return code 11# - First value is the expected return code
12# - 2nd value is the NAGIOS_CONFIG_PATH 12# - 2nd value is the NAGIOS_CONFIG_PATH
13# TODO: looks like we look in default path after looking trough this variable - shall we? 13# TODO: looks like we look in default path after looking through this variable - shall we?
14# - 3rd value is the plugin name 14# - 3rd value is the plugin name
15# - 4th is the ini locator 15# - 4th is the ini locator
16my @TESTS = ( 16my @TESTS = (
diff --git a/lib/tests/test_opts3.t b/lib/tests/test_opts3.t
index 8d974ca0..d77a35ce 100755
--- a/lib/tests/test_opts3.t
+++ b/lib/tests/test_opts3.t
@@ -10,7 +10,7 @@ if (! -e "./test_opts3") {
10# array of argument arrays 10# array of argument arrays
11# - First value is the expected return code 11# - First value is the expected return code
12# - 2nd value is the NAGIOS_CONFIG_PATH 12# - 2nd value is the NAGIOS_CONFIG_PATH
13# TODO: looks like we look in default path after looking trough this variable - shall we? 13# TODO: looks like we look in default path after looking through this variable - shall we?
14# - 3rd value is the plugin name 14# - 3rd value is the plugin name
15# - 4th and up are arguments 15# - 4th and up are arguments
16my @TESTS = ( 16my @TESTS = (
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index f35b7e27..7b10494c 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -309,7 +309,7 @@ main (int argc, char **argv)
309 309
310 /* This is the result of running ./test_utils */ 310 /* This is the result of running ./test_utils */
311 temp_string = (char *) _np_state_generate_key(); 311 temp_string = (char *) _np_state_generate_key();
312 ok(!strcmp(temp_string, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got hash with exe and no parameters" ) || 312 ok(!strcmp(temp_string, "e2d17f995fd4c020411b85e3e3d0ff7306d4147e"), "Got hash with exe and no parameters" ) ||
313 diag( "You are probably running in wrong directory. Must run as ./test_utils" ); 313 diag( "You are probably running in wrong directory. Must run as ./test_utils" );
314 314
315 315
@@ -319,7 +319,7 @@ main (int argc, char **argv)
319 this_monitoring_plugin->argv[2] = "--and"; 319 this_monitoring_plugin->argv[2] = "--and";
320 this_monitoring_plugin->argv[3] = "now"; 320 this_monitoring_plugin->argv[3] = "now";
321 temp_string = (char *) _np_state_generate_key(); 321 temp_string = (char *) _np_state_generate_key();
322 ok(!strcmp(temp_string, "94b5e17bf5abf51cb15aff5f69b96f2f8dac5ecd"), "Got based on expected argv" ); 322 ok(!strcmp(temp_string, "bd72da9f78ff1419fad921ea5e43ce56508aef6c"), "Got based on expected argv" );
323 323
324 unsetenv("MP_STATE_PATH"); 324 unsetenv("MP_STATE_PATH");
325 temp_string = (char *) _np_state_calculate_location_prefix(); 325 temp_string = (char *) _np_state_calculate_location_prefix();
@@ -342,7 +342,7 @@ main (int argc, char **argv)
342 np_enable_state(NULL, 51); 342 np_enable_state(NULL, 51);
343 temp_state_key = this_monitoring_plugin->state; 343 temp_state_key = this_monitoring_plugin->state;
344 ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); 344 ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" );
345 ok( !strcmp(temp_state_key->name, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got generated filename" ); 345 ok( !strcmp(temp_state_key->name, "e2d17f995fd4c020411b85e3e3d0ff7306d4147e"), "Got generated filename" );
346 346
347 347
348 np_enable_state("allowedchars_in_keyname", 77); 348 np_enable_state("allowedchars_in_keyname", 77);
@@ -395,7 +395,7 @@ main (int argc, char **argv)
395 ok( temp_state_data==NULL, "Older data version gives NULL" ); 395 ok( temp_state_data==NULL, "Older data version gives NULL" );
396 temp_state_key->data_version=54; 396 temp_state_key->data_version=54;
397 397
398 temp_state_key->_filename="var/nonexistant"; 398 temp_state_key->_filename="var/nonexistent";
399 temp_state_data = np_state_read(); 399 temp_state_data = np_state_read();
400 ok( temp_state_data==NULL, "Missing file gives NULL" ); 400 ok( temp_state_data==NULL, "Missing file gives NULL" );
401 ok( this_monitoring_plugin->state->state_data==NULL, "No state information" ); 401 ok( this_monitoring_plugin->state->state_data==NULL, "No state information" );
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 3822bcf1..0f521263 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -24,7 +24,7 @@
24* 24*
25*****************************************************************************/ 25*****************************************************************************/
26 26
27#include "common.h" 27#include "../plugins/common.h"
28#include <stdarg.h> 28#include <stdarg.h>
29#include "utils_base.h" 29#include "utils_base.h"
30#include <ctype.h> 30#include <ctype.h>
@@ -37,6 +37,9 @@
37 37
38monitoring_plugin *this_monitoring_plugin=NULL; 38monitoring_plugin *this_monitoring_plugin=NULL;
39 39
40unsigned int timeout_state = STATE_CRITICAL;
41unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
42
40int _np_state_read_file(FILE *); 43int _np_state_read_file(FILE *);
41 44
42void np_init( char *plugin_name, int argc, char **argv ) { 45void np_init( char *plugin_name, int argc, char **argv ) {
@@ -87,10 +90,13 @@ void _get_monitoring_plugin( monitoring_plugin **pointer ){
87void 90void
88die (int result, const char *fmt, ...) 91die (int result, const char *fmt, ...)
89{ 92{
90 va_list ap; 93 if(fmt!=NULL) {
91 va_start (ap, fmt); 94 va_list ap;
92 vprintf (fmt, ap); 95 va_start (ap, fmt);
93 va_end (ap); 96 vprintf (fmt, ap);
97 va_end (ap);
98 }
99
94 if(this_monitoring_plugin!=NULL) { 100 if(this_monitoring_plugin!=NULL) {
95 np_cleanup(); 101 np_cleanup();
96 } 102 }
@@ -122,6 +128,7 @@ range
122 temp_range->end = 0; 128 temp_range->end = 0;
123 temp_range->end_infinity = TRUE; 129 temp_range->end_infinity = TRUE;
124 temp_range->alert_on = OUTSIDE; 130 temp_range->alert_on = OUTSIDE;
131 temp_range->text = strdup(str);
125 132
126 if (str[0] == '@') { 133 if (str[0] == '@') {
127 temp_range->alert_on = INSIDE; 134 temp_range->alert_on = INSIDE;
@@ -312,18 +319,18 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
312 319
313 while (1) { 320 while (1) {
314 /* Strip any leading space */ 321 /* Strip any leading space */
315 for (varlist; isspace(varlist[0]); varlist++); 322 for (; isspace(varlist[0]); varlist++);
316 323
317 if (strncmp(name, varlist, strlen(name)) == 0) { 324 if (strncmp(name, varlist, strlen(name)) == 0) {
318 varlist += strlen(name); 325 varlist += strlen(name);
319 /* strip trailing spaces */ 326 /* strip trailing spaces */
320 for (varlist; isspace(varlist[0]); varlist++); 327 for (; isspace(varlist[0]); varlist++);
321 328
322 if (varlist[0] == '=') { 329 if (varlist[0] == '=') {
323 /* We matched the key, go past the = sign */ 330 /* We matched the key, go past the = sign */
324 varlist++; 331 varlist++;
325 /* strip leading spaces */ 332 /* strip leading spaces */
326 for (varlist; isspace(varlist[0]); varlist++); 333 for (; isspace(varlist[0]); varlist++);
327 334
328 if (tmp = index(varlist, sep)) { 335 if (tmp = index(varlist, sep)) {
329 /* Value is delimited by a comma */ 336 /* Value is delimited by a comma */
@@ -356,6 +363,22 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
356 return value; 363 return value;
357} 364}
358 365
366const char *
367state_text (int result)
368{
369 switch (result) {
370 case STATE_OK:
371 return "OK";
372 case STATE_WARNING:
373 return "WARNING";
374 case STATE_CRITICAL:
375 return "CRITICAL";
376 case STATE_DEPENDENT:
377 return "DEPENDENT";
378 default:
379 return "UNKNOWN";
380 }
381}
359 382
360/* 383/*
361 * Read a string representing a state (ok, warning... or numeric: 0, 1) and 384 * Read a string representing a state (ok, warning... or numeric: 0, 1) and
@@ -379,26 +402,45 @@ int mp_translate_state (char *state_text) {
379 * parse of argv, so that uniqueness in parameters are reflected there. 402 * parse of argv, so that uniqueness in parameters are reflected there.
380 */ 403 */
381char *_np_state_generate_key() { 404char *_np_state_generate_key() {
382 struct sha1_ctx ctx;
383 int i; 405 int i;
384 char **argv = this_monitoring_plugin->argv; 406 char **argv = this_monitoring_plugin->argv;
385 unsigned char result[20];
386 char keyname[41]; 407 char keyname[41];
387 char *p=NULL; 408 char *p=NULL;
388 409
389 sha1_init_ctx(&ctx); 410 unsigned char result[256];
390 411
412#ifdef USE_OPENSSL
413 /*
414 * This code path is chosen if openssl is available (which should be the most common
415 * scenario). Alternatively, the gnulib implementation/
416 *
417 */
418 EVP_MD_CTX *ctx = EVP_MD_CTX_new();
419
420 EVP_DigestInit(ctx, EVP_sha256());
421
391 for(i=0; i<this_monitoring_plugin->argc; i++) { 422 for(i=0; i<this_monitoring_plugin->argc; i++) {
392 sha1_process_bytes(argv[i], strlen(argv[i]), &ctx); 423 EVP_DigestUpdate(ctx, argv[i], strlen(argv[i]));
393 } 424 }
394 425
395 sha1_finish_ctx(&ctx, &result); 426 EVP_DigestFinal(ctx, result, NULL);
396 427#else
428
429 struct sha256_ctx ctx;
430
431 for(i=0; i<this_monitoring_plugin->argc; i++) {
432 sha256_process_bytes(argv[i], strlen(argv[i]), &ctx);
433 }
434
435 sha256_finish_ctx(&ctx, result);
436#endif // FOUNDOPENSSL
437
397 for (i=0; i<20; ++i) { 438 for (i=0; i<20; ++i) {
398 sprintf(&keyname[2*i], "%02x", result[i]); 439 sprintf(&keyname[2*i], "%02x", result[i]);
399 } 440 }
441
400 keyname[40]='\0'; 442 keyname[40]='\0';
401 443
402 p = strdup(keyname); 444 p = strdup(keyname);
403 if(p==NULL) { 445 if(p==NULL) {
404 die(STATE_UNKNOWN, _("Cannot execute strdup: %s"), strerror(errno)); 446 die(STATE_UNKNOWN, _("Cannot execute strdup: %s"), strerror(errno));
@@ -684,4 +726,3 @@ void np_state_write_string(time_t data_time, char *data_string) {
684 726
685 np_free(temp_file); 727 np_free(temp_file);
686} 728}
687
diff --git a/lib/utils_base.h b/lib/utils_base.h
index 42ae0c09..9cb42767 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -2,7 +2,9 @@
2#define _UTILS_BASE_ 2#define _UTILS_BASE_
3/* Header file for Monitoring Plugins utils_base.c */ 3/* Header file for Monitoring Plugins utils_base.c */
4 4
5#include "sha1.h" 5#ifndef USE_OPENSSL
6# include "sha256.h"
7#endif
6 8
7/* This file holds header information for thresholds - use this in preference to 9/* This file holds header information for thresholds - use this in preference to
8 individual plugin logic */ 10 individual plugin logic */
@@ -23,6 +25,7 @@ typedef struct range_struct {
23 double end; 25 double end;
24 int end_infinity; 26 int end_infinity;
25 int alert_on; /* OUTSIDE (default) or INSIDE */ 27 int alert_on; /* OUTSIDE (default) or INSIDE */
28 char* text; /* original unparsed text input */
26 } range; 29 } range;
27 30
28typedef struct thresholds_struct { 31typedef struct thresholds_struct {
@@ -61,6 +64,10 @@ void print_thresholds(const char *, thresholds *);
61int check_range(double, range *); 64int check_range(double, range *);
62int get_status(double, thresholds *); 65int get_status(double, thresholds *);
63 66
67/* Handle timeouts */
68extern unsigned int timeout_state;
69extern unsigned int timeout_interval;
70
64/* All possible characters in a threshold range */ 71/* All possible characters in a threshold range */
65#define NP_THRESHOLDS_CHARS "-0123456789.:@~" 72#define NP_THRESHOLDS_CHARS "-0123456789.:@~"
66 73
@@ -107,5 +114,6 @@ void np_state_write_string(time_t, char *);
107void np_init(char *, int argc, char **argv); 114void np_init(char *, int argc, char **argv);
108void np_set_args(int argc, char **argv); 115void np_set_args(int argc, char **argv);
109void np_cleanup(); 116void np_cleanup();
117const char *state_text (int);
110 118
111#endif /* _UTILS_BASE_ */ 119#endif /* _UTILS_BASE_ */
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 7eb9a3a0..f66fd573 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -40,8 +40,22 @@
40 40
41/** includes **/ 41/** includes **/
42#include "common.h" 42#include "common.h"
43#include "utils.h"
43#include "utils_cmd.h" 44#include "utils_cmd.h"
45/* This variable must be global, since there's no way the caller
46 * can forcibly slay a dead or ungainly running program otherwise.
47 * Multithreading apps and plugins can initialize it (via CMD_INIT)
48 * in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
49 * for the first time.
50 *
51 * The check for initialized values is atomic and can
52 * occur in any number of threads simultaneously. */
53static pid_t *_cmd_pids = NULL;
54
44#include "utils_base.h" 55#include "utils_base.h"
56
57#include "./maxfd.h"
58
45#include <fcntl.h> 59#include <fcntl.h>
46 60
47#ifdef HAVE_SYS_WAIT_H 61#ifdef HAVE_SYS_WAIT_H
@@ -65,31 +79,6 @@ extern char **environ;
65# define SIG_ERR ((Sigfunc *)-1) 79# define SIG_ERR ((Sigfunc *)-1)
66#endif 80#endif
67 81
68/* This variable must be global, since there's no way the caller
69 * can forcibly slay a dead or ungainly running program otherwise.
70 * Multithreading apps and plugins can initialize it (via CMD_INIT)
71 * in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
72 * for the first time.
73 *
74 * The check for initialized values is atomic and can
75 * occur in any number of threads simultaneously. */
76static pid_t *_cmd_pids = NULL;
77
78/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
79 * If that fails and the macro isn't defined, we fall back to an educated
80 * guess. There's no guarantee that our guess is adequate and the program
81 * will die with SIGSEGV if it isn't and the upper boundary is breached. */
82#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */
83#define MAXFD_LIMIT 8192 /* upper limit of open files */
84#ifdef _SC_OPEN_MAX
85static long maxfd = 0;
86#elif defined(OPEN_MAX)
87# define maxfd OPEN_MAX
88#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
89# define maxfd DEFAULT_MAXFD
90#endif
91
92
93/** prototypes **/ 82/** prototypes **/
94static int _cmd_open (char *const *, int *, int *) 83static int _cmd_open (char *const *, int *, int *)
95 __attribute__ ((__nonnull__ (1, 2, 3))); 84 __attribute__ ((__nonnull__ (1, 2, 3)));
@@ -110,13 +99,7 @@ extern void die (int, const char *, ...)
110void 99void
111cmd_init (void) 100cmd_init (void)
112{ 101{
113#ifndef maxfd 102 long maxfd = mp_open_max();
114 if (!maxfd && (maxfd = sysconf (_SC_OPEN_MAX)) < 0) {
115 /* possibly log or emit a warning here, since there's no
116 * guarantee that our guess at maxfd will be adequate */
117 maxfd = DEFAULT_MAXFD;
118 }
119#endif
120 103
121 /* if maxfd is unnaturally high, we force it to a lower value 104 /* if maxfd is unnaturally high, we force it to a lower value
122 * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause 105 * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
@@ -142,10 +125,6 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
142 125
143 int i = 0; 126 int i = 0;
144 127
145 /* if no command was passed, return with no error */
146 if (argv == NULL)
147 return -1;
148
149 if (!_cmd_pids) 128 if (!_cmd_pids)
150 CMD_INIT; 129 CMD_INIT;
151 130
@@ -176,6 +155,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
176 /* close all descriptors in _cmd_pids[] 155 /* close all descriptors in _cmd_pids[]
177 * This is executed in a separate address space (pure child), 156 * This is executed in a separate address space (pure child),
178 * so we don't have to worry about async safety */ 157 * so we don't have to worry about async safety */
158 long maxfd = mp_open_max();
179 for (i = 0; i < maxfd; i++) 159 for (i = 0; i < maxfd; i++)
180 if (_cmd_pids[i] > 0) 160 if (_cmd_pids[i] > 0)
181 close (i); 161 close (i);
@@ -185,7 +165,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
185 } 165 }
186 166
187 /* parent picks up execution here */ 167 /* parent picks up execution here */
188 /* close childs descriptors in our address space */ 168 /* close children descriptors in our address space */
189 close (pfd[1]); 169 close (pfd[1]);
190 close (pfderr[1]); 170 close (pfderr[1]);
191 171
@@ -202,6 +182,7 @@ _cmd_close (int fd)
202 pid_t pid; 182 pid_t pid;
203 183
204 /* make sure the provided fd was opened */ 184 /* make sure the provided fd was opened */
185 long maxfd = mp_open_max();
205 if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0) 186 if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0)
206 return -1; 187 return -1;
207 188
@@ -293,7 +274,6 @@ _cmd_fetch_output (int fd, output * op, int flags)
293int 274int
294cmd_run (const char *cmdstring, output * out, output * err, int flags) 275cmd_run (const char *cmdstring, output * out, output * err, int flags)
295{ 276{
296 int fd, pfd_out[2], pfd_err[2];
297 int i = 0, argc; 277 int i = 0, argc;
298 size_t cmdlen; 278 size_t cmdlen;
299 char **argv = NULL; 279 char **argv = NULL;
@@ -406,3 +386,20 @@ cmd_file_read ( char *filename, output *out, int flags)
406 386
407 return 0; 387 return 0;
408} 388}
389
390void
391timeout_alarm_handler (int signo)
392{
393 size_t i;
394 if (signo == SIGALRM) {
395 printf (_("%s - Plugin timed out after %d seconds\n"),
396 state_text(timeout_state), timeout_interval);
397
398 long maxfd = mp_open_max();
399 if(_cmd_pids) for(i = 0; i < maxfd; i++) {
400 if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL);
401 }
402
403 exit (timeout_state);
404 }
405}
diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h
index ebaf15be..f1b06c82 100644
--- a/lib/utils_cmd.h
+++ b/lib/utils_cmd.h
@@ -32,4 +32,8 @@ void cmd_init (void);
32#define CMD_NO_ARRAYS 0x01 /* don't populate arrays at all */ 32#define CMD_NO_ARRAYS 0x01 /* don't populate arrays at all */
33#define CMD_NO_ASSOC 0x02 /* output.line won't point to buf */ 33#define CMD_NO_ASSOC 0x02 /* output.line won't point to buf */
34 34
35
36void timeout_alarm_handler (int);
37
38
35#endif /* _UTILS_CMD_ */ 39#endif /* _UTILS_CMD_ */
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index efe35fc5..582d3ea1 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -28,6 +28,7 @@
28 28
29#include "common.h" 29#include "common.h"
30#include "utils_disk.h" 30#include "utils_disk.h"
31#include "gl/fsusage.h"
31 32
32void 33void
33np_add_name (struct name_list **list, const char *name) 34np_add_name (struct name_list **list, const char *name)
@@ -46,9 +47,10 @@ np_add_parameter(struct parameter_list **list, const char *name)
46 struct parameter_list *current = *list; 47 struct parameter_list *current = *list;
47 struct parameter_list *new_path; 48 struct parameter_list *new_path;
48 new_path = (struct parameter_list *) malloc (sizeof *new_path); 49 new_path = (struct parameter_list *) malloc (sizeof *new_path);
49 new_path->name = (char *) name; 50 new_path->name = (char *) malloc(strlen(name) + 1);
50 new_path->best_match = NULL; 51 new_path->best_match = NULL;
51 new_path->name_next = NULL; 52 new_path->name_next = NULL;
53 new_path->name_prev = NULL;
52 new_path->freespace_bytes = NULL; 54 new_path->freespace_bytes = NULL;
53 new_path->freespace_units = NULL; 55 new_path->freespace_units = NULL;
54 new_path->freespace_percent = NULL; 56 new_path->freespace_percent = NULL;
@@ -69,16 +71,22 @@ np_add_parameter(struct parameter_list **list, const char *name)
69 new_path->dtotal_units = 0; 71 new_path->dtotal_units = 0;
70 new_path->inodes_total = 0; 72 new_path->inodes_total = 0;
71 new_path->inodes_free = 0; 73 new_path->inodes_free = 0;
74 new_path->inodes_free_to_root = 0;
75 new_path->inodes_used = 0;
72 new_path->dused_inodes_percent = 0; 76 new_path->dused_inodes_percent = 0;
73 new_path->dfree_inodes_percent = 0; 77 new_path->dfree_inodes_percent = 0;
74 78
79 strcpy(new_path->name, name);
80
75 if (current == NULL) { 81 if (current == NULL) {
76 *list = new_path; 82 *list = new_path;
83 new_path->name_prev = NULL;
77 } else { 84 } else {
78 while (current->name_next) { 85 while (current->name_next) {
79 current = current->name_next; 86 current = current->name_next;
80 } 87 }
81 current->name_next = new_path; 88 current->name_next = new_path;
89 new_path->name_prev = current;
82 } 90 }
83 return new_path; 91 return new_path;
84} 92}
@@ -87,6 +95,9 @@ np_add_parameter(struct parameter_list **list, const char *name)
87struct parameter_list * 95struct parameter_list *
88np_del_parameter(struct parameter_list *item, struct parameter_list *prev) 96np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
89{ 97{
98 if (item == NULL) {
99 return NULL;
100 }
90 struct parameter_list *next; 101 struct parameter_list *next;
91 102
92 if (item->name_next) 103 if (item->name_next)
@@ -94,10 +105,17 @@ np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
94 else 105 else
95 next = NULL; 106 next = NULL;
96 107
97 free(item); 108 if (next)
109 next->name_prev = prev;
110
98 if (prev) 111 if (prev)
99 prev->name_next = next; 112 prev->name_next = next;
100 113
114 if (item->name) {
115 free(item->name);
116 }
117 free(item);
118
101 return next; 119 return next;
102} 120}
103 121
@@ -125,11 +143,15 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
125 size_t name_len = strlen(d->name); 143 size_t name_len = strlen(d->name);
126 size_t best_match_len = 0; 144 size_t best_match_len = 0;
127 struct mount_entry *best_match = NULL; 145 struct mount_entry *best_match = NULL;
146 struct fs_usage fsp;
128 147
129 /* set best match if path name exactly matches a mounted device name */ 148 /* set best match if path name exactly matches a mounted device name */
130 for (me = mount_list; me; me = me->me_next) { 149 for (me = mount_list; me; me = me->me_next) {
131 if (strcmp(me->me_devname, d->name)==0) 150 if (strcmp(me->me_devname, d->name)==0) {
132 best_match = me; 151 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
152 best_match = me;
153 }
154 }
133 } 155 }
134 156
135 /* set best match by directory name if no match was found by devname */ 157 /* set best match by directory name if no match was found by devname */
@@ -140,8 +162,10 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
140 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) 162 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
141 || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) 163 || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
142 { 164 {
143 best_match = me; 165 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
144 best_match_len = len; 166 best_match = me;
167 best_match_len = len;
168 }
145 } 169 }
146 } 170 }
147 } 171 }
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index 83a37639..3b5a45f8 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -24,9 +24,11 @@ struct parameter_list
24 char *group; 24 char *group;
25 struct mount_entry *best_match; 25 struct mount_entry *best_match;
26 struct parameter_list *name_next; 26 struct parameter_list *name_next;
27 uintmax_t total, available, available_to_root, used, inodes_free, inodes_total; 27 struct parameter_list *name_prev;
28 uintmax_t total, available, available_to_root, used,
29 inodes_free, inodes_free_to_root, inodes_used, inodes_total;
28 double dfree_pct, dused_pct; 30 double dfree_pct, dused_pct;
29 double dused_units, dfree_units, dtotal_units; 31 uint64_t dused_units, dfree_units, dtotal_units;
30 double dused_inodes_percent, dfree_inodes_percent; 32 double dused_inodes_percent, dfree_inodes_percent;
31}; 33};
32 34
diff --git a/m4/libcurl.m4 b/m4/libcurl.m4
new file mode 100644
index 00000000..53d694d0
--- /dev/null
+++ b/m4/libcurl.m4
@@ -0,0 +1,272 @@
1#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) 2006, David Shaw <dshaw@jabberwocky.com>
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.haxx.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21###########################################################################
22# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
23# [ACTION-IF-YES], [ACTION-IF-NO])
24# ----------------------------------------------------------
25# David Shaw <dshaw@jabberwocky.com> May-09-2006
26#
27# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
28# specify whether to default to --with-libcurl or --without-libcurl.
29# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
30# minimum version of libcurl to accept. Pass the version as a regular
31# version number like 7.10.1. If not supplied, any version is
32# accepted. ACTION-IF-YES is a list of shell commands to run if
33# libcurl was successfully found and passed the various tests.
34# ACTION-IF-NO is a list of shell commands that are run otherwise.
35# Note that using --without-libcurl does run ACTION-IF-NO.
36#
37# This macro #defines HAVE_LIBCURL if a working libcurl setup is
38# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
39# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
40# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
41# where yyy are the various protocols supported by libcurl. Both xxx
42# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
43# the macro for the complete list of possible defines. Shell
44# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
45# defined to 'yes' for those features and protocols that were found.
46# Note that xxx and yyy keep the same capitalization as in the
47# curl-config list (e.g. it's "HTTP" and not "http").
48#
49# Users may override the detected values by doing something like:
50# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
51#
52# For the sake of sanity, this macro assumes that any libcurl that is
53# found is after version 7.7.2, the first version that included the
54# curl-config script. Note that it is very important for people
55# packaging binary versions of libcurl to include this script!
56# Without curl-config, we can only guess what protocols are available,
57# or use curl_version_info to figure it out at runtime.
58
59AC_DEFUN([LIBCURL_CHECK_CONFIG],
60[
61 AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
62 AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
63 AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
64 AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
65 AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
66 AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
67 AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
68 AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
69
70 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
71 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
72 AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
73 AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
74 AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
75 AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
76 AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
77 AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
78 AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
79 AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP])
80 AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3])
81 AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP])
82 AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
83
84 AC_ARG_WITH(libcurl,
85 AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
86 [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
87
88 if test "$_libcurl_with" != "no" ; then
89
90 AC_PROG_AWK
91
92 _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
93
94 _libcurl_try_link=yes
95
96 if test -d "$_libcurl_with" ; then
97 LIBCURL_CPPFLAGS="-I$withval/include"
98 _libcurl_ldflags="-L$withval/lib"
99 AC_PATH_PROG([_libcurl_config],[curl-config],[],
100 ["$withval/bin"])
101 else
102 AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH])
103 fi
104
105 if test x$_libcurl_config != "x" ; then
106 AC_CACHE_CHECK([for the version of libcurl],
107 [libcurl_cv_lib_curl_version],
108 [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
109
110 _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
111 _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
112
113 if test $_libcurl_wanted -gt 0 ; then
114 AC_CACHE_CHECK([for libcurl >= version $2],
115 [libcurl_cv_lib_version_ok],
116 [
117 if test $_libcurl_version -ge $_libcurl_wanted ; then
118 libcurl_cv_lib_version_ok=yes
119 else
120 libcurl_cv_lib_version_ok=no
121 fi
122 ])
123 fi
124
125 if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
126 if test x"$LIBCURL_CPPFLAGS" = "x" ; then
127 LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
128 fi
129 if test x"$LIBCURL" = "x" ; then
130 LIBCURL=`$_libcurl_config --libs`
131
132 # This is so silly, but Apple actually has a bug in their
133 # curl-config script. Fixed in Tiger, but there are still
134 # lots of Panther installs around.
135 case "${host}" in
136 powerpc-apple-darwin7*)
137 LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
138 ;;
139 esac
140 fi
141
142 # All curl-config scripts support --feature
143 _libcurl_features=`$_libcurl_config --feature`
144
145 # Is it modern enough to have --protocols? (7.12.4)
146 if test $_libcurl_version -ge 461828 ; then
147 _libcurl_protocols=`$_libcurl_config --protocols`
148 fi
149 else
150 _libcurl_try_link=no
151 fi
152
153 unset _libcurl_wanted
154 fi
155
156 if test $_libcurl_try_link = yes ; then
157
158 # we didn't find curl-config, so let's see if the user-supplied
159 # link line (or failing that, "-lcurl") is enough.
160 LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
161
162 AC_CACHE_CHECK([whether libcurl is usable],
163 [libcurl_cv_lib_curl_usable],
164 [
165 _libcurl_save_cppflags=$CPPFLAGS
166 CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
167 _libcurl_save_libs=$LIBS
168 LIBS="$LIBCURL $LIBS"
169
170 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[
171/* Try and use a few common options to force a failure if we are
172 missing symbols or can't link. */
173int x;
174curl_easy_setopt(NULL,CURLOPT_URL,NULL);
175x=CURL_ERROR_SIZE;
176x=CURLOPT_WRITEFUNCTION;
177x=CURLOPT_WRITEDATA;
178x=CURLOPT_ERRORBUFFER;
179x=CURLOPT_STDERR;
180x=CURLOPT_VERBOSE;
181if (x) {;}
182]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
183
184 CPPFLAGS=$_libcurl_save_cppflags
185 LIBS=$_libcurl_save_libs
186 unset _libcurl_save_cppflags
187 unset _libcurl_save_libs
188 ])
189
190 if test $libcurl_cv_lib_curl_usable = yes ; then
191
192 # Does curl_free() exist in this version of libcurl?
193 # If not, fake it with free()
194
195 _libcurl_save_cppflags=$CPPFLAGS
196 CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
197 _libcurl_save_libs=$LIBS
198 LIBS="$LIBS $LIBCURL"
199
200 AC_CHECK_FUNC(curl_free,,
201 AC_DEFINE(curl_free,free,
202 [Define curl_free() as free() if our version of curl lacks curl_free.]))
203
204 CPPFLAGS=$_libcurl_save_cppflags
205 LIBS=$_libcurl_save_libs
206 unset _libcurl_save_cppflags
207 unset _libcurl_save_libs
208
209 AC_DEFINE(HAVE_LIBCURL,1,
210 [Define to 1 if you have a functional curl library.])
211 AC_SUBST(LIBCURL_CPPFLAGS)
212 AC_SUBST(LIBCURL)
213
214 for _libcurl_feature in $_libcurl_features ; do
215 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
216 eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
217 done
218
219 if test "x$_libcurl_protocols" = "x" ; then
220
221 # We don't have --protocols, so just assume that all
222 # protocols are available
223 _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
224
225 if test x$libcurl_feature_SSL = xyes ; then
226 _libcurl_protocols="$_libcurl_protocols HTTPS"
227
228 # FTPS wasn't standards-compliant until version
229 # 7.11.0 (0x070b00 == 461568)
230 if test $_libcurl_version -ge 461568; then
231 _libcurl_protocols="$_libcurl_protocols FTPS"
232 fi
233 fi
234
235 # RTSP, IMAP, POP3 and SMTP were added in
236 # 7.20.0 (0x071400 == 463872)
237 if test $_libcurl_version -ge 463872; then
238 _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
239 fi
240 fi
241
242 for _libcurl_protocol in $_libcurl_protocols ; do
243 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
244 eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
245 done
246 else
247 unset LIBCURL
248 unset LIBCURL_CPPFLAGS
249 fi
250 fi
251
252 unset _libcurl_try_link
253 unset _libcurl_version_parse
254 unset _libcurl_config
255 unset _libcurl_feature
256 unset _libcurl_features
257 unset _libcurl_protocol
258 unset _libcurl_protocols
259 unset _libcurl_version
260 unset _libcurl_ldflags
261 fi
262
263 if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
264 # This is the IF-NO path
265 ifelse([$4],,:,[$4])
266 else
267 # This is the IF-YES path
268 ifelse([$3],,:,[$3])
269 fi
270
271 unset _libcurl_with
272])dnl
diff --git a/m4/np_mysqlclient.m4 b/m4/np_mysqlclient.m4
index c2a4d2a7..9fe38ac9 100644
--- a/m4/np_mysqlclient.m4
+++ b/m4/np_mysqlclient.m4
@@ -13,7 +13,7 @@ dnl np_mysql_libs = flags for libs, from mysql_config --libs
13dnl np_mysql_cflags = flags for cflags, from mysql_config --cflags 13dnl np_mysql_cflags = flags for cflags, from mysql_config --cflags
14dnl Also sets in config.h: 14dnl Also sets in config.h:
15dnl HAVE_MYSQLCLIENT 15dnl HAVE_MYSQLCLIENT
16dnl Copile your code with: 16dnl Compile your code with:
17dnl $(CC) $(np_mysql_include) code.c $(np_mysql_libs) 17dnl $(CC) $(np_mysql_include) code.c $(np_mysql_libs)
18 18
19AC_DEFUN([np_mysqlclient], 19AC_DEFUN([np_mysqlclient],
@@ -53,19 +53,35 @@ AC_DEFUN([np_mysqlclient],
53 _savedcppflags="$CPPFLAGS" 53 _savedcppflags="$CPPFLAGS"
54 CPPFLAGS="$CPPFLAGS $np_mysql_include" 54 CPPFLAGS="$CPPFLAGS $np_mysql_include"
55 55
56 dnl Putting $np_mysql_libs as other libraries ensures that all mysql dependencies are linked in 56 np_check_lib_mysqlclient
57 dnl Although -lmysqlclient is duplicated, it is not a problem 57
58 AC_CHECK_LIB([mysqlclient], [mysql_init], [
59 with_mysql=$np_mysql_config
60 AC_DEFINE(HAVE_MYSQLCLIENT, 1, [Defined if mysqlclient is found and can compile])
61 ], [with_mysql=no], [$np_mysql_libs])
62 CPPFLAGS=$_savedcppflags 58 CPPFLAGS=$_savedcppflags
63 59
64 fi 60 fi
65 fi 61 fi
66]) 62])
67 63
68dnl Will take $1, find last occurrance of -LDIR and add DIR to LD_RUN_PATH 64dnl Test mysql_init using mysqlclient
65AC_DEFUN([np_check_lib_mysqlclient],
66[
67 dnl Putting $np_mysql_libs as other libraries ensures that all mysql dependencies are linked in
68 dnl Although -lmysqlclient is duplicated, it is not a problem
69 AC_CHECK_LIB([mysqlclient], [mysql_init], [
70 with_mysql=$np_mysql_config
71 AC_DEFINE(HAVE_MYSQLCLIENT, 1, [Defined if mysqlclient is found and can compile])
72 ], [np_check_lib_mariadbclient], [$np_mysql_libs])
73])
74
75dnl Test mysql_init using mariadbclient
76AC_DEFUN([np_check_lib_mariadbclient],
77[
78 AC_CHECK_LIB([mariadbclient], [mysql_init], [
79 with_mysql=$np_mysql_config
80 AC_DEFINE(HAVE_MYSQLCLIENT, 1, [Defined if mariadbclient is found and can compile])
81 ], [with_mysql=no], [$np_mysql_libs])
82])
83
84dnl Will take $1, find last occurrence of -LDIR and add DIR to LD_RUN_PATH
69AC_DEFUN([np_add_to_runpath], 85AC_DEFUN([np_add_to_runpath],
70[ 86[
71 dnl Need [[ ]] so autoconf gives us just one set 87 dnl Need [[ ]] so autoconf gives us just one set
diff --git a/m4/uriparser.m4 b/m4/uriparser.m4
new file mode 100644
index 00000000..5113638f
--- /dev/null
+++ b/m4/uriparser.m4
@@ -0,0 +1,140 @@
1# (this check is roughly based on and inspired libcurl.m4)
2# URIPARSER_CHECK ([DEFAULT-ACTION], [MINIMUM-VERSION],
3# [ACTION-IF-YES], [ACTION-IF-NO])
4# Checks for uriparser library. DEFAULT-ACTION is the string yes or no to
5# specify whether to default to --with-uriparser or --without-liburiparser.
6# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
7# minimum version of uriparser to accept. Pass the version as a regular
8# version number like 0.8.5. If not supplied, any version is
9# accepted. ACTION-IF-YES is a list of shell commands to run if
10# uriparser was successfully found and passed the various tests.
11# ACTION-IF-NO is a list of shell commands that are run otherwise.
12# Note that using --without-uriparser does run ACTION-IF-NO.
13#
14# This macro #defines HAVE_URIPARSER if a working uriparser setup is
15# found, and sets @URIPARSER@ and @URIPARSER_CPPFLAGS@ to the necessary
16# values.
17#
18# Users may override the detected values by doing something like:
19# URIPARSER="-luriparser" URIPARSER_CPPFLAGS="-I/usr/myinclude" ./configure
20#
21
22AC_DEFUN([URIPARSER_CHECK],
23[
24 AC_ARG_WITH(uriparser,
25 AS_HELP_STRING([--with-uriparser=PREFIX],[look for the uriparser library in PREFIX/lib and headers in PREFIX/include]),
26 [_uriparser_with=$withval],[_uriparser_with=ifelse([$1],,[yes],[$1])])
27
28 if test "$_uriparser_with" != "no" ; then
29
30 _uriparser_try_link=yes
31
32 AC_CHECK_PROG(PKGCONFIG,pkg-config,pkg-config,no)
33
34 if test "x$URIPARSER" != "x" || test "x$URIPARSER_CPPFLAGS" != "x"; then
35 :
36 elif test -d "$_uriparser_with" ; then
37 URIPARSER_CPPFLAGS="-I$withval/include"
38 _uriparser_ldflags="-L$withval/lib"
39
40 elif test x$PKGCONFIG != xno; then
41
42 AC_CACHE_CHECK([for the version of uriparser],
43 [uriparser_cv_uriparser_version],
44 [uriparser_cv_uriparser_version=`$PKGCONFIG liburiparser --modversion`])
45
46 AC_PROG_AWK
47
48 _uriparser_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
49
50 _uriparser_version=`echo $uriparser_cv_uriparser_version | $_uriparser_version_parse`
51 _uriparser_wanted=`echo ifelse([$2],,[0],[$2]) | $_uriparser_version_parse`
52
53 if test $_uriparser_wanted -gt 0 ; then
54 AC_CACHE_CHECK([for uriparser >= version $2],
55 [uriparser_cv_lib_version_ok],
56 [
57 if test $_uriparser_version -ge $_uriparser_wanted ; then
58 uriparser_cv_lib_version_ok=yes
59 else
60 uriparser_cv_lib_version_ok=no
61 fi
62 ])
63 fi
64
65 if test $_uriparser_wanted -eq 0 || test x$uriparser_cv_lib_version_ok = xyes ; then
66 if test x"$URIPARSER_CPPFLAGS" = "x" ; then
67 URIPARSER_CPPFLAGS=`$PKGCONFIG liburiparser --cflags`
68 fi
69 if test x"$URIPARSER" = "x" ; then
70 URIPARSER=`$PKGCONFIG liburiparser --libs`
71 fi
72 else
73 _uriparser_try_link=no
74 fi
75
76 unset _uriparser_wanted
77 else
78 dnl no pkg-config, ok, do our best and set some defaults
79 URIPARSER_CPPFLAGS="-I/usr/include"
80 URIPARSER="-luriparser -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i686-linux-gnu"
81 fi
82
83 if test $_uriparser_try_link = yes ; then
84
85 # let's see if the user-supplied
86 # link line (or failing that, "-luriparser") is enough.
87 URIPARSER=${URIPARSER-"$_uriparser_ldflags -luriparser"}
88
89 AC_CACHE_CHECK([whether uriparser is usable],
90 [uriparser_cv_lib_uriparser_usable],
91 [
92 _liburiparser_save_cppflags=$CPPFLAGS
93 CPPFLAGS="$URIPARSER_CPPFLAGS $CPPFLAGS"
94 _liburiparser_save_libs=$LIBS
95 LIBS="$URIPARSER $LIBS"
96
97 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <uriparser/Uri.h>]],[[
98/* Try and use a few common options to force a failure if we are
99 missing symbols or cannot link. */
100UriParserStateA state;
101UriUriA uri;
102state.uri = &uri;
103char *location = "http://test.dom/dir/file.ext";
104int x = uriParseUriA (&state, location);
105if (x == URI_SUCCESS) {;}
106]])],uriparser_cv_lib_uriparser_usable=yes,uriparser_cv_lib_uriparser_usable=no)
107
108 CPPFLAGS=$_liburiparser_save_cppflags
109 LIBS=$_liburiparser_save_libs
110 unset _liburiparser_save_cppflags
111 unset _liburiparser_save_libs
112 ])
113
114 if test $uriparser_cv_lib_uriparser_usable = yes ; then
115 AC_DEFINE(HAVE_URIPARSER,1,
116 [Define to 1 if you have a functional uriparser library.])
117 AC_SUBST(URIPARSER_CPPFLAGS)
118 AC_SUBST(URIPARSER)
119 else
120 unset URIPARSER
121 unset URIPARSER_CPPFLAGS
122 fi
123 fi
124
125 unset _uriparser_try_link
126 unset _uriparser_version_parse
127 unset _uriparser_version
128 unset _uriparser_ldflags
129 fi
130
131 if test x$_uriparser_with = xno || test x$uriparser_cv_lib_uriparser_usable != xyes ; then
132 # This is the IF-NO path
133 ifelse([$4],,:,[$4])
134 else
135 # This is the IF-YES path
136 ifelse([$3],,:,[$3])
137 fi
138
139 unset _uriparser_with
140])dnl
diff --git a/pkg/solaris/solpkg b/pkg/solaris/solpkg
index a21176e4..73b3c647 100755
--- a/pkg/solaris/solpkg
+++ b/pkg/solaris/solpkg
@@ -9,7 +9,7 @@ $pkgtrans = "/usr/bin/pkgtrans";
9$prototype = "prototype"; 9$prototype = "prototype";
10$pkginfo = "pkginfo"; 10$pkginfo = "pkginfo";
11$preinstall = "preinstall"; 11$preinstall = "preinstall";
12$egrep = "/usr/bin/egrep"; 12$egrep = "/usr/bin/grep -E";
13 13
14# Sanity check 14# Sanity check
15 15
diff --git a/plugins-root/Makefile.am b/plugins-root/Makefile.am
index a1ebb6d2..40aa020d 100644
--- a/plugins-root/Makefile.am
+++ b/plugins-root/Makefile.am
@@ -26,7 +26,7 @@ EXTRA_PROGRAMS = pst3
26 26
27EXTRA_DIST = t pst3.c 27EXTRA_DIST = t pst3.c
28 28
29BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a 29BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO)
30NETOBJS = ../plugins/netutils.o $(BASEOBJS) $(EXTRA_NETOBJS) 30NETOBJS = ../plugins/netutils.o $(BASEOBJS) $(EXTRA_NETOBJS)
31NETLIBS = $(NETOBJS) $(SOCKETLIBS) 31NETLIBS = $(NETOBJS) $(SOCKETLIBS)
32 32
@@ -37,6 +37,9 @@ TESTS = @PLUGIN_TEST@
37test: 37test:
38 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl 38 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl
39 39
40test-debug:
41 NPTEST_DEBUG=1 HARNESS_VERBOSE=1 perl -I $(top_builddir) -I $(top_srcdir) ../test.pl
42
40setuid_root_mode = ug=rx,u+s 43setuid_root_mode = ug=rx,u+s
41 44
42# /* Author Coreutils team - see ACKNOWLEDGEMENTS */ 45# /* Author Coreutils team - see ACKNOWLEDGEMENTS */
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index d8afb172..0ddace5b 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -1,40 +1,40 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2 *
3* Monitoring check_dhcp plugin 3 * Monitoring check_dhcp plugin
4* 4 *
5* License: GPL 5 * License: GPL
6* Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org) 6 * Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)
7* Copyright (c) 2001-2007 Monitoring Plugins Development Team 7 * Copyright (c) 2001-2007 Monitoring Plugins Development Team
8* 8 *
9* Description: 9 * Description:
10* 10 *
11* This file contains the check_dhcp plugin 11 * This file contains the check_dhcp plugin
12* 12 *
13* This plugin tests the availability of DHCP servers on a network. 13 * This plugin tests the availability of DHCP servers on a network.
14* 14 *
15* Unicast mode was originally implemented by Heiti of Boras Kommun with 15 * Unicast mode was originally implemented by Heiti of Boras Kommun with
16* general improvements as well as usability fixes and "forward"-porting by 16 * general improvements as well as usability fixes and "forward"-porting by
17* Andreas Ericsson of OP5 AB. 17 * Andreas Ericsson of OP5 AB.
18* 18 *
19* 19 *
20* This program is free software: you can redistribute it and/or modify 20 * This program is free software: you can redistribute it and/or modify
21* it under the terms of the GNU General Public License as published by 21 * it under the terms of the GNU General Public License as published by
22* the Free Software Foundation, either version 3 of the License, or 22 * the Free Software Foundation, either version 3 of the License, or
23* (at your option) any later version. 23 * (at your option) any later version.
24* 24 *
25* This program is distributed in the hope that it will be useful, 25 * This program is distributed in the hope that it will be useful,
26* but WITHOUT ANY WARRANTY; without even the implied warranty of 26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28* GNU General Public License for more details. 28 * GNU General Public License for more details.
29* 29 *
30* You should have received a copy of the GNU General Public License 30 * You should have received a copy of the GNU General Public License
31* along with this program. If not, see <http://www.gnu.org/licenses/>. 31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32* 32 *
33* 33 *
34*****************************************************************************/ 34 *****************************************************************************/
35 35
36const char *progname = "check_dhcp"; 36const char *progname = "check_dhcp";
37const char *copyright = "2001-2007"; 37const char *copyright = "2001-2023";
38const char *email = "devel@monitoring-plugins.org"; 38const char *email = "devel@monitoring-plugins.org";
39 39
40#include "common.h" 40#include "common.h"
@@ -57,9 +57,10 @@ const char *email = "devel@monitoring-plugins.org";
57#include <netinet/in.h> 57#include <netinet/in.h>
58#include <net/if.h> 58#include <net/if.h>
59#include <arpa/inet.h> 59#include <arpa/inet.h>
60
60#if HAVE_SYS_SOCKIO_H 61#if HAVE_SYS_SOCKIO_H
61#include <sys/sockio.h> 62#include <sys/sockio.h>
62#endif 63#endif // HAVE_SYS_SOCKIO_H
63 64
64#if defined( __linux__ ) 65#if defined( __linux__ )
65 66
@@ -98,10 +99,6 @@ static struct strbuf dat = {AREA_SZ, 0, (char *)dat_area};
98#define GOT_INTR 4 99#define GOT_INTR 4
99#define GOT_ERR 128 100#define GOT_ERR 128
100 101
101#define u_int8_t uint8_t
102#define u_int16_t uint16_t
103#define u_int32_t uint32_t
104
105static int get_msg(int); 102static int get_msg(int);
106static int check_ctrl(int); 103static int check_ctrl(int);
107static int put_ctrl(int, int, int); 104static int put_ctrl(int, int, int);
@@ -110,7 +107,7 @@ static int dl_open(const char *, int, int *);
110static int dl_bind(int, int, u_char *); 107static int dl_bind(int, int, u_char *);
111long mac_addr_dlpi( const char *, int, u_char *); 108long mac_addr_dlpi( const char *, int, u_char *);
112 109
113#endif 110#endif // __sun__ || __solaris__ || __hpux
114 111
115 112
116 113
@@ -119,9 +116,6 @@ long mac_addr_dlpi( const char *, int, u_char *);
119#define OK 0 116#define OK 0
120#define ERROR -1 117#define ERROR -1
121 118
122#define FALSE 0
123#define TRUE 1
124
125 119
126/**** DHCP definitions ****/ 120/**** DHCP definitions ****/
127 121
@@ -132,39 +126,39 @@ long mac_addr_dlpi( const char *, int, u_char *);
132 126
133 127
134typedef struct dhcp_packet_struct{ 128typedef struct dhcp_packet_struct{
135 u_int8_t op; /* packet type */ 129 uint8_t op; /* packet type */
136 u_int8_t htype; /* type of hardware address for this machine (Ethernet, etc) */ 130 uint8_t htype; /* type of hardware address for this machine (Ethernet, etc) */
137 u_int8_t hlen; /* length of hardware address (of this machine) */ 131 uint8_t hlen; /* length of hardware address (of this machine) */
138 u_int8_t hops; /* hops */ 132 uint8_t hops; /* hops */
139 u_int32_t xid; /* random transaction id number - chosen by this machine */ 133 uint32_t xid; /* random transaction id number - chosen by this machine */
140 u_int16_t secs; /* seconds used in timing */ 134 uint16_t secs; /* seconds used in timing */
141 u_int16_t flags; /* flags */ 135 uint16_t flags; /* flags */
142 struct in_addr ciaddr; /* IP address of this machine (if we already have one) */ 136 struct in_addr ciaddr; /* IP address of this machine (if we already have one) */
143 struct in_addr yiaddr; /* IP address of this machine (offered by the DHCP server) */ 137 struct in_addr yiaddr; /* IP address of this machine (offered by the DHCP server) */
144 struct in_addr siaddr; /* IP address of next server */ 138 struct in_addr siaddr; /* IP address of next server */
145 struct in_addr giaddr; /* IP address of DHCP relay */ 139 struct in_addr giaddr; /* IP address of DHCP relay */
146 unsigned char chaddr [MAX_DHCP_CHADDR_LENGTH]; /* hardware address of this machine */ 140 unsigned char chaddr [MAX_DHCP_CHADDR_LENGTH]; /* hardware address of this machine */
147 char sname [MAX_DHCP_SNAME_LENGTH]; /* name of DHCP server */ 141 char sname [MAX_DHCP_SNAME_LENGTH]; /* name of DHCP server */
148 char file [MAX_DHCP_FILE_LENGTH]; /* boot file name (used for diskless booting?) */ 142 char file [MAX_DHCP_FILE_LENGTH]; /* boot file name (used for diskless booting?) */
149 char options[MAX_DHCP_OPTIONS_LENGTH]; /* options */ 143 char options[MAX_DHCP_OPTIONS_LENGTH]; /* options */
150 }dhcp_packet; 144}dhcp_packet;
151 145
152 146
153typedef struct dhcp_offer_struct{ 147typedef struct dhcp_offer_struct{
154 struct in_addr server_address; /* address of DHCP server that sent this offer */ 148 struct in_addr server_address; /* address of DHCP server that sent this offer */
155 struct in_addr offered_address; /* the IP address that was offered to us */ 149 struct in_addr offered_address; /* the IP address that was offered to us */
156 u_int32_t lease_time; /* lease time in seconds */ 150 uint32_t lease_time; /* lease time in seconds */
157 u_int32_t renewal_time; /* renewal time in seconds */ 151 uint32_t renewal_time; /* renewal time in seconds */
158 u_int32_t rebinding_time; /* rebinding time in seconds */ 152 uint32_t rebinding_time; /* rebinding time in seconds */
159 struct dhcp_offer_struct *next; 153 struct dhcp_offer_struct *next;
160 }dhcp_offer; 154}dhcp_offer;
161 155
162 156
163typedef struct requested_server_struct{ 157typedef struct requested_server_struct{
164 struct in_addr server_address; 158 struct in_addr server_address;
165 int answered; 159 bool answered;
166 struct requested_server_struct *next; 160 struct requested_server_struct *next;
167 }requested_server; 161}requested_server;
168 162
169 163
170#define BOOTREQUEST 1 164#define BOOTREQUEST 1
@@ -198,7 +192,7 @@ typedef struct requested_server_struct{
198#define ETHERNET_HARDWARE_ADDRESS 1 /* used in htype field of dhcp packet */ 192#define ETHERNET_HARDWARE_ADDRESS 1 /* used in htype field of dhcp packet */
199#define ETHERNET_HARDWARE_ADDRESS_LENGTH 6 /* length of Ethernet hardware addresses */ 193#define ETHERNET_HARDWARE_ADDRESS_LENGTH 6 /* length of Ethernet hardware addresses */
200 194
201u_int8_t unicast = 0; /* unicast mode: mimic a DHCP relay */ 195uint8_t unicast = 0; /* unicast mode: mimic a DHCP relay */
202struct in_addr my_ip; /* our address (required for relay) */ 196struct in_addr my_ip; /* our address (required for relay) */
203struct in_addr dhcp_ip; /* server to query (if in unicast mode) */ 197struct in_addr dhcp_ip; /* server to query (if in unicast mode) */
204unsigned char client_hardware_address[MAX_DHCP_CHADDR_LENGTH]=""; 198unsigned char client_hardware_address[MAX_DHCP_CHADDR_LENGTH]="";
@@ -206,11 +200,11 @@ unsigned char *user_specified_mac=NULL;
206 200
207char network_interface_name[IFNAMSIZ]="eth0"; 201char network_interface_name[IFNAMSIZ]="eth0";
208 202
209u_int32_t packet_xid=0; 203uint32_t packet_xid=0;
210 204
211u_int32_t dhcp_lease_time=0; 205uint32_t dhcp_lease_time=0;
212u_int32_t dhcp_renewal_time=0; 206uint32_t dhcp_renewal_time=0;
213u_int32_t dhcp_rebinding_time=0; 207uint32_t dhcp_rebinding_time=0;
214 208
215int dhcpoffer_timeout=2; 209int dhcpoffer_timeout=2;
216 210
@@ -221,15 +215,15 @@ int valid_responses=0; /* number of valid DHCPOFFERs we received */
221int requested_servers=0; 215int requested_servers=0;
222int requested_responses=0; 216int requested_responses=0;
223 217
224int request_specific_address=FALSE; 218bool request_specific_address=false;
225int received_requested_address=FALSE; 219bool received_requested_address=false;
226int verbose=0; 220int verbose=0;
227struct in_addr requested_address; 221struct in_addr requested_address;
228 222
229 223
230int process_arguments(int, char **); 224int process_arguments(int, char **);
231int call_getopt(int, char **); 225int call_getopt(int, char **);
232int validate_arguments(int, int); 226int validate_arguments(int);
233void print_usage(void); 227void print_usage(void);
234void print_help(void); 228void print_help(void);
235 229
@@ -268,7 +262,7 @@ int main(int argc, char **argv){
268 262
269 if(process_arguments(argc,argv)!=OK){ 263 if(process_arguments(argc,argv)!=OK){
270 usage4 (_("Could not parse arguments")); 264 usage4 (_("Could not parse arguments"));
271 } 265 }
272 266
273 /* create socket for DHCP communications */ 267 /* create socket for DHCP communications */
274 dhcp_socket=create_dhcp_socket(); 268 dhcp_socket=create_dhcp_socket();
@@ -299,7 +293,7 @@ int main(int argc, char **argv){
299 free_requested_server_list(); 293 free_requested_server_list();
300 294
301 return result; 295 return result;
302 } 296}
303 297
304 298
305 299
@@ -314,82 +308,83 @@ int get_hardware_address(int sock,char *interface_name){
314 308
315 /* try and grab hardware address of requested interface */ 309 /* try and grab hardware address of requested interface */
316 if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){ 310 if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){
317 printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name); 311 printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name);
318 exit(STATE_UNKNOWN); 312 exit(STATE_UNKNOWN);
319 } 313 }
320 314
321 memcpy(&client_hardware_address[0],&ifr.ifr_hwaddr.sa_data,6); 315 memcpy(&client_hardware_address[0],&ifr.ifr_hwaddr.sa_data,6);
322 316
323#elif defined(__bsd__) 317#elif defined(__bsd__)
324 /* King 2004 see ACKNOWLEDGEMENTS */ 318 /* King 2004 see ACKNOWLEDGEMENTS */
325 319
326 int mib[6], len; 320 size_t len;
327 char *buf; 321 int mib[6];
328 unsigned char *ptr; 322 char *buf;
329 struct if_msghdr *ifm; 323 unsigned char *ptr;
330 struct sockaddr_dl *sdl; 324 struct if_msghdr *ifm;
331 325 struct sockaddr_dl *sdl;
332 mib[0] = CTL_NET; 326
333 mib[1] = AF_ROUTE; 327 mib[0] = CTL_NET;
334 mib[2] = 0; 328 mib[1] = AF_ROUTE;
335 mib[3] = AF_LINK; 329 mib[2] = 0;
336 mib[4] = NET_RT_IFLIST; 330 mib[3] = AF_LINK;
337 331 mib[4] = NET_RT_IFLIST;
338 if((mib[5] = if_nametoindex(interface_name)) == 0){ 332
339 printf(_("Error: if_nametoindex error - %s.\n"), strerror(errno)); 333 if((mib[5] = if_nametoindex(interface_name)) == 0){
340 exit(STATE_UNKNOWN); 334 printf(_("Error: if_nametoindex error - %s.\n"), strerror(errno));
341 } 335 exit(STATE_UNKNOWN);
336 }
342 337
343 if(sysctl(mib, 6, NULL, &len, NULL, 0) < 0){ 338 if(sysctl(mib, 6, NULL, &len, NULL, 0) < 0){
344 printf(_("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"), interface_name, strerror(errno)); 339 printf(_("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"), interface_name, strerror(errno));
345 exit(STATE_UNKNOWN); 340 exit(STATE_UNKNOWN);
346 } 341 }
347 342
348 if((buf = malloc(len)) == NULL){ 343 if((buf = malloc(len)) == NULL){
349 printf(_("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"), interface_name, strerror(errno)); 344 printf(_("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"), interface_name, strerror(errno));
350 exit(4); 345 exit(4);
351 } 346 }
352 347
353 if(sysctl(mib, 6, buf, &len, NULL, 0) < 0){ 348 if(sysctl(mib, 6, buf, &len, NULL, 0) < 0){
354 printf(_("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"), interface_name, strerror(errno)); 349 printf(_("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"), interface_name, strerror(errno));
355 exit(STATE_UNKNOWN); 350 exit(STATE_UNKNOWN);
356 } 351 }
357 352
358 ifm = (struct if_msghdr *)buf; 353 ifm = (struct if_msghdr *)buf;
359 sdl = (struct sockaddr_dl *)(ifm + 1); 354 sdl = (struct sockaddr_dl *)(ifm + 1);
360 ptr = (unsigned char *)LLADDR(sdl); 355 ptr = (unsigned char *)LLADDR(sdl);
361 memcpy(&client_hardware_address[0], ptr, 6) ; 356 memcpy(&client_hardware_address[0], ptr, 6) ;
362 /* King 2004 */ 357 /* King 2004 */
363 358
364#elif defined(__sun__) || defined(__solaris__) 359#elif defined(__sun__) || defined(__solaris__)
365 360
366 /* Kompf 2000-2003 see ACKNOWLEDGEMENTS */ 361 /* Kompf 2000-2003 see ACKNOWLEDGEMENTS */
367 long stat; 362 long stat;
368 char dev[20] = "/dev/"; 363 char dev[20] = "/dev/";
369 char *p; 364 char *p;
370 int unit; 365 int unit;
371 366
372 /* get last number from interfacename, eg lnc0, e1000g0*/ 367 /* get last number from interfacename, eg lnc0, e1000g0*/
373 int i; 368 int i;
374 p = interface_name + strlen(interface_name) -1; 369 p = interface_name + strlen(interface_name) -1;
375 for(i = strlen(interface_name) -1; i > 0; p--) { 370 for(i = strlen(interface_name) -1; i > 0; p--) {
376 if(isalpha(*p)) 371 if(isalpha(*p))
377 break; 372 break;
378 } 373 }
379 p++; 374 p++;
380 if( p != interface_name ){ 375 if( p != interface_name ){
381 unit = atoi(p) ; 376 unit = atoi(p) ;
382 strncat(dev, interface_name, 6) ; 377 strncat(dev, interface_name, 6) ;
383 } 378 }
384 else{ 379 else{
385 printf(_("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n"), interface_name); 380 printf(_("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n"), interface_name);
386 exit(STATE_UNKNOWN); 381 exit(STATE_UNKNOWN);
387 } 382 }
388 stat = mac_addr_dlpi(dev, unit, client_hardware_address); 383 stat = mac_addr_dlpi(dev, unit, client_hardware_address);
389 if(stat != 0){ 384 if(stat != 0){
390 printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit); 385 printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
391 exit(STATE_UNKNOWN); 386 exit(STATE_UNKNOWN);
392 } 387 }
393 388
394#elif defined(__hpux__) 389#elif defined(__hpux__)
395 390
@@ -401,8 +396,8 @@ int get_hardware_address(int sock,char *interface_name){
401 if(stat != 0){ 396 if(stat != 0){
402 printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit); 397 printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
403 exit(STATE_UNKNOWN); 398 exit(STATE_UNKNOWN);
404 } 399 }
405 /* Kompf 2000-2003 */ 400 /* Kompf 2000-2003 */
406 401
407#else 402#else
408 printf(_("Error: can't get MAC address for this architecture. Use the --mac option.\n")); 403 printf(_("Error: can't get MAC address for this architecture. Use the --mac option.\n"));
@@ -413,7 +408,7 @@ int get_hardware_address(int sock,char *interface_name){
413 print_hardware_address(client_hardware_address); 408 print_hardware_address(client_hardware_address);
414 409
415 return OK; 410 return OK;
416 } 411}
417 412
418/* determines IP address of the client interface */ 413/* determines IP address of the client interface */
419int get_ip_address(int sock,char *interface_name){ 414int get_ip_address(int sock,char *interface_name){
@@ -425,9 +420,9 @@ int get_ip_address(int sock,char *interface_name){
425 420
426 if(ioctl(sock,SIOCGIFADDR,&ifr)<0){ 421 if(ioctl(sock,SIOCGIFADDR,&ifr)<0){
427 printf(_("Error: Cannot determine IP address of interface %s\n"), 422 printf(_("Error: Cannot determine IP address of interface %s\n"),
428 interface_name); 423 interface_name);
429 exit(STATE_UNKNOWN); 424 exit(STATE_UNKNOWN);
430 } 425 }
431 426
432 my_ip=((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr; 427 my_ip=((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr;
433 428
@@ -440,13 +435,13 @@ int get_ip_address(int sock,char *interface_name){
440 printf(_("Pretending to be relay client %s\n"),inet_ntoa(my_ip)); 435 printf(_("Pretending to be relay client %s\n"),inet_ntoa(my_ip));
441 436
442 return OK; 437 return OK;
443 } 438}
444 439
445/* sends a DHCPDISCOVER broadcast message in an attempt to find DHCP servers */ 440/* sends a DHCPDISCOVER broadcast message in an attempt to find DHCP servers */
446int send_dhcp_discover(int sock){ 441int send_dhcp_discover(int sock){
447 dhcp_packet discover_packet; 442 dhcp_packet discover_packet;
448 struct sockaddr_in sockaddr_broadcast; 443 struct sockaddr_in sockaddr_broadcast;
449 unsigned short opts; 444 unsigned short opts;
450 445
451 446
452 /* clear the packet data structure */ 447 /* clear the packet data structure */
@@ -463,17 +458,12 @@ int send_dhcp_discover(int sock){
463 discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH; 458 discover_packet.hlen=ETHERNET_HARDWARE_ADDRESS_LENGTH;
464 459
465 /* 460 /*
466 * transaction ID is supposed to be random. We won't use the address so 461 * transaction ID is supposed to be random.
467 * we don't care about high entropy here. time(2) is good enough.
468 */ 462 */
469 srand(time(NULL)); 463 srand(time(NULL)^getpid());
470 packet_xid=random(); 464 packet_xid=random();
471 discover_packet.xid=htonl(packet_xid); 465 discover_packet.xid=htonl(packet_xid);
472 466
473 /**** WHAT THE HECK IS UP WITH THIS?!? IF I DON'T MAKE THIS CALL, ONLY ONE SERVER RESPONSE IS PROCESSED!!!! ****/
474 /* downright bizzarre... */
475 ntohl(discover_packet.xid);
476
477 /*discover_packet.secs=htons(65535);*/ 467 /*discover_packet.secs=htons(65535);*/
478 discover_packet.secs=0xFF; 468 discover_packet.secs=0xFF;
479 469
@@ -492,19 +482,19 @@ int send_dhcp_discover(int sock){
492 discover_packet.options[2]='\x53'; 482 discover_packet.options[2]='\x53';
493 discover_packet.options[3]='\x63'; 483 discover_packet.options[3]='\x63';
494 484
495 opts = 4; 485 opts = 4;
496 /* DHCP message type is embedded in options field */ 486 /* DHCP message type is embedded in options field */
497 discover_packet.options[opts++]=DHCP_OPTION_MESSAGE_TYPE; /* DHCP message type option identifier */ 487 discover_packet.options[opts++]=DHCP_OPTION_MESSAGE_TYPE; /* DHCP message type option identifier */
498 discover_packet.options[opts++]='\x01'; /* DHCP message option length in bytes */ 488 discover_packet.options[opts++]='\x01'; /* DHCP message option length in bytes */
499 discover_packet.options[opts++]=DHCPDISCOVER; 489 discover_packet.options[opts++]=DHCPDISCOVER;
500 490
501 /* the IP address we're requesting */ 491 /* the IP address we're requesting */
502 if(request_specific_address==TRUE){ 492 if(request_specific_address){
503 discover_packet.options[opts++]=DHCP_OPTION_REQUESTED_ADDRESS; 493 discover_packet.options[opts++]=DHCP_OPTION_REQUESTED_ADDRESS;
504 discover_packet.options[opts++]='\x04'; 494 discover_packet.options[opts++]='\x04';
505 memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address)); 495 memcpy(&discover_packet.options[opts],&requested_address,sizeof(requested_address));
506 opts += sizeof(requested_address); 496 opts += sizeof(requested_address);
507 } 497 }
508 discover_packet.options[opts++]=DHCP_OPTION_END; 498 discover_packet.options[opts++]=DHCP_OPTION_END;
509 499
510 /* unicast fields */ 500 /* unicast fields */
@@ -515,8 +505,8 @@ int send_dhcp_discover(int sock){
515 discover_packet.hops = unicast ? 1 : 0; 505 discover_packet.hops = unicast ? 1 : 0;
516 506
517 /* send the DHCPDISCOVER packet to broadcast address */ 507 /* send the DHCPDISCOVER packet to broadcast address */
518 sockaddr_broadcast.sin_family=AF_INET; 508 sockaddr_broadcast.sin_family=AF_INET;
519 sockaddr_broadcast.sin_port=htons(DHCP_SERVER_PORT); 509 sockaddr_broadcast.sin_port=htons(DHCP_SERVER_PORT);
520 sockaddr_broadcast.sin_addr.s_addr = unicast ? dhcp_ip.s_addr : INADDR_BROADCAST; 510 sockaddr_broadcast.sin_addr.s_addr = unicast ? dhcp_ip.s_addr : INADDR_BROADCAST;
521 bzero(&sockaddr_broadcast.sin_zero,sizeof(sockaddr_broadcast.sin_zero)); 511 bzero(&sockaddr_broadcast.sin_zero,sizeof(sockaddr_broadcast.sin_zero));
522 512
@@ -528,7 +518,7 @@ int send_dhcp_discover(int sock){
528 printf("DHCDISCOVER yiaddr: %s\n",inet_ntoa(discover_packet.yiaddr)); 518 printf("DHCDISCOVER yiaddr: %s\n",inet_ntoa(discover_packet.yiaddr));
529 printf("DHCDISCOVER siaddr: %s\n",inet_ntoa(discover_packet.siaddr)); 519 printf("DHCDISCOVER siaddr: %s\n",inet_ntoa(discover_packet.siaddr));
530 printf("DHCDISCOVER giaddr: %s\n",inet_ntoa(discover_packet.giaddr)); 520 printf("DHCDISCOVER giaddr: %s\n",inet_ntoa(discover_packet.giaddr));
531 } 521 }
532 522
533 /* send the DHCPDISCOVER packet out */ 523 /* send the DHCPDISCOVER packet out */
534 send_dhcp_packet(&discover_packet,sizeof(discover_packet),sock,&sockaddr_broadcast); 524 send_dhcp_packet(&discover_packet,sizeof(discover_packet),sock,&sockaddr_broadcast);
@@ -537,7 +527,7 @@ int send_dhcp_discover(int sock){
537 printf("\n\n"); 527 printf("\n\n");
538 528
539 return OK; 529 return OK;
540 } 530}
541 531
542 532
543 533
@@ -577,13 +567,13 @@ int get_dhcp_offer(int sock){
577 printf(_("Result=ERROR\n")); 567 printf(_("Result=ERROR\n"));
578 568
579 continue; 569 continue;
580 } 570 }
581 else{ 571 else{
582 if(verbose) 572 if(verbose)
583 printf(_("Result=OK\n")); 573 printf(_("Result=OK\n"));
584 574
585 responses++; 575 responses++;
586 } 576 }
587 577
588 /* The "source" is either a server or a relay. */ 578 /* The "source" is either a server or a relay. */
589 /* Save a copy of "source" into "via" even if it's via itself */ 579 /* Save a copy of "source" into "via" even if it's via itself */
@@ -593,7 +583,7 @@ int get_dhcp_offer(int sock){
593 printf(_("DHCPOFFER from IP address %s"),inet_ntoa(source.sin_addr)); 583 printf(_("DHCPOFFER from IP address %s"),inet_ntoa(source.sin_addr));
594 printf(_(" via %s\n"),inet_ntoa(via.sin_addr)); 584 printf(_(" via %s\n"),inet_ntoa(via.sin_addr));
595 printf("DHCPOFFER XID: %u (0x%X)\n",ntohl(offer_packet.xid),ntohl(offer_packet.xid)); 585 printf("DHCPOFFER XID: %u (0x%X)\n",ntohl(offer_packet.xid),ntohl(offer_packet.xid));
596 } 586 }
597 587
598 /* check packet xid to see if its the same as the one we used in the discover packet */ 588 /* check packet xid to see if its the same as the one we used in the discover packet */
599 if(ntohl(offer_packet.xid)!=packet_xid){ 589 if(ntohl(offer_packet.xid)!=packet_xid){
@@ -601,7 +591,7 @@ int get_dhcp_offer(int sock){
601 printf(_("DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"),ntohl(offer_packet.xid),packet_xid); 591 printf(_("DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"),ntohl(offer_packet.xid),packet_xid);
602 592
603 continue; 593 continue;
604 } 594 }
605 595
606 /* check hardware address */ 596 /* check hardware address */
607 result=OK; 597 result=OK;
@@ -614,7 +604,7 @@ int get_dhcp_offer(int sock){
614 604
615 if(offer_packet.chaddr[x]!=client_hardware_address[x]) 605 if(offer_packet.chaddr[x]!=client_hardware_address[x])
616 result=ERROR; 606 result=ERROR;
617 } 607 }
618 if(verbose) 608 if(verbose)
619 printf("\n"); 609 printf("\n");
620 610
@@ -623,27 +613,27 @@ int get_dhcp_offer(int sock){
623 printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n")); 613 printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n"));
624 614
625 continue; 615 continue;
626 } 616 }
627 617
628 if(verbose){ 618 if(verbose){
629 printf("DHCPOFFER ciaddr: %s\n",inet_ntoa(offer_packet.ciaddr)); 619 printf("DHCPOFFER ciaddr: %s\n",inet_ntoa(offer_packet.ciaddr));
630 printf("DHCPOFFER yiaddr: %s\n",inet_ntoa(offer_packet.yiaddr)); 620 printf("DHCPOFFER yiaddr: %s\n",inet_ntoa(offer_packet.yiaddr));
631 printf("DHCPOFFER siaddr: %s\n",inet_ntoa(offer_packet.siaddr)); 621 printf("DHCPOFFER siaddr: %s\n",inet_ntoa(offer_packet.siaddr));
632 printf("DHCPOFFER giaddr: %s\n",inet_ntoa(offer_packet.giaddr)); 622 printf("DHCPOFFER giaddr: %s\n",inet_ntoa(offer_packet.giaddr));
633 } 623 }
634 624
635 add_dhcp_offer(source.sin_addr,&offer_packet); 625 add_dhcp_offer(source.sin_addr,&offer_packet);
636 626
637 valid_responses++; 627 valid_responses++;
638 } 628 }
639 629
640 if(verbose){ 630 if(verbose){
641 printf(_("Total responses seen on the wire: %d\n"),responses); 631 printf(_("Total responses seen on the wire: %d\n"),responses);
642 printf(_("Valid responses for this machine: %d\n"),valid_responses); 632 printf(_("Valid responses for this machine: %d\n"),valid_responses);
643 } 633 }
644 634
645 return OK; 635 return OK;
646 } 636}
647 637
648 638
649 639
@@ -660,14 +650,14 @@ int send_dhcp_packet(void *buffer, int buffer_size, int sock, struct sockaddr_in
660 return ERROR; 650 return ERROR;
661 651
662 return OK; 652 return OK;
663 } 653}
664 654
665 655
666 656
667/* receives a DHCP packet */ 657/* receives a DHCP packet */
668int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, struct sockaddr_in *address){ 658int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, struct sockaddr_in *address){
669 struct timeval tv; 659 struct timeval tv;
670 fd_set readfds; 660 fd_set readfds;
671 fd_set oobfds; 661 fd_set oobfds;
672 int recv_result; 662 int recv_result;
673 socklen_t address_size; 663 socklen_t address_size;
@@ -675,94 +665,88 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
675 int nfound; 665 int nfound;
676 666
677 667
678 /* wait for data to arrive (up time timeout) */ 668 /* wait for data to arrive (up time timeout) */
679 tv.tv_sec=timeout; 669 tv.tv_sec=timeout;
680 tv.tv_usec=0; 670 tv.tv_usec=0;
681 FD_ZERO(&readfds); 671 FD_ZERO(&readfds);
682 FD_ZERO(&oobfds); 672 FD_ZERO(&oobfds);
683 FD_SET(sock,&readfds); 673 FD_SET(sock,&readfds);
684 FD_SET(sock,&oobfds); 674 FD_SET(sock,&oobfds);
685 nfound = select(sock+1,&readfds,NULL,&oobfds,&tv); 675 nfound = select(sock+1,&readfds,NULL,&oobfds,&tv);
686 676
687 /* make sure some data has arrived */ 677 /* make sure some data has arrived */
688 if(!FD_ISSET(sock,&readfds)){ 678 if(!FD_ISSET(sock,&readfds)){
689 if(verbose) 679 if(verbose)
690 printf(_("No (more) data received (nfound: %d)\n"), nfound); 680 printf(_("No (more) data received (nfound: %d)\n"), nfound);
691 return ERROR; 681 return ERROR;
692 } 682 }
693
694 else{
695 683
696 /* why do we need to peek first? i don't know, its a hack. without it, the source address of the first packet received was 684 else{
697 not being interpreted correctly. sigh... */
698 bzero(&source_address,sizeof(source_address)); 685 bzero(&source_address,sizeof(source_address));
699 address_size=sizeof(source_address); 686 address_size=sizeof(source_address);
700 recv_result=recvfrom(sock,(char *)buffer,buffer_size,MSG_PEEK,(struct sockaddr *)&source_address,&address_size); 687 recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size);
701 if(verbose) 688 if(verbose)
702 printf("recv_result_1: %d\n",recv_result); 689 printf("recv_result: %d\n",recv_result);
703 recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size);
704 if(verbose)
705 printf("recv_result_2: %d\n",recv_result);
706 690
707 if(recv_result==-1){ 691 if(recv_result==-1){
708 if(verbose){ 692 if(verbose){
709 printf(_("recvfrom() failed, ")); 693 printf(_("recvfrom() failed, "));
710 printf("errno: (%d) -> %s\n",errno,strerror(errno)); 694 printf("errno: (%d) -> %s\n",errno,strerror(errno));
711 } 695 }
712 return ERROR; 696 return ERROR;
713 } 697 }
714 else{ 698 else{
715 if(verbose){ 699 if(verbose){
716 printf(_("receive_dhcp_packet() result: %d\n"),recv_result); 700 printf(_("receive_dhcp_packet() result: %d\n"),recv_result);
717 printf(_("receive_dhcp_packet() source: %s\n"),inet_ntoa(source_address.sin_addr)); 701 printf(_("receive_dhcp_packet() source: %s\n"),inet_ntoa(source_address.sin_addr));
718 } 702 }
719 703
720 memcpy(address,&source_address,sizeof(source_address)); 704 memcpy(address,&source_address,sizeof(source_address));
721 return OK; 705 return OK;
722 } 706 }
723 } 707 }
724 708
725 return OK; 709 return OK;
726 } 710}
727 711
728 712
729/* creates a socket for DHCP communication */ 713/* creates a socket for DHCP communication */
730int create_dhcp_socket(void){ 714int create_dhcp_socket(void){
731 struct sockaddr_in myname; 715 struct sockaddr_in myname;
732 struct ifreq interface; 716 struct ifreq interface;
733 int sock; 717 int sock;
734 int flag=1; 718 int flag=1;
735 719
736 /* Set up the address we're going to bind to. */ 720 /* Set up the address we're going to bind to. */
737 bzero(&myname,sizeof(myname)); 721 bzero(&myname,sizeof(myname));
738 myname.sin_family=AF_INET; 722 myname.sin_family=AF_INET;
739 /* listen to DHCP server port if we're in unicast mode */ 723 /* listen to DHCP server port if we're in unicast mode */
740 myname.sin_port = htons(unicast ? DHCP_SERVER_PORT : DHCP_CLIENT_PORT); 724 myname.sin_port = htons(unicast ? DHCP_SERVER_PORT : DHCP_CLIENT_PORT);
741 myname.sin_addr.s_addr = unicast ? my_ip.s_addr : INADDR_ANY; 725 myname.sin_addr.s_addr = unicast ? my_ip.s_addr : INADDR_ANY;
742 bzero(&myname.sin_zero,sizeof(myname.sin_zero)); 726 bzero(&myname.sin_zero,sizeof(myname.sin_zero));
743 727
744 /* create a socket for DHCP communications */ 728 /* create a socket for DHCP communications */
745 sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); 729 sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
746 if(sock<0){ 730 if(sock<0){
747 printf(_("Error: Could not create socket!\n")); 731 printf(_("Error: Could not create socket!\n"));
748 exit(STATE_UNKNOWN); 732 exit(STATE_UNKNOWN);
749 } 733 }
750 734
751 if(verbose) 735 if(verbose)
752 printf("DHCP socket: %d\n",sock); 736 printf("DHCP socket: %d\n",sock);
753 737
754 /* set the reuse address flag so we don't get errors when restarting */ 738 /* set the reuse address flag so we don't get errors when restarting */
755 flag=1; 739 flag=1;
756 if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char *)&flag,sizeof(flag))<0){ 740 if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char *)&flag,sizeof(flag))<0){
757 printf(_("Error: Could not set reuse address option on DHCP socket!\n")); 741 printf(_("Error: Could not set reuse address option on DHCP socket!\n"));
758 exit(STATE_UNKNOWN); 742 exit(STATE_UNKNOWN);
759 } 743 }
760 744
761 /* set the broadcast option - we need this to listen to DHCP broadcast messages */ 745 /* set the broadcast option - we need this to listen to DHCP broadcast messages */
762 if(!unicast && setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){ 746 if(!unicast && setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
763 printf(_("Error: Could not set broadcast option on DHCP socket!\n")); 747 printf(_("Error: Could not set broadcast option on DHCP socket!\n"));
764 exit(STATE_UNKNOWN); 748 exit(STATE_UNKNOWN);
765 } 749 }
766 750
767 /* bind socket to interface */ 751 /* bind socket to interface */
768#if defined(__linux__) 752#if defined(__linux__)
@@ -771,21 +755,21 @@ int create_dhcp_socket(void){
771 if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){ 755 if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){
772 printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name); 756 printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name);
773 exit(STATE_UNKNOWN); 757 exit(STATE_UNKNOWN);
774 } 758 }
775 759
776#else 760#else
777 strncpy(interface.ifr_name,network_interface_name,IFNAMSIZ-1); 761 strncpy(interface.ifr_name,network_interface_name,IFNAMSIZ-1);
778 interface.ifr_name[IFNAMSIZ-1]='\0'; 762 interface.ifr_name[IFNAMSIZ-1]='\0';
779#endif 763#endif
780 764
781 /* bind the socket */ 765 /* bind the socket */
782 if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){ 766 if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){
783 printf(_("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"),DHCP_CLIENT_PORT); 767 printf(_("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"),DHCP_CLIENT_PORT);
784 exit(STATE_UNKNOWN); 768 exit(STATE_UNKNOWN);
785 } 769 }
786 770
787 return sock; 771 return sock;
788 } 772}
789 773
790 774
791/* closes DHCP socket */ 775/* closes DHCP socket */
@@ -794,7 +778,7 @@ int close_dhcp_socket(int sock){
794 close(sock); 778 close(sock);
795 779
796 return OK; 780 return OK;
797 } 781}
798 782
799 783
800/* adds a requested server address to list in memory */ 784/* adds a requested server address to list in memory */
@@ -806,7 +790,7 @@ int add_requested_server(struct in_addr server_address){
806 return ERROR; 790 return ERROR;
807 791
808 new_server->server_address=server_address; 792 new_server->server_address=server_address;
809 new_server->answered=FALSE; 793 new_server->answered=false;
810 794
811 new_server->next=requested_server_list; 795 new_server->next=requested_server_list;
812 requested_server_list=new_server; 796 requested_server_list=new_server;
@@ -817,7 +801,7 @@ int add_requested_server(struct in_addr server_address){
817 printf(_("Requested server address: %s\n"),inet_ntoa(new_server->server_address)); 801 printf(_("Requested server address: %s\n"),inet_ntoa(new_server->server_address));
818 802
819 return OK; 803 return OK;
820 } 804}
821 805
822 806
823 807
@@ -850,29 +834,29 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
850 834
851 /* get option data */ 835 /* get option data */
852 switch(option_type){ 836 switch(option_type){
853 case DHCP_OPTION_LEASE_TIME: 837 case DHCP_OPTION_LEASE_TIME:
854 memcpy(&dhcp_lease_time, &offer_packet->options[x],sizeof(dhcp_lease_time)); 838 memcpy(&dhcp_lease_time, &offer_packet->options[x],sizeof(dhcp_lease_time));
855 dhcp_lease_time = ntohl(dhcp_lease_time); 839 dhcp_lease_time = ntohl(dhcp_lease_time);
856 break; 840 break;
857 case DHCP_OPTION_RENEWAL_TIME: 841 case DHCP_OPTION_RENEWAL_TIME:
858 memcpy(&dhcp_renewal_time, &offer_packet->options[x],sizeof(dhcp_renewal_time)); 842 memcpy(&dhcp_renewal_time, &offer_packet->options[x],sizeof(dhcp_renewal_time));
859 dhcp_renewal_time = ntohl(dhcp_renewal_time); 843 dhcp_renewal_time = ntohl(dhcp_renewal_time);
860 break; 844 break;
861 case DHCP_OPTION_REBINDING_TIME: 845 case DHCP_OPTION_REBINDING_TIME:
862 memcpy(&dhcp_rebinding_time, &offer_packet->options[x],sizeof(dhcp_rebinding_time)); 846 memcpy(&dhcp_rebinding_time, &offer_packet->options[x],sizeof(dhcp_rebinding_time));
863 dhcp_rebinding_time = ntohl(dhcp_rebinding_time); 847 dhcp_rebinding_time = ntohl(dhcp_rebinding_time);
864 break; 848 break;
865 case DHCP_OPTION_SERVER_IDENTIFIER: 849 case DHCP_OPTION_SERVER_IDENTIFIER:
866 memcpy(&serv_ident.s_addr, &offer_packet->options[x],sizeof(serv_ident.s_addr)); 850 memcpy(&serv_ident.s_addr, &offer_packet->options[x],sizeof(serv_ident.s_addr));
867 break; 851 break;
868 } 852 }
869 853
870 /* skip option data we're ignoring */ 854 /* skip option data we're ignoring */
871 if(option_type==0) /* "pad" option, see RFC 2132 (3.1) */ 855 if(option_type==0) /* "pad" option, see RFC 2132 (3.1) */
872 x+=1; 856 x+=1;
873 else 857 else
874 x+=option_length; 858 x+=option_length;
875 } 859 }
876 860
877 if(verbose){ 861 if(verbose){
878 if(dhcp_lease_time==DHCP_INFINITE_TIME) 862 if(dhcp_lease_time==DHCP_INFINITE_TIME)
@@ -886,7 +870,7 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
886 if(dhcp_rebinding_time==DHCP_INFINITE_TIME) 870 if(dhcp_rebinding_time==DHCP_INFINITE_TIME)
887 printf(_("Rebinding Time: Infinite\n")); 871 printf(_("Rebinding Time: Infinite\n"));
888 printf(_("Rebinding Time: %lu seconds\n"),(unsigned long)dhcp_rebinding_time); 872 printf(_("Rebinding Time: %lu seconds\n"),(unsigned long)dhcp_rebinding_time);
889 } 873 }
890 874
891 new_offer=(dhcp_offer *)malloc(sizeof(dhcp_offer)); 875 new_offer=(dhcp_offer *)malloc(sizeof(dhcp_offer));
892 876
@@ -915,14 +899,14 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
915 if(verbose){ 899 if(verbose){
916 printf(_("Added offer from server @ %s"),inet_ntoa(new_offer->server_address)); 900 printf(_("Added offer from server @ %s"),inet_ntoa(new_offer->server_address));
917 printf(_(" of IP address %s\n"),inet_ntoa(new_offer->offered_address)); 901 printf(_(" of IP address %s\n"),inet_ntoa(new_offer->offered_address));
918 } 902 }
919 903
920 /* add new offer to head of list */ 904 /* add new offer to head of list */
921 new_offer->next=dhcp_offer_list; 905 new_offer->next=dhcp_offer_list;
922 dhcp_offer_list=new_offer; 906 dhcp_offer_list=new_offer;
923 907
924 return OK; 908 return OK;
925 } 909}
926 910
927 911
928/* frees memory allocated to DHCP OFFER list */ 912/* frees memory allocated to DHCP OFFER list */
@@ -933,10 +917,10 @@ int free_dhcp_offer_list(void){
933 for(this_offer=dhcp_offer_list;this_offer!=NULL;this_offer=next_offer){ 917 for(this_offer=dhcp_offer_list;this_offer!=NULL;this_offer=next_offer){
934 next_offer=this_offer->next; 918 next_offer=this_offer->next;
935 free(this_offer); 919 free(this_offer);
936 } 920 }
937 921
938 return OK; 922 return OK;
939 } 923}
940 924
941 925
942/* frees memory allocated to requested server list */ 926/* frees memory allocated to requested server list */
@@ -947,10 +931,10 @@ int free_requested_server_list(void){
947 for(this_server=requested_server_list;this_server!=NULL;this_server=next_server){ 931 for(this_server=requested_server_list;this_server!=NULL;this_server=next_server){
948 next_server=this_server->next; 932 next_server=this_server->next;
949 free(this_server); 933 free(this_server);
950 } 934 }
951 935
952 return OK; 936 return OK;
953 } 937}
954 938
955 939
956/* gets state and plugin output to return */ 940/* gets state and plugin output to return */
@@ -958,9 +942,9 @@ int get_results(void){
958 dhcp_offer *temp_offer; 942 dhcp_offer *temp_offer;
959 requested_server *temp_server; 943 requested_server *temp_server;
960 int result; 944 int result;
961 u_int32_t max_lease_time=0; 945 uint32_t max_lease_time=0;
962 946
963 received_requested_address=FALSE; 947 received_requested_address=false;
964 948
965 /* checks responses from requested servers */ 949 /* checks responses from requested servers */
966 requested_responses=0; 950 requested_responses=0;
@@ -976,7 +960,7 @@ int get_results(void){
976 960
977 /* see if we got the address we requested */ 961 /* see if we got the address we requested */
978 if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) 962 if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address)))
979 received_requested_address=TRUE; 963 received_requested_address=true;
980 964
981 /* see if the servers we wanted a response from talked to us or not */ 965 /* see if the servers we wanted a response from talked to us or not */
982 if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){ 966 if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){
@@ -986,16 +970,16 @@ int get_results(void){
986 if(temp_server->answered) 970 if(temp_server->answered)
987 printf(_(" (duplicate)")); 971 printf(_(" (duplicate)"));
988 printf(_("\n")); 972 printf(_("\n"));
989 } 973 }
990 if(temp_server->answered == FALSE){ 974 if(!temp_server->answered){
991 requested_responses++; 975 requested_responses++;
992 temp_server->answered=TRUE; 976 temp_server->answered=true;
993 } 977 }
994 } 978 }
995 } 979 }
996 } 980 }
997 981
998 } 982 }
999 983
1000 /* else check and see if we got our requested address from any server */ 984 /* else check and see if we got our requested address from any server */
1001 else{ 985 else{
@@ -1008,9 +992,9 @@ int get_results(void){
1008 992
1009 /* see if we got the address we requested */ 993 /* see if we got the address we requested */
1010 if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address))) 994 if(!memcmp(&requested_address,&temp_offer->offered_address,sizeof(requested_address)))
1011 received_requested_address=TRUE; 995 received_requested_address=true;
1012 } 996 }
1013 } 997 }
1014 998
1015 result=STATE_OK; 999 result=STATE_OK;
1016 if(valid_responses==0) 1000 if(valid_responses==0)
@@ -1019,7 +1003,7 @@ int get_results(void){
1019 result=STATE_CRITICAL; 1003 result=STATE_CRITICAL;
1020 else if(requested_responses<requested_servers) 1004 else if(requested_responses<requested_servers)
1021 result=STATE_WARNING; 1005 result=STATE_WARNING;
1022 else if(request_specific_address==TRUE && received_requested_address==FALSE) 1006 else if(request_specific_address && !received_requested_address)
1023 result=STATE_WARNING; 1007 result=STATE_WARNING;
1024 1008
1025 if(result==0) /* garrett honeycutt 2005 */ 1009 if(result==0) /* garrett honeycutt 2005 */
@@ -1035,15 +1019,15 @@ int get_results(void){
1035 if(dhcp_offer_list==NULL){ 1019 if(dhcp_offer_list==NULL){
1036 printf(_("No DHCPOFFERs were received.\n")); 1020 printf(_("No DHCPOFFERs were received.\n"));
1037 return result; 1021 return result;
1038 } 1022 }
1039 1023
1040 printf(_("Received %d DHCPOFFER(s)"),valid_responses); 1024 printf(_("Received %d DHCPOFFER(s)"),valid_responses);
1041 1025
1042 if(requested_servers>0) 1026 if(requested_servers>0)
1043 printf(_(", %s%d of %d requested servers responded"),((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers); 1027 printf(_(", %s%d of %d requested servers responded"),((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers);
1044 1028
1045 if(request_specific_address==TRUE) 1029 if(request_specific_address)
1046 printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address==TRUE)?"":_("not ")); 1030 printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address)?"":_("not "));
1047 1031
1048 printf(_(", max lease time = ")); 1032 printf(_(", max lease time = "));
1049 if(max_lease_time==DHCP_INFINITE_TIME) 1033 if(max_lease_time==DHCP_INFINITE_TIME)
@@ -1054,7 +1038,7 @@ int get_results(void){
1054 printf(".\n"); 1038 printf(".\n");
1055 1039
1056 return result; 1040 return result;
1057 } 1041}
1058 1042
1059 1043
1060/* process command-line arguments */ 1044/* process command-line arguments */
@@ -1065,8 +1049,8 @@ int process_arguments(int argc, char **argv){
1065 return ERROR; 1049 return ERROR;
1066 1050
1067 arg_index = call_getopt(argc,argv); 1051 arg_index = call_getopt(argc,argv);
1068 return validate_arguments(argc,arg_index); 1052 return validate_arguments(argc);
1069 } 1053}
1070 1054
1071 1055
1072 1056
@@ -1097,80 +1081,80 @@ int call_getopt(int argc, char **argv){
1097 1081
1098 switch(c){ 1082 switch(c){
1099 1083
1100 case 's': /* DHCP server address */ 1084 case 's': /* DHCP server address */
1101 resolve_host(optarg,&dhcp_ip); 1085 resolve_host(optarg,&dhcp_ip);
1102 add_requested_server(dhcp_ip); 1086 add_requested_server(dhcp_ip);
1103 break; 1087 break;
1104 1088
1105 case 'r': /* address we are requested from DHCP servers */ 1089 case 'r': /* address we are requested from DHCP servers */
1106 resolve_host(optarg,&requested_address); 1090 resolve_host(optarg,&requested_address);
1107 request_specific_address=TRUE; 1091 request_specific_address=true;
1108 break; 1092 break;
1109 1093
1110 case 't': /* timeout */ 1094 case 't': /* timeout */
1111
1112 /*
1113 if(is_intnonneg(optarg))
1114 */
1115 if(atoi(optarg)>0)
1116 dhcpoffer_timeout=atoi(optarg);
1117 /*
1118 else
1119 usage("Time interval must be a nonnegative integer\n");
1120 */
1121 break;
1122 1095
1123 case 'm': /* MAC address */ 1096 /*
1097 if(is_intnonneg(optarg))
1098 */
1099 if(atoi(optarg)>0)
1100 dhcpoffer_timeout=atoi(optarg);
1101 /*
1102 else
1103 usage("Time interval must be a nonnegative integer\n");
1104 */
1105 break;
1124 1106
1125 if((user_specified_mac=mac_aton(optarg)) == NULL) 1107 case 'm': /* MAC address */
1126 usage("Cannot parse MAC address.\n");
1127 if(verbose)
1128 print_hardware_address(user_specified_mac);
1129 1108
1130 break; 1109 if((user_specified_mac=mac_aton(optarg)) == NULL)
1110 usage("Cannot parse MAC address.\n");
1111 if(verbose)
1112 print_hardware_address(user_specified_mac);
1131 1113
1132 case 'i': /* interface name */ 1114 break;
1133 1115
1134 strncpy(network_interface_name,optarg,sizeof(network_interface_name)-1); 1116 case 'i': /* interface name */
1135 network_interface_name[sizeof(network_interface_name)-1]='\x0';
1136 1117
1137 break; 1118 strncpy(network_interface_name,optarg,sizeof(network_interface_name)-1);
1119 network_interface_name[sizeof(network_interface_name)-1]='\x0';
1138 1120
1139 case 'u': /* unicast testing */ 1121 break;
1140 unicast=1;
1141 break;
1142 1122
1143 case 'V': /* version */ 1123 case 'u': /* unicast testing */
1144 print_revision(progname, NP_VERSION); 1124 unicast=1;
1145 exit(STATE_UNKNOWN); 1125 break;
1146 1126
1147 case 'h': /* help */ 1127 case 'V': /* version */
1148 print_help(); 1128 print_revision(progname, NP_VERSION);
1149 exit(STATE_UNKNOWN); 1129 exit(STATE_UNKNOWN);
1150 1130
1151 case 'v': /* verbose */ 1131 case 'h': /* help */
1152 verbose=1; 1132 print_help();
1153 break; 1133 exit(STATE_UNKNOWN);
1154 1134
1155 case '?': /* help */ 1135 case 'v': /* verbose */
1156 usage5 (); 1136 verbose=1;
1157 break; 1137 break;
1158 1138
1159 default: 1139 case '?': /* help */
1160 break; 1140 usage5 ();
1161 } 1141 break;
1162 } 1142
1143 default:
1144 break;
1145 }
1146 }
1163 return optind; 1147 return optind;
1164 } 1148}
1165 1149
1166 1150
1167int validate_arguments(int argc, int arg_index){ 1151int validate_arguments(int argc){
1168 1152
1169 if(argc-optind > 0) 1153 if(argc - optind > 0)
1170 usage(_("Got unexpected non-option argument")); 1154 usage(_("Got unexpected non-option argument"));
1171 1155
1172 return OK; 1156 return OK;
1173 } 1157}
1174 1158
1175 1159
1176#if defined(__sun__) || defined(__solaris__) || defined(__hpux__) 1160#if defined(__sun__) || defined(__solaris__) || defined(__hpux__)
@@ -1188,21 +1172,21 @@ static int get_msg(int fd){
1188 if(res < 0){ 1172 if(res < 0){
1189 if(errno == EINTR){ 1173 if(errno == EINTR){
1190 return(GOT_INTR); 1174 return(GOT_INTR);
1191 } 1175 }
1192 else{ 1176 else{
1193 printf("%s\n", "get_msg FAILED."); 1177 printf("%s\n", "get_msg FAILED.");
1194 return(GOT_ERR); 1178 return(GOT_ERR);
1195 }
1196 } 1179 }
1180 }
1197 if(ctl.len > 0){ 1181 if(ctl.len > 0){
1198 ret |= GOT_CTRL; 1182 ret |= GOT_CTRL;
1199 } 1183 }
1200 if(dat.len > 0){ 1184 if(dat.len > 0){
1201 ret |= GOT_DATA; 1185 ret |= GOT_DATA;
1202 } 1186 }
1203 1187
1204 return(ret); 1188 return(ret);
1205 } 1189}
1206 1190
1207/* verify that dl_primitive in ctl_area = prim */ 1191/* verify that dl_primitive in ctl_area = prim */
1208static int check_ctrl(int prim){ 1192static int check_ctrl(int prim){
@@ -1211,10 +1195,10 @@ static int check_ctrl(int prim){
1211 if(err_ack->dl_primitive != prim){ 1195 if(err_ack->dl_primitive != prim){
1212 printf(_("Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"), strerror(errno)); 1196 printf(_("Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"), strerror(errno));
1213 exit(STATE_UNKNOWN); 1197 exit(STATE_UNKNOWN);
1214 } 1198 }
1215 1199
1216 return 0; 1200 return 0;
1217 } 1201}
1218 1202
1219/* put a control message on a stream */ 1203/* put a control message on a stream */
1220static int put_ctrl(int fd, int len, int pri){ 1204static int put_ctrl(int fd, int len, int pri){
@@ -1223,10 +1207,10 @@ static int put_ctrl(int fd, int len, int pri){
1223 if(putmsg(fd, &ctl, 0, pri) < 0){ 1207 if(putmsg(fd, &ctl, 0, pri) < 0){
1224 printf(_("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"), strerror(errno)); 1208 printf(_("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"), strerror(errno));
1225 exit(STATE_UNKNOWN); 1209 exit(STATE_UNKNOWN);
1226 } 1210 }
1227 1211
1228 return 0; 1212 return 0;
1229 } 1213}
1230 1214
1231/* put a control + data message on a stream */ 1215/* put a control + data message on a stream */
1232static int put_both(int fd, int clen, int dlen, int pri){ 1216static int put_both(int fd, int clen, int dlen, int pri){
@@ -1236,10 +1220,10 @@ static int put_both(int fd, int clen, int dlen, int pri){
1236 if(putmsg(fd, &ctl, &dat, pri) < 0){ 1220 if(putmsg(fd, &ctl, &dat, pri) < 0){
1237 printf(_("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"), strerror(errno)); 1221 printf(_("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"), strerror(errno));
1238 exit(STATE_UNKNOWN); 1222 exit(STATE_UNKNOWN);
1239 } 1223 }
1240 1224
1241 return 0; 1225 return 0;
1242 } 1226}
1243 1227
1244/* open file descriptor and attach */ 1228/* open file descriptor and attach */
1245static int dl_open(const char *dev, int unit, int *fd){ 1229static int dl_open(const char *dev, int unit, int *fd){
@@ -1248,13 +1232,13 @@ static int dl_open(const char *dev, int unit, int *fd){
1248 if((*fd = open(dev, O_RDWR)) == -1){ 1232 if((*fd = open(dev, O_RDWR)) == -1){
1249 printf(_("Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"), dev, strerror(errno)); 1233 printf(_("Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"), dev, strerror(errno));
1250 exit(STATE_UNKNOWN); 1234 exit(STATE_UNKNOWN);
1251 } 1235 }
1252 attach_req->dl_primitive = DL_ATTACH_REQ; 1236 attach_req->dl_primitive = DL_ATTACH_REQ;
1253 attach_req->dl_ppa = unit; 1237 attach_req->dl_ppa = unit;
1254 put_ctrl(*fd, sizeof(dl_attach_req_t), 0); 1238 put_ctrl(*fd, sizeof(dl_attach_req_t), 0);
1255 get_msg(*fd); 1239 get_msg(*fd);
1256 return check_ctrl(DL_OK_ACK); 1240 return check_ctrl(DL_OK_ACK);
1257 } 1241}
1258 1242
1259/* send DL_BIND_REQ */ 1243/* send DL_BIND_REQ */
1260static int dl_bind(int fd, int sap, u_char *addr){ 1244static int dl_bind(int fd, int sap, u_char *addr){
@@ -1272,12 +1256,12 @@ static int dl_bind(int fd, int sap, u_char *addr){
1272 if (GOT_ERR == check_ctrl(DL_BIND_ACK)){ 1256 if (GOT_ERR == check_ctrl(DL_BIND_ACK)){
1273 printf(_("Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"), strerror(errno)); 1257 printf(_("Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"), strerror(errno));
1274 exit(STATE_UNKNOWN); 1258 exit(STATE_UNKNOWN);
1275 } 1259 }
1276 bcopy((u_char *)bind_ack + bind_ack->dl_addr_offset, addr, 1260 bcopy((u_char *)bind_ack + bind_ack->dl_addr_offset, addr,
1277 bind_ack->dl_addr_length); 1261 bind_ack->dl_addr_length);
1278 1262
1279 return 0; 1263 return 0;
1280 } 1264}
1281 1265
1282/*********************************************************************** 1266/***********************************************************************
1283 * interface: 1267 * interface:
@@ -1296,15 +1280,15 @@ long mac_addr_dlpi( const char *dev, int unit, u_char *addr){
1296 u_char mac_addr[25]; 1280 u_char mac_addr[25];
1297 1281
1298 if(GOT_ERR != dl_open(dev, unit, &fd)){ 1282 if(GOT_ERR != dl_open(dev, unit, &fd)){
1299 if(GOT_ERR != dl_bind(fd, INSAP, mac_addr)){ 1283 if(GOT_ERR != dl_bind(fd, INSAP, mac_addr)){
1300 bcopy( mac_addr, addr, 6); 1284 bcopy( mac_addr, addr, 6);
1301 return 0; 1285 return 0;
1302 }
1303 } 1286 }
1304 close(fd); 1287 }
1288 close(fd);
1305 1289
1306 return -1; 1290 return -1;
1307 } 1291}
1308 1292
1309/* Kompf 2000-2003 */ 1293/* Kompf 2000-2003 */
1310#endif 1294#endif
@@ -1321,7 +1305,7 @@ void resolve_host(const char *in,struct in_addr *out){
1321 1305
1322 memcpy(out,&((struct sockaddr_in *)ai->ai_addr)->sin_addr,sizeof(*out)); 1306 memcpy(out,&((struct sockaddr_in *)ai->ai_addr)->sin_addr,sizeof(*out));
1323 freeaddrinfo(ai); 1307 freeaddrinfo(ai);
1324 } 1308}
1325 1309
1326 1310
1327/* parse MAC address string, return 6 bytes (unterminated) or NULL */ 1311/* parse MAC address string, return 6 bytes (unterminated) or NULL */
@@ -1340,10 +1324,10 @@ unsigned char *mac_aton(const char *string){
1340 result[j]=strtol(tmp,(char **)NULL,16); 1324 result[j]=strtol(tmp,(char **)NULL,16);
1341 i++; 1325 i++;
1342 j++; 1326 j++;
1343 } 1327 }
1344 1328
1345 return (j==6) ? result : NULL; 1329 return (j==6) ? result : NULL;
1346 } 1330}
1347 1331
1348 1332
1349void print_hardware_address(const unsigned char *address){ 1333void print_hardware_address(const unsigned char *address){
@@ -1354,7 +1338,7 @@ void print_hardware_address(const unsigned char *address){
1354 printf("%2.2x:", address[i]); 1338 printf("%2.2x:", address[i]);
1355 printf("%2.2x", address[i]); 1339 printf("%2.2x", address[i]);
1356 putchar('\n'); 1340 putchar('\n');
1357 } 1341}
1358 1342
1359 1343
1360/* print usage help */ 1344/* print usage help */
@@ -1367,7 +1351,7 @@ void print_help(void){
1367 1351
1368 printf("%s\n", _("This plugin tests the availability of DHCP servers on a network.")); 1352 printf("%s\n", _("This plugin tests the availability of DHCP servers on a network."));
1369 1353
1370 printf ("\n\n"); 1354 printf ("\n\n");
1371 1355
1372 print_usage(); 1356 print_usage();
1373 1357
@@ -1377,32 +1361,29 @@ void print_help(void){
1377 printf (UT_VERBOSE); 1361 printf (UT_VERBOSE);
1378 1362
1379 printf (" %s\n", "-s, --serverip=IPADDRESS"); 1363 printf (" %s\n", "-s, --serverip=IPADDRESS");
1380 printf (" %s\n", _("IP address of DHCP server that we must hear from")); 1364 printf (" %s\n", _("IP address of DHCP server that we must hear from"));
1381 printf (" %s\n", "-r, --requestedip=IPADDRESS"); 1365 printf (" %s\n", "-r, --requestedip=IPADDRESS");
1382 printf (" %s\n", _("IP address that should be offered by at least one DHCP server")); 1366 printf (" %s\n", _("IP address that should be offered by at least one DHCP server"));
1383 printf (" %s\n", "-t, --timeout=INTEGER"); 1367 printf (" %s\n", "-t, --timeout=INTEGER");
1384 printf (" %s\n", _("Seconds to wait for DHCPOFFER before timeout occurs")); 1368 printf (" %s\n", _("Seconds to wait for DHCPOFFER before timeout occurs"));
1385 printf (" %s\n", "-i, --interface=STRING"); 1369 printf (" %s\n", "-i, --interface=STRING");
1386 printf (" %s\n", _("Interface to to use for listening (i.e. eth0)")); 1370 printf (" %s\n", _("Interface to to use for listening (i.e. eth0)"));
1387 printf (" %s\n", "-m, --mac=STRING"); 1371 printf (" %s\n", "-m, --mac=STRING");
1388 printf (" %s\n", _("MAC address to use in the DHCP request")); 1372 printf (" %s\n", _("MAC address to use in the DHCP request"));
1389 printf (" %s\n", "-u, --unicast"); 1373 printf (" %s\n", "-u, --unicast");
1390 printf (" %s\n", _("Unicast testing: mimic a DHCP relay, requires -s")); 1374 printf (" %s\n", _("Unicast testing: mimic a DHCP relay, requires -s"));
1391 1375
1392 printf (UT_SUPPORT); 1376 printf (UT_SUPPORT);
1393 return; 1377 return;
1394 } 1378}
1395 1379
1396 1380
1397void 1381void
1398print_usage(void){ 1382print_usage(void){
1399 1383
1400 printf ("%s\n", _("Usage:")); 1384 printf ("%s\n", _("Usage:"));
1401 printf (" %s [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]\n",progname); 1385 printf (" %s [-v] [-u] [-s serverip] [-r requestedip] [-t timeout]\n",progname);
1402 printf (" [-i interface] [-m mac]\n"); 1386 printf (" [-i interface] [-m mac]\n");
1403 1387
1404 return; 1388 return;
1405 } 1389}
1406
1407
1408
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 9ed12ba1..1d47e9fc 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1,39 +1,39 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_icmp plugin 3* Monitoring check_icmp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2005-2008 Monitoring Plugins Development Team 6* Copyright (c) 2005-2008 Monitoring Plugins Development Team
7* Original Author : Andreas Ericsson <ae@op5.se> 7* Original Author : Andreas Ericsson <ae@op5.se>
8* 8*
9* Description: 9* Description:
10* 10*
11* This file contains the check_icmp plugin 11* This file contains the check_icmp plugin
12* 12*
13* Relevant RFC's: 792 (ICMP), 791 (IP) 13* Relevant RFC's: 792 (ICMP), 791 (IP)
14* 14*
15* This program was modeled somewhat after the check_icmp program, 15* This program was modeled somewhat after the check_icmp program,
16* which was in turn a hack of fping (www.fping.org) but has been 16* which was in turn a hack of fping (www.fping.org) but has been
17* completely rewritten since to generate higher precision rta values, 17* completely rewritten since to generate higher precision rta values,
18* and support several different modes as well as setting ttl to control. 18* and support several different modes as well as setting ttl to control.
19* redundant routes. The only remainders of fping is currently a few 19* redundant routes. The only remainders of fping is currently a few
20* function names. 20* function names.
21* 21*
22* 22*
23* This program is free software: you can redistribute it and/or modify 23* This program is free software: you can redistribute it and/or modify
24* it under the terms of the GNU General Public License as published by 24* it under the terms of the GNU General Public License as published by
25* the Free Software Foundation, either version 3 of the License, or 25* the Free Software Foundation, either version 3 of the License, or
26* (at your option) any later version. 26* (at your option) any later version.
27* 27*
28* This program is distributed in the hope that it will be useful, 28* This program is distributed in the hope that it will be useful,
29* but WITHOUT ANY WARRANTY; without even the implied warranty of 29* but WITHOUT ANY WARRANTY; without even the implied warranty of
30* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31* GNU General Public License for more details. 31* GNU General Public License for more details.
32* 32*
33* You should have received a copy of the GNU General Public License 33* You should have received a copy of the GNU General Public License
34* along with this program. If not, see <http://www.gnu.org/licenses/>. 34* along with this program. If not, see <http://www.gnu.org/licenses/>.
35* 35*
36* 36*
37*****************************************************************************/ 37*****************************************************************************/
38 38
39/* progname may change */ 39/* progname may change */
@@ -50,27 +50,20 @@ const char *email = "devel@monitoring-plugins.org";
50#if HAVE_SYS_SOCKIO_H 50#if HAVE_SYS_SOCKIO_H
51#include <sys/sockio.h> 51#include <sys/sockio.h>
52#endif 52#endif
53#include <sys/ioctl.h> 53
54#include <sys/time.h> 54#include <sys/time.h>
55#include <sys/types.h>
56#include <stdio.h>
57#include <stdlib.h>
58#include <stdarg.h>
59#include <unistd.h>
60#include <stddef.h>
61#include <errno.h> 55#include <errno.h>
62#include <string.h> 56#include <signal.h>
63#include <ctype.h> 57#include <ctype.h>
64#include <netdb.h> 58#include <float.h>
65#include <sys/socket.h>
66#include <net/if.h> 59#include <net/if.h>
67#include <netinet/in_systm.h> 60#include <netinet/in_systm.h>
68#include <netinet/in.h> 61#include <netinet/in.h>
69#include <netinet/ip.h> 62#include <netinet/ip.h>
63#include <netinet/ip6.h>
70#include <netinet/ip_icmp.h> 64#include <netinet/ip_icmp.h>
65#include <netinet/icmp6.h>
71#include <arpa/inet.h> 66#include <arpa/inet.h>
72#include <signal.h>
73#include <float.h>
74 67
75 68
76/** sometimes undefined system macros (quite a few, actually) **/ 69/** sometimes undefined system macros (quite a few, actually) **/
@@ -103,18 +96,14 @@ const char *email = "devel@monitoring-plugins.org";
103# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 96# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
104#endif 97#endif
105 98
106#ifndef DBL_MAX
107# define DBL_MAX 9.9999999999e999
108#endif
109
110typedef unsigned short range_t; /* type for get_range() -- unimplemented */ 99typedef unsigned short range_t; /* type for get_range() -- unimplemented */
111 100
112typedef struct rta_host { 101typedef struct rta_host {
113 unsigned short id; /* id in **table, and icmp pkts */ 102 unsigned short id; /* id in **table, and icmp pkts */
114 char *name; /* arg used for adding this host */ 103 char *name; /* arg used for adding this host */
115 char *msg; /* icmp error message, if any */ 104 char *msg; /* icmp error message, if any */
116 struct sockaddr_in saddr_in; /* the address of this host */ 105 struct sockaddr_storage saddr_in; /* the address of this host */
117 struct in_addr error_addr; /* stores address of error replies */ 106 struct sockaddr_storage error_addr; /* stores address of error replies */
118 unsigned long long time_waited; /* total time waited, in usecs */ 107 unsigned long long time_waited; /* total time waited, in usecs */
119 unsigned int icmp_sent, icmp_recv, icmp_lost; /* counters */ 108 unsigned int icmp_sent, icmp_recv, icmp_lost; /* counters */
120 unsigned char icmp_type, icmp_code; /* type and code from errors */ 109 unsigned char icmp_type, icmp_code; /* type and code from errors */
@@ -140,6 +129,18 @@ typedef struct icmp_ping_data {
140 unsigned short ping_id; 129 unsigned short ping_id;
141} icmp_ping_data; 130} icmp_ping_data;
142 131
132typedef union ip_hdr {
133 struct ip ip;
134 struct ip6_hdr ip6;
135} ip_hdr;
136
137typedef union icmp_packet {
138 void *buf;
139 struct icmp *icp;
140 struct icmp6_hdr *icp6;
141 u_short *cksum_in;
142} icmp_packet;
143
143/* the different modes of this program are as follows: 144/* the different modes of this program are as follows:
144 * MODE_RTA: send all packets no matter what (mimic check_icmp and check_ping) 145 * MODE_RTA: send all packets no matter what (mimic check_icmp and check_ping)
145 * MODE_HOSTCHECK: Return immediately upon any sign of life 146 * MODE_HOSTCHECK: Return immediately upon any sign of life
@@ -190,9 +191,10 @@ static int get_threshold(char *str, threshold *th);
190static void run_checks(void); 191static void run_checks(void);
191static void set_source_ip(char *); 192static void set_source_ip(char *);
192static int add_target(char *); 193static int add_target(char *);
193static int add_target_ip(char *, struct in_addr *); 194static int add_target_ip(char *, struct sockaddr_storage *);
194static int handle_random_icmp(unsigned char *, struct sockaddr_in *); 195static int handle_random_icmp(unsigned char *, struct sockaddr_storage *);
195static unsigned short icmp_checksum(unsigned short *, int); 196static void parse_address(struct sockaddr_storage *, char *, int);
197static unsigned short icmp_checksum(uint16_t *, size_t);
196static void finish(int); 198static void finish(int);
197static void crash(const char *, ...); 199static void crash(const char *, ...);
198 200
@@ -208,7 +210,7 @@ static int mode, protocols, sockets, debug = 0, timeout = 10;
208static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE; 210static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE;
209static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN; 211static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN;
210 212
211static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; 213static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0, ttl = 0;
212#define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) 214#define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost))
213static unsigned short targets_down = 0, targets = 0, packets = 0; 215static unsigned short targets_down = 0, targets = 0, packets = 0;
214#define targets_alive (targets - targets_down) 216#define targets_alive (targets - targets_down)
@@ -218,7 +220,6 @@ static pid_t pid;
218static struct timezone tz; 220static struct timezone tz;
219static struct timeval prog_start; 221static struct timeval prog_start;
220static unsigned long long max_completion_time = 0; 222static unsigned long long max_completion_time = 0;
221static unsigned char ttl = 0; /* outgoing ttl */
222static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */ 223static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */
223static int min_hosts_alive = -1; 224static int min_hosts_alive = -1;
224float pkt_backoff_factor = 1.5; 225float pkt_backoff_factor = 1.5;
@@ -273,7 +274,7 @@ get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code)
273 break; 274 break;
274 275
275 case ICMP_TIMXCEED: 276 case ICMP_TIMXCEED:
276 /* really 'out of reach', or non-existant host behind a router serving 277 /* really 'out of reach', or non-existent host behind a router serving
277 * two different subnets */ 278 * two different subnets */
278 switch(icmp_code) { 279 switch(icmp_code) {
279 case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break; 280 case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break;
@@ -300,7 +301,7 @@ get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code)
300} 301}
301 302
302static int 303static int
303handle_random_icmp(unsigned char *packet, struct sockaddr_in *addr) 304handle_random_icmp(unsigned char *packet, struct sockaddr_storage *addr)
304{ 305{
305 struct icmp p, sent_icmp; 306 struct icmp p, sent_icmp;
306 struct rta_host *host = NULL; 307 struct rta_host *host = NULL;
@@ -342,9 +343,11 @@ handle_random_icmp(unsigned char *packet, struct sockaddr_in *addr)
342 /* it is indeed a response for us */ 343 /* it is indeed a response for us */
343 host = table[ntohs(sent_icmp.icmp_seq)/packets]; 344 host = table[ntohs(sent_icmp.icmp_seq)/packets];
344 if(debug) { 345 if(debug) {
346 char address[INET6_ADDRSTRLEN];
347 parse_address(addr, address, sizeof(address));
345 printf("Received \"%s\" from %s for ICMP ECHO sent to %s.\n", 348 printf("Received \"%s\" from %s for ICMP ECHO sent to %s.\n",
346 get_icmp_error_msg(p.icmp_type, p.icmp_code), 349 get_icmp_error_msg(p.icmp_type, p.icmp_code),
347 inet_ntoa(addr->sin_addr), host->name); 350 address, host->name);
348 } 351 }
349 352
350 icmp_lost++; 353 icmp_lost++;
@@ -364,11 +367,23 @@ handle_random_icmp(unsigned char *packet, struct sockaddr_in *addr)
364 } 367 }
365 host->icmp_type = p.icmp_type; 368 host->icmp_type = p.icmp_type;
366 host->icmp_code = p.icmp_code; 369 host->icmp_code = p.icmp_code;
367 host->error_addr.s_addr = addr->sin_addr.s_addr; 370 host->error_addr = *addr;
368 371
369 return 0; 372 return 0;
370} 373}
371 374
375void parse_address(struct sockaddr_storage *addr, char *address, int size)
376{
377 switch (address_family) {
378 case AF_INET:
379 inet_ntop(address_family, &((struct sockaddr_in *)addr)->sin_addr, address, size);
380 break;
381 case AF_INET6:
382 inet_ntop(address_family, &((struct sockaddr_in6 *)addr)->sin6_addr, address, size);
383 break;
384 }
385}
386
372int 387int
373main(int argc, char **argv) 388main(int argc, char **argv)
374{ 389{
@@ -381,6 +396,8 @@ main(int argc, char **argv)
381#ifdef SO_TIMESTAMP 396#ifdef SO_TIMESTAMP
382 int on = 1; 397 int on = 1;
383#endif 398#endif
399 char *source_ip = NULL;
400 char * opts_str = "vhVw:c:n:p:t:H:s:i:b:I:l:m:64";
384 401
385 setlocale (LC_ALL, ""); 402 setlocale (LC_ALL, "");
386 bindtextdomain (PACKAGE, LOCALEDIR); 403 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -390,33 +407,8 @@ main(int argc, char **argv)
390 * that before pointer magic (esp. on network data) */ 407 * that before pointer magic (esp. on network data) */
391 icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0; 408 icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0;
392 409
393 if((icmp_sock = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) != -1) 410 address_family = -1;
394 sockets |= HAVE_ICMP; 411 int icmp_proto = IPPROTO_ICMP;
395 else icmp_sockerrno = errno;
396
397 /* if((udp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) != -1) */
398 /* sockets |= HAVE_UDP; */
399 /* else udp_sockerrno = errno; */
400
401 /* if((tcp_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) != -1) */
402 /* sockets |= HAVE_TCP; */
403 /* else tcp_sockerrno = errno; */
404
405 /* now drop privileges (no effect if not setsuid or geteuid() == 0) */
406 setuid(getuid());
407
408#ifdef SO_TIMESTAMP
409 if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)))
410 if(debug) printf("Warning: no SO_TIMESTAMP support\n");
411#endif // SO_TIMESTAMP
412
413 /* POSIXLY_CORRECT might break things, so unset it (the portable way) */
414 environ = NULL;
415
416 /* use the pid to mark packets as ours */
417 /* Some systems have 32-bit pid_t so mask off only 16 bits */
418 pid = getpid() & 0xffff;
419 /* printf("pid = %u\n", pid); */
420 412
421 /* get calling name the old-fashioned way for portability instead 413 /* get calling name the old-fashioned way for portability instead
422 * of relying on the glibc-ism __progname */ 414 * of relying on the glibc-ism __progname */
@@ -456,9 +448,6 @@ main(int argc, char **argv)
456 packets = 5; 448 packets = 5;
457 } 449 }
458 450
459 /* Parse extra opts if any */
460 argv=np_extra_opts(&argc, argv, progname);
461
462 /* support "--help" and "--version" */ 451 /* support "--help" and "--version" */
463 if(argc == 2) { 452 if(argc == 2) {
464 if(!strcmp(argv[1], "--help")) 453 if(!strcmp(argv[1], "--help"))
@@ -467,10 +456,35 @@ main(int argc, char **argv)
467 strcpy(argv[1], "-V"); 456 strcpy(argv[1], "-V");
468 } 457 }
469 458
459 /* Parse protocol arguments first */
460 for(i = 1; i < argc; i++) {
461 while((arg = getopt(argc, argv, opts_str)) != EOF) {
462 switch(arg) {
463 case '4':
464 if (address_family != -1)
465 crash("Multiple protocol versions not supported");
466 address_family = AF_INET;
467 break;
468 case '6':
469#ifdef USE_IPV6
470 if (address_family != -1)
471 crash("Multiple protocol versions not supported");
472 address_family = AF_INET6;
473#else
474 usage (_("IPv6 support not available\n"));
475#endif
476 break;
477 }
478 }
479 }
480
481 /* Reset argument scanning */
482 optind = 1;
483
484 unsigned short size;
470 /* parse the arguments */ 485 /* parse the arguments */
471 for(i = 1; i < argc; i++) { 486 for(i = 1; i < argc; i++) {
472 while((arg = getopt(argc, argv, "vhVw:c:n:p:t:H:s:i:b:I:l:m:")) != EOF) { 487 while((arg = getopt(argc, argv, opts_str)) != EOF) {
473 unsigned short size;
474 switch(arg) { 488 switch(arg) {
475 case 'v': 489 case 'v':
476 debug++; 490 debug++;
@@ -482,7 +496,7 @@ main(int argc, char **argv)
482 icmp_data_size = size; 496 icmp_data_size = size;
483 icmp_pkt_size = size + ICMP_MINLEN; 497 icmp_pkt_size = size + ICMP_MINLEN;
484 } else 498 } else
485 usage_va("ICMP data length must be between: %d and %d", 499 usage_va("ICMP data length must be between: %lu and %lu",
486 sizeof(struct icmp) + sizeof(struct icmp_ping_data), 500 sizeof(struct icmp) + sizeof(struct icmp_ping_data),
487 MAX_PING_DATA - 1); 501 MAX_PING_DATA - 1);
488 break; 502 break;
@@ -510,7 +524,7 @@ main(int argc, char **argv)
510 add_target(optarg); 524 add_target(optarg);
511 break; 525 break;
512 case 'l': 526 case 'l':
513 ttl = (unsigned char)strtoul(optarg, NULL, 0); 527 ttl = (int)strtoul(optarg, NULL, 0);
514 break; 528 break;
515 case 'm': 529 case 'm':
516 min_hosts_alive = (int)strtoul(optarg, NULL, 0); 530 min_hosts_alive = (int)strtoul(optarg, NULL, 0);
@@ -522,7 +536,7 @@ main(int argc, char **argv)
522 } 536 }
523 break; 537 break;
524 case 's': /* specify source IP address */ 538 case 's': /* specify source IP address */
525 set_source_ip(optarg); 539 source_ip = optarg;
526 break; 540 break;
527 case 'V': /* version */ 541 case 'V': /* version */
528 print_revision (progname, NP_VERSION); 542 print_revision (progname, NP_VERSION);
@@ -530,10 +544,22 @@ main(int argc, char **argv)
530 case 'h': /* help */ 544 case 'h': /* help */
531 print_help (); 545 print_help ();
532 exit (STATE_UNKNOWN); 546 exit (STATE_UNKNOWN);
547 break;
533 } 548 }
534 } 549 }
535 } 550 }
536 551
552 /* POSIXLY_CORRECT might break things, so unset it (the portable way) */
553 environ = NULL;
554
555 /* use the pid to mark packets as ours */
556 /* Some systems have 32-bit pid_t so mask off only 16 bits */
557 pid = getpid() & 0xffff;
558 /* printf("pid = %u\n", pid); */
559
560 /* Parse extra opts if any */
561 argv=np_extra_opts(&argc, argv, progname);
562
537 argv = &argv[optind]; 563 argv = &argv[optind];
538 while(*argv) { 564 while(*argv) {
539 add_target(*argv); 565 add_target(*argv);
@@ -545,6 +571,32 @@ main(int argc, char **argv)
545 exit(3); 571 exit(3);
546 } 572 }
547 573
574 // add_target might change address_family
575 switch ( address_family ){
576 case AF_INET: icmp_proto = IPPROTO_ICMP;
577 break;
578 case AF_INET6: icmp_proto = IPPROTO_ICMPV6;
579 break;
580 default: crash("Address family not supported");
581 }
582 if((icmp_sock = socket(address_family, SOCK_RAW, icmp_proto)) != -1)
583 sockets |= HAVE_ICMP;
584 else icmp_sockerrno = errno;
585
586 if( source_ip )
587 set_source_ip(source_ip);
588
589#ifdef SO_TIMESTAMP
590 if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)))
591 if(debug) printf("Warning: no SO_TIMESTAMP support\n");
592#endif // SO_TIMESTAMP
593
594 /* now drop privileges (no effect if not setsuid or geteuid() == 0) */
595 if (setuid(getuid()) == -1) {
596 printf("ERROR: Failed to drop privileges\n");
597 return 1;
598 }
599
548 if(!sockets) { 600 if(!sockets) {
549 if(icmp_sock == -1) { 601 if(icmp_sock == -1) {
550 errno = icmp_sockerrno; 602 errno = icmp_sockerrno;
@@ -608,7 +660,7 @@ main(int argc, char **argv)
608 if(max_completion_time > (u_int)timeout * 1000000) { 660 if(max_completion_time > (u_int)timeout * 1000000) {
609 printf("max_completion_time: %llu timeout: %u\n", 661 printf("max_completion_time: %llu timeout: %u\n",
610 max_completion_time, timeout); 662 max_completion_time, timeout);
611 printf("Timout must be at lest %llu\n", 663 printf("Timeout must be at least %llu\n",
612 max_completion_time / 1000000 + 1); 664 max_completion_time / 1000000 + 1);
613 } 665 }
614 } 666 }
@@ -633,7 +685,7 @@ main(int argc, char **argv)
633 } 685 }
634 686
635 host = list; 687 host = list;
636 table = malloc(sizeof(struct rta_host **) * targets); 688 table = (struct rta_host**)malloc(sizeof(struct rta_host **) * targets);
637 i = 0; 689 i = 0;
638 while(host) { 690 while(host) {
639 host->id = i*packets; 691 host->id = i*packets;
@@ -653,7 +705,7 @@ main(int argc, char **argv)
653static void 705static void
654run_checks() 706run_checks()
655{ 707{
656 u_int i, t, result; 708 u_int i, t;
657 u_int final_wait, time_passed; 709 u_int final_wait, time_passed;
658 710
659 /* this loop might actually violate the pkt_interval or target_interval 711 /* this loop might actually violate the pkt_interval or target_interval
@@ -671,9 +723,9 @@ run_checks()
671 723
672 /* we're still in the game, so send next packet */ 724 /* we're still in the game, so send next packet */
673 (void)send_icmp_ping(icmp_sock, table[t]); 725 (void)send_icmp_ping(icmp_sock, table[t]);
674 result = wait_for_reply(icmp_sock, target_interval); 726 wait_for_reply(icmp_sock, target_interval);
675 } 727 }
676 result = wait_for_reply(icmp_sock, pkt_interval * targets); 728 wait_for_reply(icmp_sock, pkt_interval * targets);
677 } 729 }
678 730
679 if(icmp_pkts_en_route && targets_alive) { 731 if(icmp_pkts_en_route && targets_alive) {
@@ -693,30 +745,47 @@ run_checks()
693 * haven't yet */ 745 * haven't yet */
694 if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n", 746 if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n",
695 final_wait, (float)final_wait / 1000); 747 final_wait, (float)final_wait / 1000);
696 result = wait_for_reply(icmp_sock, final_wait); 748 wait_for_reply(icmp_sock, final_wait);
697 } 749 }
698} 750}
699 751
752
700/* response structure: 753/* response structure:
754 * IPv4:
701 * ip header : 20 bytes 755 * ip header : 20 bytes
702 * icmp header : 28 bytes 756 * icmp header : 28 bytes
757 * IPv6:
758 * ip header : 40 bytes
759 * icmp header : 28 bytes
760 * both:
703 * icmp echo reply : the rest 761 * icmp echo reply : the rest
704 */ 762 */
705static int 763static int
706wait_for_reply(int sock, u_int t) 764wait_for_reply(int sock, u_int t)
707{ 765{
708 int n, hlen; 766 int n, hlen;
709 static unsigned char buf[4096]; 767 static unsigned char buf[65536];
710 struct sockaddr_in resp_addr; 768 struct sockaddr_storage resp_addr;
711 struct ip *ip; 769 union ip_hdr *ip;
712 struct icmp icp; 770 union icmp_packet packet;
713 struct rta_host *host; 771 struct rta_host *host;
714 struct icmp_ping_data data; 772 struct icmp_ping_data data;
715 struct timeval wait_start, now; 773 struct timeval wait_start, now;
716 u_int tdiff, i, per_pkt_wait; 774 u_int tdiff, i, per_pkt_wait;
717 775
776 if (!(packet.buf = malloc(icmp_pkt_size))) {
777 crash("send_icmp_ping(): failed to malloc %d bytes for send buffer",
778 icmp_pkt_size);
779 return -1; /* might be reached if we're in debug mode */
780 }
781
782 memset(packet.buf, 0, icmp_pkt_size);
783
718 /* if we can't listen or don't have anything to listen to, just return */ 784 /* if we can't listen or don't have anything to listen to, just return */
719 if(!t || !icmp_pkts_en_route) return 0; 785 if(!t || !icmp_pkts_en_route) {
786 free(packet.buf);
787 return 0;
788 }
720 789
721 gettimeofday(&wait_start, &tz); 790 gettimeofday(&wait_start, &tz);
722 791
@@ -735,7 +804,7 @@ wait_for_reply(int sock, u_int t)
735 804
736 /* reap responses until we hit a timeout */ 805 /* reap responses until we hit a timeout */
737 n = recvfrom_wto(sock, buf, sizeof(buf), 806 n = recvfrom_wto(sock, buf, sizeof(buf),
738 (struct sockaddr *)&resp_addr, &t, &now); 807 (struct sockaddr *)&resp_addr, &t, &now);
739 if(!n) { 808 if(!n) {
740 if(debug > 1) { 809 if(debug > 1) {
741 printf("recvfrom_wto() timed out during a %u usecs wait\n", 810 printf("recvfrom_wto() timed out during a %u usecs wait\n",
@@ -745,12 +814,23 @@ wait_for_reply(int sock, u_int t)
745 } 814 }
746 if(n < 0) { 815 if(n < 0) {
747 if(debug) printf("recvfrom_wto() returned errors\n"); 816 if(debug) printf("recvfrom_wto() returned errors\n");
817 free(packet.buf);
748 return n; 818 return n;
749 } 819 }
750 820
751 ip = (struct ip *)buf; 821 // FIXME: with ipv6 we don't have an ip header here
752 if(debug > 1) printf("received %u bytes from %s\n", 822 if (address_family != AF_INET6) {
753 ntohs(ip->ip_len), inet_ntoa(resp_addr.sin_addr)); 823 ip = (union ip_hdr *)buf;
824
825 if(debug > 1) {
826 char address[INET6_ADDRSTRLEN];
827 parse_address(&resp_addr, address, sizeof(address));
828 printf("received %u bytes from %s\n",
829 address_family == AF_INET6 ? ntohs(ip->ip6.ip6_plen)
830 : ntohs(ip->ip.ip_len),
831 address);
832 }
833 }
754 834
755/* obsolete. alpha on tru64 provides the necessary defines, but isn't broken */ 835/* obsolete. alpha on tru64 provides the necessary defines, but isn't broken */
756/* #if defined( __alpha__ ) && __STDC__ && !defined( __GLIBC__ ) */ 836/* #if defined( __alpha__ ) && __STDC__ && !defined( __GLIBC__ ) */
@@ -759,12 +839,14 @@ wait_for_reply(int sock, u_int t)
759 * off the bottom 4 bits */ 839 * off the bottom 4 bits */
760/* hlen = (ip->ip_vhl & 0x0f) << 2; */ 840/* hlen = (ip->ip_vhl & 0x0f) << 2; */
761/* #else */ 841/* #else */
762 hlen = ip->ip_hl << 2; 842 hlen = (address_family == AF_INET6) ? 0 : ip->ip.ip_hl << 2;
763/* #endif */ 843/* #endif */
764 844
765 if(n < (hlen + ICMP_MINLEN)) { 845 if(n < (hlen + ICMP_MINLEN)) {
846 char address[INET6_ADDRSTRLEN];
847 parse_address(&resp_addr, address, sizeof(address));
766 crash("received packet too short for ICMP (%d bytes, expected %d) from %s\n", 848 crash("received packet too short for ICMP (%d bytes, expected %d) from %s\n",
767 n, hlen + icmp_pkt_size, inet_ntoa(resp_addr.sin_addr)); 849 n, hlen + icmp_pkt_size, address);
768 } 850 }
769 /* else if(debug) { */ 851 /* else if(debug) { */
770 /* printf("ip header size: %u, packet size: %u (expected %u, %u)\n", */ 852 /* printf("ip header size: %u, packet size: %u (expected %u, %u)\n", */
@@ -773,23 +855,39 @@ wait_for_reply(int sock, u_int t)
773 /* } */ 855 /* } */
774 856
775 /* check the response */ 857 /* check the response */
776 memcpy(&icp, buf + hlen, sizeof(icp));
777 858
778 if(ntohs(icp.icmp_id) != pid || icp.icmp_type != ICMP_ECHOREPLY || 859 memcpy(packet.buf, buf + hlen, icmp_pkt_size);
779 ntohs(icp.icmp_seq) >= targets*packets) { 860/* address_family == AF_INET6 ? sizeof(struct icmp6_hdr)
861 : sizeof(struct icmp));*/
862
863 if( (address_family == PF_INET &&
864 (ntohs(packet.icp->icmp_id) != pid || packet.icp->icmp_type != ICMP_ECHOREPLY
865 || ntohs(packet.icp->icmp_seq) >= targets * packets))
866 || (address_family == PF_INET6 &&
867 (ntohs(packet.icp6->icmp6_id) != pid || packet.icp6->icmp6_type != ICMP6_ECHO_REPLY
868 || ntohs(packet.icp6->icmp6_seq) >= targets * packets))) {
780 if(debug > 2) printf("not a proper ICMP_ECHOREPLY\n"); 869 if(debug > 2) printf("not a proper ICMP_ECHOREPLY\n");
781 handle_random_icmp(buf + hlen, &resp_addr); 870 handle_random_icmp(buf + hlen, &resp_addr);
782 continue; 871 continue;
783 } 872 }
784 873
785 /* this is indeed a valid response */ 874 /* this is indeed a valid response */
786 memcpy(&data, icp.icmp_data, sizeof(data)); 875 if (address_family == PF_INET) {
787 if (debug > 2) 876 memcpy(&data, packet.icp->icmp_data, sizeof(data));
788 printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n", 877 if (debug > 2)
789 (unsigned long)sizeof(data), ntohs(icp.icmp_id), 878 printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n",
790 ntohs(icp.icmp_seq), icp.icmp_cksum); 879 (unsigned long)sizeof(data), ntohs(packet.icp->icmp_id),
880 ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum);
881 host = table[ntohs(packet.icp->icmp_seq)/packets];
882 } else {
883 memcpy(&data, &packet.icp6->icmp6_dataun.icmp6_un_data8[4], sizeof(data));
884 if (debug > 2)
885 printf("ICMP echo-reply of len %lu, id %u, seq %u, cksum 0x%X\n",
886 (unsigned long)sizeof(data), ntohs(packet.icp6->icmp6_id),
887 ntohs(packet.icp6->icmp6_seq), packet.icp6->icmp6_cksum);
888 host = table[ntohs(packet.icp6->icmp6_seq)/packets];
889 }
791 890
792 host = table[ntohs(icp.icmp_seq)/packets];
793 tdiff = get_timevaldiff(&data.stime, &now); 891 tdiff = get_timevaldiff(&data.stime, &now);
794 892
795 host->time_waited += tdiff; 893 host->time_waited += tdiff;
@@ -801,22 +899,43 @@ wait_for_reply(int sock, u_int t)
801 host->rtmin = tdiff; 899 host->rtmin = tdiff;
802 900
803 if(debug) { 901 if(debug) {
804 printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u, max: %0.3f, min: %0.3f\n", 902 char address[INET6_ADDRSTRLEN];
805 (float)tdiff / 1000, inet_ntoa(resp_addr.sin_addr), 903 parse_address(&resp_addr, address, sizeof(address));
806 ttl, ip->ip_ttl, (float)host->rtmax / 1000, (float)host->rtmin / 1000); 904
905 switch(address_family) {
906 case AF_INET: {
907 printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u, max: %0.3f, min: %0.3f\n",
908 (float)tdiff / 1000,
909 address,
910 ttl,
911 ip->ip.ip_ttl,
912 (float)host->rtmax / 1000,
913 (float)host->rtmin / 1000);
914 break;
915 };
916 case AF_INET6: {
917 printf("%0.3f ms rtt from %s, outgoing ttl: %u, max: %0.3f, min: %0.3f\n",
918 (float)tdiff / 1000,
919 address,
920 ttl,
921 (float)host->rtmax / 1000,
922 (float)host->rtmin / 1000);
923 };
924 }
807 } 925 }
808 926
809 /* if we're in hostcheck mode, exit with limited printouts */ 927 /* if we're in hostcheck mode, exit with limited printouts */
810 if(mode == MODE_HOSTCHECK) { 928 if(mode == MODE_HOSTCHECK) {
811 printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|" 929 printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|"
812 "pkt=%u;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n", 930 "pkt=%u;;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n",
813 host->name, icmp_recv, (float)tdiff / 1000, 931 host->name, icmp_recv, (float)tdiff / 1000,
814 icmp_recv, packets, (float)tdiff / 1000, 932 icmp_recv, packets, (float)tdiff / 1000,
815 (float)warn.rta / 1000, (float)crit.rta / 1000); 933 (float)warn.rta / 1000, (float)crit.rta / 1000);
816 exit(STATE_OK); 934 exit(STATE_OK);
817 } 935 }
818 } 936 }
819 937
938 free(packet.buf);
820 return 0; 939 return 0;
821} 940}
822 941
@@ -824,62 +943,86 @@ wait_for_reply(int sock, u_int t)
824static int 943static int
825send_icmp_ping(int sock, struct rta_host *host) 944send_icmp_ping(int sock, struct rta_host *host)
826{ 945{
827 static union {
828 void *buf; /* re-use so we prevent leaks */
829 struct icmp *icp;
830 u_short *cksum_in;
831 } packet = { NULL };
832 long int len; 946 long int len;
947 size_t addrlen;
833 struct icmp_ping_data data; 948 struct icmp_ping_data data;
834 struct msghdr hdr; 949 struct msghdr hdr;
835 struct iovec iov; 950 struct iovec iov;
836 struct timeval tv; 951 struct timeval tv;
837 struct sockaddr *addr; 952 void *buf = NULL;
838 953
839 if(sock == -1) { 954 if(sock == -1) {
840 errno = 0; 955 errno = 0;
841 crash("Attempt to send on bogus socket"); 956 crash("Attempt to send on bogus socket");
842 return -1; 957 return -1;
843 } 958 }
844 addr = (struct sockaddr *)&host->saddr_in;
845 959
846 if(!packet.buf) { 960 if(!buf) {
847 if (!(packet.buf = malloc(icmp_pkt_size))) { 961 if (!(buf = malloc(icmp_pkt_size))) {
848 crash("send_icmp_ping(): failed to malloc %d bytes for send buffer", 962 crash("send_icmp_ping(): failed to malloc %d bytes for send buffer",
849 icmp_pkt_size); 963 icmp_pkt_size);
850 return -1; /* might be reached if we're in debug mode */ 964 return -1; /* might be reached if we're in debug mode */
851 } 965 }
852 } 966 }
853 memset(packet.buf, 0, icmp_pkt_size); 967 memset(buf, 0, icmp_pkt_size);
854 968
855 if((gettimeofday(&tv, &tz)) == -1) return -1; 969 if((gettimeofday(&tv, &tz)) == -1) {
970 free(buf);
971 return -1;
972 }
856 973
857 data.ping_id = 10; /* host->icmp.icmp_sent; */ 974 data.ping_id = 10; /* host->icmp.icmp_sent; */
858 memcpy(&data.stime, &tv, sizeof(tv)); 975 memcpy(&data.stime, &tv, sizeof(tv));
859 memcpy(&packet.icp->icmp_data, &data, sizeof(data)); 976
860 packet.icp->icmp_type = ICMP_ECHO; 977 if (address_family == AF_INET) {
861 packet.icp->icmp_code = 0; 978 struct icmp *icp = (struct icmp*)buf;
862 packet.icp->icmp_cksum = 0; 979 addrlen = sizeof(struct sockaddr_in);
863 packet.icp->icmp_id = htons(pid); 980
864 packet.icp->icmp_seq = htons(host->id++); 981 memcpy(&icp->icmp_data, &data, sizeof(data));
865 packet.icp->icmp_cksum = icmp_checksum(packet.cksum_in, icmp_pkt_size); 982
866 983 icp->icmp_type = ICMP_ECHO;
867 if (debug > 2) 984 icp->icmp_code = 0;
868 printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n", 985 icp->icmp_cksum = 0;
869 (unsigned long)sizeof(data), ntohs(packet.icp->icmp_id), 986 icp->icmp_id = htons(pid);
870 ntohs(packet.icp->icmp_seq), packet.icp->icmp_cksum, 987 icp->icmp_seq = htons(host->id++);
871 host->name); 988 icp->icmp_cksum = icmp_checksum((uint16_t*)buf, (size_t)icmp_pkt_size);
989
990 if (debug > 2)
991 printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n",
992 (unsigned long)sizeof(data), ntohs(icp->icmp_id), ntohs(icp->icmp_seq), icp->icmp_cksum, host->name);
993 }
994 else {
995 struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf;
996 addrlen = sizeof(struct sockaddr_in6);
997
998 memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data));
999
1000 icp6->icmp6_type = ICMP6_ECHO_REQUEST;
1001 icp6->icmp6_code = 0;
1002 icp6->icmp6_cksum = 0;
1003 icp6->icmp6_id = htons(pid);
1004 icp6->icmp6_seq = htons(host->id++);
1005 // let checksum be calculated automatically
1006
1007 if (debug > 2) {
1008 printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n",
1009 (unsigned long)sizeof(data), ntohs(icp6->icmp6_id),
1010 ntohs(icp6->icmp6_seq), icp6->icmp6_cksum, host->name);
1011 }
1012 }
872 1013
873 memset(&iov, 0, sizeof(iov)); 1014 memset(&iov, 0, sizeof(iov));
874 iov.iov_base = packet.buf; 1015 iov.iov_base = buf;
875 iov.iov_len = icmp_pkt_size; 1016 iov.iov_len = icmp_pkt_size;
876 1017
877 memset(&hdr, 0, sizeof(hdr)); 1018 memset(&hdr, 0, sizeof(hdr));
878 hdr.msg_name = addr; 1019 hdr.msg_name = (struct sockaddr *)&host->saddr_in;
879 hdr.msg_namelen = sizeof(struct sockaddr); 1020 hdr.msg_namelen = addrlen;
880 hdr.msg_iov = &iov; 1021 hdr.msg_iov = &iov;
881 hdr.msg_iovlen = 1; 1022 hdr.msg_iovlen = 1;
882 1023
1024 errno = 0;
1025
883/* MSG_CONFIRM is a linux thing and only available on linux kernels >= 2.3.15, see send(2) */ 1026/* MSG_CONFIRM is a linux thing and only available on linux kernels >= 2.3.15, see send(2) */
884#ifdef MSG_CONFIRM 1027#ifdef MSG_CONFIRM
885 len = sendmsg(sock, &hdr, MSG_CONFIRM); 1028 len = sendmsg(sock, &hdr, MSG_CONFIRM);
@@ -887,9 +1030,15 @@ send_icmp_ping(int sock, struct rta_host *host)
887 len = sendmsg(sock, &hdr, 0); 1030 len = sendmsg(sock, &hdr, 0);
888#endif 1031#endif
889 1032
1033 free(buf);
1034
890 if(len < 0 || (unsigned int)len != icmp_pkt_size) { 1035 if(len < 0 || (unsigned int)len != icmp_pkt_size) {
891 if(debug) printf("Failed to send ping to %s\n", 1036 if(debug) {
892 inet_ntoa(host->saddr_in.sin_addr)); 1037 char address[INET6_ADDRSTRLEN];
1038 parse_address((struct sockaddr_storage *)&host->saddr_in, address, sizeof(address));
1039 printf("Failed to send ping to %s: %s\n", address, strerror(errno));
1040 }
1041 errno = 0;
893 return -1; 1042 return -1;
894 } 1043 }
895 1044
@@ -934,7 +1083,7 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
934 1083
935 if(!n) return 0; /* timeout */ 1084 if(!n) return 0; /* timeout */
936 1085
937 slen = sizeof(struct sockaddr); 1086 slen = sizeof(struct sockaddr_storage);
938 1087
939 memset(&iov, 0, sizeof(iov)); 1088 memset(&iov, 0, sizeof(iov));
940 iov.iov_base = buf; 1089 iov.iov_base = buf;
@@ -958,6 +1107,7 @@ recvfrom_wto(int sock, void *buf, unsigned int len, struct sockaddr *saddr,
958 break ; 1107 break ;
959 } 1108 }
960 } 1109 }
1110
961 if (!chdr) 1111 if (!chdr)
962#endif // SO_TIMESTAMP 1112#endif // SO_TIMESTAMP
963 gettimeofday(tv, &tz); 1113 gettimeofday(tv, &tz);
@@ -991,10 +1141,11 @@ finish(int sig)
991 1141
992 /* iterate thrice to calculate values, give output, and print perfparse */ 1142 /* iterate thrice to calculate values, give output, and print perfparse */
993 host = list; 1143 host = list;
1144
994 while(host) { 1145 while(host) {
995 if(!host->icmp_recv) { 1146 if(!host->icmp_recv) {
996 /* rta 0 is ofcourse not entirely correct, but will still show up 1147 /* rta 0 is ofcourse not entirely correct, but will still show up
997 * conspicuosly as missing entries in perfparse and cacti */ 1148 * conspicuously as missing entries in perfparse and cacti */
998 pl = 100; 1149 pl = 100;
999 rta = 0; 1150 rta = 0;
1000 status = STATE_CRITICAL; 1151 status = STATE_CRITICAL;
@@ -1039,10 +1190,12 @@ finish(int sig)
1039 if(!host->icmp_recv) { 1190 if(!host->icmp_recv) {
1040 status = STATE_CRITICAL; 1191 status = STATE_CRITICAL;
1041 if(host->flags & FLAG_LOST_CAUSE) { 1192 if(host->flags & FLAG_LOST_CAUSE) {
1193 char address[INET6_ADDRSTRLEN];
1194 parse_address(&host->error_addr, address, sizeof(address));
1042 printf("%s: %s @ %s. rta nan, lost %d%%", 1195 printf("%s: %s @ %s. rta nan, lost %d%%",
1043 host->name, 1196 host->name,
1044 get_icmp_error_msg(host->icmp_type, host->icmp_code), 1197 get_icmp_error_msg(host->icmp_type, host->icmp_code),
1045 inet_ntoa(host->error_addr), 1198 address,
1046 100); 1199 100);
1047 } 1200 }
1048 else { /* not marked as lost cause, so we have no flags for it */ 1201 else { /* not marked as lost cause, so we have no flags for it */
@@ -1068,7 +1221,7 @@ finish(int sig)
1068 host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, 1221 host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
1069 (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl, 1222 (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl,
1070 (targets > 1) ? host->name : "", (float)host->rtmax / 1000, 1223 (targets > 1) ? host->name : "", (float)host->rtmax / 1000,
1071 (targets > 1) ? host->name : "", (host->rtmin < DBL_MAX) ? (float)host->rtmin / 1000 : (float)0); 1224 (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0);
1072 1225
1073 host = host->next; 1226 host = host->next;
1074 } 1227 }
@@ -1104,7 +1257,6 @@ get_timevaldiff(struct timeval *early, struct timeval *later)
1104 { 1257 {
1105 return 0; 1258 return 0;
1106 } 1259 }
1107
1108 ret = (later->tv_sec - early->tv_sec) * 1000000; 1260 ret = (later->tv_sec - early->tv_sec) * 1000000;
1109 ret += later->tv_usec - early->tv_usec; 1261 ret += later->tv_usec - early->tv_usec;
1110 1262
@@ -1112,18 +1264,35 @@ get_timevaldiff(struct timeval *early, struct timeval *later)
1112} 1264}
1113 1265
1114static int 1266static int
1115add_target_ip(char *arg, struct in_addr *in) 1267add_target_ip(char *arg, struct sockaddr_storage *in)
1116{ 1268{
1117 struct rta_host *host; 1269 struct rta_host *host;
1270 struct sockaddr_in *sin, *host_sin;
1271 struct sockaddr_in6 *sin6, *host_sin6;
1118 1272
1119 /* disregard obviously stupid addresses */ 1273 if (address_family == AF_INET)
1120 if(in->s_addr == INADDR_NONE || in->s_addr == INADDR_ANY) 1274 sin = (struct sockaddr_in *)in;
1275 else
1276 sin6 = (struct sockaddr_in6 *)in;
1277
1278
1279
1280 /* disregard obviously stupid addresses
1281 * (I didn't find an ipv6 equivalent to INADDR_NONE) */
1282 if (((address_family == AF_INET && (sin->sin_addr.s_addr == INADDR_NONE
1283 || sin->sin_addr.s_addr == INADDR_ANY)))
1284 || (address_family == AF_INET6 && (sin6->sin6_addr.s6_addr == in6addr_any.s6_addr))) {
1121 return -1; 1285 return -1;
1286 }
1122 1287
1123 /* no point in adding two identical IP's, so don't. ;) */ 1288 /* no point in adding two identical IP's, so don't. ;) */
1124 host = list; 1289 host = list;
1125 while(host) { 1290 while(host) {
1126 if(host->saddr_in.sin_addr.s_addr == in->s_addr) { 1291 host_sin = (struct sockaddr_in *)&host->saddr_in;
1292 host_sin6 = (struct sockaddr_in6 *)&host->saddr_in;
1293
1294 if( (address_family == AF_INET && host_sin->sin_addr.s_addr == sin->sin_addr.s_addr)
1295 || (address_family == AF_INET6 && host_sin6->sin6_addr.s6_addr == sin6->sin6_addr.s6_addr)) {
1127 if(debug) printf("Identical IP already exists. Not adding %s\n", arg); 1296 if(debug) printf("Identical IP already exists. Not adding %s\n", arg);
1128 return -1; 1297 return -1;
1129 } 1298 }
@@ -1131,21 +1300,31 @@ add_target_ip(char *arg, struct in_addr *in)
1131 } 1300 }
1132 1301
1133 /* add the fresh ip */ 1302 /* add the fresh ip */
1134 host = malloc(sizeof(struct rta_host)); 1303 host = (struct rta_host*)malloc(sizeof(struct rta_host));
1135 if(!host) { 1304 if(!host) {
1136 crash("add_target_ip(%s, %s): malloc(%d) failed", 1305 char straddr[INET6_ADDRSTRLEN];
1137 arg, inet_ntoa(*in), sizeof(struct rta_host)); 1306 parse_address((struct sockaddr_storage*)&in, straddr, sizeof(straddr));
1307 crash("add_target_ip(%s, %s): malloc(%lu) failed",
1308 arg, straddr, sizeof(struct rta_host));
1138 } 1309 }
1139 memset(host, 0, sizeof(struct rta_host)); 1310 memset(host, 0, sizeof(struct rta_host));
1140 1311
1141 /* set the values. use calling name for output */ 1312 /* set the values. use calling name for output */
1142 host->name = strdup(arg); 1313 host->name = strdup(arg);
1143 1314
1144 /* fill out the sockaddr_in struct */ 1315 /* fill out the sockaddr_storage struct */
1145 host->saddr_in.sin_family = AF_INET; 1316 if(address_family == AF_INET) {
1146 host->saddr_in.sin_addr.s_addr = in->s_addr; 1317 host_sin = (struct sockaddr_in *)&host->saddr_in;
1318 host_sin->sin_family = AF_INET;
1319 host_sin->sin_addr.s_addr = sin->sin_addr.s_addr;
1320 }
1321 else {
1322 host_sin6 = (struct sockaddr_in6 *)&host->saddr_in;
1323 host_sin6->sin6_family = AF_INET6;
1324 memcpy(host_sin6->sin6_addr.s6_addr, sin6->sin6_addr.s6_addr, sizeof host_sin6->sin6_addr.s6_addr);
1325 }
1147 1326
1148 host->rtmin = DBL_MAX; 1327 host->rtmin = INFINITY;
1149 1328
1150 if(!list) list = cursor = host; 1329 if(!list) list = cursor = host;
1151 else cursor->next = host; 1330 else cursor->next = host;
@@ -1160,31 +1339,67 @@ add_target_ip(char *arg, struct in_addr *in)
1160static int 1339static int
1161add_target(char *arg) 1340add_target(char *arg)
1162{ 1341{
1163 int i; 1342 int error, result = -1;
1164 struct hostent *he; 1343 struct sockaddr_storage ip;
1165 struct in_addr *in, ip; 1344 struct addrinfo hints, *res, *p;
1345 struct sockaddr_in *sin;
1346 struct sockaddr_in6 *sin6;
1347
1348 switch (address_family) {
1349 case -1:
1350 /* -4 and -6 are not specified on cmdline */
1351 address_family = AF_INET;
1352 sin = (struct sockaddr_in *)&ip;
1353 result = inet_pton(address_family, arg, &sin->sin_addr);
1354#ifdef USE_IPV6
1355 if( result != 1 ){
1356 address_family = AF_INET6;
1357 sin6 = (struct sockaddr_in6 *)&ip;
1358 result = inet_pton(address_family, arg, &sin6->sin6_addr);
1359 }
1360#endif
1361 /* If we don't find any valid addresses, we still don't know the address_family */
1362 if ( result != 1) {
1363 address_family = -1;
1364 }
1365 break;
1366 case AF_INET:
1367 sin = (struct sockaddr_in *)&ip;
1368 result = inet_pton(address_family, arg, &sin->sin_addr);
1369 break;
1370 case AF_INET6:
1371 sin6 = (struct sockaddr_in6 *)&ip;
1372 result = inet_pton(address_family, arg, &sin6->sin6_addr);
1373 break;
1374 default: crash("Address family not supported");
1375 }
1166 1376
1167 /* don't resolve if we don't have to */ 1377 /* don't resolve if we don't have to */
1168 if((ip.s_addr = inet_addr(arg)) != INADDR_NONE) { 1378 if(result == 1) {
1169 /* don't add all ip's if we were given a specific one */ 1379 /* don't add all ip's if we were given a specific one */
1170 return add_target_ip(arg, &ip); 1380 return add_target_ip(arg, &ip);
1171 /* he = gethostbyaddr((char *)in, sizeof(struct in_addr), AF_INET); */
1172 /* if(!he) return add_target_ip(arg, in); */
1173 } 1381 }
1174 else { 1382 else {
1175 errno = 0; 1383 errno = 0;
1176 he = gethostbyname(arg); 1384 memset(&hints, 0, sizeof(hints));
1177 if(!he) { 1385 if (address_family == -1) {
1386 hints.ai_family = AF_UNSPEC;
1387 } else {
1388 hints.ai_family = address_family == AF_INET ? PF_INET : PF_INET6;
1389 }
1390 hints.ai_socktype = SOCK_RAW;
1391 if((error = getaddrinfo(arg, NULL, &hints, &res)) != 0) {
1178 errno = 0; 1392 errno = 0;
1179 crash("Failed to resolve %s", arg); 1393 crash("Failed to resolve %s: %s", arg, gai_strerror(error));
1180 return -1; 1394 return -1;
1181 } 1395 }
1396 address_family = res->ai_family;
1182 } 1397 }
1183 1398
1184 /* possibly add all the IP's as targets */ 1399 /* possibly add all the IP's as targets */
1185 for(i = 0; he->h_addr_list[i]; i++) { 1400 for(p = res; p != NULL; p = p->ai_next) {
1186 in = (struct in_addr *)he->h_addr_list[i]; 1401 memcpy(&ip, p->ai_addr, p->ai_addrlen);
1187 add_target_ip(arg, in); 1402 add_target_ip(arg, &ip);
1188 1403
1189 /* this is silly, but it works */ 1404 /* this is silly, but it works */
1190 if(mode == MODE_HOSTCHECK || mode == MODE_ALL) { 1405 if(mode == MODE_HOSTCHECK || mode == MODE_ALL) {
@@ -1193,6 +1408,7 @@ add_target(char *arg)
1193 } 1408 }
1194 break; 1409 break;
1195 } 1410 }
1411 freeaddrinfo(res);
1196 1412
1197 return 0; 1413 return 0;
1198} 1414}
@@ -1203,7 +1419,7 @@ set_source_ip(char *arg)
1203 struct sockaddr_in src; 1419 struct sockaddr_in src;
1204 1420
1205 memset(&src, 0, sizeof(src)); 1421 memset(&src, 0, sizeof(src));
1206 src.sin_family = AF_INET; 1422 src.sin_family = address_family;
1207 if((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE) 1423 if((src.sin_addr.s_addr = inet_addr(arg)) == INADDR_NONE)
1208 src.sin_addr.s_addr = get_ip_address(arg); 1424 src.sin_addr.s_addr = get_ip_address(arg);
1209 if(bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1) 1425 if(bind(icmp_sock, (struct sockaddr *)&src, sizeof(src)) == -1)
@@ -1214,20 +1430,26 @@ set_source_ip(char *arg)
1214static in_addr_t 1430static in_addr_t
1215get_ip_address(const char *ifname) 1431get_ip_address(const char *ifname)
1216{ 1432{
1433 // TODO: Rewrite this so the function return an error and we exit somewhere else
1434 struct sockaddr_in ip;
1435 ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy
1217#if defined(SIOCGIFADDR) 1436#if defined(SIOCGIFADDR)
1218 struct ifreq ifr; 1437 struct ifreq ifr;
1219 struct sockaddr_in ip;
1220 1438
1221 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); 1439 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
1440
1222 ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; 1441 ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
1442
1223 if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) 1443 if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1)
1224 crash("Cannot determine IP address of interface %s", ifname); 1444 crash("Cannot determine IP address of interface %s", ifname);
1445
1225 memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); 1446 memcpy(&ip, &ifr.ifr_addr, sizeof(ip));
1226 return ip.sin_addr.s_addr;
1227#else 1447#else
1448 (void) ifname;
1228 errno = 0; 1449 errno = 0;
1229 crash("Cannot get interface IP address on this platform."); 1450 crash("Cannot get interface IP address on this platform.");
1230#endif 1451#endif
1452 return ip.sin_addr.s_addr;
1231} 1453}
1232 1454
1233/* 1455/*
@@ -1309,18 +1531,19 @@ get_threshold(char *str, threshold *th)
1309} 1531}
1310 1532
1311unsigned short 1533unsigned short
1312icmp_checksum(unsigned short *p, int n) 1534icmp_checksum(uint16_t *p, size_t n)
1313{ 1535{
1314 register unsigned short cksum; 1536 unsigned short cksum;
1315 register long sum = 0; 1537 long sum = 0;
1316 1538
1317 while(n > 1) { 1539 /* sizeof(uint16_t) == 2 */
1318 sum += *p++; 1540 while(n >= 2) {
1541 sum += *(p++);
1319 n -= 2; 1542 n -= 2;
1320 } 1543 }
1321 1544
1322 /* mop up the occasional odd byte */ 1545 /* mop up the occasional odd byte */
1323 if(n == 1) sum += (unsigned char)*p; 1546 if(n == 1) sum += *((uint8_t *)p -1);
1324 1547
1325 sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ 1548 sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
1326 sum += (sum >> 16); /* add carry */ 1549 sum += (sum >> 16); /* add carry */
@@ -1347,6 +1570,8 @@ print_help(void)
1347 1570
1348 printf (" %s\n", "-H"); 1571 printf (" %s\n", "-H");
1349 printf (" %s\n", _("specify a target")); 1572 printf (" %s\n", _("specify a target"));
1573 printf (" %s\n", "[-4|-6]");
1574 printf (" %s\n", _("Use IPv4 (default) or IPv6 to communicate with the targets"));
1350 printf (" %s\n", "-w"); 1575 printf (" %s\n", "-w");
1351 printf (" %s", _("warning threshold (currently ")); 1576 printf (" %s", _("warning threshold (currently "));
1352 printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl); 1577 printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl);
diff --git a/plugins-root/pst3.c b/plugins-root/pst3.c
index c3589f0a..1f69f3a6 100644
--- a/plugins-root/pst3.c
+++ b/plugins-root/pst3.c
@@ -257,6 +257,6 @@ void usage() {
257 printf("\tRSS - Real memory usage (kilobytes)\n"); 257 printf("\tRSS - Real memory usage (kilobytes)\n");
258 printf("\t%%CPU - CPU usage\n"); 258 printf("\t%%CPU - CPU usage\n");
259 printf("\tCOMMAND - Command being run\n"); 259 printf("\tCOMMAND - Command being run\n");
260 printf("\tARGS - Full command line with arguements\n"); 260 printf("\tARGS - Full command line with arguments\n");
261 return; 261 return;
262} 262}
diff --git a/plugins-root/t/check_dhcp.t b/plugins-root/t/check_dhcp.t
index 222f4544..ce627736 100644
--- a/plugins-root/t/check_dhcp.t
+++ b/plugins-root/t/check_dhcp.t
@@ -19,7 +19,7 @@ if ($allow_sudo eq "yes" or $> == 0) {
19my $sudo = $> == 0 ? '' : 'sudo'; 19my $sudo = $> == 0 ? '' : 'sudo';
20 20
21my $successOutput = '/OK: Received \d+ DHCPOFFER\(s\), \d+ of 1 requested servers responded, max lease time = \d+ sec\./'; 21my $successOutput = '/OK: Received \d+ DHCPOFFER\(s\), \d+ of 1 requested servers responded, max lease time = \d+ sec\./';
22my $failureOutput = '/CRITICAL: No DHCPOFFERs were received/'; 22my $failureOutput = '/CRITICAL: (No DHCPOFFERs were received|Received \d+ DHCPOFFER\(s\), 0 of 1 requested servers responded, max lease time = \d+ sec\.)/';
23my $invalidOutput = '/Invalid hostname/'; 23my $invalidOutput = '/Invalid hostname/';
24 24
25my $host_responsive = getTestParameter( "NP_HOST_DHCP_RESPONSIVE", 25my $host_responsive = getTestParameter( "NP_HOST_DHCP_RESPONSIVE",
@@ -36,7 +36,12 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
36 36
37# try to determince interface 37# try to determince interface
38my $interface = ''; 38my $interface = '';
39if(`ifconfig -a 2>/dev/null` =~ m/^(e\w*\d+)/mx and $1 ne 'eth0') { 39
40# find interface used for default route
41if (-x '/usr/sbin/ip' and `/usr/sbin/ip route get 1.1.1.1 2>/dev/null` =~ m/\sdev\s(\S+)/) {
42 $interface = "-i $1";
43}
44elsif (`ifconfig -a 2>/dev/null` =~ m/^(e\w*\d+)/mx and $1 ne 'eth0') {
40 $interface = ' -i '.$1; 45 $interface = ' -i '.$1;
41} 46}
42 47
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t
index e043d4ed..96addd3b 100644
--- a/plugins-root/t/check_icmp.t
+++ b/plugins-root/t/check_icmp.t
@@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO",
12 "no" ); 12 "no" );
13 13
14if ($allow_sudo eq "yes" or $> == 0) { 14if ($allow_sudo eq "yes" or $> == 0) {
15 plan tests => 16; 15 plan tests => 20;
16} else { 16} else {
17 plan skip_all => "Need sudo to test check_icmp"; 17 plan skip_all => "Need sudo to test check_icmp";
18} 18}
@@ -83,3 +83,14 @@ $res = NPTest->testCmd(
83is( $res->return_code, 2, "One of two host nonresponsive - two required" ); 83is( $res->return_code, 2, "One of two host nonresponsive - two required" );
84like( $res->output, $failureOutput, "Output OK" ); 84like( $res->output, $failureOutput, "Output OK" );
85 85
86$res = NPTest->testCmd(
87 "$sudo ./check_icmp -H $host_responsive -s 127.0.15.15 -w 10000ms,100% -c 10000ms,100% -n 1 -m 2"
88 );
89is( $res->return_code, 0, "IPv4 source_ip accepted" );
90like( $res->output, $successOutput, "Output OK" );
91
92$res = NPTest->testCmd(
93 "$sudo ./check_icmp -H $host_responsive -b 65507"
94 );
95is( $res->return_code, 0, "Try max packet size" );
96like( $res->output, $successOutput, "Output OK - Didn't overflow" );
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am
index ea65aed1..7879791f 100644
--- a/plugins-scripts/Makefile.am
+++ b/plugins-scripts/Makefile.am
@@ -16,11 +16,13 @@ VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/
16libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \ 16libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
17 check_log check_oracle check_rpc check_sensors check_wave \ 17 check_log check_oracle check_rpc check_sensors check_wave \
18 check_ifstatus check_ifoperstatus check_mailq check_file_age \ 18 check_ifstatus check_ifoperstatus check_mailq check_file_age \
19 check_uptime check_mssql \
19 utils.sh utils.pm 20 utils.sh utils.pm
20 21
21EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ 22EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
22 check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \ 23 check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \
23 check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \ 24 check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
25 check_uptime.pl check_mssql.pl \
24 utils.sh.in utils.pm.in t 26 utils.sh.in utils.pm.in t
25 27
26EDIT = sed \ 28EDIT = sed \
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl
index 05b99203..531625c4 100755
--- a/plugins-scripts/check_breeze.pl
+++ b/plugins-scripts/check_breeze.pl
@@ -14,8 +14,9 @@ sub print_help ();
14sub print_usage (); 14sub print_usage ();
15 15
16$ENV{'PATH'}='@TRUSTED_PATH@'; 16$ENV{'PATH'}='@TRUSTED_PATH@';
17$ENV{'BASH_ENV'}=''; 17$ENV{'BASH_ENV'}='';
18$ENV{'ENV'}=''; 18$ENV{'ENV'}='';
19$ENV{'CDPATH'}='';
19 20
20Getopt::Long::Configure('bundling'); 21Getopt::Long::Configure('bundling');
21GetOptions 22GetOptions
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 4e46397d..eda8dd48 100755..100644
--- a/plugins-scripts/check_disk_smb.pl
+++ b/plugins-scripts/check_disk_smb.pl
@@ -19,15 +19,18 @@
19# 19#
20 20
21require 5.004; 21require 5.004;
22use POSIX; 22use POSIX qw(setsid);
23use strict; 23use strict;
24use Getopt::Long; 24use Getopt::Long;
25use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose); 25use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $opt_C $opt_t $verbose);
26use vars qw($PROGNAME); 26use vars qw($PROGNAME);
27use FindBin; 27use FindBin;
28use lib "$FindBin::Bin"; 28use lib "$FindBin::Bin";
29use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); 29use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
30 30
31# make us session leader which makes all children exit if we do
32setsid;
33
31sub print_help (); 34sub print_help ();
32sub print_usage (); 35sub print_usage ();
33 36
@@ -40,6 +43,7 @@ $ENV{'ENV'}='';
40Getopt::Long::Configure('bundling'); 43Getopt::Long::Configure('bundling');
41GetOptions 44GetOptions
42 ("v" => \$verbose, "verbose" => \$verbose, 45 ("v" => \$verbose, "verbose" => \$verbose,
46 "t=i" => \$opt_t, "timeout=i" => \$opt_t,
43 "P=s" => \$opt_P, "port=s" => \$opt_P, 47 "P=s" => \$opt_P, "port=s" => \$opt_P,
44 "V" => \$opt_V, "version" => \$opt_V, 48 "V" => \$opt_V, "version" => \$opt_V,
45 "h" => \$opt_h, "help" => \$opt_h, 49 "h" => \$opt_h, "help" => \$opt_h,
@@ -50,7 +54,8 @@ GetOptions
50 "s=s" => \$opt_s, "share=s" => \$opt_s, 54 "s=s" => \$opt_s, "share=s" => \$opt_s,
51 "W=s" => \$opt_W, "workgroup=s" => \$opt_W, 55 "W=s" => \$opt_W, "workgroup=s" => \$opt_W,
52 "H=s" => \$opt_H, "hostname=s" => \$opt_H, 56 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
53 "a=s" => \$opt_a, "address=s" => \$opt_a); 57 "a=s" => \$opt_a, "address=s" => \$opt_a,
58 "C=s" => \$opt_C, "configfile=s" => \$opt_C);
54 59
55if ($opt_V) { 60if ($opt_V) {
56 print_revision($PROGNAME,'@NP_VERSION@'); #' 61 print_revision($PROGNAME,'@NP_VERSION@'); #'
@@ -88,6 +93,12 @@ my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
88my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); 93my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
89($crit) || usage("Invalid critical threshold: $opt_c\n"); 94($crit) || usage("Invalid critical threshold: $opt_c\n");
90 95
96($opt_C) || ($opt_C = shift @ARGV) || ($opt_C = "");
97my $configfile = $opt_C if ($opt_C);
98usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile);
99
100if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; }
101
91# Execute the given command line and return anything it writes to STDOUT and/or 102# Execute the given command line and return anything it writes to STDOUT and/or
92# STDERR. (This might be useful for other plugins, too, so it should possibly 103# STDERR. (This might be useful for other plugins, too, so it should possibly
93# be moved to utils.pm.) 104# be moved to utils.pm.)
@@ -175,6 +186,8 @@ my @lines = undef;
175# Just in case of problems, let's not hang the monitoring system 186# Just in case of problems, let's not hang the monitoring system
176$SIG{'ALRM'} = sub { 187$SIG{'ALRM'} = sub {
177 print "No Answer from Client\n"; 188 print "No Answer from Client\n";
189 $SIG{'INT'} = 'IGNORE';
190 kill(-2, $$);
178 exit $ERRORS{"UNKNOWN"}; 191 exit $ERRORS{"UNKNOWN"};
179}; 192};
180alarm($TIMEOUT); 193alarm($TIMEOUT);
@@ -188,6 +201,7 @@ my @cmd = (
188 defined($workgroup) ? ("-W", $workgroup) : (), 201 defined($workgroup) ? ("-W", $workgroup) : (),
189 defined($address) ? ("-I", $address) : (), 202 defined($address) ? ("-I", $address) : (),
190 defined($opt_P) ? ("-p", $opt_P) : (), 203 defined($opt_P) ? ("-p", $opt_P) : (),
204 defined($configfile) ? ("-s", $configfile) : (),
191 "-c", "du" 205 "-c", "du"
192); 206);
193 207
@@ -288,7 +302,8 @@ exit $ERRORS{$state};
288 302
289sub print_usage () { 303sub print_usage () {
290 print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> 304 print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
291 -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n"; 305 -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>] [-t timeout]
306 [-C <configfile>]\n";
292} 307}
293 308
294sub print_help () { 309sub print_help () {
@@ -314,11 +329,14 @@ Perl Check SMB Disk plugin for monitoring
314 Password to log in to server. (Defaults to an empty password) 329 Password to log in to server. (Defaults to an empty password)
315-w, --warning=INTEGER or INTEGER[kMG] 330-w, --warning=INTEGER or INTEGER[kMG]
316 Percent of used space at which a warning will be generated (Default: 85%) 331 Percent of used space at which a warning will be generated (Default: 85%)
317
318-c, --critical=INTEGER or INTEGER[kMG] 332-c, --critical=INTEGER or INTEGER[kMG]
319 Percent of used space at which a critical will be generated (Defaults: 95%) 333 Percent of used space at which a critical will be generated (Defaults: 95%)
334-t, --timeout=INTEGER
335 Seconds before connection times out (Default: 15)
320-P, --port=INTEGER 336-P, --port=INTEGER
321 Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) 337 Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default)
338-C, --configfile=STRING
339 Path to configfile which should be used by smbclient (Defaults to smb.conf of your smb installation)
322 340
323 If thresholds are followed by either a k, M, or G then check to see if that 341 If thresholds are followed by either a k, M, or G then check to see if that
324 much disk space is available (kilobytes, Megabytes, Gigabytes) 342 much disk space is available (kilobytes, Megabytes, Gigabytes)
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl
index 56b8e97c..26281ddd 100755
--- a/plugins-scripts/check_file_age.pl
+++ b/plugins-scripts/check_file_age.pl
@@ -43,8 +43,6 @@ $ENV{'ENV'}='';
43 43
44$opt_w = 240; 44$opt_w = 240;
45$opt_c = 600; 45$opt_c = 600;
46$opt_W = 0;
47$opt_C = 0;
48$opt_f = ""; 46$opt_f = "";
49 47
50Getopt::Long::Configure('bundling'); 48Getopt::Long::Configure('bundling');
@@ -53,10 +51,10 @@ GetOptions(
53 "h" => \$opt_h, "help" => \$opt_h, 51 "h" => \$opt_h, "help" => \$opt_h,
54 "i" => \$opt_i, "ignore-missing" => \$opt_i, 52 "i" => \$opt_i, "ignore-missing" => \$opt_i,
55 "f=s" => \$opt_f, "file" => \$opt_f, 53 "f=s" => \$opt_f, "file" => \$opt_f,
56 "w=f" => \$opt_w, "warning-age=f" => \$opt_w, 54 "w=s" => \$opt_w, "warning-age=s" => \$opt_w,
57 "W=f" => \$opt_W, "warning-size=f" => \$opt_W, 55 "W=s" => \$opt_W, "warning-size=s" => \$opt_W,
58 "c=f" => \$opt_c, "critical-age=f" => \$opt_c, 56 "c=s" => \$opt_c, "critical-age=s" => \$opt_c,
59 "C=f" => \$opt_C, "critical-size=f" => \$opt_C); 57 "C=s" => \$opt_C, "critical-size=s" => \$opt_C);
60 58
61if ($opt_V) { 59if ($opt_V) {
62 print_revision($PROGNAME, '@NP_VERSION@'); 60 print_revision($PROGNAME, '@NP_VERSION@');
@@ -91,18 +89,47 @@ unless (-e $opt_f) {
91$st = File::stat::stat($opt_f); 89$st = File::stat::stat($opt_f);
92$age = time - $st->mtime; 90$age = time - $st->mtime;
93$size = $st->size; 91$size = $st->size;
94$perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0";
95
96 92
97$result = 'OK'; 93$result = 'OK';
98 94
99if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) { 95if ($opt_c !~ m/^\d+$/ or ($opt_C and $opt_C !~ m/^\d+$/)
100 $result = 'CRITICAL'; 96 or $opt_w !~ m/^\d+$/ or ($opt_W and $opt_W !~ m/^\d+$/)) {
97 # range has been specified so use M::P::R to process
98 require Monitoring::Plugin::Range;
99 # use permissive range defaults for size when none specified
100 $opt_W = "0:" unless ($opt_W);
101 $opt_C = "0:" unless ($opt_C);
102
103 if (Monitoring::Plugin::Range->parse_range_string($opt_c)
104 ->check_range($age) == 1) { # 1 means it raises an alert because it's OUTSIDE the range
105 $result = 'CRITICAL';
106 }
107 elsif (Monitoring::Plugin::Range->parse_range_string($opt_C)
108 ->check_range($size) == 1) {
109 $result = 'CRITICAL';
110 }
111 elsif (Monitoring::Plugin::Range->parse_range_string($opt_w)
112 ->check_range($age) == 1) {
113 $result = 'WARNING';
114 }
115 elsif (Monitoring::Plugin::Range->parse_range_string($opt_W)
116 ->check_range($size) == 1) {
117 $result = 'WARNING';
118 }
101} 119}
102elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) { 120else {
103 $result = 'WARNING'; 121 # use permissive defaults for size when none specified
122 $opt_W = 0 unless ($opt_W);
123 $opt_C = 0 unless ($opt_C);
124 if ($age > $opt_c or $size < $opt_C) {
125 $result = 'CRITICAL';
126 }
127 elsif ($age > $opt_w or $size < $opt_W) {
128 $result = 'WARNING';
129 }
104} 130}
105 131
132$perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0";
106print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes | $perfdata\n"; 133print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes | $perfdata\n";
107exit $ERRORS{$result}; 134exit $ERRORS{$result};
108 135
@@ -120,7 +147,15 @@ sub print_help () {
120 print "\n"; 147 print "\n";
121 print " -i | --ignore-missing : return OK if the file does not exist\n"; 148 print " -i | --ignore-missing : return OK if the file does not exist\n";
122 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; 149 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
123 print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n"; 150 print " <size> File must be at least this many bytes long (default: file size is ignored (0 bytes))\n\n";
151 print " Both <secs> and <size> can specify a range using the standard plugin syntax\n";
152 print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n";
153 print " then all warning and critical arguments will be interpreted as ranges.\n";
154 print " To use range processing the perl module Monitoring::Plugin must be installed\n";
155 print " For range syntax see https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n";
156 print " It is strongly recommended when using range syntax that all four of -w, -W, -c and -C are specified\n";
157 print " otherwise it is unlikely that the size test will be doing what is desired\n";
124 print "\n"; 158 print "\n";
125 support(); 159 support();
126} 160}
161
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index 3eed4bcb..e335cdad 100755
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -124,17 +124,17 @@ if (!defined($session)) {
124## map ifdescr to ifindex - should look at being able to cache this value 124## map ifdescr to ifindex - should look at being able to cache this value
125 125
126if (defined $ifdescr || defined $iftype) { 126if (defined $ifdescr || defined $iftype) {
127 # escape "/" in ifdescr - very common in the Cisco world
128 if (defined $iftype) { 127 if (defined $iftype) {
129 $status=fetch_ifindex($snmpIfType, $iftype); 128 $status=fetch_ifindex($snmpIfType, $iftype);
130 } else { 129 } else {
130 # escape "/" in ifdescr - very common in the Cisco world
131 $ifdescr =~ s/\//\\\//g; 131 $ifdescr =~ s/\//\\\//g;
132 $status=fetch_ifindex($snmpIfDescr, $ifdescr); # if using on device with large number of interfaces 132 $status=fetch_ifindex($snmpIfDescr, $ifdescr); # if using on device with large number of interfaces
133 # recommend use of SNMP v2 (get-bulk) 133 # recommend use of SNMP v2 (get-bulk)
134 } 134 }
135 if ($status==0) { 135 if ($status==0) {
136 $state = "UNKNOWN"; 136 $state = "UNKNOWN";
137 printf "$state: could not retrive ifdescr/iftype snmpkey - $status-$snmpkey\n"; 137 printf "$state: could not retrieve ifdescr/iftype snmpkey - $status-$snmpkey\n";
138 $session->close; 138 $session->close;
139 exit $ERRORS{$state}; 139 exit $ERRORS{$state};
140 } 140 }
@@ -187,7 +187,7 @@ if (defined $ifXTable) {
187 $name = $response->{$snmpIfDescr} ; 187 $name = $response->{$snmpIfDescr} ;
188} 188}
189 189
190## if AdminStatus is down - some one made a consious effort to change config 190## if AdminStatus is down - some one made a conscious effort to change config
191## 191##
192if ( not ($response->{$snmpIfAdminStatus} == 1) ) { 192if ( not ($response->{$snmpIfAdminStatus} == 1) ) {
193 $answer = "Interface $name (index $snmpkey) is administratively down."; 193 $answer = "Interface $name (index $snmpkey) is administratively down.";
@@ -286,7 +286,7 @@ sub print_usage() {
286 printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n"; 286 printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n";
287 printf "Copyright (C) 2000 Christoph Kron\n"; 287 printf "Copyright (C) 2000 Christoph Kron\n";
288 printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n"; 288 printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n";
289 printf "This programm is licensed under the terms of the "; 289 printf "This program is licensed under the terms of the ";
290 printf "GNU General Public License\n(check source code for details)\n"; 290 printf "GNU General Public License\n(check source code for details)\n";
291 printf "\n\n"; 291 printf "\n\n";
292} 292}
@@ -325,7 +325,7 @@ sub print_help() {
325 printf " (Implies the use of -I)\n"; 325 printf " (Implies the use of -I)\n";
326 printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n"; 326 printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
327 printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n"; 327 printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n";
328 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; 328 printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
329 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; 329 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
330 printf " -V (--version) Plugin version\n"; 330 printf " -V (--version) Plugin version\n";
331 printf " -h (--help) usage help \n\n"; 331 printf " -h (--help) usage help \n\n";
@@ -424,7 +424,7 @@ sub process_arguments() {
424 if (defined $seclevel && defined $secname) { 424 if (defined $seclevel && defined $secname) {
425 $session_opts{'-username'} = $secname; 425 $session_opts{'-username'} = $secname;
426 426
427 # Must define a security level even though defualt is noAuthNoPriv 427 # Must define a security level even though default is noAuthNoPriv
428 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { 428 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) {
429 usage("Must define a valid security level even though default is noAuthNoPriv"); 429 usage("Must define a valid security level even though default is noAuthNoPriv");
430 } 430 }
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index 9f2f7c31..38b87fcc 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -280,7 +280,7 @@ sub print_help() {
280 printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; 280 printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
281 printf " privacy password and authEngineID\n"; 281 printf " privacy password and authEngineID\n";
282 printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n"; 282 printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n";
283 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; 283 printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
284 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; 284 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
285 printf " -V (--version) Plugin version\n"; 285 printf " -V (--version) Plugin version\n";
286 printf " -h (--help) usage help \n\n"; 286 printf " -h (--help) usage help \n\n";
@@ -354,7 +354,7 @@ sub process_arguments() {
354 if (defined $seclevel && defined $secname) { 354 if (defined $seclevel && defined $secname) {
355 $session_opts{'-username'} = $secname; 355 $session_opts{'-username'} = $secname;
356 356
357 # Must define a security level even though defualt is noAuthNoPriv 357 # Must define a security level even though default is noAuthNoPriv
358 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { 358 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) {
359 usage("Must define a valid security level even though default is noAuthNoPriv"); 359 usage("Must define a valid security level even though default is noAuthNoPriv");
360 } 360 }
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index 22d21c2e..84f20229 100755
--- a/plugins-scripts/check_ircd.pl
+++ b/plugins-scripts/check_ircd.pl
@@ -60,7 +60,7 @@ sub print_usage ();
60sub connection ($$$$); 60sub connection ($$$$);
61sub bindRemote ($$); 61sub bindRemote ($$);
62 62
63# -------------------------------------------------------------[ Enviroment ]-- 63# -------------------------------------------------------------[ Environment ]--
64 64
65$ENV{'PATH'}='@TRUSTED_PATH@'; 65$ENV{'PATH'}='@TRUSTED_PATH@';
66$ENV{'BASH_ENV'}=''; 66$ENV{'BASH_ENV'}='';
@@ -69,7 +69,9 @@ $ENV{'ENV'}='';
69# -----------------------------------------------------------------[ Global ]-- 69# -----------------------------------------------------------------[ Global ]--
70 70
71$PROGNAME = "check_ircd"; 71$PROGNAME = "check_ircd";
72my $NICK="ircd$$"; 72# nickname shouldn't be longer than 9 chars, this might happen with large PIDs
73# To prevent this, we cut of the part over 10000
74my $NICK="ircd" . $$ % 10000;
73my $USER_INFO="monitor localhost localhost : "; 75my $USER_INFO="monitor localhost localhost : ";
74 76
75# -------------------------------------------------------------[ connection ]-- 77# -------------------------------------------------------------[ connection ]--
@@ -206,7 +208,7 @@ MAIN:
206 208
207 # Just in case of problems, let's not hang the monitoring system 209 # Just in case of problems, let's not hang the monitoring system
208 $SIG{'ALRM'} = sub { 210 $SIG{'ALRM'} = sub {
209 print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; 211 print "Something is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
210 exit $ERRORS{"UNKNOWN"}; 212 exit $ERRORS{"UNKNOWN"};
211 }; 213 };
212 214
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
index d28c8d0a..8ecdd316 100755
--- a/plugins-scripts/check_log.sh
+++ b/plugins-scripts/check_log.sh
@@ -1,8 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# Log file pattern detector plugin for monitoring 3# Log file pattern detector plugin for monitoring
4# Written by Ethan Galstad (nagios@nagios.org) 4# Written originally by Ethan Galstad (nagios@nagios.org)
5# Last Modified: 07-31-1999
6# 5#
7# Usage: ./check_log <log_file> <old_log_file> <pattern> 6# Usage: ./check_log <log_file> <old_log_file> <pattern>
8# 7#
@@ -19,7 +18,7 @@
19# On the first run of the plugin, it will return an OK state with a message 18# On the first run of the plugin, it will return an OK state with a message
20# of "Log check data initialized". On successive runs, it will return an OK 19# of "Log check data initialized". On successive runs, it will return an OK
21# state if *no* pattern matches have been found in the *difference* between the 20# state if *no* pattern matches have been found in the *difference* between the
22# log file and the older copy of the log file. If the plugin detects any 21# log file and the older copy of the log file. If the plugin detects any
23# pattern matches in the log diff, it will return a CRITICAL state and print 22# pattern matches in the log diff, it will return a CRITICAL state and print
24# out a message is the following format: "(x) last_match", where "x" is the 23# out a message is the following format: "(x) last_match", where "x" is the
25# total number of pattern matches found in the file and "last_match" is the 24# total number of pattern matches found in the file and "last_match" is the
@@ -44,6 +43,10 @@
44# check the same <log_file> for pattern matches. This is necessary 43# check the same <log_file> for pattern matches. This is necessary
45# because of the way the script operates. 44# because of the way the script operates.
46# 45#
46# 4. This plugin does NOT have an understanding of logrotation or similar
47# mechanisms. Therefore bad timing could lead to missing events
48#
49#
47# Examples: 50# Examples:
48# 51#
49# Check for login failures in the syslog... 52# Check for login failures in the syslog...
@@ -60,20 +63,26 @@
60 63
61PATH="@TRUSTED_PATH@" 64PATH="@TRUSTED_PATH@"
62export PATH 65export PATH
63PROGNAME=`basename $0` 66PROGNAME=$(basename "$0")
64PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 67PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
65REVISION="@NP_VERSION@" 68REVISION="@NP_VERSION@"
66 69
67. $PROGPATH/utils.sh 70. "$PROGPATH"/utils.sh
68 71
69print_usage() { 72print_usage() {
70 echo "Usage: $PROGNAME -F logfile -O oldlog -q query" 73 echo "Usage: $PROGNAME -F logfile -O oldlog -q query"
71 echo "Usage: $PROGNAME --help" 74 echo "Usage: $PROGNAME --help"
72 echo "Usage: $PROGNAME --version" 75 echo "Usage: $PROGNAME --version"
76 echo ""
77 echo "Other parameters:"
78 echo " -a|--all : Print all matching lines"
79 echo " --exclude: Exclude a pattern (-p or -e also applies here when used)"
80 echo " -p|--perl-regex : Use perl style regular expressions in the query"
81 echo " -e|--extended-regex : Use extended style regular expressions in the query (not necessary for GNU grep)"
73} 82}
74 83
75print_help() { 84print_help() {
76 print_revision $PROGNAME $REVISION 85 print_revision "$PROGNAME" "$REVISION"
77 echo "" 86 echo ""
78 print_usage 87 print_usage
79 echo "" 88 echo ""
@@ -87,81 +96,89 @@ print_help() {
87 96
88if [ $# -lt 1 ]; then 97if [ $# -lt 1 ]; then
89 print_usage 98 print_usage
90 exit $STATE_UNKNOWN 99 exit "$STATE_UNKNOWN"
91fi 100fi
92 101
93# Grab the command line arguments 102# Grab the command line arguments
94
95#logfile=$1
96#oldlog=$2
97#query=$3
98exitstatus=$STATE_WARNING #default 103exitstatus=$STATE_WARNING #default
99while test -n "$1"; do 104while test -n "$1"; do
100 case "$1" in 105 case "$1" in
101 --help) 106 -h | --help)
102 print_help 107 print_help
103 exit $STATE_OK 108 exit "$STATE_UNKNOWN"
104 ;; 109 ;;
105 -h) 110 -V | --version)
106 print_help 111 print_revision "$PROGNAME" "$REVISION"
107 exit $STATE_OK 112 exit "$STATE_UNKNOWN"
108 ;;
109 --version)
110 print_revision $PROGNAME $REVISION
111 exit $STATE_OK
112 ;;
113 -V)
114 print_revision $PROGNAME $REVISION
115 exit $STATE_OK
116 ;;
117 --filename)
118 logfile=$2
119 shift
120 ;; 113 ;;
121 -F) 114 -F | --filename)
122 logfile=$2 115 logfile=$2
123 shift 116 shift 2
124 ;; 117 ;;
125 --oldlog) 118 -O | --oldlog)
126 oldlog=$2 119 oldlog=$2
127 shift 120 shift 2
128 ;; 121 ;;
129 -O) 122 -q | --query)
130 oldlog=$2
131 shift
132 ;;
133 --query)
134 query=$2 123 query=$2
135 shift 124 shift 2
136 ;; 125 ;;
137 -q) 126 --exclude)
138 query=$2 127 exclude=$2
139 shift 128 shift 2
140 ;; 129 ;;
141 -x) 130 -x | --exitstatus)
142 exitstatus=$2 131 exitstatus=$2
132 shift 2
133 ;;
134 -e | --extended-regex)
135 ERE=1
143 shift 136 shift
144 ;; 137 ;;
145 --exitstatus) 138 -p | --perl-regex)
146 exitstatus=$2 139 PRE=1
140 shift
141 ;;
142 -a | --all)
143 ALL=1
147 shift 144 shift
148 ;; 145 ;;
149 *) 146 *)
150 echo "Unknown argument: $1" 147 echo "Unknown argument: $1"
151 print_usage 148 print_usage
152 exit $STATE_UNKNOWN 149 exit "$STATE_UNKNOWN"
153 ;; 150 ;;
154 esac 151 esac
155 shift
156done 152done
157 153
154# Parameter sanity check
155if [ $ERE ] && [ $PRE ] ; then
156 echo "Can not use extended and perl regex at the same time"
157 exit "$STATE_UNKNOWN"
158fi
159
160GREP="grep"
161
162if [ $ERE ]; then
163 GREP="grep -E"
164fi
165
166if [ $PRE ]; then
167 GREP="grep -P"
168fi
169
158# If the source log file doesn't exist, exit 170# If the source log file doesn't exist, exit
159 171
160if [ ! -e $logfile ]; then 172if [ ! -e "$logfile" ]; then
161 echo "Log check error: Log file $logfile does not exist!" 173 echo "Log check error: Log file $logfile does not exist!"
162 exit $STATE_UNKNOWN 174 exit "$STATE_UNKNOWN"
163elif [ ! -r $logfile ] ; then 175elif [ ! -r "$logfile" ] ; then
164 echo "Log check error: Log file $logfile is not readable!" 176 echo "Log check error: Log file $logfile is not readable!"
177 exit "$STATE_UNKNOWN"
178fi
179# If no oldlog was given this can not work properly, abort then
180if [ -z "$oldlog" ]; then
181 echo "Oldlog parameter is needed"
165 exit $STATE_UNKNOWN 182 exit $STATE_UNKNOWN
166fi 183fi
167 184
@@ -169,10 +186,10 @@ fi
169# we're running this test, so copy the original log file over to 186# we're running this test, so copy the original log file over to
170# the old diff file and exit 187# the old diff file and exit
171 188
172if [ ! -e $oldlog ]; then 189if [ ! -e "$oldlog" ]; then
173 cat $logfile > $oldlog 190 cat "$logfile" > "$oldlog"
174 echo "Log check data initialized..." 191 echo "Log check data initialized..."
175 exit $STATE_OK 192 exit "$STATE_OK"
176fi 193fi
177 194
178# The old log file exists, so compare it to the original log now 195# The old log file exists, so compare it to the original log now
@@ -180,31 +197,48 @@ fi
180# The temporary file that the script should use while 197# The temporary file that the script should use while
181# processing the log file. 198# processing the log file.
182if [ -x /bin/mktemp ]; then 199if [ -x /bin/mktemp ]; then
183 tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX` 200
201 tempdiff=$(/bin/mktemp /tmp/check_log.XXXXXXXXXX)
184else 202else
185 tempdiff=`/bin/date '+%H%M%S'` 203 tempdiff=$(/bin/date '+%H%M%S')
186 tempdiff="/tmp/check_log.${tempdiff}" 204 tempdiff="/tmp/check_log.${tempdiff}"
187 touch $tempdiff 205 touch "$tempdiff"
188 chmod 600 $tempdiff 206 chmod 600 "$tempdiff"
189fi 207fi
190 208
191diff $logfile $oldlog | grep -v "^>" > $tempdiff 209diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
210
192 211
193# Count the number of matching log entries we have 212if [ $ALL ]; then
194count=`grep -c "$query" $tempdiff` 213 # Get all matching entries in the diff file
214 if [ -n "$exclude" ]; then
215 entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude")
216 count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
217 else
218 entry=$($GREP "$query" "$tempdiff")
219 count=$($GREP -c "$query" "$tempdiff")
220 fi
195 221
196# Get the last matching entry in the diff file 222else
197lastentry=`grep "$query" $tempdiff | tail -1` 223 # Get the last matching entry in the diff file
224 if [ -n "$exclude" ]; then
225 entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude" | tail -1)
226 count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
227 else
228 entry=$($GREP "$query" "$tempdiff" | tail -1)
229 count=$($GREP -c "$query" "$tempdiff")
230 fi
231fi
198 232
199rm -f $tempdiff 233rm -f "$tempdiff"
200cat $logfile > $oldlog 234cat "$logfile" > "$oldlog"
201 235
202if [ "$count" = "0" ]; then # no matches, exit with no error 236if [ "$count" = "0" ]; then # no matches, exit with no error
203 echo "Log check ok - 0 pattern matches found" 237 echo "Log check ok - 0 pattern matches found"
204 exitstatus=$STATE_OK 238 exitstatus=$STATE_OK
205else # Print total matche count and the last entry we found 239else # Print total match count and the last entry we found
206 echo "($count) $lastentry" 240 echo "($count) $entry"
207 exitstatus=$STATE_CRITICAL 241 exitstatus=$STATE_CRITICAL
208fi 242fi
209 243
210exit $exitstatus 244exit "$exitstatus"
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index 32f498d3..49156af3 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -4,7 +4,7 @@
4# transmittal. 4# transmittal.
5# 5#
6# Initial version support sendmail's mailq command 6# Initial version support sendmail's mailq command
7# Support for mutiple sendmail queues (Carlos Canau) 7# Support for multiple sendmail queues (Carlos Canau)
8# Support for qmail (Benjamin Schmid) 8# Support for qmail (Benjamin Schmid)
9 9
10# License Information: 10# License Information:
@@ -28,9 +28,9 @@
28use POSIX; 28use POSIX;
29use strict; 29use strict;
30use Getopt::Long; 30use Getopt::Long;
31use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s 31use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s $opt_d
32 $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines 32 $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq $mailq_args
33 %srcdomains %dstdomains); 33 @lines %srcdomains %dstdomains);
34use FindBin; 34use FindBin;
35use lib "$FindBin::Bin"; 35use lib "$FindBin::Bin";
36use utils qw(%ERRORS &print_revision &support &usage ); 36use utils qw(%ERRORS &print_revision &support &usage );
@@ -48,6 +48,8 @@ $PROGNAME = "check_mailq";
48$mailq = 'sendmail'; # default 48$mailq = 'sendmail'; # default
49$msg_q = 0 ; 49$msg_q = 0 ;
50$msg_p = 0 ; 50$msg_p = 0 ;
51# If appended, must start with a space
52$mailq_args = '' ;
51$state = $ERRORS{'UNKNOWN'}; 53$state = $ERRORS{'UNKNOWN'};
52 54
53Getopt::Long::Configure('bundling'); 55Getopt::Long::Configure('bundling');
@@ -68,6 +70,10 @@ if ($opt_s) {
68 $sudo = ""; 70 $sudo = "";
69} 71}
70 72
73if ($opt_d) {
74 $mailq_args = $mailq_args . ' -C ' . $opt_d;
75}
76
71$SIG{'ALRM'} = sub { 77$SIG{'ALRM'} = sub {
72 print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); 78 print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n");
73 exit $ERRORS{"WARNING"}; 79 exit $ERRORS{"WARNING"};
@@ -143,7 +149,26 @@ if ($mailq eq "sendmail") {
143##/var/spool/mqueue/qF/df is empty 149##/var/spool/mqueue/qF/df is empty
144## Total Requests: 1 150## Total Requests: 1
145 151
146 152# separate submission/transport queues, empty
153## MSP Queue status...
154## /var/spool/mqueue-client is empty
155## Total requests: 0
156## MTA Queue status...
157## /var/spool/mqueue is empty
158## Total requests: 0
159# separate submission/transport queues: 1
160## MSP Queue status...
161## /var/spool/mqueue-client (1 request)
162## -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
163## oAJEfhdW014123 5 Fri Nov 19 14:41 jwm
164## (Deferred: Connection refused by [127.0.0.1])
165## root
166## Total requests: 1
167## MTA Queue status...
168## /var/spool/mqueue is empty
169## Total requests: 0
170
171 my $this_msg_q = 0;
147 while (<MAILQ>) { 172 while (<MAILQ>) {
148 173
149 # match email addr on queue listing 174 # match email addr on queue listing
@@ -183,13 +208,18 @@ if ($mailq eq "sendmail") {
183 # 208 #
184 # single queue: first line 209 # single queue: first line
185 # multi queue: one for each queue. overwrite on multi queue below 210 # multi queue: one for each queue. overwrite on multi queue below
186 $msg_q = $1 ; 211 $this_msg_q = $1 ;
212 $msg_q += $1 ;
187 } 213 }
188 } elsif (/^\s+Total\sRequests:\s(\d+)$/i) { 214 } elsif (/^\s+Total\sRequests:\s(\d+)$/i) {
189 print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ; 215 if ($this_msg_q) {
190 # 216 $this_msg_q = 0 ;
191 # multi queue: last line 217 } else {
192 $msg_q = $1 ; 218 print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ;
219 #
220 # multi queue: last line
221 $msg_q += $1 ;
222 }
193 } 223 }
194 224
195 } 225 }
@@ -309,8 +339,8 @@ elsif ( $mailq eq "postfix" ) {
309 339
310 ## open mailq 340 ## open mailq
311 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { 341 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
312 if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { 342 if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ$mailq_args | " ) ) {
313 print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; 343 print "ERROR: could not open $utils::PATH_TO_MAILQ$mailq_args \n";
314 exit $ERRORS{'UNKNOWN'}; 344 exit $ERRORS{'UNKNOWN'};
315 } 345 }
316 }elsif( defined $utils::PATH_TO_MAILQ){ 346 }elsif( defined $utils::PATH_TO_MAILQ){
@@ -330,7 +360,7 @@ elsif ( $mailq eq "postfix" ) {
330 close MAILQ; 360 close MAILQ;
331 361
332 if ( $? ) { 362 if ( $? ) {
333 print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/; 363 print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ$mailq_args",$/;
334 exit $ERRORS{CRITICAL}; 364 exit $ERRORS{CRITICAL};
335 } 365 }
336 366
@@ -343,7 +373,7 @@ elsif ( $mailq eq "postfix" ) {
343 }elsif ($lines[0]=~/Mail queue is empty/) { 373 }elsif ($lines[0]=~/Mail queue is empty/) {
344 $msg_q = 0; 374 $msg_q = 0;
345 }else{ 375 }else{
346 print "Couldn't match $utils::PATH_TO_MAILQ output\n"; 376 print "Couldn't match $utils::PATH_TO_MAILQ$mailq_args output\n";
347 exit $ERRORS{'UNKNOWN'}; 377 exit $ERRORS{'UNKNOWN'};
348 } 378 }
349 379
@@ -531,9 +561,9 @@ elsif ( $mailq eq "nullmailer" ) {
531 } 561 }
532 562
533 while (<MAILQ>) { 563 while (<MAILQ>) {
534 #2006-06-22 16:00:00 282 bytes 564 #2022-08-25 01:30:40 502 bytes from <user@example.com>
535 565
536 if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-2][0-9]\:[0-2][0-9]\s{2}[0-9]+\sbytes$/) { 566 if (/^\d{4}-\d{2}-\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+\d+\sbytes/) {
537 $msg_q++ ; 567 $msg_q++ ;
538 } 568 }
539 } 569 }
@@ -561,14 +591,17 @@ exit $state;
561 591
562sub process_arguments(){ 592sub process_arguments(){
563 GetOptions 593 GetOptions
564 ("V" => \$opt_V, "version" => \$opt_V, 594 ("V" => \$opt_V, "version" => \$opt_V,
565 "v" => \$opt_v, "verbose" => \$opt_v, 595 "v" => \$opt_v, "verbose" => \$opt_v,
566 "h" => \$opt_h, "help" => \$opt_h, 596 "h" => \$opt_h, "help" => \$opt_h,
567 "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) 597 "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail)
568 "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number 598 "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number
569 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number 599 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
600 "W=i" => \$opt_W, "warning-domain=i" => \$opt_W, # Warning if above this number
601 "C=i" => \$opt_C, "critical-domain=i" => \$opt_C, # Critical if above this number
570 "t=i" => \$opt_t, "timeout=i" => \$opt_t, 602 "t=i" => \$opt_t, "timeout=i" => \$opt_t,
571 "s" => \$opt_s, "sudo" => \$opt_s 603 "s" => \$opt_s, "sudo" => \$opt_s,
604 "d:s" => \$opt_d, "configdir:s" => \$opt_d,
572 ); 605 );
573 606
574 if ($opt_V) { 607 if ($opt_V) {
@@ -649,7 +682,7 @@ sub process_arguments(){
649} 682}
650 683
651sub print_usage () { 684sub print_usage () {
652 print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n"; 685 print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-d <CONFIGDIR>] [-v]\n";
653} 686}
654 687
655sub print_help () { 688sub print_help () {
@@ -662,14 +695,15 @@ sub print_help () {
662 print " Feedback/patches to support non-sendmail mailqueue welcome\n\n"; 695 print " Feedback/patches to support non-sendmail mailqueue welcome\n\n";
663 print "-w (--warning) = Min. number of messages in queue to generate warning\n"; 696 print "-w (--warning) = Min. number of messages in queue to generate warning\n";
664 print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n"; 697 print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n";
665 print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n"; 698 print "-W (--warning-domain) = Min. number of messages for same domain in queue to generate warning\n";
666 print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; 699 print "-C (--critical-domain) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
667 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; 700 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
668 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; 701 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n";
669 print "-s (--sudo) = Use sudo to call the mailq command\n"; 702 print "-s (--sudo) = Use sudo to call the mailq command\n";
703 print "-d (--configdir) = Config file or directory\n";
670 print "-h (--help)\n"; 704 print "-h (--help)\n";
671 print "-V (--version)\n"; 705 print "-V (--version)\n";
672 print "-v (--verbose) = debugging output\n"; 706 print "-v (--verbose) = debugging output\n";
673 print "\n\n"; 707 print "\n\n";
674 print "Note: -w and -c are required arguments. -W and -C are optional.\n"; 708 print "Note: -w and -c are required arguments. -W and -C are optional.\n";
675 print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n"; 709 print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n";
diff --git a/plugins-scripts/check_mssql.pl b/plugins-scripts/check_mssql.pl
index fb3952d4..bf3a651f 100755
--- a/plugins-scripts/check_mssql.pl
+++ b/plugins-scripts/check_mssql.pl
@@ -54,7 +54,7 @@ $SIG{'ALRM'} = sub {
54 print ("SQL UNKNOWN: ERROR connection $server (alarm timeout)\n"); 54 print ("SQL UNKNOWN: ERROR connection $server (alarm timeout)\n");
55 exit $ERRORS{"UNKNOWN"}; 55 exit $ERRORS{"UNKNOWN"};
56}; 56};
57alarm($TIMEOUT); 57alarm($timeout);
58 58
59unless ($dbh = DBI->connect("dbi:Sybase:server=".uc($server), "$username", "$password")) { 59unless ($dbh = DBI->connect("dbi:Sybase:server=".uc($server), "$username", "$password")) {
60 printf "SQL CRITICAL: Can't connect to mssql server $DBI::errstr\n"; 60 printf "SQL CRITICAL: Can't connect to mssql server $DBI::errstr\n";
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index 96078aca..59981386 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -8,11 +8,11 @@
8 8
9PATH="@TRUSTED_PATH@" 9PATH="@TRUSTED_PATH@"
10export PATH 10export PATH
11PROGNAME=`basename $0` 11PROGNAME=$(basename "$0")
12PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 12PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
13REVISION="@NP_VERSION@" 13REVISION="@NP_VERSION@"
14 14
15. $PROGPATH/utils.sh 15. "$PROGPATH"/utils.sh
16 16
17 17
18print_usage() { 18print_usage() {
@@ -29,7 +29,7 @@ print_usage() {
29} 29}
30 30
31print_help() { 31print_help() {
32 print_revision $PROGNAME $REVISION 32 print_revision "$PROGNAME" "$REVISION"
33 echo "" 33 echo ""
34 print_usage 34 print_usage
35 echo "" 35 echo ""
@@ -86,48 +86,48 @@ esac
86# Information options 86# Information options
87case "$cmd" in 87case "$cmd" in
88--help) 88--help)
89 print_help 89 print_help
90 exit $STATE_OK 90 exit "$STATE_UNKNOWN"
91 ;; 91 ;;
92-h) 92-h)
93 print_help 93 print_help
94 exit $STATE_OK 94 exit "$STATE_UNKNOWN"
95 ;; 95 ;;
96--version) 96--version)
97 print_revision $PROGNAME $REVISION 97 print_revision "$PROGNAME" "$REVISION"
98 exit $STATE_OK 98 exit "$STATE_UNKNOWN"
99 ;; 99 ;;
100-V) 100-V)
101 print_revision $PROGNAME $REVISION 101 print_revision "$PROGNAME" "$REVISION"
102 exit $STATE_OK 102 exit "$STATE_UNKNOWN"
103 ;; 103 ;;
104esac 104esac
105 105
106# Hunt down a reasonable ORACLE_HOME 106# Hunt down a reasonable ORACLE_HOME
107if [ -z "$ORACLE_HOME" ] ; then 107if [ -z "$ORACLE_HOME" ] ; then
108 # Adjust to taste 108 # Adjust to taste
109 for oratab in /var/opt/oracle/oratab /etc/oratab 109 for oratab in /var/opt/oracle/oratab /etc/oratab
110 do 110 do
111 [ ! -f $oratab ] && continue 111 [ ! -f $oratab ] && continue
112 ORACLE_HOME=`IFS=: 112 ORACLE_HOME=`IFS=:
113 while read SID ORACLE_HOME junk; 113 while read -r SID ORACLE_HOME junk;
114 do 114 do
115 if [ "$SID" = "$2" -o "$SID" = "*" ] ; then 115 if [ "$SID" = "$2" ] || [ "$SID" = "*" ] ; then
116 echo $ORACLE_HOME; 116 echo "$ORACLE_HOME";
117 exit; 117 exit;
118 fi; 118 fi;
119 done < $oratab` 119 done < $oratab`
120 [ -n "$ORACLE_HOME" ] && break 120 [ -n "$ORACLE_HOME" ] && break
121 done 121 done
122fi 122fi
123# Last resort 123# Last resort
124[ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle 124[ -z "$ORACLE_HOME" ] && [ -d "$PROGPATH"/oracle ] && ORACLE_HOME=$PROGPATH/oracle
125 125
126if [ "$cmd" != "--db" ]; then 126if [ "$cmd" != "--db" ]; then
127 if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then 127 if [ -z "$ORACLE_HOME" ] || [ ! -d "$ORACLE_HOME" ] ; then
128 echo "Cannot determine ORACLE_HOME for sid $2" 128 echo "Cannot determine ORACLE_HOME for sid $2"
129 exit $STATE_UNKNOWN 129 exit "$STATE_UNKNOWN"
130 fi 130 fi
131fi 131fi
132PATH=$PATH:$ORACLE_HOME/bin 132PATH=$PATH:$ORACLE_HOME/bin
133LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib 133LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
@@ -135,81 +135,81 @@ export ORACLE_HOME PATH LD_LIBRARY_PATH
135 135
136case "$cmd" in 136case "$cmd" in
137--tns) 137--tns)
138 tnschk=` tnsping $2` 138 tnschk=$(tnsping "$2")
139 tnschk2=` echo $tnschk | grep -c OK` 139 tnschk2=$(echo "$tnschk" | grep -c OK)
140 if [ ${tnschk2} -eq 1 ] ; then 140 if [ "${tnschk2}" -eq 1 ] ; then
141 tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} 141 tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
142 echo "OK - reply time ${tnschk3} from $2" 142 echo "OK - reply time ${tnschk3} from $2"
143 exit $STATE_OK 143 exit "$STATE_OK"
144 else 144 else
145 echo "No TNS Listener on $2" 145 echo "No TNS Listener on $2"
146 exit $STATE_CRITICAL 146 exit "$STATE_CRITICAL"
147 fi 147 fi
148 ;; 148 ;;
149--oranames) 149--oranames)
150 namesctl status $2 | awk ' 150 namesctl status "$2" | awk '
151 /Server has been running for:/ { 151 /Server has been running for:/ {
152 msg = "OK: Up" 152 msg = "OK: Up"
153 for (i = 6; i <= NF; i++) { 153 for (i = 6; i <= NF; i++) {
154 msg = msg " " $i 154 msg = msg " " $i
155 } 155 }
156 status = '$STATE_OK' 156 status = '"$STATE_OK"'
157 } 157 }
158 /error/ { 158 /error/ {
159 msg = "CRITICAL: " $0 159 msg = "CRITICAL: " $0
160 status = '$STATE_CRITICAL' 160 status = '"$STATE_CRITICAL"'
161 } 161 }
162 END { 162 END {
163 print msg 163 print msg
164 exit status 164 exit status
165 }' 165 }'
166 ;; 166 ;;
167--db) 167--db)
168 pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"` 168 pmonchk=$(pgrep -f "(asm|ora)_pmon_${2}$")
169 if [ ${pmonchk} -ge 1 ] ; then 169 if [ "${pmonchk}" -ge 1 ] ; then
170 echo "${2} OK - ${pmonchk} PMON process(es) running" 170 echo "${2} OK - ${pmonchk} PMON process(es) running"
171 exit $STATE_OK 171 exit "$STATE_OK"
172 #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then 172 #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then
173 #if [ ${pmonchk} -eq 1 ] ; then 173 #if [ ${pmonchk} -eq 1 ] ; then
174 #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` 174 #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55`
175 #echo "${2} OK - running since ${utime}" 175 #echo "${2} OK - running since ${utime}"
176 #exit $STATE_OK 176 #exit $STATE_OK
177 #fi 177 #fi
178 else 178 else
179 echo "${2} Database is DOWN" 179 echo "${2} Database is DOWN"
180 exit $STATE_CRITICAL 180 exit "$STATE_CRITICAL"
181 fi 181 fi
182 ;; 182 ;;
183--login) 183--login)
184 loginchk=`sqlplus dummy/user@$2 < /dev/null` 184 loginchk=$(sqlplus dummy/user@"$2" < /dev/null)
185 loginchk2=` echo $loginchk | grep -c ORA-01017` 185 loginchk2=$(echo "$loginchk" | grep -c ORA-01017)
186 if [ ${loginchk2} -eq 1 ] ; then 186 if [ "${loginchk2}" -eq 1 ] ; then
187 echo "OK - dummy login connected" 187 echo "OK - dummy login connected"
188 exit $STATE_OK 188 exit "$STATE_OK"
189 else 189 else
190 loginchk3=` echo "$loginchk" | grep "ORA-" | head -1` 190 loginchk3=$(echo "$loginchk" | grep "ORA-" | head -1)
191 echo "CRITICAL - $loginchk3" 191 echo "CRITICAL - $loginchk3"
192 exit $STATE_CRITICAL 192 exit "$STATE_CRITICAL"
193 fi 193 fi
194 ;; 194 ;;
195--connect) 195--connect)
196 connectchk=`sqlplus $2 < /dev/null` 196 connectchk=$(sqlplus "$2" < /dev/null)
197 connectchk2=` echo $connectchk | grep -c ORA-` 197 connectchk2=$(echo "$connectchk" | grep -c ORA-)
198 if [ ${connectchk2} -eq 0 ] ; then 198 if [ "${connectchk2}" -eq 0 ] ; then
199 echo "OK - login successful" 199 echo "OK - login successful"
200 exit $STATE_OK 200 exit "$STATE_OK"
201 else 201 else
202 connectchk3=` echo "$connectchk" | grep "ORA-" | head -1` 202 connectchk3=$(echo "$connectchk" | grep "ORA-" | head -1)
203 echo "CRITICAL - $connectchk3" 203 echo "CRITICAL - $connectchk3"
204 exit $STATE_CRITICAL 204 exit "$STATE_CRITICAL"
205 fi 205 fi
206 ;; 206 ;;
207--cache) 207--cache)
208 if [ ${5} -gt ${6} ] ; then 208 if [ "${5}" -gt "${6}" ] ; then
209 echo "UNKNOWN - Warning level is less then Crit" 209 echo "UNKNOWN - Warning level is less then Crit"
210 exit $STATE_UNKNOWN 210 exit "$STATE_UNKNOWN"
211 fi 211 fi
212 result=`sqlplus -s ${3}/${4}@${2} << EOF 212 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
213set pagesize 0 213set pagesize 0
214set numf '9999999.99' 214set numf '9999999.99'
215select (1-(pr.value/(dbg.value+cg.value)))*100 215select (1-(pr.value/(dbg.value+cg.value)))*100
@@ -219,48 +219,48 @@ and dbg.name='db block gets'
219and cg.name='consistent gets'; 219and cg.name='consistent gets';
220EOF` 220EOF`
221 221
222 if [ -n "`echo $result | grep ORA-`" ] ; then 222 if echo "$result" | grep -q 'ORA-' ; then
223 error=` echo "$result" | grep "ORA-" | head -1` 223 error=$(echo "$result" | grep "ORA-" | head -1)
224 echo "CRITICAL - $error" 224 echo "CRITICAL - $error"
225 exit $STATE_CRITICAL 225 exit "$STATE_CRITICAL"
226 fi 226 fi
227 227
228 buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` 228 buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
229 buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` 229 buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
230 result=`sqlplus -s ${3}/${4}@${2} << EOF 230 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
231set pagesize 0 231set pagesize 0
232set numf '9999999.99' 232set numf '9999999.99'
233select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 233select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
234from v\\$librarycache lc; 234from v\\$librarycache lc;
235EOF` 235EOF`
236 236
237 if [ -n "`echo $result | grep ORA-`" ] ; then 237 if echo "$result" | grep -q 'ORA-' ; then
238 error=` echo "$result" | grep "ORA-" | head -1` 238 error=$(echo "$result" | grep "ORA-" | head -1)
239 echo "CRITICAL - $error" 239 echo "CRITICAL - $error"
240 exit $STATE_CRITICAL 240 exit "$STATE_CRITICAL"
241 fi 241 fi
242 242
243 lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` 243 lib_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
244 lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` 244 lib_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
245 245
246 if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then 246 if [ "$buf_hr" -le "${5}" ] || [ "$lib_hr" -le "${5}" ] ; then
247 echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 247 echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
248 exit $STATE_CRITICAL 248 exit "$STATE_CRITICAL"
249 fi 249 fi
250 if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then 250 if [ "$buf_hr" -le "${6}" ] || [ "$lib_hr" -le "${6}" ] ; then
251 echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 251 echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
252 exit $STATE_WARNING 252 exit "$STATE_WARNING"
253 fi 253 fi
254 echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 254 echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
255 255
256 exit $STATE_OK 256 exit "$STATE_OK"
257 ;; 257 ;;
258--tablespace) 258--tablespace)
259 if [ ${6} -lt ${7} ] ; then 259 if [ "${6}" -lt "${7}" ] ; then
260 echo "UNKNOWN - Warning level is more then Crit" 260 echo "UNKNOWN - Warning level is more then Crit"
261 exit $STATE_UNKNOWN 261 exit "$STATE_UNKNOWN"
262 fi 262 fi
263 result=`sqlplus -s ${3}/${4}@${2} << EOF 263 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
264set pagesize 0 264set pagesize 0
265set numf '9999999.99' 265set numf '9999999.99'
266select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc 266select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
@@ -273,32 +273,32 @@ from dba_free_space group by tablespace_name) B
273ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; 273ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
274EOF` 274EOF`
275 275
276 if [ -n "`echo $result | grep ORA-`" ] ; then 276 if echo "$result" | grep -q 'ORA-' ; then
277 error=` echo "$result" | grep "ORA-" | head -1` 277 error=$(echo "$result" | grep "ORA-" | head -1)
278 echo "CRITICAL - $error" 278 echo "CRITICAL - $error"
279 exit $STATE_CRITICAL 279 exit "$STATE_CRITICAL"
280 fi 280 fi
281 281
282 ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` 282 ts_free=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}')
283 ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` 283 ts_total=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}')
284 ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` 284 ts_pct=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}')
285 ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` 285 ts_pctx=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}')
286 if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then 286 if [ "$ts_free" -eq 0 ] && [ "$ts_total" -eq 0 ] && [ "$ts_pct" -eq 0 ] ; then
287 echo "No data returned by Oracle - tablespace $5 not found?" 287 echo "No data returned by Oracle - tablespace $5 not found?"
288 exit $STATE_UNKNOWN 288 exit "$STATE_UNKNOWN"
289 fi 289 fi
290 if [ "$ts_pct" -ge ${6} ] ; then 290 if [ "$ts_pct" -ge "${6}" ] ; then
291 echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 291 echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
292 exit $STATE_CRITICAL 292 exit "$STATE_CRITICAL"
293 fi 293 fi
294 if [ "$ts_pct" -ge ${7} ] ; then 294 if [ "$ts_pct" -ge "${7}" ] ; then
295 echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 295 echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
296 exit $STATE_WARNING 296 exit "$STATE_WARNING"
297 fi 297 fi
298 echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 298 echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
299 exit $STATE_OK 299 exit "$STATE_OK"
300 ;; 300 ;;
301*) 301*)
302 print_usage 302 print_usage
303 exit $STATE_UNKNOWN 303 exit "$STATE_UNKNOWN"
304esac 304esac
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl
index 47d6e49e..8a56b9fc 100755
--- a/plugins-scripts/check_rpc.pl
+++ b/plugins-scripts/check_rpc.pl
@@ -5,7 +5,7 @@
5# usage: 5# usage:
6# check_rpc host service 6# check_rpc host service
7# 7#
8# Check if an rpc serice is registered and running 8# Check if an rpc service is registered and running
9# using rpcinfo - $proto $host $prognum 2>&1 |"; 9# using rpcinfo - $proto $host $prognum 2>&1 |";
10# 10#
11# Use these hosts.cfg entries as examples 11# Use these hosts.cfg entries as examples
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh
index f7428301..866e0e0f 100755
--- a/plugins-scripts/check_sensors.sh
+++ b/plugins-scripts/check_sensors.sh
@@ -2,57 +2,57 @@
2 2
3PATH="@TRUSTED_PATH@" 3PATH="@TRUSTED_PATH@"
4export PATH 4export PATH
5PROGNAME=`basename $0` 5PROGNAME=$(basename "$0")
6PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 6PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
7REVISION="@NP_VERSION@" 7REVISION="@NP_VERSION@"
8 8
9. $PROGPATH/utils.sh 9. "$PROGPATH"/utils.sh
10 10
11print_usage() { 11print_usage() {
12 echo "Usage: $PROGNAME" [--ignore-fault] 12 echo "Usage: $PROGNAME" [--ignore-fault]
13} 13}
14 14
15print_help() { 15print_help() {
16 print_revision $PROGNAME $REVISION 16 print_revision "$PROGNAME" "$REVISION"
17 echo "" 17 echo ""
18 print_usage 18 print_usage
19 echo "" 19 echo ""
20 echo "This plugin checks hardware status using the lm_sensors package." 20 echo "This plugin checks hardware status using the lm_sensors package."
21 echo "" 21 echo ""
22 support 22 support
23 exit $STATE_OK 23 exit "$STATE_OK"
24} 24}
25 25
26case "$1" in 26case "$1" in
27 --help) 27 --help)
28 print_help 28 print_help
29 exit $STATE_OK 29 exit "$STATE_UNKNOWN"
30 ;; 30 ;;
31 -h) 31 -h)
32 print_help 32 print_help
33 exit $STATE_OK 33 exit "$STATE_UNKNOWN"
34 ;; 34 ;;
35 --version) 35 --version)
36 print_revision $PROGNAME $REVISION 36 print_revision "$PROGNAME" "$REVISION"
37 exit $STATE_OK 37 exit "$STATE_UNKNOWN"
38 ;; 38 ;;
39 -V) 39 -V)
40 print_revision $PROGNAME $REVISION 40 print_revision "$PROGNAME" "$REVISION"
41 exit $STATE_OK 41 exit "$STATE_UNKNOWN"
42 ;; 42 ;;
43 *) 43 *)
44 sensordata=`sensors 2>&1` 44 sensordata=$(sensors 2>&1)
45 status=$? 45 status=$?
46 if test ${status} -eq 127; then 46 if test ${status} -eq 127; then
47 text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" 47 text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
48 exit=$STATE_UNKNOWN 48 exit=$STATE_UNKNOWN
49 elif test ${status} -ne 0; then 49 elif test "${status}" -ne 0; then
50 text="WARNING - sensors returned state $status" 50 text="WARNING - sensors returned state $status"
51 exit=$STATE_WARNING 51 exit=$STATE_WARNING
52 elif echo ${sensordata} | egrep ALARM > /dev/null; then 52 elif echo "${sensordata}" | grep -E ALARM > /dev/null; then
53 text="SENSOR CRITICAL - Sensor alarm detected!" 53 text="SENSOR CRITICAL - Sensor alarm detected!"
54 exit=$STATE_CRITICAL 54 exit=$STATE_CRITICAL
55 elif echo ${sensordata} | egrep FAULT > /dev/null \ 55 elif echo "${sensordata}" | grep -E FAULT > /dev/null \
56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then 56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then
57 text="SENSOR UNKNOWN - Sensor reported fault" 57 text="SENSOR UNKNOWN - Sensor reported fault"
58 exit=$STATE_UNKNOWN 58 exit=$STATE_UNKNOWN
@@ -63,8 +63,8 @@ case "$1" in
63 63
64 echo "$text" 64 echo "$text"
65 if test "$1" = "-v" -o "$1" = "--verbose"; then 65 if test "$1" = "-v" -o "$1" = "--verbose"; then
66 echo ${sensordata} 66 echo "${sensordata}"
67 fi 67 fi
68 exit $exit 68 exit "$exit"
69 ;; 69 ;;
70esac 70esac
diff --git a/plugins-scripts/check_uptime.pl b/plugins-scripts/check_uptime.pl
new file mode 100755
index 00000000..d73e40e1
--- /dev/null
+++ b/plugins-scripts/check_uptime.pl
@@ -0,0 +1,328 @@
1#!@PERL@ -w
2
3# check_uptime - check uptime to see how long the system is running.
4#
5
6# License Information:
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20# USA
21#
22############################################################################
23
24use POSIX;
25use strict;
26use Getopt::Long;
27use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c
28 $opt_f $opt_s $opt_d
29 $lower_warn_threshold $upper_warn_threshold
30 $lower_crit_threshold $upper_crit_threshold
31 $status $state $msg);
32use FindBin;
33use lib "$FindBin::Bin";
34use utils qw(%ERRORS &print_revision &support &usage );
35
36sub print_help ();
37sub print_usage ();
38sub process_arguments ();
39
40$ENV{'PATH'}='@TRUSTED_PATH@';
41$ENV{'BASH_ENV'}='';
42$ENV{'ENV'}='';
43$PROGNAME = "check_uptime";
44$state = $ERRORS{'UNKNOWN'};
45
46my $uptime_file = "/proc/uptime";
47
48
49# Process arguments
50
51Getopt::Long::Configure('bundling');
52$status = process_arguments();
53if ($status){
54 print "ERROR: processing arguments\n";
55 exit $ERRORS{"UNKNOWN"};
56}
57
58
59# Get uptime info from file
60
61if ( ! -r $uptime_file ) {
62 print "ERROR: file '$uptime_file' is not readable\n";
63 exit $ERRORS{"UNKNOWN"};
64}
65
66if ( ! open FILE, "<", $uptime_file ) {
67 print "ERROR: cannot read from file '$uptime_file'\n";
68 exit $ERRORS{"UNKNOWN"};
69}
70
71chomp( my $file_content = <FILE> );
72close FILE;
73
74print "$uptime_file: $file_content\n" if $verbose;
75
76# Get first digit value (without fraction)
77my ( $uptime_seconds ) = $file_content =~ /^([\d]+)/;
78
79# Bail out if value is not numeric
80if ( $uptime_seconds !~ /^\d+$/ ) {
81 print "ERROR: no numeric value: $uptime_seconds\n";
82 exit $ERRORS{"UNKNOWN"};
83}
84
85
86# Do calculations for a "pretty" format (2 weeks, 5 days, ...)
87
88my ( $secs, $mins, $hours, $days, $weeks );
89$secs = $uptime_seconds;
90$mins = $hours = $days = $weeks = 0;
91if ( $secs > 100 ) {
92 $mins = int( $secs / 60 );
93 $secs -= $mins * 60;
94}
95if ( $mins > 100 ) {
96 $hours = int( $mins / 60 );
97 $mins -= $hours * 60;
98}
99if ( $hours > 48 ) {
100 $days = int( $hours / 24 );
101 $hours -= $days * 24;
102}
103if ( $days > 14 ) {
104 $weeks = int( $days / 7 );
105 $days -= $weeks * 7;
106}
107
108my $pretty_uptime = "";
109$pretty_uptime .= sprintf( "%d week%s, ", $weeks, $weeks == 1 ? "" : "s" ) if $weeks;
110$pretty_uptime .= sprintf( "%d day%s, ", $days, $days == 1 ? "" : "s" ) if $days;
111$pretty_uptime .= sprintf( "%d hour%s, ", $hours, $hours == 1 ? "" : "s" ) if $hours;
112$pretty_uptime .= sprintf( "%d minute%s, ", $mins, $mins == 1 ? "" : "s" ) if $mins;
113# Replace last occurrence of comma with "and"
114$pretty_uptime =~ s/, $/ and /;
115# Always print the seconds (though it may be 0 seconds)
116$pretty_uptime .= sprintf( "%d second%s", $secs, $secs == 1 ? "" : "s" );
117
118
119# Default to catch errors in program
120my $state_str = "UNKNOWN";
121
122# Check values
123my $out_of_bounds_text = "";
124if ( $uptime_seconds > $upper_crit_threshold ) {
125 $state_str = "CRITICAL";
126 $out_of_bounds_text = "upper crit";
127} elsif ( $uptime_seconds < $lower_crit_threshold ) {
128 $state_str = "CRITICAL";
129 $out_of_bounds_text = "lower crit";
130} elsif ( $uptime_seconds > $upper_warn_threshold ) {
131 $state_str = "WARNING";
132 $out_of_bounds_text = "upper warn";
133} elsif ( $uptime_seconds < $lower_warn_threshold ) {
134 $state_str = "WARNING";
135 $out_of_bounds_text = "lower warn";
136} else {
137 $state_str = "OK";
138}
139
140# Prepare uptime value (seconds or days)
141my $uptime_text = "";
142my $uptime_unit = "";
143if ( $opt_d ) {
144 $uptime_text = floor($uptime_seconds / 60 / 60 / 24);
145 $uptime_unit = "days";
146} else {
147 $uptime_text = $uptime_seconds;
148 $uptime_unit = "seconds";
149}
150
151$msg = "$state_str: ";
152
153$msg .= "Uptime is $uptime_text $uptime_unit. ";
154$msg .= "Exceeds $out_of_bounds_text threshold. " if $out_of_bounds_text;
155$msg .= "Running for $pretty_uptime. " if $opt_f;
156if ( $opt_s ) {
157 my $up_since = strftime( "%Y-%m-%d %H:%M:%S", localtime( time - $uptime_seconds ) );
158 $msg .= "Running since $up_since. ";
159}
160
161$state = $ERRORS{$state_str};
162
163# Perfdata support
164print "$msg|uptime=${uptime_seconds}s;$upper_warn_threshold;$upper_crit_threshold;0\n";
165exit $state;
166
167
168#####################################
169#### subs
170
171
172sub process_arguments(){
173 GetOptions
174 ("V" => \$opt_V, "version" => \$opt_V,
175 "v" => \$opt_v, "verbose" => \$opt_v,
176 "h" => \$opt_h, "help" => \$opt_h,
177 "w=s" => \$opt_w, "warning=s" => \$opt_w, # warning if above this number
178 "c=s" => \$opt_c, "critical=s" => \$opt_c, # critical if above this number
179 "f" => \$opt_f, "for" => \$opt_f, # show "running for ..."
180 "s" => \$opt_s, "since" => \$opt_s, # show "running since ..."
181 "d" => \$opt_d, "days" => \$opt_d, # report uptime in days
182 );
183
184 if ($opt_V) {
185 print_revision($PROGNAME,'@NP_VERSION@');
186 exit $ERRORS{'UNKNOWN'};
187 }
188
189 if ($opt_h) {
190 print_help();
191 exit $ERRORS{'UNKNOWN'};
192 }
193
194 if (defined $opt_v) {
195 $verbose = $opt_v;
196 }
197
198 unless ( defined $opt_w && defined $opt_c ) {
199 print_usage();
200 exit $ERRORS{'UNKNOWN'};
201 }
202
203 # Check if a range was supplied ("lowvalue:highvalue") for warning and critical
204 # Otherwise, set 0 as the lower threshold and the parameter value as upper threshold
205 # (the uptime should always be positive, so there should be no issue)
206 if ( $opt_w =~ /^(.+):(.+)$/ ) {
207 $lower_warn_threshold = $1;
208 $upper_warn_threshold = $2;
209 } else {
210 $lower_warn_threshold = 0;
211 $upper_warn_threshold = $opt_w;
212 }
213 if ( $opt_c =~ /^(.+):(.+)$/ ) {
214 $lower_crit_threshold = $1;
215 $upper_crit_threshold = $2;
216 } else {
217 $lower_crit_threshold = 0;
218 $upper_crit_threshold = $opt_c;
219 }
220
221 # Set as seconds (calculate if suffix present)
222 $lower_warn_threshold = calc_as_seconds( $lower_warn_threshold );
223 $lower_crit_threshold = calc_as_seconds( $lower_crit_threshold );
224 $upper_warn_threshold = calc_as_seconds( $upper_warn_threshold );
225 $upper_crit_threshold = calc_as_seconds( $upper_crit_threshold );
226
227 # Check for numeric value of warning parameter
228 if ( $lower_warn_threshold !~ /^\d+$/ ) {
229 print "Lower warning (-w) is not numeric\n";
230 exit $ERRORS{'UNKNOWN'};
231 }
232 if ( $upper_warn_threshold !~ /^\d+$/ ) {
233 print "Upper warning (-w) is not numeric\n";
234 exit $ERRORS{'UNKNOWN'};
235 }
236 # Check for numeric value of critical parameter
237 if ( $lower_crit_threshold !~ /^\d+$/ ) {
238 print "Lower critical (-c) is not numeric\n";
239 exit $ERRORS{'UNKNOWN'};
240 }
241 if ( $upper_crit_threshold !~ /^\d+$/ ) {
242 print "Upper critical (-c) is not numeric\n";
243 exit $ERRORS{'UNKNOWN'};
244 }
245
246 # Check boundaries
247 if ( $upper_warn_threshold >= $upper_crit_threshold ) {
248 print "Upper Warning (-w) cannot be greater than Critical (-c)!\n";
249 exit $ERRORS{'UNKNOWN'};
250 }
251 # No "<=" since both values are zero if no range (only upper threshold values) is given
252 if ( $lower_warn_threshold < $lower_crit_threshold ) {
253 print "Lower Warning (-w) cannot be less than Critical (-c)!\n";
254 exit $ERRORS{'UNKNOWN'};
255 }
256
257 return $ERRORS{'OK'};
258}
259
260sub print_usage () {
261 print "Usage: $PROGNAME -w <warn> -c <crit> [-v]\n";
262}
263
264sub print_help () {
265 print_revision($PROGNAME,'@NP_VERSION@');
266 print "Copyright (c) 2002 Subhendu Ghosh/Carlos Canau/Benjamin Schmid\n";
267 print "Copyright (c) 2018 Bernd Arnold\n";
268 print "\n";
269 print_usage();
270 print "\n";
271 print " Checks the uptime of the system using $uptime_file\n";
272 print "\n";
273 print "-w (--warning) = Min. number of uptime to generate warning\n";
274 print "-c (--critical) = Min. number of uptime to generate critical alert ( w < c )\n";
275 print "-f (--for) = Show uptime in a pretty format (Running for x weeks, x days, ...)\n";
276 print "-s (--since) = Show last boot in yyyy-mm-dd HH:MM:SS format (output from 'uptime -s')\n";
277 print "-d (--days) = Show uptime in days\n";
278 print "-h (--help)\n";
279 print "-V (--version)\n";
280 print "-v (--verbose) = debugging output\n";
281 print "\n\n";
282 print "Note: -w and -c are required arguments.\n";
283 print " You can suffix both values with s for seconds (default), m (minutes), h (hours), d (days) or w (weeks).\n";
284 print "\n";
285 print "Range support: You may specify a range for both warning and critical thresholds.\n";
286 print " This works without additional Perl modules.\n";
287 print "Example: ./check_uptime -w 10m:4w -c 1m:8w\n";
288 print " Results in a critical state when uptime is below 60 seconds or higher than 8 weeks,\n";
289 print " and in a warning state when uptime is below 10 minutes or above 4 weeks.\n";
290 print "\n\n";
291 support();
292}
293
294sub calc_as_seconds () {
295
296 my $parameter = shift;
297
298 # Check if suffix is present
299 # Calculate parameter to seconds (to get an integer value finally)
300 # If no suffix is present, just return the value
301
302 # Possible suffixes:
303 # s = seconds
304 # m = minutes
305 # h = hours
306 # d = days
307 # w = weeks
308 my %factor = ( "s" => 1,
309 "m" => 60,
310 "h" => 60 * 60,
311 "d" => 60 * 60 * 24,
312 "w" => 60 * 60 * 24 * 7,
313 );
314
315 if ( $parameter =~ /^(\d+)([a-z])$/ ) {
316 my $value = $1;
317 my $suffix = $2;
318 print "detected: value=$value, suffix=$suffix\n" if $verbose;
319 if ( ! defined $factor{$suffix} ) {
320 print "Error: wrong suffix ($suffix) for value '$parameter'";
321 exit $ERRORS{'UNKNOWN'};
322 }
323 $parameter = $value * $factor{$suffix};
324 }
325
326 return $parameter;
327
328}
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl
index 41e15f50..c24015c0 100755
--- a/plugins-scripts/check_wave.pl
+++ b/plugins-scripts/check_wave.pl
@@ -19,6 +19,7 @@ sub print_usage ();
19$ENV{'PATH'}='@TRUSTED_PATH@'; 19$ENV{'PATH'}='@TRUSTED_PATH@';
20$ENV{'BASH_ENV'}=''; 20$ENV{'BASH_ENV'}='';
21$ENV{'ENV'}=''; 21$ENV{'ENV'}='';
22$ENV{'CDPATH'}='';
22 23
23Getopt::Long::Configure('bundling'); 24Getopt::Long::Configure('bundling');
24GetOptions 25GetOptions
@@ -50,34 +51,34 @@ my $critical = $1 if ($opt_c =~ /([0-9]+)/);
50($opt_w) || ($opt_w = shift) || ($opt_w = 60); 51($opt_w) || ($opt_w = shift) || ($opt_w = 60);
51my $warning = $1 if ($opt_w =~ /([0-9]+)/); 52my $warning = $1 if ($opt_w =~ /([0-9]+)/);
52 53
53$low1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; 54$low1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
54@test = split(/ /,$low1); 55@test = split(/ /,$low1);
55$low1 = $test[2]; 56$low1 = $test[2];
56 57
57$med1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; 58$med1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
58@test = split(/ /,$med1); 59@test = split(/ /,$med1);
59$med1 = $test[2]; 60$med1 = $test[2];
60 61
61$high1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; 62$high1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
62@test = split(/ /,$high1); 63@test = split(/ /,$high1);
63$high1 = $test[2]; 64$high1 = $test[2];
64 65
65sleep(2); 66sleep(2);
66 67
67$snr = `snmpget $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`; 68$snr = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
68@test = split(/ /,$snr); 69@test = split(/ /,$snr);
69$snr = $test[2]; 70$snr = $test[2];
70$snr = int($snr*25); 71$snr = int($snr*25);
71 72
72$low2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; 73$low2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
73@test = split(/ /,$low2); 74@test = split(/ /,$low2);
74$low2 = $test[2]; 75$low2 = $test[2];
75 76
76$med2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; 77$med2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
77@test = split(/ /,$med2); 78@test = split(/ /,$med2);
78$med2 = $test[2]; 79$med2 = $test[2];
79 80
80$high2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; 81$high2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
81@test = split(/ /,$high2); 82@test = split(/ /,$high2);
82$high2 = $test[2]; 83$high2 = $test[2];
83 84
diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t
index 50a2e699..8b876708 100644
--- a/plugins-scripts/t/check_file_age.t
+++ b/plugins-scripts/t/check_file_age.t
@@ -5,14 +5,14 @@
5# 5#
6 6
7use strict; 7use strict;
8use Test::More tests => 17; 8use Test::More tests => 27;
9use NPTest; 9use NPTest;
10 10
11my $successOutput = '/^FILE_AGE OK: /'; 11my $successOutput = '/^FILE_AGE OK: /';
12my $warningOutput = '/^FILE_AGE WARNING: /'; 12my $warningOutput = '/^FILE_AGE WARNING: /';
13my $criticalOutput = '/^FILE_AGE CRITICAL: /'; 13my $criticalOutput = '/^FILE_AGE CRITICAL: /';
14my $unknownOutput = '/^FILE_AGE UNKNOWN: /'; 14my $unknownOutput = '/^FILE_AGE UNKNOWN: /';
15my $performanceOutput = '/ \| age=[0-9]+s;[0-9]+;[0-9]+ size=[0-9]+B;[0-9]+;[0-9]+;0$/'; 15my $performanceOutput = '/ \| age=[0-9]+s;[0-9:]+;[0-9:]+ size=[0-9]+B;[0-9:]+;[0-9:]+;0$/';
16 16
17my $result; 17my $result;
18my $temp_file = "/tmp/check_file_age.tmp"; 18my $temp_file = "/tmp/check_file_age.tmp";
@@ -20,64 +20,75 @@ my $temp_link = "/tmp/check_file_age.link.tmp";
20 20
21unlink $temp_file, $temp_link; 21unlink $temp_file, $temp_link;
22 22
23$result = NPTest->testCmd( 23$result = NPTest->testCmd("./check_file_age");
24 "./check_file_age"
25 );
26cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); 24cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
27like ( $result->output, $unknownOutput, "Output for unknown correct" ); 25like ( $result->output, $unknownOutput, "Output for unknown correct" );
28 26
29$result = NPTest->testCmd( 27$result = NPTest->testCmd("./check_file_age -f $temp_file");
30 "./check_file_age -f $temp_file"
31 );
32cmp_ok( $result->return_code, '==', 2, "File not exists" ); 28cmp_ok( $result->return_code, '==', 2, "File not exists" );
33like ( $result->output, $criticalOutput, "Output for file missing correct" ); 29like ( $result->output, $criticalOutput, "Output for file missing correct" );
34 30
35write_chars(100); 31write_chars(100);
36$result = NPTest->testCmd( 32$result = NPTest->testCmd("./check_file_age -f $temp_file");
37 "./check_file_age -f $temp_file"
38 );
39cmp_ok( $result->return_code, '==', 0, "File is new enough" ); 33cmp_ok( $result->return_code, '==', 0, "File is new enough" );
40like ( $result->output, $successOutput, "Output for success correct" ); 34like ( $result->output, $successOutput, "Output for success correct" );
41 35
42sleep 2; 36sleep 2;
43 37
44$result = NPTest->testCmd( 38$result = NPTest->testCmd("./check_file_age -f $temp_file -w 1");
45 "./check_file_age -f $temp_file -w 1"
46 );
47cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); 39cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" );
48like ( $result->output, $warningOutput, "Output for warning correct" ); 40like ( $result->output, $warningOutput, "Output for warning correct" );
49 41
50$result = NPTest->testCmd( 42$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1");
51 "./check_file_age -f $temp_file -c 1"
52 );
53cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); 43cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" );
54like ( $result->output, $criticalOutput, "Output for critical correct" ); 44like ( $result->output, $criticalOutput, "Output for critical correct" );
55 45
56$result = NPTest->testCmd( 46$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
57 "./check_file_age -f $temp_file -c 1000 -W 100"
58 );
59cmp_ok( $result->return_code, '==', 0, "Checking file size" ); 47cmp_ok( $result->return_code, '==', 0, "Checking file size" );
60 48
61$result = NPTest->testCmd( 49$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
62 "./check_file_age -f $temp_file -c 1000 -W 100"
63 );
64like( $result->output, $performanceOutput, "Checking for performance Output" ); 50like( $result->output, $performanceOutput, "Checking for performance Output" );
65 51
66$result = NPTest->testCmd( 52$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
67 "./check_file_age -f /non/existent --ignore-missing" 53like( $result->output, $performanceOutput, "Checking for performance Output from range" );
68 ); 54
55$result = NPTest->testCmd("./check_file_age -f /non/existent --ignore-missing");
69cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); 56cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" );
70 57
71$result = NPTest->testCmd( 58$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101");
72 "./check_file_age -f $temp_file -c 1000 -W 101"
73 );
74cmp_ok( $result->return_code, '==', 1, "One byte too short" ); 59cmp_ok( $result->return_code, '==', 1, "One byte too short" );
75 60
76$result = NPTest->testCmd( 61$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101");
77 "./check_file_age -f $temp_file -c 1000 -C 101"
78 );
79cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); 62cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" );
80 63
64SKIP: {
65 eval 'use Monitoring::Plugin::Range';
66 skip "Monitoring::Plugin::Range module require", 9 if $@;
67
68 $result = NPTest->testCmd("./check_file_age -f $temp_file -w 0:1");
69 cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" );
70 like ( $result->output, $warningOutput, "Output for warning by range correct" );
71
72 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1");
73 cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" );
74 like ( $result->output, $criticalOutput, "Output for critical by range correct" );
75
76 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1000 -W 0:100");
77 cmp_ok( $result->return_code, '==', 0, "Checking file size by range" );
78
79 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101:");
80 cmp_ok( $result->return_code, '==', 1, "One byte too short by range" );
81
82 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 0:99");
83 cmp_ok( $result->return_code, '==', 1, "One byte too long by range" );
84
85 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101:");
86 cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" );
87
88 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 0:99");
89 cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" );
90};
91
81symlink $temp_file, $temp_link or die "Cannot create symlink"; 92symlink $temp_file, $temp_link or die "Cannot create symlink";
82$result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); 93$result = NPTest->testCmd("./check_file_age -f $temp_link -c 10");
83cmp_ok( $result->return_code, '==', 0, "Works for symlinks" ); 94cmp_ok( $result->return_code, '==', 0, "Works for symlinks" );
diff --git a/plugins-scripts/t/check_log.t b/plugins-scripts/t/check_log.t
new file mode 100644
index 00000000..b66e0fd8
--- /dev/null
+++ b/plugins-scripts/t/check_log.t
@@ -0,0 +1,82 @@
1#!/usr/bin/perl -w -I ..
2#
3# check_log tests
4#
5#
6
7use strict;
8use Test::More;
9use NPTest;
10
11my $tests = 18;
12plan tests => $tests;
13
14my $firstTimeOutput ='/^Log check data initialized/';
15my $okOutput = '/^Log check ok - 0 pattern matches found/';
16my $criticalOutput = '/^\(\d+\) < /';
17my $multilineOutput = '/\(3\) <.*\n.*\n.*$/';
18my $unknownOutput = '/^Usage: /';
19my $unknownArgOutput = '/^Unknown argument: /';
20my $bothRegexOutput = '/^Can not use extended and perl regex/';
21
22my $result;
23my $temp_file = "/tmp/check_log.tmp";
24my $oldlog = "/tmp/oldlog.tmp";
25
26open(FH, '>', $temp_file) or die $!;
27close(FH);
28
29$result = NPTest->testCmd("./check_log");
30cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
31like ( $result->output, $unknownOutput, "Output for unknown correct" );
32
33$result = NPTest->testCmd("./check_log -f");
34cmp_ok( $result->return_code, '==', 3, "Wrong parameters" );
35like ( $result->output, $unknownArgOutput, "Output for unknown correct" );
36
37$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match' -e -p");
38cmp_ok( $result->return_code, '==', 3, "Both regex parameters" );
39like ( $result->output, $bothRegexOutput, "Output for unknown correct" );
40
41$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match'");
42cmp_ok( $result->return_code, '==', 0, "First time executing" );
43like ( $result->output, $firstTimeOutput, "Output for first time executing correct" );
44
45open(FH, '>>', $temp_file) or die $!;
46print FH "This is some text, that should not match\n";
47close(FH);
48
49$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'No match'");
50cmp_ok( $result->return_code, '==', 0, "No match" );
51like ( $result->output, $okOutput, "Output for no match correct" );
52
53open(FH, '>>', $temp_file) or die $!;
54print FH "This text should match\n";
55close(FH);
56
57$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'should match'");
58cmp_ok( $result->return_code, '==', 2, "Pattern match" );
59like ( $result->output, $criticalOutput, "Output for match correct" );
60
61open(FH, '>>', $temp_file) or die $!;
62print FH "This text should not match, because it is excluded\n";
63close(FH);
64
65$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' --exclude 'because'");
66cmp_ok( $result->return_code, '==', 0, "Exclude a pattern" );
67like ( $result->output, $okOutput, "Output for no match correct" );
68
69open(FH, '>>', $temp_file) or die $!;
70print FH "Trying\nwith\nmultiline\nignore me\n";
71close(FH);
72
73$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Trying\\|with\\|multiline\\|ignore' --exclude 'me' --all");
74cmp_ok( $result->return_code, '==', 2, "Multiline pattern match with --all" );
75like ( $result->output, $multilineOutput, "Output for multiline match correct" );
76
77$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' -a");
78cmp_ok( $result->return_code, '==', 0, "Non matching --all" );
79like ( $result->output, $okOutput, "Output for no match correct" );
80
81unlink($oldlog);
82unlink($temp_file);
diff --git a/plugins-scripts/t/check_uptime.t b/plugins-scripts/t/check_uptime.t
new file mode 100644
index 00000000..6e81db3c
--- /dev/null
+++ b/plugins-scripts/t/check_uptime.t
@@ -0,0 +1,135 @@
1#!/usr/bin/perl -w -I ..
2#
3# check_uptime tests
4#
5#
6
7use strict;
8use Test::More tests => 42;
9use NPTest;
10
11my $result;
12
13$result = NPTest->testCmd(
14 "./check_uptime"
15 );
16cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
17like ( $result->output, '/^Usage: check_uptime -w/', "Output for missing parameters correct" );
18
19$result = NPTest->testCmd(
20 "./check_uptime --help"
21 );
22cmp_ok( $result->return_code, '==', 3, "Help output requested" );
23like ( $result->output, '/ABSOLUTELY NO WARRANTY/', "Output for help correct" );
24
25$result = NPTest->testCmd(
26 "./check_uptime -w 5 -c 2"
27 );
28cmp_ok( $result->return_code, '==', 3, "Warning greater than critical" );
29like ( $result->output, '/^Upper Warning .*cannot be greater than Critical/', "Output for warning greater than critical correct" );
30
31$result = NPTest->testCmd(
32 "./check_uptime -c 1000 -W 100 2>&1"
33 );
34like ( $result->output, '/^Unknown option: W/', "Output with wrong parameter is correct" );
35
36$result = NPTest->testCmd(
37 "./check_uptime -f -w 1 -c 2"
38 );
39cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
40like ( $result->output, '/Running for \d+/', "Output for the f parameter correct" );
41
42$result = NPTest->testCmd(
43 "./check_uptime -s -w 1 -c 2"
44 );
45cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
46like ( $result->output, '/Running since \d+/', "Output for the s parameter correct" );
47
48$result = NPTest->testCmd(
49 "./check_uptime -d -w 1 -c 2"
50 );
51cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
52like ( $result->output, '/CRITICAL: Uptime is \d+ days/', "Output for the d parameter correct" );
53
54$result = NPTest->testCmd(
55 "./check_uptime -w 1 -c 2"
56 );
57cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
58like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" );
59
60$result = NPTest->testCmd(
61 "./check_uptime -w 1 -c 9999w"
62 );
63cmp_ok( $result->return_code, '==', 1, "Uptime lower than 9999 weeks" );
64like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" );
65
66$result = NPTest->testCmd(
67 "./check_uptime -w 9998w -c 9999w"
68 );
69cmp_ok( $result->return_code, '==', 0, "Uptime lower than 9998 weeks" );
70like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" );
71like ( $result->output, '/\|uptime=[0-9]+s;6046790400;6047395200;/', "Checking for performance output" );
72
73$result = NPTest->testCmd(
74 "./check_uptime -w 111222d -c 222333d"
75 );
76cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" );
77like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" );
78like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
79
80# Same as before, hopefully uptime is higher than 2 seconds so no warning
81$result = NPTest->testCmd(
82 "./check_uptime -w 2:111222d -c 1:222333d"
83 );
84cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days, and higher 2 seconds" );
85like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" );
86like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
87
88# Same as before, now the low warning should trigger
89$result = NPTest->testCmd(
90 "./check_uptime -w 111221d:111222d -c 1:222333d"
91 );
92cmp_ok( $result->return_code, '==', 1, "Uptime lower than 111221 days raises warning" );
93like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" );
94like ( $result->output, '/Exceeds lower warn threshold/', "Exceeds text correct" );
95like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
96
97# Same as before, now the low critical should trigger
98$result = NPTest->testCmd(
99 "./check_uptime -w 111221d:111222d -c 111220d:222333d"
100 );
101cmp_ok( $result->return_code, '==', 2, "Uptime lower than 111220 days raises critical" );
102like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" );
103like ( $result->output, '/Exceeds lower crit threshold/', "Exceeds text correct" );
104like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
105
106
107#
108# Range values using ":" without two parts ("a:b") is invalid
109# Strings without two parts are always considered as upper threshold
110#
111
112$result = NPTest->testCmd(
113 "./check_uptime -w 2: -c 1:4"
114 );
115cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
116like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" );
117
118$result = NPTest->testCmd(
119 "./check_uptime -w 2:3 -c 1:"
120 );
121cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
122like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" );
123
124$result = NPTest->testCmd(
125 "./check_uptime -w :3 -c 1:4"
126 );
127cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
128like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" );
129
130$result = NPTest->testCmd(
131 "./check_uptime -w 2:3 -c :4"
132 );
133cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" );
134like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" );
135
diff --git a/plugins-scripts/t/utils.t b/plugins-scripts/t/utils.t
index 9c2c5695..5c231791 100644
--- a/plugins-scripts/t/utils.t
+++ b/plugins-scripts/t/utils.t
@@ -10,6 +10,7 @@ use strict;
10use Test::More; 10use Test::More;
11use NPTest; 11use NPTest;
12 12
13use lib ".";
13use lib ".."; 14use lib "..";
14use utils; 15use utils;
15 16
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in
index 386831eb..c84769fb 100644
--- a/plugins-scripts/utils.pm.in
+++ b/plugins-scripts/utils.pm.in
@@ -23,6 +23,7 @@ $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ;
23$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; 23$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ;
24$PATH_TO_MAILQ = "@PATH_TO_MAILQ@"; 24$PATH_TO_MAILQ = "@PATH_TO_MAILQ@";
25$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@"; 25$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@";
26$PATH_TO_SNMPGET = "@PATH_TO_SNMPGET@";
26 27
27## common variables 28## common variables
28$TIMEOUT = 15; 29$TIMEOUT = 15;
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 0ddf9bd1..49086b7a 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -38,7 +38,9 @@ check_tcp_programs = check_ftp check_imap check_nntp check_pop \
38EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ 38EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
39 check_swap check_fping check_ldap check_game check_dig \ 39 check_swap check_fping check_ldap check_game check_dig \
40 check_nagios check_by_ssh check_dns check_nt check_ide_smart \ 40 check_nagios check_by_ssh check_dns check_nt check_ide_smart \
41 check_procs check_mysql_query check_apt check_dbi 41 check_procs check_mysql_query check_apt check_dbi check_curl
42
43SUBDIRS = picohttpparser
42 44
43EXTRA_DIST = t tests 45EXTRA_DIST = t tests
44 46
@@ -49,10 +51,10 @@ noinst_LIBRARIES = libnpcommon.a
49libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \ 51libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \
50 popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h 52 popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h
51 53
52BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a 54BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO)
53NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS) 55NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS)
54NETLIBS = $(NETOBJS) $(SOCKETLIBS) 56NETLIBS = $(NETOBJS) $(SOCKETLIBS)
55SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) 57SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) $(LIB_CRYPTO)
56 58
57TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) 59TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir)
58 60
@@ -69,6 +71,9 @@ test-debug:
69 71
70check_apt_LDADD = $(BASEOBJS) 72check_apt_LDADD = $(BASEOBJS)
71check_cluster_LDADD = $(BASEOBJS) 73check_cluster_LDADD = $(BASEOBJS)
74check_curl_CFLAGS = $(AM_CFLAGS) $(LIBCURLCFLAGS) $(URIPARSERCFLAGS) $(LIBCURLINCLUDE) $(URIPARSERINCLUDE) -Ipicohttpparser
75check_curl_CPPFLAGS = $(AM_CPPFLAGS) $(LIBCURLCFLAGS) $(URIPARSERCFLAGS) $(LIBCURLINCLUDE) $(URIPARSERINCLUDE) -Ipicohttpparser
76check_curl_LDADD = $(NETLIBS) $(LIBCURLLIBS) $(SSLOBJS) $(URIPARSERLIBS) picohttpparser/libpicohttpparser.a
72check_dbi_LDADD = $(NETLIBS) $(DBILIBS) 77check_dbi_LDADD = $(NETLIBS) $(DBILIBS)
73check_dig_LDADD = $(NETLIBS) 78check_dig_LDADD = $(NETLIBS)
74check_disk_LDADD = $(BASEOBJS) 79check_disk_LDADD = $(BASEOBJS)
@@ -89,7 +94,7 @@ check_mysql_query_CFLAGS = $(AM_CFLAGS) $(MYSQLCFLAGS)
89check_mysql_query_CPPFLAGS = $(AM_CPPFLAGS) $(MYSQLINCLUDE) 94check_mysql_query_CPPFLAGS = $(AM_CPPFLAGS) $(MYSQLINCLUDE)
90check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS) 95check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS)
91check_nagios_LDADD = $(BASEOBJS) 96check_nagios_LDADD = $(BASEOBJS)
92check_nt_LDADD = $(NETLIBS) 97check_nt_LDADD = $(NETLIBS)
93check_ntp_LDADD = $(NETLIBS) $(MATHLIBS) 98check_ntp_LDADD = $(NETLIBS) $(MATHLIBS)
94check_ntp_peer_LDADD = $(NETLIBS) $(MATHLIBS) 99check_ntp_peer_LDADD = $(NETLIBS) $(MATHLIBS)
95check_nwstat_LDADD = $(NETLIBS) 100check_nwstat_LDADD = $(NETLIBS)
@@ -107,7 +112,7 @@ check_tcp_LDADD = $(SSLOBJS)
107check_time_LDADD = $(NETLIBS) 112check_time_LDADD = $(NETLIBS)
108check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS) 113check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS)
109check_ups_LDADD = $(NETLIBS) 114check_ups_LDADD = $(NETLIBS)
110check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS) 115check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS) $(SYSTEMDLIBS)
111check_by_ssh_LDADD = $(NETLIBS) 116check_by_ssh_LDADD = $(NETLIBS)
112check_ide_smart_LDADD = $(BASEOBJS) 117check_ide_smart_LDADD = $(BASEOBJS)
113negate_LDADD = $(BASEOBJS) 118negate_LDADD = $(BASEOBJS)
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index a639a411..fa982ae3 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -1,32 +1,32 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_apt plugin 3* Monitoring check_apt plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006-2008 Monitoring Plugins Development Team 6* Copyright (c) 2006-2008 Monitoring Plugins Development Team
7* 7*
8* Original author: Sean Finney 8* Original author: Sean Finney
9* 9*
10* Description: 10* Description:
11* 11*
12* This file contains the check_apt plugin 12* This file contains the check_apt plugin
13* 13*
14* Check for available updates in apt package management systems 14* Check for available updates in apt package management systems
15* 15*
16* 16*
17* This program is free software: you can redistribute it and/or modify 17* This program is free software: you can redistribute it and/or modify
18* it under the terms of the GNU General Public License as published by 18* it under the terms of the GNU General Public License as published by
19* the Free Software Foundation, either version 3 of the License, or 19* the Free Software Foundation, either version 3 of the License, or
20* (at your option) any later version. 20* (at your option) any later version.
21* 21*
22* This program is distributed in the hope that it will be useful, 22* This program is distributed in the hope that it will be useful,
23* but WITHOUT ANY WARRANTY; without even the implied warranty of 23* but WITHOUT ANY WARRANTY; without even the implied warranty of
24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25* GNU General Public License for more details. 25* GNU General Public License for more details.
26* 26*
27* You should have received a copy of the GNU General Public License 27* You should have received a copy of the GNU General Public License
28* along with this program. If not, see <http://www.gnu.org/licenses/>. 28* along with this program. If not, see <http://www.gnu.org/licenses/>.
29* 29*
30*****************************************************************************/ 30*****************************************************************************/
31 31
32const char *progname = "check_apt"; 32const char *progname = "check_apt";
@@ -66,13 +66,19 @@ char* construct_cmdline(upgrade_type u, const char *opts);
66/* run an apt-get update */ 66/* run an apt-get update */
67int run_update(void); 67int run_update(void);
68/* run an apt-get upgrade */ 68/* run an apt-get upgrade */
69int run_upgrade(int *pkgcount, int *secpkgcount); 69int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist);
70/* add another clause to a regexp */ 70/* add another clause to a regexp */
71char* add_to_regexp(char *expr, const char *next); 71char* add_to_regexp(char *expr, const char *next);
72/* extract package name from Inst line */
73char* pkg_name(char *line);
74/* string comparison function for qsort */
75int cmpstringp(const void *p1, const void *p2);
72 76
73/* configuration variables */ 77/* configuration variables */
74static int verbose = 0; /* -v */ 78static int verbose = 0; /* -v */
75static int do_update = 0; /* whether to call apt-get update */ 79static bool list = false; /* list packages available for upgrade */
80static bool do_update = false; /* whether to call apt-get update */
81static bool only_critical = false; /* whether to warn about non-critical updates */
76static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ 82static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
77static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ 83static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
78static char *update_opts = NULL; /* options to override defaults for update */ 84static char *update_opts = NULL; /* options to override defaults for update */
@@ -80,13 +86,16 @@ static char *do_include = NULL; /* regexp to only include certain packages */
80static char *do_exclude = NULL; /* regexp to only exclude certain packages */ 86static char *do_exclude = NULL; /* regexp to only exclude certain packages */
81static char *do_critical = NULL; /* regexp specifying critical packages */ 87static char *do_critical = NULL; /* regexp specifying critical packages */
82static char *input_filename = NULL; /* input filename for testing */ 88static char *input_filename = NULL; /* input filename for testing */
89/* number of packages available for upgrade to return WARNING status */
90static int packages_warning = 1;
83 91
84/* other global variables */ 92/* other global variables */
85static int stderr_warning = 0; /* if a cmd issued output on stderr */ 93static int stderr_warning = 0; /* if a cmd issued output on stderr */
86static int exec_warning = 0; /* if a cmd exited non-zero */ 94static int exec_warning = 0; /* if a cmd exited non-zero */
87 95
88int main (int argc, char **argv) { 96int main (int argc, char **argv) {
89 int result=STATE_UNKNOWN, packages_available=0, sec_count=0; 97 int result=STATE_UNKNOWN, packages_available=0, sec_count=0, i=0;
98 char **packages_list=NULL, **secpackages_list=NULL;
90 99
91 /* Parse extra opts if any */ 100 /* Parse extra opts if any */
92 argv=np_extra_opts(&argc, argv, progname); 101 argv=np_extra_opts(&argc, argv, progname);
@@ -106,11 +115,11 @@ int main (int argc, char **argv) {
106 if(do_update) result = run_update(); 115 if(do_update) result = run_update();
107 116
108 /* apt-get upgrade */ 117 /* apt-get upgrade */
109 result = max_state(result, run_upgrade(&packages_available, &sec_count)); 118 result = max_state(result, run_upgrade(&packages_available, &sec_count, &packages_list, &secpackages_list));
110 119
111 if(sec_count > 0){ 120 if(sec_count > 0){
112 result = max_state(result, STATE_CRITICAL); 121 result = max_state(result, STATE_CRITICAL);
113 } else if(packages_available > 0){ 122 } else if(packages_available >= packages_warning && only_critical == false){
114 result = max_state(result, STATE_WARNING); 123 result = max_state(result, STATE_WARNING);
115 } else if(result > STATE_UNKNOWN){ 124 } else if(result > STATE_UNKNOWN){
116 result = STATE_UNKNOWN; 125 result = STATE_UNKNOWN;
@@ -129,6 +138,18 @@ int main (int argc, char **argv) {
129 sec_count 138 sec_count
130 ); 139 );
131 140
141 if(list) {
142 qsort(secpackages_list, sec_count, sizeof(char*), cmpstringp);
143 qsort(packages_list, packages_available-sec_count, sizeof(char*), cmpstringp);
144
145 for(i = 0; i < sec_count; i++)
146 printf("%s (security)\n", secpackages_list[i]);
147 if (only_critical == false) {
148 for(i = 0; i < packages_available - sec_count; i++)
149 printf("%s\n", packages_list[i]);
150 }
151 }
152
132 return result; 153 return result;
133} 154}
134 155
@@ -145,15 +166,18 @@ int process_arguments (int argc, char **argv) {
145 {"upgrade", optional_argument, 0, 'U'}, 166 {"upgrade", optional_argument, 0, 'U'},
146 {"no-upgrade", no_argument, 0, 'n'}, 167 {"no-upgrade", no_argument, 0, 'n'},
147 {"dist-upgrade", optional_argument, 0, 'd'}, 168 {"dist-upgrade", optional_argument, 0, 'd'},
169 {"list", no_argument, false, 'l'},
148 {"include", required_argument, 0, 'i'}, 170 {"include", required_argument, 0, 'i'},
149 {"exclude", required_argument, 0, 'e'}, 171 {"exclude", required_argument, 0, 'e'},
150 {"critical", required_argument, 0, 'c'}, 172 {"critical", required_argument, 0, 'c'},
173 {"only-critical", no_argument, 0, 'o'},
151 {"input-file", required_argument, 0, INPUT_FILE_OPT}, 174 {"input-file", required_argument, 0, INPUT_FILE_OPT},
175 {"packages-warning", required_argument, 0, 'w'},
152 {0, 0, 0, 0} 176 {0, 0, 0, 0}
153 }; 177 };
154 178
155 while(1) { 179 while(1) {
156 c = getopt_long(argc, argv, "hVvt:u::U::d::ni:e:c:", longopts, NULL); 180 c = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL);
157 181
158 if(c == -1 || c == EOF || c == 1) break; 182 if(c == -1 || c == EOF || c == 1) break;
159 183
@@ -188,12 +212,15 @@ int process_arguments (int argc, char **argv) {
188 upgrade=NO_UPGRADE; 212 upgrade=NO_UPGRADE;
189 break; 213 break;
190 case 'u': 214 case 'u':
191 do_update=1; 215 do_update=true;
192 if(optarg!=NULL){ 216 if(optarg!=NULL){
193 update_opts=strdup(optarg); 217 update_opts=strdup(optarg);
194 if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); 218 if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
195 } 219 }
196 break; 220 break;
221 case 'l':
222 list=true;
223 break;
197 case 'i': 224 case 'i':
198 do_include=add_to_regexp(do_include, optarg); 225 do_include=add_to_regexp(do_include, optarg);
199 break; 226 break;
@@ -203,9 +230,15 @@ int process_arguments (int argc, char **argv) {
203 case 'c': 230 case 'c':
204 do_critical=add_to_regexp(do_critical, optarg); 231 do_critical=add_to_regexp(do_critical, optarg);
205 break; 232 break;
233 case 'o':
234 only_critical=true;
235 break;
206 case INPUT_FILE_OPT: 236 case INPUT_FILE_OPT:
207 input_filename = optarg; 237 input_filename = optarg;
208 break; 238 break;
239 case 'w':
240 packages_warning = atoi(optarg);
241 break;
209 default: 242 default:
210 /* print short usage statement if args not parsable */ 243 /* print short usage statement if args not parsable */
211 usage5(); 244 usage5();
@@ -217,7 +250,7 @@ int process_arguments (int argc, char **argv) {
217 250
218 251
219/* run an apt-get upgrade */ 252/* run an apt-get upgrade */
220int run_upgrade(int *pkgcount, int *secpkgcount){ 253int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){
221 int i=0, result=STATE_UNKNOWN, regres=0, pc=0, spc=0; 254 int i=0, result=STATE_UNKNOWN, regres=0, pc=0, spc=0;
222 struct output chld_out, chld_err; 255 struct output chld_out, chld_err;
223 regex_t ireg, ereg, sreg; 256 regex_t ireg, ereg, sreg;
@@ -236,7 +269,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
236 die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); 269 die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf);
237 } 270 }
238 } 271 }
239 272
240 if(do_exclude!=NULL){ 273 if(do_exclude!=NULL){
241 regres=regcomp(&ereg, do_exclude, REG_EXTENDED); 274 regres=regcomp(&ereg, do_exclude, REG_EXTENDED);
242 if(regres!=0) { 275 if(regres!=0) {
@@ -245,7 +278,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
245 progname, rerrbuf); 278 progname, rerrbuf);
246 } 279 }
247 } 280 }
248 281
249 const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE; 282 const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE;
250 regres=regcomp(&sreg, crit_ptr, REG_EXTENDED); 283 regres=regcomp(&sreg, crit_ptr, REG_EXTENDED);
251 if(regres!=0) { 284 if(regres!=0) {
@@ -262,7 +295,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
262 /* run the upgrade */ 295 /* run the upgrade */
263 result = np_runcmd(cmdline, &chld_out, &chld_err, 0); 296 result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
264 } 297 }
265 298
266 /* apt-get upgrade only changes exit status if there is an 299 /* apt-get upgrade only changes exit status if there is an
267 * internal error when run in dry-run mode. therefore we will 300 * internal error when run in dry-run mode. therefore we will
268 * treat such an error as UNKNOWN */ 301 * treat such an error as UNKNOWN */
@@ -273,6 +306,11 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
273 cmdline); 306 cmdline);
274 } 307 }
275 308
309 *pkglist=malloc(sizeof(char *) * chld_out.lines);
310 if(!pkglist) die(STATE_UNKNOWN, "malloc failed!\n");
311 *secpkglist=malloc(sizeof(char *) * chld_out.lines);
312 if(!secpkglist) die(STATE_UNKNOWN, "malloc failed!\n");
313
276 /* parse the output, which should only consist of lines like 314 /* parse the output, which should only consist of lines like
277 * 315 *
278 * Inst package .... 316 * Inst package ....
@@ -297,6 +335,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
297 if(regexec(&sreg, chld_out.line[i], 0, NULL, 0)==0){ 335 if(regexec(&sreg, chld_out.line[i], 0, NULL, 0)==0){
298 spc++; 336 spc++;
299 if(verbose) printf("*"); 337 if(verbose) printf("*");
338 (*secpkglist)[spc-1] = pkg_name(chld_out.line[i]);
339 } else {
340 (*pkglist)[pc-spc-1] = pkg_name(chld_out.line[i]);
300 } 341 }
301 if(verbose){ 342 if(verbose){
302 printf("*%s\n", chld_out.line[i]); 343 printf("*%s\n", chld_out.line[i]);
@@ -330,7 +371,7 @@ int run_update(void){
330 struct output chld_out, chld_err; 371 struct output chld_out, chld_err;
331 char *cmdline; 372 char *cmdline;
332 373
333 /* run the upgrade */ 374 /* run the update */
334 cmdline = construct_cmdline(NO_UPGRADE, update_opts); 375 cmdline = construct_cmdline(NO_UPGRADE, update_opts);
335 result = np_runcmd(cmdline, &chld_out, &chld_err, 0); 376 result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
336 /* apt-get update changes exit status if it can't fetch packages. 377 /* apt-get update changes exit status if it can't fetch packages.
@@ -363,6 +404,31 @@ int run_update(void){
363 return result; 404 return result;
364} 405}
365 406
407char* pkg_name(char *line){
408 char *start=NULL, *space=NULL, *pkg=NULL;
409 int len=0;
410
411 start = line + strlen(PKGINST_PREFIX);
412 len = strlen(start);
413
414 space = index(start, ' ');
415 if(space!=NULL){
416 len = space - start;
417 }
418
419 pkg=malloc(sizeof(char)*(len+1));
420 if(!pkg) die(STATE_UNKNOWN, "malloc failed!\n");
421
422 strncpy(pkg, start, len);
423 pkg[len]='\0';
424
425 return pkg;
426}
427
428int cmpstringp(const void *p1, const void *p2){
429 return strcmp(* (char * const *) p1, * (char * const *) p2);
430}
431
366char* add_to_regexp(char *expr, const char *next){ 432char* add_to_regexp(char *expr, const char *next){
367 char *re=NULL; 433 char *re=NULL;
368 434
@@ -435,18 +501,11 @@ print_help (void)
435 501
436 printf(UT_PLUG_TIMEOUT, timeout_interval); 502 printf(UT_PLUG_TIMEOUT, timeout_interval);
437 503
438 printf (" %s\n", "-U, --upgrade=OPTS"); 504 printf (" %s\n", "-n, --no-upgrade");
439 printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
440 printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
441 printf (" %s", _("default "));
442 printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
443 printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
444 printf (" %s\n", _("the default options."));
445 printf (" %s\n", "-d, --dist-upgrade=OPTS");
446 printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
447 printf (" %s\n", _("can be provided to override the default options."));
448 printf (" %s\n", " -n, --no-upgrade");
449 printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); 505 printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
506 printf (" %s\n", "-l, --list");
507 printf (" %s\n", _("List packages available for upgrade. Packages are printed sorted by"));
508 printf (" %s\n", _("name with security packages listed first."));
450 printf (" %s\n", "-i, --include=REGEXP"); 509 printf (" %s\n", "-i, --include=REGEXP");
451 printf (" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times")); 510 printf (" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times"));
452 printf (" %s\n", _("the values will be combined together. Any packages matching this list")); 511 printf (" %s\n", _("the values will be combined together. Any packages matching this list"));
@@ -461,9 +520,16 @@ print_help (void)
461 printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified")); 520 printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified"));
462 printf (" %s\n", _("multiple times like above. Default is a regexp matching security")); 521 printf (" %s\n", _("multiple times like above. Default is a regexp matching security"));
463 printf (" %s\n", _("upgrades for Debian and Ubuntu:")); 522 printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
464 printf (" \t\%s\n", SECURITY_RE); 523 printf (" \t%s\n", SECURITY_RE);
465 printf (" %s\n", _("Note that the package must first match the include list before its")); 524 printf (" %s\n", _("Note that the package must first match the include list before its"));
466 printf (" %s\n\n", _("information is compared against the critical list.")); 525 printf (" %s\n", _("information is compared against the critical list."));
526 printf (" %s\n", "-o, --only-critical");
527 printf (" %s\n", _("Only warn about upgrades matching the critical list. The total number"));
528 printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
529 printf (" %s\n", _("the plugin to return WARNING status."));
530 printf (" %s\n", "-w, --packages-warning");
531 printf (" %s\n", _("Minimum number of packages available for upgrade to return WARNING status."));
532 printf (" %s\n\n", _("Default is 1 package."));
467 533
468 printf ("%s\n\n", _("The following options require root privileges and should be used with care:")); 534 printf ("%s\n\n", _("The following options require root privileges and should be used with care:"));
469 printf (" %s\n", "-u, --update=OPTS"); 535 printf (" %s\n", "-u, --update=OPTS");
@@ -471,6 +537,16 @@ print_help (void)
471 printf (" %s\n", _("the default options. Note: you may also need to adjust the global")); 537 printf (" %s\n", _("the default options. Note: you may also need to adjust the global"));
472 printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get")); 538 printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get"));
473 printf (" %s\n", _("upgrade is expected to take longer than the default timeout.")); 539 printf (" %s\n", _("upgrade is expected to take longer than the default timeout."));
540 printf (" %s\n", "-U, --upgrade=OPTS");
541 printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,"));
542 printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
543 printf (" %s", _("default "));
544 printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
545 printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
546 printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade"));
547 printf (" %s\n", "-d, --dist-upgrade=OPTS");
548 printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
549 printf (" %s\n", _("can be provided to override the default options."));
474 550
475 printf(UT_SUPPORT); 551 printf(UT_SUPPORT);
476} 552}
@@ -481,5 +557,5 @@ void
481print_usage(void) 557print_usage(void)
482{ 558{
483 printf ("%s\n", _("Usage:")); 559 printf ("%s\n", _("Usage:"));
484 printf ("%s [[-d|-u|-U]opts] [-n] [-t timeout]\n", progname); 560 printf ("%s [[-d|-u|-U]opts] [-n] [-l] [-t timeout] [-w packages-warning]\n", progname);
485} 561}
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 04bce38d..1ad547ed 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -49,6 +49,8 @@ unsigned int commands = 0;
49unsigned int services = 0; 49unsigned int services = 0;
50int skip_stdout = 0; 50int skip_stdout = 0;
51int skip_stderr = 0; 51int skip_stderr = 0;
52int warn_on_stderr = 0;
53bool unknown_timeout = FALSE;
52char *remotecmd = NULL; 54char *remotecmd = NULL;
53char **commargv = NULL; 55char **commargv = NULL;
54int commargc = 0; 56int commargc = 0;
@@ -100,6 +102,20 @@ main (int argc, char **argv)
100 102
101 result = cmd_run_array (commargv, &chld_out, &chld_err, 0); 103 result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
102 104
105 /* SSH returns 255 if connection attempt fails; include the first line of error output */
106 if (result == 255 && unknown_timeout) {
107 printf (_("SSH connection failed: %s\n"),
108 chld_err.lines > 0 ? chld_err.line[0] : "(no error output)");
109 return STATE_UNKNOWN;
110 }
111
112 if (verbose) {
113 for(i = 0; i < chld_out.lines; i++)
114 printf("stdout: %s\n", chld_out.line[i]);
115 for(i = 0; i < chld_err.lines; i++)
116 printf("stderr: %s\n", chld_err.line[i]);
117 }
118
103 if (skip_stdout == -1) /* --skip-stdout specified without argument */ 119 if (skip_stdout == -1) /* --skip-stdout specified without argument */
104 skip_stdout = chld_out.lines; 120 skip_stdout = chld_out.lines;
105 if (skip_stderr == -1) /* --skip-stderr specified without argument */ 121 if (skip_stderr == -1) /* --skip-stderr specified without argument */
@@ -109,7 +125,10 @@ main (int argc, char **argv)
109 if(chld_err.lines > skip_stderr) { 125 if(chld_err.lines > skip_stderr) {
110 printf (_("Remote command execution failed: %s\n"), 126 printf (_("Remote command execution failed: %s\n"),
111 chld_err.line[skip_stderr]); 127 chld_err.line[skip_stderr]);
112 return max_state_alt(result, STATE_UNKNOWN); 128 if ( warn_on_stderr )
129 return max_state_alt(result, STATE_WARNING);
130 else
131 return max_state_alt(result, STATE_UNKNOWN);
113 } 132 }
114 133
115 /* this is simple if we're not supposed to be passive. 134 /* this is simple if we're not supposed to be passive.
@@ -169,6 +188,7 @@ process_arguments (int argc, char **argv)
169 {"verbose", no_argument, 0, 'v'}, 188 {"verbose", no_argument, 0, 'v'},
170 {"fork", no_argument, 0, 'f'}, 189 {"fork", no_argument, 0, 'f'},
171 {"timeout", required_argument, 0, 't'}, 190 {"timeout", required_argument, 0, 't'},
191 {"unknown-timeout", no_argument, 0, 'U'},
172 {"host", required_argument, 0, 'H'}, /* backward compatibility */ 192 {"host", required_argument, 0, 'H'}, /* backward compatibility */
173 {"hostname", required_argument, 0, 'H'}, 193 {"hostname", required_argument, 0, 'H'},
174 {"port", required_argument,0,'p'}, 194 {"port", required_argument,0,'p'},
@@ -182,6 +202,7 @@ process_arguments (int argc, char **argv)
182 {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */ 202 {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */
183 {"skip-stdout", optional_argument, 0, 'S'}, 203 {"skip-stdout", optional_argument, 0, 'S'},
184 {"skip-stderr", optional_argument, 0, 'E'}, 204 {"skip-stderr", optional_argument, 0, 'E'},
205 {"warn-on-stderr", no_argument, 0, 'W'},
185 {"proto1", no_argument, 0, '1'}, 206 {"proto1", no_argument, 0, '1'},
186 {"proto2", no_argument, 0, '2'}, 207 {"proto2", no_argument, 0, '2'},
187 {"use-ipv4", no_argument, 0, '4'}, 208 {"use-ipv4", no_argument, 0, '4'},
@@ -200,7 +221,7 @@ process_arguments (int argc, char **argv)
200 strcpy (argv[c], "-t"); 221 strcpy (argv[c], "-t");
201 222
202 while (1) { 223 while (1) {
203 c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, 224 c = getopt_long (argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
204 &option); 225 &option);
205 226
206 if (c == -1 || c == EOF) 227 if (c == -1 || c == EOF)
@@ -222,8 +243,10 @@ process_arguments (int argc, char **argv)
222 else 243 else
223 timeout_interval = atoi (optarg); 244 timeout_interval = atoi (optarg);
224 break; 245 break;
246 case 'U':
247 unknown_timeout = TRUE;
248 break;
225 case 'H': /* host */ 249 case 'H': /* host */
226 host_or_die(optarg);
227 hostname = optarg; 250 hostname = optarg;
228 break; 251 break;
229 case 'p': /* port number */ 252 case 'p': /* port number */
@@ -301,6 +324,9 @@ process_arguments (int argc, char **argv)
301 else 324 else
302 skip_stderr = atoi (optarg); 325 skip_stderr = atoi (optarg);
303 break; 326 break;
327 case 'W': /* exit with warning if there is an output on stderr */
328 warn_on_stderr = 1;
329 break;
304 case 'o': /* Extra options for the ssh command */ 330 case 'o': /* Extra options for the ssh command */
305 comm_append("-o"); 331 comm_append("-o");
306 comm_append(optarg); 332 comm_append(optarg);
@@ -322,7 +348,6 @@ process_arguments (int argc, char **argv)
322 if (c <= argc) { 348 if (c <= argc) {
323 die (STATE_UNKNOWN, _("%s: You must provide a host name\n"), progname); 349 die (STATE_UNKNOWN, _("%s: You must provide a host name\n"), progname);
324 } 350 }
325 host_or_die(argv[c]);
326 hostname = argv[c++]; 351 hostname = argv[c++];
327 } 352 }
328 353
@@ -408,6 +433,8 @@ print_help (void)
408 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]")); 433 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]"));
409 printf (" %s\n", "-E, --skip-stderr[=n]"); 434 printf (" %s\n", "-E, --skip-stderr[=n]");
410 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]")); 435 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]"));
436 printf (" %s\n", "-W, --warn-on-stderr]");
437 printf (" %s\n", _("Exit with an warning, if there is an output on STDERR"));
411 printf (" %s\n", "-f"); 438 printf (" %s\n", "-f");
412 printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed")); 439 printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed"));
413 printf (" %s\n","-C, --command='COMMAND STRING'"); 440 printf (" %s\n","-C, --command='COMMAND STRING'");
@@ -430,6 +457,8 @@ print_help (void)
430 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); 457 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
431 printf (UT_WARN_CRIT); 458 printf (UT_WARN_CRIT);
432 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 459 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
460 printf (" %s\n","-U, --unknown-timeout");
461 printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));
433 printf (UT_VERBOSE); 462 printf (UT_VERBOSE);
434 printf("\n"); 463 printf("\n");
435 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with")); 464 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with"));
@@ -459,8 +488,8 @@ void
459print_usage (void) 488print_usage (void)
460{ 489{
461 printf ("%s\n", _("Usage:")); 490 printf ("%s\n", _("Usage:"));
462 printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" 491 printf (" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n"
463 " [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n" 492 " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n"
464 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" 493 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
465 " [-p port] [-o ssh-option] [-F configfile]\n", 494 " [-p port] [-o ssh-option] [-F configfile]\n",
466 progname); 495 progname);
diff --git a/plugins/check_cluster.c b/plugins/check_cluster.c
index b86e501d..e1ede9f7 100644
--- a/plugins/check_cluster.c
+++ b/plugins/check_cluster.c
@@ -143,6 +143,7 @@ int main(int argc, char **argv){
143 143
144int process_arguments(int argc, char **argv){ 144int process_arguments(int argc, char **argv){
145 int c; 145 int c;
146 char *ptr;
146 int option=0; 147 int option=0;
147 static struct option longopts[]={ 148 static struct option longopts[]={
148 {"data", required_argument,0,'d'}, 149 {"data", required_argument,0,'d'},
@@ -188,6 +189,15 @@ int process_arguments(int argc, char **argv){
188 189
189 case 'd': /* data values */ 190 case 'd': /* data values */
190 data_vals=(char *)strdup(optarg); 191 data_vals=(char *)strdup(optarg);
192 /* validate data */
193 for (ptr=data_vals;ptr!=NULL;ptr+=2){
194 if (ptr[0]<'0' || ptr[0]>'3')
195 return ERROR;
196 if (ptr[1]=='\0')
197 break;
198 if (ptr[1]!=',')
199 return ERROR;
200 }
191 break; 201 break;
192 202
193 case 'l': /* text label */ 203 case 'l': /* text label */
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
new file mode 100644
index 00000000..d0871c48
--- /dev/null
+++ b/plugins/check_curl.c
@@ -0,0 +1,2696 @@
1/*****************************************************************************
2*
3* Monitoring check_curl plugin
4*
5* License: GPL
6* Copyright (c) 1999-2019 Monitoring Plugins Development Team
7*
8* Description:
9*
10* This file contains the check_curl plugin
11*
12* This plugin tests the HTTP service on the specified host. It can test
13* normal (http) and secure (https) servers, follow redirects, search for
14* strings and regular expressions, check connection times, and report on
15* certificate expiration times.
16*
17* This plugin uses functions from the curl library, see
18* http://curl.haxx.se
19*
20* This program is free software: you can redistribute it and/or modify
21* it under the terms of the GNU General Public License as published by
22* the Free Software Foundation, either version 3 of the License, or
23* (at your option) any later version.
24*
25* This program is distributed in the hope that it will be useful,
26* but WITHOUT ANY WARRANTY; without even the implied warranty of
27* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28* GNU General Public License for more details.
29*
30* You should have received a copy of the GNU General Public License
31* along with this program. If not, see <http://www.gnu.org/licenses/>.
32*
33*
34*****************************************************************************/
35const char *progname = "check_curl";
36
37const char *copyright = "2006-2019";
38const char *email = "devel@monitoring-plugins.org";
39
40#include <stdbool.h>
41#include <ctype.h>
42
43#include "common.h"
44#include "utils.h"
45
46#ifndef LIBCURL_PROTOCOL_HTTP
47#error libcurl compiled without HTTP support, compiling check_curl plugin does not makes a lot of sense
48#endif
49
50#include "curl/curl.h"
51#include "curl/easy.h"
52
53#include "picohttpparser.h"
54
55#include "uriparser/Uri.h"
56
57#include <arpa/inet.h>
58#include <netinet/in.h>
59
60#if defined(HAVE_SSL) && defined(USE_OPENSSL)
61#include <openssl/opensslv.h>
62#endif
63
64#include <netdb.h>
65
66#define MAKE_LIBCURL_VERSION(major, minor, patch) ((major)*0x10000 + (minor)*0x100 + (patch))
67
68#define DEFAULT_BUFFER_SIZE 2048
69#define DEFAULT_SERVER_URL "/"
70#define HTTP_EXPECT "HTTP/"
71#define INET_ADDR_MAX_SIZE INET6_ADDRSTRLEN
72enum {
73 MAX_IPV4_HOSTLENGTH = 255,
74 HTTP_PORT = 80,
75 HTTPS_PORT = 443,
76 MAX_PORT = 65535,
77 DEFAULT_MAX_REDIRS = 15
78};
79
80enum {
81 STICKY_NONE = 0,
82 STICKY_HOST = 1,
83 STICKY_PORT = 2
84};
85
86enum {
87 FOLLOW_HTTP_CURL = 0,
88 FOLLOW_LIBCURL = 1
89};
90
91/* for buffers for header and body */
92typedef struct {
93 char *buf;
94 size_t buflen;
95 size_t bufsize;
96} curlhelp_write_curlbuf;
97
98/* for buffering the data sent in PUT */
99typedef struct {
100 char *buf;
101 size_t buflen;
102 off_t pos;
103} curlhelp_read_curlbuf;
104
105/* for parsing the HTTP status line */
106typedef struct {
107 int http_major; /* major version of the protocol, always 1 (HTTP/0.9
108 * never reached the big internet most likely) */
109 int http_minor; /* minor version of the protocol, usually 0 or 1 */
110 int http_code; /* HTTP return code as in RFC 2145 */
111 int http_subcode; /* Microsoft IIS extension, HTTP subcodes, see
112 * http://support.microsoft.com/kb/318380/en-us */
113 const char *msg; /* the human readable message */
114 char *first_line; /* a copy of the first line */
115} curlhelp_statusline;
116
117/* to know the underlying SSL library used by libcurl */
118typedef enum curlhelp_ssl_library {
119 CURLHELP_SSL_LIBRARY_UNKNOWN,
120 CURLHELP_SSL_LIBRARY_OPENSSL,
121 CURLHELP_SSL_LIBRARY_LIBRESSL,
122 CURLHELP_SSL_LIBRARY_GNUTLS,
123 CURLHELP_SSL_LIBRARY_NSS
124} curlhelp_ssl_library;
125
126enum {
127 REGS = 2,
128 MAX_RE_SIZE = 1024
129};
130#include "regex.h"
131regex_t preg;
132regmatch_t pmatch[REGS];
133char regexp[MAX_RE_SIZE];
134int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE;
135int errcode;
136bool invert_regex = false;
137
138char *server_address = NULL;
139char *host_name = NULL;
140char *server_url = 0;
141char server_ip[DEFAULT_BUFFER_SIZE];
142struct curl_slist *server_ips = NULL;
143bool specify_port = false;
144unsigned short server_port = HTTP_PORT;
145unsigned short virtual_port = 0;
146int host_name_length;
147char output_header_search[30] = "";
148char output_string_search[30] = "";
149char *warning_thresholds = NULL;
150char *critical_thresholds = NULL;
151int days_till_exp_warn, days_till_exp_crit;
152thresholds *thlds;
153char user_agent[DEFAULT_BUFFER_SIZE];
154int verbose = 0;
155bool show_extended_perfdata = false;
156bool show_body = false;
157int min_page_len = 0;
158int max_page_len = 0;
159int redir_depth = 0;
160int max_depth = DEFAULT_MAX_REDIRS;
161char *http_method = NULL;
162char *http_post_data = NULL;
163char *http_content_type = NULL;
164CURL *curl;
165bool curl_global_initialized = false;
166bool curl_easy_initialized = false;
167struct curl_slist *header_list = NULL;
168bool body_buf_initialized = false;
169curlhelp_write_curlbuf body_buf;
170bool header_buf_initialized = false;
171curlhelp_write_curlbuf header_buf;
172bool status_line_initialized = false;
173curlhelp_statusline status_line;
174bool put_buf_initialized = false;
175curlhelp_read_curlbuf put_buf;
176char http_header[DEFAULT_BUFFER_SIZE];
177long code;
178long socket_timeout = DEFAULT_SOCKET_TIMEOUT;
179double total_time;
180double time_connect;
181double time_appconnect;
182double time_headers;
183double time_firstbyte;
184char errbuf[MAX_INPUT_BUFFER];
185CURLcode res;
186char url[DEFAULT_BUFFER_SIZE];
187char msg[DEFAULT_BUFFER_SIZE];
188char perfstring[DEFAULT_BUFFER_SIZE];
189char header_expect[MAX_INPUT_BUFFER] = "";
190char string_expect[MAX_INPUT_BUFFER] = "";
191char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
192int server_expect_yn = 0;
193char user_auth[MAX_INPUT_BUFFER] = "";
194char proxy_auth[MAX_INPUT_BUFFER] = "";
195char **http_opt_headers;
196int http_opt_headers_count = 0;
197bool display_html = false;
198int onredirect = STATE_OK;
199int followmethod = FOLLOW_HTTP_CURL;
200int followsticky = STICKY_NONE;
201bool use_ssl = false;
202bool use_sni = true;
203bool check_cert = false;
204bool continue_after_check_cert = false;
205typedef union {
206 struct curl_slist* to_info;
207 struct curl_certinfo* to_certinfo;
208} cert_ptr_union;
209cert_ptr_union cert_ptr;
210int ssl_version = CURL_SSLVERSION_DEFAULT;
211char *client_cert = NULL;
212char *client_privkey = NULL;
213char *ca_cert = NULL;
214bool verify_peer_and_host = false;
215bool is_openssl_callback = false;
216#if defined(HAVE_SSL) && defined(USE_OPENSSL)
217X509 *cert = NULL;
218#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */
219bool no_body = false;
220int maximum_age = -1;
221int address_family = AF_UNSPEC;
222curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN;
223int curl_http_version = CURL_HTTP_VERSION_NONE;
224bool automatic_decompression = false;
225char *cookie_jar_file = NULL;
226
227bool process_arguments (int, char**);
228void handle_curl_option_return_code (CURLcode res, const char* option);
229int check_http (void);
230void redir (curlhelp_write_curlbuf*);
231char *perfd_time (double microsec);
232char *perfd_time_connect (double microsec);
233char *perfd_time_ssl (double microsec);
234char *perfd_time_firstbyte (double microsec);
235char *perfd_time_headers (double microsec);
236char *perfd_time_transfer (double microsec);
237char *perfd_size (int page_len);
238void print_help (void);
239void print_usage (void);
240void print_curl_version (void);
241int curlhelp_initwritebuffer (curlhelp_write_curlbuf*);
242int curlhelp_buffer_write_callback (void*, size_t , size_t , void*);
243void curlhelp_freewritebuffer (curlhelp_write_curlbuf*);
244int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t);
245int curlhelp_buffer_read_callback (void *, size_t , size_t , void *);
246void curlhelp_freereadbuffer (curlhelp_read_curlbuf *);
247curlhelp_ssl_library curlhelp_get_ssl_library ();
248const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library);
249int net_noopenssl_check_certificate (cert_ptr_union*, int, int);
250
251int curlhelp_parse_statusline (const char*, curlhelp_statusline *);
252void curlhelp_free_statusline (curlhelp_statusline *);
253char *get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header);
254int check_document_dates (const curlhelp_write_curlbuf *, char (*msg)[DEFAULT_BUFFER_SIZE]);
255int get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf);
256
257#if defined(HAVE_SSL) && defined(USE_OPENSSL)
258int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit);
259#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */
260
261void remove_newlines (char *);
262void test_file (char *);
263
264int
265main (int argc, char **argv)
266{
267 int result = STATE_UNKNOWN;
268
269 setlocale (LC_ALL, "");
270 bindtextdomain (PACKAGE, LOCALEDIR);
271 textdomain (PACKAGE);
272
273 /* Parse extra opts if any */
274 argv = np_extra_opts (&argc, argv, progname);
275
276 /* set defaults */
277 snprintf( user_agent, DEFAULT_BUFFER_SIZE, "%s/v%s (monitoring-plugins %s, %s)",
278 progname, NP_VERSION, VERSION, curl_version());
279
280 /* parse arguments */
281 if (process_arguments (argc, argv) == false)
282 usage4 (_("Could not parse arguments"));
283
284 if (display_html)
285 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
286 use_ssl ? "https" : "http",
287 host_name ? host_name : server_address,
288 virtual_port ? virtual_port : server_port,
289 server_url);
290
291 result = check_http ();
292 return result;
293}
294
295#ifdef HAVE_SSL
296#ifdef USE_OPENSSL
297
298int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
299{
300 (void) preverify_ok;
301 /* TODO: we get all certificates of the chain, so which ones
302 * should we test?
303 * TODO: is the last certificate always the server certificate?
304 */
305 cert = X509_STORE_CTX_get_current_cert(x509_ctx);
306#if OPENSSL_VERSION_NUMBER >= 0x10100000L
307 X509_up_ref(cert);
308#endif
309 if (verbose>=2) {
310 puts("* SSL verify callback with certificate:");
311 X509_NAME *subject, *issuer;
312 printf("* issuer:\n");
313 issuer = X509_get_issuer_name( cert );
314 X509_NAME_print_ex_fp(stdout, issuer, 5, XN_FLAG_MULTILINE);
315 printf("* curl verify_callback:\n* subject:\n");
316 subject = X509_get_subject_name( cert );
317 X509_NAME_print_ex_fp(stdout, subject, 5, XN_FLAG_MULTILINE);
318 puts("");
319 }
320 return 1;
321}
322
323CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm)
324{
325 (void) curl; // ignore unused parameter
326 (void) parm; // ignore unused parameter
327 SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
328
329 return CURLE_OK;
330}
331
332#endif /* USE_OPENSSL */
333#endif /* HAVE_SSL */
334
335/* returns a string "HTTP/1.x" or "HTTP/2" */
336static char *string_statuscode (int major, int minor)
337{
338 static char buf[10];
339
340 switch (major) {
341 case 1:
342 snprintf (buf, sizeof (buf), "HTTP/%d.%d", major, minor);
343 break;
344 case 2:
345 case 3:
346 snprintf (buf, sizeof (buf), "HTTP/%d", major);
347 break;
348 default:
349 /* assuming here HTTP/N with N>=4 */
350 snprintf (buf, sizeof (buf), "HTTP/%d", major);
351 break;
352 }
353
354 return buf;
355}
356
357/* Checks if the server 'reply' is one of the expected 'statuscodes' */
358static int
359expected_statuscode (const char *reply, const char *statuscodes)
360{
361 char *expected, *code;
362 int result = 0;
363
364 if ((expected = strdup (statuscodes)) == NULL)
365 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Memory allocation error\n"));
366
367 for (code = strtok (expected, ","); code != NULL; code = strtok (NULL, ","))
368 if (strstr (reply, code) != NULL) {
369 result = 1;
370 break;
371 }
372
373 free (expected);
374 return result;
375}
376
377void
378handle_curl_option_return_code (CURLcode res, const char* option)
379{
380 if (res != CURLE_OK) {
381 snprintf (msg,
382 DEFAULT_BUFFER_SIZE,
383 _("Error while setting cURL option '%s': cURL returned %d - %s"),
384 option,
385 res,
386 curl_easy_strerror(res));
387 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
388 }
389}
390
391int
392lookup_host (const char *host, char *buf, size_t buflen)
393{
394 struct addrinfo hints, *res, *result;
395 char addrstr[100];
396 size_t addrstr_len;
397 int errcode;
398 void *ptr;
399 size_t buflen_remaining = buflen - 1;
400
401 memset (&hints, 0, sizeof (hints));
402 hints.ai_family = address_family;
403 hints.ai_socktype = SOCK_STREAM;
404 hints.ai_flags |= AI_CANONNAME;
405
406 errcode = getaddrinfo (host, NULL, &hints, &result);
407 if (errcode != 0)
408 return errcode;
409
410 strcpy(buf, "");
411 res = result;
412
413 while (res) {
414 switch (res->ai_family) {
415 case AF_INET:
416 ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
417 break;
418 case AF_INET6:
419 ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
420 break;
421 }
422
423 inet_ntop (res->ai_family, ptr, addrstr, 100);
424 if (verbose >= 1) {
425 printf ("* getaddrinfo IPv%d address: %s\n",
426 res->ai_family == PF_INET6 ? 6 : 4, addrstr);
427 }
428
429 // Append all IPs to buf as a comma-separated string
430 addrstr_len = strlen(addrstr);
431 if (buflen_remaining > addrstr_len + 1) {
432 if (buf[0] != '\0') {
433 strncat(buf, ",", buflen_remaining);
434 buflen_remaining -= 1;
435 }
436 strncat(buf, addrstr, buflen_remaining);
437 buflen_remaining -= addrstr_len;
438 }
439
440 res = res->ai_next;
441 }
442
443 freeaddrinfo(result);
444
445 return 0;
446}
447
448static void
449cleanup (void)
450{
451 if (status_line_initialized) curlhelp_free_statusline(&status_line);
452 status_line_initialized = false;
453 if (curl_easy_initialized) curl_easy_cleanup (curl);
454 curl_easy_initialized = false;
455 if (curl_global_initialized) curl_global_cleanup ();
456 curl_global_initialized = false;
457 if (body_buf_initialized) curlhelp_freewritebuffer (&body_buf);
458 body_buf_initialized = false;
459 if (header_buf_initialized) curlhelp_freewritebuffer (&header_buf);
460 header_buf_initialized = false;
461 if (put_buf_initialized) curlhelp_freereadbuffer (&put_buf);
462 put_buf_initialized = false;
463}
464
465int
466check_http (void)
467{
468 int result = STATE_OK;
469 int page_len = 0;
470 int i;
471 char *force_host_header = NULL;
472 struct curl_slist *host = NULL;
473 char addrstr[DEFAULT_BUFFER_SIZE/2];
474 char dnscache[DEFAULT_BUFFER_SIZE];
475
476 /* initialize curl */
477 if (curl_global_init (CURL_GLOBAL_DEFAULT) != CURLE_OK)
478 die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_global_init failed\n");
479 curl_global_initialized = true;
480
481 if ((curl = curl_easy_init()) == NULL) {
482 die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_easy_init failed\n");
483 }
484 curl_easy_initialized = true;
485
486 /* register cleanup function to shut down libcurl properly */
487 atexit (cleanup);
488
489 if (verbose >= 1)
490 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_VERBOSE, 1), "CURLOPT_VERBOSE");
491
492 /* print everything on stdout like check_http would do */
493 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR");
494
495 if (automatic_decompression)
496#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 21, 6)
497 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""), "CURLOPT_ACCEPT_ENCODING");
498#else
499 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_ENCODING, ""), "CURLOPT_ENCODING");
500#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 21, 6) */
501
502 /* initialize buffer for body of the answer */
503 if (curlhelp_initwritebuffer(&body_buf) < 0)
504 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n");
505 body_buf_initialized = true;
506 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_WRITEFUNCTION");
507 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEDATA, (void *)&body_buf), "CURLOPT_WRITEDATA");
508
509 /* initialize buffer for header of the answer */
510 if (curlhelp_initwritebuffer( &header_buf ) < 0)
511 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for header\n" );
512 header_buf_initialized = true;
513 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_HEADERFUNCTION");
514 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEHEADER, (void *)&header_buf), "CURLOPT_WRITEHEADER");
515
516 /* set the error buffer */
517 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, errbuf), "CURLOPT_ERRORBUFFER");
518
519 /* set timeouts */
520 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, socket_timeout), "CURLOPT_CONNECTTIMEOUT");
521 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_TIMEOUT, socket_timeout), "CURLOPT_TIMEOUT");
522
523 // fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy
524 if(use_ssl && host_name != NULL) {
525 if ( (res=lookup_host (server_address, addrstr, DEFAULT_BUFFER_SIZE/2)) != 0) {
526 snprintf (msg,
527 DEFAULT_BUFFER_SIZE,
528 _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
529 server_address,
530 res,
531 gai_strerror (res));
532 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
533 }
534 snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, addrstr);
535 host = curl_slist_append(NULL, dnscache);
536 curl_easy_setopt(curl, CURLOPT_RESOLVE, host);
537 if (verbose>=1)
538 printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache);
539 }
540
541 // If server_address is an IPv6 address it must be surround by square brackets
542 struct in6_addr tmp_in_addr;
543 if (inet_pton(AF_INET6, server_address, &tmp_in_addr) == 1) {
544 char *new_server_address = malloc(strlen(server_address) + 3);
545 if (new_server_address == NULL) {
546 die(STATE_UNKNOWN, "HTTP UNKNOWN - Unable to allocate memory\n");
547 }
548 snprintf(new_server_address, strlen(server_address)+3, "[%s]", server_address);
549 free(server_address);
550 server_address = new_server_address;
551 }
552
553 /* compose URL: use the address we want to connect to, set Host: header later */
554 snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
555 use_ssl ? "https" : "http",
556 ( use_ssl & ( host_name != NULL ) ) ? host_name : server_address,
557 server_port,
558 server_url
559 );
560
561 if (verbose>=1)
562 printf ("* curl CURLOPT_URL: %s\n", url);
563 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_URL, url), "CURLOPT_URL");
564
565 /* extract proxy information for legacy proxy https requests */
566 if (!strcmp(http_method, "CONNECT") || strstr(server_url, "http") == server_url) {
567 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PROXY, server_address), "CURLOPT_PROXY");
568 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PROXYPORT, (long)server_port), "CURLOPT_PROXYPORT");
569 if (verbose>=2)
570 printf ("* curl CURLOPT_PROXY: %s:%d\n", server_address, server_port);
571 http_method = "GET";
572 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_URL, server_url), "CURLOPT_URL");
573 }
574
575 /* disable body for HEAD request */
576 if (http_method && !strcmp (http_method, "HEAD" )) {
577 no_body = true;
578 }
579
580 /* set HTTP protocol version */
581 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HTTP_VERSION, curl_http_version), "CURLOPT_HTTP_VERSION");
582
583 /* set HTTP method */
584 if (http_method) {
585 if (!strcmp(http_method, "POST"))
586 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_POST, 1), "CURLOPT_POST");
587 else if (!strcmp(http_method, "PUT"))
588 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_UPLOAD, 1), "CURLOPT_UPLOAD");
589 else
590 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CUSTOMREQUEST, http_method), "CURLOPT_CUSTOMREQUEST");
591 }
592
593 /* check if Host header is explicitly set in options */
594 if (http_opt_headers_count) {
595 for (i = 0; i < http_opt_headers_count ; i++) {
596 if (strncmp(http_opt_headers[i], "Host:", 5) == 0) {
597 force_host_header = http_opt_headers[i];
598 }
599 }
600 }
601
602 /* set hostname (virtual hosts), not needed if CURLOPT_CONNECT_TO is used, but left in anyway */
603 if(host_name != NULL && force_host_header == NULL) {
604 if((virtual_port != HTTP_PORT && !use_ssl) || (virtual_port != HTTPS_PORT && use_ssl)) {
605 snprintf(http_header, DEFAULT_BUFFER_SIZE, "Host: %s:%d", host_name, virtual_port);
606 } else {
607 snprintf(http_header, DEFAULT_BUFFER_SIZE, "Host: %s", host_name);
608 }
609 header_list = curl_slist_append (header_list, http_header);
610 }
611
612 /* always close connection, be nice to servers */
613 snprintf (http_header, DEFAULT_BUFFER_SIZE, "Connection: close");
614 header_list = curl_slist_append (header_list, http_header);
615
616 /* attach additional headers supplied by the user */
617 /* optionally send any other header tag */
618 if (http_opt_headers_count) {
619 for (i = 0; i < http_opt_headers_count ; i++) {
620 header_list = curl_slist_append (header_list, http_opt_headers[i]);
621 }
622 /* This cannot be free'd here because a redirection will then try to access this and segfault */
623 /* Covered in a testcase in tests/check_http.t */
624 /* free(http_opt_headers); */
625 }
626
627 /* set HTTP headers */
628 handle_curl_option_return_code (curl_easy_setopt( curl, CURLOPT_HTTPHEADER, header_list ), "CURLOPT_HTTPHEADER");
629
630#ifdef LIBCURL_FEATURE_SSL
631
632 /* set SSL version, warn about insecure or unsupported versions */
633 if (use_ssl) {
634 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSLVERSION, ssl_version), "CURLOPT_SSLVERSION");
635 }
636
637 /* client certificate and key to present to server (SSL) */
638 if (client_cert)
639 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSLCERT, client_cert), "CURLOPT_SSLCERT");
640 if (client_privkey)
641 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSLKEY, client_privkey), "CURLOPT_SSLKEY");
642 if (ca_cert) {
643 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CAINFO, ca_cert), "CURLOPT_CAINFO");
644 }
645 if (ca_cert || verify_peer_and_host) {
646 /* per default if we have a CA verify both the peer and the
647 * hostname in the certificate, can be switched off later */
648 handle_curl_option_return_code (curl_easy_setopt( curl, CURLOPT_SSL_VERIFYPEER, 1), "CURLOPT_SSL_VERIFYPEER");
649 handle_curl_option_return_code (curl_easy_setopt( curl, CURLOPT_SSL_VERIFYHOST, 2), "CURLOPT_SSL_VERIFYHOST");
650 } else {
651 /* backward-compatible behaviour, be tolerant in checks
652 * TODO: depending on more options have aspects we want
653 * to be less tolerant about ssl verfications
654 */
655 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0), "CURLOPT_SSL_VERIFYPEER");
656 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0), "CURLOPT_SSL_VERIFYHOST");
657 }
658
659 /* detect SSL library used by libcurl */
660 ssl_library = curlhelp_get_ssl_library ();
661
662 /* try hard to get a stack of certificates to verify against */
663 if (check_cert) {
664#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1)
665 /* inform curl to report back certificates */
666 switch (ssl_library) {
667 case CURLHELP_SSL_LIBRARY_OPENSSL:
668 case CURLHELP_SSL_LIBRARY_LIBRESSL:
669 /* set callback to extract certificate with OpenSSL context function (works with
670 * OpenSSL-style libraries only!) */
671#ifdef USE_OPENSSL
672 /* libcurl and monitoring plugins built with OpenSSL, good */
673 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
674 is_openssl_callback = true;
675#else /* USE_OPENSSL */
676#endif /* USE_OPENSSL */
677 /* libcurl is built with OpenSSL, monitoring plugins, so falling
678 * back to manually extracting certificate information */
679 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CERTINFO, 1L), "CURLOPT_CERTINFO");
680 break;
681
682 case CURLHELP_SSL_LIBRARY_NSS:
683#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0)
684 /* NSS: support for CERTINFO is implemented since 7.34.0 */
685 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CERTINFO, 1L), "CURLOPT_CERTINFO");
686#else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */
687 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (libcurl linked with SSL library '%s' is too old)\n", curlhelp_get_ssl_library_string (ssl_library));
688#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */
689 break;
690
691 case CURLHELP_SSL_LIBRARY_GNUTLS:
692#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 42, 0)
693 /* GnuTLS: support for CERTINFO is implemented since 7.42.0 */
694 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_CERTINFO, 1L), "CURLOPT_CERTINFO");
695#else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 42, 0) */
696 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (libcurl linked with SSL library '%s' is too old)\n", curlhelp_get_ssl_library_string (ssl_library));
697#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 42, 0) */
698 break;
699
700 case CURLHELP_SSL_LIBRARY_UNKNOWN:
701 default:
702 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (unknown SSL library '%s', must implement first)\n", curlhelp_get_ssl_library_string (ssl_library));
703 break;
704 }
705#else /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
706 /* old libcurl, our only hope is OpenSSL, otherwise we are out of luck */
707 if (ssl_library == CURLHELP_SSL_LIBRARY_OPENSSL || ssl_library == CURLHELP_SSL_LIBRARY_LIBRESSL)
708 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
709 else
710 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates (no CURLOPT_SSL_CTX_FUNCTION, no OpenSSL library or libcurl too old and has no CURLOPT_CERTINFO)\n");
711#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 1) */
712 }
713
714#endif /* LIBCURL_FEATURE_SSL */
715
716 /* set default or user-given user agent identification */
717 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERAGENT, user_agent), "CURLOPT_USERAGENT");
718
719 /* proxy-authentication */
720 if (strcmp(proxy_auth, ""))
721 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PROXYUSERPWD, proxy_auth), "CURLOPT_PROXYUSERPWD");
722
723 /* authentication */
724 if (strcmp(user_auth, ""))
725 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERPWD, user_auth), "CURLOPT_USERPWD");
726
727 /* TODO: parameter auth method, bitfield of following methods:
728 * CURLAUTH_BASIC (default)
729 * CURLAUTH_DIGEST
730 * CURLAUTH_DIGEST_IE
731 * CURLAUTH_NEGOTIATE
732 * CURLAUTH_NTLM
733 * CURLAUTH_NTLM_WB
734 *
735 * convenience tokens for typical sets of methods:
736 * CURLAUTH_ANYSAFE: most secure, without BASIC
737 * or CURLAUTH_ANY: most secure, even BASIC if necessary
738 *
739 * handle_curl_option_return_code (curl_easy_setopt( curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST ), "CURLOPT_HTTPAUTH");
740 */
741
742 /* handle redirections */
743 if (onredirect == STATE_DEPENDENT) {
744 if( followmethod == FOLLOW_LIBCURL ) {
745 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1), "CURLOPT_FOLLOWLOCATION");
746
747 /* default -1 is infinite, not good, could lead to zombie plugins!
748 Setting it to one bigger than maximal limit to handle errors nicely below
749 */
750 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_MAXREDIRS, max_depth+1), "CURLOPT_MAXREDIRS");
751
752 /* for now allow only http and https (we are a http(s) check plugin in the end) */
753#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 85, 0)
754 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https"), "CURLOPT_REDIR_PROTOCOLS_STR");
755#elif LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 4)
756 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS), "CURLOPT_REDIRECT_PROTOCOLS");
757#endif
758
759 /* TODO: handle the following aspects of redirection, make them
760 * command line options too later:
761 CURLOPT_POSTREDIR: method switch
762 CURLINFO_REDIRECT_URL: custom redirect option
763 CURLOPT_REDIRECT_PROTOCOLS: allow people to step outside safe protocols
764 CURLINFO_REDIRECT_COUNT: get the number of redirects, print it, maybe a range option here is nice like for expected page size?
765 */
766 } else {
767 /* old style redirection is handled below */
768 }
769 }
770
771 /* no-body */
772 if (no_body)
773 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_NOBODY, 1), "CURLOPT_NOBODY");
774
775 /* IPv4 or IPv6 forced DNS resolution */
776 if (address_family == AF_UNSPEC)
777 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_WHATEVER)");
778 else if (address_family == AF_INET)
779 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_V4)");
780#if defined (USE_IPV6) && defined (LIBCURL_FEATURE_IPV6)
781 else if (address_family == AF_INET6)
782 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6), "CURLOPT_IPRESOLVE(CURL_IPRESOLVE_V6)");
783#endif
784
785 /* either send http POST data (any data, not only POST)*/
786 if (!strcmp(http_method, "POST") ||!strcmp(http_method, "PUT")) {
787 /* set content of payload for POST and PUT */
788 if (http_content_type) {
789 snprintf (http_header, DEFAULT_BUFFER_SIZE, "Content-Type: %s", http_content_type);
790 header_list = curl_slist_append (header_list, http_header);
791 }
792 /* NULL indicates "HTTP Continue" in libcurl, provide an empty string
793 * in case of no POST/PUT data */
794 if (!http_post_data)
795 http_post_data = "";
796 if (!strcmp(http_method, "POST")) {
797 /* POST method, set payload with CURLOPT_POSTFIELDS */
798 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_POSTFIELDS, http_post_data), "CURLOPT_POSTFIELDS");
799 } else if (!strcmp(http_method, "PUT")) {
800 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READFUNCTION, (curl_read_callback)curlhelp_buffer_read_callback), "CURLOPT_READFUNCTION");
801 if (curlhelp_initreadbuffer (&put_buf, http_post_data, strlen (http_post_data)) < 0)
802 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating read buffer for PUT\n");
803 put_buf_initialized = true;
804 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READDATA, (void *)&put_buf), "CURLOPT_READDATA");
805 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_INFILESIZE, (curl_off_t)strlen (http_post_data)), "CURLOPT_INFILESIZE");
806 }
807 }
808
809 /* cookie handling */
810 if (cookie_jar_file != NULL) {
811 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR");
812 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEFILE, cookie_jar_file), "CURLOPT_COOKIEFILE");
813 }
814
815 /* do the request */
816 res = curl_easy_perform(curl);
817
818 if (verbose>=2 && http_post_data)
819 printf ("**** REQUEST CONTENT ****\n%s\n", http_post_data);
820
821 /* free header and server IP resolve lists, we don't need it anymore */
822 curl_slist_free_all (header_list); header_list = NULL;
823 curl_slist_free_all (server_ips); server_ips = NULL;
824 if (host) {
825 curl_slist_free_all (host); host = NULL;
826 }
827
828 /* Curl errors, result in critical Nagios state */
829 if (res != CURLE_OK) {
830 snprintf (msg,
831 DEFAULT_BUFFER_SIZE,
832 _("Invalid HTTP response received from host on port %d: cURL returned %d - %s"),
833 server_port,
834 res,
835 errbuf[0] ? errbuf : curl_easy_strerror(res));
836 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
837 }
838
839 /* certificate checks */
840#ifdef LIBCURL_FEATURE_SSL
841 if (use_ssl) {
842 if (check_cert) {
843 if (is_openssl_callback) {
844#ifdef USE_OPENSSL
845 /* check certificate with OpenSSL functions, curl has been built against OpenSSL
846 * and we actually have OpenSSL in the monitoring tools
847 */
848 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
849 if (!continue_after_check_cert) {
850 return result;
851 }
852#else /* USE_OPENSSL */
853 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL callback used and not linked against OpenSSL\n");
854#endif /* USE_OPENSSL */
855 } else {
856 int i;
857 struct curl_slist *slist;
858
859 cert_ptr.to_info = NULL;
860 res = curl_easy_getinfo (curl, CURLINFO_CERTINFO, &cert_ptr.to_info);
861 if (!res && cert_ptr.to_info) {
862#ifdef USE_OPENSSL
863 /* We have no OpenSSL in libcurl, but we can use OpenSSL for X509 cert parsing
864 * We only check the first certificate and assume it's the one of the server
865 */
866 const char* raw_cert = NULL;
867 for (i = 0; i < cert_ptr.to_certinfo->num_of_certs; i++) {
868 for (slist = cert_ptr.to_certinfo->certinfo[i]; slist; slist = slist->next) {
869 if (verbose >= 2)
870 printf ("%d ** %s\n", i, slist->data);
871 if (strncmp (slist->data, "Cert:", 5) == 0) {
872 raw_cert = &slist->data[5];
873 goto GOT_FIRST_CERT;
874 }
875 }
876 }
877GOT_FIRST_CERT:
878 if (!raw_cert) {
879 snprintf (msg,
880 DEFAULT_BUFFER_SIZE,
881 _("Cannot retrieve certificates from CERTINFO information - certificate data was empty"));
882 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
883 }
884 BIO* cert_BIO = BIO_new (BIO_s_mem());
885 BIO_write (cert_BIO, raw_cert, strlen(raw_cert));
886 cert = PEM_read_bio_X509 (cert_BIO, NULL, NULL, NULL);
887 if (!cert) {
888 snprintf (msg,
889 DEFAULT_BUFFER_SIZE,
890 _("Cannot read certificate from CERTINFO information - BIO error"));
891 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
892 }
893 BIO_free (cert_BIO);
894 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
895 if (!continue_after_check_cert) {
896 return result;
897 }
898#else /* USE_OPENSSL */
899 /* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our disposal,
900 * so we use the libcurl CURLINFO data
901 */
902 result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit);
903 if (!continue_after_check_cert) {
904 return result;
905 }
906#endif /* USE_OPENSSL */
907 } else {
908 snprintf (msg,
909 DEFAULT_BUFFER_SIZE,
910 _("Cannot retrieve certificates - cURL returned %d - %s"),
911 res,
912 curl_easy_strerror(res));
913 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
914 }
915 }
916 }
917 }
918#endif /* LIBCURL_FEATURE_SSL */
919
920 /* we got the data and we executed the request in a given time, so we can append
921 * performance data to the answer always
922 */
923 handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_TOTAL_TIME, &total_time), "CURLINFO_TOTAL_TIME");
924 page_len = get_content_length(&header_buf, &body_buf);
925 if(show_extended_perfdata) {
926 handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect), "CURLINFO_CONNECT_TIME");
927 handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, &time_appconnect), "CURLINFO_APPCONNECT_TIME");
928 handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_headers), "CURLINFO_PRETRANSFER_TIME");
929 handle_curl_option_return_code (curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &time_firstbyte), "CURLINFO_STARTTRANSFER_TIME");
930 snprintf(perfstring, DEFAULT_BUFFER_SIZE, "%s %s %s %s %s %s %s",
931 perfd_time(total_time),
932 perfd_size(page_len),
933 perfd_time_connect(time_connect),
934 use_ssl ? perfd_time_ssl (time_appconnect-time_connect) : "",
935 perfd_time_headers(time_headers - time_appconnect),
936 perfd_time_firstbyte(time_firstbyte - time_headers),
937 perfd_time_transfer(total_time-time_firstbyte)
938 );
939 } else {
940 snprintf(perfstring, DEFAULT_BUFFER_SIZE, "%s %s",
941 perfd_time(total_time),
942 perfd_size(page_len)
943 );
944 }
945
946 /* return a CRITICAL status if we couldn't read any data */
947 if (strlen(header_buf.buf) == 0 && strlen(body_buf.buf) == 0)
948 die (STATE_CRITICAL, _("HTTP CRITICAL - No header received from host\n"));
949
950 /* get status line of answer, check sanity of HTTP code */
951 if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) {
952 snprintf (msg,
953 DEFAULT_BUFFER_SIZE,
954 "Unparsable status line in %.3g seconds response time|%s\n",
955 total_time,
956 perfstring);
957 /* we cannot know the major/minor version here for sure as we cannot parse the first line */
958 die (STATE_CRITICAL, "HTTP CRITICAL HTTP/x.x %ld unknown - %s", code, msg);
959 }
960 status_line_initialized = true;
961
962 /* get result code from cURL */
963 handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE");
964 if (verbose>=2)
965 printf ("* curl CURLINFO_RESPONSE_CODE is %ld\n", code);
966
967 /* print status line, header, body if verbose */
968 if (verbose >= 2) {
969 printf ("**** HEADER ****\n%s\n**** CONTENT ****\n%s\n", header_buf.buf,
970 (no_body ? " [[ skipped ]]" : body_buf.buf));
971 }
972
973 /* make sure the status line matches the response we are looking for */
974 if (!expected_statuscode(status_line.first_line, server_expect)) {
975 if (server_port == HTTP_PORT)
976 snprintf(msg,
977 DEFAULT_BUFFER_SIZE,
978 _("Invalid HTTP response received from host: %s\n"),
979 status_line.first_line);
980 else
981 snprintf(msg,
982 DEFAULT_BUFFER_SIZE,
983 _("Invalid HTTP response received from host on port %d: %s\n"),
984 server_port,
985 status_line.first_line);
986 die (STATE_CRITICAL, "HTTP CRITICAL - %s%s%s", msg,
987 show_body ? "\n" : "",
988 show_body ? body_buf.buf : "");
989 }
990
991 if( server_expect_yn ) {
992 snprintf(msg, DEFAULT_BUFFER_SIZE, _("Status line output matched \"%s\" - "), server_expect);
993 if (verbose)
994 printf ("%s\n",msg);
995 result = STATE_OK;
996 }
997 else {
998 /* illegal return codes result in a critical state */
999 if (code >= 600 || code < 100) {
1000 die (STATE_CRITICAL, _("HTTP CRITICAL: Invalid Status (%d, %.40s)\n"), status_line.http_code, status_line.msg);
1001 /* server errors result in a critical state */
1002 } else if (code >= 500) {
1003 result = STATE_CRITICAL;
1004 /* client errors result in a warning state */
1005 } else if (code >= 400) {
1006 result = STATE_WARNING;
1007 /* check redirected page if specified */
1008 } else if (code >= 300) {
1009 if (onredirect == STATE_DEPENDENT) {
1010 if( followmethod == FOLLOW_LIBCURL ) {
1011 code = status_line.http_code;
1012 } else {
1013 /* old check_http style redirection, if we come
1014 * back here, we are in the same status as with
1015 * the libcurl method
1016 */
1017 redir (&header_buf);
1018 }
1019 } else {
1020 /* this is a specific code in the command line to
1021 * be returned when a redirection is encountered
1022 */
1023 }
1024 result = max_state_alt (onredirect, result);
1025 /* all other codes are considered ok */
1026 } else {
1027 result = STATE_OK;
1028 }
1029 }
1030
1031 /* libcurl redirection internally, handle error states here */
1032 if( followmethod == FOLLOW_LIBCURL ) {
1033 handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_REDIRECT_COUNT, &redir_depth), "CURLINFO_REDIRECT_COUNT");
1034 if (verbose >= 2)
1035 printf(_("* curl LIBINFO_REDIRECT_COUNT is %d\n"), redir_depth);
1036 if (redir_depth > max_depth) {
1037 snprintf (msg, DEFAULT_BUFFER_SIZE, "maximum redirection depth %d exceeded in libcurl",
1038 max_depth);
1039 die (STATE_WARNING, "HTTP WARNING - %s", msg);
1040 }
1041 }
1042
1043 /* check status codes, set exit status accordingly */
1044 if( status_line.http_code != code ) {
1045 die (STATE_CRITICAL, _("HTTP CRITICAL %s %d %s - different HTTP codes (cUrl has %ld)\n"),
1046 string_statuscode (status_line.http_major, status_line.http_minor),
1047 status_line.http_code, status_line.msg, code);
1048 }
1049
1050 if (maximum_age >= 0) {
1051 result = max_state_alt(check_document_dates(&header_buf, &msg), result);
1052 }
1053
1054 /* Page and Header content checks go here */
1055
1056 if (strlen (header_expect)) {
1057 if (!strstr (header_buf.buf, header_expect)) {
1058
1059 strncpy(&output_header_search[0],header_expect,sizeof(output_header_search));
1060
1061 if(output_header_search[sizeof(output_header_search)-1]!='\0') {
1062 bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
1063 }
1064
1065 char tmp[DEFAULT_BUFFER_SIZE];
1066
1067 snprintf (tmp,
1068 DEFAULT_BUFFER_SIZE,
1069 _("%sheader '%s' not found on '%s://%s:%d%s', "),
1070 msg,
1071 output_header_search,
1072 use_ssl ? "https" : "http",
1073 host_name ? host_name : server_address,
1074 server_port,
1075 server_url);
1076
1077 strcpy(msg, tmp);
1078
1079 result = STATE_CRITICAL;
1080 }
1081 }
1082
1083 if (strlen (string_expect)) {
1084 if (!strstr (body_buf.buf, string_expect)) {
1085
1086 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search));
1087
1088 if(output_string_search[sizeof(output_string_search)-1]!='\0') {
1089 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4);
1090 }
1091
1092 char tmp[DEFAULT_BUFFER_SIZE];
1093
1094 snprintf (tmp,
1095 DEFAULT_BUFFER_SIZE,
1096 _("%sstring '%s' not found on '%s://%s:%d%s', "),
1097 msg,
1098 output_string_search,
1099 use_ssl ? "https" : "http",
1100 host_name ? host_name : server_address,
1101 server_port,
1102 server_url);
1103
1104 strcpy(msg, tmp);
1105
1106 result = STATE_CRITICAL;
1107 }
1108 }
1109
1110 if (strlen (regexp)) {
1111 errcode = regexec (&preg, body_buf.buf, REGS, pmatch, 0);
1112 if ((errcode == 0 && !invert_regex) || (errcode == REG_NOMATCH && invert_regex)) {
1113 /* OK - No-op to avoid changing the logic around it */
1114 result = max_state_alt(STATE_OK, result);
1115 }
1116 else if ((errcode == REG_NOMATCH && !invert_regex) || (errcode == 0 && invert_regex)) {
1117 if (!invert_regex) {
1118 char tmp[DEFAULT_BUFFER_SIZE];
1119
1120 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg);
1121 strcpy(msg, tmp);
1122
1123 } else {
1124 char tmp[DEFAULT_BUFFER_SIZE];
1125
1126 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg);
1127 strcpy(msg, tmp);
1128
1129 }
1130 result = STATE_CRITICAL;
1131 } else {
1132 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
1133
1134 char tmp[DEFAULT_BUFFER_SIZE];
1135
1136 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sExecute Error: %s, "), msg, errbuf);
1137 strcpy(msg, tmp);
1138 result = STATE_UNKNOWN;
1139 }
1140 }
1141
1142 /* make sure the page is of an appropriate size */
1143 if ((max_page_len > 0) && (page_len > max_page_len)) {
1144 char tmp[DEFAULT_BUFFER_SIZE];
1145
1146 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too large, "), msg, page_len);
1147
1148 strcpy(msg, tmp);
1149
1150 result = max_state_alt(STATE_WARNING, result);
1151
1152 } else if ((min_page_len > 0) && (page_len < min_page_len)) {
1153 char tmp[DEFAULT_BUFFER_SIZE];
1154
1155 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too small, "), msg, page_len);
1156 strcpy(msg, tmp);
1157 result = max_state_alt(STATE_WARNING, result);
1158 }
1159
1160 /* -w, -c: check warning and critical level */
1161 result = max_state_alt(get_status(total_time, thlds), result);
1162
1163 /* Cut-off trailing characters */
1164 if (strlen(msg) >= 2) {
1165 if(msg[strlen(msg)-2] == ',')
1166 msg[strlen(msg)-2] = '\0';
1167 else
1168 msg[strlen(msg)-3] = '\0';
1169 }
1170
1171 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
1172 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
1173 state_text(result), string_statuscode (status_line.http_major, status_line.http_minor),
1174 status_line.http_code, status_line.msg,
1175 strlen(msg) > 0 ? " - " : "",
1176 msg, page_len, total_time,
1177 (display_html ? "</A>" : ""),
1178 perfstring,
1179 (show_body ? body_buf.buf : ""),
1180 (show_body ? "\n" : "") );
1181
1182 return result;
1183}
1184
1185int
1186uri_strcmp (const UriTextRangeA range, const char* s)
1187{
1188 if (!range.first) return -1;
1189 if (range.afterLast - range.first < strlen (s)) return -1;
1190 return strncmp (s, range.first, min( range.afterLast - range.first, strlen (s)));
1191}
1192
1193char*
1194uri_string (const UriTextRangeA range, char* buf, size_t buflen)
1195{
1196 if (!range.first) return "(null)";
1197 strncpy (buf, range.first, max (buflen-1, range.afterLast - range.first));
1198 buf[max (buflen-1, range.afterLast - range.first)] = '\0';
1199 buf[range.afterLast - range.first] = '\0';
1200 return buf;
1201}
1202
1203void
1204redir (curlhelp_write_curlbuf* header_buf)
1205{
1206 char *location = NULL;
1207 curlhelp_statusline status_line;
1208 struct phr_header headers[255];
1209 size_t nof_headers = 255;
1210 size_t msglen;
1211 char buf[DEFAULT_BUFFER_SIZE];
1212 char ipstr[INET_ADDR_MAX_SIZE];
1213 int new_port;
1214 char *new_host;
1215 char *new_url;
1216
1217 int res = phr_parse_response (header_buf->buf, header_buf->buflen,
1218 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
1219 headers, &nof_headers, 0);
1220
1221 location = get_header_value (headers, nof_headers, "location");
1222
1223 if (verbose >= 2)
1224 printf(_("* Seen redirect location %s\n"), location);
1225
1226 if (++redir_depth > max_depth)
1227 die (STATE_WARNING,
1228 _("HTTP WARNING - maximum redirection depth %d exceeded - %s%s\n"),
1229 max_depth, location, (display_html ? "</A>" : ""));
1230
1231 UriParserStateA state;
1232 UriUriA uri;
1233 state.uri = &uri;
1234 if (uriParseUriA (&state, location) != URI_SUCCESS) {
1235 if (state.errorCode == URI_ERROR_SYNTAX) {
1236 die (STATE_UNKNOWN,
1237 _("HTTP UNKNOWN - Could not parse redirect location '%s'%s\n"),
1238 location, (display_html ? "</A>" : ""));
1239 } else if (state.errorCode == URI_ERROR_MALLOC) {
1240 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate URL\n"));
1241 }
1242 }
1243
1244 if (verbose >= 2) {
1245 printf (_("** scheme: %s\n"),
1246 uri_string (uri.scheme, buf, DEFAULT_BUFFER_SIZE));
1247 printf (_("** host: %s\n"),
1248 uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE));
1249 printf (_("** port: %s\n"),
1250 uri_string (uri.portText, buf, DEFAULT_BUFFER_SIZE));
1251 if (uri.hostData.ip4) {
1252 inet_ntop (AF_INET, uri.hostData.ip4->data, ipstr, sizeof (ipstr));
1253 printf (_("** IPv4: %s\n"), ipstr);
1254 }
1255 if (uri.hostData.ip6) {
1256 inet_ntop (AF_INET, uri.hostData.ip6->data, ipstr, sizeof (ipstr));
1257 printf (_("** IPv6: %s\n"), ipstr);
1258 }
1259 if (uri.pathHead) {
1260 printf (_("** path: "));
1261 const UriPathSegmentA* p = uri.pathHead;
1262 for (; p; p = p->next) {
1263 printf ("/%s", uri_string (p->text, buf, DEFAULT_BUFFER_SIZE));
1264 }
1265 puts ("");
1266 }
1267 if (uri.query.first) {
1268 printf (_("** query: %s\n"),
1269 uri_string (uri.query, buf, DEFAULT_BUFFER_SIZE));
1270 }
1271 if (uri.fragment.first) {
1272 printf (_("** fragment: %s\n"),
1273 uri_string (uri.fragment, buf, DEFAULT_BUFFER_SIZE));
1274 }
1275 }
1276
1277 if (!uri_strcmp (uri.scheme, "https"))
1278 use_ssl = true;
1279 else
1280 use_ssl = false;
1281
1282 /* we do a sloppy test here only, because uriparser would have failed
1283 * above, if the port would be invalid, we just check for MAX_PORT
1284 */
1285 if (uri.portText.first) {
1286 new_port = atoi (uri_string (uri.portText, buf, DEFAULT_BUFFER_SIZE));
1287 } else {
1288 new_port = HTTP_PORT;
1289 if (use_ssl)
1290 new_port = HTTPS_PORT;
1291 }
1292 if (new_port > MAX_PORT)
1293 die (STATE_UNKNOWN,
1294 _("HTTP UNKNOWN - Redirection to port above %d - %s%s\n"),
1295 MAX_PORT, location, display_html ? "</A>" : "");
1296
1297 /* by RFC 7231 relative URLs in Location should be taken relative to
1298 * the original URL, so wy try to form a new absolute URL here
1299 */
1300 if (!uri.scheme.first && !uri.hostText.first) {
1301 new_host = strdup (host_name ? host_name : server_address);
1302 } else {
1303 new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE));
1304 }
1305
1306 /* compose new path */
1307 /* TODO: handle fragments and query part of URL */
1308 new_url = (char *)calloc( 1, DEFAULT_BUFFER_SIZE);
1309 if (uri.pathHead) {
1310 const UriPathSegmentA* p = uri.pathHead;
1311 for (; p; p = p->next) {
1312 strncat (new_url, "/", DEFAULT_BUFFER_SIZE);
1313 strncat (new_url, uri_string (p->text, buf, DEFAULT_BUFFER_SIZE), DEFAULT_BUFFER_SIZE-1);
1314 }
1315 }
1316
1317 if (server_port==new_port &&
1318 !strncmp(server_address, new_host, MAX_IPV4_HOSTLENGTH) &&
1319 (host_name && !strncmp(host_name, new_host, MAX_IPV4_HOSTLENGTH)) &&
1320 !strcmp(server_url, new_url))
1321 die (STATE_CRITICAL,
1322 _("HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"),
1323 use_ssl ? "https" : "http", new_host, new_port, new_url, (display_html ? "</A>" : ""));
1324
1325 /* set new values for redirected request */
1326
1327 if (!(followsticky & STICKY_HOST)) {
1328 free (server_address);
1329 server_address = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1330 }
1331 if (!(followsticky & STICKY_PORT)) {
1332 server_port = (unsigned short)new_port;
1333 }
1334
1335 free (host_name);
1336 host_name = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1337
1338 /* reset virtual port */
1339 virtual_port = server_port;
1340
1341 free(new_host);
1342 free (server_url);
1343 server_url = new_url;
1344
1345 uriFreeUriMembersA (&uri);
1346
1347 if (verbose)
1348 printf (_("Redirection to %s://%s:%d%s\n"), use_ssl ? "https" : "http",
1349 host_name ? host_name : server_address, server_port, server_url);
1350
1351 /* TODO: the hash component MUST be taken from the original URL and
1352 * attached to the URL in Location
1353 */
1354
1355 cleanup ();
1356 check_http ();
1357}
1358
1359/* check whether a file exists */
1360void
1361test_file (char *path)
1362{
1363 if (access(path, R_OK) == 0)
1364 return;
1365 usage2 (_("file does not exist or is not readable"), path);
1366}
1367
1368bool
1369process_arguments (int argc, char **argv)
1370{
1371 char *p;
1372 int c = 1;
1373 char *temp;
1374
1375 enum {
1376 INVERT_REGEX = CHAR_MAX + 1,
1377 SNI_OPTION,
1378 MAX_REDIRS_OPTION,
1379 CONTINUE_AFTER_CHECK_CERT,
1380 CA_CERT_OPTION,
1381 HTTP_VERSION_OPTION,
1382 AUTOMATIC_DECOMPRESSION,
1383 COOKIE_JAR
1384 };
1385
1386 int option = 0;
1387 int got_plus = 0;
1388 static struct option longopts[] = {
1389 STD_LONG_OPTS,
1390 {"link", no_argument, 0, 'L'},
1391 {"nohtml", no_argument, 0, 'n'},
1392 {"ssl", optional_argument, 0, 'S'},
1393 {"sni", no_argument, 0, SNI_OPTION},
1394 {"post", required_argument, 0, 'P'},
1395 {"method", required_argument, 0, 'j'},
1396 {"IP-address", required_argument, 0, 'I'},
1397 {"url", required_argument, 0, 'u'},
1398 {"port", required_argument, 0, 'p'},
1399 {"authorization", required_argument, 0, 'a'},
1400 {"proxy-authorization", required_argument, 0, 'b'},
1401 {"header-string", required_argument, 0, 'd'},
1402 {"string", required_argument, 0, 's'},
1403 {"expect", required_argument, 0, 'e'},
1404 {"regex", required_argument, 0, 'r'},
1405 {"ereg", required_argument, 0, 'r'},
1406 {"eregi", required_argument, 0, 'R'},
1407 {"linespan", no_argument, 0, 'l'},
1408 {"onredirect", required_argument, 0, 'f'},
1409 {"certificate", required_argument, 0, 'C'},
1410 {"client-cert", required_argument, 0, 'J'},
1411 {"private-key", required_argument, 0, 'K'},
1412 {"ca-cert", required_argument, 0, CA_CERT_OPTION},
1413 {"verify-cert", no_argument, 0, 'D'},
1414 {"continue-after-certificate", no_argument, 0, CONTINUE_AFTER_CHECK_CERT},
1415 {"useragent", required_argument, 0, 'A'},
1416 {"header", required_argument, 0, 'k'},
1417 {"no-body", no_argument, 0, 'N'},
1418 {"max-age", required_argument, 0, 'M'},
1419 {"content-type", required_argument, 0, 'T'},
1420 {"pagesize", required_argument, 0, 'm'},
1421 {"invert-regex", no_argument, NULL, INVERT_REGEX},
1422 {"use-ipv4", no_argument, 0, '4'},
1423 {"use-ipv6", no_argument, 0, '6'},
1424 {"extended-perfdata", no_argument, 0, 'E'},
1425 {"show-body", no_argument, 0, 'B'},
1426 {"max-redirs", required_argument, 0, MAX_REDIRS_OPTION},
1427 {"http-version", required_argument, 0, HTTP_VERSION_OPTION},
1428 {"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION},
1429 {"cookie-jar", required_argument, 0, COOKIE_JAR},
1430 {0, 0, 0, 0}
1431 };
1432
1433 if (argc < 2)
1434 return false;
1435
1436 /* support check_http compatible arguments */
1437 for (c = 1; c < argc; c++) {
1438 if (strcmp ("-to", argv[c]) == 0)
1439 strcpy (argv[c], "-t");
1440 if (strcmp ("-hn", argv[c]) == 0)
1441 strcpy (argv[c], "-H");
1442 if (strcmp ("-wt", argv[c]) == 0)
1443 strcpy (argv[c], "-w");
1444 if (strcmp ("-ct", argv[c]) == 0)
1445 strcpy (argv[c], "-c");
1446 if (strcmp ("-nohtml", argv[c]) == 0)
1447 strcpy (argv[c], "-n");
1448 }
1449
1450 server_url = strdup(DEFAULT_SERVER_URL);
1451
1452 while (1) {
1453 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:DnlLS::m:M:NEB", longopts, &option);
1454 if (c == -1 || c == EOF || c == 1)
1455 break;
1456
1457 switch (c) {
1458 case 'h':
1459 print_help();
1460 exit(STATE_UNKNOWN);
1461 break;
1462 case 'V':
1463 print_revision(progname, NP_VERSION);
1464 print_curl_version();
1465 exit(STATE_UNKNOWN);
1466 break;
1467 case 'v':
1468 verbose++;
1469 break;
1470 case 't': /* timeout period */
1471 if (!is_intnonneg (optarg))
1472 usage2 (_("Timeout interval must be a positive integer"), optarg);
1473 else
1474 socket_timeout = (int)strtol (optarg, NULL, 10);
1475 break;
1476 case 'c': /* critical time threshold */
1477 critical_thresholds = optarg;
1478 break;
1479 case 'w': /* warning time threshold */
1480 warning_thresholds = optarg;
1481 break;
1482 case 'H': /* virtual host */
1483 host_name = strdup (optarg);
1484 if (host_name[0] == '[') {
1485 if ((p = strstr (host_name, "]:")) != NULL) { /* [IPv6]:port */
1486 virtual_port = atoi (p + 2);
1487 /* cut off the port */
1488 host_name_length = strlen (host_name) - strlen (p) - 1;
1489 free (host_name);
1490 host_name = strndup (optarg, host_name_length);
1491 }
1492 } else if ((p = strchr (host_name, ':')) != NULL
1493 && strchr (++p, ':') == NULL) { /* IPv4:port or host:port */
1494 virtual_port = atoi (p);
1495 /* cut off the port */
1496 host_name_length = strlen (host_name) - strlen (p) - 1;
1497 free (host_name);
1498 host_name = strndup (optarg, host_name_length);
1499 }
1500 break;
1501 case 'I': /* internet address */
1502 server_address = strdup (optarg);
1503 break;
1504 case 'u': /* URL path */
1505 server_url = strdup (optarg);
1506 break;
1507 case 'p': /* Server port */
1508 if (!is_intnonneg (optarg))
1509 usage2 (_("Invalid port number, expecting a non-negative number"), optarg);
1510 else {
1511 if( strtol(optarg, NULL, 10) > MAX_PORT)
1512 usage2 (_("Invalid port number, supplied port number is too big"), optarg);
1513 server_port = (unsigned short)strtol(optarg, NULL, 10);
1514 specify_port = true;
1515 }
1516 break;
1517 case 'a': /* authorization info */
1518 strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1);
1519 user_auth[MAX_INPUT_BUFFER - 1] = 0;
1520 break;
1521 case 'b': /* proxy-authorization info */
1522 strncpy (proxy_auth, optarg, MAX_INPUT_BUFFER - 1);
1523 proxy_auth[MAX_INPUT_BUFFER - 1] = 0;
1524 break;
1525 case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */
1526 if (! http_post_data)
1527 http_post_data = strdup (optarg);
1528 if (! http_method)
1529 http_method = strdup("POST");
1530 break;
1531 case 'j': /* Set HTTP method */
1532 if (http_method)
1533 free(http_method);
1534 http_method = strdup (optarg);
1535 break;
1536 case 'A': /* useragent */
1537 strncpy (user_agent, optarg, DEFAULT_BUFFER_SIZE);
1538 user_agent[DEFAULT_BUFFER_SIZE-1] = '\0';
1539 break;
1540 case 'k': /* Additional headers */
1541 if (http_opt_headers_count == 0)
1542 http_opt_headers = malloc (sizeof (char *) * (++http_opt_headers_count));
1543 else
1544 http_opt_headers = realloc (http_opt_headers, sizeof (char *) * (++http_opt_headers_count));
1545 http_opt_headers[http_opt_headers_count - 1] = optarg;
1546 break;
1547 case 'L': /* show html link */
1548 display_html = true;
1549 break;
1550 case 'n': /* do not show html link */
1551 display_html = false;
1552 break;
1553 case 'C': /* Check SSL cert validity */
1554#ifdef LIBCURL_FEATURE_SSL
1555 if ((temp=strchr(optarg,','))!=NULL) {
1556 *temp='\0';
1557 if (!is_intnonneg (optarg))
1558 usage2 (_("Invalid certificate expiration period"), optarg);
1559 days_till_exp_warn = atoi(optarg);
1560 *temp=',';
1561 temp++;
1562 if (!is_intnonneg (temp))
1563 usage2 (_("Invalid certificate expiration period"), temp);
1564 days_till_exp_crit = atoi (temp);
1565 }
1566 else {
1567 days_till_exp_crit=0;
1568 if (!is_intnonneg (optarg))
1569 usage2 (_("Invalid certificate expiration period"), optarg);
1570 days_till_exp_warn = atoi (optarg);
1571 }
1572 check_cert = true;
1573 goto enable_ssl;
1574#endif
1575 case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */
1576#ifdef HAVE_SSL
1577 continue_after_check_cert = true;
1578 break;
1579#endif
1580 case 'J': /* use client certificate */
1581#ifdef LIBCURL_FEATURE_SSL
1582 test_file(optarg);
1583 client_cert = optarg;
1584 goto enable_ssl;
1585#endif
1586 case 'K': /* use client private key */
1587#ifdef LIBCURL_FEATURE_SSL
1588 test_file(optarg);
1589 client_privkey = optarg;
1590 goto enable_ssl;
1591#endif
1592#ifdef LIBCURL_FEATURE_SSL
1593 case CA_CERT_OPTION: /* use CA chain file */
1594 test_file(optarg);
1595 ca_cert = optarg;
1596 goto enable_ssl;
1597#endif
1598#ifdef LIBCURL_FEATURE_SSL
1599 case 'D': /* verify peer certificate & host */
1600 verify_peer_and_host = true;
1601 break;
1602#endif
1603 case 'S': /* use SSL */
1604#ifdef LIBCURL_FEATURE_SSL
1605 enable_ssl:
1606 use_ssl = true;
1607 /* ssl_version initialized to CURL_SSLVERSION_DEFAULT as a default.
1608 * Only set if it's non-zero. This helps when we include multiple
1609 * parameters, like -S and -C combinations */
1610 ssl_version = CURL_SSLVERSION_DEFAULT;
1611 if (c=='S' && optarg != NULL) {
1612 char *plus_ptr = strchr(optarg, '+');
1613 if (plus_ptr) {
1614 got_plus = 1;
1615 *plus_ptr = '\0';
1616 }
1617
1618 if (optarg[0] == '2')
1619 ssl_version = CURL_SSLVERSION_SSLv2;
1620 else if (optarg[0] == '3')
1621 ssl_version = CURL_SSLVERSION_SSLv3;
1622 else if (!strcmp (optarg, "1") || !strcmp (optarg, "1.0"))
1623#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0)
1624 ssl_version = CURL_SSLVERSION_TLSv1_0;
1625#else
1626 ssl_version = CURL_SSLVERSION_DEFAULT;
1627#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */
1628 else if (!strcmp (optarg, "1.1"))
1629#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0)
1630 ssl_version = CURL_SSLVERSION_TLSv1_1;
1631#else
1632 ssl_version = CURL_SSLVERSION_DEFAULT;
1633#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */
1634 else if (!strcmp (optarg, "1.2"))
1635#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0)
1636 ssl_version = CURL_SSLVERSION_TLSv1_2;
1637#else
1638 ssl_version = CURL_SSLVERSION_DEFAULT;
1639#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 34, 0) */
1640 else if (!strcmp (optarg, "1.3"))
1641#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 52, 0)
1642 ssl_version = CURL_SSLVERSION_TLSv1_3;
1643#else
1644 ssl_version = CURL_SSLVERSION_DEFAULT;
1645#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 52, 0) */
1646 else
1647 usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2, 1.3 (with optional '+' suffix)"));
1648 }
1649#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0)
1650 if (got_plus) {
1651 switch (ssl_version) {
1652 case CURL_SSLVERSION_TLSv1_3:
1653 ssl_version |= CURL_SSLVERSION_MAX_TLSv1_3;
1654 break;
1655 case CURL_SSLVERSION_TLSv1_2:
1656 case CURL_SSLVERSION_TLSv1_1:
1657 case CURL_SSLVERSION_TLSv1_0:
1658 ssl_version |= CURL_SSLVERSION_MAX_DEFAULT;
1659 break;
1660 }
1661 } else {
1662 switch (ssl_version) {
1663 case CURL_SSLVERSION_TLSv1_3:
1664 ssl_version |= CURL_SSLVERSION_MAX_TLSv1_3;
1665 break;
1666 case CURL_SSLVERSION_TLSv1_2:
1667 ssl_version |= CURL_SSLVERSION_MAX_TLSv1_2;
1668 break;
1669 case CURL_SSLVERSION_TLSv1_1:
1670 ssl_version |= CURL_SSLVERSION_MAX_TLSv1_1;
1671 break;
1672 case CURL_SSLVERSION_TLSv1_0:
1673 ssl_version |= CURL_SSLVERSION_MAX_TLSv1_0;
1674 break;
1675 }
1676 }
1677#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */
1678 if (verbose >= 2)
1679 printf(_("* Set SSL/TLS version to %d\n"), ssl_version);
1680 if (!specify_port)
1681 server_port = HTTPS_PORT;
1682 break;
1683#else /* LIBCURL_FEATURE_SSL */
1684 /* -C -J and -K fall through to here without SSL */
1685 usage4 (_("Invalid option - SSL is not available"));
1686 break;
1687 case SNI_OPTION: /* --sni is parsed, but ignored, the default is true with libcurl */
1688 use_sni = true;
1689 break;
1690#endif /* LIBCURL_FEATURE_SSL */
1691 case MAX_REDIRS_OPTION:
1692 if (!is_intnonneg (optarg))
1693 usage2 (_("Invalid max_redirs count"), optarg);
1694 else {
1695 max_depth = atoi (optarg);
1696 }
1697 break;
1698 case 'f': /* onredirect */
1699 if (!strcmp (optarg, "ok"))
1700 onredirect = STATE_OK;
1701 else if (!strcmp (optarg, "warning"))
1702 onredirect = STATE_WARNING;
1703 else if (!strcmp (optarg, "critical"))
1704 onredirect = STATE_CRITICAL;
1705 else if (!strcmp (optarg, "unknown"))
1706 onredirect = STATE_UNKNOWN;
1707 else if (!strcmp (optarg, "follow"))
1708 onredirect = STATE_DEPENDENT;
1709 else if (!strcmp (optarg, "stickyport"))
1710 onredirect = STATE_DEPENDENT, followmethod = FOLLOW_HTTP_CURL, followsticky = STICKY_HOST|STICKY_PORT;
1711 else if (!strcmp (optarg, "sticky"))
1712 onredirect = STATE_DEPENDENT, followmethod = FOLLOW_HTTP_CURL, followsticky = STICKY_HOST;
1713 else if (!strcmp (optarg, "follow"))
1714 onredirect = STATE_DEPENDENT, followmethod = FOLLOW_HTTP_CURL, followsticky = STICKY_NONE;
1715 else if (!strcmp (optarg, "curl"))
1716 onredirect = STATE_DEPENDENT, followmethod = FOLLOW_LIBCURL;
1717 else usage2 (_("Invalid onredirect option"), optarg);
1718 if (verbose >= 2)
1719 printf(_("* Following redirects set to %s\n"), state_text(onredirect));
1720 break;
1721 case 'd': /* string or substring */
1722 strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1);
1723 header_expect[MAX_INPUT_BUFFER - 1] = 0;
1724 break;
1725 case 's': /* string or substring */
1726 strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1);
1727 string_expect[MAX_INPUT_BUFFER - 1] = 0;
1728 break;
1729 case 'e': /* string or substring */
1730 strncpy (server_expect, optarg, MAX_INPUT_BUFFER - 1);
1731 server_expect[MAX_INPUT_BUFFER - 1] = 0;
1732 server_expect_yn = 1;
1733 break;
1734 case 'T': /* Content-type */
1735 http_content_type = strdup (optarg);
1736 break;
1737 case 'l': /* linespan */
1738 cflags &= ~REG_NEWLINE;
1739 break;
1740 case 'R': /* regex */
1741 cflags |= REG_ICASE;
1742 // fall through
1743 case 'r': /* regex */
1744 strncpy (regexp, optarg, MAX_RE_SIZE - 1);
1745 regexp[MAX_RE_SIZE - 1] = 0;
1746 errcode = regcomp (&preg, regexp, cflags);
1747 if (errcode != 0) {
1748 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
1749 printf (_("Could Not Compile Regular Expression: %s"), errbuf);
1750 return false;
1751 }
1752 break;
1753 case INVERT_REGEX:
1754 invert_regex = true;
1755 break;
1756 case '4':
1757 address_family = AF_INET;
1758 break;
1759 case '6':
1760#if defined (USE_IPV6) && defined (LIBCURL_FEATURE_IPV6)
1761 address_family = AF_INET6;
1762#else
1763 usage4 (_("IPv6 support not available"));
1764#endif
1765 break;
1766 case 'm': /* min_page_length */
1767 {
1768 char *tmp;
1769 if (strchr(optarg, ':') != (char *)NULL) {
1770 /* range, so get two values, min:max */
1771 tmp = strtok(optarg, ":");
1772 if (tmp == NULL) {
1773 printf("Bad format: try \"-m min:max\"\n");
1774 exit (STATE_WARNING);
1775 } else
1776 min_page_len = atoi(tmp);
1777
1778 tmp = strtok(NULL, ":");
1779 if (tmp == NULL) {
1780 printf("Bad format: try \"-m min:max\"\n");
1781 exit (STATE_WARNING);
1782 } else
1783 max_page_len = atoi(tmp);
1784 } else
1785 min_page_len = atoi (optarg);
1786 break;
1787 }
1788 case 'N': /* no-body */
1789 no_body = true;
1790 break;
1791 case 'M': /* max-age */
1792 {
1793 int L = strlen(optarg);
1794 if (L && optarg[L-1] == 'm')
1795 maximum_age = atoi (optarg) * 60;
1796 else if (L && optarg[L-1] == 'h')
1797 maximum_age = atoi (optarg) * 60 * 60;
1798 else if (L && optarg[L-1] == 'd')
1799 maximum_age = atoi (optarg) * 60 * 60 * 24;
1800 else if (L && (optarg[L-1] == 's' ||
1801 isdigit (optarg[L-1])))
1802 maximum_age = atoi (optarg);
1803 else {
1804 fprintf (stderr, "unparsable max-age: %s\n", optarg);
1805 exit (STATE_WARNING);
1806 }
1807 if (verbose >= 2)
1808 printf ("* Maximal age of document set to %d seconds\n", maximum_age);
1809 }
1810 break;
1811 case 'E': /* show extended perfdata */
1812 show_extended_perfdata = true;
1813 break;
1814 case 'B': /* print body content after status line */
1815 show_body = true;
1816 break;
1817 case HTTP_VERSION_OPTION:
1818 curl_http_version = CURL_HTTP_VERSION_NONE;
1819 if (strcmp (optarg, "1.0") == 0) {
1820 curl_http_version = CURL_HTTP_VERSION_1_0;
1821 } else if (strcmp (optarg, "1.1") == 0) {
1822 curl_http_version = CURL_HTTP_VERSION_1_1;
1823 } else if ((strcmp (optarg, "2.0") == 0) || (strcmp (optarg, "2") == 0)) {
1824#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0)
1825 curl_http_version = CURL_HTTP_VERSION_2_0;
1826#else
1827 curl_http_version = CURL_HTTP_VERSION_NONE;
1828#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) */
1829 } else {
1830 fprintf (stderr, "unknown http-version parameter: %s\n", optarg);
1831 exit (STATE_WARNING);
1832 }
1833 break;
1834 case AUTOMATIC_DECOMPRESSION:
1835 automatic_decompression = true;
1836 break;
1837 case COOKIE_JAR:
1838 cookie_jar_file = optarg;
1839 break;
1840 case '?':
1841 /* print short usage statement if args not parsable */
1842 usage5 ();
1843 break;
1844 }
1845 }
1846
1847 c = optind;
1848
1849 if (server_address == NULL && c < argc)
1850 server_address = strdup (argv[c++]);
1851
1852 if (host_name == NULL && c < argc)
1853 host_name = strdup (argv[c++]);
1854
1855 if (server_address == NULL) {
1856 if (host_name == NULL)
1857 usage4 (_("You must specify a server address or host name"));
1858 else
1859 server_address = strdup (host_name);
1860 }
1861
1862 set_thresholds(&thlds, warning_thresholds, critical_thresholds);
1863
1864 if (critical_thresholds && thlds->critical->end>(double)socket_timeout)
1865 socket_timeout = (int)thlds->critical->end + 1;
1866 if (verbose >= 2)
1867 printf ("* Socket timeout set to %ld seconds\n", socket_timeout);
1868
1869 if (http_method == NULL)
1870 http_method = strdup ("GET");
1871
1872 if (client_cert && !client_privkey)
1873 usage4 (_("If you use a client certificate you must also specify a private key file"));
1874
1875 if (virtual_port == 0)
1876 virtual_port = server_port;
1877 else {
1878 if ((use_ssl && server_port == HTTPS_PORT) || (!use_ssl && server_port == HTTP_PORT))
1879 if(!specify_port)
1880 server_port = virtual_port;
1881 }
1882
1883 return true;
1884}
1885
1886char *perfd_time (double elapsed_time)
1887{
1888 return fperfdata ("time", elapsed_time, "s",
1889 thlds->warning?true:false, thlds->warning?thlds->warning->end:0,
1890 thlds->critical?true:false, thlds->critical?thlds->critical->end:0,
1891 true, 0, true, socket_timeout);
1892}
1893
1894char *perfd_time_connect (double elapsed_time_connect)
1895{
1896 return fperfdata ("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1897}
1898
1899char *perfd_time_ssl (double elapsed_time_ssl)
1900{
1901 return fperfdata ("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1902}
1903
1904char *perfd_time_headers (double elapsed_time_headers)
1905{
1906 return fperfdata ("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1907}
1908
1909char *perfd_time_firstbyte (double elapsed_time_firstbyte)
1910{
1911 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1912}
1913
1914char *perfd_time_transfer (double elapsed_time_transfer)
1915{
1916 return fperfdata ("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1917}
1918
1919char *perfd_size (int page_len)
1920{
1921 return perfdata ("size", page_len, "B",
1922 (min_page_len>0?true:false), min_page_len,
1923 (min_page_len>0?true:false), 0,
1924 true, 0, false, 0);
1925}
1926
1927void
1928print_help (void)
1929{
1930 print_revision (progname, NP_VERSION);
1931
1932 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
1933 printf (COPYRIGHT, copyright, email);
1934
1935 printf ("%s\n", _("This plugin tests the HTTP service on the specified host. It can test"));
1936 printf ("%s\n", _("normal (http) and secure (https) servers, follow redirects, search for"));
1937 printf ("%s\n", _("strings and regular expressions, check connection times, and report on"));
1938 printf ("%s\n", _("certificate expiration times."));
1939 printf ("\n");
1940 printf ("%s\n", _("It makes use of libcurl to do so. It tries to be as compatible to check_http"));
1941 printf ("%s\n", _("as possible."));
1942
1943 printf ("\n\n");
1944
1945 print_usage ();
1946
1947 printf (_("NOTE: One or both of -H and -I must be specified"));
1948
1949 printf ("\n");
1950
1951 printf (UT_HELP_VRSN);
1952 printf (UT_EXTRA_OPTS);
1953
1954 printf (" %s\n", "-H, --hostname=ADDRESS");
1955 printf (" %s\n", _("Host name argument for servers using host headers (virtual host)"));
1956 printf (" %s\n", _("Append a port to include it in the header (eg: example.com:5000)"));
1957 printf (" %s\n", "-I, --IP-address=ADDRESS");
1958 printf (" %s\n", _("IP address or name (use numeric address if possible to bypass DNS lookup)."));
1959 printf (" %s\n", "-p, --port=INTEGER");
1960 printf (" %s", _("Port number (default: "));
1961 printf ("%d)\n", HTTP_PORT);
1962
1963 printf (UT_IPv46);
1964
1965#ifdef LIBCURL_FEATURE_SSL
1966 printf (" %s\n", "-S, --ssl=VERSION[+]");
1967 printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"));
1968 printf (" %s\n", _("auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"));
1969 printf (" %s\n", _("1.2 = TLSv1.2, 1.3 = TLSv1.3). With a '+' suffix, newer versions are also accepted."));
1970 printf (" %s\n", _("Note: SSLv2 and SSLv3 are deprecated and are usually disabled in libcurl"));
1971 printf (" %s\n", "--sni");
1972 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
1973#if LIBCURL_VERSION_NUM >= 0x071801
1974 printf (" %s\n", _("Note: --sni is the default in libcurl as SSLv2 and SSLV3 are deprecated and"));
1975 printf (" %s\n", _(" SNI only really works since TLSv1.0"));
1976#else
1977 printf (" %s\n", _("Note: SNI is not supported in libcurl before 7.18.1"));
1978#endif
1979 printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
1980 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
1981 printf (" %s\n", _("(when this option is used the URL is not checked by default. You can use"));
1982 printf (" %s\n", _(" --continue-after-certificate to override this behavior)"));
1983 printf (" %s\n", "--continue-after-certificate");
1984 printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check."));
1985 printf (" %s\n", _("Does nothing unless -C is used."));
1986 printf (" %s\n", "-J, --client-cert=FILE");
1987 printf (" %s\n", _("Name of file that contains the client certificate (PEM format)"));
1988 printf (" %s\n", _("to be used in establishing the SSL session"));
1989 printf (" %s\n", "-K, --private-key=FILE");
1990 printf (" %s\n", _("Name of file containing the private key (PEM format)"));
1991 printf (" %s\n", _("matching the client certificate"));
1992 printf (" %s\n", "--ca-cert=FILE");
1993 printf (" %s\n", _("CA certificate file to verify peer against"));
1994 printf (" %s\n", "-D, --verify-cert");
1995 printf (" %s\n", _("Verify the peer's SSL certificate and hostname"));
1996#endif
1997
1998 printf (" %s\n", "-e, --expect=STRING");
1999 printf (" %s\n", _("Comma-delimited list of strings, at least one of them is expected in"));
2000 printf (" %s", _("the first (status) line of the server response (default: "));
2001 printf ("%s)\n", HTTP_EXPECT);
2002 printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"));
2003 printf (" %s\n", "-d, --header-string=STRING");
2004 printf (" %s\n", _("String to expect in the response headers"));
2005 printf (" %s\n", "-s, --string=STRING");
2006 printf (" %s\n", _("String to expect in the content"));
2007 printf (" %s\n", "-u, --url=PATH");
2008 printf (" %s\n", _("URL to GET or POST (default: /)"));
2009 printf (" %s\n", "-P, --post=STRING");
2010 printf (" %s\n", _("URL encoded http POST data"));
2011 printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)");
2012 printf (" %s\n", _("Set HTTP method."));
2013 printf (" %s\n", "-N, --no-body");
2014 printf (" %s\n", _("Don't wait for document body: stop reading after headers."));
2015 printf (" %s\n", _("(Note that this still does an HTTP GET or POST, not a HEAD.)"));
2016 printf (" %s\n", "-M, --max-age=SECONDS");
2017 printf (" %s\n", _("Warn if document is more than SECONDS old. the number can also be of"));
2018 printf (" %s\n", _("the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."));
2019 printf (" %s\n", "-T, --content-type=STRING");
2020 printf (" %s\n", _("specify Content-Type header media type when POSTing\n"));
2021 printf (" %s\n", "-l, --linespan");
2022 printf (" %s\n", _("Allow regex to span newlines (must precede -r or -R)"));
2023 printf (" %s\n", "-r, --regex, --ereg=STRING");
2024 printf (" %s\n", _("Search page for regex STRING"));
2025 printf (" %s\n", "-R, --eregi=STRING");
2026 printf (" %s\n", _("Search page for case-insensitive regex STRING"));
2027 printf (" %s\n", "--invert-regex");
2028 printf (" %s\n", _("Return CRITICAL if found, OK if not\n"));
2029 printf (" %s\n", "-a, --authorization=AUTH_PAIR");
2030 printf (" %s\n", _("Username:password on sites with basic authentication"));
2031 printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");
2032 printf (" %s\n", _("Username:password on proxy-servers with basic authentication"));
2033 printf (" %s\n", "-A, --useragent=STRING");
2034 printf (" %s\n", _("String to be sent in http header as \"User Agent\""));
2035 printf (" %s\n", "-k, --header=STRING");
2036 printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers"));
2037 printf (" %s\n", "-E, --extended-perfdata");
2038 printf (" %s\n", _("Print additional performance data"));
2039 printf (" %s\n", "-B, --show-body");
2040 printf (" %s\n", _("Print body content below status line"));
2041 printf (" %s\n", "-L, --link");
2042 printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)"));
2043 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport|curl>");
2044 printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the"));
2045 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same."));
2046 printf (" %s\n", _("follow uses the old redirection algorithm of check_http."));
2047 printf (" %s\n", _("curl uses CURL_FOLLOWLOCATION built into libcurl."));
2048 printf (" %s\n", "--max-redirs=INTEGER");
2049 printf (" %s", _("Maximal number of redirects (default: "));
2050 printf ("%d)\n", DEFAULT_MAX_REDIRS);
2051 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>");
2052 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));
2053 printf ("\n");
2054 printf (" %s\n", "--http-version=VERSION");
2055 printf (" %s\n", _("Connect via specific HTTP protocol."));
2056 printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)"));
2057 printf (" %s\n", "--enable-automatic-decompression");
2058 printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING)."));
2059 printf (" %s\n", "---cookie-jar=FILE");
2060 printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested."));
2061 printf ("\n");
2062
2063 printf (UT_WARN_CRIT);
2064
2065 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
2066
2067 printf (UT_VERBOSE);
2068
2069 printf ("\n");
2070 printf ("%s\n", _("Notes:"));
2071 printf (" %s\n", _("This plugin will attempt to open an HTTP connection with the host."));
2072 printf (" %s\n", _("Successful connects return STATE_OK, refusals and timeouts return STATE_CRITICAL"));
2073 printf (" %s\n", _("other errors return STATE_UNKNOWN. Successful connects, but incorrect response"));
2074 printf (" %s\n", _("messages from the host result in STATE_WARNING return values. If you are"));
2075 printf (" %s\n", _("checking a virtual server that uses 'host headers' you must supply the FQDN"));
2076 printf (" %s\n", _("(fully qualified domain name) as the [host_name] argument."));
2077
2078#ifdef LIBCURL_FEATURE_SSL
2079 printf ("\n");
2080 printf (" %s\n", _("This plugin can also check whether an SSL enabled web server is able to"));
2081 printf (" %s\n", _("serve content (optionally within a specified time) or whether the X509 "));
2082 printf (" %s\n", _("certificate is still valid for the specified number of days."));
2083 printf ("\n");
2084 printf (" %s\n", _("Please note that this plugin does not check if the presented server"));
2085 printf (" %s\n", _("certificate matches the hostname of the server, or if the certificate"));
2086 printf (" %s\n", _("has a valid chain of trust to one of the locally installed CAs."));
2087 printf ("\n");
2088 printf ("%s\n", _("Examples:"));
2089 printf (" %s\n\n", "CHECK CONTENT: check_curl -w 5 -c 10 --ssl -H www.verisign.com");
2090 printf (" %s\n", _("When the 'www.verisign.com' server returns its content within 5 seconds,"));
2091 printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds"));
2092 printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,"));
2093 printf (" %s\n", _("a STATE_CRITICAL will be returned."));
2094 printf ("\n");
2095 printf (" %s\n\n", "CHECK CERTIFICATE: check_curl -H www.verisign.com -C 14");
2096 printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 14 days,"));
2097 printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than"));
2098 printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"));
2099 printf (" %s\n\n", _("the certificate is expired."));
2100 printf ("\n");
2101 printf (" %s\n\n", "CHECK CERTIFICATE: check_curl -H www.verisign.com -C 30,14");
2102 printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 30 days,"));
2103 printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than"));
2104 printf (" %s\n", _("30 days, but more than 14 days, a STATE_WARNING is returned."));
2105 printf (" %s\n", _("A STATE_CRITICAL will be returned when certificate expires in less than 14 days"));
2106#endif
2107
2108 printf ("\n %s\n", "CHECK WEBSERVER CONTENT VIA PROXY:");
2109 printf (" %s\n", _("It is recommended to use an environment proxy like:"));
2110 printf (" %s\n", _("http_proxy=http://192.168.100.35:3128 ./check_curl -H www.monitoring-plugins.org"));
2111 printf (" %s\n", _("legacy proxy requests in check_http style still work:"));
2112 printf (" %s\n", _("check_curl -I 192.168.100.35 -p 3128 -u http://www.monitoring-plugins.org/ -H www.monitoring-plugins.org"));
2113
2114#ifdef LIBCURL_FEATURE_SSL
2115 printf ("\n %s\n", "CHECK SSL WEBSERVER CONTENT VIA PROXY USING HTTP 1.1 CONNECT: ");
2116 printf (" %s\n", _("It is recommended to use an environment proxy like:"));
2117 printf (" %s\n", _("https_proxy=http://192.168.100.35:3128 ./check_curl -H www.verisign.com -S"));
2118 printf (" %s\n", _("legacy proxy requests in check_http style still work:"));
2119 printf (" %s\n", _("check_curl -I 192.168.100.35 -p 3128 -u https://www.verisign.com/ -S -j CONNECT -H www.verisign.com "));
2120 printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>"));
2121 printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds"));
2122 printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,"));
2123 printf (" %s\n", _("a STATE_CRITICAL will be returned."));
2124
2125#endif
2126
2127 printf (UT_SUPPORT);
2128
2129}
2130
2131
2132
2133void
2134print_usage (void)
2135{
2136 printf ("%s\n", _("Usage:"));
2137 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
2138 printf (" [-J <client certificate file>] [-K <private key>] [--ca-cert <CA certificate file>] [-D]\n");
2139 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n");
2140 printf (" [-b proxy_auth] [-f <ok|warning|critical|follow|sticky|stickyport|curl>]\n");
2141 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
2142 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
2143 printf (" [-A string] [-k string] [-S <version>] [--sni]\n");
2144 printf (" [-T <content-type>] [-j method]\n");
2145 printf (" [--http-version=<version>] [--enable-automatic-decompression]\n");
2146 printf (" [--cookie-jar=<cookie jar file>\n");
2147 printf (" %s -H <vhost> | -I <IP-address> -C <warn_age>[,<crit_age>]\n",progname);
2148 printf (" [-p <port>] [-t <timeout>] [-4|-6] [--sni]\n");
2149 printf ("\n");
2150#ifdef LIBCURL_FEATURE_SSL
2151 printf ("%s\n", _("In the first form, make an HTTP request."));
2152 printf ("%s\n\n", _("In the second form, connect to the server and check the TLS certificate."));
2153#endif
2154 printf ("%s\n", _("WARNING: check_curl is experimental. Please use"));
2155 printf ("%s\n\n", _("check_http if you need a stable version."));
2156}
2157
2158void
2159print_curl_version (void)
2160{
2161 printf( "%s\n", curl_version());
2162}
2163
2164int
2165curlhelp_initwritebuffer (curlhelp_write_curlbuf *buf)
2166{
2167 buf->bufsize = DEFAULT_BUFFER_SIZE;
2168 buf->buflen = 0;
2169 buf->buf = (char *)malloc ((size_t)buf->bufsize);
2170 if (buf->buf == NULL) return -1;
2171 return 0;
2172}
2173
2174int
2175curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *stream)
2176{
2177 curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream;
2178
2179 while (buf->bufsize < buf->buflen + size * nmemb + 1) {
2180 buf->bufsize = buf->bufsize * 2;
2181 buf->buf = (char *)realloc (buf->buf, buf->bufsize);
2182 if (buf->buf == NULL) {
2183 fprintf(stderr, "malloc failed (%d) %s\n", errno, strerror(errno));
2184 return -1;
2185 }
2186 }
2187
2188 memcpy (buf->buf + buf->buflen, buffer, size * nmemb);
2189 buf->buflen += size * nmemb;
2190 buf->buf[buf->buflen] = '\0';
2191
2192 return (int)(size * nmemb);
2193}
2194
2195int
2196curlhelp_buffer_read_callback (void *buffer, size_t size, size_t nmemb, void *stream)
2197{
2198 curlhelp_read_curlbuf *buf = (curlhelp_read_curlbuf *)stream;
2199
2200 size_t n = min (nmemb * size, buf->buflen - buf->pos);
2201
2202 memcpy (buffer, buf->buf + buf->pos, n);
2203 buf->pos += n;
2204
2205 return (int)n;
2206}
2207
2208void
2209curlhelp_freewritebuffer (curlhelp_write_curlbuf *buf)
2210{
2211 free (buf->buf);
2212 buf->buf = NULL;
2213}
2214
2215int
2216curlhelp_initreadbuffer (curlhelp_read_curlbuf *buf, const char *data, size_t datalen)
2217{
2218 buf->buflen = datalen;
2219 buf->buf = (char *)malloc ((size_t)buf->buflen);
2220 if (buf->buf == NULL) return -1;
2221 memcpy (buf->buf, data, datalen);
2222 buf->pos = 0;
2223 return 0;
2224}
2225
2226void
2227curlhelp_freereadbuffer (curlhelp_read_curlbuf *buf)
2228{
2229 free (buf->buf);
2230 buf->buf = NULL;
2231}
2232
2233/* TODO: where to put this, it's actually part of sstrings2 (logically)?
2234 */
2235const char*
2236strrstr2(const char *haystack, const char *needle)
2237{
2238 int counter;
2239 size_t len;
2240 const char *prev_pos;
2241 const char *pos;
2242
2243 if (haystack == NULL || needle == NULL)
2244 return NULL;
2245
2246 if (haystack[0] == '\0' || needle[0] == '\0')
2247 return NULL;
2248
2249 counter = 0;
2250 prev_pos = NULL;
2251 pos = haystack;
2252 len = strlen (needle);
2253 for (;;) {
2254 pos = strstr (pos, needle);
2255 if (pos == NULL) {
2256 if (counter == 0)
2257 return NULL;
2258 else
2259 return prev_pos;
2260 }
2261 counter++;
2262 prev_pos = pos;
2263 pos += len;
2264 if (*pos == '\0') return prev_pos;
2265 }
2266}
2267
2268int
2269curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line)
2270{
2271 char *first_line_end;
2272 char *p;
2273 size_t first_line_len;
2274 char *pp;
2275 const char *start;
2276 char *first_line_buf;
2277
2278 /* find last start of a new header */
2279 start = strrstr2 (buf, "\r\nHTTP/");
2280 if (start != NULL) {
2281 start += 2;
2282 buf = start;
2283 }
2284
2285 first_line_end = strstr(buf, "\r\n");
2286 if (first_line_end == NULL) return -1;
2287
2288 first_line_len = (size_t)(first_line_end - buf);
2289 status_line->first_line = (char *)malloc (first_line_len + 1);
2290 if (status_line->first_line == NULL) return -1;
2291 memcpy (status_line->first_line, buf, first_line_len);
2292 status_line->first_line[first_line_len] = '\0';
2293 first_line_buf = strdup( status_line->first_line );
2294
2295 /* protocol and version: "HTTP/x.x" SP or "HTTP/2" SP */
2296
2297 p = strtok(first_line_buf, "/");
2298 if( p == NULL ) { free( first_line_buf ); return -1; }
2299 if( strcmp( p, "HTTP" ) != 0 ) { free( first_line_buf ); return -1; }
2300
2301 p = strtok( NULL, " " );
2302 if( p == NULL ) { free( first_line_buf ); return -1; }
2303 if( strchr( p, '.' ) != NULL ) {
2304
2305 /* HTTP 1.x case */
2306 strtok( p, "." );
2307 status_line->http_major = (int)strtol( p, &pp, 10 );
2308 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2309 strtok( NULL, " " );
2310 status_line->http_minor = (int)strtol( p, &pp, 10 );
2311 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2312 p += 4; /* 1.x SP */
2313 } else {
2314 /* HTTP 2 case */
2315 status_line->http_major = (int)strtol( p, &pp, 10 );
2316 status_line->http_minor = 0;
2317 p += 2; /* 2 SP */
2318 }
2319
2320 /* status code: "404" or "404.1", then SP */
2321
2322 p = strtok( p, " " );
2323 if( p == NULL ) { free( first_line_buf ); return -1; }
2324 if( strchr( p, '.' ) != NULL ) {
2325 char *ppp;
2326 ppp = strtok( p, "." );
2327 status_line->http_code = (int)strtol( ppp, &pp, 10 );
2328 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2329 ppp = strtok( NULL, "" );
2330 status_line->http_subcode = (int)strtol( ppp, &pp, 10 );
2331 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2332 p += 6; /* 400.1 SP */
2333 } else {
2334 status_line->http_code = (int)strtol( p, &pp, 10 );
2335 status_line->http_subcode = -1;
2336 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2337 p += 4; /* 400 SP */
2338 }
2339
2340 /* Human readable message: "Not Found" CRLF */
2341
2342 p = strtok( p, "" );
2343 if( p == NULL ) { status_line->msg = ""; return 0; }
2344 status_line->msg = status_line->first_line + ( p - first_line_buf );
2345 free( first_line_buf );
2346
2347 return 0;
2348}
2349
2350void
2351curlhelp_free_statusline (curlhelp_statusline *status_line)
2352{
2353 free (status_line->first_line);
2354}
2355
2356void
2357remove_newlines (char *s)
2358{
2359 char *p;
2360
2361 for (p = s; *p != '\0'; p++)
2362 if (*p == '\r' || *p == '\n')
2363 *p = ' ';
2364}
2365
2366char *
2367get_header_value (const struct phr_header* headers, const size_t nof_headers, const char* header)
2368{
2369 int i;
2370 for( i = 0; i < nof_headers; i++ ) {
2371 if(headers[i].name != NULL && strncasecmp( header, headers[i].name, max( headers[i].name_len, 4 ) ) == 0 ) {
2372 return strndup( headers[i].value, headers[i].value_len );
2373 }
2374 }
2375 return NULL;
2376}
2377
2378int
2379check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFAULT_BUFFER_SIZE])
2380{
2381 char *server_date = NULL;
2382 char *document_date = NULL;
2383 int date_result = STATE_OK;
2384 curlhelp_statusline status_line;
2385 struct phr_header headers[255];
2386 size_t nof_headers = 255;
2387 size_t msglen;
2388
2389 int res = phr_parse_response (header_buf->buf, header_buf->buflen,
2390 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
2391 headers, &nof_headers, 0);
2392
2393 server_date = get_header_value (headers, nof_headers, "date");
2394 document_date = get_header_value (headers, nof_headers, "last-modified");
2395
2396 if (!server_date || !*server_date) {
2397 char tmp[DEFAULT_BUFFER_SIZE];
2398
2399 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), *msg);
2400 strcpy(*msg, tmp);
2401
2402 date_result = max_state_alt(STATE_UNKNOWN, date_result);
2403
2404 } else if (!document_date || !*document_date) {
2405 char tmp[DEFAULT_BUFFER_SIZE];
2406
2407 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), *msg);
2408 strcpy(*msg, tmp);
2409
2410 date_result = max_state_alt(STATE_CRITICAL, date_result);
2411
2412 } else {
2413 time_t srv_data = curl_getdate (server_date, NULL);
2414 time_t doc_data = curl_getdate (document_date, NULL);
2415 if (verbose >= 2)
2416 printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, document_date, (int)doc_data);
2417 if (srv_data <= 0) {
2418 char tmp[DEFAULT_BUFFER_SIZE];
2419
2420 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
2421 strcpy(*msg, tmp);
2422
2423 date_result = max_state_alt(STATE_CRITICAL, date_result);
2424 } else if (doc_data <= 0) {
2425 char tmp[DEFAULT_BUFFER_SIZE];
2426
2427 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
2428 strcpy(*msg, tmp);
2429
2430 date_result = max_state_alt(STATE_CRITICAL, date_result);
2431 } else if (doc_data > srv_data + 30) {
2432 char tmp[DEFAULT_BUFFER_SIZE];
2433
2434 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
2435 strcpy(*msg, tmp);
2436
2437 date_result = max_state_alt(STATE_CRITICAL, date_result);
2438 } else if (doc_data < srv_data - maximum_age) {
2439 int n = (srv_data - doc_data);
2440 if (n > (60 * 60 * 24 * 2)) {
2441 char tmp[DEFAULT_BUFFER_SIZE];
2442
2443 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
2444 strcpy(*msg, tmp);
2445
2446 date_result = max_state_alt(STATE_CRITICAL, date_result);
2447 } else {
2448 char tmp[DEFAULT_BUFFER_SIZE];
2449
2450 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
2451 strcpy(*msg, tmp);
2452
2453 date_result = max_state_alt(STATE_CRITICAL, date_result);
2454 }
2455 }
2456 }
2457
2458 if (server_date) free (server_date);
2459 if (document_date) free (document_date);
2460
2461 return date_result;
2462}
2463
2464
2465int
2466get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_write_curlbuf* body_buf)
2467{
2468 const char *s;
2469 int content_length = 0;
2470 char *copy;
2471 struct phr_header headers[255];
2472 size_t nof_headers = 255;
2473 size_t msglen;
2474 char *content_length_s = NULL;
2475 curlhelp_statusline status_line;
2476
2477 int res = phr_parse_response (header_buf->buf, header_buf->buflen,
2478 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
2479 headers, &nof_headers, 0);
2480
2481 content_length_s = get_header_value (headers, nof_headers, "content-length");
2482 if (!content_length_s) {
2483 return header_buf->buflen + body_buf->buflen;
2484 }
2485 content_length_s += strspn (content_length_s, " \t");
2486 content_length = atoi (content_length_s);
2487 if (content_length != body_buf->buflen) {
2488 /* TODO: should we warn if the actual and the reported body length don't match? */
2489 }
2490
2491 if (content_length_s) free (content_length_s);
2492
2493 return header_buf->buflen + body_buf->buflen;
2494}
2495
2496/* TODO: is there a better way in libcurl to check for the SSL library? */
2497curlhelp_ssl_library
2498curlhelp_get_ssl_library ()
2499{
2500 curl_version_info_data* version_data;
2501 char *ssl_version;
2502 char *library;
2503 curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN;
2504
2505 version_data = curl_version_info (CURLVERSION_NOW);
2506 if (version_data == NULL) return CURLHELP_SSL_LIBRARY_UNKNOWN;
2507
2508 ssl_version = strdup (version_data->ssl_version);
2509 if (ssl_version == NULL ) return CURLHELP_SSL_LIBRARY_UNKNOWN;
2510
2511 library = strtok (ssl_version, "/");
2512 if (library == NULL) return CURLHELP_SSL_LIBRARY_UNKNOWN;
2513
2514 if (strcmp (library, "OpenSSL") == 0)
2515 ssl_library = CURLHELP_SSL_LIBRARY_OPENSSL;
2516 else if (strcmp (library, "LibreSSL") == 0)
2517 ssl_library = CURLHELP_SSL_LIBRARY_LIBRESSL;
2518 else if (strcmp (library, "GnuTLS") == 0)
2519 ssl_library = CURLHELP_SSL_LIBRARY_GNUTLS;
2520 else if (strcmp (library, "NSS") == 0)
2521 ssl_library = CURLHELP_SSL_LIBRARY_NSS;
2522
2523 if (verbose >= 2)
2524 printf ("* SSL library string is : %s %s (%d)\n", version_data->ssl_version, library, ssl_library);
2525
2526 free (ssl_version);
2527
2528 return ssl_library;
2529}
2530
2531const char*
2532curlhelp_get_ssl_library_string (curlhelp_ssl_library ssl_library)
2533{
2534 switch (ssl_library) {
2535 case CURLHELP_SSL_LIBRARY_OPENSSL:
2536 return "OpenSSL";
2537 case CURLHELP_SSL_LIBRARY_LIBRESSL:
2538 return "LibreSSL";
2539 case CURLHELP_SSL_LIBRARY_GNUTLS:
2540 return "GnuTLS";
2541 case CURLHELP_SSL_LIBRARY_NSS:
2542 return "NSS";
2543 case CURLHELP_SSL_LIBRARY_UNKNOWN:
2544 default:
2545 return "unknown";
2546 }
2547}
2548
2549#ifdef LIBCURL_FEATURE_SSL
2550#ifndef USE_OPENSSL
2551time_t
2552parse_cert_date (const char *s)
2553{
2554 struct tm tm;
2555 time_t date;
2556 char *res;
2557
2558 if (!s) return -1;
2559
2560 /* Jan 17 14:25:12 2020 GMT */
2561 res = strptime (s, "%Y-%m-%d %H:%M:%S GMT", &tm);
2562 /* Sep 11 12:00:00 2020 GMT */
2563 if (res == NULL) strptime (s, "%Y %m %d %H:%M:%S GMT", &tm);
2564 date = mktime (&tm);
2565
2566 return date;
2567}
2568
2569/* TODO: this needs cleanup in the sslutils.c, maybe we the #else case to
2570 * OpenSSL could be this function
2571 */
2572int
2573net_noopenssl_check_certificate (cert_ptr_union* cert_ptr, int days_till_exp_warn, int days_till_exp_crit)
2574{
2575 int i;
2576 struct curl_slist* slist;
2577 int cname_found = 0;
2578 char* start_date_str = NULL;
2579 char* end_date_str = NULL;
2580 time_t start_date;
2581 time_t end_date;
2582 char *tz;
2583 float time_left;
2584 int days_left;
2585 int time_remaining;
2586 char timestamp[50] = "";
2587 int status = STATE_UNKNOWN;
2588
2589 if (verbose >= 2)
2590 printf ("**** REQUEST CERTIFICATES ****\n");
2591
2592 for (i = 0; i < cert_ptr->to_certinfo->num_of_certs; i++) {
2593 for (slist = cert_ptr->to_certinfo->certinfo[i]; slist; slist = slist->next) {
2594 /* find first common name in subject,
2595 * TODO: check alternative subjects for
2596 * TODO: have a decent parser here and not a hack
2597 * multi-host certificate, check wildcards
2598 */
2599 if (strncasecmp (slist->data, "Subject:", 8) == 0) {
2600 int d = 3;
2601 char* p = strstr (slist->data, "CN=");
2602 if (p == NULL) {
2603 d = 5;
2604 p = strstr (slist->data, "CN = ");
2605 }
2606 if (p != NULL) {
2607 if (strncmp (host_name, p+d, strlen (host_name)) == 0) {
2608 cname_found = 1;
2609 }
2610 }
2611 } else if (strncasecmp (slist->data, "Start Date:", 11) == 0) {
2612 start_date_str = &slist->data[11];
2613 } else if (strncasecmp (slist->data, "Expire Date:", 12) == 0) {
2614 end_date_str = &slist->data[12];
2615 } else if (strncasecmp (slist->data, "Cert:", 5) == 0) {
2616 goto HAVE_FIRST_CERT;
2617 }
2618 if (verbose >= 2)
2619 printf ("%d ** %s\n", i, slist->data);
2620 }
2621 }
2622HAVE_FIRST_CERT:
2623
2624 if (verbose >= 2)
2625 printf ("**** REQUEST CERTIFICATES ****\n");
2626
2627 if (!cname_found) {
2628 printf("%s\n",_("CRITICAL - Cannot retrieve certificate subject."));
2629 return STATE_CRITICAL;
2630 }
2631
2632 start_date = parse_cert_date (start_date_str);
2633 if (start_date <= 0) {
2634 snprintf (msg, DEFAULT_BUFFER_SIZE, _("WARNING - Unparsable 'Start Date' in certificate: '%s'"),
2635 start_date_str);
2636 puts (msg);
2637 return STATE_WARNING;
2638 }
2639
2640 end_date = parse_cert_date (end_date_str);
2641 if (end_date <= 0) {
2642 snprintf (msg, DEFAULT_BUFFER_SIZE, _("WARNING - Unparsable 'Expire Date' in certificate: '%s'"),
2643 start_date_str);
2644 puts (msg);
2645 return STATE_WARNING;
2646 }
2647
2648 time_left = difftime (end_date, time(NULL));
2649 days_left = time_left / 86400;
2650 tz = getenv("TZ");
2651 setenv("TZ", "GMT", 1);
2652 tzset();
2653 strftime(timestamp, 50, "%c %z", localtime(&end_date));
2654 if (tz)
2655 setenv("TZ", tz, 1);
2656 else
2657 unsetenv("TZ");
2658 tzset();
2659
2660 if (days_left > 0 && days_left <= days_till_exp_warn) {
2661 printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", host_name, days_left, timestamp);
2662 if (days_left > days_till_exp_crit)
2663 status = STATE_WARNING;
2664 else
2665 status = STATE_CRITICAL;
2666 } else if (days_left == 0 && time_left > 0) {
2667 if (time_left >= 3600)
2668 time_remaining = (int) time_left / 3600;
2669 else
2670 time_remaining = (int) time_left / 60;
2671
2672 printf (_("%s - Certificate '%s' expires in %u %s (%s)\n"),
2673 (days_left>days_till_exp_crit) ? "WARNING" : "CRITICAL", host_name, time_remaining,
2674 time_left >= 3600 ? "hours" : "minutes", timestamp);
2675
2676 if ( days_left > days_till_exp_crit)
2677 status = STATE_WARNING;
2678 else
2679 status = STATE_CRITICAL;
2680 } else if (time_left < 0) {
2681 printf(_("CRITICAL - Certificate '%s' expired on %s.\n"), host_name, timestamp);
2682 status=STATE_CRITICAL;
2683 } else if (days_left == 0) {
2684 printf (_("%s - Certificate '%s' just expired (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", host_name, timestamp);
2685 if (days_left > days_till_exp_crit)
2686 status = STATE_WARNING;
2687 else
2688 status = STATE_CRITICAL;
2689 } else {
2690 printf(_("OK - Certificate '%s' will expire on %s.\n"), host_name, timestamp);
2691 status = STATE_OK;
2692 }
2693 return status;
2694}
2695#endif /* USE_OPENSSL */
2696#endif /* LIBCURL_FEATURE_SSL */
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c
index 826eb8d9..c24ca248 100644
--- a/plugins/check_dbi.c
+++ b/plugins/check_dbi.c
@@ -35,6 +35,7 @@ const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "utils.h" 37#include "utils.h"
38#include "utils_cmd.h"
38 39
39#include "netutils.h" 40#include "netutils.h"
40 41
@@ -140,21 +141,28 @@ main (int argc, char **argv)
140 if (verbose > 2) 141 if (verbose > 2)
141 printf ("Initializing DBI\n"); 142 printf ("Initializing DBI\n");
142 143
143 if (dbi_initialize (NULL) < 0) { 144 dbi_inst *instance_p;
145
146 if (dbi_initialize_r(NULL, instance_p) < 0) {
144 printf ("UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n"); 147 printf ("UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n");
145 return STATE_UNKNOWN; 148 return STATE_UNKNOWN;
146 } 149 }
147 150
151 if (instance_p == NULL) {
152 printf ("UNKNOWN - failed to initialize DBI.\n");
153 return STATE_UNKNOWN;
154 }
155
148 if (verbose) 156 if (verbose)
149 printf ("Opening DBI driver '%s'\n", np_dbi_driver); 157 printf ("Opening DBI driver '%s'\n", np_dbi_driver);
150 158
151 driver = dbi_driver_open (np_dbi_driver); 159 driver = dbi_driver_open_r(np_dbi_driver, instance_p);
152 if (! driver) { 160 if (! driver) {
153 printf ("UNKNOWN - failed to open DBI driver '%s'; possibly it's not installed.\n", 161 printf ("UNKNOWN - failed to open DBI driver '%s'; possibly it's not installed.\n",
154 np_dbi_driver); 162 np_dbi_driver);
155 163
156 printf ("Known drivers:\n"); 164 printf ("Known drivers:\n");
157 for (driver = dbi_driver_list (NULL); driver; driver = dbi_driver_list (driver)) { 165 for (driver = dbi_driver_list_r(NULL, instance_p); driver; driver = dbi_driver_list_r(driver, instance_p)) {
158 printf (" - %s\n", dbi_driver_get_name (driver)); 166 printf (" - %s\n", dbi_driver_get_name (driver));
159 } 167 }
160 return STATE_UNKNOWN; 168 return STATE_UNKNOWN;
@@ -425,6 +433,7 @@ process_arguments (int argc, char **argv)
425 else 433 else
426 timeout_interval = atoi (optarg); 434 timeout_interval = atoi (optarg);
427 435
436 break;
428 case 'H': /* host */ 437 case 'H': /* host */
429 if (!is_host (optarg)) 438 if (!is_host (optarg))
430 usage2 (_("Invalid hostname/address"), optarg); 439 usage2 (_("Invalid hostname/address"), optarg);
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 473d4b97..5d85ae26 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -48,7 +48,7 @@ void print_usage (void);
48 48
49#define UNDEFINED 0 49#define UNDEFINED 0
50#define DEFAULT_PORT 53 50#define DEFAULT_PORT 53
51#define DEFAULT_TRIES 3 51#define DEFAULT_TRIES 2
52 52
53char *query_address = NULL; 53char *query_address = NULL;
54char *record_type = "A"; 54char *record_type = "A";
@@ -94,7 +94,7 @@ main (int argc, char **argv)
94 timeout_interval_dig = timeout_interval / number_tries + number_tries; 94 timeout_interval_dig = timeout_interval / number_tries + number_tries;
95 95
96 /* get the command to run */ 96 /* get the command to run */
97 xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d", 97 xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +retry=%d +time=%d",
98 PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig); 98 PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig);
99 99
100 alarm (timeout_interval); 100 alarm (timeout_interval);
@@ -331,7 +331,7 @@ print_help (void)
331 printf ("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n"); 331 printf ("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n");
332 printf (COPYRIGHT, copyright, email); 332 printf (COPYRIGHT, copyright, email);
333 333
334 printf (_("This plugin test the DNS service on the specified host using dig")); 334 printf (_("This plugin tests the DNS service on the specified host using dig"));
335 335
336 printf ("\n\n"); 336 printf ("\n\n");
337 337
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 874a0ee0..7dc1c4b1 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1,29 +1,29 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_disk plugin 3* Monitoring check_disk plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2008 Monitoring Plugins Development Team 6* Copyright (c) 1999-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_disk plugin 10* This file contains the check_disk plugin
11* 11*
12* 12*
13* This program is free software: you can redistribute it and/or modify 13* This program is free software: you can redistribute it and/or modify
14* it under the terms of the GNU General Public License as published by 14* it under the terms of the GNU General Public License as published by
15* the Free Software Foundation, either version 3 of the License, or 15* the Free Software Foundation, either version 3 of the License, or
16* (at your option) any later version. 16* (at your option) any later version.
17* 17*
18* This program is distributed in the hope that it will be useful, 18* This program is distributed in the hope that it will be useful,
19* but WITHOUT ANY WARRANTY; without even the implied warranty of 19* but WITHOUT ANY WARRANTY; without even the implied warranty of
20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21* GNU General Public License for more details. 21* GNU General Public License for more details.
22* 22*
23* You should have received a copy of the GNU General Public License 23* You should have received a copy of the GNU General Public License
24* along with this program. If not, see <http://www.gnu.org/licenses/>. 24* along with this program. If not, see <http://www.gnu.org/licenses/>.
25* 25*
26* 26*
27*****************************************************************************/ 27*****************************************************************************/
28 28
29const char *progname = "check_disk"; 29const char *progname = "check_disk";
@@ -46,7 +46,7 @@ const char *email = "devel@monitoring-plugins.org";
46#include <stdarg.h> 46#include <stdarg.h>
47#include "fsusage.h" 47#include "fsusage.h"
48#include "mountlist.h" 48#include "mountlist.h"
49#include "intprops.h" /* necessary for TYPE_MAXIMUM */ 49#include "intprops.h" /* necessary for TYPE_MAXIMUM */
50#if HAVE_LIMITS_H 50#if HAVE_LIMITS_H
51# include <limits.h> 51# include <limits.h>
52#endif 52#endif
@@ -58,9 +58,6 @@ const char *email = "devel@monitoring-plugins.org";
58# define ERROR -1 58# define ERROR -1
59#endif 59#endif
60 60
61/* If nonzero, show inode information. */
62static int inode_format = 1;
63
64/* If nonzero, show even filesystems with zero size or 61/* If nonzero, show even filesystems with zero size or
65 uninteresting types. */ 62 uninteresting types. */
66static int show_all_fs = 1; 63static int show_all_fs = 1;
@@ -115,11 +112,12 @@ enum
115{ 112{
116 SYNC_OPTION = CHAR_MAX + 1, 113 SYNC_OPTION = CHAR_MAX + 1,
117 NO_SYNC_OPTION, 114 NO_SYNC_OPTION,
118 BLOCK_SIZE_OPTION 115 BLOCK_SIZE_OPTION,
116 IGNORE_MISSING
119}; 117};
120 118
121#ifdef _AIX 119#ifdef _AIX
122 #pragma alloca 120#pragma alloca
123#endif 121#endif
124 122
125int process_arguments (int, char **); 123int process_arguments (int, char **);
@@ -129,13 +127,10 @@ int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, ch
129void print_help (void); 127void print_help (void);
130void print_usage (void); 128void print_usage (void);
131double calculate_percent(uintmax_t, uintmax_t); 129double calculate_percent(uintmax_t, uintmax_t);
132void stat_path (struct parameter_list *p); 130bool stat_path (struct parameter_list *p);
133void get_stats (struct parameter_list *p, struct fs_usage *fsp); 131void get_stats (struct parameter_list *p, struct fs_usage *fsp);
134void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); 132void get_path_stats (struct parameter_list *p, struct fs_usage *fsp);
135 133
136double w_dfp = -1.0;
137double c_dfp = -1.0;
138char *path;
139char *exclude_device; 134char *exclude_device;
140char *units; 135char *units;
141uintmax_t mult = 1024 * 1024; 136uintmax_t mult = 1024 * 1024;
@@ -143,7 +138,9 @@ int verbose = 0;
143int erronly = FALSE; 138int erronly = FALSE;
144int display_mntp = FALSE; 139int display_mntp = FALSE;
145int exact_match = FALSE; 140int exact_match = FALSE;
141bool ignore_missing = false;
146int freespace_ignore_reserved = FALSE; 142int freespace_ignore_reserved = FALSE;
143int display_inodes_perfdata = FALSE;
147char *warn_freespace_units = NULL; 144char *warn_freespace_units = NULL;
148char *crit_freespace_units = NULL; 145char *crit_freespace_units = NULL;
149char *warn_freespace_percent = NULL; 146char *warn_freespace_percent = NULL;
@@ -157,6 +154,7 @@ char *crit_usedinodes_percent = NULL;
157char *warn_freeinodes_percent = NULL; 154char *warn_freeinodes_percent = NULL;
158char *crit_freeinodes_percent = NULL; 155char *crit_freeinodes_percent = NULL;
159int path_selected = FALSE; 156int path_selected = FALSE;
157bool path_ignored = false;
160char *group = NULL; 158char *group = NULL;
161struct stat *stat_buf; 159struct stat *stat_buf;
162struct name_list *seen = NULL; 160struct name_list *seen = NULL;
@@ -168,27 +166,28 @@ main (int argc, char **argv)
168 int result = STATE_UNKNOWN; 166 int result = STATE_UNKNOWN;
169 int disk_result = STATE_UNKNOWN; 167 int disk_result = STATE_UNKNOWN;
170 char *output; 168 char *output;
169 char *ignored;
171 char *details; 170 char *details;
172 char *perf; 171 char *perf;
173 char *preamble; 172 char *perf_ilabel;
173 char *preamble = " - free space:";
174 char *ignored_preamble = " - ignored paths:";
174 char *flag_header; 175 char *flag_header;
175 double inode_space_pct;
176 double warning_high_tide;
177 double critical_high_tide;
178 int temp_result; 176 int temp_result;
179 177
180 struct mount_entry *me; 178 struct mount_entry *me;
181 struct fs_usage fsp, tmpfsp; 179 struct fs_usage fsp;
182 struct parameter_list *temp_list, *path; 180 struct parameter_list *temp_list, *path;
183 181
184#ifdef __CYGWIN__ 182#ifdef __CYGWIN__
185 char mountdir[32]; 183 char mountdir[32];
186#endif 184#endif
187 185
188 preamble = strdup (" - free space:");
189 output = strdup (""); 186 output = strdup ("");
187 ignored = strdup ("");
190 details = strdup (""); 188 details = strdup ("");
191 perf = strdup (""); 189 perf = strdup ("");
190 perf_ilabel = strdup ("");
192 stat_buf = malloc(sizeof *stat_buf); 191 stat_buf = malloc(sizeof *stat_buf);
193 192
194 setlocale (LC_ALL, ""); 193 setlocale (LC_ALL, "");
@@ -206,7 +205,7 @@ main (int argc, char **argv)
206 /* If a list of paths has not been selected, find entire 205 /* If a list of paths has not been selected, find entire
207 mount list and create list of paths 206 mount list and create list of paths
208 */ 207 */
209 if (path_selected == FALSE) { 208 if (path_selected == FALSE && path_ignored == false) {
210 for (me = mount_list; me; me = me->me_next) { 209 for (me = mount_list; me; me = me->me_next) {
211 if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) { 210 if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) {
212 path = np_add_parameter(&path_select_list, me->me_mountdir); 211 path = np_add_parameter(&path_select_list, me->me_mountdir);
@@ -216,24 +215,49 @@ main (int argc, char **argv)
216 set_all_thresholds(path); 215 set_all_thresholds(path);
217 } 216 }
218 } 217 }
219 np_set_best_match(path_select_list, mount_list, exact_match); 218
219 if (path_ignored == false) {
220 np_set_best_match(path_select_list, mount_list, exact_match);
221 }
220 222
221 /* Error if no match found for specified paths */ 223 /* Error if no match found for specified paths */
222 temp_list = path_select_list; 224 temp_list = path_select_list;
223 225
224 while (temp_list) { 226 while (path_select_list) {
225 if (! temp_list->best_match) { 227 if (! path_select_list->best_match && ignore_missing == true) {
226 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); 228 /* If the first element will be deleted, the temp_list must be updated with the new start address as well */
229 if (path_select_list == temp_list) {
230 temp_list = path_select_list->name_next;
231 }
232 /* Add path argument to list of ignored paths to inform about missing paths being ignored and not alerted */
233 xasprintf (&ignored, "%s %s;", ignored, path_select_list->name);
234 /* Delete the path from the list so that it is not stat-checked later in the code. */
235 path_select_list = np_del_parameter(path_select_list, path_select_list->name_prev);
236 } else if (! path_select_list->best_match) {
237 /* Without --ignore-missing option, exit with Critical state. */
238 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), path_select_list->name);
239 } else {
240 /* Continue jumping through the list */
241 path_select_list = path_select_list->name_next;
227 } 242 }
243 }
244
245 path_select_list = temp_list;
228 246
229 temp_list = temp_list->name_next; 247 if (! path_select_list && ignore_missing == true) {
248 result = STATE_OK;
249 if (verbose >= 2) {
250 printf ("None of the provided paths were found\n");
251 }
230 } 252 }
231 253
232 /* Process for every path in list */ 254 /* Process for every path in list */
233 for (path = path_select_list; path; path=path->name_next) { 255 for (path = path_select_list; path; path=path->name_next) {
234 if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) 256 if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL)
235 printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end, 257 printf("Thresholds(pct) for %s warn: %f crit %f\n",
236 path->freespace_percent->critical->end); 258 path->name,
259 path->freespace_percent->warning->end,
260 path->freespace_percent->critical->end);
237 261
238 if (verbose >= 3 && path->group != NULL) 262 if (verbose >= 3 && path->group != NULL)
239 printf("Group of %s: %s\n",path->name,path->group); 263 printf("Group of %s: %s\n",path->name,path->group);
@@ -243,26 +267,34 @@ main (int argc, char **argv)
243 267
244 me = path->best_match; 268 me = path->best_match;
245 269
270 if (!me) {
271 continue;
272 }
273
246#ifdef __CYGWIN__ 274#ifdef __CYGWIN__
247 if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11) 275 if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11)
248 continue; 276 continue;
249 snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10); 277 snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10);
250 if (GetDriveType(mountdir) != DRIVE_FIXED) 278 if (GetDriveType(mountdir) != DRIVE_FIXED)
251 me->me_remote = 1; 279 me->me_remote = 1;
252#endif 280#endif
253 /* Filters */ 281 /* Filters */
254 282
255 /* Remove filesystems already seen */ 283 /* Remove filesystems already seen */
256 if (np_seen_name(seen, me->me_mountdir)) { 284 if (np_seen_name(seen, me->me_mountdir)) {
257 continue; 285 continue;
258 } 286 }
259 np_add_name(&seen, me->me_mountdir); 287 np_add_name(&seen, me->me_mountdir);
260 288
261 if (path->group == NULL) { 289 if (path->group == NULL) {
262 /* Skip remote filesystems if we're not interested in them */ 290 /* Skip remote filesystems if we're not interested in them */
263 if (me->me_remote && show_local_fs) { 291 if (me->me_remote && show_local_fs) {
264 if (stat_remote_fs) 292 if (stat_remote_fs) {
265 stat_path(path); 293 if (!stat_path(path) && ignore_missing == true) {
294 result = STATE_OK;
295 xasprintf (&ignored, "%s %s;", ignored, path->name);
296 }
297 }
266 continue; 298 continue;
267 /* Skip pseudo fs's if we haven't asked for all fs's */ 299 /* Skip pseudo fs's if we haven't asked for all fs's */
268 } else if (me->me_dummy && !show_all_fs) { 300 } else if (me->me_dummy && !show_all_fs) {
@@ -281,15 +313,30 @@ main (int argc, char **argv)
281 } 313 }
282 } 314 }
283 315
284 stat_path(path); 316 if (!stat_path(path)) {
317 if (ignore_missing == true) {
318 result = STATE_OK;
319 xasprintf (&ignored, "%s %s;", ignored, path->name);
320 }
321 continue;
322 }
285 get_fs_usage (me->me_mountdir, me->me_devname, &fsp); 323 get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
286 324
287 if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) { 325 if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) {
288 get_stats (path, &fsp); 326 get_stats (path, &fsp);
289 327
290 if (verbose >= 3) { 328 if (verbose >= 3) {
291 printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n", 329 printf ("For %s, used_pct=%g free_pct=%g used_units=%lu free_units=%lu total_units=%lu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%lu\n",
292 me->me_mountdir, path->dused_pct, path->dfree_pct, path->dused_units, path->dfree_units, path->dtotal_units, path->dused_inodes_percent, path->dfree_inodes_percent, fsp.fsu_blocksize, mult); 330 me->me_mountdir,
331 path->dused_pct,
332 path->dfree_pct,
333 path->dused_units,
334 path->dfree_units,
335 path->dtotal_units,
336 path->dused_inodes_percent,
337 path->dfree_inodes_percent,
338 fsp.fsu_blocksize,
339 mult);
293 } 340 }
294 341
295 /* Threshold comparisons */ 342 /* Threshold comparisons */
@@ -326,68 +373,89 @@ main (int argc, char **argv)
326 */ 373 */
327 374
328 /* *_high_tide must be reinitialized at each run */ 375 /* *_high_tide must be reinitialized at each run */
329 warning_high_tide = UINT_MAX; 376 uint64_t warning_high_tide = UINT64_MAX;
330 critical_high_tide = UINT_MAX;
331 377
332 if (path->freespace_units->warning != NULL) { 378 if (path->freespace_units->warning != NULL) {
333 warning_high_tide = path->dtotal_units - path->freespace_units->warning->end; 379 warning_high_tide = (path->dtotal_units - path->freespace_units->warning->end) * mult;
334 } 380 }
335 if (path->freespace_percent->warning != NULL) { 381 if (path->freespace_percent->warning != NULL) {
336 warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*path->dtotal_units )); 382 warning_high_tide = min( warning_high_tide, (uint64_t)((1.0 - path->freespace_percent->warning->end/100) * (path->dtotal_units * mult)) );
337 } 383 }
384
385 uint64_t critical_high_tide = UINT64_MAX;
386
338 if (path->freespace_units->critical != NULL) { 387 if (path->freespace_units->critical != NULL) {
339 critical_high_tide = path->dtotal_units - path->freespace_units->critical->end; 388 critical_high_tide = (path->dtotal_units - path->freespace_units->critical->end) * mult;
340 } 389 }
341 if (path->freespace_percent->critical != NULL) { 390 if (path->freespace_percent->critical != NULL) {
342 critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*path->dtotal_units )); 391 critical_high_tide = min( critical_high_tide, (uint64_t)((1.0 - path->freespace_percent->critical->end/100) * (path->dtotal_units * mult)) );
343 } 392 }
344 393
345 /* Nb: *_high_tide are unset when == UINT_MAX */ 394 /* Nb: *_high_tide are unset when == UINT64_MAX */
346 xasprintf (&perf, "%s %s", perf, 395 xasprintf (&perf, "%s %s", perf,
347 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 396 perfdata_uint64 (
348 path->dused_units, units, 397 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
349 (warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide, 398 path->dused_units * mult, "B",
350 (critical_high_tide != UINT_MAX ? TRUE : FALSE), critical_high_tide, 399 (warning_high_tide == UINT64_MAX ? FALSE : TRUE), warning_high_tide,
351 TRUE, 0, 400 (critical_high_tide == UINT64_MAX ? FALSE : TRUE), critical_high_tide,
352 TRUE, path->dtotal_units)); 401 TRUE, 0,
402 TRUE, path->dtotal_units * mult));
403
404 if (display_inodes_perfdata) {
405 /* *_high_tide must be reinitialized at each run */
406 warning_high_tide = UINT64_MAX;
407 critical_high_tide = UINT64_MAX;
408
409 if (path->freeinodes_percent->warning != NULL) {
410 warning_high_tide = (uint64_t) fabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total ));
411 }
412 if (path->freeinodes_percent->critical != NULL) {
413 critical_high_tide = (uint64_t) fabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total ));
414 }
415
416 xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
417 /* Nb: *_high_tide are unset when == UINT64_MAX */
418 xasprintf (&perf, "%s %s", perf,
419 perfdata_uint64 (perf_ilabel,
420 path->inodes_used, "",
421 (warning_high_tide != UINT64_MAX ? TRUE : FALSE), warning_high_tide,
422 (critical_high_tide != UINT64_MAX ? TRUE : FALSE), critical_high_tide,
423 TRUE, 0,
424 TRUE, path->inodes_total));
425 }
353 426
354 if (disk_result==STATE_OK && erronly && !verbose) 427 if (disk_result==STATE_OK && erronly && !verbose)
355 continue; 428 continue;
356 429
357 if(disk_result && verbose >= 1) { 430 if(disk_result && verbose >= 1) {
358 xasprintf(&flag_header, " %s [", state_text (disk_result)); 431 xasprintf(&flag_header, " %s [", state_text (disk_result));
359 } else { 432 } else {
360 xasprintf(&flag_header, ""); 433 xasprintf(&flag_header, "");
361 } 434 }
362 xasprintf (&output, "%s%s %s %.0f %s (%.0f%%", 435 xasprintf (&output, "%s%s %s %llu%s (%.0f%%",
363 output, flag_header, 436 output, flag_header,
364 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 437 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
365 path->dfree_units, 438 path->dfree_units,
366 units, 439 units,
367 path->dfree_pct); 440 path->dfree_pct);
368 if (path->dused_inodes_percent < 0) { 441 if (path->dused_inodes_percent < 0) {
369 xasprintf(&output, "%s inode=-)%s;", output, (disk_result ? "]" : "")); 442 xasprintf(&output, "%s inode=-)%s;", output, (disk_result ? "]" : ""));
370 } else { 443 } else {
371 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : "")); 444 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : ""));
372 } 445 }
373 free(flag_header); 446 free(flag_header);
374 /* TODO: Need to do a similar debug line
375 xasprintf (&details, _("%s\n\
376%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
377 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct,
378 me->me_devname, me->me_type, me->me_mountdir,
379 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
380 */
381
382 } 447 }
383
384 } 448 }
385 449
386 if (verbose >= 2) 450 if (verbose >= 2)
387 xasprintf (&output, "%s%s", output, details); 451 xasprintf (&output, "%s%s", output, details);
388 452
453 if (strcmp(output, "") == 0 && ! erronly) {
454 preamble = "";
455 xasprintf (&output, " - No disks were found for provided parameters;");
456 }
389 457
390 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf); 458 printf ("DISK %s%s%s%s%s|%s\n", state_text (result), ((erronly && result==STATE_OK)) ? "" : preamble, output, (strcmp(ignored, "") == 0) ? "" : ignored_preamble, ignored, perf);
391 return result; 459 return result;
392} 460}
393 461
@@ -423,9 +491,7 @@ process_arguments (int argc, char **argv)
423 int c, err; 491 int c, err;
424 struct parameter_list *se; 492 struct parameter_list *se;
425 struct parameter_list *temp_list = NULL, *previous = NULL; 493 struct parameter_list *temp_list = NULL, *previous = NULL;
426 struct parameter_list *temp_path_select_list = NULL; 494 struct mount_entry *me;
427 struct mount_entry *me, *temp_me;
428 int result = OK;
429 regex_t re; 495 regex_t re;
430 int cflags = REG_NOSUB | REG_EXTENDED; 496 int cflags = REG_NOSUB | REG_EXTENDED;
431 int default_cflags = cflags; 497 int default_cflags = cflags;
@@ -458,8 +524,10 @@ process_arguments (int argc, char **argv)
458 {"ignore-ereg-partition", required_argument, 0, 'i'}, 524 {"ignore-ereg-partition", required_argument, 0, 'i'},
459 {"ignore-eregi-path", required_argument, 0, 'I'}, 525 {"ignore-eregi-path", required_argument, 0, 'I'},
460 {"ignore-eregi-partition", required_argument, 0, 'I'}, 526 {"ignore-eregi-partition", required_argument, 0, 'I'},
527 {"ignore-missing", no_argument, 0, IGNORE_MISSING},
461 {"local", no_argument, 0, 'l'}, 528 {"local", no_argument, 0, 'l'},
462 {"stat-remote-fs", no_argument, 0, 'L'}, 529 {"stat-remote-fs", no_argument, 0, 'L'},
530 {"iperfdata", no_argument, 0, 'P'},
463 {"mountpoint", no_argument, 0, 'M'}, 531 {"mountpoint", no_argument, 0, 'M'},
464 {"errors-only", no_argument, 0, 'e'}, 532 {"errors-only", no_argument, 0, 'e'},
465 {"exact-match", no_argument, 0, 'E'}, 533 {"exact-match", no_argument, 0, 'E'},
@@ -482,7 +550,7 @@ process_arguments (int argc, char **argv)
482 strcpy (argv[c], "-t"); 550 strcpy (argv[c], "-t");
483 551
484 while (1) { 552 while (1) {
485 c = getopt_long (argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLg:R:r:i:I:MEA", longopts, &option); 553 c = getopt_long (argc, argv, "+?VqhvefCt:c:w:K:W:u:p:x:X:N:mklLPg:R:r:i:I:MEA", longopts, &option);
486 554
487 if (c == -1 || c == EOF) 555 if (c == -1 || c == EOF)
488 break; 556 break;
@@ -516,7 +584,7 @@ process_arguments (int argc, char **argv)
516 584
517 /* Awful mistake where the range values do not make sense. Normally, 585 /* Awful mistake where the range values do not make sense. Normally,
518 you alert if the value is within the range, but since we are using 586 you alert if the value is within the range, but since we are using
519 freespace, we have to alert if outside the range. Thus we artifically 587 freespace, we have to alert if outside the range. Thus we artificially
520 force @ at the beginning of the range, so that it is backwards compatible 588 force @ at the beginning of the range, so that it is backwards compatible
521 */ 589 */
522 case 'c': /* critical threshold */ 590 case 'c': /* critical threshold */
@@ -535,14 +603,14 @@ process_arguments (int argc, char **argv)
535 } 603 }
536 break; 604 break;
537 605
538 case 'W': /* warning inode threshold */ 606 case 'W': /* warning inode threshold */
539 if (*optarg == '@') { 607 if (*optarg == '@') {
540 warn_freeinodes_percent = optarg; 608 warn_freeinodes_percent = optarg;
541 } else { 609 } else {
542 xasprintf(&warn_freeinodes_percent, "@%s", optarg); 610 xasprintf(&warn_freeinodes_percent, "@%s", optarg);
543 } 611 }
544 break; 612 break;
545 case 'K': /* critical inode threshold */ 613 case 'K': /* critical inode threshold */
546 if (*optarg == '@') { 614 if (*optarg == '@') {
547 crit_freeinodes_percent = optarg; 615 crit_freeinodes_percent = optarg;
548 } else { 616 } else {
@@ -552,21 +620,39 @@ process_arguments (int argc, char **argv)
552 case 'u': 620 case 'u':
553 if (units) 621 if (units)
554 free(units); 622 free(units);
555 if (! strcmp (optarg, "bytes")) { 623 if (! strcasecmp (optarg, "bytes")) {
556 mult = (uintmax_t)1; 624 mult = (uintmax_t)1;
557 units = strdup ("B"); 625 units = strdup ("B");
558 } else if (! strcmp (optarg, "kB")) { 626 } else if (!strcmp(optarg, "KiB")) {
559 mult = (uintmax_t)1024; 627 mult = (uintmax_t)1024;
628 units = strdup ("KiB");
629 } else if (! strcmp (optarg, "kB")) {
630 mult = (uintmax_t)1000;
560 units = strdup ("kB"); 631 units = strdup ("kB");
561 } else if (! strcmp (optarg, "MB")) { 632 } else if (!strcmp(optarg, "MiB")) {
562 mult = (uintmax_t)1024 * 1024; 633 mult = (uintmax_t)1024 * 1024;
634 units = strdup ("MiB");
635 } else if (! strcmp (optarg, "MB")) {
636 mult = (uintmax_t)1000 * 1000;
563 units = strdup ("MB"); 637 units = strdup ("MB");
564 } else if (! strcmp (optarg, "GB")) { 638 } else if (!strcmp(optarg, "GiB")) {
565 mult = (uintmax_t)1024 * 1024 * 1024; 639 mult = (uintmax_t)1024 * 1024 * 1024;
640 units = strdup ("GiB");
641 } else if (! strcmp (optarg, "GB")){
642 mult = (uintmax_t)1000 * 1000 * 1000;
566 units = strdup ("GB"); 643 units = strdup ("GB");
567 } else if (! strcmp (optarg, "TB")) { 644 } else if (!strcmp(optarg, "TiB")) {
568 mult = (uintmax_t)1024 * 1024 * 1024 * 1024; 645 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
646 units = strdup ("TiB");
647 } else if (! strcmp (optarg, "TB")) {
648 mult = (uintmax_t)1000 * 1000 * 1000 * 1000;
569 units = strdup ("TB"); 649 units = strdup ("TB");
650 } else if (!strcmp(optarg, "PiB")) {
651 mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
652 units = strdup ("PiB");
653 } else if (! strcmp (optarg, "PB")){
654 mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000;
655 units = strdup ("PB");
570 } else { 656 } else {
571 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 657 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
572 } 658 }
@@ -577,19 +663,23 @@ process_arguments (int argc, char **argv)
577 mult = 1024; 663 mult = 1024;
578 if (units) 664 if (units)
579 free(units); 665 free(units);
580 units = strdup ("kB"); 666 units = strdup ("kiB");
581 break; 667 break;
582 case 'm': /* display mountpoint */ 668 case 'm': /* display mountpoint */
583 mult = 1024 * 1024; 669 mult = 1024 * 1024;
584 if (units) 670 if (units)
585 free(units); 671 free(units);
586 units = strdup ("MB"); 672 units = strdup ("MiB");
587 break; 673 break;
588 case 'L': 674 case 'L':
589 stat_remote_fs = 1; 675 stat_remote_fs = 1;
676 /* fallthrough */
590 case 'l': 677 case 'l':
591 show_local_fs = 1; 678 show_local_fs = 1;
592 break; 679 break;
680 case 'P':
681 display_inodes_perfdata = 1;
682 break;
593 case 'p': /* select path */ 683 case 'p': /* select path */
594 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent || 684 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
595 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units || 685 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
@@ -601,12 +691,19 @@ process_arguments (int argc, char **argv)
601 /* add parameter if not found. overwrite thresholds if path has already been added */ 691 /* add parameter if not found. overwrite thresholds if path has already been added */
602 if (! (se = np_find_parameter(path_select_list, optarg))) { 692 if (! (se = np_find_parameter(path_select_list, optarg))) {
603 se = np_add_parameter(&path_select_list, optarg); 693 se = np_add_parameter(&path_select_list, optarg);
694
695 if (stat(optarg, &stat_buf[0]) && ignore_missing == true) {
696 path_ignored = true;
697 break;
698 }
604 } 699 }
605 se->group = group; 700 se->group = group;
606 set_all_thresholds(se); 701 set_all_thresholds(se);
607 702
608 /* With autofs, it is required to stat() the path before re-populating the mount_list */ 703 /* With autofs, it is required to stat() the path before re-populating the mount_list */
609 stat_path(se); 704 if (!stat_path(se)) {
705 break;
706 }
610 /* NB: We can't free the old mount_list "just like that": both list pointers and struct 707 /* NB: We can't free the old mount_list "just like that": both list pointers and struct
611 * pointers are copied around. One of the reason it wasn't done yet is that other parts 708 * pointers are copied around. One of the reason it wasn't done yet is that other parts
612 * of check_disk need the same kind of cleanup so it'd better be done as a whole */ 709 * of check_disk need the same kind of cleanup so it'd better be done as a whole */
@@ -649,6 +746,7 @@ process_arguments (int argc, char **argv)
649 break; 746 break;
650 case 'I': 747 case 'I':
651 cflags |= REG_ICASE; 748 cflags |= REG_ICASE;
749 // Intentional fallthrough
652 case 'i': 750 case 'i':
653 if (!path_selected) 751 if (!path_selected)
654 die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly")); 752 die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly"));
@@ -686,16 +784,21 @@ process_arguments (int argc, char **argv)
686 cflags = default_cflags; 784 cflags = default_cflags;
687 break; 785 break;
688 786
787 case IGNORE_MISSING:
788 ignore_missing = true;
789 break;
689 case 'A': 790 case 'A':
690 optarg = strdup(".*"); 791 optarg = strdup(".*");
792 // Intentional fallthrough
691 case 'R': 793 case 'R':
692 cflags |= REG_ICASE; 794 cflags |= REG_ICASE;
795 // Intentional fallthrough
693 case 'r': 796 case 'r':
694 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent || 797 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
695 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units || 798 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
696 warn_usedspace_percent || crit_usedspace_percent || warn_usedinodes_percent || 799 warn_usedspace_percent || crit_usedspace_percent || warn_usedinodes_percent ||
697 crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) { 800 crit_usedinodes_percent || warn_freeinodes_percent || crit_freeinodes_percent )) {
698 die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -r/-R\n")); 801 die (STATE_UNKNOWN, "DISK %s: %s", _("UNKNOWN"), _("Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--all)\n"));
699 } 802 }
700 803
701 err = regcomp(&re, optarg, cflags); 804 err = regcomp(&re, optarg, cflags);
@@ -719,7 +822,11 @@ process_arguments (int argc, char **argv)
719 } 822 }
720 } 823 }
721 824
722 if (!fnd) 825 if (!fnd && ignore_missing == true) {
826 path_ignored = true;
827 /* path_selected = TRUE;*/
828 break;
829 } else if (!fnd)
723 die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), 830 die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"),
724 _("Regular expression did not match any path or disk"), optarg); 831 _("Regular expression did not match any path or disk"), optarg);
725 832
@@ -779,14 +886,14 @@ process_arguments (int argc, char **argv)
779 if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c])) 886 if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c]))
780 crit_usedspace_percent = argv[c++]; 887 crit_usedspace_percent = argv[c++];
781 888
782 if (argc > c && path == NULL) { 889 if (argc > c) {
783 se = np_add_parameter(&path_select_list, strdup(argv[c++])); 890 se = np_add_parameter(&path_select_list, strdup(argv[c++]));
784 path_selected = TRUE; 891 path_selected = TRUE;
785 set_all_thresholds(se); 892 set_all_thresholds(se);
786 } 893 }
787 894
788 if (units == NULL) { 895 if (units == NULL) {
789 units = strdup ("MB"); 896 units = strdup ("MiB");
790 mult = (uintmax_t)1024 * 1024; 897 mult = (uintmax_t)1024 * 1024;
791 } 898 }
792 899
@@ -822,51 +929,6 @@ set_all_thresholds (struct parameter_list *path)
822 set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); 929 set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent);
823} 930}
824 931
825/* TODO: Remove?
826
827int
828validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, double iwp, double icp, char *mypath)
829{
830 if (w < 0 && c < 0 && wp < 0.0 && cp < 0.0) {
831 printf (_("INPUT ERROR: No thresholds specified"));
832 print_path (mypath);
833 return ERROR;
834 }
835 else if ((wp >= 0.0 || cp >= 0.0) &&
836 (wp < 0.0 || cp < 0.0 || wp > 100.0 || cp > 100.0 || cp > wp)) {
837 printf (_("\
838INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
839 cp, wp);
840 print_path (mypath);
841 return ERROR;
842 }
843 else if ((iwp >= 0.0 || icp >= 0.0) &&
844 (iwp < 0.0 || icp < 0.0 || iwp > 100.0 || icp > 100.0 || icp > iwp)) {
845 printf (_("\
846INPUT ERROR: C_IDFP (%f) should be less than W_IDFP (%.1f) and both should be between zero and 100 percent, inclusive"),
847 icp, iwp);
848 print_path (mypath);
849 return ERROR;
850 }
851 else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) {
852 printf (_("\
853INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
854 (unsigned long)c, (unsigned long)w);
855 print_path (mypath);
856 return ERROR;
857 }
858
859 return OK;
860}
861
862*/
863
864
865
866
867
868
869
870void 932void
871print_help (void) 933print_help (void)
872{ 934{
@@ -909,6 +971,8 @@ print_help (void)
909 printf (" %s\n", _("Display only devices/mountpoints with errors")); 971 printf (" %s\n", _("Display only devices/mountpoints with errors"));
910 printf (" %s\n", "-f, --freespace-ignore-reserved"); 972 printf (" %s\n", "-f, --freespace-ignore-reserved");
911 printf (" %s\n", _("Don't account root-reserved blocks into freespace in perfdata")); 973 printf (" %s\n", _("Don't account root-reserved blocks into freespace in perfdata"));
974 printf (" %s\n", "-P, --iperfdata");
975 printf (" %s\n", _("Display inode usage in perfdata"));
912 printf (" %s\n", "-g, --group=NAME"); 976 printf (" %s\n", "-g, --group=NAME");
913 printf (" %s\n", _("Group paths. Thresholds apply to (free-)space of all partitions together")); 977 printf (" %s\n", _("Group paths. Thresholds apply to (free-)space of all partitions together"));
914 printf (" %s\n", "-k, --kilobytes"); 978 printf (" %s\n", "-k, --kilobytes");
@@ -919,7 +983,7 @@ print_help (void)
919 printf (" %s\n", _("Only check local filesystems against thresholds. Yet call stat on remote filesystems")); 983 printf (" %s\n", _("Only check local filesystems against thresholds. Yet call stat on remote filesystems"));
920 printf (" %s\n", _("to test if they are accessible (e.g. to detect Stale NFS Handles)")); 984 printf (" %s\n", _("to test if they are accessible (e.g. to detect Stale NFS Handles)"));
921 printf (" %s\n", "-M, --mountpoint"); 985 printf (" %s\n", "-M, --mountpoint");
922 printf (" %s\n", _("Display the mountpoint instead of the partition")); 986 printf (" %s\n", _("Display the (block) device instead of the mount point"));
923 printf (" %s\n", "-m, --megabytes"); 987 printf (" %s\n", "-m, --megabytes");
924 printf (" %s\n", _("Same as '--units MB'")); 988 printf (" %s\n", _("Same as '--units MB'"));
925 printf (" %s\n", "-A, --all"); 989 printf (" %s\n", "-A, --all");
@@ -932,6 +996,9 @@ print_help (void)
932 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)")); 996 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)"));
933 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION"); 997 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION");
934 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)")); 998 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)"));
999 printf (" %s\n", "--ignore-missing");
1000 printf (" %s\n", _("Return OK if no filesystem matches, filesystem does not exist or is inaccessible."));
1001 printf (" %s\n", _("(Provide this option before -p / -r / --ereg-path if used)"));
935 printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1002 printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
936 printf (" %s\n", "-u, --units=STRING"); 1003 printf (" %s\n", "-u, --units=STRING");
937 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); 1004 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
@@ -942,12 +1009,20 @@ print_help (void)
942 printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); 1009 printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)"));
943 1010
944 printf ("\n"); 1011 printf ("\n");
1012 printf ("%s\n", _("General usage hints:"));
1013 printf (" %s\n", _("- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the same as"));
1014 printf (" %s\n", _("\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."));
1015 printf (" %s\n", _("- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} {thresholds b} ...\""));
1016
1017
1018
1019 printf ("\n");
945 printf ("%s\n", _("Examples:")); 1020 printf ("%s\n", _("Examples:"));
946 printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /"); 1021 printf (" %s\n", "check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /");
947 printf (" %s\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB")); 1022 printf (" %s\n\n", _("Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"));
948 printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -g sidDATA -r '^/oracle/SID/data.*$'"); 1023 printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -g sidDATA -r '^/oracle/SID/data.*$'");
949 printf (" %s\n", _("Checks all filesystems not matching -r at 100M and 50M. The fs matching the -r regex")); 1024 printf (" %s\n", _("Checks all filesystems not matching -r at 100M and 50M. The fs matching the -r regex"));
950 printf (" %s\n", _("are grouped which means the freespace thresholds are applied to all disks together")); 1025 printf (" %s\n\n", _("are grouped which means the freespace thresholds are applied to all disks together"));
951 printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar"); 1026 printf (" %s\n", "check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar");
952 printf (" %s\n", _("Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use 100M/50M")); 1027 printf (" %s\n", _("Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use 100M/50M"));
953 1028
@@ -960,12 +1035,12 @@ void
960print_usage (void) 1035print_usage (void)
961{ 1036{
962 printf ("%s\n", _("Usage:")); 1037 printf ("%s\n", _("Usage:"));
963 printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname); 1038 printf (" %s {-w absolute_limit |-w percentage_limit%% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit%% | -K inode_percentage_limit } {-p path | -x device}\n", progname);
964 printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); 1039 printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
965 printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); 1040 printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n");
966} 1041}
967 1042
968void 1043bool
969stat_path (struct parameter_list *p) 1044stat_path (struct parameter_list *p)
970{ 1045{
971 /* Stat entry to check that dir exists and is accessible */ 1046 /* Stat entry to check that dir exists and is accessible */
@@ -974,9 +1049,14 @@ stat_path (struct parameter_list *p)
974 if (stat (p->name, &stat_buf[0])) { 1049 if (stat (p->name, &stat_buf[0])) {
975 if (verbose >= 3) 1050 if (verbose >= 3)
976 printf("stat failed on %s\n", p->name); 1051 printf("stat failed on %s\n", p->name);
977 printf("DISK %s - ", _("CRITICAL")); 1052 if (ignore_missing == true) {
978 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); 1053 return false;
1054 } else {
1055 printf("DISK %s - ", _("CRITICAL"));
1056 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno));
1057 }
979 } 1058 }
1059 return true;
980} 1060}
981 1061
982 1062
@@ -996,66 +1076,87 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
996 continue; 1076 continue;
997#endif 1077#endif
998 if (p_list->group && ! (strcmp(p_list->group, p->group))) { 1078 if (p_list->group && ! (strcmp(p_list->group, p->group))) {
999 stat_path(p_list); 1079 if (! stat_path(p_list))
1080 continue;
1000 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); 1081 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp);
1001 get_path_stats(p_list, &tmpfsp); 1082 get_path_stats(p_list, &tmpfsp);
1002 if (verbose >= 3) 1083 if (verbose >= 3)
1003 printf("Group %s: adding %llu blocks sized %llu, (%s) used_units=%g free_units=%g total_units=%g fsu_blocksize=%llu mult=%llu\n", 1084 printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%lu free_units=%lu total_units=%lu mult=%lu\n",
1004 p_list->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p_list->best_match->me_mountdir, p_list->dused_units, p_list->dfree_units, 1085 p_list->group,
1005 p_list->dtotal_units, mult); 1086 tmpfsp.fsu_blocks,
1006 1087 tmpfsp.fsu_blocksize,
1007 /* prevent counting the first FS of a group twice since its parameter_list entry 1088 p_list->best_match->me_mountdir,
1089 p_list->dused_units,
1090 p_list->dfree_units,
1091 p_list->dtotal_units,
1092 mult);
1093
1094 /* prevent counting the first FS of a group twice since its parameter_list entry
1008 * is used to carry the information of all file systems of the entire group */ 1095 * is used to carry the information of all file systems of the entire group */
1009 if (! first) { 1096 if (! first) {
1010 p->total += p_list->total; 1097 p->total += p_list->total;
1011 p->available += p_list->available; 1098 p->available += p_list->available;
1012 p->available_to_root += p_list->available_to_root; 1099 p->available_to_root += p_list->available_to_root;
1013 p->used += p_list->used; 1100 p->used += p_list->used;
1014 1101
1015 p->dused_units += p_list->dused_units; 1102 p->dused_units += p_list->dused_units;
1016 p->dfree_units += p_list->dfree_units; 1103 p->dfree_units += p_list->dfree_units;
1017 p->dtotal_units += p_list->dtotal_units; 1104 p->dtotal_units += p_list->dtotal_units;
1018 p->inodes_total += p_list->inodes_total; 1105 p->inodes_total += p_list->inodes_total;
1019 p->inodes_free += p_list->inodes_free; 1106 p->inodes_free += p_list->inodes_free;
1107 p->inodes_free_to_root += p_list->inodes_free_to_root;
1108 p->inodes_used += p_list->inodes_used;
1020 } 1109 }
1021 first = 0; 1110 first = 0;
1022 } 1111 }
1023 if (verbose >= 3) 1112 if (verbose >= 3)
1024 printf("Group %s now has: used_units=%g free_units=%g total_units=%g fsu_blocksize=%llu mult=%llu\n", 1113 printf("Group %s now has: used_units=%lu free_units=%lu total_units=%lu fsu_blocksize=%lu mult=%lu\n",
1025 p->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p->best_match->me_mountdir, p->dused_units, 1114 p->group,
1026 p->dfree_units, p->dtotal_units, mult); 1115 p->dused_units,
1116 p->dfree_units,
1117 p->dtotal_units,
1118 tmpfsp.fsu_blocksize,
1119 mult);
1027 } 1120 }
1028 /* modify devname and mountdir for output */ 1121 /* modify devname and mountdir for output */
1029 p->best_match->me_mountdir = p->best_match->me_devname = p->group; 1122 p->best_match->me_mountdir = p->best_match->me_devname = p->group;
1030 } 1123 }
1031 /* finally calculate percentages for either plain FS or summed up group */ 1124 /* finally calculate percentages for either plain FS or summed up group */
1032 p->dused_pct = calculate_percent( p->used, p->used + p->available ); /* used + available can never be > uintmax */ 1125 p->dused_pct = calculate_percent( p->used, p->used + p->available ); /* used + available can never be > uintmax */
1033 p->dfree_pct = 100 - p->dused_pct; 1126 p->dfree_pct = 100 - p->dused_pct;
1034 p->dused_inodes_percent = calculate_percent(p->inodes_total - p->inodes_free, p->inodes_total); 1127 p->dused_inodes_percent = calculate_percent(p->inodes_total - p->inodes_free, p->inodes_total);
1035 p->dfree_inodes_percent = 100 - p->dused_inodes_percent; 1128 p->dfree_inodes_percent = 100 - p->dused_inodes_percent;
1036 1129
1037} 1130}
1038 1131
1039void 1132void
1040get_path_stats (struct parameter_list *p, struct fs_usage *fsp) { 1133get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
1041 /* 2007-12-08 - Workaround for Gnulib reporting insanely high available 1134 p->available = fsp->fsu_bavail;
1042 * space on BSD (the actual value should be negative but fsp->fsu_bavail
1043 * is unsigned) */
1044 p->available = fsp->fsu_bavail > fsp->fsu_bfree ? 0 : fsp->fsu_bavail;
1045 p->available_to_root = fsp->fsu_bfree; 1135 p->available_to_root = fsp->fsu_bfree;
1046 p->used = fsp->fsu_blocks - fsp->fsu_bfree; 1136 p->used = fsp->fsu_blocks - fsp->fsu_bfree;
1047 if (freespace_ignore_reserved) { 1137 if (freespace_ignore_reserved) {
1048 /* option activated : we substract the root-reserved space from the total */ 1138 /* option activated : we subtract the root-reserved space from the total */
1049 p->total = fsp->fsu_blocks - p->available_to_root + p->available; 1139 p->total = fsp->fsu_blocks - p->available_to_root + p->available;
1050 } else { 1140 } else {
1051 /* default behaviour : take all the blocks into account */ 1141 /* default behaviour : take all the blocks into account */
1052 p->total = fsp->fsu_blocks; 1142 p->total = fsp->fsu_blocks;
1053 } 1143 }
1054 1144
1055 p->dused_units = p->used*fsp->fsu_blocksize/mult; 1145 p->dused_units = p->used*fsp->fsu_blocksize/mult;
1056 p->dfree_units = p->available*fsp->fsu_blocksize/mult; 1146 p->dfree_units = p->available*fsp->fsu_blocksize/mult;
1057 p->dtotal_units = p->total*fsp->fsu_blocksize/mult; 1147 p->dtotal_units = p->total*fsp->fsu_blocksize/mult;
1058 p->inodes_total = fsp->fsu_files; /* Total file nodes. */ 1148 /* Free file nodes. Not sure the workaround is required, but in case...*/
1059 p->inodes_free = fsp->fsu_ffree; /* Free file nodes. */ 1149 p->inodes_free = fsp->fsu_ffree;
1150 p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */
1151 p->inodes_used = fsp->fsu_files - fsp->fsu_ffree;
1152 if (freespace_ignore_reserved) {
1153 /* option activated : we subtract the root-reserved inodes from the total */
1154 /* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */
1155 /* for others, fsp->fsu_ffree == fsp->fsu_favail */
1156 p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free;
1157 } else {
1158 /* default behaviour : take all the inodes into account */
1159 p->inodes_total = fsp->fsu_files;
1160 }
1060 np_add_name(&seen, p->best_match->me_mountdir); 1161 np_add_name(&seen, p->best_match->me_mountdir);
1061} 1162}
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 48601f02..7ffce98b 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -41,7 +41,9 @@ const char *email = "devel@monitoring-plugins.org";
41 41
42int process_arguments (int, char **); 42int process_arguments (int, char **);
43int validate_arguments (void); 43int validate_arguments (void);
44int error_scan (char *); 44int error_scan (char *, int *);
45int ip_match_cidr(const char *, const char *);
46unsigned long ip2long(const char *);
45void print_help (void); 47void print_help (void);
46void print_usage (void); 48void print_usage (void);
47 49
@@ -52,8 +54,10 @@ char ptr_server[ADDRESS_LENGTH] = "";
52int verbose = FALSE; 54int verbose = FALSE;
53char **expected_address = NULL; 55char **expected_address = NULL;
54int expected_address_cnt = 0; 56int expected_address_cnt = 0;
57int expect_nxdomain = FALSE;
55 58
56int expect_authority = FALSE; 59int expect_authority = FALSE;
60int all_match = FALSE;
57thresholds *time_thresholds = NULL; 61thresholds *time_thresholds = NULL;
58 62
59static int 63static int
@@ -71,7 +75,7 @@ main (int argc, char **argv)
71{ 75{
72 char *command_line = NULL; 76 char *command_line = NULL;
73 char input_buffer[MAX_INPUT_BUFFER]; 77 char input_buffer[MAX_INPUT_BUFFER];
74 char *address = NULL; /* comma seperated str with addrs/ptrs (sorted) */ 78 char *address = NULL; /* comma separated str with addrs/ptrs (sorted) */
75 char **addresses = NULL; 79 char **addresses = NULL;
76 int n_addresses = 0; 80 int n_addresses = 0;
77 char *msg = NULL; 81 char *msg = NULL;
@@ -81,10 +85,10 @@ main (int argc, char **argv)
81 double elapsed_time; 85 double elapsed_time;
82 long microsec; 86 long microsec;
83 struct timeval tv; 87 struct timeval tv;
84 int multi_address;
85 int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ 88 int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
86 output chld_out, chld_err; 89 output chld_out, chld_err;
87 size_t i; 90 size_t i;
91 int is_nxdomain = FALSE;
88 92
89 setlocale (LC_ALL, ""); 93 setlocale (LC_ALL, "");
90 bindtextdomain (PACKAGE, LOCALEDIR); 94 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -127,7 +131,7 @@ main (int argc, char **argv)
127 if (verbose) 131 if (verbose)
128 puts(chld_out.line[i]); 132 puts(chld_out.line[i]);
129 133
130 if (strcasestr (chld_out.line[i], ".in-addr.arpa")) { 134 if (strcasestr (chld_out.line[i], ".in-addr.arpa") || strcasestr (chld_out.line[i], ".ip6.arpa")) {
131 if ((temp_buffer = strstr (chld_out.line[i], "name = "))) 135 if ((temp_buffer = strstr (chld_out.line[i], "name = ")))
132 addresses[n_addresses++] = strdup (temp_buffer + 7); 136 addresses[n_addresses++] = strdup (temp_buffer + 7);
133 else { 137 else {
@@ -167,8 +171,8 @@ main (int argc, char **argv)
167 temp_buffer++; 171 temp_buffer++;
168 172
169 /* Strip leading spaces */ 173 /* Strip leading spaces */
170 for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++) 174 while (*temp_buffer == ' ')
171 /* NOOP */; 175 temp_buffer++;
172 176
173 strip(temp_buffer); 177 strip(temp_buffer);
174 if (temp_buffer==NULL || strlen(temp_buffer)==0) { 178 if (temp_buffer==NULL || strlen(temp_buffer)==0) {
@@ -184,7 +188,7 @@ main (int argc, char **argv)
184 } 188 }
185 189
186 190
187 result = error_scan (chld_out.line[i]); 191 result = error_scan (chld_out.line[i], &is_nxdomain);
188 if (result != STATE_OK) { 192 if (result != STATE_OK) {
189 msg = strchr (chld_out.line[i], ':'); 193 msg = strchr (chld_out.line[i], ':');
190 if(msg) msg++; 194 if(msg) msg++;
@@ -197,13 +201,20 @@ main (int argc, char **argv)
197 if (verbose) 201 if (verbose)
198 puts(chld_err.line[i]); 202 puts(chld_err.line[i]);
199 203
200 if (error_scan (chld_err.line[i]) != STATE_OK) { 204 if (error_scan (chld_err.line[i], &is_nxdomain) != STATE_OK) {
201 result = max_state (result, error_scan (chld_err.line[i])); 205 result = max_state (result, error_scan (chld_err.line[i], &is_nxdomain));
202 msg = strchr(input_buffer, ':'); 206 msg = strchr(input_buffer, ':');
203 if(msg) msg++; 207 if(msg)
208 msg++;
209 else
210 msg = input_buffer;
204 } 211 }
205 } 212 }
206 213
214 if (is_nxdomain && !expect_nxdomain) {
215 die (STATE_CRITICAL, _("Domain '%s' was not found by the server\n"), query_address);
216 }
217
207 if (addresses) { 218 if (addresses) {
208 int i,slen; 219 int i,slen;
209 char *adrp; 220 char *adrp;
@@ -227,11 +238,27 @@ main (int argc, char **argv)
227 if (result == STATE_OK && expected_address_cnt > 0) { 238 if (result == STATE_OK && expected_address_cnt > 0) {
228 result = STATE_CRITICAL; 239 result = STATE_CRITICAL;
229 temp_buffer = ""; 240 temp_buffer = "";
241 unsigned long expect_match = (1 << expected_address_cnt) - 1;
242 unsigned long addr_match = (1 << n_addresses) - 1;
243
230 for (i=0; i<expected_address_cnt; i++) { 244 for (i=0; i<expected_address_cnt; i++) {
231 /* check if we get a match and prepare an error string */ 245 int j;
232 if (strcmp(address, expected_address[i]) == 0) result = STATE_OK; 246 /* check if we get a match on 'raw' ip or cidr */
247 for (j=0; j<n_addresses; j++) {
248 if ( strcmp(addresses[j], expected_address[i]) == 0
249 || ip_match_cidr(addresses[j], expected_address[i]) ) {
250 result = STATE_OK;
251 addr_match &= ~(1 << j);
252 expect_match &= ~(1 << i);
253 }
254 }
255
256 /* prepare an error string */
233 xasprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]); 257 xasprintf(&temp_buffer, "%s%s; ", temp_buffer, expected_address[i]);
234 } 258 }
259 /* check if expected_address must cover all in addresses and none may be missing */
260 if (all_match && (expect_match != 0 || addr_match != 0))
261 result = STATE_CRITICAL;
235 if (result == STATE_CRITICAL) { 262 if (result == STATE_CRITICAL) {
236 /* Strip off last semicolon... */ 263 /* Strip off last semicolon... */
237 temp_buffer[strlen(temp_buffer)-2] = '\0'; 264 temp_buffer[strlen(temp_buffer)-2] = '\0';
@@ -239,6 +266,16 @@ main (int argc, char **argv)
239 } 266 }
240 } 267 }
241 268
269 if (expect_nxdomain) {
270 if (!is_nxdomain) {
271 result = STATE_CRITICAL;
272 xasprintf(&msg, _("Domain '%s' was found by the server: '%s'\n"), query_address, address);
273 } else {
274 if (address != NULL) free(address);
275 address = "NXDOMAIN";
276 }
277 }
278
242 /* check if authoritative */ 279 /* check if authoritative */
243 if (result == STATE_OK && expect_authority && non_authoritative) { 280 if (result == STATE_OK && expect_authority && non_authoritative) {
244 result = STATE_CRITICAL; 281 result = STATE_CRITICAL;
@@ -249,11 +286,6 @@ main (int argc, char **argv)
249 elapsed_time = (double)microsec / 1.0e6; 286 elapsed_time = (double)microsec / 1.0e6;
250 287
251 if (result == STATE_OK) { 288 if (result == STATE_OK) {
252 if (strchr (address, ',') == NULL)
253 multi_address = FALSE;
254 else
255 multi_address = TRUE;
256
257 result = get_status(elapsed_time, time_thresholds); 289 result = get_status(elapsed_time, time_thresholds);
258 if (result == STATE_OK) { 290 if (result == STATE_OK) {
259 printf ("DNS %s: ", _("OK")); 291 printf ("DNS %s: ", _("OK"));
@@ -295,12 +327,43 @@ main (int argc, char **argv)
295 return result; 327 return result;
296} 328}
297 329
330int
331ip_match_cidr(const char *addr, const char *cidr_ro)
332{
333 char *subnet, *mask_c, *cidr = strdup(cidr_ro);
334 int mask;
335 subnet = strtok(cidr, "/");
336 mask_c = strtok(NULL, "\0");
337 if (!subnet || !mask_c)
338 return FALSE;
339 mask = atoi(mask_c);
340
341 /* https://www.cryptobells.com/verifying-ips-in-a-subnet-in-php/ */
342 return (ip2long(addr) & ~((1 << (32 - mask)) - 1)) == (ip2long(subnet) >> (32 - mask)) << (32 - mask);
343}
298 344
345unsigned long
346ip2long(const char* src) {
347 unsigned long ip[4];
348 /* http://computer-programming-forum.com/47-c-language/1376ffb92a12c471.htm */
349 return (sscanf(src, "%3lu.%3lu.%3lu.%3lu",
350 &ip[0], &ip[1], &ip[2], &ip[3]) == 4 &&
351 ip[0] < 256 && ip[1] < 256 &&
352 ip[2] < 256 && ip[3] < 256)
353 ? ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]
354 : 0;
355}
299 356
300int 357int
301error_scan (char *input_buffer) 358error_scan (char *input_buffer, int *is_nxdomain)
302{ 359{
303 360
361 const int nxdomain = strstr (input_buffer, "Non-existent") ||
362 strstr (input_buffer, "** server can't find") ||
363 strstr (input_buffer, "** Can't find") ||
364 strstr (input_buffer, "NXDOMAIN");
365 if (nxdomain) *is_nxdomain = TRUE;
366
304 /* the DNS lookup timed out */ 367 /* the DNS lookup timed out */
305 if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) || 368 if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) ||
306 strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) || 369 strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) ||
@@ -310,6 +373,8 @@ error_scan (char *input_buffer)
310 /* DNS server is not running... */ 373 /* DNS server is not running... */
311 else if (strstr (input_buffer, "No response from server")) 374 else if (strstr (input_buffer, "No response from server"))
312 die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server); 375 die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
376 else if (strstr (input_buffer, "no servers could be reached"))
377 die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
313 378
314 /* Host name is valid, but server doesn't have records... */ 379 /* Host name is valid, but server doesn't have records... */
315 else if (strstr (input_buffer, "No records")) 380 else if (strstr (input_buffer, "No records"))
@@ -317,7 +382,7 @@ error_scan (char *input_buffer)
317 382
318 /* Connection was refused */ 383 /* Connection was refused */
319 else if (strstr (input_buffer, "Connection refused") || 384 else if (strstr (input_buffer, "Connection refused") ||
320 strstr (input_buffer, "Couldn't find server") || 385 strstr (input_buffer, "Couldn't find server") ||
321 strstr (input_buffer, "Refused") || 386 strstr (input_buffer, "Refused") ||
322 (strstr (input_buffer, "** server can't find") && 387 (strstr (input_buffer, "** server can't find") &&
323 strstr (input_buffer, ": REFUSED"))) 388 strstr (input_buffer, ": REFUSED")))
@@ -331,12 +396,6 @@ error_scan (char *input_buffer)
331 else if (strstr (input_buffer, "No information")) 396 else if (strstr (input_buffer, "No information"))
332 die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server); 397 die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server);
333 398
334 /* Host or domain name does not exist */
335 else if (strstr (input_buffer, "Non-existent") ||
336 strstr (input_buffer, "** server can't find") ||
337 strstr (input_buffer,"NXDOMAIN"))
338 die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address);
339
340 /* Network is unreachable */ 399 /* Network is unreachable */
341 else if (strstr (input_buffer, "Network is unreachable")) 400 else if (strstr (input_buffer, "Network is unreachable"))
342 die (STATE_CRITICAL, _("Network is unreachable\n")); 401 die (STATE_CRITICAL, _("Network is unreachable\n"));
@@ -373,7 +432,9 @@ process_arguments (int argc, char **argv)
373 {"server", required_argument, 0, 's'}, 432 {"server", required_argument, 0, 's'},
374 {"reverse-server", required_argument, 0, 'r'}, 433 {"reverse-server", required_argument, 0, 'r'},
375 {"expected-address", required_argument, 0, 'a'}, 434 {"expected-address", required_argument, 0, 'a'},
435 {"expect-nxdomain", no_argument, 0, 'n'},
376 {"expect-authority", no_argument, 0, 'A'}, 436 {"expect-authority", no_argument, 0, 'A'},
437 {"all", no_argument, 0, 'L'},
377 {"warning", required_argument, 0, 'w'}, 438 {"warning", required_argument, 0, 'w'},
378 {"critical", required_argument, 0, 'c'}, 439 {"critical", required_argument, 0, 'c'},
379 {0, 0, 0, 0} 440 {0, 0, 0, 0}
@@ -387,7 +448,7 @@ process_arguments (int argc, char **argv)
387 strcpy (argv[c], "-t"); 448 strcpy (argv[c], "-t");
388 449
389 while (1) { 450 while (1) {
390 c = getopt_long (argc, argv, "hVvAt:H:s:r:a:w:c:", long_opts, &opt_index); 451 c = getopt_long (argc, argv, "hVvALnt:H:s:r:a:w:c:", long_opts, &opt_index);
391 452
392 if (c == -1 || c == EOF) 453 if (c == -1 || c == EOF)
393 break; 454 break;
@@ -428,13 +489,33 @@ process_arguments (int argc, char **argv)
428 case 'a': /* expected address */ 489 case 'a': /* expected address */
429 if (strlen (optarg) >= ADDRESS_LENGTH) 490 if (strlen (optarg) >= ADDRESS_LENGTH)
430 die (STATE_UNKNOWN, _("Input buffer overflow\n")); 491 die (STATE_UNKNOWN, _("Input buffer overflow\n"));
431 expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**)); 492 if (strchr(optarg, ',') != NULL) {
432 expected_address[expected_address_cnt] = strdup(optarg); 493 char *comma = strchr(optarg, ',');
433 expected_address_cnt++; 494 while (comma != NULL) {
495 expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
496 expected_address[expected_address_cnt] = strndup(optarg, comma - optarg);
497 expected_address_cnt++;
498 optarg = comma + 1;
499 comma = strchr(optarg, ',');
500 }
501 expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
502 expected_address[expected_address_cnt] = strdup(optarg);
503 expected_address_cnt++;
504 } else {
505 expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
506 expected_address[expected_address_cnt] = strdup(optarg);
507 expected_address_cnt++;
508 }
509 break;
510 case 'n': /* expect NXDOMAIN */
511 expect_nxdomain = TRUE;
434 break; 512 break;
435 case 'A': /* expect authority */ 513 case 'A': /* expect authority */
436 expect_authority = TRUE; 514 expect_authority = TRUE;
437 break; 515 break;
516 case 'L': /* all must match */
517 all_match = TRUE;
518 break;
438 case 'w': 519 case 'w':
439 warning = optarg; 520 warning = optarg;
440 break; 521 break;
@@ -470,8 +551,15 @@ process_arguments (int argc, char **argv)
470int 551int
471validate_arguments () 552validate_arguments ()
472{ 553{
473 if (query_address[0] == 0) 554 if (query_address[0] == 0) {
555 printf ("missing --host argument\n");
556 return ERROR;
557 }
558
559 if (expected_address_cnt > 0 && expect_nxdomain) {
560 printf ("--expected-address and --expect-nxdomain cannot be combined\n");
474 return ERROR; 561 return ERROR;
562 }
475 563
476 return OK; 564 return OK;
477} 565}
@@ -500,17 +588,22 @@ print_help (void)
500 printf (" %s\n", _("The name or address you want to query")); 588 printf (" %s\n", _("The name or address you want to query"));
501 printf (" -s, --server=HOST\n"); 589 printf (" -s, --server=HOST\n");
502 printf (" %s\n", _("Optional DNS server you want to use for the lookup")); 590 printf (" %s\n", _("Optional DNS server you want to use for the lookup"));
503 printf (" -a, --expected-address=IP-ADDRESS|HOST\n"); 591 printf (" -a, --expected-address=IP-ADDRESS|CIDR|HOST\n");
504 printf (" %s\n", _("Optional IP-ADDRESS you expect the DNS server to return. HOST must end with")); 592 printf (" %s\n", _("Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"));
505 printf (" %s\n", _("a dot (.). This option can be repeated multiple times (Returns OK if any")); 593 printf (" %s\n", _("with a dot (.). This option can be repeated multiple times (Returns OK if any"));
506 printf (" %s\n", _("value match). If multiple addresses are returned at once, you have to match")); 594 printf (" %s\n", _("value matches)."));
507 printf (" %s\n", _("the whole string of addresses separated with commas (sorted alphabetically).")); 595 printf (" -n, --expect-nxdomain\n");
596 printf (" %s\n", _("Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"));
597 printf (" %s\n", _("Cannot be used together with -a"));
508 printf (" -A, --expect-authority\n"); 598 printf (" -A, --expect-authority\n");
509 printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup")); 599 printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup"));
510 printf (" -w, --warning=seconds\n"); 600 printf (" -w, --warning=seconds\n");
511 printf (" %s\n", _("Return warning if elapsed time exceeds value. Default off")); 601 printf (" %s\n", _("Return warning if elapsed time exceeds value. Default off"));
512 printf (" -c, --critical=seconds\n"); 602 printf (" -c, --critical=seconds\n");
513 printf (" %s\n", _("Return critical if elapsed time exceeds value. Default off")); 603 printf (" %s\n", _("Return critical if elapsed time exceeds value. Default off"));
604 printf (" -L, --all\n");
605 printf (" %s\n", _("Return critical if the list of expected addresses does not match all addresses"));
606 printf (" %s\n", _("returned. Default off"));
514 607
515 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 608 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
516 609
@@ -522,5 +615,5 @@ void
522print_usage (void) 615print_usage (void)
523{ 616{
524 printf ("%s\n", _("Usage:")); 617 printf ("%s\n", _("Usage:"));
525 printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit]\n", progname); 618 printf ("%s -H host [-s server] [-a expected-address] [-n] [-A] [-t timeout] [-w warn] [-c crit] [-L]\n", progname);
526} 619}
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index da1ce1a6..23a9e990 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -37,6 +37,7 @@ const char *email = "devel@monitoring-plugins.org";
37#include "popen.h" 37#include "popen.h"
38#include "netutils.h" 38#include "netutils.h"
39#include "utils.h" 39#include "utils.h"
40#include <stdbool.h>
40 41
41enum { 42enum {
42 PACKET_COUNT = 1, 43 PACKET_COUNT = 1,
@@ -65,13 +66,14 @@ double crta;
65double wrta; 66double wrta;
66int cpl_p = FALSE; 67int cpl_p = FALSE;
67int wpl_p = FALSE; 68int wpl_p = FALSE;
69bool alive_p = FALSE;
68int crta_p = FALSE; 70int crta_p = FALSE;
69int wrta_p = FALSE; 71int wrta_p = FALSE;
70 72
71int 73int
72main (int argc, char **argv) 74main (int argc, char **argv)
73{ 75{
74/* normaly should be int result = STATE_UNKNOWN; */ 76/* normally should be int result = STATE_UNKNOWN; */
75 77
76 int status = STATE_UNKNOWN; 78 int status = STATE_UNKNOWN;
77 int result = 0; 79 int result = 0;
@@ -147,9 +149,11 @@ main (int argc, char **argv)
147 (void) fclose (child_stderr); 149 (void) fclose (child_stderr);
148 150
149 /* close the pipe */ 151 /* close the pipe */
150 if (result = spclose (child_process)) 152 result = spclose (child_process);
153 if (result) {
151 /* need to use max_state not max */ 154 /* need to use max_state not max */
152 status = max_state (status, STATE_WARNING); 155 status = max_state (status, STATE_WARNING);
156 }
153 157
154 if (result > 1 ) { 158 if (result > 1 ) {
155 status = max_state (status, STATE_UNKNOWN); 159 status = max_state (status, STATE_UNKNOWN);
@@ -171,10 +175,7 @@ main (int argc, char **argv)
171} 175}
172 176
173 177
174 178int textscan (char *buf) {
175int
176textscan (char *buf)
177{
178 char *rtastr = NULL; 179 char *rtastr = NULL;
179 char *losstr = NULL; 180 char *losstr = NULL;
180 char *xmtstr = NULL; 181 char *xmtstr = NULL;
@@ -183,8 +184,22 @@ textscan (char *buf)
183 double xmt; 184 double xmt;
184 int status = STATE_UNKNOWN; 185 int status = STATE_UNKNOWN;
185 186
187 /* stops testing after the first successful reply. */
188 if (alive_p && strstr(buf, "avg, 0% loss)")) {
189 rtastr = strstr (buf, "ms (");
190 rtastr = 1 + index(rtastr, '(');
191 rta = strtod(rtastr, NULL);
192 loss=strtod("0",NULL);
193 die (STATE_OK,
194 _("FPING %s - %s (rta=%f ms)|%s\n"),
195 state_text (STATE_OK), server_name,rta,
196 /* No loss since we only waited for the first reply
197 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), */
198 fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0));
199 }
200
186 if (strstr (buf, "not found")) { 201 if (strstr (buf, "not found")) {
187 die (STATE_CRITICAL, _("FPING UNKNOW - %s not found\n"), server_name); 202 die (STATE_CRITICAL, _("FPING UNKNOWN - %s not found\n"), server_name);
188 203
189 } 204 }
190 else if (strstr (buf, "is unreachable") || strstr (buf, "Unreachable")) { 205 else if (strstr (buf, "is unreachable") || strstr (buf, "Unreachable")) {
@@ -278,6 +293,7 @@ process_arguments (int argc, char **argv)
278 {"sourceif", required_argument, 0, 'I'}, 293 {"sourceif", required_argument, 0, 'I'},
279 {"critical", required_argument, 0, 'c'}, 294 {"critical", required_argument, 0, 'c'},
280 {"warning", required_argument, 0, 'w'}, 295 {"warning", required_argument, 0, 'w'},
296 {"alive", no_argument, 0, 'a'},
281 {"bytes", required_argument, 0, 'b'}, 297 {"bytes", required_argument, 0, 'b'},
282 {"number", required_argument, 0, 'n'}, 298 {"number", required_argument, 0, 'n'},
283 {"target-timeout", required_argument, 0, 'T'}, 299 {"target-timeout", required_argument, 0, 'T'},
@@ -304,7 +320,7 @@ process_arguments (int argc, char **argv)
304 } 320 }
305 321
306 while (1) { 322 while (1) {
307 c = getopt_long (argc, argv, "+hVvH:S:c:w:b:n:T:i:I:46", longopts, &option); 323 c = getopt_long (argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:46", longopts, &option);
308 324
309 if (c == -1 || c == EOF || c == 1) 325 if (c == -1 || c == EOF || c == 1)
310 break; 326 break;
@@ -312,6 +328,9 @@ process_arguments (int argc, char **argv)
312 switch (c) { 328 switch (c) {
313 case '?': /* print short usage statement if args not parsable */ 329 case '?': /* print short usage statement if args not parsable */
314 usage5 (); 330 usage5 ();
331 case 'a': /* host alive mode */
332 alive_p = TRUE;
333 break;
315 case 'h': /* help */ 334 case 'h': /* help */
316 print_help (); 335 print_help ();
317 exit (STATE_UNKNOWN); 336 exit (STATE_UNKNOWN);
@@ -335,6 +354,7 @@ process_arguments (int argc, char **argv)
335 break; 354 break;
336 case 'I': /* sourceip */ 355 case 'I': /* sourceip */
337 sourceif = strscpy (sourceif, optarg); 356 sourceif = strscpy (sourceif, optarg);
357 break;
338 case '4': /* IPv4 only */ 358 case '4': /* IPv4 only */
339 address_family = AF_INET; 359 address_family = AF_INET;
340 break; 360 break;
@@ -446,9 +466,7 @@ get_threshold (char *arg, char *rv[2])
446} 466}
447 467
448 468
449void 469void print_help (void) {
450print_help (void)
451{
452 470
453 print_revision (progname, NP_VERSION); 471 print_revision (progname, NP_VERSION);
454 472
@@ -474,6 +492,8 @@ print_help (void)
474 printf (" %s\n", _("warning threshold pair")); 492 printf (" %s\n", _("warning threshold pair"));
475 printf (" %s\n", "-c, --critical=THRESHOLD"); 493 printf (" %s\n", "-c, --critical=THRESHOLD");
476 printf (" %s\n", _("critical threshold pair")); 494 printf (" %s\n", _("critical threshold pair"));
495 printf (" %s\n", "-a, --alive");
496 printf (" %s\n", _("Return OK after first successful reply"));
477 printf (" %s\n", "-b, --bytes=INTEGER"); 497 printf (" %s\n", "-b, --bytes=INTEGER");
478 printf (" %s (default: %d)\n", _("size of ICMP packet"),PACKET_SIZE); 498 printf (" %s (default: %d)\n", _("size of ICMP packet"),PACKET_SIZE);
479 printf (" %s\n", "-n, --number=INTEGER"); 499 printf (" %s\n", "-n, --number=INTEGER");
diff --git a/plugins/check_game.c b/plugins/check_game.c
index 709dae1b..a534b69b 100644
--- a/plugins/check_game.c
+++ b/plugins/check_game.c
@@ -318,7 +318,7 @@ print_help (void)
318 printf ("%s\n", _("Notes:")); 318 printf ("%s\n", _("Notes:"));
319 printf (" %s\n", _("This plugin uses the 'qstat' command, the popular game server status query tool.")); 319 printf (" %s\n", _("This plugin uses the 'qstat' command, the popular game server status query tool."));
320 printf (" %s\n", _("If you don't have the package installed, you will need to download it from")); 320 printf (" %s\n", _("If you don't have the package installed, you will need to download it from"));
321 printf (" %s\n", _("http://www.activesw.com/people/steve/qstat.html before you can use this plugin.")); 321 printf (" %s\n", _("https://github.com/multiplay/qstat before you can use this plugin."));
322 322
323 printf (UT_SUPPORT); 323 printf (UT_SUPPORT);
324} 324}
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index f159f5a2..c34bb082 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -66,7 +66,8 @@ void print_usage (void);
66 66
67char *community = NULL; 67char *community = NULL;
68char *address = NULL; 68char *address = NULL;
69char *port = NULL; 69unsigned int port = 0;
70int check_paper_out = 1;
70 71
71int 72int
72main (int argc, char **argv) 73main (int argc, char **argv)
@@ -120,8 +121,12 @@ main (int argc, char **argv)
120 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); 121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
121 122
122 /* get the command to run */ 123 /* get the command to run */
123 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%hd %s", PATH_TO_SNMPGET, community, 124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%u %s",
124 address, port, query_string); 125 PATH_TO_SNMPGET,
126 community,
127 address,
128 port,
129 query_string);
125 130
126 /* run the command */ 131 /* run the command */
127 child_process = spopen (command_line); 132 child_process = spopen (command_line);
@@ -240,7 +245,8 @@ main (int argc, char **argv)
240 strcpy (errmsg, _("Paper Jam")); 245 strcpy (errmsg, _("Paper Jam"));
241 } 246 }
242 else if (paper_out) { 247 else if (paper_out) {
243 result = STATE_WARNING; 248 if (check_paper_out)
249 result = STATE_WARNING;
244 strcpy (errmsg, _("Out of Paper")); 250 strcpy (errmsg, _("Out of Paper"));
245 } 251 }
246 else if (line_status == OFFLINE) { 252 else if (line_status == OFFLINE) {
@@ -325,7 +331,7 @@ process_arguments (int argc, char **argv)
325 331
326 332
327 while (1) { 333 while (1) {
328 c = getopt_long (argc, argv, "+hVH:C:p:", longopts, &option); 334 c = getopt_long (argc, argv, "+hVH:C:p:D", longopts, &option);
329 335
330 if (c == -1 || c == EOF || c == 1) 336 if (c == -1 || c == EOF || c == 1)
331 break; 337 break;
@@ -348,6 +354,9 @@ process_arguments (int argc, char **argv)
348 else 354 else
349 port = atoi(optarg); 355 port = atoi(optarg);
350 break; 356 break;
357 case 'D': /* disable paper out check*/
358 check_paper_out = 0;
359 break;
351 case 'V': /* version */ 360 case 'V': /* version */
352 print_revision (progname, NP_VERSION); 361 print_revision (progname, NP_VERSION);
353 exit (STATE_UNKNOWN); 362 exit (STATE_UNKNOWN);
@@ -376,11 +385,8 @@ process_arguments (int argc, char **argv)
376 community = strdup (DEFAULT_COMMUNITY); 385 community = strdup (DEFAULT_COMMUNITY);
377 } 386 }
378 387
379 if (port == NULL) { 388 if (port == 0) {
380 if (argv[c] != NULL ) 389 port = atoi(DEFAULT_PORT);
381 port = argv[c];
382 else
383 port = atoi (DEFAULT_PORT);
384 } 390 }
385 391
386 return validate_arguments (); 392 return validate_arguments ();
@@ -420,6 +426,8 @@ print_help (void)
420 printf (" %s", _("Specify the port to check ")); 426 printf (" %s", _("Specify the port to check "));
421 printf (_("(default=%s)"), DEFAULT_PORT); 427 printf (_("(default=%s)"), DEFAULT_PORT);
422 printf ("\n"); 428 printf ("\n");
429 printf (" %s\n", "-D");
430 printf (" %s", _("Disable paper check "));
423 431
424 printf (UT_SUPPORT); 432 printf (UT_SUPPORT);
425} 433}
@@ -430,5 +438,5 @@ void
430print_usage (void) 438print_usage (void)
431{ 439{
432 printf ("%s\n", _("Usage:")); 440 printf ("%s\n", _("Usage:"));
433 printf ("%s -H host [-C community] [-p port]\n", progname); 441 printf ("%s -H host [-C community] [-p port] [-D]\n", progname);
434} 442}
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 2038f4a1..718c8ee7 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -31,13 +31,14 @@
31* 31*
32*****************************************************************************/ 32*****************************************************************************/
33 33
34/* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */
35
36const char *progname = "check_http"; 34const char *progname = "check_http";
37const char *copyright = "1999-2013"; 35const char *copyright = "1999-2022";
38const char *email = "devel@monitoring-plugins.org"; 36const char *email = "devel@monitoring-plugins.org";
39 37
38// Do NOT sort those headers, it will break the build
39// TODO: Fix this
40#include "common.h" 40#include "common.h"
41#include "base64.h"
41#include "netutils.h" 42#include "netutils.h"
42#include "utils.h" 43#include "utils.h"
43#include "base64.h" 44#include "base64.h"
@@ -52,11 +53,13 @@ enum {
52 MAX_IPV4_HOSTLENGTH = 255, 53 MAX_IPV4_HOSTLENGTH = 255,
53 HTTP_PORT = 80, 54 HTTP_PORT = 80,
54 HTTPS_PORT = 443, 55 HTTPS_PORT = 443,
55 MAX_PORT = 65535 56 MAX_PORT = 65535,
57 DEFAULT_MAX_REDIRS = 15
56}; 58};
57 59
58#ifdef HAVE_SSL 60#ifdef HAVE_SSL
59int check_cert = FALSE; 61bool check_cert = false;
62bool continue_after_check_cert = false;
60int ssl_version = 0; 63int ssl_version = 0;
61int days_till_exp_warn, days_till_exp_crit; 64int days_till_exp_warn, days_till_exp_crit;
62char *randbuff; 65char *randbuff;
@@ -67,12 +70,12 @@ X509 *server_cert;
67# define my_recv(buf, len) read(sd, buf, len) 70# define my_recv(buf, len) read(sd, buf, len)
68# define my_send(buf, len) send(sd, buf, len, 0) 71# define my_send(buf, len) send(sd, buf, len, 0)
69#endif /* HAVE_SSL */ 72#endif /* HAVE_SSL */
70int no_body = FALSE; 73bool no_body = false;
71int maximum_age = -1; 74int maximum_age = -1;
72 75
73enum { 76enum {
74 REGS = 2, 77 REGS = 2,
75 MAX_RE_SIZE = 256 78 MAX_RE_SIZE = 1024
76}; 79};
77#include "regex.h" 80#include "regex.h"
78regex_t preg; 81regex_t preg;
@@ -89,12 +92,14 @@ struct timeval tv_temp;
89#define HTTP_URL "/" 92#define HTTP_URL "/"
90#define CRLF "\r\n" 93#define CRLF "\r\n"
91 94
92int specify_port = FALSE; 95bool specify_port = false;
93int server_port = HTTP_PORT; 96int server_port = HTTP_PORT;
97int virtual_port = 0;
94char server_port_text[6] = ""; 98char server_port_text[6] = "";
95char server_type[6] = "http"; 99char server_type[6] = "http";
96char *server_address; 100char *server_address;
97char *host_name; 101char *host_name;
102int host_name_length;
98char *server_url; 103char *server_url;
99char *user_agent; 104char *user_agent;
100int server_url_length; 105int server_url_length;
@@ -102,38 +107,39 @@ int server_expect_yn = 0;
102char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; 107char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
103char header_expect[MAX_INPUT_BUFFER] = ""; 108char header_expect[MAX_INPUT_BUFFER] = "";
104char string_expect[MAX_INPUT_BUFFER] = ""; 109char string_expect[MAX_INPUT_BUFFER] = "";
105char output_header_search[30] = "";
106char output_string_search[30] = "";
107char *warning_thresholds = NULL; 110char *warning_thresholds = NULL;
108char *critical_thresholds = NULL; 111char *critical_thresholds = NULL;
109thresholds *thlds; 112thresholds *thlds;
110char user_auth[MAX_INPUT_BUFFER] = ""; 113char user_auth[MAX_INPUT_BUFFER] = "";
111char proxy_auth[MAX_INPUT_BUFFER] = ""; 114char proxy_auth[MAX_INPUT_BUFFER] = "";
112int display_html = FALSE; 115bool display_html = false;
113char **http_opt_headers; 116char **http_opt_headers;
114int http_opt_headers_count = 0; 117int http_opt_headers_count = 0;
115int onredirect = STATE_OK; 118int onredirect = STATE_OK;
116int followsticky = STICKY_NONE; 119int followsticky = STICKY_NONE;
117int use_ssl = FALSE; 120bool use_ssl = false;
118int use_sni = FALSE; 121bool use_sni = false;
119int verbose = FALSE; 122bool verbose = false;
120int show_extended_perfdata = FALSE; 123bool show_extended_perfdata = false;
124bool show_body = false;
121int sd; 125int sd;
122int min_page_len = 0; 126int min_page_len = 0;
123int max_page_len = 0; 127int max_page_len = 0;
124int redir_depth = 0; 128int redir_depth = 0;
125int max_depth = 15; 129int max_depth = DEFAULT_MAX_REDIRS;
126char *http_method; 130char *http_method;
131char *http_method_proxy;
127char *http_post_data; 132char *http_post_data;
128char *http_content_type; 133char *http_content_type;
129char buffer[MAX_INPUT_BUFFER]; 134char buffer[MAX_INPUT_BUFFER];
130char *client_cert = NULL; 135char *client_cert = NULL;
131char *client_privkey = NULL; 136char *client_privkey = NULL;
132 137
133int process_arguments (int, char **); 138// Forward function declarations
139bool process_arguments (int, char **);
134int check_http (void); 140int check_http (void);
135void redir (char *pos, char *status_line); 141void redir (char *pos, char *status_line);
136int server_type_check(const char *type); 142bool server_type_check(const char *type);
137int server_port_check(int ssl_flag); 143int server_port_check(int ssl_flag);
138char *perfd_time (double microsec); 144char *perfd_time (double microsec);
139char *perfd_time_connect (double microsec); 145char *perfd_time_connect (double microsec);
@@ -144,6 +150,7 @@ char *perfd_time_transfer (double microsec);
144char *perfd_size (int page_len); 150char *perfd_size (int page_len);
145void print_help (void); 151void print_help (void);
146void print_usage (void); 152void print_usage (void);
153char *unchunk_content(const char *content);
147 154
148int 155int
149main (int argc, char **argv) 156main (int argc, char **argv)
@@ -163,10 +170,10 @@ main (int argc, char **argv)
163 /* Parse extra opts if any */ 170 /* Parse extra opts if any */
164 argv=np_extra_opts (&argc, argv, progname); 171 argv=np_extra_opts (&argc, argv, progname);
165 172
166 if (process_arguments (argc, argv) == ERROR) 173 if (process_arguments (argc, argv) == false)
167 usage4 (_("Could not parse arguments")); 174 usage4 (_("Could not parse arguments"));
168 175
169 if (display_html == TRUE) 176 if (display_html == true)
170 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">", 177 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
171 use_ssl ? "https" : "http", host_name ? host_name : server_address, 178 use_ssl ? "https" : "http", host_name ? host_name : server_address,
172 server_port, server_url); 179 server_port, server_url);
@@ -189,9 +196,11 @@ test_file (char *path)
189 usage2 (_("file does not exist or is not readable"), path); 196 usage2 (_("file does not exist or is not readable"), path);
190} 197}
191 198
192/* process command-line arguments */ 199/*
193int 200 * process command-line arguments
194process_arguments (int argc, char **argv) 201 * returns true on success, false otherwise
202 */
203bool process_arguments (int argc, char **argv)
195{ 204{
196 int c = 1; 205 int c = 1;
197 char *p; 206 char *p;
@@ -199,7 +208,9 @@ process_arguments (int argc, char **argv)
199 208
200 enum { 209 enum {
201 INVERT_REGEX = CHAR_MAX + 1, 210 INVERT_REGEX = CHAR_MAX + 1,
202 SNI_OPTION 211 SNI_OPTION,
212 MAX_REDIRS_OPTION,
213 CONTINUE_AFTER_CHECK_CERT
203 }; 214 };
204 215
205 int option = 0; 216 int option = 0;
@@ -227,6 +238,7 @@ process_arguments (int argc, char **argv)
227 {"certificate", required_argument, 0, 'C'}, 238 {"certificate", required_argument, 0, 'C'},
228 {"client-cert", required_argument, 0, 'J'}, 239 {"client-cert", required_argument, 0, 'J'},
229 {"private-key", required_argument, 0, 'K'}, 240 {"private-key", required_argument, 0, 'K'},
241 {"continue-after-certificate", no_argument, 0, CONTINUE_AFTER_CHECK_CERT},
230 {"useragent", required_argument, 0, 'A'}, 242 {"useragent", required_argument, 0, 'A'},
231 {"header", required_argument, 0, 'k'}, 243 {"header", required_argument, 0, 'k'},
232 {"no-body", no_argument, 0, 'N'}, 244 {"no-body", no_argument, 0, 'N'},
@@ -237,11 +249,13 @@ process_arguments (int argc, char **argv)
237 {"use-ipv4", no_argument, 0, '4'}, 249 {"use-ipv4", no_argument, 0, '4'},
238 {"use-ipv6", no_argument, 0, '6'}, 250 {"use-ipv6", no_argument, 0, '6'},
239 {"extended-perfdata", no_argument, 0, 'E'}, 251 {"extended-perfdata", no_argument, 0, 'E'},
252 {"show-body", no_argument, 0, 'B'},
253 {"max-redirs", required_argument, 0, MAX_REDIRS_OPTION},
240 {0, 0, 0, 0} 254 {0, 0, 0, 0}
241 }; 255 };
242 256
243 if (argc < 2) 257 if (argc < 2)
244 return ERROR; 258 return false;
245 259
246 for (c = 1; c < argc; c++) { 260 for (c = 1; c < argc; c++) {
247 if (strcmp ("-to", argv[c]) == 0) 261 if (strcmp ("-to", argv[c]) == 0)
@@ -257,7 +271,7 @@ process_arguments (int argc, char **argv)
257 } 271 }
258 272
259 while (1) { 273 while (1) {
260 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NE", longopts, &option); 274 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NEB", longopts, &option);
261 if (c == -1 || c == EOF) 275 if (c == -1 || c == EOF)
262 break; 276 break;
263 277
@@ -297,10 +311,10 @@ process_arguments (int argc, char **argv)
297 /* xasprintf (&http_opt_headers, "%s", optarg); */ 311 /* xasprintf (&http_opt_headers, "%s", optarg); */
298 break; 312 break;
299 case 'L': /* show html link */ 313 case 'L': /* show html link */
300 display_html = TRUE; 314 display_html = true;
301 break; 315 break;
302 case 'n': /* do not show html link */ 316 case 'n': /* do not show html link */
303 display_html = FALSE; 317 display_html = false;
304 break; 318 break;
305 case 'C': /* Check SSL cert validity */ 319 case 'C': /* Check SSL cert validity */
306#ifdef HAVE_SSL 320#ifdef HAVE_SSL
@@ -321,9 +335,14 @@ process_arguments (int argc, char **argv)
321 usage2 (_("Invalid certificate expiration period"), optarg); 335 usage2 (_("Invalid certificate expiration period"), optarg);
322 days_till_exp_warn = atoi (optarg); 336 days_till_exp_warn = atoi (optarg);
323 } 337 }
324 check_cert = TRUE; 338 check_cert = true;
325 goto enable_ssl; 339 goto enable_ssl;
326#endif 340#endif
341 case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */
342#ifdef HAVE_SSL
343 continue_after_check_cert = true;
344 break;
345#endif
327 case 'J': /* use client certificate */ 346 case 'J': /* use client certificate */
328#ifdef HAVE_SSL 347#ifdef HAVE_SSL
329 test_file(optarg); 348 test_file(optarg);
@@ -341,7 +360,7 @@ process_arguments (int argc, char **argv)
341 enable_ssl: 360 enable_ssl:
342 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple 361 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple
343 parameters, like -S and -C combinations */ 362 parameters, like -S and -C combinations */
344 use_ssl = TRUE; 363 use_ssl = true;
345 if (c=='S' && optarg != NULL) { 364 if (c=='S' && optarg != NULL) {
346 int got_plus = strchr(optarg, '+') != NULL; 365 int got_plus = strchr(optarg, '+') != NULL;
347 366
@@ -358,7 +377,7 @@ process_arguments (int argc, char **argv)
358 else 377 else
359 usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)")); 378 usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)"));
360 } 379 }
361 if (specify_port == FALSE) 380 if (specify_port == false)
362 server_port = HTTPS_PORT; 381 server_port = HTTPS_PORT;
363#else 382#else
364 /* -C -J and -K fall through to here without SSL */ 383 /* -C -J and -K fall through to here without SSL */
@@ -366,8 +385,15 @@ process_arguments (int argc, char **argv)
366#endif 385#endif
367 break; 386 break;
368 case SNI_OPTION: 387 case SNI_OPTION:
369 use_sni = TRUE; 388 use_sni = true;
370 break; 389 break;
390 case MAX_REDIRS_OPTION:
391 if (!is_intnonneg (optarg))
392 usage2 (_("Invalid max_redirs count"), optarg);
393 else {
394 max_depth = atoi (optarg);
395 }
396 break;
371 case 'f': /* onredirect */ 397 case 'f': /* onredirect */
372 if (!strcmp (optarg, "stickyport")) 398 if (!strcmp (optarg, "stickyport"))
373 onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST|STICKY_PORT; 399 onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST|STICKY_PORT;
@@ -391,11 +417,25 @@ process_arguments (int argc, char **argv)
391 case 'H': /* Host Name (virtual host) */ 417 case 'H': /* Host Name (virtual host) */
392 host_name = strdup (optarg); 418 host_name = strdup (optarg);
393 if (host_name[0] == '[') { 419 if (host_name[0] == '[') {
394 if ((p = strstr (host_name, "]:")) != NULL) /* [IPv6]:port */ 420 if ((p = strstr (host_name, "]:")) != NULL) { /* [IPv6]:port */
395 server_port = atoi (p + 2); 421 virtual_port = atoi (p + 2);
422 /* cut off the port */
423 host_name_length = strlen (host_name) - strlen (p) - 1;
424 free (host_name);
425 host_name = strndup (optarg, host_name_length);
426 if (specify_port == false)
427 server_port = virtual_port;
428 }
396 } else if ((p = strchr (host_name, ':')) != NULL 429 } else if ((p = strchr (host_name, ':')) != NULL
397 && strchr (++p, ':') == NULL) /* IPv4:port or host:port */ 430 && strchr (++p, ':') == NULL) { /* IPv4:port or host:port */
398 server_port = atoi (p); 431 virtual_port = atoi (p);
432 /* cut off the port */
433 host_name_length = strlen (host_name) - strlen (p) - 1;
434 free (host_name);
435 host_name = strndup (optarg, host_name_length);
436 if (specify_port == false)
437 server_port = virtual_port;
438 }
399 break; 439 break;
400 case 'I': /* Server IP-address */ 440 case 'I': /* Server IP-address */
401 server_address = strdup (optarg); 441 server_address = strdup (optarg);
@@ -409,7 +449,7 @@ process_arguments (int argc, char **argv)
409 usage2 (_("Invalid port number"), optarg); 449 usage2 (_("Invalid port number"), optarg);
410 else { 450 else {
411 server_port = atoi (optarg); 451 server_port = atoi (optarg);
412 specify_port = TRUE; 452 specify_port = true;
413 } 453 }
414 break; 454 break;
415 case 'a': /* authorization info */ 455 case 'a': /* authorization info */
@@ -430,6 +470,12 @@ process_arguments (int argc, char **argv)
430 if (http_method) 470 if (http_method)
431 free(http_method); 471 free(http_method);
432 http_method = strdup (optarg); 472 http_method = strdup (optarg);
473 char *tmp;
474 if ((tmp = strstr(http_method, ":")) > 0) {
475 tmp[0] = '\0';
476 http_method = http_method;
477 http_method_proxy = ++tmp;
478 }
433 break; 479 break;
434 case 'd': /* string or substring */ 480 case 'd': /* string or substring */
435 strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1); 481 strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1);
@@ -452,6 +498,7 @@ process_arguments (int argc, char **argv)
452 break; 498 break;
453 case 'R': /* regex */ 499 case 'R': /* regex */
454 cflags |= REG_ICASE; 500 cflags |= REG_ICASE;
501 // fall through
455 case 'r': /* regex */ 502 case 'r': /* regex */
456 strncpy (regexp, optarg, MAX_RE_SIZE - 1); 503 strncpy (regexp, optarg, MAX_RE_SIZE - 1);
457 regexp[MAX_RE_SIZE - 1] = 0; 504 regexp[MAX_RE_SIZE - 1] = 0;
@@ -459,7 +506,7 @@ process_arguments (int argc, char **argv)
459 if (errcode != 0) { 506 if (errcode != 0) {
460 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); 507 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
461 printf (_("Could Not Compile Regular Expression: %s"), errbuf); 508 printf (_("Could Not Compile Regular Expression: %s"), errbuf);
462 return ERROR; 509 return false;
463 } 510 }
464 break; 511 break;
465 case INVERT_REGEX: 512 case INVERT_REGEX:
@@ -476,7 +523,7 @@ process_arguments (int argc, char **argv)
476#endif 523#endif
477 break; 524 break;
478 case 'v': /* verbose */ 525 case 'v': /* verbose */
479 verbose = TRUE; 526 verbose = true;
480 break; 527 break;
481 case 'm': /* min_page_length */ 528 case 'm': /* min_page_length */
482 { 529 {
@@ -501,7 +548,7 @@ process_arguments (int argc, char **argv)
501 break; 548 break;
502 } 549 }
503 case 'N': /* no-body */ 550 case 'N': /* no-body */
504 no_body = TRUE; 551 no_body = true;
505 break; 552 break;
506 case 'M': /* max-age */ 553 case 'M': /* max-age */
507 { 554 {
@@ -522,7 +569,10 @@ process_arguments (int argc, char **argv)
522 } 569 }
523 break; 570 break;
524 case 'E': /* show extended perfdata */ 571 case 'E': /* show extended perfdata */
525 show_extended_perfdata = TRUE; 572 show_extended_perfdata = true;
573 break;
574 case 'B': /* print body content after status line */
575 show_body = true;
526 break; 576 break;
527 } 577 }
528 } 578 }
@@ -550,10 +600,16 @@ process_arguments (int argc, char **argv)
550 if (http_method == NULL) 600 if (http_method == NULL)
551 http_method = strdup ("GET"); 601 http_method = strdup ("GET");
552 602
553 if (client_cert && !client_privkey) 603 if (http_method_proxy == NULL)
604 http_method_proxy = strdup ("GET");
605
606 if (client_cert && !client_privkey)
554 usage4 (_("If you use a client certificate you must also specify a private key file")); 607 usage4 (_("If you use a client certificate you must also specify a private key file"));
555 608
556 return TRUE; 609 if (virtual_port == 0)
610 virtual_port = server_port;
611
612 return true;
557} 613}
558 614
559 615
@@ -893,10 +949,25 @@ check_http (void)
893 /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */ 949 /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */
894 950
895 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 951 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
896 && host_name != NULL && use_ssl == TRUE) { 952 && host_name != NULL && use_ssl == true) {
897 953
898 if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); 954 if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT);
899 asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); 955 asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent);
956 if (strlen(proxy_auth)) {
957 base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth);
958 xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth);
959 }
960 /* optionally send any other header tag */
961 if (http_opt_headers_count) {
962 for (i = 0; i < http_opt_headers_count ; i++) {
963 if (force_host_header != http_opt_headers[i]) {
964 xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]);
965 }
966 }
967 /* This cannot be free'd here because a redirection will then try to access this and segfault */
968 /* Covered in a testcase in tests/check_http.t */
969 /* free(http_opt_headers); */
970 }
900 asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf); 971 asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf);
901 asprintf (&buf, "%sHost: %s\r\n", buf, host_name); 972 asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
902 /* we finished our request, send empty line with CRLF */ 973 /* we finished our request, send empty line with CRLF */
@@ -912,7 +983,7 @@ check_http (void)
912 } 983 }
913#ifdef HAVE_SSL 984#ifdef HAVE_SSL
914 elapsed_time_connect = (double)microsec_connect / 1.0e6; 985 elapsed_time_connect = (double)microsec_connect / 1.0e6;
915 if (use_ssl == TRUE) { 986 if (use_ssl == true) {
916 gettimeofday (&tv_temp, NULL); 987 gettimeofday (&tv_temp, NULL);
917 result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey); 988 result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey);
918 if (verbose) printf ("SSL initialized\n"); 989 if (verbose) printf ("SSL initialized\n");
@@ -920,18 +991,20 @@ check_http (void)
920 die (STATE_CRITICAL, NULL); 991 die (STATE_CRITICAL, NULL);
921 microsec_ssl = deltime (tv_temp); 992 microsec_ssl = deltime (tv_temp);
922 elapsed_time_ssl = (double)microsec_ssl / 1.0e6; 993 elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
923 if (check_cert == TRUE) { 994 if (check_cert == true) {
924 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); 995 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
925 np_net_ssl_cleanup(); 996 if (continue_after_check_cert == false) {
926 if (sd) close(sd); 997 if (sd) close(sd);
927 return result; 998 np_net_ssl_cleanup();
999 return result;
1000 }
928 } 1001 }
929 } 1002 }
930#endif /* HAVE_SSL */ 1003#endif /* HAVE_SSL */
931 1004
932 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 1005 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
933 && host_name != NULL && use_ssl == TRUE) 1006 && host_name != NULL && use_ssl == true)
934 asprintf (&buf, "%s %s %s\r\n%s\r\n", "GET", server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); 1007 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
935 else 1008 else
936 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); 1009 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
937 1010
@@ -958,13 +1031,13 @@ check_http (void)
958 * 14.23). Some server applications/configurations cause trouble if the 1031 * 14.23). Some server applications/configurations cause trouble if the
959 * (default) port is explicitly specified in the "Host:" header line. 1032 * (default) port is explicitly specified in the "Host:" header line.
960 */ 1033 */
961 if ((use_ssl == FALSE && server_port == HTTP_PORT) || 1034 if ((use_ssl == false && virtual_port == HTTP_PORT) ||
962 (use_ssl == TRUE && server_port == HTTPS_PORT) || 1035 (use_ssl == true && virtual_port == HTTPS_PORT) ||
963 (server_address != NULL && strcmp(http_method, "CONNECT") == 0 1036 (server_address != NULL && strcmp(http_method, "CONNECT") == 0
964 && host_name != NULL && use_ssl == TRUE)) 1037 && host_name != NULL && use_ssl == true))
965 xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); 1038 xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
966 else 1039 else
967 xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); 1040 xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port);
968 } 1041 }
969 } 1042 }
970 1043
@@ -1001,9 +1074,8 @@ check_http (void)
1001 } 1074 }
1002 1075
1003 xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); 1076 xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
1004 xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); 1077 xasprintf (&buf, "%s%s", buf, http_post_data);
1005 } 1078 } else {
1006 else {
1007 /* or just a newline so the server knows we're done with the request */ 1079 /* or just a newline so the server knows we're done with the request */
1008 xasprintf (&buf, "%s%s", buf, CRLF); 1080 xasprintf (&buf, "%s%s", buf, CRLF);
1009 } 1081 }
@@ -1022,10 +1094,19 @@ check_http (void)
1022 microsec_firstbyte = deltime (tv_temp); 1094 microsec_firstbyte = deltime (tv_temp);
1023 elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6; 1095 elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6;
1024 } 1096 }
1097 while (pos = memchr(buffer, '\0', i)) {
1098 /* replace nul character with a blank */
1099 *pos = ' ';
1100 }
1025 buffer[i] = '\0'; 1101 buffer[i] = '\0';
1026 xasprintf (&full_page_new, "%s%s", full_page, buffer); 1102
1027 free (full_page); 1103 if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL)
1104 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n"));
1105
1106 memmove(&full_page_new[pagesize], buffer, i + 1);
1107
1028 full_page = full_page_new; 1108 full_page = full_page_new;
1109
1029 pagesize += i; 1110 pagesize += i;
1030 1111
1031 if (no_body && document_headers_done (full_page)) { 1112 if (no_body && document_headers_done (full_page)) {
@@ -1037,25 +1118,7 @@ check_http (void)
1037 elapsed_time_transfer = (double)microsec_transfer / 1.0e6; 1118 elapsed_time_transfer = (double)microsec_transfer / 1.0e6;
1038 1119
1039 if (i < 0 && errno != ECONNRESET) { 1120 if (i < 0 && errno != ECONNRESET) {
1040#ifdef HAVE_SSL 1121 die(STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1041 /*
1042 if (use_ssl) {
1043 sslerr=SSL_get_error(ssl, i);
1044 if ( sslerr == SSL_ERROR_SSL ) {
1045 die (STATE_WARNING, _("HTTP WARNING - Client Certificate Required\n"));
1046 } else {
1047 die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1048 }
1049 }
1050 else {
1051 */
1052#endif
1053 die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1054#ifdef HAVE_SSL
1055 /* XXX
1056 }
1057 */
1058#endif
1059 } 1122 }
1060 1123
1061 /* return a CRITICAL status if we couldn't read any data */ 1124 /* return a CRITICAL status if we couldn't read any data */
@@ -1063,10 +1126,10 @@ check_http (void)
1063 die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n")); 1126 die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n"));
1064 1127
1065 /* close the connection */ 1128 /* close the connection */
1129 if (sd) close(sd);
1066#ifdef HAVE_SSL 1130#ifdef HAVE_SSL
1067 np_net_ssl_cleanup(); 1131 np_net_ssl_cleanup();
1068#endif 1132#endif
1069 if (sd) close(sd);
1070 1133
1071 /* Save check time */ 1134 /* Save check time */
1072 microsec = deltime (tv); 1135 microsec = deltime (tv);
@@ -1117,6 +1180,8 @@ check_http (void)
1117 xasprintf (&msg, 1180 xasprintf (&msg,
1118 _("Invalid HTTP response received from host on port %d: %s\n"), 1181 _("Invalid HTTP response received from host on port %d: %s\n"),
1119 server_port, status_line); 1182 server_port, status_line);
1183 if (show_body)
1184 xasprintf (&msg, _("%s\n%s"), msg, page);
1120 die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); 1185 die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg);
1121 } 1186 }
1122 1187
@@ -1178,32 +1243,73 @@ check_http (void)
1178 } 1243 }
1179 1244
1180 /* Page and Header content checks go here */ 1245 /* Page and Header content checks go here */
1181 if (strlen (header_expect)) { 1246 if (strlen(header_expect) > 0) {
1182 if (!strstr (header, header_expect)) { 1247 if (strstr(header, header_expect) == NULL) {
1183 strncpy(&output_header_search[0],header_expect,sizeof(output_header_search)); 1248 // We did not find the header, the rest is for building the output and setting the state
1184 if(output_header_search[sizeof(output_header_search)-1]!='\0') { 1249 char output_header_search[30] = "";
1185 bcopy("...",&output_header_search[sizeof(output_header_search)-4],4); 1250
1251 strncpy(&output_header_search[0], header_expect,
1252 sizeof(output_header_search));
1253
1254 if (output_header_search[sizeof(output_header_search) - 1] != '\0') {
1255 bcopy("...",
1256 &output_header_search[sizeof(output_header_search) - 4],
1257 4);
1186 } 1258 }
1187 xasprintf (&msg, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1259
1260 xasprintf (&msg,
1261 _("%sheader '%s' not found on '%s://%s:%d%s', "),
1262 msg,
1263 output_header_search, use_ssl ? "https" : "http",
1264 host_name ? host_name : server_address, server_port,
1265 server_url);
1266
1188 result = STATE_CRITICAL; 1267 result = STATE_CRITICAL;
1189 } 1268 }
1190 } 1269 }
1191 1270
1271 // At this point we should test if the content is chunked and unchunk it, so
1272 // it can be searched (and possibly printed)
1273 const char *chunked_header_regex_string = "Transfer-Encoding: *chunked *";
1274 regex_t chunked_header_regex;
1275
1276 if (regcomp(&chunked_header_regex, chunked_header_regex_string, REG_ICASE)) {
1277 die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to compile chunked_header_regex regex");
1278 }
1279
1280 regmatch_t chre_pmatch[1]; // We actually do not care about this, since we only want to know IF it was found
1281
1282 if (!no_body && regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) {
1283 if (verbose) {
1284 printf("Found chunked content\n");
1285 }
1286 // We actually found the chunked header
1287 char *tmp = unchunk_content(page);
1288 if (tmp == NULL) {
1289 die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to unchunk message body");
1290 }
1291 page = tmp;
1292 }
1192 1293
1193 if (strlen (string_expect)) { 1294 if (strlen(string_expect) > 0) {
1194 if (!strstr (page, string_expect)) { 1295 if (!strstr(page, string_expect)) {
1195 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search)); 1296 // We found the string the body, the rest is for building the output
1196 if(output_string_search[sizeof(output_string_search)-1]!='\0') { 1297 char output_string_search[30] = "";
1197 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); 1298 strncpy(&output_string_search[0], string_expect,
1299 sizeof(output_string_search));
1300 if (output_string_search[sizeof(output_string_search) - 1] != '\0') {
1301 bcopy("...", &output_string_search[sizeof(output_string_search) - 4],
1302 4);
1198 } 1303 }
1199 xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1304 xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
1200 result = STATE_CRITICAL; 1305 result = STATE_CRITICAL;
1201 } 1306 }
1202 } 1307 }
1203 1308
1204 if (strlen (regexp)) { 1309 if (strlen(regexp) > 0) {
1205 errcode = regexec (&preg, page, REGS, pmatch, 0); 1310 errcode = regexec(&preg, page, REGS, pmatch, 0);
1206 if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) { 1311 if ((errcode == 0 && invert_regex == 0) ||
1312 (errcode == REG_NOMATCH && invert_regex == 1)) {
1207 /* OK - No-op to avoid changing the logic around it */ 1313 /* OK - No-op to avoid changing the logic around it */
1208 result = max_state_alt(STATE_OK, result); 1314 result = max_state_alt(STATE_OK, result);
1209 } 1315 }
@@ -1255,7 +1361,7 @@ check_http (void)
1255 perfd_time (elapsed_time), 1361 perfd_time (elapsed_time),
1256 perfd_size (page_len), 1362 perfd_size (page_len),
1257 perfd_time_connect (elapsed_time_connect), 1363 perfd_time_connect (elapsed_time_connect),
1258 use_ssl == TRUE ? perfd_time_ssl (elapsed_time_ssl) : "", 1364 use_ssl == true ? perfd_time_ssl (elapsed_time_ssl) : "",
1259 perfd_time_headers (elapsed_time_headers), 1365 perfd_time_headers (elapsed_time_headers),
1260 perfd_time_firstbyte (elapsed_time_firstbyte), 1366 perfd_time_firstbyte (elapsed_time_firstbyte),
1261 perfd_time_transfer (elapsed_time_transfer)); 1367 perfd_time_transfer (elapsed_time_transfer));
@@ -1267,6 +1373,9 @@ check_http (void)
1267 perfd_time (elapsed_time), 1373 perfd_time (elapsed_time),
1268 perfd_size (page_len)); 1374 perfd_size (page_len));
1269 1375
1376 if (show_body)
1377 xasprintf (&msg, _("%s\n%s"), msg, page);
1378
1270 result = max_state_alt(get_status(elapsed_time, thlds), result); 1379 result = max_state_alt(get_status(elapsed_time, thlds), result);
1271 1380
1272 die (result, "HTTP %s: %s\n", state_text(result), msg); 1381 die (result, "HTTP %s: %s\n", state_text(result), msg);
@@ -1274,7 +1383,94 @@ check_http (void)
1274 return STATE_UNKNOWN; 1383 return STATE_UNKNOWN;
1275} 1384}
1276 1385
1386/* Receivces a pointer to the beginning of the body of a HTTP message
1387 * which is chunked and returns a pointer to a freshly allocated memory
1388 * region containing the unchunked body or NULL if something failed.
1389 * The result must be freed by the caller.
1390 */
1391char *unchunk_content(const char *content) {
1392 // https://en.wikipedia.org/wiki/Chunked_transfer_encoding
1393 // https://www.rfc-editor.org/rfc/rfc7230#section-4.1
1394 char *result = NULL;
1395 char *start_of_chunk;
1396 char* end_of_chunk;
1397 long size_of_chunk;
1398 const char *pointer = content;
1399 char *endptr;
1400 long length_of_chunk = 0;
1401 size_t overall_size = 0;
1402
1403 while (true) {
1404 size_of_chunk = strtol(pointer, &endptr, 16);
1405 if (size_of_chunk == LONG_MIN || size_of_chunk == LONG_MAX) {
1406 // Apparently underflow or overflow, should not happen
1407 if (verbose) {
1408 printf("Got an underflow or overflow from strtol at: %u\n", __LINE__);
1409 }
1410 return NULL;
1411 }
1412 if (endptr == pointer) {
1413 // Apparently this was not a number
1414 if (verbose) {
1415 printf("Chunked content did not start with a number at all (Line: %u)\n", __LINE__);
1416 }
1417 return NULL;
1418 }
1419
1420 // So, we got the length of the chunk
1421 if (*endptr == ';') {
1422 // Chunk extension starts here
1423 while (*endptr != '\r') {
1424 endptr++;
1425 }
1426 }
1427
1428 start_of_chunk = endptr + 2;
1429 end_of_chunk = start_of_chunk + size_of_chunk;
1430 length_of_chunk = (long)(end_of_chunk - start_of_chunk);
1431 pointer = end_of_chunk + 2; //Next number should be here
1432
1433 if (length_of_chunk == 0) {
1434 // Chunk length is 0, so this is the last one
1435 break;
1436 }
1437
1438 overall_size += length_of_chunk;
1439
1440 if (result == NULL) {
1441 // Size of the chunk plus the ending NULL byte
1442 result = (char *)malloc(length_of_chunk +1);
1443 if (result == NULL) {
1444 if (verbose) {
1445 printf("Failed to allocate memory for unchunked body\n");
1446 }
1447 return NULL;
1448 }
1449 } else {
1450 // Enlarge memory to the new size plus the ending NULL byte
1451 void *tmp = realloc(result, overall_size +1);
1452 if (tmp == NULL) {
1453 if (verbose) {
1454 printf("Failed to allocate memory for unchunked body\n");
1455 }
1456 return NULL;
1457 } else {
1458 result = tmp;
1459 }
1460 }
1461
1462 memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk);
1463 }
1277 1464
1465 if (overall_size == 0 && result == NULL) {
1466 // We might just have received the end chunk without previous content, so result is never allocated
1467 result = calloc(1, sizeof(char));
1468 // No error handling here, we can only return NULL anyway
1469 } else {
1470 result[overall_size] = '\0';
1471 }
1472 return result;
1473}
1278 1474
1279/* per RFC 2396 */ 1475/* per RFC 2396 */
1280#define URI_HTTP "%5[HTPShtps]" 1476#define URI_HTTP "%5[HTPShtps]"
@@ -1285,7 +1481,9 @@ check_http (void)
1285#define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH 1481#define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH
1286#define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT 1482#define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT
1287#define HD4 URI_HTTP "://" URI_HOST 1483#define HD4 URI_HTTP "://" URI_HOST
1288#define HD5 URI_PATH 1484/* relative reference redirect like //www.site.org/test https://tools.ietf.org/html/rfc3986 */
1485#define HD5 "//" URI_HOST "/" URI_PATH
1486#define HD6 URI_PATH
1289 1487
1290void 1488void
1291redir (char *pos, char *status_line) 1489redir (char *pos, char *status_line)
@@ -1362,9 +1560,21 @@ redir (char *pos, char *status_line)
1362 use_ssl = server_type_check (type); 1560 use_ssl = server_type_check (type);
1363 i = server_port_check (use_ssl); 1561 i = server_port_check (use_ssl);
1364 } 1562 }
1563 /* URI_HTTP, URI_HOST, URI_PATH */
1564 else if (sscanf (pos, HD5, addr, url) == 2) {
1565 if(use_ssl){
1566 strcpy (type,"https");
1567 }
1568 else{
1569 strcpy (type, server_type);
1570 }
1571 xasprintf (&url, "/%s", url);
1572 use_ssl = server_type_check (type);
1573 i = server_port_check (use_ssl);
1574 }
1365 1575
1366 /* URI_PATH */ 1576 /* URI_PATH */
1367 else if (sscanf (pos, HD5, url) == 1) { 1577 else if (sscanf (pos, HD6, url) == 1) {
1368 /* relative url */ 1578 /* relative url */
1369 if ((url[0] != '/')) { 1579 if ((url[0] != '/')) {
1370 if ((x = strrchr(server_url, '/'))) 1580 if ((x = strrchr(server_url, '/')))
@@ -1395,8 +1605,8 @@ redir (char *pos, char *status_line)
1395 !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) && 1605 !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) &&
1396 (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) && 1606 (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) &&
1397 !strcmp(server_url, url)) 1607 !strcmp(server_url, url))
1398 die (STATE_WARNING, 1608 die (STATE_CRITICAL,
1399 _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"), 1609 _("HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"),
1400 type, addr, i, url, (display_html ? "</A>" : "")); 1610 type, addr, i, url, (display_html ? "</A>" : ""));
1401 1611
1402 strcpy (server_type, type); 1612 strcpy (server_type, type);
@@ -1421,6 +1631,9 @@ redir (char *pos, char *status_line)
1421 MAX_PORT, server_type, server_address, server_port, server_url, 1631 MAX_PORT, server_type, server_address, server_port, server_url,
1422 display_html ? "</A>" : ""); 1632 display_html ? "</A>" : "");
1423 1633
1634 /* reset virtual port */
1635 virtual_port = server_port;
1636
1424 if (verbose) 1637 if (verbose)
1425 printf (_("Redirection to %s://%s:%d%s\n"), server_type, 1638 printf (_("Redirection to %s://%s:%d%s\n"), server_type,
1426 host_name ? host_name : server_address, server_port, server_url); 1639 host_name ? host_name : server_address, server_port, server_url);
@@ -1430,13 +1643,13 @@ redir (char *pos, char *status_line)
1430} 1643}
1431 1644
1432 1645
1433int 1646bool
1434server_type_check (const char *type) 1647server_type_check (const char *type)
1435{ 1648{
1436 if (strcmp (type, "https")) 1649 if (strcmp (type, "https"))
1437 return FALSE; 1650 return false;
1438 else 1651 else
1439 return TRUE; 1652 return true;
1440} 1653}
1441 1654
1442int 1655int
@@ -1451,42 +1664,42 @@ server_port_check (int ssl_flag)
1451char *perfd_time (double elapsed_time) 1664char *perfd_time (double elapsed_time)
1452{ 1665{
1453 return fperfdata ("time", elapsed_time, "s", 1666 return fperfdata ("time", elapsed_time, "s",
1454 thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0, 1667 thlds->warning?true:false, thlds->warning?thlds->warning->end:0,
1455 thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0, 1668 thlds->critical?true:false, thlds->critical?thlds->critical->end:0,
1456 TRUE, 0, FALSE, 0); 1669 true, 0, true, socket_timeout);
1457} 1670}
1458 1671
1459char *perfd_time_connect (double elapsed_time_connect) 1672char *perfd_time_connect (double elapsed_time_connect)
1460{ 1673{
1461 return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); 1674 return fperfdata ("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1462} 1675}
1463 1676
1464char *perfd_time_ssl (double elapsed_time_ssl) 1677char *perfd_time_ssl (double elapsed_time_ssl)
1465{ 1678{
1466 return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); 1679 return fperfdata ("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1467} 1680}
1468 1681
1469char *perfd_time_headers (double elapsed_time_headers) 1682char *perfd_time_headers (double elapsed_time_headers)
1470{ 1683{
1471 return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); 1684 return fperfdata ("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1472} 1685}
1473 1686
1474char *perfd_time_firstbyte (double elapsed_time_firstbyte) 1687char *perfd_time_firstbyte (double elapsed_time_firstbyte)
1475{ 1688{
1476 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); 1689 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1477} 1690}
1478 1691
1479char *perfd_time_transfer (double elapsed_time_transfer) 1692char *perfd_time_transfer (double elapsed_time_transfer)
1480{ 1693{
1481 return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0); 1694 return fperfdata ("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1482} 1695}
1483 1696
1484char *perfd_size (int page_len) 1697char *perfd_size (int page_len)
1485{ 1698{
1486 return perfdata ("size", page_len, "B", 1699 return perfdata ("size", page_len, "B",
1487 (min_page_len>0?TRUE:FALSE), min_page_len, 1700 (min_page_len>0?true:false), min_page_len,
1488 (min_page_len>0?TRUE:FALSE), 0, 1701 (min_page_len>0?true:false), 0,
1489 TRUE, 0, FALSE, 0); 1702 true, 0, false, 0);
1490} 1703}
1491 1704
1492void 1705void
@@ -1506,6 +1719,10 @@ print_help (void)
1506 1719
1507 print_usage (); 1720 print_usage ();
1508 1721
1722#ifdef HAVE_SSL
1723 printf (_("In the first form, make an HTTP request."));
1724 printf (_("In the second form, connect to the server and check the TLS certificate."));
1725#endif
1509 printf (_("NOTE: One or both of -H and -I must be specified")); 1726 printf (_("NOTE: One or both of -H and -I must be specified"));
1510 1727
1511 printf ("\n"); 1728 printf ("\n");
@@ -1533,7 +1750,11 @@ print_help (void)
1533 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)")); 1750 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
1534 printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]"); 1751 printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
1535 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443")); 1752 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
1536 printf (" %s\n", _("(when this option is used the URL is not checked.)")); 1753 printf (" %s\n", _("(when this option is used the URL is not checked by default. You can use"));
1754 printf (" %s\n", _(" --continue-after-certificate to override this behavior)"));
1755 printf (" %s\n", "--continue-after-certificate");
1756 printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check."));
1757 printf (" %s\n", _("Does nothing unless -C is used."));
1537 printf (" %s\n", "-J, --client-cert=FILE"); 1758 printf (" %s\n", "-J, --client-cert=FILE");
1538 printf (" %s\n", _("Name of file that contains the client certificate (PEM format)")); 1759 printf (" %s\n", _("Name of file that contains the client certificate (PEM format)"));
1539 printf (" %s\n", _("to be used in establishing the SSL session")); 1760 printf (" %s\n", _("to be used in establishing the SSL session"));
@@ -1555,7 +1776,7 @@ print_help (void)
1555 printf (" %s\n", _("URL to GET or POST (default: /)")); 1776 printf (" %s\n", _("URL to GET or POST (default: /)"));
1556 printf (" %s\n", "-P, --post=STRING"); 1777 printf (" %s\n", "-P, --post=STRING");
1557 printf (" %s\n", _("URL encoded http POST data")); 1778 printf (" %s\n", _("URL encoded http POST data"));
1558 printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)"); 1779 printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT, CONNECT:POST)");
1559 printf (" %s\n", _("Set HTTP method.")); 1780 printf (" %s\n", _("Set HTTP method."));
1560 printf (" %s\n", "-N, --no-body"); 1781 printf (" %s\n", "-N, --no-body");
1561 printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); 1782 printf (" %s\n", _("Don't wait for document body: stop reading after headers."));
@@ -1585,14 +1806,18 @@ print_help (void)
1585 printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers")); 1806 printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers"));
1586 printf (" %s\n", "-E, --extended-perfdata"); 1807 printf (" %s\n", "-E, --extended-perfdata");
1587 printf (" %s\n", _("Print additional performance data")); 1808 printf (" %s\n", _("Print additional performance data"));
1809 printf (" %s\n", "-B, --show-body");
1810 printf (" %s\n", _("Print body content below status line"));
1588 printf (" %s\n", "-L, --link"); 1811 printf (" %s\n", "-L, --link");
1589 printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); 1812 printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)"));
1590 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>"); 1813 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>");
1591 printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the")); 1814 printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the"));
1592 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same.")); 1815 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same."));
1816 printf (" %s\n", "--max-redirs=INTEGER");
1817 printf (" %s", _("Maximal number of redirects (default: "));
1818 printf ("%d)\n", DEFAULT_MAX_REDIRS);
1593 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); 1819 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>");
1594 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)")); 1820 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));
1595
1596 printf (UT_WARN_CRIT); 1821 printf (UT_WARN_CRIT);
1597 1822
1598 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1823 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
@@ -1603,7 +1828,7 @@ print_help (void)
1603 printf ("%s\n", _("Notes:")); 1828 printf ("%s\n", _("Notes:"));
1604 printf (" %s\n", _("This plugin will attempt to open an HTTP connection with the host.")); 1829 printf (" %s\n", _("This plugin will attempt to open an HTTP connection with the host."));
1605 printf (" %s\n", _("Successful connects return STATE_OK, refusals and timeouts return STATE_CRITICAL")); 1830 printf (" %s\n", _("Successful connects return STATE_OK, refusals and timeouts return STATE_CRITICAL"));
1606 printf (" %s\n", _("other errors return STATE_UNKNOWN. Successful connects, but incorrect reponse")); 1831 printf (" %s\n", _("other errors return STATE_UNKNOWN. Successful connects, but incorrect response"));
1607 printf (" %s\n", _("messages from the host result in STATE_WARNING return values. If you are")); 1832 printf (" %s\n", _("messages from the host result in STATE_WARNING return values. If you are"));
1608 printf (" %s\n", _("checking a virtual server that uses 'host headers' you must supply the FQDN")); 1833 printf (" %s\n", _("checking a virtual server that uses 'host headers' you must supply the FQDN"));
1609 printf (" %s\n", _("(fully qualified domain name) as the [host_name] argument.")); 1834 printf (" %s\n", _("(fully qualified domain name) as the [host_name] argument."));
@@ -1642,7 +1867,8 @@ print_help (void)
1642 printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>")); 1867 printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>"));
1643 printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds")); 1868 printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds"));
1644 printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,")); 1869 printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,"));
1645 printf (" %s\n", _("a STATE_CRITICAL will be returned.")); 1870 printf (" %s\n", _("a STATE_CRITICAL will be returned. By adding a colon to the method you can set the method used"));
1871 printf (" %s\n", _("inside the proxied connection: -j CONNECT:POST"));
1646 1872
1647#endif 1873#endif
1648 1874
@@ -1659,9 +1885,11 @@ print_usage (void)
1659 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname); 1885 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
1660 printf (" [-J <client certificate file>] [-K <private key>]\n"); 1886 printf (" [-J <client certificate file>] [-K <private key>]\n");
1661 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n"); 1887 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n");
1662 printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); 1888 printf (" [-b proxy_auth] [-f <ok|warning|critical|follow|sticky|stickyport>]\n");
1663 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); 1889 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
1664 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); 1890 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
1665 printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); 1891 printf (" [-A string] [-k string] [-S <version>] [--sni]\n");
1666 printf (" [-T <content-type>] [-j method]\n"); 1892 printf (" [-T <content-type>] [-j method]\n");
1893 printf (" %s -H <vhost> | -I <IP-address> -C <warn_age>[,<crit_age>]\n",progname);
1894 printf (" [-p <port>] [-t <timeout>] [-4|-6] [--sni]\n");
1667} 1895}
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c
index 8d540ca1..0160d98b 100644
--- a/plugins/check_ide_smart.c
+++ b/plugins/check_ide_smart.c
@@ -166,7 +166,6 @@ enum SmartCommand
166 166
167char *get_offline_text (int); 167char *get_offline_text (int);
168int smart_read_values (int, values_t *); 168int smart_read_values (int, values_t *);
169int values_not_passed (values_t *, thresholds_t *);
170int nagios (values_t *, thresholds_t *); 169int nagios (values_t *, thresholds_t *);
171void print_value (value_t *, threshold_t *); 170void print_value (value_t *, threshold_t *);
172void print_values (values_t *, thresholds_t *); 171void print_values (values_t *, thresholds_t *);
@@ -284,7 +283,7 @@ get_offline_text (int status)
284 return offline_status_text[i].text; 283 return offline_status_text[i].text;
285 } 284 }
286 } 285 }
287 return "UNKNOW"; 286 return "UNKNOWN";
288} 287}
289 288
290 289
@@ -340,31 +339,6 @@ smart_read_values (int fd, values_t * values)
340 339
341 340
342int 341int
343values_not_passed (values_t * p, thresholds_t * t)
344{
345 value_t * value = p->values;
346 threshold_t * threshold = t->thresholds;
347 int failed = 0;
348 int passed = 0;
349 int i;
350 for (i = 0; i < NR_ATTRIBUTES; i++) {
351 if (value->id && threshold->id && value->id == threshold->id) {
352 if (value->value < threshold->threshold) {
353 ++failed;
354 }
355 else {
356 ++passed;
357 }
358 }
359 ++value;
360 ++threshold;
361 }
362 return (passed ? -failed : 2);
363}
364
365
366
367int
368nagios (values_t * p, thresholds_t * t) 342nagios (values_t * p, thresholds_t * t)
369{ 343{
370 value_t * value = p->values; 344 value_t * value = p->values;
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index 66be4b46..a1bfe1be 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -222,7 +222,7 @@ main (int argc, char *argv[])
222 /* reset the alarm handler */ 222 /* reset the alarm handler */
223 alarm (0); 223 alarm (0);
224 224
225 /* calcutate the elapsed time and compare to thresholds */ 225 /* calculate the elapsed time and compare to thresholds */
226 226
227 microsec = deltime (tv); 227 microsec = deltime (tv);
228 elapsed_time = (double)microsec / 1.0e6; 228 elapsed_time = (double)microsec / 1.0e6;
@@ -237,7 +237,7 @@ main (int argc, char *argv[])
237 if(entries_thresholds != NULL) { 237 if(entries_thresholds != NULL) {
238 if (verbose) { 238 if (verbose) {
239 printf ("entries found: %d\n", num_entries); 239 printf ("entries found: %d\n", num_entries);
240 print_thresholds("entry threasholds", entries_thresholds); 240 print_thresholds("entry thresholds", entries_thresholds);
241 } 241 }
242 status_entries = get_status(num_entries, entries_thresholds); 242 status_entries = get_status(num_entries, entries_thresholds);
243 if (status_entries == STATE_CRITICAL) { 243 if (status_entries == STATE_CRITICAL) {
@@ -432,6 +432,9 @@ validate_arguments ()
432 set_thresholds(&entries_thresholds, 432 set_thresholds(&entries_thresholds,
433 warn_entries, crit_entries); 433 warn_entries, crit_entries);
434 } 434 }
435 if (ld_passwd==NULL)
436 ld_passwd = getenv("LDAP_PASSWORD");
437
435 return OK; 438 return OK;
436} 439}
437 440
@@ -465,7 +468,7 @@ print_help (void)
465 printf (" %s\n", "-D [--bind]"); 468 printf (" %s\n", "-D [--bind]");
466 printf (" %s\n", _("ldap bind DN (if required)")); 469 printf (" %s\n", _("ldap bind DN (if required)"));
467 printf (" %s\n", "-P [--pass]"); 470 printf (" %s\n", "-P [--pass]");
468 printf (" %s\n", _("ldap password (if required)")); 471 printf (" %s\n", _("ldap password (if required, or set the password through environment variable 'LDAP_PASSWORD')"));
469 printf (" %s\n", "-T [--starttls]"); 472 printf (" %s\n", "-T [--starttls]");
470 printf (" %s\n", _("use starttls mechanism introduced in protocol version 3")); 473 printf (" %s\n", _("use starttls mechanism introduced in protocol version 3"));
471 printf (" %s\n", "-S [--ssl]"); 474 printf (" %s\n", "-S [--ssl]");
diff --git a/plugins/check_load.c b/plugins/check_load.c
index a96435f4..313df8ad 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -1,40 +1,43 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_load plugin 3* Monitoring check_load plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Monitoring Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_load plugin 10* This file contains the check_load plugin
11* 11*
12* This plugin tests the current system load average. 12* This plugin tests the current system load average.
13* 13*
14* 14*
15* This program is free software: you can redistribute it and/or modify 15* This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17* the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18* (at your option) any later version.
19* 19*
20* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23* GNU General Public License for more details.
24* 24*
25* You should have received a copy of the GNU General Public License 25* You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26* along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27*
28* 28*
29*****************************************************************************/ 29*****************************************************************************/
30 30
31const char *progname = "check_load"; 31const char *progname = "check_load";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2022";
33const char *email = "devel@monitoring-plugins.org"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "./common.h"
36#include "utils.h" 36#include "./runcmd.h"
37#include "popen.h" 37#include "./utils.h"
38#include "./popen.h"
39
40#include <string.h>
38 41
39#ifdef HAVE_SYS_LOADAVG_H 42#ifdef HAVE_SYS_LOADAVG_H
40#include <sys/loadavg.h> 43#include <sys/loadavg.h>
@@ -52,6 +55,9 @@ static int process_arguments (int argc, char **argv);
52static int validate_arguments (void); 55static int validate_arguments (void);
53void print_help (void); 56void print_help (void);
54void print_usage (void); 57void print_usage (void);
58static int print_top_consuming_processes();
59
60static int n_procs_to_show = 0;
55 61
56/* strictly for pretty-print usage in loops */ 62/* strictly for pretty-print usage in loops */
57static const int nums[3] = { 1, 5, 15 }; 63static const int nums[3] = { 1, 5, 15 };
@@ -64,7 +70,7 @@ double cload[3] = { 0.0, 0.0, 0.0 };
64#define la15 la[2] 70#define la15 la[2]
65 71
66char *status_line; 72char *status_line;
67int take_into_account_cpus = 0; 73bool take_into_account_cpus = false;
68 74
69static void 75static void
70get_threshold(char *arg, double *th) 76get_threshold(char *arg, double *th)
@@ -97,11 +103,11 @@ get_threshold(char *arg, double *th)
97int 103int
98main (int argc, char **argv) 104main (int argc, char **argv)
99{ 105{
100 int result; 106 int result = -1;
101 int i; 107 int i;
102 long numcpus; 108 long numcpus;
103 109
104 double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about unitialized arrays */ 110 double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about uninitialized arrays */
105#ifndef HAVE_GETLOADAVG 111#ifndef HAVE_GETLOADAVG
106 char input_buffer[MAX_INPUT_BUFFER]; 112 char input_buffer[MAX_INPUT_BUFFER];
107# ifdef HAVE_PROC_LOADAVG 113# ifdef HAVE_PROC_LOADAVG
@@ -160,7 +166,7 @@ main (int argc, char **argv)
160 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15); 166 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
161 } 167 }
162 else { 168 else {
163 printf (_("could not parse load from uptime: %s\n"), result, PATH_TO_UPTIME); 169 printf (_("could not parse load from uptime %s: %d\n"), PATH_TO_UPTIME, result);
164 return STATE_UNKNOWN; 170 return STATE_UNKNOWN;
165 } 171 }
166 172
@@ -172,13 +178,6 @@ main (int argc, char **argv)
172# endif 178# endif
173#endif 179#endif
174 180
175 if (take_into_account_cpus == 1) {
176 if ((numcpus = GET_NUMBER_OF_CPUS()) > 0) {
177 la[0] = la[0] / numcpus;
178 la[1] = la[1] / numcpus;
179 la[2] = la[2] / numcpus;
180 }
181 }
182 if ((la[0] < 0.0) || (la[1] < 0.0) || (la[2] < 0.0)) { 181 if ((la[0] < 0.0) || (la[1] < 0.0) || (la[2] < 0.0)) {
183#ifdef HAVE_GETLOADAVG 182#ifdef HAVE_GETLOADAVG
184 printf (_("Error in getloadavg()\n")); 183 printf (_("Error in getloadavg()\n"));
@@ -196,20 +195,54 @@ main (int argc, char **argv)
196 result = STATE_OK; 195 result = STATE_OK;
197 196
198 xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15); 197 xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
198 xasprintf(&status_line, ("total %s"), status_line);
199
200
201 double scaled_la[3] = { 0.0, 0.0, 0.0 };
202 bool is_using_scaled_load_values = false;
203
204 if (take_into_account_cpus == true && (numcpus = GET_NUMBER_OF_CPUS()) > 0) {
205 is_using_scaled_load_values = true;
206
207 scaled_la[0] = la[0] / numcpus;
208 scaled_la[1] = la[1] / numcpus;
209 scaled_la[2] = la[2] / numcpus;
210
211 char *tmp = NULL;
212 xasprintf(&tmp, _("load average: %.2f, %.2f, %.2f"), scaled_la[0], scaled_la[1], scaled_la[2]);
213 xasprintf(&status_line, "scaled %s - %s", tmp, status_line);
214 }
199 215
200 for(i = 0; i < 3; i++) { 216 for(i = 0; i < 3; i++) {
201 if(la[i] > cload[i]) { 217 if (is_using_scaled_load_values) {
202 result = STATE_CRITICAL; 218 if(scaled_la[i] > cload[i]) {
203 break; 219 result = STATE_CRITICAL;
220 break;
221 }
222 else if(scaled_la[i] > wload[i]) result = STATE_WARNING;
223 } else {
224 if(la[i] > cload[i]) {
225 result = STATE_CRITICAL;
226 break;
227 }
228 else if(la[i] > wload[i]) result = STATE_WARNING;
204 } 229 }
205 else if(la[i] > wload[i]) result = STATE_WARNING;
206 } 230 }
207 231
208 printf("%s - %s|", state_text(result), status_line); 232 printf("LOAD %s - %s|", state_text(result), status_line);
209 for(i = 0; i < 3; i++) 233 for(i = 0; i < 3; i++) {
210 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]); 234 if (is_using_scaled_load_values) {
235 printf("load%d=%.3f;;;0; ", nums[i], la[i]);
236 printf("scaled_load%d=%.3f;%.3f;%.3f;0; ", nums[i], scaled_la[i], wload[i], cload[i]);
237 } else {
238 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]);
239 }
240 }
211 241
212 putchar('\n'); 242 putchar('\n');
243 if (n_procs_to_show > 0) {
244 print_top_consuming_processes();
245 }
213 return result; 246 return result;
214} 247}
215 248
@@ -227,6 +260,7 @@ process_arguments (int argc, char **argv)
227 {"percpu", no_argument, 0, 'r'}, 260 {"percpu", no_argument, 0, 'r'},
228 {"version", no_argument, 0, 'V'}, 261 {"version", no_argument, 0, 'V'},
229 {"help", no_argument, 0, 'h'}, 262 {"help", no_argument, 0, 'h'},
263 {"procs-to-show", required_argument, 0, 'n'},
230 {0, 0, 0, 0} 264 {0, 0, 0, 0}
231 }; 265 };
232 266
@@ -234,7 +268,7 @@ process_arguments (int argc, char **argv)
234 return ERROR; 268 return ERROR;
235 269
236 while (1) { 270 while (1) {
237 c = getopt_long (argc, argv, "Vhrc:w:", longopts, &option); 271 c = getopt_long (argc, argv, "Vhrc:w:n:", longopts, &option);
238 272
239 if (c == -1 || c == EOF) 273 if (c == -1 || c == EOF)
240 break; 274 break;
@@ -247,7 +281,7 @@ process_arguments (int argc, char **argv)
247 get_threshold(optarg, cload); 281 get_threshold(optarg, cload);
248 break; 282 break;
249 case 'r': /* Divide load average by number of CPUs */ 283 case 'r': /* Divide load average by number of CPUs */
250 take_into_account_cpus = 1; 284 take_into_account_cpus = true;
251 break; 285 break;
252 case 'V': /* version */ 286 case 'V': /* version */
253 print_revision (progname, NP_VERSION); 287 print_revision (progname, NP_VERSION);
@@ -255,6 +289,9 @@ process_arguments (int argc, char **argv)
255 case 'h': /* help */ 289 case 'h': /* help */
256 print_help (); 290 print_help ();
257 exit (STATE_UNKNOWN); 291 exit (STATE_UNKNOWN);
292 case 'n':
293 n_procs_to_show = atoi(optarg);
294 break;
258 case '?': /* help */ 295 case '?': /* help */
259 usage5 (); 296 usage5 ();
260 } 297 }
@@ -278,7 +315,6 @@ process_arguments (int argc, char **argv)
278} 315}
279 316
280 317
281
282static int 318static int
283validate_arguments (void) 319validate_arguments (void)
284{ 320{
@@ -299,7 +335,6 @@ validate_arguments (void)
299} 335}
300 336
301 337
302
303void 338void
304print_help (void) 339print_help (void)
305{ 340{
@@ -310,7 +345,7 @@ print_help (void)
310 345
311 printf (_("This plugin tests the current system load average.")); 346 printf (_("This plugin tests the current system load average."));
312 347
313 printf ("\n\n"); 348 printf ("\n\n");
314 349
315 print_usage (); 350 print_usage ();
316 351
@@ -318,12 +353,15 @@ print_help (void)
318 printf (UT_EXTRA_OPTS); 353 printf (UT_EXTRA_OPTS);
319 354
320 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15"); 355 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15");
321 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn")); 356 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn"));
322 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15"); 357 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15");
323 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn")); 358 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn"));
324 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\"")); 359 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\""));
325 printf (" %s\n", "-r, --percpu"); 360 printf (" %s\n", "-r, --percpu");
326 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)")); 361 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)"));
362 printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS");
363 printf (" %s\n", _("Number of processes to show when printing the top consuming processes."));
364 printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0"));
327 365
328 printf (UT_SUPPORT); 366 printf (UT_SUPPORT);
329} 367}
@@ -331,6 +369,49 @@ print_help (void)
331void 369void
332print_usage (void) 370print_usage (void)
333{ 371{
334 printf ("%s\n", _("Usage:")); 372 printf ("%s\n", _("Usage:"));
335 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n", progname); 373 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname);
374}
375
376#ifdef PS_USES_PROCPCPU
377int cmpstringp(const void *p1, const void *p2) {
378 int procuid = 0;
379 int procpid = 0;
380 int procppid = 0;
381 int procvsz = 0;
382 int procrss = 0;
383 float procpcpu = 0;
384 char procstat[8];
385#ifdef PS_USES_PROCETIME
386 char procetime[MAX_INPUT_BUFFER];
387#endif /* PS_USES_PROCETIME */
388 char procprog[MAX_INPUT_BUFFER];
389 int pos;
390 sscanf (* (char * const *) p1, PS_FORMAT, PS_VARLIST);
391 float procpcpu1 = procpcpu;
392 sscanf (* (char * const *) p2, PS_FORMAT, PS_VARLIST);
393 return procpcpu1 < procpcpu;
394}
395#endif /* PS_USES_PROCPCPU */
396
397static int print_top_consuming_processes() {
398 int i = 0;
399 struct output chld_out, chld_err;
400 if(np_runcmd(PS_COMMAND, &chld_out, &chld_err, 0) != 0){
401 fprintf(stderr, _("'%s' exited with non-zero status.\n"), PS_COMMAND);
402 return STATE_UNKNOWN;
403 }
404 if (chld_out.lines < 2) {
405 fprintf(stderr, _("some error occurred getting procs list.\n"));
406 return STATE_UNKNOWN;
407 }
408#ifdef PS_USES_PROCPCPU
409 qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp);
410#endif /* PS_USES_PROCPCPU */
411 int lines_to_show = chld_out.lines < (size_t)(n_procs_to_show + 1)
412 ? (int)chld_out.lines : n_procs_to_show + 1;
413 for (i = 0; i < lines_to_show; i += 1) {
414 printf("%s\n", chld_out.line[i]);
415 }
416 return OK;
336} 417}
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 5773afd9..7d855544 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -34,7 +34,7 @@ const char *progname = "check_mysql";
34const char *copyright = "1999-2011"; 34const char *copyright = "1999-2011";
35const char *email = "devel@monitoring-plugins.org"; 35const char *email = "devel@monitoring-plugins.org";
36 36
37#define SLAVERESULTSIZE 70 37#define SLAVERESULTSIZE 96
38 38
39#include "common.h" 39#include "common.h"
40#include "utils.h" 40#include "utils.h"
@@ -89,6 +89,8 @@ static const char *metric_counter[LENGTH_METRIC_COUNTER] = {
89 "Uptime" 89 "Uptime"
90}; 90};
91 91
92#define MYSQLDUMP_THREADS_QUERY "SELECT COUNT(1) mysqldumpThreads FROM information_schema.processlist WHERE info LIKE 'SELECT /*!40001 SQL_NO_CACHE */%'"
93
92thresholds *my_threshold = NULL; 94thresholds *my_threshold = NULL;
93 95
94int process_arguments (int, char **); 96int process_arguments (int, char **);
@@ -108,7 +110,7 @@ main (int argc, char **argv)
108 110
109 char *result = NULL; 111 char *result = NULL;
110 char *error = NULL; 112 char *error = NULL;
111 char slaveresult[SLAVERESULTSIZE]; 113 char slaveresult[SLAVERESULTSIZE] = { 0 };
112 char* perf; 114 char* perf;
113 115
114 perf = strdup (""); 116 perf = strdup ("");
@@ -138,7 +140,10 @@ main (int argc, char **argv)
138 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers); 140 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
139 /* establish a connection to the server and error checking */ 141 /* establish a connection to the server and error checking */
140 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { 142 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
141 if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR) 143 /* Depending on internally-selected auth plugin MySQL might return */
144 /* ER_ACCESS_DENIED_NO_PASSWORD_ERROR or ER_ACCESS_DENIED_ERROR. */
145 /* Semantically these errors are the same. */
146 if (ignore_auth && (mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR || mysql_errno (&mysql) == ER_ACCESS_DENIED_NO_PASSWORD_ERROR))
142 { 147 {
143 printf("MySQL OK - Version: %s (protocol %d)\n", 148 printf("MySQL OK - Version: %s (protocol %d)\n",
144 mysql_get_server_info(&mysql), 149 mysql_get_server_info(&mysql),
@@ -275,11 +280,30 @@ main (int argc, char **argv)
275 /* Save slave status in slaveresult */ 280 /* Save slave status in slaveresult */
276 snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown"); 281 snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown");
277 282
278 /* Raise critical error if SQL THREAD or IO THREAD are stopped */ 283 /* Raise critical error if SQL THREAD or IO THREAD are stopped, but only if there are no mysqldump threads running */
279 if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) { 284 if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) {
280 mysql_free_result (res); 285 MYSQL_RES *res_mysqldump;
281 mysql_close (&mysql); 286 MYSQL_ROW row_mysqldump;
282 die (STATE_CRITICAL, "%s\n", slaveresult); 287 unsigned int mysqldump_threads = 0;
288
289 if (mysql_query (&mysql, MYSQLDUMP_THREADS_QUERY) == 0) {
290 /* store the result */
291 if ( (res_mysqldump = mysql_store_result (&mysql)) != NULL) {
292 if (mysql_num_rows(res_mysqldump) == 1) {
293 if ( (row_mysqldump = mysql_fetch_row (res_mysqldump)) != NULL) {
294 mysqldump_threads = atoi(row_mysqldump[0]);
295 }
296 }
297 /* free the result */
298 mysql_free_result (res_mysqldump);
299 }
300 mysql_close (&mysql);
301 }
302 if (mysqldump_threads == 0) {
303 die (STATE_CRITICAL, "%s\n", slaveresult);
304 } else {
305 strncat(slaveresult, " Mysqldump: in progress", SLAVERESULTSIZE-1);
306 }
283 } 307 }
284 308
285 if (verbose >=3) { 309 if (verbose >=3) {
@@ -291,7 +315,7 @@ main (int argc, char **argv)
291 } 315 }
292 316
293 /* Check Seconds Behind against threshold */ 317 /* Check Seconds Behind against threshold */
294 if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) { 318 if ((seconds_behind_field != -1) && (row[seconds_behind_field] != NULL && strcmp (row[seconds_behind_field], "NULL") != 0)) {
295 double value = atof(row[seconds_behind_field]); 319 double value = atof(row[seconds_behind_field]);
296 int status; 320 int status;
297 321
@@ -379,6 +403,9 @@ process_arguments (int argc, char **argv)
379 if (is_host (optarg)) { 403 if (is_host (optarg)) {
380 db_host = optarg; 404 db_host = optarg;
381 } 405 }
406 else if (*optarg == '/') {
407 db_socket = optarg;
408 }
382 else { 409 else {
383 usage2 (_("Invalid hostname/address"), optarg); 410 usage2 (_("Invalid hostname/address"), optarg);
384 } 411 }
@@ -548,7 +575,7 @@ print_help (void)
548 printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds")); 575 printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds"));
549 printf (" %s\n", _("behind master")); 576 printf (" %s\n", _("behind master"));
550 printf (" %s\n", "-l, --ssl"); 577 printf (" %s\n", "-l, --ssl");
551 printf (" %s\n", _("Use ssl encryptation")); 578 printf (" %s\n", _("Use ssl encryption"));
552 printf (" %s\n", "-C, --ca-cert=STRING"); 579 printf (" %s\n", "-C, --ca-cert=STRING");
553 printf (" %s\n", _("Path to CA signing the cert")); 580 printf (" %s\n", _("Path to CA signing the cert"));
554 printf (" %s\n", "-a, --cert=STRING"); 581 printf (" %s\n", "-a, --cert=STRING");
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index 49a14dd3..ac2fb15d 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -136,18 +136,18 @@ main (int argc, char **argv)
136 die (STATE_CRITICAL, "QUERY %s: Fetch row error - %s\n", _("CRITICAL"), error); 136 die (STATE_CRITICAL, "QUERY %s: Fetch row error - %s\n", _("CRITICAL"), error);
137 } 137 }
138 138
139 /* free the result */
140 mysql_free_result (res);
141
142 /* close the connection */
143 mysql_close (&mysql);
144
145 if (! is_numeric(row[0])) { 139 if (! is_numeric(row[0])) {
146 die (STATE_CRITICAL, "QUERY %s: %s - '%s'\n", _("CRITICAL"), _("Is not a numeric"), row[0]); 140 die (STATE_CRITICAL, "QUERY %s: %s - '%s'\n", _("CRITICAL"), _("Is not a numeric"), row[0]);
147 } 141 }
148 142
149 value = strtod(row[0], NULL); 143 value = strtod(row[0], NULL);
150 144
145 /* free the result */
146 mysql_free_result (res);
147
148 /* close the connection */
149 mysql_close (&mysql);
150
151 if (verbose >= 3) 151 if (verbose >= 3)
152 printf("mysql result: %f\n", value); 152 printf("mysql result: %f\n", value);
153 153
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 59c135db..d73d83ce 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -341,7 +341,7 @@ int main(int argc, char **argv){
341 341
342 2) If the counter you're going to measure is percent-based, the code will detect 342 2) If the counter you're going to measure is percent-based, the code will detect
343 the percent sign in its name and will attribute minimum (0%) and maximum (100%) 343 the percent sign in its name and will attribute minimum (0%) and maximum (100%)
344 values automagically, as well the ¨%" sign to graph units. 344 values automagically, as well the "%" sign to graph units.
345 345
346 3) OTOH, if the counter is "absolute", you'll have to provide the following 346 3) OTOH, if the counter is "absolute", you'll have to provide the following
347 the counter unit - that is, the dimensions of the counter you're getting. Examples: 347 the counter unit - that is, the dimensions of the counter you're getting. Examples:
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 75efc289..99537c88 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -10,7 +10,7 @@
10* 10*
11* This file contains the check_ntp plugin 11* This file contains the check_ntp plugin
12* 12*
13* This plugin to check ntp servers independant of any commandline 13* This plugin to check ntp servers independent of any commandline
14* programs or external libraries. 14* programs or external libraries.
15* 15*
16* 16*
@@ -79,7 +79,7 @@ typedef struct {
79/* this structure holds data about results from querying offset from a peer */ 79/* this structure holds data about results from querying offset from a peer */
80typedef struct { 80typedef struct {
81 time_t waiting; /* ts set when we started waiting for a response */ 81 time_t waiting; /* ts set when we started waiting for a response */
82 int num_responses; /* number of successfully recieved responses */ 82 int num_responses; /* number of successfully received responses */
83 uint8_t stratum; /* copied verbatim from the ntp_message */ 83 uint8_t stratum; /* copied verbatim from the ntp_message */
84 double rtdelay; /* converted from the ntp_message */ 84 double rtdelay; /* converted from the ntp_message */
85 double rtdisp; /* converted from the ntp_message */ 85 double rtdisp; /* converted from the ntp_message */
@@ -100,7 +100,7 @@ typedef struct {
100 /* NB: not necessarily NULL terminated! */ 100 /* NB: not necessarily NULL terminated! */
101} ntp_control_message; 101} ntp_control_message;
102 102
103/* this is an association/status-word pair found in control packet reponses */ 103/* this is an association/status-word pair found in control packet responses */
104typedef struct { 104typedef struct {
105 uint16_t assoc; 105 uint16_t assoc;
106 uint16_t status; 106 uint16_t status;
@@ -297,7 +297,7 @@ void setup_request(ntp_message *p){
297 * this is done by filtering servers based on stratum, dispersion, and 297 * this is done by filtering servers based on stratum, dispersion, and
298 * finally round-trip delay. */ 298 * finally round-trip delay. */
299int best_offset_server(const ntp_server_results *slist, int nservers){ 299int best_offset_server(const ntp_server_results *slist, int nservers){
300 int i=0, cserver=0, best_server=-1; 300 int cserver=0, best_server=-1;
301 301
302 /* for each server */ 302 /* for each server */
303 for(cserver=0; cserver<nservers; cserver++){ 303 for(cserver=0; cserver<nservers; cserver++){
@@ -355,8 +355,8 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
355 * - we also "manually" handle resolving host names and connecting, because 355 * - we also "manually" handle resolving host names and connecting, because
356 * we have to do it in a way that our lazy macros don't handle currently :( */ 356 * we have to do it in a way that our lazy macros don't handle currently :( */
357double offset_request(const char *host, int *status){ 357double offset_request(const char *host, int *status){
358 int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; 358 int i=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
359 int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1; 359 int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
360 time_t now_time=0, start_ts=0; 360 time_t now_time=0, start_ts=0;
361 ntp_message *req=NULL; 361 ntp_message *req=NULL;
362 double avg_offset=0.; 362 double avg_offset=0.;
@@ -421,7 +421,6 @@ double offset_request(const char *host, int *status){
421 * been touched in the past second or so and is still lacking 421 * been touched in the past second or so and is still lacking
422 * some responses. for each of these servers, send a new request, 422 * some responses. for each of these servers, send a new request,
423 * and update the "waiting" timestamp with the current time. */ 423 * and update the "waiting" timestamp with the current time. */
424 one_written=0;
425 now_time=time(NULL); 424 now_time=time(NULL);
426 425
427 for(i=0; i<num_hosts; i++){ 426 for(i=0; i<num_hosts; i++){
@@ -431,7 +430,6 @@ double offset_request(const char *host, int *status){
431 setup_request(&req[i]); 430 setup_request(&req[i]);
432 write(socklist[i], &req[i], sizeof(ntp_message)); 431 write(socklist[i], &req[i], sizeof(ntp_message));
433 servers[i].waiting=now_time; 432 servers[i].waiting=now_time;
434 one_written=1;
435 break; 433 break;
436 } 434 }
437 } 435 }
@@ -488,9 +486,9 @@ double offset_request(const char *host, int *status){
488 } 486 }
489 487
490 /* cleanup */ 488 /* cleanup */
491 /* FIXME: Not closing the socket to avoid re-use of the local port 489 /* FIXME: Not closing the socket to avoid reuse of the local port
492 * which can cause old NTP packets to be read instead of NTP control 490 * which can cause old NTP packets to be read instead of NTP control
493 * pactets in jitter_request(). THERE MUST BE ANOTHER WAY... 491 * packets in jitter_request(). THERE MUST BE ANOTHER WAY...
494 * for(j=0; j<num_hosts; j++){ close(socklist[j]); } */ 492 * for(j=0; j<num_hosts; j++){ close(socklist[j]); } */
495 free(socklist); 493 free(socklist);
496 free(ufds); 494 free(ufds);
@@ -514,7 +512,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
514} 512}
515 513
516/* XXX handle responses with the error bit set */ 514/* XXX handle responses with the error bit set */
517double jitter_request(const char *host, int *status){ 515double jitter_request(int *status){
518 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0; 516 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
519 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; 517 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
520 int peers_size=0, peer_offset=0; 518 int peers_size=0, peer_offset=0;
@@ -550,7 +548,7 @@ double jitter_request(const char *host, int *status){
550 DBG(print_ntp_control_message(&req)); 548 DBG(print_ntp_control_message(&req));
551 /* Attempt to read the largest size packet possible */ 549 /* Attempt to read the largest size packet possible */
552 req.count=htons(MAX_CM_SIZE); 550 req.count=htons(MAX_CM_SIZE);
553 DBG(printf("recieving READSTAT response")) 551 DBG(printf("receiving READSTAT response"))
554 read(conn, &req, SIZEOF_NTPCM(req)); 552 read(conn, &req, SIZEOF_NTPCM(req));
555 DBG(print_ntp_control_message(&req)); 553 DBG(print_ntp_control_message(&req));
556 /* Each peer identifier is 4 bytes in the data section, which 554 /* Each peer identifier is 4 bytes in the data section, which
@@ -577,7 +575,7 @@ double jitter_request(const char *host, int *status){
577 } 575 }
578 } 576 }
579 } 577 }
580 if(verbose) printf("%d candiate peers available\n", num_candidates); 578 if(verbose) printf("%d candidate peers available\n", num_candidates);
581 if(verbose && syncsource_found) printf("synchronization source found\n"); 579 if(verbose && syncsource_found) printf("synchronization source found\n");
582 if(! syncsource_found){ 580 if(! syncsource_found){
583 *status = STATE_UNKNOWN; 581 *status = STATE_UNKNOWN;
@@ -599,7 +597,7 @@ double jitter_request(const char *host, int *status){
599 /* By spec, putting the variable name "jitter" in the request 597 /* By spec, putting the variable name "jitter" in the request
600 * should cause the server to provide _only_ the jitter value. 598 * should cause the server to provide _only_ the jitter value.
601 * thus reducing net traffic, guaranteeing us only a single 599 * thus reducing net traffic, guaranteeing us only a single
602 * datagram in reply, and making intepretation much simpler 600 * datagram in reply, and making interpretation much simpler
603 */ 601 */
604 /* Older servers doesn't know what jitter is, so if we get an 602 /* Older servers doesn't know what jitter is, so if we get an
605 * error on the first pass we redo it with "dispersion" */ 603 * error on the first pass we redo it with "dispersion" */
@@ -610,7 +608,7 @@ double jitter_request(const char *host, int *status){
610 DBG(print_ntp_control_message(&req)); 608 DBG(print_ntp_control_message(&req));
611 609
612 req.count = htons(MAX_CM_SIZE); 610 req.count = htons(MAX_CM_SIZE);
613 DBG(printf("recieving READVAR response...\n")); 611 DBG(printf("receiving READVAR response...\n"));
614 read(conn, &req, SIZEOF_NTPCM(req)); 612 read(conn, &req, SIZEOF_NTPCM(req));
615 DBG(print_ntp_control_message(&req)); 613 DBG(print_ntp_control_message(&req));
616 614
@@ -805,7 +803,7 @@ int main(int argc, char *argv[]){
805 * (for example) will result in an error 803 * (for example) will result in an error
806 */ 804 */
807 if(do_jitter){ 805 if(do_jitter){
808 jitter=jitter_request(server_address, &jitter_result); 806 jitter=jitter_request(&jitter_result);
809 result = max_state_alt(result, get_status(jitter, jitter_thresholds)); 807 result = max_state_alt(result, get_status(jitter, jitter_thresholds));
810 /* -1 indicates that we couldn't calculate the jitter 808 /* -1 indicates that we couldn't calculate the jitter
811 * Only overrides STATE_OK from the offset */ 809 * Only overrides STATE_OK from the offset */
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index c656b0f5..49cb1008 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -86,7 +86,7 @@ typedef struct {
86 /* NB: not necessarily NULL terminated! */ 86 /* NB: not necessarily NULL terminated! */
87} ntp_control_message; 87} ntp_control_message;
88 88
89/* this is an association/status-word pair found in control packet reponses */ 89/* this is an association/status-word pair found in control packet responses */
90typedef struct { 90typedef struct {
91 uint16_t assoc; 91 uint16_t assoc;
92 uint16_t status; 92 uint16_t status;
@@ -189,7 +189,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
189} 189}
190 190
191/* This function does all the actual work; roughly here's what it does 191/* This function does all the actual work; roughly here's what it does
192 * beside setting the offest, jitter and stratum passed as argument: 192 * beside setting the offset, jitter and stratum passed as argument:
193 * - offset can be negative, so if it cannot get the offset, offset_result 193 * - offset can be negative, so if it cannot get the offset, offset_result
194 * is set to UNKNOWN, otherwise OK. 194 * is set to UNKNOWN, otherwise OK.
195 * - jitter and stratum are set to -1 if they cannot be retrieved so any 195 * - jitter and stratum are set to -1 if they cannot be retrieved so any
@@ -199,7 +199,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
199 * status is pretty much useless as syncsource_found is a global variable 199 * status is pretty much useless as syncsource_found is a global variable
200 * used later in main to check is the server was synchronized. It works 200 * used later in main to check is the server was synchronized. It works
201 * so I left it alone */ 201 * so I left it alone */
202int ntp_request(const char *host, double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){ 202int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){
203 int conn=-1, i, npeers=0, num_candidates=0; 203 int conn=-1, i, npeers=0, num_candidates=0;
204 double tmp_offset = 0; 204 double tmp_offset = 0;
205 int min_peer_sel=PEER_INCLUDED; 205 int min_peer_sel=PEER_INCLUDED;
@@ -245,7 +245,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
245 do { 245 do {
246 /* Attempt to read the largest size packet possible */ 246 /* Attempt to read the largest size packet possible */
247 req.count=htons(MAX_CM_SIZE); 247 req.count=htons(MAX_CM_SIZE);
248 DBG(printf("recieving READSTAT response")) 248 DBG(printf("receiving READSTAT response"))
249 if(read(conn, &req, SIZEOF_NTPCM(req)) == -1) 249 if(read(conn, &req, SIZEOF_NTPCM(req)) == -1)
250 die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n"); 250 die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n");
251 DBG(print_ntp_control_message(&req)); 251 DBG(print_ntp_control_message(&req));
@@ -306,7 +306,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
306 /* Putting the wanted variable names in the request 306 /* Putting the wanted variable names in the request
307 * cause the server to provide _only_ the requested values. 307 * cause the server to provide _only_ the requested values.
308 * thus reducing net traffic, guaranteeing us only a single 308 * thus reducing net traffic, guaranteeing us only a single
309 * datagram in reply, and making intepretation much simpler 309 * datagram in reply, and making interpretation much simpler
310 */ 310 */
311 /* Older servers doesn't know what jitter is, so if we get an 311 /* Older servers doesn't know what jitter is, so if we get an
312 * error on the first pass we redo it with "dispersion" */ 312 * error on the first pass we redo it with "dispersion" */
@@ -585,8 +585,8 @@ int main(int argc, char *argv[]){
585 /* set socket timeout */ 585 /* set socket timeout */
586 alarm (socket_timeout); 586 alarm (socket_timeout);
587 587
588 /* This returns either OK or WARNING (See comment preceeding ntp_request) */ 588 /* This returns either OK or WARNING (See comment preceding ntp_request) */
589 result = ntp_request(server_address, &offset, &offset_result, &jitter, &stratum, &num_truechimers); 589 result = ntp_request(&offset, &offset_result, &jitter, &stratum, &num_truechimers);
590 590
591 if(offset_result == STATE_UNKNOWN) { 591 if(offset_result == STATE_UNKNOWN) {
592 /* if there's no sync peer (this overrides ntp_request output): */ 592 /* if there's no sync peer (this overrides ntp_request output): */
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index 295f86f6..46cc604f 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -81,7 +81,7 @@ typedef struct {
81/* this structure holds data about results from querying offset from a peer */ 81/* this structure holds data about results from querying offset from a peer */
82typedef struct { 82typedef struct {
83 time_t waiting; /* ts set when we started waiting for a response */ 83 time_t waiting; /* ts set when we started waiting for a response */
84 int num_responses; /* number of successfully recieved responses */ 84 int num_responses; /* number of successfully received responses */
85 uint8_t stratum; /* copied verbatim from the ntp_message */ 85 uint8_t stratum; /* copied verbatim from the ntp_message */
86 double rtdelay; /* converted from the ntp_message */ 86 double rtdelay; /* converted from the ntp_message */
87 double rtdisp; /* converted from the ntp_message */ 87 double rtdisp; /* converted from the ntp_message */
@@ -244,7 +244,7 @@ void setup_request(ntp_message *p){
244 * this is done by filtering servers based on stratum, dispersion, and 244 * this is done by filtering servers based on stratum, dispersion, and
245 * finally round-trip delay. */ 245 * finally round-trip delay. */
246int best_offset_server(const ntp_server_results *slist, int nservers){ 246int best_offset_server(const ntp_server_results *slist, int nservers){
247 int i=0, cserver=0, best_server=-1; 247 int cserver=0, best_server=-1;
248 248
249 /* for each server */ 249 /* for each server */
250 for(cserver=0; cserver<nservers; cserver++){ 250 for(cserver=0; cserver<nservers; cserver++){
@@ -303,7 +303,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
303 * we have to do it in a way that our lazy macros don't handle currently :( */ 303 * we have to do it in a way that our lazy macros don't handle currently :( */
304double offset_request(const char *host, int *status){ 304double offset_request(const char *host, int *status){
305 int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; 305 int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
306 int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1; 306 int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
307 time_t now_time=0, start_ts=0; 307 time_t now_time=0, start_ts=0;
308 ntp_message *req=NULL; 308 ntp_message *req=NULL;
309 double avg_offset=0.; 309 double avg_offset=0.;
@@ -368,7 +368,6 @@ double offset_request(const char *host, int *status){
368 * been touched in the past second or so and is still lacking 368 * been touched in the past second or so and is still lacking
369 * some responses. For each of these servers, send a new request, 369 * some responses. For each of these servers, send a new request,
370 * and update the "waiting" timestamp with the current time. */ 370 * and update the "waiting" timestamp with the current time. */
371 one_written=0;
372 now_time=time(NULL); 371 now_time=time(NULL);
373 372
374 for(i=0; i<num_hosts; i++){ 373 for(i=0; i<num_hosts; i++){
@@ -378,7 +377,6 @@ double offset_request(const char *host, int *status){
378 setup_request(&req[i]); 377 setup_request(&req[i]);
379 write(socklist[i], &req[i], sizeof(ntp_message)); 378 write(socklist[i], &req[i], sizeof(ntp_message));
380 servers[i].waiting=now_time; 379 servers[i].waiting=now_time;
381 one_written=1;
382 break; 380 break;
383 } 381 }
384 } 382 }
@@ -635,7 +633,7 @@ void print_help(void){
635 printf("%s\n", _("Notes:")); 633 printf("%s\n", _("Notes:"));
636 printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use")); 634 printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use"));
637 printf(" %s\n", _("check_ntp_peer.")); 635 printf(" %s\n", _("check_ntp_peer."));
638 printf(" %s\n", _("--time-offset is usefull for compensating for servers with known")); 636 printf(" %s\n", _("--time-offset is useful for compensating for servers with known"));
639 printf(" %s\n", _("and expected clock skew.")); 637 printf(" %s\n", _("and expected clock skew."));
640 printf("\n"); 638 printf("\n");
641 printf(UT_THRESHOLDS_NOTES); 639 printf(UT_THRESHOLDS_NOTES);
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index e7e8de05..3c9d23e2 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -1668,7 +1668,7 @@ void print_help(void)
1668 1668
1669 printf ("\n"); 1669 printf ("\n");
1670 printf ("%s\n", _("Notes:")); 1670 printf ("%s\n", _("Notes:"));
1671 printf (" %s\n", _("- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG")); 1671 printf (" %s\n", _("- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"));
1672 printf (" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check.")); 1672 printf (" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check."));
1673 printf (" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)")); 1673 printf (" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)"));
1674 printf (" %s\n", _("- Values for critical thresholds should be lower than warning thresholds")); 1674 printf (" %s\n", _("- Values for critical thresholds should be lower than warning thresholds"));
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 2eb699e8..61990335 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -34,6 +34,7 @@ const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "utils.h" 36#include "utils.h"
37#include "utils_cmd.h"
37 38
38#include "netutils.h" 39#include "netutils.h"
39#include <libpq-fe.h> 40#include <libpq-fe.h>
@@ -68,7 +69,6 @@ int process_arguments (int, char **);
68int validate_arguments (void); 69int validate_arguments (void);
69void print_usage (void); 70void print_usage (void);
70void print_help (void); 71void print_help (void);
71int is_pg_dbname (char *);
72int is_pg_logname (char *); 72int is_pg_logname (char *);
73int do_query (PGconn *, char *); 73int do_query (PGconn *, char *);
74 74
@@ -84,6 +84,8 @@ char *pgparams = NULL;
84double twarn = (double)DEFAULT_WARN; 84double twarn = (double)DEFAULT_WARN;
85double tcrit = (double)DEFAULT_CRIT; 85double tcrit = (double)DEFAULT_CRIT;
86char *pgquery = NULL; 86char *pgquery = NULL;
87#define OPTID_QUERYNAME -1000
88char *pgqueryname = NULL;
87char *query_warning = NULL; 89char *query_warning = NULL;
88char *query_critical = NULL; 90char *query_critical = NULL;
89thresholds *qthresholds = NULL; 91thresholds *qthresholds = NULL;
@@ -91,7 +93,7 @@ int verbose = 0;
91 93
92/****************************************************************************** 94/******************************************************************************
93 95
94The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@ 96The (pseudo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
95tags in the comments. With in the tags, the XML is assembled sequentially. 97tags in the comments. With in the tags, the XML is assembled sequentially.
96You can define entities in tags. You also have all the #defines available as 98You can define entities in tags. You also have all the #defines available as
97entities. 99entities.
@@ -284,6 +286,7 @@ process_arguments (int argc, char **argv)
284 {"database", required_argument, 0, 'd'}, 286 {"database", required_argument, 0, 'd'},
285 {"option", required_argument, 0, 'o'}, 287 {"option", required_argument, 0, 'o'},
286 {"query", required_argument, 0, 'q'}, 288 {"query", required_argument, 0, 'q'},
289 {"queryname", required_argument, 0, OPTID_QUERYNAME},
287 {"query_critical", required_argument, 0, 'C'}, 290 {"query_critical", required_argument, 0, 'C'},
288 {"query_warning", required_argument, 0, 'W'}, 291 {"query_warning", required_argument, 0, 'W'},
289 {"verbose", no_argument, 0, 'v'}, 292 {"verbose", no_argument, 0, 'v'},
@@ -343,10 +346,10 @@ process_arguments (int argc, char **argv)
343 pgport = optarg; 346 pgport = optarg;
344 break; 347 break;
345 case 'd': /* database name */ 348 case 'd': /* database name */
346 if (!is_pg_dbname (optarg)) /* checks length and valid chars */ 349 if (strlen(optarg) >= NAMEDATALEN) {
347 usage2 (_("Database name is not valid"), optarg); 350 usage2 (_("Database name exceeds the maximum length"), optarg);
348 else /* we know length, and know optarg is terminated, so us strcpy */ 351 }
349 strcpy (dbName, optarg); 352 snprintf(dbName, NAMEDATALEN, "%s", optarg);
350 break; 353 break;
351 case 'l': /* login name */ 354 case 'l': /* login name */
352 if (!is_pg_logname (optarg)) 355 if (!is_pg_logname (optarg))
@@ -367,6 +370,9 @@ process_arguments (int argc, char **argv)
367 case 'q': 370 case 'q':
368 pgquery = optarg; 371 pgquery = optarg;
369 break; 372 break;
373 case OPTID_QUERYNAME:
374 pgqueryname = optarg;
375 break;
370 case 'v': 376 case 'v':
371 verbose++; 377 verbose++;
372 break; 378 break;
@@ -407,45 +413,6 @@ validate_arguments ()
407 return OK; 413 return OK;
408} 414}
409 415
410
411/******************************************************************************
412
413@@-
414<sect3>
415<title>is_pg_dbname</title>
416
417<para>&PROTO_is_pg_dbname;</para>
418
419<para>Given a database name, this function returns TRUE if the string
420is a valid PostgreSQL database name, and returns false if it is
421not.</para>
422
423<para>Valid PostgreSQL database names are less than &NAMEDATALEN;
424characters long and consist of letters, numbers, and underscores. The
425first character cannot be a number, however.</para>
426
427</sect3>
428-@@
429******************************************************************************/
430
431
432
433int
434is_pg_dbname (char *dbname)
435{
436 char txt[NAMEDATALEN];
437 char tmp[NAMEDATALEN];
438 if (strlen (dbname) > NAMEDATALEN - 1)
439 return (FALSE);
440 strncpy (txt, dbname, NAMEDATALEN - 1);
441 txt[NAMEDATALEN - 1] = 0;
442 if (sscanf (txt, "%[_a-zA-Z]%[^_a-zA-Z0-9-]", tmp, tmp) == 1)
443 return (TRUE);
444 if (sscanf (txt, "%[_a-zA-Z]%[_a-zA-Z0-9-]%[^_a-zA-Z0-9-]", tmp, tmp, tmp) ==
445 2) return (TRUE);
446 return (FALSE);
447}
448
449/** 416/**
450 417
451the tango program should eventually create an entity here based on the 418the tango program should eventually create an entity here based on the
@@ -528,6 +495,9 @@ print_help (void)
528 495
529 printf (" %s\n", "-q, --query=STRING"); 496 printf (" %s\n", "-q, --query=STRING");
530 printf (" %s\n", _("SQL query to run. Only first column in first row will be read")); 497 printf (" %s\n", _("SQL query to run. Only first column in first row will be read"));
498 printf (" %s\n", "--queryname=STRING");
499 printf (" %s\n", _("A name for the query, this string is used instead of the query"));
500 printf (" %s\n", _("in the long output of the plugin"));
531 printf (" %s\n", "-W, --query-warning=RANGE"); 501 printf (" %s\n", "-W, --query-warning=RANGE");
532 printf (" %s\n", _("SQL query value to result in warning status (double)")); 502 printf (" %s\n", _("SQL query value to result in warning status (double)"));
533 printf (" %s\n", "-C, --query-critical=RANGE"); 503 printf (" %s\n", "-C, --query-critical=RANGE");
@@ -547,7 +517,10 @@ print_help (void)
547 printf (" %s\n", _("connecting to the server. The result from the query has to be numeric.")); 517 printf (" %s\n", _("connecting to the server. The result from the query has to be numeric."));
548 printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result ")); 518 printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result "));
549 printf (" %s\n", _("of the last command is taken into account only. The value of the first")); 519 printf (" %s\n", _("of the last command is taken into account only. The value of the first"));
550 printf (" %s\n\n", _("column in the first row is used as the check result.")); 520 printf (" %s\n", _("column in the first row is used as the check result. If a second column is"));
521 printf (" %s\n", _("present in the result set, this is added to the plugin output with a"));
522 printf (" %s\n", _("prefix of \"Extra Info:\". This information can be displayed in the system"));
523 printf (" %s\n\n", _("executing the plugin."));
551 524
552 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual")); 525 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"));
553 printf (" %s\n\n", _("for details about how to access internal statistics of the database server.")); 526 printf (" %s\n\n", _("for details about how to access internal statistics of the database server."));
@@ -565,7 +538,7 @@ print_help (void)
565 538
566 printf (" %s\n", _("Typically, the monitoring user (unless the --logname option is used) should be")); 539 printf (" %s\n", _("Typically, the monitoring user (unless the --logname option is used) should be"));
567 printf (" %s\n", _("able to connect to the database without a password. The plugin can also send")); 540 printf (" %s\n", _("able to connect to the database without a password. The plugin can also send"));
568 printf (" %s\n", _("a password, but no effort is made to obsure or encrypt the password.")); 541 printf (" %s\n", _("a password, but no effort is made to obscure or encrypt the password."));
569 542
570 printf (UT_SUPPORT); 543 printf (UT_SUPPORT);
571} 544}
@@ -587,6 +560,7 @@ do_query (PGconn *conn, char *query)
587 PGresult *res; 560 PGresult *res;
588 561
589 char *val_str; 562 char *val_str;
563 char *extra_info;
590 double value; 564 double value;
591 565
592 char *endptr = NULL; 566 char *endptr = NULL;
@@ -641,10 +615,22 @@ do_query (PGconn *conn, char *query)
641 : (my_status == STATE_CRITICAL) 615 : (my_status == STATE_CRITICAL)
642 ? _("CRITICAL") 616 ? _("CRITICAL")
643 : _("UNKNOWN")); 617 : _("UNKNOWN"));
644 printf (_("'%s' returned %f"), query, value); 618 if(pgqueryname) {
619 printf (_("%s returned %f"), pgqueryname, value);
620 }
621 else {
622 printf (_("'%s' returned %f"), query, value);
623 }
624
645 printf ("|query=%f;%s;%s;;\n", value, 625 printf ("|query=%f;%s;%s;;\n", value,
646 query_warning ? query_warning : "", 626 query_warning ? query_warning : "",
647 query_critical ? query_critical : ""); 627 query_critical ? query_critical : "");
628 if (PQnfields (res) > 1) {
629 extra_info = PQgetvalue (res, 0, 1);
630 if (extra_info != NULL) {
631 printf ("Extra Info: %s\n", extra_info);
632 }
633 }
648 return my_status; 634 return my_status;
649} 635}
650 636
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 423ecbe5..741f732e 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -37,6 +37,8 @@ const char *email = "devel@monitoring-plugins.org";
37#include "popen.h" 37#include "popen.h"
38#include "utils.h" 38#include "utils.h"
39 39
40#include <signal.h>
41
40#define WARN_DUPLICATES "DUPLICATES FOUND! " 42#define WARN_DUPLICATES "DUPLICATES FOUND! "
41#define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */ 43#define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */
42 44
@@ -138,7 +140,7 @@ main (int argc, char **argv)
138 if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) { 140 if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) {
139 printf ("%s\n", cmd); 141 printf ("%s\n", cmd);
140 die (STATE_UNKNOWN, 142 die (STATE_UNKNOWN,
141 _("CRITICAL - Could not interpret output from ping command\n")); 143 _("CRITICAL - Could not interpret output from ping command\n"));
142 } 144 }
143 145
144 if (pl >= cpl || rta >= crta || rta < 0) 146 if (pl >= cpl || rta >= crta || rta < 0)
@@ -163,10 +165,14 @@ main (int argc, char **argv)
163 printf ("</A>"); 165 printf ("</A>");
164 166
165 /* Print performance data */ 167 /* Print performance data */
166 printf("|%s", fperfdata ("rta", (double) rta, "ms", 168 if (pl != 100) {
167 wrta>0?TRUE:FALSE, wrta, 169 printf("|%s", fperfdata ("rta", (double) rta, "ms",
168 crta>0?TRUE:FALSE, crta, 170 wrta>0?TRUE:FALSE, wrta,
169 TRUE, 0, FALSE, 0)); 171 crta>0?TRUE:FALSE, crta,
172 TRUE, 0, FALSE, 0));
173 } else {
174 printf("| rta=U;%f;%f;;", wrta, crta);
175 }
170 printf(" %s\n", perfdata ("pl", (long) pl, "%", 176 printf(" %s\n", perfdata ("pl", (long) pl, "%",
171 wpl>0?TRUE:FALSE, wpl, 177 wpl>0?TRUE:FALSE, wpl,
172 cpl>0?TRUE:FALSE, cpl, 178 cpl>0?TRUE:FALSE, cpl,
@@ -521,12 +527,13 @@ int
521error_scan (char buf[MAX_INPUT_BUFFER], const char *addr) 527error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
522{ 528{
523 if (strstr (buf, "Network is unreachable") || 529 if (strstr (buf, "Network is unreachable") ||
524 strstr (buf, "Destination Net Unreachable") 530 strstr (buf, "Destination Net Unreachable") ||
531 strstr (buf, "No route")
525 ) 532 )
526 die (STATE_CRITICAL, _("CRITICAL - Network Unreachable (%s)\n"), addr); 533 die (STATE_CRITICAL, _("CRITICAL - Network Unreachable (%s)\n"), addr);
527 else if (strstr (buf, "Destination Host Unreachable")) 534 else if (strstr (buf, "Destination Host Unreachable") || strstr(buf, "Address unreachable"))
528 die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)\n"), addr); 535 die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)\n"), addr);
529 else if (strstr (buf, "Destination Port Unreachable")) 536 else if (strstr (buf, "Destination Port Unreachable") || strstr(buf, "Port unreachable"))
530 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"), addr); 537 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"), addr);
531 else if (strstr (buf, "Destination Protocol Unreachable")) 538 else if (strstr (buf, "Destination Protocol Unreachable"))
532 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"), addr); 539 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"), addr);
@@ -534,11 +541,11 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
534 die (STATE_CRITICAL, _("CRITICAL - Network Prohibited (%s)\n"), addr); 541 die (STATE_CRITICAL, _("CRITICAL - Network Prohibited (%s)\n"), addr);
535 else if (strstr (buf, "Destination Host Prohibited")) 542 else if (strstr (buf, "Destination Host Prohibited"))
536 die (STATE_CRITICAL, _("CRITICAL - Host Prohibited (%s)\n"), addr); 543 die (STATE_CRITICAL, _("CRITICAL - Host Prohibited (%s)\n"), addr);
537 else if (strstr (buf, "Packet filtered")) 544 else if (strstr (buf, "Packet filtered") || strstr(buf, "Administratively prohibited"))
538 die (STATE_CRITICAL, _("CRITICAL - Packet Filtered (%s)\n"), addr); 545 die (STATE_CRITICAL, _("CRITICAL - Packet Filtered (%s)\n"), addr);
539 else if (strstr (buf, "unknown host" )) 546 else if (strstr (buf, "unknown host" ))
540 die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)\n"), addr); 547 die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)\n"), addr);
541 else if (strstr (buf, "Time to live exceeded")) 548 else if (strstr (buf, "Time to live exceeded") || strstr(buf, "Time exceeded"))
542 die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)\n"), addr); 549 die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)\n"), addr);
543 else if (strstr (buf, "Destination unreachable: ")) 550 else if (strstr (buf, "Destination unreachable: "))
544 die (STATE_CRITICAL, _("CRITICAL - Destination Unreachable (%s)\n"), addr); 551 die (STATE_CRITICAL, _("CRITICAL - Destination Unreachable (%s)\n"), addr);
@@ -547,7 +554,7 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
547 if (warn_text == NULL) 554 if (warn_text == NULL)
548 warn_text = strdup (_(WARN_DUPLICATES)); 555 warn_text = strdup (_(WARN_DUPLICATES));
549 else if (! strstr (warn_text, _(WARN_DUPLICATES)) && 556 else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
550 xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1) 557 xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
551 die (STATE_UNKNOWN, _("Unable to realloc warn_text\n")); 558 die (STATE_UNKNOWN, _("Unable to realloc warn_text\n"));
552 return (STATE_WARNING); 559 return (STATE_WARNING);
553 } 560 }
@@ -567,7 +574,7 @@ print_help (void)
567 574
568 printf (_("Use ping to check connection statistics for a remote host.")); 575 printf (_("Use ping to check connection statistics for a remote host."));
569 576
570 printf ("\n\n"); 577 printf ("\n\n");
571 578
572 print_usage (); 579 print_usage ();
573 580
@@ -577,29 +584,29 @@ print_help (void)
577 printf (UT_IPv46); 584 printf (UT_IPv46);
578 585
579 printf (" %s\n", "-H, --hostname=HOST"); 586 printf (" %s\n", "-H, --hostname=HOST");
580 printf (" %s\n", _("host to ping")); 587 printf (" %s\n", _("host to ping"));
581 printf (" %s\n", "-w, --warning=THRESHOLD"); 588 printf (" %s\n", "-w, --warning=THRESHOLD");
582 printf (" %s\n", _("warning threshold pair")); 589 printf (" %s\n", _("warning threshold pair"));
583 printf (" %s\n", "-c, --critical=THRESHOLD"); 590 printf (" %s\n", "-c, --critical=THRESHOLD");
584 printf (" %s\n", _("critical threshold pair")); 591 printf (" %s\n", _("critical threshold pair"));
585 printf (" %s\n", "-p, --packets=INTEGER"); 592 printf (" %s\n", "-p, --packets=INTEGER");
586 printf (" %s ", _("number of ICMP ECHO packets to send")); 593 printf (" %s ", _("number of ICMP ECHO packets to send"));
587 printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS); 594 printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS);
588 printf (" %s\n", "-L, --link"); 595 printf (" %s\n", "-L, --link");
589 printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)")); 596 printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)"));
590 597
591 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 598 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
592 599
593 printf ("\n"); 600 printf ("\n");
594 printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel")); 601 printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"));
595 printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the")); 602 printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"));
596 printf ("%s\n", _("percentage of packet loss to trigger an alarm state.")); 603 printf ("%s\n", _("percentage of packet loss to trigger an alarm state."));
597 604
598 printf ("\n"); 605 printf ("\n");
599 printf ("%s\n", _("This plugin uses the ping command to probe the specified host for packet loss")); 606 printf ("%s\n", _("This plugin uses the ping command to probe the specified host for packet loss"));
600 printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output")); 607 printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output"));
601 printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in")); 608 printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"));
602 printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/")); 609 printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/"));
603 610
604 printf (UT_SUPPORT); 611 printf (UT_SUPPORT);
605} 612}
@@ -607,7 +614,7 @@ print_help (void)
607void 614void
608print_usage (void) 615print_usage (void)
609{ 616{
610 printf ("%s\n", _("Usage:")); 617 printf ("%s\n", _("Usage:"));
611 printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname); 618 printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname);
612 printf (" [-p packets] [-t timeout] [-4|-6]\n"); 619 printf (" [-p packets] [-t timeout] [-4|-6]\n");
613} 620}
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 4bcc56bc..c17c6996 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -1,34 +1,34 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_procs plugin 3* Monitoring check_procs plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2008 Monitoring Plugins Development Team 6* Copyright (c) 2000-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_procs plugin 10* This file contains the check_procs plugin
11* 11*
12* Checks all processes and generates WARNING or CRITICAL states if the 12* Checks all processes and generates WARNING or CRITICAL states if the
13* specified metric is outside the required threshold ranges. The metric 13* specified metric is outside the required threshold ranges. The metric
14* defaults to number of processes. Search filters can be applied to limit 14* defaults to number of processes. Search filters can be applied to limit
15* the processes to check. 15* the processes to check.
16* 16*
17* 17*
18* This program is free software: you can redistribute it and/or modify 18* This program is free software: you can redistribute it and/or modify
19* it under the terms of the GNU General Public License as published by 19* it under the terms of the GNU General Public License as published by
20* the Free Software Foundation, either version 3 of the License, or 20* the Free Software Foundation, either version 3 of the License, or
21* (at your option) any later version. 21* (at your option) any later version.
22* 22*
23* This program is distributed in the hope that it will be useful, 23* This program is distributed in the hope that it will be useful,
24* but WITHOUT ANY WARRANTY; without even the implied warranty of 24* but WITHOUT ANY WARRANTY; without even the implied warranty of
25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26* GNU General Public License for more details. 26* GNU General Public License for more details.
27* 27*
28* You should have received a copy of the GNU General Public License 28* You should have received a copy of the GNU General Public License
29* along with this program. If not, see <http://www.gnu.org/licenses/>. 29* along with this program. If not, see <http://www.gnu.org/licenses/>.
30* 30*
31* 31*
32*****************************************************************************/ 32*****************************************************************************/
33 33
34const char *progname = "check_procs"; 34const char *progname = "check_procs";
@@ -50,7 +50,7 @@ const char *email = "devel@monitoring-plugins.org";
50 50
51int process_arguments (int, char **); 51int process_arguments (int, char **);
52int validate_arguments (void); 52int validate_arguments (void);
53int convert_to_seconds (char *); 53int convert_to_seconds (char *);
54void print_help (void); 54void print_help (void);
55void print_usage (void); 55void print_usage (void);
56 56
@@ -70,6 +70,7 @@ int options = 0; /* bitmask of filter criteria to test against */
70#define PCPU 256 70#define PCPU 256
71#define ELAPSED 512 71#define ELAPSED 512
72#define EREG_ARGS 1024 72#define EREG_ARGS 1024
73#define EXCLUDE_PROGS 2048
73 74
74#define KTHREAD_PARENT "kthreadd" /* the parent process of kernel threads: 75#define KTHREAD_PARENT "kthreadd" /* the parent process of kernel threads:
75 ppid of procs are compared to pid of this proc*/ 76 ppid of procs are compared to pid of this proc*/
@@ -93,6 +94,9 @@ int rss;
93float pcpu; 94float pcpu;
94char *statopts; 95char *statopts;
95char *prog; 96char *prog;
97char *exclude_progs;
98char **exclude_progs_arr = NULL;
99char exclude_progs_counter = 0;
96char *args; 100char *args;
97char *input_filename = NULL; 101char *input_filename = NULL;
98regex_t re_args; 102regex_t re_args;
@@ -230,9 +234,9 @@ main (int argc, char **argv)
230 procseconds = convert_to_seconds(procetime); 234 procseconds = convert_to_seconds(procetime);
231 235
232 if (verbose >= 3) 236 if (verbose >= 3)
233 printf ("proc#=%d uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n", 237 printf ("proc#=%d uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n",
234 procs, procuid, procvsz, procrss, 238 procs, procuid, procvsz, procrss,
235 procpid, procppid, procpcpu, procstat, 239 procpid, procppid, procpcpu, procstat,
236 procetime, procprog, procargs); 240 procetime, procprog, procargs);
237 241
238 /* Ignore self */ 242 /* Ignore self */
@@ -250,7 +254,26 @@ main (int argc, char **argv)
250 continue; 254 continue;
251 } 255 }
252 256
253 /* filter kernel threads (childs of KTHREAD_PARENT)*/ 257 /* Ignore excluded processes by name */
258 if(options & EXCLUDE_PROGS) {
259 int found = 0;
260 int i = 0;
261
262 for(i=0; i < (exclude_progs_counter); i++) {
263 if(!strcmp(procprog, exclude_progs_arr[i])) {
264 found = 1;
265 }
266 }
267 if(found == 0) {
268 resultsum |= EXCLUDE_PROGS;
269 } else
270 {
271 if(verbose >= 3)
272 printf("excluding - by ignorelist\n");
273 }
274 }
275
276 /* filter kernel threads (children of KTHREAD_PARENT)*/
254 /* TODO adapt for other OSes than GNU/Linux 277 /* TODO adapt for other OSes than GNU/Linux
255 sorry for not doing that, but I've no other OSes to test :-( */ 278 sorry for not doing that, but I've no other OSes to test :-( */
256 if (kthread_filter == 1) { 279 if (kthread_filter == 1) {
@@ -265,7 +288,7 @@ main (int argc, char **argv)
265 } 288 }
266 } 289 }
267 290
268 if ((options & STAT) && (strstr (statopts, procstat))) 291 if ((options & STAT) && (strstr (procstat, statopts)))
269 resultsum |= STAT; 292 resultsum |= STAT;
270 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) 293 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL))
271 resultsum |= ARGS; 294 resultsum |= ARGS;
@@ -292,9 +315,9 @@ main (int argc, char **argv)
292 315
293 procs++; 316 procs++;
294 if (verbose >= 2) { 317 if (verbose >= 2) {
295 printf ("Matched: uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n", 318 printf ("Matched: uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n",
296 procuid, procvsz, procrss, 319 procuid, procvsz, procrss,
297 procpid, procppid, procpcpu, procstat, 320 procpid, procppid, procpcpu, procstat,
298 procetime, procprog, procargs); 321 procetime, procprog, procargs);
299 } 322 }
300 323
@@ -320,7 +343,7 @@ main (int argc, char **argv)
320 result = max_state (result, i); 343 result = max_state (result, i);
321 } 344 }
322 } 345 }
323 } 346 }
324 /* This should not happen */ 347 /* This should not happen */
325 else if (verbose) { 348 else if (verbose) {
326 printf(_("Not parseable: %s"), input_buffer); 349 printf(_("Not parseable: %s"), input_buffer);
@@ -332,7 +355,7 @@ main (int argc, char **argv)
332 return STATE_UNKNOWN; 355 return STATE_UNKNOWN;
333 } 356 }
334 357
335 if ( result == STATE_UNKNOWN ) 358 if ( result == STATE_UNKNOWN )
336 result = STATE_OK; 359 result = STATE_OK;
337 360
338 /* Needed if procs found, but none match filter */ 361 /* Needed if procs found, but none match filter */
@@ -352,9 +375,9 @@ main (int argc, char **argv)
352 if (metric != METRIC_PROCS) { 375 if (metric != METRIC_PROCS) {
353 printf (_("%d crit, %d warn out of "), crit, warn); 376 printf (_("%d crit, %d warn out of "), crit, warn);
354 } 377 }
355 } 378 }
356 printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs); 379 printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs);
357 380
358 if (strcmp(fmt,"") != 0) { 381 if (strcmp(fmt,"") != 0) {
359 printf (_(" with %s"), fmt); 382 printf (_(" with %s"), fmt);
360 } 383 }
@@ -409,6 +432,7 @@ process_arguments (int argc, char **argv)
409 {"input-file", required_argument, 0, CHAR_MAX+2}, 432 {"input-file", required_argument, 0, CHAR_MAX+2},
410 {"no-kthreads", required_argument, 0, 'k'}, 433 {"no-kthreads", required_argument, 0, 'k'},
411 {"traditional-filter", no_argument, 0, 'T'}, 434 {"traditional-filter", no_argument, 0, 'T'},
435 {"exclude-process", required_argument, 0, 'X'},
412 {0, 0, 0, 0} 436 {0, 0, 0, 0}
413 }; 437 };
414 438
@@ -417,7 +441,7 @@ process_arguments (int argc, char **argv)
417 strcpy (argv[c], "-t"); 441 strcpy (argv[c], "-t");
418 442
419 while (1) { 443 while (1) {
420 c = getopt_long (argc, argv, "Vvhkt:c:w:p:s:u:C:a:z:r:m:P:T", 444 c = getopt_long (argc, argv, "Vvhkt:c:w:p:s:u:C:a:z:r:m:P:T:X:",
421 longopts, &option); 445 longopts, &option);
422 446
423 if (c == -1 || c == EOF) 447 if (c == -1 || c == EOF)
@@ -440,7 +464,7 @@ process_arguments (int argc, char **argv)
440 break; 464 break;
441 case 'c': /* critical threshold */ 465 case 'c': /* critical threshold */
442 critical_range = optarg; 466 critical_range = optarg;
443 break; 467 break;
444 case 'w': /* warning threshold */ 468 case 'w': /* warning threshold */
445 warning_range = optarg; 469 warning_range = optarg;
446 break; 470 break;
@@ -490,6 +514,23 @@ process_arguments (int argc, char **argv)
490 prog); 514 prog);
491 options |= PROG; 515 options |= PROG;
492 break; 516 break;
517 case 'X':
518 if(exclude_progs)
519 break;
520 else
521 exclude_progs = optarg;
522 xasprintf (&fmt, _("%s%sexclude progs '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
523 exclude_progs);
524 char *p = strtok(exclude_progs, ",");
525
526 while(p){
527 exclude_progs_arr = realloc(exclude_progs_arr, sizeof(char*) * ++exclude_progs_counter);
528 exclude_progs_arr[exclude_progs_counter-1] = p;
529 p = strtok(NULL, ",");
530 }
531
532 options |= EXCLUDE_PROGS;
533 break;
493 case 'a': /* args (full path name with args) */ 534 case 'a': /* args (full path name with args) */
494 /* TODO: allow this to be passed in with --metric */ 535 /* TODO: allow this to be passed in with --metric */
495 if (args) 536 if (args)
@@ -542,11 +583,11 @@ process_arguments (int argc, char **argv)
542 if ( strcmp(optarg, "PROCS") == 0) { 583 if ( strcmp(optarg, "PROCS") == 0) {
543 metric = METRIC_PROCS; 584 metric = METRIC_PROCS;
544 break; 585 break;
545 } 586 }
546 else if ( strcmp(optarg, "VSZ") == 0) { 587 else if ( strcmp(optarg, "VSZ") == 0) {
547 metric = METRIC_VSZ; 588 metric = METRIC_VSZ;
548 break; 589 break;
549 } 590 }
550 else if ( strcmp(optarg, "RSS") == 0 ) { 591 else if ( strcmp(optarg, "RSS") == 0 ) {
551 metric = METRIC_RSS; 592 metric = METRIC_RSS;
552 break; 593 break;
@@ -559,7 +600,7 @@ process_arguments (int argc, char **argv)
559 metric = METRIC_ELAPSED; 600 metric = METRIC_ELAPSED;
560 break; 601 break;
561 } 602 }
562 603
563 usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!")); 604 usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"));
564 case 'k': /* linux kernel thread filter */ 605 case 'k': /* linux kernel thread filter */
565 kthread_filter = 1; 606 kthread_filter = 1;
@@ -642,7 +683,7 @@ convert_to_seconds(char *etime) {
642 seconds = 0; 683 seconds = 0;
643 684
644 for (ptr = etime; *ptr != '\0'; ptr++) { 685 for (ptr = etime; *ptr != '\0'; ptr++) {
645 686
646 if (*ptr == '-') { 687 if (*ptr == '-') {
647 hyphcnt++; 688 hyphcnt++;
648 continue; 689 continue;
@@ -745,6 +786,8 @@ print_help (void)
745 printf (" %s\n", _("Only scan for processes with args that contain the regex STRING.")); 786 printf (" %s\n", _("Only scan for processes with args that contain the regex STRING."));
746 printf (" %s\n", "-C, --command=COMMAND"); 787 printf (" %s\n", "-C, --command=COMMAND");
747 printf (" %s\n", _("Only scan for exact matches of COMMAND (without path).")); 788 printf (" %s\n", _("Only scan for exact matches of COMMAND (without path)."));
789 printf (" %s\n", "-X, --exclude-process");
790 printf (" %s\n", _("Exclude processes which match this comma separated list"));
748 printf (" %s\n", "-k, --no-kthreads"); 791 printf (" %s\n", "-k, --no-kthreads");
749 printf (" %s\n", _("Only scan for non kernel threads (works on Linux only).")); 792 printf (" %s\n", _("Only scan for non kernel threads (works on Linux only)."));
750 793
@@ -764,13 +807,18 @@ be the total number of running processes\n\n"));
764 printf (" %s\n", "check_procs -w 2:2 -c 2:1024 -C portsentry"); 807 printf (" %s\n", "check_procs -w 2:2 -c 2:1024 -C portsentry");
765 printf (" %s\n", _("Warning if not two processes with command name portsentry.")); 808 printf (" %s\n", _("Warning if not two processes with command name portsentry."));
766 printf (" %s\n\n", _("Critical if < 2 or > 1024 processes")); 809 printf (" %s\n\n", _("Critical if < 2 or > 1024 processes"));
810 printf (" %s\n", "check_procs -c 1: -C sshd");
811 printf (" %s\n", _("Critical if not at least 1 process with command sshd"));
812 printf (" %s\n", "check_procs -w 1024 -c 1: -C sshd");
813 printf (" %s\n", _("Warning if > 1024 processes with command name sshd."));
814 printf (" %s\n\n", _("Critical if < 1 processes with command name sshd."));
767 printf (" %s\n", "check_procs -w 10 -a '/usr/local/bin/perl' -u root"); 815 printf (" %s\n", "check_procs -w 10 -a '/usr/local/bin/perl' -u root");
768 printf (" %s\n", _("Warning alert if > 10 processes with command arguments containing")); 816 printf (" %s\n", _("Warning alert if > 10 processes with command arguments containing"));
769 printf (" %s\n\n", _("'/usr/local/bin/perl' and owned by root")); 817 printf (" %s\n\n", _("'/usr/local/bin/perl' and owned by root"));
770 printf (" %s\n", "check_procs -w 50000 -c 100000 --metric=VSZ"); 818 printf (" %s\n", "check_procs -w 50000 -c 100000 --metric=VSZ");
771 printf (" %s\n\n", _("Alert if VSZ of any processes over 50K or 100K")); 819 printf (" %s\n\n", _("Alert if VSZ of any processes over 50K or 100K"));
772 printf (" %s\n", "check_procs -w 10 -c 20 --metric=CPU"); 820 printf (" %s\n", "check_procs -w 10 -c 20 --metric=CPU");
773 printf (" %s\n", _("Alert if CPU of any processes over 10%% or 20%%")); 821 printf (" %s\n", _("Alert if CPU of any processes over 10\% or 20\%"));
774 822
775 printf (UT_SUPPORT); 823 printf (UT_SUPPORT);
776} 824}
@@ -781,5 +829,5 @@ print_usage (void)
781 printf ("%s\n", _("Usage:")); 829 printf ("%s\n", _("Usage:"));
782 printf ("%s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n", progname); 830 printf ("%s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n", progname);
783 printf (" [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n"); 831 printf (" [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n");
784 printf (" [-C command] [-k] [-t timeout] [-v]\n"); 832 printf (" [-C command] [-X process_to_exclude] [-k] [-t timeout] [-v]\n");
785} 833}
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 03cbb8b0..b1b4938c 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -36,7 +36,9 @@ const char *email = "devel@monitoring-plugins.org";
36#include "utils.h" 36#include "utils.h"
37#include "netutils.h" 37#include "netutils.h"
38 38
39#if defined(HAVE_LIBFREERADIUS_CLIENT) 39#if defined(HAVE_LIBRADCLI)
40#include <radcli/radcli.h>
41#elif defined(HAVE_LIBFREERADIUS_CLIENT)
40#include <freeradius-client.h> 42#include <freeradius-client.h>
41#elif defined(HAVE_LIBRADIUSCLIENT_NG) 43#elif defined(HAVE_LIBRADIUSCLIENT_NG)
42#include <radiusclient-ng.h> 44#include <radiusclient-ng.h>
@@ -48,22 +50,24 @@ int process_arguments (int, char **);
48void print_help (void); 50void print_help (void);
49void print_usage (void); 51void print_usage (void);
50 52
51#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) 53#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
52#define my_rc_conf_str(a) rc_conf_str(rch,a) 54#define my_rc_conf_str(a) rc_conf_str(rch,a)
55#if defined(HAVE_LIBRADCLI)
56#define my_rc_send_server(a,b) rc_send_server(rch,a,b,AUTH)
57#else
53#define my_rc_send_server(a,b) rc_send_server(rch,a,b) 58#define my_rc_send_server(a,b) rc_send_server(rch,a,b)
54#ifdef HAVE_LIBFREERADIUS_CLIENT 59#endif
60#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADCLI)
55#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f) 61#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f)
56#else 62#else
57#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) 63#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
58#endif 64#endif
59#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
60#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) 65#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
61#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) 66#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
62#else 67#else
63#define my_rc_conf_str(a) rc_conf_str(a) 68#define my_rc_conf_str(a) rc_conf_str(a)
64#define my_rc_send_server(a,b) rc_send_server(a, b) 69#define my_rc_send_server(a,b) rc_send_server(a, b)
65#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f) 70#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
66#define my_rc_own_ipaddress() rc_own_ipaddress()
67#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d) 71#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
68#define my_rc_read_dictionary(a) rc_read_dictionary(a) 72#define my_rc_read_dictionary(a) rc_read_dictionary(a)
69#endif 73#endif
@@ -76,7 +80,7 @@ void print_usage (void);
76 80
77int my_rc_read_config(char *); 81int my_rc_read_config(char *);
78 82
79#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) 83#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
80rc_handle *rch = NULL; 84rc_handle *rch = NULL;
81#endif 85#endif
82 86
@@ -90,11 +94,10 @@ char *config_file = NULL;
90unsigned short port = PW_AUTH_UDP_PORT; 94unsigned short port = PW_AUTH_UDP_PORT;
91int retries = 1; 95int retries = 1;
92int verbose = FALSE; 96int verbose = FALSE;
93ENV *env = NULL;
94 97
95/****************************************************************************** 98/******************************************************************************
96 99
97The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@ 100The (pseudo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
98tags in the comments. With in the tags, the XML is assembled sequentially. 101tags in the comments. With in the tags, the XML is assembled sequentially.
99You can define entities in tags. You also have all the #defines available as 102You can define entities in tags. You also have all the #defines available as
100entities. 103entities.
@@ -150,7 +153,13 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
150int 153int
151main (int argc, char **argv) 154main (int argc, char **argv)
152{ 155{
156 struct sockaddr_storage ss;
157 char name[HOST_NAME_MAX];
158#ifdef RC_BUFFER_LEN
159 char msg[RC_BUFFER_LEN];
160#else
153 char msg[BUFFER_LEN]; 161 char msg[BUFFER_LEN];
162#endif
154 SEND_DATA data; 163 SEND_DATA data;
155 int result = STATE_UNKNOWN; 164 int result = STATE_UNKNOWN;
156 uint32_t client_id, service; 165 uint32_t client_id, service;
@@ -185,15 +194,14 @@ main (int argc, char **argv)
185 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); 194 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
186 } 195 }
187 196
188 if (nasipaddress != NULL) { 197 if (nasipaddress == NULL) {
189 if (rc_good_ipaddr (nasipaddress)) 198 if (gethostname (name, sizeof(name)) != 0)
190 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); 199 die (STATE_UNKNOWN, _("gethostname() failed!\n"));
191 if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) 200 nasipaddress = name;
192 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
193 } else {
194 if ((client_id = my_rc_own_ipaddress ()) == 0)
195 die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
196 } 201 }
202 if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */
203 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
204 client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr);
197 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) 205 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
198 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); 206 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
199 207
@@ -274,7 +282,7 @@ process_arguments (int argc, char **argv)
274 break; 282 break;
275 case 'P': /* port */ 283 case 'P': /* port */
276 if (is_intnonneg (optarg)) 284 if (is_intnonneg (optarg))
277 port = atoi (optarg); 285 port = (unsigned short)atoi (optarg);
278 else 286 else
279 usage4 (_("Port must be a positive integer")); 287 usage4 (_("Port must be a positive integer"));
280 break; 288 break;
@@ -310,7 +318,7 @@ process_arguments (int argc, char **argv)
310 break; 318 break;
311 case 't': /* timeout */ 319 case 't': /* timeout */
312 if (is_intpos (optarg)) 320 if (is_intpos (optarg))
313 timeout_interval = atoi (optarg); 321 timeout_interval = (unsigned)atoi (optarg);
314 else 322 else
315 usage2 (_("Timeout interval must be a positive integer"), optarg); 323 usage2 (_("Timeout interval must be a positive integer"), optarg);
316 break; 324 break;
@@ -356,7 +364,7 @@ print_help (void)
356 printf (" %s\n", "-u, --username=STRING"); 364 printf (" %s\n", "-u, --username=STRING");
357 printf (" %s\n", _("The user to authenticate")); 365 printf (" %s\n", _("The user to authenticate"));
358 printf (" %s\n", "-p, --password=STRING"); 366 printf (" %s\n", "-p, --password=STRING");
359 printf (" %s\n", _("Password for autentication (SECURITY RISK)")); 367 printf (" %s\n", _("Password for authentication (SECURITY RISK)"));
360 printf (" %s\n", "-n, --nas-id=STRING"); 368 printf (" %s\n", "-n, --nas-id=STRING");
361 printf (" %s\n", _("NAS identifier")); 369 printf (" %s\n", _("NAS identifier"));
362 printf (" %s\n", "-N, --nas-ip-address=STRING"); 370 printf (" %s\n", "-N, --nas-ip-address=STRING");
@@ -373,7 +381,7 @@ print_help (void)
373 printf ("\n"); 381 printf ("\n");
374 printf ("%s\n", _("This plugin tests a RADIUS server to see if it is accepting connections.")); 382 printf ("%s\n", _("This plugin tests a RADIUS server to see if it is accepting connections."));
375 printf ("%s\n", _("The server to test must be specified in the invocation, as well as a user")); 383 printf ("%s\n", _("The server to test must be specified in the invocation, as well as a user"));
376 printf ("%s\n", _("name and password. A configuration file may also be present. The format of")); 384 printf ("%s\n", _("name and password. A configuration file must be present. The format of"));
377 printf ("%s\n", _("the configuration file is described in the radiusclient library sources.")); 385 printf ("%s\n", _("the configuration file is described in the radiusclient library sources."));
378 printf ("%s\n", _("The password option presents a substantial security issue because the")); 386 printf ("%s\n", _("The password option presents a substantial security issue because the"));
379 printf ("%s\n", _("password can possibly be determined by careful watching of the command line")); 387 printf ("%s\n", _("password can possibly be determined by careful watching of the command line"));
@@ -399,7 +407,7 @@ print_usage (void)
399 407
400int my_rc_read_config(char * a) 408int my_rc_read_config(char * a)
401{ 409{
402#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) 410#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
403 rch = rc_read_config(a); 411 rch = rc_read_config(a);
404 return (rch == NULL) ? 1 : 0; 412 return (rch == NULL) ? 1 : 0;
405#else 413#else
diff --git a/plugins/check_real.c b/plugins/check_real.c
index 6491e6e9..fbdb70f3 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -178,7 +178,7 @@ main (int argc, char **argv)
178 178
179 /* watch for the REAL connection string */ 179 /* watch for the REAL connection string */
180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0); 180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
181 buffer[result] = '\0'; /* null terminate recieved buffer */ 181 buffer[result] = '\0'; /* null terminate received buffer */
182 182
183 /* return a CRITICAL status if we couldn't read any data */ 183 /* return a CRITICAL status if we couldn't read any data */
184 if (result == -1) { 184 if (result == -1) {
@@ -436,9 +436,9 @@ print_help (void)
436 436
437 printf ("\n"); 437 printf ("\n");
438 printf ("%s\n", _("This plugin will attempt to open an RTSP connection with the host.")); 438 printf ("%s\n", _("This plugin will attempt to open an RTSP connection with the host."));
439 printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return")); 439 printf ("%s\n", _("Successful connects return STATE_OK, refusals and timeouts return"));
440 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,")); 440 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"));
441 printf ("%s\n", _("but incorrect reponse messages from the host result in STATE_WARNING return")); 441 printf ("%s\n", _("but incorrect response messages from the host result in STATE_WARNING return"));
442 printf ("%s\n", _("values.")); 442 printf ("%s\n", _("values."));
443 443
444 printf (UT_SUPPORT); 444 printf (UT_SUPPORT);
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 1996c6d3..fc0ae2c4 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -3,7 +3,7 @@
3* Monitoring check_smtp plugin 3* Monitoring check_smtp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Monitoring Plugins Development Team 6* Copyright (c) 2000-2023 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -42,27 +42,26 @@ const char *email = "devel@monitoring-plugins.org";
42#ifdef HAVE_SSL 42#ifdef HAVE_SSL
43int check_cert = FALSE; 43int check_cert = FALSE;
44int days_till_exp_warn, days_till_exp_crit; 44int days_till_exp_warn, days_till_exp_crit;
45# define my_recv(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) 45# define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
46# define my_send(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0)) 46# define my_send(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
47#else /* ifndef HAVE_SSL */ 47#else /* ifndef HAVE_SSL */
48# define my_recv(buf, len) read(sd, buf, len) 48# define my_recv(buf, len) read(sd, buf, len)
49# define my_send(buf, len) send(sd, buf, len, 0) 49# define my_send(buf, len) send(sd, buf, len, 0)
50#endif 50#endif
51 51
52enum { 52enum {
53 SMTP_PORT = 25 53 SMTP_PORT = 25,
54 SMTPS_PORT = 465
54}; 55};
56#define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n"
55#define SMTP_EXPECT "220" 57#define SMTP_EXPECT "220"
56#define SMTP_HELO "HELO " 58#define SMTP_HELO "HELO "
57#define SMTP_EHLO "EHLO " 59#define SMTP_EHLO "EHLO "
60#define SMTP_LHLO "LHLO "
58#define SMTP_QUIT "QUIT\r\n" 61#define SMTP_QUIT "QUIT\r\n"
59#define SMTP_STARTTLS "STARTTLS\r\n" 62#define SMTP_STARTTLS "STARTTLS\r\n"
60#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" 63#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
61 64
62#ifndef HOST_MAX_BYTES
63#define HOST_MAX_BYTES 255
64#endif
65
66#define EHLO_SUPPORTS_STARTTLS 1 65#define EHLO_SUPPORTS_STARTTLS 1
67 66
68int process_arguments (int, char **); 67int process_arguments (int, char **);
@@ -85,6 +84,7 @@ int eflags = 0;
85int errcode, excode; 84int errcode, excode;
86 85
87int server_port = SMTP_PORT; 86int server_port = SMTP_PORT;
87int server_port_option = 0;
88char *server_address = NULL; 88char *server_address = NULL;
89char *server_expect = NULL; 89char *server_expect = NULL;
90char *mail_command = NULL; 90char *mail_command = NULL;
@@ -105,7 +105,11 @@ double critical_time = 0;
105int check_critical_time = FALSE; 105int check_critical_time = FALSE;
106int verbose = 0; 106int verbose = 0;
107int use_ssl = FALSE; 107int use_ssl = FALSE;
108int use_starttls = FALSE;
109int use_sni = FALSE;
110short use_proxy_prefix = FALSE;
108short use_ehlo = FALSE; 111short use_ehlo = FALSE;
112short use_lhlo = FALSE;
109short ssl_established = 0; 113short ssl_established = 0;
110char *localhostname = NULL; 114char *localhostname = NULL;
111int sd; 115int sd;
@@ -128,6 +132,7 @@ main (int argc, char **argv)
128 char *cmd_str = NULL; 132 char *cmd_str = NULL;
129 char *helocmd = NULL; 133 char *helocmd = NULL;
130 char *error_msg = ""; 134 char *error_msg = "";
135 char *server_response = NULL;
131 struct timeval tv; 136 struct timeval tv;
132 137
133 /* Catch pipe errors in read/write - sometimes occurs when writing QUIT */ 138 /* Catch pipe errors in read/write - sometimes occurs when writing QUIT */
@@ -155,7 +160,9 @@ main (int argc, char **argv)
155 return STATE_CRITICAL; 160 return STATE_CRITICAL;
156 } 161 }
157 } 162 }
158 if(use_ehlo) 163 if(use_lhlo)
164 xasprintf (&helocmd, "%s%s%s", SMTP_LHLO, localhostname, "\r\n");
165 else if(use_ehlo)
159 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n"); 166 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
160 else 167 else
161 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n"); 168 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
@@ -182,6 +189,26 @@ main (int argc, char **argv)
182 result = my_tcp_connect (server_address, server_port, &sd); 189 result = my_tcp_connect (server_address, server_port, &sd);
183 190
184 if (result == STATE_OK) { /* we connected */ 191 if (result == STATE_OK) { /* we connected */
192 /* If requested, send PROXY header */
193 if (use_proxy_prefix) {
194 if (verbose)
195 printf ("Sending header %s\n", PROXY_PREFIX);
196 my_send(PROXY_PREFIX, strlen(PROXY_PREFIX));
197 }
198
199#ifdef HAVE_SSL
200 if (use_ssl) {
201 result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
202 if (result != STATE_OK) {
203 printf (_("CRITICAL - Cannot create SSL context.\n"));
204 close(sd);
205 np_net_ssl_cleanup();
206 return STATE_CRITICAL;
207 } else {
208 ssl_established = 1;
209 }
210 }
211#endif
185 212
186 /* watch for the SMTP connection string and */ 213 /* watch for the SMTP connection string and */
187 /* return a WARNING status if we couldn't read any data */ 214 /* return a WARNING status if we couldn't read any data */
@@ -189,44 +216,32 @@ main (int argc, char **argv)
189 printf (_("recv() failed\n")); 216 printf (_("recv() failed\n"));
190 return STATE_WARNING; 217 return STATE_WARNING;
191 } 218 }
192 else { 219
193 if (verbose) 220 /* save connect return (220 hostname ..) for later use */
194 printf ("%s", buffer); 221 xasprintf(&server_response, "%s", buffer);
195 /* strip the buffer of carriage returns */
196 strip (buffer);
197 /* make sure we find the response we are looking for */
198 if (!strstr (buffer, server_expect)) {
199 if (server_port == SMTP_PORT)
200 printf (_("Invalid SMTP response received from host: %s\n"), buffer);
201 else
202 printf (_("Invalid SMTP response received from host on port %d: %s\n"),
203 server_port, buffer);
204 return STATE_WARNING;
205 }
206 }
207 222
208 /* send the HELO/EHLO command */ 223 /* send the HELO/EHLO command */
209 send(sd, helocmd, strlen(helocmd), 0); 224 my_send(helocmd, strlen(helocmd));
210 225
211 /* allow for response to helo command to reach us */ 226 /* allow for response to helo command to reach us */
212 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) { 227 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
213 printf (_("recv() failed\n")); 228 printf (_("recv() failed\n"));
214 return STATE_WARNING; 229 return STATE_WARNING;
215 } else if(use_ehlo){ 230 } else if(use_ehlo || use_lhlo){
216 if(strstr(buffer, "250 STARTTLS") != NULL || 231 if(strstr(buffer, "250 STARTTLS") != NULL ||
217 strstr(buffer, "250-STARTTLS") != NULL){ 232 strstr(buffer, "250-STARTTLS") != NULL){
218 supports_tls=TRUE; 233 supports_tls=TRUE;
219 } 234 }
220 } 235 }
221 236
222 if(use_ssl && ! supports_tls){ 237 if(use_starttls && ! supports_tls){
223 printf(_("WARNING - TLS not supported by server\n")); 238 printf(_("WARNING - TLS not supported by server\n"));
224 smtp_quit(); 239 smtp_quit();
225 return STATE_WARNING; 240 return STATE_WARNING;
226 } 241 }
227 242
228#ifdef HAVE_SSL 243#ifdef HAVE_SSL
229 if(use_ssl) { 244 if(use_starttls) {
230 /* send the STARTTLS command */ 245 /* send the STARTTLS command */
231 send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); 246 send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0);
232 247
@@ -236,11 +251,11 @@ main (int argc, char **argv)
236 smtp_quit(); 251 smtp_quit();
237 return STATE_UNKNOWN; 252 return STATE_UNKNOWN;
238 } 253 }
239 result = np_net_ssl_init(sd); 254 result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
240 if(result != STATE_OK) { 255 if(result != STATE_OK) {
241 printf (_("CRITICAL - Cannot create SSL context.\n")); 256 printf (_("CRITICAL - Cannot create SSL context.\n"));
242 np_net_ssl_cleanup();
243 close(sd); 257 close(sd);
258 np_net_ssl_cleanup();
244 return STATE_CRITICAL; 259 return STATE_CRITICAL;
245 } else { 260 } else {
246 ssl_established = 1; 261 ssl_established = 1;
@@ -284,12 +299,31 @@ main (int argc, char **argv)
284 } 299 }
285#endif 300#endif
286 301
302 if (verbose)
303 printf ("%s", buffer);
304
305 /* save buffer for later use */
306 xasprintf(&server_response, "%s%s", server_response, buffer);
307 /* strip the buffer of carriage returns */
308 strip (server_response);
309
310 /* make sure we find the droids we are looking for */
311 if (!strstr (server_response, server_expect)) {
312 if (server_port == SMTP_PORT)
313 printf (_("Invalid SMTP response received from host: %s\n"), server_response);
314 else
315 printf (_("Invalid SMTP response received from host on port %d: %s\n"),
316 server_port, server_response);
317 return STATE_WARNING;
318 }
319
287 if (send_mail_from) { 320 if (send_mail_from) {
288 my_send(cmd_str, strlen(cmd_str)); 321 my_send(cmd_str, strlen(cmd_str));
289 if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose) 322 if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose)
290 printf("%s", buffer); 323 printf("%s", buffer);
291 } 324 }
292 325
326 n = 0;
293 while (n < ncommands) { 327 while (n < ncommands) {
294 xasprintf (&cmd_str, "%s%s", commands[n], "\r\n"); 328 xasprintf (&cmd_str, "%s%s", commands[n], "\r\n");
295 my_send(cmd_str, strlen(cmd_str)); 329 my_send(cmd_str, strlen(cmd_str));
@@ -446,6 +480,10 @@ process_arguments (int argc, char **argv)
446 int c; 480 int c;
447 char* temp; 481 char* temp;
448 482
483 enum {
484 SNI_OPTION
485 };
486
449 int option = 0; 487 int option = 0;
450 static struct option longopts[] = { 488 static struct option longopts[] = {
451 {"hostname", required_argument, 0, 'H'}, 489 {"hostname", required_argument, 0, 'H'},
@@ -466,9 +504,14 @@ process_arguments (int argc, char **argv)
466 {"use-ipv4", no_argument, 0, '4'}, 504 {"use-ipv4", no_argument, 0, '4'},
467 {"use-ipv6", no_argument, 0, '6'}, 505 {"use-ipv6", no_argument, 0, '6'},
468 {"help", no_argument, 0, 'h'}, 506 {"help", no_argument, 0, 'h'},
507 {"lmtp", no_argument, 0, 'L'},
508 {"ssl", no_argument, 0, 's'},
509 {"tls", no_argument, 0, 's'},
469 {"starttls",no_argument,0,'S'}, 510 {"starttls",no_argument,0,'S'},
511 {"sni", no_argument, 0, SNI_OPTION},
470 {"certificate",required_argument,0,'D'}, 512 {"certificate",required_argument,0,'D'},
471 {"ignore-quit-failure",no_argument,0,'q'}, 513 {"ignore-quit-failure",no_argument,0,'q'},
514 {"proxy",no_argument,0,'r'},
472 {0, 0, 0, 0} 515 {0, 0, 0, 0}
473 }; 516 };
474 517
@@ -485,7 +528,7 @@ process_arguments (int argc, char **argv)
485 } 528 }
486 529
487 while (1) { 530 while (1) {
488 c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", 531 c = getopt_long (argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:sSD:F:A:U:P:q",
489 longopts, &option); 532 longopts, &option);
490 533
491 if (c == -1 || c == EOF) 534 if (c == -1 || c == EOF)
@@ -502,7 +545,7 @@ process_arguments (int argc, char **argv)
502 break; 545 break;
503 case 'p': /* port */ 546 case 'p': /* port */
504 if (is_intpos (optarg)) 547 if (is_intpos (optarg))
505 server_port = atoi (optarg); 548 server_port_option = atoi (optarg);
506 else 549 else
507 usage4 (_("Port must be a positive integer")); 550 usage4 (_("Port must be a positive integer"));
508 break; 551 break;
@@ -607,11 +650,29 @@ process_arguments (int argc, char **argv)
607#else 650#else
608 usage (_("SSL support not available - install OpenSSL and recompile")); 651 usage (_("SSL support not available - install OpenSSL and recompile"));
609#endif 652#endif
653 case 's':
654 /* ssl */
655 use_ssl = TRUE;
656 server_port = SMTPS_PORT;
657 break;
610 case 'S': 658 case 'S':
611 /* starttls */ 659 /* starttls */
612 use_ssl = TRUE; 660 use_starttls = TRUE;
613 use_ehlo = TRUE; 661 use_ehlo = TRUE;
614 break; 662 break;
663 case SNI_OPTION:
664#ifdef HAVE_SSL
665 use_sni = TRUE;
666#else
667 usage (_("SSL support not available - install OpenSSL and recompile"));
668#endif
669 break;
670 case 'r':
671 use_proxy_prefix = TRUE;
672 break;
673 case 'L':
674 use_lhlo = TRUE;
675 break;
615 case '4': 676 case '4':
616 address_family = AF_INET; 677 address_family = AF_INET;
617 break; 678 break;
@@ -655,6 +716,14 @@ process_arguments (int argc, char **argv)
655 if (from_arg==NULL) 716 if (from_arg==NULL)
656 from_arg = strdup(" "); 717 from_arg = strdup(" ");
657 718
719 if (use_starttls && use_ssl) {
720 usage4 (_("Set either -s/--ssl/--tls or -S/--starttls"));
721 }
722
723 if (server_port_option != 0) {
724 server_port = server_port_option;
725 }
726
658 return validate_arguments (); 727 return validate_arguments ();
659} 728}
660 729
@@ -764,10 +833,12 @@ recvlines(char *buf, size_t bufsize)
764int 833int
765my_close (void) 834my_close (void)
766{ 835{
836 int result;
837 result = close(sd);
767#ifdef HAVE_SSL 838#ifdef HAVE_SSL
768 np_net_ssl_cleanup(); 839 np_net_ssl_cleanup();
769#endif 840#endif
770 return close(sd); 841 return result;
771} 842}
772 843
773 844
@@ -805,11 +876,18 @@ print_help (void)
805 printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")), 876 printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")),
806 printf (" %s\n", "-F, --fqdn=STRING"); 877 printf (" %s\n", "-F, --fqdn=STRING");
807 printf (" %s\n", _("FQDN used for HELO")); 878 printf (" %s\n", _("FQDN used for HELO"));
879 printf (" %s\n", "-r, --proxy");
880 printf (" %s\n", _("Use PROXY protocol prefix for the connection."));
808#ifdef HAVE_SSL 881#ifdef HAVE_SSL
809 printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]"); 882 printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]");
810 printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); 883 printf (" %s\n", _("Minimum number of days a certificate has to be valid."));
884 printf (" %s\n", "-s, --ssl, --tls");
885 printf (" %s\n", _("Use SSL/TLS for the connection."));
886 printf (_(" Sets default port to %d.\n"), SMTPS_PORT);
811 printf (" %s\n", "-S, --starttls"); 887 printf (" %s\n", "-S, --starttls");
812 printf (" %s\n", _("Use STARTTLS for the connection.")); 888 printf (" %s\n", _("Use STARTTLS for the connection."));
889 printf (" %s\n", "--sni");
890 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
813#endif 891#endif
814 892
815 printf (" %s\n", "-A, --authtype=STRING"); 893 printf (" %s\n", "-A, --authtype=STRING");
@@ -818,6 +896,8 @@ print_help (void)
818 printf (" %s\n", _("SMTP AUTH username")); 896 printf (" %s\n", _("SMTP AUTH username"));
819 printf (" %s\n", "-P, --authpass=STRING"); 897 printf (" %s\n", "-P, --authpass=STRING");
820 printf (" %s\n", _("SMTP AUTH password")); 898 printf (" %s\n", _("SMTP AUTH password"));
899 printf (" %s\n", "-L, --lmtp");
900 printf (" %s\n", _("Send LHLO instead of HELO/EHLO"));
821 printf (" %s\n", "-q, --ignore-quit-failure"); 901 printf (" %s\n", "-q, --ignore-quit-failure");
822 printf (" %s\n", _("Ignore failure when sending QUIT command to server")); 902 printf (" %s\n", _("Ignore failure when sending QUIT command to server"));
823 903
@@ -828,9 +908,9 @@ print_help (void)
828 printf (UT_VERBOSE); 908 printf (UT_VERBOSE);
829 909
830 printf("\n"); 910 printf("\n");
831 printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return")); 911 printf ("%s\n", _("Successful connects return STATE_OK, refusals and timeouts return"));
832 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful")); 912 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"));
833 printf ("%s\n", _("connects, but incorrect reponse messages from the host result in")); 913 printf ("%s\n", _("connects, but incorrect response messages from the host result in"));
834 printf ("%s\n", _("STATE_WARNING return values.")); 914 printf ("%s\n", _("STATE_WARNING return values."));
835 915
836 printf (UT_SUPPORT); 916 printf (UT_SUPPORT);
@@ -844,6 +924,6 @@ print_usage (void)
844 printf ("%s\n", _("Usage:")); 924 printf ("%s\n", _("Usage:"));
845 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname); 925 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
846 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n"); 926 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
847 printf ("[-F fqdn] [-S] [-D warn days cert expire[,crit days cert expire]] [-v] \n"); 927 printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [--sni] [-v] \n");
848} 928}
849 929
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 9839d6e8..56a586ad 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -1,31 +1,31 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_snmp plugin 3* Monitoring check_snmp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Monitoring Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_snmp plugin 10* This file contains the check_snmp plugin
11* 11*
12* Check status of remote machines and obtain system information via SNMP 12* Check status of remote machines and obtain system information via SNMP
13* 13*
14* 14*
15* This program is free software: you can redistribute it and/or modify 15* This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17* the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18* (at your option) any later version.
19* 19*
20* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23* GNU General Public License for more details.
24* 24*
25* You should have received a copy of the GNU General Public License 25* You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26* along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27*
28* 28*
29*****************************************************************************/ 29*****************************************************************************/
30 30
31const char *progname = "check_snmp"; 31const char *progname = "check_snmp";
@@ -46,6 +46,7 @@ const char *email = "devel@monitoring-plugins.org";
46#define DEFAULT_PRIV_PROTOCOL "DES" 46#define DEFAULT_PRIV_PROTOCOL "DES"
47#define DEFAULT_DELIMITER "=" 47#define DEFAULT_DELIMITER "="
48#define DEFAULT_OUTPUT_DELIMITER " " 48#define DEFAULT_OUTPUT_DELIMITER " "
49#define DEFAULT_BUFFER_SIZE 100
49 50
50#define mark(a) ((a)!=0?"*":"") 51#define mark(a) ((a)!=0?"*":"")
51 52
@@ -64,6 +65,7 @@ const char *email = "devel@monitoring-plugins.org";
64#define L_RATE_MULTIPLIER CHAR_MAX+2 65#define L_RATE_MULTIPLIER CHAR_MAX+2
65#define L_INVERT_SEARCH CHAR_MAX+3 66#define L_INVERT_SEARCH CHAR_MAX+3
66#define L_OFFSET CHAR_MAX+4 67#define L_OFFSET CHAR_MAX+4
68#define L_IGNORE_MIB_PARSING_ERRORS CHAR_MAX+5
67 69
68/* Gobble to string - stop incrementing c when c[0] match one of the 70/* Gobble to string - stop incrementing c when c[0] match one of the
69 * characters in s */ 71 * characters in s */
@@ -90,6 +92,7 @@ char *thisarg (char *str);
90char *nextarg (char *str); 92char *nextarg (char *str);
91void print_usage (void); 93void print_usage (void);
92void print_help (void); 94void print_help (void);
95char *multiply (char *str);
93 96
94#include "regex.h" 97#include "regex.h"
95char regex_expect[MAX_INPUT_BUFFER] = ""; 98char regex_expect[MAX_INPUT_BUFFER] = "";
@@ -113,6 +116,7 @@ char *authproto = NULL;
113char *privproto = NULL; 116char *privproto = NULL;
114char *authpasswd = NULL; 117char *authpasswd = NULL;
115char *privpasswd = NULL; 118char *privpasswd = NULL;
119int nulloid = STATE_UNKNOWN;
116char **oids = NULL; 120char **oids = NULL;
117size_t oids_size = 0; 121size_t oids_size = 0;
118char *label; 122char *label;
@@ -152,7 +156,12 @@ state_data *previous_state;
152double *previous_value; 156double *previous_value;
153size_t previous_size = OID_COUNT_STEP; 157size_t previous_size = OID_COUNT_STEP;
154int perf_labels = 1; 158int perf_labels = 1;
155 159char* ip_version = "";
160double multiplier = 1.0;
161char *fmtstr = "";
162bool fmtstr_set = false;
163char buffer[DEFAULT_BUFFER_SIZE];
164bool ignore_mib_parsing_errors = false;
156 165
157static char *fix_snmp_range(char *th) 166static char *fix_snmp_range(char *th)
158{ 167{
@@ -300,42 +309,55 @@ main (int argc, char **argv)
300 } 309 }
301 310
302 /* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */ 311 /* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */
303 command_line = calloc (10 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *)); 312
304 command_line[0] = snmpcmd; 313 unsigned index = 0;
305 command_line[1] = strdup ("-Le"); 314 command_line = calloc (11 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *));
306 command_line[2] = strdup ("-t"); 315
307 xasprintf (&command_line[3], "%d", timeout_interval); 316 command_line[index++] = snmpcmd;
308 command_line[4] = strdup ("-r"); 317 command_line[index++] = strdup ("-Le");
309 xasprintf (&command_line[5], "%d", retries); 318 command_line[index++] = strdup ("-t");
310 command_line[6] = strdup ("-m"); 319 xasprintf (&command_line[index++], "%d", timeout_interval);
311 command_line[7] = strdup (miblist); 320 command_line[index++] = strdup ("-r");
312 command_line[8] = "-v"; 321 xasprintf (&command_line[index++], "%d", retries);
313 command_line[9] = strdup (proto); 322 command_line[index++] = strdup ("-m");
323 command_line[index++] = strdup (miblist);
324 command_line[index++] = "-v";
325 command_line[index++] = strdup (proto);
326
327 xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s",
328 snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto);
329
330 if (ignore_mib_parsing_errors) {
331 command_line[index++] = "-Pe";
332 xasprintf(&cl_hidden_auth, "%s -Pe", cl_hidden_auth);
333 }
334
314 335
315 for (i = 0; i < numcontext; i++) { 336 for (i = 0; i < numcontext; i++) {
316 command_line[10 + i] = contextargs[i]; 337 command_line[index++] = contextargs[i];
317 } 338 }
318 339
319 for (i = 0; i < numauthpriv; i++) { 340 for (i = 0; i < numauthpriv; i++) {
320 command_line[10 + numcontext + i] = authpriv[i]; 341 command_line[index++] = authpriv[i];
321 } 342 }
322 343
323 xasprintf (&command_line[10 + numcontext + numauthpriv], "%s:%s", server_address, port); 344 xasprintf (&command_line[index++], "%s:%s", server_address, port);
324 345
325 /* This is just for display purposes, so it can remain a string */ 346 xasprintf(&cl_hidden_auth, "%s [context] [authpriv] %s:%s",
326 xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s:%s", 347 cl_hidden_auth,
327 snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[context]", "[authpriv]", 348 server_address,
328 server_address, port); 349 port);
329 350
330 for (i = 0; i < numoids; i++) { 351 for (i = 0; i < numoids; i++) {
331 command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i]; 352 command_line[index++] = oids[i];
332 xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); 353 xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
333 } 354 }
334 355
335 command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL; 356 command_line[index++] = NULL;
336 357
337 if (verbose) 358 if (verbose) {
338 printf ("%s\n", cl_hidden_auth); 359 printf ("%s\n", cl_hidden_auth);
360 }
339 361
340 /* Set signal handling and alarm */ 362 /* Set signal handling and alarm */
341 if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) { 363 if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) {
@@ -375,7 +397,7 @@ main (int argc, char **argv)
375 } 397 }
376 } 398 }
377 399
378 for (line=0, i=0; line < chld_out.lines; line++, i++) { 400 for (line=0, i=0; line < chld_out.lines && i < numoids ; line++, i++) {
379 if(calculate_rate) 401 if(calculate_rate)
380 conv = "%.10g"; 402 conv = "%.10g";
381 else 403 else
@@ -397,15 +419,15 @@ main (int argc, char **argv)
397 is_counter=0; 419 is_counter=0;
398 /* We strip out the datatype indicator for PHBs */ 420 /* We strip out the datatype indicator for PHBs */
399 if (strstr (response, "Gauge: ")) { 421 if (strstr (response, "Gauge: ")) {
400 show = strstr (response, "Gauge: ") + 7; 422 show = multiply (strstr (response, "Gauge: ") + 7);
401 } 423 }
402 else if (strstr (response, "Gauge32: ")) { 424 else if (strstr (response, "Gauge32: ")) {
403 show = strstr (response, "Gauge32: ") + 9; 425 show = multiply (strstr (response, "Gauge32: ") + 9);
404 } 426 }
405 else if (strstr (response, "Counter32: ")) { 427 else if (strstr (response, "Counter32: ")) {
406 show = strstr (response, "Counter32: ") + 11; 428 show = strstr (response, "Counter32: ") + 11;
407 is_counter=1; 429 is_counter=1;
408 if(!calculate_rate) 430 if(!calculate_rate)
409 strcpy(type, "c"); 431 strcpy(type, "c");
410 } 432 }
411 else if (strstr (response, "Counter64: ")) { 433 else if (strstr (response, "Counter64: ")) {
@@ -415,7 +437,11 @@ main (int argc, char **argv)
415 strcpy(type, "c"); 437 strcpy(type, "c");
416 } 438 }
417 else if (strstr (response, "INTEGER: ")) { 439 else if (strstr (response, "INTEGER: ")) {
418 show = strstr (response, "INTEGER: ") + 9; 440 show = multiply (strstr (response, "INTEGER: ") + 9);
441
442 if (fmtstr_set) {
443 conv = fmtstr;
444 }
419 } 445 }
420 else if (strstr (response, "OID: ")) { 446 else if (strstr (response, "OID: ")) {
421 show = strstr (response, "OID: ") + 5; 447 show = strstr (response, "OID: ") + 5;
@@ -468,9 +494,20 @@ main (int argc, char **argv)
468 /* Process this block for numeric comparisons */ 494 /* Process this block for numeric comparisons */
469 /* Make some special values,like Timeticks numeric only if a threshold is defined */ 495 /* Make some special values,like Timeticks numeric only if a threshold is defined */
470 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) { 496 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
497 if (verbose > 2) {
498 print_thresholds(" thresholds", thlds[i]);
499 }
471 ptr = strpbrk (show, "-0123456789"); 500 ptr = strpbrk (show, "-0123456789");
472 if (ptr == NULL) 501 if (ptr == NULL){
473 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); 502 if (nulloid == 3)
503 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
504 else if (nulloid == 0)
505 die (STATE_OK,_("No valid data returned (%s)\n"), show);
506 else if (nulloid == 1)
507 die (STATE_WARNING,_("No valid data returned (%s)\n"), show);
508 else if (nulloid == 2)
509 die (STATE_CRITICAL,_("No valid data returned (%s)\n"), show);
510 }
474 while (i >= response_size) { 511 while (i >= response_size) {
475 response_size += OID_COUNT_STEP; 512 response_size += OID_COUNT_STEP;
476 response_value = realloc(response_value, response_size * sizeof(*response_value)); 513 response_value = realloc(response_value, response_size * sizeof(*response_value));
@@ -576,20 +613,24 @@ main (int argc, char **argv)
576 len = sizeof(perfstr)-strlen(perfstr)-1; 613 len = sizeof(perfstr)-strlen(perfstr)-1;
577 strncat(perfstr, show, len>ptr-show ? ptr-show : len); 614 strncat(perfstr, show, len>ptr-show ? ptr-show : len);
578 615
616 if (strcmp(type, "") != 0) {
617 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
618 }
619
579 if (warning_thresholds) { 620 if (warning_thresholds) {
580 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 621 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
581 strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 622 if(thlds[i]->warning && thlds[i]->warning->text)
623 strncat(perfstr, thlds[i]->warning->text, sizeof(perfstr)-strlen(perfstr)-1);
582 } 624 }
583 625
584 if (critical_thresholds) { 626 if (critical_thresholds) {
585 if (!warning_thresholds) 627 if (!warning_thresholds)
586 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 628 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
587 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 629 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
588 strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 630 if(thlds[i]->critical && thlds[i]->critical->text)
631 strncat(perfstr, thlds[i]->critical->text, sizeof(perfstr)-strlen(perfstr)-1);
589 } 632 }
590 633
591 if (type)
592 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
593 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); 634 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
594 } 635 }
595 } 636 }
@@ -601,7 +642,7 @@ main (int argc, char **argv)
601 state_string=malloc(string_length); 642 state_string=malloc(string_length);
602 if(state_string==NULL) 643 if(state_string==NULL)
603 die(STATE_UNKNOWN, _("Cannot malloc")); 644 die(STATE_UNKNOWN, _("Cannot malloc"));
604 645
605 current_length=0; 646 current_length=0;
606 for(i=0; i<total_oids; i++) { 647 for(i=0; i<total_oids; i++) {
607 xasprintf(&temp_string,"%.0f",response_value[i]); 648 xasprintf(&temp_string,"%.0f",response_value[i]);
@@ -623,7 +664,7 @@ main (int argc, char **argv)
623 state_string[--current_length]='\0'; 664 state_string[--current_length]='\0';
624 if (verbose > 2) 665 if (verbose > 2)
625 printf("State string=%s\n",state_string); 666 printf("State string=%s\n",state_string);
626 667
627 /* This is not strictly the same as time now, but any subtle variations will cancel out */ 668 /* This is not strictly the same as time now, but any subtle variations will cancel out */
628 np_state_write_string(current_time, state_string ); 669 np_state_write_string(current_time, state_string );
629 if(previous_state==NULL) { 670 if(previous_state==NULL) {
@@ -655,6 +696,7 @@ process_arguments (int argc, char **argv)
655 {"oid", required_argument, 0, 'o'}, 696 {"oid", required_argument, 0, 'o'},
656 {"object", required_argument, 0, 'o'}, 697 {"object", required_argument, 0, 'o'},
657 {"delimiter", required_argument, 0, 'd'}, 698 {"delimiter", required_argument, 0, 'd'},
699 {"nulloid", required_argument, 0, 'z'},
658 {"output-delimiter", required_argument, 0, 'D'}, 700 {"output-delimiter", required_argument, 0, 'D'},
659 {"string", required_argument, 0, 's'}, 701 {"string", required_argument, 0, 's'},
660 {"timeout", required_argument, 0, 't'}, 702 {"timeout", required_argument, 0, 't'},
@@ -680,6 +722,11 @@ process_arguments (int argc, char **argv)
680 {"offset", required_argument, 0, L_OFFSET}, 722 {"offset", required_argument, 0, L_OFFSET},
681 {"invert-search", no_argument, 0, L_INVERT_SEARCH}, 723 {"invert-search", no_argument, 0, L_INVERT_SEARCH},
682 {"perf-oids", no_argument, 0, 'O'}, 724 {"perf-oids", no_argument, 0, 'O'},
725 {"ipv4", no_argument, 0, '4'},
726 {"ipv6", no_argument, 0, '6'},
727 {"multiplier", required_argument, 0, 'M'},
728 {"fmtstr", required_argument, 0, 'f'},
729 {"ignore-mib-parsing-errors", no_argument, false, L_IGNORE_MIB_PARSING_ERRORS},
683 {0, 0, 0, 0} 730 {0, 0, 0, 0}
684 }; 731 };
685 732
@@ -697,7 +744,7 @@ process_arguments (int argc, char **argv)
697 } 744 }
698 745
699 while (1) { 746 while (1) {
700 c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", 747 c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:M:f:z:",
701 longopts, &option); 748 longopts, &option);
702 749
703 if (c == -1 || c == EOF) 750 if (c == -1 || c == EOF)
@@ -808,6 +855,12 @@ process_arguments (int argc, char **argv)
808 eval_method[j+1] |= CRIT_PRESENT; 855 eval_method[j+1] |= CRIT_PRESENT;
809 } 856 }
810 break; 857 break;
858 case 'z': /* Null OID Return Check */
859 if (!is_integer (optarg))
860 usage2 (_("Exit status must be a positive integer"), optarg);
861 else
862 nulloid = atoi(optarg);
863 break;
811 case 's': /* string or substring */ 864 case 's': /* string or substring */
812 strncpy (string_value, optarg, sizeof (string_value) - 1); 865 strncpy (string_value, optarg, sizeof (string_value) - 1);
813 string_value[sizeof (string_value) - 1] = 0; 866 string_value[sizeof (string_value) - 1] = 0;
@@ -821,6 +874,7 @@ process_arguments (int argc, char **argv)
821 break; 874 break;
822 case 'R': /* regex */ 875 case 'R': /* regex */
823 cflags = REG_ICASE; 876 cflags = REG_ICASE;
877 // fall through
824 case 'r': /* regex */ 878 case 'r': /* regex */
825 cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; 879 cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
826 strncpy (regex_expect, optarg, sizeof (regex_expect) - 1); 880 strncpy (regex_expect, optarg, sizeof (regex_expect) - 1);
@@ -922,6 +976,26 @@ process_arguments (int argc, char **argv)
922 case 'O': 976 case 'O':
923 perf_labels=0; 977 perf_labels=0;
924 break; 978 break;
979 case '4':
980 break;
981 case '6':
982 xasprintf(&ip_version, "udp6:");
983 if(verbose>2)
984 printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
985 break;
986 case 'M':
987 if ( strspn( optarg, "0123456789.," ) == strlen( optarg ) ) {
988 multiplier=strtod(optarg,NULL);
989 }
990 break;
991 case 'f':
992 if (multiplier != 1.0) {
993 fmtstr=optarg;
994 fmtstr_set = true;
995 }
996 break;
997 case L_IGNORE_MIB_PARSING_ERRORS:
998 ignore_mib_parsing_errors = true;
925 } 999 }
926 } 1000 }
927 1001
@@ -991,7 +1065,7 @@ validate_arguments ()
991 contextargs[0] = strdup ("-n"); 1065 contextargs[0] = strdup ("-n");
992 contextargs[1] = strdup (context); 1066 contextargs[1] = strdup (context);
993 } 1067 }
994 1068
995 if (seclevel == NULL) 1069 if (seclevel == NULL)
996 xasprintf(&seclevel, "noAuthNoPriv"); 1070 xasprintf(&seclevel, "noAuthNoPriv");
997 1071
@@ -1112,6 +1186,44 @@ nextarg (char *str)
1112 1186
1113 1187
1114 1188
1189/* multiply result (values 0 < n < 1 work as divider) */
1190char *
1191multiply (char *str)
1192{
1193 char *endptr;
1194 double val;
1195 char *conv = "%f";
1196
1197 if(multiplier == 1)
1198 return(str);
1199
1200 if(verbose>2)
1201 printf(" multiply input: %s\n", str);
1202
1203 val = strtod (str, &endptr);
1204 if ((val == 0.0) && (endptr == str)) {
1205 die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str);
1206 }
1207
1208 if(verbose>2)
1209 printf(" multiply extracted double: %f\n", val);
1210 val *= multiplier;
1211 if (fmtstr_set) {
1212 conv = fmtstr;
1213 }
1214 if (val == (int)val) {
1215 snprintf(buffer, DEFAULT_BUFFER_SIZE, "%.0f", val);
1216 } else {
1217 if(verbose>2)
1218 printf(" multiply using format: %s\n", conv);
1219 snprintf(buffer, DEFAULT_BUFFER_SIZE, conv, val);
1220 }
1221 if(verbose>2)
1222 printf(" multiply result: %s\n", buffer);
1223 return buffer;
1224}
1225
1226
1115void 1227void
1116print_help (void) 1228print_help (void)
1117{ 1229{
@@ -1127,6 +1239,7 @@ print_help (void)
1127 1239
1128 printf (UT_HELP_VRSN); 1240 printf (UT_HELP_VRSN);
1129 printf (UT_EXTRA_OPTS); 1241 printf (UT_EXTRA_OPTS);
1242 printf (UT_IPv46);
1130 1243
1131 printf (UT_HOST_PORT, 'p', DEFAULT_PORT); 1244 printf (UT_HOST_PORT, 'p', DEFAULT_PORT);
1132 1245
@@ -1150,7 +1263,7 @@ print_help (void)
1150 printf ("(%s \"%s\")\n", _("default is") ,DEFAULT_COMMUNITY); 1263 printf ("(%s \"%s\")\n", _("default is") ,DEFAULT_COMMUNITY);
1151 printf (" %s\n", "-U, --secname=USERNAME"); 1264 printf (" %s\n", "-U, --secname=USERNAME");
1152 printf (" %s\n", _("SNMPv3 username")); 1265 printf (" %s\n", _("SNMPv3 username"));
1153 printf (" %s\n", "-A, --authpassword=PASSWORD"); 1266 printf (" %s\n", "-A, --authpasswd=PASSWORD");
1154 printf (" %s\n", _("SNMPv3 authentication password")); 1267 printf (" %s\n", _("SNMPv3 authentication password"));
1155 printf (" %s\n", "-X, --privpasswd=PASSWORD"); 1268 printf (" %s\n", "-X, --privpasswd=PASSWORD");
1156 printf (" %s\n", _("SNMPv3 privacy password")); 1269 printf (" %s\n", _("SNMPv3 privacy password"));
@@ -1165,6 +1278,14 @@ print_help (void)
1165 printf (" %s \"%s\"\n", _("Delimiter to use when parsing returned data. Default is"), DEFAULT_DELIMITER); 1278 printf (" %s \"%s\"\n", _("Delimiter to use when parsing returned data. Default is"), DEFAULT_DELIMITER);
1166 printf (" %s\n", _("Any data on the right hand side of the delimiter is considered")); 1279 printf (" %s\n", _("Any data on the right hand side of the delimiter is considered"));
1167 printf (" %s\n", _("to be the data that should be used in the evaluation.")); 1280 printf (" %s\n", _("to be the data that should be used in the evaluation."));
1281 printf (" %s\n", "-z, --nulloid=#");
1282 printf (" %s\n", _("If the check returns a 0 length string or NULL value"));
1283 printf (" %s\n", _("This option allows you to choose what status you want it to exit"));
1284 printf (" %s\n", _("Excluding this option renders the default exit of 3(STATE_UNKNOWN)"));
1285 printf (" %s\n", _("0 = OK"));
1286 printf (" %s\n", _("1 = WARNING"));
1287 printf (" %s\n", _("2 = CRITICAL"));
1288 printf (" %s\n", _("3 = UNKNOWN"));
1168 1289
1169 /* Tests Against Integers */ 1290 /* Tests Against Integers */
1170 printf (" %s\n", "-w, --warning=THRESHOLD(s)"); 1291 printf (" %s\n", "-w, --warning=THRESHOLD(s)");
@@ -1176,7 +1297,7 @@ print_help (void)
1176 printf (" %s\n", "--rate-multiplier"); 1297 printf (" %s\n", "--rate-multiplier");
1177 printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); 1298 printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute"));
1178 printf (" %s\n", "--offset=OFFSET"); 1299 printf (" %s\n", "--offset=OFFSET");
1179 printf (" %s\n", _("Add/substract the specified OFFSET to numeric sensor data")); 1300 printf (" %s\n", _("Add/subtract the specified OFFSET to numeric sensor data"));
1180 1301
1181 /* Tests Against Strings */ 1302 /* Tests Against Strings */
1182 printf (" %s\n", "-s, --string=STRING"); 1303 printf (" %s\n", "-s, --string=STRING");
@@ -1195,14 +1316,22 @@ print_help (void)
1195 printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.').")); 1316 printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.')."));
1196 printf (" %s\n", "-D, --output-delimiter=STRING"); 1317 printf (" %s\n", "-D, --output-delimiter=STRING");
1197 printf (" %s\n", _("Separates output on multiple OID requests")); 1318 printf (" %s\n", _("Separates output on multiple OID requests"));
1319 printf (" %s\n", "-M, --multiplier=FLOAT");
1320 printf (" %s\n", _("Multiplies current value, 0 < n < 1 works as divider, defaults to 1"));
1321 printf (" %s\n", "-f, --fmtstr=STRING");
1322 printf (" %s\n", _("C-style format string for float values (see option -M)"));
1198 1323
1199 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1324 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1325 printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5"));
1200 printf (" %s\n", "-e, --retries=INTEGER"); 1326 printf (" %s\n", "-e, --retries=INTEGER");
1201 printf (" %s\n", _("Number of retries to be used in the requests")); 1327 printf (" %s%i\n", _("Number of retries to be used in the requests, default: "), DEFAULT_RETRIES);
1202 1328
1203 printf (" %s\n", "-O, --perf-oids"); 1329 printf (" %s\n", "-O, --perf-oids");
1204 printf (" %s\n", _("Label performance data with OIDs instead of --label's")); 1330 printf (" %s\n", _("Label performance data with OIDs instead of --label's"));
1205 1331
1332 printf (" %s\n", "--ignore-mib-parsing-errors");
1333 printf (" %s\n", _("Tell snmpget to not print errors encountered when parsing MIB files"));
1334
1206 printf (UT_VERBOSE); 1335 printf (UT_VERBOSE);
1207 1336
1208 printf ("\n"); 1337 printf ("\n");
@@ -1245,5 +1374,6 @@ print_usage (void)
1245 printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); 1374 printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n");
1246 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); 1375 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
1247 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); 1376 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
1248 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); 1377 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
1378 printf ("[-M multiplier [-f format]]\n");
1249} 1379}
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 4d5a4071..cd965e31 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -1,30 +1,30 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_swap plugin 3* Monitoring check_swap plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
7* Copyright (c) 2000-2007 Monitoring Plugins Development Team 7* Copyright (c) 2000-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
11* This file contains the check_swap plugin 11* This file contains the check_swap plugin
12* 12*
13* 13*
14* This program is free software: you can redistribute it and/or modify 14* This program is free software: you can redistribute it and/or modify
15* it under the terms of the GNU General Public License as published by 15* it under the terms of the GNU General Public License as published by
16* the Free Software Foundation, either version 3 of the License, or 16* the Free Software Foundation, either version 3 of the License, or
17* (at your option) any later version. 17* (at your option) any later version.
18* 18*
19* This program is distributed in the hope that it will be useful, 19* This program is distributed in the hope that it will be useful,
20* but WITHOUT ANY WARRANTY; without even the implied warranty of 20* but WITHOUT ANY WARRANTY; without even the implied warranty of
21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22* GNU General Public License for more details. 22* GNU General Public License for more details.
23* 23*
24* You should have received a copy of the GNU General Public License 24* You should have received a copy of the GNU General Public License
25* along with this program. If not, see <http://www.gnu.org/licenses/>. 25* along with this program. If not, see <http://www.gnu.org/licenses/>.
26* 26*
27* 27*
28*****************************************************************************/ 28*****************************************************************************/
29 29
30const char *progname = "check_swap"; 30const char *progname = "check_swap";
@@ -51,16 +51,19 @@ const char *email = "devel@monitoring-plugins.org";
51# define SWAP_CONVERSION 1 51# define SWAP_CONVERSION 1
52#endif 52#endif
53 53
54int check_swap (int usp, float free_swap_mb); 54typedef struct {
55 int is_percentage;
56 uint64_t value;
57} threshold_t;
58
59int check_swap (float free_swap_mb, float total_swap_mb);
55int process_arguments (int argc, char **argv); 60int process_arguments (int argc, char **argv);
56int validate_arguments (void); 61int validate_arguments (void);
57void print_usage (void); 62void print_usage (void);
58void print_help (void); 63void print_help (void);
59 64
60int warn_percent = 0; 65threshold_t warn;
61int crit_percent = 0; 66threshold_t crit;
62float warn_size_bytes = 0;
63float crit_size_bytes = 0;
64int verbose; 67int verbose;
65int allswaps; 68int allswaps;
66int no_swap_state = STATE_CRITICAL; 69int no_swap_state = STATE_CRITICAL;
@@ -68,9 +71,10 @@ int no_swap_state = STATE_CRITICAL;
68int 71int
69main (int argc, char **argv) 72main (int argc, char **argv)
70{ 73{
71 int percent_used, percent; 74 unsigned int percent_used, percent;
72 float total_swap_mb = 0, used_swap_mb = 0, free_swap_mb = 0; 75 uint64_t total_swap_mb = 0, used_swap_mb = 0, free_swap_mb = 0;
73 float dsktotal_mb = 0, dskused_mb = 0, dskfree_mb = 0, tmp_mb = 0; 76 uint64_t dsktotal_mb = 0, dskused_mb = 0, dskfree_mb = 0;
77 uint64_t tmp_KB = 0;
74 int result = STATE_UNKNOWN; 78 int result = STATE_UNKNOWN;
75 char input_buffer[MAX_INPUT_BUFFER]; 79 char input_buffer[MAX_INPUT_BUFFER];
76#ifdef HAVE_PROC_MEMINFO 80#ifdef HAVE_PROC_MEMINFO
@@ -116,10 +120,15 @@ main (int argc, char **argv)
116 } 120 }
117 fp = fopen (PROC_MEMINFO, "r"); 121 fp = fopen (PROC_MEMINFO, "r");
118 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { 122 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
119 if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %f %f %f", &dsktotal_mb, &dskused_mb, &dskfree_mb) == 3) { 123 /*
120 dsktotal_mb = dsktotal_mb / 1048576; /* Apply conversion */ 124 * The following sscanf call looks for a line looking like: "Swap: 123 123 123"
121 dskused_mb = dskused_mb / 1048576; 125 * On which kind of system this format exists, I can not say, but I wanted to
122 dskfree_mb = dskfree_mb / 1048576; 126 * document this for people who are not adapt with sscanf anymore, like me
127 */
128 if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %lu %lu %lu", &dsktotal_mb, &dskused_mb, &dskfree_mb) == 3) {
129 dsktotal_mb = dsktotal_mb / (1024 * 1024); /* Apply conversion */
130 dskused_mb = dskused_mb / (1024 * 1024);
131 dskfree_mb = dskfree_mb / (1024 * 1024);
123 total_swap_mb += dsktotal_mb; 132 total_swap_mb += dsktotal_mb;
124 used_swap_mb += dskused_mb; 133 used_swap_mb += dskused_mb;
125 free_swap_mb += dskfree_mb; 134 free_swap_mb += dskfree_mb;
@@ -128,21 +137,29 @@ main (int argc, char **argv)
128 percent=100.0; 137 percent=100.0;
129 else 138 else
130 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 139 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
131 result = max_state (result, check_swap (percent, dskfree_mb)); 140 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
132 if (verbose) 141 if (verbose)
133 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 142 xasprintf (&status, "%s [%lu (%d%%)]", status, dskfree_mb, 100 - percent);
134 } 143 }
135 } 144 }
136 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) { 145
146 /*
147 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123"
148 * This format exists at least on Debian Linux with a 5.* kernel
149 */
150 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) {
137 if (verbose >= 3) { 151 if (verbose >= 3) {
138 printf("Got %s with %f\n", str, tmp_mb); 152 printf("Got %s with %lu\n", str, tmp_KB);
139 } 153 }
140 /* I think this part is always in Kb, so convert to mb */ 154 /* I think this part is always in Kb, so convert to mb */
141 if (strcmp ("Total", str) == 0) { 155 if (strcmp ("Total", str) == 0) {
142 dsktotal_mb = tmp_mb / 1024; 156 dsktotal_mb = tmp_KB / 1024;
143 } 157 }
144 else if (strcmp ("Free", str) == 0) { 158 else if (strcmp ("Free", str) == 0) {
145 dskfree_mb = tmp_mb / 1024; 159 dskfree_mb = dskfree_mb + tmp_KB / 1024;
160 }
161 else if (strcmp ("Cached", str) == 0) {
162 dskfree_mb = dskfree_mb + tmp_KB / 1024;
146 } 163 }
147 } 164 }
148 } 165 }
@@ -161,7 +178,7 @@ main (int argc, char **argv)
161# ifdef _AIX 178# ifdef _AIX
162 if (!allswaps) { 179 if (!allswaps) {
163 xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); 180 xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
164 xasprintf(&swap_format, "%s", "%f%*s %f"); 181 xasprintf(&swap_format, "%s", "%lu%*s %lu");
165 conv_factor = 1; 182 conv_factor = 1;
166 } 183 }
167# endif 184# endif
@@ -188,9 +205,9 @@ main (int argc, char **argv)
188 temp_buffer = strtok (input_buffer, " \n"); 205 temp_buffer = strtok (input_buffer, " \n");
189 while (temp_buffer) { 206 while (temp_buffer) {
190 if (strstr (temp_buffer, "blocks")) 207 if (strstr (temp_buffer, "blocks"))
191 sprintf (str, "%s %s", str, "%f"); 208 sprintf (str, "%s %s", str, "%lu");
192 else if (strstr (temp_buffer, "dskfree")) 209 else if (strstr (temp_buffer, "dskfree"))
193 sprintf (str, "%s %s", str, "%f"); 210 sprintf (str, "%s %s", str, "%lu");
194 else 211 else
195 sprintf (str, "%s %s", str, "%*s"); 212 sprintf (str, "%s %s", str, "%*s");
196 temp_buffer = strtok (NULL, " \n"); 213 temp_buffer = strtok (NULL, " \n");
@@ -227,7 +244,7 @@ main (int argc, char **argv)
227 free_swap_mb += dskfree_mb; 244 free_swap_mb += dskfree_mb;
228 if (allswaps) { 245 if (allswaps) {
229 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 246 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
230 result = max_state (result, check_swap (percent, dskfree_mb)); 247 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
231 if (verbose) 248 if (verbose)
232 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 249 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
233 } 250 }
@@ -289,7 +306,7 @@ main (int argc, char **argv)
289 306
290 if(allswaps && dsktotal_mb > 0){ 307 if(allswaps && dsktotal_mb > 0){
291 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 308 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
292 result = max_state (result, check_swap (percent, dskfree_mb)); 309 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
293 if (verbose) { 310 if (verbose) {
294 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 311 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
295 } 312 }
@@ -328,7 +345,7 @@ main (int argc, char **argv)
328 345
329 if(allswaps && dsktotal_mb > 0){ 346 if(allswaps && dsktotal_mb > 0){
330 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 347 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
331 result = max_state (result, check_swap (percent, dskfree_mb)); 348 result = max_state (result, check_swap(dskfree_mb, dsktotal_mb));
332 if (verbose) { 349 if (verbose) {
333 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 350 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
334 } 351 }
@@ -355,41 +372,55 @@ main (int argc, char **argv)
355 status = "- Swap is either disabled, not present, or of zero size. "; 372 status = "- Swap is either disabled, not present, or of zero size. ";
356 } 373 }
357 374
358 result = max_state (result, check_swap (percent_used, free_swap_mb)); 375 result = max_state (result, check_swap(free_swap_mb, total_swap_mb));
359 printf (_("SWAP %s - %d%% free (%d MB out of %d MB) %s|"), 376 printf (_("SWAP %s - %d%% free (%dMB out of %dMB) %s|"),
360 state_text (result), 377 state_text (result),
361 (100 - percent_used), (int) free_swap_mb, (int) total_swap_mb, status); 378 (100 - percent_used), (int) free_swap_mb, (int) total_swap_mb, status);
362 379
363 puts (perfdata ("swap", (long) free_swap_mb, "MB", 380 uint64_t warn_print = warn.value;
364 TRUE, (long) max (warn_size_bytes/(1024 * 1024), warn_percent/100.0*total_swap_mb), 381 if (warn.is_percentage) warn_print = warn.value * (total_swap_mb *1024 *1024/100);
365 TRUE, (long) max (crit_size_bytes/(1024 * 1024), crit_percent/100.0*total_swap_mb), 382 uint64_t crit_print = crit.value;
383 if (crit.is_percentage) crit_print = crit.value * (total_swap_mb *1024 *1024/100);
384
385 puts (perfdata_uint64 ("swap", free_swap_mb *1024 *1024, "B",
386 TRUE, warn_print,
387 TRUE, crit_print,
366 TRUE, 0, 388 TRUE, 0,
367 TRUE, (long) total_swap_mb)); 389 TRUE, (long) total_swap_mb * 1024 * 1024));
368 390
369 return result; 391 return result;
370} 392}
371 393
372 394
373
374int 395int
375check_swap (int usp, float free_swap_mb) 396check_swap(float free_swap_mb, float total_swap_mb)
376{ 397{
377 398
378 if (!free_swap_mb) return no_swap_state; 399 if (!total_swap_mb) return no_swap_state;
379 400
380 int result = STATE_UNKNOWN; 401 uint64_t free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */
381 float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */ 402
382 if (usp >= 0 && crit_percent != 0 && usp >= (100.0 - crit_percent)) 403 if (!crit.is_percentage && crit.value >= free_swap) return STATE_CRITICAL;
383 result = STATE_CRITICAL; 404 if (!warn.is_percentage && warn.value >= free_swap) return STATE_WARNING;
384 else if (crit_size_bytes > 0 && free_swap <= crit_size_bytes) 405
385 result = STATE_CRITICAL; 406
386 else if (usp >= 0 && warn_percent != 0 && usp >= (100.0 - warn_percent)) 407 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100;
387 result = STATE_WARNING; 408
388 else if (warn_size_bytes > 0 && free_swap <= warn_size_bytes) 409 if (crit.is_percentage &&
389 result = STATE_WARNING; 410 crit.value != 0 &&
390 else if (usp >= 0.0) 411 usage_percentage >= (100 - crit.value))
391 result = STATE_OK; 412 {
392 return result; 413 return STATE_CRITICAL;
414 }
415
416 if (warn.is_percentage &&
417 warn.value != 0 &&
418 usage_percentage >= (100 - warn.value))
419 {
420 return STATE_WARNING;
421 }
422
423 return STATE_OK;
393} 424}
394 425
395 426
@@ -422,42 +453,66 @@ process_arguments (int argc, char **argv)
422 break; 453 break;
423 454
424 switch (c) { 455 switch (c) {
425 case 'w': /* warning size threshold */ 456 case 'w': /* warning size threshold */
426 if (is_intnonneg (optarg)) { 457 {
427 warn_size_bytes = (float) atoi (optarg); 458 /*
428 break; 459 * We expect either a positive integer value without a unit, which means
429 } 460 * the unit is Bytes or a positive integer value and a percentage sign (%),
430 else if (strstr (optarg, ",") && 461 * which means the value must be with 0 and 100 and is relative to the total swap
431 strstr (optarg, "%") && 462 */
432 sscanf (optarg, "%f,%d%%", &warn_size_bytes, &warn_percent) == 2) { 463 size_t length;
433 warn_size_bytes = floorf(warn_size_bytes); 464 length = strlen(optarg);
434 break; 465
435 } 466 if (optarg[length - 1] == '%') {
436 else if (strstr (optarg, "%") && 467 /* It's percentage */
437 sscanf (optarg, "%d%%", &warn_percent) == 1) { 468 warn.is_percentage = 1;
438 break; 469 optarg[length - 1] = '\0';
439 } 470 if (is_uint64(optarg, &warn.value)) {
440 else { 471 if (warn.value > 100) {
441 usage4 (_("Warning threshold must be integer or percentage!")); 472 usage4 (_("Warning threshold percentage must be <= 100!"));
442 } 473 }
443 case 'c': /* critical size threshold */ 474 }
444 if (is_intnonneg (optarg)) { 475 break;
445 crit_size_bytes = (float) atoi (optarg); 476 } else {
446 break; 477 /* It's Bytes */
447 } 478 warn.is_percentage = 0;
448 else if (strstr (optarg, ",") && 479 if (is_uint64(optarg, &warn.value)) {
449 strstr (optarg, "%") && 480 break;
450 sscanf (optarg, "%f,%d%%", &crit_size_bytes, &crit_percent) == 2) { 481 } else {
451 crit_size_bytes = floorf(crit_size_bytes); 482 usage4 (_("Warning threshold be positive integer or percentage!"));
452 break; 483 }
453 } 484 }
454 else if (strstr (optarg, "%") &&
455 sscanf (optarg, "%d%%", &crit_percent) == 1) {
456 break;
457 }
458 else {
459 usage4 (_("Critical threshold must be integer or percentage!"));
460 } 485 }
486 case 'c': /* critical size threshold */
487 {
488 /*
489 * We expect either a positive integer value without a unit, which means
490 * the unit is Bytes or a positive integer value and a percentage sign (%),
491 * which means the value must be with 0 and 100 and is relative to the total swap
492 */
493 size_t length;
494 length = strlen(optarg);
495
496 if (optarg[length - 1] == '%') {
497 /* It's percentage */
498 crit.is_percentage = 1;
499 optarg[length - 1] = '\0';
500 if (is_uint64(optarg, &crit.value)) {
501 if (crit.value> 100) {
502 usage4 (_("Critical threshold percentage must be <= 100!"));
503 }
504 }
505 break;
506 } else {
507 /* It's Bytes */
508 crit.is_percentage = 0;
509 if (is_uint64(optarg, &crit.value)) {
510 break;
511 } else {
512 usage4 (_("Critical threshold be positive integer or percentage!"));
513 }
514 }
515 }
461 case 'a': /* all swap */ 516 case 'a': /* all swap */
462 allswaps = TRUE; 517 allswaps = TRUE;
463 break; 518 break;
@@ -465,6 +520,7 @@ process_arguments (int argc, char **argv)
465 if ((no_swap_state = mp_translate_state(optarg)) == ERROR) { 520 if ((no_swap_state = mp_translate_state(optarg)) == ERROR) {
466 usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 521 usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
467 } 522 }
523 break;
468 case 'v': /* verbose */ 524 case 'v': /* verbose */
469 verbose++; 525 verbose++;
470 break; 526 break;
@@ -482,23 +538,6 @@ process_arguments (int argc, char **argv)
482 c = optind; 538 c = optind;
483 if (c == argc) 539 if (c == argc)
484 return validate_arguments (); 540 return validate_arguments ();
485 if (warn_percent == 0 && is_intnonneg (argv[c]))
486 warn_percent = atoi (argv[c++]);
487
488 if (c == argc)
489 return validate_arguments ();
490 if (crit_percent == 0 && is_intnonneg (argv[c]))
491 crit_percent = atoi (argv[c++]);
492
493 if (c == argc)
494 return validate_arguments ();
495 if (warn_size_bytes == 0 && is_intnonneg (argv[c]))
496 warn_size_bytes = (float) atoi (argv[c++]);
497
498 if (c == argc)
499 return validate_arguments ();
500 if (crit_size_bytes == 0 && is_intnonneg (argv[c]))
501 crit_size_bytes = (float) atoi (argv[c++]);
502 541
503 return validate_arguments (); 542 return validate_arguments ();
504} 543}
@@ -508,17 +547,15 @@ process_arguments (int argc, char **argv)
508int 547int
509validate_arguments (void) 548validate_arguments (void)
510{ 549{
511 if (warn_percent == 0 && crit_percent == 0 && warn_size_bytes == 0 550 if (warn.value == 0 && crit.value == 0) {
512 && crit_size_bytes == 0) {
513 return ERROR; 551 return ERROR;
514 } 552 }
515 else if (warn_percent < crit_percent) { 553 else if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
516 usage4 554 /* This is NOT triggered if warn and crit are different units, e.g warn is percentage
517 (_("Warning percentage should be more than critical percentage")); 555 * and crit is absolute. We cannot determine the condition at this point since we
518 } 556 * dont know the value of total swap yet
519 else if (warn_size_bytes < crit_size_bytes) { 557 */
520 usage4 558 usage4(_("Warning should be more than critical"));
521 (_("Warning free space should be more than critical free space"));
522 } 559 }
523 return OK; 560 return OK;
524} 561}
@@ -534,7 +571,7 @@ print_help (void)
534 571
535 printf ("%s\n", _("Check swap space on local machine.")); 572 printf ("%s\n", _("Check swap space on local machine."));
536 573
537 printf ("\n\n"); 574 printf ("\n\n");
538 575
539 print_usage (); 576 print_usage ();
540 577
@@ -542,33 +579,32 @@ print_help (void)
542 printf (UT_EXTRA_OPTS); 579 printf (UT_EXTRA_OPTS);
543 580
544 printf (" %s\n", "-w, --warning=INTEGER"); 581 printf (" %s\n", "-w, --warning=INTEGER");
545 printf (" %s\n", _("Exit with WARNING status if less than INTEGER bytes of swap space are free")); 582 printf (" %s\n", _("Exit with WARNING status if less than INTEGER bytes of swap space are free"));
546 printf (" %s\n", "-w, --warning=PERCENT%%"); 583 printf (" %s\n", "-w, --warning=PERCENT%");
547 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of swap space is free")); 584 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of swap space is free"));
548 printf (" %s\n", "-c, --critical=INTEGER"); 585 printf (" %s\n", "-c, --critical=INTEGER");
549 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free")); 586 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free"));
550 printf (" %s\n", "-c, --critical=PERCENT%%"); 587 printf (" %s\n", "-c, --critical=PERCENT%");
551 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free")); 588 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free"));
552 printf (" %s\n", "-a, --allswaps"); 589 printf (" %s\n", "-a, --allswaps");
553 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one")); 590 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one"));
554 printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>"); 591 printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>");
555 printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state)); 592 printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state));
556 printf (UT_VERBOSE); 593 printf (UT_VERBOSE);
557 594
558 printf ("\n"); 595 printf ("\n");
559 printf ("%s\n", _("Notes:")); 596 printf ("%s\n", _("Notes:"));
560 printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked.")); 597 printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
561 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.")); 598 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
562 599
563 printf (UT_SUPPORT); 600 printf (UT_SUPPORT);
564} 601}
565 602
566 603
567
568void 604void
569print_usage (void) 605print_usage (void)
570{ 606{
571 printf ("%s\n", _("Usage:")); 607 printf ("%s\n", _("Usage:"));
572 printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname); 608 printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
573 printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n"); 609 printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n");
574} 610}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 6dc9aa96..1d307cf3 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -86,6 +86,11 @@ static char buffer[MAXBUF];
86static int expect_mismatch_state = STATE_WARNING; 86static int expect_mismatch_state = STATE_WARNING;
87static int match_flags = NP_MATCH_EXACT; 87static int match_flags = NP_MATCH_EXACT;
88 88
89#ifdef HAVE_SSL
90static char *sni = NULL;
91static int sni_specified = FALSE;
92#endif
93
89#define FLAG_SSL 0x01 94#define FLAG_SSL 0x01
90#define FLAG_VERBOSE 0x02 95#define FLAG_VERBOSE 0x02
91#define FLAG_TIME_WARN 0x04 96#define FLAG_TIME_WARN 0x04
@@ -123,7 +128,7 @@ main (int argc, char **argv)
123 SERVICE[i] = toupper(SERVICE[i]); 128 SERVICE[i] = toupper(SERVICE[i]);
124 } 129 }
125 130
126 /* set up a resonable buffer at first (will be realloc()'ed if 131 /* set up a reasonable buffer at first (will be realloc()'ed if
127 * user specifies other options) */ 132 * user specifies other options) */
128 server_expect = calloc(sizeof(char *), 2); 133 server_expect = calloc(sizeof(char *), 2);
129 134
@@ -241,14 +246,14 @@ main (int argc, char **argv)
241 246
242#ifdef HAVE_SSL 247#ifdef HAVE_SSL
243 if (flags & FLAG_SSL){ 248 if (flags & FLAG_SSL){
244 result = np_net_ssl_init(sd); 249 result = np_net_ssl_init_with_hostname(sd, (sni_specified ? sni : NULL));
245 if (result == STATE_OK && check_cert == TRUE) { 250 if (result == STATE_OK && check_cert == TRUE) {
246 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); 251 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
247 } 252 }
248 } 253 }
249 if(result != STATE_OK){ 254 if(result != STATE_OK){
250 np_net_ssl_cleanup();
251 if(sd) close(sd); 255 if(sd) close(sd);
256 np_net_ssl_cleanup();
252 return result; 257 return result;
253 } 258 }
254#endif /* HAVE_SSL */ 259#endif /* HAVE_SSL */
@@ -321,10 +326,10 @@ main (int argc, char **argv)
321 if (server_quit != NULL) { 326 if (server_quit != NULL) {
322 my_send(server_quit, strlen(server_quit)); 327 my_send(server_quit, strlen(server_quit));
323 } 328 }
329 if (sd) close (sd);
324#ifdef HAVE_SSL 330#ifdef HAVE_SSL
325 np_net_ssl_cleanup(); 331 np_net_ssl_cleanup();
326#endif 332#endif
327 if (sd) close (sd);
328 333
329 microsec = deltime (tv); 334 microsec = deltime (tv);
330 elapsed_time = (double)microsec / 1.0e6; 335 elapsed_time = (double)microsec / 1.0e6;
@@ -401,6 +406,10 @@ process_arguments (int argc, char **argv)
401 int escape = 0; 406 int escape = 0;
402 char *temp; 407 char *temp;
403 408
409 enum {
410 SNI_OPTION = CHAR_MAX + 1
411 };
412
404 int option = 0; 413 int option = 0;
405 static struct option longopts[] = { 414 static struct option longopts[] = {
406 {"hostname", required_argument, 0, 'H'}, 415 {"hostname", required_argument, 0, 'H'},
@@ -427,6 +436,7 @@ process_arguments (int argc, char **argv)
427 {"version", no_argument, 0, 'V'}, 436 {"version", no_argument, 0, 'V'},
428 {"help", no_argument, 0, 'h'}, 437 {"help", no_argument, 0, 'h'},
429 {"ssl", no_argument, 0, 'S'}, 438 {"ssl", no_argument, 0, 'S'},
439 {"sni", required_argument, 0, SNI_OPTION},
430 {"certificate", required_argument, 0, 'D'}, 440 {"certificate", required_argument, 0, 'D'},
431 {0, 0, 0, 0} 441 {0, 0, 0, 0}
432 }; 442 };
@@ -604,6 +614,15 @@ process_arguments (int argc, char **argv)
604 die (STATE_UNKNOWN, _("Invalid option - SSL is not available")); 614 die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
605#endif 615#endif
606 break; 616 break;
617 case SNI_OPTION:
618#ifdef HAVE_SSL
619 flags |= FLAG_SSL;
620 sni_specified = TRUE;
621 sni = optarg;
622#else
623 die (STATE_UNKNOWN, _("Invalid option - SSL is not available"));
624#endif
625 break;
607 case 'A': 626 case 'A':
608 match_flags |= NP_MATCH_ALL; 627 match_flags |= NP_MATCH_ALL;
609 break; 628 break;
@@ -671,6 +690,8 @@ print_help (void)
671 printf (" %s\n", _("1st is #days for warning, 2nd is critical (if not specified - 0).")); 690 printf (" %s\n", _("1st is #days for warning, 2nd is critical (if not specified - 0)."));
672 printf (" %s\n", "-S, --ssl"); 691 printf (" %s\n", "-S, --ssl");
673 printf (" %s\n", _("Use SSL for the connection.")); 692 printf (" %s\n", _("Use SSL for the connection."));
693 printf (" %s\n", "--sni=STRING");
694 printf (" %s\n", _("SSL server_name"));
674#endif 695#endif
675 696
676 printf (UT_WARN_CRIT); 697 printf (UT_WARN_CRIT);
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index e9e56a51..68737c4b 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -89,7 +89,7 @@ char *ups_status;
89int temp_output_c = 0; 89int temp_output_c = 0;
90 90
91int determine_status (void); 91int determine_status (void);
92int get_ups_variable (const char *, char *, size_t); 92int get_ups_variable (const char *, char *);
93 93
94int process_arguments (int, char **); 94int process_arguments (int, char **);
95int validate_arguments (void); 95int validate_arguments (void);
@@ -189,7 +189,7 @@ main (int argc, char **argv)
189 } 189 }
190 190
191 /* get the ups utility voltage if possible */ 191 /* get the ups utility voltage if possible */
192 res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer)); 192 res=get_ups_variable ("input.voltage", temp_buffer);
193 if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY; 193 if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY;
194 else if (res != OK) 194 else if (res != OK)
195 return STATE_CRITICAL; 195 return STATE_CRITICAL;
@@ -224,7 +224,7 @@ main (int argc, char **argv)
224 } 224 }
225 225
226 /* get the ups battery percent if possible */ 226 /* get the ups battery percent if possible */
227 res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer)); 227 res=get_ups_variable ("battery.charge", temp_buffer);
228 if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT; 228 if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT;
229 else if ( res != OK) 229 else if ( res != OK)
230 return STATE_CRITICAL; 230 return STATE_CRITICAL;
@@ -253,7 +253,7 @@ main (int argc, char **argv)
253 } 253 }
254 254
255 /* get the ups load percent if possible */ 255 /* get the ups load percent if possible */
256 res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer)); 256 res=get_ups_variable ("ups.load", temp_buffer);
257 if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT; 257 if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT;
258 else if ( res != OK) 258 else if ( res != OK)
259 return STATE_CRITICAL; 259 return STATE_CRITICAL;
@@ -282,7 +282,7 @@ main (int argc, char **argv)
282 } 282 }
283 283
284 /* get the ups temperature if possible */ 284 /* get the ups temperature if possible */
285 res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer)); 285 res=get_ups_variable ("ups.temperature", temp_buffer);
286 if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP; 286 if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP;
287 else if ( res != OK) 287 else if ( res != OK)
288 return STATE_CRITICAL; 288 return STATE_CRITICAL;
@@ -342,7 +342,7 @@ determine_status (void)
342 char *ptr; 342 char *ptr;
343 int res; 343 int res;
344 344
345 res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); 345 res=get_ups_variable ("ups.status", recv_buffer);
346 if (res == NOSUCHVAR) return OK; 346 if (res == NOSUCHVAR) return OK;
347 if (res != STATE_OK) { 347 if (res != STATE_OK) {
348 printf ("%s\n", _("Invalid response received from host")); 348 printf ("%s\n", _("Invalid response received from host"));
@@ -388,7 +388,7 @@ determine_status (void)
388 388
389/* gets a variable value for a specific UPS */ 389/* gets a variable value for a specific UPS */
390int 390int
391get_ups_variable (const char *varname, char *buf, size_t buflen) 391get_ups_variable (const char *varname, char *buf)
392{ 392{
393 /* char command[MAX_INPUT_BUFFER]; */ 393 /* char command[MAX_INPUT_BUFFER]; */
394 char temp_buffer[MAX_INPUT_BUFFER]; 394 char temp_buffer[MAX_INPUT_BUFFER];
@@ -402,7 +402,10 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
402 402
403 /* create the command string to send to the UPS daemon */ 403 /* create the command string to send to the UPS daemon */
404 /* Add LOGOUT to avoid read failure logs */ 404 /* Add LOGOUT to avoid read failure logs */
405 sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname); 405 if (snprintf (send_buffer, sizeof(send_buffer), "GET VAR %s %s\nLOGOUT\n", ups_name, varname) >= sizeof(send_buffer)) {
406 printf("%s\n", _("UPS name to long for buffer"));
407 return ERROR;
408 }
406 409
407 /* send the command to the daemon and get a response back */ 410 /* send the command to the daemon and get a response back */
408 if (process_tcp_request 411 if (process_tcp_request
@@ -504,7 +507,7 @@ process_arguments (int argc, char **argv)
504 usage2 (_("Invalid hostname/address"), optarg); 507 usage2 (_("Invalid hostname/address"), optarg);
505 } 508 }
506 break; 509 break;
507 case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */ 510 case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Fahrenheit) */
508 temp_output_c = 1; 511 temp_output_c = 1;
509 break; 512 break;
510 case 'u': /* ups name */ 513 case 'u': /* ups name */
diff --git a/plugins/check_users.c b/plugins/check_users.c
index 54415a48..2a9ee986 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -1,33 +1,33 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_users plugin 3* Monitoring check_users plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2012 Monitoring Plugins Development Team 6* Copyright (c) 2000-2012 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_users plugin 10* This file contains the check_users plugin
11* 11*
12* This plugin checks the number of users currently logged in on the local 12* This plugin checks the number of users currently logged in on the local
13* system and generates an error if the number exceeds the thresholds 13* system and generates an error if the number exceeds the thresholds
14* specified. 14* specified.
15* 15*
16* 16*
17* This program is free software: you can redistribute it and/or modify 17* This program is free software: you can redistribute it and/or modify
18* it under the terms of the GNU General Public License as published by 18* it under the terms of the GNU General Public License as published by
19* the Free Software Foundation, either version 3 of the License, or 19* the Free Software Foundation, either version 3 of the License, or
20* (at your option) any later version. 20* (at your option) any later version.
21* 21*
22* This program is distributed in the hope that it will be useful, 22* This program is distributed in the hope that it will be useful,
23* but WITHOUT ANY WARRANTY; without even the implied warranty of 23* but WITHOUT ANY WARRANTY; without even the implied warranty of
24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25* GNU General Public License for more details. 25* GNU General Public License for more details.
26* 26*
27* You should have received a copy of the GNU General Public License 27* You should have received a copy of the GNU General Public License
28* along with this program. If not, see <http://www.gnu.org/licenses/>. 28* along with this program. If not, see <http://www.gnu.org/licenses/>.
29* 29*
30* 30*
31*****************************************************************************/ 31*****************************************************************************/
32 32
33const char *progname = "check_users"; 33const char *progname = "check_users";
@@ -48,21 +48,26 @@ const char *email = "devel@monitoring-plugins.org";
48# include "popen.h" 48# include "popen.h"
49#endif 49#endif
50 50
51#ifdef HAVE_LIBSYSTEMD
52#include <systemd/sd-daemon.h>
53#include <systemd/sd-login.h>
54#endif
55
51#define possibly_set(a,b) ((a) == 0 ? (b) : 0) 56#define possibly_set(a,b) ((a) == 0 ? (b) : 0)
52 57
53int process_arguments (int, char **); 58int process_arguments (int, char **);
54void print_help (void); 59void print_help (void);
55void print_usage (void); 60void print_usage (void);
56 61
57int wusers = -1; 62char *warning_range = NULL;
58int cusers = -1; 63char *critical_range = NULL;
64thresholds *thlds = NULL;
59 65
60int 66int
61main (int argc, char **argv) 67main (int argc, char **argv)
62{ 68{
63 int users = -1; 69 int users = -1;
64 int result = STATE_UNKNOWN; 70 int result = STATE_UNKNOWN;
65 char *perf;
66#if HAVE_WTSAPI32_H 71#if HAVE_WTSAPI32_H
67 WTS_SESSION_INFO *wtsinfo; 72 WTS_SESSION_INFO *wtsinfo;
68 DWORD wtscount; 73 DWORD wtscount;
@@ -77,8 +82,6 @@ main (int argc, char **argv)
77 bindtextdomain (PACKAGE, LOCALEDIR); 82 bindtextdomain (PACKAGE, LOCALEDIR);
78 textdomain (PACKAGE); 83 textdomain (PACKAGE);
79 84
80 perf = strdup ("");
81
82 /* Parse extra opts if any */ 85 /* Parse extra opts if any */
83 argv = np_extra_opts (&argc, argv, progname); 86 argv = np_extra_opts (&argc, argv, progname);
84 87
@@ -87,6 +90,11 @@ main (int argc, char **argv)
87 90
88 users = 0; 91 users = 0;
89 92
93#ifdef HAVE_LIBSYSTEMD
94 if (sd_booted () > 0)
95 users = sd_get_sessions (NULL);
96 else {
97#endif
90#if HAVE_WTSAPI32_H 98#if HAVE_WTSAPI32_H
91 if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 99 if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
92 0, 1, &wtsinfo, &wtscount)) { 100 0, 1, &wtsinfo, &wtscount)) {
@@ -158,25 +166,20 @@ main (int argc, char **argv)
158 if (spclose (child_process)) 166 if (spclose (child_process))
159 result = possibly_set (result, STATE_UNKNOWN); 167 result = possibly_set (result, STATE_UNKNOWN);
160#endif 168#endif
169#ifdef HAVE_LIBSYSTEMD
170 }
171#endif
161 172
162 /* check the user count against warning and critical thresholds */ 173 /* check the user count against warning and critical thresholds */
163 if (users > cusers) 174 result = get_status((double)users, thlds);
164 result = STATE_CRITICAL;
165 else if (users > wusers)
166 result = STATE_WARNING;
167 else if (users >= 0)
168 result = STATE_OK;
169 175
170 if (result == STATE_UNKNOWN) 176 if (result == STATE_UNKNOWN)
171 printf ("%s\n", _("Unable to read output")); 177 printf ("%s\n", _("Unable to read output"));
172 else { 178 else {
173 xasprintf (&perf, "%s", perfdata ("users", users, "", 179 printf (_("USERS %s - %d users currently logged in |%s\n"),
174 TRUE, wusers, 180 state_text(result), users,
175 TRUE, cusers, 181 sperfdata_int("users", users, "", warning_range,
176 TRUE, 0, 182 critical_range, TRUE, 0, FALSE, 0));
177 FALSE, 0));
178 printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result),
179 users, perf);
180 } 183 }
181 184
182 return result; 185 return result;
@@ -215,33 +218,27 @@ process_arguments (int argc, char **argv)
215 print_revision (progname, NP_VERSION); 218 print_revision (progname, NP_VERSION);
216 exit (STATE_UNKNOWN); 219 exit (STATE_UNKNOWN);
217 case 'c': /* critical */ 220 case 'c': /* critical */
218 if (!is_intnonneg (optarg)) 221 critical_range = optarg;
219 usage4 (_("Critical threshold must be a positive integer"));
220 else
221 cusers = atoi (optarg);
222 break; 222 break;
223 case 'w': /* warning */ 223 case 'w': /* warning */
224 if (!is_intnonneg (optarg)) 224 warning_range = optarg;
225 usage4 (_("Warning threshold must be a positive integer"));
226 else
227 wusers = atoi (optarg);
228 break; 225 break;
229 } 226 }
230 } 227 }
231 228
232 c = optind; 229 c = optind;
233 if (wusers == -1 && argc > c) { 230 if (warning_range == NULL && argc > c)
234 if (is_intnonneg (argv[c]) == FALSE) 231 warning_range = argv[c++];
235 usage4 (_("Warning threshold must be a positive integer")); 232 if (critical_range == NULL && argc > c)
236 else 233 critical_range = argv[c++];
237 wusers = atoi (argv[c++]); 234
238 } 235 /* this will abort in case of invalid ranges */
239 if (cusers == -1 && argc > c) { 236 set_thresholds (&thlds, warning_range, critical_range);
240 if (is_intnonneg (argv[c]) == FALSE) 237
241 usage4 (_("Warning threshold must be a positive integer")); 238 if (thlds->warning->end < 0)
242 else 239 usage4 (_("Warning threshold must be a positive integer"));
243 cusers = atoi (argv[c]); 240 if (thlds->critical->end < 0)
244 } 241 usage4 (_("Critical threshold must be a positive integer"));
245 242
246 return OK; 243 return OK;
247} 244}
diff --git a/plugins/common.h b/plugins/common.h
index 01003b3b..6bf4fca4 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -161,12 +161,24 @@
161# endif 161# endif
162#endif 162#endif
163 163
164/* openssl 1.1 does not set OPENSSL_NO_SSL2 by default but ships without ssl2 */
165#ifdef OPENSSL_VERSION_NUMBER
166# if OPENSSL_VERSION_NUMBER >= 0x10100000
167# define OPENSSL_NO_SSL2
168# endif
169#endif
170
164/* 171/*
165 * 172 *
166 * Standard Values 173 * Standard Values
167 * 174 *
168 */ 175 */
169 176
177/* MariaDB 10.2 client does not set MYSQL_PORT */
178#ifndef MYSQL_PORT
179# define MYSQL_PORT 3306
180#endif
181
170enum { 182enum {
171 OK = 0, 183 OK = 0,
172 ERROR = -1 184 ERROR = -1
diff --git a/plugins/negate.c b/plugins/negate.c
index beaed1ea..50f62d33 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -59,8 +59,8 @@ static int state[4] = {
59int 59int
60main (int argc, char **argv) 60main (int argc, char **argv)
61{ 61{
62 int found = 0, result = STATE_UNKNOWN; 62 int result = STATE_UNKNOWN;
63 char *buf, *sub; 63 char *sub;
64 char **command_line; 64 char **command_line;
65 output chld_out, chld_err; 65 output chld_out, chld_err;
66 int i; 66 int i;
@@ -86,11 +86,9 @@ main (int argc, char **argv)
86 result = cmd_run_array (command_line, &chld_out, &chld_err, 0); 86 result = cmd_run_array (command_line, &chld_out, &chld_err, 0);
87 } 87 }
88 if (chld_err.lines > 0) { 88 if (chld_err.lines > 0) {
89 printf ("Error output from command:\n");
90 for (i = 0; i < chld_err.lines; i++) { 89 for (i = 0; i < chld_err.lines; i++) {
91 printf ("%s\n", chld_err.line[i]); 90 fprintf (stderr, "%s\n", chld_err.line[i]);
92 } 91 }
93 exit (STATE_WARNING);
94 } 92 }
95 93
96 /* Return UNKNOWN or worse if no output is returned */ 94 /* Return UNKNOWN or worse if no output is returned */
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 705aaf09..1bb4f076 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -359,20 +359,21 @@ is_addr (const char *address)
359} 359}
360 360
361int 361int
362resolve_host_or_addr (const char *address, int family) 362dns_lookup (const char *in, struct sockaddr_storage *ss, int family)
363{ 363{
364 struct addrinfo hints; 364 struct addrinfo hints;
365 struct addrinfo *res; 365 struct addrinfo *res;
366 int retval; 366 int retval;
367 367
368 memset (&hints, 0, sizeof (hints)); 368 memset (&hints, 0, sizeof(struct addrinfo));
369 hints.ai_family = family; 369 hints.ai_family = family;
370 retval = getaddrinfo (address, NULL, &hints, &res);
371 370
371 retval = getaddrinfo (in, NULL, &hints, &res);
372 if (retval != 0) 372 if (retval != 0)
373 return FALSE; 373 return FALSE;
374 else { 374
375 freeaddrinfo (res); 375 if (ss != NULL)
376 return TRUE; 376 memcpy (ss, res->ai_addr, res->ai_addrlen);
377 } 377 freeaddrinfo (res);
378 return TRUE;
378} 379}
diff --git a/plugins/netutils.h b/plugins/netutils.h
index 2766029e..ea653e72 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -45,6 +45,10 @@
45# endif /* UNIX_PATH_MAX */ 45# endif /* UNIX_PATH_MAX */
46#endif /* HAVE_SYS_UN_H */ 46#endif /* HAVE_SYS_UN_H */
47 47
48#ifndef HOST_MAX_BYTES
49# define HOST_MAX_BYTES 255
50#endif
51
48/* process_request and wrapper macros */ 52/* process_request and wrapper macros */
49#define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ 53#define process_tcp_request(addr, port, sbuf, rbuf, rsize) \
50 process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) 54 process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize)
@@ -71,8 +75,9 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer,
71/* "is_*" wrapper macros and functions */ 75/* "is_*" wrapper macros and functions */
72int is_host (const char *); 76int is_host (const char *);
73int is_addr (const char *); 77int is_addr (const char *);
74int resolve_host_or_addr (const char *, int); 78int dns_lookup (const char *, struct sockaddr_storage *, int);
75void host_or_die(const char *str); 79void host_or_die(const char *str);
80#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family)
76#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) 81#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET)
77#ifdef USE_IPV6 82#ifdef USE_IPV6
78# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) 83# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)
@@ -87,7 +92,7 @@ extern int econn_refuse_state;
87extern int was_refused; 92extern int was_refused;
88extern int address_family; 93extern int address_family;
89 94
90RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); 95void socket_timeout_alarm_handler (int) __attribute__((noreturn));
91 96
92/* SSL-Related functionality */ 97/* SSL-Related functionality */
93#ifdef HAVE_SSL 98#ifdef HAVE_SSL
diff --git a/plugins/picohttpparser/Makefile.am b/plugins/picohttpparser/Makefile.am
new file mode 100644
index 00000000..87e05313
--- /dev/null
+++ b/plugins/picohttpparser/Makefile.am
@@ -0,0 +1,3 @@
1noinst_LIBRARIES = libpicohttpparser.a
2
3libpicohttpparser_a_SOURCES = picohttpparser.c picohttpparser.h
diff --git a/plugins/picohttpparser/picohttpparser.c b/plugins/picohttpparser/picohttpparser.c
new file mode 100644
index 00000000..d0bfac62
--- /dev/null
+++ b/plugins/picohttpparser/picohttpparser.c
@@ -0,0 +1,651 @@
1/*
2 * Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase,
3 * Shigeo Mitsunari
4 *
5 * The software is licensed under either the MIT License (below) or the Perl
6 * license.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to
10 * deal in the Software without restriction, including without limitation the
11 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 * sell copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * IN THE SOFTWARE.
25 */
26
27#include <assert.h>
28#include <stddef.h>
29#include <string.h>
30#ifdef __SSE4_2__
31#ifdef _MSC_VER
32#include <nmmintrin.h>
33#else
34#include <x86intrin.h>
35#endif
36#endif
37#include "picohttpparser.h"
38
39#if __GNUC__ >= 3
40#define likely(x) __builtin_expect(!!(x), 1)
41#define unlikely(x) __builtin_expect(!!(x), 0)
42#else
43#define likely(x) (x)
44#define unlikely(x) (x)
45#endif
46
47#ifdef _MSC_VER
48#define ALIGNED(n) _declspec(align(n))
49#else
50#define ALIGNED(n) __attribute__((aligned(n)))
51#endif
52
53#define IS_PRINTABLE_ASCII(c) ((unsigned char)(c)-040u < 0137u)
54
55#define CHECK_EOF() \
56 if (buf == buf_end) { \
57 *ret = -2; \
58 return NULL; \
59 }
60
61#define EXPECT_CHAR_NO_CHECK(ch) \
62 if (*buf++ != ch) { \
63 *ret = -1; \
64 return NULL; \
65 }
66
67#define EXPECT_CHAR(ch) \
68 CHECK_EOF(); \
69 EXPECT_CHAR_NO_CHECK(ch);
70
71#define ADVANCE_TOKEN(tok, toklen) \
72 do { \
73 const char *tok_start = buf; \
74 static const char ALIGNED(16) ranges2[16] = "\000\040\177\177"; \
75 int found2; \
76 buf = findchar_fast(buf, buf_end, ranges2, 4, &found2); \
77 if (!found2) { \
78 CHECK_EOF(); \
79 } \
80 while (1) { \
81 if (*buf == ' ') { \
82 break; \
83 } else if (unlikely(!IS_PRINTABLE_ASCII(*buf))) { \
84 if ((unsigned char)*buf < '\040' || *buf == '\177') { \
85 *ret = -1; \
86 return NULL; \
87 } \
88 } \
89 ++buf; \
90 CHECK_EOF(); \
91 } \
92 tok = tok_start; \
93 toklen = buf - tok_start; \
94 } while (0)
95
96static const char *token_char_map = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
97 "\0\1\0\1\1\1\1\1\0\0\1\1\0\1\1\0\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0"
98 "\0\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\1\1"
99 "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\1\0\1\0"
100 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
101 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
102 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
103 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
104
105static const char *findchar_fast(const char *buf, const char *buf_end, const char *ranges, size_t ranges_size, int *found)
106{
107 *found = 0;
108#if __SSE4_2__
109 if (likely(buf_end - buf >= 16)) {
110 __m128i ranges16 = _mm_loadu_si128((const __m128i *)ranges);
111
112 size_t left = (buf_end - buf) & ~15;
113 do {
114 __m128i b16 = _mm_loadu_si128((const __m128i *)buf);
115 int r = _mm_cmpestri(ranges16, ranges_size, b16, 16, _SIDD_LEAST_SIGNIFICANT | _SIDD_CMP_RANGES | _SIDD_UBYTE_OPS);
116 if (unlikely(r != 16)) {
117 buf += r;
118 *found = 1;
119 break;
120 }
121 buf += 16;
122 left -= 16;
123 } while (likely(left != 0));
124 }
125#else
126 /* suppress unused parameter warning */
127 (void)buf_end;
128 (void)ranges;
129 (void)ranges_size;
130#endif
131 return buf;
132}
133
134static const char *get_token_to_eol(const char *buf, const char *buf_end, const char **token, size_t *token_len, int *ret)
135{
136 const char *token_start = buf;
137
138#ifdef __SSE4_2__
139 static const char ALIGNED(16) ranges1[16] = "\0\010" /* allow HT */
140 "\012\037" /* allow SP and up to but not including DEL */
141 "\177\177"; /* allow chars w. MSB set */
142 int found;
143 buf = findchar_fast(buf, buf_end, ranges1, 6, &found);
144 if (found)
145 goto FOUND_CTL;
146#else
147 /* find non-printable char within the next 8 bytes, this is the hottest code; manually inlined */
148 while (likely(buf_end - buf >= 8)) {
149#define DOIT() \
150 do { \
151 if (unlikely(!IS_PRINTABLE_ASCII(*buf))) \
152 goto NonPrintable; \
153 ++buf; \
154 } while (0)
155 DOIT();
156 DOIT();
157 DOIT();
158 DOIT();
159 DOIT();
160 DOIT();
161 DOIT();
162 DOIT();
163#undef DOIT
164 continue;
165 NonPrintable:
166 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
167 goto FOUND_CTL;
168 }
169 ++buf;
170 }
171#endif
172 for (;; ++buf) {
173 CHECK_EOF();
174 if (unlikely(!IS_PRINTABLE_ASCII(*buf))) {
175 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
176 goto FOUND_CTL;
177 }
178 }
179 }
180FOUND_CTL:
181 if (likely(*buf == '\015')) {
182 ++buf;
183 EXPECT_CHAR('\012');
184 *token_len = buf - 2 - token_start;
185 } else if (*buf == '\012') {
186 *token_len = buf - token_start;
187 ++buf;
188 } else {
189 *ret = -1;
190 return NULL;
191 }
192 *token = token_start;
193
194 return buf;
195}
196
197static const char *is_complete(const char *buf, const char *buf_end, size_t last_len, int *ret)
198{
199 int ret_cnt = 0;
200 buf = last_len < 3 ? buf : buf + last_len - 3;
201
202 while (1) {
203 CHECK_EOF();
204 if (*buf == '\015') {
205 ++buf;
206 CHECK_EOF();
207 EXPECT_CHAR('\012');
208 ++ret_cnt;
209 } else if (*buf == '\012') {
210 ++buf;
211 ++ret_cnt;
212 } else {
213 ++buf;
214 ret_cnt = 0;
215 }
216 if (ret_cnt == 2) {
217 return buf;
218 }
219 }
220
221 *ret = -2;
222 return NULL;
223}
224
225#define PARSE_INT(valp_, mul_) \
226 if (*buf < '0' || '9' < *buf) { \
227 buf++; \
228 *ret = -1; \
229 return NULL; \
230 } \
231 *(valp_) = (mul_) * (*buf++ - '0');
232
233#define PARSE_INT_3(valp_) \
234 do { \
235 int res_ = 0; \
236 PARSE_INT(&res_, 100) \
237 *valp_ = res_; \
238 PARSE_INT(&res_, 10) \
239 *valp_ += res_; \
240 PARSE_INT(&res_, 1) \
241 *valp_ += res_; \
242 } while (0)
243
244/* returned pointer is always within [buf, buf_end), or null */
245static const char *parse_http_version(const char *buf, const char *buf_end, int *major_version, int *minor_version, int *ret)
246{
247 /* we want at least [HTTP/1.<two chars>] to try to parse */
248 if (buf_end - buf < 9) {
249 *ret = -2;
250 return NULL;
251 }
252 EXPECT_CHAR_NO_CHECK('H');
253 EXPECT_CHAR_NO_CHECK('T');
254 EXPECT_CHAR_NO_CHECK('T');
255 EXPECT_CHAR_NO_CHECK('P');
256 EXPECT_CHAR_NO_CHECK('/');
257 PARSE_INT(major_version, 1);
258 if (*major_version == 1) {
259 EXPECT_CHAR_NO_CHECK('.');
260 PARSE_INT(minor_version, 1);
261 } else {
262 *minor_version = 0;
263 }
264 return buf;
265}
266
267static const char *parse_headers(const char *buf, const char *buf_end, struct phr_header *headers, size_t *num_headers,
268 size_t max_headers, int *ret)
269{
270 for (;; ++*num_headers) {
271 CHECK_EOF();
272 if (*buf == '\015') {
273 ++buf;
274 EXPECT_CHAR('\012');
275 break;
276 } else if (*buf == '\012') {
277 ++buf;
278 break;
279 }
280 if (*num_headers == max_headers) {
281 *ret = -1;
282 return NULL;
283 }
284 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
285 /* parsing name, but do not discard SP before colon, see
286 * http://www.mozilla.org/security/announce/2006/mfsa2006-33.html */
287 headers[*num_headers].name = buf;
288 static const char ALIGNED(16) ranges1[] = "\x00 " /* control chars and up to SP */
289 "\"\"" /* 0x22 */
290 "()" /* 0x28,0x29 */
291 ",," /* 0x2c */
292 "//" /* 0x2f */
293 ":@" /* 0x3a-0x40 */
294 "[]" /* 0x5b-0x5d */
295 "{\377"; /* 0x7b-0xff */
296 int found;
297 buf = findchar_fast(buf, buf_end, ranges1, sizeof(ranges1) - 1, &found);
298 if (!found) {
299 CHECK_EOF();
300 }
301 while (1) {
302 if (*buf == ':') {
303 break;
304 } else if (!token_char_map[(unsigned char)*buf]) {
305 *ret = -1;
306 return NULL;
307 }
308 ++buf;
309 CHECK_EOF();
310 }
311 if ((headers[*num_headers].name_len = buf - headers[*num_headers].name) == 0) {
312 *ret = -1;
313 return NULL;
314 }
315 ++buf;
316 for (;; ++buf) {
317 CHECK_EOF();
318 if (!(*buf == ' ' || *buf == '\t')) {
319 break;
320 }
321 }
322 } else {
323 headers[*num_headers].name = NULL;
324 headers[*num_headers].name_len = 0;
325 }
326 const char *value;
327 size_t value_len;
328 if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) {
329 return NULL;
330 }
331 /* remove trailing SPs and HTABs */
332 const char *value_end = value + value_len;
333 for (; value_end != value; --value_end) {
334 const char c = *(value_end - 1);
335 if (!(c == ' ' || c == '\t')) {
336 break;
337 }
338 }
339 headers[*num_headers].value = value;
340 headers[*num_headers].value_len = value_end - value;
341 }
342 return buf;
343}
344
345static const char *parse_request(const char *buf, const char *buf_end, const char **method, size_t *method_len, const char **path,
346 size_t *path_len, int *major_version, int *minor_version, struct phr_header *headers, size_t *num_headers,
347 size_t max_headers, int *ret)
348{
349 /* skip first empty line (some clients add CRLF after POST content) */
350 CHECK_EOF();
351 if (*buf == '\015') {
352 ++buf;
353 EXPECT_CHAR('\012');
354 } else if (*buf == '\012') {
355 ++buf;
356 }
357
358 /* parse request line */
359 ADVANCE_TOKEN(*method, *method_len);
360 do {
361 ++buf;
362 } while (*buf == ' ');
363 ADVANCE_TOKEN(*path, *path_len);
364 do {
365 ++buf;
366 } while (*buf == ' ');
367 if (*method_len == 0 || *path_len == 0) {
368 *ret = -1;
369 return NULL;
370 }
371 if ((buf = parse_http_version(buf, buf_end, major_version, minor_version, ret)) == NULL) {
372 return NULL;
373 }
374 if (*buf == '\015') {
375 ++buf;
376 EXPECT_CHAR('\012');
377 } else if (*buf == '\012') {
378 ++buf;
379 } else {
380 *ret = -1;
381 return NULL;
382 }
383
384 return parse_headers(buf, buf_end, headers, num_headers, max_headers, ret);
385}
386
387int phr_parse_request(const char *buf_start, size_t len, const char **method, size_t *method_len, const char **path,
388 size_t *path_len, int *major_version, int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len)
389{
390 const char *buf = buf_start, *buf_end = buf_start + len;
391 size_t max_headers = *num_headers;
392 int r;
393
394 *method = NULL;
395 *method_len = 0;
396 *path = NULL;
397 *path_len = 0;
398 *major_version = -1;
399 *minor_version = -1;
400 *num_headers = 0;
401
402 /* if last_len != 0, check if the request is complete (a fast countermeasure
403 against slowloris */
404 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
405 return r;
406 }
407
408 if ((buf = parse_request(buf, buf_end, method, method_len, path, path_len, major_version, minor_version, headers, num_headers, max_headers,
409 &r)) == NULL) {
410 return r;
411 }
412
413 return (int)(buf - buf_start);
414}
415
416static const char *parse_response(const char *buf, const char *buf_end, int *major_version, int *minor_version, int *status, const char **msg,
417 size_t *msg_len, struct phr_header *headers, size_t *num_headers, size_t max_headers, int *ret)
418{
419 /* parse "HTTP/1.x" */
420 if ((buf = parse_http_version(buf, buf_end, major_version, minor_version, ret)) == NULL) {
421 return NULL;
422 }
423 /* skip space */
424 if (*buf != ' ') {
425 *ret = -1;
426 return NULL;
427 }
428 do {
429 ++buf;
430 } while (*buf == ' ');
431 /* parse status code, we want at least [:digit:][:digit:][:digit:]<other char> to try to parse */
432 if (buf_end - buf < 4) {
433 *ret = -2;
434 return NULL;
435 }
436 PARSE_INT_3(status);
437
438 /* get message including preceding space */
439 if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) {
440 return NULL;
441 }
442 if (*msg_len == 0) {
443 /* ok */
444 } else if (**msg == ' ') {
445 /* remove preceding space */
446 do {
447 ++*msg;
448 --*msg_len;
449 } while (**msg == ' ');
450 } else {
451 /* garbage found after status code */
452 *ret = -1;
453 return NULL;
454 }
455
456 return parse_headers(buf, buf_end, headers, num_headers, max_headers, ret);
457}
458
459int phr_parse_response(const char *buf_start, size_t len, int *major_version, int *minor_version, int *status, const char **msg, size_t *msg_len,
460 struct phr_header *headers, size_t *num_headers, size_t last_len)
461{
462 const char *buf = buf_start, *buf_end = buf + len;
463 size_t max_headers = *num_headers;
464 int r;
465
466 *major_version = -1;
467 *minor_version = -1;
468 *status = 0;
469 *msg = NULL;
470 *msg_len = 0;
471 *num_headers = 0;
472
473 /* if last_len != 0, check if the response is complete (a fast countermeasure
474 against slowloris */
475 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
476 return r;
477 }
478
479 if ((buf = parse_response(buf, buf_end, major_version, minor_version, status, msg, msg_len, headers, num_headers, max_headers, &r)) == NULL) {
480 return r;
481 }
482
483 return (int)(buf - buf_start);
484}
485
486int phr_parse_headers(const char *buf_start, size_t len, struct phr_header *headers, size_t *num_headers, size_t last_len)
487{
488 const char *buf = buf_start, *buf_end = buf + len;
489 size_t max_headers = *num_headers;
490 int r;
491
492 *num_headers = 0;
493
494 /* if last_len != 0, check if the response is complete (a fast countermeasure
495 against slowloris */
496 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
497 return r;
498 }
499
500 if ((buf = parse_headers(buf, buf_end, headers, num_headers, max_headers, &r)) == NULL) {
501 return r;
502 }
503
504 return (int)(buf - buf_start);
505}
506
507enum {
508 CHUNKED_IN_CHUNK_SIZE,
509 CHUNKED_IN_CHUNK_EXT,
510 CHUNKED_IN_CHUNK_DATA,
511 CHUNKED_IN_CHUNK_CRLF,
512 CHUNKED_IN_TRAILERS_LINE_HEAD,
513 CHUNKED_IN_TRAILERS_LINE_MIDDLE
514};
515
516static int decode_hex(int ch)
517{
518 if ('0' <= ch && ch <= '9') {
519 return ch - '0';
520 } else if ('A' <= ch && ch <= 'F') {
521 return ch - 'A' + 0xa;
522 } else if ('a' <= ch && ch <= 'f') {
523 return ch - 'a' + 0xa;
524 } else {
525 return -1;
526 }
527}
528
529ssize_t phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, size_t *_bufsz)
530{
531 size_t dst = 0, src = 0, bufsz = *_bufsz;
532 ssize_t ret = -2; /* incomplete */
533
534 while (1) {
535 switch (decoder->_state) {
536 case CHUNKED_IN_CHUNK_SIZE:
537 for (;; ++src) {
538 int v;
539 if (src == bufsz)
540 goto Exit;
541 if ((v = decode_hex(buf[src])) == -1) {
542 if (decoder->_hex_count == 0) {
543 ret = -1;
544 goto Exit;
545 }
546 break;
547 }
548 if (decoder->_hex_count == sizeof(size_t) * 2) {
549 ret = -1;
550 goto Exit;
551 }
552 decoder->bytes_left_in_chunk = decoder->bytes_left_in_chunk * 16 + v;
553 ++decoder->_hex_count;
554 }
555 decoder->_hex_count = 0;
556 decoder->_state = CHUNKED_IN_CHUNK_EXT;
557 /* fallthru */
558 case CHUNKED_IN_CHUNK_EXT:
559 /* RFC 7230 A.2 "Line folding in chunk extensions is disallowed" */
560 for (;; ++src) {
561 if (src == bufsz)
562 goto Exit;
563 if (buf[src] == '\012')
564 break;
565 }
566 ++src;
567 if (decoder->bytes_left_in_chunk == 0) {
568 if (decoder->consume_trailer) {
569 decoder->_state = CHUNKED_IN_TRAILERS_LINE_HEAD;
570 break;
571 } else {
572 goto Complete;
573 }
574 }
575 decoder->_state = CHUNKED_IN_CHUNK_DATA;
576 /* fallthru */
577 case CHUNKED_IN_CHUNK_DATA: {
578 size_t avail = bufsz - src;
579 if (avail < decoder->bytes_left_in_chunk) {
580 if (dst != src)
581 memmove(buf + dst, buf + src, avail);
582 src += avail;
583 dst += avail;
584 decoder->bytes_left_in_chunk -= avail;
585 goto Exit;
586 }
587 if (dst != src)
588 memmove(buf + dst, buf + src, decoder->bytes_left_in_chunk);
589 src += decoder->bytes_left_in_chunk;
590 dst += decoder->bytes_left_in_chunk;
591 decoder->bytes_left_in_chunk = 0;
592 decoder->_state = CHUNKED_IN_CHUNK_CRLF;
593 }
594 /* fallthru */
595 case CHUNKED_IN_CHUNK_CRLF:
596 for (;; ++src) {
597 if (src == bufsz)
598 goto Exit;
599 if (buf[src] != '\015')
600 break;
601 }
602 if (buf[src] != '\012') {
603 ret = -1;
604 goto Exit;
605 }
606 ++src;
607 decoder->_state = CHUNKED_IN_CHUNK_SIZE;
608 break;
609 case CHUNKED_IN_TRAILERS_LINE_HEAD:
610 for (;; ++src) {
611 if (src == bufsz)
612 goto Exit;
613 if (buf[src] != '\015')
614 break;
615 }
616 if (buf[src++] == '\012')
617 goto Complete;
618 decoder->_state = CHUNKED_IN_TRAILERS_LINE_MIDDLE;
619 /* fallthru */
620 case CHUNKED_IN_TRAILERS_LINE_MIDDLE:
621 for (;; ++src) {
622 if (src == bufsz)
623 goto Exit;
624 if (buf[src] == '\012')
625 break;
626 }
627 ++src;
628 decoder->_state = CHUNKED_IN_TRAILERS_LINE_HEAD;
629 break;
630 default:
631 assert(!"decoder is corrupt");
632 }
633 }
634
635Complete:
636 ret = bufsz - src;
637Exit:
638 if (dst != src)
639 memmove(buf + dst, buf + src, bufsz - src);
640 *_bufsz = dst;
641 return ret;
642}
643
644int phr_decode_chunked_is_in_data(struct phr_chunked_decoder *decoder)
645{
646 return decoder->_state == CHUNKED_IN_CHUNK_DATA;
647}
648
649#undef CHECK_EOF
650#undef EXPECT_CHAR
651#undef ADVANCE_TOKEN
diff --git a/plugins/picohttpparser/picohttpparser.h b/plugins/picohttpparser/picohttpparser.h
new file mode 100644
index 00000000..8f13b36f
--- /dev/null
+++ b/plugins/picohttpparser/picohttpparser.h
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase,
3 * Shigeo Mitsunari
4 *
5 * The software is licensed under either the MIT License (below) or the Perl
6 * license.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to
10 * deal in the Software without restriction, including without limitation the
11 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 * sell copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * IN THE SOFTWARE.
25 */
26
27#ifndef picohttpparser_h
28#define picohttpparser_h
29
30#include <sys/types.h>
31
32#ifdef _MSC_VER
33#define ssize_t intptr_t
34#endif
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40/* contains name and value of a header (name == NULL if is a continuing line
41 * of a multiline header */
42struct phr_header {
43 const char *name;
44 size_t name_len;
45 const char *value;
46 size_t value_len;
47};
48
49/* returns number of bytes consumed if successful, -2 if request is partial,
50 * -1 if failed */
51int phr_parse_request(const char *buf, size_t len, const char **method, size_t *method_len, const char **path, size_t *path_len,
52 int *major_version, int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len);
53
54/* ditto */
55int phr_parse_response(const char *_buf, size_t len, int *major_version, int *minor_version, int *status, const char **msg, size_t *msg_len,
56 struct phr_header *headers, size_t *num_headers, size_t last_len);
57
58/* ditto */
59int phr_parse_headers(const char *buf, size_t len, struct phr_header *headers, size_t *num_headers, size_t last_len);
60
61/* should be zero-filled before start */
62struct phr_chunked_decoder {
63 size_t bytes_left_in_chunk; /* number of bytes left in current chunk */
64 char consume_trailer; /* if trailing headers should be consumed */
65 char _hex_count;
66 char _state;
67};
68
69/* the function rewrites the buffer given as (buf, bufsz) removing the chunked-
70 * encoding headers. When the function returns without an error, bufsz is
71 * updated to the length of the decoded data available. Applications should
72 * repeatedly call the function while it returns -2 (incomplete) every time
73 * supplying newly arrived data. If the end of the chunked-encoded data is
74 * found, the function returns a non-negative number indicating the number of
75 * octets left undecoded at the tail of the supplied buffer. Returns -1 on
76 * error.
77 */
78ssize_t phr_decode_chunked(struct phr_chunked_decoder *decoder, char *buf, size_t *bufsz);
79
80/* returns if the chunked decoder is in middle of chunked data */
81int phr_decode_chunked_is_in_data(struct phr_chunked_decoder *decoder);
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif
diff --git a/plugins/popen.c b/plugins/popen.c
index 592263fd..036bc608 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -14,7 +14,7 @@
14* FILE * spopen(const char *); 14* FILE * spopen(const char *);
15* int spclose(FILE *); 15* int spclose(FILE *);
16* 16*
17* Code taken with liitle modification from "Advanced Programming for the Unix 17* Code taken with little modification from "Advanced Programming for the Unix
18* Environment" by W. Richard Stevens 18* Environment" by W. Richard Stevens
19* 19*
20* This is considered safe in that no shell is spawned, and the environment 20* This is considered safe in that no shell is spawned, and the environment
@@ -38,10 +38,11 @@
38* 38*
39*****************************************************************************/ 39*****************************************************************************/
40 40
41#include "common.h" 41#include "./common.h"
42#include "./utils.h"
43#include "../lib/maxfd.h"
42 44
43/* extern so plugin has pid to kill exec'd process on timeouts */ 45/* extern so plugin has pid to kill exec'd process on timeouts */
44extern int timeout_interval;
45extern pid_t *childpid; 46extern pid_t *childpid;
46extern int *child_stderr_array; 47extern int *child_stderr_array;
47extern FILE *child_process; 48extern FILE *child_process;
@@ -49,9 +50,9 @@ extern FILE *child_process;
49FILE *spopen (const char *); 50FILE *spopen (const char *);
50int spclose (FILE *); 51int spclose (FILE *);
51#ifdef REDHAT_SPOPEN_ERROR 52#ifdef REDHAT_SPOPEN_ERROR
52RETSIGTYPE popen_sigchld_handler (int); 53void popen_sigchld_handler (int);
53#endif 54#endif
54RETSIGTYPE popen_timeout_alarm_handler (int); 55void popen_timeout_alarm_handler (int);
55 56
56#include <stdarg.h> /* ANSI C header file */ 57#include <stdarg.h> /* ANSI C header file */
57#include <fcntl.h> 58#include <fcntl.h>
@@ -76,18 +77,9 @@ RETSIGTYPE popen_timeout_alarm_handler (int);
76#define SIG_ERR ((Sigfunc *)-1) 77#define SIG_ERR ((Sigfunc *)-1)
77#endif 78#endif
78 79
79#define min(a,b) ((a) < (b) ? (a) : (b))
80#define max(a,b) ((a) > (b) ? (a) : (b))
81int open_max (void); /* {Prog openmax} */
82static void err_sys (const char *, ...) __attribute__((noreturn,format(printf, 1, 2)));
83char *rtrim (char *, const char *);
84 80
85char *pname = NULL; /* caller can set this from argv[0] */ 81char *pname = NULL; /* caller can set this from argv[0] */
86 82
87/*int *childerr = NULL;*//* ptr to array allocated at run-time */
88/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
89static int maxfd; /* from our open_max(), {Prog openmax} */
90
91#ifdef REDHAT_SPOPEN_ERROR 83#ifdef REDHAT_SPOPEN_ERROR
92static volatile int childtermd = 0; 84static volatile int childtermd = 0;
93#endif 85#endif
@@ -186,14 +178,14 @@ spopen (const char *cmdstring)
186 } 178 }
187 argv[i] = NULL; 179 argv[i] = NULL;
188 180
181 long maxfd = mp_open_max();
182
189 if (childpid == NULL) { /* first time through */ 183 if (childpid == NULL) { /* first time through */
190 maxfd = open_max (); /* allocate zeroed out array for child pids */
191 if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL) 184 if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
192 return (NULL); 185 return (NULL);
193 } 186 }
194 187
195 if (child_stderr_array == NULL) { /* first time through */ 188 if (child_stderr_array == NULL) { /* first time through */
196 maxfd = open_max (); /* allocate zeroed out array for child pids */
197 if ((child_stderr_array = calloc ((size_t)maxfd, sizeof (int))) == NULL) 189 if ((child_stderr_array = calloc ((size_t)maxfd, sizeof (int))) == NULL)
198 return (NULL); 190 return (NULL);
199 } 191 }
@@ -273,17 +265,8 @@ spclose (FILE * fp)
273 return (1); 265 return (1);
274} 266}
275 267
276#ifdef OPEN_MAX
277static int openmax = OPEN_MAX;
278#else
279static int openmax = 0;
280#endif
281
282#define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */
283 /* no guarantee this is adequate */
284
285#ifdef REDHAT_SPOPEN_ERROR 268#ifdef REDHAT_SPOPEN_ERROR
286RETSIGTYPE 269void
287popen_sigchld_handler (int signo) 270popen_sigchld_handler (int signo)
288{ 271{
289 if (signo == SIGCHLD) 272 if (signo == SIGCHLD)
@@ -291,7 +274,7 @@ popen_sigchld_handler (int signo)
291} 274}
292#endif 275#endif
293 276
294RETSIGTYPE 277void
295popen_timeout_alarm_handler (int signo) 278popen_timeout_alarm_handler (int signo)
296{ 279{
297 int fh; 280 int fh;
@@ -309,63 +292,3 @@ popen_timeout_alarm_handler (int signo)
309 exit (STATE_CRITICAL); 292 exit (STATE_CRITICAL);
310 } 293 }
311} 294}
312
313
314int
315open_max (void)
316{
317 if (openmax == 0) { /* first time through */
318 errno = 0;
319 if ((openmax = sysconf (_SC_OPEN_MAX)) < 0) {
320 if (errno == 0)
321 openmax = OPEN_MAX_GUESS; /* it's indeterminate */
322 else
323 err_sys (_("sysconf error for _SC_OPEN_MAX"));
324 }
325 }
326 return (openmax);
327}
328
329
330/* Fatal error related to a system call.
331 * Print a message and die. */
332
333#define MAXLINE 2048
334static void
335err_sys (const char *fmt, ...)
336{
337 int errnoflag = 1;
338 int errno_save;
339 char buf[MAXLINE];
340
341 va_list ap;
342
343 va_start (ap, fmt);
344 /* err_doit (1, fmt, ap); */
345 errno_save = errno; /* value caller might want printed */
346 vsprintf (buf, fmt, ap);
347 if (errnoflag)
348 sprintf (buf + strlen (buf), ": %s", strerror (errno_save));
349 strcat (buf, "\n");
350 fflush (stdout); /* in case stdout and stderr are the same */
351 fputs (buf, stderr);
352 fflush (NULL); /* flushes all stdio output streams */
353 va_end (ap);
354 exit (1);
355}
356
357char *
358rtrim (char *str, const char *tok)
359{
360 int i = 0;
361 int j = sizeof (str);
362
363 while (str != NULL && i < j) {
364 if (*(str + i) == *tok) {
365 sprintf (str + i, "%s", "\0");
366 return str;
367 }
368 i++;
369 }
370 return str;
371}
diff --git a/plugins/popen.h b/plugins/popen.h
index fc7e78e2..1ea69632 100644
--- a/plugins/popen.h
+++ b/plugins/popen.h
@@ -5,9 +5,8 @@
5 5
6FILE *spopen (const char *); 6FILE *spopen (const char *);
7int spclose (FILE *); 7int spclose (FILE *);
8RETSIGTYPE popen_timeout_alarm_handler (int); 8void popen_timeout_alarm_handler (int);
9 9
10extern unsigned int timeout_interval;
11pid_t *childpid=NULL; 10pid_t *childpid=NULL;
12int *child_stderr_array=NULL; 11int *child_stderr_array=NULL;
13FILE *child_process=NULL; 12FILE *child_process=NULL;
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 1a7c904f..bc0a4974 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -44,6 +44,8 @@
44# include <sys/wait.h> 44# include <sys/wait.h>
45#endif 45#endif
46 46
47#include "./utils.h"
48
47/** macros **/ 49/** macros **/
48#ifndef WEXITSTATUS 50#ifndef WEXITSTATUS
49# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) 51# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
@@ -67,19 +69,6 @@
67 * occur in any number of threads simultaneously. */ 69 * occur in any number of threads simultaneously. */
68static pid_t *np_pids = NULL; 70static pid_t *np_pids = NULL;
69 71
70/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
71 * If that fails and the macro isn't defined, we fall back to an educated
72 * guess. There's no guarantee that our guess is adequate and the program
73 * will die with SIGSEGV if it isn't and the upper boundary is breached. */
74#ifdef _SC_OPEN_MAX
75static long maxfd = 0;
76#elif defined(OPEN_MAX)
77# define maxfd OPEN_MAX
78#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
79# define maxfd 256
80#endif
81
82
83/** prototypes **/ 72/** prototypes **/
84static int np_runcmd_open(const char *, int *, int *) 73static int np_runcmd_open(const char *, int *, int *)
85 __attribute__((__nonnull__(1, 2, 3))); 74 __attribute__((__nonnull__(1, 2, 3)));
@@ -99,14 +88,7 @@ extern void die (int, const char *, ...)
99 * through this api and thus achieve async-safeness throughout the api */ 88 * through this api and thus achieve async-safeness throughout the api */
100void np_runcmd_init(void) 89void np_runcmd_init(void)
101{ 90{
102#ifndef maxfd 91 long maxfd = mp_open_max();
103 if(!maxfd && (maxfd = sysconf(_SC_OPEN_MAX)) < 0) {
104 /* possibly log or emit a warning here, since there's no
105 * guarantee that our guess at maxfd will be adequate */
106 maxfd = 256;
107 }
108#endif
109
110 if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t)); 92 if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t));
111} 93}
112 94
@@ -133,10 +115,6 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
133 env[0] = strdup("LC_ALL=C"); 115 env[0] = strdup("LC_ALL=C");
134 env[1] = '\0'; 116 env[1] = '\0';
135 117
136 /* if no command was passed, return with no error */
137 if (cmdstring == NULL)
138 return -1;
139
140 /* make copy of command string so strtok() doesn't silently modify it */ 118 /* make copy of command string so strtok() doesn't silently modify it */
141 /* (the calling program may want to access it later) */ 119 /* (the calling program may want to access it later) */
142 cmdlen = strlen(cmdstring); 120 cmdlen = strlen(cmdstring);
@@ -213,6 +191,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
213 /* close all descriptors in np_pids[] 191 /* close all descriptors in np_pids[]
214 * This is executed in a separate address space (pure child), 192 * This is executed in a separate address space (pure child),
215 * so we don't have to worry about async safety */ 193 * so we don't have to worry about async safety */
194 long maxfd = mp_open_max();
216 for (i = 0; i < maxfd; i++) 195 for (i = 0; i < maxfd; i++)
217 if(np_pids[i] > 0) 196 if(np_pids[i] > 0)
218 close (i); 197 close (i);
@@ -222,7 +201,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
222 } 201 }
223 202
224 /* parent picks up execution here */ 203 /* parent picks up execution here */
225 /* close childs descriptors in our address space */ 204 /* close children descriptors in our address space */
226 close(pfd[1]); 205 close(pfd[1]);
227 close(pfderr[1]); 206 close(pfderr[1]);
228 207
@@ -240,6 +219,7 @@ np_runcmd_close(int fd)
240 pid_t pid; 219 pid_t pid;
241 220
242 /* make sure this fd was opened by popen() */ 221 /* make sure this fd was opened by popen() */
222 long maxfd = mp_open_max();
243 if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0) 223 if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0)
244 return -1; 224 return -1;
245 225
@@ -263,6 +243,7 @@ runcmd_timeout_alarm_handler (int signo)
263 if (signo == SIGALRM) 243 if (signo == SIGALRM)
264 puts(_("CRITICAL - Plugin timed out while executing system call")); 244 puts(_("CRITICAL - Plugin timed out while executing system call"));
265 245
246 long maxfd = mp_open_max();
266 if(np_pids) for(i = 0; i < maxfd; i++) { 247 if(np_pids) for(i = 0; i < maxfd; i++) {
267 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL); 248 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
268 } 249 }
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 4f9c793c..6bc0ba81 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -1,29 +1,29 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring Plugins SSL utilities 3* Monitoring Plugins SSL utilities
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2005-2010 Monitoring Plugins Development Team 6* Copyright (c) 2005-2010 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains common functions for plugins that require SSL. 10* This file contains common functions for plugins that require SSL.
11* 11*
12* 12*
13* This program is free software: you can redistribute it and/or modify 13* This program is free software: you can redistribute it and/or modify
14* it under the terms of the GNU General Public License as published by 14* it under the terms of the GNU General Public License as published by
15* the Free Software Foundation, either version 3 of the License, or 15* the Free Software Foundation, either version 3 of the License, or
16* (at your option) any later version. 16* (at your option) any later version.
17* 17*
18* This program is distributed in the hope that it will be useful, 18* This program is distributed in the hope that it will be useful,
19* but WITHOUT ANY WARRANTY; without even the implied warranty of 19* but WITHOUT ANY WARRANTY; without even the implied warranty of
20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21* GNU General Public License for more details. 21* GNU General Public License for more details.
22* 22*
23* You should have received a copy of the GNU General Public License 23* You should have received a copy of the GNU General Public License
24* along with this program. If not, see <http://www.gnu.org/licenses/>. 24* along with this program. If not, see <http://www.gnu.org/licenses/>.
25* 25*
26* 26*
27*****************************************************************************/ 27*****************************************************************************/
28 28
29#define MAX_CN_LENGTH 256 29#define MAX_CN_LENGTH 256
@@ -31,9 +31,8 @@
31#include "netutils.h" 31#include "netutils.h"
32 32
33#ifdef HAVE_SSL 33#ifdef HAVE_SSL
34static SSL_CTX *c=NULL; 34static SSL_CTX *ctx=NULL;
35static SSL *s=NULL; 35static SSL *s=NULL;
36static int initialized=0;
37 36
38int np_net_ssl_init(int sd) { 37int np_net_ssl_init(int sd) {
39 return np_net_ssl_init_with_hostname(sd, NULL); 38 return np_net_ssl_init_with_hostname(sd, NULL);
@@ -48,24 +47,24 @@ int np_net_ssl_init_with_hostname_and_version(int sd, char *host_name, int versi
48} 47}
49 48
50int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int version, char *cert, char *privkey) { 49int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int version, char *cert, char *privkey) {
51 SSL_METHOD *method = NULL;
52 long options = 0; 50 long options = 0;
53 51
52 if ((ctx = SSL_CTX_new(TLS_client_method())) == NULL) {
53 printf("%s\n", _("CRITICAL - Cannot create SSL context."));
54 return STATE_CRITICAL;
55 }
56
54 switch (version) { 57 switch (version) {
55 case MP_SSLv2: /* SSLv2 protocol */ 58 case MP_SSLv2: /* SSLv2 protocol */
56#if defined(USE_GNUTLS) || defined(OPENSSL_NO_SSL2)
57 printf("%s\n", _("UNKNOWN - SSL protocol version 2 is not supported by your SSL library.")); 59 printf("%s\n", _("UNKNOWN - SSL protocol version 2 is not supported by your SSL library."));
58 return STATE_UNKNOWN; 60 return STATE_UNKNOWN;
59#else
60 method = SSLv2_client_method();
61 break;
62#endif
63 case MP_SSLv3: /* SSLv3 protocol */ 61 case MP_SSLv3: /* SSLv3 protocol */
64#if defined(OPENSSL_NO_SSL3) 62#if defined(OPENSSL_NO_SSL3)
65 printf("%s\n", _("UNKNOWN - SSL protocol version 3 is not supported by your SSL library.")); 63 printf("%s\n", _("UNKNOWN - SSL protocol version 3 is not supported by your SSL library."));
66 return STATE_UNKNOWN; 64 return STATE_UNKNOWN;
67#else 65#else
68 method = SSLv3_client_method(); 66 SSL_CTX_set_min_proto_version(ctx, SSL3_VERSION);
67 SSL_CTX_set_max_proto_version(ctx, SSL3_VERSION);
69 break; 68 break;
70#endif 69#endif
71 case MP_TLSv1: /* TLSv1 protocol */ 70 case MP_TLSv1: /* TLSv1 protocol */
@@ -73,7 +72,8 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
73 printf("%s\n", _("UNKNOWN - TLS protocol version 1 is not supported by your SSL library.")); 72 printf("%s\n", _("UNKNOWN - TLS protocol version 1 is not supported by your SSL library."));
74 return STATE_UNKNOWN; 73 return STATE_UNKNOWN;
75#else 74#else
76 method = TLSv1_client_method(); 75 SSL_CTX_set_min_proto_version(ctx, TLS1_VERSION);
76 SSL_CTX_set_max_proto_version(ctx, TLS1_VERSION);
77 break; 77 break;
78#endif 78#endif
79 case MP_TLSv1_1: /* TLSv1.1 protocol */ 79 case MP_TLSv1_1: /* TLSv1.1 protocol */
@@ -81,7 +81,8 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
81 printf("%s\n", _("UNKNOWN - TLS protocol version 1.1 is not supported by your SSL library.")); 81 printf("%s\n", _("UNKNOWN - TLS protocol version 1.1 is not supported by your SSL library."));
82 return STATE_UNKNOWN; 82 return STATE_UNKNOWN;
83#else 83#else
84 method = TLSv1_1_client_method(); 84 SSL_CTX_set_min_proto_version(ctx, TLS1_1_VERSION);
85 SSL_CTX_set_max_proto_version(ctx, TLS1_1_VERSION);
85 break; 86 break;
86#endif 87#endif
87 case MP_TLSv1_2: /* TLSv1.2 protocol */ 88 case MP_TLSv1_2: /* TLSv1.2 protocol */
@@ -89,7 +90,8 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
89 printf("%s\n", _("UNKNOWN - TLS protocol version 1.2 is not supported by your SSL library.")); 90 printf("%s\n", _("UNKNOWN - TLS protocol version 1.2 is not supported by your SSL library."));
90 return STATE_UNKNOWN; 91 return STATE_UNKNOWN;
91#else 92#else
92 method = TLSv1_2_client_method(); 93 SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
94 SSL_CTX_set_max_proto_version(ctx, TLS1_2_VERSION);
93 break; 95 break;
94#endif 96#endif
95 case MP_TLSv1_2_OR_NEWER: 97 case MP_TLSv1_2_OR_NEWER:
@@ -97,47 +99,43 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
97 printf("%s\n", _("UNKNOWN - Disabling TLSv1.1 is not supported by your SSL library.")); 99 printf("%s\n", _("UNKNOWN - Disabling TLSv1.1 is not supported by your SSL library."));
98 return STATE_UNKNOWN; 100 return STATE_UNKNOWN;
99#else 101#else
100 options |= SSL_OP_NO_TLSv1_1; 102 SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
103 break;
101#endif 104#endif
102 /* FALLTHROUGH */
103 case MP_TLSv1_1_OR_NEWER: 105 case MP_TLSv1_1_OR_NEWER:
104#if !defined(SSL_OP_NO_TLSv1) 106#if !defined(SSL_OP_NO_TLSv1)
105 printf("%s\n", _("UNKNOWN - Disabling TLSv1 is not supported by your SSL library.")); 107 printf("%s\n", _("UNKNOWN - Disabling TLSv1 is not supported by your SSL library."));
106 return STATE_UNKNOWN; 108 return STATE_UNKNOWN;
107#else 109#else
108 options |= SSL_OP_NO_TLSv1; 110 SSL_CTX_set_min_proto_version(ctx, TLS1_1_VERSION);
111 break;
109#endif 112#endif
110 /* FALLTHROUGH */
111 case MP_TLSv1_OR_NEWER: 113 case MP_TLSv1_OR_NEWER:
112#if defined(SSL_OP_NO_SSLv3) 114#if defined(SSL_OP_NO_SSLv3)
113 options |= SSL_OP_NO_SSLv3; 115 SSL_CTX_set_min_proto_version(ctx, TLS1_VERSION);
116 break;
114#endif 117#endif
115 /* FALLTHROUGH */
116 case MP_SSLv3_OR_NEWER: 118 case MP_SSLv3_OR_NEWER:
117#if defined(SSL_OP_NO_SSLv2) 119#if defined(SSL_OP_NO_SSLv2)
118 options |= SSL_OP_NO_SSLv2; 120 SSL_CTX_set_min_proto_version(ctx, SSL3_VERSION);
121 break;
119#endif 122#endif
120 case MP_SSLv2_OR_NEWER:
121 /* FALLTHROUGH */
122 default: /* Default to auto negotiation */
123 method = SSLv23_client_method();
124 }
125 if (!initialized) {
126 /* Initialize SSL context */
127 SSLeay_add_ssl_algorithms();
128 SSL_load_error_strings();
129 OpenSSL_add_all_algorithms();
130 initialized = 1;
131 }
132 if ((c = SSL_CTX_new(method)) == NULL) {
133 printf("%s\n", _("CRITICAL - Cannot create SSL context."));
134 return STATE_CRITICAL;
135 } 123 }
124
136 if (cert && privkey) { 125 if (cert && privkey) {
137 SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM);
138 SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM);
139#ifdef USE_OPENSSL 126#ifdef USE_OPENSSL
140 if (!SSL_CTX_check_private_key(c)) { 127 if (!SSL_CTX_use_certificate_chain_file(ctx, cert)) {
128#elif USE_GNUTLS
129 if (!SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM)) {
130#else
131#error Unported for unknown SSL library
132#endif
133 printf ("%s\n", _("CRITICAL - Unable to open certificate chain file!\n"));
134 return STATE_CRITICAL;
135 }
136 SSL_CTX_use_PrivateKey_file(ctx, privkey, SSL_FILETYPE_PEM);
137#ifdef USE_OPENSSL
138 if (!SSL_CTX_check_private_key(ctx)) {
141 printf ("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n")); 139 printf ("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n"));
142 return STATE_CRITICAL; 140 return STATE_CRITICAL;
143 } 141 }
@@ -146,9 +144,9 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
146#ifdef SSL_OP_NO_TICKET 144#ifdef SSL_OP_NO_TICKET
147 options |= SSL_OP_NO_TICKET; 145 options |= SSL_OP_NO_TICKET;
148#endif 146#endif
149 SSL_CTX_set_options(c, options); 147 SSL_CTX_set_options(ctx, options);
150 SSL_CTX_set_mode(c, SSL_MODE_AUTO_RETRY); 148 SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
151 if ((s = SSL_new(c)) != NULL) { 149 if ((s = SSL_new(ctx)) != NULL) {
152#ifdef SSL_set_tlsext_host_name 150#ifdef SSL_set_tlsext_host_name
153 if (host_name != NULL) 151 if (host_name != NULL)
154 SSL_set_tlsext_host_name(s, host_name); 152 SSL_set_tlsext_host_name(s, host_name);
@@ -175,9 +173,9 @@ void np_net_ssl_cleanup() {
175#endif 173#endif
176 SSL_shutdown(s); 174 SSL_shutdown(s);
177 SSL_free(s); 175 SSL_free(s);
178 if (c) { 176 if (ctx) {
179 SSL_CTX_free(c); 177 SSL_CTX_free(ctx);
180 c=NULL; 178 ctx=NULL;
181 } 179 }
182 s=NULL; 180 s=NULL;
183 } 181 }
@@ -191,13 +189,13 @@ int np_net_ssl_read(void *buf, int num) {
191 return SSL_read(s, buf, num); 189 return SSL_read(s, buf, num);
192} 190}
193 191
194int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){ 192int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit){
195# ifdef USE_OPENSSL 193# ifdef USE_OPENSSL
196 X509 *certificate=NULL;
197 X509_NAME *subj=NULL; 194 X509_NAME *subj=NULL;
198 char timestamp[50] = ""; 195 char timestamp[50] = "";
199 char cn[MAX_CN_LENGTH]= ""; 196 char cn[MAX_CN_LENGTH]= "";
200 197 char *tz;
198
201 int cnlen =-1; 199 int cnlen =-1;
202 int status=STATE_UNKNOWN; 200 int status=STATE_UNKNOWN;
203 201
@@ -209,7 +207,6 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
209 int time_remaining; 207 int time_remaining;
210 time_t tm_t; 208 time_t tm_t;
211 209
212 certificate=SSL_get_peer_certificate(s);
213 if (!certificate) { 210 if (!certificate) {
214 printf("%s\n",_("CRITICAL - Cannot retrieve server certificate.")); 211 printf("%s\n",_("CRITICAL - Cannot retrieve server certificate."));
215 return STATE_CRITICAL; 212 return STATE_CRITICAL;
@@ -264,10 +261,18 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
264 (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0'); 261 (tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0');
265 stamp.tm_isdst = -1; 262 stamp.tm_isdst = -1;
266 263
267 time_left = difftime(timegm(&stamp), time(NULL)); 264 tm_t = timegm(&stamp);
265 time_left = difftime(tm_t, time(NULL));
268 days_left = time_left / 86400; 266 days_left = time_left / 86400;
269 tm_t = mktime (&stamp); 267 tz = getenv("TZ");
270 strftime(timestamp, 50, "%c", localtime(&tm_t)); 268 setenv("TZ", "GMT", 1);
269 tzset();
270 strftime(timestamp, 50, "%c %z", localtime(&tm_t));
271 if (tz)
272 setenv("TZ", tz, 1);
273 else
274 unsetenv("TZ");
275 tzset();
271 276
272 if (days_left > 0 && days_left <= days_till_exp_warn) { 277 if (days_left > 0 && days_left <= days_till_exp_warn) {
273 printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp); 278 printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp);
@@ -310,4 +315,16 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
310# endif /* USE_OPENSSL */ 315# endif /* USE_OPENSSL */
311} 316}
312 317
318int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
319# ifdef USE_OPENSSL
320 X509 *certificate = NULL;
321 certificate=SSL_get_peer_certificate(s);
322 return(np_net_ssl_check_certificate(certificate, days_till_exp_warn, days_till_exp_crit));
323# else /* ifndef USE_OPENSSL */
324 printf("%s\n", _("WARNING - Plugin does not support checking certificates."));
325 return STATE_WARNING;
326# endif /* USE_OPENSSL */
327}
328
329
313#endif /* HAVE_SSL */ 330#endif /* HAVE_SSL */
diff --git a/plugins/t/check_apt.t b/plugins/t/check_apt.t
index 9ba0ff8e..430eb53e 100644
--- a/plugins/t/check_apt.t
+++ b/plugins/t/check_apt.t
@@ -23,7 +23,7 @@ sub make_result_regexp {
23} 23}
24 24
25if (-x "./check_apt") { 25if (-x "./check_apt") {
26 plan tests => 28; 26 plan tests => 36;
27} else { 27} else {
28 plan skip_all => "No check_apt compiled"; 28 plan skip_all => "No check_apt compiled";
29} 29}
@@ -40,10 +40,18 @@ $result = NPTest->testCmd( sprintf($testfile_command, "", "debian2") );
40is( $result->return_code, 1, "Debian apt output, warning" ); 40is( $result->return_code, 1, "Debian apt output, warning" );
41like( $result->output, make_result_regexp(13, 0), "Output correct" ); 41like( $result->output, make_result_regexp(13, 0), "Output correct" );
42 42
43$result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian2") );
44is( $result->return_code, 0, "Debian apt output, no critical" );
45like( $result->output, make_result_regexp(13, 0), "Output correct" );
46
43$result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") ); 47$result = NPTest->testCmd( sprintf($testfile_command, "", "debian3") );
44is( $result->return_code, 2, "Debian apt output, some critical" ); 48is( $result->return_code, 2, "Debian apt output, some critical" );
45like( $result->output, make_result_regexp(19, 4), "Output correct" ); 49like( $result->output, make_result_regexp(19, 4), "Output correct" );
46 50
51$result = NPTest->testCmd( sprintf($testfile_command, "-o", "debian3") );
52is( $result->return_code, 2, "Debian apt output, some critical" );
53like( $result->output, make_result_regexp(19, 4), "Output correct" );
54
47$result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") ); 55$result = NPTest->testCmd( sprintf($testfile_command, "-c '^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)'", "debian3") );
48is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" ); 56is( $result->return_code, 2, "Debian apt output - should have same result when default security regexp specified via -c" );
49like( $result->output, make_result_regexp(19, 4), "Output correct" ); 57like( $result->output, make_result_regexp(19, 4), "Output correct" );
@@ -52,6 +60,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") );
52is( $result->return_code, 1, "Debian apt output, filter for libc6" ); 60is( $result->return_code, 1, "Debian apt output, filter for libc6" );
53like( $result->output, make_result_regexp(3, 0), "Output correct" ); 61like( $result->output, make_result_regexp(3, 0), "Output correct" );
54 62
63$result = NPTest->testCmd( sprintf($testfile_command, "-i libc6", "debian3") );
64is( $result->return_code, 1, "Debian apt output, filter for libc6, not critical" );
65like( $result->output, make_result_regexp(3, 0), "Output correct" );
66
55$result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") ); 67$result = NPTest->testCmd( sprintf($testfile_command, "-i libc6 -i xen", "debian3") );
56is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" ); 68is( $result->return_code, 2, "Debian apt output, filter for libc6 and xen" );
57like( $result->output, make_result_regexp(9, 4), "Output correct" ); 69like( $result->output, make_result_regexp(9, 4), "Output correct" );
@@ -64,6 +76,10 @@ $result = NPTest->testCmd( sprintf($testfile_command, "-e libc6", "debian3") );
64is( $result->return_code, 2, "Debian apt output, filter out libc6" ); 76is( $result->return_code, 2, "Debian apt output, filter out libc6" );
65like( $result->output, make_result_regexp(16, 4), "Output correct" ); 77like( $result->output, make_result_regexp(16, 4), "Output correct" );
66 78
79$result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -o", "debian3") );
80is( $result->return_code, 2, "Debian apt output, filter out libc6, critical" );
81like( $result->output, make_result_regexp(16, 4), "Output correct" );
82
67$result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") ); 83$result = NPTest->testCmd( sprintf($testfile_command, "-e libc6 -e xen", "debian3") );
68is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" ); 84is( $result->return_code, 1, "Debian apt output, filter out libc6 and xen" );
69like( $result->output, make_result_regexp(10, 0), "Output correct" ); 85like( $result->output, make_result_regexp(10, 0), "Output correct" );
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t
index 4797390d..b6479f1f 100644
--- a/plugins/t/check_by_ssh.t
+++ b/plugins/t/check_by_ssh.t
@@ -9,17 +9,9 @@ use Test::More;
9use NPTest; 9use NPTest;
10 10
11# Required parameters 11# Required parameters
12my $ssh_service = getTestParameter( "NP_SSH_HOST", 12my $ssh_service = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost");
13 "A host providing SSH service", 13my $ssh_key = getTestParameter("NP_SSH_IDENTITY", "A key allowing access to NP_SSH_HOST", "~/.ssh/id_dsa");
14 "localhost"); 14my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE", "A config file with ssh settings", "~/.ssh/config");
15
16my $ssh_key = getTestParameter( "NP_SSH_IDENTITY",
17 "A key allowing access to NP_SSH_HOST",
18 "~/.ssh/id_dsa");
19
20my $ssh_conf = getTestParameter( "NP_SSH_CONFIGFILE",
21 "A config file with ssh settings",
22 "~/.ssh/config");
23 15
24 16
25plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key); 17plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_service && $ssh_key);
@@ -27,19 +19,19 @@ plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_servic
27plan tests => 42; 19plan tests => 42;
28 20
29# Some random check strings/response 21# Some random check strings/response
30my @responce = ('OK: Everything is fine', 22my @response = ('OK: Everything is fine',
31 'WARNING: Hey, pick me, pick me', 23 'WARNING: Hey, pick me, pick me',
32 'CRITICAL: Shit happens', 24 'CRITICAL: Shit happens',
33 'UNKNOWN: What can I do for ya', 25 'UNKNOWN: What can I do for ya',
34 'WOOPS: What did I smoke', 26 'WOOPS: What did I smoke',
35); 27);
36my @responce_re; 28my @response_re;
37my @check; 29my @check;
38for (@responce) { 30for (@response) {
39 push(@check, "echo $_"); 31 push(@check, "echo $_");
40 my $re_str = $_; 32 my $re_str = $_;
41 $re_str =~ s{(.)} { "\Q$1" }ge; 33 $re_str =~ s{(.)} { "\Q$1" }ge;
42 push(@responce_re, $re_str); 34 push(@response_re, $re_str);
43} 35}
44 36
45my $result; 37my $result;
@@ -55,7 +47,7 @@ for (my $i=0; $i<4; $i++) {
55 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" 47 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'"
56 ); 48 );
57 cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); 49 cmp_ok($result->return_code, '==', $i, "Exit with return code $i");
58 is($result->output, $responce[$i], "Status text is correct for check $i"); 50 is($result->output, $response[$i], "Status text is correct for check $i");
59} 51}
60 52
61$result = NPTest->testCmd( 53$result = NPTest->testCmd(
@@ -92,7 +84,7 @@ $result = NPTest->testCmd(
92 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" 84 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'"
93 ); 85 );
94cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); 86cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)");
95is($result->output, $responce[4], "Return proper status text even with unknown status codes"); 87is($result->output, $response[4], "Return proper status text even with unknown status codes");
96 88
97$result = NPTest->testCmd( 89$result = NPTest->testCmd(
98 "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" 90 "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'"
@@ -116,7 +108,7 @@ my %linemap = (
116foreach my $line (0, 2, 4, 6) { 108foreach my $line (0, 2, 4, 6) {
117 my $code = $linemap{$line}; 109 my $code = $linemap{$line};
118 my $statline = $line+1; 110 my $statline = $line+1;
119 is($lines[$line], "$responce[$code]", "multiple checks status text is correct for line $line"); 111 is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line");
120 is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); 112 is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line");
121} 113}
122 114
@@ -132,7 +124,7 @@ close(PASV) or die("Unable to close '/tmp/check_by_ssh.$$': $!");
132cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed'); 124cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed');
133for (0) { 125for (0) {
134 if ($pasv[$_]) { 126 if ($pasv[$_]) {
135 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $responce_re[2] . '$/', 'proper result for passive check'); 127 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $response_re[2] . '$/', 'proper result for passive check');
136 } else { 128 } else {
137 fail('proper result for passive check'); 129 fail('proper result for passive check');
138 } 130 }
@@ -152,7 +144,7 @@ for (0, 1, 2, 3, 4) {
152 if ($pasv[$_]) { 144 if ($pasv[$_]) {
153 my $ret = $_; 145 my $ret = $_;
154 $ret = 9 if ($_ == 4); 146 $ret = 9 if ($_ == 4);
155 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $responce_re[$_] . '$/', "proper result for passive check $_"); 147 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $response_re[$_] . '$/', "proper result for passive check $_");
156 } else { 148 } else {
157 fail("proper result for passive check $_"); 149 fail("proper result for passive check $_");
158 } 150 }
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
new file mode 100644
index 00000000..eae98cc1
--- /dev/null
+++ b/plugins/t/check_curl.t
@@ -0,0 +1,213 @@
1#! /usr/bin/perl -w -I ..
2#
3# HyperText Transfer Protocol (HTTP) Test via check_curl
4#
5#
6
7use strict;
8use Test::More;
9use POSIX qw/mktime strftime/;
10
11use vars qw($tests $has_ipv6);
12
13BEGIN {
14 use NPTest;
15 $has_ipv6 = NPTest::has_ipv6();
16 $tests = $has_ipv6 ? 59 : 57;
17 plan tests => $tests;
18}
19
20
21my $successOutput = '/OK.*HTTP.*second/';
22
23my $res;
24my $plugin = 'check_http';
25$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
26
27my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
28my $host_tcp_http_ipv6 = getTestParameter("NP_HOST_TCP_HTTP_IPV6", "An IPv6 address providing a HTTP Service (a web server)", "::1");
29my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
30my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
31my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
32my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
33my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes");
34my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org");
35my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost");
36my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128");
37
38my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
39
40
41$res = NPTest->testCmd(
42 "./$plugin $host_tcp_http -wt 300 -ct 600"
43 );
44cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
45like( $res->output, $successOutput, "Output OK" );
46
47if ($has_ipv6) {
48 # Test for IPv6 formatting
49 $res = NPTest->testCmd(
50 "./$plugin -I $host_tcp_http_ipv6 -wt 300 -ct 600"
51 );
52 cmp_ok( $res->return_code, '==', 0, "IPv6 URL formatting is working" );
53 like( $res->output, $successOutput, "Output OK" );
54}
55
56$res = NPTest->testCmd(
57 "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
58 );
59like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
60
61$res = NPTest->testCmd(
62 "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
63 );
64cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
65# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
66like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK");
67
68$res = NPTest->testCmd(
69 "./$plugin $hostname_invalid -wt 1 -ct 2"
70 );
71cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
72# The first part of the message comes from the OS catalogue, so cannot check this.
73# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename
74# Is also possible to get a socket timeout if DNS is not responding fast enough
75# cURL gives us consistent strings from it's own 'lib/strerror.c'
76like( $res->output, "/cURL returned 6 - Could not resolve host:/", "Output OK");
77
78# host header checks
79$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http");
80like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
81like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
82
83$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http -p 80");
84like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
85like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
86
87$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
88like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
89like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
90
91$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
92like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
93like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
94
95$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80 -k 'Host: testhost:8001'");
96like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" );
97like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
98
99$res = NPTest->testCmd("./$plugin -v -I $host_tcp_http -p 80 -k 'Host: testhost:8001'");
100like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" );
101like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" );
102
103SKIP: {
104 skip "No internet access", 4 if $internet_access eq "no";
105
106 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S");
107 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
108
109 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:8080 -S -p 443");
110 like( $res->output, '/^Host: '.$host_tls_http.':8080\s*$/ms', "Host Header OK" );
111
112 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443");
113 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
114
115 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -S -p 443");
116 like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" );
117};
118
119SKIP: {
120 skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
121
122 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring'" );
123 cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'");
124
125 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" );
126 cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'");
127 like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
128
129 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" );
130 cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'");
131
132 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
133 cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
134 like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
135
136 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
137 cmp_ok( $res->return_code, "==", 0, "And also when not found");
138}
139SKIP: {
140 skip "No internet access", 28 if $internet_access eq "no";
141
142 $res = NPTest->testCmd(
143 "./$plugin --ssl $host_tls_http"
144 );
145 cmp_ok( $res->return_code, '==', 0, "Can read https for $host_tls_http" );
146
147 $res = NPTest->testCmd( "./$plugin -C 1 --ssl $host_tls_http" );
148 cmp_ok( $res->return_code, '==', 0, "Checking certificate for $host_tls_http");
149 like ( $res->output, "/Certificate '$host_tls_cert' will expire on/", "Output OK" );
150 my $saved_cert_output = $res->output;
151
152 $res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" );
153 cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http");
154 like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" );
155
156 $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
157 is( $res->return_code, 0, "Old syntax for cert checking okay" );
158 is( $res->output, $saved_cert_output, "Same output as new syntax" );
159
160 $res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" );
161 is( $res->return_code, 0, "Updated syntax for cert checking okay" );
162 is( $res->output, $saved_cert_output, "Same output as new syntax" );
163
164 $res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" );
165 cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
166
167 $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
168 cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
169
170 # run some certificate checks with faketime
171 SKIP: {
172 skip "No faketime binary found", 12 if !$faketime;
173 $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http");
174 like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output");
175 is( $res->return_code, 0, "Catch cert output exit code" );
176 my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
177 if(!defined $year) {
178 die("parsing date failed from: ".$res->output);
179 }
180 my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
181 my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
182 my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts));
183 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./$plugin -C 1 $host_tls_http");
184 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date");
185 is( $res->return_code, 2, "Output on expire date" );
186
187 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./$plugin -C 1 $host_tls_http");
188 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output");
189 is( $res->return_code, 2, "cert expires in 1 second exit code" );
190
191 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./$plugin -C 1 $host_tls_http");
192 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output");
193 is( $res->return_code, 2, "cert expires in 2 minutes exit code" );
194
195 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./$plugin -C 1 $host_tls_http");
196 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output");
197 is( $res->return_code, 2, "cert expires in 2 hours exit code" );
198
199 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./$plugin -C 1 $host_tls_http");
200 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output");
201 is( $res->return_code, 2, "Certificate expired exit code" );
202 };
203
204 $res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -E" );
205 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
206 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
207
208 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" );
209 is( $res->return_code, 0, "Redirection based on location is okay");
210
211 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
212 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
213}
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 7e0f74b7..ca035ce7 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -23,7 +23,7 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
23if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { 23if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
24 plan skip_all => "Need 2 mountpoints to test"; 24 plan skip_all => "Need 2 mountpoints to test";
25} else { 25} else {
26 plan tests => 78; 26 plan tests => 88;
27} 27}
28 28
29$result = NPTest->testCmd( 29$result = NPTest->testCmd(
@@ -88,8 +88,9 @@ $result = NPTest->testCmd(
88 ); 88 );
89$_ = $result->perf_output; 89$_ = $result->perf_output;
90my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/); 90my ($warn_absth_data, $crit_absth_data, $total_absth_data) = (m/=.[^;]*;(\d+);(\d+);\d+;(\d+)/);
91is ($warn_absth_data, $total_absth_data - 20, "Wrong warning in perf data using absolute thresholds"); 91# default unit is MiB, but perfdata is always bytes
92is ($crit_absth_data, $total_absth_data - 10, "Wrong critical in perf data using absolute thresholds"); 92is ($warn_absth_data, $total_absth_data - (20 * (2 ** 20)), "Wrong warning in perf data using absolute thresholds");
93is ($crit_absth_data, $total_absth_data - (10 * (2 ** 20)), "Wrong critical in perf data using absolute thresholds");
93 94
94# Then check percent thresholds. 95# Then check percent thresholds.
95$result = NPTest->testCmd( 96$result = NPTest->testCmd(
@@ -119,7 +120,7 @@ like ( $result->only_output, qr/$more_free/, "Have disk name in text");
119$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" ); 120$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -p $more_free -p $less_free" );
120cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free"); 121cmp_ok( $result->return_code, '==', 0, "At least 1 MB available on $more_free and $less_free");
121$_ = $result->output; 122$_ = $result->output;
122my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+) MB .* (\d+) MB /g); 123my ($free_mb_on_mp1, $free_mb_on_mp2) = (m/(\d+)MiB .* (\d+)MiB /g);
123my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2; 124my $free_mb_on_all = $free_mb_on_mp1 + $free_mb_on_mp2;
124 125
125 126
@@ -248,11 +249,11 @@ $result = NPTest->testCmd( "./check_disk -w 100% -c 100% ".${mountpoint_valid} )
248cmp_ok( $result->return_code, "==", 2, "100% empty" ); 249cmp_ok( $result->return_code, "==", 2, "100% empty" );
249like( $result->output, $failureOutput, "Right output" ); 250like( $result->output, $failureOutput, "Right output" );
250 251
251$result = NPTest->testCmd( "./check_disk -w 100000 -c 100000 $mountpoint_valid" ); 252$result = NPTest->testCmd( "./check_disk -w 100000000 -c 100000000 $mountpoint_valid" );
252cmp_ok( $result->return_code, '==', 2, "Check for 100GB free" ); 253cmp_ok( $result->return_code, '==', 2, "Check for 100TB free" );
253 254
254$result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u GB ".${mountpoint_valid} ); # 100 GB empty 255$result = NPTest->testCmd( "./check_disk -w 100 -c 100 -u TB ".${mountpoint_valid} ); # 100 TB empty
255cmp_ok( $result->return_code, "==", 2, "100 GB empty" ); 256cmp_ok( $result->return_code, "==", 2, "100 TB empty" );
256 257
257 258
258# Checking old syntax of check_disk warn crit [fs], with warn/crit at USED% thresholds 259# Checking old syntax of check_disk warn crit [fs], with warn/crit at USED% thresholds
@@ -325,19 +326,19 @@ cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free meg
325$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" ); 326$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
326cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname"); 327cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
327 328
328# regex: exit unknown if given regex is not compileable 329# regex: exit unknown if given regex is not compilable
329$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" ); 330$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
330cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable"); 331cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compilable");
331 332
332# ignore: exit unknown, if all pathes are deselected using -i 333# ignore: exit unknown, if all paths are deselected using -i
333$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" ); 334$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" );
334cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)"); 335cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)");
335 336
336# ignore: exit unknown, if all pathes are deselected using -I 337# ignore: exit unknown, if all paths are deselected using -I
337$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" ); 338$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" );
338cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)"); 339cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)");
339 340
340# ignore: exit unknown, if all pathes are deselected using -i 341# ignore: exit unknown, if all paths are deselected using -i
341$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" ); 342$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" );
342cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'"); 343cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'");
343 344
@@ -346,7 +347,32 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mo
346like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it"); 347like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it");
347unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it"); 348unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it");
348 349
349# ignore: test if all pathes are listed when ignore regex doesn't match 350# ignore: test if all paths are listed when ignore regex doesn't match
350$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'"); 351$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'");
351like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match"); 352like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match");
352like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match"); 353like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match");
354
355# ignore-missing: exit okay, when fs is not accessible
356$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob");
357cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob");
358like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /bob;.*$/', 'Output OK');
359
360# ignore-missing: exit okay, when regex does not match
361$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob");
362cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
363like( $result->output, '/^DISK OK - No disks were found for provided parameters;.*$/', 'Output OK');
364
365# ignore-missing: exit okay, when fs with exact match (-E) is not found
366$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -E -p /etc");
367cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs");
368like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /etc;.*$/', 'Output OK');
369
370# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (regex)
371$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r '/bob' -r '^/\$'");
372cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
373like( $result->output, '/^DISK OK - free space: \/ .*$/', 'Output OK');
374
375# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (path)
376$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p '/bob' -p '/'");
377cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
378like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK'); \ No newline at end of file
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index 035e7682..afb2062d 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,26 +10,38 @@ use NPTest;
10 10
11plan skip_all => "check_dns not compiled" unless (-x "check_dns"); 11plan skip_all => "check_dns not compiled" unless (-x "check_dns");
12 12
13plan tests => 16; 13plan tests => 23;
14 14
15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; 15my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
16 16
17my $hostname_valid = getTestParameter( 17my $hostname_valid = getTestParameter(
18 "NP_HOSTNAME_VALID", 18 "NP_HOSTNAME_VALID",
19 "A valid (known to DNS) hostname", 19 "A valid (known to DNS) hostname",
20 "monitoring-plugins.org" 20 "monitoring-plugins.org",
21 ); 21 );
22 22
23my $hostname_valid_ip = getTestParameter( 23my $hostname_valid_ip = getTestParameter(
24 "NP_HOSTNAME_VALID_IP", 24 "NP_HOSTNAME_VALID_IP",
25 "The IP address of the valid hostname $hostname_valid", 25 "The IP address of the valid hostname $hostname_valid",
26 "66.118.156.50", 26 "130.133.8.40",
27 );
28
29my $hostname_valid_cidr = getTestParameter(
30 "NP_HOSTNAME_VALID_CIDR",
31 "An valid CIDR range containing $hostname_valid_ip",
32 "130.133.8.41/30",
33 );
34
35my $hostname_invalid_cidr = getTestParameter(
36 "NP_HOSTNAME_INVALID_CIDR",
37 "An (valid) CIDR range NOT containing $hostname_valid_ip",
38 "130.133.8.39/30",
27 ); 39 );
28 40
29my $hostname_valid_reverse = getTestParameter( 41my $hostname_valid_reverse = getTestParameter(
30 "NP_HOSTNAME_VALID_REVERSE", 42 "NP_HOSTNAME_VALID_REVERSE",
31 "The hostname of $hostname_valid_ip", 43 "The hostname of $hostname_valid_ip",
32 "66-118-156-50.static.sagonet.net.", 44 "orwell.monitoring-plugins.org.",
33 ); 45 );
34 46
35my $hostname_invalid = getTestParameter( 47my $hostname_invalid = getTestParameter(
@@ -87,3 +99,17 @@ $res = NPTest->testCmd("./check_dns -H $hostname_valid_ip -a $hostname_valid_rev
87cmp_ok( $res->return_code, '==', 0, "Got expected fqdn"); 99cmp_ok( $res->return_code, '==', 0, "Got expected fqdn");
88like ( $res->output, $successOutput, "Output OK"); 100like ( $res->output, $successOutput, "Output OK");
89 101
102$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_cidr -t 5");
103cmp_ok( $res->return_code, '==', 0, "Got expected address");
104
105$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5");
106cmp_ok( $res->return_code, '==', 2, "Got wrong address");
107like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK");
108
109$res = NPTest->testCmd("./check_dns -H $hostname_valid -n");
110cmp_ok( $res->return_code, '==', 2, "Found $hostname_valid");
111like ( $res->output, "/^DNS CRITICAL.*Domain '$hostname_valid' was found by the server:/", "Output OK");
112
113$res = NPTest->testCmd("./check_dns -H $hostname_invalid -n");
114cmp_ok( $res->return_code, '==', 0, "Did not find $hostname_invalid");
115like ( $res->output, $successOutput, "Output OK" );
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t
index 08692e46..67b357b2 100644
--- a/plugins/t/check_fping.t
+++ b/plugins/t/check_fping.t
@@ -5,40 +5,30 @@
5# 5#
6 6
7use strict; 7use strict;
8use Test; 8use Test::More;
9use NPTest; 9use NPTest;
10 10
11use vars qw($tests); 11my $host_responsive = getTestParameter("NP_HOST_RESPONSIVE", "The hostname of system responsive to network requests", "localhost");
12my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
13my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
12 14
13BEGIN {$tests = 4; plan tests => $tests} 15my $res;
14
15my $successOutput = '/^FPING OK - /';
16my $failureOutput = '/^FPING CRITICAL - /';
17
18my $host_responsive = getTestParameter( "host_responsive", "NP_HOST_RESPONSIVE", "localhost",
19 "The hostname of system responsive to network requests" );
20
21my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
22 "The hostname of system not responsive to network requests" );
23
24my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
25 "An invalid (not known to DNS) hostname" );
26
27
28my $t;
29 16
30my $fping = qx(which fping 2> /dev/null); 17my $fping = qx(which fping 2> /dev/null);
31chomp($fping); 18chomp($fping);
32if( ! -x "./check_fping") { 19if( ! -x "./check_fping") {
33 $t += skipMissingCmd( "./check_fping", $tests ); 20 plan skip_all => "check_fping not found, skipping tests";
34} 21}
35elsif ( $> != 0 && (!$fping || ! -u $fping)) { 22elsif ( !$fping || !-x $fping ) {
36 $t += skipMsg( "./check_fping", $tests ); 23 plan skip_all => "fping not found or cannot be executed, skipping tests";
37} else { 24} else {
38 $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); 25 plan tests => 3;
39 $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); 26 $res = NPTest->testCmd( "./check_fping $host_responsive" );
40 $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); 27 cmp_ok( $res->return_code, '==', 0, "Responsive host returns OK");
41}
42 28
43exit(0) if defined($Test::Harness::VERSION); 29 $res = NPTest->testCmd( "./check_fping $host_nonresponsive" );
44exit($tests - $t); 30 cmp_ok( $res->return_code, '==', 2, "Non-Responsive host returns Critical");
31
32 $res = NPTest->testCmd( "./check_fping $hostname_invalid" );
33 cmp_ok( $res->return_code, '==', 3, "Invalid host returns Unknown");
34}
diff --git a/plugins/t/check_ftp.t b/plugins/t/check_ftp.t
index de6831ba..93a7d7c3 100644
--- a/plugins/t/check_ftp.t
+++ b/plugins/t/check_ftp.t
@@ -11,14 +11,9 @@ use NPTest;
11use vars qw($tests); 11use vars qw($tests);
12BEGIN {$tests = 4; plan tests => $tests} 12BEGIN {$tests = 4; plan tests => $tests}
13 13
14my $host_tcp_ftp = getTestParameter( "host_tcp_ftp", "NP_HOST_TCP_FTP", "localhost", 14my $host_tcp_ftp = getTestParameter("NP_HOST_TCP_FTP", "A host providing the FTP Service (an FTP server)", "localhost");
15 "A host providing the FTP Service (an FTP server)"); 15my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
16 16my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
17my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
18 "The hostname of system not responsive to network requests" );
19
20my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
21 "An invalid (not known to DNS) hostname" );
22 17
23my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/'; 18my $successOutput = '/FTP OK -\s+[0-9]?\.?[0-9]+ second response time/';
24 19
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index 2b906e30..1f2fbdfd 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,54 +9,46 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 42; 12plan tests => 49;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $successOutput = '/OK.*HTTP.*second/';
15 15
16my $res; 16my $res;
17 17my $plugin = 'check_http';
18my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP", 18$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
19 "A host providing the HTTP Service (a web server)", 19
20 "localhost" ); 20my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
21 21my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
22my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", 22my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
23 "The hostname of system not responsive to network requests", 23my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
24 "10.0.0.1" ); 24my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
25 25my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes");
26my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", 26my $host_tcp_http2 = getTestParameter("NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org");
27 "An invalid (not known to DNS) hostname", 27my $host_tcp_proxy = getTestParameter("NP_HOST_TCP_PROXY", "A host providing a HTTP proxy with CONNECT support", "localhost");
28 "nosuchhost"); 28my $port_tcp_proxy = getTestParameter("NP_PORT_TCP_PROXY", "Port of the proxy with HTTP and CONNECT support", "3128");
29
30my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
31 "Is this system directly connected to the internet?",
32 "yes");
33
34my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
35 "A host providing an index page containing the string 'monitoring'",
36 "test.monitoring-plugins.org" );
37 29
38my $faketime = -x '/usr/bin/faketime' ? 1 : 0; 30my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
39 31
40 32
41$res = NPTest->testCmd( 33$res = NPTest->testCmd(
42 "./check_http $host_tcp_http -wt 300 -ct 600" 34 "./$plugin $host_tcp_http -wt 300 -ct 600"
43 ); 35 );
44cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); 36cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
45like( $res->output, $successOutput, "Output OK" ); 37like( $res->output, $successOutput, "Output OK" );
46 38
47$res = NPTest->testCmd( 39$res = NPTest->testCmd(
48 "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" 40 "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
49 ); 41 );
50like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); 42like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
51 43
52$res = NPTest->testCmd( 44$res = NPTest->testCmd(
53 "./check_http $host_nonresponsive -wt 1 -ct 2 -t 3" 45 "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
54 ); 46 );
55cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); 47cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
56cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK"); 48cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 3 seconds", "Output OK");
57 49
58$res = NPTest->testCmd( 50$res = NPTest->testCmd(
59 "./check_http $hostname_invalid -wt 1 -ct 2" 51 "./$plugin $hostname_invalid -wt 1 -ct 2"
60 ); 52 );
61cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); 53cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
62# The first part of the message comes from the OS catalogue, so cannot check this. 54# The first part of the message comes from the OS catalogue, so cannot check this.
@@ -64,104 +56,135 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
64# Is also possible to get a socket timeout if DNS is not responding fast enough 56# Is also possible to get a socket timeout if DNS is not responding fast enough
65like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); 57like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
66 58
59# host header checks
60$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http");
61like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
62
63$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http -p 80");
64like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
65
66$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
67like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
68
69$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http:8080 -p 80");
70like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
71
72SKIP: {
73 skip "No internet access", 3 if $internet_access eq "no";
74
75 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S");
76 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
77
78 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:8080 -S -p 443");
79 like( $res->output, '/^Host: '.$host_tls_http.':8080\s*$/ms', "Host Header OK" );
80
81 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443");
82 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
83};
84
67SKIP: { 85SKIP: {
68 skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; 86 skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
69 87
70 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring'" ); 88 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring'" );
71 cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'"); 89 cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'");
72 90
73 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing'" ); 91 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" );
74 cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'"); 92 cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'");
75 like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); 93 like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
76 94
77 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'mONiTORing'" ); 95 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" );
78 cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'"); 96 cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'");
79 97
80 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring' --invert-regex" ); 98 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
81 cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); 99 cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
82 like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); 100 like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
83 101
84 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" ); 102 $res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
85 cmp_ok( $res->return_code, "==", 0, "And also when not found"); 103 cmp_ok( $res->return_code, "==", 0, "And also when not found");
86} 104}
87SKIP: { 105SKIP: {
88 skip "No internet access", 16 if $internet_access eq "no"; 106 skip "No internet access", 22 if $internet_access eq "no";
89 107
90 $res = NPTest->testCmd( 108 $res = NPTest->testCmd(
91 "./check_http --ssl www.verisign.com" 109 "./$plugin --ssl $host_tls_http"
92 ); 110 );
93 cmp_ok( $res->return_code, '==', 0, "Can read https for www.verisign.com" ); 111 cmp_ok( $res->return_code, '==', 0, "Can read https for $host_tls_http" );
94 112
95 $res = NPTest->testCmd( "./check_http -C 1 --ssl www.verisign.com" ); 113 $res = NPTest->testCmd( "./$plugin -C 1 --ssl $host_tls_http" );
96 cmp_ok( $res->return_code, '==', 0, "Checking certificate for www.verisign.com"); 114 cmp_ok( $res->return_code, '==', 0, "Checking certificate for $host_tls_http");
97 like ( $res->output, "/Certificate 'www.verisign.com' will expire on/", "Output OK" ); 115 like ( $res->output, "/Certificate '$host_tls_cert' will expire on/", "Output OK" );
98 my $saved_cert_output = $res->output; 116 my $saved_cert_output = $res->output;
99 117
100 $res = NPTest->testCmd( "./check_http -C 8000,1 --ssl www.verisign.com" ); 118 $res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" );
101 cmp_ok( $res->return_code, '==', 1, "Checking certificate for www.verisign.com"); 119 cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http");
102 like ( $res->output, qr/WARNING - Certificate 'www.verisign.com' expires in \d+ day/, "Output Warning" ); 120 like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" );
103 121
104 $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); 122 $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
105 is( $res->return_code, 0, "Old syntax for cert checking okay" ); 123 is( $res->return_code, 0, "Old syntax for cert checking okay" );
106 is( $res->output, $saved_cert_output, "Same output as new syntax" ); 124 is( $res->output, $saved_cert_output, "Same output as new syntax" );
107 125
108 $res = NPTest->testCmd( "./check_http -H www.verisign.com -C 1" ); 126 $res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" );
109 is( $res->return_code, 0, "Updated syntax for cert checking okay" ); 127 is( $res->return_code, 0, "Updated syntax for cert checking okay" );
110 is( $res->output, $saved_cert_output, "Same output as new syntax" ); 128 is( $res->output, $saved_cert_output, "Same output as new syntax" );
111 129
112 $res = NPTest->testCmd( "./check_http -C 1 www.verisign.com" ); 130 $res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" );
113 cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added"); 131 cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
114 132
115 $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); 133 $res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
116 cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); 134 cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
117 135
118 # run some certificate checks with faketime 136 # run some certificate checks with faketime
119 SKIP: { 137 SKIP: {
120 skip "No faketime binary found", 12 if !$faketime; 138 skip "No faketime binary found", 7 if !$faketime;
121 $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com"); 139 $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http");
122 like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output"); 140 like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output");
123 is( $res->return_code, 0, "Catch cert output exit code" ); 141 is( $res->return_code, 0, "Catch cert output exit code" );
124 my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)\./); 142 my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
125 if(!defined $year) { 143 if(!defined $year) {
126 die("parsing date failed from: ".$res); 144 die("parsing date failed from: ".$res->output);
127 } 145 }
128 my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11}; 146 my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
129 my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900); 147 my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
130 my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts)); 148 my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts));
131 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_http -C 1 www.verisign.com"); 149 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./$plugin -C 1 $host_tls_http");
132 like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' just expired/, "Output on expire date"); 150 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date");
133 is( $res->return_code, 2, "Output on expire date" );
134 151
135 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./check_http -C 1 www.verisign.com"); 152 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./$plugin -C 1 $host_tls_http");
136 like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 0 minutes/, "cert expires in 1 second output"); 153 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output");
137 is( $res->return_code, 2, "cert expires in 1 second exit code" );
138 154
139 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./check_http -C 1 www.verisign.com"); 155 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./$plugin -C 1 $host_tls_http");
140 like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 minutes/, "cert expires in 2 minutes output"); 156 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output");
141 is( $res->return_code, 2, "cert expires in 2 minutes exit code" );
142 157
143 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./check_http -C 1 www.verisign.com"); 158 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./$plugin -C 1 $host_tls_http");
144 like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expires in 2 hours/, "cert expires in 2 hours output"); 159 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output");
145 is( $res->return_code, 2, "cert expires in 2 hours exit code" );
146 160
147 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_http -C 1 www.verisign.com"); 161 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./$plugin -C 1 $host_tls_http");
148 like($res->output, qr/CRITICAL - Certificate 'www.verisign.com' expired on/, "Certificate expired output"); 162 like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output");
149 is( $res->return_code, 2, "Certificate expired exit code" );
150 }; 163 };
151 164
152 $res = NPTest->testCmd( "./check_http --ssl www.verisign.com -E" ); 165 $res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -E" );
153 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
154 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 167 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
155 168
156 $res = NPTest->testCmd( 169 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
157 "./check_http --ssl -H www.e-paycobalt.com"
158 );
159 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
160
161
162 $res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" );
163 is( $res->return_code, 0, "Redirection based on location is okay"); 170 is( $res->return_code, 0, "Redirection based on location is okay");
164 171
165 $res = NPTest->testCmd( "./check_http -H www.mozilla.com --extended-perfdata" ); 172 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" );
166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 173 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
167} 174}
175
176SKIP: {
177 skip "No internet access or proxy configured", 6 if $internet_access eq "no" or ! $host_tcp_proxy;
178
179 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302");
180 is( $res->return_code, 0, "Proxy HTTP works");
181 like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficient");
182
183 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT");
184 is( $res->return_code, 0, "Proxy HTTP CONNECT works");
185 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
186
187 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD");
188 is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method");
189 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
190}
diff --git a/plugins/t/check_imap.t b/plugins/t/check_imap.t
index 9c6eae1f..cf2f81c8 100644
--- a/plugins/t/check_imap.t
+++ b/plugins/t/check_imap.t
@@ -8,17 +8,10 @@ use strict;
8use Test::More tests => 7; 8use Test::More tests => 7;
9use NPTest; 9use NPTest;
10 10
11my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", 11my $host_tcp_smtp = getTestParameter("NP_HOST_TCP_SMTP", "A host providing an STMP Service (a mail server)", "mailhost");
12 "A host providing an STMP Service (a mail server)"); 12my $host_tcp_imap = getTestParameter("NP_HOST_TCP_IMAP", "A host providing an IMAP Service (a mail server)", $host_tcp_smtp);
13 13my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
14my $host_tcp_imap = getTestParameter( "host_tcp_imap", "NP_HOST_TCP_IMAP", $host_tcp_smtp, 14my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
15 "A host providing an IMAP Service (a mail server)");
16
17my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
18 "The hostname of system not responsive to network requests" );
19
20my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
21 "An invalid (not known to DNS) hostname" );
22 15
23my $t; 16my $t;
24 17
@@ -32,7 +25,7 @@ $t = NPTest->testCmd( "./check_imap $host_tcp_imap -p 143 -wt 9 -ct 9 -to 10 -e
32cmp_ok( $t->return_code, '==', 0, "Check old parameter options" ); 25cmp_ok( $t->return_code, '==', 0, "Check old parameter options" );
33 26
34$t = NPTest->testCmd( "./check_imap $host_nonresponsive" ); 27$t = NPTest->testCmd( "./check_imap $host_nonresponsive" );
35cmp_ok( $t->return_code, '==', 2, "Get error with non reponsive host" ); 28cmp_ok( $t->return_code, '==', 2, "Get error with non responsive host" );
36 29
37$t = NPTest->testCmd( "./check_imap $hostname_invalid" ); 30$t = NPTest->testCmd( "./check_imap $hostname_invalid" );
38cmp_ok( $t->return_code, '==', 2, "Invalid hostname" ); 31cmp_ok( $t->return_code, '==', 2, "Invalid hostname" );
diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t
index 7a708d5b..fcdae179 100644
--- a/plugins/t/check_jabber.t
+++ b/plugins/t/check_jabber.t
@@ -10,23 +10,9 @@ use NPTest;
10 10
11plan tests => 10; 11plan tests => 10;
12 12
13my $host_tcp_jabber = getTestParameter( 13my $host_tcp_jabber = getTestParameter("NP_HOST_TCP_JABBER", "A host providing the Jabber Service", "jabber.de");
14 "NP_HOST_TCP_JABBER", 14my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
15 "A host providing the Jabber Service", 15my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
16 "jabber.org"
17 );
18
19my $host_nonresponsive = getTestParameter(
20 "NP_HOST_NONRESPONSIVE",
21 "The hostname of system not responsive to network requests",
22 "10.0.0.1",
23 );
24
25my $hostname_invalid = getTestParameter(
26 "NP_HOSTNAME_INVALID",
27 "An invalid (not known to DNS) hostname",
28 "nosuchhost",
29 );
30 16
31 17
32my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/'; 18my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on '.$host_tcp_jabber.' port 5222/';
diff --git a/plugins/t/check_ldap.t b/plugins/t/check_ldap.t
index b8944d4b..b8a4a766 100644
--- a/plugins/t/check_ldap.t
+++ b/plugins/t/check_ldap.t
@@ -9,19 +9,10 @@ use warnings;
9use Test::More; 9use Test::More;
10use NPTest; 10use NPTest;
11 11
12my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP", 12my $host_tcp_ldap = getTestParameter("NP_HOST_TCP_LDAP", "A host providing the LDAP Service", "localhost");
13 "A host providing the LDAP Service", 13my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN", "A base dn for the LDAP Service", "cn=admin");
14 "localhost" ); 14my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
15 15my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
16my $ldap_base_dn = getTestParameter("NP_LDAP_BASE_DN",
17 "A base dn for the LDAP Service",
18 "cn=admin" );
19
20my $host_nonresponsive = getTestParameter("host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
21 "The hostname of system not responsive to network requests" );
22
23my $hostname_invalid = getTestParameter("hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
24 "An invalid (not known to DNS) hostname" );
25 16
26my($result, $cmd); 17my($result, $cmd);
27my $command = './check_ldap'; 18my $command = './check_ldap';
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t
index 55f6f752..bba8947c 100644
--- a/plugins/t/check_load.t
+++ b/plugins/t/check_load.t
@@ -11,10 +11,12 @@ use NPTest;
11my $res; 11my $res;
12 12
13my $loadValue = "[0-9]+\.?[0-9]+"; 13my $loadValue = "[0-9]+\.?[0-9]+";
14my $successOutput = "/^OK - load average: $loadValue, $loadValue, $loadValue/"; 14my $successOutput = "/^LOAD OK - total load average: $loadValue, $loadValue, $loadValue/";
15my $failureOutput = "/^CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; 15my $successScaledOutput = "/^LOAD OK - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
16my $failureOutput = "/^LOAD CRITICAL - total load average: $loadValue, $loadValue, $loadValue/";
17my $failurScaledOutput = "/^LOAD CRITICAL - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
16 18
17plan tests => 11; 19plan tests => 13;
18 20
19$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" ); 21$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
20cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); 22cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
@@ -26,7 +28,7 @@ like( $res->output, $failureOutput, "Output OK");
26 28
27$res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" ); 29$res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
28cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division"); 30cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
29like( $res->output, $failureOutput, "Output OK"); 31like( $res->output, $failurScaledOutput, "Output OK");
30 32
31$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" ); 33$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
32cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments"); 34cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
@@ -34,3 +36,8 @@ like( $res->output, $successOutput, "Output OK");
34like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)"); 36like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
35like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)"); 37like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
36like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)"); 38like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");
39
40
41$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100 -r" );
42cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
43like( $res->output, $successScaledOutput, "Output OK");
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index 28cd4cd0..baf3acc6 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -5,7 +5,7 @@
5# 5#
6# 6#
7# These are the database permissions required for this test: 7# These are the database permissions required for this test:
8# GRANT SELECT ON $db.* TO $user@$host INDENTIFIED BY '$password'; 8# GRANT SELECT ON $db.* TO $user@$host IDENTIFIED BY '$password';
9# GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host; 9# GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host;
10# Check with: 10# Check with:
11# mysql -u$user -p$password -h$host $db 11# mysql -u$user -p$password -h$host $db
@@ -21,30 +21,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
21plan tests => 15; 21plan tests => 15;
22 22
23my $bad_login_output = '/Access denied for user /'; 23my $bad_login_output = '/Access denied for user /';
24my $mysqlserver = getTestParameter( 24my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup");
25 "NP_MYSQL_SERVER", 25my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup");
26 "A MySQL Server hostname or IP with no slaves setup" 26my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest");
27 ); 27my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup");
28my $mysqlsocket = getTestParameter( 28my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest");
29 "NP_MYSQL_SOCKET",
30 "Full path to a MySQL Server socket with no slaves setup"
31 );
32my $mysql_login_details = getTestParameter(
33 "MYSQL_LOGIN_DETAILS",
34 "Command line parameters to specify login access (requires " .
35 "REPLICATION CLIENT privleges)",
36 "-u test -ptest",
37 );
38my $with_slave = getTestParameter(
39 "NP_MYSQL_WITH_SLAVE",
40 "MySQL server with slaves setup"
41 );
42my $with_slave_login = getTestParameter(
43 "NP_MYSQL_WITH_SLAVE_LOGIN",
44 "Login details for server with slave (requires REPLICATION CLIENT " .
45 "privleges)",
46 $mysql_login_details || "-u test -ptest"
47 );
48 29
49my $result; 30my $result;
50 31
diff --git a/plugins/t/check_mysql_query.t b/plugins/t/check_mysql_query.t
index 407af881..c30245b2 100644
--- a/plugins/t/check_mysql_query.t
+++ b/plugins/t/check_mysql_query.t
@@ -17,15 +17,8 @@ use vars qw($tests);
17 17
18plan skip_all => "check_mysql_query not compiled" unless (-x "check_mysql_query"); 18plan skip_all => "check_mysql_query not compiled" unless (-x "check_mysql_query");
19 19
20my $mysqlserver = getTestParameter( 20my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server with no slaves setup");
21 "NP_MYSQL_SERVER", 21my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access", "-u user -ppw -d db");
22 "A MySQL Server with no slaves setup"
23 );
24my $mysql_login_details = getTestParameter(
25 "MYSQL_LOGIN_DETAILS",
26 "Command line parameters to specify login access",
27 "-u user -ppw -d db",
28 );
29my $result; 22my $result;
30 23
31if (! $mysqlserver) { 24if (! $mysqlserver) {
@@ -38,7 +31,7 @@ $result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver $
38cmp_ok( $result->return_code, '==', 0, "Can run query"); 31cmp_ok( $result->return_code, '==', 0, "Can run query");
39 32
40$result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details"); 33$result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details");
41cmp_ok( $result->return_code, '==', 3, "Missing query parmeter"); 34cmp_ok( $result->return_code, '==', 3, "Missing query parameter");
42like( $result->output, "/Must specify a SQL query to run/", "Missing query error message"); 35like( $result->output, "/Must specify a SQL query to run/", "Missing query error message");
43 36
44$result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql"); 37$result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql");
diff --git a/plugins/t/check_nagios.t b/plugins/t/check_nagios.t
index 81fc24d8..f38f5e9c 100644
--- a/plugins/t/check_nagios.t
+++ b/plugins/t/check_nagios.t
@@ -36,7 +36,7 @@ cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" );
36like ( $result->output, $warningOutput, "Output for warning correct" ); 36like ( $result->output, $warningOutput, "Output for warning correct" );
37 37
38my $now = time; 38my $now = time;
39# This substitution is dependant on the testcase 39# This substitution is dependent on the testcase
40system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; 40system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1";
41 41
42$result = NPTest->testCmd( 42$result = NPTest->testCmd(
diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t
index aa6dae45..1a1ebe3e 100644
--- a/plugins/t/check_smtp.t
+++ b/plugins/t/check_smtp.t
@@ -8,12 +8,14 @@ use strict;
8use Test::More; 8use Test::More;
9use NPTest; 9use NPTest;
10 10
11my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP", 11my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP",
12 "A host providing an SMTP Service (a mail server)", "mailhost"); 12 "A host providing an SMTP Service (a mail server)", "mailhost");
13my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS", 13my $host_tcp_smtp_starttls = getTestParameter( "NP_HOST_TCP_SMTP_STARTTLS",
14 "A host providing SMTP with STARTTLS", $host_tcp_smtp);
15my $host_tcp_smtp_nostarttls = getTestParameter( "NP_HOST_TCP_SMTP_NOSTARTTLS",
16 "A host providing SMTP without STARTTLS", "");
17my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS",
14 "A host providing SMTP with TLS", $host_tcp_smtp); 18 "A host providing SMTP with TLS", $host_tcp_smtp);
15my $host_tcp_smtp_notls = getTestParameter( "NP_HOST_TCP_SMTP_NOTLS",
16 "A host providing SMTP without TLS", "");
17 19
18my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", 20my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
19 "The hostname of system not responsive to network requests", "10.0.0.1" ); 21 "The hostname of system not responsive to network requests", "10.0.0.1" );
@@ -22,7 +24,7 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
22 "An invalid (not known to DNS) hostname", "nosuchhost" ); 24 "An invalid (not known to DNS) hostname", "nosuchhost" );
23my $res; 25my $res;
24 26
25plan tests => 10; 27plan tests => 16;
26 28
27SKIP: { 29SKIP: {
28 skip "No SMTP server defined", 4 unless $host_tcp_smtp; 30 skip "No SMTP server defined", 4 unless $host_tcp_smtp;
@@ -42,22 +44,38 @@ SKIP: {
42 local $TODO = "Output is over two lines"; 44 local $TODO = "Output is over two lines";
43 like ( $res->output, qr/^SMTP WARNING/, "Correct error message" ); 45 like ( $res->output, qr/^SMTP WARNING/, "Correct error message" );
44 } 46 }
47
48 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp --ssl -p 25" );
49 is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp with TLS on standard SMTP port" );
50 like ($res->output, qr/^CRITICAL - Cannot make SSL connection\./, "Check output of connecting to $host_tcp_smtp with TLS on standard SMTP port");
45} 51}
46 52
47SKIP: { 53SKIP: {
48 skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls; 54 skip "No SMTP server with STARTTLS defined", 1 unless $host_tcp_smtp_starttls;
49 # SSL connection for TLS 55 # SSL connection for STARTTLS
50 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p 25 -S" ); 56 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_starttls -p 25 -S" );
51 is ($res->return_code, 0, "OK, with STARTTLS" ); 57 is ($res->return_code, 0, "OK, with STARTTLS" );
52} 58}
53 59
54SKIP: { 60SKIP: {
55 skip "No SMTP server without TLS defined", 2 unless $host_tcp_smtp_notls; 61 skip "No SMTP server without STARTTLS defined", 2 unless $host_tcp_smtp_nostarttls;
56 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_notls -p 25 -S" ); 62 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_nostarttls -p 25 -S" );
57 is ($res->return_code, 1, "OK, got warning from server without TLS"); 63 is ($res->return_code, 1, "OK, got warning from server without STARTTLS");
58 is ($res->output, "WARNING - TLS not supported by server", "Right error message" ); 64 is ($res->output, "WARNING - TLS not supported by server", "Right error message" );
59} 65}
60 66
67SKIP: {
68 skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls;
69 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls --ssl" );
70 is ($res->return_code, 0, "Check rc of connecting to $host_tcp_smtp_tls with TLS" );
71 like ($res->output, qr/^SMTP OK - /, "Check output of connecting to $host_tcp_smtp_tls with TLS" );
72
73 my $unused_port = 4465;
74 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p $unused_port --ssl" );
75 is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port" );
76 like ($res->output, qr/^connect to address $host_tcp_smtp_tls and port $unused_port: Connection refused/, "Check output of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port");
77}
78
61$res = NPTest->testCmd( "./check_smtp $host_nonresponsive" ); 79$res = NPTest->testCmd( "./check_smtp $host_nonresponsive" );
62is ($res->return_code, 2, "CRITICAL - host non responding" ); 80is ($res->return_code, 2, "CRITICAL - host non responding" );
63 81
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index aefd872a..576cc506 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -10,44 +10,38 @@ use NPTest;
10 10
11BEGIN { 11BEGIN {
12 plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp"; 12 plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp";
13 plan tests => 61; 13 plan tests => 63;
14} 14}
15 15
16my $res; 16my $res;
17 17
18my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost", 18my $host_snmp = getTestParameter("NP_HOST_SNMP", "A host providing an SNMP Service", "localhost");
19 "A host providing an SNMP Service"); 19my $snmp_community = getTestParameter("NP_SNMP_COMMUNITY", "The SNMP Community string for SNMP Testing (assumes snmp v1)", "public");
20my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
21my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
22my $user_snmp = getTestParameter("NP_SNMP_USER", "An SNMP user", "auth_md5");
20 23
21my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public",
22 "The SNMP Community string for SNMP Testing (assumes snmp v1)" );
23
24my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
25 "The hostname of system not responsive to network requests" );
26
27my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
28 "An invalid (not known to DNS) hostname" );
29my $user_snmp = getTestParameter( "user_snmp", "NP_SNMP_USER", "auth_md5", "An SNMP user");
30 24
31$res = NPTest->testCmd( "./check_snmp -t 1" ); 25$res = NPTest->testCmd( "./check_snmp -t 1" );
32is( $res->return_code, 3, "No host name" ); 26is( $res->return_code, 3, "No host name" );
33is( $res->output, "No host specified" ); 27is( $res->output, "No host specified" );
34 28
35$res = NPTest->testCmd( "./check_snmp -H fakehostname" ); 29$res = NPTest->testCmd( "./check_snmp -H fakehostname --ignore-mib-parsing-errors" );
36is( $res->return_code, 3, "No OIDs specified" ); 30is( $res->return_code, 3, "No OIDs specified" );
37is( $res->output, "No OIDs specified" ); 31is( $res->output, "No OIDs specified" );
38 32
39$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" ); 33$res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3 -U not_a_user --seclevel=rubbish" );
40is( $res->return_code, 3, "Invalid seclevel" ); 34is( $res->return_code, 3, "Invalid seclevel" );
41like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); 35like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" );
42 36
43$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3c" ); 37$res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3c" );
44is( $res->return_code, 3, "Invalid protocol" ); 38is( $res->return_code, 3, "Invalid protocol" );
45like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); 39like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
46 40
47SKIP: { 41SKIP: {
48 skip "no snmp host defined", 48 if ( ! $host_snmp ); 42 skip "no snmp host defined", 50 if ( ! $host_snmp );
49 43
50 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); 44 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
51 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); 45 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
52 like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK"); 46 like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK");
53 $res->output =~ /^SNMP OK - (\d+)/; 47 $res->output =~ /^SNMP OK - (\d+)/;
@@ -57,107 +51,111 @@ SKIP: {
57 51
58 52
59 # some more threshold tests 53 # some more threshold tests
60 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1"); 54 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1");
61 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1" ); 55 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1" );
62 56
63 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:"); 57 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:");
64 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 1:" ); 58 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 1:" );
65 59
66 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c ~:1"); 60 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c ~:1");
67 cmp_ok( $res->return_code, '==', 2, "Threshold test -c ~:1" ); 61 cmp_ok( $res->return_code, '==', 2, "Threshold test -c ~:1" );
68 62
69 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:10"); 63 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:10");
70 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1:10" ); 64 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1:10" );
71 65
72 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c \@1:10"); 66 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c \@1:10");
73 cmp_ok( $res->return_code, '==', 0, "Threshold test -c \@1:10" ); 67 cmp_ok( $res->return_code, '==', 0, "Threshold test -c \@1:10" );
74 68
75 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 10:1"); 69 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 10:1");
76 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 10:1" ); 70 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 10:1" );
77 71
78 72
79 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:"); 73 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:");
80 cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" ); 74 cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" );
81 like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK"); 75 like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK");
82 76
83 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0"); 77 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0");
84 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); 78 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" );
85 unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values"); 79 unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values");
86 80
87 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0,system.sysDescr.0"); 81 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0,system.sysDescr.0");
88 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" ); 82 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" );
89 like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 83 like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
90 84
91 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0"); 85 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0");
92 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" ); 86 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" );
93 like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 87 like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
94 88
95 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"); 89 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1");
96 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" ); 90 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" );
97 like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format"); 91 like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format");
98 92
99 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"); 93 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:");
100 cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " ); 94 cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " );
101 like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format"); 95 like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format");
102 96
103 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"); 97 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0");
104 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" ); 98 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" );
105 like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format"); 99 like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format");
106 100
107 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2"); 101 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2");
108 cmp_ok( $res->return_code, '==', 0, "Checking two OIDs at once" ); 102 cmp_ok( $res->return_code, '==', 0, "Checking two OIDs at once" );
109 like($res->output, "/^SNMP OK - 2 1/", "Got two values back" ); 103 like($res->output, "/^SNMP OK - 2 1/", "Got two values back" );
110 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); 104 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" );
111 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); 105 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" );
112 106
113 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2"); 107 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2");
114 cmp_ok( $res->return_code, '==', 2, "Checking critical threshold is passed if any one value crosses" ); 108 cmp_ok( $res->return_code, '==', 2, "Checking critical threshold is passed if any one value crosses" );
115 like($res->output, "/^SNMP CRITICAL - 2 *1*/", "Got two values back" ); 109 like($res->output, "/^SNMP CRITICAL - 2 *1*/", "Got two values back" );
116 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); 110 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" );
117 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); 111 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" );
118 112
119 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:"); 113 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:");
120 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrMemorySize and hrSystemProcesses"); 114 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrMemorySize and hrSystemProcesses");
121 like($res->output, '/^SNMP OK - \d+ \d+/', "String contains hrMemorySize and hrSystemProcesses"); 115 like($res->output, '/^SNMP OK - \d+ \d+/', "String contains hrMemorySize and hrSystemProcesses");
122 116
123 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0"); 117 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0");
124 cmp_ok( $res->return_code, '==', 0, "Exit OK with inside-range thresholds"); 118 cmp_ok( $res->return_code, '==', 0, "Exit OK with inside-range thresholds");
125 like($res->output, '/^SNMP OK - 1\s.*$/', "String matches SNMP OK and output format"); 119 like($res->output, '/^SNMP OK - 1\s.*$/', "String matches SNMP OK and output format");
126 120
127 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3"); 121 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3");
128 $res->output =~ m/^SNMP OK - (\d+\.\d{2})\s.*$/; 122 $res->output =~ m/^SNMP OK - (\d+\.\d{2})\s.*$/;
129 my $lower = $1 - 0.05; 123 my $lower = $1 - 0.05;
130 my $higher = $1 + 0.05; 124 my $higher = $1 + 0.05;
131 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher"); 125 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher");
132 cmp_ok( $res->return_code, '==', 1, "Exit WARNING with fractionnal arguments"); 126 cmp_ok( $res->return_code, '==', 1, "Exit WARNING with fractionnal arguments");
133 127
134 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2"); 128 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2");
135 cmp_ok( $res->return_code, '==', 1, "Exit WARNING on 2nd threshold"); 129 cmp_ok( $res->return_code, '==', 1, "Exit WARNING on 2nd threshold");
136 like($res->output, '/^SNMP WARNING - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s+\*1\*\s.*$/', "First OID returned as string, 2nd checked for thresholds"); 130 like($res->output, '/^SNMP WARNING - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s+\*1\*\s.*$/', "First OID returned as string, 2nd checked for thresholds");
137 131
138 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''"); 132 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''");
139 cmp_ok( $res->return_code, '==', 0, "Empty thresholds doesn't crash"); 133 cmp_ok( $res->return_code, '==', 0, "Empty thresholds doesn't crash");
140 134
141 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2"); 135 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2");
142 cmp_ok( $res->return_code, '==', 0, "Skipping first two thresholds on 2 OID check"); 136 cmp_ok( $res->return_code, '==', 0, "Skipping first two thresholds on 2 OID check");
143 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping first two thresholds, result printed rather than parsed"); 137 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping first two thresholds, result printed rather than parsed");
144 138
145 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,"); 139 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,");
146 cmp_ok( $res->return_code, '==', 0, "Skipping all thresholds"); 140 cmp_ok( $res->return_code, '==', 0, "Skipping all thresholds");
147 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping all thresholds, result printed rather than parsed"); 141 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping all thresholds, result printed rather than parsed");
148 142
149 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'"); 143 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'");
150 cmp_ok( $res->return_code, '==', 2, "Timetick used as a threshold"); 144 cmp_ok( $res->return_code, '==', 2, "Timetick used as a threshold");
151 like($res->output, '/^SNMP CRITICAL - \*\d+\* 1\/100 sec.*$/', "Timetick used as a threshold, parsed as numeric"); 145 like($res->output, '/^SNMP CRITICAL - \*\d+\* 1\/100 sec.*$/', "Timetick used as a threshold, parsed as numeric");
152 146
153 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0"); 147 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0");
154 cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); 148 cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
155 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); 149 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
150
151 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1");
152 cmp_ok( $res->return_code, '==', 0, "snmp response without datatype");
153 like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" );
156} 154}
157 155
158SKIP: { 156SKIP: {
159 skip "no SNMP user defined", 1 if ( ! $user_snmp ); 157 skip "no SNMP user defined", 1 if ( ! $user_snmp );
160 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv"); 158 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv");
161 like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" ); 159 like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" );
162} 160}
163 161
@@ -165,14 +163,14 @@ SKIP: {
165# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway 163# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway
166SKIP: { 164SKIP: {
167 skip "no non responsive host defined", 2 if ( ! $host_nonresponsive ); 165 skip "no non responsive host defined", 2 if ( ! $host_nonresponsive );
168 $res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); 166 $res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
169 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" ); 167 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" );
170 like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem"); 168 like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem");
171} 169}
172 170
173SKIP: { 171SKIP: {
174 skip "no non invalid host defined", 2 if ( ! $hostname_invalid ); 172 skip "no non invalid host defined", 2 if ( ! $hostname_invalid );
175 $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); 173 $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
176 cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); 174 cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" );
177 like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host)/', "String matches invalid host"); 175 like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host).*/s', "String matches invalid host");
178} 176}
diff --git a/plugins/t/check_ssh.t b/plugins/t/check_ssh.t
index 80083492..a5cd23ce 100644
--- a/plugins/t/check_ssh.t
+++ b/plugins/t/check_ssh.t
@@ -9,17 +9,9 @@ use Test::More;
9use NPTest; 9use NPTest;
10 10
11# Required parameters 11# Required parameters
12my $ssh_host = getTestParameter("NP_SSH_HOST", 12my $ssh_host = getTestParameter("NP_SSH_HOST", "A host providing SSH service", "localhost");
13 "A host providing SSH service", 13my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1" );
14 "localhost"); 14my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost" );
15
16my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE",
17 "The hostname of system not responsive to network requests",
18 "10.0.0.1" );
19
20my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID",
21 "An invalid (not known to DNS) hostname",
22 "nosuchhost" );
23 15
24 16
25plan skip_all => "SSH_HOST must be defined" unless $ssh_host; 17plan skip_all => "SSH_HOST must be defined" unless $ssh_host;
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t
index e44adc90..de9e0f05 100644
--- a/plugins/t/check_swap.t
+++ b/plugins/t/check_swap.t
@@ -8,9 +8,9 @@ use strict;
8use Test::More tests => 8; 8use Test::More tests => 8;
9use NPTest; 9use NPTest;
10 10
11my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; 11my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
12my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; 12my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
13my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/'; 13my $warnOutput = '/^SWAP WARNING - [0-9]+\% free \([0-9]+MB out of [0-9]+MB\)/';
14 14
15my $result; 15my $result;
16 16
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t
index f996685d..cb4de53d 100644
--- a/plugins/t/check_tcp.t
+++ b/plugins/t/check_tcp.t
@@ -15,18 +15,11 @@ BEGIN {
15} 15}
16 16
17 17
18my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", 18my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
19 "A host providing the HTTP Service (a web server)" ); 19my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
20 20my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
21my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", 21my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
22 "The hostname of system not responsive to network requests" ); 22my $internet_access = getTestParameter("NP_INTERNET_ACCESS", "Is this system directly connected to the internet?", "yes");
23
24my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
25 "An invalid (not known to DNS) hostname" );
26
27my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
28 "Is this system directly connected to the internet?",
29 "yes");
30 23
31my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; 24my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/';
32 25
@@ -42,10 +35,10 @@ $t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2
42$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); 35$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 );
43$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); 36$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 );
44if($internet_access ne "no") { 37if($internet_access ne "no") {
45 $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); 38 $t += checkCmd( "./check_tcp -S -D 1 -H $host_tls_http -p 443", 0 );
46 $t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 ); 39 $t += checkCmd( "./check_tcp -S -D 9000,1 -H $host_tls_http -p 443", 1 );
47 $t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); 40 $t += checkCmd( "./check_tcp -S -D 9000 -H $host_tls_http -p 443", 1 );
48 $t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); 41 $t += checkCmd( "./check_tcp -S -D 9000,8999 -H $host_tls_http -p 443", 2 );
49} 42}
50 43
51# Need the \r\n to make it more standards compliant with web servers. Need the various quotes 44# Need the \r\n to make it more standards compliant with web servers. Need the various quotes
diff --git a/plugins/t/check_time.t b/plugins/t/check_time.t
index 961f56e6..92c2f891 100644
--- a/plugins/t/check_time.t
+++ b/plugins/t/check_time.t
@@ -11,14 +11,9 @@ use NPTest;
11use vars qw($tests); 11use vars qw($tests);
12BEGIN {$tests = 8; plan tests => $tests} 12BEGIN {$tests = 8; plan tests => $tests}
13 13
14my $host_udp_time = getTestParameter( "host_udp_time", "NP_HOST_UDP_TIME", "localhost", 14my $host_udp_time = getTestParameter("NP_HOST_UDP_TIME", "A host providing the UDP Time Service", "localhost");
15 "A host providing the UDP Time Service" ); 15my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
16 16my $hostname_invalid = getTestParameter("NP_HOSTNAME_INVALID", "An invalid (not known to DNS) hostname", "nosuchhost");
17my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
18 "The hostname of system not responsive to network requests" );
19
20my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
21 "An invalid (not known to DNS) hostname" );
22 17
23my $successOutput = '/^TIME OK - [0-9]+ second time difference/'; 18my $successOutput = '/^TIME OK - [0-9]+ second time difference/';
24 19
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t
index 1f6fee70..6c47d095 100644
--- a/plugins/t/check_udp.t
+++ b/plugins/t/check_udp.t
@@ -34,12 +34,12 @@ my $nc;
34if(system("which nc.traditional >/dev/null 2>&1") == 0) { 34if(system("which nc.traditional >/dev/null 2>&1") == 0) {
35 $nc = 'nc.traditional -w 3 -l -u -p 3333'; 35 $nc = 'nc.traditional -w 3 -l -u -p 3333';
36} 36}
37elsif(system("which netcat >/dev/null 2>&1") == 0) {
38 $nc = 'netcat -w 3 -l -u -p 3333';
39}
40elsif(system("which nc >/dev/null 2>&1") == 0) { 37elsif(system("which nc >/dev/null 2>&1") == 0) {
41 $nc = 'nc -w 3 -l -u -4 localhost 3333'; 38 $nc = 'nc -w 3 -l -u -4 localhost 3333';
42} 39}
40elsif(system("which netcat >/dev/null 2>&1") == 0) {
41 $nc = 'netcat -w 3 -l -u -p 3333';
42}
43 43
44SKIP: { 44SKIP: {
45 skip "solaris netcat does not listen to udp", 6 if $^O eq 'solaris'; 45 skip "solaris netcat does not listen to udp", 6 if $^O eq 'solaris';
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t
index 39044bb5..9ebc2fc6 100644
--- a/plugins/t/check_users.t
+++ b/plugins/t/check_users.t
@@ -2,7 +2,7 @@
2# 2#
3# Logged in Users Tests via check_users 3# Logged in Users Tests via check_users
4# 4#
5# Trick: This ckeck requires at least 1 user logged in. These commands should 5# Trick: This check requires at least 1 user logged in. These commands should
6# leave a session open forever in the background: 6# leave a session open forever in the background:
7# 7#
8# $ ssh -tt localhost </dev/null >/dev/null 2>/dev/null & 8# $ ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
@@ -13,7 +13,7 @@ use Test;
13use NPTest; 13use NPTest;
14 14
15use vars qw($tests); 15use vars qw($tests);
16BEGIN {$tests = 4; plan tests => $tests} 16BEGIN {$tests = 8; plan tests => $tests}
17 17
18my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/'; 18my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
19my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/'; 19my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/';
@@ -22,6 +22,8 @@ my $t;
22 22
23$t += checkCmd( "./check_users 1000 1000", 0, $successOutput ); 23$t += checkCmd( "./check_users 1000 1000", 0, $successOutput );
24$t += checkCmd( "./check_users 0 0", 2, $failureOutput ); 24$t += checkCmd( "./check_users 0 0", 2, $failureOutput );
25$t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput );
26$t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput );
25 27
26exit(0) if defined($Test::Harness::VERSION); 28exit(0) if defined($Test::Harness::VERSION);
27exit($tests - $t); 29exit($tests - $t);
diff --git a/plugins/t/negate.t b/plugins/t/negate.t
index d96a109b..5ec1c843 100644
--- a/plugins/t/negate.t
+++ b/plugins/t/negate.t
@@ -84,7 +84,7 @@ foreach my $current_state (keys(%state)) {
84 foreach my $new_state (keys(%state)) { 84 foreach my $new_state (keys(%state)) {
85 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); 85 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" );
86 is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" ); 86 is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" );
87 is( $res->output, uc($new_state).": Fake $new_state", "Substitued fake $new_state output"); 87 is( $res->output, uc($new_state).": Fake $new_state", "Substituted fake $new_state output");
88 } 88 }
89} 89}
90 90
diff --git a/plugins/tests/certs/.gitignore b/plugins/tests/certs/.gitignore
new file mode 100644
index 00000000..79acaaa5
--- /dev/null
+++ b/plugins/tests/certs/.gitignore
@@ -0,0 +1,2 @@
1/*.csr
2/*.srl
diff --git a/plugins/tests/certs/client-cert.pem b/plugins/tests/certs/client-cert.pem
new file mode 100644
index 00000000..5709750d
--- /dev/null
+++ b/plugins/tests/certs/client-cert.pem
@@ -0,0 +1,22 @@
1-----BEGIN CERTIFICATE-----
2MIIDtDCCApwCAQIwDQYJKoZIhvcNAQELBQAwgaAxCzAJBgNVBAYTAkRFMRAwDgYD
3VQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0b3Jp
4bmcgUGx1Z2luczEkMCIGA1UEAwwbTW9uaXRvcmluZyBQbHVnaW5zIENsaWVudENB
5MSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdpbnMub3JnMB4X
6DTIxMDIyODIxMDIxMloXDTMwMTEyODIxMDIxMlowgZ4xCzAJBgNVBAYTAkRFMRAw
7DgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0
8b3JpbmcgUGx1Z2luczEiMCAGA1UEAwwZTW9uaXRvcmluZyBQbHVnaW5zIENsaWVu
9dDErMCkGCSqGSIb3DQEJARYcZGV2ZWxAbW9uaXRvcmluZy1wbHVnaW5zLm9yZzCC
10ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3EiqfFPomm5dZQPGYG5SrF
11rPvyqseXTzCkwUIUzGf+Sfm3s13zx7e3ije/04yKhTXgK59EQ793q7E2aWhSOz3s
12hwKKdylFkOIyc5jgbAfF1/pLZMK209rLt/mMRksXCRXYrHdTjRMx1ev4C2407+8Y
138qkf77DuYQmUqCQe7DPOvqLeagdw9JcLGmQNTKHg3fl6wyRl5K1Bsy+qXu2XvEjZ
140Ng7n8LHjOUkTqUEJndOxci9gL5cHU5ttul/GW34dKOtTuMU/pQX6/ywYusOGVOx
15RYI76OolRqj5BqbNctDIB/obe2RLo+UVx74/0jAxtH4XS23pYjO7NUpJcytsVG8C
16AwEAATANBgkqhkiG9w0BAQsFAAOCAQEAYfaY5n4pCq0NWPCdeVVRr4nr+GAfv1TC
17/PKcGuEoJZKt7TQT+OOA5yeZMZb53OvtA49D1r9aoJzWe946KElWOEBqxDRi5Cdr
18wkqpwGcPT2RfAqA3/cvQZ1XsquboXrCf7ajdl5OC64bs2jkqCFh9gnxuI140g8Ar
19Njol8BFxRPaYWOnwuQwmh/2t0FJqr3WSD85HrNqtxUSNGbTdSsvCfgF0v7QVkvLG
203/cbx6z5hxzj2JUjhMnCvn+EbasoJt4xyBFvg67Q2229SMwu9YNqS63GVoKUqhCB
214Gl5v31qx8dAFKuRvnez3ze/6oohwmakZkst4hcQdgZocHhzesvKlg==
22-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/client-key.pem b/plugins/tests/certs/client-key.pem
new file mode 100644
index 00000000..09b6761d
--- /dev/null
+++ b/plugins/tests/certs/client-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDNxIqnxT6JpuXW
3UDxmBuUqxaz78qrHl08wpMFCFMxn/kn5t7Nd88e3t4o3v9OMioU14CufREO/d6ux
4NmloUjs97IcCincpRZDiMnOY4GwHxdf6S2TCttPay7f5jEZLFwkV2Kx3U40TMdXr
5+AtuNO/vGPKpH++w7mEJlKgkHuwzzr6i3moHcPSXCxpkDUyh4N35esMkZeStQbMv
6ql7tl7xI2dDYO5/Cx4zlJE6lBCZ3TsXIvYC+XB1Obbbpfxlt+HSjrU7jFP6UF+v8
7sGLrDhlTsUWCO+jqJUao+QamzXLQyAf6G3tkS6PlFce+P9IwMbR+F0tt6WIzuzVK
8SXMrbFRvAgMBAAECggEBALtc2pB3p0E6KpAiEU0pvCRdSO1FgsIpAd+eNadRPur2
9fi+XWQkUwGeGBaJL1npja3aqP65PP40pj7nWfNaUAgOZyznCEU0QXiPJor6yo0vU
10l5v+aKpwRao107i0RRF80TYGTMx+1LeEqnCqNOZN56gERHlBbkTiWpOZvBzf1143
11oegTcyM6+Ee6+FYNhHaDyIYD0md1S2wGR+IBPet6HwWiakLNKahFPa7lOLIKfmmD
12iTtifcbf4724wSe44a0uTeP4JrquZSeIKakm8MEmffmYqpycnaakYefd0Xc5UEsH
13+VbhKpOWGY3d8FKHqUsTa+6QyXb2uFPo6A+yWm0pdJECgYEA7Prd5sbWACvXOcHT
14ONDBAgyfAVDQwOXi3D4dk6D5mg+/jxl5ZQY5slszJrwsLFtoEzXtYpNfTy3cpNOp
15JLbBDZYnqty+5tD8t3/Zv2IBXCAgvuk5CgfJWP5FNAfiyUEE6Vbp6J/5/vAnODsa
16fxZryN5UsH0X8ew7AlbfcVNyj4kCgYEA3khetIgn+GR6sv9jFRdCT6aJbp0xMsms
176F4v3L5FG4Kp+SwDHL1bVOhieJ5g8odYp9hDbgTEEqbJfNmyCOu9+OQmZ/mztku7
186reU8HhYBIvi+hFeJmvqKpdIgU0Zveg4Bst5QordmhPk8AHjBC4xvQ++uh7rwYKd
19WVsS08bGDjcCgYEAlAuNARUKsASzakOqHv5a9VrJIttH7povBYRQmd+gzxwzgcRa
20UEB5XvEWnYZE2lkoRYgVCtYiXqa6BsasDmGVbVV25okNQckhd8mJUMR7MQBpNJsi
21pR+EK/J9bSnYBf52gQdpDYiTdy60ca6KuQZaw5wRsEgV426+1pFK+dM16HECgYBY
22cTsdYb9lmbUoW201CxgbUQwFsw3MQ2pE2pT4o8wjcg3nUpe6a61XT08+5uV0Gl4w
23CmBp+gN52Fr7DjNEUWg5C64sWLIkqmWOspTUSU3cITyiex6W8wEtCRyUNfU0Fp2U
24Nol87HvXvmqtBFMraqXnr8gXjg4H5MxurUoEcWaEaQKBgCT4iIGZwW0Qf2rkFC7B
25xObzVGefivVVbaf8/c/LRO8TMLdnExkShMOmCzHeHV4mMEZDLbMOusHCI7xm10EX
26l3L1I1Kyqnhm1RH3e7TVWgkTmIDW3V5Fgrhm1jx5Iz6et4sb4Uh+bZq9tTLyqfZY
278s0yJUrfpjRggfk7eUs5s7aY
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/clientca-cert.pem b/plugins/tests/certs/clientca-cert.pem
new file mode 100644
index 00000000..9ce7cd7d
--- /dev/null
+++ b/plugins/tests/certs/clientca-cert.pem
@@ -0,0 +1,25 @@
1-----BEGIN CERTIFICATE-----
2MIIEIzCCAwugAwIBAgIUL9Jfp5zv5B29NgDsNEFU2OM/UHswDQYJKoZIhvcNAQEL
3BQAwgaAxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN
4dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEkMCIGA1UEAwwbTW9u
5aXRvcmluZyBQbHVnaW5zIENsaWVudENBMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBt
6b25pdG9yaW5nLXBsdWdpbnMub3JnMB4XDTIxMDIyODIxMDIxMVoXDTMwMTEyODIx
7MDIxMVowgaAxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQH
8DAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEkMCIGA1UEAwwb
9TW9uaXRvcmluZyBQbHVnaW5zIENsaWVudENBMSswKQYJKoZIhvcNAQkBFhxkZXZl
10bEBtb25pdG9yaW5nLXBsdWdpbnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
11MIIBCgKCAQEAyxiWsGrsJFHw3VR0pqHviXUfbfKMw8LaCxI5EQZfInsMVkBIGWEW
12tFW6qDuAOsMdzsrKOnQRNNt852ts/0Uz++z8zysoauAGpc4JnCZuM5A1DU5CFXBx
13w6Ax+1ft3UsTt8C6kfLfs8mPCbtNVqAHrMrIqDxsNSRRxQSqkzp1vD8rwSKcbB1h
14u2+lut1bEqMe7dp89jKOtc6G/1tHUFQuLAGFoX/qk9yPscmQNzL6YbLP4m9r/416
15PsxWsAfyY97hmoYo6mSCue5LmeanOsjf4Kzq90hIJRwrpiUGmxGjW+tPLEhQBZw6
16C2wHyN74YIJYX2xREz2ijT0mgsqdhO5ZxwIDAQABo1MwUTAdBgNVHQ4EFgQUtsP9
17Z3fKkhmFp97Kh/cW/UqHMIMwHwYDVR0jBBgwFoAUtsP9Z3fKkhmFp97Kh/cW/UqH
18MIMwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEApO5o+YECwTEv
19s+elDJZQ20UYwDSiU9Lpf4EcdnRv6FAb5UlhfRTH3ZdKCc/HX7kcKuy3PsF+b8Pw
20EusoKito9OlNEOF5HYAI9/J54/qceqn+SC0INsISeE19PvT0dma7lBSj4OvBv0IS
21GYbdztVaKLWqYgYs0mcEzteUc4MZcy1/C+Ru1i1Kp2s9/vIeAw2PV2+kpWtw88Pb
22FRJomGngP/hQdwniayCltG/Q1smS4iFEHNI5ayLZj1qJGMHwzqGiRr4KknJKfHzv
23fl4NQaFyMY31s1FRIS6QVIRFHVzUAlKZTdzwqEJygg3fUS9n9uDBnyDI/sW7DQuj
24yjSmYRS1hw==
25-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/clientca-key.pem b/plugins/tests/certs/clientca-key.pem
new file mode 100644
index 00000000..a939f035
--- /dev/null
+++ b/plugins/tests/certs/clientca-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDLGJawauwkUfDd
3VHSmoe+JdR9t8ozDwtoLEjkRBl8iewxWQEgZYRa0VbqoO4A6wx3Oyso6dBE023zn
4a2z/RTP77PzPKyhq4AalzgmcJm4zkDUNTkIVcHHDoDH7V+3dSxO3wLqR8t+zyY8J
5u01WoAesysioPGw1JFHFBKqTOnW8PyvBIpxsHWG7b6W63VsSox7t2nz2Mo61zob/
6W0dQVC4sAYWhf+qT3I+xyZA3Mvphss/ib2v/jXo+zFawB/Jj3uGahijqZIK57kuZ
75qc6yN/grOr3SEglHCumJQabEaNb608sSFAFnDoLbAfI3vhgglhfbFETPaKNPSaC
8yp2E7lnHAgMBAAECggEAJqAWiJbNMlsjI/Tb+pTxqYLM52wpuVFlhpWApOxBS517
9SywOikUcvE9RoI0wZfyVvq5yp4tLenID3z9fC21t5Yu8yOm8VhclLINy8G+epc/X
10RyCLEOjBuiLNXq/qXRvaNChDU16NjPPYcFFe9AqbaxFl+BkFu1Wc94tbpYSIv7Qt
11L6iBxUTXdgvLM5doa9AazIQzJx+jUsVCgRVQQf3zsLqtp9hH0Pfq+KWFIy5TA+bG
120NFmYyQndRjtT0ihWGuNU7D8AXa+z7abzk+HydIlx4D//vGgdNq92QYPdnu2BBya
135Fs6LkmkUonX/I8FbkLbRKkQWNPMt+Ks21t3xcVBgQKBgQDn4HuHVCPwxgU6Mv+5
140sHJXYBq1fDzrUt0+iTtYkRqViX+9Mp4sUpYgXext/wXFLcKzQQp5B0g1dLYLSRS
15KwhsdiN0J7ZcoP1GMStw8zsayRTf8C3WRU6aACqyFiylYbyh56XomfYgwhja/7l9
16pzpVJD9ecG+mLVAyAkJtK2JolQKBgQDgOZfvrQj0L4QG+9E5VmFc3PE+6k3g+zDO
17MWqTSh0fOHqdTEyet4bMC4DogXGVsvw0/UKwbrGHOk0+ltA5VyKUtK/whSutr/+S
18nhCHljhV0XUN/I3OFcvezFjM3g0oC4uy1cL30hoM4IfeHM1d3EYse9N1Y/Op+mR6
19Sx+fEku16wKBgQC0KQ7RjuZ95N2a4pUe5En9EtD8MU4Nhs/iC5k1d+yAUn8jIT9P
20lzCUo8NEKheMN2Qg2Dor8jlPkdNIc4qM7TKWUxQo49IlFlCzgPCnydRac3HsrMhw
21e1ke/pIt3FzEArR1d27I0xcRTL3TKm4M2ynPjWJPFj0peHue33KNL/A+IQKBgEpL
22awd0Sxo1wEZcG9gmwf32C01wbzuTn3lCsHB7Ryj4GtCR3nVclCJ50U24zjzu4Fhi
23bj1tgA8xhzSs3fOR5phlQkKsrWtQfJtFGm8CnEn7LBDlVMsrN7Dr/qRrEuro4HHy
24GDbq+8y2fO5glr955BqLMOadprf0imRnDeQ0OLffAoGBAJio+X+xpglgMOC4BeH9
259LcYi9nUEw8MDJNGo9/3e0XKA7spd3HShLDvt8YZhFJ2m168qBpGfezuw0+jpWxy
26PV9q0dokAgDx4pvCzIKaptZ1D30CWXJZHq25VK1tA41PCUIOh8JD5+R0MpxA5rn2
27DbqL4Vq7K7K0imGENYhHdyM+
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/clientchain-cert.pem b/plugins/tests/certs/clientchain-cert.pem
new file mode 100644
index 00000000..acd1e3e8
--- /dev/null
+++ b/plugins/tests/certs/clientchain-cert.pem
@@ -0,0 +1,45 @@
1-----BEGIN CERTIFICATE-----
2MIIDuTCCAqECAQQwDQYJKoZIhvcNAQELBQAwgaAxCzAJBgNVBAYTAkRFMRAwDgYD
3VQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0b3Jp
4bmcgUGx1Z2luczEkMCIGA1UEAwwbTW9uaXRvcmluZyBQbHVnaW5zIENsaWVudENB
5MSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdpbnMub3JnMB4X
6DTIxMDIyODIxMDIxMloXDTMwMTEyODIxMDIxMlowgaMxCzAJBgNVBAYTAkRFMRAw
7DgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0
8b3JpbmcgUGx1Z2luczEnMCUGA1UEAwweTW9uaXRvcmluZyBQbHVnaW5zIENsaWVu
9dENoYWluMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdpbnMu
10b3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAphvoJBbi/rDvm3+X
118xok0sLCJvCRuUpSbU5wEmREQlkoOGmWK4l6r1JyOphKRBo8+n2MxPiCMvAmTrqx
12VlBmkcmyrwWj392Nga+2SLWTziASk5nFrrhV6U79PkgXnETV2Wk1/FNVIFkB8N+B
13undsTce8LLiCs7hfA5CK7ctJg8fqsAsmgKBNGzBRWwkbvxZPd6xlY6foIJeD7PQ2
14elvTmrD6WXSZq7GshFpDEkL3AifqrPMdsTnbBpyGgJ/fBM1b2dx9k53e25mgEQmn
15iSuYQxn08BsUT0FOvav8ksZLBQz859fuqCtwhikpODO635fD9zK5YkBPlVl+/5xo
16SvKOywIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBh4zeSKjENfY+VDLtPssaNQz2a
17R1ioY40lZ0WoihDSrfG32dqTK/R2YsLKBABjJ7uRYS1NIBMrtS2OktK8BWD5IUTF
18FuGuWilu6IWiTKZrLiZh1rsilNDVqwhorRPxDnbF+qVt9EMIvzKnKdJLGF+CWHN9
19yYJDeTD8MK5uR7zUJR3PsgW4ve5pFTi7z2UJ/xRvgOds6bmeeQnvaWDEL7k2+hrr
200G899A086NL3htzaOnIllg0xo2D1o4ToncAJn+cUQVJmHZSg9HYiD4Lg3z8uXPAl
21rt/MX7dBm4dnImLXbSg7N3e8FdUtz+kZT9z+beKAeIe9JTbpxtsVUTzUZBBA
22-----END CERTIFICATE-----
23-----BEGIN CERTIFICATE-----
24MIID2jCCAsKgAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBoDELMAkGA1UEBhMCREUx
25EDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwSTW9u
26aXRvcmluZyBQbHVnaW5zMSQwIgYDVQQDDBtNb25pdG9yaW5nIFBsdWdpbnMgQ2xp
27ZW50Q0ExKzApBgkqhkiG9w0BCQEWHGRldmVsQG1vbml0b3JpbmctcGx1Z2lucy5v
28cmcwHhcNMjEwMjI4MjEwMjEyWhcNMzAxMTI4MjEwMjEyWjCBqjELMAkGA1UEBhMC
29REUxEDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwS
30TW9uaXRvcmluZyBQbHVnaW5zMS4wLAYDVQQDDCVNb25pdG9yaW5nIFBsdWdpbnMg
31Q2xpZW50SW50ZXJtZWRpYXRlMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9y
32aW5nLXBsdWdpbnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
336rUgOZ9pAOxrcgeeOT3Vmu1YmY2O/C9tXhpKzDzjTaWUzcdDg00KdsjXfgbDzSiV
34uvMzjX63aKpmqeFG+05D2VzQGit3knqerUgl10FnTotiJGF5CU5/gY1aPxTJ7rj2
35tD6LINBkJcPTyQ4MoJT19pssvCax9erY1RxoXxLblJ+31C+VvrftdmBP4nVKXK26
364anb1oUQhkgpXpJimJBmF+v7NbDs1Wh21Be80KXUh9SKgePhSQblr2QlRcA7jLgJ
374PMjZ+KYF+da+4RB7s+DvTXVDMn9AL84E1w5Ut1E8XZV+u4RjWPvNdhK/7GnuxOR
38C9SdxonqkPQ8hiI7thP9bQIDAQABoxMwETAPBgNVHRMBAf8EBTADAQH/MA0GCSqG
39SIb3DQEBCwUAA4IBAQDKQeiDbyr0/7sEhX33MmTDv84GeWgKl9qqHecx+d/0vImb
40c8XHK0PDa4lVqo/BW4P1hjKzpt2DW35kbOhuqGqM0lasIczef43aCDDEBLwstAe6
41qMoyWGVGoAQbpwT3li2pMrsIYoPwMvoSGNUphjrkdpviff2POkLly7a5RrR1X3qt
42Dai6eYbeMCr9NdgW7AZ5++/sKlFoe+zVk/Ed31s4D2lh3awrApZhVgcoquPmEwpt
43gm+OgRmHw50U4SF3ZaJPwDyLMbx+clH/bgUg0+Za9e53Br1NtGKmw7hh/7CG/hy0
44yxeLd930pH4vZu7s0XM56N/ckkfUzRkAH8dSmhH4
45-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/clientchain-key.pem b/plugins/tests/certs/clientchain-key.pem
new file mode 100644
index 00000000..0263604f
--- /dev/null
+++ b/plugins/tests/certs/clientchain-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCmG+gkFuL+sO+b
3f5fzGiTSwsIm8JG5SlJtTnASZERCWSg4aZYriXqvUnI6mEpEGjz6fYzE+IIy8CZO
4urFWUGaRybKvBaPf3Y2Br7ZItZPOIBKTmcWuuFXpTv0+SBecRNXZaTX8U1UgWQHw
534G6d2xNx7wsuIKzuF8DkIrty0mDx+qwCyaAoE0bMFFbCRu/Fk93rGVjp+ggl4Ps
69DZ6W9OasPpZdJmrsayEWkMSQvcCJ+qs8x2xOdsGnIaAn98EzVvZ3H2Tnd7bmaAR
7CaeJK5hDGfTwGxRPQU69q/ySxksFDPzn1+6oK3CGKSk4M7rfl8P3MrliQE+VWX7/
8nGhK8o7LAgMBAAECggEAAfTqMyKh4eYrrGVAYPi53lG0/8htrwUVG3yFDXJo628p
9biCwSCsCavZJqi8JEOxOM5UvB1L2FauGh/7i/+VKkAUUOcOTPpvZguGTACBDcXYn
10Qd3Z2kkJmgn4Kbenr4uQCVOX8zT4F710rGW1nYCyoefsa4pw37UYSW52dH6kiwzW
119k4X251nDMl/twBdOcjZbL768IEa5l4nySLpUNwfrVbSb1NzBoH0dVioh3DTLjt6
12gaShW4eIpaKczht1U97n6/7WNLl6vHX/mR99k/py8OhzhR1ccYpd2IfSHAWyQT0M
13K8BoNnkjICrr9oc0FCr2BVJa3IzKHlhukF4GTZiGYQKBgQDWCHTwAmwL4FFEBVhj
14pZne/sjaZc8TzPPxA8SkmxwDIZrM7tSu7qUuYgWTM432jZbLILWTyGfXf2PpqyF6
15wOpoBJj1ETkre8ZfRmYvsSvS5vtjF3Drszol+XvZnOclfB5VG3m5P2vYkQ8wI9OE
16Y5jUBgDj0RsCNd8QnrC1u54U/wKBgQDGrd5y8S9kUT0P0lkZit7bYjSPJExtClXt
17V7YNTjELrVCdc0jranxBWaub8NP3e6TGTi9HiQWvk2eOAS2qyccqlK4+YAK5XO3D
18EpFUNNcClq8CErw2POuCAKajrPuSp6vd6q8h4lTzDExVctQS4R9fRKKFBKkPUV5G
19UiKFllnKNQKBgQDBGIQXfLfpxwjKK2BhFihKDOc8UhmOrZtvV4zzTJTrJkg4l0f+
20QoN34ytQcHSleXwP6oSmvWkh/GYxjBj6XE2eZndwsYc4ecSwdB0A7gCxl345Gg7g
21NqRBWmGoJGxNXzsmYVFiFZvAmK5xKgFMMWbR8lCfOCn7xopmviSC8K9gFQKBgFRb
22KmH/SbH8VELNews/TVQ0pEBKlzCM/OLjJOcNVgGxOtM/Say677sHibeST0168AFK
233QQwh3t+yK8gjPVA6xGHQ1w0g7OUY1c6IP5x2QC+XdwxfDxDLXNrN1WzcrVX/78f
24j/CBGrR/ekGlmanSb/GRQLfdvLJGSBLveLzjk4gpAoGBANN9RUm/aRz3dDBWex46
25kJ15xKJfLZiUeyDvY5+5d7YF4/tw5LU4XmKQNhiojHecykrTzPUMaGyMrbMPNn32
26WFW9CKMjuBEwWpMDJJb1/5NLEvpwu++sr7bUPZkQl76ot6OqgNHodbP8ATqrNr80
275b8FrEN1LyfkTbabxNyAWcA0
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/clientintermediate-cert.pem b/plugins/tests/certs/clientintermediate-cert.pem
new file mode 100644
index 00000000..608a8fa2
--- /dev/null
+++ b/plugins/tests/certs/clientintermediate-cert.pem
@@ -0,0 +1,23 @@
1-----BEGIN CERTIFICATE-----
2MIID2jCCAsKgAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBoDELMAkGA1UEBhMCREUx
3EDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwSTW9u
4aXRvcmluZyBQbHVnaW5zMSQwIgYDVQQDDBtNb25pdG9yaW5nIFBsdWdpbnMgQ2xp
5ZW50Q0ExKzApBgkqhkiG9w0BCQEWHGRldmVsQG1vbml0b3JpbmctcGx1Z2lucy5v
6cmcwHhcNMjEwMjI4MjEwMjEyWhcNMzAxMTI4MjEwMjEyWjCBqjELMAkGA1UEBhMC
7REUxEDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwS
8TW9uaXRvcmluZyBQbHVnaW5zMS4wLAYDVQQDDCVNb25pdG9yaW5nIFBsdWdpbnMg
9Q2xpZW50SW50ZXJtZWRpYXRlMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9y
10aW5nLXBsdWdpbnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
116rUgOZ9pAOxrcgeeOT3Vmu1YmY2O/C9tXhpKzDzjTaWUzcdDg00KdsjXfgbDzSiV
12uvMzjX63aKpmqeFG+05D2VzQGit3knqerUgl10FnTotiJGF5CU5/gY1aPxTJ7rj2
13tD6LINBkJcPTyQ4MoJT19pssvCax9erY1RxoXxLblJ+31C+VvrftdmBP4nVKXK26
144anb1oUQhkgpXpJimJBmF+v7NbDs1Wh21Be80KXUh9SKgePhSQblr2QlRcA7jLgJ
154PMjZ+KYF+da+4RB7s+DvTXVDMn9AL84E1w5Ut1E8XZV+u4RjWPvNdhK/7GnuxOR
16C9SdxonqkPQ8hiI7thP9bQIDAQABoxMwETAPBgNVHRMBAf8EBTADAQH/MA0GCSqG
17SIb3DQEBCwUAA4IBAQDKQeiDbyr0/7sEhX33MmTDv84GeWgKl9qqHecx+d/0vImb
18c8XHK0PDa4lVqo/BW4P1hjKzpt2DW35kbOhuqGqM0lasIczef43aCDDEBLwstAe6
19qMoyWGVGoAQbpwT3li2pMrsIYoPwMvoSGNUphjrkdpviff2POkLly7a5RrR1X3qt
20Dai6eYbeMCr9NdgW7AZ5++/sKlFoe+zVk/Ed31s4D2lh3awrApZhVgcoquPmEwpt
21gm+OgRmHw50U4SF3ZaJPwDyLMbx+clH/bgUg0+Za9e53Br1NtGKmw7hh/7CG/hy0
22yxeLd930pH4vZu7s0XM56N/ckkfUzRkAH8dSmhH4
23-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/clientintermediate-key.pem b/plugins/tests/certs/clientintermediate-key.pem
new file mode 100644
index 00000000..13f68874
--- /dev/null
+++ b/plugins/tests/certs/clientintermediate-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDqtSA5n2kA7Gty
3B545PdWa7ViZjY78L21eGkrMPONNpZTNx0ODTQp2yNd+BsPNKJW68zONfrdoqmap
44Ub7TkPZXNAaK3eSep6tSCXXQWdOi2IkYXkJTn+BjVo/FMnuuPa0Posg0GQlw9PJ
5DgyglPX2myy8JrH16tjVHGhfEtuUn7fUL5W+t+12YE/idUpcrbrhqdvWhRCGSCle
6kmKYkGYX6/s1sOzVaHbUF7zQpdSH1IqB4+FJBuWvZCVFwDuMuAng8yNn4pgX51r7
7hEHuz4O9NdUMyf0AvzgTXDlS3UTxdlX67hGNY+812Er/sae7E5EL1J3GieqQ9DyG
8Iju2E/1tAgMBAAECggEACyYJXtNUoIeaXvM/r8ZhJBfMEpcnyJDUKBklnmfyABky
9ZUfmzBDXw2as3b6ihFc+LYAp3bm8KouVjtI1lfBUxrli5StVZa7PZLm9mmjv6Eo0
10ojfDEQ8afWPieoaZRO6iQVOLNkbPyv9vSuiQ7vvEZy9dw54u69h47j6IMqPprDiG
11ropUNeGAvTnh1Vf9/8aCHEvHUNHcc4zjzGiQ+E60JgnbpGVeJKoeiMgrQE0yjweo
12KyKA47Y6vqP6+AxAaPplXtmrx2UCbMjktHNvLvg42+2UlLS5roiwmJYEN9c6iT6t
13y82MJrjEFGZyLG2u6ZQANSJiIWaCnOyT1o2deJ8NoQKBgQD7UxivDTuljQD0so+E
14JX9UaFZ9PgS+8LC9v56PciL4XQ7bcCVP5vVgZZPABiQ9i989Wq7qI042Jrfu5qtE
15SthlOAu80GvAQV+Oujwo7ZzM6ciQtjMsj63r2uayWXnmQ07QcIg7x7y161Pt9Bqr
16LIDrqHziIj/lzT7+6QKZaQwFaQKBgQDvEuSC14CBlMhy2jji71kB/3Ya3c+8dP+A
17kQZL9wEWK4a4dm8IaTS8jl1/luhQUzFRMyh2rWaTqqigSe3dvs5DRblhE5NPwTSI
189TO7t1EnzjW3R8LxZZsySyiSFnZ/8mR0empxq0Mov37OdXBj0tXuuzREf/hwijWh
19WuLxJUSjZQKBgAIDZ2Y3l+u6lnBfYdDwL/XwJAk6zvTsnq3WdCG4C1mr/St62YGr
20WvnbtnRKWE356d7m9BHCGKVMaBrM1EBmzRb6fPWVQde3blmJWmQFi0UE9mtaWkyY
21Fg+WoFR7bQOQNHhs/lpkPjnC2dhFJVWLtLiuj9mL5rEjlMab/T5XXhZJAoGBAMEP
22FZ8fXbPGrTQqSwPfWpZFcF9zvbynEmkFM/uGRMddcNZnNXSqWJ7nrFNLTuEGvW2g
23DU4A6zPV/YQrDz4hRjmHBZOCFlSyZbUvpY4yFAQ7/p66AY+kiHZNwT5vi1P5Luvs
24qyaNsZcnRMR+i7rg2EeHv0aNvNdMlNBvL5KikNINAoGAU2P/phdwJOUcqgHavQcQ
25ureTEyZ5i5AeNomNeHSj0slG24V9nxOqEL7D00JKln7oAPovYBUWocEnF39uBJe0
26p0Hy7fCCK6EI8/0QyiQuuZmJfDEEvjQqE6irONNH63r2UwDEpDNGFvGsZNuWHLZc
27SXADu5oSNu6o6IydiyOx528=
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/expired-cert.pem b/plugins/tests/certs/expired-cert.pem
index 40324cf8..87fc8e47 100644
--- a/plugins/tests/certs/expired-cert.pem
+++ b/plugins/tests/certs/expired-cert.pem
@@ -1,21 +1,24 @@
1-----BEGIN CERTIFICATE----- 1-----BEGIN CERTIFICATE-----
2MIIDYzCCAsygAwIBAgIJAJISzcX71f5pMA0GCSqGSIb3DQEBBAUAMH8xCzAJBgNV 2MIIEETCCAvmgAwIBAgIUVDKkhcUoYFnjYCw12tScPIqQzqIwDQYJKoZIhvcNAQEL
3BAYTAlVLMRMwEQYDVQQIEwpEZXJieXNoaXJlMQ8wDQYDVQQHEwZCZWxwZXIxFzAV 3BQAwgZcxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN
4BgNVBAoTDk5hZ2lvcyBQbHVnaW5zMREwDwYDVQQDEwhUb24gVm9vbjEeMBwGCSqG 4dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9u
5SIb3DQEJARYPdG9udm9vbkBtYWMuY29tMB4XDTA5MDMwNjAwMTMxNVoXDTA5MDMw 5aXRvcmluZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5n
6NTAwMTMxNlowfzELMAkGA1UEBhMCVUsxEzARBgNVBAgTCkRlcmJ5c2hpcmUxDzAN 6LXBsdWdpbnMub3JnMB4XDTA4MDEwMTEyMDAwMFoXDTA4MDEwMjEyMDAwMFowgZcx
7BgNVBAcTBkJlbHBlcjEXMBUGA1UEChMOTmFnaW9zIFBsdWdpbnMxETAPBgNVBAMT 7CzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gx
8CFRvbiBWb29uMR4wHAYJKoZIhvcNAQkBFg90b252b29uQG1hYy5jb20wgZ8wDQYJ 8GzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9uaXRvcmlu
9KoZIhvcNAQEBBQADgY0AMIGJAoGBAOQHP4JnzACi4q6quXAiK+gTSffG6yyjEV+K 9ZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdp
10iyutRgBF2MdF03X5ls0wENw/5fnMTrHynl4XoGoV/rD4CR2hGT0m7dv7Vu0MRLlP 10bnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwg1dmGT3rVqM
11J1SCiFeMuQS30zzLMJr0A7IW869qRlKQmzxs1JT6XDbSoNQuF154zoxwNsKlMjoX 11beVWWLy8EAiq9re07AF8sTERy9oIYF5EUq9f0xO53mwwqIWV77O9mF99/kDFGQuQ
12tJSHN2YpAgMBAAGjgeYwgeMwHQYDVR0OBBYEFHWjM9OQldrDLMcAfPnUVfGxlzOp 12NOnICMSHXNtMXEXzfBaMighw0uyCh1o/VCejNQ5x/HU8aLh930g5DIcOJQ3fZ4v9
13MIGzBgNVHSMEgaswgaiAFHWjM9OQldrDLMcAfPnUVfGxlzOpoYGEpIGBMH8xCzAJ 138kBaie7+aPgRMVDM1vIrILfedq9Kt56zvPizkXhDeqxjKyIZdrdoBlX5zAfftWtY
14BgNVBAYTAlVLMRMwEQYDVQQIEwpEZXJieXNoaXJlMQ8wDQYDVQQHEwZCZWxwZXIx 14HpQ+lkThSSXqQnchN6S2JFejmRtsNnceDVOBBdvlzmH0NlfwjynLK3/EJooTsINy
15FzAVBgNVBAoTDk5hZ2lvcyBQbHVnaW5zMREwDwYDVQQDEwhUb24gVm9vbjEeMBwG 15i9dXD8/Oe8r+UA+nokWvnWC2IAUJjpxW+XAyTG/NofGwX+PwquT0YD5cSlODIwZA
16CSqGSIb3DQEJARYPdG9udm9vbkBtYWMuY29tggkAkhLNxfvV/mkwDAYDVR0TBAUw 16WAimygWLqQIDAQABo1MwUTAdBgNVHQ4EFgQUsKyJAwR9OXWEcSZMQz73GfpxCJIw
17AwEB/zANBgkqhkiG9w0BAQQFAAOBgQDHjoXoGwBamCiNplTt93jH/TO08RATdZP5 17HwYDVR0jBBgwFoAUsKyJAwR9OXWEcSZMQz73GfpxCJIwDwYDVR0TAQH/BAUwAwEB
1845hlxv2+PKCjjTiFa2mjAvopFiqmYsr40XYEmpeYMiaOzOW5rBjtqBAT/JJWyfda 18/zANBgkqhkiG9w0BAQsFAAOCAQEAYKFGX7J3Fc/T9s278w61E2dSsY4DS/mjSDik
19SCmj3swqyKus63rv/iuokIhZzBdhbB+eOJJrmwT2SEc5KdRaipH0QAGF1nZAAGzo 19fMWvod6eKw0fE3wJOnkWxjEH3VywTY6CmHd/oiJOaD8lr/Vk+BJfYNVBaVNmguyg
206xW7hkzYog== 204LXoWz9Benx0bAIeuDbNAhOvA4H4aIz8UrD9lKFvKdRp42gPMLtMEbzbLcBdT95D
216BX7EhYm7vTnpitLPgFxVCsJ1JFqv2AQfUm+IkqQkezPs5x0tWLyrvCDNRGJ0kfv
22UuowpUZXDOh3k1vB+xaSOFviieLaCW8TSdd5FZgI2HQj4e6vCKsMGuKKZXrMUTI/
23qtrFlUfsOuwourfC5LMHtCyYo5B3uvAWT1eTXxhrGqyleSlxJQ==
21-----END CERTIFICATE----- 24-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/expired-key.pem b/plugins/tests/certs/expired-key.pem
index af0e24da..c5bba569 100644
--- a/plugins/tests/certs/expired-key.pem
+++ b/plugins/tests/certs/expired-key.pem
@@ -1,15 +1,28 @@
1-----BEGIN RSA PRIVATE KEY----- 1-----BEGIN PRIVATE KEY-----
2MIICXAIBAAKBgQDkBz+CZ8wAouKuqrlwIivoE0n3xussoxFfiosrrUYARdjHRdN1 2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDCDV2YZPetWoxt
3+ZbNMBDcP+X5zE6x8p5eF6BqFf6w+AkdoRk9Ju3b+1btDES5TydUgohXjLkEt9M8 35VZYvLwQCKr2t7TsAXyxMRHL2ghgXkRSr1/TE7nebDCohZXvs72YX33+QMUZC5A0
4yzCa9AOyFvOvakZSkJs8bNSU+lw20qDULhdeeM6McDbCpTI6F7SUhzdmKQIDAQAB 46cgIxIdc20xcRfN8FoyKCHDS7IKHWj9UJ6M1DnH8dTxouH3fSDkMhw4lDd9ni/3y
5AoGARgI3rHjjuDpKMGg4IMZNBqaNaiZHY9/44IVvrww21rSbFqtIfgsQEpU0R/rS 5QFqJ7v5o+BExUMzW8isgt952r0q3nrO8+LOReEN6rGMrIhl2t2gGVfnMB9+1a1ge
6R7xDWPztRGQqmwd/t6OfYNpqHbjO1MWzasVBVnzue5P59Y1xy1h0LZF8+a9GY++0 6lD6WROFJJepCdyE3pLYkV6OZG2w2dx4NU4EF2+XOYfQ2V/CPKcsrf8QmihOwg3KL
7uAGUC24jsXSmypNVzoX+ZKyinA3oYV/etdPYx1W8Ms5XIzUCQQD7xwhMuLok6Kbq 711cPz857yv5QD6eiRa+dYLYgBQmOnFb5cDJMb82h8bBf4/Cq5PRgPlxKU4MjBkBY
8UEgiSfBTbx+haP3IiqqMF14z8QoEyD3jchydNaXEYdQxN8jEl2aPrMqTc6x8Jq4/ 8CKbKBYupAgMBAAECggEBAJ2mdCKJ7LoWdT4W8pZ3BqZUFGkKCF8wOhhOUDH3+ZQp
9ai0OkB+fAkEA59pAmN81HylV7+CsVjLOSbJqzau7NDxSs2uutxhHZRwz0e25wVer 9IYK3XbdDMF7mMIXIuW4a7W4sLlTwU/Ar98U1JMESwRIMS7YvUke+ngDKKLcDVGwY
10fA03l08u0ebC/TDHkmHV6ikCryM5HU2FNwJAVZJFzd2S1myEHmr+uTisB49jDrbi 10Qpjg9vP0v2Al8qT1NbW/nDF0S2aJJbWfAvnblHK5ClFHL9iL107NQYJ8PqzXbnFL
11WkBWypo+mCS6JPnxntXvx7auClq9haTSBY73eqldiFPuMZvr6P2rJqHxPQJBAOTM 11gCQRiZxVHlrbn/73ZUMHPGEoU0711U9hSjrsqrRuSAMC+V38s4HxOomZWutlVAHF
12quaxjti7kATy8N73sD9mBKQGju1TgkFxSK+DFCGhnTnToXY9MAtxd6SoDYoyccYu 12HwClNZBqRO+a2njPyUuV9DM/rl5Tm9IQ89iFo3/QEORICK77HjJYhi+UzdfI5F35
13dyPrzJAR/IYc+mYCdC0CQDKlZuMPVXEgvGaQapzMQ++5yJRvMZF4tWvONBs0OCE9 13UntRJt+WLaiAP+K6Vt6oxHSm58qXnOkeLzaAunTTie0CgYEA6OLYfme8xe5zYXWX
14QYarsTi5M20cymMBXHOLZIjqwsni4G/C9kqJSvC75Vg= 14rqmKNYdcVfMkvL+vUfVT475o/piRtE54JC1LYWEFAN8paxEWHD5HZMy0+ONNXfGm
15-----END RSA PRIVATE KEY----- 15zyNNTN/Lagz4WcpdFzKQmhfdro7DzRiDfdvwSLmaZDyE41PPPVVvfrI9IeDiUNY4
16nWLSb3sWo96Iuns+RoMqeA9wkqsCgYEA1U/UqeVQVTPlrWyiB2VXoI1xvFCCJTf8
174NC0gcisxLRrtINk0BwrUJrRy0x1OLpJWiKwUl/W1GgvPPfhbYcUOb669JNtTIjY
18FeIZblCTjz9GzKKmXeDciXvccyEdCJVUlPO3/e2JiJ4mCDjULprifq0a2gcQevFS
19PfqVULhBOvsCgYB5KfS7J1vGmv36ucSWAe0/VlKLATqe3RfpCzt/JQTZWSWNaroF
20EG/ElUaWIoUZCEW5oglg/0Q0rYYGF4DTCingkhrx7ReVF70BIbSsBzi15d8nKNbY
21t4I3RCF4fyggYe1TmsysXS2DH85/gkToVY7oo2CvF0uJwi8vXnTNDDNkiwKBgHKs
22mAc94BHt9GtnGzQepx0I7TvvjAe2MZwqlt+uojKdS8mfWXMHscGDeYVxdRMqEoUC
23YQfnvfYyjDKaj/XxyE3C237gQsICTyh0hHdpmepIeidIyWdumyDOFZVPF+ylWvM4
24kpFQQb/QRWHmKyti2KCBLw5G/fUaBryLGfprE6ZBAoGBANy5rr41A679UQZ0abev
25bOZb7YWOHYp/wReJaQbvLAyR30os3aEY/0ht9S+OWdrgGMezPKvsx2Sqr/CwoFXI
26esiklpknr11maEPxnQJYi4FYiXS1a3NCg7yBvKzFEgx2XnMAC3s6zhuZXaFq4zNu
27pm5Btrq/NZqtVXovS+UhGLvJ
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/ext.cnf b/plugins/tests/certs/ext.cnf
new file mode 100644
index 00000000..d09cee13
--- /dev/null
+++ b/plugins/tests/certs/ext.cnf
@@ -0,0 +1,2 @@
1[ client_ca ]
2basicConstraints = critical, CA:true
diff --git a/plugins/tests/certs/generate-certs.sh b/plugins/tests/certs/generate-certs.sh
new file mode 100755
index 00000000..78660a26
--- /dev/null
+++ b/plugins/tests/certs/generate-certs.sh
@@ -0,0 +1,63 @@
1#!/bin/sh -e
2#
3# Recreates the https server certificates
4#
5# Set the GEN_EXPIRED environment variable to also regenerate
6# the expired certificate.
7
8cd "$(dirname "$0")"
9trap 'rm -f *.csr; rm -f clientca-cert.srl' EXIT
10
11subj() {
12 c="DE"
13 st="Bavaria"
14 l="Munich"
15 o="Monitoring Plugins"
16 cn="Monitoring Plugins"
17 emailAddress="devel@monitoring-plugins.org"
18
19 if [ -n "$1" ]; then
20 # Add to CN
21 cn="$cn $1"
22 fi
23
24 printf "/C=%s/ST=%s/L=%s/O=%s/CN=%s/emailAddress=%s" \
25 "$c" "$st" "$l" "$o" "$cn" "$emailAddress"
26}
27
28# server
29openssl req -new -x509 -days 3560 -nodes \
30 -keyout server-key.pem -out server-cert.pem \
31 -subj "$(subj)"
32# server, expired
33# there is generally no need to regenerate this, as it will stay epxired
34[ -n "$GEN_EXPIRED" ] && TZ=UTC faketime -f '2008-01-01 12:00:00' \
35 openssl req -new -x509 -days 1 -nodes \
36 -keyout expired-key.pem -out expired-cert.pem \
37 -subj "$(subj)"
38
39# client, ca
40openssl req -new -x509 -days 3560 -nodes \
41 -keyout clientca-key.pem -out clientca-cert.pem \
42 -subj "$(subj ClientCA)"
43echo "01" >clientca-cert.srl
44# client
45openssl req -new -nodes \
46 -keyout client-key.pem -out client-cert.csr \
47 -subj "$(subj Client)"
48openssl x509 -days 3560 -req -CA clientca-cert.pem -CAkey clientca-key.pem \
49 -in client-cert.csr -out client-cert.pem
50# client, intermediate
51openssl req -new -nodes \
52 -keyout clientintermediate-key.pem -out clientintermediate-cert.csr \
53 -subj "$(subj ClientIntermediate)"
54openssl x509 -days 3560 -req -CA clientca-cert.pem -CAkey clientca-key.pem \
55 -extfile ext.cnf -extensions client_ca \
56 -in clientintermediate-cert.csr -out clientintermediate-cert.pem
57# client, chain
58openssl req -new -nodes \
59 -keyout clientchain-key.pem -out clientchain-cert.csr \
60 -subj "$(subj ClientChain)"
61openssl x509 -days 3560 -req -CA clientca-cert.pem -CAkey clientca-key.pem \
62 -in clientchain-cert.csr -out clientchain-cert.pem
63cat clientintermediate-cert.pem >>clientchain-cert.pem
diff --git a/plugins/tests/certs/server-cert.pem b/plugins/tests/certs/server-cert.pem
index 549e4f7e..d1249ef1 100644
--- a/plugins/tests/certs/server-cert.pem
+++ b/plugins/tests/certs/server-cert.pem
@@ -1,21 +1,24 @@
1-----BEGIN CERTIFICATE----- 1-----BEGIN CERTIFICATE-----
2MIIDYzCCAsygAwIBAgIJAL8LkpNwzYdxMA0GCSqGSIb3DQEBBAUAMH8xCzAJBgNV 2MIIEETCCAvmgAwIBAgIUZwOhY4myaCUaPek3NM+MxbLG9vwwDQYJKoZIhvcNAQEL
3BAYTAlVLMRMwEQYDVQQIEwpEZXJieXNoaXJlMQ8wDQYDVQQHEwZCZWxwZXIxFzAV 3BQAwgZcxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN
4BgNVBAoTDk5hZ2lvcyBQbHVnaW5zMREwDwYDVQQDEwhUb24gVm9vbjEeMBwGCSqG 4dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9u
5SIb3DQEJARYPdG9udm9vbkBtYWMuY29tMB4XDTA5MDMwNTIxNDEyOFoXDTE5MDMw 5aXRvcmluZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5n
6MzIxNDEyOFowfzELMAkGA1UEBhMCVUsxEzARBgNVBAgTCkRlcmJ5c2hpcmUxDzAN 6LXBsdWdpbnMub3JnMB4XDTIxMDIyODIxMDIxMVoXDTMwMTEyODIxMDIxMVowgZcx
7BgNVBAcTBkJlbHBlcjEXMBUGA1UEChMOTmFnaW9zIFBsdWdpbnMxETAPBgNVBAMT 7CzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gx
8CFRvbiBWb29uMR4wHAYJKoZIhvcNAQkBFg90b252b29uQG1hYy5jb20wgZ8wDQYJ 8GzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9uaXRvcmlu
9KoZIhvcNAQEBBQADgY0AMIGJAoGBAKcWMBtNtfY8vZXk0SN6/EYTVN/LOvaOSegy 9ZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdp
10oVdLoGwuwjagk+XmCzvCqHZRp8lnCLay7AO8AQI7TSN02ihCcSrgGA9OT+HciIJ1 10bnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2/3eBA4WG6xz
11l5/kEYUAuA1PR6YKK/T713zUAlMzy2tsugx5+xSsSEwsXkmne52jJiG/wuE5CLT0 11LfM6xcWywxThb1Rp7XAW3ewQd9/PdoWXEe8BJWlLfyYi1drLMcsDywhLkKmW4Vp9
129pF8HQqHAgMBAAGjgeYwgeMwHQYDVR0OBBYEFGioSPQ/rdE19+zaeY2YvHTXlUDI 121R4PAkiljjrB/ZaUMDLJ1ri3dwX4RvXG7crsU3QWFWCBOrf5V2FTRQ2m/H/KyB/6
13MIGzBgNVHSMEgaswgaiAFGioSPQ/rdE19+zaeY2YvHTXlUDIoYGEpIGBMH8xCzAJ 13rVZANsU47HqTFSPiUm2j7P3wx/wtHeYC+qmNG7zZTjAYPYxfKiod0lytTSmb+h54
14BgNVBAYTAlVLMRMwEQYDVQQIEwpEZXJieXNoaXJlMQ8wDQYDVQQHEwZCZWxwZXIx 146lxn3+VPEXZAQZlLvPnm/58JnXGrUv7B2yocf5MhKkLJOrGxH2hfwKISfaj2gpOV
15FzAVBgNVBAoTDk5hZ2lvcyBQbHVnaW5zMREwDwYDVQQDEwhUb24gVm9vbjEeMBwG 15m4PUVYiDzCSpq1fPvwbUxIvdO27xprx+mrGOFM6f2UCEOc35w8FSmYiR2yQTnEJK
16CSqGSIb3DQEJARYPdG9udm9vbkBtYWMuY29tggkAvwuSk3DNh3EwDAYDVR0TBAUw 16pbSQD6t1jQIDAQABo1MwUTAdBgNVHQ4EFgQUMeYgglT2aWDlF8KEeF2376AlTGYw
17AwEB/zANBgkqhkiG9w0BAQQFAAOBgQCdqasaIO6JiV5ONFG6Tr1++85UfEdZKMUX 17HwYDVR0jBBgwFoAUMeYgglT2aWDlF8KEeF2376AlTGYwDwYDVR0TAQH/BAUwAwEB
18N2NHiNNUunolIZEYR+dW99ezKmHlDiQ/tMgoLVYpl2Ubho2pAkLGQR+W0ZASgWQ1 18/zANBgkqhkiG9w0BAQsFAAOCAQEAFcEg83rTJdgkp7JLYqK0j8JogSHNlDYchr/r
19NjfV27Rv0y6lYQMTA0lVAU93L1x9reo3FMedmL5+H+lIEpLCxEPtAJNISrJOneZB 19VxKBgQwfnjSp5A8d5+uTQ9s3QDabw8v7YeSrzYXbbjuWZ61mnl84tzOQ8LMeESnC
20W5jDadwkoQ== 20CBXRCxB8Ow22WsVTVJq279SGYT+cZrdsmqGVWDi1A0C5kH+XTLAioG5CZmmxemD/
21S92ZoRxGyYfg33r+3X6EMcEYtHKGxCUa3EPcPOL4dq2F3nOnyjiWPZm3786H3NY2
22nsYwrEhAdUFtbYSsV5O0c/Zlc33fmTfh654ab35io1DtwmFo7q8J532dUE007EN0
23mIQmhdrjNJJHIftgSt0fuN5m48oLOnX7vvkz+X0WLWfVTtMr0w==
21-----END CERTIFICATE----- 24-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/server-key.pem b/plugins/tests/certs/server-key.pem
index eacaeaa3..0de63f8f 100644
--- a/plugins/tests/certs/server-key.pem
+++ b/plugins/tests/certs/server-key.pem
@@ -1,15 +1,28 @@
1-----BEGIN RSA PRIVATE KEY----- 1-----BEGIN PRIVATE KEY-----
2MIICWwIBAAKBgQCnFjAbTbX2PL2V5NEjevxGE1Tfyzr2jknoMqFXS6BsLsI2oJPl 2MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDb/d4EDhYbrHMt
35gs7wqh2UafJZwi2suwDvAECO00jdNooQnEq4BgPTk/h3IiCdZef5BGFALgNT0em 38zrFxbLDFOFvVGntcBbd7BB33892hZcR7wElaUt/JiLV2ssxywPLCEuQqZbhWn3V
4Civ0+9d81AJTM8trbLoMefsUrEhMLF5Jp3udoyYhv8LhOQi09PaRfB0KhwIDAQAB 4Hg8CSKWOOsH9lpQwMsnWuLd3BfhG9cbtyuxTdBYVYIE6t/lXYVNFDab8f8rIH/qt
5AoGAfpxclcP8N3vteXErXURrd7pcXT0GECDgNjhvc9PV20RPXM+vYs1AA+fMeeQE 5VkA2xTjsepMVI+JSbaPs/fDH/C0d5gL6qY0bvNlOMBg9jF8qKh3SXK1NKZv6Hnjq
6TaRqwO6x016aMRO4rz5ztYArecTBznkds1k59pkN/Ne/nsueU4tvGK8MNyS2o986 6XGff5U8RdkBBmUu8+eb/nwmdcatS/sHbKhx/kyEqQsk6sbEfaF/AohJ9qPaCk5Wb
7Voohqkaq4Lcy1bcHJb9su1ELjegEr1R76Mz452Hsy+uTbAECQQDcg/tZWKVeh5CQ 7g9RViIPMJKmrV8+/BtTEi907bvGmvH6asY4Uzp/ZQIQ5zfnDwVKZiJHbJBOcQkql
8dOEB3YWHwfn0NDgfPm/X2i2kAZ7n7URaUy/ffdlfsrr1mBtHCfedLoOxmmlNfEpM 8tJAPq3WNAgMBAAECggEBAIvJDUjQVpXxByL8eazviT5SR0jBf6mC3tTWykQRb7ck
9hXAAurSHAkEAwfk7fEb0iN0Sj9gTozO7c6Ky10KwePZyjVzqSQIiJq3NX8BEaIeb 9/bBEiRrnhDRf3CS9KP4TvO5G8BUU3a2GHYzM08akuKXeiiODidfyfbQ1nUZBAdi9
1051TXxE5VxaLjjMLRkA0hWTYXClgERFZ6AQJAN7ChPqwzf08PRFwwIw911JY5cOHr 10FVFF7tK8YcflkVfpTMOMMSggm6m33fc58sQvmQ/0U85XuJvnOEkeJ9pQJa49e8GR
11NoDHMCUql5vNLNdwBruxgGjBB/kUXEfgw60RusFvgt/zLh1wiii844JDawJAGQBF 11lpCQImF7ygltHPEz4o8qOtNMuPxiHOxpc517+ozQULZk153NTfGok1XctDFFZ3YX
12sYP3urg7zzx7c3qUe5gJ0wLuefjR1PSX4ecbfb7DDMdcSdjIuG1QDiZGmd2f1KG7 128okLSfcqZ28mdHYSvI9xf60Cm7cT9tunXHwZ0f1esTFiVYpAp+oTJqtdYxr/fYlL
13nwSCOtxk5dloW2KGAQJAQh/iBn0QhfKLFAP5eZBVk8E8XlZuw+S2DLy5SnBlIiYJ 13oO8G8iIQ7LjdJfgo84PscpKdSRCq3BfnmER1Eyg6hrUCgYEA/0hL5Y/haz/2jYGy
14GB5I2OClgtudXMv1labFrcST8O9eFrtsrhU1iUGUOw== 14aa8yZSuD1ZcWtj7pLKrBQnHPHIHsjSBggWhopvonCFvCjgSS1pOFOUAwMGc0T+Dw
15-----END RSA PRIVATE KEY----- 15rWo3w8cEUyECl3Bw8gbCWtRXaigzU9TPgCWyx1j5dTopQhLObzS/m7fJFElnYNru
16jqhsUfWS+NKk8a5+A7i9lv4iBLMCgYEA3Jws3Lfj/Xs7LljrvryTMpPthvUGBcyt
17U9Qmf1Hmur90RP5V1rx4FqPQzIeaGQyZDNIUnkhBSqQZNCts3Rzay7N4uQzk8OEg
18S8Llnw76wLwi0SJ4okDtT5tpTR6fcS0M9lGN+zvvfUB4+ul8oub0pMcyme/pywEz
19ap+x3xAQPL8CgYEAiYOBVtTNof9fqdRurh1w8SyipKDx3BRBeQ02c7tozLt0GIWT
20VsJOdXwVIJyFTglKrAnlXvSjwL8nX8wU+eVYyr5fJwSGJ9urC8T2VwVBXW7wTz04
211Zf5GQdlwW8mIHCPATqR6Kj0yVfNN1BX50L0rqWxmRWnQoUzXn/aqQaWfp8CgYAW
229693/zEeR8EejyVkAy/z+RCml0XcPrXg31pusPErihkpwazgIVkDSmTHlmqFpxkc
23C5cX73/UrIbvNoIr9wAUawfrhBsltNpu6MiNKbsTa8LYMRWMFuReAFkTLVf+KWmL
24D2yPtmq1iIvP25UdRJw9t3teKWsWtnZK6HtVNM/r8wKBgQDKlqUpy8r4KK+S2w80
25H7rAQJo1DgXsYrgSa2gfppSKro4lm3ltyAfVIrKQKP7uCo9xTGKVQAUPttMs2+17
26nwbwvt7/nG7G1Dk/C/t6b7SJ80VY5b9ZZKIJ0wOjajLufSjPNCe0ZTRn32XusZUn
27nYGB5/QXYr5WGV9YhAkRsFJYgA==
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
new file mode 100755
index 00000000..3c914830
--- /dev/null
+++ b/plugins/tests/check_curl.t
@@ -0,0 +1,526 @@
1#! /usr/bin/perl -w -I ..
2#
3# Test check_http by having an actual HTTP server running
4#
5# To create the https server certificate:
6# openssl req -new -x509 -keyout server-key.pem -out server-cert.pem -days 3650 -nodes
7# to create a new expired certificate:
8# faketime '2008-01-01 12:00:00' openssl req -new -x509 -keyout expired-key.pem -out expired-cert.pem -days 1 -nodes
9# Country Name (2 letter code) [AU]:DE
10# State or Province Name (full name) [Some-State]:Bavaria
11# Locality Name (eg, city) []:Munich
12# Organization Name (eg, company) [Internet Widgets Pty Ltd]:Monitoring Plugins
13# Organizational Unit Name (eg, section) []:
14# Common Name (e.g. server FQDN or YOUR name) []:Monitoring Plugins
15# Email Address []:devel@monitoring-plugins.org
16
17use strict;
18use Test::More;
19use NPTest;
20use FindBin qw($Bin);
21
22$ENV{'LC_TIME'} = "C";
23
24my $common_tests = 73;
25my $ssl_only_tests = 8;
26# Check that all dependent modules are available
27eval "use HTTP::Daemon 6.01;";
28plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
29eval {
30 require HTTP::Status;
31 require HTTP::Response;
32};
33
34my $plugin = 'check_http';
35$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
36
37# look for libcurl version to see if some advanced checks are possible (>= 7.49.0)
38my $advanced_checks = 12;
39my $use_advanced_checks = 0;
40my $required_version = '7.49.0';
41my $virtual_host = 'www.somefunnyhost.com';
42my $virtual_port = 42;
43my $curl_version = '';
44open (my $fh, '-|', "./$plugin --version") or die;
45while (<$fh>) {
46 if (m{libcurl/([\d.]+)\s}) {
47 $curl_version = $1;
48 last;
49 }
50}
51close ($fh);
52if ($curl_version) {
53 my ($major, $minor, $release) = split (/\./, $curl_version);
54 my ($req_major, $req_minor, $req_release) = split (/\./, $required_version);
55 my $check = ($major <=> $req_major or $minor <=> $req_minor or $release <=> $req_release);
56 if ($check >= 0) {
57 $use_advanced_checks = 1;
58 print "Found libcurl $major.$minor.$release. Using advanced checks\n";
59 }
60}
61
62if ($@) {
63 plan skip_all => "Missing required module for test: $@";
64} else {
65 if (-x "./$plugin") {
66 plan tests => $common_tests * 2 + $ssl_only_tests + $advanced_checks;
67 } else {
68 plan skip_all => "No $plugin compiled";
69 }
70}
71
72my $servers = { http => 0 }; # HTTP::Daemon should always be available
73eval { require HTTP::Daemon::SSL };
74if ($@) {
75 diag "Cannot load HTTP::Daemon::SSL: $@";
76} else {
77 $servers->{https} = 0;
78}
79
80# set a fixed version, so the header size doesn't vary
81$HTTP::Daemon::VERSION = "1.00";
82
83my $port_http = 50000 + int(rand(1000));
84my $port_https = $port_http + 1;
85my $port_https_expired = $port_http + 2;
86
87# This array keeps sockets around for implementing timeouts
88my @persist;
89
90# Start up all servers
91my @pids;
92my $pid = fork();
93if ($pid) {
94 # Parent
95 push @pids, $pid;
96 if (exists $servers->{https}) {
97 # Fork a normal HTTPS server
98 $pid = fork();
99 if ($pid) {
100 # Parent
101 push @pids, $pid;
102 # Fork an expired cert server
103 $pid = fork();
104 if ($pid) {
105 push @pids, $pid;
106 } else {
107 my $d = HTTP::Daemon::SSL->new(
108 LocalPort => $port_https_expired,
109 LocalAddr => "127.0.0.1",
110 SSL_cert_file => "$Bin/certs/expired-cert.pem",
111 SSL_key_file => "$Bin/certs/expired-key.pem",
112 ) || die;
113 print "Please contact https expired at: <URL:", $d->url, ">\n";
114 run_server( $d );
115 exit;
116 }
117 } else {
118 my $d = HTTP::Daemon::SSL->new(
119 LocalPort => $port_https,
120 LocalAddr => "127.0.0.1",
121 SSL_cert_file => "$Bin/certs/server-cert.pem",
122 SSL_key_file => "$Bin/certs/server-key.pem",
123 ) || die;
124 print "Please contact https at: <URL:", $d->url, ">\n";
125 run_server( $d );
126 exit;
127 }
128 }
129} else {
130 # Child
131 #print "child\n";
132 my $d = HTTP::Daemon->new(
133 LocalPort => $port_http,
134 LocalAddr => "127.0.0.1",
135 ) || die;
136 print "Please contact http at: <URL:", $d->url, ">\n";
137 run_server( $d );
138 exit;
139}
140
141# give our webservers some time to startup
142sleep(3);
143
144# Run the same server on http and https
145sub run_server {
146 my $d = shift;
147 MAINLOOP: while (my $c = $d->accept ) {
148 while (my $r = $c->get_request) {
149 if ($r->method eq "GET" and $r->url->path =~ m^/statuscode/(\d+)^) {
150 $c->send_basic_header($1);
151 $c->send_crlf;
152 } elsif ($r->method eq "GET" and $r->url->path =~ m^/file/(.*)^) {
153 $c->send_basic_header;
154 $c->send_crlf;
155 $c->send_file_response("$Bin/var/$1");
156 } elsif ($r->method eq "GET" and $r->url->path eq "/slow") {
157 $c->send_basic_header;
158 $c->send_crlf;
159 sleep 1;
160 $c->send_response("slow");
161 } elsif ($r->url->path eq "/method") {
162 if ($r->method eq "DELETE") {
163 $c->send_error(HTTP::Status->RC_METHOD_NOT_ALLOWED);
164 } elsif ($r->method eq "foo") {
165 $c->send_error(HTTP::Status->RC_NOT_IMPLEMENTED);
166 } else {
167 $c->send_status_line(200, $r->method);
168 }
169 } elsif ($r->url->path eq "/postdata") {
170 $c->send_basic_header;
171 $c->send_crlf;
172 $c->send_response($r->method.":".$r->content);
173 } elsif ($r->url->path eq "/redirect") {
174 $c->send_redirect( "/redirect2" );
175 } elsif ($r->url->path eq "/redir_external") {
176 $c->send_redirect(($d->isa('HTTP::Daemon::SSL') ? "https" : "http") . "://169.254.169.254/redirect2" );
177 } elsif ($r->url->path eq "/redirect2") {
178 $c->send_basic_header;
179 $c->send_crlf;
180 $c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
181 } elsif ($r->url->path eq "/redir_timeout") {
182 $c->send_redirect( "/timeout" );
183 } elsif ($r->url->path eq "/timeout") {
184 # Keep $c from being destroyed, but prevent severe leaks
185 unshift @persist, $c;
186 delete($persist[1000]);
187 next MAINLOOP;
188 } elsif ($r->url->path eq "/header_check") {
189 $c->send_basic_header;
190 $c->send_header('foo');
191 $c->send_crlf;
192 } elsif ($r->url->path eq "/header_broken_check") {
193 $c->send_basic_header;
194 $c->send_header('foo');
195 print $c "Test1:: broken\n";
196 print $c " Test2: leading whitespace\n";
197 $c->send_crlf;
198 } elsif ($r->url->path eq "/virtual_port") {
199 # return sent Host header
200 $c->send_basic_header;
201 $c->send_crlf;
202 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
203 } elsif ($r->url->path eq "/chunked") {
204 my $chunks = ["chunked", "encoding", "test\n"];
205 $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
206 my $chunk = shift @{$chunks};
207 return unless $chunk;
208 sleep(1);
209 return($chunk);
210 }));
211 } else {
212 $c->send_error(HTTP::Status->RC_FORBIDDEN);
213 }
214 $c->close;
215 }
216 }
217}
218
219END {
220 foreach my $pid (@pids) {
221 if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
222 }
223};
224
225if ($ARGV[0] && $ARGV[0] eq "-d") {
226 while (1) {
227 sleep 100;
228 }
229}
230
231my $result;
232my $command = "./$plugin -H 127.0.0.1";
233
234run_common_tests( { command => "$command -p $port_http" } );
235SKIP: {
236 skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https};
237 run_common_tests( { command => "$command -p $port_https", ssl => 1 } );
238
239 my $expiry = "Thu Nov 28 21:02:11 2030 +0000";
240
241 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
242 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
243 is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on $expiry.", "output ok" );
244
245 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
246 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
247 like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
248
249 # Expired cert tests
250 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
251 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
252 like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
253
254 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
255 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
256 is( $result->output,
257 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 12:00:00 2008 +0000.',
258 "output ok" );
259
260}
261
262my $cmd;
263
264# advanced checks with virtual hostname and virtual port
265SKIP: {
266 skip "libcurl version is smaller than $required_version", 6 unless $use_advanced_checks;
267
268 # http without virtual port
269 $cmd = "./$plugin -H $virtual_host -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host:$port_http\$";
270 $result = NPTest->testCmd( $cmd );
271 is( $result->return_code, 0, $cmd);
272 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
273
274 # http with virtual port (!= 80)
275 $cmd = "./$plugin -H $virtual_host:$virtual_port -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host:$virtual_port\$";
276 $result = NPTest->testCmd( $cmd );
277 is( $result->return_code, 0, $cmd);
278 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
279
280 # http with virtual port (80)
281 $cmd = "./$plugin -H $virtual_host:80 -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host\$";
282 $result = NPTest->testCmd( $cmd );
283 is( $result->return_code, 0, $cmd);
284 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
285}
286
287# and the same for SSL
288SKIP: {
289 skip "libcurl version is smaller than $required_version and/or HTTP::Daemon::SSL not installed", 6 if ! exists $servers->{https} or not $use_advanced_checks;
290 # https without virtual port
291 $cmd = "./$plugin -H $virtual_host -I 127.0.0.1 -p $port_https --ssl -u /virtual_port -r ^$virtual_host:$port_https\$";
292 $result = NPTest->testCmd( $cmd );
293 is( $result->return_code, 0, $cmd);
294 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
295
296 # https with virtual port (!= 443)
297 $cmd = "./$plugin -H $virtual_host:$virtual_port -I 127.0.0.1 -p $port_https --ssl -u /virtual_port -r ^$virtual_host:$virtual_port\$";
298 $result = NPTest->testCmd( $cmd );
299 is( $result->return_code, 0, $cmd);
300 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
301
302 # https with virtual port (443)
303 $cmd = "./$plugin -H $virtual_host:443 -I 127.0.0.1 -p $port_https --ssl -u /virtual_port -r ^$virtual_host\$";
304 $result = NPTest->testCmd( $cmd );
305 is( $result->return_code, 0, $cmd);
306 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
307}
308
309
310sub run_common_tests {
311 my ($opts) = @_;
312 my $command = $opts->{command};
313 if ($opts->{ssl}) {
314 $command .= " --ssl";
315 }
316
317 $result = NPTest->testCmd( "$command -u /file/root" );
318 is( $result->return_code, 0, "/file/root");
319 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" );
320
321 $result = NPTest->testCmd( "$command -u /file/root -s Root" );
322 is( $result->return_code, 0, "/file/root search for string");
323 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" );
324
325 $result = NPTest->testCmd( "$command -u /file/root -s NonRoot" );
326 is( $result->return_code, 2, "Missing string check");
327 like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - string 'NonRoot' not found on 'https?://127\.0\.0\.1:\d+/file/root'%, "Shows search string and location");
328
329 $result = NPTest->testCmd( "$command -u /file/root -s NonRootWithOver30charsAndMoreFunThanAWetFish" );
330 is( $result->return_code, 2, "Missing string check");
331 like( $result->output, qr%HTTP CRITICAL: HTTP/1\.1 200 OK - string 'NonRootWithOver30charsAndM...' not found on 'https?://127\.0\.0\.1:\d+/file/root'%, "Shows search string and location");
332
333 $result = NPTest->testCmd( "$command -u /header_check -d foo" );
334 is( $result->return_code, 0, "header_check search for string");
335 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 96 bytes in [\d\.]+ second/', "Output correct" );
336
337 $result = NPTest->testCmd( "$command -u /header_check -d bar" );
338 is( $result->return_code, 2, "Missing header string check");
339 like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - header 'bar' not found on 'https?://127\.0\.0\.1:\d+/header_check'%, "Shows search string and location");
340
341 $result = NPTest->testCmd( "$command -u /header_broken_check" );
342 is( $result->return_code, 0, "header_check search for string");
343 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 138 bytes in [\d\.]+ second/', "Output correct" );
344
345 my $cmd;
346 $cmd = "$command -u /slow";
347 $result = NPTest->testCmd( $cmd );
348 is( $result->return_code, 0, "$cmd");
349 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
350 $result->output =~ /in ([\d\.]+) second/;
351 cmp_ok( $1, ">", 1, "Time is > 1 second" );
352
353 $cmd = "$command -u /statuscode/200";
354 $result = NPTest->testCmd( $cmd );
355 is( $result->return_code, 0, $cmd);
356 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
357
358 $cmd = "$command -u /statuscode/200 -e 200";
359 $result = NPTest->testCmd( $cmd );
360 is( $result->return_code, 0, $cmd);
361 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - Status line output matched "200" - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
362
363 $cmd = "$command -u /statuscode/201";
364 $result = NPTest->testCmd( $cmd );
365 is( $result->return_code, 0, $cmd);
366 like( $result->output, '/^HTTP OK: HTTP/1.1 201 Created - \d+ bytes in [\d\.]+ second /', "Output correct: ".$result->output );
367
368 $cmd = "$command -u /statuscode/201 -e 201";
369 $result = NPTest->testCmd( $cmd );
370 is( $result->return_code, 0, $cmd);
371 like( $result->output, '/^HTTP OK: HTTP/1.1 201 Created - Status line output matched "201" - \d+ bytes in [\d\.]+ second /', "Output correct: ".$result->output );
372
373 $cmd = "$command -u /statuscode/201 -e 200";
374 $result = NPTest->testCmd( $cmd );
375 is( $result->return_code, 2, $cmd);
376 like( $result->output, '/^HTTP CRITICAL - Invalid HTTP response received from host on port \d+: HTTP/1.1 201 Created/', "Output correct: ".$result->output );
377
378 $cmd = "$command -u /statuscode/200 -e 200,201,202";
379 $result = NPTest->testCmd( $cmd );
380 is( $result->return_code, 0, $cmd);
381 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - Status line output matched "200,201,202" - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
382
383 $cmd = "$command -u /statuscode/201 -e 200,201,202";
384 $result = NPTest->testCmd( $cmd );
385 is( $result->return_code, 0, $cmd);
386 like( $result->output, '/^HTTP OK: HTTP/1.1 201 Created - Status line output matched "200,201,202" - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
387
388 $cmd = "$command -u /statuscode/203 -e 200,201,202";
389 $result = NPTest->testCmd( $cmd );
390 is( $result->return_code, 2, $cmd);
391 like( $result->output, '/^HTTP CRITICAL - Invalid HTTP response received from host on port (\d+): HTTP/1.1 203 Non-Authoritative Information/', "Output correct: ".$result->output );
392
393 $cmd = "$command -j HEAD -u /method";
394 $result = NPTest->testCmd( $cmd );
395 is( $result->return_code, 0, $cmd);
396 like( $result->output, '/^HTTP OK: HTTP/1.1 200 HEAD - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
397
398 $cmd = "$command -j POST -u /method";
399 $result = NPTest->testCmd( $cmd );
400 is( $result->return_code, 0, $cmd);
401 like( $result->output, '/^HTTP OK: HTTP/1.1 200 POST - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
402
403 $cmd = "$command -j GET -u /method";
404 $result = NPTest->testCmd( $cmd );
405 is( $result->return_code, 0, $cmd);
406 like( $result->output, '/^HTTP OK: HTTP/1.1 200 GET - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
407
408 $cmd = "$command -u /method";
409 $result = NPTest->testCmd( $cmd );
410 is( $result->return_code, 0, $cmd);
411 like( $result->output, '/^HTTP OK: HTTP/1.1 200 GET - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
412
413 $cmd = "$command -P foo -u /method";
414 $result = NPTest->testCmd( $cmd );
415 is( $result->return_code, 0, $cmd);
416 like( $result->output, '/^HTTP OK: HTTP/1.1 200 POST - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
417
418 $cmd = "$command -j DELETE -u /method";
419 $result = NPTest->testCmd( $cmd );
420 is( $result->return_code, 1, $cmd);
421 like( $result->output, '/^HTTP WARNING: HTTP/1.1 405 Method Not Allowed/', "Output correct: ".$result->output );
422
423 $cmd = "$command -j foo -u /method";
424 $result = NPTest->testCmd( $cmd );
425 is( $result->return_code, 2, $cmd);
426 like( $result->output, '/^HTTP CRITICAL: HTTP/1.1 501 Not Implemented/', "Output correct: ".$result->output );
427
428 $cmd = "$command -P stufftoinclude -u /postdata -s POST:stufftoinclude";
429 $result = NPTest->testCmd( $cmd );
430 is( $result->return_code, 0, $cmd);
431 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
432
433 $cmd = "$command -j PUT -P stufftoinclude -u /postdata -s PUT:stufftoinclude";
434 $result = NPTest->testCmd( $cmd );
435 is( $result->return_code, 0, $cmd);
436 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
437
438 # To confirm that the free doesn't segfault
439 $cmd = "$command -P stufftoinclude -j PUT -u /postdata -s PUT:stufftoinclude";
440 $result = NPTest->testCmd( $cmd );
441 is( $result->return_code, 0, $cmd);
442 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
443
444 $cmd = "$command -u /redirect";
445 $result = NPTest->testCmd( $cmd );
446 is( $result->return_code, 0, $cmd);
447 like( $result->output, '/^HTTP OK: HTTP/1.1 301 Moved Permanently - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
448
449 $cmd = "$command -f follow -u /redirect";
450 $result = NPTest->testCmd( $cmd );
451 is( $result->return_code, 0, $cmd);
452 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
453
454 $cmd = "$command -u /redirect -k 'follow: me'";
455 $result = NPTest->testCmd( $cmd );
456 is( $result->return_code, 0, $cmd);
457 like( $result->output, '/^HTTP OK: HTTP/1.1 301 Moved Permanently - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
458
459 $cmd = "$command -f follow -u /redirect -k 'follow: me'";
460 $result = NPTest->testCmd( $cmd );
461 is( $result->return_code, 0, $cmd);
462 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
463
464 $cmd = "$command -f sticky -u /redirect -k 'follow: me'";
465 $result = NPTest->testCmd( $cmd );
466 is( $result->return_code, 0, $cmd);
467 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
468
469 $cmd = "$command -f stickyport -u /redirect -k 'follow: me'";
470 $result = NPTest->testCmd( $cmd );
471 is( $result->return_code, 0, $cmd);
472 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
473
474 # These tests may block
475 print "ALRM\n";
476
477 # stickyport - on full urlS port is set back to 80 otherwise
478 $cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected";
479 eval {
480 local $SIG{ALRM} = sub { die "alarm\n" };
481 alarm(2);
482 $result = NPTest->testCmd( $cmd );
483 };
484 alarm(0);
485 isnt( $@, "alarm\n", $cmd );
486 is( $result->return_code, 0, $cmd );
487
488 # Let's hope there won't be any web server on :80 returning "redirected"!
489 $cmd = "$command -f sticky -u /redir_external -t 5 -s redirected";
490 eval {
491 local $SIG{ALRM} = sub { die "alarm\n" };
492 alarm(2);
493 $result = NPTest->testCmd( $cmd );
494 };
495 alarm(0);
496 isnt( $@, "alarm\n", $cmd );
497 isnt( $result->return_code, 0, $cmd );
498
499 # Test an external address - timeout
500 SKIP: {
501 skip "This doesn't seem to work all the time", 1 unless ($ENV{HTTP_EXTERNAL});
502 $cmd = "$command -f follow -u /redir_external -t 5";
503 eval {
504 $result = NPTest->testCmd( $cmd, 2 );
505 };
506 like( $@, "/timeout in command: $cmd/", $cmd );
507 }
508
509 $cmd = "$command -u /timeout -t 5";
510 eval {
511 $result = NPTest->testCmd( $cmd, 2 );
512 };
513 like( $@, "/timeout in command: $cmd/", $cmd );
514
515 $cmd = "$command -f follow -u /redir_timeout -t 2";
516 eval {
517 $result = NPTest->testCmd( $cmd, 5 );
518 };
519 is( $@, "", $cmd );
520
521 $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
522 eval {
523 $result = NPTest->testCmd( $cmd, 5 );
524 };
525 is( $@, "", $cmd );
526}
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index e72d243a..6078b274 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -3,22 +3,20 @@
3# Test check_http by having an actual HTTP server running 3# Test check_http by having an actual HTTP server running
4# 4#
5# To create the https server certificate: 5# To create the https server certificate:
6# openssl req -new -x509 -keyout server-key.pem -out server-cert.pem -days 3650 -nodes 6# ./certs/generate-certs.sh
7# Country Name (2 letter code) [AU]:UK
8# State or Province Name (full name) [Some-State]:Derbyshire
9# Locality Name (eg, city) []:Belper
10# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins
11# Organizational Unit Name (eg, section) []:
12# Common Name (eg, YOUR name) []:Ton Voon
13# Email Address []:tonvoon@mac.com
14 7
15use strict; 8use strict;
16use Test::More; 9use Test::More;
17use NPTest; 10use NPTest;
18use FindBin qw($Bin); 11use FindBin qw($Bin);
12use IO::Socket::INET;
19 13
20my $common_tests = 70; 14$ENV{'LC_TIME'} = "C";
21my $ssl_only_tests = 8; 15
16my $common_tests = 71;
17my $virtual_port_tests = 8;
18my $ssl_only_tests = 12;
19my $chunked_encoding_special_tests = 1;
22# Check that all dependent modules are available 20# Check that all dependent modules are available
23eval "use HTTP::Daemon 6.01;"; 21eval "use HTTP::Daemon 6.01;";
24plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@; 22plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
@@ -27,13 +25,16 @@ eval {
27 require HTTP::Response; 25 require HTTP::Response;
28}; 26};
29 27
28my $plugin = 'check_http';
29$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
30
30if ($@) { 31if ($@) {
31 plan skip_all => "Missing required module for test: $@"; 32 plan skip_all => "Missing required module for test: $@";
32} else { 33} else {
33 if (-x "./check_http") { 34 if (-x "./$plugin") {
34 plan tests => $common_tests * 2 + $ssl_only_tests; 35 plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests + $chunked_encoding_special_tests;
35 } else { 36 } else {
36 plan skip_all => "No check_http compiled"; 37 plan skip_all => "No $plugin compiled";
37 } 38 }
38} 39}
39 40
@@ -51,119 +52,217 @@ $HTTP::Daemon::VERSION = "1.00";
51my $port_http = 50000 + int(rand(1000)); 52my $port_http = 50000 + int(rand(1000));
52my $port_https = $port_http + 1; 53my $port_https = $port_http + 1;
53my $port_https_expired = $port_http + 2; 54my $port_https_expired = $port_http + 2;
55my $port_https_clientcert = $port_http + 3;
56my $port_hacked_http = $port_http + 4;
54 57
55# This array keeps sockets around for implementing timeouts 58# This array keeps sockets around for implementing timeouts
56my @persist; 59my @persist;
57 60
58# Start up all servers 61# Start up all servers
59my @pids; 62my @pids;
60my $pid = fork(); 63# Fork a HTTP server
61if ($pid) { 64my $pid = fork;
62 # Parent 65defined $pid or die "Failed to fork";
63 push @pids, $pid; 66if (!$pid) {
64 if (exists $servers->{https}) { 67 undef @pids;
65 # Fork a normal HTTPS server
66 $pid = fork();
67 if ($pid) {
68 # Parent
69 push @pids, $pid;
70 # Fork an expired cert server
71 $pid = fork();
72 if ($pid) {
73 push @pids, $pid;
74 } else {
75 my $d = HTTP::Daemon::SSL->new(
76 LocalPort => $port_https_expired,
77 LocalAddr => "127.0.0.1",
78 SSL_cert_file => "$Bin/certs/expired-cert.pem",
79 SSL_key_file => "$Bin/certs/expired-key.pem",
80 ) || die;
81 print "Please contact https expired at: <URL:", $d->url, ">\n";
82 run_server( $d );
83 exit;
84 }
85 } else {
86 my $d = HTTP::Daemon::SSL->new(
87 LocalPort => $port_https,
88 LocalAddr => "127.0.0.1",
89 SSL_cert_file => "$Bin/certs/server-cert.pem",
90 SSL_key_file => "$Bin/certs/server-key.pem",
91 ) || die;
92 print "Please contact https at: <URL:", $d->url, ">\n";
93 run_server( $d );
94 exit;
95 }
96 }
97 # give our webservers some time to startup
98 sleep(1);
99} else {
100 # Child
101 #print "child\n";
102 my $d = HTTP::Daemon->new( 68 my $d = HTTP::Daemon->new(
103 LocalPort => $port_http, 69 LocalPort => $port_http,
104 LocalAddr => "127.0.0.1", 70 LocalAddr => "127.0.0.1",
105 ) || die; 71 ) || die;
106 print "Please contact http at: <URL:", $d->url, ">\n"; 72 print "Please contact http at: <URL:", $d->url, ">\n";
107 run_server( $d ); 73 run_server( $d );
108 exit; 74 die "webserver stopped";
75}
76push @pids, $pid;
77
78# Fork the hacked HTTP server
79undef $pid;
80$pid = fork;
81defined $pid or die "Failed to fork";
82if (!$pid) {
83 # this is the fork
84 undef @pids;
85 my $socket = new IO::Socket::INET (
86 LocalHost => '0.0.0.0',
87 LocalPort => $port_hacked_http,
88 Proto => 'tcp',
89 Listen => 5,
90 Reuse => 1
91 );
92 die "cannot create socket $!n" unless $socket;
93 my $local_sock = $socket->sockport();
94 print "server waiting for client connection on port $local_sock\n";
95 run_hacked_http_server ( $socket );
96 die "hacked http server stopped";
97}
98push @pids, $pid;
99
100if (exists $servers->{https}) {
101 # Fork a normal HTTPS server
102 $pid = fork;
103 defined $pid or die "Failed to fork";
104 if (!$pid) {
105 undef @pids;
106 # closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
107 local $SIG{'PIPE'} = 'IGNORE';
108 my $d = HTTP::Daemon::SSL->new(
109 LocalPort => $port_https,
110 LocalAddr => "127.0.0.1",
111 SSL_cert_file => "$Bin/certs/server-cert.pem",
112 SSL_key_file => "$Bin/certs/server-key.pem",
113 ) || die;
114 print "Please contact https at: <URL:", $d->url, ">\n";
115 run_server( $d );
116 die "webserver stopped";
117 }
118 push @pids, $pid;
119
120 # Fork an expired cert server
121 $pid = fork;
122 defined $pid or die "Failed to fork";
123 if (!$pid) {
124 undef @pids;
125 # closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
126 local $SIG{'PIPE'} = 'IGNORE';
127 my $d = HTTP::Daemon::SSL->new(
128 LocalPort => $port_https_expired,
129 LocalAddr => "127.0.0.1",
130 SSL_cert_file => "$Bin/certs/expired-cert.pem",
131 SSL_key_file => "$Bin/certs/expired-key.pem",
132 ) || die;
133 print "Please contact https expired at: <URL:", $d->url, ">\n";
134 run_server( $d );
135 die "webserver stopped";
136 }
137 push @pids, $pid;
138
139 # Fork an client cert expecting server
140 $pid = fork;
141 defined $pid or die "Failed to fork";
142 if (!$pid) {
143 undef @pids;
144 # closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
145 local $SIG{'PIPE'} = 'IGNORE';
146 my $d = HTTP::Daemon::SSL->new(
147 LocalPort => $port_https_clientcert,
148 LocalAddr => "127.0.0.1",
149 SSL_cert_file => "$Bin/certs/server-cert.pem",
150 SSL_key_file => "$Bin/certs/server-key.pem",
151 SSL_verify_mode => IO::Socket::SSL->SSL_VERIFY_PEER | IO::Socket::SSL->SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
152 SSL_ca_file => "$Bin/certs/clientca-cert.pem",
153 ) || die;
154 print "Please contact https client cert at: <URL:", $d->url, ">\n";
155 run_server( $d );
156 die "webserver stopped";
157 }
158 push @pids, $pid;
109} 159}
110 160
161# give our webservers some time to startup
162sleep(3);
163
111# Run the same server on http and https 164# Run the same server on http and https
112sub run_server { 165sub run_server {
113 my $d = shift; 166 my $d = shift;
114 MAINLOOP: while (my $c = $d->accept ) { 167 while (1) {
115 while (my $r = $c->get_request) { 168 MAINLOOP: while (my $c = $d->accept) {
116 if ($r->method eq "GET" and $r->url->path =~ m^/statuscode/(\d+)^) { 169 while (my $r = $c->get_request) {
117 $c->send_basic_header($1); 170 if ($r->method eq "GET" and $r->url->path =~ m^/statuscode/(\d+)^) {
118 $c->send_crlf; 171 $c->send_basic_header($1);
119 } elsif ($r->method eq "GET" and $r->url->path =~ m^/file/(.*)^) { 172 $c->send_crlf;
120 $c->send_basic_header; 173 } elsif ($r->method eq "GET" and $r->url->path =~ m^/file/(.*)^) {
121 $c->send_crlf; 174 $c->send_basic_header;
122 $c->send_file_response("$Bin/var/$1"); 175 $c->send_crlf;
123 } elsif ($r->method eq "GET" and $r->url->path eq "/slow") { 176 $c->send_file_response("$Bin/var/$1");
124 $c->send_basic_header; 177 } elsif ($r->method eq "GET" and $r->url->path eq "/slow") {
125 $c->send_crlf; 178 $c->send_basic_header;
126 sleep 1; 179 $c->send_crlf;
127 $c->send_response("slow"); 180 sleep 1;
128 } elsif ($r->url->path eq "/method") { 181 $c->send_response("slow");
129 if ($r->method eq "DELETE") { 182 } elsif ($r->url->path eq "/method") {
130 $c->send_error(HTTP::Status->RC_METHOD_NOT_ALLOWED); 183 if ($r->method eq "DELETE") {
131 } elsif ($r->method eq "foo") { 184 $c->send_error(HTTP::Status->RC_METHOD_NOT_ALLOWED);
132 $c->send_error(HTTP::Status->RC_NOT_IMPLEMENTED); 185 } elsif ($r->method eq "foo") {
186 $c->send_error(HTTP::Status->RC_NOT_IMPLEMENTED);
187 } else {
188 $c->send_status_line(200, $r->method);
189 }
190 } elsif ($r->url->path eq "/postdata") {
191 $c->send_basic_header;
192 $c->send_crlf;
193 $c->send_response($r->method.":".$r->content);
194 } elsif ($r->url->path eq "/redirect") {
195 $c->send_redirect( "/redirect2" );
196 } elsif ($r->url->path eq "/redir_external") {
197 $c->send_redirect(($d->isa('HTTP::Daemon::SSL') ? "https" : "http") . "://169.254.169.254/redirect2" );
198 } elsif ($r->url->path eq "/redirect2") {
199 $c->send_basic_header;
200 $c->send_crlf;
201 $c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
202 } elsif ($r->url->path eq "/redir_timeout") {
203 $c->send_redirect( "/timeout" );
204 } elsif ($r->url->path eq "/timeout") {
205 # Keep $c from being destroyed, but prevent severe leaks
206 unshift @persist, $c;
207 delete($persist[1000]);
208 next MAINLOOP;
209 } elsif ($r->url->path eq "/header_check") {
210 $c->send_basic_header;
211 $c->send_header('foo');
212 $c->send_crlf;
213 } elsif ($r->url->path eq "/virtual_port") {
214 # return sent Host header
215 $c->send_basic_header;
216 $c->send_crlf;
217 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
218 } elsif ($r->url->path eq "/chunked") {
219 my $chunks = ["chunked", "encoding", "test\n"];
220 $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
221 my $chunk = shift @{$chunks};
222 return unless $chunk;
223 sleep(1);
224 return($chunk);
225 }));
133 } else { 226 } else {
134 $c->send_status_line(200, $r->method); 227 $c->send_error(HTTP::Status->RC_FORBIDDEN);
135 } 228 }
136 } elsif ($r->url->path eq "/postdata") { 229 $c->close;
137 $c->send_basic_header;
138 $c->send_crlf;
139 $c->send_response($r->method.":".$r->content);
140 } elsif ($r->url->path eq "/redirect") {
141 $c->send_redirect( "/redirect2" );
142 } elsif ($r->url->path eq "/redir_external") {
143 $c->send_redirect(($d->isa('HTTP::Daemon::SSL') ? "https" : "http") . "://169.254.169.254/redirect2" );
144 } elsif ($r->url->path eq "/redirect2") {
145 $c->send_basic_header;
146 $c->send_crlf;
147 $c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
148 } elsif ($r->url->path eq "/redir_timeout") {
149 $c->send_redirect( "/timeout" );
150 } elsif ($r->url->path eq "/timeout") {
151 # Keep $c from being destroyed, but prevent severe leaks
152 unshift @persist, $c;
153 delete($persist[1000]);
154 next MAINLOOP;
155 } elsif ($r->url->path eq "/header_check") {
156 $c->send_basic_header;
157 $c->send_header('foo');
158 $c->send_crlf;
159 } else {
160 $c->send_error(HTTP::Status->RC_FORBIDDEN);
161 } 230 }
162 $c->close;
163 } 231 }
164 } 232 }
165} 233}
166 234
235sub run_hacked_http_server {
236 my $socket = shift;
237
238 # auto-flush on socket
239 $| = 1;
240
241
242 while(1)
243 {
244 # waiting for a new client connection
245 my $client_socket = $socket->accept();
246
247 # get information about a newly connected client
248 my $client_address = $client_socket->peerhost();
249 my $client_portn = $client_socket->peerport();
250 print "connection from $client_address:$client_portn";
251
252 # read up to 1024 characters from the connected client
253 my $data = "";
254 $client_socket->recv($data, 1024);
255 print "received data: $data";
256
257 # write response data to the connected client
258 $data = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n";
259 $client_socket->send($data);
260
261 # notify client that response has been sent
262 shutdown($client_socket, 1);
263 }
264}
265
167END { 266END {
168 foreach my $pid (@pids) { 267 foreach my $pid (@pids) {
169 if ($pid) { print "Killing $pid\n"; kill "INT", $pid } 268 if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
@@ -177,34 +276,85 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
177} 276}
178 277
179my $result; 278my $result;
180my $command = "./check_http -H 127.0.0.1"; 279my $command = "./$plugin -H 127.0.0.1";
181 280
281run_chunked_encoding_special_test( {command => "$command -p $port_hacked_http"});
182run_common_tests( { command => "$command -p $port_http" } ); 282run_common_tests( { command => "$command -p $port_http" } );
183SKIP: { 283SKIP: {
184 skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https}; 284 skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https};
185 run_common_tests( { command => "$command -p $port_https", ssl => 1 } ); 285 run_common_tests( { command => "$command -p $port_https", ssl => 1 } );
186 286
287 my $expiry = "Thu Nov 28 21:02:11 2030 +0000";
288
187 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); 289 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
188 is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); 290 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
189 is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019.', "output ok" ); 291 is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on $expiry.", "output ok" );
190 292
191 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); 293 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
192 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); 294 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
193 like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" ); 295 like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
194 296
195 # Expired cert tests 297 # Expired cert tests
196 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); 298 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
197 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); 299 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
198 like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" ); 300 like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
199 301
200 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); 302 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
201 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); 303 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
202 is( $result->output, 304 is( $result->output,
203 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009.', 305 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 12:00:00 2008 +0000.',
204 "output ok" ); 306 "output ok" );
205 307
308 # client cert tests
309 my $cmd;
310 $cmd = "$command -p $port_https_clientcert"
311 . " -J \"$Bin/certs/client-cert.pem\""
312 . " -K \"$Bin/certs/client-key.pem\""
313 . " -u /statuscode/200";
314 $result = NPTest->testCmd($cmd);
315 is( $result->return_code, 0, $cmd);
316 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
317
318 $cmd = "$command -p $port_https_clientcert"
319 . " -J \"$Bin/certs/clientchain-cert.pem\""
320 . " -K \"$Bin/certs/clientchain-key.pem\""
321 . " -u /statuscode/200";
322 $result = NPTest->testCmd($cmd);
323 is( $result->return_code, 0, $cmd);
324 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
325}
326
327my $cmd;
328# check virtual port behaviour
329#
330# http without virtual port
331$cmd = "$command -p $port_http -u /virtual_port -r ^127.0.0.1:$port_http\$";
332$result = NPTest->testCmd( $cmd );
333is( $result->return_code, 0, $cmd);
334like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
335
336# http with virtual port
337$cmd = "$command:80 -p $port_http -u /virtual_port -r ^127.0.0.1\$";
338$result = NPTest->testCmd( $cmd );
339is( $result->return_code, 0, $cmd);
340like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
341
342SKIP: {
343 skip "HTTP::Daemon::SSL not installed", 4 if ! exists $servers->{https};
344 # https without virtual port
345 $cmd = "$command -p $port_https --ssl -u /virtual_port -r ^127.0.0.1:$port_https\$";
346 $result = NPTest->testCmd( $cmd );
347 is( $result->return_code, 0, $cmd);
348 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
349
350 # https with virtual port
351 $cmd = "$command:443 -p $port_https --ssl -u /virtual_port -r ^127.0.0.1\$";
352 $result = NPTest->testCmd( $cmd );
353 is( $result->return_code, 0, $cmd);
354 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
206} 355}
207 356
357
208sub run_common_tests { 358sub run_common_tests {
209 my ($opts) = @_; 359 my ($opts) = @_;
210 my $command = $opts->{command}; 360 my $command = $opts->{command};
@@ -370,27 +520,29 @@ sub run_common_tests {
370 520
371 # stickyport - on full urlS port is set back to 80 otherwise 521 # stickyport - on full urlS port is set back to 80 otherwise
372 $cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected"; 522 $cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected";
523 alarm(2);
373 eval { 524 eval {
374 local $SIG{ALRM} = sub { die "alarm\n" }; 525 local $SIG{ALRM} = sub { die "alarm\n" };
375 alarm(2);
376 $result = NPTest->testCmd( $cmd ); 526 $result = NPTest->testCmd( $cmd );
377 alarm(0); }; 527 };
378 isnt( $@, "alarm\n", $cmd ); 528 isnt( $@, "alarm\n", $cmd );
529 alarm(0);
379 is( $result->return_code, 0, $cmd ); 530 is( $result->return_code, 0, $cmd );
380 531
381 # Let's hope there won't be any web server on :80 returning "redirected"! 532 # Let's hope there won't be any web server on :80 returning "redirected"!
382 $cmd = "$command -f sticky -u /redir_external -t 5 -s redirected"; 533 $cmd = "$command -f sticky -u /redir_external -t 5 -s redirected";
534 alarm(2);
383 eval { 535 eval {
384 local $SIG{ALRM} = sub { die "alarm\n" }; 536 local $SIG{ALRM} = sub { die "alarm\n" };
385 alarm(2);
386 $result = NPTest->testCmd( $cmd ); 537 $result = NPTest->testCmd( $cmd );
387 alarm(0); }; 538 };
388 isnt( $@, "alarm\n", $cmd ); 539 isnt( $@, "alarm\n", $cmd );
540 alarm(0);
389 isnt( $result->return_code, 0, $cmd ); 541 isnt( $result->return_code, 0, $cmd );
390 542
391 # Test an external address - timeout 543 # Test an external address - timeout
392 SKIP: { 544 SKIP: {
393 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); 545 skip "This doesn't seem to work all the time", 1 unless ($ENV{HTTP_EXTERNAL});
394 $cmd = "$command -f follow -u /redir_external -t 5"; 546 $cmd = "$command -f follow -u /redir_external -t 5";
395 eval { 547 eval {
396 $result = NPTest->testCmd( $cmd, 2 ); 548 $result = NPTest->testCmd( $cmd, 2 );
@@ -410,4 +562,20 @@ sub run_common_tests {
410 }; 562 };
411 is( $@, "", $cmd ); 563 is( $@, "", $cmd );
412 564
565 $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
566 eval {
567 $result = NPTest->testCmd( $cmd, 5 );
568 };
569 is( $@, "", $cmd );
570}
571
572sub run_chunked_encoding_special_test {
573 my ($opts) = @_;
574 my $command = $opts->{command};
575
576 $cmd = "$command -u / -s 'ChunkedEncodingSpecialTest'";
577 eval {
578 $result = NPTest->testCmd( $cmd, 5 );
579 };
580 is( $@, "", $cmd );
413} 581}
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 54d43d9b..b3a0a301 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -8,13 +8,14 @@ use Test::More;
8use NPTest; 8use NPTest;
9 9
10if (-x "./check_procs") { 10if (-x "./check_procs") {
11 plan tests => 50; 11 plan tests => 54;
12} else { 12} else {
13 plan skip_all => "No check_procs compiled"; 13 plan skip_all => "No check_procs compiled";
14} 14}
15 15
16my $result; 16my $result;
17my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin"; 17my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin";
18my $cmd_etime = "./check_procs --input-file=tests/var/ps-axwo.debian";
18 19
19$result = NPTest->testCmd( "$command" ); 20$result = NPTest->testCmd( "$command" );
20is( $result->return_code, 0, "Run with no options" ); 21is( $result->return_code, 0, "Run with no options" );
@@ -33,9 +34,13 @@ is( $result->return_code, 0, "Checking no threshold breeched" );
33is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" ); 34is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" );
34 35
35$result = NPTest->testCmd( "$command -C launchd -c 5" ); 36$result = NPTest->testCmd( "$command -C launchd -c 5" );
36is( $result->return_code, 2, "Checking processes filtered by command name" ); 37is( $result->return_code, 2, "Checking processes matched by command name" );
37is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" ); 38is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
38 39
40$result = NPTest->testCmd( "$command -X bash -c 5" );
41is( $result->return_code, 2, "Checking processes excluded by command name" );
42is( $result->output, "PROCS CRITICAL: 95 processes with exclude progs 'bash' | procs=95;;5;0;", "Output correct" );
43
39SKIP: { 44SKIP: {
40 skip 'user with uid 501 required', 4 unless getpwuid(501); 45 skip 'user with uid 501 required', 4 unless getpwuid(501);
41 46
@@ -69,9 +74,21 @@ SKIP: {
69 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); 74 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
70}; 75};
71 76
72$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); 77SKIP: {
73is( $result->return_code, 0, "Checking regexp search of arguments" ); 78 skip 'check_procs is compiled with etime format support', 2 if `$command -vvv` =~ m/etime/mx;
74is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); 79
80 $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
81 is( $result->return_code, 0, "Checking regexp search of arguments" );
82 is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
83}
84
85SKIP: {
86 skip 'check_procs is compiled without etime format support', 2 if `$cmd_etime -vvv` !~ m/etime/mx;
87
88 $result = NPTest->testCmd( "$cmd_etime -m ELAPSED -C apache2 -w 1000 -c 2000" );
89 is( $result->return_code, 2, "Checking elapsed time threshold" );
90 is( $result->output, "ELAPSED CRITICAL: 10 crit, 0 warn out of 10 processes with command name 'apache2' | procs=10;;;0; procs_warn=0;;;0; procs_crit=10;;;0;", "Output correct" );
91}
75 92
76$result = NPTest->testCmd( "$command --vsz 1000000" ); 93$result = NPTest->testCmd( "$command --vsz 1000000" );
77is( $result->return_code, 0, "Checking filter by VSZ" ); 94is( $result->return_code, 0, "Checking filter by VSZ" );
@@ -83,7 +100,7 @@ is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;',
83 100
84$result = NPTest->testCmd( "$command -s S" ); 101$result = NPTest->testCmd( "$command -s S" );
85is( $result->return_code, 0, "Checking filter for sleeping processes" ); 102is( $result->return_code, 0, "Checking filter for sleeping processes" );
86like( $result->output, '/^PROCS OK: 44 processes with STATE = S/', "Output correct" ); 103like( $result->output, '/^PROCS OK: 88 processes with STATE = S/', "Output correct" );
87 104
88$result = NPTest->testCmd( "$command -s Z" ); 105$result = NPTest->testCmd( "$command -s Z" );
89is( $result->return_code, 0, "Checking filter for zombies" ); 106is( $result->return_code, 0, "Checking filter for zombies" );
@@ -129,4 +146,3 @@ is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowSe
129$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); 146$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
130is( $result->return_code, 0, "Checking no pipe symbol in output" ); 147is( $result->return_code, 0, "Checking no pipe symbol in output" );
131is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); 148is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
132
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index 73a68b20..bfe42e16 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -7,8 +7,9 @@ use strict;
7use Test::More; 7use Test::More;
8use NPTest; 8use NPTest;
9use FindBin qw($Bin); 9use FindBin qw($Bin);
10use POSIX qw/strftime/;
10 11
11my $tests = 67; 12my $tests = 81;
12# Check that all dependent modules are available 13# Check that all dependent modules are available
13eval { 14eval {
14 require NetSNMP::OID; 15 require NetSNMP::OID;
@@ -37,6 +38,7 @@ if ($@) {
37 38
38my $port_snmp = 16100 + int(rand(100)); 39my $port_snmp = 16100 + int(rand(100));
39 40
41my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
40 42
41# Start up server 43# Start up server
42my @pids; 44my @pids;
@@ -51,13 +53,13 @@ if ($pid) {
51 #print "child\n"; 53 #print "child\n";
52 54
53 print "Please contact SNMP at: $port_snmp\n"; 55 print "Please contact SNMP at: $port_snmp\n";
54 close(STDERR); # Coment out to debug snmpd problems (most errors sent there are OK) 56 close(STDERR); # Comment out to debug snmpd problems (most errors sent there are OK)
55 exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp"); 57 exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
56} 58}
57 59
58END { 60END {
59 foreach my $pid (@pids) { 61 foreach my $pid (@pids) {
60 if ($pid) { print "Killing $pid\n"; kill "INT", $pid } 62 if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
61 } 63 }
62}; 64};
63 65
@@ -118,77 +120,81 @@ like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C
118"And now have fun with with this: \"C:\\\\\" 120"And now have fun with with this: \"C:\\\\\"
119because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); 121because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3");
120 122
121system("rm -f ".$ENV{'MP_STATE_PATH'}."/check_snmp/*"); 123system("rm -f ".$ENV{'MP_STATE_PATH'}."/*/check_snmp/*");
122$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" );
123is($res->return_code, 0, "Returns OK");
124is($res->output, "No previous data to calculate rate - assume okay");
125 124
126# Need to sleep, otherwise duration=0 125# run rate checks with faketime. rate checks depend on the exact amount of time spend between the
127sleep 1; 126# plugin runs which may fail on busy machines.
127# using faketime removes this race condition and also saves all the sleeps in between.
128SKIP: {
129 skip "No faketime binary found", 28 if !$faketime;
128 130
129$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); 131 my $ts = time();
130is($res->return_code, 1, "WARNING - due to going above rate calculation" ); 132 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" );
131is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666;600 "); 133 is($res->return_code, 0, "Returns OK");
134 is($res->output, "No previous data to calculate rate - assume okay");
132 135
133$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); 136 # test rate 1 second later
134is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); 137 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" );
135is($res->output, "Time duration between plugin calls is invalid"); 138 is($res->return_code, 1, "WARNING - due to going above rate calculation" );
139 is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666;600 ");
136 140
141 # test rate with same time
142 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" );
143 is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" );
144 is($res->output, "Time duration between plugin calls is invalid");
137 145
138$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" );
139is($res->return_code, 0, "OK for first call" );
140is($res->output, "No previous data to calculate rate - assume okay" );
141 146
142# Need to sleep, otherwise duration=0 147 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" );
143sleep 1; 148 is($res->return_code, 0, "OK for first call" );
149 is($res->output, "No previous data to calculate rate - assume okay" );
144 150
145$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" ); 151 # test rate 1 second later
146is($res->return_code, 0, "OK as no thresholds" ); 152 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" );
147is($res->output, "SNMP RATE OK - inoctets 666 | inoctets=666 ", "Check label"); 153 is($res->return_code, 0, "OK as no thresholds" );
154 is($res->output, "SNMP RATE OK - inoctets 666 | inoctets=666 ", "Check label");
148 155
149sleep 2; 156 # test rate 3 seconds later
157 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+3))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" );
158 is($res->return_code, 0, "OK as no thresholds" );
159 is($res->output, "SNMP RATE OK - inoctets 333 | inoctets=333 ", "Check rate decreases due to longer interval");
150 160
151$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" );
152is($res->return_code, 0, "OK as no thresholds" );
153is($res->output, "SNMP RATE OK - inoctets 333 | inoctets=333 ", "Check rate decreases due to longer interval");
154 161
162 # label performance data check
163 $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test" );
164 is($res->return_code, 0, "OK as no thresholds" );
165 is($res->output, "SNMP OK - test 67996 | test=67996c ", "Check label");
155 166
156# label performance data check 167 $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l \"test'test\"" );
157$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test" ); 168 is($res->return_code, 0, "OK as no thresholds" );
158is($res->return_code, 0, "OK as no thresholds" ); 169 is($res->output, "SNMP OK - test'test 68662 | \"test'test\"=68662c ", "Check label");
159is($res->output, "SNMP OK - test 67996 | test=67996c ", "Check label");
160 170
161$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l \"test'test\"" ); 171 $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test\"test'" );
162is($res->return_code, 0, "OK as no thresholds" ); 172 is($res->return_code, 0, "OK as no thresholds" );
163is($res->output, "SNMP OK - test'test 68662 | \"test'test\"=68662c ", "Check label"); 173 is($res->output, "SNMP OK - test\"test 69328 | 'test\"test'=69328c ", "Check label");
164 174
165$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test\"test'" ); 175 $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test -O" );
166is($res->return_code, 0, "OK as no thresholds" ); 176 is($res->return_code, 0, "OK as no thresholds" );
167is($res->output, "SNMP OK - test\"test 69328 | 'test\"test'=69328c ", "Check label"); 177 is($res->output, "SNMP OK - test 69994 | iso.3.6.1.4.1.8072.3.2.67.10=69994c ", "Check label");
168 178
169$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test -O" ); 179 $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10" );
170is($res->return_code, 0, "OK as no thresholds" ); 180 is($res->return_code, 0, "OK as no thresholds" );
171is($res->output, "SNMP OK - test 69994 | iso.3.6.1.4.1.8072.3.2.67.10=69994c ", "Check label"); 181 is($res->output, "SNMP OK - 70660 | iso.3.6.1.4.1.8072.3.2.67.10=70660c ", "Check label");
172 182
173$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10" ); 183 $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test test'" );
174is($res->return_code, 0, "OK as no thresholds" ); 184 is($res->return_code, 0, "OK as no thresholds" );
175is($res->output, "SNMP OK - 70660 | iso.3.6.1.4.1.8072.3.2.67.10=70660c ", "Check label"); 185 is($res->output, "SNMP OK - test test 71326 | 'test test'=71326c ", "Check label");
176 186
177$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test test'" );
178is($res->return_code, 0, "OK as no thresholds" );
179is($res->output, "SNMP OK - test test 71326 | 'test test'=71326c ", "Check label");
180 187
188 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" );
189 is($res->return_code, 0, "OK for first call" );
190 is($res->output, "No previous data to calculate rate - assume okay" );
181 191
182$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" ); 192 # test 1 second later
183is($res->return_code, 0, "OK for first call" ); 193 $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" );
184is($res->output, "No previous data to calculate rate - assume okay" ); 194 is($res->return_code, 0, "OK as no thresholds" );
185 195 is($res->output, "SNMP RATE OK - inoctets_per_minute 39960 | inoctets_per_minute=39960 ", "Checking multiplier");
186# Need to sleep, otherwise duration=0 196};
187sleep 1;
188 197
189$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" );
190is($res->return_code, 0, "OK as no thresholds" );
191is($res->output, "SNMP RATE OK - inoctets_per_minute 39960 | inoctets_per_minute=39960 ", "Checking multiplier");
192 198
193 199
194$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.11 -s '\"stringtests\"'" ); 200$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.11 -s '\"stringtests\"'" );
@@ -221,7 +227,7 @@ is($res->output, 'SNMP OK - "555\"I said\"" | ', "Check string with a double quo
221 227
222$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.15 -r 'CUSTOM CHECK OK'" ); 228$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.15 -r 'CUSTOM CHECK OK'" );
223is($res->return_code, 0, "String check should check whole string, not a parsed number" ); 229is($res->return_code, 0, "String check should check whole string, not a parsed number" );
224is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string"); 230is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check with numbers returns whole string");
225 231
226$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); 232$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
227is($res->return_code, 0, "Negative integer check OK" ); 233is($res->return_code, 0, "Negative integer check OK" );
@@ -245,9 +251,36 @@ is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-2:;-3:
245 251
246$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c '~:-6.5'" ); 252$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c '~:-6.5'" );
247is($res->return_code, 0, "Negative float OK" ); 253is($res->return_code, 0, "Negative float OK" );
248is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;~:-6.5 ', "Negative float OK output" ); 254is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;@-6.5:~ ', "Negative float OK output" );
249 255
250$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w '~:-6.65' -c '~:-6.55'" ); 256$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w '~:-6.65' -c '~:-6.55'" );
251is($res->return_code, 1, "Negative float WARNING" ); 257is($res->return_code, 1, "Negative float WARNING" );
252is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;~:-6.65;~:-6.55 ', "Negative float WARNING output" ); 258is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;@-6.65:~;@-6.55:~ ', "Negative float WARNING output" );
259
260$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w '1:100000,-10:20' -c '2:200000,-20:30'" );
261is($res->return_code, 0, "Multiple OIDs with thresholds" );
262like($res->output, '/SNMP OK - \d+ -4 | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1:100000;2:200000 iso.3.6.1.4.1.8072.3.2.67.17=-4;-10:20;-20:30/', "Multiple OIDs with thresholds output" );
263
264$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w '1:100000,-1:2' -c '2:200000,-20:30'" );
265is($res->return_code, 1, "Multiple OIDs with thresholds" );
266like($res->output, '/SNMP WARNING - \d+ \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1:100000;2:200000 iso.3.6.1.4.1.8072.3.2.67.17=-4;-10:20;-20:30/', "Multiple OIDs with thresholds output" );
267
268$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w 1,2 -c 1" );
269is($res->return_code, 2, "Multiple OIDs with some thresholds" );
270like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" );
271
272$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19");
273is($res->return_code, 0, "Test plain .1.3.6.1.4.1.8072.3.2.67.6 RC" );
274is($res->output,'SNMP OK - 42 | iso.3.6.1.4.1.8072.3.2.67.19=42 ', "Test plain value of .1.3.6.1.4.1.8072.3.2.67.1" );
275
276$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 -M .1");
277is($res->return_code, 0, "Test multiply RC" );
278is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' , "Test multiply .1 output" );
279
280$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' ");
281is($res->return_code, 0, "Test multiply RC + format" );
282is($res->output, 'SNMP OK - 4.20 | iso.3.6.1.4.1.8072.3.2.67.19=4.20 ', "Test multiply .1 output + format" );
253 283
284$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' -w 1");
285is($res->return_code, 1, "Test multiply RC + format + thresholds" );
286is($res->output, 'SNMP WARNING - *4.20* | iso.3.6.1.4.1.8072.3.2.67.19=4.20;1 ', "Test multiply .1 output + format + thresholds" );
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl
index 0e41d575..38912e98 100644
--- a/plugins/tests/check_snmp_agent.pl
+++ b/plugins/tests/check_snmp_agent.pl
@@ -32,11 +32,11 @@ my $multilin5 = 'And now have fun with with this: "C:\\"
32because we\'re not done yet!'; 32because we\'re not done yet!';
33 33
34# Next are arrays of indexes (Type, initial value and increments) 34# Next are arrays of indexes (Type, initial value and increments)
35# 0..16 <---- please update comment when adding/removing fields 35# 0..19 <---- please update comment when adding/removing fields
36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR ); 36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER );
37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' ); 37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6', 42 );
38# undef increments are randomized 38# undef increments are randomized
39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef ); 39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef, 0 );
40 40
41# Number of elements in our OID 41# Number of elements in our OID
42my $oidelts; 42my $oidelts;
diff --git a/plugins/tests/var/ps-axwo.debian b/plugins/tests/var/ps-axwo.debian
new file mode 100644
index 00000000..5889e9a4
--- /dev/null
+++ b/plugins/tests/var/ps-axwo.debian
@@ -0,0 +1,219 @@
1STAT UID PID PPID VSZ RSS %CPU ELAPSED COMMAND COMMAND
2Ss 0 1 0 167244 7144 0.1 26-03:07:26 systemd /lib/systemd/systemd --system --deserialize 17
3S 0 2 0 0 0 0.0 26-03:07:26 kthreadd [kthreadd]
4I< 0 3 2 0 0 0.0 26-03:07:26 rcu_gp [rcu_gp]
5I< 0 4 2 0 0 0.0 26-03:07:26 rcu_par_gp [rcu_par_gp]
6I< 0 6 2 0 0 0.0 26-03:07:26 kworker/0:0H-ev [kworker/0:0H-events_highpri]
7I< 0 9 2 0 0 0.0 26-03:07:26 mm_percpu_wq [mm_percpu_wq]
8S 0 10 2 0 0 0.0 26-03:07:26 rcu_tasks_rude_ [rcu_tasks_rude_]
9S 0 11 2 0 0 0.0 26-03:07:26 rcu_tasks_trace [rcu_tasks_trace]
10S 0 12 2 0 0 0.0 26-03:07:26 ksoftirqd/0 [ksoftirqd/0]
11I 0 13 2 0 0 0.0 26-03:07:26 rcu_sched [rcu_sched]
12S 0 14 2 0 0 0.0 26-03:07:26 migration/0 [migration/0]
13S 0 15 2 0 0 0.0 26-03:07:26 cpuhp/0 [cpuhp/0]
14S 0 16 2 0 0 0.0 26-03:07:26 cpuhp/1 [cpuhp/1]
15S 0 17 2 0 0 0.0 26-03:07:26 migration/1 [migration/1]
16S 0 18 2 0 0 0.0 26-03:07:26 ksoftirqd/1 [ksoftirqd/1]
17I< 0 20 2 0 0 0.0 26-03:07:26 kworker/1:0H-ev [kworker/1:0H-events_highpri]
18S 0 21 2 0 0 0.0 26-03:07:26 cpuhp/2 [cpuhp/2]
19S 0 22 2 0 0 0.0 26-03:07:26 migration/2 [migration/2]
20S 0 23 2 0 0 0.0 26-03:07:26 ksoftirqd/2 [ksoftirqd/2]
21I< 0 25 2 0 0 0.0 26-03:07:26 kworker/2:0H-ev [kworker/2:0H-events_highpri]
22S 0 26 2 0 0 0.0 26-03:07:26 cpuhp/3 [cpuhp/3]
23S 0 27 2 0 0 0.0 26-03:07:26 migration/3 [migration/3]
24S 0 28 2 0 0 0.0 26-03:07:26 ksoftirqd/3 [ksoftirqd/3]
25I< 0 30 2 0 0 0.0 26-03:07:26 kworker/3:0H-ev [kworker/3:0H-events_highpri]
26S 0 35 2 0 0 0.0 26-03:07:26 kdevtmpfs [kdevtmpfs]
27I< 0 36 2 0 0 0.0 26-03:07:26 netns [netns]
28S 0 37 2 0 0 0.0 26-03:07:26 kauditd [kauditd]
29S 0 38 2 0 0 0.0 26-03:07:26 khungtaskd [khungtaskd]
30S 0 39 2 0 0 0.0 26-03:07:26 oom_reaper [oom_reaper]
31I< 0 40 2 0 0 0.0 26-03:07:26 writeback [writeback]
32S 0 41 2 0 0 0.0 26-03:07:26 kcompactd0 [kcompactd0]
33SN 0 42 2 0 0 0.0 26-03:07:26 ksmd [ksmd]
34SN 0 43 2 0 0 0.0 26-03:07:26 khugepaged [khugepaged]
35I< 0 62 2 0 0 0.0 26-03:07:26 kintegrityd [kintegrityd]
36I< 0 63 2 0 0 0.0 26-03:07:26 kblockd [kblockd]
37I< 0 64 2 0 0 0.0 26-03:07:26 blkcg_punt_bio [blkcg_punt_bio]
38I< 0 65 2 0 0 0.0 26-03:07:26 edac-poller [edac-poller]
39I< 0 66 2 0 0 0.0 26-03:07:26 devfreq_wq [devfreq_wq]
40I< 0 67 2 0 0 0.0 26-03:07:26 kworker/2:1H-ev [kworker/2:1H-events_highpri]
41S 0 70 2 0 0 0.3 26-03:07:25 kswapd0 [kswapd0]
42I< 0 71 2 0 0 0.0 26-03:07:25 kthrotld [kthrotld]
43I< 0 72 2 0 0 0.0 26-03:07:25 acpi_thermal_pm [acpi_thermal_pm]
44I< 0 74 2 0 0 0.0 26-03:07:25 ipv6_addrconf [ipv6_addrconf]
45I< 0 80 2 0 0 0.0 26-03:07:25 kworker/3:1H-ev [kworker/3:1H-events_highpri]
46I< 0 84 2 0 0 0.0 26-03:07:25 kstrp [kstrp]
47I< 0 87 2 0 0 0.0 26-03:07:25 zswap-shrink [zswap-shrink]
48I< 0 110 2 0 0 0.0 26-03:07:25 kworker/0:1H-ev [kworker/0:1H-events_highpri]
49I< 0 141 2 0 0 0.0 26-03:07:25 ata_sff [ata_sff]
50S 0 143 2 0 0 0.0 26-03:07:25 scsi_eh_0 [scsi_eh_0]
51I< 0 144 2 0 0 0.0 26-03:07:25 scsi_tmf_0 [scsi_tmf_0]
52S 0 145 2 0 0 0.0 26-03:07:25 scsi_eh_1 [scsi_eh_1]
53I< 0 146 2 0 0 0.0 26-03:07:25 scsi_tmf_1 [scsi_tmf_1]
54S 0 147 2 0 0 0.0 26-03:07:25 scsi_eh_2 [scsi_eh_2]
55I< 0 148 2 0 0 0.0 26-03:07:25 scsi_tmf_2 [scsi_tmf_2]
56S 0 149 2 0 0 0.0 26-03:07:25 scsi_eh_3 [scsi_eh_3]
57I< 0 150 2 0 0 0.0 26-03:07:25 scsi_tmf_3 [scsi_tmf_3]
58S 0 151 2 0 0 0.0 26-03:07:25 scsi_eh_4 [scsi_eh_4]
59I< 0 152 2 0 0 0.0 26-03:07:25 scsi_tmf_4 [scsi_tmf_4]
60S 0 153 2 0 0 0.0 26-03:07:25 scsi_eh_5 [scsi_eh_5]
61I< 0 154 2 0 0 0.0 26-03:07:25 scsi_tmf_5 [scsi_tmf_5]
62S 0 158 2 0 0 0.0 26-03:07:25 card0-crtc0 [card0-crtc0]
63S 0 159 2 0 0 0.0 26-03:07:25 card0-crtc1 [card0-crtc1]
64S 0 160 2 0 0 0.0 26-03:07:25 card0-crtc2 [card0-crtc2]
65I< 0 162 2 0 0 0.0 26-03:07:25 kworker/1:1H-ev [kworker/1:1H-events_highpri]
66S 0 163 2 0 0 0.0 26-03:07:25 scsi_eh_6 [scsi_eh_6]
67I< 0 164 2 0 0 0.0 26-03:07:25 scsi_tmf_6 [scsi_tmf_6]
68S 0 165 2 0 0 0.0 26-03:07:25 usb-storage [usb-storage]
69I< 0 167 2 0 0 0.0 26-03:07:25 uas [uas]
70I< 0 176 2 0 0 0.0 26-03:07:25 kdmflush [kdmflush]
71I< 0 177 2 0 0 0.0 26-03:07:25 kdmflush [kdmflush]
72S 0 202 2 0 0 0.0 26-03:07:24 scsi_eh_7 [scsi_eh_7]
73I< 0 203 2 0 0 0.0 26-03:07:24 scsi_tmf_7 [scsi_tmf_7]
74S 0 204 2 0 0 0.0 26-03:07:24 usb-storage [usb-storage]
75I< 0 232 2 0 0 0.0 26-03:07:23 btrfs-worker [btrfs-worker]
76I< 0 233 2 0 0 0.0 26-03:07:23 btrfs-worker-hi [btrfs-worker-hi]
77I< 0 234 2 0 0 0.0 26-03:07:23 btrfs-delalloc [btrfs-delalloc]
78I< 0 235 2 0 0 0.0 26-03:07:23 btrfs-flush_del [btrfs-flush_del]
79I< 0 236 2 0 0 0.0 26-03:07:23 btrfs-cache [btrfs-cache]
80I< 0 237 2 0 0 0.0 26-03:07:23 btrfs-fixup [btrfs-fixup]
81I< 0 238 2 0 0 0.0 26-03:07:23 btrfs-endio [btrfs-endio]
82I< 0 239 2 0 0 0.0 26-03:07:23 btrfs-endio-met [btrfs-endio-met]
83I< 0 240 2 0 0 0.0 26-03:07:23 btrfs-endio-met [btrfs-endio-met]
84I< 0 241 2 0 0 0.0 26-03:07:23 btrfs-endio-rai [btrfs-endio-rai]
85I< 0 242 2 0 0 0.0 26-03:07:23 btrfs-rmw [btrfs-rmw]
86I< 0 243 2 0 0 0.0 26-03:07:23 btrfs-endio-wri [btrfs-endio-wri]
87I< 0 244 2 0 0 0.0 26-03:07:23 btrfs-freespace [btrfs-freespace]
88I< 0 245 2 0 0 0.0 26-03:07:23 btrfs-delayed-m [btrfs-delayed-m]
89I< 0 246 2 0 0 0.0 26-03:07:23 btrfs-readahead [btrfs-readahead]
90I< 0 247 2 0 0 0.0 26-03:07:23 btrfs-qgroup-re [btrfs-qgroup-re]
91S 0 248 2 0 0 0.0 26-03:07:23 btrfs-cleaner [btrfs-cleaner]
92S 0 249 2 0 0 0.2 26-03:07:23 btrfs-transacti [btrfs-transacti]
93I< 0 317 2 0 0 0.0 26-03:07:22 rpciod [rpciod]
94I< 0 322 2 0 0 0.0 26-03:07:22 xprtiod [xprtiod]
95S 0 381 2 0 0 0.0 26-03:07:22 irq/133-mei_me [irq/133-mei_me]
96S 0 422 2 0 0 0.0 26-03:07:22 watchdogd [watchdogd]
97I< 0 523 2 0 0 0.0 26-03:07:22 led_workqueue [led_workqueue]
98I< 0 583 2 0 0 0.0 26-03:07:22 cryptd [cryptd]
99I< 0 590 2 0 0 0.0 26-03:07:22 ext4-rsv-conver [ext4-rsv-conver]
100Ss 104 693 1 12324 4292 0.5 26-03:07:21 dbus-daemon /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
101Ss 0 731 1 575120 1368 0.0 26-03:07:21 systemd-logind /lib/systemd/systemd-logind
102Ssl 0 1111 1 121248 732 0.0 26-03:07:18 unattended-upgr /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
103S 0 1141 2 0 0 0.0 26-03:07:18 lockd [lockd]
104I< 0 1459 2 0 0 0.0 26-03:07:16 nfsiod [nfsiod]
105S 0 1621 2 0 0 0.0 26-03:07:15 NFSv4 callback [NFSv4 callback]
106Ssl 0 1771 1 1548340 676 0.0 26-03:07:13 libvirtd /usr/sbin/libvirtd
107I< 0 24315 2 0 0 0.0 26-02:49:02 cifsiod [cifsiod]
108I< 0 24316 2 0 0 0.0 26-02:49:02 smb3decryptd [smb3decryptd]
109I< 0 24317 2 0 0 0.0 26-02:49:02 cifsfileinfoput [cifsfileinfoput]
110I< 0 24318 2 0 0 0.0 26-02:49:02 cifsoplockd [cifsoplockd]
111I< 0 24319 2 0 0 0.0 26-02:49:02 cifs-dfscache [cifs-dfscache]
112S 0 24322 2 0 0 0.0 26-02:49:02 cifsd [cifsd]
113I< 0 24413 2 0 0 0.0 26-02:48:57 btrfs-worker [btrfs-worker]
114I< 0 24414 2 0 0 0.0 26-02:48:57 btrfs-worker-hi [btrfs-worker-hi]
115I< 0 24415 2 0 0 0.0 26-02:48:57 btrfs-delalloc [btrfs-delalloc]
116I< 0 24416 2 0 0 0.0 26-02:48:57 btrfs-flush_del [btrfs-flush_del]
117I< 0 24418 2 0 0 0.0 26-02:48:57 btrfs-cache [btrfs-cache]
118I< 0 24419 2 0 0 0.0 26-02:48:57 btrfs-fixup [btrfs-fixup]
119I< 0 24420 2 0 0 0.0 26-02:48:57 btrfs-endio [btrfs-endio]
120I< 0 24421 2 0 0 0.0 26-02:48:57 btrfs-endio-met [btrfs-endio-met]
121I< 0 24422 2 0 0 0.0 26-02:48:57 btrfs-endio-met [btrfs-endio-met]
122I< 0 24423 2 0 0 0.0 26-02:48:57 btrfs-endio-rai [btrfs-endio-rai]
123I< 0 24424 2 0 0 0.0 26-02:48:57 btrfs-rmw [btrfs-rmw]
124I< 0 24425 2 0 0 0.0 26-02:48:57 btrfs-endio-wri [btrfs-endio-wri]
125I< 0 24426 2 0 0 0.0 26-02:48:57 btrfs-freespace [btrfs-freespace]
126I< 0 24427 2 0 0 0.0 26-02:48:57 btrfs-delayed-m [btrfs-delayed-m]
127I< 0 24428 2 0 0 0.0 26-02:48:57 btrfs-readahead [btrfs-readahead]
128I< 0 24429 2 0 0 0.0 26-02:48:57 btrfs-qgroup-re [btrfs-qgroup-re]
129S 0 24450 2 0 0 0.0 26-02:48:53 btrfs-cleaner [btrfs-cleaner]
130S 0 24451 2 0 0 0.0 26-02:48:53 btrfs-transacti [btrfs-transacti]
131I< 0 747708 2 0 0 0.0 16-21:06:20 xfsalloc [xfsalloc]
132I< 0 747709 2 0 0 0.0 16-21:06:20 xfs_mru_cache [xfs_mru_cache]
133S 0 747713 2 0 0 0.0 16-21:06:20 jfsIO [jfsIO]
134S 0 747714 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
135S 0 747715 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
136S 0 747716 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
137S 0 747717 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
138S 0 747718 2 0 0 0.0 16-21:06:20 jfsSync [jfsSync]
139Ss 0 1071687 1 105976 28304 0.0 3-03:12:31 systemd-journal /lib/systemd/systemd-journald
140Ss 0 1934146 1 25672 4704 0.0 11:19:31 cupsd /usr/sbin/cupsd -l
141Ssl 0 1934148 1 182868 8540 0.0 11:19:31 cups-browsed /usr/sbin/cups-browsed
142S 13 1934155 3392655 5752 88 0.0 11:19:31 pinger (pinger)
143S< 33 1934166 3393034 57996 5460 0.0 11:19:31 apache2 /usr/sbin/apache2 -k start
144S< 33 1934167 3393034 216944 13892 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
145S< 33 1934168 3393034 216944 13756 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
146S< 33 1934169 3393034 216936 13732 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
147S< 33 1934170 3393034 216944 13888 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
148S< 33 1934172 3393034 216944 15388 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
149S< 33 1934701 3393034 216936 13736 0.0 11:19:29 apache2 /usr/sbin/apache2 -k start
150S< 33 1935056 3393034 216920 13724 0.0 11:19:28 apache2 /usr/sbin/apache2 -k start
151S 7 1936834 1934146 16652 832 0.0 11:18:12 dbus /usr/lib/cups/notifier/dbus dbus://
152S< 33 1955909 3393034 216928 13792 0.0 11:00:25 apache2 /usr/sbin/apache2 -k start
153I< 0 2531464 2 0 0 0.0 06:35:47 kworker/u9:0-i9 [kworker/u9:0-i915_flip]
154I 0 2570506 2 0 0 0.0 06:27:41 kworker/1:0-cgr [kworker/1:0-cgroup_destroy]
155I 0 2596195 2 0 0 0.0 06:21:52 kworker/1:1-eve [kworker/1:1-events]
156I 0 2785341 2 0 0 0.0 03:34:16 kworker/u8:8-bt [kworker/u8:8-btrfs-endio-write]
157I 0 2785520 2 0 0 0.0 03:33:50 kworker/3:0-eve [kworker/3:0-events]
158I 0 2798669 2 0 0 0.0 03:21:09 kworker/u8:5-bt [kworker/u8:5-btrfs-endio-write]
159Ss 0 2803015 1 5616 3108 0.0 03:17:54 cron /usr/sbin/cron -f
160I 0 2845483 2 0 0 0.0 02:38:11 kworker/0:3-eve [kworker/0:3-events]
161I 0 2939490 2 0 0 0.1 01:10:32 kworker/0:0-eve [kworker/0:0-events]
162I 0 2939754 2 0 0 0.0 01:10:26 kworker/u8:1-i9 [kworker/u8:1-i915]
163I 0 2942040 2 0 0 0.0 01:08:02 kworker/u8:7-bt [kworker/u8:7-btrfs-endio-meta]
164S 117 2954268 3392551 40044 5772 0.0 56:37 pickup pickup -l -t unix -u -c
165I 0 2965195 2 0 0 0.0 46:00 kworker/u8:0-bt [kworker/u8:0-btrfs-worker]
166I 0 2977972 2 0 0 0.0 33:54 kworker/u8:2-bt [kworker/u8:2-btrfs-endio-write]
167I 0 2985488 2 0 0 0.0 27:02 kworker/u8:3-bl [kworker/u8:3-blkcg_punt_bio]
168I 0 2987519 2 0 0 1.0 25:15 kworker/2:1-eve [kworker/2:1-events]
169I 0 2987601 2 0 0 0.0 25:03 kworker/u8:9-i9 [kworker/u8:9-i915]
170I< 0 2995218 2 0 0 0.0 18:41 kworker/u9:2-xp [kworker/u9:2-xprtiod]
171I 0 2997170 2 0 0 0.0 16:41 kworker/3:1-rcu [kworker/3:1-rcu_gp]
172I 0 3001264 2 0 0 0.0 13:01 kworker/u8:4-bt [kworker/u8:4-btrfs-endio-write]
173I 0 3004697 2 0 0 0.7 09:41 kworker/2:0-eve [kworker/2:0-events]
174I 0 3010619 2 0 0 1.0 04:29 kworker/2:2-eve [kworker/2:2-events]
175I 0 3014612 2 0 0 0.0 00:41 kworker/3:2-eve [kworker/3:2-events]
176S 0 3015082 2803015 6716 3028 0.0 00:30 cron /usr/sbin/CRON -f
177I 0 3015382 2 0 0 0.0 00:00 kworker/u8:6-bt [kworker/u8:6-btrfs-endio-meta]
178Ss 1 3392068 1 5592 504 0.0 15-02:34:39 atd /usr/sbin/atd -f
179Ssl 0 3392072 1 235796 1740 0.0 15-02:34:39 accounts-daemon /usr/libexec/accounts-daemon
180Ssl 106 3392076 1 315708 6128 0.0 15-02:34:39 colord /usr/libexec/colord
181Ss 0 3392083 1 8120 720 0.0 15-02:34:39 haveged /usr/sbin/haveged --Foreground --verbose=1
182Ss 0 3392090 1 5168 132 0.0 15-02:34:39 blkmapd /usr/sbin/blkmapd
183SNsl 111 3392094 1 155648 440 0.0 15-02:34:39 rtkit-daemon /usr/libexec/rtkit-daemon
184Ssl 0 3392097 1 290168 1352 0.0 15-02:34:39 packagekitd /usr/libexec/packagekitd
185Ss 128 3392100 1 7960 448 0.0 15-02:34:39 rpcbind /sbin/rpcbind -f -w
186Ss 0 3392114 1 13432 616 0.0 15-02:34:39 systemd-machine /lib/systemd/systemd-machined
187Ss 0 3392118 1 13316 848 0.0 15-02:34:39 sshd sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
188Ssl 0 3392124 1 244072 2456 0.0 15-02:34:39 upowerd /usr/libexec/upowerd
189Ssl 0 3392138 1 1634748 10684 0.0 15-02:34:39 containerd /usr/bin/containerd
190Ssl 0 3392139 1 222768 1784 0.0 15-02:34:39 rsyslogd /usr/sbin/rsyslogd -n -iNONE
191Ss 13 3392140 1 3344 152 0.0 15-02:34:39 polipo /usr/bin/polipo -c /etc/polipo/config pidFile=/var/run/polipo/polipo.pid daemonise=true
192Ssl 119 3392156 1 76472 1688 0.0 15-02:34:39 ntpd /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 119:126
193Ss 120 3392168 1 4656 276 0.0 15-02:34:39 rpc.statd /sbin/rpc.statd --no-notify
194Ss 0 3392171 1 5072 432 0.0 15-02:34:39 rpc.mountd /usr/sbin/rpc.mountd --manage-gids
195Ss 0 3392176 1 5008 288 0.0 15-02:34:39 rpc.idmapd /usr/sbin/rpc.idmapd
196Ss 105 3392184 1 15544 6816 3.5 15-02:34:39 avahi-daemon avahi-daemon: running [tsui.local]
197Ss 0 3392186 1 25288 3860 0.0 15-02:34:39 systemd-udevd /lib/systemd/systemd-udevd
198S 105 3392190 3392184 8788 52 0.0 15-02:34:39 avahi-daemon avahi-daemon: chroot helper
199Ssl 0 3392197 1 396120 4188 0.0 15-02:34:39 udisksd /usr/libexec/udisks2/udisksd
200Ssl 0 3392214 1 237504 6632 0.0 15-02:34:39 polkitd /usr/libexec/polkitd --no-debug
201Ss 0 3392284 1 9684 560 0.0 15-02:34:38 xinetd /usr/sbin/xinetd -pidfile /run/xinetd.pid -stayalive -inetd_compat -inetd_ipv6
202Ssl 0 3392285 1 314840 1352 0.0 15-02:34:38 ModemManager /usr/sbin/ModemManager
203Ss 0 3392317 1 2352 140 0.0 15-02:34:38 acpid /usr/sbin/acpid
204S 0 3392400 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
205S 0 3392401 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
206S 0 3392402 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
207S 0 3392403 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
208S 0 3392404 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
209S 0 3392405 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
210S 0 3392407 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
211S 0 3392410 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
212Ss 0 3392551 1 40092 1304 0.0 15-02:34:37 master /usr/lib/postfix/sbin/master -w
213S 117 3392553 3392551 40156 568 0.0 15-02:34:37 qmgr qmgr -l -t unix -u
214Ss 0 3392650 1 63652 4 0.0 15-02:34:36 squid /usr/sbin/squid --foreground -sYC
215Ssl 116 3392652 1 1675196 93848 0.0 15-02:34:36 mariadbd /usr/sbin/mariadbd
216S 13 3392655 3392650 81776 21232 0.0 15-02:34:36 squid (squid-1) --kid squid-1 --foreground -sYC
217S 13 3392657 3392655 5572 68 0.0 15-02:34:36 log_file_daemon (logfile-daemon) /var/log/squid/access.log
218S<s 0 3393034 1 216648 7560 0.0 15-02:34:34 apache2 /usr/sbin/apache2 -k start
219Ss 33 3393037 1 3432 180 0.0 15-02:34:34 htcacheclean /usr/bin/htcacheclean -d 120 -p /var/cache/apache2/mod_cache_disk -l 300M -n
diff --git a/plugins/tests/var/ps_axwo.debian b/plugins/tests/var/ps_axwo.debian
deleted file mode 100644
index 37a2d35e..00000000
--- a/plugins/tests/var/ps_axwo.debian
+++ /dev/null
@@ -1,84 +0,0 @@
1STAT UID PID PPID VSZ RSS %CPU COMMAND COMMAND
2S 0 1 0 1504 428 0.0 init init [2]
3SN 0 2 1 0 0 0.0 ksoftirqd/0 [ksoftirqd/0]
4S< 0 3 1 0 0 0.0 events/0 [events/0]
5S< 0 4 3 0 0 0.0 khelper [khelper]
6S< 0 5 3 0 0 0.0 kacpid [kacpid]
7S< 0 38 3 0 0 0.0 kblockd/0 [kblockd/0]
8S 0 48 3 0 0 0.0 pdflush [pdflush]
9S< 0 51 3 0 0 0.0 aio/0 [aio/0]
10S 0 50 1 0 0 0.0 kswapd0 [kswapd0]
11S 0 193 1 0 0 0.0 kseriod [kseriod]
12S 0 214 1 0 0 0.0 scsi_eh_0 [scsi_eh_0]
13S 0 221 1 0 0 0.0 khubd [khubd]
14S 0 299 1 0 0 0.3 kjournald [kjournald]
15S 0 1148 1 0 0 0.0 pciehpd_event [pciehpd_event]
16S 0 1168 1 0 0 0.0 shpchpd_event [shpchpd_event]
17Ss 1 1795 1 1612 276 0.0 portmap /sbin/portmap
18Ss 0 2200 1 1652 568 0.0 vmware-guestd /usr/sbin/vmware-guestd --background /var/run/vmware-guestd.pid
19Ss 0 2209 1 2240 532 0.0 inetd /usr/sbin/inetd
20Ss 0 2319 1 3468 792 0.0 sshd /usr/sbin/sshd
21Ss 0 2323 1 2468 676 0.0 rpc.statd /sbin/rpc.statd
22Ss 1 2332 1 1684 488 0.0 atd /usr/sbin/atd
23Ss 0 2335 1 1764 636 0.0 cron /usr/sbin/cron
24Ss+ 0 2350 1 1500 348 0.0 getty /sbin/getty 38400 tty1
25Ss+ 0 2351 1 1500 348 0.0 getty /sbin/getty 38400 tty2
26Ss+ 0 2352 1 1500 348 0.0 getty /sbin/getty 38400 tty3
27Ss+ 0 2353 1 1500 348 0.0 getty /sbin/getty 38400 tty4
28Ss+ 0 2354 1 1500 348 0.0 getty /sbin/getty 38400 tty5
29Ss+ 0 2355 1 1500 348 0.0 getty /sbin/getty 38400 tty6
30S 0 6907 1 2308 892 0.0 mysqld_safe /bin/sh /usr/bin/mysqld_safe
31S 103 6944 6907 123220 27724 0.0 mysqld /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
32S 0 6945 6907 1488 420 0.0 logger logger -p daemon.err -t mysqld_safe -i -t mysqld
33S 1001 17778 1 6436 1588 0.0 snmpd /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid
34Ss 0 17789 1 9496 5556 0.0 snmptrapd /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/monitoring/snmp/load -p /var/run/snmptrapd.pid
35Ss 0 847 2319 14452 1752 0.0 sshd sshd: tonvoon [priv]
36S 1000 857 847 14616 1832 0.0 sshd sshd: tonvoon@pts/3
37Ss 1000 860 857 2984 1620 0.0 bash -bash
38S 0 868 860 2588 1428 0.0 bash -su
39S+ 1001 877 868 2652 1568 0.0 bash -su
40S 0 6086 3 0 0 0.0 pdflush [pdflush]
41Ss 0 17832 2319 14452 1752 0.0 sshd sshd: tonvoon [priv]
42S 1000 18155 17832 14620 1840 0.0 sshd sshd: tonvoon@pts/0
43Ss 1000 18156 18155 2984 1620 0.0 bash -bash
44S 0 18518 18156 2588 1428 0.0 bash -su
45S 1001 18955 18518 2672 1600 0.0 bash -su
46Ss 0 21683 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
47S 1000 21742 21683 14620 1896 0.0 sshd sshd: tonvoon@pts/1
48Ss 1000 21743 21742 2984 1620 0.0 bash -bash
49S 0 21748 21743 2592 1432 0.0 bash -su
50S 1001 21757 21748 2620 1540 0.0 bash -su
51Ss 0 2334 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
52S 1000 2343 2334 14620 1840 0.0 sshd sshd: tonvoon@pts/2
53Ss 1000 2344 2343 2984 1620 0.0 bash -bash
54S 0 2349 2344 2592 1432 0.0 bash -su
55S+ 1001 2364 2349 2620 1520 0.0 bash -su
56T 1001 2454 2364 2096 1032 0.0 vi vi configure.in.rej
57S+ 1001 8500 21757 69604 52576 0.0 opsview_web_ser /usr/bin/perl -w ./script/opsview_web_server.pl -f -d
58Ss 0 7609 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
59S 1000 7617 7609 14460 1828 0.0 sshd sshd: tonvoon@pts/4
60Ss 1000 7618 7617 2984 1620 0.0 bash -bash
61S 0 7623 7618 2592 1432 0.0 bash -su
62S+ 1001 7632 7623 2620 1528 0.0 bash -su
63Ss 1001 12678 1 20784 17728 0.0 opsviewd opsviewd
64Ss 0 832 1 14512 6360 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
65S 33 842 832 14648 6596 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
66S 33 843 832 14512 6504 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
67S 33 844 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
68S 33 845 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
69S 33 846 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
70Ss 7 4081 1 2464 884 0.0 lpd /usr/sbin/lpd -s
71S 33 26484 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
72Ss 1001 22324 1 20252 1612 0.1 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
73Ss 0 23336 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
74S 1000 23339 23336 14620 1840 0.0 sshd sshd: tonvoon@pts/5
75Ss 1000 23340 23339 2996 1636 0.0 bash -bash
76S 0 23367 23340 3020 1628 0.0 bash bash
77S 1001 23370 23367 3064 1748 0.0 bash bash
78Ss 1001 23783 1 3220 764 0.0 ndo2db /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
79Ss 1001 23784 1 6428 4948 0.0 import_ndologsd import_ndologsd
80S+ 1001 9803 18955 4132 1936 0.0 ssh ssh altinity@cube02.lei.altinity
81S 1001 22505 22324 20256 1616 0.0 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
82S 1001 22506 22505 1676 608 0.0 check_ping /usr/local/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1
83S 1001 22507 22506 1660 492 0.0 ping /bin/ping -n -U -w 10 -c 1 192.168.10.23
84R+ 1001 22508 23370 2308 680 0.0 ps ps axwo stat uid pid ppid vsz rss pcpu comm args
diff --git a/plugins/utils.c b/plugins/utils.c
index a864e4aa..71c0bdd8 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -27,6 +27,8 @@
27#include "utils_base.h" 27#include "utils_base.h"
28#include <stdarg.h> 28#include <stdarg.h>
29#include <limits.h> 29#include <limits.h>
30#include <string.h>
31#include <errno.h>
30 32
31#include <arpa/inet.h> 33#include <arpa/inet.h>
32 34
@@ -36,9 +38,6 @@ extern const char *progname;
36#define STRLEN 64 38#define STRLEN 64
37#define TXTBLK 128 39#define TXTBLK 128
38 40
39unsigned int timeout_state = STATE_CRITICAL;
40unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
41
42time_t start_time, end_time; 41time_t start_time, end_time;
43 42
44/* ************************************************************************** 43/* **************************************************************************
@@ -148,33 +147,6 @@ print_revision (const char *command_name, const char *revision)
148 command_name, revision, PACKAGE, VERSION); 147 command_name, revision, PACKAGE, VERSION);
149} 148}
150 149
151const char *
152state_text (int result)
153{
154 switch (result) {
155 case STATE_OK:
156 return "OK";
157 case STATE_WARNING:
158 return "WARNING";
159 case STATE_CRITICAL:
160 return "CRITICAL";
161 case STATE_DEPENDENT:
162 return "DEPENDENT";
163 default:
164 return "UNKNOWN";
165 }
166}
167
168void
169timeout_alarm_handler (int signo)
170{
171 if (signo == SIGALRM) {
172 printf (_("%s - Plugin timed out after %d seconds\n"),
173 state_text(timeout_state), timeout_interval);
174 exit (timeout_state);
175 }
176}
177
178int 150int
179is_numeric (char *number) 151is_numeric (char *number)
180{ 152{
@@ -269,6 +241,46 @@ is_intnonneg (char *number)
269 return FALSE; 241 return FALSE;
270} 242}
271 243
244/*
245 * Checks whether the number in the string _number_ can be put inside a int64_t
246 * On success the number will be written to the _target_ address, if _target_ is not set
247 * to NULL.
248 */
249int is_int64(char *number, int64_t *target) {
250 errno = 0;
251 uint64_t tmp = strtoll(number, NULL, 10);
252 if (errno != 0) {
253 return 0;
254 }
255 if (tmp < INT64_MIN || tmp > INT64_MAX) {
256 return 0;
257 }
258 if (target != NULL) {
259 *target = tmp;
260 }
261 return 1;
262}
263
264/*
265 * Checks whether the number in the string _number_ can be put inside a uint64_t
266 * On success the number will be written to the _target_ address, if _target_ is not set
267 * to NULL.
268 */
269int is_uint64(char *number, uint64_t *target) {
270 errno = 0;
271 uint64_t tmp = strtoll(number, NULL, 10);
272 if (errno != 0) {
273 return 0;
274 }
275 if (tmp < 0 || tmp > UINT64_MAX) {
276 return 0;
277 }
278 if (target != NULL) {
279 *target = tmp;
280 }
281 return 1;
282}
283
272int 284int
273is_intpercent (char *number) 285is_intpercent (char *number)
274{ 286{
@@ -577,10 +589,94 @@ char *perfdata (const char *label,
577 xasprintf (&data, "%s;", data); 589 xasprintf (&data, "%s;", data);
578 590
579 if (minp) 591 if (minp)
580 xasprintf (&data, "%s%ld", data, minv); 592 xasprintf (&data, "%s%ld;", data, minv);
593 else
594 xasprintf (&data, "%s;", data);
595
596 if (maxp)
597 xasprintf (&data, "%s%ld", data, maxv);
598
599 return data;
600}
601
602
603char *perfdata_uint64 (const char *label,
604 uint64_t val,
605 const char *uom,
606 int warnp, /* Warning present */
607 uint64_t warn,
608 int critp, /* Critical present */
609 uint64_t crit,
610 int minp, /* Minimum present */
611 uint64_t minv,
612 int maxp, /* Maximum present */
613 uint64_t maxv)
614{
615 char *data = NULL;
616
617 if (strpbrk (label, "'= "))
618 xasprintf (&data, "'%s'=%" PRIu64 "%s;", label, val, uom);
619 else
620 xasprintf (&data, "%s=%" PRIu64 "%s;", label, val, uom);
621
622 if (warnp)
623 xasprintf (&data, "%s%" PRIu64 ";", data, warn);
624 else
625 xasprintf (&data, "%s;", data);
626
627 if (critp)
628 xasprintf (&data, "%s%" PRIu64 ";", data, crit);
629 else
630 xasprintf (&data, "%s;", data);
631
632 if (minp)
633 xasprintf (&data, "%s%" PRIu64 ";", data, minv);
634 else
635 xasprintf (&data, "%s;", data);
636
637 if (maxp)
638 xasprintf (&data, "%s%" PRIu64, data, maxv);
639
640 return data;
641}
642
643
644char *perfdata_int64 (const char *label,
645 int64_t val,
646 const char *uom,
647 int warnp, /* Warning present */
648 int64_t warn,
649 int critp, /* Critical present */
650 int64_t crit,
651 int minp, /* Minimum present */
652 int64_t minv,
653 int maxp, /* Maximum present */
654 int64_t maxv)
655{
656 char *data = NULL;
657
658 if (strpbrk (label, "'= "))
659 xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
660 else
661 xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
662
663 if (warnp)
664 xasprintf (&data, "%s%" PRId64 ";", data, warn);
665 else
666 xasprintf (&data, "%s;", data);
667
668 if (critp)
669 xasprintf (&data, "%s%" PRId64 ";", data, crit);
670 else
671 xasprintf (&data, "%s;", data);
672
673 if (minp)
674 xasprintf (&data, "%s%" PRId64 ";", data, minv);
675 else
676 xasprintf (&data, "%s;", data);
581 677
582 if (maxp) 678 if (maxp)
583 xasprintf (&data, "%s;%ld", data, maxv); 679 xasprintf (&data, "%s%" PRId64, data, maxv);
584 680
585 return data; 681 return data;
586} 682}
@@ -668,3 +764,43 @@ char *sperfdata (const char *label,
668 764
669 return data; 765 return data;
670} 766}
767
768char *sperfdata_int (const char *label,
769 int val,
770 const char *uom,
771 char *warn,
772 char *crit,
773 int minp,
774 int minv,
775 int maxp,
776 int maxv)
777{
778 char *data = NULL;
779 if (strpbrk (label, "'= "))
780 xasprintf (&data, "'%s'=", label);
781 else
782 xasprintf (&data, "%s=", label);
783
784 xasprintf (&data, "%s%d", data, val);
785 xasprintf (&data, "%s%s;", data, uom);
786
787 if (warn!=NULL)
788 xasprintf (&data, "%s%s", data, warn);
789
790 xasprintf (&data, "%s;", data);
791
792 if (crit!=NULL)
793 xasprintf (&data, "%s%s", data, crit);
794
795 xasprintf (&data, "%s;", data);
796
797 if (minp)
798 xasprintf (&data, "%s%d", data, minv);
799
800 if (maxp) {
801 xasprintf (&data, "%s;", data);
802 xasprintf (&data, "%s%d", data, maxv);
803 }
804
805 return data;
806}
diff --git a/plugins/utils.h b/plugins/utils.h
index 4c4aaccc..cb979ce7 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -7,7 +7,7 @@
7/* The purpose of this package is to provide safer alternatives to C 7/* The purpose of this package is to provide safer alternatives to C
8functions that might otherwise be vulnerable to hacking. This 8functions that might otherwise be vulnerable to hacking. This
9currently includes a standard suite of validation routines to be sure 9currently includes a standard suite of validation routines to be sure
10that an string argument acually converts to its intended type and a 10that an string argument actually converts to its intended type and a
11suite of string handling routine that do their own memory management 11suite of string handling routine that do their own memory management
12in order to resist overflow attacks. In addition, a few functions are 12in order to resist overflow attacks. In addition, a few functions are
13provided to standardize version and error reporting across the entire 13provided to standardize version and error reporting across the entire
@@ -16,6 +16,7 @@ suite of plugins. */
16/* now some functions etc are being defined in ../lib/utils_base.c */ 16/* now some functions etc are being defined in ../lib/utils_base.c */
17#include "utils_base.h" 17#include "utils_base.h"
18 18
19
19#ifdef NP_EXTRA_OPTS 20#ifdef NP_EXTRA_OPTS
20/* Include extra-opts functions if compiled in */ 21/* Include extra-opts functions if compiled in */
21#include "extra_opts.h" 22#include "extra_opts.h"
@@ -29,13 +30,6 @@ suite of plugins. */
29void support (void); 30void support (void);
30void print_revision (const char *, const char *); 31void print_revision (const char *, const char *);
31 32
32/* Handle timeouts */
33
34extern unsigned int timeout_state;
35extern unsigned int timeout_interval;
36
37RETSIGTYPE timeout_alarm_handler (int);
38
39extern time_t start_time, end_time; 33extern time_t start_time, end_time;
40 34
41/* Test input types */ 35/* Test input types */
@@ -45,6 +39,8 @@ int is_intpos (char *);
45int is_intneg (char *); 39int is_intneg (char *);
46int is_intnonneg (char *); 40int is_intnonneg (char *);
47int is_intpercent (char *); 41int is_intpercent (char *);
42int is_uint64(char *number, uint64_t *target);
43int is_int64(char *number, int64_t *target);
48 44
49int is_numeric (char *); 45int is_numeric (char *);
50int is_positive (char *); 46int is_positive (char *);
@@ -89,34 +85,26 @@ void usage4(const char *) __attribute__((noreturn));
89void usage5(void) __attribute__((noreturn)); 85void usage5(void) __attribute__((noreturn));
90void usage_va(const char *fmt, ...) __attribute__((noreturn)); 86void usage_va(const char *fmt, ...) __attribute__((noreturn));
91 87
92const char *state_text (int);
93
94#define max(a,b) (((a)>(b))?(a):(b)) 88#define max(a,b) (((a)>(b))?(a):(b))
95#define min(a,b) (((a)<(b))?(a):(b)) 89#define min(a,b) (((a)<(b))?(a):(b))
96 90
97char *perfdata (const char *, 91char *perfdata (const char *, long int, const char *, int, long int,
98 long int, 92 int, long int, int, long int, int, long int);
99 const char *, 93
100 int, 94char *perfdata_uint64 (const char *, uint64_t , const char *, int, uint64_t,
101 long int, 95 int, uint64_t, int, uint64_t, int, uint64_t);
102 int, 96
103 long int, 97char *perfdata_int64 (const char *, int64_t, const char *, int, int64_t,
104 int, 98 int, int64_t, int, int64_t, int, int64_t);
105 long int, 99
106 int, 100char *fperfdata (const char *, double, const char *, int, double,
107 long int); 101 int, double, int, double, int, double);
108 102
109char *fperfdata (const char *, 103char *sperfdata (const char *, double, const char *, char *, char *,
110 double, 104 int, double, int, double);
111 const char *, 105
112 int, 106char *sperfdata_int (const char *, int, const char *, char *, char *,
113 double, 107 int, int, int, int);
114 int,
115 double,
116 int,
117 double,
118 int,
119 double);
120 108
121/* The idea here is that, although not every plugin will use all of these, 109/* The idea here is that, although not every plugin will use all of these,
122 most will or should. Therefore, for consistency, these very common 110 most will or should. Therefore, for consistency, these very common
diff --git a/po/Makevars b/po/Makevars
index 1bf1e0db..b35f5adc 100644
--- a/po/Makevars
+++ b/po/Makevars
@@ -8,7 +8,7 @@ subdir = po
8top_builddir = .. 8top_builddir = ..
9 9
10# These options get passed to xgettext. 10# These options get passed to xgettext.
11XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format 11XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format --no-location
12 12
13# This is the copyright holder that gets inserted into the header of the 13# This is the copyright holder that gets inserted into the header of the
14# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 14# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
diff --git a/po/de.po b/po/de.po
index 51551aef..9ea32df9 100644
--- a/po/de.po
+++ b/po/de.po
@@ -1,119 +1,87 @@
1# translation of de.po to 1# translation of de.po to
2# German Language Translation File. 2# German Language Translation File.
3# This file is distributed under the same license as the nagios-plugins package. 3# This file is distributed under the same license as the nagios-plugins package.
4# Copyright (C) 2004 Nagios Plugin Development Group. 4# Copyright (C) 2023 Nagios Plugin Development Group.
5# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003, 2004. 5# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003, 2004.
6# 6#
7# 7#
8msgid "" 8msgid ""
9msgstr "" 9msgstr ""
10"Project-Id-Version: nagiosplug\n" 10"Project-Id-Version: PACKAGE VERSION\n"
11"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 11"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
12"POT-Creation-Date: 2014-01-19 16:30-0500\n" 12"POT-Creation-Date: 2023-09-22 15:36+0200\n"
13"PO-Revision-Date: 2004-12-23 17:46+0100\n" 13"PO-Revision-Date: 2004-12-23 17:46+0100\n"
14"Last-Translator: <>\n" 14"Last-Translator: \n"
15"Language-Team: English <en@li.org>\n" 15"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
16"Language: en\n" 16"org>\n"
17"Language: de\n"
17"MIME-Version: 1.0\n" 18"MIME-Version: 1.0\n"
18"Content-Type: text/plain; charset=iso-8859-1\n" 19"Content-Type: text/plain; charset=UTF-8\n"
19"Content-Transfer-Encoding: 8bit\n" 20"Content-Transfer-Encoding: 8bit\n"
20"Plural-Forms: nplurals=2; plural=(n > 1);X-Generator: KBabel 1.3.1\n" 21"Plural-Forms: nplurals=2; plural=(n > 1);\n"
21 22"X-Generator: KBabel 1.3.1\n"
22#: plugins/check_by_ssh.c:86 plugins/check_cluster.c:76 plugins/check_dig.c:88 23
23#: plugins/check_disk.c:194 plugins/check_dns.c:102 plugins/check_dummy.c:52
24#: plugins/check_fping.c:93 plugins/check_game.c:82 plugins/check_hpjd.c:103
25#: plugins/check_http.c:167 plugins/check_ldap.c:109 plugins/check_load.c:122
26#: plugins/check_mrtgtraf.c:83 plugins/check_mysql.c:122
27#: plugins/check_nagios.c:91 plugins/check_nt.c:127 plugins/check_ntp.c:770
28#: plugins/check_ntp_peer.c:575 plugins/check_ntp_time.c:552
29#: plugins/check_nwstat.c:173 plugins/check_overcr.c:102
30#: plugins/check_pgsql.c:172 plugins/check_ping.c:95 plugins/check_procs.c:172
31#: plugins/check_radius.c:160 plugins/check_real.c:80 plugins/check_smtp.c:144
32#: plugins/check_snmp.c:240 plugins/check_ssh.c:73 plugins/check_swap.c:110
33#: plugins/check_tcp.c:218 plugins/check_time.c:78 plugins/check_ups.c:122
34#: plugins/check_users.c:77 plugins/negate.c:214 plugins-root/check_dhcp.c:270
35msgid "Could not parse arguments" 24msgid "Could not parse arguments"
36msgstr "Argumente konnten nicht ausgewertet werden" 25msgstr "Argumente konnten nicht ausgewertet werden"
37 26
38#: plugins/check_by_ssh.c:90 plugins/check_dig.c:82 plugins/check_dns.c:95
39#: plugins/check_nagios.c:95 plugins/check_pgsql.c:178 plugins/check_ping.c:99
40#: plugins/check_procs.c:188 plugins/check_snmp.c:336 plugins/negate.c:79
41msgid "Cannot catch SIGALRM" 27msgid "Cannot catch SIGALRM"
42msgstr "Konnte SIGALRM nicht erhalten" 28msgstr "Konnte SIGALRM nicht erhalten"
43 29
44#: plugins/check_by_ssh.c:110 30#, c-format
31msgid "SSH connection failed: %s\n"
32msgstr ""
33
45#, c-format 34#, c-format
46msgid "Remote command execution failed: %s\n" 35msgid "Remote command execution failed: %s\n"
47msgstr "" 36msgstr ""
48 37
49#: plugins/check_by_ssh.c:122
50#, c-format 38#, c-format
51msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n" 39msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n"
52msgstr "" 40msgstr ""
53 41
54#: plugins/check_by_ssh.c:134
55#, c-format 42#, c-format
56msgid "SSH WARNING: could not open %s\n" 43msgid "SSH WARNING: could not open %s\n"
57msgstr "SSH WARNING: Konnte %s nicht öffnen\n" 44msgstr "SSH WARNING: Konnte %s nicht öffnen\n"
58 45
59#: plugins/check_by_ssh.c:143
60#, c-format 46#, c-format
61msgid "%s: Error parsing output\n" 47msgid "%s: Error parsing output\n"
62msgstr "" 48msgstr ""
63 49
64#: plugins/check_by_ssh.c:220 plugins/check_disk.c:476
65#: plugins/check_http.c:278 plugins/check_ldap.c:293 plugins/check_pgsql.c:311
66#: plugins/check_procs.c:437 plugins/check_radius.c:308
67#: plugins/check_real.c:356 plugins/check_smtp.c:581 plugins/check_snmp.c:736
68#: plugins/check_ssh.c:138 plugins/check_tcp.c:505 plugins/check_time.c:302
69#: plugins/check_ups.c:556 plugins/negate.c:164
70msgid "Timeout interval must be a positive integer" 50msgid "Timeout interval must be a positive integer"
71msgstr "Timeout interval muss ein positiver Integer sein" 51msgstr "Timeout interval muss ein positiver Integer sein"
72 52
73#: plugins/check_by_ssh.c:230 plugins/check_pgsql.c:341
74#: plugins/check_radius.c:272 plugins/check_real.c:327
75#: plugins/check_smtp.c:506 plugins/check_tcp.c:511 plugins/check_time.c:296
76#: plugins/check_ups.c:518
77msgid "Port must be a positive integer" 53msgid "Port must be a positive integer"
78msgstr "Port muss ein positiver Integer sein" 54msgstr "Port muss ein positiver Integer sein"
79 55
80#: plugins/check_by_ssh.c:291
81#, fuzzy 56#, fuzzy
82msgid "skip-stdout argument must be an integer" 57msgid "skip-stdout argument must be an integer"
83msgstr "skip-stdout argument muss ein Integer sein" 58msgstr "skip-stdout argument muss ein Integer sein"
84 59
85#: plugins/check_by_ssh.c:299
86#, fuzzy 60#, fuzzy
87msgid "skip-stderr argument must be an integer" 61msgid "skip-stderr argument must be an integer"
88msgstr "skip-stderr argument muss ein Integer sein" 62msgstr "skip-stderr argument muss ein Integer sein"
89 63
90#: plugins/check_by_ssh.c:322
91#, c-format 64#, c-format
92msgid "%s: You must provide a host name\n" 65msgid "%s: You must provide a host name\n"
93msgstr "%s: Hostname muss angegeben werden\n" 66msgstr "%s: Hostname muss angegeben werden\n"
94 67
95#: plugins/check_by_ssh.c:340
96msgid "No remotecmd" 68msgid "No remotecmd"
97msgstr "Kein remotecm" 69msgstr "Kein remotecm"
98 70
99#: plugins/check_by_ssh.c:354
100#, c-format 71#, c-format
101msgid "%s: Argument limit of %d exceeded\n" 72msgid "%s: Argument limit of %d exceeded\n"
102msgstr "" 73msgstr ""
103 74
104#: plugins/check_by_ssh.c:357
105#, fuzzy 75#, fuzzy
106msgid "Can not (re)allocate 'commargv' buffer\n" 76msgid "Can not (re)allocate 'commargv' buffer\n"
107msgstr "Konnte·url·nicht·zuweisen\n" 77msgstr "Konnte·url·nicht·zuweisen\n"
108 78
109#: plugins/check_by_ssh.c:371
110#, c-format 79#, c-format
111msgid "" 80msgid ""
112"%s: In passive mode, you must provide a service name for each command.\n" 81"%s: In passive mode, you must provide a service name for each command.\n"
113msgstr "" 82msgstr ""
114"%s: Im passive mode muss ein Servicename für jeden Befehl angegeben werden.\n" 83"%s: Im passive mode muss ein Servicename für jeden Befehl angegeben werden.\n"
115 84
116#: plugins/check_by_ssh.c:374
117#, fuzzy, c-format 85#, fuzzy, c-format
118msgid "" 86msgid ""
119"%s: In passive mode, you must provide the host short name from the " 87"%s: In passive mode, you must provide the host short name from the "
@@ -122,262 +90,188 @@ msgstr ""
122"%s: Im passive mode muss der \"host short name\" aus der Nagios " 90"%s: Im passive mode muss der \"host short name\" aus der Nagios "
123"Konfiguration angegeben werden\n" 91"Konfiguration angegeben werden\n"
124 92
125#: plugins/check_by_ssh.c:388
126#, fuzzy, c-format 93#, fuzzy, c-format
127msgid "This plugin uses SSH to execute commands on a remote host" 94msgid "This plugin uses SSH to execute commands on a remote host"
128msgstr "" 95msgstr ""
129"Dieses Plugin nutzt SSH um Befehle auf dem entfernten Rechner auszuführen\n" 96"Dieses Plugin nutzt SSH um Befehle auf dem entfernten Rechner auszuführen\n"
130"\n" 97"\n"
131 98
132#: plugins/check_by_ssh.c:403
133msgid "tell ssh to use Protocol 1 [optional]" 99msgid "tell ssh to use Protocol 1 [optional]"
134msgstr "" 100msgstr ""
135 101
136#: plugins/check_by_ssh.c:405
137msgid "tell ssh to use Protocol 2 [optional]" 102msgid "tell ssh to use Protocol 2 [optional]"
138msgstr "" 103msgstr ""
139 104
140#: plugins/check_by_ssh.c:407
141msgid "Ignore all or (if specified) first n lines on STDOUT [optional]" 105msgid "Ignore all or (if specified) first n lines on STDOUT [optional]"
142msgstr "" 106msgstr ""
143 107
144#: plugins/check_by_ssh.c:409
145msgid "Ignore all or (if specified) first n lines on STDERR [optional]" 108msgid "Ignore all or (if specified) first n lines on STDERR [optional]"
146msgstr "" 109msgstr ""
147 110
148#: plugins/check_by_ssh.c:411 111msgid "Exit with an warning, if there is an output on STDERR"
112msgstr ""
113
149msgid "" 114msgid ""
150"tells ssh to fork rather than create a tty [optional]. This will always " 115"tells ssh to fork rather than create a tty [optional]. This will always "
151"return OK if ssh is executed" 116"return OK if ssh is executed"
152msgstr "" 117msgstr ""
153 118
154#: plugins/check_by_ssh.c:413
155msgid "command to execute on the remote machine" 119msgid "command to execute on the remote machine"
156msgstr "" 120msgstr ""
157 121
158#: plugins/check_by_ssh.c:415
159msgid "SSH user name on remote host [optional]" 122msgid "SSH user name on remote host [optional]"
160msgstr "" 123msgstr ""
161 124
162#: plugins/check_by_ssh.c:417
163msgid "identity of an authorized key [optional]" 125msgid "identity of an authorized key [optional]"
164msgstr "" 126msgstr ""
165 127
166#: plugins/check_by_ssh.c:419
167msgid "external command file for monitoring [optional]" 128msgid "external command file for monitoring [optional]"
168msgstr "" 129msgstr ""
169 130
170#: plugins/check_by_ssh.c:421
171msgid "list of monitoring service names, separated by ':' [optional]" 131msgid "list of monitoring service names, separated by ':' [optional]"
172msgstr "" 132msgstr ""
173 133
174#: plugins/check_by_ssh.c:423
175msgid "short name of host in the monitoring configuration [optional]" 134msgid "short name of host in the monitoring configuration [optional]"
176msgstr "" 135msgstr ""
177 136
178#: plugins/check_by_ssh.c:425
179msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]" 137msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]"
180msgstr "" 138msgstr ""
181 139
182#: plugins/check_by_ssh.c:427
183msgid "Tell ssh to use this configfile [optional]" 140msgid "Tell ssh to use this configfile [optional]"
184msgstr "" 141msgstr ""
185 142
186#: plugins/check_by_ssh.c:429
187msgid "Tell ssh to suppress warning and diagnostic messages [optional]" 143msgid "Tell ssh to suppress warning and diagnostic messages [optional]"
188msgstr "" 144msgstr ""
189 145
190#: plugins/check_by_ssh.c:434 146msgid "Make connection problems return UNKNOWN instead of CRITICAL"
147msgstr ""
148
191msgid "The most common mode of use is to refer to a local identity file with" 149msgid "The most common mode of use is to refer to a local identity file with"
192msgstr "" 150msgstr ""
193 151
194#: plugins/check_by_ssh.c:435
195msgid "the '-i' option. In this mode, the identity pair should have a null" 152msgid "the '-i' option. In this mode, the identity pair should have a null"
196msgstr "" 153msgstr ""
197 154
198#: plugins/check_by_ssh.c:436
199msgid "passphrase and the public key should be listed in the authorized_keys" 155msgid "passphrase and the public key should be listed in the authorized_keys"
200msgstr "" 156msgstr ""
201 157
202#: plugins/check_by_ssh.c:437
203msgid "file of the remote host. Usually the key will be restricted to running" 158msgid "file of the remote host. Usually the key will be restricted to running"
204msgstr "" 159msgstr ""
205 160
206#: plugins/check_by_ssh.c:438
207msgid "only one command on the remote server. If the remote SSH server tracks" 161msgid "only one command on the remote server. If the remote SSH server tracks"
208msgstr "" 162msgstr ""
209 163
210#: plugins/check_by_ssh.c:439
211msgid "invocation arguments, the one remote program may be an agent that can" 164msgid "invocation arguments, the one remote program may be an agent that can"
212msgstr "" 165msgstr ""
213 166
214#: plugins/check_by_ssh.c:440
215msgid "execute additional commands as proxy" 167msgid "execute additional commands as proxy"
216msgstr "" 168msgstr ""
217 169
218#: plugins/check_by_ssh.c:442
219msgid "To use passive mode, provide multiple '-C' options, and provide" 170msgid "To use passive mode, provide multiple '-C' options, and provide"
220msgstr "" 171msgstr ""
221 172
222#: plugins/check_by_ssh.c:443
223msgid "" 173msgid ""
224"all of -O, -s, and -n options (servicelist order must match '-C'options)" 174"all of -O, -s, and -n options (servicelist order must match '-C'options)"
225msgstr "" 175msgstr ""
226 176
227#: plugins/check_by_ssh.c:445 plugins/check_cluster.c:261
228#: plugins/check_dig.c:355 plugins/check_disk.c:924 plugins/check_http.c:1560
229#: plugins/check_nagios.c:312 plugins/check_ntp.c:869
230#: plugins/check_ntp_peer.c:705 plugins/check_ntp_time.c:633
231#: plugins/check_procs.c:763 plugins/negate.c:271 plugins/urlize.c:180
232msgid "Examples:" 177msgid "Examples:"
233msgstr "" 178msgstr ""
234 179
235#: plugins/check_by_ssh.c:460 plugins/check_cluster.c:274
236#: plugins/check_dig.c:367 plugins/check_disk.c:941 plugins/check_dns.c:486
237#: plugins/check_dummy.c:122 plugins/check_fping.c:505
238#: plugins/check_game.c:331 plugins/check_hpjd.c:414 plugins/check_http.c:1590
239#: plugins/check_ldap.c:451 plugins/check_load.c:334 plugins/check_mrtg.c:382
240#: plugins/check_mysql.c:569 plugins/check_nagios.c:323 plugins/check_nt.c:774
241#: plugins/check_ntp.c:888 plugins/check_ntp_peer.c:725
242#: plugins/check_ntp_time.c:642 plugins/check_nwstat.c:1685
243#: plugins/check_overcr.c:467 plugins/check_pgsql.c:578
244#: plugins/check_ping.c:603 plugins/check_procs.c:781
245#: plugins/check_radius.c:385 plugins/check_real.c:451
246#: plugins/check_smtp.c:843 plugins/check_snmp.c:1207 plugins/check_ssh.c:309
247#: plugins/check_swap.c:558 plugins/check_tcp.c:684 plugins/check_time.c:371
248#: plugins/check_ups.c:660 plugins/check_users.c:240
249#: plugins/check_ide_smart.c:640 plugins/negate.c:295 plugins/urlize.c:197
250#: plugins-root/check_dhcp.c:1422 plugins-root/check_icmp.c:1354
251msgid "Usage:" 180msgid "Usage:"
252msgstr "" 181msgstr ""
253 182
254#: plugins/check_cluster.c:230
255#, c-format 183#, c-format
256msgid "Host/Service Cluster Plugin for Monitoring" 184msgid "Host/Service Cluster Plugin for Monitoring"
257msgstr "" 185msgstr ""
258 186
259#: plugins/check_cluster.c:236 plugins/check_nt.c:676
260msgid "Options:" 187msgid "Options:"
261msgstr "" 188msgstr ""
262 189
263#: plugins/check_cluster.c:239
264msgid "Check service cluster status" 190msgid "Check service cluster status"
265msgstr "" 191msgstr ""
266 192
267#: plugins/check_cluster.c:241
268msgid "Check host cluster status" 193msgid "Check host cluster status"
269msgstr "" 194msgstr ""
270 195
271#: plugins/check_cluster.c:243
272msgid "Optional prepended text output (i.e. \"Host cluster\")" 196msgid "Optional prepended text output (i.e. \"Host cluster\")"
273msgstr "" 197msgstr ""
274 198
275#: plugins/check_cluster.c:245 plugins/check_cluster.c:248
276msgid "Specifies the range of hosts or services in cluster that must be in a" 199msgid "Specifies the range of hosts or services in cluster that must be in a"
277msgstr "" 200msgstr ""
278 201
279#: plugins/check_cluster.c:246
280msgid "non-OK state in order to return a WARNING status level" 202msgid "non-OK state in order to return a WARNING status level"
281msgstr "" 203msgstr ""
282 204
283#: plugins/check_cluster.c:249
284msgid "non-OK state in order to return a CRITICAL status level" 205msgid "non-OK state in order to return a CRITICAL status level"
285msgstr "" 206msgstr ""
286 207
287#: plugins/check_cluster.c:251
288msgid "The status codes of the hosts or services in the cluster, separated by" 208msgid "The status codes of the hosts or services in the cluster, separated by"
289msgstr "" 209msgstr ""
290 210
291#: plugins/check_cluster.c:252
292msgid "commas" 211msgid "commas"
293msgstr "" 212msgstr ""
294 213
295#: plugins/check_cluster.c:257 plugins/check_game.c:318
296#: plugins/check_http.c:1542 plugins/check_ldap.c:438 plugins/check_mrtg.c:363
297#: plugins/check_mrtgtraf.c:361 plugins/check_mysql.c:558
298#: plugins/check_nt.c:758 plugins/check_ntp.c:865 plugins/check_ntp_peer.c:696
299#: plugins/check_ntp_time.c:626 plugins/check_nwstat.c:1670
300#: plugins/check_overcr.c:456 plugins/check_snmp.c:1178
301#: plugins/check_swap.c:547 plugins/check_ups.c:642 plugins/negate.c:277
302#: plugins-root/check_icmp.c:1329
303msgid "Notes:" 214msgid "Notes:"
304msgstr "" 215msgstr ""
305 216
306#: plugins/check_cluster.c:263
307msgid "" 217msgid ""
308"Will alert critical if there are 3 or more service data points in a non-OK" 218"Will alert critical if there are 3 or more service data points in a non-OK"
309msgstr "" 219msgstr ""
310 220
311#: plugins/check_cluster.c:264 plugins/check_ups.c:639
312msgid "state." 221msgid "state."
313msgstr "" 222msgstr ""
314 223
315#: plugins/check_dig.c:100 plugins/check_dig.c:102
316#, c-format 224#, c-format
317msgid "Looking for: '%s'\n" 225msgid "Looking for: '%s'\n"
318msgstr "" 226msgstr ""
319 227
320#: plugins/check_dig.c:109
321msgid "dig returned an error status" 228msgid "dig returned an error status"
322msgstr "dig hat einen Fehler zurückgegeben" 229msgstr "dig hat einen Fehler zurückgegeben"
323 230
324#: plugins/check_dig.c:134
325msgid "Server not found in ANSWER SECTION" 231msgid "Server not found in ANSWER SECTION"
326msgstr "Server nicht gefunden in ANSWER SECTION" 232msgstr "Server nicht gefunden in ANSWER SECTION"
327 233
328#: plugins/check_dig.c:144
329msgid "No ANSWER SECTION found" 234msgid "No ANSWER SECTION found"
330msgstr "Keine ANSWER SECTION gefunden" 235msgstr "Keine ANSWER SECTION gefunden"
331 236
332#: plugins/check_dig.c:171
333#, fuzzy 237#, fuzzy
334msgid "Probably a non-existent host/domain" 238msgid "Probably a non-existent host/domain"
335msgstr "nicht existierender Host/Domain" 239msgstr "nicht existierender Host/Domain"
336 240
337#: plugins/check_dig.c:233
338#, fuzzy, c-format 241#, fuzzy, c-format
339msgid "Port must be a positive integer - %s" 242msgid "Port must be a positive integer - %s"
340msgstr "Port muss ein positiver Integer sein - %s" 243msgstr "Port muss ein positiver Integer sein - %s"
341 244
342#: plugins/check_dig.c:244
343#, fuzzy, c-format 245#, fuzzy, c-format
344msgid "Warning interval must be a positive integer - %s" 246msgid "Warning interval must be a positive integer - %s"
345msgstr "Warning interval muss ein positiver Integer sein - %s" 247msgstr "Warning interval muss ein positiver Integer sein - %s"
346 248
347#: plugins/check_dig.c:252
348#, fuzzy, c-format 249#, fuzzy, c-format
349msgid "Critical interval must be a positive integer - %s" 250msgid "Critical interval must be a positive integer - %s"
350msgstr "Critical interval muss ein positiver Integer sein - %s" 251msgstr "Critical interval muss ein positiver Integer sein - %s"
351 252
352#: plugins/check_dig.c:260
353#, fuzzy, c-format 253#, fuzzy, c-format
354msgid "Timeout interval must be a positive integer - %s" 254msgid "Timeout interval must be a positive integer - %s"
355msgstr "Timeout interval muss ein positiver Integer sein - %s" 255msgstr "Timeout interval muss ein positiver Integer sein - %s"
356 256
357#: plugins/check_dig.c:325
358#, fuzzy, c-format 257#, fuzzy, c-format
359msgid "This plugin test the DNS service on the specified host using dig" 258msgid "This plugin tests the DNS service on the specified host using dig"
360msgstr "Testet den DNS Dienst auf dem angegebenen Host mit dig" 259msgstr "Testet den DNS Dienst auf dem angegebenen Host mit dig"
361 260
362#: plugins/check_dig.c:338
363msgid "Force dig to only use IPv4 query transport" 261msgid "Force dig to only use IPv4 query transport"
364msgstr "" 262msgstr ""
365 263
366#: plugins/check_dig.c:340
367msgid "Force dig to only use IPv6 query transport" 264msgid "Force dig to only use IPv6 query transport"
368msgstr "" 265msgstr ""
369 266
370#: plugins/check_dig.c:342
371#, fuzzy 267#, fuzzy
372msgid "Machine name to lookup" 268msgid "Machine name to lookup"
373msgstr "zu prüfender Hostname" 269msgstr "zu prüfender Hostname"
374 270
375#: plugins/check_dig.c:344
376#, fuzzy 271#, fuzzy
377msgid "Record type to lookup (default: A)" 272msgid "Record type to lookup (default: A)"
378msgstr "abzufragender Datensatztyp (Default: A)" 273msgstr "abzufragender Datensatztyp (Default: A)"
379 274
380#: plugins/check_dig.c:346
381#, fuzzy 275#, fuzzy
382msgid "" 276msgid ""
383"An address expected to be in the answer section. If not set, uses whatever" 277"An address expected to be in the answer section. If not set, uses whatever"
@@ -385,96 +279,71 @@ msgstr ""
385"Adresse die in der ANSWER SECTION erwartet wird.wenn nicht gesetzt, " 279"Adresse die in der ANSWER SECTION erwartet wird.wenn nicht gesetzt, "
386"ubernommen aus -l" 280"ubernommen aus -l"
387 281
388#: plugins/check_dig.c:347
389msgid "was in -l" 282msgid "was in -l"
390msgstr "" 283msgstr ""
391 284
392#: plugins/check_dig.c:349
393msgid "Pass STRING as argument(s) to dig" 285msgid "Pass STRING as argument(s) to dig"
394msgstr "" 286msgstr ""
395 287
396#: plugins/check_disk.c:216
397#, fuzzy, c-format 288#, fuzzy, c-format
398msgid "DISK %s: %s not found\n" 289msgid "DISK %s: %s not found\n"
399msgstr "%s [%s nicht gefunden]" 290msgstr "%s [%s nicht gefunden]"
400 291
401#: plugins/check_disk.c:216 plugins/check_disk.c:956 plugins/check_dns.c:241
402#: plugins/check_dummy.c:74 plugins/check_mysql.c:299
403#: plugins/check_nagios.c:104 plugins/check_nagios.c:168
404#: plugins/check_nagios.c:172 plugins/check_pgsql.c:601
405#: plugins/check_pgsql.c:618 plugins/check_pgsql.c:627
406#: plugins/check_pgsql.c:642 plugins/check_procs.c:351
407#, c-format 292#, c-format
408msgid "CRITICAL" 293msgid "CRITICAL"
409msgstr "CRITICAL" 294msgstr "CRITICAL"
410 295
411#: plugins/check_disk.c:550
412#, c-format 296#, c-format
413msgid "unit type %s not known\n" 297msgid "unit type %s not known\n"
414msgstr "unbekannter unit type: %s\n" 298msgstr "unbekannter unit type: %s\n"
415 299
416#: plugins/check_disk.c:553
417#, c-format 300#, c-format
418msgid "failed allocating storage for '%s'\n" 301msgid "failed allocating storage for '%s'\n"
419msgstr "konnte keinen Speicher für '%s' reservieren\n" 302msgstr "konnte keinen Speicher für '%s' reservieren\n"
420 303
421#: plugins/check_disk.c:577 plugins/check_disk.c:618 plugins/check_disk.c:626
422#: plugins/check_disk.c:633 plugins/check_disk.c:637 plugins/check_disk.c:677
423#: plugins/check_disk.c:683 plugins/check_disk.c:702 plugins/check_dummy.c:77
424#: plugins/check_dummy.c:80 plugins/check_pgsql.c:643
425#: plugins/check_procs.c:506
426#, c-format 304#, c-format
427msgid "UNKNOWN" 305msgid "UNKNOWN"
428msgstr "UNKNOWN" 306msgstr "UNKNOWN"
429 307
430#: plugins/check_disk.c:577
431msgid "Must set a threshold value before using -p\n" 308msgid "Must set a threshold value before using -p\n"
432msgstr "" 309msgstr ""
433 310
434#: plugins/check_disk.c:618
435msgid "Must set -E before selecting paths\n" 311msgid "Must set -E before selecting paths\n"
436msgstr "" 312msgstr ""
437 313
438#: plugins/check_disk.c:626
439msgid "Must set group value before selecting paths\n" 314msgid "Must set group value before selecting paths\n"
440msgstr "" 315msgstr ""
441 316
442#: plugins/check_disk.c:633
443msgid "" 317msgid ""
444"Paths need to be selected before using -i/-I. Use -A to select all paths " 318"Paths need to be selected before using -i/-I. Use -A to select all paths "
445"explicitly" 319"explicitly"
446msgstr "" 320msgstr ""
447 321
448#: plugins/check_disk.c:637 plugins/check_disk.c:683 plugins/check_procs.c:506
449msgid "Could not compile regular expression" 322msgid "Could not compile regular expression"
450msgstr "" 323msgstr ""
451 324
452#: plugins/check_disk.c:677 325msgid ""
453msgid "Must set a threshold value before using -r/-R\n" 326"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
327"all)\n"
454msgstr "" 328msgstr ""
455 329
456#: plugins/check_disk.c:703
457msgid "Regular expression did not match any path or disk" 330msgid "Regular expression did not match any path or disk"
458msgstr "" 331msgstr ""
459 332
460#: plugins/check_disk.c:749
461#, fuzzy 333#, fuzzy
462msgid "Unknown argument" 334msgid "Unknown argument"
463msgstr "Unbekanntes Argument" 335msgstr "Unbekanntes Argument"
464 336
465#: plugins/check_disk.c:783
466#, c-format 337#, c-format
467msgid " for %s\n" 338msgid " for %s\n"
468msgstr "" 339msgstr ""
469 340
470#: plugins/check_disk.c:857
471#, fuzzy 341#, fuzzy
472msgid "" 342msgid ""
473"This plugin checks the amount of used disk space on a mounted file system" 343"This plugin checks the amount of used disk space on a mounted file system"
474msgstr "" 344msgstr ""
475"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem" 345"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem"
476 346
477#: plugins/check_disk.c:858
478#, fuzzy 347#, fuzzy
479msgid "" 348msgid ""
480"and generates an alert if free space is less than one of the threshold values" 349"and generates an alert if free space is less than one of the threshold values"
@@ -482,3575 +351,2953 @@ msgstr ""
482"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 351"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
483"unterschritten wird." 352"unterschritten wird."
484 353
485#: plugins/check_disk.c:868
486msgid "Exit with WARNING status if less than INTEGER units of disk are free" 354msgid "Exit with WARNING status if less than INTEGER units of disk are free"
487msgstr "" 355msgstr ""
488 356
489#: plugins/check_disk.c:870
490msgid "Exit with WARNING status if less than PERCENT of disk space is free" 357msgid "Exit with WARNING status if less than PERCENT of disk space is free"
491msgstr "" 358msgstr ""
492 359
493#: plugins/check_disk.c:872
494msgid "Exit with CRITICAL status if less than INTEGER units of disk are free" 360msgid "Exit with CRITICAL status if less than INTEGER units of disk are free"
495msgstr "" 361msgstr ""
496 362
497#: plugins/check_disk.c:874
498msgid "Exit with CRITICAL status if less than PERCENT of disk space is free" 363msgid "Exit with CRITICAL status if less than PERCENT of disk space is free"
499msgstr "" 364msgstr ""
500 365
501#: plugins/check_disk.c:876
502msgid "Exit with WARNING status if less than PERCENT of inode space is free" 366msgid "Exit with WARNING status if less than PERCENT of inode space is free"
503msgstr "" 367msgstr ""
504 368
505#: plugins/check_disk.c:878
506msgid "Exit with CRITICAL status if less than PERCENT of inode space is free" 369msgid "Exit with CRITICAL status if less than PERCENT of inode space is free"
507msgstr "" 370msgstr ""
508 371
509#: plugins/check_disk.c:880 372msgid ""
510msgid "Path or partition (may be repeated)" 373"Mount point or block device as emitted by the mount(8) command (may be "
374"repeated)"
511msgstr "" 375msgstr ""
512 376
513#: plugins/check_disk.c:882
514msgid "Ignore device (only works if -p unspecified)" 377msgid "Ignore device (only works if -p unspecified)"
515msgstr "" 378msgstr ""
516 379
517#: plugins/check_disk.c:884
518msgid "Clear thresholds" 380msgid "Clear thresholds"
519msgstr "" 381msgstr ""
520 382
521#: plugins/check_disk.c:886
522msgid "For paths or partitions specified with -p, only check for exact paths" 383msgid "For paths or partitions specified with -p, only check for exact paths"
523msgstr "" 384msgstr ""
524 385
525#: plugins/check_disk.c:888
526msgid "Display only devices/mountpoints with errors" 386msgid "Display only devices/mountpoints with errors"
527msgstr "" 387msgstr ""
528 388
529#: plugins/check_disk.c:890
530msgid "Don't account root-reserved blocks into freespace in perfdata" 389msgid "Don't account root-reserved blocks into freespace in perfdata"
531msgstr "" 390msgstr ""
532 391
533#: plugins/check_disk.c:892 392msgid "Display inode usage in perfdata"
393msgstr ""
394
534msgid "" 395msgid ""
535"Group paths. Thresholds apply to (free-)space of all partitions together" 396"Group paths. Thresholds apply to (free-)space of all partitions together"
536msgstr "" 397msgstr ""
537 398
538#: plugins/check_disk.c:894
539msgid "Same as '--units kB'" 399msgid "Same as '--units kB'"
540msgstr "" 400msgstr ""
541 401
542#: plugins/check_disk.c:896
543msgid "Only check local filesystems" 402msgid "Only check local filesystems"
544msgstr "" 403msgstr ""
545 404
546#: plugins/check_disk.c:898
547msgid "" 405msgid ""
548"Only check local filesystems against thresholds. Yet call stat on remote " 406"Only check local filesystems against thresholds. Yet call stat on remote "
549"filesystems" 407"filesystems"
550msgstr "" 408msgstr ""
551 409
552#: plugins/check_disk.c:899
553msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)" 410msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)"
554msgstr "" 411msgstr ""
555 412
556#: plugins/check_disk.c:901 413msgid "Display the (block) device instead of the mount point"
557msgid "Display the mountpoint instead of the partition"
558msgstr "" 414msgstr ""
559 415
560#: plugins/check_disk.c:903
561msgid "Same as '--units MB'" 416msgid "Same as '--units MB'"
562msgstr "" 417msgstr ""
563 418
564#: plugins/check_disk.c:905
565msgid "Explicitly select all paths. This is equivalent to -R '.*'" 419msgid "Explicitly select all paths. This is equivalent to -R '.*'"
566msgstr "" 420msgstr ""
567 421
568#: plugins/check_disk.c:907
569msgid "" 422msgid ""
570"Case insensitive regular expression for path/partition (may be repeated)" 423"Case insensitive regular expression for path/partition (may be repeated)"
571msgstr "" 424msgstr ""
572 425
573#: plugins/check_disk.c:909
574msgid "Regular expression for path or partition (may be repeated)" 426msgid "Regular expression for path or partition (may be repeated)"
575msgstr "" 427msgstr ""
576 428
577#: plugins/check_disk.c:911
578msgid "" 429msgid ""
579"Regular expression to ignore selected path/partition (case insensitive) (may " 430"Regular expression to ignore selected path/partition (case insensitive) (may "
580"be repeated)" 431"be repeated)"
581msgstr "" 432msgstr ""
582 433
583#: plugins/check_disk.c:913
584msgid "" 434msgid ""
585"Regular expression to ignore selected path or partition (may be repeated)" 435"Regular expression to ignore selected path or partition (may be repeated)"
586msgstr "" 436msgstr ""
587 437
588#: plugins/check_disk.c:916 438msgid ""
439"Return OK if no filesystem matches, filesystem does not exist or is "
440"inaccessible."
441msgstr ""
442
443msgid "(Provide this option before -p / -r / --ereg-path if used)"
444msgstr ""
445
589msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 446msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
590msgstr "" 447msgstr ""
591 448
592#: plugins/check_disk.c:919
593msgid "Ignore all filesystems of indicated type (may be repeated)" 449msgid "Ignore all filesystems of indicated type (may be repeated)"
594msgstr "" 450msgstr ""
595 451
596#: plugins/check_disk.c:921
597msgid "Check only filesystems of indicated type (may be repeated)" 452msgid "Check only filesystems of indicated type (may be repeated)"
598msgstr "" 453msgstr ""
599 454
600#: plugins/check_disk.c:926 455msgid "General usage hints:"
456msgstr "Allgemeine Nutzungshinweise:"
457
458msgid ""
459"- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the "
460"same as"
461msgstr ""
462
463msgid "\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."
464msgstr ""
465
466msgid ""
467"- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} "
468"{thresholds b} ...\""
469msgstr ""
470
601msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB" 471msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
602msgstr "" 472msgstr ""
603 473
604#: plugins/check_disk.c:928
605msgid "" 474msgid ""
606"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -" 475"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -"
607"r regex" 476"r regex"
608msgstr "" 477msgstr ""
609 478
610#: plugins/check_disk.c:929
611msgid "" 479msgid ""
612"are grouped which means the freespace thresholds are applied to all disks " 480"are grouped which means the freespace thresholds are applied to all disks "
613"together" 481"together"
614msgstr "" 482msgstr ""
615 483
616#: plugins/check_disk.c:931
617msgid "" 484msgid ""
618"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use " 485"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use "
619"100M/50M" 486"100M/50M"
620msgstr "" 487msgstr ""
621 488
622#: plugins/check_disk.c:957
623#, c-format 489#, c-format
624msgid "%s %s: %s\n" 490msgid "%s %s: %s\n"
625msgstr "" 491msgstr ""
626 492
627#: plugins/check_disk.c:957
628msgid "is not accessible" 493msgid "is not accessible"
629msgstr "" 494msgstr ""
630 495
631#: plugins/check_dns.c:116
632#, fuzzy 496#, fuzzy
633msgid "nslookup returned an error status" 497msgid "nslookup returned an error status"
634msgstr "nslookup hat einen Fehler zurückgegeben" 498msgstr "nslookup hat einen Fehler zurückgegeben"
635 499
636#: plugins/check_dns.c:134
637msgid "Warning plugin error" 500msgid "Warning plugin error"
638msgstr "Warnung Plugin Fehler" 501msgstr "Warnung Plugin Fehler"
639 502
640#: plugins/check_dns.c:154 503#, fuzzy, c-format
504msgid "DNS CRITICAL - '%s' returned empty server string\n"
505msgstr "DNS CRITICAL - '%s' hat einen leeren Hostnamen zurückgegeben\n"
506
507#, fuzzy, c-format
508msgid "DNS CRITICAL - No response from DNS %s\n"
509msgstr "Keine Antwort von DNS %s\n"
510
641#, c-format 511#, c-format
642msgid "DNS CRITICAL - '%s' returned empty host name string\n" 512msgid "DNS CRITICAL - '%s' returned empty host name string\n"
643msgstr "DNS CRITICAL - '%s' hat einen leeren Hostnamen zurückgegeben\n" 513msgstr "DNS CRITICAL - '%s' hat einen leeren Hostnamen zurückgegeben\n"
644 514
645#: plugins/check_dns.c:160
646msgid "Non-authoritative answer:" 515msgid "Non-authoritative answer:"
647msgstr "" 516msgstr ""
648 517
649#: plugins/check_dns.c:201 518#, fuzzy, c-format
519msgid "Domain '%s' was not found by the server\n"
520msgstr "Domäne %s wurde vom Server nicht gefunden\n"
521
650#, fuzzy, c-format 522#, fuzzy, c-format
651msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n" 523msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n"
652msgstr "DNS CRITICAL - '%s' Ausgabeverarbeitung hat keine Adresse ergeben\n" 524msgstr "DNS CRITICAL - '%s' Ausgabeverarbeitung hat keine Adresse ergeben\n"
653 525
654#: plugins/check_dns.c:216
655#, fuzzy, c-format 526#, fuzzy, c-format
656msgid "expected '%s' but got '%s'" 527msgid "expected '%s' but got '%s'"
657msgstr "Erwartet: %s aber: %s erhalten" 528msgstr "Erwartet: %s aber: %s erhalten"
658 529
659#: plugins/check_dns.c:223 530#, fuzzy, c-format
531msgid "Domain '%s' was found by the server: '%s'\n"
532msgstr "Domäne %s wurde vom Server nicht gefunden\n"
533
660#, c-format 534#, c-format
661msgid "server %s is not authoritative for %s" 535msgid "server %s is not authoritative for %s"
662msgstr "Server %s ist nicht autoritativ für %s" 536msgstr "Server %s ist nicht autoritativ für %s"
663 537
664#: plugins/check_dns.c:237 plugins/check_dummy.c:68 plugins/check_nagios.c:182
665#: plugins/check_pgsql.c:638 plugins/check_procs.c:344
666#, c-format 538#, c-format
667msgid "OK" 539msgid "OK"
668msgstr "OK" 540msgstr "OK"
669 541
670#: plugins/check_dns.c:239 plugins/check_dummy.c:71 plugins/check_mysql.c:296
671#: plugins/check_nagios.c:182 plugins/check_pgsql.c:607
672#: plugins/check_pgsql.c:612 plugins/check_pgsql.c:640
673#: plugins/check_procs.c:346
674#, c-format 542#, c-format
675msgid "WARNING" 543msgid "WARNING"
676msgstr "WARNING" 544msgstr "WARNING"
677 545
678#: plugins/check_dns.c:243
679#, fuzzy, c-format 546#, fuzzy, c-format
680msgid "%.3f second response time" 547msgid "%.3f second response time"
681msgid_plural "%.3f seconds response time" 548msgid_plural "%.3f seconds response time"
682msgstr[0] "%.3f Sekunden Antwortzeit " 549msgstr[0] "%.3f Sekunden Antwortzeit "
683msgstr[1] "%.3f Sekunden Antwortzeit " 550msgstr[1] "%.3f Sekunden Antwortzeit "
684 551
685#: plugins/check_dns.c:244
686#, fuzzy, c-format 552#, fuzzy, c-format
687msgid ". %s returns %s" 553msgid ". %s returns %s"
688msgstr "%s hat %s zurückgegeben" 554msgstr "%s hat %s zurückgegeben"
689 555
690#: plugins/check_dns.c:248
691#, c-format 556#, c-format
692msgid "DNS WARNING - %s\n" 557msgid "DNS WARNING - %s\n"
693msgstr "DNS WARNING - %s\n" 558msgstr "DNS WARNING - %s\n"
694 559
695#: plugins/check_dns.c:249 plugins/check_dns.c:252 plugins/check_dns.c:255
696msgid " Probably a non-existent host/domain" 560msgid " Probably a non-existent host/domain"
697msgstr "nicht existierender Host/Domain" 561msgstr "nicht existierender Host/Domain"
698 562
699#: plugins/check_dns.c:251
700#, c-format 563#, c-format
701msgid "DNS CRITICAL - %s\n" 564msgid "DNS CRITICAL - %s\n"
702msgstr "DNS CRITICAL - %s\n" 565msgstr "DNS CRITICAL - %s\n"
703 566
704#: plugins/check_dns.c:254
705#, fuzzy, c-format 567#, fuzzy, c-format
706msgid "DNS UNKNOWN - %s\n" 568msgid "DNS UNKNOWN - %s\n"
707msgstr "DNS UNKNOW - %s\n" 569msgstr "DNS UNKNOWN - %s\n"
708 570
709#: plugins/check_dns.c:267
710msgid "Note: nslookup is deprecated and may be removed from future releases." 571msgid "Note: nslookup is deprecated and may be removed from future releases."
711msgstr "" 572msgstr ""
712 573
713#: plugins/check_dns.c:268
714msgid "Consider using the `dig' or `host' programs instead. Run nslookup with" 574msgid "Consider using the `dig' or `host' programs instead. Run nslookup with"
715msgstr "" 575msgstr ""
716 576
717#: plugins/check_dns.c:269
718msgid "the `-sil[ent]' option to prevent this message from appearing." 577msgid "the `-sil[ent]' option to prevent this message from appearing."
719msgstr "" 578msgstr ""
720 579
721#: plugins/check_dns.c:274
722#, c-format 580#, c-format
723msgid "No response from DNS %s\n" 581msgid "No response from DNS %s\n"
724msgstr "Keine Antwort von DNS %s\n" 582msgstr "Keine Antwort von DNS %s\n"
725 583
726#: plugins/check_dns.c:278
727#, c-format 584#, c-format
728msgid "DNS %s has no records\n" 585msgid "DNS %s has no records\n"
729msgstr "Nameserver %s hat keine Datensätze\n" 586msgstr "Nameserver %s hat keine Datensätze\n"
730 587
731#: plugins/check_dns.c:286
732#, c-format 588#, c-format
733msgid "Connection to DNS %s was refused\n" 589msgid "Connection to DNS %s was refused\n"
734msgstr "Verbindung zum Nameserver %s wurde verweigert\n" 590msgstr "Verbindung zum Nameserver %s wurde verweigert\n"
735 591
736#: plugins/check_dns.c:290
737#, c-format 592#, c-format
738msgid "Query was refused by DNS server at %s\n" 593msgid "Query was refused by DNS server at %s\n"
739msgstr "" 594msgstr ""
740 595
741#: plugins/check_dns.c:294
742#, c-format 596#, c-format
743msgid "No information returned by DNS server at %s\n" 597msgid "No information returned by DNS server at %s\n"
744msgstr "" 598msgstr ""
745 599
746#: plugins/check_dns.c:300
747#, c-format
748msgid "Domain %s was not found by the server\n"
749msgstr "Domäne %s wurde vom Server nicht gefunden\n"
750
751#: plugins/check_dns.c:304
752msgid "Network is unreachable\n" 600msgid "Network is unreachable\n"
753msgstr "Netzwerk nicht erreichbar\n" 601msgstr "Netzwerk nicht erreichbar\n"
754 602
755#: plugins/check_dns.c:308
756#, c-format 603#, c-format
757msgid "DNS failure for %s\n" 604msgid "DNS failure for %s\n"
758msgstr "DNS Fehler für %s\n" 605msgstr "DNS Fehler für %s\n"
759 606
760#: plugins/check_dns.c:372 plugins/check_dns.c:380 plugins/check_dns.c:387
761#: plugins/check_dns.c:392 plugins/check_dns.c:414 plugins/check_dns.c:422
762#: plugins/check_game.c:211 plugins/check_game.c:219
763msgid "Input buffer overflow\n" 607msgid "Input buffer overflow\n"
764msgstr "Eingabe-Pufferüberlauf\n" 608msgstr "Eingabe-Pufferüberlauf\n"
765 609
766#: plugins/check_dns.c:450
767msgid "" 610msgid ""
768"This plugin uses the nslookup program to obtain the IP address for the given " 611"This plugin uses the nslookup program to obtain the IP address for the given "
769"host/domain query." 612"host/domain query."
770msgstr "" 613msgstr ""
771 614
772#: plugins/check_dns.c:451
773msgid "An optional DNS server to use may be specified." 615msgid "An optional DNS server to use may be specified."
774msgstr "" 616msgstr ""
775 617
776#: plugins/check_dns.c:452
777msgid "" 618msgid ""
778"If no DNS server is specified, the default server(s) specified in /etc/" 619"If no DNS server is specified, the default server(s) specified in /etc/"
779"resolv.conf will be used." 620"resolv.conf will be used."
780msgstr "" 621msgstr ""
781 622
782#: plugins/check_dns.c:462
783msgid "The name or address you want to query" 623msgid "The name or address you want to query"
784msgstr "" 624msgstr ""
785 625
786#: plugins/check_dns.c:464
787msgid "Optional DNS server you want to use for the lookup" 626msgid "Optional DNS server you want to use for the lookup"
788msgstr "" 627msgstr ""
789 628
790#: plugins/check_dns.c:466
791msgid "" 629msgid ""
792"Optional IP-ADDRESS you expect the DNS server to return. HOST must end with" 630"Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"
793msgstr "" 631msgstr ""
794 632
795#: plugins/check_dns.c:467
796msgid "" 633msgid ""
797"a dot (.). This option can be repeated multiple times (Returns OK if any" 634"with a dot (.). This option can be repeated multiple times (Returns OK if any"
798msgstr "" 635msgstr ""
799 636
800#: plugins/check_dns.c:468 637msgid "value matches)."
801msgid ""
802"value match). If multiple addresses are returned at once, you have to match"
803msgstr "" 638msgstr ""
804 639
805#: plugins/check_dns.c:469
806msgid "" 640msgid ""
807"the whole string of addresses separated with commas (sorted alphabetically)." 641"Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"
642msgstr ""
643
644msgid "Cannot be used together with -a"
808msgstr "" 645msgstr ""
809 646
810#: plugins/check_dns.c:471
811msgid "Optionally expect the DNS server to be authoritative for the lookup" 647msgid "Optionally expect the DNS server to be authoritative for the lookup"
812msgstr "" 648msgstr ""
813 649
814#: plugins/check_dns.c:473
815msgid "Return warning if elapsed time exceeds value. Default off" 650msgid "Return warning if elapsed time exceeds value. Default off"
816msgstr "" 651msgstr ""
817 652
818#: plugins/check_dns.c:475
819msgid "Return critical if elapsed time exceeds value. Default off" 653msgid "Return critical if elapsed time exceeds value. Default off"
820msgstr "" 654msgstr ""
821 655
822#: plugins/check_dummy.c:62 656msgid ""
657"Return critical if the list of expected addresses does not match all "
658"addresses"
659msgstr ""
660
661msgid "returned. Default off"
662msgstr ""
663
823msgid "Arguments to check_dummy must be an integer" 664msgid "Arguments to check_dummy must be an integer"
824msgstr "Argument für check_dummy muss ein Integer sein" 665msgstr "Argument für check_dummy muss ein Integer sein"
825 666
826#: plugins/check_dummy.c:82
827#, c-format 667#, c-format
828msgid "Status %d is not a supported error state\n" 668msgid "Status %d is not a supported error state\n"
829msgstr "Status %d ist kein bekannter Fehlerstatus\n" 669msgstr "Status %d ist kein bekannter Fehlerstatus\n"
830 670
831#: plugins/check_dummy.c:104
832msgid "" 671msgid ""
833"This plugin will simply return the state corresponding to the numeric value" 672"This plugin will simply return the state corresponding to the numeric value"
834msgstr "" 673msgstr ""
835 674
836#: plugins/check_dummy.c:106
837msgid "of the <state> argument with optional text" 675msgid "of the <state> argument with optional text"
838msgstr "" 676msgstr ""
839 677
840#: plugins/check_fping.c:125 plugins/check_hpjd.c:128 plugins/check_ping.c:438
841#: plugins/check_swap.c:175 plugins/check_users.c:94 plugins/urlize.c:110
842#, c-format 678#, c-format
843msgid "Could not open pipe: %s\n" 679msgid "Could not open pipe: %s\n"
844msgstr "Pipe: %s konnte nicht geöffnet werden\n" 680msgstr "Pipe: %s konnte nicht geöffnet werden\n"
845 681
846#: plugins/check_fping.c:131 plugins/check_hpjd.c:134 plugins/check_load.c:153
847#: plugins/check_swap.c:181 plugins/check_users.c:100 plugins/urlize.c:116
848#, c-format 682#, c-format
849msgid "Could not open stderr for %s\n" 683msgid "Could not open stderr for %s\n"
850msgstr "Konnte stderr nicht öffnen für: %s\n" 684msgstr "Konnte stderr nicht öffnen für: %s\n"
851 685
852#: plugins/check_fping.c:157
853#, fuzzy 686#, fuzzy
854msgid "FPING UNKNOWN - IP address not found\n" 687msgid "FPING UNKNOWN - IP address not found\n"
855msgstr "FPING UNKNOW - %s nicht gefunden\n" 688msgstr "FPING UNKNOWN - %s nicht gefunden\n"
856 689
857#: plugins/check_fping.c:160
858msgid "FPING UNKNOWN - invalid commandline argument\n" 690msgid "FPING UNKNOWN - invalid commandline argument\n"
859msgstr "" 691msgstr ""
860 692
861#: plugins/check_fping.c:163
862#, fuzzy 693#, fuzzy
863msgid "FPING UNKNOWN - failed system call\n" 694msgid "FPING UNKNOWN - failed system call\n"
864msgstr "FPING UNKNOW - %s nicht gefunden\n" 695msgstr "FPING UNKNOWN - %s nicht gefunden\n"
696
697#, fuzzy, c-format
698msgid "FPING %s - %s (rta=%f ms)|%s\n"
699msgstr "FPING %s - %s (verloren=%.0f%% )|%s\n"
865 700
866#: plugins/check_fping.c:187
867#, c-format 701#, c-format
868msgid "FPING UNKNOW - %s not found\n" 702msgid "FPING UNKNOWN - %s not found\n"
869msgstr "FPING UNKNOW - %s nicht gefunden\n" 703msgstr "FPING UNKNOWN - %s nicht gefunden\n"
870 704
871#: plugins/check_fping.c:191
872#, c-format 705#, c-format
873msgid "FPING CRITICAL - %s is unreachable\n" 706msgid "FPING CRITICAL - %s is unreachable\n"
874msgstr "FPING CRITICAL - %s ist nicht erreichbar\n" 707msgstr "FPING CRITICAL - %s ist nicht erreichbar\n"
875 708
876#: plugins/check_fping.c:196
877#, fuzzy, c-format 709#, fuzzy, c-format
878msgid "FPING UNKNOWN - %s parameter error\n" 710msgid "FPING UNKNOWN - %s parameter error\n"
879msgstr "FPING UNKNOW - %s nicht gefunden\n" 711msgstr "FPING UNKNOWN - %s nicht gefunden\n"
880 712
881#: plugins/check_fping.c:200 plugins/check_fping.c:240
882#, c-format 713#, c-format
883msgid "FPING CRITICAL - %s is down\n" 714msgid "FPING CRITICAL - %s is down\n"
884msgstr "FPING CRITICAL - %s ist down\n" 715msgstr "FPING CRITICAL - %s ist down\n"
885 716
886#: plugins/check_fping.c:227
887#, c-format 717#, c-format
888msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n" 718msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"
889msgstr "FPING %s - %s (verloren=%.0f%%, rta=%f ms)|%s %s\n" 719msgstr "FPING %s - %s (verloren=%.0f%%, rta=%f ms)|%s %s\n"
890 720
891#: plugins/check_fping.c:253
892#, c-format 721#, c-format
893msgid "FPING %s - %s (loss=%.0f%% )|%s\n" 722msgid "FPING %s - %s (loss=%.0f%% )|%s\n"
894msgstr "FPING %s - %s (verloren=%.0f%% )|%s\n" 723msgstr "FPING %s - %s (verloren=%.0f%% )|%s\n"
895 724
896#: plugins/check_fping.c:326 plugins/check_fping.c:332
897#: plugins/check_hpjd.c:338 plugins/check_hpjd.c:361 plugins/check_mysql.c:371
898#: plugins/check_mysql.c:455 plugins/check_ntp.c:709
899#: plugins/check_ntp_peer.c:497 plugins/check_ntp_time.c:496
900#: plugins/check_pgsql.c:335 plugins/check_ping.c:295 plugins/check_ping.c:418
901#: plugins/check_radius.c:264 plugins/check_real.c:314
902#: plugins/check_real.c:376 plugins/check_smtp.c:499 plugins/check_smtp.c:641
903#: plugins/check_ssh.c:157 plugins/check_time.c:240 plugins/check_time.c:315
904#: plugins/check_ups.c:504 plugins/check_ups.c:573
905msgid "Invalid hostname/address" 725msgid "Invalid hostname/address"
906msgstr "Ungültige(r) Hostname/Adresse" 726msgstr "Ungültige(r) Hostname/Adresse"
907 727
908#: plugins/check_fping.c:345 plugins/check_ldap.c:353 plugins/check_ping.c:246
909msgid "IPv6 support not available\n" 728msgid "IPv6 support not available\n"
910msgstr "" 729msgstr ""
911 730
912#: plugins/check_fping.c:378
913msgid "Packet size must be a positive integer" 731msgid "Packet size must be a positive integer"
914msgstr "Paketgröße muss ein positiver Integer sein" 732msgstr "Paketgröße muss ein positiver Integer sein"
915 733
916#: plugins/check_fping.c:384
917msgid "Packet count must be a positive integer" 734msgid "Packet count must be a positive integer"
918msgstr "Paketanzahl muss ein positiver Integer sein" 735msgstr "Paketanzahl muss ein positiver Integer sein"
919 736
920#: plugins/check_fping.c:390
921#, fuzzy 737#, fuzzy
922msgid "Target timeout must be a positive integer" 738msgid "Target timeout must be a positive integer"
923msgstr "Warnung time muss ein positiver Integer sein" 739msgstr "Warnung time muss ein positiver Integer sein"
924 740
925#: plugins/check_fping.c:396
926#, fuzzy 741#, fuzzy
927msgid "Interval must be a positive integer" 742msgid "Interval must be a positive integer"
928msgstr "Timeout interval muss ein positiver Integer sein" 743msgstr "Timeout interval muss ein positiver Integer sein"
929 744
930#: plugins/check_fping.c:402 plugins/check_ntp.c:733
931#: plugins/check_ntp_peer.c:524 plugins/check_ntp_time.c:523
932#: plugins/check_radius.c:314 plugins/check_time.c:319
933msgid "Hostname was not supplied" 745msgid "Hostname was not supplied"
934msgstr "" 746msgstr ""
935 747
936#: plugins/check_fping.c:422
937#, c-format 748#, c-format
938msgid "%s: Only one threshold may be packet loss (%s)\n" 749msgid "%s: Only one threshold may be packet loss (%s)\n"
939msgstr "%s: Nur ein Wert darf für paket loss angegeben werden (%s)\n" 750msgstr "%s: Nur ein Wert darf für packet loss angegeben werden (%s)\n"
940 751
941#: plugins/check_fping.c:426
942#, c-format 752#, c-format
943msgid "%s: Only one threshold must be packet loss (%s)\n" 753msgid "%s: Only one threshold must be packet loss (%s)\n"
944msgstr "%s: Nur ein Wert darf für paket loss angegeben werden (%s)\n" 754msgstr "%s: Nur ein Wert darf für packet loss angegeben werden (%s)\n"
945 755
946#: plugins/check_fping.c:458
947msgid "" 756msgid ""
948"This plugin will use the fping command to ping the specified host for a fast " 757"This plugin will use the fping command to ping the specified host for a fast "
949"check" 758"check"
950msgstr "" 759msgstr ""
951 760
952#: plugins/check_fping.c:460
953msgid "Note that it is necessary to set the suid flag on fping." 761msgid "Note that it is necessary to set the suid flag on fping."
954msgstr "" 762msgstr ""
955 763
956#: plugins/check_fping.c:472
957msgid "" 764msgid ""
958"name or IP Address of host to ping (IP Address bypasses name lookup, " 765"name or IP Address of host to ping (IP Address bypasses name lookup, "
959"reducing system load)" 766"reducing system load)"
960msgstr "" 767msgstr ""
961 768
962#: plugins/check_fping.c:474 plugins/check_ping.c:575
963#, fuzzy 769#, fuzzy
964msgid "warning threshold pair" 770msgid "warning threshold pair"
965msgstr "Warning threshold Integer sein" 771msgstr "Warning threshold Integer sein"
966 772
967#: plugins/check_fping.c:476 plugins/check_ping.c:577
968#, fuzzy 773#, fuzzy
969msgid "critical threshold pair" 774msgid "critical threshold pair"
970msgstr "Critical threshold muss ein Integer sein" 775msgstr "Critical threshold muss ein Integer sein"
971 776
972#: plugins/check_fping.c:478 777msgid "Return OK after first successful reply"
778msgstr ""
779
973msgid "size of ICMP packet" 780msgid "size of ICMP packet"
974msgstr "" 781msgstr ""
975 782
976#: plugins/check_fping.c:480
977msgid "number of ICMP packets to send" 783msgid "number of ICMP packets to send"
978msgstr "" 784msgstr ""
979 785
980#: plugins/check_fping.c:482
981msgid "Target timeout (ms)" 786msgid "Target timeout (ms)"
982msgstr "" 787msgstr ""
983 788
984#: plugins/check_fping.c:484
985msgid "Interval (ms) between sending packets" 789msgid "Interval (ms) between sending packets"
986msgstr "" 790msgstr ""
987 791
988#: plugins/check_fping.c:486
989msgid "name or IP Address of sourceip" 792msgid "name or IP Address of sourceip"
990msgstr "" 793msgstr ""
991 794
992#: plugins/check_fping.c:488
993msgid "source interface name" 795msgid "source interface name"
994msgstr "" 796msgstr ""
995 797
996#: plugins/check_fping.c:491
997#, c-format 798#, c-format
998msgid "" 799msgid ""
999"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time " 800"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time "
1000"(ms)" 801"(ms)"
1001msgstr "" 802msgstr ""
1002 803
1003#: plugins/check_fping.c:492
1004msgid "" 804msgid ""
1005"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of" 805"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of"
1006msgstr "" 806msgstr ""
1007 807
1008#: plugins/check_fping.c:493
1009msgid "packet loss to trigger an alarm state." 808msgid "packet loss to trigger an alarm state."
1010msgstr "" 809msgstr ""
1011 810
1012#: plugins/check_fping.c:496
1013msgid "IPv4 is used by default. Specify -6 to use IPv6." 811msgid "IPv4 is used by default. Specify -6 to use IPv6."
1014msgstr "" 812msgstr ""
1015 813
1016#: plugins/check_game.c:111
1017#, c-format 814#, c-format
1018msgid "CRITICAL - Host type parameter incorrect!\n" 815msgid "CRITICAL - Host type parameter incorrect!\n"
1019msgstr "CRITICAL - Host type parameter unkorrekt!\n" 816msgstr "CRITICAL - Host type parameter unkorrekt!\n"
1020 817
1021#: plugins/check_game.c:126
1022#, fuzzy, c-format 818#, fuzzy, c-format
1023msgid "CRITICAL - Host not found\n" 819msgid "CRITICAL - Host not found\n"
1024msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n" 820msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n"
1025 821
1026#: plugins/check_game.c:130
1027#, fuzzy, c-format 822#, fuzzy, c-format
1028msgid "CRITICAL - Game server down or unavailable\n" 823msgid "CRITICAL - Game server down or unavailable\n"
1029msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 824msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
1030 825
1031#: plugins/check_game.c:134
1032#, fuzzy, c-format 826#, fuzzy, c-format
1033msgid "CRITICAL - Game server timeout\n" 827msgid "CRITICAL - Game server timeout\n"
1034msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n" 828msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n"
1035 829
1036#: plugins/check_game.c:297
1037#, c-format 830#, c-format
1038msgid "This plugin tests game server connections with the specified host." 831msgid "This plugin tests game server connections with the specified host."
1039msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 832msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
1040 833
1041#: plugins/check_game.c:307
1042msgid "Optional port of which to connect" 834msgid "Optional port of which to connect"
1043msgstr "" 835msgstr ""
1044 836
1045#: plugins/check_game.c:309
1046msgid "Field number in raw qstat output that contains game name" 837msgid "Field number in raw qstat output that contains game name"
1047msgstr "" 838msgstr ""
1048 839
1049#: plugins/check_game.c:311
1050msgid "Field number in raw qstat output that contains map name" 840msgid "Field number in raw qstat output that contains map name"
1051msgstr "" 841msgstr ""
1052 842
1053#: plugins/check_game.c:313
1054msgid "Field number in raw qstat output that contains ping time" 843msgid "Field number in raw qstat output that contains ping time"
1055msgstr "" 844msgstr ""
1056 845
1057#: plugins/check_game.c:319
1058#, fuzzy 846#, fuzzy
1059msgid "" 847msgid ""
1060"This plugin uses the 'qstat' command, the popular game server status query " 848"This plugin uses the 'qstat' command, the popular game server status query "
1061"tool." 849"tool."
1062msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 850msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
1063 851
1064#: plugins/check_game.c:320
1065msgid "" 852msgid ""
1066"If you don't have the package installed, you will need to download it from" 853"If you don't have the package installed, you will need to download it from"
1067msgstr "" 854msgstr ""
1068 855
1069#: plugins/check_game.c:321 856msgid "https://github.com/multiplay/qstat before you can use this plugin."
1070msgid ""
1071"http://www.activesw.com/people/steve/qstat.html before you can use this "
1072"plugin."
1073msgstr "" 857msgstr ""
1074 858
1075#: plugins/check_hpjd.c:239
1076msgid "Paper Jam" 859msgid "Paper Jam"
1077msgstr "Papierstau" 860msgstr "Papierstau"
1078 861
1079#: plugins/check_hpjd.c:243
1080msgid "Out of Paper" 862msgid "Out of Paper"
1081msgstr "Kein Papier" 863msgstr "Kein Papier"
1082 864
1083#: plugins/check_hpjd.c:248
1084msgid "Printer Offline" 865msgid "Printer Offline"
1085msgstr "Drucker ausgeschaltet" 866msgstr "Drucker ausgeschaltet"
1086 867
1087#: plugins/check_hpjd.c:253
1088msgid "Peripheral Error" 868msgid "Peripheral Error"
1089msgstr "Peripheriefehler" 869msgstr "Peripheriefehler"
1090 870
1091#: plugins/check_hpjd.c:257
1092msgid "Intervention Required" 871msgid "Intervention Required"
1093msgstr "Eingriff benötigt" 872msgstr "Eingriff benötigt"
1094 873
1095#: plugins/check_hpjd.c:261
1096msgid "Toner Low" 874msgid "Toner Low"
1097msgstr "Wenig Toner" 875msgstr "Wenig Toner"
1098 876
1099#: plugins/check_hpjd.c:265
1100msgid "Insufficient Memory" 877msgid "Insufficient Memory"
1101msgstr "Nicht genügend Speicher" 878msgstr "Nicht genügend Speicher"
1102 879
1103#: plugins/check_hpjd.c:269
1104msgid "A Door is Open" 880msgid "A Door is Open"
1105msgstr "Eine Abdeckung ist offen" 881msgstr "Eine Abdeckung ist offen"
1106 882
1107#: plugins/check_hpjd.c:273
1108msgid "Output Tray is Full" 883msgid "Output Tray is Full"
1109msgstr "Ausgabeschacht ist voll" 884msgstr "Ausgabeschacht ist voll"
1110 885
1111#: plugins/check_hpjd.c:277
1112msgid "Data too Slow for Engine" 886msgid "Data too Slow for Engine"
1113msgstr "" 887msgstr ""
1114 888
1115#: plugins/check_hpjd.c:281
1116msgid "Unknown Paper Error" 889msgid "Unknown Paper Error"
1117msgstr "Papierfehler" 890msgstr "Papierfehler"
1118 891
1119#: plugins/check_hpjd.c:286
1120#, c-format 892#, c-format
1121msgid "Printer ok - (%s)\n" 893msgid "Printer ok - (%s)\n"
1122msgstr "Printer ok - (%s)\n" 894msgstr "Printer ok - (%s)\n"
1123 895
1124#: plugins/check_hpjd.c:391 896#, fuzzy
897msgid "Port must be a positive short integer"
898msgstr "Port muss ein positiver Integer sein"
899
1125#, fuzzy 900#, fuzzy
1126msgid "This plugin tests the STATUS of an HP printer with a JetDirect card." 901msgid "This plugin tests the STATUS of an HP printer with a JetDirect card."
1127msgstr "" 902msgstr ""
1128"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect " 903"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect "
1129"Karte.\n" 904"Karte.\n"
1130"Net-snmp muss auf dem ausführenden Computer installiert sein.\n" 905"Net-snmp muss auf dem ausführenden Computer installiert sein.\n"
1131"\n" 906"\n"
1132 907
1133#: plugins/check_hpjd.c:392
1134#, fuzzy 908#, fuzzy
1135msgid "Net-snmp must be installed on the computer running the plugin." 909msgid "Net-snmp must be installed on the computer running the plugin."
1136msgstr "" 910msgstr ""
1137"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect " 911"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect "
1138"Karte.\n" 912"Karte.\n"
1139"Net-snmp muss auf dem ausführenden Computer installiert sein.\n" 913"Net-snmp muss auf dem ausführenden Computer installiert sein.\n"
1140"\n" 914"\n"
1141 915
1142#: plugins/check_hpjd.c:402
1143msgid "The SNMP community name " 916msgid "The SNMP community name "
1144msgstr "" 917msgstr ""
1145 918
1146#: plugins/check_hpjd.c:403
1147#, c-format 919#, c-format
1148msgid "(default=%s)" 920msgid "(default=%s)"
1149msgstr "" 921msgstr ""
1150 922
1151#: plugins/check_http.c:189 923msgid "Specify the port to check "
924msgstr ""
925
926msgid "Disable paper check "
927msgstr ""
928
1152msgid "file does not exist or is not readable" 929msgid "file does not exist or is not readable"
1153msgstr "" 930msgstr ""
1154 931
1155#: plugins/check_http.c:310 plugins/check_http.c:315 plugins/check_http.c:321
1156#: plugins/check_smtp.c:600 plugins/check_tcp.c:576 plugins/check_tcp.c:580
1157#: plugins/check_tcp.c:586
1158msgid "Invalid certificate expiration period" 932msgid "Invalid certificate expiration period"
1159msgstr "Ungültiger Zertifikatsablauftermin" 933msgstr "Ungültiger Zertifikatsablauftermin"
1160 934
1161#: plugins/check_http.c:348
1162msgid "" 935msgid ""
1163"Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 " 936"Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional "
1164"(SSLv3)" 937"'+' suffix)"
1165msgstr "" 938msgstr ""
1166 939
1167#: plugins/check_http.c:354 plugins/check_tcp.c:599
1168#, fuzzy 940#, fuzzy
1169msgid "Invalid option - SSL is not available" 941msgid "Invalid option - SSL is not available"
1170msgstr "Ungültige Option - SSL ist nicht verfügbar\n" 942msgstr "Ungültige Option - SSL ist nicht verfügbar\n"
943
944msgid "Invalid max_redirs count"
945msgstr ""
1171 946
1172#: plugins/check_http.c:375
1173msgid "Invalid onredirect option" 947msgid "Invalid onredirect option"
1174msgstr "" 948msgstr ""
1175 949
1176#: plugins/check_http.c:377
1177#, c-format 950#, c-format
1178msgid "option f:%d \n" 951msgid "option f:%d \n"
1179msgstr "Option f:%d \n" 952msgstr "Option f:%d \n"
1180 953
1181#: plugins/check_http.c:398
1182msgid "Invalid port number" 954msgid "Invalid port number"
1183msgstr "Ungültige Portnummer" 955msgstr "Ungültige Portnummer"
1184 956
1185#: plugins/check_http.c:450
1186#, c-format 957#, c-format
1187msgid "Could Not Compile Regular Expression: %s" 958msgid "Could Not Compile Regular Expression: %s"
1188msgstr "" 959msgstr ""
1189 960
1190#: plugins/check_http.c:464 plugins/check_ntp.c:722
1191#: plugins/check_ntp_peer.c:513 plugins/check_ntp_time.c:512
1192#: plugins/check_smtp.c:621 plugins/check_ssh.c:149 plugins/check_tcp.c:477
1193msgid "IPv6 support not available" 961msgid "IPv6 support not available"
1194msgstr "IPv6 Unterstützung nicht vorhanden" 962msgstr "IPv6 Unterstützung nicht vorhanden"
1195 963
1196#: plugins/check_http.c:529 plugins/check_ping.c:422
1197msgid "You must specify a server address or host name" 964msgid "You must specify a server address or host name"
1198msgstr "Hostname oder Serveradresse muss angegeben werden" 965msgstr "Hostname oder Serveradresse muss angegeben werden"
1199 966
1200#: plugins/check_http.c:543
1201msgid "" 967msgid ""
1202"If you use a client certificate you must also specify a private key file" 968"If you use a client certificate you must also specify a private key file"
1203msgstr "" 969msgstr ""
1204 970
1205#: plugins/check_http.c:667 plugins/check_http.c:835
1206#, fuzzy 971#, fuzzy
1207msgid "HTTP UNKNOWN - Memory allocation error\n" 972msgid "HTTP UNKNOWN - Memory allocation error\n"
1208msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n" 973msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
1209 974
1210#: plugins/check_http.c:739
1211#, fuzzy, c-format 975#, fuzzy, c-format
1212msgid "%sServer date unknown, " 976msgid "%sServer date unknown, "
1213msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n" 977msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n"
1214 978
1215#: plugins/check_http.c:742
1216#, fuzzy, c-format 979#, fuzzy, c-format
1217msgid "%sDocument modification date unknown, " 980msgid "%sDocument modification date unknown, "
1218msgstr "HTTP CRITICAL - Datum der letzten Änderung unbekannt\n" 981msgstr "HTTP CRITICAL - Datum der letzten Änderung unbekannt\n"
1219 982
1220#: plugins/check_http.c:749
1221#, fuzzy, c-format 983#, fuzzy, c-format
1222msgid "%sServer date \"%100s\" unparsable, " 984msgid "%sServer date \"%100s\" unparsable, "
1223msgstr "HTTP CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 985msgstr "HTTP CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
1224 986
1225#: plugins/check_http.c:752
1226#, fuzzy, c-format 987#, fuzzy, c-format
1227msgid "%sDocument date \"%100s\" unparsable, " 988msgid "%sDocument date \"%100s\" unparsable, "
1228msgstr "" 989msgstr ""
1229"HTTP CRITICAL - Dokumentendatum \"%100s\" konnte nicht verarbeitet werden" 990"HTTP CRITICAL - Dokumentendatum \"%100s\" konnte nicht verarbeitet werden"
1230 991
1231#: plugins/check_http.c:755
1232#, fuzzy, c-format 992#, fuzzy, c-format
1233msgid "%sDocument is %d seconds in the future, " 993msgid "%sDocument is %d seconds in the future, "
1234msgstr "HTTP CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 994msgstr "HTTP CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
1235 995
1236#: plugins/check_http.c:760
1237#, fuzzy, c-format 996#, fuzzy, c-format
1238msgid "%sLast modified %.1f days ago, " 997msgid "%sLast modified %.1f days ago, "
1239msgstr "HTTP CRITICAL - Letzte Änderung vor %.1f Tagen\n" 998msgstr "HTTP CRITICAL - Letzte Änderung vor %.1f Tagen\n"
1240 999
1241#: plugins/check_http.c:763
1242#, fuzzy, c-format 1000#, fuzzy, c-format
1243msgid "%sLast modified %d:%02d:%02d ago, " 1001msgid "%sLast modified %d:%02d:%02d ago, "
1244msgstr "HTTP CRITICAL - Letzte Änderung vor %d:%02d:%02d \n" 1002msgstr "HTTP CRITICAL - Letzte Änderung vor %d:%02d:%02d \n"
1245 1003
1246#: plugins/check_http.c:876
1247msgid "HTTP CRITICAL - Unable to open TCP socket\n" 1004msgid "HTTP CRITICAL - Unable to open TCP socket\n"
1248msgstr "HTTP CRITICAL - Konnte TCP socket nicht öffnen\n" 1005msgstr "HTTP CRITICAL - Konnte TCP socket nicht öffnen\n"
1006
1007#, fuzzy
1008msgid "HTTP UNKNOWN - Could not allocate memory for full_page\n"
1009msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
1249 1010
1250#: plugins/check_http.c:995
1251msgid "HTTP CRITICAL - Error on receive\n" 1011msgid "HTTP CRITICAL - Error on receive\n"
1252msgstr "HTTP CRITICAL - Fehler beim Empfangen\n" 1012msgstr "HTTP CRITICAL - Fehler beim Empfangen\n"
1253 1013
1254#: plugins/check_http.c:1005
1255#, fuzzy 1014#, fuzzy
1256msgid "HTTP CRITICAL - No data received from host\n" 1015msgid "HTTP CRITICAL - No data received from host\n"
1257msgstr "HTTP CRITICAL - Keine Daten empfangen\n" 1016msgstr "HTTP CRITICAL - Keine Daten empfangen\n"
1258 1017
1259#: plugins/check_http.c:1056
1260#, fuzzy, c-format 1018#, fuzzy, c-format
1261msgid "Invalid HTTP response received from host: %s\n" 1019msgid "Invalid HTTP response received from host: %s\n"
1262msgstr "Ungültige HTTP Antwort von Host empfangen\n" 1020msgstr "Ungültige HTTP Antwort von Host empfangen\n"
1263 1021
1264#: plugins/check_http.c:1060
1265#, fuzzy, c-format 1022#, fuzzy, c-format
1266msgid "Invalid HTTP response received from host on port %d: %s\n" 1023msgid "Invalid HTTP response received from host on port %d: %s\n"
1267msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 1024msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
1025
1026#, c-format
1027msgid ""
1028"%s\n"
1029"%s"
1030msgstr ""
1268 1031
1269#: plugins/check_http.c:1069
1270#, fuzzy, c-format 1032#, fuzzy, c-format
1271msgid "Status line output matched \"%s\" - " 1033msgid "Status line output matched \"%s\" - "
1272msgstr "HTTP OK: Statusausgabe passt auf \"%s\"\n" 1034msgstr "HTTP OK: Statusausgabe passt auf \"%s\"\n"
1273 1035
1274#: plugins/check_http.c:1080
1275#, c-format 1036#, c-format
1276msgid "HTTP CRITICAL: Invalid Status Line (%s)\n" 1037msgid "HTTP CRITICAL: Invalid Status Line (%s)\n"
1277msgstr "HTTP CRITICAL: Ungültige Statusmeldung (%s)\n" 1038msgstr "HTTP CRITICAL: Ungültige Statusmeldung (%s)\n"
1278 1039
1279#: plugins/check_http.c:1087
1280#, c-format 1040#, c-format
1281msgid "HTTP CRITICAL: Invalid Status (%s)\n" 1041msgid "HTTP CRITICAL: Invalid Status (%s)\n"
1282msgstr "HTTP CRITICAL: Ungültiger Status (%s)\n" 1042msgstr "HTTP CRITICAL: Ungültiger Status (%s)\n"
1283 1043
1284#: plugins/check_http.c:1091 plugins/check_http.c:1096
1285#: plugins/check_http.c:1106 plugins/check_http.c:1110
1286#, c-format 1044#, c-format
1287msgid "%s - " 1045msgid "%s - "
1288msgstr "" 1046msgstr ""
1289 1047
1290#: plugins/check_http.c:1129
1291#, fuzzy, c-format 1048#, fuzzy, c-format
1292msgid "%sheader '%s' not found on '%s://%s:%d%s', " 1049msgid "%sheader '%s' not found on '%s://%s:%d%s', "
1293msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1050msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1294 1051
1295#: plugins/check_http.c:1141
1296#, fuzzy, c-format 1052#, fuzzy, c-format
1297msgid "%sstring '%s' not found on '%s://%s:%d%s', " 1053msgid "%sstring '%s' not found on '%s://%s:%d%s', "
1298msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1054msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1299 1055
1300#: plugins/check_http.c:1154
1301#, fuzzy, c-format 1056#, fuzzy, c-format
1302msgid "%spattern not found, " 1057msgid "%spattern not found, "
1303msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1058msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1304 1059
1305#: plugins/check_http.c:1156
1306#, fuzzy, c-format 1060#, fuzzy, c-format
1307msgid "%spattern found, " 1061msgid "%spattern found, "
1308msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1062msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1309 1063
1310#: plugins/check_http.c:1162
1311#, fuzzy, c-format 1064#, fuzzy, c-format
1312msgid "%sExecute Error: %s, " 1065msgid "%sExecute Error: %s, "
1313msgstr "HTTP CRITICAL - Fehler: %s\n" 1066msgstr "HTTP CRITICAL - Fehler: %s\n"
1314 1067
1315#: plugins/check_http.c:1178
1316#, fuzzy, c-format 1068#, fuzzy, c-format
1317msgid "%spage size %d too large, " 1069msgid "%spage size %d too large, "
1318msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n" 1070msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n"
1319 1071
1320#: plugins/check_http.c:1181
1321#, fuzzy, c-format 1072#, fuzzy, c-format
1322msgid "%spage size %d too small, " 1073msgid "%spage size %d too small, "
1323msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n" 1074msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n"
1324 1075
1325#: plugins/check_http.c:1194
1326#, fuzzy, c-format 1076#, fuzzy, c-format
1327msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s" 1077msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"
1328msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n" 1078msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n"
1329 1079
1330#: plugins/check_http.c:1206
1331#, fuzzy, c-format 1080#, fuzzy, c-format
1332msgid "%s - %d bytes in %.3f second response time %s|%s %s" 1081msgid "%s - %d bytes in %.3f second response time %s|%s %s"
1333msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n" 1082msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n"
1334 1083
1335#: plugins/check_http.c:1244
1336msgid "HTTP UNKNOWN - Could not allocate addr\n" 1084msgid "HTTP UNKNOWN - Could not allocate addr\n"
1337msgstr "HTTP UNKNOWN - Konnte addr nicht zuweisen\n" 1085msgstr "HTTP UNKNOWN - Konnte addr nicht zuweisen\n"
1338 1086
1339#: plugins/check_http.c:1248 plugins/check_http.c:1279
1340#, fuzzy 1087#, fuzzy
1341msgid "HTTP UNKNOWN - Could not allocate URL\n" 1088msgid "HTTP UNKNOWN - Could not allocate URL\n"
1342msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n" 1089msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
1343 1090
1344#: plugins/check_http.c:1257
1345#, c-format 1091#, c-format
1346msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n" 1092msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n"
1347msgstr "" 1093msgstr ""
1348 1094
1349#: plugins/check_http.c:1272
1350#, fuzzy, c-format 1095#, fuzzy, c-format
1351msgid "HTTP UNKNOWN - Empty redirect location%s\n" 1096msgid "HTTP UNKNOWN - Empty redirect location%s\n"
1352msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n" 1097msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n"
1353 1098
1354#: plugins/check_http.c:1322
1355#, c-format 1099#, c-format
1356msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n" 1100msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n"
1357msgstr "" 1101msgstr ""
1358 1102
1359#: plugins/check_http.c:1332
1360#, fuzzy, c-format 1103#, fuzzy, c-format
1361msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n" 1104msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n"
1362msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n" 1105msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n"
1363 1106
1364#: plugins/check_http.c:1340 1107#, fuzzy, c-format
1365#, c-format 1108msgid "HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1366msgid "HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1367msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n" 1109msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n"
1368 1110
1369#: plugins/check_http.c:1361
1370#, fuzzy, c-format 1111#, fuzzy, c-format
1371msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n" 1112msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"
1372msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n" 1113msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n"
1373 1114
1374#: plugins/check_http.c:1366
1375#, c-format 1115#, c-format
1376msgid "Redirection to %s://%s:%d%s\n" 1116msgid "Redirection to %s://%s:%d%s\n"
1377msgstr "" 1117msgstr ""
1378 1118
1379#: plugins/check_http.c:1440
1380#, fuzzy 1119#, fuzzy
1381msgid "This plugin tests the HTTP service on the specified host. It can test" 1120msgid "This plugin tests the HTTP service on the specified host. It can test"
1382msgstr "" 1121msgstr ""
1383"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 1122"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
1384"\n" 1123"\n"
1385 1124
1386#: plugins/check_http.c:1441
1387msgid "normal (http) and secure (https) servers, follow redirects, search for" 1125msgid "normal (http) and secure (https) servers, follow redirects, search for"
1388msgstr "" 1126msgstr ""
1389 1127
1390#: plugins/check_http.c:1442
1391msgid "strings and regular expressions, check connection times, and report on" 1128msgid "strings and regular expressions, check connection times, and report on"
1392msgstr "" 1129msgstr ""
1393 1130
1394#: plugins/check_http.c:1443
1395#, fuzzy 1131#, fuzzy
1396msgid "certificate expiration times." 1132msgid "certificate expiration times."
1397msgstr "Clientzertifikat benötigt\n" 1133msgstr "Clientzertifikat benötigt\n"
1134
1135#, c-format
1136msgid "In the first form, make an HTTP request."
1137msgstr ""
1138
1139#, c-format
1140msgid ""
1141"In the second form, connect to the server and check the TLS certificate."
1142msgstr ""
1398 1143
1399#: plugins/check_http.c:1449
1400#, c-format 1144#, c-format
1401msgid "NOTE: One or both of -H and -I must be specified" 1145msgid "NOTE: One or both of -H and -I must be specified"
1402msgstr "" 1146msgstr ""
1403 1147
1404#: plugins/check_http.c:1457
1405msgid "Host name argument for servers using host headers (virtual host)" 1148msgid "Host name argument for servers using host headers (virtual host)"
1406msgstr "" 1149msgstr ""
1407 1150
1408#: plugins/check_http.c:1458
1409msgid "Append a port to include it in the header (eg: example.com:5000)" 1151msgid "Append a port to include it in the header (eg: example.com:5000)"
1410msgstr "" 1152msgstr ""
1411 1153
1412#: plugins/check_http.c:1460
1413msgid "" 1154msgid ""
1414"IP address or name (use numeric address if possible to bypass DNS lookup)." 1155"IP address or name (use numeric address if possible to bypass DNS lookup)."
1415msgstr "" 1156msgstr ""
1416 1157
1417#: plugins/check_http.c:1462
1418msgid "Port number (default: " 1158msgid "Port number (default: "
1419msgstr "" 1159msgstr ""
1420 1160
1421#: plugins/check_http.c:1469
1422msgid "" 1161msgid ""
1423"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents" 1162"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"
1424msgstr "" 1163msgstr ""
1425 1164
1426#: plugins/check_http.c:1470 1165msgid "auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"
1427msgid "auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3)." 1166msgstr ""
1167
1168msgid "1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted."
1428msgstr "" 1169msgstr ""
1429 1170
1430#: plugins/check_http.c:1472
1431msgid "Enable SSL/TLS hostname extension support (SNI)" 1171msgid "Enable SSL/TLS hostname extension support (SNI)"
1432msgstr "" 1172msgstr ""
1433 1173
1434#: plugins/check_http.c:1474
1435msgid "" 1174msgid ""
1436"Minimum number of days a certificate has to be valid. Port defaults to 443" 1175"Minimum number of days a certificate has to be valid. Port defaults to 443"
1437msgstr "" 1176msgstr ""
1438 1177
1439#: plugins/check_http.c:1475 1178msgid ""
1440msgid "(when this option is used the URL is not checked.)" 1179"(when this option is used the URL is not checked by default. You can use"
1180msgstr ""
1181
1182msgid " --continue-after-certificate to override this behavior)"
1183msgstr ""
1184
1185msgid ""
1186"Allows the HTTP check to continue after performing the certificate check."
1187msgstr ""
1188
1189msgid "Does nothing unless -C is used."
1441msgstr "" 1190msgstr ""
1442 1191
1443#: plugins/check_http.c:1477
1444msgid "Name of file that contains the client certificate (PEM format)" 1192msgid "Name of file that contains the client certificate (PEM format)"
1445msgstr "" 1193msgstr ""
1446 1194
1447#: plugins/check_http.c:1478
1448msgid "to be used in establishing the SSL session" 1195msgid "to be used in establishing the SSL session"
1449msgstr "" 1196msgstr ""
1450 1197
1451#: plugins/check_http.c:1480
1452msgid "Name of file containing the private key (PEM format)" 1198msgid "Name of file containing the private key (PEM format)"
1453msgstr "" 1199msgstr ""
1454 1200
1455#: plugins/check_http.c:1481
1456msgid "matching the client certificate" 1201msgid "matching the client certificate"
1457msgstr "" 1202msgstr ""
1458 1203
1459#: plugins/check_http.c:1485
1460msgid "Comma-delimited list of strings, at least one of them is expected in" 1204msgid "Comma-delimited list of strings, at least one of them is expected in"
1461msgstr "" 1205msgstr ""
1462 1206
1463#: plugins/check_http.c:1486
1464msgid "the first (status) line of the server response (default: " 1207msgid "the first (status) line of the server response (default: "
1465msgstr "" 1208msgstr ""
1466 1209
1467#: plugins/check_http.c:1488
1468msgid "" 1210msgid ""
1469"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)" 1211"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"
1470msgstr "" 1212msgstr ""
1471 1213
1472#: plugins/check_http.c:1490
1473msgid "String to expect in the response headers" 1214msgid "String to expect in the response headers"
1474msgstr "" 1215msgstr ""
1475 1216
1476#: plugins/check_http.c:1492
1477msgid "String to expect in the content" 1217msgid "String to expect in the content"
1478msgstr "" 1218msgstr ""
1479 1219
1480#: plugins/check_http.c:1494
1481msgid "URL to GET or POST (default: /)" 1220msgid "URL to GET or POST (default: /)"
1482msgstr "" 1221msgstr ""
1483 1222
1484#: plugins/check_http.c:1496
1485msgid "URL encoded http POST data" 1223msgid "URL encoded http POST data"
1486msgstr "" 1224msgstr ""
1487 1225
1488#: plugins/check_http.c:1498
1489msgid "Set HTTP method." 1226msgid "Set HTTP method."
1490msgstr "" 1227msgstr ""
1491 1228
1492#: plugins/check_http.c:1500
1493msgid "Don't wait for document body: stop reading after headers." 1229msgid "Don't wait for document body: stop reading after headers."
1494msgstr "" 1230msgstr ""
1495 1231
1496#: plugins/check_http.c:1501
1497msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)" 1232msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)"
1498msgstr "" 1233msgstr ""
1499 1234
1500#: plugins/check_http.c:1503
1501msgid "Warn if document is more than SECONDS old. the number can also be of" 1235msgid "Warn if document is more than SECONDS old. the number can also be of"
1502msgstr "" 1236msgstr ""
1503 1237
1504#: plugins/check_http.c:1504
1505msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days." 1238msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."
1506msgstr "" 1239msgstr ""
1507 1240
1508#: plugins/check_http.c:1506
1509msgid "specify Content-Type header media type when POSTing\n" 1241msgid "specify Content-Type header media type when POSTing\n"
1510msgstr "" 1242msgstr ""
1511 1243
1512#: plugins/check_http.c:1509
1513msgid "Allow regex to span newlines (must precede -r or -R)" 1244msgid "Allow regex to span newlines (must precede -r or -R)"
1514msgstr "" 1245msgstr ""
1515 1246
1516#: plugins/check_http.c:1511
1517msgid "Search page for regex STRING" 1247msgid "Search page for regex STRING"
1518msgstr "" 1248msgstr ""
1519 1249
1520#: plugins/check_http.c:1513
1521msgid "Search page for case-insensitive regex STRING" 1250msgid "Search page for case-insensitive regex STRING"
1522msgstr "" 1251msgstr ""
1523 1252
1524#: plugins/check_http.c:1515
1525msgid "Return CRITICAL if found, OK if not\n" 1253msgid "Return CRITICAL if found, OK if not\n"
1526msgstr "" 1254msgstr ""
1527 1255
1528#: plugins/check_http.c:1518
1529msgid "Username:password on sites with basic authentication" 1256msgid "Username:password on sites with basic authentication"
1530msgstr "" 1257msgstr ""
1531 1258
1532#: plugins/check_http.c:1520
1533msgid "Username:password on proxy-servers with basic authentication" 1259msgid "Username:password on proxy-servers with basic authentication"
1534msgstr "" 1260msgstr ""
1535 1261
1536#: plugins/check_http.c:1522
1537msgid "String to be sent in http header as \"User Agent\"" 1262msgid "String to be sent in http header as \"User Agent\""
1538msgstr "" 1263msgstr ""
1539 1264
1540#: plugins/check_http.c:1524
1541msgid "" 1265msgid ""
1542"Any other tags to be sent in http header. Use multiple times for additional " 1266"Any other tags to be sent in http header. Use multiple times for additional "
1543"headers" 1267"headers"
1544msgstr "" 1268msgstr ""
1545 1269
1546#: plugins/check_http.c:1526
1547msgid "Print additional performance data" 1270msgid "Print additional performance data"
1548msgstr "" 1271msgstr ""
1549 1272
1550#: plugins/check_http.c:1528 1273msgid "Print body content below status line"
1274msgstr ""
1275
1551msgid "Wrap output in HTML link (obsoleted by urlize)" 1276msgid "Wrap output in HTML link (obsoleted by urlize)"
1552msgstr "" 1277msgstr ""
1553 1278
1554#: plugins/check_http.c:1530
1555msgid "How to handle redirected pages. sticky is like follow but stick to the" 1279msgid "How to handle redirected pages. sticky is like follow but stick to the"
1556msgstr "" 1280msgstr ""
1557 1281
1558#: plugins/check_http.c:1531
1559msgid "specified IP address. stickyport also ensures port stays the same." 1282msgid "specified IP address. stickyport also ensures port stays the same."
1560msgstr "" 1283msgstr ""
1561 1284
1562#: plugins/check_http.c:1533 1285#, fuzzy
1286msgid "Maximal number of redirects (default: "
1287msgstr "Ungültige Portnummer"
1288
1563msgid "Minimum page size required (bytes) : Maximum page size required (bytes)" 1289msgid "Minimum page size required (bytes) : Maximum page size required (bytes)"
1564msgstr "" 1290msgstr ""
1565 1291
1566#: plugins/check_http.c:1543
1567#, fuzzy 1292#, fuzzy
1568msgid "This plugin will attempt to open an HTTP connection with the host." 1293msgid "This plugin will attempt to open an HTTP connection with the host."
1569msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 1294msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
1570 1295
1571#: plugins/check_http.c:1544
1572msgid "" 1296msgid ""
1573"Successful connects return STATE_OK, refusals and timeouts return " 1297"Successful connects return STATE_OK, refusals and timeouts return "
1574"STATE_CRITICAL" 1298"STATE_CRITICAL"
1575msgstr "" 1299msgstr ""
1576 1300
1577#: plugins/check_http.c:1545
1578msgid "" 1301msgid ""
1579"other errors return STATE_UNKNOWN. Successful connects, but incorrect " 1302"other errors return STATE_UNKNOWN. Successful connects, but incorrect "
1580"reponse" 1303"response"
1581msgstr "" 1304msgstr ""
1582 1305
1583#: plugins/check_http.c:1546
1584msgid "" 1306msgid ""
1585"messages from the host result in STATE_WARNING return values. If you are" 1307"messages from the host result in STATE_WARNING return values. If you are"
1586msgstr "" 1308msgstr ""
1587 1309
1588#: plugins/check_http.c:1547
1589msgid "" 1310msgid ""
1590"checking a virtual server that uses 'host headers' you must supply the FQDN" 1311"checking a virtual server that uses 'host headers' you must supply the FQDN"
1591msgstr "" 1312msgstr ""
1592 1313
1593#: plugins/check_http.c:1548
1594msgid "(fully qualified domain name) as the [host_name] argument." 1314msgid "(fully qualified domain name) as the [host_name] argument."
1595msgstr "" 1315msgstr ""
1596 1316
1597#: plugins/check_http.c:1552
1598msgid "This plugin can also check whether an SSL enabled web server is able to" 1317msgid "This plugin can also check whether an SSL enabled web server is able to"
1599msgstr "" 1318msgstr ""
1600 1319
1601#: plugins/check_http.c:1553
1602msgid "serve content (optionally within a specified time) or whether the X509 " 1320msgid "serve content (optionally within a specified time) or whether the X509 "
1603msgstr "" 1321msgstr ""
1604 1322
1605#: plugins/check_http.c:1554
1606msgid "certificate is still valid for the specified number of days." 1323msgid "certificate is still valid for the specified number of days."
1607msgstr "" 1324msgstr ""
1608 1325
1609#: plugins/check_http.c:1556
1610#, fuzzy 1326#, fuzzy
1611msgid "Please note that this plugin does not check if the presented server" 1327msgid "Please note that this plugin does not check if the presented server"
1612msgstr "" 1328msgstr ""
1613"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 1329"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
1614"\n" 1330"\n"
1615 1331
1616#: plugins/check_http.c:1557
1617msgid "certificate matches the hostname of the server, or if the certificate" 1332msgid "certificate matches the hostname of the server, or if the certificate"
1618msgstr "" 1333msgstr ""
1619 1334
1620#: plugins/check_http.c:1558
1621msgid "has a valid chain of trust to one of the locally installed CAs." 1335msgid "has a valid chain of trust to one of the locally installed CAs."
1622msgstr "" 1336msgstr ""
1623 1337
1624#: plugins/check_http.c:1562
1625msgid "" 1338msgid ""
1626"When the 'www.verisign.com' server returns its content within 5 seconds," 1339"When the 'www.verisign.com' server returns its content within 5 seconds,"
1627msgstr "" 1340msgstr ""
1628 1341
1629#: plugins/check_http.c:1563
1630msgid "" 1342msgid ""
1631"a STATE_OK will be returned. When the server returns its content but exceeds" 1343"a STATE_OK will be returned. When the server returns its content but exceeds"
1632msgstr "" 1344msgstr ""
1633 1345
1634#: plugins/check_http.c:1564
1635msgid "" 1346msgid ""
1636"the 5-second threshold, a STATE_WARNING will be returned. When an error " 1347"the 5-second threshold, a STATE_WARNING will be returned. When an error "
1637"occurs," 1348"occurs,"
1638msgstr "" 1349msgstr ""
1639 1350
1640#: plugins/check_http.c:1565
1641msgid "a STATE_CRITICAL will be returned." 1351msgid "a STATE_CRITICAL will be returned."
1642msgstr "" 1352msgstr ""
1643 1353
1644#: plugins/check_http.c:1568
1645msgid "" 1354msgid ""
1646"When the certificate of 'www.verisign.com' is valid for more than 14 days," 1355"When the certificate of 'www.verisign.com' is valid for more than 14 days,"
1647msgstr "" 1356msgstr ""
1648 1357
1649#: plugins/check_http.c:1569 plugins/check_http.c:1575
1650msgid "" 1358msgid ""
1651"a STATE_OK is returned. When the certificate is still valid, but for less " 1359"a STATE_OK is returned. When the certificate is still valid, but for less "
1652"than" 1360"than"
1653msgstr "" 1361msgstr ""
1654 1362
1655#: plugins/check_http.c:1570
1656msgid "" 1363msgid ""
1657"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when" 1364"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"
1658msgstr "" 1365msgstr ""
1659 1366
1660#: plugins/check_http.c:1571
1661#, fuzzy 1367#, fuzzy
1662msgid "the certificate is expired." 1368msgid "the certificate is expired."
1663msgstr "Clientzertifikat benötigt\n" 1369msgstr "Clientzertifikat benötigt\n"
1664 1370
1665#: plugins/check_http.c:1574
1666msgid "" 1371msgid ""
1667"When the certificate of 'www.verisign.com' is valid for more than 30 days," 1372"When the certificate of 'www.verisign.com' is valid for more than 30 days,"
1668msgstr "" 1373msgstr ""
1669 1374
1670#: plugins/check_http.c:1576
1671msgid "30 days, but more than 14 days, a STATE_WARNING is returned." 1375msgid "30 days, but more than 14 days, a STATE_WARNING is returned."
1672msgstr "" 1376msgstr ""
1673 1377
1674#: plugins/check_http.c:1577
1675msgid "" 1378msgid ""
1676"A STATE_CRITICAL will be returned when certificate expires in less than 14 " 1379"A STATE_CRITICAL will be returned when certificate expires in less than 14 "
1677"days" 1380"days"
1678msgstr "" 1381msgstr ""
1679 1382
1680#: plugins/check_ldap.c:133 1383msgid ""
1384"check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j "
1385"CONNECT -H www.verisign.com "
1386msgstr ""
1387
1388msgid ""
1389"all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -"
1390"S(sl) -j CONNECT -H <webserver>"
1391msgstr ""
1392
1393msgid ""
1394"a STATE_CRITICAL will be returned. By adding a colon to the method you can "
1395"set the method used"
1396msgstr ""
1397
1398msgid "inside the proxied connection: -j CONNECT:POST"
1399msgstr ""
1400
1681#, c-format 1401#, c-format
1682msgid "Could not connect to the server at port %i\n" 1402msgid "Could not connect to the server at port %i\n"
1683msgstr "" 1403msgstr ""
1684 1404
1685#: plugins/check_ldap.c:142
1686#, c-format 1405#, c-format
1687msgid "Could not set protocol version %d\n" 1406msgid "Could not set protocol version %d\n"
1688msgstr "" 1407msgstr ""
1689 1408
1690#: plugins/check_ldap.c:157
1691#, fuzzy, c-format 1409#, fuzzy, c-format
1692msgid "Could not init TLS at port %i!\n" 1410msgid "Could not init TLS at port %i!\n"
1693msgstr "Konnte stderr nicht öffnen für: %s\n" 1411msgstr "Konnte stderr nicht öffnen für: %s\n"
1694 1412
1695#: plugins/check_ldap.c:161
1696#, c-format 1413#, c-format
1697msgid "TLS not supported by the libraries!\n" 1414msgid "TLS not supported by the libraries!\n"
1698msgstr "" 1415msgstr ""
1699 1416
1700#: plugins/check_ldap.c:181
1701#, fuzzy, c-format 1417#, fuzzy, c-format
1702msgid "Could not init startTLS at port %i!\n" 1418msgid "Could not init startTLS at port %i!\n"
1703msgstr "Konnte stderr nicht öffnen für: %s\n" 1419msgstr "Konnte stderr nicht öffnen für: %s\n"
1704 1420
1705#: plugins/check_ldap.c:185
1706#, c-format 1421#, c-format
1707msgid "startTLS not supported by the library, needs LDAPv3!\n" 1422msgid "startTLS not supported by the library, needs LDAPv3!\n"
1708msgstr "" 1423msgstr ""
1709 1424
1710#: plugins/check_ldap.c:195
1711#, c-format 1425#, c-format
1712msgid "Could not bind to the LDAP server\n" 1426msgid "Could not bind to the LDAP server\n"
1713msgstr "" 1427msgstr ""
1714 1428
1715#: plugins/check_ldap.c:204
1716#, c-format 1429#, c-format
1717msgid "Could not search/find objectclasses in %s\n" 1430msgid "Could not search/find objectclasses in %s\n"
1718msgstr "" 1431msgstr ""
1719 1432
1720#: plugins/check_ldap.c:227 1433#, fuzzy, c-format
1434msgid "LDAP %s - found %d entries in %.3f seconds|%s %s\n"
1435msgstr "HTTP OK %s - %.3f Sekunde Antwortzeit %s%s|%s %s\n"
1436
1721#, c-format 1437#, c-format
1722msgid "LDAP %s - %.3f seconds response time|%s\n" 1438msgid "LDAP %s - %.3f seconds response time|%s\n"
1723msgstr "" 1439msgstr ""
1724 1440
1725#: plugins/check_ldap.c:339 plugins/check_ldap.c:347
1726#, c-format 1441#, c-format
1727msgid "%s cannot be combined with %s" 1442msgid "%s cannot be combined with %s"
1728msgstr "" 1443msgstr ""
1729 1444
1730#: plugins/check_ldap.c:379
1731msgid "Please specify the host name\n" 1445msgid "Please specify the host name\n"
1732msgstr "" 1446msgstr ""
1733 1447
1734#: plugins/check_ldap.c:382
1735msgid "Please specify the LDAP base\n" 1448msgid "Please specify the LDAP base\n"
1736msgstr "" 1449msgstr ""
1737 1450
1738#: plugins/check_ldap.c:411
1739msgid "ldap attribute to search (default: \"(objectclass=*)\"" 1451msgid "ldap attribute to search (default: \"(objectclass=*)\""
1740msgstr "" 1452msgstr ""
1741 1453
1742#: plugins/check_ldap.c:413
1743msgid "ldap base (eg. ou=my unit, o=my org, c=at" 1454msgid "ldap base (eg. ou=my unit, o=my org, c=at"
1744msgstr "" 1455msgstr ""
1745 1456
1746#: plugins/check_ldap.c:415
1747msgid "ldap bind DN (if required)" 1457msgid "ldap bind DN (if required)"
1748msgstr "" 1458msgstr ""
1749 1459
1750#: plugins/check_ldap.c:417 1460msgid ""
1751msgid "ldap password (if required)" 1461"ldap password (if required, or set the password through environment variable "
1462"'LDAP_PASSWORD')"
1752msgstr "" 1463msgstr ""
1753 1464
1754#: plugins/check_ldap.c:419
1755msgid "use starttls mechanism introduced in protocol version 3" 1465msgid "use starttls mechanism introduced in protocol version 3"
1756msgstr "" 1466msgstr ""
1757 1467
1758#: plugins/check_ldap.c:421
1759msgid "use ldaps (ldap v2 ssl method). this also sets the default port to" 1468msgid "use ldaps (ldap v2 ssl method). this also sets the default port to"
1760msgstr "" 1469msgstr ""
1761 1470
1762#: plugins/check_ldap.c:425
1763msgid "use ldap protocol version 2" 1471msgid "use ldap protocol version 2"
1764msgstr "" 1472msgstr ""
1765 1473
1766#: plugins/check_ldap.c:427
1767msgid "use ldap protocol version 3" 1474msgid "use ldap protocol version 3"
1768msgstr "" 1475msgstr ""
1769 1476
1770#: plugins/check_ldap.c:428
1771msgid "default protocol version:" 1477msgid "default protocol version:"
1772msgstr "" 1478msgstr ""
1773 1479
1774#: plugins/check_ldap.c:439 1480msgid "Number of found entries to result in warning status"
1481msgstr ""
1482
1483msgid "Number of found entries to result in critical status"
1484msgstr ""
1485
1775msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be" 1486msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be"
1776msgstr "" 1487msgstr ""
1777 1488
1778#: plugins/check_ldap.c:440
1779#, c-format 1489#, c-format
1780msgid "" 1490msgid ""
1781" implied (using default port %i) unless --port=636 is specified. In that " 1491" implied (using default port %i) unless --port=636 is specified. In that "
1782"case\n" 1492"case\n"
1783msgstr "" 1493msgstr ""
1784 1494
1785#: plugins/check_ldap.c:441
1786msgid "'SSL on connect' will be used no matter how the plugin was called." 1495msgid "'SSL on connect' will be used no matter how the plugin was called."
1787msgstr "" 1496msgstr ""
1788 1497
1789#: plugins/check_ldap.c:442
1790msgid "" 1498msgid ""
1791"This detection is deprecated, please use 'check_ldap' with the '--starttls' " 1499"This detection is deprecated, please use 'check_ldap' with the '--starttls' "
1792"or '--ssl' flags" 1500"or '--ssl' flags"
1793msgstr "" 1501msgstr ""
1794 1502
1795#: plugins/check_ldap.c:443
1796msgid "to define the behaviour explicitly instead." 1503msgid "to define the behaviour explicitly instead."
1797msgstr "" 1504msgstr ""
1798 1505
1799#: plugins/check_load.c:87 1506msgid "The parameters --warn-entries and --crit-entries are optional."
1507msgstr ""
1508
1800msgid "Warning threshold must be float or float triplet!\n" 1509msgid "Warning threshold must be float or float triplet!\n"
1801msgstr "" 1510msgstr ""
1802 1511
1803#: plugins/check_load.c:132 plugins/check_load.c:148
1804#, c-format 1512#, c-format
1805msgid "Error opening %s\n" 1513msgid "Error opening %s\n"
1806msgstr "" 1514msgstr ""
1807 1515
1808#: plugins/check_load.c:163
1809#, fuzzy, c-format 1516#, fuzzy, c-format
1810msgid "could not parse load from uptime: %s\n" 1517msgid "could not parse load from uptime %s: %d\n"
1811msgstr "Argumente konnten nicht ausgewertet werden" 1518msgstr "Argumente konnten nicht ausgewertet werden"
1812 1519
1813#: plugins/check_load.c:169
1814#, c-format 1520#, c-format
1815msgid "Error code %d returned in %s\n" 1521msgid "Error code %d returned in %s\n"
1816msgstr "" 1522msgstr ""
1817 1523
1818#: plugins/check_load.c:184
1819#, c-format 1524#, c-format
1820msgid "Error in getloadavg()\n" 1525msgid "Error in getloadavg()\n"
1821msgstr "" 1526msgstr ""
1822 1527
1823#: plugins/check_load.c:187 plugins/check_load.c:189
1824#, c-format 1528#, c-format
1825msgid "Error processing %s\n" 1529msgid "Error processing %s\n"
1826msgstr "" 1530msgstr ""
1827 1531
1828#: plugins/check_load.c:198
1829#, c-format 1532#, c-format
1830msgid "load average: %.2f, %.2f, %.2f" 1533msgid "load average: %.2f, %.2f, %.2f"
1831msgstr "" 1534msgstr ""
1832 1535
1833#: plugins/check_load.c:291
1834#, fuzzy, c-format 1536#, fuzzy, c-format
1835msgid "Critical threshold for %d-minute load average is not specified\n" 1537msgid "Critical threshold for %d-minute load average is not specified\n"
1836msgstr "Critical threshold muss ein positiver Integer sein\n" 1538msgstr "Critical threshold muss ein positiver Integer sein\n"
1837 1539
1838#: plugins/check_load.c:293
1839#, fuzzy, c-format 1540#, fuzzy, c-format
1840msgid "Warning threshold for %d-minute load average is not specified\n" 1541msgid "Warning threshold for %d-minute load average is not specified\n"
1841msgstr "Warning threshold muss ein positiver Integer sein\n" 1542msgstr "Warning threshold muss ein positiver Integer sein\n"
1842 1543
1843#: plugins/check_load.c:295
1844#, c-format 1544#, c-format
1845msgid "" 1545msgid ""
1846"Parameter inconsistency: %d-minute \"warning load\" is greater than " 1546"Parameter inconsistency: %d-minute \"warning load\" is greater than "
1847"\"critical load\"\n" 1547"\"critical load\"\n"
1848msgstr "" 1548msgstr ""
1849 1549
1850#: plugins/check_load.c:311
1851#, c-format 1550#, c-format
1852msgid "This plugin tests the current system load average." 1551msgid "This plugin tests the current system load average."
1853msgstr "" 1552msgstr ""
1854 1553
1855#: plugins/check_load.c:321
1856msgid "Exit with WARNING status if load average exceeds WLOADn" 1554msgid "Exit with WARNING status if load average exceeds WLOADn"
1857msgstr "" 1555msgstr ""
1858 1556
1859#: plugins/check_load.c:323
1860msgid "Exit with CRITICAL status if load average exceed CLOADn" 1557msgid "Exit with CRITICAL status if load average exceed CLOADn"
1861msgstr "" 1558msgstr ""
1862 1559
1863#: plugins/check_load.c:324
1864msgid "the load average format is the same used by \"uptime\" and \"w\"" 1560msgid "the load average format is the same used by \"uptime\" and \"w\""
1865msgstr "" 1561msgstr ""
1866 1562
1867#: plugins/check_load.c:326
1868msgid "Divide the load averages by the number of CPUs (when possible)" 1563msgid "Divide the load averages by the number of CPUs (when possible)"
1869msgstr "" 1564msgstr ""
1870 1565
1871#: plugins/check_mrtg.c:75 1566msgid "Number of processes to show when printing the top consuming processes."
1567msgstr ""
1568
1569msgid "NUMBER_OF_PROCS=0 disables this feature. Default value is 0"
1570msgstr ""
1571
1572#, c-format
1573msgid "'%s' exited with non-zero status.\n"
1574msgstr ""
1575
1576#, c-format
1577msgid "some error occurred getting procs list.\n"
1578msgstr ""
1579
1872msgid "Could not parse arguments\n" 1580msgid "Could not parse arguments\n"
1873msgstr "" 1581msgstr ""
1874 1582
1875#: plugins/check_mrtg.c:80
1876#, c-format 1583#, c-format
1877msgid "Unable to open MRTG log file\n" 1584msgid "Unable to open MRTG log file\n"
1878msgstr "" 1585msgstr ""
1879 1586
1880#: plugins/check_mrtg.c:127
1881#, c-format 1587#, c-format
1882msgid "Unable to process MRTG log file\n" 1588msgid "Unable to process MRTG log file\n"
1883msgstr "" 1589msgstr ""
1884 1590
1885#: plugins/check_mrtg.c:135 plugins/check_mrtgtraf.c:136
1886#, c-format 1591#, c-format
1887msgid "MRTG data has expired (%d minutes old)\n" 1592msgid "MRTG data has expired (%d minutes old)\n"
1888msgstr "" 1593msgstr ""
1889 1594
1890#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1891#: plugins/check_mrtgtraf.c:196
1892msgid "Avg" 1595msgid "Avg"
1893msgstr "" 1596msgstr ""
1894 1597
1895#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1896#: plugins/check_mrtgtraf.c:196
1897msgid "Max" 1598msgid "Max"
1898msgstr "" 1599msgstr ""
1899 1600
1900#: plugins/check_mrtg.c:221
1901msgid "Invalid variable number" 1601msgid "Invalid variable number"
1902msgstr "" 1602msgstr ""
1903 1603
1904#: plugins/check_mrtg.c:256
1905#, c-format 1604#, c-format
1906msgid "" 1605msgid ""
1907"%s is not a valid expiration time\n" 1606"%s is not a valid expiration time\n"
1908"Use '%s -h' for additional help\n" 1607"Use '%s -h' for additional help\n"
1909msgstr "" 1608msgstr ""
1910 1609
1911#: plugins/check_mrtg.c:273
1912msgid "Invalid variable number\n" 1610msgid "Invalid variable number\n"
1913msgstr "" 1611msgstr ""
1914 1612
1915#: plugins/check_mrtg.c:300
1916msgid "You must supply the variable number" 1613msgid "You must supply the variable number"
1917msgstr "" 1614msgstr ""
1918 1615
1919#: plugins/check_mrtg.c:321
1920msgid "" 1616msgid ""
1921"This plugin will check either the average or maximum value of one of the" 1617"This plugin will check either the average or maximum value of one of the"
1922msgstr "" 1618msgstr ""
1923 1619
1924#: plugins/check_mrtg.c:322
1925#, fuzzy 1620#, fuzzy
1926msgid "two variables recorded in an MRTG log file." 1621msgid "two variables recorded in an MRTG log file."
1927msgstr "Konnte MRTG Logfile nicht öffnen" 1622msgstr "Konnte MRTG Logfile nicht öffnen"
1928 1623
1929#: plugins/check_mrtg.c:332
1930msgid "The MRTG log file containing the data you want to monitor" 1624msgid "The MRTG log file containing the data you want to monitor"
1931msgstr "" 1625msgstr ""
1932 1626
1933#: plugins/check_mrtg.c:334
1934msgid "Minutes before MRTG data is considered to be too old" 1627msgid "Minutes before MRTG data is considered to be too old"
1935msgstr "" 1628msgstr ""
1936 1629
1937#: plugins/check_mrtg.c:336
1938msgid "Should we check average or maximum values?" 1630msgid "Should we check average or maximum values?"
1939msgstr "" 1631msgstr ""
1940 1632
1941#: plugins/check_mrtg.c:338
1942msgid "Which variable set should we inspect? (1 or 2)" 1633msgid "Which variable set should we inspect? (1 or 2)"
1943msgstr "" 1634msgstr ""
1944 1635
1945#: plugins/check_mrtg.c:340
1946msgid "Threshold value for data to result in WARNING status" 1636msgid "Threshold value for data to result in WARNING status"
1947msgstr "" 1637msgstr ""
1948 1638
1949#: plugins/check_mrtg.c:342
1950msgid "Threshold value for data to result in CRITICAL status" 1639msgid "Threshold value for data to result in CRITICAL status"
1951msgstr "" 1640msgstr ""
1952 1641
1953#: plugins/check_mrtg.c:344
1954msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)" 1642msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)"
1955msgstr "" 1643msgstr ""
1956 1644
1957#: plugins/check_mrtg.c:346
1958msgid "Option units label for data (Example: Packets/Sec, Errors/Sec," 1645msgid "Option units label for data (Example: Packets/Sec, Errors/Sec,"
1959msgstr "" 1646msgstr ""
1960 1647
1961#: plugins/check_mrtg.c:347
1962#, c-format 1648#, c-format
1963msgid "\"Bytes Per Second\", \"%% Utilization\")" 1649msgid "\"Bytes Per Second\", \"%% Utilization\")"
1964msgstr "" 1650msgstr ""
1965 1651
1966#: plugins/check_mrtg.c:350
1967msgid "" 1652msgid ""
1968"If the value exceeds the <vwl> threshold, a WARNING status is returned. If" 1653"If the value exceeds the <vwl> threshold, a WARNING status is returned. If"
1969msgstr "" 1654msgstr ""
1970 1655
1971#: plugins/check_mrtg.c:351
1972msgid "" 1656msgid ""
1973"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If" 1657"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If"
1974msgstr "" 1658msgstr ""
1975 1659
1976#: plugins/check_mrtg.c:352
1977msgid "the data in the log file is older than <expire_minutes> old, a WARNING" 1660msgid "the data in the log file is older than <expire_minutes> old, a WARNING"
1978msgstr "" 1661msgstr ""
1979 1662
1980#: plugins/check_mrtg.c:353
1981msgid "status is returned and a warning message is printed." 1663msgid "status is returned and a warning message is printed."
1982msgstr "" 1664msgstr ""
1983 1665
1984#: plugins/check_mrtg.c:356
1985msgid "" 1666msgid ""
1986"This plugin is useful for monitoring MRTG data that does not correspond to" 1667"This plugin is useful for monitoring MRTG data that does not correspond to"
1987msgstr "" 1668msgstr ""
1988 1669
1989#: plugins/check_mrtg.c:357
1990msgid "" 1670msgid ""
1991"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)." 1671"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."
1992msgstr "" 1672msgstr ""
1993 1673
1994#: plugins/check_mrtg.c:358
1995msgid "" 1674msgid ""
1996"It can be used to monitor any kind of data that MRTG is monitoring - errors," 1675"It can be used to monitor any kind of data that MRTG is monitoring - errors,"
1997msgstr "" 1676msgstr ""
1998 1677
1999#: plugins/check_mrtg.c:359
2000msgid "" 1678msgid ""
2001"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows" 1679"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"
2002msgstr "" 1680msgstr ""
2003 1681
2004#: plugins/check_mrtg.c:360
2005msgid "" 1682msgid ""
2006"me to track processor utilization, user connections, drive space, etc and" 1683"me to track processor utilization, user connections, drive space, etc and"
2007msgstr "" 1684msgstr ""
2008 1685
2009#: plugins/check_mrtg.c:361
2010msgid "this plugin works well for monitoring that kind of data as well." 1686msgid "this plugin works well for monitoring that kind of data as well."
2011msgstr "" 1687msgstr ""
2012 1688
2013#: plugins/check_mrtg.c:364
2014msgid "" 1689msgid ""
2015"- This plugin only monitors one of the two variables stored in the MRTG log" 1690"- This plugin only monitors one of the two variables stored in the MRTG log"
2016msgstr "" 1691msgstr ""
2017 1692
2018#: plugins/check_mrtg.c:365
2019msgid "file. If you want to monitor both values you will have to define two" 1693msgid "file. If you want to monitor both values you will have to define two"
2020msgstr "" 1694msgstr ""
2021 1695
2022#: plugins/check_mrtg.c:366
2023msgid "commands with different values for the <variable> argument. Of course," 1696msgid "commands with different values for the <variable> argument. Of course,"
2024msgstr "" 1697msgstr ""
2025 1698
2026#: plugins/check_mrtg.c:367
2027msgid "you can always hack the code to make this plugin work for you..." 1699msgid "you can always hack the code to make this plugin work for you..."
2028msgstr "" 1700msgstr ""
2029 1701
2030#: plugins/check_mrtg.c:368
2031msgid "" 1702msgid ""
2032"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded " 1703"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded "
2033"from" 1704"from"
2034msgstr "" 1705msgstr ""
2035 1706
2036#: plugins/check_mrtgtraf.c:88
2037msgid "Unable to open MRTG log file" 1707msgid "Unable to open MRTG log file"
2038msgstr "Konnte MRTG Logfile nicht öffnen" 1708msgstr "Konnte MRTG Logfile nicht öffnen"
2039 1709
2040#: plugins/check_mrtgtraf.c:130
2041msgid "Unable to process MRTG log file" 1710msgid "Unable to process MRTG log file"
2042msgstr "" 1711msgstr ""
2043 1712
2044#: plugins/check_mrtgtraf.c:194
2045#, c-format 1713#, c-format
2046msgid "%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n" 1714msgid "%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"
2047msgstr "" 1715msgstr ""
2048 1716
2049#: plugins/check_mrtgtraf.c:207
2050#, c-format 1717#, c-format
2051msgid "Traffic %s - %s\n" 1718msgid "Traffic %s - %s\n"
2052msgstr "" 1719msgstr ""
2053 1720
2054#: plugins/check_mrtgtraf.c:335
2055msgid "" 1721msgid ""
2056"This plugin will check the incoming/outgoing transfer rates of a router," 1722"This plugin will check the incoming/outgoing transfer rates of a router,"
2057msgstr "" 1723msgstr ""
2058 1724
2059#: plugins/check_mrtgtraf.c:336
2060msgid "switch, etc recorded in an MRTG log. If the newest log entry is older" 1725msgid "switch, etc recorded in an MRTG log. If the newest log entry is older"
2061msgstr "" 1726msgstr ""
2062 1727
2063#: plugins/check_mrtgtraf.c:337
2064msgid "than <expire_minutes>, a WARNING status is returned. If either the" 1728msgid "than <expire_minutes>, a WARNING status is returned. If either the"
2065msgstr "" 1729msgstr ""
2066 1730
2067#: plugins/check_mrtgtraf.c:338
2068msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in" 1731msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in"
2069msgstr "" 1732msgstr ""
2070 1733
2071#: plugins/check_mrtgtraf.c:339
2072msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed" 1734msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed"
2073msgstr "" 1735msgstr ""
2074 1736
2075#: plugins/check_mrtgtraf.c:340
2076msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results." 1737msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results."
2077msgstr "" 1738msgstr ""
2078 1739
2079#: plugins/check_mrtgtraf.c:350
2080msgid "File to read log from" 1740msgid "File to read log from"
2081msgstr "" 1741msgstr ""
2082 1742
2083#: plugins/check_mrtgtraf.c:352
2084msgid "Minutes after which log expires" 1743msgid "Minutes after which log expires"
2085msgstr "" 1744msgstr ""
2086 1745
2087#: plugins/check_mrtgtraf.c:354
2088msgid "Test average or maximum" 1746msgid "Test average or maximum"
2089msgstr "" 1747msgstr ""
2090 1748
2091#: plugins/check_mrtgtraf.c:356
2092#, fuzzy 1749#, fuzzy
2093msgid "Warning threshold pair <incoming>,<outgoing>" 1750msgid "Warning threshold pair <incoming>,<outgoing>"
2094msgstr "Warning threshold Integer sein" 1751msgstr "Warning threshold Integer sein"
2095 1752
2096#: plugins/check_mrtgtraf.c:358
2097#, fuzzy 1753#, fuzzy
2098msgid "Critical threshold pair <incoming>,<outgoing>" 1754msgid "Critical threshold pair <incoming>,<outgoing>"
2099msgstr "Critical threshold muss ein Integer sein" 1755msgstr "Critical threshold muss ein Integer sein"
2100 1756
2101#: plugins/check_mrtgtraf.c:362
2102msgid "" 1757msgid ""
2103"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from" 1758"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"
2104msgstr "" 1759msgstr ""
2105 1760
2106#: plugins/check_mrtgtraf.c:364
2107msgid "- While MRTG can monitor things other than traffic rates, this" 1761msgid "- While MRTG can monitor things other than traffic rates, this"
2108msgstr "" 1762msgstr ""
2109 1763
2110#: plugins/check_mrtgtraf.c:365
2111msgid " plugin probably won't work with much else without modification." 1764msgid " plugin probably won't work with much else without modification."
2112msgstr "" 1765msgstr ""
2113 1766
2114#: plugins/check_mrtgtraf.c:366
2115msgid "- The calculated i/o rates are a little off from what MRTG actually" 1767msgid "- The calculated i/o rates are a little off from what MRTG actually"
2116msgstr "" 1768msgstr ""
2117 1769
2118#: plugins/check_mrtgtraf.c:367
2119msgid " reports. I'm not sure why this is right now, but will look into it" 1770msgid " reports. I'm not sure why this is right now, but will look into it"
2120msgstr "" 1771msgstr ""
2121 1772
2122#: plugins/check_mrtgtraf.c:368
2123msgid " for future enhancements of this plugin." 1773msgid " for future enhancements of this plugin."
2124msgstr "" 1774msgstr ""
2125 1775
2126#: plugins/check_mrtgtraf.c:378
2127#, c-format 1776#, c-format
2128msgid "Usage" 1777msgid "Usage"
2129msgstr "" 1778msgstr ""
2130 1779
2131#: plugins/check_mysql.c:171
2132#, c-format 1780#, c-format
2133msgid "status store_result error: %s\n" 1781msgid "status store_result error: %s\n"
2134msgstr "" 1782msgstr ""
2135 1783
2136#: plugins/check_mysql.c:202
2137#, c-format 1784#, c-format
2138msgid "slave query error: %s\n" 1785msgid "slave query error: %s\n"
2139msgstr "" 1786msgstr ""
2140 1787
2141#: plugins/check_mysql.c:209
2142#, c-format 1788#, c-format
2143msgid "slave store_result error: %s\n" 1789msgid "slave store_result error: %s\n"
2144msgstr "" 1790msgstr ""
2145 1791
2146#: plugins/check_mysql.c:215
2147msgid "No slaves defined" 1792msgid "No slaves defined"
2148msgstr "" 1793msgstr ""
2149 1794
2150#: plugins/check_mysql.c:223
2151#, c-format 1795#, c-format
2152msgid "slave fetch row error: %s\n" 1796msgid "slave fetch row error: %s\n"
2153msgstr "" 1797msgstr ""
2154 1798
2155#: plugins/check_mysql.c:228
2156#, c-format 1799#, c-format
2157msgid "Slave running: %s" 1800msgid "Slave running: %s"
2158msgstr "" 1801msgstr ""
2159 1802
2160#: plugins/check_mysql.c:505
2161msgid "This program tests connections to a MySQL server" 1803msgid "This program tests connections to a MySQL server"
2162msgstr "" 1804msgstr ""
2163 1805
2164#: plugins/check_mysql.c:516 1806msgid "Ignore authentication failure and check for mysql connectivity only"
1807msgstr ""
1808
2165msgid "Use the specified socket (has no effect if -H is used)" 1809msgid "Use the specified socket (has no effect if -H is used)"
2166msgstr "" 1810msgstr ""
2167 1811
2168#: plugins/check_mysql.c:519
2169msgid "Check database with indicated name" 1812msgid "Check database with indicated name"
2170msgstr "" 1813msgstr ""
2171 1814
2172#: plugins/check_mysql.c:521
2173msgid "Read from the specified client options file" 1815msgid "Read from the specified client options file"
2174msgstr "" 1816msgstr ""
2175 1817
2176#: plugins/check_mysql.c:523
2177msgid "Use a client options group" 1818msgid "Use a client options group"
2178msgstr "" 1819msgstr ""
2179 1820
2180#: plugins/check_mysql.c:525
2181msgid "Connect using the indicated username" 1821msgid "Connect using the indicated username"
2182msgstr "" 1822msgstr ""
2183 1823
2184#: plugins/check_mysql.c:527
2185msgid "Use the indicated password to authenticate the connection" 1824msgid "Use the indicated password to authenticate the connection"
2186msgstr "" 1825msgstr ""
2187 1826
2188#: plugins/check_mysql.c:528
2189msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!" 1827msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!"
2190msgstr "" 1828msgstr ""
2191 1829
2192#: plugins/check_mysql.c:529
2193msgid "Your clear-text password could be visible as a process table entry" 1830msgid "Your clear-text password could be visible as a process table entry"
2194msgstr "" 1831msgstr ""
2195 1832
2196#: plugins/check_mysql.c:531
2197msgid "Check if the slave thread is running properly." 1833msgid "Check if the slave thread is running properly."
2198msgstr "" 1834msgstr ""
2199 1835
2200#: plugins/check_mysql.c:533
2201msgid "Exit with WARNING status if slave server is more than INTEGER seconds" 1836msgid "Exit with WARNING status if slave server is more than INTEGER seconds"
2202msgstr "" 1837msgstr ""
2203 1838
2204#: plugins/check_mysql.c:534 plugins/check_mysql.c:537
2205msgid "behind master" 1839msgid "behind master"
2206msgstr "" 1840msgstr ""
2207 1841
2208#: plugins/check_mysql.c:536
2209msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds" 1842msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds"
2210msgstr "" 1843msgstr ""
2211 1844
2212#: plugins/check_mysql.c:539 1845msgid "Use ssl encryption"
2213msgid "Use ssl encryptation"
2214msgstr "" 1846msgstr ""
2215 1847
2216#: plugins/check_mysql.c:541
2217msgid "Path to CA signing the cert" 1848msgid "Path to CA signing the cert"
2218msgstr "" 1849msgstr ""
2219 1850
2220#: plugins/check_mysql.c:543
2221msgid "Path to SSL certificate" 1851msgid "Path to SSL certificate"
2222msgstr "" 1852msgstr ""
2223 1853
2224#: plugins/check_mysql.c:545
2225msgid "Path to private SSL key" 1854msgid "Path to private SSL key"
2226msgstr "" 1855msgstr ""
2227 1856
2228#: plugins/check_mysql.c:547
2229msgid "Path to CA directory" 1857msgid "Path to CA directory"
2230msgstr "" 1858msgstr ""
2231 1859
2232#: plugins/check_mysql.c:549
2233msgid "List of valid SSL ciphers" 1860msgid "List of valid SSL ciphers"
2234msgstr "" 1861msgstr ""
2235 1862
2236#: plugins/check_mysql.c:553
2237msgid "" 1863msgid ""
2238"There are no required arguments. By default, the local database is checked" 1864"There are no required arguments. By default, the local database is checked"
2239msgstr "" 1865msgstr ""
2240 1866
2241#: plugins/check_mysql.c:554
2242msgid "" 1867msgid ""
2243"using the default unix socket. You can force TCP on localhost by using an" 1868"using the default unix socket. You can force TCP on localhost by using an"
2244msgstr "" 1869msgstr ""
2245 1870
2246#: plugins/check_mysql.c:555
2247msgid "IP address or FQDN ('localhost' will use the socket as well)." 1871msgid "IP address or FQDN ('localhost' will use the socket as well)."
2248msgstr "" 1872msgstr ""
2249 1873
2250#: plugins/check_mysql.c:559
2251msgid "You must specify -p with an empty string to force an empty password," 1874msgid "You must specify -p with an empty string to force an empty password,"
2252msgstr "" 1875msgstr ""
2253 1876
2254#: plugins/check_mysql.c:560
2255msgid "overriding any my.cnf settings." 1877msgid "overriding any my.cnf settings."
2256msgstr "" 1878msgstr ""
2257 1879
2258#: plugins/check_nagios.c:104
2259msgid "Cannot open status log for reading!" 1880msgid "Cannot open status log for reading!"
2260msgstr "" 1881msgstr ""
2261 1882
2262#: plugins/check_nagios.c:154
2263#, c-format 1883#, c-format
2264msgid "Found process: %s %s\n" 1884msgid "Found process: %s %s\n"
2265msgstr "" 1885msgstr ""
2266 1886
2267#: plugins/check_nagios.c:168
2268msgid "Could not locate a running Nagios process!" 1887msgid "Could not locate a running Nagios process!"
2269msgstr "" 1888msgstr ""
2270 1889
2271#: plugins/check_nagios.c:172
2272msgid "Cannot parse Nagios log file for valid time" 1890msgid "Cannot parse Nagios log file for valid time"
2273msgstr "" 1891msgstr ""
2274 1892
2275#: plugins/check_nagios.c:183 plugins/check_procs.c:356
2276#, c-format 1893#, c-format
2277msgid "%d process" 1894msgid "%d process"
2278msgid_plural "%d processes" 1895msgid_plural "%d processes"
2279msgstr[0] "" 1896msgstr[0] ""
2280msgstr[1] "" 1897msgstr[1] ""
2281 1898
2282#: plugins/check_nagios.c:186
2283#, c-format 1899#, c-format
2284msgid "status log updated %d second ago" 1900msgid "status log updated %d second ago"
2285msgid_plural "status log updated %d seconds ago" 1901msgid_plural "status log updated %d seconds ago"
2286msgstr[0] "" 1902msgstr[0] ""
2287msgstr[1] "" 1903msgstr[1] ""
2288 1904
2289#: plugins/check_nagios.c:224 plugins/check_nagios.c:253
2290#, fuzzy 1905#, fuzzy
2291msgid "Expiration time must be an integer (seconds)\n" 1906msgid "Expiration time must be an integer (seconds)\n"
2292msgstr "skip lines muss ein Integer sein" 1907msgstr "skip lines muss ein Integer sein"
2293 1908
2294#: plugins/check_nagios.c:260
2295#, fuzzy 1909#, fuzzy
2296msgid "Timeout must be an integer (seconds)\n" 1910msgid "Timeout must be an integer (seconds)\n"
2297msgstr "skip lines muss ein Integer sein" 1911msgstr "skip lines muss ein Integer sein"
2298 1912
2299#: plugins/check_nagios.c:272
2300#, fuzzy 1913#, fuzzy
2301msgid "You must provide the status_log\n" 1914msgid "You must provide the status_log\n"
2302msgstr "%s: Hostname muss angegeben werden\n" 1915msgstr "%s: Hostname muss angegeben werden\n"
2303 1916
2304#: plugins/check_nagios.c:275
2305#, fuzzy 1917#, fuzzy
2306msgid "You must provide a process string\n" 1918msgid "You must provide a process string\n"
2307msgstr "%s: Hostname muss angegeben werden\n" 1919msgstr "%s: Hostname muss angegeben werden\n"
2308 1920
2309#: plugins/check_nagios.c:289
2310#, fuzzy 1921#, fuzzy
2311msgid "" 1922msgid ""
2312"This plugin checks the status of the Nagios process on the local machine" 1923"This plugin checks the status of the Nagios process on the local machine"
2313msgstr "" 1924msgstr ""
2314"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n" 1925"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n"
2315"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 1926"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
2316"unterschritten wird.\n" 1927"unterschritten wird.\n"
2317"\n" 1928"\n"
2318 1929
2319#: plugins/check_nagios.c:290
2320msgid "" 1930msgid ""
2321"The plugin will check to make sure the Nagios status log is no older than" 1931"The plugin will check to make sure the Nagios status log is no older than"
2322msgstr "" 1932msgstr ""
2323 1933
2324#: plugins/check_nagios.c:291
2325msgid "the number of minutes specified by the expires option." 1934msgid "the number of minutes specified by the expires option."
2326msgstr "" 1935msgstr ""
2327 1936
2328#: plugins/check_nagios.c:292
2329msgid "" 1937msgid ""
2330"It also checks the process table for a process matching the command argument." 1938"It also checks the process table for a process matching the command argument."
2331msgstr "" 1939msgstr ""
2332 1940
2333#: plugins/check_nagios.c:302
2334msgid "Name of the log file to check" 1941msgid "Name of the log file to check"
2335msgstr "" 1942msgstr ""
2336 1943
2337#: plugins/check_nagios.c:304
2338msgid "Minutes aging after which logfile is considered stale" 1944msgid "Minutes aging after which logfile is considered stale"
2339msgstr "" 1945msgstr ""
2340 1946
2341#: plugins/check_nagios.c:306
2342msgid "Substring to search for in process arguments" 1947msgid "Substring to search for in process arguments"
2343msgstr "" 1948msgstr ""
2344 1949
2345#: plugins/check_nagios.c:308
2346msgid "Timeout for the plugin in seconds" 1950msgid "Timeout for the plugin in seconds"
2347msgstr "" 1951msgstr ""
2348 1952
2349#: plugins/check_nt.c:142
2350#, c-format 1953#, c-format
2351msgid "Wrong client version - running: %s, required: %s" 1954msgid "Wrong client version - running: %s, required: %s"
2352msgstr "" 1955msgstr ""
2353 1956
2354#: plugins/check_nt.c:153 plugins/check_nt.c:218
2355msgid "missing -l parameters" 1957msgid "missing -l parameters"
2356msgstr "" 1958msgstr ""
2357 1959
2358#: plugins/check_nt.c:155
2359msgid "wrong -l parameter." 1960msgid "wrong -l parameter."
2360msgstr "" 1961msgstr ""
2361 1962
2362#: plugins/check_nt.c:159
2363msgid "CPU Load" 1963msgid "CPU Load"
2364msgstr "" 1964msgstr ""
2365 1965
2366#: plugins/check_nt.c:182
2367#, c-format 1966#, c-format
2368msgid " %lu%% (%lu min average)" 1967msgid " %lu%% (%lu min average)"
2369msgstr "" 1968msgstr ""
2370 1969
2371#: plugins/check_nt.c:184
2372#, c-format 1970#, c-format
2373msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100" 1971msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100"
2374msgstr "" 1972msgstr ""
2375 1973
2376#: plugins/check_nt.c:194
2377msgid "not enough values for -l parameters" 1974msgid "not enough values for -l parameters"
2378msgstr "" 1975msgstr ""
2379 1976
2380#: plugins/check_nt.c:206 1977msgid "wrong -l argument"
2381#, c-format
2382msgid "System Uptime - %u day(s) %u hour(s) %u minute(s)"
2383msgstr "" 1978msgstr ""
2384 1979
2385#: plugins/check_nt.c:220 1980#, c-format
2386msgid "wrong -l argument" 1981msgid "System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"
2387msgstr "" 1982msgstr ""
2388 1983
2389#: plugins/check_nt.c:236
2390#, c-format 1984#, c-format
2391msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)" 1985msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"
2392msgstr "" 1986msgstr ""
2393 1987
2394#: plugins/check_nt.c:239
2395#, c-format 1988#, c-format
2396msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f" 1989msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2397msgstr "" 1990msgstr ""
2398 1991
2399#: plugins/check_nt.c:253
2400msgid "Free disk space : Invalid drive" 1992msgid "Free disk space : Invalid drive"
2401msgstr "" 1993msgstr ""
2402 1994
2403#: plugins/check_nt.c:263
2404msgid "No service/process specified" 1995msgid "No service/process specified"
2405msgstr "" 1996msgstr ""
2406 1997
2407#: plugins/check_nt.c:271 plugins/check_nt.c:284 plugins/check_nt.c:288
2408#: plugins/check_nt.c:622
2409msgid "could not fetch information from server\n" 1998msgid "could not fetch information from server\n"
2410msgstr "" 1999msgstr ""
2411 2000
2412#: plugins/check_nt.c:296
2413#, c-format 2001#, c-format
2414msgid "" 2002msgid ""
2415"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)" 2003"Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"
2416msgstr "" 2004msgstr ""
2417 2005
2418#: plugins/check_nt.c:299
2419#, c-format 2006#, c-format
2420msgid "'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f" 2007msgid "'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"
2421msgstr "" 2008msgstr ""
2422 2009
2423#: plugins/check_nt.c:335 plugins/check_nt.c:420 plugins/check_nt.c:450
2424msgid "No counter specified" 2010msgid "No counter specified"
2425msgstr "" 2011msgstr ""
2426 2012
2427#: plugins/check_nt.c:367
2428msgid "Minimum value contains non-numbers" 2013msgid "Minimum value contains non-numbers"
2429msgstr "" 2014msgstr ""
2430 2015
2431#: plugins/check_nt.c:371
2432msgid "Maximum value contains non-numbers" 2016msgid "Maximum value contains non-numbers"
2433msgstr "" 2017msgstr ""
2434 2018
2435#: plugins/check_nt.c:378
2436msgid "No unit counter specified" 2019msgid "No unit counter specified"
2437msgstr "" 2020msgstr ""
2438 2021
2439#: plugins/check_nt.c:465
2440msgid "Please specify a variable to check" 2022msgid "Please specify a variable to check"
2441msgstr "" 2023msgstr ""
2442 2024
2443#: plugins/check_nt.c:549
2444#, fuzzy 2025#, fuzzy
2445msgid "Server port must be an integer\n" 2026msgid "Server port must be an integer\n"
2446msgstr "skip lines muss ein Integer sein" 2027msgstr "skip lines muss ein Integer sein"
2447 2028
2448#: plugins/check_nt.c:603
2449#, fuzzy 2029#, fuzzy
2450msgid "You must provide a server address or host name" 2030msgid "You must provide a server address or host name"
2451msgstr "Hostname oder Serveradresse muss angegeben werden" 2031msgstr "Hostname oder Serveradresse muss angegeben werden"
2452 2032
2453#: plugins/check_nt.c:609
2454msgid "None" 2033msgid "None"
2455msgstr "" 2034msgstr ""
2456 2035
2457#: plugins/check_nt.c:666
2458msgid "This plugin collects data from the NSClient service running on a" 2036msgid "This plugin collects data from the NSClient service running on a"
2459msgstr "" 2037msgstr ""
2460 2038
2461#: plugins/check_nt.c:667
2462msgid "Windows NT/2000/XP/2003 server." 2039msgid "Windows NT/2000/XP/2003 server."
2463msgstr "" 2040msgstr ""
2464 2041
2465#: plugins/check_nt.c:678
2466msgid "Name of the host to check" 2042msgid "Name of the host to check"
2467msgstr "" 2043msgstr ""
2468 2044
2469#: plugins/check_nt.c:680
2470#, fuzzy 2045#, fuzzy
2471msgid "Optional port number (default: " 2046msgid "Optional port number (default: "
2472msgstr "Ungültige Portnummer" 2047msgstr "Ungültige Portnummer"
2473 2048
2474#: plugins/check_nt.c:683
2475msgid "Password needed for the request" 2049msgid "Password needed for the request"
2476msgstr "" 2050msgstr ""
2477 2051
2478#: plugins/check_nt.c:685 plugins/check_nwstat.c:1661
2479#: plugins/check_overcr.c:432
2480msgid "Threshold which will result in a warning status" 2052msgid "Threshold which will result in a warning status"
2481msgstr "" 2053msgstr ""
2482 2054
2483#: plugins/check_nt.c:687 plugins/check_nwstat.c:1663
2484#: plugins/check_overcr.c:434
2485msgid "Threshold which will result in a critical status" 2055msgid "Threshold which will result in a critical status"
2486msgstr "" 2056msgstr ""
2487 2057
2488#: plugins/check_nt.c:689
2489msgid "Seconds before connection attempt times out (default: " 2058msgid "Seconds before connection attempt times out (default: "
2490msgstr "" 2059msgstr ""
2491 2060
2492#: plugins/check_nt.c:691
2493msgid "Parameters passed to specified check (see below)" 2061msgid "Parameters passed to specified check (see below)"
2494msgstr "" 2062msgstr ""
2495 2063
2496#: plugins/check_nt.c:693
2497msgid "Display options (currently only SHOWALL works)" 2064msgid "Display options (currently only SHOWALL works)"
2498msgstr "" 2065msgstr ""
2499 2066
2500#: plugins/check_nt.c:695
2501msgid "Return UNKNOWN on timeouts" 2067msgid "Return UNKNOWN on timeouts"
2502msgstr "" 2068msgstr ""
2503 2069
2504#: plugins/check_nt.c:698
2505msgid "Print this help screen" 2070msgid "Print this help screen"
2506msgstr "" 2071msgstr ""
2507 2072
2508#: plugins/check_nt.c:700
2509msgid "Print version information" 2073msgid "Print version information"
2510msgstr "" 2074msgstr ""
2511 2075
2512#: plugins/check_nt.c:702
2513msgid "Variable to check" 2076msgid "Variable to check"
2514msgstr "" 2077msgstr ""
2515 2078
2516#: plugins/check_nt.c:703
2517msgid "Valid variables are:" 2079msgid "Valid variables are:"
2518msgstr "" 2080msgstr ""
2519 2081
2520#: plugins/check_nt.c:705
2521msgid "Get the NSClient version" 2082msgid "Get the NSClient version"
2522msgstr "" 2083msgstr ""
2523 2084
2524#: plugins/check_nt.c:706
2525msgid "If -l <version> is specified, will return warning if versions differ." 2085msgid "If -l <version> is specified, will return warning if versions differ."
2526msgstr "" 2086msgstr ""
2527 2087
2528#: plugins/check_nt.c:708
2529msgid "Average CPU load on last x minutes." 2088msgid "Average CPU load on last x minutes."
2530msgstr "" 2089msgstr ""
2531 2090
2532#: plugins/check_nt.c:709
2533msgid "Request a -l parameter with the following syntax:" 2091msgid "Request a -l parameter with the following syntax:"
2534msgstr "" 2092msgstr ""
2535 2093
2536#: plugins/check_nt.c:710
2537msgid "-l <minutes range>,<warning threshold>,<critical threshold>." 2094msgid "-l <minutes range>,<warning threshold>,<critical threshold>."
2538msgstr "" 2095msgstr ""
2539 2096
2540#: plugins/check_nt.c:711
2541msgid "<minute range> should be less than 24*60." 2097msgid "<minute range> should be less than 24*60."
2542msgstr "" 2098msgstr ""
2543 2099
2544#: plugins/check_nt.c:712
2545msgid "" 2100msgid ""
2546"Thresholds are percentage and up to 10 requests can be done in one shot." 2101"Thresholds are percentage and up to 10 requests can be done in one shot."
2547msgstr "" 2102msgstr ""
2548 2103
2549#: plugins/check_nt.c:715
2550msgid "Get the uptime of the machine." 2104msgid "Get the uptime of the machine."
2551msgstr "" 2105msgstr ""
2552 2106
2553#: plugins/check_nt.c:716 2107msgid "-l <unit> "
2554msgid "No specific parameters. No warning or critical threshold" 2108msgstr ""
2109
2110msgid "<unit> = seconds, minutes, hours, or days. (default: minutes)"
2555msgstr "" 2111msgstr ""
2556 2112
2557#: plugins/check_nt.c:718 2113#, fuzzy
2114msgid "Thresholds will use the unit specified above."
2115msgstr ""
2116"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2117"\n"
2118
2558msgid "Size and percentage of disk use." 2119msgid "Size and percentage of disk use."
2559msgstr "" 2120msgstr ""
2560 2121
2561#: plugins/check_nt.c:719
2562msgid "Request a -l parameter containing the drive letter only." 2122msgid "Request a -l parameter containing the drive letter only."
2563msgstr "" 2123msgstr ""
2564 2124
2565#: plugins/check_nt.c:720 plugins/check_nt.c:723
2566msgid "Warning and critical thresholds can be specified with -w and -c." 2125msgid "Warning and critical thresholds can be specified with -w and -c."
2567msgstr "" 2126msgstr ""
2568 2127
2569#: plugins/check_nt.c:722
2570msgid "Memory use." 2128msgid "Memory use."
2571msgstr "" 2129msgstr ""
2572 2130
2573#: plugins/check_nt.c:725
2574msgid "Check the state of one or several services." 2131msgid "Check the state of one or several services."
2575msgstr "" 2132msgstr ""
2576 2133
2577#: plugins/check_nt.c:726 plugins/check_nt.c:735
2578msgid "Request a -l parameters with the following syntax:" 2134msgid "Request a -l parameters with the following syntax:"
2579msgstr "" 2135msgstr ""
2580 2136
2581#: plugins/check_nt.c:727
2582msgid "-l <service1>,<service2>,<service3>,..." 2137msgid "-l <service1>,<service2>,<service3>,..."
2583msgstr "" 2138msgstr ""
2584 2139
2585#: plugins/check_nt.c:728
2586msgid "You can specify -d SHOWALL in case you want to see working services" 2140msgid "You can specify -d SHOWALL in case you want to see working services"
2587msgstr "" 2141msgstr ""
2588 2142
2589#: plugins/check_nt.c:729
2590msgid "in the returned string." 2143msgid "in the returned string."
2591msgstr "" 2144msgstr ""
2592 2145
2593#: plugins/check_nt.c:731
2594msgid "Check if one or several process are running." 2146msgid "Check if one or several process are running."
2595msgstr "" 2147msgstr ""
2596 2148
2597#: plugins/check_nt.c:732
2598msgid "Same syntax as SERVICESTATE." 2149msgid "Same syntax as SERVICESTATE."
2599msgstr "" 2150msgstr ""
2600 2151
2601#: plugins/check_nt.c:734
2602msgid "Check any performance counter of Windows NT/2000." 2152msgid "Check any performance counter of Windows NT/2000."
2603msgstr "" 2153msgstr ""
2604 2154
2605#: plugins/check_nt.c:736
2606msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>" 2155msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>"
2607msgstr "" 2156msgstr ""
2608 2157
2609#: plugins/check_nt.c:737
2610msgid "The <description> parameter is optional and is given to a printf " 2158msgid "The <description> parameter is optional and is given to a printf "
2611msgstr "" 2159msgstr ""
2612 2160
2613#: plugins/check_nt.c:738
2614msgid "output command which requires a float parameter." 2161msgid "output command which requires a float parameter."
2615msgstr "" 2162msgstr ""
2616 2163
2617#: plugins/check_nt.c:739
2618#, c-format 2164#, c-format
2619msgid "If <description> does not include \"%%\", it is used as a label." 2165msgid "If <description> does not include \"%%\", it is used as a label."
2620msgstr "" 2166msgstr ""
2621 2167
2622#: plugins/check_nt.c:740 plugins/check_nt.c:755
2623msgid "Some examples:" 2168msgid "Some examples:"
2624msgstr "" 2169msgstr ""
2625 2170
2626#: plugins/check_nt.c:744
2627msgid "Check any performance counter object of Windows NT/2000." 2171msgid "Check any performance counter object of Windows NT/2000."
2628msgstr "" 2172msgstr ""
2629 2173
2630#: plugins/check_nt.c:745
2631msgid "" 2174msgid ""
2632"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>" 2175"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"
2633msgstr "" 2176msgstr ""
2634 2177
2635#: plugins/check_nt.c:746
2636msgid "<counter object> is a Windows Perfmon Counter object (eg. Process)," 2178msgid "<counter object> is a Windows Perfmon Counter object (eg. Process),"
2637msgstr "" 2179msgstr ""
2638 2180
2639#: plugins/check_nt.c:747
2640msgid "if it is two words, it should be enclosed in quotes" 2181msgid "if it is two words, it should be enclosed in quotes"
2641msgstr "" 2182msgstr ""
2642 2183
2643#: plugins/check_nt.c:748
2644msgid "The returned results will be a comma-separated list of instances on " 2184msgid "The returned results will be a comma-separated list of instances on "
2645msgstr "" 2185msgstr ""
2646 2186
2647#: plugins/check_nt.c:749
2648msgid " the selected computer for that object." 2187msgid " the selected computer for that object."
2649msgstr "" 2188msgstr ""
2650 2189
2651#: plugins/check_nt.c:750
2652msgid "" 2190msgid ""
2653"The purpose of this is to be run from command line to determine what " 2191"The purpose of this is to be run from command line to determine what "
2654"instances" 2192"instances"
2655msgstr "" 2193msgstr ""
2656 2194
2657#: plugins/check_nt.c:751
2658msgid "" 2195msgid ""
2659" are available for monitoring without having to log onto the Windows server" 2196" are available for monitoring without having to log onto the Windows server"
2660msgstr "" 2197msgstr ""
2661 2198
2662#: plugins/check_nt.c:752
2663msgid " to run Perfmon directly." 2199msgid " to run Perfmon directly."
2664msgstr "" 2200msgstr ""
2665 2201
2666#: plugins/check_nt.c:753
2667msgid "" 2202msgid ""
2668"It can also be used in scripts that automatically create the monitoring " 2203"It can also be used in scripts that automatically create the monitoring "
2669"service" 2204"service"
2670msgstr "" 2205msgstr ""
2671 2206
2672#: plugins/check_nt.c:754
2673msgid " configuration files." 2207msgid " configuration files."
2674msgstr "" 2208msgstr ""
2675 2209
2676#: plugins/check_nt.c:756
2677msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process" 2210msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"
2678msgstr "" 2211msgstr ""
2679 2212
2680#: plugins/check_nt.c:759
2681msgid "" 2213msgid ""
2682"- The NSClient service should be running on the server to get any information" 2214"- The NSClient service should be running on the server to get any information"
2683msgstr "" 2215msgstr ""
2684 2216
2685#: plugins/check_nt.c:761
2686msgid "- Critical thresholds should be lower than warning thresholds" 2217msgid "- Critical thresholds should be lower than warning thresholds"
2687msgstr "" 2218msgstr ""
2688 2219
2689#: plugins/check_nt.c:762
2690msgid "- Default port 1248 is sometimes in use by other services. The error" 2220msgid "- Default port 1248 is sometimes in use by other services. The error"
2691msgstr "" 2221msgstr ""
2692 2222
2693#: plugins/check_nt.c:763
2694msgid "" 2223msgid ""
2695"output when this happens contains \"Cannot map xxxxx to protocol number\"." 2224"output when this happens contains \"Cannot map xxxxx to protocol number\"."
2696msgstr "" 2225msgstr ""
2697 2226
2698#: plugins/check_nt.c:764
2699msgid "One fix for this is to change the port to something else on check_nt " 2227msgid "One fix for this is to change the port to something else on check_nt "
2700msgstr "" 2228msgstr ""
2701 2229
2702#: plugins/check_nt.c:765
2703msgid "and on the client service it's connecting to." 2230msgid "and on the client service it's connecting to."
2704msgstr "" 2231msgstr ""
2705 2232
2706#: plugins/check_ntp.c:807 plugins/check_ntp_peer.c:612 2233#, c-format
2707#: plugins/check_ntp_time.c:571 2234msgid "jitter response too large (%lu bytes)\n"
2235msgstr ""
2236
2708msgid "NTP CRITICAL:" 2237msgid "NTP CRITICAL:"
2709msgstr "NTP CRITICAL:" 2238msgstr "NTP CRITICAL:"
2710 2239
2711#: plugins/check_ntp.c:810 plugins/check_ntp_peer.c:615
2712#: plugins/check_ntp_time.c:574
2713msgid "NTP WARNING:" 2240msgid "NTP WARNING:"
2714msgstr "NTP WARNING:" 2241msgstr "NTP WARNING:"
2715 2242
2716#: plugins/check_ntp.c:813 plugins/check_ntp_peer.c:618
2717#: plugins/check_ntp_time.c:577
2718msgid "NTP OK:" 2243msgid "NTP OK:"
2719msgstr "NTP OK:" 2244msgstr "NTP OK:"
2720 2245
2721#: plugins/check_ntp.c:816 plugins/check_ntp_peer.c:621
2722#: plugins/check_ntp_time.c:580
2723msgid "NTP UNKNOWN:" 2246msgid "NTP UNKNOWN:"
2724msgstr "NTP UNKNOWN:" 2247msgstr "NTP UNKNOWN:"
2725 2248
2726#: plugins/check_ntp.c:820 plugins/check_ntp_peer.c:630
2727#: plugins/check_ntp_time.c:584
2728msgid "Offset unknown" 2249msgid "Offset unknown"
2729msgstr "" 2250msgstr ""
2730 2251
2731#: plugins/check_ntp.c:823 plugins/check_ntp_peer.c:633
2732#: plugins/check_ntp_time.c:587
2733msgid "Offset" 2252msgid "Offset"
2734msgstr "" 2253msgstr ""
2735 2254
2736#: plugins/check_ntp.c:844 plugins/check_ntp_peer.c:662
2737#, fuzzy 2255#, fuzzy
2738msgid "This plugin checks the selected ntp server" 2256msgid "This plugin checks the selected ntp server"
2739msgstr "" 2257msgstr ""
2740"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 2258"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2741"\n" 2259"\n"
2742 2260
2743#: plugins/check_ntp.c:854 plugins/check_ntp_peer.c:674
2744#: plugins/check_ntp_time.c:614
2745msgid "Offset to result in warning status (seconds)" 2261msgid "Offset to result in warning status (seconds)"
2746msgstr "" 2262msgstr ""
2747 2263
2748#: plugins/check_ntp.c:856 plugins/check_ntp_peer.c:676
2749#: plugins/check_ntp_time.c:616
2750msgid "Offset to result in critical status (seconds)" 2264msgid "Offset to result in critical status (seconds)"
2751msgstr "" 2265msgstr ""
2752 2266
2753#: plugins/check_ntp.c:858 plugins/check_ntp_peer.c:682
2754#, fuzzy 2267#, fuzzy
2755msgid "Warning threshold for jitter" 2268msgid "Warning threshold for jitter"
2756msgstr "Warning threshold Integer sein" 2269msgstr "Warning threshold Integer sein"
2757 2270
2758#: plugins/check_ntp.c:860 plugins/check_ntp_peer.c:684
2759#, fuzzy 2271#, fuzzy
2760msgid "Critical threshold for jitter" 2272msgid "Critical threshold for jitter"
2761msgstr "Critical threshold muss ein Integer sein" 2273msgstr "Critical threshold muss ein Integer sein"
2762 2274
2763#: plugins/check_ntp.c:870
2764msgid "Normal offset check:" 2275msgid "Normal offset check:"
2765msgstr "" 2276msgstr ""
2766 2277
2767#: plugins/check_ntp.c:873 plugins/check_ntp_peer.c:709
2768msgid "" 2278msgid ""
2769"Check jitter too, avoiding critical notifications if jitter isn't available" 2279"Check jitter too, avoiding critical notifications if jitter isn't available"
2770msgstr "" 2280msgstr ""
2771 2281
2772#: plugins/check_ntp.c:874 plugins/check_ntp_peer.c:710
2773msgid "(See Notes above for more details on thresholds formats):" 2282msgid "(See Notes above for more details on thresholds formats):"
2774msgstr "" 2283msgstr ""
2775 2284
2776#: plugins/check_ntp.c:879 plugins/check_ntp.c:886
2777msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or" 2285msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or"
2778msgstr "" 2286msgstr ""
2779 2287
2780#: plugins/check_ntp.c:880 plugins/check_ntp.c:887
2781msgid "check_ntp_time instead." 2288msgid "check_ntp_time instead."
2782msgstr "" 2289msgstr ""
2783 2290
2784#: plugins/check_ntp_peer.c:625
2785msgid "Server not synchronized" 2291msgid "Server not synchronized"
2786msgstr "" 2292msgstr ""
2787 2293
2788#: plugins/check_ntp_peer.c:627
2789msgid "Server has the LI_ALARM bit set" 2294msgid "Server has the LI_ALARM bit set"
2790msgstr "" 2295msgstr ""
2791 2296
2792#: plugins/check_ntp_peer.c:672
2793msgid "" 2297msgid ""
2794"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized" 2298"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"
2795msgstr "" 2299msgstr ""
2796 2300
2797#: plugins/check_ntp_peer.c:678
2798#, fuzzy 2301#, fuzzy
2799msgid "Warning threshold for stratum of server's synchronization peer" 2302msgid "Warning threshold for stratum of server's synchronization peer"
2800msgstr "Warning threshold Integer sein" 2303msgstr "Warning threshold Integer sein"
2801 2304
2802#: plugins/check_ntp_peer.c:680
2803#, fuzzy 2305#, fuzzy
2804msgid "Critical threshold for stratum of server's synchronization peer" 2306msgid "Critical threshold for stratum of server's synchronization peer"
2805msgstr "Critical threshold muss ein Integer sein" 2307msgstr "Critical threshold muss ein Integer sein"
2806 2308
2807#: plugins/check_ntp_peer.c:686
2808#, fuzzy 2309#, fuzzy
2809msgid "Warning threshold for number of usable time sources (\"truechimers\")" 2310msgid "Warning threshold for number of usable time sources (\"truechimers\")"
2810msgstr "Warning threshold muss ein positiver Integer sein\n" 2311msgstr "Warning threshold muss ein positiver Integer sein\n"
2811 2312
2812#: plugins/check_ntp_peer.c:688
2813#, fuzzy 2313#, fuzzy
2814msgid "Critical threshold for number of usable time sources (\"truechimers\")" 2314msgid "Critical threshold for number of usable time sources (\"truechimers\")"
2815msgstr "Critical threshold muss ein positiver Integer sein\n" 2315msgstr "Critical threshold muss ein positiver Integer sein\n"
2816 2316
2817#: plugins/check_ntp_peer.c:693
2818msgid "This plugin checks an NTP server independent of any commandline" 2317msgid "This plugin checks an NTP server independent of any commandline"
2819msgstr "" 2318msgstr ""
2820 2319
2821#: plugins/check_ntp_peer.c:694
2822msgid "programs or external libraries." 2320msgid "programs or external libraries."
2823msgstr "" 2321msgstr ""
2824 2322
2825#: plugins/check_ntp_peer.c:697
2826#, fuzzy 2323#, fuzzy
2827msgid "Use this plugin to check the health of an NTP server. It supports" 2324msgid "Use this plugin to check the health of an NTP server. It supports"
2828msgstr "" 2325msgstr ""
2829"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 2326"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2830"\n" 2327"\n"
2831 2328
2832#: plugins/check_ntp_peer.c:698
2833msgid "checking the offset with the sync peer, the jitter and stratum. This" 2329msgid "checking the offset with the sync peer, the jitter and stratum. This"
2834msgstr "" 2330msgstr ""
2835 2331
2836#: plugins/check_ntp_peer.c:699
2837msgid "plugin will not check the clock offset between the local host and NTP" 2332msgid "plugin will not check the clock offset between the local host and NTP"
2838msgstr "" 2333msgstr ""
2839 2334
2840#: plugins/check_ntp_peer.c:700
2841msgid "server; please use check_ntp_time for that purpose." 2335msgid "server; please use check_ntp_time for that purpose."
2842msgstr "" 2336msgstr ""
2843 2337
2844#: plugins/check_ntp_peer.c:706
2845msgid "Simple NTP server check:" 2338msgid "Simple NTP server check:"
2846msgstr "" 2339msgstr ""
2847 2340
2848#: plugins/check_ntp_peer.c:713
2849msgid "Only check the number of usable time sources (\"truechimers\"):" 2341msgid "Only check the number of usable time sources (\"truechimers\"):"
2850msgstr "" 2342msgstr ""
2851 2343
2852#: plugins/check_ntp_peer.c:716
2853msgid "Check only stratum:" 2344msgid "Check only stratum:"
2854msgstr "" 2345msgstr ""
2855 2346
2856#: plugins/check_ntp_time.c:602
2857#, fuzzy 2347#, fuzzy
2858msgid "This plugin checks the clock offset with the ntp server" 2348msgid "This plugin checks the clock offset with the ntp server"
2859msgstr "" 2349msgstr ""
2860"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 2350"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2861"\n" 2351"\n"
2862 2352
2863#: plugins/check_ntp_time.c:612
2864msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found" 2353msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found"
2865msgstr "" 2354msgstr ""
2866 2355
2867#: plugins/check_ntp_time.c:621 2356msgid "Expected offset of the ntp server relative to local server (seconds)"
2357msgstr ""
2358
2868#, fuzzy 2359#, fuzzy
2869msgid "This plugin checks the clock offset between the local host and a" 2360msgid "This plugin checks the clock offset between the local host and a"
2870msgstr "" 2361msgstr ""
2871"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n" 2362"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n"
2872"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 2363"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
2873"unterschritten wird.\n" 2364"unterschritten wird.\n"
2874"\n" 2365"\n"
2875 2366
2876#: plugins/check_ntp_time.c:622
2877msgid "remote NTP server. It is independent of any commandline programs or" 2367msgid "remote NTP server. It is independent of any commandline programs or"
2878msgstr "" 2368msgstr ""
2879 2369
2880#: plugins/check_ntp_time.c:623
2881msgid "external libraries." 2370msgid "external libraries."
2882msgstr "" 2371msgstr ""
2883 2372
2884#: plugins/check_ntp_time.c:627
2885msgid "If you'd rather want to monitor an NTP server, please use" 2373msgid "If you'd rather want to monitor an NTP server, please use"
2886msgstr "" 2374msgstr ""
2887 2375
2888#: plugins/check_ntp_time.c:628
2889msgid "check_ntp_peer." 2376msgid "check_ntp_peer."
2890msgstr "" 2377msgstr ""
2891 2378
2892#: plugins/check_nwstat.c:194 2379msgid "--time-offset is useful for compensating for servers with known"
2380msgstr ""
2381
2382msgid "and expected clock skew."
2383msgstr ""
2384
2893#, c-format 2385#, c-format
2894msgid "NetWare %s: " 2386msgid "NetWare %s: "
2895msgstr "" 2387msgstr ""
2896 2388
2897#: plugins/check_nwstat.c:232
2898#, c-format 2389#, c-format
2899msgid "Up %s," 2390msgid "Up %s,"
2900msgstr "" 2391msgstr ""
2901 2392
2902#: plugins/check_nwstat.c:240
2903#, c-format 2393#, c-format
2904msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100" 2394msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"
2905msgstr "" 2395msgstr ""
2906 2396
2907#: plugins/check_nwstat.c:268
2908#, c-format 2397#, c-format
2909msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;" 2398msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"
2910msgstr "" 2399msgstr ""
2911 2400
2912#: plugins/check_nwstat.c:293
2913#, c-format 2401#, c-format
2914msgid "%s: Long term cache hits = %lu%%" 2402msgid "%s: Long term cache hits = %lu%%"
2915msgstr "" 2403msgstr ""
2916 2404
2917#: plugins/check_nwstat.c:315
2918#, c-format 2405#, c-format
2919msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;" 2406msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"
2920msgstr "" 2407msgstr ""
2921 2408
2922#: plugins/check_nwstat.c:340
2923#, c-format 2409#, c-format
2924msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;" 2410msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"
2925msgstr "" 2411msgstr ""
2926 2412
2927#: plugins/check_nwstat.c:365
2928#, c-format 2413#, c-format
2929msgid "%s: LRU sitting time = %lu minutes" 2414msgid "%s: LRU sitting time = %lu minutes"
2930msgstr "" 2415msgstr ""
2931 2416
2932#: plugins/check_nwstat.c:382 plugins/check_nwstat.c:410
2933#: plugins/check_nwstat.c:437 plugins/check_nwstat.c:470
2934#: plugins/check_nwstat.c:650 plugins/check_nwstat.c:676
2935#: plugins/check_nwstat.c:707 plugins/check_nwstat.c:753
2936#: plugins/check_nwstat.c:777
2937#, c-format 2417#, c-format
2938msgid "CRITICAL - Volume '%s' does not exist!" 2418msgid "CRITICAL - Volume '%s' does not exist!"
2939msgstr "" 2419msgstr ""
2940 2420
2941#: plugins/check_nwstat.c:391
2942#, c-format 2421#, c-format
2943msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;" 2422msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"
2944msgstr "" 2423msgstr ""
2945 2424
2946#: plugins/check_nwstat.c:392 plugins/check_nwstat.c:420
2947#: plugins/check_nwstat.c:447 plugins/check_nwstat.c:659
2948#: plugins/check_nwstat.c:685 plugins/check_nwstat.c:761
2949msgid "Only " 2425msgid "Only "
2950msgstr "" 2426msgstr ""
2951 2427
2952#: plugins/check_nwstat.c:419
2953#, c-format 2428#, c-format
2954msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;" 2429msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"
2955msgstr "" 2430msgstr ""
2956 2431
2957#: plugins/check_nwstat.c:446
2958#, c-format 2432#, c-format
2959msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;" 2433msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"
2960msgstr "" 2434msgstr ""
2961 2435
2962#: plugins/check_nwstat.c:494
2963#, c-format 2436#, c-format
2964msgid "" 2437msgid ""
2965"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100" 2438"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"
2966msgstr "" 2439msgstr ""
2967 2440
2968#: plugins/check_nwstat.c:528
2969#, c-format 2441#, c-format
2970msgid "Directory Services Database is %s (DS version %s)" 2442msgid "Directory Services Database is %s (DS version %s)"
2971msgstr "" 2443msgstr ""
2972 2444
2973#: plugins/check_nwstat.c:545
2974#, c-format 2445#, c-format
2975msgid "Logins are %s" 2446msgid "Logins are %s"
2976msgstr "" 2447msgstr ""
2977 2448
2978#: plugins/check_nwstat.c:545
2979msgid "enabled" 2449msgid "enabled"
2980msgstr "" 2450msgstr ""
2981 2451
2982#: plugins/check_nwstat.c:545
2983msgid "disabled" 2452msgid "disabled"
2984msgstr "" 2453msgstr ""
2985 2454
2986#: plugins/check_nwstat.c:560
2987#, fuzzy 2455#, fuzzy
2988msgid "CRITICAL - NRM Status is bad!" 2456msgid "CRITICAL - NRM Status is bad!"
2989msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 2457msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
2990 2458
2991#: plugins/check_nwstat.c:565
2992msgid "Warning - NRM Status is suspect!" 2459msgid "Warning - NRM Status is suspect!"
2993msgstr "" 2460msgstr ""
2994 2461
2995#: plugins/check_nwstat.c:568
2996msgid "OK - NRM Status is good!" 2462msgid "OK - NRM Status is good!"
2997msgstr "" 2463msgstr ""
2998 2464
2999#: plugins/check_nwstat.c:610
3000#, c-format 2465#, c-format
3001msgid "%lu of %lu (%lu%%) packet receive buffers used" 2466msgid "%lu of %lu (%lu%%) packet receive buffers used"
3002msgstr "" 2467msgstr ""
3003 2468
3004#: plugins/check_nwstat.c:634
3005#, c-format 2469#, c-format
3006msgid "%lu entries in SAP table" 2470msgid "%lu entries in SAP table"
3007msgstr "" 2471msgstr ""
3008 2472
3009#: plugins/check_nwstat.c:636
3010#, c-format 2473#, c-format
3011msgid "%lu entries in SAP table for SAP type %d" 2474msgid "%lu entries in SAP table for SAP type %d"
3012msgstr "" 2475msgstr ""
3013 2476
3014#: plugins/check_nwstat.c:658
3015#, c-format 2477#, c-format
3016msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2478msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3017msgstr "" 2479msgstr ""
3018 2480
3019#: plugins/check_nwstat.c:684
3020#, c-format 2481#, c-format
3021msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2482msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3022msgstr "" 2483msgstr ""
3023 2484
3024#: plugins/check_nwstat.c:730
3025#, c-format 2485#, c-format
3026msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100" 2486msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"
3027msgstr "" 2487msgstr ""
3028 2488
3029#: plugins/check_nwstat.c:761
3030#, c-format 2489#, c-format
3031msgid "%s%lu KB not yet purgeable on volume %s" 2490msgid "%s%lu KB not yet purgeable on volume %s"
3032msgstr "" 2491msgstr ""
3033 2492
3034#: plugins/check_nwstat.c:800
3035#, c-format 2493#, c-format
3036msgid "%lu MB (%lu%%) not yet purgeable on volume %s" 2494msgid "%lu MB (%lu%%) not yet purgeable on volume %s"
3037msgstr "" 2495msgstr ""
3038 2496
3039#: plugins/check_nwstat.c:821
3040#, c-format 2497#, c-format
3041msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0" 2498msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0"
3042msgstr "" 2499msgstr ""
3043 2500
3044#: plugins/check_nwstat.c:846
3045#, c-format 2501#, c-format
3046msgid "%lu abended threads|Abends=%lu;%lu;%lu;;" 2502msgid "%lu abended threads|Abends=%lu;%lu;%lu;;"
3047msgstr "" 2503msgstr ""
3048 2504
3049#: plugins/check_nwstat.c:881
3050#, c-format 2505#, c-format
3051msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu" 2506msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"
3052msgstr "" 2507msgstr ""
3053 2508
3054#: plugins/check_nwstat.c:904
3055msgid "CRITICAL - Time not in sync with network!" 2509msgid "CRITICAL - Time not in sync with network!"
3056msgstr "" 2510msgstr ""
3057 2511
3058#: plugins/check_nwstat.c:907
3059msgid "OK - Time in sync with network!" 2512msgid "OK - Time in sync with network!"
3060msgstr "" 2513msgstr ""
3061 2514
3062#: plugins/check_nwstat.c:930
3063#, c-format 2515#, c-format
3064msgid "LRU sitting time = %lu seconds" 2516msgid "LRU sitting time = %lu seconds"
3065msgstr "" 2517msgstr ""
3066 2518
3067#: plugins/check_nwstat.c:949
3068#, c-format 2519#, c-format
3069msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100" 2520msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"
3070msgstr "" 2521msgstr ""
3071 2522
3072#: plugins/check_nwstat.c:971
3073#, c-format 2523#, c-format
3074msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100" 2524msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"
3075msgstr "" 2525msgstr ""
3076 2526
3077#: plugins/check_nwstat.c:989
3078#, c-format 2527#, c-format
3079msgid "NDS Version %s" 2528msgid "NDS Version %s"
3080msgstr "" 2529msgstr ""
3081 2530
3082#: plugins/check_nwstat.c:1005
3083#, c-format 2531#, c-format
3084msgid "Up %s" 2532msgid "Up %s"
3085msgstr "" 2533msgstr ""
3086 2534
3087#: plugins/check_nwstat.c:1019
3088#, c-format 2535#, c-format
3089msgid "Module %s version %s is loaded" 2536msgid "Module %s version %s is loaded"
3090msgstr "" 2537msgstr ""
3091 2538
3092#: plugins/check_nwstat.c:1022
3093#, c-format 2539#, c-format
3094msgid "Module %s is not loaded" 2540msgid "Module %s is not loaded"
3095msgstr "" 2541msgstr ""
3096 2542
3097#: plugins/check_nwstat.c:1033 plugins/check_nwstat.c:1059
3098#: plugins/check_nwstat.c:1085 plugins/check_nwstat.c:1111
3099#: plugins/check_nwstat.c:1137 plugins/check_nwstat.c:1163
3100#: plugins/check_nwstat.c:1189 plugins/check_nwstat.c:1215
3101#: plugins/check_nwstat.c:1241 plugins/check_nwstat.c:1267
3102#, fuzzy, c-format 2543#, fuzzy, c-format
3103msgid "CRITICAL - Value '%s' does not exist!" 2544msgid "CRITICAL - Value '%s' does not exist!"
3104msgstr "%s [%s nicht gefunden]" 2545msgstr "%s [%s nicht gefunden]"
3105 2546
3106#: plugins/check_nwstat.c:1042 plugins/check_nwstat.c:1068
3107#: plugins/check_nwstat.c:1094 plugins/check_nwstat.c:1120
3108#: plugins/check_nwstat.c:1146 plugins/check_nwstat.c:1172
3109#: plugins/check_nwstat.c:1198 plugins/check_nwstat.c:1224
3110#: plugins/check_nwstat.c:1250 plugins/check_nwstat.c:1276
3111#, c-format 2547#, c-format
3112msgid "%s is %lu|%s=%lu;%lu;%lu;;" 2548msgid "%s is %lu|%s=%lu;%lu;%lu;;"
3113msgstr "" 2549msgstr ""
3114 2550
3115#: plugins/check_nwstat.c:1289 plugins/check_overcr.c:285
3116msgid "Nothing to check!\n" 2551msgid "Nothing to check!\n"
3117msgstr "" 2552msgstr ""
3118 2553
3119#: plugins/check_nwstat.c:1371 plugins/check_overcr.c:355
3120#, fuzzy 2554#, fuzzy
3121msgid "Server port an integer\n" 2555msgid "Server port an integer\n"
3122msgstr "skip lines muss ein Integer sein" 2556msgstr "skip lines muss ein Integer sein"
3123 2557
3124#: plugins/check_nwstat.c:1601
3125msgid "This plugin attempts to contact the MRTGEXT NLM running on a" 2558msgid "This plugin attempts to contact the MRTGEXT NLM running on a"
3126msgstr "" 2559msgstr ""
3127 2560
3128#: plugins/check_nwstat.c:1602
3129msgid "Novell server to gather the requested system information." 2561msgid "Novell server to gather the requested system information."
3130msgstr "" 2562msgstr ""
3131 2563
3132#: plugins/check_nwstat.c:1614 plugins/check_overcr.c:436
3133msgid "Variable to check. Valid variables include:" 2564msgid "Variable to check. Valid variables include:"
3134msgstr "" 2565msgstr ""
3135 2566
3136#: plugins/check_nwstat.c:1615
3137msgid "LOAD1 = 1 minute average CPU load" 2567msgid "LOAD1 = 1 minute average CPU load"
3138msgstr "" 2568msgstr ""
3139 2569
3140#: plugins/check_nwstat.c:1616
3141msgid "LOAD5 = 5 minute average CPU load" 2570msgid "LOAD5 = 5 minute average CPU load"
3142msgstr "" 2571msgstr ""
3143 2572
3144#: plugins/check_nwstat.c:1617
3145msgid "LOAD15 = 15 minute average CPU load" 2573msgid "LOAD15 = 15 minute average CPU load"
3146msgstr "" 2574msgstr ""
3147 2575
3148#: plugins/check_nwstat.c:1618
3149msgid "CSPROCS = number of current service processes (NW 5.x only)" 2576msgid "CSPROCS = number of current service processes (NW 5.x only)"
3150msgstr "" 2577msgstr ""
3151 2578
3152#: plugins/check_nwstat.c:1619
3153msgid "ABENDS = number of abended threads (NW 5.x only)" 2579msgid "ABENDS = number of abended threads (NW 5.x only)"
3154msgstr "" 2580msgstr ""
3155 2581
3156#: plugins/check_nwstat.c:1620
3157msgid "UPTIME = server uptime" 2582msgid "UPTIME = server uptime"
3158msgstr "" 2583msgstr ""
3159 2584
3160#: plugins/check_nwstat.c:1621
3161msgid "LTCH = percent long term cache hits" 2585msgid "LTCH = percent long term cache hits"
3162msgstr "" 2586msgstr ""
3163 2587
3164#: plugins/check_nwstat.c:1622
3165msgid "CBUFF = current number of cache buffers" 2588msgid "CBUFF = current number of cache buffers"
3166msgstr "" 2589msgstr ""
3167 2590
3168#: plugins/check_nwstat.c:1623
3169msgid "CDBUFF = current number of dirty cache buffers" 2591msgid "CDBUFF = current number of dirty cache buffers"
3170msgstr "" 2592msgstr ""
3171 2593
3172#: plugins/check_nwstat.c:1624
3173msgid "DCB = dirty cache buffers as a percentage of the total" 2594msgid "DCB = dirty cache buffers as a percentage of the total"
3174msgstr "" 2595msgstr ""
3175 2596
3176#: plugins/check_nwstat.c:1625
3177msgid "TCB = dirty cache buffers as a percentage of the original" 2597msgid "TCB = dirty cache buffers as a percentage of the original"
3178msgstr "" 2598msgstr ""
3179 2599
3180#: plugins/check_nwstat.c:1626
3181msgid "OFILES = number of open files" 2600msgid "OFILES = number of open files"
3182msgstr "" 2601msgstr ""
3183 2602
3184#: plugins/check_nwstat.c:1627
3185msgid " VMF<vol> = MB of free space on Volume <vol>" 2603msgid " VMF<vol> = MB of free space on Volume <vol>"
3186msgstr "" 2604msgstr ""
3187 2605
3188#: plugins/check_nwstat.c:1628
3189msgid " VMU<vol> = MB used space on Volume <vol>" 2606msgid " VMU<vol> = MB used space on Volume <vol>"
3190msgstr "" 2607msgstr ""
3191 2608
3192#: plugins/check_nwstat.c:1629
3193msgid " VMP<vol> = MB of purgeable space on Volume <vol>" 2609msgid " VMP<vol> = MB of purgeable space on Volume <vol>"
3194msgstr "" 2610msgstr ""
3195 2611
3196#: plugins/check_nwstat.c:1630
3197msgid " VPF<vol> = percent free space on volume <vol>" 2612msgid " VPF<vol> = percent free space on volume <vol>"
3198msgstr "" 2613msgstr ""
3199 2614
3200#: plugins/check_nwstat.c:1631
3201msgid " VKF<vol> = KB of free space on volume <vol>" 2615msgid " VKF<vol> = KB of free space on volume <vol>"
3202msgstr "" 2616msgstr ""
3203 2617
3204#: plugins/check_nwstat.c:1632
3205msgid " VPP<vol> = percent purgeable space on volume <vol>" 2618msgid " VPP<vol> = percent purgeable space on volume <vol>"
3206msgstr "" 2619msgstr ""
3207 2620
3208#: plugins/check_nwstat.c:1633
3209msgid " VKP<vol> = KB of purgeable space on volume <vol>" 2621msgid " VKP<vol> = KB of purgeable space on volume <vol>"
3210msgstr "" 2622msgstr ""
3211 2623
3212#: plugins/check_nwstat.c:1634
3213msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>" 2624msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>"
3214msgstr "" 2625msgstr ""
3215 2626
3216#: plugins/check_nwstat.c:1635
3217msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>" 2627msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>"
3218msgstr "" 2628msgstr ""
3219 2629
3220#: plugins/check_nwstat.c:1636
3221msgid " LRUM = LRU sitting time in minutes" 2630msgid " LRUM = LRU sitting time in minutes"
3222msgstr "" 2631msgstr ""
3223 2632
3224#: plugins/check_nwstat.c:1637
3225msgid " LRUS = LRU sitting time in seconds" 2633msgid " LRUS = LRU sitting time in seconds"
3226msgstr "" 2634msgstr ""
3227 2635
3228#: plugins/check_nwstat.c:1638
3229msgid " DSDB = check to see if DS Database is open" 2636msgid " DSDB = check to see if DS Database is open"
3230msgstr "" 2637msgstr ""
3231 2638
3232#: plugins/check_nwstat.c:1639
3233msgid " DSVER = NDS version" 2639msgid " DSVER = NDS version"
3234msgstr "" 2640msgstr ""
3235 2641
3236#: plugins/check_nwstat.c:1640
3237msgid " UPRB = used packet receive buffers" 2642msgid " UPRB = used packet receive buffers"
3238msgstr "" 2643msgstr ""
3239 2644
3240#: plugins/check_nwstat.c:1641
3241msgid " PUPRB = percent (of max) used packet receive buffers" 2645msgid " PUPRB = percent (of max) used packet receive buffers"
3242msgstr "" 2646msgstr ""
3243 2647
3244#: plugins/check_nwstat.c:1642
3245msgid " SAPENTRIES = number of entries in the SAP table" 2648msgid " SAPENTRIES = number of entries in the SAP table"
3246msgstr "" 2649msgstr ""
3247 2650
3248#: plugins/check_nwstat.c:1643
3249msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>" 2651msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"
3250msgstr "" 2652msgstr ""
3251 2653
3252#: plugins/check_nwstat.c:1644
3253msgid " TSYNC = timesync status" 2654msgid " TSYNC = timesync status"
3254msgstr "" 2655msgstr ""
3255 2656
3256#: plugins/check_nwstat.c:1645
3257msgid " LOGINS = check to see if logins are enabled" 2657msgid " LOGINS = check to see if logins are enabled"
3258msgstr "" 2658msgstr ""
3259 2659
3260#: plugins/check_nwstat.c:1646
3261msgid " CONNS = number of currently licensed connections" 2660msgid " CONNS = number of currently licensed connections"
3262msgstr "" 2661msgstr ""
3263 2662
3264#: plugins/check_nwstat.c:1647
3265msgid " NRMH\t= NRM Summary Status" 2663msgid " NRMH\t= NRM Summary Status"
3266msgstr "" 2664msgstr ""
3267 2665
3268#: plugins/check_nwstat.c:1648
3269msgid " NRMP<stat> = Returns the current value for a NRM health item" 2666msgid " NRMP<stat> = Returns the current value for a NRM health item"
3270msgstr "" 2667msgstr ""
3271 2668
3272#: plugins/check_nwstat.c:1649
3273msgid " NRMM<stat> = Returns the current memory stats from NRM" 2669msgid " NRMM<stat> = Returns the current memory stats from NRM"
3274msgstr "" 2670msgstr ""
3275 2671
3276#: plugins/check_nwstat.c:1650
3277msgid " NRMS<stat> = Returns the current Swapfile stats from NRM" 2672msgid " NRMS<stat> = Returns the current Swapfile stats from NRM"
3278msgstr "" 2673msgstr ""
3279 2674
3280#: plugins/check_nwstat.c:1651
3281msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml" 2675msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"
3282msgstr "" 2676msgstr ""
3283 2677
3284#: plugins/check_nwstat.c:1652
3285msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml" 2678msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"
3286msgstr "" 2679msgstr ""
3287 2680
3288#: plugins/check_nwstat.c:1653
3289msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml" 2681msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"
3290msgstr "" 2682msgstr ""
3291 2683
3292#: plugins/check_nwstat.c:1654
3293msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml" 2684msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"
3294msgstr "" 2685msgstr ""
3295 2686
3296#: plugins/check_nwstat.c:1655
3297msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml" 2687msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"
3298msgstr "" 2688msgstr ""
3299 2689
3300#: plugins/check_nwstat.c:1656
3301msgid "" 2690msgid ""
3302" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml" 2691" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"
3303msgstr "" 2692msgstr ""
3304 2693
3305#: plugins/check_nwstat.c:1657
3306msgid " NLM:<nlm> = check if NLM is loaded and report version" 2694msgid " NLM:<nlm> = check if NLM is loaded and report version"
3307msgstr "" 2695msgstr ""
3308 2696
3309#: plugins/check_nwstat.c:1658
3310msgid " (e.g. NLM:TSANDS.NLM)" 2697msgid " (e.g. NLM:TSANDS.NLM)"
3311msgstr "" 2698msgstr ""
3312 2699
3313#: plugins/check_nwstat.c:1665
3314msgid "Include server version string in results" 2700msgid "Include server version string in results"
3315msgstr "" 2701msgstr ""
3316 2702
3317#: plugins/check_nwstat.c:1671 2703msgid "- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"
3318msgid "- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"
3319msgstr "" 2704msgstr ""
3320 2705
3321#: plugins/check_nwstat.c:1672
3322msgid "" 2706msgid ""
3323" extension for NetWare be loaded on the Novell servers you wish to check." 2707" extension for NetWare be loaded on the Novell servers you wish to check."
3324msgstr "" 2708msgstr ""
3325 2709
3326#: plugins/check_nwstat.c:1673
3327msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)" 2710msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)"
3328msgstr "" 2711msgstr ""
3329 2712
3330#: plugins/check_nwstat.c:1674
3331msgid "" 2713msgid ""
3332"- Values for critical thresholds should be lower than warning thresholds" 2714"- Values for critical thresholds should be lower than warning thresholds"
3333msgstr "" 2715msgstr ""
3334 2716
3335#: plugins/check_nwstat.c:1675
3336msgid "" 2717msgid ""
3337" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, " 2718" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "
3338msgstr "" 2719msgstr ""
3339 2720
3340#: plugins/check_nwstat.c:1676
3341msgid " TCB, LRUS and LRUM." 2721msgid " TCB, LRUS and LRUM."
3342msgstr "" 2722msgstr ""
3343 2723
3344#: plugins/check_overcr.c:123
3345msgid "Unknown error fetching load data\n" 2724msgid "Unknown error fetching load data\n"
3346msgstr "" 2725msgstr ""
3347 2726
3348#: plugins/check_overcr.c:127
3349msgid "Invalid response from server - no load information\n" 2727msgid "Invalid response from server - no load information\n"
3350msgstr "" 2728msgstr ""
3351 2729
3352#: plugins/check_overcr.c:133
3353msgid "Invalid response from server after load 1\n" 2730msgid "Invalid response from server after load 1\n"
3354msgstr "" 2731msgstr ""
3355 2732
3356#: plugins/check_overcr.c:139
3357msgid "Invalid response from server after load 5\n" 2733msgid "Invalid response from server after load 5\n"
3358msgstr "" 2734msgstr ""
3359 2735
3360#: plugins/check_overcr.c:164
3361#, c-format 2736#, c-format
3362msgid "Load %s - %s-min load average = %0.2f" 2737msgid "Load %s - %s-min load average = %0.2f"
3363msgstr "" 2738msgstr ""
3364 2739
3365#: plugins/check_overcr.c:174
3366msgid "Unknown error fetching disk data\n" 2740msgid "Unknown error fetching disk data\n"
3367msgstr "" 2741msgstr ""
3368 2742
3369#: plugins/check_overcr.c:184 plugins/check_overcr.c:236
3370#: plugins/check_overcr.c:240
3371msgid "Invalid response from server\n" 2743msgid "Invalid response from server\n"
3372msgstr "" 2744msgstr ""
3373 2745
3374#: plugins/check_overcr.c:211
3375msgid "Unknown error fetching network status\n" 2746msgid "Unknown error fetching network status\n"
3376msgstr "" 2747msgstr ""
3377 2748
3378#: plugins/check_overcr.c:221
3379#, c-format 2749#, c-format
3380msgid "Net %s - %d connection%s on port %d" 2750msgid "Net %s - %d connection%s on port %d"
3381msgstr "" 2751msgstr ""
3382 2752
3383#: plugins/check_overcr.c:232
3384msgid "Unknown error fetching process status\n" 2753msgid "Unknown error fetching process status\n"
3385msgstr "" 2754msgstr ""
3386 2755
3387#: plugins/check_overcr.c:250
3388#, c-format 2756#, c-format
3389msgid "Process %s - %d instance%s of %s running" 2757msgid "Process %s - %d instance%s of %s running"
3390msgstr "" 2758msgstr ""
3391 2759
3392#: plugins/check_overcr.c:277
3393#, c-format 2760#, c-format
3394msgid "Uptime %s - Up %d days %d hours %d minutes" 2761msgid "Uptime %s - Up %d days %d hours %d minutes"
3395msgstr "" 2762msgstr ""
3396 2763
3397#: plugins/check_overcr.c:419
3398msgid "" 2764msgid ""
3399"This plugin attempts to contact the Over-CR collector daemon running on the" 2765"This plugin attempts to contact the Over-CR collector daemon running on the"
3400msgstr "" 2766msgstr ""
3401 2767
3402#: plugins/check_overcr.c:420
3403msgid "remote UNIX server in order to gather the requested system information." 2768msgid "remote UNIX server in order to gather the requested system information."
3404msgstr "" 2769msgstr ""
3405 2770
3406#: plugins/check_overcr.c:437
3407msgid "LOAD1 = 1 minute average CPU load" 2771msgid "LOAD1 = 1 minute average CPU load"
3408msgstr "" 2772msgstr ""
3409 2773
3410#: plugins/check_overcr.c:438
3411msgid "LOAD5 = 5 minute average CPU load" 2774msgid "LOAD5 = 5 minute average CPU load"
3412msgstr "" 2775msgstr ""
3413 2776
3414#: plugins/check_overcr.c:439
3415msgid "LOAD15 = 15 minute average CPU load" 2777msgid "LOAD15 = 15 minute average CPU load"
3416msgstr "" 2778msgstr ""
3417 2779
3418#: plugins/check_overcr.c:440
3419msgid "DPU<filesys> = percent used disk space on filesystem <filesys>" 2780msgid "DPU<filesys> = percent used disk space on filesystem <filesys>"
3420msgstr "" 2781msgstr ""
3421 2782
3422#: plugins/check_overcr.c:441
3423msgid "PROC<process> = number of running processes with name <process>" 2783msgid "PROC<process> = number of running processes with name <process>"
3424msgstr "" 2784msgstr ""
3425 2785
3426#: plugins/check_overcr.c:442
3427msgid "NET<port> = number of active connections on TCP port <port>" 2786msgid "NET<port> = number of active connections on TCP port <port>"
3428msgstr "" 2787msgstr ""
3429 2788
3430#: plugins/check_overcr.c:443
3431msgid "UPTIME = system uptime in seconds" 2789msgid "UPTIME = system uptime in seconds"
3432msgstr "" 2790msgstr ""
3433 2791
3434#: plugins/check_overcr.c:450
3435msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be" 2792msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be"
3436msgstr "" 2793msgstr ""
3437 2794
3438#: plugins/check_overcr.c:451
3439msgid "running on the remote server." 2795msgid "running on the remote server."
3440msgstr "" 2796msgstr ""
3441 2797
3442#: plugins/check_overcr.c:452
3443msgid "Over-CR can be downloaded from http://www.molitor.org/overcr" 2798msgid "Over-CR can be downloaded from http://www.molitor.org/overcr"
3444msgstr "" 2799msgstr ""
3445 2800
3446#: plugins/check_overcr.c:453
3447msgid "This plugin was tested with version 0.99.53 of the Over-CR collector" 2801msgid "This plugin was tested with version 0.99.53 of the Over-CR collector"
3448msgstr "" 2802msgstr ""
3449 2803
3450#: plugins/check_overcr.c:457
3451msgid "" 2804msgid ""
3452"For the available options, the critical threshold value should always be" 2805"For the available options, the critical threshold value should always be"
3453msgstr "" 2806msgstr ""
3454 2807
3455#: plugins/check_overcr.c:458
3456msgid "" 2808msgid ""
3457"higher than the warning threshold value, EXCEPT with the uptime variable" 2809"higher than the warning threshold value, EXCEPT with the uptime variable"
3458msgstr "" 2810msgstr ""
3459 2811
3460#: plugins/check_pgsql.c:222
3461#, c-format 2812#, c-format
3462msgid "CRITICAL - no connection to '%s' (%s).\n" 2813msgid "CRITICAL - no connection to '%s' (%s).\n"
3463msgstr "" 2814msgstr ""
3464 2815
3465#: plugins/check_pgsql.c:250
3466#, c-format 2816#, c-format
3467msgid " %s - database %s (%f sec.)|%s\n" 2817msgid " %s - database %s (%f sec.)|%s\n"
3468msgstr "" 2818msgstr ""
3469 2819
3470#: plugins/check_pgsql.c:317 plugins/check_time.c:277 plugins/check_time.c:289
3471#: plugins/check_users.c:181
3472msgid "Critical threshold must be a positive integer" 2820msgid "Critical threshold must be a positive integer"
3473msgstr "Critical threshold muss ein positiver Integer sein" 2821msgstr "Critical threshold muss ein positiver Integer sein"
3474 2822
3475#: plugins/check_pgsql.c:323 plugins/check_time.c:258 plugins/check_time.c:282
3476#: plugins/check_users.c:187 plugins/check_users.c:197
3477#: plugins/check_users.c:203
3478msgid "Warning threshold must be a positive integer" 2823msgid "Warning threshold must be a positive integer"
3479msgstr "Warning threshold muss ein positiver Integer sein" 2824msgstr "Warning threshold muss ein positiver Integer sein"
3480 2825
3481#: plugins/check_pgsql.c:347 2826msgid "Database name exceeds the maximum length"
3482msgid "Database name is not valid"
3483msgstr "" 2827msgstr ""
3484 2828
3485#: plugins/check_pgsql.c:353
3486msgid "User name is not valid" 2829msgid "User name is not valid"
3487msgstr "" 2830msgstr ""
3488 2831
3489#: plugins/check_pgsql.c:504
3490#, c-format 2832#, c-format
3491msgid "Test whether a PostgreSQL Database is accepting connections." 2833msgid "Test whether a PostgreSQL Database is accepting connections."
3492msgstr "" 2834msgstr ""
3493 2835
3494#: plugins/check_pgsql.c:516
3495msgid "Database to check " 2836msgid "Database to check "
3496msgstr "" 2837msgstr ""
3497 2838
3498#: plugins/check_pgsql.c:517
3499#, c-format 2839#, c-format
3500msgid "(default: %s)" 2840msgid "(default: %s)\n"
3501msgstr "" 2841msgstr ""
3502 2842
3503#: plugins/check_pgsql.c:519
3504msgid "Login name of user" 2843msgid "Login name of user"
3505msgstr "" 2844msgstr ""
3506 2845
3507#: plugins/check_pgsql.c:521
3508msgid "Password (BIG SECURITY ISSUE)" 2846msgid "Password (BIG SECURITY ISSUE)"
3509msgstr "" 2847msgstr ""
3510 2848
3511#: plugins/check_pgsql.c:523
3512msgid "Connection parameters (keyword = value), see below" 2849msgid "Connection parameters (keyword = value), see below"
3513msgstr "" 2850msgstr ""
3514 2851
3515#: plugins/check_pgsql.c:530
3516msgid "SQL query to run. Only first column in first row will be read" 2852msgid "SQL query to run. Only first column in first row will be read"
3517msgstr "" 2853msgstr ""
3518 2854
3519#: plugins/check_pgsql.c:532 2855msgid "A name for the query, this string is used instead of the query"
2856msgstr ""
2857
2858msgid "in the long output of the plugin"
2859msgstr ""
2860
3520msgid "SQL query value to result in warning status (double)" 2861msgid "SQL query value to result in warning status (double)"
3521msgstr "" 2862msgstr ""
3522 2863
3523#: plugins/check_pgsql.c:534
3524msgid "SQL query value to result in critical status (double)" 2864msgid "SQL query value to result in critical status (double)"
3525msgstr "" 2865msgstr ""
3526 2866
3527#: plugins/check_pgsql.c:539
3528msgid "All parameters are optional." 2867msgid "All parameters are optional."
3529msgstr "" 2868msgstr ""
3530 2869
3531#: plugins/check_pgsql.c:540
3532msgid "" 2870msgid ""
3533"This plugin tests a PostgreSQL DBMS to determine whether it is active and" 2871"This plugin tests a PostgreSQL DBMS to determine whether it is active and"
3534msgstr "" 2872msgstr ""
3535 2873
3536#: plugins/check_pgsql.c:541
3537msgid "accepting queries. In its current operation, it simply connects to the" 2874msgid "accepting queries. In its current operation, it simply connects to the"
3538msgstr "" 2875msgstr ""
3539 2876
3540#: plugins/check_pgsql.c:542
3541msgid "" 2877msgid ""
3542"specified database, and then disconnects. If no database is specified, it" 2878"specified database, and then disconnects. If no database is specified, it"
3543msgstr "" 2879msgstr ""
3544 2880
3545#: plugins/check_pgsql.c:543
3546msgid "" 2881msgid ""
3547"connects to the template1 database, which is present in every functioning" 2882"connects to the template1 database, which is present in every functioning"
3548msgstr "" 2883msgstr ""
3549 2884
3550#: plugins/check_pgsql.c:544
3551msgid "PostgreSQL DBMS." 2885msgid "PostgreSQL DBMS."
3552msgstr "" 2886msgstr ""
3553 2887
3554#: plugins/check_pgsql.c:546
3555msgid "If a query is specified using the -q option, it will be executed after" 2888msgid "If a query is specified using the -q option, it will be executed after"
3556msgstr "" 2889msgstr ""
3557 2890
3558#: plugins/check_pgsql.c:547
3559msgid "connecting to the server. The result from the query has to be numeric." 2891msgid "connecting to the server. The result from the query has to be numeric."
3560msgstr "" 2892msgstr ""
3561 2893
3562#: plugins/check_pgsql.c:548
3563msgid "" 2894msgid ""
3564"Multiple SQL commands, separated by semicolon, are allowed but the result " 2895"Multiple SQL commands, separated by semicolon, are allowed but the result "
3565msgstr "" 2896msgstr ""
3566 2897
3567#: plugins/check_pgsql.c:549
3568msgid "of the last command is taken into account only. The value of the first" 2898msgid "of the last command is taken into account only. The value of the first"
3569msgstr "" 2899msgstr ""
3570 2900
3571#: plugins/check_pgsql.c:550 2901msgid ""
3572msgid "column in the first row is used as the check result." 2902"column in the first row is used as the check result. If a second column is"
2903msgstr ""
2904
2905msgid "present in the result set, this is added to the plugin output with a"
2906msgstr ""
2907
2908msgid ""
2909"prefix of \"Extra Info:\". This information can be displayed in the system"
2910msgstr ""
2911
2912msgid "executing the plugin."
3573msgstr "" 2913msgstr ""
3574 2914
3575#: plugins/check_pgsql.c:552
3576msgid "" 2915msgid ""
3577"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual" 2916"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"
3578msgstr "" 2917msgstr ""
3579 2918
3580#: plugins/check_pgsql.c:553
3581msgid "" 2919msgid ""
3582"for details about how to access internal statistics of the database server." 2920"for details about how to access internal statistics of the database server."
3583msgstr "" 2921msgstr ""
3584 2922
3585#: plugins/check_pgsql.c:555
3586msgid "" 2923msgid ""
3587"For a list of available connection parameters which may be used with the -o" 2924"For a list of available connection parameters which may be used with the -o"
3588msgstr "" 2925msgstr ""
3589 2926
3590#: plugins/check_pgsql.c:556
3591msgid "" 2927msgid ""
3592"command line option, see the documentation for PQconnectdb() in the chapter" 2928"command line option, see the documentation for PQconnectdb() in the chapter"
3593msgstr "" 2929msgstr ""
3594 2930
3595#: plugins/check_pgsql.c:557
3596msgid "" 2931msgid ""
3597"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be" 2932"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"
3598msgstr "" 2933msgstr ""
3599 2934
3600#: plugins/check_pgsql.c:558
3601msgid "" 2935msgid ""
3602"used to specify a service name in pg_service.conf to be used for additional" 2936"used to specify a service name in pg_service.conf to be used for additional"
3603msgstr "" 2937msgstr ""
3604 2938
3605#: plugins/check_pgsql.c:559
3606msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:" 2939msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:"
3607msgstr "" 2940msgstr ""
3608 2941
3609#: plugins/check_pgsql.c:560
3610msgid "-o 'sslmode=require'." 2942msgid "-o 'sslmode=require'."
3611msgstr "" 2943msgstr ""
3612 2944
3613#: plugins/check_pgsql.c:562
3614msgid "" 2945msgid ""
3615"The plugin will connect to a local postmaster if no host is specified. To" 2946"The plugin will connect to a local postmaster if no host is specified. To"
3616msgstr "" 2947msgstr ""
3617 2948
3618#: plugins/check_pgsql.c:563
3619msgid "" 2949msgid ""
3620"connect to a remote host, be sure that the remote postmaster accepts TCP/IP" 2950"connect to a remote host, be sure that the remote postmaster accepts TCP/IP"
3621msgstr "" 2951msgstr ""
3622 2952
3623#: plugins/check_pgsql.c:564
3624msgid "connections (start the postmaster with the -i option)." 2953msgid "connections (start the postmaster with the -i option)."
3625msgstr "" 2954msgstr ""
3626 2955
3627#: plugins/check_pgsql.c:566
3628msgid "" 2956msgid ""
3629"Typically, the monitoring user (unless the --logname option is used) should " 2957"Typically, the monitoring user (unless the --logname option is used) should "
3630"be" 2958"be"
3631msgstr "" 2959msgstr ""
3632 2960
3633#: plugins/check_pgsql.c:567
3634msgid "" 2961msgid ""
3635"able to connect to the database without a password. The plugin can also send" 2962"able to connect to the database without a password. The plugin can also send"
3636msgstr "" 2963msgstr ""
3637 2964
3638#: plugins/check_pgsql.c:568 2965msgid "a password, but no effort is made to obscure or encrypt the password."
3639msgid "a password, but no effort is made to obsure or encrypt the password."
3640msgstr "" 2966msgstr ""
3641 2967
3642#: plugins/check_pgsql.c:601
3643#, c-format 2968#, c-format
3644msgid "QUERY %s - %s: %s.\n" 2969msgid "QUERY %s - %s: %s.\n"
3645msgstr "" 2970msgstr ""
3646 2971
3647#: plugins/check_pgsql.c:601
3648msgid "Error with query" 2972msgid "Error with query"
3649msgstr "" 2973msgstr ""
3650 2974
3651#: plugins/check_pgsql.c:607
3652msgid "No rows returned" 2975msgid "No rows returned"
3653msgstr "" 2976msgstr ""
3654 2977
3655#: plugins/check_pgsql.c:612
3656msgid "No columns returned" 2978msgid "No columns returned"
3657msgstr "" 2979msgstr ""
3658 2980
3659#: plugins/check_pgsql.c:618
3660#, fuzzy 2981#, fuzzy
3661msgid "No data returned" 2982msgid "No data returned"
3662msgstr "Keine Daten empfangen %s\n" 2983msgstr "Keine Daten empfangen %s\n"
3663 2984
3664#: plugins/check_pgsql.c:627
3665msgid "Is not a numeric" 2985msgid "Is not a numeric"
3666msgstr "" 2986msgstr ""
3667 2987
3668#: plugins/check_pgsql.c:644 2988#, fuzzy, c-format
2989msgid "%s returned %f"
2990msgstr "%s hat %s zurückgegeben"
2991
3669#, fuzzy, c-format 2992#, fuzzy, c-format
3670msgid "'%s' returned %f" 2993msgid "'%s' returned %f"
3671msgstr "%s hat %s zurückgegeben" 2994msgstr "%s hat %s zurückgegeben"
3672 2995
3673#: plugins/check_ping.c:141
3674msgid "CRITICAL - Could not interpret output from ping command\n" 2996msgid "CRITICAL - Could not interpret output from ping command\n"
3675msgstr "" 2997msgstr ""
3676 2998
3677#: plugins/check_ping.c:157
3678#, c-format 2999#, c-format
3679msgid "PING %s - %sPacket loss = %d%%" 3000msgid "PING %s - %sPacket loss = %d%%"
3680msgstr "" 3001msgstr ""
3681 3002
3682#: plugins/check_ping.c:160
3683#, c-format 3003#, c-format
3684msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms" 3004msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"
3685msgstr "" 3005msgstr ""
3686 3006
3687#: plugins/check_ping.c:257
3688msgid "Could not realloc() addresses\n" 3007msgid "Could not realloc() addresses\n"
3689msgstr "" 3008msgstr ""
3690 3009
3691#: plugins/check_ping.c:272 plugins/check_ping.c:352
3692#, c-format 3010#, c-format
3693msgid "<max_packets> (%s) must be a non-negative number\n" 3011msgid "<max_packets> (%s) must be a non-negative number\n"
3694msgstr "" 3012msgstr ""
3695 3013
3696#: plugins/check_ping.c:306
3697#, c-format 3014#, c-format
3698msgid "<wpl> (%s) must be an integer percentage\n" 3015msgid "<wpl> (%s) must be an integer percentage\n"
3699msgstr "" 3016msgstr ""
3700 3017
3701#: plugins/check_ping.c:317
3702#, c-format 3018#, c-format
3703msgid "<cpl> (%s) must be an integer percentage\n" 3019msgid "<cpl> (%s) must be an integer percentage\n"
3704msgstr "" 3020msgstr ""
3705 3021
3706#: plugins/check_ping.c:328
3707#, c-format 3022#, c-format
3708msgid "<wrta> (%s) must be a non-negative number\n" 3023msgid "<wrta> (%s) must be a non-negative number\n"
3709msgstr "" 3024msgstr ""
3710 3025
3711#: plugins/check_ping.c:339
3712#, c-format 3026#, c-format
3713msgid "<crta> (%s) must be a non-negative number\n" 3027msgid "<crta> (%s) must be a non-negative number\n"
3714msgstr "" 3028msgstr ""
3715 3029
3716#: plugins/check_ping.c:372
3717#, c-format 3030#, c-format
3718msgid "" 3031msgid ""
3719"%s: Warning threshold must be integer or percentage!\n" 3032"%s: Warning threshold must be integer or percentage!\n"
3720"\n" 3033"\n"
3721msgstr "" 3034msgstr ""
3722 3035
3723#: plugins/check_ping.c:385
3724#, c-format 3036#, c-format
3725msgid "<wrta> was not set\n" 3037msgid "<wrta> was not set\n"
3726msgstr "" 3038msgstr ""
3727 3039
3728#: plugins/check_ping.c:389
3729#, c-format 3040#, c-format
3730msgid "<crta> was not set\n" 3041msgid "<crta> was not set\n"
3731msgstr "" 3042msgstr ""
3732 3043
3733#: plugins/check_ping.c:393
3734#, c-format 3044#, c-format
3735msgid "<wpl> was not set\n" 3045msgid "<wpl> was not set\n"
3736msgstr "" 3046msgstr ""
3737 3047
3738#: plugins/check_ping.c:397
3739#, c-format 3048#, c-format
3740msgid "<cpl> was not set\n" 3049msgid "<cpl> was not set\n"
3741msgstr "" 3050msgstr ""
3742 3051
3743#: plugins/check_ping.c:401
3744#, c-format 3052#, c-format
3745msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n" 3053msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n"
3746msgstr "" 3054msgstr ""
3747 3055
3748#: plugins/check_ping.c:405
3749#, c-format 3056#, c-format
3750msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n" 3057msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n"
3751msgstr "" 3058msgstr ""
3752 3059
3753#: plugins/check_ping.c:442
3754#, c-format 3060#, c-format
3755msgid "Cannot open stderr for %s\n" 3061msgid "Cannot open stderr for %s\n"
3756msgstr "" 3062msgstr ""
3757 3063
3758#: plugins/check_ping.c:492 plugins/check_ping.c:494
3759msgid "System call sent warnings to stderr " 3064msgid "System call sent warnings to stderr "
3760msgstr "" 3065msgstr ""
3761 3066
3762#: plugins/check_ping.c:519
3763#, fuzzy, c-format 3067#, fuzzy, c-format
3764msgid "CRITICAL - Network Unreachable (%s)\n" 3068msgid "CRITICAL - Network Unreachable (%s)\n"
3765msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3069msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3766 3070
3767#: plugins/check_ping.c:521
3768#, fuzzy, c-format 3071#, fuzzy, c-format
3769msgid "CRITICAL - Host Unreachable (%s)\n" 3072msgid "CRITICAL - Host Unreachable (%s)\n"
3770msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3073msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3771 3074
3772#: plugins/check_ping.c:523
3773#, fuzzy, c-format 3075#, fuzzy, c-format
3774msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n" 3076msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"
3775msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3077msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3776 3078
3777#: plugins/check_ping.c:525
3778#, fuzzy, c-format 3079#, fuzzy, c-format
3779msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n" 3080msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"
3780msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3081msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3781 3082
3782#: plugins/check_ping.c:527
3783#, fuzzy, c-format 3083#, fuzzy, c-format
3784msgid "CRITICAL - Network Prohibited (%s)\n" 3084msgid "CRITICAL - Network Prohibited (%s)\n"
3785msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3085msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3786 3086
3787#: plugins/check_ping.c:529
3788#, fuzzy, c-format 3087#, fuzzy, c-format
3789msgid "CRITICAL - Host Prohibited (%s)\n" 3088msgid "CRITICAL - Host Prohibited (%s)\n"
3790msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3089msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3791 3090
3792#: plugins/check_ping.c:531
3793#, fuzzy, c-format 3091#, fuzzy, c-format
3794msgid "CRITICAL - Packet Filtered (%s)\n" 3092msgid "CRITICAL - Packet Filtered (%s)\n"
3795msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3093msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3796 3094
3797#: plugins/check_ping.c:533
3798#, fuzzy, c-format 3095#, fuzzy, c-format
3799msgid "CRITICAL - Host not found (%s)\n" 3096msgid "CRITICAL - Host not found (%s)\n"
3800msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n" 3097msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n"
3801 3098
3802#: plugins/check_ping.c:535
3803#, fuzzy, c-format 3099#, fuzzy, c-format
3804msgid "CRITICAL - Time to live exceeded (%s)\n" 3100msgid "CRITICAL - Time to live exceeded (%s)\n"
3805msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3101msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3806 3102
3807#: plugins/check_ping.c:537
3808#, fuzzy, c-format 3103#, fuzzy, c-format
3809msgid "CRITICAL - Destination Unreachable (%s)\n" 3104msgid "CRITICAL - Destination Unreachable (%s)\n"
3810msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3105msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3811 3106
3812#: plugins/check_ping.c:544
3813msgid "Unable to realloc warn_text\n" 3107msgid "Unable to realloc warn_text\n"
3814msgstr "" 3108msgstr ""
3815 3109
3816#: plugins/check_ping.c:561
3817#, c-format 3110#, c-format
3818msgid "Use ping to check connection statistics for a remote host." 3111msgid "Use ping to check connection statistics for a remote host."
3819msgstr "" 3112msgstr ""
3820 3113
3821#: plugins/check_ping.c:573
3822msgid "host to ping" 3114msgid "host to ping"
3823msgstr "" 3115msgstr ""
3824 3116
3825#: plugins/check_ping.c:579
3826msgid "number of ICMP ECHO packets to send" 3117msgid "number of ICMP ECHO packets to send"
3827msgstr "" 3118msgstr ""
3828 3119
3829#: plugins/check_ping.c:580
3830#, c-format 3120#, c-format
3831msgid "(Default: %d)\n" 3121msgid "(Default: %d)\n"
3832msgstr "" 3122msgstr ""
3833 3123
3834#: plugins/check_ping.c:582
3835msgid "show HTML in the plugin output (obsoleted by urlize)" 3124msgid "show HTML in the plugin output (obsoleted by urlize)"
3836msgstr "" 3125msgstr ""
3837 3126
3838#: plugins/check_ping.c:587
3839msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel" 3127msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"
3840msgstr "" 3128msgstr ""
3841 3129
3842#: plugins/check_ping.c:588
3843msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the" 3130msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"
3844msgstr "" 3131msgstr ""
3845 3132
3846#: plugins/check_ping.c:589
3847msgid "percentage of packet loss to trigger an alarm state." 3133msgid "percentage of packet loss to trigger an alarm state."
3848msgstr "" 3134msgstr ""
3849 3135
3850#: plugins/check_ping.c:592
3851#, fuzzy 3136#, fuzzy
3852msgid "" 3137msgid ""
3853"This plugin uses the ping command to probe the specified host for packet loss" 3138"This plugin uses the ping command to probe the specified host for packet loss"
3854msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3139msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
3855 3140
3856#: plugins/check_ping.c:593
3857msgid "" 3141msgid ""
3858"(percentage) and round trip average (milliseconds). It can produce HTML " 3142"(percentage) and round trip average (milliseconds). It can produce HTML "
3859"output" 3143"output"
3860msgstr "" 3144msgstr ""
3861 3145
3862#: plugins/check_ping.c:594
3863msgid "" 3146msgid ""
3864"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in" 3147"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"
3865msgstr "" 3148msgstr ""
3866 3149
3867#: plugins/check_ping.c:595
3868msgid "the contrib area of the downloads section at http://www.nagios.org/" 3150msgid "the contrib area of the downloads section at http://www.nagios.org/"
3869msgstr "" 3151msgstr ""
3870 3152
3871#: plugins/check_procs.c:193
3872#, c-format 3153#, c-format
3873msgid "CMD: %s\n" 3154msgid "CMD: %s\n"
3874msgstr "" 3155msgstr ""
3875 3156
3876#: plugins/check_procs.c:198
3877msgid "System call sent warnings to stderr" 3157msgid "System call sent warnings to stderr"
3878msgstr "" 3158msgstr ""
3879 3159
3880#: plugins/check_procs.c:326
3881#, c-format 3160#, c-format
3882msgid "Not parseable: %s" 3161msgid "Not parseable: %s"
3883msgstr "" 3162msgstr ""
3884 3163
3885#: plugins/check_procs.c:331
3886#, c-format 3164#, c-format
3887msgid "Unable to read output\n" 3165msgid "Unable to read output\n"
3888msgstr "" 3166msgstr ""
3889 3167
3890#: plugins/check_procs.c:348
3891#, c-format 3168#, c-format
3892msgid "%d warn out of " 3169msgid "%d warn out of "
3893msgstr "" 3170msgstr ""
3894 3171
3895#: plugins/check_procs.c:353
3896#, c-format 3172#, c-format
3897msgid "%d crit, %d warn out of " 3173msgid "%d crit, %d warn out of "
3898msgstr "" 3174msgstr ""
3899 3175
3900#: plugins/check_procs.c:359
3901#, c-format 3176#, c-format
3902msgid " with %s" 3177msgid " with %s"
3903msgstr "" 3178msgstr ""
3904 3179
3905#: plugins/check_procs.c:453
3906#, fuzzy 3180#, fuzzy
3907msgid "Parent Process ID must be an integer!" 3181msgid "Parent Process ID must be an integer!"
3908msgstr "Argument für check_dummy muss ein Integer sein" 3182msgstr "Argument für check_dummy muss ein Integer sein"
3909 3183
3910#: plugins/check_procs.c:459 plugins/check_procs.c:586
3911#, c-format 3184#, c-format
3912msgid "%s%sSTATE = %s" 3185msgid "%s%sSTATE = %s"
3913msgstr "" 3186msgstr ""
3914 3187
3915#: plugins/check_procs.c:468
3916#, fuzzy 3188#, fuzzy
3917msgid "UID was not found" 3189msgid "UID was not found"
3918msgstr "%s [%s nicht gefunden]" 3190msgstr "%s [%s nicht gefunden]"
3919 3191
3920#: plugins/check_procs.c:474
3921#, fuzzy 3192#, fuzzy
3922msgid "User name was not found" 3193msgid "User name was not found"
3923msgstr "%s [%s nicht gefunden]" 3194msgstr "%s [%s nicht gefunden]"
3924 3195
3925#: plugins/check_procs.c:489
3926#, c-format 3196#, c-format
3927msgid "%s%scommand name '%s'" 3197msgid "%s%scommand name '%s'"
3928msgstr "" 3198msgstr ""
3929 3199
3930#: plugins/check_procs.c:524 3200#, c-format
3201msgid "%s%sexclude progs '%s'"
3202msgstr ""
3203
3931#, fuzzy 3204#, fuzzy
3932msgid "RSS must be an integer!" 3205msgid "RSS must be an integer!"
3933msgstr "skip lines muss ein Integer sein" 3206msgstr "skip lines muss ein Integer sein"
3934 3207
3935#: plugins/check_procs.c:531
3936#, fuzzy 3208#, fuzzy
3937msgid "VSZ must be an integer!" 3209msgid "VSZ must be an integer!"
3938msgstr "skip lines muss ein Integer sein" 3210msgstr "skip lines muss ein Integer sein"
3939 3211
3940#: plugins/check_procs.c:539
3941msgid "PCPU must be a float!" 3212msgid "PCPU must be a float!"
3942msgstr "" 3213msgstr ""
3943 3214
3944#: plugins/check_procs.c:563
3945msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!" 3215msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"
3946msgstr "" 3216msgstr ""
3947 3217
3948#: plugins/check_procs.c:694
3949msgid "" 3218msgid ""
3950"Checks all processes and generates WARNING or CRITICAL states if the " 3219"Checks all processes and generates WARNING or CRITICAL states if the "
3951"specified" 3220"specified"
3952msgstr "" 3221msgstr ""
3953 3222
3954#: plugins/check_procs.c:695
3955msgid "" 3223msgid ""
3956"metric is outside the required threshold ranges. The metric defaults to " 3224"metric is outside the required threshold ranges. The metric defaults to "
3957"number" 3225"number"
3958msgstr "" 3226msgstr ""
3959 3227
3960#: plugins/check_procs.c:696
3961msgid "" 3228msgid ""
3962"of processes. Search filters can be applied to limit the processes to check." 3229"of processes. Search filters can be applied to limit the processes to check."
3963msgstr "" 3230msgstr ""
3964 3231
3965#: plugins/check_procs.c:705
3966msgid "Generate warning state if metric is outside this range" 3232msgid "Generate warning state if metric is outside this range"
3967msgstr "" 3233msgstr ""
3968 3234
3969#: plugins/check_procs.c:707
3970msgid "Generate critical state if metric is outside this range" 3235msgid "Generate critical state if metric is outside this range"
3971msgstr "" 3236msgstr ""
3972 3237
3973#: plugins/check_procs.c:709
3974msgid "Check thresholds against metric. Valid types:" 3238msgid "Check thresholds against metric. Valid types:"
3975msgstr "" 3239msgstr ""
3976 3240
3977#: plugins/check_procs.c:710
3978msgid "PROCS - number of processes (default)" 3241msgid "PROCS - number of processes (default)"
3979msgstr "" 3242msgstr ""
3980 3243
3981#: plugins/check_procs.c:711
3982msgid "VSZ - virtual memory size" 3244msgid "VSZ - virtual memory size"
3983msgstr "" 3245msgstr ""
3984 3246
3985#: plugins/check_procs.c:712
3986msgid "RSS - resident set memory size" 3247msgid "RSS - resident set memory size"
3987msgstr "" 3248msgstr ""
3988 3249
3989#: plugins/check_procs.c:713
3990msgid "CPU - percentage CPU" 3250msgid "CPU - percentage CPU"
3991msgstr "" 3251msgstr ""
3992 3252
3993#: plugins/check_procs.c:716
3994msgid "ELAPSED - time elapsed in seconds" 3253msgid "ELAPSED - time elapsed in seconds"
3995msgstr "" 3254msgstr ""
3996 3255
3997#: plugins/check_procs.c:721
3998msgid "Extra information. Up to 3 verbosity levels" 3256msgid "Extra information. Up to 3 verbosity levels"
3999msgstr "" 3257msgstr ""
4000 3258
4001#: plugins/check_procs.c:724
4002msgid "Filter own process the traditional way by PID instead of /proc/pid/exe" 3259msgid "Filter own process the traditional way by PID instead of /proc/pid/exe"
4003msgstr "" 3260msgstr ""
4004 3261
4005#: plugins/check_procs.c:729
4006msgid "Only scan for processes that have, in the output of `ps`, one or" 3262msgid "Only scan for processes that have, in the output of `ps`, one or"
4007msgstr "" 3263msgstr ""
4008 3264
4009#: plugins/check_procs.c:730
4010msgid "more of the status flags you specify (for example R, Z, S, RS," 3265msgid "more of the status flags you specify (for example R, Z, S, RS,"
4011msgstr "" 3266msgstr ""
4012 3267
4013#: plugins/check_procs.c:731
4014msgid "RSZDT, plus others based on the output of your 'ps' command)." 3268msgid "RSZDT, plus others based on the output of your 'ps' command)."
4015msgstr "" 3269msgstr ""
4016 3270
4017#: plugins/check_procs.c:733
4018msgid "Only scan for children of the parent process ID indicated." 3271msgid "Only scan for children of the parent process ID indicated."
4019msgstr "" 3272msgstr ""
4020 3273
4021#: plugins/check_procs.c:735
4022msgid "Only scan for processes with VSZ higher than indicated." 3274msgid "Only scan for processes with VSZ higher than indicated."
4023msgstr "" 3275msgstr ""
4024 3276
4025#: plugins/check_procs.c:737
4026msgid "Only scan for processes with RSS higher than indicated." 3277msgid "Only scan for processes with RSS higher than indicated."
4027msgstr "" 3278msgstr ""
4028 3279
4029#: plugins/check_procs.c:739
4030msgid "Only scan for processes with PCPU higher than indicated." 3280msgid "Only scan for processes with PCPU higher than indicated."
4031msgstr "" 3281msgstr ""
4032 3282
4033#: plugins/check_procs.c:741
4034msgid "Only scan for processes with user name or ID indicated." 3283msgid "Only scan for processes with user name or ID indicated."
4035msgstr "" 3284msgstr ""
4036 3285
4037#: plugins/check_procs.c:743
4038msgid "Only scan for processes with args that contain STRING." 3286msgid "Only scan for processes with args that contain STRING."
4039msgstr "" 3287msgstr ""
4040 3288
4041#: plugins/check_procs.c:745
4042msgid "Only scan for processes with args that contain the regex STRING." 3289msgid "Only scan for processes with args that contain the regex STRING."
4043msgstr "" 3290msgstr ""
4044 3291
4045#: plugins/check_procs.c:747
4046msgid "Only scan for exact matches of COMMAND (without path)." 3292msgid "Only scan for exact matches of COMMAND (without path)."
4047msgstr "" 3293msgstr ""
4048 3294
4049#: plugins/check_procs.c:749 3295msgid "Exclude processes which match this comma separated list"
3296msgstr ""
3297
4050msgid "Only scan for non kernel threads (works on Linux only)." 3298msgid "Only scan for non kernel threads (works on Linux only)."
4051msgstr "" 3299msgstr ""
4052 3300
4053#: plugins/check_procs.c:751
4054#, c-format 3301#, c-format
4055msgid "" 3302msgid ""
4056"\n" 3303"\n"
@@ -4060,7 +3307,6 @@ msgid ""
4060"\n" 3307"\n"
4061msgstr "" 3308msgstr ""
4062 3309
4063#: plugins/check_procs.c:756
4064#, c-format 3310#, c-format
4065msgid "" 3311msgid ""
4066"This plugin checks the number of currently running processes and\n" 3312"This plugin checks the number of currently running processes and\n"
@@ -4071,1144 +3317,993 @@ msgid ""
4071"\n" 3317"\n"
4072msgstr "" 3318msgstr ""
4073 3319
4074#: plugins/check_procs.c:765
4075msgid "Warning if not two processes with command name portsentry." 3320msgid "Warning if not two processes with command name portsentry."
4076msgstr "" 3321msgstr ""
4077 3322
4078#: plugins/check_procs.c:766
4079msgid "Critical if < 2 or > 1024 processes" 3323msgid "Critical if < 2 or > 1024 processes"
4080msgstr "" 3324msgstr ""
4081 3325
4082#: plugins/check_procs.c:768 3326msgid "Critical if not at least 1 process with command sshd"
4083msgid "Warning alert if > 10 processes with command arguments containing"
4084msgstr "" 3327msgstr ""
4085 3328
4086#: plugins/check_procs.c:769 3329msgid "Warning if > 1024 processes with command name sshd."
4087msgid "'/usr/local/bin/perl' and owned by root"
4088msgstr "" 3330msgstr ""
4089 3331
4090#: plugins/check_procs.c:771 3332msgid "Critical if < 1 processes with command name sshd."
4091msgid "Alert if VSZ of any processes over 50K or 100K"
4092msgstr "" 3333msgstr ""
4093 3334
4094#: plugins/check_procs.c:773 3335msgid "Warning alert if > 10 processes with command arguments containing"
4095#, c-format
4096msgid "Alert if CPU of any processes over 10%% or 20%%"
4097msgstr "" 3336msgstr ""
4098 3337
4099#: plugins/check_radius.c:165 3338msgid "'/usr/local/bin/perl' and owned by root"
4100msgid "Config file error"
4101msgstr "" 3339msgstr ""
4102 3340
4103#: plugins/check_radius.c:174 3341msgid "Alert if VSZ of any processes over 50K or 100K"
4104msgid "Out of Memory?"
4105msgstr "" 3342msgstr ""
4106 3343
4107#: plugins/check_radius.c:178 3344msgid "Alert if CPU of any processes over 10% or 20%"
4108msgid "Invalid NAS-Identifier" 3345msgstr ""
3346
3347msgid "Config file error\n"
4109msgstr "" 3348msgstr ""
4110 3349
4111#: plugins/check_radius.c:183 plugins/check_radius.c:185
4112#: plugins/check_radius.c:191
4113#, fuzzy 3350#, fuzzy
4114msgid "Invalid NAS-IP-Address" 3351msgid "Out of Memory?\n"
4115msgstr "Ungültige(r) Hostname/Adresse" 3352msgstr "Kein Papier"
4116 3353
4117#: plugins/check_radius.c:188 3354#, fuzzy
4118msgid "Can't find local IP for NAS-IP-Address" 3355msgid "Invalid NAS-Identifier\n"
4119msgstr "" 3356msgstr "Ungültige(r) Hostname/Adresse"
4120 3357
4121#: plugins/check_radius.c:202 3358#, c-format
4122msgid "Timeout" 3359msgid "gethostname() failed!\n"
4123msgstr "" 3360msgstr ""
4124 3361
4125#: plugins/check_radius.c:204 3362#, fuzzy
4126msgid "Auth Error" 3363msgid "Invalid NAS-IP-Address\n"
3364msgstr "Ungültige(r) Hostname/Adresse"
3365
3366msgid "Timeout\n"
4127msgstr "" 3367msgstr ""
4128 3368
4129#: plugins/check_radius.c:206 3369msgid "Auth Error\n"
4130msgid "Auth Failed"
4131msgstr "" 3370msgstr ""
4132 3371
4133#: plugins/check_radius.c:208 3372#, fuzzy
4134msgid "Bad Response" 3373msgid "Auth Failed\n"
3374msgstr "Fehlgeschlagen"
3375
3376msgid "Bad Response\n"
4135msgstr "" 3377msgstr ""
4136 3378
4137#: plugins/check_radius.c:212 3379msgid "Auth OK\n"
4138msgid "Auth OK"
4139msgstr "" 3380msgstr ""
4140 3381
4141#: plugins/check_radius.c:213
4142#, fuzzy, c-format 3382#, fuzzy, c-format
4143msgid "Unexpected result code %d" 3383msgid "Unexpected result code %d"
4144msgstr "Erwartet: %s aber: %s erhalten" 3384msgstr "Erwartet: %s aber: %s erhalten"
4145 3385
4146#: plugins/check_radius.c:302
4147msgid "Number of retries must be a positive integer" 3386msgid "Number of retries must be a positive integer"
4148msgstr "" 3387msgstr ""
4149 3388
4150#: plugins/check_radius.c:316
4151msgid "User not specified" 3389msgid "User not specified"
4152msgstr "" 3390msgstr ""
4153 3391
4154#: plugins/check_radius.c:318
4155msgid "Password not specified" 3392msgid "Password not specified"
4156msgstr "" 3393msgstr ""
4157 3394
4158#: plugins/check_radius.c:320
4159msgid "Configuration file not specified" 3395msgid "Configuration file not specified"
4160msgstr "" 3396msgstr ""
4161 3397
4162#: plugins/check_radius.c:338
4163#, fuzzy 3398#, fuzzy
4164msgid "Tests to see if a RADIUS server is accepting connections." 3399msgid "Tests to see if a RADIUS server is accepting connections."
4165msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3400msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4166 3401
4167#: plugins/check_radius.c:350
4168msgid "The user to authenticate" 3402msgid "The user to authenticate"
4169msgstr "" 3403msgstr ""
4170 3404
4171#: plugins/check_radius.c:352 3405msgid "Password for authentication (SECURITY RISK)"
4172msgid "Password for autentication (SECURITY RISK)"
4173msgstr "" 3406msgstr ""
4174 3407
4175#: plugins/check_radius.c:354
4176msgid "NAS identifier" 3408msgid "NAS identifier"
4177msgstr "" 3409msgstr ""
4178 3410
4179#: plugins/check_radius.c:356
4180msgid "NAS IP Address" 3411msgid "NAS IP Address"
4181msgstr "" 3412msgstr ""
4182 3413
4183#: plugins/check_radius.c:358
4184msgid "Configuration file" 3414msgid "Configuration file"
4185msgstr "" 3415msgstr ""
4186 3416
4187#: plugins/check_radius.c:360
4188msgid "Response string to expect from the server" 3417msgid "Response string to expect from the server"
4189msgstr "" 3418msgstr ""
4190 3419
4191#: plugins/check_radius.c:362
4192msgid "Number of times to retry a failed connection" 3420msgid "Number of times to retry a failed connection"
4193msgstr "" 3421msgstr ""
4194 3422
4195#: plugins/check_radius.c:367
4196#, fuzzy 3423#, fuzzy
4197msgid "" 3424msgid ""
4198"This plugin tests a RADIUS server to see if it is accepting connections." 3425"This plugin tests a RADIUS server to see if it is accepting connections."
4199msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3426msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4200 3427
4201#: plugins/check_radius.c:368
4202msgid "" 3428msgid ""
4203"The server to test must be specified in the invocation, as well as a user" 3429"The server to test must be specified in the invocation, as well as a user"
4204msgstr "" 3430msgstr ""
4205 3431
4206#: plugins/check_radius.c:369 3432msgid "name and password. A configuration file must be present. The format of"
4207msgid ""
4208"name and password. A configuration file may also be present. The format of"
4209msgstr "" 3433msgstr ""
4210 3434
4211#: plugins/check_radius.c:370
4212msgid "" 3435msgid ""
4213"the configuration file is described in the radiusclient library sources." 3436"the configuration file is described in the radiusclient library sources."
4214msgstr "" 3437msgstr ""
4215 3438
4216#: plugins/check_radius.c:371
4217msgid "The password option presents a substantial security issue because the" 3439msgid "The password option presents a substantial security issue because the"
4218msgstr "" 3440msgstr ""
4219 3441
4220#: plugins/check_radius.c:372
4221msgid "" 3442msgid ""
4222"password can possibly be determined by careful watching of the command line" 3443"password can possibly be determined by careful watching of the command line"
4223msgstr "" 3444msgstr ""
4224 3445
4225#: plugins/check_radius.c:373 3446msgid "in a process listing. This risk is exacerbated because the plugin will"
4226msgid "in a process listing. This risk is exacerbated because the monitor will"
4227msgstr "" 3447msgstr ""
4228 3448
4229#: plugins/check_radius.c:374 3449msgid ""
4230msgid "run the plugin at regular predictable intervals. Please be sure that" 3450"typically be executed at regular predictable intervals. Please be sure that"
4231msgstr "" 3451msgstr ""
4232 3452
4233#: plugins/check_radius.c:375
4234msgid "the password used does not allow access to sensitive system resources." 3453msgid "the password used does not allow access to sensitive system resources."
4235msgstr "" 3454msgstr ""
4236 3455
4237#: plugins/check_real.c:91
4238#, c-format 3456#, c-format
4239msgid "Unable to connect to %s on port %d\n" 3457msgid "Unable to connect to %s on port %d\n"
4240msgstr "" 3458msgstr ""
4241 3459
4242#: plugins/check_real.c:113
4243#, c-format 3460#, c-format
4244msgid "No data received from %s\n" 3461msgid "No data received from %s\n"
4245msgstr "" 3462msgstr ""
4246 3463
4247#: plugins/check_real.c:118 plugins/check_real.c:191
4248#, fuzzy 3464#, fuzzy
4249msgid "Invalid REAL response received from host" 3465msgid "Invalid REAL response received from host"
4250msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3466msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4251 3467
4252#: plugins/check_real.c:120 plugins/check_real.c:193
4253#, c-format 3468#, c-format
4254msgid "Invalid REAL response received from host on port %d\n" 3469msgid "Invalid REAL response received from host on port %d\n"
4255msgstr "" 3470msgstr ""
4256 3471
4257#: plugins/check_real.c:184 plugins/check_tcp.c:311
4258#, c-format 3472#, c-format
4259msgid "No data received from host\n" 3473msgid "No data received from host\n"
4260msgstr "" 3474msgstr ""
4261 3475
4262#: plugins/check_real.c:247
4263#, c-format 3476#, c-format
4264msgid "REAL %s - %d second response time\n" 3477msgid "REAL %s - %d second response time\n"
4265msgstr "" 3478msgstr ""
4266 3479
4267#: plugins/check_real.c:336 plugins/check_ups.c:536
4268msgid "Warning time must be a positive integer" 3480msgid "Warning time must be a positive integer"
4269msgstr "Warnung time muss ein positiver Integer sein" 3481msgstr "Warnung time muss ein positiver Integer sein"
4270 3482
4271#: plugins/check_real.c:345 plugins/check_ups.c:527
4272msgid "Critical time must be a positive integer" 3483msgid "Critical time must be a positive integer"
4273msgstr "Critical time muss ein positiver Integer sein" 3484msgstr "Critical time muss ein positiver Integer sein"
4274 3485
4275#: plugins/check_real.c:381
4276#, fuzzy 3486#, fuzzy
4277msgid "You must provide a server to check" 3487msgid "You must provide a server to check"
4278msgstr "%s: Hostname muss angegeben werden\n" 3488msgstr "%s: Hostname muss angegeben werden\n"
4279 3489
4280#: plugins/check_real.c:413
4281#, fuzzy 3490#, fuzzy
4282msgid "This plugin tests the REAL service on the specified host." 3491msgid "This plugin tests the REAL service on the specified host."
4283msgstr "" 3492msgstr ""
4284"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 3493"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
4285"\n" 3494"\n"
4286 3495
4287#: plugins/check_real.c:425
4288msgid "Connect to this url" 3496msgid "Connect to this url"
4289msgstr "" 3497msgstr ""
4290 3498
4291#: plugins/check_real.c:427
4292#, c-format 3499#, c-format
4293msgid "String to expect in first line of server response (default: %s)\n" 3500msgid "String to expect in first line of server response (default: %s)\n"
4294msgstr "" 3501msgstr ""
4295 3502
4296#: plugins/check_real.c:437
4297#, fuzzy 3503#, fuzzy
4298msgid "This plugin will attempt to open an RTSP connection with the host." 3504msgid "This plugin will attempt to open an RTSP connection with the host."
4299msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3505msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4300 3506
4301#: plugins/check_real.c:438 plugins/check_smtp.c:830 3507msgid "Successful connects return STATE_OK, refusals and timeouts return"
4302msgid "Successul connects return STATE_OK, refusals and timeouts return"
4303msgstr "" 3508msgstr ""
4304 3509
4305#: plugins/check_real.c:439
4306msgid "" 3510msgid ""
4307"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects," 3511"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"
4308msgstr "" 3512msgstr ""
4309 3513
4310#: plugins/check_real.c:440
4311msgid "" 3514msgid ""
4312"but incorrect reponse messages from the host result in STATE_WARNING return" 3515"but incorrect response messages from the host result in STATE_WARNING return"
4313msgstr "" 3516msgstr ""
4314 3517
4315#: plugins/check_real.c:441
4316msgid "values." 3518msgid "values."
4317msgstr "" 3519msgstr ""
4318 3520
4319#: plugins/check_smtp.c:150 plugins/check_swap.c:265 plugins/check_swap.c:271
4320#, c-format 3521#, c-format
4321msgid "malloc() failed!\n" 3522msgid "malloc() failed!\n"
4322msgstr "" 3523msgstr ""
4323 3524
4324#: plugins/check_smtp.c:154
4325#, c-format 3525#, c-format
4326msgid "gethostname() failed!\n" 3526msgid "CRITICAL - Cannot create SSL context.\n"
4327msgstr "" 3527msgstr ""
4328 3528
4329#: plugins/check_smtp.c:189 plugins/check_smtp.c:213
4330#, c-format 3529#, c-format
4331msgid "recv() failed\n" 3530msgid "recv() failed\n"
4332msgstr "" 3531msgstr ""
4333 3532
4334#: plugins/check_smtp.c:200
4335#, fuzzy, c-format
4336msgid "Invalid SMTP response received from host: %s\n"
4337msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4338
4339#: plugins/check_smtp.c:202
4340#, fuzzy, c-format
4341msgid "Invalid SMTP response received from host on port %d: %s\n"
4342msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
4343
4344#: plugins/check_smtp.c:223
4345#, c-format 3533#, c-format
4346msgid "WARNING - TLS not supported by server\n" 3534msgid "WARNING - TLS not supported by server\n"
4347msgstr "" 3535msgstr ""
4348 3536
4349#: plugins/check_smtp.c:235
4350#, c-format 3537#, c-format
4351msgid "Server does not support STARTTLS\n" 3538msgid "Server does not support STARTTLS\n"
4352msgstr "" 3539msgstr ""
4353 3540
4354#: plugins/check_smtp.c:241
4355#, c-format
4356msgid "CRITICAL - Cannot create SSL context.\n"
4357msgstr ""
4358
4359#: plugins/check_smtp.c:261
4360msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS." 3541msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS."
4361msgstr "" 3542msgstr ""
4362 3543
4363#: plugins/check_smtp.c:266
4364#, c-format 3544#, c-format
4365msgid "sent %s" 3545msgid "sent %s"
4366msgstr "" 3546msgstr ""
4367 3547
4368#: plugins/check_smtp.c:268
4369msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS." 3548msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS."
4370msgstr "" 3549msgstr ""
4371 3550
4372#: plugins/check_smtp.c:303 plugins/check_snmp.c:806 3551#, fuzzy, c-format
3552msgid "Invalid SMTP response received from host: %s\n"
3553msgstr "Ungültige HTTP Antwort von Host empfangen\n"
3554
3555#, fuzzy, c-format
3556msgid "Invalid SMTP response received from host on port %d: %s\n"
3557msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
3558
4373#, c-format 3559#, c-format
4374msgid "Could Not Compile Regular Expression" 3560msgid "Could Not Compile Regular Expression"
4375msgstr "" 3561msgstr ""
4376 3562
4377#: plugins/check_smtp.c:312
4378#, c-format 3563#, c-format
4379msgid "SMTP %s - Invalid response '%s' to command '%s'\n" 3564msgid "SMTP %s - Invalid response '%s' to command '%s'\n"
4380msgstr "" 3565msgstr ""
4381 3566
4382#: plugins/check_smtp.c:316 plugins/check_snmp.c:511
4383#, c-format 3567#, c-format
4384msgid "Execute Error: %s\n" 3568msgid "Execute Error: %s\n"
4385msgstr "" 3569msgstr ""
4386 3570
4387#: plugins/check_smtp.c:330
4388msgid "no authuser specified, " 3571msgid "no authuser specified, "
4389msgstr "" 3572msgstr ""
4390 3573
4391#: plugins/check_smtp.c:335
4392msgid "no authpass specified, " 3574msgid "no authpass specified, "
4393msgstr "" 3575msgstr ""
4394 3576
4395#: plugins/check_smtp.c:342 plugins/check_smtp.c:363 plugins/check_smtp.c:383
4396#: plugins/check_smtp.c:688
4397#, c-format 3577#, c-format
4398msgid "sent %s\n" 3578msgid "sent %s\n"
4399msgstr "" 3579msgstr ""
4400 3580
4401#: plugins/check_smtp.c:345
4402#, fuzzy 3581#, fuzzy
4403msgid "recv() failed after AUTH LOGIN, " 3582msgid "recv() failed after AUTH LOGIN, "
4404msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3583msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4405 3584
4406#: plugins/check_smtp.c:350 plugins/check_smtp.c:371 plugins/check_smtp.c:391
4407#: plugins/check_smtp.c:699
4408#, fuzzy, c-format 3585#, fuzzy, c-format
4409msgid "received %s\n" 3586msgid "received %s\n"
4410msgstr "Keine Daten empfangen %s\n" 3587msgstr "Keine Daten empfangen %s\n"
4411 3588
4412#: plugins/check_smtp.c:354
4413#, fuzzy 3589#, fuzzy
4414msgid "invalid response received after AUTH LOGIN, " 3590msgid "invalid response received after AUTH LOGIN, "
4415msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3591msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4416 3592
4417#: plugins/check_smtp.c:367
4418msgid "recv() failed after sending authuser, " 3593msgid "recv() failed after sending authuser, "
4419msgstr "" 3594msgstr ""
4420 3595
4421#: plugins/check_smtp.c:375
4422#, fuzzy 3596#, fuzzy
4423msgid "invalid response received after authuser, " 3597msgid "invalid response received after authuser, "
4424msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3598msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4425 3599
4426#: plugins/check_smtp.c:387
4427msgid "recv() failed after sending authpass, " 3600msgid "recv() failed after sending authpass, "
4428msgstr "" 3601msgstr ""
4429 3602
4430#: plugins/check_smtp.c:395
4431#, fuzzy 3603#, fuzzy
4432msgid "invalid response received after authpass, " 3604msgid "invalid response received after authpass, "
4433msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3605msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4434 3606
4435#: plugins/check_smtp.c:402
4436msgid "only authtype LOGIN is supported, " 3607msgid "only authtype LOGIN is supported, "
4437msgstr "" 3608msgstr ""
4438 3609
4439#: plugins/check_smtp.c:426
4440#, fuzzy, c-format 3610#, fuzzy, c-format
4441msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n" 3611msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n"
4442msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n" 3612msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n"
4443 3613
4444#: plugins/check_smtp.c:536 plugins/check_smtp.c:548
4445#, c-format 3614#, c-format
4446msgid "Could not realloc() units [%d]\n" 3615msgid "Could not realloc() units [%d]\n"
4447msgstr "" 3616msgstr ""
4448 3617
4449#: plugins/check_smtp.c:556
4450#, fuzzy 3618#, fuzzy
4451msgid "Critical time must be a positive" 3619msgid "Critical time must be a positive"
4452msgstr "Critical time muss ein positiver Integer sein" 3620msgstr "Critical time muss ein positiver Integer sein"
4453 3621
4454#: plugins/check_smtp.c:564
4455#, fuzzy 3622#, fuzzy
4456msgid "Warning time must be a positive" 3623msgid "Warning time must be a positive"
4457msgstr "Warnung time muss ein positiver Integer sein" 3624msgstr "Warnung time muss ein positiver Integer sein"
4458 3625
4459#: plugins/check_smtp.c:611
4460msgid "SSL support not available - install OpenSSL and recompile" 3626msgid "SSL support not available - install OpenSSL and recompile"
4461msgstr "" 3627msgstr ""
4462 3628
4463#: plugins/check_smtp.c:679 plugins/check_smtp.c:684 3629msgid "Set either -s/--ssl/--tls or -S/--starttls"
3630msgstr "Setze entweder -s/--ssl/--tls oder -S/--starttls"
3631
4464#, c-format 3632#, c-format
4465msgid "Connection closed by server before sending QUIT command\n" 3633msgid "Connection closed by server before sending QUIT command\n"
4466msgstr "" 3634msgstr ""
4467 3635
4468#: plugins/check_smtp.c:694
4469#, fuzzy, c-format 3636#, fuzzy, c-format
4470msgid "recv() failed after QUIT." 3637msgid "recv() failed after QUIT."
4471msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3638msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4472 3639
4473#: plugins/check_smtp.c:696
4474#, c-format 3640#, c-format
4475msgid "Connection reset by peer." 3641msgid "Connection reset by peer."
4476msgstr "" 3642msgstr ""
4477 3643
4478#: plugins/check_smtp.c:784
4479#, fuzzy 3644#, fuzzy
4480msgid "This plugin will attempt to open an SMTP connection with the host." 3645msgid "This plugin will attempt to open an SMTP connection with the host."
4481msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3646msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4482 3647
4483#: plugins/check_smtp.c:798
4484#, c-format 3648#, c-format
4485msgid " String to expect in first line of server response (default: '%s')\n" 3649msgid " String to expect in first line of server response (default: '%s')\n"
4486msgstr "" 3650msgstr ""
4487 3651
4488#: plugins/check_smtp.c:800
4489msgid "SMTP command (may be used repeatedly)" 3652msgid "SMTP command (may be used repeatedly)"
4490msgstr "" 3653msgstr ""
4491 3654
4492#: plugins/check_smtp.c:802
4493msgid "Expected response to command (may be used repeatedly)" 3655msgid "Expected response to command (may be used repeatedly)"
4494msgstr "" 3656msgstr ""
4495 3657
4496#: plugins/check_smtp.c:804
4497msgid "FROM-address to include in MAIL command, required by Exchange 2000" 3658msgid "FROM-address to include in MAIL command, required by Exchange 2000"
4498msgstr "" 3659msgstr ""
4499 3660
4500#: plugins/check_smtp.c:806
4501msgid "FQDN used for HELO" 3661msgid "FQDN used for HELO"
4502msgstr "" 3662msgstr ""
4503 3663
4504#: plugins/check_smtp.c:809 plugins/check_tcp.c:665 3664msgid "Use PROXY protocol prefix for the connection."
3665msgstr "Benutze PROXY-Protokoll-Präfix für die Verbindung."
3666
4505msgid "Minimum number of days a certificate has to be valid." 3667msgid "Minimum number of days a certificate has to be valid."
4506msgstr "" 3668msgstr ""
4507 3669
4508#: plugins/check_smtp.c:811 3670#, fuzzy
3671msgid "Use SSL/TLS for the connection."
3672msgstr "Benutze SSL/TLS für die Verbindung."
3673
3674#, c-format
3675msgid " Sets default port to %d.\n"
3676msgstr " Setze den Default-Port auf %d.\n"
3677
4509msgid "Use STARTTLS for the connection." 3678msgid "Use STARTTLS for the connection."
4510msgstr "" 3679msgstr "Benutze STARTTLS für die Verbindung."
4511 3680
4512#: plugins/check_smtp.c:815
4513msgid "SMTP AUTH type to check (default none, only LOGIN supported)" 3681msgid "SMTP AUTH type to check (default none, only LOGIN supported)"
4514msgstr "" 3682msgstr ""
4515 3683
4516#: plugins/check_smtp.c:817
4517msgid "SMTP AUTH username" 3684msgid "SMTP AUTH username"
4518msgstr "" 3685msgstr ""
4519 3686
4520#: plugins/check_smtp.c:819
4521msgid "SMTP AUTH password" 3687msgid "SMTP AUTH password"
4522msgstr "" 3688msgstr ""
4523 3689
4524#: plugins/check_smtp.c:821 3690msgid "Send LHLO instead of HELO/EHLO"
3691msgstr ""
3692
4525msgid "Ignore failure when sending QUIT command to server" 3693msgid "Ignore failure when sending QUIT command to server"
4526msgstr "" 3694msgstr ""
4527 3695
4528#: plugins/check_smtp.c:831
4529msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful" 3696msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"
4530msgstr "" 3697msgstr ""
4531 3698
4532#: plugins/check_smtp.c:832 3699msgid "connects, but incorrect response messages from the host result in"
4533msgid "connects, but incorrect reponse messages from the host result in"
4534msgstr "" 3700msgstr ""
4535 3701
4536#: plugins/check_smtp.c:833
4537msgid "STATE_WARNING return values." 3702msgid "STATE_WARNING return values."
4538msgstr "" 3703msgstr ""
4539 3704
4540#: plugins/check_snmp.c:169 plugins/check_snmp.c:582
4541msgid "Cannot malloc" 3705msgid "Cannot malloc"
4542msgstr "" 3706msgstr ""
4543 3707
4544#: plugins/check_snmp.c:356
4545#, fuzzy, c-format 3708#, fuzzy, c-format
4546msgid "External command error: %s\n" 3709msgid "External command error: %s\n"
4547msgstr "Papierfehler" 3710msgstr "Papierfehler"
4548 3711
4549#: plugins/check_snmp.c:361
4550#, c-format 3712#, c-format
4551msgid "External command error with no output (return code: %d)\n" 3713msgid "External command error with no output (return code: %d)\n"
4552msgstr "" 3714msgstr ""
4553 3715
4554#: plugins/check_snmp.c:464
4555#, fuzzy, c-format 3716#, fuzzy, c-format
4556msgid "No valid data returned (%s)\n" 3717msgid "No valid data returned (%s)\n"
4557msgstr "Keine Daten empfangen %s\n" 3718msgstr "Keine Daten empfangen %s\n"
4558 3719
4559#: plugins/check_snmp.c:475
4560msgid "Time duration between plugin calls is invalid" 3720msgid "Time duration between plugin calls is invalid"
4561msgstr "" 3721msgstr ""
4562 3722
4563#: plugins/check_snmp.c:588
4564msgid "Cannot asprintf()" 3723msgid "Cannot asprintf()"
4565msgstr "" 3724msgstr ""
4566 3725
4567#: plugins/check_snmp.c:594
4568msgid "Cannot realloc()" 3726msgid "Cannot realloc()"
4569msgstr "" 3727msgstr ""
4570 3728
4571#: plugins/check_snmp.c:610
4572msgid "No previous data to calculate rate - assume okay" 3729msgid "No previous data to calculate rate - assume okay"
4573msgstr "" 3730msgstr ""
4574 3731
4575#: plugins/check_snmp.c:751
4576#, fuzzy 3732#, fuzzy
4577msgid "Retries interval must be a positive integer" 3733msgid "Retries interval must be a positive integer"
4578msgstr "Time interval muss ein positiver Integer sein" 3734msgstr "Time interval muss ein positiver Integer sein"
4579 3735
4580#: plugins/check_snmp.c:831 3736#, fuzzy
3737msgid "Exit status must be a positive integer"
3738msgstr "Maxbytes muss ein positiver Integer sein"
3739
4581#, fuzzy, c-format 3740#, fuzzy, c-format
4582msgid "Could not reallocate labels[%d]" 3741msgid "Could not reallocate labels[%d]"
4583msgstr "Konnte addr nicht zuweisen\n" 3742msgstr "Konnte addr nicht zuweisen\n"
4584 3743
4585#: plugins/check_snmp.c:844
4586#, fuzzy 3744#, fuzzy
4587msgid "Could not reallocate labels\n" 3745msgid "Could not reallocate labels\n"
4588msgstr "Konnte·url·nicht·zuweisen\n" 3746msgstr "Konnte·url·nicht·zuweisen\n"
4589 3747
4590#: plugins/check_snmp.c:860
4591#, fuzzy, c-format 3748#, fuzzy, c-format
4592msgid "Could not reallocate units [%d]\n" 3749msgid "Could not reallocate units [%d]\n"
4593msgstr "Konnte·url·nicht·zuweisen\n" 3750msgstr "Konnte·url·nicht·zuweisen\n"
4594 3751
4595#: plugins/check_snmp.c:872
4596msgid "Could not realloc() units\n" 3752msgid "Could not realloc() units\n"
4597msgstr "" 3753msgstr ""
4598 3754
4599#: plugins/check_snmp.c:889
4600#, fuzzy 3755#, fuzzy
4601msgid "Rate multiplier must be a positive integer" 3756msgid "Rate multiplier must be a positive integer"
4602msgstr "Paketgröße muss ein positiver Integer sein" 3757msgstr "Paketgröße muss ein positiver Integer sein"
4603 3758
4604#: plugins/check_snmp.c:947
4605#, fuzzy 3759#, fuzzy
4606msgid "No host specified\n" 3760msgid "No host specified\n"
4607msgstr "" 3761msgstr ""
4608"Kein Hostname angegeben\n" 3762"Kein Hostname angegeben\n"
4609"\n" 3763"\n"
4610 3764
4611#: plugins/check_snmp.c:951
4612#, fuzzy 3765#, fuzzy
4613msgid "No OIDs specified\n" 3766msgid "No OIDs specified\n"
4614msgstr "" 3767msgstr ""
4615"Kein Hostname angegeben\n" 3768"Kein Hostname angegeben\n"
4616"\n" 3769"\n"
4617 3770
4618#: plugins/check_snmp.c:973
4619msgid "Invalid seclevel"
4620msgstr ""
4621
4622#: plugins/check_snmp.c:980 plugins/check_snmp.c:983 plugins/check_snmp.c:1001
4623#, c-format 3771#, c-format
4624msgid "Required parameter: %s\n" 3772msgid "Required parameter: %s\n"
4625msgstr "" 3773msgstr ""
4626 3774
4627#: plugins/check_snmp.c:1022 3775msgid "Invalid seclevel"
3776msgstr ""
3777
4628msgid "Invalid SNMP version" 3778msgid "Invalid SNMP version"
4629msgstr "" 3779msgstr ""
4630 3780
4631#: plugins/check_snmp.c:1039
4632msgid "Unbalanced quotes\n" 3781msgid "Unbalanced quotes\n"
4633msgstr "" 3782msgstr ""
4634 3783
4635#: plugins/check_snmp.c:1088 3784#, c-format
3785msgid "multiplier set (%.1f), but input is not a number: %s"
3786msgstr ""
3787
4636msgid "Check status of remote machines and obtain system information via SNMP" 3788msgid "Check status of remote machines and obtain system information via SNMP"
4637msgstr "" 3789msgstr ""
4638 3790
4639#: plugins/check_snmp.c:1101
4640msgid "Use SNMP GETNEXT instead of SNMP GET" 3791msgid "Use SNMP GETNEXT instead of SNMP GET"
4641msgstr "" 3792msgstr ""
4642 3793
4643#: plugins/check_snmp.c:1103
4644msgid "SNMP protocol version" 3794msgid "SNMP protocol version"
4645msgstr "" 3795msgstr ""
4646 3796
4647#: plugins/check_snmp.c:1105 3797msgid "SNMPv3 context"
3798msgstr ""
3799
4648msgid "SNMPv3 securityLevel" 3800msgid "SNMPv3 securityLevel"
4649msgstr "" 3801msgstr ""
4650 3802
4651#: plugins/check_snmp.c:1107
4652msgid "SNMPv3 auth proto" 3803msgid "SNMPv3 auth proto"
4653msgstr "" 3804msgstr ""
4654 3805
4655#: plugins/check_snmp.c:1109
4656msgid "SNMPv3 priv proto (default DES)" 3806msgid "SNMPv3 priv proto (default DES)"
4657msgstr "" 3807msgstr ""
4658 3808
4659#: plugins/check_snmp.c:1113
4660msgid "Optional community string for SNMP communication" 3809msgid "Optional community string for SNMP communication"
4661msgstr "" 3810msgstr ""
4662 3811
4663#: plugins/check_snmp.c:1114
4664msgid "default is" 3812msgid "default is"
4665msgstr "" 3813msgstr ""
4666 3814
4667#: plugins/check_snmp.c:1116
4668msgid "SNMPv3 username" 3815msgid "SNMPv3 username"
4669msgstr "" 3816msgstr ""
4670 3817
4671#: plugins/check_snmp.c:1118
4672msgid "SNMPv3 authentication password" 3818msgid "SNMPv3 authentication password"
4673msgstr "" 3819msgstr ""
4674 3820
4675#: plugins/check_snmp.c:1120
4676msgid "SNMPv3 privacy password" 3821msgid "SNMPv3 privacy password"
4677msgstr "" 3822msgstr ""
4678 3823
4679#: plugins/check_snmp.c:1124
4680msgid "Object identifier(s) or SNMP variables whose value you wish to query" 3824msgid "Object identifier(s) or SNMP variables whose value you wish to query"
4681msgstr "" 3825msgstr ""
4682 3826
4683#: plugins/check_snmp.c:1126
4684msgid "" 3827msgid ""
4685"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'" 3828"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'"
4686msgstr "" 3829msgstr ""
4687 3830
4688#: plugins/check_snmp.c:1127
4689msgid "for symbolic OIDs.)" 3831msgid "for symbolic OIDs.)"
4690msgstr "" 3832msgstr ""
4691 3833
4692#: plugins/check_snmp.c:1129
4693msgid "Delimiter to use when parsing returned data. Default is" 3834msgid "Delimiter to use when parsing returned data. Default is"
4694msgstr "" 3835msgstr ""
4695 3836
4696#: plugins/check_snmp.c:1130
4697msgid "Any data on the right hand side of the delimiter is considered" 3837msgid "Any data on the right hand side of the delimiter is considered"
4698msgstr "" 3838msgstr ""
4699 3839
4700#: plugins/check_snmp.c:1131
4701msgid "to be the data that should be used in the evaluation." 3840msgid "to be the data that should be used in the evaluation."
4702msgstr "" 3841msgstr ""
4703 3842
4704#: plugins/check_snmp.c:1135 3843msgid "If the check returns a 0 length string or NULL value"
3844msgstr ""
3845
3846msgid "This option allows you to choose what status you want it to exit"
3847msgstr ""
3848
3849msgid "Excluding this option renders the default exit of 3(STATE_UNKNOWN)"
3850msgstr ""
3851
3852msgid "0 = OK"
3853msgstr ""
3854
3855#, fuzzy
3856msgid "1 = WARNING"
3857msgstr "WARNING"
3858
3859#, fuzzy
3860msgid "2 = CRITICAL"
3861msgstr "CRITICAL"
3862
3863#, fuzzy
3864msgid "3 = UNKNOWN"
3865msgstr "UNKNOWN"
3866
4705#, fuzzy 3867#, fuzzy
4706msgid "Warning threshold range(s)" 3868msgid "Warning threshold range(s)"
4707msgstr "Warning threshold Integer sein" 3869msgstr "Warning threshold Integer sein"
4708 3870
4709#: plugins/check_snmp.c:1137
4710#, fuzzy 3871#, fuzzy
4711msgid "Critical threshold range(s)" 3872msgid "Critical threshold range(s)"
4712msgstr "Critical threshold muss ein Integer sein" 3873msgstr "Critical threshold muss ein Integer sein"
4713 3874
4714#: plugins/check_snmp.c:1139
4715msgid "Enable rate calculation. See 'Rate Calculation' below" 3875msgid "Enable rate calculation. See 'Rate Calculation' below"
4716msgstr "" 3876msgstr ""
4717 3877
4718#: plugins/check_snmp.c:1141
4719msgid "" 3878msgid ""
4720"Converts rate per second. For example, set to 60 to convert to per minute" 3879"Converts rate per second. For example, set to 60 to convert to per minute"
4721msgstr "" 3880msgstr ""
4722 3881
4723#: plugins/check_snmp.c:1143 3882msgid "Add/subtract the specified OFFSET to numeric sensor data"
4724msgid "Add/substract the specified OFFSET to numeric sensor data"
4725msgstr "" 3883msgstr ""
4726 3884
4727#: plugins/check_snmp.c:1147
4728msgid "Return OK state (for that OID) if STRING is an exact match" 3885msgid "Return OK state (for that OID) if STRING is an exact match"
4729msgstr "" 3886msgstr ""
4730 3887
4731#: plugins/check_snmp.c:1149
4732msgid "" 3888msgid ""
4733"Return OK state (for that OID) if extended regular expression REGEX matches" 3889"Return OK state (for that OID) if extended regular expression REGEX matches"
4734msgstr "" 3890msgstr ""
4735 3891
4736#: plugins/check_snmp.c:1151
4737msgid "" 3892msgid ""
4738"Return OK state (for that OID) if case-insensitive extended REGEX matches" 3893"Return OK state (for that OID) if case-insensitive extended REGEX matches"
4739msgstr "" 3894msgstr ""
4740 3895
4741#: plugins/check_snmp.c:1153
4742msgid "Invert search result (CRITICAL if found)" 3896msgid "Invert search result (CRITICAL if found)"
4743msgstr "" 3897msgstr ""
4744 3898
4745#: plugins/check_snmp.c:1157
4746msgid "Prefix label for output from plugin" 3899msgid "Prefix label for output from plugin"
4747msgstr "" 3900msgstr ""
4748 3901
4749#: plugins/check_snmp.c:1159
4750msgid "Units label(s) for output data (e.g., 'sec.')." 3902msgid "Units label(s) for output data (e.g., 'sec.')."
4751msgstr "" 3903msgstr ""
4752 3904
4753#: plugins/check_snmp.c:1161
4754msgid "Separates output on multiple OID requests" 3905msgid "Separates output on multiple OID requests"
4755msgstr "" 3906msgstr ""
4756 3907
4757#: plugins/check_snmp.c:1165 3908msgid "Multiplies current value, 0 < n < 1 works as divider, defaults to 1"
4758msgid "Number of retries to be used in the requests" 3909msgstr ""
3910
3911msgid "C-style format string for float values (see option -M)"
3912msgstr ""
3913
3914msgid ""
3915"NOTE the final timeout value is calculated using this formula: "
3916"timeout_interval * retries + 5"
3917msgstr ""
3918
3919msgid "Number of retries to be used in the requests, default: "
4759msgstr "" 3920msgstr ""
4760 3921
4761#: plugins/check_snmp.c:1168
4762msgid "Label performance data with OIDs instead of --label's" 3922msgid "Label performance data with OIDs instead of --label's"
4763msgstr "" 3923msgstr ""
4764 3924
4765#: plugins/check_snmp.c:1173 3925msgid "Tell snmpget to not print errors encountered when parsing MIB files"
3926msgstr ""
3927
4766msgid "" 3928msgid ""
4767"This plugin uses the 'snmpget' command included with the NET-SNMP package." 3929"This plugin uses the 'snmpget' command included with the NET-SNMP package."
4768msgstr "" 3930msgstr ""
4769 3931
4770#: plugins/check_snmp.c:1174
4771msgid "" 3932msgid ""
4772"if you don't have the package installed, you will need to download it from" 3933"if you don't have the package installed, you will need to download it from"
4773msgstr "" 3934msgstr ""
4774 3935
4775#: plugins/check_snmp.c:1175
4776msgid "http://net-snmp.sourceforge.net before you can use this plugin." 3936msgid "http://net-snmp.sourceforge.net before you can use this plugin."
4777msgstr "" 3937msgstr ""
4778 3938
4779#: plugins/check_snmp.c:1179
4780msgid "" 3939msgid ""
4781"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited " 3940"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited "
4782msgstr "" 3941msgstr ""
4783 3942
4784#: plugins/check_snmp.c:1180
4785msgid "list (lists with internal spaces must be quoted)." 3943msgid "list (lists with internal spaces must be quoted)."
4786msgstr "" 3944msgstr ""
4787 3945
4788#: plugins/check_snmp.c:1184
4789msgid "" 3946msgid ""
4790"- When checking multiple OIDs, separate ranges by commas like '-w " 3947"- When checking multiple OIDs, separate ranges by commas like '-w "
4791"1:10,1:,:20'" 3948"1:10,1:,:20'"
4792msgstr "" 3949msgstr ""
4793 3950
4794#: plugins/check_snmp.c:1185
4795msgid "- Note that only one string and one regex may be checked at present" 3951msgid "- Note that only one string and one regex may be checked at present"
4796msgstr "" 3952msgstr ""
4797 3953
4798#: plugins/check_snmp.c:1186
4799msgid "" 3954msgid ""
4800"- All evaluation methods other than PR, STR, and SUBSTR expect that the value" 3955"- All evaluation methods other than PR, STR, and SUBSTR expect that the value"
4801msgstr "" 3956msgstr ""
4802 3957
4803#: plugins/check_snmp.c:1187
4804msgid "returned from the SNMP query is an unsigned integer." 3958msgid "returned from the SNMP query is an unsigned integer."
4805msgstr "" 3959msgstr ""
4806 3960
4807#: plugins/check_snmp.c:1190
4808msgid "Rate Calculation:" 3961msgid "Rate Calculation:"
4809msgstr "" 3962msgstr ""
4810 3963
4811#: plugins/check_snmp.c:1191
4812msgid "In many places, SNMP returns counters that are only meaningful when" 3964msgid "In many places, SNMP returns counters that are only meaningful when"
4813msgstr "" 3965msgstr ""
4814 3966
4815#: plugins/check_snmp.c:1192
4816msgid "calculating the counter difference since the last check. check_snmp" 3967msgid "calculating the counter difference since the last check. check_snmp"
4817msgstr "" 3968msgstr ""
4818 3969
4819#: plugins/check_snmp.c:1193
4820msgid "saves the last state information in a file so that the rate per second" 3970msgid "saves the last state information in a file so that the rate per second"
4821msgstr "" 3971msgstr ""
4822 3972
4823#: plugins/check_snmp.c:1194
4824msgid "can be calculated. Use the --rate option to save state information." 3973msgid "can be calculated. Use the --rate option to save state information."
4825msgstr "" 3974msgstr ""
4826 3975
4827#: plugins/check_snmp.c:1195
4828msgid "" 3976msgid ""
4829"On the first run, there will be no prior state - this will return with OK." 3977"On the first run, there will be no prior state - this will return with OK."
4830msgstr "" 3978msgstr ""
4831 3979
4832#: plugins/check_snmp.c:1196
4833msgid "The state is uniquely determined by the arguments to the plugin, so" 3980msgid "The state is uniquely determined by the arguments to the plugin, so"
4834msgstr "" 3981msgstr ""
4835 3982
4836#: plugins/check_snmp.c:1197
4837msgid "changing the arguments will create a new state file." 3983msgid "changing the arguments will create a new state file."
4838msgstr "" 3984msgstr ""
4839 3985
4840#: plugins/check_ssh.c:165
4841#, fuzzy 3986#, fuzzy
4842msgid "Port number must be a positive integer" 3987msgid "Port number must be a positive integer"
4843msgstr "Port muss ein positiver Integer sein" 3988msgstr "Port muss ein positiver Integer sein"
4844 3989
4845#: plugins/check_ssh.c:232
4846#, c-format 3990#, c-format
4847msgid "Server answer: %s" 3991msgid "Server answer: %s"
4848msgstr "" 3992msgstr ""
4849 3993
4850#: plugins/check_ssh.c:251
4851#, c-format 3994#, c-format
4852msgid "SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n" 3995msgid "SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"
3996msgstr ""
3997
3998#, c-format
3999msgid ""
4000"SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"
4853msgstr "" 4001msgstr ""
4854 4002
4855#: plugins/check_ssh.c:260
4856#, c-format 4003#, c-format
4857msgid "SSH OK - %s (protocol %s) | %s\n" 4004msgid "SSH OK - %s (protocol %s) | %s\n"
4858msgstr "" 4005msgstr ""
4859 4006
4860#: plugins/check_ssh.c:281
4861msgid "Try to connect to an SSH server at specified server and port" 4007msgid "Try to connect to an SSH server at specified server and port"
4862msgstr "" 4008msgstr ""
4863 4009
4864#: plugins/check_ssh.c:297
4865msgid "" 4010msgid ""
4866"Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)" 4011"Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"
4012msgstr ""
4013
4014msgid "Alert if protocol doesn't match expected protocol version (ex: 2.0)"
4867msgstr "" 4015msgstr ""
4868 4016
4869#: plugins/check_swap.c:169
4870#, c-format 4017#, c-format
4871msgid "Command: %s\n" 4018msgid "Command: %s\n"
4872msgstr "" 4019msgstr ""
4873 4020
4874#: plugins/check_swap.c:171
4875#, c-format 4021#, c-format
4876msgid "Format: %s\n" 4022msgid "Format: %s\n"
4877msgstr "" 4023msgstr ""
4878 4024
4879#: plugins/check_swap.c:207
4880#, c-format 4025#, c-format
4881msgid "total=%.0f, used=%.0f, free=%.0f\n" 4026msgid "total=%.0f, used=%.0f, free=%.0f\n"
4882msgstr "" 4027msgstr ""
4883 4028
4884#: plugins/check_swap.c:221
4885#, c-format 4029#, c-format
4886msgid "total=%.0f, free=%.0f\n" 4030msgid "total=%.0f, free=%.0f\n"
4887msgstr "" 4031msgstr ""
4888 4032
4889#: plugins/check_swap.c:253
4890msgid "Error getting swap devices\n" 4033msgid "Error getting swap devices\n"
4891msgstr "" 4034msgstr ""
4892 4035
4893#: plugins/check_swap.c:256
4894msgid "SWAP OK: No swap devices defined\n" 4036msgid "SWAP OK: No swap devices defined\n"
4895msgstr "" 4037msgstr ""
4896 4038
4897#: plugins/check_swap.c:277 plugins/check_swap.c:319
4898msgid "swapctl failed: " 4039msgid "swapctl failed: "
4899msgstr "" 4040msgstr ""
4900 4041
4901#: plugins/check_swap.c:278 plugins/check_swap.c:320
4902msgid "Error in swapctl call\n" 4042msgid "Error in swapctl call\n"
4903msgstr "" 4043msgstr ""
4904 4044
4905#: plugins/check_swap.c:357
4906#, c-format 4045#, c-format
4907msgid "SWAP %s - %d%% free (%d MB out of %d MB) %s|" 4046msgid "SWAP %s - %d%% free (%dMB out of %dMB) %s|"
4908msgstr "" 4047msgstr ""
4909 4048
4910#: plugins/check_swap.c:435 4049#, fuzzy
4911msgid "Warning threshold must be integer or percentage!" 4050msgid "Warning threshold percentage must be <= 100!"
4051msgstr "Warning threshold Integer sein"
4052
4053#, fuzzy
4054msgid "Warning threshold be positive integer or percentage!"
4912msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein" 4055msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein"
4913 4056
4914#: plugins/check_swap.c:453 4057#, fuzzy
4915msgid "Critical threshold must be integer or percentage!" 4058msgid "Critical threshold percentage must be <= 100!"
4916msgstr "Critical threshold muss ein Integer oder ein Prozentwert sein!" 4059msgstr "Critical threshold muss ein Integer sein"
4917 4060
4918#: plugins/check_swap.c:507
4919#, fuzzy 4061#, fuzzy
4920msgid "Warning percentage should be more than critical percentage" 4062msgid "Critical threshold be positive integer or percentage!"
4921msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein" 4063msgstr "Critical threshold muss ein Integer oder ein Prozentwert sein!"
4922 4064
4923#: plugins/check_swap.c:511 4065msgid ""
4924msgid "Warning free space should be more than critical free space" 4066"no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
4067"or integer (0-3)."
4925msgstr "" 4068msgstr ""
4926 4069
4927#: plugins/check_swap.c:525 4070#, fuzzy
4071msgid "Warning should be more than critical"
4072msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein"
4073
4928msgid "Check swap space on local machine." 4074msgid "Check swap space on local machine."
4929msgstr "" 4075msgstr ""
4930 4076
4931#: plugins/check_swap.c:535
4932msgid "" 4077msgid ""
4933"Exit with WARNING status if less than INTEGER bytes of swap space are free" 4078"Exit with WARNING status if less than INTEGER bytes of swap space are free"
4934msgstr "" 4079msgstr ""
4935 4080
4936#: plugins/check_swap.c:537
4937msgid "Exit with WARNING status if less than PERCENT of swap space is free" 4081msgid "Exit with WARNING status if less than PERCENT of swap space is free"
4938msgstr "" 4082msgstr ""
4939 4083
4940#: plugins/check_swap.c:539
4941msgid "" 4084msgid ""
4942"Exit with CRITICAL status if less than INTEGER bytes of swap space are free" 4085"Exit with CRITICAL status if less than INTEGER bytes of swap space are free"
4943msgstr "" 4086msgstr ""
4944 4087
4945#: plugins/check_swap.c:541 4088msgid "Exit with CRITICAL status if less than PERCENT of swap space is free"
4946msgid "Exit with CRITCAL status if less than PERCENT of swap space is free"
4947msgstr "" 4089msgstr ""
4948 4090
4949#: plugins/check_swap.c:543
4950msgid "Conduct comparisons for all swap partitions, one by one" 4091msgid "Conduct comparisons for all swap partitions, one by one"
4951msgstr "" 4092msgstr ""
4952 4093
4953#: plugins/check_swap.c:548 4094msgid ""
4095"Resulting state when there is no swap regardless of thresholds. Default:"
4096msgstr ""
4097
4098msgid ""
4099"Both INTEGER and PERCENT thresholds can be specified, they are all checked."
4100msgstr ""
4101
4954msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s." 4102msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."
4955msgstr "" 4103msgstr ""
4956 4104
4957#: plugins/check_tcp.c:206
4958msgid "CRITICAL - Generic check_tcp called with unknown service\n" 4105msgid "CRITICAL - Generic check_tcp called with unknown service\n"
4959msgstr "" 4106msgstr ""
4960 4107
4961#: plugins/check_tcp.c:230
4962msgid "With UDP checks, a send/expect string must be specified." 4108msgid "With UDP checks, a send/expect string must be specified."
4963msgstr "" 4109msgstr ""
4964 4110
4965#: plugins/check_tcp.c:431
4966msgid "No arguments found" 4111msgid "No arguments found"
4967msgstr "" 4112msgstr ""
4968 4113
4969#: plugins/check_tcp.c:534
4970msgid "Maxbytes must be a positive integer" 4114msgid "Maxbytes must be a positive integer"
4971msgstr "Maxbytes muss ein positiver Integer sein" 4115msgstr "Maxbytes muss ein positiver Integer sein"
4972 4116
4973#: plugins/check_tcp.c:552
4974msgid "Refuse must be one of ok, warn, crit" 4117msgid "Refuse must be one of ok, warn, crit"
4975msgstr "" 4118msgstr ""
4976 4119
4977#: plugins/check_tcp.c:562
4978msgid "Mismatch must be one of ok, warn, crit" 4120msgid "Mismatch must be one of ok, warn, crit"
4979msgstr "" 4121msgstr ""
4980 4122
4981#: plugins/check_tcp.c:568
4982msgid "Delay must be a positive integer" 4123msgid "Delay must be a positive integer"
4983msgstr "Delay muss ein positiver Integer sein" 4124msgstr "Delay muss ein positiver Integer sein"
4984 4125
4985#: plugins/check_tcp.c:613
4986#, fuzzy 4126#, fuzzy
4987msgid "You must provide a server address" 4127msgid "You must provide a server address"
4988msgstr "%s: Hostname muss angegeben werden\n" 4128msgstr "%s: Hostname muss angegeben werden\n"
4989 4129
4990#: plugins/check_tcp.c:615
4991#, fuzzy 4130#, fuzzy
4992msgid "Invalid hostname, address or socket" 4131msgid "Invalid hostname, address or socket"
4993msgstr "Ungültige(r) Hostname/Adresse" 4132msgstr "Ungültige(r) Hostname/Adresse"
4994 4133
4995#: plugins/check_tcp.c:629
4996#, fuzzy, c-format 4134#, fuzzy, c-format
4997msgid "" 4135msgid ""
4998"This plugin tests %s connections with the specified host (or unix socket).\n" 4136"This plugin tests %s connections with the specified host (or unix socket).\n"
4999"\n" 4137"\n"
5000msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 4138msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
5001 4139
5002#: plugins/check_tcp.c:642
5003msgid "" 4140msgid ""
5004"Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or " 4141"Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send "
5005"quit option" 4142"or quit option"
5006msgstr "" 4143msgstr ""
5007 4144
5008#: plugins/check_tcp.c:643
5009msgid "Default: nothing added to send, \\r\\n added to end of quit" 4145msgid "Default: nothing added to send, \\r\\n added to end of quit"
5010msgstr "" 4146msgstr ""
5011 4147
5012#: plugins/check_tcp.c:645
5013msgid "String to send to the server" 4148msgid "String to send to the server"
5014msgstr "" 4149msgstr ""
5015 4150
5016#: plugins/check_tcp.c:647
5017msgid "String to expect in server response" 4151msgid "String to expect in server response"
5018msgstr "" 4152msgstr ""
5019 4153
5020#: plugins/check_tcp.c:647
5021msgid "(may be repeated)" 4154msgid "(may be repeated)"
5022msgstr "" 4155msgstr ""
5023 4156
5024#: plugins/check_tcp.c:649
5025msgid "All expect strings need to occur in server response. Default is any" 4157msgid "All expect strings need to occur in server response. Default is any"
5026msgstr "" 4158msgstr ""
5027 4159
5028#: plugins/check_tcp.c:651
5029msgid "String to send server to initiate a clean close of the connection" 4160msgid "String to send server to initiate a clean close of the connection"
5030msgstr "" 4161msgstr ""
5031 4162
5032#: plugins/check_tcp.c:653
5033msgid "Accept TCP refusals with states ok, warn, crit (default: crit)" 4163msgid "Accept TCP refusals with states ok, warn, crit (default: crit)"
5034msgstr "" 4164msgstr ""
5035 4165
5036#: plugins/check_tcp.c:655
5037msgid "" 4166msgid ""
5038"Accept expected string mismatches with states ok, warn, crit (default: warn)" 4167"Accept expected string mismatches with states ok, warn, crit (default: warn)"
5039msgstr "" 4168msgstr ""
5040 4169
5041#: plugins/check_tcp.c:657
5042#, fuzzy 4170#, fuzzy
5043msgid "Hide output from TCP socket" 4171msgid "Hide output from TCP socket"
5044msgstr "Konnte TCP socket nicht öffnen\n" 4172msgstr "Konnte TCP socket nicht öffnen\n"
5045 4173
5046#: plugins/check_tcp.c:659
5047msgid "Close connection once more than this number of bytes are received" 4174msgid "Close connection once more than this number of bytes are received"
5048msgstr "" 4175msgstr ""
5049 4176
5050#: plugins/check_tcp.c:661
5051msgid "Seconds to wait between sending string and polling for response" 4177msgid "Seconds to wait between sending string and polling for response"
5052msgstr "" 4178msgstr ""
5053 4179
5054#: plugins/check_tcp.c:666
5055msgid "1st is #days for warning, 2nd is critical (if not specified - 0)." 4180msgid "1st is #days for warning, 2nd is critical (if not specified - 0)."
5056msgstr "" 4181msgstr ""
5057 4182
5058#: plugins/check_tcp.c:668
5059msgid "Use SSL for the connection." 4183msgid "Use SSL for the connection."
5060msgstr "" 4184msgstr ""
5061 4185
5062#: plugins/check_time.c:102 4186msgid "SSL server_name"
4187msgstr ""
4188
5063#, c-format 4189#, c-format
5064msgid "TIME UNKNOWN - could not connect to server %s, port %d\n" 4190msgid "TIME UNKNOWN - could not connect to server %s, port %d\n"
5065msgstr "" 4191msgstr ""
5066 4192
5067#: plugins/check_time.c:115
5068#, c-format 4193#, c-format
5069msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n" 4194msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n"
5070msgstr "" 4195msgstr ""
5071 4196
5072#: plugins/check_time.c:139
5073#, c-format 4197#, c-format
5074msgid "TIME UNKNOWN - no data received from server %s, port %d\n" 4198msgid "TIME UNKNOWN - no data received from server %s, port %d\n"
5075msgstr "" 4199msgstr ""
5076 4200
5077#: plugins/check_time.c:152
5078#, c-format 4201#, c-format
5079msgid "TIME %s - %d second response time|%s\n" 4202msgid "TIME %s - %d second response time|%s\n"
5080msgstr "" 4203msgstr ""
5081 4204
5082#: plugins/check_time.c:170
5083#, c-format 4205#, c-format
5084msgid "TIME %s - %lu second time difference|%s %s\n" 4206msgid "TIME %s - %lu second time difference|%s %s\n"
5085msgstr "" 4207msgstr ""
5086 4208
5087#: plugins/check_time.c:254
5088msgid "Warning thresholds must be a positive integer" 4209msgid "Warning thresholds must be a positive integer"
5089msgstr "Warning thresholds muss ein positiver Integer sein" 4210msgstr "Warning thresholds muss ein positiver Integer sein"
5090 4211
5091#: plugins/check_time.c:273
5092msgid "Critical thresholds must be a positive integer" 4212msgid "Critical thresholds must be a positive integer"
5093msgstr "Critical thresholds muss ein positiver Integer sein" 4213msgstr "Critical thresholds muss ein positiver Integer sein"
5094 4214
5095#: plugins/check_time.c:339
5096#, fuzzy 4215#, fuzzy
5097msgid "This plugin will check the time on the specified host." 4216msgid "This plugin will check the time on the specified host."
5098msgstr "" 4217msgstr ""
5099"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 4218"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
5100"\n" 4219"\n"
5101 4220
5102#: plugins/check_time.c:351
5103msgid "Use UDP to connect, not TCP" 4221msgid "Use UDP to connect, not TCP"
5104msgstr "" 4222msgstr ""
5105 4223
5106#: plugins/check_time.c:353
5107msgid "Time difference (sec.) necessary to result in a warning status" 4224msgid "Time difference (sec.) necessary to result in a warning status"
5108msgstr "" 4225msgstr ""
5109 4226
5110#: plugins/check_time.c:355
5111msgid "Time difference (sec.) necessary to result in a critical status" 4227msgid "Time difference (sec.) necessary to result in a critical status"
5112msgstr "" 4228msgstr ""
5113 4229
5114#: plugins/check_time.c:357
5115msgid "Response time (sec.) necessary to result in warning status" 4230msgid "Response time (sec.) necessary to result in warning status"
5116msgstr "" 4231msgstr ""
5117 4232
5118#: plugins/check_time.c:359
5119msgid "Response time (sec.) necessary to result in critical status" 4233msgid "Response time (sec.) necessary to result in critical status"
5120msgstr "" 4234msgstr ""
5121 4235
5122#: plugins/check_ups.c:144
5123msgid "On Battery, Low Battery" 4236msgid "On Battery, Low Battery"
5124msgstr "" 4237msgstr ""
5125 4238
5126#: plugins/check_ups.c:149
5127msgid "Online" 4239msgid "Online"
5128msgstr "" 4240msgstr ""
5129 4241
5130#: plugins/check_ups.c:152
5131msgid "On Battery" 4242msgid "On Battery"
5132msgstr "" 4243msgstr ""
5133 4244
5134#: plugins/check_ups.c:156
5135msgid ", Low Battery" 4245msgid ", Low Battery"
5136msgstr "" 4246msgstr ""
5137 4247
5138#: plugins/check_ups.c:160
5139msgid ", Calibrating" 4248msgid ", Calibrating"
5140msgstr "" 4249msgstr ""
5141 4250
5142#: plugins/check_ups.c:163
5143msgid ", Replace Battery" 4251msgid ", Replace Battery"
5144msgstr "" 4252msgstr ""
5145 4253
5146#: plugins/check_ups.c:167
5147msgid ", On Bypass" 4254msgid ", On Bypass"
5148msgstr "" 4255msgstr ""
5149 4256
5150#: plugins/check_ups.c:170
5151msgid ", Overload" 4257msgid ", Overload"
5152msgstr "" 4258msgstr ""
5153 4259
5154#: plugins/check_ups.c:173
5155msgid ", Trimming" 4260msgid ", Trimming"
5156msgstr "" 4261msgstr ""
5157 4262
5158#: plugins/check_ups.c:176
5159msgid ", Boosting" 4263msgid ", Boosting"
5160msgstr "" 4264msgstr ""
5161 4265
5162#: plugins/check_ups.c:179
5163msgid ", Charging" 4266msgid ", Charging"
5164msgstr "" 4267msgstr ""
5165 4268
5166#: plugins/check_ups.c:182
5167msgid ", Discharging" 4269msgid ", Discharging"
5168msgstr "" 4270msgstr ""
5169 4271
5170#: plugins/check_ups.c:185
5171msgid ", Unknown" 4272msgid ", Unknown"
5172msgstr "" 4273msgstr ""
5173 4274
5174#: plugins/check_ups.c:324
5175#, fuzzy 4275#, fuzzy
5176msgid "UPS does not support any available options\n" 4276msgid "UPS does not support any available options\n"
5177msgstr "IPv6 Unterstützung nicht vorhanden" 4277msgstr "IPv6 Unterstützung nicht vorhanden"
5178 4278
5179#: plugins/check_ups.c:348 plugins/check_ups.c:411
5180#, fuzzy 4279#, fuzzy
5181msgid "Invalid response received from host" 4280msgid "Invalid response received from host"
5182msgstr "Ungültige HTTP Antwort von Host empfangen\n" 4281msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4282
4283msgid "UPS name to long for buffer"
4284msgstr ""
5183 4285
5184#: plugins/check_ups.c:420
5185#, fuzzy, c-format 4286#, fuzzy, c-format
5186msgid "CRITICAL - no such UPS '%s' on that host\n" 4287msgid "CRITICAL - no such UPS '%s' on that host\n"
5187msgstr "%s [%s nicht gefunden]" 4288msgstr "%s [%s nicht gefunden]"
5188 4289
5189#: plugins/check_ups.c:430
5190#, fuzzy 4290#, fuzzy
5191msgid "CRITICAL - UPS data is stale" 4291msgid "CRITICAL - UPS data is stale"
5192msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 4292msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
5193 4293
5194#: plugins/check_ups.c:435
5195#, fuzzy, c-format 4294#, fuzzy, c-format
5196msgid "Unknown error: %s\n" 4295msgid "Unknown error: %s\n"
5197msgstr "Papierfehler" 4296msgstr "Papierfehler"
5198 4297
5199#: plugins/check_ups.c:442
5200msgid "Error: unable to parse variable" 4298msgid "Error: unable to parse variable"
5201msgstr "" 4299msgstr ""
5202 4300
5203#: plugins/check_ups.c:549
5204msgid "Unrecognized UPS variable" 4301msgid "Unrecognized UPS variable"
5205msgstr "" 4302msgstr ""
5206 4303
5207#: plugins/check_ups.c:587
5208msgid "Error : no UPS indicated" 4304msgid "Error : no UPS indicated"
5209msgstr "" 4305msgstr ""
5210 4306
5211#: plugins/check_ups.c:607
5212#, fuzzy 4307#, fuzzy
5213msgid "" 4308msgid ""
5214"This plugin tests the UPS service on the specified host. Network UPS Tools" 4309"This plugin tests the UPS service on the specified host. Network UPS Tools"
@@ -5216,479 +4311,406 @@ msgstr ""
5216"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 4311"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
5217"\n" 4312"\n"
5218 4313
5219#: plugins/check_ups.c:608
5220msgid "from www.networkupstools.org must be running for this plugin to work." 4314msgid "from www.networkupstools.org must be running for this plugin to work."
5221msgstr "" 4315msgstr ""
5222 4316
5223#: plugins/check_ups.c:620
5224msgid "Name of UPS" 4317msgid "Name of UPS"
5225msgstr "" 4318msgstr ""
5226 4319
5227#: plugins/check_ups.c:622
5228msgid "Output of temperatures in Celsius" 4320msgid "Output of temperatures in Celsius"
5229msgstr "" 4321msgstr ""
5230 4322
5231#: plugins/check_ups.c:624
5232msgid "Valid values for STRING are" 4323msgid "Valid values for STRING are"
5233msgstr "" 4324msgstr ""
5234 4325
5235#: plugins/check_ups.c:635
5236msgid "" 4326msgid ""
5237"This plugin attempts to determine the status of a UPS (Uninterruptible Power" 4327"This plugin attempts to determine the status of a UPS (Uninterruptible Power"
5238msgstr "" 4328msgstr ""
5239 4329
5240#: plugins/check_ups.c:636
5241msgid "" 4330msgid ""
5242"Supply) on a local or remote host. If the UPS is online or calibrating, the" 4331"Supply) on a local or remote host. If the UPS is online or calibrating, the"
5243msgstr "" 4332msgstr ""
5244 4333
5245#: plugins/check_ups.c:637
5246msgid "" 4334msgid ""
5247"plugin will return an OK state. If the battery is on it will return a WARNING" 4335"plugin will return an OK state. If the battery is on it will return a WARNING"
5248msgstr "" 4336msgstr ""
5249 4337
5250#: plugins/check_ups.c:638
5251msgid "" 4338msgid ""
5252"state. If the UPS is off or has a low battery the plugin will return a " 4339"state. If the UPS is off or has a low battery the plugin will return a "
5253"CRITICAL" 4340"CRITICAL"
5254msgstr "" 4341msgstr ""
5255 4342
5256#: plugins/check_ups.c:643
5257msgid "" 4343msgid ""
5258"You may also specify a variable to check (such as temperature, utility " 4344"You may also specify a variable to check (such as temperature, utility "
5259"voltage," 4345"voltage,"
5260msgstr "" 4346msgstr ""
5261 4347
5262#: plugins/check_ups.c:644
5263msgid "" 4348msgid ""
5264"battery load, etc.) as well as warning and critical thresholds for the value" 4349"battery load, etc.) as well as warning and critical thresholds for the value"
5265msgstr "" 4350msgstr ""
5266 4351
5267#: plugins/check_ups.c:645
5268msgid "" 4352msgid ""
5269"of that variable. If the remote host has multiple UPS that are being " 4353"of that variable. If the remote host has multiple UPS that are being "
5270"monitored" 4354"monitored"
5271msgstr "" 4355msgstr ""
5272 4356
5273#: plugins/check_ups.c:646
5274msgid "you will have to use the --ups option to specify which UPS to check." 4357msgid "you will have to use the --ups option to specify which UPS to check."
5275msgstr "" 4358msgstr ""
5276 4359
5277#: plugins/check_ups.c:648
5278msgid "" 4360msgid ""
5279"This plugin requires that the UPSD daemon distributed with Russell Kroll's" 4361"This plugin requires that the UPSD daemon distributed with Russell Kroll's"
5280msgstr "" 4362msgstr ""
5281 4363
5282#: plugins/check_ups.c:649
5283msgid "" 4364msgid ""
5284"Network UPS Tools be installed on the remote host. If you do not have the" 4365"Network UPS Tools be installed on the remote host. If you do not have the"
5285msgstr "" 4366msgstr ""
5286 4367
5287#: plugins/check_ups.c:650
5288msgid "package installed on your system, you can download it from" 4368msgid "package installed on your system, you can download it from"
5289msgstr "" 4369msgstr ""
5290 4370
5291#: plugins/check_ups.c:651
5292msgid "http://www.networkupstools.org" 4371msgid "http://www.networkupstools.org"
5293msgstr "" 4372msgstr ""
5294 4373
5295#: plugins/check_users.c:110 4374#, fuzzy, c-format
4375msgid "Could not enumerate RD sessions: %d\n"
4376msgstr "Konnte·url·nicht·zuweisen\n"
4377
5296#, c-format 4378#, c-format
5297msgid "# users=%d" 4379msgid "# users=%d"
5298msgstr "" 4380msgstr ""
5299 4381
5300#: plugins/check_users.c:133
5301msgid "Unable to read output" 4382msgid "Unable to read output"
5302msgstr "" 4383msgstr ""
5303 4384
5304#: plugins/check_users.c:140
5305#, c-format 4385#, c-format
5306msgid "USERS %s - %d users currently logged in |%s\n" 4386msgid "USERS %s - %d users currently logged in |%s\n"
5307msgstr "" 4387msgstr ""
5308 4388
5309#: plugins/check_users.c:219
5310#, fuzzy 4389#, fuzzy
5311msgid "This plugin checks the number of users currently logged in on the local" 4390msgid "This plugin checks the number of users currently logged in on the local"
5312msgstr "" 4391msgstr ""
5313"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n" 4392"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n"
5314"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 4393"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
5315"unterschritten wird.\n" 4394"unterschritten wird.\n"
5316"\n" 4395"\n"
5317 4396
5318#: plugins/check_users.c:220
5319msgid "" 4397msgid ""
5320"system and generates an error if the number exceeds the thresholds specified." 4398"system and generates an error if the number exceeds the thresholds specified."
5321msgstr "" 4399msgstr ""
5322 4400
5323#: plugins/check_users.c:230
5324msgid "Set WARNING status if more than INTEGER users are logged in" 4401msgid "Set WARNING status if more than INTEGER users are logged in"
5325msgstr "" 4402msgstr ""
5326 4403
5327#: plugins/check_users.c:232
5328msgid "Set CRITICAL status if more than INTEGER users are logged in" 4404msgid "Set CRITICAL status if more than INTEGER users are logged in"
5329msgstr "" 4405msgstr ""
5330 4406
5331#: plugins/check_ide_smart.c:256 4407msgid ""
4408"DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."
4409msgstr ""
4410
4411msgid "Nagios-compatible output is now always returned."
4412msgstr ""
4413
4414msgid "SMART commands are broken and have been disabled (See Notes in --help)."
4415msgstr ""
4416
4417msgid ""
4418"DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"
4419msgstr ""
4420
4421msgid "default and will be removed from future releases."
4422msgstr ""
4423
5332#, fuzzy, c-format 4424#, fuzzy, c-format
5333msgid "CRITICAL - Couldn't open device %s: %s\n" 4425msgid "CRITICAL - Couldn't open device %s: %s\n"
5334msgstr "CRITICAL - Device konnte nicht geöffnet werden: %s\n" 4426msgstr "CRITICAL - Device konnte nicht geöffnet werden: %s\n"
5335 4427
5336#: plugins/check_ide_smart.c:261
5337#, c-format 4428#, c-format
5338msgid "CRITICAL - SMART_CMD_ENABLE\n" 4429msgid "CRITICAL - SMART_CMD_ENABLE\n"
5339msgstr "" 4430msgstr ""
5340 4431
5341#: plugins/check_ide_smart.c:323 plugins/check_ide_smart.c:350
5342#, c-format 4432#, c-format
5343msgid "CRITICAL - SMART_READ_VALUES: %s\n" 4433msgid "CRITICAL - SMART_READ_VALUES: %s\n"
5344msgstr "" 4434msgstr ""
5345 4435
5346#: plugins/check_ide_smart.c:421
5347#, c-format 4436#, c-format
5348msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n" 4437msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"
5349msgstr "" 4438msgstr ""
5350 4439
5351#: plugins/check_ide_smart.c:429
5352#, c-format 4440#, c-format
5353msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n" 4441msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"
5354msgstr "" 4442msgstr ""
5355 4443
5356#: plugins/check_ide_smart.c:437
5357#, c-format 4444#, c-format
5358msgid "OK - Operational (%d/%d tests passed)\n" 4445msgid "OK - Operational (%d/%d tests passed)\n"
5359msgstr "" 4446msgstr ""
5360 4447
5361#: plugins/check_ide_smart.c:441
5362#, c-format 4448#, c-format
5363msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n" 4449msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n"
5364msgstr "" 4450msgstr ""
5365 4451
5366#: plugins/check_ide_smart.c:474
5367#, c-format 4452#, c-format
5368msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n" 4453msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"
5369msgstr "" 4454msgstr ""
5370 4455
5371#: plugins/check_ide_smart.c:480
5372#, c-format 4456#, c-format
5373msgid "OffLineCapability=%d {%s %s %s}\n" 4457msgid "OffLineCapability=%d {%s %s %s}\n"
5374msgstr "" 4458msgstr ""
5375 4459
5376#: plugins/check_ide_smart.c:486
5377#, c-format 4460#, c-format
5378msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n" 4461msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"
5379msgstr "" 4462msgstr ""
5380 4463
5381#: plugins/check_ide_smart.c:508 plugins/check_ide_smart.c:532
5382#, c-format 4464#, c-format
5383msgid "CRITICAL - %s: %s\n" 4465msgid "CRITICAL - %s: %s\n"
5384msgstr "" 4466msgstr ""
5385 4467
5386#: plugins/check_ide_smart.c:553 plugins/check_ide_smart.c:580 4468#, c-format
4469msgid "OK - Command sent (%s)\n"
4470msgstr ""
4471
5387#, c-format 4472#, c-format
5388msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n" 4473msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n"
5389msgstr "" 4474msgstr ""
5390 4475
5391#: plugins/check_ide_smart.c:599
5392#, c-format 4476#, c-format
5393msgid "" 4477msgid ""
5394"This plugin checks a local hard drive with the (Linux specific) SMART " 4478"This plugin checks a local hard drive with the (Linux specific) SMART "
5395"interface [http://smartlinux.sourceforge.net/smart/index.php]." 4479"interface [http://smartlinux.sourceforge.net/smart/index.php]."
5396msgstr "" 4480msgstr ""
5397 4481
5398#: plugins/check_ide_smart.c:609
5399msgid "Select device DEVICE" 4482msgid "Select device DEVICE"
5400msgstr "" 4483msgstr ""
5401 4484
5402#: plugins/check_ide_smart.c:610
5403msgid "" 4485msgid ""
5404"Note: if the device is selected with this option, _no_ other options are " 4486"Note: if the device is specified without this option, any further option will"
5405"accepted"
5406msgstr "" 4487msgstr ""
5407 4488
5408#: plugins/check_ide_smart.c:612 4489msgid "be ignored."
5409msgid "Perform immediately offline tests"
5410msgstr "" 4490msgstr ""
5411 4491
5412#: plugins/check_ide_smart.c:614 4492msgid ""
5413msgid "Returns the number of failed tests" 4493"The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"
4494msgstr ""
4495
4496msgid ""
4497"broken in an underhand manner and have been disabled. You can use smartctl"
4498msgstr ""
4499
4500msgid "instead:"
5414msgstr "" 4501msgstr ""
5415 4502
5416#: plugins/check_ide_smart.c:616 4503msgid "-0/--auto-off: use \"smartctl --offlineauto=off\""
5417msgid "Turn on automatic offline tests"
5418msgstr "" 4504msgstr ""
5419 4505
5420#: plugins/check_ide_smart.c:618 4506msgid "-1/--auto-on: use \"smartctl --offlineauto=on\""
5421msgid "Turn off automatic offline tests"
5422msgstr "" 4507msgstr ""
5423 4508
5424#: plugins/check_ide_smart.c:620 4509msgid "-i/--immediate: use \"smartctl --test=offline\""
5425msgid "Output suitable for the monitoring system"
5426msgstr "" 4510msgstr ""
5427 4511
5428#: plugins/negate.c:99
5429#, fuzzy 4512#, fuzzy
5430msgid "No data returned from command\n" 4513msgid "No data returned from command\n"
5431msgstr "Keine Daten empfangen %s\n" 4514msgstr "Keine Daten empfangen %s\n"
5432 4515
5433#: plugins/negate.c:170
5434msgid "" 4516msgid ""
5435"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) " 4517"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
5436"or integer (0-3)." 4518"or integer (0-3)."
5437msgstr "" 4519msgstr ""
5438 4520
5439#: plugins/negate.c:174
5440msgid "" 4521msgid ""
5441"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer " 4522"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer "
5442"(0-3)." 4523"(0-3)."
5443msgstr "" 4524msgstr ""
5444 4525
5445#: plugins/negate.c:180
5446msgid "" 4526msgid ""
5447"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4527"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5448"integer (0-3)." 4528"integer (0-3)."
5449msgstr "" 4529msgstr ""
5450 4530
5451#: plugins/negate.c:185
5452msgid "" 4531msgid ""
5453"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4532"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5454"integer (0-3)." 4533"integer (0-3)."
5455msgstr "" 4534msgstr ""
5456 4535
5457#: plugins/negate.c:190
5458msgid "" 4536msgid ""
5459"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4537"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5460"integer (0-3)." 4538"integer (0-3)."
5461msgstr "" 4539msgstr ""
5462 4540
5463#: plugins/negate.c:217
5464msgid "Require path to command" 4541msgid "Require path to command"
5465msgstr "" 4542msgstr ""
5466 4543
5467#: plugins/negate.c:246
5468msgid "" 4544msgid ""
5469"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)." 4545"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)."
5470msgstr "" 4546msgstr ""
5471 4547
5472#: plugins/negate.c:247
5473msgid "Additional switches can be used to control which state becomes what." 4548msgid "Additional switches can be used to control which state becomes what."
5474msgstr "" 4549msgstr ""
5475 4550
5476#: plugins/negate.c:256
5477msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status." 4551msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status."
5478msgstr "" 4552msgstr ""
5479 4553
5480#: plugins/negate.c:258
5481msgid "Custom result on Negate timeouts; see below for STATUS definition\n" 4554msgid "Custom result on Negate timeouts; see below for STATUS definition\n"
5482msgstr "" 4555msgstr ""
5483 4556
5484#: plugins/negate.c:264
5485#, c-format 4557#, c-format
5486msgid "" 4558msgid ""
5487" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n" 4559" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n"
5488msgstr "" 4560msgstr ""
5489 4561
5490#: plugins/negate.c:265
5491#, c-format 4562#, c-format
5492msgid "" 4563msgid ""
5493" quotes. Numeric values are accepted. If nothing is specified, permutes\n" 4564" quotes. Numeric values are accepted. If nothing is specified, permutes\n"
5494msgstr "" 4565msgstr ""
5495 4566
5496#: plugins/negate.c:266
5497#, c-format 4567#, c-format
5498msgid " OK and CRITICAL.\n" 4568msgid " OK and CRITICAL.\n"
5499msgstr "" 4569msgstr ""
5500 4570
5501#: plugins/negate.c:268
5502#, c-format 4571#, c-format
5503msgid "" 4572msgid ""
5504" Substitute output text as well. Will only substitute text in CAPITALS\n" 4573" Substitute output text as well. Will only substitute text in CAPITALS\n"
5505msgstr "" 4574msgstr ""
5506 4575
5507#: plugins/negate.c:273
5508msgid "Run check_ping and invert result. Must use full path to plugin" 4576msgid "Run check_ping and invert result. Must use full path to plugin"
5509msgstr "" 4577msgstr ""
5510 4578
5511#: plugins/negate.c:275
5512msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL" 4579msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL"
5513msgstr "" 4580msgstr ""
5514 4581
5515#: plugins/negate.c:278
5516msgid "" 4582msgid ""
5517"This plugin is a wrapper to take the output of another plugin and invert it." 4583"This plugin is a wrapper to take the output of another plugin and invert it."
5518msgstr "" 4584msgstr ""
5519 4585
5520#: plugins/negate.c:279
5521msgid "The full path of the plugin must be provided." 4586msgid "The full path of the plugin must be provided."
5522msgstr "" 4587msgstr ""
5523 4588
5524#: plugins/negate.c:280
5525msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL." 4589msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL."
5526msgstr "" 4590msgstr ""
5527 4591
5528#: plugins/negate.c:281
5529msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK." 4592msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK."
5530msgstr "" 4593msgstr ""
5531 4594
5532#: plugins/negate.c:282
5533msgid "Otherwise, the output state of the wrapped plugin is unchanged." 4595msgid "Otherwise, the output state of the wrapped plugin is unchanged."
5534msgstr "" 4596msgstr ""
5535 4597
5536#: plugins/negate.c:284
5537msgid "" 4598msgid ""
5538"Using timeout-result, it is possible to override the timeout behaviour or a" 4599"Using timeout-result, it is possible to override the timeout behaviour or a"
5539msgstr "" 4600msgstr ""
5540 4601
5541#: plugins/negate.c:285
5542msgid "plugin by setting the negate timeout a bit lower." 4602msgid "plugin by setting the negate timeout a bit lower."
5543msgstr "" 4603msgstr ""
5544 4604
5545#: plugins/netutils.c:49
5546#, fuzzy, c-format 4605#, fuzzy, c-format
5547msgid "%s - Socket timeout after %d seconds\n" 4606msgid "%s - Socket timeout after %d seconds\n"
5548msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 4607msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5549 4608
5550#: plugins/netutils.c:51
5551#, fuzzy, c-format 4609#, fuzzy, c-format
5552msgid "%s - Abnormal timeout after %d seconds\n" 4610msgid "%s - Abnormal timeout after %d seconds\n"
5553msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 4611msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5554 4612
5555#: plugins/netutils.c:79 plugins/netutils.c:281
5556msgid "Send failed" 4613msgid "Send failed"
5557msgstr "" 4614msgstr ""
5558 4615
5559#: plugins/netutils.c:96 plugins/netutils.c:296
5560#, fuzzy 4616#, fuzzy
5561msgid "No data was received from host!" 4617msgid "No data was received from host!"
5562msgstr "Keine Daten empfangen %s\n" 4618msgstr "Keine Daten empfangen %s\n"
5563 4619
5564#: plugins/netutils.c:204 plugins/netutils.c:240
5565msgid "Socket creation failed" 4620msgid "Socket creation failed"
5566msgstr "" 4621msgstr ""
5567 4622
5568#: plugins/netutils.c:233
5569msgid "Supplied path too long unix domain socket" 4623msgid "Supplied path too long unix domain socket"
5570msgstr "" 4624msgstr ""
5571 4625
5572#: plugins/netutils.c:305
5573msgid "Receive failed" 4626msgid "Receive failed"
5574msgstr "" 4627msgstr ""
5575 4628
5576#: plugins/netutils.c:331 plugins-root/check_dhcp.c:1342
5577#, fuzzy, c-format 4629#, fuzzy, c-format
5578msgid "Invalid hostname/address - %s" 4630msgid "Invalid hostname/address - %s"
5579msgstr "" 4631msgstr ""
5580"Ungültige(r) Name/Adresse: %s\n" 4632"Ungültige(r) Name/Adresse: %s\n"
5581"\n" 4633"\n"
5582 4634
5583#: plugins/popen.c:142
5584#, fuzzy 4635#, fuzzy
5585msgid "Could not malloc argv array in popen()" 4636msgid "Could not malloc argv array in popen()"
5586msgstr "Konnte addr nicht zuweisen\n" 4637msgstr "Konnte addr nicht zuweisen\n"
5587 4638
5588#: plugins/popen.c:152
5589#, fuzzy 4639#, fuzzy
5590msgid "CRITICAL - You need more args!!!" 4640msgid "CRITICAL - You need more args!!!"
5591msgstr "CRITICAL - Fehler: %s\n" 4641msgstr "CRITICAL - Fehler: %s\n"
5592 4642
5593#: plugins/popen.c:209
5594#, fuzzy 4643#, fuzzy
5595msgid "Cannot catch SIGCHLD" 4644msgid "Cannot catch SIGCHLD"
5596msgstr "Konnte SIGALRM nicht erhalten" 4645msgstr "Konnte SIGALRM nicht erhalten"
5597 4646
5598#: plugins/popen.c:304
5599#, fuzzy, c-format 4647#, fuzzy, c-format
5600msgid "CRITICAL - Plugin timed out after %d seconds\n" 4648msgid "CRITICAL - Plugin timed out after %d seconds\n"
5601msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 4649msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5602 4650
5603#: plugins/popen.c:307
5604msgid "CRITICAL - popen timeout received, but no child process" 4651msgid "CRITICAL - popen timeout received, but no child process"
5605msgstr "" 4652msgstr ""
5606 4653
5607#: plugins/popen.c:323
5608msgid "sysconf error for _SC_OPEN_MAX"
5609msgstr ""
5610
5611#: plugins/urlize.c:130
5612#, c-format 4654#, c-format
5613msgid "" 4655msgid ""
5614"%s UNKNOWN - No data received from host\n" 4656"%s UNKNOWN - No data received from host\n"
5615"CMD: %s</A>\n" 4657"CMD: %s</A>\n"
5616msgstr "" 4658msgstr ""
5617 4659
5618#: plugins/urlize.c:169
5619msgid "" 4660msgid ""
5620"This plugin wraps the text output of another command (plugin) in HTML <A>" 4661"This plugin wraps the text output of another command (plugin) in HTML <A>"
5621msgstr "" 4662msgstr ""
5622 4663
5623#: plugins/urlize.c:170
5624msgid "" 4664msgid ""
5625"tags, thus displaying the child plugin's output as a clickable link in " 4665"tags, thus displaying the child plugin's output as a clickable link in "
5626"compatible" 4666"compatible"
5627msgstr "" 4667msgstr ""
5628 4668
5629#: plugins/urlize.c:171
5630msgid "" 4669msgid ""
5631"monitoring status screen. This plugin returns the status of the invoked " 4670"monitoring status screen. This plugin returns the status of the invoked "
5632"plugin." 4671"plugin."
5633msgstr "" 4672msgstr ""
5634 4673
5635#: plugins/urlize.c:181
5636msgid "" 4674msgid ""
5637"Pay close attention to quoting to ensure that the shell passes the expected" 4675"Pay close attention to quoting to ensure that the shell passes the expected"
5638msgstr "" 4676msgstr ""
5639 4677
5640#: plugins/urlize.c:182
5641msgid "data to the plugin. For example, in:" 4678msgid "data to the plugin. For example, in:"
5642msgstr "" 4679msgstr ""
5643 4680
5644#: plugins/urlize.c:183
5645msgid "urlize http://example.com/ check_http -H example.com -r 'two words'" 4681msgid "urlize http://example.com/ check_http -H example.com -r 'two words'"
5646msgstr "" 4682msgstr ""
5647 4683
5648#: plugins/urlize.c:184
5649msgid "the shell will remove the single quotes and urlize will see:" 4684msgid "the shell will remove the single quotes and urlize will see:"
5650msgstr "" 4685msgstr ""
5651 4686
5652#: plugins/urlize.c:185
5653msgid "urlize http://example.com/ check_http -H example.com -r two words" 4687msgid "urlize http://example.com/ check_http -H example.com -r two words"
5654msgstr "" 4688msgstr ""
5655 4689
5656#: plugins/urlize.c:186
5657msgid "You probably want:" 4690msgid "You probably want:"
5658msgstr "" 4691msgstr ""
5659 4692
5660#: plugins/urlize.c:187
5661msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\"" 4693msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\""
5662msgstr "" 4694msgstr ""
5663 4695
5664#: plugins/utils.c:174
5665#, fuzzy, c-format
5666msgid "%s - Plugin timed out after %d seconds\n"
5667msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5668
5669#: plugins/utils.c:469
5670#, fuzzy 4696#, fuzzy
5671msgid "failed realloc in strpcpy\n" 4697msgid "failed realloc in strpcpy\n"
5672msgstr "konnte keinen Speicher für '%s' reservieren\n" 4698msgstr "konnte keinen Speicher für '%s' reservieren\n"
5673 4699
5674#: plugins/utils.c:511
5675#, fuzzy 4700#, fuzzy
5676msgid "failed malloc in strscat\n" 4701msgid "failed malloc in strscat\n"
5677msgstr "konnte keinen Speicher für '%s' reservieren\n" 4702msgstr "konnte keinen Speicher für '%s' reservieren\n"
5678 4703
5679#: plugins/utils.c:531
5680#, fuzzy 4704#, fuzzy
5681msgid "failed malloc in xvasprintf\n" 4705msgid "failed malloc in xvasprintf\n"
5682msgstr "konnte keinen Speicher für '%s' reservieren\n" 4706msgstr "konnte keinen Speicher für '%s' reservieren\n"
5683 4707
5684#: plugins/utils.h:137
5685#, c-format 4708#, c-format
5686msgid "" 4709msgid ""
5687" %s (-h | --help) for detailed help\n" 4710" %s (-h | --help) for detailed help\n"
5688" %s (-V | --version) for version information\n" 4711" %s (-V | --version) for version information\n"
5689msgstr "" 4712msgstr ""
5690 4713
5691#: plugins/utils.h:141
5692msgid "" 4714msgid ""
5693"\n" 4715"\n"
5694"Options:\n" 4716"Options:\n"
@@ -5698,7 +4720,6 @@ msgid ""
5698" Print version information\n" 4720" Print version information\n"
5699msgstr "" 4721msgstr ""
5700 4722
5701#: plugins/utils.h:148
5702#, c-format 4723#, c-format
5703msgid "" 4724msgid ""
5704" -H, --hostname=ADDRESS\n" 4725" -H, --hostname=ADDRESS\n"
@@ -5707,7 +4728,6 @@ msgid ""
5707" Port number (default: %s)\n" 4728" Port number (default: %s)\n"
5708msgstr "" 4729msgstr ""
5709 4730
5710#: plugins/utils.h:154
5711msgid "" 4731msgid ""
5712" -4, --use-ipv4\n" 4732" -4, --use-ipv4\n"
5713" Use IPv4 connection\n" 4733" Use IPv4 connection\n"
@@ -5715,14 +4735,12 @@ msgid ""
5715" Use IPv6 connection\n" 4735" Use IPv6 connection\n"
5716msgstr "" 4736msgstr ""
5717 4737
5718#: plugins/utils.h:160
5719msgid "" 4738msgid ""
5720" -v, --verbose\n" 4739" -v, --verbose\n"
5721" Show details for command-line debugging (output may be truncated by\n" 4740" Show details for command-line debugging (output may be truncated by\n"
5722"\t\tthe monitoring system)\n" 4741" the monitoring system)\n"
5723msgstr "" 4742msgstr ""
5724 4743
5725#: plugins/utils.h:165
5726msgid "" 4744msgid ""
5727" -w, --warning=DOUBLE\n" 4745" -w, --warning=DOUBLE\n"
5728" Response time to result in warning status (seconds)\n" 4746" Response time to result in warning status (seconds)\n"
@@ -5730,7 +4748,6 @@ msgid ""
5730" Response time to result in critical status (seconds)\n" 4748" Response time to result in critical status (seconds)\n"
5731msgstr "" 4749msgstr ""
5732 4750
5733#: plugins/utils.h:171
5734msgid "" 4751msgid ""
5735" -w, --warning=RANGE\n" 4752" -w, --warning=RANGE\n"
5736" Warning range (format: start:end). Alert if outside this range\n" 4753" Warning range (format: start:end). Alert if outside this range\n"
@@ -5738,14 +4755,18 @@ msgid ""
5738" Critical range\n" 4755" Critical range\n"
5739msgstr "" 4756msgstr ""
5740 4757
5741#: plugins/utils.h:177
5742#, c-format 4758#, c-format
5743msgid "" 4759msgid ""
5744" -t, --timeout=INTEGER\n" 4760" -t, --timeout=INTEGER\n"
5745" Seconds before connection times out (default: %d)\n" 4761" Seconds before connection times out (default: %d)\n"
5746msgstr "" 4762msgstr ""
5747 4763
5748#: plugins/utils.h:182 4764#, c-format
4765msgid ""
4766" -t, --timeout=INTEGER\n"
4767" Seconds before plugin times out (default: %d)\n"
4768msgstr ""
4769
5749msgid "" 4770msgid ""
5750" --extra-opts=[section][@file]\n" 4771" --extra-opts=[section][@file]\n"
5751" Read options from an ini file. See\n" 4772" Read options from an ini file. See\n"
@@ -5753,14 +4774,12 @@ msgid ""
5753" for usage and examples.\n" 4774" for usage and examples.\n"
5754msgstr "" 4775msgstr ""
5755 4776
5756#: plugins/utils.h:190
5757msgid "" 4777msgid ""
5758" See:\n" 4778" See:\n"
5759" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n" 4779" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n"
5760" for THRESHOLD format and examples.\n" 4780" for THRESHOLD format and examples.\n"
5761msgstr "" 4781msgstr ""
5762 4782
5763#: plugins/utils.h:195
5764msgid "" 4783msgid ""
5765"\n" 4784"\n"
5766"Send email to help@monitoring-plugins.org if you have questions regarding\n" 4785"Send email to help@monitoring-plugins.org if you have questions regarding\n"
@@ -5769,7 +4788,6 @@ msgid ""
5769"\n" 4788"\n"
5770msgstr "" 4789msgstr ""
5771 4790
5772#: plugins/utils.h:200
5773msgid "" 4791msgid ""
5774"\n" 4792"\n"
5775"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may " 4793"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may "
@@ -5778,410 +4796,332 @@ msgid ""
5778"For more information about these matters, see the file named COPYING.\n" 4796"For more information about these matters, see the file named COPYING.\n"
5779msgstr "" 4797msgstr ""
5780 4798
5781#: plugins-root/check_dhcp.c:320
5782#, c-format 4799#, c-format
5783msgid "Error: Could not get hardware address of interface '%s'\n" 4800msgid "Error: Could not get hardware address of interface '%s'\n"
5784msgstr "" 4801msgstr ""
5785 4802
5786#: plugins-root/check_dhcp.c:342
5787#, c-format 4803#, c-format
5788msgid "Error: if_nametoindex error - %s.\n" 4804msgid "Error: if_nametoindex error - %s.\n"
5789msgstr "" 4805msgstr ""
5790 4806
5791#: plugins-root/check_dhcp.c:347
5792#, c-format 4807#, c-format
5793msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n" 4808msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"
5794msgstr "" 4809msgstr ""
5795 4810
5796#: plugins-root/check_dhcp.c:352
5797#, c-format 4811#, c-format
5798msgid "" 4812msgid ""
5799"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n" 4813"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"
5800msgstr "" 4814msgstr ""
5801 4815
5802#: plugins-root/check_dhcp.c:357
5803#, c-format 4816#, c-format
5804msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n" 4817msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"
5805msgstr "" 4818msgstr ""
5806 4819
5807#: plugins-root/check_dhcp.c:388
5808#, c-format 4820#, c-format
5809msgid "" 4821msgid ""
5810"Error: can't find unit number in interface_name (%s) - expecting TypeNumber " 4822"Error: can't find unit number in interface_name (%s) - expecting TypeNumber "
5811"eg lnc0.\n" 4823"eg lnc0.\n"
5812msgstr "" 4824msgstr ""
5813 4825
5814#: plugins-root/check_dhcp.c:393 plugins-root/check_dhcp.c:405
5815#, c-format 4826#, c-format
5816msgid "" 4827msgid ""
5817"Error: can't read MAC address from DLPI streams interface for device %s unit " 4828"Error: can't read MAC address from DLPI streams interface for device %s unit "
5818"%d.\n" 4829"%d.\n"
5819msgstr "" 4830msgstr ""
5820 4831
5821#: plugins-root/check_dhcp.c:411
5822#, c-format 4832#, c-format
5823msgid "" 4833msgid ""
5824"Error: can't get MAC address for this architecture. Use the --mac option.\n" 4834"Error: can't get MAC address for this architecture. Use the --mac option.\n"
5825msgstr "" 4835msgstr ""
5826 4836
5827#: plugins-root/check_dhcp.c:430
5828#, c-format 4837#, c-format
5829msgid "Error: Cannot determine IP address of interface %s\n" 4838msgid "Error: Cannot determine IP address of interface %s\n"
5830msgstr "" 4839msgstr ""
5831 4840
5832#: plugins-root/check_dhcp.c:438
5833#, c-format 4841#, c-format
5834msgid "Error: Cannot get interface IP address on this platform.\n" 4842msgid "Error: Cannot get interface IP address on this platform.\n"
5835msgstr "" 4843msgstr ""
5836 4844
5837#: plugins-root/check_dhcp.c:443
5838#, c-format 4845#, c-format
5839msgid "Pretending to be relay client %s\n" 4846msgid "Pretending to be relay client %s\n"
5840msgstr "" 4847msgstr ""
5841 4848
5842#: plugins-root/check_dhcp.c:528
5843#, c-format 4849#, c-format
5844msgid "DHCPDISCOVER to %s port %d\n" 4850msgid "DHCPDISCOVER to %s port %d\n"
5845msgstr "" 4851msgstr ""
5846 4852
5847#: plugins-root/check_dhcp.c:580
5848#, c-format 4853#, c-format
5849msgid "Result=ERROR\n" 4854msgid "Result=ERROR\n"
5850msgstr "" 4855msgstr ""
5851 4856
5852#: plugins-root/check_dhcp.c:586
5853#, c-format 4857#, c-format
5854msgid "Result=OK\n" 4858msgid "Result=OK\n"
5855msgstr "" 4859msgstr ""
5856 4860
5857#: plugins-root/check_dhcp.c:596
5858#, c-format 4861#, c-format
5859msgid "DHCPOFFER from IP address %s" 4862msgid "DHCPOFFER from IP address %s"
5860msgstr "" 4863msgstr ""
5861 4864
5862#: plugins-root/check_dhcp.c:597
5863#, c-format 4865#, c-format
5864msgid " via %s\n" 4866msgid " via %s\n"
5865msgstr "" 4867msgstr ""
5866 4868
5867#: plugins-root/check_dhcp.c:604
5868#, c-format 4869#, c-format
5869msgid "" 4870msgid ""
5870"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n" 4871"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"
5871msgstr "" 4872msgstr ""
5872 4873
5873#: plugins-root/check_dhcp.c:626
5874#, c-format 4874#, c-format
5875msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n" 4875msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n"
5876msgstr "" 4876msgstr ""
5877 4877
5878#: plugins-root/check_dhcp.c:644
5879#, c-format 4878#, c-format
5880msgid "Total responses seen on the wire: %d\n" 4879msgid "Total responses seen on the wire: %d\n"
5881msgstr "" 4880msgstr ""
5882 4881
5883#: plugins-root/check_dhcp.c:645
5884#, fuzzy, c-format 4882#, fuzzy, c-format
5885msgid "Valid responses for this machine: %d\n" 4883msgid "Valid responses for this machine: %d\n"
5886msgstr "Keine Antwort vom Host \n" 4884msgstr "Keine Antwort vom Host \n"
5887 4885
5888#: plugins-root/check_dhcp.c:660
5889#, c-format 4886#, c-format
5890msgid "send_dhcp_packet result: %d\n" 4887msgid "send_dhcp_packet result: %d\n"
5891msgstr "" 4888msgstr ""
5892 4889
5893#: plugins-root/check_dhcp.c:693
5894#, fuzzy, c-format 4890#, fuzzy, c-format
5895msgid "No (more) data received (nfound: %d)\n" 4891msgid "No (more) data received (nfound: %d)\n"
5896msgstr "Keine Daten empfangen %s\n" 4892msgstr "Keine Daten empfangen %s\n"
5897 4893
5898#: plugins-root/check_dhcp.c:712
5899#, c-format 4894#, c-format
5900msgid "recvfrom() failed, " 4895msgid "recvfrom() failed, "
5901msgstr "" 4896msgstr ""
5902 4897
5903#: plugins-root/check_dhcp.c:719
5904#, c-format 4898#, c-format
5905msgid "receive_dhcp_packet() result: %d\n" 4899msgid "receive_dhcp_packet() result: %d\n"
5906msgstr "" 4900msgstr ""
5907 4901
5908#: plugins-root/check_dhcp.c:720
5909#, c-format 4902#, c-format
5910msgid "receive_dhcp_packet() source: %s\n" 4903msgid "receive_dhcp_packet() source: %s\n"
5911msgstr "" 4904msgstr ""
5912 4905
5913#: plugins-root/check_dhcp.c:750
5914#, c-format 4906#, c-format
5915msgid "Error: Could not create socket!\n" 4907msgid "Error: Could not create socket!\n"
5916msgstr "" 4908msgstr ""
5917 4909
5918#: plugins-root/check_dhcp.c:760
5919#, c-format 4910#, c-format
5920msgid "Error: Could not set reuse address option on DHCP socket!\n" 4911msgid "Error: Could not set reuse address option on DHCP socket!\n"
5921msgstr "" 4912msgstr ""
5922 4913
5923#: plugins-root/check_dhcp.c:766
5924#, c-format 4914#, c-format
5925msgid "Error: Could not set broadcast option on DHCP socket!\n" 4915msgid "Error: Could not set broadcast option on DHCP socket!\n"
5926msgstr "" 4916msgstr ""
5927 4917
5928#: plugins-root/check_dhcp.c:775
5929#, c-format 4918#, c-format
5930msgid "" 4919msgid ""
5931"Error: Could not bind socket to interface %s. Check your privileges...\n" 4920"Error: Could not bind socket to interface %s. Check your privileges...\n"
5932msgstr "" 4921msgstr ""
5933 4922
5934#: plugins-root/check_dhcp.c:786
5935#, c-format 4923#, c-format
5936msgid "" 4924msgid ""
5937"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n" 4925"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"
5938msgstr "" 4926msgstr ""
5939 4927
5940#: plugins-root/check_dhcp.c:820
5941#, c-format 4928#, c-format
5942msgid "Requested server address: %s\n" 4929msgid "Requested server address: %s\n"
5943msgstr "" 4930msgstr ""
5944 4931
5945#: plugins-root/check_dhcp.c:882
5946#, c-format 4932#, c-format
5947msgid "Lease Time: Infinite\n" 4933msgid "Lease Time: Infinite\n"
5948msgstr "" 4934msgstr ""
5949 4935
5950#: plugins-root/check_dhcp.c:884
5951#, c-format 4936#, c-format
5952msgid "Lease Time: %lu seconds\n" 4937msgid "Lease Time: %lu seconds\n"
5953msgstr "" 4938msgstr ""
5954 4939
5955#: plugins-root/check_dhcp.c:886
5956#, c-format 4940#, c-format
5957msgid "Renewal Time: Infinite\n" 4941msgid "Renewal Time: Infinite\n"
5958msgstr "" 4942msgstr ""
5959 4943
5960#: plugins-root/check_dhcp.c:888
5961#, c-format 4944#, c-format
5962msgid "Renewal Time: %lu seconds\n" 4945msgid "Renewal Time: %lu seconds\n"
5963msgstr "" 4946msgstr ""
5964 4947
5965#: plugins-root/check_dhcp.c:890
5966#, c-format 4948#, c-format
5967msgid "Rebinding Time: Infinite\n" 4949msgid "Rebinding Time: Infinite\n"
5968msgstr "" 4950msgstr ""
5969 4951
5970#: plugins-root/check_dhcp.c:891
5971#, c-format 4952#, c-format
5972msgid "Rebinding Time: %lu seconds\n" 4953msgid "Rebinding Time: %lu seconds\n"
5973msgstr "" 4954msgstr ""
5974 4955
5975#: plugins-root/check_dhcp.c:919
5976#, c-format 4956#, c-format
5977msgid "Added offer from server @ %s" 4957msgid "Added offer from server @ %s"
5978msgstr "" 4958msgstr ""
5979 4959
5980#: plugins-root/check_dhcp.c:920
5981#, c-format 4960#, c-format
5982msgid " of IP address %s\n" 4961msgid " of IP address %s\n"
5983msgstr "" 4962msgstr ""
5984 4963
5985#: plugins-root/check_dhcp.c:987
5986#, c-format 4964#, c-format
5987msgid "DHCP Server Match: Offerer=%s" 4965msgid "DHCP Server Match: Offerer=%s"
5988msgstr "" 4966msgstr ""
5989 4967
5990#: plugins-root/check_dhcp.c:988
5991#, c-format 4968#, c-format
5992msgid " Requested=%s" 4969msgid " Requested=%s"
5993msgstr "" 4970msgstr ""
5994 4971
5995#: plugins-root/check_dhcp.c:990
5996#, c-format 4972#, c-format
5997msgid " (duplicate)" 4973msgid " (duplicate)"
5998msgstr "" 4974msgstr ""
5999 4975
6000#: plugins-root/check_dhcp.c:991
6001#, c-format 4976#, c-format
6002msgid "\n" 4977msgid "\n"
6003msgstr "" 4978msgstr ""
6004 4979
6005#: plugins-root/check_dhcp.c:1039
6006#, c-format 4980#, c-format
6007msgid "No DHCPOFFERs were received.\n" 4981msgid "No DHCPOFFERs were received.\n"
6008msgstr "" 4982msgstr ""
6009 4983
6010#: plugins-root/check_dhcp.c:1043
6011#, c-format 4984#, c-format
6012msgid "Received %d DHCPOFFER(s)" 4985msgid "Received %d DHCPOFFER(s)"
6013msgstr "" 4986msgstr ""
6014 4987
6015#: plugins-root/check_dhcp.c:1046
6016#, c-format 4988#, c-format
6017msgid ", %s%d of %d requested servers responded" 4989msgid ", %s%d of %d requested servers responded"
6018msgstr "" 4990msgstr ""
6019 4991
6020#: plugins-root/check_dhcp.c:1049
6021#, c-format 4992#, c-format
6022msgid ", requested address (%s) was %soffered" 4993msgid ", requested address (%s) was %soffered"
6023msgstr "" 4994msgstr ""
6024 4995
6025#: plugins-root/check_dhcp.c:1049
6026msgid "not " 4996msgid "not "
6027msgstr "" 4997msgstr ""
6028 4998
6029#: plugins-root/check_dhcp.c:1051
6030#, c-format 4999#, c-format
6031msgid ", max lease time = " 5000msgid ", max lease time = "
6032msgstr "" 5001msgstr ""
6033 5002
6034#: plugins-root/check_dhcp.c:1053
6035#, c-format 5003#, c-format
6036msgid "Infinity" 5004msgid "Infinity"
6037msgstr "" 5005msgstr ""
6038 5006
6039#: plugins-root/check_dhcp.c:1234 5007msgid "Got unexpected non-option argument"
5008msgstr ""
5009
6040#, c-format 5010#, c-format
6041msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n" 5011msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"
6042msgstr "" 5012msgstr ""
6043 5013
6044#: plugins-root/check_dhcp.c:1246
6045#, c-format 5014#, c-format
6046msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n" 5015msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"
6047msgstr "" 5016msgstr ""
6048 5017
6049#: plugins-root/check_dhcp.c:1259
6050#, c-format 5018#, c-format
6051msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n" 5019msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"
6052msgstr "" 5020msgstr ""
6053 5021
6054#: plugins-root/check_dhcp.c:1271
6055#, c-format 5022#, c-format
6056msgid "" 5023msgid ""
6057"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n" 5024"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"
6058msgstr "" 5025msgstr ""
6059 5026
6060#: plugins-root/check_dhcp.c:1295
6061#, c-format 5027#, c-format
6062msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n" 5028msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"
6063msgstr "" 5029msgstr ""
6064 5030
6065#: plugins-root/check_dhcp.c:1374
6066#, c-format 5031#, c-format
6067msgid "Hardware address: " 5032msgid "Hardware address: "
6068msgstr "" 5033msgstr ""
6069 5034
6070#: plugins-root/check_dhcp.c:1390
6071msgid "This plugin tests the availability of DHCP servers on a network." 5035msgid "This plugin tests the availability of DHCP servers on a network."
6072msgstr "" 5036msgstr ""
6073 5037
6074#: plugins-root/check_dhcp.c:1402
6075msgid "IP address of DHCP server that we must hear from" 5038msgid "IP address of DHCP server that we must hear from"
6076msgstr "" 5039msgstr ""
6077 5040
6078#: plugins-root/check_dhcp.c:1404
6079msgid "IP address that should be offered by at least one DHCP server" 5041msgid "IP address that should be offered by at least one DHCP server"
6080msgstr "" 5042msgstr ""
6081 5043
6082#: plugins-root/check_dhcp.c:1406
6083msgid "Seconds to wait for DHCPOFFER before timeout occurs" 5044msgid "Seconds to wait for DHCPOFFER before timeout occurs"
6084msgstr "" 5045msgstr ""
6085 5046
6086#: plugins-root/check_dhcp.c:1408
6087msgid "Interface to to use for listening (i.e. eth0)" 5047msgid "Interface to to use for listening (i.e. eth0)"
6088msgstr "" 5048msgstr ""
6089 5049
6090#: plugins-root/check_dhcp.c:1410
6091msgid "MAC address to use in the DHCP request" 5050msgid "MAC address to use in the DHCP request"
6092msgstr "" 5051msgstr ""
6093 5052
6094#: plugins-root/check_dhcp.c:1412
6095msgid "Unicast testing: mimic a DHCP relay, requires -s" 5053msgid "Unicast testing: mimic a DHCP relay, requires -s"
6096msgstr "" 5054msgstr ""
6097 5055
6098#: plugins-root/check_icmp.c:1295
6099msgid "specify a target" 5056msgid "specify a target"
6100msgstr "" 5057msgstr ""
6101 5058
6102#: plugins-root/check_icmp.c:1297 5059msgid "Use IPv4 (default) or IPv6 to communicate with the targets"
5060msgstr ""
5061
6103#, fuzzy 5062#, fuzzy
6104msgid "warning threshold (currently " 5063msgid "warning threshold (currently "
6105msgstr "Warning threshold Integer sein" 5064msgstr "Warning threshold Integer sein"
6106 5065
6107#: plugins-root/check_icmp.c:1300
6108#, fuzzy 5066#, fuzzy
6109msgid "critical threshold (currently " 5067msgid "critical threshold (currently "
6110msgstr "Critical threshold muss ein Integer sein" 5068msgstr "Critical threshold muss ein Integer sein"
6111 5069
6112#: plugins-root/check_icmp.c:1303
6113#, fuzzy 5070#, fuzzy
6114msgid "specify a source IP address or device name" 5071msgid "specify a source IP address or device name"
6115msgstr "Hostname oder Serveradresse muss angegeben werden" 5072msgstr "Hostname oder Serveradresse muss angegeben werden"
6116 5073
6117#: plugins-root/check_icmp.c:1305
6118msgid "number of packets to send (currently " 5074msgid "number of packets to send (currently "
6119msgstr "" 5075msgstr ""
6120 5076
6121#: plugins-root/check_icmp.c:1308
6122msgid "max packet interval (currently " 5077msgid "max packet interval (currently "
6123msgstr "" 5078msgstr ""
6124 5079
6125#: plugins-root/check_icmp.c:1311
6126msgid "max target interval (currently " 5080msgid "max target interval (currently "
6127msgstr "" 5081msgstr ""
6128 5082
6129#: plugins-root/check_icmp.c:1314
6130msgid "number of alive hosts required for success" 5083msgid "number of alive hosts required for success"
6131msgstr "" 5084msgstr ""
6132 5085
6133#: plugins-root/check_icmp.c:1317
6134msgid "TTL on outgoing packets (currently " 5086msgid "TTL on outgoing packets (currently "
6135msgstr "" 5087msgstr ""
6136 5088
6137#: plugins-root/check_icmp.c:1320
6138msgid "timeout value (seconds, currently " 5089msgid "timeout value (seconds, currently "
6139msgstr "" 5090msgstr ""
6140 5091
6141#: plugins-root/check_icmp.c:1323
6142msgid "Number of icmp data bytes to send" 5092msgid "Number of icmp data bytes to send"
6143msgstr "" 5093msgstr ""
6144 5094
6145#: plugins-root/check_icmp.c:1324
6146msgid "Packet size will be data bytes + icmp header (currently" 5095msgid "Packet size will be data bytes + icmp header (currently"
6147msgstr "" 5096msgstr ""
6148 5097
6149#: plugins-root/check_icmp.c:1326
6150msgid "verbose" 5098msgid "verbose"
6151msgstr "" 5099msgstr ""
6152 5100
6153#: plugins-root/check_icmp.c:1330
6154msgid "The -H switch is optional. Naming a host (or several) to check is not." 5101msgid "The -H switch is optional. Naming a host (or several) to check is not."
6155msgstr "" 5102msgstr ""
6156 5103
6157#: plugins-root/check_icmp.c:1332
6158msgid "" 5104msgid ""
6159"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%" 5105"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"
6160msgstr "" 5106msgstr ""
6161 5107
6162#: plugins-root/check_icmp.c:1333
6163msgid "packet loss. The default values should work well for most users." 5108msgid "packet loss. The default values should work well for most users."
6164msgstr "" 5109msgstr ""
6165 5110
6166#: plugins-root/check_icmp.c:1334
6167msgid "" 5111msgid ""
6168"You can specify different RTA factors using the standardized abbreviations" 5112"You can specify different RTA factors using the standardized abbreviations"
6169msgstr "" 5113msgstr ""
6170 5114
6171#: plugins-root/check_icmp.c:1335
6172msgid "" 5115msgid ""
6173"us (microseconds), ms (milliseconds, default) or just plain s for seconds." 5116"us (microseconds), ms (milliseconds, default) or just plain s for seconds."
6174msgstr "" 5117msgstr ""
6175 5118
6176#: plugins-root/check_icmp.c:1341
6177msgid "The -v switch can be specified several times for increased verbosity." 5119msgid "The -v switch can be specified several times for increased verbosity."
6178msgstr "" 5120msgstr ""
6179 5121
6180#~ msgid "Critical threshold must be integer" 5122#, fuzzy, c-format
6181#~ msgstr "Critical threshold muss ein Integer sein" 5123#~ msgid "%s - Plugin timed out after %d seconds\n"
6182 5124#~ msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
6183#~ msgid "Warning threshold must be integer"
6184#~ msgstr "Warning threshold Integer sein"
6185 5125
6186#, fuzzy 5126#, fuzzy
6187#~ msgid "Critical Process Count must be an integer!" 5127#~ msgid "Critical Process Count must be an integer!"
@@ -6199,10 +5139,10 @@ msgstr ""
6199#~ msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n" 5139#~ msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n"
6200 5140
6201#~ msgid "Invalid HTTP response received from host\n" 5141#~ msgid "Invalid HTTP response received from host\n"
6202#~ msgstr "Ungültige HTTP Antwort von Host empfangen\n" 5142#~ msgstr "Ungültige HTTP Antwort von Host empfangen\n"
6203 5143
6204#~ msgid "Invalid HTTP response received from host on port %d\n" 5144#~ msgid "Invalid HTTP response received from host on port %d\n"
6205#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 5145#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
6206 5146
6207#~ msgid "HTTP CRITICAL: %s\n" 5147#~ msgid "HTTP CRITICAL: %s\n"
6208#~ msgstr "HTTP CRITICAL: %s\n" 5148#~ msgstr "HTTP CRITICAL: %s\n"
@@ -6230,20 +5170,12 @@ msgstr ""
6230#~ msgstr "HTTP CRITICAL - Text nicht gefunden%s|%s %s\n" 5170#~ msgstr "HTTP CRITICAL - Text nicht gefunden%s|%s %s\n"
6231 5171
6232#, fuzzy 5172#, fuzzy
6233#~ msgid "HTTP OK %s - %d bytes in %.3f seconds %s|%s %s\n"
6234#~ msgstr "HTTP OK %s - %.3f Sekunde Antwortzeit %s%s|%s %s\n"
6235
6236#, fuzzy
6237#~ msgid "HTTP UNKNOWN - could not allocate url\n" 5173#~ msgid "HTTP UNKNOWN - could not allocate url\n"
6238#~ msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n" 5174#~ msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
6239
6240#, fuzzy
6241#~ msgid "HTTP UNKNOWN - Could not allocate server_url%s\n"
6242#~ msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
6243 5175
6244#, fuzzy 5176#, fuzzy
6245#~ msgid "snmpget returned an error status" 5177#~ msgid "snmpget returned an error status"
6246#~ msgstr "dig hat einen Fehler zurückgegeben" 5178#~ msgstr "dig hat einen Fehler zurückgegeben"
6247 5179
6248#, fuzzy 5180#, fuzzy
6249#~ msgid "Invalid critical threshold" 5181#~ msgid "Invalid critical threshold"
@@ -6287,7 +5219,7 @@ msgstr ""
6287#~ " ssh anweisen Protokoll 2 zu verwenden\n" 5219#~ " ssh anweisen Protokoll 2 zu verwenden\n"
6288#~ " -S, --skiplines=n\n" 5220#~ " -S, --skiplines=n\n"
6289#~ " Ignoriere die ersten n Zeilen auf STDERR (um Logon Banner zu " 5221#~ " Ignoriere die ersten n Zeilen auf STDERR (um Logon Banner zu "
6290#~ "unterdrücken)\n" 5222#~ "unterdrücken)\n"
6291#~ " -f\n" 5223#~ " -f\n"
6292#~ " ssh anweisen fork zu nutzen statt ein tty zu erzeugen\n" 5224#~ " ssh anweisen fork zu nutzen statt ein tty zu erzeugen\n"
6293 5225
@@ -6306,13 +5238,13 @@ msgstr ""
6306#~ " short name of host in nagios configuration [optional]\n" 5238#~ " short name of host in nagios configuration [optional]\n"
6307#~ msgstr "" 5239#~ msgstr ""
6308#~ " -C, --command='COMMAND STRING'\n" 5240#~ " -C, --command='COMMAND STRING'\n"
6309#~ " Befehl der auf der entfernten Maschine ausgeführt werden soll\n" 5241#~ " Befehl der auf der entfernten Maschine ausgeführt werden soll\n"
6310#~ " -l, --logname=USERNAME\n" 5242#~ " -l, --logname=USERNAME\n"
6311#~ " SSH user name auf dem entfernten Host [optional]\n" 5243#~ " SSH user name auf dem entfernten Host [optional]\n"
6312#~ " -i, --identity=KEYFILE\n" 5244#~ " -i, --identity=KEYFILE\n"
6313#~ " zu verwendende Schlüsseldatei [optional]\n" 5245#~ " zu verwendende Schlüsseldatei [optional]\n"
6314#~ " -O, --output=FILE\n" 5246#~ " -O, --output=FILE\n"
6315#~ " externe Befehlsdatei für nagios [optional]\n" 5247#~ " externe Befehlsdatei für nagios [optional]\n"
6316#~ " -s, --services=LIST\n" 5248#~ " -s, --services=LIST\n"
6317#~ " Liste von nagios Servicenamen, getrennt durch ':' [optional]\n" 5249#~ " Liste von nagios Servicenamen, getrennt durch ':' [optional]\n"
6318#~ " -n, --name=NAME\n" 5250#~ " -n, --name=NAME\n"
@@ -6349,15 +5281,15 @@ msgstr ""
6349#~ "greater than zero" 5281#~ "greater than zero"
6350#~ msgstr "" 5282#~ msgstr ""
6351#~ "INPUT ERROR: C_DF (%lu) sollte kleiner sein als W_DF (%lu) und beide " 5283#~ "INPUT ERROR: C_DF (%lu) sollte kleiner sein als W_DF (%lu) und beide "
6352#~ "sollten größer als 0 sein" 5284#~ "sollten größer als 0 sein"
6353 5285
6354#, fuzzy 5286#, fuzzy
6355#~ msgid "No response from host on port %d\n" 5287#~ msgid "No response from host on port %d\n"
6356#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 5288#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
6357 5289
6358#, fuzzy 5290#, fuzzy
6359#~ msgid "Invalid response received from host on port %d\n" 5291#~ msgid "Invalid response received from host on port %d\n"
6360#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 5292#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
6361 5293
6362#~ msgid "%.3f seconds response time (%s)" 5294#~ msgid "%.3f seconds response time (%s)"
6363#~ msgstr "%.3f Sekunden Antwortzeit (%s)" 5295#~ msgstr "%.3f Sekunden Antwortzeit (%s)"
@@ -6372,7 +5304,7 @@ msgstr ""
6372#~ " Exit with CRITICAL status if less than INTEGER --units of disk are " 5304#~ " Exit with CRITICAL status if less than INTEGER --units of disk are "
6373#~ "free\n" 5305#~ "free\n"
6374#~ " -c, --critical=PERCENT%%\n" 5306#~ " -c, --critical=PERCENT%%\n"
6375#~ " Exit with CRITCAL status if less than PERCENT of disk space is free\n" 5307#~ " Exit with CRITICAL status if less than PERCENT of disk space is free\n"
6376#~ " -C, --clear\n" 5308#~ " -C, --clear\n"
6377#~ " Clear thresholds\n" 5309#~ " Clear thresholds\n"
6378#~ msgstr "" 5310#~ msgstr ""
@@ -6385,7 +5317,7 @@ msgstr ""
6385#~ " -c, --critical=PERCENT%%\n" 5317#~ " -c, --critical=PERCENT%%\n"
6386#~ " meldet Status CRITICAL, wenn weniger als PERCENT --Plattenplatz frei\n" 5318#~ " meldet Status CRITICAL, wenn weniger als PERCENT --Plattenplatz frei\n"
6387#~ " -C, --clear\n" 5319#~ " -C, --clear\n"
6388#~ " Schwellwerte löschen\n" 5320#~ " Schwellwerte löschen\n"
6389 5321
6390#~ msgid "" 5322#~ msgid ""
6391#~ "Examples:\n" 5323#~ "Examples:\n"
@@ -6394,7 +5326,7 @@ msgstr ""
6394#~ msgstr "" 5326#~ msgstr ""
6395#~ "Beispiel:\n" 5327#~ "Beispiel:\n"
6396#~ " check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n" 5328#~ " check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n"
6397#~ " Prüft /tmp und /var mit 10%,5% und / mit 100MB, 50MB\n" 5329#~ " Prüft /tmp und /var mit 10%,5% und / mit 100MB, 50MB\n"
6398 5330
6399#~ msgid "" 5331#~ msgid ""
6400#~ "This plugin uses the nslookup program to obtain the IP address\n" 5332#~ "This plugin uses the nslookup program to obtain the IP address\n"
@@ -6413,10 +5345,7 @@ msgstr ""
6413#~ msgstr "HTTP CRITICAL - Konnte keine SSL Verbindung herstellen\n" 5345#~ msgstr "HTTP CRITICAL - Konnte keine SSL Verbindung herstellen\n"
6414 5346
6415#~ msgid "Client Certificate Required\n" 5347#~ msgid "Client Certificate Required\n"
6416#~ msgstr "Clientzertifikat benötigt\n" 5348#~ msgstr "Clientzertifikat benötigt\n"
6417
6418#~ msgid "Failed"
6419#~ msgstr "Fehlgeschlagen"
6420 5349
6421#~ msgid "CRITICAL - Cannot create SSL context.\n" 5350#~ msgid "CRITICAL - Cannot create SSL context.\n"
6422#~ msgstr "CRITICAL - Konnte SSL Kontext nicht erzeugen.\n" 5351#~ msgstr "CRITICAL - Konnte SSL Kontext nicht erzeugen.\n"
@@ -6426,7 +5355,7 @@ msgstr ""
6426 5355
6427#, fuzzy 5356#, fuzzy
6428#~ msgid "Failed to allocate memory for hostname" 5357#~ msgid "Failed to allocate memory for hostname"
6429#~ msgstr "konnte keinen Speicher für '%s' reservieren\n" 5358#~ msgstr "konnte keinen Speicher für '%s' reservieren\n"
6430 5359
6431#, fuzzy 5360#, fuzzy
6432#~ msgid "CRITICAL - %d of %d hosts are alive\n" 5361#~ msgid "CRITICAL - %d of %d hosts are alive\n"
@@ -6434,7 +5363,7 @@ msgstr ""
6434 5363
6435#, fuzzy 5364#, fuzzy
6436#~ msgid "%s has no address data\n" 5365#~ msgid "%s has no address data\n"
6437#~ msgstr "Nameserver %s hat keine Datensätze\n" 5366#~ msgstr "Nameserver %s hat keine Datensätze\n"
6438 5367
6439#, fuzzy 5368#, fuzzy
6440#~ msgid "CRITICAL - Could not make SSL connection\n" 5369#~ msgid "CRITICAL - Could not make SSL connection\n"
@@ -6446,7 +5375,7 @@ msgstr ""
6446 5375
6447#, fuzzy 5376#, fuzzy
6448#~ msgid "Certificate expires today (%s).\n" 5377#~ msgid "Certificate expires today (%s).\n"
6449#~ msgstr "Clientzertifikat benötigt\n" 5378#~ msgstr "Clientzertifikat benötigt\n"
6450 5379
6451#, fuzzy 5380#, fuzzy
6452#~ msgid "ERROR: Cannot create SSL context.\n" 5381#~ msgid "ERROR: Cannot create SSL context.\n"
@@ -6474,7 +5403,7 @@ msgstr ""
6474#~ msgstr "Time interval muss ein positiver Integer sein" 5403#~ msgstr "Time interval muss ein positiver Integer sein"
6475 5404
6476#~ msgid "check_http: invalid option - SSL is not available\n" 5405#~ msgid "check_http: invalid option - SSL is not available\n"
6477#~ msgstr "check_http: ungültige Option - SSL ist nicht verfügbar\n" 5406#~ msgstr "check_http: ungültige Option - SSL ist nicht verfügbar\n"
6478 5407
6479#~ msgid "invalid hostname/address" 5408#~ msgid "invalid hostname/address"
6480#~ msgstr "Ungültige(r) Hostname/Adresse" 5409#~ msgstr "Ungültige(r) Hostname/Adresse"
diff --git a/po/fr.po b/po/fr.po
index d88dfe2e..28deb947 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -1,6 +1,6 @@
1# translation of fr.po to 1# translation of fr.po to
2# Messages français pour Nagios Plugins 2# Messages français pour Nagios Plugins
3# Copyright (C) 2003-2004 Nagios Plugin Development Group 3# Copyright (C) 2003-2023 Nagios Plugin Development Group
4# This file is distributed under the same license as the nagiosplug package. 4# This file is distributed under the same license as the nagiosplug package.
5# 5#
6# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003. 6# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003.
@@ -8,112 +8,78 @@
8# Thomas Guyot-Sionnest <dermoth@aei.ca>, 2007. 8# Thomas Guyot-Sionnest <dermoth@aei.ca>, 2007.
9msgid "" 9msgid ""
10msgstr "" 10msgstr ""
11"Project-Id-Version: fr\n" 11"Project-Id-Version: PACKAGE VERSION\n"
12"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 12"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
13"POT-Creation-Date: 2014-01-19 16:30-0500\n" 13"POT-Creation-Date: 2023-09-22 15:36+0200\n"
14"PO-Revision-Date: 2010-04-21 23:38-0400\n" 14"PO-Revision-Date: 2010-04-21 23:38-0400\n"
15"Last-Translator: Thomas Guyot-Sionnest <dermoth@aei.ca>\n" 15"Last-Translator: \n"
16"Language-Team: Nagios Plugin Development Mailing List <nagiosplug-" 16"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins."
17"devel@monitoring-plugins.org>\n" 17"org>\n"
18"Language: \n" 18"Language: fr\n"
19"MIME-Version: 1.0\n" 19"MIME-Version: 1.0\n"
20"Content-Type: text/plain; charset=UTF-8\n" 20"Content-Type: text/plain; charset=UTF-8\n"
21"Content-Transfer-Encoding: 8bit\n" 21"Content-Transfer-Encoding: 8bit\n"
22"Plural-Forms: nplurals=2; plural=(n != 1);\n" 22"Plural-Forms: nplurals=2; plural=(n != 1);\n"
23"X-Generator: KBabel 1.11.4\n" 23"X-Generator: KBabel 1.11.4\n"
24 24
25#: plugins/check_by_ssh.c:86 plugins/check_cluster.c:76 plugins/check_dig.c:88
26#: plugins/check_disk.c:194 plugins/check_dns.c:102 plugins/check_dummy.c:52
27#: plugins/check_fping.c:93 plugins/check_game.c:82 plugins/check_hpjd.c:103
28#: plugins/check_http.c:167 plugins/check_ldap.c:109 plugins/check_load.c:122
29#: plugins/check_mrtgtraf.c:83 plugins/check_mysql.c:122
30#: plugins/check_nagios.c:91 plugins/check_nt.c:127 plugins/check_ntp.c:770
31#: plugins/check_ntp_peer.c:575 plugins/check_ntp_time.c:552
32#: plugins/check_nwstat.c:173 plugins/check_overcr.c:102
33#: plugins/check_pgsql.c:172 plugins/check_ping.c:95 plugins/check_procs.c:172
34#: plugins/check_radius.c:160 plugins/check_real.c:80 plugins/check_smtp.c:144
35#: plugins/check_snmp.c:240 plugins/check_ssh.c:73 plugins/check_swap.c:110
36#: plugins/check_tcp.c:218 plugins/check_time.c:78 plugins/check_ups.c:122
37#: plugins/check_users.c:77 plugins/negate.c:214 plugins-root/check_dhcp.c:270
38msgid "Could not parse arguments" 25msgid "Could not parse arguments"
39msgstr "Impossible de décomposer les arguments" 26msgstr "Impossible de décomposer les arguments"
40 27
41#: plugins/check_by_ssh.c:90 plugins/check_dig.c:82 plugins/check_dns.c:95
42#: plugins/check_nagios.c:95 plugins/check_pgsql.c:178 plugins/check_ping.c:99
43#: plugins/check_procs.c:188 plugins/check_snmp.c:336 plugins/negate.c:79
44msgid "Cannot catch SIGALRM" 28msgid "Cannot catch SIGALRM"
45msgstr "Impossible d'obtenir le signal SIGALRM" 29msgstr "Impossible d'obtenir le signal SIGALRM"
46 30
47#: plugins/check_by_ssh.c:110 31#, fuzzy, c-format
32msgid "SSH connection failed: %s\n"
33msgstr "L'exécution de la commande à distance %s à échoué\n"
34
48#, c-format 35#, c-format
49msgid "Remote command execution failed: %s\n" 36msgid "Remote command execution failed: %s\n"
50msgstr "L'exécution de la commande à distance %s à échoué\n" 37msgstr "L'exécution de la commande à distance %s à échoué\n"
51 38
52#: plugins/check_by_ssh.c:122
53#, c-format 39#, c-format
54msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n" 40msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n"
55msgstr "" 41msgstr ""
56 42
57#: plugins/check_by_ssh.c:134
58#, c-format 43#, c-format
59msgid "SSH WARNING: could not open %s\n" 44msgid "SSH WARNING: could not open %s\n"
60msgstr "SSH AVERTISSEMENT: impossible d'ouvrir %s\n" 45msgstr "SSH AVERTISSEMENT: impossible d'ouvrir %s\n"
61 46
62#: plugins/check_by_ssh.c:143
63#, c-format 47#, c-format
64msgid "%s: Error parsing output\n" 48msgid "%s: Error parsing output\n"
65msgstr "%s: Erreur d'analyse du résultat\n" 49msgstr "%s: Erreur d'analyse du résultat\n"
66 50
67#: plugins/check_by_ssh.c:220 plugins/check_disk.c:476
68#: plugins/check_http.c:278 plugins/check_ldap.c:293 plugins/check_pgsql.c:311
69#: plugins/check_procs.c:437 plugins/check_radius.c:308
70#: plugins/check_real.c:356 plugins/check_smtp.c:581 plugins/check_snmp.c:736
71#: plugins/check_ssh.c:138 plugins/check_tcp.c:505 plugins/check_time.c:302
72#: plugins/check_ups.c:556 plugins/negate.c:164
73msgid "Timeout interval must be a positive integer" 51msgid "Timeout interval must be a positive integer"
74msgstr "Le délai d'attente doit être un entier positif" 52msgstr "Le délai d'attente doit être un entier positif"
75 53
76#: plugins/check_by_ssh.c:230 plugins/check_pgsql.c:341
77#: plugins/check_radius.c:272 plugins/check_real.c:327
78#: plugins/check_smtp.c:506 plugins/check_tcp.c:511 plugins/check_time.c:296
79#: plugins/check_ups.c:518
80msgid "Port must be a positive integer" 54msgid "Port must be a positive integer"
81msgstr "Le numéro du port doit être un entier positif" 55msgstr "Le numéro du port doit être un entier positif"
82 56
83#: plugins/check_by_ssh.c:291
84msgid "skip-stdout argument must be an integer" 57msgid "skip-stdout argument must be an integer"
85msgstr "Le nombres de lignes à sauter (skip-stdout) doit être un entier" 58msgstr "Le nombres de lignes à sauter (skip-stdout) doit être un entier"
86 59
87#: plugins/check_by_ssh.c:299
88msgid "skip-stderr argument must be an integer" 60msgid "skip-stderr argument must be an integer"
89msgstr "Le nombres de lignes à sauter (skip-stderr) doit être un entier" 61msgstr "Le nombres de lignes à sauter (skip-stderr) doit être un entier"
90 62
91#: plugins/check_by_ssh.c:322
92#, c-format 63#, c-format
93msgid "%s: You must provide a host name\n" 64msgid "%s: You must provide a host name\n"
94msgstr "%s: Vous devez fournir un nom d'hôte\n" 65msgstr "%s: Vous devez fournir un nom d'hôte\n"
95 66
96#: plugins/check_by_ssh.c:340
97msgid "No remotecmd" 67msgid "No remotecmd"
98msgstr "Pas de commande distante" 68msgstr "Pas de commande distante"
99 69
100#: plugins/check_by_ssh.c:354
101#, c-format 70#, c-format
102msgid "%s: Argument limit of %d exceeded\n" 71msgid "%s: Argument limit of %d exceeded\n"
103msgstr "" 72msgstr ""
104 73
105#: plugins/check_by_ssh.c:357
106msgid "Can not (re)allocate 'commargv' buffer\n" 74msgid "Can not (re)allocate 'commargv' buffer\n"
107msgstr "Impossible de réallouer le tampon 'commargv'\n" 75msgstr "Impossible de réallouer le tampon 'commargv'\n"
108 76
109#: plugins/check_by_ssh.c:371
110#, c-format 77#, c-format
111msgid "" 78msgid ""
112"%s: In passive mode, you must provide a service name for each command.\n" 79"%s: In passive mode, you must provide a service name for each command.\n"
113msgstr "" 80msgstr ""
114"%s: En mode passif, vous devez fournir un service pour chaque commande.\n" 81"%s: En mode passif, vous devez fournir un service pour chaque commande.\n"
115 82
116#: plugins/check_by_ssh.c:374
117#, fuzzy, c-format 83#, fuzzy, c-format
118msgid "" 84msgid ""
119"%s: In passive mode, you must provide the host short name from the " 85"%s: In passive mode, you must provide the host short name from the "
@@ -122,471 +88,355 @@ msgstr ""
122"%s: En mode passif, vous devez fournir le nom court du hôte mentionné dans " 88"%s: En mode passif, vous devez fournir le nom court du hôte mentionné dans "
123"la configuration de nagios.\n" 89"la configuration de nagios.\n"
124 90
125#: plugins/check_by_ssh.c:388
126#, c-format 91#, c-format
127msgid "This plugin uses SSH to execute commands on a remote host" 92msgid "This plugin uses SSH to execute commands on a remote host"
128msgstr "Ce plugin utilise SSH pour exécuter des commandes sur un hôte distant" 93msgstr "Ce plugin utilise SSH pour exécuter des commandes sur un hôte distant"
129 94
130#: plugins/check_by_ssh.c:403
131msgid "tell ssh to use Protocol 1 [optional]" 95msgid "tell ssh to use Protocol 1 [optional]"
132msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]" 96msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]"
133 97
134#: plugins/check_by_ssh.c:405
135msgid "tell ssh to use Protocol 2 [optional]" 98msgid "tell ssh to use Protocol 2 [optional]"
136msgstr "dire à ssh d'utiliser le protocole 2 [optionnel]" 99msgstr "dire à ssh d'utiliser le protocole 2 [optionnel]"
137 100
138#: plugins/check_by_ssh.c:407
139msgid "Ignore all or (if specified) first n lines on STDOUT [optional]" 101msgid "Ignore all or (if specified) first n lines on STDOUT [optional]"
140msgstr "" 102msgstr ""
141 103
142#: plugins/check_by_ssh.c:409
143msgid "Ignore all or (if specified) first n lines on STDERR [optional]" 104msgid "Ignore all or (if specified) first n lines on STDERR [optional]"
144msgstr "" 105msgstr ""
145 106
146#: plugins/check_by_ssh.c:411 107msgid "Exit with an warning, if there is an output on STDERR"
108msgstr ""
109
147msgid "" 110msgid ""
148"tells ssh to fork rather than create a tty [optional]. This will always " 111"tells ssh to fork rather than create a tty [optional]. This will always "
149"return OK if ssh is executed" 112"return OK if ssh is executed"
150msgstr "" 113msgstr ""
151 114
152#: plugins/check_by_ssh.c:413
153msgid "command to execute on the remote machine" 115msgid "command to execute on the remote machine"
154msgstr "commande à exécuter sur la machine distante" 116msgstr "commande à exécuter sur la machine distante"
155 117
156#: plugins/check_by_ssh.c:415
157msgid "SSH user name on remote host [optional]" 118msgid "SSH user name on remote host [optional]"
158msgstr "Nom d'utilisateur ssh sur la machine distante [optionnel]" 119msgstr "Nom d'utilisateur ssh sur la machine distante [optionnel]"
159 120
160#: plugins/check_by_ssh.c:417
161msgid "identity of an authorized key [optional]" 121msgid "identity of an authorized key [optional]"
162msgstr "Identité de la clé autorisée [optionnel]" 122msgstr "Identité de la clé autorisée [optionnel]"
163 123
164#: plugins/check_by_ssh.c:419
165#, fuzzy 124#, fuzzy
166msgid "external command file for monitoring [optional]" 125msgid "external command file for monitoring [optional]"
167msgstr "commande externe pour nagios [optionnel]" 126msgstr "commande externe pour nagios [optionnel]"
168 127
169#: plugins/check_by_ssh.c:421
170#, fuzzy 128#, fuzzy
171msgid "list of monitoring service names, separated by ':' [optional]" 129msgid "list of monitoring service names, separated by ':' [optional]"
172msgstr "liste des services nagios, séparés par ':' [optionnel] " 130msgstr "liste des services nagios, séparés par ':' [optionnel] "
173 131
174#: plugins/check_by_ssh.c:423
175#, fuzzy 132#, fuzzy
176msgid "short name of host in the monitoring configuration [optional]" 133msgid "short name of host in the monitoring configuration [optional]"
177msgstr "nom court de l'hôte dans la configuration nagios [optionnel]" 134msgstr "nom court de l'hôte dans la configuration nagios [optionnel]"
178 135
179#: plugins/check_by_ssh.c:425
180msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]" 136msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]"
181msgstr "" 137msgstr ""
182"appelle ssh avec '-o OPTION' (peut être utilisé plusieurs fois) [optionnel]" 138"appelle ssh avec '-o OPTION' (peut être utilisé plusieurs fois) [optionnel]"
183 139
184#: plugins/check_by_ssh.c:427
185#, fuzzy 140#, fuzzy
186msgid "Tell ssh to use this configfile [optional]" 141msgid "Tell ssh to use this configfile [optional]"
187msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]" 142msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]"
188 143
189#: plugins/check_by_ssh.c:429
190msgid "Tell ssh to suppress warning and diagnostic messages [optional]" 144msgid "Tell ssh to suppress warning and diagnostic messages [optional]"
191msgstr "" 145msgstr ""
192"dire à ssh de supprimer les messages d'erreurs et de diagnostic [optionnel]" 146"dire à ssh de supprimer les messages d'erreurs et de diagnostic [optionnel]"
193 147
194#: plugins/check_by_ssh.c:434 148msgid "Make connection problems return UNKNOWN instead of CRITICAL"
149msgstr ""
150
195msgid "The most common mode of use is to refer to a local identity file with" 151msgid "The most common mode of use is to refer to a local identity file with"
196msgstr "" 152msgstr ""
197 153
198#: plugins/check_by_ssh.c:435
199msgid "the '-i' option. In this mode, the identity pair should have a null" 154msgid "the '-i' option. In this mode, the identity pair should have a null"
200msgstr "" 155msgstr ""
201 156
202#: plugins/check_by_ssh.c:436
203msgid "passphrase and the public key should be listed in the authorized_keys" 157msgid "passphrase and the public key should be listed in the authorized_keys"
204msgstr "" 158msgstr ""
205 159
206#: plugins/check_by_ssh.c:437
207msgid "file of the remote host. Usually the key will be restricted to running" 160msgid "file of the remote host. Usually the key will be restricted to running"
208msgstr "" 161msgstr ""
209 162
210#: plugins/check_by_ssh.c:438
211msgid "only one command on the remote server. If the remote SSH server tracks" 163msgid "only one command on the remote server. If the remote SSH server tracks"
212msgstr "" 164msgstr ""
213 165
214#: plugins/check_by_ssh.c:439
215msgid "invocation arguments, the one remote program may be an agent that can" 166msgid "invocation arguments, the one remote program may be an agent that can"
216msgstr "" 167msgstr ""
217 168
218#: plugins/check_by_ssh.c:440
219msgid "execute additional commands as proxy" 169msgid "execute additional commands as proxy"
220msgstr "" 170msgstr ""
221 171
222#: plugins/check_by_ssh.c:442
223msgid "To use passive mode, provide multiple '-C' options, and provide" 172msgid "To use passive mode, provide multiple '-C' options, and provide"
224msgstr "Pour utiliser le mode passif, utilisez plusieurs fois l'option '-C',et" 173msgstr "Pour utiliser le mode passif, utilisez plusieurs fois l'option '-C',et"
225 174
226#: plugins/check_by_ssh.c:443
227msgid "" 175msgid ""
228"all of -O, -s, and -n options (servicelist order must match '-C'options)" 176"all of -O, -s, and -n options (servicelist order must match '-C'options)"
229msgstr "" 177msgstr ""
230"et les options -O, -s, n (l'ordre des services doit correspondre aux " 178"et les options -O, -s, n (l'ordre des services doit correspondre aux "
231"multiples options '-C)" 179"multiples options '-C)"
232 180
233#: plugins/check_by_ssh.c:445 plugins/check_cluster.c:261
234#: plugins/check_dig.c:355 plugins/check_disk.c:924 plugins/check_http.c:1560
235#: plugins/check_nagios.c:312 plugins/check_ntp.c:869
236#: plugins/check_ntp_peer.c:705 plugins/check_ntp_time.c:633
237#: plugins/check_procs.c:763 plugins/negate.c:271 plugins/urlize.c:180
238msgid "Examples:" 181msgid "Examples:"
239msgstr "Exemples:" 182msgstr "Exemples:"
240 183
241#: plugins/check_by_ssh.c:460 plugins/check_cluster.c:274
242#: plugins/check_dig.c:367 plugins/check_disk.c:941 plugins/check_dns.c:486
243#: plugins/check_dummy.c:122 plugins/check_fping.c:505
244#: plugins/check_game.c:331 plugins/check_hpjd.c:414 plugins/check_http.c:1590
245#: plugins/check_ldap.c:451 plugins/check_load.c:334 plugins/check_mrtg.c:382
246#: plugins/check_mysql.c:569 plugins/check_nagios.c:323 plugins/check_nt.c:774
247#: plugins/check_ntp.c:888 plugins/check_ntp_peer.c:725
248#: plugins/check_ntp_time.c:642 plugins/check_nwstat.c:1685
249#: plugins/check_overcr.c:467 plugins/check_pgsql.c:578
250#: plugins/check_ping.c:603 plugins/check_procs.c:781
251#: plugins/check_radius.c:385 plugins/check_real.c:451
252#: plugins/check_smtp.c:843 plugins/check_snmp.c:1207 plugins/check_ssh.c:309
253#: plugins/check_swap.c:558 plugins/check_tcp.c:684 plugins/check_time.c:371
254#: plugins/check_ups.c:660 plugins/check_users.c:240
255#: plugins/check_ide_smart.c:640 plugins/negate.c:295 plugins/urlize.c:197
256#: plugins-root/check_dhcp.c:1422 plugins-root/check_icmp.c:1354
257msgid "Usage:" 184msgid "Usage:"
258msgstr "Utilisation:" 185msgstr "Utilisation:"
259 186
260#: plugins/check_cluster.c:230
261#, fuzzy, c-format 187#, fuzzy, c-format
262msgid "Host/Service Cluster Plugin for Monitoring" 188msgid "Host/Service Cluster Plugin for Monitoring"
263msgstr "Plugin de Cluster d'Hôte/Service pour Nagios 2" 189msgstr "Plugin de Cluster d'Hôte/Service pour Nagios 2"
264 190
265#: plugins/check_cluster.c:236 plugins/check_nt.c:676
266msgid "Options:" 191msgid "Options:"
267msgstr "Options:" 192msgstr "Options:"
268 193
269#: plugins/check_cluster.c:239
270msgid "Check service cluster status" 194msgid "Check service cluster status"
271msgstr "Vérifie l'état d'un cluster de services" 195msgstr "Vérifie l'état d'un cluster de services"
272 196
273#: plugins/check_cluster.c:241
274msgid "Check host cluster status" 197msgid "Check host cluster status"
275msgstr "Vérifie l'état d'un cluster d'hôtes" 198msgstr "Vérifie l'état d'un cluster d'hôtes"
276 199
277#: plugins/check_cluster.c:243
278msgid "Optional prepended text output (i.e. \"Host cluster\")" 200msgid "Optional prepended text output (i.e. \"Host cluster\")"
279msgstr "Texte optionnel accolé à la sortie (i.e. \"Cluster d'hôtes\")" 201msgstr "Texte optionnel accolé à la sortie (i.e. \"Cluster d'hôtes\")"
280 202
281#: plugins/check_cluster.c:245 plugins/check_cluster.c:248
282msgid "Specifies the range of hosts or services in cluster that must be in a" 203msgid "Specifies the range of hosts or services in cluster that must be in a"
283msgstr "Défini le nombre d'hôtes ou de services du cluster qui doivent être" 204msgstr "Défini le nombre d'hôtes ou de services du cluster qui doivent être"
284 205
285#: plugins/check_cluster.c:246
286msgid "non-OK state in order to return a WARNING status level" 206msgid "non-OK state in order to return a WARNING status level"
287msgstr "dans un état non-OK pour retourner un état AVERTISSEMENT" 207msgstr "dans un état non-OK pour retourner un état AVERTISSEMENT"
288 208
289#: plugins/check_cluster.c:249
290msgid "non-OK state in order to return a CRITICAL status level" 209msgid "non-OK state in order to return a CRITICAL status level"
291msgstr "dans un état non-OK pour retourner un état CRITIQUE" 210msgstr "dans un état non-OK pour retourner un état CRITIQUE"
292 211
293#: plugins/check_cluster.c:251
294msgid "The status codes of the hosts or services in the cluster, separated by" 212msgid "The status codes of the hosts or services in the cluster, separated by"
295msgstr "Les codes d'état des hôtes ou des services du cluster, séparés par des" 213msgstr "Les codes d'état des hôtes ou des services du cluster, séparés par des"
296 214
297#: plugins/check_cluster.c:252
298msgid "commas" 215msgid "commas"
299msgstr "virgules" 216msgstr "virgules"
300 217
301#: plugins/check_cluster.c:257 plugins/check_game.c:318
302#: plugins/check_http.c:1542 plugins/check_ldap.c:438 plugins/check_mrtg.c:363
303#: plugins/check_mrtgtraf.c:361 plugins/check_mysql.c:558
304#: plugins/check_nt.c:758 plugins/check_ntp.c:865 plugins/check_ntp_peer.c:696
305#: plugins/check_ntp_time.c:626 plugins/check_nwstat.c:1670
306#: plugins/check_overcr.c:456 plugins/check_snmp.c:1178
307#: plugins/check_swap.c:547 plugins/check_ups.c:642 plugins/negate.c:277
308#: plugins-root/check_icmp.c:1329
309msgid "Notes:" 218msgid "Notes:"
310msgstr "Notes:" 219msgstr "Notes:"
311 220
312#: plugins/check_cluster.c:263
313msgid "" 221msgid ""
314"Will alert critical if there are 3 or more service data points in a non-OK" 222"Will alert critical if there are 3 or more service data points in a non-OK"
315msgstr "" 223msgstr ""
316 224
317#: plugins/check_cluster.c:264 plugins/check_ups.c:639
318msgid "state." 225msgid "state."
319msgstr "" 226msgstr ""
320 227
321#: plugins/check_dig.c:100 plugins/check_dig.c:102
322#, c-format 228#, c-format
323msgid "Looking for: '%s'\n" 229msgid "Looking for: '%s'\n"
324msgstr "Recherche de: '%s'\n" 230msgstr "Recherche de: '%s'\n"
325 231
326#: plugins/check_dig.c:109
327msgid "dig returned an error status" 232msgid "dig returned an error status"
328msgstr "dig à renvoyé un état d'erreur" 233msgstr "dig à renvoyé un état d'erreur"
329 234
330#: plugins/check_dig.c:134
331msgid "Server not found in ANSWER SECTION" 235msgid "Server not found in ANSWER SECTION"
332msgstr "Le serveur n'a pas été trouvé dans l'ANSWER SECTION" 236msgstr "Le serveur n'a pas été trouvé dans l'ANSWER SECTION"
333 237
334#: plugins/check_dig.c:144
335msgid "No ANSWER SECTION found" 238msgid "No ANSWER SECTION found"
336msgstr "Pas d' ANSWER SECTION trouvé" 239msgstr "Pas d' ANSWER SECTION trouvé"
337 240
338#: plugins/check_dig.c:171
339msgid "Probably a non-existent host/domain" 241msgid "Probably a non-existent host/domain"
340msgstr "Probablement un hôte/domaine inexistant" 242msgstr "Probablement un hôte/domaine inexistant"
341 243
342#: plugins/check_dig.c:233
343#, c-format 244#, c-format
344msgid "Port must be a positive integer - %s" 245msgid "Port must be a positive integer - %s"
345msgstr "Le numéro du port doit être un entier positif - %s" 246msgstr "Le numéro du port doit être un entier positif - %s"
346 247
347#: plugins/check_dig.c:244
348#, c-format 248#, c-format
349msgid "Warning interval must be a positive integer - %s" 249msgid "Warning interval must be a positive integer - %s"
350msgstr "Le seuil d'avertissement doit être un entier positif - %s" 250msgstr "Le seuil d'avertissement doit être un entier positif - %s"
351 251
352#: plugins/check_dig.c:252
353#, c-format 252#, c-format
354msgid "Critical interval must be a positive integer - %s" 253msgid "Critical interval must be a positive integer - %s"
355msgstr "Le seuil critique doit être un entier positif - %s" 254msgstr "Le seuil critique doit être un entier positif - %s"
356 255
357#: plugins/check_dig.c:260
358#, c-format 256#, c-format
359msgid "Timeout interval must be a positive integer - %s" 257msgid "Timeout interval must be a positive integer - %s"
360msgstr "Le délai d'attente doit être un entier positif - %s" 258msgstr "Le délai d'attente doit être un entier positif - %s"
361 259
362#: plugins/check_dig.c:325 260#, fuzzy, c-format
363#, c-format 261msgid "This plugin tests the DNS service on the specified host using dig"
364msgid "This plugin test the DNS service on the specified host using dig"
365msgstr "Ce plugin teste le service DNS sur l'hôte spécifié en utilisant dig" 262msgstr "Ce plugin teste le service DNS sur l'hôte spécifié en utilisant dig"
366 263
367#: plugins/check_dig.c:338
368msgid "Force dig to only use IPv4 query transport" 264msgid "Force dig to only use IPv4 query transport"
369msgstr "" 265msgstr ""
370 266
371#: plugins/check_dig.c:340
372msgid "Force dig to only use IPv6 query transport" 267msgid "Force dig to only use IPv6 query transport"
373msgstr "" 268msgstr ""
374 269
375#: plugins/check_dig.c:342
376msgid "Machine name to lookup" 270msgid "Machine name to lookup"
377msgstr "Nom de machine à rechercher" 271msgstr "Nom de machine à rechercher"
378 272
379#: plugins/check_dig.c:344
380msgid "Record type to lookup (default: A)" 273msgid "Record type to lookup (default: A)"
381msgstr "Type d'enregistrement à rechercher (par défaut: A)" 274msgstr "Type d'enregistrement à rechercher (par défaut: A)"
382 275
383#: plugins/check_dig.c:346
384msgid "" 276msgid ""
385"An address expected to be in the answer section. If not set, uses whatever" 277"An address expected to be in the answer section. If not set, uses whatever"
386msgstr "" 278msgstr ""
387"Une adresse qui devrait se trouver dans la section réponce. Si omit, utilise" 279"Une adresse qui devrait se trouver dans la section réponce. Si omit, utilise"
388 280
389#: plugins/check_dig.c:347
390msgid "was in -l" 281msgid "was in -l"
391msgstr "ce qui est passé au paramètre -l" 282msgstr "ce qui est passé au paramètre -l"
392 283
393#: plugins/check_dig.c:349
394msgid "Pass STRING as argument(s) to dig" 284msgid "Pass STRING as argument(s) to dig"
395msgstr "" 285msgstr ""
396 286
397#: plugins/check_disk.c:216
398#, c-format 287#, c-format
399msgid "DISK %s: %s not found\n" 288msgid "DISK %s: %s not found\n"
400msgstr "DISK %s: %s non trouvé\n" 289msgstr "DISK %s: %s non trouvé\n"
401 290
402#: plugins/check_disk.c:216 plugins/check_disk.c:956 plugins/check_dns.c:241
403#: plugins/check_dummy.c:74 plugins/check_mysql.c:299
404#: plugins/check_nagios.c:104 plugins/check_nagios.c:168
405#: plugins/check_nagios.c:172 plugins/check_pgsql.c:601
406#: plugins/check_pgsql.c:618 plugins/check_pgsql.c:627
407#: plugins/check_pgsql.c:642 plugins/check_procs.c:351
408#, c-format 291#, c-format
409msgid "CRITICAL" 292msgid "CRITICAL"
410msgstr "CRITIQUE" 293msgstr "CRITIQUE"
411 294
412#: plugins/check_disk.c:550
413#, c-format 295#, c-format
414msgid "unit type %s not known\n" 296msgid "unit type %s not known\n"
415msgstr "unité de type %s inconnue\n" 297msgstr "unité de type %s inconnue\n"
416 298
417#: plugins/check_disk.c:553
418#, c-format 299#, c-format
419msgid "failed allocating storage for '%s'\n" 300msgid "failed allocating storage for '%s'\n"
420msgstr "Impossible d'allouer de l'espace pour '%s'\n" 301msgstr "Impossible d'allouer de l'espace pour '%s'\n"
421 302
422#: plugins/check_disk.c:577 plugins/check_disk.c:618 plugins/check_disk.c:626
423#: plugins/check_disk.c:633 plugins/check_disk.c:637 plugins/check_disk.c:677
424#: plugins/check_disk.c:683 plugins/check_disk.c:702 plugins/check_dummy.c:77
425#: plugins/check_dummy.c:80 plugins/check_pgsql.c:643
426#: plugins/check_procs.c:506
427#, c-format 303#, c-format
428msgid "UNKNOWN" 304msgid "UNKNOWN"
429msgstr "INCONNU" 305msgstr "INCONNU"
430 306
431#: plugins/check_disk.c:577
432msgid "Must set a threshold value before using -p\n" 307msgid "Must set a threshold value before using -p\n"
433msgstr "" 308msgstr ""
434 309
435#: plugins/check_disk.c:618
436msgid "Must set -E before selecting paths\n" 310msgid "Must set -E before selecting paths\n"
437msgstr "" 311msgstr ""
438 312
439#: plugins/check_disk.c:626
440msgid "Must set group value before selecting paths\n" 313msgid "Must set group value before selecting paths\n"
441msgstr "" 314msgstr ""
442 315
443#: plugins/check_disk.c:633
444msgid "" 316msgid ""
445"Paths need to be selected before using -i/-I. Use -A to select all paths " 317"Paths need to be selected before using -i/-I. Use -A to select all paths "
446"explicitly" 318"explicitly"
447msgstr "" 319msgstr ""
448 320
449#: plugins/check_disk.c:637 plugins/check_disk.c:683 plugins/check_procs.c:506
450msgid "Could not compile regular expression" 321msgid "Could not compile regular expression"
451msgstr "Impossible de compiler l'expression rationnelle" 322msgstr "Impossible de compiler l'expression rationnelle"
452 323
453#: plugins/check_disk.c:677 324msgid ""
454msgid "Must set a threshold value before using -r/-R\n" 325"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
326"all)\n"
455msgstr "" 327msgstr ""
456 328
457#: plugins/check_disk.c:703
458msgid "Regular expression did not match any path or disk" 329msgid "Regular expression did not match any path or disk"
459msgstr "" 330msgstr ""
460 331
461#: plugins/check_disk.c:749
462msgid "Unknown argument" 332msgid "Unknown argument"
463msgstr "Argument inconnu" 333msgstr "Argument inconnu"
464 334
465#: plugins/check_disk.c:783
466#, c-format 335#, c-format
467msgid " for %s\n" 336msgid " for %s\n"
468msgstr " pour %s\n" 337msgstr " pour %s\n"
469 338
470#: plugins/check_disk.c:857
471msgid "" 339msgid ""
472"This plugin checks the amount of used disk space on a mounted file system" 340"This plugin checks the amount of used disk space on a mounted file system"
473msgstr "Ce plugin vérifie la place utilisé sur un système de fichier monté" 341msgstr "Ce plugin vérifie la place utilisé sur un système de fichier monté"
474 342
475#: plugins/check_disk.c:858
476msgid "" 343msgid ""
477"and generates an alert if free space is less than one of the threshold values" 344"and generates an alert if free space is less than one of the threshold values"
478msgstr "" 345msgstr ""
479"et génère une alerte si la place disponible est plus petite qu'un des seuils " 346"et génère une alerte si la place disponible est plus petite qu'un des seuils "
480"fourni" 347"fourni"
481 348
482#: plugins/check_disk.c:868
483msgid "Exit with WARNING status if less than INTEGER units of disk are free" 349msgid "Exit with WARNING status if less than INTEGER units of disk are free"
484msgstr "" 350msgstr ""
485"Sortir avec un résultat AVERTISSEMENT si moins de X unités de disques sont " 351"Sortir avec un résultat AVERTISSEMENT si moins de X unités de disques sont "
486"libres" 352"libres"
487 353
488#: plugins/check_disk.c:870
489msgid "Exit with WARNING status if less than PERCENT of disk space is free" 354msgid "Exit with WARNING status if less than PERCENT of disk space is free"
490msgstr "" 355msgstr ""
491"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent du disque est " 356"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent du disque est "
492"libre" 357"libre"
493 358
494#: plugins/check_disk.c:872
495msgid "Exit with CRITICAL status if less than INTEGER units of disk are free" 359msgid "Exit with CRITICAL status if less than INTEGER units of disk are free"
496msgstr "" 360msgstr ""
497"Sortir avec un résultat CRITIQUE si moins de X unités du disque sont libres" 361"Sortir avec un résultat CRITIQUE si moins de X unités du disque sont libres"
498 362
499#: plugins/check_disk.c:874
500#, fuzzy 363#, fuzzy
501msgid "Exit with CRITICAL status if less than PERCENT of disk space is free" 364msgid "Exit with CRITICAL status if less than PERCENT of disk space is free"
502msgstr "" 365msgstr ""
503"Sortir avec un résultat CRITIQUE si moins de X pour-cent du disque est libre" 366"Sortir avec un résultat CRITIQUE si moins de X pour-cent du disque est libre"
504 367
505#: plugins/check_disk.c:876
506msgid "Exit with WARNING status if less than PERCENT of inode space is free" 368msgid "Exit with WARNING status if less than PERCENT of inode space is free"
507msgstr "" 369msgstr ""
508"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent des inodes " 370"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent des inodes "
509"sont libres" 371"sont libres"
510 372
511#: plugins/check_disk.c:878
512msgid "Exit with CRITICAL status if less than PERCENT of inode space is free" 373msgid "Exit with CRITICAL status if less than PERCENT of inode space is free"
513msgstr "" 374msgstr ""
514"Sortir avec un résultat CRITIQUE si moins de X pour-cent des inodes sont " 375"Sortir avec un résultat CRITIQUE si moins de X pour-cent des inodes sont "
515"libres" 376"libres"
516 377
517#: plugins/check_disk.c:880 378msgid ""
518msgid "Path or partition (may be repeated)" 379"Mount point or block device as emitted by the mount(8) command (may be "
519msgstr "Répertoire ou partition (peut être utilisé plusieurs fois)" 380"repeated)"
381msgstr ""
520 382
521#: plugins/check_disk.c:882
522msgid "Ignore device (only works if -p unspecified)" 383msgid "Ignore device (only works if -p unspecified)"
523msgstr "Ignorer le périphérique (marche seulement lorsque -p est utilisé)" 384msgstr "Ignorer le périphérique (marche seulement lorsque -p est utilisé)"
524 385
525#: plugins/check_disk.c:884
526msgid "Clear thresholds" 386msgid "Clear thresholds"
527msgstr "Effacer les seuils" 387msgstr "Effacer les seuils"
528 388
529#: plugins/check_disk.c:886
530msgid "For paths or partitions specified with -p, only check for exact paths" 389msgid "For paths or partitions specified with -p, only check for exact paths"
531msgstr "" 390msgstr ""
532 391
533#: plugins/check_disk.c:888
534msgid "Display only devices/mountpoints with errors" 392msgid "Display only devices/mountpoints with errors"
535msgstr "Afficher seulement les périphériques/point de montage avec des erreurs" 393msgstr "Afficher seulement les périphériques/point de montage avec des erreurs"
536 394
537#: plugins/check_disk.c:890
538msgid "Don't account root-reserved blocks into freespace in perfdata" 395msgid "Don't account root-reserved blocks into freespace in perfdata"
539msgstr "" 396msgstr ""
540 397
541#: plugins/check_disk.c:892 398msgid "Display inode usage in perfdata"
399msgstr ""
400
542msgid "" 401msgid ""
543"Group paths. Thresholds apply to (free-)space of all partitions together" 402"Group paths. Thresholds apply to (free-)space of all partitions together"
544msgstr "" 403msgstr ""
545 404
546#: plugins/check_disk.c:894
547msgid "Same as '--units kB'" 405msgid "Same as '--units kB'"
548msgstr "Pareil à '--units kB'" 406msgstr "Pareil à '--units kB'"
549 407
550#: plugins/check_disk.c:896
551msgid "Only check local filesystems" 408msgid "Only check local filesystems"
552msgstr "Vérifier seulement les systèmes de fichiers locaux" 409msgstr "Vérifier seulement les systèmes de fichiers locaux"
553 410
554#: plugins/check_disk.c:898
555msgid "" 411msgid ""
556"Only check local filesystems against thresholds. Yet call stat on remote " 412"Only check local filesystems against thresholds. Yet call stat on remote "
557"filesystems" 413"filesystems"
558msgstr "" 414msgstr ""
559 415
560#: plugins/check_disk.c:899
561msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)" 416msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)"
562msgstr "" 417msgstr ""
563 418
564#: plugins/check_disk.c:901 419#, fuzzy
565msgid "Display the mountpoint instead of the partition" 420msgid "Display the (block) device instead of the mount point"
566msgstr "Afficher le point de montage au lieu de la partition" 421msgstr "Afficher le point de montage au lieu de la partition"
567 422
568#: plugins/check_disk.c:903
569msgid "Same as '--units MB'" 423msgid "Same as '--units MB'"
570msgstr "Pareil à '--units MB'" 424msgstr "Pareil à '--units MB'"
571 425
572#: plugins/check_disk.c:905
573msgid "Explicitly select all paths. This is equivalent to -R '.*'" 426msgid "Explicitly select all paths. This is equivalent to -R '.*'"
574msgstr "" 427msgstr ""
575 428
576#: plugins/check_disk.c:907
577msgid "" 429msgid ""
578"Case insensitive regular expression for path/partition (may be repeated)" 430"Case insensitive regular expression for path/partition (may be repeated)"
579msgstr "" 431msgstr ""
580"Expression rationnelle indépendante de la case pour un répertoire ou une " 432"Expression rationnelle indépendante de la case pour un répertoire ou une "
581"partition (peut être utilisé plusieurs fois)" 433"partition (peut être utilisé plusieurs fois)"
582 434
583#: plugins/check_disk.c:909
584msgid "Regular expression for path or partition (may be repeated)" 435msgid "Regular expression for path or partition (may be repeated)"
585msgstr "" 436msgstr ""
586"Expression rationnelle pour un répertoire ou une partition (peut être " 437"Expression rationnelle pour un répertoire ou une partition (peut être "
587"utilisé plusieurs fois)" 438"utilisé plusieurs fois)"
588 439
589#: plugins/check_disk.c:911
590msgid "" 440msgid ""
591"Regular expression to ignore selected path/partition (case insensitive) (may " 441"Regular expression to ignore selected path/partition (case insensitive) (may "
592"be repeated)" 442"be repeated)"
@@ -594,200 +444,192 @@ msgstr ""
594"Expression rationnelle pour ignorer un répertoire ou une partition (peut " 444"Expression rationnelle pour ignorer un répertoire ou une partition (peut "
595"être utilisé plusieurs fois)" 445"être utilisé plusieurs fois)"
596 446
597#: plugins/check_disk.c:913
598msgid "" 447msgid ""
599"Regular expression to ignore selected path or partition (may be repeated)" 448"Regular expression to ignore selected path or partition (may be repeated)"
600msgstr "" 449msgstr ""
601"Expression rationnelle pour ignorer un répertoire ou une partition (peut " 450"Expression rationnelle pour ignorer un répertoire ou une partition (peut "
602"être utilisé plusieurs fois)" 451"être utilisé plusieurs fois)"
603 452
604#: plugins/check_disk.c:916 453msgid ""
454"Return OK if no filesystem matches, filesystem does not exist or is "
455"inaccessible."
456msgstr ""
457
458msgid "(Provide this option before -p / -r / --ereg-path if used)"
459msgstr ""
460
605msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 461msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
606msgstr "Choisissez octets, kb, MB, GB, TB (par défaut: MB)" 462msgstr "Choisissez octets, kb, MB, GB, TB (par défaut: MB)"
607 463
608#: plugins/check_disk.c:919
609msgid "Ignore all filesystems of indicated type (may be repeated)" 464msgid "Ignore all filesystems of indicated type (may be repeated)"
610msgstr "" 465msgstr ""
611"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué " 466"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
612"(peut être utilisé plusieurs fois)" 467"(peut être utilisé plusieurs fois)"
613 468
614#: plugins/check_disk.c:921
615#, fuzzy 469#, fuzzy
616msgid "Check only filesystems of indicated type (may be repeated)" 470msgid "Check only filesystems of indicated type (may be repeated)"
617msgstr "" 471msgstr ""
618"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué " 472"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
619"(peut être utilisé plusieurs fois)" 473"(peut être utilisé plusieurs fois)"
620 474
621#: plugins/check_disk.c:926 475msgid "General usage hints:"
476msgstr ""
477
478msgid ""
479"- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the "
480"same as"
481msgstr ""
482
483msgid "\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."
484msgstr ""
485
486msgid ""
487"- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} "
488"{thresholds b} ...\""
489msgstr ""
490
622msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB" 491msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
623msgstr "Vérifie /tmp à 10% et /var à 5% et / à 100MB et 50MB" 492msgstr "Vérifie /tmp à 10% et /var à 5% et / à 100MB et 50MB"
624 493
625#: plugins/check_disk.c:928
626msgid "" 494msgid ""
627"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -" 495"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -"
628"r regex" 496"r regex"
629msgstr "" 497msgstr ""
630 498
631#: plugins/check_disk.c:929
632msgid "" 499msgid ""
633"are grouped which means the freespace thresholds are applied to all disks " 500"are grouped which means the freespace thresholds are applied to all disks "
634"together" 501"together"
635msgstr "" 502msgstr ""
636 503
637#: plugins/check_disk.c:931
638msgid "" 504msgid ""
639"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use " 505"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use "
640"100M/50M" 506"100M/50M"
641msgstr "" 507msgstr ""
642 508
643#: plugins/check_disk.c:957
644#, c-format 509#, c-format
645msgid "%s %s: %s\n" 510msgid "%s %s: %s\n"
646msgstr "" 511msgstr ""
647 512
648#: plugins/check_disk.c:957
649msgid "is not accessible" 513msgid "is not accessible"
650msgstr "" 514msgstr ""
651 515
652#: plugins/check_dns.c:116
653msgid "nslookup returned an error status" 516msgid "nslookup returned an error status"
654msgstr "nslookup à retourné un code d'erreur" 517msgstr "nslookup à retourné un code d'erreur"
655 518
656#: plugins/check_dns.c:134
657msgid "Warning plugin error" 519msgid "Warning plugin error"
658msgstr "Alerte erreur de plugin" 520msgstr "Alerte erreur de plugin"
659 521
660#: plugins/check_dns.c:154 522#, fuzzy, c-format
523msgid "DNS CRITICAL - '%s' returned empty server string\n"
524msgstr "DNS CRITIQUE - '%s' à retourné un nom d'hôte vide\n"
525
526#, fuzzy, c-format
527msgid "DNS CRITICAL - No response from DNS %s\n"
528msgstr "Pas de réponse du DNS %s\n"
529
661#, c-format 530#, c-format
662msgid "DNS CRITICAL - '%s' returned empty host name string\n" 531msgid "DNS CRITICAL - '%s' returned empty host name string\n"
663msgstr "DNS CRITIQUE - '%s' à retourné un nom d'hôte vide\n" 532msgstr "DNS CRITIQUE - '%s' à retourné un nom d'hôte vide\n"
664 533
665#: plugins/check_dns.c:160
666msgid "Non-authoritative answer:" 534msgid "Non-authoritative answer:"
667msgstr "Réponse non autoritative:" 535msgstr "Réponse non autoritative:"
668 536
669#: plugins/check_dns.c:201 537#, fuzzy, c-format
538msgid "Domain '%s' was not found by the server\n"
539msgstr "Le domaine %s n'a pas été trouvé par le serveur\n"
540
670#, c-format 541#, c-format
671msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n" 542msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n"
672msgstr "DNS CRITIQUE - '%s' n'a pas retourné d'adresse\n" 543msgstr "DNS CRITIQUE - '%s' n'a pas retourné d'adresse\n"
673 544
674#: plugins/check_dns.c:216
675#, c-format 545#, c-format
676msgid "expected '%s' but got '%s'" 546msgid "expected '%s' but got '%s'"
677msgstr "j'attendais '%s' mais j'ai reçu '%s'" 547msgstr "j'attendais '%s' mais j'ai reçu '%s'"
678 548
679#: plugins/check_dns.c:223 549#, fuzzy, c-format
550msgid "Domain '%s' was found by the server: '%s'\n"
551msgstr "Le domaine %s n'a pas été trouvé par le serveur\n"
552
680#, c-format 553#, c-format
681msgid "server %s is not authoritative for %s" 554msgid "server %s is not authoritative for %s"
682msgstr "serveur %s n'est pas autoritaire pour %s" 555msgstr "serveur %s n'est pas autoritaire pour %s"
683 556
684#: plugins/check_dns.c:237 plugins/check_dummy.c:68 plugins/check_nagios.c:182
685#: plugins/check_pgsql.c:638 plugins/check_procs.c:344
686#, c-format 557#, c-format
687msgid "OK" 558msgid "OK"
688msgstr "OK" 559msgstr "OK"
689 560
690#: plugins/check_dns.c:239 plugins/check_dummy.c:71 plugins/check_mysql.c:296
691#: plugins/check_nagios.c:182 plugins/check_pgsql.c:607
692#: plugins/check_pgsql.c:612 plugins/check_pgsql.c:640
693#: plugins/check_procs.c:346
694#, c-format 561#, c-format
695msgid "WARNING" 562msgid "WARNING"
696msgstr "AVERTISSEMENT" 563msgstr "AVERTISSEMENT"
697 564
698#: plugins/check_dns.c:243
699#, c-format 565#, c-format
700msgid "%.3f second response time" 566msgid "%.3f second response time"
701msgid_plural "%.3f seconds response time" 567msgid_plural "%.3f seconds response time"
702msgstr[0] "%.3f secondes de temps de réponse " 568msgstr[0] "%.3f secondes de temps de réponse "
703msgstr[1] "%.3f secondes de temps de réponse " 569msgstr[1] "%.3f secondes de temps de réponse "
704 570
705#: plugins/check_dns.c:244
706#, c-format 571#, c-format
707msgid ". %s returns %s" 572msgid ". %s returns %s"
708msgstr ". %s renvoie %s" 573msgstr ". %s renvoie %s"
709 574
710#: plugins/check_dns.c:248
711#, c-format 575#, c-format
712msgid "DNS WARNING - %s\n" 576msgid "DNS WARNING - %s\n"
713msgstr "DNS AVERTISSEMENT - %s\n" 577msgstr "DNS AVERTISSEMENT - %s\n"
714 578
715#: plugins/check_dns.c:249 plugins/check_dns.c:252 plugins/check_dns.c:255
716msgid " Probably a non-existent host/domain" 579msgid " Probably a non-existent host/domain"
717msgstr " Probablement un hôte/domaine inexistant" 580msgstr " Probablement un hôte/domaine inexistant"
718 581
719#: plugins/check_dns.c:251
720#, c-format 582#, c-format
721msgid "DNS CRITICAL - %s\n" 583msgid "DNS CRITICAL - %s\n"
722msgstr "DNS CRITIQUE - %s\n" 584msgstr "DNS CRITIQUE - %s\n"
723 585
724#: plugins/check_dns.c:254
725#, c-format 586#, c-format
726msgid "DNS UNKNOWN - %s\n" 587msgid "DNS UNKNOWN - %s\n"
727msgstr "DNS INCONNU - %s\n" 588msgstr "DNS INCONNU - %s\n"
728 589
729#: plugins/check_dns.c:267
730msgid "Note: nslookup is deprecated and may be removed from future releases." 590msgid "Note: nslookup is deprecated and may be removed from future releases."
731msgstr "" 591msgstr ""
732"Note: nslookup est obsolète et pourra être retiré dans les prochaines " 592"Note: nslookup est obsolète et pourra être retiré dans les prochaines "
733"versions." 593"versions."
734 594
735#: plugins/check_dns.c:268
736msgid "Consider using the `dig' or `host' programs instead. Run nslookup with" 595msgid "Consider using the `dig' or `host' programs instead. Run nslookup with"
737msgstr "" 596msgstr ""
738"Veuillez utiliser le programme 'dig' ou 'host' à la place. Faire fonctionner " 597"Veuillez utiliser le programme 'dig' ou 'host' à la place. Faire fonctionner "
739"nslookup avec" 598"nslookup avec"
740 599
741#: plugins/check_dns.c:269
742msgid "the `-sil[ent]' option to prevent this message from appearing." 600msgid "the `-sil[ent]' option to prevent this message from appearing."
743msgstr "L'option '-sil[ent]' empêche l'apparition de ce message." 601msgstr "L'option '-sil[ent]' empêche l'apparition de ce message."
744 602
745#: plugins/check_dns.c:274
746#, c-format 603#, c-format
747msgid "No response from DNS %s\n" 604msgid "No response from DNS %s\n"
748msgstr "Pas de réponse du DNS %s\n" 605msgstr "Pas de réponse du DNS %s\n"
749 606
750#: plugins/check_dns.c:278
751#, c-format 607#, c-format
752msgid "DNS %s has no records\n" 608msgid "DNS %s has no records\n"
753msgstr "Le DNS %s n'a pas d'enregistrements\n" 609msgstr "Le DNS %s n'a pas d'enregistrements\n"
754 610
755#: plugins/check_dns.c:286
756#, c-format 611#, c-format
757msgid "Connection to DNS %s was refused\n" 612msgid "Connection to DNS %s was refused\n"
758msgstr "La connexion au DNS %s à été refusée\n" 613msgstr "La connexion au DNS %s à été refusée\n"
759 614
760#: plugins/check_dns.c:290
761#, c-format 615#, c-format
762msgid "Query was refused by DNS server at %s\n" 616msgid "Query was refused by DNS server at %s\n"
763msgstr "La requête à été refusée par le serveur DNS %s\n" 617msgstr "La requête à été refusée par le serveur DNS %s\n"
764 618
765#: plugins/check_dns.c:294
766#, c-format 619#, c-format
767msgid "No information returned by DNS server at %s\n" 620msgid "No information returned by DNS server at %s\n"
768msgstr "Pas d'information renvoyée par le serveur DNS %s\n" 621msgstr "Pas d'information renvoyée par le serveur DNS %s\n"
769 622
770#: plugins/check_dns.c:300
771#, c-format
772msgid "Domain %s was not found by the server\n"
773msgstr "Le domaine %s n'a pas été trouvé par le serveur\n"
774
775#: plugins/check_dns.c:304
776msgid "Network is unreachable\n" 623msgid "Network is unreachable\n"
777msgstr "Le réseau est inaccessible\n" 624msgstr "Le réseau est inaccessible\n"
778 625
779#: plugins/check_dns.c:308
780#, c-format 626#, c-format
781msgid "DNS failure for %s\n" 627msgid "DNS failure for %s\n"
782msgstr "DNS à échoué pour %s\n" 628msgstr "DNS à échoué pour %s\n"
783 629
784#: plugins/check_dns.c:372 plugins/check_dns.c:380 plugins/check_dns.c:387
785#: plugins/check_dns.c:392 plugins/check_dns.c:414 plugins/check_dns.c:422
786#: plugins/check_game.c:211 plugins/check_game.c:219
787msgid "Input buffer overflow\n" 630msgid "Input buffer overflow\n"
788msgstr "Le tampon d'entrée a débordé\n" 631msgstr "Le tampon d'entrée a débordé\n"
789 632
790#: plugins/check_dns.c:450
791msgid "" 633msgid ""
792"This plugin uses the nslookup program to obtain the IP address for the given " 634"This plugin uses the nslookup program to obtain the IP address for the given "
793"host/domain query." 635"host/domain query."
@@ -795,11 +637,9 @@ msgstr ""
795"Ce plugin utilise le programme nslookup pour obtenir l'adresse IP de l'hôte/" 637"Ce plugin utilise le programme nslookup pour obtenir l'adresse IP de l'hôte/"
796"domaine à interroger." 638"domaine à interroger."
797 639
798#: plugins/check_dns.c:451
799msgid "An optional DNS server to use may be specified." 640msgid "An optional DNS server to use may be specified."
800msgstr "Un serveur DNS à utiliser peut être indiqué." 641msgstr "Un serveur DNS à utiliser peut être indiqué."
801 642
802#: plugins/check_dns.c:452
803msgid "" 643msgid ""
804"If no DNS server is specified, the default server(s) specified in /etc/" 644"If no DNS server is specified, the default server(s) specified in /etc/"
805"resolv.conf will be used." 645"resolv.conf will be used."
@@ -807,193 +647,158 @@ msgstr ""
807"Si aucun serveur DNS n'est spécifié, les serveurs spécifiés dans /etc/resolv." 647"Si aucun serveur DNS n'est spécifié, les serveurs spécifiés dans /etc/resolv."
808"conf seront utilisé." 648"conf seront utilisé."
809 649
810#: plugins/check_dns.c:462
811msgid "The name or address you want to query" 650msgid "The name or address you want to query"
812msgstr "Le nom ou l'adresse que vous voulez interroger" 651msgstr "Le nom ou l'adresse que vous voulez interroger"
813 652
814#: plugins/check_dns.c:464
815msgid "Optional DNS server you want to use for the lookup" 653msgid "Optional DNS server you want to use for the lookup"
816msgstr "Serveur DNS que vous voulez utiliser pour la recherche" 654msgstr "Serveur DNS que vous voulez utiliser pour la recherche"
817 655
818#: plugins/check_dns.c:466 656#, fuzzy
819msgid "" 657msgid ""
820"Optional IP-ADDRESS you expect the DNS server to return. HOST must end with" 658"Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"
821msgstr "" 659msgstr ""
822"Adresse IP que le serveur DNS doit retourner. Les hôtes doivent se terminer " 660"Adresse IP que le serveur DNS doit retourner. Les hôtes doivent se terminer "
823 661
824#: plugins/check_dns.c:467 662#, fuzzy
825msgid "" 663msgid ""
826"a dot (.). This option can be repeated multiple times (Returns OK if any" 664"with a dot (.). This option can be repeated multiple times (Returns OK if any"
827msgstr "avec un point (.). Cette option peut être répétée (Retourne OK si une" 665msgstr "avec un point (.). Cette option peut être répétée (Retourne OK si une"
828 666
829#: plugins/check_dns.c:468 667msgid "value matches)."
830msgid ""
831"value match). If multiple addresses are returned at once, you have to match"
832msgstr "" 668msgstr ""
833"valeur correspond). Si plusieurs adresses sont retournées en même temps,"
834 669
835#: plugins/check_dns.c:469
836msgid "" 670msgid ""
837"the whole string of addresses separated with commas (sorted alphabetically)." 671"Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"
672msgstr ""
673
674msgid "Cannot be used together with -a"
838msgstr "" 675msgstr ""
839"vous devrez toutes les inscrire séparées pas des virgules (en ordre "
840"alphabétique)"
841 676
842#: plugins/check_dns.c:471
843msgid "Optionally expect the DNS server to be authoritative for the lookup" 677msgid "Optionally expect the DNS server to be authoritative for the lookup"
844msgstr "Serveur DNS qui doit normalement être autoritaire pour la recherche" 678msgstr "Serveur DNS qui doit normalement être autoritaire pour la recherche"
845 679
846#: plugins/check_dns.c:473
847msgid "Return warning if elapsed time exceeds value. Default off" 680msgid "Return warning if elapsed time exceeds value. Default off"
848msgstr "" 681msgstr ""
849"Renvoie une alerte si le temps écoulé dépasse la valeur indiquée. Désactivé " 682"Renvoie une alerte si le temps écoulé dépasse la valeur indiquée. Désactivé "
850"par défaut" 683"par défaut"
851 684
852#: plugins/check_dns.c:475
853msgid "Return critical if elapsed time exceeds value. Default off" 685msgid "Return critical if elapsed time exceeds value. Default off"
854msgstr "" 686msgstr ""
855"Renvoie critique si le temps utilisé dépasse la valeur indiquée. Désactivé " 687"Renvoie critique si le temps utilisé dépasse la valeur indiquée. Désactivé "
856"par défaut" 688"par défaut"
857 689
858#: plugins/check_dummy.c:62 690msgid ""
691"Return critical if the list of expected addresses does not match all "
692"addresses"
693msgstr ""
694
695msgid "returned. Default off"
696msgstr ""
697
859msgid "Arguments to check_dummy must be an integer" 698msgid "Arguments to check_dummy must be an integer"
860msgstr "Les arguments pour check_dummy doivent être des entiers" 699msgstr "Les arguments pour check_dummy doivent être des entiers"
861 700
862#: plugins/check_dummy.c:82
863#, c-format 701#, c-format
864msgid "Status %d is not a supported error state\n" 702msgid "Status %d is not a supported error state\n"
865msgstr "Le résultat %d n'est pas un résultat supporté\n" 703msgstr "Le résultat %d n'est pas un résultat supporté\n"
866 704
867#: plugins/check_dummy.c:104
868msgid "" 705msgid ""
869"This plugin will simply return the state corresponding to the numeric value" 706"This plugin will simply return the state corresponding to the numeric value"
870msgstr "" 707msgstr ""
871"Ce plugin renverra simplement l'état correspondant à la valeur numérique" 708"Ce plugin renverra simplement l'état correspondant à la valeur numérique"
872 709
873#: plugins/check_dummy.c:106
874msgid "of the <state> argument with optional text" 710msgid "of the <state> argument with optional text"
875msgstr "du paramètre <state> avec un texte optionnel" 711msgstr "du paramètre <state> avec un texte optionnel"
876 712
877#: plugins/check_fping.c:125 plugins/check_hpjd.c:128 plugins/check_ping.c:438
878#: plugins/check_swap.c:175 plugins/check_users.c:94 plugins/urlize.c:110
879#, c-format 713#, c-format
880msgid "Could not open pipe: %s\n" 714msgid "Could not open pipe: %s\n"
881msgstr "Impossible d'ouvrir le pipe: %s\n" 715msgstr "Impossible d'ouvrir le pipe: %s\n"
882 716
883#: plugins/check_fping.c:131 plugins/check_hpjd.c:134 plugins/check_load.c:153
884#: plugins/check_swap.c:181 plugins/check_users.c:100 plugins/urlize.c:116
885#, c-format 717#, c-format
886msgid "Could not open stderr for %s\n" 718msgid "Could not open stderr for %s\n"
887msgstr "Impossible d'ouvrir la sortie d'erreur standard pour %s\n" 719msgstr "Impossible d'ouvrir la sortie d'erreur standard pour %s\n"
888 720
889#: plugins/check_fping.c:157
890#, fuzzy 721#, fuzzy
891msgid "FPING UNKNOWN - IP address not found\n" 722msgid "FPING UNKNOWN - IP address not found\n"
892msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 723msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
893 724
894#: plugins/check_fping.c:160
895msgid "FPING UNKNOWN - invalid commandline argument\n" 725msgid "FPING UNKNOWN - invalid commandline argument\n"
896msgstr "" 726msgstr ""
897 727
898#: plugins/check_fping.c:163
899#, fuzzy 728#, fuzzy
900msgid "FPING UNKNOWN - failed system call\n" 729msgid "FPING UNKNOWN - failed system call\n"
901msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 730msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
902 731
903#: plugins/check_fping.c:187 732#, fuzzy, c-format
733msgid "FPING %s - %s (rta=%f ms)|%s\n"
734msgstr "FPING %s - %s (perte=%.0f%% )|%s\n"
735
904#, c-format 736#, c-format
905msgid "FPING UNKNOW - %s not found\n" 737msgid "FPING UNKNOWN - %s not found\n"
906msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 738msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
907 739
908#: plugins/check_fping.c:191
909#, c-format 740#, c-format
910msgid "FPING CRITICAL - %s is unreachable\n" 741msgid "FPING CRITICAL - %s is unreachable\n"
911msgstr "PING CRITIQUE - Hôte inaccessible (%s)\n" 742msgstr "PING CRITIQUE - Hôte inaccessible (%s)\n"
912 743
913#: plugins/check_fping.c:196
914#, fuzzy, c-format 744#, fuzzy, c-format
915msgid "FPING UNKNOWN - %s parameter error\n" 745msgid "FPING UNKNOWN - %s parameter error\n"
916msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 746msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
917 747
918#: plugins/check_fping.c:200 plugins/check_fping.c:240
919#, c-format 748#, c-format
920msgid "FPING CRITICAL - %s is down\n" 749msgid "FPING CRITICAL - %s is down\n"
921msgstr "FPING CRITIQUE - %s est en panne\n" 750msgstr "FPING CRITIQUE - %s est en panne\n"
922 751
923#: plugins/check_fping.c:227
924#, c-format 752#, c-format
925msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n" 753msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"
926msgstr "FPING %s - %s (perte=%.0f%%, rta=%f ms)|%s %s\n" 754msgstr "FPING %s - %s (perte=%.0f%%, rta=%f ms)|%s %s\n"
927 755
928#: plugins/check_fping.c:253
929#, c-format 756#, c-format
930msgid "FPING %s - %s (loss=%.0f%% )|%s\n" 757msgid "FPING %s - %s (loss=%.0f%% )|%s\n"
931msgstr "FPING %s - %s (perte=%.0f%% )|%s\n" 758msgstr "FPING %s - %s (perte=%.0f%% )|%s\n"
932 759
933#: plugins/check_fping.c:326 plugins/check_fping.c:332
934#: plugins/check_hpjd.c:338 plugins/check_hpjd.c:361 plugins/check_mysql.c:371
935#: plugins/check_mysql.c:455 plugins/check_ntp.c:709
936#: plugins/check_ntp_peer.c:497 plugins/check_ntp_time.c:496
937#: plugins/check_pgsql.c:335 plugins/check_ping.c:295 plugins/check_ping.c:418
938#: plugins/check_radius.c:264 plugins/check_real.c:314
939#: plugins/check_real.c:376 plugins/check_smtp.c:499 plugins/check_smtp.c:641
940#: plugins/check_ssh.c:157 plugins/check_time.c:240 plugins/check_time.c:315
941#: plugins/check_ups.c:504 plugins/check_ups.c:573
942msgid "Invalid hostname/address" 760msgid "Invalid hostname/address"
943msgstr "Adresse/Nom d'hôte invalide" 761msgstr "Adresse/Nom d'hôte invalide"
944 762
945#: plugins/check_fping.c:345 plugins/check_ldap.c:353 plugins/check_ping.c:246
946msgid "IPv6 support not available\n" 763msgid "IPv6 support not available\n"
947msgstr "Support IPv6 non disponible\n" 764msgstr "Support IPv6 non disponible\n"
948 765
949#: plugins/check_fping.c:378
950msgid "Packet size must be a positive integer" 766msgid "Packet size must be a positive integer"
951msgstr "La taille du paquet doit être un entier positif" 767msgstr "La taille du paquet doit être un entier positif"
952 768
953#: plugins/check_fping.c:384
954msgid "Packet count must be a positive integer" 769msgid "Packet count must be a positive integer"
955msgstr "Le nombre de paquets doit être un entier positif" 770msgstr "Le nombre de paquets doit être un entier positif"
956 771
957#: plugins/check_fping.c:390
958msgid "Target timeout must be a positive integer" 772msgid "Target timeout must be a positive integer"
959msgstr "Le seuil d'avertissement doit être un entier positif" 773msgstr "Le seuil d'avertissement doit être un entier positif"
960 774
961#: plugins/check_fping.c:396
962msgid "Interval must be a positive integer" 775msgid "Interval must be a positive integer"
963msgstr "Le délai d'attente doit être un entier positif" 776msgstr "Le délai d'attente doit être un entier positif"
964 777
965#: plugins/check_fping.c:402 plugins/check_ntp.c:733
966#: plugins/check_ntp_peer.c:524 plugins/check_ntp_time.c:523
967#: plugins/check_radius.c:314 plugins/check_time.c:319
968msgid "Hostname was not supplied" 778msgid "Hostname was not supplied"
969msgstr "Le nom de l'hôte n'a pas été spécifié" 779msgstr "Le nom de l'hôte n'a pas été spécifié"
970 780
971#: plugins/check_fping.c:422
972#, c-format 781#, c-format
973msgid "%s: Only one threshold may be packet loss (%s)\n" 782msgid "%s: Only one threshold may be packet loss (%s)\n"
974msgstr "" 783msgstr ""
975"%s: Seulement un seuil peut être utilisé pour les pertes de paquets (%s)\n" 784"%s: Seulement un seuil peut être utilisé pour les pertes de paquets (%s)\n"
976 785
977#: plugins/check_fping.c:426
978#, c-format 786#, c-format
979msgid "%s: Only one threshold must be packet loss (%s)\n" 787msgid "%s: Only one threshold must be packet loss (%s)\n"
980msgstr "" 788msgstr ""
981"%s: Seulement un seuil doit être utilisé pour les pertes de paquets (%s)\n" 789"%s: Seulement un seuil doit être utilisé pour les pertes de paquets (%s)\n"
982 790
983#: plugins/check_fping.c:458
984msgid "" 791msgid ""
985"This plugin will use the fping command to ping the specified host for a fast " 792"This plugin will use the fping command to ping the specified host for a fast "
986"check" 793"check"
987msgstr "" 794msgstr ""
988"Ce plugin va utiliser la commande fping pour pinger l'hôte de manière rapide." 795"Ce plugin va utiliser la commande fping pour pinger l'hôte de manière rapide."
989 796
990#: plugins/check_fping.c:460
991msgid "Note that it is necessary to set the suid flag on fping." 797msgid "Note that it is necessary to set the suid flag on fping."
992msgstr "" 798msgstr ""
993"Veuillez noter qu'il est nécessaire de mettre le bit suid sur le programme " 799"Veuillez noter qu'il est nécessaire de mettre le bit suid sur le programme "
994"fping." 800"fping."
995 801
996#: plugins/check_fping.c:472
997msgid "" 802msgid ""
998"name or IP Address of host to ping (IP Address bypasses name lookup, " 803"name or IP Address of host to ping (IP Address bypasses name lookup, "
999"reducing system load)" 804"reducing system load)"
@@ -1001,39 +806,33 @@ msgstr ""
1001"nom ou adresse IP des hôtes à pinger (l'indication d'un adresse IP évite une " 806"nom ou adresse IP des hôtes à pinger (l'indication d'un adresse IP évite une "
1002"recherche sur le nom, ce qui réduit la charge système)" 807"recherche sur le nom, ce qui réduit la charge système)"
1003 808
1004#: plugins/check_fping.c:474 plugins/check_ping.c:575
1005msgid "warning threshold pair" 809msgid "warning threshold pair"
1006msgstr "Valeurs pour le seuil d'avertissement" 810msgstr "Valeurs pour le seuil d'avertissement"
1007 811
1008#: plugins/check_fping.c:476 plugins/check_ping.c:577
1009msgid "critical threshold pair" 812msgid "critical threshold pair"
1010msgstr "Valeurs pour le seuil critique" 813msgstr "Valeurs pour le seuil critique"
1011 814
1012#: plugins/check_fping.c:478 815msgid "Return OK after first successful reply"
816msgstr ""
817
1013msgid "size of ICMP packet" 818msgid "size of ICMP packet"
1014msgstr "taille du paquet ICMP" 819msgstr "taille du paquet ICMP"
1015 820
1016#: plugins/check_fping.c:480
1017msgid "number of ICMP packets to send" 821msgid "number of ICMP packets to send"
1018msgstr "nombre de paquets ICMP à envoyer" 822msgstr "nombre de paquets ICMP à envoyer"
1019 823
1020#: plugins/check_fping.c:482
1021msgid "Target timeout (ms)" 824msgid "Target timeout (ms)"
1022msgstr "" 825msgstr ""
1023 826
1024#: plugins/check_fping.c:484
1025msgid "Interval (ms) between sending packets" 827msgid "Interval (ms) between sending packets"
1026msgstr "" 828msgstr ""
1027 829
1028#: plugins/check_fping.c:486
1029msgid "name or IP Address of sourceip" 830msgid "name or IP Address of sourceip"
1030msgstr "" 831msgstr ""
1031 832
1032#: plugins/check_fping.c:488
1033msgid "source interface name" 833msgid "source interface name"
1034msgstr "" 834msgstr ""
1035 835
1036#: plugins/check_fping.c:491
1037#, c-format 836#, c-format
1038msgid "" 837msgid ""
1039"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time " 838"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time "
@@ -1042,63 +841,50 @@ msgstr ""
1042"Le seuil est <rta>,<pl>%% ou <rta> est le temps moyen pour l'aller retour " 841"Le seuil est <rta>,<pl>%% ou <rta> est le temps moyen pour l'aller retour "
1043"(ms)" 842"(ms)"
1044 843
1045#: plugins/check_fping.c:492
1046msgid "" 844msgid ""
1047"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of" 845"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of"
1048msgstr "" 846msgstr ""
1049"qui déclenche résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le pourcentage " 847"qui déclenche résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le pourcentage "
1050"de" 848"de"
1051 849
1052#: plugins/check_fping.c:493
1053msgid "packet loss to trigger an alarm state." 850msgid "packet loss to trigger an alarm state."
1054msgstr "paquets perdu pour déclencher une alarme." 851msgstr "paquets perdu pour déclencher une alarme."
1055 852
1056#: plugins/check_fping.c:496
1057msgid "IPv4 is used by default. Specify -6 to use IPv6." 853msgid "IPv4 is used by default. Specify -6 to use IPv6."
1058msgstr "" 854msgstr ""
1059 855
1060#: plugins/check_game.c:111
1061#, c-format 856#, c-format
1062msgid "CRITICAL - Host type parameter incorrect!\n" 857msgid "CRITICAL - Host type parameter incorrect!\n"
1063msgstr "CRITIQUE - Argument de type hôte incorrect!\n" 858msgstr "CRITIQUE - Argument de type hôte incorrect!\n"
1064 859
1065#: plugins/check_game.c:126
1066#, c-format 860#, c-format
1067msgid "CRITICAL - Host not found\n" 861msgid "CRITICAL - Host not found\n"
1068msgstr "CRITIQUE - Hôte non trouvé\n" 862msgstr "CRITIQUE - Hôte non trouvé\n"
1069 863
1070#: plugins/check_game.c:130
1071#, c-format 864#, c-format
1072msgid "CRITICAL - Game server down or unavailable\n" 865msgid "CRITICAL - Game server down or unavailable\n"
1073msgstr "CRITIQUE - Serveur de jeux en panne ou non disponible\n" 866msgstr "CRITIQUE - Serveur de jeux en panne ou non disponible\n"
1074 867
1075#: plugins/check_game.c:134
1076#, c-format 868#, c-format
1077msgid "CRITICAL - Game server timeout\n" 869msgid "CRITICAL - Game server timeout\n"
1078msgstr "CRITIQUE - Temps d'attente pour le serveur de jeux dépassé\n" 870msgstr "CRITIQUE - Temps d'attente pour le serveur de jeux dépassé\n"
1079 871
1080#: plugins/check_game.c:297
1081#, c-format 872#, c-format
1082msgid "This plugin tests game server connections with the specified host." 873msgid "This plugin tests game server connections with the specified host."
1083msgstr "Le plugin teste la connexion au serveur de jeux avec l'hôte spécifié." 874msgstr "Le plugin teste la connexion au serveur de jeux avec l'hôte spécifié."
1084 875
1085#: plugins/check_game.c:307
1086msgid "Optional port of which to connect" 876msgid "Optional port of which to connect"
1087msgstr "" 877msgstr ""
1088 878
1089#: plugins/check_game.c:309
1090msgid "Field number in raw qstat output that contains game name" 879msgid "Field number in raw qstat output that contains game name"
1091msgstr "" 880msgstr ""
1092 881
1093#: plugins/check_game.c:311
1094msgid "Field number in raw qstat output that contains map name" 882msgid "Field number in raw qstat output that contains map name"
1095msgstr "" 883msgstr ""
1096 884
1097#: plugins/check_game.c:313
1098msgid "Field number in raw qstat output that contains ping time" 885msgid "Field number in raw qstat output that contains ping time"
1099msgstr "" 886msgstr ""
1100 887
1101#: plugins/check_game.c:319
1102msgid "" 888msgid ""
1103"This plugin uses the 'qstat' command, the popular game server status query " 889"This plugin uses the 'qstat' command, the popular game server status query "
1104"tool." 890"tool."
@@ -1106,789 +892,706 @@ msgstr ""
1106"Ce plugin utilise la commande 'qstat', un programme répandu pour questioner " 892"Ce plugin utilise la commande 'qstat', un programme répandu pour questioner "
1107"les serveurs de jeux." 893"les serveurs de jeux."
1108 894
1109#: plugins/check_game.c:320
1110msgid "" 895msgid ""
1111"If you don't have the package installed, you will need to download it from" 896"If you don't have the package installed, you will need to download it from"
1112msgstr "" 897msgstr ""
1113"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis" 898"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis"
1114 899
1115#: plugins/check_game.c:321 900#, fuzzy
1116msgid "" 901msgid "https://github.com/multiplay/qstat before you can use this plugin."
1117"http://www.activesw.com/people/steve/qstat.html before you can use this "
1118"plugin."
1119msgstr "" 902msgstr ""
1120"http://www.activesw.com/people/steve/qstat.html avant de pouvoir utiliser ce " 903"http://www.activesw.com/people/steve/qstat.html avant de pouvoir utiliser ce "
1121"plugin." 904"plugin."
1122 905
1123#: plugins/check_hpjd.c:239
1124msgid "Paper Jam" 906msgid "Paper Jam"
1125msgstr "Bourrage Papier" 907msgstr "Bourrage Papier"
1126 908
1127#: plugins/check_hpjd.c:243
1128msgid "Out of Paper" 909msgid "Out of Paper"
1129msgstr "Plus de Papier" 910msgstr "Plus de Papier"
1130 911
1131#: plugins/check_hpjd.c:248
1132msgid "Printer Offline" 912msgid "Printer Offline"
1133msgstr "Imprimante hors ligne" 913msgstr "Imprimante hors ligne"
1134 914
1135#: plugins/check_hpjd.c:253
1136msgid "Peripheral Error" 915msgid "Peripheral Error"
1137msgstr "Erreur du périphérique" 916msgstr "Erreur du périphérique"
1138 917
1139#: plugins/check_hpjd.c:257
1140msgid "Intervention Required" 918msgid "Intervention Required"
1141msgstr "Intervention Requise" 919msgstr "Intervention Requise"
1142 920
1143#: plugins/check_hpjd.c:261
1144msgid "Toner Low" 921msgid "Toner Low"
1145msgstr "Toner Faible" 922msgstr "Toner Faible"
1146 923
1147#: plugins/check_hpjd.c:265
1148msgid "Insufficient Memory" 924msgid "Insufficient Memory"
1149msgstr "Mémoire Insuffisante" 925msgstr "Mémoire Insuffisante"
1150 926
1151#: plugins/check_hpjd.c:269
1152msgid "A Door is Open" 927msgid "A Door is Open"
1153msgstr "Une porte est ouverte" 928msgstr "Une porte est ouverte"
1154 929
1155#: plugins/check_hpjd.c:273
1156msgid "Output Tray is Full" 930msgid "Output Tray is Full"
1157msgstr "Le bac de sortie est plein" 931msgstr "Le bac de sortie est plein"
1158 932
1159#: plugins/check_hpjd.c:277
1160msgid "Data too Slow for Engine" 933msgid "Data too Slow for Engine"
1161msgstr "Le données arrivent trop lentement pour l'imprimante" 934msgstr "Le données arrivent trop lentement pour l'imprimante"
1162 935
1163#: plugins/check_hpjd.c:281
1164msgid "Unknown Paper Error" 936msgid "Unknown Paper Error"
1165msgstr "Erreur de papier inconnue" 937msgstr "Erreur de papier inconnue"
1166 938
1167#: plugins/check_hpjd.c:286
1168#, c-format 939#, c-format
1169msgid "Printer ok - (%s)\n" 940msgid "Printer ok - (%s)\n"
1170msgstr "Imprimante ok - (%s)\n" 941msgstr "Imprimante ok - (%s)\n"
1171 942
1172#: plugins/check_hpjd.c:391 943#, fuzzy
944msgid "Port must be a positive short integer"
945msgstr "Le numéro du port doit être un entier positif"
946
1173msgid "This plugin tests the STATUS of an HP printer with a JetDirect card." 947msgid "This plugin tests the STATUS of an HP printer with a JetDirect card."
1174msgstr "Ce plugin teste l'état d'une imprimante HP avec une carte JetDirect." 948msgstr "Ce plugin teste l'état d'une imprimante HP avec une carte JetDirect."
1175 949
1176#: plugins/check_hpjd.c:392
1177msgid "Net-snmp must be installed on the computer running the plugin." 950msgid "Net-snmp must be installed on the computer running the plugin."
1178msgstr "Net-snmp doit être installé sur l'ordinateur qui exécute le plugin." 951msgstr "Net-snmp doit être installé sur l'ordinateur qui exécute le plugin."
1179 952
1180#: plugins/check_hpjd.c:402
1181msgid "The SNMP community name " 953msgid "The SNMP community name "
1182msgstr "Le nom de la communauté SNMP " 954msgstr "Le nom de la communauté SNMP "
1183 955
1184#: plugins/check_hpjd.c:403
1185#, c-format 956#, c-format
1186msgid "(default=%s)" 957msgid "(default=%s)"
1187msgstr "(défaut=%s)" 958msgstr "(défaut=%s)"
1188 959
1189#: plugins/check_http.c:189 960#, fuzzy
961msgid "Specify the port to check "
962msgstr "Nom de l'hôte à vérifier"
963
964#, fuzzy
965msgid "Disable paper check "
966msgstr "Variable a vérifier"
967
1190msgid "file does not exist or is not readable" 968msgid "file does not exist or is not readable"
1191msgstr "" 969msgstr ""
1192 970
1193#: plugins/check_http.c:310 plugins/check_http.c:315 plugins/check_http.c:321
1194#: plugins/check_smtp.c:600 plugins/check_tcp.c:576 plugins/check_tcp.c:580
1195#: plugins/check_tcp.c:586
1196msgid "Invalid certificate expiration period" 971msgid "Invalid certificate expiration period"
1197msgstr "Période d'expiration du certificat invalide" 972msgstr "Période d'expiration du certificat invalide"
1198 973
1199#: plugins/check_http.c:348
1200msgid "" 974msgid ""
1201"Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 " 975"Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional "
1202"(SSLv3)" 976"'+' suffix)"
1203msgstr "" 977msgstr ""
1204 978
1205#: plugins/check_http.c:354 plugins/check_tcp.c:599
1206msgid "Invalid option - SSL is not available" 979msgid "Invalid option - SSL is not available"
1207msgstr "Option invalide - SSL n'est pas disponible" 980msgstr "Option invalide - SSL n'est pas disponible"
1208 981
1209#: plugins/check_http.c:375 982msgid "Invalid max_redirs count"
983msgstr ""
984
1210msgid "Invalid onredirect option" 985msgid "Invalid onredirect option"
1211msgstr "" 986msgstr ""
1212 987
1213#: plugins/check_http.c:377
1214#, c-format 988#, c-format
1215msgid "option f:%d \n" 989msgid "option f:%d \n"
1216msgstr "option f:%d \n" 990msgstr "option f:%d \n"
1217 991
1218#: plugins/check_http.c:398
1219msgid "Invalid port number" 992msgid "Invalid port number"
1220msgstr "Numéro de port invalide" 993msgstr "Numéro de port invalide"
1221 994
1222#: plugins/check_http.c:450
1223#, c-format 995#, c-format
1224msgid "Could Not Compile Regular Expression: %s" 996msgid "Could Not Compile Regular Expression: %s"
1225msgstr "Impossible de compiler l'expression rationnelle: %s" 997msgstr "Impossible de compiler l'expression rationnelle: %s"
1226 998
1227#: plugins/check_http.c:464 plugins/check_ntp.c:722
1228#: plugins/check_ntp_peer.c:513 plugins/check_ntp_time.c:512
1229#: plugins/check_smtp.c:621 plugins/check_ssh.c:149 plugins/check_tcp.c:477
1230msgid "IPv6 support not available" 999msgid "IPv6 support not available"
1231msgstr "Support IPv6 non disponible" 1000msgstr "Support IPv6 non disponible"
1232 1001
1233#: plugins/check_http.c:529 plugins/check_ping.c:422
1234msgid "You must specify a server address or host name" 1002msgid "You must specify a server address or host name"
1235msgstr "Vous devez spécifier une adresse ou un nom d'hôte" 1003msgstr "Vous devez spécifier une adresse ou un nom d'hôte"
1236 1004
1237#: plugins/check_http.c:543
1238msgid "" 1005msgid ""
1239"If you use a client certificate you must also specify a private key file" 1006"If you use a client certificate you must also specify a private key file"
1240msgstr "" 1007msgstr ""
1241 1008
1242#: plugins/check_http.c:667 plugins/check_http.c:835
1243msgid "HTTP UNKNOWN - Memory allocation error\n" 1009msgid "HTTP UNKNOWN - Memory allocation error\n"
1244msgstr "HTTP INCONNU - Impossible d'allouer la mémoire\n" 1010msgstr "HTTP INCONNU - Impossible d'allouer la mémoire\n"
1245 1011
1246#: plugins/check_http.c:739
1247#, c-format 1012#, c-format
1248msgid "%sServer date unknown, " 1013msgid "%sServer date unknown, "
1249msgstr "%sDate du serveur inconnue, " 1014msgstr "%sDate du serveur inconnue, "
1250 1015
1251#: plugins/check_http.c:742
1252#, c-format 1016#, c-format
1253msgid "%sDocument modification date unknown, " 1017msgid "%sDocument modification date unknown, "
1254msgstr "%sDate de modification du document inconnue, " 1018msgstr "%sDate de modification du document inconnue, "
1255 1019
1256#: plugins/check_http.c:749
1257#, c-format 1020#, c-format
1258msgid "%sServer date \"%100s\" unparsable, " 1021msgid "%sServer date \"%100s\" unparsable, "
1259msgstr "%sDate du serveur \"%100s\" illisible, " 1022msgstr "%sDate du serveur \"%100s\" illisible, "
1260 1023
1261#: plugins/check_http.c:752
1262#, c-format 1024#, c-format
1263msgid "%sDocument date \"%100s\" unparsable, " 1025msgid "%sDocument date \"%100s\" unparsable, "
1264msgstr "%sDate du document \"%100s\" illisible, " 1026msgstr "%sDate du document \"%100s\" illisible, "
1265 1027
1266#: plugins/check_http.c:755
1267#, c-format 1028#, c-format
1268msgid "%sDocument is %d seconds in the future, " 1029msgid "%sDocument is %d seconds in the future, "
1269msgstr "%sLa date du document est %d secondes dans le futur, " 1030msgstr "%sLa date du document est %d secondes dans le futur, "
1270 1031
1271#: plugins/check_http.c:760
1272#, c-format 1032#, c-format
1273msgid "%sLast modified %.1f days ago, " 1033msgid "%sLast modified %.1f days ago, "
1274msgstr "%sDernière modification %.1f jours auparavant, " 1034msgstr "%sDernière modification %.1f jours auparavant, "
1275 1035
1276#: plugins/check_http.c:763
1277#, c-format 1036#, c-format
1278msgid "%sLast modified %d:%02d:%02d ago, " 1037msgid "%sLast modified %d:%02d:%02d ago, "
1279msgstr "%sDernière modification %d:%02d:%02d auparavant, " 1038msgstr "%sDernière modification %d:%02d:%02d auparavant, "
1280 1039
1281#: plugins/check_http.c:876
1282msgid "HTTP CRITICAL - Unable to open TCP socket\n" 1040msgid "HTTP CRITICAL - Unable to open TCP socket\n"
1283msgstr "HTTP CRITIQUE - Impossible d'ouvrir un socket TCP\n" 1041msgstr "HTTP CRITIQUE - Impossible d'ouvrir un socket TCP\n"
1284 1042
1285#: plugins/check_http.c:995 1043#, fuzzy
1044msgid "HTTP UNKNOWN - Could not allocate memory for full_page\n"
1045msgstr "HTTP INCONNU - Impossible d'allouer une adresse\n"
1046
1286msgid "HTTP CRITICAL - Error on receive\n" 1047msgid "HTTP CRITICAL - Error on receive\n"
1287msgstr "HTTP CRITIQUE - Erreur dans la réception\n" 1048msgstr "HTTP CRITIQUE - Erreur dans la réception\n"
1288 1049
1289#: plugins/check_http.c:1005
1290msgid "HTTP CRITICAL - No data received from host\n" 1050msgid "HTTP CRITICAL - No data received from host\n"
1291msgstr "HTTP CRITIQUE - Pas de données reçues de l'hôte\n" 1051msgstr "HTTP CRITIQUE - Pas de données reçues de l'hôte\n"
1292 1052
1293#: plugins/check_http.c:1056
1294#, c-format 1053#, c-format
1295msgid "Invalid HTTP response received from host: %s\n" 1054msgid "Invalid HTTP response received from host: %s\n"
1296msgstr "Réponse HTTP reçue de l'hôte invalide: %s\n" 1055msgstr "Réponse HTTP reçue de l'hôte invalide: %s\n"
1297 1056
1298#: plugins/check_http.c:1060
1299#, c-format 1057#, c-format
1300msgid "Invalid HTTP response received from host on port %d: %s\n" 1058msgid "Invalid HTTP response received from host on port %d: %s\n"
1301msgstr "Réponse HTTP reçue de l'hôte sur le port %d invalide: %s\n" 1059msgstr "Réponse HTTP reçue de l'hôte sur le port %d invalide: %s\n"
1302 1060
1303#: plugins/check_http.c:1069 1061#, c-format
1062msgid ""
1063"%s\n"
1064"%s"
1065msgstr ""
1066
1304#, c-format 1067#, c-format
1305msgid "Status line output matched \"%s\" - " 1068msgid "Status line output matched \"%s\" - "
1306msgstr "La ligne d'état correspond à \"%s\" - " 1069msgstr "La ligne d'état correspond à \"%s\" - "
1307 1070
1308#: plugins/check_http.c:1080
1309#, c-format 1071#, c-format
1310msgid "HTTP CRITICAL: Invalid Status Line (%s)\n" 1072msgid "HTTP CRITICAL: Invalid Status Line (%s)\n"
1311msgstr "HTTP CRITIQUE: Ligne d'état non valide (%s)\n" 1073msgstr "HTTP CRITIQUE: Ligne d'état non valide (%s)\n"
1312 1074
1313#: plugins/check_http.c:1087
1314#, c-format 1075#, c-format
1315msgid "HTTP CRITICAL: Invalid Status (%s)\n" 1076msgid "HTTP CRITICAL: Invalid Status (%s)\n"
1316msgstr "HTTP CRITIQUE: Etat Invalide (%s)\n" 1077msgstr "HTTP CRITIQUE: Etat Invalide (%s)\n"
1317 1078
1318#: plugins/check_http.c:1091 plugins/check_http.c:1096
1319#: plugins/check_http.c:1106 plugins/check_http.c:1110
1320#, c-format 1079#, c-format
1321msgid "%s - " 1080msgid "%s - "
1322msgstr "" 1081msgstr ""
1323 1082
1324#: plugins/check_http.c:1129
1325#, fuzzy, c-format 1083#, fuzzy, c-format
1326msgid "%sheader '%s' not found on '%s://%s:%d%s', " 1084msgid "%sheader '%s' not found on '%s://%s:%d%s', "
1327msgstr "%schaîne non trouvée, " 1085msgstr "%schaîne non trouvée, "
1328 1086
1329#: plugins/check_http.c:1141
1330#, fuzzy, c-format 1087#, fuzzy, c-format
1331msgid "%sstring '%s' not found on '%s://%s:%d%s', " 1088msgid "%sstring '%s' not found on '%s://%s:%d%s', "
1332msgstr "%schaîne non trouvée, " 1089msgstr "%schaîne non trouvée, "
1333 1090
1334#: plugins/check_http.c:1154
1335#, c-format 1091#, c-format
1336msgid "%spattern not found, " 1092msgid "%spattern not found, "
1337msgstr "%sexpression non trouvée, " 1093msgstr "%sexpression non trouvée, "
1338 1094
1339#: plugins/check_http.c:1156
1340#, c-format 1095#, c-format
1341msgid "%spattern found, " 1096msgid "%spattern found, "
1342msgstr "%sexpression trouvée, " 1097msgstr "%sexpression trouvée, "
1343 1098
1344#: plugins/check_http.c:1162
1345#, c-format 1099#, c-format
1346msgid "%sExecute Error: %s, " 1100msgid "%sExecute Error: %s, "
1347msgstr "%sErreur d'exécution: %s, " 1101msgstr "%sErreur d'exécution: %s, "
1348 1102
1349#: plugins/check_http.c:1178
1350#, c-format 1103#, c-format
1351msgid "%spage size %d too large, " 1104msgid "%spage size %d too large, "
1352msgstr "%sla taille de la page est trop grande (%d), " 1105msgstr "%sla taille de la page est trop grande (%d), "
1353 1106
1354#: plugins/check_http.c:1181
1355#, c-format 1107#, c-format
1356msgid "%spage size %d too small, " 1108msgid "%spage size %d too small, "
1357msgstr "%sla taille de la page est trop petite (%d), " 1109msgstr "%sla taille de la page est trop petite (%d), "
1358 1110
1359#: plugins/check_http.c:1194
1360#, fuzzy, c-format 1111#, fuzzy, c-format
1361msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s" 1112msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"
1362msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s" 1113msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s"
1363 1114
1364#: plugins/check_http.c:1206
1365#, c-format 1115#, c-format
1366msgid "%s - %d bytes in %.3f second response time %s|%s %s" 1116msgid "%s - %d bytes in %.3f second response time %s|%s %s"
1367msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s" 1117msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s"
1368 1118
1369#: plugins/check_http.c:1244
1370msgid "HTTP UNKNOWN - Could not allocate addr\n" 1119msgid "HTTP UNKNOWN - Could not allocate addr\n"
1371msgstr "HTTP INCONNU - Impossible d'allouer une adresse\n" 1120msgstr "HTTP INCONNU - Impossible d'allouer une adresse\n"
1372 1121
1373#: plugins/check_http.c:1248 plugins/check_http.c:1279
1374msgid "HTTP UNKNOWN - Could not allocate URL\n" 1122msgid "HTTP UNKNOWN - Could not allocate URL\n"
1375msgstr "HTTP INCONNU - Impossible d'allouer l'URL\n" 1123msgstr "HTTP INCONNU - Impossible d'allouer l'URL\n"
1376 1124
1377#: plugins/check_http.c:1257
1378#, c-format 1125#, c-format
1379msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n" 1126msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n"
1380msgstr "" 1127msgstr ""
1381"HTTP INCONNU - Impossible de trouver l'endroit de la redirection - %s%s\n" 1128"HTTP INCONNU - Impossible de trouver l'endroit de la redirection - %s%s\n"
1382 1129
1383#: plugins/check_http.c:1272
1384#, c-format 1130#, c-format
1385msgid "HTTP UNKNOWN - Empty redirect location%s\n" 1131msgid "HTTP UNKNOWN - Empty redirect location%s\n"
1386msgstr "HTTP INCONNU - endroit de redirection vide%s\n" 1132msgstr "HTTP INCONNU - endroit de redirection vide%s\n"
1387 1133
1388#: plugins/check_http.c:1322
1389#, c-format 1134#, c-format
1390msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n" 1135msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n"
1391msgstr "" 1136msgstr ""
1392"HTTP INCONNU - Impossible de définir l'endroit de la redirection - %s%s\n" 1137"HTTP INCONNU - Impossible de définir l'endroit de la redirection - %s%s\n"
1393 1138
1394#: plugins/check_http.c:1332
1395#, c-format 1139#, c-format
1396msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n" 1140msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n"
1397msgstr "" 1141msgstr ""
1398"HTTP AVERTISSEMENT - le niveau maximum de redirection %d à été dépassé - " 1142"HTTP AVERTISSEMENT - le niveau maximum de redirection %d à été dépassé - "
1399"%s://%s:%d%s%s\n" 1143"%s://%s:%d%s%s\n"
1400 1144
1401#: plugins/check_http.c:1340 1145#, fuzzy, c-format
1402#, c-format 1146msgid "HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1403msgid "HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1404msgstr "" 1147msgstr ""
1405"HTTP AVERTISSEMENT - la redirection crée une boucle infinie - %s://%s:%d%s" 1148"HTTP AVERTISSEMENT - la redirection crée une boucle infinie - %s://%s:"
1406"%s\n" 1149"%d%s%s\n"
1407 1150
1408#: plugins/check_http.c:1361
1409#, c-format 1151#, c-format
1410msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n" 1152msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"
1411msgstr "HTTP INCONNU - Redirection à un port supérieur à %d - %s://%s:%d%s%s\n" 1153msgstr "HTTP INCONNU - Redirection à un port supérieur à %d - %s://%s:%d%s%s\n"
1412 1154
1413#: plugins/check_http.c:1366
1414#, c-format 1155#, c-format
1415msgid "Redirection to %s://%s:%d%s\n" 1156msgid "Redirection to %s://%s:%d%s\n"
1416msgstr "Redirection vers %s://%s:%d%s\n" 1157msgstr "Redirection vers %s://%s:%d%s\n"
1417 1158
1418#: plugins/check_http.c:1440
1419msgid "This plugin tests the HTTP service on the specified host. It can test" 1159msgid "This plugin tests the HTTP service on the specified host. It can test"
1420msgstr "" 1160msgstr ""
1421"Ce plugin teste le service HTTP sur l'hôte spécifié. Il peut tester les" 1161"Ce plugin teste le service HTTP sur l'hôte spécifié. Il peut tester les"
1422 1162
1423#: plugins/check_http.c:1441
1424msgid "normal (http) and secure (https) servers, follow redirects, search for" 1163msgid "normal (http) and secure (https) servers, follow redirects, search for"
1425msgstr "" 1164msgstr ""
1426"serveurs normaux (http) et sécurisés (https), suivre les redirections, " 1165"serveurs normaux (http) et sécurisés (https), suivre les redirections, "
1427"rechercher des" 1166"rechercher des"
1428 1167
1429#: plugins/check_http.c:1442
1430msgid "strings and regular expressions, check connection times, and report on" 1168msgid "strings and regular expressions, check connection times, and report on"
1431msgstr "" 1169msgstr ""
1432"chaînes de caractères et expressions rationnelles, vérifier le temps de " 1170"chaînes de caractères et expressions rationnelles, vérifier le temps de "
1433"réponse" 1171"réponse"
1434 1172
1435#: plugins/check_http.c:1443
1436msgid "certificate expiration times." 1173msgid "certificate expiration times."
1437msgstr "et rapporter la date d'expiration du certificat." 1174msgstr "et rapporter la date d'expiration du certificat."
1438 1175
1439#: plugins/check_http.c:1449 1176#, c-format
1177msgid "In the first form, make an HTTP request."
1178msgstr ""
1179
1180#, c-format
1181msgid ""
1182"In the second form, connect to the server and check the TLS certificate."
1183msgstr ""
1184
1440#, c-format 1185#, c-format
1441msgid "NOTE: One or both of -H and -I must be specified" 1186msgid "NOTE: One or both of -H and -I must be specified"
1442msgstr "NOTE: les paramètres -H et -I peuvent être spécifiés" 1187msgstr "NOTE: les paramètres -H et -I peuvent être spécifiés"
1443 1188
1444#: plugins/check_http.c:1457
1445msgid "Host name argument for servers using host headers (virtual host)" 1189msgid "Host name argument for servers using host headers (virtual host)"
1446msgstr "" 1190msgstr ""
1447 1191
1448#: plugins/check_http.c:1458
1449msgid "Append a port to include it in the header (eg: example.com:5000)" 1192msgid "Append a port to include it in the header (eg: example.com:5000)"
1450msgstr "" 1193msgstr ""
1451 1194
1452#: plugins/check_http.c:1460
1453msgid "" 1195msgid ""
1454"IP address or name (use numeric address if possible to bypass DNS lookup)." 1196"IP address or name (use numeric address if possible to bypass DNS lookup)."
1455msgstr "" 1197msgstr ""
1456 1198
1457#: plugins/check_http.c:1462
1458msgid "Port number (default: " 1199msgid "Port number (default: "
1459msgstr "Numéro du port (défaut: " 1200msgstr "Numéro du port (défaut: "
1460 1201
1461#: plugins/check_http.c:1469
1462msgid "" 1202msgid ""
1463"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents" 1203"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"
1464msgstr "" 1204msgstr ""
1465 1205
1466#: plugins/check_http.c:1470 1206msgid "auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"
1467msgid "auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3)." 1207msgstr ""
1208
1209msgid "1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted."
1468msgstr "" 1210msgstr ""
1469 1211
1470#: plugins/check_http.c:1472
1471msgid "Enable SSL/TLS hostname extension support (SNI)" 1212msgid "Enable SSL/TLS hostname extension support (SNI)"
1472msgstr "" 1213msgstr ""
1473 1214
1474#: plugins/check_http.c:1474
1475msgid "" 1215msgid ""
1476"Minimum number of days a certificate has to be valid. Port defaults to 443" 1216"Minimum number of days a certificate has to be valid. Port defaults to 443"
1477msgstr "" 1217msgstr ""
1478"Nombre de jours minimum pour que le certificat soit valide. Port par défaut " 1218"Nombre de jours minimum pour que le certificat soit valide. Port par défaut "
1479"443" 1219"443"
1480 1220
1481#: plugins/check_http.c:1475 1221msgid ""
1482msgid "(when this option is used the URL is not checked.)" 1222"(when this option is used the URL is not checked by default. You can use"
1223msgstr ""
1224
1225msgid " --continue-after-certificate to override this behavior)"
1226msgstr ""
1227
1228msgid ""
1229"Allows the HTTP check to continue after performing the certificate check."
1230msgstr ""
1231
1232msgid "Does nothing unless -C is used."
1483msgstr "" 1233msgstr ""
1484 1234
1485#: plugins/check_http.c:1477
1486msgid "Name of file that contains the client certificate (PEM format)" 1235msgid "Name of file that contains the client certificate (PEM format)"
1487msgstr "" 1236msgstr ""
1488 1237
1489#: plugins/check_http.c:1478
1490msgid "to be used in establishing the SSL session" 1238msgid "to be used in establishing the SSL session"
1491msgstr "" 1239msgstr ""
1492 1240
1493#: plugins/check_http.c:1480
1494msgid "Name of file containing the private key (PEM format)" 1241msgid "Name of file containing the private key (PEM format)"
1495msgstr "" 1242msgstr ""
1496 1243
1497#: plugins/check_http.c:1481
1498msgid "matching the client certificate" 1244msgid "matching the client certificate"
1499msgstr "" 1245msgstr ""
1500 1246
1501#: plugins/check_http.c:1485
1502msgid "Comma-delimited list of strings, at least one of them is expected in" 1247msgid "Comma-delimited list of strings, at least one of them is expected in"
1503msgstr "" 1248msgstr ""
1504"Liste the chaines de charactères séparées par des virgules, au moins une " 1249"Liste the chaines de charactères séparées par des virgules, au moins une "
1505"d'elles" 1250"d'elles"
1506 1251
1507#: plugins/check_http.c:1486
1508msgid "the first (status) line of the server response (default: " 1252msgid "the first (status) line of the server response (default: "
1509msgstr "est attendue dans la première ligne de réponse du serveur (défaut: " 1253msgstr "est attendue dans la première ligne de réponse du serveur (défaut: "
1510 1254
1511#: plugins/check_http.c:1488
1512msgid "" 1255msgid ""
1513"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)" 1256"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"
1514msgstr "" 1257msgstr ""
1515"Si spécifié, surpasse toute autre logique de status (ex: 3xx, 4xx, 5xx)" 1258"Si spécifié, surpasse toute autre logique de status (ex: 3xx, 4xx, 5xx)"
1516 1259
1517#: plugins/check_http.c:1490
1518#, fuzzy 1260#, fuzzy
1519msgid "String to expect in the response headers" 1261msgid "String to expect in the response headers"
1520msgstr "Chaîne de caractères à attendre en réponse" 1262msgstr "Chaîne de caractères à attendre en réponse"
1521 1263
1522#: plugins/check_http.c:1492
1523msgid "String to expect in the content" 1264msgid "String to expect in the content"
1524msgstr "Chaîne de caractère attendue dans le contenu" 1265msgstr "Chaîne de caractère attendue dans le contenu"
1525 1266
1526#: plugins/check_http.c:1494
1527msgid "URL to GET or POST (default: /)" 1267msgid "URL to GET or POST (default: /)"
1528msgstr "URL pour le GET ou le POST (défaut: /)" 1268msgstr "URL pour le GET ou le POST (défaut: /)"
1529 1269
1530#: plugins/check_http.c:1496
1531msgid "URL encoded http POST data" 1270msgid "URL encoded http POST data"
1532msgstr "" 1271msgstr ""
1533 1272
1534#: plugins/check_http.c:1498
1535msgid "Set HTTP method." 1273msgid "Set HTTP method."
1536msgstr "" 1274msgstr ""
1537 1275
1538#: plugins/check_http.c:1500
1539msgid "Don't wait for document body: stop reading after headers." 1276msgid "Don't wait for document body: stop reading after headers."
1540msgstr "" 1277msgstr ""
1541"Ne pas attendre pour le corps du document: arrêter de lire après les entêtes" 1278"Ne pas attendre pour le corps du document: arrêter de lire après les entêtes"
1542 1279
1543#: plugins/check_http.c:1501
1544msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)" 1280msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)"
1545msgstr "(Veuillez noter qu'un HTTP GET ou POST est effectué, pas un HEAD.)" 1281msgstr "(Veuillez noter qu'un HTTP GET ou POST est effectué, pas un HEAD.)"
1546 1282
1547#: plugins/check_http.c:1503
1548msgid "Warn if document is more than SECONDS old. the number can also be of" 1283msgid "Warn if document is more than SECONDS old. the number can also be of"
1549msgstr "" 1284msgstr ""
1550 1285
1551#: plugins/check_http.c:1504
1552msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days." 1286msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."
1553msgstr "" 1287msgstr ""
1554 1288
1555#: plugins/check_http.c:1506
1556msgid "specify Content-Type header media type when POSTing\n" 1289msgid "specify Content-Type header media type when POSTing\n"
1557msgstr "" 1290msgstr ""
1558 1291
1559#: plugins/check_http.c:1509
1560msgid "Allow regex to span newlines (must precede -r or -R)" 1292msgid "Allow regex to span newlines (must precede -r or -R)"
1561msgstr "" 1293msgstr ""
1562 1294
1563#: plugins/check_http.c:1511
1564msgid "Search page for regex STRING" 1295msgid "Search page for regex STRING"
1565msgstr "" 1296msgstr ""
1566 1297
1567#: plugins/check_http.c:1513
1568msgid "Search page for case-insensitive regex STRING" 1298msgid "Search page for case-insensitive regex STRING"
1569msgstr "" 1299msgstr ""
1570 1300
1571#: plugins/check_http.c:1515
1572msgid "Return CRITICAL if found, OK if not\n" 1301msgid "Return CRITICAL if found, OK if not\n"
1573msgstr "" 1302msgstr ""
1574 1303
1575#: plugins/check_http.c:1518
1576msgid "Username:password on sites with basic authentication" 1304msgid "Username:password on sites with basic authentication"
1577msgstr "" 1305msgstr ""
1578 1306
1579#: plugins/check_http.c:1520
1580msgid "Username:password on proxy-servers with basic authentication" 1307msgid "Username:password on proxy-servers with basic authentication"
1581msgstr "" 1308msgstr ""
1582 1309
1583#: plugins/check_http.c:1522
1584msgid "String to be sent in http header as \"User Agent\"" 1310msgid "String to be sent in http header as \"User Agent\""
1585msgstr "" 1311msgstr ""
1586 1312
1587#: plugins/check_http.c:1524
1588msgid "" 1313msgid ""
1589"Any other tags to be sent in http header. Use multiple times for additional " 1314"Any other tags to be sent in http header. Use multiple times for additional "
1590"headers" 1315"headers"
1591msgstr "" 1316msgstr ""
1592 1317
1593#: plugins/check_http.c:1526
1594msgid "Print additional performance data" 1318msgid "Print additional performance data"
1595msgstr "" 1319msgstr ""
1596 1320
1597#: plugins/check_http.c:1528 1321msgid "Print body content below status line"
1322msgstr ""
1323
1598msgid "Wrap output in HTML link (obsoleted by urlize)" 1324msgid "Wrap output in HTML link (obsoleted by urlize)"
1599msgstr "" 1325msgstr ""
1600 1326
1601#: plugins/check_http.c:1530
1602msgid "How to handle redirected pages. sticky is like follow but stick to the" 1327msgid "How to handle redirected pages. sticky is like follow but stick to the"
1603msgstr "" 1328msgstr ""
1604 1329
1605#: plugins/check_http.c:1531
1606msgid "specified IP address. stickyport also ensures port stays the same." 1330msgid "specified IP address. stickyport also ensures port stays the same."
1607msgstr "" 1331msgstr ""
1608 1332
1609#: plugins/check_http.c:1533 1333#, fuzzy
1334msgid "Maximal number of redirects (default: "
1335msgstr "PROCS - nombre de processus (défaut)"
1336
1610msgid "Minimum page size required (bytes) : Maximum page size required (bytes)" 1337msgid "Minimum page size required (bytes) : Maximum page size required (bytes)"
1611msgstr "" 1338msgstr ""
1612 1339
1613#: plugins/check_http.c:1543
1614msgid "This plugin will attempt to open an HTTP connection with the host." 1340msgid "This plugin will attempt to open an HTTP connection with the host."
1615msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte." 1341msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte."
1616 1342
1617#: plugins/check_http.c:1544
1618msgid "" 1343msgid ""
1619"Successful connects return STATE_OK, refusals and timeouts return " 1344"Successful connects return STATE_OK, refusals and timeouts return "
1620"STATE_CRITICAL" 1345"STATE_CRITICAL"
1621msgstr "" 1346msgstr ""
1622 1347
1623#: plugins/check_http.c:1545
1624msgid "" 1348msgid ""
1625"other errors return STATE_UNKNOWN. Successful connects, but incorrect " 1349"other errors return STATE_UNKNOWN. Successful connects, but incorrect "
1626"reponse" 1350"response"
1627msgstr "" 1351msgstr ""
1628 1352
1629#: plugins/check_http.c:1546
1630msgid "" 1353msgid ""
1631"messages from the host result in STATE_WARNING return values. If you are" 1354"messages from the host result in STATE_WARNING return values. If you are"
1632msgstr "" 1355msgstr ""
1633 1356
1634#: plugins/check_http.c:1547
1635msgid "" 1357msgid ""
1636"checking a virtual server that uses 'host headers' you must supply the FQDN" 1358"checking a virtual server that uses 'host headers' you must supply the FQDN"
1637msgstr "" 1359msgstr ""
1638 1360
1639#: plugins/check_http.c:1548
1640msgid "(fully qualified domain name) as the [host_name] argument." 1361msgid "(fully qualified domain name) as the [host_name] argument."
1641msgstr "" 1362msgstr ""
1642 1363
1643#: plugins/check_http.c:1552
1644msgid "This plugin can also check whether an SSL enabled web server is able to" 1364msgid "This plugin can also check whether an SSL enabled web server is able to"
1645msgstr "" 1365msgstr ""
1646 1366
1647#: plugins/check_http.c:1553
1648msgid "serve content (optionally within a specified time) or whether the X509 " 1367msgid "serve content (optionally within a specified time) or whether the X509 "
1649msgstr "" 1368msgstr ""
1650 1369
1651#: plugins/check_http.c:1554
1652msgid "certificate is still valid for the specified number of days." 1370msgid "certificate is still valid for the specified number of days."
1653msgstr "" 1371msgstr ""
1654 1372
1655#: plugins/check_http.c:1556
1656#, fuzzy 1373#, fuzzy
1657msgid "Please note that this plugin does not check if the presented server" 1374msgid "Please note that this plugin does not check if the presented server"
1658msgstr "Ce plugin vérifie le service ntp sur l'hôte" 1375msgstr "Ce plugin vérifie le service ntp sur l'hôte"
1659 1376
1660#: plugins/check_http.c:1557
1661msgid "certificate matches the hostname of the server, or if the certificate" 1377msgid "certificate matches the hostname of the server, or if the certificate"
1662msgstr "" 1378msgstr ""
1663 1379
1664#: plugins/check_http.c:1558
1665msgid "has a valid chain of trust to one of the locally installed CAs." 1380msgid "has a valid chain of trust to one of the locally installed CAs."
1666msgstr "" 1381msgstr ""
1667 1382
1668#: plugins/check_http.c:1562
1669msgid "" 1383msgid ""
1670"When the 'www.verisign.com' server returns its content within 5 seconds," 1384"When the 'www.verisign.com' server returns its content within 5 seconds,"
1671msgstr "" 1385msgstr ""
1672 1386
1673#: plugins/check_http.c:1563
1674msgid "" 1387msgid ""
1675"a STATE_OK will be returned. When the server returns its content but exceeds" 1388"a STATE_OK will be returned. When the server returns its content but exceeds"
1676msgstr "" 1389msgstr ""
1677 1390
1678#: plugins/check_http.c:1564
1679msgid "" 1391msgid ""
1680"the 5-second threshold, a STATE_WARNING will be returned. When an error " 1392"the 5-second threshold, a STATE_WARNING will be returned. When an error "
1681"occurs," 1393"occurs,"
1682msgstr "" 1394msgstr ""
1683 1395
1684#: plugins/check_http.c:1565
1685msgid "a STATE_CRITICAL will be returned." 1396msgid "a STATE_CRITICAL will be returned."
1686msgstr "" 1397msgstr ""
1687 1398
1688#: plugins/check_http.c:1568
1689msgid "" 1399msgid ""
1690"When the certificate of 'www.verisign.com' is valid for more than 14 days," 1400"When the certificate of 'www.verisign.com' is valid for more than 14 days,"
1691msgstr "" 1401msgstr ""
1692 1402
1693#: plugins/check_http.c:1569 plugins/check_http.c:1575
1694msgid "" 1403msgid ""
1695"a STATE_OK is returned. When the certificate is still valid, but for less " 1404"a STATE_OK is returned. When the certificate is still valid, but for less "
1696"than" 1405"than"
1697msgstr "" 1406msgstr ""
1698 1407
1699#: plugins/check_http.c:1570
1700msgid "" 1408msgid ""
1701"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when" 1409"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"
1702msgstr "" 1410msgstr ""
1703 1411
1704#: plugins/check_http.c:1571
1705msgid "the certificate is expired." 1412msgid "the certificate is expired."
1706msgstr "le certificat est expiré." 1413msgstr "le certificat est expiré."
1707 1414
1708#: plugins/check_http.c:1574
1709msgid "" 1415msgid ""
1710"When the certificate of 'www.verisign.com' is valid for more than 30 days," 1416"When the certificate of 'www.verisign.com' is valid for more than 30 days,"
1711msgstr "" 1417msgstr ""
1712 1418
1713#: plugins/check_http.c:1576
1714msgid "30 days, but more than 14 days, a STATE_WARNING is returned." 1419msgid "30 days, but more than 14 days, a STATE_WARNING is returned."
1715msgstr "" 1420msgstr ""
1716 1421
1717#: plugins/check_http.c:1577
1718msgid "" 1422msgid ""
1719"A STATE_CRITICAL will be returned when certificate expires in less than 14 " 1423"A STATE_CRITICAL will be returned when certificate expires in less than 14 "
1720"days" 1424"days"
1721msgstr "" 1425msgstr ""
1722 1426
1723#: plugins/check_ldap.c:133 1427msgid ""
1428"check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j "
1429"CONNECT -H www.verisign.com "
1430msgstr ""
1431
1432msgid ""
1433"all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -"
1434"S(sl) -j CONNECT -H <webserver>"
1435msgstr ""
1436
1437msgid ""
1438"a STATE_CRITICAL will be returned. By adding a colon to the method you can "
1439"set the method used"
1440msgstr ""
1441
1442msgid "inside the proxied connection: -j CONNECT:POST"
1443msgstr ""
1444
1724#, c-format 1445#, c-format
1725msgid "Could not connect to the server at port %i\n" 1446msgid "Could not connect to the server at port %i\n"
1726msgstr "Impossible de se connecter au serveur port %i\n" 1447msgstr "Impossible de se connecter au serveur port %i\n"
1727 1448
1728#: plugins/check_ldap.c:142
1729#, c-format 1449#, c-format
1730msgid "Could not set protocol version %d\n" 1450msgid "Could not set protocol version %d\n"
1731msgstr "Impossible d'utiliser le protocole version %d\n" 1451msgstr "Impossible d'utiliser le protocole version %d\n"
1732 1452
1733#: plugins/check_ldap.c:157
1734#, c-format 1453#, c-format
1735msgid "Could not init TLS at port %i!\n" 1454msgid "Could not init TLS at port %i!\n"
1736msgstr "Impossible d'initialiser TLS sur le port %i!\n" 1455msgstr "Impossible d'initialiser TLS sur le port %i!\n"
1737 1456
1738#: plugins/check_ldap.c:161
1739#, c-format 1457#, c-format
1740msgid "TLS not supported by the libraries!\n" 1458msgid "TLS not supported by the libraries!\n"
1741msgstr "TLS n'est pas supporté!\n" 1459msgstr "TLS n'est pas supporté!\n"
1742 1460
1743#: plugins/check_ldap.c:181
1744#, c-format 1461#, c-format
1745msgid "Could not init startTLS at port %i!\n" 1462msgid "Could not init startTLS at port %i!\n"
1746msgstr "Impossible d'initialiser startTLS sur le port %i!\n" 1463msgstr "Impossible d'initialiser startTLS sur le port %i!\n"
1747 1464
1748#: plugins/check_ldap.c:185
1749#, c-format 1465#, c-format
1750msgid "startTLS not supported by the library, needs LDAPv3!\n" 1466msgid "startTLS not supported by the library, needs LDAPv3!\n"
1751msgstr "" 1467msgstr ""
1752"startTLS n'est pas supporté par la librairie LDAP, j'ai besoin de LDAPv3!\n" 1468"startTLS n'est pas supporté par la librairie LDAP, j'ai besoin de LDAPv3!\n"
1753 1469
1754#: plugins/check_ldap.c:195
1755#, c-format 1470#, c-format
1756msgid "Could not bind to the LDAP server\n" 1471msgid "Could not bind to the LDAP server\n"
1757msgstr "Impossible de se connecter au serveur LDAP\n" 1472msgstr "Impossible de se connecter au serveur LDAP\n"
1758 1473
1759#: plugins/check_ldap.c:204
1760#, c-format 1474#, c-format
1761msgid "Could not search/find objectclasses in %s\n" 1475msgid "Could not search/find objectclasses in %s\n"
1762msgstr "Impossible de chercher/trouver les objectclasses dans %s\n" 1476msgstr "Impossible de chercher/trouver les objectclasses dans %s\n"
1763 1477
1764#: plugins/check_ldap.c:227 1478#, fuzzy, c-format
1479msgid "LDAP %s - found %d entries in %.3f seconds|%s %s\n"
1480msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s"
1481
1765#, c-format 1482#, c-format
1766msgid "LDAP %s - %.3f seconds response time|%s\n" 1483msgid "LDAP %s - %.3f seconds response time|%s\n"
1767msgstr "LDAP %s - %.3f secondes de temps de réponse|%s\n" 1484msgstr "LDAP %s - %.3f secondes de temps de réponse|%s\n"
1768 1485
1769#: plugins/check_ldap.c:339 plugins/check_ldap.c:347
1770#, c-format 1486#, c-format
1771msgid "%s cannot be combined with %s" 1487msgid "%s cannot be combined with %s"
1772msgstr "" 1488msgstr ""
1773 1489
1774#: plugins/check_ldap.c:379
1775msgid "Please specify the host name\n" 1490msgid "Please specify the host name\n"
1776msgstr "Veuillez spécifier le nom de l'hôte\n" 1491msgstr "Veuillez spécifier le nom de l'hôte\n"
1777 1492
1778#: plugins/check_ldap.c:382
1779msgid "Please specify the LDAP base\n" 1493msgid "Please specify the LDAP base\n"
1780msgstr "Veuillez spécifier la base LDAP\n" 1494msgstr "Veuillez spécifier la base LDAP\n"
1781 1495
1782#: plugins/check_ldap.c:411
1783msgid "ldap attribute to search (default: \"(objectclass=*)\"" 1496msgid "ldap attribute to search (default: \"(objectclass=*)\""
1784msgstr "" 1497msgstr ""
1785 1498
1786#: plugins/check_ldap.c:413
1787msgid "ldap base (eg. ou=my unit, o=my org, c=at" 1499msgid "ldap base (eg. ou=my unit, o=my org, c=at"
1788msgstr "" 1500msgstr ""
1789 1501
1790#: plugins/check_ldap.c:415
1791msgid "ldap bind DN (if required)" 1502msgid "ldap bind DN (if required)"
1792msgstr "" 1503msgstr ""
1793 1504
1794#: plugins/check_ldap.c:417 1505msgid ""
1795msgid "ldap password (if required)" 1506"ldap password (if required, or set the password through environment variable "
1507"'LDAP_PASSWORD')"
1796msgstr "" 1508msgstr ""
1797 1509
1798#: plugins/check_ldap.c:419
1799msgid "use starttls mechanism introduced in protocol version 3" 1510msgid "use starttls mechanism introduced in protocol version 3"
1800msgstr "utiliser le fonctionnement starttls du protocole version 3" 1511msgstr "utiliser le fonctionnement starttls du protocole version 3"
1801 1512
1802#: plugins/check_ldap.c:421
1803msgid "use ldaps (ldap v2 ssl method). this also sets the default port to" 1513msgid "use ldaps (ldap v2 ssl method). this also sets the default port to"
1804msgstr "" 1514msgstr ""
1805 1515
1806#: plugins/check_ldap.c:425
1807msgid "use ldap protocol version 2" 1516msgid "use ldap protocol version 2"
1808msgstr "utiliser le protocole ldap version 2" 1517msgstr "utiliser le protocole ldap version 2"
1809 1518
1810#: plugins/check_ldap.c:427
1811msgid "use ldap protocol version 3" 1519msgid "use ldap protocol version 3"
1812msgstr "utiliser le protocole ldap version 3" 1520msgstr "utiliser le protocole ldap version 3"
1813 1521
1814#: plugins/check_ldap.c:428
1815msgid "default protocol version:" 1522msgid "default protocol version:"
1816msgstr "version du protocole par défaut:" 1523msgstr "version du protocole par défaut:"
1817 1524
1818#: plugins/check_ldap.c:439 1525#, fuzzy
1526msgid "Number of found entries to result in warning status"
1527msgstr "Décalage résultant en un avertissement (secondes)"
1528
1529#, fuzzy
1530msgid "Number of found entries to result in critical status"
1531msgstr "Décalage résultant en un état critique (secondes)"
1532
1819msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be" 1533msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be"
1820msgstr "" 1534msgstr ""
1821 1535
1822#: plugins/check_ldap.c:440
1823#, c-format 1536#, c-format
1824msgid "" 1537msgid ""
1825" implied (using default port %i) unless --port=636 is specified. In that " 1538" implied (using default port %i) unless --port=636 is specified. In that "
1826"case\n" 1539"case\n"
1827msgstr "" 1540msgstr ""
1828 1541
1829#: plugins/check_ldap.c:441
1830msgid "'SSL on connect' will be used no matter how the plugin was called." 1542msgid "'SSL on connect' will be used no matter how the plugin was called."
1831msgstr "" 1543msgstr ""
1832 1544
1833#: plugins/check_ldap.c:442
1834msgid "" 1545msgid ""
1835"This detection is deprecated, please use 'check_ldap' with the '--starttls' " 1546"This detection is deprecated, please use 'check_ldap' with the '--starttls' "
1836"or '--ssl' flags" 1547"or '--ssl' flags"
1837msgstr "" 1548msgstr ""
1838 1549
1839#: plugins/check_ldap.c:443
1840msgid "to define the behaviour explicitly instead." 1550msgid "to define the behaviour explicitly instead."
1841msgstr "" 1551msgstr ""
1842 1552
1843#: plugins/check_load.c:87 1553msgid "The parameters --warn-entries and --crit-entries are optional."
1554msgstr ""
1555
1844msgid "Warning threshold must be float or float triplet!\n" 1556msgid "Warning threshold must be float or float triplet!\n"
1845msgstr "Le seuil d'alerte doit être un nombre à virgule flottante!\n" 1557msgstr "Le seuil d'alerte doit être un nombre à virgule flottante!\n"
1846 1558
1847#: plugins/check_load.c:132 plugins/check_load.c:148
1848#, c-format 1559#, c-format
1849msgid "Error opening %s\n" 1560msgid "Error opening %s\n"
1850msgstr "Erreur à l'ouverture de %s\n" 1561msgstr "Erreur à l'ouverture de %s\n"
1851 1562
1852#: plugins/check_load.c:163
1853#, fuzzy, c-format 1563#, fuzzy, c-format
1854msgid "could not parse load from uptime: %s\n" 1564msgid "could not parse load from uptime %s: %d\n"
1855msgstr "Lecture des arguments impossible\n" 1565msgstr "Lecture des arguments impossible\n"
1856 1566
1857#: plugins/check_load.c:169
1858#, c-format 1567#, c-format
1859msgid "Error code %d returned in %s\n" 1568msgid "Error code %d returned in %s\n"
1860msgstr "Le code erreur %d à été retourné par %s\n" 1569msgstr "Le code erreur %d à été retourné par %s\n"
1861 1570
1862#: plugins/check_load.c:184
1863#, c-format 1571#, c-format
1864msgid "Error in getloadavg()\n" 1572msgid "Error in getloadavg()\n"
1865msgstr "Erreur dans la fonction getloadavg()\n" 1573msgstr "Erreur dans la fonction getloadavg()\n"
1866 1574
1867#: plugins/check_load.c:187 plugins/check_load.c:189
1868#, c-format 1575#, c-format
1869msgid "Error processing %s\n" 1576msgid "Error processing %s\n"
1870msgstr "Erreur lors de l'utilisation de %s\n" 1577msgstr "Erreur lors de l'utilisation de %s\n"
1871 1578
1872#: plugins/check_load.c:198
1873#, c-format 1579#, c-format
1874msgid "load average: %.2f, %.2f, %.2f" 1580msgid "load average: %.2f, %.2f, %.2f"
1875msgstr "Charge moyenne: %.2f, %.2f, %.2f" 1581msgstr "Charge moyenne: %.2f, %.2f, %.2f"
1876 1582
1877#: plugins/check_load.c:291
1878#, c-format 1583#, c-format
1879msgid "Critical threshold for %d-minute load average is not specified\n" 1584msgid "Critical threshold for %d-minute load average is not specified\n"
1880msgstr "" 1585msgstr ""
1881"Le seuil critique pour la charge système après %d minutes n'est pas " 1586"Le seuil critique pour la charge système après %d minutes n'est pas "
1882"spécifié\n" 1587"spécifié\n"
1883 1588
1884#: plugins/check_load.c:293
1885#, c-format 1589#, c-format
1886msgid "Warning threshold for %d-minute load average is not specified\n" 1590msgid "Warning threshold for %d-minute load average is not specified\n"
1887msgstr "" 1591msgstr ""
1888"Le seuil d'avertissement pour la charge système après %d minutes n'est pas " 1592"Le seuil d'avertissement pour la charge système après %d minutes n'est pas "
1889"spécifié\n" 1593"spécifié\n"
1890 1594
1891#: plugins/check_load.c:295
1892#, c-format 1595#, c-format
1893msgid "" 1596msgid ""
1894"Parameter inconsistency: %d-minute \"warning load\" is greater than " 1597"Parameter inconsistency: %d-minute \"warning load\" is greater than "
@@ -1897,62 +1600,61 @@ msgstr ""
1897"Arguments Incorrects: %d-minute \"alerte charge système\" est plus grand que " 1600"Arguments Incorrects: %d-minute \"alerte charge système\" est plus grand que "
1898"\"alerte critique charge système\"\n" 1601"\"alerte critique charge système\"\n"
1899 1602
1900#: plugins/check_load.c:311
1901#, c-format 1603#, c-format
1902msgid "This plugin tests the current system load average." 1604msgid "This plugin tests the current system load average."
1903msgstr "Ce plugin teste la charge système actuelle." 1605msgstr "Ce plugin teste la charge système actuelle."
1904 1606
1905#: plugins/check_load.c:321
1906msgid "Exit with WARNING status if load average exceeds WLOADn" 1607msgid "Exit with WARNING status if load average exceeds WLOADn"
1907msgstr "" 1608msgstr ""
1908"Sortir avec un résultat AVERTISSEMENT si la charge moyenne dépasse WLOAD" 1609"Sortir avec un résultat AVERTISSEMENT si la charge moyenne dépasse WLOAD"
1909 1610
1910#: plugins/check_load.c:323
1911msgid "Exit with CRITICAL status if load average exceed CLOADn" 1611msgid "Exit with CRITICAL status if load average exceed CLOADn"
1912msgstr "Sortir avec un résultat CRITIQUE si la charge moyenne excède CLOAD" 1612msgstr "Sortir avec un résultat CRITIQUE si la charge moyenne excède CLOAD"
1913 1613
1914#: plugins/check_load.c:324
1915msgid "the load average format is the same used by \"uptime\" and \"w\"" 1614msgid "the load average format is the same used by \"uptime\" and \"w\""
1916msgstr "" 1615msgstr ""
1917 1616
1918#: plugins/check_load.c:326
1919msgid "Divide the load averages by the number of CPUs (when possible)" 1617msgid "Divide the load averages by the number of CPUs (when possible)"
1920msgstr "" 1618msgstr ""
1921 1619
1922#: plugins/check_mrtg.c:75 1620msgid "Number of processes to show when printing the top consuming processes."
1621msgstr ""
1622
1623msgid "NUMBER_OF_PROCS=0 disables this feature. Default value is 0"
1624msgstr ""
1625
1626#, c-format
1627msgid "'%s' exited with non-zero status.\n"
1628msgstr ""
1629
1630#, c-format
1631msgid "some error occurred getting procs list.\n"
1632msgstr ""
1633
1923msgid "Could not parse arguments\n" 1634msgid "Could not parse arguments\n"
1924msgstr "Lecture des arguments impossible\n" 1635msgstr "Lecture des arguments impossible\n"
1925 1636
1926#: plugins/check_mrtg.c:80
1927#, c-format 1637#, c-format
1928msgid "Unable to open MRTG log file\n" 1638msgid "Unable to open MRTG log file\n"
1929msgstr "Impossible d'ouvrir le fichier de log de MRTG\n" 1639msgstr "Impossible d'ouvrir le fichier de log de MRTG\n"
1930 1640
1931#: plugins/check_mrtg.c:127
1932#, c-format 1641#, c-format
1933msgid "Unable to process MRTG log file\n" 1642msgid "Unable to process MRTG log file\n"
1934msgstr "Impossible de traiter le fichier de log de MRTG\n" 1643msgstr "Impossible de traiter le fichier de log de MRTG\n"
1935 1644
1936#: plugins/check_mrtg.c:135 plugins/check_mrtgtraf.c:136
1937#, c-format 1645#, c-format
1938msgid "MRTG data has expired (%d minutes old)\n" 1646msgid "MRTG data has expired (%d minutes old)\n"
1939msgstr "Les données de MRTG on expirées (vieilles de %d minutes)\n" 1647msgstr "Les données de MRTG on expirées (vieilles de %d minutes)\n"
1940 1648
1941#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1942#: plugins/check_mrtgtraf.c:196
1943msgid "Avg" 1649msgid "Avg"
1944msgstr "Moyenne" 1650msgstr "Moyenne"
1945 1651
1946#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1947#: plugins/check_mrtgtraf.c:196
1948msgid "Max" 1652msgid "Max"
1949msgstr "Max" 1653msgstr "Max"
1950 1654
1951#: plugins/check_mrtg.c:221
1952msgid "Invalid variable number" 1655msgid "Invalid variable number"
1953msgstr "Numéro de la variable invalide" 1656msgstr "Numéro de la variable invalide"
1954 1657
1955#: plugins/check_mrtg.c:256
1956#, c-format 1658#, c-format
1957msgid "" 1659msgid ""
1958"%s is not a valid expiration time\n" 1660"%s is not a valid expiration time\n"
@@ -1961,1061 +1663,833 @@ msgstr ""
1961"%s n'est pas un temps d'expiration valide\n" 1663"%s n'est pas un temps d'expiration valide\n"
1962"Utilisez '%s -h' pour de l'aide supplémentaire\n" 1664"Utilisez '%s -h' pour de l'aide supplémentaire\n"
1963 1665
1964#: plugins/check_mrtg.c:273
1965msgid "Invalid variable number\n" 1666msgid "Invalid variable number\n"
1966msgstr "Numéro de la variable invalide\n" 1667msgstr "Numéro de la variable invalide\n"
1967 1668
1968#: plugins/check_mrtg.c:300
1969msgid "You must supply the variable number" 1669msgid "You must supply the variable number"
1970msgstr "Vous devez fournir le numéro de la variable" 1670msgstr "Vous devez fournir le numéro de la variable"
1971 1671
1972#: plugins/check_mrtg.c:321
1973msgid "" 1672msgid ""
1974"This plugin will check either the average or maximum value of one of the" 1673"This plugin will check either the average or maximum value of one of the"
1975msgstr "Ce plugin va vérifier la moyenne ou le maximum d'une " 1674msgstr "Ce plugin va vérifier la moyenne ou le maximum d'une "
1976 1675
1977#: plugins/check_mrtg.c:322
1978msgid "two variables recorded in an MRTG log file." 1676msgid "two variables recorded in an MRTG log file."
1979msgstr "deux variables du fichier de log de MRTG." 1677msgstr "deux variables du fichier de log de MRTG."
1980 1678
1981#: plugins/check_mrtg.c:332
1982msgid "The MRTG log file containing the data you want to monitor" 1679msgid "The MRTG log file containing the data you want to monitor"
1983msgstr "" 1680msgstr ""
1984 1681
1985#: plugins/check_mrtg.c:334
1986msgid "Minutes before MRTG data is considered to be too old" 1682msgid "Minutes before MRTG data is considered to be too old"
1987msgstr "" 1683msgstr ""
1988 1684
1989#: plugins/check_mrtg.c:336
1990msgid "Should we check average or maximum values?" 1685msgid "Should we check average or maximum values?"
1991msgstr "" 1686msgstr ""
1992 1687
1993#: plugins/check_mrtg.c:338
1994msgid "Which variable set should we inspect? (1 or 2)" 1688msgid "Which variable set should we inspect? (1 or 2)"
1995msgstr "" 1689msgstr ""
1996 1690
1997#: plugins/check_mrtg.c:340
1998msgid "Threshold value for data to result in WARNING status" 1691msgid "Threshold value for data to result in WARNING status"
1999msgstr "" 1692msgstr ""
2000 1693
2001#: plugins/check_mrtg.c:342
2002msgid "Threshold value for data to result in CRITICAL status" 1694msgid "Threshold value for data to result in CRITICAL status"
2003msgstr "" 1695msgstr ""
2004 1696
2005#: plugins/check_mrtg.c:344
2006msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)" 1697msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)"
2007msgstr "" 1698msgstr ""
2008 1699
2009#: plugins/check_mrtg.c:346
2010msgid "Option units label for data (Example: Packets/Sec, Errors/Sec," 1700msgid "Option units label for data (Example: Packets/Sec, Errors/Sec,"
2011msgstr "" 1701msgstr ""
2012 1702
2013#: plugins/check_mrtg.c:347
2014#, c-format 1703#, c-format
2015msgid "\"Bytes Per Second\", \"%% Utilization\")" 1704msgid "\"Bytes Per Second\", \"%% Utilization\")"
2016msgstr "" 1705msgstr ""
2017 1706
2018#: plugins/check_mrtg.c:350
2019msgid "" 1707msgid ""
2020"If the value exceeds the <vwl> threshold, a WARNING status is returned. If" 1708"If the value exceeds the <vwl> threshold, a WARNING status is returned. If"
2021msgstr "" 1709msgstr ""
2022 1710
2023#: plugins/check_mrtg.c:351
2024msgid "" 1711msgid ""
2025"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If" 1712"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If"
2026msgstr "" 1713msgstr ""
2027 1714
2028#: plugins/check_mrtg.c:352
2029msgid "the data in the log file is older than <expire_minutes> old, a WARNING" 1715msgid "the data in the log file is older than <expire_minutes> old, a WARNING"
2030msgstr "" 1716msgstr ""
2031 1717
2032#: plugins/check_mrtg.c:353
2033msgid "status is returned and a warning message is printed." 1718msgid "status is returned and a warning message is printed."
2034msgstr "" 1719msgstr ""
2035 1720
2036#: plugins/check_mrtg.c:356
2037msgid "" 1721msgid ""
2038"This plugin is useful for monitoring MRTG data that does not correspond to" 1722"This plugin is useful for monitoring MRTG data that does not correspond to"
2039msgstr "" 1723msgstr ""
2040 1724
2041#: plugins/check_mrtg.c:357
2042msgid "" 1725msgid ""
2043"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)." 1726"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."
2044msgstr "" 1727msgstr ""
2045 1728
2046#: plugins/check_mrtg.c:358
2047msgid "" 1729msgid ""
2048"It can be used to monitor any kind of data that MRTG is monitoring - errors," 1730"It can be used to monitor any kind of data that MRTG is monitoring - errors,"
2049msgstr "" 1731msgstr ""
2050 1732
2051#: plugins/check_mrtg.c:359
2052msgid "" 1733msgid ""
2053"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows" 1734"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"
2054msgstr "" 1735msgstr ""
2055 1736
2056#: plugins/check_mrtg.c:360
2057msgid "" 1737msgid ""
2058"me to track processor utilization, user connections, drive space, etc and" 1738"me to track processor utilization, user connections, drive space, etc and"
2059msgstr "" 1739msgstr ""
2060 1740
2061#: plugins/check_mrtg.c:361
2062msgid "this plugin works well for monitoring that kind of data as well." 1741msgid "this plugin works well for monitoring that kind of data as well."
2063msgstr "" 1742msgstr ""
2064 1743
2065#: plugins/check_mrtg.c:364
2066msgid "" 1744msgid ""
2067"- This plugin only monitors one of the two variables stored in the MRTG log" 1745"- This plugin only monitors one of the two variables stored in the MRTG log"
2068msgstr "" 1746msgstr ""
2069"- Ce plugin vérifie seulement une ou deux variables écrites dans un fichier " 1747"- Ce plugin vérifie seulement une ou deux variables écrites dans un fichier "
2070"de log MRTG" 1748"de log MRTG"
2071 1749
2072#: plugins/check_mrtg.c:365
2073msgid "file. If you want to monitor both values you will have to define two" 1750msgid "file. If you want to monitor both values you will have to define two"
2074msgstr "" 1751msgstr ""
2075 1752
2076#: plugins/check_mrtg.c:366
2077msgid "commands with different values for the <variable> argument. Of course," 1753msgid "commands with different values for the <variable> argument. Of course,"
2078msgstr "" 1754msgstr ""
2079 1755
2080#: plugins/check_mrtg.c:367
2081msgid "you can always hack the code to make this plugin work for you..." 1756msgid "you can always hack the code to make this plugin work for you..."
2082msgstr "" 1757msgstr ""
2083 1758
2084#: plugins/check_mrtg.c:368
2085msgid "" 1759msgid ""
2086"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded " 1760"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded "
2087"from" 1761"from"
2088msgstr "" 1762msgstr ""
2089 1763
2090#: plugins/check_mrtgtraf.c:88
2091msgid "Unable to open MRTG log file" 1764msgid "Unable to open MRTG log file"
2092msgstr "Impossible d'ouvrir le fichier de log de MRTG" 1765msgstr "Impossible d'ouvrir le fichier de log de MRTG"
2093 1766
2094#: plugins/check_mrtgtraf.c:130
2095msgid "Unable to process MRTG log file" 1767msgid "Unable to process MRTG log file"
2096msgstr "Impossible de traiter le fichier de log de MRTG" 1768msgstr "Impossible de traiter le fichier de log de MRTG"
2097 1769
2098#: plugins/check_mrtgtraf.c:194 1770#, fuzzy, c-format
2099#, c-format 1771msgid "%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"
2100msgid "%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"
2101msgstr "%s. Entrée = %0.1f %s, %s. Sortie = %0.1f %s|%s %s\n" 1772msgstr "%s. Entrée = %0.1f %s, %s. Sortie = %0.1f %s|%s %s\n"
2102 1773
2103#: plugins/check_mrtgtraf.c:207
2104#, c-format 1774#, c-format
2105msgid "Traffic %s - %s\n" 1775msgid "Traffic %s - %s\n"
2106msgstr "Trafic %s - %s\n" 1776msgstr "Trafic %s - %s\n"
2107 1777
2108#: plugins/check_mrtgtraf.c:335
2109msgid "" 1778msgid ""
2110"This plugin will check the incoming/outgoing transfer rates of a router," 1779"This plugin will check the incoming/outgoing transfer rates of a router,"
2111msgstr "" 1780msgstr ""
2112"Ce plugin va vérifier le taux de transfert en entrée/sortie d'un routeur," 1781"Ce plugin va vérifier le taux de transfert en entrée/sortie d'un routeur,"
2113 1782
2114#: plugins/check_mrtgtraf.c:336
2115msgid "switch, etc recorded in an MRTG log. If the newest log entry is older" 1783msgid "switch, etc recorded in an MRTG log. If the newest log entry is older"
2116msgstr "" 1784msgstr ""
2117 1785
2118#: plugins/check_mrtgtraf.c:337
2119msgid "than <expire_minutes>, a WARNING status is returned. If either the" 1786msgid "than <expire_minutes>, a WARNING status is returned. If either the"
2120msgstr "" 1787msgstr ""
2121 1788
2122#: plugins/check_mrtgtraf.c:338
2123msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in" 1789msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in"
2124msgstr "" 1790msgstr ""
2125 1791
2126#: plugins/check_mrtgtraf.c:339
2127msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed" 1792msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed"
2128msgstr "" 1793msgstr ""
2129 1794
2130#: plugins/check_mrtgtraf.c:340
2131msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results." 1795msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results."
2132msgstr "" 1796msgstr ""
2133 1797
2134#: plugins/check_mrtgtraf.c:350
2135msgid "File to read log from" 1798msgid "File to read log from"
2136msgstr "" 1799msgstr ""
2137 1800
2138#: plugins/check_mrtgtraf.c:352
2139msgid "Minutes after which log expires" 1801msgid "Minutes after which log expires"
2140msgstr "" 1802msgstr ""
2141 1803
2142#: plugins/check_mrtgtraf.c:354
2143msgid "Test average or maximum" 1804msgid "Test average or maximum"
2144msgstr "" 1805msgstr ""
2145 1806
2146#: plugins/check_mrtgtraf.c:356
2147msgid "Warning threshold pair <incoming>,<outgoing>" 1807msgid "Warning threshold pair <incoming>,<outgoing>"
2148msgstr "Paire de seuils d'avertissement <entrant>,<sortant>" 1808msgstr "Paire de seuils d'avertissement <entrant>,<sortant>"
2149 1809
2150#: plugins/check_mrtgtraf.c:358
2151msgid "Critical threshold pair <incoming>,<outgoing>" 1810msgid "Critical threshold pair <incoming>,<outgoing>"
2152msgstr "Paire de seuils critique <entrant>,<sortant>" 1811msgstr "Paire de seuils critique <entrant>,<sortant>"
2153 1812
2154#: plugins/check_mrtgtraf.c:362
2155msgid "" 1813msgid ""
2156"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from" 1814"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"
2157msgstr "" 1815msgstr ""
2158 1816
2159#: plugins/check_mrtgtraf.c:364
2160msgid "- While MRTG can monitor things other than traffic rates, this" 1817msgid "- While MRTG can monitor things other than traffic rates, this"
2161msgstr "" 1818msgstr ""
2162 1819
2163#: plugins/check_mrtgtraf.c:365
2164msgid " plugin probably won't work with much else without modification." 1820msgid " plugin probably won't work with much else without modification."
2165msgstr "" 1821msgstr ""
2166 1822
2167#: plugins/check_mrtgtraf.c:366
2168msgid "- The calculated i/o rates are a little off from what MRTG actually" 1823msgid "- The calculated i/o rates are a little off from what MRTG actually"
2169msgstr "" 1824msgstr ""
2170 1825
2171#: plugins/check_mrtgtraf.c:367
2172msgid " reports. I'm not sure why this is right now, but will look into it" 1826msgid " reports. I'm not sure why this is right now, but will look into it"
2173msgstr "" 1827msgstr ""
2174 1828
2175#: plugins/check_mrtgtraf.c:368
2176msgid " for future enhancements of this plugin." 1829msgid " for future enhancements of this plugin."
2177msgstr "" 1830msgstr ""
2178 1831
2179#: plugins/check_mrtgtraf.c:378
2180#, c-format 1832#, c-format
2181msgid "Usage" 1833msgid "Usage"
2182msgstr "Utilisation" 1834msgstr "Utilisation"
2183 1835
2184#: plugins/check_mysql.c:171
2185#, fuzzy, c-format 1836#, fuzzy, c-format
2186msgid "status store_result error: %s\n" 1837msgid "status store_result error: %s\n"
2187msgstr "erreur slave store_result: %s\n" 1838msgstr "erreur slave store_result: %s\n"
2188 1839
2189#: plugins/check_mysql.c:202
2190#, c-format 1840#, c-format
2191msgid "slave query error: %s\n" 1841msgid "slave query error: %s\n"
2192msgstr "erreur de requête de l'esclave: %s\n" 1842msgstr "erreur de requête de l'esclave: %s\n"
2193 1843
2194#: plugins/check_mysql.c:209
2195#, c-format 1844#, c-format
2196msgid "slave store_result error: %s\n" 1845msgid "slave store_result error: %s\n"
2197msgstr "erreur slave store_result: %s\n" 1846msgstr "erreur slave store_result: %s\n"
2198 1847
2199#: plugins/check_mysql.c:215
2200msgid "No slaves defined" 1848msgid "No slaves defined"
2201msgstr "Pas d'esclave spécifié" 1849msgstr "Pas d'esclave spécifié"
2202 1850
2203#: plugins/check_mysql.c:223
2204#, c-format 1851#, c-format
2205msgid "slave fetch row error: %s\n" 1852msgid "slave fetch row error: %s\n"
2206msgstr "erreur esclave lecture d'une ligne: %s\n" 1853msgstr "erreur esclave lecture d'une ligne: %s\n"
2207 1854
2208#: plugins/check_mysql.c:228
2209#, c-format 1855#, c-format
2210msgid "Slave running: %s" 1856msgid "Slave running: %s"
2211msgstr "L'esclave fonctionne: %s" 1857msgstr "L'esclave fonctionne: %s"
2212 1858
2213#: plugins/check_mysql.c:505
2214msgid "This program tests connections to a MySQL server" 1859msgid "This program tests connections to a MySQL server"
2215msgstr "Ce plugin teste une connexion vers un serveur MySQL" 1860msgstr "Ce plugin teste une connexion vers un serveur MySQL"
2216 1861
2217#: plugins/check_mysql.c:516 1862msgid "Ignore authentication failure and check for mysql connectivity only"
1863msgstr ""
1864
2218msgid "Use the specified socket (has no effect if -H is used)" 1865msgid "Use the specified socket (has no effect if -H is used)"
2219msgstr "" 1866msgstr ""
2220 1867
2221#: plugins/check_mysql.c:519
2222msgid "Check database with indicated name" 1868msgid "Check database with indicated name"
2223msgstr "" 1869msgstr ""
2224 1870
2225#: plugins/check_mysql.c:521
2226msgid "Read from the specified client options file" 1871msgid "Read from the specified client options file"
2227msgstr "" 1872msgstr ""
2228 1873
2229#: plugins/check_mysql.c:523
2230msgid "Use a client options group" 1874msgid "Use a client options group"
2231msgstr "" 1875msgstr ""
2232 1876
2233#: plugins/check_mysql.c:525
2234msgid "Connect using the indicated username" 1877msgid "Connect using the indicated username"
2235msgstr "" 1878msgstr ""
2236 1879
2237#: plugins/check_mysql.c:527
2238msgid "Use the indicated password to authenticate the connection" 1880msgid "Use the indicated password to authenticate the connection"
2239msgstr "" 1881msgstr ""
2240 1882
2241#: plugins/check_mysql.c:528
2242msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!" 1883msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!"
2243msgstr "" 1884msgstr ""
2244 1885
2245#: plugins/check_mysql.c:529
2246msgid "Your clear-text password could be visible as a process table entry" 1886msgid "Your clear-text password could be visible as a process table entry"
2247msgstr "" 1887msgstr ""
2248 1888
2249#: plugins/check_mysql.c:531
2250msgid "Check if the slave thread is running properly." 1889msgid "Check if the slave thread is running properly."
2251msgstr "" 1890msgstr ""
2252 1891
2253#: plugins/check_mysql.c:533
2254msgid "Exit with WARNING status if slave server is more than INTEGER seconds" 1892msgid "Exit with WARNING status if slave server is more than INTEGER seconds"
2255msgstr "" 1893msgstr ""
2256"Sortir avec un résultat AVERTISSEMENT si le serveur esclave est plus de X " 1894"Sortir avec un résultat AVERTISSEMENT si le serveur esclave est plus de X "
2257 1895
2258#: plugins/check_mysql.c:534 plugins/check_mysql.c:537
2259msgid "behind master" 1896msgid "behind master"
2260msgstr "secondes en retard sur le maître" 1897msgstr "secondes en retard sur le maître"
2261 1898
2262#: plugins/check_mysql.c:536
2263msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds" 1899msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds"
2264msgstr "Sortir avec un résultat CRITIQUE si le serveur esclave est plus de X " 1900msgstr "Sortir avec un résultat CRITIQUE si le serveur esclave est plus de X "
2265 1901
2266#: plugins/check_mysql.c:539 1902msgid "Use ssl encryption"
2267msgid "Use ssl encryptation"
2268msgstr "" 1903msgstr ""
2269 1904
2270#: plugins/check_mysql.c:541
2271msgid "Path to CA signing the cert" 1905msgid "Path to CA signing the cert"
2272msgstr "" 1906msgstr ""
2273 1907
2274#: plugins/check_mysql.c:543
2275msgid "Path to SSL certificate" 1908msgid "Path to SSL certificate"
2276msgstr "" 1909msgstr ""
2277 1910
2278#: plugins/check_mysql.c:545
2279msgid "Path to private SSL key" 1911msgid "Path to private SSL key"
2280msgstr "" 1912msgstr ""
2281 1913
2282#: plugins/check_mysql.c:547
2283msgid "Path to CA directory" 1914msgid "Path to CA directory"
2284msgstr "" 1915msgstr ""
2285 1916
2286#: plugins/check_mysql.c:549
2287msgid "List of valid SSL ciphers" 1917msgid "List of valid SSL ciphers"
2288msgstr "" 1918msgstr ""
2289 1919
2290#: plugins/check_mysql.c:553
2291msgid "" 1920msgid ""
2292"There are no required arguments. By default, the local database is checked" 1921"There are no required arguments. By default, the local database is checked"
2293msgstr "" 1922msgstr ""
2294"Il n'y a pas d'arguments nécessaires. Par défaut la base de donnée locale " 1923"Il n'y a pas d'arguments nécessaires. Par défaut la base de donnée locale "
2295"est testée" 1924"est testée"
2296 1925
2297#: plugins/check_mysql.c:554
2298msgid "" 1926msgid ""
2299"using the default unix socket. You can force TCP on localhost by using an" 1927"using the default unix socket. You can force TCP on localhost by using an"
2300msgstr "" 1928msgstr ""
2301 1929
2302#: plugins/check_mysql.c:555
2303msgid "IP address or FQDN ('localhost' will use the socket as well)." 1930msgid "IP address or FQDN ('localhost' will use the socket as well)."
2304msgstr "" 1931msgstr ""
2305 1932
2306#: plugins/check_mysql.c:559
2307msgid "You must specify -p with an empty string to force an empty password," 1933msgid "You must specify -p with an empty string to force an empty password,"
2308msgstr "" 1934msgstr ""
2309 1935
2310#: plugins/check_mysql.c:560
2311msgid "overriding any my.cnf settings." 1936msgid "overriding any my.cnf settings."
2312msgstr "" 1937msgstr ""
2313 1938
2314#: plugins/check_nagios.c:104
2315msgid "Cannot open status log for reading!" 1939msgid "Cannot open status log for reading!"
2316msgstr "Impossible d'ouvrir le fichier status log en lecture!" 1940msgstr "Impossible d'ouvrir le fichier status log en lecture!"
2317 1941
2318#: plugins/check_nagios.c:154
2319#, c-format 1942#, c-format
2320msgid "Found process: %s %s\n" 1943msgid "Found process: %s %s\n"
2321msgstr "Processus trouvé: %s %s\n" 1944msgstr "Processus trouvé: %s %s\n"
2322 1945
2323#: plugins/check_nagios.c:168
2324msgid "Could not locate a running Nagios process!" 1946msgid "Could not locate a running Nagios process!"
2325msgstr "Impossible de trouver un processus Nagios actif!" 1947msgstr "Impossible de trouver un processus Nagios actif!"
2326 1948
2327#: plugins/check_nagios.c:172
2328msgid "Cannot parse Nagios log file for valid time" 1949msgid "Cannot parse Nagios log file for valid time"
2329msgstr "" 1950msgstr ""
2330"Impossible de trouver une date/heure valide dans le fichier de log de Nagios" 1951"Impossible de trouver une date/heure valide dans le fichier de log de Nagios"
2331 1952
2332#: plugins/check_nagios.c:183 plugins/check_procs.c:356
2333#, c-format 1953#, c-format
2334msgid "%d process" 1954msgid "%d process"
2335msgid_plural "%d processes" 1955msgid_plural "%d processes"
2336msgstr[0] "%d processus" 1956msgstr[0] "%d processus"
2337msgstr[1] "%d processus" 1957msgstr[1] "%d processus"
2338 1958
2339#: plugins/check_nagios.c:186
2340#, c-format 1959#, c-format
2341msgid "status log updated %d second ago" 1960msgid "status log updated %d second ago"
2342msgid_plural "status log updated %d seconds ago" 1961msgid_plural "status log updated %d seconds ago"
2343msgstr[0] "status log mis à jour %d secondes auparavant" 1962msgstr[0] "status log mis à jour %d secondes auparavant"
2344msgstr[1] "status log mis à jour %d secondes auparavant" 1963msgstr[1] "status log mis à jour %d secondes auparavant"
2345 1964
2346#: plugins/check_nagios.c:224 plugins/check_nagios.c:253
2347msgid "Expiration time must be an integer (seconds)\n" 1965msgid "Expiration time must be an integer (seconds)\n"
2348msgstr "Le délai d'expiration doit être un entier (en secondes)\n" 1966msgstr "Le délai d'expiration doit être un entier (en secondes)\n"
2349 1967
2350#: plugins/check_nagios.c:260
2351#, fuzzy 1968#, fuzzy
2352msgid "Timeout must be an integer (seconds)\n" 1969msgid "Timeout must be an integer (seconds)\n"
2353msgstr "Le délai d'expiration doit être un entier (en secondes)\n" 1970msgstr "Le délai d'expiration doit être un entier (en secondes)\n"
2354 1971
2355#: plugins/check_nagios.c:272
2356msgid "You must provide the status_log\n" 1972msgid "You must provide the status_log\n"
2357msgstr "Vous devez fournir le status_log\n" 1973msgstr "Vous devez fournir le status_log\n"
2358 1974
2359#: plugins/check_nagios.c:275
2360msgid "You must provide a process string\n" 1975msgid "You must provide a process string\n"
2361msgstr "Vous devez fournir un nom de processus\n" 1976msgstr "Vous devez fournir un nom de processus\n"
2362 1977
2363#: plugins/check_nagios.c:289
2364msgid "" 1978msgid ""
2365"This plugin checks the status of the Nagios process on the local machine" 1979"This plugin checks the status of the Nagios process on the local machine"
2366msgstr "Ce plugin vérifie l'état du processus Nagios sur la machine locale." 1980msgstr "Ce plugin vérifie l'état du processus Nagios sur la machine locale."
2367 1981
2368#: plugins/check_nagios.c:290
2369msgid "" 1982msgid ""
2370"The plugin will check to make sure the Nagios status log is no older than" 1983"The plugin will check to make sure the Nagios status log is no older than"
2371msgstr "Ce plugin vérifie que le status log de Nagios n'est pas plus vieux que" 1984msgstr "Ce plugin vérifie que le status log de Nagios n'est pas plus vieux que"
2372 1985
2373#: plugins/check_nagios.c:291
2374msgid "the number of minutes specified by the expires option." 1986msgid "the number of minutes specified by the expires option."
2375msgstr "le nombre de minutes spécifies par l'option expire." 1987msgstr "le nombre de minutes spécifies par l'option expire."
2376 1988
2377#: plugins/check_nagios.c:292
2378msgid "" 1989msgid ""
2379"It also checks the process table for a process matching the command argument." 1990"It also checks the process table for a process matching the command argument."
2380msgstr "" 1991msgstr ""
2381 1992
2382#: plugins/check_nagios.c:302
2383msgid "Name of the log file to check" 1993msgid "Name of the log file to check"
2384msgstr "Nom du fichier log à vérifier" 1994msgstr "Nom du fichier log à vérifier"
2385 1995
2386#: plugins/check_nagios.c:304
2387msgid "Minutes aging after which logfile is considered stale" 1996msgid "Minutes aging after which logfile is considered stale"
2388msgstr "" 1997msgstr ""
2389 1998
2390#: plugins/check_nagios.c:306
2391msgid "Substring to search for in process arguments" 1999msgid "Substring to search for in process arguments"
2392msgstr "" 2000msgstr ""
2393 2001
2394#: plugins/check_nagios.c:308
2395msgid "Timeout for the plugin in seconds" 2002msgid "Timeout for the plugin in seconds"
2396msgstr "" 2003msgstr ""
2397 2004
2398#: plugins/check_nt.c:142
2399#, c-format 2005#, c-format
2400msgid "Wrong client version - running: %s, required: %s" 2006msgid "Wrong client version - running: %s, required: %s"
2401msgstr "Mauvaise version du client utilisée: %s, nécessaire: %s" 2007msgstr "Mauvaise version du client utilisée: %s, nécessaire: %s"
2402 2008
2403#: plugins/check_nt.c:153 plugins/check_nt.c:218
2404msgid "missing -l parameters" 2009msgid "missing -l parameters"
2405msgstr "Arguments -l manquants" 2010msgstr "Arguments -l manquants"
2406 2011
2407#: plugins/check_nt.c:155
2408msgid "wrong -l parameter." 2012msgid "wrong -l parameter."
2409msgstr "Arguments -l erronés." 2013msgstr "Arguments -l erronés."
2410 2014
2411#: plugins/check_nt.c:159
2412msgid "CPU Load" 2015msgid "CPU Load"
2413msgstr "Charge CPU" 2016msgstr "Charge CPU"
2414 2017
2415#: plugins/check_nt.c:182
2416#, c-format 2018#, c-format
2417msgid " %lu%% (%lu min average)" 2019msgid " %lu%% (%lu min average)"
2418msgstr " %lu%% (%lu moyenne minimale)" 2020msgstr " %lu%% (%lu moyenne minimale)"
2419 2021
2420#: plugins/check_nt.c:184
2421#, c-format 2022#, c-format
2422msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100" 2023msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100"
2423msgstr " '%lu Charge moyenne minimale'=%lu%%;%lu;%lu;0;100" 2024msgstr " '%lu Charge moyenne minimale'=%lu%%;%lu;%lu;0;100"
2424 2025
2425#: plugins/check_nt.c:194
2426msgid "not enough values for -l parameters" 2026msgid "not enough values for -l parameters"
2427msgstr "pas assez de valeur pour l'argument -l" 2027msgstr "pas assez de valeur pour l'argument -l"
2428 2028
2429#: plugins/check_nt.c:206
2430#, c-format
2431msgid "System Uptime - %u day(s) %u hour(s) %u minute(s)"
2432msgstr "Système démarré - %u jour(s) %u heure(s) %u minute(s)"
2433
2434#: plugins/check_nt.c:220
2435msgid "wrong -l argument" 2029msgid "wrong -l argument"
2436msgstr "Argument -l erroné" 2030msgstr "Argument -l erroné"
2437 2031
2438#: plugins/check_nt.c:236 2032#, fuzzy, c-format
2033msgid "System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"
2034msgstr "Système démarré - %u jour(s) %u heure(s) %u minute(s)"
2035
2439#, c-format 2036#, c-format
2440msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)" 2037msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"
2441msgstr "" 2038msgstr ""
2442"%s:\\ - total: %.2f Gb - utilisé: %.2f Gb (%.0f%%) - libre %.2f Gb (%.0f%%)" 2039"%s:\\ - total: %.2f Gb - utilisé: %.2f Gb (%.0f%%) - libre %.2f Gb (%.0f%%)"
2443 2040
2444#: plugins/check_nt.c:239
2445#, c-format 2041#, c-format
2446msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f" 2042msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2447msgstr "'%s:\\ Espace Utilisé'=%.2fGb;%.2f;%.2f;0.00;%.2f" 2043msgstr "'%s:\\ Espace Utilisé'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2448 2044
2449#: plugins/check_nt.c:253
2450msgid "Free disk space : Invalid drive" 2045msgid "Free disk space : Invalid drive"
2451msgstr "Espace disque libre : Lecteur invalide" 2046msgstr "Espace disque libre : Lecteur invalide"
2452 2047
2453#: plugins/check_nt.c:263
2454msgid "No service/process specified" 2048msgid "No service/process specified"
2455msgstr "Pas de service/processus spécifié" 2049msgstr "Pas de service/processus spécifié"
2456 2050
2457#: plugins/check_nt.c:271 plugins/check_nt.c:284 plugins/check_nt.c:288
2458#: plugins/check_nt.c:622
2459msgid "could not fetch information from server\n" 2051msgid "could not fetch information from server\n"
2460msgstr "Impossible d'obtenir l'information depuis le serveur\n" 2052msgstr "Impossible d'obtenir l'information depuis le serveur\n"
2461 2053
2462#: plugins/check_nt.c:296 2054#, fuzzy, c-format
2463#, c-format
2464msgid "" 2055msgid ""
2465"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)" 2056"Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"
2466msgstr "" 2057msgstr ""
2467"Mémoire utilisée: total:%.2f Mb - utilisée: %.2f Mb (%.0f%%) - libre: %.2f " 2058"Mémoire utilisée: total:%.2f Mb - utilisée: %.2f Mb (%.0f%%) - libre: %.2f "
2468"Mb (%.0f%%)" 2059"Mb (%.0f%%)"
2469 2060
2470#: plugins/check_nt.c:299 2061#, fuzzy, c-format
2471#, c-format 2062msgid "'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"
2472msgid "'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"
2473msgstr "'Mémoire utilisée'=%.2fMb;%.2f;%.2f;0.00;%.2f" 2063msgstr "'Mémoire utilisée'=%.2fMb;%.2f;%.2f;0.00;%.2f"
2474 2064
2475#: plugins/check_nt.c:335 plugins/check_nt.c:420 plugins/check_nt.c:450
2476msgid "No counter specified" 2065msgid "No counter specified"
2477msgstr "Pas de compteur spécifié" 2066msgstr "Pas de compteur spécifié"
2478 2067
2479#: plugins/check_nt.c:367
2480msgid "Minimum value contains non-numbers" 2068msgid "Minimum value contains non-numbers"
2481msgstr "La valeur minimum contient des caractères non numériques" 2069msgstr "La valeur minimum contient des caractères non numériques"
2482 2070
2483#: plugins/check_nt.c:371
2484msgid "Maximum value contains non-numbers" 2071msgid "Maximum value contains non-numbers"
2485msgstr "La valeur maximum contient des caractères non numériques" 2072msgstr "La valeur maximum contient des caractères non numériques"
2486 2073
2487#: plugins/check_nt.c:378
2488msgid "No unit counter specified" 2074msgid "No unit counter specified"
2489msgstr "Pas de compteur spécifié" 2075msgstr "Pas de compteur spécifié"
2490 2076
2491#: plugins/check_nt.c:465
2492msgid "Please specify a variable to check" 2077msgid "Please specify a variable to check"
2493msgstr "Veuillez préciser une variable a vérifier" 2078msgstr "Veuillez préciser une variable a vérifier"
2494 2079
2495#: plugins/check_nt.c:549
2496msgid "Server port must be an integer\n" 2080msgid "Server port must be an integer\n"
2497msgstr "Le port du serveur doit être un nombre entier\n" 2081msgstr "Le port du serveur doit être un nombre entier\n"
2498 2082
2499#: plugins/check_nt.c:603
2500msgid "You must provide a server address or host name" 2083msgid "You must provide a server address or host name"
2501msgstr "Vous devez spécifier une adresse ou un nom d'hôte" 2084msgstr "Vous devez spécifier une adresse ou un nom d'hôte"
2502 2085
2503#: plugins/check_nt.c:609
2504msgid "None" 2086msgid "None"
2505msgstr "Aucun" 2087msgstr "Aucun"
2506 2088
2507#: plugins/check_nt.c:666
2508msgid "This plugin collects data from the NSClient service running on a" 2089msgid "This plugin collects data from the NSClient service running on a"
2509msgstr "" 2090msgstr ""
2510"Ce plugin collecte les données depuis le service NSClient tournant sur un" 2091"Ce plugin collecte les données depuis le service NSClient tournant sur un"
2511 2092
2512#: plugins/check_nt.c:667
2513msgid "Windows NT/2000/XP/2003 server." 2093msgid "Windows NT/2000/XP/2003 server."
2514msgstr "Serveur Windows NT/2000/XP/2003." 2094msgstr "Serveur Windows NT/2000/XP/2003."
2515 2095
2516#: plugins/check_nt.c:678
2517msgid "Name of the host to check" 2096msgid "Name of the host to check"
2518msgstr "Nom de l'hôte à vérifier" 2097msgstr "Nom de l'hôte à vérifier"
2519 2098
2520#: plugins/check_nt.c:680
2521msgid "Optional port number (default: " 2099msgid "Optional port number (default: "
2522msgstr "Numéro de port optionnel (défaut: " 2100msgstr "Numéro de port optionnel (défaut: "
2523 2101
2524#: plugins/check_nt.c:683
2525msgid "Password needed for the request" 2102msgid "Password needed for the request"
2526msgstr "Mot de passe nécessaire pour la requête" 2103msgstr "Mot de passe nécessaire pour la requête"
2527 2104
2528#: plugins/check_nt.c:685 plugins/check_nwstat.c:1661
2529#: plugins/check_overcr.c:432
2530msgid "Threshold which will result in a warning status" 2105msgid "Threshold which will result in a warning status"
2531msgstr "" 2106msgstr ""
2532 2107
2533#: plugins/check_nt.c:687 plugins/check_nwstat.c:1663
2534#: plugins/check_overcr.c:434
2535msgid "Threshold which will result in a critical status" 2108msgid "Threshold which will result in a critical status"
2536msgstr "" 2109msgstr ""
2537 2110
2538#: plugins/check_nt.c:689
2539msgid "Seconds before connection attempt times out (default: " 2111msgid "Seconds before connection attempt times out (default: "
2540msgstr "" 2112msgstr ""
2541 2113
2542#: plugins/check_nt.c:691
2543msgid "Parameters passed to specified check (see below)" 2114msgid "Parameters passed to specified check (see below)"
2544msgstr "" 2115msgstr ""
2545 2116
2546#: plugins/check_nt.c:693
2547msgid "Display options (currently only SHOWALL works)" 2117msgid "Display options (currently only SHOWALL works)"
2548msgstr "" 2118msgstr ""
2549 2119
2550#: plugins/check_nt.c:695
2551msgid "Return UNKNOWN on timeouts" 2120msgid "Return UNKNOWN on timeouts"
2552msgstr "" 2121msgstr ""
2553 2122
2554#: plugins/check_nt.c:698
2555msgid "Print this help screen" 2123msgid "Print this help screen"
2556msgstr "Afficher l'écran d'aide" 2124msgstr "Afficher l'écran d'aide"
2557 2125
2558#: plugins/check_nt.c:700
2559msgid "Print version information" 2126msgid "Print version information"
2560msgstr "Afficher la version" 2127msgstr "Afficher la version"
2561 2128
2562#: plugins/check_nt.c:702
2563msgid "Variable to check" 2129msgid "Variable to check"
2564msgstr "Variable a vérifier" 2130msgstr "Variable a vérifier"
2565 2131
2566#: plugins/check_nt.c:703
2567msgid "Valid variables are:" 2132msgid "Valid variables are:"
2568msgstr "Les variables valides sont" 2133msgstr "Les variables valides sont"
2569 2134
2570#: plugins/check_nt.c:705
2571msgid "Get the NSClient version" 2135msgid "Get the NSClient version"
2572msgstr "Obtenir la version de NSClient" 2136msgstr "Obtenir la version de NSClient"
2573 2137
2574#: plugins/check_nt.c:706
2575msgid "If -l <version> is specified, will return warning if versions differ." 2138msgid "If -l <version> is specified, will return warning if versions differ."
2576msgstr "" 2139msgstr ""
2577"si l'argument -l <version> est spécifié, une alerte AVERTISSEMENT sera " 2140"si l'argument -l <version> est spécifié, une alerte AVERTISSEMENT sera "
2578"renvoyée, si les versions sont différentes." 2141"renvoyée, si les versions sont différentes."
2579 2142
2580#: plugins/check_nt.c:708
2581msgid "Average CPU load on last x minutes." 2143msgid "Average CPU load on last x minutes."
2582msgstr "Moyenne de la charge CPU sur les dernières x minutes." 2144msgstr "Moyenne de la charge CPU sur les dernières x minutes."
2583 2145
2584#: plugins/check_nt.c:709
2585msgid "Request a -l parameter with the following syntax:" 2146msgid "Request a -l parameter with the following syntax:"
2586msgstr "Demande un paramètre -l avec la syntaxe suivante:" 2147msgstr "Demande un paramètre -l avec la syntaxe suivante:"
2587 2148
2588#: plugins/check_nt.c:710
2589msgid "-l <minutes range>,<warning threshold>,<critical threshold>." 2149msgid "-l <minutes range>,<warning threshold>,<critical threshold>."
2590msgstr "-l <plage de minutes>,<seuil d'avertissement>,<seuil critique>." 2150msgstr "-l <plage de minutes>,<seuil d'avertissement>,<seuil critique>."
2591 2151
2592#: plugins/check_nt.c:711
2593msgid "<minute range> should be less than 24*60." 2152msgid "<minute range> should be less than 24*60."
2594msgstr "<plage de minutes> devrait être inférieur à 24*60." 2153msgstr "<plage de minutes> devrait être inférieur à 24*60."
2595 2154
2596#: plugins/check_nt.c:712
2597msgid "" 2155msgid ""
2598"Thresholds are percentage and up to 10 requests can be done in one shot." 2156"Thresholds are percentage and up to 10 requests can be done in one shot."
2599msgstr "" 2157msgstr ""
2600"Les seuils sonts en pourcentage et un maximum de 10 requêtes peuvent être " 2158"Les seuils sonts en pourcentage et un maximum de 10 requêtes peuvent être "
2601"effectuées à la fois." 2159"effectuées à la fois."
2602 2160
2603#: plugins/check_nt.c:715
2604msgid "Get the uptime of the machine." 2161msgid "Get the uptime of the machine."
2605msgstr "Obtenir le temps de service de la machine." 2162msgstr "Obtenir le temps de service de la machine."
2606 2163
2607#: plugins/check_nt.c:716 2164msgid "-l <unit> "
2608msgid "No specific parameters. No warning or critical threshold" 2165msgstr ""
2609msgstr "Pas d'argument spécifique. Pas de seuil d'avertissement ou critique" 2166
2167msgid "<unit> = seconds, minutes, hours, or days. (default: minutes)"
2168msgstr ""
2169
2170#, fuzzy
2171msgid "Thresholds will use the unit specified above."
2172msgstr "Ce plugin va vérifier l'heure sur l'hôte spécifié."
2610 2173
2611#: plugins/check_nt.c:718
2612msgid "Size and percentage of disk use." 2174msgid "Size and percentage of disk use."
2613msgstr "Taille et pourcentage de l'utilisation disque." 2175msgstr "Taille et pourcentage de l'utilisation disque."
2614 2176
2615#: plugins/check_nt.c:719
2616msgid "Request a -l parameter containing the drive letter only." 2177msgid "Request a -l parameter containing the drive letter only."
2617msgstr "Demande un paramètre -l contennant uniquement la lettre du lecteur." 2178msgstr "Demande un paramètre -l contennant uniquement la lettre du lecteur."
2618 2179
2619#: plugins/check_nt.c:720 plugins/check_nt.c:723
2620msgid "Warning and critical thresholds can be specified with -w and -c." 2180msgid "Warning and critical thresholds can be specified with -w and -c."
2621msgstr "Les seuils d'alerte et critiques peuvent être spécifiés avec -w et -c." 2181msgstr "Les seuils d'alerte et critiques peuvent être spécifiés avec -w et -c."
2622 2182
2623#: plugins/check_nt.c:722
2624msgid "Memory use." 2183msgid "Memory use."
2625msgstr "Mémoire utilisée." 2184msgstr "Mémoire utilisée."
2626 2185
2627#: plugins/check_nt.c:725
2628msgid "Check the state of one or several services." 2186msgid "Check the state of one or several services."
2629msgstr "Vérifier l'état d'un ou plusieurs services." 2187msgstr "Vérifier l'état d'un ou plusieurs services."
2630 2188
2631#: plugins/check_nt.c:726 plugins/check_nt.c:735
2632msgid "Request a -l parameters with the following syntax:" 2189msgid "Request a -l parameters with the following syntax:"
2633msgstr "Demande un paramètre -l avec la syntaxe suivante:" 2190msgstr "Demande un paramètre -l avec la syntaxe suivante:"
2634 2191
2635#: plugins/check_nt.c:727
2636msgid "-l <service1>,<service2>,<service3>,..." 2192msgid "-l <service1>,<service2>,<service3>,..."
2637msgstr "-l <service1>,<service2>,<service3>,..." 2193msgstr "-l <service1>,<service2>,<service3>,..."
2638 2194
2639#: plugins/check_nt.c:728
2640msgid "You can specify -d SHOWALL in case you want to see working services" 2195msgid "You can specify -d SHOWALL in case you want to see working services"
2641msgstr "Vous pouvez spécifier -d SHOWALL pour voir les services fonctionnant" 2196msgstr "Vous pouvez spécifier -d SHOWALL pour voir les services fonctionnant"
2642 2197
2643#: plugins/check_nt.c:729
2644msgid "in the returned string." 2198msgid "in the returned string."
2645msgstr "dans la chaîne de caractère renvoyée." 2199msgstr "dans la chaîne de caractère renvoyée."
2646 2200
2647#: plugins/check_nt.c:731
2648msgid "Check if one or several process are running." 2201msgid "Check if one or several process are running."
2649msgstr "Vérifie si un ou plusieurs processus sont démarrés." 2202msgstr "Vérifie si un ou plusieurs processus sont démarrés."
2650 2203
2651#: plugins/check_nt.c:732
2652msgid "Same syntax as SERVICESTATE." 2204msgid "Same syntax as SERVICESTATE."
2653msgstr "Même syntaxe que SERVICESTATE." 2205msgstr "Même syntaxe que SERVICESTATE."
2654 2206
2655#: plugins/check_nt.c:734
2656msgid "Check any performance counter of Windows NT/2000." 2207msgid "Check any performance counter of Windows NT/2000."
2657msgstr "Vérifier n'importe quel compteur de performance sur Windows NT/2000." 2208msgstr "Vérifier n'importe quel compteur de performance sur Windows NT/2000."
2658 2209
2659#: plugins/check_nt.c:736
2660msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>" 2210msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>"
2661msgstr "-l \"\\\\<catégorie>\\\\compteur\",\"<description>" 2211msgstr "-l \"\\\\<catégorie>\\\\compteur\",\"<description>"
2662 2212
2663#: plugins/check_nt.c:737
2664msgid "The <description> parameter is optional and is given to a printf " 2213msgid "The <description> parameter is optional and is given to a printf "
2665msgstr "Le paramètre <description> est optionnel et est passé à la fonction " 2214msgstr "Le paramètre <description> est optionnel et est passé à la fonction "
2666 2215
2667#: plugins/check_nt.c:738
2668msgid "output command which requires a float parameter." 2216msgid "output command which requires a float parameter."
2669msgstr "de sortie printf qui demande un paramètre de type float." 2217msgstr "de sortie printf qui demande un paramètre de type float."
2670 2218
2671#: plugins/check_nt.c:739
2672#, c-format 2219#, c-format
2673msgid "If <description> does not include \"%%\", it is used as a label." 2220msgid "If <description> does not include \"%%\", it is used as a label."
2674msgstr "Si <description> n'inclus pas \"%%\", il est utilisé comme étiquette." 2221msgstr "Si <description> n'inclus pas \"%%\", il est utilisé comme étiquette."
2675 2222
2676#: plugins/check_nt.c:740 plugins/check_nt.c:755
2677msgid "Some examples:" 2223msgid "Some examples:"
2678msgstr "Exemples:" 2224msgstr "Exemples:"
2679 2225
2680#: plugins/check_nt.c:744
2681msgid "Check any performance counter object of Windows NT/2000." 2226msgid "Check any performance counter object of Windows NT/2000."
2682msgstr "Vérifie n'importe quel compteur de performance de Windows NT/2000." 2227msgstr "Vérifie n'importe quel compteur de performance de Windows NT/2000."
2683 2228
2684#: plugins/check_nt.c:745
2685msgid "" 2229msgid ""
2686"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>" 2230"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"
2687msgstr "" 2231msgstr ""
2688 2232
2689#: plugins/check_nt.c:746
2690msgid "<counter object> is a Windows Perfmon Counter object (eg. Process)," 2233msgid "<counter object> is a Windows Perfmon Counter object (eg. Process),"
2691msgstr "" 2234msgstr ""
2692 2235
2693#: plugins/check_nt.c:747
2694msgid "if it is two words, it should be enclosed in quotes" 2236msgid "if it is two words, it should be enclosed in quotes"
2695msgstr "" 2237msgstr ""
2696 2238
2697#: plugins/check_nt.c:748
2698msgid "The returned results will be a comma-separated list of instances on " 2239msgid "The returned results will be a comma-separated list of instances on "
2699msgstr "" 2240msgstr ""
2700 2241
2701#: plugins/check_nt.c:749
2702msgid " the selected computer for that object." 2242msgid " the selected computer for that object."
2703msgstr "" 2243msgstr ""
2704 2244
2705#: plugins/check_nt.c:750
2706msgid "" 2245msgid ""
2707"The purpose of this is to be run from command line to determine what " 2246"The purpose of this is to be run from command line to determine what "
2708"instances" 2247"instances"
2709msgstr "" 2248msgstr ""
2710 2249
2711#: plugins/check_nt.c:751
2712msgid "" 2250msgid ""
2713" are available for monitoring without having to log onto the Windows server" 2251" are available for monitoring without having to log onto the Windows server"
2714msgstr "" 2252msgstr ""
2715 2253
2716#: plugins/check_nt.c:752
2717msgid " to run Perfmon directly." 2254msgid " to run Perfmon directly."
2718msgstr "" 2255msgstr ""
2719 2256
2720#: plugins/check_nt.c:753
2721msgid "" 2257msgid ""
2722"It can also be used in scripts that automatically create the monitoring " 2258"It can also be used in scripts that automatically create the monitoring "
2723"service" 2259"service"
2724msgstr "" 2260msgstr ""
2725 2261
2726#: plugins/check_nt.c:754
2727msgid " configuration files." 2262msgid " configuration files."
2728msgstr "" 2263msgstr ""
2729 2264
2730#: plugins/check_nt.c:756
2731msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process" 2265msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"
2732msgstr "" 2266msgstr ""
2733 2267
2734#: plugins/check_nt.c:759
2735msgid "" 2268msgid ""
2736"- The NSClient service should be running on the server to get any information" 2269"- The NSClient service should be running on the server to get any information"
2737msgstr "" 2270msgstr ""
2738"- Le service NSClient doit rouler sur le serveur pour obtenir les " 2271"- Le service NSClient doit rouler sur le serveur pour obtenir les "
2739"informations" 2272"informations"
2740 2273
2741#: plugins/check_nt.c:761
2742msgid "- Critical thresholds should be lower than warning thresholds" 2274msgid "- Critical thresholds should be lower than warning thresholds"
2743msgstr "" 2275msgstr ""
2744"- Les seuils critiques doivent être plus bas que les seuils d'avertissement" 2276"- Les seuils critiques doivent être plus bas que les seuils d'avertissement"
2745 2277
2746#: plugins/check_nt.c:762
2747msgid "- Default port 1248 is sometimes in use by other services. The error" 2278msgid "- Default port 1248 is sometimes in use by other services. The error"
2748msgstr "" 2279msgstr ""
2749"- Le port par défaut 1248 est parfois utilisé par d'autres services. L'erreur" 2280"- Le port par défaut 1248 est parfois utilisé par d'autres services. L'erreur"
2750 2281
2751#: plugins/check_nt.c:763
2752msgid "" 2282msgid ""
2753"output when this happens contains \"Cannot map xxxxx to protocol number\"." 2283"output when this happens contains \"Cannot map xxxxx to protocol number\"."
2754msgstr "qui en résulte contiens \"Cannot map xxxxx to protocol number\"." 2284msgstr "qui en résulte contiens \"Cannot map xxxxx to protocol number\"."
2755 2285
2756#: plugins/check_nt.c:764
2757msgid "One fix for this is to change the port to something else on check_nt " 2286msgid "One fix for this is to change the port to something else on check_nt "
2758msgstr "" 2287msgstr ""
2759"Une possibilité pour corriger ce problème est de changer le port dans " 2288"Une possibilité pour corriger ce problème est de changer le port dans "
2760"check_nt " 2289"check_nt "
2761 2290
2762#: plugins/check_nt.c:765
2763msgid "and on the client service it's connecting to." 2291msgid "and on the client service it's connecting to."
2764msgstr "et dans le service auquel il se connecte." 2292msgstr "et dans le service auquel il se connecte."
2765 2293
2766#: plugins/check_ntp.c:807 plugins/check_ntp_peer.c:612 2294#, c-format
2767#: plugins/check_ntp_time.c:571 2295msgid "jitter response too large (%lu bytes)\n"
2296msgstr ""
2297
2768msgid "NTP CRITICAL:" 2298msgid "NTP CRITICAL:"
2769msgstr "NTP CRITIQUE:" 2299msgstr "NTP CRITIQUE:"
2770 2300
2771#: plugins/check_ntp.c:810 plugins/check_ntp_peer.c:615
2772#: plugins/check_ntp_time.c:574
2773msgid "NTP WARNING:" 2301msgid "NTP WARNING:"
2774msgstr "NTP AVERTISSEMENT:" 2302msgstr "NTP AVERTISSEMENT:"
2775 2303
2776#: plugins/check_ntp.c:813 plugins/check_ntp_peer.c:618
2777#: plugins/check_ntp_time.c:577
2778msgid "NTP OK:" 2304msgid "NTP OK:"
2779msgstr "NTP OK:" 2305msgstr "NTP OK:"
2780 2306
2781#: plugins/check_ntp.c:816 plugins/check_ntp_peer.c:621
2782#: plugins/check_ntp_time.c:580
2783msgid "NTP UNKNOWN:" 2307msgid "NTP UNKNOWN:"
2784msgstr "NTP INCONNU:" 2308msgstr "NTP INCONNU:"
2785 2309
2786#: plugins/check_ntp.c:820 plugins/check_ntp_peer.c:630
2787#: plugins/check_ntp_time.c:584
2788msgid "Offset unknown" 2310msgid "Offset unknown"
2789msgstr "Décalage inconnu" 2311msgstr "Décalage inconnu"
2790 2312
2791#: plugins/check_ntp.c:823 plugins/check_ntp_peer.c:633
2792#: plugins/check_ntp_time.c:587
2793msgid "Offset" 2313msgid "Offset"
2794msgstr "Décalage" 2314msgstr "Décalage"
2795 2315
2796#: plugins/check_ntp.c:844 plugins/check_ntp_peer.c:662
2797msgid "This plugin checks the selected ntp server" 2316msgid "This plugin checks the selected ntp server"
2798msgstr "Ce plugin vérifie le service ntp sur l'hôte" 2317msgstr "Ce plugin vérifie le service ntp sur l'hôte"
2799 2318
2800#: plugins/check_ntp.c:854 plugins/check_ntp_peer.c:674
2801#: plugins/check_ntp_time.c:614
2802msgid "Offset to result in warning status (seconds)" 2319msgid "Offset to result in warning status (seconds)"
2803msgstr "Décalage résultant en un avertissement (secondes)" 2320msgstr "Décalage résultant en un avertissement (secondes)"
2804 2321
2805#: plugins/check_ntp.c:856 plugins/check_ntp_peer.c:676
2806#: plugins/check_ntp_time.c:616
2807msgid "Offset to result in critical status (seconds)" 2322msgid "Offset to result in critical status (seconds)"
2808msgstr "Décalage résultant en un état critique (secondes)" 2323msgstr "Décalage résultant en un état critique (secondes)"
2809 2324
2810#: plugins/check_ntp.c:858 plugins/check_ntp_peer.c:682
2811msgid "Warning threshold for jitter" 2325msgid "Warning threshold for jitter"
2812msgstr "Seuil d'avertissement pour la variation (jitter)" 2326msgstr "Seuil d'avertissement pour la variation (jitter)"
2813 2327
2814#: plugins/check_ntp.c:860 plugins/check_ntp_peer.c:684
2815msgid "Critical threshold for jitter" 2328msgid "Critical threshold for jitter"
2816msgstr "Seuil critique pour la variation (jitter)" 2329msgstr "Seuil critique pour la variation (jitter)"
2817 2330
2818#: plugins/check_ntp.c:870
2819msgid "Normal offset check:" 2331msgid "Normal offset check:"
2820msgstr "Vérification normale du décalage:" 2332msgstr "Vérification normale du décalage:"
2821 2333
2822#: plugins/check_ntp.c:873 plugins/check_ntp_peer.c:709
2823msgid "" 2334msgid ""
2824"Check jitter too, avoiding critical notifications if jitter isn't available" 2335"Check jitter too, avoiding critical notifications if jitter isn't available"
2825msgstr "" 2336msgstr ""
2826"Vérifier aussi la variation (jitter) en évitant les notifications s'il n'est " 2337"Vérifier aussi la variation (jitter) en évitant les notifications s'il n'est "
2827"pas dispoible" 2338"pas dispoible"
2828 2339
2829#: plugins/check_ntp.c:874 plugins/check_ntp_peer.c:710
2830msgid "(See Notes above for more details on thresholds formats):" 2340msgid "(See Notes above for more details on thresholds formats):"
2831msgstr "" 2341msgstr ""
2832"(Voir les Notes ci-dessus pour plus de détails sur le format des seuils)" 2342"(Voir les Notes ci-dessus pour plus de détails sur le format des seuils)"
2833 2343
2834#: plugins/check_ntp.c:879 plugins/check_ntp.c:886
2835msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or" 2344msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or"
2836msgstr "ATTENTION: check_ntp est périmé, utilisez plutôt check_ntp_peer" 2345msgstr "ATTENTION: check_ntp est périmé, utilisez plutôt check_ntp_peer"
2837 2346
2838#: plugins/check_ntp.c:880 plugins/check_ntp.c:887
2839msgid "check_ntp_time instead." 2347msgid "check_ntp_time instead."
2840msgstr "ou check_ntp_time." 2348msgstr "ou check_ntp_time."
2841 2349
2842#: plugins/check_ntp_peer.c:625
2843msgid "Server not synchronized" 2350msgid "Server not synchronized"
2844msgstr "Le serveur n'est pas synchronisé" 2351msgstr "Le serveur n'est pas synchronisé"
2845 2352
2846#: plugins/check_ntp_peer.c:627
2847msgid "Server has the LI_ALARM bit set" 2353msgid "Server has the LI_ALARM bit set"
2848msgstr "" 2354msgstr ""
2849 2355
2850#: plugins/check_ntp_peer.c:672
2851msgid "" 2356msgid ""
2852"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized" 2357"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"
2853msgstr "" 2358msgstr ""
2854"Retourne INCONNU au lieu de CRITIQUE ou AVERTISSEMENT si le serveur n'est " 2359"Retourne INCONNU au lieu de CRITIQUE ou AVERTISSEMENT si le serveur n'est "
2855"pas synchronisé" 2360"pas synchronisé"
2856 2361
2857#: plugins/check_ntp_peer.c:678
2858#, fuzzy 2362#, fuzzy
2859msgid "Warning threshold for stratum of server's synchronization peer" 2363msgid "Warning threshold for stratum of server's synchronization peer"
2860msgstr "Seuil d'avertissement pour le stratum" 2364msgstr "Seuil d'avertissement pour le stratum"
2861 2365
2862#: plugins/check_ntp_peer.c:680
2863#, fuzzy 2366#, fuzzy
2864msgid "Critical threshold for stratum of server's synchronization peer" 2367msgid "Critical threshold for stratum of server's synchronization peer"
2865msgstr "Seuil critique pour le stratum" 2368msgstr "Seuil critique pour le stratum"
2866 2369
2867#: plugins/check_ntp_peer.c:686
2868msgid "Warning threshold for number of usable time sources (\"truechimers\")" 2370msgid "Warning threshold for number of usable time sources (\"truechimers\")"
2869msgstr "" 2371msgstr ""
2870"Seuil d'avertissement pour le nombre de sources de temps utilisable " 2372"Seuil d'avertissement pour le nombre de sources de temps utilisable "
2871"(\"truechimers\")" 2373"(\"truechimers\")"
2872 2374
2873#: plugins/check_ntp_peer.c:688
2874msgid "Critical threshold for number of usable time sources (\"truechimers\")" 2375msgid "Critical threshold for number of usable time sources (\"truechimers\")"
2875msgstr "" 2376msgstr ""
2876"Seuil critique pour le nombre de sources de temps utilisable (\"truechimers" 2377"Seuil critique pour le nombre de sources de temps utilisable "
2877"\")" 2378"(\"truechimers\")"
2878 2379
2879#: plugins/check_ntp_peer.c:693
2880msgid "This plugin checks an NTP server independent of any commandline" 2380msgid "This plugin checks an NTP server independent of any commandline"
2881msgstr "Ce plugin vérifie un serveur NTP sans recours aux programmes de" 2381msgstr "Ce plugin vérifie un serveur NTP sans recours aux programmes de"
2882 2382
2883#: plugins/check_ntp_peer.c:694
2884msgid "programs or external libraries." 2383msgid "programs or external libraries."
2885msgstr "la ligne de commande ou libraries externes" 2384msgstr "la ligne de commande ou libraries externes"
2886 2385
2887#: plugins/check_ntp_peer.c:697
2888msgid "Use this plugin to check the health of an NTP server. It supports" 2386msgid "Use this plugin to check the health of an NTP server. It supports"
2889msgstr "" 2387msgstr ""
2890"Utilisez ce plugin pour vérifier le service NTP sur l'hôte. Il supporte la" 2388"Utilisez ce plugin pour vérifier le service NTP sur l'hôte. Il supporte la"
2891 2389
2892#: plugins/check_ntp_peer.c:698
2893msgid "checking the offset with the sync peer, the jitter and stratum. This" 2390msgid "checking the offset with the sync peer, the jitter and stratum. This"
2894msgstr "" 2391msgstr ""
2895"vérification du décalage avec le pair se synchronisation, la variation " 2392"vérification du décalage avec le pair se synchronisation, la variation "
2896"(jitter) et le stratum." 2393"(jitter) et le stratum."
2897 2394
2898#: plugins/check_ntp_peer.c:699
2899msgid "plugin will not check the clock offset between the local host and NTP" 2395msgid "plugin will not check the clock offset between the local host and NTP"
2900msgstr "" 2396msgstr ""
2901"Ce plugin ne vérifie pas le décalage entre le serveur local et le serveur" 2397"Ce plugin ne vérifie pas le décalage entre le serveur local et le serveur"
2902 2398
2903#: plugins/check_ntp_peer.c:700
2904msgid "server; please use check_ntp_time for that purpose." 2399msgid "server; please use check_ntp_time for that purpose."
2905msgstr "NTP; utilisez plutôt check_ntp_time à cette fin." 2400msgstr "NTP; utilisez plutôt check_ntp_time à cette fin."
2906 2401
2907#: plugins/check_ntp_peer.c:706
2908msgid "Simple NTP server check:" 2402msgid "Simple NTP server check:"
2909msgstr "Vérification simple du serveur NTP:" 2403msgstr "Vérification simple du serveur NTP:"
2910 2404
2911#: plugins/check_ntp_peer.c:713
2912msgid "Only check the number of usable time sources (\"truechimers\"):" 2405msgid "Only check the number of usable time sources (\"truechimers\"):"
2913msgstr "" 2406msgstr ""
2914 2407
2915#: plugins/check_ntp_peer.c:716
2916msgid "Check only stratum:" 2408msgid "Check only stratum:"
2917msgstr "Vérification du stratum seulement:" 2409msgstr "Vérification du stratum seulement:"
2918 2410
2919#: plugins/check_ntp_time.c:602
2920msgid "This plugin checks the clock offset with the ntp server" 2411msgid "This plugin checks the clock offset with the ntp server"
2921msgstr "Ce plugin vérifie le décalage de l'horloge avec le serveur ntp" 2412msgstr "Ce plugin vérifie le décalage de l'horloge avec le serveur ntp"
2922 2413
2923#: plugins/check_ntp_time.c:612
2924msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found" 2414msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found"
2925msgstr "Retourne INCONNU au lieu de CRITIQUE si le décalage est inconnu" 2415msgstr "Retourne INCONNU au lieu de CRITIQUE si le décalage est inconnu"
2926 2416
2927#: plugins/check_ntp_time.c:621 2417msgid "Expected offset of the ntp server relative to local server (seconds)"
2418msgstr ""
2419
2928msgid "This plugin checks the clock offset between the local host and a" 2420msgid "This plugin checks the clock offset between the local host and a"
2929msgstr "Ce plugin vérifie le décalage de l'horloge entre se serveur local et" 2421msgstr "Ce plugin vérifie le décalage de l'horloge entre se serveur local et"
2930 2422
2931#: plugins/check_ntp_time.c:622
2932msgid "remote NTP server. It is independent of any commandline programs or" 2423msgid "remote NTP server. It is independent of any commandline programs or"
2933msgstr "le serveur NTP distant. Il ne fait aucun recours aux programmes de" 2424msgstr "le serveur NTP distant. Il ne fait aucun recours aux programmes de"
2934 2425
2935#: plugins/check_ntp_time.c:623
2936msgid "external libraries." 2426msgid "external libraries."
2937msgstr "la ligne de commande ou libraries externes." 2427msgstr "la ligne de commande ou libraries externes."
2938 2428
2939#: plugins/check_ntp_time.c:627
2940msgid "If you'd rather want to monitor an NTP server, please use" 2429msgid "If you'd rather want to monitor an NTP server, please use"
2941msgstr "Si vous voulez plutôt surveiller un serveur NTP, veuillez" 2430msgstr "Si vous voulez plutôt surveiller un serveur NTP, veuillez"
2942 2431
2943#: plugins/check_ntp_time.c:628
2944msgid "check_ntp_peer." 2432msgid "check_ntp_peer."
2945msgstr "utiliser check_ntp_peer." 2433msgstr "utiliser check_ntp_peer."
2946 2434
2947#: plugins/check_nwstat.c:194 2435msgid "--time-offset is useful for compensating for servers with known"
2436msgstr ""
2437
2438msgid "and expected clock skew."
2439msgstr ""
2440
2948#, c-format 2441#, c-format
2949msgid "NetWare %s: " 2442msgid "NetWare %s: "
2950msgstr "NetWare %s: " 2443msgstr "NetWare %s: "
2951 2444
2952#: plugins/check_nwstat.c:232
2953#, c-format 2445#, c-format
2954msgid "Up %s," 2446msgid "Up %s,"
2955msgstr "Démarré %s," 2447msgstr "Démarré %s,"
2956 2448
2957#: plugins/check_nwstat.c:240
2958#, c-format 2449#, c-format
2959msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100" 2450msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"
2960msgstr "" 2451msgstr ""
2961"Charge %s - %s %s charge système minimale = %lu%%|charge%s=%lu;%lu;%lu;0;100" 2452"Charge %s - %s %s charge système minimale = %lu%%|charge%s=%lu;%lu;%lu;0;100"
2962 2453
2963#: plugins/check_nwstat.c:268
2964#, c-format 2454#, c-format
2965msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;" 2455msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"
2966msgstr "Conns %s - %lu connections actuelles|Conns=%lu;%lu;%lu;;" 2456msgstr "Conns %s - %lu connections actuelles|Conns=%lu;%lu;%lu;;"
2967 2457
2968#: plugins/check_nwstat.c:293
2969#, c-format 2458#, c-format
2970msgid "%s: Long term cache hits = %lu%%" 2459msgid "%s: Long term cache hits = %lu%%"
2971msgstr "%s: Accès cache longue durée = %lu%%" 2460msgstr "%s: Accès cache longue durée = %lu%%"
2972 2461
2973#: plugins/check_nwstat.c:315
2974#, c-format 2462#, c-format
2975msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;" 2463msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"
2976msgstr "%s: Total des caches tampons= %lu|Caches Tampons=%lu,%lu;%lu;;" 2464msgstr "%s: Total des caches tampons= %lu|Caches Tampons=%lu,%lu;%lu;;"
2977 2465
2978#: plugins/check_nwstat.c:340
2979#, c-format 2466#, c-format
2980msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;" 2467msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"
2981msgstr "%s: cache tampons sales = %lu|caches tampons sales=%lu;%lu;%lu;;" 2468msgstr "%s: cache tampons sales = %lu|caches tampons sales=%lu;%lu;%lu;;"
2982 2469
2983#: plugins/check_nwstat.c:365
2984#, c-format 2470#, c-format
2985msgid "%s: LRU sitting time = %lu minutes" 2471msgid "%s: LRU sitting time = %lu minutes"
2986msgstr "" 2472msgstr ""
2987 2473
2988#: plugins/check_nwstat.c:382 plugins/check_nwstat.c:410
2989#: plugins/check_nwstat.c:437 plugins/check_nwstat.c:470
2990#: plugins/check_nwstat.c:650 plugins/check_nwstat.c:676
2991#: plugins/check_nwstat.c:707 plugins/check_nwstat.c:753
2992#: plugins/check_nwstat.c:777
2993#, c-format 2474#, c-format
2994msgid "CRITICAL - Volume '%s' does not exist!" 2475msgid "CRITICAL - Volume '%s' does not exist!"
2995msgstr "CRITIQUE: Le volume '%s' n'existe pas!" 2476msgstr "CRITIQUE: Le volume '%s' n'existe pas!"
2996 2477
2997#: plugins/check_nwstat.c:391
2998#, c-format 2478#, c-format
2999msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;" 2479msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"
3000msgstr "%s%lu KB libre sur le volume %s|KB libres%s=%lu;%lu;%lu;;" 2480msgstr "%s%lu KB libre sur le volume %s|KB libres%s=%lu;%lu;%lu;;"
3001 2481
3002#: plugins/check_nwstat.c:392 plugins/check_nwstat.c:420
3003#: plugins/check_nwstat.c:447 plugins/check_nwstat.c:659
3004#: plugins/check_nwstat.c:685 plugins/check_nwstat.c:761
3005msgid "Only " 2482msgid "Only "
3006msgstr "Seulement" 2483msgstr "Seulement"
3007 2484
3008#: plugins/check_nwstat.c:419
3009#, c-format 2485#, c-format
3010msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;" 2486msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"
3011msgstr "%s%lu MB libre sur le volume %s|MBlibre%s=%lu;%lu;%lu;;" 2487msgstr "%s%lu MB libre sur le volume %s|MBlibre%s=%lu;%lu;%lu;;"
3012 2488
3013#: plugins/check_nwstat.c:446
3014#, c-format 2489#, c-format
3015msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;" 2490msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"
3016msgstr "" 2491msgstr ""
3017 2492
3018#: plugins/check_nwstat.c:494
3019#, c-format 2493#, c-format
3020msgid "" 2494msgid ""
3021"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100" 2495"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"
@@ -3023,1102 +2497,877 @@ msgstr ""
3023"%lu MB (%lu%%) libre sur le volume %s - total %lu MB|MBlibre%s=%lu;%lu;" 2497"%lu MB (%lu%%) libre sur le volume %s - total %lu MB|MBlibre%s=%lu;%lu;"
3024"%lu;0;100" 2498"%lu;0;100"
3025 2499
3026#: plugins/check_nwstat.c:528
3027#, c-format 2500#, c-format
3028msgid "Directory Services Database is %s (DS version %s)" 2501msgid "Directory Services Database is %s (DS version %s)"
3029msgstr "La base de données Directory Services est %s (DS version %s)" 2502msgstr "La base de données Directory Services est %s (DS version %s)"
3030 2503
3031#: plugins/check_nwstat.c:545
3032#, c-format 2504#, c-format
3033msgid "Logins are %s" 2505msgid "Logins are %s"
3034msgstr "Les logins sont %s" 2506msgstr "Les logins sont %s"
3035 2507
3036#: plugins/check_nwstat.c:545
3037msgid "enabled" 2508msgid "enabled"
3038msgstr "activé" 2509msgstr "activé"
3039 2510
3040#: plugins/check_nwstat.c:545
3041msgid "disabled" 2511msgid "disabled"
3042msgstr "désactivé" 2512msgstr "désactivé"
3043 2513
3044#: plugins/check_nwstat.c:560
3045msgid "CRITICAL - NRM Status is bad!" 2514msgid "CRITICAL - NRM Status is bad!"
3046msgstr "CRITIQUE - le statut NRM est mauvais!" 2515msgstr "CRITIQUE - le statut NRM est mauvais!"
3047 2516
3048#: plugins/check_nwstat.c:565
3049msgid "Warning - NRM Status is suspect!" 2517msgid "Warning - NRM Status is suspect!"
3050msgstr "" 2518msgstr ""
3051 2519
3052#: plugins/check_nwstat.c:568
3053msgid "OK - NRM Status is good!" 2520msgid "OK - NRM Status is good!"
3054msgstr "OK - Le status du NRM est bon!" 2521msgstr "OK - Le status du NRM est bon!"
3055 2522
3056#: plugins/check_nwstat.c:610
3057#, c-format 2523#, c-format
3058msgid "%lu of %lu (%lu%%) packet receive buffers used" 2524msgid "%lu of %lu (%lu%%) packet receive buffers used"
3059msgstr "%lu de %lu (%lu%%) paquets du tampon de réception utilisés" 2525msgstr "%lu de %lu (%lu%%) paquets du tampon de réception utilisés"
3060 2526
3061#: plugins/check_nwstat.c:634
3062#, c-format 2527#, c-format
3063msgid "%lu entries in SAP table" 2528msgid "%lu entries in SAP table"
3064msgstr "%lu entrées dans la table SAP" 2529msgstr "%lu entrées dans la table SAP"
3065 2530
3066#: plugins/check_nwstat.c:636
3067#, c-format 2531#, c-format
3068msgid "%lu entries in SAP table for SAP type %d" 2532msgid "%lu entries in SAP table for SAP type %d"
3069msgstr "%lu entrées dans la table SAP pour le type SAP %d" 2533msgstr "%lu entrées dans la table SAP pour le type SAP %d"
3070 2534
3071#: plugins/check_nwstat.c:658
3072#, c-format 2535#, c-format
3073msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2536msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3074msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;" 2537msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;"
3075 2538
3076#: plugins/check_nwstat.c:684
3077#, c-format 2539#, c-format
3078msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2540msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3079msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;" 2541msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;"
3080 2542
3081#: plugins/check_nwstat.c:730
3082#, c-format 2543#, c-format
3083msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100" 2544msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"
3084msgstr "" 2545msgstr ""
3085"%lu MB (%lu%%) effaçables sur le volume %s|Effacable%s=%lu;%lu;%lu;0;100" 2546"%lu MB (%lu%%) effaçables sur le volume %s|Effacable%s=%lu;%lu;%lu;0;100"
3086 2547
3087#: plugins/check_nwstat.c:761
3088#, c-format 2548#, c-format
3089msgid "%s%lu KB not yet purgeable on volume %s" 2549msgid "%s%lu KB not yet purgeable on volume %s"
3090msgstr "%s%lu KB pas encore effaçables sur le volume %s" 2550msgstr "%s%lu KB pas encore effaçables sur le volume %s"
3091 2551
3092#: plugins/check_nwstat.c:800
3093#, c-format 2552#, c-format
3094msgid "%lu MB (%lu%%) not yet purgeable on volume %s" 2553msgid "%lu MB (%lu%%) not yet purgeable on volume %s"
3095msgstr "%lu MB (%lu%%) pas encore effaçables sur le volume %s" 2554msgstr "%lu MB (%lu%%) pas encore effaçables sur le volume %s"
3096 2555
3097#: plugins/check_nwstat.c:821
3098#, c-format 2556#, c-format
3099msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0" 2557msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0"
3100msgstr "" 2558msgstr ""
3101 2559
3102#: plugins/check_nwstat.c:846
3103#, c-format 2560#, c-format
3104msgid "%lu abended threads|Abends=%lu;%lu;%lu;;" 2561msgid "%lu abended threads|Abends=%lu;%lu;%lu;;"
3105msgstr "%lu processus avortés|Avortés=%lu;%lu;%lu;;" 2562msgstr "%lu processus avortés|Avortés=%lu;%lu;%lu;;"
3106 2563
3107#: plugins/check_nwstat.c:881
3108#, c-format 2564#, c-format
3109msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu" 2565msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"
3110msgstr "%lu processus services actuels (%lu max)|Processus=%lu;%lu;%lu;0;%lu" 2566msgstr "%lu processus services actuels (%lu max)|Processus=%lu;%lu;%lu;0;%lu"
3111 2567
3112#: plugins/check_nwstat.c:904
3113msgid "CRITICAL - Time not in sync with network!" 2568msgid "CRITICAL - Time not in sync with network!"
3114msgstr "CRITIQUE - Le temps n'est pas synchronisé avec le réseau!" 2569msgstr "CRITIQUE - Le temps n'est pas synchronisé avec le réseau!"
3115 2570
3116#: plugins/check_nwstat.c:907
3117msgid "OK - Time in sync with network!" 2571msgid "OK - Time in sync with network!"
3118msgstr "OK - Le temps est synchronisé avec le réseau!" 2572msgstr "OK - Le temps est synchronisé avec le réseau!"
3119 2573
3120#: plugins/check_nwstat.c:930
3121#, c-format 2574#, c-format
3122msgid "LRU sitting time = %lu seconds" 2575msgid "LRU sitting time = %lu seconds"
3123msgstr "LRU temps d'attente = %lu secondes" 2576msgstr "LRU temps d'attente = %lu secondes"
3124 2577
3125#: plugins/check_nwstat.c:949
3126#, c-format 2578#, c-format
3127msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100" 2579msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"
3128msgstr "Buffers cache sales = %lu%% du total|DCB=%lu;%lu;%lu;0;100" 2580msgstr "Buffers cache sales = %lu%% du total|DCB=%lu;%lu;%lu;0;100"
3129 2581
3130#: plugins/check_nwstat.c:971
3131#, c-format 2582#, c-format
3132msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100" 2583msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"
3133msgstr "cache tampons totaux= %lu%% de l'original|TCB=%lu;%lu;%lu;0;100" 2584msgstr "cache tampons totaux= %lu%% de l'original|TCB=%lu;%lu;%lu;0;100"
3134 2585
3135#: plugins/check_nwstat.c:989
3136#, c-format 2586#, c-format
3137msgid "NDS Version %s" 2587msgid "NDS Version %s"
3138msgstr "Version NDS %s" 2588msgstr "Version NDS %s"
3139 2589
3140#: plugins/check_nwstat.c:1005
3141#, c-format 2590#, c-format
3142msgid "Up %s" 2591msgid "Up %s"
3143msgstr "Démarré %s" 2592msgstr "Démarré %s"
3144 2593
3145#: plugins/check_nwstat.c:1019
3146#, c-format 2594#, c-format
3147msgid "Module %s version %s is loaded" 2595msgid "Module %s version %s is loaded"
3148msgstr "Le Module %s version %s est chargé" 2596msgstr "Le Module %s version %s est chargé"
3149 2597
3150#: plugins/check_nwstat.c:1022
3151#, c-format 2598#, c-format
3152msgid "Module %s is not loaded" 2599msgid "Module %s is not loaded"
3153msgstr "Le Module %s n'est pas chargé" 2600msgstr "Le Module %s n'est pas chargé"
3154 2601
3155#: plugins/check_nwstat.c:1033 plugins/check_nwstat.c:1059
3156#: plugins/check_nwstat.c:1085 plugins/check_nwstat.c:1111
3157#: plugins/check_nwstat.c:1137 plugins/check_nwstat.c:1163
3158#: plugins/check_nwstat.c:1189 plugins/check_nwstat.c:1215
3159#: plugins/check_nwstat.c:1241 plugins/check_nwstat.c:1267
3160#, c-format 2602#, c-format
3161msgid "CRITICAL - Value '%s' does not exist!" 2603msgid "CRITICAL - Value '%s' does not exist!"
3162msgstr "CRITIQUE: Le valeur '%s' n'existe pas!" 2604msgstr "CRITIQUE: Le valeur '%s' n'existe pas!"
3163 2605
3164#: plugins/check_nwstat.c:1042 plugins/check_nwstat.c:1068
3165#: plugins/check_nwstat.c:1094 plugins/check_nwstat.c:1120
3166#: plugins/check_nwstat.c:1146 plugins/check_nwstat.c:1172
3167#: plugins/check_nwstat.c:1198 plugins/check_nwstat.c:1224
3168#: plugins/check_nwstat.c:1250 plugins/check_nwstat.c:1276
3169#, c-format 2606#, c-format
3170msgid "%s is %lu|%s=%lu;%lu;%lu;;" 2607msgid "%s is %lu|%s=%lu;%lu;%lu;;"
3171msgstr "%s est %lu|%s=%lu;%lu;%lu;;" 2608msgstr "%s est %lu|%s=%lu;%lu;%lu;;"
3172 2609
3173#: plugins/check_nwstat.c:1289 plugins/check_overcr.c:285
3174msgid "Nothing to check!\n" 2610msgid "Nothing to check!\n"
3175msgstr "Rien à vérifier!\n" 2611msgstr "Rien à vérifier!\n"
3176 2612
3177#: plugins/check_nwstat.c:1371 plugins/check_overcr.c:355
3178msgid "Server port an integer\n" 2613msgid "Server port an integer\n"
3179msgstr "Le port du serveur doit être un nombre entier\n" 2614msgstr "Le port du serveur doit être un nombre entier\n"
3180 2615
3181#: plugins/check_nwstat.c:1601
3182msgid "This plugin attempts to contact the MRTGEXT NLM running on a" 2616msgid "This plugin attempts to contact the MRTGEXT NLM running on a"
3183msgstr "Ce plugin essaye de contacter le NLM MRTGEXT qui s'exécute sur" 2617msgstr "Ce plugin essaye de contacter le NLM MRTGEXT qui s'exécute sur"
3184 2618
3185#: plugins/check_nwstat.c:1602
3186msgid "Novell server to gather the requested system information." 2619msgid "Novell server to gather the requested system information."
3187msgstr "un serveur Novell pour récupérer l'information système demandée." 2620msgstr "un serveur Novell pour récupérer l'information système demandée."
3188 2621
3189#: plugins/check_nwstat.c:1614 plugins/check_overcr.c:436
3190msgid "Variable to check. Valid variables include:" 2622msgid "Variable to check. Valid variables include:"
3191msgstr "Variable à vérifier. Les variables valides sont:" 2623msgstr "Variable à vérifier. Les variables valides sont:"
3192 2624
3193#: plugins/check_nwstat.c:1615
3194msgid "LOAD1 = 1 minute average CPU load" 2625msgid "LOAD1 = 1 minute average CPU load"
3195msgstr "" 2626msgstr ""
3196 2627
3197#: plugins/check_nwstat.c:1616
3198msgid "LOAD5 = 5 minute average CPU load" 2628msgid "LOAD5 = 5 minute average CPU load"
3199msgstr "" 2629msgstr ""
3200 2630
3201#: plugins/check_nwstat.c:1617
3202msgid "LOAD15 = 15 minute average CPU load" 2631msgid "LOAD15 = 15 minute average CPU load"
3203msgstr "" 2632msgstr ""
3204 2633
3205#: plugins/check_nwstat.c:1618
3206msgid "CSPROCS = number of current service processes (NW 5.x only)" 2634msgid "CSPROCS = number of current service processes (NW 5.x only)"
3207msgstr "CSPROCS = nombres de processus services actuels (NW 5.x seulement)" 2635msgstr "CSPROCS = nombres de processus services actuels (NW 5.x seulement)"
3208 2636
3209#: plugins/check_nwstat.c:1619
3210msgid "ABENDS = number of abended threads (NW 5.x only)" 2637msgid "ABENDS = number of abended threads (NW 5.x only)"
3211msgstr "" 2638msgstr ""
3212 2639
3213#: plugins/check_nwstat.c:1620
3214msgid "UPTIME = server uptime" 2640msgid "UPTIME = server uptime"
3215msgstr "" 2641msgstr ""
3216 2642
3217#: plugins/check_nwstat.c:1621
3218msgid "LTCH = percent long term cache hits" 2643msgid "LTCH = percent long term cache hits"
3219msgstr "" 2644msgstr ""
3220 2645
3221#: plugins/check_nwstat.c:1622
3222msgid "CBUFF = current number of cache buffers" 2646msgid "CBUFF = current number of cache buffers"
3223msgstr "" 2647msgstr ""
3224 2648
3225#: plugins/check_nwstat.c:1623
3226msgid "CDBUFF = current number of dirty cache buffers" 2649msgid "CDBUFF = current number of dirty cache buffers"
3227msgstr "" 2650msgstr ""
3228 2651
3229#: plugins/check_nwstat.c:1624
3230msgid "DCB = dirty cache buffers as a percentage of the total" 2652msgid "DCB = dirty cache buffers as a percentage of the total"
3231msgstr "" 2653msgstr ""
3232 2654
3233#: plugins/check_nwstat.c:1625
3234msgid "TCB = dirty cache buffers as a percentage of the original" 2655msgid "TCB = dirty cache buffers as a percentage of the original"
3235msgstr "" 2656msgstr ""
3236 2657
3237#: plugins/check_nwstat.c:1626
3238msgid "OFILES = number of open files" 2658msgid "OFILES = number of open files"
3239msgstr "" 2659msgstr ""
3240 2660
3241#: plugins/check_nwstat.c:1627
3242msgid " VMF<vol> = MB of free space on Volume <vol>" 2661msgid " VMF<vol> = MB of free space on Volume <vol>"
3243msgstr "" 2662msgstr ""
3244 2663
3245#: plugins/check_nwstat.c:1628
3246msgid " VMU<vol> = MB used space on Volume <vol>" 2664msgid " VMU<vol> = MB used space on Volume <vol>"
3247msgstr "" 2665msgstr ""
3248 2666
3249#: plugins/check_nwstat.c:1629
3250msgid " VMP<vol> = MB of purgeable space on Volume <vol>" 2667msgid " VMP<vol> = MB of purgeable space on Volume <vol>"
3251msgstr "" 2668msgstr ""
3252 2669
3253#: plugins/check_nwstat.c:1630
3254msgid " VPF<vol> = percent free space on volume <vol>" 2670msgid " VPF<vol> = percent free space on volume <vol>"
3255msgstr "" 2671msgstr ""
3256 2672
3257#: plugins/check_nwstat.c:1631
3258msgid " VKF<vol> = KB of free space on volume <vol>" 2673msgid " VKF<vol> = KB of free space on volume <vol>"
3259msgstr "" 2674msgstr ""
3260 2675
3261#: plugins/check_nwstat.c:1632
3262msgid " VPP<vol> = percent purgeable space on volume <vol>" 2676msgid " VPP<vol> = percent purgeable space on volume <vol>"
3263msgstr "" 2677msgstr ""
3264 2678
3265#: plugins/check_nwstat.c:1633
3266msgid " VKP<vol> = KB of purgeable space on volume <vol>" 2679msgid " VKP<vol> = KB of purgeable space on volume <vol>"
3267msgstr "" 2680msgstr ""
3268 2681
3269#: plugins/check_nwstat.c:1634
3270msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>" 2682msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>"
3271msgstr "" 2683msgstr ""
3272 2684
3273#: plugins/check_nwstat.c:1635
3274msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>" 2685msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>"
3275msgstr "" 2686msgstr ""
3276 2687
3277#: plugins/check_nwstat.c:1636
3278msgid " LRUM = LRU sitting time in minutes" 2688msgid " LRUM = LRU sitting time in minutes"
3279msgstr "" 2689msgstr ""
3280 2690
3281#: plugins/check_nwstat.c:1637
3282msgid " LRUS = LRU sitting time in seconds" 2691msgid " LRUS = LRU sitting time in seconds"
3283msgstr " LRUS = LRU temps d'attente en secondes" 2692msgstr " LRUS = LRU temps d'attente en secondes"
3284 2693
3285#: plugins/check_nwstat.c:1638
3286msgid " DSDB = check to see if DS Database is open" 2694msgid " DSDB = check to see if DS Database is open"
3287msgstr "" 2695msgstr ""
3288 2696
3289#: plugins/check_nwstat.c:1639
3290msgid " DSVER = NDS version" 2697msgid " DSVER = NDS version"
3291msgstr "" 2698msgstr ""
3292 2699
3293#: plugins/check_nwstat.c:1640
3294msgid " UPRB = used packet receive buffers" 2700msgid " UPRB = used packet receive buffers"
3295msgstr " UPRB = paquets du tampon de réception utilisés" 2701msgstr " UPRB = paquets du tampon de réception utilisés"
3296 2702
3297#: plugins/check_nwstat.c:1641
3298msgid " PUPRB = percent (of max) used packet receive buffers" 2703msgid " PUPRB = percent (of max) used packet receive buffers"
3299msgstr "" 2704msgstr ""
3300 2705
3301#: plugins/check_nwstat.c:1642
3302msgid " SAPENTRIES = number of entries in the SAP table" 2706msgid " SAPENTRIES = number of entries in the SAP table"
3303msgstr "" 2707msgstr ""
3304 2708
3305#: plugins/check_nwstat.c:1643
3306msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>" 2709msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"
3307msgstr " SAPENTRIES<n> = entrées dans la table SAP pour le type SAP <n>" 2710msgstr " SAPENTRIES<n> = entrées dans la table SAP pour le type SAP <n>"
3308 2711
3309#: plugins/check_nwstat.c:1644
3310msgid " TSYNC = timesync status" 2712msgid " TSYNC = timesync status"
3311msgstr "" 2713msgstr ""
3312 2714
3313#: plugins/check_nwstat.c:1645
3314msgid " LOGINS = check to see if logins are enabled" 2715msgid " LOGINS = check to see if logins are enabled"
3315msgstr "" 2716msgstr ""
3316 2717
3317#: plugins/check_nwstat.c:1646
3318msgid " CONNS = number of currently licensed connections" 2718msgid " CONNS = number of currently licensed connections"
3319msgstr "" 2719msgstr ""
3320 2720
3321#: plugins/check_nwstat.c:1647
3322msgid " NRMH\t= NRM Summary Status" 2721msgid " NRMH\t= NRM Summary Status"
3323msgstr "" 2722msgstr ""
3324 2723
3325#: plugins/check_nwstat.c:1648
3326msgid " NRMP<stat> = Returns the current value for a NRM health item" 2724msgid " NRMP<stat> = Returns the current value for a NRM health item"
3327msgstr "" 2725msgstr ""
3328 2726
3329#: plugins/check_nwstat.c:1649
3330msgid " NRMM<stat> = Returns the current memory stats from NRM" 2727msgid " NRMM<stat> = Returns the current memory stats from NRM"
3331msgstr "" 2728msgstr ""
3332 2729
3333#: plugins/check_nwstat.c:1650
3334msgid " NRMS<stat> = Returns the current Swapfile stats from NRM" 2730msgid " NRMS<stat> = Returns the current Swapfile stats from NRM"
3335msgstr "" 2731msgstr ""
3336 2732
3337#: plugins/check_nwstat.c:1651
3338msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml" 2733msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"
3339msgstr "" 2734msgstr ""
3340 2735
3341#: plugins/check_nwstat.c:1652
3342msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml" 2736msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"
3343msgstr "" 2737msgstr ""
3344 2738
3345#: plugins/check_nwstat.c:1653
3346msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml" 2739msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"
3347msgstr "" 2740msgstr ""
3348 2741
3349#: plugins/check_nwstat.c:1654
3350msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml" 2742msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"
3351msgstr "" 2743msgstr ""
3352 2744
3353#: plugins/check_nwstat.c:1655
3354msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml" 2745msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"
3355msgstr "" 2746msgstr ""
3356 2747
3357#: plugins/check_nwstat.c:1656
3358msgid "" 2748msgid ""
3359" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml" 2749" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"
3360msgstr "" 2750msgstr ""
3361 2751
3362#: plugins/check_nwstat.c:1657
3363msgid " NLM:<nlm> = check if NLM is loaded and report version" 2752msgid " NLM:<nlm> = check if NLM is loaded and report version"
3364msgstr "" 2753msgstr ""
3365 2754
3366#: plugins/check_nwstat.c:1658
3367msgid " (e.g. NLM:TSANDS.NLM)" 2755msgid " (e.g. NLM:TSANDS.NLM)"
3368msgstr "" 2756msgstr ""
3369 2757
3370#: plugins/check_nwstat.c:1665
3371msgid "Include server version string in results" 2758msgid "Include server version string in results"
3372msgstr "" 2759msgstr ""
3373 2760
3374#: plugins/check_nwstat.c:1671 2761msgid "- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"
3375msgid "- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"
3376msgstr "" 2762msgstr ""
3377 2763
3378#: plugins/check_nwstat.c:1672
3379msgid "" 2764msgid ""
3380" extension for NetWare be loaded on the Novell servers you wish to check." 2765" extension for NetWare be loaded on the Novell servers you wish to check."
3381msgstr "" 2766msgstr ""
3382 2767
3383#: plugins/check_nwstat.c:1673
3384msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)" 2768msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)"
3385msgstr " (disponible depuis http://www.engr.wisc.edu/~drews/mrtg/)" 2769msgstr " (disponible depuis http://www.engr.wisc.edu/~drews/mrtg/)"
3386 2770
3387#: plugins/check_nwstat.c:1674
3388msgid "" 2771msgid ""
3389"- Values for critical thresholds should be lower than warning thresholds" 2772"- Values for critical thresholds should be lower than warning thresholds"
3390msgstr "" 2773msgstr ""
3391 2774
3392#: plugins/check_nwstat.c:1675
3393msgid "" 2775msgid ""
3394" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, " 2776" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "
3395msgstr "" 2777msgstr ""
3396 2778
3397#: plugins/check_nwstat.c:1676
3398msgid " TCB, LRUS and LRUM." 2779msgid " TCB, LRUS and LRUM."
3399msgstr "" 2780msgstr ""
3400 2781
3401#: plugins/check_overcr.c:123
3402msgid "Unknown error fetching load data\n" 2782msgid "Unknown error fetching load data\n"
3403msgstr "" 2783msgstr ""
3404"Erreur inconnue lors de la récupération des données de charge système\n" 2784"Erreur inconnue lors de la récupération des données de charge système\n"
3405 2785
3406#: plugins/check_overcr.c:127
3407msgid "Invalid response from server - no load information\n" 2786msgid "Invalid response from server - no load information\n"
3408msgstr "Réponse invalide du serveur - pas d'information de charge système\n" 2787msgstr "Réponse invalide du serveur - pas d'information de charge système\n"
3409 2788
3410#: plugins/check_overcr.c:133
3411msgid "Invalid response from server after load 1\n" 2789msgid "Invalid response from server after load 1\n"
3412msgstr "Réponse invalide du serveur après charge système à 1 minute\n" 2790msgstr "Réponse invalide du serveur après charge système à 1 minute\n"
3413 2791
3414#: plugins/check_overcr.c:139
3415msgid "Invalid response from server after load 5\n" 2792msgid "Invalid response from server after load 5\n"
3416msgstr "Réponse invalide du serveur après charge système à 5 minute\n" 2793msgstr "Réponse invalide du serveur après charge système à 5 minute\n"
3417 2794
3418#: plugins/check_overcr.c:164
3419#, c-format 2795#, c-format
3420msgid "Load %s - %s-min load average = %0.2f" 2796msgid "Load %s - %s-min load average = %0.2f"
3421msgstr "Charge %s - %s-moyenne minimale de charge système = %0.2f" 2797msgstr "Charge %s - %s-moyenne minimale de charge système = %0.2f"
3422 2798
3423#: plugins/check_overcr.c:174
3424msgid "Unknown error fetching disk data\n" 2799msgid "Unknown error fetching disk data\n"
3425msgstr "Erreur inconnue en récupérant les données des disques\n" 2800msgstr "Erreur inconnue en récupérant les données des disques\n"
3426 2801
3427#: plugins/check_overcr.c:184 plugins/check_overcr.c:236
3428#: plugins/check_overcr.c:240
3429msgid "Invalid response from server\n" 2802msgid "Invalid response from server\n"
3430msgstr "Réponse invalide reçue du serveur\n" 2803msgstr "Réponse invalide reçue du serveur\n"
3431 2804
3432#: plugins/check_overcr.c:211
3433msgid "Unknown error fetching network status\n" 2805msgid "Unknown error fetching network status\n"
3434msgstr "Erreur inconnue lors de la réception de l'état du réseau\n" 2806msgstr "Erreur inconnue lors de la réception de l'état du réseau\n"
3435 2807
3436#: plugins/check_overcr.c:221
3437#, c-format 2808#, c-format
3438msgid "Net %s - %d connection%s on port %d" 2809msgid "Net %s - %d connection%s on port %d"
3439msgstr "Net %s - %d connections%s sur le port %d" 2810msgstr "Net %s - %d connections%s sur le port %d"
3440 2811
3441#: plugins/check_overcr.c:232
3442msgid "Unknown error fetching process status\n" 2812msgid "Unknown error fetching process status\n"
3443msgstr "Erreur inconnue en récupérant l'état des processus\n" 2813msgstr "Erreur inconnue en récupérant l'état des processus\n"
3444 2814
3445#: plugins/check_overcr.c:250
3446#, c-format 2815#, c-format
3447msgid "Process %s - %d instance%s of %s running" 2816msgid "Process %s - %d instance%s of %s running"
3448msgstr "Processus %s - %d instances%s de %s démarrées" 2817msgstr "Processus %s - %d instances%s de %s démarrées"
3449 2818
3450#: plugins/check_overcr.c:277
3451#, c-format 2819#, c-format
3452msgid "Uptime %s - Up %d days %d hours %d minutes" 2820msgid "Uptime %s - Up %d days %d hours %d minutes"
3453msgstr "Temps de fonctionnement %s - Up %d jours %d heures %d minutes" 2821msgstr "Temps de fonctionnement %s - Up %d jours %d heures %d minutes"
3454 2822
3455#: plugins/check_overcr.c:419
3456msgid "" 2823msgid ""
3457"This plugin attempts to contact the Over-CR collector daemon running on the" 2824"This plugin attempts to contact the Over-CR collector daemon running on the"
3458msgstr "" 2825msgstr ""
3459"Ce plugin essaye de joindre le service Over CR tournant sur le serveur UNIX" 2826"Ce plugin essaye de joindre le service Over CR tournant sur le serveur UNIX"
3460 2827
3461#: plugins/check_overcr.c:420
3462msgid "remote UNIX server in order to gather the requested system information." 2828msgid "remote UNIX server in order to gather the requested system information."
3463msgstr "distant afin de récupérer les informations système demandées." 2829msgstr "distant afin de récupérer les informations système demandées."
3464 2830
3465#: plugins/check_overcr.c:437
3466msgid "LOAD1 = 1 minute average CPU load" 2831msgid "LOAD1 = 1 minute average CPU load"
3467msgstr "" 2832msgstr ""
3468 2833
3469#: plugins/check_overcr.c:438
3470msgid "LOAD5 = 5 minute average CPU load" 2834msgid "LOAD5 = 5 minute average CPU load"
3471msgstr "" 2835msgstr ""
3472 2836
3473#: plugins/check_overcr.c:439
3474msgid "LOAD15 = 15 minute average CPU load" 2837msgid "LOAD15 = 15 minute average CPU load"
3475msgstr "" 2838msgstr ""
3476 2839
3477#: plugins/check_overcr.c:440
3478msgid "DPU<filesys> = percent used disk space on filesystem <filesys>" 2840msgid "DPU<filesys> = percent used disk space on filesystem <filesys>"
3479msgstr "" 2841msgstr ""
3480 2842
3481#: plugins/check_overcr.c:441
3482msgid "PROC<process> = number of running processes with name <process>" 2843msgid "PROC<process> = number of running processes with name <process>"
3483msgstr "" 2844msgstr ""
3484 2845
3485#: plugins/check_overcr.c:442
3486msgid "NET<port> = number of active connections on TCP port <port>" 2846msgid "NET<port> = number of active connections on TCP port <port>"
3487msgstr "" 2847msgstr ""
3488 2848
3489#: plugins/check_overcr.c:443
3490msgid "UPTIME = system uptime in seconds" 2849msgid "UPTIME = system uptime in seconds"
3491msgstr "" 2850msgstr ""
3492 2851
3493#: plugins/check_overcr.c:450
3494msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be" 2852msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be"
3495msgstr "Ce plugin requiert que le daemon collecteur Over-CR d'Eric Molitors" 2853msgstr "Ce plugin requiert que le daemon collecteur Over-CR d'Eric Molitors"
3496 2854
3497#: plugins/check_overcr.c:451
3498msgid "running on the remote server." 2855msgid "running on the remote server."
3499msgstr "soit fonctionnel sur le serveur distant" 2856msgstr "soit fonctionnel sur le serveur distant"
3500 2857
3501#: plugins/check_overcr.c:452
3502msgid "Over-CR can be downloaded from http://www.molitor.org/overcr" 2858msgid "Over-CR can be downloaded from http://www.molitor.org/overcr"
3503msgstr "" 2859msgstr ""
3504 2860
3505#: plugins/check_overcr.c:453
3506msgid "This plugin was tested with version 0.99.53 of the Over-CR collector" 2861msgid "This plugin was tested with version 0.99.53 of the Over-CR collector"
3507msgstr "Ce plugin a été testé avec la version 0.99.53 su collecteur Over-CR" 2862msgstr "Ce plugin a été testé avec la version 0.99.53 su collecteur Over-CR"
3508 2863
3509#: plugins/check_overcr.c:457
3510msgid "" 2864msgid ""
3511"For the available options, the critical threshold value should always be" 2865"For the available options, the critical threshold value should always be"
3512msgstr "" 2866msgstr ""
3513"Pour toutes les options disponibles, le seuil critique doit toujours être" 2867"Pour toutes les options disponibles, le seuil critique doit toujours être"
3514 2868
3515#: plugins/check_overcr.c:458
3516msgid "" 2869msgid ""
3517"higher than the warning threshold value, EXCEPT with the uptime variable" 2870"higher than the warning threshold value, EXCEPT with the uptime variable"
3518msgstr "plus grand que le seuil d'alerte SAUF pour l'option uptime" 2871msgstr "plus grand que le seuil d'alerte SAUF pour l'option uptime"
3519 2872
3520#: plugins/check_pgsql.c:222
3521#, c-format 2873#, c-format
3522msgid "CRITICAL - no connection to '%s' (%s).\n" 2874msgid "CRITICAL - no connection to '%s' (%s).\n"
3523msgstr "CRITIQUE - pas de connexion à '%s' (%s).\n" 2875msgstr "CRITIQUE - pas de connexion à '%s' (%s).\n"
3524 2876
3525#: plugins/check_pgsql.c:250
3526#, fuzzy, c-format 2877#, fuzzy, c-format
3527msgid " %s - database %s (%f sec.)|%s\n" 2878msgid " %s - database %s (%f sec.)|%s\n"
3528msgstr " %s - base de données %s (%d sec.)|%s\n" 2879msgstr " %s - base de données %s (%d sec.)|%s\n"
3529 2880
3530#: plugins/check_pgsql.c:317 plugins/check_time.c:277 plugins/check_time.c:289
3531#: plugins/check_users.c:181
3532msgid "Critical threshold must be a positive integer" 2881msgid "Critical threshold must be a positive integer"
3533msgstr "Le seuil critique doit être un entier positif" 2882msgstr "Le seuil critique doit être un entier positif"
3534 2883
3535#: plugins/check_pgsql.c:323 plugins/check_time.c:258 plugins/check_time.c:282
3536#: plugins/check_users.c:187 plugins/check_users.c:197
3537#: plugins/check_users.c:203
3538msgid "Warning threshold must be a positive integer" 2884msgid "Warning threshold must be a positive integer"
3539msgstr "Le seuil d'avertissement doit être un entier positif" 2885msgstr "Le seuil d'avertissement doit être un entier positif"
3540 2886
3541#: plugins/check_pgsql.c:347 2887#, fuzzy
3542msgid "Database name is not valid" 2888msgid "Database name exceeds the maximum length"
3543msgstr "Le nom de la base de données est invalide" 2889msgstr "Le nom de la base de données est invalide"
3544 2890
3545#: plugins/check_pgsql.c:353
3546msgid "User name is not valid" 2891msgid "User name is not valid"
3547msgstr "Le nom de l'utilisateur est invalide" 2892msgstr "Le nom de l'utilisateur est invalide"
3548 2893
3549#: plugins/check_pgsql.c:504
3550#, c-format 2894#, c-format
3551msgid "Test whether a PostgreSQL Database is accepting connections." 2895msgid "Test whether a PostgreSQL Database is accepting connections."
3552msgstr "Teste si une base de données Postgresql accepte les connections." 2896msgstr "Teste si une base de données Postgresql accepte les connections."
3553 2897
3554#: plugins/check_pgsql.c:516
3555msgid "Database to check " 2898msgid "Database to check "
3556msgstr "" 2899msgstr ""
3557 2900
3558#: plugins/check_pgsql.c:517 2901#, fuzzy, c-format
3559#, c-format 2902msgid "(default: %s)\n"
3560msgid "(default: %s)" 2903msgstr "(Défaut: %d)\n"
3561msgstr ""
3562 2904
3563#: plugins/check_pgsql.c:519
3564msgid "Login name of user" 2905msgid "Login name of user"
3565msgstr "Le nom d'un utilisateur" 2906msgstr "Le nom d'un utilisateur"
3566 2907
3567#: plugins/check_pgsql.c:521
3568msgid "Password (BIG SECURITY ISSUE)" 2908msgid "Password (BIG SECURITY ISSUE)"
3569msgstr "" 2909msgstr ""
3570 2910
3571#: plugins/check_pgsql.c:523
3572msgid "Connection parameters (keyword = value), see below" 2911msgid "Connection parameters (keyword = value), see below"
3573msgstr "" 2912msgstr ""
3574 2913
3575#: plugins/check_pgsql.c:530
3576msgid "SQL query to run. Only first column in first row will be read" 2914msgid "SQL query to run. Only first column in first row will be read"
3577msgstr "" 2915msgstr ""
3578 2916
3579#: plugins/check_pgsql.c:532 2917msgid "A name for the query, this string is used instead of the query"
2918msgstr ""
2919
2920msgid "in the long output of the plugin"
2921msgstr ""
2922
3580#, fuzzy 2923#, fuzzy
3581msgid "SQL query value to result in warning status (double)" 2924msgid "SQL query value to result in warning status (double)"
3582msgstr "Décalage résultant en un avertissement (secondes)" 2925msgstr "Décalage résultant en un avertissement (secondes)"
3583 2926
3584#: plugins/check_pgsql.c:534
3585#, fuzzy 2927#, fuzzy
3586msgid "SQL query value to result in critical status (double)" 2928msgid "SQL query value to result in critical status (double)"
3587msgstr "Décalage résultant en un état critique (secondes)" 2929msgstr "Décalage résultant en un état critique (secondes)"
3588 2930
3589#: plugins/check_pgsql.c:539
3590msgid "All parameters are optional." 2931msgid "All parameters are optional."
3591msgstr "" 2932msgstr ""
3592 2933
3593#: plugins/check_pgsql.c:540
3594msgid "" 2934msgid ""
3595"This plugin tests a PostgreSQL DBMS to determine whether it is active and" 2935"This plugin tests a PostgreSQL DBMS to determine whether it is active and"
3596msgstr "" 2936msgstr ""
3597 2937
3598#: plugins/check_pgsql.c:541
3599msgid "accepting queries. In its current operation, it simply connects to the" 2938msgid "accepting queries. In its current operation, it simply connects to the"
3600msgstr "" 2939msgstr ""
3601 2940
3602#: plugins/check_pgsql.c:542
3603msgid "" 2941msgid ""
3604"specified database, and then disconnects. If no database is specified, it" 2942"specified database, and then disconnects. If no database is specified, it"
3605msgstr "" 2943msgstr ""
3606 2944
3607#: plugins/check_pgsql.c:543
3608msgid "" 2945msgid ""
3609"connects to the template1 database, which is present in every functioning" 2946"connects to the template1 database, which is present in every functioning"
3610msgstr "" 2947msgstr ""
3611 2948
3612#: plugins/check_pgsql.c:544
3613msgid "PostgreSQL DBMS." 2949msgid "PostgreSQL DBMS."
3614msgstr "" 2950msgstr ""
3615 2951
3616#: plugins/check_pgsql.c:546
3617msgid "If a query is specified using the -q option, it will be executed after" 2952msgid "If a query is specified using the -q option, it will be executed after"
3618msgstr "" 2953msgstr ""
3619 2954
3620#: plugins/check_pgsql.c:547
3621msgid "connecting to the server. The result from the query has to be numeric." 2955msgid "connecting to the server. The result from the query has to be numeric."
3622msgstr "" 2956msgstr ""
3623 2957
3624#: plugins/check_pgsql.c:548
3625msgid "" 2958msgid ""
3626"Multiple SQL commands, separated by semicolon, are allowed but the result " 2959"Multiple SQL commands, separated by semicolon, are allowed but the result "
3627msgstr "" 2960msgstr ""
3628 2961
3629#: plugins/check_pgsql.c:549
3630msgid "of the last command is taken into account only. The value of the first" 2962msgid "of the last command is taken into account only. The value of the first"
3631msgstr "" 2963msgstr ""
3632 2964
3633#: plugins/check_pgsql.c:550 2965msgid ""
3634msgid "column in the first row is used as the check result." 2966"column in the first row is used as the check result. If a second column is"
2967msgstr ""
2968
2969msgid "present in the result set, this is added to the plugin output with a"
2970msgstr ""
2971
2972msgid ""
2973"prefix of \"Extra Info:\". This information can be displayed in the system"
2974msgstr ""
2975
2976msgid "executing the plugin."
3635msgstr "" 2977msgstr ""
3636 2978
3637#: plugins/check_pgsql.c:552
3638msgid "" 2979msgid ""
3639"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual" 2980"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"
3640msgstr "" 2981msgstr ""
3641 2982
3642#: plugins/check_pgsql.c:553
3643msgid "" 2983msgid ""
3644"for details about how to access internal statistics of the database server." 2984"for details about how to access internal statistics of the database server."
3645msgstr "" 2985msgstr ""
3646 2986
3647#: plugins/check_pgsql.c:555
3648msgid "" 2987msgid ""
3649"For a list of available connection parameters which may be used with the -o" 2988"For a list of available connection parameters which may be used with the -o"
3650msgstr "" 2989msgstr ""
3651 2990
3652#: plugins/check_pgsql.c:556
3653msgid "" 2991msgid ""
3654"command line option, see the documentation for PQconnectdb() in the chapter" 2992"command line option, see the documentation for PQconnectdb() in the chapter"
3655msgstr "" 2993msgstr ""
3656 2994
3657#: plugins/check_pgsql.c:557
3658msgid "" 2995msgid ""
3659"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be" 2996"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"
3660msgstr "" 2997msgstr ""
3661 2998
3662#: plugins/check_pgsql.c:558
3663msgid "" 2999msgid ""
3664"used to specify a service name in pg_service.conf to be used for additional" 3000"used to specify a service name in pg_service.conf to be used for additional"
3665msgstr "" 3001msgstr ""
3666 3002
3667#: plugins/check_pgsql.c:559
3668msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:" 3003msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:"
3669msgstr "" 3004msgstr ""
3670 3005
3671#: plugins/check_pgsql.c:560
3672msgid "-o 'sslmode=require'." 3006msgid "-o 'sslmode=require'."
3673msgstr "" 3007msgstr ""
3674 3008
3675#: plugins/check_pgsql.c:562
3676msgid "" 3009msgid ""
3677"The plugin will connect to a local postmaster if no host is specified. To" 3010"The plugin will connect to a local postmaster if no host is specified. To"
3678msgstr "" 3011msgstr ""
3679"Ce plugin va se connecter sur un postmaster local si aucun hôte n'est " 3012"Ce plugin va se connecter sur un postmaster local si aucun hôte n'est "
3680"spécifié." 3013"spécifié."
3681 3014
3682#: plugins/check_pgsql.c:563
3683msgid "" 3015msgid ""
3684"connect to a remote host, be sure that the remote postmaster accepts TCP/IP" 3016"connect to a remote host, be sure that the remote postmaster accepts TCP/IP"
3685msgstr "" 3017msgstr ""
3686 3018
3687#: plugins/check_pgsql.c:564
3688msgid "connections (start the postmaster with the -i option)." 3019msgid "connections (start the postmaster with the -i option)."
3689msgstr "" 3020msgstr ""
3690 3021
3691#: plugins/check_pgsql.c:566
3692msgid "" 3022msgid ""
3693"Typically, the monitoring user (unless the --logname option is used) should " 3023"Typically, the monitoring user (unless the --logname option is used) should "
3694"be" 3024"be"
3695msgstr "" 3025msgstr ""
3696 3026
3697#: plugins/check_pgsql.c:567
3698msgid "" 3027msgid ""
3699"able to connect to the database without a password. The plugin can also send" 3028"able to connect to the database without a password. The plugin can also send"
3700msgstr "" 3029msgstr ""
3701 3030
3702#: plugins/check_pgsql.c:568 3031msgid "a password, but no effort is made to obscure or encrypt the password."
3703msgid "a password, but no effort is made to obsure or encrypt the password."
3704msgstr "" 3032msgstr ""
3705 3033
3706#: plugins/check_pgsql.c:601
3707#, c-format 3034#, c-format
3708msgid "QUERY %s - %s: %s.\n" 3035msgid "QUERY %s - %s: %s.\n"
3709msgstr "" 3036msgstr ""
3710 3037
3711#: plugins/check_pgsql.c:601
3712msgid "Error with query" 3038msgid "Error with query"
3713msgstr "" 3039msgstr ""
3714 3040
3715#: plugins/check_pgsql.c:607
3716#, fuzzy 3041#, fuzzy
3717msgid "No rows returned" 3042msgid "No rows returned"
3718msgstr "Pas de données valides reçues" 3043msgstr "Pas de données valides reçues"
3719 3044
3720#: plugins/check_pgsql.c:612
3721#, fuzzy 3045#, fuzzy
3722msgid "No columns returned" 3046msgid "No columns returned"
3723msgstr "Pas de données valides reçues" 3047msgstr "Pas de données valides reçues"
3724 3048
3725#: plugins/check_pgsql.c:618
3726#, fuzzy 3049#, fuzzy
3727msgid "No data returned" 3050msgid "No data returned"
3728msgstr "Pas de données valides reçues" 3051msgstr "Pas de données valides reçues"
3729 3052
3730#: plugins/check_pgsql.c:627
3731msgid "Is not a numeric" 3053msgid "Is not a numeric"
3732msgstr "" 3054msgstr ""
3733 3055
3734#: plugins/check_pgsql.c:644 3056#, fuzzy, c-format
3057msgid "%s returned %f"
3058msgstr ". %s renvoie %s"
3059
3735#, fuzzy, c-format 3060#, fuzzy, c-format
3736msgid "'%s' returned %f" 3061msgid "'%s' returned %f"
3737msgstr ". %s renvoie %s" 3062msgstr ". %s renvoie %s"
3738 3063
3739#: plugins/check_ping.c:141
3740msgid "CRITICAL - Could not interpret output from ping command\n" 3064msgid "CRITICAL - Could not interpret output from ping command\n"
3741msgstr "CRITIQUE - Impossible d'interpréter le réponse de la commande ping\n" 3065msgstr "CRITIQUE - Impossible d'interpréter le réponse de la commande ping\n"
3742 3066
3743#: plugins/check_ping.c:157
3744#, c-format 3067#, c-format
3745msgid "PING %s - %sPacket loss = %d%%" 3068msgid "PING %s - %sPacket loss = %d%%"
3746msgstr "PING %s - %s Paquets perdus = %d%%" 3069msgstr "PING %s - %s Paquets perdus = %d%%"
3747 3070
3748#: plugins/check_ping.c:160
3749#, c-format 3071#, c-format
3750msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms" 3072msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"
3751msgstr "PING %s - %s Paquets perdus = %d%%, RTA = %2.2f ms" 3073msgstr "PING %s - %s Paquets perdus = %d%%, RTA = %2.2f ms"
3752 3074
3753#: plugins/check_ping.c:257
3754msgid "Could not realloc() addresses\n" 3075msgid "Could not realloc() addresses\n"
3755msgstr "Impossible de réallouer les adresses\n" 3076msgstr "Impossible de réallouer les adresses\n"
3756 3077
3757#: plugins/check_ping.c:272 plugins/check_ping.c:352
3758#, c-format 3078#, c-format
3759msgid "<max_packets> (%s) must be a non-negative number\n" 3079msgid "<max_packets> (%s) must be a non-negative number\n"
3760msgstr "<max_packets> (%s) doit être un nombre positif\n" 3080msgstr "<max_packets> (%s) doit être un nombre positif\n"
3761 3081
3762#: plugins/check_ping.c:306
3763#, c-format 3082#, c-format
3764msgid "<wpl> (%s) must be an integer percentage\n" 3083msgid "<wpl> (%s) must be an integer percentage\n"
3765msgstr "<wpl> (%s) doit être un pourcentage entier\n" 3084msgstr "<wpl> (%s) doit être un pourcentage entier\n"
3766 3085
3767#: plugins/check_ping.c:317
3768#, c-format 3086#, c-format
3769msgid "<cpl> (%s) must be an integer percentage\n" 3087msgid "<cpl> (%s) must be an integer percentage\n"
3770msgstr "<cpl> (%s) doit être un pourcentage entier\n" 3088msgstr "<cpl> (%s) doit être un pourcentage entier\n"
3771 3089
3772#: plugins/check_ping.c:328
3773#, c-format 3090#, c-format
3774msgid "<wrta> (%s) must be a non-negative number\n" 3091msgid "<wrta> (%s) must be a non-negative number\n"
3775msgstr "<wrta> (%s) doit être un nombre positif\n" 3092msgstr "<wrta> (%s) doit être un nombre positif\n"
3776 3093
3777#: plugins/check_ping.c:339
3778#, c-format 3094#, c-format
3779msgid "<crta> (%s) must be a non-negative number\n" 3095msgid "<crta> (%s) must be a non-negative number\n"
3780msgstr "<crta> (%s) doit être un nombre positif\n" 3096msgstr "<crta> (%s) doit être un nombre positif\n"
3781 3097
3782#: plugins/check_ping.c:372
3783#, c-format 3098#, c-format
3784msgid "" 3099msgid ""
3785"%s: Warning threshold must be integer or percentage!\n" 3100"%s: Warning threshold must be integer or percentage!\n"
3786"\n" 3101"\n"
3787msgstr "%s: Le seuil d'avertissement doit être un entier ou un pourcentage!\n" 3102msgstr "%s: Le seuil d'avertissement doit être un entier ou un pourcentage!\n"
3788 3103
3789#: plugins/check_ping.c:385
3790#, c-format 3104#, c-format
3791msgid "<wrta> was not set\n" 3105msgid "<wrta> was not set\n"
3792msgstr "<wrta> n'a pas été indiqué\n" 3106msgstr "<wrta> n'a pas été indiqué\n"
3793 3107
3794#: plugins/check_ping.c:389
3795#, c-format 3108#, c-format
3796msgid "<crta> was not set\n" 3109msgid "<crta> was not set\n"
3797msgstr "<crta> n'a pas été indiqué\n" 3110msgstr "<crta> n'a pas été indiqué\n"
3798 3111
3799#: plugins/check_ping.c:393
3800#, c-format 3112#, c-format
3801msgid "<wpl> was not set\n" 3113msgid "<wpl> was not set\n"
3802msgstr " <wpl> n'a pas été indiqué\n" 3114msgstr " <wpl> n'a pas été indiqué\n"
3803 3115
3804#: plugins/check_ping.c:397
3805#, c-format 3116#, c-format
3806msgid "<cpl> was not set\n" 3117msgid "<cpl> was not set\n"
3807msgstr "<cpl> n'a pas été indiqué\n" 3118msgstr "<cpl> n'a pas été indiqué\n"
3808 3119
3809#: plugins/check_ping.c:401
3810#, c-format 3120#, c-format
3811msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n" 3121msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n"
3812msgstr "<wrta> (%f) ne peut pas être plus large que <crta> (%f)\n" 3122msgstr "<wrta> (%f) ne peut pas être plus large que <crta> (%f)\n"
3813 3123
3814#: plugins/check_ping.c:405
3815#, c-format 3124#, c-format
3816msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n" 3125msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n"
3817msgstr "<wpl> (%d) ne peut pas être plus large que <cpl> (%d)\n" 3126msgstr "<wpl> (%d) ne peut pas être plus large que <cpl> (%d)\n"
3818 3127
3819#: plugins/check_ping.c:442
3820#, c-format 3128#, c-format
3821msgid "Cannot open stderr for %s\n" 3129msgid "Cannot open stderr for %s\n"
3822msgstr "Impossible d'ouvrir le canal d'erreur standard pour %s\n" 3130msgstr "Impossible d'ouvrir le canal d'erreur standard pour %s\n"
3823 3131
3824#: plugins/check_ping.c:492 plugins/check_ping.c:494
3825msgid "System call sent warnings to stderr " 3132msgid "System call sent warnings to stderr "
3826msgstr "" 3133msgstr ""
3827"Les appel système enverront leurs messages d'avertissement vers le canal " 3134"Les appel système enverront leurs messages d'avertissement vers le canal "
3828"d'erreur standard" 3135"d'erreur standard"
3829 3136
3830#: plugins/check_ping.c:519
3831#, fuzzy, c-format 3137#, fuzzy, c-format
3832msgid "CRITICAL - Network Unreachable (%s)\n" 3138msgid "CRITICAL - Network Unreachable (%s)\n"
3833msgstr "CRITIQUE - Le réseau est inaccessible (%s)" 3139msgstr "CRITIQUE - Le réseau est inaccessible (%s)"
3834 3140
3835#: plugins/check_ping.c:521
3836#, fuzzy, c-format 3141#, fuzzy, c-format
3837msgid "CRITICAL - Host Unreachable (%s)\n" 3142msgid "CRITICAL - Host Unreachable (%s)\n"
3838msgstr "CRITIQUE - Hôte inaccessible (%s)" 3143msgstr "CRITIQUE - Hôte inaccessible (%s)"
3839 3144
3840#: plugins/check_ping.c:523
3841#, fuzzy, c-format 3145#, fuzzy, c-format
3842msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n" 3146msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"
3843msgstr "CRITIQUE - Paquet ICMP incorrect: Port inaccessible (%s)" 3147msgstr "CRITIQUE - Paquet ICMP incorrect: Port inaccessible (%s)"
3844 3148
3845#: plugins/check_ping.c:525
3846#, fuzzy, c-format 3149#, fuzzy, c-format
3847msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n" 3150msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"
3848msgstr "CRITIQUE - Paquet ICMP incorrect: Protocole inaccessible (%s)" 3151msgstr "CRITIQUE - Paquet ICMP incorrect: Protocole inaccessible (%s)"
3849 3152
3850#: plugins/check_ping.c:527
3851#, fuzzy, c-format 3153#, fuzzy, c-format
3852msgid "CRITICAL - Network Prohibited (%s)\n" 3154msgid "CRITICAL - Network Prohibited (%s)\n"
3853msgstr "CRITIQUE - L'accès au réseau est interdit (%s)" 3155msgstr "CRITIQUE - L'accès au réseau est interdit (%s)"
3854 3156
3855#: plugins/check_ping.c:529
3856#, fuzzy, c-format 3157#, fuzzy, c-format
3857msgid "CRITICAL - Host Prohibited (%s)\n" 3158msgid "CRITICAL - Host Prohibited (%s)\n"
3858msgstr "CRITIQUE - L'accès a l'hôte est interdit (%s)" 3159msgstr "CRITIQUE - L'accès a l'hôte est interdit (%s)"
3859 3160
3860#: plugins/check_ping.c:531
3861#, fuzzy, c-format 3161#, fuzzy, c-format
3862msgid "CRITICAL - Packet Filtered (%s)\n" 3162msgid "CRITICAL - Packet Filtered (%s)\n"
3863msgstr "CRITIQUE - Paquet filtré (%s)" 3163msgstr "CRITIQUE - Paquet filtré (%s)"
3864 3164
3865#: plugins/check_ping.c:533
3866#, fuzzy, c-format 3165#, fuzzy, c-format
3867msgid "CRITICAL - Host not found (%s)\n" 3166msgid "CRITICAL - Host not found (%s)\n"
3868msgstr "CRITIQUE - Hôte non trouvé (%s)" 3167msgstr "CRITIQUE - Hôte non trouvé (%s)"
3869 3168
3870#: plugins/check_ping.c:535
3871#, fuzzy, c-format 3169#, fuzzy, c-format
3872msgid "CRITICAL - Time to live exceeded (%s)\n" 3170msgid "CRITICAL - Time to live exceeded (%s)\n"
3873msgstr "CRITIQUE - La durée de vie du paquet est dépassée (%s)" 3171msgstr "CRITIQUE - La durée de vie du paquet est dépassée (%s)"
3874 3172
3875#: plugins/check_ping.c:537
3876#, fuzzy, c-format 3173#, fuzzy, c-format
3877msgid "CRITICAL - Destination Unreachable (%s)\n" 3174msgid "CRITICAL - Destination Unreachable (%s)\n"
3878msgstr "CRITIQUE - Hôte inaccessible (%s)" 3175msgstr "CRITIQUE - Hôte inaccessible (%s)"
3879 3176
3880#: plugins/check_ping.c:544
3881#, fuzzy 3177#, fuzzy
3882msgid "Unable to realloc warn_text\n" 3178msgid "Unable to realloc warn_text\n"
3883msgstr "Impossible de réattribuer le texte d'avertissement" 3179msgstr "Impossible de réattribuer le texte d'avertissement"
3884 3180
3885#: plugins/check_ping.c:561
3886#, c-format 3181#, c-format
3887msgid "Use ping to check connection statistics for a remote host." 3182msgid "Use ping to check connection statistics for a remote host."
3888msgstr "" 3183msgstr ""
3889"Utilise ping pour vérifier les statistiques de connections d'un hôte distant." 3184"Utilise ping pour vérifier les statistiques de connections d'un hôte distant."
3890 3185
3891#: plugins/check_ping.c:573
3892msgid "host to ping" 3186msgid "host to ping"
3893msgstr "hôte à tester" 3187msgstr "hôte à tester"
3894 3188
3895#: plugins/check_ping.c:579
3896msgid "number of ICMP ECHO packets to send" 3189msgid "number of ICMP ECHO packets to send"
3897msgstr "nombre de paquets ICMP à envoyer" 3190msgstr "nombre de paquets ICMP à envoyer"
3898 3191
3899#: plugins/check_ping.c:580
3900#, c-format 3192#, c-format
3901msgid "(Default: %d)\n" 3193msgid "(Default: %d)\n"
3902msgstr "(Défaut: %d)\n" 3194msgstr "(Défaut: %d)\n"
3903 3195
3904#: plugins/check_ping.c:582
3905msgid "show HTML in the plugin output (obsoleted by urlize)" 3196msgid "show HTML in the plugin output (obsoleted by urlize)"
3906msgstr "" 3197msgstr ""
3907 3198
3908#: plugins/check_ping.c:587
3909msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel" 3199msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"
3910msgstr "" 3200msgstr ""
3911"Le seuil est <rta>,<pl>% où <rta> est le temps moyen pour l'aller retour (ms)" 3201"Le seuil est <rta>,<pl>% où <rta> est le temps moyen pour l'aller retour (ms)"
3912 3202
3913#: plugins/check_ping.c:588
3914msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the" 3203msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"
3915msgstr "qui déclenche un résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le " 3204msgstr "qui déclenche un résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le "
3916 3205
3917#: plugins/check_ping.c:589
3918msgid "percentage of packet loss to trigger an alarm state." 3206msgid "percentage of packet loss to trigger an alarm state."
3919msgstr "pourcentage de paquets perdus pour déclencher une alarme." 3207msgstr "pourcentage de paquets perdus pour déclencher une alarme."
3920 3208
3921#: plugins/check_ping.c:592
3922msgid "" 3209msgid ""
3923"This plugin uses the ping command to probe the specified host for packet loss" 3210"This plugin uses the ping command to probe the specified host for packet loss"
3924msgstr "" 3211msgstr ""
3925"Ce plugin utilise la commande ping pour vérifier l'hôte spécifié pour les " 3212"Ce plugin utilise la commande ping pour vérifier l'hôte spécifié pour les "
3926"pertes de paquets" 3213"pertes de paquets"
3927 3214
3928#: plugins/check_ping.c:593
3929msgid "" 3215msgid ""
3930"(percentage) and round trip average (milliseconds). It can produce HTML " 3216"(percentage) and round trip average (milliseconds). It can produce HTML "
3931"output" 3217"output"
3932msgstr "" 3218msgstr ""
3933 3219
3934#: plugins/check_ping.c:594
3935msgid "" 3220msgid ""
3936"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in" 3221"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"
3937msgstr "" 3222msgstr ""
3938 3223
3939#: plugins/check_ping.c:595
3940msgid "the contrib area of the downloads section at http://www.nagios.org/" 3224msgid "the contrib area of the downloads section at http://www.nagios.org/"
3941msgstr "" 3225msgstr ""
3942 3226
3943#: plugins/check_procs.c:193
3944#, c-format 3227#, c-format
3945msgid "CMD: %s\n" 3228msgid "CMD: %s\n"
3946msgstr "Commande: %s\n" 3229msgstr "Commande: %s\n"
3947 3230
3948#: plugins/check_procs.c:198
3949msgid "System call sent warnings to stderr" 3231msgid "System call sent warnings to stderr"
3950msgstr "" 3232msgstr ""
3951"L'appel système à retourné des avertissement vers le canal d'erreur standard" 3233"L'appel système à retourné des avertissement vers le canal d'erreur standard"
3952 3234
3953#: plugins/check_procs.c:326
3954#, c-format 3235#, c-format
3955msgid "Not parseable: %s" 3236msgid "Not parseable: %s"
3956msgstr "Impossible de parcourir les arguments: %s" 3237msgstr "Impossible de parcourir les arguments: %s"
3957 3238
3958#: plugins/check_procs.c:331
3959#, c-format 3239#, c-format
3960msgid "Unable to read output\n" 3240msgid "Unable to read output\n"
3961msgstr "Impossible de lire les données en entrée\n" 3241msgstr "Impossible de lire les données en entrée\n"
3962 3242
3963#: plugins/check_procs.c:348
3964#, c-format 3243#, c-format
3965msgid "%d warn out of " 3244msgid "%d warn out of "
3966msgstr "%d avertissements sur" 3245msgstr "%d avertissements sur"
3967 3246
3968#: plugins/check_procs.c:353
3969#, c-format 3247#, c-format
3970msgid "%d crit, %d warn out of " 3248msgid "%d crit, %d warn out of "
3971msgstr "%d crit, %d alertes sur " 3249msgstr "%d crit, %d alertes sur "
3972 3250
3973#: plugins/check_procs.c:359
3974#, c-format 3251#, c-format
3975msgid " with %s" 3252msgid " with %s"
3976msgstr " avec %s" 3253msgstr " avec %s"
3977 3254
3978#: plugins/check_procs.c:453
3979msgid "Parent Process ID must be an integer!" 3255msgid "Parent Process ID must be an integer!"
3980msgstr "L'identifiant du processus parent doit être un entier!" 3256msgstr "L'identifiant du processus parent doit être un entier!"
3981 3257
3982#: plugins/check_procs.c:459 plugins/check_procs.c:586
3983#, c-format 3258#, c-format
3984msgid "%s%sSTATE = %s" 3259msgid "%s%sSTATE = %s"
3985msgstr "%s%sETAT = %s" 3260msgstr "%s%sETAT = %s"
3986 3261
3987#: plugins/check_procs.c:468
3988msgid "UID was not found" 3262msgid "UID was not found"
3989msgstr "L'UID n'a pas été trouvé" 3263msgstr "L'UID n'a pas été trouvé"
3990 3264
3991#: plugins/check_procs.c:474
3992msgid "User name was not found" 3265msgid "User name was not found"
3993msgstr "L'utilisateur n'a pas été trouvé" 3266msgstr "L'utilisateur n'a pas été trouvé"
3994 3267
3995#: plugins/check_procs.c:489
3996#, c-format 3268#, c-format
3997msgid "%s%scommand name '%s'" 3269msgid "%s%scommand name '%s'"
3998msgstr "%s%snom de la commande '%s'" 3270msgstr "%s%snom de la commande '%s'"
3999 3271
4000#: plugins/check_procs.c:524 3272#, c-format
3273msgid "%s%sexclude progs '%s'"
3274msgstr ""
3275
4001msgid "RSS must be an integer!" 3276msgid "RSS must be an integer!"
4002msgstr "RSS doit être un entier!" 3277msgstr "RSS doit être un entier!"
4003 3278
4004#: plugins/check_procs.c:531
4005msgid "VSZ must be an integer!" 3279msgid "VSZ must be an integer!"
4006msgstr "VSZ doit être un entier!" 3280msgstr "VSZ doit être un entier!"
4007 3281
4008#: plugins/check_procs.c:539
4009msgid "PCPU must be a float!" 3282msgid "PCPU must be a float!"
4010msgstr "PCPU doit être un nombre en virgule flottante!" 3283msgstr "PCPU doit être un nombre en virgule flottante!"
4011 3284
4012#: plugins/check_procs.c:563
4013msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!" 3285msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"
4014msgstr "Metric doit être l'un des PROCS, VSZ, RSS, CPU, ELAPSED!" 3286msgstr "Metric doit être l'un des PROCS, VSZ, RSS, CPU, ELAPSED!"
4015 3287
4016#: plugins/check_procs.c:694
4017msgid "" 3288msgid ""
4018"Checks all processes and generates WARNING or CRITICAL states if the " 3289"Checks all processes and generates WARNING or CRITICAL states if the "
4019"specified" 3290"specified"
4020msgstr "" 3291msgstr ""
4021 3292
4022#: plugins/check_procs.c:695
4023msgid "" 3293msgid ""
4024"metric is outside the required threshold ranges. The metric defaults to " 3294"metric is outside the required threshold ranges. The metric defaults to "
4025"number" 3295"number"
4026msgstr "" 3296msgstr ""
4027 3297
4028#: plugins/check_procs.c:696
4029msgid "" 3298msgid ""
4030"of processes. Search filters can be applied to limit the processes to check." 3299"of processes. Search filters can be applied to limit the processes to check."
4031msgstr "" 3300msgstr ""
4032 3301
4033#: plugins/check_procs.c:705
4034msgid "Generate warning state if metric is outside this range" 3302msgid "Generate warning state if metric is outside this range"
4035msgstr "" 3303msgstr ""
4036 3304
4037#: plugins/check_procs.c:707
4038msgid "Generate critical state if metric is outside this range" 3305msgid "Generate critical state if metric is outside this range"
4039msgstr "" 3306msgstr ""
4040 3307
4041#: plugins/check_procs.c:709
4042msgid "Check thresholds against metric. Valid types:" 3308msgid "Check thresholds against metric. Valid types:"
4043msgstr "" 3309msgstr ""
4044 3310
4045#: plugins/check_procs.c:710
4046msgid "PROCS - number of processes (default)" 3311msgid "PROCS - number of processes (default)"
4047msgstr "PROCS - nombre de processus (défaut)" 3312msgstr "PROCS - nombre de processus (défaut)"
4048 3313
4049#: plugins/check_procs.c:711
4050msgid "VSZ - virtual memory size" 3314msgid "VSZ - virtual memory size"
4051msgstr "VSZ - taille mémoire virtuelle" 3315msgstr "VSZ - taille mémoire virtuelle"
4052 3316
4053#: plugins/check_procs.c:712
4054msgid "RSS - resident set memory size" 3317msgid "RSS - resident set memory size"
4055msgstr "" 3318msgstr ""
4056 3319
4057#: plugins/check_procs.c:713
4058msgid "CPU - percentage CPU" 3320msgid "CPU - percentage CPU"
4059msgstr "CPU - pourcentage du processeur" 3321msgstr "CPU - pourcentage du processeur"
4060 3322
4061#: plugins/check_procs.c:716
4062msgid "ELAPSED - time elapsed in seconds" 3323msgid "ELAPSED - time elapsed in seconds"
4063msgstr "ELAPSED - temps écoulé en secondes" 3324msgstr "ELAPSED - temps écoulé en secondes"
4064 3325
4065#: plugins/check_procs.c:721
4066msgid "Extra information. Up to 3 verbosity levels" 3326msgid "Extra information. Up to 3 verbosity levels"
4067msgstr "informations supplémentaires. Jusqu'à 3 niveaux de verbosité" 3327msgstr "informations supplémentaires. Jusqu'à 3 niveaux de verbosité"
4068 3328
4069#: plugins/check_procs.c:724
4070msgid "Filter own process the traditional way by PID instead of /proc/pid/exe" 3329msgid "Filter own process the traditional way by PID instead of /proc/pid/exe"
4071msgstr "" 3330msgstr ""
4072 3331
4073#: plugins/check_procs.c:729
4074msgid "Only scan for processes that have, in the output of `ps`, one or" 3332msgid "Only scan for processes that have, in the output of `ps`, one or"
4075msgstr "" 3333msgstr ""
4076 3334
4077#: plugins/check_procs.c:730
4078msgid "more of the status flags you specify (for example R, Z, S, RS," 3335msgid "more of the status flags you specify (for example R, Z, S, RS,"
4079msgstr "" 3336msgstr ""
4080 3337
4081#: plugins/check_procs.c:731
4082msgid "RSZDT, plus others based on the output of your 'ps' command)." 3338msgid "RSZDT, plus others based on the output of your 'ps' command)."
4083msgstr "" 3339msgstr ""
4084 3340
4085#: plugins/check_procs.c:733
4086msgid "Only scan for children of the parent process ID indicated." 3341msgid "Only scan for children of the parent process ID indicated."
4087msgstr "" 3342msgstr ""
4088 3343
4089#: plugins/check_procs.c:735
4090msgid "Only scan for processes with VSZ higher than indicated." 3344msgid "Only scan for processes with VSZ higher than indicated."
4091msgstr "" 3345msgstr ""
4092 3346
4093#: plugins/check_procs.c:737
4094msgid "Only scan for processes with RSS higher than indicated." 3347msgid "Only scan for processes with RSS higher than indicated."
4095msgstr "" 3348msgstr ""
4096 3349
4097#: plugins/check_procs.c:739
4098msgid "Only scan for processes with PCPU higher than indicated." 3350msgid "Only scan for processes with PCPU higher than indicated."
4099msgstr "" 3351msgstr ""
4100 3352
4101#: plugins/check_procs.c:741
4102msgid "Only scan for processes with user name or ID indicated." 3353msgid "Only scan for processes with user name or ID indicated."
4103msgstr "" 3354msgstr ""
4104 3355
4105#: plugins/check_procs.c:743
4106msgid "Only scan for processes with args that contain STRING." 3356msgid "Only scan for processes with args that contain STRING."
4107msgstr "" 3357msgstr ""
4108 3358
4109#: plugins/check_procs.c:745
4110msgid "Only scan for processes with args that contain the regex STRING." 3359msgid "Only scan for processes with args that contain the regex STRING."
4111msgstr "" 3360msgstr ""
4112 3361
4113#: plugins/check_procs.c:747
4114msgid "Only scan for exact matches of COMMAND (without path)." 3362msgid "Only scan for exact matches of COMMAND (without path)."
4115msgstr "" 3363msgstr ""
4116 3364
4117#: plugins/check_procs.c:749 3365msgid "Exclude processes which match this comma separated list"
3366msgstr ""
3367
4118msgid "Only scan for non kernel threads (works on Linux only)." 3368msgid "Only scan for non kernel threads (works on Linux only)."
4119msgstr "" 3369msgstr ""
4120 3370
4121#: plugins/check_procs.c:751
4122#, c-format 3371#, c-format
4123msgid "" 3372msgid ""
4124"\n" 3373"\n"
@@ -4133,7 +3382,6 @@ msgstr ""
4133"est à l'intérieur du seuil\n" 3382"est à l'intérieur du seuil\n"
4134"\n" 3383"\n"
4135 3384
4136#: plugins/check_procs.c:756
4137#, c-format 3385#, c-format
4138msgid "" 3386msgid ""
4139"This plugin checks the number of currently running processes and\n" 3387"This plugin checks the number of currently running processes and\n"
@@ -4150,932 +3398,840 @@ msgstr ""
4150"état actuel (ex: 'Z'), ou par le nombre de processus en cours d'exécution\n" 3398"état actuel (ex: 'Z'), ou par le nombre de processus en cours d'exécution\n"
4151"\n" 3399"\n"
4152 3400
4153#: plugins/check_procs.c:765
4154msgid "Warning if not two processes with command name portsentry." 3401msgid "Warning if not two processes with command name portsentry."
4155msgstr "" 3402msgstr ""
4156 3403
4157#: plugins/check_procs.c:766
4158msgid "Critical if < 2 or > 1024 processes" 3404msgid "Critical if < 2 or > 1024 processes"
4159msgstr "" 3405msgstr ""
4160 3406
4161#: plugins/check_procs.c:768 3407msgid "Critical if not at least 1 process with command sshd"
3408msgstr ""
3409
3410msgid "Warning if > 1024 processes with command name sshd."
3411msgstr ""
3412
3413msgid "Critical if < 1 processes with command name sshd."
3414msgstr ""
3415
4162msgid "Warning alert if > 10 processes with command arguments containing" 3416msgid "Warning alert if > 10 processes with command arguments containing"
4163msgstr "" 3417msgstr ""
4164 3418
4165#: plugins/check_procs.c:769
4166msgid "'/usr/local/bin/perl' and owned by root" 3419msgid "'/usr/local/bin/perl' and owned by root"
4167msgstr "" 3420msgstr ""
4168 3421
4169#: plugins/check_procs.c:771
4170msgid "Alert if VSZ of any processes over 50K or 100K" 3422msgid "Alert if VSZ of any processes over 50K or 100K"
4171msgstr "" 3423msgstr ""
4172 3424
4173#: plugins/check_procs.c:773 3425msgid "Alert if CPU of any processes over 10% or 20%"
4174#, c-format
4175msgid "Alert if CPU of any processes over 10%% or 20%%"
4176msgstr "" 3426msgstr ""
4177 3427
4178#: plugins/check_radius.c:165 3428#, fuzzy
4179msgid "Config file error" 3429msgid "Config file error\n"
4180msgstr "Erreur dans le fichier de configuration" 3430msgstr "Erreur dans le fichier de configuration"
4181 3431
4182#: plugins/check_radius.c:174 3432#, fuzzy
4183msgid "Out of Memory?" 3433msgid "Out of Memory?\n"
4184msgstr "Manque de Mémoire?" 3434msgstr "Manque de Mémoire?"
4185 3435
4186#: plugins/check_radius.c:178 3436#, fuzzy
4187msgid "Invalid NAS-Identifier" 3437msgid "Invalid NAS-Identifier\n"
4188msgstr "NAS-Identifier invalide" 3438msgstr "NAS-Identifier invalide"
4189 3439
4190#: plugins/check_radius.c:183 plugins/check_radius.c:185 3440#, c-format
4191#: plugins/check_radius.c:191 3441msgid "gethostname() failed!\n"
4192msgid "Invalid NAS-IP-Address" 3442msgstr "La commande gethostname() à échoué\n"
4193msgstr "NAS-IP-Address invalide"
4194 3443
4195#: plugins/check_radius.c:188 3444#, fuzzy
4196msgid "Can't find local IP for NAS-IP-Address" 3445msgid "Invalid NAS-IP-Address\n"
4197msgstr "Impossible de trouver une addresse IP locale pour le NAS-IP-Address" 3446msgstr "NAS-IP-Address invalide"
4198 3447
4199#: plugins/check_radius.c:202 3448#, fuzzy
4200msgid "Timeout" 3449msgid "Timeout\n"
4201msgstr "Temps dépassé" 3450msgstr "Temps dépassé"
4202 3451
4203#: plugins/check_radius.c:204 3452#, fuzzy
4204msgid "Auth Error" 3453msgid "Auth Error\n"
4205msgstr "Erreur d'authentification" 3454msgstr "Erreur d'authentification"
4206 3455
4207#: plugins/check_radius.c:206 3456#, fuzzy
4208msgid "Auth Failed" 3457msgid "Auth Failed\n"
4209msgstr "L'authentification à échoué" 3458msgstr "L'authentification à échoué"
4210 3459
4211#: plugins/check_radius.c:208 3460#, fuzzy
4212msgid "Bad Response" 3461msgid "Bad Response\n"
4213msgstr "Réponse invalide" 3462msgstr "Réponse invalide"
4214 3463
4215#: plugins/check_radius.c:212 3464#, fuzzy
4216msgid "Auth OK" 3465msgid "Auth OK\n"
4217msgstr "L'authentification à réussi" 3466msgstr "L'authentification à réussi"
4218 3467
4219#: plugins/check_radius.c:213
4220#, c-format 3468#, c-format
4221msgid "Unexpected result code %d" 3469msgid "Unexpected result code %d"
4222msgstr "Résultat inattendu: %d" 3470msgstr "Résultat inattendu: %d"
4223 3471
4224#: plugins/check_radius.c:302
4225msgid "Number of retries must be a positive integer" 3472msgid "Number of retries must be a positive integer"
4226msgstr "Le nombre d'essai doit être un entier positif" 3473msgstr "Le nombre d'essai doit être un entier positif"
4227 3474
4228#: plugins/check_radius.c:316
4229msgid "User not specified" 3475msgid "User not specified"
4230msgstr "L'utilisateur n'a pas été spécifié" 3476msgstr "L'utilisateur n'a pas été spécifié"
4231 3477
4232#: plugins/check_radius.c:318
4233msgid "Password not specified" 3478msgid "Password not specified"
4234msgstr "Le mot de passe n'a pas été spécifié" 3479msgstr "Le mot de passe n'a pas été spécifié"
4235 3480
4236#: plugins/check_radius.c:320
4237msgid "Configuration file not specified" 3481msgid "Configuration file not specified"
4238msgstr "Le fichier de configuration n'a pas été spécifié" 3482msgstr "Le fichier de configuration n'a pas été spécifié"
4239 3483
4240#: plugins/check_radius.c:338
4241msgid "Tests to see if a RADIUS server is accepting connections." 3484msgid "Tests to see if a RADIUS server is accepting connections."
4242msgstr "Teste si un serveur RADIUS accepte les connections." 3485msgstr "Teste si un serveur RADIUS accepte les connections."
4243 3486
4244#: plugins/check_radius.c:350
4245msgid "The user to authenticate" 3487msgid "The user to authenticate"
4246msgstr "" 3488msgstr ""
4247 3489
4248#: plugins/check_radius.c:352 3490msgid "Password for authentication (SECURITY RISK)"
4249msgid "Password for autentication (SECURITY RISK)"
4250msgstr "" 3491msgstr ""
4251 3492
4252#: plugins/check_radius.c:354
4253msgid "NAS identifier" 3493msgid "NAS identifier"
4254msgstr "" 3494msgstr ""
4255 3495
4256#: plugins/check_radius.c:356
4257msgid "NAS IP Address" 3496msgid "NAS IP Address"
4258msgstr "Adresse IP NAS" 3497msgstr "Adresse IP NAS"
4259 3498
4260#: plugins/check_radius.c:358
4261msgid "Configuration file" 3499msgid "Configuration file"
4262msgstr "Fichier de configuration" 3500msgstr "Fichier de configuration"
4263 3501
4264#: plugins/check_radius.c:360
4265msgid "Response string to expect from the server" 3502msgid "Response string to expect from the server"
4266msgstr "" 3503msgstr ""
4267 3504
4268#: plugins/check_radius.c:362
4269msgid "Number of times to retry a failed connection" 3505msgid "Number of times to retry a failed connection"
4270msgstr "" 3506msgstr ""
4271 3507
4272#: plugins/check_radius.c:367
4273msgid "" 3508msgid ""
4274"This plugin tests a RADIUS server to see if it is accepting connections." 3509"This plugin tests a RADIUS server to see if it is accepting connections."
4275msgstr "" 3510msgstr ""
4276"Ce plugin teste un serveur RADIUS afin de vérifier si il accepte les " 3511"Ce plugin teste un serveur RADIUS afin de vérifier si il accepte les "
4277"connections." 3512"connections."
4278 3513
4279#: plugins/check_radius.c:368
4280msgid "" 3514msgid ""
4281"The server to test must be specified in the invocation, as well as a user" 3515"The server to test must be specified in the invocation, as well as a user"
4282msgstr "" 3516msgstr ""
4283 3517
4284#: plugins/check_radius.c:369 3518msgid "name and password. A configuration file must be present. The format of"
4285msgid ""
4286"name and password. A configuration file may also be present. The format of"
4287msgstr "" 3519msgstr ""
4288 3520
4289#: plugins/check_radius.c:370
4290msgid "" 3521msgid ""
4291"the configuration file is described in the radiusclient library sources." 3522"the configuration file is described in the radiusclient library sources."
4292msgstr "" 3523msgstr ""
4293 3524
4294#: plugins/check_radius.c:371
4295msgid "The password option presents a substantial security issue because the" 3525msgid "The password option presents a substantial security issue because the"
4296msgstr "" 3526msgstr ""
4297 3527
4298#: plugins/check_radius.c:372
4299msgid "" 3528msgid ""
4300"password can possibly be determined by careful watching of the command line" 3529"password can possibly be determined by careful watching of the command line"
4301msgstr "" 3530msgstr ""
4302 3531
4303#: plugins/check_radius.c:373 3532msgid "in a process listing. This risk is exacerbated because the plugin will"
4304msgid "in a process listing. This risk is exacerbated because the monitor will"
4305msgstr "" 3533msgstr ""
4306 3534
4307#: plugins/check_radius.c:374 3535msgid ""
4308msgid "run the plugin at regular predictable intervals. Please be sure that" 3536"typically be executed at regular predictable intervals. Please be sure that"
4309msgstr "" 3537msgstr ""
4310 3538
4311#: plugins/check_radius.c:375
4312msgid "the password used does not allow access to sensitive system resources." 3539msgid "the password used does not allow access to sensitive system resources."
4313msgstr "" 3540msgstr ""
4314 3541
4315#: plugins/check_real.c:91
4316#, c-format 3542#, c-format
4317msgid "Unable to connect to %s on port %d\n" 3543msgid "Unable to connect to %s on port %d\n"
4318msgstr "Impossible de se connecter à %s sur le port %d\n" 3544msgstr "Impossible de se connecter à %s sur le port %d\n"
4319 3545
4320#: plugins/check_real.c:113
4321#, c-format 3546#, c-format
4322msgid "No data received from %s\n" 3547msgid "No data received from %s\n"
4323msgstr "Pas de données reçues de %s\n" 3548msgstr "Pas de données reçues de %s\n"
4324 3549
4325#: plugins/check_real.c:118 plugins/check_real.c:191
4326msgid "Invalid REAL response received from host" 3550msgid "Invalid REAL response received from host"
4327msgstr "Réponses REAL invalide reçue de l'hôte" 3551msgstr "Réponses REAL invalide reçue de l'hôte"
4328 3552
4329#: plugins/check_real.c:120 plugins/check_real.c:193
4330#, c-format 3553#, c-format
4331msgid "Invalid REAL response received from host on port %d\n" 3554msgid "Invalid REAL response received from host on port %d\n"
4332msgstr "Réponses REAL invalide reçue de l'hôte sur le port %d\n" 3555msgstr "Réponses REAL invalide reçue de l'hôte sur le port %d\n"
4333 3556
4334#: plugins/check_real.c:184 plugins/check_tcp.c:311
4335#, c-format 3557#, c-format
4336msgid "No data received from host\n" 3558msgid "No data received from host\n"
4337msgstr "Pas de données reçues de l'hôte\n" 3559msgstr "Pas de données reçues de l'hôte\n"
4338 3560
4339#: plugins/check_real.c:247
4340#, c-format 3561#, c-format
4341msgid "REAL %s - %d second response time\n" 3562msgid "REAL %s - %d second response time\n"
4342msgstr "REAL %s - %d secondes de temps de réponse\n" 3563msgstr "REAL %s - %d secondes de temps de réponse\n"
4343 3564
4344#: plugins/check_real.c:336 plugins/check_ups.c:536
4345msgid "Warning time must be a positive integer" 3565msgid "Warning time must be a positive integer"
4346msgstr "Le seuil d'avertissement doit être un entier positif" 3566msgstr "Le seuil d'avertissement doit être un entier positif"
4347 3567
4348#: plugins/check_real.c:345 plugins/check_ups.c:527
4349msgid "Critical time must be a positive integer" 3568msgid "Critical time must be a positive integer"
4350msgstr "Le seuil critique doit être un entier positif" 3569msgstr "Le seuil critique doit être un entier positif"
4351 3570
4352#: plugins/check_real.c:381
4353msgid "You must provide a server to check" 3571msgid "You must provide a server to check"
4354msgstr "Vous devez fournir un serveur à vérifier" 3572msgstr "Vous devez fournir un serveur à vérifier"
4355 3573
4356#: plugins/check_real.c:413
4357msgid "This plugin tests the REAL service on the specified host." 3574msgid "This plugin tests the REAL service on the specified host."
4358msgstr "Ce plugin teste le service REAL sur l'hôte spécifié." 3575msgstr "Ce plugin teste le service REAL sur l'hôte spécifié."
4359 3576
4360#: plugins/check_real.c:425
4361msgid "Connect to this url" 3577msgid "Connect to this url"
4362msgstr "" 3578msgstr ""
4363 3579
4364#: plugins/check_real.c:427
4365#, c-format 3580#, c-format
4366msgid "String to expect in first line of server response (default: %s)\n" 3581msgid "String to expect in first line of server response (default: %s)\n"
4367msgstr "" 3582msgstr ""
4368"Texte attendu dans la première ligne de réponse du serveur (défaut: %s)\n" 3583"Texte attendu dans la première ligne de réponse du serveur (défaut: %s)\n"
4369 3584
4370#: plugins/check_real.c:437
4371msgid "This plugin will attempt to open an RTSP connection with the host." 3585msgid "This plugin will attempt to open an RTSP connection with the host."
4372msgstr "Ce plugin va essayer d'ouvrir un connexion RTSP avec l'hôte." 3586msgstr "Ce plugin va essayer d'ouvrir un connexion RTSP avec l'hôte."
4373 3587
4374#: plugins/check_real.c:438 plugins/check_smtp.c:830 3588msgid "Successful connects return STATE_OK, refusals and timeouts return"
4375msgid "Successul connects return STATE_OK, refusals and timeouts return"
4376msgstr "" 3589msgstr ""
4377 3590
4378#: plugins/check_real.c:439
4379msgid "" 3591msgid ""
4380"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects," 3592"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"
4381msgstr "" 3593msgstr ""
4382 3594
4383#: plugins/check_real.c:440
4384msgid "" 3595msgid ""
4385"but incorrect reponse messages from the host result in STATE_WARNING return" 3596"but incorrect response messages from the host result in STATE_WARNING return"
4386msgstr "" 3597msgstr ""
4387 3598
4388#: plugins/check_real.c:441
4389msgid "values." 3599msgid "values."
4390msgstr "" 3600msgstr ""
4391 3601
4392#: plugins/check_smtp.c:150 plugins/check_swap.c:265 plugins/check_swap.c:271
4393#, c-format 3602#, c-format
4394msgid "malloc() failed!\n" 3603msgid "malloc() failed!\n"
4395msgstr "l'allocation mémoire à échoué!\n" 3604msgstr "l'allocation mémoire à échoué!\n"
4396 3605
4397#: plugins/check_smtp.c:154
4398#, c-format 3606#, c-format
4399msgid "gethostname() failed!\n" 3607msgid "CRITICAL - Cannot create SSL context.\n"
4400msgstr "La commande gethostname() à échoué\n" 3608msgstr "CRITIQUE - Impossible de créer le contexte SSL.\n"
4401 3609
4402#: plugins/check_smtp.c:189 plugins/check_smtp.c:213
4403#, c-format 3610#, c-format
4404msgid "recv() failed\n" 3611msgid "recv() failed\n"
4405msgstr "La commande recv() à échoué\n" 3612msgstr "La commande recv() à échoué\n"
4406 3613
4407#: plugins/check_smtp.c:200
4408#, c-format
4409msgid "Invalid SMTP response received from host: %s\n"
4410msgstr "Réponse SMTP reçue de l'hôte invalide: %s\n"
4411
4412#: plugins/check_smtp.c:202
4413#, c-format
4414msgid "Invalid SMTP response received from host on port %d: %s\n"
4415msgstr "Réponse SMTP reçue de l'hôte sur le port %d invalide: %s\n"
4416
4417#: plugins/check_smtp.c:223
4418#, c-format 3614#, c-format
4419msgid "WARNING - TLS not supported by server\n" 3615msgid "WARNING - TLS not supported by server\n"
4420msgstr "AVERTISSEMENT: - TLS n'est pas supporté par ce serveur\n" 3616msgstr "AVERTISSEMENT: - TLS n'est pas supporté par ce serveur\n"
4421 3617
4422#: plugins/check_smtp.c:235
4423#, c-format 3618#, c-format
4424msgid "Server does not support STARTTLS\n" 3619msgid "Server does not support STARTTLS\n"
4425msgstr "Le serveur ne supporte pas STARTTLS\n" 3620msgstr "Le serveur ne supporte pas STARTTLS\n"
4426 3621
4427#: plugins/check_smtp.c:241
4428#, c-format
4429msgid "CRITICAL - Cannot create SSL context.\n"
4430msgstr "CRITIQUE - Impossible de créer le contexte SSL.\n"
4431
4432#: plugins/check_smtp.c:261
4433msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS." 3622msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS."
4434msgstr "" 3623msgstr ""
4435 3624
4436#: plugins/check_smtp.c:266
4437#, c-format 3625#, c-format
4438msgid "sent %s" 3626msgid "sent %s"
4439msgstr "envoyé %s" 3627msgstr "envoyé %s"
4440 3628
4441#: plugins/check_smtp.c:268
4442msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS." 3629msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS."
4443msgstr "" 3630msgstr ""
4444 3631
4445#: plugins/check_smtp.c:303 plugins/check_snmp.c:806 3632#, c-format
3633msgid "Invalid SMTP response received from host: %s\n"
3634msgstr "Réponse SMTP reçue de l'hôte invalide: %s\n"
3635
3636#, c-format
3637msgid "Invalid SMTP response received from host on port %d: %s\n"
3638msgstr "Réponse SMTP reçue de l'hôte sur le port %d invalide: %s\n"
3639
4446#, c-format 3640#, c-format
4447msgid "Could Not Compile Regular Expression" 3641msgid "Could Not Compile Regular Expression"
4448msgstr "Impossible de compiler l'expression rationnelle" 3642msgstr "Impossible de compiler l'expression rationnelle"
4449 3643
4450#: plugins/check_smtp.c:312
4451#, c-format 3644#, c-format
4452msgid "SMTP %s - Invalid response '%s' to command '%s'\n" 3645msgid "SMTP %s - Invalid response '%s' to command '%s'\n"
4453msgstr "SMTP %s - réponse invalide de '%s' à la commande '%s'\n" 3646msgstr "SMTP %s - réponse invalide de '%s' à la commande '%s'\n"
4454 3647
4455#: plugins/check_smtp.c:316 plugins/check_snmp.c:511
4456#, c-format 3648#, c-format
4457msgid "Execute Error: %s\n" 3649msgid "Execute Error: %s\n"
4458msgstr "Erreur d'exécution: %s\n" 3650msgstr "Erreur d'exécution: %s\n"
4459 3651
4460#: plugins/check_smtp.c:330
4461msgid "no authuser specified, " 3652msgid "no authuser specified, "
4462msgstr "Pas d'utilisateur pour l'authentification spécifié, " 3653msgstr "Pas d'utilisateur pour l'authentification spécifié, "
4463 3654
4464#: plugins/check_smtp.c:335
4465msgid "no authpass specified, " 3655msgid "no authpass specified, "
4466msgstr "pas de mot de passe spécifié, " 3656msgstr "pas de mot de passe spécifié, "
4467 3657
4468#: plugins/check_smtp.c:342 plugins/check_smtp.c:363 plugins/check_smtp.c:383
4469#: plugins/check_smtp.c:688
4470#, c-format 3658#, c-format
4471msgid "sent %s\n" 3659msgid "sent %s\n"
4472msgstr "envoyé %s\n" 3660msgstr "envoyé %s\n"
4473 3661
4474#: plugins/check_smtp.c:345
4475msgid "recv() failed after AUTH LOGIN, " 3662msgid "recv() failed after AUTH LOGIN, "
4476msgstr "recv() à échoué après AUTH LOGIN, " 3663msgstr "recv() à échoué après AUTH LOGIN, "
4477 3664
4478#: plugins/check_smtp.c:350 plugins/check_smtp.c:371 plugins/check_smtp.c:391
4479#: plugins/check_smtp.c:699
4480#, c-format 3665#, c-format
4481msgid "received %s\n" 3666msgid "received %s\n"
4482msgstr "reçu %s\n" 3667msgstr "reçu %s\n"
4483 3668
4484#: plugins/check_smtp.c:354
4485msgid "invalid response received after AUTH LOGIN, " 3669msgid "invalid response received after AUTH LOGIN, "
4486msgstr "Réponse invalide reçue après AUTH LOGIN, " 3670msgstr "Réponse invalide reçue après AUTH LOGIN, "
4487 3671
4488#: plugins/check_smtp.c:367
4489msgid "recv() failed after sending authuser, " 3672msgid "recv() failed after sending authuser, "
4490msgstr "La commande recv() a échoué après authuser, " 3673msgstr "La commande recv() a échoué après authuser, "
4491 3674
4492#: plugins/check_smtp.c:375
4493msgid "invalid response received after authuser, " 3675msgid "invalid response received after authuser, "
4494msgstr "Réponse invalide reçue après authuser, " 3676msgstr "Réponse invalide reçue après authuser, "
4495 3677
4496#: plugins/check_smtp.c:387
4497msgid "recv() failed after sending authpass, " 3678msgid "recv() failed after sending authpass, "
4498msgstr "la commande recv() à échoué après authpass, " 3679msgstr "la commande recv() à échoué après authpass, "
4499 3680
4500#: plugins/check_smtp.c:395
4501msgid "invalid response received after authpass, " 3681msgid "invalid response received after authpass, "
4502msgstr "Réponse invalide reçue après authpass, " 3682msgstr "Réponse invalide reçue après authpass, "
4503 3683
4504#: plugins/check_smtp.c:402
4505msgid "only authtype LOGIN is supported, " 3684msgid "only authtype LOGIN is supported, "
4506msgstr "seul la méthode d'authentification LOGIN est supportée, " 3685msgstr "seul la méthode d'authentification LOGIN est supportée, "
4507 3686
4508#: plugins/check_smtp.c:426
4509#, c-format 3687#, c-format
4510msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n" 3688msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n"
4511msgstr "SMTP %s - %s%.3f sec. de temps de réponse%s%s|%s\n" 3689msgstr "SMTP %s - %s%.3f sec. de temps de réponse%s%s|%s\n"
4512 3690
4513#: plugins/check_smtp.c:536 plugins/check_smtp.c:548
4514#, c-format 3691#, c-format
4515msgid "Could not realloc() units [%d]\n" 3692msgid "Could not realloc() units [%d]\n"
4516msgstr "Impossible de réallouer des unités [%d]\n" 3693msgstr "Impossible de réallouer des unités [%d]\n"
4517 3694
4518#: plugins/check_smtp.c:556
4519#, fuzzy 3695#, fuzzy
4520msgid "Critical time must be a positive" 3696msgid "Critical time must be a positive"
4521msgstr "Le seuil critique doit être un entier positif" 3697msgstr "Le seuil critique doit être un entier positif"
4522 3698
4523#: plugins/check_smtp.c:564
4524#, fuzzy 3699#, fuzzy
4525msgid "Warning time must be a positive" 3700msgid "Warning time must be a positive"
4526msgstr "Le seuil d'avertissement doit être un entier positif" 3701msgstr "Le seuil d'avertissement doit être un entier positif"
4527 3702
4528#: plugins/check_smtp.c:611
4529msgid "SSL support not available - install OpenSSL and recompile" 3703msgid "SSL support not available - install OpenSSL and recompile"
4530msgstr "SSL n'est pas disponible - installer OpenSSL et recompilez" 3704msgstr "SSL n'est pas disponible - installer OpenSSL et recompilez"
4531 3705
4532#: plugins/check_smtp.c:679 plugins/check_smtp.c:684 3706msgid "Set either -s/--ssl/--tls or -S/--starttls"
3707msgstr "Définissez -s/--ssl/--tls ou -S/--starttls"
3708
4533#, c-format 3709#, c-format
4534msgid "Connection closed by server before sending QUIT command\n" 3710msgid "Connection closed by server before sending QUIT command\n"
4535msgstr "" 3711msgstr ""
4536 3712
4537#: plugins/check_smtp.c:694
4538#, c-format 3713#, c-format
4539msgid "recv() failed after QUIT." 3714msgid "recv() failed after QUIT."
4540msgstr "recv() à échoué après QUIT." 3715msgstr "recv() à échoué après QUIT."
4541 3716
4542#: plugins/check_smtp.c:696
4543#, c-format 3717#, c-format
4544msgid "Connection reset by peer." 3718msgid "Connection reset by peer."
4545msgstr "" 3719msgstr ""
4546 3720
4547#: plugins/check_smtp.c:784
4548msgid "This plugin will attempt to open an SMTP connection with the host." 3721msgid "This plugin will attempt to open an SMTP connection with the host."
4549msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte." 3722msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte."
4550 3723
4551#: plugins/check_smtp.c:798
4552#, c-format 3724#, c-format
4553msgid " String to expect in first line of server response (default: '%s')\n" 3725msgid " String to expect in first line of server response (default: '%s')\n"
4554msgstr "" 3726msgstr ""
4555" Texte attendu dans la première ligne de réponse du serveur (défaut: " 3727" Texte attendu dans la première ligne de réponse du serveur (défaut: "
4556"'%s')\n" 3728"'%s')\n"
4557 3729
4558#: plugins/check_smtp.c:800
4559msgid "SMTP command (may be used repeatedly)" 3730msgid "SMTP command (may be used repeatedly)"
4560msgstr "Commande SMTP (peut être utilisé plusieurs fois)" 3731msgstr "Commande SMTP (peut être utilisé plusieurs fois)"
4561 3732
4562#: plugins/check_smtp.c:802
4563msgid "Expected response to command (may be used repeatedly)" 3733msgid "Expected response to command (may be used repeatedly)"
4564msgstr "" 3734msgstr ""
4565 3735
4566#: plugins/check_smtp.c:804
4567msgid "FROM-address to include in MAIL command, required by Exchange 2000" 3736msgid "FROM-address to include in MAIL command, required by Exchange 2000"
4568msgstr "" 3737msgstr ""
4569 3738
4570#: plugins/check_smtp.c:806
4571msgid "FQDN used for HELO" 3739msgid "FQDN used for HELO"
4572msgstr "" 3740msgstr ""
4573 3741
4574#: plugins/check_smtp.c:809 plugins/check_tcp.c:665 3742msgid "Use PROXY protocol prefix for the connection."
3743msgstr "Utiliser le préfixe du protocole PROXY pour la connexion."
3744
4575msgid "Minimum number of days a certificate has to be valid." 3745msgid "Minimum number of days a certificate has to be valid."
4576msgstr "Nombre de jours minimum pour que le certificat soit valide." 3746msgstr "Nombre de jours minimum pour que le certificat soit valide."
4577 3747
4578#: plugins/check_smtp.c:811 3748#, fuzzy
3749msgid "Use SSL/TLS for the connection."
3750msgstr "Utiliser SSL/TLS pour la connexion."
3751
3752#, c-format
3753msgid " Sets default port to %d.\n"
3754msgstr " Définit le port par défaut à %d.\n"
3755
4579msgid "Use STARTTLS for the connection." 3756msgid "Use STARTTLS for the connection."
4580msgstr "" 3757msgstr "Utiliser STARTTLS pour la connexion."
4581 3758
4582#: plugins/check_smtp.c:815
4583msgid "SMTP AUTH type to check (default none, only LOGIN supported)" 3759msgid "SMTP AUTH type to check (default none, only LOGIN supported)"
4584msgstr "" 3760msgstr ""
4585 3761
4586#: plugins/check_smtp.c:817
4587msgid "SMTP AUTH username" 3762msgid "SMTP AUTH username"
4588msgstr "" 3763msgstr ""
4589 3764
4590#: plugins/check_smtp.c:819
4591msgid "SMTP AUTH password" 3765msgid "SMTP AUTH password"
4592msgstr "" 3766msgstr ""
4593 3767
4594#: plugins/check_smtp.c:821 3768msgid "Send LHLO instead of HELO/EHLO"
3769msgstr ""
3770
4595msgid "Ignore failure when sending QUIT command to server" 3771msgid "Ignore failure when sending QUIT command to server"
4596msgstr "" 3772msgstr ""
4597 3773
4598#: plugins/check_smtp.c:831
4599msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful" 3774msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"
4600msgstr "" 3775msgstr ""
4601 3776
4602#: plugins/check_smtp.c:832 3777msgid "connects, but incorrect response messages from the host result in"
4603msgid "connects, but incorrect reponse messages from the host result in"
4604msgstr "" 3778msgstr ""
4605 3779
4606#: plugins/check_smtp.c:833
4607msgid "STATE_WARNING return values." 3780msgid "STATE_WARNING return values."
4608msgstr "" 3781msgstr ""
4609 3782
4610#: plugins/check_snmp.c:169 plugins/check_snmp.c:582
4611msgid "Cannot malloc" 3783msgid "Cannot malloc"
4612msgstr "" 3784msgstr ""
4613 3785
4614#: plugins/check_snmp.c:356
4615#, c-format 3786#, c-format
4616msgid "External command error: %s\n" 3787msgid "External command error: %s\n"
4617msgstr "Erreur d'exécution de commande externe: %s\n" 3788msgstr "Erreur d'exécution de commande externe: %s\n"
4618 3789
4619#: plugins/check_snmp.c:361
4620#, c-format 3790#, c-format
4621msgid "External command error with no output (return code: %d)\n" 3791msgid "External command error with no output (return code: %d)\n"
4622msgstr "" 3792msgstr ""
4623 3793
4624#: plugins/check_snmp.c:464
4625#, fuzzy, c-format 3794#, fuzzy, c-format
4626msgid "No valid data returned (%s)\n" 3795msgid "No valid data returned (%s)\n"
4627msgstr "Pas de données valides reçues" 3796msgstr "Pas de données valides reçues"
4628 3797
4629#: plugins/check_snmp.c:475
4630msgid "Time duration between plugin calls is invalid" 3798msgid "Time duration between plugin calls is invalid"
4631msgstr "" 3799msgstr ""
4632 3800
4633#: plugins/check_snmp.c:588
4634msgid "Cannot asprintf()" 3801msgid "Cannot asprintf()"
4635msgstr "" 3802msgstr ""
4636 3803
4637#: plugins/check_snmp.c:594
4638#, fuzzy 3804#, fuzzy
4639msgid "Cannot realloc()" 3805msgid "Cannot realloc()"
4640msgstr "Impossible de réallouer des unités\n" 3806msgstr "Impossible de réallouer des unités\n"
4641 3807
4642#: plugins/check_snmp.c:610
4643msgid "No previous data to calculate rate - assume okay" 3808msgid "No previous data to calculate rate - assume okay"
4644msgstr "" 3809msgstr ""
4645 3810
4646#: plugins/check_snmp.c:751
4647msgid "Retries interval must be a positive integer" 3811msgid "Retries interval must be a positive integer"
4648msgstr "L'intervalle pour les essais doit être un entier positif" 3812msgstr "L'intervalle pour les essais doit être un entier positif"
4649 3813
4650#: plugins/check_snmp.c:831 3814#, fuzzy
3815msgid "Exit status must be a positive integer"
3816msgstr "Maxbytes doit être un entier positif"
3817
4651#, c-format 3818#, c-format
4652msgid "Could not reallocate labels[%d]" 3819msgid "Could not reallocate labels[%d]"
4653msgstr "Impossible de réallouer des labels[%d]" 3820msgstr "Impossible de réallouer des labels[%d]"
4654 3821
4655#: plugins/check_snmp.c:844
4656msgid "Could not reallocate labels\n" 3822msgid "Could not reallocate labels\n"
4657msgstr "Impossible de réallouer des labels\n" 3823msgstr "Impossible de réallouer des labels\n"
4658 3824
4659#: plugins/check_snmp.c:860
4660#, c-format 3825#, c-format
4661msgid "Could not reallocate units [%d]\n" 3826msgid "Could not reallocate units [%d]\n"
4662msgstr "Impossible de réallouer des unités [%d]\n" 3827msgstr "Impossible de réallouer des unités [%d]\n"
4663 3828
4664#: plugins/check_snmp.c:872
4665msgid "Could not realloc() units\n" 3829msgid "Could not realloc() units\n"
4666msgstr "Impossible de réallouer des unités\n" 3830msgstr "Impossible de réallouer des unités\n"
4667 3831
4668#: plugins/check_snmp.c:889
4669#, fuzzy 3832#, fuzzy
4670msgid "Rate multiplier must be a positive integer" 3833msgid "Rate multiplier must be a positive integer"
4671msgstr "La taille du paquet doit être un entier positif" 3834msgstr "La taille du paquet doit être un entier positif"
4672 3835
4673#: plugins/check_snmp.c:947
4674msgid "No host specified\n" 3836msgid "No host specified\n"
4675msgstr "Pas d'hôte spécifié\n" 3837msgstr "Pas d'hôte spécifié\n"
4676 3838
4677#: plugins/check_snmp.c:951
4678msgid "No OIDs specified\n" 3839msgid "No OIDs specified\n"
4679msgstr "Pas de compteur spécifié\n" 3840msgstr "Pas de compteur spécifié\n"
4680 3841
4681#: plugins/check_snmp.c:973
4682msgid "Invalid seclevel"
4683msgstr ""
4684
4685#: plugins/check_snmp.c:980 plugins/check_snmp.c:983 plugins/check_snmp.c:1001
4686#, c-format 3842#, c-format
4687msgid "Required parameter: %s\n" 3843msgid "Required parameter: %s\n"
4688msgstr "" 3844msgstr ""
4689 3845
4690#: plugins/check_snmp.c:1022 3846msgid "Invalid seclevel"
3847msgstr ""
3848
4691msgid "Invalid SNMP version" 3849msgid "Invalid SNMP version"
4692msgstr "Version de SNMP invalide" 3850msgstr "Version de SNMP invalide"
4693 3851
4694#: plugins/check_snmp.c:1039
4695msgid "Unbalanced quotes\n" 3852msgid "Unbalanced quotes\n"
4696msgstr "Guillemets manquants\n" 3853msgstr "Guillemets manquants\n"
4697 3854
4698#: plugins/check_snmp.c:1088 3855#, c-format
3856msgid "multiplier set (%.1f), but input is not a number: %s"
3857msgstr ""
3858
4699msgid "Check status of remote machines and obtain system information via SNMP" 3859msgid "Check status of remote machines and obtain system information via SNMP"
4700msgstr "" 3860msgstr ""
4701"Vérifie l'état des machines distantes et obtient l'information système via " 3861"Vérifie l'état des machines distantes et obtient l'information système via "
4702"SNMP" 3862"SNMP"
4703 3863
4704#: plugins/check_snmp.c:1101
4705msgid "Use SNMP GETNEXT instead of SNMP GET" 3864msgid "Use SNMP GETNEXT instead of SNMP GET"
4706msgstr "Utiliser SNMP GETNEXT au lieu de SNMP GET" 3865msgstr "Utiliser SNMP GETNEXT au lieu de SNMP GET"
4707 3866
4708#: plugins/check_snmp.c:1103
4709msgid "SNMP protocol version" 3867msgid "SNMP protocol version"
4710msgstr "Version du protocole SNMP" 3868msgstr "Version du protocole SNMP"
4711 3869
4712#: plugins/check_snmp.c:1105 3870#, fuzzy
3871msgid "SNMPv3 context"
3872msgstr "Nom d'utilisateur SNMPv3"
3873
4713msgid "SNMPv3 securityLevel" 3874msgid "SNMPv3 securityLevel"
4714msgstr "Niveau de sécurité SNMPv3 (securityLevel)" 3875msgstr "Niveau de sécurité SNMPv3 (securityLevel)"
4715 3876
4716#: plugins/check_snmp.c:1107
4717msgid "SNMPv3 auth proto" 3877msgid "SNMPv3 auth proto"
4718msgstr "Protocole d'authentification SNMPv3" 3878msgstr "Protocole d'authentification SNMPv3"
4719 3879
4720#: plugins/check_snmp.c:1109
4721msgid "SNMPv3 priv proto (default DES)" 3880msgid "SNMPv3 priv proto (default DES)"
4722msgstr "" 3881msgstr ""
4723 3882
4724#: plugins/check_snmp.c:1113
4725msgid "Optional community string for SNMP communication" 3883msgid "Optional community string for SNMP communication"
4726msgstr "Communauté optionnelle pour la communication SNMP" 3884msgstr "Communauté optionnelle pour la communication SNMP"
4727 3885
4728#: plugins/check_snmp.c:1114
4729msgid "default is" 3886msgid "default is"
4730msgstr "défaut:" 3887msgstr "défaut:"
4731 3888
4732#: plugins/check_snmp.c:1116
4733msgid "SNMPv3 username" 3889msgid "SNMPv3 username"
4734msgstr "Nom d'utilisateur SNMPv3" 3890msgstr "Nom d'utilisateur SNMPv3"
4735 3891
4736#: plugins/check_snmp.c:1118
4737msgid "SNMPv3 authentication password" 3892msgid "SNMPv3 authentication password"
4738msgstr "Mot de passe d'authentification SNMPv3" 3893msgstr "Mot de passe d'authentification SNMPv3"
4739 3894
4740#: plugins/check_snmp.c:1120
4741msgid "SNMPv3 privacy password" 3895msgid "SNMPv3 privacy password"
4742msgstr "Mot de passe de confidentialité SNMPv3" 3896msgstr "Mot de passe de confidentialité SNMPv3"
4743 3897
4744#: plugins/check_snmp.c:1124
4745msgid "Object identifier(s) or SNMP variables whose value you wish to query" 3898msgid "Object identifier(s) or SNMP variables whose value you wish to query"
4746msgstr "" 3899msgstr ""
4747 3900
4748#: plugins/check_snmp.c:1126
4749msgid "" 3901msgid ""
4750"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'" 3902"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'"
4751msgstr "" 3903msgstr ""
4752 3904
4753#: plugins/check_snmp.c:1127
4754msgid "for symbolic OIDs.)" 3905msgid "for symbolic OIDs.)"
4755msgstr "" 3906msgstr ""
4756 3907
4757#: plugins/check_snmp.c:1129
4758msgid "Delimiter to use when parsing returned data. Default is" 3908msgid "Delimiter to use when parsing returned data. Default is"
4759msgstr "" 3909msgstr ""
4760 3910
4761#: plugins/check_snmp.c:1130
4762msgid "Any data on the right hand side of the delimiter is considered" 3911msgid "Any data on the right hand side of the delimiter is considered"
4763msgstr "" 3912msgstr ""
4764 3913
4765#: plugins/check_snmp.c:1131
4766msgid "to be the data that should be used in the evaluation." 3914msgid "to be the data that should be used in the evaluation."
4767msgstr "" 3915msgstr ""
4768 3916
4769#: plugins/check_snmp.c:1135 3917msgid "If the check returns a 0 length string or NULL value"
3918msgstr ""
3919
3920msgid "This option allows you to choose what status you want it to exit"
3921msgstr ""
3922
3923msgid "Excluding this option renders the default exit of 3(STATE_UNKNOWN)"
3924msgstr ""
3925
3926msgid "0 = OK"
3927msgstr ""
3928
3929#, fuzzy
3930msgid "1 = WARNING"
3931msgstr "AVERTISSEMENT"
3932
3933#, fuzzy
3934msgid "2 = CRITICAL"
3935msgstr "CRITIQUE"
3936
3937#, fuzzy
3938msgid "3 = UNKNOWN"
3939msgstr "INCONNU"
3940
4770msgid "Warning threshold range(s)" 3941msgid "Warning threshold range(s)"
4771msgstr "Valeurs pour le seuil d'avertissement" 3942msgstr "Valeurs pour le seuil d'avertissement"
4772 3943
4773#: plugins/check_snmp.c:1137
4774msgid "Critical threshold range(s)" 3944msgid "Critical threshold range(s)"
4775msgstr "Valeurs pour le seuil critique" 3945msgstr "Valeurs pour le seuil critique"
4776 3946
4777#: plugins/check_snmp.c:1139
4778msgid "Enable rate calculation. See 'Rate Calculation' below" 3947msgid "Enable rate calculation. See 'Rate Calculation' below"
4779msgstr "" 3948msgstr ""
4780 3949
4781#: plugins/check_snmp.c:1141
4782msgid "" 3950msgid ""
4783"Converts rate per second. For example, set to 60 to convert to per minute" 3951"Converts rate per second. For example, set to 60 to convert to per minute"
4784msgstr "" 3952msgstr ""
4785 3953
4786#: plugins/check_snmp.c:1143 3954msgid "Add/subtract the specified OFFSET to numeric sensor data"
4787msgid "Add/substract the specified OFFSET to numeric sensor data"
4788msgstr "" 3955msgstr ""
4789 3956
4790#: plugins/check_snmp.c:1147
4791msgid "Return OK state (for that OID) if STRING is an exact match" 3957msgid "Return OK state (for that OID) if STRING is an exact match"
4792msgstr "" 3958msgstr ""
4793 3959
4794#: plugins/check_snmp.c:1149
4795msgid "" 3960msgid ""
4796"Return OK state (for that OID) if extended regular expression REGEX matches" 3961"Return OK state (for that OID) if extended regular expression REGEX matches"
4797msgstr "" 3962msgstr ""
4798 3963
4799#: plugins/check_snmp.c:1151
4800msgid "" 3964msgid ""
4801"Return OK state (for that OID) if case-insensitive extended REGEX matches" 3965"Return OK state (for that OID) if case-insensitive extended REGEX matches"
4802msgstr "" 3966msgstr ""
4803 3967
4804#: plugins/check_snmp.c:1153
4805msgid "Invert search result (CRITICAL if found)" 3968msgid "Invert search result (CRITICAL if found)"
4806msgstr "" 3969msgstr ""
4807 3970
4808#: plugins/check_snmp.c:1157
4809msgid "Prefix label for output from plugin" 3971msgid "Prefix label for output from plugin"
4810msgstr "" 3972msgstr ""
4811 3973
4812#: plugins/check_snmp.c:1159
4813msgid "Units label(s) for output data (e.g., 'sec.')." 3974msgid "Units label(s) for output data (e.g., 'sec.')."
4814msgstr "" 3975msgstr ""
4815 3976
4816#: plugins/check_snmp.c:1161
4817msgid "Separates output on multiple OID requests" 3977msgid "Separates output on multiple OID requests"
4818msgstr "" 3978msgstr ""
4819 3979
4820#: plugins/check_snmp.c:1165 3980msgid "Multiplies current value, 0 < n < 1 works as divider, defaults to 1"
4821msgid "Number of retries to be used in the requests" 3981msgstr ""
3982
3983msgid "C-style format string for float values (see option -M)"
3984msgstr ""
3985
3986msgid ""
3987"NOTE the final timeout value is calculated using this formula: "
3988"timeout_interval * retries + 5"
3989msgstr ""
3990
3991#, fuzzy
3992msgid "Number of retries to be used in the requests, default: "
4822msgstr "Le nombre d'essai pour les requêtes" 3993msgstr "Le nombre d'essai pour les requêtes"
4823 3994
4824#: plugins/check_snmp.c:1168
4825msgid "Label performance data with OIDs instead of --label's" 3995msgid "Label performance data with OIDs instead of --label's"
4826msgstr "" 3996msgstr ""
4827 3997
4828#: plugins/check_snmp.c:1173 3998msgid "Tell snmpget to not print errors encountered when parsing MIB files"
3999msgstr ""
4000
4829msgid "" 4001msgid ""
4830"This plugin uses the 'snmpget' command included with the NET-SNMP package." 4002"This plugin uses the 'snmpget' command included with the NET-SNMP package."
4831msgstr "" 4003msgstr ""
4832 4004
4833#: plugins/check_snmp.c:1174
4834msgid "" 4005msgid ""
4835"if you don't have the package installed, you will need to download it from" 4006"if you don't have the package installed, you will need to download it from"
4836msgstr "" 4007msgstr ""
4837"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis" 4008"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis"
4838 4009
4839#: plugins/check_snmp.c:1175
4840msgid "http://net-snmp.sourceforge.net before you can use this plugin." 4010msgid "http://net-snmp.sourceforge.net before you can use this plugin."
4841msgstr "http://net-snmp.sourceforge.net avant de pouvoir utiliser ce plugin." 4011msgstr "http://net-snmp.sourceforge.net avant de pouvoir utiliser ce plugin."
4842 4012
4843#: plugins/check_snmp.c:1179
4844#, fuzzy 4013#, fuzzy
4845msgid "" 4014msgid ""
4846"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited " 4015"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited "
4847msgstr "" 4016msgstr ""
4848"- Des OIDs multiples peuvent être séparées par des virgules ou des espaces" 4017"- Des OIDs multiples peuvent être séparées par des virgules ou des espaces"
4849 4018
4850#: plugins/check_snmp.c:1180
4851#, fuzzy 4019#, fuzzy
4852msgid "list (lists with internal spaces must be quoted)." 4020msgid "list (lists with internal spaces must be quoted)."
4853msgstr "(Les liste avec espaces doivent être entre guillemets). Max:" 4021msgstr "(Les liste avec espaces doivent être entre guillemets). Max:"
4854 4022
4855#: plugins/check_snmp.c:1184
4856msgid "" 4023msgid ""
4857"- When checking multiple OIDs, separate ranges by commas like '-w " 4024"- When checking multiple OIDs, separate ranges by commas like '-w "
4858"1:10,1:,:20'" 4025"1:10,1:,:20'"
4859msgstr "" 4026msgstr ""
4860 4027
4861#: plugins/check_snmp.c:1185
4862msgid "- Note that only one string and one regex may be checked at present" 4028msgid "- Note that only one string and one regex may be checked at present"
4863msgstr "" 4029msgstr ""
4864 4030
4865#: plugins/check_snmp.c:1186
4866msgid "" 4031msgid ""
4867"- All evaluation methods other than PR, STR, and SUBSTR expect that the value" 4032"- All evaluation methods other than PR, STR, and SUBSTR expect that the value"
4868msgstr "" 4033msgstr ""
4869 4034
4870#: plugins/check_snmp.c:1187
4871msgid "returned from the SNMP query is an unsigned integer." 4035msgid "returned from the SNMP query is an unsigned integer."
4872msgstr "" 4036msgstr ""
4873 4037
4874#: plugins/check_snmp.c:1190
4875msgid "Rate Calculation:" 4038msgid "Rate Calculation:"
4876msgstr "" 4039msgstr ""
4877 4040
4878#: plugins/check_snmp.c:1191
4879msgid "In many places, SNMP returns counters that are only meaningful when" 4041msgid "In many places, SNMP returns counters that are only meaningful when"
4880msgstr "" 4042msgstr ""
4881 4043
4882#: plugins/check_snmp.c:1192
4883msgid "calculating the counter difference since the last check. check_snmp" 4044msgid "calculating the counter difference since the last check. check_snmp"
4884msgstr "" 4045msgstr ""
4885 4046
4886#: plugins/check_snmp.c:1193
4887msgid "saves the last state information in a file so that the rate per second" 4047msgid "saves the last state information in a file so that the rate per second"
4888msgstr "" 4048msgstr ""
4889 4049
4890#: plugins/check_snmp.c:1194
4891msgid "can be calculated. Use the --rate option to save state information." 4050msgid "can be calculated. Use the --rate option to save state information."
4892msgstr "" 4051msgstr ""
4893 4052
4894#: plugins/check_snmp.c:1195
4895msgid "" 4053msgid ""
4896"On the first run, there will be no prior state - this will return with OK." 4054"On the first run, there will be no prior state - this will return with OK."
4897msgstr "" 4055msgstr ""
4898 4056
4899#: plugins/check_snmp.c:1196
4900msgid "The state is uniquely determined by the arguments to the plugin, so" 4057msgid "The state is uniquely determined by the arguments to the plugin, so"
4901msgstr "" 4058msgstr ""
4902 4059
4903#: plugins/check_snmp.c:1197
4904msgid "changing the arguments will create a new state file." 4060msgid "changing the arguments will create a new state file."
4905msgstr "" 4061msgstr ""
4906 4062
4907#: plugins/check_ssh.c:165
4908msgid "Port number must be a positive integer" 4063msgid "Port number must be a positive integer"
4909msgstr "Le numéro du port doit être un nombre entier positif" 4064msgstr "Le numéro du port doit être un nombre entier positif"
4910 4065
4911#: plugins/check_ssh.c:232
4912#, c-format 4066#, c-format
4913msgid "Server answer: %s" 4067msgid "Server answer: %s"
4914msgstr "Réponse du serveur: %s" 4068msgstr "Réponse du serveur: %s"
4915 4069
4916#: plugins/check_ssh.c:251 4070#, fuzzy, c-format
4917#, c-format 4071msgid "SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"
4918msgid "SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n" 4072msgstr ""
4073"SSH AVERTISSEMENT - %s (protocole %s) différence de version, attendu'%s'\n"
4074
4075#, fuzzy, c-format
4076msgid ""
4077"SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"
4919msgstr "" 4078msgstr ""
4920"SSH AVERTISSEMENT - %s (protocole %s) différence de version, attendu'%s'\n" 4079"SSH AVERTISSEMENT - %s (protocole %s) différence de version, attendu'%s'\n"
4921 4080
4922#: plugins/check_ssh.c:260
4923#, fuzzy, c-format 4081#, fuzzy, c-format
4924msgid "SSH OK - %s (protocol %s) | %s\n" 4082msgid "SSH OK - %s (protocol %s) | %s\n"
4925msgstr "SSH OK - %s (protocole %s)\n" 4083msgstr "SSH OK - %s (protocole %s)\n"
4926 4084
4927#: plugins/check_ssh.c:281
4928msgid "Try to connect to an SSH server at specified server and port" 4085msgid "Try to connect to an SSH server at specified server and port"
4929msgstr "Essaye de se connecter à un serveur SSH précisé à un port précis" 4086msgstr "Essaye de se connecter à un serveur SSH précisé à un port précis"
4930 4087
4931#: plugins/check_ssh.c:297 4088#, fuzzy
4932msgid "" 4089msgid ""
4933"Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)" 4090"Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"
4091msgstr ""
4092"AVERTISSEMENT si la chaîne ne correspond pas à la version précisée (ex: "
4093"OpenSSH_3.9p1)"
4094
4095#, fuzzy
4096msgid "Alert if protocol doesn't match expected protocol version (ex: 2.0)"
4934msgstr "" 4097msgstr ""
4935"AVERTISSEMENT si la chaîne ne correspond pas à la version précisée (ex: " 4098"AVERTISSEMENT si la chaîne ne correspond pas à la version précisée (ex: "
4936"OpenSSH_3.9p1)" 4099"OpenSSH_3.9p1)"
4937 4100
4938#: plugins/check_swap.c:169
4939#, c-format 4101#, c-format
4940msgid "Command: %s\n" 4102msgid "Command: %s\n"
4941msgstr "Commande: %s\n" 4103msgstr "Commande: %s\n"
4942 4104
4943#: plugins/check_swap.c:171
4944#, c-format 4105#, c-format
4945msgid "Format: %s\n" 4106msgid "Format: %s\n"
4946msgstr "Format: %s\n" 4107msgstr "Format: %s\n"
4947 4108
4948#: plugins/check_swap.c:207
4949#, c-format 4109#, c-format
4950msgid "total=%.0f, used=%.0f, free=%.0f\n" 4110msgid "total=%.0f, used=%.0f, free=%.0f\n"
4951msgstr "total=%.0f, utilisé=%.0f, libre=%.0ff\n" 4111msgstr "total=%.0f, utilisé=%.0f, libre=%.0ff\n"
4952 4112
4953#: plugins/check_swap.c:221
4954#, c-format 4113#, c-format
4955msgid "total=%.0f, free=%.0f\n" 4114msgid "total=%.0f, free=%.0f\n"
4956msgstr "total=%.0f, libre=%.0f\n" 4115msgstr "total=%.0f, libre=%.0f\n"
4957 4116
4958#: plugins/check_swap.c:253
4959msgid "Error getting swap devices\n" 4117msgid "Error getting swap devices\n"
4960msgstr "" 4118msgstr ""
4961 4119
4962#: plugins/check_swap.c:256
4963msgid "SWAP OK: No swap devices defined\n" 4120msgid "SWAP OK: No swap devices defined\n"
4964msgstr "SWAP OK: Pas de périphériques swap définis\n" 4121msgstr "SWAP OK: Pas de périphériques swap définis\n"
4965 4122
4966#: plugins/check_swap.c:277 plugins/check_swap.c:319
4967msgid "swapctl failed: " 4123msgid "swapctl failed: "
4968msgstr "swapctl à échoué:" 4124msgstr "swapctl à échoué:"
4969 4125
4970#: plugins/check_swap.c:278 plugins/check_swap.c:320
4971msgid "Error in swapctl call\n" 4126msgid "Error in swapctl call\n"
4972msgstr "" 4127msgstr ""
4973 4128
4974#: plugins/check_swap.c:357 4129#, fuzzy, c-format
4975#, c-format 4130msgid "SWAP %s - %d%% free (%dMB out of %dMB) %s|"
4976msgid "SWAP %s - %d%% free (%d MB out of %d MB) %s|"
4977msgstr "SWAP %s - %d%% libre (%d MB sur un total de %d MB) %s|" 4131msgstr "SWAP %s - %d%% libre (%d MB sur un total de %d MB) %s|"
4978 4132
4979#: plugins/check_swap.c:435 4133#, fuzzy
4980msgid "Warning threshold must be integer or percentage!" 4134msgid "Warning threshold percentage must be <= 100!"
4135msgstr "Le seuil d'avertissement doit être un entier positif"
4136
4137#, fuzzy
4138msgid "Warning threshold be positive integer or percentage!"
4981msgstr "Le seuil d'avertissement doit être un entier ou un pourcentage!" 4139msgstr "Le seuil d'avertissement doit être un entier ou un pourcentage!"
4982 4140
4983#: plugins/check_swap.c:453 4141#, fuzzy
4984msgid "Critical threshold must be integer or percentage!" 4142msgid "Critical threshold percentage must be <= 100!"
4143msgstr "le seuil critique doit être un entier positif"
4144
4145#, fuzzy
4146msgid "Critical threshold be positive integer or percentage!"
4985msgstr "Le seuil critique doit être un entier ou un pourcentage!" 4147msgstr "Le seuil critique doit être un entier ou un pourcentage!"
4986 4148
4987#: plugins/check_swap.c:507 4149#, fuzzy
4988msgid "Warning percentage should be more than critical percentage" 4150msgid ""
4151"no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
4152"or integer (0-3)."
4989msgstr "" 4153msgstr ""
4990"Le pourcentage d'avertissement doit être plus important que le pourcentage " 4154"Le résultat de temps dépassé doit être un nom d'état valide (OK, WARNING, "
4991"critique" 4155"CRITICAL, UNKNOWN) ou un nombre entier (0-3)."
4992 4156
4993#: plugins/check_swap.c:511 4157#, fuzzy
4994msgid "Warning free space should be more than critical free space" 4158msgid "Warning should be more than critical"
4995msgstr "" 4159msgstr ""
4996"Le seuil d'avertissement pour la place libre doit être plus grand que le " 4160"Le pourcentage d'avertissement doit être plus important que le pourcentage "
4997"seuil critique" 4161"critique"
4998 4162
4999#: plugins/check_swap.c:525
5000msgid "Check swap space on local machine." 4163msgid "Check swap space on local machine."
5001msgstr "Vérifie l'espace swap sur la machine locale." 4164msgstr "Vérifie l'espace swap sur la machine locale."
5002 4165
5003#: plugins/check_swap.c:535
5004msgid "" 4166msgid ""
5005"Exit with WARNING status if less than INTEGER bytes of swap space are free" 4167"Exit with WARNING status if less than INTEGER bytes of swap space are free"
5006msgstr "" 4168msgstr ""
5007"Sortir avec un résultat AVERTISSEMENT si moins de X octets de mémoire " 4169"Sortir avec un résultat AVERTISSEMENT si moins de X octets de mémoire "
5008"virtuelle sont libres" 4170"virtuelle sont libres"
5009 4171
5010#: plugins/check_swap.c:537
5011msgid "Exit with WARNING status if less than PERCENT of swap space is free" 4172msgid "Exit with WARNING status if less than PERCENT of swap space is free"
5012msgstr "" 4173msgstr ""
5013"Sortir avec un résultat AVERTISSEMENT si moins de X pour cent de mémoire " 4174"Sortir avec un résultat AVERTISSEMENT si moins de X pour cent de mémoire "
5014"virtuelle est libre" 4175"virtuelle est libre"
5015 4176
5016#: plugins/check_swap.c:539
5017msgid "" 4177msgid ""
5018"Exit with CRITICAL status if less than INTEGER bytes of swap space are free" 4178"Exit with CRITICAL status if less than INTEGER bytes of swap space are free"
5019msgstr "" 4179msgstr ""
5020"Sortir avec un résultat CRITIQUE si moins de X octets de mémoire virtuelle " 4180"Sortir avec un résultat CRITIQUE si moins de X octets de mémoire virtuelle "
5021"sont libres" 4181"sont libres"
5022 4182
5023#: plugins/check_swap.c:541 4183msgid "Exit with CRITICAL status if less than PERCENT of swap space is free"
5024msgid "Exit with CRITCAL status if less than PERCENT of swap space is free"
5025msgstr "" 4184msgstr ""
5026"Sortir avec un résultat CRITIQUE si moins de X pour cent de mémoire " 4185"Sortir avec un résultat CRITIQUE si moins de X pour cent de mémoire "
5027"virtuelle est libre" 4186"virtuelle est libre"
5028 4187
5029#: plugins/check_swap.c:543
5030msgid "Conduct comparisons for all swap partitions, one by one" 4188msgid "Conduct comparisons for all swap partitions, one by one"
5031msgstr "Vérifier chacune des partitions de mémoire virtuelle séparément" 4189msgstr "Vérifier chacune des partitions de mémoire virtuelle séparément"
5032 4190
5033#: plugins/check_swap.c:548 4191msgid ""
4192"Resulting state when there is no swap regardless of thresholds. Default:"
4193msgstr ""
4194
4195#, fuzzy
4196msgid ""
4197"Both INTEGER and PERCENT thresholds can be specified, they are all checked."
4198msgstr "Les seuils d'alerte et critiques peuvent être spécifiés avec -w et -c."
4199
5034msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s." 4200msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."
5035msgstr "" 4201msgstr ""
5036"Sur AIX, si -a est spécifié, le plugin utilise lsps -a, sinon il utilise " 4202"Sur AIX, si -a est spécifié, le plugin utilise lsps -a, sinon il utilise "
5037"lsps -s." 4203"lsps -s."
5038 4204
5039#: plugins/check_tcp.c:206
5040msgid "CRITICAL - Generic check_tcp called with unknown service\n" 4205msgid "CRITICAL - Generic check_tcp called with unknown service\n"
5041msgstr "" 4206msgstr ""
5042"CRITIQUE -check_tcp version générique utilisé avec un service inconnu\n" 4207"CRITIQUE -check_tcp version générique utilisé avec un service inconnu\n"
5043 4208
5044#: plugins/check_tcp.c:230
5045msgid "With UDP checks, a send/expect string must be specified." 4209msgid "With UDP checks, a send/expect string must be specified."
5046msgstr "" 4210msgstr ""
5047"Avec la surveillance UDP, une chaîne d'envoi et un chaîne de réponse doit " 4211"Avec la surveillance UDP, une chaîne d'envoi et un chaîne de réponse doit "
5048"être spécifiée." 4212"être spécifiée."
5049 4213
5050#: plugins/check_tcp.c:431
5051msgid "No arguments found" 4214msgid "No arguments found"
5052msgstr "Pas de paramètres" 4215msgstr "Pas de paramètres"
5053 4216
5054#: plugins/check_tcp.c:534
5055msgid "Maxbytes must be a positive integer" 4217msgid "Maxbytes must be a positive integer"
5056msgstr "Maxbytes doit être un entier positif" 4218msgstr "Maxbytes doit être un entier positif"
5057 4219
5058#: plugins/check_tcp.c:552
5059msgid "Refuse must be one of ok, warn, crit" 4220msgid "Refuse must be one of ok, warn, crit"
5060msgstr "Refuse doit être parmis ok, warn, crit" 4221msgstr "Refuse doit être parmis ok, warn, crit"
5061 4222
5062#: plugins/check_tcp.c:562
5063msgid "Mismatch must be one of ok, warn, crit" 4223msgid "Mismatch must be one of ok, warn, crit"
5064msgstr "Mismatch doit être parmis ok, warn, crit" 4224msgstr "Mismatch doit être parmis ok, warn, crit"
5065 4225
5066#: plugins/check_tcp.c:568
5067msgid "Delay must be a positive integer" 4226msgid "Delay must be a positive integer"
5068msgstr "Delay doit être un entier positif" 4227msgstr "Delay doit être un entier positif"
5069 4228
5070#: plugins/check_tcp.c:613
5071msgid "You must provide a server address" 4229msgid "You must provide a server address"
5072msgstr "Vous devez fournir une adresse serveur" 4230msgstr "Vous devez fournir une adresse serveur"
5073 4231
5074#: plugins/check_tcp.c:615
5075msgid "Invalid hostname, address or socket" 4232msgid "Invalid hostname, address or socket"
5076msgstr "Adresse/Nom/Socket invalide" 4233msgstr "Adresse/Nom/Socket invalide"
5077 4234
5078#: plugins/check_tcp.c:629
5079#, c-format 4235#, c-format
5080msgid "" 4236msgid ""
5081"This plugin tests %s connections with the specified host (or unix socket).\n" 4237"This plugin tests %s connections with the specified host (or unix socket).\n"
@@ -5084,400 +4240,351 @@ msgstr ""
5084"Ce plugin teste %s connections avec l'hôte spécifié (ou socket unix).\n" 4240"Ce plugin teste %s connections avec l'hôte spécifié (ou socket unix).\n"
5085"\n" 4241"\n"
5086 4242
5087#: plugins/check_tcp.c:642 4243#, fuzzy
5088msgid "" 4244msgid ""
5089"Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or " 4245"Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send "
5090"quit option" 4246"or quit option"
5091msgstr "" 4247msgstr ""
5092"Permet d'utiliser \\n, \\r, \\t ou \\ dans la chaîne de caractères send ou " 4248"Permet d'utiliser \\n, \\r, \\t ou \\ dans la chaîne de caractères send ou "
5093"quit. Doit être placé avant ces dernières." 4249"quit. Doit être placé avant ces dernières."
5094 4250
5095#: plugins/check_tcp.c:643
5096msgid "Default: nothing added to send, \\r\\n added to end of quit" 4251msgid "Default: nothing added to send, \\r\\n added to end of quit"
5097msgstr "" 4252msgstr ""
5098"Par défaut: Rien n'est ajouté à send, \\r\\n est ajouté à la fin de quit" 4253"Par défaut: Rien n'est ajouté à send, \\r\\n est ajouté à la fin de quit"
5099 4254
5100#: plugins/check_tcp.c:645
5101msgid "String to send to the server" 4255msgid "String to send to the server"
5102msgstr "Chaîne de caractères à envoyer au serveur" 4256msgstr "Chaîne de caractères à envoyer au serveur"
5103 4257
5104#: plugins/check_tcp.c:647
5105msgid "String to expect in server response" 4258msgid "String to expect in server response"
5106msgstr "Chaîne de caractères à attendre en réponse" 4259msgstr "Chaîne de caractères à attendre en réponse"
5107 4260
5108#: plugins/check_tcp.c:647
5109msgid "(may be repeated)" 4261msgid "(may be repeated)"
5110msgstr "(peut être utilisé plusieurs fois)" 4262msgstr "(peut être utilisé plusieurs fois)"
5111 4263
5112#: plugins/check_tcp.c:649
5113msgid "All expect strings need to occur in server response. Default is any" 4264msgid "All expect strings need to occur in server response. Default is any"
5114msgstr "" 4265msgstr ""
5115"Toutes les chaînes attendus (expect) doivent être repérés dans la réponse. " 4266"Toutes les chaînes attendus (expect) doivent être repérés dans la réponse. "
5116"Par défaut, n'importe laquelle suffit." 4267"Par défaut, n'importe laquelle suffit."
5117 4268
5118#: plugins/check_tcp.c:651
5119msgid "String to send server to initiate a clean close of the connection" 4269msgid "String to send server to initiate a clean close of the connection"
5120msgstr "Chaîne de caractères à envoyer pour fermer gracieusement la connection" 4270msgstr "Chaîne de caractères à envoyer pour fermer gracieusement la connection"
5121 4271
5122#: plugins/check_tcp.c:653
5123msgid "Accept TCP refusals with states ok, warn, crit (default: crit)" 4272msgid "Accept TCP refusals with states ok, warn, crit (default: crit)"
5124msgstr "" 4273msgstr ""
5125 4274
5126#: plugins/check_tcp.c:655
5127msgid "" 4275msgid ""
5128"Accept expected string mismatches with states ok, warn, crit (default: warn)" 4276"Accept expected string mismatches with states ok, warn, crit (default: warn)"
5129msgstr "" 4277msgstr ""
5130 4278
5131#: plugins/check_tcp.c:657
5132msgid "Hide output from TCP socket" 4279msgid "Hide output from TCP socket"
5133msgstr "Cacher la réponse provenant du socket TCP" 4280msgstr "Cacher la réponse provenant du socket TCP"
5134 4281
5135#: plugins/check_tcp.c:659
5136msgid "Close connection once more than this number of bytes are received" 4282msgid "Close connection once more than this number of bytes are received"
5137msgstr "" 4283msgstr ""
5138 4284
5139#: plugins/check_tcp.c:661
5140msgid "Seconds to wait between sending string and polling for response" 4285msgid "Seconds to wait between sending string and polling for response"
5141msgstr "" 4286msgstr ""
5142 4287
5143#: plugins/check_tcp.c:666
5144msgid "1st is #days for warning, 2nd is critical (if not specified - 0)." 4288msgid "1st is #days for warning, 2nd is critical (if not specified - 0)."
5145msgstr "" 4289msgstr ""
5146 4290
5147#: plugins/check_tcp.c:668
5148msgid "Use SSL for the connection." 4291msgid "Use SSL for the connection."
5149msgstr "" 4292msgstr ""
5150 4293
5151#: plugins/check_time.c:102 4294#, fuzzy
4295msgid "SSL server_name"
4296msgstr "Nom d'utilisateur SNMPv3"
4297
5152#, c-format 4298#, c-format
5153msgid "TIME UNKNOWN - could not connect to server %s, port %d\n" 4299msgid "TIME UNKNOWN - could not connect to server %s, port %d\n"
5154msgstr "TEMPS INCONNU - impossible de se connecter au serveur %s, au port %d\n" 4300msgstr "TEMPS INCONNU - impossible de se connecter au serveur %s, au port %d\n"
5155 4301
5156#: plugins/check_time.c:115
5157#, c-format 4302#, c-format
5158msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n" 4303msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n"
5159msgstr "" 4304msgstr ""
5160"TEMPS INCONNU - impossible d'envoyer une requête UDP au serveur %s, au port " 4305"TEMPS INCONNU - impossible d'envoyer une requête UDP au serveur %s, au port "
5161"%d\n" 4306"%d\n"
5162 4307
5163#: plugins/check_time.c:139
5164#, c-format 4308#, c-format
5165msgid "TIME UNKNOWN - no data received from server %s, port %d\n" 4309msgid "TIME UNKNOWN - no data received from server %s, port %d\n"
5166msgstr "TEMPS INCONNU - pas de données reçues du serveur %s, du port %d\n" 4310msgstr "TEMPS INCONNU - pas de données reçues du serveur %s, du port %d\n"
5167 4311
5168#: plugins/check_time.c:152
5169#, c-format 4312#, c-format
5170msgid "TIME %s - %d second response time|%s\n" 4313msgid "TIME %s - %d second response time|%s\n"
5171msgstr "TEMPS %s - %d secondes de temps de réponse|%s\n" 4314msgstr "TEMPS %s - %d secondes de temps de réponse|%s\n"
5172 4315
5173#: plugins/check_time.c:170
5174#, c-format 4316#, c-format
5175msgid "TIME %s - %lu second time difference|%s %s\n" 4317msgid "TIME %s - %lu second time difference|%s %s\n"
5176msgstr "TEMPS %s - %lu secondes de différence|%s %s\n" 4318msgstr "TEMPS %s - %lu secondes de différence|%s %s\n"
5177 4319
5178#: plugins/check_time.c:254
5179msgid "Warning thresholds must be a positive integer" 4320msgid "Warning thresholds must be a positive integer"
5180msgstr "Les seuils d'avertissement doivent être un entier positif" 4321msgstr "Les seuils d'avertissement doivent être un entier positif"
5181 4322
5182#: plugins/check_time.c:273
5183msgid "Critical thresholds must be a positive integer" 4323msgid "Critical thresholds must be a positive integer"
5184msgstr "Les seuils critiques doivent être un entier positif" 4324msgstr "Les seuils critiques doivent être un entier positif"
5185 4325
5186#: plugins/check_time.c:339
5187msgid "This plugin will check the time on the specified host." 4326msgid "This plugin will check the time on the specified host."
5188msgstr "Ce plugin va vérifier l'heure sur l'hôte spécifié." 4327msgstr "Ce plugin va vérifier l'heure sur l'hôte spécifié."
5189 4328
5190#: plugins/check_time.c:351
5191msgid "Use UDP to connect, not TCP" 4329msgid "Use UDP to connect, not TCP"
5192msgstr "" 4330msgstr ""
5193 4331
5194#: plugins/check_time.c:353
5195msgid "Time difference (sec.) necessary to result in a warning status" 4332msgid "Time difference (sec.) necessary to result in a warning status"
5196msgstr "" 4333msgstr ""
5197 4334
5198#: plugins/check_time.c:355
5199msgid "Time difference (sec.) necessary to result in a critical status" 4335msgid "Time difference (sec.) necessary to result in a critical status"
5200msgstr "" 4336msgstr ""
5201 4337
5202#: plugins/check_time.c:357
5203msgid "Response time (sec.) necessary to result in warning status" 4338msgid "Response time (sec.) necessary to result in warning status"
5204msgstr "" 4339msgstr ""
5205 4340
5206#: plugins/check_time.c:359
5207msgid "Response time (sec.) necessary to result in critical status" 4341msgid "Response time (sec.) necessary to result in critical status"
5208msgstr "" 4342msgstr ""
5209 4343
5210#: plugins/check_ups.c:144
5211msgid "On Battery, Low Battery" 4344msgid "On Battery, Low Battery"
5212msgstr "Sur Batterie, Batterie faible" 4345msgstr "Sur Batterie, Batterie faible"
5213 4346
5214#: plugins/check_ups.c:149
5215msgid "Online" 4347msgid "Online"
5216msgstr "En marche" 4348msgstr "En marche"
5217 4349
5218#: plugins/check_ups.c:152
5219msgid "On Battery" 4350msgid "On Battery"
5220msgstr "Sur Batterie" 4351msgstr "Sur Batterie"
5221 4352
5222#: plugins/check_ups.c:156
5223msgid ", Low Battery" 4353msgid ", Low Battery"
5224msgstr ", Batterie faible" 4354msgstr ", Batterie faible"
5225 4355
5226#: plugins/check_ups.c:160
5227msgid ", Calibrating" 4356msgid ", Calibrating"
5228msgstr ", Calibration" 4357msgstr ", Calibration"
5229 4358
5230#: plugins/check_ups.c:163
5231msgid ", Replace Battery" 4359msgid ", Replace Battery"
5232msgstr ", Remplacer la batterie" 4360msgstr ", Remplacer la batterie"
5233 4361
5234#: plugins/check_ups.c:167
5235msgid ", On Bypass" 4362msgid ", On Bypass"
5236msgstr ", Sur Secteur" 4363msgstr ", Sur Secteur"
5237 4364
5238#: plugins/check_ups.c:170
5239msgid ", Overload" 4365msgid ", Overload"
5240msgstr ", Surcharge" 4366msgstr ", Surcharge"
5241 4367
5242#: plugins/check_ups.c:173
5243msgid ", Trimming" 4368msgid ", Trimming"
5244msgstr ", En Test" 4369msgstr ", En Test"
5245 4370
5246#: plugins/check_ups.c:176
5247msgid ", Boosting" 4371msgid ", Boosting"
5248msgstr "" 4372msgstr ""
5249 4373
5250#: plugins/check_ups.c:179
5251msgid ", Charging" 4374msgid ", Charging"
5252msgstr ", En charge" 4375msgstr ", En charge"
5253 4376
5254#: plugins/check_ups.c:182
5255msgid ", Discharging" 4377msgid ", Discharging"
5256msgstr ", Déchargement" 4378msgstr ", Déchargement"
5257 4379
5258#: plugins/check_ups.c:185
5259msgid ", Unknown" 4380msgid ", Unknown"
5260msgstr ", Inconnu" 4381msgstr ", Inconnu"
5261 4382
5262#: plugins/check_ups.c:324
5263msgid "UPS does not support any available options\n" 4383msgid "UPS does not support any available options\n"
5264msgstr "L'UPS ne supporte aucune des options disponibles\n" 4384msgstr "L'UPS ne supporte aucune des options disponibles\n"
5265 4385
5266#: plugins/check_ups.c:348 plugins/check_ups.c:411
5267msgid "Invalid response received from host" 4386msgid "Invalid response received from host"
5268msgstr "Réponse invalide reçue de l'hôte" 4387msgstr "Réponse invalide reçue de l'hôte"
5269 4388
5270#: plugins/check_ups.c:420 4389msgid "UPS name to long for buffer"
4390msgstr ""
4391
5271#, c-format 4392#, c-format
5272msgid "CRITICAL - no such UPS '%s' on that host\n" 4393msgid "CRITICAL - no such UPS '%s' on that host\n"
5273msgstr "CRITIQUE - pas d'UPS '%s' sur cet hôte\n" 4394msgstr "CRITIQUE - pas d'UPS '%s' sur cet hôte\n"
5274 4395
5275#: plugins/check_ups.c:430
5276msgid "CRITICAL - UPS data is stale" 4396msgid "CRITICAL - UPS data is stale"
5277msgstr "CRITIQUE - les données de l'ups ne sont plus valables" 4397msgstr "CRITIQUE - les données de l'ups ne sont plus valables"
5278 4398
5279#: plugins/check_ups.c:435
5280#, c-format 4399#, c-format
5281msgid "Unknown error: %s\n" 4400msgid "Unknown error: %s\n"
5282msgstr "Erreur inconnue: %s\n" 4401msgstr "Erreur inconnue: %s\n"
5283 4402
5284#: plugins/check_ups.c:442
5285msgid "Error: unable to parse variable" 4403msgid "Error: unable to parse variable"
5286msgstr "Erreur: impossible de lire la variable" 4404msgstr "Erreur: impossible de lire la variable"
5287 4405
5288#: plugins/check_ups.c:549
5289msgid "Unrecognized UPS variable" 4406msgid "Unrecognized UPS variable"
5290msgstr "Variable d'UPS non reconnue" 4407msgstr "Variable d'UPS non reconnue"
5291 4408
5292#: plugins/check_ups.c:587
5293msgid "Error : no UPS indicated" 4409msgid "Error : no UPS indicated"
5294msgstr "Erreur: pas d'UPS indiqué" 4410msgstr "Erreur: pas d'UPS indiqué"
5295 4411
5296#: plugins/check_ups.c:607
5297msgid "" 4412msgid ""
5298"This plugin tests the UPS service on the specified host. Network UPS Tools" 4413"This plugin tests the UPS service on the specified host. Network UPS Tools"
5299msgstr "Ce plugin teste le service UPS sur l'hôte spécifié. Network UPS Tools" 4414msgstr "Ce plugin teste le service UPS sur l'hôte spécifié. Network UPS Tools"
5300 4415
5301#: plugins/check_ups.c:608
5302msgid "from www.networkupstools.org must be running for this plugin to work." 4416msgid "from www.networkupstools.org must be running for this plugin to work."
5303msgstr "" 4417msgstr ""
5304"de www.networkupstools.org doit s'exécuter sur l'hôte pour que ce plugin " 4418"de www.networkupstools.org doit s'exécuter sur l'hôte pour que ce plugin "
5305"fonctionne." 4419"fonctionne."
5306 4420
5307#: plugins/check_ups.c:620
5308msgid "Name of UPS" 4421msgid "Name of UPS"
5309msgstr "" 4422msgstr ""
5310 4423
5311#: plugins/check_ups.c:622
5312msgid "Output of temperatures in Celsius" 4424msgid "Output of temperatures in Celsius"
5313msgstr "Affichage des températures en Celsius" 4425msgstr "Affichage des températures en Celsius"
5314 4426
5315#: plugins/check_ups.c:624
5316msgid "Valid values for STRING are" 4427msgid "Valid values for STRING are"
5317msgstr "Les variables valides pour STRING sont" 4428msgstr "Les variables valides pour STRING sont"
5318 4429
5319#: plugins/check_ups.c:635
5320msgid "" 4430msgid ""
5321"This plugin attempts to determine the status of a UPS (Uninterruptible Power" 4431"This plugin attempts to determine the status of a UPS (Uninterruptible Power"
5322msgstr "" 4432msgstr ""
5323 4433
5324#: plugins/check_ups.c:636
5325msgid "" 4434msgid ""
5326"Supply) on a local or remote host. If the UPS is online or calibrating, the" 4435"Supply) on a local or remote host. If the UPS is online or calibrating, the"
5327msgstr "" 4436msgstr ""
5328 4437
5329#: plugins/check_ups.c:637
5330msgid "" 4438msgid ""
5331"plugin will return an OK state. If the battery is on it will return a WARNING" 4439"plugin will return an OK state. If the battery is on it will return a WARNING"
5332msgstr "" 4440msgstr ""
5333 4441
5334#: plugins/check_ups.c:638
5335msgid "" 4442msgid ""
5336"state. If the UPS is off or has a low battery the plugin will return a " 4443"state. If the UPS is off or has a low battery the plugin will return a "
5337"CRITICAL" 4444"CRITICAL"
5338msgstr "" 4445msgstr ""
5339 4446
5340#: plugins/check_ups.c:643
5341msgid "" 4447msgid ""
5342"You may also specify a variable to check (such as temperature, utility " 4448"You may also specify a variable to check (such as temperature, utility "
5343"voltage," 4449"voltage,"
5344msgstr "" 4450msgstr ""
5345 4451
5346#: plugins/check_ups.c:644
5347msgid "" 4452msgid ""
5348"battery load, etc.) as well as warning and critical thresholds for the value" 4453"battery load, etc.) as well as warning and critical thresholds for the value"
5349msgstr "" 4454msgstr ""
5350 4455
5351#: plugins/check_ups.c:645
5352msgid "" 4456msgid ""
5353"of that variable. If the remote host has multiple UPS that are being " 4457"of that variable. If the remote host has multiple UPS that are being "
5354"monitored" 4458"monitored"
5355msgstr "" 4459msgstr ""
5356 4460
5357#: plugins/check_ups.c:646
5358msgid "you will have to use the --ups option to specify which UPS to check." 4461msgid "you will have to use the --ups option to specify which UPS to check."
5359msgstr "" 4462msgstr ""
5360 4463
5361#: plugins/check_ups.c:648
5362msgid "" 4464msgid ""
5363"This plugin requires that the UPSD daemon distributed with Russell Kroll's" 4465"This plugin requires that the UPSD daemon distributed with Russell Kroll's"
5364msgstr "" 4466msgstr ""
5365 4467
5366#: plugins/check_ups.c:649
5367msgid "" 4468msgid ""
5368"Network UPS Tools be installed on the remote host. If you do not have the" 4469"Network UPS Tools be installed on the remote host. If you do not have the"
5369msgstr "" 4470msgstr ""
5370 4471
5371#: plugins/check_ups.c:650
5372msgid "package installed on your system, you can download it from" 4472msgid "package installed on your system, you can download it from"
5373msgstr "" 4473msgstr ""
5374 4474
5375#: plugins/check_ups.c:651
5376msgid "http://www.networkupstools.org" 4475msgid "http://www.networkupstools.org"
5377msgstr "" 4476msgstr ""
5378 4477
5379#: plugins/check_users.c:110 4478#, fuzzy, c-format
4479msgid "Could not enumerate RD sessions: %d\n"
4480msgstr "Impossible d'utiliser le protocole version %d\n"
4481
5380#, c-format 4482#, c-format
5381msgid "# users=%d" 4483msgid "# users=%d"
5382msgstr "# utilisateurs=%d" 4484msgstr "# utilisateurs=%d"
5383 4485
5384#: plugins/check_users.c:133
5385msgid "Unable to read output" 4486msgid "Unable to read output"
5386msgstr "Impossible de lire les données en entrée" 4487msgstr "Impossible de lire les données en entrée"
5387 4488
5388#: plugins/check_users.c:140
5389#, c-format 4489#, c-format
5390msgid "USERS %s - %d users currently logged in |%s\n" 4490msgid "USERS %s - %d users currently logged in |%s\n"
5391msgstr "UTILISATEURS %s - %d utilisateurs actuellement connectés sur |%s\n" 4491msgstr "UTILISATEURS %s - %d utilisateurs actuellement connectés sur |%s\n"
5392 4492
5393#: plugins/check_users.c:219
5394msgid "This plugin checks the number of users currently logged in on the local" 4493msgid "This plugin checks the number of users currently logged in on the local"
5395msgstr "" 4494msgstr ""
5396"Ce plugin vérifie le nombre d'utilisateurs actuellement connecté sur le " 4495"Ce plugin vérifie le nombre d'utilisateurs actuellement connecté sur le "
5397"système local" 4496"système local"
5398 4497
5399#: plugins/check_users.c:220
5400msgid "" 4498msgid ""
5401"system and generates an error if the number exceeds the thresholds specified." 4499"system and generates an error if the number exceeds the thresholds specified."
5402msgstr "et génère une erreur si le nombre excède le seuil spécifié." 4500msgstr "et génère une erreur si le nombre excède le seuil spécifié."
5403 4501
5404#: plugins/check_users.c:230
5405msgid "Set WARNING status if more than INTEGER users are logged in" 4502msgid "Set WARNING status if more than INTEGER users are logged in"
5406msgstr "" 4503msgstr ""
5407"Sortir avec un résultat AVERTISSEMENT si plus de INTEGER utilisateurs sont " 4504"Sortir avec un résultat AVERTISSEMENT si plus de INTEGER utilisateurs sont "
5408"connectés" 4505"connectés"
5409 4506
5410#: plugins/check_users.c:232
5411msgid "Set CRITICAL status if more than INTEGER users are logged in" 4507msgid "Set CRITICAL status if more than INTEGER users are logged in"
5412msgstr "" 4508msgstr ""
5413"Sortir avec un résultat CRITIQUE si plus de INTEGER utilisateurs sont " 4509"Sortir avec un résultat CRITIQUE si plus de INTEGER utilisateurs sont "
5414"connectés" 4510"connectés"
5415 4511
5416#: plugins/check_ide_smart.c:256 4512msgid ""
4513"DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."
4514msgstr ""
4515
4516msgid "Nagios-compatible output is now always returned."
4517msgstr ""
4518
4519msgid "SMART commands are broken and have been disabled (See Notes in --help)."
4520msgstr ""
4521
4522msgid ""
4523"DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"
4524msgstr ""
4525
4526#, fuzzy
4527msgid "default and will be removed from future releases."
4528msgstr ""
4529"Note: nslookup est obsolète et pourra être retiré dans les prochaines "
4530"versions."
4531
5417#, c-format 4532#, c-format
5418msgid "CRITICAL - Couldn't open device %s: %s\n" 4533msgid "CRITICAL - Couldn't open device %s: %s\n"
5419msgstr "Critique - Impossible d'ouvrir le périphérique %s: %s\n" 4534msgstr "Critique - Impossible d'ouvrir le périphérique %s: %s\n"
5420 4535
5421#: plugins/check_ide_smart.c:261
5422#, c-format 4536#, c-format
5423msgid "CRITICAL - SMART_CMD_ENABLE\n" 4537msgid "CRITICAL - SMART_CMD_ENABLE\n"
5424msgstr "CRITIQUE - SMART_CMD_ENABLE\n" 4538msgstr "CRITIQUE - SMART_CMD_ENABLE\n"
5425 4539
5426#: plugins/check_ide_smart.c:323 plugins/check_ide_smart.c:350
5427#, c-format 4540#, c-format
5428msgid "CRITICAL - SMART_READ_VALUES: %s\n" 4541msgid "CRITICAL - SMART_READ_VALUES: %s\n"
5429msgstr "CRITIQUE - SMART_READ_VALUES: %s\n" 4542msgstr "CRITIQUE - SMART_READ_VALUES: %s\n"
5430 4543
5431#: plugins/check_ide_smart.c:421
5432#, c-format 4544#, c-format
5433msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n" 4545msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"
5434msgstr "" 4546msgstr ""
5435"CRITIQUE - %d État de pré-panne %c Détecté! %d/%d les tests on échoués.\n" 4547"CRITIQUE - %d État de pré-panne %c Détecté! %d/%d les tests on échoués.\n"
5436 4548
5437#: plugins/check_ide_smart.c:429
5438#, c-format 4549#, c-format
5439msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n" 4550msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"
5440msgstr "" 4551msgstr ""
5441"AVERTISSEMENT - %d État de pré-panne %s Détecté! %d/%d les tests on " 4552"AVERTISSEMENT - %d État de pré-panne %s Détecté! %d/%d les tests on "
5442"échoués.\n" 4553"échoués.\n"
5443 4554
5444#: plugins/check_ide_smart.c:437
5445#, c-format 4555#, c-format
5446msgid "OK - Operational (%d/%d tests passed)\n" 4556msgid "OK - Operational (%d/%d tests passed)\n"
5447msgstr "OK - En fonctionnement (%d/%d les tests on été réussi)\n" 4557msgstr "OK - En fonctionnement (%d/%d les tests on été réussi)\n"
5448 4558
5449#: plugins/check_ide_smart.c:441
5450#, c-format 4559#, c-format
5451msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n" 4560msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n"
5452msgstr "ERREUR - État '%d' inconnu. %d/%d les tests on réussi\n" 4561msgstr "ERREUR - État '%d' inconnu. %d/%d les tests on réussi\n"
5453 4562
5454#: plugins/check_ide_smart.c:474
5455#, c-format 4563#, c-format
5456msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n" 4564msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"
5457msgstr "" 4565msgstr ""
5458"Etat Hors Ligne=%d {%s}, Hors Ligne Auto=%s, Temps avant arrêt=%d minutes\n" 4566"Etat Hors Ligne=%d {%s}, Hors Ligne Auto=%s, Temps avant arrêt=%d minutes\n"
5459 4567
5460#: plugins/check_ide_smart.c:480
5461#, c-format 4568#, c-format
5462msgid "OffLineCapability=%d {%s %s %s}\n" 4569msgid "OffLineCapability=%d {%s %s %s}\n"
5463msgstr "Capacité Hors Ligne=%d {%s %s %s}\n" 4570msgstr "Capacité Hors Ligne=%d {%s %s %s}\n"
5464 4571
5465#: plugins/check_ide_smart.c:486
5466#, c-format 4572#, c-format
5467msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n" 4573msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"
5468msgstr "Révision Smart=%d, Somme de contrôle=%d, Capacité Smart=%d {%s %s}\n" 4574msgstr "Révision Smart=%d, Somme de contrôle=%d, Capacité Smart=%d {%s %s}\n"
5469 4575
5470#: plugins/check_ide_smart.c:508 plugins/check_ide_smart.c:532
5471#, c-format 4576#, c-format
5472msgid "CRITICAL - %s: %s\n" 4577msgid "CRITICAL - %s: %s\n"
5473msgstr "CRITIQUE - %s: %s\n" 4578msgstr "CRITIQUE - %s: %s\n"
5474 4579
5475#: plugins/check_ide_smart.c:553 plugins/check_ide_smart.c:580 4580#, fuzzy, c-format
4581msgid "OK - Command sent (%s)\n"
4582msgstr "Commande: %s\n"
4583
5476#, c-format 4584#, c-format
5477msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n" 4585msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n"
5478msgstr "CRITIQUE - SMART_READ_THRESHOLDS: %s\n" 4586msgstr "CRITIQUE - SMART_READ_THRESHOLDS: %s\n"
5479 4587
5480#: plugins/check_ide_smart.c:599
5481#, c-format 4588#, c-format
5482msgid "" 4589msgid ""
5483"This plugin checks a local hard drive with the (Linux specific) SMART " 4590"This plugin checks a local hard drive with the (Linux specific) SMART "
@@ -5486,41 +4593,39 @@ msgstr ""
5486"Ce plugin vérifie un disque dur local à l'aide de l'interface SMART (pour " 4593"Ce plugin vérifie un disque dur local à l'aide de l'interface SMART (pour "
5487"Linux) [http://smartlinux.sourceforge.net/smart/index.php]." 4594"Linux) [http://smartlinux.sourceforge.net/smart/index.php]."
5488 4595
5489#: plugins/check_ide_smart.c:609
5490msgid "Select device DEVICE" 4596msgid "Select device DEVICE"
5491msgstr "" 4597msgstr ""
5492 4598
5493#: plugins/check_ide_smart.c:610
5494msgid "" 4599msgid ""
5495"Note: if the device is selected with this option, _no_ other options are " 4600"Note: if the device is specified without this option, any further option will"
5496"accepted" 4601msgstr ""
4602
4603msgid "be ignored."
4604msgstr ""
4605
4606msgid ""
4607"The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"
5497msgstr "" 4608msgstr ""
5498 4609
5499#: plugins/check_ide_smart.c:612 4610msgid ""
5500msgid "Perform immediately offline tests" 4611"broken in an underhand manner and have been disabled. You can use smartctl"
5501msgstr "" 4612msgstr ""
5502 4613
5503#: plugins/check_ide_smart.c:614 4614msgid "instead:"
5504msgid "Returns the number of failed tests"
5505msgstr "" 4615msgstr ""
5506 4616
5507#: plugins/check_ide_smart.c:616 4617msgid "-0/--auto-off: use \"smartctl --offlineauto=off\""
5508msgid "Turn on automatic offline tests"
5509msgstr "" 4618msgstr ""
5510 4619
5511#: plugins/check_ide_smart.c:618 4620msgid "-1/--auto-on: use \"smartctl --offlineauto=on\""
5512msgid "Turn off automatic offline tests"
5513msgstr "" 4621msgstr ""
5514 4622
5515#: plugins/check_ide_smart.c:620 4623msgid "-i/--immediate: use \"smartctl --test=offline\""
5516msgid "Output suitable for the monitoring system"
5517msgstr "" 4624msgstr ""
5518 4625
5519#: plugins/negate.c:99
5520msgid "No data returned from command\n" 4626msgid "No data returned from command\n"
5521msgstr "Pas de données reçues de la commande\n" 4627msgstr "Pas de données reçues de la commande\n"
5522 4628
5523#: plugins/negate.c:170
5524msgid "" 4629msgid ""
5525"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) " 4630"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
5526"or integer (0-3)." 4631"or integer (0-3)."
@@ -5528,7 +4633,6 @@ msgstr ""
5528"Le résultat de temps dépassé doit être un nom d'état valide (OK, WARNING, " 4633"Le résultat de temps dépassé doit être un nom d'état valide (OK, WARNING, "
5529"CRITICAL, UNKNOWN) ou un nombre entier (0-3)." 4634"CRITICAL, UNKNOWN) ou un nombre entier (0-3)."
5530 4635
5531#: plugins/negate.c:174
5532msgid "" 4636msgid ""
5533"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer " 4637"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer "
5534"(0-3)." 4638"(0-3)."
@@ -5536,7 +4640,6 @@ msgstr ""
5536"Ok doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou un " 4640"Ok doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou un "
5537"nombre entier (0-3)." 4641"nombre entier (0-3)."
5538 4642
5539#: plugins/negate.c:180
5540msgid "" 4643msgid ""
5541"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4644"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5542"integer (0-3)." 4645"integer (0-3)."
@@ -5544,7 +4647,6 @@ msgstr ""
5544"Warning doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou " 4647"Warning doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou "
5545"un nombre entier (0-3)." 4648"un nombre entier (0-3)."
5546 4649
5547#: plugins/negate.c:185
5548msgid "" 4650msgid ""
5549"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4651"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5550"integer (0-3)." 4652"integer (0-3)."
@@ -5552,7 +4654,6 @@ msgstr ""
5552"Critical doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou " 4654"Critical doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou "
5553"un nombre entier (0-3)." 4655"un nombre entier (0-3)."
5554 4656
5555#: plugins/negate.c:190
5556msgid "" 4657msgid ""
5557"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4658"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5558"integer (0-3)." 4659"integer (0-3)."
@@ -5560,33 +4661,27 @@ msgstr ""
5560"Unknown doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou " 4661"Unknown doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou "
5561"un nombre entier (0-3)." 4662"un nombre entier (0-3)."
5562 4663
5563#: plugins/negate.c:217
5564msgid "Require path to command" 4664msgid "Require path to command"
5565msgstr "Chemin vers la commande requis" 4665msgstr "Chemin vers la commande requis"
5566 4666
5567#: plugins/negate.c:246
5568msgid "" 4667msgid ""
5569"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)." 4668"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)."
5570msgstr "" 4669msgstr ""
5571"Inverse le statut d'un plugin (retourne OK pour CRITIQUE et vice-versa)." 4670"Inverse le statut d'un plugin (retourne OK pour CRITIQUE et vice-versa)."
5572 4671
5573#: plugins/negate.c:247
5574msgid "Additional switches can be used to control which state becomes what." 4672msgid "Additional switches can be used to control which state becomes what."
5575msgstr "" 4673msgstr ""
5576"Des options additionnelles peuvent être utilisées pour contrôler quel état " 4674"Des options additionnelles peuvent être utilisées pour contrôler quel état "
5577"devient quoi." 4675"devient quoi."
5578 4676
5579#: plugins/negate.c:256
5580msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status." 4677msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status."
5581msgstr "" 4678msgstr ""
5582"Utilisez un délai de réponse plus long que celui du plugin afin de conserver " 4679"Utilisez un délai de réponse plus long que celui du plugin afin de conserver "
5583"les résultats CRITIQUE" 4680"les résultats CRITIQUE"
5584 4681
5585#: plugins/negate.c:258
5586msgid "Custom result on Negate timeouts; see below for STATUS definition\n" 4682msgid "Custom result on Negate timeouts; see below for STATUS definition\n"
5587msgstr "" 4683msgstr ""
5588 4684
5589#: plugins/negate.c:264
5590#, c-format 4685#, c-format
5591msgid "" 4686msgid ""
5592" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n" 4687" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n"
@@ -5594,129 +4689,99 @@ msgstr ""
5594" STATUS peut être 'OK', 'WARNING', 'CRITICAL' ou 'UNKNOWN' sans les " 4689" STATUS peut être 'OK', 'WARNING', 'CRITICAL' ou 'UNKNOWN' sans les "
5595"simple\n" 4690"simple\n"
5596 4691
5597#: plugins/negate.c:265
5598#, c-format 4692#, c-format
5599msgid "" 4693msgid ""
5600" quotes. Numeric values are accepted. If nothing is specified, permutes\n" 4694" quotes. Numeric values are accepted. If nothing is specified, permutes\n"
5601msgstr " quotes. Les valeurs numériques sont acceptées. Si rien n'est\n" 4695msgstr " quotes. Les valeurs numériques sont acceptées. Si rien n'est\n"
5602 4696
5603#: plugins/negate.c:266
5604#, c-format 4697#, c-format
5605msgid " OK and CRITICAL.\n" 4698msgid " OK and CRITICAL.\n"
5606msgstr " spécifié, inverse OK et CRITIQUE.\n" 4699msgstr " spécifié, inverse OK et CRITIQUE.\n"
5607 4700
5608#: plugins/negate.c:268
5609#, c-format 4701#, c-format
5610msgid "" 4702msgid ""
5611" Substitute output text as well. Will only substitute text in CAPITALS\n" 4703" Substitute output text as well. Will only substitute text in CAPITALS\n"
5612msgstr "" 4704msgstr ""
5613 4705
5614#: plugins/negate.c:273
5615msgid "Run check_ping and invert result. Must use full path to plugin" 4706msgid "Run check_ping and invert result. Must use full path to plugin"
5616msgstr "" 4707msgstr ""
5617"Execute check_ping et inverse le résultat. Le chemin complet du plug-in doit " 4708"Execute check_ping et inverse le résultat. Le chemin complet du plug-in doit "
5618"être spécifié" 4709"être spécifié"
5619 4710
5620#: plugins/negate.c:275
5621msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL" 4711msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL"
5622msgstr "" 4712msgstr ""
5623"Ceci retournera OK au lieu de AVERTISSEMENT et INCONNU au lieu de CRITIQUE" 4713"Ceci retournera OK au lieu de AVERTISSEMENT et INCONNU au lieu de CRITIQUE"
5624 4714
5625#: plugins/negate.c:278
5626msgid "" 4715msgid ""
5627"This plugin is a wrapper to take the output of another plugin and invert it." 4716"This plugin is a wrapper to take the output of another plugin and invert it."
5628msgstr "" 4717msgstr ""
5629"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et " 4718"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et "
5630"l'inverse." 4719"l'inverse."
5631 4720
5632#: plugins/negate.c:279
5633msgid "The full path of the plugin must be provided." 4721msgid "The full path of the plugin must be provided."
5634msgstr "Le chemin complet du plugin doit être spécifié." 4722msgstr "Le chemin complet du plugin doit être spécifié."
5635 4723
5636#: plugins/negate.c:280
5637msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL." 4724msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL."
5638msgstr "Si le plugin executé retourne OK, l'adaptateur retournera CRITIQUE." 4725msgstr "Si le plugin executé retourne OK, l'adaptateur retournera CRITIQUE."
5639 4726
5640#: plugins/negate.c:281
5641msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK." 4727msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK."
5642msgstr "Si le plugin executé retourne CRITIQUE, l'adaptateur retournera OK." 4728msgstr "Si le plugin executé retourne CRITIQUE, l'adaptateur retournera OK."
5643 4729
5644#: plugins/negate.c:282
5645msgid "Otherwise, the output state of the wrapped plugin is unchanged." 4730msgid "Otherwise, the output state of the wrapped plugin is unchanged."
5646msgstr "Autrement, l'état du plugin executé reste inchangé." 4731msgstr "Autrement, l'état du plugin executé reste inchangé."
5647 4732
5648#: plugins/negate.c:284
5649msgid "" 4733msgid ""
5650"Using timeout-result, it is possible to override the timeout behaviour or a" 4734"Using timeout-result, it is possible to override the timeout behaviour or a"
5651msgstr "" 4735msgstr ""
5652 4736
5653#: plugins/negate.c:285
5654msgid "plugin by setting the negate timeout a bit lower." 4737msgid "plugin by setting the negate timeout a bit lower."
5655msgstr "" 4738msgstr ""
5656 4739
5657#: plugins/netutils.c:49
5658#, c-format 4740#, c-format
5659msgid "%s - Socket timeout after %d seconds\n" 4741msgid "%s - Socket timeout after %d seconds\n"
5660msgstr "%s - Le socket n'a pas répondu dans les %d secondes\n" 4742msgstr "%s - Le socket n'a pas répondu dans les %d secondes\n"
5661 4743
5662#: plugins/netutils.c:51
5663#, c-format 4744#, c-format
5664msgid "%s - Abnormal timeout after %d seconds\n" 4745msgid "%s - Abnormal timeout after %d seconds\n"
5665msgstr "%s - Dépassement anormal du temps de réponse après %d secondes\n" 4746msgstr "%s - Dépassement anormal du temps de réponse après %d secondes\n"
5666 4747
5667#: plugins/netutils.c:79 plugins/netutils.c:281
5668msgid "Send failed" 4748msgid "Send failed"
5669msgstr "L'envoi à échoué" 4749msgstr "L'envoi à échoué"
5670 4750
5671#: plugins/netutils.c:96 plugins/netutils.c:296
5672msgid "No data was received from host!" 4751msgid "No data was received from host!"
5673msgstr "Pas de données reçues de l'hôte!" 4752msgstr "Pas de données reçues de l'hôte!"
5674 4753
5675#: plugins/netutils.c:204 plugins/netutils.c:240
5676msgid "Socket creation failed" 4754msgid "Socket creation failed"
5677msgstr "La création du socket à échoué " 4755msgstr "La création du socket à échoué "
5678 4756
5679#: plugins/netutils.c:233
5680msgid "Supplied path too long unix domain socket" 4757msgid "Supplied path too long unix domain socket"
5681msgstr "Le chemin fourni est trop long pour un socket unix" 4758msgstr "Le chemin fourni est trop long pour un socket unix"
5682 4759
5683#: plugins/netutils.c:305
5684msgid "Receive failed" 4760msgid "Receive failed"
5685msgstr "La réception à échoué" 4761msgstr "La réception à échoué"
5686 4762
5687#: plugins/netutils.c:331 plugins-root/check_dhcp.c:1342
5688#, c-format 4763#, c-format
5689msgid "Invalid hostname/address - %s" 4764msgid "Invalid hostname/address - %s"
5690msgstr "Adresse/Nom invalide - %s" 4765msgstr "Adresse/Nom invalide - %s"
5691 4766
5692#: plugins/popen.c:142
5693msgid "Could not malloc argv array in popen()" 4767msgid "Could not malloc argv array in popen()"
5694msgstr "Impossible de réallouer un tableau pour les paramètres dans popen()" 4768msgstr "Impossible de réallouer un tableau pour les paramètres dans popen()"
5695 4769
5696#: plugins/popen.c:152
5697msgid "CRITICAL - You need more args!!!" 4770msgid "CRITICAL - You need more args!!!"
5698msgstr "CRITIQUE - Vous devez spécifier plus d'arguments!!!" 4771msgstr "CRITIQUE - Vous devez spécifier plus d'arguments!!!"
5699 4772
5700#: plugins/popen.c:209
5701msgid "Cannot catch SIGCHLD" 4773msgid "Cannot catch SIGCHLD"
5702msgstr "impossible d'obtenir le signal SIGCHLD" 4774msgstr "impossible d'obtenir le signal SIGCHLD"
5703 4775
5704#: plugins/popen.c:304
5705#, c-format 4776#, c-format
5706msgid "CRITICAL - Plugin timed out after %d seconds\n" 4777msgid "CRITICAL - Plugin timed out after %d seconds\n"
5707msgstr "CRITIQUE - Le plugin n'as pas répondu dans les %d secondes\n" 4778msgstr "CRITIQUE - Le plugin n'as pas répondu dans les %d secondes\n"
5708 4779
5709#: plugins/popen.c:307
5710msgid "CRITICAL - popen timeout received, but no child process" 4780msgid "CRITICAL - popen timeout received, but no child process"
5711msgstr "" 4781msgstr ""
5712"CRITIQUE - le temps d'attente à été dépassé dans la fonction popen, mais il " 4782"CRITIQUE - le temps d'attente à été dépassé dans la fonction popen, mais il "
5713"n'y a pas de processus fils" 4783"n'y a pas de processus fils"
5714 4784
5715#: plugins/popen.c:323
5716msgid "sysconf error for _SC_OPEN_MAX"
5717msgstr ""
5718
5719#: plugins/urlize.c:130
5720#, c-format 4785#, c-format
5721msgid "" 4786msgid ""
5722"%s UNKNOWN - No data received from host\n" 4787"%s UNKNOWN - No data received from host\n"
@@ -5725,7 +4790,6 @@ msgstr ""
5725"%s INCONNU - Pas de données reçues de l'hôte\n" 4790"%s INCONNU - Pas de données reçues de l'hôte\n"
5726"Commande: %s</A>\n" 4791"Commande: %s</A>\n"
5727 4792
5728#: plugins/urlize.c:169
5729#, fuzzy 4793#, fuzzy
5730msgid "" 4794msgid ""
5731"This plugin wraps the text output of another command (plugin) in HTML <A>" 4795"This plugin wraps the text output of another command (plugin) in HTML <A>"
@@ -5733,66 +4797,48 @@ msgstr ""
5733"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et " 4797"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et "
5734"l'inverse." 4798"l'inverse."
5735 4799
5736#: plugins/urlize.c:170
5737msgid "" 4800msgid ""
5738"tags, thus displaying the child plugin's output as a clickable link in " 4801"tags, thus displaying the child plugin's output as a clickable link in "
5739"compatible" 4802"compatible"
5740msgstr "" 4803msgstr ""
5741 4804
5742#: plugins/urlize.c:171
5743msgid "" 4805msgid ""
5744"monitoring status screen. This plugin returns the status of the invoked " 4806"monitoring status screen. This plugin returns the status of the invoked "
5745"plugin." 4807"plugin."
5746msgstr "" 4808msgstr ""
5747 4809
5748#: plugins/urlize.c:181
5749msgid "" 4810msgid ""
5750"Pay close attention to quoting to ensure that the shell passes the expected" 4811"Pay close attention to quoting to ensure that the shell passes the expected"
5751msgstr "" 4812msgstr ""
5752 4813
5753#: plugins/urlize.c:182
5754msgid "data to the plugin. For example, in:" 4814msgid "data to the plugin. For example, in:"
5755msgstr "" 4815msgstr ""
5756 4816
5757#: plugins/urlize.c:183
5758msgid "urlize http://example.com/ check_http -H example.com -r 'two words'" 4817msgid "urlize http://example.com/ check_http -H example.com -r 'two words'"
5759msgstr "" 4818msgstr ""
5760 4819
5761#: plugins/urlize.c:184
5762msgid "the shell will remove the single quotes and urlize will see:" 4820msgid "the shell will remove the single quotes and urlize will see:"
5763msgstr "" 4821msgstr ""
5764 4822
5765#: plugins/urlize.c:185
5766msgid "urlize http://example.com/ check_http -H example.com -r two words" 4823msgid "urlize http://example.com/ check_http -H example.com -r two words"
5767msgstr "" 4824msgstr ""
5768 4825
5769#: plugins/urlize.c:186
5770msgid "You probably want:" 4826msgid "You probably want:"
5771msgstr "" 4827msgstr ""
5772 4828
5773#: plugins/urlize.c:187
5774msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\"" 4829msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\""
5775msgstr "" 4830msgstr ""
5776 4831
5777#: plugins/utils.c:174
5778#, c-format
5779msgid "%s - Plugin timed out after %d seconds\n"
5780msgstr "%s - Le plugin n'as pas répondu dans les %d secondes\n"
5781
5782#: plugins/utils.c:469
5783msgid "failed realloc in strpcpy\n" 4832msgid "failed realloc in strpcpy\n"
5784msgstr "La fonction realloc à échoué dans strpcpy\n" 4833msgstr "La fonction realloc à échoué dans strpcpy\n"
5785 4834
5786#: plugins/utils.c:511
5787msgid "failed malloc in strscat\n" 4835msgid "failed malloc in strscat\n"
5788msgstr "La fonction malloc à échoué dans strscat\n" 4836msgstr "La fonction malloc à échoué dans strscat\n"
5789 4837
5790#: plugins/utils.c:531
5791#, fuzzy 4838#, fuzzy
5792msgid "failed malloc in xvasprintf\n" 4839msgid "failed malloc in xvasprintf\n"
5793msgstr "La fonction malloc à échoué dans strscat\n" 4840msgstr "La fonction malloc à échoué dans strscat\n"
5794 4841
5795#: plugins/utils.h:137
5796#, c-format 4842#, c-format
5797msgid "" 4843msgid ""
5798" %s (-h | --help) for detailed help\n" 4844" %s (-h | --help) for detailed help\n"
@@ -5801,7 +4847,6 @@ msgstr ""
5801" %s (-h | --help) pour l'aide détaillée\n" 4847" %s (-h | --help) pour l'aide détaillée\n"
5802" %s (-V | --version) pour les informations relative à la version\n" 4848" %s (-V | --version) pour les informations relative à la version\n"
5803 4849
5804#: plugins/utils.h:141
5805msgid "" 4850msgid ""
5806"\n" 4851"\n"
5807"Options:\n" 4852"Options:\n"
@@ -5817,7 +4862,6 @@ msgstr ""
5817" -V, --version\n" 4862" -V, --version\n"
5818" Afficher les informations relative à la version\n" 4863" Afficher les informations relative à la version\n"
5819 4864
5820#: plugins/utils.h:148
5821#, c-format 4865#, c-format
5822msgid "" 4866msgid ""
5823" -H, --hostname=ADDRESS\n" 4867" -H, --hostname=ADDRESS\n"
@@ -5830,7 +4874,6 @@ msgstr ""
5830" -%c, --port=INTEGER\n" 4874" -%c, --port=INTEGER\n"
5831" Numéro de port (défaut: %s)\n" 4875" Numéro de port (défaut: %s)\n"
5832 4876
5833#: plugins/utils.h:154
5834msgid "" 4877msgid ""
5835" -4, --use-ipv4\n" 4878" -4, --use-ipv4\n"
5836" Use IPv4 connection\n" 4879" Use IPv4 connection\n"
@@ -5842,18 +4885,16 @@ msgstr ""
5842" -6, --use-ipv6\n" 4885" -6, --use-ipv6\n"
5843" Utiliser une connection IPv6\n" 4886" Utiliser une connection IPv6\n"
5844 4887
5845#: plugins/utils.h:160
5846#, fuzzy 4888#, fuzzy
5847msgid "" 4889msgid ""
5848" -v, --verbose\n" 4890" -v, --verbose\n"
5849" Show details for command-line debugging (output may be truncated by\n" 4891" Show details for command-line debugging (output may be truncated by\n"
5850"\t\tthe monitoring system)\n" 4892" the monitoring system)\n"
5851msgstr "" 4893msgstr ""
5852" -v, --verbose\n" 4894" -v, --verbose\n"
5853" Affiche les informations de déboguage en ligne de commande (Nagios peut " 4895" Affiche les informations de déboguage en ligne de commande (Nagios peut "
5854"tronquer la sortie)\n" 4896"tronquer la sortie)\n"
5855 4897
5856#: plugins/utils.h:165
5857msgid "" 4898msgid ""
5858" -w, --warning=DOUBLE\n" 4899" -w, --warning=DOUBLE\n"
5859" Response time to result in warning status (seconds)\n" 4900" Response time to result in warning status (seconds)\n"
@@ -5865,7 +4906,6 @@ msgstr ""
5865" -c, --critical=DOUBLE\n" 4906" -c, --critical=DOUBLE\n"
5866" Temps de réponse résultant en un état critique (secondes)\n" 4907" Temps de réponse résultant en un état critique (secondes)\n"
5867 4908
5868#: plugins/utils.h:171
5869msgid "" 4909msgid ""
5870" -w, --warning=RANGE\n" 4910" -w, --warning=RANGE\n"
5871" Warning range (format: start:end). Alert if outside this range\n" 4911" Warning range (format: start:end). Alert if outside this range\n"
@@ -5878,7 +4918,6 @@ msgstr ""
5878" -c, --critical=RANGE\n" 4918" -c, --critical=RANGE\n"
5879" Seuil critique\n" 4919" Seuil critique\n"
5880 4920
5881#: plugins/utils.h:177
5882#, c-format 4921#, c-format
5883msgid "" 4922msgid ""
5884" -t, --timeout=INTEGER\n" 4923" -t, --timeout=INTEGER\n"
@@ -5887,7 +4926,14 @@ msgstr ""
5887" -t, --timeout=INTEGER\n" 4926" -t, --timeout=INTEGER\n"
5888" Délais de connection en secondes (défaut: %d)\n" 4927" Délais de connection en secondes (défaut: %d)\n"
5889 4928
5890#: plugins/utils.h:182 4929#, fuzzy, c-format
4930msgid ""
4931" -t, --timeout=INTEGER\n"
4932" Seconds before plugin times out (default: %d)\n"
4933msgstr ""
4934" -t, --timeout=INTEGER\n"
4935" Délais de connection en secondes (défaut: %d)\n"
4936
5891#, fuzzy 4937#, fuzzy
5892msgid "" 4938msgid ""
5893" --extra-opts=[section][@file]\n" 4939" --extra-opts=[section][@file]\n"
@@ -5900,7 +4946,6 @@ msgstr ""
5900" https://www.monitoring-plugins.org/doc/extra-opts.html\n" 4946" https://www.monitoring-plugins.org/doc/extra-opts.html\n"
5901" pour les instructions et examples.\n" 4947" pour les instructions et examples.\n"
5902 4948
5903#: plugins/utils.h:190
5904#, fuzzy 4949#, fuzzy
5905msgid "" 4950msgid ""
5906" See:\n" 4951" See:\n"
@@ -5912,7 +4957,6 @@ msgstr ""
5912"html#THRESHOLDFORMAT\n" 4957"html#THRESHOLDFORMAT\n"
5913" pour le format et examples des seuils (THRESHOLD).\n" 4958" pour le format et examples des seuils (THRESHOLD).\n"
5914 4959
5915#: plugins/utils.h:195
5916#, fuzzy 4960#, fuzzy
5917msgid "" 4961msgid ""
5918"\n" 4962"\n"
@@ -5922,14 +4966,12 @@ msgid ""
5922"\n" 4966"\n"
5923msgstr "" 4967msgstr ""
5924"\n" 4968"\n"
5925"Envoyez un email à help@monitoring-plugins.org si vous avez des " 4969"Envoyez un email à help@monitoring-plugins.org si vous avez des questions\n"
5926"questions\n"
5927"reliées à l'utilisation de ce logiciel. Pour envoyer des patches ou suggérer " 4970"reliées à l'utilisation de ce logiciel. Pour envoyer des patches ou suggérer "
5928"des\n" 4971"des\n"
5929"améliorations, envoyez un email à devel@monitoring-plugins.org\n" 4972"améliorations, envoyez un email à devel@monitoring-plugins.org\n"
5930"\n" 4973"\n"
5931 4974
5932#: plugins/utils.h:200
5933#, fuzzy 4975#, fuzzy
5934msgid "" 4976msgid ""
5935"\n" 4977"\n"
@@ -5943,25 +4985,21 @@ msgstr ""
5943"des copies des plugins selon les termes de la GNU General Public License.\n" 4985"des copies des plugins selon les termes de la GNU General Public License.\n"
5944"Pour de plus ample informations, voir le fichier COPYING.\n" 4986"Pour de plus ample informations, voir le fichier COPYING.\n"
5945 4987
5946#: plugins-root/check_dhcp.c:320
5947#, c-format 4988#, c-format
5948msgid "Error: Could not get hardware address of interface '%s'\n" 4989msgid "Error: Could not get hardware address of interface '%s'\n"
5949msgstr "" 4990msgstr ""
5950"Erreur: Impossible d'obtenir l'adresse matérielle pour l'interface '%s'\n" 4991"Erreur: Impossible d'obtenir l'adresse matérielle pour l'interface '%s'\n"
5951 4992
5952#: plugins-root/check_dhcp.c:342
5953#, c-format 4993#, c-format
5954msgid "Error: if_nametoindex error - %s.\n" 4994msgid "Error: if_nametoindex error - %s.\n"
5955msgstr "Erreur: if_nametoindex erreur - %s.\n" 4995msgstr "Erreur: if_nametoindex erreur - %s.\n"
5956 4996
5957#: plugins-root/check_dhcp.c:347
5958#, c-format 4997#, c-format
5959msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n" 4998msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"
5960msgstr "" 4999msgstr ""
5961"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s. erreur sysctl 1 " 5000"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s. erreur sysctl 1 "
5962"- %s.\n" 5001"- %s.\n"
5963 5002
5964#: plugins-root/check_dhcp.c:352
5965#, c-format 5003#, c-format
5966msgid "" 5004msgid ""
5967"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n" 5005"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"
@@ -5969,14 +5007,12 @@ msgstr ""
5969"Erreur: Impossible d'obtenir l'adresse matérielle depuis l'interface %s\n" 5007"Erreur: Impossible d'obtenir l'adresse matérielle depuis l'interface %s\n"
5970" erreur malloc - %s.\n" 5008" erreur malloc - %s.\n"
5971 5009
5972#: plugins-root/check_dhcp.c:357
5973#, c-format 5010#, c-format
5974msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n" 5011msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"
5975msgstr "" 5012msgstr ""
5976"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s erreur sysctl 2 " 5013"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s erreur sysctl 2 "
5977"- %s.\n" 5014"- %s.\n"
5978 5015
5979#: plugins-root/check_dhcp.c:388
5980#, c-format 5016#, c-format
5981msgid "" 5017msgid ""
5982"Error: can't find unit number in interface_name (%s) - expecting TypeNumber " 5018"Error: can't find unit number in interface_name (%s) - expecting TypeNumber "
@@ -5985,7 +5021,6 @@ msgstr ""
5985"Erreur: impossible de trouver le numéro dans le nom de l'interface (%s).\n" 5021"Erreur: impossible de trouver le numéro dans le nom de l'interface (%s).\n"
5986"J'attendais le nom suivi du type ex lnc0.\n" 5022"J'attendais le nom suivi du type ex lnc0.\n"
5987 5023
5988#: plugins-root/check_dhcp.c:393 plugins-root/check_dhcp.c:405
5989#, c-format 5024#, c-format
5990msgid "" 5025msgid ""
5991"Error: can't read MAC address from DLPI streams interface for device %s unit " 5026"Error: can't read MAC address from DLPI streams interface for device %s unit "
@@ -5994,7 +5029,6 @@ msgstr ""
5994"Erreur: impossible de lire l'adresse MAC depuis l'interface DLPI pour le \n" 5029"Erreur: impossible de lire l'adresse MAC depuis l'interface DLPI pour le \n"
5995"périphérique %s numéro %d.\n" 5030"périphérique %s numéro %d.\n"
5996 5031
5997#: plugins-root/check_dhcp.c:411
5998#, c-format 5032#, c-format
5999msgid "" 5033msgid ""
6000"Error: can't get MAC address for this architecture. Use the --mac option.\n" 5034"Error: can't get MAC address for this architecture. Use the --mac option.\n"
@@ -6002,47 +5036,38 @@ msgstr ""
6002"Erreur: impossible d'obtenir l'adresse MAC sur cette architecture. Utilisez " 5036"Erreur: impossible d'obtenir l'adresse MAC sur cette architecture. Utilisez "
6003"l'option --mac.\n" 5037"l'option --mac.\n"
6004 5038
6005#: plugins-root/check_dhcp.c:430
6006#, c-format 5039#, c-format
6007msgid "Error: Cannot determine IP address of interface %s\n" 5040msgid "Error: Cannot determine IP address of interface %s\n"
6008msgstr "Erreur: Impossible d'obtenir l'adresse IP de l'interface %s\n" 5041msgstr "Erreur: Impossible d'obtenir l'adresse IP de l'interface %s\n"
6009 5042
6010#: plugins-root/check_dhcp.c:438
6011#, c-format 5043#, c-format
6012msgid "Error: Cannot get interface IP address on this platform.\n" 5044msgid "Error: Cannot get interface IP address on this platform.\n"
6013msgstr "Erreur: Impossible d'obtenir l'adresse IP sur cette architecture.\n" 5045msgstr "Erreur: Impossible d'obtenir l'adresse IP sur cette architecture.\n"
6014 5046
6015#: plugins-root/check_dhcp.c:443
6016#, c-format 5047#, c-format
6017msgid "Pretending to be relay client %s\n" 5048msgid "Pretending to be relay client %s\n"
6018msgstr "" 5049msgstr ""
6019 5050
6020#: plugins-root/check_dhcp.c:528
6021#, c-format 5051#, c-format
6022msgid "DHCPDISCOVER to %s port %d\n" 5052msgid "DHCPDISCOVER to %s port %d\n"
6023msgstr "DHCPDISCOVER vers %s port %d\n" 5053msgstr "DHCPDISCOVER vers %s port %d\n"
6024 5054
6025#: plugins-root/check_dhcp.c:580
6026#, c-format 5055#, c-format
6027msgid "Result=ERROR\n" 5056msgid "Result=ERROR\n"
6028msgstr "Résultat=ERREUR\n" 5057msgstr "Résultat=ERREUR\n"
6029 5058
6030#: plugins-root/check_dhcp.c:586
6031#, c-format 5059#, c-format
6032msgid "Result=OK\n" 5060msgid "Result=OK\n"
6033msgstr "Résultat=OK\n" 5061msgstr "Résultat=OK\n"
6034 5062
6035#: plugins-root/check_dhcp.c:596
6036#, c-format 5063#, c-format
6037msgid "DHCPOFFER from IP address %s" 5064msgid "DHCPOFFER from IP address %s"
6038msgstr "DHCPOFFER depuis l'adresse IP %s" 5065msgstr "DHCPOFFER depuis l'adresse IP %s"
6039 5066
6040#: plugins-root/check_dhcp.c:597
6041#, c-format 5067#, c-format
6042msgid " via %s\n" 5068msgid " via %s\n"
6043msgstr " depuis %s\n" 5069msgstr " depuis %s\n"
6044 5070
6045#: plugins-root/check_dhcp.c:604
6046#, c-format 5071#, c-format
6047msgid "" 5072msgid ""
6048"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n" 5073"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"
@@ -6050,67 +5075,55 @@ msgstr ""
6050"DHCPOFFER XID (%u) ne correspond pas au DHCPDISCOVER XID (%u) - paquet " 5075"DHCPOFFER XID (%u) ne correspond pas au DHCPDISCOVER XID (%u) - paquet "
6051"ignoré\n" 5076"ignoré\n"
6052 5077
6053#: plugins-root/check_dhcp.c:626
6054#, c-format 5078#, c-format
6055msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n" 5079msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n"
6056msgstr "" 5080msgstr ""
6057"l'adresse matérielle du DHCPOFFER ne correspond pas à la notre paquet " 5081"l'adresse matérielle du DHCPOFFER ne correspond pas à la notre paquet "
6058"ignoré\n" 5082"ignoré\n"
6059 5083
6060#: plugins-root/check_dhcp.c:644
6061#, c-format 5084#, c-format
6062msgid "Total responses seen on the wire: %d\n" 5085msgid "Total responses seen on the wire: %d\n"
6063msgstr "Nombre total de réponses vues: %d\n" 5086msgstr "Nombre total de réponses vues: %d\n"
6064 5087
6065#: plugins-root/check_dhcp.c:645
6066#, c-format 5088#, c-format
6067msgid "Valid responses for this machine: %d\n" 5089msgid "Valid responses for this machine: %d\n"
6068msgstr "Nombre de réponse valides pour cette machine: %d\n" 5090msgstr "Nombre de réponse valides pour cette machine: %d\n"
6069 5091
6070#: plugins-root/check_dhcp.c:660
6071#, c-format 5092#, c-format
6072msgid "send_dhcp_packet result: %d\n" 5093msgid "send_dhcp_packet result: %d\n"
6073msgstr "résultat de send_dchp_packet: %d\n" 5094msgstr "résultat de send_dchp_packet: %d\n"
6074 5095
6075#: plugins-root/check_dhcp.c:693
6076#, c-format 5096#, c-format
6077msgid "No (more) data received (nfound: %d)\n" 5097msgid "No (more) data received (nfound: %d)\n"
6078msgstr "Plus de données reçues (nfound: %d)\n" 5098msgstr "Plus de données reçues (nfound: %d)\n"
6079 5099
6080#: plugins-root/check_dhcp.c:712
6081#, c-format 5100#, c-format
6082msgid "recvfrom() failed, " 5101msgid "recvfrom() failed, "
6083msgstr "recvfrom() a échoué, " 5102msgstr "recvfrom() a échoué, "
6084 5103
6085#: plugins-root/check_dhcp.c:719
6086#, c-format 5104#, c-format
6087msgid "receive_dhcp_packet() result: %d\n" 5105msgid "receive_dhcp_packet() result: %d\n"
6088msgstr "résultat de receive_dchp_packet(): %d\n" 5106msgstr "résultat de receive_dchp_packet(): %d\n"
6089 5107
6090#: plugins-root/check_dhcp.c:720
6091#, c-format 5108#, c-format
6092msgid "receive_dhcp_packet() source: %s\n" 5109msgid "receive_dhcp_packet() source: %s\n"
6093msgstr "source de receive_dchp_packet(): %s\n" 5110msgstr "source de receive_dchp_packet(): %s\n"
6094 5111
6095#: plugins-root/check_dhcp.c:750
6096#, c-format 5112#, c-format
6097msgid "Error: Could not create socket!\n" 5113msgid "Error: Could not create socket!\n"
6098msgstr "Erreur: Impossible de créer un socket!\n" 5114msgstr "Erreur: Impossible de créer un socket!\n"
6099 5115
6100#: plugins-root/check_dhcp.c:760
6101#, c-format 5116#, c-format
6102msgid "Error: Could not set reuse address option on DHCP socket!\n" 5117msgid "Error: Could not set reuse address option on DHCP socket!\n"
6103msgstr "" 5118msgstr ""
6104"Erreur: Impossible de configurer l'option de réutilisation de l'adresse sur\n" 5119"Erreur: Impossible de configurer l'option de réutilisation de l'adresse sur\n"
6105"le socket DHCP!\n" 5120"le socket DHCP!\n"
6106 5121
6107#: plugins-root/check_dhcp.c:766
6108#, c-format 5122#, c-format
6109msgid "Error: Could not set broadcast option on DHCP socket!\n" 5123msgid "Error: Could not set broadcast option on DHCP socket!\n"
6110msgstr "" 5124msgstr ""
6111"Erreur: Impossible de configurer l'option broadcast sur le socket DHCP!\n" 5125"Erreur: Impossible de configurer l'option broadcast sur le socket DHCP!\n"
6112 5126
6113#: plugins-root/check_dhcp.c:775
6114#, c-format 5127#, c-format
6115msgid "" 5128msgid ""
6116"Error: Could not bind socket to interface %s. Check your privileges...\n" 5129"Error: Could not bind socket to interface %s. Check your privileges...\n"
@@ -6118,7 +5131,6 @@ msgstr ""
6118"Erreur: Impossible de connecter le socket à l'interface %s.\n" 5131"Erreur: Impossible de connecter le socket à l'interface %s.\n"
6119"Vérifiez vos droits...\n" 5132"Vérifiez vos droits...\n"
6120 5133
6121#: plugins-root/check_dhcp.c:786
6122#, c-format 5134#, c-format
6123msgid "" 5135msgid ""
6124"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n" 5136"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"
@@ -6126,256 +5138,235 @@ msgstr ""
6126"Erreur: Impossible de se connecter au socket (port %d)! Vérifiez vos " 5138"Erreur: Impossible de se connecter au socket (port %d)! Vérifiez vos "
6127"droits..\n" 5139"droits..\n"
6128 5140
6129#: plugins-root/check_dhcp.c:820
6130#, c-format 5141#, c-format
6131msgid "Requested server address: %s\n" 5142msgid "Requested server address: %s\n"
6132msgstr "Adresse serveur demandée: %s\n" 5143msgstr "Adresse serveur demandée: %s\n"
6133 5144
6134#: plugins-root/check_dhcp.c:882
6135#, c-format 5145#, c-format
6136msgid "Lease Time: Infinite\n" 5146msgid "Lease Time: Infinite\n"
6137msgstr "Durée du Bail: Infini\n" 5147msgstr "Durée du Bail: Infini\n"
6138 5148
6139#: plugins-root/check_dhcp.c:884
6140#, c-format 5149#, c-format
6141msgid "Lease Time: %lu seconds\n" 5150msgid "Lease Time: %lu seconds\n"
6142msgstr "Durée du Bail: %lu secondes\n" 5151msgstr "Durée du Bail: %lu secondes\n"
6143 5152
6144#: plugins-root/check_dhcp.c:886
6145#, c-format 5153#, c-format
6146msgid "Renewal Time: Infinite\n" 5154msgid "Renewal Time: Infinite\n"
6147msgstr "Renouvellement du bail: Infini\n" 5155msgstr "Renouvellement du bail: Infini\n"
6148 5156
6149#: plugins-root/check_dhcp.c:888
6150#, c-format 5157#, c-format
6151msgid "Renewal Time: %lu seconds\n" 5158msgid "Renewal Time: %lu seconds\n"
6152msgstr "Durée du renouvellement = %lu secondes\n" 5159msgstr "Durée du renouvellement = %lu secondes\n"
6153 5160
6154#: plugins-root/check_dhcp.c:890
6155#, c-format 5161#, c-format
6156msgid "Rebinding Time: Infinite\n" 5162msgid "Rebinding Time: Infinite\n"
6157msgstr "Délai de nouvelle demande: Infini\n" 5163msgstr "Délai de nouvelle demande: Infini\n"
6158 5164
6159#: plugins-root/check_dhcp.c:891
6160#, c-format 5165#, c-format
6161msgid "Rebinding Time: %lu seconds\n" 5166msgid "Rebinding Time: %lu seconds\n"
6162msgstr "Délai de nouvelle demande: %lu secondes\n" 5167msgstr "Délai de nouvelle demande: %lu secondes\n"
6163 5168
6164#: plugins-root/check_dhcp.c:919
6165#, c-format 5169#, c-format
6166msgid "Added offer from server @ %s" 5170msgid "Added offer from server @ %s"
6167msgstr "Rajouté offre du serveur @ %s" 5171msgstr "Rajouté offre du serveur @ %s"
6168 5172
6169#: plugins-root/check_dhcp.c:920
6170#, c-format 5173#, c-format
6171msgid " of IP address %s\n" 5174msgid " of IP address %s\n"
6172msgstr "de l'adresse IP %s\n" 5175msgstr "de l'adresse IP %s\n"
6173 5176
6174#: plugins-root/check_dhcp.c:987
6175#, c-format 5177#, c-format
6176msgid "DHCP Server Match: Offerer=%s" 5178msgid "DHCP Server Match: Offerer=%s"
6177msgstr "Correspondance du serveur DHCP: Offrant=%s" 5179msgstr "Correspondance du serveur DHCP: Offrant=%s"
6178 5180
6179#: plugins-root/check_dhcp.c:988
6180#, c-format 5181#, c-format
6181msgid " Requested=%s" 5182msgid " Requested=%s"
6182msgstr " Demandé=%s" 5183msgstr " Demandé=%s"
6183 5184
6184#: plugins-root/check_dhcp.c:990
6185#, c-format 5185#, c-format
6186msgid " (duplicate)" 5186msgid " (duplicate)"
6187msgstr "" 5187msgstr ""
6188 5188
6189#: plugins-root/check_dhcp.c:991
6190#, c-format 5189#, c-format
6191msgid "\n" 5190msgid "\n"
6192msgstr "" 5191msgstr ""
6193 5192
6194#: plugins-root/check_dhcp.c:1039
6195#, c-format 5193#, c-format
6196msgid "No DHCPOFFERs were received.\n" 5194msgid "No DHCPOFFERs were received.\n"
6197msgstr "Pas de DHCPOFFERs reçus.\n" 5195msgstr "Pas de DHCPOFFERs reçus.\n"
6198 5196
6199#: plugins-root/check_dhcp.c:1043
6200#, c-format 5197#, c-format
6201msgid "Received %d DHCPOFFER(s)" 5198msgid "Received %d DHCPOFFER(s)"
6202msgstr "Reçu %d DHCPOFFER(s)" 5199msgstr "Reçu %d DHCPOFFER(s)"
6203 5200
6204#: plugins-root/check_dhcp.c:1046
6205#, c-format 5201#, c-format
6206msgid ", %s%d of %d requested servers responded" 5202msgid ", %s%d of %d requested servers responded"
6207msgstr ", %s%d de %d serveurs ont répondus" 5203msgstr ", %s%d de %d serveurs ont répondus"
6208 5204
6209#: plugins-root/check_dhcp.c:1049
6210#, c-format 5205#, c-format
6211msgid ", requested address (%s) was %soffered" 5206msgid ", requested address (%s) was %soffered"
6212msgstr ", l'adresse demandée (%s) %s été offerte" 5207msgstr ", l'adresse demandée (%s) %s été offerte"
6213 5208
6214#: plugins-root/check_dhcp.c:1049
6215msgid "not " 5209msgid "not "
6216msgstr "n'as pas" 5210msgstr "n'as pas"
6217 5211
6218#: plugins-root/check_dhcp.c:1051
6219#, c-format 5212#, c-format
6220msgid ", max lease time = " 5213msgid ", max lease time = "
6221msgstr ", bail maximum = " 5214msgstr ", bail maximum = "
6222 5215
6223#: plugins-root/check_dhcp.c:1053
6224#, c-format 5216#, c-format
6225msgid "Infinity" 5217msgid "Infinity"
6226msgstr "Infini" 5218msgstr "Infini"
6227 5219
6228#: plugins-root/check_dhcp.c:1234 5220msgid "Got unexpected non-option argument"
5221msgstr ""
5222
6229#, c-format 5223#, c-format
6230msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n" 5224msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"
6231msgstr "" 5225msgstr ""
6232"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans check_ctrl: %s.\n" 5226"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans check_ctrl: %s.\n"
6233 5227
6234#: plugins-root/check_dhcp.c:1246
6235#, c-format 5228#, c-format
6236msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n" 5229msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"
6237msgstr "" 5230msgstr ""
6238"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_ctrl/putmsg(): " 5231"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_ctrl/putmsg(): "
6239"%s.\n" 5232"%s.\n"
6240 5233
6241#: plugins-root/check_dhcp.c:1259
6242#, c-format 5234#, c-format
6243msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n" 5235msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"
6244msgstr "" 5236msgstr ""
6245"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_both/putmsg().\n" 5237"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_both/putmsg().\n"
6246 5238
6247#: plugins-root/check_dhcp.c:1271
6248#, c-format 5239#, c-format
6249msgid "" 5240msgid ""
6250"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n" 5241"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"
6251msgstr "" 5242msgstr ""
6252"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_attach_req/open" 5243"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_attach_req/"
6253"(%s..): %s.\n" 5244"open(%s..): %s.\n"
6254 5245
6255#: plugins-root/check_dhcp.c:1295
6256#, c-format 5246#, c-format
6257msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n" 5247msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"
6258msgstr "" 5248msgstr ""
6259"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_bind/check_ctrl" 5249"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_bind/"
6260"(): %s.\n" 5250"check_ctrl(): %s.\n"
6261 5251
6262#: plugins-root/check_dhcp.c:1374
6263#, c-format 5252#, c-format
6264msgid "Hardware address: " 5253msgid "Hardware address: "
6265msgstr "Adresse matérielle: " 5254msgstr "Adresse matérielle: "
6266 5255
6267#: plugins-root/check_dhcp.c:1390
6268msgid "This plugin tests the availability of DHCP servers on a network." 5256msgid "This plugin tests the availability of DHCP servers on a network."
6269msgstr "Ce plugin teste la disponibilité de serveurs DHCP dans un réseau." 5257msgstr "Ce plugin teste la disponibilité de serveurs DHCP dans un réseau."
6270 5258
6271#: plugins-root/check_dhcp.c:1402
6272msgid "IP address of DHCP server that we must hear from" 5259msgid "IP address of DHCP server that we must hear from"
6273msgstr "" 5260msgstr ""
6274 5261
6275#: plugins-root/check_dhcp.c:1404
6276msgid "IP address that should be offered by at least one DHCP server" 5262msgid "IP address that should be offered by at least one DHCP server"
6277msgstr "" 5263msgstr ""
6278 5264
6279#: plugins-root/check_dhcp.c:1406
6280msgid "Seconds to wait for DHCPOFFER before timeout occurs" 5265msgid "Seconds to wait for DHCPOFFER before timeout occurs"
6281msgstr "" 5266msgstr ""
6282 5267
6283#: plugins-root/check_dhcp.c:1408
6284msgid "Interface to to use for listening (i.e. eth0)" 5268msgid "Interface to to use for listening (i.e. eth0)"
6285msgstr "" 5269msgstr ""
6286 5270
6287#: plugins-root/check_dhcp.c:1410
6288msgid "MAC address to use in the DHCP request" 5271msgid "MAC address to use in the DHCP request"
6289msgstr "" 5272msgstr ""
6290 5273
6291#: plugins-root/check_dhcp.c:1412
6292msgid "Unicast testing: mimic a DHCP relay, requires -s" 5274msgid "Unicast testing: mimic a DHCP relay, requires -s"
6293msgstr "" 5275msgstr ""
6294 5276
6295#: plugins-root/check_icmp.c:1295
6296msgid "specify a target" 5277msgid "specify a target"
6297msgstr "" 5278msgstr ""
6298 5279
6299#: plugins-root/check_icmp.c:1297 5280msgid "Use IPv4 (default) or IPv6 to communicate with the targets"
5281msgstr ""
5282
6300msgid "warning threshold (currently " 5283msgid "warning threshold (currently "
6301msgstr "Valeurs pour le seuil d'avertissement (actuellement " 5284msgstr "Valeurs pour le seuil d'avertissement (actuellement "
6302 5285
6303#: plugins-root/check_icmp.c:1300
6304msgid "critical threshold (currently " 5286msgid "critical threshold (currently "
6305msgstr "Valeurs pour le seuil critique (actuellement " 5287msgstr "Valeurs pour le seuil critique (actuellement "
6306 5288
6307#: plugins-root/check_icmp.c:1303
6308msgid "specify a source IP address or device name" 5289msgid "specify a source IP address or device name"
6309msgstr "spécifiez une adresse ou un nom d'hôte" 5290msgstr "spécifiez une adresse ou un nom d'hôte"
6310 5291
6311#: plugins-root/check_icmp.c:1305
6312msgid "number of packets to send (currently " 5292msgid "number of packets to send (currently "
6313msgstr "nombre de paquets à envoyer (actuellement " 5293msgstr "nombre de paquets à envoyer (actuellement "
6314 5294
6315#: plugins-root/check_icmp.c:1308
6316msgid "max packet interval (currently " 5295msgid "max packet interval (currently "
6317msgstr "" 5296msgstr ""
6318 5297
6319#: plugins-root/check_icmp.c:1311
6320msgid "max target interval (currently " 5298msgid "max target interval (currently "
6321msgstr "" 5299msgstr ""
6322 5300
6323#: plugins-root/check_icmp.c:1314
6324msgid "number of alive hosts required for success" 5301msgid "number of alive hosts required for success"
6325msgstr "nombre d'hôtes vivants requis pour réussite" 5302msgstr "nombre d'hôtes vivants requis pour réussite"
6326 5303
6327#: plugins-root/check_icmp.c:1317
6328msgid "TTL on outgoing packets (currently " 5304msgid "TTL on outgoing packets (currently "
6329msgstr "" 5305msgstr ""
6330 5306
6331#: plugins-root/check_icmp.c:1320
6332msgid "timeout value (seconds, currently " 5307msgid "timeout value (seconds, currently "
6333msgstr "" 5308msgstr ""
6334 5309
6335#: plugins-root/check_icmp.c:1323
6336msgid "Number of icmp data bytes to send" 5310msgid "Number of icmp data bytes to send"
6337msgstr "Nombre de paquets ICMP à envoyer" 5311msgstr "Nombre de paquets ICMP à envoyer"
6338 5312
6339#: plugins-root/check_icmp.c:1324
6340msgid "Packet size will be data bytes + icmp header (currently" 5313msgid "Packet size will be data bytes + icmp header (currently"
6341msgstr "" 5314msgstr ""
6342 5315
6343#: plugins-root/check_icmp.c:1326
6344msgid "verbose" 5316msgid "verbose"
6345msgstr "" 5317msgstr ""
6346 5318
6347#: plugins-root/check_icmp.c:1330
6348msgid "The -H switch is optional. Naming a host (or several) to check is not." 5319msgid "The -H switch is optional. Naming a host (or several) to check is not."
6349msgstr "" 5320msgstr ""
6350 5321
6351#: plugins-root/check_icmp.c:1332
6352msgid "" 5322msgid ""
6353"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%" 5323"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"
6354msgstr "" 5324msgstr ""
6355 5325
6356#: plugins-root/check_icmp.c:1333
6357msgid "packet loss. The default values should work well for most users." 5326msgid "packet loss. The default values should work well for most users."
6358msgstr "" 5327msgstr ""
6359 5328
6360#: plugins-root/check_icmp.c:1334
6361msgid "" 5329msgid ""
6362"You can specify different RTA factors using the standardized abbreviations" 5330"You can specify different RTA factors using the standardized abbreviations"
6363msgstr "" 5331msgstr ""
6364 5332
6365#: plugins-root/check_icmp.c:1335
6366msgid "" 5333msgid ""
6367"us (microseconds), ms (milliseconds, default) or just plain s for seconds." 5334"us (microseconds), ms (milliseconds, default) or just plain s for seconds."
6368msgstr "" 5335msgstr ""
6369 5336
6370#: plugins-root/check_icmp.c:1341
6371msgid "The -v switch can be specified several times for increased verbosity." 5337msgid "The -v switch can be specified several times for increased verbosity."
6372msgstr "" 5338msgstr ""
6373 5339
6374#~ msgid "Critical threshold must be integer" 5340#~ msgid "Path or partition (may be repeated)"
6375#~ msgstr "le seuil critique doit être un entier positif" 5341#~ msgstr "Répertoire ou partition (peut être utilisé plusieurs fois)"
5342
5343#~ msgid ""
5344#~ "value match). If multiple addresses are returned at once, you have to "
5345#~ "match"
5346#~ msgstr ""
5347#~ "valeur correspond). Si plusieurs adresses sont retournées en même temps,"
5348
5349#~ msgid ""
5350#~ "the whole string of addresses separated with commas (sorted "
5351#~ "alphabetically)."
5352#~ msgstr ""
5353#~ "vous devrez toutes les inscrire séparées pas des virgules (en ordre "
5354#~ "alphabétique)"
5355
5356#~ msgid "No specific parameters. No warning or critical threshold"
5357#~ msgstr "Pas d'argument spécifique. Pas de seuil d'avertissement ou critique"
5358
5359#~ msgid "Can't find local IP for NAS-IP-Address"
5360#~ msgstr "Impossible de trouver une addresse IP locale pour le NAS-IP-Address"
6376 5361
6377#~ msgid "Warning threshold must be integer" 5362#~ msgid "Warning free space should be more than critical free space"
6378#~ msgstr "Le seuil d'avertissement doit être un entier positif" 5363#~ msgstr ""
5364#~ "Le seuil d'avertissement pour la place libre doit être plus grand que le "
5365#~ "seuil critique"
5366
5367#, c-format
5368#~ msgid "%s - Plugin timed out after %d seconds\n"
5369#~ msgstr "%s - Le plugin n'as pas répondu dans les %d secondes\n"
6379 5370
6380#~ msgid "Critical Process Count must be an integer!" 5371#~ msgid "Critical Process Count must be an integer!"
6381#~ msgstr "Critique Le total des processus doit être un nombre entier!" 5372#~ msgstr "Critique Le total des processus doit être un nombre entier!"
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index 8f220e98..d019a7eb 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
8msgstr "" 8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n" 9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 10"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
11"POT-Creation-Date: 2014-01-19 16:30-0500\n" 11"POT-Creation-Date: 2023-09-22 15:36+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n" 14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,3942 +18,3181 @@ msgstr ""
18"Content-Transfer-Encoding: 8bit\n" 18"Content-Transfer-Encoding: 8bit\n"
19"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 19"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
20 20
21#: plugins/check_by_ssh.c:86 plugins/check_cluster.c:76 plugins/check_dig.c:88
22#: plugins/check_disk.c:194 plugins/check_dns.c:102 plugins/check_dummy.c:52
23#: plugins/check_fping.c:93 plugins/check_game.c:82 plugins/check_hpjd.c:103
24#: plugins/check_http.c:167 plugins/check_ldap.c:109 plugins/check_load.c:122
25#: plugins/check_mrtgtraf.c:83 plugins/check_mysql.c:122
26#: plugins/check_nagios.c:91 plugins/check_nt.c:127 plugins/check_ntp.c:770
27#: plugins/check_ntp_peer.c:575 plugins/check_ntp_time.c:552
28#: plugins/check_nwstat.c:173 plugins/check_overcr.c:102
29#: plugins/check_pgsql.c:172 plugins/check_ping.c:95 plugins/check_procs.c:172
30#: plugins/check_radius.c:160 plugins/check_real.c:80 plugins/check_smtp.c:144
31#: plugins/check_snmp.c:240 plugins/check_ssh.c:73 plugins/check_swap.c:110
32#: plugins/check_tcp.c:218 plugins/check_time.c:78 plugins/check_ups.c:122
33#: plugins/check_users.c:77 plugins/negate.c:214 plugins-root/check_dhcp.c:270
34msgid "Could not parse arguments" 21msgid "Could not parse arguments"
35msgstr "" 22msgstr ""
36 23
37#: plugins/check_by_ssh.c:90 plugins/check_dig.c:82 plugins/check_dns.c:95
38#: plugins/check_nagios.c:95 plugins/check_pgsql.c:178 plugins/check_ping.c:99
39#: plugins/check_procs.c:188 plugins/check_snmp.c:336 plugins/negate.c:79
40msgid "Cannot catch SIGALRM" 24msgid "Cannot catch SIGALRM"
41msgstr "" 25msgstr ""
42 26
43#: plugins/check_by_ssh.c:110 27#, c-format
28msgid "SSH connection failed: %s\n"
29msgstr ""
30
44#, c-format 31#, c-format
45msgid "Remote command execution failed: %s\n" 32msgid "Remote command execution failed: %s\n"
46msgstr "" 33msgstr ""
47 34
48#: plugins/check_by_ssh.c:122
49#, c-format 35#, c-format
50msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n" 36msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n"
51msgstr "" 37msgstr ""
52 38
53#: plugins/check_by_ssh.c:134
54#, c-format 39#, c-format
55msgid "SSH WARNING: could not open %s\n" 40msgid "SSH WARNING: could not open %s\n"
56msgstr "" 41msgstr ""
57 42
58#: plugins/check_by_ssh.c:143
59#, c-format 43#, c-format
60msgid "%s: Error parsing output\n" 44msgid "%s: Error parsing output\n"
61msgstr "" 45msgstr ""
62 46
63#: plugins/check_by_ssh.c:220 plugins/check_disk.c:476
64#: plugins/check_http.c:278 plugins/check_ldap.c:293 plugins/check_pgsql.c:311
65#: plugins/check_procs.c:437 plugins/check_radius.c:308
66#: plugins/check_real.c:356 plugins/check_smtp.c:581 plugins/check_snmp.c:736
67#: plugins/check_ssh.c:138 plugins/check_tcp.c:505 plugins/check_time.c:302
68#: plugins/check_ups.c:556 plugins/negate.c:164
69msgid "Timeout interval must be a positive integer" 47msgid "Timeout interval must be a positive integer"
70msgstr "" 48msgstr ""
71 49
72#: plugins/check_by_ssh.c:230 plugins/check_pgsql.c:341
73#: plugins/check_radius.c:272 plugins/check_real.c:327
74#: plugins/check_smtp.c:506 plugins/check_tcp.c:511 plugins/check_time.c:296
75#: plugins/check_ups.c:518
76msgid "Port must be a positive integer" 50msgid "Port must be a positive integer"
77msgstr "" 51msgstr ""
78 52
79#: plugins/check_by_ssh.c:291
80msgid "skip-stdout argument must be an integer" 53msgid "skip-stdout argument must be an integer"
81msgstr "" 54msgstr ""
82 55
83#: plugins/check_by_ssh.c:299
84msgid "skip-stderr argument must be an integer" 56msgid "skip-stderr argument must be an integer"
85msgstr "" 57msgstr ""
86 58
87#: plugins/check_by_ssh.c:322
88#, c-format 59#, c-format
89msgid "%s: You must provide a host name\n" 60msgid "%s: You must provide a host name\n"
90msgstr "" 61msgstr ""
91 62
92#: plugins/check_by_ssh.c:340
93msgid "No remotecmd" 63msgid "No remotecmd"
94msgstr "" 64msgstr ""
95 65
96#: plugins/check_by_ssh.c:354
97#, c-format 66#, c-format
98msgid "%s: Argument limit of %d exceeded\n" 67msgid "%s: Argument limit of %d exceeded\n"
99msgstr "" 68msgstr ""
100 69
101#: plugins/check_by_ssh.c:357
102msgid "Can not (re)allocate 'commargv' buffer\n" 70msgid "Can not (re)allocate 'commargv' buffer\n"
103msgstr "" 71msgstr ""
104 72
105#: plugins/check_by_ssh.c:371
106#, c-format 73#, c-format
107msgid "" 74msgid ""
108"%s: In passive mode, you must provide a service name for each command.\n" 75"%s: In passive mode, you must provide a service name for each command.\n"
109msgstr "" 76msgstr ""
110 77
111#: plugins/check_by_ssh.c:374
112#, c-format 78#, c-format
113msgid "" 79msgid ""
114"%s: In passive mode, you must provide the host short name from the " 80"%s: In passive mode, you must provide the host short name from the "
115"monitoring configs.\n" 81"monitoring configs.\n"
116msgstr "" 82msgstr ""
117 83
118#: plugins/check_by_ssh.c:388
119#, c-format 84#, c-format
120msgid "This plugin uses SSH to execute commands on a remote host" 85msgid "This plugin uses SSH to execute commands on a remote host"
121msgstr "" 86msgstr ""
122 87
123#: plugins/check_by_ssh.c:403
124msgid "tell ssh to use Protocol 1 [optional]" 88msgid "tell ssh to use Protocol 1 [optional]"
125msgstr "" 89msgstr ""
126 90
127#: plugins/check_by_ssh.c:405
128msgid "tell ssh to use Protocol 2 [optional]" 91msgid "tell ssh to use Protocol 2 [optional]"
129msgstr "" 92msgstr ""
130 93
131#: plugins/check_by_ssh.c:407
132msgid "Ignore all or (if specified) first n lines on STDOUT [optional]" 94msgid "Ignore all or (if specified) first n lines on STDOUT [optional]"
133msgstr "" 95msgstr ""
134 96
135#: plugins/check_by_ssh.c:409
136msgid "Ignore all or (if specified) first n lines on STDERR [optional]" 97msgid "Ignore all or (if specified) first n lines on STDERR [optional]"
137msgstr "" 98msgstr ""
138 99
139#: plugins/check_by_ssh.c:411 100msgid "Exit with an warning, if there is an output on STDERR"
101msgstr ""
102
140msgid "" 103msgid ""
141"tells ssh to fork rather than create a tty [optional]. This will always " 104"tells ssh to fork rather than create a tty [optional]. This will always "
142"return OK if ssh is executed" 105"return OK if ssh is executed"
143msgstr "" 106msgstr ""
144 107
145#: plugins/check_by_ssh.c:413
146msgid "command to execute on the remote machine" 108msgid "command to execute on the remote machine"
147msgstr "" 109msgstr ""
148 110
149#: plugins/check_by_ssh.c:415
150msgid "SSH user name on remote host [optional]" 111msgid "SSH user name on remote host [optional]"
151msgstr "" 112msgstr ""
152 113
153#: plugins/check_by_ssh.c:417
154msgid "identity of an authorized key [optional]" 114msgid "identity of an authorized key [optional]"
155msgstr "" 115msgstr ""
156 116
157#: plugins/check_by_ssh.c:419
158msgid "external command file for monitoring [optional]" 117msgid "external command file for monitoring [optional]"
159msgstr "" 118msgstr ""
160 119
161#: plugins/check_by_ssh.c:421
162msgid "list of monitoring service names, separated by ':' [optional]" 120msgid "list of monitoring service names, separated by ':' [optional]"
163msgstr "" 121msgstr ""
164 122
165#: plugins/check_by_ssh.c:423
166msgid "short name of host in the monitoring configuration [optional]" 123msgid "short name of host in the monitoring configuration [optional]"
167msgstr "" 124msgstr ""
168 125
169#: plugins/check_by_ssh.c:425
170msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]" 126msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]"
171msgstr "" 127msgstr ""
172 128
173#: plugins/check_by_ssh.c:427
174msgid "Tell ssh to use this configfile [optional]" 129msgid "Tell ssh to use this configfile [optional]"
175msgstr "" 130msgstr ""
176 131
177#: plugins/check_by_ssh.c:429
178msgid "Tell ssh to suppress warning and diagnostic messages [optional]" 132msgid "Tell ssh to suppress warning and diagnostic messages [optional]"
179msgstr "" 133msgstr ""
180 134
181#: plugins/check_by_ssh.c:434 135msgid "Make connection problems return UNKNOWN instead of CRITICAL"
136msgstr ""
137
182msgid "The most common mode of use is to refer to a local identity file with" 138msgid "The most common mode of use is to refer to a local identity file with"
183msgstr "" 139msgstr ""
184 140
185#: plugins/check_by_ssh.c:435
186msgid "the '-i' option. In this mode, the identity pair should have a null" 141msgid "the '-i' option. In this mode, the identity pair should have a null"
187msgstr "" 142msgstr ""
188 143
189#: plugins/check_by_ssh.c:436
190msgid "passphrase and the public key should be listed in the authorized_keys" 144msgid "passphrase and the public key should be listed in the authorized_keys"
191msgstr "" 145msgstr ""
192 146
193#: plugins/check_by_ssh.c:437
194msgid "file of the remote host. Usually the key will be restricted to running" 147msgid "file of the remote host. Usually the key will be restricted to running"
195msgstr "" 148msgstr ""
196 149
197#: plugins/check_by_ssh.c:438
198msgid "only one command on the remote server. If the remote SSH server tracks" 150msgid "only one command on the remote server. If the remote SSH server tracks"
199msgstr "" 151msgstr ""
200 152
201#: plugins/check_by_ssh.c:439
202msgid "invocation arguments, the one remote program may be an agent that can" 153msgid "invocation arguments, the one remote program may be an agent that can"
203msgstr "" 154msgstr ""
204 155
205#: plugins/check_by_ssh.c:440
206msgid "execute additional commands as proxy" 156msgid "execute additional commands as proxy"
207msgstr "" 157msgstr ""
208 158
209#: plugins/check_by_ssh.c:442
210msgid "To use passive mode, provide multiple '-C' options, and provide" 159msgid "To use passive mode, provide multiple '-C' options, and provide"
211msgstr "" 160msgstr ""
212 161
213#: plugins/check_by_ssh.c:443
214msgid "" 162msgid ""
215"all of -O, -s, and -n options (servicelist order must match '-C'options)" 163"all of -O, -s, and -n options (servicelist order must match '-C'options)"
216msgstr "" 164msgstr ""
217 165
218#: plugins/check_by_ssh.c:445 plugins/check_cluster.c:261
219#: plugins/check_dig.c:355 plugins/check_disk.c:924 plugins/check_http.c:1560
220#: plugins/check_nagios.c:312 plugins/check_ntp.c:869
221#: plugins/check_ntp_peer.c:705 plugins/check_ntp_time.c:633
222#: plugins/check_procs.c:763 plugins/negate.c:271 plugins/urlize.c:180
223msgid "Examples:" 166msgid "Examples:"
224msgstr "" 167msgstr ""
225 168
226#: plugins/check_by_ssh.c:460 plugins/check_cluster.c:274
227#: plugins/check_dig.c:367 plugins/check_disk.c:941 plugins/check_dns.c:486
228#: plugins/check_dummy.c:122 plugins/check_fping.c:505
229#: plugins/check_game.c:331 plugins/check_hpjd.c:414 plugins/check_http.c:1590
230#: plugins/check_ldap.c:451 plugins/check_load.c:334 plugins/check_mrtg.c:382
231#: plugins/check_mysql.c:569 plugins/check_nagios.c:323 plugins/check_nt.c:774
232#: plugins/check_ntp.c:888 plugins/check_ntp_peer.c:725
233#: plugins/check_ntp_time.c:642 plugins/check_nwstat.c:1685
234#: plugins/check_overcr.c:467 plugins/check_pgsql.c:578
235#: plugins/check_ping.c:603 plugins/check_procs.c:781
236#: plugins/check_radius.c:385 plugins/check_real.c:451
237#: plugins/check_smtp.c:843 plugins/check_snmp.c:1207 plugins/check_ssh.c:309
238#: plugins/check_swap.c:558 plugins/check_tcp.c:684 plugins/check_time.c:371
239#: plugins/check_ups.c:660 plugins/check_users.c:240
240#: plugins/check_ide_smart.c:640 plugins/negate.c:295 plugins/urlize.c:197
241#: plugins-root/check_dhcp.c:1422 plugins-root/check_icmp.c:1354
242msgid "Usage:" 169msgid "Usage:"
243msgstr "" 170msgstr ""
244 171
245#: plugins/check_cluster.c:230
246#, c-format 172#, c-format
247msgid "Host/Service Cluster Plugin for Monitoring" 173msgid "Host/Service Cluster Plugin for Monitoring"
248msgstr "" 174msgstr ""
249 175
250#: plugins/check_cluster.c:236 plugins/check_nt.c:676
251msgid "Options:" 176msgid "Options:"
252msgstr "" 177msgstr ""
253 178
254#: plugins/check_cluster.c:239
255msgid "Check service cluster status" 179msgid "Check service cluster status"
256msgstr "" 180msgstr ""
257 181
258#: plugins/check_cluster.c:241
259msgid "Check host cluster status" 182msgid "Check host cluster status"
260msgstr "" 183msgstr ""
261 184
262#: plugins/check_cluster.c:243
263msgid "Optional prepended text output (i.e. \"Host cluster\")" 185msgid "Optional prepended text output (i.e. \"Host cluster\")"
264msgstr "" 186msgstr ""
265 187
266#: plugins/check_cluster.c:245 plugins/check_cluster.c:248
267msgid "Specifies the range of hosts or services in cluster that must be in a" 188msgid "Specifies the range of hosts or services in cluster that must be in a"
268msgstr "" 189msgstr ""
269 190
270#: plugins/check_cluster.c:246
271msgid "non-OK state in order to return a WARNING status level" 191msgid "non-OK state in order to return a WARNING status level"
272msgstr "" 192msgstr ""
273 193
274#: plugins/check_cluster.c:249
275msgid "non-OK state in order to return a CRITICAL status level" 194msgid "non-OK state in order to return a CRITICAL status level"
276msgstr "" 195msgstr ""
277 196
278#: plugins/check_cluster.c:251
279msgid "The status codes of the hosts or services in the cluster, separated by" 197msgid "The status codes of the hosts or services in the cluster, separated by"
280msgstr "" 198msgstr ""
281 199
282#: plugins/check_cluster.c:252
283msgid "commas" 200msgid "commas"
284msgstr "" 201msgstr ""
285 202
286#: plugins/check_cluster.c:257 plugins/check_game.c:318
287#: plugins/check_http.c:1542 plugins/check_ldap.c:438 plugins/check_mrtg.c:363
288#: plugins/check_mrtgtraf.c:361 plugins/check_mysql.c:558
289#: plugins/check_nt.c:758 plugins/check_ntp.c:865 plugins/check_ntp_peer.c:696
290#: plugins/check_ntp_time.c:626 plugins/check_nwstat.c:1670
291#: plugins/check_overcr.c:456 plugins/check_snmp.c:1178
292#: plugins/check_swap.c:547 plugins/check_ups.c:642 plugins/negate.c:277
293#: plugins-root/check_icmp.c:1329
294msgid "Notes:" 203msgid "Notes:"
295msgstr "" 204msgstr ""
296 205
297#: plugins/check_cluster.c:263
298msgid "" 206msgid ""
299"Will alert critical if there are 3 or more service data points in a non-OK" 207"Will alert critical if there are 3 or more service data points in a non-OK"
300msgstr "" 208msgstr ""
301 209
302#: plugins/check_cluster.c:264 plugins/check_ups.c:639
303msgid "state." 210msgid "state."
304msgstr "" 211msgstr ""
305 212
306#: plugins/check_dig.c:100 plugins/check_dig.c:102
307#, c-format 213#, c-format
308msgid "Looking for: '%s'\n" 214msgid "Looking for: '%s'\n"
309msgstr "" 215msgstr ""
310 216
311#: plugins/check_dig.c:109
312msgid "dig returned an error status" 217msgid "dig returned an error status"
313msgstr "" 218msgstr ""
314 219
315#: plugins/check_dig.c:134
316msgid "Server not found in ANSWER SECTION" 220msgid "Server not found in ANSWER SECTION"
317msgstr "" 221msgstr ""
318 222
319#: plugins/check_dig.c:144
320msgid "No ANSWER SECTION found" 223msgid "No ANSWER SECTION found"
321msgstr "" 224msgstr ""
322 225
323#: plugins/check_dig.c:171
324msgid "Probably a non-existent host/domain" 226msgid "Probably a non-existent host/domain"
325msgstr "" 227msgstr ""
326 228
327#: plugins/check_dig.c:233
328#, c-format 229#, c-format
329msgid "Port must be a positive integer - %s" 230msgid "Port must be a positive integer - %s"
330msgstr "" 231msgstr ""
331 232
332#: plugins/check_dig.c:244
333#, c-format 233#, c-format
334msgid "Warning interval must be a positive integer - %s" 234msgid "Warning interval must be a positive integer - %s"
335msgstr "" 235msgstr ""
336 236
337#: plugins/check_dig.c:252
338#, c-format 237#, c-format
339msgid "Critical interval must be a positive integer - %s" 238msgid "Critical interval must be a positive integer - %s"
340msgstr "" 239msgstr ""
341 240
342#: plugins/check_dig.c:260
343#, c-format 241#, c-format
344msgid "Timeout interval must be a positive integer - %s" 242msgid "Timeout interval must be a positive integer - %s"
345msgstr "" 243msgstr ""
346 244
347#: plugins/check_dig.c:325
348#, c-format 245#, c-format
349msgid "This plugin test the DNS service on the specified host using dig" 246msgid "This plugin tests the DNS service on the specified host using dig"
350msgstr "" 247msgstr ""
351 248
352#: plugins/check_dig.c:338
353msgid "Force dig to only use IPv4 query transport" 249msgid "Force dig to only use IPv4 query transport"
354msgstr "" 250msgstr ""
355 251
356#: plugins/check_dig.c:340
357msgid "Force dig to only use IPv6 query transport" 252msgid "Force dig to only use IPv6 query transport"
358msgstr "" 253msgstr ""
359 254
360#: plugins/check_dig.c:342
361msgid "Machine name to lookup" 255msgid "Machine name to lookup"
362msgstr "" 256msgstr ""
363 257
364#: plugins/check_dig.c:344
365msgid "Record type to lookup (default: A)" 258msgid "Record type to lookup (default: A)"
366msgstr "" 259msgstr ""
367 260
368#: plugins/check_dig.c:346
369msgid "" 261msgid ""
370"An address expected to be in the answer section. If not set, uses whatever" 262"An address expected to be in the answer section. If not set, uses whatever"
371msgstr "" 263msgstr ""
372 264
373#: plugins/check_dig.c:347
374msgid "was in -l" 265msgid "was in -l"
375msgstr "" 266msgstr ""
376 267
377#: plugins/check_dig.c:349
378msgid "Pass STRING as argument(s) to dig" 268msgid "Pass STRING as argument(s) to dig"
379msgstr "" 269msgstr ""
380 270
381#: plugins/check_disk.c:216
382#, c-format 271#, c-format
383msgid "DISK %s: %s not found\n" 272msgid "DISK %s: %s not found\n"
384msgstr "" 273msgstr ""
385 274
386#: plugins/check_disk.c:216 plugins/check_disk.c:956 plugins/check_dns.c:241
387#: plugins/check_dummy.c:74 plugins/check_mysql.c:299
388#: plugins/check_nagios.c:104 plugins/check_nagios.c:168
389#: plugins/check_nagios.c:172 plugins/check_pgsql.c:601
390#: plugins/check_pgsql.c:618 plugins/check_pgsql.c:627
391#: plugins/check_pgsql.c:642 plugins/check_procs.c:351
392#, c-format 275#, c-format
393msgid "CRITICAL" 276msgid "CRITICAL"
394msgstr "" 277msgstr ""
395 278
396#: plugins/check_disk.c:550
397#, c-format 279#, c-format
398msgid "unit type %s not known\n" 280msgid "unit type %s not known\n"
399msgstr "" 281msgstr ""
400 282
401#: plugins/check_disk.c:553
402#, c-format 283#, c-format
403msgid "failed allocating storage for '%s'\n" 284msgid "failed allocating storage for '%s'\n"
404msgstr "" 285msgstr ""
405 286
406#: plugins/check_disk.c:577 plugins/check_disk.c:618 plugins/check_disk.c:626
407#: plugins/check_disk.c:633 plugins/check_disk.c:637 plugins/check_disk.c:677
408#: plugins/check_disk.c:683 plugins/check_disk.c:702 plugins/check_dummy.c:77
409#: plugins/check_dummy.c:80 plugins/check_pgsql.c:643
410#: plugins/check_procs.c:506
411#, c-format 287#, c-format
412msgid "UNKNOWN" 288msgid "UNKNOWN"
413msgstr "" 289msgstr ""
414 290
415#: plugins/check_disk.c:577
416msgid "Must set a threshold value before using -p\n" 291msgid "Must set a threshold value before using -p\n"
417msgstr "" 292msgstr ""
418 293
419#: plugins/check_disk.c:618
420msgid "Must set -E before selecting paths\n" 294msgid "Must set -E before selecting paths\n"
421msgstr "" 295msgstr ""
422 296
423#: plugins/check_disk.c:626
424msgid "Must set group value before selecting paths\n" 297msgid "Must set group value before selecting paths\n"
425msgstr "" 298msgstr ""
426 299
427#: plugins/check_disk.c:633
428msgid "" 300msgid ""
429"Paths need to be selected before using -i/-I. Use -A to select all paths " 301"Paths need to be selected before using -i/-I. Use -A to select all paths "
430"explicitly" 302"explicitly"
431msgstr "" 303msgstr ""
432 304
433#: plugins/check_disk.c:637 plugins/check_disk.c:683 plugins/check_procs.c:506
434msgid "Could not compile regular expression" 305msgid "Could not compile regular expression"
435msgstr "" 306msgstr ""
436 307
437#: plugins/check_disk.c:677 308msgid ""
438msgid "Must set a threshold value before using -r/-R\n" 309"Must set a threshold value before using -r/-R/-A (--ereg-path/--eregi-path/--"
310"all)\n"
439msgstr "" 311msgstr ""
440 312
441#: plugins/check_disk.c:703
442msgid "Regular expression did not match any path or disk" 313msgid "Regular expression did not match any path or disk"
443msgstr "" 314msgstr ""
444 315
445#: plugins/check_disk.c:749
446msgid "Unknown argument" 316msgid "Unknown argument"
447msgstr "" 317msgstr ""
448 318
449#: plugins/check_disk.c:783
450#, c-format 319#, c-format
451msgid " for %s\n" 320msgid " for %s\n"
452msgstr "" 321msgstr ""
453 322
454#: plugins/check_disk.c:857
455msgid "" 323msgid ""
456"This plugin checks the amount of used disk space on a mounted file system" 324"This plugin checks the amount of used disk space on a mounted file system"
457msgstr "" 325msgstr ""
458 326
459#: plugins/check_disk.c:858
460msgid "" 327msgid ""
461"and generates an alert if free space is less than one of the threshold values" 328"and generates an alert if free space is less than one of the threshold values"
462msgstr "" 329msgstr ""
463 330
464#: plugins/check_disk.c:868
465msgid "Exit with WARNING status if less than INTEGER units of disk are free" 331msgid "Exit with WARNING status if less than INTEGER units of disk are free"
466msgstr "" 332msgstr ""
467 333
468#: plugins/check_disk.c:870
469msgid "Exit with WARNING status if less than PERCENT of disk space is free" 334msgid "Exit with WARNING status if less than PERCENT of disk space is free"
470msgstr "" 335msgstr ""
471 336
472#: plugins/check_disk.c:872
473msgid "Exit with CRITICAL status if less than INTEGER units of disk are free" 337msgid "Exit with CRITICAL status if less than INTEGER units of disk are free"
474msgstr "" 338msgstr ""
475 339
476#: plugins/check_disk.c:874
477msgid "Exit with CRITICAL status if less than PERCENT of disk space is free" 340msgid "Exit with CRITICAL status if less than PERCENT of disk space is free"
478msgstr "" 341msgstr ""
479 342
480#: plugins/check_disk.c:876
481msgid "Exit with WARNING status if less than PERCENT of inode space is free" 343msgid "Exit with WARNING status if less than PERCENT of inode space is free"
482msgstr "" 344msgstr ""
483 345
484#: plugins/check_disk.c:878
485msgid "Exit with CRITICAL status if less than PERCENT of inode space is free" 346msgid "Exit with CRITICAL status if less than PERCENT of inode space is free"
486msgstr "" 347msgstr ""
487 348
488#: plugins/check_disk.c:880 349msgid ""
489msgid "Path or partition (may be repeated)" 350"Mount point or block device as emitted by the mount(8) command (may be "
351"repeated)"
490msgstr "" 352msgstr ""
491 353
492#: plugins/check_disk.c:882
493msgid "Ignore device (only works if -p unspecified)" 354msgid "Ignore device (only works if -p unspecified)"
494msgstr "" 355msgstr ""
495 356
496#: plugins/check_disk.c:884
497msgid "Clear thresholds" 357msgid "Clear thresholds"
498msgstr "" 358msgstr ""
499 359
500#: plugins/check_disk.c:886
501msgid "For paths or partitions specified with -p, only check for exact paths" 360msgid "For paths or partitions specified with -p, only check for exact paths"
502msgstr "" 361msgstr ""
503 362
504#: plugins/check_disk.c:888
505msgid "Display only devices/mountpoints with errors" 363msgid "Display only devices/mountpoints with errors"
506msgstr "" 364msgstr ""
507 365
508#: plugins/check_disk.c:890
509msgid "Don't account root-reserved blocks into freespace in perfdata" 366msgid "Don't account root-reserved blocks into freespace in perfdata"
510msgstr "" 367msgstr ""
511 368
512#: plugins/check_disk.c:892 369msgid "Display inode usage in perfdata"
370msgstr ""
371
513msgid "" 372msgid ""
514"Group paths. Thresholds apply to (free-)space of all partitions together" 373"Group paths. Thresholds apply to (free-)space of all partitions together"
515msgstr "" 374msgstr ""
516 375
517#: plugins/check_disk.c:894
518msgid "Same as '--units kB'" 376msgid "Same as '--units kB'"
519msgstr "" 377msgstr ""
520 378
521#: plugins/check_disk.c:896
522msgid "Only check local filesystems" 379msgid "Only check local filesystems"
523msgstr "" 380msgstr ""
524 381
525#: plugins/check_disk.c:898
526msgid "" 382msgid ""
527"Only check local filesystems against thresholds. Yet call stat on remote " 383"Only check local filesystems against thresholds. Yet call stat on remote "
528"filesystems" 384"filesystems"
529msgstr "" 385msgstr ""
530 386
531#: plugins/check_disk.c:899
532msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)" 387msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)"
533msgstr "" 388msgstr ""
534 389
535#: plugins/check_disk.c:901 390msgid "Display the (block) device instead of the mount point"
536msgid "Display the mountpoint instead of the partition"
537msgstr "" 391msgstr ""
538 392
539#: plugins/check_disk.c:903
540msgid "Same as '--units MB'" 393msgid "Same as '--units MB'"
541msgstr "" 394msgstr ""
542 395
543#: plugins/check_disk.c:905
544msgid "Explicitly select all paths. This is equivalent to -R '.*'" 396msgid "Explicitly select all paths. This is equivalent to -R '.*'"
545msgstr "" 397msgstr ""
546 398
547#: plugins/check_disk.c:907
548msgid "" 399msgid ""
549"Case insensitive regular expression for path/partition (may be repeated)" 400"Case insensitive regular expression for path/partition (may be repeated)"
550msgstr "" 401msgstr ""
551 402
552#: plugins/check_disk.c:909
553msgid "Regular expression for path or partition (may be repeated)" 403msgid "Regular expression for path or partition (may be repeated)"
554msgstr "" 404msgstr ""
555 405
556#: plugins/check_disk.c:911
557msgid "" 406msgid ""
558"Regular expression to ignore selected path/partition (case insensitive) (may " 407"Regular expression to ignore selected path/partition (case insensitive) (may "
559"be repeated)" 408"be repeated)"
560msgstr "" 409msgstr ""
561 410
562#: plugins/check_disk.c:913
563msgid "" 411msgid ""
564"Regular expression to ignore selected path or partition (may be repeated)" 412"Regular expression to ignore selected path or partition (may be repeated)"
565msgstr "" 413msgstr ""
566 414
567#: plugins/check_disk.c:916 415msgid ""
416"Return OK if no filesystem matches, filesystem does not exist or is "
417"inaccessible."
418msgstr ""
419
420msgid "(Provide this option before -p / -r / --ereg-path if used)"
421msgstr ""
422
568msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 423msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
569msgstr "" 424msgstr ""
570 425
571#: plugins/check_disk.c:919
572msgid "Ignore all filesystems of indicated type (may be repeated)" 426msgid "Ignore all filesystems of indicated type (may be repeated)"
573msgstr "" 427msgstr ""
574 428
575#: plugins/check_disk.c:921
576msgid "Check only filesystems of indicated type (may be repeated)" 429msgid "Check only filesystems of indicated type (may be repeated)"
577msgstr "" 430msgstr ""
578 431
579#: plugins/check_disk.c:926 432msgid "General usage hints:"
433msgstr ""
434
435msgid ""
436"- Arguments are positional! \"-w 5 -c 1 -p /foo -w6 -c2 -p /bar\" is not the "
437"same as"
438msgstr ""
439
440msgid "\"-w 5 -c 1 -p /bar w6 -c2 -p /foo\"."
441msgstr ""
442
443msgid ""
444"- The syntax is broadly: \"{thresholds a} {paths a} -C {thresholds b} "
445"{thresholds b} ...\""
446msgstr ""
447
580msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB" 448msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
581msgstr "" 449msgstr ""
582 450
583#: plugins/check_disk.c:928
584msgid "" 451msgid ""
585"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -" 452"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -"
586"r regex" 453"r regex"
587msgstr "" 454msgstr ""
588 455
589#: plugins/check_disk.c:929
590msgid "" 456msgid ""
591"are grouped which means the freespace thresholds are applied to all disks " 457"are grouped which means the freespace thresholds are applied to all disks "
592"together" 458"together"
593msgstr "" 459msgstr ""
594 460
595#: plugins/check_disk.c:931
596msgid "" 461msgid ""
597"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use " 462"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use "
598"100M/50M" 463"100M/50M"
599msgstr "" 464msgstr ""
600 465
601#: plugins/check_disk.c:957
602#, c-format 466#, c-format
603msgid "%s %s: %s\n" 467msgid "%s %s: %s\n"
604msgstr "" 468msgstr ""
605 469
606#: plugins/check_disk.c:957
607msgid "is not accessible" 470msgid "is not accessible"
608msgstr "" 471msgstr ""
609 472
610#: plugins/check_dns.c:116
611msgid "nslookup returned an error status" 473msgid "nslookup returned an error status"
612msgstr "" 474msgstr ""
613 475
614#: plugins/check_dns.c:134
615msgid "Warning plugin error" 476msgid "Warning plugin error"
616msgstr "" 477msgstr ""
617 478
618#: plugins/check_dns.c:154 479#, c-format
480msgid "DNS CRITICAL - '%s' returned empty server string\n"
481msgstr ""
482
483#, c-format
484msgid "DNS CRITICAL - No response from DNS %s\n"
485msgstr ""
486
619#, c-format 487#, c-format
620msgid "DNS CRITICAL - '%s' returned empty host name string\n" 488msgid "DNS CRITICAL - '%s' returned empty host name string\n"
621msgstr "" 489msgstr ""
622 490
623#: plugins/check_dns.c:160
624msgid "Non-authoritative answer:" 491msgid "Non-authoritative answer:"
625msgstr "" 492msgstr ""
626 493
627#: plugins/check_dns.c:201 494#, c-format
495msgid "Domain '%s' was not found by the server\n"
496msgstr ""
497
628#, c-format 498#, c-format
629msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n" 499msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n"
630msgstr "" 500msgstr ""
631 501
632#: plugins/check_dns.c:216
633#, c-format 502#, c-format
634msgid "expected '%s' but got '%s'" 503msgid "expected '%s' but got '%s'"
635msgstr "" 504msgstr ""
636 505
637#: plugins/check_dns.c:223 506#, c-format
507msgid "Domain '%s' was found by the server: '%s'\n"
508msgstr ""
509
638#, c-format 510#, c-format
639msgid "server %s is not authoritative for %s" 511msgid "server %s is not authoritative for %s"
640msgstr "" 512msgstr ""
641 513
642#: plugins/check_dns.c:237 plugins/check_dummy.c:68 plugins/check_nagios.c:182
643#: plugins/check_pgsql.c:638 plugins/check_procs.c:344
644#, c-format 514#, c-format
645msgid "OK" 515msgid "OK"
646msgstr "" 516msgstr ""
647 517
648#: plugins/check_dns.c:239 plugins/check_dummy.c:71 plugins/check_mysql.c:296
649#: plugins/check_nagios.c:182 plugins/check_pgsql.c:607
650#: plugins/check_pgsql.c:612 plugins/check_pgsql.c:640
651#: plugins/check_procs.c:346
652#, c-format 518#, c-format
653msgid "WARNING" 519msgid "WARNING"
654msgstr "" 520msgstr ""
655 521
656#: plugins/check_dns.c:243
657#, c-format 522#, c-format
658msgid "%.3f second response time" 523msgid "%.3f second response time"
659msgid_plural "%.3f seconds response time" 524msgid_plural "%.3f seconds response time"
660msgstr[0] "" 525msgstr[0] ""
661msgstr[1] "" 526msgstr[1] ""
662 527
663#: plugins/check_dns.c:244
664#, c-format 528#, c-format
665msgid ". %s returns %s" 529msgid ". %s returns %s"
666msgstr "" 530msgstr ""
667 531
668#: plugins/check_dns.c:248
669#, c-format 532#, c-format
670msgid "DNS WARNING - %s\n" 533msgid "DNS WARNING - %s\n"
671msgstr "" 534msgstr ""
672 535
673#: plugins/check_dns.c:249 plugins/check_dns.c:252 plugins/check_dns.c:255
674msgid " Probably a non-existent host/domain" 536msgid " Probably a non-existent host/domain"
675msgstr "" 537msgstr ""
676 538
677#: plugins/check_dns.c:251
678#, c-format 539#, c-format
679msgid "DNS CRITICAL - %s\n" 540msgid "DNS CRITICAL - %s\n"
680msgstr "" 541msgstr ""
681 542
682#: plugins/check_dns.c:254
683#, c-format 543#, c-format
684msgid "DNS UNKNOWN - %s\n" 544msgid "DNS UNKNOWN - %s\n"
685msgstr "" 545msgstr ""
686 546
687#: plugins/check_dns.c:267
688msgid "Note: nslookup is deprecated and may be removed from future releases." 547msgid "Note: nslookup is deprecated and may be removed from future releases."
689msgstr "" 548msgstr ""
690 549
691#: plugins/check_dns.c:268
692msgid "Consider using the `dig' or `host' programs instead. Run nslookup with" 550msgid "Consider using the `dig' or `host' programs instead. Run nslookup with"
693msgstr "" 551msgstr ""
694 552
695#: plugins/check_dns.c:269
696msgid "the `-sil[ent]' option to prevent this message from appearing." 553msgid "the `-sil[ent]' option to prevent this message from appearing."
697msgstr "" 554msgstr ""
698 555
699#: plugins/check_dns.c:274
700#, c-format 556#, c-format
701msgid "No response from DNS %s\n" 557msgid "No response from DNS %s\n"
702msgstr "" 558msgstr ""
703 559
704#: plugins/check_dns.c:278
705#, c-format 560#, c-format
706msgid "DNS %s has no records\n" 561msgid "DNS %s has no records\n"
707msgstr "" 562msgstr ""
708 563
709#: plugins/check_dns.c:286
710#, c-format 564#, c-format
711msgid "Connection to DNS %s was refused\n" 565msgid "Connection to DNS %s was refused\n"
712msgstr "" 566msgstr ""
713 567
714#: plugins/check_dns.c:290
715#, c-format 568#, c-format
716msgid "Query was refused by DNS server at %s\n" 569msgid "Query was refused by DNS server at %s\n"
717msgstr "" 570msgstr ""
718 571
719#: plugins/check_dns.c:294
720#, c-format 572#, c-format
721msgid "No information returned by DNS server at %s\n" 573msgid "No information returned by DNS server at %s\n"
722msgstr "" 574msgstr ""
723 575
724#: plugins/check_dns.c:300
725#, c-format
726msgid "Domain %s was not found by the server\n"
727msgstr ""
728
729#: plugins/check_dns.c:304
730msgid "Network is unreachable\n" 576msgid "Network is unreachable\n"
731msgstr "" 577msgstr ""
732 578
733#: plugins/check_dns.c:308
734#, c-format 579#, c-format
735msgid "DNS failure for %s\n" 580msgid "DNS failure for %s\n"
736msgstr "" 581msgstr ""
737 582
738#: plugins/check_dns.c:372 plugins/check_dns.c:380 plugins/check_dns.c:387
739#: plugins/check_dns.c:392 plugins/check_dns.c:414 plugins/check_dns.c:422
740#: plugins/check_game.c:211 plugins/check_game.c:219
741msgid "Input buffer overflow\n" 583msgid "Input buffer overflow\n"
742msgstr "" 584msgstr ""
743 585
744#: plugins/check_dns.c:450
745msgid "" 586msgid ""
746"This plugin uses the nslookup program to obtain the IP address for the given " 587"This plugin uses the nslookup program to obtain the IP address for the given "
747"host/domain query." 588"host/domain query."
748msgstr "" 589msgstr ""
749 590
750#: plugins/check_dns.c:451
751msgid "An optional DNS server to use may be specified." 591msgid "An optional DNS server to use may be specified."
752msgstr "" 592msgstr ""
753 593
754#: plugins/check_dns.c:452
755msgid "" 594msgid ""
756"If no DNS server is specified, the default server(s) specified in /etc/" 595"If no DNS server is specified, the default server(s) specified in /etc/"
757"resolv.conf will be used." 596"resolv.conf will be used."
758msgstr "" 597msgstr ""
759 598
760#: plugins/check_dns.c:462
761msgid "The name or address you want to query" 599msgid "The name or address you want to query"
762msgstr "" 600msgstr ""
763 601
764#: plugins/check_dns.c:464
765msgid "Optional DNS server you want to use for the lookup" 602msgid "Optional DNS server you want to use for the lookup"
766msgstr "" 603msgstr ""
767 604
768#: plugins/check_dns.c:466
769msgid "" 605msgid ""
770"Optional IP-ADDRESS you expect the DNS server to return. HOST must end with" 606"Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"
771msgstr "" 607msgstr ""
772 608
773#: plugins/check_dns.c:467
774msgid "" 609msgid ""
775"a dot (.). This option can be repeated multiple times (Returns OK if any" 610"with a dot (.). This option can be repeated multiple times (Returns OK if any"
776msgstr "" 611msgstr ""
777 612
778#: plugins/check_dns.c:468 613msgid "value matches)."
779msgid ""
780"value match). If multiple addresses are returned at once, you have to match"
781msgstr "" 614msgstr ""
782 615
783#: plugins/check_dns.c:469
784msgid "" 616msgid ""
785"the whole string of addresses separated with commas (sorted alphabetically)." 617"Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"
618msgstr ""
619
620msgid "Cannot be used together with -a"
786msgstr "" 621msgstr ""
787 622
788#: plugins/check_dns.c:471
789msgid "Optionally expect the DNS server to be authoritative for the lookup" 623msgid "Optionally expect the DNS server to be authoritative for the lookup"
790msgstr "" 624msgstr ""
791 625
792#: plugins/check_dns.c:473
793msgid "Return warning if elapsed time exceeds value. Default off" 626msgid "Return warning if elapsed time exceeds value. Default off"
794msgstr "" 627msgstr ""
795 628
796#: plugins/check_dns.c:475
797msgid "Return critical if elapsed time exceeds value. Default off" 629msgid "Return critical if elapsed time exceeds value. Default off"
798msgstr "" 630msgstr ""
799 631
800#: plugins/check_dummy.c:62 632msgid ""
633"Return critical if the list of expected addresses does not match all "
634"addresses"
635msgstr ""
636
637msgid "returned. Default off"
638msgstr ""
639
801msgid "Arguments to check_dummy must be an integer" 640msgid "Arguments to check_dummy must be an integer"
802msgstr "" 641msgstr ""
803 642
804#: plugins/check_dummy.c:82
805#, c-format 643#, c-format
806msgid "Status %d is not a supported error state\n" 644msgid "Status %d is not a supported error state\n"
807msgstr "" 645msgstr ""
808 646
809#: plugins/check_dummy.c:104
810msgid "" 647msgid ""
811"This plugin will simply return the state corresponding to the numeric value" 648"This plugin will simply return the state corresponding to the numeric value"
812msgstr "" 649msgstr ""
813 650
814#: plugins/check_dummy.c:106
815msgid "of the <state> argument with optional text" 651msgid "of the <state> argument with optional text"
816msgstr "" 652msgstr ""
817 653
818#: plugins/check_fping.c:125 plugins/check_hpjd.c:128 plugins/check_ping.c:438
819#: plugins/check_swap.c:175 plugins/check_users.c:94 plugins/urlize.c:110
820#, c-format 654#, c-format
821msgid "Could not open pipe: %s\n" 655msgid "Could not open pipe: %s\n"
822msgstr "" 656msgstr ""
823 657
824#: plugins/check_fping.c:131 plugins/check_hpjd.c:134 plugins/check_load.c:153
825#: plugins/check_swap.c:181 plugins/check_users.c:100 plugins/urlize.c:116
826#, c-format 658#, c-format
827msgid "Could not open stderr for %s\n" 659msgid "Could not open stderr for %s\n"
828msgstr "" 660msgstr ""
829 661
830#: plugins/check_fping.c:157
831msgid "FPING UNKNOWN - IP address not found\n" 662msgid "FPING UNKNOWN - IP address not found\n"
832msgstr "" 663msgstr ""
833 664
834#: plugins/check_fping.c:160
835msgid "FPING UNKNOWN - invalid commandline argument\n" 665msgid "FPING UNKNOWN - invalid commandline argument\n"
836msgstr "" 666msgstr ""
837 667
838#: plugins/check_fping.c:163
839msgid "FPING UNKNOWN - failed system call\n" 668msgid "FPING UNKNOWN - failed system call\n"
840msgstr "" 669msgstr ""
841 670
842#: plugins/check_fping.c:187
843#, c-format 671#, c-format
844msgid "FPING UNKNOW - %s not found\n" 672msgid "FPING %s - %s (rta=%f ms)|%s\n"
673msgstr ""
674
675#, c-format
676msgid "FPING UNKNOWN - %s not found\n"
845msgstr "" 677msgstr ""
846 678
847#: plugins/check_fping.c:191
848#, c-format 679#, c-format
849msgid "FPING CRITICAL - %s is unreachable\n" 680msgid "FPING CRITICAL - %s is unreachable\n"
850msgstr "" 681msgstr ""
851 682
852#: plugins/check_fping.c:196
853#, c-format 683#, c-format
854msgid "FPING UNKNOWN - %s parameter error\n" 684msgid "FPING UNKNOWN - %s parameter error\n"
855msgstr "" 685msgstr ""
856 686
857#: plugins/check_fping.c:200 plugins/check_fping.c:240
858#, c-format 687#, c-format
859msgid "FPING CRITICAL - %s is down\n" 688msgid "FPING CRITICAL - %s is down\n"
860msgstr "" 689msgstr ""
861 690
862#: plugins/check_fping.c:227
863#, c-format 691#, c-format
864msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n" 692msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"
865msgstr "" 693msgstr ""
866 694
867#: plugins/check_fping.c:253
868#, c-format 695#, c-format
869msgid "FPING %s - %s (loss=%.0f%% )|%s\n" 696msgid "FPING %s - %s (loss=%.0f%% )|%s\n"
870msgstr "" 697msgstr ""
871 698
872#: plugins/check_fping.c:326 plugins/check_fping.c:332
873#: plugins/check_hpjd.c:338 plugins/check_hpjd.c:361 plugins/check_mysql.c:371
874#: plugins/check_mysql.c:455 plugins/check_ntp.c:709
875#: plugins/check_ntp_peer.c:497 plugins/check_ntp_time.c:496
876#: plugins/check_pgsql.c:335 plugins/check_ping.c:295 plugins/check_ping.c:418
877#: plugins/check_radius.c:264 plugins/check_real.c:314
878#: plugins/check_real.c:376 plugins/check_smtp.c:499 plugins/check_smtp.c:641
879#: plugins/check_ssh.c:157 plugins/check_time.c:240 plugins/check_time.c:315
880#: plugins/check_ups.c:504 plugins/check_ups.c:573
881msgid "Invalid hostname/address" 699msgid "Invalid hostname/address"
882msgstr "" 700msgstr ""
883 701
884#: plugins/check_fping.c:345 plugins/check_ldap.c:353 plugins/check_ping.c:246
885msgid "IPv6 support not available\n" 702msgid "IPv6 support not available\n"
886msgstr "" 703msgstr ""
887 704
888#: plugins/check_fping.c:378
889msgid "Packet size must be a positive integer" 705msgid "Packet size must be a positive integer"
890msgstr "" 706msgstr ""
891 707
892#: plugins/check_fping.c:384
893msgid "Packet count must be a positive integer" 708msgid "Packet count must be a positive integer"
894msgstr "" 709msgstr ""
895 710
896#: plugins/check_fping.c:390
897msgid "Target timeout must be a positive integer" 711msgid "Target timeout must be a positive integer"
898msgstr "" 712msgstr ""
899 713
900#: plugins/check_fping.c:396
901msgid "Interval must be a positive integer" 714msgid "Interval must be a positive integer"
902msgstr "" 715msgstr ""
903 716
904#: plugins/check_fping.c:402 plugins/check_ntp.c:733
905#: plugins/check_ntp_peer.c:524 plugins/check_ntp_time.c:523
906#: plugins/check_radius.c:314 plugins/check_time.c:319
907msgid "Hostname was not supplied" 717msgid "Hostname was not supplied"
908msgstr "" 718msgstr ""
909 719
910#: plugins/check_fping.c:422
911#, c-format 720#, c-format
912msgid "%s: Only one threshold may be packet loss (%s)\n" 721msgid "%s: Only one threshold may be packet loss (%s)\n"
913msgstr "" 722msgstr ""
914 723
915#: plugins/check_fping.c:426
916#, c-format 724#, c-format
917msgid "%s: Only one threshold must be packet loss (%s)\n" 725msgid "%s: Only one threshold must be packet loss (%s)\n"
918msgstr "" 726msgstr ""
919 727
920#: plugins/check_fping.c:458
921msgid "" 728msgid ""
922"This plugin will use the fping command to ping the specified host for a fast " 729"This plugin will use the fping command to ping the specified host for a fast "
923"check" 730"check"
924msgstr "" 731msgstr ""
925 732
926#: plugins/check_fping.c:460
927msgid "Note that it is necessary to set the suid flag on fping." 733msgid "Note that it is necessary to set the suid flag on fping."
928msgstr "" 734msgstr ""
929 735
930#: plugins/check_fping.c:472
931msgid "" 736msgid ""
932"name or IP Address of host to ping (IP Address bypasses name lookup, " 737"name or IP Address of host to ping (IP Address bypasses name lookup, "
933"reducing system load)" 738"reducing system load)"
934msgstr "" 739msgstr ""
935 740
936#: plugins/check_fping.c:474 plugins/check_ping.c:575
937msgid "warning threshold pair" 741msgid "warning threshold pair"
938msgstr "" 742msgstr ""
939 743
940#: plugins/check_fping.c:476 plugins/check_ping.c:577
941msgid "critical threshold pair" 744msgid "critical threshold pair"
942msgstr "" 745msgstr ""
943 746
944#: plugins/check_fping.c:478 747msgid "Return OK after first successful reply"
748msgstr ""
749
945msgid "size of ICMP packet" 750msgid "size of ICMP packet"
946msgstr "" 751msgstr ""
947 752
948#: plugins/check_fping.c:480
949msgid "number of ICMP packets to send" 753msgid "number of ICMP packets to send"
950msgstr "" 754msgstr ""
951 755
952#: plugins/check_fping.c:482
953msgid "Target timeout (ms)" 756msgid "Target timeout (ms)"
954msgstr "" 757msgstr ""
955 758
956#: plugins/check_fping.c:484
957msgid "Interval (ms) between sending packets" 759msgid "Interval (ms) between sending packets"
958msgstr "" 760msgstr ""
959 761
960#: plugins/check_fping.c:486
961msgid "name or IP Address of sourceip" 762msgid "name or IP Address of sourceip"
962msgstr "" 763msgstr ""
963 764
964#: plugins/check_fping.c:488
965msgid "source interface name" 765msgid "source interface name"
966msgstr "" 766msgstr ""
967 767
968#: plugins/check_fping.c:491
969#, c-format 768#, c-format
970msgid "" 769msgid ""
971"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time " 770"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time "
972"(ms)" 771"(ms)"
973msgstr "" 772msgstr ""
974 773
975#: plugins/check_fping.c:492
976msgid "" 774msgid ""
977"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of" 775"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of"
978msgstr "" 776msgstr ""
979 777
980#: plugins/check_fping.c:493
981msgid "packet loss to trigger an alarm state." 778msgid "packet loss to trigger an alarm state."
982msgstr "" 779msgstr ""
983 780
984#: plugins/check_fping.c:496
985msgid "IPv4 is used by default. Specify -6 to use IPv6." 781msgid "IPv4 is used by default. Specify -6 to use IPv6."
986msgstr "" 782msgstr ""
987 783
988#: plugins/check_game.c:111
989#, c-format 784#, c-format
990msgid "CRITICAL - Host type parameter incorrect!\n" 785msgid "CRITICAL - Host type parameter incorrect!\n"
991msgstr "" 786msgstr ""
992 787
993#: plugins/check_game.c:126
994#, c-format 788#, c-format
995msgid "CRITICAL - Host not found\n" 789msgid "CRITICAL - Host not found\n"
996msgstr "" 790msgstr ""
997 791
998#: plugins/check_game.c:130
999#, c-format 792#, c-format
1000msgid "CRITICAL - Game server down or unavailable\n" 793msgid "CRITICAL - Game server down or unavailable\n"
1001msgstr "" 794msgstr ""
1002 795
1003#: plugins/check_game.c:134
1004#, c-format 796#, c-format
1005msgid "CRITICAL - Game server timeout\n" 797msgid "CRITICAL - Game server timeout\n"
1006msgstr "" 798msgstr ""
1007 799
1008#: plugins/check_game.c:297
1009#, c-format 800#, c-format
1010msgid "This plugin tests game server connections with the specified host." 801msgid "This plugin tests game server connections with the specified host."
1011msgstr "" 802msgstr ""
1012 803
1013#: plugins/check_game.c:307
1014msgid "Optional port of which to connect" 804msgid "Optional port of which to connect"
1015msgstr "" 805msgstr ""
1016 806
1017#: plugins/check_game.c:309
1018msgid "Field number in raw qstat output that contains game name" 807msgid "Field number in raw qstat output that contains game name"
1019msgstr "" 808msgstr ""
1020 809
1021#: plugins/check_game.c:311
1022msgid "Field number in raw qstat output that contains map name" 810msgid "Field number in raw qstat output that contains map name"
1023msgstr "" 811msgstr ""
1024 812
1025#: plugins/check_game.c:313
1026msgid "Field number in raw qstat output that contains ping time" 813msgid "Field number in raw qstat output that contains ping time"
1027msgstr "" 814msgstr ""
1028 815
1029#: plugins/check_game.c:319
1030msgid "" 816msgid ""
1031"This plugin uses the 'qstat' command, the popular game server status query " 817"This plugin uses the 'qstat' command, the popular game server status query "
1032"tool." 818"tool."
1033msgstr "" 819msgstr ""
1034 820
1035#: plugins/check_game.c:320
1036msgid "" 821msgid ""
1037"If you don't have the package installed, you will need to download it from" 822"If you don't have the package installed, you will need to download it from"
1038msgstr "" 823msgstr ""
1039 824
1040#: plugins/check_game.c:321 825msgid "https://github.com/multiplay/qstat before you can use this plugin."
1041msgid ""
1042"http://www.activesw.com/people/steve/qstat.html before you can use this "
1043"plugin."
1044msgstr "" 826msgstr ""
1045 827
1046#: plugins/check_hpjd.c:239
1047msgid "Paper Jam" 828msgid "Paper Jam"
1048msgstr "" 829msgstr ""
1049 830
1050#: plugins/check_hpjd.c:243
1051msgid "Out of Paper" 831msgid "Out of Paper"
1052msgstr "" 832msgstr ""
1053 833
1054#: plugins/check_hpjd.c:248
1055msgid "Printer Offline" 834msgid "Printer Offline"
1056msgstr "" 835msgstr ""
1057 836
1058#: plugins/check_hpjd.c:253
1059msgid "Peripheral Error" 837msgid "Peripheral Error"
1060msgstr "" 838msgstr ""
1061 839
1062#: plugins/check_hpjd.c:257
1063msgid "Intervention Required" 840msgid "Intervention Required"
1064msgstr "" 841msgstr ""
1065 842
1066#: plugins/check_hpjd.c:261
1067msgid "Toner Low" 843msgid "Toner Low"
1068msgstr "" 844msgstr ""
1069 845
1070#: plugins/check_hpjd.c:265
1071msgid "Insufficient Memory" 846msgid "Insufficient Memory"
1072msgstr "" 847msgstr ""
1073 848
1074#: plugins/check_hpjd.c:269
1075msgid "A Door is Open" 849msgid "A Door is Open"
1076msgstr "" 850msgstr ""
1077 851
1078#: plugins/check_hpjd.c:273
1079msgid "Output Tray is Full" 852msgid "Output Tray is Full"
1080msgstr "" 853msgstr ""
1081 854
1082#: plugins/check_hpjd.c:277
1083msgid "Data too Slow for Engine" 855msgid "Data too Slow for Engine"
1084msgstr "" 856msgstr ""
1085 857
1086#: plugins/check_hpjd.c:281
1087msgid "Unknown Paper Error" 858msgid "Unknown Paper Error"
1088msgstr "" 859msgstr ""
1089 860
1090#: plugins/check_hpjd.c:286
1091#, c-format 861#, c-format
1092msgid "Printer ok - (%s)\n" 862msgid "Printer ok - (%s)\n"
1093msgstr "" 863msgstr ""
1094 864
1095#: plugins/check_hpjd.c:391 865msgid "Port must be a positive short integer"
866msgstr ""
867
1096msgid "This plugin tests the STATUS of an HP printer with a JetDirect card." 868msgid "This plugin tests the STATUS of an HP printer with a JetDirect card."
1097msgstr "" 869msgstr ""
1098 870
1099#: plugins/check_hpjd.c:392
1100msgid "Net-snmp must be installed on the computer running the plugin." 871msgid "Net-snmp must be installed on the computer running the plugin."
1101msgstr "" 872msgstr ""
1102 873
1103#: plugins/check_hpjd.c:402
1104msgid "The SNMP community name " 874msgid "The SNMP community name "
1105msgstr "" 875msgstr ""
1106 876
1107#: plugins/check_hpjd.c:403
1108#, c-format 877#, c-format
1109msgid "(default=%s)" 878msgid "(default=%s)"
1110msgstr "" 879msgstr ""
1111 880
1112#: plugins/check_http.c:189 881msgid "Specify the port to check "
882msgstr ""
883
884msgid "Disable paper check "
885msgstr ""
886
1113msgid "file does not exist or is not readable" 887msgid "file does not exist or is not readable"
1114msgstr "" 888msgstr ""
1115 889
1116#: plugins/check_http.c:310 plugins/check_http.c:315 plugins/check_http.c:321
1117#: plugins/check_smtp.c:600 plugins/check_tcp.c:576 plugins/check_tcp.c:580
1118#: plugins/check_tcp.c:586
1119msgid "Invalid certificate expiration period" 890msgid "Invalid certificate expiration period"
1120msgstr "" 891msgstr ""
1121 892
1122#: plugins/check_http.c:348
1123msgid "" 893msgid ""
1124"Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 " 894"Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional "
1125"(SSLv3)" 895"'+' suffix)"
1126msgstr "" 896msgstr ""
1127 897
1128#: plugins/check_http.c:354 plugins/check_tcp.c:599
1129msgid "Invalid option - SSL is not available" 898msgid "Invalid option - SSL is not available"
1130msgstr "" 899msgstr ""
1131 900
1132#: plugins/check_http.c:375 901msgid "Invalid max_redirs count"
902msgstr ""
903
1133msgid "Invalid onredirect option" 904msgid "Invalid onredirect option"
1134msgstr "" 905msgstr ""
1135 906
1136#: plugins/check_http.c:377
1137#, c-format 907#, c-format
1138msgid "option f:%d \n" 908msgid "option f:%d \n"
1139msgstr "" 909msgstr ""
1140 910
1141#: plugins/check_http.c:398
1142msgid "Invalid port number" 911msgid "Invalid port number"
1143msgstr "" 912msgstr ""
1144 913
1145#: plugins/check_http.c:450
1146#, c-format 914#, c-format
1147msgid "Could Not Compile Regular Expression: %s" 915msgid "Could Not Compile Regular Expression: %s"
1148msgstr "" 916msgstr ""
1149 917
1150#: plugins/check_http.c:464 plugins/check_ntp.c:722
1151#: plugins/check_ntp_peer.c:513 plugins/check_ntp_time.c:512
1152#: plugins/check_smtp.c:621 plugins/check_ssh.c:149 plugins/check_tcp.c:477
1153msgid "IPv6 support not available" 918msgid "IPv6 support not available"
1154msgstr "" 919msgstr ""
1155 920
1156#: plugins/check_http.c:529 plugins/check_ping.c:422
1157msgid "You must specify a server address or host name" 921msgid "You must specify a server address or host name"
1158msgstr "" 922msgstr ""
1159 923
1160#: plugins/check_http.c:543
1161msgid "" 924msgid ""
1162"If you use a client certificate you must also specify a private key file" 925"If you use a client certificate you must also specify a private key file"
1163msgstr "" 926msgstr ""
1164 927
1165#: plugins/check_http.c:667 plugins/check_http.c:835
1166msgid "HTTP UNKNOWN - Memory allocation error\n" 928msgid "HTTP UNKNOWN - Memory allocation error\n"
1167msgstr "" 929msgstr ""
1168 930
1169#: plugins/check_http.c:739
1170#, c-format 931#, c-format
1171msgid "%sServer date unknown, " 932msgid "%sServer date unknown, "
1172msgstr "" 933msgstr ""
1173 934
1174#: plugins/check_http.c:742
1175#, c-format 935#, c-format
1176msgid "%sDocument modification date unknown, " 936msgid "%sDocument modification date unknown, "
1177msgstr "" 937msgstr ""
1178 938
1179#: plugins/check_http.c:749
1180#, c-format 939#, c-format
1181msgid "%sServer date \"%100s\" unparsable, " 940msgid "%sServer date \"%100s\" unparsable, "
1182msgstr "" 941msgstr ""
1183 942
1184#: plugins/check_http.c:752
1185#, c-format 943#, c-format
1186msgid "%sDocument date \"%100s\" unparsable, " 944msgid "%sDocument date \"%100s\" unparsable, "
1187msgstr "" 945msgstr ""
1188 946
1189#: plugins/check_http.c:755
1190#, c-format 947#, c-format
1191msgid "%sDocument is %d seconds in the future, " 948msgid "%sDocument is %d seconds in the future, "
1192msgstr "" 949msgstr ""
1193 950
1194#: plugins/check_http.c:760
1195#, c-format 951#, c-format
1196msgid "%sLast modified %.1f days ago, " 952msgid "%sLast modified %.1f days ago, "
1197msgstr "" 953msgstr ""
1198 954
1199#: plugins/check_http.c:763
1200#, c-format 955#, c-format
1201msgid "%sLast modified %d:%02d:%02d ago, " 956msgid "%sLast modified %d:%02d:%02d ago, "
1202msgstr "" 957msgstr ""
1203 958
1204#: plugins/check_http.c:876
1205msgid "HTTP CRITICAL - Unable to open TCP socket\n" 959msgid "HTTP CRITICAL - Unable to open TCP socket\n"
1206msgstr "" 960msgstr ""
1207 961
1208#: plugins/check_http.c:995 962msgid "HTTP UNKNOWN - Could not allocate memory for full_page\n"
963msgstr ""
964
1209msgid "HTTP CRITICAL - Error on receive\n" 965msgid "HTTP CRITICAL - Error on receive\n"
1210msgstr "" 966msgstr ""
1211 967
1212#: plugins/check_http.c:1005
1213msgid "HTTP CRITICAL - No data received from host\n" 968msgid "HTTP CRITICAL - No data received from host\n"
1214msgstr "" 969msgstr ""
1215 970
1216#: plugins/check_http.c:1056
1217#, c-format 971#, c-format
1218msgid "Invalid HTTP response received from host: %s\n" 972msgid "Invalid HTTP response received from host: %s\n"
1219msgstr "" 973msgstr ""
1220 974
1221#: plugins/check_http.c:1060
1222#, c-format 975#, c-format
1223msgid "Invalid HTTP response received from host on port %d: %s\n" 976msgid "Invalid HTTP response received from host on port %d: %s\n"
1224msgstr "" 977msgstr ""
1225 978
1226#: plugins/check_http.c:1069 979#, c-format
980msgid ""
981"%s\n"
982"%s"
983msgstr ""
984
1227#, c-format 985#, c-format
1228msgid "Status line output matched \"%s\" - " 986msgid "Status line output matched \"%s\" - "
1229msgstr "" 987msgstr ""
1230 988
1231#: plugins/check_http.c:1080
1232#, c-format 989#, c-format
1233msgid "HTTP CRITICAL: Invalid Status Line (%s)\n" 990msgid "HTTP CRITICAL: Invalid Status Line (%s)\n"
1234msgstr "" 991msgstr ""
1235 992
1236#: plugins/check_http.c:1087
1237#, c-format 993#, c-format
1238msgid "HTTP CRITICAL: Invalid Status (%s)\n" 994msgid "HTTP CRITICAL: Invalid Status (%s)\n"
1239msgstr "" 995msgstr ""
1240 996
1241#: plugins/check_http.c:1091 plugins/check_http.c:1096
1242#: plugins/check_http.c:1106 plugins/check_http.c:1110
1243#, c-format 997#, c-format
1244msgid "%s - " 998msgid "%s - "
1245msgstr "" 999msgstr ""
1246 1000
1247#: plugins/check_http.c:1129
1248#, c-format 1001#, c-format
1249msgid "%sheader '%s' not found on '%s://%s:%d%s', " 1002msgid "%sheader '%s' not found on '%s://%s:%d%s', "
1250msgstr "" 1003msgstr ""
1251 1004
1252#: plugins/check_http.c:1141
1253#, c-format 1005#, c-format
1254msgid "%sstring '%s' not found on '%s://%s:%d%s', " 1006msgid "%sstring '%s' not found on '%s://%s:%d%s', "
1255msgstr "" 1007msgstr ""
1256 1008
1257#: plugins/check_http.c:1154
1258#, c-format 1009#, c-format
1259msgid "%spattern not found, " 1010msgid "%spattern not found, "
1260msgstr "" 1011msgstr ""
1261 1012
1262#: plugins/check_http.c:1156
1263#, c-format 1013#, c-format
1264msgid "%spattern found, " 1014msgid "%spattern found, "
1265msgstr "" 1015msgstr ""
1266 1016
1267#: plugins/check_http.c:1162
1268#, c-format 1017#, c-format
1269msgid "%sExecute Error: %s, " 1018msgid "%sExecute Error: %s, "
1270msgstr "" 1019msgstr ""
1271 1020
1272#: plugins/check_http.c:1178
1273#, c-format 1021#, c-format
1274msgid "%spage size %d too large, " 1022msgid "%spage size %d too large, "
1275msgstr "" 1023msgstr ""
1276 1024
1277#: plugins/check_http.c:1181
1278#, c-format 1025#, c-format
1279msgid "%spage size %d too small, " 1026msgid "%spage size %d too small, "
1280msgstr "" 1027msgstr ""
1281 1028
1282#: plugins/check_http.c:1194
1283#, c-format 1029#, c-format
1284msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s" 1030msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"
1285msgstr "" 1031msgstr ""
1286 1032
1287#: plugins/check_http.c:1206
1288#, c-format 1033#, c-format
1289msgid "%s - %d bytes in %.3f second response time %s|%s %s" 1034msgid "%s - %d bytes in %.3f second response time %s|%s %s"
1290msgstr "" 1035msgstr ""
1291 1036
1292#: plugins/check_http.c:1244
1293msgid "HTTP UNKNOWN - Could not allocate addr\n" 1037msgid "HTTP UNKNOWN - Could not allocate addr\n"
1294msgstr "" 1038msgstr ""
1295 1039
1296#: plugins/check_http.c:1248 plugins/check_http.c:1279
1297msgid "HTTP UNKNOWN - Could not allocate URL\n" 1040msgid "HTTP UNKNOWN - Could not allocate URL\n"
1298msgstr "" 1041msgstr ""
1299 1042
1300#: plugins/check_http.c:1257
1301#, c-format 1043#, c-format
1302msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n" 1044msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n"
1303msgstr "" 1045msgstr ""
1304 1046
1305#: plugins/check_http.c:1272
1306#, c-format 1047#, c-format
1307msgid "HTTP UNKNOWN - Empty redirect location%s\n" 1048msgid "HTTP UNKNOWN - Empty redirect location%s\n"
1308msgstr "" 1049msgstr ""
1309 1050
1310#: plugins/check_http.c:1322
1311#, c-format 1051#, c-format
1312msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n" 1052msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n"
1313msgstr "" 1053msgstr ""
1314 1054
1315#: plugins/check_http.c:1332
1316#, c-format 1055#, c-format
1317msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n" 1056msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n"
1318msgstr "" 1057msgstr ""
1319 1058
1320#: plugins/check_http.c:1340
1321#, c-format 1059#, c-format
1322msgid "HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n" 1060msgid "HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1323msgstr "" 1061msgstr ""
1324 1062
1325#: plugins/check_http.c:1361
1326#, c-format 1063#, c-format
1327msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n" 1064msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"
1328msgstr "" 1065msgstr ""
1329 1066
1330#: plugins/check_http.c:1366
1331#, c-format 1067#, c-format
1332msgid "Redirection to %s://%s:%d%s\n" 1068msgid "Redirection to %s://%s:%d%s\n"
1333msgstr "" 1069msgstr ""
1334 1070
1335#: plugins/check_http.c:1440
1336msgid "This plugin tests the HTTP service on the specified host. It can test" 1071msgid "This plugin tests the HTTP service on the specified host. It can test"
1337msgstr "" 1072msgstr ""
1338 1073
1339#: plugins/check_http.c:1441
1340msgid "normal (http) and secure (https) servers, follow redirects, search for" 1074msgid "normal (http) and secure (https) servers, follow redirects, search for"
1341msgstr "" 1075msgstr ""
1342 1076
1343#: plugins/check_http.c:1442
1344msgid "strings and regular expressions, check connection times, and report on" 1077msgid "strings and regular expressions, check connection times, and report on"
1345msgstr "" 1078msgstr ""
1346 1079
1347#: plugins/check_http.c:1443
1348msgid "certificate expiration times." 1080msgid "certificate expiration times."
1349msgstr "" 1081msgstr ""
1350 1082
1351#: plugins/check_http.c:1449 1083#, c-format
1084msgid "In the first form, make an HTTP request."
1085msgstr ""
1086
1087#, c-format
1088msgid ""
1089"In the second form, connect to the server and check the TLS certificate."
1090msgstr ""
1091
1352#, c-format 1092#, c-format
1353msgid "NOTE: One or both of -H and -I must be specified" 1093msgid "NOTE: One or both of -H and -I must be specified"
1354msgstr "" 1094msgstr ""
1355 1095
1356#: plugins/check_http.c:1457
1357msgid "Host name argument for servers using host headers (virtual host)" 1096msgid "Host name argument for servers using host headers (virtual host)"
1358msgstr "" 1097msgstr ""
1359 1098
1360#: plugins/check_http.c:1458
1361msgid "Append a port to include it in the header (eg: example.com:5000)" 1099msgid "Append a port to include it in the header (eg: example.com:5000)"
1362msgstr "" 1100msgstr ""
1363 1101
1364#: plugins/check_http.c:1460
1365msgid "" 1102msgid ""
1366"IP address or name (use numeric address if possible to bypass DNS lookup)." 1103"IP address or name (use numeric address if possible to bypass DNS lookup)."
1367msgstr "" 1104msgstr ""
1368 1105
1369#: plugins/check_http.c:1462
1370msgid "Port number (default: " 1106msgid "Port number (default: "
1371msgstr "" 1107msgstr ""
1372 1108
1373#: plugins/check_http.c:1469
1374msgid "" 1109msgid ""
1375"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents" 1110"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"
1376msgstr "" 1111msgstr ""
1377 1112
1378#: plugins/check_http.c:1470 1113msgid "auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"
1379msgid "auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3)." 1114msgstr ""
1115
1116msgid "1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted."
1380msgstr "" 1117msgstr ""
1381 1118
1382#: plugins/check_http.c:1472
1383msgid "Enable SSL/TLS hostname extension support (SNI)" 1119msgid "Enable SSL/TLS hostname extension support (SNI)"
1384msgstr "" 1120msgstr ""
1385 1121
1386#: plugins/check_http.c:1474
1387msgid "" 1122msgid ""
1388"Minimum number of days a certificate has to be valid. Port defaults to 443" 1123"Minimum number of days a certificate has to be valid. Port defaults to 443"
1389msgstr "" 1124msgstr ""
1390 1125
1391#: plugins/check_http.c:1475 1126msgid ""
1392msgid "(when this option is used the URL is not checked.)" 1127"(when this option is used the URL is not checked by default. You can use"
1128msgstr ""
1129
1130msgid " --continue-after-certificate to override this behavior)"
1131msgstr ""
1132
1133msgid ""
1134"Allows the HTTP check to continue after performing the certificate check."
1135msgstr ""
1136
1137msgid "Does nothing unless -C is used."
1393msgstr "" 1138msgstr ""
1394 1139
1395#: plugins/check_http.c:1477
1396msgid "Name of file that contains the client certificate (PEM format)" 1140msgid "Name of file that contains the client certificate (PEM format)"
1397msgstr "" 1141msgstr ""
1398 1142
1399#: plugins/check_http.c:1478
1400msgid "to be used in establishing the SSL session" 1143msgid "to be used in establishing the SSL session"
1401msgstr "" 1144msgstr ""
1402 1145
1403#: plugins/check_http.c:1480
1404msgid "Name of file containing the private key (PEM format)" 1146msgid "Name of file containing the private key (PEM format)"
1405msgstr "" 1147msgstr ""
1406 1148
1407#: plugins/check_http.c:1481
1408msgid "matching the client certificate" 1149msgid "matching the client certificate"
1409msgstr "" 1150msgstr ""
1410 1151
1411#: plugins/check_http.c:1485
1412msgid "Comma-delimited list of strings, at least one of them is expected in" 1152msgid "Comma-delimited list of strings, at least one of them is expected in"
1413msgstr "" 1153msgstr ""
1414 1154
1415#: plugins/check_http.c:1486
1416msgid "the first (status) line of the server response (default: " 1155msgid "the first (status) line of the server response (default: "
1417msgstr "" 1156msgstr ""
1418 1157
1419#: plugins/check_http.c:1488
1420msgid "" 1158msgid ""
1421"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)" 1159"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"
1422msgstr "" 1160msgstr ""
1423 1161
1424#: plugins/check_http.c:1490
1425msgid "String to expect in the response headers" 1162msgid "String to expect in the response headers"
1426msgstr "" 1163msgstr ""
1427 1164
1428#: plugins/check_http.c:1492
1429msgid "String to expect in the content" 1165msgid "String to expect in the content"
1430msgstr "" 1166msgstr ""
1431 1167
1432#: plugins/check_http.c:1494
1433msgid "URL to GET or POST (default: /)" 1168msgid "URL to GET or POST (default: /)"
1434msgstr "" 1169msgstr ""
1435 1170
1436#: plugins/check_http.c:1496
1437msgid "URL encoded http POST data" 1171msgid "URL encoded http POST data"
1438msgstr "" 1172msgstr ""
1439 1173
1440#: plugins/check_http.c:1498
1441msgid "Set HTTP method." 1174msgid "Set HTTP method."
1442msgstr "" 1175msgstr ""
1443 1176
1444#: plugins/check_http.c:1500
1445msgid "Don't wait for document body: stop reading after headers." 1177msgid "Don't wait for document body: stop reading after headers."
1446msgstr "" 1178msgstr ""
1447 1179
1448#: plugins/check_http.c:1501
1449msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)" 1180msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)"
1450msgstr "" 1181msgstr ""
1451 1182
1452#: plugins/check_http.c:1503
1453msgid "Warn if document is more than SECONDS old. the number can also be of" 1183msgid "Warn if document is more than SECONDS old. the number can also be of"
1454msgstr "" 1184msgstr ""
1455 1185
1456#: plugins/check_http.c:1504
1457msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days." 1186msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."
1458msgstr "" 1187msgstr ""
1459 1188
1460#: plugins/check_http.c:1506
1461msgid "specify Content-Type header media type when POSTing\n" 1189msgid "specify Content-Type header media type when POSTing\n"
1462msgstr "" 1190msgstr ""
1463 1191
1464#: plugins/check_http.c:1509
1465msgid "Allow regex to span newlines (must precede -r or -R)" 1192msgid "Allow regex to span newlines (must precede -r or -R)"
1466msgstr "" 1193msgstr ""
1467 1194
1468#: plugins/check_http.c:1511
1469msgid "Search page for regex STRING" 1195msgid "Search page for regex STRING"
1470msgstr "" 1196msgstr ""
1471 1197
1472#: plugins/check_http.c:1513
1473msgid "Search page for case-insensitive regex STRING" 1198msgid "Search page for case-insensitive regex STRING"
1474msgstr "" 1199msgstr ""
1475 1200
1476#: plugins/check_http.c:1515
1477msgid "Return CRITICAL if found, OK if not\n" 1201msgid "Return CRITICAL if found, OK if not\n"
1478msgstr "" 1202msgstr ""
1479 1203
1480#: plugins/check_http.c:1518
1481msgid "Username:password on sites with basic authentication" 1204msgid "Username:password on sites with basic authentication"
1482msgstr "" 1205msgstr ""
1483 1206
1484#: plugins/check_http.c:1520
1485msgid "Username:password on proxy-servers with basic authentication" 1207msgid "Username:password on proxy-servers with basic authentication"
1486msgstr "" 1208msgstr ""
1487 1209
1488#: plugins/check_http.c:1522
1489msgid "String to be sent in http header as \"User Agent\"" 1210msgid "String to be sent in http header as \"User Agent\""
1490msgstr "" 1211msgstr ""
1491 1212
1492#: plugins/check_http.c:1524
1493msgid "" 1213msgid ""
1494"Any other tags to be sent in http header. Use multiple times for additional " 1214"Any other tags to be sent in http header. Use multiple times for additional "
1495"headers" 1215"headers"
1496msgstr "" 1216msgstr ""
1497 1217
1498#: plugins/check_http.c:1526
1499msgid "Print additional performance data" 1218msgid "Print additional performance data"
1500msgstr "" 1219msgstr ""
1501 1220
1502#: plugins/check_http.c:1528 1221msgid "Print body content below status line"
1222msgstr ""
1223
1503msgid "Wrap output in HTML link (obsoleted by urlize)" 1224msgid "Wrap output in HTML link (obsoleted by urlize)"
1504msgstr "" 1225msgstr ""
1505 1226
1506#: plugins/check_http.c:1530
1507msgid "How to handle redirected pages. sticky is like follow but stick to the" 1227msgid "How to handle redirected pages. sticky is like follow but stick to the"
1508msgstr "" 1228msgstr ""
1509 1229
1510#: plugins/check_http.c:1531
1511msgid "specified IP address. stickyport also ensures port stays the same." 1230msgid "specified IP address. stickyport also ensures port stays the same."
1512msgstr "" 1231msgstr ""
1513 1232
1514#: plugins/check_http.c:1533 1233msgid "Maximal number of redirects (default: "
1234msgstr ""
1235
1515msgid "Minimum page size required (bytes) : Maximum page size required (bytes)" 1236msgid "Minimum page size required (bytes) : Maximum page size required (bytes)"
1516msgstr "" 1237msgstr ""
1517 1238
1518#: plugins/check_http.c:1543
1519msgid "This plugin will attempt to open an HTTP connection with the host." 1239msgid "This plugin will attempt to open an HTTP connection with the host."
1520msgstr "" 1240msgstr ""
1521 1241
1522#: plugins/check_http.c:1544
1523msgid "" 1242msgid ""
1524"Successful connects return STATE_OK, refusals and timeouts return " 1243"Successful connects return STATE_OK, refusals and timeouts return "
1525"STATE_CRITICAL" 1244"STATE_CRITICAL"
1526msgstr "" 1245msgstr ""
1527 1246
1528#: plugins/check_http.c:1545
1529msgid "" 1247msgid ""
1530"other errors return STATE_UNKNOWN. Successful connects, but incorrect " 1248"other errors return STATE_UNKNOWN. Successful connects, but incorrect "
1531"reponse" 1249"response"
1532msgstr "" 1250msgstr ""
1533 1251
1534#: plugins/check_http.c:1546
1535msgid "" 1252msgid ""
1536"messages from the host result in STATE_WARNING return values. If you are" 1253"messages from the host result in STATE_WARNING return values. If you are"
1537msgstr "" 1254msgstr ""
1538 1255
1539#: plugins/check_http.c:1547
1540msgid "" 1256msgid ""
1541"checking a virtual server that uses 'host headers' you must supply the FQDN" 1257"checking a virtual server that uses 'host headers' you must supply the FQDN"
1542msgstr "" 1258msgstr ""
1543 1259
1544#: plugins/check_http.c:1548
1545msgid "(fully qualified domain name) as the [host_name] argument." 1260msgid "(fully qualified domain name) as the [host_name] argument."
1546msgstr "" 1261msgstr ""
1547 1262
1548#: plugins/check_http.c:1552
1549msgid "This plugin can also check whether an SSL enabled web server is able to" 1263msgid "This plugin can also check whether an SSL enabled web server is able to"
1550msgstr "" 1264msgstr ""
1551 1265
1552#: plugins/check_http.c:1553
1553msgid "serve content (optionally within a specified time) or whether the X509 " 1266msgid "serve content (optionally within a specified time) or whether the X509 "
1554msgstr "" 1267msgstr ""
1555 1268
1556#: plugins/check_http.c:1554
1557msgid "certificate is still valid for the specified number of days." 1269msgid "certificate is still valid for the specified number of days."
1558msgstr "" 1270msgstr ""
1559 1271
1560#: plugins/check_http.c:1556
1561msgid "Please note that this plugin does not check if the presented server" 1272msgid "Please note that this plugin does not check if the presented server"
1562msgstr "" 1273msgstr ""
1563 1274
1564#: plugins/check_http.c:1557
1565msgid "certificate matches the hostname of the server, or if the certificate" 1275msgid "certificate matches the hostname of the server, or if the certificate"
1566msgstr "" 1276msgstr ""
1567 1277
1568#: plugins/check_http.c:1558
1569msgid "has a valid chain of trust to one of the locally installed CAs." 1278msgid "has a valid chain of trust to one of the locally installed CAs."
1570msgstr "" 1279msgstr ""
1571 1280
1572#: plugins/check_http.c:1562
1573msgid "" 1281msgid ""
1574"When the 'www.verisign.com' server returns its content within 5 seconds," 1282"When the 'www.verisign.com' server returns its content within 5 seconds,"
1575msgstr "" 1283msgstr ""
1576 1284
1577#: plugins/check_http.c:1563
1578msgid "" 1285msgid ""
1579"a STATE_OK will be returned. When the server returns its content but exceeds" 1286"a STATE_OK will be returned. When the server returns its content but exceeds"
1580msgstr "" 1287msgstr ""
1581 1288
1582#: plugins/check_http.c:1564
1583msgid "" 1289msgid ""
1584"the 5-second threshold, a STATE_WARNING will be returned. When an error " 1290"the 5-second threshold, a STATE_WARNING will be returned. When an error "
1585"occurs," 1291"occurs,"
1586msgstr "" 1292msgstr ""
1587 1293
1588#: plugins/check_http.c:1565
1589msgid "a STATE_CRITICAL will be returned." 1294msgid "a STATE_CRITICAL will be returned."
1590msgstr "" 1295msgstr ""
1591 1296
1592#: plugins/check_http.c:1568
1593msgid "" 1297msgid ""
1594"When the certificate of 'www.verisign.com' is valid for more than 14 days," 1298"When the certificate of 'www.verisign.com' is valid for more than 14 days,"
1595msgstr "" 1299msgstr ""
1596 1300
1597#: plugins/check_http.c:1569 plugins/check_http.c:1575
1598msgid "" 1301msgid ""
1599"a STATE_OK is returned. When the certificate is still valid, but for less " 1302"a STATE_OK is returned. When the certificate is still valid, but for less "
1600"than" 1303"than"
1601msgstr "" 1304msgstr ""
1602 1305
1603#: plugins/check_http.c:1570
1604msgid "" 1306msgid ""
1605"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when" 1307"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"
1606msgstr "" 1308msgstr ""
1607 1309
1608#: plugins/check_http.c:1571
1609msgid "the certificate is expired." 1310msgid "the certificate is expired."
1610msgstr "" 1311msgstr ""
1611 1312
1612#: plugins/check_http.c:1574
1613msgid "" 1313msgid ""
1614"When the certificate of 'www.verisign.com' is valid for more than 30 days," 1314"When the certificate of 'www.verisign.com' is valid for more than 30 days,"
1615msgstr "" 1315msgstr ""
1616 1316
1617#: plugins/check_http.c:1576
1618msgid "30 days, but more than 14 days, a STATE_WARNING is returned." 1317msgid "30 days, but more than 14 days, a STATE_WARNING is returned."
1619msgstr "" 1318msgstr ""
1620 1319
1621#: plugins/check_http.c:1577
1622msgid "" 1320msgid ""
1623"A STATE_CRITICAL will be returned when certificate expires in less than 14 " 1321"A STATE_CRITICAL will be returned when certificate expires in less than 14 "
1624"days" 1322"days"
1625msgstr "" 1323msgstr ""
1626 1324
1627#: plugins/check_ldap.c:133 1325msgid ""
1326"check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j "
1327"CONNECT -H www.verisign.com "
1328msgstr ""
1329
1330msgid ""
1331"all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -"
1332"S(sl) -j CONNECT -H <webserver>"
1333msgstr ""
1334
1335msgid ""
1336"a STATE_CRITICAL will be returned. By adding a colon to the method you can "
1337"set the method used"
1338msgstr ""
1339
1340msgid "inside the proxied connection: -j CONNECT:POST"
1341msgstr ""
1342
1628#, c-format 1343#, c-format
1629msgid "Could not connect to the server at port %i\n" 1344msgid "Could not connect to the server at port %i\n"
1630msgstr "" 1345msgstr ""
1631 1346
1632#: plugins/check_ldap.c:142
1633#, c-format 1347#, c-format
1634msgid "Could not set protocol version %d\n" 1348msgid "Could not set protocol version %d\n"
1635msgstr "" 1349msgstr ""
1636 1350
1637#: plugins/check_ldap.c:157
1638#, c-format 1351#, c-format
1639msgid "Could not init TLS at port %i!\n" 1352msgid "Could not init TLS at port %i!\n"
1640msgstr "" 1353msgstr ""
1641 1354
1642#: plugins/check_ldap.c:161
1643#, c-format 1355#, c-format
1644msgid "TLS not supported by the libraries!\n" 1356msgid "TLS not supported by the libraries!\n"
1645msgstr "" 1357msgstr ""
1646 1358
1647#: plugins/check_ldap.c:181
1648#, c-format 1359#, c-format
1649msgid "Could not init startTLS at port %i!\n" 1360msgid "Could not init startTLS at port %i!\n"
1650msgstr "" 1361msgstr ""
1651 1362
1652#: plugins/check_ldap.c:185
1653#, c-format 1363#, c-format
1654msgid "startTLS not supported by the library, needs LDAPv3!\n" 1364msgid "startTLS not supported by the library, needs LDAPv3!\n"
1655msgstr "" 1365msgstr ""
1656 1366
1657#: plugins/check_ldap.c:195
1658#, c-format 1367#, c-format
1659msgid "Could not bind to the LDAP server\n" 1368msgid "Could not bind to the LDAP server\n"
1660msgstr "" 1369msgstr ""
1661 1370
1662#: plugins/check_ldap.c:204
1663#, c-format 1371#, c-format
1664msgid "Could not search/find objectclasses in %s\n" 1372msgid "Could not search/find objectclasses in %s\n"
1665msgstr "" 1373msgstr ""
1666 1374
1667#: plugins/check_ldap.c:227 1375#, c-format
1376msgid "LDAP %s - found %d entries in %.3f seconds|%s %s\n"
1377msgstr ""
1378
1668#, c-format 1379#, c-format
1669msgid "LDAP %s - %.3f seconds response time|%s\n" 1380msgid "LDAP %s - %.3f seconds response time|%s\n"
1670msgstr "" 1381msgstr ""
1671 1382
1672#: plugins/check_ldap.c:339 plugins/check_ldap.c:347
1673#, c-format 1383#, c-format
1674msgid "%s cannot be combined with %s" 1384msgid "%s cannot be combined with %s"
1675msgstr "" 1385msgstr ""
1676 1386
1677#: plugins/check_ldap.c:379
1678msgid "Please specify the host name\n" 1387msgid "Please specify the host name\n"
1679msgstr "" 1388msgstr ""
1680 1389
1681#: plugins/check_ldap.c:382
1682msgid "Please specify the LDAP base\n" 1390msgid "Please specify the LDAP base\n"
1683msgstr "" 1391msgstr ""
1684 1392
1685#: plugins/check_ldap.c:411
1686msgid "ldap attribute to search (default: \"(objectclass=*)\"" 1393msgid "ldap attribute to search (default: \"(objectclass=*)\""
1687msgstr "" 1394msgstr ""
1688 1395
1689#: plugins/check_ldap.c:413
1690msgid "ldap base (eg. ou=my unit, o=my org, c=at" 1396msgid "ldap base (eg. ou=my unit, o=my org, c=at"
1691msgstr "" 1397msgstr ""
1692 1398
1693#: plugins/check_ldap.c:415
1694msgid "ldap bind DN (if required)" 1399msgid "ldap bind DN (if required)"
1695msgstr "" 1400msgstr ""
1696 1401
1697#: plugins/check_ldap.c:417 1402msgid ""
1698msgid "ldap password (if required)" 1403"ldap password (if required, or set the password through environment variable "
1404"'LDAP_PASSWORD')"
1699msgstr "" 1405msgstr ""
1700 1406
1701#: plugins/check_ldap.c:419
1702msgid "use starttls mechanism introduced in protocol version 3" 1407msgid "use starttls mechanism introduced in protocol version 3"
1703msgstr "" 1408msgstr ""
1704 1409
1705#: plugins/check_ldap.c:421
1706msgid "use ldaps (ldap v2 ssl method). this also sets the default port to" 1410msgid "use ldaps (ldap v2 ssl method). this also sets the default port to"
1707msgstr "" 1411msgstr ""
1708 1412
1709#: plugins/check_ldap.c:425
1710msgid "use ldap protocol version 2" 1413msgid "use ldap protocol version 2"
1711msgstr "" 1414msgstr ""
1712 1415
1713#: plugins/check_ldap.c:427
1714msgid "use ldap protocol version 3" 1416msgid "use ldap protocol version 3"
1715msgstr "" 1417msgstr ""
1716 1418
1717#: plugins/check_ldap.c:428
1718msgid "default protocol version:" 1419msgid "default protocol version:"
1719msgstr "" 1420msgstr ""
1720 1421
1721#: plugins/check_ldap.c:439 1422msgid "Number of found entries to result in warning status"
1423msgstr ""
1424
1425msgid "Number of found entries to result in critical status"
1426msgstr ""
1427
1722msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be" 1428msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be"
1723msgstr "" 1429msgstr ""
1724 1430
1725#: plugins/check_ldap.c:440
1726#, c-format 1431#, c-format
1727msgid "" 1432msgid ""
1728" implied (using default port %i) unless --port=636 is specified. In that " 1433" implied (using default port %i) unless --port=636 is specified. In that "
1729"case\n" 1434"case\n"
1730msgstr "" 1435msgstr ""
1731 1436
1732#: plugins/check_ldap.c:441
1733msgid "'SSL on connect' will be used no matter how the plugin was called." 1437msgid "'SSL on connect' will be used no matter how the plugin was called."
1734msgstr "" 1438msgstr ""
1735 1439
1736#: plugins/check_ldap.c:442
1737msgid "" 1440msgid ""
1738"This detection is deprecated, please use 'check_ldap' with the '--starttls' " 1441"This detection is deprecated, please use 'check_ldap' with the '--starttls' "
1739"or '--ssl' flags" 1442"or '--ssl' flags"
1740msgstr "" 1443msgstr ""
1741 1444
1742#: plugins/check_ldap.c:443
1743msgid "to define the behaviour explicitly instead." 1445msgid "to define the behaviour explicitly instead."
1744msgstr "" 1446msgstr ""
1745 1447
1746#: plugins/check_load.c:87 1448msgid "The parameters --warn-entries and --crit-entries are optional."
1449msgstr ""
1450
1747msgid "Warning threshold must be float or float triplet!\n" 1451msgid "Warning threshold must be float or float triplet!\n"
1748msgstr "" 1452msgstr ""
1749 1453
1750#: plugins/check_load.c:132 plugins/check_load.c:148
1751#, c-format 1454#, c-format
1752msgid "Error opening %s\n" 1455msgid "Error opening %s\n"
1753msgstr "" 1456msgstr ""
1754 1457
1755#: plugins/check_load.c:163
1756#, c-format 1458#, c-format
1757msgid "could not parse load from uptime: %s\n" 1459msgid "could not parse load from uptime %s: %d\n"
1758msgstr "" 1460msgstr ""
1759 1461
1760#: plugins/check_load.c:169
1761#, c-format 1462#, c-format
1762msgid "Error code %d returned in %s\n" 1463msgid "Error code %d returned in %s\n"
1763msgstr "" 1464msgstr ""
1764 1465
1765#: plugins/check_load.c:184
1766#, c-format 1466#, c-format
1767msgid "Error in getloadavg()\n" 1467msgid "Error in getloadavg()\n"
1768msgstr "" 1468msgstr ""
1769 1469
1770#: plugins/check_load.c:187 plugins/check_load.c:189
1771#, c-format 1470#, c-format
1772msgid "Error processing %s\n" 1471msgid "Error processing %s\n"
1773msgstr "" 1472msgstr ""
1774 1473
1775#: plugins/check_load.c:198
1776#, c-format 1474#, c-format
1777msgid "load average: %.2f, %.2f, %.2f" 1475msgid "load average: %.2f, %.2f, %.2f"
1778msgstr "" 1476msgstr ""
1779 1477
1780#: plugins/check_load.c:291
1781#, c-format 1478#, c-format
1782msgid "Critical threshold for %d-minute load average is not specified\n" 1479msgid "Critical threshold for %d-minute load average is not specified\n"
1783msgstr "" 1480msgstr ""
1784 1481
1785#: plugins/check_load.c:293
1786#, c-format 1482#, c-format
1787msgid "Warning threshold for %d-minute load average is not specified\n" 1483msgid "Warning threshold for %d-minute load average is not specified\n"
1788msgstr "" 1484msgstr ""
1789 1485
1790#: plugins/check_load.c:295
1791#, c-format 1486#, c-format
1792msgid "" 1487msgid ""
1793"Parameter inconsistency: %d-minute \"warning load\" is greater than " 1488"Parameter inconsistency: %d-minute \"warning load\" is greater than "
1794"\"critical load\"\n" 1489"\"critical load\"\n"
1795msgstr "" 1490msgstr ""
1796 1491
1797#: plugins/check_load.c:311
1798#, c-format 1492#, c-format
1799msgid "This plugin tests the current system load average." 1493msgid "This plugin tests the current system load average."
1800msgstr "" 1494msgstr ""
1801 1495
1802#: plugins/check_load.c:321
1803msgid "Exit with WARNING status if load average exceeds WLOADn" 1496msgid "Exit with WARNING status if load average exceeds WLOADn"
1804msgstr "" 1497msgstr ""
1805 1498
1806#: plugins/check_load.c:323
1807msgid "Exit with CRITICAL status if load average exceed CLOADn" 1499msgid "Exit with CRITICAL status if load average exceed CLOADn"
1808msgstr "" 1500msgstr ""
1809 1501
1810#: plugins/check_load.c:324
1811msgid "the load average format is the same used by \"uptime\" and \"w\"" 1502msgid "the load average format is the same used by \"uptime\" and \"w\""
1812msgstr "" 1503msgstr ""
1813 1504
1814#: plugins/check_load.c:326
1815msgid "Divide the load averages by the number of CPUs (when possible)" 1505msgid "Divide the load averages by the number of CPUs (when possible)"
1816msgstr "" 1506msgstr ""
1817 1507
1818#: plugins/check_mrtg.c:75 1508msgid "Number of processes to show when printing the top consuming processes."
1509msgstr ""
1510
1511msgid "NUMBER_OF_PROCS=0 disables this feature. Default value is 0"
1512msgstr ""
1513
1514#, c-format
1515msgid "'%s' exited with non-zero status.\n"
1516msgstr ""
1517
1518#, c-format
1519msgid "some error occurred getting procs list.\n"
1520msgstr ""
1521
1819msgid "Could not parse arguments\n" 1522msgid "Could not parse arguments\n"
1820msgstr "" 1523msgstr ""
1821 1524
1822#: plugins/check_mrtg.c:80
1823#, c-format 1525#, c-format
1824msgid "Unable to open MRTG log file\n" 1526msgid "Unable to open MRTG log file\n"
1825msgstr "" 1527msgstr ""
1826 1528
1827#: plugins/check_mrtg.c:127
1828#, c-format 1529#, c-format
1829msgid "Unable to process MRTG log file\n" 1530msgid "Unable to process MRTG log file\n"
1830msgstr "" 1531msgstr ""
1831 1532
1832#: plugins/check_mrtg.c:135 plugins/check_mrtgtraf.c:136
1833#, c-format 1533#, c-format
1834msgid "MRTG data has expired (%d minutes old)\n" 1534msgid "MRTG data has expired (%d minutes old)\n"
1835msgstr "" 1535msgstr ""
1836 1536
1837#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1838#: plugins/check_mrtgtraf.c:196
1839msgid "Avg" 1537msgid "Avg"
1840msgstr "" 1538msgstr ""
1841 1539
1842#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1843#: plugins/check_mrtgtraf.c:196
1844msgid "Max" 1540msgid "Max"
1845msgstr "" 1541msgstr ""
1846 1542
1847#: plugins/check_mrtg.c:221
1848msgid "Invalid variable number" 1543msgid "Invalid variable number"
1849msgstr "" 1544msgstr ""
1850 1545
1851#: plugins/check_mrtg.c:256
1852#, c-format 1546#, c-format
1853msgid "" 1547msgid ""
1854"%s is not a valid expiration time\n" 1548"%s is not a valid expiration time\n"
1855"Use '%s -h' for additional help\n" 1549"Use '%s -h' for additional help\n"
1856msgstr "" 1550msgstr ""
1857 1551
1858#: plugins/check_mrtg.c:273
1859msgid "Invalid variable number\n" 1552msgid "Invalid variable number\n"
1860msgstr "" 1553msgstr ""
1861 1554
1862#: plugins/check_mrtg.c:300
1863msgid "You must supply the variable number" 1555msgid "You must supply the variable number"
1864msgstr "" 1556msgstr ""
1865 1557
1866#: plugins/check_mrtg.c:321
1867msgid "" 1558msgid ""
1868"This plugin will check either the average or maximum value of one of the" 1559"This plugin will check either the average or maximum value of one of the"
1869msgstr "" 1560msgstr ""
1870 1561
1871#: plugins/check_mrtg.c:322
1872msgid "two variables recorded in an MRTG log file." 1562msgid "two variables recorded in an MRTG log file."
1873msgstr "" 1563msgstr ""
1874 1564
1875#: plugins/check_mrtg.c:332
1876msgid "The MRTG log file containing the data you want to monitor" 1565msgid "The MRTG log file containing the data you want to monitor"
1877msgstr "" 1566msgstr ""
1878 1567
1879#: plugins/check_mrtg.c:334
1880msgid "Minutes before MRTG data is considered to be too old" 1568msgid "Minutes before MRTG data is considered to be too old"
1881msgstr "" 1569msgstr ""
1882 1570
1883#: plugins/check_mrtg.c:336
1884msgid "Should we check average or maximum values?" 1571msgid "Should we check average or maximum values?"
1885msgstr "" 1572msgstr ""
1886 1573
1887#: plugins/check_mrtg.c:338
1888msgid "Which variable set should we inspect? (1 or 2)" 1574msgid "Which variable set should we inspect? (1 or 2)"
1889msgstr "" 1575msgstr ""
1890 1576
1891#: plugins/check_mrtg.c:340
1892msgid "Threshold value for data to result in WARNING status" 1577msgid "Threshold value for data to result in WARNING status"
1893msgstr "" 1578msgstr ""
1894 1579
1895#: plugins/check_mrtg.c:342
1896msgid "Threshold value for data to result in CRITICAL status" 1580msgid "Threshold value for data to result in CRITICAL status"
1897msgstr "" 1581msgstr ""
1898 1582
1899#: plugins/check_mrtg.c:344
1900msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)" 1583msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)"
1901msgstr "" 1584msgstr ""
1902 1585
1903#: plugins/check_mrtg.c:346
1904msgid "Option units label for data (Example: Packets/Sec, Errors/Sec," 1586msgid "Option units label for data (Example: Packets/Sec, Errors/Sec,"
1905msgstr "" 1587msgstr ""
1906 1588
1907#: plugins/check_mrtg.c:347
1908#, c-format 1589#, c-format
1909msgid "\"Bytes Per Second\", \"%% Utilization\")" 1590msgid "\"Bytes Per Second\", \"%% Utilization\")"
1910msgstr "" 1591msgstr ""
1911 1592
1912#: plugins/check_mrtg.c:350
1913msgid "" 1593msgid ""
1914"If the value exceeds the <vwl> threshold, a WARNING status is returned. If" 1594"If the value exceeds the <vwl> threshold, a WARNING status is returned. If"
1915msgstr "" 1595msgstr ""
1916 1596
1917#: plugins/check_mrtg.c:351
1918msgid "" 1597msgid ""
1919"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If" 1598"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If"
1920msgstr "" 1599msgstr ""
1921 1600
1922#: plugins/check_mrtg.c:352
1923msgid "the data in the log file is older than <expire_minutes> old, a WARNING" 1601msgid "the data in the log file is older than <expire_minutes> old, a WARNING"
1924msgstr "" 1602msgstr ""
1925 1603
1926#: plugins/check_mrtg.c:353
1927msgid "status is returned and a warning message is printed." 1604msgid "status is returned and a warning message is printed."
1928msgstr "" 1605msgstr ""
1929 1606
1930#: plugins/check_mrtg.c:356
1931msgid "" 1607msgid ""
1932"This plugin is useful for monitoring MRTG data that does not correspond to" 1608"This plugin is useful for monitoring MRTG data that does not correspond to"
1933msgstr "" 1609msgstr ""
1934 1610
1935#: plugins/check_mrtg.c:357
1936msgid "" 1611msgid ""
1937"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)." 1612"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."
1938msgstr "" 1613msgstr ""
1939 1614
1940#: plugins/check_mrtg.c:358
1941msgid "" 1615msgid ""
1942"It can be used to monitor any kind of data that MRTG is monitoring - errors," 1616"It can be used to monitor any kind of data that MRTG is monitoring - errors,"
1943msgstr "" 1617msgstr ""
1944 1618
1945#: plugins/check_mrtg.c:359
1946msgid "" 1619msgid ""
1947"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows" 1620"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"
1948msgstr "" 1621msgstr ""
1949 1622
1950#: plugins/check_mrtg.c:360
1951msgid "" 1623msgid ""
1952"me to track processor utilization, user connections, drive space, etc and" 1624"me to track processor utilization, user connections, drive space, etc and"
1953msgstr "" 1625msgstr ""
1954 1626
1955#: plugins/check_mrtg.c:361
1956msgid "this plugin works well for monitoring that kind of data as well." 1627msgid "this plugin works well for monitoring that kind of data as well."
1957msgstr "" 1628msgstr ""
1958 1629
1959#: plugins/check_mrtg.c:364
1960msgid "" 1630msgid ""
1961"- This plugin only monitors one of the two variables stored in the MRTG log" 1631"- This plugin only monitors one of the two variables stored in the MRTG log"
1962msgstr "" 1632msgstr ""
1963 1633
1964#: plugins/check_mrtg.c:365
1965msgid "file. If you want to monitor both values you will have to define two" 1634msgid "file. If you want to monitor both values you will have to define two"
1966msgstr "" 1635msgstr ""
1967 1636
1968#: plugins/check_mrtg.c:366
1969msgid "commands with different values for the <variable> argument. Of course," 1637msgid "commands with different values for the <variable> argument. Of course,"
1970msgstr "" 1638msgstr ""
1971 1639
1972#: plugins/check_mrtg.c:367
1973msgid "you can always hack the code to make this plugin work for you..." 1640msgid "you can always hack the code to make this plugin work for you..."
1974msgstr "" 1641msgstr ""
1975 1642
1976#: plugins/check_mrtg.c:368
1977msgid "" 1643msgid ""
1978"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded " 1644"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded "
1979"from" 1645"from"
1980msgstr "" 1646msgstr ""
1981 1647
1982#: plugins/check_mrtgtraf.c:88
1983msgid "Unable to open MRTG log file" 1648msgid "Unable to open MRTG log file"
1984msgstr "" 1649msgstr ""
1985 1650
1986#: plugins/check_mrtgtraf.c:130
1987msgid "Unable to process MRTG log file" 1651msgid "Unable to process MRTG log file"
1988msgstr "" 1652msgstr ""
1989 1653
1990#: plugins/check_mrtgtraf.c:194
1991#, c-format 1654#, c-format
1992msgid "%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n" 1655msgid "%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"
1993msgstr "" 1656msgstr ""
1994 1657
1995#: plugins/check_mrtgtraf.c:207
1996#, c-format 1658#, c-format
1997msgid "Traffic %s - %s\n" 1659msgid "Traffic %s - %s\n"
1998msgstr "" 1660msgstr ""
1999 1661
2000#: plugins/check_mrtgtraf.c:335
2001msgid "" 1662msgid ""
2002"This plugin will check the incoming/outgoing transfer rates of a router," 1663"This plugin will check the incoming/outgoing transfer rates of a router,"
2003msgstr "" 1664msgstr ""
2004 1665
2005#: plugins/check_mrtgtraf.c:336
2006msgid "switch, etc recorded in an MRTG log. If the newest log entry is older" 1666msgid "switch, etc recorded in an MRTG log. If the newest log entry is older"
2007msgstr "" 1667msgstr ""
2008 1668
2009#: plugins/check_mrtgtraf.c:337
2010msgid "than <expire_minutes>, a WARNING status is returned. If either the" 1669msgid "than <expire_minutes>, a WARNING status is returned. If either the"
2011msgstr "" 1670msgstr ""
2012 1671
2013#: plugins/check_mrtgtraf.c:338
2014msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in" 1672msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in"
2015msgstr "" 1673msgstr ""
2016 1674
2017#: plugins/check_mrtgtraf.c:339
2018msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed" 1675msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed"
2019msgstr "" 1676msgstr ""
2020 1677
2021#: plugins/check_mrtgtraf.c:340
2022msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results." 1678msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results."
2023msgstr "" 1679msgstr ""
2024 1680
2025#: plugins/check_mrtgtraf.c:350
2026msgid "File to read log from" 1681msgid "File to read log from"
2027msgstr "" 1682msgstr ""
2028 1683
2029#: plugins/check_mrtgtraf.c:352
2030msgid "Minutes after which log expires" 1684msgid "Minutes after which log expires"
2031msgstr "" 1685msgstr ""
2032 1686
2033#: plugins/check_mrtgtraf.c:354
2034msgid "Test average or maximum" 1687msgid "Test average or maximum"
2035msgstr "" 1688msgstr ""
2036 1689
2037#: plugins/check_mrtgtraf.c:356
2038msgid "Warning threshold pair <incoming>,<outgoing>" 1690msgid "Warning threshold pair <incoming>,<outgoing>"
2039msgstr "" 1691msgstr ""
2040 1692
2041#: plugins/check_mrtgtraf.c:358
2042msgid "Critical threshold pair <incoming>,<outgoing>" 1693msgid "Critical threshold pair <incoming>,<outgoing>"
2043msgstr "" 1694msgstr ""
2044 1695
2045#: plugins/check_mrtgtraf.c:362
2046msgid "" 1696msgid ""
2047"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from" 1697"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"
2048msgstr "" 1698msgstr ""
2049 1699
2050#: plugins/check_mrtgtraf.c:364
2051msgid "- While MRTG can monitor things other than traffic rates, this" 1700msgid "- While MRTG can monitor things other than traffic rates, this"
2052msgstr "" 1701msgstr ""
2053 1702
2054#: plugins/check_mrtgtraf.c:365
2055msgid " plugin probably won't work with much else without modification." 1703msgid " plugin probably won't work with much else without modification."
2056msgstr "" 1704msgstr ""
2057 1705
2058#: plugins/check_mrtgtraf.c:366
2059msgid "- The calculated i/o rates are a little off from what MRTG actually" 1706msgid "- The calculated i/o rates are a little off from what MRTG actually"
2060msgstr "" 1707msgstr ""
2061 1708
2062#: plugins/check_mrtgtraf.c:367
2063msgid " reports. I'm not sure why this is right now, but will look into it" 1709msgid " reports. I'm not sure why this is right now, but will look into it"
2064msgstr "" 1710msgstr ""
2065 1711
2066#: plugins/check_mrtgtraf.c:368
2067msgid " for future enhancements of this plugin." 1712msgid " for future enhancements of this plugin."
2068msgstr "" 1713msgstr ""
2069 1714
2070#: plugins/check_mrtgtraf.c:378
2071#, c-format 1715#, c-format
2072msgid "Usage" 1716msgid "Usage"
2073msgstr "" 1717msgstr ""
2074 1718
2075#: plugins/check_mysql.c:171
2076#, c-format 1719#, c-format
2077msgid "status store_result error: %s\n" 1720msgid "status store_result error: %s\n"
2078msgstr "" 1721msgstr ""
2079 1722
2080#: plugins/check_mysql.c:202
2081#, c-format 1723#, c-format
2082msgid "slave query error: %s\n" 1724msgid "slave query error: %s\n"
2083msgstr "" 1725msgstr ""
2084 1726
2085#: plugins/check_mysql.c:209
2086#, c-format 1727#, c-format
2087msgid "slave store_result error: %s\n" 1728msgid "slave store_result error: %s\n"
2088msgstr "" 1729msgstr ""
2089 1730
2090#: plugins/check_mysql.c:215
2091msgid "No slaves defined" 1731msgid "No slaves defined"
2092msgstr "" 1732msgstr ""
2093 1733
2094#: plugins/check_mysql.c:223
2095#, c-format 1734#, c-format
2096msgid "slave fetch row error: %s\n" 1735msgid "slave fetch row error: %s\n"
2097msgstr "" 1736msgstr ""
2098 1737
2099#: plugins/check_mysql.c:228
2100#, c-format 1738#, c-format
2101msgid "Slave running: %s" 1739msgid "Slave running: %s"
2102msgstr "" 1740msgstr ""
2103 1741
2104#: plugins/check_mysql.c:505
2105msgid "This program tests connections to a MySQL server" 1742msgid "This program tests connections to a MySQL server"
2106msgstr "" 1743msgstr ""
2107 1744
2108#: plugins/check_mysql.c:516 1745msgid "Ignore authentication failure and check for mysql connectivity only"
1746msgstr ""
1747
2109msgid "Use the specified socket (has no effect if -H is used)" 1748msgid "Use the specified socket (has no effect if -H is used)"
2110msgstr "" 1749msgstr ""
2111 1750
2112#: plugins/check_mysql.c:519
2113msgid "Check database with indicated name" 1751msgid "Check database with indicated name"
2114msgstr "" 1752msgstr ""
2115 1753
2116#: plugins/check_mysql.c:521
2117msgid "Read from the specified client options file" 1754msgid "Read from the specified client options file"
2118msgstr "" 1755msgstr ""
2119 1756
2120#: plugins/check_mysql.c:523
2121msgid "Use a client options group" 1757msgid "Use a client options group"
2122msgstr "" 1758msgstr ""
2123 1759
2124#: plugins/check_mysql.c:525
2125msgid "Connect using the indicated username" 1760msgid "Connect using the indicated username"
2126msgstr "" 1761msgstr ""
2127 1762
2128#: plugins/check_mysql.c:527
2129msgid "Use the indicated password to authenticate the connection" 1763msgid "Use the indicated password to authenticate the connection"
2130msgstr "" 1764msgstr ""
2131 1765
2132#: plugins/check_mysql.c:528
2133msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!" 1766msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!"
2134msgstr "" 1767msgstr ""
2135 1768
2136#: plugins/check_mysql.c:529
2137msgid "Your clear-text password could be visible as a process table entry" 1769msgid "Your clear-text password could be visible as a process table entry"
2138msgstr "" 1770msgstr ""
2139 1771
2140#: plugins/check_mysql.c:531
2141msgid "Check if the slave thread is running properly." 1772msgid "Check if the slave thread is running properly."
2142msgstr "" 1773msgstr ""
2143 1774
2144#: plugins/check_mysql.c:533
2145msgid "Exit with WARNING status if slave server is more than INTEGER seconds" 1775msgid "Exit with WARNING status if slave server is more than INTEGER seconds"
2146msgstr "" 1776msgstr ""
2147 1777
2148#: plugins/check_mysql.c:534 plugins/check_mysql.c:537
2149msgid "behind master" 1778msgid "behind master"
2150msgstr "" 1779msgstr ""
2151 1780
2152#: plugins/check_mysql.c:536
2153msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds" 1781msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds"
2154msgstr "" 1782msgstr ""
2155 1783
2156#: plugins/check_mysql.c:539 1784msgid "Use ssl encryption"
2157msgid "Use ssl encryptation"
2158msgstr "" 1785msgstr ""
2159 1786
2160#: plugins/check_mysql.c:541
2161msgid "Path to CA signing the cert" 1787msgid "Path to CA signing the cert"
2162msgstr "" 1788msgstr ""
2163 1789
2164#: plugins/check_mysql.c:543
2165msgid "Path to SSL certificate" 1790msgid "Path to SSL certificate"
2166msgstr "" 1791msgstr ""
2167 1792
2168#: plugins/check_mysql.c:545
2169msgid "Path to private SSL key" 1793msgid "Path to private SSL key"
2170msgstr "" 1794msgstr ""
2171 1795
2172#: plugins/check_mysql.c:547
2173msgid "Path to CA directory" 1796msgid "Path to CA directory"
2174msgstr "" 1797msgstr ""
2175 1798
2176#: plugins/check_mysql.c:549
2177msgid "List of valid SSL ciphers" 1799msgid "List of valid SSL ciphers"
2178msgstr "" 1800msgstr ""
2179 1801
2180#: plugins/check_mysql.c:553
2181msgid "" 1802msgid ""
2182"There are no required arguments. By default, the local database is checked" 1803"There are no required arguments. By default, the local database is checked"
2183msgstr "" 1804msgstr ""
2184 1805
2185#: plugins/check_mysql.c:554
2186msgid "" 1806msgid ""
2187"using the default unix socket. You can force TCP on localhost by using an" 1807"using the default unix socket. You can force TCP on localhost by using an"
2188msgstr "" 1808msgstr ""
2189 1809
2190#: plugins/check_mysql.c:555
2191msgid "IP address or FQDN ('localhost' will use the socket as well)." 1810msgid "IP address or FQDN ('localhost' will use the socket as well)."
2192msgstr "" 1811msgstr ""
2193 1812
2194#: plugins/check_mysql.c:559
2195msgid "You must specify -p with an empty string to force an empty password," 1813msgid "You must specify -p with an empty string to force an empty password,"
2196msgstr "" 1814msgstr ""
2197 1815
2198#: plugins/check_mysql.c:560
2199msgid "overriding any my.cnf settings." 1816msgid "overriding any my.cnf settings."
2200msgstr "" 1817msgstr ""
2201 1818
2202#: plugins/check_nagios.c:104
2203msgid "Cannot open status log for reading!" 1819msgid "Cannot open status log for reading!"
2204msgstr "" 1820msgstr ""
2205 1821
2206#: plugins/check_nagios.c:154
2207#, c-format 1822#, c-format
2208msgid "Found process: %s %s\n" 1823msgid "Found process: %s %s\n"
2209msgstr "" 1824msgstr ""
2210 1825
2211#: plugins/check_nagios.c:168
2212msgid "Could not locate a running Nagios process!" 1826msgid "Could not locate a running Nagios process!"
2213msgstr "" 1827msgstr ""
2214 1828
2215#: plugins/check_nagios.c:172
2216msgid "Cannot parse Nagios log file for valid time" 1829msgid "Cannot parse Nagios log file for valid time"
2217msgstr "" 1830msgstr ""
2218 1831
2219#: plugins/check_nagios.c:183 plugins/check_procs.c:356
2220#, c-format 1832#, c-format
2221msgid "%d process" 1833msgid "%d process"
2222msgid_plural "%d processes" 1834msgid_plural "%d processes"
2223msgstr[0] "" 1835msgstr[0] ""
2224msgstr[1] "" 1836msgstr[1] ""
2225 1837
2226#: plugins/check_nagios.c:186
2227#, c-format 1838#, c-format
2228msgid "status log updated %d second ago" 1839msgid "status log updated %d second ago"
2229msgid_plural "status log updated %d seconds ago" 1840msgid_plural "status log updated %d seconds ago"
2230msgstr[0] "" 1841msgstr[0] ""
2231msgstr[1] "" 1842msgstr[1] ""
2232 1843
2233#: plugins/check_nagios.c:224 plugins/check_nagios.c:253
2234msgid "Expiration time must be an integer (seconds)\n" 1844msgid "Expiration time must be an integer (seconds)\n"
2235msgstr "" 1845msgstr ""
2236 1846
2237#: plugins/check_nagios.c:260
2238msgid "Timeout must be an integer (seconds)\n" 1847msgid "Timeout must be an integer (seconds)\n"
2239msgstr "" 1848msgstr ""
2240 1849
2241#: plugins/check_nagios.c:272
2242msgid "You must provide the status_log\n" 1850msgid "You must provide the status_log\n"
2243msgstr "" 1851msgstr ""
2244 1852
2245#: plugins/check_nagios.c:275
2246msgid "You must provide a process string\n" 1853msgid "You must provide a process string\n"
2247msgstr "" 1854msgstr ""
2248 1855
2249#: plugins/check_nagios.c:289
2250msgid "" 1856msgid ""
2251"This plugin checks the status of the Nagios process on the local machine" 1857"This plugin checks the status of the Nagios process on the local machine"
2252msgstr "" 1858msgstr ""
2253 1859
2254#: plugins/check_nagios.c:290
2255msgid "" 1860msgid ""
2256"The plugin will check to make sure the Nagios status log is no older than" 1861"The plugin will check to make sure the Nagios status log is no older than"
2257msgstr "" 1862msgstr ""
2258 1863
2259#: plugins/check_nagios.c:291
2260msgid "the number of minutes specified by the expires option." 1864msgid "the number of minutes specified by the expires option."
2261msgstr "" 1865msgstr ""
2262 1866
2263#: plugins/check_nagios.c:292
2264msgid "" 1867msgid ""
2265"It also checks the process table for a process matching the command argument." 1868"It also checks the process table for a process matching the command argument."
2266msgstr "" 1869msgstr ""
2267 1870
2268#: plugins/check_nagios.c:302
2269msgid "Name of the log file to check" 1871msgid "Name of the log file to check"
2270msgstr "" 1872msgstr ""
2271 1873
2272#: plugins/check_nagios.c:304
2273msgid "Minutes aging after which logfile is considered stale" 1874msgid "Minutes aging after which logfile is considered stale"
2274msgstr "" 1875msgstr ""
2275 1876
2276#: plugins/check_nagios.c:306
2277msgid "Substring to search for in process arguments" 1877msgid "Substring to search for in process arguments"
2278msgstr "" 1878msgstr ""
2279 1879
2280#: plugins/check_nagios.c:308
2281msgid "Timeout for the plugin in seconds" 1880msgid "Timeout for the plugin in seconds"
2282msgstr "" 1881msgstr ""
2283 1882
2284#: plugins/check_nt.c:142
2285#, c-format 1883#, c-format
2286msgid "Wrong client version - running: %s, required: %s" 1884msgid "Wrong client version - running: %s, required: %s"
2287msgstr "" 1885msgstr ""
2288 1886
2289#: plugins/check_nt.c:153 plugins/check_nt.c:218
2290msgid "missing -l parameters" 1887msgid "missing -l parameters"
2291msgstr "" 1888msgstr ""
2292 1889
2293#: plugins/check_nt.c:155
2294msgid "wrong -l parameter." 1890msgid "wrong -l parameter."
2295msgstr "" 1891msgstr ""
2296 1892
2297#: plugins/check_nt.c:159
2298msgid "CPU Load" 1893msgid "CPU Load"
2299msgstr "" 1894msgstr ""
2300 1895
2301#: plugins/check_nt.c:182
2302#, c-format 1896#, c-format
2303msgid " %lu%% (%lu min average)" 1897msgid " %lu%% (%lu min average)"
2304msgstr "" 1898msgstr ""
2305 1899
2306#: plugins/check_nt.c:184
2307#, c-format 1900#, c-format
2308msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100" 1901msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100"
2309msgstr "" 1902msgstr ""
2310 1903
2311#: plugins/check_nt.c:194
2312msgid "not enough values for -l parameters" 1904msgid "not enough values for -l parameters"
2313msgstr "" 1905msgstr ""
2314 1906
2315#: plugins/check_nt.c:206 1907msgid "wrong -l argument"
2316#, c-format
2317msgid "System Uptime - %u day(s) %u hour(s) %u minute(s)"
2318msgstr "" 1908msgstr ""
2319 1909
2320#: plugins/check_nt.c:220 1910#, c-format
2321msgid "wrong -l argument" 1911msgid "System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"
2322msgstr "" 1912msgstr ""
2323 1913
2324#: plugins/check_nt.c:236
2325#, c-format 1914#, c-format
2326msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)" 1915msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"
2327msgstr "" 1916msgstr ""
2328 1917
2329#: plugins/check_nt.c:239
2330#, c-format 1918#, c-format
2331msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f" 1919msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2332msgstr "" 1920msgstr ""
2333 1921
2334#: plugins/check_nt.c:253
2335msgid "Free disk space : Invalid drive" 1922msgid "Free disk space : Invalid drive"
2336msgstr "" 1923msgstr ""
2337 1924
2338#: plugins/check_nt.c:263
2339msgid "No service/process specified" 1925msgid "No service/process specified"
2340msgstr "" 1926msgstr ""
2341 1927
2342#: plugins/check_nt.c:271 plugins/check_nt.c:284 plugins/check_nt.c:288
2343#: plugins/check_nt.c:622
2344msgid "could not fetch information from server\n" 1928msgid "could not fetch information from server\n"
2345msgstr "" 1929msgstr ""
2346 1930
2347#: plugins/check_nt.c:296
2348#, c-format 1931#, c-format
2349msgid "" 1932msgid ""
2350"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)" 1933"Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"
2351msgstr "" 1934msgstr ""
2352 1935
2353#: plugins/check_nt.c:299
2354#, c-format 1936#, c-format
2355msgid "'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f" 1937msgid "'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"
2356msgstr "" 1938msgstr ""
2357 1939
2358#: plugins/check_nt.c:335 plugins/check_nt.c:420 plugins/check_nt.c:450
2359msgid "No counter specified" 1940msgid "No counter specified"
2360msgstr "" 1941msgstr ""
2361 1942
2362#: plugins/check_nt.c:367
2363msgid "Minimum value contains non-numbers" 1943msgid "Minimum value contains non-numbers"
2364msgstr "" 1944msgstr ""
2365 1945
2366#: plugins/check_nt.c:371
2367msgid "Maximum value contains non-numbers" 1946msgid "Maximum value contains non-numbers"
2368msgstr "" 1947msgstr ""
2369 1948
2370#: plugins/check_nt.c:378
2371msgid "No unit counter specified" 1949msgid "No unit counter specified"
2372msgstr "" 1950msgstr ""
2373 1951
2374#: plugins/check_nt.c:465
2375msgid "Please specify a variable to check" 1952msgid "Please specify a variable to check"
2376msgstr "" 1953msgstr ""
2377 1954
2378#: plugins/check_nt.c:549
2379msgid "Server port must be an integer\n" 1955msgid "Server port must be an integer\n"
2380msgstr "" 1956msgstr ""
2381 1957
2382#: plugins/check_nt.c:603
2383msgid "You must provide a server address or host name" 1958msgid "You must provide a server address or host name"
2384msgstr "" 1959msgstr ""
2385 1960
2386#: plugins/check_nt.c:609
2387msgid "None" 1961msgid "None"
2388msgstr "" 1962msgstr ""
2389 1963
2390#: plugins/check_nt.c:666
2391msgid "This plugin collects data from the NSClient service running on a" 1964msgid "This plugin collects data from the NSClient service running on a"
2392msgstr "" 1965msgstr ""
2393 1966
2394#: plugins/check_nt.c:667
2395msgid "Windows NT/2000/XP/2003 server." 1967msgid "Windows NT/2000/XP/2003 server."
2396msgstr "" 1968msgstr ""
2397 1969
2398#: plugins/check_nt.c:678
2399msgid "Name of the host to check" 1970msgid "Name of the host to check"
2400msgstr "" 1971msgstr ""
2401 1972
2402#: plugins/check_nt.c:680
2403msgid "Optional port number (default: " 1973msgid "Optional port number (default: "
2404msgstr "" 1974msgstr ""
2405 1975
2406#: plugins/check_nt.c:683
2407msgid "Password needed for the request" 1976msgid "Password needed for the request"
2408msgstr "" 1977msgstr ""
2409 1978
2410#: plugins/check_nt.c:685 plugins/check_nwstat.c:1661
2411#: plugins/check_overcr.c:432
2412msgid "Threshold which will result in a warning status" 1979msgid "Threshold which will result in a warning status"
2413msgstr "" 1980msgstr ""
2414 1981
2415#: plugins/check_nt.c:687 plugins/check_nwstat.c:1663
2416#: plugins/check_overcr.c:434
2417msgid "Threshold which will result in a critical status" 1982msgid "Threshold which will result in a critical status"
2418msgstr "" 1983msgstr ""
2419 1984
2420#: plugins/check_nt.c:689
2421msgid "Seconds before connection attempt times out (default: " 1985msgid "Seconds before connection attempt times out (default: "
2422msgstr "" 1986msgstr ""
2423 1987
2424#: plugins/check_nt.c:691
2425msgid "Parameters passed to specified check (see below)" 1988msgid "Parameters passed to specified check (see below)"
2426msgstr "" 1989msgstr ""
2427 1990
2428#: plugins/check_nt.c:693
2429msgid "Display options (currently only SHOWALL works)" 1991msgid "Display options (currently only SHOWALL works)"
2430msgstr "" 1992msgstr ""
2431 1993
2432#: plugins/check_nt.c:695
2433msgid "Return UNKNOWN on timeouts" 1994msgid "Return UNKNOWN on timeouts"
2434msgstr "" 1995msgstr ""
2435 1996
2436#: plugins/check_nt.c:698
2437msgid "Print this help screen" 1997msgid "Print this help screen"
2438msgstr "" 1998msgstr ""
2439 1999
2440#: plugins/check_nt.c:700
2441msgid "Print version information" 2000msgid "Print version information"
2442msgstr "" 2001msgstr ""
2443 2002
2444#: plugins/check_nt.c:702
2445msgid "Variable to check" 2003msgid "Variable to check"
2446msgstr "" 2004msgstr ""
2447 2005
2448#: plugins/check_nt.c:703
2449msgid "Valid variables are:" 2006msgid "Valid variables are:"
2450msgstr "" 2007msgstr ""
2451 2008
2452#: plugins/check_nt.c:705
2453msgid "Get the NSClient version" 2009msgid "Get the NSClient version"
2454msgstr "" 2010msgstr ""
2455 2011
2456#: plugins/check_nt.c:706
2457msgid "If -l <version> is specified, will return warning if versions differ." 2012msgid "If -l <version> is specified, will return warning if versions differ."
2458msgstr "" 2013msgstr ""
2459 2014
2460#: plugins/check_nt.c:708
2461msgid "Average CPU load on last x minutes." 2015msgid "Average CPU load on last x minutes."
2462msgstr "" 2016msgstr ""
2463 2017
2464#: plugins/check_nt.c:709
2465msgid "Request a -l parameter with the following syntax:" 2018msgid "Request a -l parameter with the following syntax:"
2466msgstr "" 2019msgstr ""
2467 2020
2468#: plugins/check_nt.c:710
2469msgid "-l <minutes range>,<warning threshold>,<critical threshold>." 2021msgid "-l <minutes range>,<warning threshold>,<critical threshold>."
2470msgstr "" 2022msgstr ""
2471 2023
2472#: plugins/check_nt.c:711
2473msgid "<minute range> should be less than 24*60." 2024msgid "<minute range> should be less than 24*60."
2474msgstr "" 2025msgstr ""
2475 2026
2476#: plugins/check_nt.c:712
2477msgid "" 2027msgid ""
2478"Thresholds are percentage and up to 10 requests can be done in one shot." 2028"Thresholds are percentage and up to 10 requests can be done in one shot."
2479msgstr "" 2029msgstr ""
2480 2030
2481#: plugins/check_nt.c:715
2482msgid "Get the uptime of the machine." 2031msgid "Get the uptime of the machine."
2483msgstr "" 2032msgstr ""
2484 2033
2485#: plugins/check_nt.c:716 2034msgid "-l <unit> "
2486msgid "No specific parameters. No warning or critical threshold" 2035msgstr ""
2036
2037msgid "<unit> = seconds, minutes, hours, or days. (default: minutes)"
2038msgstr ""
2039
2040msgid "Thresholds will use the unit specified above."
2487msgstr "" 2041msgstr ""
2488 2042
2489#: plugins/check_nt.c:718
2490msgid "Size and percentage of disk use." 2043msgid "Size and percentage of disk use."
2491msgstr "" 2044msgstr ""
2492 2045
2493#: plugins/check_nt.c:719
2494msgid "Request a -l parameter containing the drive letter only." 2046msgid "Request a -l parameter containing the drive letter only."
2495msgstr "" 2047msgstr ""
2496 2048
2497#: plugins/check_nt.c:720 plugins/check_nt.c:723
2498msgid "Warning and critical thresholds can be specified with -w and -c." 2049msgid "Warning and critical thresholds can be specified with -w and -c."
2499msgstr "" 2050msgstr ""
2500 2051
2501#: plugins/check_nt.c:722
2502msgid "Memory use." 2052msgid "Memory use."
2503msgstr "" 2053msgstr ""
2504 2054
2505#: plugins/check_nt.c:725
2506msgid "Check the state of one or several services." 2055msgid "Check the state of one or several services."
2507msgstr "" 2056msgstr ""
2508 2057
2509#: plugins/check_nt.c:726 plugins/check_nt.c:735
2510msgid "Request a -l parameters with the following syntax:" 2058msgid "Request a -l parameters with the following syntax:"
2511msgstr "" 2059msgstr ""
2512 2060
2513#: plugins/check_nt.c:727
2514msgid "-l <service1>,<service2>,<service3>,..." 2061msgid "-l <service1>,<service2>,<service3>,..."
2515msgstr "" 2062msgstr ""
2516 2063
2517#: plugins/check_nt.c:728
2518msgid "You can specify -d SHOWALL in case you want to see working services" 2064msgid "You can specify -d SHOWALL in case you want to see working services"
2519msgstr "" 2065msgstr ""
2520 2066
2521#: plugins/check_nt.c:729
2522msgid "in the returned string." 2067msgid "in the returned string."
2523msgstr "" 2068msgstr ""
2524 2069
2525#: plugins/check_nt.c:731
2526msgid "Check if one or several process are running." 2070msgid "Check if one or several process are running."
2527msgstr "" 2071msgstr ""
2528 2072
2529#: plugins/check_nt.c:732
2530msgid "Same syntax as SERVICESTATE." 2073msgid "Same syntax as SERVICESTATE."
2531msgstr "" 2074msgstr ""
2532 2075
2533#: plugins/check_nt.c:734
2534msgid "Check any performance counter of Windows NT/2000." 2076msgid "Check any performance counter of Windows NT/2000."
2535msgstr "" 2077msgstr ""
2536 2078
2537#: plugins/check_nt.c:736
2538msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>" 2079msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>"
2539msgstr "" 2080msgstr ""
2540 2081
2541#: plugins/check_nt.c:737
2542msgid "The <description> parameter is optional and is given to a printf " 2082msgid "The <description> parameter is optional and is given to a printf "
2543msgstr "" 2083msgstr ""
2544 2084
2545#: plugins/check_nt.c:738
2546msgid "output command which requires a float parameter." 2085msgid "output command which requires a float parameter."
2547msgstr "" 2086msgstr ""
2548 2087
2549#: plugins/check_nt.c:739
2550#, c-format 2088#, c-format
2551msgid "If <description> does not include \"%%\", it is used as a label." 2089msgid "If <description> does not include \"%%\", it is used as a label."
2552msgstr "" 2090msgstr ""
2553 2091
2554#: plugins/check_nt.c:740 plugins/check_nt.c:755
2555msgid "Some examples:" 2092msgid "Some examples:"
2556msgstr "" 2093msgstr ""
2557 2094
2558#: plugins/check_nt.c:744
2559msgid "Check any performance counter object of Windows NT/2000." 2095msgid "Check any performance counter object of Windows NT/2000."
2560msgstr "" 2096msgstr ""
2561 2097
2562#: plugins/check_nt.c:745
2563msgid "" 2098msgid ""
2564"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>" 2099"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"
2565msgstr "" 2100msgstr ""
2566 2101
2567#: plugins/check_nt.c:746
2568msgid "<counter object> is a Windows Perfmon Counter object (eg. Process)," 2102msgid "<counter object> is a Windows Perfmon Counter object (eg. Process),"
2569msgstr "" 2103msgstr ""
2570 2104
2571#: plugins/check_nt.c:747
2572msgid "if it is two words, it should be enclosed in quotes" 2105msgid "if it is two words, it should be enclosed in quotes"
2573msgstr "" 2106msgstr ""
2574 2107
2575#: plugins/check_nt.c:748
2576msgid "The returned results will be a comma-separated list of instances on " 2108msgid "The returned results will be a comma-separated list of instances on "
2577msgstr "" 2109msgstr ""
2578 2110
2579#: plugins/check_nt.c:749
2580msgid " the selected computer for that object." 2111msgid " the selected computer for that object."
2581msgstr "" 2112msgstr ""
2582 2113
2583#: plugins/check_nt.c:750
2584msgid "" 2114msgid ""
2585"The purpose of this is to be run from command line to determine what " 2115"The purpose of this is to be run from command line to determine what "
2586"instances" 2116"instances"
2587msgstr "" 2117msgstr ""
2588 2118
2589#: plugins/check_nt.c:751
2590msgid "" 2119msgid ""
2591" are available for monitoring without having to log onto the Windows server" 2120" are available for monitoring without having to log onto the Windows server"
2592msgstr "" 2121msgstr ""
2593 2122
2594#: plugins/check_nt.c:752
2595msgid " to run Perfmon directly." 2123msgid " to run Perfmon directly."
2596msgstr "" 2124msgstr ""
2597 2125
2598#: plugins/check_nt.c:753
2599msgid "" 2126msgid ""
2600"It can also be used in scripts that automatically create the monitoring " 2127"It can also be used in scripts that automatically create the monitoring "
2601"service" 2128"service"
2602msgstr "" 2129msgstr ""
2603 2130
2604#: plugins/check_nt.c:754
2605msgid " configuration files." 2131msgid " configuration files."
2606msgstr "" 2132msgstr ""
2607 2133
2608#: plugins/check_nt.c:756
2609msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process" 2134msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"
2610msgstr "" 2135msgstr ""
2611 2136
2612#: plugins/check_nt.c:759
2613msgid "" 2137msgid ""
2614"- The NSClient service should be running on the server to get any information" 2138"- The NSClient service should be running on the server to get any information"
2615msgstr "" 2139msgstr ""
2616 2140
2617#: plugins/check_nt.c:761
2618msgid "- Critical thresholds should be lower than warning thresholds" 2141msgid "- Critical thresholds should be lower than warning thresholds"
2619msgstr "" 2142msgstr ""
2620 2143
2621#: plugins/check_nt.c:762
2622msgid "- Default port 1248 is sometimes in use by other services. The error" 2144msgid "- Default port 1248 is sometimes in use by other services. The error"
2623msgstr "" 2145msgstr ""
2624 2146
2625#: plugins/check_nt.c:763
2626msgid "" 2147msgid ""
2627"output when this happens contains \"Cannot map xxxxx to protocol number\"." 2148"output when this happens contains \"Cannot map xxxxx to protocol number\"."
2628msgstr "" 2149msgstr ""
2629 2150
2630#: plugins/check_nt.c:764
2631msgid "One fix for this is to change the port to something else on check_nt " 2151msgid "One fix for this is to change the port to something else on check_nt "
2632msgstr "" 2152msgstr ""
2633 2153
2634#: plugins/check_nt.c:765
2635msgid "and on the client service it's connecting to." 2154msgid "and on the client service it's connecting to."
2636msgstr "" 2155msgstr ""
2637 2156
2638#: plugins/check_ntp.c:807 plugins/check_ntp_peer.c:612 2157#, c-format
2639#: plugins/check_ntp_time.c:571 2158msgid "jitter response too large (%lu bytes)\n"
2159msgstr ""
2160
2640msgid "NTP CRITICAL:" 2161msgid "NTP CRITICAL:"
2641msgstr "" 2162msgstr ""
2642 2163
2643#: plugins/check_ntp.c:810 plugins/check_ntp_peer.c:615
2644#: plugins/check_ntp_time.c:574
2645msgid "NTP WARNING:" 2164msgid "NTP WARNING:"
2646msgstr "" 2165msgstr ""
2647 2166
2648#: plugins/check_ntp.c:813 plugins/check_ntp_peer.c:618
2649#: plugins/check_ntp_time.c:577
2650msgid "NTP OK:" 2167msgid "NTP OK:"
2651msgstr "" 2168msgstr ""
2652 2169
2653#: plugins/check_ntp.c:816 plugins/check_ntp_peer.c:621
2654#: plugins/check_ntp_time.c:580
2655msgid "NTP UNKNOWN:" 2170msgid "NTP UNKNOWN:"
2656msgstr "" 2171msgstr ""
2657 2172
2658#: plugins/check_ntp.c:820 plugins/check_ntp_peer.c:630
2659#: plugins/check_ntp_time.c:584
2660msgid "Offset unknown" 2173msgid "Offset unknown"
2661msgstr "" 2174msgstr ""
2662 2175
2663#: plugins/check_ntp.c:823 plugins/check_ntp_peer.c:633
2664#: plugins/check_ntp_time.c:587
2665msgid "Offset" 2176msgid "Offset"
2666msgstr "" 2177msgstr ""
2667 2178
2668#: plugins/check_ntp.c:844 plugins/check_ntp_peer.c:662
2669msgid "This plugin checks the selected ntp server" 2179msgid "This plugin checks the selected ntp server"
2670msgstr "" 2180msgstr ""
2671 2181
2672#: plugins/check_ntp.c:854 plugins/check_ntp_peer.c:674
2673#: plugins/check_ntp_time.c:614
2674msgid "Offset to result in warning status (seconds)" 2182msgid "Offset to result in warning status (seconds)"
2675msgstr "" 2183msgstr ""
2676 2184
2677#: plugins/check_ntp.c:856 plugins/check_ntp_peer.c:676
2678#: plugins/check_ntp_time.c:616
2679msgid "Offset to result in critical status (seconds)" 2185msgid "Offset to result in critical status (seconds)"
2680msgstr "" 2186msgstr ""
2681 2187
2682#: plugins/check_ntp.c:858 plugins/check_ntp_peer.c:682
2683msgid "Warning threshold for jitter" 2188msgid "Warning threshold for jitter"
2684msgstr "" 2189msgstr ""
2685 2190
2686#: plugins/check_ntp.c:860 plugins/check_ntp_peer.c:684
2687msgid "Critical threshold for jitter" 2191msgid "Critical threshold for jitter"
2688msgstr "" 2192msgstr ""
2689 2193
2690#: plugins/check_ntp.c:870
2691msgid "Normal offset check:" 2194msgid "Normal offset check:"
2692msgstr "" 2195msgstr ""
2693 2196
2694#: plugins/check_ntp.c:873 plugins/check_ntp_peer.c:709
2695msgid "" 2197msgid ""
2696"Check jitter too, avoiding critical notifications if jitter isn't available" 2198"Check jitter too, avoiding critical notifications if jitter isn't available"
2697msgstr "" 2199msgstr ""
2698 2200
2699#: plugins/check_ntp.c:874 plugins/check_ntp_peer.c:710
2700msgid "(See Notes above for more details on thresholds formats):" 2201msgid "(See Notes above for more details on thresholds formats):"
2701msgstr "" 2202msgstr ""
2702 2203
2703#: plugins/check_ntp.c:879 plugins/check_ntp.c:886
2704msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or" 2204msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or"
2705msgstr "" 2205msgstr ""
2706 2206
2707#: plugins/check_ntp.c:880 plugins/check_ntp.c:887
2708msgid "check_ntp_time instead." 2207msgid "check_ntp_time instead."
2709msgstr "" 2208msgstr ""
2710 2209
2711#: plugins/check_ntp_peer.c:625
2712msgid "Server not synchronized" 2210msgid "Server not synchronized"
2713msgstr "" 2211msgstr ""
2714 2212
2715#: plugins/check_ntp_peer.c:627
2716msgid "Server has the LI_ALARM bit set" 2213msgid "Server has the LI_ALARM bit set"
2717msgstr "" 2214msgstr ""
2718 2215
2719#: plugins/check_ntp_peer.c:672
2720msgid "" 2216msgid ""
2721"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized" 2217"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"
2722msgstr "" 2218msgstr ""
2723 2219
2724#: plugins/check_ntp_peer.c:678
2725msgid "Warning threshold for stratum of server's synchronization peer" 2220msgid "Warning threshold for stratum of server's synchronization peer"
2726msgstr "" 2221msgstr ""
2727 2222
2728#: plugins/check_ntp_peer.c:680
2729msgid "Critical threshold for stratum of server's synchronization peer" 2223msgid "Critical threshold for stratum of server's synchronization peer"
2730msgstr "" 2224msgstr ""
2731 2225
2732#: plugins/check_ntp_peer.c:686
2733msgid "Warning threshold for number of usable time sources (\"truechimers\")" 2226msgid "Warning threshold for number of usable time sources (\"truechimers\")"
2734msgstr "" 2227msgstr ""
2735 2228
2736#: plugins/check_ntp_peer.c:688
2737msgid "Critical threshold for number of usable time sources (\"truechimers\")" 2229msgid "Critical threshold for number of usable time sources (\"truechimers\")"
2738msgstr "" 2230msgstr ""
2739 2231
2740#: plugins/check_ntp_peer.c:693
2741msgid "This plugin checks an NTP server independent of any commandline" 2232msgid "This plugin checks an NTP server independent of any commandline"
2742msgstr "" 2233msgstr ""
2743 2234
2744#: plugins/check_ntp_peer.c:694
2745msgid "programs or external libraries." 2235msgid "programs or external libraries."
2746msgstr "" 2236msgstr ""
2747 2237
2748#: plugins/check_ntp_peer.c:697
2749msgid "Use this plugin to check the health of an NTP server. It supports" 2238msgid "Use this plugin to check the health of an NTP server. It supports"
2750msgstr "" 2239msgstr ""
2751 2240
2752#: plugins/check_ntp_peer.c:698
2753msgid "checking the offset with the sync peer, the jitter and stratum. This" 2241msgid "checking the offset with the sync peer, the jitter and stratum. This"
2754msgstr "" 2242msgstr ""
2755 2243
2756#: plugins/check_ntp_peer.c:699
2757msgid "plugin will not check the clock offset between the local host and NTP" 2244msgid "plugin will not check the clock offset between the local host and NTP"
2758msgstr "" 2245msgstr ""
2759 2246
2760#: plugins/check_ntp_peer.c:700
2761msgid "server; please use check_ntp_time for that purpose." 2247msgid "server; please use check_ntp_time for that purpose."
2762msgstr "" 2248msgstr ""
2763 2249
2764#: plugins/check_ntp_peer.c:706
2765msgid "Simple NTP server check:" 2250msgid "Simple NTP server check:"
2766msgstr "" 2251msgstr ""
2767 2252
2768#: plugins/check_ntp_peer.c:713
2769msgid "Only check the number of usable time sources (\"truechimers\"):" 2253msgid "Only check the number of usable time sources (\"truechimers\"):"
2770msgstr "" 2254msgstr ""
2771 2255
2772#: plugins/check_ntp_peer.c:716
2773msgid "Check only stratum:" 2256msgid "Check only stratum:"
2774msgstr "" 2257msgstr ""
2775 2258
2776#: plugins/check_ntp_time.c:602
2777msgid "This plugin checks the clock offset with the ntp server" 2259msgid "This plugin checks the clock offset with the ntp server"
2778msgstr "" 2260msgstr ""
2779 2261
2780#: plugins/check_ntp_time.c:612
2781msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found" 2262msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found"
2782msgstr "" 2263msgstr ""
2783 2264
2784#: plugins/check_ntp_time.c:621 2265msgid "Expected offset of the ntp server relative to local server (seconds)"
2266msgstr ""
2267
2785msgid "This plugin checks the clock offset between the local host and a" 2268msgid "This plugin checks the clock offset between the local host and a"
2786msgstr "" 2269msgstr ""
2787 2270
2788#: plugins/check_ntp_time.c:622
2789msgid "remote NTP server. It is independent of any commandline programs or" 2271msgid "remote NTP server. It is independent of any commandline programs or"
2790msgstr "" 2272msgstr ""
2791 2273
2792#: plugins/check_ntp_time.c:623
2793msgid "external libraries." 2274msgid "external libraries."
2794msgstr "" 2275msgstr ""
2795 2276
2796#: plugins/check_ntp_time.c:627
2797msgid "If you'd rather want to monitor an NTP server, please use" 2277msgid "If you'd rather want to monitor an NTP server, please use"
2798msgstr "" 2278msgstr ""
2799 2279
2800#: plugins/check_ntp_time.c:628
2801msgid "check_ntp_peer." 2280msgid "check_ntp_peer."
2802msgstr "" 2281msgstr ""
2803 2282
2804#: plugins/check_nwstat.c:194 2283msgid "--time-offset is useful for compensating for servers with known"
2284msgstr ""
2285
2286msgid "and expected clock skew."
2287msgstr ""
2288
2805#, c-format 2289#, c-format
2806msgid "NetWare %s: " 2290msgid "NetWare %s: "
2807msgstr "" 2291msgstr ""
2808 2292
2809#: plugins/check_nwstat.c:232
2810#, c-format 2293#, c-format
2811msgid "Up %s," 2294msgid "Up %s,"
2812msgstr "" 2295msgstr ""
2813 2296
2814#: plugins/check_nwstat.c:240
2815#, c-format 2297#, c-format
2816msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100" 2298msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"
2817msgstr "" 2299msgstr ""
2818 2300
2819#: plugins/check_nwstat.c:268
2820#, c-format 2301#, c-format
2821msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;" 2302msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"
2822msgstr "" 2303msgstr ""
2823 2304
2824#: plugins/check_nwstat.c:293
2825#, c-format 2305#, c-format
2826msgid "%s: Long term cache hits = %lu%%" 2306msgid "%s: Long term cache hits = %lu%%"
2827msgstr "" 2307msgstr ""
2828 2308
2829#: plugins/check_nwstat.c:315
2830#, c-format 2309#, c-format
2831msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;" 2310msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"
2832msgstr "" 2311msgstr ""
2833 2312
2834#: plugins/check_nwstat.c:340
2835#, c-format 2313#, c-format
2836msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;" 2314msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"
2837msgstr "" 2315msgstr ""
2838 2316
2839#: plugins/check_nwstat.c:365
2840#, c-format 2317#, c-format
2841msgid "%s: LRU sitting time = %lu minutes" 2318msgid "%s: LRU sitting time = %lu minutes"
2842msgstr "" 2319msgstr ""
2843 2320
2844#: plugins/check_nwstat.c:382 plugins/check_nwstat.c:410
2845#: plugins/check_nwstat.c:437 plugins/check_nwstat.c:470
2846#: plugins/check_nwstat.c:650 plugins/check_nwstat.c:676
2847#: plugins/check_nwstat.c:707 plugins/check_nwstat.c:753
2848#: plugins/check_nwstat.c:777
2849#, c-format 2321#, c-format
2850msgid "CRITICAL - Volume '%s' does not exist!" 2322msgid "CRITICAL - Volume '%s' does not exist!"
2851msgstr "" 2323msgstr ""
2852 2324
2853#: plugins/check_nwstat.c:391
2854#, c-format 2325#, c-format
2855msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;" 2326msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"
2856msgstr "" 2327msgstr ""
2857 2328
2858#: plugins/check_nwstat.c:392 plugins/check_nwstat.c:420
2859#: plugins/check_nwstat.c:447 plugins/check_nwstat.c:659
2860#: plugins/check_nwstat.c:685 plugins/check_nwstat.c:761
2861msgid "Only " 2329msgid "Only "
2862msgstr "" 2330msgstr ""
2863 2331
2864#: plugins/check_nwstat.c:419
2865#, c-format 2332#, c-format
2866msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;" 2333msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"
2867msgstr "" 2334msgstr ""
2868 2335
2869#: plugins/check_nwstat.c:446
2870#, c-format 2336#, c-format
2871msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;" 2337msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"
2872msgstr "" 2338msgstr ""
2873 2339
2874#: plugins/check_nwstat.c:494
2875#, c-format 2340#, c-format
2876msgid "" 2341msgid ""
2877"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100" 2342"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"
2878msgstr "" 2343msgstr ""
2879 2344
2880#: plugins/check_nwstat.c:528
2881#, c-format 2345#, c-format
2882msgid "Directory Services Database is %s (DS version %s)" 2346msgid "Directory Services Database is %s (DS version %s)"
2883msgstr "" 2347msgstr ""
2884 2348
2885#: plugins/check_nwstat.c:545
2886#, c-format 2349#, c-format
2887msgid "Logins are %s" 2350msgid "Logins are %s"
2888msgstr "" 2351msgstr ""
2889 2352
2890#: plugins/check_nwstat.c:545
2891msgid "enabled" 2353msgid "enabled"
2892msgstr "" 2354msgstr ""
2893 2355
2894#: plugins/check_nwstat.c:545
2895msgid "disabled" 2356msgid "disabled"
2896msgstr "" 2357msgstr ""
2897 2358
2898#: plugins/check_nwstat.c:560
2899msgid "CRITICAL - NRM Status is bad!" 2359msgid "CRITICAL - NRM Status is bad!"
2900msgstr "" 2360msgstr ""
2901 2361
2902#: plugins/check_nwstat.c:565
2903msgid "Warning - NRM Status is suspect!" 2362msgid "Warning - NRM Status is suspect!"
2904msgstr "" 2363msgstr ""
2905 2364
2906#: plugins/check_nwstat.c:568
2907msgid "OK - NRM Status is good!" 2365msgid "OK - NRM Status is good!"
2908msgstr "" 2366msgstr ""
2909 2367
2910#: plugins/check_nwstat.c:610
2911#, c-format 2368#, c-format
2912msgid "%lu of %lu (%lu%%) packet receive buffers used" 2369msgid "%lu of %lu (%lu%%) packet receive buffers used"
2913msgstr "" 2370msgstr ""
2914 2371
2915#: plugins/check_nwstat.c:634
2916#, c-format 2372#, c-format
2917msgid "%lu entries in SAP table" 2373msgid "%lu entries in SAP table"
2918msgstr "" 2374msgstr ""
2919 2375
2920#: plugins/check_nwstat.c:636
2921#, c-format 2376#, c-format
2922msgid "%lu entries in SAP table for SAP type %d" 2377msgid "%lu entries in SAP table for SAP type %d"
2923msgstr "" 2378msgstr ""
2924 2379
2925#: plugins/check_nwstat.c:658
2926#, c-format 2380#, c-format
2927msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2381msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
2928msgstr "" 2382msgstr ""
2929 2383
2930#: plugins/check_nwstat.c:684
2931#, c-format 2384#, c-format
2932msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2385msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
2933msgstr "" 2386msgstr ""
2934 2387
2935#: plugins/check_nwstat.c:730
2936#, c-format 2388#, c-format
2937msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100" 2389msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"
2938msgstr "" 2390msgstr ""
2939 2391
2940#: plugins/check_nwstat.c:761
2941#, c-format 2392#, c-format
2942msgid "%s%lu KB not yet purgeable on volume %s" 2393msgid "%s%lu KB not yet purgeable on volume %s"
2943msgstr "" 2394msgstr ""
2944 2395
2945#: plugins/check_nwstat.c:800
2946#, c-format 2396#, c-format
2947msgid "%lu MB (%lu%%) not yet purgeable on volume %s" 2397msgid "%lu MB (%lu%%) not yet purgeable on volume %s"
2948msgstr "" 2398msgstr ""
2949 2399
2950#: plugins/check_nwstat.c:821
2951#, c-format 2400#, c-format
2952msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0" 2401msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0"
2953msgstr "" 2402msgstr ""
2954 2403
2955#: plugins/check_nwstat.c:846
2956#, c-format 2404#, c-format
2957msgid "%lu abended threads|Abends=%lu;%lu;%lu;;" 2405msgid "%lu abended threads|Abends=%lu;%lu;%lu;;"
2958msgstr "" 2406msgstr ""
2959 2407
2960#: plugins/check_nwstat.c:881
2961#, c-format 2408#, c-format
2962msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu" 2409msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"
2963msgstr "" 2410msgstr ""
2964 2411
2965#: plugins/check_nwstat.c:904
2966msgid "CRITICAL - Time not in sync with network!" 2412msgid "CRITICAL - Time not in sync with network!"
2967msgstr "" 2413msgstr ""
2968 2414
2969#: plugins/check_nwstat.c:907
2970msgid "OK - Time in sync with network!" 2415msgid "OK - Time in sync with network!"
2971msgstr "" 2416msgstr ""
2972 2417
2973#: plugins/check_nwstat.c:930
2974#, c-format 2418#, c-format
2975msgid "LRU sitting time = %lu seconds" 2419msgid "LRU sitting time = %lu seconds"
2976msgstr "" 2420msgstr ""
2977 2421
2978#: plugins/check_nwstat.c:949
2979#, c-format 2422#, c-format
2980msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100" 2423msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"
2981msgstr "" 2424msgstr ""
2982 2425
2983#: plugins/check_nwstat.c:971
2984#, c-format 2426#, c-format
2985msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100" 2427msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"
2986msgstr "" 2428msgstr ""
2987 2429
2988#: plugins/check_nwstat.c:989
2989#, c-format 2430#, c-format
2990msgid "NDS Version %s" 2431msgid "NDS Version %s"
2991msgstr "" 2432msgstr ""
2992 2433
2993#: plugins/check_nwstat.c:1005
2994#, c-format 2434#, c-format
2995msgid "Up %s" 2435msgid "Up %s"
2996msgstr "" 2436msgstr ""
2997 2437
2998#: plugins/check_nwstat.c:1019
2999#, c-format 2438#, c-format
3000msgid "Module %s version %s is loaded" 2439msgid "Module %s version %s is loaded"
3001msgstr "" 2440msgstr ""
3002 2441
3003#: plugins/check_nwstat.c:1022
3004#, c-format 2442#, c-format
3005msgid "Module %s is not loaded" 2443msgid "Module %s is not loaded"
3006msgstr "" 2444msgstr ""
3007 2445
3008#: plugins/check_nwstat.c:1033 plugins/check_nwstat.c:1059
3009#: plugins/check_nwstat.c:1085 plugins/check_nwstat.c:1111
3010#: plugins/check_nwstat.c:1137 plugins/check_nwstat.c:1163
3011#: plugins/check_nwstat.c:1189 plugins/check_nwstat.c:1215
3012#: plugins/check_nwstat.c:1241 plugins/check_nwstat.c:1267
3013#, c-format 2446#, c-format
3014msgid "CRITICAL - Value '%s' does not exist!" 2447msgid "CRITICAL - Value '%s' does not exist!"
3015msgstr "" 2448msgstr ""
3016 2449
3017#: plugins/check_nwstat.c:1042 plugins/check_nwstat.c:1068
3018#: plugins/check_nwstat.c:1094 plugins/check_nwstat.c:1120
3019#: plugins/check_nwstat.c:1146 plugins/check_nwstat.c:1172
3020#: plugins/check_nwstat.c:1198 plugins/check_nwstat.c:1224
3021#: plugins/check_nwstat.c:1250 plugins/check_nwstat.c:1276
3022#, c-format 2450#, c-format
3023msgid "%s is %lu|%s=%lu;%lu;%lu;;" 2451msgid "%s is %lu|%s=%lu;%lu;%lu;;"
3024msgstr "" 2452msgstr ""
3025 2453
3026#: plugins/check_nwstat.c:1289 plugins/check_overcr.c:285
3027msgid "Nothing to check!\n" 2454msgid "Nothing to check!\n"
3028msgstr "" 2455msgstr ""
3029 2456
3030#: plugins/check_nwstat.c:1371 plugins/check_overcr.c:355
3031msgid "Server port an integer\n" 2457msgid "Server port an integer\n"
3032msgstr "" 2458msgstr ""
3033 2459
3034#: plugins/check_nwstat.c:1601
3035msgid "This plugin attempts to contact the MRTGEXT NLM running on a" 2460msgid "This plugin attempts to contact the MRTGEXT NLM running on a"
3036msgstr "" 2461msgstr ""
3037 2462
3038#: plugins/check_nwstat.c:1602
3039msgid "Novell server to gather the requested system information." 2463msgid "Novell server to gather the requested system information."
3040msgstr "" 2464msgstr ""
3041 2465
3042#: plugins/check_nwstat.c:1614 plugins/check_overcr.c:436
3043msgid "Variable to check. Valid variables include:" 2466msgid "Variable to check. Valid variables include:"
3044msgstr "" 2467msgstr ""
3045 2468
3046#: plugins/check_nwstat.c:1615
3047msgid "LOAD1 = 1 minute average CPU load" 2469msgid "LOAD1 = 1 minute average CPU load"
3048msgstr "" 2470msgstr ""
3049 2471
3050#: plugins/check_nwstat.c:1616
3051msgid "LOAD5 = 5 minute average CPU load" 2472msgid "LOAD5 = 5 minute average CPU load"
3052msgstr "" 2473msgstr ""
3053 2474
3054#: plugins/check_nwstat.c:1617
3055msgid "LOAD15 = 15 minute average CPU load" 2475msgid "LOAD15 = 15 minute average CPU load"
3056msgstr "" 2476msgstr ""
3057 2477
3058#: plugins/check_nwstat.c:1618
3059msgid "CSPROCS = number of current service processes (NW 5.x only)" 2478msgid "CSPROCS = number of current service processes (NW 5.x only)"
3060msgstr "" 2479msgstr ""
3061 2480
3062#: plugins/check_nwstat.c:1619
3063msgid "ABENDS = number of abended threads (NW 5.x only)" 2481msgid "ABENDS = number of abended threads (NW 5.x only)"
3064msgstr "" 2482msgstr ""
3065 2483
3066#: plugins/check_nwstat.c:1620
3067msgid "UPTIME = server uptime" 2484msgid "UPTIME = server uptime"
3068msgstr "" 2485msgstr ""
3069 2486
3070#: plugins/check_nwstat.c:1621
3071msgid "LTCH = percent long term cache hits" 2487msgid "LTCH = percent long term cache hits"
3072msgstr "" 2488msgstr ""
3073 2489
3074#: plugins/check_nwstat.c:1622
3075msgid "CBUFF = current number of cache buffers" 2490msgid "CBUFF = current number of cache buffers"
3076msgstr "" 2491msgstr ""
3077 2492
3078#: plugins/check_nwstat.c:1623
3079msgid "CDBUFF = current number of dirty cache buffers" 2493msgid "CDBUFF = current number of dirty cache buffers"
3080msgstr "" 2494msgstr ""
3081 2495
3082#: plugins/check_nwstat.c:1624
3083msgid "DCB = dirty cache buffers as a percentage of the total" 2496msgid "DCB = dirty cache buffers as a percentage of the total"
3084msgstr "" 2497msgstr ""
3085 2498
3086#: plugins/check_nwstat.c:1625
3087msgid "TCB = dirty cache buffers as a percentage of the original" 2499msgid "TCB = dirty cache buffers as a percentage of the original"
3088msgstr "" 2500msgstr ""
3089 2501
3090#: plugins/check_nwstat.c:1626
3091msgid "OFILES = number of open files" 2502msgid "OFILES = number of open files"
3092msgstr "" 2503msgstr ""
3093 2504
3094#: plugins/check_nwstat.c:1627
3095msgid " VMF<vol> = MB of free space on Volume <vol>" 2505msgid " VMF<vol> = MB of free space on Volume <vol>"
3096msgstr "" 2506msgstr ""
3097 2507
3098#: plugins/check_nwstat.c:1628
3099msgid " VMU<vol> = MB used space on Volume <vol>" 2508msgid " VMU<vol> = MB used space on Volume <vol>"
3100msgstr "" 2509msgstr ""
3101 2510
3102#: plugins/check_nwstat.c:1629
3103msgid " VMP<vol> = MB of purgeable space on Volume <vol>" 2511msgid " VMP<vol> = MB of purgeable space on Volume <vol>"
3104msgstr "" 2512msgstr ""
3105 2513
3106#: plugins/check_nwstat.c:1630
3107msgid " VPF<vol> = percent free space on volume <vol>" 2514msgid " VPF<vol> = percent free space on volume <vol>"
3108msgstr "" 2515msgstr ""
3109 2516
3110#: plugins/check_nwstat.c:1631
3111msgid " VKF<vol> = KB of free space on volume <vol>" 2517msgid " VKF<vol> = KB of free space on volume <vol>"
3112msgstr "" 2518msgstr ""
3113 2519
3114#: plugins/check_nwstat.c:1632
3115msgid " VPP<vol> = percent purgeable space on volume <vol>" 2520msgid " VPP<vol> = percent purgeable space on volume <vol>"
3116msgstr "" 2521msgstr ""
3117 2522
3118#: plugins/check_nwstat.c:1633
3119msgid " VKP<vol> = KB of purgeable space on volume <vol>" 2523msgid " VKP<vol> = KB of purgeable space on volume <vol>"
3120msgstr "" 2524msgstr ""
3121 2525
3122#: plugins/check_nwstat.c:1634
3123msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>" 2526msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>"
3124msgstr "" 2527msgstr ""
3125 2528
3126#: plugins/check_nwstat.c:1635
3127msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>" 2529msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>"
3128msgstr "" 2530msgstr ""
3129 2531
3130#: plugins/check_nwstat.c:1636
3131msgid " LRUM = LRU sitting time in minutes" 2532msgid " LRUM = LRU sitting time in minutes"
3132msgstr "" 2533msgstr ""
3133 2534
3134#: plugins/check_nwstat.c:1637
3135msgid " LRUS = LRU sitting time in seconds" 2535msgid " LRUS = LRU sitting time in seconds"
3136msgstr "" 2536msgstr ""
3137 2537
3138#: plugins/check_nwstat.c:1638
3139msgid " DSDB = check to see if DS Database is open" 2538msgid " DSDB = check to see if DS Database is open"
3140msgstr "" 2539msgstr ""
3141 2540
3142#: plugins/check_nwstat.c:1639
3143msgid " DSVER = NDS version" 2541msgid " DSVER = NDS version"
3144msgstr "" 2542msgstr ""
3145 2543
3146#: plugins/check_nwstat.c:1640
3147msgid " UPRB = used packet receive buffers" 2544msgid " UPRB = used packet receive buffers"
3148msgstr "" 2545msgstr ""
3149 2546
3150#: plugins/check_nwstat.c:1641
3151msgid " PUPRB = percent (of max) used packet receive buffers" 2547msgid " PUPRB = percent (of max) used packet receive buffers"
3152msgstr "" 2548msgstr ""
3153 2549
3154#: plugins/check_nwstat.c:1642
3155msgid " SAPENTRIES = number of entries in the SAP table" 2550msgid " SAPENTRIES = number of entries in the SAP table"
3156msgstr "" 2551msgstr ""
3157 2552
3158#: plugins/check_nwstat.c:1643
3159msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>" 2553msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"
3160msgstr "" 2554msgstr ""
3161 2555
3162#: plugins/check_nwstat.c:1644
3163msgid " TSYNC = timesync status" 2556msgid " TSYNC = timesync status"
3164msgstr "" 2557msgstr ""
3165 2558
3166#: plugins/check_nwstat.c:1645
3167msgid " LOGINS = check to see if logins are enabled" 2559msgid " LOGINS = check to see if logins are enabled"
3168msgstr "" 2560msgstr ""
3169 2561
3170#: plugins/check_nwstat.c:1646
3171msgid " CONNS = number of currently licensed connections" 2562msgid " CONNS = number of currently licensed connections"
3172msgstr "" 2563msgstr ""
3173 2564
3174#: plugins/check_nwstat.c:1647
3175msgid " NRMH\t= NRM Summary Status" 2565msgid " NRMH\t= NRM Summary Status"
3176msgstr "" 2566msgstr ""
3177 2567
3178#: plugins/check_nwstat.c:1648
3179msgid " NRMP<stat> = Returns the current value for a NRM health item" 2568msgid " NRMP<stat> = Returns the current value for a NRM health item"
3180msgstr "" 2569msgstr ""
3181 2570
3182#: plugins/check_nwstat.c:1649
3183msgid " NRMM<stat> = Returns the current memory stats from NRM" 2571msgid " NRMM<stat> = Returns the current memory stats from NRM"
3184msgstr "" 2572msgstr ""
3185 2573
3186#: plugins/check_nwstat.c:1650
3187msgid " NRMS<stat> = Returns the current Swapfile stats from NRM" 2574msgid " NRMS<stat> = Returns the current Swapfile stats from NRM"
3188msgstr "" 2575msgstr ""
3189 2576
3190#: plugins/check_nwstat.c:1651
3191msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml" 2577msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"
3192msgstr "" 2578msgstr ""
3193 2579
3194#: plugins/check_nwstat.c:1652
3195msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml" 2580msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"
3196msgstr "" 2581msgstr ""
3197 2582
3198#: plugins/check_nwstat.c:1653
3199msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml" 2583msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"
3200msgstr "" 2584msgstr ""
3201 2585
3202#: plugins/check_nwstat.c:1654
3203msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml" 2586msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"
3204msgstr "" 2587msgstr ""
3205 2588
3206#: plugins/check_nwstat.c:1655
3207msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml" 2589msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"
3208msgstr "" 2590msgstr ""
3209 2591
3210#: plugins/check_nwstat.c:1656
3211msgid "" 2592msgid ""
3212" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml" 2593" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"
3213msgstr "" 2594msgstr ""
3214 2595
3215#: plugins/check_nwstat.c:1657
3216msgid " NLM:<nlm> = check if NLM is loaded and report version" 2596msgid " NLM:<nlm> = check if NLM is loaded and report version"
3217msgstr "" 2597msgstr ""
3218 2598
3219#: plugins/check_nwstat.c:1658
3220msgid " (e.g. NLM:TSANDS.NLM)" 2599msgid " (e.g. NLM:TSANDS.NLM)"
3221msgstr "" 2600msgstr ""
3222 2601
3223#: plugins/check_nwstat.c:1665
3224msgid "Include server version string in results" 2602msgid "Include server version string in results"
3225msgstr "" 2603msgstr ""
3226 2604
3227#: plugins/check_nwstat.c:1671 2605msgid "- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"
3228msgid "- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"
3229msgstr "" 2606msgstr ""
3230 2607
3231#: plugins/check_nwstat.c:1672
3232msgid "" 2608msgid ""
3233" extension for NetWare be loaded on the Novell servers you wish to check." 2609" extension for NetWare be loaded on the Novell servers you wish to check."
3234msgstr "" 2610msgstr ""
3235 2611
3236#: plugins/check_nwstat.c:1673
3237msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)" 2612msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)"
3238msgstr "" 2613msgstr ""
3239 2614
3240#: plugins/check_nwstat.c:1674
3241msgid "" 2615msgid ""
3242"- Values for critical thresholds should be lower than warning thresholds" 2616"- Values for critical thresholds should be lower than warning thresholds"
3243msgstr "" 2617msgstr ""
3244 2618
3245#: plugins/check_nwstat.c:1675
3246msgid "" 2619msgid ""
3247" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, " 2620" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "
3248msgstr "" 2621msgstr ""
3249 2622
3250#: plugins/check_nwstat.c:1676
3251msgid " TCB, LRUS and LRUM." 2623msgid " TCB, LRUS and LRUM."
3252msgstr "" 2624msgstr ""
3253 2625
3254#: plugins/check_overcr.c:123
3255msgid "Unknown error fetching load data\n" 2626msgid "Unknown error fetching load data\n"
3256msgstr "" 2627msgstr ""
3257 2628
3258#: plugins/check_overcr.c:127
3259msgid "Invalid response from server - no load information\n" 2629msgid "Invalid response from server - no load information\n"
3260msgstr "" 2630msgstr ""
3261 2631
3262#: plugins/check_overcr.c:133
3263msgid "Invalid response from server after load 1\n" 2632msgid "Invalid response from server after load 1\n"
3264msgstr "" 2633msgstr ""
3265 2634
3266#: plugins/check_overcr.c:139
3267msgid "Invalid response from server after load 5\n" 2635msgid "Invalid response from server after load 5\n"
3268msgstr "" 2636msgstr ""
3269 2637
3270#: plugins/check_overcr.c:164
3271#, c-format 2638#, c-format
3272msgid "Load %s - %s-min load average = %0.2f" 2639msgid "Load %s - %s-min load average = %0.2f"
3273msgstr "" 2640msgstr ""
3274 2641
3275#: plugins/check_overcr.c:174
3276msgid "Unknown error fetching disk data\n" 2642msgid "Unknown error fetching disk data\n"
3277msgstr "" 2643msgstr ""
3278 2644
3279#: plugins/check_overcr.c:184 plugins/check_overcr.c:236
3280#: plugins/check_overcr.c:240
3281msgid "Invalid response from server\n" 2645msgid "Invalid response from server\n"
3282msgstr "" 2646msgstr ""
3283 2647
3284#: plugins/check_overcr.c:211
3285msgid "Unknown error fetching network status\n" 2648msgid "Unknown error fetching network status\n"
3286msgstr "" 2649msgstr ""
3287 2650
3288#: plugins/check_overcr.c:221
3289#, c-format 2651#, c-format
3290msgid "Net %s - %d connection%s on port %d" 2652msgid "Net %s - %d connection%s on port %d"
3291msgstr "" 2653msgstr ""
3292 2654
3293#: plugins/check_overcr.c:232
3294msgid "Unknown error fetching process status\n" 2655msgid "Unknown error fetching process status\n"
3295msgstr "" 2656msgstr ""
3296 2657
3297#: plugins/check_overcr.c:250
3298#, c-format 2658#, c-format
3299msgid "Process %s - %d instance%s of %s running" 2659msgid "Process %s - %d instance%s of %s running"
3300msgstr "" 2660msgstr ""
3301 2661
3302#: plugins/check_overcr.c:277
3303#, c-format 2662#, c-format
3304msgid "Uptime %s - Up %d days %d hours %d minutes" 2663msgid "Uptime %s - Up %d days %d hours %d minutes"
3305msgstr "" 2664msgstr ""
3306 2665
3307#: plugins/check_overcr.c:419
3308msgid "" 2666msgid ""
3309"This plugin attempts to contact the Over-CR collector daemon running on the" 2667"This plugin attempts to contact the Over-CR collector daemon running on the"
3310msgstr "" 2668msgstr ""
3311 2669
3312#: plugins/check_overcr.c:420
3313msgid "remote UNIX server in order to gather the requested system information." 2670msgid "remote UNIX server in order to gather the requested system information."
3314msgstr "" 2671msgstr ""
3315 2672
3316#: plugins/check_overcr.c:437
3317msgid "LOAD1 = 1 minute average CPU load" 2673msgid "LOAD1 = 1 minute average CPU load"
3318msgstr "" 2674msgstr ""
3319 2675
3320#: plugins/check_overcr.c:438
3321msgid "LOAD5 = 5 minute average CPU load" 2676msgid "LOAD5 = 5 minute average CPU load"
3322msgstr "" 2677msgstr ""
3323 2678
3324#: plugins/check_overcr.c:439
3325msgid "LOAD15 = 15 minute average CPU load" 2679msgid "LOAD15 = 15 minute average CPU load"
3326msgstr "" 2680msgstr ""
3327 2681
3328#: plugins/check_overcr.c:440
3329msgid "DPU<filesys> = percent used disk space on filesystem <filesys>" 2682msgid "DPU<filesys> = percent used disk space on filesystem <filesys>"
3330msgstr "" 2683msgstr ""
3331 2684
3332#: plugins/check_overcr.c:441
3333msgid "PROC<process> = number of running processes with name <process>" 2685msgid "PROC<process> = number of running processes with name <process>"
3334msgstr "" 2686msgstr ""
3335 2687
3336#: plugins/check_overcr.c:442
3337msgid "NET<port> = number of active connections on TCP port <port>" 2688msgid "NET<port> = number of active connections on TCP port <port>"
3338msgstr "" 2689msgstr ""
3339 2690
3340#: plugins/check_overcr.c:443
3341msgid "UPTIME = system uptime in seconds" 2691msgid "UPTIME = system uptime in seconds"
3342msgstr "" 2692msgstr ""
3343 2693
3344#: plugins/check_overcr.c:450
3345msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be" 2694msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be"
3346msgstr "" 2695msgstr ""
3347 2696
3348#: plugins/check_overcr.c:451
3349msgid "running on the remote server." 2697msgid "running on the remote server."
3350msgstr "" 2698msgstr ""
3351 2699
3352#: plugins/check_overcr.c:452
3353msgid "Over-CR can be downloaded from http://www.molitor.org/overcr" 2700msgid "Over-CR can be downloaded from http://www.molitor.org/overcr"
3354msgstr "" 2701msgstr ""
3355 2702
3356#: plugins/check_overcr.c:453
3357msgid "This plugin was tested with version 0.99.53 of the Over-CR collector" 2703msgid "This plugin was tested with version 0.99.53 of the Over-CR collector"
3358msgstr "" 2704msgstr ""
3359 2705
3360#: plugins/check_overcr.c:457
3361msgid "" 2706msgid ""
3362"For the available options, the critical threshold value should always be" 2707"For the available options, the critical threshold value should always be"
3363msgstr "" 2708msgstr ""
3364 2709
3365#: plugins/check_overcr.c:458
3366msgid "" 2710msgid ""
3367"higher than the warning threshold value, EXCEPT with the uptime variable" 2711"higher than the warning threshold value, EXCEPT with the uptime variable"
3368msgstr "" 2712msgstr ""
3369 2713
3370#: plugins/check_pgsql.c:222
3371#, c-format 2714#, c-format
3372msgid "CRITICAL - no connection to '%s' (%s).\n" 2715msgid "CRITICAL - no connection to '%s' (%s).\n"
3373msgstr "" 2716msgstr ""
3374 2717
3375#: plugins/check_pgsql.c:250
3376#, c-format 2718#, c-format
3377msgid " %s - database %s (%f sec.)|%s\n" 2719msgid " %s - database %s (%f sec.)|%s\n"
3378msgstr "" 2720msgstr ""
3379 2721
3380#: plugins/check_pgsql.c:317 plugins/check_time.c:277 plugins/check_time.c:289
3381#: plugins/check_users.c:181
3382msgid "Critical threshold must be a positive integer" 2722msgid "Critical threshold must be a positive integer"
3383msgstr "" 2723msgstr ""
3384 2724
3385#: plugins/check_pgsql.c:323 plugins/check_time.c:258 plugins/check_time.c:282
3386#: plugins/check_users.c:187 plugins/check_users.c:197
3387#: plugins/check_users.c:203
3388msgid "Warning threshold must be a positive integer" 2725msgid "Warning threshold must be a positive integer"
3389msgstr "" 2726msgstr ""
3390 2727
3391#: plugins/check_pgsql.c:347 2728msgid "Database name exceeds the maximum length"
3392msgid "Database name is not valid"
3393msgstr "" 2729msgstr ""
3394 2730
3395#: plugins/check_pgsql.c:353
3396msgid "User name is not valid" 2731msgid "User name is not valid"
3397msgstr "" 2732msgstr ""
3398 2733
3399#: plugins/check_pgsql.c:504
3400#, c-format 2734#, c-format
3401msgid "Test whether a PostgreSQL Database is accepting connections." 2735msgid "Test whether a PostgreSQL Database is accepting connections."
3402msgstr "" 2736msgstr ""
3403 2737
3404#: plugins/check_pgsql.c:516
3405msgid "Database to check " 2738msgid "Database to check "
3406msgstr "" 2739msgstr ""
3407 2740
3408#: plugins/check_pgsql.c:517
3409#, c-format 2741#, c-format
3410msgid "(default: %s)" 2742msgid "(default: %s)\n"
3411msgstr "" 2743msgstr ""
3412 2744
3413#: plugins/check_pgsql.c:519
3414msgid "Login name of user" 2745msgid "Login name of user"
3415msgstr "" 2746msgstr ""
3416 2747
3417#: plugins/check_pgsql.c:521
3418msgid "Password (BIG SECURITY ISSUE)" 2748msgid "Password (BIG SECURITY ISSUE)"
3419msgstr "" 2749msgstr ""
3420 2750
3421#: plugins/check_pgsql.c:523
3422msgid "Connection parameters (keyword = value), see below" 2751msgid "Connection parameters (keyword = value), see below"
3423msgstr "" 2752msgstr ""
3424 2753
3425#: plugins/check_pgsql.c:530
3426msgid "SQL query to run. Only first column in first row will be read" 2754msgid "SQL query to run. Only first column in first row will be read"
3427msgstr "" 2755msgstr ""
3428 2756
3429#: plugins/check_pgsql.c:532 2757msgid "A name for the query, this string is used instead of the query"
2758msgstr ""
2759
2760msgid "in the long output of the plugin"
2761msgstr ""
2762
3430msgid "SQL query value to result in warning status (double)" 2763msgid "SQL query value to result in warning status (double)"
3431msgstr "" 2764msgstr ""
3432 2765
3433#: plugins/check_pgsql.c:534
3434msgid "SQL query value to result in critical status (double)" 2766msgid "SQL query value to result in critical status (double)"
3435msgstr "" 2767msgstr ""
3436 2768
3437#: plugins/check_pgsql.c:539
3438msgid "All parameters are optional." 2769msgid "All parameters are optional."
3439msgstr "" 2770msgstr ""
3440 2771
3441#: plugins/check_pgsql.c:540
3442msgid "" 2772msgid ""
3443"This plugin tests a PostgreSQL DBMS to determine whether it is active and" 2773"This plugin tests a PostgreSQL DBMS to determine whether it is active and"
3444msgstr "" 2774msgstr ""
3445 2775
3446#: plugins/check_pgsql.c:541
3447msgid "accepting queries. In its current operation, it simply connects to the" 2776msgid "accepting queries. In its current operation, it simply connects to the"
3448msgstr "" 2777msgstr ""
3449 2778
3450#: plugins/check_pgsql.c:542
3451msgid "" 2779msgid ""
3452"specified database, and then disconnects. If no database is specified, it" 2780"specified database, and then disconnects. If no database is specified, it"
3453msgstr "" 2781msgstr ""
3454 2782
3455#: plugins/check_pgsql.c:543
3456msgid "" 2783msgid ""
3457"connects to the template1 database, which is present in every functioning" 2784"connects to the template1 database, which is present in every functioning"
3458msgstr "" 2785msgstr ""
3459 2786
3460#: plugins/check_pgsql.c:544
3461msgid "PostgreSQL DBMS." 2787msgid "PostgreSQL DBMS."
3462msgstr "" 2788msgstr ""
3463 2789
3464#: plugins/check_pgsql.c:546
3465msgid "If a query is specified using the -q option, it will be executed after" 2790msgid "If a query is specified using the -q option, it will be executed after"
3466msgstr "" 2791msgstr ""
3467 2792
3468#: plugins/check_pgsql.c:547
3469msgid "connecting to the server. The result from the query has to be numeric." 2793msgid "connecting to the server. The result from the query has to be numeric."
3470msgstr "" 2794msgstr ""
3471 2795
3472#: plugins/check_pgsql.c:548
3473msgid "" 2796msgid ""
3474"Multiple SQL commands, separated by semicolon, are allowed but the result " 2797"Multiple SQL commands, separated by semicolon, are allowed but the result "
3475msgstr "" 2798msgstr ""
3476 2799
3477#: plugins/check_pgsql.c:549
3478msgid "of the last command is taken into account only. The value of the first" 2800msgid "of the last command is taken into account only. The value of the first"
3479msgstr "" 2801msgstr ""
3480 2802
3481#: plugins/check_pgsql.c:550 2803msgid ""
3482msgid "column in the first row is used as the check result." 2804"column in the first row is used as the check result. If a second column is"
2805msgstr ""
2806
2807msgid "present in the result set, this is added to the plugin output with a"
2808msgstr ""
2809
2810msgid ""
2811"prefix of \"Extra Info:\". This information can be displayed in the system"
2812msgstr ""
2813
2814msgid "executing the plugin."
3483msgstr "" 2815msgstr ""
3484 2816
3485#: plugins/check_pgsql.c:552
3486msgid "" 2817msgid ""
3487"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual" 2818"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"
3488msgstr "" 2819msgstr ""
3489 2820
3490#: plugins/check_pgsql.c:553
3491msgid "" 2821msgid ""
3492"for details about how to access internal statistics of the database server." 2822"for details about how to access internal statistics of the database server."
3493msgstr "" 2823msgstr ""
3494 2824
3495#: plugins/check_pgsql.c:555
3496msgid "" 2825msgid ""
3497"For a list of available connection parameters which may be used with the -o" 2826"For a list of available connection parameters which may be used with the -o"
3498msgstr "" 2827msgstr ""
3499 2828
3500#: plugins/check_pgsql.c:556
3501msgid "" 2829msgid ""
3502"command line option, see the documentation for PQconnectdb() in the chapter" 2830"command line option, see the documentation for PQconnectdb() in the chapter"
3503msgstr "" 2831msgstr ""
3504 2832
3505#: plugins/check_pgsql.c:557
3506msgid "" 2833msgid ""
3507"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be" 2834"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"
3508msgstr "" 2835msgstr ""
3509 2836
3510#: plugins/check_pgsql.c:558
3511msgid "" 2837msgid ""
3512"used to specify a service name in pg_service.conf to be used for additional" 2838"used to specify a service name in pg_service.conf to be used for additional"
3513msgstr "" 2839msgstr ""
3514 2840
3515#: plugins/check_pgsql.c:559
3516msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:" 2841msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:"
3517msgstr "" 2842msgstr ""
3518 2843
3519#: plugins/check_pgsql.c:560
3520msgid "-o 'sslmode=require'." 2844msgid "-o 'sslmode=require'."
3521msgstr "" 2845msgstr ""
3522 2846
3523#: plugins/check_pgsql.c:562
3524msgid "" 2847msgid ""
3525"The plugin will connect to a local postmaster if no host is specified. To" 2848"The plugin will connect to a local postmaster if no host is specified. To"
3526msgstr "" 2849msgstr ""
3527 2850
3528#: plugins/check_pgsql.c:563
3529msgid "" 2851msgid ""
3530"connect to a remote host, be sure that the remote postmaster accepts TCP/IP" 2852"connect to a remote host, be sure that the remote postmaster accepts TCP/IP"
3531msgstr "" 2853msgstr ""
3532 2854
3533#: plugins/check_pgsql.c:564
3534msgid "connections (start the postmaster with the -i option)." 2855msgid "connections (start the postmaster with the -i option)."
3535msgstr "" 2856msgstr ""
3536 2857
3537#: plugins/check_pgsql.c:566
3538msgid "" 2858msgid ""
3539"Typically, the monitoring user (unless the --logname option is used) should " 2859"Typically, the monitoring user (unless the --logname option is used) should "
3540"be" 2860"be"
3541msgstr "" 2861msgstr ""
3542 2862
3543#: plugins/check_pgsql.c:567
3544msgid "" 2863msgid ""
3545"able to connect to the database without a password. The plugin can also send" 2864"able to connect to the database without a password. The plugin can also send"
3546msgstr "" 2865msgstr ""
3547 2866
3548#: plugins/check_pgsql.c:568 2867msgid "a password, but no effort is made to obscure or encrypt the password."
3549msgid "a password, but no effort is made to obsure or encrypt the password."
3550msgstr "" 2868msgstr ""
3551 2869
3552#: plugins/check_pgsql.c:601
3553#, c-format 2870#, c-format
3554msgid "QUERY %s - %s: %s.\n" 2871msgid "QUERY %s - %s: %s.\n"
3555msgstr "" 2872msgstr ""
3556 2873
3557#: plugins/check_pgsql.c:601
3558msgid "Error with query" 2874msgid "Error with query"
3559msgstr "" 2875msgstr ""
3560 2876
3561#: plugins/check_pgsql.c:607
3562msgid "No rows returned" 2877msgid "No rows returned"
3563msgstr "" 2878msgstr ""
3564 2879
3565#: plugins/check_pgsql.c:612
3566msgid "No columns returned" 2880msgid "No columns returned"
3567msgstr "" 2881msgstr ""
3568 2882
3569#: plugins/check_pgsql.c:618
3570msgid "No data returned" 2883msgid "No data returned"
3571msgstr "" 2884msgstr ""
3572 2885
3573#: plugins/check_pgsql.c:627
3574msgid "Is not a numeric" 2886msgid "Is not a numeric"
3575msgstr "" 2887msgstr ""
3576 2888
3577#: plugins/check_pgsql.c:644 2889#, c-format
2890msgid "%s returned %f"
2891msgstr ""
2892
3578#, c-format 2893#, c-format
3579msgid "'%s' returned %f" 2894msgid "'%s' returned %f"
3580msgstr "" 2895msgstr ""
3581 2896
3582#: plugins/check_ping.c:141
3583msgid "CRITICAL - Could not interpret output from ping command\n" 2897msgid "CRITICAL - Could not interpret output from ping command\n"
3584msgstr "" 2898msgstr ""
3585 2899
3586#: plugins/check_ping.c:157
3587#, c-format 2900#, c-format
3588msgid "PING %s - %sPacket loss = %d%%" 2901msgid "PING %s - %sPacket loss = %d%%"
3589msgstr "" 2902msgstr ""
3590 2903
3591#: plugins/check_ping.c:160
3592#, c-format 2904#, c-format
3593msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms" 2905msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"
3594msgstr "" 2906msgstr ""
3595 2907
3596#: plugins/check_ping.c:257
3597msgid "Could not realloc() addresses\n" 2908msgid "Could not realloc() addresses\n"
3598msgstr "" 2909msgstr ""
3599 2910
3600#: plugins/check_ping.c:272 plugins/check_ping.c:352
3601#, c-format 2911#, c-format
3602msgid "<max_packets> (%s) must be a non-negative number\n" 2912msgid "<max_packets> (%s) must be a non-negative number\n"
3603msgstr "" 2913msgstr ""
3604 2914
3605#: plugins/check_ping.c:306
3606#, c-format 2915#, c-format
3607msgid "<wpl> (%s) must be an integer percentage\n" 2916msgid "<wpl> (%s) must be an integer percentage\n"
3608msgstr "" 2917msgstr ""
3609 2918
3610#: plugins/check_ping.c:317
3611#, c-format 2919#, c-format
3612msgid "<cpl> (%s) must be an integer percentage\n" 2920msgid "<cpl> (%s) must be an integer percentage\n"
3613msgstr "" 2921msgstr ""
3614 2922
3615#: plugins/check_ping.c:328
3616#, c-format 2923#, c-format
3617msgid "<wrta> (%s) must be a non-negative number\n" 2924msgid "<wrta> (%s) must be a non-negative number\n"
3618msgstr "" 2925msgstr ""
3619 2926
3620#: plugins/check_ping.c:339
3621#, c-format 2927#, c-format
3622msgid "<crta> (%s) must be a non-negative number\n" 2928msgid "<crta> (%s) must be a non-negative number\n"
3623msgstr "" 2929msgstr ""
3624 2930
3625#: plugins/check_ping.c:372
3626#, c-format 2931#, c-format
3627msgid "" 2932msgid ""
3628"%s: Warning threshold must be integer or percentage!\n" 2933"%s: Warning threshold must be integer or percentage!\n"
3629"\n" 2934"\n"
3630msgstr "" 2935msgstr ""
3631 2936
3632#: plugins/check_ping.c:385
3633#, c-format 2937#, c-format
3634msgid "<wrta> was not set\n" 2938msgid "<wrta> was not set\n"
3635msgstr "" 2939msgstr ""
3636 2940
3637#: plugins/check_ping.c:389
3638#, c-format 2941#, c-format
3639msgid "<crta> was not set\n" 2942msgid "<crta> was not set\n"
3640msgstr "" 2943msgstr ""
3641 2944
3642#: plugins/check_ping.c:393
3643#, c-format 2945#, c-format
3644msgid "<wpl> was not set\n" 2946msgid "<wpl> was not set\n"
3645msgstr "" 2947msgstr ""
3646 2948
3647#: plugins/check_ping.c:397
3648#, c-format 2949#, c-format
3649msgid "<cpl> was not set\n" 2950msgid "<cpl> was not set\n"
3650msgstr "" 2951msgstr ""
3651 2952
3652#: plugins/check_ping.c:401
3653#, c-format 2953#, c-format
3654msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n" 2954msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n"
3655msgstr "" 2955msgstr ""
3656 2956
3657#: plugins/check_ping.c:405
3658#, c-format 2957#, c-format
3659msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n" 2958msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n"
3660msgstr "" 2959msgstr ""
3661 2960
3662#: plugins/check_ping.c:442
3663#, c-format 2961#, c-format
3664msgid "Cannot open stderr for %s\n" 2962msgid "Cannot open stderr for %s\n"
3665msgstr "" 2963msgstr ""
3666 2964
3667#: plugins/check_ping.c:492 plugins/check_ping.c:494
3668msgid "System call sent warnings to stderr " 2965msgid "System call sent warnings to stderr "
3669msgstr "" 2966msgstr ""
3670 2967
3671#: plugins/check_ping.c:519
3672#, c-format 2968#, c-format
3673msgid "CRITICAL - Network Unreachable (%s)\n" 2969msgid "CRITICAL - Network Unreachable (%s)\n"
3674msgstr "" 2970msgstr ""
3675 2971
3676#: plugins/check_ping.c:521
3677#, c-format 2972#, c-format
3678msgid "CRITICAL - Host Unreachable (%s)\n" 2973msgid "CRITICAL - Host Unreachable (%s)\n"
3679msgstr "" 2974msgstr ""
3680 2975
3681#: plugins/check_ping.c:523
3682#, c-format 2976#, c-format
3683msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n" 2977msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"
3684msgstr "" 2978msgstr ""
3685 2979
3686#: plugins/check_ping.c:525
3687#, c-format 2980#, c-format
3688msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n" 2981msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"
3689msgstr "" 2982msgstr ""
3690 2983
3691#: plugins/check_ping.c:527
3692#, c-format 2984#, c-format
3693msgid "CRITICAL - Network Prohibited (%s)\n" 2985msgid "CRITICAL - Network Prohibited (%s)\n"
3694msgstr "" 2986msgstr ""
3695 2987
3696#: plugins/check_ping.c:529
3697#, c-format 2988#, c-format
3698msgid "CRITICAL - Host Prohibited (%s)\n" 2989msgid "CRITICAL - Host Prohibited (%s)\n"
3699msgstr "" 2990msgstr ""
3700 2991
3701#: plugins/check_ping.c:531
3702#, c-format 2992#, c-format
3703msgid "CRITICAL - Packet Filtered (%s)\n" 2993msgid "CRITICAL - Packet Filtered (%s)\n"
3704msgstr "" 2994msgstr ""
3705 2995
3706#: plugins/check_ping.c:533
3707#, c-format 2996#, c-format
3708msgid "CRITICAL - Host not found (%s)\n" 2997msgid "CRITICAL - Host not found (%s)\n"
3709msgstr "" 2998msgstr ""
3710 2999
3711#: plugins/check_ping.c:535
3712#, c-format 3000#, c-format
3713msgid "CRITICAL - Time to live exceeded (%s)\n" 3001msgid "CRITICAL - Time to live exceeded (%s)\n"
3714msgstr "" 3002msgstr ""
3715 3003
3716#: plugins/check_ping.c:537
3717#, c-format 3004#, c-format
3718msgid "CRITICAL - Destination Unreachable (%s)\n" 3005msgid "CRITICAL - Destination Unreachable (%s)\n"
3719msgstr "" 3006msgstr ""
3720 3007
3721#: plugins/check_ping.c:544
3722msgid "Unable to realloc warn_text\n" 3008msgid "Unable to realloc warn_text\n"
3723msgstr "" 3009msgstr ""
3724 3010
3725#: plugins/check_ping.c:561
3726#, c-format 3011#, c-format
3727msgid "Use ping to check connection statistics for a remote host." 3012msgid "Use ping to check connection statistics for a remote host."
3728msgstr "" 3013msgstr ""
3729 3014
3730#: plugins/check_ping.c:573
3731msgid "host to ping" 3015msgid "host to ping"
3732msgstr "" 3016msgstr ""
3733 3017
3734#: plugins/check_ping.c:579
3735msgid "number of ICMP ECHO packets to send" 3018msgid "number of ICMP ECHO packets to send"
3736msgstr "" 3019msgstr ""
3737 3020
3738#: plugins/check_ping.c:580
3739#, c-format 3021#, c-format
3740msgid "(Default: %d)\n" 3022msgid "(Default: %d)\n"
3741msgstr "" 3023msgstr ""
3742 3024
3743#: plugins/check_ping.c:582
3744msgid "show HTML in the plugin output (obsoleted by urlize)" 3025msgid "show HTML in the plugin output (obsoleted by urlize)"
3745msgstr "" 3026msgstr ""
3746 3027
3747#: plugins/check_ping.c:587
3748msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel" 3028msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"
3749msgstr "" 3029msgstr ""
3750 3030
3751#: plugins/check_ping.c:588
3752msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the" 3031msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"
3753msgstr "" 3032msgstr ""
3754 3033
3755#: plugins/check_ping.c:589
3756msgid "percentage of packet loss to trigger an alarm state." 3034msgid "percentage of packet loss to trigger an alarm state."
3757msgstr "" 3035msgstr ""
3758 3036
3759#: plugins/check_ping.c:592
3760msgid "" 3037msgid ""
3761"This plugin uses the ping command to probe the specified host for packet loss" 3038"This plugin uses the ping command to probe the specified host for packet loss"
3762msgstr "" 3039msgstr ""
3763 3040
3764#: plugins/check_ping.c:593
3765msgid "" 3041msgid ""
3766"(percentage) and round trip average (milliseconds). It can produce HTML " 3042"(percentage) and round trip average (milliseconds). It can produce HTML "
3767"output" 3043"output"
3768msgstr "" 3044msgstr ""
3769 3045
3770#: plugins/check_ping.c:594
3771msgid "" 3046msgid ""
3772"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in" 3047"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"
3773msgstr "" 3048msgstr ""
3774 3049
3775#: plugins/check_ping.c:595
3776msgid "the contrib area of the downloads section at http://www.nagios.org/" 3050msgid "the contrib area of the downloads section at http://www.nagios.org/"
3777msgstr "" 3051msgstr ""
3778 3052
3779#: plugins/check_procs.c:193
3780#, c-format 3053#, c-format
3781msgid "CMD: %s\n" 3054msgid "CMD: %s\n"
3782msgstr "" 3055msgstr ""
3783 3056
3784#: plugins/check_procs.c:198
3785msgid "System call sent warnings to stderr" 3057msgid "System call sent warnings to stderr"
3786msgstr "" 3058msgstr ""
3787 3059
3788#: plugins/check_procs.c:326
3789#, c-format 3060#, c-format
3790msgid "Not parseable: %s" 3061msgid "Not parseable: %s"
3791msgstr "" 3062msgstr ""
3792 3063
3793#: plugins/check_procs.c:331
3794#, c-format 3064#, c-format
3795msgid "Unable to read output\n" 3065msgid "Unable to read output\n"
3796msgstr "" 3066msgstr ""
3797 3067
3798#: plugins/check_procs.c:348
3799#, c-format 3068#, c-format
3800msgid "%d warn out of " 3069msgid "%d warn out of "
3801msgstr "" 3070msgstr ""
3802 3071
3803#: plugins/check_procs.c:353
3804#, c-format 3072#, c-format
3805msgid "%d crit, %d warn out of " 3073msgid "%d crit, %d warn out of "
3806msgstr "" 3074msgstr ""
3807 3075
3808#: plugins/check_procs.c:359
3809#, c-format 3076#, c-format
3810msgid " with %s" 3077msgid " with %s"
3811msgstr "" 3078msgstr ""
3812 3079
3813#: plugins/check_procs.c:453
3814msgid "Parent Process ID must be an integer!" 3080msgid "Parent Process ID must be an integer!"
3815msgstr "" 3081msgstr ""
3816 3082
3817#: plugins/check_procs.c:459 plugins/check_procs.c:586
3818#, c-format 3083#, c-format
3819msgid "%s%sSTATE = %s" 3084msgid "%s%sSTATE = %s"
3820msgstr "" 3085msgstr ""
3821 3086
3822#: plugins/check_procs.c:468
3823msgid "UID was not found" 3087msgid "UID was not found"
3824msgstr "" 3088msgstr ""
3825 3089
3826#: plugins/check_procs.c:474
3827msgid "User name was not found" 3090msgid "User name was not found"
3828msgstr "" 3091msgstr ""
3829 3092
3830#: plugins/check_procs.c:489
3831#, c-format 3093#, c-format
3832msgid "%s%scommand name '%s'" 3094msgid "%s%scommand name '%s'"
3833msgstr "" 3095msgstr ""
3834 3096
3835#: plugins/check_procs.c:524 3097#, c-format
3098msgid "%s%sexclude progs '%s'"
3099msgstr ""
3100
3836msgid "RSS must be an integer!" 3101msgid "RSS must be an integer!"
3837msgstr "" 3102msgstr ""
3838 3103
3839#: plugins/check_procs.c:531
3840msgid "VSZ must be an integer!" 3104msgid "VSZ must be an integer!"
3841msgstr "" 3105msgstr ""
3842 3106
3843#: plugins/check_procs.c:539
3844msgid "PCPU must be a float!" 3107msgid "PCPU must be a float!"
3845msgstr "" 3108msgstr ""
3846 3109
3847#: plugins/check_procs.c:563
3848msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!" 3110msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"
3849msgstr "" 3111msgstr ""
3850 3112
3851#: plugins/check_procs.c:694
3852msgid "" 3113msgid ""
3853"Checks all processes and generates WARNING or CRITICAL states if the " 3114"Checks all processes and generates WARNING or CRITICAL states if the "
3854"specified" 3115"specified"
3855msgstr "" 3116msgstr ""
3856 3117
3857#: plugins/check_procs.c:695
3858msgid "" 3118msgid ""
3859"metric is outside the required threshold ranges. The metric defaults to " 3119"metric is outside the required threshold ranges. The metric defaults to "
3860"number" 3120"number"
3861msgstr "" 3121msgstr ""
3862 3122
3863#: plugins/check_procs.c:696
3864msgid "" 3123msgid ""
3865"of processes. Search filters can be applied to limit the processes to check." 3124"of processes. Search filters can be applied to limit the processes to check."
3866msgstr "" 3125msgstr ""
3867 3126
3868#: plugins/check_procs.c:705
3869msgid "Generate warning state if metric is outside this range" 3127msgid "Generate warning state if metric is outside this range"
3870msgstr "" 3128msgstr ""
3871 3129
3872#: plugins/check_procs.c:707
3873msgid "Generate critical state if metric is outside this range" 3130msgid "Generate critical state if metric is outside this range"
3874msgstr "" 3131msgstr ""
3875 3132
3876#: plugins/check_procs.c:709
3877msgid "Check thresholds against metric. Valid types:" 3133msgid "Check thresholds against metric. Valid types:"
3878msgstr "" 3134msgstr ""
3879 3135
3880#: plugins/check_procs.c:710
3881msgid "PROCS - number of processes (default)" 3136msgid "PROCS - number of processes (default)"
3882msgstr "" 3137msgstr ""
3883 3138
3884#: plugins/check_procs.c:711
3885msgid "VSZ - virtual memory size" 3139msgid "VSZ - virtual memory size"
3886msgstr "" 3140msgstr ""
3887 3141
3888#: plugins/check_procs.c:712
3889msgid "RSS - resident set memory size" 3142msgid "RSS - resident set memory size"
3890msgstr "" 3143msgstr ""
3891 3144
3892#: plugins/check_procs.c:713
3893msgid "CPU - percentage CPU" 3145msgid "CPU - percentage CPU"
3894msgstr "" 3146msgstr ""
3895 3147
3896#: plugins/check_procs.c:716
3897msgid "ELAPSED - time elapsed in seconds" 3148msgid "ELAPSED - time elapsed in seconds"
3898msgstr "" 3149msgstr ""
3899 3150
3900#: plugins/check_procs.c:721
3901msgid "Extra information. Up to 3 verbosity levels" 3151msgid "Extra information. Up to 3 verbosity levels"
3902msgstr "" 3152msgstr ""
3903 3153
3904#: plugins/check_procs.c:724
3905msgid "Filter own process the traditional way by PID instead of /proc/pid/exe" 3154msgid "Filter own process the traditional way by PID instead of /proc/pid/exe"
3906msgstr "" 3155msgstr ""
3907 3156
3908#: plugins/check_procs.c:729
3909msgid "Only scan for processes that have, in the output of `ps`, one or" 3157msgid "Only scan for processes that have, in the output of `ps`, one or"
3910msgstr "" 3158msgstr ""
3911 3159
3912#: plugins/check_procs.c:730
3913msgid "more of the status flags you specify (for example R, Z, S, RS," 3160msgid "more of the status flags you specify (for example R, Z, S, RS,"
3914msgstr "" 3161msgstr ""
3915 3162
3916#: plugins/check_procs.c:731
3917msgid "RSZDT, plus others based on the output of your 'ps' command)." 3163msgid "RSZDT, plus others based on the output of your 'ps' command)."
3918msgstr "" 3164msgstr ""
3919 3165
3920#: plugins/check_procs.c:733
3921msgid "Only scan for children of the parent process ID indicated." 3166msgid "Only scan for children of the parent process ID indicated."
3922msgstr "" 3167msgstr ""
3923 3168
3924#: plugins/check_procs.c:735
3925msgid "Only scan for processes with VSZ higher than indicated." 3169msgid "Only scan for processes with VSZ higher than indicated."
3926msgstr "" 3170msgstr ""
3927 3171
3928#: plugins/check_procs.c:737
3929msgid "Only scan for processes with RSS higher than indicated." 3172msgid "Only scan for processes with RSS higher than indicated."
3930msgstr "" 3173msgstr ""
3931 3174
3932#: plugins/check_procs.c:739
3933msgid "Only scan for processes with PCPU higher than indicated." 3175msgid "Only scan for processes with PCPU higher than indicated."
3934msgstr "" 3176msgstr ""
3935 3177
3936#: plugins/check_procs.c:741
3937msgid "Only scan for processes with user name or ID indicated." 3178msgid "Only scan for processes with user name or ID indicated."
3938msgstr "" 3179msgstr ""
3939 3180
3940#: plugins/check_procs.c:743
3941msgid "Only scan for processes with args that contain STRING." 3181msgid "Only scan for processes with args that contain STRING."
3942msgstr "" 3182msgstr ""
3943 3183
3944#: plugins/check_procs.c:745
3945msgid "Only scan for processes with args that contain the regex STRING." 3184msgid "Only scan for processes with args that contain the regex STRING."
3946msgstr "" 3185msgstr ""
3947 3186
3948#: plugins/check_procs.c:747
3949msgid "Only scan for exact matches of COMMAND (without path)." 3187msgid "Only scan for exact matches of COMMAND (without path)."
3950msgstr "" 3188msgstr ""
3951 3189
3952#: plugins/check_procs.c:749 3190msgid "Exclude processes which match this comma separated list"
3191msgstr ""
3192
3953msgid "Only scan for non kernel threads (works on Linux only)." 3193msgid "Only scan for non kernel threads (works on Linux only)."
3954msgstr "" 3194msgstr ""
3955 3195
3956#: plugins/check_procs.c:751
3957#, c-format 3196#, c-format
3958msgid "" 3197msgid ""
3959"\n" 3198"\n"
@@ -3963,7 +3202,6 @@ msgid ""
3963"\n" 3202"\n"
3964msgstr "" 3203msgstr ""
3965 3204
3966#: plugins/check_procs.c:756
3967#, c-format 3205#, c-format
3968msgid "" 3206msgid ""
3969"This plugin checks the number of currently running processes and\n" 3207"This plugin checks the number of currently running processes and\n"
@@ -3974,1568 +3212,1332 @@ msgid ""
3974"\n" 3212"\n"
3975msgstr "" 3213msgstr ""
3976 3214
3977#: plugins/check_procs.c:765
3978msgid "Warning if not two processes with command name portsentry." 3215msgid "Warning if not two processes with command name portsentry."
3979msgstr "" 3216msgstr ""
3980 3217
3981#: plugins/check_procs.c:766
3982msgid "Critical if < 2 or > 1024 processes" 3218msgid "Critical if < 2 or > 1024 processes"
3983msgstr "" 3219msgstr ""
3984 3220
3985#: plugins/check_procs.c:768 3221msgid "Critical if not at least 1 process with command sshd"
3222msgstr ""
3223
3224msgid "Warning if > 1024 processes with command name sshd."
3225msgstr ""
3226
3227msgid "Critical if < 1 processes with command name sshd."
3228msgstr ""
3229
3986msgid "Warning alert if > 10 processes with command arguments containing" 3230msgid "Warning alert if > 10 processes with command arguments containing"
3987msgstr "" 3231msgstr ""
3988 3232
3989#: plugins/check_procs.c:769
3990msgid "'/usr/local/bin/perl' and owned by root" 3233msgid "'/usr/local/bin/perl' and owned by root"
3991msgstr "" 3234msgstr ""
3992 3235
3993#: plugins/check_procs.c:771
3994msgid "Alert if VSZ of any processes over 50K or 100K" 3236msgid "Alert if VSZ of any processes over 50K or 100K"
3995msgstr "" 3237msgstr ""
3996 3238
3997#: plugins/check_procs.c:773 3239msgid "Alert if CPU of any processes over 10% or 20%"
3998#, c-format
3999msgid "Alert if CPU of any processes over 10%% or 20%%"
4000msgstr "" 3240msgstr ""
4001 3241
4002#: plugins/check_radius.c:165 3242msgid "Config file error\n"
4003msgid "Config file error"
4004msgstr "" 3243msgstr ""
4005 3244
4006#: plugins/check_radius.c:174 3245msgid "Out of Memory?\n"
4007msgid "Out of Memory?"
4008msgstr "" 3246msgstr ""
4009 3247
4010#: plugins/check_radius.c:178 3248msgid "Invalid NAS-Identifier\n"
4011msgid "Invalid NAS-Identifier"
4012msgstr "" 3249msgstr ""
4013 3250
4014#: plugins/check_radius.c:183 plugins/check_radius.c:185 3251#, c-format
4015#: plugins/check_radius.c:191 3252msgid "gethostname() failed!\n"
4016msgid "Invalid NAS-IP-Address"
4017msgstr "" 3253msgstr ""
4018 3254
4019#: plugins/check_radius.c:188 3255msgid "Invalid NAS-IP-Address\n"
4020msgid "Can't find local IP for NAS-IP-Address"
4021msgstr "" 3256msgstr ""
4022 3257
4023#: plugins/check_radius.c:202 3258msgid "Timeout\n"
4024msgid "Timeout"
4025msgstr "" 3259msgstr ""
4026 3260
4027#: plugins/check_radius.c:204 3261msgid "Auth Error\n"
4028msgid "Auth Error"
4029msgstr "" 3262msgstr ""
4030 3263
4031#: plugins/check_radius.c:206 3264msgid "Auth Failed\n"
4032msgid "Auth Failed"
4033msgstr "" 3265msgstr ""
4034 3266
4035#: plugins/check_radius.c:208 3267msgid "Bad Response\n"
4036msgid "Bad Response"
4037msgstr "" 3268msgstr ""
4038 3269
4039#: plugins/check_radius.c:212 3270msgid "Auth OK\n"
4040msgid "Auth OK"
4041msgstr "" 3271msgstr ""
4042 3272
4043#: plugins/check_radius.c:213
4044#, c-format 3273#, c-format
4045msgid "Unexpected result code %d" 3274msgid "Unexpected result code %d"
4046msgstr "" 3275msgstr ""
4047 3276
4048#: plugins/check_radius.c:302
4049msgid "Number of retries must be a positive integer" 3277msgid "Number of retries must be a positive integer"
4050msgstr "" 3278msgstr ""
4051 3279
4052#: plugins/check_radius.c:316
4053msgid "User not specified" 3280msgid "User not specified"
4054msgstr "" 3281msgstr ""
4055 3282
4056#: plugins/check_radius.c:318
4057msgid "Password not specified" 3283msgid "Password not specified"
4058msgstr "" 3284msgstr ""
4059 3285
4060#: plugins/check_radius.c:320
4061msgid "Configuration file not specified" 3286msgid "Configuration file not specified"
4062msgstr "" 3287msgstr ""
4063 3288
4064#: plugins/check_radius.c:338
4065msgid "Tests to see if a RADIUS server is accepting connections." 3289msgid "Tests to see if a RADIUS server is accepting connections."
4066msgstr "" 3290msgstr ""
4067 3291
4068#: plugins/check_radius.c:350
4069msgid "The user to authenticate" 3292msgid "The user to authenticate"
4070msgstr "" 3293msgstr ""
4071 3294
4072#: plugins/check_radius.c:352 3295msgid "Password for authentication (SECURITY RISK)"
4073msgid "Password for autentication (SECURITY RISK)"
4074msgstr "" 3296msgstr ""
4075 3297
4076#: plugins/check_radius.c:354
4077msgid "NAS identifier" 3298msgid "NAS identifier"
4078msgstr "" 3299msgstr ""
4079 3300
4080#: plugins/check_radius.c:356
4081msgid "NAS IP Address" 3301msgid "NAS IP Address"
4082msgstr "" 3302msgstr ""
4083 3303
4084#: plugins/check_radius.c:358
4085msgid "Configuration file" 3304msgid "Configuration file"
4086msgstr "" 3305msgstr ""
4087 3306
4088#: plugins/check_radius.c:360
4089msgid "Response string to expect from the server" 3307msgid "Response string to expect from the server"
4090msgstr "" 3308msgstr ""
4091 3309
4092#: plugins/check_radius.c:362
4093msgid "Number of times to retry a failed connection" 3310msgid "Number of times to retry a failed connection"
4094msgstr "" 3311msgstr ""
4095 3312
4096#: plugins/check_radius.c:367
4097msgid "" 3313msgid ""
4098"This plugin tests a RADIUS server to see if it is accepting connections." 3314"This plugin tests a RADIUS server to see if it is accepting connections."
4099msgstr "" 3315msgstr ""
4100 3316
4101#: plugins/check_radius.c:368
4102msgid "" 3317msgid ""
4103"The server to test must be specified in the invocation, as well as a user" 3318"The server to test must be specified in the invocation, as well as a user"
4104msgstr "" 3319msgstr ""
4105 3320
4106#: plugins/check_radius.c:369 3321msgid "name and password. A configuration file must be present. The format of"
4107msgid ""
4108"name and password. A configuration file may also be present. The format of"
4109msgstr "" 3322msgstr ""
4110 3323
4111#: plugins/check_radius.c:370
4112msgid "" 3324msgid ""
4113"the configuration file is described in the radiusclient library sources." 3325"the configuration file is described in the radiusclient library sources."
4114msgstr "" 3326msgstr ""
4115 3327
4116#: plugins/check_radius.c:371
4117msgid "The password option presents a substantial security issue because the" 3328msgid "The password option presents a substantial security issue because the"
4118msgstr "" 3329msgstr ""
4119 3330
4120#: plugins/check_radius.c:372
4121msgid "" 3331msgid ""
4122"password can possibly be determined by careful watching of the command line" 3332"password can possibly be determined by careful watching of the command line"
4123msgstr "" 3333msgstr ""
4124 3334
4125#: plugins/check_radius.c:373 3335msgid "in a process listing. This risk is exacerbated because the plugin will"
4126msgid "in a process listing. This risk is exacerbated because the monitor will"
4127msgstr "" 3336msgstr ""
4128 3337
4129#: plugins/check_radius.c:374 3338msgid ""
4130msgid "run the plugin at regular predictable intervals. Please be sure that" 3339"typically be executed at regular predictable intervals. Please be sure that"
4131msgstr "" 3340msgstr ""
4132 3341
4133#: plugins/check_radius.c:375
4134msgid "the password used does not allow access to sensitive system resources." 3342msgid "the password used does not allow access to sensitive system resources."
4135msgstr "" 3343msgstr ""
4136 3344
4137#: plugins/check_real.c:91
4138#, c-format 3345#, c-format
4139msgid "Unable to connect to %s on port %d\n" 3346msgid "Unable to connect to %s on port %d\n"
4140msgstr "" 3347msgstr ""
4141 3348
4142#: plugins/check_real.c:113
4143#, c-format 3349#, c-format
4144msgid "No data received from %s\n" 3350msgid "No data received from %s\n"
4145msgstr "" 3351msgstr ""
4146 3352
4147#: plugins/check_real.c:118 plugins/check_real.c:191
4148msgid "Invalid REAL response received from host" 3353msgid "Invalid REAL response received from host"
4149msgstr "" 3354msgstr ""
4150 3355
4151#: plugins/check_real.c:120 plugins/check_real.c:193
4152#, c-format 3356#, c-format
4153msgid "Invalid REAL response received from host on port %d\n" 3357msgid "Invalid REAL response received from host on port %d\n"
4154msgstr "" 3358msgstr ""
4155 3359
4156#: plugins/check_real.c:184 plugins/check_tcp.c:311
4157#, c-format 3360#, c-format
4158msgid "No data received from host\n" 3361msgid "No data received from host\n"
4159msgstr "" 3362msgstr ""
4160 3363
4161#: plugins/check_real.c:247
4162#, c-format 3364#, c-format
4163msgid "REAL %s - %d second response time\n" 3365msgid "REAL %s - %d second response time\n"
4164msgstr "" 3366msgstr ""
4165 3367
4166#: plugins/check_real.c:336 plugins/check_ups.c:536
4167msgid "Warning time must be a positive integer" 3368msgid "Warning time must be a positive integer"
4168msgstr "" 3369msgstr ""
4169 3370
4170#: plugins/check_real.c:345 plugins/check_ups.c:527
4171msgid "Critical time must be a positive integer" 3371msgid "Critical time must be a positive integer"
4172msgstr "" 3372msgstr ""
4173 3373
4174#: plugins/check_real.c:381
4175msgid "You must provide a server to check" 3374msgid "You must provide a server to check"
4176msgstr "" 3375msgstr ""
4177 3376
4178#: plugins/check_real.c:413
4179msgid "This plugin tests the REAL service on the specified host." 3377msgid "This plugin tests the REAL service on the specified host."
4180msgstr "" 3378msgstr ""
4181 3379
4182#: plugins/check_real.c:425
4183msgid "Connect to this url" 3380msgid "Connect to this url"
4184msgstr "" 3381msgstr ""
4185 3382
4186#: plugins/check_real.c:427
4187#, c-format 3383#, c-format
4188msgid "String to expect in first line of server response (default: %s)\n" 3384msgid "String to expect in first line of server response (default: %s)\n"
4189msgstr "" 3385msgstr ""
4190 3386
4191#: plugins/check_real.c:437
4192msgid "This plugin will attempt to open an RTSP connection with the host." 3387msgid "This plugin will attempt to open an RTSP connection with the host."
4193msgstr "" 3388msgstr ""
4194 3389
4195#: plugins/check_real.c:438 plugins/check_smtp.c:830 3390msgid "Successful connects return STATE_OK, refusals and timeouts return"
4196msgid "Successul connects return STATE_OK, refusals and timeouts return"
4197msgstr "" 3391msgstr ""
4198 3392
4199#: plugins/check_real.c:439
4200msgid "" 3393msgid ""
4201"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects," 3394"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"
4202msgstr "" 3395msgstr ""
4203 3396
4204#: plugins/check_real.c:440
4205msgid "" 3397msgid ""
4206"but incorrect reponse messages from the host result in STATE_WARNING return" 3398"but incorrect response messages from the host result in STATE_WARNING return"
4207msgstr "" 3399msgstr ""
4208 3400
4209#: plugins/check_real.c:441
4210msgid "values." 3401msgid "values."
4211msgstr "" 3402msgstr ""
4212 3403
4213#: plugins/check_smtp.c:150 plugins/check_swap.c:265 plugins/check_swap.c:271
4214#, c-format 3404#, c-format
4215msgid "malloc() failed!\n" 3405msgid "malloc() failed!\n"
4216msgstr "" 3406msgstr ""
4217 3407
4218#: plugins/check_smtp.c:154
4219#, c-format 3408#, c-format
4220msgid "gethostname() failed!\n" 3409msgid "CRITICAL - Cannot create SSL context.\n"
4221msgstr "" 3410msgstr ""
4222 3411
4223#: plugins/check_smtp.c:189 plugins/check_smtp.c:213
4224#, c-format 3412#, c-format
4225msgid "recv() failed\n" 3413msgid "recv() failed\n"
4226msgstr "" 3414msgstr ""
4227 3415
4228#: plugins/check_smtp.c:200
4229#, c-format
4230msgid "Invalid SMTP response received from host: %s\n"
4231msgstr ""
4232
4233#: plugins/check_smtp.c:202
4234#, c-format
4235msgid "Invalid SMTP response received from host on port %d: %s\n"
4236msgstr ""
4237
4238#: plugins/check_smtp.c:223
4239#, c-format 3416#, c-format
4240msgid "WARNING - TLS not supported by server\n" 3417msgid "WARNING - TLS not supported by server\n"
4241msgstr "" 3418msgstr ""
4242 3419
4243#: plugins/check_smtp.c:235
4244#, c-format 3420#, c-format
4245msgid "Server does not support STARTTLS\n" 3421msgid "Server does not support STARTTLS\n"
4246msgstr "" 3422msgstr ""
4247 3423
4248#: plugins/check_smtp.c:241
4249#, c-format
4250msgid "CRITICAL - Cannot create SSL context.\n"
4251msgstr ""
4252
4253#: plugins/check_smtp.c:261
4254msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS." 3424msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS."
4255msgstr "" 3425msgstr ""
4256 3426
4257#: plugins/check_smtp.c:266
4258#, c-format 3427#, c-format
4259msgid "sent %s" 3428msgid "sent %s"
4260msgstr "" 3429msgstr ""
4261 3430
4262#: plugins/check_smtp.c:268
4263msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS." 3431msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS."
4264msgstr "" 3432msgstr ""
4265 3433
4266#: plugins/check_smtp.c:303 plugins/check_snmp.c:806 3434#, c-format
3435msgid "Invalid SMTP response received from host: %s\n"
3436msgstr ""
3437
3438#, c-format
3439msgid "Invalid SMTP response received from host on port %d: %s\n"
3440msgstr ""
3441
4267#, c-format 3442#, c-format
4268msgid "Could Not Compile Regular Expression" 3443msgid "Could Not Compile Regular Expression"
4269msgstr "" 3444msgstr ""
4270 3445
4271#: plugins/check_smtp.c:312
4272#, c-format 3446#, c-format
4273msgid "SMTP %s - Invalid response '%s' to command '%s'\n" 3447msgid "SMTP %s - Invalid response '%s' to command '%s'\n"
4274msgstr "" 3448msgstr ""
4275 3449
4276#: plugins/check_smtp.c:316 plugins/check_snmp.c:511
4277#, c-format 3450#, c-format
4278msgid "Execute Error: %s\n" 3451msgid "Execute Error: %s\n"
4279msgstr "" 3452msgstr ""
4280 3453
4281#: plugins/check_smtp.c:330
4282msgid "no authuser specified, " 3454msgid "no authuser specified, "
4283msgstr "" 3455msgstr ""
4284 3456
4285#: plugins/check_smtp.c:335
4286msgid "no authpass specified, " 3457msgid "no authpass specified, "
4287msgstr "" 3458msgstr ""
4288 3459
4289#: plugins/check_smtp.c:342 plugins/check_smtp.c:363 plugins/check_smtp.c:383
4290#: plugins/check_smtp.c:688
4291#, c-format 3460#, c-format
4292msgid "sent %s\n" 3461msgid "sent %s\n"
4293msgstr "" 3462msgstr ""
4294 3463
4295#: plugins/check_smtp.c:345
4296msgid "recv() failed after AUTH LOGIN, " 3464msgid "recv() failed after AUTH LOGIN, "
4297msgstr "" 3465msgstr ""
4298 3466
4299#: plugins/check_smtp.c:350 plugins/check_smtp.c:371 plugins/check_smtp.c:391
4300#: plugins/check_smtp.c:699
4301#, c-format 3467#, c-format
4302msgid "received %s\n" 3468msgid "received %s\n"
4303msgstr "" 3469msgstr ""
4304 3470
4305#: plugins/check_smtp.c:354
4306msgid "invalid response received after AUTH LOGIN, " 3471msgid "invalid response received after AUTH LOGIN, "
4307msgstr "" 3472msgstr ""
4308 3473
4309#: plugins/check_smtp.c:367
4310msgid "recv() failed after sending authuser, " 3474msgid "recv() failed after sending authuser, "
4311msgstr "" 3475msgstr ""
4312 3476
4313#: plugins/check_smtp.c:375
4314msgid "invalid response received after authuser, " 3477msgid "invalid response received after authuser, "
4315msgstr "" 3478msgstr ""
4316 3479
4317#: plugins/check_smtp.c:387
4318msgid "recv() failed after sending authpass, " 3480msgid "recv() failed after sending authpass, "
4319msgstr "" 3481msgstr ""
4320 3482
4321#: plugins/check_smtp.c:395
4322msgid "invalid response received after authpass, " 3483msgid "invalid response received after authpass, "
4323msgstr "" 3484msgstr ""
4324 3485
4325#: plugins/check_smtp.c:402
4326msgid "only authtype LOGIN is supported, " 3486msgid "only authtype LOGIN is supported, "
4327msgstr "" 3487msgstr ""
4328 3488
4329#: plugins/check_smtp.c:426
4330#, c-format 3489#, c-format
4331msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n" 3490msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n"
4332msgstr "" 3491msgstr ""
4333 3492
4334#: plugins/check_smtp.c:536 plugins/check_smtp.c:548
4335#, c-format 3493#, c-format
4336msgid "Could not realloc() units [%d]\n" 3494msgid "Could not realloc() units [%d]\n"
4337msgstr "" 3495msgstr ""
4338 3496
4339#: plugins/check_smtp.c:556
4340msgid "Critical time must be a positive" 3497msgid "Critical time must be a positive"
4341msgstr "" 3498msgstr ""
4342 3499
4343#: plugins/check_smtp.c:564
4344msgid "Warning time must be a positive" 3500msgid "Warning time must be a positive"
4345msgstr "" 3501msgstr ""
4346 3502
4347#: plugins/check_smtp.c:611
4348msgid "SSL support not available - install OpenSSL and recompile" 3503msgid "SSL support not available - install OpenSSL and recompile"
4349msgstr "" 3504msgstr ""
4350 3505
4351#: plugins/check_smtp.c:679 plugins/check_smtp.c:684 3506msgid "Set either -s/--ssl/--tls or -S/--starttls"
3507msgstr ""
3508
4352#, c-format 3509#, c-format
4353msgid "Connection closed by server before sending QUIT command\n" 3510msgid "Connection closed by server before sending QUIT command\n"
4354msgstr "" 3511msgstr ""
4355 3512
4356#: plugins/check_smtp.c:694
4357#, c-format 3513#, c-format
4358msgid "recv() failed after QUIT." 3514msgid "recv() failed after QUIT."
4359msgstr "" 3515msgstr ""
4360 3516
4361#: plugins/check_smtp.c:696
4362#, c-format 3517#, c-format
4363msgid "Connection reset by peer." 3518msgid "Connection reset by peer."
4364msgstr "" 3519msgstr ""
4365 3520
4366#: plugins/check_smtp.c:784
4367msgid "This plugin will attempt to open an SMTP connection with the host." 3521msgid "This plugin will attempt to open an SMTP connection with the host."
4368msgstr "" 3522msgstr ""
4369 3523
4370#: plugins/check_smtp.c:798
4371#, c-format 3524#, c-format
4372msgid " String to expect in first line of server response (default: '%s')\n" 3525msgid " String to expect in first line of server response (default: '%s')\n"
4373msgstr "" 3526msgstr ""
4374 3527
4375#: plugins/check_smtp.c:800
4376msgid "SMTP command (may be used repeatedly)" 3528msgid "SMTP command (may be used repeatedly)"
4377msgstr "" 3529msgstr ""
4378 3530
4379#: plugins/check_smtp.c:802
4380msgid "Expected response to command (may be used repeatedly)" 3531msgid "Expected response to command (may be used repeatedly)"
4381msgstr "" 3532msgstr ""
4382 3533
4383#: plugins/check_smtp.c:804
4384msgid "FROM-address to include in MAIL command, required by Exchange 2000" 3534msgid "FROM-address to include in MAIL command, required by Exchange 2000"
4385msgstr "" 3535msgstr ""
4386 3536
4387#: plugins/check_smtp.c:806
4388msgid "FQDN used for HELO" 3537msgid "FQDN used for HELO"
4389msgstr "" 3538msgstr ""
4390 3539
4391#: plugins/check_smtp.c:809 plugins/check_tcp.c:665 3540msgid "Use PROXY protocol prefix for the connection."
3541msgstr ""
3542
4392msgid "Minimum number of days a certificate has to be valid." 3543msgid "Minimum number of days a certificate has to be valid."
4393msgstr "" 3544msgstr ""
4394 3545
4395#: plugins/check_smtp.c:811 3546msgid "Use SSL/TLS for the connection."
3547msgstr ""
3548
3549#, c-format
3550msgid " Sets default port to %d.\n"
3551msgstr ""
3552
4396msgid "Use STARTTLS for the connection." 3553msgid "Use STARTTLS for the connection."
4397msgstr "" 3554msgstr ""
4398 3555
4399#: plugins/check_smtp.c:815
4400msgid "SMTP AUTH type to check (default none, only LOGIN supported)" 3556msgid "SMTP AUTH type to check (default none, only LOGIN supported)"
4401msgstr "" 3557msgstr ""
4402 3558
4403#: plugins/check_smtp.c:817
4404msgid "SMTP AUTH username" 3559msgid "SMTP AUTH username"
4405msgstr "" 3560msgstr ""
4406 3561
4407#: plugins/check_smtp.c:819
4408msgid "SMTP AUTH password" 3562msgid "SMTP AUTH password"
4409msgstr "" 3563msgstr ""
4410 3564
4411#: plugins/check_smtp.c:821 3565msgid "Send LHLO instead of HELO/EHLO"
3566msgstr ""
3567
4412msgid "Ignore failure when sending QUIT command to server" 3568msgid "Ignore failure when sending QUIT command to server"
4413msgstr "" 3569msgstr ""
4414 3570
4415#: plugins/check_smtp.c:831
4416msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful" 3571msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"
4417msgstr "" 3572msgstr ""
4418 3573
4419#: plugins/check_smtp.c:832 3574msgid "connects, but incorrect response messages from the host result in"
4420msgid "connects, but incorrect reponse messages from the host result in"
4421msgstr "" 3575msgstr ""
4422 3576
4423#: plugins/check_smtp.c:833
4424msgid "STATE_WARNING return values." 3577msgid "STATE_WARNING return values."
4425msgstr "" 3578msgstr ""
4426 3579
4427#: plugins/check_snmp.c:169 plugins/check_snmp.c:582
4428msgid "Cannot malloc" 3580msgid "Cannot malloc"
4429msgstr "" 3581msgstr ""
4430 3582
4431#: plugins/check_snmp.c:356
4432#, c-format 3583#, c-format
4433msgid "External command error: %s\n" 3584msgid "External command error: %s\n"
4434msgstr "" 3585msgstr ""
4435 3586
4436#: plugins/check_snmp.c:361
4437#, c-format 3587#, c-format
4438msgid "External command error with no output (return code: %d)\n" 3588msgid "External command error with no output (return code: %d)\n"
4439msgstr "" 3589msgstr ""
4440 3590
4441#: plugins/check_snmp.c:464
4442#, c-format 3591#, c-format
4443msgid "No valid data returned (%s)\n" 3592msgid "No valid data returned (%s)\n"
4444msgstr "" 3593msgstr ""
4445 3594
4446#: plugins/check_snmp.c:475
4447msgid "Time duration between plugin calls is invalid" 3595msgid "Time duration between plugin calls is invalid"
4448msgstr "" 3596msgstr ""
4449 3597
4450#: plugins/check_snmp.c:588
4451msgid "Cannot asprintf()" 3598msgid "Cannot asprintf()"
4452msgstr "" 3599msgstr ""
4453 3600
4454#: plugins/check_snmp.c:594
4455msgid "Cannot realloc()" 3601msgid "Cannot realloc()"
4456msgstr "" 3602msgstr ""
4457 3603
4458#: plugins/check_snmp.c:610
4459msgid "No previous data to calculate rate - assume okay" 3604msgid "No previous data to calculate rate - assume okay"
4460msgstr "" 3605msgstr ""
4461 3606
4462#: plugins/check_snmp.c:751
4463msgid "Retries interval must be a positive integer" 3607msgid "Retries interval must be a positive integer"
4464msgstr "" 3608msgstr ""
4465 3609
4466#: plugins/check_snmp.c:831 3610msgid "Exit status must be a positive integer"
3611msgstr ""
3612
4467#, c-format 3613#, c-format
4468msgid "Could not reallocate labels[%d]" 3614msgid "Could not reallocate labels[%d]"
4469msgstr "" 3615msgstr ""
4470 3616
4471#: plugins/check_snmp.c:844
4472msgid "Could not reallocate labels\n" 3617msgid "Could not reallocate labels\n"
4473msgstr "" 3618msgstr ""
4474 3619
4475#: plugins/check_snmp.c:860
4476#, c-format 3620#, c-format
4477msgid "Could not reallocate units [%d]\n" 3621msgid "Could not reallocate units [%d]\n"
4478msgstr "" 3622msgstr ""
4479 3623
4480#: plugins/check_snmp.c:872
4481msgid "Could not realloc() units\n" 3624msgid "Could not realloc() units\n"
4482msgstr "" 3625msgstr ""
4483 3626
4484#: plugins/check_snmp.c:889
4485msgid "Rate multiplier must be a positive integer" 3627msgid "Rate multiplier must be a positive integer"
4486msgstr "" 3628msgstr ""
4487 3629
4488#: plugins/check_snmp.c:947
4489msgid "No host specified\n" 3630msgid "No host specified\n"
4490msgstr "" 3631msgstr ""
4491 3632
4492#: plugins/check_snmp.c:951
4493msgid "No OIDs specified\n" 3633msgid "No OIDs specified\n"
4494msgstr "" 3634msgstr ""
4495 3635
4496#: plugins/check_snmp.c:973
4497msgid "Invalid seclevel"
4498msgstr ""
4499
4500#: plugins/check_snmp.c:980 plugins/check_snmp.c:983 plugins/check_snmp.c:1001
4501#, c-format 3636#, c-format
4502msgid "Required parameter: %s\n" 3637msgid "Required parameter: %s\n"
4503msgstr "" 3638msgstr ""
4504 3639
4505#: plugins/check_snmp.c:1022 3640msgid "Invalid seclevel"
3641msgstr ""
3642
4506msgid "Invalid SNMP version" 3643msgid "Invalid SNMP version"
4507msgstr "" 3644msgstr ""
4508 3645
4509#: plugins/check_snmp.c:1039
4510msgid "Unbalanced quotes\n" 3646msgid "Unbalanced quotes\n"
4511msgstr "" 3647msgstr ""
4512 3648
4513#: plugins/check_snmp.c:1088 3649#, c-format
3650msgid "multiplier set (%.1f), but input is not a number: %s"
3651msgstr ""
3652
4514msgid "Check status of remote machines and obtain system information via SNMP" 3653msgid "Check status of remote machines and obtain system information via SNMP"
4515msgstr "" 3654msgstr ""
4516 3655
4517#: plugins/check_snmp.c:1101
4518msgid "Use SNMP GETNEXT instead of SNMP GET" 3656msgid "Use SNMP GETNEXT instead of SNMP GET"
4519msgstr "" 3657msgstr ""
4520 3658
4521#: plugins/check_snmp.c:1103
4522msgid "SNMP protocol version" 3659msgid "SNMP protocol version"
4523msgstr "" 3660msgstr ""
4524 3661
4525#: plugins/check_snmp.c:1105 3662msgid "SNMPv3 context"
3663msgstr ""
3664
4526msgid "SNMPv3 securityLevel" 3665msgid "SNMPv3 securityLevel"
4527msgstr "" 3666msgstr ""
4528 3667
4529#: plugins/check_snmp.c:1107
4530msgid "SNMPv3 auth proto" 3668msgid "SNMPv3 auth proto"
4531msgstr "" 3669msgstr ""
4532 3670
4533#: plugins/check_snmp.c:1109
4534msgid "SNMPv3 priv proto (default DES)" 3671msgid "SNMPv3 priv proto (default DES)"
4535msgstr "" 3672msgstr ""
4536 3673
4537#: plugins/check_snmp.c:1113
4538msgid "Optional community string for SNMP communication" 3674msgid "Optional community string for SNMP communication"
4539msgstr "" 3675msgstr ""
4540 3676
4541#: plugins/check_snmp.c:1114
4542msgid "default is" 3677msgid "default is"
4543msgstr "" 3678msgstr ""
4544 3679
4545#: plugins/check_snmp.c:1116
4546msgid "SNMPv3 username" 3680msgid "SNMPv3 username"
4547msgstr "" 3681msgstr ""
4548 3682
4549#: plugins/check_snmp.c:1118
4550msgid "SNMPv3 authentication password" 3683msgid "SNMPv3 authentication password"
4551msgstr "" 3684msgstr ""
4552 3685
4553#: plugins/check_snmp.c:1120
4554msgid "SNMPv3 privacy password" 3686msgid "SNMPv3 privacy password"
4555msgstr "" 3687msgstr ""
4556 3688
4557#: plugins/check_snmp.c:1124
4558msgid "Object identifier(s) or SNMP variables whose value you wish to query" 3689msgid "Object identifier(s) or SNMP variables whose value you wish to query"
4559msgstr "" 3690msgstr ""
4560 3691
4561#: plugins/check_snmp.c:1126
4562msgid "" 3692msgid ""
4563"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'" 3693"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'"
4564msgstr "" 3694msgstr ""
4565 3695
4566#: plugins/check_snmp.c:1127
4567msgid "for symbolic OIDs.)" 3696msgid "for symbolic OIDs.)"
4568msgstr "" 3697msgstr ""
4569 3698
4570#: plugins/check_snmp.c:1129
4571msgid "Delimiter to use when parsing returned data. Default is" 3699msgid "Delimiter to use when parsing returned data. Default is"
4572msgstr "" 3700msgstr ""
4573 3701
4574#: plugins/check_snmp.c:1130
4575msgid "Any data on the right hand side of the delimiter is considered" 3702msgid "Any data on the right hand side of the delimiter is considered"
4576msgstr "" 3703msgstr ""
4577 3704
4578#: plugins/check_snmp.c:1131
4579msgid "to be the data that should be used in the evaluation." 3705msgid "to be the data that should be used in the evaluation."
4580msgstr "" 3706msgstr ""
4581 3707
4582#: plugins/check_snmp.c:1135 3708msgid "If the check returns a 0 length string or NULL value"
3709msgstr ""
3710
3711msgid "This option allows you to choose what status you want it to exit"
3712msgstr ""
3713
3714msgid "Excluding this option renders the default exit of 3(STATE_UNKNOWN)"
3715msgstr ""
3716
3717msgid "0 = OK"
3718msgstr ""
3719
3720msgid "1 = WARNING"
3721msgstr ""
3722
3723msgid "2 = CRITICAL"
3724msgstr ""
3725
3726msgid "3 = UNKNOWN"
3727msgstr ""
3728
4583msgid "Warning threshold range(s)" 3729msgid "Warning threshold range(s)"
4584msgstr "" 3730msgstr ""
4585 3731
4586#: plugins/check_snmp.c:1137
4587msgid "Critical threshold range(s)" 3732msgid "Critical threshold range(s)"
4588msgstr "" 3733msgstr ""
4589 3734
4590#: plugins/check_snmp.c:1139
4591msgid "Enable rate calculation. See 'Rate Calculation' below" 3735msgid "Enable rate calculation. See 'Rate Calculation' below"
4592msgstr "" 3736msgstr ""
4593 3737
4594#: plugins/check_snmp.c:1141
4595msgid "" 3738msgid ""
4596"Converts rate per second. For example, set to 60 to convert to per minute" 3739"Converts rate per second. For example, set to 60 to convert to per minute"
4597msgstr "" 3740msgstr ""
4598 3741
4599#: plugins/check_snmp.c:1143 3742msgid "Add/subtract the specified OFFSET to numeric sensor data"
4600msgid "Add/substract the specified OFFSET to numeric sensor data"
4601msgstr "" 3743msgstr ""
4602 3744
4603#: plugins/check_snmp.c:1147
4604msgid "Return OK state (for that OID) if STRING is an exact match" 3745msgid "Return OK state (for that OID) if STRING is an exact match"
4605msgstr "" 3746msgstr ""
4606 3747
4607#: plugins/check_snmp.c:1149
4608msgid "" 3748msgid ""
4609"Return OK state (for that OID) if extended regular expression REGEX matches" 3749"Return OK state (for that OID) if extended regular expression REGEX matches"
4610msgstr "" 3750msgstr ""
4611 3751
4612#: plugins/check_snmp.c:1151
4613msgid "" 3752msgid ""
4614"Return OK state (for that OID) if case-insensitive extended REGEX matches" 3753"Return OK state (for that OID) if case-insensitive extended REGEX matches"
4615msgstr "" 3754msgstr ""
4616 3755
4617#: plugins/check_snmp.c:1153
4618msgid "Invert search result (CRITICAL if found)" 3756msgid "Invert search result (CRITICAL if found)"
4619msgstr "" 3757msgstr ""
4620 3758
4621#: plugins/check_snmp.c:1157
4622msgid "Prefix label for output from plugin" 3759msgid "Prefix label for output from plugin"
4623msgstr "" 3760msgstr ""
4624 3761
4625#: plugins/check_snmp.c:1159
4626msgid "Units label(s) for output data (e.g., 'sec.')." 3762msgid "Units label(s) for output data (e.g., 'sec.')."
4627msgstr "" 3763msgstr ""
4628 3764
4629#: plugins/check_snmp.c:1161
4630msgid "Separates output on multiple OID requests" 3765msgid "Separates output on multiple OID requests"
4631msgstr "" 3766msgstr ""
4632 3767
4633#: plugins/check_snmp.c:1165 3768msgid "Multiplies current value, 0 < n < 1 works as divider, defaults to 1"
4634msgid "Number of retries to be used in the requests" 3769msgstr ""
3770
3771msgid "C-style format string for float values (see option -M)"
3772msgstr ""
3773
3774msgid ""
3775"NOTE the final timeout value is calculated using this formula: "
3776"timeout_interval * retries + 5"
3777msgstr ""
3778
3779msgid "Number of retries to be used in the requests, default: "
4635msgstr "" 3780msgstr ""
4636 3781
4637#: plugins/check_snmp.c:1168
4638msgid "Label performance data with OIDs instead of --label's" 3782msgid "Label performance data with OIDs instead of --label's"
4639msgstr "" 3783msgstr ""
4640 3784
4641#: plugins/check_snmp.c:1173 3785msgid "Tell snmpget to not print errors encountered when parsing MIB files"
3786msgstr ""
3787
4642msgid "" 3788msgid ""
4643"This plugin uses the 'snmpget' command included with the NET-SNMP package." 3789"This plugin uses the 'snmpget' command included with the NET-SNMP package."
4644msgstr "" 3790msgstr ""
4645 3791
4646#: plugins/check_snmp.c:1174
4647msgid "" 3792msgid ""
4648"if you don't have the package installed, you will need to download it from" 3793"if you don't have the package installed, you will need to download it from"
4649msgstr "" 3794msgstr ""
4650 3795
4651#: plugins/check_snmp.c:1175
4652msgid "http://net-snmp.sourceforge.net before you can use this plugin." 3796msgid "http://net-snmp.sourceforge.net before you can use this plugin."
4653msgstr "" 3797msgstr ""
4654 3798
4655#: plugins/check_snmp.c:1179
4656msgid "" 3799msgid ""
4657"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited " 3800"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited "
4658msgstr "" 3801msgstr ""
4659 3802
4660#: plugins/check_snmp.c:1180
4661msgid "list (lists with internal spaces must be quoted)." 3803msgid "list (lists with internal spaces must be quoted)."
4662msgstr "" 3804msgstr ""
4663 3805
4664#: plugins/check_snmp.c:1184
4665msgid "" 3806msgid ""
4666"- When checking multiple OIDs, separate ranges by commas like '-w " 3807"- When checking multiple OIDs, separate ranges by commas like '-w "
4667"1:10,1:,:20'" 3808"1:10,1:,:20'"
4668msgstr "" 3809msgstr ""
4669 3810
4670#: plugins/check_snmp.c:1185
4671msgid "- Note that only one string and one regex may be checked at present" 3811msgid "- Note that only one string and one regex may be checked at present"
4672msgstr "" 3812msgstr ""
4673 3813
4674#: plugins/check_snmp.c:1186
4675msgid "" 3814msgid ""
4676"- All evaluation methods other than PR, STR, and SUBSTR expect that the value" 3815"- All evaluation methods other than PR, STR, and SUBSTR expect that the value"
4677msgstr "" 3816msgstr ""
4678 3817
4679#: plugins/check_snmp.c:1187
4680msgid "returned from the SNMP query is an unsigned integer." 3818msgid "returned from the SNMP query is an unsigned integer."
4681msgstr "" 3819msgstr ""
4682 3820
4683#: plugins/check_snmp.c:1190
4684msgid "Rate Calculation:" 3821msgid "Rate Calculation:"
4685msgstr "" 3822msgstr ""
4686 3823
4687#: plugins/check_snmp.c:1191
4688msgid "In many places, SNMP returns counters that are only meaningful when" 3824msgid "In many places, SNMP returns counters that are only meaningful when"
4689msgstr "" 3825msgstr ""
4690 3826
4691#: plugins/check_snmp.c:1192
4692msgid "calculating the counter difference since the last check. check_snmp" 3827msgid "calculating the counter difference since the last check. check_snmp"
4693msgstr "" 3828msgstr ""
4694 3829
4695#: plugins/check_snmp.c:1193
4696msgid "saves the last state information in a file so that the rate per second" 3830msgid "saves the last state information in a file so that the rate per second"
4697msgstr "" 3831msgstr ""
4698 3832
4699#: plugins/check_snmp.c:1194
4700msgid "can be calculated. Use the --rate option to save state information." 3833msgid "can be calculated. Use the --rate option to save state information."
4701msgstr "" 3834msgstr ""
4702 3835
4703#: plugins/check_snmp.c:1195
4704msgid "" 3836msgid ""
4705"On the first run, there will be no prior state - this will return with OK." 3837"On the first run, there will be no prior state - this will return with OK."
4706msgstr "" 3838msgstr ""
4707 3839
4708#: plugins/check_snmp.c:1196
4709msgid "The state is uniquely determined by the arguments to the plugin, so" 3840msgid "The state is uniquely determined by the arguments to the plugin, so"
4710msgstr "" 3841msgstr ""
4711 3842
4712#: plugins/check_snmp.c:1197
4713msgid "changing the arguments will create a new state file." 3843msgid "changing the arguments will create a new state file."
4714msgstr "" 3844msgstr ""
4715 3845
4716#: plugins/check_ssh.c:165
4717msgid "Port number must be a positive integer" 3846msgid "Port number must be a positive integer"
4718msgstr "" 3847msgstr ""
4719 3848
4720#: plugins/check_ssh.c:232
4721#, c-format 3849#, c-format
4722msgid "Server answer: %s" 3850msgid "Server answer: %s"
4723msgstr "" 3851msgstr ""
4724 3852
4725#: plugins/check_ssh.c:251
4726#, c-format 3853#, c-format
4727msgid "SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n" 3854msgid "SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"
3855msgstr ""
3856
3857#, c-format
3858msgid ""
3859"SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"
4728msgstr "" 3860msgstr ""
4729 3861
4730#: plugins/check_ssh.c:260
4731#, c-format 3862#, c-format
4732msgid "SSH OK - %s (protocol %s) | %s\n" 3863msgid "SSH OK - %s (protocol %s) | %s\n"
4733msgstr "" 3864msgstr ""
4734 3865
4735#: plugins/check_ssh.c:281
4736msgid "Try to connect to an SSH server at specified server and port" 3866msgid "Try to connect to an SSH server at specified server and port"
4737msgstr "" 3867msgstr ""
4738 3868
4739#: plugins/check_ssh.c:297
4740msgid "" 3869msgid ""
4741"Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)" 3870"Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"
3871msgstr ""
3872
3873msgid "Alert if protocol doesn't match expected protocol version (ex: 2.0)"
4742msgstr "" 3874msgstr ""
4743 3875
4744#: plugins/check_swap.c:169
4745#, c-format 3876#, c-format
4746msgid "Command: %s\n" 3877msgid "Command: %s\n"
4747msgstr "" 3878msgstr ""
4748 3879
4749#: plugins/check_swap.c:171
4750#, c-format 3880#, c-format
4751msgid "Format: %s\n" 3881msgid "Format: %s\n"
4752msgstr "" 3882msgstr ""
4753 3883
4754#: plugins/check_swap.c:207
4755#, c-format 3884#, c-format
4756msgid "total=%.0f, used=%.0f, free=%.0f\n" 3885msgid "total=%.0f, used=%.0f, free=%.0f\n"
4757msgstr "" 3886msgstr ""
4758 3887
4759#: plugins/check_swap.c:221
4760#, c-format 3888#, c-format
4761msgid "total=%.0f, free=%.0f\n" 3889msgid "total=%.0f, free=%.0f\n"
4762msgstr "" 3890msgstr ""
4763 3891
4764#: plugins/check_swap.c:253
4765msgid "Error getting swap devices\n" 3892msgid "Error getting swap devices\n"
4766msgstr "" 3893msgstr ""
4767 3894
4768#: plugins/check_swap.c:256
4769msgid "SWAP OK: No swap devices defined\n" 3895msgid "SWAP OK: No swap devices defined\n"
4770msgstr "" 3896msgstr ""
4771 3897
4772#: plugins/check_swap.c:277 plugins/check_swap.c:319
4773msgid "swapctl failed: " 3898msgid "swapctl failed: "
4774msgstr "" 3899msgstr ""
4775 3900
4776#: plugins/check_swap.c:278 plugins/check_swap.c:320
4777msgid "Error in swapctl call\n" 3901msgid "Error in swapctl call\n"
4778msgstr "" 3902msgstr ""
4779 3903
4780#: plugins/check_swap.c:357
4781#, c-format 3904#, c-format
4782msgid "SWAP %s - %d%% free (%d MB out of %d MB) %s|" 3905msgid "SWAP %s - %d%% free (%dMB out of %dMB) %s|"
3906msgstr ""
3907
3908msgid "Warning threshold percentage must be <= 100!"
3909msgstr ""
3910
3911msgid "Warning threshold be positive integer or percentage!"
4783msgstr "" 3912msgstr ""
4784 3913
4785#: plugins/check_swap.c:435 3914msgid "Critical threshold percentage must be <= 100!"
4786msgid "Warning threshold must be integer or percentage!"
4787msgstr "" 3915msgstr ""
4788 3916
4789#: plugins/check_swap.c:453 3917msgid "Critical threshold be positive integer or percentage!"
4790msgid "Critical threshold must be integer or percentage!"
4791msgstr "" 3918msgstr ""
4792 3919
4793#: plugins/check_swap.c:507 3920msgid ""
4794msgid "Warning percentage should be more than critical percentage" 3921"no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
3922"or integer (0-3)."
4795msgstr "" 3923msgstr ""
4796 3924
4797#: plugins/check_swap.c:511 3925msgid "Warning should be more than critical"
4798msgid "Warning free space should be more than critical free space"
4799msgstr "" 3926msgstr ""
4800 3927
4801#: plugins/check_swap.c:525
4802msgid "Check swap space on local machine." 3928msgid "Check swap space on local machine."
4803msgstr "" 3929msgstr ""
4804 3930
4805#: plugins/check_swap.c:535
4806msgid "" 3931msgid ""
4807"Exit with WARNING status if less than INTEGER bytes of swap space are free" 3932"Exit with WARNING status if less than INTEGER bytes of swap space are free"
4808msgstr "" 3933msgstr ""
4809 3934
4810#: plugins/check_swap.c:537
4811msgid "Exit with WARNING status if less than PERCENT of swap space is free" 3935msgid "Exit with WARNING status if less than PERCENT of swap space is free"
4812msgstr "" 3936msgstr ""
4813 3937
4814#: plugins/check_swap.c:539
4815msgid "" 3938msgid ""
4816"Exit with CRITICAL status if less than INTEGER bytes of swap space are free" 3939"Exit with CRITICAL status if less than INTEGER bytes of swap space are free"
4817msgstr "" 3940msgstr ""
4818 3941
4819#: plugins/check_swap.c:541 3942msgid "Exit with CRITICAL status if less than PERCENT of swap space is free"
4820msgid "Exit with CRITCAL status if less than PERCENT of swap space is free"
4821msgstr "" 3943msgstr ""
4822 3944
4823#: plugins/check_swap.c:543
4824msgid "Conduct comparisons for all swap partitions, one by one" 3945msgid "Conduct comparisons for all swap partitions, one by one"
4825msgstr "" 3946msgstr ""
4826 3947
4827#: plugins/check_swap.c:548 3948msgid ""
3949"Resulting state when there is no swap regardless of thresholds. Default:"
3950msgstr ""
3951
3952msgid ""
3953"Both INTEGER and PERCENT thresholds can be specified, they are all checked."
3954msgstr ""
3955
4828msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s." 3956msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."
4829msgstr "" 3957msgstr ""
4830 3958
4831#: plugins/check_tcp.c:206
4832msgid "CRITICAL - Generic check_tcp called with unknown service\n" 3959msgid "CRITICAL - Generic check_tcp called with unknown service\n"
4833msgstr "" 3960msgstr ""
4834 3961
4835#: plugins/check_tcp.c:230
4836msgid "With UDP checks, a send/expect string must be specified." 3962msgid "With UDP checks, a send/expect string must be specified."
4837msgstr "" 3963msgstr ""
4838 3964
4839#: plugins/check_tcp.c:431
4840msgid "No arguments found" 3965msgid "No arguments found"
4841msgstr "" 3966msgstr ""
4842 3967
4843#: plugins/check_tcp.c:534
4844msgid "Maxbytes must be a positive integer" 3968msgid "Maxbytes must be a positive integer"
4845msgstr "" 3969msgstr ""
4846 3970
4847#: plugins/check_tcp.c:552
4848msgid "Refuse must be one of ok, warn, crit" 3971msgid "Refuse must be one of ok, warn, crit"
4849msgstr "" 3972msgstr ""
4850 3973
4851#: plugins/check_tcp.c:562
4852msgid "Mismatch must be one of ok, warn, crit" 3974msgid "Mismatch must be one of ok, warn, crit"
4853msgstr "" 3975msgstr ""
4854 3976
4855#: plugins/check_tcp.c:568
4856msgid "Delay must be a positive integer" 3977msgid "Delay must be a positive integer"
4857msgstr "" 3978msgstr ""
4858 3979
4859#: plugins/check_tcp.c:613
4860msgid "You must provide a server address" 3980msgid "You must provide a server address"
4861msgstr "" 3981msgstr ""
4862 3982
4863#: plugins/check_tcp.c:615
4864msgid "Invalid hostname, address or socket" 3983msgid "Invalid hostname, address or socket"
4865msgstr "" 3984msgstr ""
4866 3985
4867#: plugins/check_tcp.c:629
4868#, c-format 3986#, c-format
4869msgid "" 3987msgid ""
4870"This plugin tests %s connections with the specified host (or unix socket).\n" 3988"This plugin tests %s connections with the specified host (or unix socket).\n"
4871"\n" 3989"\n"
4872msgstr "" 3990msgstr ""
4873 3991
4874#: plugins/check_tcp.c:642
4875msgid "" 3992msgid ""
4876"Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or " 3993"Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send "
4877"quit option" 3994"or quit option"
4878msgstr "" 3995msgstr ""
4879 3996
4880#: plugins/check_tcp.c:643
4881msgid "Default: nothing added to send, \\r\\n added to end of quit" 3997msgid "Default: nothing added to send, \\r\\n added to end of quit"
4882msgstr "" 3998msgstr ""
4883 3999
4884#: plugins/check_tcp.c:645
4885msgid "String to send to the server" 4000msgid "String to send to the server"
4886msgstr "" 4001msgstr ""
4887 4002
4888#: plugins/check_tcp.c:647
4889msgid "String to expect in server response" 4003msgid "String to expect in server response"
4890msgstr "" 4004msgstr ""
4891 4005
4892#: plugins/check_tcp.c:647
4893msgid "(may be repeated)" 4006msgid "(may be repeated)"
4894msgstr "" 4007msgstr ""
4895 4008
4896#: plugins/check_tcp.c:649
4897msgid "All expect strings need to occur in server response. Default is any" 4009msgid "All expect strings need to occur in server response. Default is any"
4898msgstr "" 4010msgstr ""
4899 4011
4900#: plugins/check_tcp.c:651
4901msgid "String to send server to initiate a clean close of the connection" 4012msgid "String to send server to initiate a clean close of the connection"
4902msgstr "" 4013msgstr ""
4903 4014
4904#: plugins/check_tcp.c:653
4905msgid "Accept TCP refusals with states ok, warn, crit (default: crit)" 4015msgid "Accept TCP refusals with states ok, warn, crit (default: crit)"
4906msgstr "" 4016msgstr ""
4907 4017
4908#: plugins/check_tcp.c:655
4909msgid "" 4018msgid ""
4910"Accept expected string mismatches with states ok, warn, crit (default: warn)" 4019"Accept expected string mismatches with states ok, warn, crit (default: warn)"
4911msgstr "" 4020msgstr ""
4912 4021
4913#: plugins/check_tcp.c:657
4914msgid "Hide output from TCP socket" 4022msgid "Hide output from TCP socket"
4915msgstr "" 4023msgstr ""
4916 4024
4917#: plugins/check_tcp.c:659
4918msgid "Close connection once more than this number of bytes are received" 4025msgid "Close connection once more than this number of bytes are received"
4919msgstr "" 4026msgstr ""
4920 4027
4921#: plugins/check_tcp.c:661
4922msgid "Seconds to wait between sending string and polling for response" 4028msgid "Seconds to wait between sending string and polling for response"
4923msgstr "" 4029msgstr ""
4924 4030
4925#: plugins/check_tcp.c:666
4926msgid "1st is #days for warning, 2nd is critical (if not specified - 0)." 4031msgid "1st is #days for warning, 2nd is critical (if not specified - 0)."
4927msgstr "" 4032msgstr ""
4928 4033
4929#: plugins/check_tcp.c:668
4930msgid "Use SSL for the connection." 4034msgid "Use SSL for the connection."
4931msgstr "" 4035msgstr ""
4932 4036
4933#: plugins/check_time.c:102 4037msgid "SSL server_name"
4038msgstr ""
4039
4934#, c-format 4040#, c-format
4935msgid "TIME UNKNOWN - could not connect to server %s, port %d\n" 4041msgid "TIME UNKNOWN - could not connect to server %s, port %d\n"
4936msgstr "" 4042msgstr ""
4937 4043
4938#: plugins/check_time.c:115
4939#, c-format 4044#, c-format
4940msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n" 4045msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n"
4941msgstr "" 4046msgstr ""
4942 4047
4943#: plugins/check_time.c:139
4944#, c-format 4048#, c-format
4945msgid "TIME UNKNOWN - no data received from server %s, port %d\n" 4049msgid "TIME UNKNOWN - no data received from server %s, port %d\n"
4946msgstr "" 4050msgstr ""
4947 4051
4948#: plugins/check_time.c:152
4949#, c-format 4052#, c-format
4950msgid "TIME %s - %d second response time|%s\n" 4053msgid "TIME %s - %d second response time|%s\n"
4951msgstr "" 4054msgstr ""
4952 4055
4953#: plugins/check_time.c:170
4954#, c-format 4056#, c-format
4955msgid "TIME %s - %lu second time difference|%s %s\n" 4057msgid "TIME %s - %lu second time difference|%s %s\n"
4956msgstr "" 4058msgstr ""
4957 4059
4958#: plugins/check_time.c:254
4959msgid "Warning thresholds must be a positive integer" 4060msgid "Warning thresholds must be a positive integer"
4960msgstr "" 4061msgstr ""
4961 4062
4962#: plugins/check_time.c:273
4963msgid "Critical thresholds must be a positive integer" 4063msgid "Critical thresholds must be a positive integer"
4964msgstr "" 4064msgstr ""
4965 4065
4966#: plugins/check_time.c:339
4967msgid "This plugin will check the time on the specified host." 4066msgid "This plugin will check the time on the specified host."
4968msgstr "" 4067msgstr ""
4969 4068
4970#: plugins/check_time.c:351
4971msgid "Use UDP to connect, not TCP" 4069msgid "Use UDP to connect, not TCP"
4972msgstr "" 4070msgstr ""
4973 4071
4974#: plugins/check_time.c:353
4975msgid "Time difference (sec.) necessary to result in a warning status" 4072msgid "Time difference (sec.) necessary to result in a warning status"
4976msgstr "" 4073msgstr ""
4977 4074
4978#: plugins/check_time.c:355
4979msgid "Time difference (sec.) necessary to result in a critical status" 4075msgid "Time difference (sec.) necessary to result in a critical status"
4980msgstr "" 4076msgstr ""
4981 4077
4982#: plugins/check_time.c:357
4983msgid "Response time (sec.) necessary to result in warning status" 4078msgid "Response time (sec.) necessary to result in warning status"
4984msgstr "" 4079msgstr ""
4985 4080
4986#: plugins/check_time.c:359
4987msgid "Response time (sec.) necessary to result in critical status" 4081msgid "Response time (sec.) necessary to result in critical status"
4988msgstr "" 4082msgstr ""
4989 4083
4990#: plugins/check_ups.c:144
4991msgid "On Battery, Low Battery" 4084msgid "On Battery, Low Battery"
4992msgstr "" 4085msgstr ""
4993 4086
4994#: plugins/check_ups.c:149
4995msgid "Online" 4087msgid "Online"
4996msgstr "" 4088msgstr ""
4997 4089
4998#: plugins/check_ups.c:152
4999msgid "On Battery" 4090msgid "On Battery"
5000msgstr "" 4091msgstr ""
5001 4092
5002#: plugins/check_ups.c:156
5003msgid ", Low Battery" 4093msgid ", Low Battery"
5004msgstr "" 4094msgstr ""
5005 4095
5006#: plugins/check_ups.c:160
5007msgid ", Calibrating" 4096msgid ", Calibrating"
5008msgstr "" 4097msgstr ""
5009 4098
5010#: plugins/check_ups.c:163
5011msgid ", Replace Battery" 4099msgid ", Replace Battery"
5012msgstr "" 4100msgstr ""
5013 4101
5014#: plugins/check_ups.c:167
5015msgid ", On Bypass" 4102msgid ", On Bypass"
5016msgstr "" 4103msgstr ""
5017 4104
5018#: plugins/check_ups.c:170
5019msgid ", Overload" 4105msgid ", Overload"
5020msgstr "" 4106msgstr ""
5021 4107
5022#: plugins/check_ups.c:173
5023msgid ", Trimming" 4108msgid ", Trimming"
5024msgstr "" 4109msgstr ""
5025 4110
5026#: plugins/check_ups.c:176
5027msgid ", Boosting" 4111msgid ", Boosting"
5028msgstr "" 4112msgstr ""
5029 4113
5030#: plugins/check_ups.c:179
5031msgid ", Charging" 4114msgid ", Charging"
5032msgstr "" 4115msgstr ""
5033 4116
5034#: plugins/check_ups.c:182
5035msgid ", Discharging" 4117msgid ", Discharging"
5036msgstr "" 4118msgstr ""
5037 4119
5038#: plugins/check_ups.c:185
5039msgid ", Unknown" 4120msgid ", Unknown"
5040msgstr "" 4121msgstr ""
5041 4122
5042#: plugins/check_ups.c:324
5043msgid "UPS does not support any available options\n" 4123msgid "UPS does not support any available options\n"
5044msgstr "" 4124msgstr ""
5045 4125
5046#: plugins/check_ups.c:348 plugins/check_ups.c:411
5047msgid "Invalid response received from host" 4126msgid "Invalid response received from host"
5048msgstr "" 4127msgstr ""
5049 4128
5050#: plugins/check_ups.c:420 4129msgid "UPS name to long for buffer"
4130msgstr ""
4131
5051#, c-format 4132#, c-format
5052msgid "CRITICAL - no such UPS '%s' on that host\n" 4133msgid "CRITICAL - no such UPS '%s' on that host\n"
5053msgstr "" 4134msgstr ""
5054 4135
5055#: plugins/check_ups.c:430
5056msgid "CRITICAL - UPS data is stale" 4136msgid "CRITICAL - UPS data is stale"
5057msgstr "" 4137msgstr ""
5058 4138
5059#: plugins/check_ups.c:435
5060#, c-format 4139#, c-format
5061msgid "Unknown error: %s\n" 4140msgid "Unknown error: %s\n"
5062msgstr "" 4141msgstr ""
5063 4142
5064#: plugins/check_ups.c:442
5065msgid "Error: unable to parse variable" 4143msgid "Error: unable to parse variable"
5066msgstr "" 4144msgstr ""
5067 4145
5068#: plugins/check_ups.c:549
5069msgid "Unrecognized UPS variable" 4146msgid "Unrecognized UPS variable"
5070msgstr "" 4147msgstr ""
5071 4148
5072#: plugins/check_ups.c:587
5073msgid "Error : no UPS indicated" 4149msgid "Error : no UPS indicated"
5074msgstr "" 4150msgstr ""
5075 4151
5076#: plugins/check_ups.c:607
5077msgid "" 4152msgid ""
5078"This plugin tests the UPS service on the specified host. Network UPS Tools" 4153"This plugin tests the UPS service on the specified host. Network UPS Tools"
5079msgstr "" 4154msgstr ""
5080 4155
5081#: plugins/check_ups.c:608
5082msgid "from www.networkupstools.org must be running for this plugin to work." 4156msgid "from www.networkupstools.org must be running for this plugin to work."
5083msgstr "" 4157msgstr ""
5084 4158
5085#: plugins/check_ups.c:620
5086msgid "Name of UPS" 4159msgid "Name of UPS"
5087msgstr "" 4160msgstr ""
5088 4161
5089#: plugins/check_ups.c:622
5090msgid "Output of temperatures in Celsius" 4162msgid "Output of temperatures in Celsius"
5091msgstr "" 4163msgstr ""
5092 4164
5093#: plugins/check_ups.c:624
5094msgid "Valid values for STRING are" 4165msgid "Valid values for STRING are"
5095msgstr "" 4166msgstr ""
5096 4167
5097#: plugins/check_ups.c:635
5098msgid "" 4168msgid ""
5099"This plugin attempts to determine the status of a UPS (Uninterruptible Power" 4169"This plugin attempts to determine the status of a UPS (Uninterruptible Power"
5100msgstr "" 4170msgstr ""
5101 4171
5102#: plugins/check_ups.c:636
5103msgid "" 4172msgid ""
5104"Supply) on a local or remote host. If the UPS is online or calibrating, the" 4173"Supply) on a local or remote host. If the UPS is online or calibrating, the"
5105msgstr "" 4174msgstr ""
5106 4175
5107#: plugins/check_ups.c:637
5108msgid "" 4176msgid ""
5109"plugin will return an OK state. If the battery is on it will return a WARNING" 4177"plugin will return an OK state. If the battery is on it will return a WARNING"
5110msgstr "" 4178msgstr ""
5111 4179
5112#: plugins/check_ups.c:638
5113msgid "" 4180msgid ""
5114"state. If the UPS is off or has a low battery the plugin will return a " 4181"state. If the UPS is off or has a low battery the plugin will return a "
5115"CRITICAL" 4182"CRITICAL"
5116msgstr "" 4183msgstr ""
5117 4184
5118#: plugins/check_ups.c:643
5119msgid "" 4185msgid ""
5120"You may also specify a variable to check (such as temperature, utility " 4186"You may also specify a variable to check (such as temperature, utility "
5121"voltage," 4187"voltage,"
5122msgstr "" 4188msgstr ""
5123 4189
5124#: plugins/check_ups.c:644
5125msgid "" 4190msgid ""
5126"battery load, etc.) as well as warning and critical thresholds for the value" 4191"battery load, etc.) as well as warning and critical thresholds for the value"
5127msgstr "" 4192msgstr ""
5128 4193
5129#: plugins/check_ups.c:645
5130msgid "" 4194msgid ""
5131"of that variable. If the remote host has multiple UPS that are being " 4195"of that variable. If the remote host has multiple UPS that are being "
5132"monitored" 4196"monitored"
5133msgstr "" 4197msgstr ""
5134 4198
5135#: plugins/check_ups.c:646
5136msgid "you will have to use the --ups option to specify which UPS to check." 4199msgid "you will have to use the --ups option to specify which UPS to check."
5137msgstr "" 4200msgstr ""
5138 4201
5139#: plugins/check_ups.c:648
5140msgid "" 4202msgid ""
5141"This plugin requires that the UPSD daemon distributed with Russell Kroll's" 4203"This plugin requires that the UPSD daemon distributed with Russell Kroll's"
5142msgstr "" 4204msgstr ""
5143 4205
5144#: plugins/check_ups.c:649
5145msgid "" 4206msgid ""
5146"Network UPS Tools be installed on the remote host. If you do not have the" 4207"Network UPS Tools be installed on the remote host. If you do not have the"
5147msgstr "" 4208msgstr ""
5148 4209
5149#: plugins/check_ups.c:650
5150msgid "package installed on your system, you can download it from" 4210msgid "package installed on your system, you can download it from"
5151msgstr "" 4211msgstr ""
5152 4212
5153#: plugins/check_ups.c:651
5154msgid "http://www.networkupstools.org" 4213msgid "http://www.networkupstools.org"
5155msgstr "" 4214msgstr ""
5156 4215
5157#: plugins/check_users.c:110 4216#, c-format
4217msgid "Could not enumerate RD sessions: %d\n"
4218msgstr ""
4219
5158#, c-format 4220#, c-format
5159msgid "# users=%d" 4221msgid "# users=%d"
5160msgstr "" 4222msgstr ""
5161 4223
5162#: plugins/check_users.c:133
5163msgid "Unable to read output" 4224msgid "Unable to read output"
5164msgstr "" 4225msgstr ""
5165 4226
5166#: plugins/check_users.c:140
5167#, c-format 4227#, c-format
5168msgid "USERS %s - %d users currently logged in |%s\n" 4228msgid "USERS %s - %d users currently logged in |%s\n"
5169msgstr "" 4229msgstr ""
5170 4230
5171#: plugins/check_users.c:219
5172msgid "This plugin checks the number of users currently logged in on the local" 4231msgid "This plugin checks the number of users currently logged in on the local"
5173msgstr "" 4232msgstr ""
5174 4233
5175#: plugins/check_users.c:220
5176msgid "" 4234msgid ""
5177"system and generates an error if the number exceeds the thresholds specified." 4235"system and generates an error if the number exceeds the thresholds specified."
5178msgstr "" 4236msgstr ""
5179 4237
5180#: plugins/check_users.c:230
5181msgid "Set WARNING status if more than INTEGER users are logged in" 4238msgid "Set WARNING status if more than INTEGER users are logged in"
5182msgstr "" 4239msgstr ""
5183 4240
5184#: plugins/check_users.c:232
5185msgid "Set CRITICAL status if more than INTEGER users are logged in" 4241msgid "Set CRITICAL status if more than INTEGER users are logged in"
5186msgstr "" 4242msgstr ""
5187 4243
5188#: plugins/check_ide_smart.c:256 4244msgid ""
4245"DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."
4246msgstr ""
4247
4248msgid "Nagios-compatible output is now always returned."
4249msgstr ""
4250
4251msgid "SMART commands are broken and have been disabled (See Notes in --help)."
4252msgstr ""
4253
4254msgid ""
4255"DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"
4256msgstr ""
4257
4258msgid "default and will be removed from future releases."
4259msgstr ""
4260
5189#, c-format 4261#, c-format
5190msgid "CRITICAL - Couldn't open device %s: %s\n" 4262msgid "CRITICAL - Couldn't open device %s: %s\n"
5191msgstr "" 4263msgstr ""
5192 4264
5193#: plugins/check_ide_smart.c:261
5194#, c-format 4265#, c-format
5195msgid "CRITICAL - SMART_CMD_ENABLE\n" 4266msgid "CRITICAL - SMART_CMD_ENABLE\n"
5196msgstr "" 4267msgstr ""
5197 4268
5198#: plugins/check_ide_smart.c:323 plugins/check_ide_smart.c:350
5199#, c-format 4269#, c-format
5200msgid "CRITICAL - SMART_READ_VALUES: %s\n" 4270msgid "CRITICAL - SMART_READ_VALUES: %s\n"
5201msgstr "" 4271msgstr ""
5202 4272
5203#: plugins/check_ide_smart.c:421
5204#, c-format 4273#, c-format
5205msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n" 4274msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"
5206msgstr "" 4275msgstr ""
5207 4276
5208#: plugins/check_ide_smart.c:429
5209#, c-format 4277#, c-format
5210msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n" 4278msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"
5211msgstr "" 4279msgstr ""
5212 4280
5213#: plugins/check_ide_smart.c:437
5214#, c-format 4281#, c-format
5215msgid "OK - Operational (%d/%d tests passed)\n" 4282msgid "OK - Operational (%d/%d tests passed)\n"
5216msgstr "" 4283msgstr ""
5217 4284
5218#: plugins/check_ide_smart.c:441
5219#, c-format 4285#, c-format
5220msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n" 4286msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n"
5221msgstr "" 4287msgstr ""
5222 4288
5223#: plugins/check_ide_smart.c:474
5224#, c-format 4289#, c-format
5225msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n" 4290msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"
5226msgstr "" 4291msgstr ""
5227 4292
5228#: plugins/check_ide_smart.c:480
5229#, c-format 4293#, c-format
5230msgid "OffLineCapability=%d {%s %s %s}\n" 4294msgid "OffLineCapability=%d {%s %s %s}\n"
5231msgstr "" 4295msgstr ""
5232 4296
5233#: plugins/check_ide_smart.c:486
5234#, c-format 4297#, c-format
5235msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n" 4298msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"
5236msgstr "" 4299msgstr ""
5237 4300
5238#: plugins/check_ide_smart.c:508 plugins/check_ide_smart.c:532
5239#, c-format 4301#, c-format
5240msgid "CRITICAL - %s: %s\n" 4302msgid "CRITICAL - %s: %s\n"
5241msgstr "" 4303msgstr ""
5242 4304
5243#: plugins/check_ide_smart.c:553 plugins/check_ide_smart.c:580 4305#, c-format
4306msgid "OK - Command sent (%s)\n"
4307msgstr ""
4308
5244#, c-format 4309#, c-format
5245msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n" 4310msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n"
5246msgstr "" 4311msgstr ""
5247 4312
5248#: plugins/check_ide_smart.c:599
5249#, c-format 4313#, c-format
5250msgid "" 4314msgid ""
5251"This plugin checks a local hard drive with the (Linux specific) SMART " 4315"This plugin checks a local hard drive with the (Linux specific) SMART "
5252"interface [http://smartlinux.sourceforge.net/smart/index.php]." 4316"interface [http://smartlinux.sourceforge.net/smart/index.php]."
5253msgstr "" 4317msgstr ""
5254 4318
5255#: plugins/check_ide_smart.c:609
5256msgid "Select device DEVICE" 4319msgid "Select device DEVICE"
5257msgstr "" 4320msgstr ""
5258 4321
5259#: plugins/check_ide_smart.c:610
5260msgid "" 4322msgid ""
5261"Note: if the device is selected with this option, _no_ other options are " 4323"Note: if the device is specified without this option, any further option will"
5262"accepted"
5263msgstr "" 4324msgstr ""
5264 4325
5265#: plugins/check_ide_smart.c:612 4326msgid "be ignored."
5266msgid "Perform immediately offline tests"
5267msgstr "" 4327msgstr ""
5268 4328
5269#: plugins/check_ide_smart.c:614 4329msgid ""
5270msgid "Returns the number of failed tests" 4330"The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"
5271msgstr "" 4331msgstr ""
5272 4332
5273#: plugins/check_ide_smart.c:616 4333msgid ""
5274msgid "Turn on automatic offline tests" 4334"broken in an underhand manner and have been disabled. You can use smartctl"
5275msgstr "" 4335msgstr ""
5276 4336
5277#: plugins/check_ide_smart.c:618 4337msgid "instead:"
5278msgid "Turn off automatic offline tests"
5279msgstr "" 4338msgstr ""
5280 4339
5281#: plugins/check_ide_smart.c:620 4340msgid "-0/--auto-off: use \"smartctl --offlineauto=off\""
5282msgid "Output suitable for the monitoring system" 4341msgstr ""
4342
4343msgid "-1/--auto-on: use \"smartctl --offlineauto=on\""
4344msgstr ""
4345
4346msgid "-i/--immediate: use \"smartctl --test=offline\""
5283msgstr "" 4347msgstr ""
5284 4348
5285#: plugins/negate.c:99
5286msgid "No data returned from command\n" 4349msgid "No data returned from command\n"
5287msgstr "" 4350msgstr ""
5288 4351
5289#: plugins/negate.c:170
5290msgid "" 4352msgid ""
5291"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) " 4353"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
5292"or integer (0-3)." 4354"or integer (0-3)."
5293msgstr "" 4355msgstr ""
5294 4356
5295#: plugins/negate.c:174
5296msgid "" 4357msgid ""
5297"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer " 4358"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer "
5298"(0-3)." 4359"(0-3)."
5299msgstr "" 4360msgstr ""
5300 4361
5301#: plugins/negate.c:180
5302msgid "" 4362msgid ""
5303"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4363"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5304"integer (0-3)." 4364"integer (0-3)."
5305msgstr "" 4365msgstr ""
5306 4366
5307#: plugins/negate.c:185
5308msgid "" 4367msgid ""
5309"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4368"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5310"integer (0-3)." 4369"integer (0-3)."
5311msgstr "" 4370msgstr ""
5312 4371
5313#: plugins/negate.c:190
5314msgid "" 4372msgid ""
5315"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4373"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5316"integer (0-3)." 4374"integer (0-3)."
5317msgstr "" 4375msgstr ""
5318 4376
5319#: plugins/negate.c:217
5320msgid "Require path to command" 4377msgid "Require path to command"
5321msgstr "" 4378msgstr ""
5322 4379
5323#: plugins/negate.c:246
5324msgid "" 4380msgid ""
5325"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)." 4381"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)."
5326msgstr "" 4382msgstr ""
5327 4383
5328#: plugins/negate.c:247
5329msgid "Additional switches can be used to control which state becomes what." 4384msgid "Additional switches can be used to control which state becomes what."
5330msgstr "" 4385msgstr ""
5331 4386
5332#: plugins/negate.c:256
5333msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status." 4387msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status."
5334msgstr "" 4388msgstr ""
5335 4389
5336#: plugins/negate.c:258
5337msgid "Custom result on Negate timeouts; see below for STATUS definition\n" 4390msgid "Custom result on Negate timeouts; see below for STATUS definition\n"
5338msgstr "" 4391msgstr ""
5339 4392
5340#: plugins/negate.c:264
5341#, c-format 4393#, c-format
5342msgid "" 4394msgid ""
5343" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n" 4395" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n"
5344msgstr "" 4396msgstr ""
5345 4397
5346#: plugins/negate.c:265
5347#, c-format 4398#, c-format
5348msgid "" 4399msgid ""
5349" quotes. Numeric values are accepted. If nothing is specified, permutes\n" 4400" quotes. Numeric values are accepted. If nothing is specified, permutes\n"
5350msgstr "" 4401msgstr ""
5351 4402
5352#: plugins/negate.c:266
5353#, c-format 4403#, c-format
5354msgid " OK and CRITICAL.\n" 4404msgid " OK and CRITICAL.\n"
5355msgstr "" 4405msgstr ""
5356 4406
5357#: plugins/negate.c:268
5358#, c-format 4407#, c-format
5359msgid "" 4408msgid ""
5360" Substitute output text as well. Will only substitute text in CAPITALS\n" 4409" Substitute output text as well. Will only substitute text in CAPITALS\n"
5361msgstr "" 4410msgstr ""
5362 4411
5363#: plugins/negate.c:273
5364msgid "Run check_ping and invert result. Must use full path to plugin" 4412msgid "Run check_ping and invert result. Must use full path to plugin"
5365msgstr "" 4413msgstr ""
5366 4414
5367#: plugins/negate.c:275
5368msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL" 4415msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL"
5369msgstr "" 4416msgstr ""
5370 4417
5371#: plugins/negate.c:278
5372msgid "" 4418msgid ""
5373"This plugin is a wrapper to take the output of another plugin and invert it." 4419"This plugin is a wrapper to take the output of another plugin and invert it."
5374msgstr "" 4420msgstr ""
5375 4421
5376#: plugins/negate.c:279
5377msgid "The full path of the plugin must be provided." 4422msgid "The full path of the plugin must be provided."
5378msgstr "" 4423msgstr ""
5379 4424
5380#: plugins/negate.c:280
5381msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL." 4425msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL."
5382msgstr "" 4426msgstr ""
5383 4427
5384#: plugins/negate.c:281
5385msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK." 4428msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK."
5386msgstr "" 4429msgstr ""
5387 4430
5388#: plugins/negate.c:282
5389msgid "Otherwise, the output state of the wrapped plugin is unchanged." 4431msgid "Otherwise, the output state of the wrapped plugin is unchanged."
5390msgstr "" 4432msgstr ""
5391 4433
5392#: plugins/negate.c:284
5393msgid "" 4434msgid ""
5394"Using timeout-result, it is possible to override the timeout behaviour or a" 4435"Using timeout-result, it is possible to override the timeout behaviour or a"
5395msgstr "" 4436msgstr ""
5396 4437
5397#: plugins/negate.c:285
5398msgid "plugin by setting the negate timeout a bit lower." 4438msgid "plugin by setting the negate timeout a bit lower."
5399msgstr "" 4439msgstr ""
5400 4440
5401#: plugins/netutils.c:49
5402#, c-format 4441#, c-format
5403msgid "%s - Socket timeout after %d seconds\n" 4442msgid "%s - Socket timeout after %d seconds\n"
5404msgstr "" 4443msgstr ""
5405 4444
5406#: plugins/netutils.c:51
5407#, c-format 4445#, c-format
5408msgid "%s - Abnormal timeout after %d seconds\n" 4446msgid "%s - Abnormal timeout after %d seconds\n"
5409msgstr "" 4447msgstr ""
5410 4448
5411#: plugins/netutils.c:79 plugins/netutils.c:281
5412msgid "Send failed" 4449msgid "Send failed"
5413msgstr "" 4450msgstr ""
5414 4451
5415#: plugins/netutils.c:96 plugins/netutils.c:296
5416msgid "No data was received from host!" 4452msgid "No data was received from host!"
5417msgstr "" 4453msgstr ""
5418 4454
5419#: plugins/netutils.c:204 plugins/netutils.c:240
5420msgid "Socket creation failed" 4455msgid "Socket creation failed"
5421msgstr "" 4456msgstr ""
5422 4457
5423#: plugins/netutils.c:233
5424msgid "Supplied path too long unix domain socket" 4458msgid "Supplied path too long unix domain socket"
5425msgstr "" 4459msgstr ""
5426 4460
5427#: plugins/netutils.c:305
5428msgid "Receive failed" 4461msgid "Receive failed"
5429msgstr "" 4462msgstr ""
5430 4463
5431#: plugins/netutils.c:331 plugins-root/check_dhcp.c:1342
5432#, c-format 4464#, c-format
5433msgid "Invalid hostname/address - %s" 4465msgid "Invalid hostname/address - %s"
5434msgstr "" 4466msgstr ""
5435 4467
5436#: plugins/popen.c:142
5437msgid "Could not malloc argv array in popen()" 4468msgid "Could not malloc argv array in popen()"
5438msgstr "" 4469msgstr ""
5439 4470
5440#: plugins/popen.c:152
5441msgid "CRITICAL - You need more args!!!" 4471msgid "CRITICAL - You need more args!!!"
5442msgstr "" 4472msgstr ""
5443 4473
5444#: plugins/popen.c:209
5445msgid "Cannot catch SIGCHLD" 4474msgid "Cannot catch SIGCHLD"
5446msgstr "" 4475msgstr ""
5447 4476
5448#: plugins/popen.c:304
5449#, c-format 4477#, c-format
5450msgid "CRITICAL - Plugin timed out after %d seconds\n" 4478msgid "CRITICAL - Plugin timed out after %d seconds\n"
5451msgstr "" 4479msgstr ""
5452 4480
5453#: plugins/popen.c:307
5454msgid "CRITICAL - popen timeout received, but no child process" 4481msgid "CRITICAL - popen timeout received, but no child process"
5455msgstr "" 4482msgstr ""
5456 4483
5457#: plugins/popen.c:323
5458msgid "sysconf error for _SC_OPEN_MAX"
5459msgstr ""
5460
5461#: plugins/urlize.c:130
5462#, c-format 4484#, c-format
5463msgid "" 4485msgid ""
5464"%s UNKNOWN - No data received from host\n" 4486"%s UNKNOWN - No data received from host\n"
5465"CMD: %s</A>\n" 4487"CMD: %s</A>\n"
5466msgstr "" 4488msgstr ""
5467 4489
5468#: plugins/urlize.c:169
5469msgid "" 4490msgid ""
5470"This plugin wraps the text output of another command (plugin) in HTML <A>" 4491"This plugin wraps the text output of another command (plugin) in HTML <A>"
5471msgstr "" 4492msgstr ""
5472 4493
5473#: plugins/urlize.c:170
5474msgid "" 4494msgid ""
5475"tags, thus displaying the child plugin's output as a clickable link in " 4495"tags, thus displaying the child plugin's output as a clickable link in "
5476"compatible" 4496"compatible"
5477msgstr "" 4497msgstr ""
5478 4498
5479#: plugins/urlize.c:171
5480msgid "" 4499msgid ""
5481"monitoring status screen. This plugin returns the status of the invoked " 4500"monitoring status screen. This plugin returns the status of the invoked "
5482"plugin." 4501"plugin."
5483msgstr "" 4502msgstr ""
5484 4503
5485#: plugins/urlize.c:181
5486msgid "" 4504msgid ""
5487"Pay close attention to quoting to ensure that the shell passes the expected" 4505"Pay close attention to quoting to ensure that the shell passes the expected"
5488msgstr "" 4506msgstr ""
5489 4507
5490#: plugins/urlize.c:182
5491msgid "data to the plugin. For example, in:" 4508msgid "data to the plugin. For example, in:"
5492msgstr "" 4509msgstr ""
5493 4510
5494#: plugins/urlize.c:183
5495msgid "urlize http://example.com/ check_http -H example.com -r 'two words'" 4511msgid "urlize http://example.com/ check_http -H example.com -r 'two words'"
5496msgstr "" 4512msgstr ""
5497 4513
5498#: plugins/urlize.c:184
5499msgid "the shell will remove the single quotes and urlize will see:" 4514msgid "the shell will remove the single quotes and urlize will see:"
5500msgstr "" 4515msgstr ""
5501 4516
5502#: plugins/urlize.c:185
5503msgid "urlize http://example.com/ check_http -H example.com -r two words" 4517msgid "urlize http://example.com/ check_http -H example.com -r two words"
5504msgstr "" 4518msgstr ""
5505 4519
5506#: plugins/urlize.c:186
5507msgid "You probably want:" 4520msgid "You probably want:"
5508msgstr "" 4521msgstr ""
5509 4522
5510#: plugins/urlize.c:187
5511msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\"" 4523msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\""
5512msgstr "" 4524msgstr ""
5513 4525
5514#: plugins/utils.c:174
5515#, c-format
5516msgid "%s - Plugin timed out after %d seconds\n"
5517msgstr ""
5518
5519#: plugins/utils.c:469
5520msgid "failed realloc in strpcpy\n" 4526msgid "failed realloc in strpcpy\n"
5521msgstr "" 4527msgstr ""
5522 4528
5523#: plugins/utils.c:511
5524msgid "failed malloc in strscat\n" 4529msgid "failed malloc in strscat\n"
5525msgstr "" 4530msgstr ""
5526 4531
5527#: plugins/utils.c:531
5528msgid "failed malloc in xvasprintf\n" 4532msgid "failed malloc in xvasprintf\n"
5529msgstr "" 4533msgstr ""
5530 4534
5531#: plugins/utils.h:137
5532#, c-format 4535#, c-format
5533msgid "" 4536msgid ""
5534" %s (-h | --help) for detailed help\n" 4537" %s (-h | --help) for detailed help\n"
5535" %s (-V | --version) for version information\n" 4538" %s (-V | --version) for version information\n"
5536msgstr "" 4539msgstr ""
5537 4540
5538#: plugins/utils.h:141
5539msgid "" 4541msgid ""
5540"\n" 4542"\n"
5541"Options:\n" 4543"Options:\n"
@@ -5545,7 +4547,6 @@ msgid ""
5545" Print version information\n" 4547" Print version information\n"
5546msgstr "" 4548msgstr ""
5547 4549
5548#: plugins/utils.h:148
5549#, c-format 4550#, c-format
5550msgid "" 4551msgid ""
5551" -H, --hostname=ADDRESS\n" 4552" -H, --hostname=ADDRESS\n"
@@ -5554,7 +4555,6 @@ msgid ""
5554" Port number (default: %s)\n" 4555" Port number (default: %s)\n"
5555msgstr "" 4556msgstr ""
5556 4557
5557#: plugins/utils.h:154
5558msgid "" 4558msgid ""
5559" -4, --use-ipv4\n" 4559" -4, --use-ipv4\n"
5560" Use IPv4 connection\n" 4560" Use IPv4 connection\n"
@@ -5562,14 +4562,12 @@ msgid ""
5562" Use IPv6 connection\n" 4562" Use IPv6 connection\n"
5563msgstr "" 4563msgstr ""
5564 4564
5565#: plugins/utils.h:160
5566msgid "" 4565msgid ""
5567" -v, --verbose\n" 4566" -v, --verbose\n"
5568" Show details for command-line debugging (output may be truncated by\n" 4567" Show details for command-line debugging (output may be truncated by\n"
5569"\t\tthe monitoring system)\n" 4568" the monitoring system)\n"
5570msgstr "" 4569msgstr ""
5571 4570
5572#: plugins/utils.h:165
5573msgid "" 4571msgid ""
5574" -w, --warning=DOUBLE\n" 4572" -w, --warning=DOUBLE\n"
5575" Response time to result in warning status (seconds)\n" 4573" Response time to result in warning status (seconds)\n"
@@ -5577,7 +4575,6 @@ msgid ""
5577" Response time to result in critical status (seconds)\n" 4575" Response time to result in critical status (seconds)\n"
5578msgstr "" 4576msgstr ""
5579 4577
5580#: plugins/utils.h:171
5581msgid "" 4578msgid ""
5582" -w, --warning=RANGE\n" 4579" -w, --warning=RANGE\n"
5583" Warning range (format: start:end). Alert if outside this range\n" 4580" Warning range (format: start:end). Alert if outside this range\n"
@@ -5585,14 +4582,18 @@ msgid ""
5585" Critical range\n" 4582" Critical range\n"
5586msgstr "" 4583msgstr ""
5587 4584
5588#: plugins/utils.h:177
5589#, c-format 4585#, c-format
5590msgid "" 4586msgid ""
5591" -t, --timeout=INTEGER\n" 4587" -t, --timeout=INTEGER\n"
5592" Seconds before connection times out (default: %d)\n" 4588" Seconds before connection times out (default: %d)\n"
5593msgstr "" 4589msgstr ""
5594 4590
5595#: plugins/utils.h:182 4591#, c-format
4592msgid ""
4593" -t, --timeout=INTEGER\n"
4594" Seconds before plugin times out (default: %d)\n"
4595msgstr ""
4596
5596msgid "" 4597msgid ""
5597" --extra-opts=[section][@file]\n" 4598" --extra-opts=[section][@file]\n"
5598" Read options from an ini file. See\n" 4599" Read options from an ini file. See\n"
@@ -5600,14 +4601,12 @@ msgid ""
5600" for usage and examples.\n" 4601" for usage and examples.\n"
5601msgstr "" 4602msgstr ""
5602 4603
5603#: plugins/utils.h:190
5604msgid "" 4604msgid ""
5605" See:\n" 4605" See:\n"
5606" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n" 4606" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n"
5607" for THRESHOLD format and examples.\n" 4607" for THRESHOLD format and examples.\n"
5608msgstr "" 4608msgstr ""
5609 4609
5610#: plugins/utils.h:195
5611msgid "" 4610msgid ""
5612"\n" 4611"\n"
5613"Send email to help@monitoring-plugins.org if you have questions regarding\n" 4612"Send email to help@monitoring-plugins.org if you have questions regarding\n"
@@ -5616,7 +4615,6 @@ msgid ""
5616"\n" 4615"\n"
5617msgstr "" 4616msgstr ""
5618 4617
5619#: plugins/utils.h:200
5620msgid "" 4618msgid ""
5621"\n" 4619"\n"
5622"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may " 4620"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may "
@@ -5625,398 +4623,322 @@ msgid ""
5625"For more information about these matters, see the file named COPYING.\n" 4623"For more information about these matters, see the file named COPYING.\n"
5626msgstr "" 4624msgstr ""
5627 4625
5628#: plugins-root/check_dhcp.c:320
5629#, c-format 4626#, c-format
5630msgid "Error: Could not get hardware address of interface '%s'\n" 4627msgid "Error: Could not get hardware address of interface '%s'\n"
5631msgstr "" 4628msgstr ""
5632 4629
5633#: plugins-root/check_dhcp.c:342
5634#, c-format 4630#, c-format
5635msgid "Error: if_nametoindex error - %s.\n" 4631msgid "Error: if_nametoindex error - %s.\n"
5636msgstr "" 4632msgstr ""
5637 4633
5638#: plugins-root/check_dhcp.c:347
5639#, c-format 4634#, c-format
5640msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n" 4635msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"
5641msgstr "" 4636msgstr ""
5642 4637
5643#: plugins-root/check_dhcp.c:352
5644#, c-format 4638#, c-format
5645msgid "" 4639msgid ""
5646"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n" 4640"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"
5647msgstr "" 4641msgstr ""
5648 4642
5649#: plugins-root/check_dhcp.c:357
5650#, c-format 4643#, c-format
5651msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n" 4644msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"
5652msgstr "" 4645msgstr ""
5653 4646
5654#: plugins-root/check_dhcp.c:388
5655#, c-format 4647#, c-format
5656msgid "" 4648msgid ""
5657"Error: can't find unit number in interface_name (%s) - expecting TypeNumber " 4649"Error: can't find unit number in interface_name (%s) - expecting TypeNumber "
5658"eg lnc0.\n" 4650"eg lnc0.\n"
5659msgstr "" 4651msgstr ""
5660 4652
5661#: plugins-root/check_dhcp.c:393 plugins-root/check_dhcp.c:405
5662#, c-format 4653#, c-format
5663msgid "" 4654msgid ""
5664"Error: can't read MAC address from DLPI streams interface for device %s unit " 4655"Error: can't read MAC address from DLPI streams interface for device %s unit "
5665"%d.\n" 4656"%d.\n"
5666msgstr "" 4657msgstr ""
5667 4658
5668#: plugins-root/check_dhcp.c:411
5669#, c-format 4659#, c-format
5670msgid "" 4660msgid ""
5671"Error: can't get MAC address for this architecture. Use the --mac option.\n" 4661"Error: can't get MAC address for this architecture. Use the --mac option.\n"
5672msgstr "" 4662msgstr ""
5673 4663
5674#: plugins-root/check_dhcp.c:430
5675#, c-format 4664#, c-format
5676msgid "Error: Cannot determine IP address of interface %s\n" 4665msgid "Error: Cannot determine IP address of interface %s\n"
5677msgstr "" 4666msgstr ""
5678 4667
5679#: plugins-root/check_dhcp.c:438
5680#, c-format 4668#, c-format
5681msgid "Error: Cannot get interface IP address on this platform.\n" 4669msgid "Error: Cannot get interface IP address on this platform.\n"
5682msgstr "" 4670msgstr ""
5683 4671
5684#: plugins-root/check_dhcp.c:443
5685#, c-format 4672#, c-format
5686msgid "Pretending to be relay client %s\n" 4673msgid "Pretending to be relay client %s\n"
5687msgstr "" 4674msgstr ""
5688 4675
5689#: plugins-root/check_dhcp.c:528
5690#, c-format 4676#, c-format
5691msgid "DHCPDISCOVER to %s port %d\n" 4677msgid "DHCPDISCOVER to %s port %d\n"
5692msgstr "" 4678msgstr ""
5693 4679
5694#: plugins-root/check_dhcp.c:580
5695#, c-format 4680#, c-format
5696msgid "Result=ERROR\n" 4681msgid "Result=ERROR\n"
5697msgstr "" 4682msgstr ""
5698 4683
5699#: plugins-root/check_dhcp.c:586
5700#, c-format 4684#, c-format
5701msgid "Result=OK\n" 4685msgid "Result=OK\n"
5702msgstr "" 4686msgstr ""
5703 4687
5704#: plugins-root/check_dhcp.c:596
5705#, c-format 4688#, c-format
5706msgid "DHCPOFFER from IP address %s" 4689msgid "DHCPOFFER from IP address %s"
5707msgstr "" 4690msgstr ""
5708 4691
5709#: plugins-root/check_dhcp.c:597
5710#, c-format 4692#, c-format
5711msgid " via %s\n" 4693msgid " via %s\n"
5712msgstr "" 4694msgstr ""
5713 4695
5714#: plugins-root/check_dhcp.c:604
5715#, c-format 4696#, c-format
5716msgid "" 4697msgid ""
5717"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n" 4698"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"
5718msgstr "" 4699msgstr ""
5719 4700
5720#: plugins-root/check_dhcp.c:626
5721#, c-format 4701#, c-format
5722msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n" 4702msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n"
5723msgstr "" 4703msgstr ""
5724 4704
5725#: plugins-root/check_dhcp.c:644
5726#, c-format 4705#, c-format
5727msgid "Total responses seen on the wire: %d\n" 4706msgid "Total responses seen on the wire: %d\n"
5728msgstr "" 4707msgstr ""
5729 4708
5730#: plugins-root/check_dhcp.c:645
5731#, c-format 4709#, c-format
5732msgid "Valid responses for this machine: %d\n" 4710msgid "Valid responses for this machine: %d\n"
5733msgstr "" 4711msgstr ""
5734 4712
5735#: plugins-root/check_dhcp.c:660
5736#, c-format 4713#, c-format
5737msgid "send_dhcp_packet result: %d\n" 4714msgid "send_dhcp_packet result: %d\n"
5738msgstr "" 4715msgstr ""
5739 4716
5740#: plugins-root/check_dhcp.c:693
5741#, c-format 4717#, c-format
5742msgid "No (more) data received (nfound: %d)\n" 4718msgid "No (more) data received (nfound: %d)\n"
5743msgstr "" 4719msgstr ""
5744 4720
5745#: plugins-root/check_dhcp.c:712
5746#, c-format 4721#, c-format
5747msgid "recvfrom() failed, " 4722msgid "recvfrom() failed, "
5748msgstr "" 4723msgstr ""
5749 4724
5750#: plugins-root/check_dhcp.c:719
5751#, c-format 4725#, c-format
5752msgid "receive_dhcp_packet() result: %d\n" 4726msgid "receive_dhcp_packet() result: %d\n"
5753msgstr "" 4727msgstr ""
5754 4728
5755#: plugins-root/check_dhcp.c:720
5756#, c-format 4729#, c-format
5757msgid "receive_dhcp_packet() source: %s\n" 4730msgid "receive_dhcp_packet() source: %s\n"
5758msgstr "" 4731msgstr ""
5759 4732
5760#: plugins-root/check_dhcp.c:750
5761#, c-format 4733#, c-format
5762msgid "Error: Could not create socket!\n" 4734msgid "Error: Could not create socket!\n"
5763msgstr "" 4735msgstr ""
5764 4736
5765#: plugins-root/check_dhcp.c:760
5766#, c-format 4737#, c-format
5767msgid "Error: Could not set reuse address option on DHCP socket!\n" 4738msgid "Error: Could not set reuse address option on DHCP socket!\n"
5768msgstr "" 4739msgstr ""
5769 4740
5770#: plugins-root/check_dhcp.c:766
5771#, c-format 4741#, c-format
5772msgid "Error: Could not set broadcast option on DHCP socket!\n" 4742msgid "Error: Could not set broadcast option on DHCP socket!\n"
5773msgstr "" 4743msgstr ""
5774 4744
5775#: plugins-root/check_dhcp.c:775
5776#, c-format 4745#, c-format
5777msgid "" 4746msgid ""
5778"Error: Could not bind socket to interface %s. Check your privileges...\n" 4747"Error: Could not bind socket to interface %s. Check your privileges...\n"
5779msgstr "" 4748msgstr ""
5780 4749
5781#: plugins-root/check_dhcp.c:786
5782#, c-format 4750#, c-format
5783msgid "" 4751msgid ""
5784"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n" 4752"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"
5785msgstr "" 4753msgstr ""
5786 4754
5787#: plugins-root/check_dhcp.c:820
5788#, c-format 4755#, c-format
5789msgid "Requested server address: %s\n" 4756msgid "Requested server address: %s\n"
5790msgstr "" 4757msgstr ""
5791 4758
5792#: plugins-root/check_dhcp.c:882
5793#, c-format 4759#, c-format
5794msgid "Lease Time: Infinite\n" 4760msgid "Lease Time: Infinite\n"
5795msgstr "" 4761msgstr ""
5796 4762
5797#: plugins-root/check_dhcp.c:884
5798#, c-format 4763#, c-format
5799msgid "Lease Time: %lu seconds\n" 4764msgid "Lease Time: %lu seconds\n"
5800msgstr "" 4765msgstr ""
5801 4766
5802#: plugins-root/check_dhcp.c:886
5803#, c-format 4767#, c-format
5804msgid "Renewal Time: Infinite\n" 4768msgid "Renewal Time: Infinite\n"
5805msgstr "" 4769msgstr ""
5806 4770
5807#: plugins-root/check_dhcp.c:888
5808#, c-format 4771#, c-format
5809msgid "Renewal Time: %lu seconds\n" 4772msgid "Renewal Time: %lu seconds\n"
5810msgstr "" 4773msgstr ""
5811 4774
5812#: plugins-root/check_dhcp.c:890
5813#, c-format 4775#, c-format
5814msgid "Rebinding Time: Infinite\n" 4776msgid "Rebinding Time: Infinite\n"
5815msgstr "" 4777msgstr ""
5816 4778
5817#: plugins-root/check_dhcp.c:891
5818#, c-format 4779#, c-format
5819msgid "Rebinding Time: %lu seconds\n" 4780msgid "Rebinding Time: %lu seconds\n"
5820msgstr "" 4781msgstr ""
5821 4782
5822#: plugins-root/check_dhcp.c:919
5823#, c-format 4783#, c-format
5824msgid "Added offer from server @ %s" 4784msgid "Added offer from server @ %s"
5825msgstr "" 4785msgstr ""
5826 4786
5827#: plugins-root/check_dhcp.c:920
5828#, c-format 4787#, c-format
5829msgid " of IP address %s\n" 4788msgid " of IP address %s\n"
5830msgstr "" 4789msgstr ""
5831 4790
5832#: plugins-root/check_dhcp.c:987
5833#, c-format 4791#, c-format
5834msgid "DHCP Server Match: Offerer=%s" 4792msgid "DHCP Server Match: Offerer=%s"
5835msgstr "" 4793msgstr ""
5836 4794
5837#: plugins-root/check_dhcp.c:988
5838#, c-format 4795#, c-format
5839msgid " Requested=%s" 4796msgid " Requested=%s"
5840msgstr "" 4797msgstr ""
5841 4798
5842#: plugins-root/check_dhcp.c:990
5843#, c-format 4799#, c-format
5844msgid " (duplicate)" 4800msgid " (duplicate)"
5845msgstr "" 4801msgstr ""
5846 4802
5847#: plugins-root/check_dhcp.c:991
5848#, c-format 4803#, c-format
5849msgid "\n" 4804msgid "\n"
5850msgstr "" 4805msgstr ""
5851 4806
5852#: plugins-root/check_dhcp.c:1039
5853#, c-format 4807#, c-format
5854msgid "No DHCPOFFERs were received.\n" 4808msgid "No DHCPOFFERs were received.\n"
5855msgstr "" 4809msgstr ""
5856 4810
5857#: plugins-root/check_dhcp.c:1043
5858#, c-format 4811#, c-format
5859msgid "Received %d DHCPOFFER(s)" 4812msgid "Received %d DHCPOFFER(s)"
5860msgstr "" 4813msgstr ""
5861 4814
5862#: plugins-root/check_dhcp.c:1046
5863#, c-format 4815#, c-format
5864msgid ", %s%d of %d requested servers responded" 4816msgid ", %s%d of %d requested servers responded"
5865msgstr "" 4817msgstr ""
5866 4818
5867#: plugins-root/check_dhcp.c:1049
5868#, c-format 4819#, c-format
5869msgid ", requested address (%s) was %soffered" 4820msgid ", requested address (%s) was %soffered"
5870msgstr "" 4821msgstr ""
5871 4822
5872#: plugins-root/check_dhcp.c:1049
5873msgid "not " 4823msgid "not "
5874msgstr "" 4824msgstr ""
5875 4825
5876#: plugins-root/check_dhcp.c:1051
5877#, c-format 4826#, c-format
5878msgid ", max lease time = " 4827msgid ", max lease time = "
5879msgstr "" 4828msgstr ""
5880 4829
5881#: plugins-root/check_dhcp.c:1053
5882#, c-format 4830#, c-format
5883msgid "Infinity" 4831msgid "Infinity"
5884msgstr "" 4832msgstr ""
5885 4833
5886#: plugins-root/check_dhcp.c:1234 4834msgid "Got unexpected non-option argument"
4835msgstr ""
4836
5887#, c-format 4837#, c-format
5888msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n" 4838msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"
5889msgstr "" 4839msgstr ""
5890 4840
5891#: plugins-root/check_dhcp.c:1246
5892#, c-format 4841#, c-format
5893msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n" 4842msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"
5894msgstr "" 4843msgstr ""
5895 4844
5896#: plugins-root/check_dhcp.c:1259
5897#, c-format 4845#, c-format
5898msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n" 4846msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"
5899msgstr "" 4847msgstr ""
5900 4848
5901#: plugins-root/check_dhcp.c:1271
5902#, c-format 4849#, c-format
5903msgid "" 4850msgid ""
5904"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n" 4851"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"
5905msgstr "" 4852msgstr ""
5906 4853
5907#: plugins-root/check_dhcp.c:1295
5908#, c-format 4854#, c-format
5909msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n" 4855msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"
5910msgstr "" 4856msgstr ""
5911 4857
5912#: plugins-root/check_dhcp.c:1374
5913#, c-format 4858#, c-format
5914msgid "Hardware address: " 4859msgid "Hardware address: "
5915msgstr "" 4860msgstr ""
5916 4861
5917#: plugins-root/check_dhcp.c:1390
5918msgid "This plugin tests the availability of DHCP servers on a network." 4862msgid "This plugin tests the availability of DHCP servers on a network."
5919msgstr "" 4863msgstr ""
5920 4864
5921#: plugins-root/check_dhcp.c:1402
5922msgid "IP address of DHCP server that we must hear from" 4865msgid "IP address of DHCP server that we must hear from"
5923msgstr "" 4866msgstr ""
5924 4867
5925#: plugins-root/check_dhcp.c:1404
5926msgid "IP address that should be offered by at least one DHCP server" 4868msgid "IP address that should be offered by at least one DHCP server"
5927msgstr "" 4869msgstr ""
5928 4870
5929#: plugins-root/check_dhcp.c:1406
5930msgid "Seconds to wait for DHCPOFFER before timeout occurs" 4871msgid "Seconds to wait for DHCPOFFER before timeout occurs"
5931msgstr "" 4872msgstr ""
5932 4873
5933#: plugins-root/check_dhcp.c:1408
5934msgid "Interface to to use for listening (i.e. eth0)" 4874msgid "Interface to to use for listening (i.e. eth0)"
5935msgstr "" 4875msgstr ""
5936 4876
5937#: plugins-root/check_dhcp.c:1410
5938msgid "MAC address to use in the DHCP request" 4877msgid "MAC address to use in the DHCP request"
5939msgstr "" 4878msgstr ""
5940 4879
5941#: plugins-root/check_dhcp.c:1412
5942msgid "Unicast testing: mimic a DHCP relay, requires -s" 4880msgid "Unicast testing: mimic a DHCP relay, requires -s"
5943msgstr "" 4881msgstr ""
5944 4882
5945#: plugins-root/check_icmp.c:1295
5946msgid "specify a target" 4883msgid "specify a target"
5947msgstr "" 4884msgstr ""
5948 4885
5949#: plugins-root/check_icmp.c:1297 4886msgid "Use IPv4 (default) or IPv6 to communicate with the targets"
4887msgstr ""
4888
5950msgid "warning threshold (currently " 4889msgid "warning threshold (currently "
5951msgstr "" 4890msgstr ""
5952 4891
5953#: plugins-root/check_icmp.c:1300
5954msgid "critical threshold (currently " 4892msgid "critical threshold (currently "
5955msgstr "" 4893msgstr ""
5956 4894
5957#: plugins-root/check_icmp.c:1303
5958msgid "specify a source IP address or device name" 4895msgid "specify a source IP address or device name"
5959msgstr "" 4896msgstr ""
5960 4897
5961#: plugins-root/check_icmp.c:1305
5962msgid "number of packets to send (currently " 4898msgid "number of packets to send (currently "
5963msgstr "" 4899msgstr ""
5964 4900
5965#: plugins-root/check_icmp.c:1308
5966msgid "max packet interval (currently " 4901msgid "max packet interval (currently "
5967msgstr "" 4902msgstr ""
5968 4903
5969#: plugins-root/check_icmp.c:1311
5970msgid "max target interval (currently " 4904msgid "max target interval (currently "
5971msgstr "" 4905msgstr ""
5972 4906
5973#: plugins-root/check_icmp.c:1314
5974msgid "number of alive hosts required for success" 4907msgid "number of alive hosts required for success"
5975msgstr "" 4908msgstr ""
5976 4909
5977#: plugins-root/check_icmp.c:1317
5978msgid "TTL on outgoing packets (currently " 4910msgid "TTL on outgoing packets (currently "
5979msgstr "" 4911msgstr ""
5980 4912
5981#: plugins-root/check_icmp.c:1320
5982msgid "timeout value (seconds, currently " 4913msgid "timeout value (seconds, currently "
5983msgstr "" 4914msgstr ""
5984 4915
5985#: plugins-root/check_icmp.c:1323
5986msgid "Number of icmp data bytes to send" 4916msgid "Number of icmp data bytes to send"
5987msgstr "" 4917msgstr ""
5988 4918
5989#: plugins-root/check_icmp.c:1324
5990msgid "Packet size will be data bytes + icmp header (currently" 4919msgid "Packet size will be data bytes + icmp header (currently"
5991msgstr "" 4920msgstr ""
5992 4921
5993#: plugins-root/check_icmp.c:1326
5994msgid "verbose" 4922msgid "verbose"
5995msgstr "" 4923msgstr ""
5996 4924
5997#: plugins-root/check_icmp.c:1330
5998msgid "The -H switch is optional. Naming a host (or several) to check is not." 4925msgid "The -H switch is optional. Naming a host (or several) to check is not."
5999msgstr "" 4926msgstr ""
6000 4927
6001#: plugins-root/check_icmp.c:1332
6002msgid "" 4928msgid ""
6003"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%" 4929"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"
6004msgstr "" 4930msgstr ""
6005 4931
6006#: plugins-root/check_icmp.c:1333
6007msgid "packet loss. The default values should work well for most users." 4932msgid "packet loss. The default values should work well for most users."
6008msgstr "" 4933msgstr ""
6009 4934
6010#: plugins-root/check_icmp.c:1334
6011msgid "" 4935msgid ""
6012"You can specify different RTA factors using the standardized abbreviations" 4936"You can specify different RTA factors using the standardized abbreviations"
6013msgstr "" 4937msgstr ""
6014 4938
6015#: plugins-root/check_icmp.c:1335
6016msgid "" 4939msgid ""
6017"us (microseconds), ms (milliseconds, default) or just plain s for seconds." 4940"us (microseconds), ms (milliseconds, default) or just plain s for seconds."
6018msgstr "" 4941msgstr ""
6019 4942
6020#: plugins-root/check_icmp.c:1341
6021msgid "The -v switch can be specified several times for increased verbosity." 4943msgid "The -v switch can be specified several times for increased verbosity."
6022msgstr "" 4944msgstr ""
diff --git a/tap/tap.3 b/tap/tap.3
index 4b23c24a..dce85fcd 100644
--- a/tap/tap.3
+++ b/tap/tap.3
@@ -291,7 +291,7 @@ always returns 0.
291.Xc 291.Xc
292.El 292.El
293.Pp 293.Pp
294For maximum compatability your test program should return a particular 294For maximum compatibility your test program should return a particular
295exit code. This is calculated by 295exit code. This is calculated by
296.Fn exit_status 296.Fn exit_status
297so it is sufficient to always return from 297so it is sufficient to always return from
@@ -309,7 +309,7 @@ directory in the source distribution contains numerous tests of
309functionality, written using 309functionality, written using
310.Nm . 310.Nm .
311Examine them for examples of how to construct test suites. 311Examine them for examples of how to construct test suites.
312.Sh COMPATABILITY 312.Sh COMPATIBILITY
313.Nm 313.Nm
314strives to be compatible with the Perl Test::More and Test::Harness 314strives to be compatible with the Perl Test::More and Test::Harness
315modules. The test suite verifies that 315modules. The test suite verifies that
diff --git a/tap/tap.h b/tap/tap.h
index bd817893..8ee525c8 100644
--- a/tap/tap.h
+++ b/tap/tap.h
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting 27/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
28 and requires the caller to add the final comma if they've ommitted 28 and requires the caller to add the final comma if they've omitted
29 the optional arguments */ 29 the optional arguments */
30#ifdef __GNUC__ 30#ifdef __GNUC__
31# define ok(e, test, ...) ((e) ? \ 31# define ok(e, test, ...) ((e) ? \
diff --git a/tools/build_perl_modules b/tools/build_perl_modules
index 5a57a471..b8cd34c3 100755
--- a/tools/build_perl_modules
+++ b/tools/build_perl_modules
@@ -140,7 +140,7 @@ my $libs = "$destdir/$prefix/lib:$destdir/$prefix/lib/$Config{archname}";
140 140
141my $topdir = cwd(); 141my $topdir = cwd();
142 142
143# set an initial value if there isnt one already 143# set an initial value if there isn't one already
144# Need to use PERL5LIB to ensure we get pre-installed mods from earlier 144# Need to use PERL5LIB to ensure we get pre-installed mods from earlier
145# tags in the install_order file 145# tags in the install_order file
146$ENV{PERL5LIB} ||= q{}; 146$ENV{PERL5LIB} ||= q{};
@@ -149,8 +149,8 @@ $ENV{PERL5LIB} ||= q{};
149$ENV{PERL_AUTOINSTALL} = "--skipdeps"; 149$ENV{PERL_AUTOINSTALL} = "--skipdeps";
150 150
151# keep a record of how many times a module build is done. This is so they may 151# keep a record of how many times a module build is done. This is so they may
152# be built a second time to include optional prereq's that couldnt 152# be built a second time to include optional prereq's that couldn't
153# previously be built due to circular dependancies 153# previously be built due to circular dependencies
154my %built_modules; 154my %built_modules;
155foreach my $tarball (@tarballs) { 155foreach my $tarball (@tarballs) {
156 ( my $dir = $tarball ) =~ s/\.(?:tgz|tar.gz)$//; 156 ( my $dir = $tarball ) =~ s/\.(?:tgz|tar.gz)$//;
diff --git a/tools/p1.pl b/tools/p1.pl
index 2788dbff..9cbe6dc0 100644
--- a/tools/p1.pl
+++ b/tools/p1.pl
@@ -2,7 +2,7 @@
2# 2#
3# Hacked version of the sample code from the perlembedded doco. 3# Hacked version of the sample code from the perlembedded doco.
4# 4#
5# Only major changes are to separate the compiling and cacheing from 5# Only major changes are to separate the compiling and caching from
6# the execution so that the cache can be kept in "non-volatile" parent 6# the execution so that the cache can be kept in "non-volatile" parent
7# process while the execution is done from "volatile" child processes 7# process while the execution is done from "volatile" child processes
8# and that STDOUT is redirected to a file by means of a tied filehandle 8# and that STDOUT is redirected to a file by means of a tied filehandle
diff --git a/tools/squid.conf b/tools/squid.conf
new file mode 100644
index 00000000..bed7a583
--- /dev/null
+++ b/tools/squid.conf
@@ -0,0 +1,7979 @@
1# WELCOME TO SQUID 3.5.27
2# ----------------------------
3#
4# This is the documentation for the Squid configuration file.
5# This documentation can also be found online at:
6# http://www.squid-cache.org/Doc/config/
7#
8# You may wish to look at the Squid home page and wiki for the
9# FAQ and other documentation:
10# http://www.squid-cache.org/
11# http://wiki.squid-cache.org/SquidFaq
12# http://wiki.squid-cache.org/ConfigExamples
13#
14# This documentation shows what the defaults for various directives
15# happen to be. If you don't need to change the default, you should
16# leave the line out of your squid.conf in most cases.
17#
18# In some cases "none" refers to no default setting at all,
19# while in other cases it refers to the value of the option
20# - the comments for that keyword indicate if this is the case.
21#
22
23# Configuration options can be included using the "include" directive.
24# Include takes a list of files to include. Quoting and wildcards are
25# supported.
26#
27# For example,
28#
29# include /path/to/included/file/squid.acl.config
30#
31# Includes can be nested up to a hard-coded depth of 16 levels.
32# This arbitrary restriction is to prevent recursive include references
33# from causing Squid entering an infinite loop whilst trying to load
34# configuration files.
35#
36# Values with byte units
37#
38# Squid accepts size units on some size related directives. All
39# such directives are documented with a default value displaying
40# a unit.
41#
42# Units accepted by Squid are:
43# bytes - byte
44# KB - Kilobyte (1024 bytes)
45# MB - Megabyte
46# GB - Gigabyte
47#
48# Values with spaces, quotes, and other special characters
49#
50# Squid supports directive parameters with spaces, quotes, and other
51# special characters. Surround such parameters with "double quotes". Use
52# the configuration_includes_quoted_values directive to enable or
53# disable that support.
54#
55# Squid supports reading configuration option parameters from external
56# files using the syntax:
57# parameters("/path/filename")
58# For example:
59# acl whitelist dstdomain parameters("/etc/squid/whitelist.txt")
60#
61# Conditional configuration
62#
63# If-statements can be used to make configuration directives
64# depend on conditions:
65#
66# if <CONDITION>
67# ... regular configuration directives ...
68# [else
69# ... regular configuration directives ...]
70# endif
71#
72# The else part is optional. The keywords "if", "else", and "endif"
73# must be typed on their own lines, as if they were regular
74# configuration directives.
75#
76# NOTE: An else-if condition is not supported.
77#
78# These individual conditions types are supported:
79#
80# true
81# Always evaluates to true.
82# false
83# Always evaluates to false.
84# <integer> = <integer>
85# Equality comparison of two integer numbers.
86#
87#
88# SMP-Related Macros
89#
90# The following SMP-related preprocessor macros can be used.
91#
92# ${process_name} expands to the current Squid process "name"
93# (e.g., squid1, squid2, or cache1).
94#
95# ${process_number} expands to the current Squid process
96# identifier, which is an integer number (e.g., 1, 2, 3) unique
97# across all Squid processes of the current service instance.
98#
99# ${service_name} expands into the current Squid service instance
100# name identifier which is provided by -n on the command line.
101#
102
103# TAG: broken_vary_encoding
104# This option is not yet supported by Squid-3.
105#Default:
106# none
107
108# TAG: cache_vary
109# This option is not yet supported by Squid-3.
110#Default:
111# none
112
113# TAG: error_map
114# This option is not yet supported by Squid-3.
115#Default:
116# none
117
118# TAG: external_refresh_check
119# This option is not yet supported by Squid-3.
120#Default:
121# none
122
123# TAG: location_rewrite_program
124# This option is not yet supported by Squid-3.
125#Default:
126# none
127
128# TAG: refresh_stale_hit
129# This option is not yet supported by Squid-3.
130#Default:
131# none
132
133# TAG: hierarchy_stoplist
134# Remove this line. Use always_direct or cache_peer_access ACLs instead if you need to prevent cache_peer use.
135#Default:
136# none
137
138# TAG: log_access
139# Remove this line. Use acls with access_log directives to control access logging
140#Default:
141# none
142
143# TAG: log_icap
144# Remove this line. Use acls with icap_log directives to control icap logging
145#Default:
146# none
147
148# TAG: ignore_ims_on_miss
149# Remove this line. The HTTP/1.1 feature is now configured by 'cache_miss_revalidate'.
150#Default:
151# none
152
153# TAG: chunked_request_body_max_size
154# Remove this line. Squid is now HTTP/1.1 compliant.
155#Default:
156# none
157
158# TAG: dns_v4_fallback
159# Remove this line. Squid performs a 'Happy Eyeballs' algorithm, the 'fallback' algorithm is no longer relevant.
160#Default:
161# none
162
163# TAG: emulate_httpd_log
164# Replace this with an access_log directive using the format 'common' or 'combined'.
165#Default:
166# none
167
168# TAG: forward_log
169# Use a regular access.log with ACL limiting it to MISS events.
170#Default:
171# none
172
173# TAG: ftp_list_width
174# Remove this line. Configure FTP page display using the CSS controls in errorpages.css instead.
175#Default:
176# none
177
178# TAG: ignore_expect_100
179# Remove this line. The HTTP/1.1 feature is now fully supported by default.
180#Default:
181# none
182
183# TAG: log_fqdn
184# Remove this option from your config. To log FQDN use %>A in the log format.
185#Default:
186# none
187
188# TAG: log_ip_on_direct
189# Remove this option from your config. To log server or peer names use %<A in the log format.
190#Default:
191# none
192
193# TAG: maximum_single_addr_tries
194# Replaced by connect_retries. The behaviour has changed, please read the documentation before altering.
195#Default:
196# none
197
198# TAG: referer_log
199# Replace this with an access_log directive using the format 'referrer'.
200#Default:
201# none
202
203# TAG: update_headers
204# Remove this line. The feature is supported by default in storage types where update is implemented.
205#Default:
206# none
207
208# TAG: url_rewrite_concurrency
209# Remove this line. Set the 'concurrency=' option of url_rewrite_children instead.
210#Default:
211# none
212
213# TAG: useragent_log
214# Replace this with an access_log directive using the format 'useragent'.
215#Default:
216# none
217
218# TAG: dns_testnames
219# Remove this line. DNS is no longer tested on startup.
220#Default:
221# none
222
223# TAG: extension_methods
224# Remove this line. All valid methods for HTTP are accepted by default.
225#Default:
226# none
227
228# TAG: zero_buffers
229#Default:
230# none
231
232# TAG: incoming_rate
233#Default:
234# none
235
236# TAG: server_http11
237# Remove this line. HTTP/1.1 is supported by default.
238#Default:
239# none
240
241# TAG: upgrade_http0.9
242# Remove this line. ICY/1.0 streaming protocol is supported by default.
243#Default:
244# none
245
246# TAG: zph_local
247# Alter these entries. Use the qos_flows directive instead.
248#Default:
249# none
250
251# TAG: header_access
252# Since squid-3.0 replace with request_header_access or reply_header_access
253# depending on whether you wish to match client requests or server replies.
254#Default:
255# none
256
257# TAG: httpd_accel_no_pmtu_disc
258# Since squid-3.0 use the 'disable-pmtu-discovery' flag on http_port instead.
259#Default:
260# none
261
262# TAG: wais_relay_host
263# Replace this line with 'cache_peer' configuration.
264#Default:
265# none
266
267# TAG: wais_relay_port
268# Replace this line with 'cache_peer' configuration.
269#Default:
270# none
271
272# OPTIONS FOR SMP
273# -----------------------------------------------------------------------------
274
275# TAG: workers
276# Number of main Squid processes or "workers" to fork and maintain.
277# 0: "no daemon" mode, like running "squid -N ..."
278# 1: "no SMP" mode, start one main Squid process daemon (default)
279# N: start N main Squid process daemons (i.e., SMP mode)
280#
281# In SMP mode, each worker does nearly all what a single Squid daemon
282# does (e.g., listen on http_port and forward HTTP requests).
283#Default:
284# SMP support disabled.
285
286# TAG: cpu_affinity_map
287# Usage: cpu_affinity_map process_numbers=P1,P2,... cores=C1,C2,...
288#
289# Sets 1:1 mapping between Squid processes and CPU cores. For example,
290#
291# cpu_affinity_map process_numbers=1,2,3,4 cores=1,3,5,7
292#
293# affects processes 1 through 4 only and places them on the first
294# four even cores, starting with core #1.
295#
296# CPU cores are numbered starting from 1. Requires support for
297# sched_getaffinity(2) and sched_setaffinity(2) system calls.
298#
299# Multiple cpu_affinity_map options are merged.
300#
301# See also: workers
302#Default:
303# Let operating system decide.
304
305# OPTIONS FOR AUTHENTICATION
306# -----------------------------------------------------------------------------
307
308# TAG: auth_param
309# This is used to define parameters for the various authentication
310# schemes supported by Squid.
311#
312# format: auth_param scheme parameter [setting]
313#
314# The order in which authentication schemes are presented to the client is
315# dependent on the order the scheme first appears in config file. IE
316# has a bug (it's not RFC 2617 compliant) in that it will use the basic
317# scheme if basic is the first entry presented, even if more secure
318# schemes are presented. For now use the order in the recommended
319# settings section below. If other browsers have difficulties (don't
320# recognize the schemes offered even if you are using basic) either
321# put basic first, or disable the other schemes (by commenting out their
322# program entry).
323#
324# Once an authentication scheme is fully configured, it can only be
325# shutdown by shutting squid down and restarting. Changes can be made on
326# the fly and activated with a reconfigure. I.E. You can change to a
327# different helper, but not unconfigure the helper completely.
328#
329# Please note that while this directive defines how Squid processes
330# authentication it does not automatically activate authentication.
331# To use authentication you must in addition make use of ACLs based
332# on login name in http_access (proxy_auth, proxy_auth_regex or
333# external with %LOGIN used in the format tag). The browser will be
334# challenged for authentication on the first such acl encountered
335# in http_access processing and will also be re-challenged for new
336# login credentials if the request is being denied by a proxy_auth
337# type acl.
338#
339# WARNING: authentication can't be used in a transparently intercepting
340# proxy as the client then thinks it is talking to an origin server and
341# not the proxy. This is a limitation of bending the TCP/IP protocol to
342# transparently intercepting port 80, not a limitation in Squid.
343# Ports flagged 'transparent', 'intercept', or 'tproxy' have
344# authentication disabled.
345#
346# === Parameters common to all schemes. ===
347#
348# "program" cmdline
349# Specifies the command for the external authenticator.
350#
351# By default, each authentication scheme is not used unless a
352# program is specified.
353#
354# See http://wiki.squid-cache.org/Features/AddonHelpers for
355# more details on helper operations and creating your own.
356#
357# "key_extras" format
358# Specifies a string to be append to request line format for
359# the authentication helper. "Quoted" format values may contain
360# spaces and logformat %macros. In theory, any logformat %macro
361# can be used. In practice, a %macro expands as a dash (-) if
362# the helper request is sent before the required macro
363# information is available to Squid.
364#
365# By default, Squid uses request formats provided in
366# scheme-specific examples below (search for %credentials).
367#
368# The expanded key_extras value is added to the Squid credentials
369# cache and, hence, will affect authentication. It can be used to
370# autenticate different users with identical user names (e.g.,
371# when user authentication depends on http_port).
372#
373# Avoid adding frequently changing information to key_extras. For
374# example, if you add user source IP, and it changes frequently
375# in your environment, then max_user_ip ACL is going to treat
376# every user+IP combination as a unique "user", breaking the ACL
377# and wasting a lot of memory on those user records. It will also
378# force users to authenticate from scratch whenever their IP
379# changes.
380#
381# "realm" string
382# Specifies the protection scope (aka realm name) which is to be
383# reported to the client for the authentication scheme. It is
384# commonly part of the text the user will see when prompted for
385# their username and password.
386#
387# For Basic the default is "Squid proxy-caching web server".
388# For Digest there is no default, this parameter is mandatory.
389# For NTLM and Negotiate this parameter is ignored.
390#
391# "children" numberofchildren [startup=N] [idle=N] [concurrency=N]
392#
393# The maximum number of authenticator processes to spawn. If
394# you start too few Squid will have to wait for them to process
395# a backlog of credential verifications, slowing it down. When
396# password verifications are done via a (slow) network you are
397# likely to need lots of authenticator processes.
398#
399# The startup= and idle= options permit some skew in the exact
400# amount run. A minimum of startup=N will begin during startup
401# and reconfigure. Squid will start more in groups of up to
402# idle=N in an attempt to meet traffic needs and to keep idle=N
403# free above those traffic needs up to the maximum.
404#
405# The concurrency= option sets the number of concurrent requests
406# the helper can process. The default of 0 is used for helpers
407# who only supports one request at a time. Setting this to a
408# number greater than 0 changes the protocol used to include a
409# channel ID field first on the request/response line, allowing
410# multiple requests to be sent to the same helper in parallel
411# without waiting for the response.
412#
413# Concurrency must not be set unless it's known the helper
414# supports the input format with channel-ID fields.
415#
416# NOTE: NTLM and Negotiate schemes do not support concurrency
417# in the Squid code module even though some helpers can.
418#
419#
420#
421# === Example Configuration ===
422#
423# This configuration displays the recommended authentication scheme
424# order from most to least secure with recommended minimum configuration
425# settings for each scheme:
426#
427##auth_param negotiate program <uncomment and complete this line to activate>
428##auth_param negotiate children 20 startup=0 idle=1
429##auth_param negotiate keep_alive on
430##
431##auth_param digest program <uncomment and complete this line to activate>
432##auth_param digest children 20 startup=0 idle=1
433##auth_param digest realm Squid proxy-caching web server
434##auth_param digest nonce_garbage_interval 5 minutes
435##auth_param digest nonce_max_duration 30 minutes
436##auth_param digest nonce_max_count 50
437##
438##auth_param ntlm program <uncomment and complete this line to activate>
439##auth_param ntlm children 20 startup=0 idle=1
440##auth_param ntlm keep_alive on
441##
442##auth_param basic program <uncomment and complete this line>
443##auth_param basic children 5 startup=5 idle=1
444##auth_param basic realm Squid proxy-caching web server
445##auth_param basic credentialsttl 2 hours
446#Default:
447# none
448
449# TAG: authenticate_cache_garbage_interval
450# The time period between garbage collection across the username cache.
451# This is a trade-off between memory utilization (long intervals - say
452# 2 days) and CPU (short intervals - say 1 minute). Only change if you
453# have good reason to.
454#Default:
455# authenticate_cache_garbage_interval 1 hour
456
457# TAG: authenticate_ttl
458# The time a user & their credentials stay in the logged in
459# user cache since their last request. When the garbage
460# interval passes, all user credentials that have passed their
461# TTL are removed from memory.
462#Default:
463# authenticate_ttl 1 hour
464
465# TAG: authenticate_ip_ttl
466# If you use proxy authentication and the 'max_user_ip' ACL,
467# this directive controls how long Squid remembers the IP
468# addresses associated with each user. Use a small value
469# (e.g., 60 seconds) if your users might change addresses
470# quickly, as is the case with dialup. You might be safe
471# using a larger value (e.g., 2 hours) in a corporate LAN
472# environment with relatively static address assignments.
473#Default:
474# authenticate_ip_ttl 1 second
475
476# ACCESS CONTROLS
477# -----------------------------------------------------------------------------
478
479# TAG: external_acl_type
480# This option defines external acl classes using a helper program
481# to look up the status
482#
483# external_acl_type name [options] FORMAT.. /path/to/helper [helper arguments..]
484#
485# Options:
486#
487# ttl=n TTL in seconds for cached results (defaults to 3600
488# for 1 hour)
489#
490# negative_ttl=n
491# TTL for cached negative lookups (default same
492# as ttl)
493#
494# grace=n Percentage remaining of TTL where a refresh of a
495# cached entry should be initiated without needing to
496# wait for a new reply. (default is for no grace period)
497#
498# cache=n The maximum number of entries in the result cache. The
499# default limit is 262144 entries. Each cache entry usually
500# consumes at least 256 bytes. Squid currently does not remove
501# expired cache entries until the limit is reached, so a proxy
502# will sooner or later reach the limit. The expanded FORMAT
503# value is used as the cache key, so if the details in FORMAT
504# are highly variable, a larger cache may be needed to produce
505# reduction in helper load.
506#
507# children-max=n
508# Maximum number of acl helper processes spawned to service
509# external acl lookups of this type. (default 5)
510#
511# children-startup=n
512# Minimum number of acl helper processes to spawn during
513# startup and reconfigure to service external acl lookups
514# of this type. (default 0)
515#
516# children-idle=n
517# Number of acl helper processes to keep ahead of traffic
518# loads. Squid will spawn this many at once whenever load
519# rises above the capabilities of existing processes.
520# Up to the value of children-max. (default 1)
521#
522# concurrency=n concurrency level per process. Only used with helpers
523# capable of processing more than one query at a time.
524#
525# protocol=2.5 Compatibility mode for Squid-2.5 external acl helpers.
526#
527# ipv4 / ipv6 IP protocol used to communicate with this helper.
528# The default is to auto-detect IPv6 and use it when available.
529#
530#
531# FORMAT specifications
532#
533# %LOGIN Authenticated user login name
534# %un A user name. Expands to the first available name
535# from the following list of information sources:
536# - authenticated user name, like %ul or %LOGIN
537# - user name sent by an external ACL, like %EXT_USER
538# - SSL client name, like %us in logformat
539# - ident user name, like %ui in logformat
540# %EXT_USER Username from previous external acl
541# %EXT_LOG Log details from previous external acl
542# %EXT_TAG Tag from previous external acl
543# %IDENT Ident user name
544# %SRC Client IP
545# %SRCPORT Client source port
546# %URI Requested URI
547# %DST Requested host
548# %PROTO Requested URL scheme
549# %PORT Requested port
550# %PATH Requested URL path
551# %METHOD Request method
552# %MYADDR Squid interface address
553# %MYPORT Squid http_port number
554# %PATH Requested URL-path (including query-string if any)
555# %USER_CERT SSL User certificate in PEM format
556# %USER_CERTCHAIN SSL User certificate chain in PEM format
557# %USER_CERT_xx SSL User certificate subject attribute xx
558# %USER_CA_CERT_xx SSL User certificate issuer attribute xx
559# %ssl::>sni SSL client SNI sent to Squid
560# %ssl::<cert_subject SSL server certificate DN
561# %ssl::<cert_issuer SSL server certificate issuer DN
562#
563# %>{Header} HTTP request header "Header"
564# %>{Hdr:member}
565# HTTP request header "Hdr" list member "member"
566# %>{Hdr:;member}
567# HTTP request header list member using ; as
568# list separator. ; can be any non-alphanumeric
569# character.
570#
571# %<{Header} HTTP reply header "Header"
572# %<{Hdr:member}
573# HTTP reply header "Hdr" list member "member"
574# %<{Hdr:;member}
575# HTTP reply header list member using ; as
576# list separator. ; can be any non-alphanumeric
577# character.
578#
579# %ACL The name of the ACL being tested.
580# %DATA The ACL arguments. If not used then any arguments
581# is automatically added at the end of the line
582# sent to the helper.
583# NOTE: this will encode the arguments as one token,
584# whereas the default will pass each separately.
585#
586# %% The percent sign. Useful for helpers which need
587# an unchanging input format.
588#
589#
590# General request syntax:
591#
592# [channel-ID] FORMAT-values [acl-values ...]
593#
594#
595# FORMAT-values consists of transaction details expanded with
596# whitespace separation per the config file FORMAT specification
597# using the FORMAT macros listed above.
598#
599# acl-values consists of any string specified in the referencing
600# config 'acl ... external' line. see the "acl external" directive.
601#
602# Request values sent to the helper are URL escaped to protect
603# each value in requests against whitespaces.
604#
605# If using protocol=2.5 then the request sent to the helper is not
606# URL escaped to protect against whitespace.
607#
608# NOTE: protocol=3.0 is deprecated as no longer necessary.
609#
610# When using the concurrency= option the protocol is changed by
611# introducing a query channel tag in front of the request/response.
612# The query channel tag is a number between 0 and concurrency-1.
613# This value must be echoed back unchanged to Squid as the first part
614# of the response relating to its request.
615#
616#
617# The helper receives lines expanded per the above format specification
618# and for each input line returns 1 line starting with OK/ERR/BH result
619# code and optionally followed by additional keywords with more details.
620#
621#
622# General result syntax:
623#
624# [channel-ID] result keyword=value ...
625#
626# Result consists of one of the codes:
627#
628# OK
629# the ACL test produced a match.
630#
631# ERR
632# the ACL test does not produce a match.
633#
634# BH
635# An internal error occurred in the helper, preventing
636# a result being identified.
637#
638# The meaning of 'a match' is determined by your squid.conf
639# access control configuration. See the Squid wiki for details.
640#
641# Defined keywords:
642#
643# user= The users name (login)
644#
645# password= The users password (for login= cache_peer option)
646#
647# message= Message describing the reason for this response.
648# Available as %o in error pages.
649# Useful on (ERR and BH results).
650#
651# tag= Apply a tag to a request. Only sets a tag once,
652# does not alter existing tags.
653#
654# log= String to be logged in access.log. Available as
655# %ea in logformat specifications.
656#
657# clt_conn_tag= Associates a TAG with the client TCP connection.
658# Please see url_rewrite_program related documentation
659# for this kv-pair.
660#
661# Any keywords may be sent on any response whether OK, ERR or BH.
662#
663# All response keyword values need to be a single token with URL
664# escaping, or enclosed in double quotes (") and escaped using \ on
665# any double quotes or \ characters within the value. The wrapping
666# double quotes are removed before the value is interpreted by Squid.
667# \r and \n are also replace by CR and LF.
668#
669# Some example key values:
670#
671# user=John%20Smith
672# user="John Smith"
673# user="J. \"Bob\" Smith"
674#Default:
675# none
676
677# TAG: acl
678# Defining an Access List
679#
680# Every access list definition must begin with an aclname and acltype,
681# followed by either type-specific arguments or a quoted filename that
682# they are read from.
683#
684# acl aclname acltype argument ...
685# acl aclname acltype "file" ...
686#
687# When using "file", the file should contain one item per line.
688#
689# Some acl types supports options which changes their default behaviour.
690# The available options are:
691#
692# -i,+i By default, regular expressions are CASE-SENSITIVE. To make them
693# case-insensitive, use the -i option. To return case-sensitive
694# use the +i option between patterns, or make a new ACL line
695# without -i.
696#
697# -n Disable lookups and address type conversions. If lookup or
698# conversion is required because the parameter type (IP or
699# domain name) does not match the message address type (domain
700# name or IP), then the ACL would immediately declare a mismatch
701# without any warnings or lookups.
702#
703# -- Used to stop processing all options, in the case the first acl
704# value has '-' character as first character (for example the '-'
705# is a valid domain name)
706#
707# Some acl types require suspending the current request in order
708# to access some external data source.
709# Those which do are marked with the tag [slow], those which
710# don't are marked as [fast].
711# See http://wiki.squid-cache.org/SquidFaq/SquidAcl
712# for further information
713#
714# ***** ACL TYPES AVAILABLE *****
715#
716# acl aclname src ip-address/mask ... # clients IP address [fast]
717# acl aclname src addr1-addr2/mask ... # range of addresses [fast]
718# acl aclname dst [-n] ip-address/mask ... # URL host's IP address [slow]
719# acl aclname localip ip-address/mask ... # IP address the client connected to [fast]
720#
721# acl aclname arp mac-address ... (xx:xx:xx:xx:xx:xx notation)
722# # [fast]
723# # The 'arp' ACL code is not portable to all operating systems.
724# # It works on Linux, Solaris, Windows, FreeBSD, and some other
725# # BSD variants.
726# #
727# # NOTE: Squid can only determine the MAC/EUI address for IPv4
728# # clients that are on the same subnet. If the client is on a
729# # different subnet, then Squid cannot find out its address.
730# #
731# # NOTE 2: IPv6 protocol does not contain ARP. MAC/EUI is either
732# # encoded directly in the IPv6 address or not available.
733#
734# acl aclname srcdomain .foo.com ...
735# # reverse lookup, from client IP [slow]
736# acl aclname dstdomain [-n] .foo.com ...
737# # Destination server from URL [fast]
738# acl aclname srcdom_regex [-i] \.foo\.com ...
739# # regex matching client name [slow]
740# acl aclname dstdom_regex [-n] [-i] \.foo\.com ...
741# # regex matching server [fast]
742# #
743# # For dstdomain and dstdom_regex a reverse lookup is tried if a IP
744# # based URL is used and no match is found. The name "none" is used
745# # if the reverse lookup fails.
746#
747# acl aclname src_as number ...
748# acl aclname dst_as number ...
749# # [fast]
750# # Except for access control, AS numbers can be used for
751# # routing of requests to specific caches. Here's an
752# # example for routing all requests for AS#1241 and only
753# # those to mycache.mydomain.net:
754# # acl asexample dst_as 1241
755# # cache_peer_access mycache.mydomain.net allow asexample
756# # cache_peer_access mycache_mydomain.net deny all
757#
758# acl aclname peername myPeer ...
759# # [fast]
760# # match against a named cache_peer entry
761# # set unique name= on cache_peer lines for reliable use.
762#
763# acl aclname time [day-abbrevs] [h1:m1-h2:m2]
764# # [fast]
765# # day-abbrevs:
766# # S - Sunday
767# # M - Monday
768# # T - Tuesday
769# # W - Wednesday
770# # H - Thursday
771# # F - Friday
772# # A - Saturday
773# # h1:m1 must be less than h2:m2
774#
775# acl aclname url_regex [-i] ^http:// ...
776# # regex matching on whole URL [fast]
777# acl aclname urllogin [-i] [^a-zA-Z0-9] ...
778# # regex matching on URL login field
779# acl aclname urlpath_regex [-i] \.gif$ ...
780# # regex matching on URL path [fast]
781#
782# acl aclname port 80 70 21 0-1024... # destination TCP port [fast]
783# # ranges are alloed
784# acl aclname localport 3128 ... # TCP port the client connected to [fast]
785# # NP: for interception mode this is usually '80'
786#
787# acl aclname myportname 3128 ... # *_port name [fast]
788#
789# acl aclname proto HTTP FTP ... # request protocol [fast]
790#
791# acl aclname method GET POST ... # HTTP request method [fast]
792#
793# acl aclname http_status 200 301 500- 400-403 ...
794# # status code in reply [fast]
795#
796# acl aclname browser [-i] regexp ...
797# # pattern match on User-Agent header (see also req_header below) [fast]
798#
799# acl aclname referer_regex [-i] regexp ...
800# # pattern match on Referer header [fast]
801# # Referer is highly unreliable, so use with care
802#
803# acl aclname ident username ...
804# acl aclname ident_regex [-i] pattern ...
805# # string match on ident output [slow]
806# # use REQUIRED to accept any non-null ident.
807#
808# acl aclname proxy_auth [-i] username ...
809# acl aclname proxy_auth_regex [-i] pattern ...
810# # perform http authentication challenge to the client and match against
811# # supplied credentials [slow]
812# #
813# # takes a list of allowed usernames.
814# # use REQUIRED to accept any valid username.
815# #
816# # Will use proxy authentication in forward-proxy scenarios, and plain
817# # http authenticaiton in reverse-proxy scenarios
818# #
819# # NOTE: when a Proxy-Authentication header is sent but it is not
820# # needed during ACL checking the username is NOT logged
821# # in access.log.
822# #
823# # NOTE: proxy_auth requires a EXTERNAL authentication program
824# # to check username/password combinations (see
825# # auth_param directive).
826# #
827# # NOTE: proxy_auth can't be used in a transparent/intercepting proxy
828# # as the browser needs to be configured for using a proxy in order
829# # to respond to proxy authentication.
830#
831# acl aclname snmp_community string ...
832# # A community string to limit access to your SNMP Agent [fast]
833# # Example:
834# #
835# # acl snmppublic snmp_community public
836#
837# acl aclname maxconn number
838# # This will be matched when the client's IP address has
839# # more than <number> TCP connections established. [fast]
840# # NOTE: This only measures direct TCP links so X-Forwarded-For
841# # indirect clients are not counted.
842#
843# acl aclname max_user_ip [-s] number
844# # This will be matched when the user attempts to log in from more
845# # than <number> different ip addresses. The authenticate_ip_ttl
846# # parameter controls the timeout on the ip entries. [fast]
847# # If -s is specified the limit is strict, denying browsing
848# # from any further IP addresses until the ttl has expired. Without
849# # -s Squid will just annoy the user by "randomly" denying requests.
850# # (the counter is reset each time the limit is reached and a
851# # request is denied)
852# # NOTE: in acceleration mode or where there is mesh of child proxies,
853# # clients may appear to come from multiple addresses if they are
854# # going through proxy farms, so a limit of 1 may cause user problems.
855#
856# acl aclname random probability
857# # Pseudo-randomly match requests. Based on the probability given.
858# # Probability may be written as a decimal (0.333), fraction (1/3)
859# # or ratio of matches:non-matches (3:5).
860#
861# acl aclname req_mime_type [-i] mime-type ...
862# # regex match against the mime type of the request generated
863# # by the client. Can be used to detect file upload or some
864# # types HTTP tunneling requests [fast]
865# # NOTE: This does NOT match the reply. You cannot use this
866# # to match the returned file type.
867#
868# acl aclname req_header header-name [-i] any\.regex\.here
869# # regex match against any of the known request headers. May be
870# # thought of as a superset of "browser", "referer" and "mime-type"
871# # ACL [fast]
872#
873# acl aclname rep_mime_type [-i] mime-type ...
874# # regex match against the mime type of the reply received by
875# # squid. Can be used to detect file download or some
876# # types HTTP tunneling requests. [fast]
877# # NOTE: This has no effect in http_access rules. It only has
878# # effect in rules that affect the reply data stream such as
879# # http_reply_access.
880#
881# acl aclname rep_header header-name [-i] any\.regex\.here
882# # regex match against any of the known reply headers. May be
883# # thought of as a superset of "browser", "referer" and "mime-type"
884# # ACLs [fast]
885#
886# acl aclname external class_name [arguments...]
887# # external ACL lookup via a helper class defined by the
888# # external_acl_type directive [slow]
889#
890# acl aclname user_cert attribute values...
891# # match against attributes in a user SSL certificate
892# # attribute is one of DN/C/O/CN/L/ST or a numerical OID [fast]
893#
894# acl aclname ca_cert attribute values...
895# # match against attributes a users issuing CA SSL certificate
896# # attribute is one of DN/C/O/CN/L/ST or a numerical OID [fast]
897#
898# acl aclname ext_user username ...
899# acl aclname ext_user_regex [-i] pattern ...
900# # string match on username returned by external acl helper [slow]
901# # use REQUIRED to accept any non-null user name.
902#
903# acl aclname tag tagvalue ...
904# # string match on tag returned by external acl helper [fast]
905# # DEPRECATED. Only the first tag will match with this ACL.
906# # Use the 'note' ACL instead for handling multiple tag values.
907#
908# acl aclname hier_code codename ...
909# # string match against squid hierarchy code(s); [fast]
910# # e.g., DIRECT, PARENT_HIT, NONE, etc.
911# #
912# # NOTE: This has no effect in http_access rules. It only has
913# # effect in rules that affect the reply data stream such as
914# # http_reply_access.
915#
916# acl aclname note name [value ...]
917# # match transaction annotation [fast]
918# # Without values, matches any annotation with a given name.
919# # With value(s), matches any annotation with a given name that
920# # also has one of the given values.
921# # Names and values are compared using a string equality test.
922# # Annotation sources include note and adaptation_meta directives
923# # as well as helper and eCAP responses.
924#
925# acl aclname adaptation_service service ...
926# # Matches the name of any icap_service, ecap_service,
927# # adaptation_service_set, or adaptation_service_chain that Squid
928# # has used (or attempted to use) for the master transaction.
929# # This ACL must be defined after the corresponding adaptation
930# # service is named in squid.conf. This ACL is usable with
931# # adaptation_meta because it starts matching immediately after
932# # the service has been selected for adaptation.
933#
934# acl aclname any-of acl1 acl2 ...
935# # match any one of the acls [fast or slow]
936# # The first matching ACL stops further ACL evaluation.
937# #
938# # ACLs from multiple any-of lines with the same name are ORed.
939# # For example, A = (a1 or a2) or (a3 or a4) can be written as
940# # acl A any-of a1 a2
941# # acl A any-of a3 a4
942# #
943# # This group ACL is fast if all evaluated ACLs in the group are fast
944# # and slow otherwise.
945#
946# acl aclname all-of acl1 acl2 ...
947# # match all of the acls [fast or slow]
948# # The first mismatching ACL stops further ACL evaluation.
949# #
950# # ACLs from multiple all-of lines with the same name are ORed.
951# # For example, B = (b1 and b2) or (b3 and b4) can be written as
952# # acl B all-of b1 b2
953# # acl B all-of b3 b4
954# #
955# # This group ACL is fast if all evaluated ACLs in the group are fast
956# # and slow otherwise.
957#
958# Examples:
959# acl macaddress arp 09:00:2b:23:45:67
960# acl myexample dst_as 1241
961# acl password proxy_auth REQUIRED
962# acl fileupload req_mime_type -i ^multipart/form-data$
963# acl javascript rep_mime_type -i ^application/x-javascript$
964#
965#Default:
966# ACLs all, manager, localhost, and to_localhost are predefined.
967#
968#
969# Recommended minimum configuration:
970#
971
972# Example rule allowing access from your local networks.
973# Adapt to list your (internal) IP networks from where browsing
974# should be allowed
975acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
976acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
977acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
978acl localnet src fc00::/7 # RFC 4193 local private network range
979acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
980
981acl SSL_ports port 443
982acl Safe_ports port 80 # http
983acl Safe_ports port 21 # ftp
984acl Safe_ports port 443 # https
985acl Safe_ports port 70 # gopher
986acl Safe_ports port 210 # wais
987acl Safe_ports port 1025-65535 # unregistered ports
988acl Safe_ports port 280 # http-mgmt
989acl Safe_ports port 488 # gss-http
990acl Safe_ports port 591 # filemaker
991acl Safe_ports port 777 # multiling http
992acl CONNECT method CONNECT
993
994# TAG: proxy_protocol_access
995# Determine which client proxies can be trusted to provide correct
996# information regarding real client IP address using PROXY protocol.
997#
998# Requests may pass through a chain of several other proxies
999# before reaching us. The original source details may by sent in:
1000# * HTTP message Forwarded header, or
1001# * HTTP message X-Forwarded-For header, or
1002# * PROXY protocol connection header.
1003#
1004# This directive is solely for validating new PROXY protocol
1005# connections received from a port flagged with require-proxy-header.
1006# It is checked only once after TCP connection setup.
1007#
1008# A deny match results in TCP connection closure.
1009#
1010# An allow match is required for Squid to permit the corresponding
1011# TCP connection, before Squid even looks for HTTP request headers.
1012# If there is an allow match, Squid starts using PROXY header information
1013# to determine the source address of the connection for all future ACL
1014# checks, logging, etc.
1015#
1016# SECURITY CONSIDERATIONS:
1017#
1018# Any host from which we accept client IP details can place
1019# incorrect information in the relevant header, and Squid
1020# will use the incorrect information as if it were the
1021# source address of the request. This may enable remote
1022# hosts to bypass any access control restrictions that are
1023# based on the client's source addresses.
1024#
1025# This clause only supports fast acl types.
1026# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1027#Default:
1028# all TCP connections to ports with require-proxy-header will be denied
1029
1030# TAG: follow_x_forwarded_for
1031# Determine which client proxies can be trusted to provide correct
1032# information regarding real client IP address.
1033#
1034# Requests may pass through a chain of several other proxies
1035# before reaching us. The original source details may by sent in:
1036# * HTTP message Forwarded header, or
1037# * HTTP message X-Forwarded-For header, or
1038# * PROXY protocol connection header.
1039#
1040# PROXY protocol connections are controlled by the proxy_protocol_access
1041# directive which is checked before this.
1042#
1043# If a request reaches us from a source that is allowed by this
1044# directive, then we trust the information it provides regarding
1045# the IP of the client it received from (if any).
1046#
1047# For the purpose of ACLs used in this directive the src ACL type always
1048# matches the address we are testing and srcdomain matches its rDNS.
1049#
1050# On each HTTP request Squid checks for X-Forwarded-For header fields.
1051# If found the header values are iterated in reverse order and an allow
1052# match is required for Squid to continue on to the next value.
1053# The verification ends when a value receives a deny match, cannot be
1054# tested, or there are no more values to test.
1055# NOTE: Squid does not yet follow the Forwarded HTTP header.
1056#
1057# The end result of this process is an IP address that we will
1058# refer to as the indirect client address. This address may
1059# be treated as the client address for access control, ICAP, delay
1060# pools and logging, depending on the acl_uses_indirect_client,
1061# icap_uses_indirect_client, delay_pool_uses_indirect_client,
1062# log_uses_indirect_client and tproxy_uses_indirect_client options.
1063#
1064# This clause only supports fast acl types.
1065# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1066#
1067# SECURITY CONSIDERATIONS:
1068#
1069# Any host from which we accept client IP details can place
1070# incorrect information in the relevant header, and Squid
1071# will use the incorrect information as if it were the
1072# source address of the request. This may enable remote
1073# hosts to bypass any access control restrictions that are
1074# based on the client's source addresses.
1075#
1076# For example:
1077#
1078# acl localhost src 127.0.0.1
1079# acl my_other_proxy srcdomain .proxy.example.com
1080# follow_x_forwarded_for allow localhost
1081# follow_x_forwarded_for allow my_other_proxy
1082#Default:
1083# X-Forwarded-For header will be ignored.
1084
1085# TAG: acl_uses_indirect_client on|off
1086# Controls whether the indirect client address
1087# (see follow_x_forwarded_for) is used instead of the
1088# direct client address in acl matching.
1089#
1090# NOTE: maxconn ACL considers direct TCP links and indirect
1091# clients will always have zero. So no match.
1092#Default:
1093# acl_uses_indirect_client on
1094
1095# TAG: delay_pool_uses_indirect_client on|off
1096# Controls whether the indirect client address
1097# (see follow_x_forwarded_for) is used instead of the
1098# direct client address in delay pools.
1099#Default:
1100# delay_pool_uses_indirect_client on
1101
1102# TAG: log_uses_indirect_client on|off
1103# Controls whether the indirect client address
1104# (see follow_x_forwarded_for) is used instead of the
1105# direct client address in the access log.
1106#Default:
1107# log_uses_indirect_client on
1108
1109# TAG: tproxy_uses_indirect_client on|off
1110# Controls whether the indirect client address
1111# (see follow_x_forwarded_for) is used instead of the
1112# direct client address when spoofing the outgoing client.
1113#
1114# This has no effect on requests arriving in non-tproxy
1115# mode ports.
1116#
1117# SECURITY WARNING: Usage of this option is dangerous
1118# and should not be used trivially. Correct configuration
1119# of follow_x_forwarded_for with a limited set of trusted
1120# sources is required to prevent abuse of your proxy.
1121#Default:
1122# tproxy_uses_indirect_client off
1123
1124# TAG: spoof_client_ip
1125# Control client IP address spoofing of TPROXY traffic based on
1126# defined access lists.
1127#
1128# spoof_client_ip allow|deny [!]aclname ...
1129#
1130# If there are no "spoof_client_ip" lines present, the default
1131# is to "allow" spoofing of any suitable request.
1132#
1133# Note that the cache_peer "no-tproxy" option overrides this ACL.
1134#
1135# This clause supports fast acl types.
1136# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1137#Default:
1138# Allow spoofing on all TPROXY traffic.
1139
1140# TAG: http_access
1141# Allowing or Denying access based on defined access lists
1142#
1143# To allow or deny a message received on an HTTP, HTTPS, or FTP port:
1144# http_access allow|deny [!]aclname ...
1145#
1146# NOTE on default values:
1147#
1148# If there are no "access" lines present, the default is to deny
1149# the request.
1150#
1151# If none of the "access" lines cause a match, the default is the
1152# opposite of the last line in the list. If the last line was
1153# deny, the default is allow. Conversely, if the last line
1154# is allow, the default will be deny. For these reasons, it is a
1155# good idea to have an "deny all" entry at the end of your access
1156# lists to avoid potential confusion.
1157#
1158# This clause supports both fast and slow acl types.
1159# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1160#
1161#Default:
1162# Deny, unless rules exist in squid.conf.
1163#
1164
1165#
1166# Recommended minimum Access Permission configuration:
1167#
1168# Deny requests to certain unsafe ports
1169http_access deny !Safe_ports
1170
1171# Deny CONNECT to other than secure SSL ports
1172http_access deny CONNECT !SSL_ports
1173
1174# Only allow cachemgr access from localhost
1175http_access allow localhost manager
1176http_access deny manager
1177
1178# We strongly recommend the following be uncommented to protect innocent
1179# web applications running on the proxy server who think the only
1180# one who can access services on "localhost" is a local user
1181#http_access deny to_localhost
1182
1183#
1184# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
1185#
1186
1187# Example rule allowing access from your local networks.
1188# Adapt localnet in the ACL section to list your (internal) IP networks
1189# from where browsing should be allowed
1190http_access allow localnet
1191http_access allow localhost
1192
1193# And finally deny all other access to this proxy
1194http_access deny all
1195
1196# TAG: adapted_http_access
1197# Allowing or Denying access based on defined access lists
1198#
1199# Essentially identical to http_access, but runs after redirectors
1200# and ICAP/eCAP adaptation. Allowing access control based on their
1201# output.
1202#
1203# If not set then only http_access is used.
1204#Default:
1205# Allow, unless rules exist in squid.conf.
1206
1207# TAG: http_reply_access
1208# Allow replies to client requests. This is complementary to http_access.
1209#
1210# http_reply_access allow|deny [!] aclname ...
1211#
1212# NOTE: if there are no access lines present, the default is to allow
1213# all replies.
1214#
1215# If none of the access lines cause a match the opposite of the
1216# last line will apply. Thus it is good practice to end the rules
1217# with an "allow all" or "deny all" entry.
1218#
1219# This clause supports both fast and slow acl types.
1220# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1221#Default:
1222# Allow, unless rules exist in squid.conf.
1223
1224# TAG: icp_access
1225# Allowing or Denying access to the ICP port based on defined
1226# access lists
1227#
1228# icp_access allow|deny [!]aclname ...
1229#
1230# NOTE: The default if no icp_access lines are present is to
1231# deny all traffic. This default may cause problems with peers
1232# using ICP.
1233#
1234# This clause only supports fast acl types.
1235# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1236#
1237## Allow ICP queries from local networks only
1238##icp_access allow localnet
1239##icp_access deny all
1240#Default:
1241# Deny, unless rules exist in squid.conf.
1242
1243# TAG: htcp_access
1244# Allowing or Denying access to the HTCP port based on defined
1245# access lists
1246#
1247# htcp_access allow|deny [!]aclname ...
1248#
1249# See also htcp_clr_access for details on access control for
1250# cache purge (CLR) HTCP messages.
1251#
1252# NOTE: The default if no htcp_access lines are present is to
1253# deny all traffic. This default may cause problems with peers
1254# using the htcp option.
1255#
1256# This clause only supports fast acl types.
1257# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1258#
1259## Allow HTCP queries from local networks only
1260##htcp_access allow localnet
1261##htcp_access deny all
1262#Default:
1263# Deny, unless rules exist in squid.conf.
1264
1265# TAG: htcp_clr_access
1266# Allowing or Denying access to purge content using HTCP based
1267# on defined access lists.
1268# See htcp_access for details on general HTCP access control.
1269#
1270# htcp_clr_access allow|deny [!]aclname ...
1271#
1272# This clause only supports fast acl types.
1273# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1274#
1275## Allow HTCP CLR requests from trusted peers
1276#acl htcp_clr_peer src 192.0.2.2 2001:DB8::2
1277#htcp_clr_access allow htcp_clr_peer
1278#htcp_clr_access deny all
1279#Default:
1280# Deny, unless rules exist in squid.conf.
1281
1282# TAG: miss_access
1283# Determines whether network access is permitted when satisfying a request.
1284#
1285# For example;
1286# to force your neighbors to use you as a sibling instead of
1287# a parent.
1288#
1289# acl localclients src 192.0.2.0/24 2001:DB8::a:0/64
1290# miss_access deny !localclients
1291# miss_access allow all
1292#
1293# This means only your local clients are allowed to fetch relayed/MISS
1294# replies from the network and all other clients can only fetch cached
1295# objects (HITs).
1296#
1297# The default for this setting allows all clients who passed the
1298# http_access rules to relay via this proxy.
1299#
1300# This clause only supports fast acl types.
1301# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1302#Default:
1303# Allow, unless rules exist in squid.conf.
1304
1305# TAG: ident_lookup_access
1306# A list of ACL elements which, if matched, cause an ident
1307# (RFC 931) lookup to be performed for this request. For
1308# example, you might choose to always perform ident lookups
1309# for your main multi-user Unix boxes, but not for your Macs
1310# and PCs. By default, ident lookups are not performed for
1311# any requests.
1312#
1313# To enable ident lookups for specific client addresses, you
1314# can follow this example:
1315#
1316# acl ident_aware_hosts src 198.168.1.0/24
1317# ident_lookup_access allow ident_aware_hosts
1318# ident_lookup_access deny all
1319#
1320# Only src type ACL checks are fully supported. A srcdomain
1321# ACL might work at times, but it will not always provide
1322# the correct result.
1323#
1324# This clause only supports fast acl types.
1325# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
1326#Default:
1327# Unless rules exist in squid.conf, IDENT is not fetched.
1328
1329# TAG: reply_body_max_size size [acl acl...]
1330# This option specifies the maximum size of a reply body. It can be
1331# used to prevent users from downloading very large files, such as
1332# MP3's and movies. When the reply headers are received, the
1333# reply_body_max_size lines are processed, and the first line where
1334# all (if any) listed ACLs are true is used as the maximum body size
1335# for this reply.
1336#
1337# This size is checked twice. First when we get the reply headers,
1338# we check the content-length value. If the content length value exists
1339# and is larger than the allowed size, the request is denied and the
1340# user receives an error message that says "the request or reply
1341# is too large." If there is no content-length, and the reply
1342# size exceeds this limit, the client's connection is just closed
1343# and they will receive a partial reply.
1344#
1345# WARNING: downstream caches probably can not detect a partial reply
1346# if there is no content-length header, so they will cache
1347# partial responses and give them out as hits. You should NOT
1348# use this option if you have downstream caches.
1349#
1350# WARNING: A maximum size smaller than the size of squid's error messages
1351# will cause an infinite loop and crash squid. Ensure that the smallest
1352# non-zero value you use is greater that the maximum header size plus
1353# the size of your largest error page.
1354#
1355# If you set this parameter none (the default), there will be
1356# no limit imposed.
1357#
1358# Configuration Format is:
1359# reply_body_max_size SIZE UNITS [acl ...]
1360# ie.
1361# reply_body_max_size 10 MB
1362#
1363#Default:
1364# No limit is applied.
1365
1366# NETWORK OPTIONS
1367# -----------------------------------------------------------------------------
1368
1369# TAG: http_port
1370# Usage: port [mode] [options]
1371# hostname:port [mode] [options]
1372# 1.2.3.4:port [mode] [options]
1373#
1374# The socket addresses where Squid will listen for HTTP client
1375# requests. You may specify multiple socket addresses.
1376# There are three forms: port alone, hostname with port, and
1377# IP address with port. If you specify a hostname or IP
1378# address, Squid binds the socket to that specific
1379# address. Most likely, you do not need to bind to a specific
1380# address, so you can use the port number alone.
1381#
1382# If you are running Squid in accelerator mode, you
1383# probably want to listen on port 80 also, or instead.
1384#
1385# The -a command line option may be used to specify additional
1386# port(s) where Squid listens for proxy request. Such ports will
1387# be plain proxy ports with no options.
1388#
1389# You may specify multiple socket addresses on multiple lines.
1390#
1391# Modes:
1392#
1393# intercept Support for IP-Layer NAT interception delivering
1394# traffic to this Squid port.
1395# NP: disables authentication on the port.
1396#
1397# tproxy Support Linux TPROXY (or BSD divert-to) with spoofing
1398# of outgoing connections using the client IP address.
1399# NP: disables authentication on the port.
1400#
1401# accel Accelerator / reverse proxy mode
1402#
1403# ssl-bump For each CONNECT request allowed by ssl_bump ACLs,
1404# establish secure connection with the client and with
1405# the server, decrypt HTTPS messages as they pass through
1406# Squid, and treat them as unencrypted HTTP messages,
1407# becoming the man-in-the-middle.
1408#
1409# The ssl_bump option is required to fully enable
1410# bumping of CONNECT requests.
1411#
1412# Omitting the mode flag causes default forward proxy mode to be used.
1413#
1414#
1415# Accelerator Mode Options:
1416#
1417# defaultsite=domainname
1418# What to use for the Host: header if it is not present
1419# in a request. Determines what site (not origin server)
1420# accelerators should consider the default.
1421#
1422# no-vhost Disable using HTTP/1.1 Host header for virtual domain support.
1423#
1424# protocol= Protocol to reconstruct accelerated and intercepted
1425# requests with. Defaults to HTTP/1.1 for http_port and
1426# HTTPS/1.1 for https_port.
1427# When an unsupported value is configured Squid will
1428# produce a FATAL error.
1429# Values: HTTP or HTTP/1.1, HTTPS or HTTPS/1.1
1430#
1431# vport Virtual host port support. Using the http_port number
1432# instead of the port passed on Host: headers.
1433#
1434# vport=NN Virtual host port support. Using the specified port
1435# number instead of the port passed on Host: headers.
1436#
1437# act-as-origin
1438# Act as if this Squid is the origin server.
1439# This currently means generate new Date: and Expires:
1440# headers on HIT instead of adding Age:.
1441#
1442# ignore-cc Ignore request Cache-Control headers.
1443#
1444# WARNING: This option violates HTTP specifications if
1445# used in non-accelerator setups.
1446#
1447# allow-direct Allow direct forwarding in accelerator mode. Normally
1448# accelerated requests are denied direct forwarding as if
1449# never_direct was used.
1450#
1451# WARNING: this option opens accelerator mode to security
1452# vulnerabilities usually only affecting in interception
1453# mode. Make sure to protect forwarding with suitable
1454# http_access rules when using this.
1455#
1456#
1457# SSL Bump Mode Options:
1458# In addition to these options ssl-bump requires TLS/SSL options.
1459#
1460# generate-host-certificates[=<on|off>]
1461# Dynamically create SSL server certificates for the
1462# destination hosts of bumped CONNECT requests.When
1463# enabled, the cert and key options are used to sign
1464# generated certificates. Otherwise generated
1465# certificate will be selfsigned.
1466# If there is a CA certificate lifetime of the generated
1467# certificate equals lifetime of the CA certificate. If
1468# generated certificate is selfsigned lifetime is three
1469# years.
1470# This option is disabled by default. See the ssl-bump
1471# option above for more information.
1472#
1473# dynamic_cert_mem_cache_size=SIZE
1474# Approximate total RAM size spent on cached generated
1475# certificates. If set to zero, caching is disabled.
1476#
1477# TLS / SSL Options:
1478#
1479# cert= Path to SSL certificate (PEM format).
1480#
1481# key= Path to SSL private key file (PEM format)
1482# if not specified, the certificate file is
1483# assumed to be a combined certificate and
1484# key file.
1485#
1486# version= The version of SSL/TLS supported
1487# 1 automatic (default)
1488# 2 SSLv2 only
1489# 3 SSLv3 only
1490# 4 TLSv1.0 only
1491# 5 TLSv1.1 only
1492# 6 TLSv1.2 only
1493#
1494# cipher= Colon separated list of supported ciphers.
1495# NOTE: some ciphers such as EDH ciphers depend on
1496# additional settings. If those settings are
1497# omitted the ciphers may be silently ignored
1498# by the OpenSSL library.
1499#
1500# options= Various SSL implementation options. The most important
1501# being:
1502# NO_SSLv2 Disallow the use of SSLv2
1503# NO_SSLv3 Disallow the use of SSLv3
1504# NO_TLSv1 Disallow the use of TLSv1.0
1505# NO_TLSv1_1 Disallow the use of TLSv1.1
1506# NO_TLSv1_2 Disallow the use of TLSv1.2
1507# SINGLE_DH_USE Always create a new key when using
1508# temporary/ephemeral DH key exchanges
1509# NO_TICKET Disables TLS tickets extension
1510#
1511# SINGLE_ECDH_USE
1512# Enable ephemeral ECDH key exchange.
1513# The adopted curve should be specified
1514# using the tls-dh option.
1515#
1516# ALL Enable various bug workarounds
1517# suggested as "harmless" by OpenSSL
1518# Be warned that this reduces SSL/TLS
1519# strength to some attacks.
1520# See OpenSSL SSL_CTX_set_options documentation for a
1521# complete list of options.
1522#
1523# clientca= File containing the list of CAs to use when
1524# requesting a client certificate.
1525#
1526# cafile= File containing additional CA certificates to
1527# use when verifying client certificates. If unset
1528# clientca will be used.
1529#
1530# capath= Directory containing additional CA certificates
1531# and CRL lists to use when verifying client certificates.
1532#
1533# crlfile= File of additional CRL lists to use when verifying
1534# the client certificate, in addition to CRLs stored in
1535# the capath. Implies VERIFY_CRL flag below.
1536#
1537# tls-dh=[curve:]file
1538# File containing DH parameters for temporary/ephemeral DH key
1539# exchanges, optionally prefixed by a curve for ephemeral ECDH
1540# key exchanges.
1541# See OpenSSL documentation for details on how to create the
1542# DH parameter file. Supported curves for ECDH can be listed
1543# using the "openssl ecparam -list_curves" command.
1544# WARNING: EDH and EECDH ciphers will be silently disabled if
1545# this option is not set.
1546#
1547# sslflags= Various flags modifying the use of SSL:
1548# DELAYED_AUTH
1549# Don't request client certificates
1550# immediately, but wait until acl processing
1551# requires a certificate (not yet implemented).
1552# NO_DEFAULT_CA
1553# Don't use the default CA lists built in
1554# to OpenSSL.
1555# NO_SESSION_REUSE
1556# Don't allow for session reuse. Each connection
1557# will result in a new SSL session.
1558# VERIFY_CRL
1559# Verify CRL lists when accepting client
1560# certificates.
1561# VERIFY_CRL_ALL
1562# Verify CRL lists for all certificates in the
1563# client certificate chain.
1564#
1565# sslcontext= SSL session ID context identifier.
1566#
1567# Other Options:
1568#
1569# connection-auth[=on|off]
1570# use connection-auth=off to tell Squid to prevent
1571# forwarding Microsoft connection oriented authentication
1572# (NTLM, Negotiate and Kerberos)
1573#
1574# disable-pmtu-discovery=
1575# Control Path-MTU discovery usage:
1576# off lets OS decide on what to do (default).
1577# transparent disable PMTU discovery when transparent
1578# support is enabled.
1579# always disable always PMTU discovery.
1580#
1581# In many setups of transparently intercepting proxies
1582# Path-MTU discovery can not work on traffic towards the
1583# clients. This is the case when the intercepting device
1584# does not fully track connections and fails to forward
1585# ICMP must fragment messages to the cache server. If you
1586# have such setup and experience that certain clients
1587# sporadically hang or never complete requests set
1588# disable-pmtu-discovery option to 'transparent'.
1589#
1590# name= Specifies a internal name for the port. Defaults to
1591# the port specification (port or addr:port)
1592#
1593# tcpkeepalive[=idle,interval,timeout]
1594# Enable TCP keepalive probes of idle connections.
1595# In seconds; idle is the initial time before TCP starts
1596# probing the connection, interval how often to probe, and
1597# timeout the time before giving up.
1598#
1599# require-proxy-header
1600# Require PROXY protocol version 1 or 2 connections.
1601# The proxy_protocol_access is required to whitelist
1602# downstream proxies which can be trusted.
1603#
1604# If you run Squid on a dual-homed machine with an internal
1605# and an external interface we recommend you to specify the
1606# internal address:port in http_port. This way Squid will only be
1607# visible on the internal address.
1608#
1609#
1610
1611# Squid normally listens to port 3128
1612http_port 3128
1613
1614# TAG: https_port
1615# Note: This option is only available if Squid is rebuilt with the
1616# --with-openssl
1617#
1618# Usage: [ip:]port cert=certificate.pem [key=key.pem] [mode] [options...]
1619#
1620# The socket address where Squid will listen for client requests made
1621# over TLS or SSL connections. Commonly referred to as HTTPS.
1622#
1623# This is most useful for situations where you are running squid in
1624# accelerator mode and you want to do the SSL work at the accelerator level.
1625#
1626# You may specify multiple socket addresses on multiple lines,
1627# each with their own SSL certificate and/or options.
1628#
1629# Modes:
1630#
1631# accel Accelerator / reverse proxy mode
1632#
1633# intercept Support for IP-Layer interception of
1634# outgoing requests without browser settings.
1635# NP: disables authentication and IPv6 on the port.
1636#
1637# tproxy Support Linux TPROXY for spoofing outgoing
1638# connections using the client IP address.
1639# NP: disables authentication and maybe IPv6 on the port.
1640#
1641# ssl-bump For each intercepted connection allowed by ssl_bump
1642# ACLs, establish a secure connection with the client and with
1643# the server, decrypt HTTPS messages as they pass through
1644# Squid, and treat them as unencrypted HTTP messages,
1645# becoming the man-in-the-middle.
1646#
1647# An "ssl_bump server-first" match is required to
1648# fully enable bumping of intercepted SSL connections.
1649#
1650# Requires tproxy or intercept.
1651#
1652# Omitting the mode flag causes default forward proxy mode to be used.
1653#
1654#
1655# See http_port for a list of generic options
1656#
1657#
1658# SSL Options:
1659#
1660# cert= Path to SSL certificate (PEM format).
1661#
1662# key= Path to SSL private key file (PEM format)
1663# if not specified, the certificate file is
1664# assumed to be a combined certificate and
1665# key file.
1666#
1667# version= The version of SSL/TLS supported
1668# 1 automatic (default)
1669# 2 SSLv2 only
1670# 3 SSLv3 only
1671# 4 TLSv1 only
1672#
1673# cipher= Colon separated list of supported ciphers.
1674#
1675# options= Various SSL engine options. The most important
1676# being:
1677# NO_SSLv2 Disallow the use of SSLv2
1678# NO_SSLv3 Disallow the use of SSLv3
1679# NO_TLSv1 Disallow the use of TLSv1
1680#
1681# SINGLE_DH_USE Always create a new key when using
1682# temporary/ephemeral DH key exchanges
1683#
1684# SINGLE_ECDH_USE
1685# Enable ephemeral ECDH key exchange.
1686# The adopted curve should be specified
1687# using the tls-dh option.
1688#
1689# See src/ssl_support.c or OpenSSL SSL_CTX_set_options
1690# documentation for a complete list of options.
1691#
1692# clientca= File containing the list of CAs to use when
1693# requesting a client certificate.
1694#
1695# cafile= File containing additional CA certificates to
1696# use when verifying client certificates. If unset
1697# clientca will be used.
1698#
1699# capath= Directory containing additional CA certificates
1700# and CRL lists to use when verifying client certificates.
1701#
1702# crlfile= File of additional CRL lists to use when verifying
1703# the client certificate, in addition to CRLs stored in
1704# the capath. Implies VERIFY_CRL flag below.
1705#
1706# tls-dh=[curve:]file
1707# File containing DH parameters for temporary/ephemeral DH key
1708# exchanges, optionally prefixed by a curve for ephemeral ECDH
1709# key exchanges.
1710#
1711# sslflags= Various flags modifying the use of SSL:
1712# DELAYED_AUTH
1713# Don't request client certificates
1714# immediately, but wait until acl processing
1715# requires a certificate (not yet implemented).
1716# NO_DEFAULT_CA
1717# Don't use the default CA lists built in
1718# to OpenSSL.
1719# NO_SESSION_REUSE
1720# Don't allow for session reuse. Each connection
1721# will result in a new SSL session.
1722# VERIFY_CRL
1723# Verify CRL lists when accepting client
1724# certificates.
1725# VERIFY_CRL_ALL
1726# Verify CRL lists for all certificates in the
1727# client certificate chain.
1728#
1729# sslcontext= SSL session ID context identifier.
1730#
1731# generate-host-certificates[=<on|off>]
1732# Dynamically create SSL server certificates for the
1733# destination hosts of bumped SSL requests.When
1734# enabled, the cert and key options are used to sign
1735# generated certificates. Otherwise generated
1736# certificate will be selfsigned.
1737# If there is CA certificate life time of generated
1738# certificate equals lifetime of CA certificate. If
1739# generated certificate is selfsigned lifetime is three
1740# years.
1741# This option is disabled by default. See the ssl-bump
1742# option above for more information.
1743#
1744# dynamic_cert_mem_cache_size=SIZE
1745# Approximate total RAM size spent on cached generated
1746# certificates. If set to zero, caching is disabled.
1747#
1748# See http_port for a list of available options.
1749#Default:
1750# none
1751
1752# TAG: ftp_port
1753# Enables Native FTP proxy by specifying the socket address where Squid
1754# listens for FTP client requests. See http_port directive for various
1755# ways to specify the listening address and mode.
1756#
1757# Usage: ftp_port address [mode] [options]
1758#
1759# WARNING: This is a new, experimental, complex feature that has seen
1760# limited production exposure. Some Squid modules (e.g., caching) do not
1761# currently work with native FTP proxying, and many features have not
1762# even been tested for compatibility. Test well before deploying!
1763#
1764# Native FTP proxying differs substantially from proxying HTTP requests
1765# with ftp:// URIs because Squid works as an FTP server and receives
1766# actual FTP commands (rather than HTTP requests with FTP URLs).
1767#
1768# Native FTP commands accepted at ftp_port are internally converted or
1769# wrapped into HTTP-like messages. The same happens to Native FTP
1770# responses received from FTP origin servers. Those HTTP-like messages
1771# are shoveled through regular access control and adaptation layers
1772# between the FTP client and the FTP origin server. This allows Squid to
1773# examine, adapt, block, and log FTP exchanges. Squid reuses most HTTP
1774# mechanisms when shoveling wrapped FTP messages. For example,
1775# http_access and adaptation_access directives are used.
1776#
1777# Modes:
1778#
1779# intercept Same as http_port intercept. The FTP origin address is
1780# determined based on the intended destination of the
1781# intercepted connection.
1782#
1783# tproxy Support Linux TPROXY for spoofing outgoing
1784# connections using the client IP address.
1785# NP: disables authentication and maybe IPv6 on the port.
1786#
1787# By default (i.e., without an explicit mode option), Squid extracts the
1788# FTP origin address from the login@origin parameter of the FTP USER
1789# command. Many popular FTP clients support such native FTP proxying.
1790#
1791# Options:
1792#
1793# name=token Specifies an internal name for the port. Defaults to
1794# the port address. Usable with myportname ACL.
1795#
1796# ftp-track-dirs
1797# Enables tracking of FTP directories by injecting extra
1798# PWD commands and adjusting Request-URI (in wrapping
1799# HTTP requests) to reflect the current FTP server
1800# directory. Tracking is disabled by default.
1801#
1802# protocol=FTP Protocol to reconstruct accelerated and intercepted
1803# requests with. Defaults to FTP. No other accepted
1804# values have been tested with. An unsupported value
1805# results in a FATAL error. Accepted values are FTP,
1806# HTTP (or HTTP/1.1), and HTTPS (or HTTPS/1.1).
1807#
1808# Other http_port modes and options that are not specific to HTTP and
1809# HTTPS may also work.
1810#Default:
1811# none
1812
1813# TAG: tcp_outgoing_tos
1814# Allows you to select a TOS/Diffserv value for packets outgoing
1815# on the server side, based on an ACL.
1816#
1817# tcp_outgoing_tos ds-field [!]aclname ...
1818#
1819# Example where normal_service_net uses the TOS value 0x00
1820# and good_service_net uses 0x20
1821#
1822# acl normal_service_net src 10.0.0.0/24
1823# acl good_service_net src 10.0.1.0/24
1824# tcp_outgoing_tos 0x00 normal_service_net
1825# tcp_outgoing_tos 0x20 good_service_net
1826#
1827# TOS/DSCP values really only have local significance - so you should
1828# know what you're specifying. For more information, see RFC2474,
1829# RFC2475, and RFC3260.
1830#
1831# The TOS/DSCP byte must be exactly that - a octet value 0 - 255, or
1832# "default" to use whatever default your host has.
1833# Note that only multiples of 4 are usable as the two rightmost bits have
1834# been redefined for use by ECN (RFC 3168 section 23.1).
1835# The squid parser will enforce this by masking away the ECN bits.
1836#
1837# Processing proceeds in the order specified, and stops at first fully
1838# matching line.
1839#
1840# Only fast ACLs are supported.
1841#Default:
1842# none
1843
1844# TAG: clientside_tos
1845# Allows you to select a TOS/DSCP value for packets being transmitted
1846# on the client-side, based on an ACL.
1847#
1848# clientside_tos ds-field [!]aclname ...
1849#
1850# Example where normal_service_net uses the TOS value 0x00
1851# and good_service_net uses 0x20
1852#
1853# acl normal_service_net src 10.0.0.0/24
1854# acl good_service_net src 10.0.1.0/24
1855# clientside_tos 0x00 normal_service_net
1856# clientside_tos 0x20 good_service_net
1857#
1858# Note: This feature is incompatible with qos_flows. Any TOS values set here
1859# will be overwritten by TOS values in qos_flows.
1860#
1861# The TOS/DSCP byte must be exactly that - a octet value 0 - 255, or
1862# "default" to use whatever default your host has.
1863# Note that only multiples of 4 are usable as the two rightmost bits have
1864# been redefined for use by ECN (RFC 3168 section 23.1).
1865# The squid parser will enforce this by masking away the ECN bits.
1866#
1867#Default:
1868# none
1869
1870# TAG: tcp_outgoing_mark
1871# Note: This option is only available if Squid is rebuilt with the
1872# Packet MARK (Linux)
1873#
1874# Allows you to apply a Netfilter mark value to outgoing packets
1875# on the server side, based on an ACL.
1876#
1877# tcp_outgoing_mark mark-value [!]aclname ...
1878#
1879# Example where normal_service_net uses the mark value 0x00
1880# and good_service_net uses 0x20
1881#
1882# acl normal_service_net src 10.0.0.0/24
1883# acl good_service_net src 10.0.1.0/24
1884# tcp_outgoing_mark 0x00 normal_service_net
1885# tcp_outgoing_mark 0x20 good_service_net
1886#
1887# Only fast ACLs are supported.
1888#Default:
1889# none
1890
1891# TAG: clientside_mark
1892# Note: This option is only available if Squid is rebuilt with the
1893# Packet MARK (Linux)
1894#
1895# Allows you to apply a Netfilter mark value to packets being transmitted
1896# on the client-side, based on an ACL.
1897#
1898# clientside_mark mark-value [!]aclname ...
1899#
1900# Example where normal_service_net uses the mark value 0x00
1901# and good_service_net uses 0x20
1902#
1903# acl normal_service_net src 10.0.0.0/24
1904# acl good_service_net src 10.0.1.0/24
1905# clientside_mark 0x00 normal_service_net
1906# clientside_mark 0x20 good_service_net
1907#
1908# Note: This feature is incompatible with qos_flows. Any mark values set here
1909# will be overwritten by mark values in qos_flows.
1910#Default:
1911# none
1912
1913# TAG: qos_flows
1914# Allows you to select a TOS/DSCP value to mark outgoing
1915# connections to the client, based on where the reply was sourced.
1916# For platforms using netfilter, allows you to set a netfilter mark
1917# value instead of, or in addition to, a TOS value.
1918#
1919# By default this functionality is disabled. To enable it with the default
1920# settings simply use "qos_flows mark" or "qos_flows tos". Default
1921# settings will result in the netfilter mark or TOS value being copied
1922# from the upstream connection to the client. Note that it is the connection
1923# CONNMARK value not the packet MARK value that is copied.
1924#
1925# It is not currently possible to copy the mark or TOS value from the
1926# client to the upstream connection request.
1927#
1928# TOS values really only have local significance - so you should
1929# know what you're specifying. For more information, see RFC2474,
1930# RFC2475, and RFC3260.
1931#
1932# The TOS/DSCP byte must be exactly that - a octet value 0 - 255.
1933# Note that only multiples of 4 are usable as the two rightmost bits have
1934# been redefined for use by ECN (RFC 3168 section 23.1).
1935# The squid parser will enforce this by masking away the ECN bits.
1936#
1937# Mark values can be any unsigned 32-bit integer value.
1938#
1939# This setting is configured by setting the following values:
1940#
1941# tos|mark Whether to set TOS or netfilter mark values
1942#
1943# local-hit=0xFF Value to mark local cache hits.
1944#
1945# sibling-hit=0xFF Value to mark hits from sibling peers.
1946#
1947# parent-hit=0xFF Value to mark hits from parent peers.
1948#
1949# miss=0xFF[/mask] Value to mark cache misses. Takes precedence
1950# over the preserve-miss feature (see below), unless
1951# mask is specified, in which case only the bits
1952# specified in the mask are written.
1953#
1954# The TOS variant of the following features are only possible on Linux
1955# and require your kernel to be patched with the TOS preserving ZPH
1956# patch, available from http://zph.bratcheda.org
1957# No patch is needed to preserve the netfilter mark, which will work
1958# with all variants of netfilter.
1959#
1960# disable-preserve-miss
1961# This option disables the preservation of the TOS or netfilter
1962# mark. By default, the existing TOS or netfilter mark value of
1963# the response coming from the remote server will be retained
1964# and masked with miss-mark.
1965# NOTE: in the case of a netfilter mark, the mark must be set on
1966# the connection (using the CONNMARK target) not on the packet
1967# (MARK target).
1968#
1969# miss-mask=0xFF
1970# Allows you to mask certain bits in the TOS or mark value
1971# received from the remote server, before copying the value to
1972# the TOS sent towards clients.
1973# Default for tos: 0xFF (TOS from server is not changed).
1974# Default for mark: 0xFFFFFFFF (mark from server is not changed).
1975#
1976# All of these features require the --enable-zph-qos compilation flag
1977# (enabled by default). Netfilter marking also requires the
1978# libnetfilter_conntrack libraries (--with-netfilter-conntrack) and
1979# libcap 2.09+ (--with-libcap).
1980#
1981#Default:
1982# none
1983
1984# TAG: tcp_outgoing_address
1985# Allows you to map requests to different outgoing IP addresses
1986# based on the username or source address of the user making
1987# the request.
1988#
1989# tcp_outgoing_address ipaddr [[!]aclname] ...
1990#
1991# For example;
1992# Forwarding clients with dedicated IPs for certain subnets.
1993#
1994# acl normal_service_net src 10.0.0.0/24
1995# acl good_service_net src 10.0.2.0/24
1996#
1997# tcp_outgoing_address 2001:db8::c001 good_service_net
1998# tcp_outgoing_address 10.1.0.2 good_service_net
1999#
2000# tcp_outgoing_address 2001:db8::beef normal_service_net
2001# tcp_outgoing_address 10.1.0.1 normal_service_net
2002#
2003# tcp_outgoing_address 2001:db8::1
2004# tcp_outgoing_address 10.1.0.3
2005#
2006# Processing proceeds in the order specified, and stops at first fully
2007# matching line.
2008#
2009# Squid will add an implicit IP version test to each line.
2010# Requests going to IPv4 websites will use the outgoing 10.1.0.* addresses.
2011# Requests going to IPv6 websites will use the outgoing 2001:db8:* addresses.
2012#
2013#
2014# NOTE: The use of this directive using client dependent ACLs is
2015# incompatible with the use of server side persistent connections. To
2016# ensure correct results it is best to set server_persistent_connections
2017# to off when using this directive in such configurations.
2018#
2019# NOTE: The use of this directive to set a local IP on outgoing TCP links
2020# is incompatible with using TPROXY to set client IP out outbound TCP links.
2021# When needing to contact peers use the no-tproxy cache_peer option and the
2022# client_dst_passthru directive re-enable normal forwarding such as this.
2023#
2024#Default:
2025# Address selection is performed by the operating system.
2026
2027# TAG: host_verify_strict
2028# Regardless of this option setting, when dealing with intercepted
2029# traffic, Squid always verifies that the destination IP address matches
2030# the Host header domain or IP (called 'authority form URL').
2031#
2032# This enforcement is performed to satisfy a MUST-level requirement in
2033# RFC 2616 section 14.23: "The Host field value MUST represent the naming
2034# authority of the origin server or gateway given by the original URL".
2035#
2036# When set to ON:
2037# Squid always responds with an HTTP 409 (Conflict) error
2038# page and logs a security warning if there is no match.
2039#
2040# Squid verifies that the destination IP address matches
2041# the Host header for forward-proxy and reverse-proxy traffic
2042# as well. For those traffic types, Squid also enables the
2043# following checks, comparing the corresponding Host header
2044# and Request-URI components:
2045#
2046# * The host names (domain or IP) must be identical,
2047# but valueless or missing Host header disables all checks.
2048# For the two host names to match, both must be either IP
2049# or FQDN.
2050#
2051# * Port numbers must be identical, but if a port is missing
2052# the scheme-default port is assumed.
2053#
2054#
2055# When set to OFF (the default):
2056# Squid allows suspicious requests to continue but logs a
2057# security warning and blocks caching of the response.
2058#
2059# * Forward-proxy traffic is not checked at all.
2060#
2061# * Reverse-proxy traffic is not checked at all.
2062#
2063# * Intercepted traffic which passes verification is handled
2064# according to client_dst_passthru.
2065#
2066# * Intercepted requests which fail verification are sent
2067# to the client original destination instead of DIRECT.
2068# This overrides 'client_dst_passthru off'.
2069#
2070# For now suspicious intercepted CONNECT requests are always
2071# responded to with an HTTP 409 (Conflict) error page.
2072#
2073#
2074# SECURITY NOTE:
2075#
2076# As described in CVE-2009-0801 when the Host: header alone is used
2077# to determine the destination of a request it becomes trivial for
2078# malicious scripts on remote websites to bypass browser same-origin
2079# security policy and sandboxing protections.
2080#
2081# The cause of this is that such applets are allowed to perform their
2082# own HTTP stack, in which case the same-origin policy of the browser
2083# sandbox only verifies that the applet tries to contact the same IP
2084# as from where it was loaded at the IP level. The Host: header may
2085# be different from the connected IP and approved origin.
2086#
2087#Default:
2088# host_verify_strict off
2089
2090# TAG: client_dst_passthru
2091# With NAT or TPROXY intercepted traffic Squid may pass the request
2092# directly to the original client destination IP or seek a faster
2093# source using the HTTP Host header.
2094#
2095# Using Host to locate alternative servers can provide faster
2096# connectivity with a range of failure recovery options.
2097# But can also lead to connectivity trouble when the client and
2098# server are attempting stateful interactions unaware of the proxy.
2099#
2100# This option (on by default) prevents alternative DNS entries being
2101# located to send intercepted traffic DIRECT to an origin server.
2102# The clients original destination IP and port will be used instead.
2103#
2104# Regardless of this option setting, when dealing with intercepted
2105# traffic Squid will verify the Host: header and any traffic which
2106# fails Host verification will be treated as if this option were ON.
2107#
2108# see host_verify_strict for details on the verification process.
2109#Default:
2110# client_dst_passthru on
2111
2112# SSL OPTIONS
2113# -----------------------------------------------------------------------------
2114
2115# TAG: ssl_unclean_shutdown
2116# Note: This option is only available if Squid is rebuilt with the
2117# --with-openssl
2118#
2119# Some browsers (especially MSIE) bugs out on SSL shutdown
2120# messages.
2121#Default:
2122# ssl_unclean_shutdown off
2123
2124# TAG: ssl_engine
2125# Note: This option is only available if Squid is rebuilt with the
2126# --with-openssl
2127#
2128# The OpenSSL engine to use. You will need to set this if you
2129# would like to use hardware SSL acceleration for example.
2130#Default:
2131# none
2132
2133# TAG: sslproxy_client_certificate
2134# Note: This option is only available if Squid is rebuilt with the
2135# --with-openssl
2136#
2137# Client SSL Certificate to use when proxying https:// URLs
2138#Default:
2139# none
2140
2141# TAG: sslproxy_client_key
2142# Note: This option is only available if Squid is rebuilt with the
2143# --with-openssl
2144#
2145# Client SSL Key to use when proxying https:// URLs
2146#Default:
2147# none
2148
2149# TAG: sslproxy_version
2150# Note: This option is only available if Squid is rebuilt with the
2151# --with-openssl
2152#
2153# SSL version level to use when proxying https:// URLs
2154#
2155# The versions of SSL/TLS supported:
2156#
2157# 1 automatic (default)
2158# 2 SSLv2 only
2159# 3 SSLv3 only
2160# 4 TLSv1.0 only
2161# 5 TLSv1.1 only
2162# 6 TLSv1.2 only
2163#Default:
2164# automatic SSL/TLS version negotiation
2165
2166# TAG: sslproxy_options
2167# Note: This option is only available if Squid is rebuilt with the
2168# --with-openssl
2169#
2170# Colon (:) or comma (,) separated list of SSL implementation options
2171# to use when proxying https:// URLs
2172#
2173# The most important being:
2174#
2175# NO_SSLv2 Disallow the use of SSLv2
2176# NO_SSLv3 Disallow the use of SSLv3
2177# NO_TLSv1 Disallow the use of TLSv1.0
2178# NO_TLSv1_1 Disallow the use of TLSv1.1
2179# NO_TLSv1_2 Disallow the use of TLSv1.2
2180#
2181# SINGLE_DH_USE
2182# Always create a new key when using temporary/ephemeral
2183# DH key exchanges
2184#
2185# NO_TICKET
2186# Disable use of RFC5077 session tickets. Some servers
2187# may have problems understanding the TLS extension due
2188# to ambiguous specification in RFC4507.
2189#
2190# ALL Enable various bug workarounds suggested as "harmless"
2191# by OpenSSL. Be warned that this may reduce SSL/TLS
2192# strength to some attacks.
2193#
2194# See the OpenSSL SSL_CTX_set_options documentation for a
2195# complete list of possible options.
2196#
2197# WARNING: This directive takes a single token. If a space is used
2198# the value(s) after that space are SILENTLY IGNORED.
2199#Default:
2200# none
2201
2202# TAG: sslproxy_cipher
2203# Note: This option is only available if Squid is rebuilt with the
2204# --with-openssl
2205#
2206# SSL cipher list to use when proxying https:// URLs
2207#
2208# Colon separated list of supported ciphers.
2209#Default:
2210# none
2211
2212# TAG: sslproxy_cafile
2213# Note: This option is only available if Squid is rebuilt with the
2214# --with-openssl
2215#
2216# file containing CA certificates to use when verifying server
2217# certificates while proxying https:// URLs
2218#Default:
2219# none
2220
2221# TAG: sslproxy_capath
2222# Note: This option is only available if Squid is rebuilt with the
2223# --with-openssl
2224#
2225# directory containing CA certificates to use when verifying
2226# server certificates while proxying https:// URLs
2227#Default:
2228# none
2229
2230# TAG: sslproxy_session_ttl
2231# Note: This option is only available if Squid is rebuilt with the
2232# --with-openssl
2233#
2234# Sets the timeout value for SSL sessions
2235#Default:
2236# sslproxy_session_ttl 300
2237
2238# TAG: sslproxy_session_cache_size
2239# Note: This option is only available if Squid is rebuilt with the
2240# --with-openssl
2241#
2242# Sets the cache size to use for ssl session
2243#Default:
2244# sslproxy_session_cache_size 2 MB
2245
2246# TAG: sslproxy_foreign_intermediate_certs
2247# Note: This option is only available if Squid is rebuilt with the
2248# --with-openssl
2249#
2250# Many origin servers fail to send their full server certificate
2251# chain for verification, assuming the client already has or can
2252# easily locate any missing intermediate certificates.
2253#
2254# Squid uses the certificates from the specified file to fill in
2255# these missing chains when trying to validate origin server
2256# certificate chains.
2257#
2258# The file is expected to contain zero or more PEM-encoded
2259# intermediate certificates. These certificates are not treated
2260# as trusted root certificates, and any self-signed certificate in
2261# this file will be ignored.
2262#Default:
2263# none
2264
2265# TAG: sslproxy_cert_sign_hash
2266# Note: This option is only available if Squid is rebuilt with the
2267# --with-openssl
2268#
2269# Sets the hashing algorithm to use when signing generated certificates.
2270# Valid algorithm names depend on the OpenSSL library used. The following
2271# names are usually available: sha1, sha256, sha512, and md5. Please see
2272# your OpenSSL library manual for the available hashes. By default, Squids
2273# that support this option use sha256 hashes.
2274#
2275# Squid does not forcefully purge cached certificates that were generated
2276# with an algorithm other than the currently configured one. They remain
2277# in the cache, subject to the regular cache eviction policy, and become
2278# useful if the algorithm changes again.
2279#Default:
2280# none
2281
2282# TAG: ssl_bump
2283# Note: This option is only available if Squid is rebuilt with the
2284# --with-openssl
2285#
2286# This option is consulted when a CONNECT request is received on
2287# an http_port (or a new connection is intercepted at an
2288# https_port), provided that port was configured with an ssl-bump
2289# flag. The subsequent data on the connection is either treated as
2290# HTTPS and decrypted OR tunneled at TCP level without decryption,
2291# depending on the first matching bumping "action".
2292#
2293# ssl_bump <action> [!]acl ...
2294#
2295# The following bumping actions are currently supported:
2296#
2297# splice
2298# Become a TCP tunnel without decrypting proxied traffic.
2299# This is the default action.
2300#
2301# bump
2302# When used on step SslBump1, establishes a secure connection
2303# with the client first, then connect to the server.
2304# When used on step SslBump2 or SslBump3, establishes a secure
2305# connection with the server and, using a mimicked server
2306# certificate, with the client.
2307#
2308# peek
2309# Receive client (step SslBump1) or server (step SslBump2)
2310# certificate while preserving the possibility of splicing the
2311# connection. Peeking at the server certificate (during step 2)
2312# usually precludes bumping of the connection at step 3.
2313#
2314# stare
2315# Receive client (step SslBump1) or server (step SslBump2)
2316# certificate while preserving the possibility of bumping the
2317# connection. Staring at the server certificate (during step 2)
2318# usually precludes splicing of the connection at step 3.
2319#
2320# terminate
2321# Close client and server connections.
2322#
2323# Backward compatibility actions available at step SslBump1:
2324#
2325# client-first
2326# Bump the connection. Establish a secure connection with the
2327# client first, then connect to the server. This old mode does
2328# not allow Squid to mimic server SSL certificate and does not
2329# work with intercepted SSL connections.
2330#
2331# server-first
2332# Bump the connection. Establish a secure connection with the
2333# server first, then establish a secure connection with the
2334# client, using a mimicked server certificate. Works with both
2335# CONNECT requests and intercepted SSL connections, but does
2336# not allow to make decisions based on SSL handshake info.
2337#
2338# peek-and-splice
2339# Decide whether to bump or splice the connection based on
2340# client-to-squid and server-to-squid SSL hello messages.
2341# XXX: Remove.
2342#
2343# none
2344# Same as the "splice" action.
2345#
2346# All ssl_bump rules are evaluated at each of the supported bumping
2347# steps. Rules with actions that are impossible at the current step are
2348# ignored. The first matching ssl_bump action wins and is applied at the
2349# end of the current step. If no rules match, the splice action is used.
2350# See the at_step ACL for a list of the supported SslBump steps.
2351#
2352# This clause supports both fast and slow acl types.
2353# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
2354#
2355# See also: http_port ssl-bump, https_port ssl-bump, and acl at_step.
2356#
2357#
2358# # Example: Bump all TLS connections except those originating from
2359# # localhost or those going to example.com.
2360#
2361# acl broken_sites ssl::server_name .example.com
2362# ssl_bump splice localhost
2363# ssl_bump splice broken_sites
2364# ssl_bump bump all
2365#Default:
2366# Become a TCP tunnel without decrypting proxied traffic.
2367
2368# TAG: sslproxy_flags
2369# Note: This option is only available if Squid is rebuilt with the
2370# --with-openssl
2371#
2372# Various flags modifying the use of SSL while proxying https:// URLs:
2373# DONT_VERIFY_PEER Accept certificates that fail verification.
2374# For refined control, see sslproxy_cert_error.
2375# NO_DEFAULT_CA Don't use the default CA list built in
2376# to OpenSSL.
2377#Default:
2378# none
2379
2380# TAG: sslproxy_cert_error
2381# Note: This option is only available if Squid is rebuilt with the
2382# --with-openssl
2383#
2384# Use this ACL to bypass server certificate validation errors.
2385#
2386# For example, the following lines will bypass all validation errors
2387# when talking to servers for example.com. All other
2388# validation errors will result in ERR_SECURE_CONNECT_FAIL error.
2389#
2390# acl BrokenButTrustedServers dstdomain example.com
2391# sslproxy_cert_error allow BrokenButTrustedServers
2392# sslproxy_cert_error deny all
2393#
2394# This clause only supports fast acl types.
2395# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
2396# Using slow acl types may result in server crashes
2397#
2398# Without this option, all server certificate validation errors
2399# terminate the transaction to protect Squid and the client.
2400#
2401# SQUID_X509_V_ERR_INFINITE_VALIDATION error cannot be bypassed
2402# but should not happen unless your OpenSSL library is buggy.
2403#
2404# SECURITY WARNING:
2405# Bypassing validation errors is dangerous because an
2406# error usually implies that the server cannot be trusted
2407# and the connection may be insecure.
2408#
2409# See also: sslproxy_flags and DONT_VERIFY_PEER.
2410#Default:
2411# Server certificate errors terminate the transaction.
2412
2413# TAG: sslproxy_cert_sign
2414# Note: This option is only available if Squid is rebuilt with the
2415# --with-openssl
2416#
2417#
2418# sslproxy_cert_sign <signing algorithm> acl ...
2419#
2420# The following certificate signing algorithms are supported:
2421#
2422# signTrusted
2423# Sign using the configured CA certificate which is usually
2424# placed in and trusted by end-user browsers. This is the
2425# default for trusted origin server certificates.
2426#
2427# signUntrusted
2428# Sign to guarantee an X509_V_ERR_CERT_UNTRUSTED browser error.
2429# This is the default for untrusted origin server certificates
2430# that are not self-signed (see ssl::certUntrusted).
2431#
2432# signSelf
2433# Sign using a self-signed certificate with the right CN to
2434# generate a X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT error in the
2435# browser. This is the default for self-signed origin server
2436# certificates (see ssl::certSelfSigned).
2437#
2438# This clause only supports fast acl types.
2439#
2440# When sslproxy_cert_sign acl(s) match, Squid uses the corresponding
2441# signing algorithm to generate the certificate and ignores all
2442# subsequent sslproxy_cert_sign options (the first match wins). If no
2443# acl(s) match, the default signing algorithm is determined by errors
2444# detected when obtaining and validating the origin server certificate.
2445#
2446# WARNING: SQUID_X509_V_ERR_DOMAIN_MISMATCH and ssl:certDomainMismatch can
2447# be used with sslproxy_cert_adapt, but if and only if Squid is bumping a
2448# CONNECT request that carries a domain name. In all other cases (CONNECT
2449# to an IP address or an intercepted SSL connection), Squid cannot detect
2450# the domain mismatch at certificate generation time when
2451# bump-server-first is used.
2452#Default:
2453# none
2454
2455# TAG: sslproxy_cert_adapt
2456# Note: This option is only available if Squid is rebuilt with the
2457# --with-openssl
2458#
2459#
2460# sslproxy_cert_adapt <adaptation algorithm> acl ...
2461#
2462# The following certificate adaptation algorithms are supported:
2463#
2464# setValidAfter
2465# Sets the "Not After" property to the "Not After" property of
2466# the CA certificate used to sign generated certificates.
2467#
2468# setValidBefore
2469# Sets the "Not Before" property to the "Not Before" property of
2470# the CA certificate used to sign generated certificates.
2471#
2472# setCommonName or setCommonName{CN}
2473# Sets Subject.CN property to the host name specified as a
2474# CN parameter or, if no explicit CN parameter was specified,
2475# extracted from the CONNECT request. It is a misconfiguration
2476# to use setCommonName without an explicit parameter for
2477# intercepted or tproxied SSL connections.
2478#
2479# This clause only supports fast acl types.
2480#
2481# Squid first groups sslproxy_cert_adapt options by adaptation algorithm.
2482# Within a group, when sslproxy_cert_adapt acl(s) match, Squid uses the
2483# corresponding adaptation algorithm to generate the certificate and
2484# ignores all subsequent sslproxy_cert_adapt options in that algorithm's
2485# group (i.e., the first match wins within each algorithm group). If no
2486# acl(s) match, the default mimicking action takes place.
2487#
2488# WARNING: SQUID_X509_V_ERR_DOMAIN_MISMATCH and ssl:certDomainMismatch can
2489# be used with sslproxy_cert_adapt, but if and only if Squid is bumping a
2490# CONNECT request that carries a domain name. In all other cases (CONNECT
2491# to an IP address or an intercepted SSL connection), Squid cannot detect
2492# the domain mismatch at certificate generation time when
2493# bump-server-first is used.
2494#Default:
2495# none
2496
2497# TAG: sslpassword_program
2498# Note: This option is only available if Squid is rebuilt with the
2499# --with-openssl
2500#
2501# Specify a program used for entering SSL key passphrases
2502# when using encrypted SSL certificate keys. If not specified
2503# keys must either be unencrypted, or Squid started with the -N
2504# option to allow it to query interactively for the passphrase.
2505#
2506# The key file name is given as argument to the program allowing
2507# selection of the right password if you have multiple encrypted
2508# keys.
2509#Default:
2510# none
2511
2512# OPTIONS RELATING TO EXTERNAL SSL_CRTD
2513# -----------------------------------------------------------------------------
2514
2515# TAG: sslcrtd_program
2516# Note: This option is only available if Squid is rebuilt with the
2517# --enable-ssl-crtd
2518#
2519# Specify the location and options of the executable for ssl_crtd process.
2520# /usr/lib/squid/ssl_crtd program requires -s and -M parameters
2521# For more information use:
2522# /usr/lib/squid/ssl_crtd -h
2523#Default:
2524# sslcrtd_program /usr/lib/squid/ssl_crtd -s /var/lib/ssl_db -M 4MB
2525
2526# TAG: sslcrtd_children
2527# Note: This option is only available if Squid is rebuilt with the
2528# --enable-ssl-crtd
2529#
2530# The maximum number of processes spawn to service ssl server.
2531# The maximum this may be safely set to is 32.
2532#
2533# The startup= and idle= options allow some measure of skew in your
2534# tuning.
2535#
2536# startup=N
2537#
2538# Sets the minimum number of processes to spawn when Squid
2539# starts or reconfigures. When set to zero the first request will
2540# cause spawning of the first child process to handle it.
2541#
2542# Starting too few children temporary slows Squid under load while it
2543# tries to spawn enough additional processes to cope with traffic.
2544#
2545# idle=N
2546#
2547# Sets a minimum of how many processes Squid is to try and keep available
2548# at all times. When traffic begins to rise above what the existing
2549# processes can handle this many more will be spawned up to the maximum
2550# configured. A minimum setting of 1 is required.
2551#
2552# You must have at least one ssl_crtd process.
2553#Default:
2554# sslcrtd_children 32 startup=5 idle=1
2555
2556# TAG: sslcrtvalidator_program
2557# Note: This option is only available if Squid is rebuilt with the
2558# --with-openssl
2559#
2560# Specify the location and options of the executable for ssl_crt_validator
2561# process.
2562#
2563# Usage: sslcrtvalidator_program [ttl=n] [cache=n] path ...
2564#
2565# Options:
2566# ttl=n TTL in seconds for cached results. The default is 60 secs
2567# cache=n limit the result cache size. The default value is 2048
2568#Default:
2569# none
2570
2571# TAG: sslcrtvalidator_children
2572# Note: This option is only available if Squid is rebuilt with the
2573# --with-openssl
2574#
2575# The maximum number of processes spawn to service SSL server.
2576# The maximum this may be safely set to is 32.
2577#
2578# The startup= and idle= options allow some measure of skew in your
2579# tuning.
2580#
2581# startup=N
2582#
2583# Sets the minimum number of processes to spawn when Squid
2584# starts or reconfigures. When set to zero the first request will
2585# cause spawning of the first child process to handle it.
2586#
2587# Starting too few children temporary slows Squid under load while it
2588# tries to spawn enough additional processes to cope with traffic.
2589#
2590# idle=N
2591#
2592# Sets a minimum of how many processes Squid is to try and keep available
2593# at all times. When traffic begins to rise above what the existing
2594# processes can handle this many more will be spawned up to the maximum
2595# configured. A minimum setting of 1 is required.
2596#
2597# concurrency=
2598#
2599# The number of requests each certificate validator helper can handle in
2600# parallel. A value of 0 indicates the certficate validator does not
2601# support concurrency. Defaults to 1.
2602#
2603# When this directive is set to a value >= 1 then the protocol
2604# used to communicate with the helper is modified to include
2605# a request ID in front of the request/response. The request
2606# ID from the request must be echoed back with the response
2607# to that request.
2608#
2609# You must have at least one ssl_crt_validator process.
2610#Default:
2611# sslcrtvalidator_children 32 startup=5 idle=1 concurrency=1
2612
2613# OPTIONS WHICH AFFECT THE NEIGHBOR SELECTION ALGORITHM
2614# -----------------------------------------------------------------------------
2615
2616# TAG: cache_peer
2617# To specify other caches in a hierarchy, use the format:
2618#
2619# cache_peer hostname type http-port icp-port [options]
2620#
2621# For example,
2622#
2623# # proxy icp
2624# # hostname type port port options
2625# # -------------------- -------- ----- ----- -----------
2626# cache_peer parent.foo.net parent 3128 3130 default
2627# cache_peer sib1.foo.net sibling 3128 3130 proxy-only
2628# cache_peer sib2.foo.net sibling 3128 3130 proxy-only
2629# cache_peer example.com parent 80 0 default
2630# cache_peer cdn.example.com sibling 3128 0
2631#
2632# type: either 'parent', 'sibling', or 'multicast'.
2633#
2634# proxy-port: The port number where the peer accept HTTP requests.
2635# For other Squid proxies this is usually 3128
2636# For web servers this is usually 80
2637#
2638# icp-port: Used for querying neighbor caches about objects.
2639# Set to 0 if the peer does not support ICP or HTCP.
2640# See ICP and HTCP options below for additional details.
2641#
2642#
2643# ==== ICP OPTIONS ====
2644#
2645# You MUST also set icp_port and icp_access explicitly when using these options.
2646# The defaults will prevent peer traffic using ICP.
2647#
2648#
2649# no-query Disable ICP queries to this neighbor.
2650#
2651# multicast-responder
2652# Indicates the named peer is a member of a multicast group.
2653# ICP queries will not be sent directly to the peer, but ICP
2654# replies will be accepted from it.
2655#
2656# closest-only Indicates that, for ICP_OP_MISS replies, we'll only forward
2657# CLOSEST_PARENT_MISSes and never FIRST_PARENT_MISSes.
2658#
2659# background-ping
2660# To only send ICP queries to this neighbor infrequently.
2661# This is used to keep the neighbor round trip time updated
2662# and is usually used in conjunction with weighted-round-robin.
2663#
2664#
2665# ==== HTCP OPTIONS ====
2666#
2667# You MUST also set htcp_port and htcp_access explicitly when using these options.
2668# The defaults will prevent peer traffic using HTCP.
2669#
2670#
2671# htcp Send HTCP, instead of ICP, queries to the neighbor.
2672# You probably also want to set the "icp-port" to 4827
2673# instead of 3130. This directive accepts a comma separated
2674# list of options described below.
2675#
2676# htcp=oldsquid Send HTCP to old Squid versions (2.5 or earlier).
2677#
2678# htcp=no-clr Send HTCP to the neighbor but without
2679# sending any CLR requests. This cannot be used with
2680# only-clr.
2681#
2682# htcp=only-clr Send HTCP to the neighbor but ONLY CLR requests.
2683# This cannot be used with no-clr.
2684#
2685# htcp=no-purge-clr
2686# Send HTCP to the neighbor including CLRs but only when
2687# they do not result from PURGE requests.
2688#
2689# htcp=forward-clr
2690# Forward any HTCP CLR requests this proxy receives to the peer.
2691#
2692#
2693# ==== PEER SELECTION METHODS ====
2694#
2695# The default peer selection method is ICP, with the first responding peer
2696# being used as source. These options can be used for better load balancing.
2697#
2698#
2699# default This is a parent cache which can be used as a "last-resort"
2700# if a peer cannot be located by any of the peer-selection methods.
2701# If specified more than once, only the first is used.
2702#
2703# round-robin Load-Balance parents which should be used in a round-robin
2704# fashion in the absence of any ICP queries.
2705# weight=N can be used to add bias.
2706#
2707# weighted-round-robin
2708# Load-Balance parents which should be used in a round-robin
2709# fashion with the frequency of each parent being based on the
2710# round trip time. Closer parents are used more often.
2711# Usually used for background-ping parents.
2712# weight=N can be used to add bias.
2713#
2714# carp Load-Balance parents which should be used as a CARP array.
2715# The requests will be distributed among the parents based on the
2716# CARP load balancing hash function based on their weight.
2717#
2718# userhash Load-balance parents based on the client proxy_auth or ident username.
2719#
2720# sourcehash Load-balance parents based on the client source IP.
2721#
2722# multicast-siblings
2723# To be used only for cache peers of type "multicast".
2724# ALL members of this multicast group have "sibling"
2725# relationship with it, not "parent". This is to a multicast
2726# group when the requested object would be fetched only from
2727# a "parent" cache, anyway. It's useful, e.g., when
2728# configuring a pool of redundant Squid proxies, being
2729# members of the same multicast group.
2730#
2731#
2732# ==== PEER SELECTION OPTIONS ====
2733#
2734# weight=N use to affect the selection of a peer during any weighted
2735# peer-selection mechanisms.
2736# The weight must be an integer; default is 1,
2737# larger weights are favored more.
2738# This option does not affect parent selection if a peering
2739# protocol is not in use.
2740#
2741# basetime=N Specify a base amount to be subtracted from round trip
2742# times of parents.
2743# It is subtracted before division by weight in calculating
2744# which parent to fectch from. If the rtt is less than the
2745# base time the rtt is set to a minimal value.
2746#
2747# ttl=N Specify a TTL to use when sending multicast ICP queries
2748# to this address.
2749# Only useful when sending to a multicast group.
2750# Because we don't accept ICP replies from random
2751# hosts, you must configure other group members as
2752# peers with the 'multicast-responder' option.
2753#
2754# no-delay To prevent access to this neighbor from influencing the
2755# delay pools.
2756#
2757# digest-url=URL Tell Squid to fetch the cache digest (if digests are
2758# enabled) for this host from the specified URL rather
2759# than the Squid default location.
2760#
2761#
2762# ==== CARP OPTIONS ====
2763#
2764# carp-key=key-specification
2765# use a different key than the full URL to hash against the peer.
2766# the key-specification is a comma-separated list of the keywords
2767# scheme, host, port, path, params
2768# Order is not important.
2769#
2770# ==== ACCELERATOR / REVERSE-PROXY OPTIONS ====
2771#
2772# originserver Causes this parent to be contacted as an origin server.
2773# Meant to be used in accelerator setups when the peer
2774# is a web server.
2775#
2776# forceddomain=name
2777# Set the Host header of requests forwarded to this peer.
2778# Useful in accelerator setups where the server (peer)
2779# expects a certain domain name but clients may request
2780# others. ie example.com or www.example.com
2781#
2782# no-digest Disable request of cache digests.
2783#
2784# no-netdb-exchange
2785# Disables requesting ICMP RTT database (NetDB).
2786#
2787#
2788# ==== AUTHENTICATION OPTIONS ====
2789#
2790# login=user:password
2791# If this is a personal/workgroup proxy and your parent
2792# requires proxy authentication.
2793#
2794# Note: The string can include URL escapes (i.e. %20 for
2795# spaces). This also means % must be written as %%.
2796#
2797# login=PASSTHRU
2798# Send login details received from client to this peer.
2799# Both Proxy- and WWW-Authorization headers are passed
2800# without alteration to the peer.
2801# Authentication is not required by Squid for this to work.
2802#
2803# Note: This will pass any form of authentication but
2804# only Basic auth will work through a proxy unless the
2805# connection-auth options are also used.
2806#
2807# login=PASS Send login details received from client to this peer.
2808# Authentication is not required by this option.
2809#
2810# If there are no client-provided authentication headers
2811# to pass on, but username and password are available
2812# from an external ACL user= and password= result tags
2813# they may be sent instead.
2814#
2815# Note: To combine this with proxy_auth both proxies must
2816# share the same user database as HTTP only allows for
2817# a single login (one for proxy, one for origin server).
2818# Also be warned this will expose your users proxy
2819# password to the peer. USE WITH CAUTION
2820#
2821# login=*:password
2822# Send the username to the upstream cache, but with a
2823# fixed password. This is meant to be used when the peer
2824# is in another administrative domain, but it is still
2825# needed to identify each user.
2826# The star can optionally be followed by some extra
2827# information which is added to the username. This can
2828# be used to identify this proxy to the peer, similar to
2829# the login=username:password option above.
2830#
2831# login=NEGOTIATE
2832# If this is a personal/workgroup proxy and your parent
2833# requires a secure proxy authentication.
2834# The first principal from the default keytab or defined by
2835# the environment variable KRB5_KTNAME will be used.
2836#
2837# WARNING: The connection may transmit requests from multiple
2838# clients. Negotiate often assumes end-to-end authentication
2839# and a single-client. Which is not strictly true here.
2840#
2841# login=NEGOTIATE:principal_name
2842# If this is a personal/workgroup proxy and your parent
2843# requires a secure proxy authentication.
2844# The principal principal_name from the default keytab or
2845# defined by the environment variable KRB5_KTNAME will be
2846# used.
2847#
2848# WARNING: The connection may transmit requests from multiple
2849# clients. Negotiate often assumes end-to-end authentication
2850# and a single-client. Which is not strictly true here.
2851#
2852# connection-auth=on|off
2853# Tell Squid that this peer does or not support Microsoft
2854# connection oriented authentication, and any such
2855# challenges received from there should be ignored.
2856# Default is auto to automatically determine the status
2857# of the peer.
2858#
2859#
2860# ==== SSL / HTTPS / TLS OPTIONS ====
2861#
2862# ssl Encrypt connections to this peer with SSL/TLS.
2863#
2864# sslcert=/path/to/ssl/certificate
2865# A client SSL certificate to use when connecting to
2866# this peer.
2867#
2868# sslkey=/path/to/ssl/key
2869# The private SSL key corresponding to sslcert above.
2870# If 'sslkey' is not specified 'sslcert' is assumed to
2871# reference a combined file containing both the
2872# certificate and the key.
2873#
2874# Notes:
2875#
2876# On Debian/Ubuntu systems a default snakeoil certificate is
2877# available in /etc/ssl and users can set:
2878#
2879# cert=/etc/ssl/certs/ssl-cert-snakeoil.pem
2880#
2881# and
2882#
2883# key=/etc/ssl/private/ssl-cert-snakeoil.key
2884#
2885# for testing.
2886#
2887# sslversion=1|2|3|4|5|6
2888# The SSL version to use when connecting to this peer
2889# 1 = automatic (default)
2890# 2 = SSL v2 only
2891# 3 = SSL v3 only
2892# 4 = TLS v1.0 only
2893# 5 = TLS v1.1 only
2894# 6 = TLS v1.2 only
2895#
2896# sslcipher=... The list of valid SSL ciphers to use when connecting
2897# to this peer.
2898#
2899# ssloptions=... Specify various SSL implementation options:
2900#
2901# NO_SSLv2 Disallow the use of SSLv2
2902# NO_SSLv3 Disallow the use of SSLv3
2903# NO_TLSv1 Disallow the use of TLSv1.0
2904# NO_TLSv1_1 Disallow the use of TLSv1.1
2905# NO_TLSv1_2 Disallow the use of TLSv1.2
2906#
2907# SINGLE_DH_USE
2908# Always create a new key when using
2909# temporary/ephemeral DH key exchanges
2910#
2911# NO_TICKET
2912# Disable use of RFC5077 session tickets. Some servers
2913# may have problems understanding the TLS extension due
2914# to ambiguous specification in RFC4507.
2915#
2916# ALL Enable various bug workarounds
2917# suggested as "harmless" by OpenSSL
2918# Be warned that this reduces SSL/TLS
2919# strength to some attacks.
2920#
2921# See the OpenSSL SSL_CTX_set_options documentation for a
2922# more complete list.
2923#
2924# sslcafile=... A file containing additional CA certificates to use
2925# when verifying the peer certificate.
2926#
2927# sslcapath=... A directory containing additional CA certificates to
2928# use when verifying the peer certificate.
2929#
2930# sslcrlfile=... A certificate revocation list file to use when
2931# verifying the peer certificate.
2932#
2933# sslflags=... Specify various flags modifying the SSL implementation:
2934#
2935# DONT_VERIFY_PEER
2936# Accept certificates even if they fail to
2937# verify.
2938# NO_DEFAULT_CA
2939# Don't use the default CA list built in
2940# to OpenSSL.
2941# DONT_VERIFY_DOMAIN
2942# Don't verify the peer certificate
2943# matches the server name
2944#
2945# ssldomain= The peer name as advertised in it's certificate.
2946# Used for verifying the correctness of the received peer
2947# certificate. If not specified the peer hostname will be
2948# used.
2949#
2950# front-end-https
2951# Enable the "Front-End-Https: On" header needed when
2952# using Squid as a SSL frontend in front of Microsoft OWA.
2953# See MS KB document Q307347 for details on this header.
2954# If set to auto the header will only be added if the
2955# request is forwarded as a https:// URL.
2956#
2957#
2958# ==== GENERAL OPTIONS ====
2959#
2960# connect-timeout=N
2961# A peer-specific connect timeout.
2962# Also see the peer_connect_timeout directive.
2963#
2964# connect-fail-limit=N
2965# How many times connecting to a peer must fail before
2966# it is marked as down. Standby connection failures
2967# count towards this limit. Default is 10.
2968#
2969# allow-miss Disable Squid's use of only-if-cached when forwarding
2970# requests to siblings. This is primarily useful when
2971# icp_hit_stale is used by the sibling. Excessive use
2972# of this option may result in forwarding loops. One way
2973# to prevent peering loops when using this option, is to
2974# deny cache peer usage on requests from a peer:
2975# acl fromPeer ...
2976# cache_peer_access peerName deny fromPeer
2977#
2978# max-conn=N Limit the number of concurrent connections the Squid
2979# may open to this peer, including already opened idle
2980# and standby connections. There is no peer-specific
2981# connection limit by default.
2982#
2983# A peer exceeding the limit is not used for new
2984# requests unless a standby connection is available.
2985#
2986# max-conn currently works poorly with idle persistent
2987# connections: When a peer reaches its max-conn limit,
2988# and there are idle persistent connections to the peer,
2989# the peer may not be selected because the limiting code
2990# does not know whether Squid can reuse those idle
2991# connections.
2992#
2993# standby=N Maintain a pool of N "hot standby" connections to an
2994# UP peer, available for requests when no idle
2995# persistent connection is available (or safe) to use.
2996# By default and with zero N, no such pool is maintained.
2997# N must not exceed the max-conn limit (if any).
2998#
2999# At start or after reconfiguration, Squid opens new TCP
3000# standby connections until there are N connections
3001# available and then replenishes the standby pool as
3002# opened connections are used up for requests. A used
3003# connection never goes back to the standby pool, but
3004# may go to the regular idle persistent connection pool
3005# shared by all peers and origin servers.
3006#
3007# Squid never opens multiple new standby connections
3008# concurrently. This one-at-a-time approach minimizes
3009# flooding-like effect on peers. Furthermore, just a few
3010# standby connections should be sufficient in most cases
3011# to supply most new requests with a ready-to-use
3012# connection.
3013#
3014# Standby connections obey server_idle_pconn_timeout.
3015# For the feature to work as intended, the peer must be
3016# configured to accept and keep them open longer than
3017# the idle timeout at the connecting Squid, to minimize
3018# race conditions typical to idle used persistent
3019# connections. Default request_timeout and
3020# server_idle_pconn_timeout values ensure such a
3021# configuration.
3022#
3023# name=xxx Unique name for the peer.
3024# Required if you have multiple peers on the same host
3025# but different ports.
3026# This name can be used in cache_peer_access and similar
3027# directives to identify the peer.
3028# Can be used by outgoing access controls through the
3029# peername ACL type.
3030#
3031# no-tproxy Do not use the client-spoof TPROXY support when forwarding
3032# requests to this peer. Use normal address selection instead.
3033# This overrides the spoof_client_ip ACL.
3034#
3035# proxy-only objects fetched from the peer will not be stored locally.
3036#
3037#Default:
3038# none
3039
3040# TAG: cache_peer_domain
3041# Use to limit the domains for which a neighbor cache will be
3042# queried.
3043#
3044# Usage:
3045# cache_peer_domain cache-host domain [domain ...]
3046# cache_peer_domain cache-host !domain
3047#
3048# For example, specifying
3049#
3050# cache_peer_domain parent.foo.net .edu
3051#
3052# has the effect such that UDP query packets are sent to
3053# 'bigserver' only when the requested object exists on a
3054# server in the .edu domain. Prefixing the domainname
3055# with '!' means the cache will be queried for objects
3056# NOT in that domain.
3057#
3058# NOTE: * Any number of domains may be given for a cache-host,
3059# either on the same or separate lines.
3060# * When multiple domains are given for a particular
3061# cache-host, the first matched domain is applied.
3062# * Cache hosts with no domain restrictions are queried
3063# for all requests.
3064# * There are no defaults.
3065# * There is also a 'cache_peer_access' tag in the ACL
3066# section.
3067#Default:
3068# none
3069
3070# TAG: cache_peer_access
3071# Restricts usage of cache_peer proxies.
3072#
3073# Usage:
3074# cache_peer_access peer-name allow|deny [!]aclname ...
3075#
3076# For the required peer-name parameter, use either the value of the
3077# cache_peer name=value parameter or, if name=value is missing, the
3078# cache_peer hostname parameter.
3079#
3080# This directive narrows down the selection of peering candidates, but
3081# does not determine the order in which the selected candidates are
3082# contacted. That order is determined by the peer selection algorithms
3083# (see PEER SELECTION sections in the cache_peer documentation).
3084#
3085# If a deny rule matches, the corresponding peer will not be contacted
3086# for the current transaction -- Squid will not send ICP queries and
3087# will not forward HTTP requests to that peer. An allow match leaves
3088# the corresponding peer in the selection. The first match for a given
3089# peer wins for that peer.
3090#
3091# The relative order of cache_peer_access directives for the same peer
3092# matters. The relative order of any two cache_peer_access directives
3093# for different peers does not matter. To ease interpretation, it is a
3094# good idea to group cache_peer_access directives for the same peer
3095# together.
3096#
3097# A single cache_peer_access directive may be evaluated multiple times
3098# for a given transaction because individual peer selection algorithms
3099# may check it independently from each other. These redundant checks
3100# may be optimized away in future Squid versions.
3101#
3102# This clause only supports fast acl types.
3103# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
3104#Default:
3105# No peer usage restrictions.
3106
3107# TAG: neighbor_type_domain
3108# Modify the cache_peer neighbor type when passing requests
3109# about specific domains to the peer.
3110#
3111# Usage:
3112# neighbor_type_domain neighbor parent|sibling domain domain ...
3113#
3114# For example:
3115# cache_peer foo.example.com parent 3128 3130
3116# neighbor_type_domain foo.example.com sibling .au .de
3117#
3118# The above configuration treats all requests to foo.example.com as a
3119# parent proxy unless the request is for a .au or .de ccTLD domain name.
3120#Default:
3121# The peer type from cache_peer directive is used for all requests to that peer.
3122
3123# TAG: dead_peer_timeout (seconds)
3124# This controls how long Squid waits to declare a peer cache
3125# as "dead." If there are no ICP replies received in this
3126# amount of time, Squid will declare the peer dead and not
3127# expect to receive any further ICP replies. However, it
3128# continues to send ICP queries, and will mark the peer as
3129# alive upon receipt of the first subsequent ICP reply.
3130#
3131# This timeout also affects when Squid expects to receive ICP
3132# replies from peers. If more than 'dead_peer' seconds have
3133# passed since the last ICP reply was received, Squid will not
3134# expect to receive an ICP reply on the next query. Thus, if
3135# your time between requests is greater than this timeout, you
3136# will see a lot of requests sent DIRECT to origin servers
3137# instead of to your parents.
3138#Default:
3139# dead_peer_timeout 10 seconds
3140
3141# TAG: forward_max_tries
3142# Controls how many different forward paths Squid will try
3143# before giving up. See also forward_timeout.
3144#
3145# NOTE: connect_retries (default: none) can make each of these
3146# possible forwarding paths be tried multiple times.
3147#Default:
3148# forward_max_tries 25
3149
3150# MEMORY CACHE OPTIONS
3151# -----------------------------------------------------------------------------
3152
3153# TAG: cache_mem (bytes)
3154# NOTE: THIS PARAMETER DOES NOT SPECIFY THE MAXIMUM PROCESS SIZE.
3155# IT ONLY PLACES A LIMIT ON HOW MUCH ADDITIONAL MEMORY SQUID WILL
3156# USE AS A MEMORY CACHE OF OBJECTS. SQUID USES MEMORY FOR OTHER
3157# THINGS AS WELL. SEE THE SQUID FAQ SECTION 8 FOR DETAILS.
3158#
3159# 'cache_mem' specifies the ideal amount of memory to be used
3160# for:
3161# * In-Transit objects
3162# * Hot Objects
3163# * Negative-Cached objects
3164#
3165# Data for these objects are stored in 4 KB blocks. This
3166# parameter specifies the ideal upper limit on the total size of
3167# 4 KB blocks allocated. In-Transit objects take the highest
3168# priority.
3169#
3170# In-transit objects have priority over the others. When
3171# additional space is needed for incoming data, negative-cached
3172# and hot objects will be released. In other words, the
3173# negative-cached and hot objects will fill up any unused space
3174# not needed for in-transit objects.
3175#
3176# If circumstances require, this limit will be exceeded.
3177# Specifically, if your incoming request rate requires more than
3178# 'cache_mem' of memory to hold in-transit objects, Squid will
3179# exceed this limit to satisfy the new requests. When the load
3180# decreases, blocks will be freed until the high-water mark is
3181# reached. Thereafter, blocks will be used to store hot
3182# objects.
3183#
3184# If shared memory caching is enabled, Squid does not use the shared
3185# cache space for in-transit objects, but they still consume as much
3186# local memory as they need. For more details about the shared memory
3187# cache, see memory_cache_shared.
3188#Default:
3189# cache_mem 256 MB
3190
3191# TAG: maximum_object_size_in_memory (bytes)
3192# Objects greater than this size will not be attempted to kept in
3193# the memory cache. This should be set high enough to keep objects
3194# accessed frequently in memory to improve performance whilst low
3195# enough to keep larger objects from hoarding cache_mem.
3196#Default:
3197# maximum_object_size_in_memory 512 KB
3198
3199# TAG: memory_cache_shared on|off
3200# Controls whether the memory cache is shared among SMP workers.
3201#
3202# The shared memory cache is meant to occupy cache_mem bytes and replace
3203# the non-shared memory cache, although some entities may still be
3204# cached locally by workers for now (e.g., internal and in-transit
3205# objects may be served from a local memory cache even if shared memory
3206# caching is enabled).
3207#
3208# By default, the memory cache is shared if and only if all of the
3209# following conditions are satisfied: Squid runs in SMP mode with
3210# multiple workers, cache_mem is positive, and Squid environment
3211# supports required IPC primitives (e.g., POSIX shared memory segments
3212# and GCC-style atomic operations).
3213#
3214# To avoid blocking locks, shared memory uses opportunistic algorithms
3215# that do not guarantee that every cachable entity that could have been
3216# shared among SMP workers will actually be shared.
3217#Default:
3218# "on" where supported if doing memory caching with multiple SMP workers.
3219
3220# TAG: memory_cache_mode
3221# Controls which objects to keep in the memory cache (cache_mem)
3222#
3223# always Keep most recently fetched objects in memory (default)
3224#
3225# disk Only disk cache hits are kept in memory, which means
3226# an object must first be cached on disk and then hit
3227# a second time before cached in memory.
3228#
3229# network Only objects fetched from network is kept in memory
3230#Default:
3231# Keep the most recently fetched objects in memory
3232
3233# TAG: memory_replacement_policy
3234# The memory replacement policy parameter determines which
3235# objects are purged from memory when memory space is needed.
3236#
3237# See cache_replacement_policy for details on algorithms.
3238#Default:
3239# memory_replacement_policy lru
3240
3241# DISK CACHE OPTIONS
3242# -----------------------------------------------------------------------------
3243
3244# TAG: cache_replacement_policy
3245# The cache replacement policy parameter determines which
3246# objects are evicted (replaced) when disk space is needed.
3247#
3248# lru : Squid's original list based LRU policy
3249# heap GDSF : Greedy-Dual Size Frequency
3250# heap LFUDA: Least Frequently Used with Dynamic Aging
3251# heap LRU : LRU policy implemented using a heap
3252#
3253# Applies to any cache_dir lines listed below this directive.
3254#
3255# The LRU policies keeps recently referenced objects.
3256#
3257# The heap GDSF policy optimizes object hit rate by keeping smaller
3258# popular objects in cache so it has a better chance of getting a
3259# hit. It achieves a lower byte hit rate than LFUDA though since
3260# it evicts larger (possibly popular) objects.
3261#
3262# The heap LFUDA policy keeps popular objects in cache regardless of
3263# their size and thus optimizes byte hit rate at the expense of
3264# hit rate since one large, popular object will prevent many
3265# smaller, slightly less popular objects from being cached.
3266#
3267# Both policies utilize a dynamic aging mechanism that prevents
3268# cache pollution that can otherwise occur with frequency-based
3269# replacement policies.
3270#
3271# NOTE: if using the LFUDA replacement policy you should increase
3272# the value of maximum_object_size above its default of 4 MB to
3273# to maximize the potential byte hit rate improvement of LFUDA.
3274#
3275# For more information about the GDSF and LFUDA cache replacement
3276# policies see http://www.hpl.hp.com/techreports/1999/HPL-1999-69.html
3277# and http://fog.hpl.external.hp.com/techreports/98/HPL-98-173.html.
3278#Default:
3279# cache_replacement_policy lru
3280
3281# TAG: minimum_object_size (bytes)
3282# Objects smaller than this size will NOT be saved on disk. The
3283# value is specified in bytes, and the default is 0 KB, which
3284# means all responses can be stored.
3285#Default:
3286# no limit
3287
3288# TAG: maximum_object_size (bytes)
3289# Set the default value for max-size parameter on any cache_dir.
3290# The value is specified in bytes, and the default is 4 MB.
3291#
3292# If you wish to get a high BYTES hit ratio, you should probably
3293# increase this (one 32 MB object hit counts for 3200 10KB
3294# hits).
3295#
3296# If you wish to increase hit ratio more than you want to
3297# save bandwidth you should leave this low.
3298#
3299# NOTE: if using the LFUDA replacement policy you should increase
3300# this value to maximize the byte hit rate improvement of LFUDA!
3301# See cache_replacement_policy for a discussion of this policy.
3302#Default:
3303# maximum_object_size 4 MB
3304
3305# TAG: cache_dir
3306# Format:
3307# cache_dir Type Directory-Name Fs-specific-data [options]
3308#
3309# You can specify multiple cache_dir lines to spread the
3310# cache among different disk partitions.
3311#
3312# Type specifies the kind of storage system to use. Only "ufs"
3313# is built by default. To enable any of the other storage systems
3314# see the --enable-storeio configure option.
3315#
3316# 'Directory' is a top-level directory where cache swap
3317# files will be stored. If you want to use an entire disk
3318# for caching, this can be the mount-point directory.
3319# The directory must exist and be writable by the Squid
3320# process. Squid will NOT create this directory for you.
3321#
3322# In SMP configurations, cache_dir must not precede the workers option
3323# and should use configuration macros or conditionals to give each
3324# worker interested in disk caching a dedicated cache directory.
3325#
3326#
3327# ==== The ufs store type ====
3328#
3329# "ufs" is the old well-known Squid storage format that has always
3330# been there.
3331#
3332# Usage:
3333# cache_dir ufs Directory-Name Mbytes L1 L2 [options]
3334#
3335# 'Mbytes' is the amount of disk space (MB) to use under this
3336# directory. The default is 100 MB. Change this to suit your
3337# configuration. Do NOT put the size of your disk drive here.
3338# Instead, if you want Squid to use the entire disk drive,
3339# subtract 20% and use that value.
3340#
3341# 'L1' is the number of first-level subdirectories which
3342# will be created under the 'Directory'. The default is 16.
3343#
3344# 'L2' is the number of second-level subdirectories which
3345# will be created under each first-level directory. The default
3346# is 256.
3347#
3348#
3349# ==== The aufs store type ====
3350#
3351# "aufs" uses the same storage format as "ufs", utilizing
3352# POSIX-threads to avoid blocking the main Squid process on
3353# disk-I/O. This was formerly known in Squid as async-io.
3354#
3355# Usage:
3356# cache_dir aufs Directory-Name Mbytes L1 L2 [options]
3357#
3358# see argument descriptions under ufs above
3359#
3360#
3361# ==== The diskd store type ====
3362#
3363# "diskd" uses the same storage format as "ufs", utilizing a
3364# separate process to avoid blocking the main Squid process on
3365# disk-I/O.
3366#
3367# Usage:
3368# cache_dir diskd Directory-Name Mbytes L1 L2 [options] [Q1=n] [Q2=n]
3369#
3370# see argument descriptions under ufs above
3371#
3372# Q1 specifies the number of unacknowledged I/O requests when Squid
3373# stops opening new files. If this many messages are in the queues,
3374# Squid won't open new files. Default is 64
3375#
3376# Q2 specifies the number of unacknowledged messages when Squid
3377# starts blocking. If this many messages are in the queues,
3378# Squid blocks until it receives some replies. Default is 72
3379#
3380# When Q1 < Q2 (the default), the cache directory is optimized
3381# for lower response time at the expense of a decrease in hit
3382# ratio. If Q1 > Q2, the cache directory is optimized for
3383# higher hit ratio at the expense of an increase in response
3384# time.
3385#
3386#
3387# ==== The rock store type ====
3388#
3389# Usage:
3390# cache_dir rock Directory-Name Mbytes [options]
3391#
3392# The Rock Store type is a database-style storage. All cached
3393# entries are stored in a "database" file, using fixed-size slots.
3394# A single entry occupies one or more slots.
3395#
3396# If possible, Squid using Rock Store creates a dedicated kid
3397# process called "disker" to avoid blocking Squid worker(s) on disk
3398# I/O. One disker kid is created for each rock cache_dir. Diskers
3399# are created only when Squid, running in daemon mode, has support
3400# for the IpcIo disk I/O module.
3401#
3402# swap-timeout=msec: Squid will not start writing a miss to or
3403# reading a hit from disk if it estimates that the swap operation
3404# will take more than the specified number of milliseconds. By
3405# default and when set to zero, disables the disk I/O time limit
3406# enforcement. Ignored when using blocking I/O module because
3407# blocking synchronous I/O does not allow Squid to estimate the
3408# expected swap wait time.
3409#
3410# max-swap-rate=swaps/sec: Artificially limits disk access using
3411# the specified I/O rate limit. Swap out requests that
3412# would cause the average I/O rate to exceed the limit are
3413# delayed. Individual swap in requests (i.e., hits or reads) are
3414# not delayed, but they do contribute to measured swap rate and
3415# since they are placed in the same FIFO queue as swap out
3416# requests, they may wait longer if max-swap-rate is smaller.
3417# This is necessary on file systems that buffer "too
3418# many" writes and then start blocking Squid and other processes
3419# while committing those writes to disk. Usually used together
3420# with swap-timeout to avoid excessive delays and queue overflows
3421# when disk demand exceeds available disk "bandwidth". By default
3422# and when set to zero, disables the disk I/O rate limit
3423# enforcement. Currently supported by IpcIo module only.
3424#
3425# slot-size=bytes: The size of a database "record" used for
3426# storing cached responses. A cached response occupies at least
3427# one slot and all database I/O is done using individual slots so
3428# increasing this parameter leads to more disk space waste while
3429# decreasing it leads to more disk I/O overheads. Should be a
3430# multiple of your operating system I/O page size. Defaults to
3431# 16KBytes. A housekeeping header is stored with each slot and
3432# smaller slot-sizes will be rejected. The header is smaller than
3433# 100 bytes.
3434#
3435#
3436# ==== COMMON OPTIONS ====
3437#
3438# no-store no new objects should be stored to this cache_dir.
3439#
3440# min-size=n the minimum object size in bytes this cache_dir
3441# will accept. It's used to restrict a cache_dir
3442# to only store large objects (e.g. AUFS) while
3443# other stores are optimized for smaller objects
3444# (e.g. Rock).
3445# Defaults to 0.
3446#
3447# max-size=n the maximum object size in bytes this cache_dir
3448# supports.
3449# The value in maximum_object_size directive sets
3450# the default unless more specific details are
3451# available (ie a small store capacity).
3452#
3453# Note: To make optimal use of the max-size limits you should order
3454# the cache_dir lines with the smallest max-size value first.
3455#
3456#Default:
3457# No disk cache. Store cache ojects only in memory.
3458#
3459
3460# Uncomment and adjust the following to add a disk cache directory.
3461#cache_dir ufs /var/spool/squid 100 16 256
3462
3463# TAG: store_dir_select_algorithm
3464# How Squid selects which cache_dir to use when the response
3465# object will fit into more than one.
3466#
3467# Regardless of which algorithm is used the cache_dir min-size
3468# and max-size parameters are obeyed. As such they can affect
3469# the selection algorithm by limiting the set of considered
3470# cache_dir.
3471#
3472# Algorithms:
3473#
3474# least-load
3475#
3476# This algorithm is suited to caches with similar cache_dir
3477# sizes and disk speeds.
3478#
3479# The disk with the least I/O pending is selected.
3480# When there are multiple disks with the same I/O load ranking
3481# the cache_dir with most available capacity is selected.
3482#
3483# When a mix of cache_dir sizes are configured the faster disks
3484# have a naturally lower I/O loading and larger disks have more
3485# capacity. So space used to store objects and data throughput
3486# may be very unbalanced towards larger disks.
3487#
3488#
3489# round-robin
3490#
3491# This algorithm is suited to caches with unequal cache_dir
3492# disk sizes.
3493#
3494# Each cache_dir is selected in a rotation. The next suitable
3495# cache_dir is used.
3496#
3497# Available cache_dir capacity is only considered in relation
3498# to whether the object will fit and meets the min-size and
3499# max-size parameters.
3500#
3501# Disk I/O loading is only considered to prevent overload on slow
3502# disks. This algorithm does not spread objects by size, so any
3503# I/O loading per-disk may appear very unbalanced and volatile.
3504#
3505# If several cache_dirs use similar min-size, max-size, or other
3506# limits to to reject certain responses, then do not group such
3507# cache_dir lines together, to avoid round-robin selection bias
3508# towards the first cache_dir after the group. Instead, interleave
3509# cache_dir lines from different groups. For example:
3510#
3511# store_dir_select_algorithm round-robin
3512# cache_dir rock /hdd1 ... min-size=100000
3513# cache_dir rock /ssd1 ... max-size=99999
3514# cache_dir rock /hdd2 ... min-size=100000
3515# cache_dir rock /ssd2 ... max-size=99999
3516# cache_dir rock /hdd3 ... min-size=100000
3517# cache_dir rock /ssd3 ... max-size=99999
3518#Default:
3519# store_dir_select_algorithm least-load
3520
3521# TAG: max_open_disk_fds
3522# To avoid having disk as the I/O bottleneck Squid can optionally
3523# bypass the on-disk cache if more than this amount of disk file
3524# descriptors are open.
3525#
3526# A value of 0 indicates no limit.
3527#Default:
3528# no limit
3529
3530# TAG: cache_swap_low (percent, 0-100)
3531# The low-water mark for AUFS/UFS/diskd cache object eviction by
3532# the cache_replacement_policy algorithm.
3533#
3534# Removal begins when the swap (disk) usage of a cache_dir is
3535# above this low-water mark and attempts to maintain utilization
3536# near the low-water mark.
3537#
3538# As swap utilization increases towards the high-water mark set
3539# by cache_swap_high object eviction becomes more agressive.
3540#
3541# The value difference in percentages between low- and high-water
3542# marks represent an eviction rate of 300 objects per second and
3543# the rate continues to scale in agressiveness by multiples of
3544# this above the high-water mark.
3545#
3546# Defaults are 90% and 95%. If you have a large cache, 5% could be
3547# hundreds of MB. If this is the case you may wish to set these
3548# numbers closer together.
3549#
3550# See also cache_swap_high and cache_replacement_policy
3551#Default:
3552# cache_swap_low 90
3553
3554# TAG: cache_swap_high (percent, 0-100)
3555# The high-water mark for AUFS/UFS/diskd cache object eviction by
3556# the cache_replacement_policy algorithm.
3557#
3558# Removal begins when the swap (disk) usage of a cache_dir is
3559# above the low-water mark set by cache_swap_low and attempts to
3560# maintain utilization near the low-water mark.
3561#
3562# As swap utilization increases towards this high-water mark object
3563# eviction becomes more agressive.
3564#
3565# The value difference in percentages between low- and high-water
3566# marks represent an eviction rate of 300 objects per second and
3567# the rate continues to scale in agressiveness by multiples of
3568# this above the high-water mark.
3569#
3570# Defaults are 90% and 95%. If you have a large cache, 5% could be
3571# hundreds of MB. If this is the case you may wish to set these
3572# numbers closer together.
3573#
3574# See also cache_swap_low and cache_replacement_policy
3575#Default:
3576# cache_swap_high 95
3577
3578# LOGFILE OPTIONS
3579# -----------------------------------------------------------------------------
3580
3581# TAG: logformat
3582# Usage:
3583#
3584# logformat <name> <format specification>
3585#
3586# Defines an access log format.
3587#
3588# The <format specification> is a string with embedded % format codes
3589#
3590# % format codes all follow the same basic structure where all but
3591# the formatcode is optional. Output strings are automatically escaped
3592# as required according to their context and the output format
3593# modifiers are usually not needed, but can be specified if an explicit
3594# output format is desired.
3595#
3596# % ["|[|'|#] [-] [[0]width] [{argument}] formatcode
3597#
3598# " output in quoted string format
3599# [ output in squid text log format as used by log_mime_hdrs
3600# # output in URL quoted format
3601# ' output as-is
3602#
3603# - left aligned
3604#
3605# width minimum and/or maximum field width:
3606# [width_min][.width_max]
3607# When minimum starts with 0, the field is zero-padded.
3608# String values exceeding maximum width are truncated.
3609#
3610# {arg} argument such as header name etc
3611#
3612# Format codes:
3613#
3614# % a literal % character
3615# sn Unique sequence number per log line entry
3616# err_code The ID of an error response served by Squid or
3617# a similar internal error identifier.
3618# err_detail Additional err_code-dependent error information.
3619# note The annotation specified by the argument. Also
3620# logs the adaptation meta headers set by the
3621# adaptation_meta configuration parameter.
3622# If no argument given all annotations logged.
3623# The argument may include a separator to use with
3624# annotation values:
3625# name[:separator]
3626# By default, multiple note values are separated with ","
3627# and multiple notes are separated with "\r\n".
3628# When logging named notes with %{name}note, the
3629# explicitly configured separator is used between note
3630# values. When logging all notes with %note, the
3631# explicitly configured separator is used between
3632# individual notes. There is currently no way to
3633# specify both value and notes separators when logging
3634# all notes with %note.
3635#
3636# Connection related format codes:
3637#
3638# >a Client source IP address
3639# >A Client FQDN
3640# >p Client source port
3641# >eui Client source EUI (MAC address, EUI-48 or EUI-64 identifier)
3642# >la Local IP address the client connected to
3643# >lp Local port number the client connected to
3644# >qos Client connection TOS/DSCP value set by Squid
3645# >nfmark Client connection netfilter mark set by Squid
3646#
3647# la Local listening IP address the client connection was connected to.
3648# lp Local listening port number the client connection was connected to.
3649#
3650# <a Server IP address of the last server or peer connection
3651# <A Server FQDN or peer name
3652# <p Server port number of the last server or peer connection
3653# <la Local IP address of the last server or peer connection
3654# <lp Local port number of the last server or peer connection
3655# <qos Server connection TOS/DSCP value set by Squid
3656# <nfmark Server connection netfilter mark set by Squid
3657#
3658# Time related format codes:
3659#
3660# ts Seconds since epoch
3661# tu subsecond time (milliseconds)
3662# tl Local time. Optional strftime format argument
3663# default %d/%b/%Y:%H:%M:%S %z
3664# tg GMT time. Optional strftime format argument
3665# default %d/%b/%Y:%H:%M:%S %z
3666# tr Response time (milliseconds)
3667# dt Total time spent making DNS lookups (milliseconds)
3668# tS Approximate master transaction start time in
3669# <full seconds since epoch>.<fractional seconds> format.
3670# Currently, Squid considers the master transaction
3671# started when a complete HTTP request header initiating
3672# the transaction is received from the client. This is
3673# the same value that Squid uses to calculate transaction
3674# response time when logging %tr to access.log. Currently,
3675# Squid uses millisecond resolution for %tS values,
3676# similar to the default access.log "current time" field
3677# (%ts.%03tu).
3678#
3679# Access Control related format codes:
3680#
3681# et Tag returned by external acl
3682# ea Log string returned by external acl
3683# un User name (any available)
3684# ul User name from authentication
3685# ue User name from external acl helper
3686# ui User name from ident
3687# un A user name. Expands to the first available name
3688# from the following list of information sources:
3689# - authenticated user name, like %ul
3690# - user name supplied by an external ACL, like %ue
3691# - SSL client name, like %us
3692# - ident user name, like %ui
3693# credentials Client credentials. The exact meaning depends on
3694# the authentication scheme: For Basic authentication,
3695# it is the password; for Digest, the realm sent by the
3696# client; for NTLM and Negotiate, the client challenge
3697# or client credentials prefixed with "YR " or "KK ".
3698#
3699# HTTP related format codes:
3700#
3701# REQUEST
3702#
3703# [http::]rm Request method (GET/POST etc)
3704# [http::]>rm Request method from client
3705# [http::]<rm Request method sent to server or peer
3706# [http::]ru Request URL from client (historic, filtered for logging)
3707# [http::]>ru Request URL from client
3708# [http::]<ru Request URL sent to server or peer
3709# [http::]>rs Request URL scheme from client
3710# [http::]<rs Request URL scheme sent to server or peer
3711# [http::]>rd Request URL domain from client
3712# [http::]<rd Request URL domain sent to server or peer
3713# [http::]>rP Request URL port from client
3714# [http::]<rP Request URL port sent to server or peer
3715# [http::]rp Request URL path excluding hostname
3716# [http::]>rp Request URL path excluding hostname from client
3717# [http::]<rp Request URL path excluding hostname sent to server or peer
3718# [http::]rv Request protocol version
3719# [http::]>rv Request protocol version from client
3720# [http::]<rv Request protocol version sent to server or peer
3721#
3722# [http::]>h Original received request header.
3723# Usually differs from the request header sent by
3724# Squid, although most fields are often preserved.
3725# Accepts optional header field name/value filter
3726# argument using name[:[separator]element] format.
3727# [http::]>ha Received request header after adaptation and
3728# redirection (pre-cache REQMOD vectoring point).
3729# Usually differs from the request header sent by
3730# Squid, although most fields are often preserved.
3731# Optional header name argument as for >h
3732#
3733#
3734# RESPONSE
3735#
3736# [http::]<Hs HTTP status code received from the next hop
3737# [http::]>Hs HTTP status code sent to the client
3738#
3739# [http::]<h Reply header. Optional header name argument
3740# as for >h
3741#
3742# [http::]mt MIME content type
3743#
3744#
3745# SIZE COUNTERS
3746#
3747# [http::]st Total size of request + reply traffic with client
3748# [http::]>st Total size of request received from client.
3749# Excluding chunked encoding bytes.
3750# [http::]<st Total size of reply sent to client (after adaptation)
3751#
3752# [http::]>sh Size of request headers received from client
3753# [http::]<sh Size of reply headers sent to client (after adaptation)
3754#
3755# [http::]<sH Reply high offset sent
3756# [http::]<sS Upstream object size
3757#
3758# [http::]<bs Number of HTTP-equivalent message body bytes
3759# received from the next hop, excluding chunked
3760# transfer encoding and control messages.
3761# Generated FTP/Gopher listings are treated as
3762# received bodies.
3763#
3764#
3765# TIMING
3766#
3767# [http::]<pt Peer response time in milliseconds. The timer starts
3768# when the last request byte is sent to the next hop
3769# and stops when the last response byte is received.
3770# [http::]<tt Total time in milliseconds. The timer
3771# starts with the first connect request (or write I/O)
3772# sent to the first selected peer. The timer stops
3773# with the last I/O with the last peer.
3774#
3775# Squid handling related format codes:
3776#
3777# Ss Squid request status (TCP_MISS etc)
3778# Sh Squid hierarchy status (DEFAULT_PARENT etc)
3779#
3780# SSL-related format codes:
3781#
3782# ssl::bump_mode SslBump decision for the transaction:
3783#
3784# For CONNECT requests that initiated bumping of
3785# a connection and for any request received on
3786# an already bumped connection, Squid logs the
3787# corresponding SslBump mode ("server-first" or
3788# "client-first"). See the ssl_bump option for
3789# more information about these modes.
3790#
3791# A "none" token is logged for requests that
3792# triggered "ssl_bump" ACL evaluation matching
3793# either a "none" rule or no rules at all.
3794#
3795# In all other cases, a single dash ("-") is
3796# logged.
3797#
3798# ssl::>sni SSL client SNI sent to Squid. Available only
3799# after the peek, stare, or splice SSL bumping
3800# actions.
3801#
3802# If ICAP is enabled, the following code becomes available (as
3803# well as ICAP log codes documented with the icap_log option):
3804#
3805# icap::tt Total ICAP processing time for the HTTP
3806# transaction. The timer ticks when ICAP
3807# ACLs are checked and when ICAP
3808# transaction is in progress.
3809#
3810# If adaptation is enabled the following three codes become available:
3811#
3812# adapt::<last_h The header of the last ICAP response or
3813# meta-information from the last eCAP
3814# transaction related to the HTTP transaction.
3815# Like <h, accepts an optional header name
3816# argument.
3817#
3818# adapt::sum_trs Summed adaptation transaction response
3819# times recorded as a comma-separated list in
3820# the order of transaction start time. Each time
3821# value is recorded as an integer number,
3822# representing response time of one or more
3823# adaptation (ICAP or eCAP) transaction in
3824# milliseconds. When a failed transaction is
3825# being retried or repeated, its time is not
3826# logged individually but added to the
3827# replacement (next) transaction. See also:
3828# adapt::all_trs.
3829#
3830# adapt::all_trs All adaptation transaction response times.
3831# Same as adaptation_strs but response times of
3832# individual transactions are never added
3833# together. Instead, all transaction response
3834# times are recorded individually.
3835#
3836# You can prefix adapt::*_trs format codes with adaptation
3837# service name in curly braces to record response time(s) specific
3838# to that service. For example: %{my_service}adapt::sum_trs
3839#
3840# If SSL is enabled, the following formating codes become available:
3841#
3842# %ssl::>cert_subject The Subject field of the received client
3843# SSL certificate or a dash ('-') if Squid has
3844# received an invalid/malformed certificate or
3845# no certificate at all. Consider encoding the
3846# logged value because Subject often has spaces.
3847#
3848# %ssl::>cert_issuer The Issuer field of the received client
3849# SSL certificate or a dash ('-') if Squid has
3850# received an invalid/malformed certificate or
3851# no certificate at all. Consider encoding the
3852# logged value because Issuer often has spaces.
3853#
3854# The default formats available (which do not need re-defining) are:
3855#
3856#logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
3857#logformat common %>a %[ui %[un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st %Ss:%Sh
3858#logformat combined %>a %[ui %[un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
3859#logformat referrer %ts.%03tu %>a %{Referer}>h %ru
3860#logformat useragent %>a [%tl] "%{User-Agent}>h"
3861#
3862# NOTE: When the log_mime_hdrs directive is set to ON.
3863# The squid, common and combined formats have a safely encoded copy
3864# of the mime headers appended to each line within a pair of brackets.
3865#
3866# NOTE: The common and combined formats are not quite true to the Apache definition.
3867# The logs from Squid contain an extra status and hierarchy code appended.
3868#
3869#Default:
3870# The format definitions squid, common, combined, referrer, useragent are built in.
3871
3872# TAG: access_log
3873# Configures whether and how Squid logs HTTP and ICP transactions.
3874# If access logging is enabled, a single line is logged for every
3875# matching HTTP or ICP request. The recommended directive formats are:
3876#
3877# access_log <module>:<place> [option ...] [acl acl ...]
3878# access_log none [acl acl ...]
3879#
3880# The following directive format is accepted but may be deprecated:
3881# access_log <module>:<place> [<logformat name> [acl acl ...]]
3882#
3883# In most cases, the first ACL name must not contain the '=' character
3884# and should not be equal to an existing logformat name. You can always
3885# start with an 'all' ACL to work around those restrictions.
3886#
3887# Will log to the specified module:place using the specified format (which
3888# must be defined in a logformat directive) those entries which match
3889# ALL the acl's specified (which must be defined in acl clauses).
3890# If no acl is specified, all requests will be logged to this destination.
3891#
3892# ===== Available options for the recommended directive format =====
3893#
3894# logformat=name Names log line format (either built-in or
3895# defined by a logformat directive). Defaults
3896# to 'squid'.
3897#
3898# buffer-size=64KB Defines approximate buffering limit for log
3899# records (see buffered_logs). Squid should not
3900# keep more than the specified size and, hence,
3901# should flush records before the buffer becomes
3902# full to avoid overflows under normal
3903# conditions (the exact flushing algorithm is
3904# module-dependent though). The on-error option
3905# controls overflow handling.
3906#
3907# on-error=die|drop Defines action on unrecoverable errors. The
3908# 'drop' action ignores (i.e., does not log)
3909# affected log records. The default 'die' action
3910# kills the affected worker. The drop action
3911# support has not been tested for modules other
3912# than tcp.
3913#
3914# ===== Modules Currently available =====
3915#
3916# none Do not log any requests matching these ACL.
3917# Do not specify Place or logformat name.
3918#
3919# stdio Write each log line to disk immediately at the completion of
3920# each request.
3921# Place: the filename and path to be written.
3922#
3923# daemon Very similar to stdio. But instead of writing to disk the log
3924# line is passed to a daemon helper for asychronous handling instead.
3925# Place: varies depending on the daemon.
3926#
3927# log_file_daemon Place: the file name and path to be written.
3928#
3929# syslog To log each request via syslog facility.
3930# Place: The syslog facility and priority level for these entries.
3931# Place Format: facility.priority
3932#
3933# where facility could be any of:
3934# authpriv, daemon, local0 ... local7 or user.
3935#
3936# And priority could be any of:
3937# err, warning, notice, info, debug.
3938#
3939# udp To send each log line as text data to a UDP receiver.
3940# Place: The destination host name or IP and port.
3941# Place Format: //host:port
3942#
3943# tcp To send each log line as text data to a TCP receiver.
3944# Lines may be accumulated before sending (see buffered_logs).
3945# Place: The destination host name or IP and port.
3946# Place Format: //host:port
3947#
3948# Default:
3949# access_log daemon:/var/log/squid/access.log squid
3950#Default:
3951# access_log daemon:/var/log/squid/access.log squid
3952
3953# TAG: icap_log
3954# ICAP log files record ICAP transaction summaries, one line per
3955# transaction.
3956#
3957# The icap_log option format is:
3958# icap_log <filepath> [<logformat name> [acl acl ...]]
3959# icap_log none [acl acl ...]]
3960#
3961# Please see access_log option documentation for details. The two
3962# kinds of logs share the overall configuration approach and many
3963# features.
3964#
3965# ICAP processing of a single HTTP message or transaction may
3966# require multiple ICAP transactions. In such cases, multiple
3967# ICAP transaction log lines will correspond to a single access
3968# log line.
3969#
3970# ICAP log supports many access.log logformat %codes. In ICAP context,
3971# HTTP message-related %codes are applied to the HTTP message embedded
3972# in an ICAP message. Logformat "%http::>..." codes are used for HTTP
3973# messages embedded in ICAP requests while "%http::<..." codes are used
3974# for HTTP messages embedded in ICAP responses. For example:
3975#
3976# http::>h To-be-adapted HTTP message headers sent by Squid to
3977# the ICAP service. For REQMOD transactions, these are
3978# HTTP request headers. For RESPMOD, these are HTTP
3979# response headers, but Squid currently cannot log them
3980# (i.e., %http::>h will expand to "-" for RESPMOD).
3981#
3982# http::<h Adapted HTTP message headers sent by the ICAP
3983# service to Squid (i.e., HTTP request headers in regular
3984# REQMOD; HTTP response headers in RESPMOD and during
3985# request satisfaction in REQMOD).
3986#
3987# ICAP OPTIONS transactions do not embed HTTP messages.
3988#
3989# Several logformat codes below deal with ICAP message bodies. An ICAP
3990# message body, if any, typically includes a complete HTTP message
3991# (required HTTP headers plus optional HTTP message body). When
3992# computing HTTP message body size for these logformat codes, Squid
3993# either includes or excludes chunked encoding overheads; see
3994# code-specific documentation for details.
3995#
3996# For Secure ICAP services, all size-related information is currently
3997# computed before/after TLS encryption/decryption, as if TLS was not
3998# in use at all.
3999#
4000# The following format codes are also available for ICAP logs:
4001#
4002# icap::<A ICAP server IP address. Similar to <A.
4003#
4004# icap::<service_name ICAP service name from the icap_service
4005# option in Squid configuration file.
4006#
4007# icap::ru ICAP Request-URI. Similar to ru.
4008#
4009# icap::rm ICAP request method (REQMOD, RESPMOD, or
4010# OPTIONS). Similar to existing rm.
4011#
4012# icap::>st The total size of the ICAP request sent to the ICAP
4013# server (ICAP headers + ICAP body), including chunking
4014# metadata (if any).
4015#
4016# icap::<st The total size of the ICAP response received from the
4017# ICAP server (ICAP headers + ICAP body), including
4018# chunking metadata (if any).
4019#
4020# icap::<bs The size of the ICAP response body received from the
4021# ICAP server, excluding chunking metadata (if any).
4022#
4023# icap::tr Transaction response time (in
4024# milliseconds). The timer starts when
4025# the ICAP transaction is created and
4026# stops when the transaction is completed.
4027# Similar to tr.
4028#
4029# icap::tio Transaction I/O time (in milliseconds). The
4030# timer starts when the first ICAP request
4031# byte is scheduled for sending. The timers
4032# stops when the last byte of the ICAP response
4033# is received.
4034#
4035# icap::to Transaction outcome: ICAP_ERR* for all
4036# transaction errors, ICAP_OPT for OPTION
4037# transactions, ICAP_ECHO for 204
4038# responses, ICAP_MOD for message
4039# modification, and ICAP_SAT for request
4040# satisfaction. Similar to Ss.
4041#
4042# icap::Hs ICAP response status code. Similar to Hs.
4043#
4044# icap::>h ICAP request header(s). Similar to >h.
4045#
4046# icap::<h ICAP response header(s). Similar to <h.
4047#
4048# The default ICAP log format, which can be used without an explicit
4049# definition, is called icap_squid:
4050#
4051#logformat icap_squid %ts.%03tu %6icap::tr %>A %icap::to/%03icap::Hs %icap::<st %icap::rm %icap::ru %un -/%icap::<A -
4052#
4053# See also: logformat and %adapt::<last_h
4054#Default:
4055# none
4056
4057# TAG: logfile_daemon
4058# Specify the path to the logfile-writing daemon. This daemon is
4059# used to write the access and store logs, if configured.
4060#
4061# Squid sends a number of commands to the log daemon:
4062# L<data>\n - logfile data
4063# R\n - rotate file
4064# T\n - truncate file
4065# O\n - reopen file
4066# F\n - flush file
4067# r<n>\n - set rotate count to <n>
4068# b<n>\n - 1 = buffer output, 0 = don't buffer output
4069#
4070# No responses is expected.
4071#Default:
4072# logfile_daemon /usr/lib/squid/log_file_daemon
4073
4074# TAG: stats_collection allow|deny acl acl...
4075# This options allows you to control which requests gets accounted
4076# in performance counters.
4077#
4078# This clause only supports fast acl types.
4079# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
4080#Default:
4081# Allow logging for all transactions.
4082
4083# TAG: cache_store_log
4084# Logs the activities of the storage manager. Shows which
4085# objects are ejected from the cache, and which objects are
4086# saved and for how long.
4087# There are not really utilities to analyze this data, so you can safely
4088# disable it (the default).
4089#
4090# Store log uses modular logging outputs. See access_log for the list
4091# of modules supported.
4092#
4093# Example:
4094# cache_store_log stdio:/var/log/squid/store.log
4095# cache_store_log daemon:/var/log/squid/store.log
4096#Default:
4097# none
4098
4099# TAG: cache_swap_state
4100# Location for the cache "swap.state" file. This index file holds
4101# the metadata of objects saved on disk. It is used to rebuild
4102# the cache during startup. Normally this file resides in each
4103# 'cache_dir' directory, but you may specify an alternate
4104# pathname here. Note you must give a full filename, not just
4105# a directory. Since this is the index for the whole object
4106# list you CANNOT periodically rotate it!
4107#
4108# If %s can be used in the file name it will be replaced with a
4109# a representation of the cache_dir name where each / is replaced
4110# with '.'. This is needed to allow adding/removing cache_dir
4111# lines when cache_swap_log is being used.
4112#
4113# If have more than one 'cache_dir', and %s is not used in the name
4114# these swap logs will have names such as:
4115#
4116# cache_swap_log.00
4117# cache_swap_log.01
4118# cache_swap_log.02
4119#
4120# The numbered extension (which is added automatically)
4121# corresponds to the order of the 'cache_dir' lines in this
4122# configuration file. If you change the order of the 'cache_dir'
4123# lines in this file, these index files will NOT correspond to
4124# the correct 'cache_dir' entry (unless you manually rename
4125# them). We recommend you do NOT use this option. It is
4126# better to keep these index files in each 'cache_dir' directory.
4127#Default:
4128# Store the journal inside its cache_dir
4129
4130# TAG: logfile_rotate
4131# Specifies the number of logfile rotations to make when you
4132# type 'squid -k rotate'. The default is 10, which will rotate
4133# with extensions 0 through 9. Setting logfile_rotate to 0 will
4134# disable the file name rotation, but the logfiles are still closed
4135# and re-opened. This will enable you to rename the logfiles
4136# yourself just before sending the rotate signal.
4137#
4138# Note, the 'squid -k rotate' command normally sends a USR1
4139# signal to the running squid process. In certain situations
4140# (e.g. on Linux with Async I/O), USR1 is used for other
4141# purposes, so -k rotate uses another signal. It is best to get
4142# in the habit of using 'squid -k rotate' instead of 'kill -USR1
4143# <pid>'.
4144#
4145# Note, from Squid-3.1 this option is only a default for cache.log,
4146# that log can be rotated separately by using debug_options.
4147#
4148# Note2, for Debian/Linux the default of logfile_rotate is
4149# zero, since it includes external logfile-rotation methods.
4150#Default:
4151# logfile_rotate 0
4152
4153# TAG: mime_table
4154# Path to Squid's icon configuration file.
4155#
4156# You shouldn't need to change this, but the default file contains
4157# examples and formatting information if you do.
4158#Default:
4159# mime_table /usr/share/squid/mime.conf
4160
4161# TAG: log_mime_hdrs on|off
4162# The Cache can record both the request and the response MIME
4163# headers for each HTTP transaction. The headers are encoded
4164# safely and will appear as two bracketed fields at the end of
4165# the access log (for either the native or httpd-emulated log
4166# formats). To enable this logging set log_mime_hdrs to 'on'.
4167#Default:
4168# log_mime_hdrs off
4169
4170# TAG: pid_filename
4171# A filename to write the process-id to. To disable, enter "none".
4172#Default:
4173# pid_filename /var/run/squid.pid
4174
4175# TAG: client_netmask
4176# A netmask for client addresses in logfiles and cachemgr output.
4177# Change this to protect the privacy of your cache clients.
4178# A netmask of 255.255.255.0 will log all IP's in that range with
4179# the last digit set to '0'.
4180#Default:
4181# Log full client IP address
4182
4183# TAG: strip_query_terms
4184# By default, Squid strips query terms from requested URLs before
4185# logging. This protects your user's privacy and reduces log size.
4186#
4187# When investigating HIT/MISS or other caching behaviour you
4188# will need to disable this to see the full URL used by Squid.
4189#Default:
4190# strip_query_terms on
4191
4192# TAG: buffered_logs on|off
4193# Whether to write/send access_log records ASAP or accumulate them and
4194# then write/send them in larger chunks. Buffering may improve
4195# performance because it decreases the number of I/Os. However,
4196# buffering increases the delay before log records become available to
4197# the final recipient (e.g., a disk file or logging daemon) and,
4198# hence, increases the risk of log records loss.
4199#
4200# Note that even when buffered_logs are off, Squid may have to buffer
4201# records if it cannot write/send them immediately due to pending I/Os
4202# (e.g., the I/O writing the previous log record) or connectivity loss.
4203#
4204# Currently honored by 'daemon' and 'tcp' access_log modules only.
4205#Default:
4206# buffered_logs off
4207
4208# TAG: netdb_filename
4209# Where Squid stores it's netdb journal.
4210# When enabled this journal preserves netdb state between restarts.
4211#
4212# To disable, enter "none".
4213#Default:
4214# netdb_filename stdio:/var/log/squid/netdb.state
4215
4216# OPTIONS FOR TROUBLESHOOTING
4217# -----------------------------------------------------------------------------
4218
4219# TAG: cache_log
4220# Squid administrative logging file.
4221#
4222# This is where general information about Squid behavior goes. You can
4223# increase the amount of data logged to this file and how often it is
4224# rotated with "debug_options"
4225#Default:
4226# cache_log /var/log/squid/cache.log
4227
4228# TAG: debug_options
4229# Logging options are set as section,level where each source file
4230# is assigned a unique section. Lower levels result in less
4231# output, Full debugging (level 9) can result in a very large
4232# log file, so be careful.
4233#
4234# The magic word "ALL" sets debugging levels for all sections.
4235# The default is to run with "ALL,1" to record important warnings.
4236#
4237# The rotate=N option can be used to keep more or less of these logs
4238# than would otherwise be kept by logfile_rotate.
4239# For most uses a single log should be enough to monitor current
4240# events affecting Squid.
4241#Default:
4242# Log all critical and important messages.
4243
4244# TAG: coredump_dir
4245# By default Squid leaves core files in the directory from where
4246# it was started. If you set 'coredump_dir' to a directory
4247# that exists, Squid will chdir() to that directory at startup
4248# and coredump files will be left there.
4249#
4250#Default:
4251# Use the directory from where Squid was started.
4252#
4253
4254# Leave coredumps in the first cache dir
4255coredump_dir /var/spool/squid
4256
4257# OPTIONS FOR FTP GATEWAYING
4258# -----------------------------------------------------------------------------
4259
4260# TAG: ftp_user
4261# If you want the anonymous login password to be more informative
4262# (and enable the use of picky FTP servers), set this to something
4263# reasonable for your domain, like wwwuser@somewhere.net
4264#
4265# The reason why this is domainless by default is the
4266# request can be made on the behalf of a user in any domain,
4267# depending on how the cache is used.
4268# Some FTP server also validate the email address is valid
4269# (for example perl.com).
4270#Default:
4271# ftp_user Squid@
4272
4273# TAG: ftp_passive
4274# If your firewall does not allow Squid to use passive
4275# connections, turn off this option.
4276#
4277# Use of ftp_epsv_all option requires this to be ON.
4278#Default:
4279# ftp_passive on
4280
4281# TAG: ftp_epsv_all
4282# FTP Protocol extensions permit the use of a special "EPSV ALL" command.
4283#
4284# NATs may be able to put the connection on a "fast path" through the
4285# translator, as the EPRT command will never be used and therefore,
4286# translation of the data portion of the segments will never be needed.
4287#
4288# When a client only expects to do two-way FTP transfers this may be
4289# useful.
4290# If squid finds that it must do a three-way FTP transfer after issuing
4291# an EPSV ALL command, the FTP session will fail.
4292#
4293# If you have any doubts about this option do not use it.
4294# Squid will nicely attempt all other connection methods.
4295#
4296# Requires ftp_passive to be ON (default) for any effect.
4297#Default:
4298# ftp_epsv_all off
4299
4300# TAG: ftp_epsv
4301# FTP Protocol extensions permit the use of a special "EPSV" command.
4302#
4303# NATs may be able to put the connection on a "fast path" through the
4304# translator using EPSV, as the EPRT command will never be used
4305# and therefore, translation of the data portion of the segments
4306# will never be needed.
4307#
4308# EPSV is often required to interoperate with FTP servers on IPv6
4309# networks. On the other hand, it may break some IPv4 servers.
4310#
4311# By default, EPSV may try EPSV with any FTP server. To fine tune
4312# that decision, you may restrict EPSV to certain clients or servers
4313# using ACLs:
4314#
4315# ftp_epsv allow|deny al1 acl2 ...
4316#
4317# WARNING: Disabling EPSV may cause problems with external NAT and IPv6.
4318#
4319# Only fast ACLs are supported.
4320# Requires ftp_passive to be ON (default) for any effect.
4321#Default:
4322# none
4323
4324# TAG: ftp_eprt
4325# FTP Protocol extensions permit the use of a special "EPRT" command.
4326#
4327# This extension provides a protocol neutral alternative to the
4328# IPv4-only PORT command. When supported it enables active FTP data
4329# channels over IPv6 and efficient NAT handling.
4330#
4331# Turning this OFF will prevent EPRT being attempted and will skip
4332# straight to using PORT for IPv4 servers.
4333#
4334# Some devices are known to not handle this extension correctly and
4335# may result in crashes. Devices which suport EPRT enough to fail
4336# cleanly will result in Squid attempting PORT anyway. This directive
4337# should only be disabled when EPRT results in device failures.
4338#
4339# WARNING: Doing so will convert Squid back to the old behavior with all
4340# the related problems with external NAT devices/layers and IPv4-only FTP.
4341#Default:
4342# ftp_eprt on
4343
4344# TAG: ftp_sanitycheck
4345# For security and data integrity reasons Squid by default performs
4346# sanity checks of the addresses of FTP data connections ensure the
4347# data connection is to the requested server. If you need to allow
4348# FTP connections to servers using another IP address for the data
4349# connection turn this off.
4350#Default:
4351# ftp_sanitycheck on
4352
4353# TAG: ftp_telnet_protocol
4354# The FTP protocol is officially defined to use the telnet protocol
4355# as transport channel for the control connection. However, many
4356# implementations are broken and does not respect this aspect of
4357# the FTP protocol.
4358#
4359# If you have trouble accessing files with ASCII code 255 in the
4360# path or similar problems involving this ASCII code you can
4361# try setting this directive to off. If that helps, report to the
4362# operator of the FTP server in question that their FTP server
4363# is broken and does not follow the FTP standard.
4364#Default:
4365# ftp_telnet_protocol on
4366
4367# OPTIONS FOR EXTERNAL SUPPORT PROGRAMS
4368# -----------------------------------------------------------------------------
4369
4370# TAG: diskd_program
4371# Specify the location of the diskd executable.
4372# Note this is only useful if you have compiled in
4373# diskd as one of the store io modules.
4374#Default:
4375# diskd_program /usr/lib/squid/diskd
4376
4377# TAG: unlinkd_program
4378# Specify the location of the executable for file deletion process.
4379#Default:
4380# unlinkd_program /usr/lib/squid/unlinkd
4381
4382# TAG: pinger_program
4383# Specify the location of the executable for the pinger process.
4384#Default:
4385# pinger_program /usr/lib/squid/pinger
4386
4387# TAG: pinger_enable
4388# Control whether the pinger is active at run-time.
4389# Enables turning ICMP pinger on and off with a simple
4390# squid -k reconfigure.
4391#Default:
4392# pinger_enable on
4393
4394# OPTIONS FOR URL REWRITING
4395# -----------------------------------------------------------------------------
4396
4397# TAG: url_rewrite_program
4398# Specify the location of the executable URL rewriter to use.
4399# Since they can perform almost any function there isn't one included.
4400#
4401# For each requested URL, the rewriter will receive on line with the format
4402#
4403# [channel-ID <SP>] URL [<SP> extras]<NL>
4404#
4405# See url_rewrite_extras on how to send "extras" with optional values to
4406# the helper.
4407# After processing the request the helper must reply using the following format:
4408#
4409# [channel-ID <SP>] result [<SP> kv-pairs]
4410#
4411# The result code can be:
4412#
4413# OK status=30N url="..."
4414# Redirect the URL to the one supplied in 'url='.
4415# 'status=' is optional and contains the status code to send
4416# the client in Squids HTTP response. It must be one of the
4417# HTTP redirect status codes: 301, 302, 303, 307, 308.
4418# When no status is given Squid will use 302.
4419#
4420# OK rewrite-url="..."
4421# Rewrite the URL to the one supplied in 'rewrite-url='.
4422# The new URL is fetched directly by Squid and returned to
4423# the client as the response to its request.
4424#
4425# OK
4426# When neither of url= and rewrite-url= are sent Squid does
4427# not change the URL.
4428#
4429# ERR
4430# Do not change the URL.
4431#
4432# BH
4433# An internal error occurred in the helper, preventing
4434# a result being identified. The 'message=' key name is
4435# reserved for delivering a log message.
4436#
4437#
4438# In addition to the above kv-pairs Squid also understands the following
4439# optional kv-pairs received from URL rewriters:
4440# clt_conn_tag=TAG
4441# Associates a TAG with the client TCP connection.
4442# The TAG is treated as a regular annotation but persists across
4443# future requests on the client connection rather than just the
4444# current request. A helper may update the TAG during subsequent
4445# requests be returning a new kv-pair.
4446#
4447# When using the concurrency= option the protocol is changed by
4448# introducing a query channel tag in front of the request/response.
4449# The query channel tag is a number between 0 and concurrency-1.
4450# This value must be echoed back unchanged to Squid as the first part
4451# of the response relating to its request.
4452#
4453# WARNING: URL re-writing ability should be avoided whenever possible.
4454# Use the URL redirect form of response instead.
4455#
4456# Re-write creates a difference in the state held by the client
4457# and server. Possibly causing confusion when the server response
4458# contains snippets of its view state. Embeded URLs, response
4459# and content Location headers, etc. are not re-written by this
4460# interface.
4461#
4462# By default, a URL rewriter is not used.
4463#Default:
4464# none
4465
4466# TAG: url_rewrite_children
4467# The maximum number of redirector processes to spawn. If you limit
4468# it too few Squid will have to wait for them to process a backlog of
4469# URLs, slowing it down. If you allow too many they will use RAM
4470# and other system resources noticably.
4471#
4472# The startup= and idle= options allow some measure of skew in your
4473# tuning.
4474#
4475# startup=
4476#
4477# Sets a minimum of how many processes are to be spawned when Squid
4478# starts or reconfigures. When set to zero the first request will
4479# cause spawning of the first child process to handle it.
4480#
4481# Starting too few will cause an initial slowdown in traffic as Squid
4482# attempts to simultaneously spawn enough processes to cope.
4483#
4484# idle=
4485#
4486# Sets a minimum of how many processes Squid is to try and keep available
4487# at all times. When traffic begins to rise above what the existing
4488# processes can handle this many more will be spawned up to the maximum
4489# configured. A minimum setting of 1 is required.
4490#
4491# concurrency=
4492#
4493# The number of requests each redirector helper can handle in
4494# parallel. Defaults to 0 which indicates the redirector
4495# is a old-style single threaded redirector.
4496#
4497# When this directive is set to a value >= 1 then the protocol
4498# used to communicate with the helper is modified to include
4499# an ID in front of the request/response. The ID from the request
4500# must be echoed back with the response to that request.
4501#Default:
4502# url_rewrite_children 20 startup=0 idle=1 concurrency=0
4503
4504# TAG: url_rewrite_host_header
4505# To preserve same-origin security policies in browsers and
4506# prevent Host: header forgery by redirectors Squid rewrites
4507# any Host: header in redirected requests.
4508#
4509# If you are running an accelerator this may not be a wanted
4510# effect of a redirector. This directive enables you disable
4511# Host: alteration in reverse-proxy traffic.
4512#
4513# WARNING: Entries are cached on the result of the URL rewriting
4514# process, so be careful if you have domain-virtual hosts.
4515#
4516# WARNING: Squid and other software verifies the URL and Host
4517# are matching, so be careful not to relay through other proxies
4518# or inspecting firewalls with this disabled.
4519#Default:
4520# url_rewrite_host_header on
4521
4522# TAG: url_rewrite_access
4523# If defined, this access list specifies which requests are
4524# sent to the redirector processes.
4525#
4526# This clause supports both fast and slow acl types.
4527# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
4528#Default:
4529# Allow, unless rules exist in squid.conf.
4530
4531# TAG: url_rewrite_bypass
4532# When this is 'on', a request will not go through the
4533# redirector if all the helpers are busy. If this is 'off'
4534# and the redirector queue grows too large, Squid will exit
4535# with a FATAL error and ask you to increase the number of
4536# redirectors. You should only enable this if the redirectors
4537# are not critical to your caching system. If you use
4538# redirectors for access control, and you enable this option,
4539# users may have access to pages they should not
4540# be allowed to request.
4541#Default:
4542# url_rewrite_bypass off
4543
4544# TAG: url_rewrite_extras
4545# Specifies a string to be append to request line format for the
4546# rewriter helper. "Quoted" format values may contain spaces and
4547# logformat %macros. In theory, any logformat %macro can be used.
4548# In practice, a %macro expands as a dash (-) if the helper request is
4549# sent before the required macro information is available to Squid.
4550#Default:
4551# url_rewrite_extras "%>a/%>A %un %>rm myip=%la myport=%lp"
4552
4553# OPTIONS FOR STORE ID
4554# -----------------------------------------------------------------------------
4555
4556# TAG: store_id_program
4557# Specify the location of the executable StoreID helper to use.
4558# Since they can perform almost any function there isn't one included.
4559#
4560# For each requested URL, the helper will receive one line with the format
4561#
4562# [channel-ID <SP>] URL [<SP> extras]<NL>
4563#
4564#
4565# After processing the request the helper must reply using the following format:
4566#
4567# [channel-ID <SP>] result [<SP> kv-pairs]
4568#
4569# The result code can be:
4570#
4571# OK store-id="..."
4572# Use the StoreID supplied in 'store-id='.
4573#
4574# ERR
4575# The default is to use HTTP request URL as the store ID.
4576#
4577# BH
4578# An internal error occured in the helper, preventing
4579# a result being identified.
4580#
4581# In addition to the above kv-pairs Squid also understands the following
4582# optional kv-pairs received from URL rewriters:
4583# clt_conn_tag=TAG
4584# Associates a TAG with the client TCP connection.
4585# Please see url_rewrite_program related documentation for this
4586# kv-pair
4587#
4588# Helper programs should be prepared to receive and possibly ignore
4589# additional whitespace-separated tokens on each input line.
4590#
4591# When using the concurrency= option the protocol is changed by
4592# introducing a query channel tag in front of the request/response.
4593# The query channel tag is a number between 0 and concurrency-1.
4594# This value must be echoed back unchanged to Squid as the first part
4595# of the response relating to its request.
4596#
4597# NOTE: when using StoreID refresh_pattern will apply to the StoreID
4598# returned from the helper and not the URL.
4599#
4600# WARNING: Wrong StoreID value returned by a careless helper may result
4601# in the wrong cached response returned to the user.
4602#
4603# By default, a StoreID helper is not used.
4604#Default:
4605# none
4606
4607# TAG: store_id_extras
4608# Specifies a string to be append to request line format for the
4609# StoreId helper. "Quoted" format values may contain spaces and
4610# logformat %macros. In theory, any logformat %macro can be used.
4611# In practice, a %macro expands as a dash (-) if the helper request is
4612# sent before the required macro information is available to Squid.
4613#Default:
4614# store_id_extras "%>a/%>A %un %>rm myip=%la myport=%lp"
4615
4616# TAG: store_id_children
4617# The maximum number of StoreID helper processes to spawn. If you limit
4618# it too few Squid will have to wait for them to process a backlog of
4619# requests, slowing it down. If you allow too many they will use RAM
4620# and other system resources noticably.
4621#
4622# The startup= and idle= options allow some measure of skew in your
4623# tuning.
4624#
4625# startup=
4626#
4627# Sets a minimum of how many processes are to be spawned when Squid
4628# starts or reconfigures. When set to zero the first request will
4629# cause spawning of the first child process to handle it.
4630#
4631# Starting too few will cause an initial slowdown in traffic as Squid
4632# attempts to simultaneously spawn enough processes to cope.
4633#
4634# idle=
4635#
4636# Sets a minimum of how many processes Squid is to try and keep available
4637# at all times. When traffic begins to rise above what the existing
4638# processes can handle this many more will be spawned up to the maximum
4639# configured. A minimum setting of 1 is required.
4640#
4641# concurrency=
4642#
4643# The number of requests each storeID helper can handle in
4644# parallel. Defaults to 0 which indicates the helper
4645# is a old-style single threaded program.
4646#
4647# When this directive is set to a value >= 1 then the protocol
4648# used to communicate with the helper is modified to include
4649# an ID in front of the request/response. The ID from the request
4650# must be echoed back with the response to that request.
4651#Default:
4652# store_id_children 20 startup=0 idle=1 concurrency=0
4653
4654# TAG: store_id_access
4655# If defined, this access list specifies which requests are
4656# sent to the StoreID processes. By default all requests
4657# are sent.
4658#
4659# This clause supports both fast and slow acl types.
4660# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
4661#Default:
4662# Allow, unless rules exist in squid.conf.
4663
4664# TAG: store_id_bypass
4665# When this is 'on', a request will not go through the
4666# helper if all helpers are busy. If this is 'off'
4667# and the helper queue grows too large, Squid will exit
4668# with a FATAL error and ask you to increase the number of
4669# helpers. You should only enable this if the helperss
4670# are not critical to your caching system. If you use
4671# helpers for critical caching components, and you enable this
4672# option, users may not get objects from cache.
4673#Default:
4674# store_id_bypass on
4675
4676# OPTIONS FOR TUNING THE CACHE
4677# -----------------------------------------------------------------------------
4678
4679# TAG: cache
4680# Requests denied by this directive will not be served from the cache
4681# and their responses will not be stored in the cache. This directive
4682# has no effect on other transactions and on already cached responses.
4683#
4684# This clause supports both fast and slow acl types.
4685# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
4686#
4687# This and the two other similar caching directives listed below are
4688# checked at different transaction processing stages, have different
4689# access to response information, affect different cache operations,
4690# and differ in slow ACLs support:
4691#
4692# * cache: Checked before Squid makes a hit/miss determination.
4693# No access to reply information!
4694# Denies both serving a hit and storing a miss.
4695# Supports both fast and slow ACLs.
4696# * send_hit: Checked after a hit was detected.
4697# Has access to reply (hit) information.
4698# Denies serving a hit only.
4699# Supports fast ACLs only.
4700# * store_miss: Checked before storing a cachable miss.
4701# Has access to reply (miss) information.
4702# Denies storing a miss only.
4703# Supports fast ACLs only.
4704#
4705# If you are not sure which of the three directives to use, apply the
4706# following decision logic:
4707#
4708# * If your ACL(s) are of slow type _and_ need response info, redesign.
4709# Squid does not support that particular combination at this time.
4710# Otherwise:
4711# * If your directive ACL(s) are of slow type, use "cache"; and/or
4712# * if your directive ACL(s) need no response info, use "cache".
4713# Otherwise:
4714# * If you do not want the response cached, use store_miss; and/or
4715# * if you do not want a hit on a cached response, use send_hit.
4716#Default:
4717# By default, this directive is unused and has no effect.
4718
4719# TAG: send_hit
4720# Responses denied by this directive will not be served from the cache
4721# (but may still be cached, see store_miss). This directive has no
4722# effect on the responses it allows and on the cached objects.
4723#
4724# Please see the "cache" directive for a summary of differences among
4725# store_miss, send_hit, and cache directives.
4726#
4727# Unlike the "cache" directive, send_hit only supports fast acl
4728# types. See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
4729#
4730# For example:
4731#
4732# # apply custom Store ID mapping to some URLs
4733# acl MapMe dstdomain .c.example.com
4734# store_id_program ...
4735# store_id_access allow MapMe
4736#
4737# # but prevent caching of special responses
4738# # such as 302 redirects that cause StoreID loops
4739# acl Ordinary http_status 200-299
4740# store_miss deny MapMe !Ordinary
4741#
4742# # and do not serve any previously stored special responses
4743# # from the cache (in case they were already cached before
4744# # the above store_miss rule was in effect).
4745# send_hit deny MapMe !Ordinary
4746#Default:
4747# By default, this directive is unused and has no effect.
4748
4749# TAG: store_miss
4750# Responses denied by this directive will not be cached (but may still
4751# be served from the cache, see send_hit). This directive has no
4752# effect on the responses it allows and on the already cached responses.
4753#
4754# Please see the "cache" directive for a summary of differences among
4755# store_miss, send_hit, and cache directives. See the
4756# send_hit directive for a usage example.
4757#
4758# Unlike the "cache" directive, store_miss only supports fast acl
4759# types. See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
4760#Default:
4761# By default, this directive is unused and has no effect.
4762
4763# TAG: max_stale time-units
4764# This option puts an upper limit on how stale content Squid
4765# will serve from the cache if cache validation fails.
4766# Can be overriden by the refresh_pattern max-stale option.
4767#Default:
4768# max_stale 1 week
4769
4770# TAG: refresh_pattern
4771# usage: refresh_pattern [-i] regex min percent max [options]
4772#
4773# By default, regular expressions are CASE-SENSITIVE. To make
4774# them case-insensitive, use the -i option.
4775#
4776# 'Min' is the time (in minutes) an object without an explicit
4777# expiry time should be considered fresh. The recommended
4778# value is 0, any higher values may cause dynamic applications
4779# to be erroneously cached unless the application designer
4780# has taken the appropriate actions.
4781#
4782# 'Percent' is a percentage of the objects age (time since last
4783# modification age) an object without explicit expiry time
4784# will be considered fresh.
4785#
4786# 'Max' is an upper limit on how long objects without an explicit
4787# expiry time will be considered fresh. The value is also used
4788# to form Cache-Control: max-age header for a request sent from
4789# Squid to origin/parent.
4790#
4791# options: override-expire
4792# override-lastmod
4793# reload-into-ims
4794# ignore-reload
4795# ignore-no-store
4796# ignore-must-revalidate
4797# ignore-private
4798# ignore-auth
4799# max-stale=NN
4800# refresh-ims
4801# store-stale
4802#
4803# override-expire enforces min age even if the server
4804# sent an explicit expiry time (e.g., with the
4805# Expires: header or Cache-Control: max-age). Doing this
4806# VIOLATES the HTTP standard. Enabling this feature
4807# could make you liable for problems which it causes.
4808#
4809# Note: override-expire does not enforce staleness - it only extends
4810# freshness / min. If the server returns a Expires time which
4811# is longer than your max time, Squid will still consider
4812# the object fresh for that period of time.
4813#
4814# override-lastmod enforces min age even on objects
4815# that were modified recently.
4816#
4817# reload-into-ims changes a client no-cache or ``reload''
4818# request for a cached entry into a conditional request using
4819# If-Modified-Since and/or If-None-Match headers, provided the
4820# cached entry has a Last-Modified and/or a strong ETag header.
4821# Doing this VIOLATES the HTTP standard. Enabling this feature
4822# could make you liable for problems which it causes.
4823#
4824# ignore-reload ignores a client no-cache or ``reload''
4825# header. Doing this VIOLATES the HTTP standard. Enabling
4826# this feature could make you liable for problems which
4827# it causes.
4828#
4829# ignore-no-store ignores any ``Cache-control: no-store''
4830# headers received from a server. Doing this VIOLATES
4831# the HTTP standard. Enabling this feature could make you
4832# liable for problems which it causes.
4833#
4834# ignore-must-revalidate ignores any ``Cache-Control: must-revalidate``
4835# headers received from a server. Doing this VIOLATES
4836# the HTTP standard. Enabling this feature could make you
4837# liable for problems which it causes.
4838#
4839# ignore-private ignores any ``Cache-control: private''
4840# headers received from a server. Doing this VIOLATES
4841# the HTTP standard. Enabling this feature could make you
4842# liable for problems which it causes.
4843#
4844# ignore-auth caches responses to requests with authorization,
4845# as if the originserver had sent ``Cache-control: public''
4846# in the response header. Doing this VIOLATES the HTTP standard.
4847# Enabling this feature could make you liable for problems which
4848# it causes.
4849#
4850# refresh-ims causes squid to contact the origin server
4851# when a client issues an If-Modified-Since request. This
4852# ensures that the client will receive an updated version
4853# if one is available.
4854#
4855# store-stale stores responses even if they don't have explicit
4856# freshness or a validator (i.e., Last-Modified or an ETag)
4857# present, or if they're already stale. By default, Squid will
4858# not cache such responses because they usually can't be
4859# reused. Note that such responses will be stale by default.
4860#
4861# max-stale=NN provide a maximum staleness factor. Squid won't
4862# serve objects more stale than this even if it failed to
4863# validate the object. Default: use the max_stale global limit.
4864#
4865# Basically a cached object is:
4866#
4867# FRESH if expire > now, else STALE
4868# STALE if age > max
4869# FRESH if lm-factor < percent, else STALE
4870# FRESH if age < min
4871# else STALE
4872#
4873# The refresh_pattern lines are checked in the order listed here.
4874# The first entry which matches is used. If none of the entries
4875# match the default will be used.
4876#
4877# Note, you must uncomment all the default lines if you want
4878# to change one. The default setting is only active if none is
4879# used.
4880#
4881#
4882
4883#
4884# Add any of your own refresh_pattern entries above these.
4885#
4886refresh_pattern ^ftp: 1440 20% 10080
4887refresh_pattern ^gopher: 1440 0% 1440
4888refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
4889refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
4890# example lin deb packages
4891#refresh_pattern (\.deb|\.udeb)$ 129600 100% 129600
4892refresh_pattern . 0 20% 4320
4893
4894# TAG: quick_abort_min (KB)
4895#Default:
4896# quick_abort_min 16 KB
4897
4898# TAG: quick_abort_max (KB)
4899#Default:
4900# quick_abort_max 16 KB
4901
4902# TAG: quick_abort_pct (percent)
4903# The cache by default continues downloading aborted requests
4904# which are almost completed (less than 16 KB remaining). This
4905# may be undesirable on slow (e.g. SLIP) links and/or very busy
4906# caches. Impatient users may tie up file descriptors and
4907# bandwidth by repeatedly requesting and immediately aborting
4908# downloads.
4909#
4910# When the user aborts a request, Squid will check the
4911# quick_abort values to the amount of data transferred until
4912# then.
4913#
4914# If the transfer has less than 'quick_abort_min' KB remaining,
4915# it will finish the retrieval.
4916#
4917# If the transfer has more than 'quick_abort_max' KB remaining,
4918# it will abort the retrieval.
4919#
4920# If more than 'quick_abort_pct' of the transfer has completed,
4921# it will finish the retrieval.
4922#
4923# If you do not want any retrieval to continue after the client
4924# has aborted, set both 'quick_abort_min' and 'quick_abort_max'
4925# to '0 KB'.
4926#
4927# If you want retrievals to always continue if they are being
4928# cached set 'quick_abort_min' to '-1 KB'.
4929#Default:
4930# quick_abort_pct 95
4931
4932# TAG: read_ahead_gap buffer-size
4933# The amount of data the cache will buffer ahead of what has been
4934# sent to the client when retrieving an object from another server.
4935#Default:
4936# read_ahead_gap 16 KB
4937
4938# TAG: negative_ttl time-units
4939# Set the Default Time-to-Live (TTL) for failed requests.
4940# Certain types of failures (such as "connection refused" and
4941# "404 Not Found") are able to be negatively-cached for a short time.
4942# Modern web servers should provide Expires: header, however if they
4943# do not this can provide a minimum TTL.
4944# The default is not to cache errors with unknown expiry details.
4945#
4946# Note that this is different from negative caching of DNS lookups.
4947#
4948# WARNING: Doing this VIOLATES the HTTP standard. Enabling
4949# this feature could make you liable for problems which it
4950# causes.
4951#Default:
4952# negative_ttl 0 seconds
4953
4954# TAG: positive_dns_ttl time-units
4955# Upper limit on how long Squid will cache positive DNS responses.
4956# Default is 6 hours (360 minutes). This directive must be set
4957# larger than negative_dns_ttl.
4958#Default:
4959# positive_dns_ttl 6 hours
4960
4961# TAG: negative_dns_ttl time-units
4962# Time-to-Live (TTL) for negative caching of failed DNS lookups.
4963# This also sets the lower cache limit on positive lookups.
4964# Minimum value is 1 second, and it is not recommendable to go
4965# much below 10 seconds.
4966#Default:
4967# negative_dns_ttl 1 minutes
4968
4969# TAG: range_offset_limit size [acl acl...]
4970# usage: (size) [units] [[!]aclname]
4971#
4972# Sets an upper limit on how far (number of bytes) into the file
4973# a Range request may be to cause Squid to prefetch the whole file.
4974# If beyond this limit, Squid forwards the Range request as it is and
4975# the result is NOT cached.
4976#
4977# This is to stop a far ahead range request (lets say start at 17MB)
4978# from making Squid fetch the whole object up to that point before
4979# sending anything to the client.
4980#
4981# Multiple range_offset_limit lines may be specified, and they will
4982# be searched from top to bottom on each request until a match is found.
4983# The first match found will be used. If no line matches a request, the
4984# default limit of 0 bytes will be used.
4985#
4986# 'size' is the limit specified as a number of units.
4987#
4988# 'units' specifies whether to use bytes, KB, MB, etc.
4989# If no units are specified bytes are assumed.
4990#
4991# A size of 0 causes Squid to never fetch more than the
4992# client requested. (default)
4993#
4994# A size of 'none' causes Squid to always fetch the object from the
4995# beginning so it may cache the result. (2.0 style)
4996#
4997# 'aclname' is the name of a defined ACL.
4998#
4999# NP: Using 'none' as the byte value here will override any quick_abort settings
5000# that may otherwise apply to the range request. The range request will
5001# be fully fetched from start to finish regardless of the client
5002# actions. This affects bandwidth usage.
5003#Default:
5004# none
5005
5006# TAG: minimum_expiry_time (seconds)
5007# The minimum caching time according to (Expires - Date)
5008# headers Squid honors if the object can't be revalidated.
5009# The default is 60 seconds.
5010#
5011# In reverse proxy environments it might be desirable to honor
5012# shorter object lifetimes. It is most likely better to make
5013# your server return a meaningful Last-Modified header however.
5014#
5015# In ESI environments where page fragments often have short
5016# lifetimes, this will often be best set to 0.
5017#Default:
5018# minimum_expiry_time 60 seconds
5019
5020# TAG: store_avg_object_size (bytes)
5021# Average object size, used to estimate number of objects your
5022# cache can hold. The default is 13 KB.
5023#
5024# This is used to pre-seed the cache index memory allocation to
5025# reduce expensive reallocate operations while handling clients
5026# traffic. Too-large values may result in memory allocation during
5027# peak traffic, too-small values will result in wasted memory.
5028#
5029# Check the cache manager 'info' report metrics for the real
5030# object sizes seen by your Squid before tuning this.
5031#Default:
5032# store_avg_object_size 13 KB
5033
5034# TAG: store_objects_per_bucket
5035# Target number of objects per bucket in the store hash table.
5036# Lowering this value increases the total number of buckets and
5037# also the storage maintenance rate. The default is 20.
5038#Default:
5039# store_objects_per_bucket 20
5040
5041# HTTP OPTIONS
5042# -----------------------------------------------------------------------------
5043
5044# TAG: request_header_max_size (KB)
5045# This specifies the maximum size for HTTP headers in a request.
5046# Request headers are usually relatively small (about 512 bytes).
5047# Placing a limit on the request header size will catch certain
5048# bugs (for example with persistent connections) and possibly
5049# buffer-overflow or denial-of-service attacks.
5050#Default:
5051# request_header_max_size 64 KB
5052
5053# TAG: reply_header_max_size (KB)
5054# This specifies the maximum size for HTTP headers in a reply.
5055# Reply headers are usually relatively small (about 512 bytes).
5056# Placing a limit on the reply header size will catch certain
5057# bugs (for example with persistent connections) and possibly
5058# buffer-overflow or denial-of-service attacks.
5059#Default:
5060# reply_header_max_size 64 KB
5061
5062# TAG: request_body_max_size (bytes)
5063# This specifies the maximum size for an HTTP request body.
5064# In other words, the maximum size of a PUT/POST request.
5065# A user who attempts to send a request with a body larger
5066# than this limit receives an "Invalid Request" error message.
5067# If you set this parameter to a zero (the default), there will
5068# be no limit imposed.
5069#
5070# See also client_request_buffer_max_size for an alternative
5071# limitation on client uploads which can be configured.
5072#Default:
5073# No limit.
5074
5075# TAG: client_request_buffer_max_size (bytes)
5076# This specifies the maximum buffer size of a client request.
5077# It prevents squid eating too much memory when somebody uploads
5078# a large file.
5079#Default:
5080# client_request_buffer_max_size 512 KB
5081
5082# TAG: broken_posts
5083# A list of ACL elements which, if matched, causes Squid to send
5084# an extra CRLF pair after the body of a PUT/POST request.
5085#
5086# Some HTTP servers has broken implementations of PUT/POST,
5087# and rely on an extra CRLF pair sent by some WWW clients.
5088#
5089# Quote from RFC2616 section 4.1 on this matter:
5090#
5091# Note: certain buggy HTTP/1.0 client implementations generate an
5092# extra CRLF's after a POST request. To restate what is explicitly
5093# forbidden by the BNF, an HTTP/1.1 client must not preface or follow
5094# a request with an extra CRLF.
5095#
5096# This clause only supports fast acl types.
5097# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
5098#
5099#Example:
5100# acl buggy_server url_regex ^http://....
5101# broken_posts allow buggy_server
5102#Default:
5103# Obey RFC 2616.
5104
5105# TAG: adaptation_uses_indirect_client on|off
5106# Controls whether the indirect client IP address (instead of the direct
5107# client IP address) is passed to adaptation services.
5108#
5109# See also: follow_x_forwarded_for adaptation_send_client_ip
5110#Default:
5111# adaptation_uses_indirect_client on
5112
5113# TAG: via on|off
5114# If set (default), Squid will include a Via header in requests and
5115# replies as required by RFC2616.
5116#Default:
5117# via on
5118
5119# TAG: ie_refresh on|off
5120# Microsoft Internet Explorer up until version 5.5 Service
5121# Pack 1 has an issue with transparent proxies, wherein it
5122# is impossible to force a refresh. Turning this on provides
5123# a partial fix to the problem, by causing all IMS-REFRESH
5124# requests from older IE versions to check the origin server
5125# for fresh content. This reduces hit ratio by some amount
5126# (~10% in my experience), but allows users to actually get
5127# fresh content when they want it. Note because Squid
5128# cannot tell if the user is using 5.5 or 5.5SP1, the behavior
5129# of 5.5 is unchanged from old versions of Squid (i.e. a
5130# forced refresh is impossible). Newer versions of IE will,
5131# hopefully, continue to have the new behavior and will be
5132# handled based on that assumption. This option defaults to
5133# the old Squid behavior, which is better for hit ratios but
5134# worse for clients using IE, if they need to be able to
5135# force fresh content.
5136#Default:
5137# ie_refresh off
5138
5139# TAG: vary_ignore_expire on|off
5140# Many HTTP servers supporting Vary gives such objects
5141# immediate expiry time with no cache-control header
5142# when requested by a HTTP/1.0 client. This option
5143# enables Squid to ignore such expiry times until
5144# HTTP/1.1 is fully implemented.
5145#
5146# WARNING: If turned on this may eventually cause some
5147# varying objects not intended for caching to get cached.
5148#Default:
5149# vary_ignore_expire off
5150
5151# TAG: request_entities
5152# Squid defaults to deny GET and HEAD requests with request entities,
5153# as the meaning of such requests are undefined in the HTTP standard
5154# even if not explicitly forbidden.
5155#
5156# Set this directive to on if you have clients which insists
5157# on sending request entities in GET or HEAD requests. But be warned
5158# that there is server software (both proxies and web servers) which
5159# can fail to properly process this kind of request which may make you
5160# vulnerable to cache pollution attacks if enabled.
5161#Default:
5162# request_entities off
5163
5164# TAG: request_header_access
5165# Usage: request_header_access header_name allow|deny [!]aclname ...
5166#
5167# WARNING: Doing this VIOLATES the HTTP standard. Enabling
5168# this feature could make you liable for problems which it
5169# causes.
5170#
5171# This option replaces the old 'anonymize_headers' and the
5172# older 'http_anonymizer' option with something that is much
5173# more configurable. A list of ACLs for each header name allows
5174# removal of specific header fields under specific conditions.
5175#
5176# This option only applies to outgoing HTTP request headers (i.e.,
5177# headers sent by Squid to the next HTTP hop such as a cache peer
5178# or an origin server). The option has no effect during cache hit
5179# detection. The equivalent adaptation vectoring point in ICAP
5180# terminology is post-cache REQMOD.
5181#
5182# The option is applied to individual outgoing request header
5183# fields. For each request header field F, Squid uses the first
5184# qualifying sets of request_header_access rules:
5185#
5186# 1. Rules with header_name equal to F's name.
5187# 2. Rules with header_name 'Other', provided F's name is not
5188# on the hard-coded list of commonly used HTTP header names.
5189# 3. Rules with header_name 'All'.
5190#
5191# Within that qualifying rule set, rule ACLs are checked as usual.
5192# If ACLs of an "allow" rule match, the header field is allowed to
5193# go through as is. If ACLs of a "deny" rule match, the header is
5194# removed and request_header_replace is then checked to identify
5195# if the removed header has a replacement. If no rules within the
5196# set have matching ACLs, the header field is left as is.
5197#
5198# For example, to achieve the same behavior as the old
5199# 'http_anonymizer standard' option, you should use:
5200#
5201# request_header_access From deny all
5202# request_header_access Referer deny all
5203# request_header_access User-Agent deny all
5204#
5205# Or, to reproduce the old 'http_anonymizer paranoid' feature
5206# you should use:
5207#
5208# request_header_access Authorization allow all
5209# request_header_access Proxy-Authorization allow all
5210# request_header_access Cache-Control allow all
5211# request_header_access Content-Length allow all
5212# request_header_access Content-Type allow all
5213# request_header_access Date allow all
5214# request_header_access Host allow all
5215# request_header_access If-Modified-Since allow all
5216# request_header_access Pragma allow all
5217# request_header_access Accept allow all
5218# request_header_access Accept-Charset allow all
5219# request_header_access Accept-Encoding allow all
5220# request_header_access Accept-Language allow all
5221# request_header_access Connection allow all
5222# request_header_access All deny all
5223#
5224# HTTP reply headers are controlled with the reply_header_access directive.
5225#
5226# By default, all headers are allowed (no anonymizing is performed).
5227#Default:
5228# No limits.
5229
5230# TAG: reply_header_access
5231# Usage: reply_header_access header_name allow|deny [!]aclname ...
5232#
5233# WARNING: Doing this VIOLATES the HTTP standard. Enabling
5234# this feature could make you liable for problems which it
5235# causes.
5236#
5237# This option only applies to reply headers, i.e., from the
5238# server to the client.
5239#
5240# This is the same as request_header_access, but in the other
5241# direction. Please see request_header_access for detailed
5242# documentation.
5243#
5244# For example, to achieve the same behavior as the old
5245# 'http_anonymizer standard' option, you should use:
5246#
5247# reply_header_access Server deny all
5248# reply_header_access WWW-Authenticate deny all
5249# reply_header_access Link deny all
5250#
5251# Or, to reproduce the old 'http_anonymizer paranoid' feature
5252# you should use:
5253#
5254# reply_header_access Allow allow all
5255# reply_header_access WWW-Authenticate allow all
5256# reply_header_access Proxy-Authenticate allow all
5257# reply_header_access Cache-Control allow all
5258# reply_header_access Content-Encoding allow all
5259# reply_header_access Content-Length allow all
5260# reply_header_access Content-Type allow all
5261# reply_header_access Date allow all
5262# reply_header_access Expires allow all
5263# reply_header_access Last-Modified allow all
5264# reply_header_access Location allow all
5265# reply_header_access Pragma allow all
5266# reply_header_access Content-Language allow all
5267# reply_header_access Retry-After allow all
5268# reply_header_access Title allow all
5269# reply_header_access Content-Disposition allow all
5270# reply_header_access Connection allow all
5271# reply_header_access All deny all
5272#
5273# HTTP request headers are controlled with the request_header_access directive.
5274#
5275# By default, all headers are allowed (no anonymizing is
5276# performed).
5277#Default:
5278# No limits.
5279
5280# TAG: request_header_replace
5281# Usage: request_header_replace header_name message
5282# Example: request_header_replace User-Agent Nutscrape/1.0 (CP/M; 8-bit)
5283#
5284# This option allows you to change the contents of headers
5285# denied with request_header_access above, by replacing them
5286# with some fixed string.
5287#
5288# This only applies to request headers, not reply headers.
5289#
5290# By default, headers are removed if denied.
5291#Default:
5292# none
5293
5294# TAG: reply_header_replace
5295# Usage: reply_header_replace header_name message
5296# Example: reply_header_replace Server Foo/1.0
5297#
5298# This option allows you to change the contents of headers
5299# denied with reply_header_access above, by replacing them
5300# with some fixed string.
5301#
5302# This only applies to reply headers, not request headers.
5303#
5304# By default, headers are removed if denied.
5305#Default:
5306# none
5307
5308# TAG: request_header_add
5309# Usage: request_header_add field-name field-value acl1 [acl2] ...
5310# Example: request_header_add X-Client-CA "CA=%ssl::>cert_issuer" all
5311#
5312# This option adds header fields to outgoing HTTP requests (i.e.,
5313# request headers sent by Squid to the next HTTP hop such as a
5314# cache peer or an origin server). The option has no effect during
5315# cache hit detection. The equivalent adaptation vectoring point
5316# in ICAP terminology is post-cache REQMOD.
5317#
5318# Field-name is a token specifying an HTTP header name. If a
5319# standard HTTP header name is used, Squid does not check whether
5320# the new header conflicts with any existing headers or violates
5321# HTTP rules. If the request to be modified already contains a
5322# field with the same name, the old field is preserved but the
5323# header field values are not merged.
5324#
5325# Field-value is either a token or a quoted string. If quoted
5326# string format is used, then the surrounding quotes are removed
5327# while escape sequences and %macros are processed.
5328#
5329# In theory, all of the logformat codes can be used as %macros.
5330# However, unlike logging (which happens at the very end of
5331# transaction lifetime), the transaction may not yet have enough
5332# information to expand a macro when the new header value is needed.
5333# And some information may already be available to Squid but not yet
5334# committed where the macro expansion code can access it (report
5335# such instances!). The macro will be expanded into a single dash
5336# ('-') in such cases. Not all macros have been tested.
5337#
5338# One or more Squid ACLs may be specified to restrict header
5339# injection to matching requests. As always in squid.conf, all
5340# ACLs in an option ACL list must be satisfied for the insertion
5341# to happen. The request_header_add option supports fast ACLs
5342# only.
5343#Default:
5344# none
5345
5346# TAG: note
5347# This option used to log custom information about the master
5348# transaction. For example, an admin may configure Squid to log
5349# which "user group" the transaction belongs to, where "user group"
5350# will be determined based on a set of ACLs and not [just]
5351# authentication information.
5352# Values of key/value pairs can be logged using %{key}note macros:
5353#
5354# note key value acl ...
5355# logformat myFormat ... %{key}note ...
5356#Default:
5357# none
5358
5359# TAG: relaxed_header_parser on|off|warn
5360# In the default "on" setting Squid accepts certain forms
5361# of non-compliant HTTP messages where it is unambiguous
5362# what the sending application intended even if the message
5363# is not correctly formatted. The messages is then normalized
5364# to the correct form when forwarded by Squid.
5365#
5366# If set to "warn" then a warning will be emitted in cache.log
5367# each time such HTTP error is encountered.
5368#
5369# If set to "off" then such HTTP errors will cause the request
5370# or response to be rejected.
5371#Default:
5372# relaxed_header_parser on
5373
5374# TAG: collapsed_forwarding (on|off)
5375# When enabled, instead of forwarding each concurrent request for
5376# the same URL, Squid just sends the first of them. The other, so
5377# called "collapsed" requests, wait for the response to the first
5378# request and, if it happens to be cachable, use that response.
5379# Here, "concurrent requests" means "received after the first
5380# request headers were parsed and before the corresponding response
5381# headers were parsed".
5382#
5383# This feature is disabled by default: enabling collapsed
5384# forwarding needlessly delays forwarding requests that look
5385# cachable (when they are collapsed) but then need to be forwarded
5386# individually anyway because they end up being for uncachable
5387# content. However, in some cases, such as acceleration of highly
5388# cachable content with periodic or grouped expiration times, the
5389# gains from collapsing [large volumes of simultaneous refresh
5390# requests] outweigh losses from such delays.
5391#
5392# Squid collapses two kinds of requests: regular client requests
5393# received on one of the listening ports and internal "cache
5394# revalidation" requests which are triggered by those regular
5395# requests hitting a stale cached object. Revalidation collapsing
5396# is currently disabled for Squid instances containing SMP-aware
5397# disk or memory caches and for Vary-controlled cached objects.
5398#Default:
5399# collapsed_forwarding off
5400
5401# TIMEOUTS
5402# -----------------------------------------------------------------------------
5403
5404# TAG: forward_timeout time-units
5405# This parameter specifies how long Squid should at most attempt in
5406# finding a forwarding path for the request before giving up.
5407#Default:
5408# forward_timeout 4 minutes
5409
5410# TAG: connect_timeout time-units
5411# This parameter specifies how long to wait for the TCP connect to
5412# the requested server or peer to complete before Squid should
5413# attempt to find another path where to forward the request.
5414#Default:
5415# connect_timeout 1 minute
5416
5417# TAG: peer_connect_timeout time-units
5418# This parameter specifies how long to wait for a pending TCP
5419# connection to a peer cache. The default is 30 seconds. You
5420# may also set different timeout values for individual neighbors
5421# with the 'connect-timeout' option on a 'cache_peer' line.
5422#Default:
5423# peer_connect_timeout 30 seconds
5424
5425# TAG: read_timeout time-units
5426# Applied on peer server connections.
5427#
5428# After each successful read(), the timeout will be extended by this
5429# amount. If no data is read again after this amount of time,
5430# the request is aborted and logged with ERR_READ_TIMEOUT.
5431#
5432# The default is 15 minutes.
5433#Default:
5434# read_timeout 15 minutes
5435
5436# TAG: write_timeout time-units
5437# This timeout is tracked for all connections that have data
5438# available for writing and are waiting for the socket to become
5439# ready. After each successful write, the timeout is extended by
5440# the configured amount. If Squid has data to write but the
5441# connection is not ready for the configured duration, the
5442# transaction associated with the connection is terminated. The
5443# default is 15 minutes.
5444#Default:
5445# write_timeout 15 minutes
5446
5447# TAG: request_timeout
5448# How long to wait for complete HTTP request headers after initial
5449# connection establishment.
5450#Default:
5451# request_timeout 5 minutes
5452
5453# TAG: client_idle_pconn_timeout
5454# How long to wait for the next HTTP request on a persistent
5455# client connection after the previous request completes.
5456#Default:
5457# client_idle_pconn_timeout 2 minutes
5458
5459# TAG: ftp_client_idle_timeout
5460# How long to wait for an FTP request on a connection to Squid ftp_port.
5461# Many FTP clients do not deal with idle connection closures well,
5462# necessitating a longer default timeout than client_idle_pconn_timeout
5463# used for incoming HTTP requests.
5464#Default:
5465# ftp_client_idle_timeout 30 minutes
5466
5467# TAG: client_lifetime time-units
5468# The maximum amount of time a client (browser) is allowed to
5469# remain connected to the cache process. This protects the Cache
5470# from having a lot of sockets (and hence file descriptors) tied up
5471# in a CLOSE_WAIT state from remote clients that go away without
5472# properly shutting down (either because of a network failure or
5473# because of a poor client implementation). The default is one
5474# day, 1440 minutes.
5475#
5476# NOTE: The default value is intended to be much larger than any
5477# client would ever need to be connected to your cache. You
5478# should probably change client_lifetime only as a last resort.
5479# If you seem to have many client connections tying up
5480# filedescriptors, we recommend first tuning the read_timeout,
5481# request_timeout, persistent_request_timeout and quick_abort values.
5482#Default:
5483# client_lifetime 1 day
5484
5485# TAG: half_closed_clients
5486# Some clients may shutdown the sending side of their TCP
5487# connections, while leaving their receiving sides open. Sometimes,
5488# Squid can not tell the difference between a half-closed and a
5489# fully-closed TCP connection.
5490#
5491# By default, Squid will immediately close client connections when
5492# read(2) returns "no more data to read."
5493#
5494# Change this option to 'on' and Squid will keep open connections
5495# until a read(2) or write(2) on the socket returns an error.
5496# This may show some benefits for reverse proxies. But if not
5497# it is recommended to leave OFF.
5498#Default:
5499# half_closed_clients off
5500
5501# TAG: server_idle_pconn_timeout
5502# Timeout for idle persistent connections to servers and other
5503# proxies.
5504#Default:
5505# server_idle_pconn_timeout 1 minute
5506
5507# TAG: ident_timeout
5508# Maximum time to wait for IDENT lookups to complete.
5509#
5510# If this is too high, and you enabled IDENT lookups from untrusted
5511# users, you might be susceptible to denial-of-service by having
5512# many ident requests going at once.
5513#Default:
5514# ident_timeout 10 seconds
5515
5516# TAG: shutdown_lifetime time-units
5517# When SIGTERM or SIGHUP is received, the cache is put into
5518# "shutdown pending" mode until all active sockets are closed.
5519# This value is the lifetime to set for all open descriptors
5520# during shutdown mode. Any active clients after this many
5521# seconds will receive a 'timeout' message.
5522#Default:
5523# shutdown_lifetime 30 seconds
5524
5525# ADMINISTRATIVE PARAMETERS
5526# -----------------------------------------------------------------------------
5527
5528# TAG: cache_mgr
5529# Email-address of local cache manager who will receive
5530# mail if the cache dies. The default is "webmaster".
5531#Default:
5532# cache_mgr webmaster
5533
5534# TAG: mail_from
5535# From: email-address for mail sent when the cache dies.
5536# The default is to use 'squid@unique_hostname'.
5537#
5538# See also: unique_hostname directive.
5539#Default:
5540# none
5541
5542# TAG: mail_program
5543# Email program used to send mail if the cache dies.
5544# The default is "mail". The specified program must comply
5545# with the standard Unix mail syntax:
5546# mail-program recipient < mailfile
5547#
5548# Optional command line options can be specified.
5549#Default:
5550# mail_program mail
5551
5552# TAG: cache_effective_user
5553# If you start Squid as root, it will change its effective/real
5554# UID/GID to the user specified below. The default is to change
5555# to UID of proxy.
5556# see also; cache_effective_group
5557#Default:
5558# cache_effective_user proxy
5559
5560# TAG: cache_effective_group
5561# Squid sets the GID to the effective user's default group ID
5562# (taken from the password file) and supplementary group list
5563# from the groups membership.
5564#
5565# If you want Squid to run with a specific GID regardless of
5566# the group memberships of the effective user then set this
5567# to the group (or GID) you want Squid to run as. When set
5568# all other group privileges of the effective user are ignored
5569# and only this GID is effective. If Squid is not started as
5570# root the user starting Squid MUST be member of the specified
5571# group.
5572#
5573# This option is not recommended by the Squid Team.
5574# Our preference is for administrators to configure a secure
5575# user account for squid with UID/GID matching system policies.
5576#Default:
5577# Use system group memberships of the cache_effective_user account
5578
5579# TAG: httpd_suppress_version_string on|off
5580# Suppress Squid version string info in HTTP headers and HTML error pages.
5581#Default:
5582# httpd_suppress_version_string off
5583
5584# TAG: visible_hostname
5585# If you want to present a special hostname in error messages, etc,
5586# define this. Otherwise, the return value of gethostname()
5587# will be used. If you have multiple caches in a cluster and
5588# get errors about IP-forwarding you must set them to have individual
5589# names with this setting.
5590#Default:
5591# Automatically detect the system host name
5592
5593# TAG: unique_hostname
5594# If you want to have multiple machines with the same
5595# 'visible_hostname' you must give each machine a different
5596# 'unique_hostname' so forwarding loops can be detected.
5597#Default:
5598# Copy the value from visible_hostname
5599
5600# TAG: hostname_aliases
5601# A list of other DNS names your cache has.
5602#Default:
5603# none
5604
5605# TAG: umask
5606# Minimum umask which should be enforced while the proxy
5607# is running, in addition to the umask set at startup.
5608#
5609# For a traditional octal representation of umasks, start
5610# your value with 0.
5611#Default:
5612# umask 027
5613
5614# OPTIONS FOR THE CACHE REGISTRATION SERVICE
5615# -----------------------------------------------------------------------------
5616#
5617# This section contains parameters for the (optional) cache
5618# announcement service. This service is provided to help
5619# cache administrators locate one another in order to join or
5620# create cache hierarchies.
5621#
5622# An 'announcement' message is sent (via UDP) to the registration
5623# service by Squid. By default, the announcement message is NOT
5624# SENT unless you enable it with 'announce_period' below.
5625#
5626# The announcement message includes your hostname, plus the
5627# following information from this configuration file:
5628#
5629# http_port
5630# icp_port
5631# cache_mgr
5632#
5633# All current information is processed regularly and made
5634# available on the Web at http://www.ircache.net/Cache/Tracker/.
5635
5636# TAG: announce_period
5637# This is how frequently to send cache announcements.
5638#
5639# To enable announcing your cache, just set an announce period.
5640#
5641# Example:
5642# announce_period 1 day
5643#Default:
5644# Announcement messages disabled.
5645
5646# TAG: announce_host
5647# Set the hostname where announce registration messages will be sent.
5648#
5649# See also announce_port and announce_file
5650#Default:
5651# announce_host tracker.ircache.net
5652
5653# TAG: announce_file
5654# The contents of this file will be included in the announce
5655# registration messages.
5656#Default:
5657# none
5658
5659# TAG: announce_port
5660# Set the port where announce registration messages will be sent.
5661#
5662# See also announce_host and announce_file
5663#Default:
5664# announce_port 3131
5665
5666# HTTPD-ACCELERATOR OPTIONS
5667# -----------------------------------------------------------------------------
5668
5669# TAG: httpd_accel_surrogate_id
5670# Surrogates (http://www.esi.org/architecture_spec_1.0.html)
5671# need an identification token to allow control targeting. Because
5672# a farm of surrogates may all perform the same tasks, they may share
5673# an identification token.
5674#Default:
5675# visible_hostname is used if no specific ID is set.
5676
5677# TAG: http_accel_surrogate_remote on|off
5678# Remote surrogates (such as those in a CDN) honour the header
5679# "Surrogate-Control: no-store-remote".
5680#
5681# Set this to on to have squid behave as a remote surrogate.
5682#Default:
5683# http_accel_surrogate_remote off
5684
5685# TAG: esi_parser libxml2|expat|custom
5686# ESI markup is not strictly XML compatible. The custom ESI parser
5687# will give higher performance, but cannot handle non ASCII character
5688# encodings.
5689#Default:
5690# esi_parser custom
5691
5692# DELAY POOL PARAMETERS
5693# -----------------------------------------------------------------------------
5694
5695# TAG: delay_pools
5696# This represents the number of delay pools to be used. For example,
5697# if you have one class 2 delay pool and one class 3 delays pool, you
5698# have a total of 2 delay pools.
5699#
5700# See also delay_parameters, delay_class, delay_access for pool
5701# configuration details.
5702#Default:
5703# delay_pools 0
5704
5705# TAG: delay_class
5706# This defines the class of each delay pool. There must be exactly one
5707# delay_class line for each delay pool. For example, to define two
5708# delay pools, one of class 2 and one of class 3, the settings above
5709# and here would be:
5710#
5711# Example:
5712# delay_pools 4 # 4 delay pools
5713# delay_class 1 2 # pool 1 is a class 2 pool
5714# delay_class 2 3 # pool 2 is a class 3 pool
5715# delay_class 3 4 # pool 3 is a class 4 pool
5716# delay_class 4 5 # pool 4 is a class 5 pool
5717#
5718# The delay pool classes are:
5719#
5720# class 1 Everything is limited by a single aggregate
5721# bucket.
5722#
5723# class 2 Everything is limited by a single aggregate
5724# bucket as well as an "individual" bucket chosen
5725# from bits 25 through 32 of the IPv4 address.
5726#
5727# class 3 Everything is limited by a single aggregate
5728# bucket as well as a "network" bucket chosen
5729# from bits 17 through 24 of the IP address and a
5730# "individual" bucket chosen from bits 17 through
5731# 32 of the IPv4 address.
5732#
5733# class 4 Everything in a class 3 delay pool, with an
5734# additional limit on a per user basis. This
5735# only takes effect if the username is established
5736# in advance - by forcing authentication in your
5737# http_access rules.
5738#
5739# class 5 Requests are grouped according their tag (see
5740# external_acl's tag= reply).
5741#
5742#
5743# Each pool also requires a delay_parameters directive to configure the pool size
5744# and speed limits used whenever the pool is applied to a request. Along with
5745# a set of delay_access directives to determine when it is used.
5746#
5747# NOTE: If an IP address is a.b.c.d
5748# -> bits 25 through 32 are "d"
5749# -> bits 17 through 24 are "c"
5750# -> bits 17 through 32 are "c * 256 + d"
5751#
5752# NOTE-2: Due to the use of bitmasks in class 2,3,4 pools they only apply to
5753# IPv4 traffic. Class 1 and 5 pools may be used with IPv6 traffic.
5754#
5755# This clause only supports fast acl types.
5756# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
5757#
5758# See also delay_parameters and delay_access.
5759#Default:
5760# none
5761
5762# TAG: delay_access
5763# This is used to determine which delay pool a request falls into.
5764#
5765# delay_access is sorted per pool and the matching starts with pool 1,
5766# then pool 2, ..., and finally pool N. The first delay pool where the
5767# request is allowed is selected for the request. If it does not allow
5768# the request to any pool then the request is not delayed (default).
5769#
5770# For example, if you want some_big_clients in delay
5771# pool 1 and lotsa_little_clients in delay pool 2:
5772#
5773# delay_access 1 allow some_big_clients
5774# delay_access 1 deny all
5775# delay_access 2 allow lotsa_little_clients
5776# delay_access 2 deny all
5777# delay_access 3 allow authenticated_clients
5778#
5779# See also delay_parameters and delay_class.
5780#
5781#Default:
5782# Deny using the pool, unless allow rules exist in squid.conf for the pool.
5783
5784# TAG: delay_parameters
5785# This defines the parameters for a delay pool. Each delay pool has
5786# a number of "buckets" associated with it, as explained in the
5787# description of delay_class.
5788#
5789# For a class 1 delay pool, the syntax is:
5790# delay_class pool 1
5791# delay_parameters pool aggregate
5792#
5793# For a class 2 delay pool:
5794# delay_class pool 2
5795# delay_parameters pool aggregate individual
5796#
5797# For a class 3 delay pool:
5798# delay_class pool 3
5799# delay_parameters pool aggregate network individual
5800#
5801# For a class 4 delay pool:
5802# delay_class pool 4
5803# delay_parameters pool aggregate network individual user
5804#
5805# For a class 5 delay pool:
5806# delay_class pool 5
5807# delay_parameters pool tagrate
5808#
5809# The option variables are:
5810#
5811# pool a pool number - ie, a number between 1 and the
5812# number specified in delay_pools as used in
5813# delay_class lines.
5814#
5815# aggregate the speed limit parameters for the aggregate bucket
5816# (class 1, 2, 3).
5817#
5818# individual the speed limit parameters for the individual
5819# buckets (class 2, 3).
5820#
5821# network the speed limit parameters for the network buckets
5822# (class 3).
5823#
5824# user the speed limit parameters for the user buckets
5825# (class 4).
5826#
5827# tagrate the speed limit parameters for the tag buckets
5828# (class 5).
5829#
5830# A pair of delay parameters is written restore/maximum, where restore is
5831# the number of bytes (not bits - modem and network speeds are usually
5832# quoted in bits) per second placed into the bucket, and maximum is the
5833# maximum number of bytes which can be in the bucket at any time.
5834#
5835# There must be one delay_parameters line for each delay pool.
5836#
5837#
5838# For example, if delay pool number 1 is a class 2 delay pool as in the
5839# above example, and is being used to strictly limit each host to 64Kbit/sec
5840# (plus overheads), with no overall limit, the line is:
5841#
5842# delay_parameters 1 none 8000/8000
5843#
5844# Note that 8 x 8K Byte/sec -> 64K bit/sec.
5845#
5846# Note that the word 'none' is used to represent no limit.
5847#
5848#
5849# And, if delay pool number 2 is a class 3 delay pool as in the above
5850# example, and you want to limit it to a total of 256Kbit/sec (strict limit)
5851# with each 8-bit network permitted 64Kbit/sec (strict limit) and each
5852# individual host permitted 4800bit/sec with a bucket maximum size of 64Kbits
5853# to permit a decent web page to be downloaded at a decent speed
5854# (if the network is not being limited due to overuse) but slow down
5855# large downloads more significantly:
5856#
5857# delay_parameters 2 32000/32000 8000/8000 600/8000
5858#
5859# Note that 8 x 32K Byte/sec -> 256K bit/sec.
5860# 8 x 8K Byte/sec -> 64K bit/sec.
5861# 8 x 600 Byte/sec -> 4800 bit/sec.
5862#
5863#
5864# Finally, for a class 4 delay pool as in the example - each user will
5865# be limited to 128Kbits/sec no matter how many workstations they are logged into.:
5866#
5867# delay_parameters 4 32000/32000 8000/8000 600/64000 16000/16000
5868#
5869#
5870# See also delay_class and delay_access.
5871#
5872#Default:
5873# none
5874
5875# TAG: delay_initial_bucket_level (percent, 0-100)
5876# The initial bucket percentage is used to determine how much is put
5877# in each bucket when squid starts, is reconfigured, or first notices
5878# a host accessing it (in class 2 and class 3, individual hosts and
5879# networks only have buckets associated with them once they have been
5880# "seen" by squid).
5881#Default:
5882# delay_initial_bucket_level 50
5883
5884# CLIENT DELAY POOL PARAMETERS
5885# -----------------------------------------------------------------------------
5886
5887# TAG: client_delay_pools
5888# This option specifies the number of client delay pools used. It must
5889# preceed other client_delay_* options.
5890#
5891# Example:
5892# client_delay_pools 2
5893#
5894# See also client_delay_parameters and client_delay_access.
5895#Default:
5896# client_delay_pools 0
5897
5898# TAG: client_delay_initial_bucket_level (percent, 0-no_limit)
5899# This option determines the initial bucket size as a percentage of
5900# max_bucket_size from client_delay_parameters. Buckets are created
5901# at the time of the "first" connection from the matching IP. Idle
5902# buckets are periodically deleted up.
5903#
5904# You can specify more than 100 percent but note that such "oversized"
5905# buckets are not refilled until their size goes down to max_bucket_size
5906# from client_delay_parameters.
5907#
5908# Example:
5909# client_delay_initial_bucket_level 50
5910#Default:
5911# client_delay_initial_bucket_level 50
5912
5913# TAG: client_delay_parameters
5914#
5915# This option configures client-side bandwidth limits using the
5916# following format:
5917#
5918# client_delay_parameters pool speed_limit max_bucket_size
5919#
5920# pool is an integer ID used for client_delay_access matching.
5921#
5922# speed_limit is bytes added to the bucket per second.
5923#
5924# max_bucket_size is the maximum size of a bucket, enforced after any
5925# speed_limit additions.
5926#
5927# Please see the delay_parameters option for more information and
5928# examples.
5929#
5930# Example:
5931# client_delay_parameters 1 1024 2048
5932# client_delay_parameters 2 51200 16384
5933#
5934# See also client_delay_access.
5935#
5936#Default:
5937# none
5938
5939# TAG: client_delay_access
5940# This option determines the client-side delay pool for the
5941# request:
5942#
5943# client_delay_access pool_ID allow|deny acl_name
5944#
5945# All client_delay_access options are checked in their pool ID
5946# order, starting with pool 1. The first checked pool with allowed
5947# request is selected for the request. If no ACL matches or there
5948# are no client_delay_access options, the request bandwidth is not
5949# limited.
5950#
5951# The ACL-selected pool is then used to find the
5952# client_delay_parameters for the request. Client-side pools are
5953# not used to aggregate clients. Clients are always aggregated
5954# based on their source IP addresses (one bucket per source IP).
5955#
5956# This clause only supports fast acl types.
5957# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
5958# Additionally, only the client TCP connection details are available.
5959# ACLs testing HTTP properties will not work.
5960#
5961# Please see delay_access for more examples.
5962#
5963# Example:
5964# client_delay_access 1 allow low_rate_network
5965# client_delay_access 2 allow vips_network
5966#
5967#
5968# See also client_delay_parameters and client_delay_pools.
5969#Default:
5970# Deny use of the pool, unless allow rules exist in squid.conf for the pool.
5971
5972# WCCPv1 AND WCCPv2 CONFIGURATION OPTIONS
5973# -----------------------------------------------------------------------------
5974
5975# TAG: wccp_router
5976# Use this option to define your WCCP ``home'' router for
5977# Squid.
5978#
5979# wccp_router supports a single WCCP(v1) router
5980#
5981# wccp2_router supports multiple WCCPv2 routers
5982#
5983# only one of the two may be used at the same time and defines
5984# which version of WCCP to use.
5985#Default:
5986# WCCP disabled.
5987
5988# TAG: wccp2_router
5989# Use this option to define your WCCP ``home'' router for
5990# Squid.
5991#
5992# wccp_router supports a single WCCP(v1) router
5993#
5994# wccp2_router supports multiple WCCPv2 routers
5995#
5996# only one of the two may be used at the same time and defines
5997# which version of WCCP to use.
5998#Default:
5999# WCCPv2 disabled.
6000
6001# TAG: wccp_version
6002# This directive is only relevant if you need to set up WCCP(v1)
6003# to some very old and end-of-life Cisco routers. In all other
6004# setups it must be left unset or at the default setting.
6005# It defines an internal version in the WCCP(v1) protocol,
6006# with version 4 being the officially documented protocol.
6007#
6008# According to some users, Cisco IOS 11.2 and earlier only
6009# support WCCP version 3. If you're using that or an earlier
6010# version of IOS, you may need to change this value to 3, otherwise
6011# do not specify this parameter.
6012#Default:
6013# wccp_version 4
6014
6015# TAG: wccp2_rebuild_wait
6016# If this is enabled Squid will wait for the cache dir rebuild to finish
6017# before sending the first wccp2 HereIAm packet
6018#Default:
6019# wccp2_rebuild_wait on
6020
6021# TAG: wccp2_forwarding_method
6022# WCCP2 allows the setting of forwarding methods between the
6023# router/switch and the cache. Valid values are as follows:
6024#
6025# gre - GRE encapsulation (forward the packet in a GRE/WCCP tunnel)
6026# l2 - L2 redirect (forward the packet using Layer 2/MAC rewriting)
6027#
6028# Currently (as of IOS 12.4) cisco routers only support GRE.
6029# Cisco switches only support the L2 redirect assignment method.
6030#Default:
6031# wccp2_forwarding_method gre
6032
6033# TAG: wccp2_return_method
6034# WCCP2 allows the setting of return methods between the
6035# router/switch and the cache for packets that the cache
6036# decides not to handle. Valid values are as follows:
6037#
6038# gre - GRE encapsulation (forward the packet in a GRE/WCCP tunnel)
6039# l2 - L2 redirect (forward the packet using Layer 2/MAC rewriting)
6040#
6041# Currently (as of IOS 12.4) cisco routers only support GRE.
6042# Cisco switches only support the L2 redirect assignment.
6043#
6044# If the "ip wccp redirect exclude in" command has been
6045# enabled on the cache interface, then it is still safe for
6046# the proxy server to use a l2 redirect method even if this
6047# option is set to GRE.
6048#Default:
6049# wccp2_return_method gre
6050
6051# TAG: wccp2_assignment_method
6052# WCCP2 allows the setting of methods to assign the WCCP hash
6053# Valid values are as follows:
6054#
6055# hash - Hash assignment
6056# mask - Mask assignment
6057#
6058# As a general rule, cisco routers support the hash assignment method
6059# and cisco switches support the mask assignment method.
6060#Default:
6061# wccp2_assignment_method hash
6062
6063# TAG: wccp2_service
6064# WCCP2 allows for multiple traffic services. There are two
6065# types: "standard" and "dynamic". The standard type defines
6066# one service id - http (id 0). The dynamic service ids can be from
6067# 51 to 255 inclusive. In order to use a dynamic service id
6068# one must define the type of traffic to be redirected; this is done
6069# using the wccp2_service_info option.
6070#
6071# The "standard" type does not require a wccp2_service_info option,
6072# just specifying the service id will suffice.
6073#
6074# MD5 service authentication can be enabled by adding
6075# "password=<password>" to the end of this service declaration.
6076#
6077# Examples:
6078#
6079# wccp2_service standard 0 # for the 'web-cache' standard service
6080# wccp2_service dynamic 80 # a dynamic service type which will be
6081# # fleshed out with subsequent options.
6082# wccp2_service standard 0 password=foo
6083#Default:
6084# Use the 'web-cache' standard service.
6085
6086# TAG: wccp2_service_info
6087# Dynamic WCCPv2 services require further information to define the
6088# traffic you wish to have diverted.
6089#
6090# The format is:
6091#
6092# wccp2_service_info <id> protocol=<protocol> flags=<flag>,<flag>..
6093# priority=<priority> ports=<port>,<port>..
6094#
6095# The relevant WCCPv2 flags:
6096# + src_ip_hash, dst_ip_hash
6097# + source_port_hash, dst_port_hash
6098# + src_ip_alt_hash, dst_ip_alt_hash
6099# + src_port_alt_hash, dst_port_alt_hash
6100# + ports_source
6101#
6102# The port list can be one to eight entries.
6103#
6104# Example:
6105#
6106# wccp2_service_info 80 protocol=tcp flags=src_ip_hash,ports_source
6107# priority=240 ports=80
6108#
6109# Note: the service id must have been defined by a previous
6110# 'wccp2_service dynamic <id>' entry.
6111#Default:
6112# none
6113
6114# TAG: wccp2_weight
6115# Each cache server gets assigned a set of the destination
6116# hash proportional to their weight.
6117#Default:
6118# wccp2_weight 10000
6119
6120# TAG: wccp_address
6121# Use this option if you require WCCPv2 to use a specific
6122# interface address.
6123#
6124# The default behavior is to not bind to any specific address.
6125#Default:
6126# Address selected by the operating system.
6127
6128# TAG: wccp2_address
6129# Use this option if you require WCCP to use a specific
6130# interface address.
6131#
6132# The default behavior is to not bind to any specific address.
6133#Default:
6134# Address selected by the operating system.
6135
6136# PERSISTENT CONNECTION HANDLING
6137# -----------------------------------------------------------------------------
6138#
6139# Also see "pconn_timeout" in the TIMEOUTS section
6140
6141# TAG: client_persistent_connections
6142# Persistent connection support for clients.
6143# Squid uses persistent connections (when allowed). You can use
6144# this option to disable persistent connections with clients.
6145#Default:
6146# client_persistent_connections on
6147
6148# TAG: server_persistent_connections
6149# Persistent connection support for servers.
6150# Squid uses persistent connections (when allowed). You can use
6151# this option to disable persistent connections with servers.
6152#Default:
6153# server_persistent_connections on
6154
6155# TAG: persistent_connection_after_error
6156# With this directive the use of persistent connections after
6157# HTTP errors can be disabled. Useful if you have clients
6158# who fail to handle errors on persistent connections proper.
6159#Default:
6160# persistent_connection_after_error on
6161
6162# TAG: detect_broken_pconn
6163# Some servers have been found to incorrectly signal the use
6164# of HTTP/1.0 persistent connections even on replies not
6165# compatible, causing significant delays. This server problem
6166# has mostly been seen on redirects.
6167#
6168# By enabling this directive Squid attempts to detect such
6169# broken replies and automatically assume the reply is finished
6170# after 10 seconds timeout.
6171#Default:
6172# detect_broken_pconn off
6173
6174# CACHE DIGEST OPTIONS
6175# -----------------------------------------------------------------------------
6176
6177# TAG: digest_generation
6178# This controls whether the server will generate a Cache Digest
6179# of its contents. By default, Cache Digest generation is
6180# enabled if Squid is compiled with --enable-cache-digests defined.
6181#Default:
6182# digest_generation on
6183
6184# TAG: digest_bits_per_entry
6185# This is the number of bits of the server's Cache Digest which
6186# will be associated with the Digest entry for a given HTTP
6187# Method and URL (public key) combination. The default is 5.
6188#Default:
6189# digest_bits_per_entry 5
6190
6191# TAG: digest_rebuild_period (seconds)
6192# This is the wait time between Cache Digest rebuilds.
6193#Default:
6194# digest_rebuild_period 1 hour
6195
6196# TAG: digest_rewrite_period (seconds)
6197# This is the wait time between Cache Digest writes to
6198# disk.
6199#Default:
6200# digest_rewrite_period 1 hour
6201
6202# TAG: digest_swapout_chunk_size (bytes)
6203# This is the number of bytes of the Cache Digest to write to
6204# disk at a time. It defaults to 4096 bytes (4KB), the Squid
6205# default swap page.
6206#Default:
6207# digest_swapout_chunk_size 4096 bytes
6208
6209# TAG: digest_rebuild_chunk_percentage (percent, 0-100)
6210# This is the percentage of the Cache Digest to be scanned at a
6211# time. By default it is set to 10% of the Cache Digest.
6212#Default:
6213# digest_rebuild_chunk_percentage 10
6214
6215# SNMP OPTIONS
6216# -----------------------------------------------------------------------------
6217
6218# TAG: snmp_port
6219# The port number where Squid listens for SNMP requests. To enable
6220# SNMP support set this to a suitable port number. Port number
6221# 3401 is often used for the Squid SNMP agent. By default it's
6222# set to "0" (disabled)
6223#
6224# Example:
6225# snmp_port 3401
6226#Default:
6227# SNMP disabled.
6228
6229# TAG: snmp_access
6230# Allowing or denying access to the SNMP port.
6231#
6232# All access to the agent is denied by default.
6233# usage:
6234#
6235# snmp_access allow|deny [!]aclname ...
6236#
6237# This clause only supports fast acl types.
6238# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
6239#
6240#Example:
6241# snmp_access allow snmppublic localhost
6242# snmp_access deny all
6243#Default:
6244# Deny, unless rules exist in squid.conf.
6245
6246# TAG: snmp_incoming_address
6247# Just like 'udp_incoming_address', but for the SNMP port.
6248#
6249# snmp_incoming_address is used for the SNMP socket receiving
6250# messages from SNMP agents.
6251#
6252# The default snmp_incoming_address is to listen on all
6253# available network interfaces.
6254#Default:
6255# Accept SNMP packets from all machine interfaces.
6256
6257# TAG: snmp_outgoing_address
6258# Just like 'udp_outgoing_address', but for the SNMP port.
6259#
6260# snmp_outgoing_address is used for SNMP packets returned to SNMP
6261# agents.
6262#
6263# If snmp_outgoing_address is not set it will use the same socket
6264# as snmp_incoming_address. Only change this if you want to have
6265# SNMP replies sent using another address than where this Squid
6266# listens for SNMP queries.
6267#
6268# NOTE, snmp_incoming_address and snmp_outgoing_address can not have
6269# the same value since they both use the same port.
6270#Default:
6271# Use snmp_incoming_address or an address selected by the operating system.
6272
6273# ICP OPTIONS
6274# -----------------------------------------------------------------------------
6275
6276# TAG: icp_port
6277# The port number where Squid sends and receives ICP queries to
6278# and from neighbor caches. The standard UDP port for ICP is 3130.
6279#
6280# Example:
6281# icp_port 3130
6282#Default:
6283# ICP disabled.
6284
6285# TAG: htcp_port
6286# The port number where Squid sends and receives HTCP queries to
6287# and from neighbor caches. To turn it on you want to set it to
6288# 4827.
6289#
6290# Example:
6291# htcp_port 4827
6292#Default:
6293# HTCP disabled.
6294
6295# TAG: log_icp_queries on|off
6296# If set, ICP queries are logged to access.log. You may wish
6297# do disable this if your ICP load is VERY high to speed things
6298# up or to simplify log analysis.
6299#Default:
6300# log_icp_queries on
6301
6302# TAG: udp_incoming_address
6303# udp_incoming_address is used for UDP packets received from other
6304# caches.
6305#
6306# The default behavior is to not bind to any specific address.
6307#
6308# Only change this if you want to have all UDP queries received on
6309# a specific interface/address.
6310#
6311# NOTE: udp_incoming_address is used by the ICP, HTCP, and DNS
6312# modules. Altering it will affect all of them in the same manner.
6313#
6314# see also; udp_outgoing_address
6315#
6316# NOTE, udp_incoming_address and udp_outgoing_address can not
6317# have the same value since they both use the same port.
6318#Default:
6319# Accept packets from all machine interfaces.
6320
6321# TAG: udp_outgoing_address
6322# udp_outgoing_address is used for UDP packets sent out to other
6323# caches.
6324#
6325# The default behavior is to not bind to any specific address.
6326#
6327# Instead it will use the same socket as udp_incoming_address.
6328# Only change this if you want to have UDP queries sent using another
6329# address than where this Squid listens for UDP queries from other
6330# caches.
6331#
6332# NOTE: udp_outgoing_address is used by the ICP, HTCP, and DNS
6333# modules. Altering it will affect all of them in the same manner.
6334#
6335# see also; udp_incoming_address
6336#
6337# NOTE, udp_incoming_address and udp_outgoing_address can not
6338# have the same value since they both use the same port.
6339#Default:
6340# Use udp_incoming_address or an address selected by the operating system.
6341
6342# TAG: icp_hit_stale on|off
6343# If you want to return ICP_HIT for stale cache objects, set this
6344# option to 'on'. If you have sibling relationships with caches
6345# in other administrative domains, this should be 'off'. If you only
6346# have sibling relationships with caches under your control,
6347# it is probably okay to set this to 'on'.
6348# If set to 'on', your siblings should use the option "allow-miss"
6349# on their cache_peer lines for connecting to you.
6350#Default:
6351# icp_hit_stale off
6352
6353# TAG: minimum_direct_hops
6354# If using the ICMP pinging stuff, do direct fetches for sites
6355# which are no more than this many hops away.
6356#Default:
6357# minimum_direct_hops 4
6358
6359# TAG: minimum_direct_rtt (msec)
6360# If using the ICMP pinging stuff, do direct fetches for sites
6361# which are no more than this many rtt milliseconds away.
6362#Default:
6363# minimum_direct_rtt 400
6364
6365# TAG: netdb_low
6366# The low water mark for the ICMP measurement database.
6367#
6368# Note: high watermark controlled by netdb_high directive.
6369#
6370# These watermarks are counts, not percents. The defaults are
6371# (low) 900 and (high) 1000. When the high water mark is
6372# reached, database entries will be deleted until the low
6373# mark is reached.
6374#Default:
6375# netdb_low 900
6376
6377# TAG: netdb_high
6378# The high water mark for the ICMP measurement database.
6379#
6380# Note: low watermark controlled by netdb_low directive.
6381#
6382# These watermarks are counts, not percents. The defaults are
6383# (low) 900 and (high) 1000. When the high water mark is
6384# reached, database entries will be deleted until the low
6385# mark is reached.
6386#Default:
6387# netdb_high 1000
6388
6389# TAG: netdb_ping_period
6390# The minimum period for measuring a site. There will be at
6391# least this much delay between successive pings to the same
6392# network. The default is five minutes.
6393#Default:
6394# netdb_ping_period 5 minutes
6395
6396# TAG: query_icmp on|off
6397# If you want to ask your peers to include ICMP data in their ICP
6398# replies, enable this option.
6399#
6400# If your peer has configured Squid (during compilation) with
6401# '--enable-icmp' that peer will send ICMP pings to origin server
6402# sites of the URLs it receives. If you enable this option the
6403# ICP replies from that peer will include the ICMP data (if available).
6404# Then, when choosing a parent cache, Squid will choose the parent with
6405# the minimal RTT to the origin server. When this happens, the
6406# hierarchy field of the access.log will be
6407# "CLOSEST_PARENT_MISS". This option is off by default.
6408#Default:
6409# query_icmp off
6410
6411# TAG: test_reachability on|off
6412# When this is 'on', ICP MISS replies will be ICP_MISS_NOFETCH
6413# instead of ICP_MISS if the target host is NOT in the ICMP
6414# database, or has a zero RTT.
6415#Default:
6416# test_reachability off
6417
6418# TAG: icp_query_timeout (msec)
6419# Normally Squid will automatically determine an optimal ICP
6420# query timeout value based on the round-trip-time of recent ICP
6421# queries. If you want to override the value determined by
6422# Squid, set this 'icp_query_timeout' to a non-zero value. This
6423# value is specified in MILLISECONDS, so, to use a 2-second
6424# timeout (the old default), you would write:
6425#
6426# icp_query_timeout 2000
6427#Default:
6428# Dynamic detection.
6429
6430# TAG: maximum_icp_query_timeout (msec)
6431# Normally the ICP query timeout is determined dynamically. But
6432# sometimes it can lead to very large values (say 5 seconds).
6433# Use this option to put an upper limit on the dynamic timeout
6434# value. Do NOT use this option to always use a fixed (instead
6435# of a dynamic) timeout value. To set a fixed timeout see the
6436# 'icp_query_timeout' directive.
6437#Default:
6438# maximum_icp_query_timeout 2000
6439
6440# TAG: minimum_icp_query_timeout (msec)
6441# Normally the ICP query timeout is determined dynamically. But
6442# sometimes it can lead to very small timeouts, even lower than
6443# the normal latency variance on your link due to traffic.
6444# Use this option to put an lower limit on the dynamic timeout
6445# value. Do NOT use this option to always use a fixed (instead
6446# of a dynamic) timeout value. To set a fixed timeout see the
6447# 'icp_query_timeout' directive.
6448#Default:
6449# minimum_icp_query_timeout 5
6450
6451# TAG: background_ping_rate time-units
6452# Controls how often the ICP pings are sent to siblings that
6453# have background-ping set.
6454#Default:
6455# background_ping_rate 10 seconds
6456
6457# MULTICAST ICP OPTIONS
6458# -----------------------------------------------------------------------------
6459
6460# TAG: mcast_groups
6461# This tag specifies a list of multicast groups which your server
6462# should join to receive multicasted ICP queries.
6463#
6464# NOTE! Be very careful what you put here! Be sure you
6465# understand the difference between an ICP _query_ and an ICP
6466# _reply_. This option is to be set only if you want to RECEIVE
6467# multicast queries. Do NOT set this option to SEND multicast
6468# ICP (use cache_peer for that). ICP replies are always sent via
6469# unicast, so this option does not affect whether or not you will
6470# receive replies from multicast group members.
6471#
6472# You must be very careful to NOT use a multicast address which
6473# is already in use by another group of caches.
6474#
6475# If you are unsure about multicast, please read the Multicast
6476# chapter in the Squid FAQ (http://www.squid-cache.org/FAQ/).
6477#
6478# Usage: mcast_groups 239.128.16.128 224.0.1.20
6479#
6480# By default, Squid doesn't listen on any multicast groups.
6481#Default:
6482# none
6483
6484# TAG: mcast_miss_addr
6485# Note: This option is only available if Squid is rebuilt with the
6486# -DMULTICAST_MISS_STREAM define
6487#
6488# If you enable this option, every "cache miss" URL will
6489# be sent out on the specified multicast address.
6490#
6491# Do not enable this option unless you are are absolutely
6492# certain you understand what you are doing.
6493#Default:
6494# disabled.
6495
6496# TAG: mcast_miss_ttl
6497# Note: This option is only available if Squid is rebuilt with the
6498# -DMULTICAST_MISS_STREAM define
6499#
6500# This is the time-to-live value for packets multicasted
6501# when multicasting off cache miss URLs is enabled. By
6502# default this is set to 'site scope', i.e. 16.
6503#Default:
6504# mcast_miss_ttl 16
6505
6506# TAG: mcast_miss_port
6507# Note: This option is only available if Squid is rebuilt with the
6508# -DMULTICAST_MISS_STREAM define
6509#
6510# This is the port number to be used in conjunction with
6511# 'mcast_miss_addr'.
6512#Default:
6513# mcast_miss_port 3135
6514
6515# TAG: mcast_miss_encode_key
6516# Note: This option is only available if Squid is rebuilt with the
6517# -DMULTICAST_MISS_STREAM define
6518#
6519# The URLs that are sent in the multicast miss stream are
6520# encrypted. This is the encryption key.
6521#Default:
6522# mcast_miss_encode_key XXXXXXXXXXXXXXXX
6523
6524# TAG: mcast_icp_query_timeout (msec)
6525# For multicast peers, Squid regularly sends out ICP "probes" to
6526# count how many other peers are listening on the given multicast
6527# address. This value specifies how long Squid should wait to
6528# count all the replies. The default is 2000 msec, or 2
6529# seconds.
6530#Default:
6531# mcast_icp_query_timeout 2000
6532
6533# INTERNAL ICON OPTIONS
6534# -----------------------------------------------------------------------------
6535
6536# TAG: icon_directory
6537# Where the icons are stored. These are normally kept in
6538# /usr/share/squid/icons
6539#Default:
6540# icon_directory /usr/share/squid/icons
6541
6542# TAG: global_internal_static
6543# This directive controls is Squid should intercept all requests for
6544# /squid-internal-static/ no matter which host the URL is requesting
6545# (default on setting), or if nothing special should be done for
6546# such URLs (off setting). The purpose of this directive is to make
6547# icons etc work better in complex cache hierarchies where it may
6548# not always be possible for all corners in the cache mesh to reach
6549# the server generating a directory listing.
6550#Default:
6551# global_internal_static on
6552
6553# TAG: short_icon_urls
6554# If this is enabled Squid will use short URLs for icons.
6555# If disabled it will revert to the old behavior of including
6556# it's own name and port in the URL.
6557#
6558# If you run a complex cache hierarchy with a mix of Squid and
6559# other proxies you may need to disable this directive.
6560#Default:
6561# short_icon_urls on
6562
6563# ERROR PAGE OPTIONS
6564# -----------------------------------------------------------------------------
6565
6566# TAG: error_directory
6567# If you wish to create your own versions of the default
6568# error files to customize them to suit your company copy
6569# the error/template files to another directory and point
6570# this tag at them.
6571#
6572# WARNING: This option will disable multi-language support
6573# on error pages if used.
6574#
6575# The squid developers are interested in making squid available in
6576# a wide variety of languages. If you are making translations for a
6577# language that Squid does not currently provide please consider
6578# contributing your translation back to the project.
6579# http://wiki.squid-cache.org/Translations
6580#
6581# The squid developers working on translations are happy to supply drop-in
6582# translated error files in exchange for any new language contributions.
6583#Default:
6584# Send error pages in the clients preferred language
6585
6586# TAG: error_default_language
6587# Set the default language which squid will send error pages in
6588# if no existing translation matches the clients language
6589# preferences.
6590#
6591# If unset (default) generic English will be used.
6592#
6593# The squid developers are interested in making squid available in
6594# a wide variety of languages. If you are interested in making
6595# translations for any language see the squid wiki for details.
6596# http://wiki.squid-cache.org/Translations
6597#Default:
6598# Generate English language pages.
6599
6600# TAG: error_log_languages
6601# Log to cache.log what languages users are attempting to
6602# auto-negotiate for translations.
6603#
6604# Successful negotiations are not logged. Only failures
6605# have meaning to indicate that Squid may need an upgrade
6606# of its error page translations.
6607#Default:
6608# error_log_languages on
6609
6610# TAG: err_page_stylesheet
6611# CSS Stylesheet to pattern the display of Squid default error pages.
6612#
6613# For information on CSS see http://www.w3.org/Style/CSS/
6614#Default:
6615# err_page_stylesheet /etc/squid/errorpage.css
6616
6617# TAG: err_html_text
6618# HTML text to include in error messages. Make this a "mailto"
6619# URL to your admin address, or maybe just a link to your
6620# organizations Web page.
6621#
6622# To include this in your error messages, you must rewrite
6623# the error template files (found in the "errors" directory).
6624# Wherever you want the 'err_html_text' line to appear,
6625# insert a %L tag in the error template file.
6626#Default:
6627# none
6628
6629# TAG: email_err_data on|off
6630# If enabled, information about the occurred error will be
6631# included in the mailto links of the ERR pages (if %W is set)
6632# so that the email body contains the data.
6633# Syntax is <A HREF="mailto:%w%W">%w</A>
6634#Default:
6635# email_err_data on
6636
6637# TAG: deny_info
6638# Usage: deny_info err_page_name acl
6639# or deny_info http://... acl
6640# or deny_info TCP_RESET acl
6641#
6642# This can be used to return a ERR_ page for requests which
6643# do not pass the 'http_access' rules. Squid remembers the last
6644# acl it evaluated in http_access, and if a 'deny_info' line exists
6645# for that ACL Squid returns a corresponding error page.
6646#
6647# The acl is typically the last acl on the http_access deny line which
6648# denied access. The exceptions to this rule are:
6649# - When Squid needs to request authentication credentials. It's then
6650# the first authentication related acl encountered
6651# - When none of the http_access lines matches. It's then the last
6652# acl processed on the last http_access line.
6653# - When the decision to deny access was made by an adaptation service,
6654# the acl name is the corresponding eCAP or ICAP service_name.
6655#
6656# NP: If providing your own custom error pages with error_directory
6657# you may also specify them by your custom file name:
6658# Example: deny_info ERR_CUSTOM_ACCESS_DENIED bad_guys
6659#
6660# By defaut Squid will send "403 Forbidden". A different 4xx or 5xx
6661# may be specified by prefixing the file name with the code and a colon.
6662# e.g. 404:ERR_CUSTOM_ACCESS_DENIED
6663#
6664# Alternatively you can tell Squid to reset the TCP connection
6665# by specifying TCP_RESET.
6666#
6667# Or you can specify an error URL or URL pattern. The browsers will
6668# get redirected to the specified URL after formatting tags have
6669# been replaced. Redirect will be done with 302 or 307 according to
6670# HTTP/1.1 specs. A different 3xx code may be specified by prefixing
6671# the URL. e.g. 303:http://example.com/
6672#
6673# URL FORMAT TAGS:
6674# %a - username (if available. Password NOT included)
6675# %B - FTP path URL
6676# %e - Error number
6677# %E - Error description
6678# %h - Squid hostname
6679# %H - Request domain name
6680# %i - Client IP Address
6681# %M - Request Method
6682# %o - Message result from external ACL helper
6683# %p - Request Port number
6684# %P - Request Protocol name
6685# %R - Request URL path
6686# %T - Timestamp in RFC 1123 format
6687# %U - Full canonical URL from client
6688# (HTTPS URLs terminate with *)
6689# %u - Full canonical URL from client
6690# %w - Admin email from squid.conf
6691# %x - Error name
6692# %% - Literal percent (%) code
6693#
6694#Default:
6695# none
6696
6697# OPTIONS INFLUENCING REQUEST FORWARDING
6698# -----------------------------------------------------------------------------
6699
6700# TAG: nonhierarchical_direct
6701# By default, Squid will send any non-hierarchical requests
6702# (not cacheable request type) direct to origin servers.
6703#
6704# When this is set to "off", Squid will prefer to send these
6705# requests to parents.
6706#
6707# Note that in most configurations, by turning this off you will only
6708# add latency to these request without any improvement in global hit
6709# ratio.
6710#
6711# This option only sets a preference. If the parent is unavailable a
6712# direct connection to the origin server may still be attempted. To
6713# completely prevent direct connections use never_direct.
6714#Default:
6715# nonhierarchical_direct on
6716
6717# TAG: prefer_direct
6718# Normally Squid tries to use parents for most requests. If you for some
6719# reason like it to first try going direct and only use a parent if
6720# going direct fails set this to on.
6721#
6722# By combining nonhierarchical_direct off and prefer_direct on you
6723# can set up Squid to use a parent as a backup path if going direct
6724# fails.
6725#
6726# Note: If you want Squid to use parents for all requests see
6727# the never_direct directive. prefer_direct only modifies how Squid
6728# acts on cacheable requests.
6729#Default:
6730# prefer_direct off
6731
6732# TAG: cache_miss_revalidate on|off
6733# RFC 7232 defines a conditional request mechanism to prevent
6734# response objects being unnecessarily transferred over the network.
6735# If that mechanism is used by the client and a cache MISS occurs
6736# it can prevent new cache entries being created.
6737#
6738# This option determines whether Squid on cache MISS will pass the
6739# client revalidation request to the server or tries to fetch new
6740# content for caching. It can be useful while the cache is mostly
6741# empty to more quickly have the cache populated by generating
6742# non-conditional GETs.
6743#
6744# When set to 'on' (default), Squid will pass all client If-* headers
6745# to the server. This permits server responses without a cacheable
6746# payload to be delivered and on MISS no new cache entry is created.
6747#
6748# When set to 'off' and if the request is cacheable, Squid will
6749# remove the clients If-Modified-Since and If-None-Match headers from
6750# the request sent to the server. This requests a 200 status response
6751# from the server to create a new cache entry with.
6752#Default:
6753# cache_miss_revalidate on
6754
6755# TAG: always_direct
6756# Usage: always_direct allow|deny [!]aclname ...
6757#
6758# Here you can use ACL elements to specify requests which should
6759# ALWAYS be forwarded by Squid to the origin servers without using
6760# any peers. For example, to always directly forward requests for
6761# local servers ignoring any parents or siblings you may have use
6762# something like:
6763#
6764# acl local-servers dstdomain my.domain.net
6765# always_direct allow local-servers
6766#
6767# To always forward FTP requests directly, use
6768#
6769# acl FTP proto FTP
6770# always_direct allow FTP
6771#
6772# NOTE: There is a similar, but opposite option named
6773# 'never_direct'. You need to be aware that "always_direct deny
6774# foo" is NOT the same thing as "never_direct allow foo". You
6775# may need to use a deny rule to exclude a more-specific case of
6776# some other rule. Example:
6777#
6778# acl local-external dstdomain external.foo.net
6779# acl local-servers dstdomain .foo.net
6780# always_direct deny local-external
6781# always_direct allow local-servers
6782#
6783# NOTE: If your goal is to make the client forward the request
6784# directly to the origin server bypassing Squid then this needs
6785# to be done in the client configuration. Squid configuration
6786# can only tell Squid how Squid should fetch the object.
6787#
6788# NOTE: This directive is not related to caching. The replies
6789# is cached as usual even if you use always_direct. To not cache
6790# the replies see the 'cache' directive.
6791#
6792# This clause supports both fast and slow acl types.
6793# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
6794#Default:
6795# Prevent any cache_peer being used for this request.
6796
6797# TAG: never_direct
6798# Usage: never_direct allow|deny [!]aclname ...
6799#
6800# never_direct is the opposite of always_direct. Please read
6801# the description for always_direct if you have not already.
6802#
6803# With 'never_direct' you can use ACL elements to specify
6804# requests which should NEVER be forwarded directly to origin
6805# servers. For example, to force the use of a proxy for all
6806# requests, except those in your local domain use something like:
6807#
6808# acl local-servers dstdomain .foo.net
6809# never_direct deny local-servers
6810# never_direct allow all
6811#
6812# or if Squid is inside a firewall and there are local intranet
6813# servers inside the firewall use something like:
6814#
6815# acl local-intranet dstdomain .foo.net
6816# acl local-external dstdomain external.foo.net
6817# always_direct deny local-external
6818# always_direct allow local-intranet
6819# never_direct allow all
6820#
6821# This clause supports both fast and slow acl types.
6822# See http://wiki.squid-cache.org/SquidFaq/SquidAcl for details.
6823#Default:
6824# Allow DNS results to be used for this request.
6825
6826# ADVANCED NETWORKING OPTIONS
6827# -----------------------------------------------------------------------------
6828
6829# TAG: incoming_udp_average
6830# Heavy voodoo here. I can't even believe you are reading this.
6831# Are you crazy? Don't even think about adjusting these unless
6832# you understand the algorithms in comm_select.c first!
6833#Default:
6834# incoming_udp_average 6
6835
6836# TAG: incoming_tcp_average
6837# Heavy voodoo here. I can't even believe you are reading this.
6838# Are you crazy? Don't even think about adjusting these unless
6839# you understand the algorithms in comm_select.c first!
6840#Default:
6841# incoming_tcp_average 4
6842
6843# TAG: incoming_dns_average
6844# Heavy voodoo here. I can't even believe you are reading this.
6845# Are you crazy? Don't even think about adjusting these unless
6846# you understand the algorithms in comm_select.c first!
6847#Default:
6848# incoming_dns_average 4
6849
6850# TAG: min_udp_poll_cnt
6851# Heavy voodoo here. I can't even believe you are reading this.
6852# Are you crazy? Don't even think about adjusting these unless
6853# you understand the algorithms in comm_select.c first!
6854#Default:
6855# min_udp_poll_cnt 8
6856
6857# TAG: min_dns_poll_cnt
6858# Heavy voodoo here. I can't even believe you are reading this.
6859# Are you crazy? Don't even think about adjusting these unless
6860# you understand the algorithms in comm_select.c first!
6861#Default:
6862# min_dns_poll_cnt 8
6863
6864# TAG: min_tcp_poll_cnt
6865# Heavy voodoo here. I can't even believe you are reading this.
6866# Are you crazy? Don't even think about adjusting these unless
6867# you understand the algorithms in comm_select.c first!
6868#Default:
6869# min_tcp_poll_cnt 8
6870
6871# TAG: accept_filter
6872# FreeBSD:
6873#
6874# The name of an accept(2) filter to install on Squid's
6875# listen socket(s). This feature is perhaps specific to
6876# FreeBSD and requires support in the kernel.
6877#
6878# The 'httpready' filter delays delivering new connections
6879# to Squid until a full HTTP request has been received.
6880# See the accf_http(9) man page for details.
6881#
6882# The 'dataready' filter delays delivering new connections
6883# to Squid until there is some data to process.
6884# See the accf_dataready(9) man page for details.
6885#
6886# Linux:
6887#
6888# The 'data' filter delays delivering of new connections
6889# to Squid until there is some data to process by TCP_ACCEPT_DEFER.
6890# You may optionally specify a number of seconds to wait by
6891# 'data=N' where N is the number of seconds. Defaults to 30
6892# if not specified. See the tcp(7) man page for details.
6893#EXAMPLE:
6894## FreeBSD
6895#accept_filter httpready
6896## Linux
6897#accept_filter data
6898#Default:
6899# none
6900
6901# TAG: client_ip_max_connections
6902# Set an absolute limit on the number of connections a single
6903# client IP can use. Any more than this and Squid will begin to drop
6904# new connections from the client until it closes some links.
6905#
6906# Note that this is a global limit. It affects all HTTP, HTCP, Gopher and FTP
6907# connections from the client. For finer control use the ACL access controls.
6908#
6909# Requires client_db to be enabled (the default).
6910#
6911# WARNING: This may noticably slow down traffic received via external proxies
6912# or NAT devices and cause them to rebound error messages back to their clients.
6913#Default:
6914# No limit.
6915
6916# TAG: tcp_recv_bufsize (bytes)
6917# Size of receive buffer to set for TCP sockets. Probably just
6918# as easy to change your kernel's default.
6919# Omit from squid.conf to use the default buffer size.
6920#Default:
6921# Use operating system TCP defaults.
6922
6923# ICAP OPTIONS
6924# -----------------------------------------------------------------------------
6925
6926# TAG: icap_enable on|off
6927# If you want to enable the ICAP module support, set this to on.
6928#Default:
6929# icap_enable off
6930
6931# TAG: icap_connect_timeout
6932# This parameter specifies how long to wait for the TCP connect to
6933# the requested ICAP server to complete before giving up and either
6934# terminating the HTTP transaction or bypassing the failure.
6935#
6936# The default for optional services is peer_connect_timeout.
6937# The default for essential services is connect_timeout.
6938# If this option is explicitly set, its value applies to all services.
6939#Default:
6940# none
6941
6942# TAG: icap_io_timeout time-units
6943# This parameter specifies how long to wait for an I/O activity on
6944# an established, active ICAP connection before giving up and
6945# either terminating the HTTP transaction or bypassing the
6946# failure.
6947#Default:
6948# Use read_timeout.
6949
6950# TAG: icap_service_failure_limit limit [in memory-depth time-units]
6951# The limit specifies the number of failures that Squid tolerates
6952# when establishing a new TCP connection with an ICAP service. If
6953# the number of failures exceeds the limit, the ICAP service is
6954# not used for new ICAP requests until it is time to refresh its
6955# OPTIONS.
6956#
6957# A negative value disables the limit. Without the limit, an ICAP
6958# service will not be considered down due to connectivity failures
6959# between ICAP OPTIONS requests.
6960#
6961# Squid forgets ICAP service failures older than the specified
6962# value of memory-depth. The memory fading algorithm
6963# is approximate because Squid does not remember individual
6964# errors but groups them instead, splitting the option
6965# value into ten time slots of equal length.
6966#
6967# When memory-depth is 0 and by default this option has no
6968# effect on service failure expiration.
6969#
6970# Squid always forgets failures when updating service settings
6971# using an ICAP OPTIONS transaction, regardless of this option
6972# setting.
6973#
6974# For example,
6975# # suspend service usage after 10 failures in 5 seconds:
6976# icap_service_failure_limit 10 in 5 seconds
6977#Default:
6978# icap_service_failure_limit 10
6979
6980# TAG: icap_service_revival_delay
6981# The delay specifies the number of seconds to wait after an ICAP
6982# OPTIONS request failure before requesting the options again. The
6983# failed ICAP service is considered "down" until fresh OPTIONS are
6984# fetched.
6985#
6986# The actual delay cannot be smaller than the hardcoded minimum
6987# delay of 30 seconds.
6988#Default:
6989# icap_service_revival_delay 180
6990
6991# TAG: icap_preview_enable on|off
6992# The ICAP Preview feature allows the ICAP server to handle the
6993# HTTP message by looking only at the beginning of the message body
6994# or even without receiving the body at all. In some environments,
6995# previews greatly speedup ICAP processing.
6996#
6997# During an ICAP OPTIONS transaction, the server may tell Squid what
6998# HTTP messages should be previewed and how big the preview should be.
6999# Squid will not use Preview if the server did not request one.
7000#
7001# To disable ICAP Preview for all ICAP services, regardless of
7002# individual ICAP server OPTIONS responses, set this option to "off".
7003#Example:
7004#icap_preview_enable off
7005#Default:
7006# icap_preview_enable on
7007
7008# TAG: icap_preview_size
7009# The default size of preview data to be sent to the ICAP server.
7010# This value might be overwritten on a per server basis by OPTIONS requests.
7011#Default:
7012# No preview sent.
7013
7014# TAG: icap_206_enable on|off
7015# 206 (Partial Content) responses is an ICAP extension that allows the
7016# ICAP agents to optionally combine adapted and original HTTP message
7017# content. The decision to combine is postponed until the end of the
7018# ICAP response. Squid supports Partial Content extension by default.
7019#
7020# Activation of the Partial Content extension is negotiated with each
7021# ICAP service during OPTIONS exchange. Most ICAP servers should handle
7022# negotation correctly even if they do not support the extension, but
7023# some might fail. To disable Partial Content support for all ICAP
7024# services and to avoid any negotiation, set this option to "off".
7025#
7026# Example:
7027# icap_206_enable off
7028#Default:
7029# icap_206_enable on
7030
7031# TAG: icap_default_options_ttl
7032# The default TTL value for ICAP OPTIONS responses that don't have
7033# an Options-TTL header.
7034#Default:
7035# icap_default_options_ttl 60
7036
7037# TAG: icap_persistent_connections on|off
7038# Whether or not Squid should use persistent connections to
7039# an ICAP server.
7040#Default:
7041# icap_persistent_connections on
7042
7043# TAG: adaptation_send_client_ip on|off
7044# If enabled, Squid shares HTTP client IP information with adaptation
7045# services. For ICAP, Squid adds the X-Client-IP header to ICAP requests.
7046# For eCAP, Squid sets the libecap::metaClientIp transaction option.
7047#
7048# See also: adaptation_uses_indirect_client
7049#Default:
7050# adaptation_send_client_ip off
7051
7052# TAG: adaptation_send_username on|off
7053# This sends authenticated HTTP client username (if available) to
7054# the adaptation service.
7055#
7056# For ICAP, the username value is encoded based on the
7057# icap_client_username_encode option and is sent using the header
7058# specified by the icap_client_username_header option.
7059#Default:
7060# adaptation_send_username off
7061
7062# TAG: icap_client_username_header
7063# ICAP request header name to use for adaptation_send_username.
7064#Default:
7065# icap_client_username_header X-Client-Username
7066
7067# TAG: icap_client_username_encode on|off
7068# Whether to base64 encode the authenticated client username.
7069#Default:
7070# icap_client_username_encode off
7071
7072# TAG: icap_service
7073# Defines a single ICAP service using the following format:
7074#
7075# icap_service id vectoring_point uri [option ...]
7076#
7077# id: ID
7078# an opaque identifier or name which is used to direct traffic to
7079# this specific service. Must be unique among all adaptation
7080# services in squid.conf.
7081#
7082# vectoring_point: reqmod_precache|reqmod_postcache|respmod_precache|respmod_postcache
7083# This specifies at which point of transaction processing the
7084# ICAP service should be activated. *_postcache vectoring points
7085# are not yet supported.
7086#
7087# uri: icap://servername:port/servicepath
7088# ICAP server and service location.
7089#
7090# ICAP does not allow a single service to handle both REQMOD and RESPMOD
7091# transactions. Squid does not enforce that requirement. You can specify
7092# services with the same service_url and different vectoring_points. You
7093# can even specify multiple identical services as long as their
7094# service_names differ.
7095#
7096# To activate a service, use the adaptation_access directive. To group
7097# services, use adaptation_service_chain and adaptation_service_set.
7098#
7099# Service options are separated by white space. ICAP services support
7100# the following name=value options:
7101#
7102# bypass=on|off|1|0
7103# If set to 'on' or '1', the ICAP service is treated as
7104# optional. If the service cannot be reached or malfunctions,
7105# Squid will try to ignore any errors and process the message as
7106# if the service was not enabled. No all ICAP errors can be
7107# bypassed. If set to 0, the ICAP service is treated as
7108# essential and all ICAP errors will result in an error page
7109# returned to the HTTP client.
7110#
7111# Bypass is off by default: services are treated as essential.
7112#
7113# routing=on|off|1|0
7114# If set to 'on' or '1', the ICAP service is allowed to
7115# dynamically change the current message adaptation plan by
7116# returning a chain of services to be used next. The services
7117# are specified using the X-Next-Services ICAP response header
7118# value, formatted as a comma-separated list of service names.
7119# Each named service should be configured in squid.conf. Other
7120# services are ignored. An empty X-Next-Services value results
7121# in an empty plan which ends the current adaptation.
7122#
7123# Dynamic adaptation plan may cross or cover multiple supported
7124# vectoring points in their natural processing order.
7125#
7126# Routing is not allowed by default: the ICAP X-Next-Services
7127# response header is ignored.
7128#
7129# ipv6=on|off
7130# Only has effect on split-stack systems. The default on those systems
7131# is to use IPv4-only connections. When set to 'on' this option will
7132# make Squid use IPv6-only connections to contact this ICAP service.
7133#
7134# on-overload=block|bypass|wait|force
7135# If the service Max-Connections limit has been reached, do
7136# one of the following for each new ICAP transaction:
7137# * block: send an HTTP error response to the client
7138# * bypass: ignore the "over-connected" ICAP service
7139# * wait: wait (in a FIFO queue) for an ICAP connection slot
7140# * force: proceed, ignoring the Max-Connections limit
7141#
7142# In SMP mode with N workers, each worker assumes the service
7143# connection limit is Max-Connections/N, even though not all
7144# workers may use a given service.
7145#
7146# The default value is "bypass" if service is bypassable,
7147# otherwise it is set to "wait".
7148#
7149#
7150# max-conn=number
7151# Use the given number as the Max-Connections limit, regardless
7152# of the Max-Connections value given by the service, if any.
7153#
7154# Older icap_service format without optional named parameters is
7155# deprecated but supported for backward compatibility.
7156#
7157#Example:
7158#icap_service svcBlocker reqmod_precache icap://icap1.mydomain.net:1344/reqmod bypass=0
7159#icap_service svcLogger reqmod_precache icap://icap2.mydomain.net:1344/respmod routing=on
7160#Default:
7161# none
7162
7163# TAG: icap_class
7164# This deprecated option was documented to define an ICAP service
7165# chain, even though it actually defined a set of similar, redundant
7166# services, and the chains were not supported.
7167#
7168# To define a set of redundant services, please use the
7169# adaptation_service_set directive. For service chains, use
7170# adaptation_service_chain.
7171#Default:
7172# none
7173
7174# TAG: icap_access
7175# This option is deprecated. Please use adaptation_access, which
7176# has the same ICAP functionality, but comes with better
7177# documentation, and eCAP support.
7178#Default:
7179# none
7180
7181# eCAP OPTIONS
7182# -----------------------------------------------------------------------------
7183
7184# TAG: ecap_enable on|off
7185# Controls whether eCAP support is enabled.
7186#Default:
7187# ecap_enable off
7188
7189# TAG: ecap_service
7190# Defines a single eCAP service
7191#
7192# ecap_service id vectoring_point uri [option ...]
7193#
7194# id: ID
7195# an opaque identifier or name which is used to direct traffic to
7196# this specific service. Must be unique among all adaptation
7197# services in squid.conf.
7198#
7199# vectoring_point: reqmod_precache|reqmod_postcache|respmod_precache|respmod_postcache
7200# This specifies at which point of transaction processing the
7201# eCAP service should be activated. *_postcache vectoring points
7202# are not yet supported.
7203#
7204# uri: ecap://vendor/service_name?custom&cgi=style&parameters=optional
7205# Squid uses the eCAP service URI to match this configuration
7206# line with one of the dynamically loaded services. Each loaded
7207# eCAP service must have a unique URI. Obtain the right URI from
7208# the service provider.
7209#
7210# To activate a service, use the adaptation_access directive. To group
7211# services, use adaptation_service_chain and adaptation_service_set.
7212#
7213# Service options are separated by white space. eCAP services support
7214# the following name=value options:
7215#
7216# bypass=on|off|1|0
7217# If set to 'on' or '1', the eCAP service is treated as optional.
7218# If the service cannot be reached or malfunctions, Squid will try
7219# to ignore any errors and process the message as if the service
7220# was not enabled. No all eCAP errors can be bypassed.
7221# If set to 'off' or '0', the eCAP service is treated as essential
7222# and all eCAP errors will result in an error page returned to the
7223# HTTP client.
7224#
7225# Bypass is off by default: services are treated as essential.
7226#
7227# routing=on|off|1|0
7228# If set to 'on' or '1', the eCAP service is allowed to
7229# dynamically change the current message adaptation plan by
7230# returning a chain of services to be used next.
7231#
7232# Dynamic adaptation plan may cross or cover multiple supported
7233# vectoring points in their natural processing order.
7234#
7235# Routing is not allowed by default.
7236#
7237# Older ecap_service format without optional named parameters is
7238# deprecated but supported for backward compatibility.
7239#
7240#
7241#Example:
7242#ecap_service s1 reqmod_precache ecap://filters.R.us/leakDetector?on_error=block bypass=off
7243#ecap_service s2 respmod_precache ecap://filters.R.us/virusFilter config=/etc/vf.cfg bypass=on
7244#Default:
7245# none
7246
7247# TAG: loadable_modules
7248# Instructs Squid to load the specified dynamic module(s) or activate
7249# preloaded module(s).
7250#Example:
7251#loadable_modules /usr/lib/MinimalAdapter.so
7252#Default:
7253# none
7254
7255# MESSAGE ADAPTATION OPTIONS
7256# -----------------------------------------------------------------------------
7257
7258# TAG: adaptation_service_set
7259#
7260# Configures an ordered set of similar, redundant services. This is
7261# useful when hot standby or backup adaptation servers are available.
7262#
7263# adaptation_service_set set_name service_name1 service_name2 ...
7264#
7265# The named services are used in the set declaration order. The first
7266# applicable adaptation service from the set is used first. The next
7267# applicable service is tried if and only if the transaction with the
7268# previous service fails and the message waiting to be adapted is still
7269# intact.
7270#
7271# When adaptation starts, broken services are ignored as if they were
7272# not a part of the set. A broken service is a down optional service.
7273#
7274# The services in a set must be attached to the same vectoring point
7275# (e.g., pre-cache) and use the same adaptation method (e.g., REQMOD).
7276#
7277# If all services in a set are optional then adaptation failures are
7278# bypassable. If all services in the set are essential, then a
7279# transaction failure with one service may still be retried using
7280# another service from the set, but when all services fail, the master
7281# transaction fails as well.
7282#
7283# A set may contain a mix of optional and essential services, but that
7284# is likely to lead to surprising results because broken services become
7285# ignored (see above), making previously bypassable failures fatal.
7286# Technically, it is the bypassability of the last failed service that
7287# matters.
7288#
7289# See also: adaptation_access adaptation_service_chain
7290#
7291#Example:
7292#adaptation_service_set svcBlocker urlFilterPrimary urlFilterBackup
7293#adaptation service_set svcLogger loggerLocal loggerRemote
7294#Default:
7295# none
7296
7297# TAG: adaptation_service_chain
7298#
7299# Configures a list of complementary services that will be applied
7300# one-by-one, forming an adaptation chain or pipeline. This is useful
7301# when Squid must perform different adaptations on the same message.
7302#
7303# adaptation_service_chain chain_name service_name1 svc_name2 ...
7304#
7305# The named services are used in the chain declaration order. The first
7306# applicable adaptation service from the chain is used first. The next
7307# applicable service is applied to the successful adaptation results of
7308# the previous service in the chain.
7309#
7310# When adaptation starts, broken services are ignored as if they were
7311# not a part of the chain. A broken service is a down optional service.
7312#
7313# Request satisfaction terminates the adaptation chain because Squid
7314# does not currently allow declaration of RESPMOD services at the
7315# "reqmod_precache" vectoring point (see icap_service or ecap_service).
7316#
7317# The services in a chain must be attached to the same vectoring point
7318# (e.g., pre-cache) and use the same adaptation method (e.g., REQMOD).
7319#
7320# A chain may contain a mix of optional and essential services. If an
7321# essential adaptation fails (or the failure cannot be bypassed for
7322# other reasons), the master transaction fails. Otherwise, the failure
7323# is bypassed as if the failed adaptation service was not in the chain.
7324#
7325# See also: adaptation_access adaptation_service_set
7326#
7327#Example:
7328#adaptation_service_chain svcRequest requestLogger urlFilter leakDetector
7329#Default:
7330# none
7331
7332# TAG: adaptation_access
7333# Sends an HTTP transaction to an ICAP or eCAP adaptation service.
7334#
7335# adaptation_access service_name allow|deny [!]aclname...
7336# adaptation_access set_name allow|deny [!]aclname...
7337#
7338# At each supported vectoring point, the adaptation_access
7339# statements are processed in the order they appear in this
7340# configuration file. Statements pointing to the following services
7341# are ignored (i.e., skipped without checking their ACL):
7342#
7343# - services serving different vectoring points
7344# - "broken-but-bypassable" services
7345# - "up" services configured to ignore such transactions
7346# (e.g., based on the ICAP Transfer-Ignore header).
7347#
7348# When a set_name is used, all services in the set are checked
7349# using the same rules, to find the first applicable one. See
7350# adaptation_service_set for details.
7351#
7352# If an access list is checked and there is a match, the
7353# processing stops: For an "allow" rule, the corresponding
7354# adaptation service is used for the transaction. For a "deny"
7355# rule, no adaptation service is activated.
7356#
7357# It is currently not possible to apply more than one adaptation
7358# service at the same vectoring point to the same HTTP transaction.
7359#
7360# See also: icap_service and ecap_service
7361#
7362#Example:
7363#adaptation_access service_1 allow all
7364#Default:
7365# Allow, unless rules exist in squid.conf.
7366
7367# TAG: adaptation_service_iteration_limit
7368# Limits the number of iterations allowed when applying adaptation
7369# services to a message. If your longest adaptation set or chain
7370# may have more than 16 services, increase the limit beyond its
7371# default value of 16. If detecting infinite iteration loops sooner
7372# is critical, make the iteration limit match the actual number
7373# of services in your longest adaptation set or chain.
7374#
7375# Infinite adaptation loops are most likely with routing services.
7376#
7377# See also: icap_service routing=1
7378#Default:
7379# adaptation_service_iteration_limit 16
7380
7381# TAG: adaptation_masterx_shared_names
7382# For each master transaction (i.e., the HTTP request and response
7383# sequence, including all related ICAP and eCAP exchanges), Squid
7384# maintains a table of metadata. The table entries are (name, value)
7385# pairs shared among eCAP and ICAP exchanges. The table is destroyed
7386# with the master transaction.
7387#
7388# This option specifies the table entry names that Squid must accept
7389# from and forward to the adaptation transactions.
7390#
7391# An ICAP REQMOD or RESPMOD transaction may set an entry in the
7392# shared table by returning an ICAP header field with a name
7393# specified in adaptation_masterx_shared_names.
7394#
7395# An eCAP REQMOD or RESPMOD transaction may set an entry in the
7396# shared table by implementing the libecap::visitEachOption() API
7397# to provide an option with a name specified in
7398# adaptation_masterx_shared_names.
7399#
7400# Squid will store and forward the set entry to subsequent adaptation
7401# transactions within the same master transaction scope.
7402#
7403# Only one shared entry name is supported at this time.
7404#
7405#Example:
7406## share authentication information among ICAP services
7407#adaptation_masterx_shared_names X-Subscriber-ID
7408#Default:
7409# none
7410
7411# TAG: adaptation_meta
7412# This option allows Squid administrator to add custom ICAP request
7413# headers or eCAP options to Squid ICAP requests or eCAP transactions.
7414# Use it to pass custom authentication tokens and other
7415# transaction-state related meta information to an ICAP/eCAP service.
7416#
7417# The addition of a meta header is ACL-driven:
7418# adaptation_meta name value [!]aclname ...
7419#
7420# Processing for a given header name stops after the first ACL list match.
7421# Thus, it is impossible to add two headers with the same name. If no ACL
7422# lists match for a given header name, no such header is added. For
7423# example:
7424#
7425# # do not debug transactions except for those that need debugging
7426# adaptation_meta X-Debug 1 needs_debugging
7427#
7428# # log all transactions except for those that must remain secret
7429# adaptation_meta X-Log 1 !keep_secret
7430#
7431# # mark transactions from users in the "G 1" group
7432# adaptation_meta X-Authenticated-Groups "G 1" authed_as_G1
7433#
7434# The "value" parameter may be a regular squid.conf token or a "double
7435# quoted string". Within the quoted string, use backslash (\) to escape
7436# any character, which is currently only useful for escaping backslashes
7437# and double quotes. For example,
7438# "this string has one backslash (\\) and two \"quotes\""
7439#
7440# Used adaptation_meta header values may be logged via %note
7441# logformat code. If multiple adaptation_meta headers with the same name
7442# are used during master transaction lifetime, the header values are
7443# logged in the order they were used and duplicate values are ignored
7444# (only the first repeated value will be logged).
7445#Default:
7446# none
7447
7448# TAG: icap_retry
7449# This ACL determines which retriable ICAP transactions are
7450# retried. Transactions that received a complete ICAP response
7451# and did not have to consume or produce HTTP bodies to receive
7452# that response are usually retriable.
7453#
7454# icap_retry allow|deny [!]aclname ...
7455#
7456# Squid automatically retries some ICAP I/O timeouts and errors
7457# due to persistent connection race conditions.
7458#
7459# See also: icap_retry_limit
7460#Default:
7461# icap_retry deny all
7462
7463# TAG: icap_retry_limit
7464# Limits the number of retries allowed.
7465#
7466# Communication errors due to persistent connection race
7467# conditions are unavoidable, automatically retried, and do not
7468# count against this limit.
7469#
7470# See also: icap_retry
7471#Default:
7472# No retries are allowed.
7473
7474# DNS OPTIONS
7475# -----------------------------------------------------------------------------
7476
7477# TAG: check_hostnames
7478# For security and stability reasons Squid can check
7479# hostnames for Internet standard RFC compliance. If you want
7480# Squid to perform these checks turn this directive on.
7481#Default:
7482# check_hostnames off
7483
7484# TAG: allow_underscore
7485# Underscore characters is not strictly allowed in Internet hostnames
7486# but nevertheless used by many sites. Set this to off if you want
7487# Squid to be strict about the standard.
7488# This check is performed only when check_hostnames is set to on.
7489#Default:
7490# allow_underscore on
7491
7492# TAG: dns_retransmit_interval
7493# Initial retransmit interval for DNS queries. The interval is
7494# doubled each time all configured DNS servers have been tried.
7495#Default:
7496# dns_retransmit_interval 5 seconds
7497
7498# TAG: dns_timeout
7499# DNS Query timeout. If no response is received to a DNS query
7500# within this time all DNS servers for the queried domain
7501# are assumed to be unavailable.
7502#Default:
7503# dns_timeout 30 seconds
7504
7505# TAG: dns_packet_max
7506# Maximum number of bytes packet size to advertise via EDNS.
7507# Set to "none" to disable EDNS large packet support.
7508#
7509# For legacy reasons DNS UDP replies will default to 512 bytes which
7510# is too small for many responses. EDNS provides a means for Squid to
7511# negotiate receiving larger responses back immediately without having
7512# to failover with repeat requests. Responses larger than this limit
7513# will retain the old behaviour of failover to TCP DNS.
7514#
7515# Squid has no real fixed limit internally, but allowing packet sizes
7516# over 1500 bytes requires network jumbogram support and is usually not
7517# necessary.
7518#
7519# WARNING: The RFC also indicates that some older resolvers will reply
7520# with failure of the whole request if the extension is added. Some
7521# resolvers have already been identified which will reply with mangled
7522# EDNS response on occasion. Usually in response to many-KB jumbogram
7523# sizes being advertised by Squid.
7524# Squid will currently treat these both as an unable-to-resolve domain
7525# even if it would be resolvable without EDNS.
7526#Default:
7527# EDNS disabled
7528
7529# TAG: dns_defnames on|off
7530# Normally the RES_DEFNAMES resolver option is disabled
7531# (see res_init(3)). This prevents caches in a hierarchy
7532# from interpreting single-component hostnames locally. To allow
7533# Squid to handle single-component names, enable this option.
7534#Default:
7535# Search for single-label domain names is disabled.
7536
7537# TAG: dns_multicast_local on|off
7538# When set to on, Squid sends multicast DNS lookups on the local
7539# network for domains ending in .local and .arpa.
7540# This enables local servers and devices to be contacted in an
7541# ad-hoc or zero-configuration network environment.
7542#Default:
7543# Search for .local and .arpa names is disabled.
7544
7545# TAG: dns_nameservers
7546# Use this if you want to specify a list of DNS name servers
7547# (IP addresses) to use instead of those given in your
7548# /etc/resolv.conf file.
7549#
7550# On Windows platforms, if no value is specified here or in
7551# the /etc/resolv.conf file, the list of DNS name servers are
7552# taken from the Windows registry, both static and dynamic DHCP
7553# configurations are supported.
7554#
7555# Example: dns_nameservers 10.0.0.1 192.172.0.4
7556#Default:
7557# Use operating system definitions
7558
7559# TAG: hosts_file
7560# Location of the host-local IP name-address associations
7561# database. Most Operating Systems have such a file on different
7562# default locations:
7563# - Un*X & Linux: /etc/hosts
7564# - Windows NT/2000: %SystemRoot%\system32\drivers\etc\hosts
7565# (%SystemRoot% value install default is c:\winnt)
7566# - Windows XP/2003: %SystemRoot%\system32\drivers\etc\hosts
7567# (%SystemRoot% value install default is c:\windows)
7568# - Windows 9x/Me: %windir%\hosts
7569# (%windir% value is usually c:\windows)
7570# - Cygwin: /etc/hosts
7571#
7572# The file contains newline-separated definitions, in the
7573# form ip_address_in_dotted_form name [name ...] names are
7574# whitespace-separated. Lines beginning with an hash (#)
7575# character are comments.
7576#
7577# The file is checked at startup and upon configuration.
7578# If set to 'none', it won't be checked.
7579# If append_domain is used, that domain will be added to
7580# domain-local (i.e. not containing any dot character) host
7581# definitions.
7582#Default:
7583# hosts_file /etc/hosts
7584
7585# TAG: append_domain
7586# Appends local domain name to hostnames without any dots in
7587# them. append_domain must begin with a period.
7588#
7589# Be warned there are now Internet names with no dots in
7590# them using only top-domain names, so setting this may
7591# cause some Internet sites to become unavailable.
7592#
7593#Example:
7594# append_domain .yourdomain.com
7595#Default:
7596# Use operating system definitions
7597
7598# TAG: ignore_unknown_nameservers
7599# By default Squid checks that DNS responses are received
7600# from the same IP addresses they are sent to. If they
7601# don't match, Squid ignores the response and writes a warning
7602# message to cache.log. You can allow responses from unknown
7603# nameservers by setting this option to 'off'.
7604#Default:
7605# ignore_unknown_nameservers on
7606
7607# TAG: dns_v4_first
7608# With the IPv6 Internet being as fast or faster than IPv4 Internet
7609# for most networks Squid prefers to contact websites over IPv6.
7610#
7611# This option reverses the order of preference to make Squid contact
7612# dual-stack websites over IPv4 first. Squid will still perform both
7613# IPv6 and IPv4 DNS lookups before connecting.
7614#
7615# WARNING:
7616# This option will restrict the situations under which IPv6
7617# connectivity is used (and tested), potentially hiding network
7618# problems which would otherwise be detected and warned about.
7619#Default:
7620# dns_v4_first off
7621
7622# TAG: ipcache_size (number of entries)
7623# Maximum number of DNS IP cache entries.
7624#Default:
7625# ipcache_size 1024
7626
7627# TAG: ipcache_low (percent)
7628#Default:
7629# ipcache_low 90
7630
7631# TAG: ipcache_high (percent)
7632# The size, low-, and high-water marks for the IP cache.
7633#Default:
7634# ipcache_high 95
7635
7636# TAG: fqdncache_size (number of entries)
7637# Maximum number of FQDN cache entries.
7638#Default:
7639# fqdncache_size 1024
7640
7641# MISCELLANEOUS
7642# -----------------------------------------------------------------------------
7643
7644# TAG: configuration_includes_quoted_values on|off
7645# If set, Squid will recognize each "quoted string" after a configuration
7646# directive as a single parameter. The quotes are stripped before the
7647# parameter value is interpreted or used.
7648# See "Values with spaces, quotes, and other special characters"
7649# section for more details.
7650#Default:
7651# configuration_includes_quoted_values off
7652
7653# TAG: memory_pools on|off
7654# If set, Squid will keep pools of allocated (but unused) memory
7655# available for future use. If memory is a premium on your
7656# system and you believe your malloc library outperforms Squid
7657# routines, disable this.
7658#Default:
7659# memory_pools on
7660
7661# TAG: memory_pools_limit (bytes)
7662# Used only with memory_pools on:
7663# memory_pools_limit 50 MB
7664#
7665# If set to a non-zero value, Squid will keep at most the specified
7666# limit of allocated (but unused) memory in memory pools. All free()
7667# requests that exceed this limit will be handled by your malloc
7668# library. Squid does not pre-allocate any memory, just safe-keeps
7669# objects that otherwise would be free()d. Thus, it is safe to set
7670# memory_pools_limit to a reasonably high value even if your
7671# configuration will use less memory.
7672#
7673# If set to none, Squid will keep all memory it can. That is, there
7674# will be no limit on the total amount of memory used for safe-keeping.
7675#
7676# To disable memory allocation optimization, do not set
7677# memory_pools_limit to 0 or none. Set memory_pools to "off" instead.
7678#
7679# An overhead for maintaining memory pools is not taken into account
7680# when the limit is checked. This overhead is close to four bytes per
7681# object kept. However, pools may actually _save_ memory because of
7682# reduced memory thrashing in your malloc library.
7683#Default:
7684# memory_pools_limit 5 MB
7685
7686# TAG: forwarded_for on|off|transparent|truncate|delete
7687# If set to "on", Squid will append your client's IP address
7688# in the HTTP requests it forwards. By default it looks like:
7689#
7690# X-Forwarded-For: 192.1.2.3
7691#
7692# If set to "off", it will appear as
7693#
7694# X-Forwarded-For: unknown
7695#
7696# If set to "transparent", Squid will not alter the
7697# X-Forwarded-For header in any way.
7698#
7699# If set to "delete", Squid will delete the entire
7700# X-Forwarded-For header.
7701#
7702# If set to "truncate", Squid will remove all existing
7703# X-Forwarded-For entries, and place the client IP as the sole entry.
7704#Default:
7705# forwarded_for on
7706
7707# TAG: cachemgr_passwd
7708# Specify passwords for cachemgr operations.
7709#
7710# Usage: cachemgr_passwd password action action ...
7711#
7712# Some valid actions are (see cache manager menu for a full list):
7713# 5min
7714# 60min
7715# asndb
7716# authenticator
7717# cbdata
7718# client_list
7719# comm_incoming
7720# config *
7721# counters
7722# delay
7723# digest_stats
7724# dns
7725# events
7726# filedescriptors
7727# fqdncache
7728# histograms
7729# http_headers
7730# info
7731# io
7732# ipcache
7733# mem
7734# menu
7735# netdb
7736# non_peers
7737# objects
7738# offline_toggle *
7739# pconn
7740# peer_select
7741# reconfigure *
7742# redirector
7743# refresh
7744# server_list
7745# shutdown *
7746# store_digest
7747# storedir
7748# utilization
7749# via_headers
7750# vm_objects
7751#
7752# * Indicates actions which will not be performed without a
7753# valid password, others can be performed if not listed here.
7754#
7755# To disable an action, set the password to "disable".
7756# To allow performing an action without a password, set the
7757# password to "none".
7758#
7759# Use the keyword "all" to set the same password for all actions.
7760#
7761#Example:
7762# cachemgr_passwd secret shutdown
7763# cachemgr_passwd lesssssssecret info stats/objects
7764# cachemgr_passwd disable all
7765#Default:
7766# No password. Actions which require password are denied.
7767
7768# TAG: client_db on|off
7769# If you want to disable collecting per-client statistics,
7770# turn off client_db here.
7771#Default:
7772# client_db on
7773
7774# TAG: refresh_all_ims on|off
7775# When you enable this option, squid will always check
7776# the origin server for an update when a client sends an
7777# If-Modified-Since request. Many browsers use IMS
7778# requests when the user requests a reload, and this
7779# ensures those clients receive the latest version.
7780#
7781# By default (off), squid may return a Not Modified response
7782# based on the age of the cached version.
7783#Default:
7784# refresh_all_ims off
7785
7786# TAG: reload_into_ims on|off
7787# When you enable this option, client no-cache or ``reload''
7788# requests will be changed to If-Modified-Since requests.
7789# Doing this VIOLATES the HTTP standard. Enabling this
7790# feature could make you liable for problems which it
7791# causes.
7792#
7793# see also refresh_pattern for a more selective approach.
7794#Default:
7795# reload_into_ims off
7796
7797# TAG: connect_retries
7798# This sets the maximum number of connection attempts made for each
7799# TCP connection. The connect_retries attempts must all still
7800# complete within the connection timeout period.
7801#
7802# The default is not to re-try if the first connection attempt fails.
7803# The (not recommended) maximum is 10 tries.
7804#
7805# A warning message will be generated if it is set to a too-high
7806# value and the configured value will be over-ridden.
7807#
7808# Note: These re-tries are in addition to forward_max_tries
7809# which limit how many different addresses may be tried to find
7810# a useful server.
7811#Default:
7812# Do not retry failed connections.
7813
7814# TAG: retry_on_error
7815# If set to ON Squid will automatically retry requests when
7816# receiving an error response with status 403 (Forbidden),
7817# 500 (Internal Error), 501 or 503 (Service not available).
7818# Status 502 and 504 (Gateway errors) are always retried.
7819#
7820# This is mainly useful if you are in a complex cache hierarchy to
7821# work around access control errors.
7822#
7823# NOTE: This retry will attempt to find another working destination.
7824# Which is different from the server which just failed.
7825#Default:
7826# retry_on_error off
7827
7828# TAG: as_whois_server
7829# WHOIS server to query for AS numbers. NOTE: AS numbers are
7830# queried only when Squid starts up, not for every request.
7831#Default:
7832# as_whois_server whois.ra.net
7833
7834# TAG: offline_mode
7835# Enable this option and Squid will never try to validate cached
7836# objects.
7837#Default:
7838# offline_mode off
7839
7840# TAG: uri_whitespace
7841# What to do with requests that have whitespace characters in the
7842# URI. Options:
7843#
7844# strip: The whitespace characters are stripped out of the URL.
7845# This is the behavior recommended by RFC2396 and RFC3986
7846# for tolerant handling of generic URI.
7847# NOTE: This is one difference between generic URI and HTTP URLs.
7848#
7849# deny: The request is denied. The user receives an "Invalid
7850# Request" message.
7851# This is the behaviour recommended by RFC2616 for safe
7852# handling of HTTP request URL.
7853#
7854# allow: The request is allowed and the URI is not changed. The
7855# whitespace characters remain in the URI. Note the
7856# whitespace is passed to redirector processes if they
7857# are in use.
7858# Note this may be considered a violation of RFC2616
7859# request parsing where whitespace is prohibited in the
7860# URL field.
7861#
7862# encode: The request is allowed and the whitespace characters are
7863# encoded according to RFC1738.
7864#
7865# chop: The request is allowed and the URI is chopped at the
7866# first whitespace.
7867#
7868#
7869# NOTE the current Squid implementation of encode and chop violates
7870# RFC2616 by not using a 301 redirect after altering the URL.
7871#Default:
7872# uri_whitespace strip
7873
7874# TAG: chroot
7875# Specifies a directory where Squid should do a chroot() while
7876# initializing. This also causes Squid to fully drop root
7877# privileges after initializing. This means, for example, if you
7878# use a HTTP port less than 1024 and try to reconfigure, you may
7879# get an error saying that Squid can not open the port.
7880#Default:
7881# none
7882
7883# TAG: balance_on_multiple_ip
7884# Modern IP resolvers in squid sort lookup results by preferred access.
7885# By default squid will use these IP in order and only rotates to
7886# the next listed when the most preffered fails.
7887#
7888# Some load balancing servers based on round robin DNS have been
7889# found not to preserve user session state across requests
7890# to different IP addresses.
7891#
7892# Enabling this directive Squid rotates IP's per request.
7893#Default:
7894# balance_on_multiple_ip off
7895
7896# TAG: pipeline_prefetch
7897# HTTP clients may send a pipeline of 1+N requests to Squid using a
7898# single connection, without waiting for Squid to respond to the first
7899# of those requests. This option limits the number of concurrent
7900# requests Squid will try to handle in parallel. If set to N, Squid
7901# will try to receive and process up to 1+N requests on the same
7902# connection concurrently.
7903#
7904# Defaults to 0 (off) for bandwidth management and access logging
7905# reasons.
7906#
7907# NOTE: pipelining requires persistent connections to clients.
7908#
7909# WARNING: pipelining breaks NTLM and Negotiate/Kerberos authentication.
7910#Default:
7911# Do not pre-parse pipelined requests.
7912
7913# TAG: high_response_time_warning (msec)
7914# If the one-minute median response time exceeds this value,
7915# Squid prints a WARNING with debug level 0 to get the
7916# administrators attention. The value is in milliseconds.
7917#Default:
7918# disabled.
7919
7920# TAG: high_page_fault_warning
7921# If the one-minute average page fault rate exceeds this
7922# value, Squid prints a WARNING with debug level 0 to get
7923# the administrators attention. The value is in page faults
7924# per second.
7925#Default:
7926# disabled.
7927
7928# TAG: high_memory_warning
7929# Note: This option is only available if Squid is rebuilt with the
7930# GNU Malloc with mstats()
7931#
7932# If the memory usage (as determined by gnumalloc, if available and used)
7933# exceeds this amount, Squid prints a WARNING with debug level 0 to get
7934# the administrators attention.
7935#Default:
7936# disabled.
7937
7938# TAG: sleep_after_fork (microseconds)
7939# When this is set to a non-zero value, the main Squid process
7940# sleeps the specified number of microseconds after a fork()
7941# system call. This sleep may help the situation where your
7942# system reports fork() failures due to lack of (virtual)
7943# memory. Note, however, if you have a lot of child
7944# processes, these sleep delays will add up and your
7945# Squid will not service requests for some amount of time
7946# until all the child processes have been started.
7947# On Windows value less then 1000 (1 milliseconds) are
7948# rounded to 1000.
7949#Default:
7950# sleep_after_fork 0
7951
7952# TAG: windows_ipaddrchangemonitor on|off
7953# Note: This option is only available if Squid is rebuilt with the
7954# MS Windows
7955#
7956# On Windows Squid by default will monitor IP address changes and will
7957# reconfigure itself after any detected event. This is very useful for
7958# proxies connected to internet with dial-up interfaces.
7959# In some cases (a Proxy server acting as VPN gateway is one) it could be
7960# desiderable to disable this behaviour setting this to 'off'.
7961# Note: after changing this, Squid service must be restarted.
7962#Default:
7963# windows_ipaddrchangemonitor on
7964
7965# TAG: eui_lookup
7966# Whether to lookup the EUI or MAC address of a connected client.
7967#Default:
7968# eui_lookup on
7969
7970# TAG: max_filedescriptors
7971# Reduce the maximum number of filedescriptors supported below
7972# the usual operating system defaults.
7973#
7974# Remove from squid.conf to inherit the current ulimit setting.
7975#
7976# Note: Changing this requires a restart of Squid. Also
7977# not all I/O types supports large values (eg on Windows).
7978#Default:
7979# Use operating system limits set by ulimit.
diff --git a/tools/tinderbox_build b/tools/tinderbox_build
index 48836b1e..1a41f577 100755
--- a/tools/tinderbox_build
+++ b/tools/tinderbox_build
@@ -138,7 +138,7 @@ sub BuildIt {
138# interprets that as the end of the mail, and truncates the log before 138# interprets that as the end of the mail, and truncates the log before
139# it gets to Tinderbox. (terry weismann, chris yeh) 139# it gets to Tinderbox. (terry weismann, chris yeh)
140# 140#
141# This was replaced by a perl 'port' of the above, writen by 141# This was replaced by a perl 'port' of the above, written by
142# preed@netscape.com; good things: no need for system() call, and now it's 142# preed@netscape.com; good things: no need for system() call, and now it's
143# all in perl, so we don't have to do OS checking like before. 143# all in perl, so we don't have to do OS checking like before.
144 144
diff --git a/tools/update-thanks b/tools/update-thanks
index 27932f94..b0321e32 100755
--- a/tools/update-thanks
+++ b/tools/update-thanks
@@ -34,7 +34,7 @@ git log --pretty='%an' "$since.." | sort -u | while read first last rest
34do 34do
35 if [ -n "$first" -a -n "$last" -a -z "$rest" ] 35 if [ -n "$first" -a -n "$last" -a -z "$rest" ]
36 then 36 then
37 if ! grep -q "^$first $last$" AUTHORS THANKS.in 37 if ! grep -q -i "^$first $last$" AUTHORS THANKS.in
38 then 38 then
39 echo "$first $last" >> THANKS.in 39 echo "$first $last" >> THANKS.in
40 fi 40 fi