Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.2:Ports
w3m
w3m-0.4.1-session-mgmt.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File w3m-0.4.1-session-mgmt.dif of Package w3m
fm.h | 1 history.c | 21 ++++++++++++++++++-- main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 3 deletions(-) Index: fm.h =================================================================== --- fm.h.orig +++ fm.h @@ -933,6 +933,7 @@ global int emacs_like_lineedit init(FALS global int vi_prec_num init(FALSE); global int label_topline init(FALSE); global int nextpage_topline init(FALSE); +global char *Session init(NULL); global char *displayTitleTerm init(NULL); global int displayLink init(FALSE); global int displayLinkNumber init(FALSE); Index: history.c =================================================================== --- history.c.orig +++ history.c @@ -1,5 +1,6 @@ /* $Id: history.c,v 1.11 2003/09/26 17:59:51 ukai Exp $ */ #include "fm.h" +#include <errno.h> #ifdef USE_HISTORY Buffer * @@ -36,11 +37,21 @@ loadHistory(Hist *hist) { FILE *f; Str line; +#define FNAMELEN 255 + char fname[FNAMELEN+1] = HISTORY_FILE; + if (hist == NULL) return; - if ((f = fopen(rcFile(HISTORY_FILE), "rt")) == NULL) + if (Session) { + strncat(fname, ".", FNAMELEN -6 - strlen(fname)); + strncat(fname, Session, FNAMELEN -6 - strlen(fname)); + } + if ((f = fopen(rcFile(fname), "rt")) == NULL) { + if (errno != ENOENT) + perror("error reading history file"); return; + } while (!feof(f)) { line = Strfgets(f); @@ -60,6 +71,8 @@ saveHistory(Hist *hist, size_t size) FILE *f; HistItem *item; char *tmpf; +#define FNAMELEN 255 + char fname[FNAMELEN+1] = HISTORY_FILE; if (hist == NULL || hist->list == NULL) return; @@ -79,7 +92,11 @@ saveHistory(Hist *hist, size_t size) disp_err_message("Can't save history", FALSE); return; } - rename(tmpf, rcFile(HISTORY_FILE)); + if (Session) { + strncat(fname, ".", FNAMELEN -6 - strlen(fname)); + strncat(fname, Session, FNAMELEN -6 - strlen(fname)); + } + rename(tmpf, rcFile(fname)); } #endif /* USE_HISTORY */ Index: main.c =================================================================== --- main.c.orig +++ main.c @@ -6,6 +6,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> +#include <errno.h> #include <fcntl.h> #if defined(HAVE_WAITPID) || defined(HAVE_WAIT3) #include <sys/wait.h> @@ -234,6 +235,7 @@ fusage(FILE * f, int err) fprintf(f, " -header string insert string as a header\n"); fprintf(f, " +<num> goto <num> line\n"); fprintf(f, " -num show line number\n"); + fprintf(f, " -session=<id> use session <id>\n"); fprintf(f, " -no-proxy don't use proxy\n"); #ifdef INET6 fprintf(f, " -4 IPv4 only (-o dns_order=4)\n"); @@ -271,6 +273,8 @@ static char *getCodePage(void); #endif #endif +char *loadBufferInfo(void); + static GC_warn_proc orig_GC_warn_proc = NULL; #define GC_WARN_KEEP_MAX (20) @@ -707,6 +711,8 @@ main(int argc, char **argv, char **envp) squeezeBlankLine = TRUE; else if (!strcmp("-X", argv[i])) Do_not_use_ti_te = TRUE; + else if (!strncmp("-session=", argv[i], 9)) + Session = argv[i] + 9; else if (!strcmp("-title", argv[i])) displayTitleTerm = getenv("TERM"); else if (!strncmp("-title=", argv[i], 7)) @@ -748,6 +754,22 @@ main(int argc, char **argv, char **envp) i++; } + /* if last session has been saved, get last URL */ + { + char * str; /* we blantantly skip the release of this memory -- + this seems to be the way to do things in w3m anyway + ...*/ + if (Session && (str = loadBufferInfo()) != NULL ) { + /* The URL from last session overrides the URL(s) from the command + * line */ + load_argv[0] = str; + load_argc = 1; + } + } +#ifdef USE_HISTORY + loadHistory(URLHist); +#endif /* not USE_HISTORY */ + #ifdef __WATT32__ if (w3m_debug) dbug_init(); @@ -1386,14 +1408,54 @@ tmpClearBuffer(Buffer *buf) static Str currentURL(void); #ifdef USE_BUFINFO +char * +loadBufferInfo() +{ + FILE *fp; + Str line; + char *str; +#define FNAMELEN 255 + char fname[FNAMELEN+1] = "bufinfo"; + + if (Session) { + strncat(fname, ".", FNAMELEN -6 - strlen(fname)); + strncat(fname, Session, FNAMELEN -6 - strlen(fname)); + } + if ((fp = fopen(rcFile(fname), "r")) == NULL) { + if (errno != ENOENT) + perror("error reading bufinfo file"); + return NULL; + } + line = Strfgets(fp); + Strchop(line); + Strremovefirstspaces(line); + Strremovetrailingspaces(line); + fclose(fp); + if (line->length == 0) { + str=NULL; + } else { + str=allocStr(line->ptr, -1); + } + Strclear(line); + Strfree(line); + return str; +} + void saveBufferInfo() { FILE *fp; +#define FNAMELEN 255 + char fname[FNAMELEN+1] = "bufinfo"; if (w3m_dump) return; - if ((fp = fopen(rcFile("bufinfo"), "w")) == NULL) { + if (Session) { + strncat(fname, ".", FNAMELEN -6 - strlen(fname)); + strncat(fname, Session, FNAMELEN -6 - strlen(fname)); + } + if ((fp = fopen(rcFile(fname), "w")) == NULL) { + perror("error writing bufinfo file"); return; } fprintf(fp, "%s\n", currentURL()->ptr);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor