[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[coldsync-hackers] record attributes madness



No patch this time. I'm not even sure where to start with this one.

I've been trying to get my head around the state of attribute naming in 
various parts of ColdSync. It's not pretty.

Just to establish a baseline, PalmOS SDK 5 DLCommon.h:
// Database record attributes
#define  dlpRecAttrDeleted    0x80  // delete this record next sync
#define  dlpRecAttrDirty        0x40  // archive this record next sync
#define  dlpRecAttrBusy       0x20  // record currently in use
#define  dlpRecAttrSecret     0x10  // "secret" record
#define  dlpRecAttrArchived  0x08  // archived record

DataMgr.h uses Delete rather than Deleted and doesn't have archive, but 
otherwise it's about the same. I _do_ wonder what the Palm coder that wrote 
those comments was smoking, though.

ColdSync's pdb.h:
#define PDB_REC_EXPUNGED   0x80
#define PDB_REC_DIRTY            0x40
#define PDB_REC_DELETED       0x20
#define PDB_REC_PRIVATE        0x10
#define PDB_REC_ARCHIVE        0x08

Palm::PDB:
 $entry->{attributes}{expunged} = 1 if $attributes & 0x80;
 $entry->{attributes}{dirty} = 1 if $attributes & 0x40;
 $entry->{attributes}{deleted} = 1 if $attributes & 0x20;
 $entry->{attributes}{private} = 1 if $attributes & 0x10;
 $entry->{'attributes'}{'Delete'} = 1 if $attributes & 0x80;
 $entry->{'attributes'}{'Dirty'}     = 1 if $attributes & 0x40;
 $entry->{'attributes'}{'Busy'}      = 1 if $attributes & 0x20;
 $entry->{'attributes'}{'Secret'} = 1 if $attributes & 0x10;
and $entry->{attributes}{archive} for 0x08

ColdSync::SPC:
 $retval->{'attributes'}{'deleted'} = $retval->{'attrs'} & 0x80 ? 1 : 0;
 $retval->{'attributes'}{'dirty'} = $retval->{'attrs'} & 0x40 ? 1 : 0;
 $retval->{'attributes'}{'busy'} = $retval->{'attrs'} & 0x20 ? 1 : 0;
 $retval->{'attributes'}{'secret'} = $retval->{'attrs'} & 0x10 ? 1 : 0;
 $retval->{'attributes'}{'archived'} = $retval->{'attrs'} & 0x08 ? 1 : 0;

I'm sure you see where I'm going with this.

The short summary is that any chunk of code which mixes ColdSync::SPC 
records with Palm::PDB records is in trouble. ColdSync::PDB is an obvious 
candidate, but I was just in the process of migrating an algorithm from 
Palm::PDB to ColdSync::SPC and realized that there's no expunged attribute 
and "deleted" maybe doesn't mean "deleted". The "archive" to "archived" 
change seems minor in comparison.

As well, the pdb.h/Palm::PDB 'deleted' attribute just seems wrong. I assume 
there's a historical reason for this? The 'busy' (0x20) flag was just never 
set on sync?

My gut instinct at this point is to add the PalmOS 5 naming conventions
(Delete, Dirty, Busy, Secret, Archive) to ColdSync::SPC and just stick with 
those for any future work. Changing around the semantics of Palm::PDB would 
be a Bad Thing since it seems to have a pretty large installed base. 
ColdSync::SPC could change, of course, but it seems to be the only part of 
ColdSync that matches the SDK-5 attribute naming conventions :(

Comments?

c.
This message was sent through the coldsync-hackers mailing list.  To remove
yourself from this mailing list, send a message to majordomo@thedotin.net
with the words "unsubscribe coldsync-hackers" in the message body.  For more
information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.