Xref: utzoo alt.sources:101 comp.unix.xenix:1357 Path: utzoo!hoptoad!cpsc6a!codas!ateng!chip From: chip@ateng.UUCP (Chip Salzenberg) Newsgroups: alt.sources,comp.unix.xenix Subject: Elm 1.7 beta: patches for Xenix (5 of 7) Message-ID: <172@ateng.UUCP> Date: 27 Jan 88 00:29:48 GMT Organization: A T Engineering, Tampa, FL Lines: 1225 The patches for src/*.[hc] were two large, so I split them. This is part one of two. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the "#! /bin/sh" line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # p.src.1 # This archive created: Tue Jan 26 19:14:42 1988 export PATH; PATH=/bin:$PATH : echo 'shar: extracting "p.src.1" (27008 characters) ' if test -f 'p.src.1' then echo 'shar: will not overwrite existing file "p.src.1" ' else sed 's/^X//' << \SHAR_EOF > 'p.src.1' XIndex: addr_utils.c X*** elm1.7beta/src/addr_utils.c Mon Nov 2 20:09:53 1987 X--- elm/src/addr_utils.c Mon Dec 7 12:52:21 1987 X*************** X*** 11,17 **** X #include X- #include X- X- #ifdef BSD X- #undef tolower X- #endif X X--- 11,12 ---- XIndex: builtin.c X*** elm1.7beta/src/builtin.c Mon Nov 2 20:14:34 1987 X--- elm/src/builtin.c Mon Dec 7 12:52:31 1987 X*************** X*** 20,22 **** X #include "headers.h" X- #include X X--- 20,21 ---- X*************** X*** 23,28 **** X #define BEEP 007 /* ASCII Bell character */ X- X- #ifdef BSD X- # undef tolower X- #endif X X--- 22,23 ---- XIndex: calendar.c X*** elm1.7beta/src/calendar.c Mon Nov 2 20:13:37 1987 X--- elm/src/calendar.c Wed Dec 9 09:18:43 1987 X*************** X*** 43,44 **** X--- 43,45 ---- X char *error_name(), *error_description(), *strcpy(); X+ FILE *user_fopen(); X X*************** X*** 51,63 **** X X! if (can_open(calendar_file, "a") != 0) { X! dprint(2, (debugfile, X! "Error: wrong permissions to append to calendar %s\n", X! calendar_file)); X! dprint(2, (debugfile, "** %s - %s **\n", X! error_name(errno), error_description(errno))); X! error1("Not able to append to file %s!", calendar_file); X! return; X! } X! X! if ((calendar = fopen(calendar_file,"a")) == NULL) { X dprint(2, (debugfile, X--- 52,55 ---- X X! if ((calendar = user_fopen(calendar_file,"a")) == NULL) { X! int err = errno; X dprint(2, (debugfile, X*************** X*** 66,69 **** X dprint(2, (debugfile, "** %s - %s **\n", X! error_name(errno), error_description(errno))); X! error1("Couldn't append to file %s!", calendar_file); X return; X--- 58,62 ---- X dprint(2, (debugfile, "** %s - %s **\n", X! error_name(err), error_description(err))); X! error2("Couldn't append to file %s! (%s)", X! calendar_file, error_description(err)); X return; XIndex: curses.c X*** elm1.7beta/src/curses.c Mon Nov 2 20:09:06 1987 X--- elm/src/curses.c Wed Dec 9 14:53:19 1987 X*************** X*** 39,45 **** X X- #include X- X- #ifdef BSD X- #undef tolower X- #endif X #include "curses.h" X--- 39,40 ---- X*************** X*** 565,567 **** X char *line; X! int argcount, arg1, arg2, arg3; X { X--- 560,563 ---- X char *line; X! int argcount; X! long arg1, arg2, arg3; X { X*************** X*** 619,621 **** X char *line; X! char *arg1; X { X--- 615,617 ---- X char *line; X! long arg1; X { X*************** X*** 634,636 **** X char *line; X! char *arg1, *arg2; X { X--- 630,632 ---- X char *line; X! long arg1, arg2; X { X*************** X*** 649,651 **** X char *line; X! char *arg1, *arg2, *arg3; X { X--- 645,647 ---- X char *line; X! long arg1, arg2, arg3; X { X*************** X*** 733,735 **** X X! return(result == 0? EOF : ch); X } X--- 729,731 ---- X X! return(result == 0? EOF : (ch & 0377)); X } XIndex: date.c X*** elm1.7beta/src/date.c Mon Nov 2 20:06:53 1987 X--- elm/src/date.c Mon Dec 7 12:52:55 1987 X*************** X*** 21,29 **** X X- #include X- X- #ifdef BSD X- #undef toupper X- #undef tolower X- #endif X- X #define MONTHS_IN_YEAR 11 /* 0-11 equals 12 months! */ X--- 21,22 ---- XIndex: delete.c X*** elm1.7beta/src/delete.c Mon Nov 2 20:12:11 1987 X--- elm/src/delete.c Fri Dec 18 10:41:45 1987 X*************** X*** 46,48 **** X MoveCursor((msg % headers_per_page) + 4, 3); X! if (msg == current && !arrow_cursor) { X StartBold(); X--- 46,48 ---- X MoveCursor((msg % headers_per_page) + 4, 3); X! if (msg == (current - 1) && !arrow_cursor) { X StartBold(); X*************** X*** 75,77 **** X MoveCursor((msg % headers_per_page) + 4, 4); X! if (msg == current && !arrow_cursor) { X StartBold(); X--- 75,77 ---- X MoveCursor((msg % headers_per_page) + 4, 4); X! if (msg == (current - 1) && !arrow_cursor) { X StartBold(); XIndex: domains.c X*** elm1.7beta/src/domains.c Mon Nov 9 08:23:50 1987 X--- elm/src/domains.c Mon Dec 7 12:53:06 1987 X*************** X*** 12,14 **** X #include X- #include X X--- 12,13 ---- X*************** X*** 15,21 **** X #include "headers.h" X- X- #ifdef BSD X- # undef toupper X- # undef tolower X- #endif X X--- 14,15 ---- XIndex: editmsg.c X*** elm1.7beta/src/editmsg.c Mon Nov 2 20:08:29 1987 X--- elm/src/editmsg.c Mon Dec 7 12:53:25 1987 X*************** X*** 12,14 **** X #include X- #include X X--- 12,13 ---- XIndex: elm.c X*** elm1.7beta/src/elm.c Mon Nov 2 20:10:19 1987 X--- elm/src/elm.c Wed Dec 9 09:48:03 1987 X*************** X*** 10,16 **** X X- #ifdef BSD X- # undef toupper X- # undef tolower X- #endif X- X long bytes(); X--- 10,11 ---- X*************** X*** 103,105 **** X X! case '$' : resync(); break; X X--- 98,100 ---- X X! case '$' : redraw = resync(); break; X X*************** X*** 194,196 **** X define_softkeys(CHANGE); X! redraw = newmbox(0, TRUE, TRUE); X /* mailfile_size = bytes(infile); newmbox.c NSM */ X--- 189,192 ---- X define_softkeys(CHANGE); X! if (newmbox(0, TRUE, TRUE)) X! redraw = TRUE; X /* mailfile_size = bytes(infile); newmbox.c NSM */ X*************** X*** 299,300 **** X--- 295,300 ---- X X+ #if 0 X+ /* X+ ** This `feature' is so buggy, it's dangerous. -- Chip X+ */ X case 'l' : PutLine0(LINES-3, strlen("Command: "), X*************** X*** 309,310 **** X--- 309,311 ---- X break; X+ #endif X XIndex: encode.c X*** elm1.7beta/src/encode.c Mon Nov 2 20:12:58 1987 X--- elm/src/encode.c Sat Dec 5 15:44:26 1987 X*************** X*** 133,134 **** X--- 133,142 ---- X { X+ #ifdef M_XENIX X+ X+ /** Sorry, Xenix hasn't got a crypt() function **/ X+ X+ encrypted_key = rkey; X+ X+ #else X+ X /** encrypt the key using the system routine 'crypt' **/ X*************** X*** 141,142 **** X--- 149,152 ---- X encrypted_key = crypt( key, salt); X+ X+ #endif X } XIndex: file.c X*** elm1.7beta/src/file.c Mon Nov 2 20:15:08 1987 X--- elm/src/file.c Wed Dec 9 09:44:12 1987 X*************** X*** 8,10 **** X #include "headers.h" X- #include X #include X--- 8,9 ---- X*************** X*** 11,16 **** X X- #ifdef BSD X- #undef tolower X- #endif X- X extern int errno; X--- 10,11 ---- X*************** X*** 19,20 **** X--- 14,16 ---- X unsigned long sleep(); X+ FILE *user_fopen(); X X*************** X*** 107,110 **** X X! if (access(filename,ACCESS_EXISTS)) /* already there!! */ X! appending = 1; X X--- 103,106 ---- X X! if (access(filename,ACCESS_EXISTS) == 0) /* already there!! */ X! ++appending; X X*************** X*** 110,127 **** X X! #ifdef BSD4_1 X! if ((errno = ((can_open(filename, "a") & ~0x0200) >>8))) { X! #else X! if ((errno = can_open(filename, "a"))) { X! #endif X! error1("Wrong permissions to save message to file %s!", filename); X! dprint(2, (debugfile, X! "Error: access permission on file %s denied (%s)! (save)\n", X! filename, error_name(errno))); X! header_table[current-1].status = oldstat; /* BACK! */ X! return(0); X! } X! X! dprint(4,(debugfile, "Saving mail to file '%s'...\n", filename)); X! X! if ((save_file = fopen(filename,"a")) == NULL) { X dprint(2, (debugfile, X--- 106,109 ---- X X! if ((save_file = user_fopen(filename,"a")) == NULL) { X! int err = errno; X dprint(2, (debugfile, X*************** X*** 127,129 **** X dprint(2, (debugfile, X! "Error: couldn't append to specified file %s (save)\n", X filename)); X--- 109,111 ---- X dprint(2, (debugfile, X! "Error: couldn't append message to file %s! (save)\n", X filename)); X*************** X*** 129,131 **** X filename)); X! error1("Couldn't append to file %s!", filename); X header_table[current-1].status = oldstat; /* BACK! */ X--- 111,116 ---- X filename)); X! dprint(2, (debugfile, "** %s - %s **\n", X! error_name(err), error_description(err))); X! error2("Couldn't append to file %s! (%s)", X! filename, error_description(err)); X header_table[current-1].status = oldstat; /* BACK! */ X*************** X*** 134,135 **** X--- 119,122 ---- X X+ dprint(4,(debugfile, "Saving mail to file '%s'...\n", filename)); X+ X for (i=0; i < message_count; i++) /* save each tagged msg */ X*************** X*** 175,177 **** X X! if (! appending) /* don't ask */ X error2("Message %d appended to file %s", number+1, filename); X--- 162,164 ---- X X! if (appending) X error2("Message %d appended to file %s", number+1, filename); XIndex: file_utils.c X*** elm1.7beta/src/file_utils.c Mon Nov 2 20:13:47 1987 X--- elm/src/file_utils.c Wed Dec 9 10:18:24 1987 X*************** X*** 10,12 **** X #include X- #include X #include X--- 10,11 ---- X*************** X*** 13,18 **** X X- #ifdef BSD X- # undef tolower X- #endif X- X #include X--- 12,13 ---- X*************** X*** 57,59 **** X int X! can_access(file, mode) X char *file; X--- 52,54 ---- X int X! user_access(file, mode) X char *file; X*************** X*** 61,63 **** X { X! /** returns ZERO iff user can access file or "errno" otherwise **/ X X--- 56,59 ---- X { X! /** returns 0 iff user can access file, -1 otherwise. X! errno is set appropriately. **/ X X*************** X*** 63,80 **** X X! int the_stat = 0, pid, w; X! void _exit(), exit(); X! #ifdef BSD X! union wait status; X! #else X! int status; X! #endif X! register int (*istat)(), (*qstat)(); X! X! #ifdef NO_VM /* machine without virtual memory!! */ X! if ((pid = fork()) == 0) { X! #else X! if ((pid = vfork()) == 0) { X! #endif X! setgid(groupid); X! setuid(userid); /** back to normal userid **/ X X--- 59,63 ---- X X! /** This routine used to fork() etc. just like user_fopen(). X! With fopen() I can live with it, but here, I just can't. X! Thus we simulate the kernel's access() processing. **/ X X*************** X*** 80,82 **** X X! errno = 0; X X--- 63,66 ---- X X! struct stat st; X! int filemode; X X*************** X*** 82,89 **** X X! if (access(file, mode) == 0) X! _exit(0); X! else X! _exit(errno != 0? errno : 1); /* never return zero! */ X! _exit(127); X! } X X--- 66,71 ---- X X! if (stat(file, &st) != 0) X! return (-1); X! if (mode == 0) X! return (0); X X*************** X*** 89,92 **** X X! istat = signal(SIGINT, SIG_IGN); X! qstat = signal(SIGQUIT, SIG_IGN); X X--- 71,78 ---- X X! filemode = st.st_mode & 0777; X! if (userid == st.st_uid) X! filemode >>= 6; X! else if (userid == st.st_gid) X! filemode >>= 3; X! filemode &= 07; X X*************** X*** 92,95 **** X X! while ((w = wait(&status)) != pid && w != -1) X! ; X X--- 78,81 ---- X X! if ((filemode & mode) == mode) X! return (0); X X*************** X*** 95,106 **** X X! #ifdef BSD X! the_stat = status.w_retcode; X! #else X! the_stat = status; X! #endif X! X! signal(SIGINT, istat); X! signal(SIGQUIT, qstat); X! X! return(the_stat); X } X--- 81,84 ---- X X! errno = EACCES; X! return (-1); X } X*************** X*** 107,110 **** X X! int X! can_open(file, mode) X char *file, *mode; X--- 85,88 ---- X X! FILE * X! user_fopen(file, mode) X char *file, *mode; X*************** X*** 111,115 **** X { X! /** Returns 0 iff user can open the file. This is not X! the same as can_access - it's used for when the file might X! not exist... **/ X X--- 89,94 ---- X { X! /** Returns result of `real' user trying to open the given file. X! (Original UID and GID are used.) This is used for cases when X! the file might already exist -- if, for example, it's owned by X! bin, elm may open it but the user shouldn't be allowed to. **/ X X*************** X*** 115,118 **** X X! FILE *fd; X! int the_stat = 0, pid, w; X void _exit(), exit(); X--- 94,96 ---- X X! int pid, err, w; X void _exit(), exit(); X*************** X*** 130,131 **** X--- 108,111 ---- X #endif X+ FILE *fp; X+ X setgid(groupid); X*************** X*** 133,135 **** X errno = 0; X! if ((fd = fopen(file, mode)) == NULL) X _exit(errno); X--- 113,115 ---- X errno = 0; X! if ((fp = fopen(file, mode)) == NULL) X _exit(errno); X*************** X*** 136,138 **** X else { X! fclose(fd); /* don't just LEAVE it! */ X _exit(0); X--- 116,118 ---- X else { X! fclose(fp); /* don't just LEAVE it! */ X _exit(0); X*************** X*** 148,149 **** X--- 128,132 ---- X X+ signal(SIGINT, istat); X+ signal(SIGQUIT, qstat); X+ X #ifdef BSD X*************** X*** 149,151 **** X #ifdef BSD X! the_stat = status.w_retcode; X #else X--- 132,134 ---- X #ifdef BSD X! err = status.w_retcode; X #else X*************** X*** 151,153 **** X #else X! the_stat = status; X #endif X--- 134,136 ---- X #else X! err = status >> 8; X #endif X*************** X*** 154,159 **** X X! signal(SIGINT, istat); X! signal(SIGQUIT, qstat); X! X! return(the_stat); X } X--- 137,152 ---- X X! /* X! * Go ahead and open the file (if child said it was okay). X! * Leave error code in errno for use by caller. X! * Return result of fopen(). X! * (New code by Chip, 9 Dec 1987) X! */ X! if (err) { X! errno = err; X! return (NULL); X! } X! else { X! errno = 0; X! return(fopen(file, mode)); X! } X } XIndex: fileio.c X*** elm1.7beta/src/fileio.c Mon Nov 2 20:12:16 1987 X--- elm/src/fileio.c Mon Dec 7 12:53:50 1987 X*************** X*** 10,12 **** X #include X- #include X #include X--- 10,11 ---- X*************** X*** 12,17 **** X #include X- X- #ifdef BSD X- #undef tolower X- #endif X X--- 11,12 ---- XIndex: hdrconfg.c X*** elm1.7beta/src/hdrconfg.c Mon Nov 2 20:13:52 1987 X--- elm/src/hdrconfg.c Mon Dec 7 12:54:02 1987 X*************** X*** 25,32 **** X X- #include X- X- #ifdef BSD X- #undef toupper X- #endif X- X /* these are all defined in the mailmsg file! */ X--- 25,26 ---- XIndex: help.c X*** elm1.7beta/src/help.c Mon Nov 2 20:14:38 1987 X--- elm/src/help.c Mon Dec 7 12:54:08 1987 X*************** X*** 8,15 **** X X- #include X- X- #ifdef BSD X- # undef tolower X- #endif X- X #include "headers.h" X--- 8,9 ---- XIndex: initialize.c X*** elm1.7beta/src/initialize.c Mon Nov 2 20:17:17 1987 X--- elm/src/initialize.c Wed Dec 9 10:04:36 1987 X*************** X*** 23,25 **** X #include X- #include X #include X--- 23,24 ---- X*************** X*** 26,32 **** X X- #ifdef BSD X- #undef toupper X- #undef tolower X- #endif X- X extern int errno; /* system error number on failure */ X--- 25,26 ---- X*************** X*** 189,191 **** X (void) expand_filename(infile); X! if ((errno = can_access(infile, READ_ACCESS))) { X dprint(1, (debugfile, X--- 183,186 ---- X (void) expand_filename(infile); X! if (user_access(infile, READ_ACCESS) != 0) { X! int err = errno; X dprint(1, (debugfile, X*************** X*** 192,195 **** X "Error: given file %s as mailbox - unreadable (%s)!\n", X! infile, error_name(errno))); X! fprintf(stderr,"Can't open mailbox '%s' for reading!\n", infile); X exit(1); X--- 187,191 ---- X "Error: given file %s as mailbox - unreadable (%s)!\n", X! infile, error_name(err))); X! fprintf(stderr,"Can't open mailbox %s! (%s)\n", X! infile, error_description(err)); X exit(1); XIndex: input_utils. X*** elm1.7beta/src/input_utils.c Mon Nov 2 20:17:22 1987 X--- elm/src/input_utils.c Wed Dec 9 15:31:02 1987 X*************** X*** 9,11 **** X #include X- #include X X--- 9,10 ---- X*************** X*** 11,16 **** X X- #ifdef BSD X- # undef tolower X- #endif X- X extern int errno; /* system error number */ X--- 10,11 ---- X*************** X*** 26,28 **** X want_to(question, dflt, echo_answer) X! char *question, dflt; X int echo_answer; X--- 21,24 ---- X want_to(question, dflt, echo_answer) X! char *question; X! char dflt; X int echo_answer; X*************** X*** 34,36 **** X **/ X! register char ch, cols; X X--- 30,32 ---- X **/ X! char ch; X X*************** X*** 36,38 **** X X! cols = (strlen(question) < 30)? COLUMNS-40 : COLUMNS-50; X X--- 32,38 ---- X X! if (question != NULL) { X! int cols = (strlen(question) < 30)? COLUMNS-40 : COLUMNS-50; X! PutLine3(LINES-3, cols, "%s%c%c", question, dflt, BACKSPACE); X! fflush(stdout); X! } X X*************** X*** 38,47 **** X X! PutLine3(LINES-3, cols,"%s%c%c", question, dflt, BACKSPACE); X! fflush(stdout); X! fflush(stdin); X! X! ch = tolower(ReadCh()); X! X! if (echo_answer && ch > (char) ' ') { X! Writechar(ch); X fflush(stdout); X--- 38,42 ---- X X! ch = yesno(dflt); X! if (echo_answer) { X! Write_to_screen((ch == 'y') ? "Yes" : "No", 0); X fflush(stdout); X*************** X*** 49,51 **** X X! return(ch == '\n' || ch == '\r' ? dflt : ch); X } X--- 44,67 ---- X X! return(ch); X! } X! X! int X! yesno(dflt) X! char dflt; X! { X! char ch; X! X! fflush(stdin); X! X! do { X! ch = tolower(ReadCh()); X! switch (ch) { X! case '\r': X! case '\n': X! ch = dflt; X! break; X! } X! } while ((ch != 'y') && (ch != 'n')); X! X! return (ch); X } XIndex: leavembox.c X*** elm1.7beta/src/leavembox.c Mon Nov 2 20:08:37 1987 X--- elm/src/leavembox.c Tue Dec 22 16:49:52 1987 X*************** X*** 1,2 **** X! /** leavembox.c **/ X X--- 1,2 ---- X! /** leavembox.c **/ X X*************** X*** 15,17 **** X X! #define ECHOIT 1 /* echo on for prompting! */ X X--- 15,17 ---- X X! #define ECHOIT TRUE /* echo on for prompting! */ X X*************** X*** 28,31 **** X X- extern int errno; X- X char *error_name(), *error_description(), *strcpy(); X--- 28,29 ---- X*************** X*** 33,34 **** X--- 31,33 ---- X unsigned long sleep(); X+ FILE *user_fopen(); X X*************** X*** 34,35 **** X--- 33,39 ---- X X+ extern int errno; X+ X+ /* Name of mailbox lock file -- if empty, mailbox is not locked */ X+ static char cur_lockfile[SLEN]; X+ X int X*************** X*** 200,205 **** X if (to_save) { X! if ((errno = can_open(outfile, "a"))) { X! error1( X! "Permission to append to %s denied! Leaving mailbox intact\n", X! outfile); X dprint(1, (debugfile, X--- 204,207 ---- X if (to_save) { X! if ((temp = user_fopen(outfile,"a")) == NULL) { X! int err = errno; X dprint(1, (debugfile, X*************** X*** 205,214 **** X dprint(1, (debugfile, X! "Error: Permission to append to outfile %s denied!! (%s)\n", X! outfile, "leavembox")); X! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno), X! error_description(errno))); X! unlock(); X! return(0); X! } X! if ((temp = fopen(outfile,"a")) == NULL) { X if (mbox_specified == 0) X--- 207,214 ---- X dprint(1, (debugfile, X! "Error: Couldn't append to outfile %s!! (leavembox)\n", X! outfile)); X! dprint(1, (debugfile, "** %s - %s **\n", X! error_name(err), error_description(err))); X! error2("Couldn't append to file %s! (%s)", X! outfile, error_description(err)); X if (mbox_specified == 0) X*************** X*** 215,224 **** X unlock(); /* remove mailfile lock! */ X! dprint(1, (debugfile, "Error: could not append to file %s\n", X! outfile)); X! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno), X! error_description(errno))); X! sprintf(buffer, " Could not append to file %s! ", X! outfile); X! Centerline(LINES-1, buffer); X! emergency_exit(); X } X--- 215,217 ---- X unlock(); /* remove mailfile lock! */ X! return(0); X } X*************** X*** 245,246 **** X--- 238,240 ---- X if (stat(infile, &buf) != 0) { /* grab original times... */ X+ int err = errno; X dprint(1, (debugfile, "Error: errno %s attempting to stat file %s\n", X*************** X*** 246,250 **** X dprint(1, (debugfile, "Error: errno %s attempting to stat file %s\n", X! error_name(errno), infile)); X! error3("Error %s (%s) on stat(%s)", error_name(errno), X! error_description(errno), infile); X } X--- 240,244 ---- X dprint(1, (debugfile, "Error: errno %s attempting to stat file %s\n", X! error_name(err), infile)); X! error3("Error %s (%s) on stat(%s)", error_name(err), X! error_description(err), infile); X } X*************** X*** 348,351 **** X X- char lock_name[SLEN]; X- X lock(direction) X--- 342,343 ---- X*************** X*** 366,368 **** X X! register int iteration = 0, access_val, lock_fd; X X--- 358,361 ---- X X! int iteration, fd, locked = FALSE, err = 0; X! char lockfile[SLEN], locktemp[SLEN]; X X*************** X*** 368,370 **** X X! sprintf(lock_name,"%s%s.lock", mailhome, username); X X--- 361,363 ---- X X! unlock(); /* Just in case! */ X X*************** X*** 370,372 **** X X! access_val = access(lock_name, ACCESS_EXISTS); X X--- 363,365 ---- X X! get_locknames(lockfile, locktemp); X X*************** X*** 372,377 **** X X! while (access_val != -1 && iteration++ < MAX_ATTEMPTS) { X! dprint(2, (debugfile, X! "File '%s' currently exists! Waiting...(lock)\n", X! lock_name)); X if (direction == INCOMING) X--- 365,372 ---- X X! if ((fd = creat(locktemp, 0)) == -1) { X! dprint(1, (debugfile, "Can't create temp file '%s'\n", locktemp)); X! PutLine1(LINES-1, 0, X! "I couldn't create the temp file '%s'", locktemp); X! PutLine2(LINES, 0, "** %s - %s **", error_name(errno), X! error_description(errno)); X if (direction == INCOMING) X*************** X*** 377,379 **** X if (direction == INCOMING) X! PutLine0(LINES, 0, "Mail being received!\twaiting..."); X else X--- 372,374 ---- X if (direction == INCOMING) X! leave(); X else X*************** X*** 379,384 **** X else X! error1("Attempt %d: Mail being received...waiting", X! iteration); X! sleep(5); X! access_val = access(lock_name, ACCESS_EXISTS); X } X--- 374,376 ---- X else X! emergency_exit(); X } X*************** X*** 384,387 **** X } X! X! if (access_val != -1) { X X--- 376,378 ---- X } X! close(fd); X X*************** X*** 387,388 **** X--- 378,409 ---- X X+ for (;;) { X+ X+ /** Try MAX_ATTEMPTS times to link locktemp to lockfile. **/ X+ X+ for (iteration = 0; iteration < MAX_ATTEMPTS; ++iteration) { X+ if (link(locktemp, lockfile) == 0) { X+ locked = TRUE; X+ break; X+ } X+ X+ /* We expect EEXIST; all others are real problems. */ X+ X+ if (errno != EEXIST) { X+ dprint(1, (debugfile, X+ "Can't create lock file '%s' -- %s (lock)\n", X+ lockfile, error_name(errno))); X+ leave(error1("Can't create lock file '%s'!", lockfile)); X+ } X+ X+ if (direction == INCOMING) X+ PutLine0(LINES, 0, "Mail being received! Waiting..."); X+ else X+ error1("Attempt %d: Mail being received! Waiting...", iteration); X+ X+ sleep(5); X+ } X+ X+ if (locked) X+ break; X+ X #ifdef REMOVE_AT_LAST X*************** X*** 398,400 **** X X! if (unlink(lock_name) != 0) { X dprint(1, (debugfile, X--- 419,421 ---- X X! if (unlink(lockfile) != 0) { X dprint(1, (debugfile, X*************** X*** 400,407 **** X dprint(1, (debugfile, X! "Error %s (%s)\n\ttrying to unlink file %s (%s)\n", X! error_name(errno), error_description(errno), lock_name)); X! PutLine1(LINES, 0, X! "\n\rI couldn't remove the current lock file %s\n\r", X! lock_name); X! PutLine2(LINES, 0, "** %s - %s **\n\r", error_name(errno), X error_description(errno)); X--- 421,428 ---- X dprint(1, (debugfile, X! "Error %s (%s)\n\ttrying to unlink file %s\n", X! error_name(errno), error_description(errno), lockfile)); X! PutLine1(LINES-1, 0, X! "I couldn't remove the current lock file '%s'", X! lockfile); X! PutLine2(LINES, 0, "** %s - %s **", error_name(errno), X error_description(errno)); X*************** X*** 407,408 **** X--- 428,431 ---- X error_description(errno)); X+ X+ unlink(locktemp); X if (direction == INCOMING) X*************** X*** 413,415 **** X X! /* everything is okay, so lets act as if nothing had happened... */ X X--- 436,438 ---- X X! /* and go through the loop again... */ X X*************** X*** 415,417 **** X X! #else X X--- 438,440 ---- X X! #else /* !REMOTE_AT_LAST */ X X*************** X*** 419,420 **** X--- 442,446 ---- X any of those! */ X+ X+ lockfile[0] = '\0'; /* Don't let unlock() remove it! */ X+ X if (direction == INCOMING) { X*************** X*** 423,427 **** X "Please try to read your mail again in a few minutes.\n"); X! dprint(2, (debugfile, X! "Warning: bailing out after %d iterations...(lock)\n", X! iteration)); X leave_locked(0); X--- 449,452 ---- X "Please try to read your mail again in a few minutes.\n"); X! dprint(2, (debugfile,"Giving up after %d iterations...(lock)\n", X! iteration)); X leave_locked(0); X*************** X*** 438,440 **** X X! /* if we get here we can create the lock file, so lets do it! */ X X--- 463,465 ---- X X! /** We're locked! Remove the original link and return. **/ X X*************** X*** 440,464 **** X X! if ((lock_fd = creat(lock_name, 0)) == -1) { X! dprint(1, (debugfile, X! "Can't create lock file: creat(%s) raises error %s (lock)\n", X! lock_name, error_name(errno))); X! if (errno == EACCES) X! leave(error1( X! "Can't create lock file! I need write permission in %s!\n\r", X! mailhome)); X! else { X! dprint(1, (debugfile, X! "Error encountered attempting to create lock %s\n", X! lock_name)); X! dprint(1, (debugfile, "** %s - %s **\n", error_name(errno), X! error_description(errno))); X! PutLine1(LINES, 0, X! "\n\rError encountered while attempting to create lock file %s;\n\r", X! lock_name); X! PutLine2(LINES, 0, "** %s - %s **\n\r", error_name(errno), X! error_description(errno)); X! leave(); X! } X! } X! close(lock_fd); /* close it. We don't want to KEEP the thing! */ X } X--- 465,468 ---- X X! unlink(locktemp); X! strcpy(cur_lockfile, lockfile); X } X*************** X*** 471,473 **** X X! (void) unlink(lock_name); X } X--- 475,506 ---- X X! /** By Chip -- only unlink it once. This prevents inadvertent X! removing of a lock file that I didn't create. **/ X! X! if (cur_lockfile[0]) { X! (void) unlink(cur_lockfile); X! cur_lockfile[0] = '\0'; X! } X! } X! X! get_locknames(n, t) X! char *n; X! char *t; X! { X! static char locktemp[SLEN]; X! X! #ifdef M_XENIX X! sprintf(n, "/tmp/%s.mlk", username); X! #else X! sprintf(n, "%s%s.lock", mailhome, username); X! #endif X! X! if (locktemp[0] == '\0') { X! #ifdef M_XENIX X! sprintf(locktemp, "/tmp/Elm.XXXXXX"); X! #else X! sprintf(locktemp, "%sElm.XXXXXX", mailhome); X! #endif X! mktemp(locktemp); X! } X! strcpy(t, locktemp); X } XIndex: limit.c X*** elm1.7beta/src/limit.c Mon Nov 2 20:15:15 1987 X--- elm/src/limit.c Wed Dec 9 15:38:25 1987 X*************** X*** 32,35 **** X BACKSPACE); X! criteria[0] = ReadCh(); X! if (tolower(criteria[0]) == 'y') X PutLine0(LINES-3, COLUMNS-30, "Adding criteria..."); X--- 32,35 ---- X BACKSPACE); X! criteria[0] = want_to((char *)NULL, 'n', TRUE); X! if (criteria[0] == 'y') X PutLine0(LINES-3, COLUMNS-30, "Adding criteria..."); X*************** X*** 39,41 **** X } X- X } X--- 39,40 ---- SHAR_EOF if test 27008 -ne `wc -c < 'p.src.1'` then echo 'shar: error transmitting "p.src.1" (should have been 27008 characters) ' fi chmod 644 'p.src.1' fi # end of overwriting check # End of shell archive exit 0 -- Chip Salzenberg UUCP: "{codas,uunet}!ateng!chip" A T Engineering My employer's opinions are a trade secret. "Anything that works is better than anything that doesn't."