81
Development & Programming / Re: Pascal strings in struct for reading a resource
« Last post by tenfifty2 on May 09, 2024, 08:27:10 AM »Ah, thank you joevt, that was really enlightening. I didn't think to look at it with Resourcerer.
Yes, the strings can be variable length, that's what I meant when I said the doc says they're Pascal strings, which the Mac OS includes represent as Str255. So when you say the pad can be used to treat it like a C string, how does that deal with the first part where the string length is coded? Can we still do this with the struct?
Another option I had was something like this:
Then taking CkidRecord.theRest and parsing it out. Not entirely sure how to do that though... I've taken a few stabs at it and I usually end up crashing the whole machine. Have a suggestion?
Thank you much!
Yes, the strings can be variable length, that's what I meant when I said the doc says they're Pascal strings, which the Mac OS includes represent as Str255. So when you say the pad can be used to treat it like a C string, how does that deal with the first part where the string length is coded? Can we still do this with the struct?
Another option I had was something like this:
Code: [Select]
#include <time.h>
typedef unsigned long uLong;
typedef unsigned short uShort;
typedef struct{
uLong checkSum; // checkSum
long LOC; // location identifier
short version; // ckid version number
short readOnly; // checkout state; 0=modifiable
char branch; // if modifiable & byte not 0, then branch was made on checkout
Boolean modifyReadOnly; // Did user execute "ModifyReadOnly"?
uShort history; // 1 if history present, 0 if not
uShort commentLength; // length of current comment if history is present
time_t checkoutDate; // date and time of checkout
time_t modificationDate; // modification date of file
uLong PIDa; // PID.a
uLong PIDb; // PID.b
short userID; // user ID
short fileID; // file ID
short revisionID; // revision ID
char theRest[1536] // We have to parse this out manually due to pstrings
} CKIDRec, *CKIDPtr, **CKIDHandle;
Then taking CkidRecord.theRest and parsing it out. Not entirely sure how to do that though... I've taken a few stabs at it and I usually end up crashing the whole machine. Have a suggestion?
Thank you much!