Imported from ../bash-2.04.tar.gz.
[platform/upstream/bash.git] / mailcheck.c
index 8d3f833..a4d3670 100644 (file)
@@ -6,7 +6,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
 
 Bash is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
 
 Bash is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
 version.
 
 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
 version.
 
 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,14 +16,16 @@ for more details.
 
 You should have received a copy of the GNU General Public License along
 with Bash; see the file COPYING.  If not, write to the Free Software
 
 You should have received a copy of the GNU General Public License along
 with Bash; see the file COPYING.  If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #include "config.h"
 
 #include <stdio.h>
 #include "bashtypes.h"
 #include "posixstat.h"
 
 #include "config.h"
 
 #include <stdio.h>
 #include "bashtypes.h"
 #include "posixstat.h"
-#include <sys/param.h>
+#ifndef _MINIX
+#  include <sys/param.h>
+#endif
 #if defined (HAVE_UNISTD_H)
 #  include <unistd.h>
 #endif
 #if defined (HAVE_UNISTD_H)
 #  include <unistd.h>
 #endif
@@ -44,7 +46,7 @@ typedef struct {
   char *msg;
   time_t access_time;
   time_t mod_time;
   char *msg;
   time_t access_time;
   time_t mod_time;
-  long file_size;
+  off_t file_size;
 } FILEINFO;
 
 /* The list of remembered mail files. */
 } FILEINFO;
 
 /* The list of remembered mail files. */
@@ -117,7 +119,7 @@ find_mail_file (file)
   do \
     { \
       mailfiles[i]->access_time = mailfiles[i]->mod_time = 0; \
   do \
     { \
       mailfiles[i]->access_time = mailfiles[i]->mod_time = 0; \
-      mailfiles[i]->file_size = 0L; \
+      mailfiles[i]->file_size = 0; \
     } \
   while (0)
 
     } \
   while (0)
 
@@ -150,14 +152,14 @@ add_mail_file (file, msg)
   int i;
 
   filename = full_pathname (file);
   int i;
 
   filename = full_pathname (file);
-  i = find_mail_file (file);
+  i = find_mail_file (filename);
   if (i >= 0)
     {
       if (stat (filename, &finfo) == 0)
        {
          mailfiles[i]->mod_time = finfo.st_mtime;
          mailfiles[i]->access_time = finfo.st_atime;
   if (i >= 0)
     {
       if (stat (filename, &finfo) == 0)
        {
          mailfiles[i]->mod_time = finfo.st_mtime;
          mailfiles[i]->access_time = finfo.st_atime;
-         mailfiles[i]->file_size = (long)finfo.st_size;
+         mailfiles[i]->file_size = finfo.st_size;
        }
       free (filename);
       return i;
        }
       free (filename);
       return i;
@@ -248,7 +250,7 @@ static int
 file_has_grown (i)
      int i;
 {
 file_has_grown (i)
      int i;
 {
-  long size;
+  off_t size;
   struct stat finfo;
   char *file;
 
   struct stat finfo;
   char *file;
 
@@ -291,6 +293,7 @@ make_default_mailpath ()
 {
   char *mp;
 
 {
   char *mp;
 
+  get_current_user_info ();
   mp = xmalloc (2 + sizeof (DEFAULT_MAIL_DIRECTORY) + strlen (current_user.user_name));
   strcpy (mp, DEFAULT_MAIL_DIRECTORY);
   mp[sizeof(DEFAULT_MAIL_DIRECTORY) - 1] = '/';
   mp = xmalloc (2 + sizeof (DEFAULT_MAIL_DIRECTORY) + strlen (current_user.user_name));
   strcpy (mp, DEFAULT_MAIL_DIRECTORY);
   mp[sizeof(DEFAULT_MAIL_DIRECTORY) - 1] = '/';