[BACK]Return to cmd3.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mail

Diff for /src/usr.bin/mail/cmd3.c between version 1.4 and 1.5

version 1.4, 1997/05/30 08:51:35 version 1.5, 1997/07/13 21:21:09
Line 1 
Line 1 
 /*      $OpenBSD$       */  /*      $OpenBSD$       */
 /*      $NetBSD: cmd3.c,v 1.5 1996/06/08 19:48:14 christos Exp $        */  /*      $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $   */
   
 /*  /*
  * Copyright (c) 1980, 1993   * Copyright (c) 1980, 1993
Line 36 
Line 36 
   
 #ifndef lint  #ifndef lint
 #if 0  #if 0
 static char sccsid[] = "@(#)cmd3.c      8.1 (Berkeley) 6/6/93";  static char sccsid[] = "@(#)cmd3.c      8.2 (Berkeley) 4/20/95";
 #else  #else
 static char rcsid[] = "$OpenBSD$";  static char rcsid[] = "$OpenBSD$";
 #endif  #endif
Line 67 
Line 67 
   
         (void) strcpy(cmd, str);          (void) strcpy(cmd, str);
         if (bangexp(cmd) < 0)          if (bangexp(cmd) < 0)
                 return 1;                  return(1);
         if ((shell = value("SHELL")) == NOSTR)          if ((shell = value("SHELL")) == NOSTR)
                 shell = _PATH_CSHELL;                  shell = _PATH_CSHELL;
         (void) run_command(shell, 0, -1, -1, "-c", cmd, NOSTR);          (void) run_command(shell, 0, -1, -1, "-c", cmd, NOSTR);
         (void) signal(SIGINT, sigint);          (void) signal(SIGINT, sigint);
         printf("!\n");          puts("!");
         return 0;          return(0);
 }  }
   
 /*  /*
Line 92 
Line 92 
         (void) run_command(shell, 0, -1, -1, NOSTR, NOSTR, NOSTR);          (void) run_command(shell, 0, -1, -1, NOSTR, NOSTR, NOSTR);
         (void) signal(SIGINT, sigint);          (void) signal(SIGINT, sigint);
         putchar('\n');          putchar('\n');
         return 0;          return(0);
 }  }
   
 /*  /*
Line 118 
Line 118 
                 if (*cp == '!') {                  if (*cp == '!') {
                         if (n < strlen(lastbang)) {                          if (n < strlen(lastbang)) {
 overf:  overf:
                                 printf("Command buffer overflow\n");                                  puts("Command buffer overflow");
                                 return(-1);                                  return(-1);
                         }                          }
                         changed++;                          changed++;
Line 145 
Line 145 
                 fflush(stdout);                  fflush(stdout);
         }          }
         strcpy(str, bangbuf);          strcpy(str, bangbuf);
         strncpy(lastbang, bangbuf, 128);          strncpy(lastbang, bangbuf, sizeof(lastbang) - 1);
         lastbang[128-1] = 0;          lastbang[sizeof(lastbang) - 1] = '\0';
         return(0);          return(0);
 }  }
   
Line 162 
Line 162 
         register FILE *f;          register FILE *f;
   
         if ((f = Fopen(_PATH_HELP, "r")) == NULL) {          if ((f = Fopen(_PATH_HELP, "r")) == NULL) {
                 perror(_PATH_HELP);                  warn(_PATH_HELP);
                 return(1);                  return(1);
         }          }
         while ((c = getc(f)) != EOF)          while ((c = getc(f)) != EOF)
                 putchar(c);                  putchar(c);
         Fclose(f);          (void)Fclose(f);
         return(0);          return(0);
 }  }
   
Line 187 
Line 187 
                 if ((cp = expand(*arglist)) == NOSTR)                  if ((cp = expand(*arglist)) == NOSTR)
                         return(1);                          return(1);
         if (chdir(cp) < 0) {          if (chdir(cp) < 0) {
                 perror(cp);                  warn(cp);
                 return(1);                  return(1);
         }          }
         return 0;          return(0);
 }  }
   
 int  int
Line 199 
Line 199 
 {  {
         int *msgvec = v;          int *msgvec = v;
         if (value("Replyall") == NOSTR)          if (value("Replyall") == NOSTR)
                 return (_respond(msgvec));                  return(_respond(msgvec));
         else          else
                 return (_Respond(msgvec));                  return(_Respond(msgvec));
 }  }
   
 /*  /*
Line 219 
Line 219 
         struct header head;          struct header head;
   
         if (msgvec[1] != 0) {          if (msgvec[1] != 0) {
                 printf("Sorry, can't reply to multiple messages at once\n");                  puts("Sorry, can't reply to multiple messages at once");
                 return(1);                  return(1);
         }          }
         mp = &message[msgvec[0] - 1];          mp = &message[msgvec[0] - 1];
Line 246 
Line 246 
                 np = cat(np, extract(rcv, GTO));                  np = cat(np, extract(rcv, GTO));
         else if (np == NIL) {          else if (np == NIL) {
                 if (replyto != NOSTR)                  if (replyto != NOSTR)
                         printf("Empty reply-to field -- replying to author\n");                          puts("Empty reply-to field -- replying to author");
                 np = extract(rcv, GTO);                  np = extract(rcv, GTO);
         }          }
         head.h_to = np;          head.h_to = np;
Line 279 
Line 279 
         char *newsubj;          char *newsubj;
   
         if (subj == NOSTR)          if (subj == NOSTR)
                 return NOSTR;                  return(NOSTR);
         if ((subj[0] == 'r' || subj[0] == 'R') &&          if ((subj[0] == 'r' || subj[0] == 'R') &&
             (subj[1] == 'e' || subj[1] == 'E') &&              (subj[1] == 'e' || subj[1] == 'E') &&
             subj[2] == ':')              subj[2] == ':')
                 return subj;                  return(subj);
         newsubj = salloc(strlen(subj) + 5);          newsubj = salloc(strlen(subj) + 5);
         strcpy(newsubj, "Re: ");          strcpy(newsubj, "Re: ");
         strcpy(newsubj + 4, subj);          strcpy(newsubj + 4, subj);
         return newsubj;          return(newsubj);
 }  }
   
 /*  /*
Line 303 
Line 303 
         register int *ip, mesg;          register int *ip, mesg;
   
         if (edit) {          if (edit) {
                 printf("Cannot \"preserve\" in edit mode\n");                  puts("Cannot \"preserve\" in edit mode");
                 return(1);                  return(1);
         }          }
         for (ip = msgvec; *ip != NULL; ip++) {          for (ip = msgvec; *ip != NULL; ip++) {
Line 385 
Line 385 
                 for (h = 0, s = 1; h < HSHSIZE; h++)                  for (h = 0, s = 1; h < HSHSIZE; h++)
                         for (vp = variables[h]; vp != NOVAR; vp = vp->v_link)                          for (vp = variables[h]; vp != NOVAR; vp = vp->v_link)
                                 s++;                                  s++;
                 ap = (char **) salloc(s * sizeof *ap);                  ap = (char **) salloc(s * sizeof(*ap));
                 for (h = 0, p = ap; h < HSHSIZE; h++)                  for (h = 0, p = ap; h < HSHSIZE; h++)
                         for (vp = variables[h]; vp != NOVAR; vp = vp->v_link)                          for (vp = variables[h]; vp != NOVAR; vp = vp->v_link)
                                 *p++ = vp->v_name;                                  *p++ = vp->v_name;
Line 407 
Line 407 
                 else                  else
                         cp++;                          cp++;
                 if (equal(varbuf, "")) {                  if (equal(varbuf, "")) {
                         printf("Non-null variable name required\n");                          puts("Non-null variable name required");
                         errs++;                          errs++;
                         continue;                          continue;
                 }                  }
Line 473 
Line 473 
                 for (h = 0, s = 1; h < HSHSIZE; h++)                  for (h = 0, s = 1; h < HSHSIZE; h++)
                         for (gh = groups[h]; gh != NOGRP; gh = gh->g_link)                          for (gh = groups[h]; gh != NOGRP; gh = gh->g_link)
                                 s++;                                  s++;
                 ap = (char **) salloc(s * sizeof *ap);                  ap = (char **) salloc(s * sizeof(*ap));
                 for (h = 0, p = ap; h < HSHSIZE; h++)                  for (h = 0, p = ap; h < HSHSIZE; h++)
                         for (gh = groups[h]; gh != NOGRP; gh = gh->g_link)                          for (gh = groups[h]; gh != NOGRP; gh = gh->g_link)
                                 *p++ = gh->g_name;                                  *p++ = gh->g_name;
Line 490 
Line 490 
         gname = *argv;          gname = *argv;
         h = hash(gname);          h = hash(gname);
         if ((gh = findgroup(gname)) == NOGRP) {          if ((gh = findgroup(gname)) == NOGRP) {
                 gh = (struct grouphead *) calloc(sizeof *gh, 1);                  gh = (struct grouphead *) calloc(sizeof(*gh), 1);
                 gh->g_name = vcopy(gname);                  gh->g_name = vcopy(gname);
                 gh->g_list = NOGE;                  gh->g_list = NOGE;
                 gh->g_link = groups[h];                  gh->g_link = groups[h];
Line 504 
Line 504 
          */           */
   
         for (ap = argv+1; *ap != NOSTR; ap++) {          for (ap = argv+1; *ap != NOSTR; ap++) {
                 gp = (struct group *) calloc(sizeof *gp, 1);                  gp = (struct group *) calloc(sizeof(*gp), 1);
                 gp->ge_name = vcopy(*ap);                  gp->ge_name = vcopy(*ap);
                 gp->ge_link = gh->g_list;                  gp->ge_link = gh->g_list;
                 gh->g_list = gp;                  gh->g_list = gp;
Line 549 
Line 549 
 null(v)  null(v)
         void *v;          void *v;
 {  {
         return 0;          return(0);
 }  }
   
 /*  /*
Line 563 
Line 563 
         char **argv = v;          char **argv = v;
   
         if (argv[0] == NOSTR) {          if (argv[0] == NOSTR) {
                 newfileinfo();                  newfileinfo(0);
                 return 0;                  return(0);
         }          }
         if (setfile(*argv) < 0)          if (setfile(*argv) < 0)
                 return 1;                  return(1);
         announce();          announce();
         return 0;          return(0);
 }  }
   
 /*  /*
Line 588 
Line 588 
                 if ((cp = expand(cp)) != NOSTR) {                  if ((cp = expand(cp)) != NOSTR) {
                         if (ap != argv)                          if (ap != argv)
                                 putchar(' ');                                  putchar(' ');
                         printf("%s", cp);                          fputs(cp, stdout);
                 }                  }
         }          }
         putchar('\n');          putchar('\n');
         return 0;          return(0);
 }  }
   
 int  int
Line 601 
Line 601 
 {  {
         int *msgvec = v;          int *msgvec = v;
         if (value("Replyall") == NOSTR)          if (value("Replyall") == NOSTR)
                 return (_Respond(msgvec));                  return(_Respond(msgvec));
         else          else
                 return (_respond(msgvec));                  return(_respond(msgvec));
 }  }
   
 /*  /*
Line 630 
Line 630 
                 head.h_to = cat(head.h_to, extract(cp, GTO));                  head.h_to = cat(head.h_to, extract(cp, GTO));
         }          }
         if (head.h_to == NIL)          if (head.h_to == NIL)
                 return 0;                  return(0);
         mp = &message[msgvec[0] - 1];          mp = &message[msgvec[0] - 1];
         if ((head.h_subject = hfield("subject", mp)) == NOSTR)          if ((head.h_subject = hfield("subject", mp)) == NOSTR)
                 head.h_subject = hfield("subj", mp);                  head.h_subject = hfield("subj", mp);
Line 639 
Line 639 
         head.h_bcc = NIL;          head.h_bcc = NIL;
         head.h_smopts = NIL;          head.h_smopts = NIL;
         mail1(&head, 1);          mail1(&head, 1);
         return 0;          return(0);
 }  }
   
 /*  /*
Line 654 
Line 654 
         register char *cp;          register char *cp;
   
         if (cond != CANY) {          if (cond != CANY) {
                 printf("Illegal nested \"if\"\n");                  puts("Illegal nested \"if\"");
                 return(1);                  return(1);
         }          }
         cond = CANY;          cond = CANY;
Line 686 
Line 686 
   
         switch (cond) {          switch (cond) {
         case CANY:          case CANY:
                 printf("\"Else\" without matching \"if\"\n");                  puts("\"Else\" without matching \"if\"");
                 return(1);                  return(1);
   
         case CSEND:          case CSEND:
Line 698 
Line 698 
                 break;                  break;
   
         default:          default:
                 printf("Mail's idea of conditions is screwed up\n");                  puts("mail's idea of conditions is screwed up");
                 cond = CANY;                  cond = CANY;
                 break;                  break;
         }          }
Line 714 
Line 714 
 {  {
   
         if (cond == CANY) {          if (cond == CANY) {
                 printf("\"Endif\" without matching \"if\"\n");                  puts("\"Endif\" without matching \"if\"");
                 return(1);                  return(1);
         }          }
         cond = CANY;          cond = CANY;
Line 738 
Line 738 
                         return(0);                          return(0);
                 for (ap = altnames; *ap; ap++)                  for (ap = altnames; *ap; ap++)
                         printf("%s ", *ap);                          printf("%s ", *ap);
                 printf("\n");                  putchar('\n');
                 return(0);                  return(0);
         }          }
         if (altnames != 0)          if (altnames != 0)
                 free((char *) altnames);                  free((char *) altnames);
         altnames = (char **) calloc((unsigned) c, sizeof (char *));          altnames = (char **) calloc((unsigned) c, sizeof(char *));
         for (ap = namelist, ap2 = altnames; *ap; ap++, ap2++) {          for (ap = namelist, ap2 = altnames; *ap; ap++, ap2++) {
                 cp = (char *) calloc((unsigned) strlen(*ap) + 1, sizeof (char));                  cp = (char *) calloc((unsigned) strlen(*ap) + 1, sizeof(char));
                 strcpy(cp, *ap);                  strcpy(cp, *ap);
                 *ap2 = cp;                  *ap2 = cp;
         }          }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5