[Jppy-commit] [SCM] jppy - Python bindings and API for jpilot databases and a GTK2 GUI branch, pilot-link-0.12.4-compat-devel, updated. releases/0.0.48-249-g7944299

Nick Piper nick-git@nickpiper.co.uk
Tue Jun 16 11:02:18 BST 2009


The following commit has been merged in the pilot-link-0.12.4-compat-devel branch:
commit 7944299c17798c2b4bad7c1560fb428e34120706
Author: Nick Piper <nick-git@nickpiper.co.uk>
Date:   Tue Jun 16 11:01:51 2009 +0100

    Start to make compatible with pilot-link 0.12.4 (not finished, tests fail.)

diff --git a/SConstruct b/SConstruct
index c3368d0..1badfa8 100644
--- a/SConstruct
+++ b/SConstruct
@@ -54,8 +54,7 @@ env = Environment(options=opts,
                   CPPPATH=['${mx_datetime_includes}',
                            '${pisock_includes}',
                            '${python_includes}',
-                           '#/libversit_src',
-                           '#/pilot-link_src'],
+                           '#/libversit_src'],
                   LIBPATH=['${pisock_library}'],
                   tools = ["default", "doxygen"],
                   toolpath='.',
@@ -213,22 +212,6 @@ libjpilot = jpilotEnv.StaticLibrary(target='jpilot_src/jppy_jpilot',
                                     CCFLAGS="$CCFLAGS -fPIC")
 libjpilot[0].attributes.shared = True
 
-######### parts that'll go into pilot-link upstream soon
-pilotlinkEnv = env.Clone()
-pilotlinkConfig = pilotlinkEnv.Configure()
-if not pilotlinkConfig.CheckLibWithHeader('libpisock',
-                                          'pi-socket.h','C','pi_socket_connected(0);'):
-     print "You need libpisock to compile this program"
-     Exit(1)
-pilotlinkConfig.Finish()
-# a bit of a hack. Scons doesn't support shared objects in static libraries.
-libpilotlink = pilotlinkEnv.StaticLibrary(target='pilot-link_src/jppy_pilotlink',
-                                          source=["pilot-link_src/%s" % x for x in ["calendar.c",
-                                                                                    "location.c",
-                                                                                    "blob.c"]],
-                                          CCFLAGS="$CCFLAGS -fPIC")
-libpilotlink[0].attributes.shared = True
-
 ######### Jppy
 jppyEnv = jpilotEnv.Clone()
 jppyEnv.ParseConfig('pkg-config --cflags --libs pygtk-2.0')
@@ -240,8 +223,7 @@ jppymodule = jppyEnv.SharedLibrary(target = 'jppy/__jpilotmodule',
                                    source = ['python_module_src/jpilot.i',
                                              'python_module_src/move_into_libpisock.c',
                                              'python_module_src/jpilot_helpers.c',
-                                             libjpilot,
-                                             libpilotlink] +
+                                             libjpilot] +
                                    glob.glob("python_module_src/pytype*.c") +
                                    ["libversit_src/%s" % x for x in ["vcc.y",
                                                                      "vobject.c",
@@ -282,14 +264,6 @@ if not 'darwin' == sys.platform:
      jpilot_plugins.append(pluginEnv.SharedLibrary(target = "jpilot_plugins/sync-Calendar",
                                                    source = "jpilot_plugins/sync-Calendar.c"))
 
-######### Build any test executables
-env.Program('#tests/calendardb-test', ['#pilot-link_src/calendardb-test.c',
-                                       libpilotlink],
-            LIBS=['pisock'])
-env.Program('#tests/locationdb-test', ['#pilot-link_src/locationdb-test.c',
-                                       libpilotlink],
-            LIBS=['pisock'])
-
 ######### Run Tests
 if env['test']:
      SConscript(dirs=['tests'],exports=['env','jppymodule'])
diff --git a/pilot-link_src/.gitignore b/pilot-link_src/.gitignore
deleted file mode 100644
index 76d9478..0000000
--- a/pilot-link_src/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-calendar.os
-location.os
-blob.o
-blob.os
-calendar.o
-calendardb-test.o
-location.o
-locationdb-test.o
-libjppy_pilotlink.a
\ No newline at end of file
diff --git a/pilot-link_src/blob.c b/pilot-link_src/blob.c
deleted file mode 100644
index a7e7ea6..0000000
--- a/pilot-link_src/blob.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * $Id$
- *
- * pi-blob.h - Support for blobs that appear in some palm databases.
- * 
- * (c) 2008, Jon Schewe & Judd Montgomery
- *
- * 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>
-#include <errno.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-macros.h"
-#include "pi-blob.h"
-
-/***********************************************************************
- *
- * Function:    free_Blob
- *
- * Summary:     Frees members of the blob structure
- *
- * Parameters:  Blob_t*
- *
- * Returns:     void
- *
- ***********************************************************************/
-void
-free_Blob(Blob_t *blob)
-{
-	if(NULL != blob->data) {
-		free(blob->data);
-		blob->data = NULL;
-	}
-}
-
-/***********************************************************************
- *
- * Function:    dup_Blob
- *
- * Summary:     Allocate memory for a new blob that is a duplicate of this one and copy the data into it
- *
- * Parameters:  Blob_t*
- *
- * Returns:     Blob_t* or NULL if there isn't enough memory and errno is set to ENOMEM
- *
- ***********************************************************************/
-Blob_t*
-dup_Blob(const Blob_t *blob)
-{
-	if(NULL == blob) {
-		return NULL;
-	}
-	
-	Blob_t *retval = (Blob_t*)malloc(sizeof(Blob_t));
-	if(NULL == retval) {
-		errno = ENOMEM;
-		return NULL;
-	}
-	memcpy(retval->type, blob->type, 4);
-	retval->length = blob->length;
-	if(blob->length > 0) {
-		retval->data = (uint8_t *)malloc(blob->length);
-		if(NULL == retval->data) {
-			errno = ENOMEM;
-			return NULL;
-		} else {
-			memcpy(retval->data, blob->data, blob->length);
-		}
-	} else {
-		retval->data = NULL;
-	}
-	return retval;
-}
-
-
-/***********************************************************************
- *
- * Function:    unpack_Blob
- *
- * Summary:     Unpack a blob starting at position in data
- *
- * Parameters:  Blob_t*, unsigned char*, size_t
- *
- * Returns:     the number of bytes read or -1 on error
- *
- ***********************************************************************/
-int
-unpack_Blob_p(Blob_t *blob, const unsigned char *data, const size_t position) {
-	size_t localPosition = position;
-  
-	memcpy(blob->type, (char *)data+localPosition, 4);
-	localPosition += 4;
-	//printf("blob->type = %c %c %c %c\n", blob->type[0], blob->type[1], blob->type[2], blob->type[3]);
-	blob->length = get_short(data+localPosition);
-	localPosition += 2;
-	if(blob->length > 0) {
-		//printf("blob->length = %d\n", blob->length);
-		blob->data = (uint8_t *)malloc(blob->length);
-		if(NULL == blob->data) {
-			printf("Malloc failed!\n");
-			return -1;
-		} else {
-			memcpy(blob->data, data+localPosition, blob->length);
-		}
-		localPosition += blob->length;
-	}
-
-	return localPosition - position;
-}
-
-/***********************************************************************
- *
- * Function:    pack_Blob
- *
- * Summary:     Pack a blob into the specified buffer 
- *
- * Parameters:  Blob_t*, pi_buffer_t*
- *
- * Returns:     0 on success, -1 on failure
- *
- ***********************************************************************/
-int
-pack_Blob(const Blob_t *blob, pi_buffer_t *buf) {
-	size_t offset;
-  
-	offset = buf->used;
-	pi_buffer_expect(buf, buf->used + 6 + blob->length);
-	buf->used = buf->used + 6 + blob->length;
-  
-	memcpy(buf->data+offset, blob->type, 4);
-	offset += 4;
-  
-	set_short(buf->data+offset, blob->length);
-	offset += 2;
-  
-	memcpy(buf->data+offset, blob->data, blob->length);
-	offset += blob->length;
-
-	return 0;
-}
-
-/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
-/* ex: set tabstop=4 expandtab: */
-/* Local Variables: */
-/* indent-tabs-mode: t */
-/* c-basic-offset: 8 */
-/* End: */
diff --git a/pilot-link_src/calendar.c b/pilot-link_src/calendar.c
deleted file mode 100644
index 61a9a86..0000000
--- a/pilot-link_src/calendar.c
+++ /dev/null
@@ -1,724 +0,0 @@
-/*
- * $Id$
- *
- * calendar.c - Support for PalmOne Calendar application (CalendarDB-PDat),
- * this is a copy of datebook.c with the calendar fields added.
- * 
- * (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>
-#include <errno.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-macros.h"
-#include "pi-calendar.h"
-
-#define alarmFlag 	64
-#define repeatFlag 	32
-#define noteFlag 	16
-#define exceptFlag 	8
-#define descFlag 	4
-
-/***********************************************************************
- *
- * Function:    new_CalendarEvent
- *
- * Summary:     Create empty calendar event
- *
- * Parameters:  CalendarEvent_t*
- *
- * Returns:     void
- *
- ***********************************************************************/
-void
-new_CalendarEvent(CalendarEvent_t *a)
-{
-	int i = 0;
-	
-	a->event = 0;
-	a->begin.tm_hour        = 0;
-	a->begin.tm_min         = 0;
-	a->begin.tm_sec         = 0;
-	a->begin.tm_year        = 2000;
-	a->begin.tm_mon         = 0;
-	a->begin.tm_mday        = 0;
-	a->begin.tm_isdst       = -1;
-	a->end.tm_hour        = 0;
-	a->end.tm_min         = 0;
-	a->end.tm_sec         = 0;
-	a->end.tm_year        = 2000;
-	a->end.tm_mon         = 0;
-	a->end.tm_mday        = 0;
-	a->end.tm_isdst       = -1;
-	a->alarm = 0;
-	a->advance = 0;
-	a->advanceUnits = 0;
-	a->repeatType = 0;
-	a->repeatForever = 0;
-	a->repeatEnd.tm_hour        = 0;
-	a->repeatEnd.tm_min         = 0;
-	a->repeatEnd.tm_sec         = 0;
-	a->repeatEnd.tm_year        = 2000;
-	a->repeatEnd.tm_mon         = 0;
-	a->repeatEnd.tm_mday        = 0;
-	a->repeatEnd.tm_isdst       = -1;
-
-	a->repeatFrequency = 0;
-	a->repeatDay = 0;
-	for (i = 0; i < 7; i++) {
-		a->repeatDays[i] = 0;
-	}
-	a->repeatWeekstart = 0;
-	a->exceptions = 0;
-	a->exception = NULL;
-	a->description = NULL;
-	a->note = NULL;
-	a->location = NULL;
-	a->tz = NULL;
-
-	/* initialize the blobs to NULL */
-	for (i=0; i<MAX_BLOBS; i++) {
-		a->blob[i]=NULL;
-	}
-}
-
-/***********************************************************************
- *
- * Function:    copy_CalendarEvent
- *
- * Summary: Copy the data from one calendar event to another. The destination
- * calendar event must already be cleared, either by creating new or by
- * calling free_CalendarEvent on it first.
- *
- * Parameters:  CalendarEvent_t*, CalendarEvent_t*
- *
- * Returns:     int -1 on failure (errno will be set), 0 on success
- *
- ***********************************************************************/
-int
-copy_CalendarEvent(const CalendarEvent_t *source, CalendarEvent_t *dest)
-{
-	int i = 0;
-	
-	dest->event = source->event;
-	memcpy(&(dest->begin), &(source->begin), sizeof(struct tm));
-	memcpy(&(dest->end), &(source->end), sizeof(struct tm));
-	dest->alarm = source->alarm;
-	dest->advance = source->advance;
-	dest->advanceUnits = source->advanceUnits;
-	dest->repeatType = source->repeatType;
-	dest->repeatForever = source->repeatForever;
-	memcpy(&(dest->repeatEnd), &(source->repeatEnd), sizeof(struct tm));
-
-	dest->repeatFrequency = source->repeatFrequency;
-	dest->repeatDay = source->repeatDay;
-	for (i = 0; i < 7; i++) {
-		dest->repeatDays[i] = source->repeatDays[i];
-	}
-	dest->repeatWeekstart = source->repeatWeekstart;
-	dest->exceptions = source->exceptions;
-	if(source->exceptions > 0) {
-		dest->exception = (struct tm*)malloc(source->exceptions * sizeof(struct tm));
-		if(NULL == dest->exception) {
-			errno = ENOMEM;
-			return -1;
-		}
-		for(i=0; i<source->exceptions; i++) {
-			memcpy(&(dest->exception[i]), &(source->exception[i]), sizeof(struct tm));
-		}
-	}
-	if(NULL != source->description) {
-		dest->description = strdup(source->description);
-	} else {
-		dest->description = NULL;
-	}
-	if(NULL != source->note) {
-		dest->note = strdup(source->note);
-	} else {
-		dest->note = NULL;
-	}
-	if(NULL != source->location) {
-		dest->location = strdup(source->location);
-	} else {
-		dest->location = NULL;
-	}
-
-	/* copy the blobs */
-	for (i=0; i<MAX_BLOBS; i++) {
-		if(source->blob[i] != NULL) {
-			dest->blob[i] = dup_Blob(source->blob[i]);
-			if(NULL == dest->blob[i]) {
-				return -1;
-			}
-		} else {
-			dest->blob[i] = NULL;
-		}
-	}
-
-	if(source->tz != NULL) {
-		dest->tz = dup_Timezone(source->tz);
-		if(NULL == dest->tz) {
-			return -1;
-		}
-	} else {
-		dest->tz = NULL;
-	}
-
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    free_CalendarEvent
- *
- * Summary:     Frees members of the calendar event structure
- *
- * Parameters:  CalendarEvent_t*
- *
- * Returns:     void
- *
- ***********************************************************************/
-void
-free_CalendarEvent(CalendarEvent_t *a)
-{
-	int i;
-	
-	if (a->exception != NULL) {
-		free(a->exception);
-		a->exception = NULL;
-	}
-
-	if (a->description != NULL) {
-		free(a->description);
-		a->description = NULL;
-	}
-
-	if (a->note != NULL) {
-		free(a->note);
-		a->note = NULL;
-	}
-
-	if(a->location != NULL) {
-		free(a->location);
-		a->location = NULL;
-	}
-
-	if(NULL != a->tz) {
-		free_Timezone(a->tz);
-		free(a->tz);
-	}
-
-	for(i=0; i<MAX_BLOBS; ++i) {
-		if(NULL != a->blob[i]) {
-			free_Blob(a->blob[i]);
-			
-			free(a->blob[i]);
-			a->blob[i] = NULL;
-		}
-	}
-}
-
-/***********************************************************************
- *
- * Function:    unpack_CalendarEvent
- *
- * Summary:     Fill in the calendar event structure based on the raw 
- *		record data
- *
- * Parameters:  CalendarEvent_t*, pi_buffer_t * of buffer, calendarType
- *
- * Returns:     -1 on fail, 0 on success
- *
- ***********************************************************************/
-int
-unpack_CalendarEvent(CalendarEvent_t *a, const pi_buffer_t *buf, calendarType type)
-{
-	int 	iflags,
-		j,
-		destlen,
-		i,
-		result;
-	unsigned char *p2;
-	unsigned long d;
-
-	destlen = 8;
-
-       if (type != calendar_v1)
-                return -1;
-
-	if (buf == NULL || buf->data == NULL || buf->used < destlen) {
-		return -1;
-	}
-
-	a->begin.tm_hour 	= get_byte(buf->data);
-	a->begin.tm_min 	= get_byte(buf->data + 1);
-	a->begin.tm_sec 	= 0;
-	d = (unsigned short int) get_short(buf->data + 4);
-	a->begin.tm_year 	= (d >> 9) + 4;
-	a->begin.tm_mon 	= ((d >> 5) & 15) - 1;
-	a->begin.tm_mday 	= d & 31;
-	a->begin.tm_isdst 	= -1;
-	a->end = a->begin;
-
-	a->end.tm_hour = get_byte(buf->data + 2);
-	a->end.tm_min = get_byte(buf->data + 3);
-
-	if (get_short(buf->data) == 0xffff) {
-		a->event 		= 1;
-		a->begin.tm_hour 	= 0;
-		a->begin.tm_min 	= 0;
-		a->end.tm_hour 		= 0;
-		a->end.tm_min 		= 0;
-	} else {
-		a->event = 0;
-	}
-
-	mktime(&a->begin);
-	mktime(&a->end);
-
-	iflags = get_byte(buf->data + 6);
-
-	/* buf->data+7 is gapfill */
-
-	p2 = (unsigned char *) buf->data + 8;
-
-	if (iflags & alarmFlag) {
-		a->alarm 	= 1;
-		a->advance 	= get_byte(p2);
-		p2 += 1;
-		a->advanceUnits = get_byte(p2);
-		p2 += 1;
-
-	} else {
-		a->alarm 	= 0;
-		a->advance 	= 0;
-		a->advanceUnits = 0;
-	}
-
-	if (iflags & repeatFlag) {
-		int 	i,
-			on;
-
-		a->repeatType = (enum calendarRepeatType) get_byte(p2);
-		p2 += 2;
-		d = (unsigned short int) get_short(p2);
-		p2 += 2;
-		if (d == 0xffff)
-			a->repeatForever = 1;	/* repeatEnd is invalid */
-		else {
-			a->repeatEnd.tm_year 	= (d >> 9) + 4;
-			a->repeatEnd.tm_mon 	= ((d >> 5) & 15) - 1;
-			a->repeatEnd.tm_mday 	= d & 31;
-			a->repeatEnd.tm_min 	= 0;
-			a->repeatEnd.tm_hour 	= 0;
-			a->repeatEnd.tm_sec 	= 0;
-			a->repeatEnd.tm_isdst 	= -1;
-			mktime(&a->repeatEnd);
-			a->repeatForever = 0;
-		}
-		a->repeatFrequency = get_byte(p2);
-		p2++;
-		on = get_byte(p2);
-		p2++;
-		a->repeatDay = (enum calendarDayOfMonthType) 0;
-		for (i = 0; i < 7; i++)
-			a->repeatDays[i] = 0;
-
-		if (a->repeatType == calendarRepeatMonthlyByDay)
-			a->repeatDay = (enum calendarDayOfMonthType) on;
-		else if (a->repeatType == calendarRepeatWeekly)
-			for (i = 0; i < 7; i++)
-				a->repeatDays[i] = !!(on & (1 << i));
-		a->repeatWeekstart = get_byte(p2);
-		p2++;
-		p2++;
-	} else {
-		int 	i;
-
-		a->repeatType 		= (enum calendarRepeatType) 0;
-		a->repeatForever 	= 1;	/* repeatEnd is invalid */
-		a->repeatFrequency 	= 0;
-		a->repeatDay 		= (enum calendarDayOfMonthType) 0;
-		for (i = 0; i < 7; i++)
-			a->repeatDays[i] = 0;
-		a->repeatWeekstart 	= 0;
-	}
-
-	if (iflags & exceptFlag) {
-		a->exceptions = get_short(p2);
-		p2 += 2;
-		a->exception = malloc(sizeof(struct tm) * a->exceptions);
-
-		for (j = 0; j < a->exceptions; j++, p2 += 2) {
-			d = (unsigned short int) get_short(p2);
-			a->exception[j].tm_year 	= (d >> 9) + 4;
-			a->exception[j].tm_mon 		= ((d >> 5) & 15) - 1;
-			a->exception[j].tm_mday 	= d & 31;
-			a->exception[j].tm_hour 	= 0;
-			a->exception[j].tm_min 		= 0;
-			a->exception[j].tm_sec 		= 0;
-			a->exception[j].tm_isdst 	= -1;
-			mktime(&a->exception[j]);
-		}
-
-	} else {
-		a->exceptions 	= 0;
-		a->exception 	= 0;
-	}
-
-	if (iflags & descFlag) {
-		a->description = strdup((char *)p2);
-		p2 += strlen((char *)p2) + 1;
-	} else
-		a->description = 0;
-
-	if (iflags & noteFlag) {
-		a->note = strdup((char *)p2);
-		p2 += strlen((char *)p2) + 1;
-	} else {
-		a->note = 0;
-	}
-
-	/* initialize the blobs to NULL */
-	for (i=0; i<MAX_BLOBS; ++i) {
-		a->blob[i]=NULL;
-	}
-
-	if(p2 - buf->data < buf->used) {
-		uint8_t blob_count;
-		
-		if(p2[0] == 0x42 && p2[1] == 0x64) {
-			/* this is the start of a blob, skip over location */
-			a->location = NULL;
-		} else {
-			/* location */
-			a->location = strdup((char *)p2);
-			//printf("Found location %s\n", a->location);
-			p2 += strlen(a->location) + 1;
-		}
-		
-		/* read the blobs */
-		a->tz = NULL;
-		for(blob_count = 0; buf->used - (p2 - buf->data) > 6; ++blob_count) {
-			if(blob_count >= MAX_BLOBS) {
-				/* too many blobs were found */
-				printf("Error, found more than %d blobs: %d\n", MAX_BLOBS, blob_count);
-				return -1;
-			}
-
-			a->blob[blob_count] = (Blob_t *)malloc(sizeof(Blob_t));
-			result = unpack_Blob_p(a->blob[blob_count], p2, 0);
-			if(-1 == result) {
-				return -1;
-			} else {
-				p2 += result;
-			}
-			//printf("DEBUG: record %s read in blob[%d] of size %d\n", a->description, blob_count, a->blob[blob_count]->length);
-			
-			/* if it's a timezone blob store it */
-			if (0 == memcmp(a->blob[blob_count]->type, BLOB_TYPE_CALENDAR_TIMEZONE_ID, 4)) {
-				int result;
-				if(NULL != a->tz) {
-					printf("Warning: Found more than one timezone blob! Freeing the previous one and starting again\n");
-					free_Timezone(a->tz);
-					free(a->tz);
-				}
-				a->tz = (Timezone_t *)malloc(sizeof(Timezone_t));
-				result = unpack_Timezone_p(a->tz, a->blob[blob_count]->data, 0);
-				if(-1 == result) {
-					printf("Error unpacking timezone blob\n");
-					return -1;
-				} else if(result != a->blob[blob_count]->length) {
-					printf("Read the wrong number of bytes for a timezone expected %d but was %d\n", a->blob[blob_count]->length, result);
-					return -1;
-				}
-						
-			}
-		}
-		if(p2 - buf->data < buf->used) {
-			printf("Extra data found %d bytes\n", (buf->used - (p2 - buf->data)));
-			return -1;
-		}
-	} else {
-		a->location = NULL;
-		a->tz = NULL;
-	}
-	
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    pack_CalendarEvent
- *
- * Summary:	Fill in the raw calendar event record data based on the 
- *		calendar event structure.
- *
- * Parameters:  CalendarEvent_t*, pi_buffer_t*, calendarType
- *
- * Returns:     -1 on error (bad arguments, mostyle) or 0 on success.
- *              The buffer is sized to accomodate the required data.
- *
- ***********************************************************************/
-int
-pack_CalendarEvent(const CalendarEvent_t *a, pi_buffer_t *buf, calendarType type)
-{
-	int 	iflags,
-		destlen = 8;
-	char 	*pos;
-
-       if (type != calendar_v1)
-                return -1;
-
-	if (a == NULL || buf == NULL)
-		return -1;
-
-	if (a->alarm)
-		destlen += 2;
-	if (a->repeatType)
-		destlen += 8;
-	if (a->exceptions)
-		destlen += 2 + 2 * a->exceptions;
-	if (a->note)
-		destlen += strlen(a->note) + 1;
-	if (a->description)
-		destlen += strlen(a->description) + 1;
-
-	pi_buffer_expect (buf, destlen);
-	buf->used = destlen;	
-
-	set_byte(buf->data, a->begin.tm_hour);
-	set_byte(buf->data + 1, a->begin.tm_min);
-	set_byte(buf->data + 2, a->end.tm_hour);
-	set_byte(buf->data + 3, a->end.tm_min);
-	set_short(buf->data + 4,
-		  ((a->
-		    begin.tm_year - 4) << 9) | ((a->begin.tm_mon +
-						 1) << 5) | a->begin.
-		  tm_mday);
-
-	if (a->event) {
-		set_long(buf->data, 0xffffffff);
-	}
-
-	iflags = 0;
-
-	pos = (char *) buf->data + 8;
-
-	if (a->alarm) {
-		iflags |= alarmFlag;
-
-		set_byte(pos, a->advance);
-		set_byte(pos + 1, a->advanceUnits);
-		pos += 2;
-	}
-
-	if (a->repeatType) {
-		int 	i, 
-			on;
-
-		iflags |= repeatFlag;
-
-		if (a->repeatType == calendarRepeatMonthlyByDay)
-			on = a->repeatDay;
-		else if (a->repeatType == calendarRepeatWeekly) {
-			on = 0;
-			for (i = 0; i < 7; i++)
-				if (a->repeatDays[i])
-					on |= 1 << i;
-		} else
-			on = 0;
-
-		set_byte(pos, a->repeatType);
-		set_byte(pos + 1, 0);
-		pos += 2;
-
-		if (a->repeatForever)
-			set_short(pos, 0xffff);
-		else
-			set_short(pos,
-				  ((a->
-				    repeatEnd.tm_year -
-				    4) << 9) | ((a->repeatEnd.tm_mon +
-						 1) << 5) | a->repeatEnd.
-				  tm_mday);
-
-		pos += 2;
-
-		set_byte(pos, a->repeatFrequency);
-		pos++;
-		set_byte(pos, on);
-		pos++;
-		set_byte(pos, a->repeatWeekstart);
-		pos++;
-		set_byte(pos, 0);
-		pos++;
-	}
-
-	if (a->exceptions) {
-		int 	i;
-
-		iflags |= exceptFlag;
-
-		set_short(pos, a->exceptions);
-		pos += 2;
-
-		for (i = 0; i < a->exceptions; i++, pos += 2)
-			set_short(pos,
-				  ((a->
-				    exception[i].tm_year -
-				    4) << 9) | ((a->exception[i].tm_mon +
-						 1) << 5) | a->
-				  exception[i].tm_mday);
-	}
-
-	if (a->description != NULL) {
-		iflags |= descFlag;
-
-		strcpy(pos, a->description);
-		pos += strlen(pos) + 1;
-	}
-
-	if (a->note != NULL) {
-		iflags |= noteFlag;
-
-		strcpy(pos, a->note);
-		pos += strlen(pos) + 1;
-	}
-
-	set_byte(buf->data + 6, iflags);
-	set_byte(buf->data + 7, 0);	/* gapfill */
-
-	/* Calendar stuff */
-	uint8_t blob_index;
-	size_t offset = buf->used;
-	if(NULL != a->location) {
-		offset = buf->used;
-		pi_buffer_expect(buf, buf->used + strlen(a->location)+1);
-		buf->used = buf->used + strlen(a->location)+1;
-		strcpy((char *)(buf->data+offset), a->location);
-	}
-
-	//write out the blobs
-	for(blob_index = 0; blob_index < MAX_BLOBS; ++blob_index) {
-		if(NULL != a->blob[blob_index]) {
-			pack_Blob(a->blob[blob_index], buf);
-		}
-	}
-	
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    unpack_CalendarAppInfo
- *
- * Summary:     Fill in the app info structure based on the raw app 
- *		info data
- *
- * Parameters:  CalendarAppInfo_t*, char* to record, record length
- *
- * Returns:     The necessary length of the buffer if record is NULL,
- *		or 0 on error, the length of the data used from the 
- *		buffer otherwise
- *
- ***********************************************************************/
-int
-unpack_CalendarAppInfo(CalendarAppInfo_t *ai,
-	const unsigned char *record, size_t len)
-{
-	int 	i;
-
-	i = unpack_CategoryAppInfo(&ai->category, record, len);
-	if (!i)
-		return 0;
-	record += i;
-	len -= i;
-	if (len < 2)
-		return 0;
-	ai->startOfWeek = get_byte(record);
-
-	for(i=0; i<18; ++i) {
-		ai->internal[i] = get_byte(record);
-		record += 1;
-	}
-	ai->type = calendar_v1;
-	
-	return i + 2;
-}
-
-/***********************************************************************
- *
- * Function:    pack_CalendarAppInfo
- *
- * Summary:     Fill in the raw app info record data based on the app 
- *		info structure
- *
- * Parameters:  AppointmentAppInfo*, char* to buffer, buffer length
- *
- * Returns:     The length of the buffer required if record is NULL,
- *		or 0 on error, the length of the data used from the 
- *		buffer otherwise
- *
- ***********************************************************************/
-int
-pack_CalendarAppInfo(const CalendarAppInfo_t *ai,
-	unsigned char *record, size_t len)
-{
-	int 	i;
-	unsigned char *start = record;
-
-	i = pack_CategoryAppInfo(&ai->category, record, len);
-	if (!record)
-		return i + 2;
-	if (!i)
-		return i;
-	record 	+= i;
-	len 	-= i;
-	if (len < 2)
-		return 0;
-	set_short(record, 0);
-	set_byte(record, ai->startOfWeek);
-	record += 2;
-
-	for(i=0; i<18; ++i) {
-		set_byte(record, ai->internal[i]);
-		record += 1;
-	}
-		    
-	return (record - start);
-}
-
-/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
-/* ex: set tabstop=4 expandtab: */
-/* Local Variables: */
-/* indent-tabs-mode: t */
-/* c-basic-offset: 8 */
-/* End: */
diff --git a/pilot-link_src/calendardb-test.c b/pilot-link_src/calendardb-test.c
deleted file mode 100644
index 91ba803..0000000
--- a/pilot-link_src/calendardb-test.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * $Id$
- *
- * 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);
-
-  result = unpack_CalendarAppInfo(&cab, app_info, app_info_size);
-
-  /* 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: %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]);
-          }
-        }
-      }
-    }
-    
-    /*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/pilot-link_src/location.c b/pilot-link_src/location.c
deleted file mode 100644
index f1ce5e9..0000000
--- a/pilot-link_src/location.c
+++ /dev/null
@@ -1,805 +0,0 @@
-/*
- * $Id$
- *
- * location.c:  Translate Pilot location data formats
- * (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 <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "pi-macros.h"
-#include "pi-location.h"
-
-/***********************************************************************
- *
- * Function:    new_Timezone
- *
- * Summary:     Create empty timzone
- *
- * Parameters:  Timezone_t*
- *
- * Returns:     void
- *
- ***********************************************************************/
-void
-new_Timezone(Timezone_t *a)
-{
-	a->offset = 0;
-	a->t2 = 0;
-	a->dstStart.dayOfWeek = 0;
-	a->dstStart.weekOfMonth = 0;
-	a->dstStart.month = 0;
-	a->dstStart.unknown = 0;
-	a->dstEnd.dayOfWeek = 0;
-	a->dstEnd.weekOfMonth = 0;
-	a->dstEnd.month = 0;
-	a->dstEnd.unknown = 0;
-	a->dstObserved = 0;
-	a->t4 = 0;
-	a->unknown = 0;
-	a->name = NULL;
-}
-
-/***********************************************************************
- *
- * Function:    new_Locatio
- *
- * Summary:     Create empty location
- *
- * Parameters:  Location_t*
- *
- * Returns:     void
- *
- ***********************************************************************/
-void
-new_Location(Location_t *a)
-{
-	new_Timezone(&(a->tz));
-	a->unknownExists = 0;
-	a->unknown = 0;
-	a->latitude.degrees = 0;
-	a->latitude.minutes = 0;
-	a->latitude.direction = 0;
-	a->longitude.degrees = 0;
-	a->longitude.minutes = 0;
-	a->longitude.direction = 0;
-	a->note = NULL;
-}
-
-/***********************************************************************
- *
- * Function:    copy_Timezone
- *
- * Summary: Copy the data from one timezone to another. The destination
- * timezone event must already be cleared, either by creating new or by
- * calling free_Timezone on it first.
- *
- * Parameters:  Timezone_t*, Timezone_t*
- *
- * Returns:     int -1 on failure (errno will be set), 0 on success
- *
- ***********************************************************************/
-int
-copy_Timezone(const Timezone_t *source, Timezone_t *dest)
-{
-
-	dest->offset = source->offset;
-	dest->t2 = source->t2;
-	dest->dstStart.dayOfWeek = source->dstStart.dayOfWeek;
-	dest->dstStart.weekOfMonth = source->dstStart.weekOfMonth;
-	dest->dstStart.month = source->dstStart.month;
-	dest->dstStart.unknown = source->dstStart.unknown;
-	dest->dstEnd.dayOfWeek = source->dstEnd.dayOfWeek;
-	dest->dstEnd.weekOfMonth = source->dstEnd.weekOfMonth;
-	dest->dstEnd.month = source->dstEnd.month;
-	dest->dstEnd.unknown = source->dstEnd.unknown;
-	dest->dstObserved = source->dstObserved;
-	dest->t4 = source->t4;
-	dest->unknown = source->unknown;
-	if(NULL != source->name) {
-		dest->name = strdup(source->name);
-	} else {
-		dest->name = NULL;
-	}
-	
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    copy_Location
- *
- * Summary: Copy the data from one location to another. The destination
- * location event must already be cleared, either by creating new or by
- * calling free_Location on it first.
- *
- * Parameters:  Location_t*, Location_t*
- *
- * Returns:     int -1 on failure (errno will be set), 0 on success
- *
- ***********************************************************************/
-int
-copy_Location(const Location_t *source, Location_t *dest)
-{
-	int retval;
-	retval = copy_Timezone(&(source->tz), &(dest->tz));
-	if(0 != retval) {
-		return retval;
-	}
-	dest->unknownExists = source->unknownExists;
-	dest->unknown = source->unknown;
-	dest->latitude.degrees = source->latitude.degrees;
-	dest->latitude.minutes = source->latitude.minutes;
-	dest->latitude.direction = source->latitude.direction;
-	dest->longitude.degrees = source->longitude.degrees;
-	dest->longitude.minutes = source->longitude.minutes;
-	dest->longitude.direction = source->longitude.direction;
-	if(NULL != source->note) {
-		dest->note = strdup(source->note);
-	} else {
-		dest->note = NULL;
-	}
-	
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    free_Location
- *
- * Summary:	Free the members of a location structure
- *
- * Parameters:  Location_t*
- *
- * Returns:     void
- *
- ***********************************************************************/
-void
-free_Location(Location_t *loc)
-{
-	free_Timezone(&(loc->tz));
-	
-	if(loc->note != NULL) {
-		free(loc->note);
-		loc->note = NULL;
-	}
-
-}
-
-/***********************************************************************
- *
- * Function:    dup_Timezone
- *
- * Summary:     Allocate memory for a new timezone that is a duplicate of this one and copy the data into it
- *
- * Parameters:  Timezone_t*
- *
- * Returns:     Timezone_t* or NULL if there isn't enough memory and errno is set to ENOMEM
- *
- ***********************************************************************/
-Timezone_t*
-dup_Timezone(const Timezone_t *tz)
-{
-	Timezone_t *retval = (Timezone_t*)malloc(sizeof(Timezone_t));
-	if(NULL == retval) {
-		errno = ENOMEM;
-		return NULL;
-	}
-	retval->offset = tz->offset;
-	retval->t2 = tz->t2;
-	memcpy(&(retval->dstStart), &(tz->dstStart), sizeof(DST_t));
-	memcpy(&(retval->dstEnd), &(tz->dstEnd), sizeof(DST_t));
-	retval->dstObserved = tz->dstObserved;
-	retval->t4 = tz->t4;
-	retval->unknown = tz->unknown;
-	if(NULL != tz->name) {
-		retval->name = strdup(tz->name);
-	} else {
-		retval->name = NULL;
-	}
-	
-	return retval;
-}
-
-/***********************************************************************
- *
- * Function:    free_Timezone
- *
- * Summary:	Free the members of a timezone structure
- *
- * Parameters:  Timezone_t*
- *
- * Returns:     void
- *
- ***********************************************************************/
-void
-free_Timezone(Timezone_t *tz) {
-	if(tz->name != NULL) {
-		free(tz->name);
-		tz->name = NULL;
-	}
-}
-
-/***********************************************************************
- *
- * Function:    unpack_DST
- *
- * Summary:     Fill in the daylight savings time structure based on the raw record 
- *		data
- *
- * Parameters:  DST_t*, pi_buffer_t *buf
- *
- * Returns:     -1 on error, 0 on success
- *
- ***********************************************************************/
-int
-unpack_DST(DST_t *dst, const pi_buffer_t *buf) {
-	return unpack_DST_p(dst, buf->data, 0);
-}
-/**
-   Does the work for unpack_DST given a position in buf
-*/
-int
-unpack_DST_p(DST_t *dst, const unsigned char *data, const size_t position) {
-	uint8_t byte;
-	
-	byte = get_byte(data+position);
-	switch(byte) {
-	case 0x00:
-		dst->dayOfWeek = sunday;
-		break;
-	case 0x01:
-		dst->dayOfWeek = monday;
-		break;
-	case 0x02:
-		dst->dayOfWeek = tuesday;
-		break;
-	case 0x03:
-		dst->dayOfWeek = wednesday;
-		break;
-	case 0x04:
-		dst->dayOfWeek = thursday;
-		break;
-	case 0x05:
-		dst->dayOfWeek = friday;
-		break;
-	case 0x06:
-		dst->dayOfWeek = saturday;
-		break;
-	default:
-		printf("Illegal value found in day of week: 0x%02X\n", byte);
-		return -1;
-	}
-
-	byte = get_byte(data+position+1);
-	switch(byte) {
-	case 0x00:
-		dst->weekOfMonth = first;
-		break;
-	case 0x01:
-		dst->weekOfMonth = second;
-		break;
-	case 0x02:
-		dst->weekOfMonth = third;
-		break;
-	case 0x03:
-		dst->weekOfMonth = fourth;
-		break;
-	case 0x04:
-		dst->weekOfMonth = last;
-		break;
-	default:
-		printf("Illegal value found in week: 0x%02Xd\n", byte);
-		return -1;
-	}
-
-	byte = get_byte(data+position+2);
-	switch(byte) {
-	case 0x00:
-		dst->month = none;
-		break;
-	case 0x01:
-		dst->month = january;
-		break;
-	case 0x02:
-		dst->month = february;
-		break;
-	case 0x03:
-		dst->month = march;
-		break;
-	case 0x04:
-		dst->month = april;
-		break;
-	case 0x05:
-		dst->month = may;
-		break;
-	case 0x06:
-		dst->month = june;
-		break;
-	case 0x07:
-		dst->month = july;
-		break;
-	case 0x08:
-		dst->month = august;
-		break;
-	case 0x09:
-		dst->month = september;
-		break;
-	case 0x0a:
-		dst->month = october;
-		break;
-	case 0x0b:
-		dst->month = november;
-		break;
-	case 0x0c:
-		dst->month = december;
-		break;
-	default:
-		printf("Illegal value found in month: 0x%02Xd\n", byte);
-		return -1;
-	}
-
-	dst->unknown = get_byte(data+position+3);
-	switch(dst->unknown) {
-	case 0x00:
-	case 0x01:
-	case 0x02:
-	case 0x03:
-		/*case 0x04:*/
-		break;
-	default:
-		printf("Bad value for DST.unknown: 0x%02x\n", dst->unknown);
-		return -1;
-	}
-  
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    unpack_timezone
- *
- * Summary:     Fill in the timezone structure based on the raw record 
- *		data
- *
- * Parameters:  Timezone_t*, pi_buffer_t *buf, optional position in buf
- *
- * Returns:     -1 on error, number of bytes read on success
- *
- ***********************************************************************/
-int
-unpack_Timezone(Timezone_t *tz, const pi_buffer_t *buf) {
-	return unpack_Timezone_p(tz, buf->data, 0);
-}
-/**
- * Does the work of unpack_Timezone given a position in buf.
- * 
- * Returns:     -1 on error, number of bytes read on success
- */
-int
-unpack_Timezone_p(Timezone_t *tz, const unsigned char *data, const size_t position) {
-	uint8_t byte;
-	size_t localPosition = position;
-  
-	tz->offset = get_short(data+localPosition);
-	localPosition += 2;
-	/*printf("Offset is %d\n", tz->offset);*/
-  
-	tz->t2 = get_byte(data + localPosition);
-	++localPosition;
-	switch(tz->t2) {
-	case 0x00:
-		break;
-	case 0x01:
-		break;
-	case 0x02:
-		break;
-	case 0x03:
-		break;
-	default:
-		/*printf("Bad value for t2 0x%02X\n", tz->t2);*/
-		return -1;
-	}
-
-	if(unpack_DST_p(&(tz->dstStart), data, localPosition) != 0) {
-		return -1;
-	}
-	localPosition += 4;
-
-	if(unpack_DST_p(&(tz->dstEnd), data, localPosition) != 0) {
-		return -1;
-	}
-	localPosition += 4;
-  
-	byte = get_byte(data+localPosition);
-	++localPosition;
-	switch(byte) {
-	case 0x3c:
-		/* dst observed */
-		tz->dstObserved = 1;
-		break;
-	case 0x00:
-		/* dst not observed */
-		tz->dstObserved = 0;
-		break;
-	default:
-		printf("Illegal value in dst_observed 0x%02X\n", byte);
-		return -1;
-	}
-  
-	tz->t4 = get_byte(data+localPosition);
-	++localPosition;
-
-	tz->unknown = get_byte(data+localPosition);
-	++localPosition;
-	switch(tz->unknown) {
-	case 0x80:
-	case 0x00:
-		break;
-	default:
-		printf("Bad value for unknown 0x%02X\n", tz->unknown);
-		return -1;
-	}
-
-	if(0x00 == data+localPosition) {
-		tz->name = NULL;
-		++localPosition;
-	} else {
-		tz->name = strdup((char *)(data+localPosition));
-		localPosition += strlen(tz->name) + 1;
-	}
-
-	return localPosition;
-}
-
-/***********************************************************************
- *
- * Function:    unpack_Location
- *
- * Summary:     Fill in the location structure based on the raw record 
- *		data
- *
- * Parameters:  Location_t*, pi_buffer_t *buf
- *
- * Returns:     -1 on error, 0 on success
- *
- ***********************************************************************/
-int
-unpack_Location(Location_t *loc, const pi_buffer_t *buf)
-{
-	size_t localPosition = 0;
-  
-	localPosition = unpack_Timezone_p(&(loc->tz), buf->data, localPosition);
-	if(localPosition < 0) {
-		return -1;
-	}
-
-	loc->unknownExists = 0;
-	  
-	/* unpack latitude */
-	loc->latitude.degrees = get_short(buf->data+localPosition);
-	loc->latitude.minutes = get_short(buf->data+localPosition+2);
-	if(loc->latitude.degrees > 90 || loc->latitude.degrees < -90
-	   || loc->latitude.minutes > 60 || loc->latitude.minutes < -60) {
-		/*
-		printf("latitude degrees out of range: %d or\n", loc->latitude.degrees);
-		printf("latitude minutes out of range: %d\n", loc->latitude.minutes);
-		*/
-		
-		loc->unknownExists = 1;
-		loc->unknown = get_byte(buf->data+localPosition);
-		++localPosition;
-
-		/*printf("Found unknown: 0x%02X\n", loc->unknown); */
-		
-		loc->latitude.degrees = get_short(buf->data+localPosition);
-		localPosition += 2;
-		loc->latitude.minutes = get_short(buf->data+localPosition);
-		localPosition += 2;
-	} else {
-		localPosition += 4;
-	}
-		
-	loc->longitude.degrees = get_short(buf->data+localPosition);
-	localPosition += 2;
-	loc->longitude.minutes = get_short(buf->data+localPosition);
-	localPosition += 2;
-
-	/* now make latitude and longitude easy to read */
-	loc->latitude.direction = south;
-	loc->longitude.direction = west;
-	if(loc->latitude.minutes < 0) {
-		loc->latitude.direction = north;
-		loc->latitude.minutes = -1 * loc->latitude.minutes;
-	}
-	if(loc->latitude.degrees < 0) {
-		loc->latitude.direction = north;
-		loc->latitude.degrees = -1 * loc->latitude.degrees;
-	}
-	if(loc->longitude.minutes < 0) {
-		loc->longitude.direction = east;
-		loc->longitude.minutes = -1 * loc->longitude.minutes;
-	}
-	if(loc->longitude.degrees < 0) {
-		loc->longitude.direction = east;
-		loc->longitude.degrees = -1 * loc->longitude.degrees;
-	}
-
-
-	if(0x00 == buf->data[localPosition]) {
-		loc->note = NULL;
-		++localPosition;
-	} else {
-		loc->note = strdup((char *)(buf->data+localPosition));
-		localPosition += strlen(loc->note) + 1;
-	}
-
-	return 0;
-}
-
-
-/***********************************************************************
- *
- * Function:    pack_DST
- *
- * Summary:     append raw DST record data to buf based on the 
- *		DST structure
- *
- * Parameters:  DST_t*, pi_buffer_t *buf of record, record type
- *
- * Returns:     -1 on error, 0 on success.
- *
- ***********************************************************************/
-int
-pack_DST(const DST_t *dst, pi_buffer_t *buf)
-{
-	size_t offset;
-	
-	if (dst == NULL || buf == NULL)
-		return -1;
-
-	offset = buf->used;
-	
-	pi_buffer_expect(buf, buf->used + 4);
-	buf->used = buf->used + 4;
-	
-	switch(dst->dayOfWeek) {
-	case sunday:
-		set_byte(buf->data+offset, 0x00);
-		break;
-	case monday:
-		set_byte(buf->data+offset, 0x01);
-		break;
-	case tuesday:
-		set_byte(buf->data+offset, 0x02);
-		break;
-	case wednesday:
-		set_byte(buf->data+offset, 0x03);
-		break;
-	case thursday:
-		set_byte(buf->data+offset, 0x04);
-		break;
-	case friday:
-		set_byte(buf->data+offset, 0x05);
-		break;
-	case saturday:
-		set_byte(buf->data+offset, 0x06);
-		break;
-	default:
-		return -1;
-		
-	}
-
-	switch(dst->weekOfMonth) {
-	case first:
-		set_byte(buf->data+offset+1, 0x00);
-		break;
-	case second:
-		set_byte(buf->data+offset+1, 0x01);
-		break;
-	case third:
-		set_byte(buf->data+offset+1, 0x02);
-		break;
-	case fourth:
-		set_byte(buf->data+offset+1, 0x03);
-		break;
-	case last:
-		set_byte(buf->data+offset+1, 0x04);
-		break;
-	default:
-		return -1;
-
-	}
-
-	switch(dst->month) {
-	case none:
-		set_byte(buf->data+offset+2, 0x00);
-		break;
-	case january:
-		set_byte(buf->data+offset+2, 0x01);
-		break;
-	case february:
-		set_byte(buf->data+offset+2, 0x02);
-		break;
-	case march:
-		set_byte(buf->data+offset+2, 0x03);
-		break;
-	case april:
-		set_byte(buf->data+offset+2, 0x04);
-		break;
-	case may:
-		set_byte(buf->data+offset+2, 0x05);
-		break;
-	case june:
-		set_byte(buf->data+offset+2, 0x06);
-		break;
-	case july:
-		set_byte(buf->data+offset+2, 0x07);
-		break;
-	case august:
-		set_byte(buf->data+offset+2, 0x08);
-		break;
-	case september:
-		set_byte(buf->data+offset+2, 0x09);
-		break;
-	case october:
-		set_byte(buf->data+offset+2, 0x0a);
-		break;
-	case november:
-		set_byte(buf->data+offset+2, 0x0b);
-		break;
-	case december:
-		set_byte(buf->data+offset+2, 0x0c);
-		break;
-	default:
-		return -1;
-	}
-
-	set_byte(buf->data+offset+3, dst->unknown);
-		
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    pack_Timezone
- *
- * Summary:     Append the raw Timezone record to buf based on the 
- *		Timezone structure
- *
- * Parameters:  Timezone_t*, pi_buffer_t *buf of record, record type
- *
- * Returns:     -1 on error, 0 on success.
- *
- ***********************************************************************/
-int
-pack_Timezone(const Timezone_t *tz, pi_buffer_t *buf)
-{
-
-	size_t offset;
-	
-	if (tz == NULL || buf == NULL)
-		return -1;
-	
-	offset = buf->used;
-	pi_buffer_expect(buf, buf->used + 3);
-	buf->used = buf->used + 3;
-
-	set_short(buf->data+offset, tz->offset);
-	set_byte(buf->data+offset+2, tz->t2);
-
-	pack_DST(&(tz->dstStart), buf);
-	pack_DST(&(tz->dstEnd), buf);
-
-	offset = buf->used;
-	pi_buffer_expect(buf, buf->used + 3);
-	buf->used = buf->used + 3;
-
-	if(tz->dstObserved) {
-		set_byte(buf->data+offset, 0x3c);
-	} else {
-		set_byte(buf->data+offset, 0x00);
-	}
-	set_byte(buf->data+offset, tz->t4);
-
-	if(NULL != tz->name) {
-		offset = buf->used;
-		pi_buffer_expect(buf, buf->used + strlen(tz->name)+1);
-		buf->used = buf->used + strlen(tz->name)+1;
-
-		strcpy((char *)(buf->data+offset), tz->name);
-	}
-		
-	return 0;
-}
-
-/***********************************************************************
- *
- * Function:    pack_Location
- *
- * Summary:     Append the raw Location record to buf based on the 
- *		Location structure
- *
- * Parameters:  Location_t*, pi_buffer_t *buf of record, record type
- *
- * Returns:     -1 on error, 0 on success.
- *
- ***********************************************************************/
-int
-pack_Location(const Location_t *loc, pi_buffer_t *buf)
-{
-	size_t offset;
-	
-	if (loc == NULL || buf == NULL)
-		return -1;
-
-	pack_Timezone(&(loc->tz), buf);
-
-	if(loc->unknownExists) {
-		offset = buf->used;
-		pi_buffer_expect(buf, buf->used + 1);
-		buf->used = buf->used+1;
-		set_byte(buf->data+offset, loc->unknown);
-	}
-
-	offset = buf->used;
-	pi_buffer_expect(buf, buf->used+8);
-	buf->used = buf->used+8;
-
-	if(loc->latitude.direction == north) {
-		set_short(buf->data+offset, -1 * loc->latitude.degrees);
-		set_short(buf->data+offset+2, -1 * loc->latitude.minutes);
-	} else {
-		set_short(buf->data+offset, loc->latitude.degrees);
-		set_short(buf->data+offset+2, loc->latitude.minutes);
-	}
-	if(loc->longitude.direction == east) {
-		set_short(buf->data+offset+4, -1 * loc->longitude.degrees);
-		set_short(buf->data+offset+6, -1 * loc->longitude.minutes);
-	} else {
-		set_short(buf->data+offset+4, loc->longitude.degrees);
-		set_short(buf->data+offset+6, loc->longitude.minutes);
-	}
-
-	if(NULL != loc->note) {
-		offset = buf->used;
-		pi_buffer_expect(buf, buf->used + strlen(loc->note)+1);
-		buf->used = buf->used + strlen(loc->note)+1;
-
-		strcpy((char *)(buf->data+offset), loc->note);
-	} else {
-		offset = buf->used;
-		pi_buffer_expect(buf, buf->used + 1);
-		set_byte(buf->data+offset, 0);
-		buf->used = buf->used + 1;
-	}
-		
-
-	return 0;
-}
-
-/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
-/* ex: set tabstop=4 expandtab: */
-/* Local Variables: */
-/* indent-tabs-mode: t */
-/* c-basic-offset: 8 */
-/* End: */
diff --git a/pilot-link_src/locationdb-test.c b/pilot-link_src/locationdb-test.c
deleted file mode 100644
index 30a4b86..0000000
--- a/pilot-link_src/locationdb-test.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * $Id$
- *
- * 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/pilot-link_src/pi-blob.h b/pilot-link_src/pi-blob.h
deleted file mode 100644
index 11c88b0..0000000
--- a/pilot-link_src/pi-blob.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * $Id$
- *
- * pi-blob.h - Support for blobs that appear in some palm databases.
- * 
- * (c) 2008, Jon Schewe & Judd Montgomery
- *
- * 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.
- */
-#ifndef _PILOT_BLOB_H_
-#define _PILOT_BLOB_H_
-
-#include <stdint.h>
-
-#include <pi-appinfo.h>
-#include <pi-buffer.h>
-
-/* This is the blob that has the timezone data in it */
-#define BLOB_TYPE_CALENDAR_TIMEZONE_ID "Bd00"
-/* Not sure what this blob type is, but it's just some extra data that appears in some calendar records, when it exists it is always 4 bytes long */
-#define BLOB_TYPE_CALENDAR_UNKNOWN_ID "Bd01"
-
-/* Maximum number of blobs that can exist in a record, this is just a guess at the upper bound */
-#define MAX_BLOBS 10
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-	typedef struct {
-		/* type ranges from "Bd00" - "Bd09" */
-		char type[4];
-		int16_t length;
-		uint8_t *data;
-      } Blob_t;
-
-	extern void free_Blob
-	PI_ARGS((Blob_t *blob));
-
-	extern int unpack_Blob_p
-	PI_ARGS((Blob_t *blob, const unsigned char *data, const size_t position));
-
-	extern int pack_Blob
-	PI_ARGS((const Blob_t *blob, pi_buffer_t *buf));
-
-	extern Blob_t *dup_Blob
-	PI_ARGS((const Blob_t *blob));
-	
-	
-#ifdef __cplusplus
-};
-#endif
-
-  
-#endif /* _PILOT_BLOB_H */
-
-/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
-/* ex: set tabstop=4 expandtab: */
-/* Local Variables: */
-/* indent-tabs-mode: t */
-/* c-basic-offset: 8 */
-/* End: */
-
diff --git a/pilot-link_src/pi-calendar.h b/pilot-link_src/pi-calendar.h
deleted file mode 100644
index ff57401..0000000
--- a/pilot-link_src/pi-calendar.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * $Id$
- *
- * pi-calendar.h - Support for PalmOne Calendar application (CalendarDB-PDat),
- * this is a copy of datebook.c with the calendar fields added.
- * 
- * (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.
- */
-
-#ifndef _PILOT_CALENDAR_H_
-#define _PILOT_CALENDAR_H_
-
-#include <time.h>
-
-#include <stdint.h>
-
-#include <pi-appinfo.h>
-#include <pi-buffer.h>
-#include "pi-location.h"
-#include "pi-blob.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-        typedef enum {
-                calendar_v1,
-        } calendarType;
-
-	enum calendarRepeatType {
-		calendarRepeatNone,
-		calendarRepeatDaily,
-		calendarRepeatWeekly,
-		calendarRepeatMonthlyByDay,
-		calendarRepeatMonthlyByDate,
-		calendarRepeatYearly
-	};
-
-	/* This enumeration normally isn't of much use, as you can get just
-	   as useful results by taking the value mod 7 to get the day of the
-	   week, and div 7 to get the week value, with week 4 (of 0) meaning
-	   the last, be it fourth or fifth.
-	 */
-	enum calendarDayOfMonthType {
-		calendar_1stSun, calendar_1stMon, calendar_1stTue, calendar_1stWen, calendar_1stThu,
-		calendar_1stFri,
-		calendar_1stSat,
-		calendar_2ndSun, calendar_2ndMon, calendar_2ndTue, calendar_2ndWen, calendar_2ndThu,
-		calendar_2ndFri,
-		calendar_2ndSat,
-		calendar_3rdSun, calendar_3rdMon, calendar_3rdTue, calendar_3rdWen, calendar_3rdThu,
-		calendar_3rdFri,
-		calendar_3rdSat,
-		calendar_4thSun, calendar_4thMon, calendar_4thTue, calendar_4thWen, calendar_4thThu,
-		calendar_4thFri,
-		calendar_4thSat,
-		calendar_LastSun, calendar_LastMon, calendar_LastTue, calendar_LastWen, calendar_LastThu,
-		calendar_LastFri,
-		calendar_LastSat
-	};
-
-	enum calendarAdvanceTypes { calendar_advMinutes, calendar_advHours, calendar_advDays };
-
-	/**
-	 * Times in this structure are assumed to be local unless tz is not null.
-	 */
-	typedef struct CalendarEvent {
-		int event;			/* Is this a timeless event? 				*/
-		struct tm begin, end;		/* When does this appointment start and end? 		*/
-		int alarm;			/* Should an alarm go off?    				*/
-		int advance;			/* How far in advance should it be? 			*/
-		int advanceUnits; 		/* What am I measuring the advance in? 			*/
-		enum calendarRepeatType repeatType;	/* How should I repeat this appointment, if at all?	*/
-		int repeatForever;		/* Do repetitions end at some date?			*/
-		struct tm repeatEnd;		/* What date do they end on?  				*/
-		int repeatFrequency;		/* Should I skip an interval for each repetition?	*/
-		enum calendarDayOfMonthType repeatDay;	/* for repeatMonthlyByDay				*/
-		int repeatDays[7];		/* for repeatWeekly 					*/
-		int repeatWeekstart;		/* What day did the user decide starts the week?	*/
-		int exceptions;			/* How many repetitions are there to be ignored?	*/
-		struct tm *exception;		/* What are they?					*/
-		char *description;		/* What is the description of this appointment?		*/
-		char *note;			/* Is there a note to go along with it?			*/
-		char *location;                 /* location of the event */
-		Blob_t *blob[MAX_BLOBS];
-		Timezone_t *tz;                  /* the timezone information */
-          
-	} CalendarEvent_t;
-
-	typedef struct CalendarAppInfo {
-                calendarType type;
-		struct CategoryAppInfo category;
-		int startOfWeek;
-		uint8_t internal[18];    /* don't know what this is yet */
-	} CalendarAppInfo_t;
-
-	extern void new_CalendarEvent
-	  PI_ARGS((CalendarEvent_t *event));
-	extern void free_CalendarEvent
-	  PI_ARGS((CalendarEvent_t *event));
-	extern int unpack_CalendarEvent
-	    PI_ARGS((CalendarEvent_t *event, const pi_buffer_t *record, calendarType type));
-	extern int pack_CalendarEvent
-	    PI_ARGS((const CalendarEvent_t *event, pi_buffer_t *record, calendarType type));
-	extern int unpack_CalendarAppInfo
-	  PI_ARGS((CalendarAppInfo_t *appinfo, const unsigned char *AppInfo,
-		     size_t len));
-	extern int pack_CalendarAppInfo
-	  PI_ARGS((const CalendarAppInfo_t *appinfo, unsigned char *AppInfo,
-		     size_t len));
-
-	extern int copy_CalendarEvent
-	PI_ARGS((const CalendarEvent_t *source, CalendarEvent_t *dest));
-	
-#ifdef __cplusplus
-  };
-#endif
-
-#endif				/* _PILOT_CALENDAR_H_ */
-
-/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
-/* ex: set tabstop=4 expandtab: */
-/* Local Variables: */
-/* indent-tabs-mode: t */
-/* c-basic-offset: 8 */
-/* End: */
diff --git a/pilot-link_src/pi-location.h b/pilot-link_src/pi-location.h
deleted file mode 100644
index a9ce36a..0000000
--- a/pilot-link_src/pi-location.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * $Id$
- *
- * pi-location.h: Support for Palm Location databases (locLCusLocationDB, locLDefLocationDB and part of CalendarDB-PDat)
- * (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.
- */
-  
-#ifndef _PILOT_LOCATION_H_
-#define _PILOT_LOCATION_H_
-
-#include <stdint.h>
-
-#include <pi-appinfo.h>
-#include <pi-buffer.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-	enum DayOfWeek {
-		sunday, monday, tuesday, wednesday, thursday, friday, saturday
-	};
-
-	enum WeekOfMonth {
-		first, second, third, fourth, last
-	};
-
-	enum Month {
-		none, january, february, march, april, may, june, july, august,
-		september, october, november, december
-	};
-
-	typedef struct {
-		enum DayOfWeek dayOfWeek;
-		enum WeekOfMonth weekOfMonth;
-		enum Month month;
-		uint8_t unknown;
-      } DST_t;
-
-	enum CompassDirection { north, east, south, west };
-	typedef struct {
-		int16_t degrees; /* negative is N/E */
-		int16_t minutes; /* negative is N/E */
-		enum CompassDirection direction;
-      } EarthPoint_t;
-
-	typedef struct {
-		int16_t offset; /* Offset from GMT */
-		uint8_t t2; /* 00 - 03 */
-		DST_t dstStart;
-		DST_t dstEnd;
-		uint8_t dstObserved;
-		uint8_t t4;
-		uint8_t unknown; /* always 0x80 or 0x00 */
-		char* name; /* the name of the entry, null terminated, max 21 plus null */
-      } Timezone_t;
-
-	typedef struct {
-		Timezone_t tz;
-		uint8_t unknownExists;
-		uint8_t unknown;  /* byte that sometimes exists before the lat/lon */
-		EarthPoint_t latitude;
-		EarthPoint_t longitude;
-		char* note; /* the note for this timezone, null terminated string or just null */
-      } Location_t;
-	
-	extern void new_Timezone
-	  PI_ARGS((Timezone_t *));
-	extern void new_Location
-	  PI_ARGS((Location_t *));
-  
-	extern void free_Timezone
-	PI_ARGS((Timezone_t *tz));
-	extern void free_Location
-	PI_ARGS((Location_t *loc));
-	
-	extern int unpack_DST
-	PI_ARGS((DST_t *dst, const pi_buffer_t *buf));
-	extern int unpack_DST_p
-	PI_ARGS((DST_t *dst, const unsigned char *data, const size_t position));
-	extern int unpack_Timezone
-	PI_ARGS((Timezone_t *tz, const pi_buffer_t *buf));
-	extern int unpack_Timezone_p
-	PI_ARGS((Timezone_t *tz, const unsigned char *data, const size_t position));
-	extern int unpack_Location
-	PI_ARGS((Location_t *tz, const pi_buffer_t *buf));
-
-	extern int pack_DST
-	PI_ARGS((const DST_t *dst, pi_buffer_t *buf));
-	extern int pack_Timezone
-	PI_ARGS((const Timezone_t *tz, pi_buffer_t *buf));
-	extern int pack_Location
-	PI_ARGS((const Location_t *tz, pi_buffer_t *buf));
-
-	extern Timezone_t *dup_Timezone
-	PI_ARGS((const Timezone_t *tz));
-
-	extern int copy_Timezone
-	PI_ARGS((const Timezone_t *source, Timezone_t *dest));
-
-	extern int copy_Location
-	PI_ARGS((const Location_t *source, Location_t *dest));
-	
-#ifdef __cplusplus
-};
-#endif
-
-#endif				/* _PILOT_LOCATION_H_ */
-
-/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
-/* ex: set tabstop=4 expandtab: */
-/* Local Variables: */
-/* indent-tabs-mode: t */
-/* c-basic-offset: 8 */
-/* End: */
diff --git a/python_module_src/jpilot.i b/python_module_src/jpilot.i
index aa19ac0..f34f5b5 100644
--- a/python_module_src/jpilot.i
+++ b/python_module_src/jpilot.i
@@ -217,22 +217,22 @@ int jp_pc_write(char *DB_name, buf_rec *br);
 
     contactLabels = PyList_New(17);
     for (i = 0; i < 17; i++) {
-       PyList_SetItem(contactLabels,i,PYUNICODE_DECODE(ai.contactLabels[i]));
+       PyList_SetItem(contactLabels,i,PYUNICODE_DECODE(ai.labels[i]));
     }
 
     addressTypeLabels = PyList_New(3);
-    for (i = 0; i < 3; i++) {
-       PyList_SetItem(addressTypeLabels,i,PYUNICODE_DECODE(ai.addressTypeLabels[i]));
-    }
+    PyList_SetItem(addressTypeLabels,i,PYUNICODE_DECODE(ai.labels[26+0]));
+    PyList_SetItem(addressTypeLabels,i,PYUNICODE_DECODE(ai.labels[26+4]));
+    PyList_SetItem(addressTypeLabels,i,PYUNICODE_DECODE(ai.labels[26+8]));
 
-    addressLabels = PyList_New(4);
-    for (i = 0; i < 4; i++) {
-       PyList_SetItem(addressLabels,i,PYUNICODE_DECODE(ai.addressLabels[i]));
+    addressLabels = PyList_New(3);
+    for (i = 0; i < 3; i++) {
+       PyList_SetItem(addressLabels,i,PYUNICODE_DECODE(ai.addrLabels[i]));
     }
 
     imLabels = PyList_New(5);
     for (i = 0; i < 5; i++) {
-       PyList_SetItem(imLabels,i,PYUNICODE_DECODE(ai.imLabels[i]));
+       PyList_SetItem(imLabels,i,PYUNICODE_DECODE(ai.IMLabels[i]));
     }
 
     type = ai.type;
diff --git a/python_module_src/move_into_libpisock.c b/python_module_src/move_into_libpisock.c
index e8bf67f..d268733 100644
--- a/python_module_src/move_into_libpisock.c
+++ b/python_module_src/move_into_libpisock.c
@@ -1,12 +1,4 @@
-#include <pi-contact.h>
-/* interestingly, pi-address.h needs stddef.h or to be after another header.. */
-#include <pi-address.h>
-#include <pi-todo.h>
-#include <pi-memo.h>
-#include <pi-datebook.h>
-#include <pi-buffer.h>
-
-#include "pytype_basics.h"
+#include "move_into_libpisock.h"
 
 void new_Address(struct Address *a) {
   int i;
@@ -25,7 +17,7 @@ void new_Contact(struct Contact *a) {
   time_t now;
  
   /* Initialise attributes custom to this type of object */
-  for (i=0;i<NUM_CONTACT_PHONES;i++) {
+  for (i=0;i<7;i++) {
     a->phoneLabel[i] = 0;
   }
   for (i=0;i<3;i++) {
@@ -41,7 +33,9 @@ void new_Contact(struct Contact *a) {
   a->birthdayFlag =  0;
   a->reminder     = -1;
   
-  a->pictype = cpic_none;
+  for (i=0;i<MAX_CONTACT_BLOBS;i++) {
+    a->blob[i] = NULL;
+  }
   a->picture = NULL;
 
   time( &now );
diff --git a/python_module_src/move_into_libpisock.h b/python_module_src/move_into_libpisock.h
index 0ddf6fc..106bacc 100644
--- a/python_module_src/move_into_libpisock.h
+++ b/python_module_src/move_into_libpisock.h
@@ -1,7 +1,14 @@
+#include <stddef.h>
 #include <pi-contact.h>
+#include <pi-address.h>
 #include <pi-todo.h>
 #include <pi-memo.h>
 #include <pi-datebook.h>
+#include <pi-buffer.h>
+
+#include "pytype_basics.h"
+
+void new_Address(struct Address *a);
 
 void new_Contact(struct Contact *a);
 
diff --git a/python_module_src/pytype_contacts.c b/python_module_src/pytype_contacts.c
index fae6e4c..9bdf03d 100644
--- a/python_module_src/pytype_contacts.c
+++ b/python_module_src/pytype_contacts.c
@@ -93,17 +93,19 @@ extern int PyPiContact_Init(PyObject *self, PyObject *args, PyObject *kwds) {
     memcpy(&(contact->a), &(fromcontact->a), sizeof(struct Contact));
     
     /* Now do the pointers */
-    
-    if (fromcontact->a.picture) {
-      contact->a.picture = pi_buffer_new((fromcontact->a.picture)->used);
-      if (contact->a.picture == NULL) {
-	PyErr_SetString(PyExc_MemoryError,"Unable to allocate memory for picture");
-	return -1;	    
+
+    for(i=0;i<MAX_CONTACT_BLOBS;i++) {
+      if (fromcontact->a.blob[i] != NULL) {
+	Contact_add_blob(&(contact->a), fromcontact->a.blob[i]);
+	if (!strncmp(contact->a.blob[i]->type, BLOB_TYPE_PICTURE_ID, 4)) {
+	  contact->a.picture = malloc(sizeof(struct ContactPicture));
+	  contact->a.picture->dirty  = 0;
+	  contact->a.picture->length = contact->a.blob[i]->length;
+	  contact->a.picture->data   = contact->a.blob[i]->data;
+	}
       }
-      (contact->a.picture)->used = (fromcontact->a.picture)->used;
-      memcpy((contact->a.picture)->data,(fromcontact->a.picture)->data,(fromcontact->a.picture)->used);
     }
-    
+
     for(i=0;i<NUM_CONTACT_ENTRIES;i++) {
       if (fromcontact->a.entry[i]) {
 	if ((contact->a.entry[i] = malloc(strlen(fromcontact->a.entry[i])+1)) == NULL) {
@@ -200,17 +202,18 @@ extern PyObject* PyPiContact_Wrap(struct Contact *a, PCRecType rt,
   /* set saved_br stuff, and rt and unique_id, and attrib derived details for the current contact */
   SetSavedBrAndRTandUniqueIDandAttribs(rt, unique_id, attrib, size, buf, (PyObject *)contact);
 
-  /* Now do the pointers */
-  if (a->picture) {
-    contact->a.picture = pi_buffer_new((a->picture)->used);
-    if (contact->a.picture == NULL) {
-      PyErr_SetString(PyExc_MemoryError,"Unable to allocate memory for picture");
-      return NULL;	    
+  for(i=0;i<MAX_CONTACT_BLOBS;i++) {
+    if (a->blob[i] != NULL) {
+      Contact_add_blob(&(contact->a), a->blob[i]);
+      if (!strncmp(contact->a.blob[i]->type, BLOB_TYPE_PICTURE_ID, 4)) {
+	contact->a.picture = malloc(sizeof(struct ContactPicture));
+	contact->a.picture->dirty  = 0;
+	contact->a.picture->length = contact->a.blob[i]->length;
+	contact->a.picture->data   = contact->a.blob[i]->data;
+      }
     }
-    (contact->a.picture)->used = (a->picture)->used;
-    memcpy((contact->a.picture)->data,(a->picture)->data,(a->picture)->used);
   }
-
+  
   for(i=0;i<NUM_CONTACT_ENTRIES;i++) {
     if (a->entry[i]) {
       if ((contact->a.entry[i] = malloc(strlen(a->entry[i])+1)) == NULL) {
@@ -495,7 +498,7 @@ static PyObject* PyPiContact_Generate_VCard(PyPiContact* self, PyObject *args, P
 
   safeAddPropValue(vcard,VCTitleProp,self->a.entry[contTitle]);
 
-  for (i=0;i<NUM_CONTACT_PHONES;i++) {
+  for (i=0;i<7;i++) {
     if ((self->a.entry[contPhone1 + i]) && (strcmp("",self->a.entry[contPhone1 + i]))) {
       switch(self->a.phoneLabel[i]) {
       case 0:
@@ -587,11 +590,11 @@ static PyObject* PyPiContact_Generate_VCard(PyPiContact* self, PyObject *args, P
 
     safeAddPropValue(vcard,VCCommentProp,self->a.entry[contNote]);
 
-    if (self->a.pictype == cpic_jpeg) {
+    if (self->a.picture != NULL) {
       prop = addProp(vcard,VCPhotoProp);
       setValueWithSize(prop, 
 		       (self->a.picture)->data, 
-		       (self->a.picture)->used);
+		       (self->a.picture)->length);
       addPropValue(prop,"TYPE",VCJPEGProp);
       addPropValue(prop,VCEncodingProp,VCBase64Prop);
     }
@@ -618,7 +621,7 @@ static PyObject* PyPiContact_Generate_VCard(PyPiContact* self, PyObject *args, P
     PYTYPE_CONTACTS_ADD_ADR_TO_VCARD(2);
     PYTYPE_CONTACTS_ADD_ADR_TO_VCARD(3);
 
-    for (i=0;i<NUM_CONTACT_CUSTOMS;i++) {  
+    for (i=0;i<9;i++) {  
       if (self->a.entry[contCustom1 + i]){
 	snprintf(strbuf,20,"X-Palm-Custom%d",i + 1);
 	safeAddPropValue(vcard,strbuf,self->a.entry[contCustom1 + i]);
@@ -752,9 +755,9 @@ PyObject *PyPiContact_GetItem(PyPiContact* self,  PyObject* key) {
   GET_INT_ATTR(keystring,"typeaddr3",a.addressLabel[2]);
 
   if (strcasecmp(keystring,"picture") == 0) {
-    if ((self->a.pictype == cpic_jpeg) && (self->a.picture)) {
+    if (self->a.picture != NULL) {
       PyObject *value;
-      value = PyString_FromStringAndSize((char *)((self->a.picture)->data), (self->a.picture)->used);
+      value = PyString_FromStringAndSize((char *)((self->a.picture)->data), (self->a.picture)->length);
       Py_DECREF(key);
       return value;
     } else {
@@ -765,7 +768,7 @@ PyObject *PyPiContact_GetItem(PyPiContact* self,  PyObject* key) {
   }
 
   if (strcasecmp(keystring,"phones") == 0) {
-    py_list = PyList_New(NUM_CONTACT_PHONES);
+    py_list = PyList_New(7);
     PyList_SET_ITEM(py_list, 0, PyPiContact_GetItem(self, PyString_FromString("phone1")));
     PyList_SET_ITEM(py_list, 1, PyPiContact_GetItem(self, PyString_FromString("phone2")));
     PyList_SET_ITEM(py_list, 2, PyPiContact_GetItem(self, PyString_FromString("phone3")));
@@ -778,7 +781,7 @@ PyObject *PyPiContact_GetItem(PyPiContact* self,  PyObject* key) {
   }  
 
   if (strcasecmp(keystring,"phones_with_labels") == 0) {
-    py_list = PyList_New(NUM_CONTACT_PHONES);
+    py_list = PyList_New(7);
     PyList_SET_ITEM(py_list, 0, Py_BuildValue("(Oi)",PyPiContact_GetItem(self, PyString_FromString("phone1")),
 					      self->a.phoneLabel[0]));
     PyList_SET_ITEM(py_list, 1, Py_BuildValue("(Oi)",PyPiContact_GetItem(self, PyString_FromString("phone2")),
@@ -804,7 +807,7 @@ PyObject *PyPiContact_GetItem(PyPiContact* self,  PyObject* key) {
     n = 7;
   }
   if (n > 0) {
-    for(i=0;i<NUM_CONTACT_PHONES;i++) {
+    for(i=0;i<7;i++) {
       if (n == self->a.phoneLabel[i]) {
 	if (self->a.entry[contPhone1 + i] != NULL) {
 	  Py_DECREF(key);
@@ -826,6 +829,7 @@ int PyPiContact_SetItem(PyPiContact* self, PyObject* key, PyObject* value) {
   char buf[255];
   char *keystring;
   PyObject *pytup, *pyint, *pystr;
+  struct ContactPicture picture;
   int n;
 
   if (!PyString_Check(key)) {
@@ -917,36 +921,44 @@ int PyPiContact_SetItem(PyPiContact* self, PyObject* key, PyObject* value) {
   SET_BOUNDED_INT_ATTR(keystring,"showphone",a.showPhone,value,0,4,buf,255);
 
   if (strcasecmp(keystring,"picture") == 0) {
-    if (value == Py_None) {
-      if (self->a.picture) {
-	pi_buffer_free(self->a.picture);
+
+    // free the old one (if any)
+    if (self->a.picture) {
+      for(n=0;n<MAX_CONTACT_BLOBS;n++) {	
+	// find which blob to free
+	if (self->a.blob[n]->data == self->a.picture->data) {
+	  free(self->a.blob[n]->data);
+	  free(self->a.blob[n]);
+	  self->a.blob[n] = NULL;
+	  free(self->a.picture);
+	  self->a.picture = NULL;
+	}
       }
-      self->a.picture = NULL;
-      self->a.pictype = cpic_none;
+    }
+
+    if (value == Py_None) {
+      // if we're removing the image, we're all done
+      self->unsaved_changes = 1;
       Py_DECREF(key);
       return 0;
     }
+    // otherwise we need to put in the new image
     if (!PyString_Check(value)) {
       PyErr_SetString(PyExc_TypeError,"picture must be set to a string (jpeg data)");
       Py_DECREF(key);
       return -1;
     }
-    size_t length;
-    char *buffer;
-    pi_buffer_t *pibuffer;
-    PyString_AsStringAndSize(value, &buffer, &length);
-    pibuffer = pi_buffer_new(length);
-    if (pibuffer == NULL) {
-      PyErr_SetString(PyExc_MemoryError,"Unable to allocate memory for picture");
-      return -1;	    
-    }
-    if (self->a.picture) {
-      pi_buffer_free(self->a.picture);
+    PyString_AsStringAndSize(value, (char **)(&picture.data), &picture.length);
+    Contact_add_picture(&(self->a), &picture);
+    self->a.picture->dirty = 0;
+    self->a.picture->length = picture.length;
+    // find the picture data again :-/
+    for(n=MAX_CONTACT_BLOBS;n>0;n--) {
+      if (!strncmp(self->a.blob[n]->type, BLOB_TYPE_PICTURE_ID, 4)) {
+	self->a.picture->data = self->a.blob[n]->data;
+	break;
+      }    
     }
-    self->a.picture = pibuffer;
-    (self->a.picture)->used = length;
-    memcpy((self->a.picture)->data,buffer,length);
-    self->a.pictype = cpic_jpeg;
     self->unsaved_changes = 1;
     Py_DECREF(key);
     return 0;
@@ -958,13 +970,13 @@ int PyPiContact_SetItem(PyPiContact* self, PyObject* key, PyObject* value) {
       Py_DECREF(key);
       return -1;
     }
-    if (PyList_GET_SIZE(value) != NUM_CONTACT_PHONES) {
+    if (PyList_GET_SIZE(value) != 7) {
       PyErr_SetString(PyExc_IndexError,"phone_with_labels must have 7 elements");
       Py_DECREF(key);
       return -1;
     }
 
-    for (n=0;n<NUM_CONTACT_PHONES;n++) {
+    for (n=0;n<7;n++) {
       pytup = PyList_GET_ITEM(value,n);
       if (!PyTuple_Check(pytup)) {
 	PyErr_SetString(PyExc_TypeError,"phone_with_labels must be set to a list containing tuples");

-- 
jppy - Python bindings and API for jpilot databases and a GTK2 GUI



More information about the Jppy-commit mailing list