[w3m-dev 02765] backend

From: Hironori Sakamoto <h-saka@lsi.nec.co.jp>
This commit is contained in:
Fumitoshi UKAI
2001-12-27 17:50:56 +00:00
parent c492b31f97
commit 119ef254bc
4 changed files with 34 additions and 21 deletions
+10 -1
View File
@@ -1,3 +1,12 @@
2001-12-28 Hironori Sakamoto <h-saka@lsi.nec.co.jp>
* [w3m-dev 02765] backend
* backend.c (internal_get): cleanups
* file.c (flushline): remove w3m_backend checks
* file.c (loadHTMLstream): add w3m_backend check
* fm.h (backend_halfdump_str): deleted
* fm.h (backend_halfdump_buf): added
2001-12-28 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> 2001-12-28 Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
* [w3m-dev 02761] * [w3m-dev 02761]
@@ -1723,4 +1732,4 @@
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.191 2001/12/27 17:45:25 ukai Exp $ $Id: ChangeLog,v 1.192 2001/12/27 17:50:56 ukai Exp $
+16 -7
View File
@@ -1,4 +1,4 @@
/* $Id: backend.c,v 1.5 2001/11/24 02:01:26 ukai Exp $ */ /* $Id: backend.c,v 1.6 2001/12/27 17:50:56 ukai Exp $ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
@@ -136,15 +136,21 @@ internal_get(char *url, int flag, FormList *request)
{ {
Buffer *buf; Buffer *buf;
backend_halfdump_str = Strnew_charp("<pre>\n"); backend_halfdump_buf = NULL;
do_download = flag; do_download = flag;
buf = loadGeneralFile(url, NULL, NO_REFERER, 0, request); buf = loadGeneralFile(url, NULL, NO_REFERER, 0, request);
do_download = FALSE; do_download = FALSE;
if (buf != NULL && buf != NO_BUFFER) { if (buf != NULL && buf != NO_BUFFER) {
if (!strcasecmp(buf->type, "text/html")) { if (!strcasecmp(buf->type, "text/html") && backend_halfdump_buf) {
Strcat(backend_halfdump_str, TextLineListItem *p;
Sprintf("</pre><title>%s</title>\n", buf->buffername)); Str first, last;
print_headers(buf, backend_halfdump_str->length); int len = 0;
for (p = backend_halfdump_buf->first; p; p = p->next)
len += p->ptr->line->length + 1;
first = Strnew_charp("<pre>\n");
last = Strnew_m_charp("</pre><title>", html_quote(buf->buffername),
"</title>\n", NULL);
print_headers(buf, len + first->length + last->length);
if (buf->formlist) { if (buf->formlist) {
FormList *fp; FormList *fp;
int fid = 0; int fid = 0;
@@ -154,7 +160,10 @@ internal_get(char *url, int flag, FormList *request)
print_formlist(--fid, fp); print_formlist(--fid, fp);
} }
printf("\n"); printf("\n");
Strfputs(backend_halfdump_str, stdout); printf("%s", first->ptr);
for (p = backend_halfdump_buf->first; p; p = p->next)
printf("%s\n", p->ptr->line->ptr);
printf("%s", last->ptr);
} }
else { else {
if (!strcasecmp(buf->type, "text/plain")) { if (!strcasecmp(buf->type, "text/plain")) {
+6 -11
View File
@@ -1,4 +1,4 @@
/* $Id: file.c,v 1.36 2001/12/27 17:45:26 ukai Exp $ */ /* $Id: file.c,v 1.37 2001/12/27 17:50:56 ukai Exp $ */
#include "fm.h" #include "fm.h"
#include <sys/types.h> #include <sys/types.h>
#include "myctype.h" #include "myctype.h"
@@ -2025,13 +2025,8 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
#endif #endif
if (lbuf->pos > h_env->maxlimit) if (lbuf->pos > h_env->maxlimit)
h_env->maxlimit = lbuf->pos; h_env->maxlimit = lbuf->pos;
if (buf) { if (buf)
pushTextLine(buf, lbuf); pushTextLine(buf, lbuf);
if (w3m_backend) {
Strcat(backend_halfdump_str, lbuf->line);
Strcat_char(backend_halfdump_str, '\n');
}
}
else { else {
Strfputs(lbuf->line, f); Strfputs(lbuf->line, f);
fputc('\n', f); fputc('\n', f);
@@ -2046,11 +2041,9 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
Str tmp = Strnew(), tmp2 = Strnew(); Str tmp = Strnew(), tmp2 = Strnew();
#define APPEND(str) \ #define APPEND(str) \
if (buf) { \ if (buf) \
appendTextLine(buf,(str),0); \ appendTextLine(buf,(str),0); \
if (w3m_backend) \ else \
Strcat(backend_halfdump_str, (str)); \
} else \
Strfputs((str),f) Strfputs((str),f)
while (*p) { while (*p) {
@@ -5074,6 +5067,8 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal)
newBuf->document_code = code; newBuf->document_code = code;
content_charset = '\0'; content_charset = '\0';
#endif /* JP_CHARSET */ #endif /* JP_CHARSET */
if (w3m_backend)
backend_halfdump_buf = htmlenv1.buf;
HTMLlineproc2(newBuf, htmlenv1.buf); HTMLlineproc2(newBuf, htmlenv1.buf);
} }
+2 -2
View File
@@ -1,4 +1,4 @@
/* $Id: fm.h,v 1.35 2001/12/27 17:37:49 ukai Exp $ */ /* $Id: fm.h,v 1.36 2001/12/27 17:50:56 ukai Exp $ */
/* /*
* w3m: WWW wo Miru utility * w3m: WWW wo Miru utility
* *
@@ -881,7 +881,7 @@ global int use_lessopen init(FALSE);
global int FollowRedirection init(10); global int FollowRedirection init(10);
global int w3m_backend init(FALSE); global int w3m_backend init(FALSE);
global Str backend_halfdump_str; global TextLineList *backend_halfdump_buf;
global TextList *backend_batch_commands init(NULL); global TextList *backend_batch_commands init(NULL);
int backend(void); int backend(void);
extern void deleteFiles(void); extern void deleteFiles(void);