mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-16 22:38:38 +00:00
add iksemel to in tree libs
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3756 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
7d37a04688
commit
83f4a9dc2f
66 files changed
+57293
-2
No files matched your search
@@ -0,0 +1,33 @@
|
||||
##
|
||||
## Process this file with automake to produce Makefile.in
|
||||
##
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
TESTS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
|
||||
|
||||
noinst_PROGRAMS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
|
||||
|
||||
tst_ikstack_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_ikstack_SOURCES = tst-ikstack.c
|
||||
|
||||
tst_iks_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_iks_SOURCES = tst-iks.c
|
||||
|
||||
tst_sax_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_sax_SOURCES = tst-sax.c
|
||||
|
||||
tst_dom_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_dom_SOURCES = tst-dom.c
|
||||
|
||||
tst_sha_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_sha_SOURCES = tst-sha.c
|
||||
|
||||
tst_md5_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_md5_SOURCES = tst-md5.c
|
||||
|
||||
tst_filter_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_filter_SOURCES = tst-filter.c
|
||||
|
||||
tst_jid_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_jid_SOURCES = tst-jid.c
|
||||
@@ -0,0 +1,415 @@
|
||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
ECHO = @ECHO@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
GCJ = @GCJ@
|
||||
GCJFLAGS = @GCJFLAGS@
|
||||
HAVE_LIB = @HAVE_LIB@
|
||||
LIB = @LIB@
|
||||
LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
|
||||
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
|
||||
LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIB = @LTLIB@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
RC = @RC@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
TESTS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
|
||||
|
||||
noinst_PROGRAMS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
|
||||
|
||||
tst_ikstack_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_ikstack_SOURCES = tst-ikstack.c
|
||||
|
||||
tst_iks_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_iks_SOURCES = tst-iks.c
|
||||
|
||||
tst_sax_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_sax_SOURCES = tst-sax.c
|
||||
|
||||
tst_dom_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_dom_SOURCES = tst-dom.c
|
||||
|
||||
tst_sha_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_sha_SOURCES = tst-sha.c
|
||||
|
||||
tst_md5_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_md5_SOURCES = tst-md5.c
|
||||
|
||||
tst_filter_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_filter_SOURCES = tst-filter.c
|
||||
|
||||
tst_jid_LDADD = $(top_builddir)/src/libiksemel.la
|
||||
tst_jid_SOURCES = tst-jid.c
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../include/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
noinst_PROGRAMS = tst-ikstack$(EXEEXT) tst-iks$(EXEEXT) \
|
||||
tst-sax$(EXEEXT) tst-dom$(EXEEXT) tst-sha$(EXEEXT) tst-md5$(EXEEXT) \
|
||||
tst-filter$(EXEEXT) tst-jid$(EXEEXT)
|
||||
PROGRAMS = $(noinst_PROGRAMS)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir) -I../include
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
tst_ikstack_OBJECTS = tst-ikstack.$(OBJEXT)
|
||||
tst_ikstack_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_ikstack_LDFLAGS =
|
||||
tst_iks_OBJECTS = tst-iks.$(OBJEXT)
|
||||
tst_iks_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_iks_LDFLAGS =
|
||||
tst_sax_OBJECTS = tst-sax.$(OBJEXT)
|
||||
tst_sax_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_sax_LDFLAGS =
|
||||
tst_dom_OBJECTS = tst-dom.$(OBJEXT)
|
||||
tst_dom_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_dom_LDFLAGS =
|
||||
tst_sha_OBJECTS = tst-sha.$(OBJEXT)
|
||||
tst_sha_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_sha_LDFLAGS =
|
||||
tst_md5_OBJECTS = tst-md5.$(OBJEXT)
|
||||
tst_md5_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_md5_LDFLAGS =
|
||||
tst_filter_OBJECTS = tst-filter.$(OBJEXT)
|
||||
tst_filter_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_filter_LDFLAGS =
|
||||
tst_jid_OBJECTS = tst-jid.$(OBJEXT)
|
||||
tst_jid_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
|
||||
tst_jid_LDFLAGS =
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(tst_ikstack_SOURCES) $(tst_iks_SOURCES) $(tst_sax_SOURCES) $(tst_dom_SOURCES) $(tst_sha_SOURCES) $(tst_md5_SOURCES) $(tst_filter_SOURCES) $(tst_jid_SOURCES)
|
||||
OBJECTS = $(tst_ikstack_OBJECTS) $(tst_iks_OBJECTS) $(tst_sax_OBJECTS) $(tst_dom_OBJECTS) $(tst_sha_OBJECTS) $(tst_md5_OBJECTS) $(tst_filter_OBJECTS) $(tst_jid_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .lo .o .obj .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps test/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-noinstPROGRAMS:
|
||||
|
||||
clean-noinstPROGRAMS:
|
||||
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
|
||||
|
||||
distclean-noinstPROGRAMS:
|
||||
|
||||
maintainer-clean-noinstPROGRAMS:
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
# FIXME: We should only use cygpath when building on Windows,
|
||||
# and only if it is available.
|
||||
.c.obj:
|
||||
$(COMPILE) -c `cygpath -w $<`
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
.c.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
.s.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
.S.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
|
||||
maintainer-clean-libtool:
|
||||
|
||||
tst-ikstack$(EXEEXT): $(tst_ikstack_OBJECTS) $(tst_ikstack_DEPENDENCIES)
|
||||
@rm -f tst-ikstack$(EXEEXT)
|
||||
$(LINK) $(tst_ikstack_LDFLAGS) $(tst_ikstack_OBJECTS) $(tst_ikstack_LDADD) $(LIBS)
|
||||
|
||||
tst-iks$(EXEEXT): $(tst_iks_OBJECTS) $(tst_iks_DEPENDENCIES)
|
||||
@rm -f tst-iks$(EXEEXT)
|
||||
$(LINK) $(tst_iks_LDFLAGS) $(tst_iks_OBJECTS) $(tst_iks_LDADD) $(LIBS)
|
||||
|
||||
tst-sax$(EXEEXT): $(tst_sax_OBJECTS) $(tst_sax_DEPENDENCIES)
|
||||
@rm -f tst-sax$(EXEEXT)
|
||||
$(LINK) $(tst_sax_LDFLAGS) $(tst_sax_OBJECTS) $(tst_sax_LDADD) $(LIBS)
|
||||
|
||||
tst-dom$(EXEEXT): $(tst_dom_OBJECTS) $(tst_dom_DEPENDENCIES)
|
||||
@rm -f tst-dom$(EXEEXT)
|
||||
$(LINK) $(tst_dom_LDFLAGS) $(tst_dom_OBJECTS) $(tst_dom_LDADD) $(LIBS)
|
||||
|
||||
tst-sha$(EXEEXT): $(tst_sha_OBJECTS) $(tst_sha_DEPENDENCIES)
|
||||
@rm -f tst-sha$(EXEEXT)
|
||||
$(LINK) $(tst_sha_LDFLAGS) $(tst_sha_OBJECTS) $(tst_sha_LDADD) $(LIBS)
|
||||
|
||||
tst-md5$(EXEEXT): $(tst_md5_OBJECTS) $(tst_md5_DEPENDENCIES)
|
||||
@rm -f tst-md5$(EXEEXT)
|
||||
$(LINK) $(tst_md5_LDFLAGS) $(tst_md5_OBJECTS) $(tst_md5_LDADD) $(LIBS)
|
||||
|
||||
tst-filter$(EXEEXT): $(tst_filter_OBJECTS) $(tst_filter_DEPENDENCIES)
|
||||
@rm -f tst-filter$(EXEEXT)
|
||||
$(LINK) $(tst_filter_LDFLAGS) $(tst_filter_OBJECTS) $(tst_filter_LDADD) $(LIBS)
|
||||
|
||||
tst-jid$(EXEEXT): $(tst_jid_OBJECTS) $(tst_jid_DEPENDENCIES)
|
||||
@rm -f tst-jid$(EXEEXT)
|
||||
$(LINK) $(tst_jid_LDFLAGS) $(tst_jid_OBJECTS) $(tst_jid_LDADD) $(LIBS)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP))
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = test
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
check-TESTS: $(TESTS)
|
||||
@failed=0; all=0; \
|
||||
srcdir=$(srcdir); export srcdir; \
|
||||
for tst in $(TESTS); do \
|
||||
if test -f $$tst; then dir=.; \
|
||||
else dir="$(srcdir)"; fi; \
|
||||
if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
|
||||
all=`expr $$all + 1`; \
|
||||
echo "PASS: $$tst"; \
|
||||
elif test $$? -ne 77; then \
|
||||
all=`expr $$all + 1`; \
|
||||
failed=`expr $$failed + 1`; \
|
||||
echo "FAIL: $$tst"; \
|
||||
fi; \
|
||||
done; \
|
||||
if test "$$failed" -eq 0; then \
|
||||
banner="All $$all tests passed"; \
|
||||
else \
|
||||
banner="$$failed of $$all tests failed"; \
|
||||
fi; \
|
||||
dashes=`echo "$$banner" | sed s/./=/g`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
echo "$$dashes"; \
|
||||
test "$$failed" -eq 0
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \
|
||||
mostlyclean-libtool mostlyclean-tags \
|
||||
mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-noinstPROGRAMS distclean-compile \
|
||||
distclean-libtool distclean-tags distclean-generic \
|
||||
clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-noinstPROGRAMS \
|
||||
maintainer-clean-compile maintainer-clean-libtool \
|
||||
maintainer-clean-tags maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \
|
||||
clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
|
||||
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir check-TESTS \
|
||||
info-am info dvi-am dvi check check-am installcheck-am installcheck \
|
||||
install-exec-am install-exec install-data-am install-data install-am \
|
||||
install uninstall-am uninstall all-redirect all-am all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -0,0 +1,164 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
iks *my_x;
|
||||
int nr_tests;
|
||||
|
||||
#define PR_TEST printf ("DOM test %d:\n", nr_tests)
|
||||
|
||||
void
|
||||
document (char *xml)
|
||||
{
|
||||
enum ikserror err;
|
||||
iksparser *p;
|
||||
|
||||
nr_tests++;
|
||||
if (my_x) iks_delete (my_x);
|
||||
p = iks_dom_new (&my_x);
|
||||
err = iks_parse (p, xml, 0, 1);
|
||||
switch (err) {
|
||||
case IKS_OK:
|
||||
break;
|
||||
case IKS_NOMEM:
|
||||
PR_TEST;
|
||||
puts ("Not enough memory.");
|
||||
exit (1);
|
||||
case IKS_BADXML:
|
||||
PR_TEST;
|
||||
printf ("Invalid xml at byte %ld in\n[%s]\n", iks_nr_bytes (p), xml);
|
||||
exit (1);
|
||||
case IKS_HOOK:
|
||||
PR_TEST;
|
||||
puts ("Hook.");
|
||||
}
|
||||
iks_parser_delete (p);
|
||||
}
|
||||
|
||||
void
|
||||
tag (char *name, ...)
|
||||
{
|
||||
iks *x;
|
||||
va_list ap;
|
||||
|
||||
x = my_x;
|
||||
va_start (ap, name);
|
||||
while (1) {
|
||||
char *name = iks_name (x);
|
||||
char *tmp = va_arg (ap, char*);
|
||||
if (NULL == tmp) break;
|
||||
x = iks_find (x, tmp);
|
||||
if (!x) {
|
||||
PR_TEST;
|
||||
printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (!x || NULL == iks_find (x, name)) {
|
||||
PR_TEST;
|
||||
printf ("Tag <%s> is not a child of tag <%s>\n", name, iks_name (x));
|
||||
exit (1);
|
||||
}
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void
|
||||
cdata (char *data, ...)
|
||||
{
|
||||
iks *x;
|
||||
va_list ap;
|
||||
|
||||
x = my_x;
|
||||
va_start (ap, data);
|
||||
while (1) {
|
||||
char *name = iks_name (x);
|
||||
char *tmp = va_arg (ap, char*);
|
||||
if (NULL == tmp) break;
|
||||
x = iks_find (x, tmp);
|
||||
if (!x) {
|
||||
PR_TEST;
|
||||
printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (iks_strcmp ( iks_cdata (iks_child (x)), data) != 0) {
|
||||
PR_TEST;
|
||||
printf ("CDATA [%s] not found.\n", data);
|
||||
exit (1);
|
||||
}
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void
|
||||
attrib (char *att, char *val, ...)
|
||||
{
|
||||
iks *x;
|
||||
va_list ap;
|
||||
|
||||
x = my_x;
|
||||
va_start (ap, val);
|
||||
while (1) {
|
||||
char *name = iks_name (x);
|
||||
char *tmp = va_arg (ap, char*);
|
||||
if (NULL == tmp) break;
|
||||
x = iks_find (x, tmp);
|
||||
if (!x) {
|
||||
PR_TEST;
|
||||
printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (iks_strcmp (val, iks_find_attrib (x, att)) != 0) {
|
||||
PR_TEST;
|
||||
printf ("Attribute '%s' not found.\n", att);
|
||||
exit (1);
|
||||
}
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
void
|
||||
string (char *xml)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = iks_string (iks_stack (my_x), my_x);
|
||||
if (iks_strcmp (tmp, xml) != 0) {
|
||||
PR_TEST;
|
||||
printf ("Result: %s\n", tmp);
|
||||
printf ("Expected: %s\n", xml);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
static char buf[] =
|
||||
"<presence id='JCOM_11' to='lala@j.org' type='available'><status>"
|
||||
"" <online&dangerous> "</status>meow<a><b c='d'/>"
|
||||
"</a><test/></presence>";
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
document ("<atag></atag>");
|
||||
string ("<atag/>");
|
||||
|
||||
document ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");
|
||||
tag ("b", 0);
|
||||
tag ("c", "a", 0);
|
||||
string ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");
|
||||
|
||||
document (buf);
|
||||
cdata ("\" <online&dangerous> \"", "status", 0);
|
||||
attrib ("c", "d", "a", "b", 0);
|
||||
tag ("test", 0);
|
||||
string (buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
struct {
|
||||
iksfilter *f;
|
||||
char *xml;
|
||||
int nr;
|
||||
iksFilterHook *hook[20];
|
||||
int nr_hook;
|
||||
iksFilterHook *call[20];
|
||||
int nr_call;
|
||||
} tester;
|
||||
|
||||
void
|
||||
document (char *xml)
|
||||
{
|
||||
tester.nr++;
|
||||
tester.xml = xml;
|
||||
tester.nr_hook = 0;
|
||||
}
|
||||
|
||||
void
|
||||
hook (iksFilterHook *hk)
|
||||
{
|
||||
tester.hook[tester.nr_hook++] = hk;
|
||||
}
|
||||
|
||||
void
|
||||
debug (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("Filter test %d:\n", tester.nr);
|
||||
if (tester.nr_hook) {
|
||||
puts ("Expected hook order:");
|
||||
for (i = 0; i < tester.nr_hook; i++) {
|
||||
printf (" ");
|
||||
tester.hook[i] (NULL, NULL);
|
||||
}
|
||||
} else {
|
||||
puts("No hooks expected.");
|
||||
}
|
||||
if (tester.nr_call) {
|
||||
puts ("Hook order:");
|
||||
for (i = 0; i < tester.nr_call; i++) {
|
||||
printf (" ");
|
||||
tester.call[i] (NULL, NULL);
|
||||
}
|
||||
} else {
|
||||
puts("No hooks called.");
|
||||
}
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
test (void)
|
||||
{
|
||||
iksparser *prs;
|
||||
iks *x;
|
||||
int i;
|
||||
|
||||
tester.nr_call = 0;
|
||||
|
||||
prs = iks_dom_new (&x);
|
||||
iks_parse (prs, tester.xml, strlen (tester.xml), 1);
|
||||
iks_parser_delete (prs);
|
||||
iks_filter_packet (tester.f, iks_packet (x));
|
||||
iks_delete (x);
|
||||
|
||||
if (tester.nr_call != tester.nr_hook) debug ();
|
||||
for (i = 0; i < tester.nr_hook; i++) {
|
||||
if (tester.call[i] != tester.hook[i]) debug ();
|
||||
}
|
||||
}
|
||||
|
||||
#define DEBUG(x) if (NULL == pak) { puts ( (x) ); return IKS_FILTER_PASS; }
|
||||
|
||||
int
|
||||
on_msg (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_msg");
|
||||
assert (IKS_PAK_MESSAGE == pak->type);
|
||||
tester.call[tester.nr_call++] = on_msg;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_iq (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_iq");
|
||||
assert (IKS_PAK_IQ == pak->type);
|
||||
tester.call[tester.nr_call++] = on_iq;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_iq_result (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_iq_result");
|
||||
assert (IKS_PAK_IQ == pak->type);
|
||||
assert (IKS_TYPE_RESULT == pak->subtype);
|
||||
tester.call[tester.nr_call++] = on_iq_result;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_iq_result_id_auth (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_iq_result_id_auth");
|
||||
assert (IKS_PAK_IQ == pak->type);
|
||||
assert (IKS_TYPE_RESULT == pak->subtype);
|
||||
assert (iks_strcmp (pak->id, "auth") == 0);
|
||||
tester.call[tester.nr_call++] = on_iq_result_id_auth;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_id_auth (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_id_auth");
|
||||
assert (iks_strcmp (pak->id, "auth") == 0);
|
||||
tester.call[tester.nr_call++] = on_id_auth;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_from_patrician (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_from_patrician");
|
||||
assert (iks_strcmp (pak->from->partial, "patrician@morpork.gov") == 0);
|
||||
tester.call[tester.nr_call++] = on_from_patrician;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_msg_chat_from_patrician (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_msg_chat_from_patrician");
|
||||
assert (pak->type == IKS_PAK_MESSAGE);
|
||||
assert (pak->subtype == IKS_TYPE_CHAT);
|
||||
assert (iks_strcmp (pak->from->partial, "patrician@morpork.gov") == 0);
|
||||
tester.call[tester.nr_call++] = on_msg_chat_from_patrician;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_id_albatros (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_id_albatros");
|
||||
assert (iks_strcmp (pak->id, "albatros") == 0);
|
||||
tester.call[tester.nr_call++] = on_id_albatros;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
on_from_dean (void *user_data, ikspak *pak)
|
||||
{
|
||||
DEBUG ("on_from_dean");
|
||||
assert (iks_strcmp (pak->from->partial, "dean@unseen.edu") == 0);
|
||||
tester.call[tester.nr_call++] = on_from_dean;
|
||||
return IKS_FILTER_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
tester.f = iks_filter_new ();
|
||||
iks_filter_add_rule (tester.f, on_msg, 0,
|
||||
IKS_RULE_TYPE, IKS_PAK_MESSAGE,
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_iq, 0,
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ,
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_iq_result, 0,
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_iq_result_id_auth, 0,
|
||||
IKS_RULE_TYPE, IKS_PAK_IQ,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
|
||||
IKS_RULE_ID, "auth",
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_id_auth, 0,
|
||||
IKS_RULE_ID, "auth",
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_from_dean, 0,
|
||||
IKS_RULE_FROM_PARTIAL, "dean@unseen.edu",
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_from_patrician, 0,
|
||||
IKS_RULE_FROM_PARTIAL, "patrician@morpork.gov",
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_msg_chat_from_patrician, 0,
|
||||
IKS_RULE_TYPE, IKS_PAK_MESSAGE,
|
||||
IKS_RULE_SUBTYPE, IKS_TYPE_CHAT,
|
||||
IKS_RULE_FROM_PARTIAL, "patrician@morpork.gov",
|
||||
IKS_RULE_DONE);
|
||||
iks_filter_add_rule (tester.f, on_id_albatros, 0,
|
||||
IKS_RULE_ID, "albatros",
|
||||
IKS_RULE_DONE);
|
||||
|
||||
document ("<message from='dean@unseen.edu' id='1234'><body>Born to Rune.</body></message>");
|
||||
hook (on_from_dean);
|
||||
hook (on_msg);
|
||||
test ();
|
||||
|
||||
document ("<presence from='librarian@unseen.edu' show='away'/>");
|
||||
test ();
|
||||
|
||||
document ("<message from='rincewind@unseen.edu' type='chat' id='albatros'><body>yaaargh</body></message>");
|
||||
hook (on_id_albatros);
|
||||
hook (on_msg);
|
||||
test ();
|
||||
|
||||
document ("<iq type='get' from='rincewind@unseen.edu'><query xmlns='jabber:time'/></iq>");
|
||||
hook (on_iq);
|
||||
test ();
|
||||
|
||||
document ("<message from='patrician@morpork.gov'><body>so you admit it?</body></message>");
|
||||
hook (on_from_patrician);
|
||||
hook (on_msg);
|
||||
test ();
|
||||
|
||||
document ("<iq type='result' from='rincewind@unseen.edu'><query xmlns='jabber:version'><name>cabbar</name><version>1.0</version></query></iq>");
|
||||
hook (on_iq_result);
|
||||
hook (on_iq);
|
||||
test ();
|
||||
|
||||
document ("<presence from='dean@unseen.edu/psi' type='unavailable'/>");
|
||||
hook (on_from_dean);
|
||||
test ();
|
||||
|
||||
document ("<message from='patrician@morpork.gov' type='chat' id='albatros'><body>hmm</body></message>");
|
||||
hook (on_id_albatros);
|
||||
hook (on_msg_chat_from_patrician);
|
||||
hook (on_from_patrician);
|
||||
hook (on_msg);
|
||||
test ();
|
||||
|
||||
document ("<iq type='result' id='auth'/>");
|
||||
hook (on_iq_result_id_auth);
|
||||
hook (on_id_auth);
|
||||
hook (on_iq_result);
|
||||
hook (on_iq);
|
||||
test ();
|
||||
|
||||
iks_filter_delete (tester.f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
static char xml[] =
|
||||
"<iq type='result' to='ydobon@jabber.org'><query xmlns='jabber:iq:version'>"
|
||||
"<name>TestClient</name><os>SuxOS 2000</os><version><stable solidity='rock'/>"
|
||||
"1.2.0 patchlevel 2</version></query></iq>";
|
||||
iks *x, *y, *z;
|
||||
char *t;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
x = iks_new ("iq");
|
||||
iks_insert_attrib (x, "type", "resultypo");
|
||||
iks_insert_attrib (x, "type", "result");
|
||||
iks_insert_attrib (x, "to", "ydobon@jabber.org");
|
||||
y = iks_new_within ("query", iks_stack (x));
|
||||
iks_insert_cdata (iks_insert (y, "name"), "TestClient", 10);
|
||||
iks_insert_cdata (iks_insert (y, "os"), "SuxOS", 0);
|
||||
z = iks_insert (y, "version");
|
||||
iks_insert (z, "stable");
|
||||
iks_insert_cdata (z, "1.2", 3);
|
||||
iks_insert_cdata (z, ".0 patchlevel 2", 0);
|
||||
iks_insert_node (x, y);
|
||||
z = iks_find (y, "os");
|
||||
iks_insert_attrib (z, "error", "yes");
|
||||
iks_insert_attrib (z, "error", NULL);
|
||||
iks_insert_cdata (z, " 2000", 5);
|
||||
z = iks_next (z);
|
||||
z = iks_find (z, "stable");
|
||||
iks_insert_attrib (z, "solidity", "rock");
|
||||
z = iks_parent (iks_parent (z));
|
||||
iks_insert_attrib (z, "xmlns", "jabber:iq:version");
|
||||
|
||||
t = iks_string (iks_stack (x), x);
|
||||
if(!t || strcmp(t, xml) != 0) {
|
||||
printf("Result: %s\n", t);
|
||||
printf("Expected: %s\n", xml);
|
||||
return 1;
|
||||
}
|
||||
iks_delete(x);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
struct align_test { char a; double b; };
|
||||
#define DEFAULT_ALIGNMENT ((size_t) ((char *) &((struct align_test *) 0)->b - (char *) 0))
|
||||
#define ALIGN_MASK ( DEFAULT_ALIGNMENT - 1 )
|
||||
|
||||
const char buf[] = "1234567890abcdefghijklmnopqrstuv";
|
||||
|
||||
void
|
||||
test_stack (int cs)
|
||||
{
|
||||
ikstack *s;
|
||||
char *mem, *old;
|
||||
int i;
|
||||
|
||||
s = iks_stack_new (cs, cs);
|
||||
old = NULL;
|
||||
for (i = 0; i < strlen (buf); i++) {
|
||||
iks_stack_strdup (s, buf, i);
|
||||
mem = iks_stack_alloc (s, i);
|
||||
if (((unsigned long) mem) & ALIGN_MASK) {
|
||||
printf ("ikstack bug, addr %p should be a multiply of %d\n",
|
||||
mem, DEFAULT_ALIGNMENT);
|
||||
exit (1);
|
||||
}
|
||||
memset (mem, 'x', i);
|
||||
old = iks_stack_strcat (s, old, 0, buf + i, 1);
|
||||
}
|
||||
if (strcmp (old, buf) != 0) {
|
||||
printf ("ikstack strcat bug:\nExpected: %s\n Result: %s\n", buf, old);
|
||||
exit (1);
|
||||
}
|
||||
iks_stack_delete (s);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
test_stack (0);
|
||||
test_stack (16);
|
||||
test_stack (237);
|
||||
test_stack (1024);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
ikstack *my_stack;
|
||||
|
||||
void
|
||||
print_id (iksid *id)
|
||||
{
|
||||
printf (" Full: [%s]\n Partial: [%s]\n User: [%s]\n Server: [%s]\n Resource: [%s]\n",
|
||||
id->full, id->partial, id->user, id->server, id->resource);
|
||||
}
|
||||
|
||||
#define BUG(x) { print_id ( (x) ); exit (1); }
|
||||
|
||||
void
|
||||
test_id (char *id, char *partial, char *user, char *server, char *resource)
|
||||
{
|
||||
iksid *a;
|
||||
|
||||
a = iks_id_new (my_stack, id);
|
||||
if ((a->partial || partial) && iks_strcmp (a->partial, partial) != 0) BUG(a);
|
||||
if ((a->user || user) && iks_strcmp (a->user, user) != 0) BUG(a);
|
||||
if ((a->server || server) && iks_strcmp (a->server, server) != 0) BUG(a);
|
||||
if ((a->resource || resource) && iks_strcmp (a->resource, resource) != 0) BUG(a);
|
||||
}
|
||||
|
||||
void
|
||||
test_cmp (char *stra, char *strb, int parts, int diff)
|
||||
{
|
||||
iksid *a, *b;
|
||||
|
||||
a = iks_id_new (my_stack, stra);
|
||||
b = iks_id_new (my_stack, strb);
|
||||
if (diff != iks_id_cmp (a, b, parts)) exit (1);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
my_stack = iks_stack_new (1024, 1024);
|
||||
|
||||
test_id ("jabber:madcat@jabber.org/cabbar", "madcat@jabber.org", "madcat", "jabber.org", "cabbar");
|
||||
test_id ("bob@silent.org", "bob@silent.org", "bob", "silent.org", NULL);
|
||||
|
||||
test_cmp ("dante@jabber.org/hell", "dante@jabber.org/heaven", IKS_ID_PARTIAL, 0);
|
||||
test_cmp ("madcat@jabber.org/cabbar", "madcat@jabber.org/jabberx", IKS_ID_FULL, IKS_ID_RESOURCE);
|
||||
test_cmp ("dean@unseen.edu/pda", "librarian@unseen.edu/jabberx", IKS_ID_FULL, IKS_ID_USER | IKS_ID_RESOURCE);
|
||||
test_cmp ("patrician@morpork.gov/gabber", "cohen@guild.org/gsm", IKS_ID_FULL, IKS_ID_FULL);
|
||||
test_cmp ("peter@family.com", "peter@family.com/clam", IKS_ID_PARTIAL, 0);
|
||||
|
||||
iks_stack_delete (my_stack);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2004 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
struct lala {
|
||||
char *str;
|
||||
char *hash;
|
||||
} known_hashes[] = {
|
||||
{ "abc", "900150983cd24fb0d6963f7d28e17f72" },
|
||||
{ "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
||||
"57edf4a22be3c955ac49da2e2107b67a" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
int i = 0;
|
||||
char buf[33];
|
||||
|
||||
while (known_hashes[i].str) {
|
||||
iks_md5 (known_hashes[i].str, buf);
|
||||
if (strcmp (buf, known_hashes[i].hash) != 0) {
|
||||
printf("MD5 hash of \"%s\"\n", known_hashes[i].str);
|
||||
printf(" Result: %s\n", buf);
|
||||
printf(" Expected: %s\n", known_hashes[i].hash);
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
struct element_s {
|
||||
struct element_s *next;
|
||||
enum ikstype type;
|
||||
|
||||
enum ikstagtype tag;
|
||||
char *name;
|
||||
int nr_atts;
|
||||
char *atts[10];
|
||||
char *vals[10];
|
||||
|
||||
char *cdata;
|
||||
int len;
|
||||
};
|
||||
|
||||
struct {
|
||||
char *doc;
|
||||
int len;
|
||||
struct element_s *elements;
|
||||
struct element_s *last_element;
|
||||
struct element_s *cur;
|
||||
int nr_tests;
|
||||
int nr_cur;
|
||||
int blocksize;
|
||||
} tester;
|
||||
|
||||
void
|
||||
document (char *xml)
|
||||
{
|
||||
if (tester.elements) {
|
||||
struct element_s *tmp;
|
||||
for (; tester.elements; tester.elements = tmp) {
|
||||
tmp = tester.elements->next;
|
||||
free (tester.elements);
|
||||
}
|
||||
}
|
||||
tester.doc = xml;
|
||||
tester.len = strlen (xml);
|
||||
tester.elements = NULL;
|
||||
tester.last_element = NULL;
|
||||
tester.nr_tests++;
|
||||
}
|
||||
|
||||
void
|
||||
element (enum ikstype type, ...)
|
||||
{
|
||||
struct element_s *el;
|
||||
va_list ap;
|
||||
char *tmp;
|
||||
|
||||
el = malloc (sizeof (struct element_s));
|
||||
memset (el, 0, sizeof (struct element_s));
|
||||
el->type = type;
|
||||
|
||||
va_start (ap, type);
|
||||
switch (type) {
|
||||
case IKS_TAG:
|
||||
el->tag = va_arg (ap, int);
|
||||
el->name = va_arg (ap, char*);
|
||||
if (IKS_CLOSE == el->tag) break;
|
||||
while (1) {
|
||||
tmp = va_arg (ap, char*);
|
||||
if (tmp) {
|
||||
el->atts[el->nr_atts] = tmp;
|
||||
el->vals[el->nr_atts] = va_arg (ap, char*);
|
||||
el->nr_atts++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IKS_CDATA:
|
||||
tmp = va_arg (ap, char*);
|
||||
el->cdata = tmp;
|
||||
el->len = strlen (tmp);
|
||||
break;
|
||||
case IKS_NONE:
|
||||
case IKS_ATTRIBUTE:
|
||||
puts ("invalid element() call");
|
||||
exit (1);
|
||||
}
|
||||
va_end (ap);
|
||||
|
||||
if (NULL == tester.elements) tester.elements = el;
|
||||
if (tester.last_element) tester.last_element->next = el;
|
||||
tester.last_element = el;
|
||||
}
|
||||
|
||||
#define PRINT_TEST printf ("Sax test %d, blocksize %d, element %d:\n", tester.nr_tests, tester.blocksize, tester.nr_cur)
|
||||
#define NEXT_ELEM { tester.cur = tester.cur->next; tester.nr_cur++; }
|
||||
|
||||
void
|
||||
debug_tag (enum ikstagtype type, char *name, char **atts)
|
||||
{
|
||||
int i;
|
||||
|
||||
PRINT_TEST;
|
||||
if (tester.cur && tester.cur->type == IKS_TAG) {
|
||||
switch (tester.cur->tag) {
|
||||
case IKS_OPEN:
|
||||
printf (" Expecting tag <%s>\n", tester.cur->name);
|
||||
break;
|
||||
case IKS_CLOSE:
|
||||
printf (" Expecting tag </%s>\n", tester.cur->name);
|
||||
break;
|
||||
case IKS_SINGLE:
|
||||
printf (" Expecting tag <%s/>\n", tester.cur->name);
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < tester.cur->nr_atts; i++) {
|
||||
printf (" %s='%s'\n", tester.cur->atts[i], tester.cur->vals[i]);
|
||||
}
|
||||
} else {
|
||||
printf (" Not expecting a tag here.\n");
|
||||
}
|
||||
switch (type) {
|
||||
case IKS_OPEN:
|
||||
printf (" Got tag <%s>\n", name);
|
||||
break;
|
||||
case IKS_CLOSE:
|
||||
printf (" Got tag </%s>\n", name);
|
||||
break;
|
||||
case IKS_SINGLE:
|
||||
printf (" Got tag <%s/>\n", name);
|
||||
break;
|
||||
}
|
||||
i = 0;
|
||||
while (atts && atts[i]) {
|
||||
printf (" %s='%s'\n", atts[i], atts[i+1]);
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
#define TAG_FAIL { debug_tag (type,name,atts); exit (1); }
|
||||
|
||||
int
|
||||
tagHook (void *udata, char *name, char **atts, int type)
|
||||
{
|
||||
int nr, i, flag;
|
||||
|
||||
if (!tester.cur) TAG_FAIL;
|
||||
if (tester.cur->type != IKS_TAG) TAG_FAIL;
|
||||
if (tester.cur->tag != type) TAG_FAIL;
|
||||
if (iks_strcmp (tester.cur->name, name) != 0) TAG_FAIL;
|
||||
if (!atts && tester.cur->nr_atts > 0) TAG_FAIL;
|
||||
if (atts && tester.cur->nr_atts == 0) TAG_FAIL;
|
||||
|
||||
nr = tester.cur->nr_atts;
|
||||
while (nr) {
|
||||
flag = 0;
|
||||
for (i = 0;atts[i]; i+= 2) {
|
||||
if (iks_strcmp (atts[i], tester.cur->atts[nr-1]) == 0 && iks_strcmp (atts[i+1], tester.cur->vals[nr-1]) == 0) {
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag == 0) TAG_FAIL;
|
||||
nr--;
|
||||
}
|
||||
|
||||
NEXT_ELEM;
|
||||
return IKS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
debug_cdata (char *data, size_t len, int pos)
|
||||
{
|
||||
int i;
|
||||
|
||||
PRINT_TEST;
|
||||
if (tester.cur && tester.cur->type == IKS_CDATA)
|
||||
printf (" Expecting cdata [%s]\n", tester.cur->cdata);
|
||||
else
|
||||
printf (" Not expecting cdata here\n");
|
||||
printf (" Got cdata [");
|
||||
for (i = 0; i < len; i++) putchar (data[i]);
|
||||
printf ("] at the pos %d.\n", pos);
|
||||
}
|
||||
|
||||
#define CDATA_FAIL { debug_cdata (data, len, pos); exit (1); }
|
||||
|
||||
int
|
||||
cdataHook (void *udata, char *data, size_t len)
|
||||
{
|
||||
static int pos = 0;
|
||||
|
||||
if (!tester.cur) CDATA_FAIL;
|
||||
if (tester.cur->type != IKS_CDATA) CDATA_FAIL;
|
||||
if (iks_strncmp (tester.cur->cdata + pos, data, len) != 0) CDATA_FAIL;
|
||||
pos += len;
|
||||
if (pos > tester.cur->len) CDATA_FAIL;
|
||||
if (pos == tester.cur->len) {
|
||||
pos = 0;
|
||||
NEXT_ELEM;
|
||||
}
|
||||
return IKS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
test_size (int blocksize)
|
||||
{
|
||||
enum ikserror err;
|
||||
iksparser *prs;
|
||||
int i, len;
|
||||
|
||||
tester.cur = tester.elements;
|
||||
tester.nr_cur = 1;
|
||||
tester.blocksize = blocksize;
|
||||
len = tester.len;
|
||||
|
||||
prs = iks_sax_new (NULL, tagHook, cdataHook);
|
||||
i = 0;
|
||||
if (0 == blocksize) blocksize = len;
|
||||
while (i < len) {
|
||||
if (i + blocksize > len) blocksize = len - i;
|
||||
err = iks_parse (prs, tester.doc + i, blocksize, 0);
|
||||
switch (err) {
|
||||
case IKS_OK:
|
||||
break;
|
||||
case IKS_NOMEM:
|
||||
exit (1);
|
||||
case IKS_BADXML:
|
||||
PRINT_TEST;
|
||||
printf ("Invalid xml at byte %ld in\n[%s]\n", iks_nr_bytes (prs), tester.doc);
|
||||
exit (1);
|
||||
case IKS_HOOK:
|
||||
exit (1);
|
||||
}
|
||||
i += blocksize;
|
||||
}
|
||||
if (tester.cur) exit (1);
|
||||
iks_parser_delete (prs);
|
||||
}
|
||||
|
||||
void
|
||||
test (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < tester.len; i++) {
|
||||
test_size (i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_bad (int badbyte)
|
||||
{
|
||||
iksparser *p;
|
||||
enum ikserror err;
|
||||
|
||||
p = iks_sax_new (NULL, NULL, NULL);
|
||||
err = iks_parse (p, tester.doc, tester.len, 1);
|
||||
switch (err) {
|
||||
case IKS_OK:
|
||||
break;
|
||||
case IKS_NOMEM:
|
||||
exit (1);
|
||||
case IKS_BADXML:
|
||||
if (iks_nr_bytes (p) == badbyte) return;
|
||||
break;
|
||||
case IKS_HOOK:
|
||||
exit (1);
|
||||
}
|
||||
printf ("Sax test %d:\n", tester.nr_tests);
|
||||
printf ("Expected bad byte %d, got %ld in\n[%s]\n", badbyte, iks_nr_bytes (p), tester.doc);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
document ("<lonely/>");
|
||||
element (IKS_TAG, IKS_SINGLE, "lonely", 0);
|
||||
test ();
|
||||
|
||||
document ("<?xml version='1.0'?><parent><child/><child/>child</parent>");
|
||||
element (IKS_TAG, IKS_OPEN, "parent", 0);
|
||||
element (IKS_TAG, IKS_SINGLE, "child", 0);
|
||||
element (IKS_TAG, IKS_SINGLE, "child", 0);
|
||||
element (IKS_CDATA, "child");
|
||||
element (IKS_TAG, IKS_CLOSE, "parent");
|
||||
test ();
|
||||
|
||||
document ("<mytag abc='123' id=\"XC72\"></mytag>");
|
||||
element (IKS_TAG, IKS_OPEN, "mytag", "abc", "123", "id", "XC72", 0);
|
||||
element (IKS_TAG, IKS_CLOSE, "mytag");
|
||||
test ();
|
||||
|
||||
document ("<body>I'm fixing parser&tester for "<" and ">" chars.</body>");
|
||||
element (IKS_TAG, IKS_OPEN, "body", 0);
|
||||
element (IKS_CDATA, "I'm fixing parser&tester for \"<\" and \">\" chars.");
|
||||
element (IKS_TAG, IKS_CLOSE, "body");
|
||||
test ();
|
||||
|
||||
document ("<tag a='1' b='2' c='3' d='4' e='5' f='6' g='7' id='xyz9'><sub></sub></tag>");
|
||||
element (IKS_TAG, IKS_OPEN, "tag", "a", "1", "b", "2", "c", "3", "d", "4", "e", "5", "f", "6", "g", "7", "id", "xyz9", 0);
|
||||
element (IKS_TAG, IKS_OPEN, "sub", 0);
|
||||
element (IKS_TAG, IKS_CLOSE, "sub");
|
||||
element (IKS_TAG, IKS_CLOSE, "tag");
|
||||
test ();
|
||||
|
||||
document ("<item url='http://jabber.org'><!-- little comment -->Jabber Site</item>");
|
||||
element (IKS_TAG, IKS_OPEN, "item", "url", "http://jabber.org", 0);
|
||||
element (IKS_CDATA, "Jabber Site");
|
||||
element (IKS_TAG, IKS_CLOSE, "item");
|
||||
test ();
|
||||
|
||||
document ("<index><!-- <item> - tag has no childs --><item name='lala' page='42'/></index>");
|
||||
element (IKS_TAG, IKS_OPEN, "index", 0);
|
||||
element (IKS_TAG, IKS_SINGLE, "item", "name", "lala", "page", "42", 0);
|
||||
element (IKS_TAG, IKS_CLOSE, "index");
|
||||
test ();
|
||||
|
||||
document ("<ka>1234<![CDATA[ <ka> lala ] ]] ]]] ]]>4321</ka>");
|
||||
element (IKS_TAG, IKS_OPEN, "ka", 0);
|
||||
element (IKS_CDATA, "1234 <ka> lala ] ]] ]]] 4321");
|
||||
element (IKS_TAG, IKS_CLOSE, "ka");
|
||||
test ();
|
||||
|
||||
document ("<test><standalone be='happy'/>abcd<br/><escape></test>");
|
||||
element (IKS_TAG, IKS_OPEN, "test", 0);
|
||||
element (IKS_TAG, IKS_SINGLE, "standalone", "be", "happy", 0);
|
||||
element (IKS_CDATA, "abcd");
|
||||
element (IKS_TAG, IKS_SINGLE, "br", 0);
|
||||
element (IKS_CDATA, "<escape>");
|
||||
element (IKS_TAG, IKS_CLOSE, "test");
|
||||
test ();
|
||||
|
||||
document ("<a><b>john&mary<c><d e='f' g='123456' h='madcat' klm='nop'/></c></b></a>");
|
||||
element (IKS_TAG, IKS_OPEN, "a", 0);
|
||||
element (IKS_TAG, IKS_OPEN, "b", 0);
|
||||
element (IKS_CDATA, "john&mary");
|
||||
element (IKS_TAG, IKS_OPEN, "c", 0);
|
||||
element (IKS_TAG, IKS_SINGLE, "d", "e", "f", "g", "123456", "h", "madcat", "klm", "nop", 0);
|
||||
element (IKS_TAG, IKS_CLOSE, "c", 0);
|
||||
element (IKS_TAG, IKS_CLOSE, "b", 0);
|
||||
element (IKS_TAG, IKS_CLOSE, "a", 0);
|
||||
test ();
|
||||
|
||||
document ("<test>\xFF</test>");
|
||||
test_bad (6);
|
||||
|
||||
document ("<t\0></t>");
|
||||
tester.len = 8;
|
||||
test_bad (2);
|
||||
|
||||
document ("<a><b/><c></c/></a>");
|
||||
test_bad (13);
|
||||
|
||||
document ("<e><!-- -- --></e>");
|
||||
test_bad (10);
|
||||
|
||||
document ("<g><test a='123'/ b='lala'></g>");
|
||||
test_bad (17);
|
||||
|
||||
document ("<ha><!-- <lala> --><!- comment -></ha>");
|
||||
test_bad (22);
|
||||
|
||||
document ("<lol><<></lol>");
|
||||
test_bad (16);
|
||||
|
||||
document ("<a>\xC0\x80</a>");
|
||||
test_bad (3);
|
||||
|
||||
document ("<\x8F\x85></\x8F\x85>");
|
||||
test_bad (1);
|
||||
|
||||
document ("<utf8>\xC1\x80<br/>\xED\x95\x9C\xEA\xB5\xAD\xEC\x96\xB4<err>\xC1\x65</err></utf8>");
|
||||
test_bad (28);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/* iksemel (XML parser for Jabber)
|
||||
** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
|
||||
** This code is free software; you can redistribute it and/or
|
||||
** modify it under the terms of GNU Lesser General Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "iksemel.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
struct lala {
|
||||
char *str;
|
||||
char *hash;
|
||||
} known_hashes[] = {
|
||||
{ "abc", "a9993e364706816aba3e25717850c26c9cd0d89d" },
|
||||
{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
||||
"84983e441c3bd26ebaae4aa1f95129e5e54670f1" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
int i = 0;
|
||||
char buf[42];
|
||||
|
||||
while (known_hashes[i].str) {
|
||||
iks_sha (known_hashes[i].str, buf);
|
||||
if (strcmp (buf, known_hashes[i].hash) != 0) {
|
||||
printf("SHA1 hash of \"%s\"\n", known_hashes[i].str);
|
||||
printf(" Result: %s\n", buf);
|
||||
printf(" Expected: %s\n", known_hashes[i].hash);
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user