peter@sugar.UUCP (Peter da Silva) (05/22/88)
Well, I'm trying to do a lock-based "rename" function, as follows. When I call
it I get amazing gurus. SendPkt is the routine from the compacket demo sent
out over the net lo these long months ago. I shan't post it unless it turns out
nobody can see the guilty party in the following code:
---------- snip snip ----------
FRename(l1, l2, name)
long l1, l2;
char *name;
{
char *bufptr;
long bstr;
struct FileLock *fl1, *fl2;
long args[4];
long status;
if(!l1 || !l2)
return 0;
fl1 = (struct FileLock *) (l1<<2);
fl2 = (struct FileLock *) (l2<<2);
if(fl1->fl_Volume != fl2->fl_Volume)
return 0;
bufptr = AllocMem(34, MEMF_CLEAR);
if(!bufptr) {
OutOfMemory(name);
return 0;
}
bufptr[0] = strlen(name);
strcpy(&bufptr[1], name);
bstr = ((long)bufptr) >> 2;
args[0] = l1;
args[1] = bstr;
args[2] = l2;
args[3] = bstr;
status = sendpkt(fl1->fl_Task, ACTION_RENAME_OBJECT, args, 4);
FreeMem(bufptr, 34);
return status;
}
---------- snip snip ----------
Possible problem 1: passing a BSTR to ACTION_RENAME_OBJECT. The docs just
specify a BPTR. a BSTR seemed the right thing to do by context.
Possible problem 2: fl1->fl_Task. This is documented as being an APTR to
the handler task for the lock. This should be the place to send the packet,
no?
Possible problem 3: args[0] == args[3].
--
-- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter
-- "Have you hugged your U wolf today?" ...!bellcore!tness1!sugar!peter
-- Disclaimer: These may be the official opinions of Hackercorp.