Thanks for your valuable inputs. I have pasted my skeleton code of newRecord
function. Please tell me if I can do anything more to improve the speed. I
think AES encryption algorithm executes fast, it the problem with my
procedure.
Appreciate your time.
With regards
Jeffy
flag =
newVil("ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN",
"ELEVEN");
UInt16 newRecord(char *type,char *cate,char *cus1,char *cus2,char *cus3,char
*cus4,char *cus5,char *cus6,char *cus7,char *cus8,char *note)
{
MemHandle newRecordH;
char *precord;
UInt16
cateoffset,cus1offset,cus2offset,cus3offset,cus4offset,cus5offset,cus6offset
,cus7offset,cus8offset,noteoffset;
UInt16 newIndex;
//To store
char
*ENcate,*ENcus1,*ENcus2,*ENcus3,*ENcus4,*ENcus5,*ENcus6,*ENcus7,*ENcus8,*ENn
ote;
// 1) and 2) (make a new chunk with the correct size)
newRecordH = DmNewHandle(pvildb, DB_RECORD_SIZE);
if (newRecordH == NULL)
FrmAlert (DeviceFullAlert);
// 3) Copy the data from the unpacked record to the packed one.
precord =(char *)MemHandleLock(newRecordH);
DmSet(precord,0,DB_RECORD_SIZE,0);
cateoffset = DB_ID_START + StrLen(type) + 1;
cus1offset = cateoffset + StrLen(cate) + 1;
cus2offset = cus1offset + StrLen(cus1) + 1;
cus3offset = cus2offset + StrLen(cus2) + 1;
cus4offset = cus3offset + StrLen(cus3) + 1;
cus5offset = cus4offset + StrLen(cus4) + 1;
cus6offset = cus5offset + StrLen(cus5) + 1;
cus7offset = cus6offset + StrLen(cus6) + 1;
cus8offset = cus7offset + StrLen(cus7) + 1;
noteoffset = cus8offset + StrLen(cus8) + 1;
DmWrite(precord,DB_ID_START,type,StrLen(type));
DmWrite(precord,cateoffset,cate,StrLen(cate));
DmWrite(precord,cus1offset,cus1,StrLen(cus1));
DmWrite(precord,cus2offset,cus2,StrLen(cus2));
DmWrite(precord,cus3offset,cus3,StrLen(cus3));
DmWrite(precord,cus4offset,cus4,StrLen(cus4));
DmWrite(precord,cus5offset,cus5,StrLen(cus5));
DmWrite(precord,cus6offset,cus6,StrLen(cus6));
DmWrite(precord,cus7offset,cus7,StrLen(cus7));
DmWrite(precord,cus8offset,cus8,StrLen(cus8));
DmWrite(precord,noteoffset,note,StrLen(note));
/***********************
vilRecCatFindSortPosition Return where a record is or should be Useful to
find or find where to insert a record.
1) All the record fields in the database are encrypted. I'm finding the sort
position alphabetically with all the eleven columns.
So I can't have any column decrypted that would help me in sorting.
2) This function loops through all the records in the database , decrypts
each record (11 strings) and finds the sort position.
************************/
// Get the index
newIndex = vilRecCatFindSortPosition(pvildb, precord,type);
/***********************
3) ENCRYPT function dosn't accept Char *. So that is why I use
MemPtrNew,StrCopy and MemPtrFree.
How can I do this simple?
************************/
ENcate = MemPtrNew(StrLen(cate) + 1);
ENcus1 = MemPtrNew(StrLen(cus1) + 1);
ENcus2 = MemPtrNew(StrLen(cus2) + 1);
ENcus3 = MemPtrNew(StrLen(cus3) + 1);
ENcus4 = MemPtrNew(StrLen(cus4) + 1);
ENcus5 = MemPtrNew(StrLen(cus5) + 1);
ENcus6 = MemPtrNew(StrLen(cus6) + 1);
ENcus7 = MemPtrNew(StrLen(cus7) + 1);
ENcus8 = MemPtrNew(StrLen(cus8) + 1);
ENnote = MemPtrNew(StrLen(note) + 1);
StrCopy(ENcate,cate);
StrCopy(ENcus1,cus1);
StrCopy(ENcus2,cus2);
StrCopy(ENcus3,cus3);
StrCopy(ENcus4,cus4);
StrCopy(ENcus5,cus5);
StrCopy(ENcus6,cus6);
StrCopy(ENcus7,cus7);
StrCopy(ENcus8,cus8);
StrCopy(ENnote,note);
/***ENCRYPT (Char* sInput,UInt32 iInputLen, Char* sKey, UInt32 iKeyLen)
**/
ENCRYPT(ENcate,StrLen(ENcate),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus1,StrLen(ENcus1),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus2,StrLen(ENcus2),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus3,StrLen(ENcus3),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus4,StrLen(ENcus4),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus5,StrLen(ENcus5),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus6,StrLen(ENcus6),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus7,StrLen(ENcus7),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENcus8,StrLen(ENcus8),PVILPassword,StrLen(PVILPassword));
ENCRYPT(ENnote,StrLen(ENnote),PVILPassword,StrLen(PVILPassword));
DmWrite(precord,DB_ID_START,type,StrLen(type));
DmWrite(precord,cateoffset,ENcate,StrLen(ENcate));
DmWrite(precord,cus1offset,ENcus1,StrLen(ENcus1));
DmWrite(precord,cus2offset,ENcus2,StrLen(ENcus2));
DmWrite(precord,cus3offset,ENcus3,StrLen(ENcus3));
DmWrite(precord,cus4offset,ENcus4,StrLen(ENcus4));
DmWrite(precord,cus5offset,ENcus5,StrLen(ENcus5));
DmWrite(precord,cus6offset,ENcus6,StrLen(ENcus6));
DmWrite(precord,cus7offset,ENcus7,StrLen(ENcus7));
DmWrite(precord,cus8offset,ENcus8,StrLen(ENcus8));
DmWrite(precord,noteoffset,ENnote,StrLen(ENnote));
// 4) attach in place
DmAttachRecord(pvildb, &newIndex, newRecordH, 0);
MemHandleUnlock(newRecordH);
MemPtrFree(ENcate);
MemPtrFree(ENcus1);
MemPtrFree(ENcus2);
MemPtrFree(ENcus3);
MemPtrFree(ENcus4);
MemPtrFree(ENcus5);
MemPtrFree(ENcus6);
MemPtrFree(ENcus7);
MemPtrFree(ENcus8);
MemPtrFree(ENnote);
return newIndex;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/