home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 396.lha / MSH_v1.30s / src / support.c < prev   
C/C++ Source or Header  |  1990-07-10  |  4KB  |  197 lines

  1. /*-
  2.  * $Id: support.c,v 1.30 90/06/04 23:16:41 Rhialto Rel $
  3.  * $Log:    support.c,v $
  4.  * Revision 1.30  90/06/04  23:16:41  Rhialto
  5.  * Release 1 Patch 3
  6.  * 
  7. -*/
  8.  
  9. #include "dos.h"
  10.  
  11. extern PORT    *DosPort;    /* Our DOS port... */
  12.  
  13. typedef unsigned long        ulong;
  14. typedef unsigned char        ubyte;
  15.  
  16. /*
  17.  * PACKET ROUTINES.    Dos Packets are in a rather strange format as you
  18.  * can see by this and how the PACKET structure is extracted in the
  19.  * GetMsg() of the main routine.
  20.  */
  21.  
  22. void
  23. returnpacket(packet)
  24. register struct DosPacket *packet;
  25. {
  26.     register struct Message *mess;
  27.     register struct MsgPort *replyport;
  28.  
  29.     replyport = packet->dp_Port;
  30.     mess = packet->dp_Link;
  31.     packet->dp_Port = DosPort;
  32.     mess->mn_Node.ln_Name = (char *) packet;
  33.     mess->mn_Node.ln_Succ = NULL;
  34.     mess->mn_Node.ln_Pred = NULL;
  35.     PutMsg(replyport, mess);
  36. }
  37.  
  38. /*
  39.  * Are there any packets queued to our device?
  40.  */
  41.  
  42. int
  43. packetsqueued()
  44. {
  45.     return ((void *) DosPort->mp_MsgList.lh_Head !=
  46.         (void *) &DosPort->mp_MsgList.lh_Tail);     /* & inserted by OIS */
  47. }
  48.  
  49. /*
  50.  * DOS MEMORY ROUTINES
  51.  */
  52.  
  53. void           *
  54. dosalloc(bytes)
  55. register ulong    bytes;
  56. {
  57.     register ulong *ptr;
  58.  
  59.     bytes += sizeof (*ptr);
  60.     if (ptr = AllocMem(bytes, MEMF_PUBLIC | MEMF_CLEAR)) {
  61.     *ptr = bytes;
  62.     return (ptr + 1);
  63.     }
  64.  
  65.     return NULL;
  66. }
  67.  
  68. dosfree(ptr)
  69. register ulong *ptr;
  70. {
  71.     --ptr;
  72.     FreeMem(ptr, *ptr);
  73. }
  74.  
  75. /*
  76.  * Convert a BSTR into a normal string.. copying the string into buf. I
  77.  * use normal strings for internal storage, and convert back and forth
  78.  * when required.
  79.  */
  80.  
  81. void
  82. btos(bstr, buf)
  83. ubyte           *bstr;
  84. ubyte           *buf;
  85. {
  86.     bstr = BTOC(bstr);
  87.     bmov(bstr + 1, buf, *bstr);
  88.     buf[*bstr] = 0;
  89. }
  90.  
  91. /*
  92.  * Some EXEC list handling routines not found in the EXEC library.
  93.  */
  94.  
  95. #ifdef notdef
  96.  
  97. void           *
  98. NextNode(node)
  99. register NODE        *node;
  100. {
  101.     node = node->mln_Succ;
  102.     if (node->mln_Succ == NULL)
  103.     return (NULL);
  104.     return (node);
  105. }
  106.  
  107. #endif
  108.  
  109. void           *
  110. GetHead(list)
  111. register LIST        *list;
  112. {
  113.     if ((void *) list->mlh_Head != (void *) &list->mlh_Tail)
  114.     return (list->mlh_Head);
  115.     return (NULL);
  116. }
  117.  
  118. void           *
  119. GetTail(list)
  120. register LIST        *list;
  121. {
  122.     if ((void *) list->mlh_Head != (void *) &list->mlh_Tail)
  123.     return (list->mlh_TailPred);
  124.     return (NULL);
  125. }
  126.  
  127. #ifdef HDEBUG
  128. char           *
  129. typetostr(ty)
  130. long ty;
  131. {
  132.     switch (ty) {
  133.     case ACTION_DIE:
  134.     return ("DIE");
  135.     case ACTION_CURRENT_VOLUME:
  136.     return ("CURRENT VOLUME");
  137.     case ACTION_OPENRW:
  138.     return ("OPEN-RW");
  139.     case ACTION_OPENOLD:
  140.     return ("OPEN-OLD");
  141.     case ACTION_OPENNEW:
  142.     return ("OPEN-NEW");
  143.     case ACTION_READ:
  144.     return ("READ");
  145.     case ACTION_WRITE:
  146.     return ("WRITE");
  147.     case ACTION_CLOSE:
  148.     return ("CLOSE");
  149.     case ACTION_SEEK:
  150.     return ("SEEK");
  151.     case ACTION_EXAMINE_NEXT:
  152.     return ("EXAMINE NEXT");
  153.     case ACTION_EXAMINE_OBJECT:
  154.     return ("EXAMINE OBJ");
  155.     case ACTION_INFO:
  156.     return ("INFO");
  157.     case ACTION_DISK_INFO:
  158.     return ("DISK INFO");
  159.     case ACTION_PARENT:
  160.     return ("PARENTDIR");
  161.     case ACTION_DELETE_OBJECT:
  162.     return ("DELETE");
  163.     case ACTION_CREATE_DIR:
  164.     return ("CREATEDIR");
  165.     case ACTION_LOCATE_OBJECT:
  166.     return ("LOCK");
  167.     case ACTION_COPY_DIR:
  168.     return ("DUPLOCK");
  169.     case ACTION_FREE_LOCK:
  170.     return ("FREELOCK");
  171.     case ACTION_SET_PROTECT:
  172.     return ("SETPROTECT");
  173.     case ACTION_SET_COMMENT:
  174.     return ("SETCOMMENT");
  175.     case ACTION_RENAME_OBJECT:
  176.     return ("RENAME");
  177.     case ACTION_INHIBIT:
  178.     return ("INHIBIT");
  179.     case ACTION_RENAME_DISK:
  180.     return ("RENAME DISK");
  181.     case ACTION_MORECACHE:
  182.     return ("MORE CACHE");
  183.     case ACTION_WAIT_CHAR:
  184.     return ("WAIT FOR CHAR");
  185.     case ACTION_FLUSH:
  186.     return ("FLUSH");
  187.     case ACTION_RAWMODE:
  188.     return ("RAWMODE");
  189.     case ACTION_SET_DATE:
  190.     return ("SET_DATE");
  191.     default:
  192.     return ("---------UNKNOWN-------");
  193.     }
  194. }
  195.  
  196. #endif                /* HDEBUG */
  197.