home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 56
/
af056sub.adf
/
parnfs.lha
/
support.c
< prev
Wrap
C/C++ Source or Header
|
1993-12-02
|
5KB
|
251 lines
/*-
* $Id: support.c,v 1.1 1993/12/02 20:45:46 Rhialto Exp $
* $Log: support.c,v $
* Revision 1.1 1993/12/02 20:45:46 Rhialto
* Initial revision
*
-*/
#include "netfs.h"
/*
* PACKET ROUTINES. Dos Packets are in a rather strange format as you
* can see by this and how the PACKET structure is extracted in the
* GetMsg() of the main routine.
*/
Prototype void returnpacket(struct DosPacket *packet);
void
returnpacket(struct DosPacket *packet)
{
register struct Message *mess;
register struct MsgPort *replyport;
replyport = packet->dp_Port;
mess = packet->dp_Link;
packet->dp_Port = DosPort;
mess->mn_Node.ln_Name = (char *) packet;
mess->mn_Node.ln_Succ = NULL;
mess->mn_Node.ln_Pred = NULL;
PutMsg(replyport, mess);
}
/*
* Are there any packets queued to our device?
*/
Prototype int packetsqueued(void);
int
packetsqueued(void)
{
return ((void *) DosPort->mp_MsgList.lh_Head !=
(void *) &DosPort->mp_MsgList.lh_Tail); /* & inserted by OIS */
}
/*
* DOS MEMORY ROUTINES
*/
Prototype void *dosalloc(ULONG bytes);
void *
dosalloc(ULONG bytes)
{
register ULONG *ptr;
bytes += sizeof (*ptr);
if (ptr = AllocMem(bytes, MEMF_PUBLIC | MEMF_CLEAR)) {
*ptr = bytes;
return (ptr + 1);
}
return NULL;
}
Prototype void dosfree(ULONG *ptr);
void
dosfree(ULONG *ptr)
{
--ptr;
FreeMem(ptr, *ptr);
}
/*
* Convert a BSTR into a normal string.. copying the string into buf. I
* use normal strings for internal storage, and convert back and forth
* when required.
*/
Prototype void btos(UBYTE *bstr, UBYTE *buf);
void
btos(UBYTE *bstr, UBYTE *buf)
{
bstr = BTOC(bstr);
if (*bstr)
CopyMem(bstr + 1, buf, (long)*bstr);
buf[*bstr] = 0;
}
/*
* Some EXEC list handling routines not found in the EXEC library.
*/
Prototype void *NextNode(struct MinNode *node);
void *
NextNode(struct MinNode *node)
{
node = node->mln_Succ;
if (node->mln_Succ == NULL)
return (NULL);
return (node);
}
#ifdef notdef
Prototype void *GetHead(struct MinList *list);
void *
GetHead(struct MinList *list)
{
if ((void *) list->mlh_Head != (void *) &list->mlh_Tail)
return (list->mlh_Head);
return (NULL);
}
Prototype void * GetTail(struct MinList *list);
void *
GetTail(struct MinList *list)
{
if ((void *) list->mlh_Head != (void *) &list->mlh_Tail)
return (list->mlh_TailPred);
return (NULL);
}
#endif
#ifdef DEBUG
Prototype char *typetostr(long ty);
char *
typetostr(long ty)
{
switch (ty) {
case ACTION_DIE:
return ("DIE");
case ACTION_CURRENT_VOLUME:
return ("CURRENT VOLUME");
case ACTION_OPENRW:
return ("OPEN-RW");
case ACTION_OPENOLD:
return ("OPEN-OLD");
case ACTION_OPENNEW:
return ("OPEN-NEW");
case ACTION_READ:
return ("READ");
case ACTION_WRITE:
return ("WRITE");
case ACTION_CLOSE:
return ("CLOSE");
case ACTION_SEEK:
return ("SEEK");
case ACTION_EXAMINE_NEXT:
return ("EXAMINE NEXT");
case ACTION_EXAMINE_OBJECT:
return ("EXAMINE OBJ");
case ACTION_INFO:
return ("INFO");
case ACTION_DISK_INFO:
return ("DISK INFO");
case ACTION_PARENT:
return ("PARENTDIR");
case ACTION_DELETE_OBJECT:
return ("DELETE");
case ACTION_CREATE_DIR:
return ("CREATEDIR");
case ACTION_LOCATE_OBJECT:
return ("LOCK");
case ACTION_COPY_DIR:
return ("DUPLOCK");
case ACTION_FREE_LOCK:
return ("FREELOCK");
case ACTION_SET_PROTECT:
return ("SETPROTECT");
case ACTION_SET_COMMENT:
return ("SETCOMMENT");
case ACTION_RENAME_OBJECT:
return ("RENAME");
case ACTION_INHIBIT:
return ("INHIBIT");
case ACTION_RENAME_DISK:
return ("RENAME DISK");
case ACTION_MORECACHE:
return ("MORE CACHE");
case ACTION_WAIT_CHAR:
return ("WAIT FOR CHAR");
case ACTION_FLUSH:
return ("FLUSH");
case ACTION_RAWMODE:
return ("RAWMODE");
case ACTION_SET_DATE:
return ("SET_DATE");
/* 2.0 stuff: */
case ACTION_SET_FILE_SIZE:
return "ACTION_SET_FILE_SIZE";
case ACTION_SAME_LOCK:
return "ACTION_SAME_LOCK";
case ACTION_CHANGE_SIGNAL:
return "ACTION_CHANGE_SIGNAL ???";
case ACTION_WRITE_PROTECT:
return "ACTION_WRITE_PROTECT";
case ACTION_FH_FROM_LOCK:
return "ACTION_FH_FROM_LOCK";
case ACTION_IS_FILESYSTEM:
return "ACTION_IS_FILESYSTEM";
case ACTION_CHANGE_MODE:
return "ACTION_CHANGE_MODE";
case ACTION_COPY_DIR_FH:
return "ACTION_COPY_DIR_FH";
case ACTION_EXAMINE_FH:
return "ACTION_EXAMINE_FH";
case ACTION_PARENT_FH:
return "ACTION_PARENT_FH";
case ACTION_FORMAT:
return "ACTION_FORMAT";
case ACTION_MAKE_LINK:
return "ACTION_MAKE_LINK";
case ACTION_READ_LINK:
return "ACTION_READ_LINK";
case ACTION_LOCK_RECORD:
return "ACTION_LOCK_RECORD";
case ACTION_FREE_RECORD:
return "ACTION_FREE_RECORD";
case ACTION_EXAMINE_ALL:
return "ACTION_EXAMINE_ALL";
case ACTION_ADD_NOTIFY:
return "ACTION_ADD_NOTIFY";
case ACTION_REMOVE_NOTIFY:
return "ACTION_REMOVE_NOTIFY";
/* 3.0 stuff: */
case ACTION_EXAMINE_ALL_END:
return "ACTION_EXAMINE_ALL_END";
case ACTION_SET_OWNER:
return "ACTION_SET_OWNER";
case ACTION_SERIALIZE_DISK:
return "ACTION_SERIALIZE_DISK";
default:
return ("---------UNKNOWN-------");
}
}
#endif /* HDEBUG */