mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-03 08:48:14 +02:00
Bash-5.3-alpha release
This commit is contained in:
+42
-46
@@ -1,6 +1,6 @@
|
||||
/* mailcheck.c -- The check is in the mail... */
|
||||
|
||||
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -38,12 +38,16 @@
|
||||
#include "mailcheck.h"
|
||||
#include <tilde/tilde.h>
|
||||
|
||||
#if defined (READLINE)
|
||||
# include <readline/readline.h>
|
||||
#endif
|
||||
|
||||
/* Values for flags word in struct _fileinfo */
|
||||
#define MBOX_INITIALIZED 0x01
|
||||
|
||||
extern time_t shell_start_time;
|
||||
|
||||
extern int mailstat PARAMS((const char *, struct stat *));
|
||||
extern int mailstat (const char *, struct stat *);
|
||||
|
||||
typedef struct _fileinfo {
|
||||
char *name;
|
||||
@@ -65,34 +69,38 @@ static time_t last_time_mail_checked = 0;
|
||||
|
||||
/* Non-zero means warn if a mail file has been read since last checked. */
|
||||
int mail_warning;
|
||||
static int find_mail_file (const char *);
|
||||
static void init_mail_file (int);
|
||||
static void update_mail_file (int);
|
||||
static int add_mail_file (char *, const char *);
|
||||
|
||||
static int find_mail_file PARAMS((char *));
|
||||
static void init_mail_file PARAMS((int));
|
||||
static void update_mail_file PARAMS((int));
|
||||
static int add_mail_file PARAMS((char *, char *));
|
||||
static FILEINFO *alloc_mail_file (char *, const char *);
|
||||
static void dispose_mail_file (FILEINFO *);
|
||||
|
||||
static FILEINFO *alloc_mail_file PARAMS((char *, char *));
|
||||
static void dispose_mail_file PARAMS((FILEINFO *));
|
||||
static int file_mod_date_changed (int);
|
||||
static int file_access_date_changed (int);
|
||||
static int file_has_grown (int);
|
||||
|
||||
static int file_mod_date_changed PARAMS((int));
|
||||
static int file_access_date_changed PARAMS((int));
|
||||
static int file_has_grown PARAMS((int));
|
||||
|
||||
static char *parse_mailpath_spec PARAMS((char *));
|
||||
static char *parse_mailpath_spec (char *);
|
||||
|
||||
/* Returns non-zero if it is time to check mail. */
|
||||
int
|
||||
time_to_check_mail ()
|
||||
time_to_check_mail (void)
|
||||
{
|
||||
char *temp;
|
||||
time_t now;
|
||||
intmax_t seconds;
|
||||
|
||||
#if defined (READLINE)
|
||||
if (RL_ISSTATE (RL_STATE_COMPLETING|RL_STATE_DISPATCHING))
|
||||
return (0);
|
||||
#endif
|
||||
|
||||
temp = get_string_value ("MAILCHECK");
|
||||
|
||||
/* Negative number, or non-numbers (such as empty string) cause no
|
||||
checking to take place. */
|
||||
if (temp == 0 || legal_number (temp, &seconds) == 0 || seconds < 0)
|
||||
if (temp == 0 || valid_number (temp, &seconds) == 0 || seconds < 0)
|
||||
return (0);
|
||||
|
||||
now = NOW;
|
||||
@@ -104,7 +112,7 @@ time_to_check_mail ()
|
||||
/* Okay, we have checked the mail. Perhaps I should make this function
|
||||
go away. */
|
||||
void
|
||||
reset_mail_timer ()
|
||||
reset_mail_timer (void)
|
||||
{
|
||||
last_time_mail_checked = NOW;
|
||||
}
|
||||
@@ -112,8 +120,7 @@ reset_mail_timer ()
|
||||
/* Locate a file in the list. Return index of
|
||||
entry, or -1 if not found. */
|
||||
static int
|
||||
find_mail_file (file)
|
||||
char *file;
|
||||
find_mail_file (const char *file)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -144,8 +151,7 @@ find_mail_file (file)
|
||||
while (0)
|
||||
|
||||
static void
|
||||
init_mail_file (i)
|
||||
int i;
|
||||
init_mail_file (int i)
|
||||
{
|
||||
mailfiles[i]->access_time = mailfiles[i]->mod_time = last_time_mail_checked ? last_time_mail_checked : shell_start_time;
|
||||
mailfiles[i]->file_size = 0;
|
||||
@@ -153,8 +159,7 @@ init_mail_file (i)
|
||||
}
|
||||
|
||||
static void
|
||||
update_mail_file (i)
|
||||
int i;
|
||||
update_mail_file (int i)
|
||||
{
|
||||
char *file;
|
||||
struct stat finfo;
|
||||
@@ -169,8 +174,7 @@ update_mail_file (i)
|
||||
/* Add this file to the list of remembered files and return its index
|
||||
in the list of mail files. */
|
||||
static int
|
||||
add_mail_file (file, msg)
|
||||
char *file, *msg;
|
||||
add_mail_file (char *file, const char *msg)
|
||||
{
|
||||
struct stat finfo;
|
||||
char *filename;
|
||||
@@ -199,7 +203,7 @@ add_mail_file (file, msg)
|
||||
|
||||
/* Reset the existing mail files access and modification times to zero. */
|
||||
void
|
||||
reset_mail_files ()
|
||||
reset_mail_files (void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -208,8 +212,7 @@ reset_mail_files ()
|
||||
}
|
||||
|
||||
static FILEINFO *
|
||||
alloc_mail_file (filename, msg)
|
||||
char *filename, *msg;
|
||||
alloc_mail_file (char *filename, const char *msg)
|
||||
{
|
||||
FILEINFO *mf;
|
||||
|
||||
@@ -222,8 +225,7 @@ alloc_mail_file (filename, msg)
|
||||
}
|
||||
|
||||
static void
|
||||
dispose_mail_file (mf)
|
||||
FILEINFO *mf;
|
||||
dispose_mail_file (FILEINFO *mf)
|
||||
{
|
||||
free (mf->name);
|
||||
FREE (mf->msg);
|
||||
@@ -232,7 +234,7 @@ dispose_mail_file (mf)
|
||||
|
||||
/* Free the information that we have about the remembered mail files. */
|
||||
void
|
||||
free_mail_files ()
|
||||
free_mail_files (void)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -247,7 +249,7 @@ free_mail_files ()
|
||||
}
|
||||
|
||||
void
|
||||
init_mail_dates ()
|
||||
init_mail_dates (void)
|
||||
{
|
||||
if (mailfiles == 0)
|
||||
remember_mail_dates ();
|
||||
@@ -257,8 +259,7 @@ init_mail_dates ()
|
||||
accessed since modified. If the size has dropped to zero, reset
|
||||
the cached mail file info. */
|
||||
static int
|
||||
file_mod_date_changed (i)
|
||||
int i;
|
||||
file_mod_date_changed (int i)
|
||||
{
|
||||
time_t mtime;
|
||||
struct stat finfo;
|
||||
@@ -281,8 +282,7 @@ file_mod_date_changed (i)
|
||||
|
||||
/* Return non-zero if FILE's access date has changed. */
|
||||
static int
|
||||
file_access_date_changed (i)
|
||||
int i;
|
||||
file_access_date_changed (int i)
|
||||
{
|
||||
time_t atime;
|
||||
struct stat finfo;
|
||||
@@ -302,8 +302,7 @@ file_access_date_changed (i)
|
||||
|
||||
/* Return non-zero if FILE's size has increased. */
|
||||
static int
|
||||
file_has_grown (i)
|
||||
int i;
|
||||
file_has_grown (int i)
|
||||
{
|
||||
off_t size;
|
||||
struct stat finfo;
|
||||
@@ -319,8 +318,7 @@ file_has_grown (i)
|
||||
the first unquoted `?' or `%' to the end of the string. This is the
|
||||
message to be printed when the file contents change. */
|
||||
static char *
|
||||
parse_mailpath_spec (str)
|
||||
char *str;
|
||||
parse_mailpath_spec (char *str)
|
||||
{
|
||||
char *s;
|
||||
int pass_next;
|
||||
@@ -344,7 +342,7 @@ parse_mailpath_spec (str)
|
||||
}
|
||||
|
||||
char *
|
||||
make_default_mailpath ()
|
||||
make_default_mailpath (void)
|
||||
{
|
||||
#if defined (DEFAULT_MAIL_DIRECTORY)
|
||||
char *mp;
|
||||
@@ -365,7 +363,7 @@ make_default_mailpath ()
|
||||
default value, which we randomly concoct from using Unix. */
|
||||
|
||||
void
|
||||
remember_mail_dates ()
|
||||
remember_mail_dates (void)
|
||||
{
|
||||
char *mailpaths;
|
||||
char *mailfile, *mp;
|
||||
@@ -414,15 +412,13 @@ remember_mail_dates ()
|
||||
mail file has been accessed since the last time we remembered, then
|
||||
the message "The mail in <mailfile> has been read" is printed. */
|
||||
void
|
||||
check_mail ()
|
||||
check_mail (void)
|
||||
{
|
||||
char *current_mail_file, *message;
|
||||
int i, use_user_notification;
|
||||
char *dollar_underscore, *temp;
|
||||
|
||||
dollar_underscore = get_string_value ("_");
|
||||
if (dollar_underscore)
|
||||
dollar_underscore = savestring (dollar_underscore);
|
||||
dollar_underscore = save_lastarg ();
|
||||
|
||||
for (i = 0; i < mailfiles_count; i++)
|
||||
{
|
||||
@@ -483,7 +479,7 @@ check_mail ()
|
||||
|
||||
if (dollar_underscore)
|
||||
{
|
||||
bind_variable ("_", dollar_underscore, 0);
|
||||
bind_lastarg (dollar_underscore);
|
||||
free (dollar_underscore);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user