Recent Posts

Pages: [1] 2 3 4 5 6 7 8 9 10
1
Hi Daniel!
   Thank you very much for the reply!

   I'm not certain how to incorporate those. 

   Looking at the struct I posted, I'm first of all not quite certain it's right, but let's assume it is for the purposes of this question.  In C, a Str255 is really just a 256-byte string, right?  Ok, so let's say we have some data in projectPath that's not quite that long.  Now we want to access the next relevant field, userName.  How does C know where to get it from, because according to the struct that should be 257 bytes later, right?  But it's not, because projectPath is a Pascal string and starts with the length, then the data, then the \0, and then the pad, right?

   Is it even possible to use a C struct to handle this data?

Thank you so much for the help!
2
Here's all 4 possible string moves. Pick whichever one makes sense for your situation (and maybe add bounds checks or null pointer checks if needed). BlockMoveData is backward compatible with BlockMove (it sets a flag in the A-Line trap which is ignored by BlockMove implementations which don't check it) but is only for data guaranteed to not be 68k code. This means it doesn't have to flush caches (for later 680x0 CPUs) or invalidate the 68k Emulator's JIT cache (for PowerMacs). Which can speed things up.

Code: [Select]
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;
}
3
Hi guys!
   I'm not a super great C programmer, but I'm trying to knock out a "simple" MPW Tool to print the data contained in the 'ckid' resource that gets created by Projector when you check out a file.  Unfortunately, most of the data I want is in Pascal strings.

   The format of the 'ckid' resource is documented in Appendix A in the "Bldg & Mng Progs in MPW 2ed.pdf" file that comes with MPW.  But the data structure is only described in Pascal format.  Here is a C struct that I made that seems to me like it should be equivalent:

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
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;

In the program, I do something like this (Again, not sure this is the best, but it sort of works):

Code: [Select]
Handle ResHandle;
CKIDRec CkidRecord;

refnum = openresfile(argv[1]);

ResHandle = Get1Resource('ckid',128);

HLock(ResHandle);

CkidRecord = **(CKIDRec **)ResHandle;

This works pretty well, and I can access everything up to projectPath using CkidRecord.checkSum, etc.  But once I try to get to the Str255's, it starts returning garbage or crashing.

So I found another example for dealing with Pascal strings, and added this:

Code: [Select]
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);

After that, 'projectPath' contains the Project Path, but there's garbage in front of and behind it.  'userName' always contains garbage.  I can view what should be the correct data using ResEdit, however.

I wonder if it would be easier to take everything in the struct after revisionID as one big chunk and then manually parse through it, but I've tried that a few times and haven't come up with a scheme that works and doesn't crash my machine. 

Does all that make sense?  Does anyone have any suggestions or examples of code that uses a similar stucture and how to deal with it?  Or am I looking at this all wrong?

Many thanks in advance!
4
Sorry to report but I was unsuccessful in getting the optical drive to work. The one from the MBP was not recognised. Plus now  I know I can boot the install image from the USB/IDE drive then I guess the cdrom is not that much use anyway.

Many thanks for both of your suggestions!
5
News, Information & Feedback / Re: We're hiring (and have some ideas)!
« Last post by Knezzen on Today at 07:57:06 AM »
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

Good one! :D
6
:-) it was your post I came across that informed me about that tool! So thanks!
7
News, Information & Feedback / Re: We're hiring (and have some ideas)!
« Last post by ssp3 on Today at 06:22:45 AM »
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
8
..I just realised that you can boot from a IDE drive when attached via a cheap "USB<>IDE" adaptor. That makes life easier for installation for me without an optical drive since I've got the v9 image put to an IDE drive via iBored.

It's nice to see someone else, besides me, discovering the potential of this little app  :)
9
..I just realised that you can boot from a IDE drive when attached via a cheap "USB<>IDE" adaptor. That makes life easier for installation for me without an optical drive since I've got the v9 image put to an IDE drive via iBored.
10
 Whoops!
 
Looks like I broke something. I got the drive out of the MBP. But once in the Mac Mini it was not detected. It was getting power, but OSX did not recognise it.

I tried with Mac OS9 but I cannot now boot from the internal SDD (with Mac OS9), even from OF. Now when I boot from OSX and run Disk Utility it says the disk is unpartioned.

Looks like I need to start afresh!
Pages: [1] 2 3 4 5 6 7 8 9 10