diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/Makefile.am | 5 | ||||
| -rw-r--r-- | include/Makefile.in | 25 | ||||
| -rw-r--r-- | include/libHX/defs.h | 4 | ||||
| -rw-r--r-- | include/libHX/intdiff.hpp | 24 | ||||
| -rw-r--r-- | include/libHX/io.h | 3 | ||||
| -rw-r--r-- | include/libHX/misc.h | 8 | ||||
| -rw-r--r-- | include/libHX/option.h | 6 | ||||
| -rw-r--r-- | include/libHX/proc.h | 12 | ||||
| -rw-r--r-- | include/libHX/socket.h | 20 | ||||
| -rw-r--r-- | include/libHX/string.h | 14 | 
10 files changed, 98 insertions, 23 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..49ca7d1 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) 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..9d35cdc 100644 --- a/include/libHX/io.h +++ b/include/libHX/io.h @@ -35,6 +35,9 @@ 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); diff --git a/include/libHX/misc.h b/include/libHX/misc.h index adebf22..211bc96 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; diff --git a/include/libHX/option.h b/include/libHX/option.h index 82255d3..5b4bf6f 100644 --- a/include/libHX/option.h +++ b/include/libHX/option.h @@ -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..b151682 --- /dev/null +++ b/include/libHX/socket.h @@ -0,0 +1,20 @@ +#ifndef _LIBHX_SOCKET_H +#define _LIBHX_SOCKET_H 1 + +#ifdef _WIN32 +#	include <ws2tcpip.h> +#else +#	include <netdb.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int HX_socket_from_env(const struct addrinfo *, const char *intf); + +#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)  { | 
