home *** CD-ROM | disk | FTP | other *** search
- /* Subs.c - Basic disk handler support routines */
-
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- /* |_o_o|\\ Copyright (c) 1987 The Software Distillery. All Rights Reserved */
- /* |. o.| || This program may not be distributed without the permission of */
- /* | . | || the author. BBS: */
- /* | o | || John Toebes (919)-471-6436 */
- /* | . |// */
- /* ====== */
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
- #include "handler.h"
-
- #ifdef DEBUG
- long _ECS;
- static long *debuglog;
-
- void initdebug()
- {
- debuglog = (long *)Open("CON:200/0/440/200/DISK-HANDLER", 1006);
- }
-
- void xwrite(str,len)
- char *str;
- int len;
- {
- long args[3];
- struct FileHandle *fh;
-
- fh = (struct FileHandle *)BADDR(debuglog);
- args[0] = (long)fh->fh_Arg1;
- args[1] = (long)str;
- args[2] = (long)len;
- sendpkt(fh->fh_Type,ACTION_WRITE,args,3);
- }
-
- void myprintf(str,p1,p2,p3,p4,p5,p6,p7,p8,p9)
- char *str;
- char *p1,*p2,*p3,*p4,*p5,*p6,*p7,*p8,*p9;
- {
- char buf[128];
- int len;
-
- len = sprintf(buf,str,p1,p2,p3,p4,p5,p6,p7,p8,p9);
- if (len>128) len = 128;
- xwrite(buf,len);
- }
-
- void myputbstr(str, name)
- char *str;
- char *name;
- {
- int len;
-
- xwrite(str, strlen(str));
- len = *name++;
- xwrite(name, len);
- xwrite("\n", 1);
- }
-
- void myputlstr(str, name, len)
- char *str;
- char *name;
- int len;
- {
- xwrite(str, strlen(str));
- xwrite(name, len);
- xwrite("\n", 1);
- }
-
- #endif
-
- /* misc.c - support routines - Phillip Lindsay (C) Commodore 1986
- * You may freely distribute this source and use it for Amiga Development -
- * as long as the Copyright notice is left intact.
- *
- * 30-SEP-86
- */
-
- /* returnpkt() - packet support routine
- * here is the guy who sends the packet back to the sender...
- */
-
- void retpkt(global, packet)
- GLOBAL global;
- struct DosPacket *packet;
- {
- struct Message *mess;
- struct MsgPort *replyport;
-
- replyport = packet->dp_Port;
- mess = packet->dp_Link;
- packet->dp_Port = global->port;
-
- PutMsg(replyport,mess);
- }
-
- /*
- * taskwait() ... Waits for a message to arrive at your port and
- * extracts the packet address which is returned to you.
- */
-
- struct DosPacket *taskwait(global)
- GLOBAL global;
- {
- struct Message *mymess;
-
- WaitPort(global->port); /* wait for packet */
- mymess = (struct Message *) GetMsg(global->port);
-
- global->pkt = (struct DosPacket *) mymess->mn_Node.ln_Name;
-
- #if 0
- BUG(("Incoming at %08lx from %08lx\n", global->pkt, global->pkt->dp_Port));
- #endif
- /* give them the pointer to the packet */
-
- return(global->pkt);
- }
-
- char *DosAllocMem(global, len)
- GLOBAL global;
- long len;
- {
- long *p;
-
- if (( p = (long *)AllocMem(len+4, MEMF_PUBLIC | MEMF_CLEAR)) == NULL)
- {
- if (global->pkt != NULL)
- {
- global->pkt->dp_Res1 = DOS_FALSE;
- global->pkt->dp_Res2 = ERROR_NO_FREE_STORE;
- }
- else
- {
- /* Gee. Out of memory AND there is nobody to tell about it ... */
- /* Only choice is to GURU. Maybe we could do something clever */
- /* but I doubt it... */
- BUG(("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"));
- BUG(("!!!!!!!!!!!! !!!!!!!!\n"));
- BUG(("!!!!!!!!!!!! OUT OF MEMORY !!!!!!!!\n"));
- BUG(("!!!!!!!!!!!! !!!!!!!!\n"));
- BUG(("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"));
- }
- }
- else
- *p++ = len;
-
- return((char *)p);
- }
-
- void DosFreeMem(p)
- char *p;
- {
- long *lp;
- long len;
-
- lp = (long *)p;
- len = *--lp;
- FreeMem((char *)lp, len);
- }
-
- #if 0
- /***********************************************************************
- *
- * Support Function -- Extended IO Request plus DosPacket
- *
- ***********************************************************************/
-
- struct IOExtPacket *CreateExtPkt(ioReplyPort,size)
- struct MsgPort *ioReplyPort;
- LONG size;
- {
- register struct IOExtPacket *ioExtPkt;
-
- if (ioReplyPort == 0)
- return (NULL);
-
- ioExtPkt = (struct IOExtPacket *)AllocMem (size, MEMF_CLEAR | MEMF_PUBLIC);
-
- if (ioExtPkt == 0)
- return (NULL);
-
- ioExtPkt->io_req.io_Message.mn_Node.ln_Type = NT_MESSAGE;
- ioExtPkt->io_req.io_Message.mn_Node.ln_Pri = 0;
- ioExtPkt->io_req.io_Message.mn_ReplyPort = ioReplyPort;
- ioExtPkt->io_req.io_Message.mn_Node.ln_Name = (char *)&(ioExtPkt -> io_pkt);
-
- ioExtPkt -> io_pkt.dp_Link = &(ioExtPkt ->io_req.io_Message);
- ioExtPkt -> io_pkt.dp_Port = ioReplyPort;
-
- return(ioExtPkt);
- }
-
- void DeleteExtPkt(ioExtPkt,size)
- struct IOExtPacket *ioExtPkt;
- LONG size;
- {
- FreeMem ((char *)ioExtPkt, size);
- }
- #endif
-