summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am5
-rw-r--r--include/Makefile.in25
-rw-r--r--include/libHX/defs.h12
-rw-r--r--include/libHX/intdiff.hpp24
-rw-r--r--include/libHX/io.h8
-rw-r--r--include/libHX/misc.h11
-rw-r--r--include/libHX/option.h18
-rw-r--r--include/libHX/proc.h12
-rw-r--r--include/libHX/socket.h23
-rw-r--r--include/libHX/string.h14
10 files changed, 119 insertions, 33 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index b70eebd..dd74f9a 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -2,7 +2,6 @@
nobase_include_HEADERS = libHX.h \
libHX/ctype_helper.h libHX/defs.h libHX/deque.h libHX/init.h \
- libHX/io.h libHX/list.h \
- libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/string.h \
+ libHX/intdiff.hpp libHX/io.h libHX/list.h \
+ libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/socket.h libHX/string.h \
libHX/libxml_helper.h libHX/wx_helper.hpp
-
diff --git a/include/Makefile.in b/include/Makefile.in
index f485a2b..525f047 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -169,8 +169,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@@ -184,8 +182,9 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
-CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -200,8 +199,10 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+FILECMD = @FILECMD@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
@@ -217,7 +218,6 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
-LYX = @LYX@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
@@ -294,6 +294,7 @@ psdir = @psdir@
regular_CFLAGS = @regular_CFLAGS@
regular_CPPFLAGS = @regular_CPPFLAGS@
regular_CXXFLAGS = @regular_CXXFLAGS@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -304,8 +305,8 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
nobase_include_HEADERS = libHX.h \
libHX/ctype_helper.h libHX/defs.h libHX/deque.h libHX/init.h \
- libHX/io.h libHX/list.h \
- libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/string.h \
+ libHX/intdiff.hpp libHX/io.h libHX/list.h \
+ libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/socket.h libHX/string.h \
libHX/libxml_helper.h libHX/wx_helper.hpp
all: all-am
@@ -328,8 +329,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -422,8 +423,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
-distdir: $(DISTFILES)
+distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
diff --git a/include/libHX/defs.h b/include/libHX/defs.h
index 1ace518..9d17019 100644
--- a/include/libHX/defs.h
+++ b/include/libHX/defs.h
@@ -10,8 +10,8 @@
# endif
# ifndef containerof
# include <cstddef>
-# define containerof(var, type, member) reinterpret_cast<type *>( \
- reinterpret_cast<char *>(var) - offsetof(type, member))
+# include <type_traits>
+# define containerof(var, T, member) reinterpret_cast<std::conditional<std::is_const<std::remove_pointer<decltype(var)>::type>::value, std::add_const<T>::type, T>::type *>(reinterpret_cast<std::conditional<std::is_const<std::remove_pointer<decltype(var)>::type>::value, const char, char>::type *>(var) - offsetof(T, member))
# endif
# ifndef static_cast
# define static_cast(T, x) static_cast<T>(x)
@@ -213,15 +213,15 @@ static __inline__ new_type signed_cast(unsigned char *expr)
# define container_of(v, s, m) containerof((v), s, m)
#endif
-#ifdef _WIN32
+#if !defined(_WIN32) || (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO + 0 > 0)
/*
* Sufficiently old versions of the VC runtime do not even support %ll.
*/
-# define HX_LONGLONG_FMT "I64"
-# define HX_SIZET_FMT "I"
-#else
# define HX_LONGLONG_FMT "ll"
# define HX_SIZET_FMT "z"
+#else
+# define HX_LONGLONG_FMT "I64"
+# define HX_SIZET_FMT "I"
#endif
#endif /* _LIBHX_DEFS_H */
diff --git a/include/libHX/intdiff.hpp b/include/libHX/intdiff.hpp
new file mode 100644
index 0000000..17300a1
--- /dev/null
+++ b/include/libHX/intdiff.hpp
@@ -0,0 +1,24 @@
+#ifndef LIBHX_INTDIFF_HPP
+#define LIBHX_INTDIFF_HPP 1
+#include <algorithm>
+namespace HX {
+template<typename AIter, typename BIter, typename XIter,
+ typename YIter, typename ZIter>
+void set_intersect_diff(AIter a_first, AIter a_last, BIter b_first,
+ BIter b_last, XIter xptr, YIter yptr, ZIter zptr)
+{
+ while ((a_first != a_last) && (b_first != b_last)) {
+ if (*a_first < *b_first)
+ *xptr++ = *a_first++;
+ else if (*b_first < *a_first)
+ *yptr++ = *b_first++;
+ else {
+ *zptr++ = *a_first++;
+ ++b_first;
+ }
+ }
+ std::copy(a_first, a_last, xptr);
+ std::copy(b_first, b_last, yptr);
+}
+}
+#endif
diff --git a/include/libHX/io.h b/include/libHX/io.h
index c86af72..7e0c7d3 100644
--- a/include/libHX/io.h
+++ b/include/libHX/io.h
@@ -1,6 +1,7 @@
#ifndef _LIBHX_IO_H
#define _LIBHX_IO_H 1
+#include <stdio.h>
#include <sys/types.h>
#ifdef __cplusplus
@@ -35,9 +36,16 @@ extern int HX_mkdir(const char *, unsigned int);
extern int HX_readlink(hxmc_t **, const char *);
extern int HX_realpath(hxmc_t **, const char *, unsigned int);
extern int HX_rrmdir(const char *);
+extern ssize_t HX_sendfile(int dst, int src, size_t count);
+extern char *HX_slurp_fd(int fd, size_t *outsize);
+extern char *HX_slurp_file(const char *file, size_t *outsize);
extern ssize_t HXio_fullread(int, void *, size_t);
extern ssize_t HXio_fullwrite(int, const void *, size_t);
+#ifndef HX_HEXDUMP_DECLARATION
+#define HX_HEXDUMP_DECLARATION 1
+extern void HX_hexdump(FILE *, const void *, unsigned int);
+#endif
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/libHX/misc.h b/include/libHX/misc.h
index adebf22..23607d2 100644
--- a/include/libHX/misc.h
+++ b/include/libHX/misc.h
@@ -35,11 +35,11 @@ extern "C" {
#define HX_TIMESPEC_FMT "%ld.%09ld"
#define HX_TIMEVAL_FMT "%ld.%06ld"
#ifdef __cplusplus
-# define HX_TIMESPEC_EXP(p) static_cast<long>((p)->tv_sec), (p)->tv_nsec
-# define HX_TIMEVAL_EXP(p) static_cast<long>((p)->tv_sec), (p)->tv_usec
+# define HX_TIMESPEC_EXP(p) static_cast<long>((p)->tv_sec), static_cast<long>((p)->tv_nsec)
+# define HX_TIMEVAL_EXP(p) static_cast<long>((p)->tv_sec), static_cast<long>((p)->tv_usec)
#else
-# define HX_TIMESPEC_EXP(p) static_cast(long, (p)->tv_sec), (p)->tv_nsec
-# define HX_TIMEVAL_EXP(p) static_cast(long, (p)->tv_sec), (p)->tv_usec
+# define HX_TIMESPEC_EXP(p) static_cast(long, (p)->tv_sec), static_cast(long, (p)->tv_nsec)
+# define HX_TIMEVAL_EXP(p) static_cast(long, (p)->tv_sec), static_cast(long, (p)->tv_usec)
#endif
struct stat;
@@ -59,7 +59,10 @@ extern const char *HX_dlerror(void);
*/
extern int HX_ffs(unsigned long);
extern int HX_fls(unsigned long);
+#ifndef HX_HEXDUMP_DECLARATION
+#define HX_HEXDUMP_DECLARATION 1
extern void HX_hexdump(FILE *, const void *, unsigned int);
+#endif
extern bool HX_timespec_isneg(const struct timespec *);
extern struct timespec *HX_timespec_neg(struct timespec *,
const struct timespec *);
diff --git a/include/libHX/option.h b/include/libHX/option.h
index 82255d3..40cc6e7 100644
--- a/include/libHX/option.h
+++ b/include/libHX/option.h
@@ -27,12 +27,12 @@ extern struct HXformat_map *HXformat_init(void);
extern void HXformat_free(struct HXformat_map *);
extern int HXformat_add(struct HXformat_map *, const char *, const void *,
unsigned int);
-extern int HXformat_aprintf(const struct HXformat_map *,
- hxmc_t **, const char *);
-extern int HXformat_sprintf(const struct HXformat_map *,
- char *, size_t, const char *);
-extern int HXformat_fprintf(const struct HXformat_map *,
- FILE *, const char *);
+#define HXformat_aprintf(a, b, c) HXformat3_aprintf((a), (b), (c))
+#define HXformat_fprintf(a, b, c) HXformat3_fprintf((a), (b), (c))
+#define HXformat_sprintf(a, b, c, d) HXformat3_sprintf((a), (b), (c), (d))
+extern ssize_t HXformat3_aprintf(const struct HXformat_map *, hxmc_t **, const char *);
+extern ssize_t HXformat3_fprintf(const struct HXformat_map *, FILE *, const char *);
+extern ssize_t HXformat3_sprintf(const struct HXformat_map *, char *, size_t, const char *);
/*
* OPT.C
@@ -77,7 +77,7 @@ extern int HXformat_fprintf(const struct HXformat_map *,
* Type expected of struct HXoption.ptr is given in ().
* HX_getopt (o) and HXformat_* (f) support different sets, marked with [].
*/
-enum HX_option_type {
+enum {
HXTYPE_NONE = 0,
HXTYPE_VAL,
HXTYPE_SVAL,
@@ -110,7 +110,6 @@ enum HX_option_type {
HXTYPE_XSNTMARK,
HXTYPE_XHELP, /* 30 */
HXTYPE_SIZE_T,
-};
/**
* Extra flags to be OR'ed into struct HXoption.type.
@@ -125,7 +124,6 @@ enum HX_option_type {
* %HXOPT_AND: AND *ptr by argument
* %HXOPT_XOR: XOR *ptr by argument
*/
-enum {
HXOPT_OPTIONAL = 1 << 6,
HXOPT_INC = 1 << 7,
HXOPT_DEC = 1 << 8,
@@ -144,6 +142,7 @@ enum {
* %HXOPT_USAGEONERR: print out short usage when a parsing error occurs
* %HXOPT_RQ_ORDER: require option order/POSIX mode:
* first non-option terminates option processing
+ * %HXOPT_KEEP_ARGV: do not replace argc/argv at all
*/
enum {
HXOPT_PTHRU = 1 << 0,
@@ -152,6 +151,7 @@ enum {
HXOPT_HELPONERR = 1 << 3,
HXOPT_USAGEONERR = 1 << 4,
HXOPT_RQ_ORDER = 1 << 5,
+ HXOPT_KEEP_ARGV = 1 << 6,
};
/**
diff --git a/include/libHX/proc.h b/include/libHX/proc.h
index cb682ed..fb17d5e 100644
--- a/include/libHX/proc.h
+++ b/include/libHX/proc.h
@@ -21,6 +21,16 @@ enum {
HXPROC_NULL_STDERR = 1 << 8,
};
+enum HXproc_su_status {
+ HXPROC_INITGROUPS_FAILED = -5,
+ HXPROC_SETGID_FAILED = -4,
+ HXPROC_SETUID_FAILED = -3,
+ HXPROC_GROUP_NOT_FOUND = -2,
+ HXPROC_USER_NOT_FOUND = -1,
+ HXPROC_SU_NOOP = 0,
+ HXPROC_SU_SUCCESS = 1,
+};
+
struct HXproc_ops {
void (*p_prefork)(void *);
void (*p_postfork)(void *);
@@ -41,6 +51,8 @@ struct HXproc {
extern int HXproc_run_async(const char *const *, struct HXproc *);
extern int HXproc_run_sync(const char *const *, unsigned int);
extern int HXproc_wait(struct HXproc *);
+extern enum HXproc_su_status HXproc_switch_user(const char *user, const char *group);
+extern int HXproc_top_fd(void);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/include/libHX/socket.h b/include/libHX/socket.h
new file mode 100644
index 0000000..e9db77f
--- /dev/null
+++ b/include/libHX/socket.h
@@ -0,0 +1,23 @@
+#ifndef _LIBHX_SOCKET_H
+#define _LIBHX_SOCKET_H 1
+
+#ifdef _WIN32
+# include <ws2tcpip.h>
+#else
+# include <netdb.h>
+# include <sys/socket.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int HX_socket_from_env(const struct addrinfo *, const char *intf);
+extern int HX_sockaddr_is_local(const struct sockaddr *, socklen_t, unsigned int flags);
+extern int HX_ipaddr_is_local(const char *, unsigned int flags);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _LIBHX_SOCKET_H */
diff --git a/include/libHX/string.h b/include/libHX/string.h
index 4dc4c11..9e78cd0 100644
--- a/include/libHX/string.h
+++ b/include/libHX/string.h
@@ -28,9 +28,17 @@ enum {
HXQUOTE_URIENC,
HXQUOTE_SQLSQUOTE,
HXQUOTE_SQLBQUOTE,
+ HXQUOTE_BASE64URL,
+ HXQUOTE_BASE64IMAP,
_HXQUOTE_MAX,
};
+enum {
+ HXUNIT_YEARS = 0x1U,
+ HXUNIT_MONTHS = 0x2U,
+ HXUNIT_WEEKS = 0x4U,
+};
+
#ifndef __libhx_internal_hxmc_t_defined
#define __libhx_internal_hxmc_t_defined 1
typedef char hxmc_t;
@@ -90,6 +98,12 @@ extern size_t HX_strrtrim(char *);
extern char *HX_strsep(char **, const char *);
extern char *HX_strsep2(char **, const char *);
extern char *HX_strupper(char *);
+extern double HX_strtod_unit(const char *, char **, unsigned int exponent);
+extern unsigned long long HX_strtoull_unit(const char *, char **, unsigned int exponent);
+extern char *HX_unit_size(char *out, size_t bufsize, unsigned long long size, unsigned int divisor, unsigned int cutoff);
+extern char *HX_unit_size_cu(char *out, size_t bufsize, unsigned long long size, unsigned int divisor);
+extern unsigned long long HX_strtoull_sec(const char *s, char **);
+extern char *HX_unit_seconds(char *out, size_t bufsize, unsigned long long seconds, unsigned int flags);
static __inline__ void *HX_memdup(const void *buf, size_t len)
{