add xml
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1376 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
7bbb4ec19c
commit
3058335e80
|
@ -70,6 +70,7 @@ src/include/switch_version.h\
|
||||||
src/include/switch_rtp.h\
|
src/include/switch_rtp.h\
|
||||||
src/include/switch_stun.h\
|
src/include/switch_stun.h\
|
||||||
src/include/switch_log.h\
|
src/include/switch_log.h\
|
||||||
|
src/include/switch_xml.h\
|
||||||
src/switch_rtp.c\
|
src/switch_rtp.c\
|
||||||
src/switch_buffer.c \
|
src/switch_buffer.c \
|
||||||
src/switch_caller.c \
|
src/switch_caller.c \
|
||||||
|
@ -83,7 +84,8 @@ src/switch_event.c \
|
||||||
src/switch_resample.c \
|
src/switch_resample.c \
|
||||||
src/switch_ivr.c \
|
src/switch_ivr.c \
|
||||||
src/switch_stun.c\
|
src/switch_stun.c\
|
||||||
src/switch_log.c
|
src/switch_log.c\
|
||||||
|
src/switch_xml.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,7 +115,8 @@ src/include/switch_utils.h\
|
||||||
src/include/switch_rtp.h\
|
src/include/switch_rtp.h\
|
||||||
src/include/switch_version.h\
|
src/include/switch_version.h\
|
||||||
src/include/switch_stun.h\
|
src/include/switch_stun.h\
|
||||||
src/include/switch_log.h
|
src/include/switch_log.h\
|
||||||
|
src/include/switch_xml.h
|
||||||
|
|
||||||
BUILT_SOURCES = version depends
|
BUILT_SOURCES = version depends
|
||||||
CLEANFILES = src/include/switch_version.h
|
CLEANFILES = src/include/switch_version.h
|
||||||
|
|
17
Makefile.in
17
Makefile.in
|
@ -85,7 +85,7 @@ am_libfreeswitch_la_OBJECTS = libfreeswitch_la-switch_rtp.lo \
|
||||||
libfreeswitch_la-switch_event.lo \
|
libfreeswitch_la-switch_event.lo \
|
||||||
libfreeswitch_la-switch_resample.lo \
|
libfreeswitch_la-switch_resample.lo \
|
||||||
libfreeswitch_la-switch_ivr.lo libfreeswitch_la-switch_stun.lo \
|
libfreeswitch_la-switch_ivr.lo libfreeswitch_la-switch_stun.lo \
|
||||||
libfreeswitch_la-switch_log.lo
|
libfreeswitch_la-switch_log.lo libfreeswitch_la-switch_xml.lo
|
||||||
nodist_libfreeswitch_la_OBJECTS =
|
nodist_libfreeswitch_la_OBJECTS =
|
||||||
libfreeswitch_la_OBJECTS = $(am_libfreeswitch_la_OBJECTS) \
|
libfreeswitch_la_OBJECTS = $(am_libfreeswitch_la_OBJECTS) \
|
||||||
$(nodist_libfreeswitch_la_OBJECTS)
|
$(nodist_libfreeswitch_la_OBJECTS)
|
||||||
|
@ -288,6 +288,7 @@ src/include/switch_version.h\
|
||||||
src/include/switch_rtp.h\
|
src/include/switch_rtp.h\
|
||||||
src/include/switch_stun.h\
|
src/include/switch_stun.h\
|
||||||
src/include/switch_log.h\
|
src/include/switch_log.h\
|
||||||
|
src/include/switch_xml.h\
|
||||||
src/switch_rtp.c\
|
src/switch_rtp.c\
|
||||||
src/switch_buffer.c \
|
src/switch_buffer.c \
|
||||||
src/switch_caller.c \
|
src/switch_caller.c \
|
||||||
|
@ -301,7 +302,8 @@ src/switch_event.c \
|
||||||
src/switch_resample.c \
|
src/switch_resample.c \
|
||||||
src/switch_ivr.c \
|
src/switch_ivr.c \
|
||||||
src/switch_stun.c\
|
src/switch_stun.c\
|
||||||
src/switch_log.c
|
src/switch_log.c\
|
||||||
|
src/switch_xml.c
|
||||||
|
|
||||||
|
|
||||||
#bindir = $(PREFIX)/bin
|
#bindir = $(PREFIX)/bin
|
||||||
|
@ -330,7 +332,8 @@ src/include/switch_utils.h\
|
||||||
src/include/switch_rtp.h\
|
src/include/switch_rtp.h\
|
||||||
src/include/switch_version.h\
|
src/include/switch_version.h\
|
||||||
src/include/switch_stun.h\
|
src/include/switch_stun.h\
|
||||||
src/include/switch_log.h
|
src/include/switch_log.h\
|
||||||
|
src/include/switch_xml.h
|
||||||
|
|
||||||
BUILT_SOURCES = version depends
|
BUILT_SOURCES = version depends
|
||||||
CLEANFILES = src/include/switch_version.h
|
CLEANFILES = src/include/switch_version.h
|
||||||
|
@ -483,6 +486,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_rtp.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_rtp.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_stun.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_stun.Plo@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_utils.Plo@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_utils.Plo@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_xml.Plo@am__quote@
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||||
|
@ -603,6 +607,13 @@ libfreeswitch_la-switch_log.lo: src/switch_log.c
|
||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_log.lo `test -f 'src/switch_log.c' || echo '$(srcdir)/'`src/switch_log.c
|
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_log.lo `test -f 'src/switch_log.c' || echo '$(srcdir)/'`src/switch_log.c
|
||||||
|
|
||||||
|
libfreeswitch_la-switch_xml.lo: src/switch_xml.c
|
||||||
|
@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_xml.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_xml.Tpo" -c -o libfreeswitch_la-switch_xml.lo `test -f 'src/switch_xml.c' || echo '$(srcdir)/'`src/switch_xml.c; \
|
||||||
|
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libfreeswitch_la-switch_xml.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_xml.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_xml.Tpo"; exit 1; fi
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='src/switch_xml.c' object='libfreeswitch_la-switch_xml.lo' libtool=yes @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_xml.lo `test -f 'src/switch_xml.c' || echo '$(srcdir)/'`src/switch_xml.c
|
||||||
|
|
||||||
freeswitch-switch.o: src/switch.c
|
freeswitch-switch.o: src/switch.c
|
||||||
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(freeswitch_CFLAGS) $(CFLAGS) -MT freeswitch-switch.o -MD -MP -MF "$(DEPDIR)/freeswitch-switch.Tpo" -c -o freeswitch-switch.o `test -f 'src/switch.c' || echo '$(srcdir)/'`src/switch.c; \
|
@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(freeswitch_CFLAGS) $(CFLAGS) -MT freeswitch-switch.o -MD -MP -MF "$(DEPDIR)/freeswitch-switch.Tpo" -c -o freeswitch-switch.o `test -f 'src/switch.c' || echo '$(srcdir)/'`src/switch.c; \
|
||||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/freeswitch-switch.Tpo" "$(DEPDIR)/freeswitch-switch.Po"; else rm -f "$(DEPDIR)/freeswitch-switch.Tpo"; exit 1; fi
|
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/freeswitch-switch.Tpo" "$(DEPDIR)/freeswitch-switch.Po"; else rm -f "$(DEPDIR)/freeswitch-switch.Tpo"; exit 1; fi
|
||||||
|
|
|
@ -143,7 +143,7 @@ rm="rm -f"
|
||||||
default_ofile=libtool
|
default_ofile=libtool
|
||||||
can_build_shared=yes
|
can_build_shared=yes
|
||||||
|
|
||||||
# All known linkers require a `.a' archive for static linking (except MSVC,
|
# All known linkers require a `.a' archive for static linking (except M$VC,
|
||||||
# which needs '.lib').
|
# which needs '.lib').
|
||||||
libext=a
|
libext=a
|
||||||
ltmain="$ac_aux_dir/ltmain.sh"
|
ltmain="$ac_aux_dir/ltmain.sh"
|
||||||
|
@ -359,8 +359,8 @@ if test "X${echo_test_string+set}" != Xset; then
|
||||||
# find a string as large as possible, as long as the shell can cope with it
|
# find a string as large as possible, as long as the shell can cope with it
|
||||||
for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
|
for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
|
||||||
# expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
|
# expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
|
||||||
if (echo_test_string=`eval $cmd`) 2>/dev/null &&
|
if (echo_test_string="`eval $cmd`") 2>/dev/null &&
|
||||||
echo_test_string=`eval $cmd` &&
|
echo_test_string="`eval $cmd`" &&
|
||||||
(test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
|
(test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
|
@ -529,7 +529,7 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
|
||||||
# Find out which ABI we are using.
|
# Find out which ABI we are using.
|
||||||
echo 'int i;' > conftest.$ac_ext
|
echo 'int i;' > conftest.$ac_ext
|
||||||
if AC_TRY_EVAL(ac_compile); then
|
if AC_TRY_EVAL(ac_compile); then
|
||||||
case `/usr/bin/file conftest.o` in
|
case "`/usr/bin/file conftest.o`" in
|
||||||
*32-bit*)
|
*32-bit*)
|
||||||
case $host in
|
case $host in
|
||||||
x86_64-*linux*)
|
x86_64-*linux*)
|
||||||
|
@ -611,7 +611,7 @@ AC_CACHE_CHECK([$1], [$2],
|
||||||
# with a dollar sign (not a hyphen), so the echo should work correctly.
|
# with a dollar sign (not a hyphen), so the echo should work correctly.
|
||||||
# The option is referenced via a variable to avoid confusing sed.
|
# The option is referenced via a variable to avoid confusing sed.
|
||||||
lt_compile=`echo "$ac_compile" | $SED \
|
lt_compile=`echo "$ac_compile" | $SED \
|
||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
|
(eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
|
||||||
|
@ -650,7 +650,7 @@ AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
|
||||||
LDFLAGS="$LDFLAGS $3"
|
LDFLAGS="$LDFLAGS $3"
|
||||||
printf "$lt_simple_link_test_code" > conftest.$ac_ext
|
printf "$lt_simple_link_test_code" > conftest.$ac_ext
|
||||||
if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
|
if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
|
||||||
# The linker can only warn and ignore the option if not recognized
|
# The compiler can only warn and ignore the option if not recognized
|
||||||
# So say no if there are warnings
|
# So say no if there are warnings
|
||||||
if test -s conftest.err; then
|
if test -s conftest.err; then
|
||||||
# Append any errors to the config.log.
|
# Append any errors to the config.log.
|
||||||
|
@ -725,7 +725,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
|
||||||
elif test -x /usr/sbin/sysctl; then
|
elif test -x /usr/sbin/sysctl; then
|
||||||
lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
|
lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
|
||||||
else
|
else
|
||||||
lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
|
lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
|
||||||
fi
|
fi
|
||||||
# And add a safety zone
|
# And add a safety zone
|
||||||
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
|
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
|
||||||
|
@ -854,7 +854,7 @@ int main ()
|
||||||
}]
|
}]
|
||||||
EOF
|
EOF
|
||||||
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
|
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
|
||||||
(./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
|
(./conftest; exit; ) 2>/dev/null
|
||||||
lt_status=$?
|
lt_status=$?
|
||||||
case x$lt_status in
|
case x$lt_status in
|
||||||
x$lt_dlno_uscore) $1 ;;
|
x$lt_dlno_uscore) $1 ;;
|
||||||
|
@ -1003,7 +1003,7 @@ AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
|
||||||
# Note that $ac_compile itself does not contain backslashes and begins
|
# Note that $ac_compile itself does not contain backslashes and begins
|
||||||
# with a dollar sign (not a hyphen), so the echo should work correctly.
|
# with a dollar sign (not a hyphen), so the echo should work correctly.
|
||||||
lt_compile=`echo "$ac_compile" | $SED \
|
lt_compile=`echo "$ac_compile" | $SED \
|
||||||
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
|
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
|
||||||
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
|
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
|
||||||
-e 's:$: $lt_compiler_flag:'`
|
-e 's:$: $lt_compiler_flag:'`
|
||||||
(eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
|
(eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
|
||||||
|
@ -1021,7 +1021,7 @@ AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
|
||||||
_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
|
_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
chmod u+w . 2>&AS_MESSAGE_LOG_FD
|
chmod u+w .
|
||||||
$rm conftest*
|
$rm conftest*
|
||||||
# SGI C++ compiler will create directory out/ii_files/ for
|
# SGI C++ compiler will create directory out/ii_files/ for
|
||||||
# template instantiation
|
# template instantiation
|
||||||
|
@ -1281,8 +1281,7 @@ cygwin* | mingw* | pw32*)
|
||||||
dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
|
dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
|
||||||
dldir=$destdir/`dirname \$dlpath`~
|
dldir=$destdir/`dirname \$dlpath`~
|
||||||
test -d \$dldir || mkdir -p \$dldir~
|
test -d \$dldir || mkdir -p \$dldir~
|
||||||
$install_prog $dir/$dlname \$dldir/$dlname~
|
$install_prog $dir/$dlname \$dldir/$dlname'
|
||||||
chmod a+x \$dldir/$dlname'
|
|
||||||
postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
|
postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
|
||||||
dlpath=$dir/\$dldll~
|
dlpath=$dir/\$dldll~
|
||||||
$rm \$dlpath'
|
$rm \$dlpath'
|
||||||
|
@ -1335,7 +1334,7 @@ darwin* | rhapsody*)
|
||||||
soname_spec='${libname}${release}${major}$shared_ext'
|
soname_spec='${libname}${release}${major}$shared_ext'
|
||||||
shlibpath_overrides_runpath=yes
|
shlibpath_overrides_runpath=yes
|
||||||
shlibpath_var=DYLD_LIBRARY_PATH
|
shlibpath_var=DYLD_LIBRARY_PATH
|
||||||
shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
|
shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)'
|
||||||
# Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
|
# Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
|
||||||
if test "$GCC" = yes; then
|
if test "$GCC" = yes; then
|
||||||
sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
|
sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
|
||||||
|
@ -1373,14 +1372,7 @@ kfreebsd*-gnu)
|
||||||
freebsd* | dragonfly*)
|
freebsd* | dragonfly*)
|
||||||
# DragonFly does not have aout. When/if they implement a new
|
# DragonFly does not have aout. When/if they implement a new
|
||||||
# versioning mechanism, adjust this.
|
# versioning mechanism, adjust this.
|
||||||
if test -x /usr/bin/objformat; then
|
objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
|
||||||
objformat=`/usr/bin/objformat`
|
|
||||||
else
|
|
||||||
case $host_os in
|
|
||||||
freebsd[[123]]*) objformat=aout ;;
|
|
||||||
*) objformat=elf ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
version_type=freebsd-$objformat
|
version_type=freebsd-$objformat
|
||||||
case $version_type in
|
case $version_type in
|
||||||
freebsd-elf*)
|
freebsd-elf*)
|
||||||
|
@ -1425,7 +1417,7 @@ hpux9* | hpux10* | hpux11*)
|
||||||
version_type=sunos
|
version_type=sunos
|
||||||
need_lib_prefix=no
|
need_lib_prefix=no
|
||||||
need_version=no
|
need_version=no
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
ia64*)
|
ia64*)
|
||||||
shrext_cmds='.so'
|
shrext_cmds='.so'
|
||||||
hardcode_into_libs=yes
|
hardcode_into_libs=yes
|
||||||
|
@ -1821,7 +1813,7 @@ AC_DEFUN([AC_LIBTOOL_DLOPEN],
|
||||||
|
|
||||||
# AC_LIBTOOL_WIN32_DLL
|
# AC_LIBTOOL_WIN32_DLL
|
||||||
# --------------------
|
# --------------------
|
||||||
# declare package support for building win32 DLLs
|
# declare package support for building win32 dll's
|
||||||
AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
||||||
[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
|
[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
|
||||||
])# AC_LIBTOOL_WIN32_DLL
|
])# AC_LIBTOOL_WIN32_DLL
|
||||||
|
@ -1995,7 +1987,7 @@ dnl not every word. This closes a longstanding sh security hole.
|
||||||
if test -n "$file_magic_test_file"; then
|
if test -n "$file_magic_test_file"; then
|
||||||
case $deplibs_check_method in
|
case $deplibs_check_method in
|
||||||
"file_magic "*)
|
"file_magic "*)
|
||||||
file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
|
file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
|
||||||
MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
|
MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
|
||||||
if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
|
if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
|
||||||
$EGREP "$file_magic_regex" > /dev/null; then
|
$EGREP "$file_magic_regex" > /dev/null; then
|
||||||
|
@ -2105,7 +2097,7 @@ AC_CACHE_VAL(lt_cv_path_LD,
|
||||||
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
|
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
|
||||||
lt_cv_path_LD="$ac_dir/$ac_prog"
|
lt_cv_path_LD="$ac_dir/$ac_prog"
|
||||||
# Check to see if the program is GNU ld. I'd rather use --version,
|
# Check to see if the program is GNU ld. I'd rather use --version,
|
||||||
# but apparently some variants of GNU ld only accept -v.
|
# but apparently some GNU ld's only accept -v.
|
||||||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
# Break only if it was the GNU/non-GNU ld that we prefer.
|
||||||
case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
|
case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
|
||||||
*GNU* | *'with BFD'*)
|
*GNU* | *'with BFD'*)
|
||||||
|
@ -2137,7 +2129,7 @@ AC_PROG_LD_GNU
|
||||||
AC_DEFUN([AC_PROG_LD_GNU],
|
AC_DEFUN([AC_PROG_LD_GNU],
|
||||||
[AC_REQUIRE([AC_PROG_EGREP])dnl
|
[AC_REQUIRE([AC_PROG_EGREP])dnl
|
||||||
AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
|
AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
|
||||||
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
|
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
|
||||||
case `$LD -v 2>&1 </dev/null` in
|
case `$LD -v 2>&1 </dev/null` in
|
||||||
*GNU* | *'with BFD'*)
|
*GNU* | *'with BFD'*)
|
||||||
lt_cv_prog_gnu_ld=yes
|
lt_cv_prog_gnu_ld=yes
|
||||||
|
@ -2251,7 +2243,7 @@ gnu*)
|
||||||
|
|
||||||
hpux10.20* | hpux11*)
|
hpux10.20* | hpux11*)
|
||||||
lt_cv_file_magic_cmd=/usr/bin/file
|
lt_cv_file_magic_cmd=/usr/bin/file
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
ia64*)
|
ia64*)
|
||||||
lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
|
lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
|
||||||
lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
|
lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
|
||||||
|
@ -2425,13 +2417,13 @@ esac
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# sets LIBLTDL to the link flags for the libltdl convenience library and
|
# sets LIBLTDL to the link flags for the libltdl convenience library and
|
||||||
# LTDLINCL to the include flags for the libltdl header and adds
|
# LTDLINCL to the include flags for the libltdl header and adds
|
||||||
# --enable-ltdl-convenience to the configure arguments. Note that
|
# --enable-ltdl-convenience to the configure arguments. Note that LIBLTDL
|
||||||
# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
|
# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If
|
||||||
# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
|
# DIRECTORY is not provided, it is assumed to be `libltdl'. LIBLTDL will
|
||||||
# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
|
# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with
|
||||||
# (note the single quotes!). If your package is not flat and you're not
|
# '${top_srcdir}/' (note the single quotes!). If your package is not
|
||||||
# using automake, define top_builddir and top_srcdir appropriately in
|
# flat and you're not using automake, define top_builddir and
|
||||||
# the Makefiles.
|
# top_srcdir appropriately in the Makefiles.
|
||||||
AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
|
AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
|
||||||
[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||||
case $enable_ltdl_convenience in
|
case $enable_ltdl_convenience in
|
||||||
|
@ -2450,13 +2442,13 @@ AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
# sets LIBLTDL to the link flags for the libltdl installable library and
|
# sets LIBLTDL to the link flags for the libltdl installable library and
|
||||||
# LTDLINCL to the include flags for the libltdl header and adds
|
# LTDLINCL to the include flags for the libltdl header and adds
|
||||||
# --enable-ltdl-install to the configure arguments. Note that
|
# --enable-ltdl-install to the configure arguments. Note that LIBLTDL
|
||||||
# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
|
# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If
|
||||||
# and an installed libltdl is not found, it is assumed to be `libltdl'.
|
# DIRECTORY is not provided and an installed libltdl is not found, it is
|
||||||
# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
|
# assumed to be `libltdl'. LIBLTDL will be prefixed with '${top_builddir}/'
|
||||||
# '${top_srcdir}/' (note the single quotes!). If your package is not
|
# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single
|
||||||
# flat and you're not using automake, define top_builddir and top_srcdir
|
# quotes!). If your package is not flat and you're not using automake,
|
||||||
# appropriately in the Makefiles.
|
# define top_builddir and top_srcdir appropriately in the Makefiles.
|
||||||
# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
|
# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
|
||||||
AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
|
AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
|
||||||
[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
|
||||||
|
@ -2635,7 +2627,7 @@ test "$can_build_shared" = "no" && enable_shared=no
|
||||||
|
|
||||||
# On AIX, shared libraries and static libraries use the same namespace, and
|
# On AIX, shared libraries and static libraries use the same namespace, and
|
||||||
# are all built from PIC.
|
# are all built from PIC.
|
||||||
case $host_os in
|
case "$host_os" in
|
||||||
aix3*)
|
aix3*)
|
||||||
test "$enable_shared" = yes && enable_static=no
|
test "$enable_shared" = yes && enable_static=no
|
||||||
if test -n "$RANLIB"; then
|
if test -n "$RANLIB"; then
|
||||||
|
@ -2702,7 +2694,7 @@ _LT_AC_TAGVAR(postdeps, $1)=
|
||||||
_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
|
_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
|
||||||
|
|
||||||
# Source file extension for C++ test sources.
|
# Source file extension for C++ test sources.
|
||||||
ac_ext=cpp
|
ac_ext=cc
|
||||||
|
|
||||||
# Object file extension for compiled C++ test sources.
|
# Object file extension for compiled C++ test sources.
|
||||||
objext=o
|
objext=o
|
||||||
|
@ -2918,7 +2910,7 @@ case $host_os in
|
||||||
# Exported symbols can be pulled into shared objects from archives
|
# Exported symbols can be pulled into shared objects from archives
|
||||||
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
|
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
|
||||||
_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
|
_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
|
||||||
# This is similar to how AIX traditionally builds its shared libraries.
|
# This is similar to how AIX traditionally builds it's shared libraries.
|
||||||
_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
|
_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -2957,7 +2949,7 @@ case $host_os in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
darwin* | rhapsody*)
|
darwin* | rhapsody*)
|
||||||
case $host_os in
|
case "$host_os" in
|
||||||
rhapsody* | darwin1.[[012]])
|
rhapsody* | darwin1.[[012]])
|
||||||
_LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
|
_LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
|
||||||
;;
|
;;
|
||||||
|
@ -2995,7 +2987,7 @@ case $host_os in
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
|
||||||
fi
|
fi
|
||||||
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
||||||
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
|
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
|
||||||
if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
|
if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
|
||||||
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
||||||
else
|
else
|
||||||
|
@ -3008,7 +3000,7 @@ case $host_os in
|
||||||
output_verbose_link_cmd='echo'
|
output_verbose_link_cmd='echo'
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
|
||||||
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
||||||
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
|
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
|
||||||
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
||||||
_LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
_LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
||||||
;;
|
;;
|
||||||
|
@ -3088,7 +3080,7 @@ case $host_os in
|
||||||
;;
|
;;
|
||||||
hpux10*|hpux11*)
|
hpux10*|hpux11*)
|
||||||
if test $with_gnu_ld = no; then
|
if test $with_gnu_ld = no; then
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*)
|
hppa*64*)
|
||||||
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
|
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
|
||||||
_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
|
_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
|
||||||
|
@ -3104,7 +3096,7 @@ case $host_os in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*)
|
hppa*64*)
|
||||||
_LT_AC_TAGVAR(hardcode_direct, $1)=no
|
_LT_AC_TAGVAR(hardcode_direct, $1)=no
|
||||||
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
|
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
|
||||||
|
@ -3130,7 +3122,7 @@ case $host_os in
|
||||||
_LT_AC_TAGVAR(ld_shlibs, $1)=no
|
_LT_AC_TAGVAR(ld_shlibs, $1)=no
|
||||||
;;
|
;;
|
||||||
aCC*)
|
aCC*)
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*|ia64*)
|
hppa*64*|ia64*)
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
|
||||||
;;
|
;;
|
||||||
|
@ -3151,7 +3143,7 @@ case $host_os in
|
||||||
*)
|
*)
|
||||||
if test "$GXX" = yes; then
|
if test "$GXX" = yes; then
|
||||||
if test $with_gnu_ld = no; then
|
if test $with_gnu_ld = no; then
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
ia64*|hppa*64*)
|
ia64*|hppa*64*)
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
|
||||||
;;
|
;;
|
||||||
|
@ -3252,7 +3244,7 @@ case $host_os in
|
||||||
|
|
||||||
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
|
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
|
||||||
_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
|
_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
|
||||||
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
|
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
|
||||||
;;
|
;;
|
||||||
cxx*)
|
cxx*)
|
||||||
# Compaq C++
|
# Compaq C++
|
||||||
|
@ -3484,11 +3476,10 @@ case $host_os in
|
||||||
case $cc_basename in
|
case $cc_basename in
|
||||||
CC*)
|
CC*)
|
||||||
# Sun C++ 4.2, 5.x and Centerline C++
|
# Sun C++ 4.2, 5.x and Centerline C++
|
||||||
_LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
|
|
||||||
_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
|
_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
|
||||||
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
|
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
|
||||||
$CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
|
$CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
|
||||||
|
|
||||||
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
|
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
|
||||||
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
|
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
|
||||||
|
@ -3508,7 +3499,15 @@ case $host_os in
|
||||||
esac
|
esac
|
||||||
_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
|
_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
|
||||||
|
|
||||||
output_verbose_link_cmd='echo'
|
# Commands to make compiler produce verbose output that lists
|
||||||
|
# what "hidden" libraries, object files and flags are used when
|
||||||
|
# linking a shared library.
|
||||||
|
#
|
||||||
|
# There doesn't appear to be a way to prevent this compiler from
|
||||||
|
# explicitly linking system object files so we need to strip them
|
||||||
|
# from the output so that they don't get included in the library
|
||||||
|
# dependencies.
|
||||||
|
output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
|
||||||
|
|
||||||
# Archives containing C++ object files must be created using
|
# Archives containing C++ object files must be created using
|
||||||
# "CC -xar", where "CC" is the Sun C++ compiler. This is
|
# "CC -xar", where "CC" is the Sun C++ compiler. This is
|
||||||
|
@ -3665,7 +3664,7 @@ if AC_TRY_EVAL(ac_compile); then
|
||||||
# The `*' in the case matches for architectures that use `case' in
|
# The `*' in the case matches for architectures that use `case' in
|
||||||
# $output_verbose_cmd can trigger glob expansion during the loop
|
# $output_verbose_cmd can trigger glob expansion during the loop
|
||||||
# eval without this substitution.
|
# eval without this substitution.
|
||||||
output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
|
output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`"
|
||||||
|
|
||||||
for p in `eval $output_verbose_link_cmd`; do
|
for p in `eval $output_verbose_link_cmd`; do
|
||||||
case $p in
|
case $p in
|
||||||
|
@ -3741,21 +3740,6 @@ fi
|
||||||
|
|
||||||
$rm -f confest.$objext
|
$rm -f confest.$objext
|
||||||
|
|
||||||
# PORTME: override above test on systems where it is broken
|
|
||||||
ifelse([$1],[CXX],
|
|
||||||
[case $host_os in
|
|
||||||
solaris*)
|
|
||||||
case $cc_basename in
|
|
||||||
CC*)
|
|
||||||
# Adding this requires a known-good setup of shared libraries for
|
|
||||||
# Sun compiler versions before 5.6, else PIC objects from an old
|
|
||||||
# archive will be linked into the output, leading to subtle bugs.
|
|
||||||
_LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
esac
|
|
||||||
])
|
|
||||||
|
|
||||||
case " $_LT_AC_TAGVAR(postdeps, $1) " in
|
case " $_LT_AC_TAGVAR(postdeps, $1) " in
|
||||||
*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
|
*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
|
||||||
esac
|
esac
|
||||||
|
@ -3825,7 +3809,7 @@ test "$can_build_shared" = "no" && enable_shared=no
|
||||||
|
|
||||||
# On AIX, shared libraries and static libraries use the same namespace, and
|
# On AIX, shared libraries and static libraries use the same namespace, and
|
||||||
# are all built from PIC.
|
# are all built from PIC.
|
||||||
case $host_os in
|
case "$host_os" in
|
||||||
aix3*)
|
aix3*)
|
||||||
test "$enable_shared" = yes && enable_static=no
|
test "$enable_shared" = yes && enable_static=no
|
||||||
if test -n "$RANLIB"; then
|
if test -n "$RANLIB"; then
|
||||||
|
@ -4724,7 +4708,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
|
||||||
hpux*)
|
hpux*)
|
||||||
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
|
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
|
||||||
# not for PA HP-UX.
|
# not for PA HP-UX.
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*|ia64*)
|
hppa*64*|ia64*)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -4793,7 +4777,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
|
||||||
aCC*)
|
aCC*)
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
|
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*|ia64*)
|
hppa*64*|ia64*)
|
||||||
# +Z the default
|
# +Z the default
|
||||||
;;
|
;;
|
||||||
|
@ -4834,7 +4818,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
|
||||||
# Portland Group C++ compiler.
|
# Portland Group C++ compiler.
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
|
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
|
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
|
||||||
;;
|
;;
|
||||||
cxx*)
|
cxx*)
|
||||||
# Compaq C++
|
# Compaq C++
|
||||||
|
@ -4998,7 +4982,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
|
||||||
hpux*)
|
hpux*)
|
||||||
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
|
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
|
||||||
# not for PA HP-UX.
|
# not for PA HP-UX.
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*|ia64*)
|
hppa*64*|ia64*)
|
||||||
# +Z the default
|
# +Z the default
|
||||||
;;
|
;;
|
||||||
|
@ -5045,7 +5029,7 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
||||||
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
|
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
|
||||||
# not for PA HP-UX.
|
# not for PA HP-UX.
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*|ia64*)
|
hppa*64*|ia64*)
|
||||||
# +Z the default
|
# +Z the default
|
||||||
;;
|
;;
|
||||||
|
@ -5075,12 +5059,12 @@ AC_MSG_CHECKING([for $compiler option to produce PIC])
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
|
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
|
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
|
||||||
;;
|
;;
|
||||||
pgcc* | pgf77* | pgf90* | pgf95*)
|
pgcc* | pgf77* | pgf90*)
|
||||||
# Portland Group compilers (*not* the Pentium gcc compiler,
|
# Portland Group compilers (*not* the Pentium gcc compiler,
|
||||||
# which looks to be a dead project)
|
# which looks to be a dead project)
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
|
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
|
_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
|
||||||
;;
|
;;
|
||||||
ccc*)
|
ccc*)
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
|
||||||
|
@ -5163,7 +5147,7 @@ if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
|
||||||
[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
|
[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
|
_LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
|
||||||
fi
|
fi
|
||||||
case $host_os in
|
case "$host_os" in
|
||||||
# For platforms which do not support PIC, -DPIC is meaningless:
|
# For platforms which do not support PIC, -DPIC is meaningless:
|
||||||
*djgpp*)
|
*djgpp*)
|
||||||
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
|
_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
|
||||||
|
@ -5354,11 +5338,11 @@ EOF
|
||||||
tmp_addflag=
|
tmp_addflag=
|
||||||
case $cc_basename,$host_cpu in
|
case $cc_basename,$host_cpu in
|
||||||
pgcc*) # Portland Group C compiler
|
pgcc*) # Portland Group C compiler
|
||||||
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
|
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
|
||||||
tmp_addflag=' $pic_flag'
|
tmp_addflag=' $pic_flag'
|
||||||
;;
|
;;
|
||||||
pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
|
pgf77* | pgf90* ) # Portland Group f77 and f90 compilers
|
||||||
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
|
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive,`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
|
||||||
tmp_addflag=' $pic_flag -Mnomain' ;;
|
tmp_addflag=' $pic_flag -Mnomain' ;;
|
||||||
ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
|
ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
|
||||||
tmp_addflag=' -i_dynamic' ;;
|
tmp_addflag=' -i_dynamic' ;;
|
||||||
|
@ -5564,7 +5548,7 @@ EOF
|
||||||
# Exported symbols can be pulled into shared objects from archives
|
# Exported symbols can be pulled into shared objects from archives
|
||||||
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
|
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
|
||||||
_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
|
_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
|
||||||
# This is similar to how AIX traditionally builds its shared libraries.
|
# This is similar to how AIX traditionally builds it's shared libraries.
|
||||||
_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
|
_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -5604,7 +5588,7 @@ EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
darwin* | rhapsody*)
|
darwin* | rhapsody*)
|
||||||
case $host_os in
|
case "$host_os" in
|
||||||
rhapsody* | darwin1.[[012]])
|
rhapsody* | darwin1.[[012]])
|
||||||
_LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
|
_LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
|
||||||
;;
|
;;
|
||||||
|
@ -5633,7 +5617,7 @@ EOF
|
||||||
output_verbose_link_cmd='echo'
|
output_verbose_link_cmd='echo'
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
|
||||||
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
||||||
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
|
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
|
||||||
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
||||||
_LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
_LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
||||||
else
|
else
|
||||||
|
@ -5642,7 +5626,7 @@ EOF
|
||||||
output_verbose_link_cmd='echo'
|
output_verbose_link_cmd='echo'
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
|
||||||
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
_LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
|
||||||
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
|
# Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's
|
||||||
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
||||||
_LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
_LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
|
||||||
;;
|
;;
|
||||||
|
@ -5708,7 +5692,7 @@ EOF
|
||||||
|
|
||||||
hpux10* | hpux11*)
|
hpux10* | hpux11*)
|
||||||
if test "$GCC" = yes -a "$with_gnu_ld" = no; then
|
if test "$GCC" = yes -a "$with_gnu_ld" = no; then
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*|ia64*)
|
hppa*64*|ia64*)
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
|
||||||
;;
|
;;
|
||||||
|
@ -5717,7 +5701,7 @@ EOF
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*|ia64*)
|
hppa*64*|ia64*)
|
||||||
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
|
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
|
||||||
;;
|
;;
|
||||||
|
@ -5727,7 +5711,7 @@ EOF
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
if test "$with_gnu_ld" = no; then
|
if test "$with_gnu_ld" = no; then
|
||||||
case $host_cpu in
|
case "$host_cpu" in
|
||||||
hppa*64*)
|
hppa*64*)
|
||||||
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
|
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
|
||||||
_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
|
_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
|
||||||
|
|
|
@ -34,7 +34,7 @@ AC_PROG_GCC_TRADITIONAL
|
||||||
AC_FUNC_MALLOC
|
AC_FUNC_MALLOC
|
||||||
AC_TYPE_SIGNAL
|
AC_TYPE_SIGNAL
|
||||||
AC_FUNC_STRFTIME
|
AC_FUNC_STRFTIME
|
||||||
AC_CHECK_FUNCS([gethostname vasprintf])
|
AC_CHECK_FUNCS([gethostname vasprintf mmap])
|
||||||
|
|
||||||
AC_C_BIGENDIAN(AC_DEFINE([__BYTE_ORDER],__BIG_ENDIAN,[Big Endian]),AC_DEFINE([__BYTE_ORDER],__LITTLE_ENDIAN,[Little Endian]))
|
AC_C_BIGENDIAN(AC_DEFINE([__BYTE_ORDER],__BIG_ENDIAN,[Big Endian]),AC_DEFINE([__BYTE_ORDER],__LITTLE_ENDIAN,[Little Endian]))
|
||||||
AC_DEFINE([__LITTLE_ENDIAN],1234,[for the places where it is not defined])
|
AC_DEFINE([__LITTLE_ENDIAN],1234,[for the places where it is not defined])
|
||||||
|
|
|
@ -75,6 +75,7 @@ BEGIN_EXTERN_C
|
||||||
#include <switch_stun.h>
|
#include <switch_stun.h>
|
||||||
#include <switch_stun.h>
|
#include <switch_stun.h>
|
||||||
#include <switch_log.h>
|
#include <switch_log.h>
|
||||||
|
#include <switch_xml.h>
|
||||||
|
|
||||||
END_EXTERN_C
|
END_EXTERN_C
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mmap' function. */
|
||||||
|
#undef HAVE_MMAP
|
||||||
|
|
||||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||||
#undef HAVE_NDIR_H
|
#undef HAVE_NDIR_H
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
/* switch_xml.h
|
||||||
|
*
|
||||||
|
* Copyright 2004, 2005 Aaron Voisine <aaron@voisine.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SWITCH_XML_H
|
||||||
|
#define _SWITCH_XML_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
BEGIN_EXTERN_C
|
||||||
|
|
||||||
|
#define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
|
||||||
|
#define SWITCH_XML_NAMEM 0x80 // name is malloced
|
||||||
|
#define SWITCH_XML_TXTM 0x40 // txt is malloced
|
||||||
|
#define SWITCH_XML_DUP 0x20 // attribute name and value are strduped
|
||||||
|
|
||||||
|
typedef struct switch_xml *switch_xml_t;
|
||||||
|
struct switch_xml {
|
||||||
|
char *name; // tag name
|
||||||
|
char **attr; // tag attributes { name, value, name, value, ... NULL }
|
||||||
|
char *txt; // tag character content, empty string if none
|
||||||
|
size_t off; // tag offset from start of parent tag character content
|
||||||
|
switch_xml_t next; // next tag with same name in this section at this depth
|
||||||
|
switch_xml_t sibling; // next tag with different name in same section and depth
|
||||||
|
switch_xml_t ordered; // next tag, same section and depth, in original order
|
||||||
|
switch_xml_t child; // head of sub tag list, NULL if none
|
||||||
|
switch_xml_t parent; // parent tag, NULL if current tag is root tag
|
||||||
|
short flags; // additional information
|
||||||
|
};
|
||||||
|
|
||||||
|
// Given a string of xml data and its length, parses it and creates an switch_xml
|
||||||
|
// structure. For efficiency, modifies the data by adding null terminators
|
||||||
|
// and decoding ampersand sequences. If you don't want this, copy the data and
|
||||||
|
// pass in the copy. Returns NULL on failure.
|
||||||
|
switch_xml_t switch_xml_parse_str(char *s, size_t len);
|
||||||
|
|
||||||
|
// A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
|
||||||
|
// attempts to mem map the file. Failing that, reads the file into memory.
|
||||||
|
// Returns NULL on failure.
|
||||||
|
switch_xml_t switch_xml_parse_fd(int fd);
|
||||||
|
|
||||||
|
// a wrapper for switch_xml_parse_fd() that accepts a file name
|
||||||
|
switch_xml_t switch_xml_parse_file(const char *file);
|
||||||
|
|
||||||
|
// Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
|
||||||
|
// stream into memory and then parses it. For xml files, use switch_xml_parse_file()
|
||||||
|
// or switch_xml_parse_fd()
|
||||||
|
switch_xml_t switch_xml_parse_fp(FILE *fp);
|
||||||
|
|
||||||
|
// returns the first child tag (one level deeper) with the given name or NULL
|
||||||
|
// if not found
|
||||||
|
switch_xml_t switch_xml_child(switch_xml_t xml, const char *name);
|
||||||
|
|
||||||
|
// returns the next tag of the same name in the same section and depth or NULL
|
||||||
|
// if not found
|
||||||
|
#define switch_xml_next(xml) ((xml) ? xml->next : NULL)
|
||||||
|
|
||||||
|
// Returns the Nth tag with the same name in the same section at the same depth
|
||||||
|
// or NULL if not found. An index of 0 returns the tag given.
|
||||||
|
switch_xml_t switch_xml_idx(switch_xml_t xml, int idx);
|
||||||
|
|
||||||
|
// returns the name of the given tag
|
||||||
|
#define switch_xml_name(xml) ((xml) ? xml->name : NULL)
|
||||||
|
|
||||||
|
// returns the given tag's character content or empty string if none
|
||||||
|
#define switch_xml_txt(xml) ((xml) ? xml->txt : "")
|
||||||
|
|
||||||
|
// returns the value of the requested tag attribute, or NULL if not found
|
||||||
|
const char *switch_xml_attr(switch_xml_t xml, const char *attr);
|
||||||
|
|
||||||
|
// Traverses the switch_xml sturcture to retrieve a specific subtag. Takes a
|
||||||
|
// variable length list of tag names and indexes. The argument list must be
|
||||||
|
// terminated by either an index of -1 or an empty string tag name. Example:
|
||||||
|
// title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
|
||||||
|
// This retrieves the title of the 3rd book on the 1st shelf of library.
|
||||||
|
// Returns NULL if not found.
|
||||||
|
switch_xml_t switch_xml_get(switch_xml_t xml, ...);
|
||||||
|
|
||||||
|
// Converts an switch_xml structure back to xml. Returns a string of xml data that
|
||||||
|
// must be freed.
|
||||||
|
char *switch_xml_toxml(switch_xml_t xml);
|
||||||
|
|
||||||
|
// returns a NULL terminated array of processing instructions for the given
|
||||||
|
// target
|
||||||
|
const char **switch_xml_pi(switch_xml_t xml, const char *target);
|
||||||
|
|
||||||
|
// frees the memory allocated for an switch_xml structure
|
||||||
|
void switch_xml_free(switch_xml_t xml);
|
||||||
|
|
||||||
|
// returns parser error message or empty string if none
|
||||||
|
const char *switch_xml_error(switch_xml_t xml);
|
||||||
|
|
||||||
|
// returns a new empty switch_xml structure with the given root tag name
|
||||||
|
switch_xml_t switch_xml_new(const char *name);
|
||||||
|
|
||||||
|
// wrapper for switch_xml_new() that strdup()s name
|
||||||
|
#define switch_xml_new_d(name) switch_xml_set_flag(switch_xml_new(strdup(name)), SWITCH_XML_NAMEM)
|
||||||
|
|
||||||
|
// Adds a child tag. off is the offset of the child tag relative to the start
|
||||||
|
// of the parent tag's character content. Returns the child tag.
|
||||||
|
switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, size_t off);
|
||||||
|
|
||||||
|
// wrapper for switch_xml_add_child() that strdup()s name
|
||||||
|
#define switch_xml_add_child_d(xml, name, off) \
|
||||||
|
switch_xml_set_flag(switch_xml_add_child(xml, strdup(name), off), SWITCH_XML_NAMEM)
|
||||||
|
|
||||||
|
// sets the character content for the given tag and returns the tag
|
||||||
|
switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt);
|
||||||
|
|
||||||
|
// wrapper for switch_xml_set_txt() that strdup()s txt
|
||||||
|
#define switch_xml_set_txt_d(xml, txt) \
|
||||||
|
switch_xml_set_flag(switch_xml_set_txt(xml, strdup(txt)), SWITCH_XML_TXTM)
|
||||||
|
|
||||||
|
// Sets the given tag attribute or adds a new attribute if not found. A value
|
||||||
|
// of NULL will remove the specified attribute.
|
||||||
|
void switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value);
|
||||||
|
|
||||||
|
// Wrapper for switch_xml_set_attr() that strdup()s name/value. Value cannot be NULL
|
||||||
|
#define switch_xml_set_attr_d(xml, name, value) \
|
||||||
|
switch_xml_set_attr(switch_xml_set_flag(xml, SWITCH_XML_DUP), strdup(name), strdup(value))
|
||||||
|
|
||||||
|
// sets a flag for the given tag and returns the tag
|
||||||
|
switch_xml_t switch_xml_set_flag(switch_xml_t xml, short flag);
|
||||||
|
|
||||||
|
// removes a tag along with all its subtags
|
||||||
|
void switch_xml_remove(switch_xml_t xml);
|
||||||
|
|
||||||
|
END_EXTERN_C
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _SWITCH_XML_H
|
|
@ -57,6 +57,23 @@ static void disast_function(switch_core_session_t *session, char *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void xml_function(switch_core_session_t *session, char *data)
|
||||||
|
{
|
||||||
|
switch_xml_t f1 = switch_xml_parse_file("/root/formula1.xml"), team, driver;
|
||||||
|
const char *teamname;
|
||||||
|
|
||||||
|
for (team = switch_xml_child(f1, "team"); team; team = team->next) {
|
||||||
|
teamname = switch_xml_attr(team, "name");
|
||||||
|
for (driver = switch_xml_child(team, "driver"); driver; driver = driver->next) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||||
|
"%s, %s: %s\n", switch_xml_child(driver, "name")->txt, teamname,
|
||||||
|
switch_xml_child(driver, "points")->txt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch_xml_free(f1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dirtest_function(switch_core_session_t *session, char *data)
|
static void dirtest_function(switch_core_session_t *session, char *data)
|
||||||
{
|
{
|
||||||
char *var, *val;
|
char *var, *val;
|
||||||
|
@ -204,11 +221,18 @@ static const switch_state_handler_table_t state_handlers = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const switch_application_interface_t xml_application_interface = {
|
||||||
|
/*.interface_name */ "xml",
|
||||||
|
/*.application_function */ xml_function,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
/*.next*/ NULL
|
||||||
|
};
|
||||||
|
|
||||||
static const switch_application_interface_t disast_application_interface = {
|
static const switch_application_interface_t disast_application_interface = {
|
||||||
/*.interface_name */ "disast",
|
/*.interface_name */ "disast",
|
||||||
/*.application_function */ disast_function,
|
/*.application_function */ disast_function,
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
/*.next*/ NULL
|
/*.next*/ &xml_application_interface
|
||||||
};
|
};
|
||||||
|
|
||||||
static const switch_application_interface_t tts_application_interface = {
|
static const switch_application_interface_t tts_application_interface = {
|
||||||
|
|
|
@ -79,9 +79,9 @@ static switch_caller_extension_t *flatfile_dialplan_hunt(switch_core_session_t *
|
||||||
*data = '\0';
|
*data = '\0';
|
||||||
data++;
|
data++;
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid extension on line %d\n", cfg.lineno);
|
data = "";
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extension) {
|
if (!extension) {
|
||||||
if ((extension =
|
if ((extension =
|
||||||
switch_caller_extension_new(session, caller_profile->destination_number,
|
switch_caller_extension_new(session, caller_profile->destination_number,
|
||||||
|
|
|
@ -0,0 +1,997 @@
|
||||||
|
/* switch_xml.c
|
||||||
|
*
|
||||||
|
* Copyright 2004, 2005 Aaron Voisine <aaron@voisine.org>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <switch.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define SWITCH_XML_WS "\t\r\n " // whitespace
|
||||||
|
#define SWITCH_XML_ERRL 128 // maximum error string length
|
||||||
|
|
||||||
|
typedef struct switch_xml_root *switch_xml_root_t;
|
||||||
|
struct switch_xml_root { // additional data for the root tag
|
||||||
|
struct switch_xml xml; // is a super-struct built on top of switch_xml struct
|
||||||
|
switch_xml_t cur; // current xml tree insertion point
|
||||||
|
char *m; // original xml string
|
||||||
|
size_t len; // length of allocated memory for mmap, -1 for malloc
|
||||||
|
char *u; // UTF-8 conversion of string if original was UTF-16
|
||||||
|
char *s; // start of work area
|
||||||
|
char *e; // end of work area
|
||||||
|
char **ent; // general entities (ampersand sequences)
|
||||||
|
char ***attr; // default attributes
|
||||||
|
char ***pi; // processing instructions
|
||||||
|
short standalone; // non-zero if <?xml standalone="yes"?>
|
||||||
|
char err[SWITCH_XML_ERRL]; // error string
|
||||||
|
};
|
||||||
|
|
||||||
|
char *SWITCH_XML_NIL[] = { NULL }; // empty, null terminated array of strings
|
||||||
|
|
||||||
|
// returns the first child tag with the given name or NULL if not found
|
||||||
|
switch_xml_t switch_xml_child(switch_xml_t xml, const char *name)
|
||||||
|
{
|
||||||
|
xml = (xml) ? xml->child : NULL;
|
||||||
|
while (xml && strcmp(name, xml->name)) xml = xml->sibling;
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the Nth tag with the same name in the same subsection or NULL if not
|
||||||
|
// found
|
||||||
|
switch_xml_t switch_xml_idx(switch_xml_t xml, int idx)
|
||||||
|
{
|
||||||
|
for (; xml && idx; idx--) xml = xml->next;
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the value of the requested tag attribute or NULL if not found
|
||||||
|
const char *switch_xml_attr(switch_xml_t xml, const char *attr)
|
||||||
|
{
|
||||||
|
int i = 0, j = 1;
|
||||||
|
switch_xml_root_t root = (switch_xml_root_t)xml;
|
||||||
|
|
||||||
|
if (! xml || ! xml->attr) return NULL;
|
||||||
|
while (xml->attr[i] && strcmp(attr, xml->attr[i])) i += 2;
|
||||||
|
if (xml->attr[i]) return xml->attr[i + 1]; // found attribute
|
||||||
|
|
||||||
|
while (root->xml.parent) root = (switch_xml_root_t)root->xml.parent; // root tag
|
||||||
|
for (i = 0; root->attr[i] && strcmp(xml->name, root->attr[i][0]); i++);
|
||||||
|
if (! root->attr[i]) return NULL; // no matching default attributes
|
||||||
|
while (root->attr[i][j] && strcmp(attr, root->attr[i][j])) j += 3;
|
||||||
|
return (root->attr[i][j]) ? root->attr[i][j + 1] : NULL; // found default
|
||||||
|
}
|
||||||
|
|
||||||
|
// same as switch_xml_get but takes an already initialized va_list
|
||||||
|
static switch_xml_t switch_xml_vget(switch_xml_t xml, va_list ap)
|
||||||
|
{
|
||||||
|
char *name = va_arg(ap, char *);
|
||||||
|
int idx = -1;
|
||||||
|
|
||||||
|
if (name && *name) {
|
||||||
|
idx = va_arg(ap, int);
|
||||||
|
xml = switch_xml_child(xml, name);
|
||||||
|
}
|
||||||
|
return (idx < 0) ? xml : switch_xml_vget(switch_xml_idx(xml, idx), ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Traverses the xml tree to retrieve a specific subtag. Takes a variable
|
||||||
|
// length list of tag names and indexes. The argument list must be terminated
|
||||||
|
// by either an index of -1 or an empty string tag name. Example:
|
||||||
|
// title = switch_xml_get(library, "shelf", 0, "book", 2, "title", -1);
|
||||||
|
// This retrieves the title of the 3rd book on the 1st shelf of library.
|
||||||
|
// Returns NULL if not found.
|
||||||
|
switch_xml_t switch_xml_get(switch_xml_t xml, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
switch_xml_t r;
|
||||||
|
|
||||||
|
va_start(ap, xml);
|
||||||
|
r = switch_xml_vget(xml, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns a null terminated array of processing instructions for the given
|
||||||
|
// target
|
||||||
|
const char **switch_xml_pi(switch_xml_t xml, const char *target)
|
||||||
|
{
|
||||||
|
switch_xml_root_t root = (switch_xml_root_t)xml;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (! root) return (const char **)SWITCH_XML_NIL;
|
||||||
|
while (root->xml.parent) root = (switch_xml_root_t)root->xml.parent; // root tag
|
||||||
|
while (root->pi[i] && strcmp(target, root->pi[i][0])) i++; // find target
|
||||||
|
return (const char **)((root->pi[i]) ? root->pi[i] + 1 : SWITCH_XML_NIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set an error string and return root
|
||||||
|
static switch_xml_t switch_xml_err(switch_xml_root_t root, char *s, const char *err, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int line = 1;
|
||||||
|
char *t, fmt[SWITCH_XML_ERRL];
|
||||||
|
|
||||||
|
for (t = root->s; t < s; t++) if (*t == '\n') line++;
|
||||||
|
snprintf(fmt, SWITCH_XML_ERRL, "[error near line %d]: %s", line, err);
|
||||||
|
|
||||||
|
va_start(ap, err);
|
||||||
|
vsnprintf(root->err, SWITCH_XML_ERRL, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return &root->xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively decodes entity and character references and normalizes new lines
|
||||||
|
// ent is a null terminated array of alternating entity names and values. set t
|
||||||
|
// to '&' for general entity decoding, '%' for parameter entity decoding, 'c'
|
||||||
|
// for cdata sections, ' ' for attribute normalization, or '*' for non-cdata
|
||||||
|
// attribute normalization. Returns s, or if the decoded string is longer than
|
||||||
|
// s, returns a malloced string that must be freed.
|
||||||
|
static char *switch_xml_decode(char *s, char **ent, char t)
|
||||||
|
{
|
||||||
|
char *e, *r = s, *m = s;
|
||||||
|
long b, c, d, l;
|
||||||
|
|
||||||
|
for (; *s; s++) { // normalize line endings
|
||||||
|
while (*s == '\r') {
|
||||||
|
*(s++) = '\n';
|
||||||
|
if (*s == '\n') memmove(s, (s + 1), strlen(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (s = r; ; ) {
|
||||||
|
while (*s && *s != '&' && (*s != '%' || t != '%') && !isspace(*s)) s++;
|
||||||
|
|
||||||
|
if (! *s) break;
|
||||||
|
else if (t != 'c' && ! strncmp(s, "&#", 2)) { // character reference
|
||||||
|
if (s[2] == 'x') c = strtol(s + 3, &e, 16); // base 16
|
||||||
|
else c = strtol(s + 2, &e, 10); // base 10
|
||||||
|
if (! c || *e != ';') { s++; continue; } // not a character ref
|
||||||
|
|
||||||
|
if (c < 0x80) *(s++) = c; // US-ASCII subset
|
||||||
|
else { // multi-byte UTF-8 sequence
|
||||||
|
for (b = 0, d = c; d; d /= 2) b++; // number of bits in c
|
||||||
|
b = (b - 2) / 5; // number of bytes in payload
|
||||||
|
*(s++) = (0xFF << (7 - b)) | (c >> (6 * b)); // head
|
||||||
|
while (b) *(s++) = 0x80 | ((c >> (6 * --b)) & 0x3F); // payload
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove(s, strchr(s, ';') + 1, strlen(strchr(s, ';')));
|
||||||
|
}
|
||||||
|
else if ((*s == '&' && (t == '&' || t == ' ' || t == '*')) ||
|
||||||
|
(*s == '%' && t == '%')) { // entity reference
|
||||||
|
for (b = 0; ent[b] && strncmp(s + 1, ent[b], strlen(ent[b]));
|
||||||
|
b += 2); // find entity in entity list
|
||||||
|
|
||||||
|
if (ent[b++]) { // found a match
|
||||||
|
if ((c = strlen(ent[b])) - 1 > (e = strchr(s, ';')) - s) {
|
||||||
|
l = (d = (s - r)) + c + strlen(e); // new length
|
||||||
|
r = (r == m) ? strcpy(malloc(l), r) : realloc(r, l);
|
||||||
|
e = strchr((s = r + d), ';'); // fix up pointers
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove(s + c, e + 1, strlen(e)); // shift rest of string
|
||||||
|
strncpy(s, ent[b], c); // copy in replacement text
|
||||||
|
}
|
||||||
|
else s++; // not a known entity
|
||||||
|
}
|
||||||
|
else if ((t == ' ' || t == '*') && isspace(*s)) *(s++) = ' ';
|
||||||
|
else s++; // no decoding needed
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t == '*') { // normalize spaces for non-cdata attributes
|
||||||
|
for (s = r; *s; s++) {
|
||||||
|
if ((l = strspn(s, " "))) memmove(s, s + l, strlen(s + l) + 1);
|
||||||
|
while (*s && *s != ' ') s++;
|
||||||
|
}
|
||||||
|
if (--s >= r && *s == ' ') *s = '\0'; // trim any trailing space
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
// called when parser finds start of new tag
|
||||||
|
static void switch_xml_open_tag(switch_xml_root_t root, char *name, char **attr)
|
||||||
|
{
|
||||||
|
switch_xml_t xml = root->cur;
|
||||||
|
|
||||||
|
if (xml->name) xml = switch_xml_add_child(xml, name, strlen(xml->txt));
|
||||||
|
else xml->name = name; // first open tag
|
||||||
|
|
||||||
|
xml->attr = attr;
|
||||||
|
root->cur = xml; // update tag insertion point
|
||||||
|
}
|
||||||
|
|
||||||
|
// called when parser finds character content between open and closing tag
|
||||||
|
static void switch_xml_char_content(switch_xml_root_t root, char *s, size_t len, char t)
|
||||||
|
{
|
||||||
|
switch_xml_t xml = root->cur;
|
||||||
|
char *m = s;
|
||||||
|
size_t l;
|
||||||
|
|
||||||
|
if (! xml || ! xml->name || ! len) return; // sanity check
|
||||||
|
|
||||||
|
s[len] = '\0'; // null terminate text (calling functions anticipate this)
|
||||||
|
len = strlen(s = switch_xml_decode(s, root->ent, t)) + 1;
|
||||||
|
|
||||||
|
if (! *(xml->txt)) xml->txt = s; // initial character content
|
||||||
|
else { // allocate our own memory and make a copy
|
||||||
|
xml->txt = (xml->flags & SWITCH_XML_TXTM) // allocate some space
|
||||||
|
? realloc(xml->txt, (l = strlen(xml->txt)) + len)
|
||||||
|
: strcpy(malloc((l = strlen(xml->txt)) + len), xml->txt);
|
||||||
|
strcpy(xml->txt + l, s); // add new char content
|
||||||
|
if (s != m) free(s); // free s if it was malloced by switch_xml_decode()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xml->txt != m) switch_xml_set_flag(xml, SWITCH_XML_TXTM);
|
||||||
|
}
|
||||||
|
|
||||||
|
// called when parser finds closing tag
|
||||||
|
static switch_xml_t switch_xml_close_tag(switch_xml_root_t root, char *name, char *s)
|
||||||
|
{
|
||||||
|
if (! root->cur || ! root->cur->name || strcmp(name, root->cur->name))
|
||||||
|
return switch_xml_err(root, s, "unexpected closing tag </%s>", name);
|
||||||
|
|
||||||
|
root->cur = root->cur->parent;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// checks for circular entity references, returns non-zero if no circular
|
||||||
|
// references are found, zero otherwise
|
||||||
|
static int switch_xml_ent_ok(char *name, char *s, char **ent)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (; ; s++) {
|
||||||
|
while (*s && *s != '&') s++; // find next entity reference
|
||||||
|
if (! *s) return 1;
|
||||||
|
if (! strncmp(s + 1, name, strlen(name))) return 0; // circular ref.
|
||||||
|
for (i = 0; ent[i] && strncmp(ent[i], s + 1, strlen(ent[i])); i += 2);
|
||||||
|
if (ent[i] && ! switch_xml_ent_ok(name, ent[i + 1], ent)) return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// called when the parser finds a processing instruction
|
||||||
|
static void switch_xml_proc_inst(switch_xml_root_t root, char *s, size_t len)
|
||||||
|
{
|
||||||
|
int i = 0, j = 1;
|
||||||
|
char *target = s;
|
||||||
|
|
||||||
|
s[len] = '\0'; // null terminate instruction
|
||||||
|
if (*(s += strcspn(s, SWITCH_XML_WS))) {
|
||||||
|
*s = '\0'; // null terminate target
|
||||||
|
s += strspn(s + 1, SWITCH_XML_WS) + 1; // skip whitespace after target
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! strcmp(target, "xml")) { // <?xml ... ?>
|
||||||
|
if ((s = strstr(s, "standalone")) && ! strncmp(s + strspn(s + 10,
|
||||||
|
SWITCH_XML_WS "='\"") + 10, "yes", 3)) root->standalone = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! root->pi[0]) *(root->pi = malloc(sizeof(char **))) = NULL; //first pi
|
||||||
|
|
||||||
|
while (root->pi[i] && strcmp(target, root->pi[i][0])) i++; // find target
|
||||||
|
if (! root->pi[i]) { // new target
|
||||||
|
root->pi = realloc(root->pi, sizeof(char **) * (i + 2));
|
||||||
|
root->pi[i] = malloc(sizeof(char *) * 3);
|
||||||
|
root->pi[i][0] = target;
|
||||||
|
root->pi[i][1] = (char *)(root->pi[i + 1] = NULL); // terminate pi list
|
||||||
|
root->pi[i][2] = strdup(""); // empty document position list
|
||||||
|
}
|
||||||
|
|
||||||
|
while (root->pi[i][j]) j++; // find end of instruction list for this target
|
||||||
|
root->pi[i] = realloc(root->pi[i], sizeof(char *) * (j + 3));
|
||||||
|
root->pi[i][j + 2] = realloc(root->pi[i][j + 1], j + 1);
|
||||||
|
strcpy(root->pi[i][j + 2] + j - 1, (root->xml.name) ? ">" : "<");
|
||||||
|
root->pi[i][j + 1] = NULL; // null terminate pi list for this target
|
||||||
|
root->pi[i][j] = s; // set instruction
|
||||||
|
}
|
||||||
|
|
||||||
|
// called when the parser finds an internal doctype subset
|
||||||
|
static short switch_xml_internal_dtd(switch_xml_root_t root, char *s, size_t len)
|
||||||
|
{
|
||||||
|
char q, *c, *t, *n = NULL, *v, **ent, **pe;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
pe = memcpy(malloc(sizeof(SWITCH_XML_NIL)), SWITCH_XML_NIL, sizeof(SWITCH_XML_NIL));
|
||||||
|
|
||||||
|
for (s[len] = '\0'; s; ) {
|
||||||
|
while (*s && *s != '<' && *s != '%') s++; // find next declaration
|
||||||
|
|
||||||
|
if (! *s) break;
|
||||||
|
else if (! strncmp(s, "<!ENTITY", 8)) { // parse entity definitions
|
||||||
|
c = s += strspn(s + 8, SWITCH_XML_WS) + 8; // skip white space separator
|
||||||
|
n = s + strspn(s, SWITCH_XML_WS "%"); // find name
|
||||||
|
*(s = n + strcspn(n, SWITCH_XML_WS)) = ';'; // append ; to name
|
||||||
|
|
||||||
|
v = s + strspn(s + 1, SWITCH_XML_WS) + 1; // find value
|
||||||
|
if ((q = *(v++)) != '"' && q != '\'') { // skip externals
|
||||||
|
s = strchr(s, '>');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0, ent = (*c == '%') ? pe : root->ent; ent[i]; i++);
|
||||||
|
ent = realloc(ent, (i + 3) * sizeof(char *)); // space for next ent
|
||||||
|
if (*c == '%') pe = ent;
|
||||||
|
else root->ent = ent;
|
||||||
|
|
||||||
|
*(++s) = '\0'; // null terminate name
|
||||||
|
if ((s = strchr(v, q))) *(s++) = '\0'; // null terminate value
|
||||||
|
ent[i + 1] = switch_xml_decode(v, pe, '%'); // set value
|
||||||
|
ent[i + 2] = NULL; // null terminate entity list
|
||||||
|
if (! switch_xml_ent_ok(n, ent[i + 1], ent)) { // circular reference
|
||||||
|
if (ent[i + 1] != v) free(ent[i + 1]);
|
||||||
|
switch_xml_err(root, v, "circular entity declaration &%s", n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else ent[i] = n; // set entity name
|
||||||
|
}
|
||||||
|
else if (! strncmp(s, "<!ATTLIST", 9)) { // parse default attributes
|
||||||
|
t = s + strspn(s + 9, SWITCH_XML_WS) + 9; // skip whitespace separator
|
||||||
|
if (! *t) { switch_xml_err(root, t, "unclosed <!ATTLIST"); break; }
|
||||||
|
if (*(s = t + strcspn(t, SWITCH_XML_WS ">")) == '>') continue;
|
||||||
|
else *s = '\0'; // null terminate tag name
|
||||||
|
for (i = 0; root->attr[i] && strcmp(n, root->attr[i][0]); i++);
|
||||||
|
|
||||||
|
while (*(n = ++s + strspn(s, SWITCH_XML_WS)) && *n != '>') {
|
||||||
|
if (*(s = n + strcspn(n, SWITCH_XML_WS))) *s = '\0'; // attr name
|
||||||
|
else { switch_xml_err(root, t, "malformed <!ATTLIST"); break; }
|
||||||
|
|
||||||
|
s += strspn(s + 1, SWITCH_XML_WS) + 1; // find next token
|
||||||
|
c = (strncmp(s, "CDATA", 5)) ? "*" : " "; // is it cdata?
|
||||||
|
if (! strncmp(s, "NOTATION", 8))
|
||||||
|
s += strspn(s + 8, SWITCH_XML_WS) + 8;
|
||||||
|
s = (*s == '(') ? strchr(s, ')') : s + strcspn(s, SWITCH_XML_WS);
|
||||||
|
if (! s) { switch_xml_err(root, t, "malformed <!ATTLIST"); break; }
|
||||||
|
|
||||||
|
s += strspn(s, SWITCH_XML_WS ")"); // skip white space separator
|
||||||
|
if (! strncmp(s, "#FIXED", 6))
|
||||||
|
s += strspn(s + 6, SWITCH_XML_WS) + 6;
|
||||||
|
if (*s == '#') { // no default value
|
||||||
|
s += strcspn(s, SWITCH_XML_WS ">") - 1;
|
||||||
|
if (*c == ' ') continue; // cdata is default, nothing to do
|
||||||
|
v = NULL;
|
||||||
|
}
|
||||||
|
else if ((*s == '"' || *s == '\'') && // default value
|
||||||
|
(s = strchr(v = s + 1, *s))) *s = '\0';
|
||||||
|
else { switch_xml_err(root, t, "malformed <!ATTLIST"); break; }
|
||||||
|
|
||||||
|
if (! root->attr[i]) { // new tag name
|
||||||
|
root->attr = (! i) ? malloc(2 * sizeof(char **))
|
||||||
|
: realloc(root->attr,
|
||||||
|
(i + 2) * sizeof(char **));
|
||||||
|
root->attr[i] = malloc(2 * sizeof(char *));
|
||||||
|
root->attr[i][0] = t; // set tag name
|
||||||
|
root->attr[i][1] = (char *)(root->attr[i + 1] = NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 1; root->attr[i][j]; j += 3); // find end of list
|
||||||
|
root->attr[i] = realloc(root->attr[i],
|
||||||
|
(j + 4) * sizeof(char *));
|
||||||
|
|
||||||
|
root->attr[i][j + 3] = NULL; // null terminate list
|
||||||
|
root->attr[i][j + 2] = c; // is it cdata?
|
||||||
|
root->attr[i][j + 1] = (v) ? switch_xml_decode(v, root->ent, *c)
|
||||||
|
: NULL;
|
||||||
|
root->attr[i][j] = n; // attribute name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (! strncmp(s, "<!--", 4)) s = strstr(s + 4, "-->"); // comments
|
||||||
|
else if (! strncmp(s, "<?", 2)) { // processing instructions
|
||||||
|
if ((s = strstr(c = s + 2, "?>")))
|
||||||
|
switch_xml_proc_inst(root, c, s++ - c);
|
||||||
|
}
|
||||||
|
else if (*s == '<') s = strchr(s, '>'); // skip other declarations
|
||||||
|
else if (*(s++) == '%' && ! root->standalone) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pe);
|
||||||
|
return ! *root->err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Converts a UTF-16 string to UTF-8. Returns a new string that must be freed
|
||||||
|
// or NULL if no conversion was needed.
|
||||||
|
static char *switch_xml_str2utf8(char **s, size_t *len)
|
||||||
|
{
|
||||||
|
char *u;
|
||||||
|
size_t l = 0, sl, max = *len;
|
||||||
|
long c, d;
|
||||||
|
int b, be = (**s == '\xFE') ? 1 : (**s == '\xFF') ? 0 : -1;
|
||||||
|
|
||||||
|
if (be == -1) return NULL; // not UTF-16
|
||||||
|
|
||||||
|
u = malloc(max);
|
||||||
|
for (sl = 2; sl < *len - 1; sl += 2) {
|
||||||
|
c = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) //UTF-16BE
|
||||||
|
: (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF); //UTF-16LE
|
||||||
|
if (c >= 0xD800 && c <= 0xDFFF && (sl += 2) < *len - 1) { // high-half
|
||||||
|
d = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF)
|
||||||
|
: (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF);
|
||||||
|
c = (((c & 0x3FF) << 10) | (d & 0x3FF)) + 0x10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (l + 6 > max) u = realloc(u, max += SWITCH_XML_BUFSIZE);
|
||||||
|
if (c < 0x80) u[l++] = c; // US-ASCII subset
|
||||||
|
else { // multi-byte UTF-8 sequence
|
||||||
|
for (b = 0, d = c; d; d /= 2) b++; // bits in c
|
||||||
|
b = (b - 2) / 5; // bytes in payload
|
||||||
|
u[l++] = (0xFF << (7 - b)) | (c >> (6 * b)); // head
|
||||||
|
while (b) u[l++] = 0x80 | ((c >> (6 * --b)) & 0x3F); // payload
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *s = realloc(u, *len = l);
|
||||||
|
}
|
||||||
|
|
||||||
|
// frees a tag attribute list
|
||||||
|
static void switch_xml_free_attr(char **attr) {
|
||||||
|
int i = 0;
|
||||||
|
char *m;
|
||||||
|
|
||||||
|
if (! attr || attr == SWITCH_XML_NIL) return; // nothing to free
|
||||||
|
while (attr[i]) i += 2; // find end of attribute list
|
||||||
|
m = attr[i + 1]; // list of which names and values are malloced
|
||||||
|
for (i = 0; m[i]; i++) {
|
||||||
|
if (m[i] & SWITCH_XML_NAMEM) free(attr[i * 2]);
|
||||||
|
if (m[i] & SWITCH_XML_TXTM) free(attr[(i * 2) + 1]);
|
||||||
|
}
|
||||||
|
free(m);
|
||||||
|
free(attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse the given xml string and return an switch_xml structure
|
||||||
|
switch_xml_t switch_xml_parse_str(char *s, size_t len)
|
||||||
|
{
|
||||||
|
switch_xml_root_t root = (switch_xml_root_t)switch_xml_new(NULL);
|
||||||
|
char q, e, *d, **attr, **a = NULL; // initialize a to avoid compile warning
|
||||||
|
int l, i, j;
|
||||||
|
|
||||||
|
root->m = s;
|
||||||
|
if (! len) return switch_xml_err(root, s, "root tag missing");
|
||||||
|
root->u = switch_xml_str2utf8(&s, &len); // convert utf-16 to utf-8
|
||||||
|
root->e = (root->s = s) + len; // record start and end of work area
|
||||||
|
|
||||||
|
e = s[len - 1]; // save end char
|
||||||
|
s[len - 1] = '\0'; // turn end char into null terminator
|
||||||
|
|
||||||
|
while (*s && *s != '<') s++; // find first tag
|
||||||
|
if (! *s) return switch_xml_err(root, s, "root tag missing");
|
||||||
|
|
||||||
|
for (; ; ) {
|
||||||
|
attr = (char **)SWITCH_XML_NIL;
|
||||||
|
d = ++s;
|
||||||
|
|
||||||
|
if (isalpha(*s) || *s == '_' || *s == ':' || *s < '\0') { // new tag
|
||||||
|
if (! root->cur)
|
||||||
|
return switch_xml_err(root, d, "markup outside of root element");
|
||||||
|
|
||||||
|
s += strcspn(s, SWITCH_XML_WS "/>");
|
||||||
|
while (isspace(*s)) *(s++) = '\0'; // null terminate tag name
|
||||||
|
|
||||||
|
if (*s && *s != '/' && *s != '>') // find tag in default attr list
|
||||||
|
for (i = 0; (a = root->attr[i]) && strcmp(a[0], d); i++);
|
||||||
|
|
||||||
|
for (l = 0; *s && *s != '/' && *s != '>'; l += 2) { // new attrib
|
||||||
|
attr = (l) ? realloc(attr, (l + 4) * sizeof(char *))
|
||||||
|
: malloc(4 * sizeof(char *)); // allocate space
|
||||||
|
attr[l + 3] = (l) ? realloc(attr[l + 1], (l / 2) + 2)
|
||||||
|
: malloc(2); // mem for list of maloced vals
|
||||||
|
strcpy(attr[l + 3] + (l / 2), " "); // value is not malloced
|
||||||
|
attr[l + 2] = NULL; // null terminate list
|
||||||
|
attr[l + 1] = ""; // temporary attribute value
|
||||||
|
attr[l] = s; // set attribute name
|
||||||
|
|
||||||
|
s += strcspn(s, SWITCH_XML_WS "=/>");
|
||||||
|
if (*s == '=' || isspace(*s)) {
|
||||||
|
*(s++) = '\0'; // null terminate tag attribute name
|
||||||
|
q = *(s += strspn(s, SWITCH_XML_WS "="));
|
||||||
|
if (q == '"' || q == '\'') { // attribute value
|
||||||
|
attr[l + 1] = ++s;
|
||||||
|
while (*s && *s != q) s++;
|
||||||
|
if (*s) *(s++) = '\0'; // null terminate attribute val
|
||||||
|
else {
|
||||||
|
switch_xml_free_attr(attr);
|
||||||
|
return switch_xml_err(root, d, "missing %c", q);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 1; a && a[j] && strcmp(a[j], attr[l]); j +=3);
|
||||||
|
attr[l + 1] = switch_xml_decode(attr[l + 1], root->ent, (a
|
||||||
|
&& a[j]) ? *a[j + 2] : ' ');
|
||||||
|
if (attr[l + 1] < d || attr[l + 1] > s)
|
||||||
|
attr[l + 3][l / 2] = SWITCH_XML_TXTM; // value malloced
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (isspace(*s)) s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*s == '/') { // self closing tag
|
||||||
|
*(s++) = '\0';
|
||||||
|
if ((*s && *s != '>') || (! *s && e != '>')) {
|
||||||
|
if (l) switch_xml_free_attr(attr);
|
||||||
|
return switch_xml_err(root, d, "missing >");
|
||||||
|
}
|
||||||
|
switch_xml_open_tag(root, d, attr);
|
||||||
|
switch_xml_close_tag(root, d, s);
|
||||||
|
}
|
||||||
|
else if ((q = *s) == '>' || (! *s && e == '>')) { // open tag
|
||||||
|
*s = '\0'; // temporarily null terminate tag name
|
||||||
|
switch_xml_open_tag(root, d, attr);
|
||||||
|
*s = q;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (l) switch_xml_free_attr(attr);
|
||||||
|
return switch_xml_err(root, d, "missing >");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*s == '/') { // close tag
|
||||||
|
s += strcspn(d = s + 1, SWITCH_XML_WS ">") + 1;
|
||||||
|
if (! (q = *s) && e != '>') return switch_xml_err(root, d, "missing >");
|
||||||
|
*s = '\0'; // temporarily null terminate tag name
|
||||||
|
if (switch_xml_close_tag(root, d, s)) return &root->xml;
|
||||||
|
if (isspace(*s = q)) s += strspn(s, SWITCH_XML_WS);
|
||||||
|
}
|
||||||
|
else if (! strncmp(s, "!--", 3)) { // comment
|
||||||
|
if (! (s = strstr(s + 3, "--")) || (*(s += 2) != '>' && *s) ||
|
||||||
|
(! *s && e != '>')) return switch_xml_err(root, d, "unclosed <!--");
|
||||||
|
}
|
||||||
|
else if (! strncmp(s, "![CDATA[", 8)) { // cdata
|
||||||
|
if ((s = strstr(s, "]]>")))
|
||||||
|
switch_xml_char_content(root, d + 8, (s += 2) - d - 10, 'c');
|
||||||
|
else return switch_xml_err(root, d, "unclosed <![CDATA[");
|
||||||
|
}
|
||||||
|
else if (! strncmp(s, "!DOCTYPE", 8)) { // dtd
|
||||||
|
for (l = 0; *s && ((! l && *s != '>') || (l && (*s != ']' ||
|
||||||
|
*(s + strspn(s + 1, SWITCH_XML_WS) + 1) != '>')));
|
||||||
|
l = (*s == '[') ? 1 : l) s += strcspn(s + 1, "[]>") + 1;
|
||||||
|
if (! *s && e != '>')
|
||||||
|
return switch_xml_err(root, d, "unclosed <!DOCTYPE");
|
||||||
|
d = (l) ? strchr(d, '[') + 1 : d;
|
||||||
|
if (l && ! switch_xml_internal_dtd(root, d, s++ - d)) return &root->xml;
|
||||||
|
}
|
||||||
|
else if (*s == '?') { // <?...?> processing instructions
|
||||||
|
do { s = strchr(s, '?'); } while (s && *(++s) && *s != '>');
|
||||||
|
if (! s || (! *s && e != '>'))
|
||||||
|
return switch_xml_err(root, d, "unclosed <?");
|
||||||
|
else switch_xml_proc_inst(root, d + 1, s - d - 2);
|
||||||
|
}
|
||||||
|
else return switch_xml_err(root, d, "unexpected <");
|
||||||
|
|
||||||
|
if (! s || ! *s) break;
|
||||||
|
*s = '\0';
|
||||||
|
d = ++s;
|
||||||
|
if (*s && *s != '<') { // tag character content
|
||||||
|
while (*s && *s != '<') s++;
|
||||||
|
if (*s) switch_xml_char_content(root, d, s - d, '&');
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
else if (! *s) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! root->cur) return &root->xml;
|
||||||
|
else if (! root->cur->name) return switch_xml_err(root, d, "root tag missing");
|
||||||
|
else return switch_xml_err(root, d, "unclosed tag <%s>", root->cur->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
|
||||||
|
// stream into memory and then parses it. For xml files, use switch_xml_parse_file()
|
||||||
|
// or switch_xml_parse_fd()
|
||||||
|
switch_xml_t switch_xml_parse_fp(FILE *fp)
|
||||||
|
{
|
||||||
|
switch_xml_root_t root;
|
||||||
|
size_t l, len = 0;
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
if (! (s = malloc(SWITCH_XML_BUFSIZE))) return NULL;
|
||||||
|
do {
|
||||||
|
len += (l = fread((s + len), 1, SWITCH_XML_BUFSIZE, fp));
|
||||||
|
if (l == SWITCH_XML_BUFSIZE) s = realloc(s, len + SWITCH_XML_BUFSIZE);
|
||||||
|
} while (s && l == SWITCH_XML_BUFSIZE);
|
||||||
|
|
||||||
|
if (! s) return NULL;
|
||||||
|
root = (switch_xml_root_t)switch_xml_parse_str(s, len);
|
||||||
|
root->len = -1; // so we know to free s in switch_xml_free()
|
||||||
|
return &root->xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A wrapper for switch_xml_parse_str() that accepts a file descriptor. First
|
||||||
|
// attempts to mem map the file. Failing that, reads the file into memory.
|
||||||
|
// Returns NULL on failure.
|
||||||
|
switch_xml_t switch_xml_parse_fd(int fd)
|
||||||
|
{
|
||||||
|
switch_xml_root_t root;
|
||||||
|
struct stat st;
|
||||||
|
size_t l;
|
||||||
|
void *m;
|
||||||
|
|
||||||
|
if (fd < 0) return NULL;
|
||||||
|
fstat(fd, &st);
|
||||||
|
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
l = (st.st_size + sysconf(_SC_PAGESIZE) - 1) & ~(sysconf(_SC_PAGESIZE) -1);
|
||||||
|
if ((m = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) !=
|
||||||
|
MAP_FAILED) {
|
||||||
|
madvise(m, l, MADV_SEQUENTIAL); // optimize for sequential access
|
||||||
|
root = (switch_xml_root_t)switch_xml_parse_str(m, st.st_size);
|
||||||
|
madvise(m, root->len = l, MADV_NORMAL); // put it back to normal
|
||||||
|
}
|
||||||
|
else { // mmap failed, read file into memory
|
||||||
|
#endif // HAVE_MMAP
|
||||||
|
l = read(fd, m = malloc(st.st_size), st.st_size);
|
||||||
|
root = (switch_xml_root_t)switch_xml_parse_str(m, l);
|
||||||
|
root->len = -1; // so we know to free s in switch_xml_free()
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
}
|
||||||
|
#endif // HAVE_MMAP
|
||||||
|
return &root->xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// a wrapper for switch_xml_parse_fd that accepts a file name
|
||||||
|
switch_xml_t switch_xml_parse_file(const char *file)
|
||||||
|
{
|
||||||
|
int fd = open(file, O_RDONLY, 0);
|
||||||
|
switch_xml_t xml = switch_xml_parse_fd(fd);
|
||||||
|
|
||||||
|
if (fd >= 0) close(fd);
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encodes ampersand sequences appending the results to *dst, reallocating *dst
|
||||||
|
// if length excedes max. a is non-zero for attribute encoding. Returns *dst
|
||||||
|
static char *switch_xml_ampencode(const char *s, size_t len, char **dst, size_t *dlen,
|
||||||
|
size_t *max, short a)
|
||||||
|
{
|
||||||
|
const char *e;
|
||||||
|
|
||||||
|
for (e = s + len; s != e; s++) {
|
||||||
|
while (*dlen + 10 > *max) *dst = realloc(*dst, *max += SWITCH_XML_BUFSIZE);
|
||||||
|
|
||||||
|
switch (*s) {
|
||||||
|
case '\0': return *dst;
|
||||||
|
case '&': *dlen += sprintf(*dst + *dlen, "&"); break;
|
||||||
|
case '<': *dlen += sprintf(*dst + *dlen, "<"); break;
|
||||||
|
case '>': *dlen += sprintf(*dst + *dlen, ">"); break;
|
||||||
|
case '"': *dlen += sprintf(*dst + *dlen, (a) ? """ : "\""); break;
|
||||||
|
case '\n': *dlen += sprintf(*dst + *dlen, (a) ? "
" : "\n"); break;
|
||||||
|
case '\t': *dlen += sprintf(*dst + *dlen, (a) ? "	" : "\t"); break;
|
||||||
|
case '\r': *dlen += sprintf(*dst + *dlen, "
"); break;
|
||||||
|
default: (*dst)[(*dlen)++] = *s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively converts each tag to xml appending it to *s. Reallocates *s if
|
||||||
|
// its length excedes max. start is the location of the previous tag in the
|
||||||
|
// parent tag's character content. Returns *s.
|
||||||
|
static char *switch_xml_toxml_r(switch_xml_t xml, char **s, size_t *len, size_t *max,
|
||||||
|
size_t start, char ***attr)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
char *txt = (xml->parent) ? xml->parent->txt : "";
|
||||||
|
size_t off = 0;
|
||||||
|
|
||||||
|
// parent character content up to this tag
|
||||||
|
*s = switch_xml_ampencode(txt + start, xml->off - start, s, len, max, 0);
|
||||||
|
|
||||||
|
while (*len + strlen(xml->name) + 4 > *max) // reallocate s
|
||||||
|
*s = realloc(*s, *max += SWITCH_XML_BUFSIZE);
|
||||||
|
|
||||||
|
*len += sprintf(*s + *len, "<%s", xml->name); // open tag
|
||||||
|
for (i = 0; xml->attr[i]; i += 2) { // tag attributes
|
||||||
|
if (switch_xml_attr(xml, xml->attr[i]) != xml->attr[i + 1]) continue;
|
||||||
|
while (*len + strlen(xml->attr[i]) + 7 > *max) // reallocate s
|
||||||
|
*s = realloc(*s, *max += SWITCH_XML_BUFSIZE);
|
||||||
|
|
||||||
|
*len += sprintf(*s + *len, " %s=\"", xml->attr[i]);
|
||||||
|
switch_xml_ampencode(xml->attr[i + 1], -1, s, len, max, 1);
|
||||||
|
*len += sprintf(*s + *len, "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; attr[i] && strcmp(attr[i][0], xml->name); i++);
|
||||||
|
for (j = 1; attr[i] && attr[i][j]; j += 3) { // default attributes
|
||||||
|
if (! attr[i][j + 1] || switch_xml_attr(xml, attr[i][j]) != attr[i][j + 1])
|
||||||
|
continue; // skip duplicates and non-values
|
||||||
|
while (*len + strlen(attr[i][j]) + 7 > *max) // reallocate s
|
||||||
|
*s = realloc(*s, *max += SWITCH_XML_BUFSIZE);
|
||||||
|
|
||||||
|
*len += sprintf(*s + *len, " %s=\"", attr[i][j]);
|
||||||
|
switch_xml_ampencode(attr[i][j + 1], -1, s, len, max, 1);
|
||||||
|
*len += sprintf(*s + *len, "\"");
|
||||||
|
}
|
||||||
|
*len += sprintf(*s + *len, ">");
|
||||||
|
|
||||||
|
*s = (xml->child) ? switch_xml_toxml_r(xml->child, s, len, max, 0, attr) //child
|
||||||
|
: switch_xml_ampencode(xml->txt, -1, s, len, max, 0); //data
|
||||||
|
|
||||||
|
while (*len + strlen(xml->name) + 4 > *max) // reallocate s
|
||||||
|
*s = realloc(*s, *max += SWITCH_XML_BUFSIZE);
|
||||||
|
|
||||||
|
*len += sprintf(*s + *len, "</%s>", xml->name); // close tag
|
||||||
|
|
||||||
|
while (txt[off] && off < xml->off) off++; // make sure off is within bounds
|
||||||
|
return (xml->ordered) ? switch_xml_toxml_r(xml->ordered, s, len, max, off, attr)
|
||||||
|
: switch_xml_ampencode(txt + off, -1, s, len, max, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// converts an switch_xml structure back to xml, returning it as a string that must
|
||||||
|
// be freed
|
||||||
|
char *switch_xml_toxml(switch_xml_t xml)
|
||||||
|
{
|
||||||
|
switch_xml_t p = (xml) ? xml->parent : NULL, o = (xml) ? xml->ordered : NULL;
|
||||||
|
switch_xml_root_t root = (switch_xml_root_t)xml;
|
||||||
|
size_t len = 0, max = SWITCH_XML_BUFSIZE;
|
||||||
|
char *s = strcpy(malloc(max), ""), *t, *n;
|
||||||
|
int i, j, k;
|
||||||
|
|
||||||
|
if (! xml || ! xml->name) return realloc(s, len + 1);
|
||||||
|
while (root->xml.parent) root = (switch_xml_root_t)root->xml.parent; // root tag
|
||||||
|
|
||||||
|
for (i = 0; ! p && root->pi[i]; i++) { // pre-root processing instructions
|
||||||
|
for (k = 2; root->pi[i][k - 1]; k++);
|
||||||
|
for (j = 1; (n = root->pi[i][j]); j++) {
|
||||||
|
if (root->pi[i][k][j - 1] == '>') continue; // not pre-root
|
||||||
|
while (len + strlen(t = root->pi[i][0]) + strlen(n) + 7 > max)
|
||||||
|
s = realloc(s, max += SWITCH_XML_BUFSIZE);
|
||||||
|
len += sprintf(s + len, "<?%s%s%s?>\n", t, *n ? " " : "", n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml->parent = xml->ordered = NULL;
|
||||||
|
s = switch_xml_toxml_r(xml, &s, &len, &max, 0, root->attr);
|
||||||
|
xml->parent = p;
|
||||||
|
xml->ordered = o;
|
||||||
|
|
||||||
|
for (i = 0; ! p && root->pi[i]; i++) { // post-root processing instructions
|
||||||
|
for (k = 2; root->pi[i][k - 1]; k++);
|
||||||
|
for (j = 1; (n = root->pi[i][j]); j++) {
|
||||||
|
if (root->pi[i][k][j - 1] == '<') continue; // not post-root
|
||||||
|
while (len + strlen(t = root->pi[i][0]) + strlen(n) + 7 > max)
|
||||||
|
s = realloc(s, max += SWITCH_XML_BUFSIZE);
|
||||||
|
len += sprintf(s + len, "\n<?%s%s%s?>", t, *n ? " " : "", n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return realloc(s, len + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// free the memory allocated for the switch_xml structure
|
||||||
|
void switch_xml_free(switch_xml_t xml)
|
||||||
|
{
|
||||||
|
switch_xml_root_t root = (switch_xml_root_t)xml;
|
||||||
|
int i, j;
|
||||||
|
char **a, *s;
|
||||||
|
|
||||||
|
if (! xml) return;
|
||||||
|
switch_xml_free(xml->child);
|
||||||
|
switch_xml_free(xml->ordered);
|
||||||
|
|
||||||
|
if (! xml->parent) { // free root tag allocations
|
||||||
|
for (i = 10; root->ent[i]; i += 2) // 0 - 9 are default entites (<>&"')
|
||||||
|
if ((s = root->ent[i + 1]) < root->s || s > root->e) free(s);
|
||||||
|
free(root->ent); // free list of general entities
|
||||||
|
|
||||||
|
for (i = 0; (a = root->attr[i]); i++) {
|
||||||
|
for (j = 1; a[j++]; j += 2) // free malloced attribute values
|
||||||
|
if (a[j] && (a[j] < root->s || a[j] > root->e)) free(a[j]);
|
||||||
|
free(a);
|
||||||
|
}
|
||||||
|
if (root->attr[0]) free(root->attr); // free default attribute list
|
||||||
|
|
||||||
|
for (i = 0; root->pi[i]; i++) {
|
||||||
|
for (j = 1; root->pi[i][j]; j++);
|
||||||
|
free(root->pi[i][j + 1]);
|
||||||
|
free(root->pi[i]);
|
||||||
|
}
|
||||||
|
if (root->pi[0]) free(root->pi); // free processing instructions
|
||||||
|
|
||||||
|
if (root->len == -1) free(root->m); // malloced xml data
|
||||||
|
#ifdef HAVE_MMAP
|
||||||
|
else if (root->len) munmap(root->m, root->len); // mem mapped xml data
|
||||||
|
#endif // HAVE_MMAP
|
||||||
|
if (root->u) free(root->u); // utf8 conversion
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_xml_free_attr(xml->attr); // tag attributes
|
||||||
|
if ((xml->flags & SWITCH_XML_TXTM)) free(xml->txt); // character content
|
||||||
|
if ((xml->flags & SWITCH_XML_NAMEM)) free(xml->name); // tag name
|
||||||
|
free(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return parser error message or empty string if none
|
||||||
|
const char *switch_xml_error(switch_xml_t xml)
|
||||||
|
{
|
||||||
|
while (xml && xml->parent) xml = xml->parent; // find root tag
|
||||||
|
return (xml) ? ((switch_xml_root_t)xml)->err : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns a new empty switch_xml structure with the given root tag name
|
||||||
|
switch_xml_t switch_xml_new(const char *name)
|
||||||
|
{
|
||||||
|
static char *ent[] = { "lt;", "<", "gt;", ">", "quot;", """,
|
||||||
|
"apos;", "'", "amp;", "&", NULL };
|
||||||
|
switch_xml_root_t root = (switch_xml_root_t)memset(malloc(sizeof(struct switch_xml_root)),
|
||||||
|
'\0', sizeof(struct switch_xml_root));
|
||||||
|
root->xml.name = (char *)name;
|
||||||
|
root->cur = &root->xml;
|
||||||
|
strcpy(root->err, root->xml.txt = "");
|
||||||
|
root->ent = memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
|
||||||
|
root->attr = root->pi = (char ***)(root->xml.attr = SWITCH_XML_NIL);
|
||||||
|
return &root->xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a child tag. off is the offset of the child tag relative to the start
|
||||||
|
// of the parent tag's character content. returns the child tag
|
||||||
|
switch_xml_t switch_xml_add_child(switch_xml_t xml, const char *name, size_t off)
|
||||||
|
{
|
||||||
|
switch_xml_t cur, head, child;
|
||||||
|
|
||||||
|
if (! xml) return NULL;
|
||||||
|
child = (switch_xml_t)memset(malloc(sizeof(struct switch_xml)), '\0',
|
||||||
|
sizeof(struct switch_xml));
|
||||||
|
child->name = (char *)name;
|
||||||
|
child->attr = SWITCH_XML_NIL;
|
||||||
|
child->off = off;
|
||||||
|
child->parent = xml;
|
||||||
|
child->txt = "";
|
||||||
|
|
||||||
|
if ((head = xml->child)) { // already have sub tags
|
||||||
|
if (head->off <= off) { // not first subtag
|
||||||
|
for (cur = head; cur->ordered && cur->ordered->off <= off;
|
||||||
|
cur = cur->ordered);
|
||||||
|
child->ordered = cur->ordered;
|
||||||
|
cur->ordered = child;
|
||||||
|
}
|
||||||
|
else { // first subtag
|
||||||
|
child->ordered = head;
|
||||||
|
xml->child = child;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (cur = head; cur->sibling && strcmp(cur->name, name);
|
||||||
|
cur = cur->sibling); // find tag type
|
||||||
|
if (! strcmp(cur->name, name) && cur->off <= off) { //not first of type
|
||||||
|
while (cur->next && cur->next->off <= off) cur = cur->next;
|
||||||
|
child->next = cur->next;
|
||||||
|
cur->next = child;
|
||||||
|
}
|
||||||
|
else { // first tag of this type
|
||||||
|
if (cur->off > off) child->next = cur; // not only tag of this type
|
||||||
|
for (cur = head; cur->sibling && cur->sibling->off <= off;
|
||||||
|
cur = cur->sibling);
|
||||||
|
child->sibling = cur->sibling;
|
||||||
|
cur->sibling = child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else xml->child = child; // only sub tag
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sets the character content for the given tag and returns the tag
|
||||||
|
switch_xml_t switch_xml_set_txt(switch_xml_t xml, const char *txt)
|
||||||
|
{
|
||||||
|
if (! xml) return NULL;
|
||||||
|
if (xml->flags & SWITCH_XML_TXTM) free(xml->txt); // existing txt was malloced
|
||||||
|
xml->flags &= ~SWITCH_XML_TXTM;
|
||||||
|
xml->txt = (char *)txt;
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the given tag attribute or adds a new attribute if not found. A value
|
||||||
|
// of NULL will remove the specified attribute.
|
||||||
|
void switch_xml_set_attr(switch_xml_t xml, const char *name, const char *value)
|
||||||
|
{
|
||||||
|
int l = 0, c;
|
||||||
|
|
||||||
|
if (! xml) return;
|
||||||
|
while (xml->attr[l] && strcmp(xml->attr[l], name)) l += 2;
|
||||||
|
if (! xml->attr[l]) { // not found, add as new attribute
|
||||||
|
if (! value) return; // nothing to do
|
||||||
|
if (xml->attr == SWITCH_XML_NIL) { // first attribute
|
||||||
|
xml->attr = malloc(4 * sizeof(char *));
|
||||||
|
xml->attr[1] = strdup(""); // empty list of malloced names/vals
|
||||||
|
}
|
||||||
|
else xml->attr = realloc(xml->attr, (l + 4) * sizeof(char *));
|
||||||
|
|
||||||
|
xml->attr[l] = (char *)name; // set attribute name
|
||||||
|
xml->attr[l + 2] = NULL; // null terminate attribute list
|
||||||
|
xml->attr[l + 3] = realloc(xml->attr[l + 1],
|
||||||
|
(c = strlen(xml->attr[l + 1])) + 2);
|
||||||
|
strcpy(xml->attr[l + 3] + c, " "); // set name/value as not malloced
|
||||||
|
if (xml->flags & SWITCH_XML_DUP) xml->attr[l + 3][c] = SWITCH_XML_NAMEM;
|
||||||
|
}
|
||||||
|
else if (xml->flags & SWITCH_XML_DUP) free((char *)name); // name was strduped
|
||||||
|
|
||||||
|
for (c = l; xml->attr[c]; c += 2); // find end of attribute list
|
||||||
|
if (xml->attr[c + 1][l / 2] & SWITCH_XML_TXTM) free(xml->attr[l + 1]); //old val
|
||||||
|
if (xml->flags & SWITCH_XML_DUP) xml->attr[c + 1][l / 2] |= SWITCH_XML_TXTM;
|
||||||
|
else xml->attr[c + 1][l / 2] &= ~SWITCH_XML_TXTM;
|
||||||
|
|
||||||
|
if (value) xml->attr[l + 1] = (char *)value; // set attribute value
|
||||||
|
else { // remove attribute
|
||||||
|
if (xml->attr[c + 1][l / 2] & SWITCH_XML_NAMEM) free(xml->attr[l]);
|
||||||
|
memmove(xml->attr + l, xml->attr + l + 2, (c - l + 2) * sizeof(char*));
|
||||||
|
xml->attr = realloc(xml->attr, (c + 2) * sizeof(char *));
|
||||||
|
memmove(xml->attr[c + 1] + (l / 2), xml->attr[c + 1] + (l / 2) + 1,
|
||||||
|
(c / 2) - (l / 2)); // fix list of which name/vals are malloced
|
||||||
|
}
|
||||||
|
xml->flags &= ~SWITCH_XML_DUP; // clear strdup() flag
|
||||||
|
}
|
||||||
|
|
||||||
|
// sets a flag for the given tag and returns the tag
|
||||||
|
switch_xml_t switch_xml_set_flag(switch_xml_t xml, short flag)
|
||||||
|
{
|
||||||
|
if (xml) xml->flags |= flag;
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
// removes a tag along with all its subtags
|
||||||
|
void switch_xml_remove(switch_xml_t xml)
|
||||||
|
{
|
||||||
|
switch_xml_t cur;
|
||||||
|
|
||||||
|
if (! xml) return; // nothing to do
|
||||||
|
if (xml->next) xml->next->sibling = xml->sibling; // patch sibling list
|
||||||
|
|
||||||
|
if (xml->parent) { // not root tag
|
||||||
|
cur = xml->parent->child; // find head of subtag list
|
||||||
|
if (cur == xml) xml->parent->child = xml->ordered; // first subtag
|
||||||
|
else { // not first subtag
|
||||||
|
while (cur->ordered != xml) cur = cur->ordered;
|
||||||
|
cur->ordered = cur->ordered->ordered; // patch ordered list
|
||||||
|
|
||||||
|
cur = xml->parent->child; // go back to head of subtag list
|
||||||
|
if (strcmp(cur->name, xml->name)) { // not in first sibling list
|
||||||
|
while (strcmp(cur->sibling->name, xml->name))
|
||||||
|
cur = cur->sibling;
|
||||||
|
if (cur->sibling == xml) { // first of a sibling list
|
||||||
|
cur->sibling = (xml->next) ? xml->next
|
||||||
|
: cur->sibling->sibling;
|
||||||
|
}
|
||||||
|
else cur = cur->sibling; // not first of a sibling list
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cur->next && cur->next != xml) cur = cur->next;
|
||||||
|
if (cur->next) cur->next = cur->next->next; // patch next list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xml->ordered = NULL; // prevent switch_xml_free() from clobbering ordered list
|
||||||
|
switch_xml_free(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SWITCH_XML_TEST // test harness
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
switch_xml_t xml;
|
||||||
|
char *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (argc != 2) return fprintf(stderr, "usage: %s xmlfile\n", argv[0]);
|
||||||
|
|
||||||
|
xml = switch_xml_parse_file(argv[1]);
|
||||||
|
printf("%s\n", (s = switch_xml_toxml(xml)));
|
||||||
|
free(s);
|
||||||
|
i = fprintf(stderr, "%s", switch_xml_error(xml));
|
||||||
|
switch_xml_free(xml);
|
||||||
|
return (i) ? 1 : 0;
|
||||||
|
}
|
||||||
|
#endif // SWITCH_XML_TEST
|
Loading…
Reference in New Issue