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

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

version 1.4, 1997/03/29 03:01:46 version 1.5, 1997/05/30 08:51:39
Line 71 
Line 71 
         FILE *mestmp;          FILE *mestmp;
         off_t offset;          off_t offset;
         int maybe, inhead;          int maybe, inhead;
         char linebuf[LINESIZE];          char linebuf[LINESIZE], pathbuf[PATHSIZE];
   
         /* Get temporary file. */          /* Get temporary file. */
         (void)sprintf(linebuf, "%s/mail.XXXXXXXXXX", tmpdir);          (void)snprintf(pathbuf, sizeof pathbuf, "%s/mail.XXXXXXXXXX", tmpdir);
         if ((c = mkstemp(linebuf)) == -1 ||          if ((c = mkstemp(pathbuf)) == -1 ||
             (mestmp = Fdopen(c, "r+")) == NULL) {              (mestmp = Fdopen(c, "r+")) == NULL) {
                 (void)fprintf(stderr, "mail: can't open %s\n", linebuf);                  (void)fprintf(stderr, "mail: can't open %s\n", pathbuf);
                 exit(1);                  exit(1);
         }          }
         (void)unlink(linebuf);          (void)unlink(pathbuf);
   
         msgCount = 0;          msgCount = 0;
         maybe = 1;          maybe = 1;
Line 336 
Line 336 
          */           */
         switch (*name) {          switch (*name) {
         case '%':          case '%':
                 findmail(name[1] ? name + 1 : myname, xname);                  findmail(name[1] ? name + 1 : myname, xname, sizeof xname);
                 return savestr(xname);                  return savestr(xname);
         case '#':          case '#':
                 if (name[1] != 0)                  if (name[1] != 0)
Line 351 
Line 351 
                         name = "~/mbox";                          name = "~/mbox";
                 /* fall through */                  /* fall through */
         }          }
         if (name[0] == '+' && getfold(cmdbuf) >= 0) {          if (name[0] == '+' && getfold(cmdbuf, sizeof cmdbuf) >= 0) {
                 sprintf(xname, "%s/%s", cmdbuf, name + 1);                  snprintf(xname, sizeof xname, "%s/%s", cmdbuf, name + 1);
                 name = savestr(xname);                  name = savestr(xname);
         }          }
         /* catch the most common shell meta character */          /* catch the most common shell meta character */
         if (name[0] == '~' && (name[1] == '/' || name[1] == '\0')) {          if (name[0] == '~' && (name[1] == '/' || name[1] == '\0')) {
                 sprintf(xname, "%s%s", homedir, name + 1);                  snprintf(xname, sizeof xname, "%s%s", homedir, name + 1);
                 name = savestr(xname);                  name = savestr(xname);
         }          }
         if (!anyof(name, "~{[*?$`'\"\\"))          if (!anyof(name, "~{[*?$`'\"\\"))
Line 366 
Line 366 
                 perror("pipe");                  perror("pipe");
                 return name;                  return name;
         }          }
         sprintf(cmdbuf, "echo %s", name);          snprintf(cmdbuf, sizeof cmdbuf, "echo %s", name);
         if ((shell = value("SHELL")) == NOSTR)          if ((shell = value("SHELL")) == NOSTR)
                 shell = _PATH_CSHELL;                  shell = _PATH_CSHELL;
         pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NOSTR);          pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NOSTR);
Line 409 
Line 409 
  * Determine the current folder directory name.   * Determine the current folder directory name.
  */   */
 int  int
 getfold(name)  getfold(name, namelen)
         char *name;          char *name;
           int namelen;
 {  {
         char *folder;          char *folder;
   
         if ((folder = value("folder")) == NOSTR)          if ((folder = value("folder")) == NOSTR)
                 return (-1);                  return (-1);
         if (*folder == '/')          if (*folder == '/') {
                 strcpy(name, folder);                  strncpy(name, folder, namelen-1);
         else                  name[namelen-1] = '\0';
                 sprintf(name, "%s/%s", homedir, folder);          } else
                   snprintf(name, namelen, "%s/%s", homedir, folder);
         return (0);          return (0);
 }  }
   
Line 436 
Line 438 
         else if (*cp != '/') {          else if (*cp != '/') {
                 char buf[PATHSIZE];                  char buf[PATHSIZE];
   
                 (void) sprintf(buf, "~/%s", cp);                  (void) snprintf(buf, sizeof buf, "~/%s", cp);
                 cp = expand(buf);                  cp = expand(buf);
         }          }
         return cp;          return cp;

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