added more code for handling pipes to a child process
This commit is contained in:
		@ -15,18 +15,18 @@ CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) $(LTDLINCL)
 | 
			
		||||
LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
 | 
			
		||||
LIBADD_LIB_COMMON = $(LIBM) $(LIBLTDL) 
 | 
			
		||||
 | 
			
		||||
pkgincludedir = $(includedir)
 | 
			
		||||
pkglibdir = $(libdir)
 | 
			
		||||
pkgbindir = $(bindir)
 | 
			
		||||
#pkgincludedir = $(includedir)
 | 
			
		||||
#pkglibdir = $(libdir)
 | 
			
		||||
#pkgbindir = $(bindir)
 | 
			
		||||
 | 
			
		||||
pkginclude_HEADERS = \
 | 
			
		||||
include_HEADERS = \
 | 
			
		||||
	stio-cfg.h \
 | 
			
		||||
	stio-cmn.h \
 | 
			
		||||
	stio-pro.h \
 | 
			
		||||
	stio-sck.h \
 | 
			
		||||
	stio.h
 | 
			
		||||
 | 
			
		||||
pkglib_LTLIBRARIES = libstio.la
 | 
			
		||||
lib_LTLIBRARIES = libstio.la
 | 
			
		||||
libstio_la_SOURCES = \
 | 
			
		||||
	stio-prv.h \
 | 
			
		||||
	stio.c \
 | 
			
		||||
@ -38,7 +38,7 @@ libstio_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
 | 
			
		||||
libstio_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
 | 
			
		||||
libstio_la_LIBADD = $(LIBADD_LIB_COMMON)
 | 
			
		||||
 | 
			
		||||
pkgbin_PROGRAMS = stio
 | 
			
		||||
bin_PROGRAMS = stio
 | 
			
		||||
stio_SOURCES = main.c
 | 
			
		||||
stio_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
 | 
			
		||||
stio_LDFLAGS = $(LDFLAGS_LIB_COMMON)
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,9 @@
 | 
			
		||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
 | 
			
		||||
# Makefile.in generated by automake 1.11.6 from Makefile.am.
 | 
			
		||||
# @configure_input@
 | 
			
		||||
 | 
			
		||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
 | 
			
		||||
 | 
			
		||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 | 
			
		||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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.
 | 
			
		||||
@ -17,52 +18,26 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
VPATH = @srcdir@
 | 
			
		||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
 | 
			
		||||
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 \
 | 
			
		||||
am__make_dryrun = \
 | 
			
		||||
  { \
 | 
			
		||||
    am__dry=no; \
 | 
			
		||||
    case $$MAKEFLAGS in \
 | 
			
		||||
      *\\[\ \	]*) \
 | 
			
		||||
        bs=\\; \
 | 
			
		||||
        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
 | 
			
		||||
          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
 | 
			
		||||
        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
 | 
			
		||||
          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
 | 
			
		||||
      *) \
 | 
			
		||||
        for am__flg in $$MAKEFLAGS; do \
 | 
			
		||||
          case $$am__flg in \
 | 
			
		||||
            *=*|--*) ;; \
 | 
			
		||||
            *n*) am__dry=yes; break;; \
 | 
			
		||||
          esac; \
 | 
			
		||||
        done;; \
 | 
			
		||||
    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))
 | 
			
		||||
    test $$am__dry = yes; \
 | 
			
		||||
  }
 | 
			
		||||
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
 | 
			
		||||
@ -78,11 +53,10 @@ PRE_UNINSTALL = :
 | 
			
		||||
POST_UNINSTALL = :
 | 
			
		||||
build_triplet = @build@
 | 
			
		||||
host_triplet = @host@
 | 
			
		||||
pkgbin_PROGRAMS = stio$(EXEEXT)
 | 
			
		||||
bin_PROGRAMS = stio$(EXEEXT)
 | 
			
		||||
subdir = lib
 | 
			
		||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 | 
			
		||||
	$(srcdir)/stio-cfg.h.in $(top_srcdir)/ac/depcomp \
 | 
			
		||||
	$(pkginclude_HEADERS)
 | 
			
		||||
DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
 | 
			
		||||
	$(srcdir)/Makefile.in $(srcdir)/stio-cfg.h.in
 | 
			
		||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 | 
			
		||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
 | 
			
		||||
	$(top_srcdir)/m4/ax_cxx_namespace.m4 \
 | 
			
		||||
@ -123,9 +97,9 @@ am__uninstall_files_from_dir = { \
 | 
			
		||||
    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
 | 
			
		||||
         $(am__cd) "$$dir" && rm -f $$files; }; \
 | 
			
		||||
  }
 | 
			
		||||
am__installdirs = "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(pkgbindir)" \
 | 
			
		||||
	"$(DESTDIR)$(pkgincludedir)"
 | 
			
		||||
LTLIBRARIES = $(pkglib_LTLIBRARIES)
 | 
			
		||||
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
 | 
			
		||||
	"$(DESTDIR)$(includedir)"
 | 
			
		||||
LTLIBRARIES = $(lib_LTLIBRARIES)
 | 
			
		||||
am__DEPENDENCIES_1 =
 | 
			
		||||
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
 | 
			
		||||
libstio_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
 | 
			
		||||
@ -136,29 +110,16 @@ libstio_la_OBJECTS = $(am_libstio_la_OBJECTS)
 | 
			
		||||
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 = 
 | 
			
		||||
libstio_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 | 
			
		||||
	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 | 
			
		||||
	$(libstio_la_LDFLAGS) $(LDFLAGS) -o $@
 | 
			
		||||
PROGRAMS = $(pkgbin_PROGRAMS)
 | 
			
		||||
PROGRAMS = $(bin_PROGRAMS)
 | 
			
		||||
am_stio_OBJECTS = stio-main.$(OBJEXT)
 | 
			
		||||
stio_OBJECTS = $(am_stio_OBJECTS)
 | 
			
		||||
stio_DEPENDENCIES = $(am__DEPENDENCIES_2)
 | 
			
		||||
stio_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 | 
			
		||||
	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 | 
			
		||||
	$(stio_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
 | 
			
		||||
@ -171,16 +132,20 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 | 
			
		||||
	$(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 = 
 | 
			
		||||
am__v_CC_0 = @echo "  CC    " $@;
 | 
			
		||||
AM_V_at = $(am__v_at_@AM_V@)
 | 
			
		||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
 | 
			
		||||
am__v_at_0 = @
 | 
			
		||||
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 = 
 | 
			
		||||
am__v_CCLD_0 = @echo "  CCLD  " $@;
 | 
			
		||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
 | 
			
		||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
 | 
			
		||||
am__v_GEN_0 = @echo "  GEN   " $@;
 | 
			
		||||
SOURCES = $(libstio_la_SOURCES) $(stio_SOURCES)
 | 
			
		||||
DIST_SOURCES = $(libstio_la_SOURCES) $(stio_SOURCES)
 | 
			
		||||
am__can_run_installinfo = \
 | 
			
		||||
@ -188,30 +153,10 @@ am__can_run_installinfo = \
 | 
			
		||||
    n|no|NO) false;; \
 | 
			
		||||
    *) (install-info --version) >/dev/null 2>&1;; \
 | 
			
		||||
  esac
 | 
			
		||||
HEADERS = $(pkginclude_HEADERS)
 | 
			
		||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
 | 
			
		||||
	$(LISP)stio-cfg.h.in
 | 
			
		||||
# 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)`
 | 
			
		||||
HEADERS = $(include_HEADERS)
 | 
			
		||||
ETAGS = etags
 | 
			
		||||
CTAGS = ctags
 | 
			
		||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 | 
			
		||||
pkgincludedir = $(includedir)
 | 
			
		||||
pkglibdir = $(libdir)
 | 
			
		||||
ACLOCAL = @ACLOCAL@
 | 
			
		||||
AMTAR = @AMTAR@
 | 
			
		||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 | 
			
		||||
@ -375,15 +320,18 @@ LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(libdir)
 | 
			
		||||
CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) $(LTDLINCL)
 | 
			
		||||
LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
 | 
			
		||||
LIBADD_LIB_COMMON = $(LIBM) $(LIBLTDL) 
 | 
			
		||||
pkgbindir = $(bindir)
 | 
			
		||||
pkginclude_HEADERS = \
 | 
			
		||||
 | 
			
		||||
#pkgincludedir = $(includedir)
 | 
			
		||||
#pkglibdir = $(libdir)
 | 
			
		||||
#pkgbindir = $(bindir)
 | 
			
		||||
include_HEADERS = \
 | 
			
		||||
	stio-cfg.h \
 | 
			
		||||
	stio-cmn.h \
 | 
			
		||||
	stio-pro.h \
 | 
			
		||||
	stio-sck.h \
 | 
			
		||||
	stio.h
 | 
			
		||||
 | 
			
		||||
pkglib_LTLIBRARIES = libstio.la
 | 
			
		||||
lib_LTLIBRARIES = libstio.la
 | 
			
		||||
libstio_la_SOURCES = \
 | 
			
		||||
	stio-prv.h \
 | 
			
		||||
	stio.c \
 | 
			
		||||
@ -436,8 +384,8 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 | 
			
		||||
$(am__aclocal_m4_deps):
 | 
			
		||||
 | 
			
		||||
stio-cfg.h: stamp-h1
 | 
			
		||||
	@test -f $@ || rm -f stamp-h1
 | 
			
		||||
	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
 | 
			
		||||
	@if test ! -f $@; then rm -f stamp-h1; else :; fi
 | 
			
		||||
	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
 | 
			
		||||
 | 
			
		||||
stamp-h1: $(srcdir)/stio-cfg.h.in $(top_builddir)/config.status
 | 
			
		||||
	@rm -f stamp-h1
 | 
			
		||||
@ -449,59 +397,53 @@ $(srcdir)/stio-cfg.h.in:  $(am__configure_deps)
 | 
			
		||||
 | 
			
		||||
distclean-hdr:
 | 
			
		||||
	-rm -f stio-cfg.h stamp-h1
 | 
			
		||||
 | 
			
		||||
install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
 | 
			
		||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 | 
			
		||||
	@$(NORMAL_INSTALL)
 | 
			
		||||
	@list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
 | 
			
		||||
	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 | 
			
		||||
	list2=; for p in $$list; do \
 | 
			
		||||
	  if test -f $$p; then \
 | 
			
		||||
	    list2="$$list2 $$p"; \
 | 
			
		||||
	  else :; fi; \
 | 
			
		||||
	done; \
 | 
			
		||||
	test -z "$$list2" || { \
 | 
			
		||||
	  echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \
 | 
			
		||||
	  $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \
 | 
			
		||||
	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
 | 
			
		||||
	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
 | 
			
		||||
	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
 | 
			
		||||
	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
 | 
			
		||||
	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
 | 
			
		||||
	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
uninstall-pkglibLTLIBRARIES:
 | 
			
		||||
uninstall-libLTLIBRARIES:
 | 
			
		||||
	@$(NORMAL_UNINSTALL)
 | 
			
		||||
	@list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
 | 
			
		||||
	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 | 
			
		||||
	for p in $$list; do \
 | 
			
		||||
	  $(am__strip_dir) \
 | 
			
		||||
	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
 | 
			
		||||
	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
 | 
			
		||||
	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
 | 
			
		||||
	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
clean-pkglibLTLIBRARIES:
 | 
			
		||||
	-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
 | 
			
		||||
	@list='$(pkglib_LTLIBRARIES)'; \
 | 
			
		||||
	locs=`for p in $$list; do echo $$p; done | \
 | 
			
		||||
	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
 | 
			
		||||
	      sort -u`; \
 | 
			
		||||
	test -z "$$locs" || { \
 | 
			
		||||
	  echo rm -f $${locs}; \
 | 
			
		||||
	  rm -f $${locs}; \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
clean-libLTLIBRARIES:
 | 
			
		||||
	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
 | 
			
		||||
	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
 | 
			
		||||
	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
 | 
			
		||||
	  test "$$dir" != "$$p" || dir=.; \
 | 
			
		||||
	  echo "rm -f \"$${dir}/so_locations\""; \
 | 
			
		||||
	  rm -f "$${dir}/so_locations"; \
 | 
			
		||||
	done
 | 
			
		||||
libstio.la: $(libstio_la_OBJECTS) $(libstio_la_DEPENDENCIES) $(EXTRA_libstio_la_DEPENDENCIES) 
 | 
			
		||||
	$(AM_V_CCLD)$(libstio_la_LINK) -rpath $(pkglibdir) $(libstio_la_OBJECTS) $(libstio_la_LIBADD) $(LIBS)
 | 
			
		||||
install-pkgbinPROGRAMS: $(pkgbin_PROGRAMS)
 | 
			
		||||
	$(AM_V_CCLD)$(libstio_la_LINK) -rpath $(libdir) $(libstio_la_OBJECTS) $(libstio_la_LIBADD) $(LIBS)
 | 
			
		||||
install-binPROGRAMS: $(bin_PROGRAMS)
 | 
			
		||||
	@$(NORMAL_INSTALL)
 | 
			
		||||
	@list='$(pkgbin_PROGRAMS)'; test -n "$(pkgbindir)" || list=; \
 | 
			
		||||
	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
 | 
			
		||||
	if test -n "$$list"; then \
 | 
			
		||||
	  echo " $(MKDIR_P) '$(DESTDIR)$(pkgbindir)'"; \
 | 
			
		||||
	  $(MKDIR_P) "$(DESTDIR)$(pkgbindir)" || exit 1; \
 | 
			
		||||
	  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; \
 | 
			
		||||
	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|.*|.|' \
 | 
			
		||||
	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 } \
 | 
			
		||||
@ -512,31 +454,29 @@ install-pkgbinPROGRAMS: $(pkgbin_PROGRAMS)
 | 
			
		||||
	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)$(pkgbindir)$$dir'"; \
 | 
			
		||||
	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkgbindir)$$dir" || exit $$?; \
 | 
			
		||||
	    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-pkgbinPROGRAMS:
 | 
			
		||||
uninstall-binPROGRAMS:
 | 
			
		||||
	@$(NORMAL_UNINSTALL)
 | 
			
		||||
	@list='$(pkgbin_PROGRAMS)'; test -n "$(pkgbindir)" || list=; \
 | 
			
		||||
	@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)/' \
 | 
			
		||||
	`; \
 | 
			
		||||
	      -e 's/$$/$(EXEEXT)/' `; \
 | 
			
		||||
	test -n "$$list" || exit 0; \
 | 
			
		||||
	echo " ( cd '$(DESTDIR)$(pkgbindir)' && rm -f" $$files ")"; \
 | 
			
		||||
	cd "$(DESTDIR)$(pkgbindir)" && rm -f $$files
 | 
			
		||||
	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
 | 
			
		||||
	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 | 
			
		||||
 | 
			
		||||
clean-pkgbinPROGRAMS:
 | 
			
		||||
	@list='$(pkgbin_PROGRAMS)'; test -n "$$list" || exit 0; \
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
stio$(EXEEXT): $(stio_OBJECTS) $(stio_DEPENDENCIES) $(EXTRA_stio_DEPENDENCIES) 
 | 
			
		||||
	@rm -f stio$(EXEEXT)
 | 
			
		||||
	$(AM_V_CCLD)$(stio_LINK) $(stio_OBJECTS) $(stio_LDADD) $(LIBS)
 | 
			
		||||
@ -559,14 +499,14 @@ distclean-compile:
 | 
			
		||||
@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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 $@ $<
 | 
			
		||||
@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c $<
 | 
			
		||||
 | 
			
		||||
.c.obj:
 | 
			
		||||
@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
 | 
			
		||||
@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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) '$<'`
 | 
			
		||||
@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
 | 
			
		||||
 | 
			
		||||
.c.lo:
 | 
			
		||||
@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
 | 
			
		||||
@ -629,37 +569,48 @@ mostlyclean-libtool:
 | 
			
		||||
 | 
			
		||||
clean-libtool:
 | 
			
		||||
	-rm -rf .libs _libs
 | 
			
		||||
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
 | 
			
		||||
install-includeHEADERS: $(include_HEADERS)
 | 
			
		||||
	@$(NORMAL_INSTALL)
 | 
			
		||||
	@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
 | 
			
		||||
	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
 | 
			
		||||
	if test -n "$$list"; then \
 | 
			
		||||
	  echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \
 | 
			
		||||
	  $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \
 | 
			
		||||
	  echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
 | 
			
		||||
	  $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
 | 
			
		||||
	fi; \
 | 
			
		||||
	for p in $$list; do \
 | 
			
		||||
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 | 
			
		||||
	  echo "$$d$$p"; \
 | 
			
		||||
	done | $(am__base_list) | \
 | 
			
		||||
	while read files; do \
 | 
			
		||||
	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \
 | 
			
		||||
	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \
 | 
			
		||||
	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
 | 
			
		||||
	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
uninstall-pkgincludeHEADERS:
 | 
			
		||||
uninstall-includeHEADERS:
 | 
			
		||||
	@$(NORMAL_UNINSTALL)
 | 
			
		||||
	@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
 | 
			
		||||
	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
 | 
			
		||||
	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 | 
			
		||||
	dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir)
 | 
			
		||||
	dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
 | 
			
		||||
 | 
			
		||||
ID: $(am__tagged_files)
 | 
			
		||||
	$(am__define_uniq_tagged_files); mkid -fID $$unique
 | 
			
		||||
tags: tags-am
 | 
			
		||||
TAGS: tags
 | 
			
		||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 | 
			
		||||
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 | 
			
		||||
	unique=`for i in $$list; do \
 | 
			
		||||
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 | 
			
		||||
	  done | \
 | 
			
		||||
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 | 
			
		||||
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 | 
			
		||||
	mkid -fID $$unique
 | 
			
		||||
tags: TAGS
 | 
			
		||||
 | 
			
		||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 | 
			
		||||
TAGS:  $(HEADERS) $(SOURCES) stio-cfg.h.in $(TAGS_DEPENDENCIES) \
 | 
			
		||||
		$(TAGS_FILES) $(LISP)
 | 
			
		||||
	set x; \
 | 
			
		||||
	here=`pwd`; \
 | 
			
		||||
	$(am__define_uniq_tagged_files); \
 | 
			
		||||
	list='$(SOURCES) $(HEADERS) stio-cfg.h.in $(LISP) $(TAGS_FILES)'; \
 | 
			
		||||
	unique=`for i in $$list; do \
 | 
			
		||||
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 | 
			
		||||
	  done | \
 | 
			
		||||
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 | 
			
		||||
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 | 
			
		||||
	shift; \
 | 
			
		||||
	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 | 
			
		||||
	  test -n "$$unique" || unique=$$empty_fix; \
 | 
			
		||||
@ -671,11 +622,15 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 | 
			
		||||
	      $$unique; \
 | 
			
		||||
	  fi; \
 | 
			
		||||
	fi
 | 
			
		||||
ctags: ctags-am
 | 
			
		||||
 | 
			
		||||
CTAGS: ctags
 | 
			
		||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 | 
			
		||||
	$(am__define_uniq_tagged_files); \
 | 
			
		||||
ctags: CTAGS
 | 
			
		||||
CTAGS:  $(HEADERS) $(SOURCES) stio-cfg.h.in $(TAGS_DEPENDENCIES) \
 | 
			
		||||
		$(TAGS_FILES) $(LISP)
 | 
			
		||||
	list='$(SOURCES) $(HEADERS) stio-cfg.h.in $(LISP) $(TAGS_FILES)'; \
 | 
			
		||||
	unique=`for i in $$list; do \
 | 
			
		||||
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 | 
			
		||||
	  done | \
 | 
			
		||||
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 | 
			
		||||
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 | 
			
		||||
	test -z "$(CTAGS_ARGS)$$unique" \
 | 
			
		||||
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 | 
			
		||||
	     $$unique
 | 
			
		||||
@ -684,21 +639,6 @@ 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
 | 
			
		||||
@ -736,8 +676,10 @@ distdir: $(DISTFILES)
 | 
			
		||||
check-am: all-am
 | 
			
		||||
check: check-am
 | 
			
		||||
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) stio-cfg.h
 | 
			
		||||
install-binPROGRAMS: install-libLTLIBRARIES
 | 
			
		||||
 | 
			
		||||
installdirs:
 | 
			
		||||
	for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(pkgbindir)" "$(DESTDIR)$(pkgincludedir)"; do \
 | 
			
		||||
	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \
 | 
			
		||||
	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 | 
			
		||||
	done
 | 
			
		||||
install: install-am
 | 
			
		||||
@ -772,8 +714,8 @@ maintainer-clean-generic:
 | 
			
		||||
	@echo "it deletes files that may require special tools to rebuild."
 | 
			
		||||
clean: clean-am
 | 
			
		||||
 | 
			
		||||
clean-am: clean-generic clean-libtool clean-pkgbinPROGRAMS \
 | 
			
		||||
	clean-pkglibLTLIBRARIES mostlyclean-am
 | 
			
		||||
clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
 | 
			
		||||
	clean-libtool mostlyclean-am
 | 
			
		||||
 | 
			
		||||
distclean: distclean-am
 | 
			
		||||
	-rm -rf ./$(DEPDIR)
 | 
			
		||||
@ -793,14 +735,14 @@ info: info-am
 | 
			
		||||
 | 
			
		||||
info-am:
 | 
			
		||||
 | 
			
		||||
install-data-am: install-pkgbinPROGRAMS install-pkgincludeHEADERS
 | 
			
		||||
install-data-am: install-includeHEADERS
 | 
			
		||||
	@$(NORMAL_INSTALL)
 | 
			
		||||
	$(MAKE) $(AM_MAKEFLAGS) install-data-hook
 | 
			
		||||
install-dvi: install-dvi-am
 | 
			
		||||
 | 
			
		||||
install-dvi-am:
 | 
			
		||||
 | 
			
		||||
install-exec-am: install-pkglibLTLIBRARIES
 | 
			
		||||
install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
 | 
			
		||||
 | 
			
		||||
install-html: install-html-am
 | 
			
		||||
 | 
			
		||||
@ -840,29 +782,28 @@ ps: ps-am
 | 
			
		||||
 | 
			
		||||
ps-am:
 | 
			
		||||
 | 
			
		||||
uninstall-am: uninstall-pkgbinPROGRAMS uninstall-pkgincludeHEADERS \
 | 
			
		||||
	uninstall-pkglibLTLIBRARIES
 | 
			
		||||
uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
 | 
			
		||||
	uninstall-libLTLIBRARIES
 | 
			
		||||
	@$(NORMAL_INSTALL)
 | 
			
		||||
	$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
 | 
			
		||||
.MAKE: all install-am install-data-am install-strip uninstall-am
 | 
			
		||||
 | 
			
		||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
 | 
			
		||||
	clean-libtool clean-pkgbinPROGRAMS clean-pkglibLTLIBRARIES \
 | 
			
		||||
	cscopelist-am ctags ctags-am distclean distclean-compile \
 | 
			
		||||
	distclean-generic distclean-hdr distclean-libtool \
 | 
			
		||||
	distclean-tags distdir dvi dvi-am html html-am info info-am \
 | 
			
		||||
	install install-am install-data install-data-am \
 | 
			
		||||
	install-data-hook 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-pkgbinPROGRAMS install-pkgincludeHEADERS \
 | 
			
		||||
	install-pkglibLTLIBRARIES 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-hook uninstall-pkgbinPROGRAMS \
 | 
			
		||||
	uninstall-pkgincludeHEADERS uninstall-pkglibLTLIBRARIES
 | 
			
		||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
 | 
			
		||||
	clean-generic clean-libLTLIBRARIES clean-libtool ctags \
 | 
			
		||||
	distclean distclean-compile distclean-generic distclean-hdr \
 | 
			
		||||
	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-data-hook install-dvi \
 | 
			
		||||
	install-dvi-am install-exec install-exec-am install-html \
 | 
			
		||||
	install-html-am install-includeHEADERS install-info \
 | 
			
		||||
	install-info-am install-libLTLIBRARIES 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 uninstall uninstall-am uninstall-binPROGRAMS \
 | 
			
		||||
	uninstall-hook uninstall-includeHEADERS \
 | 
			
		||||
	uninstall-libLTLIBRARIES
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
install-data-hook:
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@
 | 
			
		||||
 | 
			
		||||
#include <stio.h>
 | 
			
		||||
#include <stio-sck.h>
 | 
			
		||||
#include <stio-tcp.h>
 | 
			
		||||
#include <stio-pro.h>
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
@ -94,19 +94,19 @@ typedef struct tcp_server_t tcp_server_t;
 | 
			
		||||
 | 
			
		||||
static void tcp_sck_on_disconnect (stio_dev_sck_t* tcp)
 | 
			
		||||
{
 | 
			
		||||
	if (tcp->state & STIO_DEV_TCP_CONNECTING)
 | 
			
		||||
	if (tcp->state & STIO_DEV_SCK_CONNECTING)
 | 
			
		||||
	{
 | 
			
		||||
		printf ("TCP DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
 | 
			
		||||
	}
 | 
			
		||||
	else if (tcp->state & STIO_DEV_TCP_LISTENING)
 | 
			
		||||
	else if (tcp->state & STIO_DEV_SCK_LISTENING)
 | 
			
		||||
	{
 | 
			
		||||
		printf ("SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->sck);
 | 
			
		||||
	}
 | 
			
		||||
	else if (tcp->state & STIO_DEV_TCP_CONNECTED)
 | 
			
		||||
	else if (tcp->state & STIO_DEV_SCK_CONNECTED)
 | 
			
		||||
	{
 | 
			
		||||
		printf ("CLIENT ORIGINATING FROM HERE GOT DISCONNECTED(%d).......\n", (int)tcp->sck);
 | 
			
		||||
	}
 | 
			
		||||
	else if (tcp->state & STIO_DEV_TCP_ACCEPTED)
 | 
			
		||||
	else if (tcp->state & STIO_DEV_SCK_ACCEPTED)
 | 
			
		||||
	{
 | 
			
		||||
		printf ("CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->sck);
 | 
			
		||||
	}
 | 
			
		||||
@ -118,11 +118,11 @@ static void tcp_sck_on_disconnect (stio_dev_sck_t* tcp)
 | 
			
		||||
static int tcp_sck_on_connect (stio_dev_sck_t* tcp)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	if (tcp->state & STIO_DEV_TCP_CONNECTED)
 | 
			
		||||
	if (tcp->state & STIO_DEV_SCK_CONNECTED)
 | 
			
		||||
	{
 | 
			
		||||
printf ("device connected to a remote server... .asdfjkasdfkljasdlfkjasdj...\n");
 | 
			
		||||
	}
 | 
			
		||||
	else if (tcp->state & STIO_DEV_TCP_ACCEPTED)
 | 
			
		||||
	else if (tcp->state & STIO_DEV_SCK_ACCEPTED)
 | 
			
		||||
	{
 | 
			
		||||
printf ("device accepted client device... .asdfjkasdfkljasdlfkjasdj...\n");
 | 
			
		||||
	}
 | 
			
		||||
@ -212,6 +212,20 @@ static int arp_sck_on_write (stio_dev_sck_t* dev, stio_iolen_t wrlen, void* wrct
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ========================================================================= */
 | 
			
		||||
 | 
			
		||||
static int pro_on_read (stio_dev_pro_t* dev, const void* data, stio_iolen_t dlen)
 | 
			
		||||
{
 | 
			
		||||
printf ("PROCESS READ DATA... [%.*s]\n", (int)dlen, (char*)data);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int pro_on_write (stio_dev_pro_t* dev, stio_iolen_t wrlen, void* wrctx)
 | 
			
		||||
{
 | 
			
		||||
printf ("PROCESS WROTE DATA...\n");
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ========================================================================= */
 | 
			
		||||
 | 
			
		||||
@ -374,6 +388,26 @@ int main ()
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* pro;
 | 
			
		||||
	stio_dev_pro_make_t pro_make;
 | 
			
		||||
 | 
			
		||||
	memset (&pro_make, 0, STIO_SIZEOF(pro_make));
 | 
			
		||||
	pro_make.flags = STIO_DEV_PRO_READOUT | STIO_DEV_PRO_READERR | STIO_DEV_PRO_WRITEIN;
 | 
			
		||||
	//pro_make.cmd = "/bin/ls -laF /usr/bin";
 | 
			
		||||
	pro_make.cmd = "/bin/ls -laF";
 | 
			
		||||
	pro_make.on_read = pro_on_read;
 | 
			
		||||
	pro_make.on_write = pro_on_write;
 | 
			
		||||
 | 
			
		||||
	pro = stio_dev_pro_make (stio, 0, &pro_make);
 | 
			
		||||
	if (!pro)
 | 
			
		||||
	{
 | 
			
		||||
		printf ("CANNOT CREATE PROCESS PIPE\n");
 | 
			
		||||
		goto oops;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
	stio_loop (stio);
 | 
			
		||||
 | 
			
		||||
	g_stio = STIO_NULL;
 | 
			
		||||
 | 
			
		||||
@ -281,6 +281,10 @@ typedef stio_uint8_t stio_byte_t;
 | 
			
		||||
typedef stio_uintptr_t stio_size_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef char stio_mchar_t;
 | 
			
		||||
typedef int stio_mcint_t;
 | 
			
		||||
 | 
			
		||||
#define STIO_MT(x) (x)
 | 
			
		||||
/* =========================================================================
 | 
			
		||||
 * PRIMITIVE MACROS
 | 
			
		||||
 * ========================================================================= */
 | 
			
		||||
 | 
			
		||||
@ -30,95 +30,195 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static stio_dev_pro_t* make_sibling (stio_t* stio, stio_syshnd_t handle);
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
 | 
			
		||||
/* ========================================================================= */
 | 
			
		||||
 | 
			
		||||
static pid_t standard_fork_and_exec (stio_dev_pro_t* rdev, int pfds[], stio_dev_pro_make_t* info)
 | 
			
		||||
struct slave_info_t
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_make_t* mi;
 | 
			
		||||
	stio_syshnd_t pfd;
 | 
			
		||||
	int dev_capa;
 | 
			
		||||
	int id;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct slave_info_t slave_info_t;
 | 
			
		||||
 | 
			
		||||
static stio_dev_pro_slave_t* make_slave (stio_t* stio, slave_info_t* si);
 | 
			
		||||
 | 
			
		||||
/* ========================================================================= */
 | 
			
		||||
 | 
			
		||||
struct param_t
 | 
			
		||||
{
 | 
			
		||||
	stio_mchar_t* mcmd;
 | 
			
		||||
	stio_mchar_t* fixed_argv[4];
 | 
			
		||||
	stio_mchar_t** argv;
 | 
			
		||||
};
 | 
			
		||||
typedef struct param_t param_t;
 | 
			
		||||
 | 
			
		||||
static void free_param (stio_t* stio, param_t* param)
 | 
			
		||||
{
 | 
			
		||||
	if (param->argv && param->argv != param->fixed_argv) 
 | 
			
		||||
		STIO_MMGR_FREE (stio->mmgr, param->argv);
 | 
			
		||||
	if (param->mcmd) STIO_MMGR_FREE (stio->mmgr, param->mcmd);
 | 
			
		||||
	STIO_MEMSET (param, 0, STIO_SIZEOF(*param));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int make_param (stio_t* stio, const stio_mchar_t* cmd, int flags, param_t* param)
 | 
			
		||||
{
 | 
			
		||||
	int fcnt = 0;
 | 
			
		||||
	stio_mchar_t* mcmd = STIO_NULL;
 | 
			
		||||
 | 
			
		||||
	STIO_MEMSET (param, 0, STIO_SIZEOF(*param));
 | 
			
		||||
 | 
			
		||||
	if (flags & STIO_DEV_PRO_SHELL)
 | 
			
		||||
	{
 | 
			
		||||
		mcmd = (stio_mchar_t*)cmd;
 | 
			
		||||
 | 
			
		||||
		param->argv = param->fixed_argv;
 | 
			
		||||
		param->argv[0] = STIO_MT("/bin/sh");
 | 
			
		||||
		param->argv[1] = STIO_MT("-c");
 | 
			
		||||
		param->argv[2] = mcmd;
 | 
			
		||||
		param->argv[3] = STIO_NULL;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		int i;
 | 
			
		||||
		stio_mchar_t** argv;
 | 
			
		||||
		stio_mchar_t* mcmdptr;
 | 
			
		||||
 | 
			
		||||
		mcmd = stio_mbsdup (stio, cmd);
 | 
			
		||||
		if (!mcmd) goto oops;
 | 
			
		||||
		
 | 
			
		||||
		fcnt = stio_mbsspl (mcmd, STIO_MT(""), STIO_MT('\"'), STIO_MT('\"'), STIO_MT('\\')); 
 | 
			
		||||
		if (fcnt <= 0) 
 | 
			
		||||
		{
 | 
			
		||||
			/* no field or an error */
 | 
			
		||||
			stio->errnum = STIO_EINVAL;
 | 
			
		||||
			goto oops;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (fcnt < STIO_COUNTOF(param->fixed_argv))
 | 
			
		||||
		{
 | 
			
		||||
			param->argv = param->fixed_argv;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			param->argv = STIO_MMGR_ALLOC (stio->mmgr, (fcnt + 1) * STIO_SIZEOF(argv[0]));
 | 
			
		||||
			if (param->argv == STIO_NULL) 
 | 
			
		||||
			{
 | 
			
		||||
				stio->errnum = STIO_ENOMEM;
 | 
			
		||||
				goto oops;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		mcmdptr = mcmd;
 | 
			
		||||
		for (i = 0; i < fcnt; i++)
 | 
			
		||||
		{
 | 
			
		||||
			param->argv[i] = mcmdptr;
 | 
			
		||||
			while (*mcmdptr != STIO_MT('\0')) mcmdptr++;
 | 
			
		||||
			mcmdptr++;
 | 
			
		||||
		}
 | 
			
		||||
		param->argv[i] = STIO_NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (mcmd && mcmd != (stio_mchar_t*)cmd) param->mcmd = mcmd;
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
oops:
 | 
			
		||||
	if (mcmd && mcmd != cmd) STIO_MMGR_FREE (stio->mmgr, mcmd);
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static pid_t standard_fork_and_exec (stio_t* stio, int pfds[], int flags, param_t* param)
 | 
			
		||||
{
 | 
			
		||||
	pid_t pid;
 | 
			
		||||
 | 
			
		||||
	pid = fork ();
 | 
			
		||||
	if (fork() == -1) 
 | 
			
		||||
	if (pid == -1) 
 | 
			
		||||
	{
 | 
			
		||||
		rdev->stio->errnum = stio_syserrtoerrnum(errno);
 | 
			
		||||
		stio->errnum = stio_syserrtoerrnum(errno);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (pid == 0)
 | 
			
		||||
	{
 | 
			
		||||
		/* slave process */
 | 
			
		||||
 | 
			
		||||
		stio_syshnd_t devnull = STIO_SYSHND_INVALID;
 | 
			
		||||
 | 
			
		||||
		/* TODO: close all uneeded fds */
 | 
			
		||||
		if (info->flags & STIO_DEV_PRO_WRITEIN)
 | 
			
		||||
/* TODO: close all uneeded fds */
 | 
			
		||||
 | 
			
		||||
		if (flags & STIO_DEV_PRO_WRITEIN)
 | 
			
		||||
		{
 | 
			
		||||
			/* child should read */
 | 
			
		||||
			/* slave should read */
 | 
			
		||||
			close (pfds[1]);
 | 
			
		||||
			pfds[1] = STIO_SYSHND_INVALID;
 | 
			
		||||
 | 
			
		||||
			/* let the pipe be standard input */
 | 
			
		||||
			if (dup2 (pfds[0], 0) <= -1) goto child_oops;
 | 
			
		||||
			if (dup2 (pfds[0], 0) <= -1) goto slave_oops;
 | 
			
		||||
 | 
			
		||||
			close (pfds[0]);
 | 
			
		||||
			pfds[0] = STIO_SYSHND_INVALID;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (info->flags & STIO_DEV_PRO_READOUT)
 | 
			
		||||
		if (flags & STIO_DEV_PRO_READOUT)
 | 
			
		||||
		{
 | 
			
		||||
			/* child should write */
 | 
			
		||||
			/* slave should write */
 | 
			
		||||
			close (pfds[2]);
 | 
			
		||||
			pfds[2] = STIO_SYSHND_INVALID;
 | 
			
		||||
 | 
			
		||||
			if (dup2(pfds[3], 1) == -1) goto child_oops;
 | 
			
		||||
			if (dup2(pfds[3], 1) == -1) goto slave_oops;
 | 
			
		||||
 | 
			
		||||
			if (info->flags & STIO_DEV_PRO_ERRTOOUT)
 | 
			
		||||
			if (flags & STIO_DEV_PRO_ERRTOOUT)
 | 
			
		||||
			{
 | 
			
		||||
				if (dup2(pfds[3], 2) == -1) goto child_oops;
 | 
			
		||||
				if (dup2(pfds[3], 2) == -1) goto slave_oops;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			close (pfds[3]);
 | 
			
		||||
			pfds[3] = STIO_SYSHND_INVALID;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (info->flags & STIO_DEV_PRO_READERR)
 | 
			
		||||
		if (flags & STIO_DEV_PRO_READERR)
 | 
			
		||||
		{
 | 
			
		||||
			close (pfds[4]);
 | 
			
		||||
			pfds[4] = STIO_SYSHND_INVALID;
 | 
			
		||||
 | 
			
		||||
			if (dup2(pfds[5], 2) == -1) goto child_oops;
 | 
			
		||||
			if (dup2(pfds[5], 2) == -1) goto slave_oops;
 | 
			
		||||
 | 
			
		||||
			if (info->flags & STIO_DEV_PRO_OUTTOERR)
 | 
			
		||||
			if (flags & STIO_DEV_PRO_OUTTOERR)
 | 
			
		||||
			{
 | 
			
		||||
				if (dup2(pfds[5], 1) == -1) goto child_oops;
 | 
			
		||||
				if (dup2(pfds[5], 1) == -1) goto slave_oops;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			close (pfds[5]);
 | 
			
		||||
			pfds[5] = STIO_SYSHND_INVALID;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ((info->flags & STIO_DEV_PRO_INTONUL) ||
 | 
			
		||||
		    (info->flags & STIO_DEV_PRO_OUTTONUL) ||
 | 
			
		||||
		    (info->flags & STIO_DEV_PRO_ERRTONUL))
 | 
			
		||||
		if ((flags & STIO_DEV_PRO_INTONUL) ||
 | 
			
		||||
		    (flags & STIO_DEV_PRO_OUTTONUL) ||
 | 
			
		||||
		    (flags & STIO_DEV_PRO_ERRTONUL))
 | 
			
		||||
		{
 | 
			
		||||
		#if defined(O_LARGEFILE)
 | 
			
		||||
			devnull = open ("/dev/null", O_RDWR | O_LARGEFILE, 0);
 | 
			
		||||
			devnull = open (STIO_MT("/dev/null"), O_RDWR | O_LARGEFILE, 0);
 | 
			
		||||
		#else
 | 
			
		||||
			devnull = open ("/dev/null", O_RDWR, 0);
 | 
			
		||||
			devnull = open (STIO_MT("/dev/null"), O_RDWR, 0);
 | 
			
		||||
		#endif
 | 
			
		||||
			if (devnull == STIO_SYSHND_INVALID) goto child_oops;
 | 
			
		||||
			if (devnull == STIO_SYSHND_INVALID) goto slave_oops;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//execv (param->argv[0], param->argv);
 | 
			
		||||
		execv (param->argv[0], param->argv);
 | 
			
		||||
 | 
			
		||||
	child_oops:
 | 
			
		||||
		/* if exec fails, free 'param' parameter which is an inherited pointer */
 | 
			
		||||
		free_param (stio, param); 
 | 
			
		||||
 | 
			
		||||
	slave_oops:
 | 
			
		||||
		if (devnull != STIO_SYSHND_INVALID) close(devnull);
 | 
			
		||||
		_exit (128);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* parent process */
 | 
			
		||||
	return pid;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dev_pro_make (stio_dev_t* dev, void* ctx)
 | 
			
		||||
@ -127,6 +227,7 @@ static int dev_pro_make (stio_dev_t* dev, void* ctx)
 | 
			
		||||
	stio_dev_pro_make_t* info = (stio_dev_pro_make_t*)ctx;
 | 
			
		||||
	stio_syshnd_t pfds[6];
 | 
			
		||||
	int i, minidx = -1, maxidx = -1;
 | 
			
		||||
	param_t param;
 | 
			
		||||
	pid_t pid;
 | 
			
		||||
 | 
			
		||||
	if (info->flags & STIO_DEV_PRO_WRITEIN)
 | 
			
		||||
@ -167,10 +268,17 @@ static int dev_pro_make (stio_dev_t* dev, void* ctx)
 | 
			
		||||
		goto oops;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
/* TODO: more advanced fork and exec .. */
 | 
			
		||||
	pid = standard_fork_and_exec (rdev, pfds, info);
 | 
			
		||||
	if (pid <= -1) goto oops;
 | 
			
		||||
	if (make_param (rdev->stio, info->cmd, info->flags, ¶m) <= -1) goto oops;
 | 
			
		||||
 | 
			
		||||
/* TODO: more advanced fork and exec .. */
 | 
			
		||||
	pid = standard_fork_and_exec (rdev->stio, pfds, info->flags, ¶m);
 | 
			
		||||
	if (pid <= -1) 
 | 
			
		||||
	{
 | 
			
		||||
		free_param (rdev->stio, ¶m);
 | 
			
		||||
		goto oops;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	free_param (rdev->stio, ¶m);
 | 
			
		||||
	rdev->child_pid = pid;
 | 
			
		||||
 | 
			
		||||
	/* this is the parent process */
 | 
			
		||||
@ -184,6 +292,8 @@ static int dev_pro_make (stio_dev_t* dev, void* ctx)
 | 
			
		||||
		 */
 | 
			
		||||
		close (pfds[0]);
 | 
			
		||||
		pfds[0] = STIO_SYSHND_INVALID;
 | 
			
		||||
 | 
			
		||||
		if (stio_makesyshndasync (dev->stio, pfds[1]) <= -1) goto oops;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (info->flags & STIO_DEV_PRO_READOUT)
 | 
			
		||||
@ -196,6 +306,8 @@ static int dev_pro_make (stio_dev_t* dev, void* ctx)
 | 
			
		||||
		 */
 | 
			
		||||
		close (pfds[3]);
 | 
			
		||||
		pfds[3] = STIO_SYSHND_INVALID;
 | 
			
		||||
 | 
			
		||||
		if (stio_makesyshndasync (dev->stio, pfds[2]) <= -1) goto oops;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (info->flags & STIO_DEV_PRO_READERR)
 | 
			
		||||
@ -208,35 +320,66 @@ static int dev_pro_make (stio_dev_t* dev, void* ctx)
 | 
			
		||||
		 */
 | 
			
		||||
		close (pfds[5]);
 | 
			
		||||
		pfds[5] = STIO_SYSHND_INVALID;
 | 
			
		||||
 | 
			
		||||
		if (stio_makesyshndasync (dev->stio, pfds[4]) <= -1) goto oops;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (stio_makesyshndasync (dev->stio, pfds[1]) <= -1 ||
 | 
			
		||||
	    stio_makesyshndasync (dev->stio, pfds[2]) <= -1 ||
 | 
			
		||||
	    stio_makesyshndasync (dev->stio, pfds[4]) <= -1) goto oops;
 | 
			
		||||
	if (pfds[1] != STIO_SYSHND_INVALID)
 | 
			
		||||
	{
 | 
			
		||||
		/* hand over pfds[2] to the first slave device */
 | 
			
		||||
		slave_info_t si;
 | 
			
		||||
 | 
			
		||||
		si.mi = info;
 | 
			
		||||
		si.pfd = pfds[1];
 | 
			
		||||
		si.dev_capa = STIO_DEV_CAPA_OUT | STIO_DEV_CAPA_OUT_QUEUED | STIO_DEV_CAPA_STREAM;
 | 
			
		||||
		si.id = 0;
 | 
			
		||||
 | 
			
		||||
		rdev->slave[0] = make_slave (dev->stio, &si);
 | 
			
		||||
		if (!rdev->slave[0]) goto oops;
 | 
			
		||||
 | 
			
		||||
		pfds[1] = STIO_SYSHND_INVALID;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (pfds[2] != STIO_SYSHND_INVALID)
 | 
			
		||||
	{
 | 
			
		||||
		rdev->sibling[0] = make_sibling (dev->stio, pfds[2]);
 | 
			
		||||
		if (!rdev->sibling[0]) goto oops;
 | 
			
		||||
		/* hand over pfds[2] to the first slave device */
 | 
			
		||||
		slave_info_t si;
 | 
			
		||||
 | 
			
		||||
		si.mi = info;
 | 
			
		||||
		si.pfd = pfds[2];
 | 
			
		||||
		si.dev_capa = STIO_DEV_CAPA_IN | STIO_DEV_CAPA_STREAM;
 | 
			
		||||
		si.id = 1;
 | 
			
		||||
 | 
			
		||||
		rdev->slave[1] = make_slave (dev->stio, &si);
 | 
			
		||||
		if (!rdev->slave[1]) goto oops;
 | 
			
		||||
 | 
			
		||||
		pfds[2] = STIO_SYSHND_INVALID;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (pfds[4] != STIO_SYSHND_INVALID)
 | 
			
		||||
	{
 | 
			
		||||
		rdev->sibling[1] = make_sibling (dev->stio, pfds[4]);
 | 
			
		||||
		if (!rdev->sibling[1])
 | 
			
		||||
		{
 | 
			
		||||
			if (rdev->sibling[0])
 | 
			
		||||
			{
 | 
			
		||||
				stio_dev_pro_kill (rdev->sibling[0]);
 | 
			
		||||
				rdev->sibling[0] = STIO_NULL;
 | 
			
		||||
			}
 | 
			
		||||
			goto oops;
 | 
			
		||||
		}
 | 
			
		||||
		/* hand over pfds[4] to the second slave device */
 | 
			
		||||
		slave_info_t si;
 | 
			
		||||
 | 
			
		||||
		si.mi = info;
 | 
			
		||||
		si.pfd = pfds[4];
 | 
			
		||||
		si.dev_capa = STIO_DEV_CAPA_IN | STIO_DEV_CAPA_STREAM;
 | 
			
		||||
		si.id = 2;
 | 
			
		||||
 | 
			
		||||
		rdev->slave[2] = make_slave (dev->stio, &si);
 | 
			
		||||
		if (!rdev->slave[2]) goto oops;
 | 
			
		||||
 | 
			
		||||
		pfds[4] = STIO_SYSHND_INVALID;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rdev->pfd = pfds[1];
 | 
			
		||||
	for (i = 0; i < 3; i++) 
 | 
			
		||||
	{
 | 
			
		||||
		if (rdev->slave[i]) rdev->slave[i]->master = rdev;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	rdev->dev_capa = STIO_DEV_CAPA_VIRTUAL;
 | 
			
		||||
	rdev->on_read = info->on_read;
 | 
			
		||||
	rdev->on_write = info->on_write;
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
oops:
 | 
			
		||||
@ -245,24 +388,77 @@ oops:
 | 
			
		||||
		if (pfds[i] != STIO_SYSHND_INVALID) close (pfds[i]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (rdev->mcmd) 
 | 
			
		||||
	{
 | 
			
		||||
		STIO_MMGR_FREE (rdev->stio->mmgr, rdev->mcmd);
 | 
			
		||||
		free_param (rdev->stio, ¶m);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (i = 3; i > 0; )
 | 
			
		||||
	{
 | 
			
		||||
		i--;
 | 
			
		||||
		if (rdev->slave[i])
 | 
			
		||||
		{
 | 
			
		||||
			stio_killdev (rdev->stio, (stio_dev_t*)rdev->slave[i]);
 | 
			
		||||
			rdev->slave[i] = STIO_NULL;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dev_pro_make_sibling (stio_dev_t* dev, void* ctx)
 | 
			
		||||
static int dev_pro_make_slave (stio_dev_t* dev, void* ctx)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* rdev = (stio_dev_pro_t*)dev;
 | 
			
		||||
	stio_syshnd_t* handle = (stio_syshnd_t*)ctx;
 | 
			
		||||
	stio_dev_pro_slave_t* rdev = (stio_dev_pro_slave_t*)dev;
 | 
			
		||||
	slave_info_t* si = (slave_info_t*)ctx;
 | 
			
		||||
 | 
			
		||||
	rdev->pfd = *handle;
 | 
			
		||||
	if (stio_makesyshndasync (rdev->stio, rdev->pfd) <= -1) return -1;
 | 
			
		||||
	rdev->dev_capa = si->dev_capa;
 | 
			
		||||
	rdev->id = si->id;
 | 
			
		||||
	rdev->pfd = si->pfd;
 | 
			
		||||
	/* keep rdev->master to STIO_NULL. it's set to the right master
 | 
			
		||||
	 * device in dev_pro_make() */
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void dev_pro_kill (stio_dev_t* dev)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* rdev = (stio_dev_pro_t*)dev;
 | 
			
		||||
	int i, status;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < 3; i++)
 | 
			
		||||
	{
 | 
			
		||||
		if (rdev->slave[i])
 | 
			
		||||
		{
 | 
			
		||||
			stio_dev_pro_slave_t* sdev = rdev->slave[i];
 | 
			
		||||
			rdev->slave[i] = STIO_NULL;
 | 
			
		||||
			stio_killdev (rdev->stio, (stio_dev_t*)sdev);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
	x = waitpid (rdev->child_pid, &status, WNOHANG);
 | 
			
		||||
	if (x == rdev->child_pid)
 | 
			
		||||
	{
 | 
			
		||||
		/* child process reclaimed successfully */
 | 
			
		||||
	}
 | 
			
		||||
	else if (x == 0)
 | 
			
		||||
	{
 | 
			
		||||
		/* child still alive */
 | 
			
		||||
		/* TODO: schedule a timer job... */
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		kill (rdev->child_pid, SIGKILL);
 | 
			
		||||
		x = waitpid (rdev->child_pid, &i, WNOHANG);
 | 
			
		||||
		if (x == -1)
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void dev_pro_kill_slave (stio_dev_t* dev)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_slave_t* rdev = (stio_dev_pro_slave_t*)dev;
 | 
			
		||||
 | 
			
		||||
	if (rdev->pfd != STIO_SYSHND_INVALID)
 | 
			
		||||
	{
 | 
			
		||||
@ -270,25 +466,20 @@ static void dev_pro_kill (stio_dev_t* dev)
 | 
			
		||||
		rdev->pfd = STIO_SYSHND_INVALID;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (rdev->sibling[0])
 | 
			
		||||
	if (rdev->master)
 | 
			
		||||
	{
 | 
			
		||||
		stio_dev_pro_kill (rdev->sibling[0]);
 | 
			
		||||
		rdev->sibling[0] = STIO_NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (rdev->sibling[1])
 | 
			
		||||
	{
 | 
			
		||||
		stio_dev_pro_kill (rdev->sibling[1]);
 | 
			
		||||
		rdev->sibling[1] = STIO_NULL;
 | 
			
		||||
		/* let the master know that this slave device has been killed */
 | 
			
		||||
		rdev->master->slave[rdev->id] = STIO_NULL;
 | 
			
		||||
		rdev->master = STIO_NULL; 
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dev_pro_read (stio_dev_t* dev, void* buf, stio_iolen_t* len, stio_devadr_t* srcadr)
 | 
			
		||||
static int dev_pro_read_slave (stio_dev_t* dev, void* buf, stio_iolen_t* len, stio_devadr_t* srcadr)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* pro = (stio_dev_pro_t*)dev;
 | 
			
		||||
	stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
 | 
			
		||||
	ssize_t x;
 | 
			
		||||
 | 
			
		||||
	x = write (pro->pfd, buf, *len);
 | 
			
		||||
	x = read (pro->pfd, buf, *len);
 | 
			
		||||
	if (x <= -1)
 | 
			
		||||
	{
 | 
			
		||||
		if (errno == EINPROGRESS || errno == EWOULDBLOCK) return 0;  /* no data available */
 | 
			
		||||
@ -301,17 +492,34 @@ static int dev_pro_read (stio_dev_t* dev, void* buf, stio_iolen_t* len, stio_dev
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dev_pro_write (stio_dev_t* dev, const void* data, stio_iolen_t* len, const stio_devadr_t* dstadr)
 | 
			
		||||
static int dev_pro_write_slave (stio_dev_t* dev, const void* data, stio_iolen_t* len, const stio_devadr_t* dstadr)
 | 
			
		||||
{
 | 
			
		||||
	return -1;
 | 
			
		||||
	stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
 | 
			
		||||
	ssize_t x;
 | 
			
		||||
 | 
			
		||||
	x = write (pro->pfd, data, *len);
 | 
			
		||||
	if (x <= -1)
 | 
			
		||||
	{
 | 
			
		||||
		if (errno == EINPROGRESS || errno == EWOULDBLOCK) return 0;  /* no data can be written */
 | 
			
		||||
		if (errno == EINTR) return 0;
 | 
			
		||||
		pro->stio->errnum = stio_syserrtoerrnum(errno);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*len = x;
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static stio_syshnd_t dev_pro_getsyshnd (stio_dev_t* dev)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* pro = (stio_dev_pro_t*)dev;
 | 
			
		||||
	return (stio_syshnd_t)pro->pfd;
 | 
			
		||||
	return STIO_SYSHND_INVALID;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static stio_syshnd_t dev_pro_getsyshnd_slave (stio_dev_t* dev)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
 | 
			
		||||
	return (stio_syshnd_t)pro->pfd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int dev_pro_ioctl (stio_dev_t* dev, int cmd, void* arg)
 | 
			
		||||
{
 | 
			
		||||
@ -322,7 +530,8 @@ static int dev_pro_ioctl (stio_dev_t* dev, int cmd, void* arg)
 | 
			
		||||
		case STIO_DEV_PRO_KILL
 | 
			
		||||
		case STIO_DEV_PRO_CLOSEIN:
 | 
			
		||||
		case STIO_DEV_PRO_CLOSEOUT:
 | 
			
		||||
		case STIO_DEV_PROC_CLOSEERR: 
 | 
			
		||||
		case STIO_DEV_PRO_CLOSEERR:
 | 
			
		||||
		case STIO_DEV_PRO_WAIT:
 | 
			
		||||
	}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
@ -335,31 +544,57 @@ static stio_dev_mth_t dev_pro_methods =
 | 
			
		||||
	dev_pro_kill,
 | 
			
		||||
	dev_pro_getsyshnd,
 | 
			
		||||
 | 
			
		||||
	dev_pro_read,
 | 
			
		||||
	dev_pro_write,
 | 
			
		||||
	STIO_NULL,
 | 
			
		||||
	STIO_NULL,
 | 
			
		||||
	dev_pro_ioctl
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static stio_dev_mth_t dev_pro_methods_sibling =
 | 
			
		||||
static stio_dev_mth_t dev_pro_methods_slave =
 | 
			
		||||
{
 | 
			
		||||
	dev_pro_make_sibling,
 | 
			
		||||
	dev_pro_kill,
 | 
			
		||||
	dev_pro_getsyshnd,
 | 
			
		||||
	dev_pro_make_slave,
 | 
			
		||||
	dev_pro_kill_slave,
 | 
			
		||||
	dev_pro_getsyshnd_slave,
 | 
			
		||||
 | 
			
		||||
	dev_pro_read,
 | 
			
		||||
	dev_pro_write,
 | 
			
		||||
	dev_pro_read_slave,
 | 
			
		||||
	dev_pro_write_slave,
 | 
			
		||||
	dev_pro_ioctl
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* ========================================================================= */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int pro_ready (stio_dev_t* dev, int events)
 | 
			
		||||
{
 | 
			
		||||
	/* virtual device. no I/O */
 | 
			
		||||
	dev->stio->errnum = STIO_EINTERN;
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int pro_on_read (stio_dev_t* dev, const void* data, stio_iolen_t len, const stio_devadr_t* srcadr)
 | 
			
		||||
{
 | 
			
		||||
	/* virtual device. no I/O */
 | 
			
		||||
	dev->stio->errnum = STIO_EINTERN;
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int pro_on_write (stio_dev_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_devadr_t* dstadr)
 | 
			
		||||
{
 | 
			
		||||
	/* virtual device. no I/O */
 | 
			
		||||
	dev->stio->errnum = STIO_EINTERN;
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static stio_dev_evcb_t dev_pro_event_callbacks =
 | 
			
		||||
{
 | 
			
		||||
	pro_ready,
 | 
			
		||||
	pro_on_read,
 | 
			
		||||
	pro_on_write
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* ========================================================================= */
 | 
			
		||||
 | 
			
		||||
static int pro_ready_slave (stio_dev_t* dev, int events)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* pro = (stio_dev_pro_t*)dev;
 | 
			
		||||
printf ("PRO READY...%p\n", dev);
 | 
			
		||||
 | 
			
		||||
	if (events & STIO_DEV_EVENT_ERR)
 | 
			
		||||
	{
 | 
			
		||||
@ -382,55 +617,74 @@ printf ("PRO READY...%p\n", dev);
 | 
			
		||||
	return 1; /* the device is ok. carry on reading or writing */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int pro_on_read (stio_dev_t* dev, const void* data, stio_iolen_t len, const stio_devadr_t* srcadr)
 | 
			
		||||
static int pro_on_read_slave (stio_dev_t* dev, const void* data, stio_iolen_t len, const stio_devadr_t* srcadr)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* pro = (stio_dev_pro_t*)dev;
 | 
			
		||||
	return pro->on_read (pro, data, len);
 | 
			
		||||
	stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
 | 
			
		||||
	return pro->master->on_read (pro->master, data, len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int pro_on_write (stio_dev_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_devadr_t* dstadr)
 | 
			
		||||
static int pro_on_write_slave (stio_dev_t* dev, stio_iolen_t wrlen, void* wrctx, const stio_devadr_t* dstadr)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_pro_t* pro = (stio_dev_pro_t*)dev;
 | 
			
		||||
	return pro->on_write (pro, wrctx);
 | 
			
		||||
	stio_dev_pro_slave_t* pro = (stio_dev_pro_slave_t*)dev;
 | 
			
		||||
	return pro->master->on_write (pro->master, wrlen, wrctx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static stio_dev_evcb_t dev_pro_event_callbacks =
 | 
			
		||||
static stio_dev_evcb_t dev_pro_event_callbacks_slave =
 | 
			
		||||
{
 | 
			
		||||
	pro_ready,
 | 
			
		||||
	pro_on_read,
 | 
			
		||||
	pro_on_write
 | 
			
		||||
	pro_ready_slave,
 | 
			
		||||
	pro_on_read_slave,
 | 
			
		||||
	pro_on_write_slave
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* ========================================================================= */
 | 
			
		||||
 | 
			
		||||
static stio_dev_pro_t* make_sibling (stio_t* stio, stio_syshnd_t handle)
 | 
			
		||||
static stio_dev_pro_slave_t* make_slave (stio_t* stio, slave_info_t* si)
 | 
			
		||||
{
 | 
			
		||||
	return (stio_dev_pro_t*)stio_makedev (
 | 
			
		||||
	return (stio_dev_pro_slave_t*)stio_makedev (
 | 
			
		||||
		stio, STIO_SIZEOF(stio_dev_pro_t), 
 | 
			
		||||
		&dev_pro_methods_sibling, &dev_pro_event_callbacks, (void*)&handle);
 | 
			
		||||
		&dev_pro_methods_slave, &dev_pro_event_callbacks_slave, si);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
stio_dev_pro_t* stio_dev_pro_make (stio_t* stio, stio_size_t xtnsize, const stio_dev_pro_make_t* data)
 | 
			
		||||
stio_dev_pro_t* stio_dev_pro_make (stio_t* stio, stio_size_t xtnsize, const stio_dev_pro_make_t* info)
 | 
			
		||||
{
 | 
			
		||||
	return (stio_dev_pro_t*)stio_makedev (
 | 
			
		||||
		stio, STIO_SIZEOF(stio_dev_pro_t) + xtnsize, 
 | 
			
		||||
		&dev_pro_methods, &dev_pro_event_callbacks, (void*)data);
 | 
			
		||||
		&dev_pro_methods, &dev_pro_event_callbacks, (void*)info);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void stio_dev_pro_kill (stio_dev_pro_t* pro)
 | 
			
		||||
void stio_dev_pro_kill (stio_dev_pro_t* dev)
 | 
			
		||||
{
 | 
			
		||||
	stio_killdev (pro->stio, (stio_dev_t*)pro);
 | 
			
		||||
	stio_killdev (dev->stio, (stio_dev_t*)dev);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int stio_dev_pro_write (stio_dev_pro_t* dev, const void* data, stio_iolen_t dlen, void* wrctx)
 | 
			
		||||
{
 | 
			
		||||
	if (dev->slave[0])
 | 
			
		||||
	{
 | 
			
		||||
		return stio_dev_write ((stio_dev_t*)dev->slave[0], data, dlen, wrctx, STIO_NULL);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		dev->stio->errnum = STIO_ENOCAPA; /* TODO: is it the right error number? */
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int stio_dev_pro_timedwrite (stio_dev_pro_t* dev, const void* data, stio_iolen_t dlen, const stio_ntime_t* tmout, void* wrctx)
 | 
			
		||||
{
 | 
			
		||||
	if (dev->slave[0])
 | 
			
		||||
	{
 | 
			
		||||
		return stio_dev_timedwrite ((stio_dev_t*)dev->slave[0], data, dlen, tmout, wrctx, STIO_NULL);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		dev->stio->errnum = STIO_ENOCAPA; /* TODO: is it the right error number? */
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
int stio_dev_pro_write (stio_dev_pro_t* pro, const void* data, stio_iolen_t len, void* wrctx)
 | 
			
		||||
{
 | 
			
		||||
	return stio_dev_write ((stio_dev_t*)pro, data, len, wrctx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
stio_dev_pro_t* stio_dev_pro_getdev (stio_dev_pro_t* pro, stio_dev_pro_type_t type)
 | 
			
		||||
{
 | 
			
		||||
	switch (type)
 | 
			
		||||
@ -448,5 +702,4 @@ stio_dev_pro_t* stio_dev_pro_getdev (stio_dev_pro_t* pro, stio_dev_pro_type_t ty
 | 
			
		||||
	pro->dev->stio = STIO_EINVAL;
 | 
			
		||||
	return STIO_NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -37,27 +37,36 @@ enum stio_dev_pro_type_t
 | 
			
		||||
};
 | 
			
		||||
typedef enum stio_dev_pro_type_t stio_dev_pro_type_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef struct stio_dev_pro_t stio_dev_pro_t;
 | 
			
		||||
typedef struct stio_dev_pro_slave_t stio_dev_pro_slave_t;
 | 
			
		||||
 | 
			
		||||
typedef int (*stio_dev_pro_on_read_t) (stio_dev_pro_t* dev, const void* data, stio_iolen_t len);
 | 
			
		||||
typedef int (*stio_dev_pro_on_write_t) (stio_dev_pro_t* dev, void* wrctx);
 | 
			
		||||
typedef int (*stio_dev_pro_on_write_t) (stio_dev_pro_t* dev, stio_iolen_t wrlen, void* wrctx);
 | 
			
		||||
 | 
			
		||||
struct stio_dev_pro_t
 | 
			
		||||
{
 | 
			
		||||
	STIO_DEV_HEADERS;
 | 
			
		||||
 | 
			
		||||
	stio_syshnd_t pfd;
 | 
			
		||||
	stio_dev_pro_type_t type;
 | 
			
		||||
 | 
			
		||||
	stio_intptr_t child_pid;
 | 
			
		||||
 | 
			
		||||
	stio_dev_pro_t* sibling[2];
 | 
			
		||||
	stio_dev_pro_slave_t* slave[3];
 | 
			
		||||
 | 
			
		||||
	stio_dev_pro_on_read_t on_read;
 | 
			
		||||
	stio_dev_pro_on_write_t on_write;
 | 
			
		||||
 | 
			
		||||
	stio_tmridx_t tmridx_connect;
 | 
			
		||||
 | 
			
		||||
	stio_mchar_t* mcmd;
 | 
			
		||||
	int flags;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct stio_dev_pro_slave_t
 | 
			
		||||
{
 | 
			
		||||
	STIO_DEV_HEADERS;
 | 
			
		||||
	int id;
 | 
			
		||||
	stio_syshnd_t pfd;
 | 
			
		||||
	stio_dev_pro_t* master; /* parent device */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum stio_dev_pro_make_flag_t
 | 
			
		||||
@ -75,7 +84,10 @@ enum stio_dev_pro_make_flag_t
 | 
			
		||||
 | 
			
		||||
	STUO_DEV_PRO_DROPIN   = (1 << 8),
 | 
			
		||||
	STUO_DEV_PRO_DROPOUT  = (1 << 9),
 | 
			
		||||
	STUO_DEV_PRO_DROPERR  = (1 << 10)
 | 
			
		||||
	STUO_DEV_PRO_DROPERR  = (1 << 10),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	STIO_DEV_PRO_SHELL    = (1 << 13),
 | 
			
		||||
};
 | 
			
		||||
typedef enum stio_dev_pro_make_flag_t stio_dev_pro_make_flag_t;
 | 
			
		||||
 | 
			
		||||
@ -103,10 +115,18 @@ STIO_EXPORT void stio_dev_pro_kill (
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
STIO_EXPORT int stio_dev_pro_write (
 | 
			
		||||
	stio_dev_pro_t*  pro,
 | 
			
		||||
	const void*      data,
 | 
			
		||||
	stio_iolen_t     len,
 | 
			
		||||
	void*            wrctx
 | 
			
		||||
	stio_dev_pro_t*     pro,
 | 
			
		||||
	const void*         data,
 | 
			
		||||
	stio_iolen_t        len,
 | 
			
		||||
	void*               wrctx
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
STIO_EXPORT int stio_dev_pro_timedwrite (
 | 
			
		||||
	stio_dev_pro_t*     pro,
 | 
			
		||||
	const void*         data,
 | 
			
		||||
	stio_iolen_t        len,
 | 
			
		||||
	const stio_ntime_t* tmout,
 | 
			
		||||
	void*               wrctx
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
 | 
			
		||||
@ -64,7 +64,17 @@ struct stio_t
 | 
			
		||||
		stio_dev_t* tail;
 | 
			
		||||
	} dev; /* normal devices */
 | 
			
		||||
 | 
			
		||||
	stio_dev_t* hdev; /* halted device list - singly linked list */
 | 
			
		||||
	struct
 | 
			
		||||
	{
 | 
			
		||||
		stio_dev_t* head;
 | 
			
		||||
		stio_dev_t* tail;
 | 
			
		||||
	} hdev; /* halted devices */
 | 
			
		||||
 | 
			
		||||
	struct
 | 
			
		||||
	{
 | 
			
		||||
		stio_dev_t* head;
 | 
			
		||||
		stio_dev_t* tail;
 | 
			
		||||
	} kdev; /* killed devices */
 | 
			
		||||
 | 
			
		||||
	stio_uint8_t bigbuf[65535]; /* TODO: make this dynamic depending on devices added. device may indicate a buffer size required??? */
 | 
			
		||||
 | 
			
		||||
@ -88,8 +98,6 @@ struct stio_t
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define STIO_EPOCH_YEAR  (1970)
 | 
			
		||||
#define STIO_EPOCH_MON   (1)
 | 
			
		||||
#define STIO_EPOCH_DAY   (1)
 | 
			
		||||
@ -155,6 +163,32 @@ stio_errnum_t stio_syserrtoerrnum (
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
stio_mchar_t* stio_mbsdup (
 | 
			
		||||
	stio_t*             stio,
 | 
			
		||||
	const stio_mchar_t* src
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
stio_size_t stio_mbscpy (
 | 
			
		||||
	stio_mchar_t*       buf,
 | 
			
		||||
	const stio_mchar_t* str
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
int stio_mbsspltrn (
 | 
			
		||||
	stio_mchar_t*       s,
 | 
			
		||||
	const stio_mchar_t* delim,
 | 
			
		||||
	stio_mchar_t        lquote,
 | 
			
		||||
	stio_mchar_t        rquote, 
 | 
			
		||||
	stio_mchar_t        escape,
 | 
			
		||||
	const stio_mchar_t* trset
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
int stio_mbsspl (
 | 
			
		||||
	stio_mchar_t*       s,
 | 
			
		||||
	const stio_mchar_t* delim,
 | 
			
		||||
	stio_mchar_t        lquote,
 | 
			
		||||
	stio_mchar_t        rquote,
 | 
			
		||||
	stio_mchar_t        escape
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
void stio_cleartmrjobs (
 | 
			
		||||
	stio_t* stio
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										411
									
								
								stio/lib/stio.c
									
									
									
									
									
								
							
							
						
						
									
										411
									
								
								stio/lib/stio.c
									
									
									
									
									
								
							@ -33,6 +33,8 @@
 | 
			
		||||
 | 
			
		||||
#define DEV_CAPA_ALL_WATCHED (STIO_DEV_CAPA_IN_WATCHED | STIO_DEV_CAPA_OUT_WATCHED | STIO_DEV_CAPA_PRI_WATCHED)
 | 
			
		||||
 | 
			
		||||
#define IS_MSPACE(x) ((x) == STIO_MT(' ') || (x) == STIO_MT('\t'))
 | 
			
		||||
 | 
			
		||||
stio_t* stio_open (stio_mmgr_t* mmgr, stio_size_t xtnsize, stio_size_t tmrcapa, stio_errnum_t* errnum)
 | 
			
		||||
{
 | 
			
		||||
	stio_t* stio;
 | 
			
		||||
@ -432,13 +434,8 @@ static STIO_INLINE int __exec (stio_t* stio)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* kill all halted devices */
 | 
			
		||||
	while (stio->hdev)
 | 
			
		||||
	{
 | 
			
		||||
		stio_dev_t* next;
 | 
			
		||||
		next = stio->hdev->dev_next;
 | 
			
		||||
		stio_killdev (stio, stio->hdev);
 | 
			
		||||
		stio->hdev = next;
 | 
			
		||||
	}
 | 
			
		||||
	while (stio->hdev.head) stio_killdev (stio, stio->hdev.head);
 | 
			
		||||
	STIO_ASSERT (stio->hdev.tail == STIO_NULL);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -480,7 +477,6 @@ int stio_loop (stio_t* stio)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
stio_dev_t* stio_makedev (stio_t* stio, stio_size_t dev_size, stio_dev_mth_t* dev_mth, stio_dev_evcb_t* dev_evcb, void* make_ctx)
 | 
			
		||||
{
 | 
			
		||||
	stio_dev_t* dev;
 | 
			
		||||
@ -556,6 +552,12 @@ void stio_killdev (stio_t* stio, stio_dev_t* dev)
 | 
			
		||||
{
 | 
			
		||||
	STIO_ASSERT (stio == dev->stio);
 | 
			
		||||
 | 
			
		||||
	if (dev->dev_capa & STIO_DEV_CAPA_KILLED)
 | 
			
		||||
	{
 | 
			
		||||
		STIO_ASSERT (STIO_WQ_ISEMPTY(&dev->wq));
 | 
			
		||||
		goto kill_device;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* clear pending send requests */
 | 
			
		||||
	while (!STIO_WQ_ISEMPTY(&dev->wq))
 | 
			
		||||
	{
 | 
			
		||||
@ -566,7 +568,19 @@ void stio_killdev (stio_t* stio, stio_dev_t* dev)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* delink the dev object */
 | 
			
		||||
	if (!(dev->dev_capa & STIO_DEV_CAPA_HALTED))
 | 
			
		||||
	if (dev->dev_capa & STIO_DEV_CAPA_HALTED)
 | 
			
		||||
	{
 | 
			
		||||
		if (dev->dev_prev)
 | 
			
		||||
			dev->dev_prev->dev_next = dev->dev_next;
 | 
			
		||||
		else
 | 
			
		||||
			stio->hdev.head = dev->dev_next;
 | 
			
		||||
 | 
			
		||||
		if (dev->dev_next)
 | 
			
		||||
			dev->dev_next->dev_prev = dev->dev_prev;
 | 
			
		||||
		else
 | 
			
		||||
			stio->hdev.tail = dev->dev_prev;
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (dev->dev_prev)
 | 
			
		||||
			dev->dev_prev->dev_next = dev->dev_next;
 | 
			
		||||
@ -581,10 +595,52 @@ void stio_killdev (stio_t* stio, stio_dev_t* dev)
 | 
			
		||||
 | 
			
		||||
	stio_dev_watch (dev, STIO_DEV_WATCH_STOP, 0);
 | 
			
		||||
 | 
			
		||||
	/* and call the callback function */
 | 
			
		||||
	dev->dev_mth->kill (dev);
 | 
			
		||||
kill_device:
 | 
			
		||||
	/* call the kill callback function */
 | 
			
		||||
	if (dev->dev_mth->kill(dev) <= -1)
 | 
			
		||||
	{
 | 
			
		||||
		stio_tmrjob_t kill_job;
 | 
			
		||||
 | 
			
		||||
	STIO_MMGR_FREE (stio->mmgr, dev);
 | 
			
		||||
		if (!(dev->dev_capa & STIO_DEV_CAPA_KILLED))
 | 
			
		||||
		{
 | 
			
		||||
			dev->dev_capa &= STIO_DEV_CAPA_KILLED;
 | 
			
		||||
 | 
			
		||||
			/* place it at the back of the killed device list */
 | 
			
		||||
			if (stio->hdev.tail) stio->hdev.tail->dev_next = dev;
 | 
			
		||||
			else stio->hdev.head = dev;
 | 
			
		||||
			dev->dev_prev = stio->hdev.tail;
 | 
			
		||||
			dev->dev_next = STIO_NULL;
 | 
			
		||||
			stio->hdev.tail = dev;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/* TODO: schedule a timer job for delayed kills */
 | 
			
		||||
		STIO_MEMSET (&kill_job, 0, STIO_SIZEOF(kill_job));
 | 
			
		||||
		kill_job.ctx = rdev;
 | 
			
		||||
		stio_gettime (&kill_job.when);
 | 
			
		||||
		stio_addtime (&kill_job.when, &conn->tmout, &kill_job.when);
 | 
			
		||||
		kill_job.handler = tmr_connect_handle;
 | 
			
		||||
		kill_job.idxptr = &rdev->tmridx_connect;
 | 
			
		||||
 | 
			
		||||
		stio_instmrjob (dev->stio, &kill_job);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (dev->dev_capa & STIO_DEV_CAPA_KILLED)
 | 
			
		||||
		{
 | 
			
		||||
			/* detach it from the killed device list */
 | 
			
		||||
			if (dev->dev_prev)
 | 
			
		||||
				dev->dev_prev->dev_next = dev->dev_next;
 | 
			
		||||
			else
 | 
			
		||||
				stio->kdev.head = dev->dev_next;
 | 
			
		||||
 | 
			
		||||
			if (dev->dev_next)
 | 
			
		||||
				dev->dev_next->dev_prev = dev->dev_prev;
 | 
			
		||||
			else
 | 
			
		||||
				stio->kdev.tail = dev->dev_prev;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		STIO_MMGR_FREE (stio->mmgr, dev);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void stio_dev_halt (stio_dev_t* dev)
 | 
			
		||||
@ -605,11 +661,12 @@ void stio_dev_halt (stio_dev_t* dev)
 | 
			
		||||
		else
 | 
			
		||||
			stio->dev.tail = dev->dev_prev;
 | 
			
		||||
 | 
			
		||||
		/* place it at the beginning of the halted device list.
 | 
			
		||||
		 * the halted device list is singly linked. */
 | 
			
		||||
		dev->dev_prev = STIO_NULL;
 | 
			
		||||
		dev->dev_next = stio->hdev;
 | 
			
		||||
		stio->hdev = dev;
 | 
			
		||||
		/* place it at the back of the halted device list */
 | 
			
		||||
		if (stio->hdev.tail) stio->hdev.tail->dev_next = dev;
 | 
			
		||||
		else stio->hdev.head = dev;
 | 
			
		||||
		dev->dev_prev = stio->hdev.tail;
 | 
			
		||||
		dev->dev_next = STIO_NULL;
 | 
			
		||||
		stio->hdev.tail = dev;
 | 
			
		||||
 | 
			
		||||
		dev->dev_capa |= STIO_DEV_CAPA_HALTED;
 | 
			
		||||
	}
 | 
			
		||||
@ -628,6 +685,12 @@ int stio_dev_watch (stio_dev_t* dev, stio_dev_watch_cmd_t cmd, int events)
 | 
			
		||||
	int epoll_op;
 | 
			
		||||
	int dev_capa;
 | 
			
		||||
 | 
			
		||||
	/* the virtual device doesn't perform actual I/O.
 | 
			
		||||
	 * it's different from not hanving STIO_DEV_CAPA_IN and STIO_DEV_CAPA_OUT.
 | 
			
		||||
	 * a non-virtual device without the capabilities still gets attention
 | 
			
		||||
	 * of the system multiplexer for hangup and error. */
 | 
			
		||||
	if (dev->dev_capa & STIO_DEV_CAPA_VIRTUAL) return 0;
 | 
			
		||||
 | 
			
		||||
	ev.data.ptr = dev;
 | 
			
		||||
	switch (cmd)
 | 
			
		||||
	{
 | 
			
		||||
@ -699,6 +762,7 @@ int stio_dev_watch (stio_dev_t* dev, stio_dev_watch_cmd_t cmd, int events)
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
printf ("MODING cmd=%d %d\n", (int)cmd, (int)dev->dev_mth->getsyshnd(dev));
 | 
			
		||||
		if (epoll_ctl (dev->stio->mux, epoll_op, dev->dev_mth->getsyshnd(dev), &ev) == -1)
 | 
			
		||||
		{
 | 
			
		||||
			dev->stio->errnum = stio_syserrtoerrnum(errno);
 | 
			
		||||
@ -965,3 +1029,316 @@ stio_errnum_t stio_syserrtoerrnum (int no)
 | 
			
		||||
			return STIO_ESYSERR;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
stio_mchar_t* stio_mbsdup (stio_t* stio, const stio_mchar_t* src)
 | 
			
		||||
{
 | 
			
		||||
	stio_mchar_t* dst;
 | 
			
		||||
	stio_size_t len;
 | 
			
		||||
 | 
			
		||||
	dst = (stio_mchar_t*)src;
 | 
			
		||||
	while (*dst != STIO_MT('\0')) dst++;
 | 
			
		||||
	len = dst - src;
 | 
			
		||||
 | 
			
		||||
	dst = STIO_MMGR_ALLOC (stio->mmgr, (len + 1) * STIO_SIZEOF(*src));
 | 
			
		||||
	if (!dst)
 | 
			
		||||
	{
 | 
			
		||||
		stio->errnum = STIO_ENOMEM;
 | 
			
		||||
		return STIO_NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	STIO_MEMCPY (dst, src, (len + 1) * STIO_SIZEOF(*src));
 | 
			
		||||
	return dst;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
stio_size_t stio_mbscpy (stio_mchar_t* buf, const stio_mchar_t* str)
 | 
			
		||||
{
 | 
			
		||||
	stio_mchar_t* org = buf;
 | 
			
		||||
	while ((*buf++ = *str++) != STIO_MT('\0'));
 | 
			
		||||
	return buf - org - 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int stio_mbsspltrn (
 | 
			
		||||
	stio_mchar_t* s, const stio_mchar_t* delim,
 | 
			
		||||
	stio_mchar_t lquote, stio_mchar_t rquote, 
 | 
			
		||||
	stio_mchar_t escape, const stio_mchar_t* trset)
 | 
			
		||||
{
 | 
			
		||||
	stio_mchar_t* p = s, *d;
 | 
			
		||||
	stio_mchar_t* sp = STIO_NULL, * ep = STIO_NULL;
 | 
			
		||||
	int delim_mode;
 | 
			
		||||
	int cnt = 0;
 | 
			
		||||
 | 
			
		||||
	if (delim == STIO_NULL) delim_mode = 0;
 | 
			
		||||
	else 
 | 
			
		||||
	{
 | 
			
		||||
		delim_mode = 1;
 | 
			
		||||
		for (d = (stio_mchar_t*)delim; *d != STIO_MT('\0'); d++)
 | 
			
		||||
			if (!IS_MSPACE(*d)) delim_mode = 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (delim_mode == 0) 
 | 
			
		||||
	{
 | 
			
		||||
		/* skip preceding space characters */
 | 
			
		||||
		while (IS_MSPACE(*p)) p++;
 | 
			
		||||
 | 
			
		||||
		/* when 0 is given as "delim", it has an effect of cutting
 | 
			
		||||
		   preceding and trailing space characters off "s". */
 | 
			
		||||
		if (lquote != STIO_MT('\0') && *p == lquote) 
 | 
			
		||||
		{
 | 
			
		||||
			stio_mbscpy (p, p + 1);
 | 
			
		||||
 | 
			
		||||
			for (;;) 
 | 
			
		||||
			{
 | 
			
		||||
				if (*p == STIO_MT('\0')) return -1;
 | 
			
		||||
 | 
			
		||||
				if (escape != STIO_MT('\0') && *p == escape) 
 | 
			
		||||
				{
 | 
			
		||||
					if (trset != STIO_NULL && p[1] != STIO_MT('\0'))
 | 
			
		||||
					{
 | 
			
		||||
						const stio_mchar_t* ep = trset;
 | 
			
		||||
						while (*ep != STIO_MT('\0'))
 | 
			
		||||
						{
 | 
			
		||||
							if (p[1] == *ep++) 
 | 
			
		||||
							{
 | 
			
		||||
								p[1] = *ep;
 | 
			
		||||
								break;
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					stio_mbscpy (p, p + 1);
 | 
			
		||||
				}
 | 
			
		||||
				else 
 | 
			
		||||
				{
 | 
			
		||||
					if (*p == rquote) 
 | 
			
		||||
					{
 | 
			
		||||
						p++;
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (sp == 0) sp = p;
 | 
			
		||||
				ep = p;
 | 
			
		||||
				p++;
 | 
			
		||||
			}
 | 
			
		||||
			while (IS_MSPACE(*p)) p++;
 | 
			
		||||
			if (*p != STIO_MT('\0')) return -1;
 | 
			
		||||
 | 
			
		||||
			if (sp == 0 && ep == 0) s[0] = STIO_MT('\0');
 | 
			
		||||
			else 
 | 
			
		||||
			{
 | 
			
		||||
				ep[1] = STIO_MT('\0');
 | 
			
		||||
				if (s != (stio_mchar_t*)sp) stio_mbscpy (s, sp);
 | 
			
		||||
				cnt++;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else 
 | 
			
		||||
		{
 | 
			
		||||
			while (*p) 
 | 
			
		||||
			{
 | 
			
		||||
				if (!IS_MSPACE(*p)) 
 | 
			
		||||
				{
 | 
			
		||||
					if (sp == 0) sp = p;
 | 
			
		||||
					ep = p;
 | 
			
		||||
				}
 | 
			
		||||
				p++;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (sp == 0 && ep == 0) s[0] = STIO_MT('\0');
 | 
			
		||||
			else 
 | 
			
		||||
			{
 | 
			
		||||
				ep[1] = STIO_MT('\0');
 | 
			
		||||
				if (s != (stio_mchar_t*)sp) stio_mbscpy (s, sp);
 | 
			
		||||
				cnt++;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else if (delim_mode == 1) 
 | 
			
		||||
	{
 | 
			
		||||
		stio_mchar_t* o;
 | 
			
		||||
 | 
			
		||||
		while (*p) 
 | 
			
		||||
		{
 | 
			
		||||
			o = p;
 | 
			
		||||
			while (IS_MSPACE(*p)) p++;
 | 
			
		||||
			if (o != p) { stio_mbscpy (o, p); p = o; }
 | 
			
		||||
 | 
			
		||||
			if (lquote != STIO_MT('\0') && *p == lquote) 
 | 
			
		||||
			{
 | 
			
		||||
				stio_mbscpy (p, p + 1);
 | 
			
		||||
 | 
			
		||||
				for (;;) 
 | 
			
		||||
				{
 | 
			
		||||
					if (*p == STIO_MT('\0')) return -1;
 | 
			
		||||
 | 
			
		||||
					if (escape != STIO_MT('\0') && *p == escape) 
 | 
			
		||||
					{
 | 
			
		||||
						if (trset != STIO_NULL && p[1] != STIO_MT('\0'))
 | 
			
		||||
						{
 | 
			
		||||
							const stio_mchar_t* ep = trset;
 | 
			
		||||
							while (*ep != STIO_MT('\0'))
 | 
			
		||||
							{
 | 
			
		||||
								if (p[1] == *ep++) 
 | 
			
		||||
								{
 | 
			
		||||
									p[1] = *ep;
 | 
			
		||||
									break;
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						stio_mbscpy (p, p + 1);
 | 
			
		||||
					}
 | 
			
		||||
					else 
 | 
			
		||||
					{
 | 
			
		||||
						if (*p == rquote) 
 | 
			
		||||
						{
 | 
			
		||||
							*p++ = STIO_MT('\0');
 | 
			
		||||
							cnt++;
 | 
			
		||||
							break;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					p++;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else 
 | 
			
		||||
			{
 | 
			
		||||
				o = p;
 | 
			
		||||
				for (;;) 
 | 
			
		||||
				{
 | 
			
		||||
					if (*p == STIO_MT('\0')) 
 | 
			
		||||
					{
 | 
			
		||||
						if (o != p) cnt++;
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
					if (IS_MSPACE (*p)) 
 | 
			
		||||
					{
 | 
			
		||||
						*p++ = STIO_MT('\0');
 | 
			
		||||
						cnt++;
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
					p++;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else /* if (delim_mode == 2) */
 | 
			
		||||
	{
 | 
			
		||||
		stio_mchar_t* o;
 | 
			
		||||
		int ok;
 | 
			
		||||
 | 
			
		||||
		while (*p != STIO_MT('\0')) 
 | 
			
		||||
		{
 | 
			
		||||
			o = p;
 | 
			
		||||
			while (IS_MSPACE(*p)) p++;
 | 
			
		||||
			if (o != p) { stio_mbscpy (o, p); p = o; }
 | 
			
		||||
 | 
			
		||||
			if (lquote != STIO_MT('\0') && *p == lquote) 
 | 
			
		||||
			{
 | 
			
		||||
				stio_mbscpy (p, p + 1);
 | 
			
		||||
 | 
			
		||||
				for (;;) 
 | 
			
		||||
				{
 | 
			
		||||
					if (*p == STIO_MT('\0')) return -1;
 | 
			
		||||
 | 
			
		||||
					if (escape != STIO_MT('\0') && *p == escape) 
 | 
			
		||||
					{
 | 
			
		||||
						if (trset != STIO_NULL && p[1] != STIO_MT('\0'))
 | 
			
		||||
						{
 | 
			
		||||
							const stio_mchar_t* ep = trset;
 | 
			
		||||
							while (*ep != STIO_MT('\0'))
 | 
			
		||||
							{
 | 
			
		||||
								if (p[1] == *ep++) 
 | 
			
		||||
								{
 | 
			
		||||
									p[1] = *ep;
 | 
			
		||||
									break;
 | 
			
		||||
								}
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						stio_mbscpy (p, p + 1);
 | 
			
		||||
					}
 | 
			
		||||
					else 
 | 
			
		||||
					{
 | 
			
		||||
						if (*p == rquote) 
 | 
			
		||||
						{
 | 
			
		||||
							*p++ = STIO_MT('\0');
 | 
			
		||||
							cnt++;
 | 
			
		||||
							break;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					p++;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				ok = 0;
 | 
			
		||||
				while (IS_MSPACE(*p)) p++;
 | 
			
		||||
				if (*p == STIO_MT('\0')) ok = 1;
 | 
			
		||||
				for (d = (stio_mchar_t*)delim; *d != STIO_MT('\0'); d++) 
 | 
			
		||||
				{
 | 
			
		||||
					if (*p == *d) 
 | 
			
		||||
					{
 | 
			
		||||
						ok = 1;
 | 
			
		||||
						stio_mbscpy (p, p + 1);
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				if (ok == 0) return -1;
 | 
			
		||||
			}
 | 
			
		||||
			else 
 | 
			
		||||
			{
 | 
			
		||||
				o = p; sp = ep = 0;
 | 
			
		||||
 | 
			
		||||
				for (;;) 
 | 
			
		||||
				{
 | 
			
		||||
					if (*p == STIO_MT('\0')) 
 | 
			
		||||
					{
 | 
			
		||||
						if (ep) 
 | 
			
		||||
						{
 | 
			
		||||
							ep[1] = STIO_MT('\0');
 | 
			
		||||
							p = &ep[1];
 | 
			
		||||
						}
 | 
			
		||||
						cnt++;
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
					for (d = (stio_mchar_t*)delim; *d != STIO_MT('\0'); d++) 
 | 
			
		||||
					{
 | 
			
		||||
						if (*p == *d)  
 | 
			
		||||
						{
 | 
			
		||||
							if (sp == STIO_NULL) 
 | 
			
		||||
							{
 | 
			
		||||
								stio_mbscpy (o, p); p = o;
 | 
			
		||||
								*p++ = STIO_MT('\0');
 | 
			
		||||
							}
 | 
			
		||||
							else 
 | 
			
		||||
							{
 | 
			
		||||
								stio_mbscpy (&ep[1], p);
 | 
			
		||||
								stio_mbscpy (o, sp);
 | 
			
		||||
								o[ep - sp + 1] = STIO_MT('\0');
 | 
			
		||||
								p = &o[ep - sp + 2];
 | 
			
		||||
							}
 | 
			
		||||
							cnt++;
 | 
			
		||||
							/* last empty field after delim */
 | 
			
		||||
							if (*p == STIO_MT('\0')) cnt++;
 | 
			
		||||
							goto exit_point;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					if (!IS_MSPACE (*p)) 
 | 
			
		||||
					{
 | 
			
		||||
						if (sp == STIO_NULL) sp = p;
 | 
			
		||||
						ep = p;
 | 
			
		||||
					}
 | 
			
		||||
					p++;
 | 
			
		||||
				}
 | 
			
		||||
exit_point:
 | 
			
		||||
				;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return cnt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int stio_mbsspl (
 | 
			
		||||
	stio_mchar_t* s, const stio_mchar_t* delim,
 | 
			
		||||
	stio_mchar_t lquote, stio_mchar_t rquote, stio_mchar_t escape)
 | 
			
		||||
{
 | 
			
		||||
	return stio_mbsspltrn (s, delim, lquote, rquote, escape, STIO_NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -91,6 +91,10 @@ typedef stio_intptr_t stio_iolen_t; /* NOTE: this is a signed type */
 | 
			
		||||
enum stio_errnum_t
 | 
			
		||||
{
 | 
			
		||||
	STIO_ENOERR,
 | 
			
		||||
	STIO_ENOIMPL,
 | 
			
		||||
	STIO_ESYSERR,
 | 
			
		||||
	STIO_EINTERN,
 | 
			
		||||
 | 
			
		||||
	STIO_ENOMEM,
 | 
			
		||||
	STIO_EINVAL,
 | 
			
		||||
	STIO_ENOENT,
 | 
			
		||||
@ -104,9 +108,7 @@ enum stio_errnum_t
 | 
			
		||||
 | 
			
		||||
	STIO_EDEVMAKE,
 | 
			
		||||
	STIO_EDEVERR,
 | 
			
		||||
	STIO_EDEVHUP,
 | 
			
		||||
 | 
			
		||||
	STIO_ESYSERR
 | 
			
		||||
	STIO_EDEVHUP
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef enum stio_errnum_t stio_errnum_t;
 | 
			
		||||
@ -243,13 +245,11 @@ struct stio_dev_t
 | 
			
		||||
 | 
			
		||||
enum stio_dev_capa_t
 | 
			
		||||
{
 | 
			
		||||
	STIO_DEV_CAPA_IN           = (1 << 0),
 | 
			
		||||
	STIO_DEV_CAPA_OUT          = (1 << 1),
 | 
			
		||||
 | 
			
		||||
	STIO_DEV_CAPA_VIRTUAL      = (1 << 0),
 | 
			
		||||
	STIO_DEV_CAPA_IN           = (1 << 1),
 | 
			
		||||
	STIO_DEV_CAPA_OUT          = (1 << 2),
 | 
			
		||||
	/* #STIO_DEV_CAPA_PRI is meaningful only if #STIO_DEV_CAPA_IN is set */
 | 
			
		||||
	STIO_DEV_CAPA_PRI          = (1 << 2), 
 | 
			
		||||
 | 
			
		||||
	/*STIO_DEV_CAPA_HALFOPEN    = (1 << 3),*/
 | 
			
		||||
	STIO_DEV_CAPA_PRI          = (1 << 3), 
 | 
			
		||||
	STIO_DEV_CAPA_STREAM       = (1 << 4),
 | 
			
		||||
	STIO_DEV_CAPA_OUT_QUEUED   = (1 << 5),
 | 
			
		||||
 | 
			
		||||
@ -261,7 +261,8 @@ enum stio_dev_capa_t
 | 
			
		||||
	STIO_DEV_CAPA_OUT_WATCHED  = (1 << 13),
 | 
			
		||||
	STIO_DEV_CAPA_PRI_WATCHED  = (1 << 14), /**< can be set only if STIO_DEV_CAPA_IN_WATCHED is set */
 | 
			
		||||
 | 
			
		||||
	STIO_DEV_CAPA_HALTED       = (1 << 15)
 | 
			
		||||
	STIO_DEV_CAPA_HALTED       = (1 << 15),
 | 
			
		||||
	STIO_DEV_CAPA_KILLED       = (1 << 16)
 | 
			
		||||
};
 | 
			
		||||
typedef enum stio_dev_capa_t stio_dev_capa_t;
 | 
			
		||||
 | 
			
		||||
@ -462,21 +463,21 @@ STIO_EXPORT int stio_dev_read (
 | 
			
		||||
 * it returns 0. otherwise it returns -1.
 | 
			
		||||
 */ 
 | 
			
		||||
STIO_EXPORT int stio_dev_write (
 | 
			
		||||
	stio_dev_t*         dev,
 | 
			
		||||
	const void*         data,
 | 
			
		||||
	stio_dev_t*           dev,
 | 
			
		||||
	const void*           data,
 | 
			
		||||
	stio_iolen_t          len,
 | 
			
		||||
	void*               wrctx,
 | 
			
		||||
	const stio_devadr_t*   dstadr
 | 
			
		||||
	void*                 wrctx,
 | 
			
		||||
	const stio_devadr_t*  dstadr
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
STIO_EXPORT int stio_dev_timedwrite (
 | 
			
		||||
	stio_dev_t*         dev,
 | 
			
		||||
	const void*         data,
 | 
			
		||||
	stio_iolen_t          len,
 | 
			
		||||
	const stio_ntime_t* tmout,
 | 
			
		||||
	void*               wrctx,
 | 
			
		||||
	const stio_devadr_t*   dstadr
 | 
			
		||||
	stio_dev_t*          dev,
 | 
			
		||||
	const void*          data,
 | 
			
		||||
	stio_iolen_t         len,
 | 
			
		||||
	const stio_ntime_t*  tmout,
 | 
			
		||||
	void*                wrctx,
 | 
			
		||||
	const stio_devadr_t* dstadr
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
STIO_EXPORT void stio_dev_halt (
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user