diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/HTML.c | 56 | ||||
-rw-r--r-- | src/LYCookie.c | 39 | ||||
-rw-r--r-- | src/LYDownload.c | 8 | ||||
-rw-r--r-- | src/LYGlobalDefs.h | 3 | ||||
-rw-r--r-- | src/LYMain.c | 12 | ||||
-rw-r--r-- | src/LYMainLoop.c | 28 | ||||
-rw-r--r-- | src/LYUtils.c | 30 | ||||
-rw-r--r-- | src/Xsystem.c | 19 | ||||
-rw-r--r-- | src/tidy_tls.c | 32 |
9 files changed, 128 insertions, 99 deletions
diff --git a/src/HTML.c b/src/HTML.c index c9064dba..7dacdee9 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTML.c,v 1.115 2008/09/21 17:46:32 tom Exp $ + * $LynxId: HTML.c,v 1.116 2008/12/14 20:03:28 tom Exp $ * * Structured stream to Rich hypertext converter * ============================================ @@ -1279,38 +1279,40 @@ static int HTML_start_element(HTStructured * me, int element_number, /* * Handle links with a REV attribute. - FM + * Handle REV="made" or REV="owner". - LM & FM + * Handle REL="author" -TD */ if (present && - present[HTML_LINK_REV] && value[HTML_LINK_REV]) { + ((present[HTML_LINK_REV] && + value[HTML_LINK_REV] && + (!strcasecomp("made", value[HTML_LINK_REV]) || + !strcasecomp("owner", value[HTML_LINK_REV]))) || + (present[HTML_LINK_REL] && + value[HTML_LINK_REL] && + (!strcasecomp("author", value[HTML_LINK_REL]))))) { /* - * Handle REV="made" or REV="owner". - LM & FM + * Load the owner element. - FM */ - if (!strcasecomp("made", value[HTML_LINK_REV]) || - !strcasecomp("owner", value[HTML_LINK_REV])) { - /* - * Load the owner element. - FM - */ - HTAnchor_setOwner(me->node_anchor, href); - CTRACE((tfp, "HTML: DOC OWNER '%s' found\n", href)); - FREE(href); + HTAnchor_setOwner(me->node_anchor, href); + CTRACE((tfp, "HTML: DOC OWNER '%s' found\n", href)); + FREE(href); - /* - * Load the RevTitle element if a TITLE attribute and value - * are present. - FM - */ - if (present && present[HTML_LINK_TITLE] && - value[HTML_LINK_TITLE] && - *value[HTML_LINK_TITLE] != '\0') { - StrAllocCopy(title, value[HTML_LINK_TITLE]); - TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); - LYTrimHead(title); - LYTrimTail(title); - if (*title != '\0') - HTAnchor_setRevTitle(me->node_anchor, title); - FREE(title); - } - break; + /* + * Load the RevTitle element if a TITLE attribute and value + * are present. - FM + */ + if (present && present[HTML_LINK_TITLE] && + value[HTML_LINK_TITLE] && + *value[HTML_LINK_TITLE] != '\0') { + StrAllocCopy(title, value[HTML_LINK_TITLE]); + TRANSLATE_AND_UNESCAPE_ENTITIES(&title, TRUE, FALSE); + LYTrimHead(title); + LYTrimTail(title); + if (*title != '\0') + HTAnchor_setRevTitle(me->node_anchor, title); + FREE(title); } + break; } /* diff --git a/src/LYCookie.c b/src/LYCookie.c index a9dacd31..7527de37 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYCookie.c,v 1.92 2008/09/06 14:27:22 tom Exp $ + * $LynxId: LYCookie.c,v 1.94 2008/12/14 19:38:59 tom Exp $ * * Lynx Cookie Support LYCookie.c * =================== @@ -1865,7 +1865,7 @@ char *LYAddCookieHeader(char *hostname, #ifdef USE_PERSISTENT_COOKIES static int number_of_file_cookies = 0; -/* rjp - experiment cookie loading */ +/* rjp - cookie loading */ void LYLoadCookies(char *cookie_file) { FILE *cookie_handle; @@ -2019,13 +2019,19 @@ void LYLoadCookies(char *cookie_file) LYCloseInput(cookie_handle); } -/* rjp - experimental persistent cookie support */ +static FILE *NewCookieFile(char *cookie_file) +{ + CTrace((tfp, "LYStoreCookies: save cookies to %s on exit\n", cookie_file)); + return LYNewTxtFile(cookie_file); +} + +/* rjp - persistent cookie support */ void LYStoreCookies(char *cookie_file) { HTList *dl, *cl; domain_entry *de; cookie *co; - FILE *cookie_handle; + FILE *cookie_handle = NULL; time_t now = time(NULL); /* system specific? - RP */ if (isEmpty(cookie_file) || !strcmp(cookie_file, "/dev/null")) { @@ -2044,11 +2050,13 @@ void LYStoreCookies(char *cookie_file) return; } - CTrace((tfp, "LYStoreCookies: save cookies to %s on exit\n", cookie_file)); + /* if we read cookies from the file, we'll update it even if now empty */ + if (number_of_file_cookies != 0) { + cookie_handle = NewCookieFile(cookie_file); + if (cookie_handle == NULL) + return; + } - cookie_handle = LYNewTxtFile(cookie_file); - if (cookie_handle == NULL) - return; for (dl = domain_list; dl != NULL; dl = dl->next) { de = (domain_entry *) (dl->object); if (de == NULL) @@ -2081,6 +2089,13 @@ void LYStoreCookies(char *cookie_file) continue; } + /* when we're sure we'll write to the file - open it */ + if (cookie_handle == NULL) { + cookie_handle = NewCookieFile(cookie_file); + if (cookie_handle == NULL) + return; + } + fprintf(cookie_handle, "%s\t%s\t%s\t%s\t%" PRI_time_t "\t%s\t%s%s%s\n", de->domain, @@ -2095,9 +2110,10 @@ void LYStoreCookies(char *cookie_file) CTrace((tfp, "STORED\n")); } } - LYCloseOutput(cookie_handle); - - HTSYS_purge(cookie_file); + if (cookie_handle != NULL) { + LYCloseOutput(cookie_handle); + HTSYS_purge(cookie_file); + } } #endif @@ -2549,7 +2565,6 @@ static int LYHandleCookies(const char *arg, * comma-delimited list of domains. cookie_domain_flags handles * invcheck behavior, as well as accept/reject behavior. - BJP */ - static void cookie_domain_flag_set(char *domainstr, int flag) { diff --git a/src/LYDownload.c b/src/LYDownload.c index adf4cf47..18dc5f5f 100644 --- a/src/LYDownload.c +++ b/src/LYDownload.c @@ -1,4 +1,4 @@ -/* $LynxId: LYDownload.c,v 1.58 2007/07/01 23:39:32 Andrew.Belov Exp $ */ +/* $LynxId: LYDownload.c,v 1.59 2008/12/14 18:26:03 tom Exp $ */ #include <HTUtils.h> #include <HTParse.h> #include <HTList.h> @@ -299,10 +299,12 @@ void LYDownload(char *line) */ if (HTCountCommandArgs(download_command->command) >= 2) { _statusline(FILENAME_PROMPT); - again:if (sug_file) + again: + if (sug_file) { strncpy(buffer, sug_file, (sizeof(buffer) / 2) - 1); - else + } else { *buffer = '\0'; + } check_again: if ((ch = LYgetstr(buffer, VISIBLE, sizeof(buffer), recall)) < 0 || diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 650a510d..6fc8d56b 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -1,5 +1,5 @@ /* - * $LynxId: LYGlobalDefs.h,v 1.112 2008/12/07 22:39:32 tom Exp $ + * $LynxId: LYGlobalDefs.h,v 1.113 2008/12/14 18:07:20 tom Exp $ * * global variable definitions */ @@ -289,6 +289,7 @@ extern "C" { extern int LYTransferRate; /* see enum TransferRate */ extern int display_lines; /* number of lines in the display */ extern int dump_output_width; + extern int dump_server_status; extern int keypad_mode; /* NUMBERS_AS_ARROWS or LINKS_ARE_NUMBERED */ extern int lynx_temp_subspace; extern int max_cookies_buffer; diff --git a/src/LYMain.c b/src/LYMain.c index f1ab491f..ee40c047 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMain.c,v 1.187 2008/12/07 20:52:27 tom Exp $ + * $LynxId: LYMain.c,v 1.188 2008/12/14 18:07:56 tom Exp $ */ #include <HTUtils.h> #include <HTTP.h> @@ -485,6 +485,7 @@ int MessageSecs; /* time-delay for important Messages */ int ReplaySecs; /* time-delay for command-scripts */ int crawl_count = 0; /* Starting number for lnk#.dat files in crawls */ int dump_output_width = 0; +int dump_server_status = 0; int lynx_temp_subspace = 0; /* > 0 if we made temp-directory */ int max_cookies_domain = 50; int max_cookies_global = 500; @@ -1032,13 +1033,6 @@ int main(int argc, #endif /* _WINDOWS */ -#if 0 /* defined(__CYGWIN__) - does not work with screen */ - if (strcmp(ttyname(fileno(stdout)), "/dev/conout") != 0) { - printf("please \"$CYGWIN=notty\"\n"); - exit_immediately(EXIT_SUCCESS); - } -#endif - #if defined(WIN_EX) /* 1997/10/19 (Sun) 21:40:54 */ system_is_NT = (BOOL) is_windows_nt(); @@ -4470,7 +4464,7 @@ Lynx now exiting with signal: %d\r\n\r\n", sig); /* * Exit without dumping core. */ - exit_immediately(EXIT_SUCCESS); + exit_immediately(EXIT_FAILURE); } } #endif /* !VMS */ diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 0329f974..cd245caf 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYMainLoop.c,v 1.155 2008/12/09 00:14:47 tom Exp $ + * $LynxId: LYMainLoop.c,v 1.157 2008/12/14 18:42:42 tom Exp $ */ #include <HTUtils.h> #include <HTAccess.h> @@ -1500,11 +1500,11 @@ static int handle_LYK_ACTIVATE(int *c, strip_trailing_slash(newdoc.address); } #endif /* DIRED_SUPPORT && !__DJGPP__ */ -#ifndef USE_CACHEJAR - if (isLYNXCOOKIE(curdoc.address)) { -#else - if (isLYNXCOOKIE(curdoc.address) || isLYNXCACHE(curdoc.address)) { + if (isLYNXCOOKIE(curdoc.address) +#ifdef USE_CACHEJAR + || isLYNXCACHE(curdoc.address) #endif + ) { HTuncache_current_document(); } } @@ -2463,13 +2463,13 @@ static void handle_LYK_EDIT(int *old_c, *old_c = real_c; HTUserMsg(EDIT_DISABLED); } - } else + } #ifdef DIRED_SUPPORT - /* - * Allow the user to edit the link rather than curdoc in edit mode. - */ - if (lynx_edit_mode && - non_empty(editor) && !no_dired_support) { + /* + * Allow the user to edit the link rather than curdoc in edit mode. + */ + else if (lynx_edit_mode && + non_empty(editor) && !no_dired_support) { if (nlinks > 0) { cp = links[curdoc.link].lname; if (is_url(cp) == FILE_URL_TYPE) { @@ -2506,9 +2506,9 @@ static void handle_LYK_EDIT(int *old_c, FREE(tp); } } - } else + } #endif /* DIRED_SUPPORT */ - if (non_empty(editor)) { + else if (non_empty(editor)) { if (edit_current_file(newdoc.address, curdoc.link, LYGetNewline())) { HTuncache_current_document(); LYforce_no_cache = TRUE; /*force reload of document */ @@ -6080,7 +6080,7 @@ int mainloop(void) } else if (!dump_links_only) { print_wwwfile_to_fd(stdout, FALSE, FALSE); } - return (EXIT_SUCCESS); + return ((dump_server_status >= 400) ? EXIT_FAILURE : EXIT_SUCCESS); } /* diff --git a/src/LYUtils.c b/src/LYUtils.c index 87a059c5..99c611df 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,5 +1,5 @@ /* - * $LynxId: LYUtils.c,v 1.177 2008/09/22 22:48:31 tom Exp $ + * $LynxId: LYUtils.c,v 1.178 2008/12/14 18:42:42 tom Exp $ */ #include <HTUtils.h> #include <HTTCP.h> @@ -2788,6 +2788,8 @@ void remove_backslashes(char *buf) */ BOOLEAN inlocaldomain(void) { + int result = TRUE; + #ifdef HAVE_UTMP int n; FILE *fp; @@ -2797,6 +2799,7 @@ BOOLEAN inlocaldomain(void) if ((cp = ttyname(0))) mytty = LYLastPathSep(cp); + result = FALSE; if (mytty && (fp = fopen(UTMP_FILE, "r")) != NULL) { mytty++; do { @@ -2804,15 +2807,18 @@ BOOLEAN inlocaldomain(void) } while (n > 0 && !STREQ(me.ut_line, mytty)); (void) LYCloseInput(fp); - if (n > 0 && - strlen(me.ut_host) > strlen(LYLocalDomain) && - STREQ(LYLocalDomain, - me.ut_host + strlen(me.ut_host) - strlen(LYLocalDomain))) - return (TRUE); + if (n > 0) { + if (strlen(me.ut_host) > strlen(LYLocalDomain) && + STREQ(LYLocalDomain, + me.ut_host + strlen(me.ut_host) - strlen(LYLocalDomain))) { + result = TRUE; + } #ifdef LINUX -/* Linux fix to check for local user. J.Cullen 11Jul94 */ - if ((n > 0) && (strlen(me.ut_host) == 0)) - return (TRUE); + /* Linux fix to check for local user. J.Cullen 11Jul94 */ + else if (strlen(me.ut_host) == 0) { + result = TRUE; + } + } #endif /* LINUX */ } else { @@ -2820,12 +2826,10 @@ BOOLEAN inlocaldomain(void) "Could not get ttyname (returned %s) or open UTMP file %s\n", NONNULL(cp), UTMP_FILE)); } - - return (FALSE); #else - CTRACE((tfp, "LYUtils: inlocaldomain() not support.\n")); - return (TRUE); + CTRACE((tfp, "LYUtils: inlocaldomain() not supported.\n")); #endif /* HAVE_UTMP */ + return (result); } #ifdef HAVE_SIGACTION diff --git a/src/Xsystem.c b/src/Xsystem.c index 15a8dfd6..bd2c7c42 100644 --- a/src/Xsystem.c +++ b/src/Xsystem.c @@ -1,4 +1,4 @@ -/* $LynxId: Xsystem.c,v 1.16 2004/12/30 12:20:28 tom Exp $ +/* $LynxId: Xsystem.c,v 1.18 2008/12/14 18:44:52 tom Exp $ * like system("cmd") but return with exit code of "cmd" * for Turbo-C/MS-C/LSI-C * This code is in the public domain. @@ -82,7 +82,7 @@ static char *NEAR xmalloc(size_t n) if ((bp = typecallocn(char, n)) == 0) { write(2, "xsystem: Out of memory.!\n", 25); - exit_immediately(1); + exit_immediately(EXIT_FAILURE); } return bp; } @@ -93,7 +93,7 @@ static char *NEAR xrealloc(void *p, size_t n) if ((bp = realloc(p, n)) == (char *) 0) { write(2, "xsystem: Out of memory!.\n", 25); - exit_immediately(1); + exit_immediately(EXIT_FAILURE); } return bp; } @@ -134,15 +134,18 @@ static int NEAR is_builtin_command(char *s) static int NEAR getswchar(void) { + int result; + #ifdef __WIN32__ - return '/'; + result = '/'; #else union REGS reg; reg.x.ax = 0x3700; intdos(®, ®); - return reg.h.dl; + result = reg.h.dl; #endif + return result; } static int NEAR csystem(PRO * p, int flag) @@ -527,8 +530,10 @@ int xsystem(char *cmd) int exec_command(char *cmd, int wait_flag) { + int rc; + #if defined(__MINGW32__) - return system(cmd); + rc = system(cmd); #else PRO *p; char *pif; @@ -564,8 +569,8 @@ int exec_command(char *cmd, int wait_flag) else rc = prog_go(p, P_NOWAIT); - return rc; #endif + return rc; } #ifdef TEST diff --git a/src/tidy_tls.c b/src/tidy_tls.c index 7269342f..f71adde6 100644 --- a/src/tidy_tls.c +++ b/src/tidy_tls.c @@ -1,6 +1,7 @@ /* - * $LynxId: tidy_tls.c,v 1.1 2008/04/27 22:49:52 tom Exp $ + * $LynxId: tidy_tls.c,v 1.3 2008/12/14 18:25:25 tom Exp $ * Copyright 2008, Thomas E. Dickey + * with fix Copyright 2008 by Thomas Viehmann * * Required libraries: * libgnutls @@ -17,11 +18,16 @@ static int last_error = 0; -#define GetDnByOID(target, oid) \ +/* ugly, but hey, we could just use a more sane api, too */ +#define GetDnByOID(target, oid, thewhat) \ len = sizeof(target); \ - gnutls_x509_crt_get_dn_by_oid(xcert, oid, 0, 0, target, &len) + if (! thewhat) \ + gnutls_x509_crt_get_dn_by_oid(xcert, oid, 0, 0, target, &len); \ + else \ + gnutls_x509_crt_get_issuer_dn_by_oid(xcert, oid, 0, 0, target, &len) -static int ExtractCertificate(const gnutls_datum_t * cert, X509_NAME * result) +/* thewhat: which DN to get 0 = subject, 1 = issuer */ +static int ExtractCertificate(const gnutls_datum_t * cert, X509_NAME * result, int thewhat) { gnutls_x509_crt_t xcert; int rc; @@ -30,19 +36,19 @@ static int ExtractCertificate(const gnutls_datum_t * cert, X509_NAME * result) if ((rc = gnutls_x509_crt_init(&xcert)) >= 0) { if ((rc = gnutls_x509_crt_import(xcert, cert, GNUTLS_X509_FMT_DER)) >= 0) { GetDnByOID(result->country, - GNUTLS_OID_X520_COUNTRY_NAME); + GNUTLS_OID_X520_COUNTRY_NAME, thewhat); GetDnByOID(result->organization, - GNUTLS_OID_X520_ORGANIZATION_NAME); + GNUTLS_OID_X520_ORGANIZATION_NAME, thewhat); GetDnByOID(result->organizational_unit_name, - GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME); + GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, thewhat); GetDnByOID(result->common_name, - GNUTLS_OID_X520_COMMON_NAME); + GNUTLS_OID_X520_COMMON_NAME, thewhat); GetDnByOID(result->locality_name, - GNUTLS_OID_X520_LOCALITY_NAME); + GNUTLS_OID_X520_LOCALITY_NAME, thewhat); GetDnByOID(result->state_or_province_name, - GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME); + GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, thewhat); GetDnByOID(result->email, - GNUTLS_OID_PKCS9_EMAIL); + GNUTLS_OID_PKCS9_EMAIL, thewhat); rc = 0; } gnutls_x509_crt_deinit(xcert); @@ -570,7 +576,7 @@ X509_NAME *X509_get_issuer_name(const X509 * cert) X509_NAME *result; if ((result = typeCalloc(X509_NAME)) != 0) { - if (ExtractCertificate(&cert[1], result) < 0) { + if (ExtractCertificate(cert, result, 1) < 0) { free(result); result = 0; } @@ -586,7 +592,7 @@ X509_NAME *X509_get_subject_name(const X509 * cert) X509_NAME *result; if ((result = typeCalloc(X509_NAME)) != 0) { - if (ExtractCertificate(&cert[0], result) < 0) { + if (ExtractCertificate(cert, result, 0) < 0) { free(result); result = 0; } |