home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2379 < prev    next >
Internet Message Format  |  1990-12-28  |  92KB

  1. From: purdon@athena.mit.edu (James R. Purdon III)
  2. Newsgroups: alt.sources
  3. Subject: slugnet - Multiple user conferencing system: Part 4 of 6
  4. Message-ID: <1990Dec20.164646.25441@athena.mit.edu>
  5. Date: 20 Dec 90 16:46:46 GMT
  6.  
  7. The slugnet program is a multiple-user, interactive conferencing
  8. facility.  It currently runs under a variety of System V-based and
  9. BSD-based operating systems (although certain functions may not be
  10. possible under some of these operating systems).
  11.  
  12. Cut here-------------------------------------------------------------------
  13.  
  14. #!/bin/sh
  15. # to extract, remove the header and type "sh filename"
  16. if `test ! -s ./slugnet.c`
  17. then
  18. echo "writing ./slugnet.c"
  19. cat > ./slugnet.c << '\End\Of\Shar\'
  20. /* @(#)slugnet.c    1.16 */
  21. #include "slugnet.h"
  22. #include <pwd.h>
  23.  
  24. #ifdef NETWORK
  25. #ifdef INTERLAN
  26. #include <interlan/socket.h>
  27. #include <interlan/netdb.h>
  28. #include <interlan/in.h>
  29. #else
  30. #include <sys/socket.h>
  31. #include <netdb.h>
  32. #include <netinet/in.h>
  33. #endif
  34. #endif NETWORK
  35.  
  36. #ifdef INTERLAN
  37. #include <interlan/il_ioctl.h>
  38. #else
  39. #include <sys/ioctl.h>
  40. #endif
  41.  
  42. #ifdef NETWORK
  43. int slugnet( socket, rhost )
  44. int socket;
  45. char *rhost;
  46. #endif NETWORK
  47. #ifdef LOCAL
  48. main()
  49. #endif LOCAL
  50. {
  51.  
  52.     /* pointers */
  53.  
  54.     char *p[LINLEN];
  55.  
  56.         /* strings */
  57.  
  58.         static char access[FLNMLN]="\0";
  59.         static char billing[4]="\0";
  60.         static char broad[24]=" < broadcast message >";
  61.         static char confer[CFRLEN]="\0"; /* conference name */
  62.         static char crrct[52]="\nIs the above information correct ( yes or no )? : ";
  63.         static char dprivs[FLNMLN]="\0"; /* default privileges */
  64.         static char host[HOSTLEN]="\0"; /* host name */
  65.         static char idfrmt[28]="\nFrom %s ( %s@%s / %s ):%s";
  66.         static char idstr[LINLEN]="\0"; /* user id string */
  67.         static char jsn[JSNLEN]="aaaa"; /* user jsn - incremented per job */
  68.         static char last[UNLEN]="\0"; /* last valid un */
  69.         static char line[LINLEN+80]="\0";
  70.         static char logset[4]="\0";
  71.     static char mode[MODELN]="U"; /* mode u = user, s = server */
  72.         static char modem[LINLEN]="\0";
  73.         static char msgbuf[MSGLEN]="\0";
  74.         static char name[NAMLEN]="New user";
  75.         static char newcfr[CFRLEN]="\0"; /* conference to join */
  76.         static char normal[2]=BLANKS;
  77.         static char notallow[34]=" Error: Insufficent privileges.\n";
  78.         static char offstr[6]="off.\n";
  79.         static char onstr[5]="on.\n";
  80.         static char offtst[5]=" off";
  81.         static char ontst[4]=" on";
  82.         static char pid[PIDLEN]="\0"; /* pid in string form */
  83.         static char portstr[4]="\0";
  84.         static char prompt[PRMLEN]="\0";
  85.         static char repeat[32]="Please answer 'yes' or 'no'. : ";
  86.     static char scratch[ MSGLEN ];    /* scratch buffer */
  87.         static char server[LINLEN]="\0"; /* server string */
  88.         static char slugid[UNLEN]="\0";
  89.         static char sndbuf[MSGLEN+80]="\0"; /* send buffer */
  90.         static char srvnam[8]="Server";
  91.     static char srvhst[HOSTLEN]; /* server host name */
  92.     static char thost[HOSTLEN]; /* target host name for private messages */
  93.     char *thstp; /* pointer for thost */
  94.         static char tjsn[JSNLEN]; /* target jsn for private messages */
  95.         static char un[UNLEN];
  96.         static char uprivs[FLNMLN]="\0"; /* user privileges */
  97.         static char usrerr[36];
  98.         static char waitstr[LINLEN]; /* string for wait mode */
  99.  
  100.         /* files */
  101.         
  102.     static char actfil[FLNMLN]; /* system accounting file name */
  103.         static char bgnfil[FLNMLN]; /* prelogin file name */
  104.         static char bilfil[FLNMLN]; /* billing options file */
  105.         static char confil[FLNMLN]; /* user configuration file name */
  106.         static char deffil[FLNMLN]; /* user definition file name */
  107.         static char dirfil[FLNMLN]; /* user directory file name */
  108.         static char hlpfil[FLNMLN]; /* help file name */
  109.         static char jsnfil[FLNMLN]; /* jsn file name */
  110.         static char newfil[FLNMLN]; /* news file name */
  111.         static char profil[FLNMLN]; /* user prologue file name */
  112.         static char rcvfil[FLNMLN]; /* receiver file name */
  113.         static char sysfil[FLNMLN]; /* system configuration file */
  114.         static char tmpfil[FLNMLN]; /* user scratch file */
  115.         static char usrfil[FLNMLN]; /* user directory file name */
  116.         static char valfil[FLNMLN]; /* validated user list file name */
  117.  
  118.     /* slugdir record structure */
  119.  
  120.         struct slugdir inpstr; /* for usrfil */
  121.  
  122.         /* paths */
  123.  
  124.         static char homedir[DIRLEN];
  125.         static char slugdir[DIRLEN];
  126.  
  127.     /* char functions */
  128.  
  129.     char *ctime(),*getcwd(),*getlogin();
  130.  
  131.     /* file descriptors */
  132.  
  133.         FILE *act,*con,*def,*hlp,*inp,*rcv,*snd,*tmp;
  134. #ifdef SYSV2
  135.     FILE *fopen();
  136. #endif SYSV2
  137.  
  138.     /* ints */
  139.  
  140.         int atend,bci,bco,bill,brdcst,change,count[MSGLEN],cntns_flg,dtime,echo,
  141.         echoplex,found,hlpon,hlp_found,i,ipid,j,join,k,l,login,msgpos,
  142.         msgflg,novice,nwlnln,prvflg,prmpt_flg,reclen,remote,ringok,
  143.         scroll,serial_number,soff,space,stop,timer,usr,wait;
  144.         int allon,memon,conon,logon,hoson; /* flags for some show commands */
  145.         unsigned int port; /* com port number */
  146.     int in,out;    /* file / socket descriptor */
  147.     int fromlen;    /* length of struct sockaddr */
  148.  
  149. #ifdef NETWORK
  150.     struct sockaddr_in from;
  151.     struct sockaddr_in *fromp;
  152. #endif NETWORK
  153.  
  154.     /* stuff for ioctl */
  155.  
  156.     int off, on;
  157.  
  158.     struct hostent *hp;
  159.  
  160.         int admin,brods,dirct,files,joinc,names,network,privt,ringr,systm; /* privileges */
  161. #ifndef ULTRIX
  162.     int euid, uid;
  163. #endif ULTRIX
  164.  
  165.         long time0,time1,time();
  166.  
  167. #ifdef ULTRIX
  168.         unsigned short uid, euid;
  169. #endif ULTRIX
  170. #ifdef SYSV2
  171.     unsigned sleep(),u;
  172.     void exit();
  173. #endif SYSV2
  174. #ifdef SYSV3
  175.     unsigned sleep(),u;
  176.     void exit();
  177. #endif SYSV3
  178. #ifdef ULTRIX
  179.     void sleep();
  180.     void exit();
  181. #endif ULTRIX
  182. #ifdef SYSV2
  183.     void sigquit(),sigstop(),sighang(),sigterm();
  184. #endif SYSV2
  185. #ifdef SYSV3
  186.     void sigquit(),sigstop(),sighang(),sigterm();
  187. #endif SYSV3
  188. #ifdef BSD4
  189.     int sigurg(),sigtstp(),sigquit(),sigstop(),sighang(),sigterm();
  190. #endif BSD4
  191. #ifdef ULTRIX
  192.     int sigurg(),sigtstp(),sigquit(),sigstop(),sighang(),sigterm();
  193. #endif ULTRIX
  194.  
  195.         /* password entry field */
  196.  
  197.         struct passwd *upasswd;
  198.         struct passwd *getpwuid();
  199.  
  200.     /* these are used by ioctl */
  201.  
  202.     on = ON;
  203.     off = OFF;
  204.  
  205.     /* initialize signal variables */
  206.  
  207.     hungup = OFF;
  208.     stopscroll = OFF;
  209.  
  210.     /* get process id and host name */
  211.  
  212.     sprintf( pid, "%d", getpid());
  213.         gethostname( host, HOSTLEN );
  214.     strcpy( srvhst, host );
  215. #ifdef DBG
  216.     fprintf( stderr, "pid: %s at 1\n", pid );
  217. #endif DBG
  218.  
  219.     /* set real and effective uids */
  220.  
  221.         uid = getuid();
  222.         euid = geteuid();
  223.  
  224.        /* handle interrupts and hangups */
  225.  
  226. #ifdef LOCAL
  227.         signal(SIGHUP, sighang);
  228.         signal(SIGQUIT, sigquit);
  229. #ifdef ULTRIX
  230.     signal( SIGINT, sigstop);
  231.     signal( SIGTSTP, sigtstp);
  232. #endif ULTRIX
  233. #ifdef BSD4
  234.     signal( SIGINT, sigstop);
  235.     signal( SIGTSTP, sigtstp);
  236. #endif BSD4
  237. #ifdef SYSV2
  238.     signal(SIGINT , sigstop);
  239. #endif SYSV2
  240. #ifdef SYSV3
  241.     signal(SIGINT , sigstop);
  242. #endif SYSV3
  243. #endif LOCAL
  244. #ifdef NETWORK
  245.         signal(SIGHUP, sighang);
  246.         signal(SIGQUIT, sigquit);
  247. #ifdef ULTRIX
  248.     signal( SIGURG, sigurg);
  249.     signal( SIGINT, sigstop);
  250.     signal( SIGTSTP, sigtstp);
  251. #endif ULTRIX
  252. #ifdef BSD4
  253.     signal( SIGURG, sigurg);
  254.     signal( SIGINT, sigstop);
  255.     signal( SIGTSTP, sigtstp);
  256. #endif BSD4
  257. #ifdef SYSV2
  258.     signal(SIGINT ,sigstop);
  259. #endif SYSV2
  260. #ifdef SYSV3
  261.     signal(SIGINT ,sigstop);
  262. #endif SYSV3
  263. #endif NETWORK
  264.         signal(SIGTERM,sigterm);
  265.  
  266.  
  267.         strcpy(tjsn,"    \0"); /* target jsn for private messages */
  268.         strcpy(un,"\0");
  269.         strcpy(usrerr," Error: chgusr return code is %d.\n");
  270.         strcpy(waitstr,"\0"); /* string for wait mode */
  271.  
  272.         /* files */
  273.  
  274.         strcpy( actfil,"\0"); /* system accounting file name */
  275.         strcpy( bgnfil,"\0"); /* prelogin file name */
  276.         strcpy( bilfil,"\0"); /* billing options file */
  277.         strcpy( confil,"\0"); /* user configuration file name */
  278.         strcpy( deffil,"\0"); /* user definition file name */
  279.         strcpy( dirfil,"\0"); /* user directory file name */
  280.         strcpy( hlpfil,"\0"); /* help file name */
  281.         strcpy( jsnfil,"\0"); /* jsn file name */
  282.         strcpy( newfil,"\0"); /* news file name */
  283.         strcpy( profil,"\0"); /* user prologue file name */
  284.         strcpy( rcvfil,"\0"); /* receiver file name */
  285.         strcpy( sysfil,"\0"); /* system configuration file */
  286.         strcpy( tmpfil,"\0"); /* user scratch file */
  287.         strcpy( usrfil,"\0"); /* user directory file name */
  288.         strcpy( valfil,"\0"); /* validated user list file name */
  289.  
  290.         /* directories */
  291.  
  292.         strcpy( slugdir, SLUGDIR );
  293. #ifdef SYSV2
  294.         i=setuid(uid);
  295. #endif SYSV2
  296. #ifdef SYSV3
  297.         i=setuid(uid);
  298. #endif SYSV3
  299.         getcwd( homedir, DIRLEN );
  300. #ifdef SYSV2
  301.         i=setuid(euid);
  302. #endif SYSV2
  303. #ifdef SYSV3
  304.         i=setuid(euid);
  305. #endif SYSV3
  306.  
  307.         bci=0;
  308.         bco=0;
  309.         nwlnln=strlen("\n");
  310. #ifdef NETWORK
  311.     in=socket;
  312.         out=socket;
  313.     if( rhost != (char *)NULL ){
  314.         on = ON;
  315.         ioctl( in, FIONBIO, (char *)&on );
  316.     }
  317. #endif NETWORK
  318. #ifdef LOCAL
  319.     in=fileno(stdin);
  320.     out=fileno( stdout );
  321. #endif LOCAL
  322. #ifdef DBG
  323.     fprintf( stderr, "pid: %s at 2\n", pid );
  324. #endif DBG
  325.         reclen = sizeof( struct slugdir );
  326.         serial_number=NULL;
  327.         /* sprintf(slugid,"SLUGNET%4x0000",serial_number); */
  328.     /* get server name */
  329.         upasswd = getpwuid( euid );
  330.         strcpy(slugid,upasswd->pw_name );
  331.         repchar(slugid,' ','0');
  332.         strcpy(un,slugid);
  333.         strcpy(last,un);
  334.  
  335.         sprintf(server,idfrmt,srvnam,slugid,srvhst,jsn,normal);
  336.  
  337.         /* set directory to slugnet */
  338.  
  339.         i = chdir( slugdir );
  340.  
  341.         if( i != NULL )
  342.         {
  343.                  bco=bco+transmit(out,"\nUnable to change to directory 'slugnet'.",NOCRLF);
  344.                  return(1);
  345.         }
  346.         /* set up system configuration */
  347.  
  348.         strcpy(line,"\0");
  349.         if(DEBUG==ON && euid==uid)
  350.         {
  351.                 bco=bco+transmit(out,"\nEnter name of system configuration file. : ",NOCRLF);
  352.                 bci=bci+receive( in,line,FLNMLN,OFF);
  353.         }
  354.         if(strlen(line)<=12)
  355.                 sscanf(line,"%s",sysfil);
  356.         else
  357.                 sscanf(line,"%15s",sysfil);
  358.         if(strlen(sysfil)==0)
  359.                 strcpy(sysfil,"slugsys.dat");
  360.  
  361.         if((i=getcfg(sysfil,access,actfil,bgnfil,billing,bilfil,deffil,dirfil,
  362.         hlpfil,jsnfil,logset,modem,newfil,portstr,dprivs,profil,usrfil,valfil))!=NULL)
  363.         {
  364.                 bco=bco+transmit(out,server,CRLF);
  365.                 sprintf(line," Error: getcfg return code is %d.\n",i);
  366.                 bco=bco+transmit(out,line,NOCRLF);
  367.                 return(2);
  368.         }
  369.  
  370.         /* set billing flag */
  371.  
  372.         if(strncmp(billing,onstr,2)==NULL)
  373.                 bill=ON;
  374.         else
  375.                 bill=OFF;
  376.  
  377.         /* set login flag */
  378.  
  379.         if(strncmp(logset,onstr,2)==NULL)
  380.                 login=ON;
  381.         else
  382.                 login=OFF;
  383.  
  384.         if(DEBUG==ON && euid==uid)
  385.         {
  386.                 sprintf(line,"\nSystem Configuration\n");
  387.                 sprintf(line,"  acc: %s",access);
  388.                 i=transmit(out,line,CRLF);
  389.                 sprintf(line,"  act: %s",actfil);
  390.                 i=transmit(out,line,CRLF);
  391.                 sprintf(line,"  bgn: %s",bgnfil);
  392.                 i=transmit(out,line,CRLF);
  393.                 sprintf(line,"  bil: %s",billing);
  394.                 i=transmit(out,line,CRLF);
  395.                 sprintf(line,"  blf: %s",bilfil);
  396.                 i=transmit(out,line,CRLF);
  397.                 sprintf(line,"  def: %s",deffil);
  398.                 i=transmit(out,line,CRLF);
  399.                 sprintf(line,"  dir: %s",dirfil);
  400.                 i=transmit(out,line,CRLF);
  401.                 sprintf(line,"  hlp: %s",hlpfil);
  402.                 i=transmit(out,line,CRLF);
  403.                 sprintf(line,"  jsn: %s",jsnfil);
  404.                 i=transmit(out,line,CRLF);
  405.                 sprintf(line,"  log: %s",logset);
  406.                 i=transmit(out,line,CRLF);
  407.                 sprintf(line,"  mod: %s",modem);
  408.                 i=transmit(out,line,CRLF);
  409.                 sprintf(line,"  new: %s",newfil);
  410.                 i=transmit(out,line,CRLF);
  411.                 sscanf(portstr,"%u",&port);
  412.                 sprintf(line,"  por: %u",port);
  413.                 i=transmit(out,line,CRLF);
  414.                 sprintf(line,"  pri: %s",dprivs);
  415.                 i=transmit(out,line,CRLF);
  416.                 sprintf(line,"  pro: %s",profil);
  417.                 i=transmit(out,line,CRLF);
  418.                 sprintf(line,"  sys: %s",sysfil);
  419.                 i=transmit(out,line,CRLF);
  420.                 sprintf(line,"  usr: %s",usrfil);
  421.                 i=transmit(out,line,CRLF);
  422.                 sprintf(line,"  val: %s",valfil);
  423.                 i=transmit(out,line,CRLF);
  424.                 sprintf(line,"%s",crrct);
  425.                 i=transmit(out,line,NOCRLF);
  426.                 yno:
  427.                 i=receive( in,line,LINLEN,OFF);
  428.                 if(strncmp(line,"n",1)==NULL) return(3);
  429.                 if(strncmp(line,"y",1)!=NULL)
  430.                 {
  431.                         printf("%s\n",line);
  432.                         sprintf(line,"%s",repeat);
  433.                         i=transmit(out,line,NOCRLF);
  434.                         goto yno;
  435.                 }
  436.         }
  437.  
  438.         /* wait for calls */
  439.  
  440.         wait_for_call:
  441.  
  442.         /* initialize variables */
  443.  
  444.         bci=0;
  445.         bco=0;
  446.         cntns_flg=OFF;
  447.         echo=ON;
  448.         echoplex=OFF;
  449.         found=OFF;
  450. #ifdef LOCAL
  451.         prmpt_flg=ON;
  452. #endif LOCAL
  453. #ifdef NETWORK
  454.     if( rhost != (char *)NULL )
  455.         prmpt_flg = OFF;
  456.     else
  457.             prmpt_flg=ON;
  458. #endif NETWORK
  459.         strcpy(uprivs,dprivs);
  460.  
  461.     /* see if access allowed */
  462.     
  463.     soff=open("slugnet.off",O_RDONLY);
  464.     if( soff >= NULL )
  465.     {
  466.         bco=bco+transmit(out,"Slugnet is currently unavailable.\n",CRLF );
  467.         return(4);
  468.     }
  469.     j=close(soff);
  470.  
  471.     /* get start time */
  472.  
  473.     time(&time0);
  474. #ifdef LOCAL
  475.         /* send prelogin news */
  476.  
  477.         bco=bco+transmit(out,"Slugnet on line.\n",CRLF);
  478.         bco=bco+send_file(out,bgnfil);
  479. #endif LOCAL
  480. #ifdef NETWORK
  481.     
  482.     /* if internodal client, send server command */
  483.  
  484.     if( rhost != (char *)NULL ){
  485.         strcpy( name, "Server" );
  486.         bco = bco + transmit(out,"set server on\n",CRLF);
  487.     } else {
  488.  
  489.                /* send prelogin news */
  490.  
  491.                bco=bco+transmit(out,"Slugnet on line.\n",CRLF);
  492.             bco=bco+send_file(out,bgnfil);
  493.     }
  494. #endif NETWORK
  495. #ifdef DBG
  496.     fprintf( stderr, "pid: %s at 3\n", pid );
  497. #endif DBG
  498.  
  499. #ifdef NETWORK
  500.     if( rhost == (char *)NULL ){
  501.         fromlen = sizeof( from );
  502.         if(getpeername( out, &from, &fromlen ) == 0 ) {
  503. #ifdef DBG
  504.             fprintf( stderr, "pid: %s at 4a\n", pid );
  505. #endif DBG
  506.             fromp = &from;
  507.             fromp->sin_port = ntohs((u_short)fromp->sin_port);
  508.             if((hp = gethostbyaddr( &fromp->sin_addr, sizeof( struct in_addr ), fromp->sin_family )) != (struct hostent *)NULL) {
  509. #ifdef DBG
  510.                 fprintf( stderr, "pid: %s at 5a\n", pid );
  511. #endif DBG
  512.                 strcpy( host, hp->h_name );
  513.             } else {
  514. #ifdef DBG
  515.                 fprintf( stderr, "pid: %s at 5b\n", pid );
  516. #endif DBG
  517.                 strcpy( host, inet_ntoa( from.sin_addr ));
  518.             }
  519.         }
  520.         strcpy( un, "unknown" );
  521.     } else {
  522.         hp = gethostent();
  523.         strcpy( host, hp->h_name );
  524.             upasswd = getpwuid( uid );
  525.             strcpy(un,upasswd->pw_name );
  526.     }
  527. #ifdef DBG
  528.     fprintf( stderr, "pid: %s at 5c\n", pid );
  529. #endif DBG
  530. #endif NETWORK
  531. #ifdef LOCAL
  532.         upasswd = getpwuid( uid );
  533.         strcpy(un,upasswd->pw_name );
  534. #endif LOCAL
  535. #ifdef DBG
  536.     fprintf( stderr, "pid: %s at 6\n", pid );
  537. #endif DBG
  538.  
  539.         /* initialize session variables */
  540.  
  541.     /* if uid equals euid, set all privileges */
  542.  
  543. #ifdef LOCAL
  544.     if( uid == euid )
  545.         strcpy(uprivs,"_abdfjnprs"); 
  546. #endif LOCAL
  547.  
  548.     /* assign privileges */
  549.  
  550.         if(find(uprivs,'a',15)>NULL)
  551.                 admin=ON;             /* administrator */
  552.         else
  553.                 admin=OFF;
  554.         if(find(uprivs,'b',15)>NULL)
  555.                 brods=ON;            /* broadcast allowed */
  556.         else
  557.                 brods=OFF;
  558.         if(find(uprivs,'d',15)>NULL)
  559.                 dirct=ON;            /* redirection allowed */
  560.         else
  561.                 dirct=OFF;
  562.         if(find(uprivs,'f',15)>NULL)
  563.                 files=ON;            /* access to files allowed */
  564.         else
  565.                 files=OFF;
  566.         if(find(uprivs,'j',15)>NULL)
  567.                 joinc=ON;            /* join command allowed */
  568.         else
  569.                 joinc=OFF;
  570.         if(find(uprivs,'n',15)>NULL)
  571.                 names=ON;            /* set name command allowed */
  572.         else
  573.                 names=OFF;
  574.         if(find(uprivs,'p',15)>NULL)
  575.                 privt=ON;            /* private messages allowed */
  576.         else
  577.                 privt=OFF;
  578.         if(find(uprivs,'r',15)>NULL)
  579.                 ringr=ON;            /* ring command allowed */
  580.         else
  581.                 ringr=OFF;
  582.         if(find(uprivs,'s',15)>NULL)
  583.                 systm=ON;            /* Shell access allowed */
  584.         else
  585.                 systm=OFF;
  586. #ifdef NETWORK
  587.     network = ON;
  588. #endif NETWORK
  589. #ifdef LOCAL
  590.     network = OFF;
  591. #endif LOCAL
  592. #ifdef DBG
  593.     fprintf( stderr, "pid: %s at 7\n", pid );
  594. #endif DBG
  595.         atend=OFF;
  596.         brdcst=OFF;
  597.         strcpy(confer,"Root");
  598.         if(login==OFF)
  599.                 strcpy(confil,"slugcon.dat");
  600.         else
  601.                 sprintf(confil,"slug%s.dat",un[11]);
  602.         dtime=15;
  603. #ifdef NETWORK
  604.         in=socket;
  605. #endif NETWORK
  606. #ifdef LOCAL
  607.     in = fileno( stdin );
  608. #endif LOCAL
  609.         inp=(FILE *)NULL;
  610.         join=OFF;
  611.     strcpy(mode,"U");
  612. #ifdef NETWORK
  613.     if( rhost != (char *)NULL ){
  614.         strcpy(mode,"S");
  615.         dtime = 1;
  616.     }
  617. #endif NETWORK
  618.         msgflg=ON;
  619.         msgpos=0;
  620.         msgbuf[msgpos]=(char)NULL;
  621. #ifdef NETWORK
  622.         out=socket;
  623. #endif NETWORK
  624. #ifdef LOCAL
  625.     out = fileno( stdout );
  626.         novice=ON;
  627.         echo=ON;
  628. #endif LOCAL
  629. #ifdef NETWORK
  630.     if( rhost != (char *)NULL ){
  631.             novice=OFF;
  632.             echo=OFF;
  633.     } else {
  634.         novice=ON;
  635.             echo=ON;
  636.     }
  637. #endif NETWORK
  638.         prvflg=OFF;
  639.         remote=OFF;
  640.         ringok=ON;
  641.         scroll=OFF;
  642.         sprintf(server,idfrmt,srvnam,slugid,srvhst,jsn,normal);
  643.         stop=OFF;
  644.         timer=ON;
  645.         wait=OFF;
  646.         strcpy(waitstr,"From");
  647.  
  648.         /* read user's configuration file, if it exists */
  649.  
  650. #ifdef SYSV2
  651.         i=setuid(uid);
  652. #endif SYSV2
  653. #ifdef SYSV3
  654.         i=setuid(uid);
  655. #endif SYSV3
  656.         i=chdir(homedir);
  657.         con=fopen(confil,"r");
  658.         if(con!=NULL)
  659.         {
  660.                 fscanf(con,"%s ",deffil);
  661.                 i=repchar(deffil,'_',' ');
  662.                 fscanf(con,"%u ",&dtime);
  663.                 fscanf(con,"%d ",&echo);
  664.                 fscanf(con,"%d ",&echoplex);
  665.                 fscanf(con,"%s ",name);
  666.                 i=repchar(name,'_',' ');
  667.                 fscanf(con,"%d ",&novice);
  668.                 fscanf(con,"%s ",profil);
  669.                 i=repchar(profil,'_',' ');
  670.                 fscanf(con,"%d ",&prmpt_flg);
  671.                 fscanf(con,"%d ",&ringok);
  672.                 fscanf(con,"%d ",&timer);
  673.                 fscanf(con,"%s ",waitstr);
  674.                 i=repchar(waitstr,'_',' ');
  675.                 j=fclose(con);
  676.         }
  677. #ifdef SYSV2
  678.     i=setuid(euid);
  679. #endif SYSV2
  680. #ifdef SYSV3
  681.     i=setuid(euid);
  682. #endif SYSV3
  683.         i=chdir(slugdir);
  684.  
  685.         /* setup jsn */
  686.  
  687.         if((i=getjsn(jsn,jsnfil,rcvfil))!=NULL)
  688.         {
  689.                 bco=bco+transmit(out,server,CRLF);
  690.                 sprintf(line," Error: getjsn return code is %d.\n",i);
  691.                 bco=bco+transmit(out,line,NOCRLF);
  692.                 return(5);
  693.         }
  694.  
  695.         /* send postlogin news */
  696.  
  697.         sprintf(server,idfrmt,srvnam,slugid,srvhst,jsn,normal);
  698. #ifdef LOCAL
  699.         bco=bco+transmit(out,BLANKS,CRLF);
  700.         bco=bco+transmit(out,server,CRLF);
  701.         bco=bco+transmit(out," Welcome to Slugnet!",CRLF);
  702.         bco=bco+send_file(out,newfil);
  703. #endif LOCAL
  704. #ifdef NETWORK
  705.     if( rhost == (char *)NULL ){
  706.             bco=bco+transmit(out,BLANKS,CRLF);
  707.             bco=bco+transmit(out,server,CRLF);
  708.             bco=bco+transmit(out," Welcome to Slugnet!",CRLF);
  709.             bco=bco+send_file(out,newfil);
  710.     }
  711. #endif NETWORK
  712.  
  713.         /* put user in user directory */
  714.  
  715.         if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
  716.         {
  717.                 bco=bco+transmit(out,server,CRLF);
  718.                 sprintf(line,usrerr,i);
  719.                 bco=bco+transmit(out,line,CRLF);
  720.                 return(6);
  721.         }
  722.  
  723.         /* build logon message */
  724.  
  725.         sprintf(sndbuf,"$server:a:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) logged on %s.\n$server:m:%s:\n",name,un,host,jsn,confer,mode,server,name,un,host,jsn,confer,confer);
  726.  
  727.         /* do prologue file, if present */
  728.  
  729. #ifdef SYSV2
  730.         i=setuid(uid);
  731. #endif SYSV2
  732. #ifdef SYSV3
  733.         i=setuid(uid);
  734. #endif SYSV3
  735.         i=chdir(homedir);
  736.         inp=fopen(profil,"r");
  737. #ifdef SYSV2
  738.         i=setuid(euid);
  739. #endif SYSV2
  740. #ifdef SYSV3
  741.         i=setuid(euid);
  742. #endif SYSV3
  743.         i=chdir(slugdir);
  744.  
  745.         /* main loop */
  746.  
  747.         while(strncmp(line,"exit",4)!=NULL)
  748.         {
  749.                 /* send message */
  750.  
  751.                 sndmsg:
  752.                 if(msgflg==ON||brdcst==ON||prvflg==ON)
  753.                 {
  754. #ifdef DBGC
  755.             if( mode[ 0 ] == 'S' )
  756.                 fprintf( stderr, "s:%s",sndbuf );
  757. #endif DBGC
  758.             lock(usrfil);
  759. #ifdef SYSV2
  760.                         usr=open(usrfil,O_RDWR|O_SYNC);
  761. #endif SYSV2
  762. #ifdef SYSV3
  763.                         usr=open(usrfil,O_RDWR|O_SYNC);
  764. #endif SYSV3
  765. #ifdef BSD4
  766.                         usr=open(usrfil,O_RDWR|O_FSYNC);
  767. #endif BSD4
  768. #ifdef ULTRIX
  769.                         usr=open(usrfil,O_RDWR|O_FSYNC);
  770. #endif ULTRIX
  771.             scratch[ 0 ] = ( char )NULL;
  772.                         for(;;)
  773.                         {
  774. #ifdef SYSV2
  775.                                 j=read(usr,&inpstr,(unsigned)reclen);
  776. #endif SYSV2
  777. #ifdef SYSV3
  778.                                 j=read(usr,&inpstr,(unsigned)reclen);
  779. #endif SYSV3
  780. #ifdef BSD4
  781.                                 j=read(usr,&inpstr,reclen);
  782. #endif BSD4
  783. #ifdef ULTRIX
  784.                                 j=read(usr,&inpstr,reclen);
  785. #endif ULTRIX
  786.                 if( j == NULL )
  787.                     break;
  788.  
  789.                 /* see if the jsn is valid */
  790.  
  791.                                 if(strncmp(inpstr.jsn,"    ",JSNLEN-1)!=NULL){
  792.  
  793.                     /* make sure the process is alive */
  794.  
  795.                     sscanf( inpstr.pid, "%d", &ipid );
  796.  
  797.                     if(kill(ipid,NULL)<NULL && strcmp( inpstr.confer, confer ) == NULL ) {
  798.  
  799.                             sprintf(msgbuf,"\n$server:d:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) disconnected.\n$server:m:%s:\n",inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer,inpstr.mode,server,inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer);
  800.                         strcat( scratch, msgbuf );
  801.                         msgbuf[ 0 ] = (char)NULL;
  802.                         strcpy( inpstr.jsn, "    " );
  803.  
  804.                         
  805. #ifndef SYSV2
  806.                                     j=lseek(usr,-(long)reclen,SEEK_CUR);
  807. #endif SYSV2
  808. #ifdef SYSV2
  809.                                     j=lseek(usr,-(long)reclen,CURRENT);
  810. #endif SYSV2
  811. #ifdef SYSV2
  812.                         j=write(usr,&inpstr,(unsigned)reclen);
  813. #endif SYSV2
  814. #ifdef SYSV3
  815.                         j=write(usr,&inpstr,(unsigned)reclen);
  816. #endif SYSV3
  817. #ifdef BSD4
  818.                                         j=write(usr,&inpstr,reclen);
  819. #endif BSD4
  820. #ifdef ULTRIX
  821.                                            j=write(usr,&inpstr,reclen);
  822. #endif ULTRIX
  823.  
  824.                         /* unlink rcvfil */
  825.  
  826.                         if( strncmp( inpstr.rcvfil, "*", 1 ) != NULL )
  827.                             unlink( inpstr.rcvfil );
  828.  
  829.  
  830.  
  831.  
  832.                                     } else if( strncmp(inpstr.confer,confer,strlen(confer))==NULL
  833.                                     && strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
  834.                     && strncmp(inpstr.rcvfil,"*",1)!=NULL
  835.                                     && msgflg==ON ){    
  836.                                             lock(inpstr.rcvfil);
  837.                                             snd=fopen(inpstr.rcvfil,"a");
  838.                                             fprintf(snd,"%s\n",sndbuf);
  839.                                             j=fclose(snd);
  840.                                             unlock(inpstr.rcvfil);
  841.                                     } else if( strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
  842.                     && strncmp(inpstr.rcvfil,"*",1)!=NULL
  843.                                     && brdcst==ON ){
  844.                                             lock(inpstr.rcvfil);
  845.                                             snd=fopen(inpstr.rcvfil,"a");
  846.                                             fprintf(snd,"%s\n",sndbuf);
  847.                                                 j=fclose(snd);
  848.                                             unlock(inpstr.rcvfil);
  849.                                     } else if( strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
  850.                     && strncmp(inpstr.rcvfil,"*",1)!=NULL
  851.                     && strncmp( inpstr.mode,"S",1)==NULL
  852.                                     && ( brdcst==ON || msgflg == ON || prvflg == ON )){
  853.                                             lock(inpstr.rcvfil);
  854.                                                snd=fopen(inpstr.rcvfil,"a");
  855.                                             fprintf(snd,"%s\n",sndbuf);
  856.                                             j=fclose(snd);
  857.                                             unlock(inpstr.rcvfil);
  858.                                     } else if( strncmp(inpstr.confer,confer,strlen(confer))==NULL
  859.                                     && strncmp(inpstr.jsn,tjsn,JSNLEN-1)==NULL
  860.                                     && strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
  861.                     && strncmp(inpstr.rcvfil,"*",1)!=NULL
  862.                     && ( thost[ 0 ] == NULL || strnicmp( inpstr.host, thost, strlen( thost )) == NULL )
  863.                                     && prvflg==ON ){
  864.                                             lock(inpstr.rcvfil);
  865.                                             snd=fopen(inpstr.rcvfil,"a");
  866.                                             fprintf(snd,"%s\n",sndbuf);
  867.                                             j=fclose(snd);
  868.                                             unlock(inpstr.rcvfil);
  869.                                     } else if( strncmp(inpstr.jsn,jsn,JSNLEN-1)==NULL
  870.                                        && echo==ON && join==OFF ){
  871.                                             lock(inpstr.rcvfil);
  872.                                             snd=fopen(inpstr.rcvfil,"a");
  873.                                             fprintf(snd,"%s\n",sndbuf);
  874.                                             j=fclose(snd);
  875.                                             unlock(inpstr.rcvfil);
  876.                     }
  877.                                 }
  878.                         }
  879.  
  880.                         j=close(usr);
  881.             unlock(usrfil);
  882.  
  883.             /* clean up disconnects */
  884.  
  885.             if( scratch[ 0 ] != (char )NULL ){
  886.                 strcpy( sndbuf, scratch );
  887.                 goto sndmsg;
  888.             }
  889.  
  890.                         /* do join */
  891.  
  892.                         if(join==ON)
  893.                         {
  894.                                 join=OFF;
  895.                                 strcpy(confer,newcfr);
  896.                     sprintf(sndbuf,"$server:c:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) logged on %s.\n$server:m:%s:\n",name,un,host,jsn,confer,mode,server,name,un,host,jsn,confer,confer);
  897.                                 if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
  898.                                 {
  899.                                         bco=bco+transmit(out,server,CRLF);
  900.                                         sprintf(line,usrerr,i);
  901.                                         bco=bco+transmit(out,line,CRLF);
  902.                                         return(7);
  903.                                 }
  904.                         goto sndmsg;
  905.                         }
  906.  
  907.                         /* do exit or bye */
  908.  
  909.                         if(atend==ON)
  910.                         {
  911.                                 /* update accounting file */
  912.  
  913.                 lock(actfil);
  914.                                 act=fopen(actfil,"a");
  915.                                 chmod(actfil,00600);
  916.                 time(&time1);
  917.                 i = (int)(time1 - time0);
  918.                                 fprintf(act,"%s@%s:%s:%d:%d:%d:%d:%d:%s",un,host,jsn,bci,bco,time0,time1,i,(char *)ctime(&time0));
  919.                                 i=fclose(act);
  920.                 unlock(actfil);
  921.  
  922.                                 /* remove user from directory */
  923.  
  924.                                 if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,ON,host,pid,mode))!=NULL)
  925.                                 {
  926.                                          bco=bco+transmit(out,server,NOCRLF);
  927.                                          sprintf(line,usrerr,i);
  928.                                          bco=bco+transmit(out,line,CRLF);
  929.                                          return(8);
  930.                                 }
  931.                                 goto cleanup;
  932.                         }
  933.                 }
  934.  
  935.                 /* print and reset user's receive file */
  936.  
  937.                 if(remote==OFF)
  938.                 {
  939.             lock(rcvfil);
  940.                         rcv=fopen(rcvfil,"r");
  941.                 }
  942.  
  943.                 /* bco=bco+send_file(out,rcvfil); */
  944.  
  945.         space = OFF;
  946.                 while(feof(rcv)==NULL)
  947.                 {
  948.                         i=rdline(rcv,line,LINLEN);
  949. #ifdef DBGC
  950.             if( mode[ 0 ] == 'S' )
  951.                 fprintf( stderr, "rf: %s\n", line );
  952. #endif DBGC
  953.             if( i > 0 && wait == OFF ) space = ON;
  954.             if(mode[0] == 'S' && line[ 0 ] == '$' ){
  955.                 bco=bco+transmit(out,line,CRLF);
  956.             }
  957.                         else if(line[ 0 ] == '$' && strncmp(line+1,jsn,JSNLEN-1)==NULL ){
  958.                                 for(i=5;i<LINLEN;++i) line[i-5]=line[i];
  959.                                 remote=ON;
  960.                 unlock(rcvfil);
  961.                                 goto parser;
  962.                         }
  963.                         if(line[ 0 ] != '$' && (i = strlen( line )) > 0 )
  964.                 bco=bco+transmit(out,line,CRLF);
  965.                         if(wait==ON)
  966.                         {
  967.                                 j=strlen(waitstr);
  968.                                 for(i=0;(i+j-1)<strlen(line);++i)
  969.                                 {
  970.                                         if(strncmp(line+i,waitstr,j)==NULL){
  971.                         wait=OFF;
  972. #ifdef NETWORK
  973.                         off = OFF;
  974.                         if( ioctl( in, FIONBIO, (char *)&off ) < NULL )
  975.                             perror( "ioctl2" );
  976. #endif NETWORK
  977.                     }
  978.                                 }
  979.                         }
  980.                 }
  981.         if( space == ON && mode[ 0 ] != 'S' ) bco = bco + transmit( out, "\n", NOCRLF );
  982.                 i=fclose(rcv);
  983.                 i=unlink(rcvfil);
  984.                 rcv=fopen(rcvfil,"a");
  985.                 i=fclose(rcv);
  986.         unlock(rcvfil);
  987.  
  988.                 /* reset message flags */
  989.  
  990.                 brdcst=OFF;
  991.                 msgflg=OFF;
  992.                 prvflg=OFF;
  993.                 remote=OFF;
  994.  
  995.                 /* display prompt */
  996.  
  997.                 prompter:
  998.  
  999.         /* see if SIGINT has been sent ( stops scroll and wait mode ) */
  1000.  
  1001.                 if(stopscroll==ON)
  1002.         {
  1003.             scroll=OFF;
  1004.             wait=OFF;
  1005.             stopscroll=OFF;
  1006. #ifdef LOCAL
  1007.             /* reset input */
  1008.  
  1009.             if( inp != (FILE *)NULL ) {
  1010.                 fclose( inp );
  1011.                 inp = (FILE *)NULL;
  1012.                 in = fileno( stdin );
  1013.             }
  1014.  
  1015. #endif LOCAL
  1016.  
  1017.         }
  1018.  
  1019.                 /* display prompt */
  1020.  
  1021.         if(scroll==OFF&&wait==OFF)
  1022.                 {
  1023.                         if(prmpt_flg)
  1024.                         {
  1025.                                 sprintf(prompt,"%s> ",confer);
  1026.                                 bco=bco+transmit(out,prompt,NOCRLF);
  1027.                         }
  1028.             if(cntns_flg)
  1029.                 sleep((unsigned)dtime);
  1030.                 }
  1031.  
  1032.                 /* clear line */
  1033.  
  1034.                 for(i=0;i<LINLEN;++i) line[i]=(char)NULL;
  1035.  
  1036.                 /* if scroll or wait mode, skip user input */
  1037.  
  1038.                 if(scroll==ON||wait==ON)
  1039.                 {
  1040. #ifdef NETWORK
  1041.             /* check the socket for activity */
  1042.  
  1043.             if( read( in, line, LINLEN ) > 0 ) {
  1044.                 stopscroll = ON;
  1045.                 off = OFF;
  1046.                 if( ioctl( in, FIONBIO, (char *)&off ) < NULL )
  1047.                     perror( "ioctl2" );
  1048.                 goto prompter;
  1049.             } 
  1050. #endif NETWORK
  1051.                         if(timer==ON)
  1052.                         {
  1053.                                 time(&time1);
  1054.                                 bco=bco+transmit(out,(char *)ctime(&time1),CRLF);
  1055.                         }
  1056. #ifdef SYSV2
  1057.                         sleep((unsigned)dtime);
  1058. #endif SYSV2
  1059. #ifdef SYSV3
  1060.                         u=sleep((unsigned)dtime);
  1061. #endif SYSV3
  1062. #ifdef BSD4
  1063.                         sleep((unsigned)dtime);
  1064. #endif BSD4
  1065. #ifdef ULTRIX
  1066.                         sleep((unsigned)dtime);
  1067. #endif ULTRIX
  1068.                         goto parser;
  1069.                 }
  1070.  
  1071.                 /* get input from user */
  1072.  
  1073.                 getinp:
  1074.                 if(inp==(FILE *)NULL) { 
  1075.             /*if( mode[ 0 ] == 'S' )
  1076.                                 bco=bco+transmit(out,"\n",NOCRLF);*/
  1077.                         bci=bci+receive( in,line,LINLEN,echoplex);
  1078. #ifdef DBGC
  1079.             if( mode[ 0 ] == 'S' ) 
  1080.                 fprintf( stderr, "rr: %s", line );
  1081. #endif DBGC
  1082.             if( mode[ 0 ] == 'S' ) 
  1083.                 sleep(( unsigned )dtime );
  1084.             /* strcpy( un, hp->h_name ); */
  1085.                 } else {
  1086.                         if(feof(inp)==NULL)
  1087.                         {
  1088.                                 bco=bco+transmit(out,"\n",CRLF);
  1089.                                 i=rdline(inp,line,LINLEN);
  1090.                         }
  1091.                         else
  1092.                         {
  1093.                                 i=fclose(inp);
  1094.                                 inp=(FILE *)NULL;
  1095.                                 goto getinp;
  1096.                         }
  1097.                 }
  1098.  
  1099.                 /* command parser */
  1100.  
  1101.                 parser:
  1102.         /* strcpy( un, hp->h_name ); */
  1103.  
  1104.         /* if user has hung up, do an "exit" command */
  1105.  
  1106.         if(hungup==ON)
  1107.         {
  1108.             strcpy(line,"exit");
  1109.         }
  1110.  
  1111.                 /* restore effective uid, just in case */
  1112.  
  1113. #ifdef SYSV2
  1114.                 i=setuid(euid);
  1115. #endif SYSV2
  1116. #ifdef SYSV3
  1117.                 i=setuid(euid);
  1118. #endif SYSV3
  1119.  
  1120.                 /* comments */
  1121.  
  1122.                 if(strncmp(line,"*",1)==NULL)
  1123.                 {
  1124.                         if(echo==ON) bco=bco+transmit(out,line,CRLF);
  1125.                         goto prompter;
  1126.                 }
  1127.  
  1128.         /* process server commands */
  1129.  
  1130.         else if(strnicmp(line,"$server:",8)==NULL && mode[ 0 ] == 'S' ){
  1131.         
  1132.             /* directory change commands */
  1133.  
  1134.             if( line[ 8 ] == 'a' ||
  1135.                 line[ 8 ] == 'c' ||
  1136.                 line[ 8 ] == 'd' ){
  1137.             
  1138.                 /* replace : with nulls and set pointers */
  1139.  
  1140.                 j = strlen( line );
  1141.                 k = 0;
  1142.                 for( i = 9; i < j; ++i ){
  1143.                     if( line[ i ] == ':' ){
  1144.                         line[ i ] = (char )NULL;
  1145.                         ++i;    
  1146.                         p[ k ] = line + i;
  1147.                         ++k;
  1148.                     }
  1149.                 }
  1150.                 
  1151.                 /* issue chgusr command */
  1152.  
  1153.                 if( line[ 8 ] == 'c')
  1154.                                         i=chgusr(p[ 0 ],p[ 1 ],p[ 3 ],p[ 4 ],"*",usrfil,OFF,p[ 2 ],pid,p[ 5 ]);
  1155.                 else if( line[ 8 ] == 'a' ){
  1156.                     setjsn( p[ 3 ], jsnfil );
  1157.                                         i=chgusr(p[ 0 ],p[ 1 ],p[ 3 ],p[ 4 ],"*",usrfil,OFF,p[ 2 ],pid,p[ 5 ]);
  1158.                 } else if( line[ 8 ] == 'd' )
  1159.                                         i=chgusr(p[ 0 ],p[ 1 ],p[ 3 ],p[ 4 ],"*",usrfil,ON,p[ 2 ],pid,p[ 5 ]);
  1160.  
  1161.             /* send connection report */
  1162.  
  1163.             } else if( line[ 8 ] == 'r' ){
  1164.                 lock(usrfil);
  1165. #ifdef SYSV2
  1166.                             usr=open(usrfil,O_RDWR|O_SYNC);
  1167. #endif SYSV2
  1168. #ifdef SYSV3
  1169.                             usr=open(usrfil,O_RDWR|O_SYNC);
  1170. #endif SYSV3
  1171. #ifdef BSD4
  1172.                             usr=open(usrfil,O_RDWR|O_FSYNC);
  1173. #endif BSD4
  1174. #ifdef ULTRIX
  1175.                             usr=open(usrfil,O_RDWR|O_FSYNC);
  1176. #endif ULTRIX
  1177.                             for(;;){
  1178. #ifdef SYSV2
  1179.                                     j=read(usr,&inpstr,(unsigned)reclen);
  1180. #endif SYSV2
  1181. #ifdef SYSV3
  1182.                                     j=read(usr,&inpstr,(unsigned)reclen);
  1183. #endif SYSV3
  1184. #ifdef BSD4
  1185.                                     j=read(usr,&inpstr,reclen);
  1186. #endif BSD4
  1187. #ifdef ULTRIX
  1188.                                     j=read(usr,&inpstr,reclen);
  1189. #endif ULTRIX
  1190.                     if( j == NULL )
  1191.                         break;
  1192.  
  1193.                     /* only send registered jsns */
  1194.  
  1195.                                     if(strncmp(inpstr.jsn,"    ",JSNLEN-1)!=NULL && ( strncmp(inpstr.jsn,jsn,JSNLEN-1) != NULL || strnicmp(inpstr.host,host,HOSTLEN-1) != NULL )){
  1196.                             sprintf(sndbuf,"\n$server:a:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) connected.\n$server:m:%s:\n",inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer,inpstr.mode,server,inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer);
  1197.                                     bco=bco+transmit(out,sndbuf,CRLF);
  1198.                     }
  1199.                 }
  1200.                             j=close(usr);
  1201.                 unlock(usrfil);
  1202.             
  1203.             /* message commands */
  1204.  
  1205.             } else if( line[ 8 ] == 'b' ){
  1206.                 strcpy( line, "broadcast" );
  1207.                 goto parser;
  1208.             } else {
  1209.                 j = strlen( line );
  1210.                 for( i = 10; i < j; ++i ){
  1211.                     if( line[ i ] == ':' ) {
  1212.                         line[ i ] = (char)NULL;
  1213.                         break;
  1214.                     }
  1215.                 }
  1216.                 if( line[ 8 ] == 'm' ){
  1217.                     strcpy( confer, &line[ 10 ]);
  1218.                     strcpy( line, "send" );
  1219.                     goto parser;
  1220.                 }
  1221.                 else if( line[ 8 ] == 'p' ){
  1222.                     strcpy( tjsn, &line[ 10 ]);
  1223.                     sprintf( line, "send %s", tjsn );
  1224.                     goto parser;
  1225.                 }
  1226.             }
  1227.         }
  1228.  
  1229.                 /* set commands */
  1230.  
  1231.                 else if(strnicmp(line,"set",3)==NULL)
  1232.                 {
  1233.             change = OFF;
  1234.                         bco=bco+transmit(out,server,CRLF);
  1235.  
  1236.             /* set server mode */
  1237.  
  1238.                         if(strnicmp(line+3," server",7)==NULL)
  1239.                         {
  1240. #ifdef SERVER
  1241.                                 if(strncmp(line+10,ontst,3)==NULL){
  1242.                     echo = OFF;
  1243.                                         mode[ 0 ] = 'S';
  1244.                     prmpt_flg = OFF;
  1245.                     strcpy( name, "Server" );
  1246.                     dtime=1;
  1247.                     on = ON;
  1248.                     ioctl( in, FIONBIO, (char *)&on ); 
  1249.                 } else if(strncmp(line+10,offtst,4)==NULL){
  1250.                     echo = ON;
  1251.                                         mode[ 0 ] = 'U';
  1252.                     prmpt_flg = ON;
  1253.                     strcpy( name, "unknown" );
  1254.                     off = OFF;
  1255.                     ioctl( in, FIONBIO, (char *)&off );
  1256.                 }
  1257.                                 if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode)) != NULL ){
  1258.                                     bco=bco+transmit(out,server,CRLF);
  1259.                                         sprintf(line," Error: chgusr return code is %d.\n",i);
  1260.                                         bco=bco+transmit(out,line,CRLF);
  1261.                                         return(9);
  1262.                                 }
  1263. #endif SERVER
  1264.                                 sprintf(line," Server mode set ");
  1265.                                 if(mode[ 0 ] == 'S' ){
  1266.                                         strcat(line,onstr);
  1267.                     strcat(line,"\n$server:r:");
  1268.                                 } else
  1269.                                         strcat(line,offstr);
  1270.                         }
  1271.  
  1272.                         /* set name */
  1273.  
  1274.                         else if(strnicmp(line+3," name",5)==NULL)
  1275.                         {
  1276.                                 if(names==ON)
  1277.                                 {
  1278.                                         if(strncmp(line+8,BLANKS,1)==NULL)
  1279.                                                 strncpy(name,line+9,32);
  1280.                                         if(strlen(name)==0)
  1281.                                                 strcpy(name,"Anonymous");
  1282.  
  1283.                     /* remove colons */
  1284.  
  1285.                     j = strlen( name );
  1286.                     for( i = 0; i < j; ++i ){
  1287.                         if( name[ i ] == ':' )
  1288.                             name[ i ] = ' ';
  1289.                     }
  1290.  
  1291.                                         /* change user directory */
  1292.  
  1293.                                         if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
  1294.                                         {
  1295.                                                 bco=bco+transmit(out,server,CRLF);
  1296.                                                 sprintf(line," Error: chgusr return code is %d.\n",i);
  1297.                                                 bco=bco+transmit(out,line,CRLF);
  1298.                                                 return(10);
  1299.                                         }
  1300.                                         sprintf(line," Name set to %s.\n",name);
  1301.                     change = ON;
  1302.                                 }
  1303.                                 else
  1304.                                         strcpy(line,notallow);
  1305.                         }
  1306.  
  1307.                         /* set definition file name */
  1308.  
  1309.                         else if(strnicmp(line+3," definition",11)==NULL)
  1310.                         {
  1311.                                 if(files==ON)
  1312.                                 {
  1313. #ifdef SYSV2
  1314.                                        i=setuid(uid);
  1315. #endif SYSV2
  1316. #ifdef SYSV3
  1317.                                        i=setuid(uid);
  1318. #endif SYSV3
  1319.                                        if(strncmp(line+14,BLANKS,1)==NULL)
  1320.                                                 strncpy(deffil,line+15,12);
  1321.                                         if(strlen(deffil)==0)
  1322.                                                 strcpy(deffil,"slugdef.dat");
  1323.                                         def=fopen(deffil,"r");
  1324.                                         if(def!=NULL)
  1325.                                         {
  1326.                                                 sprintf(line," Definition file set to %s.\n",deffil);
  1327.                                                 i=fclose(def);
  1328.                                         }
  1329.                                         else
  1330.                                                 sprintf(line," Definition file name set to %s, which does not exist.\n",deffil);
  1331. #ifdef SYSV2
  1332.                                        i=setuid(euid);
  1333. #endif SYSV2
  1334. #ifdef SYSV3
  1335.                                        i=setuid(euid);
  1336. #endif SYSV3
  1337.                                 }
  1338.                                 else
  1339.                                         strcpy(line,notallow);
  1340.                         }
  1341.  
  1342.                         /* set prologue file name */
  1343.  
  1344.                         else if(strnicmp(line+3," prologue",9)==NULL)
  1345.                         {
  1346.                                 if(files==ON)
  1347.                                 {
  1348. #ifdef SYSV2
  1349.                                        i=setuid(uid);
  1350. #endif SYSV2
  1351. #ifdef SYSV3
  1352.                                        i=setuid(uid);
  1353. #endif SYSV3
  1354.                                        if(strncmp(line+12,BLANKS,1)==NULL)
  1355.                                                 strncpy(profil,line+15,12);
  1356.                                         if(strlen(profil)==0)
  1357.                                                 strcpy(deffil,"slugpro.dat");
  1358.                                         def=fopen(profil,"r");
  1359.                                         if(def!=NULL)
  1360.                                         {
  1361.                                                 sprintf(line," Prologue file set to %s.\n",deffil);
  1362.                                                 i=fclose(def);
  1363.                                         }
  1364.                                         else
  1365.                                                 sprintf(line," Prologue file name set to %s, which does not exist.\n",deffil);
  1366. #ifdef SYSV2
  1367.                                        i=setuid(euid);
  1368. #endif SYSV2
  1369. #ifdef SYSV3
  1370.                                        i=setuid(euid);
  1371. #endif SYSV3
  1372.                                 }
  1373.                                 else
  1374.                                         strcpy(line,notallow);
  1375.                         }
  1376.  
  1377.                         /* set wait string */
  1378.  
  1379.                         else if(strnicmp(line+3," wait",5)==NULL)
  1380.                         {
  1381.                                if(strncmp(line+8,BLANKS,1)==NULL)
  1382.                                         strcpy(waitstr,line+9);
  1383.                                 if(strlen(waitstr)==0)
  1384.                                         strcpy(waitstr,"From");
  1385.                                 sprintf(line," Wait string set to %s.\n",waitstr);
  1386.                         }
  1387.  
  1388.                         /* set delay time */
  1389.  
  1390.                         else if(strnicmp(line+3," delay",6)==NULL)
  1391.                         {
  1392.                                if(strncmp(line+9,BLANKS,1)==NULL)
  1393.                                         sscanf(line+10,"%d",&dtime);
  1394.                                 if(dtime<=0)
  1395.                                         dtime=15;
  1396.                                 sprintf(line," Delay time set to %d.\n",dtime);
  1397.                         }
  1398.  
  1399.                         /* set prompt mode */
  1400.  
  1401.                         else if(strnicmp(line+3," prompt",7)==NULL)
  1402.                         {
  1403.                                 if(strncmp(line+10,ontst,3)==NULL)
  1404.                                         prmpt_flg=ON;
  1405.                                 if(strncmp(line+10,offtst,4)==NULL)
  1406.                                         prmpt_flg=OFF;
  1407.                                 sprintf(line," Prompt set ");
  1408.                                 if(prmpt_flg==ON)
  1409.                                         strcat(line,onstr);
  1410.                                 else
  1411.                                         strcat(line,offstr);
  1412.                         }
  1413.  
  1414.                         /* set continuous mode */
  1415.  
  1416.                         else if(strnicmp(line+3," continuous",11)==NULL)
  1417.                         {
  1418.                                 if(strncmp(line+14,ontst,3)==NULL) {
  1419.                                         cntns_flg=ON;
  1420.                                         prmpt_flg=OFF;
  1421.                     on = ON;
  1422.                     if( ioctl( in, FIONBIO, (char *)&on ) < NULL )
  1423.                         perror( "ioctl" );
  1424.                 }
  1425.                                 if(strncmp(line+14,offtst,4)==NULL) {
  1426.                                         cntns_flg=OFF;
  1427.                                         prmpt_flg=ON;
  1428.                     off = OFF;
  1429.                     if( ioctl( in, FIONBIO, (char *)&off ) < NULL )
  1430.                         perror( "ioctl" );
  1431.                 }
  1432.                                 sprintf(line," Continuous mode set ");
  1433.                                 if(cntns_flg==ON) {
  1434.                                         strcat(line,onstr);
  1435.                                 } else {
  1436.                                         strcat(line,offstr);
  1437.                 }
  1438.                         }
  1439.  
  1440.                         /* set novice mode */
  1441.  
  1442.                         else if(strnicmp(line+3," novice",7)==NULL)
  1443.                         {
  1444.                                 if(strncmp(line+10,ontst,3)==NULL)
  1445.                                         novice=ON;
  1446.                                 if(strncmp(line+10,offtst,4)==NULL)
  1447.                                         novice=OFF;
  1448.                                 sprintf(line," Novice mode set ");
  1449.                                 if(novice==ON)
  1450.                                         strcat(line,onstr);
  1451.                                 else
  1452.                                         strcat(line,offstr);
  1453.                         }
  1454.  
  1455.                         /* set timer mode */
  1456.  
  1457.                         else if(strnicmp(line+3," timer",6)==NULL)
  1458.                         {
  1459.                                 if(strncmp(line+9,ontst,3)==NULL)
  1460.                                         timer=ON;
  1461.                                 if(strncmp(line+9,offtst,4)==NULL)
  1462.                                         timer=OFF;
  1463.                                 sprintf(line," Timer mode set ");
  1464.                                 if(timer==ON)
  1465.                                         strcat(line,onstr);
  1466.                                 else
  1467.                                         strcat(line,offstr);
  1468.                         }
  1469.  
  1470.                         /* set echo mode */
  1471.  
  1472.                         else if(strnicmp(line+3," echo",5)==NULL)
  1473.                         {
  1474.                                 if(strncmp(line+8,ontst,3)==NULL)
  1475.                                         echo=ON;
  1476.                                 if(strncmp(line+8,offtst,4)==NULL)
  1477.                                         echo=OFF;
  1478.                                 sprintf(line," Echo mode set ");
  1479.                                 if(echo==ON)
  1480.                                         strcat(line,onstr);
  1481.                                 else
  1482.                                         strcat(line,offstr);
  1483.                         }
  1484.  
  1485.                         /* set echoplex */
  1486.  
  1487.                         else if(strnicmp(line+3," echoplex",9)==NULL)
  1488.                         {
  1489.                                 if(strncmp(line+12,ontst,3)==NULL)
  1490.                                         echoplex=ON;
  1491.                                 if(strncmp(line+12,offtst,4)==NULL)
  1492.                                         echoplex=OFF;
  1493.                                 sprintf(line," Echoplex set ");
  1494.                                 if(echoplex==ON)
  1495.                                         strcat(line,onstr);
  1496.                                 else
  1497.                                         strcat(line,offstr);
  1498.                         }
  1499.  
  1500.                         /* set echo mode */
  1501.  
  1502.                         else if(strnicmp(line+3," echo",5)==NULL)
  1503.                         {
  1504.                                 if(strncmp(line+8,ontst,3)==NULL)
  1505.                                         echo=ON;
  1506.                                 if(strncmp(line+8,offtst,4)==NULL)
  1507.                                         echo=OFF;
  1508.                                 sprintf(line," Echo mode set ");
  1509.                                 if(echo==ON)
  1510.                                         strcat(line,onstr);
  1511.                                 else
  1512.                                         strcat(line,offstr);
  1513.                         }
  1514.  
  1515.                         /* set ring mode */
  1516.  
  1517.                         else if(strnicmp(line+3," ring",5)==NULL)
  1518.                         {
  1519.                                 if(ringr==ON)
  1520.                                 {
  1521.                                         if(strncmp(line+8,ontst,3)==NULL)
  1522.                                                 ringok=ON;
  1523.                                         if(strncmp(line+8,offtst,4)==NULL)
  1524.                                                 ringok=OFF;
  1525.                                         sprintf(line," Ring mode set ");
  1526.                                         if(ringok==ON)
  1527.                                                 strcat(line,onstr);
  1528.                                         else
  1529.                                                 strcat(line,offstr);
  1530.                                 }
  1531.                                 else
  1532.                                         sprintf(line,notallow,CRLF,port);
  1533.                         }
  1534.  
  1535.                         /* set configuration */
  1536.  
  1537.                         else if(strnicmp(line+3," config",7)==NULL)
  1538.                         {
  1539.                                 if(files==ON)
  1540.                                 {
  1541. #ifdef SYSV2
  1542.                                         i=setuid(uid);
  1543. #endif SYSV2
  1544. #ifdef SYSV3
  1545.                                         i=setuid(uid);
  1546. #endif SYSV3
  1547.                                         i=chdir(homedir);
  1548.                                         con=fopen(confil,"w");
  1549.                                         chmod(confil,00600);
  1550.                                         i=repchar(deffil,' ','_');
  1551.                                         fprintf(con,"%s ",deffil);
  1552.                                         i=repchar(deffil,'_',' ');
  1553.                                         fprintf(con,"%u ",dtime);
  1554.                                         fprintf(con,"%d ",echo);
  1555.                                         fprintf(con,"%d ",echoplex);
  1556.                                         i=repchar(name,' ','_');
  1557.                                         fprintf(con,"%s ",name);
  1558.                                         i=repchar(name,'_',' ');
  1559.                                         fprintf(con,"%d ",novice);
  1560.                                         i=repchar(profil,' ','_');
  1561.                                         fprintf(con,"%s ",profil);
  1562.                                         i=repchar(profil,'_',' ');
  1563.                                         fprintf(con,"%d ",prmpt_flg);
  1564.                                         fprintf(con,"%d ",ringok);
  1565.                                         fprintf(con,"%d ",timer);
  1566.                                         i=repchar(waitstr,' ','_');
  1567.                                         fprintf(con,"%s ",waitstr);
  1568.                                         i=repchar(waitstr,'_',' ');
  1569.                                         j=fclose(con);
  1570. #ifdef SYSV2
  1571.                                         i=setuid(euid);
  1572. #endif SYSV2
  1573. #ifdef SYSV3
  1574.                                         i=setuid(euid);
  1575. #endif SYSV3
  1576.                                         i=chdir(slugdir);
  1577.                                         sprintf(line," Current configuration saved.\n");
  1578.                                  }
  1579.                                 else
  1580.                                         strcpy(line,notallow);
  1581.                         }
  1582.  
  1583.             /* set login name */
  1584.  
  1585.                         else if(strnicmp(line+3," login",6)==NULL)
  1586.                         {
  1587.                                 if( network==ON )
  1588.                                 {
  1589.                                         if(strncmp(line+9,BLANKS,1)==NULL)
  1590.                     {
  1591.                                                 strncpy(un,line+10,UNLEN);
  1592.  
  1593.  
  1594.                         /* try to verify */
  1595.  
  1596.                         if( !verify( un, host ))
  1597.                             un[ 0 ] = ( char )NULL;
  1598.  
  1599.                     }
  1600.                                         if(strlen(un)==0)
  1601.                                                 strcpy(un,"unknown");
  1602.  
  1603.                     /* remove colons */
  1604.  
  1605.                     j = strlen( un );
  1606.                     for( i = 0; i < j; ++i ){
  1607.                         if( un[ i ] == ':' )
  1608.                             un[ i ] = ' ';
  1609.                     }
  1610.  
  1611.                                         /* change user directory */
  1612.  
  1613.                                         if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
  1614.                                         {
  1615.                                                 bco=bco+transmit(out,server,CRLF);
  1616.                                                 sprintf(line," Error: chgusr return code is %d.\n",i);
  1617.                                                 bco=bco+transmit(out,line,CRLF);
  1618.                                         }
  1619.                                         sprintf(line," Login set to %s.\n",un);
  1620.                     change = ON;
  1621.                                 }
  1622.                                 else
  1623.                                         strcpy(line,notallow);
  1624.                         }
  1625.                         else 
  1626.                         {
  1627.                                 sprintf(line," Error: Type \"help set\" for a list of options.\n");
  1628.                         }
  1629.                         bco=bco+transmit(out,line,CRLF);
  1630.             if( change ){
  1631.                 sprintf(sndbuf,"$server:c:%s:%s:%s:%s:%s:%s:\n",name,un,host,jsn,confer,mode);
  1632.                 brdcst=ON;
  1633.                 goto sndmsg;
  1634.             }
  1635.                 }
  1636.  
  1637.                 /* show commands */
  1638.  
  1639.                 else if(strnicmp(line,"show",4)==NULL)
  1640.                 {
  1641.  
  1642.                         bco=bco+transmit(out,server,CRLF);
  1643.                         allon=OFF;
  1644.                         conon=OFF;
  1645.                         memon=OFF;
  1646.             logon=OFF;
  1647.             hoson=OFF;
  1648.                         if(strnicmp(line+4," all",4)==NULL
  1649.                         && admin==ON)
  1650.                         {
  1651.                                 bco=bco+transmit(out, " JSN  Login    Hostname         PID      Mode Conference", CRLF);
  1652.                                 allon=ON;
  1653.                 sprintf( scratch, " %%-4.4s %%-8.8s %%-16.16s %%-8.8s  %%-1s   %%-%ds", CFRLEN );
  1654.                         }
  1655.                         else if(strnicmp(line+4," buffer",7)==NULL)
  1656.                         {
  1657.                                 if(strlen(msgbuf)==0)
  1658.                                         bco=bco+transmit(out," Error: empty message buffer.\n",CRLF);
  1659.                                 else
  1660.                                 {
  1661.                                         bco=bco+transmit(out," Contents of message buffer:",CRLF);
  1662.                                         for(i=0;i<strlen(msgbuf);++i)
  1663.                                         {
  1664.                                                 sprintf(line,"%c",msgbuf[i]);
  1665.                                                 bco=bco+transmit(out,line,NOCRLF);
  1666.                                                 if(msgbuf[i]==(char)LF) bco=bco+transmit(out,"\r",NOCRLF);
  1667.                                         }
  1668.                                         bco=bco+transmit(out,BLANKS,CRLF);
  1669.                                 }
  1670.                         }
  1671.                         else if(strnicmp(line+4," confer",7)==NULL)
  1672.                         {
  1673.                                 bco=bco+transmit(out," Users  Conference name",CRLF);
  1674.                                 conon=ON;
  1675.                                 l= -1;
  1676.                         }
  1677.                         else if(strnicmp(line+4," config",7)==NULL)
  1678.                         {
  1679.                                 bco=bco+transmit(out," Attribute         State",CRLF);
  1680.                                 sprintf(line," definition file.. %s",deffil);
  1681.                                 bco=bco+transmit(out,line,CRLF);
  1682.                                 sprintf(line," delay time....... %d",dtime);
  1683.                                 bco=bco+transmit(out,line,CRLF);
  1684.                                 bco=bco+transmit(out," echo mode........",NOCRLF);
  1685.                                 if(echo==ON)
  1686.                                         bco=bco+transmit(out,ontst,CRLF);
  1687.                                 else
  1688.                                         bco=bco+transmit(out,offtst,CRLF);
  1689.                                 bco=bco+transmit(out," echoplex.........",NOCRLF);
  1690.                                 if(echoplex==ON)
  1691.                                         bco=bco+transmit(out,ontst,CRLF);
  1692.                                 else
  1693.                                         bco=bco+transmit(out,offtst,CRLF);
  1694.                                 sprintf(line," name............. %s",name);
  1695.                                 bco=bco+transmit(out,line,CRLF);
  1696.                                 bco=bco+transmit(out," novice mode......",NOCRLF);
  1697.                                 if(novice==ON)
  1698.                                         bco=bco+transmit(out,ontst,CRLF);
  1699.                                 else
  1700.                                         bco=bco+transmit(out,offtst,CRLF);
  1701.                                 sprintf(line," prologue file.... %s",profil);
  1702.                                 bco=bco+transmit(out,line,CRLF);
  1703.                                 bco=bco+transmit(out," prompt mode......",NOCRLF);
  1704.                                 if(prmpt_flg==ON)
  1705.                                         bco=bco+transmit(out,ontst,CRLF);
  1706.                                 else
  1707.                                         bco=bco+transmit(out,offtst,CRLF);
  1708.                                 bco=bco+transmit(out," ring mode........",NOCRLF);
  1709.                                 if(ringok==ON)
  1710.                                         bco=bco+transmit(out,ontst,CRLF);
  1711.                                 else
  1712.                                         bco=bco+transmit(out,offtst,CRLF);
  1713.                                 bco=bco+transmit(out," timer mode.......",NOCRLF);
  1714.                                 if(timer==ON)
  1715.                                         bco=bco+transmit(out,ontst,CRLF);
  1716.                                 else
  1717.                                         bco=bco+transmit(out,offtst,CRLF);
  1718.                                 sprintf(line," wait string...... %s\n",waitstr);
  1719.                                 bco=bco+transmit(out,line,CRLF);
  1720.                         }
  1721.                         else if(strnicmp(line+4," members",8)==NULL)
  1722.                         {
  1723.                                 bco=bco+transmit(out," JSN  Login    Hostname         Name",CRLF);
  1724.                                 memon=ON;
  1725.                 sprintf( scratch, " %%-4.4s %%-8.8s %%-16.16s %%-%ds", NAMLEN );
  1726.                         }
  1727.                         else if(strnicmp(line+4," hosts",6)==NULL)
  1728.                         {
  1729.                 sprintf( scratch, " JSN%%-%ds Hostname%%-%ds", JSNLEN-3, HOSTLEN-8 );
  1730.                 sprintf( line, scratch, BLANKS, BLANKS );
  1731.                                 bco=bco+transmit(out,line,CRLF);
  1732.                                 hoson=ON;
  1733.                 sprintf( scratch, " %%-%ds %%-%ds", JSNLEN, HOSTLEN );
  1734.                         }
  1735.                         else if(strnicmp(line+4," logins",7)==NULL)
  1736.                         {
  1737.                 sprintf( scratch, " JSN%%-%ds Login%%-%ds", JSNLEN-3, UNLEN-5 );
  1738.                 sprintf( line, scratch, BLANKS, BLANKS );
  1739.                                 bco=bco+transmit(out,line,CRLF);
  1740.                                 logon=ON;
  1741.                 sprintf( scratch, " %%-%ds %%-%ds", JSNLEN, UNLEN );
  1742.                         }
  1743.                         else
  1744.                         {
  1745.                                 sprintf(line," Error: Type \"help show\" for a list of options.\n");
  1746.                                 bco=bco+transmit(out,line,CRLF);
  1747.                         }
  1748.  
  1749.                         /* do directory show command */
  1750.  
  1751.                         if(allon==ON||memon==ON||conon==ON||hoson==ON||logon==ON)
  1752.                         {
  1753.                 lock(usrfil);
  1754.                                 usr=open(usrfil,O_RDONLY);
  1755.                                 for(;;)
  1756.                                 {
  1757. #ifdef SYSV2
  1758.                                         j=read(usr,&inpstr,(unsigned)reclen);
  1759. #endif SYSV2
  1760. #ifdef SYSV3
  1761.                                         j=read(usr,&inpstr,(unsigned)reclen);
  1762. #endif SYSV3
  1763. #ifdef BSD4
  1764.                                         j=read(usr,&inpstr,reclen);
  1765. #endif BSD4
  1766. #ifdef ULTRIX
  1767.                                         j=read(usr,&inpstr,reclen);
  1768. #endif ULTRIX
  1769.                     if( j == NULL )
  1770.                         break;
  1771.                                         if(allon==ON
  1772.                                         && strncmp(inpstr.jsn,"    ",JSNLEN-1)!=NULL)
  1773.                                         {
  1774.                                                 sprintf(line, scratch,
  1775.                                                 inpstr.jsn,
  1776.                                                 inpstr.un,
  1777.                              inpstr.host,
  1778.                         inpstr.pid,
  1779.                         inpstr.mode,
  1780.                                                 inpstr.confer);
  1781.                                                 bco=bco+transmit(out,line,CRLF);
  1782.                                         }
  1783.                                         else if(memon==ON
  1784.                                         && strncmp(inpstr.confer,confer,strlen(confer))==NULL
  1785.                                         && strncmp(inpstr.jsn,"    ",JSNLEN-1)!=NULL
  1786.                     && strncmp( inpstr.mode,"S",1)!=NULL)
  1787.                                         {
  1788.                                                 sprintf(line, scratch,
  1789.                                                 inpstr.jsn,
  1790.                                                 inpstr.un,
  1791.                              inpstr.host,
  1792.                                                 inpstr.name);
  1793.                                                 bco=bco+transmit(out,line,CRLF);
  1794.                                         }
  1795.                                         else if(hoson==ON
  1796.                                         && strncmp(inpstr.confer,confer,strlen(confer))==NULL
  1797.                                         && strncmp(inpstr.jsn,"    ",JSNLEN-1)!=NULL
  1798.                     && strncmp( inpstr.mode,"S",1)!=NULL)
  1799.                                         {
  1800.                                                 sprintf(line, scratch,
  1801.                                                 inpstr.jsn,
  1802.                              inpstr.host );
  1803.                                                 bco=bco+transmit(out,line,CRLF);
  1804.                                         }
  1805.                                         else if(logon==ON
  1806.                                         && strncmp(inpstr.confer,confer,strlen(confer))==NULL
  1807.                                         && strncmp(inpstr.jsn,"    ",JSNLEN-1)!=NULL
  1808.                     && strncmp( inpstr.mode,"S",1)!=NULL)
  1809.                                         {
  1810.                                                 sprintf(line, scratch,
  1811.                                                 inpstr.jsn,
  1812.                                                 inpstr.un);
  1813.                                                 bco=bco+transmit(out,line,CRLF);
  1814.                                         }
  1815.                                         else if(conon==ON
  1816.                                         && strncmp(inpstr.confer,"-",1)!=NULL
  1817.                                         && strncmp(inpstr.jsn,"    ",JSNLEN-1)!=NULL
  1818.                     && strncmp( inpstr.mode,"S",1)!=NULL)
  1819.                                         {
  1820.                                                 found=OFF;
  1821.                                                 if(l<NULL)
  1822.                                                 {
  1823.                                                         l=0;
  1824.                                                         count[l]=1;
  1825.                                                         strcpy(sndbuf+(l*CFRLEN),
  1826.                                                         inpstr.confer);
  1827.                                                         found=ON;
  1828.                                                 }
  1829.                                                 else
  1830.                                                 {
  1831.                                                         for(k=0;k<=l;++k)
  1832.                                                         {
  1833.                                                                 if(strncmp(inpstr.confer,
  1834.                                                                 sndbuf+(k*CFRLEN),
  1835.                                                                 strlen(sndbuf+(k*CFRLEN)))==NULL)
  1836.                                                                 {
  1837.                                                                         ++count[k];
  1838.                                                                         found=ON;
  1839.                                                                 }
  1840.                                                         }
  1841.                                                 }
  1842.                                                 if(found==OFF)
  1843.                                                 {
  1844.                                                         ++l;
  1845.                                                         count[l]=1;
  1846.                                                         strcpy(sndbuf+(l*CFRLEN),
  1847.                                                         inpstr.confer);
  1848.                                                 }
  1849.                                          }
  1850.                                 }
  1851.                                 j=close(usr);
  1852.                 unlock(usrfil);
  1853.                                 if(conon==ON)
  1854.                                 {
  1855.                                         for(i=0;i<=l;++i)
  1856.                                         {
  1857.                                                 sprintf(line," %5d  %s",count[i],sndbuf+(i*CFRLEN));
  1858.                                                 bco=bco+transmit(out,line,CRLF);
  1859.                                         }
  1860.                                 }
  1861.                                 bco=bco+transmit(out,BLANKS,CRLF);
  1862.                         }
  1863.                 }
  1864.  
  1865.                 /* pass through to system */
  1866.  
  1867.                 else if(strncmp(line,"!",1)==NULL)
  1868.                 {
  1869.                         if(systm==ON)
  1870.                         {
  1871. #ifdef SYSV2
  1872.                                 i=setuid(uid);
  1873. #endif SYSV2
  1874. #ifdef SYSV3
  1875.                                 i=setuid(uid);
  1876. #endif SYSV3
  1877.                                 i=chdir(homedir);
  1878.                                 i=system(line+1);
  1879.                                 if(i!=NULL)
  1880.                                 {
  1881.                                         bco=bco+transmit(out,server,CRLF);
  1882.                                         sprintf(line," Error: system return code is %d\n",i);
  1883.                                         bco=bco+transmit(out,line,CRLF);
  1884.                                 }
  1885. #ifdef SYSV2
  1886.                                 i=setuid(euid);
  1887. #endif SYSV2
  1888. #ifdef SYSV3
  1889.                                 i=setuid(euid);
  1890. #endif SYSV3
  1891.                                 i=chdir(slugdir);
  1892.                         }
  1893.                         else
  1894.                         {
  1895.                                  bco=bco+transmit(out,server,CRLF);
  1896.                                  bco=bco+transmit(out,notallow,CRLF);
  1897.                         }
  1898.  
  1899.                 }
  1900.  
  1901.                 /* output redirection */
  1902.  
  1903.                 else if(strncmp(line,">",1)==NULL)
  1904.                 {
  1905.                         if(files==ON && dirct==ON)
  1906.                         {
  1907. #ifdef SYSV2
  1908.                                 i=setuid(uid);
  1909. #endif SYSV2
  1910. #ifdef SYSV3
  1911.                                 i=setuid(uid);
  1912. #endif SYSV3
  1913.                                 i=chdir(homedir);
  1914.                                 bco=bco+transmit(out,server,CRLF);
  1915.                                 if(strlen(line+1)==0||strncmp(line+1,"output",6)==NULL)
  1916.                                 {
  1917.                                         bco=bco+transmit(out," Output redirection terminated.\n",CRLF);
  1918.                                         i=close(out);
  1919. #ifdef NETWORK
  1920.                                         out=socket;
  1921. #endif NETWORK
  1922. #ifdef LOCAL
  1923.                                         out=fileno( stdout );
  1924. #endif LOCAL
  1925.                                 }
  1926.                                 else
  1927.                                 {
  1928.                                         sprintf(sndbuf," Redirecting output to %s.\n",line+1);
  1929.                                         bco=bco+transmit(out,sndbuf,CRLF);
  1930.                                         out=open(line+1, O_APPEND | O_CREAT,
  1931. 00600 );
  1932.                                         if(out==NULL)
  1933.                                         {
  1934.                                                 bco=bco+transmit(out,server,CRLF);
  1935.                                                 sprintf(sndbuf," Error: Unable to redirect output to %s.\n",
  1936.                                                 line+1);
  1937.                                                 bco=bco+transmit(out,sndbuf,CRLF);
  1938.                                         }
  1939.                                         else
  1940.                                                 chmod(line+1,00600);
  1941.                                 }
  1942. #ifdef SYSV2
  1943.                                 i=setuid(euid);
  1944. #endif SYSV2
  1945. #ifdef SYSV3
  1946.                                 i=setuid(euid);
  1947. #endif SYSV3
  1948.                                 i=chdir(slugdir);
  1949.                         }
  1950.                         else
  1951.                         {
  1952.                                  bco=bco+transmit(out,server,CRLF);
  1953.                                  bco=bco+transmit(out,notallow,CRLF);
  1954.                         }
  1955.                 }
  1956.  
  1957.                 /* input redirection */
  1958.  
  1959.                 else if(strncmp(line,"<",1)==NULL)
  1960.                 {
  1961.                         if(dirct==ON && files==ON)
  1962.                         {
  1963. #ifdef SYSV2
  1964.                                 i=setuid(uid);
  1965. #endif SYSV2
  1966. #ifdef SYSV3
  1967.                                 i=setuid(uid);
  1968. #endif SYSV3
  1969.                                 i=chdir(homedir);
  1970.                                 bco=bco+transmit(out,server,CRLF);
  1971.                                 if(strlen(line+1)==0||strncmp(line+1,"input",5)==NULL)
  1972.                                 {
  1973.                                         bco=bco+transmit(out," Input redirection terminated.\n",CRLF);
  1974.                                         i=fclose(inp);
  1975.                                         inp=NULL;
  1976.                                 }
  1977.                                 else
  1978.                                 {
  1979.                                         sprintf(sndbuf," Redirecting input to %s.\n",
  1980.                                         line+1);
  1981.                                         bco=bco+transmit(out,sndbuf,CRLF);
  1982.                                         inp=fopen(line+1,"r");
  1983.                                         if(inp==NULL)
  1984.                                         {
  1985.                                                 bco=bco+transmit(out,server,CRLF);
  1986.                                                 sprintf(sndbuf," Error: Unable to redirect input to %s.\n",line+1);
  1987.                                                 bco=bco+transmit(out,sndbuf,CRLF);
  1988.                                         }
  1989.                                 }
  1990. #ifdef SYSV2
  1991.                                 i=setuid(euid);
  1992. #endif SYSV2
  1993. #ifdef SYSV3
  1994.                                 i=setuid(euid);
  1995. #endif SYSV3
  1996.                                 i=chdir(slugdir);
  1997.                         }
  1998.                         else
  1999.                         {
  2000.                                  bco=bco+transmit(out,server,CRLF);
  2001.                                  bco=bco+transmit(out,notallow,CRLF);
  2002.                         }
  2003.                 }
  2004.  
  2005.                 /* add line to message buffer */
  2006.  
  2007.                 else if( strncmp(line,BLANKS,1)==NULL 
  2008.             || (strncmp(line, "From",4) == NULL && mode[ 0 ] == 'S')
  2009.             || (strncmp(line, "\n",1) == NULL && mode[ 0 ] == 'S' )){
  2010.                         i=strlen(line);
  2011.                         if((i+msgpos+nwlnln)<MSGLEN)
  2012.                         {
  2013.                                 strcat(msgbuf,line);
  2014.                                 if( line[ 0 ] != '\n' ) 
  2015.                     strcat(msgbuf,"\n");
  2016.                                 msgpos=msgpos+i+nwlnln;
  2017.                         }
  2018.                         else
  2019.                         {
  2020.                                 bco=bco+transmit(out,server,CRLF);
  2021.                                 sprintf(line," Error: Message buffer is full.\n");
  2022.                                 bco=bco+transmit(out,line,CRLF);
  2023.                         }
  2024.                 }
  2025.  
  2026.                 /* send private message */
  2027.  
  2028.                 else if(strnicmp(line,"send ",5)==NULL && msgpos>0)
  2029.                 {
  2030.                         if(privt==ON)
  2031.                         {
  2032.                                 prvflg=ON;
  2033.                                 strncpy(tjsn,line+5,JSNLEN-1);
  2034.                 if(( thstp = strchr( line, '@' )) != (char *)NULL ){
  2035.                     strcpy( thost, ++thstp );
  2036.                 } else
  2037.                     thost[ 0 ] = ( char )NULL;
  2038.                 if( mode[ 0 ] == 'U' ){
  2039.                                     sprintf(line," < private message to %s >",tjsn);
  2040.                                     sprintf(idstr,idfrmt,name,un,host,jsn,line);
  2041.                                     if( thost[ 0 ] != ( char )NULL)
  2042.                         sprintf(sndbuf," %s\n%s\n$server:p:%s@%s:\n",idstr,msgbuf,tjsn,thost);
  2043.                     else
  2044.                         sprintf(sndbuf," %s\n%s\n$server:p:%s:\n",idstr,msgbuf,tjsn);
  2045.                 } else if( mode[ 0 ] == 'S' )
  2046.                     strcpy( sndbuf, msgbuf );
  2047.                             msgpos=0;
  2048.                                 msgbuf[msgpos]=(char)NULL;
  2049.                                 goto sndmsg;
  2050.                         }
  2051.                         else
  2052.                                  bco=bco+transmit(out,notallow,CRLF);
  2053.                 }
  2054.  
  2055.                 /* send public message */
  2056.  
  2057.                 else if((strnicmp(line,"send",4)==NULL||(strlen(line)==0&&mode[ 0 ] != 'S') || line[ 0 ] == '\n' )&&msgpos>0 ){
  2058.                         msgflg=ON;
  2059.             if( mode[ 0 ] == 'U' ){
  2060.                             sprintf(idstr,idfrmt,name,un,host,jsn,normal);
  2061.                             sprintf(sndbuf," %s\n%s\n$server:m:%s:\n",idstr,msgbuf,confer);
  2062.             } else if( mode[ 0 ] == 'S' )
  2063.                 strcpy( sndbuf, msgbuf );
  2064.                         msgpos=0;
  2065.                         msgbuf[msgpos]=(char)NULL;
  2066.                         goto sndmsg;
  2067.                 }
  2068.  
  2069.                 /* send broadcast message */
  2070.  
  2071.                 else if(strnicmp(line,"broadcast",9)==NULL && msgpos>0)
  2072.                 {
  2073.                         if(brods==ON)
  2074.                         {
  2075.                                 brdcst=ON;
  2076.                 if( mode[ 0 ] == 'U' ){
  2077.                                        sprintf(idstr,idfrmt,name,un,host,jsn,broad);
  2078.                                     sprintf(sndbuf," %s\n%s\n$server:b:\n",idstr,msgbuf);
  2079.                 } else if( mode[ 0 ] == 'S' )
  2080.                     strcpy( sndbuf, msgbuf );
  2081.                                 msgpos=0;
  2082.                                 msgbuf[msgpos]=(char)NULL;
  2083.                                 goto sndmsg;
  2084.                         }
  2085.                         else
  2086.                                  bco=bco+transmit(out,notallow,CRLF);
  2087.                 }
  2088.  
  2089.                 /* check for messages */
  2090.  
  2091.                 else if(( strlen(line)==0 || line[ 0 ] == '\n' ) && mode[ 0 ] == 'U' ) goto sndmsg;
  2092.  
  2093.                 /* join another conference */
  2094.  
  2095.                 else if(strnicmp(line,"join",4)==NULL)
  2096.                 {
  2097.                         if(joinc==ON)
  2098.                         {
  2099.                                 sprintf(sndbuf," %s\n %s ( %s@%s / %s ) logged off %s.\n$server:m:%s:\n",server,name,un,host,jsn,confer,confer);
  2100.                                 join=ON;
  2101.                                 msgflg=ON;
  2102.                                 if(strncmp(line+4,"\0",1)==NULL)
  2103.                                          strcpy(newcfr,"\0");
  2104.                                 else
  2105.                                          strncpy(newcfr,line+5,CFRLEN-1);
  2106.                                 if(strlen(newcfr)==0) strcpy(newcfr,"Root");
  2107.  
  2108.                 /* remove colons */
  2109.  
  2110.                 j = strlen( newcfr );
  2111.                 for( i = 0; i < j; ++i ){
  2112.                     if( newcfr[ i ] == ':' )
  2113.                         newcfr[ i ] = ' ';
  2114.                 }
  2115.                                 bco=bco+transmit(out,server,CRLF);
  2116.                                 sprintf(line," Joining conference %s.",newcfr);
  2117.                                 bco=bco+transmit(out,line,CRLF);
  2118.                                 goto sndmsg;
  2119.                         }
  2120.                         else
  2121.                                 bco=bco+transmit(out,notallow,CRLF);
  2122.                 }
  2123.  
  2124.                 /* rewind command */
  2125.  
  2126.                 else if(strnicmp(line,"rewind",6)==NULL)
  2127.                         rewind(inp);
  2128.  
  2129.                 /* exit slugnet */
  2130.  
  2131.                 else if(strnicmp(line,"exit",4)==NULL
  2132.                 || strnicmp(line,"bye",3)==NULL
  2133.                 || strnicmp(line,"logoff",6)==NULL
  2134.                 || strnicmp(line,"quit",4)==NULL
  2135.                 || (strnicmp(line,"stop",4)==NULL && systm==ON))
  2136.                 {
  2137.                         atend=ON;
  2138.                         msgflg=ON;
  2139.                 sprintf(sndbuf,"$server:d:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) logged off.\n$server:m:%s:\n",name,un,host,jsn,confer,mode,server,name,un,host,jsn,confer);
  2140.                         if(strncmp(line,"stop",4)==NULL) stop=ON;
  2141.                         goto sndmsg;
  2142.                 }
  2143.  
  2144.                 /* bell + jsn: rings bell and transmits jsn */
  2145.  
  2146.                 else if(strnicmp(line,"bell ",5)==NULL)
  2147.                 {
  2148.                         strncpy(tjsn,line+5,JSNLEN-1);
  2149.                         sprintf(line," Jsn %s is ringing you.\007\n",tjsn);
  2150.                         if(strlen(tjsn)>0&&ringok==ON)
  2151.                         {
  2152.                                 bco=bco+transmit(out,server,CRLF);
  2153.                                 bco=bco+transmit(out,line,CRLF);
  2154.                         }
  2155.                 }
  2156.  
  2157.                 /* bell: sends a control g. */
  2158.  
  2159.                 else if(strnicmp(line,"bell" ,4)==NULL)
  2160.                 {
  2161.                         bco=bco+transmit(out,"\007",NOCRLF);
  2162.                 }
  2163.  
  2164.                 /* ring jsn: rings another jsn */
  2165.  
  2166.                 else if(strnicmp(line,"ring ",5)==NULL)
  2167.                 {
  2168.                         bco=bco+transmit(out,server,CRLF);
  2169.                         if(ringr==ON)
  2170.                         {
  2171.                                 strncpy(tjsn,line+5,JSNLEN-1);
  2172.                                 if(strncmp(tjsn,jsn,4)!=NULL)
  2173.                                 {
  2174.                                         sprintf(line," Ringing jsn %s.\n",tjsn);
  2175.                                         if(strlen(tjsn)>0)
  2176.                                         {
  2177.                                                 bco=bco+transmit(out,line,CRLF);
  2178.                                                 sprintf(sndbuf,"$%sbell %s\n",tjsn,jsn);
  2179.                                                 brdcst=ON;
  2180.                                                 goto sndmsg;
  2181.                                         }
  2182.                                         else
  2183.                                                 bco=bco+transmit(out," Missing or invalid jsn.\n",CRLF);
  2184.                                 }
  2185.                                 else
  2186.                                         bco=bco+transmit(out," You may not ring your own jsn.\n",CRLF);
  2187.                         }
  2188.                         else
  2189.                                 bco=bco+transmit(out,notallow,CRLF);
  2190.                 }
  2191.  
  2192.                 /* help command */
  2193.  
  2194.                 else if(strnicmp(line,"help",4)==NULL)
  2195.                 {
  2196.                         bco=bco+transmit(out,server,CRLF);
  2197.                         hlpon=OFF;
  2198.                         hlp_found=OFF;
  2199.  
  2200.                         /* find help topic requested */
  2201.  
  2202.                         sndbuf[0]=(char)NULL;
  2203.                         if(strncmp(line+4,BLANKS,1)==NULL)
  2204.                                 sprintf(sndbuf,"*%s",line+5);
  2205.                         i=strlen(sndbuf);
  2206.                         if(i<=1)
  2207.                         {
  2208.                                 sprintf(sndbuf,"*EOF");
  2209.                                 i=4;
  2210.                         }
  2211.  
  2212.                         /* search  help file */
  2213.  
  2214.                         hlp=fopen(hlpfil,"r");
  2215.                         if(hlp!=NULL)
  2216.                         {
  2217.                                 while(feof(hlp)==NULL)
  2218.                                 {
  2219.                                         j=rdline(hlp,line,LINLEN-1);
  2220.                                         if(strncmp(line,"*",1)==NULL)
  2221.                                         {
  2222.                                                 k=i;
  2223.                                                 j=find(line,':',LINLEN-1);
  2224.                                                 if(j>0&&j<i) k=j;
  2225.                                                 if(strnicmp(line,sndbuf,k)==NULL&&strncmp(line,"*EOF",4)!=NULL)
  2226.                                                 {
  2227.                                                         hlpon=ON;
  2228.                                                         hlp_found=ON;
  2229.                                                  }
  2230.                                                  else if(strncmp(line,"*EOF",4)==NULL&&hlp_found==OFF)
  2231.                                                  {
  2232.                                                         hlpon=ON;
  2233.                                                         hlp_found=ON;
  2234.                                                  }
  2235.                                                  else
  2236.                                                  {
  2237.                                                         hlpon=OFF;
  2238.                                                         if( hlp_found==ON) goto quithlp;
  2239.                                                  }
  2240.                                         }
  2241.                                         else  if(hlpon==ON)
  2242.                                                 bco=bco+transmit(out,line,CRLF);
  2243.                                 }
  2244.                                 quithlp:
  2245.                                 i=fclose(hlp);
  2246.                         }
  2247.                         else
  2248.                                 bco=bco+transmit(out," Error: Help file not present\n",CRLF);
  2249.                 }
  2250.  
  2251.                 /* wait command */
  2252.  
  2253.                 else if(strnicmp(line,"wait",4)==NULL)
  2254.                 {
  2255.                         bco=bco+transmit(out,server,CRLF);
  2256.                         sprintf(line," Waiting for \"%s\".\n",waitstr);
  2257.                         bco=bco+transmit(out,line,CRLF);
  2258.                         wait=ON;
  2259. #ifdef NETWORK
  2260.             on = ON;
  2261.             if( ioctl( in, FIONBIO, (char *)&on ) < NULL )
  2262.                 perror( "ioctl1" );
  2263. #endif NETWORK
  2264.                 }
  2265.  
  2266.                 /* scroll command */
  2267.  
  2268.                 else if(strnicmp(line,"scroll",6)==NULL)
  2269.                 {
  2270.                         bco=bco+transmit(out,server,CRLF);
  2271.                         bco=bco+transmit(out," Entering scroll mode.\n",CRLF);
  2272.                         scroll=ON;
  2273. #ifdef NETWORK
  2274.             on = ON;
  2275.             if( ioctl( in, FIONBIO, (char *)&on ) < NULL )
  2276.                 perror( "ioctl1" );
  2277. #endif NETWORK
  2278.                 }
  2279.  
  2280.                 /* delay command */
  2281.  
  2282.                 else if(strnicmp(line,"delay",5)==NULL)
  2283.                 {
  2284.                         bco=bco+transmit(out,server,CRLF);
  2285.                         sprintf(line," Delaying for %d seconds.\n",dtime);
  2286.                         bco=bco+transmit(out,line,CRLF);
  2287. #ifdef SYSV2
  2288.                         sleep((unsigned)dtime);
  2289. #endif SYSV2
  2290. #ifdef SYSV3
  2291.                         u=sleep((unsigned)dtime);
  2292. #endif SYSV3
  2293. #ifdef BSD4
  2294.                         sleep((unsigned)dtime);
  2295. #endif BSD4
  2296. #ifdef ULTRIX
  2297.                         sleep((unsigned)dtime);
  2298. #endif ULTRIX
  2299.                 }
  2300.  
  2301.                 /* clear command - clears message buffer */
  2302.  
  2303.                 else if(strnicmp(line,"clear",5)==NULL)
  2304.                 {
  2305.                         msgpos=NULL;
  2306.                         msgbuf[msgpos]=(char)NULL;
  2307.                         bco=bco+transmit(out,server,CRLF);
  2308.                         bco=bco+transmit(out," Message buffer cleared.\n",CRLF);
  2309.                 }
  2310.  
  2311.                 /* write command - writes message buffer to file */
  2312.  
  2313.                 else if(strnicmp(line,"write ",6)==NULL)
  2314.                 {
  2315.                         bco=bco+transmit(out,server,CRLF);
  2316.                         if(files==OFF)
  2317.                                 bco=bco+transmit(out,notallow,CRLF);
  2318.                         else
  2319.                         {
  2320. #ifdef SYSV2
  2321.                                 i=setuid(uid);
  2322. #endif SYSV2
  2323. #ifdef SYSV3
  2324.                                 i=setuid(uid);
  2325. #endif SYSV3
  2326.                                 i=chdir(homedir);
  2327.                                 strcpy(tmpfil,line+6);
  2328.                                 if(strlen(tmpfil)==0)
  2329.                                         bco=bco+transmit(out," Error: Invalid file name.\n",CRLF);
  2330.                                 else if(msgpos<3)
  2331.                                         bco=bco+transmit(out," Error: Buffer too short.\n",CRLF);
  2332.                                 else
  2333.                                 {
  2334.  
  2335.                                         tmp=fopen(tmpfil,"r");
  2336.                                         if(tmp!=NULL)
  2337.                                         {
  2338.                                                 i=fclose(tmp);
  2339.                                                 bco=bco+transmit(out," Error: File exists.\n",CRLF);
  2340.                                         }
  2341.                                         else
  2342.                                         {
  2343.                                                 tmp=fopen(tmpfil,"w");
  2344.                                                 if(tmp==NULL)
  2345.                                                         bco=bco+transmit(out," Error: Invalid file name.\n",CRLF);
  2346.                                                 else
  2347.                                                 {
  2348.                                                         chmod(tmpfil,00600);
  2349.                                                         i=1;
  2350.                                                         while(i<msgpos)
  2351.                                                         {
  2352. #ifdef SYSV2
  2353.                                                                 fputc((int)((char)msgbuf[i]),tmp);
  2354. #endif SYSV2
  2355. #ifdef SYSV3
  2356.                                                                 fputc((int)((char)msgbuf[i]),tmp);
  2357. #endif SYSV3
  2358. #ifdef BSD4
  2359.                                                                 fputc((char)msgbuf[i],tmp);
  2360. #endif BSD4
  2361. #ifdef ULTRIX
  2362.                                                                 fputc((char)msgbuf[i],tmp);
  2363. #endif ULTRIX
  2364.                                                                 if(msgbuf[i]=='\n')
  2365.                                                                         i=i+2;
  2366.                                                                 else
  2367.                                                                         ++i;
  2368.                                                         }
  2369.                                                         i=fclose(tmp);
  2370.                                                         sprintf(line,"\n Buffer written to %s.\n",tmpfil);
  2371.                                                         bco=bco+transmit(out,line,CRLF);
  2372.                                                 }
  2373.                                         }
  2374.                                 }
  2375. #ifdef SYSV2
  2376.                                 i=setuid(euid);
  2377. #endif SYSV2
  2378. #ifdef SYSV3
  2379.                                 i=setuid(euid);
  2380. #endif SYSV3
  2381.                                 i=chdir(slugdir);
  2382.                         }
  2383.                 }
  2384.  
  2385.                 /* see if command is in user's definition file */
  2386.  
  2387.                 else
  2388.                 {
  2389. #ifdef SYSV2
  2390.                         i=setuid(uid);
  2391. #endif SYSV2
  2392. #ifdef SYSV3
  2393.                         i=setuid(uid);
  2394. #endif SYSV3
  2395.                         i=chdir(homedir);
  2396.                         def=fopen(deffil,"r");
  2397.                         if(def!=NULL)
  2398.                         {
  2399.                                 while(feof(def)==NULL)
  2400.                                 {
  2401.                                         i=rdline(def,scratch,LINLEN);
  2402.                                         if(strncmp(scratch,"*",1)!=NULL)
  2403.                                         {
  2404.                                                 i=find(scratch,'=',LINLEN);
  2405.                                                 if(i>=0)
  2406.                                                 {
  2407.                                                         if(strnicmp(line,scratch,i)==NULL)
  2408.                                                         {
  2409.                                                                 j=find(scratch,';',LINLEN);
  2410.                                                                 if(j>=0)
  2411.                                                                 {
  2412.                                                                         strncpy(sndbuf,scratch+i+1,j-i-1);
  2413.                                                                         strcpy(sndbuf+j-i-1,line+i);
  2414.                                                                         strncpy(line,sndbuf,LINLEN-1);
  2415.                                                                         i=fclose(def);
  2416. #ifdef SYSV2
  2417.                                                                         i=setuid(euid);
  2418. #endif SYSV2
  2419. #ifdef SYSV3
  2420.                                                                         i=setuid(euid);
  2421. #endif SYSV3
  2422.                                                                         i=chdir(slugdir);
  2423.                                                                         goto parser;
  2424.                                                                 }
  2425.                                                         }
  2426.                                                 }
  2427.                                         }
  2428.                                 }
  2429.                                 i=fclose(def);
  2430.                         }
  2431. #ifdef SYSV2
  2432.                         i=setuid(euid);
  2433. #endif SYSV2
  2434. #ifdef SYSV3
  2435.                         i=setuid(euid);
  2436. #endif SYSV3
  2437.                         i=chdir(slugdir);
  2438.  
  2439.                         /* help blurb */
  2440.  
  2441.                         if(novice==ON && mode[ 0 ] == 'U' ){
  2442.                                 bco=bco+transmit(out,server,CRLF);
  2443.                                 bco=bco+transmit(out," Type \"help\" for instructions.\n",CRLF);
  2444.                         }
  2445.                         else if( mode[ 0 ] == 'U' ){
  2446.                                 strcpy(sndbuf,line);
  2447.                                 line[0]=' ';
  2448.                                 strncpy(line+1,sndbuf,LINLEN-1);
  2449.                                 goto parser;
  2450.                         }
  2451.                 }
  2452.         }
  2453.  
  2454.         /* destroy receiver file, close input, output redirection files */
  2455.  
  2456.         cleanup:
  2457.     lock(rcvfil);
  2458.         i=unlink(rcvfil);
  2459.     unlock(rcvfil);
  2460.         if(inp != NULL) 
  2461.         i=fclose(inp);
  2462. #ifdef NETWORK
  2463.     if(out != socket )
  2464. #endif NETWORK
  2465. #ifdef LOCAL
  2466.     if(out != fileno( stdout ))
  2467. #endif LOCAL
  2468.         i=close(out);
  2469.         inp=(FILE *)NULL;
  2470. #ifdef NETWORK
  2471.         out=socket;
  2472. #endif NETWORK
  2473. #ifdef LOCAL
  2474.     out = fileno( stdout );
  2475. #endif LOCAL
  2476.         if(stop==OFF && login==ON) goto wait_for_call;
  2477.         i=chdir(homedir);
  2478.         return(11);
  2479. }
  2480. \End\Of\Shar\
  2481. else
  2482.   echo "will not over write ./slugnet.c"
  2483. fi
  2484. chmod 600 ./slugnet.c
  2485. if [ `wc -c ./slugnet.c | awk '{printf $1}'` -ne 91130 ]
  2486. then
  2487. echo `wc -c ./slugnet.c | awk '{print "Got " $1 ", Expected " 91130}'`
  2488. fi
  2489. echo "Finished archive 4 of 6"
  2490. exit
  2491.