actual patch

Deven T. Corzine (deven@asylum.sf.ca.us)
Tue, 06 Dec 1994 03:15:47 -0500

Here's that patch... If it doesn't apply cleanly, you can still FTP it from
asylum.sf.ca.us:/pub/u/deven/lily-patch.gz -- let me know when to toss that.

Deven

diff -cr lclient0.8b-orig/Make.config lclient0.8b/Make.config
*** lclient0.8b-orig/Make.config Fri Oct 14 20:16:07 1994
--- lclient0.8b/Make.config Tue Dec 6 02:14:02 1994
***************
*** 29,34 ****
--- 29,37 ----
PAGE_DEFAULT_VAL = 24
#PAGE_DEFAULT_VAL = 0

+ # More prompt update frequency default. 0 is off.
+ UPD_FREQ_DEFAULT_VAL = 1
+
# This is the command that plays sounds on your machine "" for no sound
# SGI is "/usr/sbin/sfplay"
# Sun is "/usr/demo/SOUND/play"
***************
*** 47,54 ****
CC = gcc

# Select the appropriate ranlib path for re_strcmp and readline
! #RANLIB = /usr/bin/ranlib
! RANLIB = /bin/ranlib
# IRIX, A/UX and SOLARIS do not need ranlib
#RANLIB =

--- 50,57 ----
CC = gcc

# Select the appropriate ranlib path for re_strcmp and readline
! RANLIB = /usr/bin/ranlib
! #RANLIB = /bin/ranlib
# IRIX, A/UX and SOLARIS do not need ranlib
#RANLIB =

***************
*** 107,113 ****
RM = /bin/rm -f
LIBPATH = -L./readline -L./re_strcmp

! ALL_DEFINES = $(DEFINES) -DPAGE_DEFAULT=$(PAGE_DEFAULT_VAL) -DSNDCMD=\"$(SNDCMD)\" -DL_HOST=\"$(DEFAULT_HOST)\"

.c.o:
$(RM) $@
--- 110,116 ----
RM = /bin/rm -f
LIBPATH = -L./readline -L./re_strcmp

! ALL_DEFINES = $(DEFINES) -DPAGE_DEFAULT=$(PAGE_DEFAULT_VAL) -DUPD_FREQ_DEFAULT=$(UPD_FREQ_DEFAULT_VAL) -DSNDCMD=\"$(SNDCMD)\" -DL_HOST=\"$(DEFAULT_HOST)\"

.c.o:
$(RM) $@
Only in lclient0.8b: cmds.o
Only in lclient0.8b: help.o
Only in lclient0.8b: lily
diff -cr lclient0.8b-orig/lily.c lclient0.8b/lily.c
*** lclient0.8b-orig/lily.c Fri Oct 14 20:16:08 1994
--- lclient0.8b/lily.c Tue Dec 6 02:27:58 1994
***************
*** 178,192 ****
* the appropriate servicing routine is called; _UNLESS_ it is an exception.
* In that case we break out of the loop and shutdown the interface. We will
* do the same thing should the call to select fault.
! * For historical reasons [to please Phil <kutcha@acm.rpi.edu> and Linux]
! * the timeout of the select() is about 5 seconds. Anything less than that
! * turns into a busy-wait under the Linux scheduler.
*/
void main_loop()
{
fd_set r_fd, /* the fd bitmasks for read and exceptions */
x_fd;
struct timeval tmv; /* the timeout structure for the select() */

/* clear out the fd bitmasks
*/
--- 178,197 ----
* the appropriate servicing routine is called; _UNLESS_ it is an exception.
* In that case we break out of the loop and shutdown the interface. We will
* do the same thing should the call to select fault.
! *
! * The select() timeout must be initialized INSIDE the select() loop, since
! * Linux updates the timeout to reflect the remaining portion, and other
! * systems (e.g. SunOS) warn they might (and likely should) do this later.
*/
void main_loop()
{
+ time_t server_update_time = 0;
+ time_t now;
+
fd_set r_fd, /* the fd bitmasks for read and exceptions */
x_fd;
struct timeval tmv; /* the timeout structure for the select() */
+ struct timeval *tmvp; /* pointer to timeout structure */

/* clear out the fd bitmasks
*/
***************
*** 207,221 ****
FD_SET(sock, &r_fd);
FD_SET(sock, &x_fd);

! /* setup the sleep period for select()
! * Linuxites report that this should fix their busyloop problem
! */
! tmv.tv_sec = 5;
! tmv.tv_usec = 0;

/* go ahead and select, unlike most software watch for faults
*/
! if ((nfds = select(sock+1, &r_fd, 0, &x_fd, &tmv)) < 0) {
/* getting an EINTR is okay, just ignore it
*/
if (errno != EINTR) {
--- 212,236 ----
FD_SET(sock, &r_fd);
FD_SET(sock, &x_fd);

! /* Setup the select() timeout. */
! now = time(NULL);
! if (server_update_time) {
! /* Calculate server update timeout. */
! if (server_update_time > now + server_update_frequency) {
! server_update_time = now + server_update_frequency;
! }
! tmv.tv_sec = server_update_time - now;
! if (server_update_time <= now) tmv.tv_sec = 0;
! tmv.tv_usec = 0;
! tmvp = &tmv;
! } else {
! /* No timeout, block forever. */
! tmvp = NULL;
! }

/* go ahead and select, unlike most software watch for faults
*/
! if ((nfds = select(sock+1, &r_fd, 0, &x_fd, tmvp)) < 0) {
/* getting an EINTR is okay, just ignore it
*/
if (errno != EINTR) {
***************
*** 227,235 ****
}
}

! /* there were no events, so just skip right back into the loop
! */
! if (!nfds) continue;

/* if there was input from the user process it _first_ so the
* interface looks zippy
--- 242,249 ----
}
}

! /* Continue even if there's no input, to process update timeout. */
! now = time(NULL);

/* if there was input from the user process it _first_ so the
* interface looks zippy
***************
*** 238,244 ****

/* if there was input from the network, process it
*/
! if (FD_ISSET(sock, &r_fd)) if (!net_service()) return;

/* if there was an exception on the server, shutdown
*/
--- 252,295 ----

/* if there was input from the network, process it
*/
! if (FD_ISSET(sock, &r_fd)) {
! /* Process server input. */
! if (!net_service()) return;
!
! /* Handle server update timeout. */
! if (server_update_frequency) {
! if (server_update_time == 0) {
! if (to_ui_lines_queued) {
! /* Server has become unidle with lines queued. */
! at_least = " [at least]";
! display_prompt(YES);
! server_update_time = now + server_update_frequency;
! }
! } else {
! if (server_update_time <= now) {
! /* Time to update more prompt. */
! if (to_ui_lines_queued) display_prompt(YES);
! server_update_time += server_update_frequency;
! }
! }
! } else {
! if (server_update_time) {
! /* Periodic updates have been disabled. */
! at_least = "";
! if (to_ui_lines_queued) display_prompt(YES);
! }
! server_update_time = 0;
! }
! } else {
! /* No server input, check for timeout. */
! if (server_update_time && (server_update_time <= now ||
! server_update_frequency == 0)) {
! /* Server has become idle. */
! at_least = "";
! if (to_ui_lines_queued) display_prompt(YES);
! server_update_time = 0;
! }
! }

/* if there was an exception on the server, shutdown
*/
***************
*** 336,342 ****
int to_ui_lines_queued; /* the number of lines pending */
int output_lines = 0; /* number of lines printed */

-
char l_hostname[HOSTSIZE]; /* name of the lily server host */
u_short l_port = 7777; /* what is the port number */
struct sockaddr_in saddr; /* the socket address structure */
--- 387,392 ----
***************
*** 344,349 ****
--- 394,405 ----

char l_sndcmd[BUFSIZ]; /* the command to play a sound */
char l_sndfile[BUFSIZ]; /* the file to play when %g comes through */
+
+ /* Number of seconds between updates of the more prompt for server output. */
+ unsigned int server_update_frequency = UPD_FREQ_DEFAULT;
+
+ /* Pointer to either " [at least]" or "" (for more prompt). */
+ char *at_least = "";


int main(argc, argv)
diff -cr lclient0.8b-orig/lily.h lclient0.8b/lily.h
*** lclient0.8b-orig/lily.h Fri Oct 14 20:29:51 1994
--- lclient0.8b/lily.h Tue Dec 6 02:27:37 1994
***************
*** 55,61 ****
#define HOSTSIZE 64 /* max size of a hostname */
#define MAX_P_REC 12 /* max # of recip. remembered */

! #define BUFFER_MSG "--More--(%d %s pending)"

#define YES 1
#define NO 0
--- 55,61 ----
#define HOSTSIZE 64 /* max size of a hostname */
#define MAX_P_REC 12 /* max # of recip. remembered */

! #define BUFFER_MSG "--More--(%d %s pending)%s"

#define YES 1
#define NO 0
***************
*** 76,83 ****
* on the command line with -P, or
* PAGE_DEFAULT */
extern lqueue_t *to_server_q; /* when messages to server are buffered */
! extern int to_ui_lines_queued; /* the number of lines per page */
! extern int output_lines; /* lines that have been printed */

extern char l_hostname[HOSTSIZE]; /* name of the lily server host */
extern u_short l_port; /* what is the port number */
--- 76,83 ----
* on the command line with -P, or
* PAGE_DEFAULT */
extern lqueue_t *to_server_q; /* when messages to server are buffered */
! extern int to_ui_lines_queued; /* the number of lines pending */
! extern int output_lines; /* number of lines printed */

extern char l_hostname[HOSTSIZE]; /* name of the lily server host */
extern u_short l_port; /* what is the port number */
***************
*** 100,105 ****
--- 100,110 ----
extern int rl_done;
extern int readline_echoing_p;

+ /* Number of seconds between updates of the more prompt for server output. */
+ extern unsigned int server_update_frequency;
+
+ /* Pointer to either " [at least]" or "" (for more prompt). */
+ extern char *at_least;

/*
* Externals
Only in lclient0.8b: lily.o
diff -cr lclient0.8b-orig/parsers.c lclient0.8b/parsers.c
*** lclient0.8b-orig/parsers.c Fri Oct 14 20:16:09 1994
--- lclient0.8b/parsers.c Tue Dec 6 02:28:27 1994
***************
*** 292,308 ****

if (verbose)
(void)sprintf(buffer_prompt, BUFFER_MSG, to_ui_lines_queued,
! (to_ui_lines_queued == 1) ? "line" : "lines");
if (!no_readline) {
co = strlen(buffer_prompt);
for(co = strlen(buffer_prompt); co<line_width; co++ ){
buffer_prompt[co] = ' ';
}
buffer_prompt[line_width] = '\0';
rl_message(buffer_prompt,0,0);
} else if (output_lines == page_size) {
(void)sprintf(buffer_prompt, BUFFER_MSG, to_ui_lines_queued,
! (to_ui_lines_queued == 1) ? "line" : "lines");
printf((!verbose) ? NULL : buffer_prompt);
fflush(stdout);
}
--- 292,309 ----

if (verbose)
(void)sprintf(buffer_prompt, BUFFER_MSG, to_ui_lines_queued,
! (to_ui_lines_queued == 1) ? "line" : "lines", at_least);
if (!no_readline) {
co = strlen(buffer_prompt);
for(co = strlen(buffer_prompt); co<line_width; co++ ){
buffer_prompt[co] = ' ';
}
buffer_prompt[line_width] = '\0';
+ rl_clear_message();
rl_message(buffer_prompt,0,0);
} else if (output_lines == page_size) {
(void)sprintf(buffer_prompt, BUFFER_MSG, to_ui_lines_queued,
! (to_ui_lines_queued == 1) ? "line" : "lines", at_least);
printf((!verbose) ? NULL : buffer_prompt);
fflush(stdout);
}
Only in lclient0.8b: parsers.o
Only in lclient0.8b: queue.o
Only in lclient0.8b/re_strcmp: librestrcmp.a
Only in lclient0.8b/re_strcmp: regerror.o
Only in lclient0.8b/re_strcmp: regex.o
Only in lclient0.8b/re_strcmp: regexp.o
Only in lclient0.8b/re_strcmp: regsub.o
Only in lclient0.8b/readline: funmap.o
Only in lclient0.8b/readline: history.o
Only in lclient0.8b/readline: keymaps.o
Only in lclient0.8b/readline: libreadline.a
Only in lclient0.8b/readline: readline.o
Only in lclient0.8b: signalling.o
diff -cr lclient0.8b-orig/utils.c lclient0.8b/utils.c
*** lclient0.8b-orig/utils.c Fri Oct 14 20:16:09 1994
--- lclient0.8b/utils.c Tue Dec 6 00:02:35 1994
***************
*** 143,149 ****
for (x = 0; msg[x] != '\0'; x++)
if (msg[x] == '\n') to_ui_lines_queued++;

! if (to_ui_lines_queued) display_prompt(YES);
/* we just received a message, and we could not print it right
* away, so we should have at least 1 line on the queue, right?
* nope. Not all messages have a \n in them.
--- 143,150 ----
for (x = 0; msg[x] != '\0'; x++)
if (msg[x] == '\n') to_ui_lines_queued++;

! if (to_ui_lines_queued && !server_update_frequency) display_prompt(YES);
!
/* we just received a message, and we could not print it right
* away, so we should have at least 1 line on the queue, right?
* nope. Not all messages have a \n in them.
Only in lclient0.8b: utils.o