home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / tcp / amitcp / amitcp-src-22.lha / AmiTCP-2.2 / src / l / inet-handler / runstart.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-17  |  1.9 KB  |  88 lines

  1. /*
  2.  * runstart.c
  3.  *
  4.  * crabbed and modified from Matt Dillon's fifo-handler
  5.  *
  6.  * Last modified: Fri Oct  8 19:32:19 1993 too
  7.  *
  8.  * HISTORY
  9.  * $Log: runstart.c,v $
  10.  * Revision 1.1  1993/10/24  12:50:39  too
  11.  * Initial revision
  12.  *
  13.  * Revision 1.1  1993/10/24  12:50:39  too
  14.  * Initial revision
  15.  *
  16.  *
  17.  */
  18.  
  19. #include <exec/types.h>
  20. #include <exec/nodes.h>
  21. #include <exec/ports.h>
  22. #include <exec/memory.h>
  23. #include <dos/dos.h>
  24. #include <dos/dosextens.h>
  25.  
  26. #define _INL_SOCKET_H_ /* socket functions aren't needed here */
  27. #define PROTO_SOCKET_H
  28. #include "system_includes.h"
  29.  
  30. #include "runstart.h"
  31.  
  32. static struct DosList * dl; /* well, this is for testing only */
  33.  
  34. extern struct DosLibrary * DOSBase;
  35.  
  36. struct MsgPort * mkDevice(char * devname, int namelen)
  37. {
  38.   struct RootNode *    root;
  39.   struct DosInfo *    info;
  40.   struct MsgPort *    PktPort;
  41.   
  42.   if ((PktPort = CreateMsgPort()) == NULL)
  43.     return NULL;
  44.   
  45.   dl = (struct DosList *)
  46.     AllocMem(sizeof(struct DosList) + namelen + 2, MEMF_PUBLIC);
  47.   if (dl == NULL) {
  48.     DeleteMsgPort(PktPort);
  49.     return NULL;
  50.   }
  51.   CopyMem(devname, (char *)(dl + 1) + 1, namelen);
  52.   *(char *)(dl + 1) = namelen;
  53.   
  54.   dl->dol_Type = DLT_DEVICE;
  55.   dl->dol_Task = PktPort;
  56.   dl->dol_Name = MKBADDR((char *)(dl+1));
  57.   
  58.   Forbid();
  59.   root  = (struct RootNode *)DOSBase->dl_Root;
  60.   info  = (struct DosInfo  *)BADDR(root->rn_Info);
  61.   dl->dol_Next = info->di_DevInfo;
  62.   info->di_DevInfo = MKBADDR(dl);
  63.   Permit();
  64.   
  65.   return PktPort;
  66. }
  67.  
  68. void delDevice()
  69. {
  70.   struct DosInfo *    info;
  71.   struct RootNode *    root;
  72.   struct DosList *    dls;
  73.   BPTR *        bpp;
  74.   
  75.   Forbid();
  76.   root  = (struct RootNode *)DOSBase->dl_Root;
  77.   info  = (struct DosInfo  *)BADDR(root->rn_Info);
  78.   
  79.   for (bpp = &info->di_DevInfo; (dls = BADDR(*bpp)); bpp = &dls->dol_Next)
  80.     if (dls == dl) {
  81.       *bpp = dls->dol_Next;
  82.       DeleteMsgPort(dl->dol_Task);
  83.       FreeMem(dl, sizeof(struct DosList) +
  84.           (int)*(char *)BADDR(dl->dol_Name) + 2);
  85.     }
  86.   Permit();
  87. }
  88.