--- gnome-pilot-conduits-2.0.12/expense/expense_conduit.c.port-to-pilot-link-0.12 2003-01-26 18:04:09.000000000 -0500 +++ gnome-pilot-conduits-2.0.12/expense/expense_conduit.c 2005-03-15 17:35:07.000000000 -0500 @@ -238,8 +238,7 @@ static gint copy_from_pilot( GnomePilotConduit *c, GnomePilotDBInfo *dbi ) { int dbHandle; - guchar buffer[0xffff]; - + pi_buffer_t *pi_buf; struct ExpenseAppInfo *tai; struct ExpensePref *tp; @@ -263,8 +262,10 @@ g_warning("Unable to open ExpenseDB"); return -1; } + + pi_buf = pi_buffer_new (0xffff); - unpack_ExpensePref(tp, buffer, 0xffff); + unpack_ExpensePref(tp, pi_buf->data, 0xffff); #ifdef EC_DEBUG fprintf(stderr, "Orig prefs, %d bytes:\n", ret); @@ -280,9 +281,9 @@ fprintf(stderr, "\n"); #endif /* EC_DEBUG */ - ret = dlp_ReadAppBlock(dbi->pilot_socket, dbHandle, 0, buffer, 0xffff); + ret = dlp_ReadAppBlock(dbi->pilot_socket, dbHandle, 0, 0xffff, pi_buf); - unpack_ExpenseAppInfo(tai, buffer, 0xffff); + unpack_ExpenseAppInfo(tai, pi_buf->data, 0xffff); #ifdef EC_DEBUG fprintf(stderr, "Orig length %d, new length %d, orig data:\n";, ret, i); @@ -323,7 +324,7 @@ struct Expense t; int attr, category, len; - len = dlp_ReadRecordByIndex(dbi->pilot_socket, dbHandle, i, buffer, 0, 0, &attr, &category); + len = dlp_ReadRecordByIndex(dbi->pilot_socket, dbHandle, i, pi_buf, 0, &attr, &category); /* at the end of all the records? */ if(len < 0) @@ -332,7 +333,7 @@ if((attr & dlpRecAttrDeleted) || (attr & dlpRecAttrArchived)) continue; - unpack_Expense(&t, buffer, len); + unpack_Expense(&t, pi_buf->data, len); writeout_record(filehandle[category], &t, c); free_Expense(&t); } @@ -348,6 +349,10 @@ /* Close the database */ dlp_CloseDB(dbi->pilot_socket, dbHandle); + + if (pi_buf) { + pi_buffer_free (pi_buf); + } return( result ); } --- gnome-pilot-conduits-2.0.12/memo_file/memo_file_conduit.c.port-to-pilot-link-0.12 2005-03-15 17:37:25.000000000 -0500 +++ gnome-pilot-conduits-2.0.12/memo_file/memo_file_conduit.c 2005-03-15 17:37:32.000000000 -0500 @@ -868,7 +868,7 @@ pre_sync (GnomePilotConduit *c, GnomePilotDBInfo *dbi) { int l; - unsigned char *buf; + pi_buffer_t *pi_buf; g_message ("MemoFile Conduit v %s", CONDUIT_VERSION); @@ -876,14 +876,14 @@ GET_CONDUIT_DATA (c)->dbi=dbi; - buf = (unsigned char*)g_malloc (0xffff); - if ((l=dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,(unsigned char *)buf, 0xffff))<0) { + pi_buf = pi_buffer_new (0xffff); + if ((l=dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,0xffff, pi_buf))<0) { LOG ("dlp_ReadAppBlock (...) failed"); - g_free (buf); + pi_buffer_free (pi_buf); return -1; } - unpack_MemoAppInfo (&(GET_CONDUIT_DATA (c)->ai), buf, l); - g_free (buf); + unpack_MemoAppInfo (&(GET_CONDUIT_DATA (c)->ai), pi_buf->data, l); + pi_buffer_free (pi_buf); if (GET_CONDUIT_CFG (c)->dir==NULL || *(GET_CONDUIT_CFG (c)->dir) == '\0') { return -1; --- gnome-pilot-conduits-2.0.12/email/email_conduit.c.port-to-pilot-link-0.12 2003-01-26 17:29:20.000000000 -0500 +++ gnome-pilot-conduits-2.0.12/email/email_conduit.c 2005-03-15 17:35:07.000000000 -0500 @@ -301,7 +301,7 @@ static gint synchronize( GnomePilotConduit *c, GnomePilotDBInfo *dbi ) { int dbHandle; - guchar buffer[0xffff]; + pi_buffer_t *pi_buf; struct MailAppInfo tai; struct MailSyncPref pref; struct MailSignaturePref sig; @@ -319,9 +319,11 @@ fprintf( stderr, "Unable to open mail database\n" ); return( -1 ); } + + pi_buf = pi_buffer_new (0xffff); - dlp_ReadAppBlock( dbi->pilot_socket, dbHandle, 0, buffer, 0xffff ); - unpack_MailAppInfo( &tai, buffer, 0xffff ); + dlp_ReadAppBlock( dbi->pilot_socket, dbHandle, 0, 0xffff, pi_buf); + unpack_MailAppInfo( &tai, pi_buf->data, 0xffff ); pref.syncType = 0; pref.getHigh = 0; @@ -333,20 +335,20 @@ if ( pi_version( dbi->pilot_socket ) > 0x0100 ) { if ( dlp_ReadAppPreference( dbi->pilot_socket, makelong("mail"), 1, 1, - 0xffff, buffer, 0, 0 ) >= 0 ) { - unpack_MailSyncPref( &pref, buffer, 0xffff ); + 0xffff, pi_buf, 0, 0 ) >= 0 ) { + unpack_MailSyncPref( &pref, pi_buf->data, 0xffff ); } else { if ( dlp_ReadAppPreference( dbi->pilot_socket, makelong("mail"), 1, - 1, 0xffff, buffer, 0, 0 ) >= 0 ) { - unpack_MailSyncPref( &pref, buffer, 0xffff ); + 1, 0xffff, pi_buf, 0, 0 ) >= 0 ) { + unpack_MailSyncPref( &pref, pi_buf->data, 0xffff ); } else { LOG("Couldn't get any mail preferences.\n",0); } } if ( dlp_ReadAppPreference( dbi->pilot_socket, makelong("mail"), 3, 1, - 0xffff, buffer, 0, 0 ) > 0 ) { - unpack_MailSignaturePref( &sig, buffer, 0xffff ); + 0xffff, pi_buf->data, 0, 0 ) > 0 ) { + unpack_MailSignaturePref( &sig, pi_buf->data, 0xffff ); } } @@ -359,7 +361,7 @@ FILE * sendf; length = dlp_ReadNextRecInCategory( dbi->pilot_socket, dbHandle, 1, - buffer, &recID, 0, &size, &attr ); + pi_buf, &recID, 0, &attr ); if ( length < 0 ) { break; @@ -369,7 +371,7 @@ continue; } - unpack_Mail( &t, buffer, length ); + unpack_Mail( &t, pi_buf->data, length ); sendf = popen( GET_CONFIG(c)->sendmail, "w" ); if ( sendf == NULL ) { @@ -451,7 +453,7 @@ } else if ( !strcmp( GET_CONFIG(c)->sendAction, "file" ) ) { dlp_WriteRecord( dbi->pilot_socket, dbHandle, attr, recID, 3, - buffer, size, 0); + pi_buf, size, 0); } free_Mail( &t ); } @@ -469,7 +471,7 @@ /* iterate through records in category 0 (Inbox) ... */ length = dlp_ReadNextRecInCategory( dbi->pilot_socket, dbHandle, 0, - buffer, &recID, 0, &size, &attr); + pi_buf, &recID, 0, &attr); if ( length < 0 ) { break; } @@ -479,7 +481,7 @@ record->recID = recID; record->size = length; record->buffer = ((guchar *) record) + sizeof(*record); - memcpy(record->buffer, buffer, length); + memcpy(record->buffer, pi_buf->data, length); inbox_list = g_list_append(inbox_list, record); LOG("storing record %d", recID); } @@ -523,19 +525,19 @@ #endif len = 0; - while ( ( len < sizeof(buffer) ) && - ( ( l = read( mhmsg, (char *)(buffer+len), - sizeof(buffer)-len ) ) > 0 ) ) { + while ( ( len < pi_buf->allocated ) && + ( ( l = read( mhmsg, (char *)(pi_buf->data+len), + pi_buf->allocated-len ) ) > 0 ) ) { len += l; } - buffer[len] = 0; + pi_buf->data[len] = 0; if ( l < 0 ) { fprintf( stderr, "Error processing message %d\n", i ); break; } - if (write_message_to_pilot (c, dbi, dbHandle, buffer, i)) { + if (write_message_to_pilot (c, dbi, dbHandle, pi_buf->data, i)) { rec++; if ( strcmp( GET_CONFIG(c)->receiveAction, "delete" ) == 0 ) { char filename[1000]; @@ -563,9 +565,9 @@ if (f) { - fgets (buffer, sizeof (buffer) - 1, f); - while (!feof (f) && strncmp (buffer, "From ", 5)) { - fgets (buffer, sizeof (buffer) - 1, f); + fgets (pi_buf->data, pi_buf->allocated - 1, f); + while (!feof (f) && strncmp (pi_buf->data, "From ", 5)) { + fgets (pi_buf->data, pi_buf->allocated - 1, f); } for( i = 1; !feof (f); i++ ) { int len; @@ -573,9 +575,9 @@ LOG( "Processing message %d", i ); len = 0; - while ( ( len < sizeof(buffer) ) && - ( ( p = fgets ( (char *)(buffer+len), - sizeof(buffer)-len, f ) ) != 0 ) ) { + while ( ( len < pi_buf->allocated ) && + ( ( p = fgets ( (char *)(pi_buf->data+len), + pi_buf->allocated-len, f ) ) != 0 ) ) { if (!strncmp (p, "From ", 5)) { break; } else { @@ -583,7 +585,7 @@ } } - buffer[len] = 0; + pi_buf->data[len] = 0; len = 0; if ( len < 0 ) { @@ -591,7 +593,7 @@ break; } - write_message_to_pilot (c, dbi, dbHandle, buffer, i); + write_message_to_pilot (c, dbi, dbHandle, pi_buf->data, i); } fclose (f); if ( strcmp( GET_CONFIG(c)->receiveAction, "delete" ) == 0 ) { @@ -621,6 +623,8 @@ dlp_ResetLastSyncPC( dbi->pilot_socket ); dlp_CloseDB( dbi->pilot_socket, dbHandle ); + pi_buffer_free (pi_buf); + return( 0 ); } --- gnome-pilot-conduits-2.0.12/mal-conduit/mal/client/unix/malsync.c.port-to-pilot-link-0.12 2002-09-16 13:16:23.000000000 -0400 +++ gnome-pilot-conduits-2.0.12/mal-conduit/mal/client/unix/malsync.c 2005-03-15 17:35:07.000000000 -0500 @@ -107,8 +107,7 @@ 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; @@ -270,8 +269,8 @@ 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); @@ -294,9 +293,8 @@ 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. */ @@ -345,8 +343,7 @@ /*---------------------------------------------------------------------------*/ 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 @@ 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 @@ } 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) { @@ -664,31 +660,36 @@ 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 /*---------------------------------------------------------------------------*/ @@ -696,31 +697,36 @@ 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, @@ -741,14 +747,16 @@ { 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); @@ -756,8 +764,8 @@ 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; @@ -767,7 +775,7 @@ AGBufferWriterGetBufferSize(w), &id); AGBufferWriterFree(w); - + pi_buffer_free (pi_buf); } } @@ -1055,17 +1063,17 @@ 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); @@ -1081,7 +1089,7 @@ } 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; @@ -1397,7 +1405,6 @@ static void Connect(PalmSyncInfo *pi) { - struct pi_sockaddr addr; int ret; if (sd != 0) @@ -1414,10 +1421,7 @@ exit(1); } - addr.pi_family = PI_AF_PILOT; - strcpy(addr.pi_device, device); - - ret = pi_bind(sd, (struct sockaddr*)&addr, sizeof(addr)); + ret = pi_bind(sd, device); if(ret == -1) { fprintf(stderr, "Unable to bind to port '%s'.\n", device); exit(1);