w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 925e59c9db16a87027aceb7fd251bec67da98587
parent 0390d7b9931cc0f8333b4ac1ebde7eed5064b127
Author: ukai <ukai>
Date:   Sat, 26 Jul 2003 17:16:24 +0000

[w3m-dev 03945] Re: application/xhtml+xml support
* Makefile.in (ETC_DIR): added
	(CONF_DIR): added
	(DEFS): add CONF_DIR
	(MAKE_ARGS): add CONF_DIR
* config.h.in (SYS_MAILCAP): use CONF_DIR
	(SYS_URIMETHODMAP): use CONF_DIR
* func.c (sys_current_keymap_file): added
	(interpret_keymap): added
	(initKeymap): use interpret_keymap
	(interpret_mouse_action): added
	(initMouseAction): use interpret_mouse_action
* indep.c (w3m_conf_dir): added
* indep.h (w3m_conf_dir): added
* menu.c (interpret_menu): added
	(initMenu): use interpret_menu
* proto.h (confFile): added
* rc.c (init_rc): read config file by interpret_rc
	(confFile): added
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 22++++++++++++++++++++++
MMakefile.in | 8++++++--
Mconfig.h.in | 7+++----
Mfunc.c | 81++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
Mindep.c | 6++++++
Mindep.h | 1+
Mmenu.c | 54+++++++++++++++++++++++++++++++-----------------------
Mproto.h | 1+
Mrc.c | 10++++++++++
9 files changed, 133 insertions(+), 57 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,25 @@ +2003-07-27 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03945] Re: application/xhtml+xml support + * Makefile.in (ETC_DIR): added + (CONF_DIR): added + (DEFS): add CONF_DIR + (MAKE_ARGS): add CONF_DIR + * config.h.in (SYS_MAILCAP): use CONF_DIR + (SYS_URIMETHODMAP): use CONF_DIR + * func.c (sys_current_keymap_file): added + (interpret_keymap): added + (initKeymap): use interpret_keymap + (interpret_mouse_action): added + (initMouseAction): use interpret_mouse_action + * indep.c (w3m_conf_dir): added + * indep.h (w3m_conf_dir): added + * menu.c (interpret_menu): added + (initMenu): use interpret_menu + * proto.h (confFile): added + * rc.c (init_rc): read config file by interpret_rc + (confFile): added + 2003-07-23 Takahashi Youichirou <nikuq@hk.airnet.ne.jp> * [w3m-dev 03942] Save history diff --git a/Makefile.in b/Makefile.in @@ -28,12 +28,15 @@ CGIBIN_DIR = $(libexecdir)/$(package)/cgi-bin 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 @@ W3M_LIBS = @W3M_LIBS@ 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 --git a/config.h.in b/config.h.in @@ -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 --git a/func.c b/func.c @@ -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 @@ setKeymap(char *p, int lineno, int verbose) 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 @@ initKeymap(int force) } 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, &current_keymap_file, + force || !keymap_initialized); + fclose(kf); + } keymap_initialized = TRUE; } @@ -506,24 +521,13 @@ setMouseAction2(MouseActionMap * map, char *p) 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 @@ initMouseAction(void) 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 --git a/indep.c b/indep.c @@ -733,6 +733,12 @@ w3m_etc_dir() } 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 --git a/indep.h b/indep.h @@ -68,6 +68,7 @@ extern char *shell_quote(char *str); 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 --git a/menu.c b/menu.c @@ -1669,32 +1669,14 @@ optionMenu(int x, int y, char **label, int *variable, int initial, /* --- 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 @@ initMenu(void) 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 --git a/proto.h b/proto.h @@ -580,6 +580,7 @@ extern void panel_set_option(struct parsed_tagarg *); 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 --git a/rc.c b/rc.c @@ -1397,6 +1397,10 @@ init_rc(void) 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); @@ -1584,6 +1588,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 char * helpFile(char *base)