diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | config.h.dist | 3 | ||||
-rwxr-xr-x | configure | 6 | ||||
-rw-r--r-- | file.c | 17 | ||||
-rw-r--r-- | fm.h | 5 | ||||
-rw-r--r-- | menu.c | 4 | ||||
-rw-r--r-- | proto.h | 6 | ||||
-rw-r--r-- | rc.c | 11 | ||||
-rw-r--r-- | url.c | 115 |
10 files changed, 160 insertions, 11 deletions
@@ -1,6 +1,7 @@ 2002-01-15 Fumitoshi UKAI <ukai@debian.or.jp> * [w3m-dev 02832] external URI loader support + * NEWS: support external URI loader * config.h.dist (USE_EXTERNAL_URI_LOADER): added * config.h.dist (USER_URIMETHODMAP): added * config.h.dist (SYS_URIMETHODMAP): added @@ -1914,4 +1915,4 @@ * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.213 2002/01/14 15:59:16 ukai Exp $ +$Id: ChangeLog,v 1.214 2002/01/14 16:00:59 ukai Exp $ @@ -1,5 +1,6 @@ w3m 0.3? +* support external URI loader * support -dump_extra ftp:// * new regex implementation diff --git a/config.h.dist b/config.h.dist index a55d00f..e1208ae 100644 --- a/config.h.dist +++ b/config.h.dist @@ -117,6 +117,7 @@ MODEL=Linux.i686-monster-ja #undef FTPPASS_HOSTNAMEGEN #undef USE_NNTP #undef USE_GOPHER +#define USE_EXTERNAL_URI_LOADER #undef USE_ALARM #define USE_HELP_CGI @@ -147,6 +148,8 @@ MODEL=Linux.i686-monster-ja #define SYS_MAILCAP "/etc/mailcap" #define USER_MIMETYPES "~/.mime.types" #define SYS_MIMETYPES "/usr/local/lib/mime.types" +#define USER_URIMETHODMAP RC_DIR "/urimethodmap" +#define SYS_URIMETHODMAP ETC_DIR "/urimethodmap" #define DEF_SAVE_FILE "index.html" @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: configure,v 1.47 2002/01/05 16:13:27 ukai Exp $ +# $Id: configure,v 1.48 2002/01/14 15:59:17 ukai Exp $ # Configuration. # @@ -698,6 +698,7 @@ else fi # protocols? +ask_param "External URI loader support" use_external_uri_loader y ask_param "NNTP support" use_nntp $include_opt ask_param "Gopher support" use_gopher $include_opt @@ -2044,6 +2045,7 @@ $def_use_cookie $def_use_ssl $def_use_ssl_verify $def_ftppass_hostnamegen +$def_use_external_uri_loader $def_use_nntp $def_use_gopher $def_use_alarm @@ -2076,6 +2078,8 @@ $def_use_help_cgi #define SYS_MAILCAP "/etc/mailcap" #define USER_MIMETYPES "~/.mime.types" #define SYS_MIMETYPES "$MIME_TYPES" +#define USER_URIMETHODMAP RC_DIR "/urimethodmap" +#define SYS_URIMETHODMAP ETC_DIR "/urimethodmap" #define DEF_SAVE_FILE "index.html" @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.42 2002/01/12 13:33:47 ukai Exp $ */ +/* $Id: file.c,v 1.43 2002/01/14 15:59:17 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -1069,14 +1069,27 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, else { b = dirBuffer(pu.real_file); if (b == NULL) - return NULL; + return NO_BUFFER; t = "text/html"; b->real_scheme = pu.scheme; goto loaded; } } } + break; +#ifdef USE_EXTERNAL_URI_LOADER + case SCM_UNKNOWN: + tmp = searchURIMethods(&pu); + if (tmp != NULL) { + b = loadGeneralFile(tmp->ptr, NULL, NO_REFERER, 0, NULL); + if (b != NO_BUFFER) + return b; + } + break; +#endif } + disp_err_message(Sprintf("Unknown URI: %s", + parsedURL2Str(&pu)->ptr)->ptr, FALSE); return NO_BUFFER; } @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.36 2001/12/27 17:50:56 ukai Exp $ */ +/* $Id: fm.h,v 1.37 2002/01/14 15:59:17 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -784,6 +784,9 @@ global struct cookie *First_cookie init(NULL); global char *mailcap_files init(USER_MAILCAP ", " SYS_MAILCAP); global char *mimetypes_files init(USER_MIMETYPES ", " SYS_MIMETYPES); +#ifdef USE_EXTERNAL_URI_LOADER +global char *urimethodmap_files init(USER_URIMETHODMAP ", " SYS_URIMETHODMAP); +#endif global TextList *fileToDelete; @@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.11 2002/01/10 15:43:11 ukai Exp $ */ +/* $Id: menu.c,v 1.12 2002/01/14 15:59:17 ukai Exp $ */ /* * w3m menu.c */ @@ -1281,7 +1281,7 @@ initSelectMenu(void) conv_from_system(buf->currentURL.real_file)); } break; - case SCM_UNKNOWN: + // case SCM_UNKNOWN: case SCM_MISSING: break; default: @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.23 2002/01/11 20:05:58 ukai Exp $ */ +/* $Id: proto.h,v 1.24 2002/01/14 15:59:17 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -110,6 +110,10 @@ extern void setAlarmEvent(int sec, short status, int cmd, void *data); extern int currentLn(Buffer *buf); extern void tmpClearBuffer(Buffer *buf); extern char *filename_extension(char *patch, int is_url); +#ifdef USE_EXTERNAL_URI_LOADER +extern void initURIMethods(); +extern Str searchURIMethods(ParsedURL *pu); +#endif extern void examineFile(char *path, URLFile *uf); extern char *acceptableEncoding(); extern int dir_exist(char *path); @@ -1,4 +1,4 @@ -/* $Id: rc.c,v 1.24 2001/12/27 17:37:49 ukai Exp $ */ +/* $Id: rc.c,v 1.25 2002/01/14 15:59:17 ukai Exp $ */ /* * Initialization file etc. */ @@ -110,6 +110,7 @@ static char *config_file = NULL; #define CMT_SHOW_SRCH_STR "検索文字列を表示する" #define CMT_MIMETYPES "利用するmime.types" #define CMT_MAILCAP "利用するmailcap" +#define CMT_URIMETHODMAP "利用するurimethodmap" #define CMT_EDITOR "利用するエディタ" #define CMT_MAILER "利用するメーラ" #define CMT_EXTBRZ "外部ブラウザ" @@ -227,6 +228,7 @@ static char *config_file = NULL; #define CMT_SHOW_SRCH_STR "Show search strings" #define CMT_MIMETYPES "mime.types files" #define CMT_MAILCAP "mailcap files" +#define CMT_URIMETHODMAP "urimethodmap files" #define CMT_EDITOR "Editor" #define CMT_MAILER "Mailer" #define CMT_EXTBRZ "External Browser" @@ -503,6 +505,10 @@ struct param_ptr params6[] = { {"mime_types", P_STRING, PI_TEXT, (void *)&mimetypes_files, CMT_MIMETYPES, NULL}, {"mailcap", P_STRING, PI_TEXT, (void *)&mailcap_files, CMT_MAILCAP, NULL}, +#ifdef USE_EXTERNAL_URI_LOADER + {"urimethodmap", P_STRING, PI_TEXT, (void *)&urimethodmap_files, + CMT_URIMETHODMAP, NULL}, +#endif {"editor", P_STRING, PI_TEXT, (void *)&Editor, CMT_EDITOR, NULL}, {"mailer", P_STRING, PI_TEXT, (void *)&Mailer, CMT_MAILER, NULL}, {"extbrowser", P_STRING, PI_TEXT, (void *)&ExtBrowser, CMT_EXTBRZ, NULL}, @@ -1099,6 +1105,9 @@ sync_with_option(void) #endif initMailcap(); initMimeTypes(); +#ifdef USE_EXTERNAL_URI_LOADER + initURIMethods(); +#endif if (AcceptLang == NULL || *AcceptLang == '\0') { #if LANG == JA @@ -1,4 +1,4 @@ -/* $Id: url.c,v 1.32 2002/01/12 15:34:34 ukai Exp $ */ +/* $Id: url.c,v 1.33 2002/01/14 15:59:17 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include <sys/socket.h> @@ -709,6 +709,10 @@ parseURL(char *url, ParsedURL *p_url, ParsedURL *current) goto analyze_file; } /* scheme part has been found */ + if (p_url->scheme == SCM_UNKNOWN) { + p_url->file = allocStr(url, -1); + return; + } /* get host and port */ if (p[0] != '/' || p[1] != '/') { /* scheme:foo or scheme:/foo */ p_url->host = NULL; @@ -1083,9 +1087,12 @@ _parsedURL2Str(ParsedURL *pu, int pass) #endif /* USE_SSL */ }; - if (pu->scheme == SCM_UNKNOWN || pu->scheme == SCM_MISSING) { + if (pu->scheme == SCM_MISSING) { return Strnew_charp("???"); } + else if (pu->scheme == SCM_UNKNOWN) { + return Strnew_charp(pu->file); + } if (pu->host == NULL && pu->file == NULL && pu->label != NULL) { /* local label */ return Sprintf("#%s", pu->label); @@ -1945,3 +1952,107 @@ filename_extension(char *path, int is_url) else return last_dot; } + +#ifdef USE_EXTERNAL_URI_LOADER +static struct table2 **urimethods; + +static struct table2 * +loadURIMethods(char *filename) +{ + FILE *f; + int i, n; + Str tmp; + struct table2 *um; + char *up, *p; + + f = fopen(expandName(filename), "r"); + if (f == NULL) + return NULL; + i = 0; + while (tmp = Strfgets(f), tmp->length > 0) { + if (tmp->ptr[0] != '#') + i++; + } + fseek(f, 0, 0); + n = i; + um = New_N(struct table2, n + 1); + i = 0; + while (tmp = Strfgets(f), tmp->length > 0) { + if (tmp->ptr[0] == '#') + continue; + while (IS_SPACE(Strlastchar(tmp))) + Strshrink(tmp, 1); + for (up = p = tmp->ptr; *p != '\0'; p++) { + if (*p == ':') { + um[i].item1 = Strnew_charp_n(up, p - up)->ptr; + p++; + break; + } + } + if (*p == '\0') + continue; + while (*p != '\0' && IS_SPACE(*p)) + p++; + um[i].item2 = Strnew_charp(p)->ptr; + i++; + } + um[i].item1 = NULL; + um[i].item2 = NULL; + fclose(f); + return um; +} + +void +initURIMethods() +{ + TextList *methodmap_list = NULL; + TextListItem *tl; + int i; + + if (non_null(urimethodmap_files)) + methodmap_list = make_domain_list(urimethodmap_files); + if (methodmap_list == NULL) + return; + urimethods = New_N(struct table2 *, (methodmap_list->nitem + 1)); + for (i = 0, tl = methodmap_list->first; tl; tl = tl->next) { + urimethods[i] = loadURIMethods(tl->ptr); + if (urimethods[i]) + i++; + } + urimethods[i] = NULL; +} + +Str +searchURIMethods(ParsedURL *pu) +{ + struct table2 *ump; + int i; + Str scheme = NULL; + Str url; + char *p; + + if (pu->scheme != SCM_UNKNOWN) + return NULL; /* use internal */ + if (urimethods == NULL) + return NULL; + url = parsedURL2Str(pu); + for (p = url->ptr; *p != '\0'; p++) { + if (*p == ':') { + scheme = Strnew_charp_n(url->ptr, p - url->ptr); + break; + } + } + if (scheme == NULL) + return NULL; + + for (i = 0; (ump = urimethods[i]) != NULL; i++) { + while (ump->item1 != NULL) { + if (strcmp(ump->item1, scheme->ptr) == 0) { + return Sprintf(ump->item2, url_quote(url->ptr)); + } + ump++; + } + } + return NULL; +} +#endif |