From e0de95864892d1e119f91936d8b1294542ab2316 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 26 Nov 2008 22:23:22 +0100 Subject: SystemBackendPosix ist jetzt ein Modul --- Makefile.in | 2 +- compile | 142 ---- config.h.in | 56 +- configure | 1014 ++++++++++++++++++++++------ configure.ac | 14 +- src/Common/Backends/Makefile.am | 4 +- src/Common/Backends/Makefile.in | 7 +- src/Common/Backends/SystemBackendPosix.cpp | 284 -------- src/Common/Backends/SystemBackendPosix.h | 89 --- src/Makefile.am | 6 +- src/Makefile.in | 14 +- src/mad-core.cpp | 4 +- src/mad.cpp | 4 +- src/modules/Makefile.am | 9 + src/modules/Makefile.in | 507 ++++++++++++++ src/modules/SystemBackendPosix.cpp | 299 ++++++++ src/modules/SystemBackendPosix.h | 96 +++ 17 files changed, 1823 insertions(+), 728 deletions(-) delete mode 100755 compile delete mode 100644 src/Common/Backends/SystemBackendPosix.cpp delete mode 100644 src/Common/Backends/SystemBackendPosix.h create mode 100644 src/modules/Makefile.am create mode 100644 src/modules/Makefile.in create mode 100644 src/modules/SystemBackendPosix.cpp create mode 100644 src/modules/SystemBackendPosix.h diff --git a/Makefile.in b/Makefile.in index 392be65..c8cbfd2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,7 +35,7 @@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ - compile config/config.guess config/config.sub config/depcomp \ + config/config.guess config/config.sub config/depcomp \ config/install-sh config/ltmain.sh config/missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/argz.m4 \ diff --git a/compile b/compile deleted file mode 100755 index 1b1d232..0000000 --- a/compile +++ /dev/null @@ -1,142 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand `-c -o'. - -scriptversion=2005-05-14.22 - -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -case $1 in - '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand `-c -o'. -Remove `-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file `INSTALL'. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; -esac - -ofile= -cfile= -eat= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we strip `-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` - -# Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/config.h.in b/config.h.in index ff99577..b437711 100644 --- a/config.h.in +++ b/config.h.in @@ -34,7 +34,8 @@ you don't. */ #undef HAVE_DECL_CYGWIN_CONV_PATH -/* Define to 1 if you have the header file. */ +/* Define to 1 if you have the header file, and it defines `DIR'. + */ #undef HAVE_DIRENT_H /* Define if you have the GNU dld library. */ @@ -52,6 +53,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DL_H +/* Define to 1 if you have the `dup2' function. */ +#undef HAVE_DUP2 + /* Define if you have the _dyld_func_lookup function. */ #undef HAVE_DYLD @@ -61,6 +65,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if you have the `gethostname' function. */ +#undef HAVE_GETHOSTNAME + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -80,9 +87,18 @@ to 0 otherwise. */ #undef HAVE_MALLOC +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H @@ -108,12 +124,24 @@ /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDDEF_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR @@ -129,12 +157,23 @@ /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY +/* Define to 1 if you have the `strrchr' function. */ +#undef HAVE_STRRCHR + /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_DL_H +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H @@ -144,6 +183,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -208,6 +250,11 @@ #define below would cause a syntax error. */ #undef _UINT32_T +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef was allowed, the + #define below would cause a syntax error. */ +#undef _UINT64_T + /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef was allowed, the #define below would cause a syntax error. */ @@ -225,6 +272,9 @@ /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc +/* Define to `int' if does not define. */ +#undef pid_t + /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc @@ -242,6 +292,10 @@ such a type exists and the standard includes do not define it. */ #undef uint32_t +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef uint64_t + /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef uint8_t diff --git a/configure b/configure index 6a8b2a3..b68691c 100755 --- a/configure +++ b/configure @@ -1507,10 +1507,10 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer - --enable-static[=PKGS] build static libraries [default=no] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) @@ -2485,37 +2485,6 @@ fi MAINT=$MAINTAINER_MODE_TRUE -# Check whether --enable-static was given. -if test "${enable_static+set}" = set; then - enableval=$enable_static; p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -else - enable_static=no -fi - - - - - - - - - # Checks for programs. ac_ext=cpp @@ -5202,13 +5171,13 @@ if test "${lt_cv_nm_interface+set}" = set; then else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:5205: $ac_compile\"" >&5) + (eval echo "\"\$as_me:5174: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:5208: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:5177: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:5211: output\"" >&5) + (eval echo "\"\$as_me:5180: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -6308,7 +6277,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6311 "configure"' > conftest.$ac_ext + echo '#line 6280 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8174,6 +8143,36 @@ fi + # Check whether --enable-static was given. +if test "${enable_static+set}" = set; then + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=yes +fi + + + + + + + + # Check whether --with-pic was given. @@ -8603,11 +8602,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8606: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8605: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8610: \$? = $ac_status" >&5 + echo "$as_me:8609: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8927,11 +8926,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8930: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8929: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8934: \$? = $ac_status" >&5 + echo "$as_me:8933: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9032,11 +9031,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9035: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9034: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9039: \$? = $ac_status" >&5 + echo "$as_me:9038: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9087,11 +9086,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9090: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9089: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9094: \$? = $ac_status" >&5 + echo "$as_me:9093: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11848,7 +11847,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11851 "configure" +#line 11850 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11948,7 +11947,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11951 "configure" +#line 11950 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13951,11 +13950,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13954: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13953: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13958: \$? = $ac_status" >&5 + echo "$as_me:13957: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14050,11 +14049,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14053: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14052: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14057: \$? = $ac_status" >&5 + echo "$as_me:14056: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14102,11 +14101,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14105: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14104: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14109: \$? = $ac_status" >&5 + echo "$as_me:14108: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15985,7 +15984,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 15988 "configure" +#line 15987 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17150,6 +17149,7 @@ LTDLOPEN=`eval "\\$ECHO \"$libname_spec\""` + # Checks for libraries. @@ -17639,31 +17639,31 @@ LIBS=$ORIG_LIBS - -for ac_header in arpa/inet.h fcntl.h netinet/in.h stdint.h sys/socket.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" @@ -17682,166 +17682,652 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - ac_header_compiler=yes + eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no + eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include <$ac_header> + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || test ! -s conftest.err - }; then - ac_header_preproc=yes + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } +fi -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ----------------------------------- ## -## Report this to matthias@gamezock.de ## -## ----------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : else - eval "$as_ac_Header=\$ac_header_preproc" + ac_cv_search_opendir=no fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } - +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi -done - - -# Checks for typedefs, structures, and compiler characteristics. -{ echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 -echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } -if test "${ac_cv_header_stdbool_h+set}" = set; then +else + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include -#ifndef bool - "error: bool is not defined" -#endif -#ifndef false - "error: false is not defined" -#endif -#if false - "error: false is not 0" -#endif -#ifndef true - "error: true is not defined" -#endif -#if true != 1 - "error: true is not 1" -#endif -#ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" #endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -# if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a runtime - test, and that would make cross-compilation harder. +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6; } +if test "${ac_cv_header_sys_wait_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +int +main () +{ + int s; + wait (&s); + s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_sys_wait_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_sys_wait_h=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6; } +if test $ac_cv_header_sys_wait_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SYS_WAIT_H 1 +_ACEOF + +fi + + + + + + + + + + + +for ac_header in argz.h arpa/inet.h fcntl.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/socket.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ----------------------------------- ## +## Report this to matthias@gamezock.de ## +## ----------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +{ echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 +echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } +if test "${ac_cv_header_stdbool_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#ifndef bool + "error: bool is not defined" +#endif +#ifndef false + "error: false is not defined" +#endif +#if false + "error: false is not 0" +#endif +#ifndef true + "error: true is not defined" +#endif +#if true != 1 + "error: true is not 1" +#endif +#ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" +#endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + bool e = &s; + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; +# if defined __xlc__ || defined __GNUC__ + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a runtime + test, and that would make cross-compilation harder. Let us hope that IBM fixes the xlc bug, and also adds support for this kind of constant expression. In the meantime, this test will reject xlc, which is OK, since @@ -18078,6 +18564,69 @@ _ACEOF fi +{ echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } +if test "${ac_cv_type_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef pid_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_pid_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_pid_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6; } +if test $ac_cv_type_pid_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + { echo "$as_me:$LINENO: checking for size_t" >&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } if test "${ac_cv_type_size_t+set}" = set; then @@ -18353,6 +18902,82 @@ _ACEOF esac + { echo "$as_me:$LINENO: checking for uint64_t" >&5 +echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6; } +if test "${ac_cv_c_uint64_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_uint64_t=no + for ac_type in 'uint64_t' 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) -1 >> (64 - 1) == 1)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + case $ac_type in + uint64_t) ac_cv_c_uint64_t=yes ;; + *) ac_cv_c_uint64_t=$ac_type ;; +esac + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_uint64_t" != no && break + done +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_uint64_t" >&5 +echo "${ECHO_T}$ac_cv_c_uint64_t" >&6; } + case $ac_cv_c_uint64_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<\_ACEOF +#define _UINT64_T 1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define uint64_t $ac_cv_c_uint64_t +_ACEOF +;; + esac + + { echo "$as_me:$LINENO: checking for uint8_t" >&5 echo $ECHO_N "checking for uint8_t... $ECHO_C" >&6; } if test "${ac_cv_c_uint8_t+set}" = set; then @@ -19134,7 +19759,15 @@ _ACEOF -for ac_func in socket strerror strtol + + + + + + + + +for ac_func in dup2 gethostname memmove memset socket strcasecmp strchr strdup strerror strrchr strtol do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -19228,9 +19861,7 @@ fi done - - -ac_config_files="$ac_config_files Makefile libltdl/Makefile src/Makefile src/Client/Makefile src/Client/Requests/Makefile src/Common/Makefile src/Common/Backends/Makefile src/Common/Requests/Makefile src/Common/RequestHandlers/Makefile src/Core/Makefile src/Core/Backends/Makefile src/Core/Requests/Makefile src/Core/RequestHandlers/Makefile src/Daemon/Makefile src/Daemon/Backends/Makefile src/Daemon/Requests/Makefile src/Daemon/RequestHandlers/Makefile src/Net/Makefile src/Net/Packets/Makefile" +ac_config_files="$ac_config_files Makefile libltdl/Makefile src/Makefile src/Client/Makefile src/Client/Requests/Makefile src/Common/Makefile src/Common/Backends/Makefile src/Common/Requests/Makefile src/Common/RequestHandlers/Makefile src/Core/Makefile src/Core/Backends/Makefile src/Core/Requests/Makefile src/Core/RequestHandlers/Makefile src/Daemon/Makefile src/Daemon/Backends/Makefile src/Daemon/Requests/Makefile src/Daemon/RequestHandlers/Makefile src/Net/Makefile src/Net/Packets/Makefile src/modules/Makefile" cat >confcache <<\_ACEOF @@ -19862,10 +20493,10 @@ AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' -enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' +enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' @@ -20233,6 +20864,7 @@ do "src/Daemon/RequestHandlers/Makefile") CONFIG_FILES="$CONFIG_FILES src/Daemon/RequestHandlers/Makefile" ;; "src/Net/Makefile") CONFIG_FILES="$CONFIG_FILES src/Net/Makefile" ;; "src/Net/Packets/Makefile") CONFIG_FILES="$CONFIG_FILES src/Net/Packets/Makefile" ;; + "src/modules/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} @@ -21099,9 +21731,6 @@ available_tags="CXX " # ### BEGIN LIBTOOL CONFIG -# Whether or not to build static libraries. -build_old_libs=$enable_static - # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision @@ -21109,6 +21738,9 @@ macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared +# Whether or not to build static libraries. +build_old_libs=$enable_static + # What type of objects to build. pic_mode=$pic_mode diff --git a/configure.ac b/configure.ac index cc12a09..c7c69c6 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,6 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE(mad, 0.1) AM_MAINTAINER_MODE -AC_DISABLE_STATIC # Checks for programs. AC_PROG_CXX @@ -24,6 +23,7 @@ ORIG_LIBS=$LIBS LT_CONFIG_LTDL_DIR([libltdl]) LT_INIT([dlopen]) LTDL_INIT([recursive]) +AC_SUBST(LIBLTDL) # Checks for libraries. PKG_CHECK_MODULES(GnuTLS, gnutls, , AC_MSG_ERROR(Test for GnuTLS failed.)) @@ -37,15 +37,20 @@ AC_CHECK_LIB(readline, readline, AC_SUBST(READLINE_LIBS, -lreadline), AC_MSG_ERR LIBS=$ORIG_LIBS # Checks for header files. -AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdint.h sys/socket.h unistd.h]) +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/socket.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST +AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T +AC_TYPE_UINT64_T AC_TYPE_UINT8_T # Checks for library functions. @@ -53,9 +58,7 @@ AC_FUNC_MALLOC AC_HEADER_STDC AC_FUNC_REALLOC AC_TYPE_SIGNAL -AC_CHECK_FUNCS([socket strerror strtol]) - -AC_SUBST(LIBLTDL) +AC_CHECK_FUNCS([dup2 gethostname memmove memset socket strcasecmp strchr strdup strerror strrchr strtol]) AC_CONFIG_FILES([ Makefile @@ -77,6 +80,7 @@ AC_CONFIG_FILES([ src/Daemon/RequestHandlers/Makefile src/Net/Makefile src/Net/Packets/Makefile + src/modules/Makefile ]) AC_OUTPUT diff --git a/src/Common/Backends/Makefile.am b/src/Common/Backends/Makefile.am index 138e406..83e5b2f 100644 --- a/src/Common/Backends/Makefile.am +++ b/src/Common/Backends/Makefile.am @@ -1,4 +1,4 @@ noinst_LTLIBRARIES = libbackends.la -libbackends_la_SOURCES = SystemBackendPosix.cpp SystemBackendProc.cpp +libbackends_la_SOURCES = SystemBackendProc.cpp -noinst_HEADERS = ConsoleLogger.h FileLogger.h SystemBackendPosix.h SystemBackendProc.h +noinst_HEADERS = ConsoleLogger.h FileLogger.h SystemBackendProc.h diff --git a/src/Common/Backends/Makefile.in b/src/Common/Backends/Makefile.in index b07c25e..fd44c4d 100644 --- a/src/Common/Backends/Makefile.in +++ b/src/Common/Backends/Makefile.in @@ -49,7 +49,7 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libbackends_la_LIBADD = -am_libbackends_la_OBJECTS = SystemBackendPosix.lo SystemBackendProc.lo +am_libbackends_la_OBJECTS = SystemBackendProc.lo libbackends_la_OBJECTS = $(am_libbackends_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/config/depcomp @@ -207,8 +207,8 @@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libbackends.la -libbackends_la_SOURCES = SystemBackendPosix.cpp SystemBackendProc.cpp -noinst_HEADERS = ConsoleLogger.h FileLogger.h SystemBackendPosix.h SystemBackendProc.h +libbackends_la_SOURCES = SystemBackendProc.cpp +noinst_HEADERS = ConsoleLogger.h FileLogger.h SystemBackendProc.h all: all-am .SUFFIXES: @@ -260,7 +260,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackendPosix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackendProc.Plo@am__quote@ .cpp.o: diff --git a/src/Common/Backends/SystemBackendPosix.cpp b/src/Common/Backends/SystemBackendPosix.cpp deleted file mode 100644 index bff72db..0000000 --- a/src/Common/Backends/SystemBackendPosix.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * SystemBackendPosix.cpp - * - * Copyright (C) 2008 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "SystemBackendPosix.h" -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -namespace Mad { -namespace Common { -namespace Backends { - -SystemBackendPosix SystemBackendPosix::backend; - -std::map > SystemBackendPosix::processes; -std::map > SystemBackendPosix::processesWithOutput; -std::map SystemBackendPosix::processesWOHandles; -std::map SystemBackendPosix::processesWOOutput; - - -void SystemBackendPosix::setChildHandler() { - struct sigaction action; - - action.sa_handler = childHandler; - sigemptyset(&action.sa_mask); - action.sa_flags = 0; - - sigaction(SIGCHLD, &action, 0); -} - -SystemBackendPosix::~SystemBackendPosix() { - struct sigaction action; - - action.sa_handler = SIG_DFL; - sigemptyset(&action.sa_mask); - action.sa_flags = 0; - - sigaction(SIGCHLD, &action, 0); -} - - -void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback) { - std::vector ret; - std::istringstream stream(output); - std::string str; - - std::getline(stream, str); // ignore first line - - while(!stream.eof()) { - std::getline(stream, str); - - char *fsName = new char[str.length()+1]; - char *mountedOn = new char[str.length()+1]; - - FSInfo info; - - if(std::sscanf(str.c_str(), "%s %lld %lld %lld %*d%% %s", fsName, &info.total, &info.used, &info.available, mountedOn) == 5) { - info.fsName = fsName; - info.mountedOn = mountedOn; - - ret.push_back(info); - } - - delete [] fsName; - delete [] mountedOn; - } - - callback(ret); -} - -bool SystemBackendPosix::fsInfo(const sigc::slot& > &callback) { - std::vector argv; - - argv.push_back("/bin/df"); - argv.push_back("-P"); - argv.push_back("-k"); - - return execWithOutput(sigc::bind(sigc::mem_fun(this, &SystemBackendPosix::fsInfoCallback), callback), "/bin/df", argv); -} - - -void SystemBackendPosix::childHandler(int) { - int status; - pid_t pid; - - // TODO Don't call callbacks directly - - while((pid = waitpid(-1, &status, WNOHANG)) > 0) { - std::map >::iterator it = processes.find(pid); - - if(it != processes.end()) { - it->second(status); - processes.erase(it); - } - else { - std::map >::iterator it2 = processesWithOutput.find(pid); - - if(it2 != processesWithOutput.end()) { - char buffer[1024]; - ssize_t n; - std::string &output = processesWOOutput[pid]; - int handle = processesWOHandles[pid]; - - while((n = read(handle, buffer, sizeof(buffer))) > 0) - output += std::string(buffer, n); - - Net::FdManager::get()->unregisterFd(handle); - close(handle); - - it2->second(status, output); - processesWithOutput.erase(it2); - processesWOHandles.erase(pid); - processesWOOutput.erase(pid); - } - } - } - - setChildHandler(); -} - -void SystemBackendPosix::outputHandler(short events, pid_t pid) { - char buf[1024]; - - if(events & POLLIN) { - sigset_t set, oldset; - sigemptyset(&set); - sigaddset(&set, SIGCHLD); - sigprocmask(SIG_BLOCK, &set, &oldset); - - ssize_t ret; - - std::map::iterator handle = processesWOHandles.find(pid); - if(handle == processesWOHandles.end()) - return; - - while((ret = read(handle->second, buf, sizeof(buf))) > 0) - processesWOOutput[pid] += std::string(buf, ret); - - sigprocmask(SIG_SETMASK, &oldset, 0); - } -} - -std::pair SystemBackendPosix::makeArgs(const std::string &filename, const std::vector &argv, const std::vector &env) { - char **argvp, **envp; - - if(argv.empty()) { - argvp = new char*[2]; - - argvp[0] = strdup(filename.c_str()); - argvp[1] = 0; - } - else { - argvp = new char*[argv.size() + 1]; - - for(size_t s = 0; s < argv.size(); ++s) { - argvp[s] = strdup(argv[s].c_str()); - } - - argvp[argv.size()] = 0; - } - - if(env.empty()) { - envp = environ; - } - else { - envp = new char*[env.size() + 1]; - - for(size_t s = 0; s < env.size(); ++s) { - envp[0] = strdup(env[s].c_str()); - } - - envp[env.size()] = 0; - } - - return std::make_pair(argvp, envp); -} - -void SystemBackendPosix::destroyArgs(std::pair args) { - for(char **p = args.first; *p != 0; ++p) - std::free(*p); - - delete [] args.first; - - if(args.second != environ) { - for(char **p = args.second; *p != 0; ++p) - std::free(*p); - - delete [] args.second; - } -} - -bool SystemBackendPosix::exec(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { - pid_t pid; - std::pair args = makeArgs(filename, argv, env); - - sigset_t set, oldset; - sigemptyset(&set); - sigaddset(&set, SIGCHLD); - sigprocmask(SIG_BLOCK, &set, &oldset); - - bool ret = (posix_spawnp(&pid, filename.c_str(), 0, 0, args.first, args.second) == 0); - - if(ret) - processes.insert(std::make_pair(pid, resultHandler)); - - sigprocmask(SIG_SETMASK, &oldset, 0); - - destroyArgs(args); - - return ret; -} - -bool SystemBackendPosix::execWithOutput(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { - pid_t pid; - std::pair args = makeArgs(filename, argv, env); - - int saveStdout = dup(STDOUT_FILENO); - int pipeHandles[2]; - - pipe(pipeHandles); - - fcntl(pipeHandles[0], F_SETFD, FD_CLOEXEC); - - int flags = fcntl(pipeHandles[0], F_GETFL, 0); - fcntl(pipeHandles[0], F_SETFL, flags | O_NONBLOCK); - - sigset_t set, oldset; - sigemptyset(&set); - sigaddset(&set, SIGCHLD); - sigprocmask(SIG_BLOCK, &set, &oldset); - - dup2(pipeHandles[1], STDOUT_FILENO); // set the new pipe as stdout - close(pipeHandles[1]); - - bool ret = (posix_spawnp(&pid, filename.c_str(), 0, 0, args.first, args.second) == 0); - - if(ret) { - processesWithOutput.insert(std::make_pair(pid, resultHandler)); - processesWOHandles.insert(std::make_pair(pid, pipeHandles[0])); - processesWOOutput.insert(std::make_pair(pid, std::string())); - - Net::FdManager::get()->registerFd(pipeHandles[0], sigc::bind(sigc::ptr_fun(&SystemBackendPosix::outputHandler), pid), POLLIN); - } - - dup2(saveStdout, STDOUT_FILENO); // restore old stdout - close(saveStdout); - - sigprocmask(SIG_SETMASK, &oldset, 0); - - destroyArgs(args); - - return ret; -} - -} -} -} diff --git a/src/Common/Backends/SystemBackendPosix.h b/src/Common/Backends/SystemBackendPosix.h deleted file mode 100644 index 59dd2d8..0000000 --- a/src/Common/Backends/SystemBackendPosix.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SystemBackendPosix.h - * - * Copyright (C) 2008 Matthias Schiffer - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef MAD_COMMON_BACKENDS_SYSTEMBACKENDPOSIX_H_ -#define MAD_COMMON_BACKENDS_SYSTEMBACKENDPOSIX_H_ - -#include "../SystemBackend.h" - -#include -#include -#include - -#include -#include -#include - -namespace Mad { -namespace Common { -namespace Backends { - -class SystemBackendPosix : public SystemBackend { - private: - static SystemBackendPosix backend; - static std::map > processes; - - static std::map > processesWithOutput; - static std::map processesWOHandles; - static std::map processesWOOutput; - - static void setChildHandler(); - - static void childHandler(int); - - static void outputHandler(short events, pid_t pid); - - static std::pair makeArgs(const std::string &filename, const std::vector &argv, const std::vector &env); - static void destroyArgs(std::pair args); - - SystemBackendPosix() { - setChildHandler(); - } - - void fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback); - - protected: - virtual bool fsInfo(const sigc::slot& > &callback); - - virtual bool doShutdown(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/halt");} - virtual bool doReboot(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/reboot");} - - public: - ~SystemBackendPosix(); - - static void registerBackend() { - SystemBackend::registerBackend(&backend); - } - - static void unregisterBackend() { - SystemBackend::unregisterBackend(&backend); - } - - static bool exec(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), - const std::vector &env = std::vector()); - - static bool execWithOutput(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), - const std::vector &env = std::vector()); -}; - -} -} -} - -#endif /* MAD_COMMON_BACKENDS_SYSTEMBACKENDPOSIX_H_ */ diff --git a/src/Makefile.am b/src/Makefile.am index 2c4a4d0..8819a06 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,11 +1,12 @@ -SUBDIRS = Common Client Core Daemon Net +SUBDIRS = Common Client Core Daemon Net modules bin_PROGRAMS = mad madc mad-core mad_SOURCES = mad.cpp mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la \ $(sigc_LIBS) $(GnuTLS_LIBS) @LIBLTDL@ - +mad_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la + madc_SOURCES = madc.cpp madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la \ $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS) @@ -13,3 +14,4 @@ madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la \ mad_core_SOURCES = mad-core.cpp mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la \ $(sigc_LIBS) $(GnuTLS_LIBS) $(GSSAPI_LIBS) @LIBLTDL@ +mad_core_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la diff --git a/src/Makefile.in b/src/Makefile.in index e40578a..841e70c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -54,11 +54,17 @@ mad_OBJECTS = $(am_mad_OBJECTS) am__DEPENDENCIES_1 = mad_DEPENDENCIES = Daemon/libdaemon.la Common/libcommon.la \ Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +mad_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(mad_LDFLAGS) \ + $(LDFLAGS) -o $@ am_mad_core_OBJECTS = mad-core.$(OBJEXT) mad_core_OBJECTS = $(am_mad_core_OBJECTS) mad_core_DEPENDENCIES = Core/libcore.la Common/libcommon.la \ Net/libnet.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) +mad_core_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(mad_core_LDFLAGS) $(LDFLAGS) -o $@ am_madc_OBJECTS = madc.$(OBJEXT) madc_OBJECTS = $(am_madc_OBJECTS) madc_DEPENDENCIES = Client/libclient.la Common/libcommon.la \ @@ -228,11 +234,12 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = Common Client Core Daemon Net +SUBDIRS = Common Client Core Daemon Net modules mad_SOURCES = mad.cpp mad_LDADD = Daemon/libdaemon.la Common/libcommon.la Net/libnet.la \ $(sigc_LIBS) $(GnuTLS_LIBS) @LIBLTDL@ +mad_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la madc_SOURCES = madc.cpp madc_LDADD = Client/libclient.la Common/libcommon.la Net/libnet.la \ $(sigc_LIBS) $(GnuTLS_LIBS) $(READLINE_LIBS) @@ -241,6 +248,7 @@ mad_core_SOURCES = mad-core.cpp mad_core_LDADD = Core/libcore.la Common/libcommon.la Net/libnet.la \ $(sigc_LIBS) $(GnuTLS_LIBS) $(GSSAPI_LIBS) @LIBLTDL@ +mad_core_LDFLAGS = -export-dynamic -dlopen modules/SystemBackendPosix.la all: all-recursive .SUFFIXES: @@ -304,10 +312,10 @@ clean-binPROGRAMS: done mad$(EXEEXT): $(mad_OBJECTS) $(mad_DEPENDENCIES) @rm -f mad$(EXEEXT) - $(CXXLINK) $(mad_OBJECTS) $(mad_LDADD) $(LIBS) + $(mad_LINK) $(mad_OBJECTS) $(mad_LDADD) $(LIBS) mad-core$(EXEEXT): $(mad_core_OBJECTS) $(mad_core_DEPENDENCIES) @rm -f mad-core$(EXEEXT) - $(CXXLINK) $(mad_core_OBJECTS) $(mad_core_LDADD) $(LIBS) + $(mad_core_LINK) $(mad_core_OBJECTS) $(mad_core_LDADD) $(LIBS) madc$(EXEEXT): $(madc_OBJECTS) $(madc_DEPENDENCIES) @rm -f madc$(EXEEXT) $(CXXLINK) $(madc_OBJECTS) $(madc_LDADD) $(LIBS) diff --git a/src/mad-core.cpp b/src/mad-core.cpp index 257f310..96c511f 100644 --- a/src/mad-core.cpp +++ b/src/mad-core.cpp @@ -20,8 +20,8 @@ #include "Common/ConfigManager.h" #include "Common/LogManager.h" #include "Common/Logger.h" -#include "Common/Backends/SystemBackendPosix.h" #include "Common/Backends/SystemBackendProc.h" +#include "Common/ModuleManager.h" #include "Core/ConnectionManager.h" #include @@ -41,8 +41,8 @@ int main() { Common::ConfigManager::get()->loadFile("mad-core.conf"); Common::ConfigManager::get()->finish(); - Common::Backends::SystemBackendPosix::registerBackend(); Common::Backends::SystemBackendProc::registerBackend(); + Common::ModuleManager::get()->loadModule("SystemBackendPosix.la"); while(true) Core::ConnectionManager::get()->run(); diff --git a/src/mad.cpp b/src/mad.cpp index 83f01bb..6500258 100644 --- a/src/mad.cpp +++ b/src/mad.cpp @@ -20,11 +20,11 @@ #include "Net/ClientConnection.h" #include "Net/FdManager.h" #include "Net/IPAddress.h" -#include "Common/Backends/SystemBackendPosix.h" #include "Common/Backends/SystemBackendProc.h" #include "Common/ConfigManager.h" #include "Common/LogManager.h" #include "Common/Logger.h" +#include "Common/ModuleManager.h" #include "Common/Request.h" #include "Common/RequestManager.h" #include "Common/RequestHandlers/FSInfoRequestHandler.h" @@ -52,8 +52,8 @@ int main() { Common::RequestManager::get()->registerPacketType(Net::Packet::COMMAND_REBOOT); Common::RequestManager::get()->registerPacketType(Net::Packet::COMMAND_SHUTDOWN); - Common::Backends::SystemBackendPosix::registerBackend(); Common::Backends::SystemBackendProc::registerBackend(); + Common::ModuleManager::get()->loadModule("SystemBackendPosix.la"); Net::ClientConnection *connection = new Net::ClientConnection; diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am new file mode 100644 index 0000000..d94701f --- /dev/null +++ b/src/modules/Makefile.am @@ -0,0 +1,9 @@ +madlibdir = ${libdir}/mad +moddir = ${madlibdir}/modules + +mod_LTLIBRARIES = SystemBackendPosix.la +SystemBackendPosix_la_SOURCES = SystemBackendPosix.cpp +SystemBackendPosix_la_LIBADD = $(sigc_LIBS) +SystemBackendPosix_la_LDFLAGS = -module -avoid-version -export-dynamic + +noinst_HEADERS = SystemBackendPosix.h diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in new file mode 100644 index 0000000..876828a --- /dev/null +++ b/src/modules/Makefile.in @@ -0,0 +1,507 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/modules +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/argz.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltdl.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(moddir)" +modLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(mod_LTLIBRARIES) +am__DEPENDENCIES_1 = +SystemBackendPosix_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_SystemBackendPosix_la_OBJECTS = SystemBackendPosix.lo +SystemBackendPosix_la_OBJECTS = $(am_SystemBackendPosix_la_OBJECTS) +SystemBackendPosix_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(SystemBackendPosix_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(SystemBackendPosix_la_SOURCES) +DIST_SOURCES = $(SystemBackendPosix_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +ARGZ_H = @ARGZ_H@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GSSAPI_LIBS = @GSSAPI_LIBS@ +GnuTLS_CFLAGS = @GnuTLS_CFLAGS@ +GnuTLS_LIBS = @GnuTLS_LIBS@ +INCLTDL = @INCLTDL@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBADD_DL = @LIBADD_DL@ +LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ +LIBADD_DLOPEN = @LIBADD_DLOPEN@ +LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ +LIBLTDL = @LIBLTDL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTDLDEPS = @LTDLDEPS@ +LTDLINCL = @LTDLINCL@ +LTDLOPEN = @LTDLOPEN@ +LTLIBOBJS = @LTLIBOBJS@ +LT_CONFIG_H = @LT_CONFIG_H@ +LT_DLLOADERS = @LT_DLLOADERS@ +LT_DLPREOPEN = @LT_DLPREOPEN@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +ltdl_LIBOBJS = @ltdl_LIBOBJS@ +ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sigc_CFLAGS = @sigc_CFLAGS@ +sigc_LIBS = @sigc_LIBS@ +srcdir = @srcdir@ +sys_symbol_underscore = @sys_symbol_underscore@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +madlibdir = ${libdir}/mad +moddir = ${madlibdir}/modules +mod_LTLIBRARIES = SystemBackendPosix.la +SystemBackendPosix_la_SOURCES = SystemBackendPosix.cpp +SystemBackendPosix_la_LIBADD = $(sigc_LIBS) +SystemBackendPosix_la_LDFLAGS = -module -avoid-version -export-dynamic +noinst_HEADERS = SystemBackendPosix.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/modules/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-modLTLIBRARIES: $(mod_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(moddir)" || $(MKDIR_P) "$(DESTDIR)$(moddir)" + @list='$(mod_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(modLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(moddir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(modLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(moddir)/$$f"; \ + else :; fi; \ + done + +uninstall-modLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(mod_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(moddir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(moddir)/$$p"; \ + done + +clean-modLTLIBRARIES: + -test -z "$(mod_LTLIBRARIES)" || rm -f $(mod_LTLIBRARIES) + @list='$(mod_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 +SystemBackendPosix.la: $(SystemBackendPosix_la_OBJECTS) $(SystemBackendPosix_la_DEPENDENCIES) + $(SystemBackendPosix_la_LINK) -rpath $(moddir) $(SystemBackendPosix_la_OBJECTS) $(SystemBackendPosix_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackendPosix.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +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; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + 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; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(moddir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-modLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-modLTLIBRARIES + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-modLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-modLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-modLTLIBRARIES 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-modLTLIBRARIES + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/modules/SystemBackendPosix.cpp b/src/modules/SystemBackendPosix.cpp new file mode 100644 index 0000000..d34b2c8 --- /dev/null +++ b/src/modules/SystemBackendPosix.cpp @@ -0,0 +1,299 @@ +/* + * SystemBackendPosix.cpp + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "SystemBackendPosix.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#define init SystemBackendPosix_LTX_init +#define deinit SystemBackendPosix_LTX_deinit + +namespace Mad { +namespace Modules { + +SystemBackendPosix *SystemBackendPosix::backend = 0; + +std::map > SystemBackendPosix::processes; +std::map > SystemBackendPosix::processesWithOutput; +std::map SystemBackendPosix::processesWOHandles; +std::map SystemBackendPosix::processesWOOutput; + + +void SystemBackendPosix::setChildHandler() { + struct sigaction action; + + action.sa_handler = childHandler; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + + sigaction(SIGCHLD, &action, 0); +} + +SystemBackendPosix::~SystemBackendPosix() { + struct sigaction action; + + action.sa_handler = SIG_DFL; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + + sigaction(SIGCHLD, &action, 0); +} + + +void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback) { + std::vector ret; + std::istringstream stream(output); + std::string str; + + std::getline(stream, str); // ignore first line + + while(!stream.eof()) { + std::getline(stream, str); + + char *fsName = new char[str.length()+1]; + char *mountedOn = new char[str.length()+1]; + + FSInfo info; + + if(std::sscanf(str.c_str(), "%s %lld %lld %lld %*d%% %s", fsName, &info.total, &info.used, &info.available, mountedOn) == 5) { + info.fsName = fsName; + info.mountedOn = mountedOn; + + ret.push_back(info); + } + + delete [] fsName; + delete [] mountedOn; + } + + callback(ret); +} + +bool SystemBackendPosix::fsInfo(const sigc::slot& > &callback) { + std::vector argv; + + argv.push_back("/bin/df"); + argv.push_back("-P"); + argv.push_back("-k"); + + return execWithOutput(sigc::bind(sigc::mem_fun(this, &SystemBackendPosix::fsInfoCallback), callback), "/bin/df", argv); +} + + +void SystemBackendPosix::childHandler(int) { + int status; + pid_t pid; + + // TODO Don't call callbacks directly + + while((pid = waitpid(-1, &status, WNOHANG)) > 0) { + std::map >::iterator it = processes.find(pid); + + if(it != processes.end()) { + it->second(status); + processes.erase(it); + } + else { + std::map >::iterator it2 = processesWithOutput.find(pid); + + if(it2 != processesWithOutput.end()) { + char buffer[1024]; + ssize_t n; + std::string &output = processesWOOutput[pid]; + int handle = processesWOHandles[pid]; + + while((n = read(handle, buffer, sizeof(buffer))) > 0) + output += std::string(buffer, n); + + Net::FdManager::get()->unregisterFd(handle); + close(handle); + + it2->second(status, output); + processesWithOutput.erase(it2); + processesWOHandles.erase(pid); + processesWOOutput.erase(pid); + } + } + } + + setChildHandler(); +} + +void SystemBackendPosix::outputHandler(short events, pid_t pid) { + char buf[1024]; + + if(events & POLLIN) { + sigset_t set, oldset; + sigemptyset(&set); + sigaddset(&set, SIGCHLD); + sigprocmask(SIG_BLOCK, &set, &oldset); + + ssize_t ret; + + std::map::iterator handle = processesWOHandles.find(pid); + if(handle == processesWOHandles.end()) + return; + + while((ret = read(handle->second, buf, sizeof(buf))) > 0) + processesWOOutput[pid] += std::string(buf, ret); + + sigprocmask(SIG_SETMASK, &oldset, 0); + } +} + +std::pair SystemBackendPosix::makeArgs(const std::string &filename, const std::vector &argv, const std::vector &env) { + char **argvp, **envp; + + if(argv.empty()) { + argvp = new char*[2]; + + argvp[0] = strdup(filename.c_str()); + argvp[1] = 0; + } + else { + argvp = new char*[argv.size() + 1]; + + for(size_t s = 0; s < argv.size(); ++s) { + argvp[s] = strdup(argv[s].c_str()); + } + + argvp[argv.size()] = 0; + } + + if(env.empty()) { + envp = environ; + } + else { + envp = new char*[env.size() + 1]; + + for(size_t s = 0; s < env.size(); ++s) { + envp[0] = strdup(env[s].c_str()); + } + + envp[env.size()] = 0; + } + + return std::make_pair(argvp, envp); +} + +void SystemBackendPosix::destroyArgs(std::pair args) { + for(char **p = args.first; *p != 0; ++p) + std::free(*p); + + delete [] args.first; + + if(args.second != environ) { + for(char **p = args.second; *p != 0; ++p) + std::free(*p); + + delete [] args.second; + } +} + +bool SystemBackendPosix::exec(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { + pid_t pid; + std::pair args = makeArgs(filename, argv, env); + + sigset_t set, oldset; + sigemptyset(&set); + sigaddset(&set, SIGCHLD); + sigprocmask(SIG_BLOCK, &set, &oldset); + + bool ret = (posix_spawnp(&pid, filename.c_str(), 0, 0, args.first, args.second) == 0); + + if(ret) + processes.insert(std::make_pair(pid, resultHandler)); + + sigprocmask(SIG_SETMASK, &oldset, 0); + + destroyArgs(args); + + return ret; +} + +bool SystemBackendPosix::execWithOutput(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { + pid_t pid; + std::pair args = makeArgs(filename, argv, env); + + int saveStdout = dup(STDOUT_FILENO); + int pipeHandles[2]; + + pipe(pipeHandles); + + fcntl(pipeHandles[0], F_SETFD, FD_CLOEXEC); + + int flags = fcntl(pipeHandles[0], F_GETFL, 0); + fcntl(pipeHandles[0], F_SETFL, flags | O_NONBLOCK); + + sigset_t set, oldset; + sigemptyset(&set); + sigaddset(&set, SIGCHLD); + sigprocmask(SIG_BLOCK, &set, &oldset); + + dup2(pipeHandles[1], STDOUT_FILENO); // set the new pipe as stdout + close(pipeHandles[1]); + + bool ret = (posix_spawnp(&pid, filename.c_str(), 0, 0, args.first, args.second) == 0); + + if(ret) { + processesWithOutput.insert(std::make_pair(pid, resultHandler)); + processesWOHandles.insert(std::make_pair(pid, pipeHandles[0])); + processesWOOutput.insert(std::make_pair(pid, std::string())); + + Net::FdManager::get()->registerFd(pipeHandles[0], sigc::bind(sigc::ptr_fun(&SystemBackendPosix::outputHandler), pid), POLLIN); + } + + dup2(saveStdout, STDOUT_FILENO); // restore old stdout + close(saveStdout); + + sigprocmask(SIG_SETMASK, &oldset, 0); + + destroyArgs(args); + + return ret; +} + +} +} + +extern "C" { + +void init() { + Mad::Modules::SystemBackendPosix::registerBackend(); +} + +void deinit() { + Mad::Modules::SystemBackendPosix::unregisterBackend(); +} + +} + diff --git a/src/modules/SystemBackendPosix.h b/src/modules/SystemBackendPosix.h new file mode 100644 index 0000000..9be16af --- /dev/null +++ b/src/modules/SystemBackendPosix.h @@ -0,0 +1,96 @@ +/* + * SystemBackendPosix.h + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_MODULE_SYSTEMBACKENDPOSIX_H_ +#define MAD_MODULE_SYSTEMBACKENDPOSIX_H_ + +#include + +#include +#include +#include + +#include +#include +#include + +namespace Mad { +namespace Modules { + +class SystemBackendPosix : public Common::SystemBackend { + private: + static SystemBackendPosix *backend; + static std::map > processes; + + static std::map > processesWithOutput; + static std::map processesWOHandles; + static std::map processesWOOutput; + + static void setChildHandler(); + + static void childHandler(int); + + static void outputHandler(short events, pid_t pid); + + static std::pair makeArgs(const std::string &filename, const std::vector &argv, const std::vector &env); + static void destroyArgs(std::pair args); + + SystemBackendPosix() { + setChildHandler(); + } + + void fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback); + + protected: + virtual bool fsInfo(const sigc::slot& > &callback); + + virtual bool doShutdown(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/halt");} + virtual bool doReboot(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/reboot");} + + public: + ~SystemBackendPosix(); + + static void registerBackend() { + if(backend) + return; + + backend = new SystemBackendPosix(); + SystemBackend::registerBackend(backend); + } + + static void unregisterBackend() { + if(!backend) + return; + + SystemBackend::unregisterBackend(backend); + delete backend; + backend = 0; + } + + static bool exec(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), + const std::vector &env = std::vector()); + + static bool execWithOutput(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv = std::vector(), + const std::vector &env = std::vector()); +}; + +} +} + +#endif /* MAD_MODULE_SYSTEMBACKENDPOSIX_H_ */ -- cgit v1.2.3