taylor@hpldat.UUCP (Dave Taylor) (05/03/87)
This is Elm Patch Kit #4 of 8 and contains patches for:
src/aliaslib.c src/domains.c src/fileio.c src/return_addr.c
src/addr_utils.c src/input_utils.c src/mailtime.c src/encode.c
src/leavembox.c src/opt_utils.c
Please feed this directly to ``patch''.
Index: src/aliaslib.c
***************
*** 79,82
! dprint2(6, "expand_system(%s, show-errors=%s)\n", buffer,
! onoff(show_errors));
findnode(buffer, show_errors);
--- 79,82 -----
! dprint(6, (debugfile, "expand_system(%s, show-errors=%s)\n", buffer,
! onoff(show_errors)));
findnode(buffer, show_errors);
***************
*** 108,111
if (! valid_name(word)) {
! dprint2(3, "Encountered illegal address %s (%s)\n",
! word, "expand_group");
error1("%s is an illegal address!", word);
--- 108,111 -----
if (! valid_name(word)) {
! dprint(3, (debugfile, "Encountered illegal address %s in %s\n",
! word, "expand_group"));
error1("%s is an illegal address!", word);
***************
*** 137,139
if (strlen(word) > 20) {
! dprint2(3, "Too long alias name entered [%s] (%s)\n", word, "find");
error1("Bad alias name: %s. Too long.\n", word);
--- 137,139 -----
if (strlen(word) > 20) {
! dprint(3, (debugfile, "Overly long alias name entered: %s\n", word));
error1("Bad alias name: %s. Too long.\n", word);
Index: src/domains.c
***************
*** 48,51
if ((domainfd = fopen(domains, "r")) == NULL) {
! dprint1(1, "Can't open file %s as domains file (open_domain_file)\n",
! domains);
}
--- 48,52 -----
if ((domainfd = fopen(domains, "r")) == NULL) {
! dprint(1, (debugfile,
! "Can't open file %s as domains file (open_domain_file)\n",
! domains));
}
***************
*** 52,56
else {
! dprint1(2,
! "\nOpened '%s' as the domain database. (open_domain_file)\n\n",
! domains);
}
--- 53,56 -----
else {
! dprint(2, (debugfile,
! "\nOpened '%s' as the domain database\n\n", domains));
}
***************
*** 76,78
else { /* invalid format - not "user@host.domain" */
! dprint1(3,
"Invalid format for domain expansion: %s (expand_domain)\n",
--- 76,78 -----
else { /* invalid format - not "user@host.domain" */
! dprint(3, (debugfile,
"Invalid format for domain expansion: %s (expand_domain)\n",
***************
*** 78,80
"Invalid format for domain expansion: %s (expand_domain)\n",
! buffer);
return(NULL);
--- 78,80 -----
"Invalid format for domain expansion: %s (expand_domain)\n",
! buffer));
return(NULL);
***************
*** 200,204
else {
! dprint1(2,"Domain info for %s from file broken into THREE fields!!\n",
! domain);
! dprint3(2, "-> %s\n-> %s\n-> %s\n", field1, field2, field3);
error1("Warning: domain %s uses a defunct field!!", domain);
--- 200,207 -----
else {
! dprint(2, (debugfile,
! "Domain info for %s from file broken into THREE fields!!\n",
! domain));
! dprint(2, (debugfile,
! "-> %s\n-> %s\n-> %s\n", field1, field2, field3));
! dprint(2, (debugfile, "(this means it's using a defunct field)\n"));
error1("Warning: domain %s uses a defunct field!!", domain);
***************
*** 235,238
if ((expanded = find_path_to(machine, FALSE)) == NULL) {
! dprint2(3,"\nCouldn't expand system path '%s' (%s)\n\n",
! machine, "domains");
error1("Couldn't find a path to %s!", machine);
--- 238,242 -----
if ((expanded = find_path_to(machine, FALSE)) == NULL) {
! dprint(3, (debugfile,
! "\nCouldn't expand system path '%s' (%s)\n\n",
! machine, "domains"));
error1("Couldn't find a path to %s!", machine);
***************
*** 248,251
if ((expanded = find_path_to(path, FALSE)) == NULL) {
! dprint2(3,"\nCouldn't expand system path '%s' (%s)\n\n",
! path, "domains");
error1("I Couldn't find a path to %s!", path);
--- 252,256 -----
if ((expanded = find_path_to(path, FALSE)) == NULL) {
! dprint(3, (debugfile,
! "\nCouldn't expand system path '%s' (%s)\n\n",
! path, "domains"));
error1("I Couldn't find a path to %s!", path);
***************
*** 259,261
case OBSOLETE: /* fall through.. */
! default : dprint2(1,
"\nError: Bad sequence in template file for domain '%s': %%%c\n\n",
--- 264,266 -----
case OBSOLETE: /* fall through.. */
! default : dprint(1, (debugfile,
"\nError: Bad sequence in template file for domain '%s': %%%c\n\n",
***************
*** 261,263
"\nError: Bad sequence in template file for domain '%s': %%%c\n\n",
! domain, template[i]);
}
--- 266,268 -----
"\nError: Bad sequence in template file for domain '%s': %%%c\n\n",
! domain, template[i]));
}
Index: src/fileio.c
***************
*** 8,9
#include "headers.h"
#include <ctype.h>
--- 8,11 -----
#include "headers.h"
+ #include <sys/types.h>
+ #include <sys/stat.h>
#include <ctype.h>
***************
*** 38,41
if (fseek(mailfile, header_table[current-1].offset, 0) == -1) {
! dprint2(1,"ERROR: Attempt to seek %d bytes into file failed (%s)",
! header_table[current-1].offset, "copy_message");
error1("ELM [seek] failed trying to read %d bytes into file",
--- 40,44 -----
if (fseek(mailfile, header_table[current-1].offset, 0) == -1) {
! dprint(1, (debugfile,
! "ERROR: Attempt to seek %d bytes into file failed (%s)",
! header_table[current-1].offset, "copy_message"));
error1("ELM [seek] failed trying to read %d bytes into file",
***************
*** 63,66
else if (! in_header && first_word(buffer, "From ")) {
! dprint0(1,"\n*** Internal Problem...Tried to add the following;\n");
! dprint1(1," '%s'\nto output file (copy_message) ***\n", buffer);
ok = 0; /* STOP NOW! */
--- 66,71 -----
else if (! in_header && first_word(buffer, "From ")) {
! dprint(1, (debugfile,
! "\n*** Internal Problem...Tried to add the following;\n"));
! dprint(1, (debugfile,
! " '%s'\nto output file (copy_message) ***\n", buffer));
ok = 0; /* STOP NOW! */
***************
*** 74,75
#ifdef SITE_HIDING
--- 79,103 -----
+ /******** the following routines are for a nice clean way to preserve
+ the stats related to the file we're currently reading and all
+ *********/
+
+ static struct stat statbuff;
+
+ save_file_stats(fname)
+ char *fname;
+ {
+ struct stat *stat();
+
+ stat(fname, &statbuff);
+ }
+
+ restore_file_stats(fname)
+ char *fname;
+ {
+ chmod(fname, statbuff.st_mode & 0777);
+ chown(fname, statbuff.st_uid, statbuff.st_gid);
+ }
+
+ /** and finally, here's something for that evil trick: site hiding **/
+
#ifdef SITE_HIDING
***************
*** 87,89
! this is shit and should be flagged as bad news!
--- 115,119 -----
! this line is deliberately inserted to ensure that you THINK
! about what you're doing, and perhaps even contact the author
! of Elm before you USE this option...
***************
*** 90,93
if ((hidden_users = fopen (HIDDEN_SITE_USERS,"r")) == NULL) {
! dprint2(1,"Couldn't open hidden site file %s [%s]\n",
! HIDDEN_SITE_USERS, error_name(errno));
return(FALSE);
--- 120,124 -----
if ((hidden_users = fopen (HIDDEN_SITE_USERS,"r")) == NULL) {
! dprint(1, (debugfile,
! "Couldn't open hidden site file %s [%s]\n",
! HIDDEN_SITE_USERS, error_name(errno)));
return(FALSE);
***************
*** 97,100
if (strcmp(buffer, specific_username) == 0) {
! dprint1(3,"** Found user '%s' in hidden site file!\n",
! specific_username);
fclose(hidden_users);
--- 128,131 -----
if (strcmp(buffer, specific_username) == 0) {
! dprint(3, (debugfile, "** Found user '%s' in hidden site file!\n",
! specific_username));
fclose(hidden_users);
***************
*** 104,107
fclose(hidden_users);
! dprint1(3,"** Couldn't find user '%s' in hidden site file!\n",
! specific_username);
--- 135,139 -----
fclose(hidden_users);
! dprint(3, (debugfile,
! "** Couldn't find user '%s' in hidden site file!\n",
! specific_username));
Index: src/return_addr.c
***************
*** 231,233
if (fseek(mailfile, header_table[current-1].offset, 0) == -1) {
! dprint3(1,"Error: seek %ld bytes into file hit errno %s (%s)",
header_table[current-1].offset, error_name(errno),
--- 231,234 -----
if (fseek(mailfile, header_table[current-1].offset, 0) == -1) {
! dprint(1, (debugfile,
! "Error: seek %ld bytes into file hit errno %s (%s)",
header_table[current-1].offset, error_name(errno),
***************
*** 233,235
header_table[current-1].offset, error_name(errno),
! "get_return");
error2("couldn't seek %d bytes into file (%s)",
--- 234,236 -----
header_table[current-1].offset, error_name(errno),
! "get_return"));
error2("couldn't seek %d bytes into file (%s)",
***************
*** 253,255
name1, name2, alt_name2);
! if (strcmp(name2, "from") == 0)
strcpy(name2, alt_name2);
--- 254,256 -----
name1, name2, alt_name2);
! if (strcmp(name2, "from") == 0) /* remote from xyz */
strcpy(name2, alt_name2);
***************
*** 255,256
strcpy(name2, alt_name2);
add_site(buffer, name2, lastname);
--- 256,259 -----
strcpy(name2, alt_name2);
+ else if (strcmp(name2, "by") == 0) /* forwarded by xyz */
+ strcpy(name2, alt_name2);
add_site(buffer, name2, lastname);
***************
*** 314,316
if (fseek(mailfile, header_table[current-1].offset, 0) == -1) {
! dprint3(1,"Error: seek %ld bytes into file hit errno %s (%s)",
header_table[current-1].offset, error_name(errno),
--- 317,320 -----
if (fseek(mailfile, header_table[current-1].offset, 0) == -1) {
! dprint(1, (debugfile,
! "Error: seek %ld bytes into file hit errno %s (%s)",
header_table[current-1].offset, error_name(errno),
***************
*** 316,318
header_table[current-1].offset, error_name(errno),
! "get_existing_address");
error2("couldn't seek %d bytes into the file (%s)",
--- 320,322 -----
header_table[current-1].offset, error_name(errno),
! "get_existing_address"));
error2("couldn't seek %d bytes into the file (%s)",
Index: src/addr_utils.c
***************
*** 13,15
! #ifdef BSD
#undef tolower
--- 13,15 -----
! #ifdef BSD
#undef tolower
***************
*** 33,36
if (sysname == NULL) {
! dprint0(2,
! "Warning - talk_to_sys is currently set to NULL! (talk_to)\n");
return(0);
--- 33,36 -----
if (sysname == NULL) {
! dprint(2, (debugfile,
! "Warning: talk_to_sys is currently set to NULL!\n"));
return(0);
***************
*** 201,203
else if (strpbrk(word,"!@:") != NULL)
! #ifdef DONT_TOUCH_ADDRESS
sprintf(full_to, "%s%s%s", full_to,
--- 201,203 -----
else if (strpbrk(word,"!@:") != NULL)
! #ifdef DONT_TOUCH_ADDRESSES
sprintf(full_to, "%s%s%s", full_to,
***************
*** 222,226
fprintf(stderr,"Use \"checkalias\" to find valid addresses!\n\r");
! dprint1(1,
! "Can't expand alias %s - bailing out! (build_address)\n",
! word);
emergency_exit();
--- 222,226 -----
fprintf(stderr,"Use \"checkalias\" to find valid addresses!\n\r");
! dprint(1, (debugfile,
! "Can't expand alias %s - bailing out of build_address\n",
! word));
emergency_exit();
***************
*** 228,230
else {
! dprint1(2,"Entered unknown address %s (build_address)\n", word);
sprintf(buffer, "'%s' is an unknown address. Replace with: ",
--- 228,230 -----
else {
! dprint(2,(debugfile,"Entered unknown address %s\n", word));
sprintf(buffer, "'%s' is an unknown address. Replace with: ",
***************
*** 242,244
strlen(new_to_list) > 0? " ":"", word);
! dprint1(3,"Replaced with %s (build_address)\n", word);
}
--- 242,245 -----
strlen(new_to_list) > 0? " ":"", word);
! dprint(3,(debugfile, "Replaced with %s in build_address\n",
! word));
}
***************
*** 245,247
else
! dprint0(3,"Address removed from to list (build_address)\n");
if (mail_only) printf("\n\r");
--- 246,249 -----
else
! dprint(3,(debugfile,
! "Address removed from TO list by build_address\n"));
if (mail_only) printf("\n\r");
***************
*** 281,284
if (timebuff[1] != ':' && timebuff[2] != ':') {
! dprint1(3,"real_from returns FAIL [bad time field] on\n-> %s\n",
! buffer);
return(FALSE);
--- 283,287 -----
if (timebuff[1] != ':' && timebuff[2] != ':') {
! dprint(3,(debugfile,
! "Real_from returns FAIL [bad time field] on\n-> %s\n",
! buffer));
return(FALSE);
***************
*** 289,292
if (junk[0] != '\0') {
! dprint1(3,"real_from returns FAIL [too many fields] on\n-> %s\n",
! buffer);
return(FALSE);
--- 292,296 -----
if (junk[0] != '\0') {
! dprint(3, (debugfile,
! "Real_from returns FAIL [too many fields] on\n-> %s\n",
! buffer));
return(FALSE);
***************
*** 323,325
! machine[0] = '\0';
--- 327,329 -----
! machine[0] = holding_from[0] = '\0';
***************
*** 340,341
if (machine[0] == '\0')
--- 344,352 -----
+ /* the following fix is to deal with ">From xyz ... forwarded by xyz"
+ which occasionally shows up within AT&T. Thanks to Bill Carpenter
+ for the fix! */
+
+ if (strcmp(machine, holding_from) == 0)
+ machine[0] = '\0';
+
if (machine[0] == '\0')
***************
*** 341,343
if (machine[0] == '\0')
! sprintf(buff,"anonymous");
else
--- 352,354 -----
if (machine[0] == '\0')
! strcpy(buff, holding_from[0] ? holding_from : "anonymous");
else
***************
*** 453,456
if (words < 6) { /* strange format. We're outta here! */
! dprint1(3,"parse_arpa_date failed [less than six fields] on\n-> %s\n",
! string);
return;
--- 464,468 -----
if (words < 6) { /* strange format. We're outta here! */
! dprint(3,(debugfile,
! "Parse_arpa_date failed [less than six fields] on\n-> %s\n",
! string));
return;
***************
*** 472,475
if (! valid_date(word[1], word[2], word[3])) {
! dprint4(3,"parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[1], word[2], word[3], string);
return; /* strange date! */
--- 484,488 -----
if (! valid_date(word[1], word[2], word[3])) {
! dprint(3,(debugfile,
! "parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[1], word[2], word[3], string));
return; /* strange date! */
***************
*** 483,486
if (! valid_date(word[2], word[3], word[4])) {
! dprint4(3,"parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[2], word[3], word[4], string);
return; /* strange date! */
--- 496,500 -----
if (! valid_date(word[2], word[3], word[4])) {
! dprint(3,(debugfile,
! "parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[2], word[3], word[4], string));
return; /* strange date! */
***************
*** 496,498
if (! valid_date(word[3], word[2], word[5])) {
! dprint4(3,
"parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
--- 510,512 -----
if (! valid_date(word[3], word[2], word[5])) {
! dprint(3, (debugfile,
"parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
***************
*** 498,500
"parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[3], word[2], word[5], string);
return; /* strange date! */
--- 512,514 -----
"parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[3], word[2], word[5], string));
return; /* strange date! */
***************
*** 506,509
if (! valid_date(word[3], word[2], word[4])) {
! dprint4(3,"parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[3], word[2], word[4], string);
return; /* strange date! */
--- 520,524 -----
if (! valid_date(word[3], word[2], word[4])) {
! dprint(3,(debugfile,
! "parse_arpa_date failed [bad date: %s/%s/%s] on\n-> %s\n",
! word[3], word[2], word[4], string));
return; /* strange date! */
***************
*** 542,545
if (host_count == MAX_HOPS) {
! dprint0(2,
! "Can't build return address - hit MAX_HOPS (fix_arpa_address)\n");
error("Can't build return address - hit MAX_HOPS limit!");
--- 557,560 -----
if (host_count == MAX_HOPS) {
! dprint(2, (debugfile,
! "Can't build return address - hit MAX_HOPS in fix_arpa_address\n"));
error("Can't build return address - hit MAX_HOPS limit!");
Index: src/input_utils.c
***************
*** 9,10
#include <errno.h>
--- 9,11 -----
#include <errno.h>
+ #include <ctype.h>
***************
*** 14,17
! #define special_char(c) (c == ' ' || c == '\t' || c == '/' || c == ',' \
! || c == '\0')
--- 15,17 -----
! #define isstopchar(c) (c == ' ' || c == '\t' || c == '/')
***************
*** 72,83
{
! /** Display the string on the screen and if RETURN is pressed, return
! it. Otherwise, allow standard text input, including backspaces
! and such until RETURN is hit.
! If "append_current" is set, then leave the default string in
! place and edit AFTER it...assume 'x,y' is placing us at the
! beginning of the string...
! This routine returns zero unless INTERRUPT hit, then it returns
! -1 and must be treated accordingly.
! Added ^W and ^R support...
! Also added that if x and y are < 0 don't try any cursor stuff
**/
--- 72,85 -----
{
! /** This will display the string on the screen and allow the user to
! either accept it (by pressing RETURN) or alter it according to
! what the user types. The various flags are:
! string is the buffer to use (with optional initial value)
! x,y is the location we're at on the screen (-1,-1 means
! that we can't use this info and need to explicitly
! use backspace-space-backspace sequences)
! append_current means that we have an initial string and that
! the cursor should be placed at the END of the line,
! not the beginning (the default).
!
! If we hit an interrupt or EOF we'll return non-zero.
**/
***************
*** 85,87
char ch;
! register int index = 0, use_cursor_control;
--- 87,89 -----
char ch;
! register int ch_count = 0, index = 0, use_cursor_control, done=0;
***************
*** 87,92
! use_cursor_control = ((! mail_only) && x >= 0 && y >= 0);
!
! if (use_cursor_control)
! PutLine1(x,y, "%s", string);
else
--- 89,92 -----
! if ((use_cursor_control = (! mail_only && x >= 0 && y >= 0)))
! PutLine1(x, y, "%s", string);
else
***************
*** 96,98
! if (! append_current)
if (use_cursor_control)
--- 96,98 -----
! if (! append_current) {
if (use_cursor_control)
***************
*** 101,102
non_destructive_back_up(strlen(string));
--- 101,105 -----
non_destructive_back_up(strlen(string));
+ }
+ else
+ index = strlen(string);
***************
*** 105,107
! ch = getchar();
--- 108,113 -----
! /** now we have the screen as we want it and the cursor in the
! right place, we can loop around on the input and return the
! string as soon as the user presses <RETURN>
! **/
***************
*** 107,140
- if (ch == '\n' || ch == '\r') {
- if (cursor_control)
- transmit_functions(ON);
- return(0); /* we're done. No change needed */
- }
-
- CleartoEOLN();
-
- index = (append_current? strlen(string) : 0);
-
- if (ch == kill_line) {
- if (use_cursor_control)
- MoveCursor(x,y);
- else
- back_up(index);
- CleartoEOLN();
- index = 0;
- }
- else if (ch != backspace) {
- Writechar(ch);
- string[index++] = ch;
- }
- else if (index > 0) {
- index--;
- erase_a_char();
- }
- else {
- Writechar(' ');
- Writechar(BACKSPACE);
- fflush(stdout);
- }
-
do {
--- 113,114 -----
do {
***************
*** 142,143
/* the following is converted from a case statement to
--- 116,135 -----
+ if (ch == ctrl('D')) { /* we've hit EOF */
+ if (cursor_control)
+ transmit_functions(ON);
+ return(1);
+ }
+
+ if (ch_count++ == 0) {
+ if (ch == '\n' || ch == '\r') {
+ if (cursor_control)
+ transmit_functions(ON);
+ return(0);
+ }
+ else if (! append_current) {
+ CleartoEOLN();
+ index = (append_current? strlen(string) : 0);
+ }
+ }
+
/* the following is converted from a case statement to
***************
*** 148,159
! if (ch == backspace) {
! if (index > 0) {
! erase_a_char();
! index--;
! }
! else {
! Writechar(' ');
! Writechar(BACKSPACE);
! fflush(stdout);
! }
}
--- 140,145 -----
! if (ch == backspace) {
! if (index > 0) {
! Writechar(BACKSPACE);
! index--;
}
***************
*** 159,165
}
! else if (ch == '\n' || ch == '\r') {
! string[index] = '\0';
! if (cursor_control)
! transmit_functions(ON);
! return(0);
}
--- 145,163 -----
}
! Writechar(' ');
! Writechar(BACKSPACE);
! fflush(stdout);
! }
! else if (ch == '\n' || ch == '\r') {
! string[index] = '\0';
! if (cursor_control)
! transmit_functions(ON);
! return(0);
! }
! else if (ch == ctrl('W')) { /* back up a word! */
! if (index == 0)
! continue; /* no point staying here.. */
! index--;
! while (index >= 0 && isspace(string[index])) {
! index--;
! erase_a_char();
}
***************
*** 165,175
}
! else if (ch == ctrl('W')) { /* back up a word! */
! if (special_char(string[index]) && index > 0) {
! index--;
! erase_a_char();
! }
! while (index > 0 && ! special_char(string[index])) {
! index--;
! erase_a_char();
! }
}
--- 163,168 -----
}
!
! while (index >= 0 && ! isstopchar(string[index])) {
! index--;
! erase_a_char();
}
***************
*** 175,184
}
! else if (ch == ctrl('R')) {
! string[index] = '\0';
! if (use_cursor_control) {
! PutLine1(x,y, "%s", string);
! CleartoEOLN();
! }
! else
! printf("\n%s", string);
}
--- 168,176 -----
}
! index++; /* and make sure we point at the first AVAILABLE slot */
! }
! else if (ch == ctrl('R')) {
! string[index] = '\0';
! if (use_cursor_control) {
! PutLine1(x,y, "%s", string);
! CleartoEOLN();
}
***************
*** 184,201
}
! else if (ch == kill_line) {
! if (use_cursor_control)
! MoveCursor(x,y);
! else
! back_up(index+1);
! CleartoEOLN();
! index = 0;
! }
! else if (ch == NULL) {
! if (cursor_control)
! transmit_functions(ON);
! fflush(stdin); /* remove extraneous chars, if any */
! string[0] = '\0'; /* clean up string, and... */
! return(-1);
! }
! else { /* default case */
--- 176,196 -----
}
! else
! printf("\n%s", string);
! }
! else if (ch == kill_line) {
! if (use_cursor_control)
! MoveCursor(x,y);
! else
! back_up(index+1);
! CleartoEOLN();
! index = 0;
! }
! else if (ch == '\0') {
! if (cursor_control)
! transmit_functions(ON);
! fflush(stdin); /* remove extraneous chars, if any */
! string[0] = '\0'; /* clean up string, and... */
! return(-1);
! }
! else { /* default case */
***************
*** 203,205
Writechar(ch);
! }
} while (index < SLEN);
--- 198,200 -----
Writechar(ch);
! }
} while (index < SLEN);
***************
*** 210,211
transmit_functions(ON);
return(0);
--- 205,207 -----
transmit_functions(ON);
+
return(0);
***************
*** 226,228
char ch;
! register index = 0;
--- 222,224 -----
char ch;
! register index = 0, done;
***************
*** 300,307
else if (ch == ctrl('W')) {
! /* get to rightmost non-alpha */
! if (special_char (string[index]) && index > 0)
! index--;
! while (index > 0 && ! special_char(string[index])) {
! erase_a_char();
! index--;
}
--- 296,303 -----
else if (ch == ctrl('W')) {
! if (index == 0)
! continue; /* no point staying here.. */
! index--;
! while (index >= 0 && isspace(string[index])) {
! index--;
! erase_a_char();
}
***************
*** 307,308
}
}
--- 303,310 -----
}
+
+ while (index >= 0 && ! isstopchar(string[index])) {
+ index--;
+ erase_a_char();
+ }
+ index++; /* and make sure we point at the first AVAILABLE slot */
}
***************
*** 322,324
}
! else if (ch == NULL) {
if (cursor_control)
--- 324,326 -----
}
! else if (ch == '\0') {
if (cursor_control)
Index: src/mailtime.c
***************
*** 133,135
#else
! if (utime(filename, NULL) == -1) /* note no "S" */
#endif
--- 133,135 -----
#else
! if (utime(filename, (char *) NULL) == -1) /* note no "S" */
#endif
Index: src/encode.c
***************
*** 52,54
MoveCursor(LINES-1,0);
! if ( strcmp( buffer, getpass( "Please enter it again: "))) {
error("Your keys were not the same!");
--- 52,54 -----
MoveCursor(LINES-1,0);
! if ( send && strcmp( buffer, getpass( "Please enter it again: "))) {
error("Your keys were not the same!");
Index: src/leavembox.c
***************
*** 10,11
#include <sys/stat.h>
#include <errno.h>
--- 10,12 -----
#include <sys/stat.h>
+ #include <unistd.h>
#include <errno.h>
***************
*** 14,22
- /** added due to a bug in the 2.1 OS **/
-
- struct utimbuf {
- time_t actime; /** access time **/
- time_t modtime; /** modification */
- };
-
extern int errno;
--- 15,16 -----
extern int errno;
***************
*** 40,44
char outfile[SLEN], buffer[SLEN];
! struct stat buf; /* stat command */
! struct utimbuf times; /* utime command */
! register int to_delete = 0, to_save = 0, i, mode = 00644,
pending = 0, number_saved = 0, last_sortby;
--- 34,38 -----
char outfile[SLEN], buffer[SLEN];
! struct stat buf; /* stat command */
! struct utimbuf utime_buffer; /* utime command */
! register int to_delete = 0, to_save = 0, i,
pending = 0, number_saved = 0, last_sortby;
***************
*** 44,46
pending = 0, number_saved = 0, last_sortby;
! char dflt;
long bytes();
--- 38,40 -----
pending = 0, number_saved = 0, last_sortby;
! char answer;
long bytes();
***************
*** 47,49
! dprint0(1,"\n\n-- leaving_mailbox --\n\n");
--- 41,43 -----
! dprint(1, (debugfile, "\n\n-- leaving_mailbox --\n\n"));
***************
*** 56,58
! dprint2(2,"Count: %d to delete and %d to save\n", to_delete, to_save);
--- 50,53 -----
! dprint(2, (debugfile,
! "Count: %d to delete and %d to save\n", to_delete, to_save));
***************
*** 66,71
! if (always_del) /* set up the default answer... */
! dflt = 'y';
! else
! dflt = 'n';
--- 61,67 -----
! if (to_delete) {
! if (always_del) /* set up the default answer... */
! answer = 'y';
! else
! answer = 'n';
***************
*** 71,73
- if (question_me && to_delete)
if (to_save) {
--- 67,68 -----
if (to_save) {
***************
*** 73,77
if (to_save) {
! fflush(stdin);
! sprintf(buffer, "Delete message%s? (y/n) ", plural(to_delete));
! if (want_to(buffer, dflt, ECHOIT) != 'y') {
if (mbox_specified == 0) unlock(); /* remove lock! */
--- 68,75 -----
if (to_save) {
! if (question_me) {
! fflush(stdin);
! sprintf(buffer, "Delete message%s? (y/n) ", plural(to_delete));
! answer = want_to(buffer, answer, ECHOIT);
! }
! if (answer != 'y') {
if (mbox_specified == 0) unlock(); /* remove lock! */
***************
*** 77,80
if (mbox_specified == 0) unlock(); /* remove lock! */
! dprint1(3,"\tDelete message%s? - answer was NO\n",
! plural(to_delete));
error("Nothing deleted");
--- 75,78 -----
if (mbox_specified == 0) unlock(); /* remove lock! */
! dprint(3, (debugfile, "\tDelete message%s? - answer was NO\n",
! plural(to_delete)));
error("Nothing deleted");
***************
*** 84,87
else if (! to_save) { /* nothing to save!! */
! fflush(stdin);
! if (want_to("Delete all mail? (y/n) ", dflt, ECHOIT)!='y') {
if (mbox_specified == 0) unlock(); /* remove lock! */
--- 82,88 -----
else if (! to_save) { /* nothing to save!! */
! if (question_me) {
! fflush(stdin);
! answer = want_to("Delete all mail? (y/n) ", answer, ECHOIT);
! }
! if (answer != 'y') {
if (mbox_specified == 0) unlock(); /* remove lock! */
***************
*** 87,89
if (mbox_specified == 0) unlock(); /* remove lock! */
! dprint0(3,"Delete all mail? - answer was NO\n");
error("Nothing deleted");
--- 88,90 -----
if (mbox_specified == 0) unlock(); /* remove lock! */
! dprint(3, (debugfile, "Delete all mail? - answer was NO\n"));
error("Nothing deleted");
***************
*** 92,93
}
--- 93,95 -----
}
+ }
***************
*** 93,99
- if (always_leave)
- dflt = 'y';
- else
- dflt = 'n';
-
/** we have to check to see what the sorting order was...so that
--- 95,96 -----
/** we have to check to see what the sorting order was...so that
***************
*** 109,122
! if (question_me && to_save && mbox_specified == 0) {
! fflush(stdin);
! if (want_to("Keep mail in incoming mailbox? (y/n) ",dflt, ECHOIT)
! == 'y')
! if (to_delete) /* okay - keep undeleted as pending! */
! pending++;
! else { /* gag! nothing to delete, don't save! */
! unlock(); /* remove mailfile lock! */
! dprint0(3,"Keep mail in incoming mailbox? -- answer was YES\n");
! error("Mailbox unchanged");
! return(FALSE); /* nothing changed! */
! }
}
--- 106,128 -----
! if (to_save && mbox_specified == 0) {
! if (always_leave) /* set up default answer */
! answer = 'y';
! else
! answer = 'n';
! if (question_me) {
! fflush(stdin);
! answer = want_to("Keep mail in incoming mailbox? (y/n) ",
! answer, ECHOIT);
! }
! if (answer == 'y') {
! if (to_delete) /* okay - keep undeleted as pending! */
! pending++;
! else { /* gag! nothing to delete, don't save! */
! unlock(); /* remove mailfile lock! */
! dprint(3, (debugfile,
! "Keep mail in incoming mailbox? -- answer was YES\n"));
! error("Mailbox unchanged");
! return(FALSE); /* nothing changed! */
! }
! }
}
***************
*** 147,149
! dprint1(2,"Action: %s\n", buffer);
--- 153,155 -----
! dprint(2, (debugfile, "Action: %s\n", buffer));
***************
*** 172,174
outfile);
! dprint2(1,
"Error: Permission to append to outfile %s denied!! (%s)\n",
--- 178,180 -----
outfile);
! dprint(1, (debugfile,
"Error: Permission to append to outfile %s denied!! (%s)\n",
***************
*** 174,178
"Error: Permission to append to outfile %s denied!! (%s)\n",
! outfile, "leavembox");
! dprint2(1,"** %s - %s **\n", error_name(errno),
! error_description(errno));
unlock();
--- 180,184 -----
"Error: Permission to append to outfile %s denied!! (%s)\n",
! outfile, "leavembox"));
! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! error_description(errno)));
unlock();
***************
*** 183,188
unlock(); /* remove mailfile lock! */
! dprint1(1,"Error: could not append to file %s\n",
! outfile);
! dprint2(1,"** %s - %s **\n", error_name(errno),
! error_description(errno));
sprintf(buffer, " Could not append to file %s! ",
--- 189,194 -----
unlock(); /* remove mailfile lock! */
! dprint(1, (debugfile, "Error: could not append to file %s\n",
! outfile));
! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! error_description(errno)));
sprintf(buffer, " Could not append to file %s! ",
***************
*** 197,199
if (! number_saved++) {
! dprint2(2,"Saving message%s #%d, ", plural(to_save), current);
}
--- 203,206 -----
if (! number_saved++) {
! dprint(2, (debugfile, "Saving message%s #%d, ",
! plural(to_save), current));
}
***************
*** 200,202
else {
! dprint1(2,"#%d, ", current);
}
--- 207,209 -----
else {
! dprint(2, (debugfile, "#%d, ", current));
}
***************
*** 205,207
fclose(temp);
! dprint0(2,"\n\n");
}
--- 212,214 -----
fclose(temp);
! dprint(2, (debugfile, "\n\n"));
}
***************
*** 211,220
! /** let's grab the original mode and date/time of the mailfile
! before removing it **/
!
! if (stat(infile, &buf) == 0)
! mode = buf.st_mode & 00777;
! else {
! dprint2(1,"Error: errno %s attempting to stat file %s\n",
! error_name(errno), infile);
error3("Error %s (%s) on stat(%s)", error_name(errno),
--- 218,222 -----
! if (stat(infile, &buf) != 0) { /* grab original times... */
! dprint(1, (debugfile, "Error: errno %s attempting to stat file %s\n",
! error_name(errno), infile));
error3("Error %s (%s) on stat(%s)", error_name(errno),
***************
*** 237,242
if (copy(outfile, infile) != 0) {
! dprint2(1,"leavembox: copy(%s, %s) failed;",
! outfile, infile);
! dprint2(1,"** %s - %s **\n", error_name(errno),
! error_description(errno));
error("couldn't modify mail file!");
--- 239,244 -----
if (copy(outfile, infile) != 0) {
! dprint(1, (debugfile, "leavembox: copy(%s, %s) failed;",
! outfile, infile));
! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! error_description(errno)));
error("couldn't modify mail file!");
***************
*** 245,250
if (copy(outfile, infile) != 0) {
! dprint1(1,"leavembox: couldn't copy to %s either!! Help;",
! infile);
! dprint2(1,"** %s - %s **\n", error_name(errno),
! error_description(errno));
error("something godawful is happening to me!!!");
--- 247,253 -----
if (copy(outfile, infile) != 0) {
! dprint(1, (debugfile,
! "leavembox: couldn't copy to %s either!! Help;",
! infile));
! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! error_description(errno)));
error("something godawful is happening to me!!!");
***************
*** 253,256
else {
! dprint1(1,"\nWoah! Confused - Saved mail in %s (leavembox)\n",
! infile);
error1("saved mail in %s", infile);
--- 256,260 -----
else {
! dprint(1, (debugfile,
! "\nWoah! Confused - Saved mail in %s (leavembox)\n",
! infile));
error1("saved mail in %s", infile);
***************
*** 260,264
else {
! dprint2(1,"link(%s, %s) failed (leavembox)\n", outfile, infile);
! dprint2(1,"** %s - %s **\n", error_name(errno),
! error_description(errno));
error2("link failed! %s - %s", error_name(errno),
--- 264,269 -----
else {
! dprint(1, (debugfile, "link(%s, %s) failed (leavembox)\n",
! outfile, infile));
! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! error_description(errno)));
error2("link failed! %s - %s", error_name(errno),
***************
*** 274,275
fclose(temp);
chmod(infile, mode);
--- 279,282 -----
fclose(temp);
+ restore_file_stats(infile);
+ /**
chmod(infile, mode);
***************
*** 276,277
chown(infile, userid, groupid);
}
--- 283,285 -----
chown(infile, userid, groupid);
+ **/
}
***************
*** 279,286
if (mbox_specified == 0) {
! if (mode != 00644) { /* if not the default mail access mode... */
! if (! pending) { /* if none still being saved */
! temp = fopen(infile, "w");
! fclose(temp);
! }
! chmod(infile,mode);
--- 287,294 -----
if (mbox_specified == 0) {
! if (! pending) { /* if none still being saved */
! temp = fopen(infile, "w");
! fclose(temp);
! }
!
! restore_file_stats(infile);
***************
*** 286,289
! /* let's set the access times of the new mail file to be
! the same as the OLD one (still sitting in 'buf') ! */
--- 294,297 -----
! /* let's set the access times of the new mail file to be
! the same as the OLD one (still sitting in 'buf') ! */
***************
*** 289,292
! times.actime = buf.st_atime;
! times.modtime= buf.st_mtime;
--- 297,300 -----
! utime_buffer.actime = buf.st_atime;
! utime_buffer.modtime= buf.st_mtime;
***************
*** 292,298
! if (utime(infile, ×) != 0) {
! dprint0(1,"Error: encountered error doing utime (leavmbox)\n");
! dprint2(1,"** %s - %s **\n", error_name(errno),
! error_description(errno));
! error2("Error %s trying to change file %s access time",
error_name(errno), infile);
--- 300,307 -----
! if (utime(infile, &utime_buffer) != 0) {
! dprint(1, (debugfile,
! "Error: encountered error doing utime (leavmbox)\n"));
! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! error_description(errno)));
! error2("Error %s trying to change file %s access time",
error_name(errno), infile);
***************
*** 298,300
error_name(errno), infile);
- }
}
--- 307,308 -----
error_name(errno), infile);
}
***************
*** 300,301
}
unlock(); /* remove the lock on the file ASAP! */
--- 308,310 -----
}
+
unlock(); /* remove the lock on the file ASAP! */
***************
*** 309,316
- #ifdef SAVE_GROUP_MAILBOX_ID
- chown(infile, userid, getegid()); /** see the Config Guide **/
- #else
- chown(infile, userid, groupid); /** file owned by user **/
- #endif
-
return(to_delete);
--- 318,319 -----
return(to_delete);
***************
*** 343,346
while (access_val != -1 && iteration++ < MAX_ATTEMPTS) {
! dprint1(2,"File '%s' currently exists! Waiting...(lock)\n",
! lock_name);
if (direction == INCOMING)
--- 346,350 -----
while (access_val != -1 && iteration++ < MAX_ATTEMPTS) {
! dprint(2, (debugfile,
! "File '%s' currently exists! Waiting...(lock)\n",
! lock_name));
if (direction == INCOMING)
***************
*** 346,348
if (direction == INCOMING)
! PutLine0(LINES, 0, "\nMail being received!\twaiting...");
else
--- 350,352 -----
if (direction == INCOMING)
! PutLine0(LINES, 0, "Mail being received!\twaiting...");
else
***************
*** 360,363
! dprint0(2,
! "Warning: I'm giving up waiting - removing lock file(lock)\n");
if (direction == INCOMING)
--- 364,367 -----
! dprint(2, (debugfile,
! "Warning: I'm giving up waiting - removing lock file(lock)\n"));
if (direction == INCOMING)
***************
*** 368,371
if (unlink(lock_name) != 0) {
! dprint3(1,"Error %s (%s)\n\ttrying to unlink file %s (%s)\n",
! error_name(errno), error_description(errno), lock_name);
PutLine1(LINES, 0,
--- 372,376 -----
if (unlink(lock_name) != 0) {
! dprint(1, (debugfile,
! "Error %s (%s)\n\ttrying to unlink file %s (%s)\n",
! error_name(errno), error_description(errno), lock_name));
PutLine1(LINES, 0,
***************
*** 391,394
"Please try to read your mail again in a few minutes.\n");
! dprint1(2,"Warning:bailing out after %d iterations...(lock)\n",
! iteration);
leave_locked(0);
--- 396,400 -----
"Please try to read your mail again in a few minutes.\n");
! dprint(2, (debugfile,
! "Warning: bailing out after %d iterations...(lock)\n",
! iteration));
leave_locked(0);
***************
*** 396,399
else {
! dprint1(2,"Warning: after %d iterations, timed out! (lock)\n",
! iteration);
leave(error("Timed out on lock file reads. Leaving program"));
--- 402,406 -----
else {
! dprint(2, (debugfile,
! "Warning: after %d iterations, timed out! (lock)\n",
! iteration));
leave(error("Timed out on lock file reads. Leaving program"));
***************
*** 407,410
if ((lock_fd = creat(lock_name, 0)) == -1) {
! dprint2(1,"Can't create lock file: creat(%s) raises error %s (lock)\n",
! lock_name, error_name(errno));
if (errno == EACCES)
--- 414,418 -----
if ((lock_fd = creat(lock_name, 0)) == -1) {
! dprint(1, (debugfile,
! "Can't create lock file: creat(%s) raises error %s (lock)\n",
! lock_name, error_name(errno)));
if (errno == EACCES)
***************
*** 414,419
else {
! dprint1(1,"Error encountered attempting to create lock %s\n",
! lock_name);
! dprint2(1,"** %s - %s **\n", error_name(errno),
! error_description(errno));
PutLine1(LINES, 0,
--- 422,428 -----
else {
! dprint(1, (debugfile,
! "Error encountered attempting to create lock %s\n",
! lock_name));
! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! error_description(errno)));
PutLine1(LINES, 0,
Index: src/opt_utils.c
***************
*** 17,18
#ifdef NEED_GETHOSTNAME
# include <sys/utsname.h>
--- 17,19 -----
#ifdef NEED_GETHOSTNAME
+ # include <sys/types.h>
# include <sys/utsname.h>
***************
*** 20,26
- #ifdef UTS
- # include <sys/tubio.h>
- # define TTYIN 0 /* standard input */
- #endif
-
#ifdef NEED_GETHOSTNAME
--- 21,22 -----
#ifdef NEED_GETHOSTNAME
***************
*** 31,33
{
! /** Return the name of the current host machine. UTS only **/
--- 27,29 -----
{
! /** Return the name of the current host machine. **/
***************
*** 41,43
(void) strncpy(hostname,name.nodename,size-1);
! hostname[size] = '\0';
--- 37,39 -----
(void) strncpy(hostname,name.nodename,size-1);
! hostname[size - 1] = '\0';
***************
*** 47,49
! #ifdef UTS
--- 43,45 -----
! #ifdef NEED_CUSERID
***************
*** 49,78
- int
- isa3270()
- {
- /** Returns TRUE and sets LINES and COLUMNS to the correct values
- for an Amdahl (IBM) tube screen, or returns FALSE if on a normal
- terminal (of course, next to a 3270, ANYTHING is normal!!) **/
-
- struct tubiocb tubecb;
-
- dprint0(3,"Seeing if we're a 3270...");
-
- if (ioctl(TTYIN, TUBGETMOD, &tubecb) == -1) {
- dprint0(3,"We're not!\n");
- return(FALSE); /* not a tube! */
- }
-
- LINES = tubecb->line_cnt - 1;
- COLUMNS = tubecb->col_cnt;
-
- dprint2(3,"We are! %d lines and %d columns!\n",
- LINES, COLUMNS);
- return(TRUE);
- }
-
- #endif /* def UTS */
-
- #ifdef BSD
-
cuserid(uname)
--- 45,46 -----
cuserid(uname)
***************
*** 91,92
}
--- 59,64 -----
}
+
+ #endif
+
+ #ifdef BSD
End of Patch Kit #4