diff --git a/bin/Makefile.am b/bin/Makefile.am index 79c4126..115ef03 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -24,27 +24,21 @@ LIBADD_COMMON += $(DL_LIBS) endif bin_PROGRAMS = hcl -hcl_SOURCES = main.c +hcl_SOURCES = hcl.c hcl_CPPFLAGS = $(CPPFLAGS_COMMON) hcl_LDFLAGS = $(LDFLAGS_COMMON) hcl_LDADD = ../lib/libhcl.la $(LIBADD_COMMON) if ENABLE_HCLX -bin_PROGRAMS += hcls -hcls_SOURCES = main-s.c -hcls_CPPFLAGS = $(CPPFLAGS_COMMON) -hcls_LDFLAGS = $(LDFLAGS_COMMON) -hcls_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) - -bin_PROGRAMS += hclc -hclc_SOURCES = main-c.c -hclc_CPPFLAGS = $(CPPFLAGS_COMMON) -hclc_LDFLAGS = $(LDFLAGS_COMMON) -hclc_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) +bin_PROGRAMS += hclx +hclx_SOURCES = hclx.c +hclx_CPPFLAGS = $(CPPFLAGS_COMMON) +hclx_LDFLAGS = $(LDFLAGS_COMMON) +hclx_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) bin_PROGRAMS += hclj -hclj_SOURCES = main-j.c +hclj_SOURCES = hclj.c hclj_CPPFLAGS = $(CPPFLAGS_COMMON) hclj_LDFLAGS = $(LDFLAGS_COMMON) hclj_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) diff --git a/bin/Makefile.in b/bin/Makefile.in index 3e9dbe6..3ad25de 100644 --- a/bin/Makefile.in +++ b/bin/Makefile.in @@ -95,7 +95,7 @@ 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_HCLX_TRUE@am__append_3 = hcls hclc hclj +@ENABLE_HCLX_TRUE@am__append_3 = hclx hclj subdir = bin ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \ @@ -110,11 +110,10 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/lib/hcl-cfg.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -@ENABLE_HCLX_TRUE@am__EXEEXT_1 = hcls$(EXEEXT) hclc$(EXEEXT) \ -@ENABLE_HCLX_TRUE@ hclj$(EXEEXT) +@ENABLE_HCLX_TRUE@am__EXEEXT_1 = hclx$(EXEEXT) hclj$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_hcl_OBJECTS = hcl-main.$(OBJEXT) +am_hcl_OBJECTS = hcl-hcl.$(OBJEXT) hcl_OBJECTS = $(am_hcl_OBJECTS) am__DEPENDENCIES_1 = @ENABLE_LIBLTDL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) @@ -128,30 +127,22 @@ 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_HCLX_TRUE@am_hclc_OBJECTS = hclc-main-c.$(OBJEXT) -hclc_OBJECTS = $(am_hclc_OBJECTS) -@ENABLE_HCLX_TRUE@hclc_DEPENDENCIES = ../lib/libhclx.la \ -@ENABLE_HCLX_TRUE@ $(am__DEPENDENCIES_4) -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_HCLX_TRUE@am_hclj_OBJECTS = hclj-main-j.$(OBJEXT) +am__hclj_SOURCES_DIST = hclj.c +@ENABLE_HCLX_TRUE@am_hclj_OBJECTS = hclj-hclj.$(OBJEXT) hclj_OBJECTS = $(am_hclj_OBJECTS) @ENABLE_HCLX_TRUE@hclj_DEPENDENCIES = ../lib/libhclx.la \ @ENABLE_HCLX_TRUE@ $(am__DEPENDENCIES_4) 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_HCLX_TRUE@am_hcls_OBJECTS = hcls-main-s.$(OBJEXT) -hcls_OBJECTS = $(am_hcls_OBJECTS) -@ENABLE_HCLX_TRUE@hcls_DEPENDENCIES = ../lib/libhclx.la \ +am__hclx_SOURCES_DIST = hclx.c +@ENABLE_HCLX_TRUE@am_hclx_OBJECTS = hclx-hclx.$(OBJEXT) +hclx_OBJECTS = $(am_hclx_OBJECTS) +@ENABLE_HCLX_TRUE@hclx_DEPENDENCIES = ../lib/libhclx.la \ @ENABLE_HCLX_TRUE@ $(am__DEPENDENCIES_4) -hcls_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ +hclx_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(hcls_LDFLAGS) $(LDFLAGS) -o $@ + $(hclx_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 @@ -167,9 +158,8 @@ am__v_at_1 = DEFAULT_INCLUDES = depcomp = $(SHELL) $(top_srcdir)/ac/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/hcl-main.Po \ - ./$(DEPDIR)/hclc-main-c.Po ./$(DEPDIR)/hclj-main-j.Po \ - ./$(DEPDIR)/hcls-main-s.Po +am__depfiles_remade = ./$(DEPDIR)/hcl-hcl.Po ./$(DEPDIR)/hclj-hclj.Po \ + ./$(DEPDIR)/hclx-hclx.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -189,10 +179,9 @@ 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) +SOURCES = $(hcl_SOURCES) $(hclj_SOURCES) $(hclx_SOURCES) +DIST_SOURCES = $(hcl_SOURCES) $(am__hclj_SOURCES_DIST) \ + $(am__hclx_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -369,19 +358,15 @@ CPPFLAGS_COMMON = \ CFLAGS_COMMON = LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir) LIBADD_COMMON = $(am__append_1) $(am__append_2) -hcl_SOURCES = main.c +hcl_SOURCES = hcl.c hcl_CPPFLAGS = $(CPPFLAGS_COMMON) hcl_LDFLAGS = $(LDFLAGS_COMMON) hcl_LDADD = ../lib/libhcl.la $(LIBADD_COMMON) -@ENABLE_HCLX_TRUE@hcls_SOURCES = main-s.c -@ENABLE_HCLX_TRUE@hcls_CPPFLAGS = $(CPPFLAGS_COMMON) -@ENABLE_HCLX_TRUE@hcls_LDFLAGS = $(LDFLAGS_COMMON) -@ENABLE_HCLX_TRUE@hcls_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) -@ENABLE_HCLX_TRUE@hclc_SOURCES = main-c.c -@ENABLE_HCLX_TRUE@hclc_CPPFLAGS = $(CPPFLAGS_COMMON) -@ENABLE_HCLX_TRUE@hclc_LDFLAGS = $(LDFLAGS_COMMON) -@ENABLE_HCLX_TRUE@hclc_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) -@ENABLE_HCLX_TRUE@hclj_SOURCES = main-j.c +@ENABLE_HCLX_TRUE@hclx_SOURCES = hclx.c +@ENABLE_HCLX_TRUE@hclx_CPPFLAGS = $(CPPFLAGS_COMMON) +@ENABLE_HCLX_TRUE@hclx_LDFLAGS = $(LDFLAGS_COMMON) +@ENABLE_HCLX_TRUE@hclx_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) +@ENABLE_HCLX_TRUE@hclj_SOURCES = hclj.c @ENABLE_HCLX_TRUE@hclj_CPPFLAGS = $(CPPFLAGS_COMMON) @ENABLE_HCLX_TRUE@hclj_LDFLAGS = $(LDFLAGS_COMMON) @ENABLE_HCLX_TRUE@hclj_LDADD = ../lib/libhclx.la $(LIBADD_COMMON) @@ -472,17 +457,13 @@ 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) +hclx$(EXEEXT): $(hclx_OBJECTS) $(hclx_DEPENDENCIES) $(EXTRA_hclx_DEPENDENCIES) + @rm -f hclx$(EXEEXT) + $(AM_V_CCLD)$(hclx_LINK) $(hclx_OBJECTS) $(hclx_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -490,10 +471,9 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcl-main.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclc-main-c.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclj-main-j.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcls-main-s.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hcl-hcl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclj-hclj.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hclx-hclx.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -525,61 +505,47 @@ am--depfiles: $(am__depfiles_remade) @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@ +hcl-hcl.o: hcl.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcl-hcl.o -MD -MP -MF $(DEPDIR)/hcl-hcl.Tpo -c -o hcl-hcl.o `test -f 'hcl.c' || echo '$(srcdir)/'`hcl.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcl-hcl.Tpo $(DEPDIR)/hcl-hcl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hcl.c' object='hcl-hcl.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 +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcl-hcl.o `test -f 'hcl.c' || echo '$(srcdir)/'`hcl.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@ +hcl-hcl.obj: hcl.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hcl-hcl.obj -MD -MP -MF $(DEPDIR)/hcl-hcl.Tpo -c -o hcl-hcl.obj `if test -f 'hcl.c'; then $(CYGPATH_W) 'hcl.c'; else $(CYGPATH_W) '$(srcdir)/hcl.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hcl-hcl.Tpo $(DEPDIR)/hcl-hcl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hcl.c' object='hcl-hcl.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` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hcl_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hcl-hcl.obj `if test -f 'hcl.c'; then $(CYGPATH_W) 'hcl.c'; else $(CYGPATH_W) '$(srcdir)/hcl.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@ +hclj-hclj.o: hclj.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclj-hclj.o -MD -MP -MF $(DEPDIR)/hclj-hclj.Tpo -c -o hclj-hclj.o `test -f 'hclj.c' || echo '$(srcdir)/'`hclj.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclj-hclj.Tpo $(DEPDIR)/hclj-hclj.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hclj.c' object='hclj-hclj.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 +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclj-hclj.o `test -f 'hclj.c' || echo '$(srcdir)/'`hclj.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@ +hclj-hclj.obj: hclj.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclj-hclj.obj -MD -MP -MF $(DEPDIR)/hclj-hclj.Tpo -c -o hclj-hclj.obj `if test -f 'hclj.c'; then $(CYGPATH_W) 'hclj.c'; else $(CYGPATH_W) '$(srcdir)/hclj.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclj-hclj.Tpo $(DEPDIR)/hclj-hclj.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hclj.c' object='hclj-hclj.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` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclj_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclj-hclj.obj `if test -f 'hclj.c'; then $(CYGPATH_W) 'hclj.c'; else $(CYGPATH_W) '$(srcdir)/hclj.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@ +hclx-hclx.o: hclx.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclx-hclx.o -MD -MP -MF $(DEPDIR)/hclx-hclx.Tpo -c -o hclx-hclx.o `test -f 'hclx.c' || echo '$(srcdir)/'`hclx.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclx-hclx.Tpo $(DEPDIR)/hclx-hclx.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hclx.c' object='hclx-hclx.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 +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclx-hclx.o `test -f 'hclx.c' || echo '$(srcdir)/'`hclx.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@ +hclx-hclx.obj: hclx.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hclx-hclx.obj -MD -MP -MF $(DEPDIR)/hclx-hclx.Tpo -c -o hclx-hclx.obj `if test -f 'hclx.c'; then $(CYGPATH_W) 'hclx.c'; else $(CYGPATH_W) '$(srcdir)/hclx.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hclx-hclx.Tpo $(DEPDIR)/hclx-hclx.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hclx.c' object='hclx-hclx.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` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hclx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hclx-hclx.obj `if test -f 'hclx.c'; then $(CYGPATH_W) 'hclx.c'; else $(CYGPATH_W) '$(srcdir)/hclx.c'; fi` mostlyclean-libtool: -rm -f *.lo @@ -713,10 +679,9 @@ clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am distclean: distclean-am - -rm -f ./$(DEPDIR)/hcl-main.Po - -rm -f ./$(DEPDIR)/hclc-main-c.Po - -rm -f ./$(DEPDIR)/hclj-main-j.Po - -rm -f ./$(DEPDIR)/hcls-main-s.Po + -rm -f ./$(DEPDIR)/hcl-hcl.Po + -rm -f ./$(DEPDIR)/hclj-hclj.Po + -rm -f ./$(DEPDIR)/hclx-hclx.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -762,10 +727,9 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/hcl-main.Po - -rm -f ./$(DEPDIR)/hclc-main-c.Po - -rm -f ./$(DEPDIR)/hclj-main-j.Po - -rm -f ./$(DEPDIR)/hcls-main-s.Po + -rm -f ./$(DEPDIR)/hcl-hcl.Po + -rm -f ./$(DEPDIR)/hclj-hclj.Po + -rm -f ./$(DEPDIR)/hclx-hclx.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/bin/main.c b/bin/hcl.c similarity index 100% rename from bin/main.c rename to bin/hcl.c diff --git a/bin/main-j.c b/bin/hclj.c similarity index 100% rename from bin/main-j.c rename to bin/hclj.c diff --git a/bin/main-s.c b/bin/hclx.c similarity index 76% rename from bin/main-s.c rename to bin/hclx.c index 860082b..ae55d27 100644 --- a/bin/main-s.c +++ b/bin/hclx.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #if defined(HAVE_TIME_H) # include @@ -48,8 +50,6 @@ # include #endif -#include -#include /* ========================================================================= */ @@ -67,6 +67,9 @@ struct server_xtn_t } logbuf; }; + +typedef server_xtn_t client_xtn_t; + /* ========================================================================= */ static void* sys_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size) @@ -128,10 +131,8 @@ static int write_all (int fd, const hcl_bch_t* ptr, hcl_oow_t len) } -static int write_log (hcl_server_t* server, int fd, const hcl_bch_t* ptr, hcl_oow_t len) +static int write_log (server_xtn_t* xtn, 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) @@ -177,10 +178,8 @@ static int write_log (hcl_server_t* server, int fd, const hcl_bch_t* ptr, hcl_oo return 0; } -static void flush_log (hcl_server_t* server, int fd) +static void flush_log (server_xtn_t* xtn, 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); @@ -188,9 +187,8 @@ static void flush_log (hcl_server_t* server, int fd) } } -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) +static void log_write (server_xtn_t* xtn, 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; @@ -243,21 +241,21 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask, tslen = 25; } - write_log (server, logfd, ts, tslen); + write_log (xtn, 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); + write_log (xtn, 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 (mask & HCL_LOG_FATAL) write_log (xtn, logfd, "\x1B[1;31m", 7); + else if (mask & HCL_LOG_ERROR) write_log (xtn, logfd, "\x1B[1;32m", 7); + else if (mask & HCL_LOG_WARN) write_log (xtn, logfd, "\x1B[1;33m", 7); } #if defined(HCL_OOCH_IS_UCH) @@ -280,7 +278,7 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask, /*assert (ucslen > 0);*/ /* attempt to write all converted characters */ - if (write_log(server, logfd, buf, bcslen) <= -1) break; + if (write_log(xtn, logfd, buf, bcslen) <= -1) break; if (n == 0) break; else @@ -293,26 +291,39 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask, { /* conversion error */ if (bcslen <= 0) break; - if (write_log(server, logfd, buf, bcslen) <= -1) break; + if (write_log(xtn, logfd, buf, bcslen) <= -1) break; msgidx += ucslen; len -= ucslen; } } #else - write_log (server, logfd, msg, len); + write_log (xtn, 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); + if (mask & (HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN)) write_log (xtn, logfd, "\x1B[0m", 4); } - flush_log (server, logfd); + flush_log (xtn, logfd); +} + +/* ========================================================================= */ + +static void server_log_write (hcl_server_t* server, hcl_oow_t wid, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len) +{ + log_write ((server_xtn_t*)hcl_server_getxtn(server), wid, mask, msg, len); +} + +static void client_log_write (hcl_client_t* client, hcl_bitmask_t mask, const hcl_ooch_t* msg, hcl_oow_t len) +{ + log_write ((client_xtn_t*)hcl_client_getxtn(client), HCL_SERVER_WID_INVALID, mask, msg, len); } /* ========================================================================= */ static hcl_server_t* g_server = HCL_NULL; +static hcl_client_t* g_client = HCL_NULL; /* ========================================================================= */ @@ -321,6 +332,7 @@ 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); + if (g_client) hcl_client_stop (g_client); } static void set_signal (int sig, signal_handler_t handler) @@ -498,7 +510,7 @@ static int handle_incpath (hcl_server_t* server, const char* str) #define MIN_WORKER_STACK_SIZE 512000ul #define MIN_ACTOR_HEAP_SIZE 512000ul -int server_main (const char* outer, int argc, char* argv[]) +static int server_main (const char* outer, int argc, char* argv[]) { hcl_bci_t c; static hcl_bopt_lng_t lopt[] = @@ -540,7 +552,7 @@ int server_main (const char* outer, int argc, char* argv[]) if (argc < 2) { print_usage: - fprintf (stderr, "Usage: %s bind-address:port\n", argv[0]); + fprintf (stderr, "Usage: %s %s bind-address:port\n", outer, argv[0]); return -1; } @@ -604,7 +616,7 @@ int server_main (const char* outer, int argc, char* argv[]) if (opt.ind >= argc) goto print_usage; memset (&server_prim, 0, HCL_SIZEOF(server_prim)); - server_prim.log_write = log_write; + server_prim.log_write = server_log_write; server = hcl_server_open(&sys_mmgr, HCL_SIZEOF(server_xtn_t), &server_prim, HCL_NULL); if (!server) @@ -675,25 +687,177 @@ oops: return -1; } +/* -------------------------------------------------------------- */ +static int client_on_packet (hcl_xproto_t* proto, hcl_xpkt_type_t type, const void* data, hcl_oow_t len) +{ + if (type == HCL_XPKT_STDOUT) + { + if (len > 0) fprintf (stdout, "%.*s", (int)len, data); + } + else if (type == HCL_XPKT_STDERR) + { + if (len > 0) fprintf (stderr, "%.*s", (int)len, data); + } + else if (type == HCL_XPKT_ERROR) + { + /* error notification */ + if (len > 0) fprintf (stderr, "ERROR: %.*s\n", (int)len, data); + } + return 1; +} + +static int client_main (const char* outer, 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 %s [options] bind-address:port script-to-run\n", outer, argv[0]); + fprintf (stderr, "Options are:\n"); + fprintf (stderr, " -l/--log log-options\n"); + fprintf (stderr, " --reuseaddr\n"); + fprintf (stderr, " --shutwr\n"); + 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 = client_log_write; + client_prim.on_packet = client_on_packet; + + 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 = hcl_client_start(client, argv[opt.ind], argv[opt.ind + 1], reuse_addr, shut_wr_after_req); + if (n <= -1) + { + fprintf (stderr, "ERROR: %s\n", hcl_client_geterrbmsg(client)); + goto oops; + } + + 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; +} /* -------------------------------------------------------------- */ static void print_main_usage (const char* argv0) { - fprintf (stderr, "USAGE: %s server|client\n"); + fprintf (stderr, "Usage: %s server|client\n", argv0); } int main (int argc, char* argv[]) { int n; + const char* argv0; + + argv0 = hcl_get_base_name_from_bcstr_path(argv[0]); if (argc < 2) { - print_main_usage (argv[0]); + print_main_usage (argv0); n = -1; } else if (strcmp(argv[1], "server") == 0) { - n = server_main(argv[0], argc -1, &argv[1]); + n = server_main(argv0, argc -1, &argv[1]); } else if (strcmp(argv[1], "client") == 0) { diff --git a/lib/hcl-cmn.h b/lib/hcl-cmn.h index 5ab0e34..82f90bd 100644 --- a/lib/hcl-cmn.h +++ b/lib/hcl-cmn.h @@ -898,6 +898,12 @@ typedef struct hcl_t hcl_t; # undef HCL_HAVE_INLINE #endif +#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4)) +# define HCL_SENTINEL(v) __attribute__((__sentinel__(x))) +#else +# define HCL_SENTINEL(v) +#endif + #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)) # define HCL_UNUSED __attribute__((__unused__)) #else @@ -962,22 +968,24 @@ typedef struct hcl_t hcl_t; /* ========================================================================= * COMPILER FEATURE TEST MACROS * =========================================================================*/ +#if !defined(__has_attribute) + #define __has_attribute(x) 0 +#endif + #if !defined(__has_builtin) && defined(_INTELC32_) /* intel c code builder 1.0 ended up with an error without this override */ #define __has_builtin(x) 0 #endif /* +#if !defined(__has_feature) + #define __has_feature(x) 0 +#endif #if !defined(__is_identifier) #define __is_identifier(x) 0 #endif - -#if !defined(__has_attribute) - #define __has_attribute(x) 0 -#endif */ - #if defined(__has_builtin) #if __has_builtin(__builtin_ctz) #define HCL_HAVE_BUILTIN_CTZ diff --git a/lib/hcl-utl.h b/lib/hcl-utl.h index 8674c4d..5eed634 100644 --- a/lib/hcl-utl.h +++ b/lib/hcl-utl.h @@ -943,6 +943,24 @@ HCL_EXPORT void hcl_sub_ntime ( const hcl_ntime_t* y ); +/* ========================================================================= + * PATH NAME + * ========================================================================= */ + +const hcl_bch_t* hcl_get_base_name_from_bcstr_path ( + const hcl_bch_t* path +); + +const hcl_uch_t* hcl_get_base_name_from_ucstr_path ( + const hcl_uch_t* path +); + +#if defined(HCL_OOCH_IS_UCH) +#define hcl_get_base_name_from_path(x) hcl_get_base_name_from_ucstr_path(x) +#else +#define hcl_get_base_name_from_path(x) hcl_get_base_name_from_bcstr_path(x) +#endif + /* ========================================================================= * BIT SWAP * ========================================================================= */ diff --git a/lib/hcl-x.h b/lib/hcl-x.h index e2b2736..f550dff 100644 --- a/lib/hcl-x.h +++ b/lib/hcl-x.h @@ -323,6 +323,10 @@ HCL_EXPORT int hcl_client_start ( int shut_wr_after_req ); +HCL_EXPORT void hcl_client_stop ( + hcl_client_t* client +); + HCL_EXPORT int hcl_client_setoption ( hcl_client_t* client, hcl_client_option_t id, diff --git a/lib/std.c b/lib/std.c index bc55e36..9d0c601 100644 --- a/lib/std.c +++ b/lib/std.c @@ -3291,18 +3291,6 @@ struct bb_t hcl_bch_t* fn; }; -static const hcl_bch_t* get_base_name (const hcl_bch_t* path) -{ - const hcl_bch_t* p, * last = HCL_NULL; - - for (p = path; *p != '\0'; p++) - { - if (HCL_IS_PATH_SEP(*p)) last = p; - } - - return (last == HCL_NULL)? path: (last + 1); -} - #if defined(__DOS__) || defined(_WIN32) || defined(__OS2__) #define FOPEN_R_FLAGS "rb" #else @@ -3329,7 +3317,7 @@ static HCL_INLINE int open_cci_stream (hcl_t* hcl, hcl_io_cciarg_t* arg) fn = ((bb_t*)arg->includer->handle)->fn; - fb = get_base_name(fn); + fb = hcl_get_base_name_from_bcstr_path(fn); parlen = fb - fn; bb = (bb_t*)hcl_callocmem(hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (parlen + bcslen + 1))); diff --git a/lib/utl.c b/lib/utl.c index 7756d6c..d6e80e6 100644 --- a/lib/utl.c +++ b/lib/utl.c @@ -1330,3 +1330,28 @@ void hcl_sub_ntime (hcl_ntime_t* z, const hcl_ntime_t* x, const hcl_ntime_t* y) z->nsec = ns; } +/* ----------------------------------------------------------------------- */ + +const hcl_bch_t* hcl_get_base_name_from_bcstr_path (const hcl_bch_t* path) +{ + const hcl_bch_t* p, * last = HCL_NULL; + + for (p = path; *p != '\0'; p++) + { + if (HCL_IS_PATH_SEP(*p)) last = p; + } + + return (last == HCL_NULL)? path: (last + 1); +} + +const hcl_uch_t* hcl_get_base_name_from_ucstr_path (const hcl_uch_t* path) +{ + const hcl_uch_t* p, * last = HCL_NULL; + + for (p = path; *p != '\0'; p++) + { + if (HCL_IS_PATH_SEP(*p)) last = p; + } + + return (last == HCL_NULL)? path: (last + 1); +} diff --git a/lib/x-client.c b/lib/x-client.c index f4c80f2..98f0ac0 100644 --- a/lib/x-client.c +++ b/lib/x-client.c @@ -636,3 +636,8 @@ oops: return -1; } +void hcl_client_stop (hcl_client_t* client) +{ + /* TODO: */ + /* TODO: break the cleint loop */ +} diff --git a/lib/x-server.c b/lib/x-server.c index 379c39a..5be9404 100644 --- a/lib/x-server.c +++ b/lib/x-server.c @@ -254,18 +254,6 @@ static int send_stdout_chars (hcl_xproto_t* proto, int xpkt_code, const hcl_ooch /* ========================================================================= */ -static const hcl_bch_t* get_base_name (const hcl_bch_t* path) -{ - const hcl_bch_t* p, * last = HCL_NULL; - - for (p = path; *p != '\0'; p++) - { - if (HCL_IS_PATH_SEP(*p)) last = p; - } - - return (last == HCL_NULL)? path: (last + 1); -} - static HCL_INLINE int open_read_stream (hcl_t* hcl, hcl_io_cciarg_t* arg) { worker_hcl_xtn_t* xtn = (worker_hcl_xtn_t*)hcl_getxtn(hcl); @@ -299,7 +287,7 @@ static HCL_INLINE int open_read_stream (hcl_t* hcl, hcl_io_cciarg_t* arg) } else { - fb = get_base_name(fn); + fb = hcl_get_base_name_from_bcstr_path(fn); parlen = fb - fn; }