diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1998-07-25 03:14:56 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1998-07-25 03:14:56 -0400 |
commit | aa3258c631eaca9dc2e7e2590b8778b827006144 (patch) | |
tree | 8fc25814a576a0db800da7a1421f6a3c76a2ae6d /src | |
parent | 5488a2e17cfeff78f8927f652ecb9750d7a28c29 (diff) | |
download | lynx-snapshots-aa3258c631eaca9dc2e7e2590b8778b827006144.tar.gz |
snapshot of project "lynx", label v2-8-1dev_18
Diffstat (limited to 'src')
39 files changed, 565 insertions, 315 deletions
diff --git a/src/GridText.c b/src/GridText.c index 3e325d08..bff01ebd 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -433,10 +433,11 @@ PUBLIC HText * HText_new ARGS1( HTList_addObject(loaded_texts, self); #if defined(VMS) && defined(VAXC) && !defined(__DECC) while (HTList_count(loaded_texts) > HTCacheSize && - VMTotal > HTVirtualMemorySize) { + VMTotal > HTVirtualMemorySize) #else - if (HTList_count(loaded_texts) > HTCacheSize) { + if (HTList_count(loaded_texts) > HTCacheSize) #endif /* VMS && VAXC && !__DECC */ + { CTRACE(tfp, "GridText: Freeing off cached doc.\n"); HText_free((HText *)HTList_removeFirstObject(loaded_texts)); #if defined(VMS) && defined (VAXC) && !defined(__DECC) @@ -3704,17 +3705,17 @@ PUBLIC int HText_getNumOfLines NOARGS * HText_getTitle returns the title of the * current document. */ -PUBLIC char * HText_getTitle NOARGS +PUBLIC CONST char * HText_getTitle NOARGS { return(HTMainText ? - (char *) HTAnchor_title(HTMainText->node_anchor) : NULL); + HTAnchor_title(HTMainText->node_anchor) : 0); } #ifdef USE_HASH -PUBLIC char *HText_getStyle NOARGS +PUBLIC CONST char *HText_getStyle NOARGS { return(HTMainText ? - (char *) HTAnchor_style(HTMainText->node_anchor) : NULL); + HTAnchor_style(HTMainText->node_anchor) : 0); } #endif @@ -3924,30 +3925,30 @@ PUBLIC void HTCheckFnameForCompression ARGS3( * HText_getLastModified returns the Last-Modified header * if available, for the current document. - FM */ -PUBLIC char * HText_getLastModified NOARGS +PUBLIC CONST char * HText_getLastModified NOARGS { return(HTMainText ? - (char *) HTAnchor_last_modified(HTMainText->node_anchor) : NULL); + HTAnchor_last_modified(HTMainText->node_anchor) : 0); } /* * HText_getDate returns the Date header * if available, for the current document. - FM */ -PUBLIC char * HText_getDate NOARGS +PUBLIC CONST char * HText_getDate NOARGS { return(HTMainText ? - (char *) HTAnchor_date(HTMainText->node_anchor) : NULL); + HTAnchor_date(HTMainText->node_anchor) : 0); } /* * HText_getServer returns the Server header * if available, for the current document. - FM */ -PUBLIC char * HText_getServer NOARGS +PUBLIC CONST char * HText_getServer NOARGS { return(HTMainText ? - (char *)HTAnchor_server(HTMainText->node_anchor) : NULL); + HTAnchor_server(HTMainText->node_anchor) : 0); } /* @@ -5202,14 +5203,14 @@ PUBLIC void user_message ARGS2( * HText_getOwner returns the owner of the * current document. */ -PUBLIC char * HText_getOwner NOARGS +PUBLIC CONST char * HText_getOwner NOARGS { return(HTMainText ? - (char *)HTAnchor_owner(HTMainText->node_anchor) : NULL); + HTAnchor_owner(HTMainText->node_anchor) : 0); } /* -* HText_setMainTextOwner sets the owner for the + * HText_setMainTextOwner sets the owner for the * current document. */ PUBLIC void HText_setMainTextOwner ARGS1( @@ -5226,10 +5227,10 @@ PUBLIC void HText_setMainTextOwner ARGS1( * current document, used as the subject for mailto comments * to the owner. */ -PUBLIC char * HText_getRevTitle NOARGS +PUBLIC CONST char * HText_getRevTitle NOARGS { return(HTMainText ? - (char *)HTAnchor_RevTitle(HTMainText->node_anchor) : NULL); + HTAnchor_RevTitle(HTMainText->node_anchor) : 0); } /* diff --git a/src/GridText.h b/src/GridText.h index 2cf7da85..daeabe6e 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -71,23 +71,23 @@ extern void HText_setIgnoreExcess PARAMS((HText *text, BOOL ignore)); extern int HText_sourceAnchors PARAMS((HText * text)); extern void HText_setStale PARAMS((HText * text)); extern void HText_refresh PARAMS((HText * text)); -extern char * HText_getTitle NOPARAMS; +extern CONST char * HText_getTitle NOPARAMS; extern CONST char * HText_getSugFname NOPARAMS; extern void HTCheckFnameForCompression PARAMS(( char ** fname, HTParentAnchor * anchor, BOOLEAN strip_ok)); -extern char * HText_getLastModified NOPARAMS; -extern char * HText_getDate NOPARAMS; -extern char * HText_getServer NOPARAMS; -extern char * HText_getOwner NOPARAMS; +extern CONST char * HText_getLastModified NOPARAMS; +extern CONST char * HText_getDate NOPARAMS; +extern CONST char * HText_getServer NOPARAMS; +extern CONST char * HText_getOwner NOPARAMS; extern CONST char * HText_getContentBase NOPARAMS; extern CONST char * HText_getContentLocation NOPARAMS; +extern CONST char * HText_getRevTitle NOPARAMS; #ifdef USE_HASH -extern char * HText_getStyle NOPARAMS; +extern CONST char * HText_getStyle NOPARAMS; #endif extern void HText_setMainTextOwner PARAMS((CONST char * owner)); -extern char * HText_getRevTitle NOPARAMS; extern void print_wwwfile_to_fd PARAMS((FILE * fp, int is_reply)); extern BOOL HText_select PARAMS((HText *text)); extern BOOL HText_POSTReplyLoaded PARAMS((document *doc)); diff --git a/src/HTAlert.c b/src/HTAlert.c index 72f14f4a..c2dba887 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -62,30 +62,46 @@ PUBLIC void HTReadProgress ARGS2( long, bytes, long, total) { - static long kb_units = 1024000; + static long kb_units = 1024; static time_t first, last; + static long bytes_last; + long transfer_rate; char line[80]; - time_t now = time((time_t *)0); + time_t now = time((time_t *)0); /* once per second */ char *units = "bytes"; if (bytes == 0) { first = last = now; - } else if (bytes > 0) { - if (now != last) { - last = now; + bytes_last = bytes; + } else if ((bytes > 0) && + (now != first)) + /* 1 sec delay for transfer_rate calculation :-( */ { + transfer_rate = (bytes) / (now - first); /* bytes/sec */ + + /* optimal refresh time: every 0.2 sec */ + if ((bytes - bytes_last) > (transfer_rate / 5)) { + + bytes_last += (transfer_rate / 5); /* until we got next second */ + + if (now != last) { + last = now; + bytes_last = bytes; + } if (total >= kb_units || bytes >= kb_units) { - if (bytes > 0) bytes /= 1024; + bytes /= 1024; if (total > 0) total /= 1024; units = "KB"; } - if (total > 0) { + + if (total > 0) sprintf (line, "Read %ld of %ld %s of data.", bytes, total, units); - } else if (total < 0) { - sprintf (line, "Read %ld uncompressed %s of data.", bytes, units); + if (total <= 0) + sprintf (line, "Read %ld %s of data.", bytes, units); + if (transfer_rate > 0) + sprintf (line + strlen(line), " %ld kb/sec.", transfer_rate / 1024); + if (total < 0) { if (total < -1) strcat(line, " (Press 'z' to abort)"); - } else { - sprintf (line, "Read %ld %s of data.", bytes, units); } _HTProgress(line); } @@ -117,9 +133,9 @@ PUBLIC BOOL HTConfirm ARGS1(CONST char *, Msg) #ifdef VMS extern BOOLEAN HadVMSInterrupt; #endif /* VMS */ - + _user_message("%s (y/n) ", Msg); - + while (1) { c = LYgetch(); #ifdef VMS @@ -152,7 +168,7 @@ PUBLIC char * HTPrompt ARGS2( Tmp[199] = '\0'; _statusline(Msg); - if (deflt) + if (deflt) strncpy(Tmp, deflt, 199); if (!dump_output_immediately) @@ -219,7 +235,7 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( authentication_info[0] && authentication_info[1]) || (IsProxy == TRUE && proxyauth_info[0] && proxyauth_info[1])) { - /* + /* ** The -auth or -pauth parameter gave us both the username ** and password to use for the first realm or proxy server, ** respectively, so just use them without any prompting. - FM @@ -351,11 +367,9 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( ** Returns FALSE on cancel, ** TRUE if the cookie should be set. */ -PUBLIC BOOL HTConfirmCookie ARGS6( +PUBLIC BOOL HTConfirmCookie ARGS4( void *, dp, CONST char *, server, - CONST char *, domain, - CONST char *, path, CONST char *, name, CONST char *, value) { @@ -369,11 +383,11 @@ PUBLIC BOOL HTConfirmCookie ARGS6( if ((de = (domain_entry *)dp) == NULL) return FALSE; - + /* ** If the user has specified a constant action, don't prompt at all. */ - if (de->bv == ACCEPT_ALWAYS) + if (de->bv == ACCEPT_ALWAYS || de->bv == FROM_FILE) return TRUE; if (de->bv == REJECT_ALWAYS) return FALSE; @@ -393,9 +407,9 @@ PUBLIC BOOL HTConfirmCookie ARGS6( ** minus the length of the %s directives (10 chars) */ if (de != NULL) { - if (de->bv == ACCEPT_ALWAYS) + if (de->bv == ACCEPT_ALWAYS) return TRUE; - if (de->bv == REJECT_ALWAYS) + if (de->bv == REJECT_ALWAYS) return FALSE; } space_free = (((LYcols - 1) - 37) - strlen(server)); @@ -547,7 +561,7 @@ PUBLIC int HTConfirmPostRedirect ARGS2( StrAllocCat(show_POST_url, Redirecting_url); } while (1) { - int c; + int c; switch (on_screen) { case 0: @@ -564,7 +578,7 @@ PUBLIC int HTConfirmPostRedirect ARGS2( ** with same method and POST content. - FM */ FREE(show_POST_url); - return 1; + return 1; case 7: case 'C': diff --git a/src/HTAlert.h b/src/HTAlert.h index 8f44c7a8..77be4315 100644 --- a/src/HTAlert.h +++ b/src/HTAlert.h @@ -109,8 +109,6 @@ extern void HTPromptUsernameAndPassword PARAMS(( extern BOOL HTConfirmCookie PARAMS(( void * dp, CONST char * server, - CONST char * domain, - CONST char * path, CONST char * name, CONST char * value)); diff --git a/src/HTFWriter.c b/src/HTFWriter.c index c73e01d6..fd35802e 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -550,7 +550,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( me->anchor = anchor; me->sink = sink; - if (LYCachedTemp(fnam, anchor->FileCache)) { + if (LYCachedTemp(fnam, &(anchor->FileCache))) { me->fp = LYNewBinFile (fnam); } else { /* @@ -703,7 +703,7 @@ PUBLIC HTStream* HTSaveToFile ARGS3( /* * Set up a 'D'ownload. */ - if (LYCachedTemp(fnam, anchor->FileCache)) { + if (LYCachedTemp(fnam, &(anchor->FileCache))) { ret_obj->fp = LYNewBinFile (fnam); } else { /* @@ -775,8 +775,7 @@ PUBLIC HTStream* HTSaveToFile ARGS3( * sizeof (char),1); if (FIXED_RECORD_COMMAND == NULL) outofmem(__FILE__, "HTSaveToFile"); - sprintf(FIXED_RECORD_COMMAND, - FIXED_RECORD_COMMAND_MASK, fnam, "", "", "", "", "", ""); + sprintf(FIXED_RECORD_COMMAND, FIXED_RECORD_COMMAND_MASK, fnam); } else { #endif /* VMS */ ret_obj->end_command = (char *)calloc (sizeof(char)*12,1); diff --git a/src/HTForms.h b/src/HTForms.h index c01d3df1..eb0784f2 100644 --- a/src/HTForms.h +++ b/src/HTForms.h @@ -7,7 +7,7 @@ #endif /* LYSTRUCTS_H */ /* in LYForms.c */ -extern int change_form_link PARAMS((struct link *form_link, int mode, +extern int change_form_link PARAMS((struct link *form_link, document *newdoc, BOOLEAN *refresh_screen, char *link_name, char *link_value)); @@ -59,7 +59,7 @@ typedef struct _FormInfo { char * value; /* user entered string data */ char * orig_value;/* the original value */ int size; /* width on the screen */ - int maxlength; /* max width of data */ + unsigned maxlength; /* max width of data */ int group; /* a group associated with the link * this is used for select's */ @@ -130,9 +130,6 @@ typedef struct _PerFormInfo #define NORMAL_LYNX_MODE 1 #define FORMS_LYNX_MODE 2 -#define FORM_UP 1 -#define FORM_DOWN 2 - #define FIRST_ORDER 1 #define MIDDLE_ORDER 2 #define LAST_ORDER 3 diff --git a/src/HTML.c b/src/HTML.c index 4e99ed2e..8513ff44 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -2427,8 +2427,8 @@ PRIVATE void HTML_start_element ARGS6( if (!url_type && !strncmp(href, "/foo/..", 7) && (!strncmp(me->node_anchor->address, "ftp:", 4) || !strncmp(me->node_anchor->address, "file:", 5))) { - for (i = 0; href[i]; i++) - href[i] = href[i+7]; + for (i = 0; (href[i] = href[i+7]) != 0; i++) + ; } /* diff --git a/src/LYCharSets.c b/src/LYCharSets.c index 0e7474bb..d6609a99 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -57,7 +57,7 @@ PUBLIC int LYNumCharsets = 0; /* Will be initialized later by UC_Register. */ ** ** This MUST match exactly the table referred to in the DTD! */ -PRIVATE char * ISO_Latin1[] = { +PRIVATE CONST char * ISO_Latin1[] = { "\306", /* capital AE diphthong (ligature) (Æ) - AElig */ "\301", /* capital A, acute accent (Á) - Aacute */ "\302", /* capital A, circumflex accent (Â) - Acirc */ @@ -176,7 +176,7 @@ PRIVATE char * ISO_Latin1[] = { ** ** This MUST match exactly the table referred to in the DTD! */ -PUBLIC char * SevenBitApproximations[] = { +PUBLIC CONST char * SevenBitApproximations[] = { "AE", /* capital AE diphthong (ligature) (Æ) - AElig */ "A", /* capital A, acute accent (Á) - Aacute */ "A", /* capital A, circumflex accent (Â) - Acirc */ @@ -323,7 +323,7 @@ PUBLIC char * SevenBitApproximations[] = { /* * Add the array name to LYCharSets */ -PUBLIC char ** LYCharSets[MAXCHARSETS]={ +PUBLIC CONST char ** LYCharSets[MAXCHARSETS]={ ISO_Latin1, /* ISO Latin 1 */ SevenBitApproximations, /* DosLatin1 (cp850) */ SevenBitApproximations, /* WinLatin1 (cp1252) */ @@ -459,7 +459,7 @@ PUBLIC int LYlowest_eightbit[MAXCHARSETS]={ * 'o'ptions (.lynxrc) to * set a different default. */ -PUBLIC char** p_entity_values = ISO_Latin1; /* Pointer to translation */ +PUBLIC CONST char** p_entity_values = ISO_Latin1; /* Pointer to translation */ PUBLIC int current_char_set = 0; /* Index for translation */ /* diff --git a/src/LYCharSets.h b/src/LYCharSets.h index ff68dd9b..cd9e4ccc 100644 --- a/src/LYCharSets.h +++ b/src/LYCharSets.h @@ -22,9 +22,9 @@ extern CONST char * LYchar_set_names[]; extern int LYCharSetsDeclared NOPARAMS; -extern char ** LYCharSets[]; -extern char * SevenBitApproximations[]; -extern char ** p_entity_values; +extern CONST char ** LYCharSets[]; +extern CONST char * SevenBitApproximations[]; +extern CONST char ** p_entity_values; extern int LYlowest_eightbit[]; extern int LYNumCharsets; extern LYUCcharset LYCharSet_UC[]; diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index f380ce0a..ed4722f7 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -315,7 +315,7 @@ PUBLIC char *LYFindEndOfComment ARGS1( */ PUBLIC void LYFillLocalFileURL ARGS2( char **, href, - char *, base) + CONST char *, base) { char * temp = NULL; @@ -1510,7 +1510,7 @@ PRIVATE char * UCPutUtf8ToBuffer ARGS3(char *, q, UCode_t, code, BOOL, terminate } /* as in HTParse.c, saves some calls - kw */ -PRIVATE char *hex = "0123456789ABCDEF"; +PRIVATE CONST char *hex = "0123456789ABCDEF"; /* * Any raw 8-bit or multibyte characters already have been @@ -3521,7 +3521,8 @@ PUBLIC int LYLegitimizeHREF ARGS4( * it, such that the bad partial reference might get corrected * by the document provider. - FM */ - char *temp = NULL, *path = NULL, *str = "", *cp; + char *temp = NULL, *path = NULL, *cp; + CONST char *str = ""; if (((temp = HTParse(*href, (me->inBASE ? diff --git a/src/LYCharUtils.h b/src/LYCharUtils.h index fb079332..dc5a6c7f 100644 --- a/src/LYCharUtils.h +++ b/src/LYCharUtils.h @@ -38,10 +38,10 @@ extern char *LYFindEndOfComment PARAMS(( char * str)); extern void LYFillLocalFileURL PARAMS(( char ** href, - char * base)); + CONST char * base)); extern void LYAddMETAcharsetToFD PARAMS(( - FILE * fd, - int disp_chndl)); + FILE * fd, + int disp_chndl)); #ifdef Lynx_HTML_Handler extern int OL_CONTINUE; /* flag for whether CONTINUE is set */ diff --git a/src/LYCookie.c b/src/LYCookie.c index 6767c023..e4937e33 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -95,6 +95,7 @@ struct _cookie { int flags; /* Various flags */ time_t expires;/* The time when this cookie expires */ BOOL quoted; /* Was a value quoted in the Set-Cookie header? */ + BOOL from_file; /* Was this cookie loaded from the file jar? - RP */ }; typedef struct _cookie cookie; @@ -103,6 +104,8 @@ typedef struct _cookie cookie; #define COOKIE_FLAG_EXPIRES_SET 4 /* If set, an expiry date was set */ #define COOKIE_FLAG_DOMAIN_SET 8 /* If set, an non-default domain was set */ #define COOKIE_FLAG_PATH_SET 16 /* If set, an non-default path was set */ +#define COOKIE_FLAG_PERSISTENT 32 /* If set, this cookie was persistent */ + struct _HTStream { HTStreamClass * isa; @@ -405,7 +408,21 @@ PRIVATE void store_cookie ARGS3( de = (domain_entry *)calloc(1, sizeof(domain_entry)); if (de == NULL) outofmem(__FILE__, "store_cookie"); - de->bv = QUERY_USER; +#ifdef EXP_PERSISTENT_COOKIES + /* + * Ok, this is a problem. The first cookie for a domain + * effectively sets the policy for that whole domain - for + * something like Netlink, where there are lots of websites + * under www.netlink.co.uk, this isn't sensible. However, + * taking this sort of decision down to cookie level also + * isn't sensible. Perhaps something based on the domain + * and the path in conjunction makes more sense? - RP + */ + if (co->flags & COOKIE_FLAG_PERSISTENT) + de->bv = FROM_FILE; + else +#endif + de->bv = QUERY_USER; cookie_list = de->cookie_list = HTList_new(); StrAllocCopy(de->domain, co->domain); HTList_addObject(domain_list, de); @@ -486,8 +503,7 @@ PRIVATE void store_cookie ARGS3( * Get confirmation if we need it, and add cookie * if confirmed or 'allow' is set to always. - FM */ - } else if (HTConfirmCookie(de, hostname, - co->domain, co->path, co->name, co->value)) { + } else if (HTConfirmCookie(de, hostname, co->name, co->value)) { HTList_insertObjectAt(cookie_list, co, pos); total_cookies++; } else { @@ -1813,6 +1829,151 @@ PUBLIC char * LYCookie ARGS4( return(NULL); } +/* rjp - experiment cookie loading */ +#ifdef EXP_PERSISTENT_COOKIES +PUBLIC void LYLoadCookies ARGS1 ( + CONST char *, cookie_file) +{ + FILE *cookie_handle; + char buf[5000]; /* should be long enough for a cookie line */ + char domain[256], path[256], name[256], value[4100]; + char what[8], secure[8], expires_a[16]; + int expires; + + cookie_handle = fopen(cookie_file, "r+"); + if (!cookie_handle) + return; + + while (!feof(cookie_handle)) { + cookie *moo; + int tok_loop; + char *tok_values[] = {domain, what, path, secure, expires_a, name, value, NULL}; + char *tok_out, *tok_ptr; + + fgets(buf, 4999, cookie_handle); /* test return value */ + + /* + * Tokenise the cookie line into it's component parts - + * this only works for Netscape style cookie files at the + * moment. It may be worth investigating an alternative + * format for Lynx because the Netscape format isn't all + * that useful, or future-proof. - RP + * + * 'fixed' by using strsep instead of strtok. No idea + * what kind of platform problems this might introduce. - RP + */ + tok_ptr = buf; + tok_out = strsep(&tok_ptr, "\t"); + for (tok_loop = 0; tok_out && tok_values[tok_loop]; tok_loop++) { + if (TRACE) + fprintf(stderr, ">%d:%p:%p:[%s]:%s\n", + tok_loop, tok_values[tok_loop], tok_out, tok_out, buf); + strcpy(tok_values[tok_loop], tok_out); + /* + * It looks like strtok ignores a leading delimiter, + * which makes things a bit more interesting. Something + * like "FALSE\t\tFALSE\t" translates to FALSE,FALSE + * instead of FALSE,,FALSE. - RP + */ + tok_out = strsep(&tok_ptr, "\t"); + } + expires = atoi(expires_a); + + /* + * This fails when the path is blank + * + * sscanf(buf, "%s\t%s\t%s\t%s\t%d\t%s\t%[ -~]", + * domain, what, path, secure, &expires, name, value); + */ + + if (TRACE) + fprintf(stderr, "%s\t%s\t%s\t%s\t%d\t%s\t%s\tREADCOOKIE\n", + domain, what, path, secure, expires, name, value); + moo = newCookie(); + StrAllocCopy(moo->domain, domain); + StrAllocCopy(moo->path, path); + StrAllocCopy(moo->name, name); + StrAllocCopy(moo->value, value); + moo->pathlen = strlen(moo->path); + moo->flags |= COOKIE_FLAG_PERSISTENT; + /* + * I don't like using this to store the cookies because it's + * designed to store cookies that have been received from an + * HTTP request, not from a persistent cookie jar. Hence the + * mucking about with the COOKIE_FLAG_PERSISTENT above. - RP + */ + store_cookie(moo, domain, path); + } + fclose (cookie_handle); +} + +/* rjp - experimental persistent cookie support */ +PRIVATE void LYStoreCookies ARGS1 ( + CONST char *, cookie_fileX) +{ + char buf[1024]; + HTList *dl, *cl; + domain_entry *de; + cookie *co; + FILE *cookie_handle; + char *cookie_file = "cookies"; +#ifdef VMS + extern BOOLEAN HadVMSInterrupt; +#endif /* VMS */ + + /* + * Check whether we have something to do. - FM + */ + if (HTList_isEmpty(domain_list)) { + /* No cookies, so don't bother updating the file */ + return; + } + + cookie_handle = fopen(cookie_file, "w+"); + for (dl = domain_list; dl != NULL; dl = dl->next) { + de = dl->object; + if (de == NULL) + /* + * Fote says the first object is NULL. Go with that. + */ + continue; + + switch (de->bv) { + case (ACCEPT_ALWAYS): + sprintf(buf, COOKIES_ALWAYS_ALLOWED); + break; + case (REJECT_ALWAYS): + sprintf(buf, COOKIES_NEVER_ALLOWED); + break; + case (QUERY_USER): + sprintf(buf, COOKIES_ALLOWED_VIA_PROMPT); + break; + case (FROM_FILE): + sprintf(buf, "(From Cookie Jar)"); + break; + } + + /* + * Show the domain's cookies. - FM + */ + for (cl = de->cookie_list; cl != NULL; cl = cl->next) { + /* + * First object is always NULL. - FM + */ + if ((co = (cookie *)cl->object) == NULL) + continue; + + fprintf(cookie_handle, "%s\t%s\t%s\t%s\t%ld\t%s\t%s\n", + de->domain, + "FALSE", co->path, + co->flags & COOKIE_FLAG_SECURE ? "TRUE" : "FALSE", + (long) co->expires, co->name, co->value); + } + } + fclose(cookie_handle); +} +#endif + /* LYHandleCookies - F.Macrides (macrides@sci.wfeb.edu) ** --------------- ** @@ -1852,6 +2013,11 @@ PRIVATE int LYHandleCookies ARGS4 ( extern BOOLEAN HadVMSInterrupt; #endif /* VMS */ +#ifdef EXP_PERSISTENT_COOKIES + /* rjp - this can go here for now */ + LYStoreCookies ("j"); +#endif + /* * Check whether we have something to do. - FM */ @@ -2147,7 +2313,10 @@ Delete_all_cookies_in_domain: break; case (QUERY_USER): sprintf(buf, COOKIES_ALLOWED_VIA_PROMPT); - break; + break; + case (FROM_FILE): + sprintf(buf, COOKIES_READ_FROM_FILE); + break; } (*target->isa->put_block)(target, buf, strlen(buf)); diff --git a/src/LYCookie.h b/src/LYCookie.h index 9900a017..e1e4ad1a 100644 --- a/src/LYCookie.h +++ b/src/LYCookie.h @@ -1,4 +1,3 @@ - #ifndef LYCOOKIES_H #define LYCOOKIES_H @@ -11,8 +10,10 @@ extern char *LYCookie PARAMS(( CONST char * partialpath, int port, BOOL secure)); +extern void LYLoadCookies PARAMS(( + CONST char * cookie_file)); -typedef enum {ACCEPT_ALWAYS, REJECT_ALWAYS, QUERY_USER} behaviour; +typedef enum {ACCEPT_ALWAYS, REJECT_ALWAYS, QUERY_USER, FROM_FILE} behaviour; struct _domain_entry { char * domain; /* Domain for which these cookies are valid */ diff --git a/src/LYCurses.c b/src/LYCurses.c index 42c2fc5b..03d5aba7 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -313,7 +313,10 @@ PRIVATE int LYAttrset ARGS3(WINDOW*,win,int,color,int,mono) return A_NORMAL; } -PUBLIC void curses_w_style ARGS4(WINDOW*,win,int,style,int,dir,int,previous) +PUBLIC void curses_w_style ARGS3( + WINDOW*, win, + int, style, + int, dir) { int YP,XP; bucket* ds=&hashStyles[style]; @@ -399,7 +402,7 @@ PUBLIC void wcurses_css ARGS3(WINDOW *,win,char*,name,int,dir) else try_again=0; } else { CTRACE(tfp, "ok (%d)\n", hash_code(name)); - curses_w_style(win, hash_code(name), dir, 0); + curses_w_style(win, hash_code(name), dir); try_again=0; } } @@ -407,12 +410,14 @@ PUBLIC void wcurses_css ARGS3(WINDOW *,win,char*,name,int,dir) PUBLIC void curses_css ARGS2(char *,name,int,dir) { - wcurses_css(stdscr, name, dir); + wcurses_css(stdscr, name, dir); } -PUBLIC void curses_style ARGS3(int,style,int,dir,int,previous) +PUBLIC void curses_style ARGS2( + int, style, + int, dir) { - curses_w_style(stdscr, style, dir, previous); + curses_w_style(stdscr, style, dir); } #ifdef NOT_USED @@ -847,6 +852,18 @@ PUBLIC void start_curses NOARGS PUBLIC void lynx_enable_mouse ARGS1(int,state) { + +#ifdef __BORLANDC__ + HANDLE hConIn = INVALID_HANDLE_VALUE; + hConIn = GetStdHandle(STD_INPUT_HANDLE); + if (LYUseMouse == 0) + { + SetConsoleMode(hConIn, ENABLE_WINDOW_INPUT); + FlushConsoleInputBuffer(hConIn); + return; + } +#endif + if (LYUseMouse == 0) return; @@ -854,18 +871,14 @@ PUBLIC void lynx_enable_mouse ARGS1(int,state) SLtt_set_mouse_mode (state, 0); SLtt_flush_output (); #else + #ifdef NCURSES_MOUSE_VERSION /* Inform ncurses that we're interested in knowing when mouse * button 1 is clicked */ -#ifndef _WINDOWS if (state) mousemask(BUTTON1_CLICKED | BUTTON3_CLICKED, NULL); else mousemask(0, NULL); -#else - if (state) - mouse_set(BUTTON1_CLICKED && BUTTON2_CLICKED && BUTTON3_CLICKED); -#endif /* !_WINDOWS */ #endif /* NCURSES_MOUSE_VERSION */ #if defined(DJGPP) && !defined(USE_SLANG) @@ -1511,7 +1524,7 @@ again: * and VMSsignal() is just a "helper", also not a full emulation. */ -PUBLIC void *VMSsignal (sig,func) +PUBLIC void VMSsignal (sig,func) int sig; void (*func)(); { @@ -1579,13 +1592,12 @@ void (*func)(); PRIVATE unsigned int DCLspawn_exception ARGS2( void *, sigarr, void *, mecharr) -{ #else PRIVATE int DCLspawn_exception ARGS2( void *, sigarr, void *, mecharr) -{ #endif /* __DECC */ +{ int status; status = lib$sig_to_ret(sigarr, mecharr); @@ -1611,10 +1623,11 @@ PRIVATE int spawn_DCLprocess ARGS1( #ifdef __ALPHA /** OpenVMS/AXP lacked the TRUSTED flag before v6.1 **/ if (VersionVMS[1] > '6' || (VersionVMS[1] == '6' && VersionVMS[2] == '.' && - VersionVMS[3] >= '1')) { + VersionVMS[3] >= '1')) #else - if (VersionVMS[1] >= '6') { + if (VersionVMS[1] >= '6') #endif /* __ALPHA */ + { /* * Include TRUSTED flag. */ @@ -1716,7 +1729,7 @@ PUBLIC void lynx_start_link_color ARGS2( PUBLIC void lynx_stop_link_color ARGS2( int, flag, - int, pending) + int, pending GCC_UNUSED) { #ifdef USE_COLOR_STYLE LynxChangeStyle(flag == ON ? s_alink : s_a, ABS_OFF, 0); diff --git a/src/LYCurses.h b/src/LYCurses.h index 8e6443de..38545cd7 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -160,20 +160,20 @@ extern void VMSexit(); extern int ttopen(); extern int ttclose(); extern int ttgetc(); -extern void *VMSsignal PARAMS((int sig, void (*func)())); +extern void VMSsignal PARAMS((int sig, void (*func)())); #endif /* VMS */ #if defined(USE_COLOR_STYLE) extern void curses_css PARAMS((char * name, int dir)); -extern void curses_style PARAMS((int style, int dir, int previous)); -extern void curses_w_style PARAMS((WINDOW* win, int style, int dir, int previous)); +extern void curses_style PARAMS((int style, int dir)); +extern void curses_w_style PARAMS((WINDOW* win, int style, int dir)); extern void setHashStyle PARAMS((int style, int color, int cattr, int mono, char* element)); extern void setStyle PARAMS((int style, int color, int cattr, int mono)); extern void wcurses_css PARAMS((WINDOW * win, char* name, int dir)); -#define LynxChangeStyle curses_style +#define LynxChangeStyle(style,dir,previous) curses_style(style,dir) #else extern int slang_style PARAMS((int style, int dir, int previous)); -#define LynxChangeStyle slang_style +#define LynxChangeStyle(style,dir,previous) slang_style(style,dir,previous) #endif /* USE_COLOR_STYLE */ #if USE_COLOR_TABLE @@ -382,4 +382,15 @@ extern void lynx_start_radio_color NOPARAMS; extern void lynx_stop_radio_color NOPARAMS; extern void lynx_stop_all_colors NOPARAMS; +/* + * To prevent corrupting binary data with _WINDOWS and DJGPP we open files and + * stdout in BINARY mode by default. Where necessary we should open and + * (close!) TEXT mode. + */ +#if defined(_WINDOWS) || defined(DJGPP) +#define SetOutputMode(mode) setmode(fileno(stdout), mode) +#else +#define SetOutputMode(mode) /* nothing */ +#endif + #endif /* LYCURSES_H */ diff --git a/src/LYEdit.c b/src/LYEdit.c index 55e991fc..75f0521e 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -74,14 +74,15 @@ PUBLIC int edit_current_file ARGS3( if (strlen(filename)>1) filename++; #endif #ifdef DOSPATH - if ((fp = fopen(HTDOS_name(filename),"r")) == NULL) { + if ((fp = fopen(HTDOS_name(filename),"r")) == NULL) #else #ifdef VMS - if ((fp = fopen(HTVMS_name("", filename), "r")) == NULL) { + if ((fp = fopen(HTVMS_name("", filename), "r")) == NULL) #else - if ((fp = fopen(filename, "r")) == NULL) { + if ((fp = fopen(filename, "r")) == NULL) #endif /* VMS */ #endif /* DOSPATH */ + { HTAlert(COULD_NOT_ACCESS_FILE); FREE(filename); goto failure; @@ -96,14 +97,15 @@ PUBLIC int edit_current_file ARGS3( * Don't allow editing if user lacks append access. */ #ifdef DOSPATH - if ((fp = fopen(HTDOS_name("", filename), "a")) == NULL) { + if ((fp = fopen(HTDOS_name("", filename), "a")) == NULL) #else #ifdef VMS - if ((fp = fopen(HTVMS_name("", filename), "a")) == NULL) { + if ((fp = fopen(HTVMS_name("", filename), "a")) == NULL) #else - if ((fp = fopen(filename, "a")) == NULL) { + if ((fp = fopen(filename, "a")) == NULL) #endif /* VMS */ #endif /* DOSPATH */ + { _statusline(NOAUTH_TO_EDIT_FILE); sleep(MessageSecs); goto failure; diff --git a/src/LYForms.c b/src/LYForms.c index b9d4da25..3f572bc2 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -34,9 +34,8 @@ PRIVATE int popup_options PARAMS(( int i_length, int disabled)); -PUBLIC int change_form_link ARGS6( +PUBLIC int change_form_link ARGS5( struct link *, form_link, - int, mode, document *, newdoc, BOOLEAN *, refresh_screen, char *, link_name, diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 722f6d6b..85ebc101 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -29,22 +29,6 @@ extern BOOLEAN UseFixedRecords; /* convert binary files to FIXED 512 records */ #endif /* VMS */ #ifndef VMS -extern char *NNTPSERVER_putenv_cmd; -extern char *http_proxy_putenv_cmd; -extern char *https_proxy_putenv_cmd; -extern char *ftp_proxy_putenv_cmd; -extern char *gopher_proxy_putenv_cmd; -extern char *cso_proxy_putenv_cmd; -extern char *news_proxy_putenv_cmd; -extern char *newspost_proxy_putenv_cmd; -extern char *newsreply_proxy_putenv_cmd; -extern char *snews_proxy_putenv_cmd; -extern char *snewspost_proxy_putenv_cmd; -extern char *snewsreply_proxy_putenv_cmd; -extern char *nntp_proxy_putenv_cmd; -extern char *wais_proxy_putenv_cmd; -extern char *finger_proxy_putenv_cmd; -extern char *no_proxy_putenv_cmd; extern char *list_format; #endif /* !VMS */ @@ -55,7 +39,7 @@ extern char *LYCSwingPath; #ifdef DIRED_SUPPORT extern BOOLEAN lynx_edit_mode; extern BOOLEAN no_dired_support; -extern BOOLEAN dir_list_style; +extern int dir_list_style; extern HTList *tagged; #define FILES_FIRST 1 #define MIXED_STYLE 2 @@ -150,7 +134,7 @@ extern BOOLEAN LYforce_no_cache; extern BOOLEAN LYoverride_no_cache; /* don't need fresh copy, from history */ extern BOOLEAN LYinternal_flag; /* don't need fresh copy, was internal link */ extern BOOLEAN LYresubmit_posts; -extern BOOLEAN user_mode; /* novice or advanced */ +extern int user_mode; /* novice or advanced */ extern BOOLEAN is_www_index; extern BOOLEAN dump_output_immediately; extern int dump_output_width; @@ -170,7 +154,7 @@ extern BOOLEAN error_logging; /* TRUE to mail error messages */ extern BOOLEAN check_mail; /* TRUE to report unread/new mail messages */ extern BOOLEAN vi_keys; /* TRUE to turn on vi-like key movement */ extern BOOLEAN emacs_keys; /* TRUE to turn on emacs-like key movement */ -extern BOOLEAN keypad_mode; /* is set to either NUMBERS_AS_ARROWS * +extern int keypad_mode; /* is set to either NUMBERS_AS_ARROWS * * or LINKS_ARE_NUMBERED */ extern BOOLEAN case_sensitive; /* TRUE to turn on case sensitive search */ extern BOOLEAN no_inside_telnet; /* this and following are restrictions */ @@ -332,10 +316,6 @@ extern BOOLEAN LYPrependBaseToSource; extern BOOLEAN LYPrependCharsetToSource; extern BOOLEAN LYQuitDefaultYes; -#ifdef RAWDOSKEYHACK -extern BOOLEAN raw_dos_key_hack; /* Turn on and off DOS key hack */ -#endif /* RAWDOSKEYHACK */ - #ifndef VMS extern BOOLEAN LYNoCore; #endif /* !VMS */ diff --git a/src/LYJump.c b/src/LYJump.c index b0a407be..ec211f02 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -402,10 +402,11 @@ PRIVATE unsigned LYRead_Jumpfile ARGS1(struct JumpTable *,jtp) return 0; } } else - if ((fd=open(jtp->file, O_RDONLY, "mbc=32")) < 0) { + if ((fd=open(jtp->file, O_RDONLY, "mbc=32")) < 0) #else - if ((fd=open(jtp->file, O_RDONLY)) < 0) { + if ((fd=open(jtp->file, O_RDONLY)) < 0) #endif /* VMS */ + { HTAlert(CANNOT_OPEN_JUMP_FILE); FREE(mp); return 0; diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 3213f6c4..3e087687 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -539,8 +539,8 @@ LYK_DO_NOTHING, #endif /* DIRED_SUPPORT && OK_OVERRIDE */ struct rmap { - char *name; - char *doc; + CONST char *name; + CONST char *doc; }; PRIVATE struct rmap revmap[] = { { "UNMAPPED", NULL }, @@ -636,7 +636,7 @@ PRIVATE struct rmap revmap[] = { { NULL, "" } }; -PRIVATE char *funckey[] = { +PRIVATE CONST char *funckey[] = { "Up Arrow", "Down Arrow", "Right Arrow", diff --git a/src/LYLocal.c b/src/LYLocal.c index 828b0779..d85be6e3 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -97,7 +97,7 @@ PRIVATE BOOLEAN permit_location PARAMS(( #endif /* OK_PERMIT */ PRIVATE char *render_item PARAMS(( - char * s, + CONST char * s, char * path, char * dir, char * buf, @@ -1086,8 +1086,8 @@ PUBLIC BOOLEAN local_remove ARGS1( * Makes the code a bit cleaner. */ static struct { - char *string_mode; /* Key for value below */ - long permit_bits; /* Value for chmod/whatever */ + CONST char *string_mode; /* Key for value below */ + long permit_bits; /* Value for chmod/whatever */ } permissions[] = { {"IRUSR", S_IRUSR}, {"IWUSR", S_IWUSR}, @@ -2078,7 +2078,7 @@ PUBLIC void add_menu_item ARGS1( * Create URL for DIRED HREF value. */ PRIVATE char * render_item ARGS6( - char *, s, + CONST char *, s, char *, path, char *, dir, char *, buf, diff --git a/src/LYMail.c b/src/LYMail.c index 9ca2a175..94b38c74 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -35,10 +35,10 @@ PRIVATE void remove_tildes PARAMS((char *string)); ** mailform() sends form content to the mailto address(es). - FM */ PUBLIC void mailform ARGS4( - char *, mailto_address, - char *, mailto_subject, - char *, mailto_content, - char *, mailto_type) + CONST char *, mailto_address, + CONST char *, mailto_subject, + CONST char *, mailto_content, + CONST char *, mailto_type) { FILE *fd; char *address = NULL; @@ -399,26 +399,26 @@ PUBLIC void mailform ARGS4( i = 0; len = strlen(mailto_content); while (len > 78) { - strncpy(cmd, (char *)&mailto_content[i], 78); + strncpy(cmd, &mailto_content[i], 78); cmd[78] = '\0'; fprintf(fd, "%s\n", cmd); i += 78; - len = strlen((char *)&mailto_content[i]); + len = strlen(&mailto_content[i]); } - fprintf(fd, "%s\n", (char *)&mailto_content[i]); + fprintf(fd, "%s\n", &mailto_content[i]); mailto_content = (cp+1); } i = 0; len = strlen(mailto_content); while (len > 78) { - strncpy(cmd, (char *)&mailto_content[i], 78); + strncpy(cmd, &mailto_content[i], 78); cmd[78] = '\0'; fprintf(fd, "%s\n", cmd); i += 78; - len = strlen((char *)&mailto_content[i]); + len = strlen(&mailto_content[i]); } if (len) - fprintf(fd, "%s\n", (char *)&mailto_content[i]); + fprintf(fd, "%s\n", &mailto_content[i]); #ifdef UNIX pclose(fd); @@ -880,7 +880,7 @@ PUBLIC void reply_by_mail ARGS3( CTRACE(tfp, "reply_by_mail(\"%s\", \"%s\", \"%s\")\n", mail_address?mail_address:"<nil>", filename?filename:"<nil>", - title?tilde:"<nil>"); + title?title:"<nil>"); if (!strncasecomp(system_mail, "PMDF SEND", 9)) { isPMDF = TRUE; @@ -1517,9 +1517,9 @@ PUBLIC void reply_by_mail ARGS3( */ sprintf(buf, "\n"); StrAllocCat(header, buf); + CTRACE(tfp,"**header==\n%s",header); #endif /* !VMS */ - CTRACE(tfp,"**header==\n%s",header); if (!no_editor && editor && *editor != '\0') { /* * Use an external editor for the message. diff --git a/src/LYMail.h b/src/LYMail.h index 8de71866..3304228a 100644 --- a/src/LYMail.h +++ b/src/LYMail.h @@ -9,10 +9,10 @@ extern BOOLEAN term_letter; extern void mailform PARAMS(( - char * mailto_address, - char * mailto_subject, - char * mailto_content, - char * mailto_type)); + CONST char * mailto_address, + CONST char * mailto_subject, + CONST char * mailto_content, + CONST char * mailto_type)); extern void mailmsg PARAMS(( int cur, char * owner_address, diff --git a/src/LYMain.c b/src/LYMain.c index 06526a5d..65687a51 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -33,6 +33,7 @@ #ifdef DOSPATH #include <HTDOS.h> #endif +#include <LYCookie.h> #ifdef __DJGPP__ #include <dos.h> @@ -109,7 +110,7 @@ PUBLIC char *LYCSwingPath = NULL; #ifdef DIRED_SUPPORT PUBLIC BOOLEAN lynx_edit_mode = FALSE; PUBLIC BOOLEAN no_dired_support = FALSE; -PUBLIC BOOLEAN dir_list_style = MIXED_STYLE; +PUBLIC int dir_list_style = MIXED_STYLE; PUBLIC HTList *tagged = NULL; #ifdef OK_OVERRIDE PUBLIC BOOLEAN prev_lynx_edit_mode = FALSE; @@ -179,7 +180,7 @@ PUBLIC BOOLEAN LYJumpFileURL = FALSE; /* always FALSE the first time */ PUBLIC BOOLEAN jump_buffer = JUMPBUFFER; /* TRUE if offering default shortcut */ PUBLIC BOOLEAN goto_buffer = GOTOBUFFER; /* TRUE if offering default goto URL */ PUBLIC BOOLEAN recent_sizechange = FALSE;/* the window size changed recently? */ -PUBLIC BOOLEAN user_mode = NOVICE_MODE; +PUBLIC int user_mode = NOVICE_MODE; PUBLIC BOOLEAN dump_output_immediately = FALSE; PUBLIC BOOLEAN is_www_index = FALSE; PUBLIC BOOLEAN lynx_mode = NORMAL_LYNX_MODE; @@ -198,7 +199,7 @@ PUBLIC BOOLEAN error_logging = MAIL_SYSTEM_ERROR_LOGGING; PUBLIC BOOLEAN check_mail = CHECKMAIL; PUBLIC BOOLEAN vi_keys = VI_KEYS_ALWAYS_ON; PUBLIC BOOLEAN emacs_keys = EMACS_KEYS_ALWAYS_ON; -PUBLIC BOOLEAN keypad_mode = DEFAULT_KEYPAD_MODE; +PUBLIC int keypad_mode = DEFAULT_KEYPAD_MODE; PUBLIC BOOLEAN case_sensitive = CASE_SENSITIVE_ALWAYS_ON; PUBLIC BOOLEAN telnet_ok = TRUE; PUBLIC BOOLEAN news_ok = TRUE; @@ -208,9 +209,6 @@ PUBLIC BOOLEAN system_editor = FALSE; #ifdef USE_EXTERNALS PUBLIC BOOLEAN no_externals = FALSE; #endif -#ifdef RAWDOSKEYHACK -PUBLIC BOOLEAN raw_dos_key_hack = TRUE; -#endif /* RAWDOSKEYHACK */ PUBLIC BOOLEAN no_inside_telnet = FALSE; PUBLIC BOOLEAN no_outside_telnet = FALSE; PUBLIC BOOLEAN no_telnet_port = FALSE; @@ -441,23 +439,7 @@ PRIVATE void free_lynx_globals NOARGS #ifdef LYNXCGI_LINKS /* WebSter Mods -jkt */ FREE(LYCgiDocumentRoot); #endif /* LYNXCGI_LINKS */ - FREE(lynx_version_putenv_command); - FREE(NNTPSERVER_putenv_cmd); - FREE(http_proxy_putenv_cmd); - FREE(https_proxy_putenv_cmd); - FREE(ftp_proxy_putenv_cmd); - FREE(gopher_proxy_putenv_cmd); - FREE(cso_proxy_putenv_cmd); - FREE(news_proxy_putenv_cmd); - FREE(newspost_proxy_putenv_cmd); - FREE(newsreply_proxy_putenv_cmd); - FREE(snews_proxy_putenv_cmd); - FREE(snewspost_proxy_putenv_cmd); - FREE(snewsreply_proxy_putenv_cmd); - FREE(nntp_proxy_putenv_cmd); - FREE(wais_proxy_putenv_cmd); - FREE(finger_proxy_putenv_cmd); - FREE(no_proxy_putenv_cmd); + free_lynx_cfg(); #endif /* !VMS */ #ifdef VMS @@ -595,7 +577,7 @@ PUBLIC int main ARGS2( * Where necessary we should open and (close!) TEXT mode. */ _fmode = O_BINARY; - setmode( fileno( stdout ), O_BINARY ); + SetOutputMode( O_BINARY ); #endif #ifdef DOSPATH @@ -1543,6 +1525,14 @@ PUBLIC int main ARGS2( */ HTMLUseCharacterSet(current_char_set); +#ifdef EXP_PERSISTENT_COOKIES + /* + * Sod it, this looks like a reasonable place to load the + * cookies file, probably. - RP + */ + LYLoadCookies("cookies"); /* add command line options! */ +#endif + /* * If startfile is a file URL and the host is defaulted, * force in "//localhost", and if it's not an absolute URL, @@ -1822,7 +1812,7 @@ typedef union { typedef struct parse_args_type { - char *name; + CONST char *name; int type; #define IGNORE_ARG 0x000 #define TOGGLE_ARG 0x001 @@ -1845,7 +1835,7 @@ typedef struct parse_args_type */ ParseData; - char *help_string; + CONST char *help_string; } Parse_Args_Type; @@ -1907,10 +1897,10 @@ static int assume_charset_fun ARGS3( if (next_arg == 0) { UCLYhndl_for_unspec = 0; } else { - LYLowerCase(next_arg); - StrAllocCopy(UCAssume_MIMEcharset, next_arg); - if (UCAssume_MIMEcharset && *UCAssume_MIMEcharset) - UCLYhndl_for_unspec = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + LYLowerCase(next_arg); + StrAllocCopy(UCAssume_MIMEcharset, next_arg); + if (UCAssume_MIMEcharset && *UCAssume_MIMEcharset) + UCLYhndl_for_unspec = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); } return 0; } @@ -1924,11 +1914,11 @@ static int assume_local_charset_fun ARGS3( if (next_arg == 0) { UCLYhndl_HTFile_for_unspec = 0; } else { - LYLowerCase(next_arg); - StrAllocCopy(UCAssume_localMIMEcharset, next_arg); - if (UCAssume_localMIMEcharset && *UCAssume_localMIMEcharset) - UCLYhndl_HTFile_for_unspec = - UCGetLYhndl_byMIME(UCAssume_localMIMEcharset); + LYLowerCase(next_arg); + StrAllocCopy(UCAssume_localMIMEcharset, next_arg); + if (UCAssume_localMIMEcharset && *UCAssume_localMIMEcharset) + UCLYhndl_HTFile_for_unspec = + UCGetLYhndl_byMIME(UCAssume_localMIMEcharset); } return 0; } @@ -1976,7 +1966,7 @@ static int base_fun ARGS3( */ LYPrependBase = TRUE; if (HTOutputFormat == HTAtom_for("www/dump")) - HTOutputFormat = HTAtom_for("www/download"); + HTOutputFormat = HTAtom_for("www/download"); return 0; } @@ -1984,9 +1974,9 @@ static int base_fun ARGS3( #ifdef USE_SLANG /* -blink */ static int blink_fun ARGS3( - Parse_Args_Type*, p, - char **, argv, - char *, next_arg) + Parse_Args_Type*, p GCC_UNUSED, + char **, argv GCC_UNUSED, + char *, next_arg GCC_UNUSED) { Lynx_Color_Flags |= SL_LYNX_USE_BLINK; return 0; @@ -2000,7 +1990,7 @@ static int cache_fun ARGS3( char *, next_arg) { if (next_arg != 0) - HTCacheSize = atoi(next_arg); + HTCacheSize = atoi(next_arg); /* * Limit size. */ @@ -2023,14 +2013,14 @@ static int child_fun ARGS3( #ifdef USE_SLANG /* -color */ static int color_fun ARGS3( - Parse_Args_Type*, p, - char **, argv, - char *, next_arg) + Parse_Args_Type*, p GCC_UNUSED, + char **, argv GCC_UNUSED, + char *, next_arg GCC_UNUSED) { Lynx_Color_Flags |= SL_LYNX_USE_COLOR; if (LYShowColor != SHOW_COLOR_ALWAYS) - LYShowColor = SHOW_COLOR_ON; + LYShowColor = SHOW_COLOR_ON; return 0; } @@ -2106,7 +2096,7 @@ static int error_file_fun ARGS3( * of an HTTP transaction. */ if (next_arg != 0) - http_error_file = next_arg; + http_error_file = next_arg; return 0; } @@ -2159,13 +2149,13 @@ static int get_data_fun ARGS3( */ while (fgets(buf, sizeof(buf), stdin) && strncmp(buf, "---", 3) != 0) { - int j; + int j; - for (j = strlen(buf) - 1; j >= 0 && /* Strip line terminators */ + for (j = strlen(buf) - 1; j >= 0 && /* Strip line terminators */ (buf[j] == CR || buf[j] == LF); j--) buf[j] = '\0'; - StrAllocCat(*get_data, buf); + StrAllocCat(*get_data, buf); } return 0; @@ -2197,7 +2187,7 @@ static int hiddenlinks_fun ARGS3( else print_help_and_exit (-1); } else { - LYHiddenLinks = HIDDENLINKS_MERGE; + LYHiddenLinks = HIDDENLINKS_MERGE; } return 0; @@ -2458,9 +2448,9 @@ static int restrictions_fun ARGS3( if (next_arg != 0) { parse_restrictions(next_arg); } else { - for (n = 0; n < sizeof(Usage)/sizeof(Usage[0]); n++) - printf("%s\n", Usage[n]); - exit(0); + for (n = 0; n < sizeof(Usage)/sizeof(Usage[0]); n++) + printf("%s\n", Usage[n]); + exit(0); } return 0; } @@ -2939,6 +2929,10 @@ treated '>' as a co-terminator for double-quotes and tags" "validate", IGNORE_ARG, 0, "accept only http URLs (for validation)" ), + PARSE_SET( + "verbose", TOGGLE_ARG, &verbose_img, + "toggles [LINK], [IMAGE] and [INLINE] comments \nwith filenames of these images" + ), PARSE_FUN( "version", FUNCTION_ARG, version_fun, "print Lynx version information" @@ -2955,8 +2949,8 @@ treated '>' as a co-terminator for double-quotes and tags" }; static void print_help_strings ARGS2( - char *, name, - char *, help) + CONST char *, name, + CONST char *, help) { int pad; int c; @@ -2989,11 +2983,11 @@ static void print_help_strings ARGS2( } else { c = ' '; } - fputc (c, stdout); + fputc (c, stdout); while (pad--) fputc (' ', stdout); } else { - fputc (c, stdout); + fputc (c, stdout); } help++; first--; @@ -3008,6 +3002,8 @@ static void print_help_and_exit ARGS1(int, exit_status) if (pgm == NULL) pgm = "lynx"; + SetOutputMode( O_TEXT ); + fprintf (stdout, "USAGE: %s [options] [file]\n", pgm); fprintf (stdout, "Options are:\n"); print_help_strings("", @@ -3017,6 +3013,8 @@ in double-quotes (\"-\") on VMS)"); for (p = Arg_Table; p->name != 0; p++) print_help_strings(p->name, p->help_string); + SetOutputMode( O_BINARY ); + exit (exit_status); } @@ -3029,7 +3027,7 @@ in double-quotes (\"-\") on VMS)"); * If a and b match, it returns 1. Otherwise 0 is returned. */ static int arg_eqs_parse ARGS3( - char *, a, + CONST char *, a, char *, b, char **, c) { @@ -3103,7 +3101,7 @@ PRIVATE void parse_arg ARGS2( * special handling. - FM */ if (*arg_name == 0) - return; + return; p = Arg_Table; while (p->name != 0) { @@ -3124,7 +3122,7 @@ PRIVATE void parse_arg ARGS2( if ((p->type & NEED_NEXT_ARG) && (next_arg == 0)) { next_arg = argv[1]; if ((i != 0) && (next_arg != 0)) - (*i)++; + (*i)++; } switch (p->type & ARG_TYPE_MASK) { @@ -3163,17 +3161,17 @@ PRIVATE void parse_arg ARGS2( case LYSTRING_ARG: if ((q->str_value != 0) && (next_arg != 0)) - StrAllocCopy(*(q->str_value), next_arg); + StrAllocCopy(*(q->str_value), next_arg); break; case INT_ARG: if ((q->int_value != 0) && (next_arg != 0)) - *(q->int_value) = atoi (next_arg); + *(q->int_value) = atoi (next_arg); break; case STRING_ARG: if ((q->str_value != 0) && (next_arg != 0)) - *(q->str_value) = next_arg; + *(q->str_value) = next_arg; break; case IGNORE_ARG: diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 566027f3..fa01fdbe 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -207,7 +207,7 @@ int mainloop NOARGS BOOLEAN emacs_keys_flag = emacs_keys; BOOLEAN keypad_mode_flag = keypad_mode; BOOLEAN user_mode_flag = user_mode; - BOOLEAN HTfileSortMethod_flag = HTfileSortMethod; + int HTfileSortMethod_flag = HTfileSortMethod; int CurrentCharSet_flag = current_char_set; int CurrentAssumeCharSet_flag = UCLYhndl_for_unspec; int CurrentAssumeLocalCharSet_flag = UCLYhndl_HTFile_for_unspec; @@ -642,8 +642,14 @@ try_again: startfile); else #endif /* UNIX */ + { + + SetOutputMode( O_TEXT ); printf("\nlynx: Can't access startfile %s\n", startfile); + SetOutputMode( O_BINARY ); + } + if (!dump_output_immediately) { #ifndef NOSIGHUP (void) signal(SIGHUP, SIG_DFL); @@ -740,9 +746,13 @@ try_again: } else #endif /* UNIX */ { + SetOutputMode( O_TEXT ); + printf( "\nlynx: Start file could not be found or is not text/html or text/plain\n"); printf(" Exiting...\n"); + + SetOutputMode( O_BINARY ); } if (!dump_output_immediately) { #ifndef NOSIGHUP @@ -1047,7 +1057,7 @@ try_again: } else if (!dump_output_immediately) { StrAllocCopy(curdoc.title, newdoc.title); } - owner_address = HText_getOwner(); + owner_address = (char *)HText_getOwner(); curdoc.safe = HTLoadedDocumentIsSafe(); if (!dump_output_immediately) { LYAddVisitedLink(&curdoc); @@ -1558,7 +1568,7 @@ try_again: addstr(FORM_NOVICELINE_TWO); } c = change_form_link(&links[curdoc.link], - FORM_UP, &newdoc, &refresh_screen, + &newdoc, &refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); @@ -2895,7 +2905,7 @@ new_cmd: /* links[curdoc.link].hightext); } c = change_form_link(&links[curdoc.link], - FORM_UP, &newdoc, &refresh_screen, + &newdoc, &refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); if (HTOutputFormat == HTAtom_for("www/download") && @@ -3714,7 +3724,7 @@ check_goto_URL: if (lynx_mode == FORMS_LYNX_MODE) { if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) { c = change_form_link(&links[curdoc.link], - FORM_UP, &newdoc, &refresh_screen, + &newdoc, &refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); /* @@ -3739,7 +3749,7 @@ check_goto_URL: if (lynx_mode==FORMS_LYNX_MODE) { if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) { c = change_form_link(&links[curdoc.link], - FORM_DOWN,&newdoc,&refresh_screen, + &newdoc,&refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); goto new_keyboard_input; @@ -4106,17 +4116,17 @@ check_goto_URL: /* * The owner_address is a mailto: URL. */ - cp = HText_getRevTitle(); + CONST char *kp = HText_getRevTitle(); if (strchr(owner_address,':')!=NULL) /* * Send a reply. The address is after the colon. */ reply_by_mail(strchr(owner_address,':')+1, curdoc.address, - (cp ? cp : "")); + (kp ? kp : "")); else reply_by_mail(owner_address, curdoc.address, - (cp ? cp : "")); + (kp ? kp : "")); refresh_screen = TRUE; /* to force a showpage */ } diff --git a/src/LYNews.c b/src/LYNews.c index 45d560cb..3237a0ea 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -47,6 +47,7 @@ PUBLIC char *LYNewsPost ARGS2( char user_input[1024]; char CJKinput[1024]; char *cp = NULL; + CONST char *kp = NULL; int c = 0; /* user input */ FILE *fd = NULL; char my_tempfile[256]; @@ -140,15 +141,15 @@ PUBLIC char *LYNewsPost ARGS2( addstr("\n\n Please provide or edit the Subject: header\n"); strcpy(user_input, "Subject: "); if ((followup == TRUE && nhist > 0) && - (cp = HText_getTitle()) != NULL) { + (kp = HText_getTitle()) != NULL) { /* * Add the default subject. */ - cp = LYSkipBlanks(cp); - if (strncasecomp(cp, "Re:", 3)) { + kp = LYSkipCBlanks(kp); + if (strncasecomp(kp, "Re:", 3)) { strcat(user_input, "Re: "); } - strcat(user_input, cp); + strcat(user_input, kp); } cp = NULL; if (LYgetstr(user_input, VISIBLE, diff --git a/src/LYOptions.c b/src/LYOptions.c index c763b853..d4a20f8d 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -2122,7 +2122,8 @@ PRIVATE int popup_choice ARGS6( #ifndef USE_SLANG WINDOW * form_window; #endif /* !USE_SLANG */ - int num_choices = 0, top, bottom, length = -1, width = 0; + int num_choices = 0, top, bottom, length = -1; + unsigned width = 0; char ** Cptr = choices; int window_offset = 0; int DisplayLines = (LYlines - 2); diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index a8e1ac67..b5abda17 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -297,7 +297,7 @@ PRIVATE void add_printer_to_list ARGS2( int default_fg = COLOR_WHITE; int default_bg = COLOR_BLACK; -static char *Color_Strings[16] = +static CONST char *Color_Strings[16] = { "black", "red", @@ -463,6 +463,7 @@ typedef union { #define PARSE_SET(n,t,v) {n,t, 0, &v, 0, 0, 0, 0} #define PARSE_INT(n,t,v) {n,t, 0, 0, &v, 0, 0, 0} #define PARSE_STR(n,t,v) {n,t, 0, 0, 0, &v, 0, 0} +#define PARSE_ENV(n,t,v) {n,t, 0, 0, 0, v, 0, 0} #define PARSE_FUN(n,t,v) {n,t, 0, 0, 0, 0, v, 0} #define PARSE_DEF(n,t,v) {n,t, 0, 0, 0, 0, 0, v} #else @@ -471,13 +472,14 @@ typedef union { #define PARSE_SET(n,t,v) {n,t, (long)&(v)} #define PARSE_INT(n,t,v) {n,t, (long)&(v)} #define PARSE_STR(n,t,v) {n,t, (long)&(v)} +#define PARSE_ENV(n,t,v) {n,t, (long) (v)} #define PARSE_FUN(n,t,v) {n,t, (long) (v)} #define PARSE_DEF(n,t,v) {n,t, (long) (v)} #endif typedef struct { - char *name; + CONST char *name; int type; #define CONF_BOOL 1 /* BOOLEAN type */ #define CONF_FUN 2 @@ -804,7 +806,7 @@ static Config_Type Config_Table [] = #ifdef USE_COLOR_TABLE PARSE_FUN("color", CONF_FUN, color_fun), #endif - PARSE_STR("cso_proxy", CONF_ENV, cso_proxy_putenv_cmd ), + PARSE_ENV("cso_proxy", CONF_ENV, 0 ), #ifdef VMS PARSE_STR("CSWING_PATH", CONF_STR, LYCSwingPath), #endif @@ -826,17 +828,17 @@ static Config_Type Config_Table [] = #ifdef USE_EXTERNALS PARSE_ADD("external", CONF_ADD_ITEM, externals), #endif - PARSE_STR("finger_proxy", CONF_ENV, finger_proxy_putenv_cmd ), + PARSE_ENV("finger_proxy", CONF_ENV, 0 ), PARSE_SET("force_ssl_cookies_secure", CONF_BOOL, LYForceSSLCookiesSecure), - PARSE_STR("ftp_proxy", CONF_ENV, ftp_proxy_putenv_cmd ), + PARSE_ENV("ftp_proxy", CONF_ENV, 0 ), PARSE_STR("global_extension_map", CONF_STR, global_extension_map), PARSE_STR("global_mailcap", CONF_STR, global_type_map), - PARSE_STR("gopher_proxy", CONF_ENV, gopher_proxy_putenv_cmd ), + PARSE_ENV("gopher_proxy", CONF_ENV, 0 ), PARSE_SET("gotobuffer", CONF_BOOL, goto_buffer), PARSE_STR("helpfile", CONF_STR, helpfile), PARSE_SET("historical_comments", CONF_BOOL, historical_comments), - PARSE_STR("http_proxy", CONF_ENV, http_proxy_putenv_cmd ), - PARSE_STR("https_proxy", CONF_ENV, https_proxy_putenv_cmd ), + PARSE_ENV("http_proxy", CONF_ENV, 0 ), + PARSE_ENV("https_proxy", CONF_ENV, 0 ), PARSE_FUN("include", CONF_INCLUDE, 0), PARSE_INT("infosecs", CONF_INT, InfoSecs), PARSE_STR("jump_prompt", CONF_STR, jumpprompt), @@ -874,11 +876,11 @@ static Config_Type Config_Table [] = PARSE_FUN("news_chunk_size", CONF_FUN, news_chunk_size_fun), PARSE_FUN("news_max_chunk", CONF_FUN, news_max_chunk_fun), PARSE_FUN("news_posting", CONF_FUN, news_posting_fun), - PARSE_STR("news_proxy", CONF_ENV, news_proxy_putenv_cmd), - PARSE_STR("newspost_proxy", CONF_ENV, newspost_proxy_putenv_cmd), - PARSE_STR("newsreply_proxy", CONF_ENV, newsreply_proxy_putenv_cmd), - PARSE_STR("nntp_proxy", CONF_ENV, nntp_proxy_putenv_cmd), - PARSE_STR("nntpserver", CONF_ENV, NNTPSERVER_putenv_cmd), + PARSE_ENV("news_proxy", CONF_ENV, 0), + PARSE_ENV("newspost_proxy", CONF_ENV, 0), + PARSE_ENV("newsreply_proxy", CONF_ENV, 0), + PARSE_ENV("nntp_proxy", CONF_ENV, 0), + PARSE_ENV("nntpserver", CONF_ENV, 0), PARSE_SET("no_dot_files", CONF_BOOL, no_dotfiles), PARSE_SET("no_file_referer", CONF_BOOL, no_filereferer), #ifndef VMS @@ -886,7 +888,7 @@ static Config_Type Config_Table [] = #endif PARSE_SET("no_from_header", CONF_BOOL, LYNoFromHeader), PARSE_SET("no_ismap_if_usemap", CONF_BOOL, LYNoISMAPifUSEMAP), - PARSE_STR("no_proxy", CONF_ENV, no_proxy_putenv_cmd ), + PARSE_ENV("no_proxy", CONF_ENV, 0 ), PARSE_SET("no_referer_header", CONF_BOOL, LYNoRefererHeader), #ifdef DISP_PARTIAL PARSE_SET("partial", CONF_BOOL, display_partial), @@ -898,9 +900,6 @@ static Config_Type Config_Table [] = PARSE_SET("prepend_base_to_source", CONF_BOOL, LYPrependBaseToSource), PARSE_SET("prepend_charset_to_source", CONF_BOOL, LYPrependCharsetToSource), PARSE_FUN("printer", CONF_FUN, printer_fun), -#ifdef RAWDOSKEYHACK - PARSE_SET("raw_dos_key_hack", CONF_BOOL, raw_dos_key_hack), -#endif PARSE_SET("quit_default_yes", CONF_BOOL, LYQuitDefaultYes), PARSE_STR("save_space", CONF_STR, lynx_save_space), PARSE_SET("scan_for_buried_news_refs", CONF_BOOL, scan_for_buried_news_references), @@ -908,9 +907,9 @@ static Config_Type Config_Table [] = PARSE_SET("seek_frag_map_in_cur", CONF_BOOL, LYSeekFragMAPinCur), PARSE_SET("set_cookies", CONF_BOOL, LYSetCookies), PARSE_SET("show_cursor", CONF_BOOL, LYShowCursor), - PARSE_STR("snews_proxy", CONF_ENV, snews_proxy_putenv_cmd ), - PARSE_STR("snewspost_proxy", CONF_ENV, snewspost_proxy_putenv_cmd ), - PARSE_STR("snewsreply_proxy", CONF_ENV, snewsreply_proxy_putenv_cmd ), + PARSE_ENV("snews_proxy", CONF_ENV, 0 ), + PARSE_ENV("snewspost_proxy", CONF_ENV, 0 ), + PARSE_ENV("snewsreply_proxy", CONF_ENV, 0 ), PARSE_SET("soft_dquotes", CONF_BOOL, soft_dquotes), PARSE_STR("startfile", CONF_STR, startfile), PARSE_SET("strip_dotdot_urls", CONF_BOOL, LYStripDotDotURLs), @@ -940,13 +939,39 @@ static Config_Type Config_Table [] = PARSE_SET("verbose_images", CONF_BOOL, verbose_img), PARSE_SET("vi_keys_always_on", CONF_BOOL, vi_keys), PARSE_FUN("viewer", CONF_FUN, viewer_fun), - PARSE_STR("wais_proxy", CONF_ENV, wais_proxy_putenv_cmd ), + PARSE_ENV("wais_proxy", CONF_ENV, 0 ), PARSE_STR("xloadimage_command", CONF_STR, XLoadImageCommand), {0} }; /* + * Free memory allocated in 'read_cfg()' + */ +PUBLIC void free_lynx_cfg NOARGS +{ + Config_Type *tbl; + + for (tbl = Config_Table; tbl->name != 0; tbl++) { +#ifdef PARSE_DEBUG + Config_Type *q = tbl; +#else + ConfigUnion *q = (ConfigUnion *)(&(tbl->value)); +#endif + switch (tbl->type) { + case CONF_ENV: + if (q->str_value != 0) { + FREE(*(q->str_value)); + free((char *)q->str_value); + } + break; + default: + break; + } + } +} + +/* * Process the configuration file (lynx.cfg). */ PUBLIC void read_cfg ARGS3( @@ -1092,6 +1117,7 @@ PUBLIC void read_cfg ARGS3( #else char tmpbuf[MAX_LINE_BUFFER_LEN]; sprintf (tmpbuf, "%s=%s", tbl->name, value); + q->str_value = (char **)calloc(1, sizeof(char **)); StrAllocCopy(*(q->str_value), tmpbuf); putenv (*(q->str_value)); #endif diff --git a/src/LYReadCFG.h b/src/LYReadCFG.h index a6ed7c70..6b60165d 100644 --- a/src/LYReadCFG.h +++ b/src/LYReadCFG.h @@ -44,6 +44,7 @@ extern int check_color PARAMS((char * color, int the_default)); #endif extern void read_cfg PARAMS((char *cfg_filename, char *parent_filename, int nesting_level)); +extern void free_lynx_cfg NOPARAMS; extern BOOLEAN have_read_cfg; #endif /* LYREADCFG_H */ diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index f0ae2a20..a70a1a04 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -40,7 +40,7 @@ PUBLIC int showinfo ARGS4( int url_type; FILE *fp0; char *Address = NULL, *Title = NULL; - char *cp; + CONST char *cp; #ifdef DIRED_SUPPORT char temp[300]; diff --git a/src/LYStrings.c b/src/LYStrings.c index e5548165..9f8b3f19 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1459,7 +1459,7 @@ again: */ PUBLIC char * LYstrstr ARGS2( char *, chptr, - char *, tarptr) + CONST char *, tarptr) { int len = strlen(tarptr); diff --git a/src/LYStrings.h b/src/LYStrings.h index 48c5a478..c115b7db 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -23,7 +23,7 @@ extern int LYgetstr PARAMS(( int recall)); extern char * LYstrstr PARAMS(( char * chptr, - char * tarptr)); + CONST char * tarptr)); extern char * LYmbcsstrncpy PARAMS(( char * dst, CONST char * src, diff --git a/src/LYUtils.c b/src/LYUtils.c index e4e4fa47..f124c664 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1936,7 +1936,7 @@ PUBLIC void statusline ARGS1( return; } -static char *novice_lines[] = { +static CONST char *novice_lines[] = { #ifndef NOVICE_LINE_TWO_A #define NOVICE_LINE_TWO_A NOVICE_LINE_TWO #define NOVICE_LINE_TWO_B "" @@ -1979,7 +1979,7 @@ PUBLIC void noviceline ARGS1( if (LYUseNoviceLineTwo) addstr(NOVICE_LINE_TWO); else - addstr(novice_lines[lineno]); + addstr((char *)novice_lines[lineno]); #ifdef NOTDEFINED if (is_www_index && more_flag) { @@ -2138,7 +2138,7 @@ PUBLIC int HTCheckForInterrupt NOARGS break; case LYK_END: if (HText_canScrollDown()) - Newline_partial = HText_getNumOfLines() - display_lines + 2; + Newline_partial = HText_getNumOfLines() - display_lines + 1; /* set "current" value */ break; case LYK_REFRESH : @@ -2259,12 +2259,13 @@ PUBLIC BOOLEAN LYisLocalHost ARGS1( #ifdef VMS if ((0==strcasecomp(host, "localhost") || 0==strcasecomp(host, LYHostName) || - 0==strcasecomp(host, HTHostName()))) { + 0==strcasecomp(host, HTHostName()))) #else if ((0==strcmp(host, "localhost") || 0==strcmp(host, LYHostName) || - 0==strcmp(host, HTHostName()))) { + 0==strcmp(host, HTHostName()))) #endif /* VMS */ + { FREE(host); return YES; } @@ -2342,10 +2343,11 @@ PUBLIC BOOLEAN LYisLocalAlias ARGS1( while (NULL != (alias = (char *)HTList_nextObject(cur))) { #ifdef VMS - if (0==strcasecomp(host, alias)) { + if (0==strcasecomp(host, alias)) #else - if (0==strcmp(host, alias)) { + if (0==strcmp(host, alias)) #endif /* VMS */ + { FREE(host); return YES; } @@ -2414,7 +2416,7 @@ PUBLIC int LYCheckForProxyURL ARGS1( */ static BOOLEAN compare_type ARGS3( char *, tst, - char *, cmp, + CONST char *, cmp, size_t, len) { if (!strncasecomp(tst, cmp, len)) { @@ -3323,7 +3325,7 @@ PUBLIC int number2arrows ARGS1( * parse_restrictions takes a string of comma-separated restrictions * and sets the corresponding flags to restrict the facilities available. */ -PRIVATE char *restrict_name[] = { +PRIVATE CONST char *restrict_name[] = { "inside_telnet" , "outside_telnet", "telnet_port" , @@ -3410,10 +3412,10 @@ PRIVATE BOOLEAN *restrict_flag[] = { (BOOLEAN *) 0 }; PUBLIC void parse_restrictions ARGS1( - char *, s) + CONST char *, s) { - char *p; - char *word; + CONST char *p; + CONST char *word; int i; if (STREQ("all", s)) { @@ -3468,17 +3470,15 @@ PUBLIC void parse_restrictions ARGS1( p = s; while (*p) { - p = LYSkipBlanks(p); + p = LYSkipCBlanks(p); if (*p == '\0') break; word = p; while (*p != ',' && *p != '\0') p++; - if (*p) - *p++ = '\0'; for (i=0; restrict_name[i]; i++) - if (STREQ(word, restrict_name[i])) { + if (STRNEQ(word, restrict_name[i], p-word)) { *restrict_flag[i] = TRUE; break; } @@ -3628,7 +3628,7 @@ PUBLIC int LYCheckMail NOARGS */ PUBLIC void LYEnsureAbsoluteURL ARGS2( char **, href, - char *, name) + CONST char *, name) { char *temp = NULL; @@ -3790,7 +3790,6 @@ PUBLIC void LYConvertToURL ARGS1( strcat(url_file, old_string); CTRACE(tfp, "Can't find '%s' Will assume it's a bad path.\n", old_string); - } StrAllocCat(*AllocatedString, url_file); } else { /* @@ -5384,18 +5383,40 @@ int remove ARGS1(char *, name) #ifdef UNIX /* - * Open a file that we don't want other users to see. For new files, the umask - * will suffice; however if the file already exists we'll change permissions - * first, before opening it. If the chmod fails because of some reason other - * than a non-existent file, there's no point in trying to open it. + * Open a file that we don't want other users to see. */ PRIVATE FILE *OpenHiddenFile ARGS2(char *, name, char *, mode) { - int save = umask(HIDE_UMASK); FILE *fp = 0; - if (chmod(name, HIDE_CHMOD) == 0 || errno == ENOENT) - fp = fopen(name, mode); - umask(save); + +#if defined(O_CREAT) && defined(O_EXCL) /* we have fcntl.h or kindred? */ + /* + * This is the preferred method for creating new files, since it ensures + * that no one has an existing file or link that they happen to own. + */ + if (*mode == 'w') { + int fd = open(name, O_CREAT|O_EXCL|O_WRONLY, HIDE_CHMOD); + if (fd >= 0) { + fp = fdopen(fd, mode); + } + } + else +#endif + /* + * This is less stringent, but reasonably portable. For new files, the + * umask will suffice; however if the file already exists we'll change + * permissions first, before opening it. If the chmod fails because of + * some reason other than a non-existent file, there's no point in trying + * to open it. + * + * This won't work properly if the user is root, since the chmod succeeds. + */ + { + int save = umask(HIDE_UMASK); + if (chmod(name, HIDE_CHMOD) == 0 || errno == ENOENT) + fp = fopen(name, mode); + umask(save); + } return fp; } #else @@ -5468,13 +5489,13 @@ PUBLIC void LYRelaxFilePermissions ARGS1(CONST char *, name) */ PUBLIC BOOLEAN LYCachedTemp ARGS2( char *, result, - char *, cached) + char **, cached) { FILE *fp; - if (cached) { - strcpy(result, cached); - FREE(cached); + if (*cached) { + strcpy(result, *cached); + FREE(*cached); if ((fp = fopen(result, "r")) != NULL) { fclose(fp); remove(result); diff --git a/src/LYUtils.h b/src/LYUtils.h index 391e8ef0..7c925f4a 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -30,10 +30,10 @@ extern void HTSugFilenames_free NOPARAMS; extern void HTAddSugFilename PARAMS((char *fname)); extern void change_sug_filename PARAMS((char *fname)); extern int number2arrows PARAMS((int number)); -extern void parse_restrictions PARAMS((char *s)); +extern void parse_restrictions PARAMS((CONST char *s)); extern void checkmail NOPARAMS; extern int LYCheckMail NOPARAMS; -extern void LYEnsureAbsoluteURL PARAMS((char **href, char *name)); +extern void LYEnsureAbsoluteURL PARAMS((char **href, CONST char *name)); extern void LYConvertToURL PARAMS((char **AllocatedString)); extern BOOLEAN LYExpandHostForURL PARAMS(( char **AllocatedString, char *prefix_list, char *suffix_list)); @@ -60,7 +60,7 @@ extern FILE *LYAppendToTxtFile PARAMS((char * name)); #ifdef UNIX extern void LYRelaxFilePermissions PARAMS((CONST char * name)); #endif -extern BOOLEAN LYCachedTemp PARAMS((char *result, char *cached)); +extern BOOLEAN LYCachedTemp PARAMS((char *result, char **cached)); extern FILE *LYOpenTemp PARAMS((char *result, CONST char *suffix, CONST char *mode)); extern FILE *LYReopenTemp PARAMS((char *name)); extern FILE *LYOpenScratch PARAMS((char *result, CONST char *prefix)); diff --git a/src/UCdomap.c b/src/UCdomap.c index 52617440..ae3ac64c 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -265,7 +265,7 @@ PRIVATE int con_insert_unipair PARAMS(( int fordefault)); PRIVATE int con_insert_unipair_str PARAMS(( u16 unicode, - char * replace_str, + CONST char * replace_str, int fordefault)); PRIVATE void con_clear_unimap PARAMS(( int fordefault)); @@ -306,7 +306,7 @@ PRIVATE int UC_FindGN_byMIME PARAMS(( CONST char * UC_MIMEcharset)); PRIVATE void UCreset_allocated_LYCharSets NOPARAMS; PRIVATE void UCfree_allocated_LYCharSets NOPARAMS; -PRIVATE char ** UC_setup_LYCharSets_repl PARAMS(( +PRIVATE CONST char ** UC_setup_LYCharSets_repl PARAMS(( int UC_charset_in_hndl, unsigned lowest8)); PRIVATE int UC_Register_with_LYCharSets PARAMS(( @@ -602,11 +602,12 @@ PRIVATE int con_insert_unipair ARGS3( PRIVATE int con_insert_unipair_str ARGS3( u16, unicode, - char *, replace_str, + CONST char *, replace_str, int, fordefault) { int i, n; - char ***p1, **p2; + char ***p1; + CONST char **p2; if(fordefault) p1 = unidefault_pagedir_str[n = unicode >> 11]; @@ -626,15 +627,18 @@ PRIVATE int con_insert_unipair_str ARGS3( } } - if (!(p2 = p1[n = (unicode >> 6) & 0x1f])) { - p2 = p1[n] = (char* *)malloc(64*sizeof(char *)); - if (!p2) + n = ((unicode >> 6) & 0x1f); + if (!p1[n]) { + p1[n] = (char **)malloc(64*sizeof(char *)); + if (!p1[n]) return -ENOMEM; + p2 = (CONST char **)p1[n]; for (i = 0; i < 64; i++) { p2[i] = NULL; /* No replace string this character (yet) */ } } + p2 = (CONST char **)p1[n]; p2[unicode & 0x3f] = replace_str; @@ -1649,7 +1653,7 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1( /* * We need to remember which ones were allocated and which are static. */ -PRIVATE char ** remember_allocated_LYCharSets[MAXCHARSETS]; +PRIVATE CONST char ** remember_allocated_LYCharSets[MAXCHARSETS]; PRIVATE void UCreset_allocated_LYCharSets NOARGS { @@ -1671,17 +1675,17 @@ PRIVATE void UCfree_allocated_LYCharSets NOARGS } } -PRIVATE char ** UC_setup_LYCharSets_repl ARGS2( +PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2( int, UC_charset_in_hndl, unsigned, lowest8) { - char **ISO_Latin1 = LYCharSets[0]; - char **p; + CONST char **ISO_Latin1 = LYCharSets[0]; + CONST char **p; char **prepl; u16 *pp; - char **tp; - char *s7; - char *s8; + CONST char **tp; + CONST char *s7; + CONST char *s8; size_t i; int j, changed; u16 k; @@ -1690,7 +1694,7 @@ PRIVATE char ** UC_setup_LYCharSets_repl ARGS2( /* * Create a temporary table for reverse lookup of latin1 codes: */ - tp = (char **)malloc(96 * sizeof(char *)); + tp = (CONST char **)malloc(96 * sizeof(CONST char *)); if (!tp) return NULL; for (i = 0; i < 96; i++) @@ -1744,12 +1748,14 @@ PRIVATE char ** UC_setup_LYCharSets_repl ARGS2( * Now allocate a new table compatible with LYCharSets[] * and with the HTMLDTD for entities. * We don't know yet whether we'll keep it around. */ - p = prepl = (char **)malloc(HTML_dtd.number_of_entities * sizeof(char *)); - if (!p) { + prepl = (char **)malloc(HTML_dtd.number_of_entities * sizeof(char *)); + if (!prepl) { FREE(tp); FREE(ti); - return NULL; + return 0; } + + p = (CONST char **)prepl; changed = 0; for (i = 0; i < HTML_dtd.number_of_entities; i++, p++) { /* @@ -1820,7 +1826,7 @@ PRIVATE char ** UC_setup_LYCharSets_repl ARGS2( FREE(prepl); return NULL; } - return prepl; + return (CONST char **)prepl; } /* @@ -1833,7 +1839,7 @@ PRIVATE int UC_Register_with_LYCharSets ARGS4( int, lowest_eightbit) { int i, LYhndl, found; - char **repl; + CONST char **repl; LYhndl = -1; if (LYNumCharsets == 0) { @@ -1912,7 +1918,7 @@ PRIVATE int UC_Register_with_LYCharSets ARGS4( /* * Remember to FREE at exit. */ - remember_allocated_LYCharSets[LYhndl]=repl; + remember_allocated_LYCharSets[LYhndl] = repl; } } return LYhndl; diff --git a/src/UCdomap.h b/src/UCdomap.h index a0ff36b3..1570baf0 100644 --- a/src/UCdomap.h +++ b/src/UCdomap.h @@ -29,7 +29,7 @@ extern void UC_Charset_Setup PARAMS(( int lowest_eight, int UC_rawuni)); -char *UC_GNsetMIMEnames[4] = +CONST char *UC_GNsetMIMEnames[4] = {"iso-8859-1", "x-dec-graphics", "cp437", "x-transparent"}; int UC_GNhandles[4] = {-1, -1, -1, -1}; diff --git a/src/chrtrans/UCkd.h b/src/chrtrans/UCkd.h index 1e55716e..104882d7 100644 --- a/src/chrtrans/UCkd.h +++ b/src/chrtrans/UCkd.h @@ -34,7 +34,7 @@ struct unipair { }; struct unipair_str { u16 unicode; - char * replace_str; + CONST char * replace_str; }; struct unimapdesc { u16 entry_ct; diff --git a/src/descrip.mms b/src/descrip.mms index 9f84a7b8..014a3a2b 100644 --- a/src/descrip.mms +++ b/src/descrip.mms @@ -154,7 +154,7 @@ TCPFLAGS = /Define = (DEBUG, ACCESS_AUTH, $(TCP)) TOPT = sys$disk:[]$(TCPOPT).opt COPT = sys$disk:[]$(COMPILER).opt WWWLIB = [-.WWW.Library.Implementation]WWWLib_$(TCP).olb -CFLAGS = $(TCPFLAGS) $(CFLAGS)/Include = ([-], [.chrtrans], [-.WWW.Library.Implementation]) +CFLAGS = $(TCPFLAGS) $(CFLAGS)/Include=([], [-], [.chrtrans], [-.WWW.Library.Implementation]) lynx : lynx.exe diff --git a/src/makefile.dsl b/src/makefile.dsl index 956b0b01..542abd1b 100644 --- a/src/makefile.dsl +++ b/src/makefile.dsl @@ -12,7 +12,7 @@ LYStyle.o LYHash.o CFLAGS= $(MCFLAGS) -I. -I.. $(SLANGINC) CC = gcc -MCFLAGS = -O3 -DUSE_ZLIB -DUSE_EXTERNALS \ +MCFLAGS = -O3 -DDISP_PARTIAL -DUSE_ZLIB -DUSE_EXTERNALS \ -DUSE_SLANG -DDJGPP_KEYHANDLER -DACCESS_AUTH -DNO_CUSERID \ -DNOUSERS -DDOSPATH -DNO_TTYTYPE -DNO_UTMP -I../WWW/library/implement -I../djgpp/tcplib/include \ -I./chrtrans -I../djgpp/tcplib/include/tcp |