[w3m-dev 03945] Re: application/xhtml+xml support
Hironori SAKAMOTO <[email protected]>
| Newsgroups | gmane.comp.web.w3m.devel |
|---|---|
| Message-ID | <[email protected]> |
> > mailcap ;) > mailcap > application/xhtml+xml; cat %s; x-htmloutput > ? PREFIX/etc/w3m/mailcap ETC_DIR PREFIX/etc/w3m/ config PREFIX/etc/w3m/config (PREFIX/etc/w3mconfig ) keymap, menu, mouse ----------------------------------- <[email protected]> http://www2u.biglobe.ne.jp/~hsaka/ diff -u Makefile.in.orig Makefile.in --- Makefile.in.orig Mon Apr 7 11:51:44 2003 +++ Makefile.in Fri Jul 25 10:31:16 2003 @@ -28,12 +28,15 @@ AUXBIN_DIR = $(libexecdir)/$(package) HELP_DIR = $(datadir)/$(package) RC_DIR = ~/.$(package) +ETC_DIR = $(sysconfdir) +CONF_DIR = $(sysconfdir)/$(package) CFLAGS = $(OPTS) @CFLAGS@ $(DEFS) CPPFLAGS = @CPPFLAGS@ DEFS = @DEFS@ -I. -I$(top_srcdir) -DAUXBIN_DIR=\"$(AUXBIN_DIR)\" \ -DLIB_DIR=\"$(CGIBIN_DIR)\" -DHELP_DIR=\"$(HELP_DIR)\" \ - -DETC_DIR=\"$(sysconfdir)\" -DRC_DIR=\"$(RC_DIR)\" + -DETC_DIR=\"$(ETC_DIR)\" -DCONF_DIR=\"$(CONF_DIR)\" \ + -DRC_DIR=\"$(RC_DIR)\" LDFLAGS = @LDFLAGS@ LIBS = -L. -lindep @LIBS@ W3M_LIBS = @W3M_LIBS@ @@ -41,7 +44,8 @@ MAKE_ARGS = PERL='$(PERL)' MKDIR='$(MKDIR)' INSTALL='$(INSTALL)' \ BIN_DIR='$(bindir)' AUXBIN_DIR='$(AUXBIN_DIR)' \ LIB_DIR='$(CGIBIN_DIR)' \ - HELP_DIR='$(HELP_DIR)' MAN_DIR='$(mandir)' ETC_DIR='$(sysconfdir)' \ + HELP_DIR='$(HELP_DIR)' MAN_DIR='$(mandir)' ETC_DIR='$(ETC_DIR)' \ + CONF_DIR='$(CONF_DIR)' \ RC_DIR='$(RC_DIR)' DESTDIR='$(DESTDIR)' KEYBIND_SRC='$(KEYBIND_SRC)' IMGCFLAGS = @IMGX11CFLAGS@ @IMGFBCFLAGS@ diff -u config.h.in.orig config.h.in --- config.h.in.orig Mon Apr 7 11:51:54 2003 +++ config.h.in Fri Jul 25 10:25:02 2003 @@ -12,7 +12,6 @@ #define IMGDISPLAY "w3mimgdisplay" #define XFACE2XPM "xface2xpm" -#define RC_DIR "~/.w3m" #define BOOKMARK "bookmark.html" #define CONFIG_FILE "config" #define KEYMAP_FILE "keymap" @@ -24,11 +23,11 @@ #define PASSWD_FILE RC_DIR "/passwd" #define PRE_FORM_FILE RC_DIR "/pre_form" #define USER_MAILCAP RC_DIR "/mailcap" -#define SYS_MAILCAP ETC_DIR "mailcap" +#define SYS_MAILCAP CONF_DIR "/mailcap" #define USER_MIMETYPES "~/.mime.types" -#define SYS_MIMETYPES ETC_DIR "mime.types" +#define SYS_MIMETYPES ETC_DIR "/mime.types" #define USER_URIMETHODMAP RC_DIR "/urimethodmap" -#define SYS_URIMETHODMAP ETC_DIR "/urimethodmap" +#define SYS_URIMETHODMAP CONF_DIR "/urimethodmap" #define DEF_SAVE_FILE "index.html" diff -u func.c.orig func.c --- func.c.orig Tue May 13 10:27:31 2003 +++ func.c Fri Jul 25 10:58:35 2003 @@ -15,6 +15,7 @@ #define KEYDATA_HASH_SIZE 16 static Hash_iv *keyData = NULL; static char keymap_initialized = FALSE; +static struct stat sys_current_keymap_file; static struct stat current_keymap_file; void @@ -108,26 +109,25 @@ putHash_iv(keyData, c, NULL); } -void -initKeymap(int force) +static void +interpret_keymap(FILE *kf, struct stat *current, int force) { - FILE *kf; + int fd; + struct stat kstat; Str line; char *p, *s, *emsg; int lineno; int verbose = 1; - int fd; - struct stat kstat; extern int str_to_bool(char *value, int old); - if ((kf = fopen(rcFile(keymap_file), "rt")) == NULL || - ((fd = fileno(kf)) < 0 || fstat(fd, &kstat) || - (!force && keymap_initialized && - kstat.st_mtime == current_keymap_file.st_mtime && - kstat.st_dev == current_keymap_file.st_dev && - kstat.st_ino == current_keymap_file.st_ino && - kstat.st_size == current_keymap_file.st_size))) + if ((fd = fileno(kf)) < 0 || fstat(fd, &kstat) || + (!force && + kstat.st_mtime == current->st_mtime && + kstat.st_dev == current->st_dev && + kstat.st_ino == current->st_ino && + kstat.st_size == current->st_size)) return; + *current = kstat; lineno = 0; while (!feof(kf)) { @@ -157,8 +157,23 @@ } setKeymap(p, lineno, verbose); } - fclose(kf); - current_keymap_file = kstat; +} + +void +initKeymap(int force) +{ + FILE *kf; + + if ((kf = fopen(confFile(KEYMAP_FILE), "rt")) != NULL) { + interpret_keymap(kf, &sys_current_keymap_file, + force || !keymap_initialized); + fclose(kf); + } + if ((kf = fopen(rcFile(keymap_file), "rt")) != NULL) { + interpret_keymap(kf, ¤t_keymap_file, + force || !keymap_initialized); + fclose(kf); + } keymap_initialized = TRUE; } @@ -506,24 +521,13 @@ map->data = s; } -void -initMouseAction(void) +static void +interpret_mouse_action(FILE *mf) { - FILE *mf; Str line; char *p, *s; int b; - bcopy((void *)&default_mouse_action, (void *)&mouse_action, - sizeof(default_mouse_action)); - mouse_action.lastline_map[0] = New_N(MouseActionMap, 6); - bcopy((void *)&default_lastline_action, - (void *)mouse_action.lastline_map[0], - sizeof(default_lastline_action)); - - if ((mf = fopen(rcFile(MOUSE_FILE), "rt")) == NULL) - return; - while (!feof(mf)) { line = Strfgets(mf); Strchop(line); @@ -577,6 +581,27 @@ else if (!strcasecmp(s, "tab")) setMouseAction2(&mouse_action.tab_map[b], p); } - fclose(mf); +} + +void +initMouseAction(void) +{ + FILE *mf; + + bcopy((void *)&default_mouse_action, (void *)&mouse_action, + sizeof(default_mouse_action)); + mouse_action.lastline_map[0] = New_N(MouseActionMap, 6); + bcopy((void *)&default_lastline_action, + (void *)mouse_action.lastline_map[0], + sizeof(default_lastline_action)); + + if ((mf = fopen(confFile(MOUSE_FILE), "rt")) != NULL) { + interpret_mouse_action(mf); + fclose(mf); + } + if ((mf = fopen(rcFile(MOUSE_FILE), "rt")) != NULL) { + interpret_mouse_action(mf); + fclose(mf); + } } #endif diff -u indep.c.orig indep.c --- indep.c.orig Tue May 13 10:27:31 2003 +++ indep.c Fri Jul 25 10:30:40 2003 @@ -733,6 +733,12 @@ } char * +w3m_conf_dir() +{ + return w3m_dir("W3M_CONF_DIR", CONF_DIR); +} + +char * w3m_help_dir() { return w3m_dir("W3M_HELP_DIR", HELP_DIR); diff -u indep.h.orig indep.h --- indep.h.orig Thu Apr 10 14:08:47 2003 +++ indep.h Fri Jul 25 10:29:13 2003 @@ -68,6 +68,7 @@ extern char *w3m_auxbin_dir(); extern char *w3m_lib_dir(); extern char *w3m_etc_dir(); +extern char *w3m_conf_dir(); extern char *w3m_help_dir(); #define New(type) ((type*)GC_MALLOC(sizeof(type))) diff -u menu.c.orig menu.c --- menu.c.orig Tue May 13 10:27:31 2003 +++ menu.c Fri Jul 25 10:42:07 2003 @@ -1669,32 +1669,14 @@ /* --- InitMenu --- */ -void -initMenu(void) +static void +interpret_menu(FILE *mf) { - FILE *mf; Str line; char *p, *s; - int in_menu, nmenu = 0, nitem = 0, type; + int in_menu = 0, nmenu = 0, nitem = 0, type; MenuItem *item = NULL; - MenuList *list; - w3mMenuList = New_N(MenuList, 3); - w3mMenuList[0].id = "Main"; - w3mMenuList[0].menu = &MainMenu; - w3mMenuList[0].item = MainMenuItem; - w3mMenuList[1].id = "Select"; - w3mMenuList[1].menu = &SelectMenu; - w3mMenuList[1].item = NULL; - w3mMenuList[2].id = "SelectTab"; - w3mMenuList[2].menu = &SelTabMenu; - w3mMenuList[2].item = NULL; - w3mMenuList[3].id = NULL; - - if ((mf = fopen(rcFile(MENU_FILE), "rt")) == NULL) - goto create_menu; - - in_menu = 0; while (!feof(mf)) { line = Strfgets(mf); Strchop(line); @@ -1734,9 +1716,35 @@ item[nitem].type = MENU_END; } } - fclose(mf); +} + +void +initMenu(void) +{ + FILE *mf; + MenuList *list; + + w3mMenuList = New_N(MenuList, 3); + w3mMenuList[0].id = "Main"; + w3mMenuList[0].menu = &MainMenu; + w3mMenuList[0].item = MainMenuItem; + w3mMenuList[1].id = "Select"; + w3mMenuList[1].menu = &SelectMenu; + w3mMenuList[1].item = NULL; + w3mMenuList[2].id = "SelectTab"; + w3mMenuList[2].menu = &SelTabMenu; + w3mMenuList[2].item = NULL; + w3mMenuList[3].id = NULL; + + if ((mf = fopen(confFile(MENU_FILE), "rt")) != NULL) { + interpret_menu(mf); + fclose(mf); + } + if ((mf = fopen(rcFile(MENU_FILE), "rt")) != NULL) { + interpret_menu(mf); + fclose(mf); + } - create_menu: for (list = w3mMenuList; list->id != NULL; list++) { if (list->item == NULL) continue; diff -u proto.h.orig proto.h --- proto.h.orig Fri Jul 25 10:14:52 2003 +++ proto.h Fri Jul 25 10:38:19 2003 @@ -580,6 +580,7 @@ extern void sync_with_option(void); extern char *rcFile(char *base); extern char *etcFile(char *base); +extern char *confFile(char *base); extern char *auxbinFile(char *base); extern char *libFile(char *base); extern char *helpFile(char *base); diff -u rc.c.orig rc.c --- rc.c.orig Mon Jul 7 19:44:17 2003 +++ rc.c Fri Jul 25 10:38:25 2003 @@ -1397,6 +1397,10 @@ interpret_rc(f); fclose(f); } + if ((f = fopen(confFile(CONFIG_FILE), "rt")) != NULL) { + interpret_rc(f); + fclose(f); + } if ((f = fopen(config_file, "rt")) != NULL) { interpret_rc(f); fclose(f); @@ -1582,6 +1586,12 @@ etcFile(char *base) { return expandPath(Strnew_m_charp(w3m_etc_dir(), "/", base, NULL)->ptr); +} + +char * +confFile(char *base) +{ + return expandPath(Strnew_m_charp(w3m_conf_dir(), "/", base, NULL)->ptr); } #ifndef USE_HELP_CGI