home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / NR4MAIL.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  1KB  |  72 lines

  1. /* NETROM mailbox interface
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  *
  4.  *  May '91 Bill Simpson
  5.  *      move to separate file for compilation & linking
  6.  */
  7. #include <ctype.h>
  8. #include "global.h"
  9. #ifdef NETROMSERVER
  10. #include "proc.h"
  11. #include "netrom.h"
  12. #include "socket.h"
  13. #include "session.h"
  14. #include "cmdparse.h"
  15. #include "commands.h"
  16. #include "mailbox.h"
  17. #include "nr4mail.h"
  18. #include "lapb.h"
  19. #include "telnet.h"
  20.   
  21. static int Nrsocket = -1;
  22.   
  23. int
  24. nr4start(argc,argv,p)
  25. int argc;
  26. char *argv[];
  27. void *p;
  28. {
  29.     int s;
  30.   
  31.     if (Nrsocket != -1)
  32.         return -1;
  33.   
  34.     psignal(Curproc,0); /* Don't keep the parser waiting */
  35.     chname(Curproc,"NETROM listener");
  36.     Nrsocket = socket(AF_NETROM,SOCK_SEQPACKET,0);
  37.     /* bind() is done automatically */
  38.     if (listen(Nrsocket,1) == -1) {
  39.         close_s(Nrsocket);
  40.         Nrsocket = -1;
  41.         return -1;
  42.     }
  43.     for(;;){
  44.         if((s = accept(Nrsocket,NULLCHAR,NULLINT)) == -1)
  45.             break;  /* Service is shutting down */
  46. #ifdef MAILBOX
  47.         /* Spawn a server */
  48.         if(newproc("mbox",2048,mbx_incom,s,(void *)NR4_LINK,NULL,0) == NULLPROC)
  49.             close_s(s);
  50. #else
  51.         to_ttylink(s,NRSESSION);
  52. #endif
  53.     }
  54.     close_s(Nrsocket);
  55.     Nrsocket = -1;
  56.     return 0;
  57. }
  58.   
  59. int
  60. nr40(argc,argv,p)
  61. int argc;
  62. char *argv[];
  63. void *p;
  64. {
  65.     close_s(Nrsocket);
  66.     Nrsocket = -1;
  67.     return 0;
  68. }
  69.   
  70. #endif /* NETROMSERVER */
  71.   
  72.