summaryrefslogtreecommitdiffstats
path: root/debian/pilot-link/pilot-link-0.12.5-dfsg/tests
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-09-11 14:38:47 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-09-11 14:38:47 +0900
commit884c8093d63402a1ad0b502244b791e3c6782be3 (patch)
treea600d4ab0d431a2bdfe4c15b70df43c14fbd8dd0 /debian/pilot-link/pilot-link-0.12.5-dfsg/tests
parent14e1aa2006796f147f3f4811fb908a6b01e79253 (diff)
downloadextra-dependencies-884c8093d63402a1ad0b502244b791e3c6782be3.tar.gz
extra-dependencies-884c8093d63402a1ad0b502244b791e3c6782be3.zip
Added debian extra dependency packages.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'debian/pilot-link/pilot-link-0.12.5-dfsg/tests')
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.am52
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.in746
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/calendardb-test.c320
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/contactsdb-test.c378
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/dlp-test.c724
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/locationdb-test.c192
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/packers.c1775
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/versamail-test.c222
-rw-r--r--debian/pilot-link/pilot-link-0.12.5-dfsg/tests/vfs-test.c461
9 files changed, 4870 insertions, 0 deletions
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.am b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.am
new file mode 100644
index 00000000..8c787bc0
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.am
@@ -0,0 +1,52 @@
+INCLUDES = \
+ -I../include \
+ -I$(top_srcdir)/include \
+ $(POPT_INCLUDES)
+
+noinst_PROGRAMS = \
+ calendardb-test \
+ locationdb-test \
+ contactsdb-test \
+ dlp-test \
+ versamail-test \
+ vfs-test
+
+calendardb_test_SOURCES = \
+ calendardb-test.c
+calendardb_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+locationdb_test_SOURCES = \
+ locationdb-test.c
+locationdb_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+contactsdb_test_SOURCES = \
+ contactsdb-test.c
+contactsdb_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+dlp_test_SOURCES = \
+ dlp-test.c
+dlp_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+vfs_test_SOURCES = \
+ vfs-test.c
+vfs_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+versamail_test_SOURCES = \
+ versamail-test.c
+versamail_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+check_PROGRAMS = \
+ packers
+
+packers_SOURCES = \
+ packers.c
+packers_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+TESTS = packers
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.in b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.in
new file mode 100644
index 00000000..c9ee2888
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/Makefile.in
@@ -0,0 +1,746 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+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@
+target_triplet = @target@
+noinst_PROGRAMS = calendardb-test$(EXEEXT) locationdb-test$(EXEEXT) \
+ contactsdb-test$(EXEEXT) dlp-test$(EXEEXT) \
+ versamail-test$(EXEEXT) vfs-test$(EXEEXT)
+check_PROGRAMS = packers$(EXEEXT)
+TESTS = packers$(EXEEXT)
+subdir = tests
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/bluez.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/python.m4 \
+ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/tcl.m4 \
+ $(top_srcdir)/m4/threads.m4 \
+ $(top_srcdir)/m4/vl_lib_readline.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h \
+ $(top_builddir)/include/pi-md5.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_calendardb_test_OBJECTS = calendardb-test.$(OBJEXT)
+calendardb_test_OBJECTS = $(am_calendardb_test_OBJECTS)
+calendardb_test_DEPENDENCIES = $(top_builddir)/libpisock/libpisock.la
+am_contactsdb_test_OBJECTS = contactsdb-test.$(OBJEXT)
+contactsdb_test_OBJECTS = $(am_contactsdb_test_OBJECTS)
+contactsdb_test_DEPENDENCIES = $(top_builddir)/libpisock/libpisock.la
+am_dlp_test_OBJECTS = dlp-test.$(OBJEXT)
+dlp_test_OBJECTS = $(am_dlp_test_OBJECTS)
+dlp_test_DEPENDENCIES = $(top_builddir)/libpisock/libpisock.la
+am_locationdb_test_OBJECTS = locationdb-test.$(OBJEXT)
+locationdb_test_OBJECTS = $(am_locationdb_test_OBJECTS)
+locationdb_test_DEPENDENCIES = $(top_builddir)/libpisock/libpisock.la
+am_packers_OBJECTS = packers.$(OBJEXT)
+packers_OBJECTS = $(am_packers_OBJECTS)
+packers_DEPENDENCIES = $(top_builddir)/libpisock/libpisock.la
+am_versamail_test_OBJECTS = versamail-test.$(OBJEXT)
+versamail_test_OBJECTS = $(am_versamail_test_OBJECTS)
+versamail_test_DEPENDENCIES = $(top_builddir)/libpisock/libpisock.la
+am_vfs_test_OBJECTS = vfs-test.$(OBJEXT)
+vfs_test_OBJECTS = $(am_vfs_test_OBJECTS)
+vfs_test_DEPENDENCIES = $(top_builddir)/libpisock/libpisock.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(calendardb_test_SOURCES) $(contactsdb_test_SOURCES) \
+ $(dlp_test_SOURCES) $(locationdb_test_SOURCES) \
+ $(packers_SOURCES) $(versamail_test_SOURCES) \
+ $(vfs_test_SOURCES)
+DIST_SOURCES = $(calendardb_test_SOURCES) $(contactsdb_test_SOURCES) \
+ $(dlp_test_SOURCES) $(locationdb_test_SOURCES) \
+ $(packers_SOURCES) $(versamail_test_SOURCES) \
+ $(vfs_test_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BLUEZ_CFLAGS = @BLUEZ_CFLAGS@
+BLUEZ_LIBS = @BLUEZ_LIBS@
+CAT_ENTRY_END = @CAT_ENTRY_END@
+CAT_ENTRY_START = @CAT_ENTRY_START@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DOCBOOK_ROOT = @DOCBOOK_ROOT@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+GREP = @GREP@
+ICONV_CFLAGS = @ICONV_CFLAGS@
+ICONV_LIBS = @ICONV_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAR = @JAR@
+JAVA = @JAVA@
+JAVABASE = @JAVABASE@
+JAVAC = @JAVAC@
+JAVA_VERSION = @JAVA_VERSION@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PIC_LIBS = @PIC_LIBS@
+PILOT_LINK_MAJOR = @PILOT_LINK_MAJOR@
+PILOT_LINK_MINOR = @PILOT_LINK_MINOR@
+PILOT_LINK_PATCH = @PILOT_LINK_PATCH@
+PILOT_LINK_VERS = @PILOT_LINK_VERS@
+PISOCK_AGE = @PISOCK_AGE@
+PISOCK_CURRENT = @PISOCK_CURRENT@
+PISOCK_REVISION = @PISOCK_REVISION@
+PISYNC_AGE = @PISYNC_AGE@
+PISYNC_CURRENT = @PISYNC_CURRENT@
+PISYNC_REVISION = @PISYNC_REVISION@
+PKG_CONFIG = @PKG_CONFIG@
+PNG_CFLAGS = @PNG_CFLAGS@
+PNG_LIBS = @PNG_LIBS@
+POPT_INCLUDES = @POPT_INCLUDES@
+POPT_LIBS = @POPT_LIBS@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_CFLAGS = @PYTHON_CFLAGS@
+PYTHON_H = @PYTHON_H@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+RL_LIBS = @RL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TCLSH_PROG = @TCLSH_PROG@
+TCL_BIN_DIR = @TCL_BIN_DIR@
+TCL_DEFS = @TCL_DEFS@
+TCL_EXTRA_CFLAGS = @TCL_EXTRA_CFLAGS@
+TCL_INCLUDES = @TCL_INCLUDES@
+TCL_LD_FLAGS = @TCL_LD_FLAGS@
+TCL_LIBS = @TCL_LIBS@
+TCL_LIB_FILE = @TCL_LIB_FILE@
+TCL_LIB_FLAG = @TCL_LIB_FLAG@
+TCL_LIB_SPEC = @TCL_LIB_SPEC@
+TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@
+TCL_SRC_DIR = @TCL_SRC_DIR@
+TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@
+TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@
+TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
+TCL_VERSION = @TCL_VERSION@
+VERSION = @VERSION@
+WISH_PROG = @WISH_PROG@
+XML_CATALOG = @XML_CATALOG@
+XSLTPROC = @XSLTPROC@
+XSLTPROC_FLAGS = @XSLTPROC_FLAGS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+usb_libs = @usb_libs@
+INCLUDES = \
+ -I../include \
+ -I$(top_srcdir)/include \
+ $(POPT_INCLUDES)
+
+calendardb_test_SOURCES = \
+ calendardb-test.c
+
+calendardb_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+locationdb_test_SOURCES = \
+ locationdb-test.c
+
+locationdb_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+contactsdb_test_SOURCES = \
+ contactsdb-test.c
+
+contactsdb_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+dlp_test_SOURCES = \
+ dlp-test.c
+
+dlp_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+vfs_test_SOURCES = \
+ vfs-test.c
+
+vfs_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+versamail_test_SOURCES = \
+ versamail-test.c
+
+versamail_test_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+packers_SOURCES = \
+ packers.c
+
+packers_LDADD = \
+ $(top_builddir)/libpisock/libpisock.la
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+calendardb-test$(EXEEXT): $(calendardb_test_OBJECTS) $(calendardb_test_DEPENDENCIES)
+ @rm -f calendardb-test$(EXEEXT)
+ $(LINK) $(calendardb_test_OBJECTS) $(calendardb_test_LDADD) $(LIBS)
+contactsdb-test$(EXEEXT): $(contactsdb_test_OBJECTS) $(contactsdb_test_DEPENDENCIES)
+ @rm -f contactsdb-test$(EXEEXT)
+ $(LINK) $(contactsdb_test_OBJECTS) $(contactsdb_test_LDADD) $(LIBS)
+dlp-test$(EXEEXT): $(dlp_test_OBJECTS) $(dlp_test_DEPENDENCIES)
+ @rm -f dlp-test$(EXEEXT)
+ $(LINK) $(dlp_test_OBJECTS) $(dlp_test_LDADD) $(LIBS)
+locationdb-test$(EXEEXT): $(locationdb_test_OBJECTS) $(locationdb_test_DEPENDENCIES)
+ @rm -f locationdb-test$(EXEEXT)
+ $(LINK) $(locationdb_test_OBJECTS) $(locationdb_test_LDADD) $(LIBS)
+packers$(EXEEXT): $(packers_OBJECTS) $(packers_DEPENDENCIES)
+ @rm -f packers$(EXEEXT)
+ $(LINK) $(packers_OBJECTS) $(packers_LDADD) $(LIBS)
+versamail-test$(EXEEXT): $(versamail_test_OBJECTS) $(versamail_test_DEPENDENCIES)
+ @rm -f versamail-test$(EXEEXT)
+ $(LINK) $(versamail_test_OBJECTS) $(versamail_test_LDADD) $(LIBS)
+vfs-test$(EXEEXT): $(vfs_test_OBJECTS) $(vfs_test_DEPENDENCIES)
+ @rm -f vfs-test$(EXEEXT)
+ $(LINK) $(vfs_test_OBJECTS) $(vfs_test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calendardb-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/contactsdb-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlp-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/locationdb-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packers.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/versamail-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vfs-test.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@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
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$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
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+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)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_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-checkPROGRAMS clean-generic clean-libtool \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libtool \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# 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/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/calendardb-test.c b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/calendardb-test.c
new file mode 100644
index 00000000..fe526c84
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/calendardb-test.c
@@ -0,0 +1,320 @@
+/*
+ * $Id: calendardb-test.c,v 1.3 2010-01-17 00:37:35 judd Exp $
+ *
+ * calendardb-test.c: Test code for calendar database
+
+ * (c) 2008, Jon Schewe
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include "pi-source.h"
+#include "pi-file.h"
+#include "pi-macros.h"
+#include "pi-calendar.h"
+
+/***********************************************************************
+ *
+ * Function: dump
+ *
+ * Summary: Dump data as requested by other functions
+ *
+ * Parameters: None
+ *
+ * Returns: Nothing
+ *
+ ***********************************************************************/
+static void dump(void *buf, int n)
+{
+ int ch,
+ i,
+ j;
+
+ if(NULL == buf) {
+ printf("Null buf\n");
+ return;
+ }
+
+ for (i = 0; i < n; i += 16) {
+ printf("%04x: ", i);
+ for (j = 0; j < 16; j++) {
+ if (i + j < n)
+ printf("%02x ",
+ ((unsigned char *) buf)[i + j]);
+ else
+ printf(" ");
+ }
+ printf(" ");
+ for (j = 0; j < 16 && i + j < n; j++) {
+ ch = ((unsigned char *) buf)[i + j] & 0x7f;
+ if (ch < ' ' || ch >= 0x7f)
+ putchar('.');
+ else
+ putchar(ch);
+ }
+ printf("\n");
+ }
+}
+
+/**
+ * Test parsing database.
+ */
+void parse(pi_file_t *pf)
+{
+ void *app_info;
+ size_t app_info_size;
+ int i;
+ CalendarAppInfo_t cab;
+ int result;
+ int nentries;
+ unsigned char *buf;
+ int attrs, cat;
+ size_t size;
+ recordid_t uid;
+ CalendarEvent_t appt;
+ int entnum;
+ pi_buffer_t *pi_buf;
+ pi_buffer_t *test;
+ char timeString[256];
+
+ pi_file_get_app_info(pf, &app_info, &app_info_size);
+ if (app_info == NULL) {
+ fprintf(stderr, "Unable to get app info\n");
+ return;
+ }
+ printf("Size of appinfo block: %d\n", (int)app_info_size);
+
+ // dump the appinfo
+ dump(app_info, app_info_size);
+
+ pi_buf = pi_buffer_new(0);
+ pi_buf->data = app_info;
+ pi_buf->used = app_info_size;
+ pi_buf->allocated = app_info_size;
+
+ result = unpack_CalendarAppInfo(&cab, pi_buf);
+ printf("unpack_CalendarAppInfo returned %d\n", result);
+
+ pi_buf->data=NULL;
+ pi_buf->used = 0;
+ pi_buf->allocated = 0;
+
+ result = pack_CalendarAppInfo(&cab, pi_buf);
+ printf("pack_CalendarAppInfo returned %d\n", result);
+
+ // dump the appinfo
+ dump(pi_buf->data, pi_buf->used);
+
+ pi_buffer_free(pi_buf);
+
+ /* print out the standard app info stuff and see if it's right */
+ /* not really useful for Calendar, all names are custom
+ for(i=0; i<16; ++i) {
+ printf("renamed[%d] = %d\n", i, cab.category.renamed[i]);
+ }
+ */
+
+ for(i=0; i<16; ++i) {
+ printf("Category %d is %s\n", i, cab.category.name[i]);
+ }
+
+ printf("Start of week is %d\n", cab.startOfWeek);
+
+ printf("Internal:\n");
+ dump(cab.internal, 18);
+
+ pi_file_get_entries(pf, &nentries);
+ printf("Number of entries: %d\n", nentries);
+
+ for (entnum = 0; entnum < nentries; entnum++) {
+ if (pi_file_read_record(pf, entnum, (void **) &buf, &size,
+ &attrs, &cat, &uid) < 0) {
+ printf("Error reading record number %d\n", entnum);
+ return;
+ }
+
+ /* Skip deleted records */
+ if ((attrs & dlpRecAttrDeleted)
+ || (attrs & dlpRecAttrArchived)) {
+ continue;
+ }
+
+ printf("original record %d:\n", entnum);
+ dump(buf, size);
+
+ pi_buf = pi_buffer_new(size);
+ pi_buffer_append(pi_buf, buf, size);
+
+ result = unpack_CalendarEvent(&appt, pi_buf, calendar_v1);
+ if(-1 == result) {
+ printf("Error unpacking record %d!\n", entnum);
+ }
+
+ printf("\tdescription: %s\n", appt.description);
+ if(NULL != appt.location) {
+ printf("\tLocation: %s\n", appt.location);
+ }
+
+ printf("\tis event: %d\n", appt.event);
+
+ result = strftime(timeString, 256, "%F %T %z", &(appt.begin));
+ if(0 == result) {
+ printf("Error begin time to string!");
+ } else {
+ printf("\tBegin: %s\n", timeString);
+ }
+ result = strftime(timeString, 256, "%F %T %z", &(appt.end));
+ if(0 == result) {
+ printf("Error end time to string!");
+ } else {
+ printf("\tEnd: %s\n", timeString);
+ }
+
+ printf("\tnote: %s\n", appt.note);
+
+ if(NULL != appt.tz) {
+ printf("\tTimezone name: %s\n", appt.tz->name);
+ printf("\t\tOffset from GMT: %d minutes\n", appt.tz->offset);
+ printf("\t\tDST observed: %d\n", appt.tz->dstObserved);
+ printf("\t\tDST start:\n");
+ printf("\t\t\tdayOfWeek: %d\n", appt.tz->dstStart.dayOfWeek);
+ printf("\t\t\tweekOfMonth: %d\n", appt.tz->dstStart.weekOfMonth);
+ printf("\t\t\tmonth: %d\n", appt.tz->dstStart.month);
+ printf("\t\tDST end:\n");
+ printf("\t\t\tdayOfWeek: %d\n", appt.tz->dstEnd.dayOfWeek);
+ printf("\t\t\tweekOfMonth: %d\n", appt.tz->dstEnd.weekOfMonth);
+ printf("\t\t\tmonth: %d\n", appt.tz->dstEnd.month);
+ }
+
+ /* now try and pack the record and see if we get the same data */
+ test = pi_buffer_new(0);
+ result = pack_CalendarEvent(&appt, test, calendar_v1);
+ if(result == -1) {
+ printf("Error packing record %d!\n", entnum);
+ } else {
+ printf("packed record\n");
+ dump(test->data, test->used);
+
+ if(pi_buf->used != test->used) {
+ int i;
+ printf("Error: Different record sizes unpack: %ld pack: %ld last byte unpack: 0x%02X pack: 0x%02X\n", pi_buf->used, test->used, pi_buf->data[pi_buf->used-1], test->data[test->used-1]);
+ for(i=0; i<pi_buf->used; ++i) {
+ if(pi_buf->data[i] != test->data[i]) {
+ printf("Error: Byte %d is different unpack: 0x%02X pack: 0x%02X\n", i, pi_buf->data[i], test->data[i]);
+ }
+ }
+ }
+ }
+
+ /*printf("event: %d\n", appt.event);*/
+
+ /*
+ if (appt.untimed() == false) {
+ cout << "Begin Time: " << asctime(appt.
+ beginTime());
+ cout << "End Time: " << asctime(appt.endTime());
+ } else {
+ cout << "Untimed event" << endl;
+ }
+
+ if (appt.hasAlarm()) {
+ cout << "The alarm is set to go off " << appt.
+ advance() << " ";
+
+ switch (appt.advanceUnits()) {
+ case appointment_t::minutes:
+ cout << "minutes";
+ break;
+ case appointment_t::hours:
+ cout << "hours";
+ break;
+ case appointment_t::days:
+ cout << "days";
+ default:
+ cout << "(internal error)";
+ }
+
+ cout << " before the event" << endl;
+ } else
+ cout << "There is not an alarm set for this event"
+ << endl;
+
+ if (appt.repeatType() != appointment_t::none)
+ prettyPrintRepeat(&appt);
+ else
+ cout << "Event does not repeat" << endl;
+
+ if ((timePtr = appt.exceptions())) {
+ size = appt.numExceptions();
+ cout << "I seem to have " << size << " exceptions:"
+ << endl;
+ for (int i = 0; i < size; i++)
+ cout << "\t" << asctime(&timePtr[i]);
+ }
+
+ cout << "Description: " << appt.description() << endl;
+
+ if (appt.note()) {
+ cout << "Note: " << appt.note() << endl;
+ }
+
+ cout << endl;
+ */
+
+ pi_buffer_free(pi_buf);
+ free_CalendarEvent(&appt);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ pi_file_t *pf;
+ struct DBInfo info;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s [.pdb file]\n", *argv);
+ return 1;
+ }
+
+
+ if ((pf = pi_file_open(*(argv + 1))) == NULL) {
+ perror("pi_file_open");
+ return 1;
+ }
+
+ pi_file_get_info(pf, &info);
+
+ parse(pf);
+
+ pi_file_close(pf);
+
+ return 0;
+}
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/contactsdb-test.c b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/contactsdb-test.c
new file mode 100644
index 00000000..11abf976
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/contactsdb-test.c
@@ -0,0 +1,378 @@
+/*
+ * contactsdb-test.c: Playing around with palmOne's ContactsDB-PAdd
+ *
+ * Written by T. Joseph Carter <knghtbrd@bluecherry.net>
+ *
+ * This program is released to the public domain where allowed by law. Some
+ * countries (eg, the United States) lack legal provision for releasing
+ * Copyright claims. In such jurisdictions you are licensed to use, modify,
+ * and distribute this program as you see fit. This program is released
+ * WITHOUT ANY WARRANTY, including the implied warranties of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * These terms do NOT apply to libpisock, which is covered by the GNU Library
+ * General Public License. Please see the GNU LGPL for details.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "popt.h"
+#include "pi-socket.h"
+#include "pi-dlp.h"
+#include "pi-header.h"
+#include "pi-appinfo.h"
+#include "pi-contact.h"
+
+#undef PRINT_USELESS_INFO
+#undef SAVE_PICTURES
+
+#define hi(x) (((x) >> 4) & 0x0f)
+#define lo(x) ((x) & 0x0f)
+
+char *contacts_fields[] =
+{
+ "Last name",
+ "First name",
+ "Company",
+ "Title",
+ "Phone 1",
+ "Phone 2",
+ "Phone 3",
+ "Phone 4",
+ "Phone 5",
+ "Phone 6",
+ "Phone 7",
+ "Messaging 1",
+ "Messaging 2",
+ "Website",
+ "Custom 1",
+ "Custom 2",
+ "Custom 3",
+ "Custom 4",
+ "Custom 5",
+ "Custom 6",
+ "Custom 7",
+ "Custom 8",
+ "Custom 9",
+ "Address 1",
+ "City",
+ "State",
+ "Zip",
+ "Country",
+ "Address 2",
+ "City",
+ "State",
+ "Zip",
+ "Country",
+ "Address 3",
+ "City",
+ "State",
+ "Zip",
+ "Country",
+ "Note"
+};
+
+char *contacts_phones[] =
+{
+ "Phone (Work)",
+ "Phone (Home)",
+ "Phone (Fax)",
+ "Phone (Other)",
+ "Email",
+ "Phone (Main)",
+ "Phone (Pager)",
+ "Phone (Mobile)"
+};
+
+char *contacts_ims[] =
+{
+ "IM",
+ "AIM",
+ "MSN IM",
+ "Yahoo IM",
+ "ICQ"
+};
+
+char *contacts_addrs[] =
+{
+ "Addr (Work)",
+ "Addr (Home)",
+ "Addr (Other)"
+};
+
+/* This is ugly, but it works */
+void
+hexprint (unsigned char *data, size_t len, size_t ofs, int ascii)
+{
+ int i, j;
+ int line;
+
+ line = ofs;
+ i = 0;
+
+ while (i < len)
+ {
+ printf (" %08X:", line);
+ for (j = 0; j < 16; j++, i++)
+ {
+ if (i < len)
+ printf (" %02X", data[i]);
+ else
+ printf (" ");
+ if (j == 7)
+ printf (" ");
+ }
+ if (ascii)
+ {
+ printf (" |");
+ i -= 16;
+ for (j = 0; j < 16; j++, i++)
+ {
+ if (i < len)
+ {
+ if (isprint(data[i]))
+ printf ("%c", data[i]);
+ else
+ printf (".");
+ }
+ else
+ printf (" ");
+ }
+ printf ("|\n");
+ }
+ else
+ printf ("\n");
+ line += 16;
+ }
+}
+
+
+int
+print_appblock (int sd, int db, struct ContactAppInfo *cai)
+{
+ int i;
+ size_t j;
+ pi_buffer_t *appblock = pi_buffer_new(0xffff);
+
+ if (dlp_ReadAppBlock(sd, db, 0, -1, appblock) <= 0)
+ goto error;
+
+ if (unpack_ContactAppInfo (cai, appblock) < 0)
+ goto error;
+
+ pi_buffer_free (appblock);
+
+ printf ("Categories:\n");
+ for (i = 0; i < 16; i++)
+ {
+ if (strlen(cai->category.name[i]) > 0)
+ printf (" Category %i: %s\n",
+ cai->category.ID[i], cai->category.name[i]);
+ }
+ printf (" Last Unique ID: %i\n", cai->category.lastUniqueID);
+
+ printf ("\nCustom labels");
+ for (i = 0; i < cai->numCustoms; i++)
+ {
+ if (i%4 == 0)
+ printf ("\n ");
+ printf ("%02i:%-16s ", i, cai->customLabels[i]);
+ }
+ if (i%4 != 0)
+ printf ("\n");
+
+ /* Fair enough for a test to print opaque data.. */
+ if (cai->internal != NULL) {
+ printf ("\nInternal data (opaque)\n");
+ hexprint ((unsigned char *)cai->internal, sizeof(cai->internal), 0, 0);
+ }
+
+ printf ("\nField labels");
+ i = 0;
+ for (j = 0; j < cai->num_labels; j++)
+ {
+ if (i%4 == 0)
+ printf ("\n ");
+ printf ("%02i:%-16s ", i++, cai->labels[j]);
+ }
+ if (i%4 != 0)
+ printf ("\n");
+
+ printf ("\nCountry: %i\n", cai->country);
+
+ printf ("Sorting: %s\n\n", cai->sortByCompany ? "By company" : "By name");
+
+ return 0;
+
+error:
+ pi_buffer_free(appblock);
+ return -1;
+}
+
+
+void
+print_records (int sd, int db, struct ContactAppInfo *cai)
+{
+ char *l;
+ struct Contact c;
+ int i, idx, attr, category;
+ recordid_t recid;
+ pi_buffer_t *buf;
+
+ buf = pi_buffer_new (0xffff);
+
+ for (idx = 0; /**/; idx++) {
+ if (dlp_ReadRecordByIndex (sd, db, idx, buf,
+ &recid, &attr, &category) < 0)
+ break;
+
+ printf ("\nRecord 0x%04x\n", (unsigned int)recid);
+ printf (" Category : %i\n", category);
+ printf (" Attributes : %c%c%c%c%c\n",
+ attr & dlpRecAttrDeleted ? 'X' : '-',
+ attr & dlpRecAttrArchived ? 'A' : '-',
+ attr & dlpRecAttrSecret ? 'S' : '-',
+ attr & dlpRecAttrBusy ? 'B' : '-',
+ attr & dlpRecAttrDirty ? 'd' : '-');
+ printf (" Length : %zu\n", buf->used);
+
+ if (buf->used == 0)
+ /* Empty records are legal */
+ continue;
+
+ if (unpack_Contact (&c, buf, cai->type) < 0) {
+ printf (" [Broken record]\n");
+ continue;
+ }
+
+#if PRINT_USELESS_INFO
+ printf (" Phone labels: { %i, %i, %i, %i, %i, %i, %i }"
+ " (showing [%i])\n",
+ c.phoneLabel[0],
+ c.phoneLabel[1],
+ c.phoneLabel[2],
+ c.phoneLabel[3],
+ c.phoneLabel[4],
+ c.phoneLabel[5],
+ c.phoneLabel[6],
+ c.showPhone);
+ printf (" Address labels: { %i, %i, %i }\n",
+ c.addressLabel[0],
+ c.addressLabel[1],
+ c.addressLabel[2]);
+ printf (" IM labels: { %i, %i }\n",
+ c.IMLabel[0],
+ c.IMLabel[1]);
+#endif /* PRINT_USELESS_INFO */
+
+ for (i = 0; i < NUM_CONTACT_ENTRIES; i++) {
+ if (c.entry[i] != NULL) {
+ /* Special cases are annoying.. */
+ if (i > 3 && i < 11)
+ l = contacts_phones[c.phoneLabel[i - 4]];
+ else if (i == 11 || i == 12)
+ l = contacts_ims[c.IMLabel[i - 11]];
+ else if (i == 23)
+ l = contacts_addrs[c.addressLabel[0]];
+ else if (i == 28)
+ l = contacts_addrs[c.addressLabel[1]];
+ else if (i == 33)
+ l = contacts_addrs[c.addressLabel[2]];
+ else
+ l = contacts_fields[i];
+
+ printf (" %-15s: %s\n", l, c.entry[i]);
+ }
+ }
+
+ if (c.birthdayFlag) {
+ printf (" Birthday : %i-%02i-%02i",
+ c.birthday.tm_year + 1900,
+ c.birthday.tm_mon + 1,
+ c.birthday.tm_mday);
+
+ if (c.reminder)
+ printf (" (%i day reminder)", c.advance);
+ puts ("");
+ }
+
+ if (c.picture != NULL) {
+#ifdef SAVE_PICTURES
+ char fname[25];
+ FILE *f;
+
+ snprintf (fname, 24, "rec-%lu.jpeg",
+ (uint32_t)recid);
+ printf (" Picture : %s\n", fname);
+ f = fopen (fname, "wb");
+ if (f) {
+ fwrite (c.picture->data, c.picture->length, 1, f);
+ fclose (f);
+ }
+#else
+ printf (" Picture : JPEG (%zu bytes)\n",
+ c.picture->length);
+#endif /* SAVE_PICTURES */
+ }
+
+ free_Contact (&c);
+ }
+ pi_buffer_free (buf);
+
+ return;
+}
+
+
+int
+main (const int argc, const char **argv)
+{
+ int sd = -1;
+ int db;
+ struct ContactAppInfo cai;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: contactsdb-test <port>\n");
+ return 1;
+ }
+
+ sd = pilot_connect (argv[1]);
+
+ if (sd < 0)
+ goto error;
+
+ if (dlp_OpenConduit (sd) < 0)
+ goto error;
+
+ if (dlp_OpenDB(sd, 0, dlpOpenRead, "ContactsDB-PAdd", &db) < 0)
+ {
+ fprintf (stderr, "Unable to open Contacts database\n");
+ goto error;
+ }
+
+ if (print_appblock (sd, db, &cai) < 0) {
+ fprintf (stderr, "Failed read/print appblock\n");
+ goto error;
+ } else {
+ print_records (sd, db, &cai);
+ }
+ free_ContactAppInfo (&cai);
+
+ dlp_CloseDB(sd, db);
+ dlp_EndOfSync (sd, 0);
+ pi_close (sd);
+
+error:
+ if (sd != -1)
+ pi_close (sd);
+ return 1;
+}
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/dlp-test.c b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/dlp-test.c
new file mode 100644
index 00000000..45924f60
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/dlp-test.c
@@ -0,0 +1,724 @@
+/*
+ * dlp-test.c: DLP Regression Test
+ *
+ * (c) 2002, JP Rosevear.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * This regression test calls every DLP function except the following:
+ * dlp_CallApplication
+ * dlp_ResetSystem
+ * dlp_ProcessRPC
+ */
+
+#include <stdio.h>
+
+#include "pi-debug.h"
+#include "pi-source.h"
+#include "pi-dlp.h"
+
+/* Prototypes */
+int pilot_connect(char *port);
+
+/* For various protocol versions, set to 0 to not test those versions */
+#define DLP_1_1 1
+#define DLP_1_2 1
+
+/* Logging defines */
+#define CHECK_RESULT(func) \
+ if (result < 0) { \
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST " #func " failed (%d)\n", result)); \
+ goto error; \
+ }
+
+/* Utility defines */
+#define pi_mktag(c1,c2,c3,c4) (((c1)<<24)|((c2)<<16)|((c3)<<8)|(c4))
+
+#define CREATOR pi_mktag('T', 'e', 's', 't')
+#define DATA pi_mktag('D', 'A', 'T', 'A')
+#define INFO pi_mktag('I', 'N', 'F', 'O')
+
+int
+main (int argc, char **argv)
+{
+ int sd;
+ int result;
+ struct SysInfo s;
+ struct PilotUser u1, u2;
+ struct NetSyncInfo n1, n2;
+ struct CardInfo c;
+ struct DBInfo dbi;
+ struct DBSizeInfo dbsi;
+ unsigned long romVersion;
+ time_t t1, t2;
+ int handle;
+ unsigned char pref1[256], pref2[256];
+ unsigned char ablock1[256];
+ unsigned char sblock1[256];
+ unsigned char ires1[256];
+ unsigned char dres1[256];
+ unsigned char record1[256], record2[256], record3[256];
+ recordid_t rid1, rid2, rid3, rlist[4];
+ int index, id_, count;
+ unsigned long type;
+ int cardno;
+ int i;
+ pi_buffer_t *record4,
+ *dres2,
+ *ires2,
+ *appblock;
+
+ record4 = pi_buffer_new (sizeof(record1));
+ ires2 = pi_buffer_new (sizeof (ires1));
+ dres2 = pi_buffer_new (sizeof (dres1));
+ appblock = pi_buffer_new(256);
+
+ sd = pilot_connect (argv[1]);
+
+ t1 = time (NULL);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "DLPTEST Starting at %s", ctime (&t1)));
+
+ /*********************************************************************
+ *
+ * Test: Open Conduit
+ *
+ * Direct Testing Functions:
+ * dlp_OpenConduit
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ result = dlp_OpenConduit (sd);
+ CHECK_RESULT(dlp_OpenConduit);
+
+ /*********************************************************************
+ *
+ * Test: System Information
+ *
+ * Direct Testing Functions:
+ * dlp_ReadSysInfo
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ result = dlp_ReadSysInfo (sd, &s);
+ CHECK_RESULT(dlp_ReadSysInfo);
+
+ /*********************************************************************
+ *
+ * Test: User Info
+ *
+ * Direct Testing Functions:
+ * dlp_WriteUserInfo
+ * dlp_ReadUserInfo
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ memset (&u1, '\0', sizeof (struct PilotUser));
+ memset (&u2, '\0', sizeof (struct PilotUser));
+ u1.passwordLength = 0;
+ strcpy (u1.username, "Test User");
+ strcpy (u1.password, "");
+ u1.userID = 500;
+ u1.viewerID = 5000;
+ u1.lastSyncPC = 111111;
+ u1.successfulSyncDate = time(NULL);
+ u1.lastSyncDate = time(NULL) + 100;
+
+ result = dlp_WriteUserInfo (sd, &u1);
+ CHECK_RESULT(dlp_WriteUserInfo);
+ result = dlp_ReadUserInfo (sd, &u2);
+ CHECK_RESULT(dlp_ReadUserInfo);
+ if (memcmp(&u1, &u2, sizeof(struct PilotUser) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST User info mismatch\n"));
+ goto error;
+ }
+
+ /*********************************************************************
+ *
+ * Test: Feature
+ *
+ * Direct Testing Functions:
+ * dlp_ReadFeature
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ romVersion = 0;
+
+ result = dlp_ReadFeature(sd, makelong("psys"), 1, &romVersion);
+ CHECK_RESULT(dlp_ReadFeature);
+ if (romVersion != s.romVersion) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Rom Version mismatch\n"));
+ goto error;
+ }
+
+ /*********************************************************************
+ *
+ * Test: Net Sync Info
+ *
+ * Direct Testing Functions:
+ * dlp_WriteNetSyncInfo
+ * dlp_ReadNetSyncInfo
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+#if DLP_1_1
+ memset (&n1, '\0', sizeof (struct NetSyncInfo));
+ memset (&n2, '\0', sizeof (struct NetSyncInfo));
+ n1.lanSync = 0;
+ strcpy (n1.hostName, "localhost");
+ strcpy (n1.hostAddress, "192.168.1.1");
+ strcpy (n1.hostSubnetMask, "255.255.255.0");
+
+ result = dlp_WriteNetSyncInfo (sd, &n1);
+ CHECK_RESULT(dlp_WriteNetSyncInfo);
+ result = dlp_ReadNetSyncInfo (sd, &n2);
+ CHECK_RESULT(dlp_ReadNetSyncInfo);
+ if (memcmp(&n1, &n2, sizeof(struct NetSyncInfo) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Net sync info mismatch\n"));
+ goto error;
+ }
+#endif
+
+ /*********************************************************************
+ *
+ * Test: Time
+ *
+ * Direct Testing Functions:
+ * dlp_SetSysDateTime
+ * dlp_GetSysDateTime
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ t1 = time(NULL);
+
+ dlp_SetSysDateTime (sd, t1);
+ CHECK_RESULT(dlp_SetSysDateTime);
+ dlp_GetSysDateTime (sd, &t2);
+ CHECK_RESULT(dlp_GetSysDateTime);
+ if (t2 > t1 + 1) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST System Time Mismatch\n"));
+ goto error;
+ }
+
+ /*********************************************************************
+ *
+ * Test: Storage Information
+ *
+ * Direct Testing Functions:
+ * dlp_ReadStorageInfo
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ c.more = 1;
+ for (i = 0; c.more != 0; i++) {
+ result = dlp_ReadStorageInfo (sd, i, &c);
+ CHECK_RESULT(dlp_ReadStorageInfo);
+ }
+
+ /*********************************************************************
+ *
+ * Test: Database List
+ *
+ * Direct Testing Functions:
+ * dlp_ReadDBList
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ dbi.more = 1;
+ for (i = 0; dbi.more != 0; i++) {
+ result = dlp_ReadDBList (sd, 0, dlpDBListRAM | dlpDBListROM, i, record4);
+ CHECK_RESULT(dlp_ReadDBList);
+ memcpy(&dbi, record4->data, sizeof(struct DBInfo));
+ }
+
+ /*********************************************************************
+ *
+ * Test: Existing Database
+ *
+ * Direct Testing Functions:
+ * dlp_OpenDB
+ * dlp_CloseDB
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ result = dlp_OpenDB (sd, 0, dlpOpenReadWrite, "ToDoDB", &handle);
+ CHECK_RESULT(dlp_OpenDB);
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB);
+
+ /*********************************************************************
+ *
+ * Test: New Database
+ *
+ * Direct Testing Functions:
+ * dlp_CreateDB
+ * dlp_CloseDB
+ * dlp_DeleteDB
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ result = dlp_CreateDB (sd, CREATOR, DATA, 0, dlpDBFlagResource, 1, "TestResource", &handle);
+ CHECK_RESULT(dlp_CreateDB);
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB);
+ result = dlp_DeleteDB (sd, 0, "TestResource");
+ CHECK_RESULT(dlp_DeleteDB);
+
+ /*********************************************************************
+ *
+ * Test: Database Info and Searching
+ *
+ * Direct Testing Functions:
+ * dlp_SetDBInfo
+ * dlp_FindDBByName
+ * dlp_FindDBByOpenHandle
+ * dlp_FindDBByTypeCreator
+ *
+ * Indirect Testing Functions:
+ * dlp_CreateDB
+ * dlp_OpenDB
+ * dlp_ReadDBList
+ * dlp_CloseDB
+ * dlp_DeleteDB
+ *
+ *********************************************************************/
+#if DLP_1_2
+ result = dlp_CreateDB (sd, CREATOR, DATA, 0, 0, 1, "TestRecord", &handle);
+ CHECK_RESULT(dlp_CreateDB);
+ result = dlp_SetDBInfo (sd, handle, dlpDBFlagBackup, dlpDBFlagCopyPrevention, 0, 0, 0, 0, 0, 0);
+ CHECK_RESULT(dlp_SetDBInfo);
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB);
+
+ result = dlp_OpenDB (sd, 0, dlpOpenReadWrite, "TestRecord", &handle);
+ CHECK_RESULT(dlp_OpenDB);
+
+ result = dlp_FindDBByOpenHandle (sd, handle, &cardno, NULL, &dbi, &dbsi);
+ CHECK_RESULT(dlp_FindDBByOpenHandle);
+ if (strcmp (dbi.name, "TestRecord") || !(dbi.flags & dlpDBFlagBackup)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Database info mismatch with openhandle\n"));
+ goto error;
+ }
+
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB);
+
+ result = dlp_FindDBByName (sd, 0, "TestRecord", NULL, NULL, &dbi, &dbsi);
+ CHECK_RESULT(dlp_FindDBByName);
+ if (strcmp (dbi.name, "TestRecord") || !(dbi.flags & dlpDBFlagBackup)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Database info mismatch with name\n"));
+ goto error;
+ }
+
+ result = dlp_FindDBByTypeCreator (sd, DATA, CREATOR, 1, 0, &cardno, NULL, NULL, &dbi, &dbsi);
+ CHECK_RESULT(dlp_FindDBByName);
+ if (strcmp (dbi.name, "TestRecord") || !(dbi.flags & dlpDBFlagBackup)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Database info mismatch with type/creator\n"));
+ goto error;
+ }
+
+ result = dlp_DeleteDB (sd, 0, "TestRecord");
+ CHECK_RESULT(dlp_DeleteDB);
+#endif
+
+ /*********************************************************************
+ *
+ * Test: App Preference
+ *
+ * Direct Testing Functions:
+ * dlp_WriteAppPreference
+ * dlp_ReadAppPreference
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ memset (pref1, '\0', sizeof (pref1));
+ memset (pref2, '\0', sizeof (pref2));
+ pref1[9] = 'T';
+ pref2[10] = 'T';
+
+ result = dlp_WriteAppPreference (sd, CREATOR, 0, 1, 1, pref1, sizeof(pref1));
+ CHECK_RESULT(dlp_WriteAppPrefence);
+ result = dlp_ReadAppPreference (sd, CREATOR, 0, 1, sizeof(pref2), pref2, NULL, NULL);
+ CHECK_RESULT(dlp_ReadAppPreference);
+ if (memcmp(&pref1, &pref2, sizeof(pref1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Preference mismatch\n"));
+ goto error;
+ }
+
+ /*********************************************************************
+ *
+ * Test: Record
+ *
+ * Direct Testing Functions:
+ * dlp_WriteAppBlock
+ * dlp_ReadAppBlock
+ * dlp_WriteSortBlock
+ * dlp_ReadSortBlock
+ * dlp_WriteRecord
+ * dlp_ReadOpenDBInfo
+ * dlp_ReadRecordById
+ * dlp_ReadRecordByIndex
+ * dlp_ReadNextModifiedRec
+ * dlp_ReadNextRecInCategory
+ * dlp_ReadNextModifiedRecInCategory
+ * dlp_MoveCategory
+ * dlp_DeleteRecord
+ * dlp_DeleteCategory
+ * dlp_ResetDBIndex
+ *
+ * Indirect Testing Functions:
+ * dlp_CreateDB
+ * dlp_CloseDB
+ * dlp_DeleteDB
+ *
+ *********************************************************************/
+ memset (ablock1, '\0', sizeof (ablock1));
+ memset (sblock1, '\0', sizeof (sblock1));
+ memset (record1, '\0', sizeof (record1));
+ memset (record2, '\0', sizeof (record2));
+ memset (record3, '\0', sizeof (record3));
+ ablock1[3] = 'T';
+ sblock1[17] = 'T';
+ record1[32] = 'T';
+ record2[33] = 'T';
+ record3[34] = 'T';
+
+ result = dlp_CreateDB (sd, CREATOR, DATA, 0, 0, 1, "TestRecord", &handle);
+ CHECK_RESULT(dlp_CreateDB);
+
+ /* Write and read back an app block */
+ result = dlp_WriteAppBlock (sd, handle, ablock1, sizeof(ablock1));
+ CHECK_RESULT(dlp_WriteAppBlock);
+ result = dlp_ReadAppBlock (sd, handle, 0, sizeof(ablock1), appblock);
+ CHECK_RESULT(dlp_ReadAppBlock);
+ if (result != sizeof(ablock1) || memcmp(ablock1, appblock->data, sizeof(ablock1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST App block mismatch\n"));
+ goto error;
+ }
+
+ /* Write and read back a sort block */
+ result = dlp_WriteSortBlock (sd, handle, sblock1, sizeof(sblock1));
+ CHECK_RESULT(dlp_WriteSortBlock);
+ result = dlp_ReadSortBlock (sd, handle, 0, sizeof(sblock1), appblock);
+ CHECK_RESULT(dlp_ReadSortBlock);
+ if (result != sizeof(sblock1) || memcmp(sblock1, appblock->data, sizeof(sblock1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST App block mismatch\n"));
+ goto error;
+ }
+
+ /* Write some records out */
+ result = dlp_WriteRecord (sd, handle, 0, 0, 1, record1, sizeof(record1), &rid1);
+ CHECK_RESULT(dlp_WriteRecord);
+ result = dlp_WriteRecord (sd, handle, dlpRecAttrDirty, 0, 2, record2, sizeof(record2), &rid2);
+ CHECK_RESULT(dlp_WriteRecord);
+ result = dlp_WriteRecord (sd, handle, 0, 0, 3, record3, sizeof(record3), &rid3);
+ CHECK_RESULT(dlp_WriteRecord);
+
+ /* Get the db info */
+ result = dlp_ReadOpenDBInfo (sd, handle, &count);
+ CHECK_RESULT(dlp_ReadOpenDBInfo);
+ if (count != 3) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Read wrong open database info\n"));
+ goto error;
+ }
+
+ /* Get the id list */
+ result = dlp_ReadRecordIDList (sd, handle, 0, 0, 4, rlist, &count);
+ CHECK_RESULT(dlp_ReadRecordIDList);
+ if (count != 3) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Read wrong record id list length\n"));
+ goto error;
+ }
+ for (i = 0; i < 3; i++) {
+ if (rlist[i] != rid1 && rlist[i] != rid2 && rlist[i] != rid3) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Read wrong record id\n"));
+ goto error;
+ }
+ }
+
+ /* Try reading the records in various ways */
+ result = dlp_ReadRecordById (sd, handle, rid1, record4, &index, NULL, NULL);
+ CHECK_RESULT(dlp_ReadRecordById);
+ if (memcmp(record1, record4->data, sizeof(record1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Record by Id mismatch\n"));
+ goto error;
+ }
+ result = dlp_ReadRecordByIndex (sd, handle, index, record4, NULL, NULL, NULL);
+ CHECK_RESULT(dlp_ReadRecordByIndex);
+ if (memcmp(record1, record4->data, sizeof(record1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Record by index mismatch\n"));
+ goto error;
+ }
+ result = dlp_ReadNextModifiedRec (sd, handle, record4, NULL, NULL, NULL, NULL);
+ CHECK_RESULT(dlp_ReadNextModifiedRec);
+ if (memcmp(record2, record4->data, sizeof(record2) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Next modified record mismatch\n"));
+ goto error;
+ }
+
+ /* Reset because of the above next modified record call */
+ result = dlp_ResetDBIndex (sd, handle);
+ CHECK_RESULT(dlp_ResetDBIndex)
+
+ /* This is a DLP 1.1 call, but pilot-link has a 1.0 implementation */
+ result = dlp_ReadNextRecInCategory (sd, handle, 3, record4, NULL, NULL, NULL);
+ CHECK_RESULT(dlp_ReadNextRecInCategory)
+ if (memcmp(record3, record4->data, sizeof(record3) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST dlp_ReadNextRecInCategory mismatch\n"));
+ goto error;
+ }
+
+ /* Reset because of the above next record in category call */
+ result = dlp_ResetDBIndex (sd, handle);
+ CHECK_RESULT(dlp_ResetDBIndex)
+
+ /* This is a DLP 1.1 call, but pilot-link has a 1.0 implementation */
+ result = dlp_ReadNextModifiedRecInCategory (sd, handle, 2, record4, NULL, NULL, NULL);
+ CHECK_RESULT(dlp_ReadNextModifiedRecInCategory)
+ if (memcmp(record2, record4->data, sizeof(record2) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST dlp_ReadNextModifiedRecInCategory mismatch\n"));
+ goto error;
+ }
+
+ /* Reset because of the above next modified record in category call */
+ result = dlp_ResetDBIndex (sd, handle);
+ CHECK_RESULT(dlp_ResetDBIndex)
+
+ /* Move a category and try to read the record back in */
+ result = dlp_MoveCategory (sd, handle, 1, 4);
+ CHECK_RESULT(dlp_MoveCategory)
+ result = dlp_ReadNextRecInCategory (sd, handle, 4, record4, NULL, NULL, NULL);
+ CHECK_RESULT(dlp_ReadNextRecInCategory)
+ if (memcmp(record1, record4->data, sizeof(record1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST dlp_ReadNextRecInCategory mismatch\n"));
+ goto error;
+ }
+
+ /* Delete records in various ways */
+ result = dlp_DeleteRecord (sd, handle, 0, rid1);
+ CHECK_RESULT(dlp_DeleteRecord <Single>);
+ result = dlp_ReadRecordById (sd, handle, rid1, record4, NULL, NULL, NULL);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Deleted record could still be read\n"));
+ goto error;
+ }
+ result = dlp_DeleteCategory (sd, handle, 3);
+ CHECK_RESULT(dlp_DeleteCategory);
+ result = dlp_ReadRecordById (sd, handle, rid3, record4, NULL, NULL, NULL);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Deleted category could still be read\n"));
+ goto error;
+ }
+ result = dlp_DeleteRecord (sd, handle, 1, 0);
+ CHECK_RESULT(dlp_DeleteRecord <All>);
+ result = dlp_ReadRecordById (sd, handle, rid2, record4, NULL, NULL, NULL);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Deleted all record could still be read\n"));
+ goto error;
+ }
+
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB);
+ result = dlp_DeleteDB (sd, 0, "TestRecord");
+ CHECK_RESULT(dlp_DeleteDB);
+
+ /*********************************************************************
+ *
+ * Test: Resource
+ *
+ * Direct Testing Functions:
+ * dlp_WriteResource
+ * dlp_ReadResourceByType
+ * dlp_ReadResourceByIndex
+ * dlp_DeleteResource
+ *
+ * Indirect Testing Functions:
+ * dlp_CreateDB
+ * dlp_CloseDB
+ * dlp_DeleteDB
+ *
+ *********************************************************************/
+ memset (ires1, '\0', sizeof (ires1));
+ memset (dres1, '\0', sizeof (dres1));
+ ires1[3] = 'T';
+ dres1[4] = 'T';
+
+ result = dlp_CreateDB (sd, CREATOR, DATA, 0, dlpDBFlagResource, 1, "TestResource", &handle);
+ CHECK_RESULT(dlp_CreateDB);
+
+ /* Write out some resources */
+ result = dlp_WriteResource (sd, handle, INFO, 1, ires1, sizeof(ires1));
+ CHECK_RESULT(dlp_WriteResource);
+ result = dlp_WriteResource (sd, handle, DATA, 0, dres1, sizeof(dres1));
+ CHECK_RESULT(dlp_WriteResource);
+
+ /* Read in the resources by various methods */
+ result = dlp_ReadResourceByType (sd, handle, INFO, 1, ires2, &index);
+ CHECK_RESULT(dlp_ReadResourceByType)
+ if (memcmp(ires1, ires2->data, sizeof(ires1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Resource by type mismatch\n"));
+ goto error;
+ }
+ result = dlp_ReadResourceByIndex (sd, handle, index, ires2, &type, &id_);
+ CHECK_RESULT(dlp_ReadResourceByIndex)
+ if (memcmp(ires1, ires2->data, sizeof(ires1) != 0)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Resource by index mismatch\n"));
+ goto error;
+ }
+ if (type != INFO) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Resource by index return type mismatch\n"));
+ goto error;
+ }
+ if (id_ != 1) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Resource by index return id mismatch\n"));
+ goto error;
+ }
+
+ /* Delete resources by the various methods */
+ result = dlp_DeleteResource (sd, handle, 0, INFO, 1);
+ CHECK_RESULT(dlp_DeleteResource <Single>)
+ result = dlp_ReadResourceByType (sd, handle, INFO, 1, ires2, &index);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Deleted resource could still be read\n"));
+ goto error;
+ }
+ result = dlp_DeleteResource (sd, handle, 1, INFO, 1);
+ CHECK_RESULT(dlp_DeleteResource <All>)
+ result = dlp_ReadResourceByType (sd, handle, DATA, 0, dres2, &index);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Deleted all resource could still be read\n"));
+ goto error;
+ }
+
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB)
+ result = dlp_DeleteDB (sd, 0, "TestResource");
+ CHECK_RESULT(dlp_DeleteDB)
+
+ /*********************************************************************
+ *
+ * Test: Database Cleanup
+ *
+ * Direct Testing Functions:
+ * dlp_CleanUpDatabase
+ * dlp_ResetSyncFlags
+ *
+ * Indirect Testing Functions:
+ * dlp_CreateDB
+ * dlp_WriteRecord
+ * dlp_CloseDB
+ * dlp_DeleteDB
+ *
+ *********************************************************************/
+ result = dlp_CreateDB (sd, CREATOR, DATA, 0, 0, 1, "TestRecord", &handle);
+ CHECK_RESULT(dlp_CreateDB);
+
+ /* Create dummy records */
+ result = dlp_WriteRecord (sd, handle, dlpRecAttrDeleted, 0, 0, record1, sizeof(record1), &rid1);
+ CHECK_RESULT(dlp_WriteRecord);
+ result = dlp_WriteRecord (sd, handle, dlpRecAttrDirty, 0, 0, record2, sizeof(record2), &rid2);
+ CHECK_RESULT(dlp_WriteRecord);
+
+ /* Call the test functions */
+ result = dlp_CleanUpDatabase (sd, handle);
+ CHECK_RESULT(dlp_CleanUpDatabase);
+ result = dlp_ResetSyncFlags (sd, handle);
+ CHECK_RESULT(dlp_ResetSyncFlags);
+
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB);
+
+ /* Confirm the test functions worked */
+ result = dlp_OpenDB (sd, 0, dlpOpenReadWrite, "TestRecord", &handle);
+ CHECK_RESULT(dlp_OpenDB);
+
+ result = dlp_ReadRecordById (sd, handle, rid1, record4, NULL, NULL, NULL);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Cleaned up record could still be read\n"));
+ goto error;
+ }
+ result = dlp_ReadNextModifiedRec (sd, handle, record4, NULL, NULL, NULL, NULL);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "DLPTEST Modified recorded could still be read\n"));
+ goto error;
+ }
+
+ result = dlp_CloseDB (sd, handle);
+ CHECK_RESULT(dlp_CloseDB);
+ result = dlp_DeleteDB (sd, 0, "TestRecord");
+ CHECK_RESULT(dlp_DeleteDB);
+
+ /*********************************************************************
+ *
+ * Test: Sync Log
+ *
+ * Direct Testing Functions:
+ * dlp_AddSyncLogEntry
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ result = dlp_AddSyncLogEntry (sd, "dlp-test added sync log entry");
+ CHECK_RESULT(dlp_AddSyncLogEntry);
+
+ /*********************************************************************
+ *
+ * Test: End Sync
+ *
+ * Direct Testing Functions:
+ * dlp_EndOfSync
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+ result = dlp_EndOfSync (sd, dlpEndCodeNormal);
+ CHECK_RESULT(dlp_EndOfSync);
+
+ t1 = time (NULL);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "DLPTEST Ending at %s", ctime (&t1)));
+
+ error:
+ pi_close (sd);
+ pi_buffer_free (record4);
+ pi_buffer_free (ires2);
+ pi_buffer_free (dres2);
+ pi_buffer_free(appblock);
+ return 0;
+}
+
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/locationdb-test.c b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/locationdb-test.c
new file mode 100644
index 00000000..baf96114
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/locationdb-test.c
@@ -0,0 +1,192 @@
+/*
+ * $Id: locationdb-test.c,v 1.1 2009/02/22 08:09:02 nicholas Exp $
+ *
+ * calendardb-test.c: Test parsing the PalmOne timezone databases
+ * loclLDefLocationDB and loclCusLocationDB.
+
+ * (c) 2008, Jon Schewe
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+*/
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include "pi-source.h"
+#include "pi-file.h"
+#include "pi-macros.h"
+#include "pi-location.h"
+
+/***********************************************************************
+ *
+ * Function: dump
+ *
+ * Summary: Dump data as requested by other functions
+ *
+ * Parameters: None
+ *
+ * Returns: Nothing
+ *
+ ***********************************************************************/
+static void dump(void *buf, int n)
+{
+ int ch,
+ i,
+ j;
+
+ for (i = 0; i < n; i += 16) {
+ printf("%04x: ", i);
+ for (j = 0; j < 16; j++) {
+ if (i + j < n)
+ printf("%02x ",
+ ((unsigned char *) buf)[i + j]);
+ else
+ printf(" ");
+ }
+ printf(" ");
+ for (j = 0; j < 16 && i + j < n; j++) {
+ ch = ((unsigned char *) buf)[i + j] & 0x7f;
+ if (ch < ' ' || ch >= 0x7f)
+ putchar('.');
+ else
+ putchar(ch);
+ }
+ printf("\n");
+ }
+}
+
+/**
+ * Test parsing database.
+ */
+void parse(pi_file_t *pf)
+{
+ int result;
+ int nentries;
+ char *buf;
+ int attrs, cat;
+ size_t size;
+ recordid_t uid;
+ Location_t loc;
+ int entnum;
+ pi_buffer_t *pi_buf;
+ pi_buffer_t *test;
+
+ pi_file_get_entries(pf, &nentries);
+ printf("Number of entries: %d\n", nentries);
+
+ for (entnum = 0; entnum < nentries; entnum++) {
+ if (pi_file_read_record(pf, entnum, (void **) &buf, &size,
+ &attrs, &cat, &uid) < 0) {
+ printf("Error reading record number %d\n", entnum);
+ return;
+ }
+
+ /* Skip deleted records */
+ if ((attrs & dlpRecAttrDeleted)
+ || (attrs & dlpRecAttrArchived)) {
+ continue;
+ }
+
+ printf("original record %d\n", entnum);
+ dump(buf, size);
+
+ pi_buf = pi_buffer_new(size);
+ pi_buffer_append(pi_buf, buf, size);
+
+ result = unpack_Location(&loc, pi_buf);
+ if(result == -1) {
+ printf("Error unpacking record %d!\n", entnum);
+ } else {
+ printf("Timezone name: %s\n", loc.tz.name);
+ printf("\tOffset from GMT: %d minutes\n", loc.tz.offset);
+ printf("\tDST observed: %d\n", loc.tz.dstObserved);
+ printf("\tNote is: %s\n", loc.note);
+
+ printf("\tlat: %d degrees %d minutes\n", loc.latitude.degrees, loc.latitude.minutes);
+ printf("\tlon: %d degrees %d minutes\n", loc.longitude.degrees, loc.longitude.minutes);
+
+ }
+
+
+ /* now try and pack the record and see if we get the same data */
+ test = pi_buffer_new(0);
+ result = pack_Location(&loc, test);
+ if(result == -1) {
+ printf("Error packing record %d!\n", entnum);
+ } else {
+ printf("packed record\n");
+ dump(test->data, test->used);
+
+ if(pi_buf->used != test->used) {
+ int i;
+ printf("Error: Different record sizes unpack: %d pack: %d last byte unpack: 0x%02X pack: 0x%02X\n", pi_buf->used, test->used, pi_buf->data[pi_buf->used-1], test->data[test->used-1]);
+ for(i=0; i<pi_buf->used; ++i) {
+ if(pi_buf->data[i] != test->data[i]) {
+ printf("Error: Byte %d is different unpack: 0x%02X pack: 0x%02X\n", i, pi_buf->data[i], test->data[i]);
+ }
+ }
+ }
+ }
+
+
+ pi_buffer_free(test);
+
+ pi_buffer_free(pi_buf);
+ free_Location(&loc);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ pi_file_t *pf;
+ struct DBInfo info;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s [.pdb file]\n", *argv);
+ return 1;
+ }
+
+
+ if ((pf = pi_file_open(*(argv + 1))) == NULL) {
+ perror("pi_file_open");
+ return 1;
+ }
+
+ pi_file_get_info(pf, &info);
+
+ parse(pf);
+
+ pi_file_close(pf);
+
+ return 0;
+}
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/packers.c b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/packers.c
new file mode 100644
index 00000000..692c482e
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/packers.c
@@ -0,0 +1,1775 @@
+/* packers.c: Test packing functions
+ *
+ * Copyright (c) 1997, Kenneth Albanowski
+ *
+ * This is free software, licensed under the GNU Public License V2.
+ * See the file COPYING for details.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "pi-source.h"
+#include "pi-socket.h"
+#include "pi-memo.h"
+#include "pi-address.h"
+#include "pi-datebook.h"
+#include "pi-todo.h"
+#include "pi-dlp.h"
+#include "pi-expense.h"
+#include "pi-mail.h"
+
+unsigned char seed;
+char *target;
+int targetlen;
+
+
+void reset_block(char *buffer, int len)
+{
+ unsigned int i;
+
+ for (i = 0; i < len; i++)
+ buffer[i] = (i + seed) & 0xff;
+}
+
+int check_block(int test, const char *buffer, int len, int start,
+ int count, const char *name)
+{
+ unsigned int i;
+ int fore = 0, aft = 0;
+
+ for (i = 0; i < start; i++)
+ if (buffer[i] != (char) ((i + seed) & 0xff)) {
+ fore = start - i;
+ break;
+ }
+ for (i = start + count; i < len; i++)
+ if (buffer[i] != (char) ((i + seed) & 0xff)) {
+ aft = i - start;
+ break;
+ }
+ if (fore || aft) {
+ printf("%d: %s scribbled ", test, name);
+ if (fore)
+ printf("%d byte(s) before", fore);
+ if (fore && aft)
+ printf(", and ");
+ if (aft)
+ printf("%d byte(s) after", aft);
+ printf(" the allocated buffer.\n");
+ return 1;
+ }
+ return 0;
+}
+
+char MemoAppBlock[17 * 16 + 10] = "\
+\x00\x00\x55\x6e\x66\x69\x6c\x65\x64\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x42\x75\x73\x69\x6e\x65\x73\x73\x00\x00\x00\x00\x00\x00\
+\x00\x00\x50\x65\x72\x73\x6f\x6e\x61\x6c\x00\x00\x00\x00\x00\x00\
+\x00\x00\x54\x65\x63\x68\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x54\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x42\x6f\x6f\x6b\x73\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x53\x74\x6f\x72\x79\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x01\x02\x10\x11\x12\x13\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x13\x00\x00\x00\x00\x00\x01\x00";
+
+char MemoRecord[3 * 16 + 7] = "\
+\x61\x61\x4d\x61\x6b\x65\x66\x69\x6c\x65\x0a\x52\x45\x41\x44\x4d\
+\x45\x0a\x6c\x69\x63\x65\x6e\x73\x65\x2e\x74\x65\x72\x6d\x73\x0a\
+\x70\x69\x6c\x6f\x74\x6c\x69\x6e\x6b\x2e\x63\x0a\x74\x65\x73\x74\
+\x2e\x74\x63\x6c\x2a\x0a\x00";
+
+int test_memo()
+{
+ struct MemoAppInfo mai;
+ struct Memo m;
+ pi_buffer_t *RecordBuffer;
+ int l;
+ int errors = 0;
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_MemoAppInfo(&mai, MemoAppBlock, sizeof(MemoAppBlock) + 10);
+ if (l != sizeof(MemoAppBlock)) {
+ errors++;
+ printf
+ ("1: unpack_MemoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MemoAppBlock));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_MemoAppInfo(&mai, MemoAppBlock, sizeof(MemoAppBlock) + 1);
+ if (l != sizeof(MemoAppBlock)) {
+ errors++;
+ printf
+ ("2: unpack_MemoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MemoAppBlock));
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ l = unpack_MemoAppInfo(&mai, MemoAppBlock, sizeof(MemoAppBlock) - 10);
+ if (l != 0) {
+ errors++;
+ printf
+ ("3: unpack_MemoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ /* Note: -1 isn't used, because four bytes _can_ be subtracted, to account for
+ the new data in OS 2.0 */
+ l = unpack_MemoAppInfo(&mai, MemoAppBlock, sizeof(MemoAppBlock) - 5);
+ if (l != 0) {
+ errors++;
+ printf
+ ("4: unpack_MemoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_MemoAppInfo(&mai, MemoAppBlock, sizeof(MemoAppBlock));
+ if (l != sizeof(MemoAppBlock)) {
+ errors++;
+ printf
+ ("5: unpack_MemoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MemoAppBlock));
+ }
+
+ if (
+ (mai.sortByAlpha == 0) ||
+ strcmp(mai.category.name[0], "Unfiled") ||
+ strcmp(mai.category.name[1], "Business") ||
+ strcmp(mai.category.name[2], "Personal") ||
+ strcmp(mai.category.name[3], "Tech") ||
+ strcmp(mai.category.name[4], "Test") ||
+ strcmp(mai.category.name[5], "Books") ||
+ strcmp(mai.category.name[6], "Story") ||
+ strcmp(mai.category.name[7], "") ||
+ strcmp(mai.category.name[8], "") ||
+ strcmp(mai.category.name[9], "") ||
+ strcmp(mai.category.name[10], "") ||
+ strcmp(mai.category.name[11], "") ||
+ strcmp(mai.category.name[12], "") ||
+ strcmp(mai.category.name[13], "") ||
+ strcmp(mai.category.name[14], "") ||
+ strcmp(mai.category.name[15], "") ||
+ mai.category.renamed[0] ||
+ mai.category.renamed[1] ||
+ mai.category.renamed[2] ||
+ mai.category.renamed[3] ||
+ mai.category.renamed[4] ||
+ mai.category.renamed[5] ||
+ mai.category.renamed[6] ||
+ mai.category.renamed[7] ||
+ mai.category.renamed[8] ||
+ mai.category.renamed[9] ||
+ mai.category.renamed[10] ||
+ mai.category.renamed[11] ||
+ mai.category.renamed[12] ||
+ mai.category.renamed[13] ||
+ mai.category.renamed[14] ||
+ mai.category.renamed[15] ||
+ (mai.category.ID[0] != 0) ||
+ (mai.category.ID[1] != 1) ||
+ (mai.category.ID[2] != 2) ||
+ (mai.category.ID[3] != 16) ||
+ (mai.category.ID[4] != 17) ||
+ (mai.category.ID[5] != 18) ||
+ (mai.category.ID[6] != 19) ||
+ (mai.category.ID[7] != 0) ||
+ (mai.category.ID[8] != 0) ||
+ (mai.category.ID[9] != 0) ||
+ (mai.category.ID[10] != 0) ||
+ (mai.category.ID[11] != 0) ||
+ (mai.category.ID[12] != 0) ||
+ (mai.category.ID[13] != 0) ||
+ (mai.category.ID[14] != 0) ||
+ (mai.category.ID[15] != 0) ||
+ (mai.category.lastUniqueID != 19) || 0) {
+ errors++;
+ printf("6: unpack_MemoAppInfo generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_MemoAppInfo(&mai, 0, 0);
+ if (l != sizeof(MemoAppBlock)) {
+ errors++;
+ printf
+ ("7: pack_MemoAppInfo returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(MemoAppBlock));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_MemoAppInfo(&mai, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf("8: pack_MemoAppInfo packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(9, target, 8192, 128, 1, "pack_MemoAppInfo"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_MemoAppInfo(&mai, target + 128, 8192 - 256);
+ if (l != sizeof(MemoAppBlock)) {
+ errors++;
+ printf
+ ("10: pack_MemoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MemoAppBlock));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(11, target, 8192, 128, l, "pack_MemoAppInfo"))
+ errors++;
+
+ if (memcmp(target + 128, MemoAppBlock, sizeof(MemoAppBlock))) {
+ errors++;
+ printf
+ ("12: pack_MemoAppInfo generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(MemoAppBlock, sizeof(MemoAppBlock));
+ }
+
+ RecordBuffer = pi_buffer_new(sizeof(MemoRecord));
+ memcpy(RecordBuffer->data, MemoRecord, RecordBuffer->allocated);
+ RecordBuffer->used=sizeof(MemoRecord);
+ unpack_Memo(&m, RecordBuffer, memo_v1);
+ pi_buffer_free(RecordBuffer);
+
+ if (
+ (m.text == 0) ||
+ strcmp(m.text,
+ "aaMakefile\x0aREADME\x0alicense.terms\x0apilotlink.c\x0atest.tcl*\x0a"))
+ {
+ errors++;
+ printf("13: unpack_Memo generated incorrect information\n");
+ }
+
+ RecordBuffer = pi_buffer_new(0);
+ if (pack_Memo(&m, RecordBuffer, memo_v1) != 0) {
+ errors++;
+ printf("14: pack_Memo returned failure\n");
+ }
+
+ if (RecordBuffer->used != sizeof(MemoRecord)) {
+ errors++;
+ printf
+ ("15: pack_MemoRecord returned incorrect allocation length (got %d, expected %d)\n",
+ RecordBuffer->used, sizeof(MemoRecord));
+ }
+
+ if (memcmp(RecordBuffer->data, MemoRecord, sizeof(MemoRecord))) {
+ errors++;
+ printf("16: pack_Memo generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(MemoRecord, sizeof(MemoRecord));
+ }
+
+ pi_buffer_free(RecordBuffer);
+
+ printf("Memo packers test completed with %d error(s).\n", errors);
+
+ return errors;
+}
+
+char AddressAppBlock[39 * 16 + 14] = "\
+\x00\x10\x55\x6e\x66\x69\x6c\x65\x64\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x42\x75\x73\x69\x6e\x65\x73\x73\x00\x00\x00\x00\x00\x00\
+\x00\x00\x50\x65\x72\x73\x6f\x6e\x61\x6c\x00\x00\x00\x00\x00\x00\
+\x00\x00\x51\x75\x69\x63\x6b\x4c\x69\x73\x74\x00\x00\x00\x00\x00\
+\x00\x00\x46\x6f\x6f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x01\x02\x03\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x11\x00\x00\x00\x00\x00\x0e\x00\x4c\x61\x73\x74\x20\x6e\
+\x61\x6d\x65\x00\x00\x00\x00\x00\x00\x00\x46\x69\x72\x73\x74\x20\
+\x6e\x61\x6d\x65\x00\x00\x00\x00\x00\x00\x43\x6f\x6d\x70\x61\x6e\
+\x79\x00\x00\x00\x00\x00\x00\x00\x00\x00\x57\x6f\x72\x6b\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x48\x6f\x6d\x65\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x46\x61\x78\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4f\x74\x68\x65\x72\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x45\x2d\x6d\x61\x69\x6c\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x41\x64\x64\x72\x65\x73\
+\x73\x00\x00\x00\x00\x00\x00\x00\x00\x00\x43\x69\x74\x79\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x53\x74\x61\x74\x65\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5a\x69\x70\x20\x43\x6f\
+\x64\x65\x00\x00\x00\x00\x00\x00\x00\x00\x43\x6f\x75\x6e\x74\x72\
+\x79\x00\x00\x00\x00\x00\x00\x00\x00\x00\x54\x69\x74\x6c\x65\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x43\x75\x73\x74\x6f\x6d\
+\x20\x31\x00\x00\x00\x00\x00\x00\x00\x00\x43\x75\x73\x74\x6f\x6d\
+\x20\x32\x00\x00\x00\x00\x00\x00\x00\x00\x43\x75\x73\x74\x6f\x6d\
+\x20\x33\x00\x00\x00\x00\x00\x00\x00\x00\x43\x75\x73\x74\x6f\x6d\
+\x20\x34\x00\x00\x00\x00\x00\x00\x00\x00\x4e\x6f\x74\x65\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4d\x61\x69\x6e\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x50\x61\x67\x65\x72\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4d\x6f\x62\x69\x6c\x65\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00";
+
+char AddressRecord[2 * 16 + 12] = "\
+\x00\x14\x32\x10\x00\x04\x41\x03\x00\x53\x68\x61\x77\x00\x42\x65\
+\x72\x6e\x61\x72\x64\x00\x4e\x6f\x6e\x65\x20\x6b\x6e\x6f\x77\x6e\
+\x00\x43\x31\x00\x41\x20\x6e\x6f\x74\x65\x2e\x00";
+
+int test_address()
+{
+ struct AddressAppInfo mai;
+ struct Address m;
+ pi_buffer_t *RecordBuffer;
+ int l;
+ int errors = 0;
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_AddressAppInfo(&mai, AddressAppBlock,
+ sizeof(AddressAppBlock) + 10);
+ if (l != sizeof(AddressAppBlock)) {
+ errors++;
+ printf
+ ("1: unpack_AddressAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AddressAppBlock));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_AddressAppInfo(&mai, AddressAppBlock,
+ sizeof(AddressAppBlock) + 1);
+ if (l != sizeof(AddressAppBlock)) {
+ errors++;
+ printf
+ ("2: unpack_AddressAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AddressAppBlock));
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ l =
+ unpack_AddressAppInfo(&mai, AddressAppBlock,
+ sizeof(AddressAppBlock) - 10);
+ if (l != 0) {
+ errors++;
+ printf
+ ("3: unpack_AddressAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ l =
+ unpack_AddressAppInfo(&mai, AddressAppBlock,
+ sizeof(AddressAppBlock) - 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("4: unpack_AddressAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_AddressAppInfo(&mai, AddressAppBlock,
+ sizeof(AddressAppBlock));
+ if (l != sizeof(AddressAppBlock)) {
+ errors++;
+ printf
+ ("5: unpack_AddressAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AddressAppBlock));
+ }
+
+ if (strcmp(mai.category.name[0], "Unfiled") ||
+ strcmp(mai.category.name[1], "Business") ||
+ strcmp(mai.category.name[2], "Personal") ||
+ strcmp(mai.category.name[3], "QuickList") ||
+ strcmp(mai.category.name[4], "Foo") ||
+ strcmp(mai.category.name[5], "") ||
+ strcmp(mai.category.name[6], "") ||
+ strcmp(mai.category.name[7], "") ||
+ strcmp(mai.category.name[8], "") ||
+ strcmp(mai.category.name[9], "") ||
+ strcmp(mai.category.name[10], "") ||
+ strcmp(mai.category.name[11], "") ||
+ strcmp(mai.category.name[12], "") ||
+ strcmp(mai.category.name[13], "") ||
+ strcmp(mai.category.name[14], "") ||
+ strcmp(mai.category.name[15], "") ||
+ mai.category.renamed[0] ||
+ mai.category.renamed[1] ||
+ mai.category.renamed[2] ||
+ mai.category.renamed[3] ||
+ (!mai.category.renamed[4]) ||
+ mai.category.renamed[5] ||
+ mai.category.renamed[6] ||
+ mai.category.renamed[7] ||
+ mai.category.renamed[8] ||
+ mai.category.renamed[9] ||
+ mai.category.renamed[10] ||
+ mai.category.renamed[11] ||
+ mai.category.renamed[12] ||
+ mai.category.renamed[13] ||
+ mai.category.renamed[14] ||
+ mai.category.renamed[15] ||
+ (mai.category.ID[0] != 0) ||
+ (mai.category.ID[1] != 1) ||
+ (mai.category.ID[2] != 2) ||
+ (mai.category.ID[3] != 3) ||
+ (mai.category.ID[4] != 17) ||
+ (mai.category.ID[5] != 0) ||
+ (mai.category.ID[6] != 0) ||
+ (mai.category.ID[7] != 0) ||
+ (mai.category.ID[8] != 0) ||
+ (mai.category.ID[9] != 0) ||
+ (mai.category.ID[10] != 0) ||
+ (mai.category.ID[11] != 0) ||
+ (mai.category.ID[12] != 0) ||
+ (mai.category.ID[13] != 0) ||
+ (mai.category.ID[14] != 0) ||
+ (mai.category.ID[15] != 0) ||
+ (mai.category.lastUniqueID != 17) || 0) {
+ errors++;
+ printf("6: unpack_AddressAppInfo generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_AddressAppInfo(&mai, 0, 0);
+ if (l != sizeof(AddressAppBlock)) {
+ errors++;
+ printf
+ ("7: pack_AddressAppInfo returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(AddressAppBlock));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_AddressAppInfo(&mai, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("8: pack_AddressAppInfo packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(9, target, 8192, 128, 1, "pack_AddressAppInfo"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_AddressAppInfo(&mai, target + 128, 8192 - 256);
+ if (l != sizeof(AddressAppBlock)) {
+ errors++;
+ printf
+ ("10: pack_AddressAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AddressAppBlock));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(11, target, 8192, 128, l, "pack_AddressAppInfo"))
+ errors++;
+
+ if (memcmp(target + 128, AddressAppBlock, sizeof(AddressAppBlock))) {
+ errors++;
+ printf
+ ("12: pack_AddressAppInfo generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(AddressAppBlock, sizeof(AddressAppBlock));
+ }
+
+
+ /* Unpacker should return count of bytes used */
+ RecordBuffer = pi_buffer_new(sizeof(AddressRecord));
+ memcpy(RecordBuffer->data, AddressRecord, RecordBuffer->allocated);
+ RecordBuffer->used=sizeof(AddressRecord);
+ unpack_Address(&m, RecordBuffer, address_v1);
+ pi_buffer_free(RecordBuffer);
+
+ if (
+ (m.phoneLabel[0] != 0) ||
+ (m.phoneLabel[1] != 1) ||
+ (m.phoneLabel[2] != 2) ||
+ (m.phoneLabel[3] != 3) ||
+ (m.phoneLabel[4] != 4) ||
+ strcmp(m.entry[0], "Shaw") ||
+ strcmp(m.entry[1], "Bernard") ||
+ m.entry[2] ||
+ m.entry[3] ||
+ strcmp(m.entry[8], "None known") ||
+ strcmp(m.entry[14], "C1") || (m.showPhone != 1) || 0) {
+ errors++;
+ printf("13: unpack_Address generated incorrect information\n");
+ }
+
+ RecordBuffer = pi_buffer_new(0);
+ if (pack_Address(&m, RecordBuffer, address_v1) != 0) {
+ errors++;
+ printf("14: pack_Address returned failure\n");
+ }
+
+ if (RecordBuffer->used != sizeof(AddressRecord)) {
+ errors++;
+ printf
+ ("15: pack_Address returned incorrect length (got %d, expected %d)\n",
+ RecordBuffer->used, sizeof(AddressRecord));
+ }
+
+ if (memcmp(RecordBuffer->data, AddressRecord, sizeof(AddressRecord))) {
+ errors++;
+ printf("16: pack_Address generated incorrect information. Got:\n");
+ pi_dumpdata(RecordBuffer->data, l);
+ printf(" expected:\n");
+ pi_dumpdata(AddressRecord, sizeof(AddressRecord));
+ }
+
+ pi_buffer_free(RecordBuffer);
+
+ printf("Address packers test completed with %d error(s).\n", errors);
+
+ return errors;
+}
+
+char AppointmentAppBlock[17 * 16 + 8] = "\
+\x00\x00\x55\x6e\x66\x69\x6c\x65\x64\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00";
+
+/* Note: Bytes seven and seventeen ares undefined by the Pilot code,
+ and thus have a floating value. This sample record has
+ been altered to make theses bytes zero, to match what our
+ packing code generates. */
+char AppointmentRecord[2 * 16 + 3] = "\
+\x09\x00\x0d\x28\xbb\x02\x7c\x00\x1d\x02\x02\x00\xbd\x24\x02\x55\
+\x00\x00\x00\x01\xbb\x0c\x47\x65\x6f\x72\x67\x65\x00\x4e\x6f\x74\
+\x65\x21\x00";
+
+
+int test_appointment()
+{
+ struct AppointmentAppInfo mai;
+ struct Appointment m;
+ pi_buffer_t *RecordBuffer;
+ int l;
+ int errors = 0;
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_AppointmentAppInfo(&mai, AppointmentAppBlock,
+ sizeof(AppointmentAppBlock) + 10);
+ if (l != sizeof(AppointmentAppBlock)) {
+ errors++;
+ printf
+ ("1: unpack_AppointmentAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AppointmentAppBlock));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_AppointmentAppInfo(&mai, AppointmentAppBlock,
+ sizeof(AppointmentAppBlock) + 1);
+ if (l != sizeof(AppointmentAppBlock)) {
+ errors++;
+ printf
+ ("2: unpack_AppointmentAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AppointmentAppBlock));
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ l =
+ unpack_AppointmentAppInfo(&mai, AppointmentAppBlock,
+ sizeof(AppointmentAppBlock) - 10);
+ if (l != 0) {
+ errors++;
+ printf
+ ("3: unpack_AppointmentAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ l =
+ unpack_AppointmentAppInfo(&mai, AppointmentAppBlock,
+ sizeof(AppointmentAppBlock) - 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("4: unpack_AppointmentAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_AppointmentAppInfo(&mai, AppointmentAppBlock,
+ sizeof(AppointmentAppBlock));
+ if (l != sizeof(AppointmentAppBlock)) {
+ errors++;
+ printf
+ ("5: unpack_AppointmentAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AppointmentAppBlock));
+ }
+
+ if (
+/* strcmp(mai.category.name[0],"Unfiled") ||
+ strcmp(mai.category.name[1],"Business") ||
+ strcmp(mai.category.name[2],"Personal") ||
+ strcmp(mai.category.name[3],"QuickList") ||
+ strcmp(mai.category.name[4],"Foo") ||
+ strcmp(mai.category.name[5],"") ||
+ strcmp(mai.category.name[6],"") ||
+ strcmp(mai.category.name[7],"") ||
+ strcmp(mai.category.name[8],"") ||
+ strcmp(mai.category.name[9],"") ||
+ strcmp(mai.category.name[10],"") ||
+ strcmp(mai.category.name[11],"") ||
+ strcmp(mai.category.name[12],"") ||
+ strcmp(mai.category.name[13],"") ||
+ strcmp(mai.category.name[14],"") ||
+ strcmp(mai.category.name[15],"") ||
+ mai.category.renamed[0] ||
+ mai.category.renamed[1] ||
+ mai.category.renamed[2] ||
+ mai.category.renamed[3] ||
+ (!mai.category.renamed[4]) ||
+ mai.category.renamed[5] ||
+ mai.category.renamed[6] ||
+ mai.category.renamed[7] ||
+ mai.category.renamed[8] ||
+ mai.category.renamed[9] ||
+ mai.category.renamed[10] ||
+ mai.category.renamed[11] ||
+ mai.category.renamed[12] ||
+ mai.category.renamed[13] ||
+ mai.category.renamed[14] ||
+ mai.category.renamed[15] ||
+ (mai.category.ID[0] != 0) ||
+ (mai.category.ID[1] != 1) ||
+ (mai.category.ID[2] != 2) ||
+ (mai.category.ID[3] != 3) ||
+ (mai.category.ID[4] != 17) ||
+ (mai.category.ID[5] != 0) ||
+ (mai.category.ID[6] != 0) ||
+ (mai.category.ID[7] != 0) ||
+ (mai.category.ID[8] != 0) ||
+ (mai.category.ID[9] != 0) ||
+ (mai.category.ID[10] != 0) ||
+ (mai.category.ID[11] != 0) ||
+ (mai.category.ID[12] != 0) ||
+ (mai.category.ID[13] != 0) ||
+ (mai.category.ID[14] != 0) ||
+ (mai.category.ID[15] != 0) ||
+ (mai.category.lastUniqueID != 17) ||*/
+ 0) {
+ errors++;
+ printf
+ ("6: unpack_AppointmentAppInfo generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_AppointmentAppInfo(&mai, 0, 0);
+ if (l != sizeof(AppointmentAppBlock)) {
+ errors++;
+ printf
+ ("7: pack_AppointmentAppInfo returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(AppointmentAppBlock));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_AppointmentAppInfo(&mai, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("8: pack_AppointmentAppInfo packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(9, target, 8192, 128, 1, "pack_AppointmentAppInfo"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_AppointmentAppInfo(&mai, target + 128, 8192 - 256);
+ if (l != sizeof(AppointmentAppBlock)) {
+ errors++;
+ printf
+ ("10: pack_AppointmentAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(AppointmentAppBlock));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(11, target, 8192, 128, l, "pack_AppointmentAppInfo"))
+ errors++;
+
+ if (memcmp
+ (target + 128, AppointmentAppBlock, sizeof(AppointmentAppBlock))) {
+ errors++;
+ printf
+ ("12: pack_AppointmentAppInfo generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(AppointmentAppBlock, sizeof(AppointmentAppBlock));
+ }
+
+
+ RecordBuffer = pi_buffer_new(sizeof(AppointmentRecord));
+ memcpy(RecordBuffer->data, AppointmentRecord, RecordBuffer->allocated);
+ RecordBuffer->used=sizeof(AppointmentRecord);
+ unpack_Appointment(&m, RecordBuffer, datebook_v1);
+ pi_buffer_free(RecordBuffer);
+
+ if (
+/* (m.phonelabel[0] != 0) ||
+ (m.phonelabel[1] != 1) ||
+ (m.phonelabel[2] != 2) ||
+ (m.phonelabel[3] != 3) ||
+ (m.phonelabel[4] != 4) ||
+ strcmp(m.entry[0],"Shaw") ||
+ strcmp(m.entry[1],"Bernard") ||
+ m.entry[2] ||
+ m.entry[3] ||
+ strcmp(m.entry[8],"None known") ||
+ strcmp(m.entry[14],"C1") ||
+ (m.whichphone != 1) ||*/
+ 0) {
+ errors++;
+ printf("13: unpack_Appointment generated incorrect information\n");
+ }
+
+ RecordBuffer = pi_buffer_new(0);
+ if (pack_Appointment(&m, RecordBuffer, datebook_v1) != 0) {
+ errors++;
+ printf("14: pack_Appointment returned failure\n");
+ }
+
+ if (RecordBuffer->used != sizeof(AppointmentRecord)) {
+ errors++;
+ printf
+ ("15: pack_Appointment returned incorrect length (got %d, expected %d)\n",
+ RecordBuffer->used, sizeof(AppointmentRecord));
+ }
+
+ if (memcmp(RecordBuffer->data, AppointmentRecord, sizeof(AppointmentRecord))) {
+ errors++;
+ printf
+ ("16: pack_Appointment generated incorrect information. Got:\n");
+ pi_dumpdata(RecordBuffer->data, l);
+ printf(" expected:\n");
+ pi_dumpdata(AppointmentRecord, sizeof(AppointmentRecord));
+ }
+
+ printf("Appointment packers test completed with %d error(s).\n",
+ errors);
+
+ return errors;
+}
+
+char ToDoAppBlock[17 * 16 + 10] = "\
+\x00\x08\x55\x6e\x66\x69\x6c\x65\x64\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x42\x75\x73\x69\x6e\x65\x73\x73\x00\x00\x00\x00\x00\x00\
+\x00\x00\x50\x65\x72\x73\x6f\x6e\x61\x6c\x00\x00\x00\x00\x00\x00\
+\x00\x00\x46\x6f\x6f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x01\x02\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x11\x00\x00\x00\xff\xff\x01\x00";
+
+char ToDoRecord[1 * 16 + 1] = "\
+\xbb\x09\x05\x54\x6f\x64\x6f\x33\x00\x41\x20\x6e\x6f\x74\x65\x2e\
+\x00";
+
+int test_todo()
+{
+ struct ToDoAppInfo mai;
+ struct ToDo m;
+ pi_buffer_t *RecordBuffer;
+ int l;
+ int errors = 0;
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_ToDoAppInfo(&mai, ToDoAppBlock, sizeof(ToDoAppBlock) + 10);
+ if (l != sizeof(ToDoAppBlock)) {
+ errors++;
+ printf
+ ("1: unpack_ToDoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ToDoAppBlock));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_ToDoAppInfo(&mai, ToDoAppBlock, sizeof(ToDoAppBlock) + 1);
+ if (l != sizeof(ToDoAppBlock)) {
+ errors++;
+ printf
+ ("2: unpack_ToDoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ToDoAppBlock));
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ l = unpack_ToDoAppInfo(&mai, ToDoAppBlock, sizeof(ToDoAppBlock) - 10);
+ if (l != 0) {
+ errors++;
+ printf
+ ("3: unpack_ToDoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ l = unpack_ToDoAppInfo(&mai, ToDoAppBlock, sizeof(ToDoAppBlock) - 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("4: unpack_ToDoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, 0);
+ }
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_ToDoAppInfo(&mai, ToDoAppBlock, sizeof(ToDoAppBlock));
+ if (l != sizeof(ToDoAppBlock)) {
+ errors++;
+ printf
+ ("5: unpack_ToDoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ToDoAppBlock));
+ }
+
+ if (
+/* strcmp(mai.category.name[0],"Unfiled") ||
+ strcmp(mai.category.name[1],"Business") ||
+ strcmp(mai.category.name[2],"Personal") ||
+ strcmp(mai.category.name[3],"QuickList") ||
+ strcmp(mai.category.name[4],"Foo") ||
+ strcmp(mai.category.name[5],"") ||
+ strcmp(mai.category.name[6],"") ||
+ strcmp(mai.category.name[7],"") ||
+ strcmp(mai.category.name[8],"") ||
+ strcmp(mai.category.name[9],"") ||
+ strcmp(mai.category.name[10],"") ||
+ strcmp(mai.category.name[11],"") ||
+ strcmp(mai.category.name[12],"") ||
+ strcmp(mai.category.name[13],"") ||
+ strcmp(mai.category.name[14],"") ||
+ strcmp(mai.category.name[15],"") ||
+ mai.category.renamed[0] ||
+ mai.category.renamed[1] ||
+ mai.category.renamed[2] ||
+ mai.category.renamed[3] ||
+ (!mai.category.renamed[4]) ||
+ mai.category.renamed[5] ||
+ mai.category.renamed[6] ||
+ mai.category.renamed[7] ||
+ mai.category.renamed[8] ||
+ mai.category.renamed[9] ||
+ mai.category.renamed[10] ||
+ mai.category.renamed[11] ||
+ mai.category.renamed[12] ||
+ mai.category.renamed[13] ||
+ mai.category.renamed[14] ||
+ mai.category.renamed[15] ||
+ (mai.category.ID[0] != 0) ||
+ (mai.category.ID[1] != 1) ||
+ (mai.category.ID[2] != 2) ||
+ (mai.category.ID[3] != 3) ||
+ (mai.category.ID[4] != 17) ||
+ (mai.category.ID[5] != 0) ||
+ (mai.category.ID[6] != 0) ||
+ (mai.category.ID[7] != 0) ||
+ (mai.category.ID[8] != 0) ||
+ (mai.category.ID[9] != 0) ||
+ (mai.category.ID[10] != 0) ||
+ (mai.category.ID[11] != 0) ||
+ (mai.category.ID[12] != 0) ||
+ (mai.category.ID[13] != 0) ||
+ (mai.category.ID[14] != 0) ||
+ (mai.category.ID[15] != 0) ||
+ (mai.category.lastUniqueID != 17) ||*/
+ 0) {
+ errors++;
+ printf("6: unpack_ToDoAppInfo generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_ToDoAppInfo(&mai, 0, 0);
+ if (l != sizeof(ToDoAppBlock)) {
+ errors++;
+ printf
+ ("7: pack_ToDoAppInfo returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(ToDoAppBlock));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_ToDoAppInfo(&mai, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf("8: pack_ToDoAppInfo packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(9, target, 8192, 128, 1, "pack_ToDoAppInfo"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_ToDoAppInfo(&mai, target + 128, 8192 - 256);
+ if (l != sizeof(ToDoAppBlock)) {
+ errors++;
+ printf
+ ("10: pack_ToDoAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ToDoAppBlock));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(11, target, 8192, 128, l, "pack_ToDoAppInfo"))
+ errors++;
+
+ if (memcmp(target + 128, ToDoAppBlock, sizeof(ToDoAppBlock))) {
+ errors++;
+ printf
+ ("12: pack_ToDoAppInfo generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(ToDoAppBlock, sizeof(ToDoAppBlock));
+ }
+
+
+ /* Unpacker should return count of bytes used */
+ RecordBuffer = pi_buffer_new(sizeof(ToDoRecord));
+ memcpy(RecordBuffer->data, ToDoRecord, RecordBuffer->allocated);
+ RecordBuffer->used=sizeof(ToDoRecord);
+ unpack_ToDo(&m, RecordBuffer, todo_v1);
+ pi_buffer_free(RecordBuffer);
+
+ if (
+/* (m.phonelabel[0] != 0) ||
+ (m.phonelabel[1] != 1) ||
+ (m.phonelabel[2] != 2) ||
+ (m.phonelabel[3] != 3) ||
+ (m.phonelabel[4] != 4) ||
+ strcmp(m.entry[0],"Shaw") ||
+ strcmp(m.entry[1],"Bernard") ||
+ m.entry[2] ||
+ m.entry[3] ||
+ strcmp(m.entry[8],"None known") ||
+ strcmp(m.entry[14],"C1") ||
+ (m.whichphone != 1) ||*/
+ 0) {
+ errors++;
+ printf("13: unpack_ToDo generated incorrect information\n");
+ }
+
+ reset_block(target, 8192);
+
+ RecordBuffer = pi_buffer_new(0);
+ if (pack_ToDo(&m, RecordBuffer, todo_v1) != 0) {
+ errors++;
+ printf("14: pack_ToDo returned failure\n");
+ }
+
+ if (RecordBuffer->used != sizeof(ToDoRecord)) {
+ errors++;
+ printf
+ ("15: pack_ToDo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ToDoRecord));
+ }
+
+ if (memcmp(RecordBuffer->data, ToDoRecord, sizeof(ToDoRecord))) {
+ errors++;
+ printf("16: pack_ToDo generated incorrect information. Got:\n");
+ pi_dumpdata(RecordBuffer->data, l);
+ printf(" expected:\n");
+ pi_dumpdata(ToDoRecord, sizeof(ToDoRecord));
+ }
+
+ pi_buffer_free(RecordBuffer);
+
+ printf("ToDo packers test completed with %d error(s).\n", errors);
+
+ return errors;
+}
+
+char ExpenseAppBlock[24 * 16 + 8] = "\
+\x00\x00\x55\x6e\x66\x69\x6c\x65\x64\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x4e\x65\x77\x20\x59\x6f\x72\x6b\x00\x00\x00\x00\x00\x00\
+\x00\x00\x50\x61\x72\x69\x73\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x45\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x01\x02\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00";
+
+/* Byte five is floating */
+char ExpenseRecord[1 * 16 + 14] = "\
+\xbb\x2a\x09\x01\x08\x00\x32\x39\x2e\x37\x32\x00\x55\x00\x43\x00\
+\x41\x74\x74\x00\x54\x68\x65\x20\x6e\x6f\x74\x65\x2e\x00";
+
+
+int test_expense()
+{
+ struct ExpenseAppInfo mai;
+ struct Expense m;
+ int l;
+ int errors = 0;
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_ExpenseAppInfo(&mai, ExpenseAppBlock,
+ sizeof(ExpenseAppBlock) + 10);
+ if (l != sizeof(ExpenseAppBlock)) {
+ errors++;
+ printf
+ ("1: unpack_ExpenseAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ExpenseAppBlock));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_ExpenseAppInfo(&mai, ExpenseAppBlock,
+ sizeof(ExpenseAppBlock) + 1);
+ if (l != sizeof(ExpenseAppBlock)) {
+ errors++;
+ printf
+ ("2: unpack_ExpenseAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ExpenseAppBlock));
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ /*l = unpack_ExpenseAppInfo(&mai, ExpenseAppBlock, sizeof(ExpenseAppBlock)-10);
+ if (l != 0) {
+ errors++;
+ printf("x: unpack_ExpenseAppInfo returned incorrect length (got %d, expected %d)\n", l, 0);
+ } */
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_ExpenseAppInfo(&mai, ExpenseAppBlock,
+ sizeof(ExpenseAppBlock));
+ if (l != sizeof(ExpenseAppBlock)) {
+ errors++;
+ printf
+ ("3: unpack_ExpenseAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ExpenseAppBlock));
+ }
+
+
+ if (
+/* strcmp(mai.category.name[0],"Unfiled") ||
+ strcmp(mai.category.name[1],"Business") ||
+ strcmp(mai.category.name[2],"Personal") ||
+ strcmp(mai.category.name[3],"QuickList") ||
+ strcmp(mai.category.name[4],"Foo") ||
+ strcmp(mai.category.name[5],"") ||
+ strcmp(mai.category.name[6],"") ||
+ strcmp(mai.category.name[7],"") ||
+ strcmp(mai.category.name[8],"") ||
+ strcmp(mai.category.name[9],"") ||
+ strcmp(mai.category.name[10],"") ||
+ strcmp(mai.category.name[11],"") ||
+ strcmp(mai.category.name[12],"") ||
+ strcmp(mai.category.name[13],"") ||
+ strcmp(mai.category.name[14],"") ||
+ strcmp(mai.category.name[15],"") ||
+ mai.category.renamed[0] ||
+ mai.category.renamed[1] ||
+ mai.category.renamed[2] ||
+ mai.category.renamed[3] ||
+ (!mai.category.renamed[4]) ||
+ mai.category.renamed[5] ||
+ mai.category.renamed[6] ||
+ mai.category.renamed[7] ||
+ mai.category.renamed[8] ||
+ mai.category.renamed[9] ||
+ mai.category.renamed[10] ||
+ mai.category.renamed[11] ||
+ mai.category.renamed[12] ||
+ mai.category.renamed[13] ||
+ mai.category.renamed[14] ||
+ mai.category.renamed[15] ||
+ (mai.category.ID[0] != 0) ||
+ (mai.category.ID[1] != 1) ||
+ (mai.category.ID[2] != 2) ||
+ (mai.category.ID[3] != 3) ||
+ (mai.category.ID[4] != 17) ||
+ (mai.category.ID[5] != 0) ||
+ (mai.category.ID[6] != 0) ||
+ (mai.category.ID[7] != 0) ||
+ (mai.category.ID[8] != 0) ||
+ (mai.category.ID[9] != 0) ||
+ (mai.category.ID[10] != 0) ||
+ (mai.category.ID[11] != 0) ||
+ (mai.category.ID[12] != 0) ||
+ (mai.category.ID[13] != 0) ||
+ (mai.category.ID[14] != 0) ||
+ (mai.category.ID[15] != 0) ||
+ (mai.category.lastUniqueID != 17) ||*/
+ 0) {
+ errors++;
+ printf("4: unpack_ExpenseAppInfo generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_ExpenseAppInfo(&mai, 0, 0);
+ if (l != sizeof(ExpenseAppBlock)) {
+ errors++;
+ printf
+ ("5: pack_ExpenseAppInfo returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(ExpenseAppBlock));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_ExpenseAppInfo(&mai, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("6: pack_ExpenseAppInfo packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(7, target, 8192, 128, 1, "pack_ExpenseAppInfo"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_ExpenseAppInfo(&mai, target + 128, 8192 - 256);
+ if (l != sizeof(ExpenseAppBlock)) {
+ errors++;
+ printf
+ ("8: pack_ExpenseAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ExpenseAppBlock));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(9, target, 8192, 128, l, "pack_ExpenseAppInfo"))
+ errors++;
+
+ if (memcmp(target + 128, ExpenseAppBlock, sizeof(ExpenseAppBlock))) {
+ errors++;
+ printf
+ ("10: pack_ExpenseAppInfo generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(ExpenseAppBlock, sizeof(ExpenseAppBlock));
+ }
+
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_Expense(&m, ExpenseRecord, sizeof(ExpenseRecord) + 10);
+ if (l != sizeof(ExpenseRecord)) {
+ errors++;
+ printf
+ ("11: unpack_Expense returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ExpenseRecord));
+ }
+
+ if (
+/* (m.phonelabel[0] != 0) ||
+ (m.phonelabel[1] != 1) ||
+ (m.phonelabel[2] != 2) ||
+ (m.phonelabel[3] != 3) ||
+ (m.phonelabel[4] != 4) ||
+ strcmp(m.entry[0],"Shaw") ||
+ strcmp(m.entry[1],"Bernard") ||
+ m.entry[2] ||
+ m.entry[3] ||
+ strcmp(m.entry[8],"None known") ||
+ strcmp(m.entry[14],"C1") ||
+ (m.whichphone != 1) ||*/
+ 0) {
+ errors++;
+ printf("12: unpack_Expense generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_Expense(&m, 0, 0);
+ if (l != sizeof(ExpenseRecord)) {
+ errors++;
+ printf
+ ("13: pack_Expense returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(ExpenseRecord));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_Expense(&m, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf("14: pack_Expense packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(15, target, 8192, 128, 1, "pack_Expense"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_Expense(&m, target + 128, 8192 - 256);
+ if (l != sizeof(ExpenseRecord)) {
+ errors++;
+ printf
+ ("16: pack_Expense returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(ExpenseRecord));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(17, target, 8192, 128, l, "pack_Expense"))
+ errors++;
+
+ if (memcmp(target + 128, ExpenseRecord, sizeof(ExpenseRecord))) {
+ errors++;
+ printf("18: pack_Expense generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(ExpenseRecord, sizeof(ExpenseRecord));
+ }
+
+ printf("Expense packers test completed with %d error(s).\n", errors);
+
+ return errors;
+}
+
+char MailAppBlock[18 * 16 + 1] = "\
+\x00\x1f\x49\x6e\x62\x6f\x78\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x4f\x75\x74\x62\x6f\x78\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x44\x65\x6c\x65\x74\x65\x64\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x46\x69\x6c\x65\x64\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x44\x72\x61\x66\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
+\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\
+\x0e\x0f\x0f\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x01\x20\
+\x00";
+
+char MailRecord[1 * 16 + 2] = "\
+\x00\x00\x00\x00\x78\x00\x43\x00\x00\x61\x00\x62\x00\x00\x00\x00\
+\x44\x00"; /*\x27"; This byte seems to be spurious */
+
+char MailSigPreference[3] = "\
+\x61\x62\x00";
+
+char MailSyncPreference[13] = "\
+\x02\x01\x00\x00\x17\x70\x61\x74\x00\x6c\x64\x00\x00";
+
+int test_mail()
+{
+ struct MailAppInfo mai;
+ struct Mail m;
+ struct MailSyncPref s1;
+ struct MailSignaturePref s2;
+ int l;
+ int errors = 0;
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_MailAppInfo(&mai, MailAppBlock, sizeof(MailAppBlock) + 10);
+ if (l != sizeof(MailAppBlock)) {
+ errors++;
+ printf
+ ("1: unpack_MailAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailAppBlock));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_MailAppInfo(&mai, MailAppBlock, sizeof(MailAppBlock) + 1);
+ if (l != sizeof(MailAppBlock)) {
+ errors++;
+ printf
+ ("2: unpack_MailAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailAppBlock));
+ }
+
+ /* Unpacker should return failure if the block is too small to contain data */
+ /*l = unpack_MailAppInfo(&mai, MailAppBlock, sizeof(MailAppBlock)-10);
+ if (l != 0) {
+ errors++;
+ printf("2: unpack_MailAppInfo returned incorrect length (got %d, expected %d)\n", l, 0);
+ } */
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_MailAppInfo(&mai, MailAppBlock, sizeof(MailAppBlock));
+ if (l != sizeof(MailAppBlock)) {
+ errors++;
+ printf
+ ("3: unpack_MailAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailAppBlock));
+ }
+
+
+ if (
+/* strcmp(mai.category.name[0],"Unfiled") ||
+ strcmp(mai.category.name[1],"Business") ||
+ strcmp(mai.category.name[2],"Personal") ||
+ strcmp(mai.category.name[3],"QuickList") ||
+ strcmp(mai.category.name[4],"Foo") ||
+ strcmp(mai.category.name[5],"") ||
+ strcmp(mai.category.name[6],"") ||
+ strcmp(mai.category.name[7],"") ||
+ strcmp(mai.category.name[8],"") ||
+ strcmp(mai.category.name[9],"") ||
+ strcmp(mai.category.name[10],"") ||
+ strcmp(mai.category.name[11],"") ||
+ strcmp(mai.category.name[12],"") ||
+ strcmp(mai.category.name[13],"") ||
+ strcmp(mai.category.name[14],"") ||
+ strcmp(mai.category.name[15],"") ||
+ mai.category.renamed[0] ||
+ mai.category.renamed[1] ||
+ mai.category.renamed[2] ||
+ mai.category.renamed[3] ||
+ (!mai.category.renamed[4]) ||
+ mai.category.renamed[5] ||
+ mai.category.renamed[6] ||
+ mai.category.renamed[7] ||
+ mai.category.renamed[8] ||
+ mai.category.renamed[9] ||
+ mai.category.renamed[10] ||
+ mai.category.renamed[11] ||
+ mai.category.renamed[12] ||
+ mai.category.renamed[13] ||
+ mai.category.renamed[14] ||
+ mai.category.renamed[15] ||
+ (mai.category.ID[0] != 0) ||
+ (mai.category.ID[1] != 1) ||
+ (mai.category.ID[2] != 2) ||
+ (mai.category.ID[3] != 3) ||
+ (mai.category.ID[4] != 17) ||
+ (mai.category.ID[5] != 0) ||
+ (mai.category.ID[6] != 0) ||
+ (mai.category.ID[7] != 0) ||
+ (mai.category.ID[8] != 0) ||
+ (mai.category.ID[9] != 0) ||
+ (mai.category.ID[10] != 0) ||
+ (mai.category.ID[11] != 0) ||
+ (mai.category.ID[12] != 0) ||
+ (mai.category.ID[13] != 0) ||
+ (mai.category.ID[14] != 0) ||
+ (mai.category.ID[15] != 0) ||
+ (mai.category.lastUniqueID != 17) ||*/
+ 0) {
+ errors++;
+ printf("4: unpack_MailAppInfo generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_MailAppInfo(&mai, 0, 0);
+ if (l != sizeof(MailAppBlock)) {
+ errors++;
+ printf
+ ("5: pack_MailAppInfo returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(MailAppBlock));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_MailAppInfo(&mai, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf("6: pack_MailAppInfo packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(7, target, 8192, 128, 1, "pack_MailAppInfo"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_MailAppInfo(&mai, target + 128, 8192 - 256);
+ if (l != sizeof(MailAppBlock)) {
+ errors++;
+ printf
+ ("8: pack_MailAppInfo returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailAppBlock));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(9, target, 8192, 128, l, "pack_MailAppInfo"))
+ errors++;
+
+ if (memcmp(target + 128, MailAppBlock, sizeof(MailAppBlock))) {
+ errors++;
+ printf
+ ("10: pack_MailAppInfo generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(MailAppBlock, sizeof(MailAppBlock));
+ }
+
+
+ /* Unpacker should return count of bytes used */
+ l = unpack_Mail(&m, MailRecord, sizeof(MailRecord) + 10);
+ if (l != sizeof(MailRecord)) {
+ errors++;
+ printf
+ ("11: unpack_Mail returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailRecord));
+ }
+
+ if (
+/* (m.phonelabel[0] != 0) ||
+ (m.phonelabel[1] != 1) ||
+ (m.phonelabel[2] != 2) ||
+ (m.phonelabel[3] != 3) ||
+ (m.phonelabel[4] != 4) ||
+ strcmp(m.entry[0],"Shaw") ||
+ strcmp(m.entry[1],"Bernard") ||
+ m.entry[2] ||
+ m.entry[3] ||
+ strcmp(m.entry[8],"None known") ||
+ strcmp(m.entry[14],"C1") ||
+ (m.whichphone != 1) ||*/
+ 0) {
+ errors++;
+ printf("12: unpack_Mail generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_Mail(&m, 0, 0);
+ if (l != sizeof(MailRecord)) {
+ errors++;
+ printf
+ ("13: pack_Mail returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(MailRecord));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_Mail(&m, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf("14: pack_Mail packed into too small buffer (got %d)\n", l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(15, target, 8192, 128, 1, "pack_Mail"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_Mail(&m, target + 128, 8192 - 256);
+ if (l != sizeof(MailRecord)) {
+ errors++;
+ printf
+ ("16: pack_Mail returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailRecord));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(17, target, 8192, 128, l, "pack_Mail"))
+ errors++;
+
+ if (memcmp(target + 128, MailRecord, sizeof(MailRecord))) {
+ errors++;
+ printf("18: pack_Mail generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(MailRecord, sizeof(MailRecord));
+ }
+
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_MailSyncPref(&s1, MailSyncPreference,
+ sizeof(MailSyncPreference) + 10);
+ if (l != sizeof(MailSyncPreference)) {
+ errors++;
+ printf
+ ("19: unpack_MailSyncPref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_MailSyncPref(&s1, MailSyncPreference,
+ sizeof(MailSyncPreference) + 1);
+ if (l != sizeof(MailSyncPreference)) {
+ errors++;
+ printf
+ ("20: unpack_MailSyncPref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_MailSyncPref(&s1, MailSyncPreference,
+ sizeof(MailSyncPreference));
+ if (l != sizeof(MailSyncPreference)) {
+ errors++;
+ printf
+ ("21: unpack_MailSyncPref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ if (
+/* (m.phonelabel[0] != 0) ||
+ (m.phonelabel[1] != 1) ||
+ (m.phonelabel[2] != 2) ||
+ (m.phonelabel[3] != 3) ||
+ (m.phonelabel[4] != 4) ||
+ strcmp(m.entry[0],"Shaw") ||
+ strcmp(m.entry[1],"Bernard") ||
+ m.entry[2] ||
+ m.entry[3] ||
+ strcmp(m.entry[8],"None known") ||
+ strcmp(m.entry[14],"C1") ||
+ (m.whichphone != 1) ||*/
+ 0) {
+ errors++;
+ printf("22: unpack_MailSyncPref generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_MailSyncPref(&s1, 0, 0);
+ if (l != sizeof(MailSyncPreference)) {
+ errors++;
+ printf
+ ("23: pack_MailSyncPref returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_MailSyncPref(&s1, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("24: pack_MailSyncPref packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(25, target, 8192, 128, 1, "pack_MailSyncPref"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_MailSyncPref(&s1, target + 128, 8192 - 256);
+ if (l != sizeof(MailSyncPreference)) {
+ errors++;
+ printf
+ ("26: pack_MailSyncPref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(27, target, 8192, 128, l, "pack_Mail"))
+ errors++;
+
+ if (memcmp
+ (target + 128, MailSyncPreference, sizeof(MailSyncPreference))) {
+ errors++;
+ printf
+ ("28: pack_MailSyncPref generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(MailSyncPreference, sizeof(MailSyncPreference));
+ }
+
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_MailSignaturePref(&s2, MailSigPreference,
+ sizeof(MailSigPreference) + 10);
+ if (l != sizeof(MailSigPreference)) {
+ errors++;
+ printf
+ ("29: unpack_MailSigPref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_MailSignaturePref(&s2, MailSigPreference,
+ sizeof(MailSigPreference) + 1);
+ if (l != sizeof(MailSigPreference)) {
+ errors++;
+ printf
+ ("30: unpack_MailSigPref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ /* Unpacker should return count of bytes used */
+ l =
+ unpack_MailSignaturePref(&s2, MailSigPreference,
+ sizeof(MailSigPreference));
+ if (l != sizeof(MailSigPreference)) {
+ errors++;
+ printf
+ ("31: unpack_MailSigPref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSyncPreference));
+ }
+
+ if (
+/* (m.phonelabel[0] != 0) ||
+ (m.phonelabel[1] != 1) ||
+ (m.phonelabel[2] != 2) ||
+ (m.phonelabel[3] != 3) ||
+ (m.phonelabel[4] != 4) ||
+ strcmp(m.entry[0],"Shaw") ||
+ strcmp(m.entry[1],"Bernard") ||
+ m.entry[2] ||
+ m.entry[3] ||
+ strcmp(m.entry[8],"None known") ||
+ strcmp(m.entry[14],"C1") ||
+ (m.whichphone != 1) ||*/
+ 0) {
+ errors++;
+ printf("32: unpack_MailSyncPref generated incorrect information\n");
+ }
+
+ /* Packer should return necessary block length when no buffer is given */
+ l = pack_MailSignaturePref(&s2, 0, 0);
+ if (l != sizeof(MailSigPreference)) {
+ errors++;
+ printf
+ ("33: pack_MailSignaturePref returned incorrect allocation length (got %d, expected %d)\n",
+ l, sizeof(MailSigPreference));
+ }
+
+ reset_block(target, 8192);
+
+ /* Packer should not pack when the block length is too small */
+ l = pack_MailSignaturePref(&s2, target + 128, 1);
+ if (l != 0) {
+ errors++;
+ printf
+ ("34: pack_MailSignaturePref packed into too small buffer (got %d)\n",
+ l);
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(35, target, 8192, 128, 1, "pack_MailSyncPref"))
+ errors++;
+
+ reset_block(target, 8192);
+
+ /* Packer should return length of data written */
+ l = pack_MailSignaturePref(&s2, target + 128, 8192 - 256);
+ if (l != sizeof(MailSigPreference)) {
+ errors++;
+ printf
+ ("36: pack_MailSignaturePref returned incorrect length (got %d, expected %d)\n",
+ l, sizeof(MailSigPreference));
+ }
+
+ /* Packer should not scribble on memory */
+ if (check_block(37, target, 8192, 128, l, "pack_Mail"))
+ errors++;
+
+ if (memcmp(target + 128, MailSigPreference, sizeof(MailSigPreference))) {
+ errors++;
+ printf
+ ("38: pack_MailSignaturePref generated incorrect information. Got:\n");
+ pi_dumpdata(target + 128, l);
+ printf(" expected:\n");
+ pi_dumpdata(MailSigPreference, sizeof(MailSigPreference));
+ }
+
+ printf("Mail packers test completed with %d error(s).\n", errors);
+
+ return errors;
+}
+
+
+int main(int argc, char *argv[])
+{
+ seed = time(0) & 0xff; /* Make scribble checker use a random check value */
+ target = malloc(8192);
+ targetlen = 8192;
+
+ test_memo();
+ test_address();
+ test_appointment();
+ test_todo();
+ test_expense();
+ test_mail();
+ return 0;
+}
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/versamail-test.c b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/versamail-test.c
new file mode 100644
index 00000000..4e1ce265
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/versamail-test.c
@@ -0,0 +1,222 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "pi-file.h"
+#include "pi-versamail.h"
+
+size_t palm_strftime(char *s, size_t max, const char *fmt, const struct tm *tm);
+
+void hex_dump(unsigned char *buf, int size)
+{
+ char text[18];
+ int i;
+
+ bzero(text, 17);
+
+ for (i = 0; i < size; i++) {
+ printf("%02x ", buf[i]);
+ text[i % 16] = (isprint(buf[i]) ? buf[i] : '.');
+ if ((i + 1) % 16 == 0) {
+ printf("%s\n", text);
+ bzero(text, 17);
+ }
+ }
+ printf("\n");
+}
+
+int print_cat_info(struct CategoryAppInfo *ai)
+{
+ int i;
+
+ printf("Category Info Start\n");
+ printf("renamed=");
+ for (i = 0; i < 16; i++) {
+ printf("%d", ai->renamed[i]);
+ }
+ printf("\n");
+ for (i = 0; i < 16; i++) {
+ printf("Index %02d ID %03d %s\n", i, ai->ID[i],
+ ai->name[i]);
+ }
+ printf("lastUniqueID = %d\n", ai->lastUniqueID);
+ printf("Category Info End\n");
+ return 0;
+}
+
+int print_versamail_app_info(int db, void *record, int size)
+{
+ struct VersaMailAppInfo ai;
+
+ printf("Category app info\n"); //undo
+ //hex_dump(record, size);//undo
+ unpack_VersaMailAppInfo(&ai, record, size);
+ print_cat_info(&(ai.category));
+
+ return 0;
+}
+
+
+void print_versamail_record(void *record, int size, int attr, int idx)
+{
+ struct VersaMail mail;
+ char datestr[255];
+
+ unpack_VersaMail(&mail, record, size);
+
+ printf("----\n");
+ printf("version: %lu\n", mail.imapuid);
+ palm_strftime(datestr, 254, "%c", &(mail.date));
+ //printf("date: %s\n", datestr);
+ //printf("category: %d\n", mail.category);
+ //printf("account: %d\n", mail.accountNo);
+ printf("unknown1: %d\n", mail.unknown1);
+ printf("unknown2: %d\n", mail.unknown2);
+ printf("reserved1: %d\n", mail.reserved1);
+ printf("reserved2: %d\n", mail.reserved2);
+ printf("download: %d\n", mail.download);
+ printf("mark: %d\n", mail.mark);
+ printf("read: %d\n", mail.read);
+ printf("body: %s\n", mail.body);
+ //printf("to: %s\n", mail.to);
+ //printf("from: %s\n", mail.from);
+ //printf("cc: %s\n", mail.cc);
+ //printf("bcc: %s\n", mail.bcc);
+ printf("subject: %s\n", mail.subject);
+ //printf("dateString: %s\n", mail.dateString);
+ //printf("replyTo: %s\n", mail.replyTo);
+
+ free_VersaMail(&mail);
+}
+
+void validate_versamail_packer(void *record, int size, int attr, int idx)
+{
+ struct VersaMail mail;
+ char *buffer;
+ int len;
+ int i;
+
+ unpack_VersaMail(&mail, record, size);
+ len = pack_VersaMail(&mail, NULL, 0);
+ buffer = malloc(len);
+ pack_VersaMail(&mail, buffer, len);
+
+ /* printf("-------------\n"); */
+ if (size - len != 0) {
+ printf
+ ("on-disk size is %d, pack asked for %d to repack, wrong by %d.\n",
+ size, len, size - len);
+ }
+ printf("subject: %s\n", mail.subject);
+ printf(" attachment count: %d\n", mail.attachmentCount);
+
+ if (0) {
+ printf("uid: %d\n", (int) mail.imapuid);
+ printf("size: %d\n", mail.msgSize);
+ printf("unknown1: %d\n", mail.unknown1);
+ printf("unknown2: %d\n", mail.unknown2);
+ printf("reserved1: %d\n", mail.reserved1);
+ printf("reserved2: %d\n", mail.reserved2);
+ printf("download: %d\n", mail.download);
+ printf("mark: %d\n", mail.mark);
+ /*
+ printf("body: %s\n", mail.body);
+ printf("dateString: %s\n", mail.dateString);
+ printf("replyTo: %s\n", mail.replyTo);
+ */
+ }
+
+ if (0) {
+ if (mail.unknown3length > 0) {
+ for (i = 0; i < mail.unknown3length; i++) {
+ printf
+ ("unknown attachment system Byte %3d: 0x%10x | %c | %6d\n",
+ i, ((char *) mail.unknown3)[i],
+ (isprint(((char *) mail.unknown3)[i])
+ ? ((char *) mail.unknown3)[i] : '.'),
+ ((char *) mail.unknown3)[i]);
+ }
+ }
+ }
+
+
+ for (i = 0; i < ((size) > (len) ? (size) : (len)); i++) {
+ if ((i < len) && (i < size)) {
+ if (!((char *) record)[i] == buffer[i]) {
+ printf
+ ("WRONG Byte %3d: 0x%10x (%c) vs. 0x%10x (%c)\n",
+ i, ((char *) record)[i],
+ (isprint(((char *) record)[i])
+ ? ((char *) record)[i] : '.'),
+ buffer[i],
+ (isprint(buffer[i]) ? buffer[i] :
+ '.'));
+ } else {
+ if (0) {
+ printf
+ (" OK Byte %3d: 0x%10x (%c) vs. 0x%10x (%c)\n",
+ i, ((char *) record)[i],
+ (isprint(((char *) record)[i])
+ ? ((char *) record)[i] :
+ '.'), buffer[i],
+ (isprint(buffer[i]) ?
+ buffer[i] : '.'));
+ }
+ }
+ } else if (i < len) {
+ printf
+ ("WRONG Byte %3d: ----------- vs. 0x%10x (%c)\n",
+ i, buffer[i],
+ (isprint(buffer[i]) ? buffer[i] : '.'));
+ } else if (i < size) {
+ printf
+ ("WRONG Byte %3d: 0x%10x (%c) vs. -----------\n",
+ i + 1, ((char *) record)[i],
+ (isprint(((char *) record)[i])
+ ? ((char *) record)[i] : '.'));
+ }
+ }
+ free(buffer);
+ free_VersaMail(&mail);
+
+}
+
+int main(int argc, char *argv[])
+{
+ struct pi_file *pi_fp;
+ char *DBname;
+ int r;
+ int idx;
+ size_t size;
+ int attr;
+ int cat;
+ recordid_t uid;
+ void *record;
+
+ DBname = "MultiMail Messages.pdb";
+
+ pi_fp = pi_file_open(DBname);
+ if (pi_fp == 0) {
+ printf("Unable to open '%s'!\n", DBname);
+ return -1;
+ }
+
+ pi_file_get_app_info PI_ARGS((pi_fp, &record, &size));
+
+ print_versamail_app_info(r, record, size);
+ printf("----------\n");
+
+ for (idx = 0;; idx++) {
+ r = pi_file_read_record(pi_fp, idx, &record, &size, &attr,
+ &cat, &uid);
+ if (r < 0)
+ break;
+ //print_versamail_record(record, size, attr, idx);
+ validate_versamail_packer(record, size, attr, idx);
+ }
+
+ pi_file_close(pi_fp);
+
+ return 0;
+}
diff --git a/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/vfs-test.c b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/vfs-test.c
new file mode 100644
index 00000000..0e617c76
--- /dev/null
+++ b/debian/pilot-link/pilot-link-0.12.5-dfsg/tests/vfs-test.c
@@ -0,0 +1,461 @@
+/*
+ * vfs-test.c: VFS Regression Test
+ *
+ * (c) 2002, JP Rosevear.
+ * (c) 2004, Florent Pillet
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * This regression test calls every DLP function except the following:
+ * dlp_CallApplication
+ * dlp_ResetSystem
+ * dlp_ProcessRPC
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "pi-debug.h"
+#include "pi-socket.h"
+#include "pi-dlp.h"
+#include "pi-error.h"
+#include "pi-source.h"
+#include "pi-header.h"
+
+
+/* For various protocol versions, set to 0 to not test those versions */
+#define DLP_1_1 1
+#define DLP_1_2 1
+#define DLP_1_3 1
+
+/* Logging defines */
+#define CHECK_RESULT(func) \
+ if (result < 0) { \
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "VFSTEST " #func " failed (%d, last palmos error: 0x%04x)\n", result, pi_palmos_error(sd))); \
+ if (result == PI_ERR_SOCK_DISCONNECTED) \
+ goto error; \
+ }
+
+#define TEST_VFS_DIR "/vfs-test"
+#define TEST_VFS_FILE "/vfs-test/test.dat"
+#define TEST_VFS_FILE2 "/vfs-test/test2.dat"
+#define TEST_VFS_FILE2_SHORT "test2.dat"
+#define BIG_FILE_SIZE (2 * 1024 * 1024) /* test vfs read/write with 1Mb data */
+
+int main (int argc, char **argv)
+{
+ int i,
+ j,
+ sd,
+ result,
+ refs[200],
+ ref_length,
+ len,
+ numStrings;
+ char *strings;
+ FileRef fileRef;
+ unsigned long fileAttrs;
+ unsigned char *buf1;
+
+ time_t t1, t2;
+ char name[255],
+ oldName[255];
+
+ unsigned long flags;
+
+ sd = pilot_connect (argv[1]);
+ if (sd < 0) return 1;
+
+ t1 = time (NULL);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "VFSTEST Starting at %s", ctime (&t1)));
+
+ /*********************************************************************
+ *
+ * Test: Expansion
+ *
+ * Direct Testing Functions:
+ * dlp_ExpSlotEnumerate
+ * dlp_ExpCardPresent
+ * dlp_ExpCardInfo
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+#if DLP_1_3
+ ref_length = sizeof (refs) / sizeof (refs[0]);
+ result = dlp_ExpSlotEnumerate (sd, &ref_length, refs);
+ CHECK_RESULT(dlp_ExpSlotEnumerate);
+
+ for (i = 0; i < ref_length; i++) {
+ result = dlp_ExpCardPresent (sd, refs[i]);
+ if (result == PI_ERR_DLP_PALMOS) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "* dlp_ExpCardPresent: card not present in slot %d, PalmOS err 0x%04x\n", i, pi_palmos_error(sd)));
+ } else {
+ CHECK_RESULT(dlp_ExpCardPresent);
+ if (result >= 0) {
+ strings = NULL;
+ result = dlp_ExpCardInfo (sd, refs[i], &flags, &numStrings, &strings);
+ CHECK_RESULT(dlp_ExpCardInfo);
+
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Expansion card {%d}: "
+ "capabilities = 0x%08lx, numStrings = %d\n", refs[i], flags, numStrings));
+
+ if (strings) {
+ char *p = strings;
+ for (j = 0; j < numStrings; j++) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "\tstring[%d] = '%s'\n", j, p));
+ p += strlen (p) + 1;
+ }
+ free (strings);
+ }
+ }
+ }
+ }
+#endif
+
+ /*********************************************************************
+ *
+ * Test: VFS Volumes, files and directories
+ *
+ * Direct Testing Functions:
+ * dlp_VFSDirCreate
+ * dlp_VFSDirEntryEnumerate
+ * dlp_VFSFileClose
+ * dlp_VFSFileCreate
+ * dlp_VFSFileDelete
+ * dlp_VFSFileEOF
+ * dlp_VFSFileGetAttributes
+ * dlp_VFSFileGetDate
+ * dlp_VFSFileOpen
+ * dlp_VFSFileRead
+ * dlp_VFSFileRename
+ * dlp_VFSFileResize
+ * dlp_VFSFileSeek
+ * dlp_VFSFileSetAttributes
+ * dlp_VFSFileSetDate
+ * dlp_VFSFileSize
+ * dlp_VFSFileTell
+ * dlp_VFSFileWrite
+ * dlp_VFSGetDefaultDir
+ * dlp_VFSVolumeEnumerate
+ * dlp_VFSVolumeGetLabel
+ * dlp_VFSVolumeInfo
+ * dlp_VFSVolumeSetLabel
+ * dlp_VFSVolumeSize
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+#if DLP_1_3
+ ref_length = sizeof (refs) / sizeof (refs[0]);
+ result = dlp_VFSVolumeEnumerate (sd, &ref_length, refs);
+ CHECK_RESULT(dlp_VFSVolumeEnumerate);
+
+ for (i = 0; i < ref_length; i++) {
+ struct VFSInfo vfs;
+ long used, total;
+
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "\nTESTING VOLUME %d/%d {ref=%d}\n\n", i+1, ref_length, refs[i]));
+
+ result = dlp_VFSVolumeInfo (sd, refs[i], &vfs);
+ CHECK_RESULT(dlp_VFSVolumeInfo);
+ if (result >= 0) {
+ name[0] = 0;
+ if (vfs.attributes & 0x00000004)
+ strcpy (name, "hidden ");
+ if (vfs.attributes & 0x00000002)
+ strcat (name, "read-only ");
+ if (vfs.attributes & 0x00000001)
+ strcat (name, "slot-based");
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Volume attributes:\n\tattributes: %s\n", name));
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "\tfsType: '%4.4s'\n\tfsCreator: '%4.4s'\n\tmountClass: '%4.4s'\n", &vfs.fsType, &vfs.fsCreator, &vfs.mountClass));
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "\tslotLibRefNum: %d\n\tslotRefNum: %d\n\tmediaType: '%4.4s'\n\n", vfs.slotLibRefNum, vfs.slotRefNum, &vfs.mediaType));
+ }
+
+ result = dlp_VFSVolumeSize (sd, refs[i], &used, &total);
+ CHECK_RESULT(dlp_VFSVolumeSize);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* volume used: %ld / %ld bytes\n", used, total));
+ }
+
+ /* volume label test */
+ len = sizeof (name);
+ result = dlp_VFSVolumeGetLabel (sd, refs[i], &len, name);
+ CHECK_RESULT(dlp_VFSVolumeGetLabel);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* volume label: '%s'\n", name));
+ }
+ strcpy (oldName, name);
+
+ result = dlp_VFSVolumeSetLabel (sd, refs[i], "Test");
+ CHECK_RESULT(dlp_VFSVolumeSetLabel);
+ if (result >= 0) {
+ len = sizeof (name);
+ result = dlp_VFSVolumeGetLabel (sd, refs[i], &len, name);
+ CHECK_RESULT(dlp_VFSVolumeGetLabel);
+ if (result >= 0) {
+ if (strcmp("Test", name)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_ERR, "* ERROR: Label change mismatch\n"));
+ } else {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Label change successful\n"));
+ }
+ }
+
+ result = dlp_VFSVolumeSetLabel (sd, refs[i], oldName);
+ CHECK_RESULT(dlp_VFSVolumeSetLabel);
+ }
+
+ /* directory listing test */
+ len = sizeof (name);
+ result = dlp_VFSGetDefaultDir (sd, refs[i], ".prc", name, &len);
+ CHECK_RESULT(dlp_VFSGetDefaultDir);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Listing directory contents at '%s'\n", name));
+
+ result = dlp_VFSFileOpen (sd, refs[i], name, 0x0007 /* vfsModeReadWrite */, &fileRef);
+ CHECK_RESULT(dlp_VFSFileOpen);
+ if (result >= 0) {
+ unsigned long dirIterator = vfsIteratorStart;
+ do {
+ struct VFSDirInfo dirItems[16];
+ int dirCount;
+
+ memset (dirItems, 0, sizeof(dirItems));
+ dirCount = 16;
+ result = dlp_VFSDirEntryEnumerate (sd, fileRef, &dirIterator, &dirCount, dirItems);
+ CHECK_RESULT(dlp_VFSDirEntryEnumerate);
+
+ if (result >= 0) {
+ for (j = 0; j < dirCount; j++) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "\t'%s' attrs = 0x%08lx\n", dirItems[j].name, dirItems[j].attr));
+ }
+ }
+ } while (dirIterator != vfsIteratorStop && result >= 0);
+
+ result = dlp_VFSFileClose (sd, fileRef);
+ CHECK_RESULT(dlp_VFSFileClose);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Closed directory %s\n", name));
+ }
+ }
+
+ /* directory creation test */
+ result = dlp_VFSDirCreate (sd, refs[i], "/vfs-test");
+ CHECK_RESULT(dlp_VFSDirCreate);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Created directory %s\n", TEST_VFS_DIR));
+
+ /* file access tests */
+ result = dlp_VFSFileCreate (sd, refs[i], TEST_VFS_FILE);
+ CHECK_RESULT(dlp_VFSFileCreate);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Created file %s\n", TEST_VFS_FILE));
+
+ result = dlp_VFSFileOpen (sd, refs[i], TEST_VFS_FILE, 0x0007 /* read-write */, &fileRef);
+ CHECK_RESULT(dlp_VFSFileOpen);
+ if (result >= 0) {
+ pi_buffer_t *fileBuf =
+ pi_buffer_new (BIG_FILE_SIZE);
+
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Opened file %s\n", TEST_VFS_FILE));
+
+ strcpy (name, "a test string written to a file\n");
+ result = dlp_VFSFileWrite (sd, fileRef, (unsigned char *)name, strlen (name));
+ CHECK_RESULT(dlp_VFSFileWrite);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Wrote small string to file %s\n", TEST_VFS_FILE));
+
+ result = dlp_VFSFileTell (sd, fileRef, &j);
+ CHECK_RESULT(dlp_VFSFileTell);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Current seek position: %d\n", j));
+ }
+
+ result = dlp_VFSFileSeek (sd, fileRef, vfsOriginBeginning, 0);
+ CHECK_RESULT(dlp_VFSFileSeek);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Seeked to beginning of file\n", j));
+ }
+
+ result = dlp_VFSFileRead (sd, fileRef, fileBuf, strlen(name));
+ CHECK_RESULT(dlp_VFSFileRead);
+ if (fileBuf->used != strlen (name)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* ERROR: File read: read %d instead of the expected %d\n", len, strlen (name)));
+ } else if (memcmp (name, fileBuf->data, fileBuf->used)) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* ERROR: File read: read data mismatch\n", fileBuf->used, strlen (name)));
+ pi_dumpdata (name, fileBuf->used);
+ pi_dumpdata (fileBuf->data, fileBuf->used);
+ } else {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* File read: successfully read the data back\n"));
+ }
+ }
+
+ /* huge file write/read test - allocate a big buffer,
+ don't clean it (keep the garbage), write it to the
+ file and read it back them compare */
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Please wait, writing %ld bytes of data to the file...\n", (long)BIG_FILE_SIZE));
+ buf1 = (unsigned char *)malloc (BIG_FILE_SIZE);
+ if (buf1) {
+ result = dlp_VFSFileWrite (sd, fileRef, buf1, BIG_FILE_SIZE);
+ CHECK_RESULT(dlp_VFSFileWrite);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Successful, now reading it back...\n"));
+
+ result = dlp_VFSFileSeek (sd, fileRef, vfsOriginCurrent, -BIG_FILE_SIZE);
+ CHECK_RESULT(dlp_VFSFileSeek);
+
+ result = dlp_VFSFileRead (sd, fileRef, fileBuf, BIG_FILE_SIZE);
+ CHECK_RESULT(dlp_VFSFileRead);
+ if (result >= 0) {
+ if (fileBuf->used != BIG_FILE_SIZE || memcmp (buf1, fileBuf->data, BIG_FILE_SIZE))
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* ERROR, data differs!\n"));
+ else
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Successful, all bytes are the same...\n"));
+ }
+ }
+ }
+ if (buf1)
+ free (buf1);
+ pi_buffer_free (fileBuf);
+
+ result = dlp_VFSFileEOF (sd, fileRef);
+ if (pi_palmos_error(sd) == 0x2A07) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* File EOF: YES\n"));
+ } else if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* File EOF: NO\n"));
+ } else {
+ CHECK_RESULT(dlp_VFSFileEOF);
+ }
+
+ result = dlp_VFSFileSize (sd, fileRef, &len);
+ CHECK_RESULT(dlp_VFSFileSize);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* File size: %d bytes\n", len));
+ }
+
+ result = dlp_VFSFileGetAttributes (sd, fileRef, &fileAttrs);
+ CHECK_RESULT(dlp_VFSFileGetAttributes);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* File attributes: 0x%08lx\n", fileAttrs));
+ }
+
+ fileAttrs |= 0x00000001L;
+ result = dlp_VFSFileSetAttributes (sd, fileRef, fileAttrs);
+ CHECK_RESULT(dlp_VFSFileSetAttributes);
+
+ result = dlp_VFSFileGetAttributes (sd, fileRef, &fileAttrs);
+ CHECK_RESULT(dlp_VFSFileGetAttributes);
+ if (fileAttrs & 0x00000001L) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Successfully set read-only bit on file attributes\n"));
+ }
+
+ fileAttrs &= ~0x00000001L;
+ result = dlp_VFSFileSetAttributes (sd, fileRef, fileAttrs);
+ CHECK_RESULT(dlp_VFSFileSetAttributes);
+
+ result = dlp_VFSFileResize (sd, fileRef, 1024);
+ CHECK_RESULT(dlp_VFSFileResize);
+
+ result = dlp_VFSFileSize (sd, fileRef, &len);
+ CHECK_RESULT(dlp_VFSFileGetSize);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* File size after resize: %d\n", len));
+ }
+
+ result = dlp_VFSFileGetDate (sd, fileRef, vfsFileDateCreated, &t1);
+ CHECK_RESULT(dlp_VFSFileGetDate);
+ if (result >= 0) {
+ ctime_r (&t1, name);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Date created: %s", name));
+ }
+
+ result = dlp_VFSFileGetDate (sd, fileRef, vfsFileDateModified, &t2);
+ CHECK_RESULT(dlp_VFSFileGetDate);
+ if (result >= 0) {
+ ctime_r (&t2, name);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Date modified: %s", name));
+ }
+
+ result = dlp_VFSFileGetDate (sd, fileRef, vfsFileDateAccessed, &t2);
+ CHECK_RESULT(dlp_VFSFileGetDate);
+ if (result >= 0) {
+ ctime_r (&t2, name);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Date accessed: %s", name));
+ }
+
+ t1 -= 3600 * 24;
+ result = dlp_VFSFileSetDate (sd, fileRef, vfsFileDateCreated, t1);
+ CHECK_RESULT(dlp_VFSFileSetDate);
+ if (result >= 0) {
+ result = dlp_VFSFileGetDate (sd, fileRef, vfsFileDateCreated, &t2);
+ CHECK_RESULT(dlp_VFSFileGetDate);
+ if (result >= 0) {
+ if (t1 == t2)
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* dlp_VFSFileSetDate successful\n"));
+ else
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* BUG: dlp_VFSFileSetDate FAILED\n"));
+ }
+ }
+
+ result = dlp_VFSFileClose (sd, fileRef);
+ CHECK_RESULT(dlp_VFSFileClose);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Closed file %s\n", TEST_VFS_FILE));
+ }
+ }
+
+ result = dlp_VFSFileRename (sd, refs[i], TEST_VFS_FILE, TEST_VFS_FILE2_SHORT);
+ CHECK_RESULT(dlp_VFSFileRename);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Renamed file %s to %s\n", TEST_VFS_FILE, TEST_VFS_FILE2_SHORT));
+ }
+
+ result = dlp_VFSFileDelete (sd, refs[i], TEST_VFS_FILE2);
+ CHECK_RESULT(dlp_VFSFileDelete);
+ if (result >= 0) {
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Deleted file %s\n", TEST_VFS_FILE2));
+ }
+ }
+
+ result = dlp_VFSFileDelete (sd, refs[i], "/vfs-test");
+ CHECK_RESULT(dlp_VFSFileDelete);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "* Deleted directory /vfs-test\n"));
+ }
+#endif
+
+ /*********************************************************************
+ *
+ * Test: VFS Import/Export Databases
+ *
+ * Direct Testing Functions:
+ * dlp_VFSImportDatabaseFromFile
+ * dlp_VFSExportDatabaseFromFile
+ *
+ * Indirect Testing Functions:
+ * None
+ *
+ *********************************************************************/
+
+ t1 = time (NULL);
+ LOG((PI_DBG_USER, PI_DBG_LVL_INFO, "VFSTEST Ending at %s", ctime (&t1)));
+
+error:
+ pi_close (sd);
+
+ return 0;
+}
+