summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorunknown <unknown@unknown>2009-10-23 04:29:39 +0000
committerunknown <unknown@unknown>2009-10-23 04:29:39 +0000
commitddf5c42f67757000d6ec7686b92a667c2a252dca (patch)
treee070b352fab4b285b7a4ea547d0cbfff9b7fb4d1 /tools
downloadiksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.tar.gz
iksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.tar.xz
iksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.zip
Imported from iksemel-1.3.tar.gz.
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am18
-rw-r--r--tools/Makefile.in476
-rw-r--r--tools/hash.c144
-rw-r--r--tools/ikslint.c283
-rw-r--r--tools/iksperf.c316
-rw-r--r--tools/iksroster.c379
-rw-r--r--tools/perf.c84
-rw-r--r--tools/perf.h10
8 files changed, 1710 insertions, 0 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 0000000..ab81e66
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,18 @@
+##
+## Process this file with automake to produce Makefile.in
+##
+
+INCLUDES = -I$(top_srcdir)/include
+
+bin_PROGRAMS = ikslint iksroster iksperf
+
+noinst_HEADERS = perf.h
+
+ikslint_LDADD = $(top_builddir)/src/libiksemel.la
+ikslint_SOURCES = ikslint.c hash.c
+
+iksroster_LDADD = $(top_builddir)/src/libiksemel.la
+iksroster_SOURCES = iksroster.c
+
+iksperf_LDADD = $(top_builddir)/src/libiksemel.la
+iksperf_SOURCES = iksperf.c perf.c
diff --git a/tools/Makefile.in b/tools/Makefile.in
new file mode 100644
index 0000000..d933c44
--- /dev/null
+++ b/tools/Makefile.in
@@ -0,0 +1,476 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = ikslint$(EXEEXT) iksroster$(EXEEXT) iksperf$(EXEEXT)
+subdir = tools
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_ikslint_OBJECTS = ikslint.$(OBJEXT) hash.$(OBJEXT)
+ikslint_OBJECTS = $(am_ikslint_OBJECTS)
+ikslint_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_iksperf_OBJECTS = iksperf.$(OBJEXT) perf.$(OBJEXT)
+iksperf_OBJECTS = $(am_iksperf_OBJECTS)
+iksperf_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_iksroster_OBJECTS = iksroster.$(OBJEXT)
+iksroster_OBJECTS = $(am_iksroster_OBJECTS)
+iksroster_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(ikslint_SOURCES) $(iksperf_SOURCES) $(iksroster_SOURCES)
+DIST_SOURCES = $(ikslint_SOURCES) $(iksperf_SOURCES) \
+ $(iksroster_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DO_POSIX_FALSE = @DO_POSIX_FALSE@
+DO_POSIX_TRUE = @DO_POSIX_TRUE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
+LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
+LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+INCLUDES = -I$(top_srcdir)/include
+noinst_HEADERS = perf.h
+ikslint_LDADD = $(top_builddir)/src/libiksemel.la
+ikslint_SOURCES = ikslint.c hash.c
+iksroster_LDADD = $(top_builddir)/src/libiksemel.la
+iksroster_SOURCES = iksroster.c
+iksperf_LDADD = $(top_builddir)/src/libiksemel.la
+iksperf_SOURCES = iksperf.c perf.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tools/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+ikslint$(EXEEXT): $(ikslint_OBJECTS) $(ikslint_DEPENDENCIES)
+ @rm -f ikslint$(EXEEXT)
+ $(LINK) $(ikslint_LDFLAGS) $(ikslint_OBJECTS) $(ikslint_LDADD) $(LIBS)
+iksperf$(EXEEXT): $(iksperf_OBJECTS) $(iksperf_DEPENDENCIES)
+ @rm -f iksperf$(EXEEXT)
+ $(LINK) $(iksperf_LDFLAGS) $(iksperf_OBJECTS) $(iksperf_LDADD) $(LIBS)
+iksroster$(EXEEXT): $(iksroster_OBJECTS) $(iksroster_DEPENDENCIES)
+ @rm -f iksroster$(EXEEXT)
+ $(LINK) $(iksroster_LDFLAGS) $(iksroster_OBJECTS) $(iksroster_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ikslint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iksperf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iksroster.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perf.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binPROGRAMS install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binPROGRAMS uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tools/hash.c b/tools/hash.c
new file mode 100644
index 0000000..8ba83a0
--- /dev/null
+++ b/tools/hash.c
@@ -0,0 +1,144 @@
+/* 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 "common.h"
+#include "iksemel.h"
+
+static unsigned int
+hash_str (const char *str)
+{
+ const char *p;
+ unsigned int h = 0;
+
+ for (p = str; *p != '\0'; p++) {
+ h = ( h << 5 ) - h + *p;
+ }
+ return h;
+}
+
+struct item {
+ char *name;
+ unsigned int count;
+ struct item *next;
+};
+
+struct hash_s {
+ struct item **table;
+ unsigned int size;
+ unsigned int count;
+ ikstack *s;
+};
+
+typedef struct hash_s hash;
+
+hash *
+hash_new (unsigned int table_size)
+{
+ hash *h;
+
+ h = malloc (sizeof (struct hash_s));
+ if (!h) return NULL;
+ h->table = calloc (sizeof (struct item *), table_size);
+ if (!h->table) {
+ free (h);
+ return NULL;
+ }
+ h->s = iks_stack_new (sizeof (hash) * 128, 8192);
+ if (!h->s) {
+ free (h->table);
+ free (h);
+ return NULL;
+ }
+ h->size = table_size;
+ h->count = 0;
+
+ return h;
+}
+
+char *
+hash_insert (hash *h, const char *name)
+{
+ struct item *t, *p;
+ unsigned int val;
+
+ val = hash_str (name) % h->size;
+ h->count++;
+
+ for (t = h->table[val]; t; t = t->next) {
+ if (strcmp (t->name, name) == 0)
+ break;
+ }
+ if (NULL == t) {
+ t = iks_stack_alloc (h->s, sizeof (struct item));
+ if (!t) return NULL;
+ t->name = iks_stack_strdup (h->s, name, 0);
+ t->count = 0;
+ t->next = NULL;
+ p = h->table[val];
+ if (!p) {
+ h->table[val] = t;
+ } else {
+ while (1) {
+ if (p->next == NULL) {
+ p->next = t;
+ break;
+ }
+ p = p->next;
+ }
+ }
+ }
+ t->count++;
+
+ return t->name;
+}
+
+static int
+my_cmp (const void *a, const void *b)
+{
+ unsigned int c1, c2;
+
+ c1 = (*(struct item **)a)->count;
+ c2 = (*(struct item **)b)->count;
+
+ if (c1 > c2)
+ return -1;
+ else if (c1 == c2)
+ return 0;
+ else
+ return 1;
+}
+
+void
+hash_print (hash *h, char *title_fmt, char *line_fmt)
+{
+ struct item **tags, *t;
+ unsigned int i = 0, pos = 0;
+
+ tags = calloc (sizeof (struct tag *), h->count);
+
+ for (; i < h->size; i ++) {
+ for (t = h->table[i]; t; t = t->next) {
+ tags[pos++] = t;
+ }
+ }
+
+ qsort (tags, pos, sizeof (struct item *), my_cmp);
+
+ printf (title_fmt, pos);
+ for (i = 0; i < pos; i++) {
+ printf (line_fmt, tags[i]->name, tags[i]->count);
+ }
+
+ free (tags);
+}
+
+void
+hash_delete (hash *h)
+{
+ iks_stack_delete (h->s);
+ free (h->table);
+ free (h);
+}
diff --git a/tools/ikslint.c b/tools/ikslint.c
new file mode 100644
index 0000000..0b655d2
--- /dev/null
+++ b/tools/ikslint.c
@@ -0,0 +1,283 @@
+/* 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 "common.h"
+#include "iksemel.h"
+
+struct hash_s;
+typedef struct hash_s hash;
+
+hash *hash_new (unsigned int table_size);
+char *hash_insert (hash *table, const char *name);
+void hash_print (hash *h, char *title_fmt, char *line_fmt);
+void hash_delete (hash *table);
+
+#include <sys/stat.h>
+
+#ifdef HAVE_GETOPT_LONG
+#include <getopt.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+static struct option longopts[] = {
+ { "stats", 0, 0, 's' },
+ { "histogram", 0, 0, 't' },
+ { "help", 0, 0, 'h' },
+ { "version", 0, 0, 'V' },
+ { 0, 0, 0, 0 }
+};
+#endif
+
+static char *shortopts = "sthV";
+
+static void
+print_usage (void)
+{
+ puts ("Usage: ikslint [OPTIONS] FILE\n"
+ "This tool checks the well-formedness of an XML document.\n"
+ " -s, --stats Print statistics.\n"
+ " -t, --histogram Print tag histogram.\n"
+ " -h, --help Print this text and exit.\n"
+ " -V, --version Print version and exit.\n"
+#ifndef HAVE_GETOPT_LONG
+ "(long options are not supported on your system)\n"
+#endif
+ "Report bugs to <iksemel-dev@jabberstudio.org>.");
+}
+
+/* calculate and print statistics */
+int lint_pr_stats = 0;
+
+/* print tag histogram */
+int lint_pr_hist = 0;
+
+hash *tag_table;
+
+char **tag_list;
+int tag_size, tag_pos;
+
+void
+tag_push (const char *name)
+{
+ if (!tag_list) {
+ tag_size = 128;
+ tag_list = malloc (sizeof (char *) * tag_size);
+ if (!tag_list) exit (2);
+ }
+ tag_list[tag_pos] = hash_insert (tag_table, name);
+ if (!tag_list[tag_pos]) exit (2);
+ tag_pos++;
+ if (tag_pos == tag_size) {
+ char **tmp;
+ tmp = malloc (sizeof (char *) * tag_size * 2);
+ if (!tmp) exit (2);
+ memcpy (tmp, tag_list, sizeof (char *) * tag_size);
+ free (tag_list);
+ tag_list = tmp;
+ tag_size *= 2;
+ }
+}
+
+char *
+tag_pull (void)
+{
+ tag_pos--;
+ return tag_list[tag_pos];
+}
+
+struct stats {
+ unsigned int level;
+ unsigned int max_depth;
+ unsigned int nr_tags;
+ unsigned int nr_stags;
+ unsigned int cdata_size;
+};
+
+int
+tagHook (void *udata, char *name, char **atts, int type)
+{
+ struct stats *st = (struct stats *) udata;
+ char *tmp;
+
+ switch (type) {
+ case IKS_OPEN:
+ tag_push (name);
+ st->level++;
+ if (st->level > st->max_depth) st->max_depth = st->level;
+ break;
+ case IKS_CLOSE:
+ tmp = tag_pull ();
+ if (iks_strcmp (tmp, name) != 0) {
+ fprintf (stderr, "Tag mismatch, expecting '%s', got '%s'.\n",
+ tmp, name);
+ return IKS_HOOK;
+ }
+ st->level--;
+ st->nr_tags++;
+ break;
+ case IKS_SINGLE:
+ if (NULL == hash_insert (tag_table, name)) exit (2);
+ st->nr_stags++;
+ break;
+ }
+ return IKS_OK;
+}
+
+int
+cdataHook (void *udata, char *data, size_t len)
+{
+ struct stats *st = (struct stats *) udata;
+
+ st->cdata_size += len;
+ return IKS_OK;
+}
+
+void
+check_file (char *fname)
+{
+ iksparser *prs;
+ struct stats st;
+ FILE *f;
+ char *buf;
+ struct stat fs;
+ size_t sz, blk, ret, pos;
+ enum ikserror err;
+ int done;
+
+ memset (&st, 0, sizeof (struct stats));
+ prs = iks_sax_new (&st, tagHook, cdataHook);
+ if (NULL == prs) exit (2);
+
+ if (fname) {
+ if (stat (fname, &fs) != 0) {
+ fprintf (stderr, "Cannot access file '%s'.\n", fname);
+ exit (1);
+ }
+ sz = fs.st_size;
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
+ blk = fs.st_blksize;
+#else
+ blk = 4096;
+#endif
+ f = fopen (fname, "r");
+ if (!f) {
+ fprintf (stderr, "Cannot open file '%s'.\n", fname);
+ exit (1);
+ }
+ buf = malloc (blk);
+ if (!buf) {
+ fclose (f);
+ fprintf (stderr, "Cannot allocate %d bytes.\n", blk);
+ exit (2);
+ }
+ } else {
+ f = stdin;
+ blk = 4096;
+ sz = 0;
+ buf = malloc (blk);
+ if (!buf) exit (2);
+ }
+
+ tag_table = hash_new (367);
+ if (!tag_table) exit (2);
+
+ pos = 0;
+ done = 0;
+ while (0 == done) {
+ ret = fread (buf, 1, blk, f);
+ pos += ret;
+ if (feof (f)) {
+ done = 1;
+ } else {
+ if (ret != blk) {
+ if (fname)
+ fprintf (stderr, "Read error in file '%s'.\n", fname);
+ else
+ fprintf (stderr, "Read error in stream.\n");
+ exit (1);
+ }
+ }
+ err = iks_parse (prs, buf, ret, done);
+ switch (err) {
+ case IKS_OK:
+ break;
+ case IKS_NOMEM:
+ exit (2);
+ case IKS_BADXML:
+ if (fname)
+ fprintf (stderr, "Invalid xml at byte %ld, line %ld in file '%s'.\n",
+ iks_nr_bytes (prs), iks_nr_lines (prs), fname);
+ else
+ fprintf (stderr, "Invalid xml at byte %ld, line %ld in stream.\n",
+ iks_nr_bytes (prs), iks_nr_lines (prs));
+ exit (1);
+ case IKS_HOOK:
+ if (fname)
+ fprintf (stderr, "Byte %ld, line %ld in file '%s'.\n",
+ iks_nr_bytes (prs), iks_nr_lines (prs), fname);
+ else
+ fprintf (stderr, "Byte %ld, line %ld in stream.\n",
+ iks_nr_bytes (prs), iks_nr_lines (prs));
+ exit (1);
+ }
+ }
+
+ free (buf);
+ if (fname) fclose (f);
+
+ if (fname && (lint_pr_stats || lint_pr_hist)) {
+ printf ("File '%s' (%d bytes):\n", fname, sz);
+ }
+ if (lint_pr_stats) {
+ printf ("Tags: %d pairs, %d single, %d max depth.\n", st.nr_tags, st.nr_stags, st.max_depth);
+ printf ("Total size of character data: %d bytes.\n", st.cdata_size);
+ }
+ if (lint_pr_hist) {
+ hash_print (tag_table,
+ "Histogram of %d unique tags:\n",
+ "<%s> %d times.\n");
+ }
+ hash_delete (tag_table);
+
+ iks_parser_delete (prs);
+}
+
+int
+main (int argc, char *argv[])
+{
+ int c;
+
+#ifdef HAVE_GETOPT_LONG
+ int i;
+ while ((c = getopt_long (argc, argv, shortopts, longopts, &i)) != -1) {
+#else
+ while ((c = getopt (argc, argv, shortopts)) != -1) {
+#endif
+ switch (c) {
+ case 's':
+ lint_pr_stats = 1;
+ break;
+ case 't':
+ lint_pr_hist = 1;
+ break;
+ case 'h':
+ print_usage ();
+ exit (0);
+ case 'V':
+ puts ("ikslint (iksemel) "VERSION);
+ exit (0);
+ }
+ }
+ if (!argv[optind]) {
+ check_file (NULL);
+ } else {
+ for (; optind < argc; optind++) {
+ check_file (argv[optind]);
+ }
+ }
+
+ return 0;
+}
diff --git a/tools/iksperf.c b/tools/iksperf.c
new file mode 100644
index 0000000..81e98ad
--- /dev/null
+++ b/tools/iksperf.c
@@ -0,0 +1,316 @@
+/* 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 "common.h"
+#include "iksemel.h"
+#include "perf.h"
+
+#include <sys/stat.h>
+
+#ifdef HAVE_GETOPT_LONG
+#include <getopt.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+static struct option longopts[] = {
+ { "all", 0, 0, 'a' },
+ { "sax", 0, 0, 's' },
+ { "dom", 0, 0, 'd' },
+ { "serialize", 0, 0, 'e' },
+ { "sha1", 0, 0, '1' },
+ { "block", required_argument, 0, 'b' },
+ { "memdbg", 0, 0, 'm' },
+ { "help", 0, 0, 'h' },
+ { "version", 0, 0, 'V' },
+ { 0, 0, 0, 0 }
+};
+#endif
+
+static char *shortopts = "asde1b:mhV";
+
+static void
+print_usage (void)
+{
+ puts ("Usage: iksperf [OPTIONS] FILE\n"
+ "This tool measures the performance of the iksemel library.\n"
+ " -a, --all Make all tests.\n"
+ " -s, --sax Sax test.\n"
+ " -d, --dom Tree generating test.\n"
+ " -e, --serialize Tree serializing test.\n"
+ " -1, --sha1 SHA1 hashing test.\n"
+ " -b, --block SIZE Parse the file in SIZE byte blocks.\n"
+ " -m, --memdbg Trace malloc and free calls.\n"
+ " -h, --help Print this text and exit.\n"
+ " -V, --version Print version and exit.\n"
+#ifndef HAVE_GETOPT_LONG
+ "(long options are not supported on your system)\n"
+#endif
+ "Report bugs to <iksemel-dev@jabberstudio.org>.");
+}
+
+/* if not 0, file is parsed in block_size byte blocks */
+int block_size;
+
+char *load_file (const char *fname, int *sizeptr)
+{
+ FILE *f;
+ char *buf;
+ struct stat fs;
+ size_t size, ret;
+
+ if (stat (fname, &fs) != 0) {
+ fprintf (stderr, "Cannot access file '%s'.\n", fname);
+ exit (1);
+ }
+ size = fs.st_size;
+
+ printf ("Test file '%s' (%d bytes):\n", fname, size);
+
+ f = fopen (fname, "rb");
+ if (!f) {
+ fprintf (stderr, "Cannot open file.\n");
+ exit (1);
+ }
+
+ buf = malloc (size);
+ if (!buf) {
+ fclose (f);
+ fprintf (stderr, "Cannot allocate %d bytes for buffer.\n", size);
+ exit (2);
+ }
+
+ ret = fread (buf, 1, size, f);
+ if (ret < size) {
+ fprintf (stderr, "Read error in file.\n");
+ exit (1);
+ }
+
+ *sizeptr = size;
+ fclose (f);
+ return buf;
+}
+
+/* stats */
+int sax_tag;
+int sax_cdata;
+
+int
+tagHook (void *udata, char *name, char **atts, int type)
+{
+ ++sax_tag;
+ return IKS_OK;
+}
+
+int
+cdataHook (void *udata, char *data, size_t len)
+{
+ ++sax_cdata;
+ return IKS_OK;
+}
+
+void
+sax_test (char *buf, int len)
+{
+ unsigned long time;
+ iksparser *prs;
+ int bs, i, err;
+
+ bs = block_size;
+ if (0 == bs) bs = len;
+ sax_tag = 0;
+ sax_cdata = 0;
+
+ t_reset ();
+
+ prs = iks_sax_new (NULL, tagHook, cdataHook);
+ i = 0;
+ while (i < len) {
+ if (i + bs > len) bs = len - i;
+ err = iks_parse (prs, buf + i, bs, 0);
+ switch (err) {
+ case IKS_OK:
+ break;
+ case IKS_NOMEM:
+ exit (2);
+ case IKS_BADXML:
+ fprintf (stderr, "Invalid xml at byte %ld, line %ld\n",
+ iks_nr_bytes (prs), iks_nr_lines (prs));
+ exit (1);
+ case IKS_HOOK:
+ exit (1);
+ }
+ i += bs;
+ }
+
+ time = t_elapsed ();
+
+ printf ("SAX: parsing took %ld milliseconds.\n", time);
+ printf ("SAX: tag hook called %d, cdata hook called %d times.\n", sax_tag, sax_cdata);
+
+ iks_parser_delete (prs);
+}
+
+void dom_test (char *buf, int len)
+{
+ int bs, i, err;
+ iksparser *prs;
+ unsigned long time;
+ iks *x;
+ size_t allocated, used;
+
+ bs = block_size;
+ if (0 == bs) bs = len;
+
+ t_reset ();
+
+ prs = iks_dom_new (&x);
+ iks_set_size_hint (prs, len);
+ i = 0;
+ while (i < len) {
+ if (i + bs > len) bs = len - i;
+ err = iks_parse (prs, buf + i, bs, 0);
+ switch (err) {
+ case IKS_OK:
+ break;
+ case IKS_NOMEM:
+ exit (2);
+ case IKS_BADXML:
+ fprintf (stderr, "Invalid xml at byte %ld, line %ld\n",
+ iks_nr_bytes (prs), iks_nr_lines (prs));
+ exit (1);
+ case IKS_HOOK:
+ exit (1);
+ }
+ i += bs;
+ }
+
+ time = t_elapsed ();
+ iks_stack_stat (iks_stack (x), &allocated, &used);
+
+ printf ("DOM: parsing and building the tree took %ld milliseconds.\n", time);
+ printf ("DOM: ikstack: %d bytes allocated, %d bytes used.\n", allocated, used);
+
+ t_reset ();
+ iks_delete (x);
+ time = t_elapsed ();
+ printf ("DOM: deleting the tree took %ld milliseconds.\n", time);
+
+ iks_parser_delete (prs);
+}
+
+void
+serialize_test (char *buf, int len)
+{
+ unsigned long time;
+ iks *x;
+ iksparser *prs;
+ char *xml;
+ int err;
+
+ prs = iks_dom_new (&x);
+ err = iks_parse (prs, buf, len, 1);
+ switch (err) {
+ case IKS_OK:
+ break;
+ case IKS_NOMEM:
+ exit (2);
+ case IKS_BADXML:
+ fprintf (stderr, "Invalid xml at byte %ld, line %ld\n",
+ iks_nr_bytes (prs), iks_nr_lines (prs));
+ exit (1);
+ case IKS_HOOK:
+ exit (1);
+ }
+ iks_parser_delete (prs);
+
+ t_reset ();
+
+ xml = iks_string (iks_stack (x), x);
+
+ time = t_elapsed ();
+
+ printf ("Serialize: serializing the tree took %ld milliseconds.\n", time);
+
+ iks_delete (x);
+}
+
+void
+sha_test (char *buf, int len)
+{
+ unsigned long time;
+ iksha *s;
+ char out[41];
+
+ t_reset ();
+
+ s = iks_sha_new ();
+ iks_sha_hash (s, buf, len, 1);
+ iks_sha_print (s, out);
+ out[40] = '\0';
+ iks_sha_delete (s);
+
+ time = t_elapsed ();
+
+ printf ("SHA: hashing took %ld milliseconds.\n", time);
+ printf ("SHA: hash [%s]\n", out);
+}
+
+int
+main (int argc, char *argv[])
+{
+ int test_type = 0;
+ int c;
+
+#ifdef HAVE_GETOPT_LONG
+ int i;
+ while ((c = getopt_long (argc, argv, shortopts, longopts, &i)) != -1) {
+#else
+ while ((c = getopt (argc, argv, shortopts)) != -1) {
+#endif
+ switch (c) {
+ case 'a':
+ test_type = 0xffff;
+ break;
+ case 's':
+ test_type |= 1;
+ break;
+ case 'd':
+ test_type |= 2;
+ break;
+ case 'e':
+ test_type |= 4;
+ break;
+ case '1':
+ test_type |= 8;
+ break;
+ case 'b':
+ block_size = atoi (optarg);
+ break;
+ case 'm':
+ m_trace ();
+ break;
+ case 'h':
+ print_usage ();
+ exit (0);
+ case 'V':
+ puts ("iksperf (iksemel) "VERSION);
+ exit (0);
+ }
+ }
+ for (; optind < argc; optind++) {
+ char *buf;
+ int len;
+
+ buf = load_file (argv[optind], &len);
+ if (test_type & 1) sax_test (buf, len);
+ if (test_type == 0 || test_type & 2) dom_test (buf, len);
+ if (test_type & 4) serialize_test (buf, len);
+ if (test_type & 8) sha_test (buf, len);
+ free (buf);
+ }
+
+ return 0;
+}
diff --git a/tools/iksroster.c b/tools/iksroster.c
new file mode 100644
index 0000000..144f3de
--- /dev/null
+++ b/tools/iksroster.c
@@ -0,0 +1,379 @@
+/* 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 "common.h"
+#include "iksemel.h"
+
+#ifdef HAVE_GETOPT_LONG
+#include <getopt.h>
+#endif
+
+#ifdef _WIN32
+#include <winsock.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+static struct option longopts[] = {
+ { "backup", required_argument, 0, 'b' },
+ { "restore", required_argument, 0, 'r' },
+ { "file", required_argument, 0, 'f' },
+ { "timeout", required_argument, 0, 't' },
+ { "secure", 0, 0, 's' },
+ { "sasl", 0, 0, 'a' },
+ { "log", 0, 0, 'l' },
+ { "help", 0, 0, 'h' },
+ { "version", 0, 0, 'V' },
+ { 0, 0, 0, 0 }
+};
+#endif
+
+static char *shortopts = "b:r:f:t:salhV";
+
+static void
+print_usage (void)
+{
+ puts ("Usage: iksroster [OPTIONS]\n"
+ "This is a backup tool for your jabber roster.\n"
+ " -b, --backup=JID Download roster from the server.\n"
+ " -r, --restore=JID Upload roster to the server.\n"
+ " -f, --file=FILE Load/Save roster to this file.\n"
+ " -t, --timeout=SECS Set network timeout.\n"
+ " -s, --secure Use encrypted connection.\n"
+ " -a, --sasl Use SASL authentication.\n"
+ " -l, --log Print exchanged xml data.\n"
+ " -h, --help Print this text and exit.\n"
+ " -V, --version Print version and exit.\n"
+#ifndef HAVE_GETOPT_LONG
+ "(long options are not supported on your system)\n"
+#endif
+#ifndef HAVE_GNUTLS
+ "(secure connections are not supported on your system)\n"
+#endif
+ "Report bugs to <iksemel-dev@jabberstudio.org>.");
+}
+
+/* stuff we keep per session */
+struct session {
+ iksparser *prs;
+ iksid *acc;
+ char *pass;
+ int features;
+ int authorized;
+ int counter;
+ int set_roster;
+ int job_done;
+};
+
+/* precious roster we'll deal with */
+iks *my_roster;
+
+/* out packet filter */
+iksfilter *my_filter;
+
+/* connection time outs if nothing comes for this much seconds */
+int opt_timeout = 30;
+
+/* connection flags */
+int opt_use_tls;
+int opt_use_sasl;
+int opt_log;
+
+void
+j_error (char *msg)
+{
+ fprintf (stderr, "iksroster: %s\n", msg);
+ exit (2);
+}
+
+int
+on_result (struct session *sess, ikspak *pak)
+{
+ iks *x;
+
+ if (sess->set_roster == 0) {
+ x = iks_make_iq (IKS_TYPE_GET, IKS_NS_ROSTER);
+ iks_insert_attrib (x, "id", "roster");
+ iks_send (sess->prs, x);
+ iks_delete (x);
+ } else {
+ iks_insert_attrib (my_roster, "type", "set");
+ iks_send (sess->prs, my_roster);
+ }
+ return IKS_FILTER_EAT;
+}
+
+int
+on_stream (struct session *sess, int type, iks *node)
+{
+ sess->counter = opt_timeout;
+
+ switch (type) {
+ case IKS_NODE_START:
+ if (opt_use_tls && !iks_is_secure (sess->prs)) {
+ iks_start_tls (sess->prs);
+ break;
+ }
+ if (!opt_use_sasl) {
+ iks *x;
+
+ x = iks_make_auth (sess->acc, sess->pass, iks_find_attrib (node, "id"));
+ iks_insert_attrib (x, "id", "auth");
+ iks_send (sess->prs, x);
+ iks_delete (x);
+ }
+ break;
+
+ case IKS_NODE_NORMAL:
+ if (strcmp ("stream:features", iks_name (node)) == 0) {
+ sess->features = iks_stream_features (node);
+ if (opt_use_sasl) {
+ if (opt_use_tls && !iks_is_secure (sess->prs)) break;
+ if (sess->authorized) {
+ iks *t;
+ if (sess->features & IKS_STREAM_BIND) {
+ t = iks_make_resource_bind (sess->acc);
+ iks_send (sess->prs, t);
+ iks_delete (t);
+ }
+ if (sess->features & IKS_STREAM_SESSION) {
+ t = iks_make_session ();
+ iks_insert_attrib (t, "id", "auth");
+ iks_send (sess->prs, t);
+ iks_delete (t);
+ }
+ } else {
+ if (sess->features & IKS_STREAM_SASL_MD5)
+ iks_start_sasl (sess->prs, IKS_SASL_DIGEST_MD5, sess->acc->user, sess->pass);
+ else if (sess->features & IKS_STREAM_SASL_PLAIN)
+ iks_start_sasl (sess->prs, IKS_SASL_PLAIN, sess->acc->user, sess->pass);
+ }
+ }
+ } else if (strcmp ("failure", iks_name (node)) == 0) {
+ j_error ("sasl authentication failed");
+ } else if (strcmp ("success", iks_name (node)) == 0) {
+ sess->authorized = 1;
+ iks_send_header (sess->prs, sess->acc->server);
+ } else {
+ ikspak *pak;
+
+ pak = iks_packet (node);
+ iks_filter_packet (my_filter, pak);
+ if (sess->job_done == 1) return IKS_HOOK;
+ }
+ break;
+
+ case IKS_NODE_STOP:
+ j_error ("server disconnected");
+
+ case IKS_NODE_ERROR:
+ j_error ("stream error");
+ }
+
+ if (node) iks_delete (node);
+ return IKS_OK;
+}
+
+int
+on_error (void *user_data, ikspak *pak)
+{
+ j_error ("authorization failed");
+ return IKS_FILTER_EAT;
+}
+
+int
+on_roster (struct session *sess, ikspak *pak)
+{
+ my_roster = pak->x;
+ sess->job_done = 1;
+ return IKS_FILTER_EAT;
+}
+
+void
+on_log (struct session *sess, const char *data, size_t size, int is_incoming)
+{
+ if (iks_is_secure (sess->prs)) fprintf (stderr, "Sec");
+ if (is_incoming) fprintf (stderr, "RECV"); else fprintf (stderr, "SEND");
+ fprintf (stderr, "[%s]\n", data);
+}
+
+void
+j_setup_filter (struct session *sess)
+{
+ if (my_filter) iks_filter_delete (my_filter);
+ my_filter = iks_filter_new ();
+ iks_filter_add_rule (my_filter, (iksFilterHook *) on_result, sess,
+ IKS_RULE_TYPE, IKS_PAK_IQ,
+ IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
+ IKS_RULE_ID, "auth",
+ IKS_RULE_DONE);
+ iks_filter_add_rule (my_filter, on_error, sess,
+ IKS_RULE_TYPE, IKS_PAK_IQ,
+ IKS_RULE_SUBTYPE, IKS_TYPE_ERROR,
+ IKS_RULE_ID, "auth",
+ IKS_RULE_DONE);
+ iks_filter_add_rule (my_filter, (iksFilterHook *) on_roster, sess,
+ IKS_RULE_TYPE, IKS_PAK_IQ,
+ IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
+ IKS_RULE_ID, "roster",
+ IKS_RULE_DONE);
+}
+
+void
+j_connect (char *jabber_id, char *pass, int set_roster)
+{
+ struct session sess;
+ int e;
+
+ memset (&sess, 0, sizeof (sess));
+ sess.prs = iks_stream_new (IKS_NS_CLIENT, &sess, (iksStreamHook *) on_stream);
+ if (opt_log) iks_set_log_hook (sess.prs, (iksLogHook *) on_log);
+ sess.acc = iks_id_new (iks_parser_stack (sess.prs), jabber_id);
+ if (NULL == sess.acc->resource) {
+ /* user gave no resource name, use the default */
+ char *tmp;
+ tmp = iks_malloc (strlen (sess.acc->user) + strlen (sess.acc->server) + 9 + 3);
+ sprintf (tmp, "%s@%s/%s", sess.acc->user, sess.acc->server, "iksroster");
+ sess.acc = iks_id_new (iks_parser_stack (sess.prs), tmp);
+ iks_free (tmp);
+ }
+ sess.pass = pass;
+ sess.set_roster = set_roster;
+
+ j_setup_filter (&sess);
+
+ e = iks_connect_tcp (sess.prs, sess.acc->server, IKS_JABBER_PORT);
+ switch (e) {
+ case IKS_OK:
+ break;
+ case IKS_NET_NODNS:
+ j_error ("hostname lookup failed");
+ case IKS_NET_NOCONN:
+ j_error ("connection failed");
+ default:
+ j_error ("io error");
+ }
+
+ sess.counter = opt_timeout;
+ while (1) {
+ e = iks_recv (sess.prs, 1);
+ if (IKS_HOOK == e) break;
+ if (IKS_NET_TLSFAIL == e) j_error ("tls handshake failed");
+ if (IKS_OK != e) j_error ("io error");
+ sess.counter--;
+ if (sess.counter == 0) j_error ("network timeout");
+ }
+ iks_parser_delete (sess.prs);
+}
+
+int
+main (int argc, char *argv[])
+{
+ char *from = NULL;
+ char *to = NULL;
+ char *file = NULL;
+ char from_pw[128], to_pw[128];
+ int c;
+#ifdef HAVE_GETOPT_LONG
+ int i;
+
+ while ((c = getopt_long (argc, argv, shortopts, longopts, &i)) != -1) {
+#else
+ while ((c = getopt (argc, argv, shortopts)) != -1) {
+#endif
+ switch (c) {
+ case 'b':
+ from = optarg;
+ printf ("Password for %s: ", optarg);
+ fflush (stdout);
+ fgets (from_pw, 127, stdin);
+ strtok (from_pw, "\r\n");
+ break;
+ case 'r':
+ to = optarg;
+ printf ("Password for %s: ", optarg);
+ fflush (stdout);
+ fgets (to_pw, 127, stdin);
+ strtok (to_pw, "\r\n");
+ break;
+ case 'f':
+ file = strdup (optarg);
+ break;
+ case 't':
+ opt_timeout = atoi (optarg);
+ if (opt_timeout < 10) opt_timeout = 10;
+ break;
+ case 's':
+ if (!iks_has_tls ()) {
+ puts ("Cannot make encrypted connections.");
+ puts ("iksemel library is not compiled with GnuTLS support.");
+ exit (1);
+ }
+ opt_use_tls = 1;
+ break;
+ case 'a':
+ opt_use_sasl = 1;
+ break;
+ case 'l':
+ opt_log = 1;
+ break;
+ case 'h':
+ print_usage ();
+ exit (0);
+ case 'V':
+ puts ("iksroster (iksemel) "VERSION);
+ exit (0);
+ }
+ }
+ if (from == NULL && to == NULL) {
+ puts ("What I'm supposed to do?");
+ print_usage ();
+ exit (1);
+ }
+ if (to && (from == NULL && file == NULL)) {
+ puts ("Store which roster?");
+ print_usage ();
+ exit (1);
+ }
+
+#ifdef _WIN32
+ WSADATA wsaData;
+ WSAStartup (MAKEWORD (1,1), &wsaData);
+#endif
+
+ if (from) {
+ j_connect (from, from_pw, 0);
+ if (file) {
+ switch (iks_save (file, my_roster)) {
+ case IKS_OK:
+ break;
+ case IKS_FILE_NOACCESS:
+ j_error ("cannot write to file");
+ default:
+ j_error ("file io error");
+ }
+ }
+ } else {
+ switch (iks_load (file, &my_roster)) {
+ case IKS_OK:
+ break;
+ case IKS_FILE_NOFILE:
+ j_error ("file not found");
+ case IKS_FILE_NOACCESS:
+ j_error ("cannot read file");
+ default:
+ j_error ("file io error");
+ }
+ }
+ if (to) {
+ j_connect (to, to_pw, 1);
+ }
+
+#ifdef _WIN32
+ WSACleanup ();
+#endif
+
+ return 0;
+}
diff --git a/tools/perf.c b/tools/perf.c
new file mode 100644
index 0000000..ac5a848
--- /dev/null
+++ b/tools/perf.c
@@ -0,0 +1,84 @@
+/* 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>
+#ifdef _WIN32
+#include <windows.h>
+#include <limits.h>
+#else
+#include <sys/time.h>
+#endif
+
+#include "iksemel.h"
+
+/* timing functions */
+
+#ifdef _WIN32
+static DWORD start_tv;
+
+void
+t_reset (void)
+{
+ start_tv = GetTickCount ();
+}
+
+unsigned long
+t_elapsed (void)
+{
+ DWORD end_tv;
+
+ end_tv = GetTickCount ();
+ if (end_tv < start_tv)
+ return UINT_MAX - (start_tv - end_tv - 1);
+ else
+ return end_tv - start_tv;
+}
+
+#else
+static struct timeval start_tv;
+
+void
+t_reset (void)
+{
+ gettimeofday (&start_tv, NULL);
+}
+
+unsigned long
+t_elapsed (void)
+{
+ unsigned long msec;
+ struct timeval cur_tv;
+
+ gettimeofday (&cur_tv, NULL);
+ msec = (cur_tv.tv_sec * 1000) + (cur_tv.tv_usec / 1000);
+ msec -= (start_tv.tv_sec * 1000) + (start_tv.tv_usec / 1000);
+ return msec;
+}
+#endif
+
+/* memory functions */
+
+static void *
+m_malloc (size_t size)
+{
+ void *ptr = malloc (size);
+ printf ("MEM: malloc (%d) => %p\n", size, ptr);
+ return ptr;
+}
+
+static void
+m_free (void *ptr)
+{
+ printf ("MEM: free (%p)\n", ptr);
+}
+
+void
+m_trace (void)
+{
+ iks_set_mem_funcs (m_malloc, m_free);
+}
diff --git a/tools/perf.h b/tools/perf.h
new file mode 100644
index 0000000..04f1638
--- /dev/null
+++ b/tools/perf.h
@@ -0,0 +1,10 @@
+/* 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.
+*/
+
+void t_reset (void);
+unsigned long t_elapsed (void);
+
+void m_trace (void);