This is usefull in places where lclient is launched directly in an xterm
(from a window manager menu.) Without the -w flag, the xterm will not
stay around long enough for the user to read the error or info message
that lclient prints upon exiting.
(I have also built the 0.8b-post lclient with the latest version of readline.
The fixes were minor, and I will email those if anyone expresses interest.)
Enjoy,
-Shiv
-=-
------------------------cut-here-for-patch-------------------------------
diff -cr lily/cmds.c lily.new/cmds.c
*** lily/cmds.c Sat Dec 17 14:24:24 1994
--- lily.new/cmds.c Sun May 4 12:53:47 1997
***************
*** 675,679 ****
printf("(logging out)\n");
input_shutdown();
net_shutdown();
! exit(0);
}
--- 675,679 ----
printf("(logging out)\n");
input_shutdown();
net_shutdown();
! lazy_exit(0);
}
diff -cr lily/lily.c lily.new/lily.c
*** lily/lily.c Wed Jan 4 11:20:07 1995
--- lily.new/lily.c Sun May 4 12:57:12 1997
***************
*** 457,470 ****
/* scan through the arguments list and handle them all nicely
*/
! while ((opt = getopt(argc, argv, "PhprSldtsf")) != -1) {
switch (opt) {
case 'P': /* paging */
if (optind >= argc) {
printf("\nyou must provide a value for the page size with -P\n");
(void)fprintf(stderr, "%s", USAGE);
! exit(-1);
}
def_page_size = page_size = atoi(argv[optind++]) - 2;
break;
--- 457,470 ----
/* scan through the arguments list and handle them all nicely
*/
! while ((opt = getopt(argc, argv, "PhprSldtsfw")) != -1) {
switch (opt) {
case 'P': /* paging */
if (optind >= argc) {
printf("\nyou must provide a value for the page size with -P\n");
(void)fprintf(stderr, "%s", USAGE);
! lazy_exit(-1);
}
def_page_size = page_size = atoi(argv[optind++]) - 2;
break;
***************
*** 477,487 ****
if (optind >= argc) {
printf("\nyou must provide a value for a host with -h\n");
(void)fprintf(stderr, "%s", USAGE);
! exit(-1);
}
if (strlen(argv[optind]) >= HOSTSIZE) {
(void)fprintf(stderr, "%s: hostname too long\n", argv[0]);
! exit(2);
}
(void)strcpy(l_hostname, argv[optind++]);
break;
--- 477,487 ----
if (optind >= argc) {
printf("\nyou must provide a value for a host with -h\n");
(void)fprintf(stderr, "%s", USAGE);
! lazy_exit(-1);
}
if (strlen(argv[optind]) >= HOSTSIZE) {
(void)fprintf(stderr, "%s: hostname too long\n", argv[0]);
! lazy_exit(2);
}
(void)strcpy(l_hostname, argv[optind++]);
break;
***************
*** 490,496 ****
if (optind >= argc) {
printf("\nyou must provide a value for the port with -p\n");
(void)fprintf(stderr, "%s", USAGE);
! exit(-1);
}
l_port = atoi(argv[optind++]);
break;
--- 490,496 ----
if (optind >= argc) {
printf("\nyou must provide a value for the port with -p\n");
(void)fprintf(stderr, "%s", USAGE);
! lazy_exit(-1);
}
l_port = atoi(argv[optind++]);
break;
***************
*** 503,509 ****
if (optind >= argc) {
printf("\nyou must provide a value for the log file with -l\n");
(void)fprintf(stderr, "%s", USAGE);
! exit(-1);
}
longname = tilde_expand(argv[optind++]);
strcpy(log_filename, longname);
--- 503,509 ----
if (optind >= argc) {
printf("\nyou must provide a value for the log file with -l\n");
(void)fprintf(stderr, "%s", USAGE);
! lazy_exit(-1);
}
longname = tilde_expand(argv[optind++]);
strcpy(log_filename, longname);
***************
*** 512,518 ****
printf("\nUnable to open file %s for logging\n", log_filename);
printf("Start lily again with a logfile you can write to, or");
printf(" without logging\n");
! exit(3);
}
break;
--- 512,518 ----
printf("\nUnable to open file %s for logging\n", log_filename);
printf("Start lily again with a logfile you can write to, or");
printf(" without logging\n");
! lazy_exit(3);
}
break;
***************
*** 524,530 ****
if (optind >= argc) {
printf("\nyou must provide a value for tabbing with -t\n");
(void)fprintf(stderr, "%s", USAGE);
! exit(-1);
}
if (!strcasecmp(argv[optind++], "irc")) irc_tabbing = YES;
--- 524,530 ----
if (optind >= argc) {
printf("\nyou must provide a value for tabbing with -t\n");
(void)fprintf(stderr, "%s", USAGE);
! lazy_exit(-1);
}
if (!strcasecmp(argv[optind++], "irc")) irc_tabbing = YES;
***************
*** 543,551 ****
fixed_prompt = YES;
break;
default:
(void)fprintf(stderr, "%s", USAGE);
! exit(1);
}
}
--- 543,554 ----
fixed_prompt = YES;
break;
+ case 'w': /* wait for an extra return before exiting */
+ lazy_exit_setup(1);
+ break;
default:
(void)fprintf(stderr, "%s", USAGE);
! lazy_exit(1);
}
}
***************
*** 564,581 ****
if (!net_setup()) {
(void)fprintf(stderr, "%s: unable to setup network\n", argv[0]);
! exit(4);
}
if (!input_setup()) {
(void)fprintf(stderr, "%s: unable to setup input\n", argv[0]);
! exit(5);
}
main_loop();
net_shutdown();
input_shutdown();
! exit(0);
}
--- 567,584 ----
if (!net_setup()) {
(void)fprintf(stderr, "%s: unable to setup network\n", argv[0]);
! lazy_exit(4);
}
if (!input_setup()) {
(void)fprintf(stderr, "%s: unable to setup input\n", argv[0]);
! lazy_exit(5);
}
main_loop();
net_shutdown();
input_shutdown();
! lazy_exit(0);
}
diff -cr lily/utils.c lily.new/utils.c
*** lily/utils.c Sat Dec 17 14:24:31 1994
--- lily.new/utils.c Sun May 4 13:17:09 1997
***************
*** 383,385 ****
--- 383,409 ----
rl_deprep_terminal();
}
}
+
+
+ /*
+ ** simple hack to allow the client to wait for the user to be able to
+ ** read the error/info message being printed.
+ **
+ ** Useful in conditions where lclient is invoked inside an xterm
+ */
+
+ static int do_lazy_exit = 0;
+
+ void lazy_exit_setup( int code ){
+ do_lazy_exit = code;
+ }
+
+ void lazy_exit( int code ){
+ char c;
+ if( do_lazy_exit ) {
+ fprintf(stdout,"*** Hit the return key to exit ***\n");
+ fflush(stdout);
+ while( (c = fgetc(stdin)) != (int)'\n' );
+ }
+ exit(code);
+ }