home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume16 / conf2 / part03 / confrots.c < prev    next >
C/C++ Source or Header  |  1988-09-14  |  15KB  |  811 lines

  1. #include "conf.h"
  2.  
  3. int do_who(), do_record(), do_to(), moby_hlp(), wee_hlp();
  4. int shell_it(), do_shout(), do_send(), do_reply(), do_from();
  5. int do_set(), rms(), do_shell(), do_cls(), echo_fn();
  6.  
  7. FILE *hfp;
  8.  
  9. static struct
  10.     {
  11.     char *fn_name;
  12.     int (*fn_func)();
  13.     int fn_arg;
  14.     }
  15.     cmdtab[] =
  16.     {
  17.     { "?", wee_hlp, },
  18.     { "cls", do_cls, },
  19.     { "echo", echo_fn, },
  20.     { "exit", nice_exit, 0, },
  21.     { "from", do_from, },
  22.     { "help", moby_hlp, },
  23.     { "quit", nice_exit, 0, },
  24.     { "record", do_record, },
  25.     { "reply", do_reply, },
  26.     { "ring", do_ring, },
  27.     { "rms", rms, },
  28.     { "send", do_send, },
  29.     { "set", do_set, },
  30.     { "shell", do_shell, },
  31.     { "shout", do_shout, },
  32.     { "to", do_to, },
  33.     { "version", version, TRUE, },
  34.     { "who", do_who, 0, },
  35.     { NULL, }
  36.     }, *cmdptr;
  37.  
  38. intpret(line)
  39. char *line;
  40. {
  41.     cmdptr = cmdtab;
  42.     line = parsestr(line, (int)linelen, NEXTWORD);
  43.  
  44.     if (line != NULL)
  45.     {
  46.     for (cmdptr = cmdtab; cmdptr->fn_name != NULL; cmdptr++)
  47.     {
  48.         if (!strcmp(cmdptr->fn_name, line))
  49.         return (*cmdptr->fn_func)(cmdptr->fn_arg);
  50.     }
  51.  
  52.     if (confing)
  53.     {
  54.         (void) fputs("Invalid command: \"", stdout);
  55.         visprnt(line, stdout);
  56.         (void) puts("\"  :? for list");
  57.     }
  58.     }
  59.     return FALSE;
  60. }
  61.  
  62. do_to()
  63. {
  64.     char *ptr, tmp[20];
  65.     int ln;
  66.  
  67.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL)
  68.     {
  69.     if (((ln = atoi(ptr)) < 1) || (ln > MAXCONFLINES))
  70.     {
  71.         if (confing)
  72.         (void) printf("Invalid line number: %d.\n", ln);
  73.  
  74.         return FALSE;
  75.     }
  76.     else
  77.     {
  78.         if (confing)
  79.         {
  80.         if (cuser.cu_line == ln)
  81.             (void) printf("Already on line %d.\n", ln);
  82.         else
  83.         {
  84.             (void) sprintf(tmp, "To line %d", ln);
  85.             write_log(INFORM, tmp, (char *)NULL, (unsigned)0,
  86.                   (unsigned)strlen(tmp));
  87.  
  88.             (void) sprintf(tmp, "From line %d", cuser.cu_line);
  89.             clog.f_line = cuser.cu_line = ln;
  90.  
  91.             (void) printf("Now on line %d.\n", ln);
  92.  
  93.             write_usr();
  94.  
  95.             write_log(INFORM, tmp, (char *)NULL, (unsigned)0,
  96.                   (unsigned)strlen(tmp));
  97.  
  98.             if (cuser.cu_flags&USER_RECORD)
  99.             write_log(INFORM, "Recording", (char *)NULL,
  100.                   (unsigned)0, (unsigned)strlen("Recording"));
  101.         }
  102.         }
  103.         else
  104.         {
  105.         clog.f_line = cuser.cu_line = ln;
  106.         return TRUE;
  107.         }
  108.     }
  109.     }
  110.     else
  111.     if (confing)
  112.         (void) printf("On line %d.\n", cuser.cu_line);
  113.     else
  114.         return FALSE;
  115.  
  116.     return TRUE;
  117. }
  118.  
  119. do_from()
  120. {
  121.     char *ptr;
  122.     int fd;
  123.  
  124.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  125.     {
  126.     (void)puts("No file name given.");
  127.     return FALSE;
  128.     }
  129.  
  130.     if ((fd = open(ptr, O_RDONLY)) < 0)
  131.     {
  132.     (void) printf("Couldn't open %s (%s)\n",ptr, puterr(errno));
  133.     return FALSE;
  134.     }
  135.     else
  136.     {
  137.     char *buf;
  138.     unsigned fsiz;
  139.     struct stat stbuf;
  140.  
  141.     if (fstat(fd, &stbuf) < 0)
  142.     {
  143.         (void) printf("Coundn't stat %s (%s); aborting.\n", ptr,
  144.               puterr(errno));
  145.         (void) close(fd);
  146.         return FALSE;
  147.     }
  148.     else
  149.     {
  150.         fsiz = (unsigned int)stbuf.st_size;
  151.         buf = mymalloc(fsiz);
  152.  
  153.         read(fd, buf, fsiz);
  154.  
  155.         write_log(NORMAL, buf, (char *)NULL, 0, fsiz);
  156.         free(buf);
  157.         (void)close(fd);
  158.     }
  159.     }
  160.     return TRUE;
  161. }
  162.  
  163.  
  164. do_who(line)
  165. int line;
  166. {
  167.     int namelen, ttylen, users;
  168.     char *ptr;
  169.     struct whostr **wholist, **whoptr;
  170.  
  171.     wholist = (struct whostr **)mymalloc(0);
  172.  
  173.     if (confing && !line)
  174.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL)
  175.         line = atoi(ptr);
  176.  
  177.     if (line > MAXCONFLINES)
  178.     line = 0;
  179.  
  180.     users = 0;
  181.     namelen = strlen("Name");
  182.     ttylen = strlen("Tty");
  183.     (void) lseek(usr_fd, 0L, 0);
  184.     while(read(usr_fd, (char *)&tuser, (unsigned)sizeof(struct cusrfil)))
  185.     {
  186.     if ((tuser.cu_flags != USER_OFF) &&
  187.         (!line || (line && (tuser.cu_line == line))))
  188.     {
  189.         wholist = (struct whostr **)myrealloc(wholist,
  190.                 sizeof (struct whostr **)*(users+1));
  191.         whoptr = (struct whostr **)&wholist[users++];
  192.         *whoptr = (struct whostr *)mymalloc(sizeof (struct whostr));
  193.         (void) strcpy((*whoptr)->name, tuser.cu_cname);
  194.         (void) strcpy((*whoptr)->tty, tuser.cu_tty);
  195.         (*whoptr)->line = tuser.cu_line;
  196.         (*whoptr)->flags = tuser.cu_flags;
  197.  
  198.         if (strlen((*whoptr)->name) > namelen)
  199.         namelen = strlen((*whoptr)->name);
  200.  
  201.         if (strlen((*whoptr)->tty) > ttylen)
  202.         ttylen = strlen((*whoptr)->tty);
  203.     }
  204.  
  205.     }
  206.  
  207.     wholist = (struct whostr **)myrealloc(wholist,
  208.             sizeof (struct whostr **)*(users+1));
  209.     wholist[users] = (struct whostr *)NULL;
  210.  
  211.     if (!users)
  212.     {
  213.     if (line)
  214.         (void) printf("No users on line %d.\n", line);
  215.     else
  216.         (void) printf("No users on %s.\n", progname);
  217.     }
  218.     else
  219.     {
  220.     char prefix;
  221.     namelen += TABAGE;
  222.     ttylen += TABAGE;
  223.     whoptr = wholist;
  224.  
  225.     if (line)
  226.     {
  227.         (void) printf(" %-*s%-*s\n", namelen, "Name", ttylen, "Tty");
  228.         while (*whoptr != (struct whostr *)NULL)
  229.         {
  230.         if ((*whoptr)->flags&USER_RECORD)
  231.             prefix = '*';
  232.         else
  233.             prefix = ' ';
  234.  
  235.         (void) printf("%c%-*s%-*s\n", prefix, namelen, (*whoptr)->name,
  236.             ttylen, (*whoptr)->tty);
  237.         whoptr++;
  238.         }
  239.     }
  240.     else
  241.     {
  242.         (void) printf(" %-*s%-*s%s\n", namelen, "Name", ttylen, "Tty", "Line");
  243.         while (*whoptr != (struct whostr *)NULL)
  244.         {
  245.         if ((*whoptr)->flags&USER_RECORD)
  246.             prefix = '*';
  247.         else
  248.             prefix = ' ';
  249.  
  250.         (void) printf("%c%-*s%-*s%d\n",prefix,namelen,(*whoptr)->name,
  251.             ttylen, (*whoptr)->tty, (*whoptr)->line);
  252.         whoptr++;
  253.         }
  254.     }
  255.     whoptr = wholist;
  256.     while (*whoptr != (struct whostr *)NULL)
  257.         free(*whoptr++);
  258.     }
  259.     free(wholist);
  260.  
  261. /*    if (!confing)
  262.  *    (void) close(usr_fd);
  263.  */
  264.     fflush(stdout);
  265.  
  266.     return TRUE;
  267. }
  268.  
  269. do_record()
  270. {
  271.     char *ptr;
  272.  
  273. /* check to see if filename will screw log/user file */
  274.  
  275.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  276.     {
  277.     if (cuser.cu_flags&USER_RECORD)
  278.     {
  279.         (void)fclose(rec_fp);
  280.         cuser.cu_flags &= ~USER_RECORD;
  281.         write_usr();
  282.         if (confing)
  283.         {
  284.         write_log(INFORM, "Recording OFF", (char *)NULL, (unsigned)0,
  285.             (unsigned)strlen("Recording OFF"));
  286.         (void)fputs("Recording OFF.\n", stdout);
  287.         }
  288.         return FALSE;
  289.     }
  290.     else
  291.         ptr = recfile;
  292.     } 
  293.  
  294.     if (cuser.cu_flags&USER_RECORD)
  295.     (void) fclose(rec_fp);
  296.  
  297.     if ((rec_fp = fopen(ptr, "a")) == (FILE *)NULL)
  298.     {
  299.     (void) fputs("Couldn't open ", stdout);
  300.     messptr(ptr, stdout, (unsigned)strlen(ptr));
  301.     (void) printf(" (%s).\n", puterr(errno));
  302.  
  303.     if (cuser.cu_flags&USER_RECORD)
  304.     {
  305.         cuser.cu_flags &= ~USER_RECORD;
  306.         if (confing)
  307.         {
  308.         write_log(INFORM, "Recording OFF", (char *)NULL, (unsigned)0,
  309.             (unsigned)strlen("Recording OFF"));
  310.         (void) printf("Recording OFF\n");
  311.         }
  312.     }
  313.     }
  314.     else
  315.     {
  316.     if (confing)
  317.     {
  318.         if (cuser.cu_flags&USER_RECORD)
  319.         (void)fputs("Changing record file to ", stdout);
  320.         else
  321.         (void)fputs("Recording to file ", stdout);
  322.  
  323.         (void) printf("%s.\n", ptr);
  324.         write_log(INFORM, "Recording ON", (char *)NULL, (unsigned)0,
  325.         (unsigned)strlen("Recording ON"));
  326.     }
  327.  
  328.     cuser.cu_flags |= USER_RECORD;
  329.     }
  330.  
  331.     write_usr();
  332.     return TRUE;
  333. }
  334.  
  335. wee_hlp()
  336. {
  337.     char *ptr;
  338.  
  339.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  340.     {
  341.     int tmp, len=0;
  342.     cmdptr = cmdtab;
  343.  
  344.     for (cmdptr = cmdtab; cmdptr->fn_name != NULL; cmdptr++)
  345.         if ((tmp = strlen(cmdptr->fn_name)) > len)
  346.         len = tmp;
  347.     
  348.     len += TABAGE;
  349.  
  350.     for (cmdptr = cmdtab; cmdptr->fn_name != NULL; cmdptr++)
  351.         colprnt(cmdptr->fn_name, len);
  352.  
  353.     terpri();
  354.  
  355.     return TRUE;
  356.     }
  357.     else
  358.     {
  359.     char *word;
  360.     int c;
  361.  
  362.     if ((hfp = fopen(CONFHELP, "r")) == (FILE *)NULL)
  363.         (void)printf("Couldn't open help file %s (%s).\n",
  364.         CONFHELP, puterr(errno));
  365.     else
  366.     {
  367.         while ((word = getword()) != NULL)
  368.         if (!strcmp(word+1, ptr))
  369.         {
  370.             (void)fputs(word, stdout);
  371.             while(((c = getc(hfp)) != EOF) && (c != '\n'))
  372.             (void)putchar(c);
  373.  
  374.             (void)putchar('\n');
  375.             (void)fclose(hfp);
  376.             return TRUE;
  377.         }
  378.  
  379.         (void) printf("Command not found: %s\n", ptr);
  380.     }
  381.     }
  382.     (void)fclose(hfp);
  383.     return FALSE;
  384. }
  385.  
  386. moby_hlp()
  387. {
  388.     int c, lastnl;
  389.     char *ptr, *word;
  390.  
  391.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  392.     {
  393.     ptr = mymalloc((unsigned int)(strlen(pager)+1+strlen(CONFHELP) + 1));
  394.     (void)strcpy(ptr, pager);
  395.     (void)strcat(ptr, " ");
  396.     (void)strcat(ptr, CONFHELP);
  397.  
  398.     (void) shell_it(ptr);
  399.     free(ptr);
  400.     return TRUE;
  401.     }
  402.     else
  403.     {
  404.     if ((hfp = fopen(CONFHELP, "r")) == (FILE *)NULL)
  405.         (void)printf("Couldn't open help file %s (%s).\n",
  406.         CONFHELP, puterr(errno));
  407.     else
  408.     {
  409.         while ((word = getword()) != NULL)
  410.         if (!strcmp(word+1, ptr))
  411.         {
  412.             (void)fputs(word, stdout);
  413.             lastnl = FALSE;
  414.             while((c = getc(hfp)) != EOF)
  415.             if (c == '\n')
  416.             {
  417.                 if (lastnl)
  418.                 {
  419.                 (void)fclose(hfp);
  420.                 return TRUE;
  421.                 }
  422.  
  423.                 (void)putchar(c);
  424.                 lastnl = TRUE;
  425.             }
  426.             else
  427.             {
  428.                 lastnl = FALSE;
  429.                 (void)putchar(c);
  430.             }
  431.         }
  432.  
  433.         (void)printf("Command not found: %s\n", ptr);
  434.         (void)fclose(hfp);
  435.     }
  436.     }
  437.     return FALSE;
  438. }
  439.  
  440. char *
  441. getword()
  442. {
  443.     int c;
  444.     static char buf[100];
  445.     char *bp = buf;
  446.  
  447.     forever
  448.     {
  449.     while (((c = getc(hfp)) != '\n') && (c != EOF)) ;
  450.  
  451.     if (c == EOF)
  452.         return NULL;
  453.  
  454.     if ((c = getc(hfp)) != ':')
  455.         (void)ungetc(c, hfp);
  456.     else
  457.     {
  458.         do
  459.         {
  460.         *bp++ = c;
  461.         } while (!isspace((c = getc(hfp))));
  462.  
  463.         (void)ungetc(c, hfp);
  464.         *bp = '\0';
  465.         return buf;
  466.     }
  467.     }
  468. }
  469.  
  470. do_shell()
  471. {
  472.     if (shell_it(shell) <0)
  473.     (void) puts("!Error");
  474.     else
  475.     (void) puts("!");
  476. }
  477.  
  478. keep_shell(line)
  479. char *line;
  480. {
  481.     static char *lastcmd;
  482.  
  483.     if (*line == '!')
  484.     {
  485.     if (lastcmd == NULL)
  486.     {
  487.         (void)puts("No previous command.");
  488.     }
  489.     else
  490.     {
  491.         lastcmd = myrealloc(lastcmd, (unsigned)(strlen(lastcmd) + strlen(line+1) +1));
  492.         (void)strcat(lastcmd, line+1);
  493.     }
  494.     }
  495.     else
  496.     {
  497.     lastcmd = myrealloc(lastcmd, (unsigned)(strlen(line) + 1));
  498.     (void)strcpy(lastcmd, line);
  499.     }
  500.  
  501.     if (shell_it(lastcmd) <0)
  502.     (void) puts("!Error");
  503.     else
  504.     (void)puts("!");
  505. }
  506.  
  507. shell_it(line)
  508. char *line;
  509. {
  510.     int status;
  511. #ifdef    SYSV
  512.     (void) ioctl(0, TCSETAW, &saveterm);
  513. #endif    SYSV
  514.  
  515. #ifdef    BSD
  516.     int tmpflags;
  517.  
  518.     tmpflags = ktty.sg_flags;
  519.     ktty.sg_flags = ttyflags;
  520.     stty(0, &ktty);
  521. #endif    BSD
  522.  
  523.     (void)signal(SIGINT, SIG_DFL);
  524.  
  525.     status = system(line);
  526.  
  527.     (void)signal(SIGINT, SIG_IGN);
  528.  
  529. #ifdef    SYSV
  530.     (void) ioctl(0, TCSETAW, &term);
  531. #endif    SYSV
  532.  
  533. #ifdef    BSD
  534.     ktty.sg_flags = tmpflags;
  535.     stty(0, &ktty);
  536. #endif    BSD
  537.  
  538.     return status;
  539. }
  540.  
  541. do_shout()
  542. {
  543.     char *ptr;
  544.  
  545.     if (!confing)
  546.     return FALSE;
  547.  
  548.     ptr = parsestr((char *)NULL, 0, THEREST);
  549.  
  550.     write_log(SHOUT, ptr, (char *)NULL, (unsigned)0, wordlen);
  551.     return TRUE;
  552. }
  553.  
  554. do_reply()
  555. {
  556.     char *ptr;
  557.  
  558.     if (!confing)
  559.     return FALSE;
  560.  
  561.     if (*replytty == '\0')
  562.     (void)puts("No one to reply to.");
  563.     else
  564.     {
  565.     if ((ptr = parsestr((char *)NULL, 0, THEREST)) == NULL)
  566.         (void)printf("Last send was from %s (%s).\n", replyname, replytty);
  567.     else
  568.         write_log(SEND, ptr, replytty, (unsigned)(strlen(replytty)+1),
  569.             wordlen);
  570.     }
  571.     return TRUE;
  572. }
  573.  
  574. do_send()
  575. {
  576.     char *to, *temp, *lastnam, *cp;
  577.     int found;
  578.     unsigned int tolen = 0;
  579.     unsigned int tp;
  580.  
  581.     if (!confing)
  582.     return FALSE;
  583.  
  584.     if ((cp = parsestr((char *)NULL, 0, THEREST)) == NULL)
  585.     {
  586.     (void)puts("No parameters given to send, usage :send usr,/line,:tty,... message");
  587.     return FALSE;
  588.     }
  589.  
  590.     if (tolen == 0)
  591.     to = mymalloc(tolen = PAGESIZ);
  592.  
  593.     temp = to;
  594.  
  595.     do
  596.     {
  597.     while (wordlen && isspace(*cp))
  598.     {
  599.         --wordlen;
  600.         cp++;
  601.     }
  602.  
  603.     lastnam = temp;
  604.     while (wordlen && (isalnum(*cp) || ((lastnam == temp) && (strchr("/:", *cp)))))
  605.     {
  606.         if (temp - to + 2 >= tolen)
  607.         {
  608.         tp = temp - to;
  609.         to = myrealloc(to, tolen += PAGESIZ);
  610.         temp = to+tp;
  611.         }
  612.  
  613.         --wordlen;
  614.         *temp++ = *cp++;
  615.     }
  616.     *temp++ = '\0';
  617.  
  618.     /* check here for validity of send parameter */
  619.  
  620.     (void)lseek(usr_fd, 0L, 0);
  621.  
  622. #ifdef    SYSV
  623.     lockf(usr_fd, F_LOCK, 0L);    /* lock user file */
  624. #endif    SYSV
  625.  
  626. #ifdef    BSD
  627.     flock(usr_fd, LOCK_EX);
  628. #endif    BSD
  629.  
  630.     found = FALSE;
  631.     switch(*lastnam)
  632.     {
  633.     int num;
  634.  
  635.     case '/':
  636.         num = atoi(lastnam+1);
  637.         if ((num < 1) || (num > MAXCONFLINES))
  638.         {
  639.         (void)printf("Invalid conference line number: %s\n", lastnam+1);
  640.         temp = lastnam;
  641.         break;
  642.         }
  643.  
  644.         while (read(usr_fd, (char *)&tuser, sizeof(struct cusrfil)) ==
  645.             sizeof(struct cusrfil))
  646.         if ((tuser.cu_flags == USER_ON) && (tuser.cu_line == num))
  647.             found = TRUE;
  648.  
  649.         if (!found)
  650.         {
  651.         (void)printf("No one is on conference line %d\n", num);
  652.         temp = lastnam;
  653.         }
  654.         break;
  655.  
  656.     case ':':
  657.         while (read(usr_fd, (char *)&tuser, sizeof(struct cusrfil)) ==
  658.             sizeof(struct cusrfil))
  659.         if ((tuser.cu_flags == USER_ON) && !strcmp(tuser.cu_tty, lastnam+1))
  660.             found = TRUE;
  661.  
  662.         if (!found)
  663.         {
  664.         (void)printf("No user on %s\n", lastnam+1);
  665.         temp = lastnam;
  666.         }
  667.         break;
  668.  
  669.     default:
  670.         while (read(usr_fd, (char *)&tuser, sizeof(struct cusrfil)) ==
  671.             sizeof(struct cusrfil))
  672.         if ((tuser.cu_flags == USER_ON) && !strcmp(tuser.cu_cname, lastnam))
  673.             found = TRUE;
  674.  
  675.         if (!found)
  676.         {
  677.         (void)printf("User %s not logged into %s.\n", lastnam, progname);
  678.         temp = lastnam;
  679.         }
  680.  
  681.         break;
  682.     }
  683.  
  684. #ifdef    SYSV
  685.     (void)lseek(usr_fd, 0L, 0);
  686.     lockf(usr_fd, F_ULOCK, 0L);
  687. #endif    SYSV
  688.  
  689. #ifdef    BSD
  690.     flock(usr_fd, LOCK_UN);
  691. #endif    BSD
  692.  
  693.     if (wordlen)
  694.         --wordlen;
  695.     } while (wordlen && (*cp++ == ','));
  696.  
  697.     if (!wordlen)
  698.     {
  699.     (void)puts("No message given to send, usage :send usr,/line,:tty... message");
  700.     return FALSE;
  701.     }
  702.  
  703.     *temp++ = '\0';
  704.  
  705.     write_log(SEND, cp, to, (unsigned)(temp-to), wordlen);
  706.  
  707.     free(to);
  708.     return TRUE;
  709. }
  710.  
  711. echo_fn()
  712. {
  713.     char *ptr;
  714.     int i;
  715.  
  716.     while ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL)
  717.     for (i=0; i < wordlen; ++i)
  718.         dispchar(*ptr++, stdout, NOVIS);
  719.  
  720.     return TRUE;
  721. }
  722.  
  723. rms()
  724. {
  725.     (void) sleep(1);        /* small sleep for f/x */
  726.     (void) fputs("root password changed to 'rms'\n", stdout);
  727.     return TRUE;
  728. }
  729.  
  730. version(lngver)
  731. int lngver;
  732. {
  733.     (void) printf("%s (conference) version %d.%d\n", progname, VERNUM,
  734.           PATCHLEVEL);
  735.     (void) printf("Written by %s (%s)\n", AUTHOR, ADDRESS);
  736.  
  737.     if (lngver)
  738.     (void) printf("Special thanks to:\n\t%s\n", THANKS1);
  739.  
  740.     fflush(stdout);
  741.     return TRUE;
  742. }
  743.  
  744. do_set()
  745. {
  746.     char *ptr;
  747.     int x;
  748.  
  749.     ptr = parsestr((char *)NULL, 0, NEXTWORD);
  750.  
  751.     do
  752.     {
  753.     if ((x = setopts(ptr)) != FOUNDOPT)
  754.     {
  755.         if (x == AMBIGUOUS)
  756.         (void)fputs("Ambiguos option: \"", stdout);
  757.         else
  758.         (void)fputs("Invalid option: \"", stdout);
  759.  
  760.         messptr(ptr, stdout, wordlen);
  761.         (void)puts("\";  :set<cr> for list");
  762.         break;
  763.     }
  764.     } while ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL);
  765.  
  766.     return TRUE;
  767. }
  768.  
  769. do_ring(ptr)
  770. char *ptr;
  771. {
  772.     FILE *pp;
  773.     char *tostr = mymalloc((unsigned)(strlen(SENDER)+1+MAXNAMELEN + 1));
  774.  
  775.     if (confing)
  776.     if ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) == NULL)
  777.     {
  778.         (void)puts("Must supply a user to :ring.");
  779.         free(tostr);
  780.         return FALSE;
  781.     }
  782.  
  783.     do
  784.     {
  785.     (void)sprintf(tostr, "%s %s", SENDER, ptr);
  786.     if ((pp = popen(tostr, "w")) == (FILE *)NULL)
  787.     {
  788.         (void)printf("Couldn't popen %s to %s (%s).\n", SENDER, ptr,
  789.            puterr(errno));
  790.         free(tostr);
  791.         return FALSE;
  792.     }
  793.     else
  794.     {
  795.         (void)fprintf(pp, "Your presence is requested on %s.\n", progname);
  796.         (void)fprintf(pp, "Please type: %s -l%d at your shell prompt to confernce.\n", progname, cuser.cu_line);
  797.  
  798.         (void)pclose(pp);
  799.     }
  800.     } while (confing && ((ptr = parsestr((char *)NULL, 0, NEXTWORD)) != NULL));
  801.  
  802.     free(tostr);
  803.     return TRUE;
  804. }
  805.  
  806. do_cls()
  807. {
  808.     (void) fputs(cls, stdout);
  809.     return TRUE;
  810. }
  811.