about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--lynx.cfg24
-rw-r--r--lynx.man6
-rw-r--r--lynx_help/Lynx_users_guide.html25
-rw-r--r--src/GridText.c69
-rw-r--r--src/HTAlert.c10
-rw-r--r--src/LYClean.c18
-rw-r--r--src/LYHistory.h3
-rw-r--r--src/LYMain.c41
-rw-r--r--src/LYReadCFG.c32
-rw-r--r--src/LYSession.c47
-rw-r--r--src/LYSession.h6
12 files changed, 191 insertions, 95 deletions
diff --git a/CHANGES b/CHANGES
index c6fa8a02..caf791e6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,12 @@
--- $LynxId: CHANGES,v 1.253 2008/01/11 00:45:24 tom Exp $
+-- $LynxId: CHANGES,v 1.254 2008/02/11 00:58:27 tom Exp $
 ===============================================================================
 Changes since Lynx 2.8 release
 ===============================================================================
 
 2007-??-?? (2.8.7dev.8)
++ add XWINDOWS / NON_XWINDOWS environment-variable field to DOWNLOAD, etc., in
+  lynx.cfg to specify whether a downloader (printer, etc) is enabled when
+  the X display variable is set -PBM
 * add configure script options --enable-session-cache and --enable-progressbar
   for PBM's experimental session and progressbar features -TD
 * add session save/restore feature -PBM
diff --git a/lynx.cfg b/lynx.cfg
index 6e8535c6..b11a8d1e 100644
--- a/lynx.cfg
+++ b/lynx.cfg
@@ -1,4 +1,4 @@
-# $LynxId: lynx.cfg,v 1.154 2008/01/10 00:35:29 tom Exp $
+# $LynxId: lynx.cfg,v 1.155 2008/02/10 23:43:24 Paul.B.Mahol Exp $
 # lynx.cfg file.
 # The default placement for this file is /usr/local/lib/lynx.cfg (Unix)
 #                                     or Lynx_Dir:lynx.cfg (VMS)
@@ -1736,9 +1736,9 @@ DEFAULT_INDEX_FILE:http://lynx.isc.org/
 #
 # To define your own print or download option use the following formats:
 #
-# PRINTER:<name>:<command>:<option>:<lines/page>
+# PRINTER:<name>:<command>:<option>:<lines/page>[:<environment>]
 #
-# DOWNLOADER:<name>:<command>:<option>
+# DOWNLOADER:<name>:<command>:<option>[:<environment>]
 #
 # <name>       is what you will see on the print/download screen.
 #
@@ -1765,6 +1765,15 @@ DEFAULT_INDEX_FILE:http://lynx.isc.org/
 #              it uses current screen length for the computation
 #              when `Print to screen' is selected.
 #
+# [:<environment>]
+#              optional, if XWINDOWS then printer/downloader will be
+#              enabled if DISPLAY environment variable IS defined and
+#              disabled otherwise, if environment is NON_XWINDOWS
+#              then printer/downloader will be enabled if DISPLAY
+#              environment variable IS NOT defined and disabled otherwise,
+#              for anything else or if environment is not specified
+#              printer/downloader is always enabled.
+#
 # You must put the whole definition on one line;
 # if you use a colon, precede it with a backslash.
 #
@@ -2313,7 +2322,7 @@ MINIMAL_COMMENTS:TRUE
 #       by some built-in defaults in src/HTInit.c.
 #
 # The VIEWER definition takes the form of:
-#    VIEWER:<mime type>:<viewer command>[:environment]
+#    VIEWER:<mime type>:<viewer command>[:<environment>]
 #      where -mime type is the MIME content type of the file
 #	     -viewer command is a system command that can be
 #             used to display the file where %s is replaced
@@ -3074,7 +3083,7 @@ COLOR:6:brightred:black
 #
 # The lynx.cfg line is as follows:
 #
-# EXTERNAL:<url>:<command> %s:<norestriction>:<allow_for_activate>
+# EXTERNAL:<url>:<command> %s:<norestriction>:<allow_for_activate>[:environment]
 #
 # <url> Any given URL.  This can be normal ones like ftp or http or it
 # can be one made up like mymail.
@@ -3094,6 +3103,11 @@ COLOR:6:brightred:black
 # pressing EXTERN key on it).  If this component of the line is absent, then
 # FALSE is assumed.
 #
+# [:environment] Optional, if XWINDOWS then command is allowed only if
+# $DISPLAY environment variable is set, else if NON_XWINDOWS then command
+# is allowed only if $DISPLAY environment variable is not set, if absent or
+# anything else command is always allowed.
+#
 # For invoking the command use the EXTERN_LINK or EXTERN_PAGE key.  By default
 # EXTERN_LINK is mapped to '.', and EXTERN_PAGE to ',' (if the feature is
 # enabled), see the KEYMAP section above.
diff --git a/lynx.man b/lynx.man
index 6b3a65a4..986f3b98 100644
--- a/lynx.man
+++ b/lynx.man
@@ -1,4 +1,4 @@
-.\" $LynxId: lynx.man,v 1.77 2008/01/08 00:19:25 tom Exp $
+.\" $LynxId: lynx.man,v 1.79 2008/02/11 00:27:34 tom Exp $
 .nr N -1
 .nr D 5
 .TH LYNX 1
@@ -358,7 +358,7 @@ do justification of text.
 .B \-link\fR=\fINUMBER
 starting count for lnk#.dat files produced by \fB\-crawl\fR.
 .TP
-.B -listonly
+.B \-listonly
 for \fB-dump\fR, show only the list of links.
 .TP
 .B \-localhost
@@ -792,7 +792,7 @@ traverse all http links derived from startfile.  When used with
 is output to a file, intended for indexing.  See CRAWL.announce
 for more information.
 .TP
-.B trim_input_fields
+.B \-trim_input_fields
 trim input text/textarea fields in forms.
 .TP
 .B \-underline_links
diff --git a/lynx_help/Lynx_users_guide.html b/lynx_help/Lynx_users_guide.html
index 5a5aff6b..bce12d33 100644
--- a/lynx_help/Lynx_users_guide.html
+++ b/lynx_help/Lynx_users_guide.html
@@ -1,5 +1,5 @@
 <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 3.0//EN">
-<!-- $LynxId: Lynx_users_guide.html,v 1.92 2008/01/10 21:44:53 tom Exp $ -->
+<!-- $LynxId: Lynx_users_guide.html,v 1.93 2008/02/11 00:23:06 tom Exp $ -->
 <html>
 <head>
 <title>Lynx Users Guide v2.8.6</title>
@@ -2326,7 +2326,7 @@ as well as the maxmimum amount of memory used by the cache.
 
 <p>The structure of <em>Cache Jar</em> is simple:
 <ul>
-<li>Each entry starts with its ordinal number (within session),
+<li>Each entry starts with its ordinal number (within the session),
 recently added documents in cache have a smaller number than documents
 which are added before, and are positioned at the end of <em>Cache Jar</em>
 
@@ -2340,10 +2340,23 @@ Activating this link, lynx displays the corresponding cached document.
 
 <li>Below each cached document URL lynx shows
 the document properties which include:
-Lines,
-Size, File-Cache, Content-Type, Content-Language, Content-Encoding,
-Content-Location, Subject, Owner, Date, Expires, Last-Modified, ETag, Server, and
-Source-Cache-File.
+<ul>
+<li>Lines,
+<li>Size,
+<li>File-Cache,
+<li>Content-Type,
+<li>Content-Language,
+<li>Content-Encoding,
+<li>Content-Location,
+<li>Subject,
+<li>Owner,
+<li>Date,
+<li>Expires,
+<li>Last-Modified,
+<li>ETag,
+<li>Server, and
+<li>Source-Cache-File.
+</ul>
 </ul>
 
 <p>This feature can be enabled by default using the USE_CACHEJAR symbol in the
diff --git a/src/GridText.c b/src/GridText.c
index 0212d43a..388ac476 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.143 2008/02/10 23:25:38 tom Exp $
+ * $LynxId: GridText.c,v 1.144 2008/02/11 00:07:05 Paul.B.Mahol Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -14253,6 +14253,9 @@ static int LYHandleCache(const char *arg,
     char *content_language = NULL;
     char *content_encoding = NULL;
     char *content_location = NULL;
+    char *content_disposition = NULL;
+    char *content_md5 = NULL;
+    char *message_id = NULL;
     char *date = NULL;
     char *owner = NULL;
     char *subject = NULL;
@@ -14328,9 +14331,6 @@ static int LYHandleCache(const char *arg,
 	       helpfilepath, CACHE_JAR_HELP, CACHE_JAR_TITLE);
     PUTS(buf);
 
-    HTSprintf0(&buf, "<pre>\n");
-    PUTS(buf);
-
     /*
      * Max number of cached documents is always same as HTCacheSize.
      * We count them from oldest to newest. Currently cached document
@@ -14347,39 +14347,41 @@ static int LYHandleCache(const char *arg,
 	if (cachedoc != 0) {
 	    HTParentAnchor *docanchor = cachedoc->node_anchor;
 
-	    Size = docanchor->content_length;
 	    if (docanchor != 0) {
 #ifdef USE_SOURCE_CACHE
 		source_cache_file = docanchor->source_cache_file;
 #endif
-		title = docanchor->title;
-		address = docanchor->address;
+		Size = docanchor->content_length;
+		StrAllocCopy(title, docanchor->title);
+		StrAllocCopy(address, docanchor->address);
 		content_type = docanchor->content_type;
 		content_language = docanchor->content_language;
 		content_encoding = docanchor->content_encoding;
 		content_location = docanchor->content_location;
+		content_disposition = docanchor->content_disposition;
+		content_md5 = docanchor->content_md5;
+		message_id = docanchor->message_id;
 		owner = docanchor->owner;
-		subject = docanchor->subject;
+		StrAllocCopy(subject, docanchor->subject);
 		date = docanchor->date;
 		expires = docanchor->expires;
 		ETag = docanchor->ETag;
-		server = docanchor->server;
+		StrAllocCopy(server, docanchor->server);
 		FileCache = docanchor->FileCache;
 		last_modified = docanchor->last_modified;
 		cache_control = docanchor->cache_control;
 	    }
 	}
 
-	HTSprintf0(&buf, "%s<em>%d</em>. <tab id=t%d>",
-		   (x > 99 ? "" : x < 10 ? "  " : " "), x, x);
-	PUTS(buf);
-	HTSprintf0(&buf, "<a href=\"%s%d\">", STR_LYNXCACHE, x);
-	PUTS(buf);
-	HTSprintf0(&buf, "%s</a>\n%s", title == NULL ? address : title,
-		   (x > 99 ? " " : x < 10 ? "   " : "  "));
-	PUTS(buf);
-	HTSprintf0(&buf, "URL: <a href=\"%s\">%s</a>\n%s", address, address,
-		   (x > 99 ? "  " : x < 10 ? "    " : "   "));
+	LYEntify(&address, TRUE);
+	if (isEmpty(title))
+	    StrAllocCopy(title, NO_TITLE);
+	else
+	    LYEntify(&title, TRUE);
+
+	HTSprintf0(&buf,
+		   "<p><em>%d.</em> Title: <a href=\"%s%d\">%s</a><br />URL: <a href=\"%s\">%s</a><br />",
+		   x, STR_LYNXCACHE, x, title, address, address);
 	PUTS(buf);
 	if (Size > 0) {
 	    HTSprintf0(&buf, "Size: %d  ", Size);
@@ -14390,7 +14392,8 @@ static int LYHandleCache(const char *arg,
 	    PUTS(buf);
 	}
 	if (FileCache != NULL) {
-	    HTSprintf0(&buf, "File-Cache: %s  ", FileCache);
+	    HTSprintf0(&buf, "File-Cache: <a href=\"file://%s\">%s</a>  ",
+		       FileCache, FileCache);
 	    PUTS(buf);
 	}
 	if (cache_control != NULL) {
@@ -14413,12 +14416,25 @@ static int LYHandleCache(const char *arg,
 	    HTSprintf0(&buf, "Content-Location: %s  ", content_location);
 	    PUTS(buf);
 	}
+	if (content_disposition != NULL) {
+	    HTSprintf0(&buf, "Content-Disposition: %s  ", content_disposition);
+	    PUTS(buf);
+	}
+	if (content_md5 != NULL) {
+	    HTSprintf0(&buf, "Content-MD5: %s  ", content_md5);
+	    PUTS(buf);
+	}
+	if (message_id != NULL) {
+	    HTSprintf0(&buf, "Message-ID: %s  ", message_id);
+	    PUTS(buf);
+	}
 	if (subject != NULL) {
+	    LYEntify(&subject, TRUE);
 	    HTSprintf0(&buf, "Subject: %s  ", subject);
 	    PUTS(buf);
 	}
 	if (owner != NULL) {
-	    HTSprintf0(&buf, "Owner: %s  ", owner);
+	    HTSprintf0(&buf, "Owner: <a href=%s>%s</a>  ", owner, owner);
 	    PUTS(buf);
 	}
 	if (date != NULL) {
@@ -14438,7 +14454,8 @@ static int LYHandleCache(const char *arg,
 	    PUTS(buf);
 	}
 	if (server != NULL) {
-	    HTSprintf0(&buf, "Server: %s  ", server);
+	    LYEntify(&server, TRUE);
+	    HTSprintf0(&buf, "Server: <em>%s</em>  ", server);
 	    PUTS(buf);
 	}
 #ifdef USE_SOURCE_CACHE
@@ -14449,11 +14466,15 @@ static int LYHandleCache(const char *arg,
 	    PUTS(buf);
 	}
 #endif
-	HTSprintf0(&buf, "<tab to=t%d>\n", x);
+	HTSprintf0(&buf, "<br />");
 	PUTS(buf);
     }
-    HTSprintf0(&buf, "</pre>\n</body>\n</html>\n");
+    HTSprintf0(&buf, "</body></html>");
     PUTS(buf);
+    FREE(subject);
+    FREE(title);
+    FREE(address);
+    FREE(server);
 
     /*
      * Free the target to complete loading of the Cache Jar Page, and report a
diff --git a/src/HTAlert.c b/src/HTAlert.c
index 498163e8..7f20322f 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAlert.c,v 1.78 2008/02/10 21:39:42 tom Exp $
+ * $LynxId: HTAlert.c,v 1.79 2008/02/11 00:28:56 tom Exp $
  *
  *	Displaying messages and getting input for Lynx Browser
  *	==========================================================
@@ -316,10 +316,12 @@ void HTReadProgress(long bytes, long total)
 		break;
 #endif
 	    default:
-		if (total > 0)
-		    HTSprintf0(&line, gettext("Read %s of %s of data"), bytesp, totalp);
-		else
+		if (total > 0) {
+		    HTSprintf0(&line, gettext("Read %s of %s of data"),
+			       bytesp, totalp);
+		} else {
 		    HTSprintf0(&line, gettext("Read %s of data"), bytesp);
+		}
 
 		if (LYTransferRate != rateOFF
 		    && transfer_rate > 0) {
diff --git a/src/LYClean.c b/src/LYClean.c
index 14078a4a..efeb3841 100644
--- a/src/LYClean.c
+++ b/src/LYClean.c
@@ -1,3 +1,4 @@
+/* $LynxId: LYClean.c,v 1.38 2008/02/11 00:50:19 Paul.B.Mahol Exp $ */
 #include <HTUtils.h>
 #include <LYCurses.h>
 #include <LYUtils.h>
@@ -8,6 +9,7 @@
 #include <LYTraversal.h>
 #include <LYHistory.h>
 #include <LYCookie.h>
+#include <LYSession.h>
 #include <UCAuto.h>
 #include <HTAlert.h>
 
@@ -123,10 +125,18 @@ void cleanup_sig(int sig)
 	}
 #ifndef NOSIGHUP
     } else {
+#ifdef USE_SESSIONS
+	/*
+	 * Wondering is this right place and time to do it.
+	 * We need this, for example it is usefull to save session
+	 * if user closed lynx in non standard way, like closing
+	 * xterm window or in worst one like crash.
+	 */
+	SaveSession();
+#endif /* USE_SESSIONS */
 	cleanup_files();
     }
 #endif /* NOSIGHUP */
-
     if (sig != 0) {
 	exit_immediately(EXIT_SUCCESS);
     } else {
@@ -190,6 +200,12 @@ void cleanup(void)
     if (persistent_cookies)
 	LYStoreCookies(LYCookieSaveFile);
 #endif
+#ifdef USE_SESSIONS
+    /*
+     * Wondering is this right place and time to do it.
+     */
+    SaveSession();
+#endif /* USE_SESSIONS */
 
     cleanup_files();
 #ifdef VMS
diff --git a/src/LYHistory.h b/src/LYHistory.h
index 37315ca5..db94144c 100644
--- a/src/LYHistory.h
+++ b/src/LYHistory.h
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: LYHistory.h,v 1.19 2008/02/11 01:05:04 tom Exp $
+ */
 #ifndef LYHISTORY_H
 #define LYHISTORY_H
 
diff --git a/src/LYMain.c b/src/LYMain.c
index c5dd20c7..f5a023d8 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYMain.c,v 1.178 2008/01/08 00:48:59 tom Exp $ */
+/* $LynxId: LYMain.c,v 1.179 2008/02/11 00:41:46 Paul.B.Mahol Exp $ */
 #include <HTUtils.h>
 #include <HTTP.h>
 #include <HTParse.h>
@@ -2185,11 +2185,8 @@ int main(int argc,
 	ena_csi((BOOLEAN) (LYlowest_eightbit[current_char_set] > 155));
 #ifdef USE_SESSIONS
 	RestoreSession();
+#endif /* USE_SESSIONS */
 	status = mainloop();
-	SaveSession();
-#else
-	status = mainloop();
-#endif
 	LYCloseCloset(RECALL_URL);
 	LYCloseCloset(RECALL_MAIL);
 #if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
@@ -3315,7 +3312,8 @@ static Config_Type Arg_Table [] =
    ),
    PARSE_FUN(
       "base",		4|FUNCTION_ARG,		base_fun,
-      "prepend a request URL comment and BASE tag to text/html\noutputs for -source dumps"
+      "prepend a request URL comment and BASE tag to text/html\n\
+outputs for -source dumps"
    ),
 #ifndef DISABLE_BIBP
    PARSE_STR(
@@ -3484,7 +3482,8 @@ keys (may be incompatible with some curses packages)"
 #endif
    PARSE_SET(
       "force_empty_hrefless_a",	4|SET_ARG,	force_empty_hrefless_a,
-      "\nforce HREF-less 'A' elements to be empty (close them as\nsoon as they are seen)"
+      "\nforce HREF-less 'A' elements to be empty (close them as\n\
+soon as they are seen)"
    ),
    PARSE_SET(
       "force_html",	4|SET_ARG,		LYforce_HTML_mode,
@@ -3642,7 +3641,7 @@ keys (may be incompatible with some curses packages)"
    ),
    PARSE_SET(
       "nomargins",	4|SET_ARG,		no_margins,
-      "disable the right/left margins in the default style-sheet"
+      "disable the right/left margins in the default\nstyle-sheet"
    ),
 #if defined(HAVE_SIGACTION) && defined(SIGWINCH)
    PARSE_SET(
@@ -3729,11 +3728,13 @@ with partial-display logic"
    ),
    PARSE_SET(
       "popup",		4|UNSET_ARG,		LYUseDefSelPop,
-      "toggles handling of single-choice SELECT options via\npopup windows or as lists of radio buttons"
+      "toggles handling of single-choice SELECT options via\n\
+popup windows or as lists of radio buttons"
    ),
    PARSE_FUN(
       "post_data",	2|FUNCTION_ARG,		post_data_fun,
-      "user data for post forms, read from stdin,\nterminated by '---' on a line"
+      "user data for post forms, read from stdin,\n\
+terminated by '---' on a line"
    ),
    PARSE_SET(
       "preparsed",	4|SET_ARG,		LYPreparsedSource,
@@ -3804,7 +3805,8 @@ with the PREV_DOC command or from the History List"
 #ifdef USE_SESSIONS
    PARSE_STR(
       "session",	2|NEED_LYSTRING_ARG,	session_file,
-      "=FILENAME\nresumes from specified file on startup and saves session to that file on exit"
+      "=FILENAME\nresumes from specified file on startup and\n\
+saves session to that file on exit"
    ),
    PARSE_STR(
       "sessionin",	2|NEED_LYSTRING_ARG,	sessionin_file,
@@ -3837,8 +3839,8 @@ with the PREV_DOC command or from the History List"
 #endif
    PARSE_SET(
       "soft_dquotes",	4|TOGGLE_ARG,		soft_dquotes,
-      "toggles emulation of the old Netscape and Mosaic bug which\n\
-treated '>' as a co-terminator for double-quotes and tags"
+      "toggles emulation of the old Netscape and Mosaic\n\
+bug which treated '>' as a co-terminator for\ndouble-quotes and tags"
    ),
    PARSE_FUN(
       "source",		4|FUNCTION_ARG,		source_fun,
@@ -3854,7 +3856,7 @@ treated '>' as a co-terminator for double-quotes and tags"
    ),
    PARSE_SET(
       "stderr",		4|SET_ARG,		dump_to_stderr,
-      "write warning messages to standard error when -dump -or -source is used"
+      "write warning messages to standard error when -dump\nor -source is used"
    ),
    PARSE_SET(
       "stdin",		4|SET_ARG,		startfile_stdin,
@@ -3890,7 +3892,7 @@ treated '>' as a co-terminator for double-quotes and tags"
 #endif
    PARSE_SET(
       "tlog",		2|TOGGLE_ARG,		LYUseTraceLog,
-      "toggles use of a Lynx Trace Log for the current session"
+      "toggles use of a Lynx Trace Log for the current\nsession"
    ),
 #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION
    PARSE_SET(
@@ -3914,7 +3916,7 @@ treated '>' as a co-terminator for double-quotes and tags"
    ),
    PARSE_SET(
       "trim_input_fields", 2|SET_ARG,		LYtrimInputFields,
-      "trim input text/textarea fields in forms"
+      "\ntrim input text/textarea fields in forms"
    ),
    PARSE_SET(
       "underline_links",4|TOGGLE_ARG,		LYUnderlineLinks,
@@ -3936,11 +3938,14 @@ treated '>' as a co-terminator for double-quotes and tags"
    ),
    PARSE_SET(
       "validate",	2|SET_ARG,		LYValidate,
-      "accept only http URLs (meant for validation)\nimplies more restrictions than -anonymous, but\ngoto is allowed for http and https"
+      "accept only http URLs (meant for validation)\n\
+implies more restrictions than -anonymous, but\n\
+goto is allowed for http and https"
    ),
    PARSE_SET(
       "verbose",	4|TOGGLE_ARG,		verbose_img,
-      "toggles [LINK], [IMAGE] and [INLINE] comments \nwith filenames of these images"
+      "toggles [LINK], [IMAGE] and [INLINE] comments\n\
+with filenames of these images"
    ),
    PARSE_FUN(
       "version",	1|FUNCTION_ARG,		version_fun,
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index f489d88f..af3358db 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYReadCFG.c,v 1.126 2008/02/10 22:05:02 tom Exp $ */
+/* $LynxId: LYReadCFG.c,v 1.127 2008/02/11 00:54:34 Paul.B.Mahol Exp $ */
 #ifndef NO_RULES
 #include <HTRules.h>
 #else
@@ -111,16 +111,42 @@ static void free_all_item_lists(void)
 }
 
 /*
- * Process string buffer fields for DOWNLOADER or UPLOADER menus.
+ * Process string buffer fields for DOWNLOADER or UPLOADER
+ *                               or PRINTERS   or EXTERNALS menus
  */
 static void add_item_to_list(char *buffer,
 			     lynx_list_item_type **list_ptr,
 			     int special)
 {
-    char *colon, *next_colon;
+    char *colon, *next_colon, *last_colon;
     lynx_list_item_type *cur_item, *prev_item;
 
     /*
+     * Check if the XWINDOWS or NON_XWINDOWS keyword is present in the last
+     * field, and act properly when found depending if external environment
+     * $DISPLAY variable is set.
+     */
+    if ((last_colon = strrchr(buffer, ':')) != NULL && *(last_colon - 1) != '\\') {
+	*last_colon++ = '\0';
+	/*
+	 * If last_colon equals XWINDOWS then only continue
+	 * if there is a $DISPLAY variable
+	 */
+	if (!strcasecomp(last_colon, "XWINDOWS")) {
+	    if (LYgetXDisplay() == NULL)
+		return;
+	}
+	/*
+	 * If last_colon equals NON_XWINDOWS then only continue
+	 * if there is no $DISPLAY variable
+	 */
+	else if (!strcasecomp(last_colon, "NON_XWINDOWS")) {
+	    if (LYgetXDisplay() != NULL)
+		return;
+	}
+    }
+
+    /*
      * Make a linked list
      */
     if (*list_ptr == NULL) {
diff --git a/src/LYSession.c b/src/LYSession.c
index d578c7c4..ed9e170c 100644
--- a/src/LYSession.c
+++ b/src/LYSession.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYSession.c,v 1.3 2008/01/12 01:32:08 tom Exp $ */
+/* $LynxId: LYSession.c,v 1.4 2008/02/11 00:00:19 Paul.B.Mahol Exp $ */
 
 #include <LYSession.h>
 
@@ -55,19 +55,18 @@ static char *get_filename(char *given_name)
 /* Restore session from file, pretty slow, but it should be fine
  * for everyday, normal use.
  */
-BOOLEAN RestoreSession(void)
+void RestoreSession(void)
 {
-    int code;
     char *my_filename = get_filename(sessionin_file);
     FILE *fp;
     char *buffer = 0;
     DocInfo doc;
     VisitedLink *vl;
     int i = 0;
-    short errors = 10;		/* how much syntax errors are allowed in
+    short errors = 10;		/* how many syntax errors are allowed in
 
-				   session file before abort. */
-    char *value1, *value2, *line, *linktext, *level;
+				   session file before aborting. */
+    char *value1, *value2, *rsline, *linktext, *rslevel;
 
     /*
      * This should be done only once, here:  iff USE_SESSIONS is defined or: 
@@ -77,13 +76,12 @@ BOOLEAN RestoreSession(void)
 
     if (my_filename == NULL) {
 	/* nothing to do, so exit */
-	return (TRUE);
+	return;
     }
 
     CTRACE((tfp, "RestoreSession %s\n", my_filename));
     SetDefaultMode(O_TEXT);
     if ((fp = fopen(my_filename, TXT_R)) != NULL) {
-	code = TRUE;
 
 	/*
 	 * This should be safe, entries are added to lynx until memory i
@@ -111,11 +109,11 @@ BOOLEAN RestoreSession(void)
 #endif /* GOTOURL_OUT_SESSION */
 	    } else if (*buffer == 'h') {
 #ifdef HISTORY_OUT_SESSION
-		if ((line = strchr(buffer, ' ')) == 0)
+		if ((rsline = strchr(buffer, ' ')) == 0)
 		    continue;
 		else {
-		    line++;
-		    if ((linktext = strchr(line, ' ')) == 0)
+		    rsline++;
+		    if ((linktext = strchr(rsline, ' ')) == 0)
 			continue;
 		    else
 			*linktext++ = 0;
@@ -125,7 +123,7 @@ BOOLEAN RestoreSession(void)
 			*value1++ = 0;
 		    if ((value2 = strchr(value1, '\t')) != 0) {
 			*value2++ = 0;
-			doc.line = atoi(line);
+			doc.line = atoi(rsline);
 			doc.link = atoi(linktext);
 			StrAllocCopy(doc.address, value1);
 			StrAllocCopy(doc.title, value2);
@@ -135,11 +133,11 @@ BOOLEAN RestoreSession(void)
 #endif /* HISTORY_OUT_SESSION */
 	    } else if (*buffer == 'V') {
 #ifdef VLINK_OUT_SESSION
-		if ((level = strchr(buffer, ' ')) == 0)
+		if ((rslevel = strchr(buffer, ' ')) == 0)
 		    continue;
 		else {
-		    level++;
-		    if ((value1 = strchr(level, ' ')) == 0)
+		    rslevel++;
+		    if ((value1 = strchr(rslevel, ' ')) == 0)
 			continue;
 		    else
 			*value1++ = 0;
@@ -151,7 +149,7 @@ BOOLEAN RestoreSession(void)
 			vl = (VisitedLink *)
 			    HTList_objectAt(Visited_Links, i);
 			if (vl != NULL) {
-			    vl->level = atoi(level);
+			    vl->level = atoi(rslevel);
 			    i++;
 			}
 		    }
@@ -170,17 +168,13 @@ BOOLEAN RestoreSession(void)
 	LYCloseOutput(fp);
     }
     SetDefaultMode(O_BINARY);
-    return (TRUE);
 }
 
-/* Save session to file, overwriting one.
- * Fast as much as lynx allow.
- * If it is still slow for you improve following functions:
- * HTListObjectAt() and HTList_count().
+/*
+ * Save session to file, overwriting one.
  */
-BOOLEAN SaveSession(void)
+void SaveSession(void)
 {
-    int code = FALSE;
     char *my_filename = get_filename(sessionout_file);
     FILE *fp;
     VisitedLink *vl;
@@ -188,19 +182,19 @@ BOOLEAN SaveSession(void)
 
     if (my_filename == NULL) {
 	/* nothing to do, so exit */
-	return (TRUE);
+	return;
     }
 
     CTRACE((tfp, "SaveSession %s\n", my_filename));
 
     SetDefaultMode(O_TEXT);
     if ((fp = fopen(my_filename, TXT_W)) != NULL) {
-	code = TRUE;
 
 	fprintf(fp, "# lynx session\n");	/* @@@ simple for now */
 
 	/* Note use of session_limit, the most recent entries in list,
-	   from end of list, are saved */
+	 * from the end of list, are saved.
+	 */
 
 #ifdef SEARCH_IN_SESSION
 	k = HTList_count(search_queries);
@@ -264,7 +258,6 @@ BOOLEAN SaveSession(void)
 
     }
     SetDefaultMode(O_BINARY);
-    return (code);
 }
 
 #endif /* USE_SESSIONS */
diff --git a/src/LYSession.h b/src/LYSession.h
index f6c26a01..90d74fca 100644
--- a/src/LYSession.h
+++ b/src/LYSession.h
@@ -1,4 +1,4 @@
-/* $LynxId: LYSession.h,v 1.2 2008/01/10 23:50:45 tom Exp $ */
+/* $LynxId: LYSession.h,v 1.3 2008/02/10 23:47:39 Paul.B.Mahol Exp $ */
 #ifndef LYSESSION_H
 #define LYSESSION_H
 
@@ -7,8 +7,8 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-    extern BOOLEAN RestoreSession(void);
-    extern BOOLEAN SaveSession(void);
+    extern void RestoreSession(void);
+    extern void SaveSession(void);
 
 #ifdef __cplusplus
 }