91
Development & Programming / Re: Pascal strings in struct for reading a resource
« Last post by joevt on May 08, 2024, 10:36:52 PM »The Resorcerer template says the strings are variable length, not fixed length.
The Mac OS 9 Lives Forum is dedicated to...
Installing, Maintaining, and Extending the functionality of Mac OS 9
Each Section can be Expanded or Compressed by clicking the Title of the section
This will shrink the Forum to display Only the Sections you want
typedef unsigned char Str255[256];
No, it doesn't: the footnote states "3) Under Mac OS 9.", with a full stop right after saying "9", meaning anything that is not 9 is excluded.
void CStrToCStr(char * src, char * dst) {
int len = strlen(src);
BlockMoveData(src, dst, len+1);
}
void PStrToPStr(Str255 src, Str255 dst) {
int len = src[0];
BlockMoveData(src, dst, len+1);
}
void CStrToPStr(char * src, Str255 dst) {
int len = strlen(src);
BlockMoveData(src, dst+1, len);
dst[0] = (char)len;
}
void PStrToCStr(Str255 src, char * dst) {
int len = src[0];
BlockMoveData(src+1, dst, len);
dst[len] = 0;
}
#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
Str255 projectPath; // project path
char pad1;
Str255 userName; // user name
char pad2;
Str255 revisionNum; // revision number
char pad3;
Str255 fileName; // filename
char pad4;
Str255 taskDesc; // task
char pad5;
Str255 comment; // comment
char pad6;
} CKIDRec, *CKIDPtr, **CKIDHandle;
Handle ResHandle;
CKIDRec CkidRecord;
refnum = openresfile(argv[1]);
ResHandle = Get1Resource('ckid',128);
HLock(ResHandle);
CkidRecord = **(CKIDRec **)ResHandle;
StringPtr projectPathPtr, userNamePtr;
Str255 projectPath, userName;
Size bytes;
projectPathPtr = (**(CKIDHandle)ResHandle).projectPath;
bytes = (**(CKIDHandle)ResHandle).projectPath[0] + 1;
BlockMove(projectPathPtr, projectPath, bytes);
userNamePtr = (**(CKIDHandle)ResHandle).userName;
bytes = (**(CKIDHandle)ResHandle).userName[0] + 1;
BlockMove(userNamePtr, userName, bytes);
Speaking of tutorials.. Here's another one that describes trick not mentioned anywhere else on the web:
http://macos9lives.com/smforum/index.php?topic=6742