[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.16 and 1.17

version 1.16, 2001/11/20 20:50:00 version 1.17, 2001/11/21 15:26:39
Line 36 
Line 36 
   
 #ifndef lint  #ifndef lint
 #if 0  #if 0
 static char sccsid[] = "@(#)cmd3.c      8.2 (Berkeley) 4/20/95";  static const char sccsid[] = "@(#)cmd3.c        8.2 (Berkeley) 4/20/95";
 #else  #else
 static char rcsid[] = "$OpenBSD$";  static const char rcsid[] = "$OpenBSD$";
 #endif  #endif
 #endif /* not lint */  #endif /* not lint */
   
Line 50 
Line 50 
  *   *
  * Still more user commands.   * Still more user commands.
  */   */
 static int diction __P((const void *, const void *));  static int diction(const void *, const void *);
   
 /*  /*
  * Process a shell escape by saving signals, ignoring signals,   * Process a shell escape by saving signals, ignoring signals,
  * and forking a sh -c   * and forking a sh -c
  */   */
 int  int
 shell(v)  shell(void *v)
         void *v;  
 {  {
         char *str = v;          char *str = v;
         char *shell;          char *shell;
Line 83 
Line 82 
  */   */
 /*ARGSUSED*/  /*ARGSUSED*/
 int  int
 dosh(v)  dosh(void *v)
         void *v;  
 {  {
         char *shell;          char *shell;
         struct sigaction oact;          struct sigaction oact;
Line 104 
Line 102 
  * last issued command where possible.   * last issued command where possible.
  */   */
 int  int
 bangexp(str, strsize)  bangexp(char *str, size_t strsize)
         char *str;  
         size_t strsize;  
 {  {
         char bangbuf[BUFSIZ];          char bangbuf[BUFSIZ];
         static char lastbang[BUFSIZ];          static char lastbang[BUFSIZ];
Line 124 
Line 120 
                                 return(-1);                                  return(-1);
                         }                          }
                         changed++;                          changed++;
                         strncpy(cp2, lastbang, sizeof(bangbuf) - (cp2 - bangbuf) - 1);                          strlcpy(cp2, lastbang, sizeof(bangbuf) - (cp2 - bangbuf));
                         bangbuf[sizeof(bangbuf) - 1] = '\0';  
                         cp2 += strlen(lastbang);                          cp2 += strlen(lastbang);
                         n -= strlen(lastbang);                          n -= strlen(lastbang);
                         cp++;                          cp++;
Line 147 
Line 142 
                 (void)printf("!%s\n", bangbuf);                  (void)printf("!%s\n", bangbuf);
                 (void)fflush(stdout);                  (void)fflush(stdout);
         }          }
         (void)strncpy(str, bangbuf, strsize - 1);          (void)strlcpy(str, bangbuf, strsize);
         str[strsize - 1]  = '\0';          (void)strlcpy(lastbang, bangbuf, sizeof(lastbang));
         (void)strncpy(lastbang, bangbuf, sizeof(lastbang) - 1);  
         lastbang[sizeof(lastbang) - 1] = '\0';  
         return(0);          return(0);
 }  }
   
Line 158 
Line 151 
  * Print out a nice help message from some file or another.   * Print out a nice help message from some file or another.
  */   */
 int  int
 help(v)  help(void *v)
         void *v;  
 {  {
   
         (void)run_command(value("PAGER"), 0, -1, -1, _PATH_HELP, NULL);          (void)run_command(value("PAGER"), 0, -1, -1, _PATH_HELP, NULL);
Line 170 
Line 162 
  * Change user's working directory.   * Change user's working directory.
  */   */
 int  int
 schdir(v)  schdir(void *v)
         void *v;  
 {  {
         char **arglist = v;          char **arglist = v;
         char *cp;          char *cp;
Line 192 
Line 183 
 }  }
   
 int  int
 respond(v)  respond(void *v)
         void *v;  
 {  {
         int *msgvec = v;          int *msgvec = v;
   
         if (value("Replyall") == NULL)          if (value("Replyall") == NULL)
                 return(_respond(msgvec));                  return(_respond(msgvec));
         else          else
Line 230 
Line 221 
         else if ((cp = skin(hfield("to", mp))) != NULL)          else if ((cp = skin(hfield("to", mp))) != NULL)
                 np = extract(cp, GTO);                  np = extract(cp, GTO);
         else          else
                 np = NIL;                  np = NULL;
         np = elide(np);          np = elide(np);
         /*          /*
          * Delete my name from the reply list,           * Delete my name from the reply list,
Line 240 
Line 231 
         if (altnames)          if (altnames)
                 for (ap = altnames; *ap; ap++)                  for (ap = altnames; *ap; ap++)
                         np = delname(np, *ap);                          np = delname(np, *ap);
         if (np != NIL && replyto == NULL)          if (np != NULL && replyto == NULL)
                 np = cat(np, extract(rcv, GTO));                  np = cat(np, extract(rcv, GTO));
         else if (np == NIL) {          else if (np == NULL) {
                 if (replyto != NULL)                  if (replyto != NULL)
                         puts("Empty reply-to field -- replying to author");                          puts("Empty reply-to field -- replying to author");
                 np = extract(rcv, GTO);                  np = extract(rcv, GTO);
Line 259 
Line 250 
                                 np = delname(np, *ap);                                  np = delname(np, *ap);
                 head.h_cc = np;                  head.h_cc = np;
         } else          } else
                 head.h_cc = NIL;                  head.h_cc = NULL;
         head.h_bcc = NIL;          head.h_bcc = NULL;
         head.h_smopts = NIL;          head.h_smopts = NULL;
         mail1(&head, 1);          mail1(&head, 1);
         return(0);          return(0);
 }  }
Line 271 
Line 262 
  * it does not already.   * it does not already.
  */   */
 char *  char *
 reedit(subj)  reedit(char *subj)
         char *subj;  
 {  {
         char *newsubj;          char *newsubj;
   
Line 293 
Line 283 
  * mailbox as unread.   * mailbox as unread.
  */   */
 int  int
 marknew(v)  marknew(void *v)
         void *v;  
 {  {
         int *msgvec = v;          int *msgvec = v;
         int *ip;          int *ip;
Line 312 
Line 301 
  * back to the system mailbox.   * back to the system mailbox.
  */   */
 int  int
 preserve(v)  preserve(void *v)
         void *v;  
 {  {
         int *msgvec = v;          int *msgvec = v;
         int *ip, mesg;          int *ip, mesg;
Line 337 
Line 325 
  * Mark all given messages as unread.   * Mark all given messages as unread.
  */   */
 int  int
 unread(v)  unread(void *v)
         void *v;  
 {  {
         int *msgvec = v;          int *msgvec = v;
         int *ip;          int *ip;
Line 355 
Line 342 
  * Print the size of each message.   * Print the size of each message.
  */   */
 int  int
 messize(v)  messize(void *v)
         void *v;  
 {  {
         int *msgvec = v;          int *msgvec = v;
         struct message *mp;          struct message *mp;
Line 375 
Line 361 
  * by returning an error.   * by returning an error.
  */   */
 int  int
 rexit(v)  rexit(void *v)
         void *v;  
 {  {
   
         if (sourcing)          if (sourcing)
                 return(1);                  return(1);
         exit(0);          exit(0);
Line 389 
Line 375 
  * of csh.   * of csh.
  */   */
 int  int
 set(v)  set(void *v)
         void *v;  
 {  {
         char **arglist = v;          char **arglist = v;
         struct var *vp;          struct var *vp;
Line 400 
Line 385 
   
         if (*arglist == NULL) {          if (*arglist == NULL) {
                 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 != NULL; 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 != NULL; vp = vp->v_link)
                                 *p++ = vp->v_name;                                  *p++ = vp->v_name;
                 *p = NULL;                  *p = NULL;
                 sort(ap);                  sort(ap);
Line 437 
Line 422 
  * Unset a bunch of variable values.   * Unset a bunch of variable values.
  */   */
 int  int
 unset(v)  unset(void *v)
         void *v;  
 {  {
         char **arglist = v;          char **arglist = v;
         struct var *vp, *vp2;          struct var *vp, *vp2;
Line 447 
Line 431 
   
         errs = 0;          errs = 0;
         for (ap = arglist; *ap != NULL; ap++) {          for (ap = arglist; *ap != NULL; ap++) {
                 if ((vp2 = lookup(*ap)) == NOVAR) {                  if ((vp2 = lookup(*ap)) == NULL) {
                         if (!sourcing) {                          if (!sourcing) {
                                 printf("\"%s\": undefined variable\n", *ap);                                  printf("\"%s\": undefined variable\n", *ap);
                                 errs++;                                  errs++;
Line 476 
Line 460 
  * Put add users to a group.   * Put add users to a group.
  */   */
 int  int
 group(v)  group(void *v)
         void *v;  
 {  {
         char **argv = v;          char **argv = v;
         struct grouphead *gh;          struct grouphead *gh;
Line 487 
Line 470 
   
         if (*argv == NULL) {          if (*argv == NULL) {
                 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 != NULL; 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 != NULL; gh = gh->g_link)
                                 *p++ = gh->g_name;                                  *p++ = gh->g_name;
                 *p = NULL;                  *p = NULL;
                 sort(ap);                  sort(ap);
Line 505 
Line 488 
         }          }
         gname = *argv;          gname = *argv;
         h = hash(gname);          h = hash(gname);
         if ((gh = findgroup(gname)) == NOGRP) {          if ((gh = findgroup(gname)) == NULL) {
                 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 = NULL;
                 gh->g_link = groups[h];                  gh->g_link = groups[h];
                 groups[h] = gh;                  groups[h] = gh;
         }          }
Line 533 
Line 516 
  * order.   * order.
  */   */
 void  void
 sort(list)  sort(char **list)
         char **list;  
 {  {
         char **ap;          char **ap;
   
Line 550 
Line 532 
  * qsort.   * qsort.
  */   */
 static int  static int
 diction(a, b)  diction(const void *a, const void *b)
         const void *a, *b;  
 {  {
   
         return(strcmp(*(char **)a, *(char **)b));          return(strcmp(*(char **)a, *(char **)b));
 }  }
   
 /*  /*
  * The do nothing command for comments.   * The do nothing command for comments.
  */   */
   
 /*ARGSUSED*/  /*ARGSUSED*/
 int  int
 null(v)  null(void *v)
         void *v;  
 {  {
   
         return(0);          return(0);
 }  }
   
Line 573 
Line 554 
  * the current file.   * the current file.
  */   */
 int  int
 file(v)  file(void *v)
         void *v;  
 {  {
         char **argv = v;          char **argv = v;
   
Line 593 
Line 573 
  * Expand file names like echo   * Expand file names like echo
  */   */
 int  int
 echo(v)  echo(void *v)
         void *v;  
 {  {
         char **argv = v;          char **argv = v;
         char **ap, *cp;          char **ap, *cp;
Line 612 
Line 591 
 }  }
   
 int  int
 Respond(v)  Respond(void *v)
         void *v;  
 {  {
         int *msgvec = v;          int *msgvec = v;
   
         if (value("Replyall") == NULL)          if (value("Replyall") == NULL)
                 return(_Respond(msgvec));                  return(_Respond(msgvec));
         else          else
Line 628 
Line 607 
  * reply.   * reply.
  */   */
 int  int
 _Respond(msgvec)  _Respond(int *msgvec)
         int msgvec[];  
 {  {
         struct header head;          struct header head;
         struct message *mp;          struct message *mp;
         int *ap;          int *ap;
         char *cp;          char *cp;
   
         head.h_to = NIL;          head.h_to = NULL;
         for (ap = msgvec; *ap != 0; ap++) {          for (ap = msgvec; *ap != 0; ap++) {
                 mp = &message[*ap - 1];                  mp = &message[*ap - 1];
                 touch(mp);                  touch(mp);
Line 645 
Line 623 
                         cp = skin(nameof(mp, 2));                          cp = skin(nameof(mp, 2));
                 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 == NULL)
                 return(0);                  return(0);
         mp = &message[msgvec[0] - 1];          mp = &message[msgvec[0] - 1];
         if ((head.h_subject = hfield("subject", mp)) == NULL)          if ((head.h_subject = hfield("subject", mp)) == NULL)
                 head.h_subject = hfield("subj", mp);                  head.h_subject = hfield("subj", mp);
         head.h_subject = reedit(head.h_subject);          head.h_subject = reedit(head.h_subject);
         head.h_cc = NIL;          head.h_cc = NULL;
         head.h_bcc = NIL;          head.h_bcc = NULL;
         head.h_smopts = NIL;          head.h_smopts = NULL;
         mail1(&head, 1);          mail1(&head, 1);
         return(0);          return(0);
 }  }
Line 663 
Line 641 
  * .mailrc and do some things if sending, others if receiving.   * .mailrc and do some things if sending, others if receiving.
  */   */
 int  int
 ifcmd(v)  ifcmd(void *v)
         void *v;  
 {  {
         char **argv = v;          char **argv = v;
         char *cp;          char *cp;
Line 696 
Line 673 
  * flip over the conditional flag.   * flip over the conditional flag.
  */   */
 int  int
 elsecmd(v)  elsecmd(void *v)
         void *v;  
 {  {
   
         switch (cond) {          switch (cond) {
Line 725 
Line 701 
  * End of if statement.  Just set cond back to anything.   * End of if statement.  Just set cond back to anything.
  */   */
 int  int
 endifcmd(v)  endifcmd(void *v)
         void *v;  
 {  {
   
         if (cond == CANY) {          if (cond == CANY) {
Line 741 
Line 716 
  * Set the list of alternate names.   * Set the list of alternate names.
  */   */
 int  int
 alternates(v)  alternates(void *v)
         void *v;  
 {  {
         char **namelist = v;          char **namelist = v;
         char **ap, **ap2, *cp;          char **ap, **ap2, *cp;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17