moved all files to the top-level

This commit is contained in:
2022-10-02 19:30:14 +09:00
parent e03b9bd9a9
commit 384925992c
140 changed files with 0 additions and 0 deletions

74
bin/Makefile.am Normal file
View File

@ -0,0 +1,74 @@
AUTOMAKE_OPTIONS = nostdinc
CPPFLAGS_COMMON = \
-I$(abs_builddir) \
-I$(abs_builddir)/../lib \
-I$(abs_srcdir) \
-I$(abs_srcdir)/../lib \
-I$(includedir)
CFLAGS_COMMON =
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
LIBADD_COMMON = ../lib/libhio.la
bin_PROGRAMS = hio-execd
hio_execd_SOURCES = execd.c
hio_execd_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_execd_CFLAGS = $(CFLAGS_COMMON)
hio_execd_LDFLAGS = $(LDFLAGS_COMMON)
hio_execd_LDADD = $(LIBADD_COMMON)
if HAVE_X11_LIB
bin_PROGRAMS += hio-te
hio_te_SOURCES = te.c
hio_te_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_te_CFLAGS = $(CFLAGS_COMMON)
hio_te_LDFLAGS = $(LDFLAGS_COMMON)
hio_te_LDADD = $(LIBADD_COMMON) -lX11
endif
bin_PROGRAMS += hio-t01
hio_t01_SOURCES = t01.c
hio_t01_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t01_CFLAGS = $(CFLAGS_COMMON)
hio_t01_LDFLAGS = $(LDFLAGS_COMMON)
hio_t01_LDADD = $(LIBADD_COMMON)
bin_PROGRAMS += hio-t02
hio_t02_SOURCES = t02.c
hio_t02_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t02_CFLAGS = $(CFLAGS_COMMON)
hio_t02_LDFLAGS = $(LDFLAGS_COMMON)
hio_t02_LDADD = $(LIBADD_COMMON)
bin_PROGRAMS += hio-t03
hio_t03_SOURCES = t03.c
hio_t03_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t03_CFLAGS = $(CFLAGS_COMMON)
hio_t03_LDFLAGS = $(LDFLAGS_COMMON)
hio_t03_LDADD = $(LIBADD_COMMON)
bin_PROGRAMS += hio-t04
hio_t04_SOURCES = t04.c
hio_t04_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t04_CFLAGS = $(CFLAGS_COMMON)
hio_t04_LDFLAGS = $(LDFLAGS_COMMON)
hio_t04_LDADD = $(LIBADD_COMMON)
if ENABLE_MARIADB
hio_t04_CFLAGS += $(MARIADB_CFLAGS)
hio_t04_LDFLAGS += $(MARIADB_LDFLAGS)
hio_t04_LDADD += $(MARIADB_LIBS)
endif
bin_PROGRAMS += hio-t05
hio_t05_SOURCES = t05.c
hio_t05_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t05_CFLAGS = $(CFLAGS_COMMON)
hio_t05_LDFLAGS = $(LDFLAGS_COMMON)
hio_t05_LDADD = $(LIBADD_COMMON)
bin_PROGRAMS += hio-t06
hio_t06_SOURCES = t06.c
hio_t06_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t06_CFLAGS = $(CFLAGS_COMMON)
hio_t06_LDFLAGS = $(LDFLAGS_COMMON)
hio_t06_LDADD = $(LIBADD_COMMON)

938
bin/Makefile.in Normal file
View File

@ -0,0 +1,938 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = hio-execd$(EXEEXT) $(am__EXEEXT_1) hio-t01$(EXEEXT) \
hio-t02$(EXEEXT) hio-t03$(EXEEXT) hio-t04$(EXEEXT) \
hio-t05$(EXEEXT) hio-t06$(EXEEXT)
@HAVE_X11_LIB_TRUE@am__append_1 = hio-te
@ENABLE_MARIADB_TRUE@am__append_2 = $(MARIADB_CFLAGS)
@ENABLE_MARIADB_TRUE@am__append_3 = $(MARIADB_LDFLAGS)
@ENABLE_MARIADB_TRUE@am__append_4 = $(MARIADB_LIBS)
subdir = bin
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_lib_mariadb.m4 \
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/lib/hio-cfg.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@HAVE_X11_LIB_TRUE@am__EXEEXT_1 = hio-te$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_hio_execd_OBJECTS = hio_execd-execd.$(OBJEXT)
hio_execd_OBJECTS = $(am_hio_execd_OBJECTS)
hio_execd_DEPENDENCIES = $(LIBADD_COMMON)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
hio_execd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_execd_CFLAGS) \
$(CFLAGS) $(hio_execd_LDFLAGS) $(LDFLAGS) -o $@
am_hio_t01_OBJECTS = hio_t01-t01.$(OBJEXT)
hio_t01_OBJECTS = $(am_hio_t01_OBJECTS)
hio_t01_DEPENDENCIES = $(LIBADD_COMMON)
hio_t01_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t01_CFLAGS) \
$(CFLAGS) $(hio_t01_LDFLAGS) $(LDFLAGS) -o $@
am_hio_t02_OBJECTS = hio_t02-t02.$(OBJEXT)
hio_t02_OBJECTS = $(am_hio_t02_OBJECTS)
hio_t02_DEPENDENCIES = $(LIBADD_COMMON)
hio_t02_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t02_CFLAGS) \
$(CFLAGS) $(hio_t02_LDFLAGS) $(LDFLAGS) -o $@
am_hio_t03_OBJECTS = hio_t03-t03.$(OBJEXT)
hio_t03_OBJECTS = $(am_hio_t03_OBJECTS)
hio_t03_DEPENDENCIES = $(LIBADD_COMMON)
hio_t03_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t03_CFLAGS) \
$(CFLAGS) $(hio_t03_LDFLAGS) $(LDFLAGS) -o $@
am_hio_t04_OBJECTS = hio_t04-t04.$(OBJEXT)
hio_t04_OBJECTS = $(am_hio_t04_OBJECTS)
am__DEPENDENCIES_1 =
@ENABLE_MARIADB_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
hio_t04_DEPENDENCIES = $(LIBADD_COMMON) $(am__DEPENDENCIES_2)
hio_t04_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t04_CFLAGS) \
$(CFLAGS) $(hio_t04_LDFLAGS) $(LDFLAGS) -o $@
am_hio_t05_OBJECTS = hio_t05-t05.$(OBJEXT)
hio_t05_OBJECTS = $(am_hio_t05_OBJECTS)
hio_t05_DEPENDENCIES = $(LIBADD_COMMON)
hio_t05_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t05_CFLAGS) \
$(CFLAGS) $(hio_t05_LDFLAGS) $(LDFLAGS) -o $@
am_hio_t06_OBJECTS = hio_t06-t06.$(OBJEXT)
hio_t06_OBJECTS = $(am_hio_t06_OBJECTS)
hio_t06_DEPENDENCIES = $(LIBADD_COMMON)
hio_t06_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t06_CFLAGS) \
$(CFLAGS) $(hio_t06_LDFLAGS) $(LDFLAGS) -o $@
am__hio_te_SOURCES_DIST = te.c
@HAVE_X11_LIB_TRUE@am_hio_te_OBJECTS = hio_te-te.$(OBJEXT)
hio_te_OBJECTS = $(am_hio_te_OBJECTS)
@HAVE_X11_LIB_TRUE@hio_te_DEPENDENCIES = $(LIBADD_COMMON)
hio_te_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_te_CFLAGS) $(CFLAGS) \
$(hio_te_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/hio_execd-execd.Po \
./$(DEPDIR)/hio_t01-t01.Po ./$(DEPDIR)/hio_t02-t02.Po \
./$(DEPDIR)/hio_t03-t03.Po ./$(DEPDIR)/hio_t04-t04.Po \
./$(DEPDIR)/hio_t05-t05.Po ./$(DEPDIR)/hio_t06-t06.Po \
./$(DEPDIR)/hio_te-te.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(hio_execd_SOURCES) $(hio_t01_SOURCES) $(hio_t02_SOURCES) \
$(hio_t03_SOURCES) $(hio_t04_SOURCES) $(hio_t05_SOURCES) \
$(hio_t06_SOURCES) $(hio_te_SOURCES)
DIST_SOURCES = $(hio_execd_SOURCES) $(hio_t01_SOURCES) \
$(hio_t02_SOURCES) $(hio_t03_SOURCES) $(hio_t04_SOURCES) \
$(hio_t05_SOURCES) $(hio_t06_SOURCES) \
$(am__hio_te_SOURCES_DIST)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__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 $(top_srcdir)/ac/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_MODE = @BUILD_MODE@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HIO_PROJECT_AUTHOR = @HIO_PROJECT_AUTHOR@
HIO_PROJECT_URL = @HIO_PROJECT_URL@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MARIADB_CFLAGS = @MARIADB_CFLAGS@
MARIADB_CONFIG = @MARIADB_CONFIG@
MARIADB_LDFLAGS = @MARIADB_LDFLAGS@
MARIADB_LIBS = @MARIADB_LIBS@
MARIADB_VERSION = @MARIADB_VERSION@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
PATH_SEPARATOR = @PATH_SEPARATOR@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
QUADMATH_LIBS = @QUADMATH_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
SSL_LIBS = @SSL_LIBS@
STRIP = @STRIP@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
CPPFLAGS_COMMON = \
-I$(abs_builddir) \
-I$(abs_builddir)/../lib \
-I$(abs_srcdir) \
-I$(abs_srcdir)/../lib \
-I$(includedir)
CFLAGS_COMMON =
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
LIBADD_COMMON = ../lib/libhio.la
hio_execd_SOURCES = execd.c
hio_execd_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_execd_CFLAGS = $(CFLAGS_COMMON)
hio_execd_LDFLAGS = $(LDFLAGS_COMMON)
hio_execd_LDADD = $(LIBADD_COMMON)
@HAVE_X11_LIB_TRUE@hio_te_SOURCES = te.c
@HAVE_X11_LIB_TRUE@hio_te_CPPFLAGS = $(CPPFLAGS_COMMON)
@HAVE_X11_LIB_TRUE@hio_te_CFLAGS = $(CFLAGS_COMMON)
@HAVE_X11_LIB_TRUE@hio_te_LDFLAGS = $(LDFLAGS_COMMON)
@HAVE_X11_LIB_TRUE@hio_te_LDADD = $(LIBADD_COMMON) -lX11
hio_t01_SOURCES = t01.c
hio_t01_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t01_CFLAGS = $(CFLAGS_COMMON)
hio_t01_LDFLAGS = $(LDFLAGS_COMMON)
hio_t01_LDADD = $(LIBADD_COMMON)
hio_t02_SOURCES = t02.c
hio_t02_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t02_CFLAGS = $(CFLAGS_COMMON)
hio_t02_LDFLAGS = $(LDFLAGS_COMMON)
hio_t02_LDADD = $(LIBADD_COMMON)
hio_t03_SOURCES = t03.c
hio_t03_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t03_CFLAGS = $(CFLAGS_COMMON)
hio_t03_LDFLAGS = $(LDFLAGS_COMMON)
hio_t03_LDADD = $(LIBADD_COMMON)
hio_t04_SOURCES = t04.c
hio_t04_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t04_CFLAGS = $(CFLAGS_COMMON) $(am__append_2)
hio_t04_LDFLAGS = $(LDFLAGS_COMMON) $(am__append_3)
hio_t04_LDADD = $(LIBADD_COMMON) $(am__append_4)
hio_t05_SOURCES = t05.c
hio_t05_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t05_CFLAGS = $(CFLAGS_COMMON)
hio_t05_LDFLAGS = $(LDFLAGS_COMMON)
hio_t05_LDADD = $(LIBADD_COMMON)
hio_t06_SOURCES = t06.c
hio_t06_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t06_CFLAGS = $(CFLAGS_COMMON)
hio_t06_LDFLAGS = $(LDFLAGS_COMMON)
hio_t06_LDADD = $(LIBADD_COMMON)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign bin/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign bin/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
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)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
hio-execd$(EXEEXT): $(hio_execd_OBJECTS) $(hio_execd_DEPENDENCIES) $(EXTRA_hio_execd_DEPENDENCIES)
@rm -f hio-execd$(EXEEXT)
$(AM_V_CCLD)$(hio_execd_LINK) $(hio_execd_OBJECTS) $(hio_execd_LDADD) $(LIBS)
hio-t01$(EXEEXT): $(hio_t01_OBJECTS) $(hio_t01_DEPENDENCIES) $(EXTRA_hio_t01_DEPENDENCIES)
@rm -f hio-t01$(EXEEXT)
$(AM_V_CCLD)$(hio_t01_LINK) $(hio_t01_OBJECTS) $(hio_t01_LDADD) $(LIBS)
hio-t02$(EXEEXT): $(hio_t02_OBJECTS) $(hio_t02_DEPENDENCIES) $(EXTRA_hio_t02_DEPENDENCIES)
@rm -f hio-t02$(EXEEXT)
$(AM_V_CCLD)$(hio_t02_LINK) $(hio_t02_OBJECTS) $(hio_t02_LDADD) $(LIBS)
hio-t03$(EXEEXT): $(hio_t03_OBJECTS) $(hio_t03_DEPENDENCIES) $(EXTRA_hio_t03_DEPENDENCIES)
@rm -f hio-t03$(EXEEXT)
$(AM_V_CCLD)$(hio_t03_LINK) $(hio_t03_OBJECTS) $(hio_t03_LDADD) $(LIBS)
hio-t04$(EXEEXT): $(hio_t04_OBJECTS) $(hio_t04_DEPENDENCIES) $(EXTRA_hio_t04_DEPENDENCIES)
@rm -f hio-t04$(EXEEXT)
$(AM_V_CCLD)$(hio_t04_LINK) $(hio_t04_OBJECTS) $(hio_t04_LDADD) $(LIBS)
hio-t05$(EXEEXT): $(hio_t05_OBJECTS) $(hio_t05_DEPENDENCIES) $(EXTRA_hio_t05_DEPENDENCIES)
@rm -f hio-t05$(EXEEXT)
$(AM_V_CCLD)$(hio_t05_LINK) $(hio_t05_OBJECTS) $(hio_t05_LDADD) $(LIBS)
hio-t06$(EXEEXT): $(hio_t06_OBJECTS) $(hio_t06_DEPENDENCIES) $(EXTRA_hio_t06_DEPENDENCIES)
@rm -f hio-t06$(EXEEXT)
$(AM_V_CCLD)$(hio_t06_LINK) $(hio_t06_OBJECTS) $(hio_t06_LDADD) $(LIBS)
hio-te$(EXEEXT): $(hio_te_OBJECTS) $(hio_te_DEPENDENCIES) $(EXTRA_hio_te_DEPENDENCIES)
@rm -f hio-te$(EXEEXT)
$(AM_V_CCLD)$(hio_te_LINK) $(hio_te_OBJECTS) $(hio_te_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_execd-execd.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t01-t01.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t02-t02.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t03-t03.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t04-t04.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t05-t05.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t06-t06.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_te-te.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
hio_execd-execd.o: execd.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_execd_CPPFLAGS) $(CPPFLAGS) $(hio_execd_CFLAGS) $(CFLAGS) -MT hio_execd-execd.o -MD -MP -MF $(DEPDIR)/hio_execd-execd.Tpo -c -o hio_execd-execd.o `test -f 'execd.c' || echo '$(srcdir)/'`execd.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_execd-execd.Tpo $(DEPDIR)/hio_execd-execd.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='execd.c' object='hio_execd-execd.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_execd_CPPFLAGS) $(CPPFLAGS) $(hio_execd_CFLAGS) $(CFLAGS) -c -o hio_execd-execd.o `test -f 'execd.c' || echo '$(srcdir)/'`execd.c
hio_execd-execd.obj: execd.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_execd_CPPFLAGS) $(CPPFLAGS) $(hio_execd_CFLAGS) $(CFLAGS) -MT hio_execd-execd.obj -MD -MP -MF $(DEPDIR)/hio_execd-execd.Tpo -c -o hio_execd-execd.obj `if test -f 'execd.c'; then $(CYGPATH_W) 'execd.c'; else $(CYGPATH_W) '$(srcdir)/execd.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_execd-execd.Tpo $(DEPDIR)/hio_execd-execd.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='execd.c' object='hio_execd-execd.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_execd_CPPFLAGS) $(CPPFLAGS) $(hio_execd_CFLAGS) $(CFLAGS) -c -o hio_execd-execd.obj `if test -f 'execd.c'; then $(CYGPATH_W) 'execd.c'; else $(CYGPATH_W) '$(srcdir)/execd.c'; fi`
hio_t01-t01.o: t01.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t01_CPPFLAGS) $(CPPFLAGS) $(hio_t01_CFLAGS) $(CFLAGS) -MT hio_t01-t01.o -MD -MP -MF $(DEPDIR)/hio_t01-t01.Tpo -c -o hio_t01-t01.o `test -f 't01.c' || echo '$(srcdir)/'`t01.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t01-t01.Tpo $(DEPDIR)/hio_t01-t01.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t01.c' object='hio_t01-t01.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t01_CPPFLAGS) $(CPPFLAGS) $(hio_t01_CFLAGS) $(CFLAGS) -c -o hio_t01-t01.o `test -f 't01.c' || echo '$(srcdir)/'`t01.c
hio_t01-t01.obj: t01.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t01_CPPFLAGS) $(CPPFLAGS) $(hio_t01_CFLAGS) $(CFLAGS) -MT hio_t01-t01.obj -MD -MP -MF $(DEPDIR)/hio_t01-t01.Tpo -c -o hio_t01-t01.obj `if test -f 't01.c'; then $(CYGPATH_W) 't01.c'; else $(CYGPATH_W) '$(srcdir)/t01.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t01-t01.Tpo $(DEPDIR)/hio_t01-t01.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t01.c' object='hio_t01-t01.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t01_CPPFLAGS) $(CPPFLAGS) $(hio_t01_CFLAGS) $(CFLAGS) -c -o hio_t01-t01.obj `if test -f 't01.c'; then $(CYGPATH_W) 't01.c'; else $(CYGPATH_W) '$(srcdir)/t01.c'; fi`
hio_t02-t02.o: t02.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t02_CPPFLAGS) $(CPPFLAGS) $(hio_t02_CFLAGS) $(CFLAGS) -MT hio_t02-t02.o -MD -MP -MF $(DEPDIR)/hio_t02-t02.Tpo -c -o hio_t02-t02.o `test -f 't02.c' || echo '$(srcdir)/'`t02.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t02-t02.Tpo $(DEPDIR)/hio_t02-t02.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t02.c' object='hio_t02-t02.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t02_CPPFLAGS) $(CPPFLAGS) $(hio_t02_CFLAGS) $(CFLAGS) -c -o hio_t02-t02.o `test -f 't02.c' || echo '$(srcdir)/'`t02.c
hio_t02-t02.obj: t02.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t02_CPPFLAGS) $(CPPFLAGS) $(hio_t02_CFLAGS) $(CFLAGS) -MT hio_t02-t02.obj -MD -MP -MF $(DEPDIR)/hio_t02-t02.Tpo -c -o hio_t02-t02.obj `if test -f 't02.c'; then $(CYGPATH_W) 't02.c'; else $(CYGPATH_W) '$(srcdir)/t02.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t02-t02.Tpo $(DEPDIR)/hio_t02-t02.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t02.c' object='hio_t02-t02.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t02_CPPFLAGS) $(CPPFLAGS) $(hio_t02_CFLAGS) $(CFLAGS) -c -o hio_t02-t02.obj `if test -f 't02.c'; then $(CYGPATH_W) 't02.c'; else $(CYGPATH_W) '$(srcdir)/t02.c'; fi`
hio_t03-t03.o: t03.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t03_CPPFLAGS) $(CPPFLAGS) $(hio_t03_CFLAGS) $(CFLAGS) -MT hio_t03-t03.o -MD -MP -MF $(DEPDIR)/hio_t03-t03.Tpo -c -o hio_t03-t03.o `test -f 't03.c' || echo '$(srcdir)/'`t03.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t03-t03.Tpo $(DEPDIR)/hio_t03-t03.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t03.c' object='hio_t03-t03.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t03_CPPFLAGS) $(CPPFLAGS) $(hio_t03_CFLAGS) $(CFLAGS) -c -o hio_t03-t03.o `test -f 't03.c' || echo '$(srcdir)/'`t03.c
hio_t03-t03.obj: t03.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t03_CPPFLAGS) $(CPPFLAGS) $(hio_t03_CFLAGS) $(CFLAGS) -MT hio_t03-t03.obj -MD -MP -MF $(DEPDIR)/hio_t03-t03.Tpo -c -o hio_t03-t03.obj `if test -f 't03.c'; then $(CYGPATH_W) 't03.c'; else $(CYGPATH_W) '$(srcdir)/t03.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t03-t03.Tpo $(DEPDIR)/hio_t03-t03.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t03.c' object='hio_t03-t03.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t03_CPPFLAGS) $(CPPFLAGS) $(hio_t03_CFLAGS) $(CFLAGS) -c -o hio_t03-t03.obj `if test -f 't03.c'; then $(CYGPATH_W) 't03.c'; else $(CYGPATH_W) '$(srcdir)/t03.c'; fi`
hio_t04-t04.o: t04.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t04_CPPFLAGS) $(CPPFLAGS) $(hio_t04_CFLAGS) $(CFLAGS) -MT hio_t04-t04.o -MD -MP -MF $(DEPDIR)/hio_t04-t04.Tpo -c -o hio_t04-t04.o `test -f 't04.c' || echo '$(srcdir)/'`t04.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t04-t04.Tpo $(DEPDIR)/hio_t04-t04.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t04.c' object='hio_t04-t04.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t04_CPPFLAGS) $(CPPFLAGS) $(hio_t04_CFLAGS) $(CFLAGS) -c -o hio_t04-t04.o `test -f 't04.c' || echo '$(srcdir)/'`t04.c
hio_t04-t04.obj: t04.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t04_CPPFLAGS) $(CPPFLAGS) $(hio_t04_CFLAGS) $(CFLAGS) -MT hio_t04-t04.obj -MD -MP -MF $(DEPDIR)/hio_t04-t04.Tpo -c -o hio_t04-t04.obj `if test -f 't04.c'; then $(CYGPATH_W) 't04.c'; else $(CYGPATH_W) '$(srcdir)/t04.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t04-t04.Tpo $(DEPDIR)/hio_t04-t04.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t04.c' object='hio_t04-t04.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t04_CPPFLAGS) $(CPPFLAGS) $(hio_t04_CFLAGS) $(CFLAGS) -c -o hio_t04-t04.obj `if test -f 't04.c'; then $(CYGPATH_W) 't04.c'; else $(CYGPATH_W) '$(srcdir)/t04.c'; fi`
hio_t05-t05.o: t05.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t05_CPPFLAGS) $(CPPFLAGS) $(hio_t05_CFLAGS) $(CFLAGS) -MT hio_t05-t05.o -MD -MP -MF $(DEPDIR)/hio_t05-t05.Tpo -c -o hio_t05-t05.o `test -f 't05.c' || echo '$(srcdir)/'`t05.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t05-t05.Tpo $(DEPDIR)/hio_t05-t05.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t05.c' object='hio_t05-t05.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t05_CPPFLAGS) $(CPPFLAGS) $(hio_t05_CFLAGS) $(CFLAGS) -c -o hio_t05-t05.o `test -f 't05.c' || echo '$(srcdir)/'`t05.c
hio_t05-t05.obj: t05.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t05_CPPFLAGS) $(CPPFLAGS) $(hio_t05_CFLAGS) $(CFLAGS) -MT hio_t05-t05.obj -MD -MP -MF $(DEPDIR)/hio_t05-t05.Tpo -c -o hio_t05-t05.obj `if test -f 't05.c'; then $(CYGPATH_W) 't05.c'; else $(CYGPATH_W) '$(srcdir)/t05.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t05-t05.Tpo $(DEPDIR)/hio_t05-t05.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t05.c' object='hio_t05-t05.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t05_CPPFLAGS) $(CPPFLAGS) $(hio_t05_CFLAGS) $(CFLAGS) -c -o hio_t05-t05.obj `if test -f 't05.c'; then $(CYGPATH_W) 't05.c'; else $(CYGPATH_W) '$(srcdir)/t05.c'; fi`
hio_t06-t06.o: t06.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -MT hio_t06-t06.o -MD -MP -MF $(DEPDIR)/hio_t06-t06.Tpo -c -o hio_t06-t06.o `test -f 't06.c' || echo '$(srcdir)/'`t06.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t06-t06.Tpo $(DEPDIR)/hio_t06-t06.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t06.c' object='hio_t06-t06.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -c -o hio_t06-t06.o `test -f 't06.c' || echo '$(srcdir)/'`t06.c
hio_t06-t06.obj: t06.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -MT hio_t06-t06.obj -MD -MP -MF $(DEPDIR)/hio_t06-t06.Tpo -c -o hio_t06-t06.obj `if test -f 't06.c'; then $(CYGPATH_W) 't06.c'; else $(CYGPATH_W) '$(srcdir)/t06.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t06-t06.Tpo $(DEPDIR)/hio_t06-t06.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t06.c' object='hio_t06-t06.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -c -o hio_t06-t06.obj `if test -f 't06.c'; then $(CYGPATH_W) 't06.c'; else $(CYGPATH_W) '$(srcdir)/t06.c'; fi`
hio_te-te.o: te.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_te_CPPFLAGS) $(CPPFLAGS) $(hio_te_CFLAGS) $(CFLAGS) -MT hio_te-te.o -MD -MP -MF $(DEPDIR)/hio_te-te.Tpo -c -o hio_te-te.o `test -f 'te.c' || echo '$(srcdir)/'`te.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_te-te.Tpo $(DEPDIR)/hio_te-te.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='te.c' object='hio_te-te.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_te_CPPFLAGS) $(CPPFLAGS) $(hio_te_CFLAGS) $(CFLAGS) -c -o hio_te-te.o `test -f 'te.c' || echo '$(srcdir)/'`te.c
hio_te-te.obj: te.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_te_CPPFLAGS) $(CPPFLAGS) $(hio_te_CFLAGS) $(CFLAGS) -MT hio_te-te.obj -MD -MP -MF $(DEPDIR)/hio_te-te.Tpo -c -o hio_te-te.obj `if test -f 'te.c'; then $(CYGPATH_W) 'te.c'; else $(CYGPATH_W) '$(srcdir)/te.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_te-te.Tpo $(DEPDIR)/hio_te-te.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='te.c' object='hio_te-te.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_te_CPPFLAGS) $(CPPFLAGS) $(hio_te_CFLAGS) $(CFLAGS) -c -o hio_te-te.obj `if test -f 'te.c'; then $(CYGPATH_W) 'te.c'; else $(CYGPATH_W) '$(srcdir)/te.c'; fi`
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/hio_execd-execd.Po
-rm -f ./$(DEPDIR)/hio_t01-t01.Po
-rm -f ./$(DEPDIR)/hio_t02-t02.Po
-rm -f ./$(DEPDIR)/hio_t03-t03.Po
-rm -f ./$(DEPDIR)/hio_t04-t04.Po
-rm -f ./$(DEPDIR)/hio_t05-t05.Po
-rm -f ./$(DEPDIR)/hio_t06-t06.Po
-rm -f ./$(DEPDIR)/hio_te-te.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/hio_execd-execd.Po
-rm -f ./$(DEPDIR)/hio_t01-t01.Po
-rm -f ./$(DEPDIR)/hio_t02-t02.Po
-rm -f ./$(DEPDIR)/hio_t03-t03.Po
-rm -f ./$(DEPDIR)/hio_t04-t04.Po
-rm -f ./$(DEPDIR)/hio_t05-t05.Po
-rm -f ./$(DEPDIR)/hio_t06-t06.Po
-rm -f ./$(DEPDIR)/hio_te-te.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

386
bin/execd.c Normal file
View File

@ -0,0 +1,386 @@
/*
* $Id$
*
Copyright (c) 2016-2020 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <hio.h>
#include <hio-utl.h>
#include <hio-sck.h>
#include <hio-pro.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <net/if.h>
#include <assert.h>
#if defined(HAVE_OPENSSL_SSL_H) && defined(HAVE_SSL)
# include <openssl/ssl.h>
# if defined(HAVE_OPENSSL_ERR_H)
# include <openssl/err.h>
# endif
# if defined(HAVE_OPENSSL_ENGINE_H)
# include <openssl/engine.h>
# endif
# define USE_SSL
#endif
/* ========================================================================= */
struct mmgr_stat_t
{
hio_oow_t total_count;
};
typedef struct mmgr_stat_t mmgr_stat_t;
static mmgr_stat_t mmgr_stat;
static void* mmgr_alloc (hio_mmgr_t* mmgr, hio_oow_t size)
{
void* x;
#if 0
if (((mmgr_stat_t*)mmgr->ctx)->total_count > 300)
{
printf ("CRITICAL ERROR ---> too many heap chunks...\n");
return HIO_NULL;
}
#endif
x = malloc (size);
if (x) ((mmgr_stat_t*)mmgr->ctx)->total_count++;
return x;
}
static void* mmgr_realloc (hio_mmgr_t* mmgr, void* ptr, hio_oow_t size)
{
return realloc (ptr, size);
}
static void mmgr_free (hio_mmgr_t* mmgr, void* ptr)
{
((mmgr_stat_t*)mmgr->ctx)->total_count--;
return free (ptr);
}
static hio_mmgr_t mmgr =
{
mmgr_alloc,
mmgr_realloc,
mmgr_free,
&mmgr_stat
};
/* ========================================================================= */
#if defined(USE_SSL)
static void cleanup_openssl ()
{
/* ERR_remove_state() should be called for each thread if the application is thread */
ERR_remove_state (0);
#if defined(HAVE_ENGINE_CLEANUP)
ENGINE_cleanup ();
#endif
ERR_free_strings ();
EVP_cleanup ();
#if defined(HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
CRYPTO_cleanup_all_ex_data ();
#endif
}
#endif
struct tcp_server_t
{
int tally;
};
typedef struct tcp_server_t tcp_server_t;
static void tcp_sck_on_disconnect (hio_dev_sck_t* tcp)
{
switch (HIO_DEV_SCK_GET_PROGRESS(tcp))
{
case HIO_DEV_SCK_CONNECTING:
HIO_INFO1 (tcp->hio, "OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_CONNECTING_SSL:
HIO_INFO1 (tcp->hio, "OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_LISTENING:
HIO_INFO1 (tcp->hio, "SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_CONNECTED:
HIO_INFO1 (tcp->hio, "OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_ACCEPTING_SSL:
HIO_INFO1 (tcp->hio, "INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_ACCEPTED:
HIO_INFO1 (tcp->hio, "INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->hnd);
break;
default:
HIO_INFO2 (tcp->hio, "SOCKET DEVICE DISCONNECTED (%d - %x)\n", (int)tcp->hnd, (unsigned int)tcp->state);
break;
}
}
static void tcp_sck_on_connect (hio_dev_sck_t* tcp)
{
hio_bch_t buf1[128], buf2[128];
hio_skadtobcstr (tcp->hio, &tcp->localaddr, buf1, HIO_COUNTOF(buf1), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
hio_skadtobcstr (tcp->hio, &tcp->remoteaddr, buf2, HIO_COUNTOF(buf2), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
if (tcp->state & HIO_DEV_SCK_CONNECTED)
{
HIO_INFO3 (tcp->hio, "DEVICE connected to a remote server... LOCAL %hs REMOTE %hs SCK: %d\n", buf1, buf2, tcp->hnd);
}
else if (tcp->state & HIO_DEV_SCK_ACCEPTED)
{
HIO_INFO3 (tcp->hio, "DEVICE accepted client device... .LOCAL %hs REMOTE %hs SCK: %d\n", buf1, buf2, tcp->hnd);
}
if (hio_dev_sck_write(tcp, "hello", 5, HIO_NULL, HIO_NULL) <= -1)
{
hio_dev_sck_halt (tcp);
}
}
static int tcp_sck_on_write (hio_dev_sck_t* tcp, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{
tcp_server_t* ts;
hio_ntime_t tmout;
if (wrlen <= -1)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> SEDING TIMED OUT...........\n", (int)tcp->hnd);
hio_dev_sck_halt (tcp);
}
else
{
ts = (tcp_server_t*)(tcp + 1);
if (wrlen == 0)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> CLOSED WRITING END\n", (int)tcp->hnd);
}
else
{
HIO_INFO3 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> SENT MESSAGE %d of length %ld\n", (int)tcp->hnd, ts->tally, (long int)wrlen);
}
ts->tally++;
// if (ts->tally >= 2) hio_dev_sck_halt (tcp);
HIO_INIT_NTIME (&tmout, 5, 0);
//hio_dev_sck_read (tcp, 1);
HIO_INFO3 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> REQUESTING to READ with timeout of %ld.%08ld\n", (int)tcp->hnd, (long int)tmout.sec, (long int)tmout.nsec);
hio_dev_sck_timedread (tcp, 1, &tmout);
}
return 0;
}
static int tcp_sck_on_read (hio_dev_sck_t* tcp, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{
int n;
if (len <= -1)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: TIMED OUT...\n", (int)tcp->hnd);
hio_dev_sck_halt (tcp);
return 0;
}
else if (len <= 0)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: EOF RECEIVED...\n", (int)tcp->hnd);
/* no outstanding request. but EOF */
hio_dev_sck_halt (tcp);
return 0;
}
HIO_INFO2 (tcp->hio, "TCP_SCK_ON_READ(%d) - received %d bytes\n", (int)tcp->hnd, (int)len);
{
hio_ntime_t tmout;
static char a ='A';
static char xxx[1000000];
memset (xxx, a++ , HIO_SIZEOF(xxx));
HIO_INFO2 (tcp->hio, "TCP_SCK_ON_READ(%d) >>> REQUESTING to write data of %d bytes\n", (int)tcp->hnd, HIO_SIZEOF(xxx));
//return hio_dev_sck_write (tcp, "HELLO", 5, HIO_NULL);
HIO_INIT_NTIME (&tmout, 5, 0);
n = hio_dev_sck_timedwrite(tcp, xxx, HIO_SIZEOF(xxx), &tmout, HIO_NULL, HIO_NULL);
if (n <= -1) return -1;
}
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) - REQUESTING TO STOP READ\n", (int)tcp->hnd);
hio_dev_sck_read (tcp, 0);
#if 0
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) - REQUESTING TO CLOSE WRITING END\n", (int)tcp->hnd);
/* post the write finisher - close the writing end */
n = hio_dev_sck_write(tcp, HIO_NULL, 0, HIO_NULL, HIO_NULL);
if (n <= -1) return -1;
#endif
return 0;
/* return 1; let the main loop to read more greedily without consulting the multiplexer */
}
/* ========================================================================= */
static void pro_on_close (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid)
{
hio_t* hio = pro->hio;
if (sid == HIO_DEV_PRO_MASTER)
HIO_INFO1 (hio, "PROCESS(%d) CLOSE MASTER\n", (int)pro->child_pid);
else
HIO_INFO2 (hio, "PROCESS(%d) CLOSE SLAVE[%d]\n", (int)pro->child_pid, sid);
}
static int pro_on_read (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid, const void* data, hio_iolen_t dlen)
{
hio_t* hio = pro->hio;
if (dlen <= -1)
{
HIO_INFO1 (hio, "PROCESS(%d): READ TIMED OUT...\n", (int)pro->child_pid);
hio_dev_pro_halt (pro);
return 0;
}
else if (dlen <= 0)
{
HIO_INFO1 (hio, "PROCESS(%d): EOF RECEIVED...\n", (int)pro->child_pid);
/* no outstanding request. but EOF */
hio_dev_pro_halt (pro);
return 0;
}
HIO_INFO5 (hio, "PROCESS(%d) READ DATA ON SLAVE[%d] len=%d [%.*hs]\n", (int)pro->child_pid, (int)sid, (int)dlen, dlen, (char*)data);
if (sid == HIO_DEV_PRO_OUT)
{
hio_dev_pro_read (pro, sid, 0);
hio_dev_pro_write (pro, "HELLO\n", 6, HIO_NULL);
}
return 0;
}
static int pro_on_write (hio_dev_pro_t* pro, hio_iolen_t wrlen, void* wrctx)
{
hio_t* hio = pro->hio;
hio_ntime_t tmout;
if (wrlen <= -1)
{
HIO_INFO1 (hio, "PROCESS(%d): WRITE TIMED OUT...\n", (int)pro->child_pid);
hio_dev_pro_halt (pro);
return 0;
}
HIO_DEBUG2 (hio, "PROCESS(%d) wrote data of %d bytes\n", (int)pro->child_pid, (int)wrlen);
/*hio_dev_pro_read (pro, HIO_DEV_PRO_OUT, 1);*/
HIO_INIT_NTIME (&tmout, 5, 0);
hio_dev_pro_timedread (pro, HIO_DEV_PRO_OUT, 1, &tmout);
return 0;
}
/* ========================================================================= */
static hio_t* g_hio;
static void handle_signal (int sig)
{
if (g_hio) hio_stop (g_hio, HIO_STOPREQ_TERMINATION);
}
int main (int argc, char* argv[])
{
hio_t* hio = HIO_NULL;
hio_dev_sck_t* tcpsvr;
hio_dev_sck_make_t tcp_make;
hio_dev_sck_connect_t tcp_conn;
tcp_server_t* ts;
hio = hio_open(&mmgr, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
goto oops;
}
memset (&tcp_make, 0, HIO_SIZEOF(tcp_make));
tcp_make.type = HIO_DEV_SCK_TCP4;
tcp_make.on_write = tcp_sck_on_write;
tcp_make.on_read = tcp_sck_on_read;
tcp_make.on_connect = tcp_sck_on_connect;
tcp_make.on_disconnect = tcp_sck_on_disconnect;
tcpsvr = hio_dev_sck_make(hio, HIO_SIZEOF(tcp_server_t), &tcp_make);
if (!tcpsvr)
{
printf ("Cannot make a tcp server\n");
goto oops;
}
ts = (tcp_server_t*)(tcpsvr + 1);
ts->tally = 0;
memset (&tcp_conn, 0, HIO_SIZEOF(tcp_conn));
hio_bcstrtoskad(hio, "127.0.0.1:9999", &tcp_conn.remoteaddr);
HIO_INIT_NTIME (&tcp_conn.connect_tmout, 5, 0);
tcp_conn.options = 0;
if (hio_dev_sck_connect(tcpsvr, &tcp_conn) <= -1)
{
}
#if 0
while (1)
{
hio_exec (hio);
}
#endif
hio_loop (hio);
oops:
if (hio) hio_close (hio);
return 0;
}

1430
bin/t01.c Normal file

File diff suppressed because it is too large Load Diff

258
bin/t02.c Normal file
View File

@ -0,0 +1,258 @@
#include <hio.h>
#include <hio-utl.h>
#include <hio-sck.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct mmgr_stat_t
{
hio_oow_t total_count;
};
typedef struct mmgr_stat_t mmgr_stat_t;
static mmgr_stat_t mmgr_stat;
static void* mmgr_alloc (hio_mmgr_t* mmgr, hio_oow_t size)
{
void* x;
if (((mmgr_stat_t*)mmgr->ctx)->total_count > 3000)
{
printf ("CRITICAL ERROR ---> too many heap chunks...\n");
return HIO_NULL;
}
x = malloc (size);
if (x) ((mmgr_stat_t*)mmgr->ctx)->total_count++;
return x;
}
static void* mmgr_realloc (hio_mmgr_t* mmgr, void* ptr, hio_oow_t size)
{
return realloc (ptr, size);
}
static void mmgr_free (hio_mmgr_t* mmgr, void* ptr)
{
((mmgr_stat_t*)mmgr->ctx)->total_count--;
return free (ptr);
}
static hio_mmgr_t mmgr =
{
mmgr_alloc,
mmgr_realloc,
mmgr_free,
&mmgr_stat
};
struct tcp_xtn_t
{
int tally;
};
typedef struct tcp_xtn_t tcp_xtn_t;
static void tcp_sck_on_disconnect (hio_dev_sck_t* tcp)
{
switch (HIO_DEV_SCK_GET_PROGRESS(tcp))
{
case HIO_DEV_SCK_CONNECTING:
HIO_INFO1 (tcp->hio, "OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_CONNECTING_SSL:
HIO_INFO1 (tcp->hio, "OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_LISTENING:
HIO_INFO1 (tcp->hio, "SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_CONNECTED:
HIO_INFO1 (tcp->hio, "OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_ACCEPTING_SSL:
HIO_INFO1 (tcp->hio, "INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_ACCEPTED:
HIO_INFO1 (tcp->hio, "INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->hnd);
break;
default:
HIO_INFO2 (tcp->hio, "SOCKET DEVICE DISCONNECTED (%d - %x)\n", (int)tcp->hnd, (unsigned int)tcp->state);
break;
}
}
static void tcp_sck_on_connect (hio_dev_sck_t* tcp)
{
hio_bch_t buf1[128], buf2[128];
hio_skadtobcstr (tcp->hio, &tcp->localaddr, buf1, HIO_COUNTOF(buf1), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
hio_skadtobcstr (tcp->hio, &tcp->remoteaddr, buf2, HIO_COUNTOF(buf2), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
if (tcp->state & HIO_DEV_SCK_CONNECTED)
{
HIO_INFO3 (tcp->hio, "DEVICE connected to a remote server... LOCAL %hs REMOTE %hs SCK: %d\n", buf1, buf2, tcp->hnd);
}
else if (tcp->state & HIO_DEV_SCK_ACCEPTED)
{
HIO_INFO3 (tcp->hio, "DEVICE accepted client device... .LOCAL %hs REMOTE %hs SCK: %d\n", buf1, buf2, tcp->hnd);
}
if (hio_dev_sck_write(tcp, "hello", 5, HIO_NULL, HIO_NULL) <= -1)
{
hio_dev_sck_halt (tcp);
}
}
static int tcp_sck_on_write (hio_dev_sck_t* tcp, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{
tcp_xtn_t* ts;
hio_ntime_t tmout;
if (wrlen <= -1)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> SEDING TIMED OUT...........\n", (int)tcp->hnd);
hio_dev_sck_halt (tcp);
}
else
{
ts = (tcp_xtn_t*)(tcp + 1);
if (wrlen == 0)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> CLOSED WRITING END\n", (int)tcp->hnd);
}
else
{
HIO_INFO3 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> SENT MESSAGE %d of length %ld\n", (int)tcp->hnd, ts->tally, (long int)wrlen);
}
ts->tally++;
// if (ts->tally >= 2) hio_dev_sck_halt (tcp);
HIO_INIT_NTIME (&tmout, 5, 0);
//hio_dev_sck_read (tcp, 1);
HIO_INFO3 (tcp->hio, "TCP_SCK_ON_WRITE(%d) >>> REQUESTING to READ with timeout of %ld.%08ld\n", (int)tcp->hnd, (long int)tmout.sec, (long int)tmout.nsec);
hio_dev_sck_timedread (tcp, 1, &tmout);
}
return 0;
}
static int tcp_sck_on_read (hio_dev_sck_t* tcp, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{
int n;
if (len <= -1)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: TIMED OUT...\n", (int)tcp->hnd);
hio_dev_sck_halt (tcp);
return 0;
}
else if (len <= 0)
{
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: EOF RECEIVED...\n", (int)tcp->hnd);
/* no outstanding request. but EOF */
hio_dev_sck_halt (tcp);
return 0;
}
HIO_INFO2 (tcp->hio, "TCP_SCK_ON_READ(%d) - received %d bytes\n", (int)tcp->hnd, (int)len);
{
hio_ntime_t tmout;
static char a ='A';
static char xxx[1000000];
memset (xxx, a++ , HIO_SIZEOF(xxx));
HIO_INFO2 (tcp->hio, "TCP_SCK_ON_READ(%d) >>> REQUESTING to write data of %d bytes\n", (int)tcp->hnd, HIO_SIZEOF(xxx));
//return hio_dev_sck_write (tcp, "HELLO", 5, HIO_NULL);
HIO_INIT_NTIME (&tmout, 5, 0);
n = hio_dev_sck_timedwrite(tcp, xxx, HIO_SIZEOF(xxx), &tmout, HIO_NULL, HIO_NULL);
if (n <= -1) return -1;
}
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) - REQUESTING TO STOP READ\n", (int)tcp->hnd);
hio_dev_sck_read (tcp, 0);
#if 0
HIO_INFO1 (tcp->hio, "TCP_SCK_ON_READ(%d) - REQUESTING TO CLOSE WRITING END\n", (int)tcp->hnd);
/* post the write finisher - close the writing end */
n = hio_dev_sck_write(tcp, HIO_NULL, 0, HIO_NULL, HIO_NULL);
if (n <= -1) return -1;
#endif
return 0;
/* return 1; let the main loop to read more greedily without consulting the multiplexer */
}
int main (int argc, char* argv[])
{
hio_t* hio = HIO_NULL;
hio_dev_sck_t* tcpsvr;
hio_dev_sck_make_t tcp_make;
hio_dev_sck_connect_t tcp_conn;
tcp_xtn_t* ts;
if (argc != 2)
{
fprintf (stderr, "Usage: %s ipaddr:port\n", argv[0]);
return -1;
}
hio = hio_open(&mmgr, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
goto oops;
}
memset (&tcp_conn, 0, HIO_SIZEOF(tcp_conn));
hio_bcstrtoskad(hio, argv[1], &tcp_conn.remoteaddr);
HIO_INIT_NTIME (&tcp_conn.connect_tmout, 5, 0);
tcp_conn.options = 0;
memset (&tcp_make, 0, HIO_SIZEOF(tcp_make));
tcp_make.type = hio_skad_get_family(&tcp_conn.remoteaddr) == HIO_AF_INET? HIO_DEV_SCK_TCP4: HIO_DEV_SCK_TCP6;
tcp_make.on_write = tcp_sck_on_write;
tcp_make.on_read = tcp_sck_on_read;
tcp_make.on_connect = tcp_sck_on_connect;
tcp_make.on_disconnect = tcp_sck_on_disconnect;
tcpsvr = hio_dev_sck_make(hio, HIO_SIZEOF(tcp_xtn_t), &tcp_make);
if (!tcpsvr)
{
printf ("Cannot make a tcp server\n");
goto oops;
}
ts = (tcp_xtn_t*)(tcpsvr + 1);
ts->tally = 0;
if (hio_dev_sck_connect(tcpsvr, &tcp_conn) <= -1)
{
}
hio_loop (hio);
oops:
if (hio) hio_close (hio);
return 0;
return 0;
}

265
bin/t03.c Normal file
View File

@ -0,0 +1,265 @@
#include <hio.h>
#include <hio-json.h>
#include <stdio.h>
#include <string.h>
#define DEBUG
static int on_json_inst (hio_json_t* json, hio_json_inst_t inst, hio_oow_t level, hio_oow_t index, hio_json_state_t container_state, const hio_oocs_t* str, void* ctx)
{
hio_t* hio = hio_json_gethio(json);
hio_oow_t i;
switch (inst)
{
case HIO_JSON_INST_START_ARRAY:
if (level > 0)
{
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
}
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>[\n", (unsigned long)index);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "[\n");
#endif
break;
case HIO_JSON_INST_END_ARRAY:
hio_logbfmt (hio, HIO_LOG_STDOUT, "\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>]", (unsigned long)index);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "]");
#endif
break;
case HIO_JSON_INST_START_OBJECT:
if (level > 0)
{
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
}
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>{\n", (unsigned long)index);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "{\n");
#endif
break;
case HIO_JSON_INST_END_OBJECT:
hio_logbfmt (hio, HIO_LOG_STDOUT, "\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>}", (unsigned long)index);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "}");
#endif
break;
case HIO_JSON_INST_KEY:
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>%.*js: ", (unsigned long)index, str->len, str->ptr);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "%.*js: ", str->len, str->ptr);
#endif
break;
case HIO_JSON_INST_NIL:
if (level > 0)
{
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
}
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>null", (unsigned long)index);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "null");
#endif
break;
case HIO_JSON_INST_TRUE:
if (level > 0)
{
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
}
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>true", (unsigned long)index);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "true");
#endif
break;
case HIO_JSON_INST_FALSE:
if (level > 0)
{
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
}
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>false", (unsigned long)index);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "false");
#endif
break;
case HIO_JSON_INST_NUMBER:
if (level > 0)
{
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
}
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>%.*js", (unsigned long)index, str->len, str->ptr);
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "%.*js", str->len, str->ptr);
#endif
break;
case HIO_JSON_INST_STRING:
if (level > 0)
{
if (index > 0) hio_logbfmt (hio, HIO_LOG_STDOUT, ",\n");
for (i = 0; i < level; i++) hio_logbfmt (hio, HIO_LOG_STDOUT, "\t");
}
#if defined(DEBUG)
hio_logbfmt (hio, HIO_LOG_STDOUT, "<%lu>\"%.*js\"", (unsigned long)index, str->len, str->ptr); /* TODO: escaping */
#else
hio_logbfmt (hio, HIO_LOG_STDOUT, "\"%.*js\"", str->len, str->ptr); /* TODO: escaping */
#endif
break;
default:
hio_logbfmt (hio, HIO_LOG_STDOUT, "*****UNKNOWN*****\n", str->len, str->ptr);
return -1;
}
return 0;
}
static int write_json_element (hio_jsonwr_t* jsonwr, const hio_bch_t* dptr, hio_oow_t dlen, void* ctx)
{
fwrite (dptr, 1, dlen, stdout);
return 0;
}
int main (int argc, char* argv[])
{
hio_t* hio = HIO_NULL;
hio_bitmask_t o = 0;
int i;
for (i = 1; i < argc; i++)
{
if (strcmp(argv[i], "--permit-word-key") == 0) o |= HIO_JSON_PERMIT_WORD_KEY;
if (strcmp(argv[i], "--optional-comma") == 0) o |= HIO_JSON_OPTIONAL_COMMA;
if (strcmp(argv[i], "--line-comment") == 0) o |= HIO_JSON_LINE_COMMENT;
}
hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
return -1;
}
{
hio_json_t* json = HIO_NULL;
char buf[128];
hio_oow_t rem;
size_t size;
json = hio_json_open(hio, 0);
hio_json_setoption (json, o);
hio_json_setinstcb (json, on_json_inst, HIO_NULL);
rem = 0;
while (!feof(stdin) || rem > 0)
{
int x;
if (!feof(stdin))
{
size = fread(&buf[rem], 1, sizeof(buf) - rem, stdin);
if (size <= 0) break;
}
else
{
size = rem;
rem = 0;
}
if ((x = hio_json_feed(json, buf, size + rem, &rem, 1)) <= -1)
{
hio_logbfmt (hio, HIO_LOG_STDOUT, "**** ERROR - %js ****\n", hio_geterrmsg(hio));
goto done;
}
if (x > 0)
{
/* document completed.
* if only whitespaces are given, x is still greater 0. */
hio_logbfmt (hio, HIO_LOG_STDOUT, "\n-----------------------------------\n");
}
/*printf ("--> x %d input %d left-over %d => [%.*s]\n", (int)x, (int)size, (int)rem, (int)rem, &buf[size - rem]);*/
if (rem > 0) memcpy (buf, &buf[size - rem], rem);
}
hio_logbfmt (hio, HIO_LOG_STDOUT, "\n");
if (json->state_stack != &json->state_top) hio_logbfmt (hio, HIO_LOG_STDOUT, "**** ERROR - incomplete ****\n");
done:
hio_json_close (json);
}
hio_logbfmt (hio, HIO_LOG_STDOUT, "\n===================================\n");
{
hio_jsonwr_t* jsonwr = HIO_NULL;
hio_uch_t ddd[4] = { 'D', '\0', 'R', 'Q' };
hio_uch_t ddv[5] = { L'', L'', L'', L'', L'' };
jsonwr = hio_jsonwr_open (hio, 0, HIO_JSONWR_FLAG_PRETTY);
hio_jsonwr_setwritecb (jsonwr, write_json_element, HIO_NULL);
hio_jsonwr_startarray (jsonwr);
hio_jsonwr_writestringwithbchars (jsonwr, "hello", 5);
hio_jsonwr_writestringwithbchars (jsonwr, "world", 5);
hio_jsonwr_startobject (jsonwr);
hio_jsonwr_writekeywithbchars (jsonwr, "abc", 3);
hio_jsonwr_writestringwithbchars (jsonwr, "computer", 8);
hio_jsonwr_writekeywithbchars (jsonwr, "k", 1);
hio_jsonwr_writestringwithbchars (jsonwr, "play nice", 9);
hio_jsonwr_writekeywithuchars (jsonwr, ddd, 4);
hio_jsonwr_writestringwithuchars (jsonwr, ddv, 5);
hio_jsonwr_endobject (jsonwr);
hio_jsonwr_writestringwithbchars (jsonwr, "tyler", 5);
hio_jsonwr_startarray (jsonwr);
hio_jsonwr_writestringwithbchars (jsonwr, "airplain", 8);
hio_jsonwr_writestringwithbchars (jsonwr, "gro\0wn\nup", 9);
hio_jsonwr_writetrue (jsonwr);
hio_jsonwr_endarray (jsonwr);
hio_jsonwr_endarray (jsonwr);
hio_jsonwr_close (jsonwr);
}
hio_close (hio);
return 0;
}

320
bin/t04.c Normal file
View File

@ -0,0 +1,320 @@
#include <hio.h>
#if defined(HIO_ENABLE_MARIADB)
#include <hio-mar.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#if 0
#include <mariadb/mysql.h>
#else
#include <mysql.h>
#endif
#if 0
static void mar_on_disconnect (hio_dev_mar_t* dev)
{
}
static void mar_on_connect (hio_dev_mar_t* dev)
{
printf ("CONNECTED...\n");
if (hio_dev_mar_querywithbchars(dev, "SHOW STATUS", 11) <= -1)
{
hio_dev_mar_halt (dev);
}
}
static void mar_on_query_started (hio_dev_mar_t* dev, int mar_ret, const hio_bch_t* mar_errmsg)
{
if (mar_ret != 0)
{
printf ("QUERY NOT SENT PROPERLY..%s\n", mysql_error(dev->hnd));
}
else
{
printf ("QUERY SENT..\n");
if (hio_dev_mar_fetchrows(dev) <= -1)
{
printf ("FETCH ROW FAILURE - %s\n", errmsg);
hio_dev_mar_halt (dev);
}
}
}
static void mar_on_row_fetched (hio_dev_mar_t* dev, void* data)
{
MYSQL_ROW row = (MYSQL_ROW)data;
static int x = 0;
if (!row)
{
printf ("NO MORE ROW..\n");
if (x == 0 && hio_dev_mar_querywithbchars(dev, "SELECT * FROM pdns.records", 26) <= -1) hio_dev_mar_halt (dev);
x++;
}
else
{
if (x == 0)
printf ("%s %s\n", row[0], row[1]);
else if (x == 1)
printf ("%s %s %s %s %s\n", row[0], row[1], row[2], row[3], row[4]);
//printf ("GOT ROW\n");
}
}
int main (int argc, char* argv[])
{
hio_t* hio = HIO_NULL;
hio_dev_mar_t* mar;
hio_dev_mar_make_t mi;
hio_dev_mar_connect_t ci;
if (argc != 6)
{
fprintf (stderr, "Usage: %s ipaddr port username password dbname\n", argv[0]);
return -1;
}
hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
goto oops;
}
memset (&ci, 0, HIO_SIZEOF(ci));
ci.host = argv[1];
ci.port = 3306; /* TODO: argv[2]; */
ci.username = argv[3];
ci.password = argv[4];
ci.dbname = argv[5];
memset (&mi, 0, HIO_SIZEOF(mi));
/*mi.on_write = mar_on_write;
mi.on_read = mar_on_read;*/
mi.on_connect = mar_on_connect;
mi.on_disconnect = mar_on_disconnect;
mi.on_query_started = mar_on_query_started;
mi.on_row_fetched = mar_on_row_fetched;
mar = hio_dev_mar_make(hio, 0, &mi);
if (!mar)
{
printf ("Cannot make a mar db client device\n");
goto oops;
}
if (hio_dev_mar_connect(mar, &ci) <= -1)
{
printf ("Cannot connect to mar db server\n");
goto oops;
}
hio_loop (hio);
oops:
if (hio) hio_close (hio);
return 0;
}
#endif
static void on_result (hio_svc_marc_t* svc, hio_oow_t sid, hio_svc_marc_rcode_t rcode, void* data, void* qctx)
{
static int x = 0;
switch (rcode)
{
case HIO_SVC_MARC_RCODE_ROW:
{
MYSQL_ROW row = (MYSQL_ROW)data;
// if (x == 0)
printf ("[%lu] %s %s\n", sid, row[0], row[1]);
// else if (x == 1)
// printf ("%s %s %s %s %s\n", row[0], row[1], row[2], row[3], row[4]);
//printf ("GOT ROW\n");
#if 0
x++;
if (x == 1)
{
printf ("BLOCKING PACKET...........................\n");
system ("/sbin/iptables -I OUTPUT -p tcp --dport 3306 -j REJECT");
system ("/sbin/iptables -I INPUT -p tcp --sport 3306 -j REJECT");
}
#endif
break;
}
case HIO_SVC_MARC_RCODE_DONE:
printf ("[%lu] NO DATA..\n", sid);
break;
case HIO_SVC_MARC_RCODE_ERROR:
{
hio_svc_marc_dev_error_t* err = (hio_svc_marc_dev_error_t*)data;
printf ("QUERY ERROR - [%d] %s\n", err->mar_errcode, err->mar_errmsg);
break;
}
}
}
static hio_t* g_hio = HIO_NULL;
static void handle_signal (int sig)
{
hio_stop (g_hio, HIO_STOPREQ_TERMINATION);
}
static void send_test_query (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t* job)
{
hio_svc_marc_t* marc = (hio_svc_marc_t*)job->ctx;
hio_bch_t buf[256];
hio_bch_t tmp[256];
int len;
HIO_INFO0 (hio, "ATTEMPTING TO SEND QUERY\n");
if (hio_svc_marc_querywithbchars(marc, 0, HIO_SVC_MARC_QTYPE_SELECT, "SHOW STATUS", 11, on_result, HIO_NULL) <= -1)
{
HIO_INFO1 (hio, "FAILED TO SEND QUERY - %js\n", hio_geterrmsg(hio));
}
hio_svc_marc_escapebchars (marc, "wild", 4, tmp);
len = snprintf(buf, HIO_COUNTOF(buf), "SELECT name, content FROM records WHERE name like '%%%s%%'", tmp);
if (hio_svc_marc_querywithbchars(marc, 1, HIO_SVC_MARC_QTYPE_SELECT, buf, len, on_result, HIO_NULL) <= -1)
{
HIO_INFO1 (hio, "FAILED TO SEND QUERY - %js\n", hio_geterrmsg(hio));
}
}
static int schedule_timer_job_after (hio_t* hio, const hio_ntime_t* fire_after, hio_tmrjob_handler_t handler, void* ctx)
{
hio_tmrjob_t tmrjob;
memset (&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = ctx;
hio_gettime (hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, fire_after);
tmrjob.handler = handler;
tmrjob.idxptr = HIO_NULL;
return hio_instmrjob(hio, &tmrjob);
}
int main (int argc, char* argv[])
{
hio_t* hio = HIO_NULL;
hio_svc_marc_t* marc;
hio_svc_marc_connect_t ci;
hio_svc_marc_tmout_t tmout;
if (argc != 6)
{
fprintf (stderr, "Usage: %s ipaddr port username password dbname\n", argv[0]);
return -1;
}
hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
goto oops;
}
memset (&ci, 0, HIO_SIZEOF(ci));
ci.host = argv[1];
ci.port = 3306; /* TODO: argv[2]; */
ci.username = argv[3];
ci.password = argv[4];
ci.dbname = argv[5];
memset (&tmout, 0, HIO_SIZEOF(tmout));
HIO_INIT_NTIME (&tmout.c, 4, 0);
HIO_INIT_NTIME (&tmout.r, -1, 0);
HIO_INIT_NTIME (&tmout.w, -1, 0);
marc = hio_svc_marc_start(hio, &ci, &tmout, HIO_NULL);
/*marc = hio_svc_marc_start(hio, &ci, HIO_NULL, HIO_NULL);*/
if (!marc)
{
printf ("Cannot start a mariadb client service\n");
goto oops;
}
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_SELECT, "SHOW STATUS", 11, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM", 11, on_result, HIO_NULL);
// hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_SELECT, "SHOW STATUS", 11, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM XXX", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM ZZZ", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM TTT", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM QQQ", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 4 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 10 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 10 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
hio_svc_marc_querywithbchars (marc, 10 | HIO_SVC_MARC_SID_FLAG_AUTO_BOUNDED, HIO_SVC_MARC_QTYPE_ACTION, "DELETE FROM RRR", 14, on_result, HIO_NULL);
#if 0
memset (&mi, 0, HIO_SIZEOF(mi));
/*mi.on_write = mar_on_write;
mi.on_read = mar_on_read;*/
mi.on_connect = mar_on_connect;
mi.on_disconnect = mar_on_disconnect;
mi.on_query_started = mar_on_query_started;
mi.on_row_fetched = mar_on_row_fetched;
mar = hio_dev_mar_make(hio, 0, &mi);
if (!mar)
{
printf ("Cannot make a mar db client device\n");
goto oops;
}
if (hio_dev_mar_connect(mar, &ci) <= -1)
{
printf ("Cannot connect to mar db server\n");
goto oops;
}
#endif
g_hio = hio;
signal (SIGINT, handle_signal);
/* ---------------------------------------- */
{
hio_ntime_t x;
HIO_INIT_NTIME (&x, 20, 0);
schedule_timer_job_after (hio, &x, send_test_query, marc);
hio_loop (hio);
}
/* ---------------------------------------- */
signal (SIGINT, SIG_IGN);
g_hio = HIO_NULL;
oops:
printf ("about to close hio...\n");
if (hio) hio_close (hio);
return 0;
}
#else
#include <stdio.h>
int main (int argc, char* argv[])
{
printf ("mariadb not enabled\n");
return 0;
}
#endif

88
bin/t05.c Normal file
View File

@ -0,0 +1,88 @@
#include <hio-sck.h>
#include <hio-http.h>
#include <hio-pty.h>
#include <hio-utl.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
static hio_t* g_hio = HIO_NULL;
static void handle_sigint (int sig)
{
if (g_hio) hio_stop (g_hio, HIO_STOPREQ_TERMINATION);
}
int pty_on_read (hio_dev_pty_t* dev, const void* data, hio_iolen_t len)
{
hio_iolen_t i;
for (i = 0; i < len; i++) fputc(*((char*)data + i), stdout);
return 0;
}
int pty_on_write (hio_dev_pty_t* dev, hio_iolen_t wrlen, void* wrctx)
{
return 0;
}
void pty_on_close (hio_dev_pty_t* dev)
{
printf (">> pty closed....\n");
}
int main (int argc, char* argv[])
{
hio_t* hio = HIO_NULL;
hio_dev_pty_t* pty;
hio_dev_pty_make_t pi;
struct sigaction sigact;
int xret = -1;
memset (&sigact, 0, HIO_SIZEOF(sigact));
sigact.sa_handler = SIG_IGN;
sigaction (SIGPIPE, &sigact, HIO_NULL);
memset (&sigact, 0, HIO_SIZEOF(sigact));
sigact.sa_handler = handle_sigint;
sigaction (SIGINT, &sigact, HIO_NULL);
hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
goto oops;
}
hio_setoption (hio, HIO_LOG_TARGET_BCSTR, "/dev/stderr");
memset (&pi, 0, HIO_SIZEOF(pi));
pi.cmd = "/bin/ls -laF /etc";
pi.flags = HIO_DEV_PTY_SHELL;
pi.on_write = pty_on_write;
pi.on_read = pty_on_read;
pi.on_close = pty_on_close;
pty = hio_dev_pty_make(hio, 0, &pi);
if (!pty) goto oops;
g_hio = hio;
hio_loop (hio);
xret = 0;
oops:
memset (&sigact, 0, HIO_SIZEOF(sigact));
sigact.sa_handler = SIG_IGN;
sigaction (SIGINT, &sigact, HIO_NULL);
if (hio) hio_close (hio);
return xret;
}

692
bin/t06.c Normal file
View File

@ -0,0 +1,692 @@
#include <hio-sck.h>
#include <hio-http.h>
#include <hio-dhcp.h>
#include <hio-utl.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#define MAX_NUM_THRS 256
static int g_num_thrs = 2;
static hio_svc_htts_t* g_htts[MAX_NUM_THRS];
static int g_htts_no = 0;
static pthread_mutex_t g_htts_mutex = PTHREAD_MUTEX_INITIALIZER;
static int g_dev_type4 = HIO_DEV_SCK_TCP4;
static int g_dev_type6 = HIO_DEV_SCK_TCP6;
static int print_qparam (hio_bcs_t* key, hio_bcs_t* val, void* ctx)
{
key->len = hio_perdec_http_bcs(key, key->ptr, HIO_NULL);
val->len = hio_perdec_http_bcs(val, val->ptr, HIO_NULL);
fprintf ((FILE*)ctx, "\t[%.*s] = [%.*s]\n", (int)key->len, key->ptr, (int)val->len, val->ptr);
return 0;
}
static void on_htts_thr_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
{
FILE* fp;
int i;
if (tfi->req_method != HIO_HTTP_GET)
{
write (iop->wfd, "Status: 405\r\n\r\n", 15); /* method not allowed */
return;
}
fp = fdopen(iop->wfd, "w");
if (!fp)
{
write (iop->wfd, "Status: 500\r\n\r\n", 15); /* internal server error */
return;
}
fprintf (fp, "Status: 200\r\n");
fprintf (fp, "Content-Type: text/html\r\n\r\n");
fprintf (fp, "request path = %s\n", tfi->req_path);
if (tfi->req_param)
{
fprintf (fp, "request params:\n");
hio_scan_http_qparam (tfi->req_param, print_qparam, fp);
}
for (i = 0; i < 100; i++) fprintf (fp, "%d * %d => %d\n", i, i, i * i);
/* invalid iop->wfd to mark that this function closed this file descriptor.
* no invalidation will lead to double closes on the same file descriptor. */
iop->wfd = HIO_SYSHND_INVALID;
fclose (fp);
}
static void on_htts_thr2_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
{
FILE* fp, * sf;
if (tfi->req_method != HIO_HTTP_GET)
{
write (iop->wfd, "Status: 405\r\n\r\n", 15); /* method not allowed */
return;
}
fp = fdopen(iop->wfd, "w");
if (!fp)
{
write (iop->wfd, "Status: 500\r\n\r\n", 15); /* internal server error */
return;
}
sf = fopen(&tfi->req_path[5], "r");
if (!sf)
{
fprintf (fp, "Status: 404\r\n\r\n");
}
else
{
char buf[4096];
fprintf (fp, "Status: 200\r\n");
fprintf (fp, "Content-Type: text/html\r\n\r\n");
while (!feof(sf) && !ferror(sf))
{
size_t n;
n = fread(buf, 1, sizeof(buf), sf);
if (n > 0) fwrite (buf, 1, n, fp);
}
fclose (sf);
}
/* invalid iop->wfd to mark that this function closed this file descriptor.
* no invalidation will lead to double closes on the same file descriptor.
* the hio library attempt to close it if it's not INVALID after this handler. */
iop->wfd = HIO_SYSHND_INVALID;
fclose (fp);
}
/* ========================================================================= */
int process_http_request (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* req)
{
hio_t* hio = hio_svc_htts_gethio(htts);
// hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(csck);
hio_http_method_t mth;
/* percent-decode the query path to the original buffer
* since i'm not going to need it in the original form
* any more. once it's decoded in the peek mode,
* the decoded query path is made available in the
* non-peek mode as well */
HIO_DEBUG2 (hio, "[RAW-REQ] %s %s\n", hio_htre_getqmethodname(req), hio_htre_getqpath(req));
hio_htre_perdecqpath(req);
/* TODO: proper request logging */
HIO_DEBUG2 (hio, "[REQ] %s %s\n", hio_htre_getqmethodname(req), hio_htre_getqpath(req));
#if 0
hio_printf (HIO_T("================================\n"));
hio_printf (HIO_T("[%lu] %hs REQUEST ==> [%hs] version[%d.%d %hs] method[%hs]\n"),
(unsigned long)time(NULL),
(peek? HIO_MT("PEEK"): HIO_MT("HANDLE")),
hio_htre_getqpath(req),
hio_htre_getmajorversion(req),
hio_htre_getminorversion(req),
hio_htre_getverstr(req),
hio_htre_getqmethodname(req)
);
if (hio_htre_getqparam(req))
hio_printf (HIO_T("PARAMS ==> [%hs]\n"), hio_htre_getqparam(req));
hio_htb_walk (&req->hdrtab, walk, HIO_NULL);
if (hio_htre_getcontentlen(req) > 0)
{
hio_printf (HIO_T("CONTENT [%.*S]\n"), (int)hio_htre_getcontentlen(req), hio_htre_getcontentptr(req));
}
#endif
mth = hio_htre_getqmethodtype(req);
/* determine what to do once the header fields are all received.
* i don't want to delay this until the contents are received.
* if you don't like this behavior, you must implement your own
* callback function for request handling. */
#if 0
/* TODO support X-HTTP-Method-Override */
if (data.method == HIO_HTTP_POST)
{
tmp = hio_htre_getheaderval(req, HIO_MT("X-HTTP-Method-Override"));
if (tmp)
{
/*while (tmp->next) tmp = tmp->next;*/ /* get the last value */
data.method = hio_mbstohttpmethod (tmp->ptr);
}
}
#endif
#if 0
if (mth == HIO_HTTP_CONNECT)
{
/* CONNECT method must not have content set.
* however, arrange to discard it if so.
*
* NOTE: CONNECT is implemented to ignore many headers like
* 'Expect: 100-continue' and 'Connection: keep-alive'. */
hio_htre_discardcontent (req);
}
else
{
/* this part can be checked in actual hio_svc_htts_doXXX() functions.
* some doXXX handlers may not require length for POST.
* it may be able to simply accept till EOF? or treat as if CONTENT_LENGTH is 0*/
if (mth == HIO_HTTP_POST && !(req->flags & (HIO_HTRE_ATTR_LENGTH | HIO_HTRE_ATTR_CHUNKED)))
{
/* POST without Content-Length nor not chunked */
hio_htre_discardcontent (req);
/* 411 Length Required - can't keep alive. Force disconnect */
req->flags &= ~HIO_HTRE_ATTR_KEEPALIVE; /* to cause sendstatus() to close */
if (hio_svc_htts_sendstatus(htts, csck, req, 411, HIO_NULL) <= -1) goto oops;
}
else
#endif
{
const hio_bch_t* qpath = hio_htre_getqpath(req);
int x;
if (hio_comp_bcstr_limited(qpath, "/thr/", 5, 1) == 0)
x = hio_svc_htts_dothr(htts, csck, req, on_htts_thr_request, HIO_NULL);
else if (hio_comp_bcstr_limited(qpath, "/thr2/", 6, 1) == 0)
x = hio_svc_htts_dothr(htts, csck, req, on_htts_thr2_request, HIO_NULL);
else if (hio_comp_bcstr_limited(qpath, "/txt/", 5, 1) == 0)
x = hio_svc_htts_dotxt(htts, csck, req, 200, "text/plain", qpath);
else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0)
x = hio_svc_htts_docgi(htts, csck, req, "", qpath + 4);
else if (hio_comp_bcstr_limited(qpath, "/fcgi/", 5, 1) == 0)
{
hio_skad_t fcgis_addr;
hio_bcstrtoskad(hio, "127.0.0.1:9000", &fcgis_addr);
x = hio_svc_htts_dofcgi(htts, csck, req, &fcgis_addr);
}
else
x = hio_svc_htts_dofile(htts, csck, req, "", qpath, "text/plain");
if (x <= -1) goto oops;
}
#if 0
}
#endif
return 0;
oops:
hio_dev_sck_halt (csck);
return -1;
}
void* thr_func (void* arg)
{
hio_t* hio = HIO_NULL;
hio_svc_htts_t* htts = HIO_NULL;
hio_dev_sck_bind_t htts_bind_info[2];
int htts_no = -1;
hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
goto oops;
}
hio_setoption (hio, HIO_LOG_TARGET_BCSTR, "/dev/stderr");
memset (&htts_bind_info, 0, HIO_SIZEOF(htts_bind_info));
hio_skad_init_for_qx (&htts_bind_info[0].localaddr);
hio_bcstrtoskad (hio, "0.0.0.0:9988", &htts_bind_info[1].localaddr);
htts_bind_info[1].options = HIO_DEV_SCK_BIND_REUSEADDR | HIO_DEV_SCK_BIND_REUSEPORT | HIO_DEV_SCK_BIND_IGNERR;
#if 0
htts_bind_info[1].options |= HIO_DEV_SCK_BIND_SSL;
htts_bind_info[1].ssl_certfile = "localhost.crt";
htts_bind_info[1].ssl_keyfile = "localhost.key";
#endif
htts = hio_svc_htts_start(hio, htts_bind_info, HIO_COUNTOF(htts_bind_info), process_http_request);
if (!htts)
{
printf ("Unable to start htts\n");
goto oops;
}
pthread_mutex_lock (&g_htts_mutex);
htts_no = g_htts_no;
g_htts[htts_no] = htts;
g_htts_no = (g_htts_no + 1) % g_num_thrs;
pthread_mutex_unlock (&g_htts_mutex);
hio_loop (hio);
oops:
pthread_mutex_lock (&g_htts_mutex);
if (htts)
{
hio_svc_htts_stop (htts);
g_htts[htts_no] = HIO_NULL;
}
pthread_mutex_unlock (&g_htts_mutex);
if (hio) hio_close (hio);
pthread_exit (HIO_NULL);
return HIO_NULL;
}
/* ========================================================================= */
static void tcp_sck_on_disconnect (hio_dev_sck_t* tcp)
{
switch (HIO_DEV_SCK_GET_PROGRESS(tcp))
{
case HIO_DEV_SCK_CONNECTING:
HIO_INFO1 (tcp->hio, "OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_CONNECTING_SSL:
HIO_INFO1 (tcp->hio, "OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_LISTENING:
HIO_INFO1 (tcp->hio, "SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_CONNECTED:
HIO_INFO1 (tcp->hio, "OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_ACCEPTING_SSL:
HIO_INFO1 (tcp->hio, "INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->hnd);
break;
case HIO_DEV_SCK_ACCEPTED:
HIO_INFO1 (tcp->hio, "INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->hnd);
break;
default:
HIO_INFO2 (tcp->hio, "SOCKET DEVICE DISCONNECTED (%d - %x)\n", (int)tcp->hnd, (unsigned int)tcp->state);
break;
}
}
static void tcp_sck_on_connect (hio_dev_sck_t* tcp)
{
hio_bch_t buf1[128], buf2[128];
hio_skadtobcstr (tcp->hio, &tcp->localaddr, buf1, HIO_COUNTOF(buf1), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
hio_skadtobcstr (tcp->hio, &tcp->remoteaddr, buf2, HIO_COUNTOF(buf2), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
if (tcp->state & HIO_DEV_SCK_CONNECTED)
{
HIO_INFO3 (tcp->hio, "DEVICE connected to a remote server... LOCAL %hs REMOTE %hs SCK: %d\n", buf1, buf2, tcp->hnd);
}
else if (tcp->state & HIO_DEV_SCK_ACCEPTED)
{
/* TODO: pass it to distributor??? */
/* THIS PART WON"T BE CALLED FOR tcp_sck_on_raw_accept.. */
}
}
static hio_tmridx_t xx_tmridx;
static int try_to_accept (hio_dev_sck_t* sck, hio_dev_sck_qxmsg_t* qxmsg, int in_mq);
typedef struct xx_mq_t xx_mq_t;
struct xx_mq_t
{
xx_mq_t* q_next;
xx_mq_t* q_prev;
hio_dev_sck_qxmsg_t msg;
};
#define XX_MQ_INIT(mq) ((mq)->q_next = (mq)->q_prev = (mq))
#define XX_MQ_TAIL(mq) ((mq)->q_prev)
#define XX_MQ_HEAD(mq) ((mq)->q_next)
#define XX_MQ_IS_EMPTY(mq) (XX_MQ_HEAD(mq) == (mq))
#define XX_MQ_IS_NODE(mq,x) ((mq) != (x))
#define XX_MQ_IS_HEAD(mq,x) (XX_MQ_HEAD(mq) == (x))
#define XX_MQ_IS_TAIL(mq,x) (XX_MQ_TAIL(mq) == (x))
#define XX_MQ_NEXT(x) ((x)->q_next)
#define XX_MQ_PREV(x) ((x)->q_prev)
#define XX_MQ_LINK(p,x,n) HIO_Q_LINK((hio_q_t*)p,(hio_q_t*)x,(hio_q_t*)n)
#define XX_MQ_UNLINK(x) HIO_Q_UNLINK((hio_q_t*)x)
#define XX_MQ_REPL(o,n) HIO_Q_REPL(o,n);
#define XX_MQ_ENQ(mq,x) XX_MQ_LINK(XX_MQ_TAIL(mq), (hio_q_t*)x, mq)
#define XX_MQ_DEQ(mq) XX_MQ_UNLINK(XX_MQ_HEAD(mq))
static xx_mq_t xx_mq;
static void enable_accept (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t* job)
{
hio_dev_sck_t* rdev = (hio_dev_sck_t*)job->ctx;
while (!XX_MQ_IS_EMPTY(&xx_mq))
{
xx_mq_t* mq;
mq = XX_MQ_HEAD(&xx_mq);
if (try_to_accept(rdev, &mq->msg, 1) == 0) return; /* EAGAIN situation */
XX_MQ_UNLINK (mq);
hio_freemem (hio, mq);
}
assert (XX_MQ_IS_EMPTY(&xx_mq));
if (hio_dev_sck_read(rdev, 1) <= -1) // it's a disaster if this fails. the acceptor will get stalled if it happens
{
printf ("DISASTER.... UNABLE TO ENABLE READ ON ACCEPTOR\n");
}
}
static int try_to_accept (hio_dev_sck_t* sck, hio_dev_sck_qxmsg_t* qxmsg, int in_mq)
{
hio_t* hio = sck->hio;
hio_svc_htts_t* htts;
pthread_mutex_lock (&g_htts_mutex);
htts = g_htts[g_htts_no];
g_htts_no = (g_htts_no + 1) % g_num_thrs;
pthread_mutex_unlock (&g_htts_mutex);
/* 0: index to the QX socket device (see the the first binding address to hi_svc_htts_start) */
if (hio_svc_htts_writetosidechan(htts, 0, qxmsg, HIO_SIZEOF(*qxmsg)) <= -1)
{
hio_bch_t buf[128];
if (errno == EAGAIN)
{
//printf ("sidechannel retrying %s\n", strerror(errno));
if (hio_dev_sck_read(sck, 0) <= -1) goto sidechan_write_error;
if (!in_mq)
{
xx_mq_t* mq;
mq = hio_allocmem(hio, HIO_SIZEOF(*mq));
if (HIO_UNLIKELY(!mq)) goto sidechan_write_error;
mq->msg = *qxmsg;
XX_MQ_ENQ (&xx_mq, mq);
}
if (xx_tmridx == HIO_TMRIDX_INVALID)
hio_schedtmrjobat (hio, HIO_NULL, enable_accept, &xx_tmridx, sck);
return 0; /* enqueued for later writing */
}
else
{
const char* msg;
sidechan_write_error:
//printf ("sidechannel write error errno=%d strerror=%s\n", errno, strerror(errno));
hio_skadtobcstr (hio, &qxmsg->remoteaddr, buf, HIO_COUNTOF(buf), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
HIO_INFO2 (hio, "unable to handle the accepted connection %ld from %hs\n", (long int)qxmsg->syshnd, buf);
msg = "HTTP/1.0 503 Service unavailable\r\nConnection: close\r\nContent-Length: 0\r\n\r\n";
write (qxmsg->syshnd, msg, strlen(msg));
printf ("close %d\n", qxmsg->syshnd);
close (qxmsg->syshnd);
return -1; /* failed to accept */
}
}
/************************************
{
static int sc = 0;
printf ("sc => %d\n", sc++);
}
************************************/
return 1; /* full success */
}
static void tcp_sck_on_raw_accept (hio_dev_sck_t* sck, hio_syshnd_t syshnd, hio_skad_t* remoteaddr)
{
/*hio_t* hio = sck->hio;*/
/* inform the worker of this accepted syshnd */
hio_dev_sck_qxmsg_t qxmsg;
memset (&qxmsg, 0, HIO_SIZEOF(qxmsg));
qxmsg.cmd = HIO_DEV_SCK_QXMSG_NEWCONN;
qxmsg.scktype = sck->type;
qxmsg.syshnd = syshnd;
qxmsg.remoteaddr = *remoteaddr;
try_to_accept (sck, &qxmsg, 0);
}
static int tcp_sck_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{
/* won't be invoked if tcp.
* invokde if sctp_sp */
//printf ("wrote back chan %d\n", hio_skad_chan(dstaddr));
return 0;
}
static int tcp_sck_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{
/* won't be invoked
* invokde if sctp_sp */
#if 0
hio_iovec_t iov;
/* the code here is invoked on a seqpacket socket. .. this part not ready. will rewrite if the core support is done */
printf ("[%.*s] chan %d\n", (int)len, buf, hio_skad_chan(srcaddr));
iov.iov_ptr = buf;
iov.iov_len = len;
hio_skad_set_scope_id (srcaddr, 3);
hio_dev_sck_writev (sck, &iov, 1, HIO_NULL, srcaddr);
#endif
return 0;
}
static int add_listener (hio_t* hio, hio_bch_t* addrstr)
{
hio_dev_sck_make_t mi;
hio_dev_sck_t* tcp;
hio_dev_sck_bind_t bi;
hio_dev_sck_listen_t li;
int f;
memset (&bi, 0, HIO_SIZEOF(bi));
if (hio_bcstrtoskad(hio, addrstr, &bi.localaddr) <= -1)
{
HIO_INFO1 (hio, "invalid listening address - %hs\n", addrstr);
return -1;
}
bi.options = HIO_DEV_SCK_BIND_REUSEADDR /*| HIO_DEV_SCK_BIND_REUSEPORT |*/;
bi.options |= HIO_DEV_SCK_BIND_IGNERR;
#if defined(USE_SSL)
bi.options |= HIO_DEV_SCK_BIND_SSL;
bi.ssl_certfile = "localhost.crt";
bi.ssl_keyfile = "localhost.key";
#endif
memset (&mi, 0, HIO_SIZEOF(mi));
f = hio_skad_get_family(&bi.localaddr);
if (f == HIO_AF_INET) mi.type = g_dev_type4;
else if (f == HIO_AF_INET6) mi.type = g_dev_type6;
else if (f == HIO_AF_UNIX) mi.type = HIO_DEV_SCK_UNIX;
else
{
HIO_INFO1 (hio, "unsupported address type - %hs\n", addrstr);
return -1;
}
mi.options = HIO_DEV_SCK_MAKE_LENIENT;
mi.on_write = tcp_sck_on_write;
mi.on_read = tcp_sck_on_read;
mi.on_connect = tcp_sck_on_connect; /* this is invoked on a client accept as well */
mi.on_disconnect = tcp_sck_on_disconnect;
mi.on_raw_accept = tcp_sck_on_raw_accept;
tcp = hio_dev_sck_make(hio, 0, &mi);
if (!tcp)
{
HIO_INFO2 (hio, "Cannot make tcp for %hs - %js\n", addrstr, hio_geterrmsg(hio));
return -1;
}
if (hio_dev_sck_bind(tcp, &bi) <= -1)
{
HIO_INFO2 (hio, "tcp hio_dev_sck_bind() failed with %hs - %js\n", addrstr, hio_geterrmsg(hio));
return -1;
}
memset (&li, 0, HIO_SIZEOF(li));
li.backlogs = 4096;
HIO_INIT_NTIME (&li.accept_tmout, 5, 1);
if (hio_dev_sck_listen(tcp, &li) <= -1)
{
HIO_INFO2 (hio, "tcp hio_dev_sck_listen() failed on %hs - %js\n", addrstr, hio_geterrmsg(hio));
return -1;
}
else
{
hio_skad_t skad;
hio_bch_t buf[HIO_SKAD_IP_STRLEN + 1];
hio_dev_sck_getsockaddr (tcp, &skad);
hio_skadtobcstr (hio, &skad, buf, HIO_COUNTOF(buf), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
HIO_INFO1 (hio, "main listener on %hs\n", buf);
}
return 0;
}
static hio_t* g_hio = HIO_NULL;
static void handle_sigint (int sig)
{
if (g_hio) hio_stop (g_hio, HIO_STOPREQ_TERMINATION);
}
int main (int argc, char* argv[])
{
hio_t* hio = HIO_NULL;
pthread_t t[MAX_NUM_THRS];
hio_oow_t i;
struct sigaction sigact;
int xret = -1;
// TODO: use getopt() or something similar
for (i = 1; i < argc; )
{
if (strcmp(argv[i], "-s") == 0)
{
i++;
g_dev_type4 = HIO_DEV_SCK_SCTP4;
g_dev_type6 = HIO_DEV_SCK_SCTP6;
}
else if (strcmp(argv[i], "-ss") == 0)
{
i++;
g_dev_type4 = HIO_DEV_SCK_SCTP4_SP;
g_dev_type6 = HIO_DEV_SCK_SCTP6_SP;
}
else if (strcmp(argv[i], "-t") == 0)
{
i++;
if (i < argc)
{
g_num_thrs = atoi(argv[i]);
if (g_num_thrs < 1 || g_num_thrs > MAX_NUM_THRS)
{
printf ("Error: %s not allowed for -t\n", argv[i]);
return -1;
}
i++;
}
else
{
g_num_thrs = 2;
}
}
else
{
printf ("Error: invalid argument %s\n", argv[i]);
return -1;
}
}
memset (&sigact, 0, HIO_SIZEOF(sigact));
sigact.sa_handler = SIG_IGN;
sigaction (SIGPIPE, &sigact, HIO_NULL);
memset (&sigact, 0, HIO_SIZEOF(sigact));
sigact.sa_handler = handle_sigint;
sigaction (SIGINT, &sigact, HIO_NULL);
XX_MQ_INIT (&xx_mq);
xx_tmridx = HIO_TMRIDX_INVALID;
hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
goto oops;
}
hio_setoption (hio, HIO_LOG_TARGET_BCSTR, "/dev/stderr");
g_hio = hio;
for (i = 0; i < g_num_thrs; i++)
pthread_create (&t[i], HIO_NULL, thr_func, hio);
sleep (1); /* TODO: use pthread_cond_wait()/pthread_cond_signal() or a varialble to see if all threads are up */
/* TODO: wait until all threads are ready to serve... */
if (add_listener(hio, "[::]:9987") <= -1 &&
add_listener(hio, "0.0.0.0:9987") <= -1) goto oops; /* as long as 1 listener is alive */
/* add a unix socket listener.
* don't check for an error to continue without it in case it fails. */
unlink ("t06.sck");
add_listener(hio, "@t06.sck");
{
hio_skad_t skad;
hio_bcstrtoskad(hio, "[::]:3547", &skad);
hio_svc_dhcs_start (hio, &skad, 1);
}
hio_loop (hio);
xret = 0;
oops:
memset (&sigact, 0, HIO_SIZEOF(sigact));
sigact.sa_handler = SIG_IGN;
sigaction (SIGINT, &sigact, HIO_NULL);
pthread_mutex_lock (&g_htts_mutex);
for (i = 0; i < g_num_thrs; i++)
{
if (g_htts[i]) hio_stop (hio_svc_htts_gethio(g_htts[i]), HIO_STOPREQ_TERMINATION);
}
pthread_mutex_unlock (&g_htts_mutex);
for (i = 0; i < g_num_thrs; i++)
{
pthread_join (t[i], HIO_NULL);
}
if (hio) hio_close (hio);
return xret;
}

420
bin/te.c Normal file
View File

@ -0,0 +1,420 @@
/* minimal terminal emulator - based on eduterm (https://www.uninformativ.de/git/eduterm/file/README.html) */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <ctype.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <hio-shw.h>
#include <hio-pty.h>
struct X11
{
int fd;
Display *dpy;
int screen;
Window root;
Window termwin;
GC termgc;
unsigned long col_fg, col_bg;
int w, h;
XFontStruct *xfont;
int font_width, font_height;
char *buf;
int buf_w, buf_h;
int buf_x, buf_y;
};
struct pair_t
{
struct X11* x11;
hio_syshnd_t pty;
};
#if 0
int term_set_size(struct PTY *pty, struct X11 *x11)
{
struct winsize ws = {
.ws_col = x11->buf_w,
.ws_row = x11->buf_h,
};
/* This is the very same ioctl that normal programs use to query the
* window size. Normal programs are actually able to do this, too,
* but it makes little sense: Setting the size has no effect on the
* PTY driver in the kernel (it just keeps a record of it) or the
* terminal emulator. IIUC, all that's happening is that subsequent
* ioctls will report the new size -- until another ioctl sets a new
* size.
*
* I didn't see any response to ioctls of normal programs in any of
* the popular terminals (XTerm, VTE, st). They are not informed by
* the kernel when a normal program issues an ioctl like that.
*
* On the other hand, if we were to issue this ioctl during runtime
* and the size actually changed, child programs would get a
* SIGWINCH. */
if (ioctl(pty->master, TIOCSWINSZ, &ws) == -1)
{
perror("ioctl(TIOCSWINSZ)");
return 0;
}
return 1;
}
#endif
void x11_key (XKeyEvent *ev, struct X11* x11, int pty_fd)
{
char buf[32];
KeySym ksym;
int len;
len = XLookupString(ev, buf, HIO_SIZEOF(buf), &ksym, 0);
if (len > 0) write (pty_fd, buf, len);
}
void x11_redraw(struct X11 *x11)
{
int x, y;
char buf[1];
XSetForeground(x11->dpy, x11->termgc, x11->col_bg);
XFillRectangle(x11->dpy, x11->termwin, x11->termgc, 0, 0, x11->w, x11->h);
XSetForeground(x11->dpy, x11->termgc, x11->col_fg);
for (y = 0; y < x11->buf_h; y++)
{
#if 0
for (x = 0; x < x11->buf_w; x++)
{
buf[0] = x11->buf[y * x11->buf_w + x];
if (!iscntrl(buf[0]))
{
XDrawString(x11->dpy, x11->termwin, x11->termgc,
x * x11->font_width,
y * x11->font_height + x11->xfont->ascent,
buf, 1);
}
}
#else
XDrawString(x11->dpy, x11->termwin, x11->termgc,
0 * x11->font_width,
y * x11->font_height + x11->xfont->ascent,
&x11->buf[y * x11->buf_w], x11->buf_w);
#endif
}
/* draw a cursor */
XSetForeground(x11->dpy, x11->termgc, x11->col_fg);
XFillRectangle(x11->dpy, x11->termwin, x11->termgc,
x11->buf_x * x11->font_width,
x11->buf_y * x11->font_height,
x11->font_width, x11->font_height);
XSync(x11->dpy, False);
//XFlush (x11->dpy);
}
int x11_setup(struct X11 *x11)
{
Colormap cmap;
XColor color;
XSetWindowAttributes wa = {
.background_pixmap = ParentRelative,
.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask,
};
x11->dpy = XOpenDisplay(NULL);
if (x11->dpy == NULL)
{
fprintf(stderr, "Cannot open display\n");
return -1;
}
x11->screen = DefaultScreen(x11->dpy);
x11->root = RootWindow(x11->dpy, x11->screen);
x11->fd = ConnectionNumber(x11->dpy);
x11->xfont = XLoadQueryFont(x11->dpy, "fixed");
if (x11->xfont == NULL)
{
fprintf(stderr, "Could not load font\n");
return -1;
}
x11->font_width = XTextWidth(x11->xfont, "m", 1);
x11->font_height = x11->xfont->ascent + x11->xfont->descent;
cmap = DefaultColormap(x11->dpy, x11->screen);
if (!XAllocNamedColor(x11->dpy, cmap, "#000000", &color, &color))
{
fprintf(stderr, "Could not load bg color\n");
return -1;
}
x11->col_bg = color.pixel;
if (!XAllocNamedColor(x11->dpy, cmap, "#aaaaaa", &color, &color))
{
fprintf(stderr, "Could not load fg color\n");
return -1;
}
x11->col_fg = color.pixel;
/* The terminal will have a fixed size of 80x25 cells. This is an
* arbitrary number. No resizing has been implemented and child
* processes can't even ask us for the current size (for now).
*
* buf_x, buf_y will be the current cursor position. */
x11->buf_w = 80;
x11->buf_h = 25;
x11->buf_x = 0;
x11->buf_y = 0;
x11->buf = malloc(x11->buf_w * x11->buf_h);
if (x11->buf == NULL)
{
perror("calloc");
return -1;
}
memset (x11->buf, ' ', x11->buf_w * x11->buf_h);
x11->w = x11->buf_w * x11->font_width;
x11->h = x11->buf_h * x11->font_height;
x11->termwin = XCreateWindow(x11->dpy, x11->root,
0, 0,
x11->w, x11->h,
0,
DefaultDepth(x11->dpy, x11->screen),
CopyFromParent,
DefaultVisual(x11->dpy, x11->screen),
CWBackPixmap | CWEventMask,
&wa);
XStoreName(x11->dpy, x11->termwin, "et");
XMapWindow(x11->dpy, x11->termwin);
x11->termgc = XCreateGC(x11->dpy, x11->termwin, 0, NULL);
XSync(x11->dpy, False);
return 0;
}
void x11_cleanup (struct X11* x11)
{
XFreeGC (x11->dpy, x11->termgc);
XDestroyWindow (x11->dpy, x11->termwin);
XFreeFont (x11->dpy, x11->xfont);
XCloseDisplay (x11->dpy);
free (x11->buf);
}
int pty_on_read (hio_dev_pty_t* dev, const void* data, hio_iolen_t len)
{
hio_iolen_t x;
const hio_uint8_t* buf = (const hio_uint8_t*)data;
int just_wrapped = 0;
struct pair_t* p = hio_dev_pty_getxtn(dev);
struct X11* x11 = p->x11;
for (x = 0; x < len; x++)
{
if (buf[x] == '\r')
{
x11->buf_x = 0;
}
else if (buf[x] == '\b')
{
if(x11->buf_x > 0)
{
x11->buf[x11->buf_y * x11->buf_w + x11->buf_x] = ' ';
x11->buf_x--;
}
}
else if (buf[x] == '\7')
{
/* beep */
}
else
{
if (buf[x] != '\n')
{
/* If this is a regular byte, store it and advance
* the cursor one cell "to the right". This might
* actually wrap to the next line, see below. */
x11->buf[x11->buf_y * x11->buf_w + x11->buf_x] = buf[x];
x11->buf_x++;
if (x11->buf_x >= x11->buf_w)
{
x11->buf_x = 0;
x11->buf_y++;
just_wrapped = 1;
}
else
just_wrapped = 0;
}
else if (!just_wrapped)
{
/* We read a newline and we did *not* implicitly
* wrap to the next line with the last byte we read.
* This means we must *now* advance to the next
* line.
*
* This is the same behaviour that most other
* terminals have: If you print a full line and then
* a newline, they "ignore" that newline. (Just
* think about it: A full line of text could always
* wrap to the next line implicitly, so that
* additional newline could cause the cursor to jump
* to the next line *again*.) */
x11->buf_y++;
just_wrapped = 0;
}
/* We now check if "the next line" is actually outside
* of the buffer. If it is, we shift the entire content
* one line up and then stay in the very last line.
*
* After the memmove(), the last line still has the old
* content. We must clear it. */
if (x11->buf_y >= x11->buf_h)
{
int i;
memmove(x11->buf, &x11->buf[x11->buf_w], x11->buf_w * (x11->buf_h - 1));
x11->buf_y = x11->buf_h - 1;
for (i = 0; i < x11->buf_w; i++) x11->buf[x11->buf_y * x11->buf_w + i] = ' ';
}
}
}
x11_redraw (x11);
return 0;
}
int pty_on_write (hio_dev_pty_t* dev, hio_iolen_t wrlen, void* wrctx)
{
return 0;
}
void pty_on_close (hio_dev_pty_t* dev)
{
printf (">> pty closed....\n");
hio_stop (hio_dev_pty_gethio(dev), HIO_STOPREQ_TERMINATION);
}
int shw_on_ready (hio_dev_shw_t* dev, int events)
{
struct pair_t* p = hio_dev_shw_getxtn(dev);
struct X11* x11 = p->x11;
/* consume data here beforehand. don't let the hio loop
* read the data */
XEvent ev;
while (XPending(x11->dpy))
{
XNextEvent(x11->dpy, &ev);
switch (ev.type)
{
case Expose:
x11_redraw (x11);
break;
case KeyPress:
x11_key (&ev.xkey, x11, p->pty);
break;
}
}
/* no output via hio on the x11 connection. so let's not care about it. */
return 0; /* don't invoke the read method */
}
int shw_on_read (hio_dev_shw_t* dev, const void* data, hio_iolen_t len)
{
return 0;
}
int shw_on_write (hio_dev_shw_t* dev, hio_iolen_t wrlen, void* wrctx)
{
return 0;
}
void shw_on_close (hio_dev_shw_t* dev)
{
printf (">> shw closed....\n");
}
int main()
{
hio_t* hio = HIO_NULL;
struct X11 x11;
hio_dev_pty_t* pty;
hio_dev_shw_t* shw;
hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 512, HIO_NULL);
if (!hio)
{
printf ("Cannot open hio\n");
return -1;
}
hio_setoption (hio, HIO_LOG_TARGET_BCSTR, "/dev/stderr");
if (x11_setup(&x11) <= -1) return -1;
{
hio_dev_pty_make_t pi;
struct pair_t* pair;
memset (&pi, 0, HIO_SIZEOF(pi));
pi.cmd = "/bin/ksh";
pi.flags = 0;
pi.on_write = pty_on_write;
pi.on_read = pty_on_read;
pi.on_close = pty_on_close;
pty = hio_dev_pty_make(hio, HIO_SIZEOF(*pair), &pi);
pair = hio_dev_pty_getxtn(pty);
pair->x11 = &x11;
pair->pty = hio_dev_pty_getsyshnd(pty);
/*
if (!term_set_size(&pty, &x11))
return 1;
*/
}
{
hio_dev_shw_make_t si;
struct pair_t* pair;
memset (&si, 0, HIO_SIZEOF(si));
si.hnd = ConnectionNumber(x11.dpy);
si.flags = HIO_DEV_SHW_KEEP_OPEN_ON_CLOSE | HIO_DEV_SHW_DISABLE_OUT | HIO_DEV_SHW_DISABLE_STREAM;
si.on_ready = shw_on_ready;
si.on_write = shw_on_write;
si.on_read = shw_on_read;
si.on_close = shw_on_close;
shw = hio_dev_shw_make(hio, HIO_SIZEOF(*pair), &si);
pair = hio_dev_shw_getxtn(shw);
pair->x11 = &x11;
pair->pty = hio_dev_pty_getsyshnd(pty);
}
hio_loop (hio);
if (hio) hio_close (hio);
x11_cleanup (&x11);
return 0;
}