I assume that you're filling in the 'expected' field as well:
> readInfo->done = false;
> readInfo->accum = MemPtrNew( contentLen );
> // <assume the accum field gets the right data>
> readInfo->ptr = readInfo->accum;
readInfo->expected = <number of bytes of data>;
> err = ExgDBRead( (ExgDBReadProcPtr) read_proc
> (ExgDBDeleteProcPtr) delete_proc,
> readInfo, &dbID, 0, &needReset, true);
> err = DmCreateDatabaseFromImage( readInfo->accum );
You're not passing back (via *sizeP) the number of bytes that you passed
back via *dataP:
> Err read_proc( void *dataP, UInt32 *sizeP, void *userDataP )
> {
> read_info *rinfo = (read_info*) userDataP;
> UInt16 readCount;
> int err = 0;
>
> if( rinfo->done ) {
> *sizeP = 0;
> return errNone;
> }
>
> if( rinfo->expected > 0 ) {
> readCount = rinfo->expected;
> if( readCount > *sizeP )
> readCount = *sizeP;
*sizeP = readCount;
> MemMove( dataP, rinfo->ptr, readCount );
> rinfo->ptr += readCount;
> rinfo->expected -= readCount;
> if( rinfo->expected <= 0 )
> rinfo->done = true;
> }
>
> return errNone;
> }
>
>
>
> typedef struct read_info {
> UInt16 expected;
> char *accum;
> char *ptr;
> Boolean done;
> } read_info;
Those are the only issues I noticed.
--
Danny Epstein
OS Engineer, Palm Inc.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/