diff options
author | Eduardo Chappa <chappa@washington.edu> | 2020-06-14 15:54:08 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2020-06-14 15:54:08 -0600 |
commit | 4fa8e0bba357cfc2810ebe8c2dff79ae1778ada7 (patch) | |
tree | 9b2a9976c330aed7aa380b4bef45c952e54c3f30 /alpine/help.c | |
parent | 35aeccf9de673b44bb0f3e2f6d0cb7cbf7a0270e (diff) | |
download | alpine-4fa8e0bba357cfc2810ebe8c2dff79ae1778ada7.tar.xz |
* Creation of Alpine's Privacy Policy. This is presented as a link to an online
document from the Release Notes. Upon user request,
Alpine downloads and displays this document. Links to the privacy policy are
also displayed when a user starts Alpine for the first time, or when a user
starts a new version of Alpine. There is no default exit greeting command for
these screens, and to exit the user must press "E", instead of the old default,
which was the RETURN command. The RETURN command will open the handle on which
the cursor is on, which by default is the Privacy Policy
Diffstat (limited to 'alpine/help.c')
-rw-r--r-- | alpine/help.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/alpine/help.c b/alpine/help.c index a3a502a6..6c5f2e70 100644 --- a/alpine/help.c +++ b/alpine/help.c @@ -119,8 +119,8 @@ the first line in the text. int helper_internal(HelpType text, char *frag, char *title, int flags) { - char **shown_text; - int cmd = MC_NONE; + char **shown_text, **external_text = NULL, *help_text = NULL, **rv; + int cmd = MC_NONE, is_external; long offset = 0L; char *error = NULL, tmp_title[MAX_SCREEN_COLS + 1]; STORE_S *store; @@ -132,6 +132,37 @@ helper_internal(HelpType text, char *frag, char *title, int flags) /* assumption here is that HelpType is char ** */ shown_text = text; + is_external = 0; + + if(shown_text && *shown_text && !struncmp(*shown_text, "x-alpine-http:", 14)){ + int status; + help_text = http_get(*shown_text + 14, &status); + if(status != HTTP_OK){ + shown_text = NO_HELP; + if(help_text) fs_give((void **) &help_text); + } + else{ + is_external = 1; + if(help_text == NULL) external_text = NO_HELP; + else{ + char *s, *t; + int nlines; + + for(nlines = 0, s = help_text; s != NULL; nlines++){ + s = strchr(s, '\n'); + if(s != NULL) s++; + } + rv = external_text = fs_get((nlines + 1)*sizeof(char *)); + for(s = help_text; s != NULL; s = t){ + t = strchr(s, '\n'); + if(t != NULL) *t++ = '\0'; + *rv++ = cpystr(s); + } + *rv = NULL; + } + } + + } if(F_ON(F_BLANK_KEYMENU,ps_global)){ FOOTER_ROWS(ps_global) = 3; @@ -149,16 +180,16 @@ helper_internal(HelpType text, char *frag, char *title, int flags) * Turn it into a charstar with digested html */ do{ - init_helper_getc(shown_text); + init_helper_getc(is_external ? external_text : shown_text); init_handles(&handles); memset(&hscroll, 0, sizeof(HELP_SCROLL_S)); - hscroll.help_source = shown_text; + hscroll.help_source = is_external ? external_text : shown_text; if((store = so_get(CharStar, NULL, EDIT_ACCESS)) != NULL){ gf_set_so_writec(&pc, store); gf_filter_init(); - if(!struncmp(shown_text[0], "<html>", 6)) + if(!struncmp(hscroll.help_source[0], "<html>", 6) || is_external) gf_link_filter(gf_html2plain, gf_html2plain_opt("x-alpine-help:", ps_global->ttyo->screen_cols, @@ -205,18 +236,18 @@ helper_internal(HelpType text, char *frag, char *title, int flags) sargs.text.handles = sargs.text.handles->next; if(!(sargs.bar.title = title)){ - if(!struncmp(shown_text[0], "<html>", 6)){ + if(!struncmp(hscroll.help_source[0], "<html>", 6) || is_external){ char *p; int i; /* if we're looking at html, look for a <title> * in the <head>... */ for(i = 1; - shown_text[i] - && struncmp(shown_text[i], "</head>", 7); + hscroll.help_source[0][i] + && struncmp(hscroll.help_source[i], "</head>", 7); i++) - if(!struncmp(shown_text[i], "<title>", 7)){ - strncpy(tmp_20k_buf, &shown_text[i][7], SIZEOF_20KBUF); + if(!struncmp(hscroll.help_source[i], "<title>", 7)){ + strncpy(tmp_20k_buf, &hscroll.help_source[i][7], SIZEOF_20KBUF); tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; if((p = strchr(tmp_20k_buf, '<')) != NULL) *p = '\0'; @@ -336,6 +367,12 @@ helper_internal(HelpType text, char *frag, char *title, int flags) } while(cmd == MC_RESIZE); + if(external_text != NULL){ + for(rv = external_text; *rv != NULL; *rv++) + fs_give((void **) &*rv); + fs_give((void **) external_text); + } + if(help_text) fs_give((void **) &help_text); return(cmd); } |