added the bin directory and moves files for binary commands into it
This commit is contained in:
58
bin/Makefile.am
Normal file
58
bin/Makefile.am
Normal file
@ -0,0 +1,58 @@
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
|
||||
CPPFLAGS_ALL_COMMON = \
|
||||
-I$(abs_builddir) \
|
||||
-I$(abs_builddir)/../lib \
|
||||
-I$(abs_srcdir) \
|
||||
-I$(abs_srcdir)/../lib \
|
||||
-I$(includedir)
|
||||
|
||||
LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(abs_builddir)/../lib -L$(libdir)
|
||||
|
||||
##################################################
|
||||
# MAIN LIBRARY
|
||||
##################################################
|
||||
|
||||
CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) $(LTDLINCL)
|
||||
LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
|
||||
LIBADD_LIB_COMMON = $(LIBM)
|
||||
|
||||
if ENABLE_LIBLTDL
|
||||
LIBADD_LIB_COMMON += $(LTDL_LIBS)
|
||||
else
|
||||
LIBADD_LIB_COMMON += $(DL_LIBS)
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = hcl
|
||||
hcl_SOURCES = main.c ../lib/cb-impl.h ../lib/cb-impl.c
|
||||
hcl_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_PFMOD)
|
||||
hcl_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
hcl_LDADD = $(LIBADD_LIB_COMMON) -lhcl
|
||||
hcl_DEPENDENCIES = ../lib/libhcl.la
|
||||
|
||||
if ENABLE_HCLEX
|
||||
|
||||
## cb-impl.c is included in libhclex.
|
||||
## so ../lib/cb-impl.h and ../lib/cb-impl.c are not listed as sources
|
||||
|
||||
bin_PROGRAMS += hcls
|
||||
hcls_SOURCES = main-s.c
|
||||
hcls_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
hcls_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
hcls_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
hcls_DEPENDENCIES = ../lib/libhclex.la
|
||||
|
||||
bin_PROGRAMS += hclc
|
||||
hclc_SOURCES = main-c.c
|
||||
hclc_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
hclc_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
hclc_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
hclc_DEPENDENCIES = ../lib/libhclex.la
|
||||
|
||||
bin_PROGRAMS += hclj
|
||||
hclj_SOURCES = main-j.c
|
||||
hclj_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
hclj_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
hclj_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
hclj_DEPENDENCIES = ../lib/libhclex.la
|
||||
endif
|
831
bin/Makefile.in
Normal file
831
bin/Makefile.in
Normal file
@ -0,0 +1,831 @@
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2014 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@
|
||||
@ENABLE_LIBLTDL_TRUE@am__append_1 = $(LTDL_LIBS)
|
||||
@ENABLE_LIBLTDL_FALSE@am__append_2 = $(DL_LIBS)
|
||||
bin_PROGRAMS = hcl$(EXEEXT) $(am__EXEEXT_1)
|
||||
@ENABLE_HCLEX_TRUE@am__append_3 = hcls hclc hclj
|
||||
subdir = bin
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
||||
$(top_srcdir)/m4/ax_cxx_namespace.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/hcl-cfg.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
@ENABLE_HCLEX_TRUE@am__EXEEXT_1 = hcls$(EXEEXT) hclc$(EXEEXT) \
|
||||
@ENABLE_HCLEX_TRUE@ hclj$(EXEEXT)
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am__dirstamp = $(am__leading_dot)dirstamp
|
||||
am_hcl_OBJECTS = hcl-main.$(OBJEXT) ../lib/hcl-cb-impl.$(OBJEXT)
|
||||
hcl_OBJECTS = $(am_hcl_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
@ENABLE_LIBLTDL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||
@ENABLE_LIBLTDL_FALSE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
|
||||
am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
|
||||
$(am__DEPENDENCIES_3)
|
||||
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 =
|
||||
hcl_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(hcl_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am__hclc_SOURCES_DIST = main-c.c
|
||||
@ENABLE_HCLEX_TRUE@am_hclc_OBJECTS = hclc-main-c.$(OBJEXT)
|
||||
hclc_OBJECTS = $(am_hclc_OBJECTS)
|
||||
hclc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(hclc_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am__hclj_SOURCES_DIST = main-j.c
|
||||
@ENABLE_HCLEX_TRUE@am_hclj_OBJECTS = hclj-main-j.$(OBJEXT)
|
||||
hclj_OBJECTS = $(am_hclj_OBJECTS)
|
||||
hclj_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(hclj_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am__hcls_SOURCES_DIST = main-s.c
|
||||
@ENABLE_HCLEX_TRUE@am_hcls_OBJECTS = hcls-main-s.$(OBJEXT)
|
||||
hcls_OBJECTS = $(am_hcls_OBJECTS)
|
||||
hcls_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(hcls_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__depfiles_maybe = depfiles
|
||||
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 = $(hcl_SOURCES) $(hclc_SOURCES) $(hclj_SOURCES) \
|
||||
$(hcls_SOURCES)
|
||||
DIST_SOURCES = $(hcl_SOURCES) $(am__hclc_SOURCES_DIST) \
|
||||
$(am__hclj_SOURCES_DIST) $(am__hcls_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@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DL_LIBS = @DL_LIBS@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_CXX = @HAVE_CXX@
|
||||
HCL_PROJECT_AUTHOR = @HCL_PROJECT_AUTHOR@
|
||||
HCL_PROJECT_URL = @HCL_PROJECT_URL@
|
||||
HCL_SIZEOF_CHAR = @HCL_SIZEOF_CHAR@
|
||||
HCL_SIZEOF_CHAR16_T = @HCL_SIZEOF_CHAR16_T@
|
||||
HCL_SIZEOF_CHAR32_T = @HCL_SIZEOF_CHAR32_T@
|
||||
HCL_SIZEOF_DOUBLE = @HCL_SIZEOF_DOUBLE@
|
||||
HCL_SIZEOF_FLOAT = @HCL_SIZEOF_FLOAT@
|
||||
HCL_SIZEOF_INT = @HCL_SIZEOF_INT@
|
||||
HCL_SIZEOF_LONG = @HCL_SIZEOF_LONG@
|
||||
HCL_SIZEOF_LONG_DOUBLE = @HCL_SIZEOF_LONG_DOUBLE@
|
||||
HCL_SIZEOF_LONG_LONG = @HCL_SIZEOF_LONG_LONG@
|
||||
HCL_SIZEOF_OFF64_T = @HCL_SIZEOF_OFF64_T@
|
||||
HCL_SIZEOF_OFF_T = @HCL_SIZEOF_OFF_T@
|
||||
HCL_SIZEOF_SHORT = @HCL_SIZEOF_SHORT@
|
||||
HCL_SIZEOF_VOID_P = @HCL_SIZEOF_VOID_P@
|
||||
HCL_SIZEOF_WCHAR_T = @HCL_SIZEOF_WCHAR_T@
|
||||
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@
|
||||
LTDL_LIBS = @LTDL_LIBS@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
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@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
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_CXX = @ac_ct_CXX@
|
||||
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@
|
||||
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_ALL_COMMON = \
|
||||
-I$(abs_builddir) \
|
||||
-I$(abs_builddir)/../lib \
|
||||
-I$(abs_srcdir) \
|
||||
-I$(abs_srcdir)/../lib \
|
||||
-I$(includedir)
|
||||
|
||||
LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(abs_builddir)/../lib -L$(libdir)
|
||||
|
||||
##################################################
|
||||
# MAIN LIBRARY
|
||||
##################################################
|
||||
CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) $(LTDLINCL)
|
||||
LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
|
||||
LIBADD_LIB_COMMON = $(LIBM) $(am__append_1) $(am__append_2)
|
||||
hcl_SOURCES = main.c ../lib/cb-impl.h ../lib/cb-impl.c
|
||||
hcl_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_PFMOD)
|
||||
hcl_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
hcl_LDADD = $(LIBADD_LIB_COMMON) -lhcl
|
||||
hcl_DEPENDENCIES = ../lib/libhcl.la
|
||||
@ENABLE_HCLEX_TRUE@hcls_SOURCES = main-s.c
|
||||
@ENABLE_HCLEX_TRUE@hcls_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hcls_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hcls_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
@ENABLE_HCLEX_TRUE@hcls_DEPENDENCIES = ../lib/libhclex.la
|
||||
@ENABLE_HCLEX_TRUE@hclc_SOURCES = main-c.c
|
||||
@ENABLE_HCLEX_TRUE@hclc_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hclc_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hclc_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
@ENABLE_HCLEX_TRUE@hclc_DEPENDENCIES = ../lib/libhclex.la
|
||||
@ENABLE_HCLEX_TRUE@hclj_SOURCES = main-j.c
|
||||
@ENABLE_HCLEX_TRUE@hclj_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hclj_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||
@ENABLE_HCLEX_TRUE@hclj_LDADD = $(LIBADD_LIB_COMMON) $(PTHREAD_LIBS) -lhcl -lhclex
|
||||
@ENABLE_HCLEX_TRUE@hclj_DEPENDENCIES = ../lib/libhclex.la
|
||||
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__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
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
|
||||
../lib/$(am__dirstamp):
|
||||
@$(MKDIR_P) ../lib
|
||||
@: > ../lib/$(am__dirstamp)
|
||||
../lib/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) ../lib/$(DEPDIR)
|
||||
@: > ../lib/$(DEPDIR)/$(am__dirstamp)
|
||||
../lib/hcl-cb-impl.$(OBJEXT): ../lib/$(am__dirstamp) \
|
||||
../lib/$(DEPDIR)/$(am__dirstamp)
|
||||
|
||||
hcl$(EXEEXT): $(hcl_OBJECTS) $(hcl_DEPENDENCIES) $(EXTRA_hcl_DEPENDENCIES)
|
||||
@rm -f hcl$(EXEEXT)
|
||||
$(AM_V_CCLD)$(hcl_LINK) $(hcl_OBJECTS) $(hcl_LDADD) $(LIBS)
|
||||
|
||||
hclc$(EXEEXT): $(hclc_OBJECTS) $(hclc_DEPENDENCIES) $(EXTRA_hclc_DEPENDENCIES)
|
||||
@rm -f hclc$(EXEEXT)
|
||||
$(AM_V_CCLD)$(hclc_LINK) $(hclc_OBJECTS) $(hclc_LDADD) $(LIBS)
|
||||
|
||||
hclj$(EXEEXT): $(hclj_OBJECTS) $(hclj_DEPENDENCIES) $(EXTRA_hclj_DEPENDENCIES)
|
||||
@rm -f hclj$(EXEEXT)
|
||||
$(AM_V_CCLD)$(hclj_LINK) $(hclj_OBJECTS) $(hclj_LDADD) $(LIBS)
|
||||
|
||||
hcls$(EXEEXT): $(hcls_OBJECTS) $(hcls_DEPENDENCIES) $(EXTRA_hcls_DEPENDENCIES)
|
||||
@rm -f hcls$(EXEEXT)
|
||||
$(AM_V_CCLD)$(hcls_LINK) $(hcls_OBJECTS) $(hcls_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
-rm -f ../lib/*.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@../lib/$(DEPDIR)/hcl-cb-impl.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcl-main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclc-main-c.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclj-main-j.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcls-main-s.Po@am__quote@
|
||||
|
||||
.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 $@ $<
|
||||
|
||||
hcl-main.o: main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcl-main.o -MD -MP -MF $(DEPDIR)/hcl-main.Tpo -c -o hcl-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcl-main.Tpo $(DEPDIR)/hcl-main.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='hcl-main.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) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcl-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
|
||||
|
||||
hcl-main.obj: main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcl-main.obj -MD -MP -MF $(DEPDIR)/hcl-main.Tpo -c -o hcl-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcl-main.Tpo $(DEPDIR)/hcl-main.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='hcl-main.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) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcl-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
|
||||
|
||||
../lib/hcl-cb-impl.o: ../lib/cb-impl.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ../lib/hcl-cb-impl.o -MD -MP -MF ../lib/$(DEPDIR)/hcl-cb-impl.Tpo -c -o ../lib/hcl-cb-impl.o `test -f '../lib/cb-impl.c' || echo '$(srcdir)/'`../lib/cb-impl.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/$(DEPDIR)/hcl-cb-impl.Tpo ../lib/$(DEPDIR)/hcl-cb-impl.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/cb-impl.c' object='../lib/hcl-cb-impl.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) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ../lib/hcl-cb-impl.o `test -f '../lib/cb-impl.c' || echo '$(srcdir)/'`../lib/cb-impl.c
|
||||
|
||||
../lib/hcl-cb-impl.obj: ../lib/cb-impl.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ../lib/hcl-cb-impl.obj -MD -MP -MF ../lib/$(DEPDIR)/hcl-cb-impl.Tpo -c -o ../lib/hcl-cb-impl.obj `if test -f '../lib/cb-impl.c'; then $(CYGPATH_W) '../lib/cb-impl.c'; else $(CYGPATH_W) '$(srcdir)/../lib/cb-impl.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../lib/$(DEPDIR)/hcl-cb-impl.Tpo ../lib/$(DEPDIR)/hcl-cb-impl.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../lib/cb-impl.c' object='../lib/hcl-cb-impl.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) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ../lib/hcl-cb-impl.obj `if test -f '../lib/cb-impl.c'; then $(CYGPATH_W) '../lib/cb-impl.c'; else $(CYGPATH_W) '$(srcdir)/../lib/cb-impl.c'; fi`
|
||||
|
||||
hclc-main-c.o: main-c.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclc-main-c.o -MD -MP -MF $(DEPDIR)/hclc-main-c.Tpo -c -o hclc-main-c.o `test -f 'main-c.c' || echo '$(srcdir)/'`main-c.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclc-main-c.Tpo $(DEPDIR)/hclc-main-c.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-c.c' object='hclc-main-c.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) $(hclc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclc-main-c.o `test -f 'main-c.c' || echo '$(srcdir)/'`main-c.c
|
||||
|
||||
hclc-main-c.obj: main-c.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclc-main-c.obj -MD -MP -MF $(DEPDIR)/hclc-main-c.Tpo -c -o hclc-main-c.obj `if test -f 'main-c.c'; then $(CYGPATH_W) 'main-c.c'; else $(CYGPATH_W) '$(srcdir)/main-c.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclc-main-c.Tpo $(DEPDIR)/hclc-main-c.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-c.c' object='hclc-main-c.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) $(hclc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclc-main-c.obj `if test -f 'main-c.c'; then $(CYGPATH_W) 'main-c.c'; else $(CYGPATH_W) '$(srcdir)/main-c.c'; fi`
|
||||
|
||||
hclj-main-j.o: main-j.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclj-main-j.o -MD -MP -MF $(DEPDIR)/hclj-main-j.Tpo -c -o hclj-main-j.o `test -f 'main-j.c' || echo '$(srcdir)/'`main-j.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclj-main-j.Tpo $(DEPDIR)/hclj-main-j.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-j.c' object='hclj-main-j.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) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclj-main-j.o `test -f 'main-j.c' || echo '$(srcdir)/'`main-j.c
|
||||
|
||||
hclj-main-j.obj: main-j.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclj-main-j.obj -MD -MP -MF $(DEPDIR)/hclj-main-j.Tpo -c -o hclj-main-j.obj `if test -f 'main-j.c'; then $(CYGPATH_W) 'main-j.c'; else $(CYGPATH_W) '$(srcdir)/main-j.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclj-main-j.Tpo $(DEPDIR)/hclj-main-j.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-j.c' object='hclj-main-j.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) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclj-main-j.obj `if test -f 'main-j.c'; then $(CYGPATH_W) 'main-j.c'; else $(CYGPATH_W) '$(srcdir)/main-j.c'; fi`
|
||||
|
||||
hcls-main-s.o: main-s.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcls_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcls-main-s.o -MD -MP -MF $(DEPDIR)/hcls-main-s.Tpo -c -o hcls-main-s.o `test -f 'main-s.c' || echo '$(srcdir)/'`main-s.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcls-main-s.Tpo $(DEPDIR)/hcls-main-s.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-s.c' object='hcls-main-s.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) $(hcls_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcls-main-s.o `test -f 'main-s.c' || echo '$(srcdir)/'`main-s.c
|
||||
|
||||
hcls-main-s.obj: main-s.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcls_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcls-main-s.obj -MD -MP -MF $(DEPDIR)/hcls-main-s.Tpo -c -o hcls-main-s.obj `if test -f 'main-s.c'; then $(CYGPATH_W) 'main-s.c'; else $(CYGPATH_W) '$(srcdir)/main-s.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcls-main-s.Tpo $(DEPDIR)/hcls-main-s.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-s.c' object='hcls-main-s.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) $(hcls_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcls-main-s.obj `if test -f 'main-s.c'; then $(CYGPATH_W) 'main-s.c'; else $(CYGPATH_W) '$(srcdir)/main-s.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: $(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)
|
||||
-rm -f ../lib/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f ../lib/$(am__dirstamp)
|
||||
|
||||
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 -rf ../lib/$(DEPDIR) ./$(DEPDIR)
|
||||
-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 -rf ../lib/$(DEPDIR) ./$(DEPDIR)
|
||||
-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 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:
|
859
bin/main-c.c
Normal file
859
bin/main-c.c
Normal file
@ -0,0 +1,859 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2016-2018 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 WARRANTIES
|
||||
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 "hcl-c.h"
|
||||
#include "hcl-opt.h"
|
||||
#include "hcl-utl.h"
|
||||
#include "hcl-xutl.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
|
||||
#if defined(HAVE_TIME_H)
|
||||
# include <time.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#if defined(HAVE_SIGNAL_H)
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_UIO_H)
|
||||
# include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
typedef struct client_xtn_t client_xtn_t;
|
||||
struct client_xtn_t
|
||||
{
|
||||
int logfd;
|
||||
hcl_bitmask_t logmask;
|
||||
int logfd_istty;
|
||||
|
||||
struct
|
||||
{
|
||||
hcl_bch_t buf[4096];
|
||||
hcl_oow_t len;
|
||||
} logbuf;
|
||||
|
||||
int reply_count;
|
||||
hcl_oow_t data_length;
|
||||
};
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static void* sys_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void* sys_realloc (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void sys_free (hcl_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
static hcl_mmgr_t sys_mmgr =
|
||||
{
|
||||
sys_alloc,
|
||||
sys_realloc,
|
||||
sys_free,
|
||||
HCL_NULL
|
||||
};
|
||||
/* ========================================================================= */
|
||||
|
||||
static int write_all (int fd, const hcl_bch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
hcl_ooi_t wr;
|
||||
|
||||
wr = write(fd, ptr, len);
|
||||
|
||||
if (wr <= -1)
|
||||
{
|
||||
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN == EWOULDBLOCK)
|
||||
if (errno == EAGAIN) continue;
|
||||
#else
|
||||
#if defined(EAGAIN)
|
||||
if (errno == EAGAIN) continue;
|
||||
#elif defined(EWOULDBLOCK)
|
||||
if (errno == EWOULDBLOCK) continue;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(EINTR)
|
||||
/* TODO: would this interfere with non-blocking nature of this VM? */
|
||||
if (errno == EINTR) continue;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr += wr;
|
||||
len -= wr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int write_log (hcl_client_t* client, int fd, const hcl_bch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
client_xtn_t* xtn;
|
||||
|
||||
|
||||
xtn = hcl_client_getxtn(client);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
if (xtn->logbuf.len > 0)
|
||||
{
|
||||
hcl_oow_t rcapa, cplen;
|
||||
|
||||
rcapa = HCL_COUNTOF(xtn->logbuf.buf) - xtn->logbuf.len;
|
||||
cplen = (len >= rcapa)? rcapa: len;
|
||||
|
||||
memcpy (&xtn->logbuf.buf[xtn->logbuf.len], ptr, cplen);
|
||||
xtn->logbuf.len += cplen;
|
||||
ptr += cplen;
|
||||
len -= cplen;
|
||||
|
||||
if (xtn->logbuf.len >= HCL_COUNTOF(xtn->logbuf.buf))
|
||||
{
|
||||
write_all(fd, xtn->logbuf.buf, xtn->logbuf.len);
|
||||
xtn->logbuf.len = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_oow_t rcapa;
|
||||
|
||||
rcapa = HCL_COUNTOF(xtn->logbuf.buf);
|
||||
if (len >= rcapa)
|
||||
{
|
||||
write_all (fd, ptr, rcapa);
|
||||
ptr += rcapa;
|
||||
len -= rcapa;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (xtn->logbuf.buf, ptr, len);
|
||||
xtn->logbuf.len += len;
|
||||
ptr += len;
|
||||
len -= len;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void flush_log (hcl_client_t* client, int fd)
|
||||
{
|
||||
client_xtn_t* xtn;
|
||||
xtn = hcl_client_getxtn(client);
|
||||
if (xtn->logbuf.len > 0)
|
||||
{
|
||||
write_all (fd, xtn->logbuf.buf, xtn->logbuf.len);
|
||||
xtn->logbuf.len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void log_write (hcl_client_t* client, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
client_xtn_t* xtn;
|
||||
hcl_oow_t msgidx;
|
||||
int n, logfd;
|
||||
|
||||
xtn = hcl_client_getxtn(client);
|
||||
|
||||
if (mask & HCL_LOG_STDERR)
|
||||
{
|
||||
/* the messages that go to STDERR don't get masked out */
|
||||
logfd = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(xtn->logmask & mask & ~HCL_LOG_ALL_LEVELS)) return; /* check log types */
|
||||
if (!(xtn->logmask & mask & ~HCL_LOG_ALL_TYPES)) return; /* check log levels */
|
||||
|
||||
if (mask & HCL_LOG_STDOUT) logfd = 1;
|
||||
else
|
||||
{
|
||||
logfd = xtn->logfd;
|
||||
if (logfd <= -1) return;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: beautify the log message.
|
||||
* do classification based on mask. */
|
||||
if (!(mask & (HCL_LOG_STDOUT | HCL_LOG_STDERR)))
|
||||
{
|
||||
time_t now;
|
||||
char ts[32];
|
||||
size_t tslen;
|
||||
struct tm tm, *tmp;
|
||||
|
||||
now = time(NULL);
|
||||
|
||||
#if defined(__OS2__)
|
||||
tmp = _localtime(&now, &tm);
|
||||
#elif defined(HAVE_LOCALTIME_R)
|
||||
tmp = localtime_r(&now, &tm);
|
||||
#else
|
||||
tmp = localtime(&now);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STRFTIME_SMALL_Z)
|
||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||
#else
|
||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
||||
#endif
|
||||
if (tslen == 0)
|
||||
{
|
||||
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
||||
tslen = 25;
|
||||
}
|
||||
|
||||
write_log (client, logfd, ts, tslen);
|
||||
}
|
||||
|
||||
if (logfd == xtn->logfd && xtn->logfd_istty)
|
||||
{
|
||||
if (mask & HCL_LOG_FATAL) write_log (client, logfd, "\x1B[1;31m", 7);
|
||||
else if (mask & HCL_LOG_ERROR) write_log (client, logfd, "\x1B[1;32m", 7);
|
||||
else if (mask & HCL_LOG_WARN) write_log (client, logfd, "\x1B[1;33m", 7);
|
||||
}
|
||||
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
msgidx = 0;
|
||||
while (len > 0)
|
||||
{
|
||||
ucslen = len;
|
||||
bcslen = HCL_COUNTOF(buf);
|
||||
|
||||
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
||||
if (n == 0 || n == -2)
|
||||
{
|
||||
/* n = 0:
|
||||
* converted all successfully
|
||||
* n == -2:
|
||||
* buffer not sufficient. not all got converted yet.
|
||||
* write what have been converted this round. */
|
||||
|
||||
/*HCL_ASSERT (hcl, ucslen > 0); */ /* if this fails, the buffer size must be increased */
|
||||
/*assert (ucslen > 0);*/
|
||||
|
||||
/* attempt to write all converted characters */
|
||||
if (write_log(client, logfd, buf, bcslen) <= -1) break;
|
||||
|
||||
if (n == 0) break;
|
||||
else
|
||||
{
|
||||
msgidx += ucslen;
|
||||
len -= ucslen;
|
||||
}
|
||||
}
|
||||
else if (n <= -1)
|
||||
{
|
||||
/* conversion error */
|
||||
if (bcslen <= 0) break;
|
||||
if (write_log(client, logfd, buf, bcslen) <= -1) break;
|
||||
msgidx += ucslen;
|
||||
len -= ucslen;
|
||||
}
|
||||
}
|
||||
#else
|
||||
write_log (client, logfd, msg, len);
|
||||
#endif
|
||||
|
||||
if (logfd == xtn->logfd && xtn->logfd_istty)
|
||||
{
|
||||
if (mask & (HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN)) write_log (client, logfd, "\x1B[0m", 4);
|
||||
}
|
||||
|
||||
flush_log (client, logfd);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static hcl_client_t* g_client = HCL_NULL;
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
typedef void (*signal_handler_t) (int, siginfo_t*, void*);
|
||||
|
||||
static void handle_sigint (int sig, siginfo_t* siginfo, void* ctx)
|
||||
{
|
||||
/*if (g_client) hcl_client_stop (g_client);*/
|
||||
}
|
||||
|
||||
static void set_signal (int sig, signal_handler_t handler)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
memset (&sa, 0, sizeof(sa));
|
||||
/*sa.sa_handler = handler;*/
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sa.sa_sigaction = handler;
|
||||
sigemptyset (&sa.sa_mask);
|
||||
|
||||
sigaction (sig, &sa, NULL);
|
||||
}
|
||||
|
||||
static void set_signal_to_ignore (int sig)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
memset (&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sa.sa_flags = 0;
|
||||
sigemptyset (&sa.sa_mask);
|
||||
|
||||
sigaction (sig, &sa, NULL);
|
||||
}
|
||||
|
||||
static void set_signal_to_default (int sig)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
memset (&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sa.sa_flags = 0;
|
||||
sigemptyset (&sa.sa_mask);
|
||||
|
||||
sigaction (sig, &sa, NULL);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static int handle_logopt (hcl_client_t* client, const hcl_bch_t* str)
|
||||
{
|
||||
hcl_bch_t* xstr = (hcl_bch_t*)str;
|
||||
hcl_bch_t* cm, * flt;
|
||||
hcl_bitmask_t logmask;
|
||||
client_xtn_t* xtn;
|
||||
|
||||
xtn = (client_xtn_t*)hcl_client_getxtn(client);
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
||||
if (cm)
|
||||
{
|
||||
/* i duplicate this string for open() below as open() doesn't
|
||||
* accept a length-bounded string */
|
||||
xstr = strdup(str);
|
||||
if (!xstr)
|
||||
{
|
||||
fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
||||
*cm = '\0';
|
||||
|
||||
logmask = xtn->logmask;
|
||||
do
|
||||
{
|
||||
flt = cm + 1;
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr(flt, ',');
|
||||
if (cm) *cm = '\0';
|
||||
|
||||
if (hcl_comp_bcstr(flt, "app") == 0) logmask |= HCL_LOG_APP;
|
||||
else if (hcl_comp_bcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER;
|
||||
else if (hcl_comp_bcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM;
|
||||
else if (hcl_comp_bcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC;
|
||||
else if (hcl_comp_bcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC;
|
||||
else if (hcl_comp_bcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC;
|
||||
else if (hcl_comp_bcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE;
|
||||
|
||||
else if (hcl_comp_bcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL;
|
||||
else if (hcl_comp_bcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR;
|
||||
else if (hcl_comp_bcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN;
|
||||
else if (hcl_comp_bcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO;
|
||||
else if (hcl_comp_bcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG;
|
||||
|
||||
else if (hcl_comp_bcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL;
|
||||
else if (hcl_comp_bcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR;
|
||||
else if (hcl_comp_bcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN;
|
||||
else if (hcl_comp_bcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO;
|
||||
else if (hcl_comp_bcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG;
|
||||
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "ERROR: unknown log option value - %s\n", flt);
|
||||
if (str != xstr) free (xstr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (cm);
|
||||
|
||||
if (!(logmask & HCL_LOG_ALL_TYPES)) logmask |= HCL_LOG_ALL_TYPES; /* no types specified. force to all types */
|
||||
if (!(logmask & HCL_LOG_ALL_LEVELS)) logmask |= HCL_LOG_ALL_LEVELS; /* no levels specified. force to all levels */
|
||||
}
|
||||
else
|
||||
{
|
||||
logmask = HCL_LOG_ALL_LEVELS | HCL_LOG_ALL_TYPES;
|
||||
}
|
||||
|
||||
xtn->logfd = open(xstr, O_CREAT | O_WRONLY | O_APPEND , 0644);
|
||||
if (xtn->logfd == -1)
|
||||
{
|
||||
fprintf (stderr, "ERROR: cannot open a log file %s\n", xstr);
|
||||
if (str != xstr) free (xstr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
xtn->logmask = logmask;
|
||||
#if defined(HAVE_ISATTY)
|
||||
xtn->logfd_istty = isatty(xtn->logfd);
|
||||
#endif
|
||||
|
||||
if (str != xstr) free (xstr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int start_reply (hcl_client_t* client, hcl_client_reply_type_t type, const hcl_ooch_t* dptr, hcl_oow_t dlen)
|
||||
{
|
||||
client_xtn_t* client_xtn;
|
||||
client_xtn = hcl_client_getxtn(client);
|
||||
|
||||
if (client_xtn->reply_count > 0)
|
||||
{
|
||||
hcl_client_seterrbfmt (client, HCL_EFLOOD, "\n<<WARNING>> redundant reply received\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dptr)
|
||||
{
|
||||
/* short-form response - no end_reply will be called */
|
||||
if (type == HCL_CLIENT_REPLY_TYPE_ERROR)
|
||||
{
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
hcl_bch_t bcs[256];
|
||||
hcl_oow_t bcslen;
|
||||
|
||||
/* NOTE: the error may get truncated without looping */
|
||||
bcslen = HCL_COUNTOF(bcs);
|
||||
hcl_conv_uchars_to_bchars_with_cmgr (dptr, &dlen, bcs, &bcslen, hcl_client_getcmgr(client));
|
||||
printf ("\nERROR - [%.*s]\n", (int)bcslen, bcs);
|
||||
#else
|
||||
printf ("\nERROR - [%.*s]\n", (int)dlen, dptr);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
hcl_oow_t drem = dlen;
|
||||
while (drem > 0)
|
||||
{
|
||||
hcl_bch_t bcs[256];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
|
||||
ucslen = drem;
|
||||
bcslen = HCL_COUNTOF(bcs);
|
||||
hcl_conv_uchars_to_bchars_with_cmgr(dptr, &ucslen, bcs, &bcslen, hcl_client_getcmgr(client));
|
||||
client_xtn->data_length += bcslen;
|
||||
if (write_all(0, bcs, bcslen) <= -1)
|
||||
{
|
||||
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
drem -= ucslen;
|
||||
dptr += ucslen;
|
||||
}
|
||||
#else
|
||||
client_xtn->data_length += dlen;
|
||||
if (write_all(0, dptr, dlen) <= -1)
|
||||
{
|
||||
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
printf ("\nTOTAL DATA %lu bytes\n", (unsigned long int)client_xtn->data_length);
|
||||
|
||||
/*fflush (stdout);*/
|
||||
client_xtn->reply_count++;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* long-form response */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int end_reply (hcl_client_t* client, hcl_client_end_reply_state_t state)
|
||||
{
|
||||
client_xtn_t* client_xtn;
|
||||
client_xtn = hcl_client_getxtn(client);
|
||||
|
||||
if (state == HCL_CLIENT_END_REPLY_STATE_REVOKED)
|
||||
{
|
||||
/* nothing to do here */
|
||||
printf ("\n<<WARNING>> REPLY(%lu bytes) received so far has been revoked\n", (unsigned long int)client_xtn->data_length);
|
||||
client_xtn->data_length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
client_xtn->reply_count++;
|
||||
/*fflush (stdout);*/
|
||||
printf ("\nTOTAL DATA %lu bytes\n", (unsigned long int)client_xtn->data_length);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int feed_attr (hcl_client_t* client, const hcl_oocs_t* key, const hcl_oocs_t* val)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int feed_data (hcl_client_t* client, const void* ptr, hcl_oow_t len)
|
||||
{
|
||||
client_xtn_t* client_xtn;
|
||||
|
||||
client_xtn = hcl_client_getxtn(client);
|
||||
client_xtn->data_length += len;
|
||||
|
||||
if (write_all(0, ptr, len) <= -1)
|
||||
{
|
||||
hcl_client_seterrbfmt (client, HCL_EIOERR, "unable to write data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static int handle_request (hcl_client_t* client, const char* ipaddr, const char* script, int reuse_addr, int shut_wr_after_req)
|
||||
{
|
||||
hcl_sckaddr_t sckaddr;
|
||||
hcl_scklen_t scklen;
|
||||
int sckfam;
|
||||
int sck = -1;
|
||||
struct iovec iov[3];
|
||||
int index, count;
|
||||
|
||||
hcl_oow_t used, avail;
|
||||
int x;
|
||||
hcl_bch_t buf[256];
|
||||
ssize_t n;
|
||||
|
||||
client_xtn_t* client_xtn;
|
||||
|
||||
client_xtn = hcl_client_getxtn(client);
|
||||
|
||||
sckfam = hcl_bchars_to_sckaddr(ipaddr, strlen(ipaddr), &sckaddr, &scklen);
|
||||
if (sckfam <= -1)
|
||||
{
|
||||
fprintf (stderr, "cannot convert ip address - %s\n", ipaddr);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
sck = socket (sckfam, SOCK_STREAM, 0);
|
||||
if (sck <= -1)
|
||||
{
|
||||
fprintf (stderr, "cannot create a socket for %s - %s\n", ipaddr, strerror(errno));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (reuse_addr)
|
||||
{
|
||||
if (sckfam == AF_INET)
|
||||
{
|
||||
struct sockaddr_in anyaddr;
|
||||
int opt = 1;
|
||||
setsockopt(sck, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt));
|
||||
memset (&anyaddr, 0, HCL_SIZEOF(anyaddr));
|
||||
anyaddr.sin_family = sckfam;
|
||||
bind(sck, (struct sockaddr *)&anyaddr, scklen);
|
||||
}
|
||||
else if (sckfam == AF_INET6)
|
||||
{
|
||||
struct sockaddr_in6 anyaddr;
|
||||
int opt = 1;
|
||||
setsockopt(sck, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt));
|
||||
memset (&anyaddr, 0, HCL_SIZEOF(anyaddr));
|
||||
anyaddr.sin6_family = sckfam;
|
||||
bind(sck, (struct sockaddr *)&anyaddr, scklen);
|
||||
}
|
||||
}
|
||||
|
||||
if (connect(sck, (struct sockaddr*)&sckaddr, scklen) <= -1)
|
||||
{
|
||||
fprintf (stderr, "cannot connect to %s - %s\n", ipaddr, strerror(errno));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
iov[count].iov_base = ".SCRIPT (do ";
|
||||
iov[count++].iov_len = 12;
|
||||
iov[count].iov_base = (char*)script;
|
||||
iov[count++].iov_len = strlen(script);
|
||||
/* the script above must not include trailing newlines */
|
||||
iov[count].iov_base = ")\n";
|
||||
iov[count++].iov_len = 2;
|
||||
|
||||
index = 0;
|
||||
while (1)
|
||||
{
|
||||
ssize_t nwritten;
|
||||
struct msghdr msg;
|
||||
|
||||
memset (&msg, 0, HCL_SIZEOF(msg));
|
||||
msg.msg_iov = (struct iovec*)&iov[index];
|
||||
msg.msg_iovlen = count - index;
|
||||
nwritten = sendmsg(sck, &msg, 0);
|
||||
/*nwritten = writev(proto->worker->sck, (const struct iovec*)&iov[index], count - index);*/
|
||||
if (nwritten <= -1)
|
||||
{
|
||||
/* error occurred inside the worker thread shouldn't affect the error information
|
||||
* in the server object. so here, i just log a message */
|
||||
fprintf (stderr, "Unable to sendmsg on %d - %s\n", sck, strerror(errno));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
while (index < count && (size_t)nwritten >= iov[index].iov_len)
|
||||
nwritten -= iov[index++].iov_len;
|
||||
|
||||
if (index == count) break;
|
||||
|
||||
iov[index].iov_base = (void*)((hcl_uint8_t*)iov[index].iov_base + nwritten);
|
||||
iov[index].iov_len -= nwritten;
|
||||
}
|
||||
|
||||
if (shut_wr_after_req) shutdown (sck, SHUT_WR);
|
||||
|
||||
client_xtn->data_length = 0;
|
||||
client_xtn->reply_count = 0;
|
||||
|
||||
/* TODO: implement timeout? */
|
||||
avail = 0;
|
||||
while (client_xtn->reply_count == 0)
|
||||
{
|
||||
n = recv(sck, &buf[avail], HCL_SIZEOF(buf) - avail, 0);
|
||||
if (n <= -1)
|
||||
{
|
||||
fprintf (stderr, "Unable to read from %d - %s\n", sck, strerror(n));
|
||||
goto oops;
|
||||
}
|
||||
if (n == 0)
|
||||
{
|
||||
if (hcl_client_getstate(client) != HCL_CLIENT_STATE_START)
|
||||
{
|
||||
fprintf (stderr, "Sudden end of reply\n");
|
||||
goto oops;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
avail += n;;
|
||||
x = hcl_client_feed(client, buf, avail, &used);
|
||||
if (x <= -1)
|
||||
{
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
hcl_errnum_t errnum = hcl_client_geterrnum(client);
|
||||
const hcl_ooch_t* errmsg = hcl_client_geterrmsg(client);
|
||||
hcl_bch_t errbuf[2048];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
|
||||
bcslen = HCL_COUNTOF(errbuf);
|
||||
hcl_conv_ucstr_to_bcstr_with_cmgr (errmsg, &ucslen, errbuf, &bcslen, hcl_client_getcmgr(client));
|
||||
fprintf (stderr, "Client error [%d] - %s\n", (int)errnum, errbuf);
|
||||
#else
|
||||
fprintf (stderr, "Client error [%d] - %s\n", (int)hcl_client_geterrnum(client), hcl_client_geterrmsg(client));
|
||||
#endif
|
||||
goto oops;
|
||||
}
|
||||
|
||||
avail -= used;
|
||||
if (avail > 0) memmove (&buf[0], &buf[used], avail);
|
||||
}
|
||||
|
||||
/* TODO: we can check if the buffer has all been consumed. if not, there is trailing garbage.. */
|
||||
|
||||
/*shutdown (sck, (shut_wr_after_req? SHUT_RD: SHUT_RDWR));*/
|
||||
if (!shut_wr_after_req) shutdown (sck, SHUT_RDWR);
|
||||
|
||||
/*{
|
||||
struct linger linger;
|
||||
linger.l_onoff = 1;
|
||||
linger.l_linger = 0;
|
||||
setsockopt (sck, SOL_SOCKET, SO_LINGER, (char *) &linger, sizeof(linger));
|
||||
}*/
|
||||
|
||||
close (sck);
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
if (sck >= 0) close (sck);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
hcl_bci_t c;
|
||||
static hcl_bopt_lng_t lopt[] =
|
||||
{
|
||||
{ ":log", 'l' },
|
||||
{ "reuseaddr", '\0' },
|
||||
{ "shutwr", '\0' },
|
||||
{ HCL_NULL, '\0' }
|
||||
};
|
||||
static hcl_bopt_t opt =
|
||||
{
|
||||
"l:",
|
||||
lopt
|
||||
};
|
||||
|
||||
hcl_client_t* client;
|
||||
client_xtn_t* xtn;
|
||||
hcl_client_prim_t client_prim;
|
||||
int n;
|
||||
const char* logopt = HCL_NULL;
|
||||
int reuse_addr = 0;
|
||||
int shut_wr_after_req = 0;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
print_usage:
|
||||
fprintf (stderr, "Usage: %s [-l/--log log-options] [--reuseaddr] [--shutwr] bind-address:port script-to-run\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((c = hcl_getbopt (argc, argv, &opt)) != HCL_BCI_EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'l':
|
||||
logopt = opt.arg;
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
if (hcl_comp_bcstr(opt.lngopt, "reuseaddr") == 0)
|
||||
{
|
||||
reuse_addr = 1;
|
||||
}
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "shutwr") == 0)
|
||||
{
|
||||
shut_wr_after_req = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto print_usage;
|
||||
}
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if (opt.lngopt)
|
||||
fprintf (stderr, "bad argument for '%s'\n", opt.lngopt);
|
||||
else
|
||||
fprintf (stderr, "bad argument for '%c'\n", opt.opt);
|
||||
|
||||
return -1;
|
||||
|
||||
default:
|
||||
goto print_usage;
|
||||
}
|
||||
}
|
||||
|
||||
/* needs 2 fixed arguments */
|
||||
if (opt.ind + 1 >= argc) goto print_usage;
|
||||
|
||||
memset (&client_prim, 0, HCL_SIZEOF(client_prim));
|
||||
client_prim.log_write = log_write;
|
||||
client_prim.start_reply = start_reply;
|
||||
client_prim.feed_attr = feed_attr;
|
||||
client_prim.feed_data = feed_data;
|
||||
client_prim.end_reply = end_reply;
|
||||
|
||||
client = hcl_client_open(&sys_mmgr, HCL_SIZEOF(client_xtn_t), &client_prim, HCL_NULL);
|
||||
if (!client)
|
||||
{
|
||||
fprintf (stderr, "cannot open client\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
xtn = (client_xtn_t*)hcl_client_getxtn(client);
|
||||
xtn->logfd = -1;
|
||||
xtn->logfd_istty = 0;
|
||||
|
||||
if (logopt)
|
||||
{
|
||||
if (handle_logopt(client, logopt) <= -1) goto oops;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* default logging mask when no logging option is set */
|
||||
xtn->logmask = HCL_LOG_ALL_TYPES | HCL_LOG_ERROR | HCL_LOG_FATAL;
|
||||
}
|
||||
|
||||
g_client = client;
|
||||
set_signal (SIGINT, handle_sigint);
|
||||
set_signal_to_ignore (SIGPIPE);
|
||||
|
||||
n = handle_request (client, argv[opt.ind], argv[opt.ind + 1], reuse_addr, shut_wr_after_req);
|
||||
|
||||
set_signal_to_default (SIGINT);
|
||||
set_signal_to_default (SIGPIPE);
|
||||
g_client = NULL;
|
||||
|
||||
if (xtn->logfd >= 0)
|
||||
{
|
||||
close (xtn->logfd);
|
||||
xtn->logfd = -1;
|
||||
xtn->logfd_istty = 0;
|
||||
}
|
||||
|
||||
hcl_client_close (client);
|
||||
return n;
|
||||
|
||||
oops:
|
||||
if (client) hcl_client_close (client);
|
||||
return -1;
|
||||
}
|
337
bin/main-j.c
Normal file
337
bin/main-j.c
Normal file
@ -0,0 +1,337 @@
|
||||
#include <hcl-json.h>
|
||||
#include <hcl-utl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
typedef struct json_xtn_t json_xtn_t;
|
||||
struct json_xtn_t
|
||||
{
|
||||
int logfd;
|
||||
hcl_bitmask_t logmask;
|
||||
int logfd_istty;
|
||||
|
||||
struct
|
||||
{
|
||||
hcl_bch_t buf[4096];
|
||||
hcl_oow_t len;
|
||||
} logbuf;
|
||||
|
||||
int depth;
|
||||
};
|
||||
/* ========================================================================= */
|
||||
|
||||
static void* sys_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void* sys_realloc (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void sys_free (hcl_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
static hcl_mmgr_t sys_mmgr =
|
||||
{
|
||||
sys_alloc,
|
||||
sys_realloc,
|
||||
sys_free,
|
||||
HCL_NULL
|
||||
};
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static int write_all (int fd, const hcl_bch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
hcl_ooi_t wr;
|
||||
|
||||
wr = write(fd, ptr, len);
|
||||
|
||||
if (wr <= -1)
|
||||
{
|
||||
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN == EWOULDBLOCK)
|
||||
if (errno == EAGAIN) continue;
|
||||
#else
|
||||
#if defined(EAGAIN)
|
||||
if (errno == EAGAIN) continue;
|
||||
#elif defined(EWOULDBLOCK)
|
||||
if (errno == EWOULDBLOCK) continue;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(EINTR)
|
||||
/* TODO: would this interfere with non-blocking nature of this VM? */
|
||||
if (errno == EINTR) continue;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr += wr;
|
||||
len -= wr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int write_log (hcl_json_t* json, int fd, const hcl_bch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
json_xtn_t* xtn = (json_xtn_t*)hcl_json_getxtn(json);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
if (xtn->logbuf.len > 0)
|
||||
{
|
||||
hcl_oow_t rcapa, cplen;
|
||||
|
||||
rcapa = HCL_COUNTOF(xtn->logbuf.buf) - xtn->logbuf.len;
|
||||
cplen = (len >= rcapa)? rcapa: len;
|
||||
|
||||
memcpy (&xtn->logbuf.buf[xtn->logbuf.len], ptr, cplen);
|
||||
xtn->logbuf.len += cplen;
|
||||
ptr += cplen;
|
||||
len -= cplen;
|
||||
|
||||
if (xtn->logbuf.len >= HCL_COUNTOF(xtn->logbuf.buf))
|
||||
{
|
||||
write_all(fd, xtn->logbuf.buf, xtn->logbuf.len);
|
||||
xtn->logbuf.len = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_oow_t rcapa;
|
||||
|
||||
rcapa = HCL_COUNTOF(xtn->logbuf.buf);
|
||||
if (len >= rcapa)
|
||||
{
|
||||
write_all (fd, ptr, rcapa);
|
||||
ptr += rcapa;
|
||||
len -= rcapa;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (xtn->logbuf.buf, ptr, len);
|
||||
xtn->logbuf.len += len;
|
||||
ptr += len;
|
||||
len -= len;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void flush_log (hcl_json_t* json, int fd)
|
||||
{
|
||||
json_xtn_t* xtn = (json_xtn_t*)hcl_json_getxtn(json);
|
||||
if (xtn->logbuf.len > 0)
|
||||
{
|
||||
write_all (fd, xtn->logbuf.buf, xtn->logbuf.len);
|
||||
xtn->logbuf.len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void log_write (hcl_json_t* json, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
json_xtn_t* xtn = (json_xtn_t*)hcl_json_getxtn(json);
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
|
||||
hcl_oow_t msgidx;
|
||||
int n, logfd;
|
||||
|
||||
if (mask & HCL_LOG_STDERR)
|
||||
{
|
||||
/* the messages that go to STDERR don't get masked out */
|
||||
logfd = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(xtn->logmask & mask & ~HCL_LOG_ALL_LEVELS)) return; /* check log types */
|
||||
if (!(xtn->logmask & mask & ~HCL_LOG_ALL_TYPES)) return; /* check log levels */
|
||||
|
||||
if (mask & HCL_LOG_STDOUT) logfd = 1;
|
||||
else
|
||||
{
|
||||
logfd = xtn->logfd;
|
||||
if (logfd <= -1) return;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: beautify the log message.
|
||||
* do classification based on mask. */
|
||||
if (!(mask & (HCL_LOG_STDOUT | HCL_LOG_STDERR)))
|
||||
{
|
||||
time_t now;
|
||||
char ts[32];
|
||||
size_t tslen;
|
||||
struct tm tm, *tmp;
|
||||
|
||||
now = time(NULL);
|
||||
|
||||
#if defined(__OS2__)
|
||||
tmp = _localtime(&now, &tm);
|
||||
#elif defined(HAVE_LOCALTIME_R)
|
||||
tmp = localtime_r(&now, &tm);
|
||||
#else
|
||||
tmp = localtime(&now);
|
||||
#endif
|
||||
#if defined(HAVE_STRFTIME_SMALL_Z)
|
||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||
#else
|
||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
||||
#endif
|
||||
if (tslen == 0)
|
||||
{
|
||||
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
||||
tslen = 25;
|
||||
}
|
||||
|
||||
write_log (json, logfd, ts, tslen);
|
||||
}
|
||||
|
||||
if (logfd == xtn->logfd && xtn->logfd_istty)
|
||||
{
|
||||
if (mask & HCL_LOG_FATAL) write_log (json, logfd, "\x1B[1;31m", 7);
|
||||
else if (mask & HCL_LOG_ERROR) write_log (json, logfd, "\x1B[1;32m", 7);
|
||||
else if (mask & HCL_LOG_WARN) write_log (json, logfd, "\x1B[1;33m", 7);
|
||||
}
|
||||
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
msgidx = 0;
|
||||
while (len > 0)
|
||||
{
|
||||
ucslen = len;
|
||||
bcslen = HCL_COUNTOF(buf);
|
||||
|
||||
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
||||
if (n == 0 || n == -2)
|
||||
{
|
||||
/* n = 0:
|
||||
* converted all successfully
|
||||
* n == -2:
|
||||
* buffer not sufficient. not all got converted yet.
|
||||
* write what have been converted this round. */
|
||||
|
||||
/*HCL_ASSERT (hcl, ucslen > 0); */ /* if this fails, the buffer size must be increased */
|
||||
/*assert (ucslen > 0);*/
|
||||
|
||||
/* attempt to write all converted characters */
|
||||
if (write_log(json, logfd, buf, bcslen) <= -1) break;
|
||||
|
||||
if (n == 0) break;
|
||||
else
|
||||
{
|
||||
msgidx += ucslen;
|
||||
len -= ucslen;
|
||||
}
|
||||
}
|
||||
else if (n <= -1)
|
||||
{
|
||||
/* conversion error */
|
||||
if (bcslen <= 0) break;
|
||||
if (write_log(json, logfd, buf, bcslen) <= -1) break;
|
||||
msgidx += ucslen;
|
||||
len -= ucslen;
|
||||
}
|
||||
}
|
||||
#else
|
||||
write_log (json, logfd, msg, len);
|
||||
#endif
|
||||
|
||||
if (logfd == xtn->logfd && xtn->logfd_istty)
|
||||
{
|
||||
if (mask & (HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN)) write_log (json, logfd, "\x1B[0m", 4);
|
||||
}
|
||||
|
||||
flush_log (json, logfd);
|
||||
}
|
||||
|
||||
static int instcb (hcl_json_t* json, hcl_json_inst_t it, const hcl_oocs_t* str)
|
||||
{
|
||||
json_xtn_t* json_xtn = (json_xtn_t*)hcl_json_getxtn(json);
|
||||
|
||||
switch (it)
|
||||
{
|
||||
case HCL_JSON_INST_START_ARRAY:
|
||||
json_xtn->depth++;
|
||||
hcl_json_logbfmt (json, HCL_LOG_INFO | HCL_LOG_APP, "[\n");
|
||||
break;
|
||||
case HCL_JSON_INST_END_ARRAY:
|
||||
json_xtn->depth--;
|
||||
hcl_json_logbfmt (json, HCL_LOG_INFO | HCL_LOG_APP, "]\n");
|
||||
break;
|
||||
case HCL_JSON_INST_START_DIC:
|
||||
json_xtn->depth++;
|
||||
hcl_json_logbfmt (json, HCL_LOG_INFO | HCL_LOG_APP, "{\n");
|
||||
break;
|
||||
case HCL_JSON_INST_END_DIC:
|
||||
json_xtn->depth--;
|
||||
hcl_json_logbfmt (json, HCL_LOG_INFO | HCL_LOG_APP, "}\n");
|
||||
break;
|
||||
|
||||
case HCL_JSON_INST_KEY:
|
||||
hcl_json_logbfmt (json, HCL_LOG_INFO | HCL_LOG_APP, "%.*js: ", str->len, str->ptr);
|
||||
break;
|
||||
|
||||
case HCL_JSON_INST_CHARACTER:
|
||||
case HCL_JSON_INST_STRING:
|
||||
case HCL_JSON_INST_NUMBER:
|
||||
case HCL_JSON_INST_TRUE:
|
||||
case HCL_JSON_INST_FALSE:
|
||||
case HCL_JSON_INST_NIL:
|
||||
hcl_json_logbfmt (json, HCL_LOG_INFO | HCL_LOG_APP, "%.*js\n", str->len, str->ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ========================================================================= */
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
|
||||
hcl_json_t* json;
|
||||
hcl_json_prim_t json_prim;
|
||||
json_xtn_t* json_xtn;
|
||||
hcl_oow_t xlen;
|
||||
const char* p;
|
||||
|
||||
memset (&json_prim, 0, HCL_SIZEOF(json_prim));
|
||||
json_prim.log_write = log_write;
|
||||
json_prim.instcb = instcb;
|
||||
|
||||
json = hcl_json_open (&sys_mmgr, HCL_SIZEOF(json_xtn_t), &json_prim, NULL);
|
||||
|
||||
json_xtn = (json_xtn_t*)hcl_json_getxtn(json);
|
||||
json_xtn->logmask = HCL_LOG_ALL_LEVELS | HCL_LOG_ALL_TYPES;
|
||||
|
||||
p = "[ \"ab\\xab\\uC88B\\uC544\\uC6A9c\", \"kaden\", \"iron\", true, { \"null\": \"a\\1bc\", \"123\": \"AA20AA\", \"10\": -0.123, \"way\": '\\uC88A' } ]";
|
||||
/*p = "{ \"result\": \"SUCCESS\", \"message\": \"1 clients\", \"sessions\": [] }";*/
|
||||
|
||||
if (hcl_json_feed(json, p, strlen(p), &xlen) <= -1)
|
||||
{
|
||||
hcl_json_logbfmt (json, HCL_LOG_FATAL | HCL_LOG_APP, "ERROR: unable to process - %js\n", hcl_json_geterrmsg(json));
|
||||
}
|
||||
else if (json_xtn->depth != 0)
|
||||
{
|
||||
hcl_json_logbfmt (json, HCL_LOG_FATAL | HCL_LOG_APP, "ERROR: incomplete input\n");
|
||||
}
|
||||
|
||||
hcl_json_close (json);
|
||||
return 0;
|
||||
}
|
688
bin/main-s.c
Normal file
688
bin/main-s.c
Normal file
@ -0,0 +1,688 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2016-2018 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 WARRANTIES
|
||||
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 "hcl-s.h"
|
||||
#include "hcl-opt.h"
|
||||
#include "hcl-utl.h"
|
||||
#include "hcl-xutl.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
|
||||
#if defined(HAVE_TIME_H)
|
||||
# include <time.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#if defined(HAVE_SIGNAL_H)
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_UIO_H)
|
||||
# include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
typedef struct server_xtn_t server_xtn_t;
|
||||
struct server_xtn_t
|
||||
{
|
||||
int logfd;
|
||||
hcl_bitmask_t logmask;
|
||||
int logfd_istty;
|
||||
|
||||
struct
|
||||
{
|
||||
hcl_bch_t buf[4096];
|
||||
hcl_oow_t len;
|
||||
} logbuf;
|
||||
};
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static void* sys_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void* sys_realloc (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
static void sys_free (hcl_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
static hcl_mmgr_t sys_mmgr =
|
||||
{
|
||||
sys_alloc,
|
||||
sys_realloc,
|
||||
sys_free,
|
||||
HCL_NULL
|
||||
};
|
||||
/* ========================================================================= */
|
||||
|
||||
static int write_all (int fd, const hcl_bch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
hcl_ooi_t wr;
|
||||
|
||||
wr = write(fd, ptr, len);
|
||||
|
||||
if (wr <= -1)
|
||||
{
|
||||
#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN == EWOULDBLOCK)
|
||||
if (errno == EAGAIN) continue;
|
||||
#else
|
||||
#if defined(EAGAIN)
|
||||
if (errno == EAGAIN) continue;
|
||||
#elif defined(EWOULDBLOCK)
|
||||
if (errno == EWOULDBLOCK) continue;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(EINTR)
|
||||
/* TODO: would this interfere with non-blocking nature of this VM? */
|
||||
if (errno == EINTR) continue;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr += wr;
|
||||
len -= wr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int write_log (hcl_server_t* server, int fd, const hcl_bch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
server_xtn_t* xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
if (xtn->logbuf.len > 0)
|
||||
{
|
||||
hcl_oow_t rcapa, cplen;
|
||||
|
||||
rcapa = HCL_COUNTOF(xtn->logbuf.buf) - xtn->logbuf.len;
|
||||
cplen = (len >= rcapa)? rcapa: len;
|
||||
|
||||
memcpy (&xtn->logbuf.buf[xtn->logbuf.len], ptr, cplen);
|
||||
xtn->logbuf.len += cplen;
|
||||
ptr += cplen;
|
||||
len -= cplen;
|
||||
|
||||
if (xtn->logbuf.len >= HCL_COUNTOF(xtn->logbuf.buf))
|
||||
{
|
||||
write_all(fd, xtn->logbuf.buf, xtn->logbuf.len);
|
||||
xtn->logbuf.len = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_oow_t rcapa;
|
||||
|
||||
rcapa = HCL_COUNTOF(xtn->logbuf.buf);
|
||||
if (len >= rcapa)
|
||||
{
|
||||
write_all (fd, ptr, rcapa);
|
||||
ptr += rcapa;
|
||||
len -= rcapa;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (xtn->logbuf.buf, ptr, len);
|
||||
xtn->logbuf.len += len;
|
||||
ptr += len;
|
||||
len -= len;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void flush_log (hcl_server_t* server, int fd)
|
||||
{
|
||||
server_xtn_t* xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
||||
|
||||
if (xtn->logbuf.len > 0)
|
||||
{
|
||||
write_all (fd, xtn->logbuf.buf, xtn->logbuf.len);
|
||||
xtn->logbuf.len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
server_xtn_t* xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
||||
hcl_bch_t buf[256];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
hcl_oow_t msgidx;
|
||||
int n, logfd;
|
||||
|
||||
if (mask & HCL_LOG_STDERR)
|
||||
{
|
||||
/* the messages that go to STDERR don't get masked out */
|
||||
logfd = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(xtn->logmask & mask & ~HCL_LOG_ALL_LEVELS)) return; /* check log types */
|
||||
if (!(xtn->logmask & mask & ~HCL_LOG_ALL_TYPES)) return; /* check log levels */
|
||||
|
||||
if (mask & HCL_LOG_STDOUT) logfd = 1;
|
||||
else
|
||||
{
|
||||
logfd = xtn->logfd;
|
||||
if (logfd <= -1) return;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: beautify the log message.
|
||||
* do classification based on mask. */
|
||||
if (!(mask & (HCL_LOG_STDOUT | HCL_LOG_STDERR)))
|
||||
{
|
||||
time_t now;
|
||||
char ts[32];
|
||||
size_t tslen;
|
||||
struct tm tm, *tmp;
|
||||
|
||||
now = time(NULL);
|
||||
|
||||
#if defined(__OS2__)
|
||||
tmp = _localtime(&now, &tm);
|
||||
#elif defined(HAVE_LOCALTIME_R)
|
||||
tmp = localtime_r(&now, &tm);
|
||||
#else
|
||||
tmp = localtime(&now);
|
||||
#endif
|
||||
#if defined(HAVE_STRFTIME_SMALL_Z)
|
||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||
#else
|
||||
tslen = strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp);
|
||||
#endif
|
||||
if (tslen == 0)
|
||||
{
|
||||
strcpy (ts, "0000-00-00 00:00:00 +0000");
|
||||
tslen = 25;
|
||||
}
|
||||
|
||||
write_log (server, logfd, ts, tslen);
|
||||
|
||||
if (wid != HCL_SERVER_WID_INVALID)
|
||||
{
|
||||
/* TODO: check if the underlying snprintf support %zd */
|
||||
tslen = snprintf (ts, sizeof(ts), "[%zu] ", wid);
|
||||
write_log (server, logfd, ts, tslen);
|
||||
}
|
||||
}
|
||||
|
||||
if (logfd == xtn->logfd && xtn->logfd_istty)
|
||||
{
|
||||
if (mask & HCL_LOG_FATAL) write_log (server, logfd, "\x1B[1;31m", 7);
|
||||
else if (mask & HCL_LOG_ERROR) write_log (server, logfd, "\x1B[1;32m", 7);
|
||||
else if (mask & HCL_LOG_WARN) write_log (server, logfd, "\x1B[1;33m", 7);
|
||||
}
|
||||
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
msgidx = 0;
|
||||
while (len > 0)
|
||||
{
|
||||
ucslen = len;
|
||||
bcslen = HCL_COUNTOF(buf);
|
||||
|
||||
n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
|
||||
if (n == 0 || n == -2)
|
||||
{
|
||||
/* n = 0:
|
||||
* converted all successfully
|
||||
* n == -2:
|
||||
* buffer not sufficient. not all got converted yet.
|
||||
* write what have been converted this round. */
|
||||
|
||||
/*HCL_ASSERT (hcl, ucslen > 0); */ /* if this fails, the buffer size must be increased */
|
||||
/*assert (ucslen > 0);*/
|
||||
|
||||
/* attempt to write all converted characters */
|
||||
if (write_log(server, logfd, buf, bcslen) <= -1) break;
|
||||
|
||||
if (n == 0) break;
|
||||
else
|
||||
{
|
||||
msgidx += ucslen;
|
||||
len -= ucslen;
|
||||
}
|
||||
}
|
||||
else if (n <= -1)
|
||||
{
|
||||
/* conversion error */
|
||||
if (bcslen <= 0) break;
|
||||
if (write_log(server, logfd, buf, bcslen) <= -1) break;
|
||||
msgidx += ucslen;
|
||||
len -= ucslen;
|
||||
}
|
||||
}
|
||||
#else
|
||||
write_log (server, logfd, msg, len);
|
||||
#endif
|
||||
|
||||
if (logfd == xtn->logfd && xtn->logfd_istty)
|
||||
{
|
||||
if (mask & (HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN)) write_log (server, logfd, "\x1B[0m", 4);
|
||||
}
|
||||
|
||||
flush_log (server, logfd);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static hcl_server_t* g_server = HCL_NULL;
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
typedef void (*signal_handler_t) (int, siginfo_t*, void*);
|
||||
|
||||
static void handle_sigint (int sig, siginfo_t* siginfo, void* ctx)
|
||||
{
|
||||
if (g_server) hcl_server_stop (g_server);
|
||||
}
|
||||
|
||||
static void set_signal (int sig, signal_handler_t handler)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
memset (&sa, 0, sizeof(sa));
|
||||
/*sa.sa_handler = handler;*/
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sa.sa_sigaction = handler;
|
||||
sigemptyset (&sa.sa_mask);
|
||||
|
||||
sigaction (sig, &sa, NULL);
|
||||
}
|
||||
|
||||
static void set_signal_to_ignore (int sig)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
memset (&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sa.sa_flags = 0;
|
||||
sigemptyset (&sa.sa_mask);
|
||||
|
||||
sigaction (sig, &sa, NULL);
|
||||
}
|
||||
|
||||
static void set_signal_to_default (int sig)
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
memset (&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sa.sa_flags = 0;
|
||||
sigemptyset (&sa.sa_mask);
|
||||
|
||||
sigaction (sig, &sa, NULL);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static int handle_logopt (hcl_server_t* server, const hcl_bch_t* str)
|
||||
{
|
||||
hcl_bch_t* xstr = (hcl_bch_t*)str;
|
||||
hcl_bch_t* cm, * flt;
|
||||
hcl_bitmask_t logmask;
|
||||
server_xtn_t* xtn;
|
||||
|
||||
xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
||||
if (cm)
|
||||
{
|
||||
/* i duplicate this string for open() below as open() doesn't
|
||||
* accept a length-bounded string */
|
||||
xstr = strdup(str);
|
||||
if (!xstr)
|
||||
{
|
||||
fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr(xstr, ',');
|
||||
*cm = '\0';
|
||||
|
||||
logmask = xtn->logmask;
|
||||
do
|
||||
{
|
||||
flt = cm + 1;
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr(flt, ',');
|
||||
if (cm) *cm = '\0';
|
||||
|
||||
if (hcl_comp_bcstr(flt, "app") == 0) logmask |= HCL_LOG_APP;
|
||||
else if (hcl_comp_bcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER;
|
||||
else if (hcl_comp_bcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM;
|
||||
else if (hcl_comp_bcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC;
|
||||
else if (hcl_comp_bcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC;
|
||||
else if (hcl_comp_bcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC;
|
||||
else if (hcl_comp_bcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE;
|
||||
|
||||
else if (hcl_comp_bcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL;
|
||||
else if (hcl_comp_bcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR;
|
||||
else if (hcl_comp_bcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN;
|
||||
else if (hcl_comp_bcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO;
|
||||
else if (hcl_comp_bcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG;
|
||||
|
||||
else if (hcl_comp_bcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL;
|
||||
else if (hcl_comp_bcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR;
|
||||
else if (hcl_comp_bcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN;
|
||||
else if (hcl_comp_bcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO;
|
||||
else if (hcl_comp_bcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG;
|
||||
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "ERROR: unknown log option value - %s\n", flt);
|
||||
if (str != xstr) free (xstr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (cm);
|
||||
|
||||
if (!(logmask & HCL_LOG_ALL_TYPES)) logmask |= HCL_LOG_ALL_TYPES; /* no types specified. force to all types */
|
||||
if (!(logmask & HCL_LOG_ALL_LEVELS)) logmask |= HCL_LOG_ALL_LEVELS; /* no levels specified. force to all levels */
|
||||
}
|
||||
else
|
||||
{
|
||||
logmask = HCL_LOG_ALL_LEVELS | HCL_LOG_ALL_TYPES;
|
||||
}
|
||||
|
||||
xtn->logfd = open(xstr, O_CREAT | O_WRONLY | O_APPEND , 0644);
|
||||
if (xtn->logfd == -1)
|
||||
{
|
||||
fprintf (stderr, "ERROR: cannot open a log file %s\n", xstr);
|
||||
if (str != xstr) free (xstr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
xtn->logmask = logmask;
|
||||
#if defined(HAVE_ISATTY)
|
||||
xtn->logfd_istty = isatty(xtn->logfd);
|
||||
#endif
|
||||
|
||||
if (str != xstr) free (xstr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
static int handle_dbgopt (hcl_server_t* server, const char* str)
|
||||
{
|
||||
const hcl_bch_t* cm, * flt;
|
||||
hcl_oow_t len;
|
||||
hcl_bitmask_t trait;
|
||||
|
||||
hcl_server_getoption (server, HCL_SERVER_TRAIT, &trait);
|
||||
|
||||
cm = str - 1;
|
||||
do
|
||||
{
|
||||
flt = cm + 1;
|
||||
|
||||
cm = hcl_find_bchar_in_bcstr(flt, ',');
|
||||
len = cm? (cm - flt): hcl_count_bcstr(flt);
|
||||
if (hcl_comp_bchars_bcstr(flt, len, "gc") == 0) trait |= HCL_SERVER_TRAIT_DEBUG_GC;
|
||||
else if (hcl_comp_bchars_bcstr(flt, len, "bigint") == 0) trait |= HCL_SERVER_TRAIT_DEBUG_BIGINT;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (cm);
|
||||
|
||||
hcl_server_setoption (server, HCL_SERVER_TRAIT, &trait);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int handle_incpath (hcl_server_t* server, const char* str)
|
||||
{
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
hcl_ooch_t incpath[HCL_PATH_MAX + 1];
|
||||
hcl_oow_t bcslen, ucslen;
|
||||
|
||||
ucslen = HCL_COUNTOF(incpath);
|
||||
if (hcl_conv_bcstr_to_ucstr_with_cmgr(str, &bcslen, incpath, &ucslen, hcl_server_getcmgr(server), 1) <= -1) return -1;
|
||||
return hcl_server_setoption(server, HCL_SERVER_SCRIPT_INCLUDE_PATH, incpath);
|
||||
#else
|
||||
return hcl_server_setoption(server, HCL_SERVER_SCRIPT_INCLUDE_PATH, str);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#define MIN_WORKER_STACK_SIZE 512000ul
|
||||
#define MIN_ACTOR_HEAP_SIZE 512000ul
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
hcl_bci_t c;
|
||||
static hcl_bopt_lng_t lopt[] =
|
||||
{
|
||||
{ ":log", 'l' },
|
||||
{ "large-pages", '\0' },
|
||||
{ ":worker-max-count", '\0' },
|
||||
{ ":worker-stack-size", '\0' },
|
||||
{ ":worker-idle-timeout", '\0' },
|
||||
{ ":actor-heap-size", 'm' },
|
||||
{ ":actor-max-runtime", '\0' },
|
||||
{ ":script-include-path", '\0' },
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
{ ":debug", '\0' }, /* NOTE: there is no short option for --debug */
|
||||
#endif
|
||||
{ HCL_NULL, '\0' }
|
||||
};
|
||||
static hcl_bopt_t opt =
|
||||
{
|
||||
"l:m:",
|
||||
lopt
|
||||
};
|
||||
|
||||
hcl_server_t* server;
|
||||
server_xtn_t* xtn;
|
||||
hcl_server_prim_t server_prim;
|
||||
int n;
|
||||
|
||||
const char* logopt = HCL_NULL;
|
||||
const char* dbgopt = HCL_NULL;
|
||||
const char* incpath = HCL_NULL;
|
||||
hcl_oow_t worker_max_count = 0;
|
||||
hcl_oow_t worker_stack_size = MIN_ACTOR_HEAP_SIZE;
|
||||
hcl_ntime_t worker_idle_timeout = { 0, 0 };
|
||||
hcl_oow_t actor_heap_size = MIN_ACTOR_HEAP_SIZE;
|
||||
hcl_ntime_t actor_max_runtime = { 0, 0 };
|
||||
int large_pages = 0;
|
||||
hcl_bitmask_t trait;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
print_usage:
|
||||
fprintf (stderr, "Usage: %s bind-address:port\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((c = hcl_getbopt (argc, argv, &opt)) != HCL_BCI_EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'l':
|
||||
logopt = opt.arg;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
actor_heap_size = strtoul(opt.arg, HCL_NULL, 0);
|
||||
if (actor_heap_size <= MIN_ACTOR_HEAP_SIZE) actor_heap_size = MIN_ACTOR_HEAP_SIZE;
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
if (hcl_comp_bcstr(opt.lngopt, "large-pages") == 0)
|
||||
{
|
||||
large_pages = 1;
|
||||
}
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "worker-max-count") == 0)
|
||||
{
|
||||
worker_max_count = strtoul(opt.arg, HCL_NULL, 0);
|
||||
}
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "worker-stack-size") == 0)
|
||||
{
|
||||
worker_stack_size = strtoul(opt.arg, HCL_NULL, 0);
|
||||
if (worker_stack_size <= MIN_WORKER_STACK_SIZE) worker_stack_size = MIN_WORKER_STACK_SIZE;
|
||||
}
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "worker-idle-timeout") == 0)
|
||||
{
|
||||
worker_idle_timeout.sec = strtoul(opt.arg, HCL_NULL, 0);
|
||||
}
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "actor-max-runtime") == 0)
|
||||
{
|
||||
actor_max_runtime.sec = strtoul(opt.arg, HCL_NULL, 0);
|
||||
}
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "script-include-path") == 0)
|
||||
{
|
||||
incpath = opt.arg;
|
||||
}
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
else if (hcl_comp_bcstr(opt.lngopt, "debug") == 0)
|
||||
{
|
||||
dbgopt = opt.arg;
|
||||
}
|
||||
#endif
|
||||
else goto print_usage;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if (opt.lngopt)
|
||||
fprintf (stderr, "bad argument for '%s'\n", opt.lngopt);
|
||||
else
|
||||
fprintf (stderr, "bad argument for '%c'\n", opt.opt);
|
||||
|
||||
return -1;
|
||||
|
||||
default:
|
||||
goto print_usage;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt.ind >= argc) goto print_usage;
|
||||
|
||||
memset (&server_prim, 0, HCL_SIZEOF(server_prim));
|
||||
server_prim.log_write = log_write;
|
||||
|
||||
server = hcl_server_open(&sys_mmgr, HCL_SIZEOF(server_xtn_t), &server_prim, HCL_NULL);
|
||||
if (!server)
|
||||
{
|
||||
fprintf (stderr, "cannot open server\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
xtn = (server_xtn_t*)hcl_server_getxtn(server);
|
||||
xtn->logfd = -1;
|
||||
xtn->logfd_istty = 0;
|
||||
|
||||
if (logopt)
|
||||
{
|
||||
if (handle_logopt(server, logopt) <= -1) goto oops;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* default logging mask when no logging option is set */
|
||||
xtn->logmask = HCL_LOG_ALL_TYPES | HCL_LOG_ERROR | HCL_LOG_FATAL;
|
||||
}
|
||||
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
if (dbgopt)
|
||||
{
|
||||
if (handle_dbgopt(server, dbgopt) <= -1) goto oops;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (incpath)
|
||||
{
|
||||
if (handle_incpath(server, incpath) <= -1) goto oops;
|
||||
}
|
||||
|
||||
hcl_server_getoption (server, HCL_SERVER_TRAIT, &trait);
|
||||
if (large_pages) trait |= HCL_SERVER_TRAIT_USE_LARGE_PAGES;
|
||||
else trait &= ~HCL_SERVER_TRAIT_USE_LARGE_PAGES;
|
||||
hcl_server_setoption (server, HCL_SERVER_TRAIT, &trait);
|
||||
|
||||
hcl_server_setoption (server, HCL_SERVER_WORKER_MAX_COUNT, &worker_max_count);
|
||||
hcl_server_setoption (server, HCL_SERVER_WORKER_STACK_SIZE, &worker_stack_size);
|
||||
hcl_server_setoption (server, HCL_SERVER_WORKER_IDLE_TIMEOUT, &worker_idle_timeout);
|
||||
hcl_server_setoption (server, HCL_SERVER_ACTOR_HEAP_SIZE, &actor_heap_size);
|
||||
hcl_server_setoption (server, HCL_SERVER_ACTOR_MAX_RUNTIME, &actor_max_runtime);
|
||||
|
||||
g_server = server;
|
||||
set_signal (SIGINT, handle_sigint);
|
||||
set_signal_to_ignore (SIGPIPE);
|
||||
|
||||
n = hcl_server_start(server, argv[opt.ind]);
|
||||
|
||||
set_signal_to_default (SIGINT);
|
||||
set_signal_to_default (SIGPIPE);
|
||||
g_server = NULL;
|
||||
|
||||
if (n <= -1)
|
||||
{
|
||||
hcl_server_logbfmt (server, HCL_LOG_APP | HCL_LOG_FATAL, "server error[%d] - %js\n", hcl_server_geterrnum(server), hcl_server_geterrmsg(server));
|
||||
}
|
||||
|
||||
if (xtn->logfd >= 0)
|
||||
{
|
||||
close (xtn->logfd);
|
||||
xtn->logfd = -1;
|
||||
xtn->logfd_istty = 0;
|
||||
}
|
||||
|
||||
hcl_server_close (server);
|
||||
return n;
|
||||
|
||||
oops:
|
||||
if (server) hcl_server_close (server);
|
||||
return -1;
|
||||
}
|
1284
bin/main.c
Normal file
1284
bin/main.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user