Update to malsync-2.2.0.

Big big thank to pilot-link developper
Florent Pillet <pilot-link at florentpillet dot com> for resolving a
tricky bad pointer issue.

ok steven@
This commit is contained in:
ajacoutot 2006-10-20 11:51:58 +00:00
parent 7f8e85cc3f
commit 52ff98a855
5 changed files with 342 additions and 14 deletions

View File

@ -1,13 +1,17 @@
# $OpenBSD: Makefile,v 1.25 2006/09/17 19:21:46 jasper Exp $ # $OpenBSD: Makefile,v 1.26 2006/10/20 11:51:58 ajacoutot Exp $
COMMENT= "command line tool to synchronize Palm pilot to AvantGo" COMMENT= "command line tool to synchronize Palm pilot to AvantGo"
VERSION= 2.1.1 VERSION= 2.2.0
DISTNAME= malsync_${VERSION}.src DISTNAME= malsync_${VERSION}.src
PKGNAME= malsync-${VERSION}p0 PKGNAME= malsync-${VERSION}
CATEGORIES= comms palm CATEGORIES= comms palm
MAINTAINER= Antoine Jacoutot <ajacoutot@lphp.org> MASTER_SITES= http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/distfiles/ \
http://gentoo.oregonstate.edu/distfiles/ \
ftp://ftp.fr.freebsd.org/pub/FreeBSD/distfiles/
MAINTAINER= Antoine Jacoutot <ajacoutot@openbsd.org>
# MPL # MPL
PERMIT_PACKAGE_CDROM= Yes PERMIT_PACKAGE_CDROM= Yes
@ -16,7 +20,7 @@ PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes PERMIT_DISTFILES_FTP= Yes
WANTLIB= c WANTLIB= c
LIB_DEPENDS= pisock.>=8::comms/pilot-link LIB_DEPENDS= pisock.>=9::comms/pilot-link
USE_GMAKE= Yes USE_GMAKE= Yes
WRKSRC= ${WRKDIR}/malsync WRKSRC= ${WRKDIR}/malsync

View File

@ -1,4 +1,4 @@
MD5 (malsync_2.1.1.src.tar.gz) = b6342df8559a53a51cf3294ac06ed992 MD5 (malsync_2.2.0.src.tar.gz) = d1c41526b91bb38c21a4ced01d26328c
RMD160 (malsync_2.1.1.src.tar.gz) = 59f17609ec30fa156a604e476852f6bed393f9f3 RMD160 (malsync_2.2.0.src.tar.gz) = 14be8ba01c20969eed8d7b718284880e0bbd424f
SHA1 (malsync_2.1.1.src.tar.gz) = c2746f25cd7a10409c342f34675dd072b6ea1cdd SHA1 (malsync_2.2.0.src.tar.gz) = c8400205b3f8770c105c9f62afdba20c94b85c26
SIZE (malsync_2.1.1.src.tar.gz) = 171745 SIZE (malsync_2.2.0.src.tar.gz) = 173851

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-Makefile,v 1.3 2004/12/29 04:57:15 pvalchev Exp $ $OpenBSD: patch-Makefile,v 1.4 2006/10/20 11:51:58 ajacoutot Exp $
--- Makefile.orig Sun Nov 17 11:52:53 2002 --- Makefile.orig Tue Sep 19 16:46:31 2006
+++ Makefile Tue Dec 28 21:48:50 2004 +++ Makefile Tue Sep 19 16:48:06 2006
@@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
TARGET = malsync TARGET = malsync
@ -13,7 +13,7 @@ $OpenBSD: patch-Makefile,v 1.3 2004/12/29 04:57:15 pvalchev Exp $
endif endif
TREETOP = . TREETOP = .
-PILOT_LINK_DIR = $(TREETOP)/pilot-link-0.11.5 -PILOT_LINK_DIR = $(TREETOP)/pilot-link-0.11.7
+PILOT_LINK_DIR = $(PREFIX) +PILOT_LINK_DIR = $(PREFIX)
-CFLAGS = -Wall -g -DMALSYNC -I$(TREETOP)/mal/common \ -CFLAGS = -Wall -g -DMALSYNC -I$(TREETOP)/mal/common \
@ -26,7 +26,7 @@ $OpenBSD: patch-Makefile,v 1.3 2004/12/29 04:57:15 pvalchev Exp $
$(TARGET): $(OBJS) $(TARGET): $(OBJS)
- $(CC) $(DYNLINK) $(CFLAGS) -o $@ $(OBJS) \ - $(CC) $(DYNLINK) $(CFLAGS) -o $@ $(OBJS) \
- -L${PILOT_LINK_DIR}/libpisock/.libs -lpisock $(LINKLIBS) - ${PILOT_LINK_DIR}/libpisock/.libs/libpisock.a $(LINKLIBS)
+ $(CC) $(DYNLINK) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) \ + $(CC) $(DYNLINK) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) \
+ -L${PILOT_LINK_DIR}/lib -lpisock $(LINKLIBS) + -L${PILOT_LINK_DIR}/lib -lpisock $(LINKLIBS)
clean: clean:

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-mal_client_unix_MAL31DBConfig_c,v 1.3 2006/10/20 11:51:58 ajacoutot Exp $
--- mal/client/unix/MAL31DBConfig.c.orig Fri Oct 20 12:22:01 2006
+++ mal/client/unix/MAL31DBConfig.c Fri Oct 20 12:22:14 2006
@@ -20,7 +20,7 @@
*/
#include <MAL31DBConfig.h>
-#ifdef DARWIN
+#ifdef __OpenBSD__
#include <stdlib.h>
#else
#include <malloc.h>

View File

@ -0,0 +1,312 @@
$OpenBSD: patch-malsync_c,v 1.1 2006/10/20 11:51:58 ajacoutot Exp $
--- malsync.c.orig Wed Jul 23 22:02:30 2003
+++ malsync.c Thu Oct 19 16:13:29 2006
@@ -100,8 +100,7 @@ typedef struct {
int pilot_rHandle;
int pilot_RecIndex;
recordid_t id;
- uint8 *pilot_buffer;
- int pilot_buffer_size;
+ pi_buffer_t *pi_buf;
/* Secure Network Library Stuff */
AGBool hasseclib;
@@ -266,8 +265,8 @@ syncInfoFree(PalmSyncInfo * pInfo)
if (NULL != pInfo->userConfig)
AGUserConfigFree(pInfo->userConfig);
- if (NULL != pInfo->pilot_buffer)
- free(pInfo->pilot_buffer);
+ if (NULL != pInfo->pi_buf)
+ pi_buffer_free (pInfo->pi_buf);
if (NULL != pInfo->commandProcessor)
AGCommandProcessorFree(pInfo->commandProcessor);
@@ -290,9 +289,8 @@ syncInfoNew()
bzero(pInfo, sizeof(PalmSyncInfo));
- pInfo->pilot_buffer_size = pbs;
- pInfo->pilot_buffer = (uint8 *)malloc(pbs);
- if (NULL == pInfo->pilot_buffer)
+ pInfo->pi_buf = pi_buffer_new (pbs);
+ if (NULL == pInfo->pi_buf)
goto fail;
/* Allocate the platform calls record. */
@@ -341,8 +339,7 @@ int16 readInt16(uint8 * p)
/*---------------------------------------------------------------------------*/
static void
readAndUseDeviceInfoDatabase(AGDeviceInfo * devInfo,
- uint8 *dev_db_info_buffer,
- uint32 dev_db_info_buffer_size)
+ pi_buffer_t *pi_buf)
{
int database_id = 0;
long result;
@@ -373,13 +370,13 @@ readAndUseDeviceInfoDatabase(AGDeviceInf
int rc;
rc = dlp_ReadRecordByIndex(sd, database_id, 0,
- (void *)dev_db_info_buffer,
- &id, &dev_db_info_buffer_size,
+ pi_buf,
+ &id,
&attr, &cat);
if (rc >= 0) {
- uint8 *p = dev_db_info_buffer;
+ uint8 *p = pi_buf->data;
int16 dev_db_info_version = readInt16(p);
p+=sizeof(int16);
devInfo->colorDepth = readInt32(p);
@@ -472,8 +469,7 @@ readDeviceInfo(PalmSyncInfo * pInfo)
}
readAndUseDeviceInfoDatabase(devInfo,
- pInfo->pilot_buffer,
- pInfo->pilot_buffer_size);
+ pInfo->pi_buf);
/* Override the color depth if the user wants low res images. */
if (lowres) {
@@ -663,31 +659,36 @@ static int32
readDeviceUserConfig32(int userConfigDBHandle, AGUserConfig **deviceUserConfig)
{
recordid_t id;
- int bufferSize = BUFFERSIZE;
+ pi_buffer_t *pi_buf;
int attr = 0;
int cat = 0;
int rc;
- uint8 buffer[BUFFERSIZE];
AGBufferReader * r = NULL;
- rc = dlp_ReadRecordByIndex(sd, userConfigDBHandle, 0, (void *)buffer,
- &id, &bufferSize, &attr, &cat);
+ pi_buf = pi_buffer_new (BUFFERSIZE);
+
+ rc = dlp_ReadRecordByIndex(sd, userConfigDBHandle, 0, pi_buf,
+ &id, &attr, &cat);
if (rc < 0) {
if (verbose)
printf("readDeviceUserConfig: dlp_ReadRecordByIndex , err = %d\n",
rc);
+ pi_buffer_free (pi_buf);
return 0;
}
- r = AGBufferReaderNew(buffer);
+ r = AGBufferReaderNew(pi_buf->data);
if (r) {
*deviceUserConfig = AGUserConfigNew();
AGUserConfigReadData(*deviceUserConfig, (AGReader*)r);
AGBufferReaderFree(r);
+ pi_buffer_free (pi_buf);
return id;
- } else
+ } else {
+ pi_buffer_free (pi_buf);
return 0;
+ }
}
#define BUFFERSIZE 0xFFFF
/*---------------------------------------------------------------------------*/
@@ -695,31 +696,36 @@ static int32 readDeviceUserConfig31(int
AGUserConfig **deviceUserConfig)
{
recordid_t id;
- int bufferSize = BUFFERSIZE;
int attr = 0;
int cat = 0;
int rc;
- uint8 buffer[BUFFERSIZE];
+ pi_buffer_t *pi_buf;
AGBufferReader * r = NULL;
- rc = dlp_ReadRecordByIndex(sd, userConfigDBHandle, 0, (void *)buffer,
- &id, &bufferSize, &attr, &cat);
+ pi_buf = pi_buffer_new (BUFFERSIZE);
+
+ rc = dlp_ReadRecordByIndex(sd, userConfigDBHandle, 0, pi_buf,
+ &id, &attr, &cat);
if (rc < 0) {
if (verbose)
printf("readDeviceUserConfig: dlp_ReadRecordByIndex , err = %d\n",
rc);
+ pi_buffer_free (pi_buf);
return 0;
}
- r = AGBufferReaderNew(buffer);
+ r = AGBufferReaderNew(pi_buf->data);
if (r) {
*deviceUserConfig = AGUserConfigNew();
MAL31ReadUserData(*deviceUserConfig, (AGReader*)r);
AGBufferReaderFree(r);
+ pi_buffer_free (pi_buf);
return id;
- } else
+ } else {
+ pi_buffer_free (pi_buf);
return 0;
+ }
}
/*---------------------------------------------------------------------------*/
static int32 readDeviceUserConfig(int userConfigDBHandle,
@@ -740,23 +746,25 @@ static void writeDeviceUserConfig(int us
{
recordid_t id;
- int bufferSize = BUFFERSIZE;
int attr = 0;
int cat = 0;
- uint8 buffer[BUFFERSIZE];
AGBufferWriter * w = NULL;
+
w = AGBufferWriterNew(0);
if (w) {
long result;
+ pi_buffer_t *pi_buf;
+ pi_buf = pi_buffer_new (BUFFERSIZE);
+
if (threeone) {
MAL31WriteUserData(deviceUserConfig, (AGWriter*)w);
} else {
AGUserConfigWriteData(deviceUserConfig, (AGWriter*)w);
}
- result = dlp_ReadRecordByIndex(sd, userConfigDBHandle, 0, (void *)buffer,
- &id, &bufferSize, &attr, &cat);
+ result = dlp_ReadRecordByIndex(sd, userConfigDBHandle, 0, pi_buf,
+ &id, &attr, &cat);
if (result < 0)
id = 0;
@@ -766,7 +774,7 @@ static void writeDeviceUserConfig(int us
AGBufferWriterGetBufferSize(w),
&id);
AGBufferWriterFree(w);
-
+ pi_buffer_free (pi_buf);
}
}
@@ -1044,17 +1052,17 @@ getRecordBase(PalmSyncInfo * pInfo, AGBo
int32 result;
int att = 0;
int cat = 0;
- int size = pInfo->pilot_buffer_size;
+ //int size = pInfo->pi_buf->allocated;
int idx = pInfo->pilot_RecIndex++;
result = (modonly) ?
- dlp_ReadNextModifiedRec (sd, pInfo->pilot_rHandle, pInfo->pilot_buffer,
+ dlp_ReadNextModifiedRec (sd, pInfo->pilot_rHandle, pInfo->pi_buf,
&pInfo->id, &idx,
- &size, &att, &cat)
+ &att, &cat)
:
dlp_ReadRecordByIndex(sd, pInfo->pilot_rHandle, idx,
- pInfo->pilot_buffer, &pInfo->id,
- &size, &att, &cat);
+ pInfo->pi_buf, &pInfo->id,
+ &att, &cat);
if (result < 0) {
closeDatabase(pInfo);
@@ -1070,7 +1078,7 @@ getRecordBase(PalmSyncInfo * pInfo, AGBo
}
pInfo->record = AGRecordInit(pInfo->record, pInfo->id,
AGPalmPilotAttribsToMALMod((uint8)att),
- size, pInfo->pilot_buffer, 0, NULL);
+ pInfo->pi_buf->used, pInfo->pi_buf->data, 0, NULL);
*record = pInfo->record;
return AGCLIENT_CONTINUE;
@@ -1363,7 +1371,6 @@ main(int argc, char *argv[])
static void
Connect(PalmSyncInfo *pi)
{
- struct pi_sockaddr addr;
int ret;
if (sd != 0)
@@ -1595,40 +1602,39 @@ fill_in_versioninfo(int sd, AGExpansionV
&database_id);
- if (result >= 0) {
- long syncReadResult;
- int attr = 0;
- int cat = 0;
- recordid_t id;
- int rc;
- const int version_buffer_size = 0x1000;
- uint8 version_buffer[version_buffer_size];
-
-
- rc = dlp_ReadRecordByIndex(sd, database_id,
- 0,
- (void *)version_buffer,
- &id,
- &version_buffer_size,
- &attr,
- &cat);
-
- if (rc >= 0) {
- ClientVersion cv;
- ClientVersionReadData(&cv,
- version_buffer_size,
- version_buffer);
- vi->device_major = cv.major;
- vi->device_minor = cv.minor;
- vi->device_build = cv.buildno;
-
- vi->conn_agent_major = cv.major;
- vi->conn_agent_minor = cv.minor;
- vi->conn_agent_build = cv.buildno;
- }
- dlp_CloseDB(sd, database_id);
-
+if (result >= 0) {
+ long syncReadResult;
+ int attr = 0;
+ int cat = 0;
+ recordid_t id;
+ int rc;
+ pi_buffer_t *version_buffer = pi_buffer_new(0x1000);
+
+ rc = dlp_ReadRecordByIndex(sd, database_id,
+ 0,
+ version_buffer,
+ &id,
+ &attr,
+ &cat);
+
+ if (rc >= 0) {
+ ClientVersion cv;
+ ClientVersionReadData(&cv,
+ version_buffer->used,
+ version_buffer->data);
+ vi->device_major = cv.major;
+ vi->device_minor = cv.minor;
+ vi->device_build = cv.buildno;
+
+ vi->conn_agent_major = cv.major;
+ vi->conn_agent_minor = cv.minor;
+ vi->conn_agent_build = cv.buildno;
}
+
+ pi_buffer_free(version_buffer);
+
+ dlp_CloseDB(sd, database_id);
+
+ }
}
-