gsasl-1.8.1/ 0000755 0000000 0000000 00000000000 13521017733 007603 5 0000000 0000000 gsasl-1.8.1/gtk-doc.make 0000644 0000000 0000000 00000025040 13521000261 011677 0000000 0000000 # -*- mode: makefile -*-
#
# gtk-doc.make - make rules for gtk-doc
# Copyright (C) 2003 James Henstridge
# 2004-2007 Damon Chaplin
# 2007-2017 Stefan Sauer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
####################################
# Everything below here is generic #
####################################
if GTK_DOC_USE_LIBTOOL
GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
GTKDOC_RUN = $(LIBTOOL) --mode=execute
else
GTKDOC_CC = $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
GTKDOC_LD = $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS)
GTKDOC_RUN =
endif
# We set GPATH here; this gives us semantics for GNU make
# which are more like other make's VPATH, when it comes to
# whether a source that is a target of one rule is then
# searched for in VPATH/GPATH.
#
GPATH = $(srcdir)
TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
SETUP_FILES = \
$(content_files) \
$(expand_content_files) \
$(DOC_MAIN_SGML_FILE) \
$(DOC_MODULE)-sections.txt \
$(DOC_MODULE)-overrides.txt
EXTRA_DIST = \
$(HTML_IMAGES) \
$(SETUP_FILES)
DOC_STAMPS=setup-build.stamp scan-build.stamp sgml-build.stamp \
html-build.stamp pdf-build.stamp \
sgml.stamp html.stamp pdf.stamp
SCANOBJ_FILES = \
$(DOC_MODULE).args \
$(DOC_MODULE).hierarchy \
$(DOC_MODULE).interfaces \
$(DOC_MODULE).prerequisites \
$(DOC_MODULE).signals
REPORT_FILES = \
$(DOC_MODULE)-undocumented.txt \
$(DOC_MODULE)-undeclared.txt \
$(DOC_MODULE)-unused.txt
gtkdoc-check.test: Makefile
$(AM_V_GEN)echo "#!/bin/sh -e" > $@; \
echo "$(GTKDOC_CHECK_PATH) || exit 1" >> $@; \
chmod +x $@
CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) gtkdoc-check.test
if GTK_DOC_BUILD_HTML
HTML_BUILD_STAMP=html-build.stamp
else
HTML_BUILD_STAMP=
endif
if GTK_DOC_BUILD_PDF
PDF_BUILD_STAMP=pdf-build.stamp
else
PDF_BUILD_STAMP=
endif
all-gtk-doc: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
.PHONY: all-gtk-doc
if ENABLE_GTK_DOC
all-local: all-gtk-doc
endif
docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP)
$(REPORT_FILES): sgml-build.stamp
#### setup ####
GTK_DOC_V_SETUP=$(GTK_DOC_V_SETUP_@AM_V@)
GTK_DOC_V_SETUP_=$(GTK_DOC_V_SETUP_@AM_DEFAULT_V@)
GTK_DOC_V_SETUP_0=@echo " DOC Preparing build";
setup-build.stamp:
-$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \
if test "x$$files" != "x" ; then \
for file in $$files ; do \
destdir=`dirname $(abs_builddir)/$$file`; \
test -d "$$destdir" || mkdir -p "$$destdir"; \
test -f $(abs_srcdir)/$$file && \
cp -pf $(abs_srcdir)/$$file $(abs_builddir)/$$file || true; \
done; \
fi; \
fi
$(AM_V_at)touch setup-build.stamp
#### scan ####
GTK_DOC_V_SCAN=$(GTK_DOC_V_SCAN_@AM_V@)
GTK_DOC_V_SCAN_=$(GTK_DOC_V_SCAN_@AM_DEFAULT_V@)
GTK_DOC_V_SCAN_0=@echo " DOC Scanning header files";
GTK_DOC_V_INTROSPECT=$(GTK_DOC_V_INTROSPECT_@AM_V@)
GTK_DOC_V_INTROSPECT_=$(GTK_DOC_V_INTROSPECT_@AM_DEFAULT_V@)
GTK_DOC_V_INTROSPECT_0=@echo " DOC Introspecting gobjects";
scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB)
$(GTK_DOC_V_SCAN)_source_dir='' ; \
for i in $(DOC_SOURCE_DIR) ; do \
_source_dir="$${_source_dir} --source-dir=$$i" ; \
done ; \
gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES)
$(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \
scanobj_options=""; \
gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \
if test "$$?" = "0"; then \
if test "x$(V)" = "x1"; then \
scanobj_options="--verbose"; \
fi; \
fi; \
CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" \
gtkdoc-scangobj $(SCANGOBJ_OPTIONS) $$scanobj_options --module=$(DOC_MODULE); \
else \
for i in $(SCANOBJ_FILES) ; do \
test -f $$i || touch $$i ; \
done \
fi
$(AM_V_at)touch scan-build.stamp
$(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp
@true
#### xml ####
GTK_DOC_V_XML=$(GTK_DOC_V_XML_@AM_V@)
GTK_DOC_V_XML_=$(GTK_DOC_V_XML_@AM_DEFAULT_V@)
GTK_DOC_V_XML_0=@echo " DOC Building XML";
sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(HFILE_GLOB) $(CFILE_GLOB) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files) xml/gtkdocentities.ent
$(GTK_DOC_V_XML)_source_dir='' ; \
for i in $(DOC_SOURCE_DIR) ; do \
_source_dir="$${_source_dir} --source-dir=$$i" ; \
done ; \
gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS)
$(AM_V_at)touch sgml-build.stamp
sgml.stamp: sgml-build.stamp
@true
$(DOC_MAIN_SGML_FILE): sgml-build.stamp
@true
xml/gtkdocentities.ent: Makefile
$(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \
echo ""; \
echo ""; \
echo ""; \
echo ""; \
echo ""; \
echo ""; \
echo ""; \
) > $@
#### html ####
GTK_DOC_V_HTML=$(GTK_DOC_V_HTML_@AM_V@)
GTK_DOC_V_HTML_=$(GTK_DOC_V_HTML_@AM_DEFAULT_V@)
GTK_DOC_V_HTML_0=@echo " DOC Building HTML";
GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_@AM_V@)
GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_@AM_DEFAULT_V@)
GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references";
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
$(GTK_DOC_V_HTML)rm -rf html && mkdir html && \
mkhtml_options=""; \
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \
if test "$$?" = "0"; then \
if test "x$(V)" = "x1"; then \
mkhtml_options="$$mkhtml_options --verbose"; \
fi; \
fi; \
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \
if test "$$?" = "0"; then \
mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \
fi; \
cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
-@test "x$(HTML_IMAGES)" = "x" || \
for file in $(HTML_IMAGES) ; do \
test -f $(abs_srcdir)/$$file && cp $(abs_srcdir)/$$file $(abs_builddir)/html; \
test -f $(abs_builddir)/$$file && cp $(abs_builddir)/$$file $(abs_builddir)/html; \
test -f $$file && cp $$file $(abs_builddir)/html; \
done;
$(GTK_DOC_V_XREF)gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS)
$(AM_V_at)touch html-build.stamp
#### pdf ####
GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_@AM_V@)
GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_@AM_DEFAULT_V@)
GTK_DOC_V_PDF_0=@echo " DOC Building PDF";
pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
$(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \
mkpdf_options=""; \
gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \
if test "$$?" = "0"; then \
if test "x$(V)" = "x1"; then \
mkpdf_options="$$mkpdf_options --verbose"; \
fi; \
fi; \
if test "x$(HTML_IMAGES)" != "x"; then \
for img in $(HTML_IMAGES); do \
part=`dirname $$img`; \
echo $$mkpdf_options | grep >/dev/null "\-\-imgdir=$$part "; \
if test $$? != 0; then \
mkpdf_options="$$mkpdf_options --imgdir=$$part"; \
fi; \
done; \
fi; \
gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS)
$(AM_V_at)touch pdf-build.stamp
##############
clean-local:
@rm -f *~ *.bak
@rm -rf .libs
@if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \
rm -f $(DOC_MODULE).types; \
fi
@if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \
rm -f $(DOC_MODULE)-sections.txt; \
fi
distclean-local:
@rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \
$(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
rm -f $(SETUP_FILES) $(DOC_MODULE).types; \
fi
maintainer-clean-local:
@rm -rf xml html
install-data-local:
@installfiles=`echo $(builddir)/html/*`; \
if test "$$installfiles" = '$(builddir)/html/*'; \
then echo 1>&2 'Nothing to install' ; \
else \
if test -n "$(DOC_MODULE_VERSION)"; then \
installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
else \
installdir="$(DESTDIR)$(TARGET_DIR)"; \
fi; \
$(mkinstalldirs) $${installdir} ; \
for i in $$installfiles; do \
echo ' $(INSTALL_DATA) '$$i ; \
$(INSTALL_DATA) $$i $${installdir}; \
done; \
if test -n "$(DOC_MODULE_VERSION)"; then \
mv -f $${installdir}/$(DOC_MODULE).devhelp2 \
$${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \
fi; \
$(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \
fi
uninstall-local:
@if test -n "$(DOC_MODULE_VERSION)"; then \
installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \
else \
installdir="$(DESTDIR)$(TARGET_DIR)"; \
fi; \
rm -rf $${installdir}
#
# Require gtk-doc when making dist
#
if HAVE_GTK_DOC
dist-check-gtkdoc: docs
else
dist-check-gtkdoc:
@echo "*** gtk-doc is needed to run 'make dist'. ***"
@echo "*** gtk-doc was not found when 'configure' ran. ***"
@echo "*** please install gtk-doc and rerun 'configure'. ***"
@false
endif
dist-hook: dist-check-gtkdoc all-gtk-doc dist-hook-local
@mkdir $(distdir)/html
@cp ./html/* $(distdir)/html
@-cp ./$(DOC_MODULE).pdf $(distdir)/
@-cp ./$(DOC_MODULE).types $(distdir)/
@-cp ./$(DOC_MODULE)-sections.txt $(distdir)/
@cd $(distdir) && rm -f $(DISTCLEANFILES)
@$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html
.PHONY : dist-hook-local docs
gsasl-1.8.1/gl/ 0000755 0000000 0000000 00000000000 13521017732 010204 5 0000000 0000000 gsasl-1.8.1/gl/sys_stat.in.h 0000644 0000000 0000000 00000054142 13516251577 012574 0000000 0000000 /* Provide a more complete sys/stat.h header file.
Copyright (C) 2005-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
/* This file is supposed to be used on platforms where is
incomplete. It is intended to provide definitions and prototypes
needed by an application. Start with what the system provides. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
#if defined __need_system_sys_stat_h
/* Special invocation convention. */
#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
#else
/* Normal invocation convention. */
#ifndef _@GUARD_PREFIX@_SYS_STAT_H
/* Get nlink_t.
May also define off_t to a 64-bit type on native Windows. */
#include
/* Get struct timespec. */
#include
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
#ifndef _@GUARD_PREFIX@_SYS_STAT_H
#define _@GUARD_PREFIX@_SYS_STAT_H
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
/* Before doing "#define mknod rpl_mknod" below, we need to include all
headers that may declare mknod(). OS/2 kLIBC declares mknod() in
, not in . */
#ifdef __KLIBC__
# include
#endif
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). Native Windows platforms declare mkdir
in and/or , not in . */
#if defined _WIN32 && ! defined __CYGWIN__
# include /* mingw32, mingw64 */
# include /* mingw64, MSVC 9 */
#endif
/* Native Windows platforms declare umask() in . */
#if 0 && (defined _WIN32 && ! defined __CYGWIN__)
# include
#endif
/* Large File Support on native Windows. */
#if @WINDOWS_64_BIT_ST_SIZE@
# define stat _stati64
#endif
/* Optionally, override 'struct stat' on native Windows. */
#if @GNULIB_OVERRIDES_STRUCT_STAT@
# undef stat
# if @GNULIB_STAT@
# define stat rpl_stat
# else
/* Provoke a clear link error if stat() is used as a function and
module 'stat' is not in use. */
# define stat stat_used_without_requesting_gnulib_module_stat
# endif
# if !GNULIB_defined_struct_stat
struct stat
{
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
# if 0
uid_t st_uid;
# else /* uid_t is not defined by default on native Windows. */
short st_uid;
# endif
# if 0
gid_t st_gid;
# else /* gid_t is not defined by default on native Windows. */
short st_gid;
# endif
dev_t st_rdev;
off_t st_size;
# if 0
blksize_t st_blksize;
blkcnt_t st_blocks;
# endif
# if @WINDOWS_STAT_TIMESPEC@
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
# else
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
# endif
};
# if @WINDOWS_STAT_TIMESPEC@
# define st_atime st_atim.tv_sec
# define st_mtime st_mtim.tv_sec
# define st_ctime st_ctim.tv_sec
/* Indicator, for gnulib internal purposes. */
# define _GL_WINDOWS_STAT_TIMESPEC 1
# endif
# define GNULIB_defined_struct_stat 1
# endif
/* Other possible values of st_mode. */
# if 0
# define _S_IFBLK 0x6000
# endif
# if 0
# define _S_IFLNK 0xA000
# endif
# if 0
# define _S_IFSOCK 0xC000
# endif
#endif
#ifndef S_IFIFO
# ifdef _S_IFIFO
# define S_IFIFO _S_IFIFO
# endif
#endif
#ifndef S_IFMT
# define S_IFMT 0170000
#endif
#if STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISNAM
# undef S_ISMPB
# undef S_ISMPC
# undef S_ISNWK
# undef S_ISREG
# undef S_ISSOCK
#endif
#ifndef S_ISBLK
# ifdef S_IFBLK
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
# else
# define S_ISBLK(m) 0
# endif
#endif
#ifndef S_ISCHR
# ifdef S_IFCHR
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
# else
# define S_ISCHR(m) 0
# endif
#endif
#ifndef S_ISDIR
# ifdef S_IFDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# else
# define S_ISDIR(m) 0
# endif
#endif
#ifndef S_ISDOOR /* Solaris 2.5 and up */
# define S_ISDOOR(m) 0
#endif
#ifndef S_ISFIFO
# ifdef S_IFIFO
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
# else
# define S_ISFIFO(m) 0
# endif
#endif
#ifndef S_ISLNK
# ifdef S_IFLNK
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
# else
# define S_ISLNK(m) 0
# endif
#endif
#ifndef S_ISMPB /* V7 */
# ifdef S_IFMPB
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
# else
# define S_ISMPB(m) 0
# define S_ISMPC(m) 0
# endif
#endif
#ifndef S_ISMPX /* AIX */
# define S_ISMPX(m) 0
#endif
#ifndef S_ISNAM /* Xenix */
# ifdef S_IFNAM
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
# else
# define S_ISNAM(m) 0
# endif
#endif
#ifndef S_ISNWK /* HP/UX */
# ifdef S_IFNWK
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
# else
# define S_ISNWK(m) 0
# endif
#endif
#ifndef S_ISPORT /* Solaris 10 and up */
# define S_ISPORT(m) 0
#endif
#ifndef S_ISREG
# ifdef S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# else
# define S_ISREG(m) 0
# endif
#endif
#ifndef S_ISSOCK
# ifdef S_IFSOCK
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
# else
# define S_ISSOCK(m) 0
# endif
#endif
#ifndef S_TYPEISMQ
# define S_TYPEISMQ(p) 0
#endif
#ifndef S_TYPEISTMO
# define S_TYPEISTMO(p) 0
#endif
#ifndef S_TYPEISSEM
# ifdef S_INSEM
# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
# else
# define S_TYPEISSEM(p) 0
# endif
#endif
#ifndef S_TYPEISSHM
# ifdef S_INSHD
# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
# else
# define S_TYPEISSHM(p) 0
# endif
#endif
/* high performance ("contiguous data") */
#ifndef S_ISCTG
# define S_ISCTG(p) 0
#endif
/* Cray DMF (data migration facility): off line, with data */
#ifndef S_ISOFD
# define S_ISOFD(p) 0
#endif
/* Cray DMF (data migration facility): off line, with no data */
#ifndef S_ISOFL
# define S_ISOFL(p) 0
#endif
/* 4.4BSD whiteout */
#ifndef S_ISWHT
# define S_ISWHT(m) 0
#endif
/* If any of the following are undefined,
define them to their de facto standard values. */
#if !S_ISUID
# define S_ISUID 04000
#endif
#if !S_ISGID
# define S_ISGID 02000
#endif
/* S_ISVTX is a common extension to POSIX. */
#ifndef S_ISVTX
# define S_ISVTX 01000
#endif
#if !S_IRUSR && S_IREAD
# define S_IRUSR S_IREAD
#endif
#if !S_IRUSR
# define S_IRUSR 00400
#endif
#if !S_IRGRP
# define S_IRGRP (S_IRUSR >> 3)
#endif
#if !S_IROTH
# define S_IROTH (S_IRUSR >> 6)
#endif
#if !S_IWUSR && S_IWRITE
# define S_IWUSR S_IWRITE
#endif
#if !S_IWUSR
# define S_IWUSR 00200
#endif
#if !S_IWGRP
# define S_IWGRP (S_IWUSR >> 3)
#endif
#if !S_IWOTH
# define S_IWOTH (S_IWUSR >> 6)
#endif
#if !S_IXUSR && S_IEXEC
# define S_IXUSR S_IEXEC
#endif
#if !S_IXUSR
# define S_IXUSR 00100
#endif
#if !S_IXGRP
# define S_IXGRP (S_IXUSR >> 3)
#endif
#if !S_IXOTH
# define S_IXOTH (S_IXUSR >> 6)
#endif
#if !S_IRWXU
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#endif
#if !S_IRWXG
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#endif
#if !S_IRWXO
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#endif
/* S_IXUGO is a common extension to POSIX. */
#if !S_IXUGO
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#endif
#ifndef S_IRWXUGO
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
#endif
/* Macros for futimens and utimensat. */
#ifndef UTIME_NOW
# define UTIME_NOW (-1)
# define UTIME_OMIT (-2)
#endif
#if @GNULIB_FCHMODAT@
# if !@HAVE_FCHMODAT@
_GL_FUNCDECL_SYS (fchmodat, int,
(int fd, char const *file, mode_t mode, int flag)
_GL_ARG_NONNULL ((2)));
# endif
_GL_CXXALIAS_SYS (fchmodat, int,
(int fd, char const *file, mode_t mode, int flag));
_GL_CXXALIASWARN (fchmodat);
#elif defined GNULIB_POSIXCHECK
# undef fchmodat
# if HAVE_RAW_DECL_FCHMODAT
_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
"use gnulib module openat for portability");
# endif
#endif
#if @GNULIB_FSTAT@
# if @REPLACE_FSTAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fstat
# define fstat rpl_fstat
# endif
_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
# else
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
# endif
_GL_CXXALIASWARN (fstat);
#elif @GNULIB_OVERRIDES_STRUCT_STAT@
# undef fstat
# define fstat fstat_used_without_requesting_gnulib_module_fstat
#elif @WINDOWS_64_BIT_ST_SIZE@
/* Above, we define stat to _stati64. */
# define fstat _fstati64
#elif defined GNULIB_POSIXCHECK
# undef fstat
# if HAVE_RAW_DECL_FSTAT
_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
"use gnulib module fstat for portability");
# endif
#endif
#if @GNULIB_FSTATAT@
# if @REPLACE_FSTATAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fstatat
# define fstatat rpl_fstatat
# endif
_GL_FUNCDECL_RPL (fstatat, int,
(int fd, char const *name, struct stat *st, int flags)
_GL_ARG_NONNULL ((2, 3)));
_GL_CXXALIAS_RPL (fstatat, int,
(int fd, char const *name, struct stat *st, int flags));
# else
# if !@HAVE_FSTATAT@
_GL_FUNCDECL_SYS (fstatat, int,
(int fd, char const *name, struct stat *st, int flags)
_GL_ARG_NONNULL ((2, 3)));
# endif
_GL_CXXALIAS_SYS (fstatat, int,
(int fd, char const *name, struct stat *st, int flags));
# endif
_GL_CXXALIASWARN (fstatat);
#elif @GNULIB_OVERRIDES_STRUCT_STAT@
# undef fstatat
# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
#elif defined GNULIB_POSIXCHECK
# undef fstatat
# if HAVE_RAW_DECL_FSTATAT
_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
"use gnulib module openat for portability");
# endif
#endif
#if @GNULIB_FUTIMENS@
/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
implementation relies on futimesat, which on Solaris 10 makes an invocation
to futimens that is meant to invoke the libc's futimens(), not gnulib's
futimens(). */
# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef futimens
# define futimens rpl_futimens
# endif
_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
# else
# if !@HAVE_FUTIMENS@
_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
# endif
_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
# endif
# if @HAVE_FUTIMENS@
_GL_CXXALIASWARN (futimens);
# endif
#elif defined GNULIB_POSIXCHECK
# undef futimens
# if HAVE_RAW_DECL_FUTIMENS
_GL_WARN_ON_USE (futimens, "futimens is not portable - "
"use gnulib module futimens for portability");
# endif
#endif
#if @GNULIB_LCHMOD@
/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
denotes a symbolic link. */
# if !@HAVE_LCHMOD@
/* The lchmod replacement follows symbolic links. Callers should take
this into account; lchmod should be applied only to arguments that
are known to not be symbolic links. On hosts that lack lchmod,
this can lead to race conditions between the check and the
invocation of lchmod, but we know of no workarounds that are
reliable in general. You might try requesting support for lchmod
from your operating system supplier. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lchmod chmod
# endif
/* Need to cast, because on mingw, the second parameter of chmod is
int mode. */
_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
(const char *filename, mode_t mode));
# else
# if 0 /* assume already declared */
_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
# endif
# if @HAVE_LCHMOD@
_GL_CXXALIASWARN (lchmod);
# endif
#elif defined GNULIB_POSIXCHECK
# undef lchmod
# if HAVE_RAW_DECL_LCHMOD
_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
"use gnulib module lchmod for portability");
# endif
#endif
#if @GNULIB_LSTAT@
# if ! @HAVE_LSTAT@
/* mingw does not support symlinks, therefore it does not have lstat. But
without links, stat does just fine. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lstat stat
# endif
_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
# elif @REPLACE_LSTAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef lstat
# define lstat rpl_lstat
# endif
_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
# else
_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
# endif
# if @HAVE_LSTAT@
_GL_CXXALIASWARN (lstat);
# endif
#elif @GNULIB_OVERRIDES_STRUCT_STAT@
# undef lstat
# define lstat lstat_used_without_requesting_gnulib_module_lstat
#elif defined GNULIB_POSIXCHECK
# undef lstat
# if HAVE_RAW_DECL_LSTAT
_GL_WARN_ON_USE (lstat, "lstat is unportable - "
"use gnulib module lstat for portability");
# endif
#endif
#if @REPLACE_MKDIR@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef mkdir
# define mkdir rpl_mkdir
# endif
_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
#else
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
Additionally, it declares _mkdir (and depending on compile flags, an
alias mkdir), only in the nonstandard includes and ,
which are included above. */
# if defined _WIN32 && ! defined __CYGWIN__
# if !GNULIB_defined_rpl_mkdir
static int
rpl_mkdir (char const *name, mode_t mode)
{
return _mkdir (name);
}
# define GNULIB_defined_rpl_mkdir 1
# endif
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define mkdir rpl_mkdir
# endif
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
# else
_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
# endif
#endif
_GL_CXXALIASWARN (mkdir);
#if @GNULIB_MKDIRAT@
# if !@HAVE_MKDIRAT@
_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
_GL_ARG_NONNULL ((2)));
# endif
_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
_GL_CXXALIASWARN (mkdirat);
#elif defined GNULIB_POSIXCHECK
# undef mkdirat
# if HAVE_RAW_DECL_MKDIRAT
_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
"use gnulib module openat for portability");
# endif
#endif
#if @GNULIB_MKFIFO@
# if @REPLACE_MKFIFO@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef mkfifo
# define mkfifo rpl_mkfifo
# endif
_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
# else
# if !@HAVE_MKFIFO@
_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
# endif
_GL_CXXALIASWARN (mkfifo);
#elif defined GNULIB_POSIXCHECK
# undef mkfifo
# if HAVE_RAW_DECL_MKFIFO
_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
"use gnulib module mkfifo for portability");
# endif
#endif
#if @GNULIB_MKFIFOAT@
# if !@HAVE_MKFIFOAT@
_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
_GL_ARG_NONNULL ((2)));
# endif
_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
_GL_CXXALIASWARN (mkfifoat);
#elif defined GNULIB_POSIXCHECK
# undef mkfifoat
# if HAVE_RAW_DECL_MKFIFOAT
_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
"use gnulib module mkfifoat for portability");
# endif
#endif
#if @GNULIB_MKNOD@
# if @REPLACE_MKNOD@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef mknod
# define mknod rpl_mknod
# endif
_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
# else
# if !@HAVE_MKNOD@
_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
_GL_ARG_NONNULL ((1)));
# endif
/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
# endif
_GL_CXXALIASWARN (mknod);
#elif defined GNULIB_POSIXCHECK
# undef mknod
# if HAVE_RAW_DECL_MKNOD
_GL_WARN_ON_USE (mknod, "mknod is not portable - "
"use gnulib module mknod for portability");
# endif
#endif
#if @GNULIB_MKNODAT@
# if !@HAVE_MKNODAT@
_GL_FUNCDECL_SYS (mknodat, int,
(int fd, char const *file, mode_t mode, dev_t dev)
_GL_ARG_NONNULL ((2)));
# endif
_GL_CXXALIAS_SYS (mknodat, int,
(int fd, char const *file, mode_t mode, dev_t dev));
_GL_CXXALIASWARN (mknodat);
#elif defined GNULIB_POSIXCHECK
# undef mknodat
# if HAVE_RAW_DECL_MKNODAT
_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
"use gnulib module mkfifoat for portability");
# endif
#endif
#if @GNULIB_STAT@
# if @REPLACE_STAT@
# if !@GNULIB_OVERRIDES_STRUCT_STAT@
/* We can't use the object-like #define stat rpl_stat, because of
struct stat. This means that rpl_stat will not be used if the user
does (stat)(a,b). Oh well. */
# if defined _AIX && defined stat && defined _LARGE_FILES
/* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
so we have to replace stat64() instead of stat(). */
# undef stat64
# define stat64(name, st) rpl_stat (name, st)
# elif @WINDOWS_64_BIT_ST_SIZE@
/* Above, we define stat to _stati64. */
# if defined __MINGW32__ && defined _stati64
# ifndef _USE_32BIT_TIME_T
/* The system headers define _stati64 to _stat64. */
# undef _stat64
# define _stat64(name, st) rpl_stat (name, st)
# endif
# elif defined _MSC_VER && defined _stati64
# ifdef _USE_32BIT_TIME_T
/* The system headers define _stati64 to _stat32i64. */
# undef _stat32i64
# define _stat32i64(name, st) rpl_stat (name, st)
# else
/* The system headers define _stati64 to _stat64. */
# undef _stat64
# define _stat64(name, st) rpl_stat (name, st)
# endif
# else
# undef _stati64
# define _stati64(name, st) rpl_stat (name, st)
# endif
# elif defined __MINGW32__ && defined stat
# ifdef _USE_32BIT_TIME_T
/* The system headers define stat to _stat32i64. */
# undef _stat32i64
# define _stat32i64(name, st) rpl_stat (name, st)
# else
/* The system headers define stat to _stat64. */
# undef _stat64
# define _stat64(name, st) rpl_stat (name, st)
# endif
# elif defined _MSC_VER && defined stat
# ifdef _USE_32BIT_TIME_T
/* The system headers define stat to _stat32. */
# undef _stat32
# define _stat32(name, st) rpl_stat (name, st)
# else
/* The system headers define stat to _stat64i32. */
# undef _stat64i32
# define _stat64i32(name, st) rpl_stat (name, st)
# endif
# else /* !(_AIX || __MINGW32__ || _MSC_VER) */
# undef stat
# define stat(name, st) rpl_stat (name, st)
# endif /* !_LARGE_FILES */
# endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
_GL_EXTERN_C int stat (const char *name, struct stat *buf)
_GL_ARG_NONNULL ((1, 2));
# endif
#elif @GNULIB_OVERRIDES_STRUCT_STAT@
/* see above:
#define stat stat_used_without_requesting_gnulib_module_stat
*/
#elif defined GNULIB_POSIXCHECK
# undef stat
# if HAVE_RAW_DECL_STAT
_GL_WARN_ON_USE (stat, "stat is unportable - "
"use gnulib module stat for portability");
# endif
#endif
#if @GNULIB_UTIMENSAT@
/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
implementation relies on futimesat, which on Solaris 10 makes an invocation
to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
utimensat(). */
# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef utimensat
# define utimensat rpl_utimensat
# endif
_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
struct timespec const times[2], int flag)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
struct timespec const times[2], int flag));
# else
# if !@HAVE_UTIMENSAT@
_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
struct timespec const times[2], int flag)
_GL_ARG_NONNULL ((2)));
# endif
_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
struct timespec const times[2], int flag));
# endif
# if @HAVE_UTIMENSAT@
_GL_CXXALIASWARN (utimensat);
# endif
#elif defined GNULIB_POSIXCHECK
# undef utimensat
# if HAVE_RAW_DECL_UTIMENSAT
_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
"use gnulib module utimensat for portability");
# endif
#endif
#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
#endif
gsasl-1.8.1/gl/connect.c 0000644 0000000 0000000 00000003016 13516251574 011731 0000000 0000000 /* connect.c --- wrappers for Windows connect function
Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* Written by Paolo Bonzini */
#include
#define WIN32_LEAN_AND_MEAN
/* Get winsock2.h. */
#include
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
#include "w32sock.h"
#undef connect
int
rpl_connect (int fd, const struct sockaddr *sockaddr, socklen_t len)
{
SOCKET sock = FD_TO_SOCKET (fd);
if (sock == INVALID_SOCKET)
{
errno = EBADF;
return -1;
}
else
{
int r = connect (sock, sockaddr, len);
if (r < 0)
{
/* EINPROGRESS is not returned by WinSock 2.0; for backwards
compatibility, connect(2) uses EWOULDBLOCK. */
if (WSAGetLastError () == WSAEWOULDBLOCK)
WSASetLastError (WSAEINPROGRESS);
set_winsock_errno ();
}
return r;
}
}
gsasl-1.8.1/gl/msvc-nothrow.c 0000644 0000000 0000000 00000002515 13516251576 012753 0000000 0000000 /* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
Copyright (C) 2011-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
#include
/* Specification. */
#include "msvc-nothrow.h"
/* Get declarations of the native Windows API functions. */
#define WIN32_LEAN_AND_MEAN
#include
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
# include "msvc-inval.h"
#endif
#undef _get_osfhandle
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
intptr_t
_gl_nothrow_get_osfhandle (int fd)
{
intptr_t result;
TRY_MSVC_INVAL
{
result = _get_osfhandle (fd);
}
CATCH_MSVC_INVAL
{
result = (intptr_t) INVALID_HANDLE_VALUE;
}
DONE_MSVC_INVAL;
return result;
}
#endif
gsasl-1.8.1/gl/stat-time.c 0000644 0000000 0000000 00000000132 13516251573 012202 0000000 0000000 #include
#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE
#include "stat-time.h"
gsasl-1.8.1/gl/iconv_open-irix.gperf 0000644 0000000 0000000 00000002677 13516251574 014305 0000000 0000000 /* Character set conversion.
Copyright (C) 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
struct mapping { int standard_name; const char vendor_name[10 + 1]; };
%struct-type
%language=ANSI-C
%define slot-name standard_name
%define hash-function-name mapping_hash
%define lookup-function-name mapping_lookup
%readonly-tables
%global-table
%define word-array-name mappings
%pic
%%
# On IRIX 6.5, look in /usr/lib/iconv and /usr/lib/international/encodings.
ISO-8859-1, "ISO8859-1"
ISO-8859-2, "ISO8859-2"
ISO-8859-3, "ISO8859-3"
ISO-8859-4, "ISO8859-4"
ISO-8859-5, "ISO8859-5"
ISO-8859-6, "ISO8859-6"
ISO-8859-7, "ISO8859-7"
ISO-8859-8, "ISO8859-8"
ISO-8859-9, "ISO8859-9"
ISO-8859-15, "ISO8859-15"
KOI8-R, "KOI8"
CP855, "DOS855"
CP1251, "WIN1251"
GB2312, "eucCN"
EUC-JP, "eucJP"
EUC-KR, "eucKR"
EUC-TW, "eucTW"
SHIFT_JIS, "sjis"
TIS-620, "TIS620"
gsasl-1.8.1/gl/dosname.h 0000644 0000000 0000000 00000003674 13516251573 011744 0000000 0000000 /* File names on MS-DOS/Windows systems.
Copyright (C) 2000-2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
From Paul Eggert and Jim Meyering. */
#ifndef _DOSNAME_H
#define _DOSNAME_H
#if (defined _WIN32 || defined __CYGWIN__ \
|| defined __EMX__ || defined __MSDOS__ || defined __DJGPP__)
/* This internal macro assumes ASCII, but all hosts that support drive
letters use ASCII. */
# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
<= 'z' - 'a')
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
# ifndef __CYGWIN__
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
# endif
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#else
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
# define ISSLASH(C) ((C) == '/')
#endif
#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
#endif
#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
# else
# define IS_ABSOLUTE_FILE_NAME(F) \
(ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
#endif
#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
#endif /* DOSNAME_H_ */
gsasl-1.8.1/gl/localcharset.c 0000644 0000000 0000000 00000101735 13516251575 012754 0000000 0000000 /* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2006, 2008-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
/* Written by Bruno Haible . */
#include
/* Specification. */
#include "localcharset.h"
#include
#include
#include
#include
#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
#endif
#if defined _WIN32 && !defined __CYGWIN__
# define WINDOWS_NATIVE
# include
#endif
#if defined __EMX__
/* Assume EMX program runs on OS/2, even if compiled under DOS. */
# ifndef OS2
# define OS2
# endif
#endif
#if !defined WINDOWS_NATIVE
# if HAVE_LANGINFO_CODESET
# include
# else
# if 0 /* see comment regarding use of setlocale(), below */
# include
# endif
# endif
# ifdef __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include
# endif
#elif defined WINDOWS_NATIVE
# define WIN32_LEAN_AND_MEAN
# include
#endif
#if defined OS2
# define INCL_DOS
# include
#endif
/* For MB_CUR_MAX_L */
#if defined DARWIN7
# include
#endif
#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
/* On these platforms, we use a mapping from non-canonical encoding name
to GNU canonical encoding name. */
/* With glibc-2.1 or newer, we don't need any canonicalization,
because glibc has iconv and both glibc and libiconv support all
GNU canonical names directly. */
# if !((defined __GNU_LIBRARY__ && __GLIBC__ >= 2) || defined __UCLIBC__)
struct table_entry
{
const char alias[11+1];
const char canonical[11+1];
};
/* Table of platform-dependent mappings, sorted in ascending order. */
static const struct table_entry alias_table[] =
{
# if defined __FreeBSD__ /* FreeBSD */
/*{ "ARMSCII-8", "ARMSCII-8" },*/
{ "Big5", "BIG5" },
{ "C", "ASCII" },
/*{ "CP1131", "CP1131" },*/
/*{ "CP1251", "CP1251" },*/
/*{ "CP866", "CP866" },*/
/*{ "GB18030", "GB18030" },*/
/*{ "GB2312", "GB2312" },*/
/*{ "GBK", "GBK" },*/
/*{ "ISCII-DEV", "?" },*/
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-13", "ISO-8859-13" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-7", "ISO-8859-7" },
{ "ISO8859-9", "ISO-8859-9" },
/*{ "KOI8-R", "KOI8-R" },*/
/*{ "KOI8-U", "KOI8-U" },*/
{ "SJIS", "SHIFT_JIS" },
{ "US-ASCII", "ASCII" },
{ "eucCN", "GB2312" },
{ "eucJP", "EUC-JP" },
{ "eucKR", "EUC-KR" }
# define alias_table_defined
# endif
# if defined __NetBSD__ /* NetBSD */
{ "646", "ASCII" },
/*{ "ARMSCII-8", "ARMSCII-8" },*/
/*{ "BIG5", "BIG5" },*/
{ "Big5-HKSCS", "BIG5-HKSCS" },
/*{ "CP1251", "CP1251" },*/
/*{ "CP866", "CP866" },*/
/*{ "GB18030", "GB18030" },*/
/*{ "GB2312", "GB2312" },*/
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-13", "ISO-8859-13" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-4", "ISO-8859-4" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-7", "ISO-8859-7" },
/*{ "KOI8-R", "KOI8-R" },*/
/*{ "KOI8-U", "KOI8-U" },*/
/*{ "PT154", "PT154" },*/
{ "SJIS", "SHIFT_JIS" },
{ "eucCN", "GB2312" },
{ "eucJP", "EUC-JP" },
{ "eucKR", "EUC-KR" },
{ "eucTW", "EUC-TW" }
# define alias_table_defined
# endif
# if defined __OpenBSD__ /* OpenBSD */
{ "646", "ASCII" },
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-13", "ISO-8859-13" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-4", "ISO-8859-4" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-7", "ISO-8859-7" }
# define alias_table_defined
# endif
# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
/* Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
useless:
- It returns the empty string when LANG is set to a locale of the
form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
LC_CTYPE file.
- The environment variables LANG, LC_CTYPE, LC_ALL are not set by
the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
- The documentation says:
"... all code that calls BSD system routines should ensure
that the const *char parameters of these routines are in UTF-8
encoding. All BSD system functions expect their string
parameters to be in UTF-8 encoding and nothing else."
It also says
"An additional caveat is that string parameters for files,
paths, and other file-system entities must be in canonical
UTF-8. In a canonical UTF-8 Unicode string, all decomposable
characters are decomposed ..."
but this is not true: You can pass non-decomposed UTF-8 strings
to file system functions, and it is the OS which will convert
them to decomposed UTF-8 before accessing the file system.
- The Apple Terminal application displays UTF-8 by default.
- However, other applications are free to use different encodings:
- xterm uses ISO-8859-1 by default.
- TextEdit uses MacRoman by default.
We prefer UTF-8 over decomposed UTF-8-MAC because one should
minimize the use of decomposed Unicode. Unfortunately, through the
Darwin file system, decomposed UTF-8 strings are leaked into user
space nevertheless.
Then there are also the locales with encodings other than US-ASCII
and UTF-8. These locales can be occasionally useful to users (e.g.
when grepping through ISO-8859-1 encoded text files), when all their
file names are in US-ASCII.
*/
{ "ARMSCII-8", "ARMSCII-8" },
{ "Big5", "BIG5" },
{ "Big5HKSCS", "BIG5-HKSCS" },
{ "CP1131", "CP1131" },
{ "CP1251", "CP1251" },
{ "CP866", "CP866" },
{ "CP949", "CP949" },
{ "GB18030", "GB18030" },
{ "GB2312", "GB2312" },
{ "GBK", "GBK" },
/*{ "ISCII-DEV", "?" },*/
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-13", "ISO-8859-13" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-4", "ISO-8859-4" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-7", "ISO-8859-7" },
{ "ISO8859-9", "ISO-8859-9" },
{ "KOI8-R", "KOI8-R" },
{ "KOI8-U", "KOI8-U" },
{ "PT154", "PT154" },
{ "SJIS", "SHIFT_JIS" },
{ "eucCN", "GB2312" },
{ "eucJP", "EUC-JP" },
{ "eucKR", "EUC-KR" }
# define alias_table_defined
# endif
# if defined _AIX /* AIX */
/*{ "GBK", "GBK" },*/
{ "IBM-1046", "CP1046" },
{ "IBM-1124", "CP1124" },
{ "IBM-1129", "CP1129" },
{ "IBM-1252", "CP1252" },
{ "IBM-850", "CP850" },
{ "IBM-856", "CP856" },
{ "IBM-921", "ISO-8859-13" },
{ "IBM-922", "CP922" },
{ "IBM-932", "CP932" },
{ "IBM-943", "CP943" },
{ "IBM-eucCN", "GB2312" },
{ "IBM-eucJP", "EUC-JP" },
{ "IBM-eucKR", "EUC-KR" },
{ "IBM-eucTW", "EUC-TW" },
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-6", "ISO-8859-6" },
{ "ISO8859-7", "ISO-8859-7" },
{ "ISO8859-8", "ISO-8859-8" },
{ "ISO8859-9", "ISO-8859-9" },
{ "TIS-620", "TIS-620" },
/*{ "UTF-8", "UTF-8" },*/
{ "big5", "BIG5" }
# define alias_table_defined
# endif
# if defined __hpux /* HP-UX */
{ "SJIS", "SHIFT_JIS" },
{ "arabic8", "HP-ARABIC8" },
{ "big5", "BIG5" },
{ "cp1251", "CP1251" },
{ "eucJP", "EUC-JP" },
{ "eucKR", "EUC-KR" },
{ "eucTW", "EUC-TW" },
{ "gb18030", "GB18030" },
{ "greek8", "HP-GREEK8" },
{ "hebrew8", "HP-HEBREW8" },
{ "hkbig5", "BIG5-HKSCS" },
{ "hp15CN", "GB2312" },
{ "iso88591", "ISO-8859-1" },
{ "iso885913", "ISO-8859-13" },
{ "iso885915", "ISO-8859-15" },
{ "iso88592", "ISO-8859-2" },
{ "iso88594", "ISO-8859-4" },
{ "iso88595", "ISO-8859-5" },
{ "iso88596", "ISO-8859-6" },
{ "iso88597", "ISO-8859-7" },
{ "iso88598", "ISO-8859-8" },
{ "iso88599", "ISO-8859-9" },
{ "kana8", "HP-KANA8" },
{ "koi8r", "KOI8-R" },
{ "roman8", "HP-ROMAN8" },
{ "tis620", "TIS-620" },
{ "turkish8", "HP-TURKISH8" },
{ "utf8", "UTF-8" }
# define alias_table_defined
# endif
# if defined __sgi /* IRIX */
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-7", "ISO-8859-7" },
{ "ISO8859-9", "ISO-8859-9" },
{ "eucCN", "GB2312" },
{ "eucJP", "EUC-JP" },
{ "eucKR", "EUC-KR" },
{ "eucTW", "EUC-TW" }
# define alias_table_defined
# endif
# if defined __osf__ /* OSF/1 */
/*{ "GBK", "GBK" },*/
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-4", "ISO-8859-4" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-7", "ISO-8859-7" },
{ "ISO8859-8", "ISO-8859-8" },
{ "ISO8859-9", "ISO-8859-9" },
{ "KSC5601", "CP949" },
{ "SJIS", "SHIFT_JIS" },
{ "TACTIS", "TIS-620" },
/*{ "UTF-8", "UTF-8" },*/
{ "big5", "BIG5" },
{ "cp850", "CP850" },
{ "dechanyu", "DEC-HANYU" },
{ "dechanzi", "GB2312" },
{ "deckanji", "DEC-KANJI" },
{ "deckorean", "EUC-KR" },
{ "eucJP", "EUC-JP" },
{ "eucKR", "EUC-KR" },
{ "eucTW", "EUC-TW" },
{ "sdeckanji", "EUC-JP" }
# define alias_table_defined
# endif
# if defined __sun /* Solaris */
{ "5601", "EUC-KR" },
{ "646", "ASCII" },
/*{ "BIG5", "BIG5" },*/
{ "Big5-HKSCS", "BIG5-HKSCS" },
{ "GB18030", "GB18030" },
/*{ "GBK", "GBK" },*/
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-11", "TIS-620" },
{ "ISO8859-13", "ISO-8859-13" },
{ "ISO8859-15", "ISO-8859-15" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-3", "ISO-8859-3" },
{ "ISO8859-4", "ISO-8859-4" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-6", "ISO-8859-6" },
{ "ISO8859-7", "ISO-8859-7" },
{ "ISO8859-8", "ISO-8859-8" },
{ "ISO8859-9", "ISO-8859-9" },
{ "PCK", "SHIFT_JIS" },
{ "TIS620.2533", "TIS-620" },
/*{ "UTF-8", "UTF-8" },*/
{ "ansi-1251", "CP1251" },
{ "cns11643", "EUC-TW" },
{ "eucJP", "EUC-JP" },
{ "gb2312", "GB2312" },
{ "koi8-r", "KOI8-R" }
# define alias_table_defined
# endif
# if defined __minix /* Minix */
{ "646", "ASCII" }
# define alias_table_defined
# endif
# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Windows */
{ "CP1361", "JOHAB" },
{ "CP20127", "ASCII" },
{ "CP20866", "KOI8-R" },
{ "CP20936", "GB2312" },
{ "CP21866", "KOI8-RU" },
{ "CP28591", "ISO-8859-1" },
{ "CP28592", "ISO-8859-2" },
{ "CP28593", "ISO-8859-3" },
{ "CP28594", "ISO-8859-4" },
{ "CP28595", "ISO-8859-5" },
{ "CP28596", "ISO-8859-6" },
{ "CP28597", "ISO-8859-7" },
{ "CP28598", "ISO-8859-8" },
{ "CP28599", "ISO-8859-9" },
{ "CP28605", "ISO-8859-15" },
{ "CP38598", "ISO-8859-8" },
{ "CP51932", "EUC-JP" },
{ "CP51936", "GB2312" },
{ "CP51949", "EUC-KR" },
{ "CP51950", "EUC-TW" },
{ "CP54936", "GB18030" },
{ "CP65001", "UTF-8" },
{ "CP936", "GBK" }
# define alias_table_defined
# endif
# if defined OS2 /* OS/2 */
/* The list of encodings is taken from "List of OS/2 Codepages"
by Alex Taylor:
.
See also "IBM Globalization - Code page identifiers":
. */
{ "CP1089", "ISO-8859-6" },
{ "CP1208", "UTF-8" },
{ "CP1381", "GB2312" },
{ "CP1386", "GBK" },
{ "CP3372", "EUC-JP" },
{ "CP813", "ISO-8859-7" },
{ "CP819", "ISO-8859-1" },
{ "CP878", "KOI8-R" },
{ "CP912", "ISO-8859-2" },
{ "CP913", "ISO-8859-3" },
{ "CP914", "ISO-8859-4" },
{ "CP915", "ISO-8859-5" },
{ "CP916", "ISO-8859-8" },
{ "CP920", "ISO-8859-9" },
{ "CP921", "ISO-8859-13" },
{ "CP923", "ISO-8859-15" },
{ "CP954", "EUC-JP" },
{ "CP964", "EUC-TW" },
{ "CP970", "EUC-KR" }
# define alias_table_defined
# endif
# if defined VMS /* OpenVMS */
/* The list of encodings is taken from the OpenVMS 7.3-1 documentation
"Compaq C Run-Time Library Reference Manual for OpenVMS systems"
section 10.7 "Handling Different Character Sets". */
{ "DECHANYU", "DEC-HANYU" },
{ "DECHANZI", "GB2312" },
{ "DECKANJI", "DEC-KANJI" },
{ "DECKOREAN", "EUC-KR" },
{ "ISO8859-1", "ISO-8859-1" },
{ "ISO8859-2", "ISO-8859-2" },
{ "ISO8859-5", "ISO-8859-5" },
{ "ISO8859-7", "ISO-8859-7" },
{ "ISO8859-8", "ISO-8859-8" },
{ "ISO8859-9", "ISO-8859-9" },
{ "SDECKANJI", "EUC-JP" },
{ "SJIS", "SHIFT_JIS" },
{ "eucJP", "EUC-JP" },
{ "eucTW", "EUC-TW" }
# define alias_table_defined
# endif
# ifndef alias_table_defined
/* Just a dummy entry, to avoid a C syntax error. */
{ "", "" }
# endif
};
# endif
#else
/* On these platforms, we use a mapping from locale name to GNU canonical
encoding name. */
struct table_entry
{
const char locale[17+1];
const char canonical[11+1];
};
/* Table of platform-dependent mappings, sorted in ascending order. */
static const struct table_entry locale_table[] =
{
# if defined __FreeBSD__ /* FreeBSD 4.2 */
{ "cs_CZ.ISO_8859-2", "ISO-8859-2" },
{ "da_DK.DIS_8859-15", "ISO-8859-15" },
{ "da_DK.ISO_8859-1", "ISO-8859-1" },
{ "de_AT.DIS_8859-15", "ISO-8859-15" },
{ "de_AT.ISO_8859-1", "ISO-8859-1" },
{ "de_CH.DIS_8859-15", "ISO-8859-15" },
{ "de_CH.ISO_8859-1", "ISO-8859-1" },
{ "de_DE.DIS_8859-15", "ISO-8859-15" },
{ "de_DE.ISO_8859-1", "ISO-8859-1" },
{ "en_AU.DIS_8859-15", "ISO-8859-15" },
{ "en_AU.ISO_8859-1", "ISO-8859-1" },
{ "en_CA.DIS_8859-15", "ISO-8859-15" },
{ "en_CA.ISO_8859-1", "ISO-8859-1" },
{ "en_GB.DIS_8859-15", "ISO-8859-15" },
{ "en_GB.ISO_8859-1", "ISO-8859-1" },
{ "en_US.DIS_8859-15", "ISO-8859-15" },
{ "en_US.ISO_8859-1", "ISO-8859-1" },
{ "es_ES.DIS_8859-15", "ISO-8859-15" },
{ "es_ES.ISO_8859-1", "ISO-8859-1" },
{ "fi_FI.DIS_8859-15", "ISO-8859-15" },
{ "fi_FI.ISO_8859-1", "ISO-8859-1" },
{ "fr_BE.DIS_8859-15", "ISO-8859-15" },
{ "fr_BE.ISO_8859-1", "ISO-8859-1" },
{ "fr_CA.DIS_8859-15", "ISO-8859-15" },
{ "fr_CA.ISO_8859-1", "ISO-8859-1" },
{ "fr_CH.DIS_8859-15", "ISO-8859-15" },
{ "fr_CH.ISO_8859-1", "ISO-8859-1" },
{ "fr_FR.DIS_8859-15", "ISO-8859-15" },
{ "fr_FR.ISO_8859-1", "ISO-8859-1" },
{ "hr_HR.ISO_8859-2", "ISO-8859-2" },
{ "hu_HU.ISO_8859-2", "ISO-8859-2" },
{ "is_IS.DIS_8859-15", "ISO-8859-15" },
{ "is_IS.ISO_8859-1", "ISO-8859-1" },
{ "it_CH.DIS_8859-15", "ISO-8859-15" },
{ "it_CH.ISO_8859-1", "ISO-8859-1" },
{ "it_IT.DIS_8859-15", "ISO-8859-15" },
{ "it_IT.ISO_8859-1", "ISO-8859-1" },
{ "ja_JP.EUC", "EUC-JP" },
{ "ja_JP.SJIS", "SHIFT_JIS" },
{ "ja_JP.Shift_JIS", "SHIFT_JIS" },
{ "ko_KR.EUC", "EUC-KR" },
{ "la_LN.ASCII", "ASCII" },
{ "la_LN.DIS_8859-15", "ISO-8859-15" },
{ "la_LN.ISO_8859-1", "ISO-8859-1" },
{ "la_LN.ISO_8859-2", "ISO-8859-2" },
{ "la_LN.ISO_8859-4", "ISO-8859-4" },
{ "lt_LN.ASCII", "ASCII" },
{ "lt_LN.DIS_8859-15", "ISO-8859-15" },
{ "lt_LN.ISO_8859-1", "ISO-8859-1" },
{ "lt_LN.ISO_8859-2", "ISO-8859-2" },
{ "lt_LT.ISO_8859-4", "ISO-8859-4" },
{ "nl_BE.DIS_8859-15", "ISO-8859-15" },
{ "nl_BE.ISO_8859-1", "ISO-8859-1" },
{ "nl_NL.DIS_8859-15", "ISO-8859-15" },
{ "nl_NL.ISO_8859-1", "ISO-8859-1" },
{ "no_NO.DIS_8859-15", "ISO-8859-15" },
{ "no_NO.ISO_8859-1", "ISO-8859-1" },
{ "pl_PL.ISO_8859-2", "ISO-8859-2" },
{ "pt_PT.DIS_8859-15", "ISO-8859-15" },
{ "pt_PT.ISO_8859-1", "ISO-8859-1" },
{ "ru_RU.CP866", "CP866" },
{ "ru_RU.ISO_8859-5", "ISO-8859-5" },
{ "ru_RU.KOI8-R", "KOI8-R" },
{ "ru_SU.CP866", "CP866" },
{ "ru_SU.ISO_8859-5", "ISO-8859-5" },
{ "ru_SU.KOI8-R", "KOI8-R" },
{ "sl_SI.ISO_8859-2", "ISO-8859-2" },
{ "sv_SE.DIS_8859-15", "ISO-8859-15" },
{ "sv_SE.ISO_8859-1", "ISO-8859-1" },
{ "uk_UA.KOI8-U", "KOI8-U" },
{ "zh_CN.EUC", "GB2312" },
{ "zh_TW.BIG5", "BIG5" },
{ "zh_TW.Big5", "BIG5" }
# define locale_table_defined
# endif
# if defined __DJGPP__ /* DOS / DJGPP 2.03 */
/* The encodings given here may not all be correct.
If you find that the encoding given for your language and
country is not the one your DOS machine actually uses, just
correct it in this file, and send a mail to
Juan Manuel Guerrero
and . */
{ "C", "ASCII" },
{ "ar", "CP864" },
{ "ar_AE", "CP864" },
{ "ar_DZ", "CP864" },
{ "ar_EG", "CP864" },
{ "ar_IQ", "CP864" },
{ "ar_IR", "CP864" },
{ "ar_JO", "CP864" },
{ "ar_KW", "CP864" },
{ "ar_MA", "CP864" },
{ "ar_OM", "CP864" },
{ "ar_QA", "CP864" },
{ "ar_SA", "CP864" },
{ "ar_SY", "CP864" },
{ "be", "CP866" },
{ "be_BE", "CP866" },
{ "bg", "CP866" }, /* not CP855 ?? */
{ "bg_BG", "CP866" }, /* not CP855 ?? */
{ "ca", "CP850" },
{ "ca_ES", "CP850" },
{ "cs", "CP852" },
{ "cs_CZ", "CP852" },
{ "da", "CP865" }, /* not CP850 ?? */
{ "da_DK", "CP865" }, /* not CP850 ?? */
{ "de", "CP850" },
{ "de_AT", "CP850" },
{ "de_CH", "CP850" },
{ "de_DE", "CP850" },
{ "el", "CP869" },
{ "el_GR", "CP869" },
{ "en", "CP850" },
{ "en_AU", "CP850" }, /* not CP437 ?? */
{ "en_CA", "CP850" },
{ "en_GB", "CP850" },
{ "en_NZ", "CP437" },
{ "en_US", "CP437" },
{ "en_ZA", "CP850" }, /* not CP437 ?? */
{ "eo", "CP850" },
{ "eo_EO", "CP850" },
{ "es", "CP850" },
{ "es_AR", "CP850" },
{ "es_BO", "CP850" },
{ "es_CL", "CP850" },
{ "es_CO", "CP850" },
{ "es_CR", "CP850" },
{ "es_CU", "CP850" },
{ "es_DO", "CP850" },
{ "es_EC", "CP850" },
{ "es_ES", "CP850" },
{ "es_GT", "CP850" },
{ "es_HN", "CP850" },
{ "es_MX", "CP850" },
{ "es_NI", "CP850" },
{ "es_PA", "CP850" },
{ "es_PE", "CP850" },
{ "es_PY", "CP850" },
{ "es_SV", "CP850" },
{ "es_UY", "CP850" },
{ "es_VE", "CP850" },
{ "et", "CP850" },
{ "et_EE", "CP850" },
{ "eu", "CP850" },
{ "eu_ES", "CP850" },
{ "fi", "CP850" },
{ "fi_FI", "CP850" },
{ "fr", "CP850" },
{ "fr_BE", "CP850" },
{ "fr_CA", "CP850" },
{ "fr_CH", "CP850" },
{ "fr_FR", "CP850" },
{ "ga", "CP850" },
{ "ga_IE", "CP850" },
{ "gd", "CP850" },
{ "gd_GB", "CP850" },
{ "gl", "CP850" },
{ "gl_ES", "CP850" },
{ "he", "CP862" },
{ "he_IL", "CP862" },
{ "hr", "CP852" },
{ "hr_HR", "CP852" },
{ "hu", "CP852" },
{ "hu_HU", "CP852" },
{ "id", "CP850" }, /* not CP437 ?? */
{ "id_ID", "CP850" }, /* not CP437 ?? */
{ "is", "CP861" }, /* not CP850 ?? */
{ "is_IS", "CP861" }, /* not CP850 ?? */
{ "it", "CP850" },
{ "it_CH", "CP850" },
{ "it_IT", "CP850" },
{ "ja", "CP932" },
{ "ja_JP", "CP932" },
{ "kr", "CP949" }, /* not CP934 ?? */
{ "kr_KR", "CP949" }, /* not CP934 ?? */
{ "lt", "CP775" },
{ "lt_LT", "CP775" },
{ "lv", "CP775" },
{ "lv_LV", "CP775" },
{ "mk", "CP866" }, /* not CP855 ?? */
{ "mk_MK", "CP866" }, /* not CP855 ?? */
{ "mt", "CP850" },
{ "mt_MT", "CP850" },
{ "nb", "CP865" }, /* not CP850 ?? */
{ "nb_NO", "CP865" }, /* not CP850 ?? */
{ "nl", "CP850" },
{ "nl_BE", "CP850" },
{ "nl_NL", "CP850" },
{ "nn", "CP865" }, /* not CP850 ?? */
{ "nn_NO", "CP865" }, /* not CP850 ?? */
{ "no", "CP865" }, /* not CP850 ?? */
{ "no_NO", "CP865" }, /* not CP850 ?? */
{ "pl", "CP852" },
{ "pl_PL", "CP852" },
{ "pt", "CP850" },
{ "pt_BR", "CP850" },
{ "pt_PT", "CP850" },
{ "ro", "CP852" },
{ "ro_RO", "CP852" },
{ "ru", "CP866" },
{ "ru_RU", "CP866" },
{ "sk", "CP852" },
{ "sk_SK", "CP852" },
{ "sl", "CP852" },
{ "sl_SI", "CP852" },
{ "sq", "CP852" },
{ "sq_AL", "CP852" },
{ "sr", "CP852" }, /* CP852 or CP866 or CP855 ?? */
{ "sr_CS", "CP852" }, /* CP852 or CP866 or CP855 ?? */
{ "sr_YU", "CP852" }, /* CP852 or CP866 or CP855 ?? */
{ "sv", "CP850" },
{ "sv_SE", "CP850" },
{ "th", "CP874" },
{ "th_TH", "CP874" },
{ "tr", "CP857" },
{ "tr_TR", "CP857" },
{ "uk", "CP1125" },
{ "uk_UA", "CP1125" },
{ "zh_CN", "GBK" },
{ "zh_TW", "CP950" } /* not CP938 ?? */
# define locale_table_defined
# endif
# ifndef locale_table_defined
/* Just a dummy entry, to avoid a C syntax error. */
{ "", "" }
# endif
};
#endif
/* Determine the current locale's character encoding, and canonicalize it
into one of the canonical names listed in localcharset.h.
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
#ifdef STATIC
STATIC
#endif
const char *
locale_charset (void)
{
const char *codeset;
#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
# if HAVE_LANGINFO_CODESET
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
# ifdef __CYGWIN__
/* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
returns "US-ASCII". Return the suffix of the locale name from the
environment variables (if present) or the codepage as a number. */
if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
{
const char *locale;
static char buf[2 + 10 + 1];
locale = getenv ("LC_ALL");
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG");
}
if (locale != NULL && locale[0] != '\0')
{
/* If the locale name contains an encoding after the dot, return
it. */
const char *dot = strchr (locale, '.');
if (dot != NULL)
{
const char *modifier;
dot++;
/* Look for the possible @... trailer and remove it, if any. */
modifier = strchr (dot, '@');
if (modifier == NULL)
return dot;
if (modifier - dot < sizeof (buf))
{
memcpy (buf, dot, modifier - dot);
buf [modifier - dot] = '\0';
return buf;
}
}
}
/* The Windows API has a function returning the locale's codepage as a
number: GetACP(). This encoding is used by Cygwin, unless the user
has set the environment variable CYGWIN=codepage:oem (which very few
people do).
Output directed to console windows needs to be converted (to
GetOEMCP() if the console is using a raster font, or to
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
this conversion transparently (see winsup/cygwin/fhandler_console.cc),
converting to GetConsoleOutputCP(). This leads to correct results,
except when SetConsoleOutputCP has been called and a raster font is
in use. */
sprintf (buf, "CP%u", GetACP ());
codeset = buf;
}
# endif
if (codeset == NULL)
/* The canonical name cannot be determined. */
codeset = "";
# elif defined WINDOWS_NATIVE
static char buf[2 + 10 + 1];
/* The Windows API has a function returning the locale's codepage as
a number, but the value doesn't change according to what the
'setlocale' call specified. So we use it as a last resort, in
case the string returned by 'setlocale' doesn't specify the
codepage. */
char *current_locale = setlocale (LC_ALL, NULL);
char *pdot;
/* If they set different locales for different categories,
'setlocale' will return a semi-colon separated list of locale
values. To make sure we use the correct one, we choose LC_CTYPE. */
if (strchr (current_locale, ';'))
current_locale = setlocale (LC_CTYPE, NULL);
pdot = strrchr (current_locale, '.');
if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
sprintf (buf, "CP%s", pdot + 1);
else
{
/* The Windows API has a function returning the locale's codepage as a
number: GetACP().
When the output goes to a console window, it needs to be provided in
GetOEMCP() encoding if the console is using a raster font, or in
GetConsoleOutputCP() encoding if it is using a TrueType font.
But in GUI programs and for output sent to files and pipes, GetACP()
encoding is the best bet. */
sprintf (buf, "CP%u", GetACP ());
}
/* For a locale name such as "French_France.65001", in Windows 10,
setlocale now returns "French_France.utf8" instead. */
if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
codeset = "UTF-8";
else
codeset = buf;
# elif defined OS2
const char *locale;
static char buf[2 + 10 + 1];
ULONG cp[3];
ULONG cplen;
codeset = NULL;
/* Allow user to override the codeset, as set in the operating system,
with standard language environment variables. */
locale = getenv ("LC_ALL");
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG");
}
if (locale != NULL && locale[0] != '\0')
{
/* If the locale name contains an encoding after the dot, return it. */
const char *dot = strchr (locale, '.');
if (dot != NULL)
{
const char *modifier;
dot++;
/* Look for the possible @... trailer and remove it, if any. */
modifier = strchr (dot, '@');
if (modifier == NULL)
return dot;
if (modifier - dot < sizeof (buf))
{
memcpy (buf, dot, modifier - dot);
buf [modifier - dot] = '\0';
return buf;
}
}
/* For the POSIX locale, don't use the system's codepage. */
if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
codeset = "";
}
if (codeset == NULL)
{
/* OS/2 has a function returning the locale's codepage as a number. */
if (DosQueryCp (sizeof (cp), cp, &cplen))
codeset = "";
else
{
sprintf (buf, "CP%u", cp[0]);
codeset = buf;
}
}
# else
# error "Add code for other platforms here."
# endif
/* Resolve alias. */
{
# ifdef alias_table_defined
/* On some platforms, UTF-8 locales are the most frequently used ones.
Speed up the common case and slow down the less common cases by
testing for this case first. */
# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__
if (strcmp (codeset, "UTF-8") == 0)
goto done_table_lookup;
else
# endif
{
const struct table_entry * const table = alias_table;
size_t const table_size =
sizeof (alias_table) / sizeof (struct table_entry);
/* The table is sorted. Perform a binary search. */
size_t hi = table_size;
size_t lo = 0;
while (lo < hi)
{
/* Invariant:
for i < lo, strcmp (table[i].alias, codeset) < 0,
for i >= hi, strcmp (table[i].alias, codeset) > 0. */
size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
int cmp = strcmp (table[mid].alias, codeset);
if (cmp < 0)
lo = mid + 1;
else if (cmp > 0)
hi = mid;
else
{
/* Found an i with
strcmp (table[i].alias, codeset) == 0. */
codeset = table[mid].canonical;
goto done_table_lookup;
}
}
}
if (0)
done_table_lookup: ;
else
# endif
{
/* Did not find it in the table. */
/* On Mac OS X, all modern locales use the UTF-8 encoding.
BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
codeset = "UTF-8";
# else
/* Don't return an empty string. GNU libc and GNU libiconv interpret
the empty string as denoting "the locale's character encoding",
thus GNU libiconv would call this function a second time. */
if (codeset[0] == '\0')
codeset = "ASCII";
# endif
}
}
#else
/* On old systems which lack it, use setlocale or getenv. */
const char *locale = NULL;
/* But most old systems don't have a complete set of locales. Some
(like DJGPP) have only the C locale. Therefore we don't use setlocale
here; it would return "C" when it doesn't support the locale name the
user has set. */
# if 0
locale = setlocale (LC_CTYPE, NULL);
# endif
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_ALL");
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG");
if (locale == NULL)
locale = "";
}
}
/* Map locale name to canonical encoding name. */
{
# ifdef locale_table_defined
const struct table_entry * const table = locale_table;
size_t const table_size =
sizeof (locale_table) / sizeof (struct table_entry);
/* The table is sorted. Perform a binary search. */
size_t hi = table_size;
size_t lo = 0;
while (lo < hi)
{
/* Invariant:
for i < lo, strcmp (table[i].locale, locale) < 0,
for i >= hi, strcmp (table[i].locale, locale) > 0. */
size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
int cmp = strcmp (table[mid].locale, locale);
if (cmp < 0)
lo = mid + 1;
else if (cmp > 0)
hi = mid;
else
{
/* Found an i with
strcmp (table[i].locale, locale) == 0. */
codeset = table[mid].canonical;
goto done_table_lookup;
}
}
if (0)
done_table_lookup: ;
else
# endif
{
/* Did not find it in the table. */
/* On Mac OS X, all modern locales use the UTF-8 encoding.
BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
codeset = "UTF-8";
# else
/* The canonical name cannot be determined. */
/* Don't return an empty string. GNU libc and GNU libiconv interpret
the empty string as denoting "the locale's character encoding",
thus GNU libiconv would call this function a second time. */
codeset = "ASCII";
# endif
}
}
#endif
#ifdef DARWIN7
/* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
(the default codeset) does not work when MB_CUR_MAX is 1. */
if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1)
codeset = "ASCII";
#endif
return codeset;
}
gsasl-1.8.1/gl/quotearg.h 0000644 0000000 0000000 00000042034 13516251576 012141 0000000 0000000 /* quotearg.h - quote arguments for output
Copyright (C) 1998-2002, 2004, 2006, 2008-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* Written by Paul Eggert */
#ifndef QUOTEARG_H_
# define QUOTEARG_H_ 1
# include
/* Basic quoting styles. For each style, an example is given on the
input strings "simple", "\0 \t\n'\"\033?""?/\\", and "a:b", using
quotearg_buffer, quotearg_mem, and quotearg_colon_mem with that
style and the default flags and quoted characters. Note that the
examples are shown here as valid C strings rather than what
displays on a terminal (with "??/" as a trigraph for "\\"). */
enum quoting_style
{
/* Output names as-is (ls --quoting-style=literal). Can result in
embedded null bytes if QA_ELIDE_NULL_BYTES is not in
effect.
quotearg_buffer:
"simple", "\0 \t\n'\"\033??/\\", "a:b"
quotearg:
"simple", " \t\n'\"\033??/\\", "a:b"
quotearg_colon:
"simple", " \t\n'\"\033??/\\", "a:b"
*/
literal_quoting_style,
/* Quote names for the shell if they contain shell metacharacters
or would cause ambiguous output (ls --quoting-style=shell).
Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not
in effect.
quotearg_buffer:
"simple", "'\0 \t\n'\\''\"\033??/\\'", "a:b"
quotearg:
"simple", "' \t\n'\\''\"\033??/\\'", "a:b"
quotearg_colon:
"simple", "' \t\n'\\''\"\033??/\\'", "'a:b'"
*/
shell_quoting_style,
/* Quote names for the shell, even if they would normally not
require quoting (ls --quoting-style=shell-always). Can result
in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect.
Behaves like shell_quoting_style if QA_ELIDE_OUTER_QUOTES is in
effect.
quotearg_buffer:
"'simple'", "'\0 \t\n'\\''\"\033??/\\'", "'a:b'"
quotearg:
"'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
quotearg_colon:
"'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
*/
shell_always_quoting_style,
/* Quote names for the shell if they contain shell metacharacters
or other problematic characters (ls --quoting-style=shell-escape).
Non printable characters are quoted using the $'...' syntax,
which originated in ksh93 and is widely supported by most shells,
and proposed for inclusion in POSIX.
quotearg_buffer:
"simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b"
quotearg:
"simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b"
quotearg_colon:
"simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "'a:b'"
*/
shell_escape_quoting_style,
/* Quote names for the shell even if they would normally not
require quoting (ls --quoting-style=shell-escape).
Non printable characters are quoted using the $'...' syntax,
which originated in ksh93 and is widely supported by most shells,
and proposed for inclusion in POSIX. Behaves like
shell_escape_quoting_style if QA_ELIDE_OUTER_QUOTES is in effect.
quotearg_buffer:
"simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b"
quotearg:
"simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b"
quotearg_colon:
"simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "'a:b'"
*/
shell_escape_always_quoting_style,
/* Quote names as for a C language string (ls --quoting-style=c).
Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is
in effect. Split into consecutive strings if
QA_SPLIT_TRIGRAPHS.
quotearg_buffer:
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
quotearg:
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
quotearg_colon:
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
*/
c_quoting_style,
/* Like c_quoting_style except omit the surrounding double-quote
characters if no quoted characters are encountered.
quotearg_buffer:
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
quotearg:
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
quotearg_colon:
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
*/
c_maybe_quoting_style,
/* Like c_quoting_style except always omit the surrounding
double-quote characters and ignore QA_SPLIT_TRIGRAPHS
(ls --quoting-style=escape).
quotearg_buffer:
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
quotearg:
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
quotearg_colon:
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a\\:b"
*/
escape_quoting_style,
/* Like clocale_quoting_style, but use single quotes in the
default C locale or if the program does not use gettext
(ls --quoting-style=locale). For UTF-8 locales, quote
characters will use Unicode.
LC_MESSAGES=C
quotearg_buffer:
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
quotearg:
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
quotearg_colon:
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a\\:b'"
LC_MESSAGES=pt_PT.utf8
quotearg_buffer:
"\302\253simple\302\273",
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
quotearg:
"\302\253simple\302\273",
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
quotearg_colon:
"\302\253simple\302\273",
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
*/
locale_quoting_style,
/* Like c_quoting_style except use quotation marks appropriate for
the locale and ignore QA_SPLIT_TRIGRAPHS
(ls --quoting-style=clocale).
LC_MESSAGES=C
quotearg_buffer:
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
quotearg:
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
quotearg_colon:
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
LC_MESSAGES=pt_PT.utf8
quotearg_buffer:
"\302\253simple\302\273",
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
quotearg:
"\302\253simple\302\273",
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
quotearg_colon:
"\302\253simple\302\273",
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
*/
clocale_quoting_style,
/* Like clocale_quoting_style except use the custom quotation marks
set by set_custom_quoting. If custom quotation marks are not
set, the behavior is undefined.
left_quote = right_quote = "'"
quotearg_buffer:
"'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'"
quotearg:
"'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'"
quotearg_colon:
"'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a\\:b'"
left_quote = "(" and right_quote = ")"
quotearg_buffer:
"(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)"
quotearg:
"(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)"
quotearg_colon:
"(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a\\:b)"
left_quote = ":" and right_quote = " "
quotearg_buffer:
":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b "
quotearg:
":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b "
quotearg_colon:
":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a\\:b "
left_quote = "\"'" and right_quote = "'\""
Notice that this is treated as a single level of quotes or two
levels where the outer quote need not be escaped within the inner
quotes. For two levels where the outer quote must be escaped
within the inner quotes, you must use separate quotearg
invocations.
quotearg_buffer:
"\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\""
quotearg:
"\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\""
quotearg_colon:
"\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a\\:b'\""
*/
custom_quoting_style
};
/* Flags for use in set_quoting_flags. */
enum quoting_flags
{
/* Always elide null bytes from styles that do not quote them,
even when the length of the result is available to the
caller. */
QA_ELIDE_NULL_BYTES = 0x01,
/* Omit the surrounding quote characters if no escaped characters
are encountered. Note that if no other character needs
escaping, then neither does the escape character. */
QA_ELIDE_OUTER_QUOTES = 0x02,
/* In the c_quoting_style and c_maybe_quoting_style, split ANSI
trigraph sequences into concatenated strings (for example,
"?""?/" rather than "??/", which could be confused with
"\\"). */
QA_SPLIT_TRIGRAPHS = 0x04
};
/* For now, --quoting-style=literal is the default, but this may change. */
# ifndef DEFAULT_QUOTING_STYLE
# define DEFAULT_QUOTING_STYLE literal_quoting_style
# endif
/* Names of quoting styles and their corresponding values. */
extern char const *const quoting_style_args[];
extern enum quoting_style const quoting_style_vals[];
struct quoting_options;
/* The functions listed below set and use a hidden variable
that contains the default quoting style options. */
/* Allocate a new set of quoting options, with contents initially identical
to O if O is not null, or to the default if O is null.
It is the caller's responsibility to free the result. */
struct quoting_options *clone_quoting_options (struct quoting_options *o);
/* Get the value of O's quoting style. If O is null, use the default. */
enum quoting_style get_quoting_style (struct quoting_options const *o);
/* In O (or in the default if O is null),
set the value of the quoting style to S. */
void set_quoting_style (struct quoting_options *o, enum quoting_style s);
/* In O (or in the default if O is null),
set the value of the quoting options for character C to I.
Return the old value. Currently, the only values defined for I are
0 (the default) and 1 (which means to quote the character even if
it would not otherwise be quoted). C must never be a digit or a
letter that has special meaning after a backslash (for example, "\t"
for tab). */
int set_char_quoting (struct quoting_options *o, char c, int i);
/* In O (or in the default if O is null),
set the value of the quoting options flag to I, which can be a
bitwise combination of enum quoting_flags, or 0 for default
behavior. Return the old value. */
int set_quoting_flags (struct quoting_options *o, int i);
/* In O (or in the default if O is null),
set the value of the quoting style to custom_quoting_style,
set the left quote to LEFT_QUOTE, and set the right quote to
RIGHT_QUOTE. Each of LEFT_QUOTE and RIGHT_QUOTE must be
null-terminated and can be the empty string. Because backslashes are
used for escaping, it does not make sense for RIGHT_QUOTE to contain
a backslash. RIGHT_QUOTE must not begin with a digit or a letter
that has special meaning after a backslash (for example, "\t" for
tab). */
void set_custom_quoting (struct quoting_options *o,
char const *left_quote,
char const *right_quote);
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
argument ARG (of size ARGSIZE), using O to control quoting.
If O is null, use the default.
Terminate the output with a null character, and return the written
size of the output, not counting the terminating null.
If BUFFERSIZE is too small to store the output string, return the
value that would have been returned had BUFFERSIZE been large enough.
If ARGSIZE is -1, use the string length of the argument for ARGSIZE.
On output, BUFFER might contain embedded null bytes if ARGSIZE was
not -1, the style of O does not use backslash escapes, and the
flags of O do not request elision of null bytes.*/
size_t quotearg_buffer (char *buffer, size_t buffersize,
char const *arg, size_t argsize,
struct quoting_options const *o);
/* Like quotearg_buffer, except return the result in a newly allocated
buffer. It is the caller's responsibility to free the result. The
result will not contain embedded null bytes. */
char *quotearg_alloc (char const *arg, size_t argsize,
struct quoting_options const *o);
/* Like quotearg_alloc, except that the length of the result,
excluding the terminating null byte, is stored into SIZE if it is
non-NULL. The result might contain embedded null bytes if ARGSIZE
was not -1, SIZE was not NULL, the style of O does not use
backslash escapes, and the flags of O do not request elision of
null bytes.*/
char *quotearg_alloc_mem (char const *arg, size_t argsize,
size_t *size, struct quoting_options const *o);
/* Use storage slot N to return a quoted version of the string ARG.
Use the default quoting options.
The returned value points to static storage that can be
reused by the next call to this function with the same value of N.
N must be nonnegative. The output of all functions in the
quotearg_n family are guaranteed to not contain embedded null
bytes.*/
char *quotearg_n (int n, char const *arg);
/* Equivalent to quotearg_n (0, ARG). */
char *quotearg (char const *arg);
/* Use storage slot N to return a quoted version of the argument ARG
of size ARGSIZE. This is like quotearg_n (N, ARG), except it can
quote null bytes. */
char *quotearg_n_mem (int n, char const *arg, size_t argsize);
/* Equivalent to quotearg_n_mem (0, ARG, ARGSIZE). */
char *quotearg_mem (char const *arg, size_t argsize);
/* Use style S and storage slot N to return a quoted version of the string ARG.
This is like quotearg_n (N, ARG), except that it uses S with no other
options to specify the quoting method. */
char *quotearg_n_style (int n, enum quoting_style s, char const *arg);
/* Use style S and storage slot N to return a quoted version of the
argument ARG of size ARGSIZE. This is like quotearg_n_style
(N, S, ARG), except it can quote null bytes. */
char *quotearg_n_style_mem (int n, enum quoting_style s,
char const *arg, size_t argsize);
/* Equivalent to quotearg_n_style (0, S, ARG). */
char *quotearg_style (enum quoting_style s, char const *arg);
/* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */
char *quotearg_style_mem (enum quoting_style s,
char const *arg, size_t argsize);
/* Like quotearg (ARG), except also quote any instances of CH.
See set_char_quoting for a description of acceptable CH values. */
char *quotearg_char (char const *arg, char ch);
/* Like quotearg_char (ARG, CH), except it can quote null bytes. */
char *quotearg_char_mem (char const *arg, size_t argsize, char ch);
/* Equivalent to quotearg_char (ARG, ':'). */
char *quotearg_colon (char const *arg);
/* Like quotearg_colon (ARG), except it can quote null bytes. */
char *quotearg_colon_mem (char const *arg, size_t argsize);
/* Like quotearg_n_style, except with ':' quoting enabled. */
char *quotearg_n_style_colon (int n, enum quoting_style s, char const *arg);
/* Like quotearg_n_style (N, S, ARG) but with S as custom_quoting_style
with left quote as LEFT_QUOTE and right quote as RIGHT_QUOTE. See
set_custom_quoting for a description of acceptable LEFT_QUOTE and
RIGHT_QUOTE values. */
char *quotearg_n_custom (int n, char const *left_quote,
char const *right_quote, char const *arg);
/* Like quotearg_n_custom (N, LEFT_QUOTE, RIGHT_QUOTE, ARG) except it
can quote null bytes. */
char *quotearg_n_custom_mem (int n, char const *left_quote,
char const *right_quote,
char const *arg, size_t argsize);
/* Equivalent to quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG). */
char *quotearg_custom (char const *left_quote, char const *right_quote,
char const *arg);
/* Equivalent to quotearg_n_custom_mem (0, LEFT_QUOTE, RIGHT_QUOTE, ARG,
ARGSIZE). */
char *quotearg_custom_mem (char const *left_quote,
char const *right_quote,
char const *arg, size_t argsize);
/* Free any dynamically allocated memory. */
void quotearg_free (void);
#endif /* !QUOTEARG_H_ */
gsasl-1.8.1/gl/getopt-core.h 0000644 0000000 0000000 00000007103 13516251573 012535 0000000 0000000 /* Declarations for getopt (basic, portable features only).
Copyright (C) 1989-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
. */
#ifndef _GETOPT_CORE_H
#define _GETOPT_CORE_H 1
/* This header should not be used directly; include getopt.h or
unistd.h instead. Unlike most bits headers, it does not have
a protective #error, because the guard macro for getopt.h in
gnulib is not fixed. */
__BEGIN_DECLS
/* For communication from 'getopt' to the caller.
When 'getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when 'ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to 'getopt'.
On entry to 'getopt', zero means this is the first call; initialize.
When 'getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, 'optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message 'getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, 'optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in 'optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU 'getopt'.
The argument '--' causes premature termination of argument
scanning, explicitly telling 'getopt' that there are no more
options.
If OPTS begins with '-', then non-option arguments are treated as
arguments to the option '\1'. This behavior is specific to the GNU
'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
the environment, then do not permute arguments.
For standards compliance, the 'argv' argument has the type
char *const *, but this is inaccurate; if argument permutation is
enabled, the argv array (not the strings it points to) must be
writable. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
__THROW _GL_ARG_NONNULL ((2, 3));
__END_DECLS
#endif /* _GETOPT_CORE_H */
gsasl-1.8.1/gl/inet_ntop.c 0000644 0000000 0000000 00000015347 13516251575 012312 0000000 0000000 /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include
/* Specification. */
#include
/* Use this to suppress gcc's "...may be used before initialized" warnings.
Beware: The Code argument must not contain commas. */
#ifndef IF_LINT
# if defined GCC_LINT || defined lint
# define IF_LINT(Code) Code
# else
# define IF_LINT(Code) /* empty */
# endif
#endif
#if HAVE_DECL_INET_NTOP
# undef inet_ntop
const char *
rpl_inet_ntop (int af, const void *restrict src,
char *restrict dst, socklen_t cnt)
{
return inet_ntop (af, src, dst, cnt);
}
#else
# include
# include
# include
# define NS_IN6ADDRSZ 16
# define NS_INT16SZ 2
/*
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1];
static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size);
# if HAVE_IPV6
static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size);
# endif
/* char *
* inet_ntop(af, src, dst, size)
* convert a network format address to presentation format.
* return:
* pointer to presentation format address ('dst'), or NULL (see errno).
* author:
* Paul Vixie, 1996.
*/
const char *
inet_ntop (int af, const void *restrict src,
char *restrict dst, socklen_t cnt)
{
switch (af)
{
# if HAVE_IPV4
case AF_INET:
return (inet_ntop4 (src, dst, cnt));
# endif
# if HAVE_IPV6
case AF_INET6:
return (inet_ntop6 (src, dst, cnt));
# endif
default:
errno = EAFNOSUPPORT;
return (NULL);
}
/* NOTREACHED */
}
/* const char *
* inet_ntop4(src, dst, size)
* format an IPv4 address
* return:
* 'dst' (as a const)
* notes:
* (1) uses no statics
* (2) takes a u_char* not an in_addr as input
* author:
* Paul Vixie, 1996.
*/
static const char *
inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
{
char tmp[sizeof "255.255.255.255"];
int len;
len = sprintf (tmp, "%u.%u.%u.%u", src[0], src[1], src[2], src[3]);
if (len < 0)
return NULL;
if (len > size)
{
errno = ENOSPC;
return NULL;
}
return strcpy (dst, tmp);
}
# if HAVE_IPV6
/* const char *
* inet_ntop6(src, dst, size)
* convert IPv6 binary address into presentation (printable) format
* author:
* Paul Vixie, 1996.
*/
static const char *
inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
* to contain a value of the specified size. On some systems, like
* Crays, there is no such thing as an integer variable with 16 bits.
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
struct
{
int base, len;
} best, cur;
unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
/*
* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset (words, '\0', sizeof words);
for (i = 0; i < NS_IN6ADDRSZ; i += 2)
words[i / 2] = (src[i] << 8) | src[i + 1];
best.base = -1;
cur.base = -1;
IF_LINT(best.len = 0);
IF_LINT(cur.len = 0);
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{
if (words[i] == 0)
{
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
}
else
{
if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
}
if (best.base != -1 && best.len < 2)
best.base = -1;
/*
* Format the result.
*/
tp = tmp;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{
if (i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
return (NULL);
tp += strlen (tp);
break;
}
{
int len = sprintf (tp, "%x", words[i]);
if (len < 0)
return NULL;
tp += len;
}
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/*
* Check for overflow, copy, and we're done.
*/
if ((socklen_t) (tp - tmp) > size)
{
errno = ENOSPC;
return NULL;
}
return strcpy (dst, tmp);
}
# endif
#endif
gsasl-1.8.1/gl/striconv.c 0000644 0000000 0000000 00000031200 13516251577 012146 0000000 0000000 /* Charset conversion.
Copyright (C) 2001-2007, 2010-2019 Free Software Foundation, Inc.
Written by Bruno Haible and Simon Josefsson.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
#include
/* Specification. */
#include "striconv.h"
#include
#include
#include
#if HAVE_ICONV
# include
/* Get MB_LEN_MAX, CHAR_BIT. */
# include
#endif
#include "c-strcase.h"
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#endif
#if HAVE_ICONV
int
mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
char **resultp, size_t *lengthp)
{
# define tmpbufsize 4096
size_t length;
char *result;
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|| defined __sun)
/* Set to the initial state. */
iconv (cd, NULL, NULL, NULL, NULL);
# endif
/* Determine the length we need. */
{
size_t count = 0;
/* The alignment is needed when converting e.g. to glibc's WCHAR_T or
libiconv's UCS-4-INTERNAL encoding. */
union { unsigned int align; char buf[tmpbufsize]; } tmp;
# define tmpbuf tmp.buf
const char *inptr = src;
size_t insize = srclen;
while (insize > 0)
{
char *outptr = tmpbuf;
size_t outsize = tmpbufsize;
size_t res = iconv (cd,
(ICONV_CONST char **) &inptr, &insize,
&outptr, &outsize);
if (res == (size_t)(-1))
{
if (errno == E2BIG)
;
else if (errno == EINVAL)
break;
else
return -1;
}
# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
/* Irix iconv() inserts a NUL byte if it cannot convert.
NetBSD iconv() inserts a question mark if it cannot convert.
Only GNU libiconv and GNU libc are known to prefer to fail rather
than doing a lossy conversion. */
else if (res > 0)
{
errno = EILSEQ;
return -1;
}
# endif
count += outptr - tmpbuf;
}
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
# if defined _LIBICONV_VERSION \
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|| defined __sun)
{
char *outptr = tmpbuf;
size_t outsize = tmpbufsize;
size_t res = iconv (cd, NULL, NULL, &outptr, &outsize);
if (res == (size_t)(-1))
return -1;
count += outptr - tmpbuf;
}
# endif
length = count;
# undef tmpbuf
}
if (length == 0)
{
*lengthp = 0;
return 0;
}
if (*resultp != NULL && *lengthp >= length)
result = *resultp;
else
{
result = (char *) malloc (length);
if (result == NULL)
{
errno = ENOMEM;
return -1;
}
}
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|| defined __sun)
/* Return to the initial state. */
iconv (cd, NULL, NULL, NULL, NULL);
# endif
/* Do the conversion for real. */
{
const char *inptr = src;
size_t insize = srclen;
char *outptr = result;
size_t outsize = length;
while (insize > 0)
{
size_t res = iconv (cd,
(ICONV_CONST char **) &inptr, &insize,
&outptr, &outsize);
if (res == (size_t)(-1))
{
if (errno == EINVAL)
break;
else
goto fail;
}
# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
/* Irix iconv() inserts a NUL byte if it cannot convert.
NetBSD iconv() inserts a question mark if it cannot convert.
Only GNU libiconv and GNU libc are known to prefer to fail rather
than doing a lossy conversion. */
else if (res > 0)
{
errno = EILSEQ;
goto fail;
}
# endif
}
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
# if defined _LIBICONV_VERSION \
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|| defined __sun)
{
size_t res = iconv (cd, NULL, NULL, &outptr, &outsize);
if (res == (size_t)(-1))
goto fail;
}
# endif
if (outsize != 0)
abort ();
}
*resultp = result;
*lengthp = length;
return 0;
fail:
{
if (result != *resultp)
{
int saved_errno = errno;
free (result);
errno = saved_errno;
}
return -1;
}
# undef tmpbufsize
}
char *
str_cd_iconv (const char *src, iconv_t cd)
{
/* For most encodings, a trailing NUL byte in the input will be converted
to a trailing NUL byte in the output. But not for UTF-7. So that this
function is usable for UTF-7, we have to exclude the NUL byte from the
conversion and add it by hand afterwards. */
# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
/* Irix iconv() inserts a NUL byte if it cannot convert.
NetBSD iconv() inserts a question mark if it cannot convert.
Only GNU libiconv and GNU libc are known to prefer to fail rather
than doing a lossy conversion. For other iconv() implementations,
we have to look at the number of irreversible conversions returned;
but this information is lost when iconv() returns for an E2BIG reason.
Therefore we cannot use the second, faster algorithm. */
char *result = NULL;
size_t length = 0;
int retval = mem_cd_iconv (src, strlen (src), cd, &result, &length);
char *final_result;
if (retval < 0)
{
if (result != NULL)
abort ();
return NULL;
}
/* Add the terminating NUL byte. */
final_result =
(result != NULL ? realloc (result, length + 1) : malloc (length + 1));
if (final_result == NULL)
{
free (result);
errno = ENOMEM;
return NULL;
}
final_result[length] = '\0';
return final_result;
# else
/* This algorithm is likely faster than the one above. But it may produce
iconv() returns for an E2BIG reason, when the output size guess is too
small. Therefore it can only be used when we don't need the number of
irreversible conversions performed. */
char *result;
size_t result_size;
size_t length;
const char *inptr = src;
size_t inbytes_remaining = strlen (src);
/* Make a guess for the worst-case output size, in order to avoid a
realloc. It's OK if the guess is wrong as long as it is not zero and
doesn't lead to an integer overflow. */
result_size = inbytes_remaining;
{
size_t approx_sqrt_SIZE_MAX = SIZE_MAX >> (sizeof (size_t) * CHAR_BIT / 2);
if (result_size <= approx_sqrt_SIZE_MAX / MB_LEN_MAX)
result_size *= MB_LEN_MAX;
}
result_size += 1; /* for the terminating NUL */
result = (char *) malloc (result_size);
if (result == NULL)
{
errno = ENOMEM;
return NULL;
}
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
# if defined _LIBICONV_VERSION \
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|| defined __sun)
/* Set to the initial state. */
iconv (cd, NULL, NULL, NULL, NULL);
# endif
/* Do the conversion. */
{
char *outptr = result;
size_t outbytes_remaining = result_size - 1;
for (;;)
{
/* Here inptr + inbytes_remaining = src + strlen (src),
outptr + outbytes_remaining = result + result_size - 1. */
size_t res = iconv (cd,
(ICONV_CONST char **) &inptr, &inbytes_remaining,
&outptr, &outbytes_remaining);
if (res == (size_t)(-1))
{
if (errno == EINVAL)
break;
else if (errno == E2BIG)
{
size_t used = outptr - result;
size_t newsize = result_size * 2;
char *newresult;
if (!(newsize > result_size))
{
errno = ENOMEM;
goto failed;
}
newresult = (char *) realloc (result, newsize);
if (newresult == NULL)
{
errno = ENOMEM;
goto failed;
}
result = newresult;
result_size = newsize;
outptr = result + used;
outbytes_remaining = result_size - 1 - used;
}
else
goto failed;
}
else
break;
}
/* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
# if defined _LIBICONV_VERSION \
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|| defined __sun)
for (;;)
{
/* Here outptr + outbytes_remaining = result + result_size - 1. */
size_t res = iconv (cd, NULL, NULL, &outptr, &outbytes_remaining);
if (res == (size_t)(-1))
{
if (errno == E2BIG)
{
size_t used = outptr - result;
size_t newsize = result_size * 2;
char *newresult;
if (!(newsize > result_size))
{
errno = ENOMEM;
goto failed;
}
newresult = (char *) realloc (result, newsize);
if (newresult == NULL)
{
errno = ENOMEM;
goto failed;
}
result = newresult;
result_size = newsize;
outptr = result + used;
outbytes_remaining = result_size - 1 - used;
}
else
goto failed;
}
else
break;
}
# endif
/* Add the terminating NUL byte. */
*outptr++ = '\0';
length = outptr - result;
}
/* Give away unused memory. */
if (length < result_size)
{
char *smaller_result = (char *) realloc (result, length);
if (smaller_result != NULL)
result = smaller_result;
}
return result;
failed:
{
int saved_errno = errno;
free (result);
errno = saved_errno;
return NULL;
}
# endif
}
#endif
char *
str_iconv (const char *src, const char *from_codeset, const char *to_codeset)
{
if (*src == '\0' || c_strcasecmp (from_codeset, to_codeset) == 0)
{
char *result = strdup (src);
if (result == NULL)
errno = ENOMEM;
return result;
}
else
{
#if HAVE_ICONV
iconv_t cd;
char *result;
/* Avoid glibc-2.1 bug with EUC-KR. */
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
&& !defined _LIBICONV_VERSION
if (c_strcasecmp (from_codeset, "EUC-KR") == 0
|| c_strcasecmp (to_codeset, "EUC-KR") == 0)
{
errno = EINVAL;
return NULL;
}
# endif
cd = iconv_open (to_codeset, from_codeset);
if (cd == (iconv_t) -1)
return NULL;
result = str_cd_iconv (src, cd);
if (result == NULL)
{
/* Close cd, but preserve the errno from str_cd_iconv. */
int saved_errno = errno;
iconv_close (cd);
errno = saved_errno;
}
else
{
if (iconv_close (cd) < 0)
{
/* Return NULL, but free the allocated memory, and while doing
that, preserve the errno from iconv_close. */
int saved_errno = errno;
free (result);
errno = saved_errno;
return NULL;
}
}
return result;
#else
/* This is a different error code than if iconv_open existed but didn't
support from_codeset and to_codeset, so that the caller can emit
an error message such as
"iconv() is not supported. Installing GNU libiconv and
then reinstalling this package would fix this." */
errno = ENOSYS;
return NULL;
#endif
}
}
gsasl-1.8.1/gl/vasprintf.c 0000644 0000000 0000000 00000002473 13516251577 012325 0000000 0000000 /* Formatted output to strings.
Copyright (C) 1999, 2002, 2006-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
#include
/* Specification. */
#ifdef IN_LIBASPRINTF
# include "vasprintf.h"
#else
# include
#endif
#include
#include
#include
#include "vasnprintf.h"
int
vasprintf (char **resultp, const char *format, va_list args)
{
size_t length;
char *result = vasnprintf (NULL, &length, format, args);
if (result == NULL)
return -1;
if (length > INT_MAX)
{
free (result);
errno = EOVERFLOW;
return -1;
}
*resultp = result;
/* Return the number of resulting bytes, excluding the trailing NUL. */
return length;
}
gsasl-1.8.1/gl/arg-nonnull.h 0000644 0000000 0000000 00000002301 13516251573 012534 0000000 0000000 /* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers.
n = 1 stands for the first argument, n = 2 for the second argument etc. */
#ifndef _GL_ARG_NONNULL
# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
# else
# define _GL_ARG_NONNULL(params)
# endif
#endif
gsasl-1.8.1/gl/stdio-impl.h 0000644 0000000 0000000 00000017270 13516251577 012400 0000000 0000000 /* Implementation details of FILE streams.
Copyright (C) 2007-2008, 2010-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* Many stdio implementations have the same logic and therefore can share
the same implementation of stdio extension API, except that some fields
have different naming conventions, or their access requires some casts. */
/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
problem by defining it ourselves. FIXME: Do not rely on glibc
internals. */
#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
# define _IO_IN_BACKUP 0x100
#endif
/* BSD stdio derived implementations. */
#if defined __NetBSD__ /* NetBSD */
/* Get __NetBSD_Version__. */
# include
#endif
#include /* For detecting Plan9. */
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
# if defined __DragonFly__ /* DragonFly */
/* See . */
# define fp_ ((struct { struct __FILE_public pub; \
struct { unsigned char *_base; int _size; } _bf; \
void *cookie; \
void *_close; \
void *_read; \
void *_seek; \
void *_write; \
struct { unsigned char *_base; int _size; } _ub; \
int _ur; \
unsigned char _ubuf[3]; \
unsigned char _nbuf[1]; \
struct { unsigned char *_base; int _size; } _lb; \
int _blksize; \
fpos_t _offset; \
/* More fields, not relevant here. */ \
} *) fp)
/* See . */
# define _p pub._p
# define _flags pub._flags
# define _r pub._r
# define _w pub._w
# elif defined __ANDROID__ /* Android */
# ifdef __LP64__
# define _gl_flags_file_t int
# else
# define _gl_flags_file_t short
# endif
/* Up to this commit from 2015-10-12
the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
see
and .
After this commit, the innards of FILE are hidden. */
# define fp_ ((struct { unsigned char *_p; \
int _r; \
int _w; \
_gl_flags_file_t _flags; \
_gl_flags_file_t _file; \
struct { unsigned char *_base; size_t _size; } _bf; \
int _lbfsize; \
void *_cookie; \
void *_close; \
void *_read; \
void *_seek; \
void *_write; \
struct { unsigned char *_base; size_t _size; } _ext; \
unsigned char *_up; \
int _ur; \
unsigned char _ubuf[3]; \
unsigned char _nbuf[1]; \
struct { unsigned char *_base; size_t _size; } _lb; \
int _blksize; \
fpos_t _offset; \
/* More fields, not relevant here. */ \
} *) fp)
# else
# define fp_ fp
# endif
# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
/* See
and
and */
struct __sfileext
{
struct __sbuf _ub; /* ungetc buffer */
/* More fields, not relevant here. */
};
# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
# elif defined __ANDROID__ /* Android */
struct __sfileext
{
struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
/* More fields, not relevant here. */
};
# define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub
# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
# define fp_ub fp_->_ub
# endif
# define HASUB(fp) (fp_ub._base != NULL)
# if defined __ANDROID__ /* Android */
/* Needed after this commit from 2016-01-25
*/
# ifndef __SEOF
# define __SLBF 1
# define __SNBF 2
# define __SRD 4
# define __SWR 8
# define __SRW 0x10
# define __SEOF 0x20
# define __SERR 0x40
# endif
# ifndef __SOFF
# define __SOFF 0x1000
# endif
# endif
#endif
/* SystemV derived implementations. */
#ifdef __TANDEM /* NonStop Kernel */
# ifndef _IOERR
/* These values were determined by the program 'stdioext-flags' at
. */
# define _IOERR 0x40
# define _IOREAD 0x80
# define _IOWRT 0x4
# define _IORW 0x100
# endif
#endif
#if defined _IOERR
# if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
# define fp_ ((struct { unsigned char *_ptr; \
unsigned char *_base; \
unsigned char *_end; \
long _cnt; \
int _file; \
unsigned int _flag; \
} *) fp)
# elif defined __VMS /* OpenVMS */
# define fp_ ((struct _iobuf *) fp)
# else
# define fp_ fp
# endif
# if defined _SCO_DS /* OpenServer */
# define _cnt __cnt
# define _ptr __ptr
# define _base __base
# define _flag __flag
# endif
#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */
/* does not define the innards of FILE any more. */
# define WINDOWS_OPAQUE_FILE
struct _gl_real_FILE
{
/* Note: Compared to older Windows and to mingw, it has the fields
_base and _cnt swapped. */
unsigned char *_ptr;
unsigned char *_base;
int _cnt;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
};
# define fp_ ((struct _gl_real_FILE *) fp)
/* These values were determined by a program similar to the one at
. */
# define _IOREAD 0x1
# define _IOWRT 0x2
# define _IORW 0x4
# define _IOEOF 0x8
# define _IOERR 0x10
#endif
gsasl-1.8.1/gl/gettext.h 0000644 0000000 0000000 00000024764 13516251574 012006 0000000 0000000 /* Convenience header for conditional use of GNU .
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
/* NLS can be disabled through the configure --disable-nls option
or through "#define ENABLE NLS 0" before including this file. */
#if defined ENABLE_NLS && ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include
/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
the gettext() and ngettext() macros. This is an alternative to calling
textdomain(), and is useful for libraries. */
# ifdef DEFAULT_TEXT_DOMAIN
# undef gettext
# define gettext(Msgid) \
dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
# undef ngettext
# define ngettext(Msgid1, Msgid2, N) \
dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
# endif
#else
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
chokes if dcgettext is defined as a macro. So include it now, to make
later inclusions of a NOP. We don't include
as well because people using "gettext.h" will not include ,
and also including would fail on SunOS 4, whereas
is OK. */
#if defined(__sun)
# include
#endif
/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
, which chokes if dcgettext is defined as a macro. So include
it now, to make later inclusions of a NOP. */
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
# include
# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
# include
# endif
#endif
/* Disabled NLS.
The casts to 'const char *' serve the purpose of producing warnings
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
# undef gettext
# define gettext(Msgid) ((const char *) (Msgid))
# undef dgettext
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
# undef dcgettext
# define dcgettext(Domainname, Msgid, Category) \
((void) (Category), dgettext (Domainname, Msgid))
# undef ngettext
# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 \
? ((void) (Msgid2), (const char *) (Msgid1)) \
: ((void) (Msgid1), (const char *) (Msgid2)))
# undef dngettext
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
# undef dcngettext
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
# undef textdomain
# define textdomain(Domainname) ((const char *) (Domainname))
# undef bindtextdomain
# define bindtextdomain(Domainname, Dirname) \
((void) (Domainname), (const char *) (Dirname))
# undef bind_textdomain_codeset
# define bind_textdomain_codeset(Domainname, Codeset) \
((void) (Domainname), (const char *) (Codeset))
#endif
/* Prefer gnulib's setlocale override over libintl's setlocale override. */
#ifdef GNULIB_defined_setlocale
# undef setlocale
# define setlocale rpl_setlocale
#endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code.
The argument, String, should be a literal string. Concatenated strings
and other string expressions won't work.
The macro's expansion is not parenthesized, so that it is suitable as
initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String
/* The separator between msgctxt and msgid in a .mo file. */
#define GETTEXT_CONTEXT_GLUE "\004"
/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
short and rarely need to change.
The letter 'p' stands for 'particular' or 'special'. */
#ifdef DEFAULT_TEXT_DOMAIN
# define pgettext(Msgctxt, Msgid) \
pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#else
# define pgettext(Msgctxt, Msgid) \
pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#endif
#define dpgettext(Domainname, Msgctxt, Msgid) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
#ifdef DEFAULT_TEXT_DOMAIN
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#else
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#endif
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
pgettext_aux (const char *domain,
const char *msg_ctxt_id, const char *msgid,
int category)
{
const char *translation = dcgettext (domain, msg_ctxt_id, category);
if (translation == msg_ctxt_id)
return msgid;
else
return translation;
}
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
npgettext_aux (const char *domain,
const char *msg_ctxt_id, const char *msgid,
const char *msgid_plural, unsigned long int n,
int category)
{
const char *translation =
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
if (translation == msg_ctxt_id || translation == msgid_plural)
return (n == 1 ? msgid : msgid_plural);
else
return translation;
}
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
can be arbitrary expressions. But for string literals these macros are
less efficient than those above. */
#include
/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
the default GCC many warnings set. This allows programs to disable use
of VLAs, which may be unintended, or may be awkward to support portably,
or may have security implications due to non-deterministic stack usage. */
#if (!defined GNULIB_NO_VLA \
&& (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
/* || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
|| (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
#endif
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include
#endif
#define pgettext_expr(Msgctxt, Msgid) \
dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
dcpgettext_expr (const char *domain,
const char *msgctxt, const char *msgid,
int category)
{
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
char *msg_ctxt_id =
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
if (msg_ctxt_id != NULL)
#endif
{
int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcgettext (domain, msg_ctxt_id, category);
found_translation = (translation != msg_ctxt_id);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
if (found_translation)
return translation;
}
return msgid;
}
#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
dcnpgettext_expr (const char *domain,
const char *msgctxt, const char *msgid,
const char *msgid_plural, unsigned long int n,
int category)
{
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
char *msg_ctxt_id =
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
if (msg_ctxt_id != NULL)
#endif
{
int found_translation;
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
if (found_translation)
return translation;
}
return (n == 1 ? msgid : msgid_plural);
}
#endif /* _LIBGETTEXT_H */
gsasl-1.8.1/gl/minmax.h 0000644 0000000 0000000 00000004471 13516251573 011603 0000000 0000000 /* MIN, MAX macros.
Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2019 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
#ifndef _MINMAX_H
#define _MINMAX_H
/* Note: MIN, MAX are also defined in on some systems
(glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
MIN, MAX macro redefinitions on some systems; the workaround is to
#include this file as the last one among the #include list. */
/* Before we define the following symbols we get the file
since otherwise we get redefinitions on some systems if is
included after this file. Likewise for .
If more than one of these system headers define MIN and MAX, pick just
one of the headers (because the definitions most likely are the same). */
#if HAVE_MINMAX_IN_LIMITS_H
# include
#elif HAVE_MINMAX_IN_SYS_PARAM_H
# include
#endif
/* Note: MIN and MAX should be used with two arguments of the
same type. They might not return the minimum and maximum of their two
arguments, if the arguments have different types or have unusual
floating-point values. For example, on a typical host with 32-bit 'int',
64-bit 'long long', and 64-bit IEEE 754 'double' types:
MAX (-1, 2147483648) returns 4294967295.
MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
MAX (NaN, 0.0) returns 0.0.
MAX (+0.0, -0.0) returns -0.0.
and in each case the answer is in some sense bogus. */
/* MAX(a,b) returns the maximum of A and B. */
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
/* MIN(a,b) returns the minimum of A and B. */
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#endif /* _MINMAX_H */
gsasl-1.8.1/gl/iconv_open-osf.gperf 0000644 0000000 0000000 00000003315 13516251574 014107 0000000 0000000 /* Character set conversion.
Copyright (C) 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
struct mapping { int standard_name; const char vendor_name[10 + 1]; };
%struct-type
%language=ANSI-C
%define slot-name standard_name
%define hash-function-name mapping_hash
%define lookup-function-name mapping_lookup
%readonly-tables
%global-table
%define word-array-name mappings
%pic
%%
# On OSF/1 5.1, look in /usr/lib/nls/loc/iconv.
ISO-8859-1, "ISO8859-1"
ISO-8859-2, "ISO8859-2"
ISO-8859-3, "ISO8859-3"
ISO-8859-4, "ISO8859-4"
ISO-8859-5, "ISO8859-5"
ISO-8859-6, "ISO8859-6"
ISO-8859-7, "ISO8859-7"
ISO-8859-8, "ISO8859-8"
ISO-8859-9, "ISO8859-9"
ISO-8859-15, "ISO8859-15"
CP437, "cp437"
CP775, "cp775"
CP850, "cp850"
CP852, "cp852"
CP855, "cp855"
CP857, "cp857"
CP861, "cp861"
CP862, "cp862"
CP865, "cp865"
CP866, "cp866"
CP869, "cp869"
CP874, "cp874"
CP949, "KSC5601"
CP1250, "cp1250"
CP1251, "cp1251"
CP1252, "cp1252"
CP1253, "cp1253"
CP1254, "cp1254"
CP1255, "cp1255"
CP1256, "cp1256"
CP1257, "cp1257"
CP1258, "cp1258"
EUC-JP, "eucJP"
EUC-KR, "eucKR"
EUC-TW, "eucTW"
BIG5, "big5"
SHIFT_JIS, "SJIS"
TIS-620, "TACTIS"
gsasl-1.8.1/gl/stat-w32.h 0000644 0000000 0000000 00000003066 13516251573 011675 0000000 0000000 /* Core of implementation of fstat and stat for native Windows.
Copyright (C) 2017-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#ifndef _STAT_W32_H
#define _STAT_W32_H 1
/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
#if _GL_WINDOWS_STAT_TIMESPEC
extern struct timespec _gl_convert_FILETIME_to_timespec (const FILETIME *ft);
#else
extern time_t _gl_convert_FILETIME_to_POSIX (const FILETIME *ft);
#endif
/* Fill *BUF with information about the file designated by H.
PATH is the file name, if known, otherwise NULL.
Return 0 if successful, or -1 with errno set upon failure. */
extern int _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf);
/* Bitmasks for st_mode. */
#define S_IREAD_UGO (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
#define S_IWRITE_UGO (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
#define S_IEXEC_UGO (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6))
#endif /* _STAT_W32_H */
gsasl-1.8.1/gl/windows-mutex.c 0000644 0000000 0000000 00000005177 13516251573 013143 0000000 0000000 /* Plain mutexes (native Windows implementation).
Copyright (C) 2005-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
/* Written by Bruno Haible , 2005.
Based on GCC's gthr-win32.h. */
#include
/* Specification. */
#include "windows-mutex.h"
#include
void
glwthread_mutex_init (glwthread_mutex_t *mutex)
{
InitializeCriticalSection (&mutex->lock);
mutex->guard.done = 1;
}
int
glwthread_mutex_lock (glwthread_mutex_t *mutex)
{
if (!mutex->guard.done)
{
if (InterlockedIncrement (&mutex->guard.started) == 0)
/* This thread is the first one to need this mutex. Initialize it. */
glwthread_mutex_init (mutex);
else
{
/* Don't let mutex->guard.started grow and wrap around. */
InterlockedDecrement (&mutex->guard.started);
/* Yield the CPU while waiting for another thread to finish
initializing this mutex. */
while (!mutex->guard.done)
Sleep (0);
}
}
EnterCriticalSection (&mutex->lock);
return 0;
}
int
glwthread_mutex_trylock (glwthread_mutex_t *mutex)
{
if (!mutex->guard.done)
{
if (InterlockedIncrement (&mutex->guard.started) == 0)
/* This thread is the first one to need this mutex. Initialize it. */
glwthread_mutex_init (mutex);
else
{
/* Don't let mutex->guard.started grow and wrap around. */
InterlockedDecrement (&mutex->guard.started);
/* Let another thread finish initializing this mutex, and let it also
lock this mutex. */
return EBUSY;
}
}
if (!TryEnterCriticalSection (&mutex->lock))
return EBUSY;
return 0;
}
int
glwthread_mutex_unlock (glwthread_mutex_t *mutex)
{
if (!mutex->guard.done)
return EINVAL;
LeaveCriticalSection (&mutex->lock);
return 0;
}
int
glwthread_mutex_destroy (glwthread_mutex_t *mutex)
{
if (!mutex->guard.done)
return EINVAL;
DeleteCriticalSection (&mutex->lock);
mutex->guard.done = 0;
return 0;
}
gsasl-1.8.1/gl/wctype.in.h 0000644 0000000 0000000 00000033164 13516251577 012237 0000000 0000000 /* A substitute for ISO C99 , for platforms that lack it.
Copyright (C) 2006-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
/* Written by Bruno Haible and Paul Eggert. */
/*
* ISO C 99 for platforms that lack it.
*
*
* iswctype, towctrans, towlower, towupper, wctrans, wctype,
* wctrans_t, and wctype_t are not yet implemented.
*/
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
#if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)
/* Special invocation convention:
- With MinGW 3.22, when includes , only some part of
is being processed, which doesn't include the idempotency
guard. */
#@INCLUDE_NEXT@ @NEXT_WCTYPE_H@
#else
/* Normal invocation convention. */
#ifndef _@GUARD_PREFIX@_WCTYPE_H
#if @HAVE_WINT_T@
/* Solaris 2.5 has a bug: must be included before .
Tru64 with Desktop Toolkit C has a bug: must be included before
.
BSD/OS 4.0.1 has a bug: , and must be
included before . */
# include
# include
# include
# include
#endif
/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
isw* functions in , as well as in . Include
, in advance to avoid rpl_ prefix being added to the
declarations. */
#if defined _WIN32 && ! defined __CYGWIN__
# include
# include
#endif
/* Include the original if it exists.
BeOS 5 has the functions but no . */
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_WCTYPE_H@
# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
#endif
#ifndef _@GUARD_PREFIX@_WCTYPE_H
#define _@GUARD_PREFIX@_WCTYPE_H
#ifndef _GL_INLINE_HEADER_BEGIN
#error "Please include config.h first."
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef _GL_WCTYPE_INLINE
# define _GL_WCTYPE_INLINE _GL_INLINE
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
/* Solaris 2.6 includes which includes which
#defines a number of identifiers in the application namespace. Revert
these #defines. */
#ifdef __sun
# undef multibyte
# undef eucw1
# undef eucw2
# undef eucw3
# undef scrw1
# undef scrw2
# undef scrw3
#endif
/* Define wint_t and WEOF. (Also done in wchar.in.h.) */
#if !@HAVE_WINT_T@ && !defined wint_t
# define wint_t int
# ifndef WEOF
# define WEOF -1
# endif
#else
/* mingw and MSVC define wint_t as 'unsigned short' in or
. This is too small: ISO C 99 section 7.24.1.(2) says that
wint_t must be "unchanged by default argument promotions". Override it. */
# if @GNULIB_OVERRIDES_WINT_T@
# if !GNULIB_defined_wint_t
# if @HAVE_CRTDEFS_H@
# include
# else
# include
# endif
typedef unsigned int rpl_wint_t;
# undef wint_t
# define wint_t rpl_wint_t
# define GNULIB_defined_wint_t 1
# endif
# endif
# ifndef WEOF
# define WEOF ((wint_t) -1)
# endif
#endif
#if !GNULIB_defined_wctype_functions
/* FreeBSD 4.4 to 4.11 has but lacks the functions.
Linux libc5 has and the functions but they are broken.
Assume all 11 functions (all isw* except iswblank) are implemented the
same way, or not at all. */
# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
undefined variable _ctmp_ and to macros like _P, and they
refer to system functions like _iswctype that are not in the
standard C library. Rather than try to get ancient buggy
implementations like this to work, just disable them. */
# undef iswalnum
# undef iswalpha
# undef iswblank
# undef iswcntrl
# undef iswdigit
# undef iswgraph
# undef iswlower
# undef iswprint
# undef iswpunct
# undef iswspace
# undef iswupper
# undef iswxdigit
# undef towlower
# undef towupper
/* Linux libc5 has and the functions but they are broken. */
# if @REPLACE_ISWCNTRL@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define iswalnum rpl_iswalnum
# define iswalpha rpl_iswalpha
# define iswblank rpl_iswblank
# define iswcntrl rpl_iswcntrl
# define iswdigit rpl_iswdigit
# define iswgraph rpl_iswgraph
# define iswlower rpl_iswlower
# define iswprint rpl_iswprint
# define iswpunct rpl_iswpunct
# define iswspace rpl_iswspace
# define iswupper rpl_iswupper
# define iswxdigit rpl_iswxdigit
# endif
# endif
# if @REPLACE_TOWLOWER@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define towlower rpl_towlower
# define towupper rpl_towupper
# endif
# endif
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswalnum
# else
iswalnum
# endif
(wint_t wc)
{
return ((wc >= '0' && wc <= '9')
|| ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswalpha
# else
iswalpha
# endif
(wint_t wc)
{
return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswblank
# else
iswblank
# endif
(wint_t wc)
{
return wc == ' ' || wc == '\t';
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswcntrl
# else
iswcntrl
# endif
(wint_t wc)
{
return (wc & ~0x1f) == 0 || wc == 0x7f;
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswdigit
# else
iswdigit
# endif
(wint_t wc)
{
return wc >= '0' && wc <= '9';
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswgraph
# else
iswgraph
# endif
(wint_t wc)
{
return wc >= '!' && wc <= '~';
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswlower
# else
iswlower
# endif
(wint_t wc)
{
return wc >= 'a' && wc <= 'z';
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswprint
# else
iswprint
# endif
(wint_t wc)
{
return wc >= ' ' && wc <= '~';
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswpunct
# else
iswpunct
# endif
(wint_t wc)
{
return (wc >= '!' && wc <= '~'
&& !((wc >= '0' && wc <= '9')
|| ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswspace
# else
iswspace
# endif
(wint_t wc)
{
return (wc == ' ' || wc == '\t'
|| wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswupper
# else
iswupper
# endif
(wint_t wc)
{
return wc >= 'A' && wc <= 'Z';
}
_GL_WCTYPE_INLINE int
# if @REPLACE_ISWCNTRL@
rpl_iswxdigit
# else
iswxdigit
# endif
(wint_t wc)
{
return ((wc >= '0' && wc <= '9')
|| ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
}
_GL_WCTYPE_INLINE wint_t
# if @REPLACE_TOWLOWER@
rpl_towlower
# else
towlower
# endif
(wint_t wc)
{
return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
}
_GL_WCTYPE_INLINE wint_t
# if @REPLACE_TOWLOWER@
rpl_towupper
# else
towupper
# endif
(wint_t wc)
{
return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
}
# elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
/* Only the iswblank function is missing. */
# if @REPLACE_ISWBLANK@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define iswblank rpl_iswblank
# endif
_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
# else
_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
# endif
# endif
# if defined __MINGW32__
/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
The functions towlower and towupper are implemented in the MSVCRT library
to take a wchar_t argument and return a wchar_t result. mingw declares
these functions to take a wint_t argument and return a wint_t result.
This means that:
1. When the user passes an argument outside the range 0x0000..0xFFFF, the
function will look only at the lower 16 bits. This is allowed according
to POSIX.
2. The return value is returned in the lower 16 bits of the result register.
The upper 16 bits are random: whatever happened to be in that part of the
result register. We need to fix this by adding a zero-extend from
wchar_t to wint_t after the call. */
_GL_WCTYPE_INLINE wint_t
rpl_towlower (wint_t wc)
{
return (wint_t) (wchar_t) towlower (wc);
}
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define towlower rpl_towlower
# endif
_GL_WCTYPE_INLINE wint_t
rpl_towupper (wint_t wc)
{
return (wint_t) (wchar_t) towupper (wc);
}
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define towupper rpl_towupper
# endif
# endif /* __MINGW32__ */
# define GNULIB_defined_wctype_functions 1
#endif
#if @REPLACE_ISWCNTRL@
_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
#else
_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
#endif
_GL_CXXALIASWARN (iswalnum);
_GL_CXXALIASWARN (iswalpha);
_GL_CXXALIASWARN (iswcntrl);
_GL_CXXALIASWARN (iswdigit);
_GL_CXXALIASWARN (iswgraph);
_GL_CXXALIASWARN (iswlower);
_GL_CXXALIASWARN (iswprint);
_GL_CXXALIASWARN (iswpunct);
_GL_CXXALIASWARN (iswspace);
_GL_CXXALIASWARN (iswupper);
_GL_CXXALIASWARN (iswxdigit);
#if @GNULIB_ISWBLANK@
# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
# else
_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
# endif
_GL_CXXALIASWARN (iswblank);
#endif
#if !@HAVE_WCTYPE_T@
# if !GNULIB_defined_wctype_t
typedef void * wctype_t;
# define GNULIB_defined_wctype_t 1
# endif
#endif
/* Get a descriptor for a wide character property. */
#if @GNULIB_WCTYPE@
# if !@HAVE_WCTYPE_T@
_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
# endif
_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
_GL_CXXALIASWARN (wctype);
#elif defined GNULIB_POSIXCHECK
# undef wctype
# if HAVE_RAW_DECL_WCTYPE
_GL_WARN_ON_USE (wctype, "wctype is unportable - "
"use gnulib module wctype for portability");
# endif
#endif
/* Test whether a wide character has a given property.
The argument WC must be either a wchar_t value or WEOF.
The argument DESC must have been returned by the wctype() function. */
#if @GNULIB_ISWCTYPE@
# if !@HAVE_WCTYPE_T@
_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
# endif
_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
_GL_CXXALIASWARN (iswctype);
#elif defined GNULIB_POSIXCHECK
# undef iswctype
# if HAVE_RAW_DECL_ISWCTYPE
_GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
"use gnulib module iswctype for portability");
# endif
#endif
#if @REPLACE_TOWLOWER@ || defined __MINGW32__
_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
#else
_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
#endif
_GL_CXXALIASWARN (towlower);
_GL_CXXALIASWARN (towupper);
#if !@HAVE_WCTRANS_T@
# if !GNULIB_defined_wctrans_t
typedef void * wctrans_t;
# define GNULIB_defined_wctrans_t 1
# endif
#endif
/* Get a descriptor for a wide character case conversion. */
#if @GNULIB_WCTRANS@
# if !@HAVE_WCTRANS_T@
_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
# endif
_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
_GL_CXXALIASWARN (wctrans);
#elif defined GNULIB_POSIXCHECK
# undef wctrans
# if HAVE_RAW_DECL_WCTRANS
_GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
"use gnulib module wctrans for portability");
# endif
#endif
/* Perform a given case conversion on a wide character.
The argument WC must be either a wchar_t value or WEOF.
The argument DESC must have been returned by the wctrans() function. */
#if @GNULIB_TOWCTRANS@
# if !@HAVE_WCTRANS_T@
_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
# endif
_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
_GL_CXXALIASWARN (towctrans);
#elif defined GNULIB_POSIXCHECK
# undef towctrans
# if HAVE_RAW_DECL_TOWCTRANS
_GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
"use gnulib module towctrans for portability");
# endif
#endif
_GL_INLINE_HEADER_END
#endif /* _@GUARD_PREFIX@_WCTYPE_H */
#endif /* _@GUARD_PREFIX@_WCTYPE_H */
#endif
gsasl-1.8.1/gl/malloc.c 0000644 0000000 0000000 00000002733 13516251573 011553 0000000 0000000 /* malloc() function that is glibc compatible.
Copyright (C) 1997-1998, 2006-2007, 2009-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
/* written by Jim Meyering and Bruno Haible */
#define _GL_USE_STDLIB_ALLOC 1
#include
/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
#ifdef malloc
# define NEED_MALLOC_GNU 1
# undef malloc
/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */
#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU
# define NEED_MALLOC_GNU 1
#endif
#include
#include
/* Allocate an N-byte block of memory from the heap.
If N is zero, allocate a 1-byte block. */
void *
rpl_malloc (size_t n)
{
void *result;
#if NEED_MALLOC_GNU
if (n == 0)
n = 1;
#endif
result = malloc (n);
#if !HAVE_MALLOC_POSIX
if (result == NULL)
errno = ENOMEM;
#endif
return result;
}
gsasl-1.8.1/gl/strdup.c 0000644 0000000 0000000 00000002471 13516251573 011624 0000000 0000000 /* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2019 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
#ifndef _LIBC
# include
#endif
/* Get specification. */
#include
#include
#undef __strdup
#ifdef _LIBC
# undef strdup
#endif
#ifndef weak_alias
# define __strdup strdup
#endif
/* Duplicate S, returning an identical malloc'd string. */
char *
__strdup (const char *s)
{
size_t len = strlen (s) + 1;
void *new = malloc (len);
if (new == NULL)
return NULL;
return (char *) memcpy (new, s, len);
}
#ifdef libc_hidden_def
libc_hidden_def (__strdup)
#endif
#ifdef weak_alias
weak_alias (__strdup, strdup)
#endif
gsasl-1.8.1/gl/memchr.valgrind 0000644 0000000 0000000 00000002142 13516251576 013140 0000000 0000000 # Suppress a valgrind message about use of uninitialized memory in memchr().
# Copyright (C) 2009-2019 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# POSIX states that when the character is found, memchr must not read extra
# bytes in an overestimated length (for example, where memchr is used to
# implement strnlen). However, we use a safe word read to provide a speedup.
{
memchr-value4
Memcheck:Value4
fun:rpl_memchr
}
{
memchr-value8
Memcheck:Value8
fun:rpl_memchr
}
gsasl-1.8.1/gl/close.c 0000644 0000000 0000000 00000002770 13516251574 011413 0000000 0000000 /* close replacement.
Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#include
/* Specification. */
#include
#include
#include "fd-hook.h"
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
# include "msvc-inval.h"
#endif
#undef close
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
close_nothrow (int fd)
{
int result;
TRY_MSVC_INVAL
{
result = close (fd);
}
CATCH_MSVC_INVAL
{
result = -1;
errno = EBADF;
}
DONE_MSVC_INVAL;
return result;
}
#else
# define close_nothrow close
#endif
/* Override close() to call into other gnulib modules. */
int
rpl_close (int fd)
{
#if WINDOWS_SOCKETS
int retval = execute_all_close_hooks (close_nothrow, fd);
#else
int retval = close_nothrow (fd);
#endif
#if REPLACE_FCHDIR
if (retval >= 0)
_gl_unregister_fd (fd);
#endif
return retval;
}
gsasl-1.8.1/gl/lseek.c 0000644 0000000 0000000 00000003451 13516251575 011407 0000000 0000000 /* An lseek() function that detects pipes.
Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
#include
/* Specification. */
#include
#if defined _WIN32 && ! defined __CYGWIN__
/* Windows platforms. */
/* Get GetFileType. */
# include
/* Get _get_osfhandle. */
# if GNULIB_MSVC_NOTHROW
# include "msvc-nothrow.h"
# else
# include
# endif
#else
# include
#endif
#include
#undef lseek
off_t
rpl_lseek (int fd, off_t offset, int whence)
{
#if defined _WIN32 && ! defined __CYGWIN__
/* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
HANDLE h = (HANDLE) _get_osfhandle (fd);
if (h == INVALID_HANDLE_VALUE)
{
errno = EBADF;
return -1;
}
if (GetFileType (h) != FILE_TYPE_DISK)
{
errno = ESPIPE;
return -1;
}
#else
/* BeOS lseek mistakenly succeeds on pipes... */
struct stat statbuf;
if (fstat (fd, &statbuf) < 0)
return -1;
if (!S_ISREG (statbuf.st_mode))
{
errno = ESPIPE;
return -1;
}
#endif
#if _GL_WINDOWS_64_BIT_OFF_T
return _lseeki64 (fd, offset, whence);
#else
return lseek (fd, offset, whence);
#endif
}
gsasl-1.8.1/gl/iconv_open-hpux.gperf 0000644 0000000 0000000 00000003455 13516251574 014311 0000000 0000000 /* Character set conversion.
Copyright (C) 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
struct mapping { int standard_name; const char vendor_name[9 + 1]; };
%struct-type
%language=ANSI-C
%define slot-name standard_name
%define hash-function-name mapping_hash
%define lookup-function-name mapping_lookup
%readonly-tables
%global-table
%define word-array-name mappings
%pic
%%
# On HP-UX 11.11, look in /usr/lib/nls/iconv.
ISO-8859-1, "iso88591"
ISO-8859-2, "iso88592"
ISO-8859-5, "iso88595"
ISO-8859-6, "iso88596"
ISO-8859-7, "iso88597"
ISO-8859-8, "iso88598"
ISO-8859-9, "iso88599"
ISO-8859-15, "iso885915"
CP437, "cp437"
CP775, "cp775"
CP850, "cp850"
CP852, "cp852"
CP855, "cp855"
CP857, "cp857"
CP861, "cp861"
CP862, "cp862"
CP864, "cp864"
CP865, "cp865"
CP866, "cp866"
CP869, "cp869"
CP874, "cp874"
CP1250, "cp1250"
CP1251, "cp1251"
CP1252, "cp1252"
CP1253, "cp1253"
CP1254, "cp1254"
CP1255, "cp1255"
CP1256, "cp1256"
CP1257, "cp1257"
CP1258, "cp1258"
HP-ROMAN8, "roman8"
HP-ARABIC8, "arabic8"
HP-GREEK8, "greek8"
HP-HEBREW8, "hebrew8"
HP-TURKISH8, "turkish8"
HP-KANA8, "kana8"
TIS-620, "tis620"
GB2312, "hp15CN"
EUC-JP, "eucJP"
EUC-KR, "eucKR"
EUC-TW, "eucTW"
BIG5, "big5"
SHIFT_JIS, "sjis"
UTF-8, "utf8"
gsasl-1.8.1/gl/xalloc.h 0000644 0000000 0000000 00000017053 13516251577 011600 0000000 0000000 /* xalloc.h -- malloc with out-of-memory checking
Copyright (C) 1990-2000, 2003-2004, 2006-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#ifndef XALLOC_H_
#define XALLOC_H_
#include
#include
#include "xalloc-oversized.h"
#ifndef _GL_INLINE_HEADER_BEGIN
#error "Please include config.h first."
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef XALLOC_INLINE
# define XALLOC_INLINE _GL_INLINE
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if ! defined __clang__ && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
#else
# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
#endif
/* This function is always triggered when memory is exhausted.
It must be defined by the application, either explicitly
or by using gnulib's xalloc-die module. This is the
function to call when one wants the program to die because of a
memory allocation failure. */
extern _Noreturn void xalloc_die (void);
void *xmalloc (size_t s)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
void *xzalloc (size_t s)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
void *xcalloc (size_t n, size_t s)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
void *xrealloc (void *p, size_t s)
_GL_ATTRIBUTE_ALLOC_SIZE ((2));
void *x2realloc (void *p, size_t *pn);
void *xmemdup (void const *p, size_t s)
_GL_ATTRIBUTE_ALLOC_SIZE ((2));
char *xstrdup (char const *str)
_GL_ATTRIBUTE_MALLOC;
/* In the following macros, T must be an elementary or structure/union or
typedef'ed type, or a pointer to such a type. To apply one of the
following macros to a function pointer or array type, you need to typedef
it first and use the typedef name. */
/* Allocate an object of type T dynamically, with error checking. */
/* extern t *XMALLOC (typename t); */
#define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
/* Allocate memory for N elements of type T, with error checking. */
/* extern t *XNMALLOC (size_t n, typename t); */
#define XNMALLOC(n, t) \
((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
/* Allocate an object of type T dynamically, with error checking,
and zero it. */
/* extern t *XZALLOC (typename t); */
#define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
/* Allocate memory for N elements of type T, with error checking,
and zero it. */
/* extern t *XCALLOC (size_t n, typename t); */
#define XCALLOC(n, t) \
((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
/* Allocate an array of N objects, each with S bytes of memory,
dynamically, with error checking. S must be nonzero. */
XALLOC_INLINE void *xnmalloc (size_t n, size_t s)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
XALLOC_INLINE void *
xnmalloc (size_t n, size_t s)
{
if (xalloc_oversized (n, s))
xalloc_die ();
return xmalloc (n * s);
}
/* Change the size of an allocated block of memory P to an array of N
objects each of S bytes, with error checking. S must be nonzero. */
XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s)
_GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
XALLOC_INLINE void *
xnrealloc (void *p, size_t n, size_t s)
{
if (xalloc_oversized (n, s))
xalloc_die ();
return xrealloc (p, n * s);
}
/* If P is null, allocate a block of at least *PN such objects;
otherwise, reallocate P so that it contains more than *PN objects
each of S bytes. S must be nonzero. Set *PN to the new number of
objects, and return the pointer to the new block. *PN is never set
to zero, and the returned pointer is never null.
Repeated reallocations are guaranteed to make progress, either by
allocating an initial block with a nonzero size, or by allocating a
larger block.
In the following implementation, nonzero sizes are increased by a
factor of approximately 1.5 so that repeated reallocations have
O(N) overall cost rather than O(N**2) cost, but the
specification for this function does not guarantee that rate.
Here is an example of use:
int *p = NULL;
size_t used = 0;
size_t allocated = 0;
void
append_int (int value)
{
if (used == allocated)
p = x2nrealloc (p, &allocated, sizeof *p);
p[used++] = value;
}
This causes x2nrealloc to allocate a block of some nonzero size the
first time it is called.
To have finer-grained control over the initial size, set *PN to a
nonzero value before calling this function with P == NULL. For
example:
int *p = NULL;
size_t used = 0;
size_t allocated = 0;
size_t allocated1 = 1000;
void
append_int (int value)
{
if (used == allocated)
{
p = x2nrealloc (p, &allocated1, sizeof *p);
allocated = allocated1;
}
p[used++] = value;
}
*/
XALLOC_INLINE void *
x2nrealloc (void *p, size_t *pn, size_t s)
{
size_t n = *pn;
if (! p)
{
if (! n)
{
/* The approximate size to use for initial small allocation
requests, when the invoking code specifies an old size of
zero. This is the largest "small" request for the GNU C
library malloc. */
enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
n = DEFAULT_MXFAST / s;
n += !n;
}
if (xalloc_oversized (n, s))
xalloc_die ();
}
else
{
/* Set N = floor (1.5 * N) + 1 so that progress is made even if N == 0.
Check for overflow, so that N * S stays in both ptrdiff_t and
size_t range. The check may be slightly conservative, but an
exact check isn't worth the trouble. */
if ((PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX) / 3 * 2 / s
<= n)
xalloc_die ();
n += n / 2 + 1;
}
*pn = n;
return xrealloc (p, n * s);
}
/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
except it returns char *. */
XALLOC_INLINE char *xcharalloc (size_t n)
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
XALLOC_INLINE char *
xcharalloc (size_t n)
{
return XNMALLOC (n, char);
}
#ifdef __cplusplus
}
/* C++ does not allow conversions from void * to other pointer types
without a cast. Use templates to work around the problem when
possible. */
template inline T *
xrealloc (T *p, size_t s)
{
return (T *) xrealloc ((void *) p, s);
}
template inline T *
xnrealloc (T *p, size_t n, size_t s)
{
return (T *) xnrealloc ((void *) p, n, s);
}
template inline T *
x2realloc (T *p, size_t *pn)
{
return (T *) x2realloc ((void *) p, pn);
}
template inline T *
x2nrealloc (T *p, size_t *pn, size_t s)
{
return (T *) x2nrealloc ((void *) p, pn, s);
}
template inline T *
xmemdup (T const *p, size_t s)
{
return (T *) xmemdup ((void const *) p, s);
}
#endif
_GL_INLINE_HEADER_END
#endif /* !XALLOC_H_ */
gsasl-1.8.1/gl/fseeko.c 0000644 0000000 0000000 00000013773 13516251574 011567 0000000 0000000 /* An fseeko() function that, together with fflush(), is POSIX compliant.
Copyright (C) 2007-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see . */
#include
/* Specification. */
#include
/* Get off_t, lseek, _POSIX_VERSION. */
#include
#include "stdio-impl.h"
int
fseeko (FILE *fp, off_t offset, int whence)
#undef fseeko
#if !HAVE_FSEEKO
# undef fseek
# define fseeko fseek
#endif
#if _GL_WINDOWS_64_BIT_OFF_T
# undef fseeko
# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
# define fseeko _fseeki64
# else /* mingw before msvcrt8.0 */
# define fseeko fseeko64
# endif
#endif
{
#if LSEEK_PIPE_BROKEN
/* mingw gives bogus answers rather than failure on non-seekable files. */
if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
return EOF;
#endif
/* These tests are based on fpurge.c. */
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
/* GNU libc, BeOS, Haiku, Linux libc5 */
if (fp->_IO_read_end == fp->_IO_read_ptr
&& fp->_IO_write_ptr == fp->_IO_write_base
&& fp->_IO_save_base == NULL)
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
# if defined __SL64 && defined __SCLE /* Cygwin */
if ((fp->_flags & __SL64) == 0)
{
/* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
mode; but has an fseeko that requires 64-bit mode. */
FILE *tmp = fopen ("/dev/null", "r");
if (!tmp)
return -1;
fp->_flags |= __SL64;
fp->_seek64 = tmp->_seek64;
fclose (tmp);
}
# endif
if (fp_->_p == fp_->_bf._base
&& fp_->_r == 0
&& fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
? fp_->_bf._size
: 0)
&& fp_ub._base == NULL)
#elif defined __EMX__ /* emx+gcc */
if (fp->_ptr == fp->_buffer
&& fp->_rcount == 0
&& fp->_wcount == 0
&& fp->_ungetc_count == 0)
#elif defined __minix /* Minix */
if (fp_->_ptr == fp_->_buf
&& (fp_->_ptr == NULL || fp_->_count == 0))
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
if (fp_->_ptr == fp_->_base
&& (fp_->_ptr == NULL || fp_->_cnt == 0))
#elif defined __UCLIBC__ /* uClibc */
if (((fp->__modeflags & __FLAG_WRITING) == 0
|| fp->__bufpos == fp->__bufstart)
&& ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
|| fp->__bufpos == fp->__bufread))
#elif defined __QNX__ /* QNX */
if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
&& fp->_Rback == fp->_Back + sizeof (fp->_Back)
&& fp->_Rsave == NULL)
#elif defined __MINT__ /* Atari FreeMiNT */
if (fp->__bufp == fp->__buffer
&& fp->__get_limit == fp->__bufp
&& fp->__put_limit == fp->__bufp
&& !fp->__pushed_back)
#elif defined EPLAN9 /* Plan9 */
if (fp->rp == fp->buf
&& fp->wp == fp->buf)
#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
/* Cross-compiling to some other system advertising conformance to
POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
If this assumption is incorrect, please report the bug to
bug-gnulib. */
if (0)
#else
#error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
#endif
{
/* We get here when an fflush() call immediately preceded this one (or
if ftell() has created buffers but no I/O has occurred on a
newly-opened stream). We know there are no buffers. */
off_t pos = lseek (fileno (fp), offset, whence);
if (pos == -1)
{
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
fp_->_flags &= ~__SOFF;
#endif
return -1;
}
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
/* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags &= ~_IO_EOF_SEEN;
fp->_offset = pos;
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
/* fp_->_offset is typed as an integer. */
fp_->_offset = pos;
# else
/* fp_->_offset is an fpos_t. */
{
/* Use a union, since on NetBSD, the compilation flags
determine whether fpos_t is typedef'd to off_t or a struct
containing a single off_t member. */
union
{
fpos_t f;
off_t o;
} u;
u.o = pos;
fp_->_offset = u.f;
}
# endif
fp_->_flags |= __SOFF;
fp_->_flags &= ~__SEOF;
#elif defined __EMX__ /* emx+gcc */
fp->_flags &= ~_IOEOF;
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
fp_->_flag &= ~_IOEOF;
#elif defined __MINT__ /* Atari FreeMiNT */
fp->__offset = pos;
fp->__eof = 0;
#endif
return 0;
}
return fseeko (fp, offset, whence);
}
gsasl-1.8.1/gl/xalloc-die.c 0000644 0000000 0000000 00000002435 13516251577 012330 0000000 0000000 /* Report a memory allocation failure and exit.
Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#include
#include "xalloc.h"
#include
#include "error.h"
#include "exitfail.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
void
xalloc_die (void)
{
error (exit_failure, 0, "%s", _("memory exhausted"));
/* _Noreturn cannot be given to error, since it may return if
its first argument is 0. To help compilers understand the
xalloc_die does not return, call abort. Also, the abort is a
safety feature if exit_failure is 0 (which shouldn't happen). */
abort ();
}
gsasl-1.8.1/gl/w32sock.h 0000644 0000000 0000000 00000006431 13516251577 011607 0000000 0000000 /* w32sock.h --- internal auxiliary functions for Windows socket functions
Copyright (C) 2008-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* Written by Paolo Bonzini */
#include
/* Get O_RDWR and O_BINARY. */
#include
/* Get _open_osfhandle(). */
#include
/* Get _get_osfhandle(). */
#if GNULIB_MSVC_NOTHROW
# include "msvc-nothrow.h"
#else
# include
#endif
#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY))
static inline void
set_winsock_errno (void)
{
int err = WSAGetLastError ();
/* Map some WSAE* errors to the runtime library's error codes. */
switch (err)
{
case WSA_INVALID_HANDLE:
errno = EBADF;
break;
case WSA_NOT_ENOUGH_MEMORY:
errno = ENOMEM;
break;
case WSA_INVALID_PARAMETER:
errno = EINVAL;
break;
case WSAENAMETOOLONG:
errno = ENAMETOOLONG;
break;
case WSAENOTEMPTY:
errno = ENOTEMPTY;
break;
case WSAEWOULDBLOCK:
errno = EWOULDBLOCK;
break;
case WSAEINPROGRESS:
errno = EINPROGRESS;
break;
case WSAEALREADY:
errno = EALREADY;
break;
case WSAENOTSOCK:
errno = ENOTSOCK;
break;
case WSAEDESTADDRREQ:
errno = EDESTADDRREQ;
break;
case WSAEMSGSIZE:
errno = EMSGSIZE;
break;
case WSAEPROTOTYPE:
errno = EPROTOTYPE;
break;
case WSAENOPROTOOPT:
errno = ENOPROTOOPT;
break;
case WSAEPROTONOSUPPORT:
errno = EPROTONOSUPPORT;
break;
case WSAEOPNOTSUPP:
errno = EOPNOTSUPP;
break;
case WSAEAFNOSUPPORT:
errno = EAFNOSUPPORT;
break;
case WSAEADDRINUSE:
errno = EADDRINUSE;
break;
case WSAEADDRNOTAVAIL:
errno = EADDRNOTAVAIL;
break;
case WSAENETDOWN:
errno = ENETDOWN;
break;
case WSAENETUNREACH:
errno = ENETUNREACH;
break;
case WSAENETRESET:
errno = ENETRESET;
break;
case WSAECONNABORTED:
errno = ECONNABORTED;
break;
case WSAECONNRESET:
errno = ECONNRESET;
break;
case WSAENOBUFS:
errno = ENOBUFS;
break;
case WSAEISCONN:
errno = EISCONN;
break;
case WSAENOTCONN:
errno = ENOTCONN;
break;
case WSAETIMEDOUT:
errno = ETIMEDOUT;
break;
case WSAECONNREFUSED:
errno = ECONNREFUSED;
break;
case WSAELOOP:
errno = ELOOP;
break;
case WSAEHOSTUNREACH:
errno = EHOSTUNREACH;
break;
default:
errno = (err > 10000 && err < 10025) ? err - 10000 : err;
break;
}
}
gsasl-1.8.1/gl/hard-locale.h 0000644 0000000 0000000 00000001572 13516251573 012464 0000000 0000000 /* Determine whether a locale is hard.
Copyright (C) 1999, 2003-2004, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#ifndef HARD_LOCALE_H_
# define HARD_LOCALE_H_ 1
# include
bool hard_locale (int);
#endif /* HARD_LOCALE_H_ */
gsasl-1.8.1/gl/limits.in.h 0000644 0000000 0000000 00000007400 13516251573 012213 0000000 0000000 /* A GNU-like .
Copyright 2016-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
#ifndef _@GUARD_PREFIX@_LIMITS_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
#ifndef _@GUARD_PREFIX@_LIMITS_H
#define _@GUARD_PREFIX@_LIMITS_H
#ifndef LLONG_MIN
# if defined LONG_LONG_MIN /* HP-UX 11.31 */
# define LLONG_MIN LONG_LONG_MIN
# elif defined LONGLONG_MIN /* IRIX 6.5 */
# define LLONG_MIN LONGLONG_MIN
# elif defined __GNUC__
# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
# endif
#endif
#ifndef LLONG_MAX
# if defined LONG_LONG_MAX /* HP-UX 11.31 */
# define LLONG_MAX LONG_LONG_MAX
# elif defined LONGLONG_MAX /* IRIX 6.5 */
# define LLONG_MAX LONGLONG_MAX
# elif defined __GNUC__
# define LLONG_MAX __LONG_LONG_MAX__
# endif
#endif
#ifndef ULLONG_MAX
# if defined ULONG_LONG_MAX /* HP-UX 11.31 */
# define ULLONG_MAX ULONG_LONG_MAX
# elif defined ULONGLONG_MAX /* IRIX 6.5 */
# define ULLONG_MAX ULONGLONG_MAX
# elif defined __GNUC__
# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
# endif
#endif
/* The number of usable bits in an unsigned or signed integer type
with minimum value MIN and maximum value MAX, as an int expression
suitable in #if. Cover all known practical hosts. This
implementation exploits the fact that MAX is 1 less than a power of
2, and merely counts the number of 1 bits in MAX; "COBn" means
"count the number of 1 bits in the low-order n bits"). */
#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
#ifndef WORD_BIT
/* Assume 'int' is 32 bits wide. */
# define WORD_BIT 32
#endif
#ifndef LONG_BIT
/* Assume 'long' is 32 or 64 bits wide. */
# if LONG_MAX == INT_MAX
# define LONG_BIT 32
# else
# define LONG_BIT 64
# endif
#endif
/* Macros specified by ISO/IEC TS 18661-1:2014. */
#if (! defined ULLONG_WIDTH \
&& (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
#endif /* _@GUARD_PREFIX@_LIMITS_H */
#endif /* _@GUARD_PREFIX@_LIMITS_H */
gsasl-1.8.1/gl/unistd.c 0000644 0000000 0000000 00000000147 13516251577 011613 0000000 0000000 #include
#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
#include "unistd.h"
typedef int dummy;
gsasl-1.8.1/gl/getprogname.c 0000644 0000000 0000000 00000020117 13516251573 012610 0000000 0000000 /* Program name management.
Copyright (C) 2016-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#include
/* Specification. */
#include "getprogname.h"
#include /* get program_invocation_name declaration */
#include /* get __argv declaration */
#ifdef _AIX
# include
# include
# include
#endif
#ifdef __MVS__
# ifndef _OPEN_SYS
# define _OPEN_SYS
# endif
# include
# include
#endif
#ifdef __hpux
# include
# include
# include
# include
#endif
#ifdef __sgi
# include
# include
# include
# include
# include
#endif
#include "dirname.h"
#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
char const *
getprogname (void)
{
# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* glibc, BeOS */
/* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
return program_invocation_short_name;
# elif HAVE_DECL_PROGRAM_INVOCATION_NAME /* glibc, BeOS */
/* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
return last_component (program_invocation_name);
# elif HAVE_GETEXECNAME /* Solaris */
/* https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */
const char *p = getexecname ();
if (!p)
p = "?";
return last_component (p);
# elif HAVE_DECL___ARGV /* mingw, MSVC */
/* https://docs.microsoft.com/en-us/cpp/c-runtime-library/argc-argv-wargv */
const char *p = __argv && __argv[0] ? __argv[0] : "?";
return last_component (p);
# elif HAVE_VAR___PROGNAME /* OpenBSD, Android, QNX */
/* https://man.openbsd.org/style.9 */
/* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */
/* Be careful to declare this only when we absolutely need it
(OpenBSD 5.1), rather than when it's available. Otherwise,
its mere declaration makes program_invocation_short_name
malfunction (have zero length) with Fedora 25's glibc. */
extern char *__progname;
const char *p = __progname;
# if defined __ANDROID__
return last_component (p);
# else
return p && p[0] ? p : "?";
# endif
# elif _AIX /* AIX */
/* Idea by Bastien ROUCARIÈS,
https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html
Reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.basetrf1/getprocs.htm
*/
static char *p;
static int first = 1;
if (first)
{
first = 0;
pid_t pid = getpid ();
struct procentry64 procs;
p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1)
? strdup (procs.pi_comm)
: NULL);
if (!p)
p = "?";
}
return p;
# elif defined __hpux
static char *p;
static int first = 1;
if (first)
{
first = 0;
pid_t pid = getpid ();
struct pst_status status;
if (pstat_getproc (&status, sizeof status, 0, pid) > 0)
{
char *ucomm = status.pst_ucomm;
char *cmd = status.pst_cmd;
if (strlen (ucomm) < PST_UCOMMLEN - 1)
p = ucomm;
else
{
/* ucomm is truncated to length PST_UCOMMLEN - 1.
Look at cmd instead. */
char *space = strchr (cmd, ' ');
if (space != NULL)
*space = '\0';
p = strrchr (cmd, '/');
if (p != NULL)
p++;
else
p = cmd;
if (strlen (p) > PST_UCOMMLEN - 1
&& memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
/* p is less truncated than ucomm. */
;
else
p = ucomm;
}
p = strdup (p);
}
else
{
# if !defined __LP64__
/* Support for 32-bit programs running in 64-bit HP-UX.
The documented way to do this is to use the same source code
as above, but in a compilation unit where '#define _PSTAT64 1'
is in effect. I prefer a single compilation unit; the struct
size and the offsets are not going to change. */
char status64[1216];
if (__pstat_getproc64 (status64, sizeof status64, 0, pid) > 0)
{
char *ucomm = status64 + 288;
char *cmd = status64 + 168;
if (strlen (ucomm) < PST_UCOMMLEN - 1)
p = ucomm;
else
{
/* ucomm is truncated to length PST_UCOMMLEN - 1.
Look at cmd instead. */
char *space = strchr (cmd, ' ');
if (space != NULL)
*space = '\0';
p = strrchr (cmd, '/');
if (p != NULL)
p++;
else
p = cmd;
if (strlen (p) > PST_UCOMMLEN - 1
&& memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
/* p is less truncated than ucomm. */
;
else
p = ucomm;
}
p = strdup (p);
}
else
# endif
p = NULL;
}
if (!p)
p = "?";
}
return p;
# elif __MVS__ /* z/OS */
/* https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm */
static char *p = "?";
static int first = 1;
if (first)
{
pid_t pid = getpid ();
int token;
W_PSPROC buf;
first = 0;
memset (&buf, 0, sizeof(buf));
buf.ps_cmdptr = (char *) malloc (buf.ps_cmdlen = PS_CMDBLEN_LONG);
buf.ps_conttyptr = (char *) malloc (buf.ps_conttylen = PS_CONTTYBLEN);
buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN);
if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr)
{
for (token = 0; token >= 0;
token = w_getpsent (token, &buf, sizeof(buf)))
{
if (token > 0 && buf.ps_pid == pid)
{
char *s = strdup (last_component (buf.ps_pathptr));
if (s)
p = s;
break;
}
}
}
free (buf.ps_cmdptr);
free (buf.ps_conttyptr);
free (buf.ps_pathptr);
}
return p;
# elif defined __sgi /* IRIX */
char filename[50];
int fd;
sprintf (filename, "/proc/pinfo/%d", (int) getpid ());
fd = open (filename, O_RDONLY);
if (0 <= fd)
{
prpsinfo_t buf;
int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf);
close (fd);
if (ioctl_ok)
{
char *name = buf.pr_fname;
size_t namesize = sizeof buf.pr_fname;
char *namenul = memchr (name, '\0', namesize);
size_t namelen = namenul ? namenul - name : namesize;
char *namecopy = malloc (namelen + 1);
if (namecopy)
{
namecopy[namelen] = 0;
return memcpy (namecopy, name, namelen);
}
}
}
return NULL;
# else
# error "getprogname module not ported to this OS"
# endif
}
#endif
/*
* Hey Emacs!
* Local Variables:
* coding: utf-8
* End:
*/
gsasl-1.8.1/gl/unistr.in.h 0000644 0000000 0000000 00000055066 13516251577 012255 0000000 0000000 /* Elementary Unicode string functions.
Copyright (C) 2001-2002, 2005-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#ifndef _UNISTR_H
#define _UNISTR_H
#include "unitypes.h"
/* Get common macros for C. */
#include "unused-parameter.h"
/* Get bool. */
#include
/* Get size_t. */
#include
#ifdef __cplusplus
extern "C" {
#endif
/* Conventions:
All functions prefixed with u8_ operate on UTF-8 encoded strings.
Their unit is an uint8_t (1 byte).
All functions prefixed with u16_ operate on UTF-16 encoded strings.
Their unit is an uint16_t (a 2-byte word).
All functions prefixed with u32_ operate on UCS-4 encoded strings.
Their unit is an uint32_t (a 4-byte word).
All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly
n units.
All arguments starting with "str" and the arguments of functions starting
with u8_str/u16_str/u32_str denote a NUL terminated string, i.e. a string
which terminates at the first NUL unit. This termination unit is
considered part of the string for all memory allocation purposes, but
is not considered part of the string for all other logical purposes.
Functions returning a string result take a (resultbuf, lengthp) argument
pair. If resultbuf is not NULL and the result fits into *lengthp units,
it is put in resultbuf, and resultbuf is returned. Otherwise, a freshly
allocated string is returned. In both cases, *lengthp is set to the
length (number of units) of the returned string. In case of error,
NULL is returned and errno is set. */
/* Elementary string checks. */
/* Check whether an UTF-8 string is well-formed.
Return NULL if valid, or a pointer to the first invalid unit otherwise. */
extern const uint8_t *
u8_check (const uint8_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
/* Check whether an UTF-16 string is well-formed.
Return NULL if valid, or a pointer to the first invalid unit otherwise. */
extern const uint16_t *
u16_check (const uint16_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
/* Check whether an UCS-4 string is well-formed.
Return NULL if valid, or a pointer to the first invalid unit otherwise. */
extern const uint32_t *
u32_check (const uint32_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
/* Elementary string conversions. */
/* Convert an UTF-8 string to an UTF-16 string. */
extern uint16_t *
u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf,
size_t *lengthp);
/* Convert an UTF-8 string to an UCS-4 string. */
extern uint32_t *
u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf,
size_t *lengthp);
/* Convert an UTF-16 string to an UTF-8 string. */
extern uint8_t *
u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf,
size_t *lengthp);
/* Convert an UTF-16 string to an UCS-4 string. */
extern uint32_t *
u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf,
size_t *lengthp);
/* Convert an UCS-4 string to an UTF-8 string. */
extern uint8_t *
u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf,
size_t *lengthp);
/* Convert an UCS-4 string to an UTF-16 string. */
extern uint16_t *
u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf,
size_t *lengthp);
/* Elementary string functions. */
/* Return the length (number of units) of the first character in S, which is
no longer than N. Return 0 if it is the NUL character. Return -1 upon
failure. */
/* Similar to mblen(), except that s must not be NULL. */
extern int
u8_mblen (const uint8_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
extern int
u16_mblen (const uint16_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
extern int
u32_mblen (const uint32_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
/* Return the length (number of units) of the first character in S, putting
its 'ucs4_t' representation in *PUC. Upon failure, *PUC is set to 0xfffd,
and an appropriate number of units is returned.
The number of available units, N, must be > 0. */
/* Similar to mbtowc(), except that puc and s must not be NULL, n must be > 0,
and the NUL character is not treated specially. */
/* The variants with _unsafe suffix are for backward compatibility with
libunistring versions < 0.9.7. */
#if GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n);
# else
extern int
u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n);
static inline int
u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
{
uint8_t c = *s;
if (c < 0x80)
{
*puc = c;
return 1;
}
else
return u8_mbtouc_unsafe_aux (puc, s, n);
}
# endif
#endif
#if GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n);
# else
extern int
u16_mbtouc_unsafe_aux (ucs4_t *puc, const uint16_t *s, size_t n);
static inline int
u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n)
{
uint16_t c = *s;
if (c < 0xd800 || c >= 0xe000)
{
*puc = c;
return 1;
}
else
return u16_mbtouc_unsafe_aux (puc, s, n);
}
# endif
#endif
#if GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n);
# else
static inline int
u32_mbtouc_unsafe (ucs4_t *puc,
const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
{
uint32_t c = *s;
if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
*puc = c;
else
/* invalid multibyte character */
*puc = 0xfffd;
return 1;
}
# endif
#endif
#if GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n);
# else
extern int
u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n);
static inline int
u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
{
uint8_t c = *s;
if (c < 0x80)
{
*puc = c;
return 1;
}
else
return u8_mbtouc_aux (puc, s, n);
}
# endif
#endif
#if GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n);
# else
extern int
u16_mbtouc_aux (ucs4_t *puc, const uint16_t *s, size_t n);
static inline int
u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n)
{
uint16_t c = *s;
if (c < 0xd800 || c >= 0xe000)
{
*puc = c;
return 1;
}
else
return u16_mbtouc_aux (puc, s, n);
}
# endif
#endif
#if GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
# else
static inline int
u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
{
uint32_t c = *s;
if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
*puc = c;
else
/* invalid multibyte character */
*puc = 0xfffd;
return 1;
}
# endif
#endif
/* Return the length (number of units) of the first character in S, putting
its 'ucs4_t' representation in *PUC. Upon failure, *PUC is set to 0xfffd,
and -1 is returned for an invalid sequence of units, -2 is returned for an
incomplete sequence of units.
The number of available units, N, must be > 0. */
/* Similar to u*_mbtouc(), except that the return value gives more details
about the failure, similar to mbrtowc(). */
#if GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING
extern int
u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n);
#endif
#if GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING
extern int
u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n);
#endif
#if GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING
extern int
u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n);
#endif
/* Put the multibyte character represented by UC in S, returning its
length. Return -1 upon failure, -2 if the number of available units, N,
is too small. The latter case cannot occur if N >= 6/2/1, respectively. */
/* Similar to wctomb(), except that s must not be NULL, and the argument n
must be specified. */
#if GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING
/* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr. */
extern int
u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n);
# if !HAVE_INLINE
extern int
u8_uctomb (uint8_t *s, ucs4_t uc, int n);
# else
static inline int
u8_uctomb (uint8_t *s, ucs4_t uc, int n)
{
if (uc < 0x80 && n > 0)
{
s[0] = uc;
return 1;
}
else
return u8_uctomb_aux (s, uc, n);
}
# endif
#endif
#if GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING
/* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr. */
extern int
u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n);
# if !HAVE_INLINE
extern int
u16_uctomb (uint16_t *s, ucs4_t uc, int n);
# else
static inline int
u16_uctomb (uint16_t *s, ucs4_t uc, int n)
{
if (uc < 0xd800 && n > 0)
{
s[0] = uc;
return 1;
}
else
return u16_uctomb_aux (s, uc, n);
}
# endif
#endif
#if GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_uctomb (uint32_t *s, ucs4_t uc, int n);
# else
static inline int
u32_uctomb (uint32_t *s, ucs4_t uc, int n)
{
if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
{
if (n > 0)
{
*s = uc;
return 1;
}
else
return -2;
}
else
return -1;
}
# endif
#endif
/* Copy N units from SRC to DEST. */
/* Similar to memcpy(). */
extern uint8_t *
u8_cpy (uint8_t *dest, const uint8_t *src, size_t n);
extern uint16_t *
u16_cpy (uint16_t *dest, const uint16_t *src, size_t n);
extern uint32_t *
u32_cpy (uint32_t *dest, const uint32_t *src, size_t n);
/* Copy N units from SRC to DEST, guaranteeing correct behavior for
overlapping memory areas. */
/* Similar to memmove(). */
extern uint8_t *
u8_move (uint8_t *dest, const uint8_t *src, size_t n);
extern uint16_t *
u16_move (uint16_t *dest, const uint16_t *src, size_t n);
extern uint32_t *
u32_move (uint32_t *dest, const uint32_t *src, size_t n);
/* Set the first N characters of S to UC. UC should be a character that
occupies only 1 unit. */
/* Similar to memset(). */
extern uint8_t *
u8_set (uint8_t *s, ucs4_t uc, size_t n);
extern uint16_t *
u16_set (uint16_t *s, ucs4_t uc, size_t n);
extern uint32_t *
u32_set (uint32_t *s, ucs4_t uc, size_t n);
/* Compare S1 and S2, each of length N. */
/* Similar to memcmp(). */
extern int
u8_cmp (const uint8_t *s1, const uint8_t *s2, size_t n)
_UC_ATTRIBUTE_PURE;
extern int
u16_cmp (const uint16_t *s1, const uint16_t *s2, size_t n)
_UC_ATTRIBUTE_PURE;
extern int
u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n)
_UC_ATTRIBUTE_PURE;
/* Compare S1 and S2. */
/* Similar to the gnulib function memcmp2(). */
extern int
u8_cmp2 (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2)
_UC_ATTRIBUTE_PURE;
extern int
u16_cmp2 (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2)
_UC_ATTRIBUTE_PURE;
extern int
u32_cmp2 (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2)
_UC_ATTRIBUTE_PURE;
/* Search the string at S for UC. */
/* Similar to memchr(). */
extern uint8_t *
u8_chr (const uint8_t *s, size_t n, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
extern uint16_t *
u16_chr (const uint16_t *s, size_t n, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
extern uint32_t *
u32_chr (const uint32_t *s, size_t n, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
/* Count the number of Unicode characters in the N units from S. */
/* Similar to mbsnlen(). */
extern size_t
u8_mbsnlen (const uint8_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
extern size_t
u16_mbsnlen (const uint16_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
extern size_t
u32_mbsnlen (const uint32_t *s, size_t n)
_UC_ATTRIBUTE_PURE;
/* Elementary string functions with memory allocation. */
/* Make a freshly allocated copy of S, of length N. */
extern uint8_t *
u8_cpy_alloc (const uint8_t *s, size_t n);
extern uint16_t *
u16_cpy_alloc (const uint16_t *s, size_t n);
extern uint32_t *
u32_cpy_alloc (const uint32_t *s, size_t n);
/* Elementary string functions on NUL terminated strings. */
/* Return the length (number of units) of the first character in S.
Return 0 if it is the NUL character. Return -1 upon failure. */
extern int
u8_strmblen (const uint8_t *s)
_UC_ATTRIBUTE_PURE;
extern int
u16_strmblen (const uint16_t *s)
_UC_ATTRIBUTE_PURE;
extern int
u32_strmblen (const uint32_t *s)
_UC_ATTRIBUTE_PURE;
/* Return the length (number of units) of the first character in S, putting
its 'ucs4_t' representation in *PUC. Return 0 if it is the NUL
character. Return -1 upon failure. */
extern int
u8_strmbtouc (ucs4_t *puc, const uint8_t *s);
extern int
u16_strmbtouc (ucs4_t *puc, const uint16_t *s);
extern int
u32_strmbtouc (ucs4_t *puc, const uint32_t *s);
/* Forward iteration step. Advances the pointer past the next character,
or returns NULL if the end of the string has been reached. Puts the
character's 'ucs4_t' representation in *PUC. */
extern const uint8_t *
u8_next (ucs4_t *puc, const uint8_t *s);
extern const uint16_t *
u16_next (ucs4_t *puc, const uint16_t *s);
extern const uint32_t *
u32_next (ucs4_t *puc, const uint32_t *s);
/* Backward iteration step. Advances the pointer to point to the previous
character, or returns NULL if the beginning of the string had been reached.
Puts the character's 'ucs4_t' representation in *PUC. */
extern const uint8_t *
u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start);
extern const uint16_t *
u16_prev (ucs4_t *puc, const uint16_t *s, const uint16_t *start);
extern const uint32_t *
u32_prev (ucs4_t *puc, const uint32_t *s, const uint32_t *start);
/* Return the number of units in S. */
/* Similar to strlen(), wcslen(). */
extern size_t
u8_strlen (const uint8_t *s)
_UC_ATTRIBUTE_PURE;
extern size_t
u16_strlen (const uint16_t *s)
_UC_ATTRIBUTE_PURE;
extern size_t
u32_strlen (const uint32_t *s)
_UC_ATTRIBUTE_PURE;
/* Return the number of units in S, but at most MAXLEN. */
/* Similar to strnlen(), wcsnlen(). */
extern size_t
u8_strnlen (const uint8_t *s, size_t maxlen)
_UC_ATTRIBUTE_PURE;
extern size_t
u16_strnlen (const uint16_t *s, size_t maxlen)
_UC_ATTRIBUTE_PURE;
extern size_t
u32_strnlen (const uint32_t *s, size_t maxlen)
_UC_ATTRIBUTE_PURE;
/* Copy SRC to DEST. */
/* Similar to strcpy(), wcscpy(). */
extern uint8_t *
u8_strcpy (uint8_t *dest, const uint8_t *src);
extern uint16_t *
u16_strcpy (uint16_t *dest, const uint16_t *src);
extern uint32_t *
u32_strcpy (uint32_t *dest, const uint32_t *src);
/* Copy SRC to DEST, returning the address of the terminating NUL in DEST. */
/* Similar to stpcpy(). */
extern uint8_t *
u8_stpcpy (uint8_t *dest, const uint8_t *src);
extern uint16_t *
u16_stpcpy (uint16_t *dest, const uint16_t *src);
extern uint32_t *
u32_stpcpy (uint32_t *dest, const uint32_t *src);
/* Copy no more than N units of SRC to DEST. */
/* Similar to strncpy(), wcsncpy(). */
extern uint8_t *
u8_strncpy (uint8_t *dest, const uint8_t *src, size_t n);
extern uint16_t *
u16_strncpy (uint16_t *dest, const uint16_t *src, size_t n);
extern uint32_t *
u32_strncpy (uint32_t *dest, const uint32_t *src, size_t n);
/* Copy no more than N units of SRC to DEST. Return a pointer past the last
non-NUL unit written into DEST. */
/* Similar to stpncpy(). */
extern uint8_t *
u8_stpncpy (uint8_t *dest, const uint8_t *src, size_t n);
extern uint16_t *
u16_stpncpy (uint16_t *dest, const uint16_t *src, size_t n);
extern uint32_t *
u32_stpncpy (uint32_t *dest, const uint32_t *src, size_t n);
/* Append SRC onto DEST. */
/* Similar to strcat(), wcscat(). */
extern uint8_t *
u8_strcat (uint8_t *dest, const uint8_t *src);
extern uint16_t *
u16_strcat (uint16_t *dest, const uint16_t *src);
extern uint32_t *
u32_strcat (uint32_t *dest, const uint32_t *src);
/* Append no more than N units of SRC onto DEST. */
/* Similar to strncat(), wcsncat(). */
extern uint8_t *
u8_strncat (uint8_t *dest, const uint8_t *src, size_t n);
extern uint16_t *
u16_strncat (uint16_t *dest, const uint16_t *src, size_t n);
extern uint32_t *
u32_strncat (uint32_t *dest, const uint32_t *src, size_t n);
/* Compare S1 and S2. */
/* Similar to strcmp(), wcscmp(). */
#ifdef __sun
/* Avoid a collision with the u8_strcmp() function in Solaris 11 libc. */
extern int
u8_strcmp_gnu (const uint8_t *s1, const uint8_t *s2)
_UC_ATTRIBUTE_PURE;
# define u8_strcmp u8_strcmp_gnu
#else
extern int
u8_strcmp (const uint8_t *s1, const uint8_t *s2)
_UC_ATTRIBUTE_PURE;
#endif
extern int
u16_strcmp (const uint16_t *s1, const uint16_t *s2)
_UC_ATTRIBUTE_PURE;
extern int
u32_strcmp (const uint32_t *s1, const uint32_t *s2)
_UC_ATTRIBUTE_PURE;
/* Compare S1 and S2 using the collation rules of the current locale.
Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2.
Upon failure, set errno and return any value. */
/* Similar to strcoll(), wcscoll(). */
extern int
u8_strcoll (const uint8_t *s1, const uint8_t *s2);
extern int
u16_strcoll (const uint16_t *s1, const uint16_t *s2);
extern int
u32_strcoll (const uint32_t *s1, const uint32_t *s2);
/* Compare no more than N units of S1 and S2. */
/* Similar to strncmp(), wcsncmp(). */
extern int
u8_strncmp (const uint8_t *s1, const uint8_t *s2, size_t n)
_UC_ATTRIBUTE_PURE;
extern int
u16_strncmp (const uint16_t *s1, const uint16_t *s2, size_t n)
_UC_ATTRIBUTE_PURE;
extern int
u32_strncmp (const uint32_t *s1, const uint32_t *s2, size_t n)
_UC_ATTRIBUTE_PURE;
/* Duplicate S, returning an identical malloc'd string. */
/* Similar to strdup(), wcsdup(). */
extern uint8_t *
u8_strdup (const uint8_t *s);
extern uint16_t *
u16_strdup (const uint16_t *s);
extern uint32_t *
u32_strdup (const uint32_t *s);
/* Find the first occurrence of UC in STR. */
/* Similar to strchr(), wcschr(). */
extern uint8_t *
u8_strchr (const uint8_t *str, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
extern uint16_t *
u16_strchr (const uint16_t *str, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
extern uint32_t *
u32_strchr (const uint32_t *str, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
/* Find the last occurrence of UC in STR. */
/* Similar to strrchr(), wcsrchr(). */
extern uint8_t *
u8_strrchr (const uint8_t *str, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
extern uint16_t *
u16_strrchr (const uint16_t *str, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
extern uint32_t *
u32_strrchr (const uint32_t *str, ucs4_t uc)
_UC_ATTRIBUTE_PURE;
/* Return the length of the initial segment of STR which consists entirely
of Unicode characters not in REJECT. */
/* Similar to strcspn(), wcscspn(). */
extern size_t
u8_strcspn (const uint8_t *str, const uint8_t *reject)
_UC_ATTRIBUTE_PURE;
extern size_t
u16_strcspn (const uint16_t *str, const uint16_t *reject)
_UC_ATTRIBUTE_PURE;
extern size_t
u32_strcspn (const uint32_t *str, const uint32_t *reject)
_UC_ATTRIBUTE_PURE;
/* Return the length of the initial segment of STR which consists entirely
of Unicode characters in ACCEPT. */
/* Similar to strspn(), wcsspn(). */
extern size_t
u8_strspn (const uint8_t *str, const uint8_t *accept)
_UC_ATTRIBUTE_PURE;
extern size_t
u16_strspn (const uint16_t *str, const uint16_t *accept)
_UC_ATTRIBUTE_PURE;
extern size_t
u32_strspn (const uint32_t *str, const uint32_t *accept)
_UC_ATTRIBUTE_PURE;
/* Find the first occurrence in STR of any character in ACCEPT. */
/* Similar to strpbrk(), wcspbrk(). */
extern uint8_t *
u8_strpbrk (const uint8_t *str, const uint8_t *accept)
_UC_ATTRIBUTE_PURE;
extern uint16_t *
u16_strpbrk (const uint16_t *str, const uint16_t *accept)
_UC_ATTRIBUTE_PURE;
extern uint32_t *
u32_strpbrk (const uint32_t *str, const uint32_t *accept)
_UC_ATTRIBUTE_PURE;
/* Find the first occurrence of NEEDLE in HAYSTACK. */
/* Similar to strstr(), wcsstr(). */
extern uint8_t *
u8_strstr (const uint8_t *haystack, const uint8_t *needle)
_UC_ATTRIBUTE_PURE;
extern uint16_t *
u16_strstr (const uint16_t *haystack, const uint16_t *needle)
_UC_ATTRIBUTE_PURE;
extern uint32_t *
u32_strstr (const uint32_t *haystack, const uint32_t *needle)
_UC_ATTRIBUTE_PURE;
/* Test whether STR starts with PREFIX. */
extern bool
u8_startswith (const uint8_t *str, const uint8_t *prefix)
_UC_ATTRIBUTE_PURE;
extern bool
u16_startswith (const uint16_t *str, const uint16_t *prefix)
_UC_ATTRIBUTE_PURE;
extern bool
u32_startswith (const uint32_t *str, const uint32_t *prefix)
_UC_ATTRIBUTE_PURE;
/* Test whether STR ends with SUFFIX. */
extern bool
u8_endswith (const uint8_t *str, const uint8_t *suffix)
_UC_ATTRIBUTE_PURE;
extern bool
u16_endswith (const uint16_t *str, const uint16_t *suffix)
_UC_ATTRIBUTE_PURE;
extern bool
u32_endswith (const uint32_t *str, const uint32_t *suffix)
_UC_ATTRIBUTE_PURE;
/* Divide STR into tokens separated by characters in DELIM.
This interface is actually more similar to wcstok than to strtok. */
/* Similar to strtok_r(), wcstok(). */
extern uint8_t *
u8_strtok (uint8_t *str, const uint8_t *delim, uint8_t **ptr);
extern uint16_t *
u16_strtok (uint16_t *str, const uint16_t *delim, uint16_t **ptr);
extern uint32_t *
u32_strtok (uint32_t *str, const uint32_t *delim, uint32_t **ptr);
#ifdef __cplusplus
}
#endif
#endif /* _UNISTR_H */
gsasl-1.8.1/gl/fd-hook.h 0000644 0000000 0000000 00000011343 13516251574 011636 0000000 0000000 /* Hook for making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
#ifndef FD_HOOK_H
#define FD_HOOK_H
#ifdef __cplusplus
extern "C" {
#endif
/* Currently, this entire code is only needed for the handling of sockets
on native Windows platforms. */
#if WINDOWS_SOCKETS
/* Type of function that closes FD. */
typedef int (*gl_close_fn) (int fd);
/* Type of function that applies a control request to FD. */
typedef int (*gl_ioctl_fn) (int fd, int request, void *arg);
/* An element of the list of file descriptor hooks.
In CLOS (Common Lisp Object System) speak, it consists of an "around"
method for the close() function and an "around" method for the ioctl()
function.
The fields of this structure are considered private. */
struct fd_hook
{
/* Doubly linked list. */
struct fd_hook *private_next;
struct fd_hook *private_prev;
/* Function that treats the types of FD that it knows about and calls
execute_close_hooks (REMAINING_LIST, PRIMARY, FD) as a fallback. */
int (*private_close_fn) (const struct fd_hook *remaining_list,
gl_close_fn primary,
int fd);
/* Function that treats the types of FD that it knows about and calls
execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) as a
fallback. */
int (*private_ioctl_fn) (const struct fd_hook *remaining_list,
gl_ioctl_fn primary,
int fd, int request, void *arg);
};
/* This type of function closes FD, applying special knowledge for the FD
types it knows about, and calls
execute_close_hooks (REMAINING_LIST, PRIMARY, FD)
for the other FD types.
In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
and PRIMARY is the "primary" method for close(). */
typedef int (*close_hook_fn) (const struct fd_hook *remaining_list,
gl_close_fn primary,
int fd);
/* Execute the close hooks in REMAINING_LIST, with PRIMARY as "primary" method.
Return 0 or -1, like close() would do. */
extern int execute_close_hooks (const struct fd_hook *remaining_list,
gl_close_fn primary,
int fd);
/* Execute all close hooks, with PRIMARY as "primary" method.
Return 0 or -1, like close() would do. */
extern int execute_all_close_hooks (gl_close_fn primary, int fd);
/* This type of function applies a control request to FD, applying special
knowledge for the FD types it knows about, and calls
execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG)
for the other FD types.
In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
and PRIMARY is the "primary" method for ioctl(). */
typedef int (*ioctl_hook_fn) (const struct fd_hook *remaining_list,
gl_ioctl_fn primary,
int fd, int request, void *arg);
/* Execute the ioctl hooks in REMAINING_LIST, with PRIMARY as "primary" method.
Return 0 or -1, like ioctl() would do. */
extern int execute_ioctl_hooks (const struct fd_hook *remaining_list,
gl_ioctl_fn primary,
int fd, int request, void *arg);
/* Execute all ioctl hooks, with PRIMARY as "primary" method.
Return 0 or -1, like ioctl() would do. */
extern int execute_all_ioctl_hooks (gl_ioctl_fn primary,
int fd, int request, void *arg);
/* Add a function pair to the list of file descriptor hooks.
CLOSE_HOOK and IOCTL_HOOK may be NULL, indicating no change.
The LINK variable points to a piece of memory which is guaranteed to be
accessible until the corresponding call to unregister_fd_hook. */
extern void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook,
struct fd_hook *link);
/* Removes a hook from the list of file descriptor hooks. */
extern void unregister_fd_hook (struct fd_hook *link);
#endif
#ifdef __cplusplus
}
#endif
#endif /* FD_HOOK_H */
gsasl-1.8.1/gl/getpass.h 0000644 0000000 0000000 00000000165 13516251574 011755 0000000 0000000 /* Obsolete; consider using unistd.h instead. */
/* Get getpass declaration, if available. */
#include
gsasl-1.8.1/gl/netinet_in.in.h 0000644 0000000 0000000 00000002475 13516251576 013060 0000000 0000000 /* Substitute for .
Copyright (C) 2007-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
#ifndef _@GUARD_PREFIX@_NETINET_IN_H
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
#if @HAVE_NETINET_IN_H@
/* On many platforms, assumes prior inclusion of
. */
# include
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_NETINET_IN_H@
#endif
#ifndef _@GUARD_PREFIX@_NETINET_IN_H
#define _@GUARD_PREFIX@_NETINET_IN_H
#if !@HAVE_NETINET_IN_H@
/* A platform that lacks . */
# include
#endif
#endif /* _@GUARD_PREFIX@_NETINET_IN_H */
#endif /* _@GUARD_PREFIX@_NETINET_IN_H */
gsasl-1.8.1/gl/c-strcasecmp.c 0000644 0000000 0000000 00000003045 13516251574 012666 0000000 0000000 /* c-strcasecmp.c -- case insensitive string comparator in C locale
Copyright (C) 1998-1999, 2005-2006, 2009-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
#include
/* Specification. */
#include "c-strcase.h"
#include
#include "c-ctype.h"
int
c_strcasecmp (const char *s1, const char *s2)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2)
return 0;
do
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
if (c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
}
gsasl-1.8.1/gl/time.in.h 0000644 0000000 0000000 00000031342 13516251577 011656 0000000 0000000 /* A more-standard .
Copyright (C) 2007-2019 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see . */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* Don't get in the way of glibc when it includes time.h merely to
declare a few standard symbols, rather than to declare all the
symbols. (However, skip this for MinGW as it treats __need_time_t
incompatibly.) Also, Solaris 8 eventually includes itself
recursively; if that is happening, just include the system
without adding our own declarations. */
#if (((defined __need_time_t || defined __need_clock_t \
|| defined __need_timespec) \
&& !defined __MINGW32__) \
|| defined _@GUARD_PREFIX@_TIME_H)
# @INCLUDE_NEXT@ @NEXT_TIME_H@
#else
# define _@GUARD_PREFIX@_TIME_H
# @INCLUDE_NEXT@ @NEXT_TIME_H@
/* NetBSD 5.0 mis-defines NULL. */
# include
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
/* Some systems don't define struct timespec (e.g., AIX 4.1).
Or they define it with the wrong member names or define it in
(e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it,
but the pthreads-win32 library defines it in . */
# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
# include
# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
# include
# elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
# include
# else
# ifdef __cplusplus
extern "C" {
# endif
# if !GNULIB_defined_struct_timespec
# undef timespec
# define timespec rpl_timespec
struct timespec
{
time_t tv_sec;
long int tv_nsec;
};
# define GNULIB_defined_struct_timespec 1
# endif
# ifdef __cplusplus
}
# endif
# endif
# endif
# if !GNULIB_defined_struct_time_t_must_be_integral
/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
time_t to be an integer type, even though C99 permits floating
point. We don't know of any implementation that uses floating
point, and it is much easier to write code that doesn't have to
worry about that corner case, so we force the issue. */
struct __time_t_must_be_integral {
unsigned int __floating_time_t_unsupported : (time_t) 1;
};
# define GNULIB_defined_struct_time_t_must_be_integral 1
# endif
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
return -1 and store the remaining time into RMTP. See
. */
# if @GNULIB_NANOSLEEP@
# if @REPLACE_NANOSLEEP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define nanosleep rpl_nanosleep
# endif
_GL_FUNCDECL_RPL (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# else
# if ! @HAVE_NANOSLEEP@
_GL_FUNCDECL_SYS (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# endif
_GL_CXXALIASWARN (nanosleep);
# endif
/* Initialize time conversion information. */
# if @GNULIB_TZSET@
# if @REPLACE_TZSET@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef tzset
# define tzset rpl_tzset
# endif
_GL_FUNCDECL_RPL (tzset, void, (void));
_GL_CXXALIAS_RPL (tzset, void, (void));
# else
# if ! @HAVE_TZSET@
_GL_FUNCDECL_SYS (tzset, void, (void));
# endif
_GL_CXXALIAS_SYS (tzset, void, (void));
# endif
_GL_CXXALIASWARN (tzset);
# endif
/* Return the 'time_t' representation of TP and normalize TP. */
# if @GNULIB_MKTIME@
# if @REPLACE_MKTIME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define mktime rpl_mktime
# endif
_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
# else
_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
# endif
_GL_CXXALIASWARN (mktime);
# endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
and
. */
# if @GNULIB_TIME_R@
# if @REPLACE_LOCALTIME_R@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef localtime_r
# define localtime_r rpl_localtime_r
# endif
_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
# if ! @HAVE_DECL_LOCALTIME_R@
_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
# if @HAVE_DECL_LOCALTIME_R@
_GL_CXXALIASWARN (localtime_r);
# endif
# if @REPLACE_LOCALTIME_R@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef gmtime_r
# define gmtime_r rpl_gmtime_r
# endif
_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
# if ! @HAVE_DECL_LOCALTIME_R@
_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
# if @HAVE_DECL_LOCALTIME_R@
_GL_CXXALIASWARN (gmtime_r);
# endif
# endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
and
. */
# if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
# if @REPLACE_LOCALTIME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef localtime
# define localtime rpl_localtime
# endif
_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
# else
_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
# endif
_GL_CXXALIASWARN (localtime);
# endif
# if 0 || @REPLACE_GMTIME@
# if @REPLACE_GMTIME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef gmtime
# define gmtime rpl_gmtime
# endif
_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
# else
_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
# endif
_GL_CXXALIASWARN (gmtime);
# endif
/* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
the resulting broken-down time into TM. See
. */
# if @GNULIB_STRPTIME@
# if ! @HAVE_STRPTIME@
_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
char const *restrict __format,
struct tm *restrict __tm)
_GL_ARG_NONNULL ((1, 2, 3)));
# endif
_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
char const *restrict __format,
struct tm *restrict __tm));
_GL_CXXALIASWARN (strptime);
# endif
/* Convert *TP to a date and time string. See
. */
# if @GNULIB_CTIME@
# if @REPLACE_CTIME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define ctime rpl_ctime
# endif
_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
# else
_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
# endif
_GL_CXXALIASWARN (ctime);
# endif
/* Convert *TP to a date and time string. See
. */
# if @GNULIB_STRFTIME@
# if @REPLACE_STRFTIME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define strftime rpl_strftime
# endif
_GL_FUNCDECL_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
const char *__fmt, const struct tm *__tp)
_GL_ARG_NONNULL ((1, 3, 4)));
_GL_CXXALIAS_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
const char *__fmt, const struct tm *__tp));
# else
_GL_CXXALIAS_SYS (strftime, size_t, (char *__buf, size_t __bufsize,
const char *__fmt, const struct tm *__tp));
# endif
_GL_CXXALIASWARN (strftime);
# endif
# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
typedef struct tm_zone *timezone_t;
_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
(timezone_t __tz, time_t const *restrict __timer,
struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
(timezone_t __tz, time_t const *restrict __timer,
struct tm *restrict __result));
_GL_FUNCDECL_SYS (mktime_z, time_t,
(timezone_t __tz, struct tm *restrict __result)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_SYS (mktime_z, time_t,
(timezone_t __tz, struct tm *restrict __result));
# endif
/* Convert TM to a time_t value, assuming UTC. */
# if @GNULIB_TIMEGM@
# if @REPLACE_TIMEGM@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef timegm
# define timegm rpl_timegm
# endif
_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
# else
# if ! @HAVE_TIMEGM@
_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
# endif
_GL_CXXALIASWARN (timegm);
# endif
/* Encourage applications to avoid unsafe functions that can overrun
buffers when given outlandish struct tm values. Portable
applications should use strftime (or even sprintf) instead. */
# if defined GNULIB_POSIXCHECK
# undef asctime
_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
# endif
# if defined GNULIB_POSIXCHECK
# undef asctime_r
_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime
_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime_r
_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
# endif
#endif
gsasl-1.8.1/gl/getopt-pfx-core.h 0000644 0000000 0000000 00000004262 13516251573 013333 0000000 0000000 /* getopt (basic, portable features) gnulib wrapper header.
Copyright (C) 1989-2019 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library.
This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with gnulib; if not, see
. */
#ifndef _GETOPT_PFX_CORE_H
#define _GETOPT_PFX_CORE_H 1
/* This header should not be used directly; include getopt.h or
unistd.h instead. It does not have a protective #error, because
the guard macro for getopt.h in gnulib is not fixed. */
/* Standalone applications should #define __GETOPT_PREFIX to an
identifier that prefixes the external functions and variables
defined in getopt-core.h and getopt-ext.h. Systematically
rename identifiers so that they do not collide with the system
functions and variables. Renaming avoids problems with some
compilers and linkers. */
#ifdef __GETOPT_PREFIX
# ifndef __GETOPT_ID
# define __GETOPT_CONCAT(x, y) x ## y
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
# endif
# undef getopt
# undef optarg
# undef opterr
# undef optind
# undef optopt
# define getopt __GETOPT_ID (getopt)
# define optarg __GETOPT_ID (optarg)
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
/* The system's getopt.h may have already included getopt-core.h to
declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
getopt-core.h declares them with prefixes. */
# undef _GETOPT_CORE_H
#endif
#include
#endif /* _GETOPT_PFX_CORE_H */
gsasl-1.8.1/gl/stat-w32.c 0000644 0000000 0000000 00000042242 13516251573 011667 0000000 0000000 /* Core of implementation of fstat and stat for native Windows.
Copyright (C) 2017-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* Written by Bruno Haible. */
#include
#if defined _WIN32 && ! defined __CYGWIN__
/* Ensure that defines FILE_ID_INFO. */
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#include
#include
#include
#include
#include
#include
#include
/* Specification. */
#include "stat-w32.h"
#include "pathmax.h"
#include "verify.h"
/* Avoid warnings from gcc -Wcast-function-type. */
#define GetProcAddress \
(void *) GetProcAddress
#if _GL_WINDOWS_STAT_INODES == 2
/* GetFileInformationByHandleEx was introduced only in Windows Vista. */
typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,
FILE_INFO_BY_HANDLE_CLASS fiClass,
LPVOID lpBuffer,
DWORD dwBufferSize);
static GetFileInformationByHandleExFuncType GetFileInformationByHandleExFunc = NULL;
#endif
/* GetFinalPathNameByHandle was introduced only in Windows Vista. */
typedef DWORD (WINAPI * GetFinalPathNameByHandleFuncType) (HANDLE hFile,
LPTSTR lpFilePath,
DWORD lenFilePath,
DWORD dwFlags);
static GetFinalPathNameByHandleFuncType GetFinalPathNameByHandleFunc = NULL;
static BOOL initialized = FALSE;
static void
initialize (void)
{
HMODULE kernel32 = LoadLibrary ("kernel32.dll");
if (kernel32 != NULL)
{
#if _GL_WINDOWS_STAT_INODES == 2
GetFileInformationByHandleExFunc =
(GetFileInformationByHandleExFuncType) GetProcAddress (kernel32, "GetFileInformationByHandleEx");
#endif
GetFinalPathNameByHandleFunc =
(GetFinalPathNameByHandleFuncType) GetProcAddress (kernel32, "GetFinalPathNameByHandleA");
}
initialized = TRUE;
}
/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
#if _GL_WINDOWS_STAT_TIMESPEC
struct timespec
_gl_convert_FILETIME_to_timespec (const FILETIME *ft)
{
struct timespec result;
/* FILETIME: */
unsigned long long since_1601 =
((unsigned long long) ft->dwHighDateTime << 32)
| (unsigned long long) ft->dwLowDateTime;
if (since_1601 == 0)
{
result.tv_sec = 0;
result.tv_nsec = 0;
}
else
{
/* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
leap years, in total 134774 days. */
unsigned long long since_1970 =
since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
result.tv_sec = since_1970 / (unsigned long long) 10000000;
result.tv_nsec = (unsigned long) (since_1970 % (unsigned long long) 10000000) * 100;
}
return result;
}
#else
time_t
_gl_convert_FILETIME_to_POSIX (const FILETIME *ft)
{
/* FILETIME: */
unsigned long long since_1601 =
((unsigned long long) ft->dwHighDateTime << 32)
| (unsigned long long) ft->dwLowDateTime;
if (since_1601 == 0)
return 0;
else
{
/* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
leap years, in total 134774 days. */
unsigned long long since_1970 =
since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
return since_1970 / (unsigned long long) 10000000;
}
}
#endif
/* Fill *BUF with information about the file designated by H.
PATH is the file name, if known, otherwise NULL.
Return 0 if successful, or -1 with errno set upon failure. */
int
_gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
{
/* GetFileType
*/
DWORD type = GetFileType (h);
if (type == FILE_TYPE_DISK)
{
if (!initialized)
initialize ();
/* st_mode can be determined through
GetFileAttributesEx
or through
GetFileInformationByHandle
or through
GetFileInformationByHandleEx with argument FileBasicInfo
The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
BY_HANDLE_FILE_INFORMATION info;
if (! GetFileInformationByHandle (h, &info))
goto failed;
/* Test for error conditions before starting to fill *buf. */
if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
{
errno = EOVERFLOW;
return -1;
}
#if _GL_WINDOWS_STAT_INODES
/* st_ino can be determined through
GetFileInformationByHandle
as 64 bits, or through
GetFileInformationByHandleEx with argument FileIdInfo
as 128 bits.
The latter requires -D_WIN32_WINNT=_WIN32_WINNT_WIN8 or higher. */
/* Experiments show that GetFileInformationByHandleEx does not provide
much more information than GetFileInformationByHandle:
* The dwVolumeSerialNumber from GetFileInformationByHandle is equal
to the low 32 bits of the 64-bit VolumeSerialNumber from
GetFileInformationByHandleEx, and is apparently sufficient for
identifying the device.
* The nFileIndex from GetFileInformationByHandle is equal to the low
64 bits of the 128-bit FileId from GetFileInformationByHandleEx,
and the high 64 bits of this 128-bit FileId are zero.
* On a FAT file system, GetFileInformationByHandleEx fails with error
ERROR_INVALID_PARAMETER, whereas GetFileInformationByHandle
succeeds.
* On a CIFS/SMB file system, GetFileInformationByHandleEx fails with
error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle
succeeds. */
# if _GL_WINDOWS_STAT_INODES == 2
if (GetFileInformationByHandleExFunc != NULL)
{
FILE_ID_INFO id;
if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id)))
{
buf->st_dev = id.VolumeSerialNumber;
verify (sizeof (ino_t) == sizeof (id.FileId));
memcpy (&buf->st_ino, &id.FileId, sizeof (ino_t));
goto ino_done;
}
else
{
switch (GetLastError ())
{
case ERROR_INVALID_PARAMETER: /* older Windows version, or FAT */
case ERROR_INVALID_LEVEL: /* CIFS/SMB file system */
goto fallback;
default:
goto failed;
}
}
}
fallback: ;
/* Fallback for older Windows versions. */
buf->st_dev = info.dwVolumeSerialNumber;
buf->st_ino._gl_ino[0] = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
buf->st_ino._gl_ino[1] = 0;
ino_done: ;
# else /* _GL_WINDOWS_STAT_INODES == 1 */
buf->st_dev = info.dwVolumeSerialNumber;
buf->st_ino = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
# endif
#else
/* st_ino is not wide enough for identifying a file on a device.
Without st_ino, st_dev is pointless. */
buf->st_dev = 0;
buf->st_ino = 0;
#endif
/* st_mode. */
unsigned int mode =
/* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
| S_IREAD_UGO
| ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
/* Determine whether the file is executable by looking at the file
name suffix.
If the file name is already known, use it. Otherwise, for
non-empty files, it can be determined through
GetFinalPathNameByHandle
or through
GetFileInformationByHandleEx with argument FileNameInfo
Both require -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
{
char fpath[PATH_MAX];
if (path != NULL
|| (GetFinalPathNameByHandleFunc != NULL
&& GetFinalPathNameByHandleFunc (h, fpath, sizeof (fpath), VOLUME_NAME_NONE)
< sizeof (fpath)
&& (path = fpath, 1)))
{
const char *last_dot = NULL;
const char *p;
for (p = path; *p != '\0'; p++)
if (*p == '.')
last_dot = p;
if (last_dot != NULL)
{
const char *suffix = last_dot + 1;
if (_stricmp (suffix, "exe") == 0
|| _stricmp (suffix, "bat") == 0
|| _stricmp (suffix, "cmd") == 0
|| _stricmp (suffix, "com") == 0)
mode |= S_IEXEC_UGO;
}
}
else
/* Cannot determine file name. Pretend that it is executable. */
mode |= S_IEXEC_UGO;
}
}
buf->st_mode = mode;
/* st_nlink can be determined through
GetFileInformationByHandle
or through
GetFileInformationByHandleEx with argument FileStandardInfo
The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
buf->st_nlink = (info.nNumberOfLinks > SHRT_MAX ? SHRT_MAX : info.nNumberOfLinks);
/* There's no easy way to map the Windows SID concept to an integer. */
buf->st_uid = 0;
buf->st_gid = 0;
/* st_rdev is irrelevant for normal files and directories. */
buf->st_rdev = 0;
/* st_size can be determined through
GetFileSizeEx
or through
GetFileAttributesEx
or through
GetFileInformationByHandle
or through
GetFileInformationByHandleEx with argument FileStandardInfo
The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
if (sizeof (buf->st_size) <= 4)
/* Range check already done above. */
buf->st_size = info.nFileSizeLow;
else
buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
/* st_atime, st_mtime, st_ctime can be determined through
GetFileTime
or through
GetFileAttributesEx
or through
GetFileInformationByHandle
or through
GetFileInformationByHandleEx with argument FileBasicInfo
The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
#if _GL_WINDOWS_STAT_TIMESPEC
buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
#else
buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
#endif
return 0;
}
else if (type == FILE_TYPE_CHAR || type == FILE_TYPE_PIPE)
{
buf->st_dev = 0;
#if _GL_WINDOWS_STAT_INODES == 2
buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
#else
buf->st_ino = 0;
#endif
buf->st_mode = (type == FILE_TYPE_PIPE ? _S_IFIFO : _S_IFCHR);
buf->st_nlink = 1;
buf->st_uid = 0;
buf->st_gid = 0;
buf->st_rdev = 0;
if (type == FILE_TYPE_PIPE)
{
/* PeekNamedPipe
*/
DWORD bytes_available;
if (PeekNamedPipe (h, NULL, 0, NULL, &bytes_available, NULL))
buf->st_size = bytes_available;
else
buf->st_size = 0;
}
else
buf->st_size = 0;
#if _GL_WINDOWS_STAT_TIMESPEC
buf->st_atim.tv_sec = 0; buf->st_atim.tv_nsec = 0;
buf->st_mtim.tv_sec = 0; buf->st_mtim.tv_nsec = 0;
buf->st_ctim.tv_sec = 0; buf->st_ctim.tv_nsec = 0;
#else
buf->st_atime = 0;
buf->st_mtime = 0;
buf->st_ctime = 0;
#endif
return 0;
}
else
{
errno = ENOENT;
return -1;
}
failed:
{
DWORD error = GetLastError ();
#if 0
fprintf (stderr, "_gl_fstat_by_handle error 0x%x\n", (unsigned int) error);
#endif
switch (error)
{
case ERROR_ACCESS_DENIED:
case ERROR_SHARING_VIOLATION:
errno = EACCES;
break;
case ERROR_OUTOFMEMORY:
errno = ENOMEM;
break;
case ERROR_WRITE_FAULT:
case ERROR_READ_FAULT:
case ERROR_GEN_FAILURE:
errno = EIO;
break;
default:
errno = EINVAL;
break;
}
return -1;
}
}
#else
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
typedef int dummy;
#endif
gsasl-1.8.1/gl/memchr.c 0000644 0000000 0000000 00000013347 13516251576 011565 0000000 0000000 /* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2019
Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
with help from Dan Sahlin (dan@sics.se) and
commentary by Jim Blandy (jimb@ai.mit.edu);
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
and implemented by Roland McGrath (roland@ai.mit.edu).
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see