home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 2 / amigaformatcd02.iso / comms / netsoftware / nethandler.lha / NetHandler / server / device.c next >
Encoding:
C/C++ Source or Header  |  1989-09-16  |  2.0 KB  |  70 lines

  1. /* Device.c - Device support routines */
  2.  
  3. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  4. /* |_o_o|\\ Copyright (c) 1987 The Software Distillery. All Rights Reserved*/
  5. /* |. o.| || This program may not be distributed without the permission of */
  6. /* | .  | || the author.                                           BBS:    */
  7. /* | o  | ||   John Toebes    Dave Baker                     (919)-471-6436*/
  8. /* |  . |//                                                                */
  9. /* ======                                                                  */
  10. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  11.  
  12. #include "server.h"
  13.  
  14. int InitDevice(global)
  15. GLOBAL global;
  16. {
  17.    int rc;
  18.    struct StandardPacket *sp;
  19.    BUGP("InitDevice: Entry")
  20.    BUG(("InitDevice: Entry\n"));
  21.  
  22.    if ((global->n.devport = (struct MsgPort *)CreatePort(NULL,0))==NULL)
  23.    {
  24.       BUG(("********CreatePort Failed\n"));
  25.       BUGR("Can't init server")
  26.       return(1);        /* error in createport */
  27.    }  
  28.  
  29.    if(!(sp = global->stdpkt = (struct StandardPacket *)
  30.       AllocMem(sizeof(struct StandardPacket),MEMF_CLEAR)))
  31.    {
  32.       BUG(("********Couldn't allocate StandardPacket!!\n"));
  33.       BUGR("No memory!")
  34.       return(1);
  35.    }
  36.    sp->sp_Msg.mn_Node.ln_Name = (char *)(global->pkt= &(sp->sp_Pkt));
  37.    sp->sp_Pkt.dp_Link = &(sp->sp_Msg);
  38.  
  39.    if(!(global->dosport=(struct MsgPort *)DeviceProc("ROOT:")) &&
  40.       !(global->dosport=(struct MsgPort *)DeviceProc("SYS:")))
  41.    {
  42.       BUG(("********DeviceProc of ROOT: and SYS: Failed\n"));
  43.       BUGR("No DeviceProc")
  44.       return(1);
  45.    }
  46.    global->RP.RDevice = (RPTR)global->dosport;
  47.  
  48.    OpenTimer(global, global->n.port);
  49.  
  50.    rc = InitRDevice(global);
  51.  
  52.    BUGP("InitDevice: Exit")
  53.    return(rc);
  54. }
  55.  
  56. int TermDevice(global)
  57. GLOBAL global;
  58. {
  59.    CloseTimer(global);
  60.    TermRDevice(global);
  61.    return(1);
  62. }
  63.  
  64. void RmtDie(global, pkt)
  65. GLOBAL global;
  66. struct DosPacket *pkt;
  67. {
  68.    if(--global->n.run == 1) global->n.run = 0;
  69. }
  70.