lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] LYNXMESSAGES:/ without temp-files (was: lynx-dev problem with


From: Leonid Pauzner
Subject: [patch] LYNXMESSAGES:/ without temp-files (was: lynx-dev problem with saving pages in lynx)
Date: Mon, 18 Oct 1999 07:03:41 +0400 (MSD)

17-Oct-99 08:17 Klaus Weide wrote:
> On Sun, 17 Oct 1999, Leonid Pauzner wrote:
>> 6-Sep-99 04:38 Klaus Weide wrote:
>> >> > That sounds like a problem with generating temporary files.

>> BTW, a history of status-line messages will not work either...
>> Only trace log can bring up a diagnostic if $HOME mounted (rw) in turn.

> Another reason for "status-line history would be better if
> it was using non-tempfile approach"...

> (Well it would be nice, but it's not a big problem.)

>   Klaus

Well, not a big problem but seems time to implement. The patch follows.

One problem found: this page should be updated every time, even when we
choose it from the history page. Unfortunately, anchor->no_cache isn't enough.
Currently worked out in getfile()...
Klaus, please look for proper no_cache solution -
try to follow LYNXMESSAGES:/ link from the history page,
'd'ownload it, etc.


* implement LYNXMESSAGES:/ page using non-tempfile approach


diff -u old/lygetfil.c ./lygetfil.c
--- old/lygetfil.c      Fri Oct 15 04:25:58 1999
+++ ./lygetfil.c        Mon Oct 18 06:25:40 1999
@@ -14,7 +14,6 @@
 #include <LYGetFile.h>
 #include <LYPrint.h>
 #include <LYOptions.h>
-#include <LYHistory.h>
 #include <LYStrings.h>
 #include <LYClean.h>
 #include <LYDownload.h>
@@ -317,6 +316,11 @@
                    /* show compile-time settings */
                    return(lynx_compile_opts(doc));
 #endif
+               } else if (url_type == LYNXMESSAGES_URL_TYPE) {
+                       /* Uh! */
+                       LYforce_no_cache = TRUE;
+                       LYoverride_no_cache = FALSE;
+                       /* continue */

 #ifndef DISABLE_NEWS
                } else if (url_type == NEWSPOST_URL_TYPE ||
@@ -776,23 +780,9 @@
                        }
                        FREE(cp);
                    }
-                   if (url_type == LYNXMESSAGES_URL_TYPE) {
-                       int rv;
-                   /* show list of recent statusline messages */
-                       if ((rv = LYshow_statusline_messages(doc)) != NORMAL) {
-                           return rv;
-                       }
-                       WWWDoc.address = doc->address;
-                       WWWDoc.post_data = doc->post_data;
-                       WWWDoc.post_content_type = doc->post_content_type;
-                       WWWDoc.bookmark = doc->bookmark;
-                       WWWDoc.isHEAD = doc->isHEAD;
-                       WWWDoc.safe = doc->safe;
-                   } else {
+                   CTRACE_SLEEP(MessageSecs);
+                   user_message(WWW_WAIT_MESSAGE, doc->address);

-                       CTRACE_SLEEP(MessageSecs);
-                       user_message(WWW_WAIT_MESSAGE, doc->address);
-                   }
                    if (TRACE) {
 #ifdef USE_SLANG
                        if (LYCursesON) {
@@ -851,6 +841,7 @@
                                url_type == LYNXCOMPILE_OPTS_URL_TYPE ||
                                url_type == LYNXHIST_URL_TYPE ||
                                url_type == LYNXCOOKIE_URL_TYPE ||
+                               url_type == LYNXMESSAGES_URL_TYPE ||
                                (LYValidate &&
                                 url_type != HTTP_URL_TYPE &&
                                 url_type != HTTPS_URL_TYPE) ||
diff -u old/lyhistor.c ./lyhistor.c
--- old/lyhistor.c      Fri Oct 15 04:26:10 1999
+++ ./lyhistor.c        Mon Oct 18 06:40:20 1999
@@ -14,7 +14,7 @@
 #include <LYShowInfo.h>
 #include <LYStrings.h>
 #include <LYCharUtils.h>
-#include <LYGetFile.h>
+#include <LYCharSets.h>

 #ifdef DIRED_SUPPORT
 #include <LYUpload.h>
@@ -685,74 +685,6 @@
 #endif
 }

-
-/*
- *  Status line messages list, LYNXMESSAGES:/ internal page,
- *  called from getfile().
- */
-PUBLIC int LYshow_statusline_messages ARGS1(
-    document *,                              newdoc)
-{
-    static char tempfile[LY_MAXPATH] = "\0";
-    static char *info_url;
-    FILE *fp0;
-    int i;
-    char *temp = NULL;
-
-    if (LYReuseTempfiles) {
-       fp0 = LYOpenTempRewrite(tempfile, HTML_SUFFIX, "w");
-    } else {
-       LYRemoveTemp(tempfile);
-       fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w");
-    }
-    if (fp0 == NULL) {
-       HTAlert(CANNOT_OPEN_TEMP);
-       return(NOT_FOUND);
-    }
-    LYLocalFileToURL(&info_url, tempfile);
-
-    LYforce_no_cache = TRUE;  /* don't cache this doc */
-
-    BeginInternalPage (fp0, STATUSLINES_TITLE, NULL);
-    fprintf(fp0, "<pre>\n");
-    fprintf(fp0, "<ol>\n");
-
-    /* print messages in reverse order: */
-    i = topOfStack;
-    while (--i >= 0) {
-       if (buffstack[i] != NULL) {
-           StrAllocCopy(temp, buffstack[i]);
-           LYEntify(&temp, TRUE);
-           fprintf(fp0,  "<li> <em>%s</em>\n",  temp);
-       }
-    }
-    i = STATUSBUFSIZE;
-    while (--i >= topOfStack) {
-       if (buffstack[i] != NULL) {
-           StrAllocCopy(temp, buffstack[i]);
-           LYEntify(&temp, TRUE);
-           fprintf(fp0,  "<li> <em>%s</em>\n",  temp);
-       }
-    }
-
-    fprintf(fp0, "</ol>\n");
-    fprintf(fp0, "</pre>\n");
-    EndInternalPage(fp0);
-    LYCloseTempFP(fp0);
-
-
-    /* exit to getfile() cycle */
-    StrAllocCopy(newdoc->address, info_url);
-    FREE(newdoc->post_data);
-    FREE(newdoc->post_content_type);
-    FREE(newdoc->bookmark);
-    newdoc->isHEAD = FALSE;
-
-    /* Leave loading it to getfile - that has the advantage to make
-       this kind of link 'd'ownloadable. - kw */
-    return(NORMAL);
-}
-
 /*
  * Dump statusline messages into the buffer.
  * Called from mainloop() when exit immediately with an error:
@@ -807,3 +739,95 @@
        to_stack(temp);
     }
 }
+
+/*     LYLoadMESSAGES
+**     --------------
+**     Create a text/html stream with a list of recent statusline messages.
+**     LYNXMESSAGES:/ internal page.
+**     [implementation based on LYLoadKeymap()].
+*/
+
+struct _HTStream
+{
+  HTStreamClass * isa;
+};
+
+PRIVATE int LYLoadMESSAGES ARGS4 (
+       CONST char *,           arg GCC_UNUSED,
+       HTParentAnchor *,       anAnchor,
+       HTFormat,               format_out,
+       HTStream*,              sink)
+{
+    HTFormat format_in = WWW_HTML;
+    HTStream *target = NULL;
+    char *buf = NULL;
+
+    int i;
+    char *temp = NULL;
+
+
+    /*
+     *  Set up the stream. - FM
+     */
+    target = HTStreamStack(format_in, format_out, sink, anAnchor);
+
+    if (!target || target == NULL) {
+       HTSprintf0(&buf, CANNOT_CONVERT_I_TO_O,
+                        HTAtom_name(format_in), HTAtom_name(format_out));
+       HTAlert(buf);
+       FREE(buf);
+       return(HT_NOT_LOADED);
+    }
+    anAnchor->no_cache = TRUE;
+
+#define PUTS(buf)    (*target->isa->put_block)(target, buf, strlen(buf))
+
+    HTSprintf0(&buf, "<html>\n<head>\n");
+    PUTS(buf);
+       /*
+        *  This page is a list of messages in display character set.
+        */
+    HTSprintf0(&buf, "<META %s content=\"text/html;charset=%s\">\n",
+               "http-equiv=\"content-type\"",
+               LYCharSet_UC[current_char_set].MIMEname);
+    PUTS(buf);
+    HTSprintf0(&buf, "<title>%s</title>\n", STATUSLINES_TITLE);
+    PUTS(buf);
+    HTSprintf0(&buf, "</head>\n<body>\n<pre>\n<ol>\n");
+    PUTS(buf);
+
+    /* print messages in reverse order: */
+    i = topOfStack;
+    while (--i >= 0) {
+       if (buffstack[i] != NULL) {
+           StrAllocCopy(temp, buffstack[i]);
+           LYEntify(&temp, TRUE);
+           HTSprintf0(&buf, "<li> <em>%s</em>\n",  temp);
+           PUTS(buf);
+       }
+    }
+    i = STATUSBUFSIZE;
+    while (--i >= topOfStack) {
+       if (buffstack[i] != NULL) {
+           StrAllocCopy(temp, buffstack[i]);
+           LYEntify(&temp, TRUE);
+           HTSprintf0(&buf, "<li> <em>%s</em>\n",  temp);
+           PUTS(buf);
+       }
+    }
+    FREE(temp);
+
+    HTSprintf0(&buf, "</ol>\n</pre>\n</body>\n</html>\n");
+    PUTS(buf);
+
+    (*target->isa->_free)(target);
+    FREE(buf);
+    return(HT_LOADED);
+}
+
+#ifdef GLOBALDEF_IS_MACRO
+#define _LYMESSAGES_C_GLOBALDEF_1_INIT { "LYNXMESSAGES", LYLoadMESSAGES, 0}
+GLOBALDEF (HTProtocol,LYLynxStatusMessages,_LYMESSAGES_C_GLOBALDEF_1_INIT);
+#else
+GLOBALDEF PUBLIC HTProtocol LYLynxStatusMessages = {"LYNXMESSAGES", 
LYLoadMESSAGES, 0};
+#endif /* GLOBALDEF_IS_MACRO */
diff -u old/lyhistor.h ./lyhistor.h
--- old/lyhistor.h      Fri Jun 11 03:34:08 1999
+++ ./lyhistor.h        Mon Oct 18 02:27:16 1999
@@ -16,7 +16,6 @@

 extern void LYstore_message2 PARAMS((CONST char *message, CONST char 
*argument));
 extern void LYstore_message PARAMS((CONST char *message));
-extern int LYshow_statusline_messages PARAMS((document *newdoc));
 extern void LYstatusline_messages_on_exit PARAMS((char **buf));

 #endif /* LYHISTORY_H */
diff -u old/lykeymap.c ./lykeymap.c
--- old/lykeymap.c      Mon Sep 13 20:07:18 1999
+++ ./lykeymap.c        Mon Oct 18 03:46:20 1999
@@ -928,16 +928,18 @@
     }
     anAnchor->no_cache = TRUE;

+#define PUTS(buf)    (*target->isa->put_block)(target, buf, strlen(buf))
+
     HTSprintf0(&buf, "<head>\n<title>%s</title>\n</head>\n<body>\n",
                     CURRENT_KEYMAP_TITLE);
-    (*target->isa->put_block)(target, buf, strlen(buf));
+    PUTS(buf);
     HTSprintf0(&buf, "<h1>%s (%s)%s<a href=\"%s%s\">%s</a></h1>\n",
        LYNX_NAME, LYNX_VERSION,
        HELP_ON_SEGMENT,
        helpfilepath, CURRENT_KEYMAP_HELP, CURRENT_KEYMAP_TITLE);
-    (*target->isa->put_block)(target, buf, strlen(buf));
+    PUTS(buf);
     HTSprintf0(&buf, "<pre>\n");
-    (*target->isa->put_block)(target, buf, strlen(buf));
+    PUTS(buf);

     for (i = 'a'+1; i <= 'z'+1; i++) {
        print_binding(target, i);
@@ -959,7 +961,7 @@
     }

     HTSprintf0(&buf,"</pre>\n</body>\n");
-    (*target->isa->put_block)(target, buf, strlen(buf));
+    PUTS(buf);

     (*target->isa->_free)(target);
     FREE(buf);
diff -u old/lymain.c ./lymain.c
--- old/lymain.c        Fri Oct 15 04:26:44 1999
+++ ./lymain.c  Mon Oct 18 02:09:30 1999
@@ -2051,18 +2051,20 @@
 /*
  *  Called by HTAccessInit to register any protocols supported by lynx.
  *  Protocols added by lynx:
- *    LYNXKEYMAP, lynxcgi, LYNXIMGMAP, LYNXCOOKIE
+ *    LYNXKEYMAP, lynxcgi, LYNXIMGMAP, LYNXCOOKIE, LYNXMESSAGES
  */
 #ifdef GLOBALREF_IS_MACRO
 extern GLOBALREF (HTProtocol, LYLynxKeymap);
 extern GLOBALREF (HTProtocol, LYLynxCGI);
 extern GLOBALREF (HTProtocol, LYLynxIMGmap);
 extern GLOBALREF (HTProtocol, LYLynxCookies);
+extern GLOBALREF (HTProtocol, LYLynxStatusMessages);
 #else
 GLOBALREF  HTProtocol LYLynxKeymap;
 GLOBALREF  HTProtocol LYLynxCGI;
 GLOBALREF  HTProtocol LYLynxIMGmap;
 GLOBALREF  HTProtocol LYLynxCookies;
+GLOBALREF  HTProtocol LYLynxStatusMessages;
 #endif /* GLOBALREF_IS_MACRO */

 PUBLIC void LYRegisterLynxProtocols NOARGS
@@ -2071,13 +2073,14 @@
     HTRegisterProtocol(&LYLynxCGI);
     HTRegisterProtocol(&LYLynxIMGmap);
     HTRegisterProtocol(&LYLynxCookies);
+    HTRegisterProtocol(&LYLynxStatusMessages);
 }

 #ifndef NO_CONFIG_INFO
 /*
  *  Some stuff to reload lynx.cfg without restarting new lynx session,
  *  also load options menu items and command-line options
- *  to make things consistent.  Not implemented yet.
+ *  to make things consistent.
  *  Warning: experimental, more main() reorganization required.
  *
  *  Called by user of interactive session by LYNXCFG://reload/ link.
@@ -2124,7 +2127,7 @@
        custom_display_charset = FALSE;
        memset((char*)charset_subsets, 0, sizeof(charset_subset_t)*MAXCHARSETS);
 #endif
-       free_lynx_cfg(); /* free downloaders, printers, not always environments 
*/
+       free_lynx_cfg(); /* free downloaders, printers, environments */
        /*
         *  Process the configuration file.
         */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]