diff options
Diffstat (limited to 'src')
125 files changed, 10051 insertions, 11841 deletions
diff --git a/src/AttrList.h b/src/AttrList.h index b58456ff..cacb02e4 100644 --- a/src/AttrList.h +++ b/src/AttrList.h @@ -56,7 +56,7 @@ typedef struct _linkedlist { } linked_list; #endif -#define HText_characterStyle CTRACE(tfp,"HTC called from %s/%d\n",__FILE__,__LINE__);_internal_HTC +#define HText_characterStyle if(TRACE)fprintf(stderr,"HTC called from %s/%d\n",__FILE__,__LINE__);_internal_HTC #undef HText_characterStyle #define HText_characterStyle _internal_HTC diff --git a/src/DefaultStyle.c b/src/DefaultStyle.c index 2e00ba62..bff1b11d 100644 --- a/src/DefaultStyle.c +++ b/src/DefaultStyle.c @@ -4,6 +4,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTStyle.h> #include <HTFont.h> diff --git a/src/GridText.c b/src/GridText.c index 8319737c..0e489dbb 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -3,6 +3,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTString.h> #include <HTFont.h> #include <HTAccess.h> @@ -15,6 +16,7 @@ #include <UCAux.h> #include <assert.h> +#include <ctype.h> #ifndef VMS #ifdef SYSLOG_REQUESTED_URLS #include <syslog.h> @@ -41,8 +43,6 @@ #include <LYexit.h> #include <LYLeaks.h> -#undef DEBUG_APPCH - #ifdef USE_COLOR_STYLE #include <AttrList.h> #include <LYHash.h> @@ -54,16 +54,16 @@ unsigned int cached_styles[CACHEH][CACHEW]; #ifdef USE_COLOR_STYLE_UNUSED void LynxClearScreenCache NOARGS { - int i,j; - - CTRACE(tfp, "flushing cached screen styles\n"); - for (i=0;i<CACHEH;i++) - for (j=0;j<CACHEW;j++) - cached_styles[i][j]=s_a; + int i,j; +if (TRACE) + fprintf(stderr, "flushing cached screen styles\n"); + for (i=0;i<CACHEH;i++) + for (j=0;j<CACHEW;j++) + cached_styles[i][j]=s_a; } #endif /* USE_COLOR_STYLE */ -struct _HTStream { /* only know it as object */ +struct _HTStream { /* only know it as object */ CONST HTStreamClass * isa; /* ... */ }; @@ -72,6 +72,8 @@ struct _HTStream { /* only know it as object */ #define IS_UTF_EXTRA(ch) (text->T.output_utf8 && \ ((unsigned char)(ch)&0xc0) == 0x80) +#define FREE(x) if (x) {free(x); x = NULL;} + extern BOOL HTPassHighCtrlRaw; extern HTkcode kanji_code; extern HTCJKlang HTCJK; @@ -114,8 +116,8 @@ typedef struct _stylechange { typedef struct _line { struct _line *next; struct _line *prev; - unsigned offset; /* Implicit initial spaces */ - unsigned size; /* Number of characters */ + int unsigned offset; /* Implicit initial spaces */ + int unsigned size; /* Number of characters */ BOOL split_after; /* Can we split after? */ BOOL bullet; /* Do we bullet? */ #if defined(USE_COLOR_STYLE) @@ -179,7 +181,7 @@ struct _HText { int top_of_screen; /* Line number */ HTLine * top_of_screen_line; /* Top */ HTLine * next_line; /* Bottom + 1 */ - unsigned permissible_split; /* in last line */ + int permissible_split; /* in last line */ BOOL in_line_1; /* of paragraph */ BOOL stale; /* Must refresh */ BOOL page_has_target; /* has target on screen */ @@ -189,7 +191,7 @@ struct _HText { S_nonascii_text, S_dollar_paren, S_jisx0201_text } state; /* Escape sequence? */ - int kanji_buf; /* Lead multibyte */ + char kanji_buf; /* Lead multibyte */ int in_sjis; /* SJIS flag */ int halted; /* emergency halt */ @@ -244,7 +246,7 @@ PRIVATE int HText_TrueLineSize PARAMS(( /* * text->halted = 1: have set fake 'Z' and output a message - * 2: next time when HText_appendCharacter is called + * 2: next time when HText_appendCharacter is called * it will append *** MEMORY EXHAUSTED ***, then set * to 3. * 3: normal text output will be suppressed (but not anchors, @@ -310,8 +312,9 @@ PRIVATE void * LY_check_calloc ARGS2( HText * t = HTList_objectAt(loaded_texts, i); if (t == HTMainText) t = NULL; /* shouldn't happen */ - { - CTRACE(tfp, "\r *** Emergency freeing document %d/%d for '%s'%s!\n", + if (TRACE) { + fprintf(stderr, + "\r *** Emergency freeing document %d/%d for '%s'%s!\n", i + 1, n, ((t && t->node_anchor && t->node_anchor->address) ? @@ -405,7 +408,8 @@ PUBLIC HText * HText_new ARGS1( #if defined(VMS) && defined (VAXC) && !defined(__DECC) status = lib$stat_vm(&VMType, &VMTotal); - CTRACE(tfp, "GridText: VMTotal = %d\n", VMTotal); + if (TRACE) + fprintf(stderr, "GridText: VMTotal = %d\n", VMTotal); #endif /* VMS && VAXC && !__DECC */ if (!loaded_texts) { @@ -421,26 +425,28 @@ PUBLIC HText * HText_new ARGS1( * and free it before reloading. - Dick Wesseling (ftu@fi.ruu.nl) */ if (anchor->document) { - HTList_removeObject(loaded_texts, anchor->document); - CTRACE(tfp, "GridText: Auto-uncaching\n") ; - ((HText *)anchor->document)->node_anchor = NULL; - HText_free((HText *)anchor->document); - anchor->document = NULL; + HTList_removeObject(loaded_texts, anchor->document); + if (TRACE) + fprintf(stderr, "GridText: Auto-uncaching\n") ; + ((HText *)anchor->document)->node_anchor = NULL; + HText_free((HText *)anchor->document); + anchor->document = NULL; } 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"); + if (TRACE) + fprintf(stderr, "GridText: Freeing off cached doc.\n"); HText_free((HText *)HTList_removeFirstObject(loaded_texts)); #if defined(VMS) && defined (VAXC) && !defined(__DECC) status = lib$stat_vm(&VMType, &VMTotal); - CTRACE(tfp, "GridText: VMTotal reduced to %d\n", VMTotal); + if (TRACE) + fprintf(stderr, "GridText: VMTotal reduced to %d\n", VMTotal); #endif /* VMS && VAXC && !__DECC */ } @@ -527,22 +533,11 @@ PUBLIC HText * HText_new ARGS1( underline_on = FALSE; /* reset */ bold_on = FALSE; -#ifdef DISP_PARTIAL - /* - * By this function we create HText object and set new Lines counter - * so we may start displaying the document while downloading. - LP - */ - if (display_partial) - NumOfLines_partial = 0; /* enable HTDisplayPartial() */ -#endif - - CTRACE(tfp, "GridText: start HText_new\n"); - return self; } -/* Creation Method 2 -** --------------- +/* Creation Method 2 +** --------------- ** ** Stream is assumed open and left open. */ @@ -578,9 +573,9 @@ PUBLIC void HText_free ARGS1( l->prev->next = l->next; /* Unlink l */ self->last_line = l->prev; if (l != self->last_line) { - FREE(l); + FREE(l); } else { - free(l); + free(l); } } if (l == self->last_line) { /* empty */ @@ -758,9 +753,9 @@ PRIVATE int display_line ARGS2( #define CStyle line->styles[current_style] while (current_style < line->numstyles && - i >= (int) (CStyle.horizpos + line->offset + 1)) + i >= CStyle.horizpos + line->offset + 1) { - LynxChangeStyle (CStyle.style,CStyle.direction,CStyle.previous); + (void) LynxChangeStyle (CStyle.style,CStyle.direction,CStyle.previous); current_style++; } #endif @@ -768,7 +763,7 @@ PRIVATE int display_line ARGS2( #ifndef USE_COLOR_STYLE case LY_UNDERLINE_START_CHAR: - if (dump_output_immediately && use_underscore) { + if (dump_output_immediately && use_underscore) { addch('_'); i++; } else { @@ -777,7 +772,7 @@ PRIVATE int display_line ARGS2( break; case LY_UNDERLINE_END_CHAR: - if (dump_output_immediately && use_underscore) { + if (dump_output_immediately && use_underscore) { addch('_'); i++; } else { @@ -792,15 +787,10 @@ PRIVATE int display_line ARGS2( case LY_BOLD_END_CHAR: stop_bold (); break; - #endif - case LY_SOFT_NEWLINE: - if (!dump_output_immediately) - addch('+'); - break; case LY_SOFT_HYPHEN: - if (*data != '\0' || + if (*data != '\0' || isspace((unsigned char)LastDisplayChar) || LastDisplayChar == '-') { /* @@ -894,7 +884,7 @@ PRIVATE int display_line ARGS2( #else while (current_style < line->numstyles) { - LynxChangeStyle (CStyle.style, CStyle.direction, CStyle.previous); + (void) LynxChangeStyle (CStyle.style, CStyle.direction, CStyle.previous); current_style++; } #undef CStyle @@ -964,7 +954,7 @@ PRIVATE void display_title ARGS1( sprintf(percent, " (p%d of %d)", ((text->top_of_screen >= start_of_last_page) ? total_pages : - ((text->top_of_screen + display_lines)/(display_lines))), + ((text->top_of_screen + display_lines)/(display_lines))), total_pages); } else { percent[0] = '\0'; /* Null string */ @@ -979,13 +969,13 @@ PRIVATE void display_title ARGS1( if (*title && (tmp = (unsigned char *)calloc(1, (strlen(title) + 1)))) { if (kanji_code == EUC) { - TO_EUC((unsigned char *)title, tmp); + TO_EUC((unsigned char *)title, tmp); } else if (kanji_code == SJIS) { - TO_SJIS((unsigned char *)title, tmp); + TO_SJIS((unsigned char *)title, tmp); } else { - for (i = 0, j = 0; title[i]; i++) { + for (i = 0, j = 0; title[i]; i++) { if (title[i] != '\033') { - tmp[j++] = title[i]; + tmp[j++] = title[i]; } } tmp[j] = '\0'; @@ -1100,7 +1090,7 @@ PRIVATE void display_page ARGS3( #else assert(line->next != NULL); #endif /* !VMS */ - } /* Loop */ + } if (LYlowest_eightbit[current_char_set] <= 255 && (current_char_set != charset_last_displayed) && @@ -1330,7 +1320,7 @@ PRIVATE void display_page ARGS3( * in it. - FM */ move((i + 2), 0); - } /* end while */ + } #endif /* FANCY CURSES || USE_SLANG */ /* @@ -1349,8 +1339,8 @@ PRIVATE void display_page ARGS3( } display_flag = TRUE; line = line->next; - } /* end of "Verify and display each line." loop */ - } /* end "Output the page." */ + } + } text->next_line = line; /* Line after screen */ text->stale = NO; /* Display is up-to-date */ @@ -1387,17 +1377,17 @@ PRIVATE void display_page ARGS3( * Memory leak fixed 05-27-94 * Garrett Arch Blythe */ - auto char *cp_AnchorAddress = NULL; + auto char *cp_AnchorAddress = NULL; if (traversal) - cp_AnchorAddress = stub_HTAnchor_address(link_dest); + cp_AnchorAddress = stub_HTAnchor_address(link_dest); else { #ifndef DONT_TRACK_INTERNAL_LINKS if (Anchor_ptr->link_type == INTERNAL_LINK_ANCHOR) { link_dest_intl = HTAnchor_followTypedLink( (HTAnchor *)Anchor_ptr->anchor, LINK_INTERNAL); if (link_dest_intl && link_dest_intl != link_dest) { - - CTRACE(tfp, + if (TRACE) + fprintf(stderr, "display_page: unexpected typed link to %s!\n", link_dest_intl->parent->address); link_dest_intl = NULL; @@ -1428,7 +1418,7 @@ PRIVATE void display_page ARGS3( links[nlinks].target = empty_string; links[nlinks].form = NULL; - nlinks++; + nlinks++; display_flag = TRUE; } else if (Anchor_ptr->link_type == INPUT_ANCHOR @@ -1477,7 +1467,7 @@ PRIVATE void display_page ARGS3( links[nlinks].hightext2_offset = 0; nlinks++; - /* + /* * Bold the link after incrementing nlinks. */ highlight(OFF, (nlinks - 1), target); @@ -1488,8 +1478,9 @@ PRIVATE void display_page ARGS3( /* * Not showing anchor. */ - if (Anchor_ptr->hightext && *Anchor_ptr->hightext) - CTRACE(tfp, + if (TRACE && + Anchor_ptr->hightext && *Anchor_ptr->hightext) + fprintf(stderr, "\nGridText: Not showing link, hightext=%s\n", Anchor_ptr->hightext); } @@ -1507,12 +1498,14 @@ PRIVATE void display_page ARGS3( * to use half-page or two-line scrolling. - FM */ if (LYCursesON) { - HTAlert(MAXLINKS_REACHED); + _statusline(MAXLINKS_REACHED); + sleep(AlertSecs); } - CTRACE(tfp, "\ndisplay_page: MAXLINKS reached.\n"); + if (TRACE) + fprintf(stderr, "\ndisplay_page: MAXLINKS reached.\n"); break; } - } /* end of loop "Add the anchors to Lynx structures." */ + } /* * Free any un-reallocated links[] entries @@ -1540,7 +1533,7 @@ PRIVATE void display_page ARGS3( addstr("\n Document is empty"); } - if (HTCJK != NOCJK || text->T.output_utf8) { + if (HTCJK != NOCJK || text->T.output_utf8 || TRACE) { /* * For non-multibyte curses. */ @@ -1586,7 +1579,7 @@ PUBLIC void HText_beginAppend ARGS1( PRIVATE void split_line ARGS2( HText *, text, - unsigned, split) + int, split) { HTStyle * style = text->style; HTLine * temp; @@ -1608,18 +1601,15 @@ PRIVATE void split_line ARGS2( HTLine * previous = text->last_line; int ctrl_chars_on_previous_line = 0; char * cp; - /* can't wrap in middle of multibyte sequences, so allocate 2 extra */ - HTLine * line = (HTLine *)LY_CALLOC(1, LINE_SIZE(MAX_LINE)+2); + HTLine * line = (HTLine *)LY_CALLOC(1, LINE_SIZE(MAX_LINE)); if (line == NULL) outofmem(__FILE__, "split_line_1"); ctrl_chars_on_this_line = 0; /*reset since we are going to a new line*/ text->LastChar = ' '; -#ifdef DEBUG_APPCH - CTRACE(tfp,"GridText: split_line(%p,%d) called\n", text, split); - CTRACE(tfp," bold_on=%d, underline_on=%d\n", bold_on, underline_on); -#endif + if (TRACE) + fprintf(stderr,"GridText: split_line called\n"); text->Lines++; @@ -1706,8 +1696,8 @@ PRIVATE void split_line ARGS2( } } if (previous->numstyles > 0 && previous->styles[LastStyle].direction) { - - CTRACE(tfp, "%s\n%s%s\n", + if (TRACE) + fprintf(stderr, "%s\n%s%s\n", "........... Too many character styles on line:", "........... ", previous->data); } @@ -1722,7 +1712,7 @@ PRIVATE void split_line ARGS2( line->styles[0].horizpos = 0xffffffff; if (previous->numstyles == 0) previous->styles[0].horizpos = 0xffffffff; -#endif /*USE_COLOR_STYLE*/ +#endif previous->next = line; text->last_line = line; line->size = 0; @@ -1753,8 +1743,8 @@ PRIVATE void split_line ARGS2( */ if (split > 0) { /* Delete space at "split" splitting line */ char *p, *prevdata = previous->data, *linedata = line->data; - unsigned plen; - unsigned i; + unsigned int plen; + int i; /* * Split the line. - FM @@ -1781,42 +1771,38 @@ PRIVATE void split_line ARGS2( * Make sure our global flag is correct. - FM */ underline_on = NO; - if (split) { - for (i = (split-1); i != 0; i--) { - if (prevdata[i] == LY_UNDERLINE_END_CHAR) { - break; - } - if (prevdata[i] == LY_UNDERLINE_START_CHAR) { - underline_on = YES; - break; - } + for (i = (split-1); i >= 0; i--) { + if (prevdata[i] == LY_UNDERLINE_END_CHAR) { + break; + } + if (prevdata[i] == LY_UNDERLINE_START_CHAR) { + underline_on = YES; + break; } } /* * Act on the global flag if set above. - FM */ if (underline_on && *p != LY_UNDERLINE_END_CHAR) { - linedata[line->size++] = LY_UNDERLINE_START_CHAR; + linedata[line->size++] = LY_UNDERLINE_START_CHAR; linedata[line->size] = '\0'; ctrl_chars_on_this_line++; SpecialAttrChars++; } - if (plen) { - for (i = (plen - 1); i != 0; i--) { - if (p[i] == LY_UNDERLINE_START_CHAR) { - underline_on = YES; - break; - } - if (p[i] == LY_UNDERLINE_END_CHAR) { - underline_on = NO; - break; - } + for (i = (plen - 1); i >= 0; i--) { + if (p[i] == LY_UNDERLINE_START_CHAR) { + underline_on = YES; + break; } - for (i = (plen - 1); i != 0; i--) { - if (p[i] == LY_UNDERLINE_START_CHAR || - p[i] == LY_UNDERLINE_END_CHAR) { - ctrl_chars_on_this_line++; - } + if (p[i] == LY_UNDERLINE_END_CHAR) { + underline_on = NO; + break; + } + } + for (i = (plen - 1); i >= 0; i--) { + if (p[i] == LY_UNDERLINE_START_CHAR || + p[i] == LY_UNDERLINE_END_CHAR) { + ctrl_chars_on_this_line++; } } } @@ -1826,15 +1812,13 @@ PRIVATE void split_line ARGS2( * sure that our global flag is correct. - FM */ bold_on = NO; - if (split) { - for (i = (split - 1); i != 0; i--) { - if (prevdata[i] == LY_BOLD_END_CHAR) { - break; - } - if (prevdata[i] == LY_BOLD_START_CHAR) { - bold_on = YES; - break; - } + for (i = (split - 1); i >= 0; i--) { + if (prevdata[i] == LY_BOLD_END_CHAR) { + break; + } + if (prevdata[i] == LY_BOLD_START_CHAR) { + bold_on = YES; + break; } } /* @@ -1845,29 +1829,26 @@ PRIVATE void split_line ARGS2( linedata[line->size] = '\0'; ctrl_chars_on_this_line++; SpecialAttrChars++;; - } else - bold_on = OFF; - if (plen) { - for (i = (plen - 1); i != 0; i--) { - if (p[i] == LY_BOLD_START_CHAR) { - bold_on = YES; - break; - } - if (p[i] == LY_BOLD_END_CHAR) { - bold_on = NO; - break; - } + } + for (i = (plen - 1); i >= 0; i--) { + if (p[i] == LY_BOLD_START_CHAR) { + bold_on = YES; + break; } - for (i = (plen - 1); i != 0; i--) { - if (p[i] == LY_BOLD_START_CHAR || - p[i] == LY_BOLD_END_CHAR || - IS_UTF_EXTRA(p[i]) || - p[i] == LY_SOFT_HYPHEN) { - ctrl_chars_on_this_line++; - } - if (p[i] == LY_SOFT_HYPHEN && text->permissible_split < i) { - text->permissible_split = i + 1; - } + if (p[i] == LY_BOLD_END_CHAR) { + bold_on = NO; + break; + } + } + for (i = (plen - 1); i >= 0; i--) { + if (p[i] == LY_BOLD_START_CHAR || + p[i] == LY_BOLD_END_CHAR || + IS_UTF_EXTRA(p[i]) || + p[i] == LY_SOFT_HYPHEN) { + ctrl_chars_on_this_line++; + } + if (p[i] == LY_SOFT_HYPHEN && text->permissible_split < i) { + text->permissible_split = i + 1; } } @@ -1950,15 +1931,15 @@ PRIVATE void split_line ARGS2( if (split > 0) { for (a = text->first_anchor; a; a = a->next) { if (a->line_num == CurLine) { - if ((unsigned)a->line_pos >= split) { + if (a->line_pos >= split) { a->start += (1 + SpecialAttrChars - HeadTrim - TailTrim); a->line_pos -= (split - SpecialAttrChars + HeadTrim); a->line_num = text->Lines; } else if ((a->link_type & HYPERTEXT_ANCHOR) && - (unsigned)(a->line_pos + a->extent) >= split) { + (a->line_pos + a->extent) >= split) { a->extent -= (TailTrim + HeadTrim); if (a->extent < 0) { - a->extent = 0; + a->extent = 0; } } } @@ -1981,7 +1962,7 @@ PRIVATE void blank_lines ARGS2( while ((line != text->last_line) && (HText_TrueLineSize(line, text, IgnoreSpaces) == 0)) { if (newlines == 0) - break; + break; newlines--; /* Don't bother: already blank */ line = line->prev; } @@ -2024,8 +2005,8 @@ PUBLIC void HText_setStyle ARGS2( return; /* Safety */ after = text->style->spaceAfter; before = style->spaceBefore; - - CTRACE(tfp, "GridText: Change to style %s\n", style->name); + if (TRACE) + fprintf(stderr, "GridText: Change to style %s\n", style->name); blank_lines (text, ((after > before) ? after : before)); @@ -2043,49 +2024,6 @@ PUBLIC void HText_appendCharacter ARGS2( HTStyle * style; int indent; -#ifdef DEBUG_APPCH - if (TRACE) { - char * special = NULL; /* make trace a little more readable */ - switch(ch) { - case HT_NON_BREAK_SPACE: - special = "HT_NON_BREAK_SPACE"; - break; - case HT_EM_SPACE: - special = "HT_EM_SPACE"; - break; - case LY_UNDERLINE_START_CHAR: - special = "LY_UNDERLINE_START_CHAR"; - break; - case LY_UNDERLINE_END_CHAR: - special = "LY_UNDERLINE_END_CHAR"; - break; - case LY_BOLD_START_CHAR: - special = "LY_BOLD_START_CHAR"; - break; - case LY_BOLD_END_CHAR: - special = "LY_BOLD_END_CHAR"; - break; - case LY_SOFT_HYPHEN: - special = "LY_SOFT_HYPHEN"; - break; - case LY_SOFT_NEWLINE: - special = "LY_SOFT_NEWLINE"; - break; - default: - special = NULL; - break; - } - - if (special != NULL) { - CTRACE(tfp, "add(%s %d special char) %d/%d\n", special, ch, - HTisDocumentSource(), HTOutputFormat != WWW_SOURCE); - } else { - CTRACE(tfp, "add(%c) %d/%d\n", ch, - HTisDocumentSource(), HTOutputFormat != WWW_SOURCE); - } - } /* trace only */ -#endif /* DEBUG_APPCH */ - /* * Make sure we don't crash on NULLs. */ @@ -2129,11 +2067,19 @@ PUBLIC void HText_appendCharacter ARGS2( !text->T.transp && !text->T.output_utf8 && (unsigned char)ch < LYlowest_eightbit[current_char_set]) return; -#endif /* !USE_SLANG */ +#endif /* USE_SLANG */ if ((unsigned char)ch == 155 && HTCJK == NOCJK) { /* octal 233 */ if (!HTPassHighCtrlRaw && !text->T.transp && !text->T.output_utf8 && - (155 < LYlowest_eightbit[current_char_set])) { + (155 < LYlowest_eightbit[current_char_set]) && + strncmp(LYchar_set_names[current_char_set], + "DosLatin1 (cp850)", 17) && + strncmp(LYchar_set_names[current_char_set], + "DosLatinUS (cp437)", 18) && + strncmp(LYchar_set_names[current_char_set], + "Macintosh (8 bit)", 17) && + strncmp(LYchar_set_names[current_char_set], + "NeXT character set", 18)) { return; } } @@ -2206,7 +2152,7 @@ PUBLIC void HText_appendCharacter ARGS2( /* * Can split here. - FM */ - text->permissible_split = text->last_line->size; + text->permissible_split = (int)text->last_line->size; text->state = S_text; return; } else if (ch == 'I') { @@ -2214,7 +2160,7 @@ PUBLIC void HText_appendCharacter ARGS2( /* * Can split here. - FM */ - text->permissible_split = text->last_line->size; + text->permissible_split = (int)text->last_line->size; return; } else { text->state = S_text; @@ -2243,7 +2189,7 @@ PUBLIC void HText_appendCharacter ARGS2( text->kanji_buf = '\0'; return; } else { - text->kanji_buf = '\216'; + text->kanji_buf = '\x8E'; ch |= 0200; } break; @@ -2254,7 +2200,7 @@ PUBLIC void HText_appendCharacter ARGS2( /* * JIS X0201 Kana in SJIS support. - by ASATAKU */ - if ((text->kcode == SJIS) && + if ((text->kcode == SJIS) && ((unsigned char)ch >= 0xA1) && ((unsigned char)ch <= 0xDF)) { unsigned char c = (unsigned char)ch; @@ -2263,15 +2209,15 @@ PUBLIC void HText_appendCharacter ARGS2( (unsigned char *)&kb, (unsigned char *)&c); ch = (char)c; - text->kanji_buf = kb; - } else { + text->kanji_buf = (char)kb; + } else { text->kanji_buf = ch; /* * Can split here. - FM */ - text->permissible_split = text->last_line->size; + text->permissible_split = (int)text->last_line->size; return; - } + } } } else { goto check_IgnoreExcess; @@ -2282,7 +2228,6 @@ PUBLIC void HText_appendCharacter ARGS2( if (IsSpecialAttrChar(ch)) { #ifndef USE_COLOR_STYLE - if (line->size >= (MAX_LINE-1)) return; if (ch == LY_UNDERLINE_START_CHAR) { line->data[line->size++] = LY_UNDERLINE_START_CHAR; line->data[line->size] = '\0'; @@ -2309,11 +2254,6 @@ PUBLIC void HText_appendCharacter ARGS2( bold_on = OFF; ctrl_chars_on_this_line++; return; - } else if (ch == LY_SOFT_NEWLINE) { - line->data[line->size++] = LY_SOFT_NEWLINE; - line->data[line->size] = '\0'; - ctrl_chars_on_this_line++; - return; } else if (ch == LY_SOFT_HYPHEN) { int i; @@ -2322,7 +2262,7 @@ PUBLIC void HText_appendCharacter ARGS2( * on the line, or if it is preceded by a space or * hyphen. - FM */ - if (line->size < 1 || text->permissible_split >= line->size) + if (line->size < 1 || text->permissible_split >= (int)line->size) return; for (i = (text->permissible_split + 1); line->data[i]; i++) { @@ -2406,24 +2346,23 @@ PUBLIC void HText_appendCharacter ARGS2( line->data[--line->size] = '\0'; ctrl_chars_on_this_line--; } - here = ((int)(line->size + line->offset) + indent) + here = (((int)line->size + (int)line->offset) + indent) - ctrl_chars_on_this_line; /* Consider special chars GAB */ if (style->tabs) { /* Use tab table */ for (Tab = style->tabs; Tab->position <= here; - Tab++) { + Tab++) if (!Tab->position) { new_line(text); return; } - } target = Tab->position; } else if (text->in_line_1) { /* Use 2nd indent */ if (here >= (int)style->leftIndent) { - new_line(text); /* wrap */ + new_line(text); /* wrap */ return; } else { - target = (int)style->leftIndent; + target = (int)style->leftIndent; } } else { /* Default tabs align with left indent mod 8 */ #ifdef DEFAULT_TABS_8 @@ -2438,42 +2377,32 @@ PUBLIC void HText_appendCharacter ARGS2( if (target > (LYcols-1) - (int)style->rightIndent && HTOutputFormat != WWW_SOURCE) { new_line(text); + return; } else { /* * Can split here. - FM */ - text->permissible_split = line->size; + text->permissible_split = (int)line->size; if (line->size == 0) { - line->offset = line->offset + target - here; + line->offset = line->offset + target - here; } else { - for (; here<target; here++) { + for (; here<target; here++) { /* Put character into line */ line->data[line->size++] = ' '; line->data[line->size] = '\0'; - } + } } + return; } - return; + /*NOTREACHED*/ } /* if tab */ - else { - /* - * If we're displaying document source, wrap long lines to keep all of - * the source visible. - */ - int target = (int)(line->offset + line->size); - if ((target >= (LYcols-1) - style->rightIndent) && - HTisDocumentSource()) { - new_line(text); - line = text->last_line; - HText_appendCharacter (text, LY_SOFT_NEWLINE); - } - } + if (ch == ' ') { /* * Can split here. - FM */ - text->permissible_split = text->last_line->size; + text->permissible_split = (int)text->last_line->size; /* * There are some pages written in * different kanji codes. - TA @@ -2594,10 +2523,7 @@ check_IgnoreExcess: /* * Can split here. - FM */ - text->permissible_split = text->last_line->size; - } - if (ch == LY_SOFT_NEWLINE) { - ctrl_chars_on_this_line++; + text->permissible_split = (int)text->last_line->size; } } } @@ -2680,7 +2606,7 @@ PUBLIC int HText_beginAnchor ARGS3( BOOL, underline, HTChildAnchor *, anc) { - char marker[32]; + char marker[16]; TextAnchor * a = (TextAnchor *) calloc(1, sizeof(*a)); @@ -2754,7 +2680,7 @@ PUBLIC void HText_endAnchor ARGS2( } else { for (a = text->first_anchor; a; a = a->next) { if (a->number == number) { - break; + break; } } if (a == NULL) { @@ -2766,15 +2692,15 @@ PUBLIC void HText_endAnchor ARGS2( a = text->last_anchor; } } - - CTRACE(tfp, "HText_endAnchor: number:%d link_type:%d\n", + if (TRACE) + fprintf(stderr, "HText_endAnchor: number:%d link_type:%d\n", a->number, a->link_type); if (a->link_type == INPUT_ANCHOR) { /* * Shouldn't happen, but put test here anyway to be safe. - LE */ - - CTRACE(tfp, + if (TRACE) + fprintf(stderr, "HText_endAnchor: internal error: last anchor was input field!\n"); return; } @@ -2818,7 +2744,7 @@ PUBLIC void HText_endAnchor ARGS2( j = (last->size - i); while (j < last->size) { if (!IsSpecialAttrChar(last->data[j]) && - !isspace((unsigned char)last->data[j]) && + !isspace((unsigned char)last->data[j]) && last->data[j] != HT_NON_BREAK_SPACE && last->data[j] != HT_EM_SPACE) break; @@ -2854,20 +2780,20 @@ PUBLIC void HText_endAnchor ARGS2( while (i == 0 && a->extent > CurBlankExtent) { j = prev->size - a->extent + CurBlankExtent; if (j < 0) { - /* + /* * The anchor starts on a preceding line, * so check all of this line. - FM */ - j = 0; + j = 0; i = prev->size; } else { - /* + /* * The anchor starts on this line. - FM */ - i = a->extent - CurBlankExtent; + i = a->extent - CurBlankExtent; } while (j < prev->size) { - if (!IsSpecialAttrChar(prev->data[j]) && + if (!IsSpecialAttrChar(prev->data[j]) && !isspace((unsigned char)prev->data[j]) && prev->data[j] != HT_NON_BREAK_SPACE && prev->data[j] != HT_EM_SPACE) @@ -2958,15 +2884,15 @@ PUBLIC void HText_endAnchor ARGS2( j--; NumSize++; while (j >= 0 && isdigit((unsigned char)start->data[j])) { - j--; + j--; NumSize++; } while (j < 0) { - j++; + j++; NumSize--; } if (start->data[j] == '[') { - /* + /* * The numbered bracket is entirely * on this line. - FM */ @@ -2980,16 +2906,21 @@ PUBLIC void HText_endAnchor ARGS2( anc->start -= NumSize; anc->line_pos -= NumSize; } - start->size = j; + start->size = j; start->data[j++] = '\0'; while (j < k) start->data[j++] = '\0'; } else if (prev && prev->size > 1) { k = (i + 1); j = (prev->size - 1); - while ((j >= 0) && IsSpecialAttrChar(prev->data[j])) + while ((j >= 0) && + (prev->data[j] == LY_BOLD_START_CHAR || + prev->data[j] == LY_BOLD_END_CHAR || + prev->data[j] == LY_UNDERLINE_START_CHAR || + prev->data[j] == LY_UNDERLINE_END_CHAR || + prev->data[j] == LY_SOFT_HYPHEN)) j--; - i = (j + 1); + i = (j + 1); while (j >= 0 && isdigit((unsigned char)prev->data[j])) { j--; @@ -3020,9 +2951,9 @@ PUBLIC void HText_endAnchor ARGS2( j = 0; i = k; while (k < start->size) - start->data[j++] = start->data[k++]; + start->data[j++] = start->data[k++]; if (start != last) - text->chars -= i; + text->chars -= i; for (anc = a; anc; anc = anc->next) { anc->start -= i; anc->line_pos -= i; @@ -3030,7 +2961,7 @@ PUBLIC void HText_endAnchor ARGS2( start->size = j; start->data[j++] = '\0'; while (j < k) - start->data[j++] = '\0'; + start->data[j++] = '\0'; } else { /* * Shucks! We didn't find the @@ -3047,17 +2978,22 @@ PUBLIC void HText_endAnchor ARGS2( } } else if (prev && prev->size > 2) { j = (prev->size - 1); - while ((j >= 0) && IsSpecialAttrChar(prev->data[j])) - j--; + while ((j >= 0) && + (prev->data[j] == LY_BOLD_START_CHAR || + prev->data[j] == LY_BOLD_END_CHAR || + prev->data[j] == LY_UNDERLINE_START_CHAR || + prev->data[j] == LY_UNDERLINE_END_CHAR || + prev->data[j] == LY_SOFT_HYPHEN)) + j--; if (j < 0) - j = 0; + j = 0; i = (j + 1); if ((j > 2) && - (prev->data[j] == ']' && + (prev->data[j] == ']' && isdigit((unsigned char)prev->data[j - 1]))) { - j--; + j--; NumSize++; - k = (j + 1); + k = (j + 1); while (j >= 0 && isdigit((unsigned char)prev->data[j])) { j--; @@ -3097,7 +3033,7 @@ PUBLIC void HText_endAnchor ARGS2( * Shucks! We didn't find the * numbered bracket. - FM */ - a->show_anchor = YES; + a->show_anchor = YES; } } else { /* @@ -3126,7 +3062,7 @@ PUBLIC void HText_endAnchor ARGS2( a->extent = 0; if (text->hiddenlinkflag != HIDDENLINKS_MERGE) { a->number = 0; - text->last_anchor_number--; + text->last_anchor_number--; HText_AddHiddenLink(text, a); } } else { @@ -3196,12 +3132,15 @@ PRIVATE void remove_special_attr_chars ARGS1( PUBLIC void HText_endAppend ARGS1( HText *, text) { + int cur_line, cur_char, cur_shift, len; + TextAnchor *anchor_ptr; HTLine *line_ptr; + unsigned char ch; if (!text) return; - - CTRACE(tfp,"Gridtext: Entering HText_endAppend\n"); + if (TRACE) + fprintf(stderr,"Gridtext: Entering HText_endAppend\n"); /* * Create a blank line at the bottom. @@ -3222,6 +3161,9 @@ PUBLIC void HText_endAppend ARGS1( * Get the first line. */ line_ptr = text->last_line->next; + cur_char = line_ptr->size; + cur_line = 0; + cur_shift = 0; /* * Remove the blank lines at the end of document. @@ -3229,8 +3171,8 @@ PUBLIC void HText_endAppend ARGS1( while (text->last_line->data[0] == '\0' && text->Lines > 2) { HTLine *next_to_the_last_line = text->last_line->prev; - - CTRACE(tfp, "GridText: Removing bottom blank line: %s\n", + if (TRACE) + fprintf(stderr, "GridText: Removing bottom blank line: %s\n", text->last_line->data); /* * line_ptr points to the first line. @@ -3240,58 +3182,18 @@ PUBLIC void HText_endAppend ARGS1( FREE(text->last_line); text->last_line = next_to_the_last_line; text->Lines--; - CTRACE(tfp, "GridText: New bottom line: %s\n", +#ifdef NOTUSED_BAD_FOR_SCREEN + if (TRACE) { + fprintf(stderr, "GridText: New bottom line: %s\n", text->last_line->data); + } +#endif } /* * Fix up the anchor structure values and * create the hightext strings. - FM */ - HText_trimHightext(text, FALSE); -} - - -/* -** This function gets the hightext from the text by finding the char -** position, and brings the anchors in line with the text by adding the text -** offset to each of the anchors. -** -** `Forms input' fields cannot be displayed properly without this function -** to be invoked (detected in display_partial mode). -** -** (BOOLEAN value allow us to disable annoying repeated trace messages -** for display_partial mode). -*/ -PUBLIC void HText_trimHightext ARGS2( - HText *, text, - BOOLEAN, disable_trace) -{ - int cur_line, cur_char, cur_shift; - TextAnchor *anchor_ptr; - HTLine *line_ptr; - unsigned char ch; - - if (!text) - return; - - CTRACE(tfp,"Gridtext: Entering HText_trimHightext\n"); - - if (disable_trace) - CTRACE(tfp,"HText_trimHightext: trace disabled in display_partial mode\n"); - - /* - * Get the first line. - */ - line_ptr = text->last_line->next; - cur_char = line_ptr->size; - cur_line = 0; - cur_shift = 0; - - /* - * Fix up the anchor structure values and - * create the hightext strings. - FM - */ for (anchor_ptr = text->first_anchor; anchor_ptr; anchor_ptr=anchor_ptr->next) { re_parse: @@ -3312,9 +3214,8 @@ re_parse: } if (anchor_ptr->line_pos < 0) anchor_ptr->line_pos = 0; - - if (!disable_trace) - CTRACE(tfp, "Gridtext: Anchor found on line:%d col:%d\n", + if (TRACE) + fprintf(stderr, "Gridtext: Anchor found on line:%d col:%d\n", cur_line, anchor_ptr->line_pos); /* @@ -3324,7 +3225,7 @@ re_parse: if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) { ch = (unsigned char)line_ptr->data[anchor_ptr->line_pos]; while (isspace(ch) || - IsSpecialAttrChar(ch)) { + IsSpecialAttrChar(ch)) { anchor_ptr->line_pos++; anchor_ptr->extent--; cur_shift++; @@ -3334,23 +3235,29 @@ re_parse: if (anchor_ptr->extent < 0) { anchor_ptr->extent = 0; } - - if (!disable_trace) - CTRACE(tfp, "anchor text: '%s'\n", - line_ptr->data); +#ifdef NOTUSED_BAD_FOR_SCREEN + if (TRACE) + fprintf(stderr, "anchor text: '%s' pos: %d\n", + line_ptr->data, anchor_ptr->line_pos); +#endif /* * If the link begins with an end of line and we have more * lines, then start the highlighting on the next line. - FM */ - if ((unsigned)anchor_ptr->line_pos >= strlen(line_ptr->data) && + if (anchor_ptr->line_pos >= strlen(line_ptr->data) && cur_line < text->Lines) { anchor_ptr->start += (cur_shift + 1); cur_shift = 0; - CTRACE(tfp, "found anchor at end of line\n"); + if (TRACE) + fprintf(stderr, "found anchor at end of line\n"); goto re_parse; } cur_shift = 0; - +#ifdef NOTUSED_BAD_FOR_SCREEN + if (TRACE) + fprintf(stderr, "anchor text: '%s' pos: %d\n", + line_ptr->data, anchor_ptr->line_pos); +#endif /* * Copy the link name into the data structure. */ @@ -3367,7 +3274,7 @@ re_parse: * If true the anchor extends over two lines, * copy that into the data structure. */ - if ((unsigned)anchor_ptr->extent > strlen(anchor_ptr->hightext)) { + if (anchor_ptr->extent > strlen(anchor_ptr->hightext)) { HTLine *line_ptr2 = line_ptr->next; /* * Double check that we have a line pointer, @@ -3378,11 +3285,19 @@ re_parse: line_ptr2->data, (anchor_ptr->extent - strlen(anchor_ptr->hightext))); - anchor_ptr->hightext2offset = line_ptr2->offset; + anchor_ptr->hightext2offset = line_ptr2->offset; remove_special_attr_chars(anchor_ptr->hightext2); if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) { - LYTrimTrailing(anchor_ptr->hightext2); - if (anchor_ptr->hightext2[0] == '\0') { + if ((len = strlen(anchor_ptr->hightext2)) > 0) { + len--; + while (len >= 0 && + isspace((unsigned char) + anchor_ptr->hightext2[len])) { + anchor_ptr->hightext2[len] = '\0'; + len--; + } + } + if (len <= 0 && anchor_ptr->hightext2[0] == '\0') { FREE(anchor_ptr->hightext2); anchor_ptr->hightext2offset = 0; } @@ -3391,7 +3306,14 @@ re_parse: } remove_special_attr_chars(anchor_ptr->hightext); if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) { - LYTrimTrailing(anchor_ptr->hightext); + if ((len = strlen(anchor_ptr->hightext)) > 0) { + len--; + while (len >= 0 && + isspace((unsigned char)anchor_ptr->hightext[len])) { + anchor_ptr->hightext[len] = '\0'; + len--; + } + } } /* @@ -3412,10 +3334,10 @@ re_parse: */ anchor_ptr->line_pos += line_ptr->offset; anchor_ptr->line_num = cur_line; - - if (!disable_trace) - CTRACE(tfp, "GridText: add link on line %d col %d in HText_trimHightext\n", - cur_line, anchor_ptr->line_pos); + if (TRACE) + fprintf(stderr, + "GridText: adding link on line %d in HText_endAppend\n", + cur_line); /* * If this is the last anchor, we're done! @@ -3426,12 +3348,12 @@ re_parse: } -/* Dump diagnostics to tfp +/* Dump diagnostics to stderr */ PUBLIC void HText_dump ARGS1( HText *, text GCC_UNUSED) { - fprintf(tfp, "HText: Dump called\n"); + fprintf(stderr, "HText: Dump called\n"); } @@ -3487,7 +3409,7 @@ PUBLIC void HText_FormDescNumber ARGS2( for (a = HTMainText->first_anchor; a; a = a->next) { if (a->number == number) { if (!(a->input_field && a->input_field->type)) { - *desc = "unknown field or link"; + *desc = "unknown field or link"; return; } break; @@ -3630,7 +3552,7 @@ PUBLIC int HTGetLinkInfo ARGS6( */ return(NO); } - if (anchors_this_screen > 0 && + if (anchors_this_screen > 0 && anchors_this_screen <= nlinks && a->line_num >= HTMainText->top_of_screen && a->line_num < HTMainText->top_of_screen+(display_lines)) { @@ -3642,7 +3564,7 @@ PUBLIC int HTGetLinkInfo ARGS6( */ *go_line = HTMainText->top_of_screen; if (linknum) - *linknum = anchors_this_screen - 1; + *linknum = anchors_this_screen - 1; } else { /* * if the requested anchor is not within the currently @@ -3666,13 +3588,13 @@ PUBLIC int HTGetLinkInfo ARGS6( max_offset = display_lines - 1; *go_line = prev_anchor_line - max_offset; if (*go_line <= prev_prev_anchor_line) - *go_line = prev_prev_anchor_line + 1; + *go_line = prev_prev_anchor_line + 1; if (*go_line < 0) - *go_line = 0; + *go_line = 0; if (linknum) - *linknum = anchors_this_line - 1; - } - return(LINK_LINE_FOUND); + *linknum = anchors_this_line - 1; + } + return(LINK_LINE_FOUND); } else { *hightext= a->hightext; link_dest = HTAnchor_followMainLink((HTAnchor *)a->anchor); @@ -3686,8 +3608,9 @@ PUBLIC int HTGetLinkInfo ARGS6( link_dest_intl = HTAnchor_followTypedLink( (HTAnchor *)a->anchor, LINK_INTERNAL); if (link_dest_intl && link_dest_intl != link_dest) { - - CTRACE(tfp, "HTGetLinkInfo: unexpected typed link to %s!\n", + if (TRACE) + fprintf(stderr, + "HTGetLinkInfo: unexpected typed link to %s!\n", link_dest_intl->parent->address); link_dest_intl = NULL; } @@ -3809,17 +3732,17 @@ PUBLIC int HText_getNumOfLines NOARGS * HText_getTitle returns the title of the * current document. */ -PUBLIC CONST char * HText_getTitle NOARGS +PUBLIC char * HText_getTitle NOARGS { return(HTMainText ? - HTAnchor_title(HTMainText->node_anchor) : 0); + (char *) HTAnchor_title(HTMainText->node_anchor) : NULL); } #ifdef USE_HASH -PUBLIC CONST char *HText_getStyle NOARGS +PUBLIC char *HText_getStyle NOARGS { return(HTMainText ? - HTAnchor_style(HTMainText->node_anchor) : 0); + (char *) HTAnchor_style(HTMainText->node_anchor) : NULL); } #endif @@ -3828,10 +3751,10 @@ PUBLIC CONST char *HText_getStyle NOARGS * document (normally derived from a Content-Disposition header with * attachment; filename=name.suffix). - FM */ -PUBLIC CONST char * HText_getSugFname NOARGS +PUBLIC char * HText_getSugFname NOARGS { return(HTMainText ? - HTAnchor_SugFname(HTMainText->node_anchor) : 0); + (char *) HTAnchor_SugFname(HTMainText->node_anchor) : NULL); } /* @@ -3924,12 +3847,12 @@ PUBLIC void HTCheckFnameForCompression ARGS3( !strcasecomp(dot, ".gz") || !strcasecomp(dot, ".Z")) { if (!method) { - /* + /* * It has a suffix which signifies a gzipped * or compressed file for us, but the anchor * claims otherwise, so tweak the suffix. - FM */ - cp = (dot + 1); + cp = (dot + 1); *dot = '\0'; if (!strcasecomp(cp, "tgz")) { StrAllocCat(*fname, ".tar"); @@ -3942,7 +3865,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( if (!strcasecomp(cp, "-gz") || !strcasecomp(cp, "_gz")) { if (!method) { - /* + /* * It has a tail which signifies a gzipped * file for us, but the anchor claims otherwise, * so tweak the suffix. - FM @@ -3972,7 +3895,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( if (!strcasecomp(cp, "-Z") || !strcasecomp(cp, "_Z")) { if (!method) { - /* + /* * It has a tail which signifies a compressed * file for us, but the anchor claims otherwise, * so tweak the suffix. - FM @@ -4029,69 +3952,44 @@ PUBLIC void HTCheckFnameForCompression ARGS3( * HText_getLastModified returns the Last-Modified header * if available, for the current document. - FM */ -PUBLIC CONST char * HText_getLastModified NOARGS +PUBLIC char * HText_getLastModified NOARGS { return(HTMainText ? - HTAnchor_last_modified(HTMainText->node_anchor) : 0); + (char *) HTAnchor_last_modified(HTMainText->node_anchor) : NULL); } /* * HText_getDate returns the Date header * if available, for the current document. - FM */ -PUBLIC CONST char * HText_getDate NOARGS +PUBLIC char * HText_getDate NOARGS { return(HTMainText ? - HTAnchor_date(HTMainText->node_anchor) : 0); + (char *) HTAnchor_date(HTMainText->node_anchor) : NULL); } /* * HText_getServer returns the Server header * if available, for the current document. - FM */ -PUBLIC CONST char * HText_getServer NOARGS +PUBLIC char * HText_getServer NOARGS { return(HTMainText ? - HTAnchor_server(HTMainText->node_anchor) : 0); + (char *)HTAnchor_server(HTMainText->node_anchor) : NULL); } /* * HText_pageDisplay displays a screen of text - * starting from the line 'line_num'-1. - * This is the primary call for lynx. + * starting from the line 'line_num'-1 + * this is the primary call for lynx */ PUBLIC void HText_pageDisplay ARGS2( int, line_num, char *, target) { - CTRACE(tfp, "GridText: HText_pageDisplay at line %d started\n", line_num); - -#ifdef DISP_PARTIAL - if (display_partial && detected_forms_input_partial) { - /* - ** Garbage is reported from forms input fields in incremental mode. - ** So we start HText_trimHightext() to forget this side effect. - ** This function was split-out from HText_endAppend(). - ** It may not be the best solution but it works. - LP - ** (TRUE = to disable annoying repeated trace messages) - ** - ** Side effect is reported from multiply call of HText_trimHightext. - */ - HText_trimHightext(HTMainText, TRUE); - } - detected_forms_input_partial = FALSE; -#endif - display_page(HTMainText, line_num-1, target); -#ifdef DISP_PARTIAL - if (display_partial && debug_display_partial) - sleep(MessageSecs); -#endif - is_www_index = HTAnchor_isIndex(HTMainAnchor); - - CTRACE(tfp, "GridText: HText_pageDisplay finished\n"); } /* @@ -4168,8 +4066,7 @@ PUBLIC BOOL HText_canScrollDown NOARGS { HText * text = HTMainText; - return (text != 0) - && ((text->top_of_screen + display_lines) < text->Lines+1); + return ((text->top_of_screen + display_lines) < text->Lines+1); } /* Scroll actions @@ -4300,10 +4197,10 @@ PUBLIC BOOL HTFindPoundSelector ARGS1( if (a->anchor && a->anchor->tag) if (!strcmp(a->anchor->tag, selector)) { - www_search_result = a->line_num+1; - - CTRACE(tfp, - "HText: Selecting anchor [%d] at character %d, line %d\n", + www_search_result = a->line_num+1; + if (TRACE) + fprintf(stderr, + "HText: Selecting anchor [%d] at character %d, line %d\n", a->number, a->start, www_search_result); if (!strcmp(selector, LYToolbarName)) --www_search_result; @@ -4333,7 +4230,7 @@ PUBLIC BOOL HText_selectAnchor ARGS2( if (a->anchor == anchor) break; } if (!a) { - CTRACE(tfp, "HText: No such anchor in this text!\n"); + if (TRACE) fprintf(stderr, "HText: No such anchor in this text!\n"); return NO; } @@ -4344,14 +4241,14 @@ PUBLIC BOOL HText_selectAnchor ARGS2( { int l = line_for_char(text, a->start); - CTRACE(tfp, + if (TRACE) fprintf(stderr, "HText: Selecting anchor [%d] at character %d, line %d\n", a->number, a->start, l); if ( !text->stale && (l >= text->top_of_screen) && ( l < text->top_of_screen + display_lines+1)) - return YES; + return YES; www_search_result = l - (display_lines/3); /* put in global variable */ } @@ -4449,7 +4346,7 @@ PUBLIC HTAnchor * HText_referenceSelected ARGS1( PUBLIC int HText_getTopOfScreen NOARGS { HText * text = HTMainText; - return text != 0 ? text->top_of_screen : 0; + return text->top_of_screen; } PUBLIC int HText_getLines ARGS1( @@ -4526,7 +4423,7 @@ PUBLIC int do_www_search ARGS1( document *, doc) { char searchstring[256], temp[256], *cp, *tmpaddress = NULL; - int ch, recall; + int ch, recall, i; int QueryTotal; int QueryNum; BOOLEAN PreviousSearch = FALSE; @@ -4543,7 +4440,7 @@ PUBLIC int do_www_search ARGS1( strcpy(searchstring, ++cp); for (cp=searchstring; *cp; cp++) if (*cp == '+') - *cp = ' '; + *cp = ' '; HTUnEscape(searchstring); strcpy(temp, searchstring); /* @@ -4578,22 +4475,22 @@ get_query: *searchstring == '\0' || ch == UPARROW || ch == DNARROW) { if (recall && ch == UPARROW) { if (PreviousSearch) { - /* + /* * Use the second to last query in the list. - FM */ - QueryNum = 1; + QueryNum = 1; PreviousSearch = FALSE; } else { - /* + /* * Go back to the previous query in the list. - FM */ - QueryNum++; + QueryNum++; } if (QueryNum >= QueryTotal) - /* + /* * Roll around to the last query in the list. - FM */ - QueryNum = 0; + QueryNum = 0; if ((cp=(char *)HTList_objectAt(search_queries, QueryNum)) != NULL) { strcpy(searchstring, cp); @@ -4609,19 +4506,19 @@ get_query: } } else if (recall && ch == DNARROW) { if (PreviousSearch) { - /* + /* * Use the first query in the list. - FM */ - QueryNum = QueryTotal - 1; + QueryNum = QueryTotal - 1; PreviousSearch = FALSE; } else { - /* + /* * Advance to the next query in the list. - FM */ - QueryNum--; + QueryNum--; } if (QueryNum < 0) - /* + /* * Roll around to the first query in the list. - FM */ QueryNum = QueryTotal - 1; @@ -4643,25 +4540,37 @@ get_query: /* * Search cancelled. */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return(NULLFILE); } /* * Strip leaders and trailers. - FM */ - LYTrimLeading(searchstring); - if (!(*searchstring)) { - HTInfoMsg(CANCELLED); + cp = searchstring; + while (*cp && isspace((unsigned char)*cp)) + cp++; + if (!(*cp)) { + _statusline(CANCELLED); + sleep(InfoSecs); return(NULLFILE); } - LYTrimTrailing(searchstring); + if (cp > searchstring) { + for (i = 0; *cp; i++) + searchstring[i] = *cp++; + searchstring[i] = '\0'; + } + cp = searchstring + strlen(searchstring) - 1; + while ((cp > searchstring) && isspace((unsigned char)*cp)) + *cp-- = '\0'; /* * Don't resubmit the same query unintentionally. */ if (!LYforce_no_cache && 0 == strcmp(temp, searchstring)) { - HTUserMsg(USE_C_R_TO_RESUB_CUR_QUERY); + _statusline(USE_C_R_TO_RESUB_CUR_QUERY); + sleep(MessageSecs); return(NULLFILE); } @@ -4705,7 +4614,8 @@ get_query: StrAllocCopy(doc->address, cp_freeme); FREE(cp_freeme); - CTRACE(tfp,"\ndo_www_search: newfile: %s\n",doc->address); + if (TRACE) + fprintf(stderr,"\ndo_www_search: newfile: %s\n",doc->address); /* * Yah, the search succeeded. @@ -4734,7 +4644,6 @@ PUBLIC void print_wwwfile_to_fd ARGS2( int, is_reply) { register int i; - int first = TRUE; HTLine * line; #ifdef VMS extern BOOLEAN HadVMSInterrupt; @@ -4745,11 +4654,6 @@ PUBLIC void print_wwwfile_to_fd ARGS2( line = HTMainText->last_line->next; for (;; line = line->next) { - if (!first - && line->data[0] != LY_SOFT_NEWLINE) - fputc('\n',fp); - first = FALSE; - /* * Add news-style quotation if requested. - FM */ @@ -4757,7 +4661,7 @@ PUBLIC void print_wwwfile_to_fd ARGS2( fputc('>',fp); } - /* + /* * Add offset. */ for (i = 0; i < (int)line->offset; i++) { @@ -4769,13 +4673,14 @@ PUBLIC void print_wwwfile_to_fd ARGS2( */ for (i = 0; line->data[i] != '\0'; i++) { if (!IsSpecialAttrChar(line->data[i])) { - fputc(line->data[i], fp); + fputc(line->data[i],fp); } else if (line->data[i] == LY_SOFT_HYPHEN && line->data[i + 1] == '\0') { /* last char on line */ if (dump_output_immediately && LYRawMode && LYlowest_eightbit[current_char_set] <= 173 && - (LYCharSet_UC[current_char_set].enc == UCT_ENC_8859 || + (current_char_set == 0 || + LYCharSet_UC[current_char_set].enc == UCT_ENC_8859 || LYCharSet_UC[current_char_set].like8859 & UCT_R_8859SPECL)) { fputc(0xad, fp); /* the iso8859 byte for SHY */ @@ -4795,6 +4700,11 @@ PUBLIC void print_wwwfile_to_fd ARGS2( } } + /* + * Add the return. + */ + fputc('\n',fp); + if (line == HTMainText->last_line) break; @@ -4803,7 +4713,6 @@ PUBLIC void print_wwwfile_to_fd ARGS2( break; #endif /* VMS */ } - fputc('\n',fp); } @@ -4818,7 +4727,6 @@ PUBLIC void print_crawl_to_fd ARGS3( char *, thetitle) { register int i; - int first = TRUE; HTLine * line; #ifdef VMS extern BOOLEAN HadVMSInterrupt; @@ -4834,10 +4742,6 @@ PUBLIC void print_crawl_to_fd ARGS3( } for (;; line = line->next) { - if (!first - && line->data[0] != LY_SOFT_NEWLINE) - fputc('\n',fp); - first = FALSE; /* * Add offset. */ @@ -4851,26 +4755,31 @@ PUBLIC void print_crawl_to_fd ARGS3( for (i = 0; line->data[i] != '\0'; i++) { if (!IsSpecialAttrChar(line->data[i])) { fputc(line->data[i], fp); - } else if (line->data[i] == LY_SOFT_HYPHEN && - line->data[i + 1] == '\0') { /* last char on line */ - if (dump_output_immediately && - LYRawMode && - LYlowest_eightbit[current_char_set] <= 173 && - (LYCharSet_UC[current_char_set].enc == UCT_ENC_8859 || - LYCharSet_UC[current_char_set].like8859 & - UCT_R_8859SPECL)) { - fputc(0xad, fp); /* the iso8859 byte for SHY */ - } else { - fputc('-', fp); - } + } else if (line->data[i] == LY_SOFT_HYPHEN && + line->data[i + 1] == '\0') { /* last char on line */ + if (dump_output_immediately && + LYRawMode && + LYlowest_eightbit[current_char_set] <= 173 && + (current_char_set == 0 || + LYCharSet_UC[current_char_set].enc == UCT_ENC_8859 || + LYCharSet_UC[current_char_set].like8859 & + UCT_R_8859SPECL)) { + fputc(0xad, fp); /* the iso8859 byte for SHY */ + } else { + fputc('-', fp); + } } } + /* + * Add the return. + */ + fputc('\n',fp); + if (line == HTMainText->last_line) { break; } } - fputc('\n',fp); /* * Add the References list if appropriate @@ -5016,7 +4925,7 @@ PUBLIC void www_user_search ARGS3( if ((a->input_field != NULL && a->input_field->value != NULL) && a->input_field->type != F_HIDDEN_TYPE) { if (a->input_field->type == F_PASSWORD_TYPE) { - /* + /* * Check the actual, hidden password, and then * the displayed string. - FM */ @@ -5065,7 +4974,7 @@ PUBLIC void www_user_search ARGS3( /* * Search for checked or unchecked parens. - FM */ - if (a->input_field->num_value) { + if (a->input_field->num_value) { cp = checked_radio; } else { cp = unchecked_radio; @@ -5082,7 +4991,7 @@ PUBLIC void www_user_search ARGS3( * Search for checked or unchecked * square brackets. - FM */ - if (a->input_field->num_value) { + if (a->input_field->num_value) { cp = checked_box; } else { cp = unchecked_box; @@ -5095,7 +5004,7 @@ PUBLIC void www_user_search ARGS3( return; } } else { - /* + /* * Check the values intended for display. * May have been found already via the * hightext search, but make sure here @@ -5175,7 +5084,7 @@ PUBLIC void www_user_search ARGS3( if ((a->input_field != NULL && a->input_field->value != NULL) && a->input_field->type != F_HIDDEN_TYPE) { if (a->input_field->type == F_PASSWORD_TYPE) { - /* + /* * Check the actual, hidden password, and then * the displayed string. - FM */ @@ -5224,7 +5133,7 @@ PUBLIC void www_user_search ARGS3( /* * Search for checked or unchecked parens. - FM */ - if (a->input_field->num_value) { + if (a->input_field->num_value) { cp = checked_radio; } else { cp = unchecked_radio; @@ -5241,7 +5150,7 @@ PUBLIC void www_user_search ARGS3( * Search for checked or unchecked * square brackets. - FM */ - if (a->input_field->num_value) { + if (a->input_field->num_value) { cp = checked_box; } else { cp = unchecked_box; @@ -5254,7 +5163,7 @@ PUBLIC void www_user_search ARGS3( return; } } else { - /* + /* * Check the values intended for display. * May have been found already via the * hightext search, but make sure here @@ -5279,17 +5188,18 @@ PUBLIC void www_user_search ARGS3( } if (case_sensitive && LYno_attr_char_strstr(line->data, target)) { - tentative_result=count; + tentative_result=count; break; } else if (!case_sensitive && LYno_attr_char_case_strstr(line->data, target)) { - tentative_result = count; + tentative_result = count; break; } else if (count > start_line) { /* next line */ - HTUserMsg2(STRING_NOT_FOUND, target); - return; /* end */ + _user_message(STRING_NOT_FOUND, target); + sleep(MessageSecs); + return; /* end */ } else { - line = line->next; + line = line->next; count++; } } @@ -5330,14 +5240,14 @@ PUBLIC void user_message ARGS2( * HText_getOwner returns the owner of the * current document. */ -PUBLIC CONST char * HText_getOwner NOARGS +PUBLIC char * HText_getOwner NOARGS { return(HTMainText ? - HTAnchor_owner(HTMainText->node_anchor) : 0); + (char *)HTAnchor_owner(HTMainText->node_anchor) : NULL); } /* - * HText_setMainTextOwner sets the owner for the +* HText_setMainTextOwner sets the owner for the * current document. */ PUBLIC void HText_setMainTextOwner ARGS1( @@ -5354,30 +5264,30 @@ PUBLIC void HText_setMainTextOwner ARGS1( * current document, used as the subject for mailto comments * to the owner. */ -PUBLIC CONST char * HText_getRevTitle NOARGS +PUBLIC char * HText_getRevTitle NOARGS { return(HTMainText ? - HTAnchor_RevTitle(HTMainText->node_anchor) : 0); + (char *)HTAnchor_RevTitle(HTMainText->node_anchor) : NULL); } /* * HText_getContentBase returns the Content-Base header * of the current document. */ -PUBLIC CONST char * HText_getContentBase NOARGS +PUBLIC char * HText_getContentBase NOARGS { return(HTMainText ? - HTAnchor_content_base(HTMainText->node_anchor) : 0); + (char *)HTAnchor_content_base(HTMainText->node_anchor) : NULL); } /* * HText_getContentLocation returns the Content-Location header * of the current document. */ -PUBLIC CONST char * HText_getContentLocation NOARGS +PUBLIC char * HText_getContentLocation NOARGS { return(HTMainText ? - HTAnchor_content_location(HTMainText->node_anchor) : 0); + (char *)HTAnchor_content_location(HTMainText->node_anchor) : NULL); } PUBLIC void HTuncache_current_document NOARGS @@ -5393,24 +5303,28 @@ PUBLIC void HTuncache_current_document NOARGS FREE(htmain_anchor->UCStages); } } - CTRACE(tfp, "\rHTuncache.. freeing document for '%s'%s\n", + if (TRACE) { + fprintf(stderr, "\rHTuncache.. freeing document for '%s'%s\n", ((htmain_anchor && htmain_anchor->address) ? htmain_anchor->address : "unknown anchor"), ((htmain_anchor && htmain_anchor->post_data) ? " with POST data" : "")); + } HTList_removeObject(loaded_texts, HTMainText); HText_free(HTMainText); HTMainText = NULL; } else { - CTRACE(tfp, "HTuncache.. HTMainText already is NULL!\n"); + if (TRACE) { + fprintf(stderr, "HTuncache.. HTMainText already is NULL!\n"); + } } } PUBLIC int HTisDocumentSource NOARGS { - return (HTMainText != 0) ? HTMainText->source : FALSE; + return(HTMainText->source); } PUBLIC char * HTLoadedDocumentURL NOARGS @@ -5547,7 +5461,7 @@ PRIVATE int HText_TrueLineSize ARGS3( (!(text && text->T.output_utf8) || (unsigned char)line->data[i] < 128 || ((unsigned char)(line->data[i] & 0xc0) == 0xc0)) && - !isspace((unsigned char)line->data[i]) && + !isspace((unsigned char)line->data[i]) && (unsigned char)line->data[i] != HT_NON_BREAK_SPACE && (unsigned char)line->data[i] != HT_EM_SPACE) { true_size++; @@ -5659,7 +5573,7 @@ PUBLIC void HText_setTabID ARGS2( } else { while (NULL != (Tab = (HTTabID *)HTList_nextObject(cur))) { if (Tab->name && !strcmp(Tab->name, name)) - return; /* Already set. Keep the first value. */ + return; /* Already set. Keep the first value. */ last = cur; } if (last) @@ -5687,7 +5601,7 @@ PUBLIC int HText_getTabIDColumn ARGS2( if (text && name && *name && cur) { while (NULL != (Tab = (HTTabID *)HTList_nextObject(cur))) { if (Tab->name && !strcmp(Tab->name, name)) - break; + break; } if (Tab) column = Tab->column; @@ -5841,9 +5755,11 @@ PUBLIC void HText_beginForm ARGS5( * convert to lowercase and collapse spaces. - kw */ if (accept_cs != NULL) { + int i; StrAllocCopy(HTFormAcceptCharset, accept_cs); - LYRemoveBlanks(HTFormAcceptCharset); - LYLowerCase(HTFormAcceptCharset); + collapse_spaces(HTFormAcceptCharset); + for (i = 0; HTFormAcceptCharset[i]; i++) + HTFormAcceptCharset[i] = TOLOWER(HTFormAcceptCharset[i]); } /* @@ -5863,7 +5779,9 @@ PUBLIC void HText_beginForm ARGS5( PerFormInfo_free(HTCurrentForm); /* shouldn't happen here - kw */ HTCurrentForm = newform; - CTRACE(tfp, "BeginForm: action:%s Method:%d%s%s%s%s%s%s\n", + if (TRACE) + fprintf(stderr, + "BeginForm: action:%s Method:%d%s%s%s%s%s%s\n", HTFormAction, HTFormMethod, (HTFormTitle ? " Title:" : ""), (HTFormTitle ? HTFormTitle : ""), @@ -5887,7 +5805,7 @@ PUBLIC void HText_endForm ARGS1( */ while (a) { if (a->link_type == INPUT_ANCHOR && - a->input_field->number == HTFormNumber && + a->input_field->number == HTFormNumber && a->input_field->type == F_TEXT_TYPE) { /* * Got it. Make it submitting. - FM @@ -5906,7 +5824,7 @@ PUBLIC void HText_endForm ARGS1( break; } if (a == text->last_anchor) - break; + break; a = a->next; } } @@ -5928,7 +5846,8 @@ PUBLIC void HText_endForm ARGS1( HTList_appendObject(text->forms, HTCurrentForm); HTCurrentForm = NULL; } else { - CTRACE(tfp, "endForm: HTCurrentForm is missing!\n"); + if (TRACE) + fprintf(stderr, "endForm: HTCurrentForm is missing!\n"); } FREE(HTCurSelectGroup); @@ -5970,16 +5889,18 @@ PUBLIC void HText_beginSelect ARGS4( */ StrAllocCopy(HTCurSelectGroupSize, size); - CTRACE(tfp,"HText_beginSelect: name=%s type=%d size=%s\n", + if (TRACE) { + fprintf(stderr,"HText_beginSelect: name=%s type=%d size=%s\n", ((HTCurSelectGroup == NULL) ? "<NULL>" : HTCurSelectGroup), HTCurSelectGroupType, ((HTCurSelectGroupSize == NULL) ? "<NULL>" : HTCurSelectGroupSize)); - CTRACE(tfp,"HText_beginSelect: name_cs=%d \"%s\"\n", + fprintf(stderr,"HText_beginSelect: name_cs=%d \"%s\"\n", HTCurSelectGroupCharset, (HTCurSelectGroupCharset >= 0 ? LYCharSet_UC[HTCurSelectGroupCharset].MIMEname : "<UNKNOWN>")); + } } /* @@ -6004,7 +5925,8 @@ PUBLIC int HText_getOptionNum ARGS1( for (op = a->input_field->select_list; op; op = op->next) n++; - CTRACE(tfp, "HText_getOptionNum: Got number '%d'.\n", n); + if (TRACE) + fprintf(stderr, "HText_getOptionNum: Got number '%d'.\n", n); return(n); } @@ -6035,13 +5957,13 @@ PRIVATE char * HText_skipOptionNumPrefix ARGS1( if ((cp && *cp && *cp++ == '(') && *cp && isdigit(*cp++)) { while (*cp && isdigit(*cp)) - ++cp; + ++cp; if (*cp && *cp++ == ')') { int i = (cp - opname); while (i < 5) { if (*cp != '_') - break; + break; i++; cp++; } @@ -6049,7 +5971,7 @@ PRIVATE char * HText_skipOptionNumPrefix ARGS1( cp = opname; } } else { - cp = opname; + cp = opname; } } else { cp = opname; @@ -6081,12 +6003,16 @@ PUBLIC char * HText_setLastOptionValue ARGS7( if (!(text && text->last_anchor && text->last_anchor->link_type == INPUT_ANCHOR)) { - CTRACE(tfp, "HText_setLastOptionValue: invalid call! value:%s!\n", + if (TRACE) + fprintf(stderr, + "HText_setLastOptionValue: invalid call! value:%s!\n", (value ? value : "<NULL>")); return NULL; } - CTRACE(tfp, "Entering HText_setLastOptionValue: value:%s, checked:%s\n", + if (TRACE) + fprintf(stderr, + "Entering HText_setLastOptionValue: value:%s, checked:%s\n", value, (checked ? "on" : "off")); /* @@ -6164,17 +6090,21 @@ PUBLIC char * HText_setLastOptionValue ARGS7( * No option items yet. */ if (text->last_anchor->input_field->type != F_OPTION_LIST_TYPE) { - CTRACE(tfp, "HText_setLastOptionValue: last input_field not F_OPTION_LIST_TYPE (%d)\n", + if (TRACE) { + fprintf(stderr, + "HText_setLastOptionValue: last input_field not F_OPTION_LIST_TYPE (%d)\n", F_OPTION_LIST_TYPE); - CTRACE(tfp, " but %d, ignoring!\n", + fprintf(stderr, + " but %d, ignoring!\n", text->last_anchor->input_field->type); + } return NULL; } new_ptr = text->last_anchor->input_field->select_list = (OptionType *)calloc(1, sizeof(OptionType)); if (new_ptr == NULL) - outofmem(__FILE__, "HText_setLastOptionValue"); + outofmem(__FILE__, "HText_setLastOptionValue"); first_option = TRUE; } else { @@ -6187,7 +6117,7 @@ PUBLIC char * HText_setLastOptionValue ARGS7( op_ptr->next = new_ptr = (OptionType *)calloc(1, sizeof(OptionType)); if (new_ptr == NULL) - outofmem(__FILE__, "HText_setLastOptionValue"); + outofmem(__FILE__, "HText_setLastOptionValue"); } new_ptr->name = NULL; @@ -6195,7 +6125,7 @@ PUBLIC char * HText_setLastOptionValue ARGS7( new_ptr->next = NULL; for (i = 0, j = 0; cp[i]; i++) { if (cp[i] == HT_NON_BREAK_SPACE || - cp[i] == HT_EM_SPACE) { + cp[i] == HT_EM_SPACE) { cp[j++] = ' '; } else if (cp[i] != LY_SOFT_HYPHEN && !IsSpecialAttrChar((unsigned char)cp[i])) { @@ -6205,7 +6135,7 @@ PUBLIC char * HText_setLastOptionValue ARGS7( cp[j] = '\0'; if (HTCJK != NOCJK) { if (cp && - (tmp = (unsigned char *)calloc(1, strlen(cp)+1))) { + (tmp = (unsigned char *)calloc(1, strlen(cp)+1))) { if (kanji_code == EUC) { TO_EUC((unsigned char *)cp, tmp); val_cs = current_char_set; @@ -6214,7 +6144,7 @@ PUBLIC char * HText_setLastOptionValue ARGS7( val_cs = current_char_set; } else { for (i = 0, j = 0; cp[i]; i++) { - if (cp[i] != '\033') { + if (cp[i] != '\033') { tmp[j++] = cp[i]; } } @@ -6299,24 +6229,24 @@ PUBLIC char * HText_setLastOptionValue ARGS7( } if (TRACE) { - fprintf(tfp,"HText_setLastOptionValue:%s value=%s", + fprintf(stderr,"HText_setLastOptionValue:%s value=%s", (order == LAST_ORDER) ? " LAST_ORDER" : "", value); - fprintf(tfp," val_cs=%d \"%s\"", + fprintf(stderr," val_cs=%d \"%s\"", val_cs, (val_cs >= 0 ? LYCharSet_UC[val_cs].MIMEname : "<UNKNOWN>")); if (submit_value) { - fprintf(tfp, " (submit_val_cs %d \"%s\") submit_value%s=%s\n", + fprintf(stderr, " (submit_val_cs %d \"%s\") submit_value%s=%s\n", submit_val_cs, (submit_val_cs >= 0 ? LYCharSet_UC[submit_val_cs].MIMEname : "<UNKNOWN>"), (HTCurSelectGroupType == F_CHECKBOX_TYPE) ? - "(ignored)" : "", + "(ignored)" : "", submit_value); } else { - fprintf(tfp,"\n"); + fprintf(stderr,"\n"); } } return(ret_Value); @@ -6340,12 +6270,8 @@ PUBLIC int HText_beginInput ARGS3( unsigned char *tmp = NULL; int i, j; - CTRACE(tfp,"Entering HText_beginInput\n"); - -#ifdef DISP_PARTIAL - if (display_partial) - detected_forms_input_partial = TRUE; /* trimHightext temp fix */ -#endif + if (TRACE) + fprintf(stderr,"Entering HText_beginInput\n"); if (a == NULL || f == NULL) outofmem(__FILE__, "HText_beginInput"); @@ -6375,7 +6301,7 @@ PUBLIC int HText_beginInput ARGS3( TextAnchor * b = text->first_anchor; int i2 = 0; while (b) { - if (b->link_type == INPUT_ANCHOR && + if (b->link_type == INPUT_ANCHOR && b->input_field->type == F_RADIO_TYPE && b->input_field->number == HTFormNumber) { if (!strcmp(b->input_field->name, I->name)) { @@ -6437,7 +6363,7 @@ PUBLIC int HText_beginInput ARGS3( } else { for (i = 0, j = 0; IValue[i]; i++) { if (IValue[i] != '\033') { - tmp[j++] = IValue[i]; + tmp[j++] = IValue[i]; } } } @@ -6563,7 +6489,8 @@ PUBLIC int HText_beginInput ARGS3( /* * Error! NAME must be present. */ - CTRACE(tfp, + if (TRACE) + fprintf(stderr, "GridText: No name present in input field; not displaying\n"); FREE(a); FREE(f); @@ -6668,8 +6595,9 @@ PUBLIC int HText_beginInput ARGS3( */ if (I->accept_cs) { StrAllocCopy(f->accept_cs, I->accept_cs); - LYRemoveBlanks(f->accept_cs); - LYLowerCase(f->accept_cs); + collapse_spaces(f->accept_cs); + for (i = 0; f->accept_cs[i]; i++) + f->accept_cs[i] = TOLOWER(f->accept_cs[i]); } /* @@ -6743,9 +6671,9 @@ PUBLIC int HText_beginInput ARGS3( * account as well. - FM */ if (keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED) - MaximumSize -= ((a->number/10) + 3); + MaximumSize -= ((a->number/10) + 3); if (f->size > MaximumSize) - f->size = MaximumSize; + f->size = MaximumSize; /* * Save value for submit/reset buttons so they @@ -6789,27 +6717,30 @@ PUBLIC int HText_beginInput ARGS3( text->forms = HTList_new(); } } else { - CTRACE(tfp, "beginInput: HTCurrentForm is missing!\n"); + if (TRACE) + fprintf(stderr, "beginInput: HTCurrentForm is missing!\n"); } - CTRACE(tfp, "Input link: name=%s\nvalue=%s\nsize=%d\n", + if (TRACE) { + fprintf(stderr,"Input link: name=%s\nvalue=%s\nsize=%d\n", f->name, ((f->value != NULL) ? f->value : ""), f->size); - CTRACE(tfp, "Input link: name_cs=%d \"%s\" (from %d \"%s\")\n", + fprintf(stderr,"Input link: name_cs=%d \"%s\" (from %d \"%s\")\n", f->name_cs, (f->name_cs >= 0 ? LYCharSet_UC[f->name_cs].MIMEname : "<UNKNOWN>"), I->name_cs, (I->name_cs >= 0 ? LYCharSet_UC[I->name_cs].MIMEname : "<UNKNOWN>")); - CTRACE(tfp, " value_cs=%d \"%s\" (from %d \"%s\")\n", + fprintf(stderr," value_cs=%d \"%s\" (from %d \"%s\")\n", f->value_cs, (f->value_cs >= 0 ? LYCharSet_UC[f->value_cs].MIMEname : "<UNKNOWN>"), I->value_cs, (I->value_cs >= 0 ? LYCharSet_UC[I->value_cs].MIMEname : "<UNKNOWN>")); + } /* * Return the SIZE of the input field. @@ -6957,10 +6888,14 @@ PUBLIC void HText_SubmitForm ARGS4( thisform = HTList_objectAt(HTMainText->forms, form_number - 1); /* Sanity check */ if (!thisform) { - CTRACE(tfp, "SubmitForm: form %d not in HTMainText's list!\n", + if (TRACE) + fprintf(stderr, + "SubmitForm: form %d not in HTMainText's list!\n", form_number); } else if (thisform->number != form_number) { - CTRACE(tfp, "SubmitForm: failed sanity check, %d!=%d !\n", + if (TRACE) + fprintf(stderr, + "SubmitForm: failed sanity check, %d!=%d !\n", thisform->number, form_number); thisform = NULL; } @@ -7050,12 +6985,13 @@ PUBLIC void HText_SubmitForm ARGS4( if (target_cs >= 0) { target_csname = HTMainText->node_anchor->charset; } else { - target_cs = UCLYhndl_for_unspec; /* always >= 0 */ - target_csname = LYCharSet_UC[target_cs].MIMEname; + target_cs = UCLYhndl_for_unspec; + if (target_cs >= 0) + target_csname = LYCharSet_UC[target_cs].MIMEname; } } if (target_cs < 0) { - target_cs = UCLYhndl_for_unspec; /* always >= 0 */ + target_cs = UCLYhndl_for_unspec; } /* @@ -7071,22 +7007,22 @@ PUBLIC void HText_SubmitForm ARGS4( char *p; char * val; - form_ptr = anchor_ptr->input_field; + form_ptr = anchor_ptr->input_field; val = form_ptr->cp_submit_value != NULL ? - form_ptr->cp_submit_value : form_ptr->value; + form_ptr->cp_submit_value : form_ptr->value; field_has_8bit = NO; field_has_special = NO; - len += (strlen(form_ptr->name) + (Boundary ? 100 : 10)); + len += (strlen(form_ptr->name) + (Boundary ? 100 : 10)); /* * Calculate by the option submit value if present. */ if (form_ptr->cp_submit_value != NULL) { len += (strlen(form_ptr->cp_submit_value) + 10); } else { - len += (strlen(form_ptr->value) + 10); + len += (strlen(form_ptr->value) + 10); } - len += 32; /* plus and ampersand + safety net */ + len += 32; /* plus and ampersand + safety net */ for (p = val; p && *p && !(field_has_8bit && field_has_special); @@ -7154,7 +7090,7 @@ PUBLIC void HText_SubmitForm ARGS4( } } else if (anchor_ptr->input_field->number > form_number) { - break; + break; } } @@ -7277,30 +7213,33 @@ PUBLIC void HText_SubmitForm ARGS4( textarea_lineno = 0; switch(form_ptr->type) { - case F_RESET_TYPE: + case F_RESET_TYPE: break; - case F_SUBMIT_TYPE: - case F_TEXT_SUBMIT_TYPE: - case F_IMAGE_SUBMIT_TYPE: + case F_SUBMIT_TYPE: + case F_TEXT_SUBMIT_TYPE: + case F_IMAGE_SUBMIT_TYPE: if (!(form_ptr->name && *form_ptr->name != '\0' && !strcmp(form_ptr->name, link_name))) { - CTRACE(tfp, + if (TRACE) { + fprintf(stderr, "SubmitForm: skipping submit field with "); - CTRACE(tfp, "name \"%s\" for link_name \"%s\", %s.\n", + fprintf(stderr, + "name \"%s\" for link_name \"%s\", %s.", form_ptr->name ? form_ptr->name : "???", link_name ? link_name : "???", (form_ptr->name && *form_ptr->name) ? "not current link" : "no field name"); + } break; } if (!(form_ptr->type == F_TEXT_SUBMIT_TYPE || (form_ptr->value && *form_ptr->value != '\0' && !strcmp(form_ptr->value, link_value)))) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "SubmitForm: skipping submit field with "); - fprintf(tfp, - "name \"%s\" for link_name \"%s\", %s!\n", + fprintf(stderr, + "name \"%s\" for link_name \"%s\", %s!", form_ptr->name ? form_ptr->name : "???", link_name ? link_name : "???", "values are different"); @@ -7308,11 +7247,11 @@ PUBLIC void HText_SubmitForm ARGS4( break; } /* fall through */ - case F_RADIO_TYPE: + case F_RADIO_TYPE: case F_CHECKBOX_TYPE: case F_TEXTAREA_TYPE: case F_PASSWORD_TYPE: - case F_TEXT_TYPE: + case F_TEXT_TYPE: case F_OPTION_LIST_TYPE: case F_HIDDEN_TYPE: /* @@ -7349,7 +7288,9 @@ PUBLIC void HText_SubmitForm ARGS4( success = LYUCTranslateBackFormData(&copied_val_used, form_ptr->value_cs, target_cs, PlainText); - CTRACE(tfp, "SubmitForm: field \"%s\" %d %s -> %d %s %s\n", + if (TRACE) { + fprintf(stderr, + "SubmitForm: field \"%s\" %d %s -> %d %s %s\n", form_ptr->name ? form_ptr->name : "", form_ptr->value_cs, form_ptr->value_cs >= 0 ? @@ -7358,14 +7299,18 @@ PUBLIC void HText_SubmitForm ARGS4( target_cs, target_csname ? target_csname : "???", success ? "OK" : "FAILED"); + } if (success) { val_used = copied_val_used; } } else { /* We can use the value directly. */ - CTRACE(tfp, "SubmitForm: field \"%s\" %d %s OK\n", + if (TRACE) { + fprintf(stderr, + "SubmitForm: field \"%s\" %d %s OK\n", form_ptr->name ? form_ptr->name : "", target_cs, target_csname ? target_csname : "???"); + } success = YES; } if (!success) { @@ -7439,7 +7384,9 @@ PUBLIC void HText_SubmitForm ARGS4( success = LYUCTranslateBackFormData(&copied_name_used, form_ptr->name_cs, target_cs, PlainText); - CTRACE(tfp, "SubmitForm: name \"%s\" %d %s -> %d %s %s\n", + if (TRACE) { + fprintf(stderr, + "SubmitForm: name \"%s\" %d %s -> %d %s %s\n", form_ptr->name ? form_ptr->name : "", form_ptr->name_cs, form_ptr->name_cs >= 0 ? @@ -7448,6 +7395,7 @@ PUBLIC void HText_SubmitForm ARGS4( target_cs, target_csname ? target_csname : "???", success ? "OK" : "FAILED"); + } if (success) { name_used = copied_name_used; } @@ -7461,10 +7409,13 @@ PUBLIC void HText_SubmitForm ARGS4( } } } else { /* We can use the name directly. */ - CTRACE(tfp, "SubmitForm: name \"%s\" %d %s OK\n", + if (TRACE) { + fprintf(stderr, + "SubmitForm: name \"%s\" %d %s OK\n", form_ptr->name ? form_ptr->name : "", target_cs, target_csname ? target_csname : "???"); + } success = YES; if (Boundary) { StrAllocCopy(copied_name_used, name_used); @@ -7498,7 +7449,8 @@ PUBLIC void HText_SubmitForm ARGS4( break; default: - CTRACE(tfp, "SubmitForm: What type is %d?\n", + if (TRACE) + fprintf(stderr, "SubmitForm: What type is %d?\n", form_ptr->type); } @@ -7833,9 +7785,9 @@ PUBLIC void HText_SubmitForm ARGS4( FREE(copied_name_used); FREE(copied_val_used); break; - } + } } else if (anchor_ptr->input_field->number > form_number) { - break; + break; } } @@ -7851,16 +7803,19 @@ PUBLIC void HText_SubmitForm ARGS4( FREE(previous_blanks); if (submit_item->submit_method == URL_MAIL_METHOD) { - HTUserMsg2("Submitting %s", submit_item->submit_action); - CTRACE(tfp, "\nGridText - mailto_address: %s\n", + _user_message("Submitting %s", submit_item->submit_action); + if (TRACE) { + fprintf(stderr, "\nGridText - mailto_address: %s\n", (submit_item->submit_action+7)); - CTRACE(tfp, "GridText - mailto_subject: %s\n", + fprintf(stderr, "GridText - mailto_subject: %s\n", ((submit_item->submit_title && *submit_item->submit_title) ? (submit_item->submit_title) : (HText_getTitle() ? - HText_getTitle() : ""))); - CTRACE(tfp,"GridText - mailto_content: %s\n",query); + HText_getTitle() : ""))); + fprintf(stderr,"GridText - mailto_content: %s\n",query); + } + sleep(MessageSecs); mailform((submit_item->submit_action+7), ((submit_item->submit_title && *submit_item->submit_title) ? @@ -7878,7 +7833,8 @@ PUBLIC void HText_SubmitForm ARGS4( if (submit_item->submit_method == URL_POST_METHOD || Boundary) { StrAllocCopy(doc->post_data, query); - CTRACE(tfp,"GridText - post_data: %s\n",doc->post_data); + if (TRACE) + fprintf(stderr,"GridText - post_data: %s\n",doc->post_data); StrAllocCopy(doc->address, submit_item->submit_action); FREE(query); return; @@ -7941,9 +7897,9 @@ PUBLIC void HText_ResetForm ARGS1( anchor_ptr->input_field->type == F_CHECKBOX_TYPE) { if (anchor_ptr->input_field->orig_value[0] == '0') - anchor_ptr->input_field->num_value = 0; + anchor_ptr->input_field->num_value = 0; else - anchor_ptr->input_field->num_value = 1; + anchor_ptr->input_field->num_value = 1; } else if (anchor_ptr->input_field->type == F_OPTION_LIST_TYPE) { @@ -7953,7 +7909,7 @@ PUBLIC void HText_ResetForm ARGS1( anchor_ptr->input_field->cp_submit_value = anchor_ptr->input_field->orig_submit_value; - } else { + } else { StrAllocCopy(anchor_ptr->input_field->value, anchor_ptr->input_field->orig_value); } @@ -7987,13 +7943,13 @@ PUBLIC void HText_activateRadioButton ARGS1( if (anchor_ptr->input_field->number == form_number) { /* if it has the same name and its on */ - if (!strcmp(anchor_ptr->input_field->name, form->name) && + if (!strcmp(anchor_ptr->input_field->name, form->name) && anchor_ptr->input_field->num_value) { anchor_ptr->input_field->num_value = 0; break; - } + } } else if (anchor_ptr->input_field->number > form_number) { - break; + break; } } @@ -8192,7 +8148,7 @@ PUBLIC void HText_setBreakPoint ARGS1( /* * Can split here. - FM */ - text->permissible_split = text->last_line->size; + text->permissible_split = (int)text->last_line->size; return; } diff --git a/src/GridText.h b/src/GridText.h index a99f66da..265cadd7 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -10,12 +10,6 @@ #include <HTForms.h> #endif /* HTFORMS_H */ -#ifndef HT_NON_BREAK_SPACE -#define HT_NON_BREAK_SPACE ((char)1) /* remember it */ -#endif /* !HT_NON_BREAK_SPACE */ -#ifndef HT_EM_SPACE -#define HT_EM_SPACE ((char)2) /* remember it */ -#endif /* !HT_EM_SPACE */ #define LY_UNDERLINE_START_CHAR '\003' #define LY_UNDERLINE_END_CHAR '\004' #define LY_BOLD_START_CHAR '\005' @@ -23,46 +17,7 @@ #ifndef LY_SOFT_HYPHEN #define LY_SOFT_HYPHEN ((char)7) #endif /* !LY_SOFT_HYPHEN */ -#define LY_SOFT_NEWLINE ((char)8) - -#define IsSpecialAttrChar(a) ((a > '\002') && (a <= '\010')) - -/* just for information: -US-ASCII control characters <32 which are not defined in Unicode standard -=00 U+0000 NULL -=01 U+0001 START OF HEADING -=02 U+0002 START OF TEXT -=03 U+0003 END OF TEXT -=04 U+0004 END OF TRANSMISSION -=05 U+0005 ENQUIRY -=06 U+0006 ACKNOWLEDGE -=07 U+0007 BELL -=08 U+0008 BACKSPACE -=09 U+0009 HORIZONTAL TABULATION -=0A U+000A LINE FEED -=0B U+000B VERTICAL TABULATION -=0C U+000C FORM FEED -=0D U+000D CARRIAGE RETURN -=0E U+000E SHIFT OUT -=0F U+000F SHIFT IN -=10 U+0010 DATA LINK ESCAPE -=11 U+0011 DEVICE CONTROL ONE -=12 U+0012 DEVICE CONTROL TWO -=13 U+0013 DEVICE CONTROL THREE -=14 U+0014 DEVICE CONTROL FOUR -=15 U+0015 NEGATIVE ACKNOWLEDGE -=16 U+0016 SYNCHRONOUS IDLE -=17 U+0017 END OF TRANSMISSION BLOCK -=18 U+0018 CANCEL -=19 U+0019 END OF MEDIUM -=1A U+001A SUBSTITUTE -=1B U+001B ESCAPE -=1C U+001C FILE SEPARATOR -=1D U+001D GROUP SEPARATOR -=1E U+001E RECORD SEPARATOR -=1F U+001F UNIT SEPARATOR -=7F U+007F DELETE -*/ +#define IsSpecialAttrChar(a) ((a > '\002') && (a < '\010')) extern int HTCurSelectGroupType; extern char * HTCurSelectGroupSize; @@ -83,6 +38,9 @@ extern HTParentAnchor * HTMainAnchor; /* Anchor for HTMainText */ #endif /* SHORT_NAMES */ extern int WWW_TraceFlag; +extern int HTCacheSize; + +extern BOOLEAN mustshow; #if defined(VMS) && defined(VAXC) && !defined(__DECC) extern int HTVirtualMemorySize; @@ -113,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 CONST char * HText_getTitle NOPARAMS; -extern CONST char * HText_getSugFname NOPARAMS; +extern char * HText_getTitle NOPARAMS; +extern char * HText_getSugFname NOPARAMS; extern void HTCheckFnameForCompression PARAMS(( char ** fname, HTParentAnchor * anchor, BOOLEAN strip_ok)); -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; +extern char * HText_getLastModified NOPARAMS; +extern char * HText_getDate NOPARAMS; +extern char * HText_getServer NOPARAMS; +extern char * HText_getOwner NOPARAMS; +extern char * HText_getContentBase NOPARAMS; +extern char * HText_getContentLocation NOPARAMS; #ifdef USE_HASH -extern CONST char * HText_getStyle NOPARAMS; +extern 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)); @@ -200,9 +158,6 @@ extern int HText_beginInput PARAMS(( HText * text, BOOL underline, InputFieldData *I)); -extern void HText_trimHightext PARAMS(( - HText * text, - BOOLEAN disable_trace)); extern void HText_SubmitForm PARAMS(( FormInfo * submit_item, document * doc, diff --git a/src/HTAlert.c b/src/HTAlert.c index c709361a..74d8d2b8 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -10,6 +10,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTAlert.h> #include <LYGlobalDefs.h> #include <LYCurses.h> @@ -21,58 +22,27 @@ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + + /* Issue a message about a problem. HTAlert() ** -------------------------------- */ PUBLIC void HTAlert ARGS1( CONST char *, Msg) { - CTRACE(tfp, "\nAlert!: %s\n\n", Msg); - CTRACE_FLUSH(tfp); - _user_message("Alert!: %s", Msg); + if (TRACE) { + fprintf(stderr, "\nAlert!: %s", Msg); + fflush(stderr); + _user_message("Alert!: %s", Msg); + fprintf(stderr, "\n\n"); + fflush(stderr); + } else + _user_message("Alert!: %s", Msg); sleep(AlertSecs); } -/* Issue an informational message. HTInfoMsg() -** -------------------------------- -*/ -PUBLIC void HTInfoMsg ARGS1( - CONST char *, Msg) -{ - _statusline(Msg); - if (Msg && *Msg) { - CTRACE(tfp, "Info message: %s\n", Msg); - sleep(InfoSecs); - } -} - -/* Issue an important message. HTUserMsg() -** -------------------------------- -*/ -PUBLIC void HTUserMsg ARGS1( - CONST char *, Msg) -{ - _statusline(Msg); - if (Msg && *Msg) { - CTRACE(tfp, "User message: %s\n", Msg); - sleep(MessageSecs); - } -} - -PUBLIC void HTUserMsg2 ARGS2( - CONST char *, Msg2, - CONST char *, Arg) -{ - _user_message(Msg2, Arg); - if (Msg2 && *Msg2) { - CTRACE(tfp, "User message: "); - CTRACE(tfp, Msg2, Arg); - CTRACE(tfp, "\n"); - sleep(MessageSecs); - } -} - /* Issue a progress message. HTProgress() ** ------------------------- */ @@ -80,69 +50,9 @@ PUBLIC void HTProgress ARGS1( CONST char *, Msg) { if (TRACE) - fprintf(tfp, "%s\n", Msg); + fprintf(stderr, "%s\n", Msg); else - statusline(Msg); -} - -/* Issue a read-progress message. HTReadProgress() -** ------------------------------ -*/ -PUBLIC void HTReadProgress ARGS2( - long, bytes, - long, total) -{ - static long kb_units = 1024; - static time_t first, last; - static long bytes_last; - long transfer_rate, divisor; - char line[80]; - time_t now = time((time_t *)0); /* once per second */ - char *units = "bytes"; - - if (bytes == 0) { - first = 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; - } - units = "bytes"; - divisor = 1; - if (LYshow_kb_rate - && (total >= kb_units || bytes >= kb_units)) { - units = "KB"; - divisor = kb_units; - bytes /= divisor; - if (total > 0) total /= divisor; - } - - if (total > 0) - sprintf (line, "Read %ld of %ld %s of data", bytes, total, units); - else - sprintf (line, "Read %ld %s of data", bytes, units); - if ((transfer_rate > 0) - && (!LYshow_kb_rate || (bytes * divisor >= kb_units))) - sprintf (line + strlen(line), ", %ld %s/sec.", transfer_rate / divisor, units); - else - sprintf (line + strlen(line), "."); - if (total < 0) { - if (total < -1) - strcat(line, " (Press 'z' to abort)"); - } - HTProgress(line); - } - } + statusline(Msg); } PRIVATE BOOL conf_cancelled = NO; /* used by HTConfirm only - kw */ @@ -170,9 +80,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 @@ -205,11 +115,11 @@ PUBLIC char * HTPrompt ARGS2( Tmp[199] = '\0'; _statusline(Msg); - if (deflt) - strncpy(Tmp, deflt, 199); + if (deflt) + strncpy(Tmp, deflt, 199); if (!dump_output_immediately) - LYgetstr(Tmp, VISIBLE, sizeof(Tmp), NORECALL); + LYgetstr(Tmp, VISIBLE, sizeof(Tmp), NORECALL); StrAllocCopy(rep, Tmp); @@ -229,37 +139,37 @@ PUBLIC char * HTPromptPassword ARGS1( pw[0] = '\0'; if (!dump_output_immediately) { - _statusline(Msg ? Msg : PASSWORD_PROMPT); - LYgetstr(pw, HIDDEN, sizeof(pw), NORECALL); /* hidden */ - StrAllocCopy(result, pw); + _statusline(Msg ? Msg : PASSWORD_PROMPT); + LYgetstr(pw, HIDDEN, sizeof(pw), NORECALL); /* hidden */ + StrAllocCopy(result, pw); } else { - printf("\n%s\n", PASSWORD_REQUIRED); + printf("\n%s\n", PASSWORD_REQUIRED); StrAllocCopy(result, ""); } return result; } -/* Prompt both username and password. HTPromptUsernameAndPassword() -** ---------------------------------- +/* Prompt both username and password. HTPromptUsernameAndPassword() +** ---------------------------------- ** ** On entry, -** Msg is the prompting message. -** *username and -** *password are char pointers which contain default +** Msg is the prompting message. +** *username and +** *password are char pointers which contain default ** or zero-length strings; they are changed -** to point to result strings. -** IsProxy should be TRUE if this is for +** to point to result strings. +** IsProxy should be TRUE if this is for ** proxy authentication. ** -** If *username is not NULL, it is taken -** to point to a default value. -** Initial value of *password is -** completely discarded. +** If *username is not NULL, it is taken +** to point to a default value. +** Initial value of *password is +** completely discarded. ** ** On exit, -** *username and *password point to newly allocated -** strings -- original strings pointed to by them -** are NOT freed. +** *username and *password point to newly allocated +** strings -- original strings pointed to by them +** are NOT freed. ** */ PUBLIC void HTPromptUsernameAndPassword ARGS4( @@ -272,12 +182,12 @@ 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 */ - StrAllocCopy(*username, (IsProxy ? + StrAllocCopy(*username, (IsProxy ? proxyauth_info[0] : authentication_info[0])); if (IsProxy) { FREE(proxyauth_info[0]); @@ -292,15 +202,15 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( FREE(authentication_info[1]); } } else if (dump_output_immediately) { - /* + /* * We are not interactive and don't have both the * username and password from the command line, * but might have one or the other. - FM */ - if ((IsProxy == FALSE && authentication_info[0]) || + if ((IsProxy == FALSE && authentication_info[0]) || (IsProxy == TRUE && proxyauth_info[0])) { /* - ** Use the command line username. - FM + ** Use the command line username. - FM */ StrAllocCopy(*username, (IsProxy ? proxyauth_info[0] : authentication_info[0])); @@ -311,14 +221,14 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( } } else { /* - ** Default to "WWWuser". - FM + ** Default to "WWWuser". - FM */ - StrAllocCopy(*username, "WWWuser"); + StrAllocCopy(*username, "WWWuser"); } - if ((IsProxy == FALSE && authentication_info[1]) || + if ((IsProxy == FALSE && authentication_info[1]) || (IsProxy == TRUE && proxyauth_info[1])) { /* - ** Use the command line password. - FM + ** Use the command line password. - FM */ StrAllocCopy(*password, (IsProxy ? proxyauth_info[1] : authentication_info[1])); @@ -329,23 +239,23 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( } } else { /* - ** Default to a zero-length string. - FM + ** Default to a zero-length string. - FM */ StrAllocCopy(*password, ""); } printf("\n%s\n", USERNAME_PASSWORD_REQUIRED); } else { - /* + /* * We are interactive and don't have both the * username and password from the command line, * but might have one or the other. - FM */ - if ((IsProxy == FALSE && authentication_info[0]) || + if ((IsProxy == FALSE && authentication_info[0]) || (IsProxy == TRUE && proxyauth_info[0])) { /* - ** Offer the command line username in the - ** prompt for the first realm. - FM + ** Offer the command line username in the + ** prompt for the first realm. - FM */ StrAllocCopy(*username, (IsProxy ? proxyauth_info[0] : authentication_info[0])); @@ -363,10 +273,10 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( } else { *username = HTPrompt(USERNAME_PROMPT, *username); } - if ((IsProxy == FALSE && authentication_info[1]) || + if ((IsProxy == FALSE && authentication_info[1]) || (IsProxy == TRUE && proxyauth_info[1])) { /* - ** Use the command line password for the first realm. - FM + ** Use the command line password for the first realm. - FM */ StrAllocCopy(*password, (IsProxy ? proxyauth_info[1] : authentication_info[1])); @@ -377,13 +287,13 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( } } else if (*username != NULL && *username[0] != '\0') { /* - ** We have a non-zero length username, - ** so prompt for the password. - FM + ** We have a non-zero length username, + ** so prompt for the password. - FM */ *password = HTPromptPassword(PASSWORD_PROMPT); } else { /* - ** Return a zero-length password. - FM + ** Return a zero-length password. - FM */ StrAllocCopy(*password, ""); } @@ -404,9 +314,11 @@ PUBLIC void HTPromptUsernameAndPassword ARGS4( ** Returns FALSE on cancel, ** TRUE if the cookie should be set. */ -PUBLIC BOOL HTConfirmCookie ARGS4( - void *, dp, +PUBLIC BOOL HTConfirmCookie ARGS6( + void *, dp, CONST char *, server, + CONST char *, domain, + CONST char *, path, CONST char *, name, CONST char *, value) { @@ -419,70 +331,57 @@ PUBLIC BOOL HTConfirmCookie ARGS4( #endif /* VMS */ if ((de = (domain_entry *)dp) == NULL) - return FALSE; - -#ifdef ENHANCED_COOKIES - /* If the user has specified a list of domains to allow or deny - ** from the config file, then they'll already have de->bv set to - ** ACCEPT_ALWAYS or REJECT_ALWAYS so we can relax and let the - ** default cookie handling code cope with this fine. I hope. - */ -#endif + return FALSE; + /* - ** If the user has specified a constant action, don't prompt at all. + ** If the user has specified a constant action, don't prompt at all. */ - if (de->bv == ACCEPT_ALWAYS || de->bv == FROM_FILE) - return TRUE; + if (de->bv == ACCEPT_ALWAYS) + return TRUE; if (de->bv == REJECT_ALWAYS) - return FALSE; + return FALSE; if (dump_output_immediately) { - /* + /* ** Non-interactive, can't respond. Use the LYSetCookies value * based on its compilation or configuration setting, or on the ** command line toggle. - FM */ - return LYSetCookies; + return LYSetCookies; } /* - ** Figure out how much of the cookie we can show. - ** The '37' is the length of ADVANCED_COOKIE_CONFIRMATION, - ** minus the length of the %s directives (10 chars) + ** Figure out how much of the cookie we can show. + ** The '37' is the length of ADVANCED_COOKIE_CONFIRMATION, + ** 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)); if (space_free < 0) - space_free = 0; + space_free = 0; namelen = strlen(name); valuelen = strlen(value); if ((namelen + valuelen) > space_free) { - /* + /* ** Argh... there isn't enough space on our single line for ** the whole cookie. Reduce them both by a percentage. ** This should be smarter. */ - float percentage; - percentage = (float)space_free/(float)(namelen + valuelen); - namelen = (int)(percentage*(float)namelen); - valuelen = (int)(percentage*(float)valuelen); - } - if(!LYAcceptAllCookies) { - sprintf(message, ADVANCED_COOKIE_CONFIRMATION, - server, namelen, name, valuelen, value); - _statusline(message); + float percentage; + percentage = (float)space_free/(float)(namelen + valuelen); + namelen = (int)(percentage*(float)namelen); + valuelen = (int)(percentage*(float)valuelen); } + sprintf(message, ADVANCED_COOKIE_CONFIRMATION, + server, namelen, name, valuelen, value); + _statusline(message); while (1) { - if(!LYAcceptAllCookies) { - ch = LYgetch(); - } else { - ch = 'A'; - } + ch = LYgetch(); #ifdef VMS if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; @@ -491,52 +390,56 @@ PUBLIC BOOL HTConfirmCookie ARGS4( #endif /* VMS */ switch(TOUPPER(ch)) { case 'A': - /* + /* ** Set to accept all cookies for this domain. */ de->bv = ACCEPT_ALWAYS; - HTUserMsg2(ALWAYS_ALLOWING_COOKIES, de->domain); + _user_message(ALWAYS_ALLOWING_COOKIES, de->domain); + sleep(MessageSecs); return TRUE; case 'N': case 7: /* Ctrl-G */ case 3: /* Ctrl-C */ - /* + /* ** Reject the cookie. */ - HTUserMsg(REJECTING_COOKIE); + _statusline(REJECTING_COOKIE); + sleep(MessageSecs); return FALSE; - case 'V': - /* + case 'V': + /* ** Set to reject all cookies from this domain. */ de->bv = REJECT_ALWAYS; - HTUserMsg2(NEVER_ALLOWING_COOKIES, de->domain); + _user_message(NEVER_ALLOWING_COOKIES, de->domain); + sleep(MessageSecs); return FALSE; case 'Y': - /* + /* ** Accept the cookie. */ - HTInfoMsg(ALLOWING_COOKIE); + _statusline(ALLOWING_COOKIE); + sleep(InfoSecs); return TRUE; default: - continue; + continue; } } } -/* Confirm redirection of POST. HTConfirmPostRedirect() +/* Confirm redirection of POST. HTConfirmPostRedirect() ** ---------------------------- ** ** On entry, -** Redirecting_url is the Location. +** Redirecting_url is the Location. ** server_status is the server status code. ** ** On exit, -** Returns 0 on cancel, +** Returns 0 on cancel, ** 1 for redirect of POST with content, ** 303 for redirect as GET without content */ @@ -548,11 +451,11 @@ PUBLIC int HTConfirmPostRedirect ARGS2( char StatusInfo[256]; char url[256]; int on_screen = 0; /* 0 - show menu - * 1 - show url + * 1 - show url * 2 - menu is already on screen */ if (server_status == 303 || - server_status == 302) { + server_status == 302) { /* * HTTP.c should not have called us for either of * these because we're treating 302 as historical, @@ -561,35 +464,34 @@ PUBLIC int HTConfirmPostRedirect ARGS2( return 303; } - if (dump_output_immediately) { - if (server_status == 301) { + if (dump_output_immediately) + if (server_status == 301) { /* - ** Treat 301 as historical, i.e., like 303 (GET - ** without content), when not interactive. - FM + ** Treat 301 as historical, i.e., like 303 (GET + ** without content), when not interactive. - FM */ - return 303; - } else { + return 303; + } else { /* - ** Treat anything else (e.g., 305, 306 or 307) as too - ** dangerous to redirect without confirmation, and thus - ** cancel when not interactive. - FM + ** Treat anything else (e.g., 305, 306 or 307) as too + ** dangerous to redirect without confirmation, and thus + ** cancel when not interactive. - FM */ return 0; } - } StatusInfo[254] = StatusInfo[255] = '\0'; url[254] = url[(LYcols < 250 ? LYcols-1 : 255)] = '\0'; if (user_mode == NOVICE_MODE) { - on_screen = 2; - move(LYlines-2, 0); - sprintf(StatusInfo, SERVER_ASKED_FOR_REDIRECTION, server_status); + on_screen = 2; + move(LYlines-2, 0); + sprintf(StatusInfo, SERVER_ASKED_FOR_REDIRECTION, server_status); addstr(StatusInfo); clrtoeol(); - move(LYlines-1, 0); + move(LYlines-1, 0); sprintf(url, "URL: %.*s", (LYcols < 250 ? LYcols-6 : 250), Redirecting_url); - addstr(url); + addstr(url); clrtoeol(); if (server_status == 301) { _statusline(PROCEED_GET_CANCEL); @@ -607,14 +509,14 @@ PUBLIC int HTConfirmPostRedirect ARGS2( StrAllocCat(show_POST_url, Redirecting_url); } while (1) { - int c; + int c; switch (on_screen) { case 0: _statusline(StatusInfo); break; case 1: - _statusline(show_POST_url); + _statusline(show_POST_url); } c = LYgetch(); switch (TOUPPER(c)) { @@ -623,22 +525,22 @@ PUBLIC int HTConfirmPostRedirect ARGS2( ** Proceed with 301 or 307 redirect of POST ** with same method and POST content. - FM */ - FREE(show_POST_url); - return 1; + FREE(show_POST_url); + return 1; - case 7: - case 'C': - /* + case 7: + case 'C': + /* ** Cancel request. */ - FREE(show_POST_url); + FREE(show_POST_url); return 0; case 'U': - /* + /* ** Show URL for intermediate or advanced mode. */ - if (user_mode != NOVICE_MODE) { + if (user_mode != NOVICE_MODE) { if (on_screen == 1) { on_screen = 0; } else { @@ -650,7 +552,7 @@ PUBLIC int HTConfirmPostRedirect ARGS2( case 'G': if (server_status == 301) { /* - ** Treat as 303 (GET without content). + ** Treat as 303 (GET without content). */ FREE(show_POST_url); return 303; @@ -658,7 +560,7 @@ PUBLIC int HTConfirmPostRedirect ARGS2( /* fall through to default */ default: - /* + /* ** Get another character. */ if (on_screen == 1) { diff --git a/src/HTAlert.h b/src/HTAlert.h index 334843db..b35267b6 100644 --- a/src/HTAlert.h +++ b/src/HTAlert.h @@ -1,3 +1,5 @@ +/* */ + /* Displaying messages and getting input for WWW Library ** ===================================================== ** @@ -5,10 +7,10 @@ ** Feb 93 Portablized etc TBL */ -#ifndef HTALERT_H -#define HTALERT_H 1 - +#ifndef HTUTILS_H #include <HTUtils.h> +#endif /* HTUTILS_H */ +#include <tcp.h> /* Display a message and get the input ** @@ -27,9 +29,6 @@ extern char * HTPrompt PARAMS((CONST char * Msg, CONST char * deflt)); ** The input is a list of parameters for printf. */ extern void HTAlert PARAMS((CONST char * Msg)); -extern void HTInfoMsg PARAMS((CONST char * Msg)); -extern void HTUserMsg PARAMS((CONST char * Msg)); -extern void HTUserMsg2 PARAMS((CONST char * Msg, CONST char * Arg)); /* Display a progress message for information (and diagnostics) only @@ -38,7 +37,7 @@ extern void HTUserMsg2 PARAMS((CONST char * Msg, CONST char * Arg)); ** The input is a list of parameters for printf. */ extern void HTProgress PARAMS((CONST char * Msg)); -extern void HTReadProgress PARAMS((long bytes, long total)); +extern BOOLEAN mustshow; #define _HTProgress(msg) mustshow = TRUE, HTProgress(msg) /* @@ -108,6 +107,8 @@ 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)); @@ -127,4 +128,6 @@ extern int HTConfirmPostRedirect PARAMS(( CONST char * Redirecting_url, int server_status)); -#endif /* HTALERT_H */ +/* + + */ diff --git a/src/HTFWriter.c b/src/HTFWriter.c index e446db19..9e91704b 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -9,6 +9,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <LYCurses.h> #include <HTFWriter.h> #include <HTSaveToFile.h> @@ -19,11 +20,18 @@ #include <HTFile.h> #include <HTPlain.h> #include <HTFile.h> +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ +#ifdef DOSPATH +#include <HTDOS.h> +#endif #include <LYStrings.h> #include <LYUtils.h> #include <LYGlobalDefs.h> #include <LYSignal.h> +#include <LYSystem.h> #include <GridText.h> #include <LYexit.h> #include <LYLeaks.h> @@ -50,6 +58,9 @@ PUBLIC HTStream* HTSaveToFile PARAMS(( HTParentAnchor * anchor, HTStream * sink)); +#define FREE(x) if (x) {free(x); x = NULL;} + + /* Stream Object ** ------------- */ @@ -65,7 +76,7 @@ struct _HTStream { HTParentAnchor * anchor; /* Original stream's anchor. */ HTStream * sink; /* Original stream's sink. */ #ifdef FNAMES_8_3 - BOOLEAN idash; /* remember position to become '.'*/ + int idash; /* remember position to become '.'*/ #endif }; @@ -124,7 +135,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) fflush(me->fp); if (me->end_command) { /* Temp file */ - LYCloseTempFP(me->fp); + fclose(me->fp); #ifdef VMS if (0 == strcmp(me->end_command, "SaveVMSBinaryFile")) { /* @@ -132,7 +143,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) * we want to convert to fixed records format. - FM */ #ifdef USE_COMMAND_FILE - LYSystem(FIXED_RECORD_COMMAND); + system(FIXED_RECORD_COMMAND); #else LYVMS_FixedLengthRecords(FIXED_RECORD_COMMAND); #endif /* USE_COMMAND_FILE */ @@ -140,6 +151,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) if (me->remove_command) { /* NEVER REMOVE THE FILE unless during an abort!*/ + /* system(me->remove_command); */ FREE(me->remove_command); } } else @@ -183,7 +195,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) * Uncompress it. - FM */ if (me->end_command && me->end_command[0]) - LYSystem(me->end_command); + system(me->end_command); fp = fopen(me->anchor->FileCache, "r"); } if (fp != NULL) { @@ -215,13 +227,11 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) */ if (skip_loadfile) { char *new_path = NULL; - char *the_dash = me->idash ? strrchr(path, '-') : 0; - if (the_dash != 0) { - unsigned off = (the_dash - path); + if (me->idash > 1 && path[me->idash] == '-') { StrAllocCopy(new_path, path); - new_path[off] = '.'; - if (strlen(new_path + off) > 4) - new_path[off + 4] = '\0'; + new_path[me->idash] = '.'; + if (strlen(new_path + me->idash) > 4) + new_path[me->idash + 4] = '\0'; if (rename(path, new_path) == 0) { FREE(path); path = new_path; @@ -231,7 +241,17 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) } } #endif /* FNAMES_8_3 */ - LYLocalFileToURL (&addr, path); + StrAllocCopy(addr, "file://localhost"); +#ifdef DOSPATH + StrAllocCat(addr, "/"); + StrAllocCat(addr, HTDOS_wwwName(path)); +#else +#ifdef VMS + StrAllocCat(addr, HTVMS_wwwName(path)); +#else + StrAllocCat(addr, path); +#endif /* VMS */ +#endif /* DOSPATH */ if (!use_gzread) { StrAllocCopy(me->anchor->FileCache, path); StrAllocCopy(me->anchor->content_encoding, "binary"); @@ -279,7 +299,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) * (or even the same!). We can skip this * needless duplication by using the * viewer_command which has already been - * determined when the HTCompressed stream was + * determind when the HTCompressed stream was * created. - kw */ FREE(me->end_command); @@ -300,10 +320,11 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) HTProgress(me->end_command); stop_curses(); } - LYSystem(me->end_command); + system(me->end_command); if (me->remove_command) { /* NEVER REMOVE THE FILE unless during an abort!!!*/ + /* system(me->remove_command); */ FREE(me->remove_command); } if (!dump_output_immediately) @@ -329,6 +350,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) } if (me->remove_command) { /* NEVER REMOVE THE FILE unless during an abort!!!*/ + /* system(me->remove_command); */ FREE(me->remove_command); } } else if (strcmp(me->end_command, "SaveToFile")) { @@ -343,10 +365,11 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) _HTProgress(me->end_command); stop_curses(); } - LYSystem(me->end_command); + system(me->end_command); if (me->remove_command) { /* NEVER REMOVE THE FILE unless during an abort!!!*/ + /* system(me->remove_command); */ FREE(me->remove_command); } if (!dump_output_immediately) @@ -358,6 +381,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) */ if (me->remove_command) { /* NEVER REMOVE THE FILE unless during an abort!!!*/ + /* system(me->remove_command); */ FREE(me->remove_command); } } @@ -394,14 +418,17 @@ PRIVATE void HTFWriter_abort ARGS2( HTStream *, me, HTError, e GCC_UNUSED) { - CTRACE(tfp,"HTFWriter_abort called\n"); - LYCloseTempFP(me->fp); + if (TRACE) + fprintf(stderr,"HTFWriter_abort called\n"); + + fclose(me->fp); FREE(me->viewer_command); if (me->end_command) { /* Temp file */ - CTRACE(tfp, "HTFWriter: Aborting: file not executed.\n"); + if (TRACE) + fprintf(stderr, "HTFWriter: Aborting: file not executed.\n"); FREE(me->end_command); if (me->remove_command) { - LYSystem(me->remove_command); + system(me->remove_command); FREE(me->remove_command); } } @@ -476,7 +503,9 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( { char fnam[256]; CONST char *suffix; + char *cp; HTStream* me; + FILE *fp = NULL; if (traversal) { LYCancelledFetch = TRUE; @@ -490,7 +519,8 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( return(NULL); } if (no_exec) { - HTAlert(EXECUTION_DISABLED); + _statusline(EXECUTION_DISABLED); + sleep(AlertSecs); return HTPlainPresent(pres, anchor, sink); } if (!local_exec) @@ -503,7 +533,8 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( sprintf(buf, EXECUTION_DISABLED_FOR_FILE, key_for_func(LYK_OPTIONS)); - HTAlert(buf); + _statusline(buf); + sleep(AlertSecs); return HTPlainPresent(pres, anchor, sink); } } @@ -522,27 +553,61 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( me->anchor = anchor; me->sink = sink; - if (LYCachedTemp(fnam, &(anchor->FileCache))) { - me->fp = LYNewBinFile (fnam); + if (anchor->FileCache) { + strcpy(fnam, anchor->FileCache); + FREE(anchor->FileCache); + if ((fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + remove(fnam); + } } else { /* + * Lynx routine to create a temporary filename + */ +SaveAndExecute_tempname: + tempname (fnam, NEW_FILE); + /* * Check for a suffix. - * Save the file under a suitably suffixed name. */ - if (!strcasecomp(pres->rep->name, "text/html")) { - suffix = HTML_SUFFIX; - } else if (!strcasecomp(pres->rep->name, "text/plain")) { - suffix = ".txt"; - } else if (!strcasecomp(pres->rep->name, - "application/octet-stream")) { - suffix = ".bin"; - } else if ((suffix = HTFileSuffix(pres->rep, anchor->content_encoding)) == 0 - || *suffix != '.') { - suffix = HTML_SUFFIX; + if (((cp = strrchr(fnam, '.')) != NULL) && +#ifdef VMS + NULL == strchr(cp, ']') && +#endif /* VMS */ + NULL == strchr(cp, '/')) { + /* + * Save the file under a suitably suffixed name. + */ + *cp = '\0'; + if (!strcasecomp(pres->rep->name, "text/html")) { + strcat(fnam, HTML_SUFFIX); + } else if (!strcasecomp(pres->rep->name, "text/plain")) { + strcat(fnam, ".txt"); + } else if (!strcasecomp(pres->rep->name, + "application/octet-stream")) { + strcat(fnam, ".bin"); + } else if ((suffix = HTFileSuffix(pres->rep, anchor->content_encoding)) + && *suffix == '.') { + strcat(fnam, suffix); + /* + * It's not one of the suffixes checked for a + * spoof in tempname(), so check it now. - FM + */ + if (strcmp(suffix, HTML_SUFFIX) && + strcmp(suffix, ".txt") && + strcmp(suffix, ".bin") && + (fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + goto SaveAndExecute_tempname; + } + } else { + *cp = '.'; + } } - me->fp = LYOpenTemp(fnam, suffix, "wb"); } + me->fp = LYNewBinFile (fnam); if (!me->fp) { HTAlert(CANNOT_OPEN_TEMP); FREE(me); @@ -602,8 +667,9 @@ PUBLIC HTStream* HTSaveToFile ARGS3( char fnam[256]; CONST char * suffix; char *cp; - int c = 0; + int c=0; BOOL IsBinary = TRUE; + FILE *fp = NULL; ret_obj = (HTStream*)calloc(sizeof(* ret_obj),1); if (ret_obj == NULL) @@ -628,7 +694,8 @@ PUBLIC HTStream* HTSaveToFile ARGS3( if (traversal || (no_download && !override_no_download && no_disk_save)) { if (!traversal) { - HTAlert(CANNOT_DISPLAY_FILE); + _statusline(CANNOT_DISPLAY_FILE); + sleep(AlertSecs); } LYCancelDownload = TRUE; if (traversal) @@ -674,32 +741,58 @@ PUBLIC HTStream* HTSaveToFile ARGS3( /* * Set up a 'D'ownload. */ - if (LYCachedTemp(fnam, &(anchor->FileCache))) { - ret_obj->fp = LYNewBinFile (fnam); + if (anchor->FileCache) { + strcpy(fnam, anchor->FileCache); + FREE(anchor->FileCache); + if ((fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + remove(fnam); + } } else { /* + * Lynx routine to create a temporary filename + */ +SaveToFile_tempname: + tempname(fnam, NEW_FILE); + /* * Check for a suffix. - * Save the file under a suitably suffixed name. */ - if (!strcasecomp(pres->rep->name, "text/html")) { - suffix = HTML_SUFFIX; - } else if (!strcasecomp(pres->rep->name, "text/plain")) { - suffix = ".txt"; - } else if (!strcasecomp(pres->rep->name, + if (((cp=strrchr(fnam, '.')) != NULL) && +#ifdef VMS + NULL == strchr(cp, ']') && +#endif /* VMS */ + NULL == strchr(cp, '/')) { + /* + * Save the file under a suitably suffixed name. + */ + *cp = '\0'; + if (!strcasecomp(pres->rep->name, "text/html")) { + strcat(fnam, HTML_SUFFIX); + } else if (!strcasecomp(pres->rep->name, "text/plain")) { + strcat(fnam, ".txt"); + } else if (!strcasecomp(pres->rep->name, "application/octet-stream")) { - suffix = ".bin"; - } else if ((suffix = HTFileSuffix(pres->rep, - anchor->content_encoding)) == 0 - || *suffix != '.') { - suffix = HTML_SUFFIX; + strcat(fnam, ".bin"); + } else if ((suffix = HTFileSuffix(pres->rep, + anchor->content_encoding)) && *suffix == '.') { + strcat(fnam, suffix); + /* + * It's not one of the suffixes checked for a + * spoof in tempname(), so check it now. - FM + */ + if (strcmp(suffix, HTML_SUFFIX) && + strcmp(suffix, ".txt") && + strcmp(suffix, ".bin") && + (fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + goto SaveToFile_tempname; + } + } else { + *cp = '.'; + } } - ret_obj->fp = LYOpenTemp(fnam, suffix, "wb"); - } - - if (!ret_obj->fp) { - HTAlert(CANNOT_OPEN_OUTPUT); - FREE(ret_obj); - return NULL; } if (0==strncasecomp(pres->rep->name, "text/", 5) || @@ -712,6 +805,13 @@ PUBLIC HTStream* HTSaveToFile ARGS3( */ IsBinary = FALSE; + ret_obj->fp = LYNewBinFile (fnam); + if (!ret_obj->fp) { + HTAlert(CANNOT_OPEN_OUTPUT); + FREE(ret_obj); + return NULL; + } + /* * Any "application/foo" or other non-"text/foo" types that * are actually text but not checked, above, will be treated @@ -719,7 +819,8 @@ PUBLIC HTStream* HTSaveToFile ARGS3( * Unix folks don't need to know this, but we'll show it to * them, too. - FM */ - HTUserMsg2("Content-type: %s", pres->rep->name); + user_message("Content-type: %s", pres->rep->name); + sleep(MessageSecs); StrAllocCopy(WWW_Download_File,fnam); @@ -745,7 +846,8 @@ 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); @@ -770,8 +872,6 @@ Prepend_BASE: * Note that the markup will be technically invalid if a DOCTYPE * declaration, or HTML or HEAD tags, are present, and thus the * file may need editing for perfection. - FM - * - * Add timestamp (last reload). */ char *temp = NULL; @@ -781,19 +881,15 @@ Prepend_BASE: StrAllocCopy(temp, anchor->content_location); } if (temp) { - LYRemoveBlanks(temp); + collapse_spaces(temp); if (!is_url(temp)) { FREE(temp); } } fprintf(ret_obj->fp, - "<!-- X-URL: %s -->\n", anchor->address); - if (anchor->date && *anchor->date) - fprintf(ret_obj->fp, - "<!-- Date: %s -->\n", anchor->date); - fprintf(ret_obj->fp, - "<BASE HREF=\"%s\">\n\n", (temp ? temp : anchor->address)); + "<!-- X-URL: %s -->\n<BASE HREF=\"%s\">\n\n", + anchor->address, (temp ? temp : anchor->address)); FREE(temp); } if (LYPrependCharsetToSource && @@ -812,8 +908,8 @@ Prepend_BASE: if (anchor->charset && *anchor->charset) { StrAllocCopy(temp, anchor->charset); - LYRemoveBlanks(temp); - fprintf(ret_obj->fp, + collapse_spaces(temp); + fprintf(ret_obj->fp, "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=%s\">\n\n", temp); } @@ -837,15 +933,15 @@ PUBLIC HTStream* HTCompressed ARGS3( int n, i; BOOL can_present = FALSE; char fnam[256]; - char temp[256]; CONST char *suffix; char *uncompress_mask = NULL; char *compress_suffix = ""; + char *cp; CONST char *middle; FILE *fp = NULL; /* - * Deal with any inappropriate invocations of this function, + * Deal with any inappropriate invokations of this function, * or a download request, in which case we won't bother to * uncompress the file. - FM */ @@ -924,9 +1020,6 @@ PUBLIC HTStream* HTCompressed ARGS3( me->output_format = pres->rep_out; me->anchor = anchor; me->sink = sink; -#ifdef FNAMES_8_3 - me->idash = FALSE; -#endif /* * Remove any old versions of the file. - FM @@ -942,45 +1035,61 @@ PUBLIC HTStream* HTCompressed ARGS3( /* * Get a new temporary filename and substitute a suitable suffix. - FM */ - middle = NULL; - if (!strcasecomp(anchor->content_type, "text/html")) { - middle = HTML_SUFFIX; - middle++; /* point to 'h' of .htm(l) - kw */ - } else if (!strcasecomp(anchor->content_type, "text/plain")) { - middle = "txt"; - } else if (!strcasecomp(anchor->content_type, - "application/octet-stream")) { - middle = "bin"; - } else if ((suffix = - HTFileSuffix(HTAtom_for(anchor->content_type), NULL)) && - *suffix == '.') { +Compressed_tempname: + tempname(fnam, NEW_FILE); + if ((cp = strrchr(fnam, '.')) != NULL) { + middle = NULL; + if (!strcasecomp(anchor->content_type, "text/html")) { + middle = HTML_SUFFIX; + middle++; /* point to 'h' of .htm(l) - kw */ + } else if (!strcasecomp(anchor->content_type, "text/plain")) { + middle = "txt"; + } else if (!strcasecomp(anchor->content_type, + "application/octet-stream")) { + middle = "bin"; + } else if ((suffix = + HTFileSuffix(HTAtom_for(anchor->content_type), NULL)) && + *suffix == '.') { #if defined(VMS) || defined(FNAMES_8_3) - if (strchr(suffix + 1, '.') == NULL) + if (strchr(suffix + 1, '.') == NULL) #endif - middle = suffix + 1; - } - - temp[0] = 0; /* construct the suffix */ - if (middle) { + middle = suffix + 1; + } + if (middle) { + *cp = '\0'; #ifdef FNAMES_8_3 - me->idash = TRUE; /* remember position of '-' - kw */ - strcat(temp, "-"); /* NAME-htm, NAME-txt, etc. - hack for DOS */ + me->idash = strlen(fnam); /* remember position of '-' - kw */ + strcat(fnam, "-"); /* NAME-htm, NAME-txt, etc. - hack for DOS */ #else - strcat(temp, "."); /* NAME.html, NAME-txt etc. */ + strcat(fnam, "."); /* NAME.html, NAME-txt etc. */ #endif /* FNAMES_8_3 */ - strcat(temp, middle); + strcat(fnam, middle); #ifdef VMS - strcat(temp, "-"); /* NAME.html-gz, NAME.txt-gz, NAME.txt-Z etc.*/ + strcat(fnam, "-"); /* NAME.html-gz, NAME.txt-gz, NAME.txt-Z etc.*/ #else - strcat(temp, "."); /* NAME-htm.gz (DOS), NAME.html.gz (UNIX)etc.*/ + strcat(fnam, "."); /* NAME-htm.gz (DOS), NAME.html.gz (UNIX)etc.*/ #endif /* VMS */ + } else { + *(cp + 1) = '\0'; + } + } else { + strcat(fnam, "."); + } + strcat(fnam, compress_suffix); + /* + * It's not one of the suffixes checked for a + * spoof in tempname(), so check it now. - FM + */ + if ((fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + goto Compressed_tempname; } - strcat(temp, compress_suffix); /* * Open the file for receiving the compressed input stream. - FM */ - me->fp = LYOpenTemp (fnam, temp, "wb"); + me->fp = LYNewBinFile (fnam); if (!me->fp) { HTAlert(CANNOT_OPEN_TEMP); FREE(uncompress_mask); @@ -1138,7 +1247,7 @@ PUBLIC unsigned long LYVMS_FixedLengthRecords ARGS1(char *, filename) /* RMS supplies a user-mode channel (see FAB$L_FOP FAB$V_UFO doc) */ channel = (unsigned short) fab.fab$l_stv; - /* set up ACP interface structures */ + /* set up ACP interface strutures */ /* file information block, passed by descriptor; it's okay to start with an empty FIB after RMS has accessed the file for us */ fib_dsc.len = sizeof fib; diff --git a/src/HTForms.h b/src/HTForms.h index eb0784f2..c01d3df1 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, +extern int change_form_link PARAMS((struct link *form_link, int mode, 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 */ - unsigned maxlength; /* max width of data */ + int maxlength; /* max width of data */ int group; /* a group associated with the link * this is used for select's */ @@ -130,6 +130,9 @@ 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/HTInit.c b/src/HTInit.c index 6d46ee30..807df2fd 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -1,4 +1,4 @@ -/* Configuration-specific Initialization HTInit.c +/* Configuration-specific Initialialization HTInit.c ** ---------------------------------------- */ @@ -7,6 +7,7 @@ */ #include <HTUtils.h> +#include <tcp.h> /* Implements: */ @@ -22,20 +23,29 @@ #include <HTSaveToFile.h> /* LJM */ #include <userdefs.h> -#include <LYStrings.h> #include <LYUtils.h> #include <LYGlobalDefs.h> #include <LYSignal.h> +#include <LYSystem.h> #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + +#ifdef VMS +#define DISPLAY "DECW$DISPLAY" +#else +#define DISPLAY "DISPLAY" +#endif /* VMS */ + PRIVATE int HTLoadTypesConfigFile PARAMS((char *fn)); PRIVATE int HTLoadExtensionsConfigFile PARAMS((char *fn)); PUBLIC void HTFormatInit NOARGS { FILE *fp = NULL; + char *cp = NULL; #ifdef NeXT HTSetPresentation("application/postscript", "open %s", 1.0, 2.0, 0.0, 0); @@ -44,7 +54,7 @@ PUBLIC void HTFormatInit NOARGS HTSetPresentation("audio/basic", "open %s", 1.0, 2.0, 0.0, 0); HTSetPresentation("*", "open %s", 1.0, 0.0, 0.0, 0); #else - if (LYgetXDisplay() != 0) { /* Must have X11 */ + if ((cp = getenv(DISPLAY)) != NULL && *cp != '\0') { /* Must have X11 */ HTSetPresentation("application/postscript", "ghostview %s&", 1.0, 3.0, 0.0, 0); HTSetPresentation("image/gif", XLoadImageCommand, 1.0, 3.0, 0.0, 0); @@ -160,8 +170,13 @@ PUBLIC void HTFormatInit NOARGS /* These should override everything else. */ HTLoadTypesConfigFile(personal_type_map); } else { - char buffer[LY_MAXPATH]; - LYAddPathToHome(buffer, sizeof(buffer), personal_type_map); + char buffer[256]; +#ifdef VMS + sprintf(buffer, "sys$login:%s", personal_type_map); +#else + sprintf(buffer, "%s/%s", (Home_Dir() ? Home_Dir() : ""), + personal_type_map); +#endif HTLoadTypesConfigFile(buffer); } @@ -222,6 +237,7 @@ PRIVATE int ExitWithError PARAMS((char *txt)); PRIVATE int PassesTest PARAMS((struct MailcapEntry *mc)); #define LINE_BUF_SIZE 2048 +#define TMPFILE_NAME_SIZE 256 PRIVATE char *GetCommand ARGS2( char *, s, @@ -263,16 +279,27 @@ PRIVATE char *GetCommand ARGS2( PRIVATE char *Cleanse ARGS1( char *, s) { - LYTrimLeading(s); - LYTrimTrailing(s); - LYLowerCase(s); - return(s); + char *tmp, *news; + + /* strip leading white space */ + while (*s && isspace((unsigned char) *s)) + ++s; + news = s; + /* put in lower case */ + for (tmp=s; *tmp; ++tmp) { + *tmp = TOLOWER ((unsigned char)*tmp); + } + /* strip trailing white space */ + while ((tmp > news) && *--tmp && isspace((unsigned char) *tmp)) + *tmp = '\0'; + return(news); } PRIVATE int ProcessMailcapEntry ARGS2( FILE *, fp, struct MailcapEntry *, mc) { + int i, j; size_t rawentryalloc = 2000, len; char *rawentry, *s, *t, *LineBuf; @@ -308,7 +335,8 @@ PRIVATE int ProcessMailcapEntry ARGS2( FREE(LineBuf); - s = LYSkipBlanks(rawentry); + for (s = rawentry; *s && isspace((unsigned char) *s); ++s) + ; if (!*s) { /* totally blank entry -- quietly ignore */ FREE(rawentry); @@ -316,8 +344,11 @@ PRIVATE int ProcessMailcapEntry ARGS2( } s = strchr(rawentry, ';'); if (s == NULL) { - CTRACE(tfp, "ProcessMailcapEntry: Ignoring invalid mailcap entry: %s\n", - rawentry); + if (TRACE) { + fprintf(stderr, + "ProcessMailcapEntry: Ignoring invalid mailcap entry: %s\n", + rawentry); + } FREE(rawentry); return(0); } @@ -326,14 +357,20 @@ PRIVATE int ProcessMailcapEntry ARGS2( !strncasecomp(rawentry, "text/plain", 10)) { --s; *s = ';'; - CTRACE(tfp, "ProcessMailcapEntry: Ignoring mailcap entry: %s\n", - rawentry); + if (TRACE) { + fprintf(stderr, + "ProcessMailcapEntry: Ignoring mailcap entry: %s\n", + rawentry); + } FREE(rawentry); return(0); } - LYRemoveBlanks(rawentry); - LYLowerCase(rawentry); - + for (i = 0, j = 0; rawentry[i]; i++) { + if (rawentry[i] != ' ') { + rawentry[j++] = TOLOWER(rawentry[i]); + } + } + rawentry[j] = '\0'; mc->needsterminal = 0; mc->copiousoutput = 0; mc->needtofree = 1; @@ -350,7 +387,8 @@ PRIVATE int ProcessMailcapEntry ARGS2( if (!t) { goto assign_presentation; } - s = LYSkipBlanks(t); + s = t; + while (s && *s && isspace((unsigned char) *s)) ++s; while (s) { char *arg, *eq, *mallocd_string; @@ -369,7 +407,9 @@ PRIVATE int ProcessMailcapEntry ARGS2( } else if (eq && !strcmp(arg, "test")) { mc->testcommand = NULL; StrAllocCopy(mc->testcommand, eq); - CTRACE(tfp, "ProcessMailcapEntry: Found testcommand:%s\n", + if (TRACE) + fprintf(stderr, + "ProcessMailcapEntry: Found testcommand:%s\n", mc->testcommand); } else if (eq && !strcmp(arg, "description")) { mc->label = eq; @@ -389,21 +429,24 @@ PRIVATE int ProcessMailcapEntry ARGS2( if (mc->maxbytes < 0) mc->maxbytes = 0; } else if (strcmp(arg, "notes")) { /* IGNORE notes field */ - if (*arg) - CTRACE(tfp, "ProcessMailcapEntry: Ignoring mailcap flag '%s'.\n", - arg); + if (*arg && TRACE) + fprintf(stderr, + "ProcessMailcapEntry: Ignoring mailcap flag '%s'.\n", + arg); } } - FREE(mallocd_string); - s = t; + FREE(mallocd_string); + s = t; } assign_presentation: FREE(rawentry); if (PassesTest(mc)) { - CTRACE(tfp, "ProcessMailcapEntry Setting up conversion %s : %s\n", + if (TRACE) + fprintf(stderr, + "ProcessMailcapEntry Setting up conversion %s : %s\n", mc->contenttype, mc->command); HTSetPresentation(mc->contenttype, mc->command, mc->quality, 3.0, 0.0, mc->maxbytes); @@ -433,15 +476,22 @@ PRIVATE void BuildCommand ARGS5( break; case 'n': case 'F': - CTRACE(tfp, "BuildCommand: Bad mailcap \"test\" clause: %s\n", + if (TRACE) { + fprintf(stderr, + "BuildCommand: Bad mailcap \"test\" clause: %s\n", controlstring); + } case 's': if (TmpFileLen && TmpFileName) { if ((to - *pBuf) + TmpFileLen + 1 > Bufsize) { *to = '\0'; - CTRACE(tfp, "BuildCommand: Too long mailcap \"test\" clause,\n"); - CTRACE(tfp, " ignoring: %s%s...\n", + if (TRACE) { + fprintf(stderr, + "BuildCommand: Too long mailcap \"test\" clause,\n"); + fprintf(stderr, + " ignoring: %s%s...\n", *pBuf, TmpFileName); + } **pBuf = '\0'; return; } @@ -450,9 +500,11 @@ PRIVATE void BuildCommand ARGS5( } break; default: - CTRACE(tfp, + if (TRACE) { + fprintf(stderr, "BuildCommand: Ignoring unrecognized format code in mailcap file '%%%c'.\n", *from); + } break; } } else if (*from == '%') { @@ -462,9 +514,13 @@ PRIVATE void BuildCommand ARGS5( } if (to >= *pBuf + Bufsize) { (*pBuf)[Bufsize - 1] = '\0'; - CTRACE(tfp, "BuildCommand: Too long mailcap \"test\" clause,\n"); - CTRACE(tfp, " ignoring: %s...\n", + if (TRACE) { + fprintf(stderr, + "BuildCommand: Too long mailcap \"test\" clause,\n"); + fprintf(stderr, + " ignoring: %s...\n", *pBuf); + } **pBuf = '\0'; return; } @@ -476,7 +532,8 @@ PRIVATE int PassesTest ARGS1( struct MailcapEntry *, mc) { int result; - char *cmd, TmpFileName[LY_MAXPATH]; + char *cmd, TmpFileName[TMPFILE_NAME_SIZE]; + char *cp = NULL; /* * Make sure we have a command @@ -489,23 +546,31 @@ PRIVATE int PassesTest ARGS1( */ if (0 == strcasecomp(mc->testcommand, "test -n \"$DISPLAY\"")) { FREE(mc->testcommand); - CTRACE(tfp, "PassesTest: Testing for XWINDOWS environment.\n"); - if (LYgetXDisplay() != NULL) { - CTRACE(tfp, "PassesTest: Test passed!\n"); + if (TRACE) + fprintf(stderr, + "PassesTest: Testing for XWINDOWS environment.\n"); + if ((cp = getenv(DISPLAY)) != NULL && *cp != '\0') { + if (TRACE) + fprintf(stderr,"PassesTest: Test passed!\n"); return(0 == 0); } else { - CTRACE(tfp, "PassesTest: Test failed!\n"); + if (TRACE) + fprintf(stderr,"PassesTest: Test failed!\n"); return(-1 == 0); } } if (0 == strcasecomp(mc->testcommand, "test -z \"$DISPLAY\"")) { FREE(mc->testcommand); - CTRACE(tfp, "PassesTest: Testing for NON_XWINDOWS environment.\n"); - if (LYgetXDisplay() == NULL) { - CTRACE(tfp,"PassesTest: Test passed!\n"); + if (TRACE) + fprintf(stderr, + "PassesTest: Testing for NON_XWINDOWS environment.\n"); + if (!((cp = getenv(DISPLAY)) != NULL && *cp != '\0')) { + if (TRACE) + fprintf(stderr,"PassesTest: Test passed!\n"); return(0 == 0); } else { - CTRACE(tfp,"PassesTest: Test failed!\n"); + if (TRACE) + fprintf(stderr,"PassesTest: Test failed!\n"); return(-1 == 0); } } @@ -515,8 +580,11 @@ PRIVATE int PassesTest ARGS1( */ if (0 == strcasecomp(mc->testcommand, "test -n \"$LYNX_VERSION\"")){ FREE(mc->testcommand); - CTRACE(tfp, "PassesTest: Testing for LYNX environment.\n"); - CTRACE(tfp, "PassesTest: Test passed!\n"); + if (TRACE) { + fprintf(stderr, + "PassesTest: Testing for LYNX environment.\n"); + fprintf(stderr,"PassesTest: Test passed!\n"); + } return(0 == 0); } else /* @@ -524,17 +592,18 @@ PRIVATE int PassesTest ARGS1( */ if (0 == strcasecomp(mc->testcommand, "test -z \"$LYNX_VERSION\"")) { FREE(mc->testcommand); - CTRACE(tfp, "PassesTest: Testing for non-LYNX environment.\n"); - CTRACE(tfp, "PassesTest: Test failed!\n"); + if (TRACE) { + fprintf(stderr, + "PassesTest: Testing for non-LYNX environment.\n"); + fprintf(stderr,"PassesTest: Test failed!\n"); + } return(-1 == 0); } /* * Build the command and execute it. */ - if (LYOpenTemp(TmpFileName, HTML_SUFFIX, "w") == 0) - ExitWithError(CANNOT_OPEN_TEMP); - LYCloseTemp(TmpFileName); + tempname(TmpFileName, NEW_FILE); cmd = (char *)malloc(1024); if (!cmd) ExitWithError("Out of memory"); @@ -542,10 +611,10 @@ PRIVATE int PassesTest ARGS1( mc->testcommand, TmpFileName, strlen(TmpFileName)); - CTRACE(tfp, "PassesTest: Executing test command: %s\n", cmd); - result = LYSystem(cmd); + if (TRACE) + fprintf(stderr,"PassesTest: Executing test command: %s\n", cmd); + result = system(cmd); FREE(cmd); - LYRemoveTemp(TmpFileName); /* * Free the test command as well since @@ -553,11 +622,10 @@ PRIVATE int PassesTest ARGS1( */ FREE(mc->testcommand); - if (result) { - CTRACE(tfp,"PassesTest: Test failed!\n"); - } else { - CTRACE(tfp,"PassesTest: Test passed!\n"); - } + if (TRACE && result) + fprintf(stderr,"PassesTest: Test failed!\n"); + else if (TRACE) + fprintf(stderr,"PassesTest: Test passed!\n"); return(result == 0); } @@ -568,10 +636,14 @@ PRIVATE int ProcessMailcapFile ARGS1( struct MailcapEntry mc; FILE *fp; - CTRACE(tfp, "ProcessMailcapFile: Loading file '%s'.\n", + if (TRACE) + fprintf(stderr, + "ProcessMailcapFile: Loading file '%s'.\n", file); if ((fp = fopen(file, "r")) == NULL) { - CTRACE(tfp, "ProcessMailcapFile: Could not open '%s'.\n", + if (TRACE) + fprintf(stderr, + "ProcessMailcapFile: Could not open '%s'.\n", file); return(-1 == 0); } @@ -587,7 +659,7 @@ PRIVATE int ExitWithError ARGS1( char *, txt) { if (txt) - fprintf(tfp, "metamail: %s\n", txt); + fprintf(stderr, "metamail: %s\n", txt); #ifndef NOSIGHUP (void) signal(SIGHUP, SIG_DFL); #endif /* NOSIGHUP */ @@ -632,7 +704,9 @@ PUBLIC void HTFileInit NOARGS { FILE *fp; - CTRACE(tfp, "HTFileInit: Loading default (HTInit) extension maps.\n"); + if (TRACE) + fprintf(stderr, + "HTFileInit: Loading default (HTInit) extension maps.\n"); /* default suffix interpretation */ HTSetSuffix("*", "text/plain", "7bit", 1.0); @@ -640,7 +714,7 @@ PUBLIC void HTFileInit NOARGS #ifdef EXEC_SCRIPTS /* - * define these extensions for exec scripts. + * define these extentions for exec scripts. */ #ifndef VMS /* for csh exec links */ @@ -687,8 +761,6 @@ PUBLIC void HTFileInit NOARGS HTSetSuffix(".zip", "application/x-Zip File", "binary", 1.0); - HTSetSuffix(".bz2", "application/x-bzip2", "binary", 1.0); - HTSetSuffix(".uu", "application/x-UUencoded", "8bit", 1.0); HTSetSuffix(".hqx", "application/x-Binhex", "8bit", 1.0); @@ -835,7 +907,6 @@ PUBLIC void HTFileInit NOARGS HTSetSuffix(".ht3", "text/html", "8bit", 1.0); HTSetSuffix(".phtml", "text/html", "8bit", 1.0); HTSetSuffix(".shtml", "text/html", "8bit", 1.0); - HTSetSuffix(".sht", "text/html", "8bit", 1.0); HTSetSuffix(".htmlx", "text/html", "8bit", 1.0); HTSetSuffix(".htm", "text/html", "8bit", 1.0); HTSetSuffix(".html", "text/html", "8bit", 1.0); @@ -848,8 +919,13 @@ PUBLIC void HTFileInit NOARGS /* These should override everything else. */ HTLoadExtensionsConfigFile(personal_extension_map); } else { - char buffer[LY_MAXPATH]; - LYAddPathToHome(buffer, sizeof(buffer), personal_extension_map); + char buffer[256]; +#ifdef VMS + sprintf(buffer, "sys$login:%s", personal_extension_map); +#else + sprintf(buffer, "%s/%s", (Home_Dir() ? Home_Dir() : ""), + personal_extension_map); +#endif /* VMS */ /* These should override everything else. */ HTLoadExtensionsConfigFile(buffer); } @@ -925,13 +1001,17 @@ PRIVATE int HTLoadExtensionsConfigFile ARGS1( { char l[MAX_STRING_LEN],w[MAX_STRING_LEN],*ct; FILE *f; - int count = 0; + int x, count = 0; - CTRACE(tfp, "HTLoadExtensionsConfigFile: Loading file '%s'.\n", fn); + if (TRACE) + fprintf(stderr, + "HTLoadExtensionsConfigFile: Loading file '%s'.\n", fn); if ((f = fopen(fn,"r")) == NULL) { - CTRACE(tfp, "HTLoadExtensionsConfigFile: Could not open '%s'.\n", fn); - return count; + if (TRACE) + fprintf(stderr, + "HTLoadExtensionsConfigFile: Could not open '%s'.\n", fn); + return count; } while (!(HTGetLine(l,MAX_STRING_LEN,f))) { @@ -942,7 +1022,8 @@ PRIVATE int HTLoadExtensionsConfigFile ARGS1( if (!ct) outofmem(__FILE__, "HTLoadExtensionsConfigFile"); strcpy(ct,w); - LYLowerCase(ct); + for (x = 0; ct[x]; x++) + ct[x] = TOLOWER(ct[x]); while(l[0]) { HTGetWord(w, l, ' ', '\t'); @@ -951,10 +1032,15 @@ PRIVATE int HTLoadExtensionsConfigFile ARGS1( if (!ct) outofmem(__FILE__, "HTLoadExtensionsConfigFile"); - sprintf(ext, ".%s", w); - LYLowerCase(ext); + for (x = 0; w[x]; x++) + ext[x+1] = TOLOWER(w[x]); + ext[0] = '.'; + ext[strlen(w)+1] = '\0'; - CTRACE (tfp, "SETTING SUFFIX '%s' to '%s'.\n", ext, ct); + if (TRACE) { + fprintf (stderr, + "SETTING SUFFIX '%s' to '%s'.\n", ext, ct); + } if (strstr(ct, "tex") != NULL || strstr(ct, "postscript") != NULL || @@ -11,9 +11,8 @@ ** Being Overidden ** */ -#define DICKEY_TEST - #include <HTUtils.h> +#include <tcp.h> #define Lynx_HTML_Handler #include <HTChunk.h> @@ -41,7 +40,6 @@ #include <HTNestedList.h> #include <GridText.h> #include <LYSignal.h> -#include <LYStrings.h> #include <LYUtils.h> #include <LYMap.h> #include <LYList.h> @@ -49,6 +47,7 @@ #ifdef VMS #include <LYCurses.h> +#include <HTVMSUtils.h> #endif /* VMS */ #ifdef USE_COLOR_STYLE @@ -63,7 +62,7 @@ char Style_className[16384]; #include <LYexit.h> #include <LYLeaks.h> -#define STACKLEVEL(me) ((me->stack + MAX_NESTING - 1) - me->sp) +#define FREE(x) if (x) {free(x); x = NULL;} extern BOOL HTPassEightBitRaw; extern HTCJKlang HTCJK; @@ -82,7 +81,7 @@ PRIVATE HTStyleSheet * styleSheet; /* Application-wide */ /* Module-wide style cache */ -PRIVATE HTStyle *styles[HTML_ELEMENTS+31]; /* adding 24 nested list styles */ +PUBLIC HTStyle *styles[HTML_ELEMENTS+31]; /* adding 24 nested list styles */ /* and 3 header alignment styles */ /* and 3 div alignment styles */ PRIVATE HTStyle *default_style; @@ -100,15 +99,19 @@ PRIVATE void HTML_end_element PARAMS((HTStructured *me, int element_number, char **include)); +/* Forward declarations of routines +*/ +PRIVATE void get_styles NOPARAMS; +PRIVATE void change_paragraph_style PARAMS((HTStructured * me, + HTStyle * style)); + /* * If we have verbose_img set, display labels for images. */ -#define VERBOSE_IMG(value,src_type,string) \ - ((verbose_img) ? (newtitle = MakeNewTitle(value,src_type)): string) +#define VERBOSE_IMG(value,string) \ + ((verbose_img) ? (newtitle = MakeNewTitle(value)): string) -PRIVATE char* MakeNewTitle PARAMS((CONST char ** value, int src_type)); -PRIVATE char* MakeNewImageValue PARAMS((CONST char ** value)); -PRIVATE char* MakeNewMapValue PARAMS((const char ** value, const char* mapstr)); +PRIVATE char * MakeNewTitle(CONST char ** value); /* Set an internal flag that the next call to a stack-affecting method ** is only internal and the stack manipulation should be skipped. - kw @@ -176,18 +179,6 @@ PRIVATE void change_paragraph_style ARGS2(HTStructured *, me, HTStyle *,style) ** A C T I O N R O U T I N E S */ -/* FIXME: this should be amended to do the substitution only when not in a - * multibyte stream. - */ -#if EXP_JAPANESE_SPACES -#define FIX_JAPANESE_SPACES \ - (HTCJK == CHINESE || HTCJK == JAPANESE || HTCJK == TAIPEI) - /* don't replace '\n' with ' ' if Chinese or Japanese - HN - */ -#else -#define FIX_JAPANESE_SPACES 0 -#endif - /* Character handling ** ------------------ */ @@ -227,17 +218,10 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c) case HTML_TITLE: if (c == LY_SOFT_HYPHEN) return; - if (c != '\n' && c != '\t' && c != '\r') { + if (c != '\n' && c != '\t' && c != '\r') HTChunkPutc(&me->title, c); - } else if (FIX_JAPANESE_SPACES) { - if (c == '\t') { - HTChunkPutc(&me->title, ' '); - } else { - return; - } - } else { + else HTChunkPutc(&me->title, ' '); - } return; case HTML_STYLE: @@ -349,15 +333,13 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c) UPDATE_STYLE; } if (c == '\n') { - if (!FIX_JAPANESE_SPACES) { - if (me->in_word) { - if (HText_getLastChar(me->text) != ' ') { - me->inP = TRUE; - me->inLABEL = FALSE; - HText_appendCharacter(me->text, ' '); - } - me->in_word = NO; + if (me->in_word) { + if (HText_getLastChar(me->text) != ' ') { + me->inP = TRUE; + me->inLABEL = FALSE; + HText_appendCharacter(me->text, ' '); } + me->in_word = NO; } } else if (c == ' ' || c == '\t') { @@ -380,15 +362,15 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c) } /* end second switch */ if (c == '\n' || c == '\t') { - HText_setLastChar(me->text, ' '); /* set it to a generic separator */ + HText_setLastChar(me->text, ' '); /* set it to a generic seperater */ /* * \r's are ignored. In order to keep collapsing spaces * correctly we must default back to the previous - * separator if there was one + * seperater if there was one */ } else if (c == '\r' && HText_getLastChar(me->text) == ' ') { - HText_setLastChar(me->text, ' '); /* set it to a generic separator */ + HText_setLastChar(me->text, ' '); /* set it to a generic seperater */ } else { HText_setLastChar(me->text, c); } @@ -486,12 +468,10 @@ PUBLIC void HTML_put_string ARGS2(HTStructured *, me, CONST char *, s) UPDATE_STYLE; } if (c == '\n') { - if (!FIX_JAPANESE_SPACES) { - if (me->in_word) { - if (HText_getLastChar(me->text) != ' ') - HText_appendCharacter(me->text, ' '); - me->in_word = NO; - } + if (me->in_word) { + if (HText_getLastChar(me->text) != ' ') + HText_appendCharacter(me->text, ' '); + me->in_word = NO; } } else if (c == ' ' || c == '\t') { @@ -507,15 +487,15 @@ PUBLIC void HTML_put_string ARGS2(HTStructured *, me, CONST char *, s) /* set the Last Character */ if (c == '\n' || c == '\t') { - /* set it to a generic separator */ + /* set it to a generic seperater */ HText_setLastChar(me->text, ' '); } else if (c == '\r' && HText_getLastChar(me->text) == ' ') { /* * \r's are ignored. In order to keep collapsing * spaces correctly, we must default back to the - * previous separator, if there was one. So we - * set LastChar to a generic separator. + * previous seperator, if there was one. So we + * set LastChar to a generic seperater. */ HText_setLastChar(me->text, ' '); } else { @@ -636,7 +616,7 @@ PRIVATE void HTML_start_element ARGS6( char *I_value = NULL; char *I_name = NULL; char *temp = NULL; - int dest_char_set = UCLYhndl_for_unrec; + int dest_char_set = -1; HTParentAnchor *dest = NULL; /* An anchor's destination */ BOOL dest_ismap = FALSE; /* Is dest an image map script? */ BOOL UseBASE = TRUE; /* Resoved vs. BASE if present? */ @@ -691,30 +671,31 @@ PRIVATE void HTML_start_element ARGS6( if (TRACE) { - fprintf(tfp, "CSSTRIM:%s -> %d", myHash, hcode); + fprintf(stderr, "CSSTRIM:%s -> %d", myHash, hcode); if (hashStyles[hcode].code!=hcode) { char *rp=strrchr(myHash, '.'); - fprintf(tfp, " (undefined) %s\n", myHash); + fprintf(stderr, " (undefined) %s\n", myHash); if (rp) { int hcd; *rp='\0'; /* trim the class */ hcd = hash_code(myHash); - fprintf(tfp, "CSS:%s -> %d", myHash, hcd); + fprintf(stderr, "CSS:%s -> %d", myHash, hcd); if (hashStyles[hcd].code!=hcd) - fprintf(tfp, " (undefined) %s\n", myHash); + fprintf(stderr, " (undefined) %s\n", myHash); else - fprintf(tfp, " ca=%d\n", hashStyles[hcd].color); + fprintf(stderr, " ca=%d\n", hashStyles[hcd].color); } } else - fprintf(tfp, " ca=%d\n", hashStyles[hcode].color); + fprintf(stderr, " ca=%d\n", hashStyles[hcode].color); } if (displayStyles[element_number + STARTAT].color > -2) /* actually set */ { - CTRACE(tfp, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name); + if (TRACE) + fprintf(stderr, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name); HText_characterStyle(me->text, hcode, 1); } #endif /* USE_COLOR_STYLE */ @@ -737,8 +718,11 @@ PRIVATE void HTML_start_element ARGS6( char *related = NULL; StrAllocCopy(base, value[HTML_BASE_HREF]); - if (!(url_type = LYLegitimizeHREF(me, &base, TRUE, TRUE))) { - CTRACE(tfp, "HTML: BASE '%s' is not an absolute URL.\n", + if (!(url_type = LYLegitimizeHREF(me, (char**)&base, + TRUE, TRUE))) { + if (TRACE) + fprintf(stderr, + "HTML: BASE '%s' is not an absolute URL.\n", (base ? base : "")); if (me->inBadBASE == FALSE) HTAlert(BASE_NOT_ABSOLUTE); @@ -831,7 +815,7 @@ PRIVATE void HTML_start_element ARGS6( case HTML_META: if (present) - LYHandleMETA(me, present, value, include); + LYHandleMETA(me, present, value, (char **)&include); break; case HTML_TITLE: @@ -855,7 +839,7 @@ PRIVATE void HTML_start_element ARGS6( } } else { StrAllocCopy(href, value[HTML_LINK_HREF]); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); } /* @@ -873,7 +857,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '\0' && *href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); @@ -898,13 +882,15 @@ PRIVATE void HTML_start_element ARGS6( PARSE_ALL); StrAllocCopy(href, temp); FREE(temp); - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, (me->inBASE ? me->base_href : me->node_anchor->address)); } HTAnchor_setOwner(me->node_anchor, href); - CTRACE(tfp, "HTML: DOC OWNER '%s' found\n", href); + if (TRACE) + fprintf(stderr, + "HTML: DOC OWNER '%s' found\n", href); FREE(href); /* @@ -936,7 +922,10 @@ PRIVATE void HTML_start_element ARGS6( */ if (!strcasecomp(value[HTML_LINK_REL], "StyleSheet") || !strcasecomp(value[HTML_LINK_REL], "Style")) { - CTRACE(tfp, "HTML: StyleSheet link found.\n"); + if (TRACE) { + fprintf(stderr, + "HTML: StyleSheet link found.\n"); + } #ifdef LINKEDSTYLES if (href && *href != '\0') { @@ -956,16 +945,18 @@ PRIVATE void HTML_start_element ARGS6( res = style_readFromFile(href); } } - CTRACE(tfp, "CSS: StyleSheet=%s %d\n", href, res); + if (TRACE) + fprintf(stderr, "CSS: StyleSheet=%s %d\n", href, res); if (res == 0) HTAnchor_setStyle (me->node_anchor, href); } - else { - CTRACE(tfp, + else + if (TRACE) + fprintf(stderr, " non-local StyleSheets not yet implemented.\n"); - } #else - CTRACE(tfp, + if (TRACE) + fprintf(stderr, " StyleSheets not yet implemented.\n"); #endif FREE(href); @@ -1021,8 +1012,11 @@ PRIVATE void HTML_start_element ARGS6( !strcasecomp(value[HTML_LINK_REL], "Bibliography")) { StrAllocCopy(title, value[HTML_LINK_REL]); } else { - CTRACE(tfp, "HTML: LINK with REL=\"%s\" ignored.\n", + if (TRACE) { + fprintf(stderr, + "HTML: LINK with REL=\"%s\" ignored.\n", value[HTML_LINK_REL]); + } FREE(href); break; } @@ -1040,8 +1034,11 @@ PRIVATE void HTML_start_element ARGS6( } else if (!strcasecomp(value[HTML_LINK_REL], "Index")) { StrAllocCopy(href, indexfile); } else { - CTRACE(tfp, "HTML: LINK with REL=\"%s\" and no HREF ignored.\n", + if (TRACE) { + fprintf(stderr, + "HTML: LINK with REL=\"%s\" and no HREF ignored.\n", value[HTML_LINK_REL]); + } break; } StrAllocCopy(title, value[HTML_LINK_REL]); @@ -1073,7 +1070,7 @@ PRIVATE void HTML_start_element ARGS6( * fingers. - FM */ SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } /* @@ -1096,13 +1093,12 @@ PRIVATE void HTML_start_element ARGS6( dest_char_set = UCGetLYhndl_byMIME(value[HTML_LINK_CHARSET]); if (dest_char_set < 0) dest_char_set = UCLYhndl_for_unrec; - if (dest_char_set < 0) /* recover if not defined :-( */ - dest_char_set = UCLYhndl_for_unspec; /* always >= 0 */ } - if (dest) + if (dest && dest_char_set >= 0) HTAnchor_setUCInfoStage(dest, dest_char_set, UCT_STAGE_PARSER, UCT_SETBY_LINK); + dest_char_set = -1; } UPDATE_STYLE; if (!HText_hasToolbar(me->text) && @@ -1126,7 +1122,8 @@ PRIVATE void HTML_start_element ARGS6( { char tmp[1024]; sprintf(tmp, "link.%s.%s.%s", value[HTML_LINK_CLASS], title, value[HTML_LINK_CLASS]); - CTRACE(tfp, "CSSTRIM:link=%s\n", tmp); + if (TRACE) + fprintf(stderr, "CSSTRIM:link=%s\n", tmp); HText_characterStyle(me->text, hash_code(tmp), 1); HTML_put_string(me, title); @@ -1163,7 +1160,8 @@ PRIVATE void HTML_start_element ARGS6( StrAllocCopy(isindex_href, value[HTML_ISINDEX_HREF]); else StrAllocCopy(isindex_href, value[HTML_ISINDEX_ACTION]); - url_type = LYLegitimizeHREF(me, &isindex_href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&isindex_href, + TRUE, TRUE); /* * Check whether a base tag is in effect. @@ -1259,7 +1257,7 @@ PRIVATE void HTML_start_element ARGS6( value[HTML_FRAME_SRC] && *value[HTML_FRAME_SRC] != '\0') { StrAllocCopy(href, value[HTML_FRAME_SRC]); CHECK_FOR_INTERN(href); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Check whether a base tag is in effect. - FM @@ -1276,14 +1274,14 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '\0' && *href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } me->CurrentA = HTAnchor_findChildAndLink( me->node_anchor, /* Parent */ @@ -1331,7 +1329,7 @@ PRIVATE void HTML_start_element ARGS6( value[HTML_IFRAME_SRC] && *value[HTML_IFRAME_SRC] != '\0') { StrAllocCopy(href, value[HTML_IFRAME_SRC]); CHECK_FOR_INTERN(href); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Check whether a base tag is in effect. - FM @@ -1348,13 +1346,13 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '\0' && *href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); if (me->inA) - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); me->CurrentA = HTAnchor_findChildAndLink( me->node_anchor, /* Parent */ NULL, /* Tag */ @@ -1414,8 +1412,8 @@ PRIVATE void HTML_start_element ARGS6( case HTML_DIV: if (me->Division_Level < (MAX_NESTING - 1)) { me->Division_Level++; - } else { - CTRACE(tfp, + } else if (TRACE) { + fprintf(stderr, "HTML: ****** Maximum nesting of %d divisions exceeded!\n", MAX_NESTING); } @@ -1543,20 +1541,13 @@ PRIVATE void HTML_start_element ARGS6( break; case HTML_P: - LYHandleP(me, present, value, include, TRUE); + LYHandleP(me, present, value, (char **)&include, TRUE); break; case HTML_BR: UPDATE_STYLE; CHECK_ID(HTML_GEN_ID); - /* Add a \r (new line) if these three conditions are true: - * 1. We are not collapsing BR's, and - * 2. The previous line has text on it, or - * 3. This line has text on it. - * Otherwise, don't do anything. -DH 980814, TD 980827 - */ - if ((LYCollapseBRs == FALSE && - HText_PreviousLineSize(me->text, FALSE)) || + if ((LYCollapseBRs == FALSE) || HText_LastLineSize(me->text, FALSE)) { HText_setLastChar(me->text, ' '); /* absorb white space */ HText_appendCharacter(me->text, '\r'); @@ -1684,7 +1675,9 @@ PRIVATE void HTML_start_element ARGS6( case HTML_TAB: if (!present) { /* Bad tag. Must have at least one attribute. - FM */ - CTRACE(tfp, "HTML: TAB tag has no attributes. Ignored.\n"); + if (TRACE) + fprintf(stderr, + "HTML: TAB tag has no attributes. Ignored.\n"); break; } UPDATE_STYLE; @@ -1697,7 +1690,9 @@ PRIVATE void HTML_start_element ARGS6( * the ALIGN and DP attributes implemented. - FM */ HTML_put_character(me, ' '); - CTRACE(tfp, "HTML: ALIGN not 'left'. Using space instead of TAB.\n"); + if (TRACE) + fprintf(stderr, + "HTML: ALIGN not 'left'. Using space instead of TAB.\n"); } else if (!LYoverride_default_alignment(me) && me->current_default_alignment != HT_LEFT) { @@ -1708,7 +1703,9 @@ PRIVATE void HTML_start_element ARGS6( * that the alignment be HT_LEFT. - FM */ HTML_put_character(me, ' '); - CTRACE(tfp, "HTML: Not HT_LEFT. Using space instead of TAB.\n"); + if (TRACE) + fprintf(stderr, + "HTML: Not HT_LEFT. Using space instead of TAB.\n"); } else if ((present[HTML_TAB_TO] && value[HTML_TAB_TO] && *value[HTML_TAB_TO]) || @@ -1747,7 +1744,9 @@ PRIVATE void HTML_start_element ARGS6( if (target < column || target > HText_getMaximumColumn(me->text)) { HTML_put_character(me, ' '); - CTRACE(tfp, "HTML: Column out of bounds. Using space instead of TAB.\n"); + if (TRACE) + fprintf(stderr, + "HTML: Column out of bounds. Using space instead of TAB.\n"); } else { for (i = column; i < target; i++) HText_appendCharacter(me->text, ' '); @@ -1790,7 +1789,7 @@ PRIVATE void HTML_start_element ARGS6( */ #ifdef NOTUSED_FOTEMODS if (me->inFONT == TRUE) - HTML_end_element(me, HTML_FONT, &include); + HTML_end_element(me, HTML_FONT, (char **)&include); #endif /* NOTUSED_FOTEMODS */ /* @@ -1816,15 +1815,18 @@ PRIVATE void HTML_start_element ARGS6( * Can't display both underline and bold at same time. */ if (me->inBoldA == TRUE || me->inBoldH == TRUE) { - CTRACE(tfp, "Underline Level is %d\n", me->Underline_Level); + if (TRACE) + fprintf(stderr,"Underline Level is %d\n", me->Underline_Level); break; } if (me->inUnderline == FALSE) { HText_appendCharacter(me->text, LY_UNDERLINE_START_CHAR); me->inUnderline = TRUE; - CTRACE(tfp,"Beginning underline\n"); + if (TRACE) + fprintf(stderr,"Beginning underline\n"); } else { - CTRACE(tfp,"Underline Level is %d\n", me->Underline_Level); + if (TRACE) + fprintf(stderr,"Underline Level is %d\n", me->Underline_Level); } break; @@ -1930,14 +1932,16 @@ PRIVATE void HTML_start_element ARGS6( (!strcasecomp(value[HTML_NOTE_CLASS], "CAUTION") || !strcasecomp(value[HTML_NOTE_CLASS], "WARNING"))) { StrAllocCopy(note, value[HTML_NOTE_CLASS]); - LYUpperCase(note); + for (i = 0; note[i] != '\0'; i++) + note[i] = TOUPPER(note[i]); StrAllocCat(note, ":"); } else if (present && present[HTML_NOTE_ROLE] && value[HTML_NOTE_ROLE] && (!strcasecomp(value[HTML_NOTE_ROLE], "CAUTION") || !strcasecomp(value[HTML_NOTE_ROLE], "WARNING"))) { StrAllocCopy(note, value[HTML_NOTE_ROLE]); - LYUpperCase(note); + for (i = 0; note[i] != '\0'; i++) + note[i] = TOUPPER(note[i]); StrAllocCat(note, ":"); } else { StrAllocCopy(note, "NOTE:"); @@ -2393,7 +2397,7 @@ PRIVATE void HTML_start_element ARGS6( */ if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } /* * Set to know we are in an anchor. @@ -2440,7 +2444,7 @@ PRIVATE void HTML_start_element ARGS6( } else { StrAllocCopy(href, value[HTML_A_HREF]); } - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Deal with our ftp gateway kludge. - FM @@ -2448,8 +2452,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] = href[i+7]) != 0; i++) - ; + for (i = 0; href[i]; i++) + href[i] = href[i+7]; } /* @@ -2472,7 +2476,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '\0' && *href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); @@ -2492,7 +2496,9 @@ PRIVATE void HTML_start_element ARGS6( ** Found TYPE="internal link" but not in a valid context ** where we have written it. - kw */ - CTRACE(tfp, "HTML: Found invalid HREF=\"%s\" TYPE=\"%s\"!\n", + if (TRACE) + fprintf(stderr, + "HTML: Found invalid HREF=\"%s\" TYPE=\"%s\"!\n", href, temp); FREE(temp); } @@ -2533,8 +2539,6 @@ PRIVATE void HTML_start_element ARGS6( dest_char_set = UCGetLYhndl_byMIME(temp); if (dest_char_set < 0) { dest_char_set = UCLYhndl_for_unrec; - if (dest_char_set < 0) /* recover if not defined :-( */ - dest_char_set = UCLYhndl_for_unspec; /* always >= 0 */ } } if (title != NULL || dest_ismap == TRUE || dest_char_set >= 0) { @@ -2546,7 +2550,7 @@ PRIVATE void HTML_start_element ARGS6( HTAnchor_setTitle(dest, title); if (dest && dest_ismap) dest->isISMAPScript = TRUE; - if (dest) { + if (dest && dest_char_set >= 0) { /* ** Load the anchor's chartrans structures. ** This should be done more intelligently @@ -2563,6 +2567,7 @@ PRIVATE void HTML_start_element ARGS6( FREE(temp); dest = NULL; dest_ismap = FALSE; + dest_char_set = -1; FREE(title); } me->CurrentANum = HText_beginAnchor(me->text, @@ -2577,7 +2582,7 @@ PRIVATE void HTML_start_element ARGS6( */ if (href == NULL && me->inBoldA == FALSE) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, &include); + HTML_end_element(me, HTML_A, (char **)&include); } #endif /* NOTUSED_FOTEMODS */ FREE(href); @@ -2596,12 +2601,16 @@ PRIVATE void HTML_start_element ARGS6( )) != NULL) { if (dest->isISMAPScript == TRUE) { dest_ismap = TRUE; - CTRACE(tfp, "HTML: '%s' is an ISMAP script\n", + if (TRACE) + fprintf(stderr, + "HTML: '%s' is an ISMAP script\n", dest->address); } else if (present && present[HTML_IMG_ISMAP]) { dest_ismap = TRUE; dest->isISMAPScript = TRUE; - CTRACE(tfp, "HTML: Designating '%s' as an ISMAP script\n", + if (TRACE) + fprintf(stderr, + "HTML: Designating '%s' as an ISMAP script\n", dest->address); } } @@ -2617,7 +2626,7 @@ PRIVATE void HTML_start_element ARGS6( value[HTML_IMG_USEMAP] && *value[HTML_IMG_USEMAP]) { StrAllocCopy(map_href, value[HTML_IMG_USEMAP]); CHECK_FOR_INTERN(map_href); - url_type = LYLegitimizeHREF(me, &map_href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&map_href, TRUE, TRUE); /* * If map_href ended up zero-length or otherwise doesn't * have a hash, it can't be valid, so ignore it. - FM @@ -2665,7 +2674,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&map_href, + LYFillLocalFileURL((char **)&map_href, ((UseBASE && me->inBASE) ? me->base_href : me->node_anchor->address)); UseBASE = TRUE; @@ -2734,16 +2743,16 @@ PRIVATE void HTML_start_element ARGS6( LYTrimTail(alt_string); if (*alt_string == '\0') { if (map_href) { - StrAllocCopy(alt_string, (title ? title : - MakeNewMapValue(value,"USEMAP"))); + StrAllocCopy(alt_string, (title ? + title : "[USEMAP]")); } else if (dest_ismap) { - StrAllocCopy(alt_string, (title ? title : - MakeNewMapValue(value,"ISMAP"))); + StrAllocCopy(alt_string, (title ? + title : "[ISMAP]")); } else if (me->inA == TRUE && dest) { StrAllocCopy(alt_string, (title ? title : - VERBOSE_IMG(value, HTML_IMG_SRC, "[LINK]"))); + VERBOSE_IMG(value, "[LINK]"))); } else { StrAllocCopy(alt_string, @@ -2751,24 +2760,24 @@ PRIVATE void HTML_start_element ARGS6( ((present && present[HTML_IMG_ISOBJECT]) ? "(OBJECT)" : - VERBOSE_IMG(value, HTML_IMG_SRC, "[INLINE]")))); + VERBOSE_IMG(value, "[INLINE]")))); } } } } else if (map_href) { - StrAllocCopy(alt_string, (title ? title : - MakeNewMapValue(value,"USEMAP"))); + StrAllocCopy(alt_string, (title ? + title : "[USEMAP]")); } else if ((dest_ismap == TRUE) || (me->inA && present && present[HTML_IMG_ISMAP])) { - StrAllocCopy(alt_string, (title ? title : - MakeNewMapValue(value,"ISMAP"))); + StrAllocCopy(alt_string, (title ? + title : "[ISMAP]")); } else if (me->inA == TRUE && dest) { StrAllocCopy(alt_string, (title ? title : - VERBOSE_IMG(value, HTML_IMG_SRC, "[LINK]"))); + VERBOSE_IMG(value, "[LINK]"))); } else { if (pseudo_inline_alts || clickable_images) @@ -2776,19 +2785,22 @@ PRIVATE void HTML_start_element ARGS6( ((present && present[HTML_IMG_ISOBJECT]) ? "(OBJECT)" : - VERBOSE_IMG(value, HTML_IMG_SRC, "[INLINE]")))); + VERBOSE_IMG(value, "[INLINE]")))); else StrAllocCopy(alt_string, (title ? title : "")); } if (*alt_string == '\0' && map_href) { - StrAllocCopy(alt_string, MakeNewMapValue(value,"USEMAP")); + StrAllocCopy(alt_string, "[USEMAP]"); } - CTRACE(tfp, "HTML IMG: USEMAP=%d ISMAP=%d ANCHOR=%d PARA=%d\n", + if (TRACE) { + fprintf(stderr, + "HTML IMG: USEMAP=%d ISMAP=%d ANCHOR=%d PARA=%d\n", map_href ? 1 : 0, (dest_ismap == TRUE) ? 1 : 0, me->inA, me->inP); + } /* * Check for an ID attribute. - FM @@ -2809,7 +2821,7 @@ PRIVATE void HTML_start_element ARGS6( present && present[HTML_IMG_SRC] && value[HTML_IMG_SRC] && *value[HTML_IMG_SRC] != '\0') { StrAllocCopy(href, value[HTML_IMG_SRC]); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Check whether a base tag is in effect. - FM @@ -2826,7 +2838,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '\0' && *href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); @@ -2844,7 +2856,7 @@ PRIVATE void HTML_start_element ARGS6( if (dest_ismap) { HTML_put_character(me, ' '); me->in_word = NO; - HTML_put_string(me, MakeNewMapValue(value,"ISMAP")); + HTML_put_string(me, "[ISMAP]"); } else if (dest) { HTML_put_character(me, ' '); me->in_word = NO; @@ -2905,7 +2917,7 @@ PRIVATE void HTML_start_element ARGS6( present[HTML_IMG_ISOBJECT]) ? ((map_href || dest_ismap) ? "(IMAGE)" : "(OBJECT)") : - VERBOSE_IMG(value, HTML_IMG_SRC, "[IMAGE]"))); + VERBOSE_IMG(value, "[IMAGE]"))); if (id_string && !map_href) { if ((ID_A = HTAnchor_findChildAndLink( me->node_anchor, /* Parent */ @@ -2960,7 +2972,7 @@ PRIVATE void HTML_start_element ARGS6( ((present && present[HTML_IMG_ISOBJECT]) ? "(IMAGE)" : - VERBOSE_IMG(value, HTML_IMG_SRC, "[IMAGE]"))); + VERBOSE_IMG(value, "[IMAGE]"))); } else { HTML_put_character(me, ' '); /* space char may be ignored */ me->in_word = NO; @@ -3012,7 +3024,7 @@ PRIVATE void HTML_start_element ARGS6( if (dest_ismap) { HTML_put_character(me, ' ');/* space char may be ignored */ me->in_word = NO; - HTML_put_string(me, MakeNewMapValue(value,"ISMAP")); + HTML_put_string(me, "[ISMAP]"); } else if (dest) { HTML_put_character(me, ' ');/* space char may be ignored */ me->in_word = NO; @@ -3151,7 +3163,7 @@ PRIVATE void HTML_start_element ARGS6( */ StrAllocCopy(href, value[HTML_AREA_HREF]); CHECK_FOR_INTERN(href); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Check whether a BASE tag is in effect, and use it @@ -3173,7 +3185,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((((me->inBASE && *href != '\0') && !(*href == '#' && LYSeekFragAREAinCur == TRUE))) @@ -3256,7 +3268,7 @@ PRIVATE void HTML_start_element ARGS6( me->inFIG = TRUE; if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } if (!present || (present && !present[HTML_FIG_ISOBJECT])) { @@ -3275,7 +3287,7 @@ PRIVATE void HTML_start_element ARGS6( value[HTML_FIG_SRC] && *value[HTML_FIG_SRC] != '\0') { StrAllocCopy(href, value[HTML_FIG_SRC]); CHECK_FOR_INTERN(href); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href) { /* * Check whether a base tag is in effect. - FM @@ -3292,7 +3304,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); @@ -3435,7 +3447,7 @@ PRIVATE void HTML_start_element ARGS6( value[HTML_OVERLAY_SRC] && *value[HTML_OVERLAY_SRC] != '\0') { StrAllocCopy(href, value[HTML_OVERLAY_SRC]); CHECK_FOR_INTERN(href); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href) { /* * Check whether a base tag is in effect. - FM @@ -3452,14 +3464,14 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } me->CurrentA = HTAnchor_findChildAndLink( me->node_anchor, /* Parent */ @@ -3548,20 +3560,21 @@ PRIVATE void HTML_start_element ARGS6( if (present[HTML_APPLET_CODEBASE] && value[HTML_APPLET_CODEBASE] && *value[HTML_APPLET_CODEBASE]) { StrAllocCopy(base, value[HTML_APPLET_CODEBASE]); - LYRemoveBlanks(base); + collapse_spaces(base); TRANSLATE_AND_UNESCAPE_TO_STD(&base); /* * Force it to be a directory. - FM */ if (*base == '\0') StrAllocCopy(base, "/"); - LYAddHtmlSep(&base); - url_type = LYLegitimizeHREF(me, &base, TRUE, FALSE); + if (base[strlen(base)-1] != '/') + StrAllocCat(base, "/"); + url_type = LYLegitimizeHREF(me, (char**)&base, TRUE, FALSE); /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&base, + LYFillLocalFileURL((char **)&base, (me->inBASE ? me->base_href : me->node_anchor->address)); @@ -3587,7 +3600,7 @@ PRIVATE void HTML_start_element ARGS6( } StrAllocCopy(code, value[HTML_APPLET_CODE]); - url_type = LYLegitimizeHREF(me, &code, TRUE, FALSE); + url_type = LYLegitimizeHREF(me, (char**)&code, TRUE, FALSE); href = HTParse(code, base, PARSE_ALL); FREE(base); FREE(code); @@ -3640,7 +3653,7 @@ PRIVATE void HTML_start_element ARGS6( value[HTML_BGSOUND_SRC] && *value[HTML_BGSOUND_SRC] != '\0') { StrAllocCopy(href, value[HTML_BGSOUND_SRC]); CHECK_FOR_INTERN(href); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href == '\0') { FREE(href); break; @@ -3661,7 +3674,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); @@ -3754,7 +3767,7 @@ PRIVATE void HTML_start_element ARGS6( value[HTML_EMBED_SRC] && *value[HTML_EMBED_SRC] != '\0') { StrAllocCopy(href, value[HTML_EMBED_SRC]); CHECK_FOR_INTERN(href); - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href != '\0') { /* * Check whether a base tag is in effect. - FM @@ -3771,7 +3784,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '#' && me->inBASE) ? me->base_href : me->node_anchor->address)); @@ -3898,9 +3911,12 @@ PRIVATE void HTML_start_element ARGS6( * that one now. - FM */ if (me->inFORM) { - CTRACE(tfp, "HTML: Missing FORM end tag. Faking it!\n"); + if (TRACE) { + fprintf(stderr, + "HTML: Missing FORM end tag. Faking it!\n"); + } SET_SKIP_STACK(HTML_FORM); - HTML_end_element(me, HTML_FORM, include); + HTML_end_element(me, HTML_FORM, (char **)&include); } /* @@ -3918,7 +3934,7 @@ PRIVATE void HTML_start_element ARGS6( * Prepare to do housekeeping on the reference. - FM */ StrAllocCopy(action, value[HTML_FORM_ACTION]); - url_type = LYLegitimizeHREF(me, &action, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&action, TRUE, TRUE); /* * Check whether a base tag is in effect. Note that @@ -3979,7 +3995,11 @@ PRIVATE void HTML_start_element ARGS6( if (present && present[HTML_FORM_ENCTYPE] && value[HTML_FORM_ENCTYPE] && *value[HTML_FORM_ENCTYPE]) { StrAllocCopy(enctype, value[HTML_FORM_ENCTYPE]); - LYLowerCase(enctype); + /* + * Force the enctype value to all lower case. - FM + */ + for (cp = enctype; *cp; cp++) + *cp = TOLOWER(*cp); } if (present) { @@ -4073,11 +4093,12 @@ PRIVATE void HTML_start_element ARGS6( */ if (!me->inFORM) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: BUTTON tag not within FORM tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } /* * We'll process it, since the chances of a crash are @@ -4227,7 +4248,6 @@ PRIVATE void HTML_start_element ARGS6( int chars; BOOL UseALTasVALUE = FALSE; BOOL HaveSRClink = FALSE; - char* ImageSrc = NULL; BOOL IsSubmitOrReset = FALSE; /* init */ @@ -4280,7 +4300,8 @@ PRIVATE void HTML_start_element ARGS6( if (me->inFORM) HText_DisableCurrentForm(); #endif /* NOTDEFINED */ - CTRACE(tfp, "HTML: Ignoring TYPE=\"range\"\n"); + if (TRACE) + fprintf(stderr, "HTML: Ignoring TYPE=\"range\"\n"); break; } else if (!strcasecomp(I.type, "file")) { @@ -4302,7 +4323,8 @@ PRIVATE void HTML_start_element ARGS6( if (me->inFORM) HText_DisableCurrentForm(); #endif /* NOTDEFINED */ - CTRACE(tfp, "HTML: Ignoring TYPE=\"file\"\n"); + if (TRACE) + fprintf(stderr, "HTML: Ignoring TYPE=\"file\"\n"); break; } else if (!strcasecomp(I.type, "button")) { @@ -4319,11 +4341,12 @@ PRIVATE void HTML_start_element ARGS6( */ if (!me->inFORM) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: INPUT tag not within FORM tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } /* * We'll process it, since the chances of a crash are @@ -4338,11 +4361,12 @@ PRIVATE void HTML_start_element ARGS6( */ if (me->inTEXTAREA) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: Missing TEXTAREA end tag.\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } } @@ -4350,11 +4374,13 @@ PRIVATE void HTML_start_element ARGS6( * Check for an unclosed SELECT, try to close it if found. */ if (me->inSELECT) { - CTRACE(tfp, "HTML: Missing SELECT end tag, faking it...\n"); + if (TRACE) { + fprintf(stderr, "HTML: Missing SELECT end tag, faking it...\n"); + } if (me->sp->tag_number != HTML_SELECT) { SET_SKIP_STACK(HTML_SELECT); } - HTML_end_element(me, HTML_SELECT, include); + HTML_end_element(me, HTML_SELECT, (char **)&include); } /* @@ -4384,12 +4410,7 @@ PRIVATE void HTML_start_element ARGS6( */ UseALTasVALUE = TRUE; } - if (verbose_img && !clickable_images && - present && present[HTML_INPUT_SRC] && - value[HTML_INPUT_SRC] && *value[HTML_INPUT_SRC] && - I.type && !strcasecomp(I.type, "image")) { - ImageSrc = MakeNewImageValue(value); - } else if (clickable_images == TRUE && + if (clickable_images == TRUE && present && present[HTML_INPUT_SRC] && value[HTML_INPUT_SRC] && *value[HTML_INPUT_SRC] && I.type && !strcasecomp(I.type, "image")) { @@ -4400,7 +4421,7 @@ PRIVATE void HTML_start_element ARGS6( * SRC's value a link if it's still not zero-length * legitiimizing it. - FM */ - url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href) { /* * Check whether a base tag is in effect. - FM @@ -4417,7 +4438,7 @@ PRIVATE void HTML_start_element ARGS6( /* * Check whether to fill in localhost. - FM */ - LYFillLocalFileURL(&href, + LYFillLocalFileURL((char **)&href, ((*href != '#' && me->inBASE) ? me->base_href : @@ -4425,7 +4446,7 @@ PRIVATE void HTML_start_element ARGS6( if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } me->CurrentA = HTAnchor_findChildAndLink( me->node_anchor, /* Parent */ @@ -4435,7 +4456,7 @@ PRIVATE void HTML_start_element ARGS6( HText_beginAnchor(me->text, me->inUnderline, me->CurrentA); if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_START_CHAR); - HTML_put_string(me, VERBOSE_IMG(value,HTML_INPUT_SRC,"[IMAGE]")); + HTML_put_string(me, VERBOSE_IMG(value, "[IMAGE]")); if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_END_CHAR); HText_endAnchor(me->text, 0); @@ -4458,7 +4479,7 @@ PRIVATE void HTML_start_element ARGS6( if (I.type && !strcasecomp(I.type, "hidden")) { me->HiddenValue = TRUE; - current_char_set = LATIN1; /* Default ISO-Latin1 */ + current_char_set = 0; /* Default ISO-Latin1 */ LYUseDefaultRawMode = TRUE; HTMLSetCharacterHandling(current_char_set); } @@ -4516,11 +4537,6 @@ PRIVATE void HTML_start_element ARGS6( */ StrAllocCopy(I_value, "Submit"); I.value = I_value; - } else if ( ImageSrc ) { - /* [IMAGE]-Submit with verbose images and not clickable images. - * Use ImageSrc if no other alt or value is supplied. --LE - */ - I.value = ImageSrc; } if (present && present[HTML_INPUT_CHECKED]) I.checked = YES; @@ -4698,11 +4714,12 @@ PRIVATE void HTML_start_element ARGS6( */ if (!me->inFORM) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: TEXTAREA start tag not within FORM tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } /* * Too likely to cause a crash, so we'll ignore it. - FM @@ -4788,16 +4805,17 @@ PRIVATE void HTML_start_element ARGS6( */ if (me->inSELECT) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: SELECT start tag in SELECT element. Faking SELECT end tag. *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } if (me->sp->tag_number != HTML_SELECT) { SET_SKIP_STACK(HTML_SELECT); } - HTML_end_element(me, HTML_SELECT, include); + HTML_end_element(me, HTML_SELECT, (char **)&include); } /* @@ -4805,7 +4823,7 @@ PRIVATE void HTML_start_element ARGS6( */ LYHandleSELECT(me, present, (CONST char **)value, - include, + (char **)&include, TRUE); break; @@ -4821,11 +4839,12 @@ PRIVATE void HTML_start_element ARGS6( */ if (!me->inSELECT) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: OPTION tag not within SELECT tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } /* @@ -5021,11 +5040,11 @@ PRIVATE void HTML_start_element ARGS6( */ if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } if (me->Underline_Level > 0) { SET_SKIP_STACK(HTML_U); - HTML_end_element(me, HTML_U, include); + HTML_end_element(me, HTML_U, (char **)&include); } me->inTABLE = TRUE; if (!strcmp(me->sp->style->name, "Preformatted")) { @@ -5035,8 +5054,8 @@ PRIVATE void HTML_start_element ARGS6( } if (me->Division_Level < (MAX_NESTING - 1)) { me->Division_Level++; - } else { - CTRACE(tfp, + } else if (TRACE) { + fprintf(stderr, "HTML: ****** Maximum nesting of %d divisions/tables exceeded!\n", MAX_NESTING); } @@ -5075,11 +5094,11 @@ PRIVATE void HTML_start_element ARGS6( */ if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } if (me->Underline_Level > 0) { SET_SKIP_STACK(HTML_U); - HTML_end_element(me, HTML_U, include); + HTML_end_element(me, HTML_U, (char **)&include); } UPDATE_STYLE; if (HText_LastLineSize(me->text, FALSE)) { @@ -5127,11 +5146,11 @@ PRIVATE void HTML_start_element ARGS6( */ if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } if (me->Underline_Level > 0) { SET_SKIP_STACK(HTML_U); - HTML_end_element(me, HTML_U, include); + HTML_end_element(me, HTML_U, (char **)&include); } UPDATE_STYLE; CHECK_ID(HTML_TR_ID); @@ -5144,11 +5163,11 @@ PRIVATE void HTML_start_element ARGS6( */ if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } if (me->Underline_Level > 0) { SET_SKIP_STACK(HTML_U); - HTML_end_element(me, HTML_U, include); + HTML_end_element(me, HTML_U, (char **)&include); } UPDATE_STYLE; CHECK_ID(HTML_COL_ID); @@ -5157,11 +5176,11 @@ PRIVATE void HTML_start_element ARGS6( case HTML_TH: if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } if (me->Underline_Level > 0) { SET_SKIP_STACK(HTML_U); - HTML_end_element(me, HTML_U, include); + HTML_end_element(me, HTML_U, (char **)&include); } UPDATE_STYLE; CHECK_ID(HTML_TD_ID); @@ -5175,11 +5194,11 @@ PRIVATE void HTML_start_element ARGS6( case HTML_TD: if (me->inA) { SET_SKIP_STACK(HTML_A); - HTML_end_element(me, HTML_A, include); + HTML_end_element(me, HTML_A, (char **)&include); } if (me->Underline_Level > 0) { SET_SKIP_STACK(HTML_U); - HTML_end_element(me, HTML_U, include); + HTML_end_element(me, HTML_U, (char **)&include); } UPDATE_STYLE; CHECK_ID(HTML_TD_ID); @@ -5204,12 +5223,11 @@ PRIVATE void HTML_start_element ARGS6( } /* end switch */ -#if defined(DICKEY_TEST) - if (HTML_dtd.tags[ElementNumber].contents != SGML_EMPTY) -#endif - { + if (HTML_dtd.tags[ElementNumber].contents != SGML_EMPTY) { if (me->skip_stack > 0) { - CTRACE(tfp, "HTML:begin_element: internal call (level %d), leaving on stack - %s\n", + if (TRACE) + fprintf(stderr, + "HTML:begin_element: internal call (level %d), leaving on stack - %s\n", me->skip_stack, me->sp->style->name); me->skip_stack--; return; @@ -5217,7 +5235,7 @@ PRIVATE void HTML_start_element ARGS6( if (me->sp == me->stack) { if (me->stack_overrun == FALSE) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "HTML: ****** Maximum nesting of %d tags exceeded!\n", MAX_NESTING); @@ -5229,19 +5247,21 @@ PRIVATE void HTML_start_element ARGS6( return; } - CTRACE(tfp,"HTML:begin_element[%d]: adding style to stack - %s\n", - (int) STACKLEVEL(me), - me->new_style->name); (me->sp)--; me->sp[0].style = me->new_style; /* Stack new style */ me->sp[0].tag_number = ElementNumber; + + if (TRACE) + fprintf(stderr,"HTML:begin_element: adding style to stack - %s\n", + me->new_style->name); } -#if defined(DICKEY_TEST) && defined(USE_COLOR_STYLE) +#if defined(USE_COLOR_STYLE) /* end empty tags straight away */ if (HTML_dtd.tags[ElementNumber].contents == SGML_EMPTY) { - CTRACE(tfp, "STYLE:begin_element:ending EMPTY element style\n"); + if (TRACE) + fprintf(stderr, "STYLE:begin_element:ending EMPTY element style\n"); #if !defined(USE_HASH) HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF); #else @@ -5268,12 +5288,14 @@ PRIVATE void HTML_start_element ARGS6( #if defined(PREVAIL) start=strrchr(Style_className, '.'); if (start) - strcpy(prevailing_class, (start+1)); + strcpy(prevailing_class, (char*)(start+1)); else strcpy(prevailing_class, ""); #endif - CTRACE(tfp, "CSS:%s (trimmed %s, SGML_EMPTY)\n", Style_className, tmp); + + if (TRACE) + fprintf(stderr, "CSS:%s (trimmed %s, SGML_EMPTY)\n", Style_className, tmp); } } #endif /* USE_COLOR_STYLE */ @@ -5305,7 +5327,7 @@ PRIVATE void HTML_end_element ARGS3( #ifdef CAREFUL /* parser assumed to produce good nesting */ if (element_number != me->sp[0].tag_number && HTML_dtd.tags[element_number].contents != SGML_EMPTY) { - CTRACE(tfp, + fprintf(stderr, "HTMLText: end of element %s when expecting end of %s\n", HTML_dtd.tags[element_number].name, HTML_dtd.tags[me->sp->tag_number].name); @@ -5349,7 +5371,9 @@ PRIVATE void HTML_end_element ARGS3( BreakFlag = TRUE; } if (me->skip_stack > 0) { - CTRACE(tfp, "HTML:end_element: Internal call (level %d), leaving on stack - %s\n", + if (TRACE) + fprintf(stderr, + "HTML:end_element: Internal call (level %d), leaving on stack - %s\n", me->skip_stack, me->sp->style->name); me->skip_stack--; } else if (me->stack_overrun == TRUE && @@ -5395,11 +5419,13 @@ PRIVATE void HTML_end_element ARGS3( return; } else if (me->sp < (me->stack + MAX_NESTING - 1)) { (me->sp)++; - CTRACE(tfp, "HTML:end_element[%d]: Popped style off stack - %s\n", - (int) STACKLEVEL(me), + if (TRACE) + fprintf(stderr, + "HTML:end_element: Popped style off stack - %s\n", me->sp->style->name); } else { - CTRACE(tfp, + if (TRACE) + fprintf(stderr, "Stack underflow error! Tried to pop off more styles than exist in stack\n"); } } @@ -5411,10 +5437,11 @@ PRIVATE void HTML_end_element ARGS3( */ if (me->inTEXTAREA && element_number != HTML_TEXTAREA) { if (TRACE) { - fprintf(tfp, "Bad HTML: Missing TEXTAREA end tag\n"); + fprintf(stderr, "Bad HTML: Missing TEXTAREA end tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } } @@ -5428,9 +5455,9 @@ PRIVATE void HTML_end_element ARGS3( switch(element_number) { case HTML_HTML: - if (me->inA || me->inSELECT || me->inTEXTAREA) { + if (me->inA || me->inSELECT || me->inTEXTAREA) if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: %s%s%s%s%s not closed before HTML end tag *****\n", me->inSELECT ? "SELECT" : "", (me->inSELECT && me->inTEXTAREA) ? ", " : "", @@ -5438,10 +5465,10 @@ PRIVATE void HTML_end_element ARGS3( ((me->inSELECT || me->inTEXTAREA) && me->inA) ? ", " : "", me->inA ? "A" : ""); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } - } break; case HTML_HEAD: @@ -5488,7 +5515,7 @@ PRIVATE void HTML_end_element ARGS3( ((MBM_A_subdescript[i] && *MBM_A_subdescript[i]) ? MBM_A_subdescript[i] : "(none)")); - LYEntify(&temp, TRUE); + LYEntify((char **)&temp, TRUE); StrAllocCat(*include, temp); StrAllocCat(*include, "<BR><EM> Filepath:</EM> "); @@ -5496,7 +5523,7 @@ PRIVATE void HTML_end_element ARGS3( ((MBM_A_subbookmark[i] && *MBM_A_subbookmark[i]) ? MBM_A_subbookmark[i] : "(unknown)")); - LYEntify(&temp, TRUE); + LYEntify((char **)&temp, TRUE); StrAllocCat(*include, temp); FREE(temp); StrAllocCat(*include, "</H2>"); @@ -5513,8 +5540,10 @@ PRIVATE void HTML_end_element ARGS3( * we'll just ignore. - FM */ HTChunkTerminate(&me->style_block); - CTRACE(tfp, "HTML: STYLE content =\n%s\n", + if (TRACE) { + fprintf(stderr, "HTML: STYLE content =\n%s\n", me->style_block.data); + } HTChunkClear(&me->style_block); break; @@ -5524,15 +5553,17 @@ PRIVATE void HTML_end_element ARGS3( * we'll just ignore. - FM */ HTChunkTerminate(&me->script); - CTRACE(tfp, "HTML: SCRIPT content =\n%s\n", + if (TRACE) { + fprintf(stderr, "HTML: SCRIPT content =\n%s\n", me->script.data); + } HTChunkClear(&me->script); break; case HTML_BODY: - if (me->inA || me->inSELECT || me->inTEXTAREA) { + if (me->inA || me->inSELECT || me->inTEXTAREA) if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: %s%s%s%s%s not closed before BODY end tag *****\n", me->inSELECT ? "SELECT" : "", (me->inSELECT && me->inTEXTAREA) ? ", " : "", @@ -5540,10 +5571,10 @@ PRIVATE void HTML_end_element ARGS3( ((me->inSELECT || me->inTEXTAREA) && me->inA) ? ", " : "", me->inA ? "A" : ""); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } - } break; case HTML_FRAMESET: @@ -5625,7 +5656,7 @@ PRIVATE void HTML_end_element ARGS3( case HTML_P: LYHandleP(me, (CONST BOOL*)0, (CONST char **)0, - include, + (char **)&include, FALSE); break; @@ -5656,9 +5687,11 @@ PRIVATE void HTML_end_element ARGS3( if (me->inUnderline && me->Underline_Level < 1) { HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; - CTRACE(tfp, "Ending underline\n"); + if (TRACE) + fprintf(stderr,"Ending underline\n"); } else { - CTRACE(tfp, "Underline Level is %d\n", me->Underline_Level); + if (TRACE) + fprintf(stderr,"Underline Level is %d\n", me->Underline_Level); } break; @@ -5754,8 +5787,11 @@ PRIVATE void HTML_end_element ARGS3( case HTML_MENU: case HTML_DIR: me->List_Nesting_Level--; - CTRACE(tfp, "HTML_end_element: Reducing List Nesting Level to %d\n", + if (TRACE) { + fprintf(stderr, + "HTML_end_element: Reducing List Nesting Level to %d\n", me->List_Nesting_Level); + } change_paragraph_style(me, me->sp->style); /* Often won't really change */ UPDATE_STYLE; if (me->List_Nesting_Level >= 0) @@ -5879,7 +5915,8 @@ PRIVATE void HTML_end_element ARGS3( * pass a dummy start tag to the SGML parser so that it * will resume the accumulation of OBJECT content. - FM */ - CTRACE(tfp, "HTML: Nested OBJECT tags. Recycling.\n"); + if (TRACE) + fprintf(stderr, "HTML: Nested OBJECT tags. Recycling.\n"); if (*include == NULL) { StrAllocCopy(*include, "<OBJECT>"); } else { @@ -5898,12 +5935,13 @@ PRIVATE void HTML_end_element ARGS3( * we have bad HTML or otherwise misparsed. - FM */ if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: Unmatched OBJECT start and end tags. Discarding content:\n%s\n", me->object.data); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } goto End_Object; } @@ -5913,7 +5951,8 @@ PRIVATE void HTML_end_element ARGS3( * assuming we weren't tripped up by comments * or quoted attributes. - FM */ - CTRACE(tfp, "HTML:OBJECT content:\n%s\n", me->object.data); + if (TRACE) + fprintf(stderr, "HTML:OBJECT content:\n%s\n", me->object.data); /* * OBJECTs with DECLARE should be saved but @@ -5926,7 +5965,8 @@ PRIVATE void HTML_end_element ARGS3( if (me->object_declare == TRUE) { if (me->object_id && *me->object_id) LYHandleID(me, me->object_id); - CTRACE(tfp, "HTML: DECLAREd OBJECT. Ignoring!\n"); + if (TRACE) + fprintf(stderr, "HTML: DECLAREd OBJECT. Ignoring!\n"); goto End_Object; } @@ -5939,7 +5979,8 @@ PRIVATE void HTML_end_element ARGS3( if (me->object_name != NULL) { if (me->object_id && *me->object_id) LYHandleID(me, me->object_id); - CTRACE(tfp, "HTML: NAMEd OBJECT. Ignoring!\n"); + if (TRACE) + fprintf(stderr, "HTML: NAMEd OBJECT. Ignoring!\n"); goto End_Object; } @@ -5965,19 +6006,22 @@ PRIVATE void HTML_end_element ARGS3( } StrAllocCat(data, "</OBJECT>"); StrAllocCat(*include, data); - CTRACE(tfp, "HTML: Recycling nested OBJECT%s.\n", + if (TRACE) + fprintf(stderr, "HTML: Recycling nested OBJECT%s.\n", (e > 1) ? "s" : ""); FREE(data); goto End_Object; } else { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: Unmatched OBJECT start and end tags. Discarding content.\n"); + goto End_Object; } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); + goto End_Object; } - goto End_Object; } } @@ -5985,7 +6029,9 @@ PRIVATE void HTML_end_element ARGS3( * If it's content has SHAPES, convert it to FIG. - FM */ if (me->object_shapes == TRUE) { - CTRACE(tfp, "HTML: OBJECT has SHAPES. Converting to FIG.\n"); + if (TRACE) + fprintf(stderr, + "HTML: OBJECT has SHAPES. Converting to FIG.\n"); StrAllocCat(*include, "<FIG ISOBJECT IMAGEMAP"); if (me->object_ismap == TRUE) StrAllocCat(*include, " IMAGEMAP"); @@ -6013,7 +6059,9 @@ PRIVATE void HTML_end_element ARGS3( * convert it to IMG. - FM */ if (me->object_usemap != NULL) { - CTRACE(tfp, "HTML: OBJECT has USEMAP. Converting to IMG.\n"); + if (TRACE) + fprintf(stderr, + "HTML: OBJECT has USEMAP. Converting to IMG.\n"); StrAllocCat(*include, "<IMG ISOBJECT"); if (me->object_id != NULL) { @@ -6170,10 +6218,11 @@ End_Object: */ if (!me->inFORM) { if (TRACE) { - fprintf(tfp, "Bad HTML: Unmatched FORM end tag\n"); + fprintf(stderr, "Bad HTML: Unmatched FORM end tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } } @@ -6190,16 +6239,17 @@ End_Object: */ if (me->inSELECT) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: Open SELECT at FORM end. Faking SELECT end tag. *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } if (me->sp->tag_number != HTML_SELECT) { SET_SKIP_STACK(HTML_SELECT); } - HTML_end_element(me, HTML_SELECT, include); + HTML_end_element(me, HTML_SELECT, (char **)&include); } /* @@ -6248,10 +6298,11 @@ End_Object: */ if (!me->inTEXTAREA) { if (TRACE) { - fprintf(tfp, "Bad HTML: Unmatched TEXTAREA end tag\n"); + fprintf(stderr, "Bad HTML: Unmatched TEXTAREA end tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } break; } @@ -6427,10 +6478,11 @@ End_Object: */ if (!me->inSELECT) { if (TRACE) { - fprintf(tfp, "Bad HTML: Unmatched SELECT end tag *****\n"); + fprintf(stderr, "Bad HTML: Unmatched SELECT end tag *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } break; } @@ -6450,11 +6502,12 @@ End_Object: */ if (!me->inFORM) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: SELECT end tag not within FORM element *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } /* * Hopefully won't crash, so we'll ignore it. - kw @@ -6631,15 +6684,15 @@ End_Object: */ if (end) *end='\0'; - hcode = hash_code(lookfrom && *lookfrom ? lookfrom : &tmp[1]); - CTRACE(tfp, "CSS:%s (trimmed %s, END_ELEMENT)\n", Style_className, tmp); + hcode=hash_code(lookfrom && *lookfrom ? lookfrom : &tmp[1]); + if (TRACE) + fprintf(stderr, "CSS:%s (trimmed %s, END_ELEMENT)\n", Style_className, tmp); } -#if defined(DICKEY_TEST) if (HTML_dtd.tags[element_number].contents != SGML_EMPTY) -#endif { - CTRACE(tfp, "STYLE:end_element: ending non-EMPTY style\n"); + if (TRACE) + fprintf(stderr, "STYLE:end_element: ending non-EMPTY style\n"); #if !defined(USE_HASH) HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF); #else @@ -6650,7 +6703,7 @@ End_Object: { char *dot=strrchr(Style_className,'.'); LYstrncpy(prevailing_class, - dot ? (dot+1) : "", + dot ? (char*)(dot+1) : "", (TEMPSTRINGSIZE - 1)); } #endif @@ -6726,18 +6779,19 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me) HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; me->Underline_Level = 0; - CTRACE(tfp,"HTML_free: Ending underline\n"); + if (TRACE) + fprintf(stderr,"HTML_free: Ending underline\n"); } if (me->inA) { - HTML_end_element(me, HTML_A, &include); + HTML_end_element(me, HTML_A, (char **)&include); me->inA = FALSE; } if (me->inFONT) { - HTML_end_element(me, HTML_FONT, &include); + HTML_end_element(me, HTML_FONT, (char **)&include); me->inFONT = FALSE; } if (me->inFORM) { - HTML_end_element(me, HTML_FORM, &include); + HTML_end_element(me, HTML_FORM, (char **)&include); me->inFORM = FALSE; } if (me->option.size > 0) { @@ -6747,18 +6801,20 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me) * have gone very wrong. - kw */ if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: SELECT or OPTION not ended properly *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } HTChunkTerminate(&me->option); /* * Output the left-over data as text, maybe it was invalid * markup meant to be shown somewhere. - kw */ - CTRACE(tfp, "HTML_free: ***** leftover option data: %s\n", + if (TRACE) + fprintf(stderr, "HTML_free: ***** leftover option data: %s\n", me->option.data); HTML_put_string(me, me->option.data); HTChunkClear(&me->option); @@ -6770,18 +6826,20 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me) * have gone very wrong. - kw */ if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: TEXTAREA not used properly *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } HTChunkTerminate(&me->textarea); /* * Output the left-over data as text, maybe it was invalid * markup meant to be shown somewhere. - kw */ - CTRACE(tfp, "HTML_free: ***** leftover textarea data: %s\n", + if (TRACE) + fprintf(stderr, "HTML_free: ***** leftover textarea data: %s\n", me->textarea.data); HTML_put_string(me, me->textarea.data); HTChunkClear(&me->textarea); @@ -6794,14 +6852,14 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me) if (!dump_output_immediately && HText_sourceAnchors(me->text) < 1 && HText_HiddenLinkCount(me->text) > 0) { - HTML_start_element(me, HTML_P, 0, 0, -1, &include); + HTML_start_element(me, HTML_P, 0, 0, -1, (char **)&include); HTML_put_character(me, '['); - HTML_start_element(me, HTML_EM, 0, 0, -1, &include); + HTML_start_element(me, HTML_EM, 0, 0, -1, (char **)&include); HTML_put_string(me, "Document has only hidden links. Use the 'l'ist command."); - HTML_end_element(me, HTML_EM, &include); + HTML_end_element(me, HTML_EM, (char **)&include); HTML_put_character(me, ']'); - HTML_end_element(me, HTML_P, &include); + HTML_end_element(me, HTML_P, (char **)&include); } /* @@ -6816,15 +6874,16 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me) * have gone very wrong. - kw */ if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: SELECT or OPTION not ended properly *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } if (TRACE) { HTChunkTerminate(&me->option); - fprintf(tfp, "HTML_free: ***** leftover option data: %s\n", + fprintf(stderr, "HTML_free: ***** leftover option data: %s\n", me->option.data); } HTChunkClear(&me->option); @@ -6836,15 +6895,16 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me) * have gone very wrong. - kw */ if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: TEXTAREA not used properly *****\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } if (TRACE) { HTChunkTerminate(&me->textarea); - fprintf(tfp, "HTML_free: ***** leftover textarea data: %s\n", + fprintf(stderr, "HTML_free: ***** leftover textarea data: %s\n", me->textarea.data); } HTChunkClear(&me->textarea); @@ -6887,15 +6947,15 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e) me->Underline_Level = 0; } if (me->inA) { - HTML_end_element(me, HTML_A, &include); + HTML_end_element(me, HTML_A, (char **)&include); me->inA = FALSE; } if (me->inFONT) { - HTML_end_element(me, HTML_FONT, &include); + HTML_end_element(me, HTML_FONT, (char **)&include); me->inFONT = FALSE; } if (me->inFORM) { - HTML_end_element(me, HTML_FORM, &include); + HTML_end_element(me, HTML_FORM, (char **)&include); me->inFORM = FALSE; } @@ -6912,10 +6972,10 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e) * have gone very wrong. - kw */ if (TRACE) { - fprintf(tfp, + fprintf(stderr, "HTML_abort: SELECT or OPTION not ended properly *****\n"); HTChunkTerminate(&me->option); - fprintf(tfp, "HTML_abort: ***** leftover option data: %s\n", + fprintf(stderr, "HTML_abort: ***** leftover option data: %s\n", me->option.data); } HTChunkClear(&me->option); @@ -6927,10 +6987,10 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e) * have gone very wrong. - kw */ if (TRACE) { - fprintf(tfp, + fprintf(stderr, "HTML_abort: TEXTAREA not used properly *****\n"); HTChunkTerminate(&me->textarea); - fprintf(tfp, "HTML_abort: ***** leftover textarea data: %s\n", + fprintf(stderr, "HTML_abort: ***** leftover textarea data: %s\n", me->textarea.data); } HTChunkClear(&me->textarea); @@ -6967,7 +7027,6 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e) */ PRIVATE void get_styles NOARGS { - styleSheet = DefaultStyle(); default_style = HTStyleNamed(styleSheet, "Normal"); styles[HTML_H1] = HTStyleNamed(styleSheet, "Heading1"); @@ -7034,17 +7093,6 @@ PRIVATE void get_styles NOARGS styles[HTML_LISTING] = HTStyleNamed(styleSheet, "Listing"); } -/* - * If we're called from another module, make sure we've initialized styles - * array first. - */ -PUBLIC HTStyle *LYstyles ARGS1(int, style_number) -{ - if (styles[style_number] == 0) - get_styles(); - return styles[style_number]; -} - /* P U B L I C */ @@ -7106,6 +7154,7 @@ PUBLIC HTStructured* HTML_new ARGS3( * array is not necessarily the same as it was from 'get_styles()'. So * we reinitialize the whole thing. */ + styleSheet = DefaultStyle(); get_styles(); me->isa = &HTMLPresentation; @@ -7266,16 +7315,16 @@ PUBLIC HTStructured* HTML_new ARGS3( LYUCcharset *p_in = HTAnchor_getUCInfoStage(me->node_anchor, UCT_STAGE_MIME); if (p_in->enc == UCT_ENC_CJK && HTCJK == NOCJK) { - HTAnchor_resetUCInfoStage(me->node_anchor, LATIN1, + HTAnchor_resetUCInfoStage(me->node_anchor, 0, UCT_STAGE_MIME, UCT_SETBY_DEFAULT); - HTAnchor_setUCInfoStage(me->node_anchor, LATIN1, + HTAnchor_setUCInfoStage(me->node_anchor, 0, UCT_STAGE_MIME, UCT_SETBY_DEFAULT); - HTAnchor_resetUCInfoStage(me->node_anchor, LATIN1, + HTAnchor_resetUCInfoStage(me->node_anchor, 0, UCT_STAGE_PARSER, UCT_SETBY_DEFAULT); - HTAnchor_setUCInfoStage(me->node_anchor, LATIN1, + HTAnchor_setUCInfoStage(me->node_anchor, 0, UCT_STAGE_PARSER, UCT_SETBY_DEFAULT); } @@ -7460,54 +7509,19 @@ PUBLIC int HTLoadError ARGS3( return -number; } -PRIVATE char * MakeNewTitle ARGS2(CONST char **, value, int, src_type) -{ - char *ptr; - char *newtitle = NULL; - StrAllocCopy(newtitle, "["); - ptr = strrchr(value[src_type], '/'); - if (!ptr) { - StrAllocCat(newtitle, value[src_type]); - } else { - StrAllocCat(newtitle, ptr + 1); - } - StrAllocCat(newtitle, "]"); - return newtitle; -} - -PRIVATE char * MakeNewImageValue ARGS1(CONST char **, value) +PRIVATE char * MakeNewTitle(CONST char ** value) { char *ptr; char *newtitle = NULL; StrAllocCopy(newtitle, "["); - ptr = strrchr(value[HTML_INPUT_SRC], '/'); + ptr = strrchr(value[HTML_IMG_SRC], '/'); if (!ptr) { - StrAllocCat(newtitle, value[HTML_INPUT_SRC]); + StrAllocCat(newtitle, value[HTML_IMG_SRC]); } else { StrAllocCat(newtitle, ptr + 1); } - StrAllocCat(newtitle, "]-Submit"); - return newtitle; -} - -PRIVATE char * MakeNewMapValue ARGS2(const char **, value, const char*, mapstr) -{ - char *ptr; - char *newtitle = NULL; - - StrAllocCopy(newtitle, "["); - StrAllocCat(newtitle,mapstr); /* ISMAP or USEMAP */ - if ( verbose_img ) { - StrAllocCat(newtitle,":"); - ptr = strrchr(value[HTML_IMG_SRC], '/'); - if (!ptr) { - StrAllocCat(newtitle, value[HTML_IMG_SRC]); - } else { - StrAllocCat(newtitle, ptr + 1); - } - } StrAllocCat(newtitle, "]"); return newtitle; } @@ -207,7 +207,9 @@ struct _HTStructured { int tag_charset; /* charset for attribute values etc. */ }; -extern HTStyle *LYstyles PARAMS((int style_number)); +extern HTStyle *styles[HTML_ELEMENTS+31]; /* adding 24 nested list styles */ + /* and 3 header alignment styles */ + /* and 3 div alignment styles */ /* * Semi-Private functions. - FM diff --git a/src/HTSaveToFile.h b/src/HTSaveToFile.h index 4374f7a4..a13ad78a 100644 --- a/src/HTSaveToFile.h +++ b/src/HTSaveToFile.h @@ -1,10 +1,6 @@ #ifndef HTSAVETOFILE_H #define HTSAVETOFILE_H -#include <HTUtils.h> -#include <HTStream.h> -#include <HTFormat.h> - extern HTStream * HTSaveToFile PARAMS(( HTPresentation * pres, HTParentAnchor * anchor, diff --git a/src/LYBookmark.c b/src/LYBookmark.c index dc635da3..5ce5c754 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -1,23 +1,30 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTAlert.h> #include <LYUtils.h> #include <LYStrings.h> #include <LYBookmark.h> #include <LYGlobalDefs.h> #include <LYSignal.h> +#include <LYSystem.h> #include <LYKeymap.h> -#include <LYCharUtils.h> /* need for META charset */ -#include <LYCharSets.h> /* need for LYHaveCJKCharacterSet */ +#include <LYCharUtils.h> #include <LYCurses.h> #include <GridText.h> +#ifdef DOSPATH +#include <HTDOS.h> +#endif #ifdef VMS +#include <HTVMSUtils.h> #include <nam.h> -extern BOOLEAN HadVMSInterrupt; /* Flag from cleanup_sig() AST */ +extern BOOLEAN HadVMSInterrupt; /* Flag from cleanup_sig() AST */ #endif /* VMS */ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + PUBLIC char *MBM_A_subbookmark[MBM_V_MAXFILES+1]; PUBLIC char *MBM_A_subdescript[MBM_V_MAXFILES+1]; @@ -40,32 +47,34 @@ PRIVATE char * convert_mosaic_bookmark_file PARAMS((char *filename_buffer)); PUBLIC char * get_bookmark_filename ARGS1( char **, URL) { + char URL_buffer[256]; static char filename_buffer[256]; char string_buffer[256]; FILE *fp; int MBM_tmp; /* - * Multi_Bookmarks support. - FMG & FM - * Let user select a bookmark file. + * Multi_Bookmarks support. - FMG & FM + * Let user select a bookmark file. */ MBM_tmp = select_multi_bookmarks(); if (MBM_tmp == -2) - /* + /* * Zero-length pointer flags a cancel. - FM - */ - return(""); + */ + return(""); if (MBM_tmp == -1) { sprintf(string_buffer, BOOKMARK_FILE_NOT_DEFINED, key_for_func(LYK_OPTIONS)); - HTAlert(string_buffer); + _statusline(string_buffer); + sleep(AlertSecs); /* * Space flags an undefined selection. - FMG */ return(" "); } else { - /* + /* * Save the filepath as a global. The system path will be * loaded into to the (static) filename_buffer as the return * value, the URL will be allocated into *URL, and we also @@ -77,27 +86,28 @@ PUBLIC char * get_bookmark_filename ARGS1( } /* - * Seek it in the home path. - FM + * Seek it in the home path. - FM */ filename_buffer[255] = '\0'; LYAddPathToHome(filename_buffer, sizeof(filename_buffer), BookmarkPage); - CTRACE(tfp, "\nget_bookmark_filename: SEEKING %s\n AS %s\n\n", + if (TRACE) + fprintf(stderr, "\nget_bookmark_filename: SEEKING %s\n AS %s\n\n", BookmarkPage, filename_buffer); if ((fp = fopen(filename_buffer,"r")) != NULL) { goto success; } /* - * Failure. + * Failure. */ return(NULL); success: /* - * We now have the file open. - * Check if it is a mosaic hotlist. + * We now have the file open. + * Check if it is a mosaic hotlist. */ if (fgets(string_buffer, 255, fp) && !strncmp(string_buffer, "ncsa-xmosaic-hotlist-format-1", 29)) { @@ -108,13 +118,34 @@ success: is_mosaic_hotlist = TRUE; fclose(fp); newname = convert_mosaic_bookmark_file(filename_buffer); - LYLocalFileToURL(URL, newname); +#ifdef DOSPATH + sprintf(URL_buffer, "file://localhost/%s", + HTDOS_wwwName((char *)newname)); +#else +#ifdef VMS + sprintf(URL_buffer,"file://localhost%s", + HTVMS_wwwName((char *)newname)); +#else + sprintf(URL_buffer,"file://localhost%s", newname); +#endif /* VMS */ +#endif /* DOSPATH */ } else { fclose(fp); is_mosaic_hotlist = FALSE; - LYLocalFileToURL(URL, filename_buffer); +#ifdef DOSPATH + sprintf(URL_buffer,"file://localhost/%s", + HTDOS_wwwName((char *)filename_buffer)); +#else +#ifdef VMS + sprintf(URL_buffer,"file://localhost%s", + HTVMS_wwwName((char *)filename_buffer)); +#else + sprintf(URL_buffer,"file://localhost%s", filename_buffer); +#endif /* VMS */ +#endif /* DOSPATH */ } + StrAllocCopy(*URL, URL_buffer); return(filename_buffer); /* bookmark file exists */ } /* big end */ @@ -124,17 +155,26 @@ success: * file for handling as a Lynx bookmark file. - FM */ PRIVATE char * convert_mosaic_bookmark_file ARGS1( - char *, filename_buffer) + char *, filename_buffer) { static char newfile[256]; + static BOOLEAN first = TRUE; FILE *fp, *nfp; char buf[BUFSIZ]; int line = -2; char *endline; - LYRemoveTemp(newfile); - if ((nfp = LYOpenTemp(newfile, HTML_SUFFIX, "w")) == NULL) { - LYMBM_statusline(NO_TEMP_FOR_HOTLIST); + if (first) { + tempname(newfile, NEW_FILE); + first = FALSE; +#ifdef VMS + } else { + remove(newfile); /* Remove duplicates on VMS. */ +#endif /* VMS */ + } + + if ((nfp = fopen(newfile, "w")) == NULL) { + LYMBM_statusline(NO_TEMP_FOR_HOTLIST); sleep(AlertSecs); return (""); } @@ -157,23 +197,20 @@ PRIVATE char * convert_mosaic_bookmark_file ARGS1( if((line % 2) == 0) { /* even lines */ if(*buf != '\0') { strtok(buf," "); /* kill everything after the space */ - fprintf(nfp,"<LI><a href=\"%s\">",buf); /* the URL */ + fprintf(nfp,"<LI><a href=\"%s\">",buf); /* the URL */ } } else { /* odd lines */ - fprintf(nfp,"%s</a>\n",buf); /* the title */ + fprintf(nfp,"%s</a>\n",buf); /* the title */ } - } + } /* else - ignore the line (this gets rid of first two lines) */ line++; } - LYCloseTempFP(nfp); + fclose(nfp); fclose(fp); return(newfile); } -PRIVATE BOOLEAN have8bit PARAMS((char *Title)); -PRIVATE char* title_convert8bit PARAMS((char *Title)); - /* * Adds a link to a bookmark file, creating the file * if it doesn't already exist, and making sure that @@ -182,8 +219,8 @@ PRIVATE char* title_convert8bit PARAMS((char *Title)); * to that file. - FM */ PUBLIC void save_bookmark_link ARGS2( - char *, address, - char *, title) + char *, address, + char *, title) { FILE *fp; BOOLEAN first_time = FALSE; @@ -199,32 +236,32 @@ PUBLIC void save_bookmark_link ARGS2( HText *text; /* - * Make sure we were passed something to save. - FM + * Make sure we were passed something to save. - FM */ if (!(address && *address)) { - HTAlert(MALFORMED_ADDRESS); + HTAlert(MALFORMED_ADDRESS); return; } /* - * Offer a choice of bookmark files, - * or get the default. - FMG + * Offer a choice of bookmark files, + * or get the default. - FMG */ filename = get_bookmark_filename(&bookmark_URL); /* - * If filename is NULL, must create a new file. If - * filename is a space, an invalid bookmark file was - * selected, or if zero-length, the user cancelled. - * Ignore request in both cases. Otherwise, make - * a copy before anything might change the static - * get_bookmark_filename() buffer. - FM + * If filename is NULL, must create a new file. If + * filename is a space, an invalid bookmark file was + * selected, or if zero-length, the user cancelled. + * Ignore request in both cases. Otherwise, make + * a copy before anything might change the static + * get_bookmark_filename() buffer. - FM */ if (filename == NULL) { - first_time = TRUE; + first_time = TRUE; filename_buffer[0] = '\0'; } else { - if (*filename == '\0' || !strcmp(filename," ")) { + if (*filename == '\0' || !strcmp(filename," ")) { FREE(bookmark_URL); return; } @@ -232,22 +269,22 @@ PUBLIC void save_bookmark_link ARGS2( } /* - * If BookmarkPage is NULL, something went - * wrong, so ignore the request. - FM + * If BookmarkPage is NULL, something went + * wrong, so ignore the request. - FM */ if (BookmarkPage == NULL) { - FREE(bookmark_URL); + FREE(bookmark_URL); return; } /* - * If the link will be added to the same - * bookmark file, get confirmation. - FM + * If the link will be added to the same + * bookmark file, get confirmation. - FM */ if (LYMultiBookmarks == TRUE && - strstr(HTLoadedDocumentURL(), - (*BookmarkPage == '.' ? - (BookmarkPage+1) : BookmarkPage)) != NULL) { + strstr(HTLoadedDocumentURL(), + (*BookmarkPage == '.' ? + (BookmarkPage+1) : BookmarkPage)) != NULL) { LYMBM_statusline(MULTIBOOKMARKS_SELF); c = LYgetch(); if (TOUPPER(c) != 'L') { @@ -257,7 +294,7 @@ PUBLIC void save_bookmark_link ARGS2( } /* - * Allow user to change the title. - FM + * Allow user to change the title. - FM */ string_buffer[255] = '\0'; LYstrncpy(string_buffer, title, 255); @@ -272,34 +309,30 @@ PUBLIC void save_bookmark_link ARGS2( } /* - * Create the Title with any left-angle-brackets - * converted to < entities and any ampersands - * converted to & entities. - FM - * - * Convert 8-bit letters to &#xUUUU to avoid dependencies - * from display character set which may need changing. - * Do NOT convert any 8-bit chars if we have CJK display. - LP + * Create the Title with any left-angle-brackets + * converted to < entities and any ampersands + * converted to & entities. - FM */ StrAllocCopy(Title, string_buffer); LYEntify(&Title, TRUE); - if (UCSaveBookmarksInUnicode && - have8bit(Title) && (!LYHaveCJKCharacterSet)) - StrAllocCopy(Title, title_convert8bit(Title)); /* - * Create the bookmark file, if it doesn't exist already, - * Otherwise, open the pre-existing bookmark file. - FM + * Create the bookmark file, if it doesn't exist already, + * Otherwise, open the pre-existing bookmark file. - FM */ - SetDefaultMode(O_TEXT); +#if defined(__DJGPP__) || defined(_WINDOWS) + _fmode = O_TEXT; +#endif /* __DJGPP__ or _WINDOWS */ if (first_time) { - /* + /* * Seek it in the home path. - FM */ LYAddPathToHome(filename_buffer, sizeof(filename_buffer), BookmarkPage); } - CTRACE(tfp, "\nsave_bookmark_link: SEEKING %s\n AS %s\n\n", + if (TRACE) + fprintf(stderr, "\nsave_bookmark_link: SEEKING %s\n AS %s\n\n", BookmarkPage, filename_buffer); if ((fp = fopen(filename_buffer, (first_time ? "w" : "a+"))) == NULL) { LYMBM_statusline(BOOKMARK_OPEN_FAILED); @@ -309,14 +342,13 @@ PUBLIC void save_bookmark_link ARGS2( } /* - * Convert all ampersands in the address to & entities. - FM + * Convert all ampersands in the address to & entities. - FM */ StrAllocCopy(Address, address); LYEntify(&Address, FALSE); /* - * If we created a new bookmark file, write the headers. - FM - * Once and forever... + * If we created a new bookmark file, write the headers. - FM */ if (first_time) { fprintf(fp,"<head>\n"); @@ -327,18 +359,13 @@ PUBLIC void save_bookmark_link ARGS2( the 'R' key but may have been remapped by you or your system\n\ administrator.<br>\n\ This file also may be edited with a standard text editor to delete\n\ - outdated or invalid links, or to change their order.\n\n\ -<!--\n\ -Note: if you edit this file manually\n\ - you should not change the format within the lines\n\ - or add other HTML markup.\n\ - Make sure any bookmark link saved as a single line\n\ --->\n\n\ + outdated or invalid links, or to change their order, but you should\n\ + not change the format within the lines or add other HTML markup.\n\n\ <p>\n<ol>\n"); } /* - * Add the bookmark link, in Mosaic hotlist or Lynx format. - FM + * Add the bookmark link, in Mosaic hotlist or Lynx format. - FM */ if (is_mosaic_hotlist) { time_t NowTime = time(NULL); @@ -352,16 +379,18 @@ Note: if you edit this file manually\n\ } fclose(fp); - SetDefaultMode(O_BINARY); +#if defined(__DJGPP__) || defined(_WINDOWS) + _fmode = O_BINARY; +#endif /* __DJGPP__ or _WINDOWS */ /* - * If this is a cached bookmark file, set nocache for - * it so we'll see the new bookmark link when that - * cache is retrieved. - FM + * If this is a cached bookmark file, set nocache for + * it so we'll see the new bookmark link when that + * cache is retrieved. - FM */ if (!first_time && nhist > 0 && bookmark_URL) { - for (i = 0; i < nhist; i++) { + for (i = 0; i < nhist; i++) { if (history[i].bookmark && - !strcmp(history[i].address, bookmark_URL)) { + !strcmp(history[i].address, bookmark_URL)) { WWWDoc.address = history[i].address; WWWDoc.post_data = NULL; WWWDoc.post_content_type = NULL; @@ -370,7 +399,7 @@ Note: if you edit this file manually\n\ WWWDoc.safe = FALSE; if (((tmpanchor = HTAnchor_parent( HTAnchor_findAddress(&WWWDoc) - )) != NULL) && + )) != NULL) && (text = (HText *)HTAnchor_document(tmpanchor)) != NULL) { HText_setNoCache(text); } @@ -380,7 +409,7 @@ Note: if you edit this file manually\n\ } /* - * Clean up and report success. + * Clean up and report success. */ FREE(Title); FREE(Address); @@ -388,7 +417,7 @@ Note: if you edit this file manually\n\ LYMBM_statusline(OPERATION_DONE); sleep(MessageSecs); } - + /* * Remove a link from a bookmark file. The calling * function is expected to have used get_filename_link(), @@ -398,7 +427,7 @@ Note: if you edit this file manually\n\ */ PUBLIC void remove_bookmark_link ARGS2( int, cur, - char *, cur_bookmark_page) + char *, cur_bookmark_page) { FILE *fp, *nfp; char buf[BUFSIZ]; @@ -412,39 +441,54 @@ PUBLIC void remove_bookmark_link ARGS2( struct stat stat_buf; mode_t mode; #endif /* VMS */ - char homepath[256]; - CTRACE(tfp, "remove_bookmark_link: deleting link number: %d\n", cur); + if (TRACE) + fprintf(stderr, "remove_bookmark_link: deleting link number: %d\n", + cur); if (!cur_bookmark_page) return; LYAddPathToHome(filename_buffer, sizeof(filename_buffer), cur_bookmark_page); - CTRACE(tfp, "\nremove_bookmark_link: SEEKING %s\n AS %s\n\n", + if (TRACE) + fprintf(stderr, "\nremove_bookmark_link: SEEKING %s\n AS %s\n\n", cur_bookmark_page, filename_buffer); if ((fp = fopen(filename_buffer, "r")) == NULL) { - HTAlert(BOOKMARK_OPEN_FAILED_FOR_DEL); + _statusline(BOOKMARK_OPEN_FAILED_FOR_DEL); + sleep(AlertSecs); return; } - LYAddPathToHome(homepath, sizeof(homepath), ""); - if ((nfp = LYOpenScratch(newfile, homepath)) == 0) { +#ifdef VMS + sprintf(newfile, "%s-%d", filename_buffer, getpid()); +#else + tempname(newfile, NEW_FILE); +#endif /* VMS */ + if ((nfp = LYNewTxtFile(newfile)) == NULL) { fclose(fp); - HTAlert(BOOKSCRA_OPEN_FAILED_FOR_DEL); +#ifdef VMS + _statusline(BOOKSCRA_OPEN_FAILED_FOR_DEL); +#else + _statusline(BOOKTEMP_OPEN_FAILED_FOR_DEL); +#endif /* VMS */ + sleep(AlertSecs); return; } #ifdef UNIX /* - * Explicitly preserve bookmark file mode on Unix. - DSL + * Explicitly preserve bookmark file mode on Unix. - DSL */ if (stat(filename_buffer, &stat_buf) == 0) { - mode = ((stat_buf.st_mode & 0777) | 0600); /* make it writable */ + mode = ((stat_buf.st_mode & 0777) | HIDE_CHMOD); + (void) fclose(nfp); + nfp = NULL; (void) chmod(newfile, mode); - if ((nfp = LYReopenTemp(newfile)) == NULL) { + if ((nfp = fopen(newfile, "a")) == NULL) { (void) fclose(fp); - HTAlert(BOOKTEMP_REOPEN_FAIL_FOR_DEL); + _statusline(BOOKTEMP_REOPEN_FAIL_FOR_DEL); + sleep(AlertSecs); return; } } @@ -453,12 +497,12 @@ PUBLIC void remove_bookmark_link ARGS2( if (is_mosaic_hotlist) { int del_line = cur*2; /* two lines per entry */ n = -3; /* skip past cookie and name lines */ - while (fgets(buf, sizeof(buf), fp) != NULL) { + while (fgets(buf, sizeof(buf), fp) != NULL) { n++; - if (n == del_line || n == del_line+1) + if (n == del_line || n == del_line+1) continue; /* remove two lines */ - if (fputs(buf, nfp) == EOF) - goto failure; + if (fputs(buf, nfp) == EOF) + goto failure; } } else { @@ -466,64 +510,59 @@ PUBLIC void remove_bookmark_link ARGS2( BOOLEAN retain; int seen; - n = -1; - while (fgets(buf, sizeof(buf), fp) != NULL) { + n = -1; + while (fgets(buf, sizeof(buf), fp) != NULL) { retain = TRUE; seen = 0; cp = buf; - while (n < cur && (cp = LYstrstr(cp, "<a href="))) { + while (n < cur && (cp = LYstrstr(cp, "<a href="))) { seen++; - if (++n == cur) { + if (++n == cur) { if (seen != 1 || !LYstrstr(buf, "</a>") || LYstrstr((cp + 1), "<a href=")) { - HTAlert(BOOKMARK_LINK_NOT_ONE_LINE); + _statusline(BOOKMARK_LINK_NOT_ONE_LINE); + sleep(AlertSecs); goto failure; } - CTRACE(tfp, "remove_bookmark_link: skipping link %d\n", n); - retain = FALSE; + if (TRACE) + fprintf(stderr, + "remove_bookmark_link: skipping link %d\n", n); + retain = FALSE; } cp += 8; - } - if (retain && fputs(buf, nfp) == EOF) - goto failure; - } + } + if (retain && fputs(buf, nfp) == EOF) + goto failure; + } } - CTRACE(tfp, "remove_bookmark_link: files: %s %s\n", + if (TRACE) + fprintf(stderr, "remove_bookmark_link: files: %s %s\n", newfile, filename_buffer); fclose(fp); fp = NULL; - LYCloseTempFP(nfp); + fclose(nfp); nfp = NULL; #ifdef DOSPATH remove(filename_buffer); #endif /* DOSPATH */ - -#ifdef UNIX - /* - * By copying onto the bookmark file, rather than renaming it, we - * can preserve the original ownership of the file, provided that - * it is writable by the current process. - * Changed to copy 1998-04-26 -- gil - */ - { char buffer[3072]; - - sprintf(buffer, "%s %s %s && %s %s", - COPY_PATH, newfile, filename_buffer, - RM_PATH, newfile); - - CTRACE(tfp, "remove_bookmark_link: %s\n", buffer); - if( LYSystem( buffer ) ) { - HTAlert(BOOKTEMP_COPY_FAIL); - } else { - return; - } - } -#else /* !UNIX */ if (rename(newfile, filename_buffer) != -1) { - HTSYS_purge(filename_buffer); - return; +#ifdef VMS + char VMSfilename[256]; + /* + * Purge lower version of file. + */ + sprintf(VMSfilename, "%s;-1", filename_buffer); + while (remove(VMSfilename) == 0) + ; + /* + * Reset version number. + */ + sprintf(VMSfilename, "%s;1", filename_buffer); + rename(filename_buffer, VMSfilename); +#endif /* VMS */ + return; } else { #ifndef VMS /* @@ -532,34 +571,35 @@ PUBLIC void remove_bookmark_link ARGS2( * Used to be ODD_RENAME */ #ifdef _WINDOWS - if (errno == ENOTSAM) + if (errno == ENOTSAM) { #else - if (errno == EXDEV) -#endif /* WINDOWS */ - { + if (errno == EXDEV) { +#endif /* WINDOWS */ char buffer[2048]; sprintf(buffer, "%s %s %s", MV_PATH, newfile, filename_buffer); - LYSystem(buffer); + system(buffer); return; } #endif /* !VMS */ #ifdef VMS - HTAlert(ERROR_RENAMING_SCRA); + _statusline(ERROR_RENAMING_SCRA); #else - HTAlert(ERROR_RENAMING_TEMP); + _statusline(ERROR_RENAMING_TEMP); #endif /* VMS */ if (TRACE) perror("renaming the file"); + sleep(AlertSecs); } -#endif /* UNIX */ - + failure: - HTAlert(BOOKMARK_DEL_FAILED); - LYCloseTempFP(nfp); + _statusline(BOOKMARK_DEL_FAILED); + sleep(AlertSecs); + if (nfp != NULL) + fclose(nfp); if (fp != NULL) - fclose(fp); - LYRemoveTemp(newfile); + fclose(fp); + remove(newfile); } /* @@ -570,19 +610,19 @@ PUBLIC int select_multi_bookmarks NOARGS int c; /* - * If not enabled, pick the "default" (0). + * If not enabled, pick the "default" (0). */ if (LYMultiBookmarks == FALSE || LYHaveSubBookmarks() == FALSE) { if (MBM_A_subbookmark[0]) /* If it exists! */ - return(0); + return(0); else - return(-1); + return(-1); } /* - * For ADVANCED users, we can just mess with the status line to save - * the 2 redraws of the screen, if LYMBMAdvnced is TRUE. '=' will - * still show the screen and let them do it the "long" way. + * For ADVANCED users, we can just mess with the status line to save + * the 2 redraws of the screen, if LYMBMAdvnced is TRUE. '=' will + * still show the screen and let them do it the "long" way. */ if (LYMBMAdvanced && user_mode == ADVANCED_MODE) { LYMBM_statusline(MULTIBOOKMARKS_SELECT); @@ -592,18 +632,18 @@ get_advanced_choice: if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; c = 7; - } + } #endif /* VMS */ if (LYisNonAlnumKeyname(c, LYK_PREV_DOC) || c == 7 || c == 3) { /* - * Treat left-arrow, ^G, or ^C as cancel. + * Treat left-arrow, ^G, or ^C as cancel. */ return(-2); } if (LYisNonAlnumKeyname(c, LYK_REFRESH)) { /* - * Refresh the screen. + * Refresh the screen. */ lynx_force_repaint(); refresh(); @@ -611,19 +651,19 @@ get_advanced_choice: } if (LYisNonAlnumKeyname(c, LYK_ACTIVATE)) { /* - * Assume default bookmark file on ENTER or right-arrow. + * Assume default bookmark file on ENTER or right-arrow. */ return (MBM_A_subbookmark[0] ? 0 : -1); } switch (c) { case '=': - /* + /* * Get the choice via the menu. */ return(select_menu_multi_bookmarks()); default: - /* + /* * Convert to an array index, act on it if valid. * Otherwise, get another keystroke. */ @@ -637,7 +677,7 @@ get_advanced_choice: */ return (MBM_A_subbookmark[c] ? c : -1); } else { - /* + /* * Get the choice via the menu. */ return(select_menu_multi_bookmarks()); @@ -655,51 +695,52 @@ PUBLIC int select_menu_multi_bookmarks NOARGS char shead_buffer[256]; /* - * If not enabled, pick the "default" (0). + * If not enabled, pick the "default" (0). */ if (LYMultiBookmarks == FALSE) return(0); /* - * Filip M. Gieszczykiewicz (filipg@paranoia.com) & FM - * --------------------------------------------------- - * LYMultiBookmarks - TRUE when multi_support enabled. + * Filip M. Gieszczykiewicz (filipg@paranoia.com) & FM + * --------------------------------------------------- + * LYMultiBookmarks - TRUE when multi_support enabled. * - * MBM_A_subbookmark[n] - Hold values of the respective - * "multi_bookmarkn" in the lynxrc file. + * MBM_A_subbookmark[n] - Hold values of the respective + * "multi_bookmarkn" in the lynxrc file. * - * MBM_A_subdescript[n] - Hold description entries in the - * lynxrc file. + * MBM_A_subdescript[n] - Hold description entries in the + * lynxrc file. * - * Note: MBM_A_subbookmark[0] is defined to be same value as - * "bookmark_file" in the lynxrc file and/or the startup - * "bookmark_page". + * Note: MBM_A_subbookmark[0] is defined to be same value as + * "bookmark_file" in the lynxrc file and/or the startup + * "bookmark_page". * - * We make the display of bookmarks depend on rows we have - * available. + * We make the display of bookmarks depend on rows we have + * available. * - * We load BookmarkPage with the valid MBM_A_subbookmark[n] - * via get_bookmark_filename(). Otherwise, that function - * returns a zero-length string to indicate a cancel, a - * single space to indicate an invalid choice, or NULL to - * indicate an inaccessible file. + * We load BookmarkPage with the valid MBM_A_subbookmark[n] + * via get_bookmark_filename(). Otherwise, that function + * returns a zero-length string to indicate a cancel, a + * single space to indicate an invalid choice, or NULL to + * indicate an inaccessible file. */ MBM_allow=(LYlines-7); /* We need 7 for header and footer */ /* - * Screen big enough? + * Screen big enough? */ if (MBM_allow <= 0) { - /* + /* * Too small. */ - HTAlert(MULTIBOOKMARKS_SMALL); + _statusline(MULTIBOOKMARKS_SMALL); + sleep(AlertSecs); return (-2); } /* - * Load the bad choice message buffer. + * Load the bad choice message buffer. */ sprintf(string_buffer, - BOOKMARK_FILE_NOT_DEFINED, + BOOKMARK_FILE_NOT_DEFINED, key_for_func(LYK_OPTIONS)); MBM_screens = (MBM_V_MAXFILES/MBM_allow)+1; /* int rounds off low. */ @@ -718,21 +759,21 @@ draw_bookmark_choices: MBM_to = MBM_V_MAXFILES; /* - * Display menu of bookmarks. NOTE that we avoid printw()'s - * to increase the chances that any non-ASCII or multibyte/CJK - * characters will be handled properly. - FM + * Display menu of bookmarks. NOTE that we avoid printw()'s + * to increase the chances that any non-ASCII or multibyte/CJK + * characters will be handled properly. - FM */ clear(); move(1, 5); lynx_start_h1_color (); if (MBM_screens > 1) { - sprintf(shead_buffer, + sprintf(shead_buffer, MULTIBOOKMARKS_SHEAD_MASK, MBM_current, MBM_screens); addstr(shead_buffer); } else { - addstr(MULTIBOOKMARKS_SHEAD); + addstr(MULTIBOOKMARKS_SHEAD); } - + lynx_stop_h1_color (); MBM_tmp_count = 0; @@ -751,7 +792,7 @@ draw_bookmark_choices: } /* - * Don't need to show it if it all fits on one screen! + * Don't need to show it if it all fits on one screen! */ if (MBM_screens > 1) { move(LYlines-2, 0); @@ -804,20 +845,20 @@ get_bookmark_choice: } /* - * Next range, if available. + * Next range, if available. */ if ((c == ']' || LYisNonAlnumKeyname(c, LYK_NEXT_PAGE)) && - MBM_screens > 1) { + MBM_screens > 1) { if (++MBM_current > MBM_screens) MBM_current = 1; goto draw_bookmark_choices; } /* - * Previous range, if available. + * Previous range, if available. */ if ((c == '[' || LYisNonAlnumKeyname(c, LYK_PREV_PAGE)) && - MBM_screens > 1) { + MBM_screens > 1) { if (--MBM_current <= 0) MBM_current = MBM_screens; goto draw_bookmark_choices; @@ -825,12 +866,12 @@ get_bookmark_choice: c = TOUPPER(c) - 'A'; /* - * See if we have a bookmark like that. + * See if we have a bookmark like that. */ if (c < 0 || c > MBM_V_MAXFILES) { goto get_bookmark_choice; } else if (!MBM_A_subbookmark[c]) { - LYMBM_statusline(string_buffer); + LYMBM_statusline(string_buffer); sleep(AlertSecs); LYMBM_statusline(MULTIBOOKMARKS_SAVE); goto get_bookmark_choice; @@ -849,7 +890,7 @@ PUBLIC BOOLEAN LYHaveSubBookmarks NOARGS int i; for (i = 1; i < MBM_V_MAXFILES; i++) { - if (MBM_A_subbookmark[i] != NULL && *MBM_A_subbookmark[i] != '\0') + if (MBM_A_subbookmark[i] != NULL && *MBM_A_subbookmark[i] != '\0') return(TRUE); } @@ -864,94 +905,14 @@ PUBLIC BOOLEAN LYHaveSubBookmarks NOARGS * _statusline() so that any multibyte/CJK characters in the * string will be handled properly. - FM */ -PUBLIC void LYMBM_statusline ARGS1( - char *, text) + PUBLIC void LYMBM_statusline ARGS1( + char *, text) { if (LYMultiBookmarks == TRUE && user_mode == NOVICE_MODE) { LYStatusLine = (LYlines - 1); - _statusline(text); + _statusline(text); LYStatusLine = -1; } else { - _statusline(text); - } -} - -/* - * Check whether string have 8 bit chars. - */ -PRIVATE BOOLEAN have8bit ARGS1(char *, Title) -{ - CONST char *p = Title; - - for ( ; *p; p++) { - if ((unsigned char)*p > 127) - return(TRUE); - } - return(FALSE); /* if we came here */ -} - -/* - * Ok, title have 8-bit characters and they are in display charset. - * Bookmarks is a permanent file. To avoid dependencies from display - * character set which may be changed with time - * we store 8-bit characters as numeric character reference (NCR), - * so where the character encoded as unicode number in form of &#xUUUU; - * - * To make bookmarks more readable for human (&#xUUUU certainly not) - * we add a comment with '7-bit approximation' from the converted string. - * This is a valid HTML and bookmarks code. - * - * We do not want use META charset tag in bookmarks file: - * it will never be changed later :-( - * NCR's translation is part of I18N and HTML4.0 - * supported starting with Lynx 2.7.2, - * Netscape 4.0 and MSIE 4.0. - * Older versions fail. - * - */ -PRIVATE char* title_convert8bit ARGS1(char *, Title) -{ - CONST char *p = Title; - char temp[256]; - char *q = temp; - char *comment = NULL; - char *ncr = NULL; - char *buf = NULL; - - for ( ; *p; p++) { - LYstrncpy(q, p, 1); - if ((unsigned char)*q <= 127) { - StrAllocCat(comment, q); - StrAllocCat(ncr, q); - } else { - int charset_in, charset_out, uck; - long unicode; - char replace_buf [10], replace_buf2 [10]; - - charset_in = current_char_set; - charset_out = UCGetLYhndl_byMIME("us-ascii"); - - uck = UCTransCharStr(replace_buf, sizeof(replace_buf), *q, - charset_in, charset_out, YES); - if (uck >0) - StrAllocCat(comment, replace_buf); - - unicode = UCTransToUni( *q, charset_in); - - StrAllocCat(ncr, "&#"); - sprintf(replace_buf2, "%ld", unicode); - StrAllocCat(ncr, replace_buf2); - StrAllocCat(ncr, ";"); - } + _statusline(text); } - - /* - * valid bookmark should be a single line (no linebreaks!). - */ - StrAllocCat(buf, "<!-- "); - StrAllocCat(buf, comment); - StrAllocCat(buf, " -->"); - StrAllocCat(buf, ncr); - - return(buf); } diff --git a/src/LYCgi.c b/src/LYCgi.c index 5e7ea902..9a6ab780 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -24,6 +24,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTTP.h> #include <HTParse.h> #include <HTTCP.h> @@ -40,15 +41,14 @@ #include <LYGetFile.h> #include <LYBookmark.h> #include <GridText.h> +#include <ctype.h> #include <LYCgi.h> #include <LYSignal.h> #include <LYLocal.h> #include <LYLeaks.h> -#ifdef HAVE_SYS_WAIT_H -#include <sys/wait.h> -#endif +#define FREE(x) if (x) {free(x); x = NULL;} struct _HTStream { @@ -122,7 +122,7 @@ PRIVATE int LYLoadCGI ARGS4( HTFormat, format_out, HTStream*, sink) { - int status = 0; + int status; #ifdef LYNXCGI_LINKS #ifndef VMS char *cp; @@ -190,7 +190,9 @@ PRIVATE int LYLoadCGI ARGS4( /* Found PATH_INFO data. Strip it off of pgm and into path_info. */ StrAllocCopy(path_info, pgm+strlen(pgm_buff)); strcpy(pgm, pgm_buff); - CTRACE(tfp, "LYNXCGI: stat() of %s succeeded, path_info=\"%s\".\n", + if (TRACE) + fprintf(stderr, + "LYNXCGI: stat() of %s succeeded, path_info=\"%s\".\n", pgm_buff, path_info); } FREE(pgm_buff); @@ -221,8 +223,11 @@ PRIVATE int LYLoadCGI ARGS4( * to confusing to know just what file is loaded. - kw */ if (path_info) { - CTRACE(tfp, "%s is not a file and %s not an executable, giving up.\n", + if (TRACE) { + fprintf(stderr, + "%s is not a file and %s not an executable, giving up.\n", orig_pgm, pgm); + } FREE(path_info); FREE(pgm); FREE(orig_pgm); @@ -230,9 +235,13 @@ PRIVATE int LYLoadCGI ARGS4( return(status); } - LYLocalFileToURL (&new_arg, orig_pgm); + StrAllocCopy(new_arg, "file://localhost"); + StrAllocCat(new_arg, orig_pgm); - CTRACE(tfp, "%s is not an executable file, passing the buck.\n", arg); + if (TRACE) { + fprintf(stderr, + "%s is not an executable file, passing the buck.\n", arg); + } status = HTLoadFile(new_arg, anAnchor, format_out, sink); FREE(new_arg); @@ -252,7 +261,8 @@ PRIVATE int LYLoadCGI ARGS4( status = HT_NOT_LOADED; } else if (no_lynxcgi) { - HTUserMsg(CGI_DISABLED); + _statusline(CGI_DISABLED); + sleep(MessageSecs); status = HT_NOT_LOADED; } else if (no_bookmark_exec && @@ -267,7 +277,8 @@ PRIVATE int LYLoadCGI ARGS4( * no_bookmark_exec is TRUE an we are not now coming from a * bookmark page. - kw */ - HTUserMsg(BOOKMARK_EXEC_DISABLED); + _statusline(BOOKMARK_EXEC_DISABLED); + sleep(MessageSecs); status = HT_NOT_LOADED; } else if (anAnchor != HTMainAnchor && @@ -313,7 +324,8 @@ PRIVATE int LYLoadCGI ARGS4( if (!target || target == NULL) { sprintf(buf, CANNOT_CONVERT_I_TO_O, HTAtom_name(format_in), HTAtom_name(format_out)); - HTAlert(buf); + _statusline(buf); + sleep(AlertSecs); status = HT_NOT_LOADED; } else if (anAnchor->post_data && pipe(fd1) < 0) { @@ -360,10 +372,13 @@ PRIVATE int LYLoadCGI ARGS4( close(fd1[0]); /* We have form data to push across the pipe */ - CTRACE(tfp, "LYNXCGI: Doing post, content-type '%s'\n", + if (TRACE) { + fprintf(stderr, "LYNXCGI: Doing post, content-type '%s'\n", anAnchor->post_content_type); - CTRACE(tfp, "LYNXCGI: Writing:\n%s----------------------------------\n", + fprintf(stderr, + "LYNXCGI: Writing:\n%s----------------------------------\n", anAnchor->post_data); + } remaining = strlen(anAnchor->post_data); while ((written = write(fd1[1], anAnchor->post_data + total_written, @@ -382,24 +397,36 @@ PRIVATE int LYLoadCGI ARGS4( } break; } - CTRACE(tfp, "LYNXCGI: Wrote %d bytes of POST data.\n", + if (TRACE) { + fprintf(stderr, + "LYNXCGI: Wrote %d bytes of POST data.\n", written); + } total_written += written; remaining -= written; if (remaining == 0) break; } if (remaining != 0) { - CTRACE(tfp, "LYNXCGI: %d bytes remain unwritten!\n", + if (TRACE) + fprintf(stderr, + "LYNXCGI: %d bytes remain unwritten!\n", remaining); } close(fd1[1]); } - HTReadProgress(total_chars = 0, 0); + total_chars = 0; while((chars = read(fd2[0], buf, sizeof(buf))) > 0) { - HTReadProgress(total_chars += chars, 0); - CTRACE(tfp, "LYNXCGI: Rx: %.*s\n", chars, buf); + char line[40]; + + total_chars += chars; + sprintf (line, "Read %d bytes of data.", total_chars); + HTProgress(line); + if (TRACE) { + fprintf(stderr, "LYNXCGI: Rx: %.*s\n", chars, buf); + } + (*target->isa->put_block)(target, buf, chars); } #if !HAVE_WAITPID @@ -426,7 +453,7 @@ PRIVATE int LYLoadCGI ARGS4( char post_len[32]; int argv_cnt = 3; /* name, one arg and terminator */ char **cur_argv = NULL; - char buf2[BUFSIZ]; + char buf[BUFSIZ]; /* Set up output pipe */ close(fd2[0]); @@ -434,10 +461,10 @@ PRIVATE int LYLoadCGI ARGS4( dup2(fd2[1], fileno(stderr)); close(fd2[1]); - sprintf(buf2, "HTTP_ACCEPT_LANGUAGE=%.*s", - (int)(sizeof(buf2) - 22), language); - buf2[(sizeof(buf2) - 1)] = '\0'; - add_environment_value(buf2); + sprintf(buf, "HTTP_ACCEPT_LANGUAGE=%.*s", + (int)(sizeof(buf) - 22), language); + buf[(sizeof(buf) - 1)] = '\0'; + add_environment_value(buf); if (pref_charset) { cp = NULL; @@ -544,7 +571,9 @@ PRIVATE int LYLoadCGI ARGS4( if (LYCgiDocumentRoot != NULL && path_info != NULL ) { /* Construct and add PATH_TRANSLATED to env */ StrAllocCopy(document_root, LYCgiDocumentRoot); - LYTrimHtmlSep(document_root); + if (document_root[strlen(document_root) - 1] == '/') { + document_root[strlen(document_root) - 1] = '\0'; + } path_translated = document_root; StrAllocCat(path_translated, path_info); cp = NULL; @@ -616,7 +645,8 @@ PRIVATE int LYLoadCGI ARGS4( status = HT_LOADED; #endif /* VMS */ #else /* LYNXCGI_LINKS */ - HTUserMsg(CGI_NOT_COMPILED); + _statusline(CGI_NOT_COMPILED); + sleep(MessageSecs); status = HT_NOT_LOADED; #endif /* LYNXCGI_LINKS */ return(status); diff --git a/src/LYCgi.h b/src/LYCgi.h index b0e1cd63..56a8d15d 100644 --- a/src/LYCgi.h +++ b/src/LYCgi.h @@ -1,8 +1,7 @@ + #ifndef LYCGI_H #define LYCGI_H -#include <HTUtils.h> - extern void add_lynxcgi_environment PARAMS((CONST char *variable_name)); #endif /* LYGETFILE_H */ diff --git a/src/LYCharSets.c b/src/LYCharSets.c index 031e6126..0e7474bb 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTCJK.h> #include <HTMLDTD.h> @@ -25,11 +26,7 @@ PUBLIC BOOLEAN LYHaveCJKCharacterSet = FALSE; PUBLIC BOOLEAN DisplayCharsetMatchLocale = TRUE; extern void UCInit NOARGS; extern int UCInitialized; -PUBLIC int LYNumCharsets = 0; /* Will be initialized later by UC_Register. */ -PUBLIC int current_char_set = -1; /* will be intitialized later in LYMain.c */ -PUBLIC CONST char** p_entity_values = NULL; /* Pointer, for HTML_put_entity()*/ - /* obsolete and probably not used(???) */ - /* will be initialized in HTMLUseCharacterSet */ +PUBLIC int LYNumCharsets = 0; /* Will be initialized later by UC_Register. */ /* * INSTRUCTIONS for adding new character sets which do not have @@ -60,7 +57,7 @@ PUBLIC CONST char** p_entity_values = NULL; /* Pointer, for HTML_put_entity()*/ ** ** This MUST match exactly the table referred to in the DTD! */ -PRIVATE CONST char * ISO_Latin1[] = { +PRIVATE char * ISO_Latin1[] = { "\306", /* capital AE diphthong (ligature) (Æ) - AElig */ "\301", /* capital A, acute accent (Á) - Aacute */ "\302", /* capital A, circumflex accent (Â) - Acirc */ @@ -179,7 +176,7 @@ PRIVATE CONST char * ISO_Latin1[] = { ** ** This MUST match exactly the table referred to in the DTD! */ -PUBLIC CONST char * SevenBitApproximations[] = { +PUBLIC char * SevenBitApproximations[] = { "AE", /* capital AE diphthong (ligature) (Æ) - AElig */ "A", /* capital A, acute accent (Á) - Aacute */ "A", /* capital A, circumflex accent (Â) - Acirc */ @@ -326,7 +323,7 @@ PUBLIC CONST char * SevenBitApproximations[] = { /* * Add the array name to LYCharSets */ -PUBLIC CONST char ** LYCharSets[MAXCHARSETS]={ +PUBLIC char ** LYCharSets[MAXCHARSETS]={ ISO_Latin1, /* ISO Latin 1 */ SevenBitApproximations, /* DosLatin1 (cp850) */ SevenBitApproximations, /* WinLatin1 (cp1252) */ @@ -335,8 +332,8 @@ PUBLIC CONST char ** LYCharSets[MAXCHARSETS]={ SevenBitApproximations, /* Macintosh (8 bit) */ SevenBitApproximations, /* NeXT character set */ SevenBitApproximations, /* Chinese */ - SevenBitApproximations, /* Japanese (EUC-JP) */ - SevenBitApproximations, /* Japanese (Shift_JIS) */ + SevenBitApproximations, /* Japanese (EUC) */ + SevenBitApproximations, /* Japanese (SJIS) */ SevenBitApproximations, /* Korean */ SevenBitApproximations, /* Taipei (Big5) */ SevenBitApproximations, /* Vietnamese (VISCII) */ @@ -349,21 +346,21 @@ PUBLIC CONST char ** LYCharSets[MAXCHARSETS]={ * The order of LYCharSets and LYchar_set_names MUST be the same */ PUBLIC CONST char * LYchar_set_names[MAXCHARSETSP]={ - "Western (ISO-8859-1)", - "Western (cp850)", - "Western (windows-1252)", - "IBM PC US codepage (cp437)", - "DEC Multinational", - "Macintosh (8 bit)", - "NeXT character set", - "Chinese", - "Japanese (EUC-JP)", - "Japanese (Shift_JIS)", - "Korean", - "Taipei (Big5)", - "Vietnamese (VISCII)", - "7 bit approximations (US-ASCII)", - "Transparent", + "ISO Latin 1 ", + "DosLatin1 (cp850) ", + "WinLatin1 (cp1252) ", + "DosLatinUS (cp437) ", + "DEC Multinational ", + "Macintosh (8 bit) ", + "NeXT character set ", + "Chinese ", + "Japanese (EUC) ", + "Japanese (SJIS) ", + "Korean ", + "Taipei (Big5) ", + "Vietnamese (VISCII) ", + "7 bit approximations", + "Transparent ", (char *) 0 }; @@ -455,6 +452,15 @@ PUBLIC int LYlowest_eightbit[MAXCHARSETS]={ 128 /* Transparent (???) */ }; +/* + * The default character set. + * -------------------------- + * Use lynx.cfg and/or user + * 'o'ptions (.lynxrc) to + * set a different default. + */ +PUBLIC char** p_entity_values = ISO_Latin1; /* Pointer to translation */ +PUBLIC int current_char_set = 0; /* Index for translation */ /* * Function to set the handling of selected character sets @@ -462,20 +468,24 @@ PUBLIC int LYlowest_eightbit[MAXCHARSETS]={ */ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) { - int chndl = safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset); - + int chndl = -2; if (LYCharSet_UC[i].enc != UCT_ENC_CJK) { + chndl = 0; + + if (UCAssume_MIMEcharset) + chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); HTCJK = NOCJK; kanji_code = NOKANJI; - if (i == chndl) - LYRawMode = LYUseDefaultRawMode; - else - LYRawMode = (!LYUseDefaultRawMode); HTPassEightBitNum = ((LYCharSet_UC[i].codepoints & UCT_CP_SUPERSETOF_LAT1) || (LYCharSet_UC[i].like8859 & UCT_R_HIGH8BIT)); + if (i == (chndl < 0 ? 0 : chndl)) { + LYRawMode = LYUseDefaultRawMode ? TRUE : FALSE; + } else { + LYRawMode = LYUseDefaultRawMode ? FALSE : TRUE; + } if (LYRawMode) { HTPassEightBitRaw = (LYlowest_eightbit[i] <= 160); } else { @@ -489,51 +499,76 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) HTPassHighCtrlNum = FALSE; - } else { /* CJK encoding: */ - CONST char *mime = LYCharSet_UC[i].MIMEname; - - if (!strcmp(mime, "euc-cn")) { - HTCJK = CHINESE; - kanji_code = EUC; - } else if (!strcmp(mime, "euc-jp")) { - HTCJK = JAPANESE; - kanji_code = EUC; - } else if (!strcmp(mime, "shift_jis")) { - HTCJK = JAPANESE; - kanji_code = SJIS; - } else if (!strcmp(mime, "euc-kr")) { - HTCJK = KOREAN; - kanji_code = EUC; - } else if (!strcmp(mime, "big5")) { - HTCJK = TAIPEI; - kanji_code = EUC; - } + } else if (!strncmp(LYchar_set_names[i], "Chinese", 7)) { + HTCJK = LYUseDefaultRawMode ? CHINESE : NOCJK; + LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + kanji_code = EUC; + HTPassEightBitRaw = FALSE; + HTPassEightBitNum = FALSE; + HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; + HTPassHighCtrlNum = FALSE; + + } else if (!strncmp(LYchar_set_names[i], "Japanese (EUC)", 14)) { + HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK; + LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + kanji_code = EUC; + HTPassEightBitRaw = FALSE; + HTPassEightBitNum = FALSE; + HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; + HTPassHighCtrlNum = FALSE; + + } else if (!strncmp(LYchar_set_names[i], "Japanese (SJIS)", 15)) { + HTCJK = LYUseDefaultRawMode ? JAPANESE : NOCJK; + LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + kanji_code = SJIS; + HTPassEightBitRaw = FALSE; + HTPassEightBitNum = FALSE; + HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; + HTPassHighCtrlNum = FALSE; - /* for any CJK: */ - if (!LYUseDefaultRawMode) - HTCJK = NOCJK; + } else if (!strncmp(LYchar_set_names[i], "Korean", 6)) { + HTCJK = LYUseDefaultRawMode ? KOREAN : NOCJK; LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + kanji_code = EUC; HTPassEightBitRaw = FALSE; HTPassEightBitNum = FALSE; HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; HTPassHighCtrlNum = FALSE; + + } else if (!strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) { + HTCJK = LYUseDefaultRawMode ? TAIPEI : NOCJK; + LYRawMode = (HTCJK != NOCJK) ? TRUE : FALSE; + kanji_code = EUC; + HTPassEightBitRaw = FALSE; + HTPassEightBitNum = FALSE; + HTPassHighCtrlRaw = (HTCJK != NOCJK) ? TRUE : FALSE; + HTPassHighCtrlNum = FALSE; + + } else { + HTCJK = NOCJK; + kanji_code = NOKANJI; + HTPassEightBitRaw = LYUseDefaultRawMode ? FALSE : TRUE; + LYRawMode = HTPassEightBitRaw; + HTPassEightBitNum = FALSE; + HTPassHighCtrlRaw = FALSE; + HTPassHighCtrlNum = FALSE; } - /* - * Comment for coding below: - * UCLYhndl_for_unspec is "current" state with LYRawMode, - * but UCAssume_MIMEcharset is independent from LYRawMode: - * holds the history and may be changed from 'O'ptions menu only. - LP - */ if (LYRawMode) { - UCLYhndl_for_unspec = i; /* UCAssume_MIMEcharset not changed! */ + UCLYhndl_for_unspec = i; } else { - if (chndl != i && + if (chndl == -2) { + chndl = 0; + + if (UCAssume_MIMEcharset) + chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + } + if (chndl != i && chndl >= 0 && (LYCharSet_UC[i].enc != UCT_ENC_CJK || LYCharSet_UC[chndl].enc != UCT_ENC_CJK)) { - UCLYhndl_for_unspec = chndl; /* fall to UCAssume_MIMEcharset */ + UCLYhndl_for_unspec = chndl; } else { - UCLYhndl_for_unspec = LATIN1; /* UCAssume_MIMEcharset not changed! */ + UCLYhndl_for_unspec = 0; } } @@ -554,45 +589,21 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) } /* - * Function to set HTCJK based on "in" and "out" charsets. - */ -PUBLIC void Set_HTCJK ARGS2( - CONST char *, inMIMEname, - CONST char *, outMIMEname) -{ - if (LYRawMode) { - if ((!strcmp(inMIMEname, "euc-jp") || - !strcmp(inMIMEname, "shift_jis")) && - (!strcmp(outMIMEname, "euc-jp") || - !strcmp(outMIMEname, "shift_jis"))) { - HTCJK = JAPANESE; - } else if (!strcmp(inMIMEname, "euc-cn") && - !strcmp(outMIMEname, "euc-cn")) { - HTCJK = CHINESE; - } else if (!strcmp(inMIMEname, "big5") && - !strcmp(outMIMEname, "big5")) { - HTCJK = TAIPEI; - } else if (!strcmp(inMIMEname, "euc-kr") && - !strcmp(outMIMEname, "euc-kr")) { - HTCJK = KOREAN; - } else { - HTCJK = NOCJK; - } - } else { - HTCJK = NOCJK; - } -} - -/* * Function to set the LYDefaultRawMode value * based on the selected character set. - FM - * - * Currently unused: the default value so obvious - * that LYUseDefaultRawMode utilized directly by someone's mistake. - LP */ -PRIVATE void HTMLSetRawModeDefault ARGS1(int,i) +PUBLIC void HTMLSetRawModeDefault ARGS1(int,i) { - LYDefaultRawMode = (LYCharSet_UC[i].enc == UCT_ENC_CJK); + if (!strncmp(LYchar_set_names[i], "ISO Latin 1", 11) || + !strncmp(LYchar_set_names[i], "Chinese", 7) || + !strncmp(LYchar_set_names[i], "Japanese (EUC)", 14) || + !strncmp(LYchar_set_names[i], "Japanese (SJIS)", 15) || + !strncmp(LYchar_set_names[i], "Korean", 6) || + !strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) { + LYDefaultRawMode = TRUE; + } else { + LYDefaultRawMode = FALSE; + } return; } @@ -606,15 +617,32 @@ PUBLIC void HTMLSetUseDefaultRawMode ARGS2( BOOLEAN, modeflag) { if (LYCharSet_UC[i].enc != UCT_ENC_CJK) { + int chndl = 0; - int chndl = safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset); + if (UCAssume_MIMEcharset) + chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); if (i == chndl) LYUseDefaultRawMode = modeflag; else LYUseDefaultRawMode = (!modeflag); - } else /* CJK encoding: */ - LYUseDefaultRawMode = modeflag; - + } else if (!strncmp(LYchar_set_names[i], "ISO Latin 1", 11) || + !strncmp(LYchar_set_names[i], "Chinese", 7) || + !strncmp(LYchar_set_names[i], "Japanese (EUC)", 14) || + !strncmp(LYchar_set_names[i], "Japanese (SJIS)", 15) || + !strncmp(LYchar_set_names[i], "Korean", 6) || + !strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) { + if (modeflag == TRUE) { + LYUseDefaultRawMode = TRUE; + } else { + LYUseDefaultRawMode = FALSE; + } + } else { + if (modeflag == FALSE) { + LYUseDefaultRawMode = TRUE; + } else { + LYUseDefaultRawMode = FALSE; + } + } return; } @@ -622,9 +650,17 @@ PUBLIC void HTMLSetUseDefaultRawMode ARGS2( * Function to set the LYHaveCJKCharacterSet value * based on the selected character set. - FM */ -PRIVATE void HTMLSetHaveCJKCharacterSet ARGS1(int,i) +PUBLIC void HTMLSetHaveCJKCharacterSet ARGS1(int,i) { - LYHaveCJKCharacterSet = (LYCharSet_UC[i].enc == UCT_ENC_CJK); + if (!strncmp(LYchar_set_names[i], "Chinese", 7) || + !strncmp(LYchar_set_names[i], "Japanese (EUC)", 14) || + !strncmp(LYchar_set_names[i], "Japanese (SJIS)", 15) || + !strncmp(LYchar_set_names[i], "Korean", 6) || + !strncmp(LYchar_set_names[i], "Taipei (Big5)", 13)) { + LYHaveCJKCharacterSet = TRUE; + } else { + LYHaveCJKCharacterSet = FALSE; + } return; } @@ -636,142 +672,41 @@ PRIVATE void HTMLSetHaveCJKCharacterSet ARGS1(int,i) */ PRIVATE void HTMLSetDisplayCharsetMatchLocale ARGS1(int,i) { - BOOLEAN match; - - if (LYHaveCJKCharacterSet) { + if (strncasecomp(LYCharSet_UC[i].MIMEname, "cp", 2) || + strncasecomp(LYCharSet_UC[i].MIMEname, "windows", 7)) { /* - ** We have no intention to pass CJK via UCTransChar if that happened. - ** Let someone from CJK correct this if necessary. + ** Assume dos/windows displays usually on remote terminal, + ** so rarely match locale. + ** (in fact, MS Windows codepoints locale are never seen on UNIX). */ - DisplayCharsetMatchLocale = TRUE; /* old-style */ - return; - - } else if (strncasecomp(LYCharSet_UC[i].MIMEname, "cp", 2) || - strncasecomp(LYCharSet_UC[i].MIMEname, "windows", 7)) { - /* - ** Assume dos/windows displays usually on remote terminal, hence it - ** rarely matches locale. (In fact, MS Windows codepoints locale are - ** never seen on UNIX). - */ - match = FALSE; + DisplayCharsetMatchLocale = FALSE; } else { - match = TRUE; /* guess, but see below */ + DisplayCharsetMatchLocale = TRUE; + } #if !defined(LOCALE) - match = FALSE; -#else - if (UCForce8bitTOUPPER) { - /* - ** Force disable locale (from lynx.cfg) - */ - match = FALSE; - } + DisplayCharsetMatchLocale = FALSE; +#endif +#if defined(EXP_8BIT_TOUPPER) + /* + ** Force disable locale, + ** but we have no intention to pass CJK via UCTransChar if that happened. + ** Let someone from CJK correct this if necessary. + */ + if (!LYHaveCJKCharacterSet) + DisplayCharsetMatchLocale = FALSE; #endif - } - DisplayCharsetMatchLocale = match; return; } - -/* - * lynx 2.8/2.7.2(and more early) compatibility code: - * "human-readable" charset names changes with time - * so we map that history names to MIME here - * to get old lynx.cfg and (especially) .lynxrc always recognized. - * Please update this table when you change "fullname" of any present charset. - */ -typedef struct _names_pairs { - CONST char * fullname; - CONST char * MIMEname; -} names_pairs; - -PRIVATE CONST names_pairs OLD_charset_names[] = { - {"ISO Latin 1", "iso-8859-1"}, - {"ISO Latin 2", "iso-8859-2"}, - {"WinLatin1 (cp1252)", "windows-1252"}, - {"DEC Multinational", "dec-mcs"}, - {"Macintosh (8 bit)", "macintosh"}, - {"NeXT character set", "next"}, - {"KOI8-R Cyrillic", "koi8-r"}, - {"Chinese", "euc-cn"}, - {"Japanese (EUC)", "euc-jp"}, - {"Japanese (SJIS)", "shift_jis"}, - {"Korean", "euc-kr"}, - {"Taipei (Big5)", "big5"}, - {"Vietnamese (VISCII)", "viscii"}, - {"7 bit approximations","us-ascii"}, - {"Transparent", "x-transparent"}, - {"DosLatinUS (cp437)", "cp437"}, - {"IBM PC character set","cp437"}, - {"DosLatin1 (cp850)", "cp850"}, - {"IBM PC codepage 850", "cp850"}, - {"DosLatin2 (cp852)", "cp852"}, - {"PC Latin2 CP 852", "cp852"}, - {"DosCyrillic (cp866)", "cp866"}, - {"DosArabic (cp864)", "cp864"}, - {"DosGreek (cp737)", "cp737"}, - {"DosBaltRim (cp775)", "cp775"}, - {"DosGreek2 (cp869)", "cp869"}, - {"DosHebrew (cp862)", "cp862"}, - {"WinLatin2 (cp1250)", "windows-1250"}, - {"WinCyrillic (cp1251)","windows-1251"}, - {"WinGreek (cp1253)", "windows-1253"}, - {"WinHebrew (cp1255)", "windows-1255"}, - {"WinArabic (cp1256)", "windows-1256"}, - {"WinBaltRim (cp1257)", "windows-1257"}, - {"ISO Latin 3", "iso-8859-3"}, - {"ISO Latin 4", "iso-8859-4"}, - {"ISO 8859-5 Cyrillic", "iso-8859-5"}, - {"ISO 8859-6 Arabic", "iso-8859-6"}, - {"ISO 8859-7 Greek", "iso-8859-7"}, - {"ISO 8859-8 Hebrew", "iso-8859-8"}, - {"ISO 8859-9 (Latin 5)","iso-8859-9"}, - {"ISO 8859-10", "iso-8859-10"}, - {"UNICODE UTF 8", "utf-8"}, - {"RFC 1345 w/o Intro", "mnemonic+ascii+0"}, - {"RFC 1345 Mnemonic", "mnemonic"}, - {NULL, NULL}, /* terminated with NULL */ -}; - -/* - * lynx 2.8/2.7.2 compatibility code: - * read "character_set" parameter from lynx.cfg and .lynxrc - * in both MIME name and "human-readable" name (old and new style). - * Returns -1 if not recognized. - */ -PUBLIC int UCGetLYhndl_byAnyName ARGS1 (char *, value) -{ - int i; - - LYTrimTrailing(value); - if (value == NULL) return -1; - - /* search by name */ - for (i = 0; (i < MAXCHARSETS && LYchar_set_names[i]); i++) { - if (!strcmp(value, LYchar_set_names[i])) { - return i; /* OK */ - } - } - - /* search by old name from 2.8/2.7.2 version */ - for (i = 0; (OLD_charset_names[i].fullname); i++) { - if (!strcmp(value, OLD_charset_names[i].fullname)) { - return UCGetLYhndl_byMIME(OLD_charset_names[i].MIMEname); /* OK */ - } - } - - return UCGetLYhndl_byMIME(value); /* by MIME */ -} - - /* * Entity names -- Ordered by ISO Latin 1 value. * --------------------------------------------- * For conversions of DECIMAL escaped entities. * Must be in order of ascending value. */ -PRIVATE CONST char * LYEntityNames[] = { +PUBLIC CONST char * LYEntityNames[] = { /* NAME DECIMAL VALUE */ "nbsp", /* 160, non breaking space */ "iexcl", /* 161, inverted exclamation mark */ @@ -893,7 +828,7 @@ PUBLIC CONST char * HTMLGetEntityName ARGS1( * in the ISO_Latin1 and UC_entity_info unicode_entities arrays. * It returns 0 if not found. - FM * - * unicode_entities[] handles all the names from old style entities[] too. + * unicode_entities[] now handles all the names from old style entities[] too. * Lynx now calls unicode_entities[] only through this function: * HTMLGetEntityUCValue(). Note, we need not check for special characters * here in function or even before it, we should check them *after* @@ -908,6 +843,7 @@ PUBLIC UCode_t HTMLGetEntityUCValue ARGS1( UCode_t value = 0; size_t i, high, low; int diff = 0; +/* CONST char ** entities = HTML_dtd.entity_names; */ CONST UC_entity_info * unicode_entities = HTML_dtd.unicode_entity_info; /* @@ -916,6 +852,72 @@ PUBLIC UCode_t HTMLGetEntityUCValue ARGS1( if (!(name && *name)) return(value); + +#ifdef NOTDEFINED +/* +** unicode_entities[] now handles all names from entities[], so disable latter. +** Let us keep this some sort of comment until we remove +** all calls to old-style entities[] from the code. - LP +*/ + + /* + * Handle names that have control characters + * or strings in ISO_Latin1[]. - FM + */ + if (!strcmp(name, "nbsp")) { + return(160); + } + if (!strcmp(name, "shy")) { + return(173); + } + if (!strcmp(name, "ensp")) { + return(8194); + } + if (!strcmp(name, "emsp")) { + return(8195); + } + if (!strcmp(name, "thinsp")) { + return(8201); + } + if (!strcmp(name, "ndash") || + !strcmp(name, "endash")) { + return(8211); + } + if (!strcmp(name, "mdash") || + !strcmp(name, "emdash")) { + return(8212); + } + if (!strcmp(name, "trade")) { + return(8482); + } + + /* + * Now try ISO_Latin1[]. - FM + */ + for (low = 0, high = HTML_dtd.number_of_entities; + high > low; + diff < 0 ? (low = i+1) : (high = i)) { + /* + ** Binary search. + */ + i = (low + (high-low)/2); + diff = strcmp(entities[i], name); + if (diff == 0) { + if (strlen(ISO_Latin1[i]) == 1) { + value = (unsigned char)(ISO_Latin1[i][0]); + } + break; + } + } + if (value > 0) { + return(value); + } + + /* + * Not yet found... - FM + */ +#endif /* NOTDEFINED */ + /* * Try UC_entity_info unicode_entities[]. */ @@ -940,11 +942,10 @@ PUBLIC UCode_t HTMLGetEntityUCValue ARGS1( * Function to select a character set and then set the * character handling and LYHaveCJKCharacterSet flag. - FM */ -PUBLIC void HTMLUseCharacterSet ARGS1(int, i) +PUBLIC void HTMLUseCharacterSet ARGS1(int,i) { - HTMLSetRawModeDefault(i); p_entity_values = LYCharSets[i]; - HTMLSetCharacterHandling(i); /* set LYRawMode and CJK attributes */ + HTMLSetCharacterHandling(i); HTMLSetHaveCJKCharacterSet(i); HTMLSetDisplayCharsetMatchLocale(i); return; @@ -958,5 +959,17 @@ PUBLIC int LYCharSetsDeclared NOPARAMS { UCInit(); + if (UCAssume_MIMEcharset && *UCAssume_MIMEcharset) { + UCLYhndl_for_unspec = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + } else { + UCLYhndl_for_unspec = 0; + } + if (UCAssume_localMIMEcharset && *UCAssume_localMIMEcharset) + UCLYhndl_HTFile_for_unspec = + UCGetLYhndl_byMIME(UCAssume_localMIMEcharset); + if (UCAssume_unrecMIMEcharset && *UCAssume_unrecMIMEcharset) + UCLYhndl_for_unrec = + UCGetLYhndl_byMIME(UCAssume_unrecMIMEcharset); + return UCInitialized; } diff --git a/src/LYCharSets.h b/src/LYCharSets.h index b5a889f7..ff68dd9b 100644 --- a/src/LYCharSets.h +++ b/src/LYCharSets.h @@ -1,20 +1,19 @@ + #ifndef LYCHARSETS_H #define LYCHARSETS_H -#include <HTUtils.h> -#include <UCDefs.h> - #ifndef UCMAP_H #include <UCMap.h> #endif /* !UCMAP_H */ extern BOOLEAN LYHaveCJKCharacterSet; -extern BOOLEAN DisplayCharsetMatchLocale; +extern BOOLEAN DisplayCharsetMatchLocale; /* - * currently active character set (internal handler) + * LYchar_set_name[current_char_set] points to the currently active set. */ extern int current_char_set; +extern CONST char * LYchar_set_names[]; /* * Initializer, calls initialization function for the @@ -23,20 +22,20 @@ extern int current_char_set; extern int LYCharSetsDeclared NOPARAMS; -extern CONST char ** LYCharSets[]; -extern CONST char * SevenBitApproximations[]; -extern CONST char ** p_entity_values; -extern CONST char * LYchar_set_names[]; /* Full name, not MIME */ +extern char ** LYCharSets[]; +extern char * SevenBitApproximations[]; +extern char ** p_entity_values; extern int LYlowest_eightbit[]; extern int LYNumCharsets; extern LYUCcharset LYCharSet_UC[]; -extern int UCGetLYhndl_byAnyName PARAMS((char *value)); extern void HTMLSetCharacterHandling PARAMS((int i)); +extern void HTMLSetRawModeDefault PARAMS((int i)); extern void HTMLSetUseDefaultRawMode PARAMS((int i, BOOLEAN modeflag)); +extern void HTMLSetHaveCJKCharacterSet PARAMS((int i)); extern void HTMLUseCharacterSet PARAMS((int i)); extern UCode_t HTMLGetEntityUCValue PARAMS((CONST char *name)); -extern void Set_HTCJK PARAMS((CONST char *inMIMEname, CONST char *outMIMEname)); +extern CONST char * LYEntityNames[]; extern CONST char * HTMLGetEntityName PARAMS((UCode_t code)); /* ** HTMLGetEntityName calls LYEntityNames for iso-8859-1 entity diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index dd62a239..e860ce47 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -3,6 +3,7 @@ ** ========================================================================== */ #include <HTUtils.h> +#include <tcp.h> #include <SGML.h> #define Lynx_HTML_Handler @@ -30,16 +31,24 @@ #include <HTNestedList.h> #include <GridText.h> #include <LYSignal.h> -#include <LYStrings.h> #include <LYUtils.h> #include <LYMap.h> #include <LYBookmark.h> #include <LYCurses.h> #include <LYCookie.h> +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ +#ifdef DOSPATH +#include <HTDOS.h> +#endif + #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + extern BOOL HTPassEightBitRaw; extern BOOL HTPassEightBitNum; extern BOOL HTPassHighCtrlRaw; @@ -305,7 +314,7 @@ PUBLIC char *LYFindEndOfComment ARGS1( */ PUBLIC void LYFillLocalFileURL ARGS2( char **, href, - CONST char *, base) + char *, base) { char * temp = NULL; @@ -326,24 +335,15 @@ PUBLIC void LYFillLocalFileURL ARGS2( StrAllocCat(*href, "localhost"); } else if (!strncmp(*href, "file:///", 8)) { StrAllocCopy(temp, (*href+7)); - LYLocalFileToURL (href, temp); - } else if (!strncmp(*href, "file:/", 6) && !LYIsHtmlSep(*(*href+6))) { + StrAllocCopy(*href, "file://localhost"); + StrAllocCat(*href, temp); + } else if (!strncmp(*href, "file:/", 6) && *(*href+6) != '/') { StrAllocCopy(temp, (*href+5)); - LYLocalFileToURL (href, temp); + StrAllocCopy(*href, "file://localhost"); + StrAllocCat(*href, temp); } } -#if defined(DOSPATH) || defined(__EMX__) - if (*(*href+1) == ':') { - /* - * If it's a local DOS path beginning with drive letter, - * add file://localhost/ prefix and go ahead. - */ - StrAllocCopy(temp, *href); - LYLocalFileToURL (href, temp); - } -#endif /* DOSPATH */ - /* * No path in a file://localhost URL means a * directory listing for the current default. - FM @@ -359,9 +359,14 @@ PUBLIC void LYFillLocalFileURL ARGS2( #else getwd (curdir); #endif /* NO_GETCWD */ - temp2 = wwwName(curdir); +#ifdef DOSPATH + temp2 = HTDOS_wwwName(curdir); +#else + temp2 = curdir; +#endif /* DOSPATH */ #endif /* VMS */ - LYAddHtmlSep(href); + if (temp2[0] != '/') + StrAllocCat(*href, "/"); /* * Check for pathological cases - current dir has chars which * MUST BE URL-escaped - kw @@ -412,7 +417,7 @@ PUBLIC void LYFillLocalFileURL ARGS2( ** Currently this function is used for temporary files like "Lynx Info Page" ** and for one permanent - bookmarks (so it may be a problem if you change ** the display charset later: new bookmark entries may be mistranslated). -** - LP +** - LP */ PUBLIC void LYAddMETAcharsetToFD ARGS2( FILE *, fd, @@ -905,8 +910,11 @@ PUBLIC void LYExpandString ARGS2( ** The chartrans procedure failed, so we don't ** do anything, and hope for the best. - FM */ - CTRACE(tfp, "LYExpandString: Bad in (%d) or out (%d) handle(s).\n", + if (TRACE) { + fprintf(stderr, + "LYExpandString: Bad in (%d) or out (%d) handle(s).\n", me->inUCLYhndl, me->outUCLYhndl); + } return; } @@ -1049,7 +1057,7 @@ PUBLIC void LYExpandString ARGS2( saved_char_in = c; #endif /* NOTDEFINED */ if (me->T.trans_to_uni && - (code >= LYlowest_eightbit[me->inUCLYhndl] || + (code >= 127 || (code < 32 && code != 0 && me->T.trans_C0_to_uni))) { /* @@ -1255,7 +1263,7 @@ PUBLIC void LYExpandString ARGS2( ** back translate for our character set. - FM */ if (code > 160 && code < 256 && - me->outUCLYhndl != LATIN1 && + me->outUCLYhndl != 0 && (!(HTPassEightBitRaw || (me->T.do_8bitraw && !me->T.trans_from_uni)))) { value = (code - 160); @@ -1319,7 +1327,10 @@ PUBLIC void LYExpandString ARGS2( */ if (code == 8204 || code == 8205 || code == 8206 || code == 8207) { - CTRACE(tfp, "LYExpandString: Ignoring '%ld'.\n", code); + if (TRACE) { + fprintf(stderr, + "LYExpandString: Ignoring '%ld'.\n", code); + } if (me->T.decode_utf8 && *utf_buf) { utf_buf[0] == '\0'; utf_buf_p = utf_buf; @@ -1504,11 +1515,11 @@ PRIVATE char * UCPutUtf8ToBuffer ARGS3(char *, q, UCode_t, code, BOOL, terminate } /* as in HTParse.c, saves some calls - kw */ -PRIVATE CONST char *hex = "0123456789ABCDEF"; +PRIVATE char *hex = "0123456789ABCDEF"; /* - * Any raw 8-bit or multibyte characters already have been - * handled in relation to the display character set + * Any raw 8-bit or multibyte characters already have been + * handled in relation to the display character set * in SGML_character(), including named and numeric entities. * ** This function used for translations HTML special fields inside tags @@ -1571,20 +1582,6 @@ PRIVATE CONST char *hex = "0123456789ABCDEF"; ** if string translated or translation unnecessary, ** NULL otherwise ** (in which case something probably went wrong.) -** -** -** In general, this somehow ugly function (KW) -** cover three functions from v.2.7.2 (FM): -** extern void LYExpandString PARAMS(( -** HTStructured * me, -** char ** str)); -** extern void LYUnEscapeEntities PARAMS(( -** HTStructured * me, -** char ** str)); -** extern void LYUnEscapeToLatinOne PARAMS(( -** HTStructured * me, -** char ** str, -** BOOLEAN isURL)); */ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( @@ -1991,141 +1988,6 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( break; } else { code = lcode; - if ((code == 1) || - (code > 127 && code < 156)) { - /* - ** Assume these are Microsoft code points, inflicted on - ** us by FrontPage. - FM - ** - ** MS FrontPage uses syntax like ™ in 128-159 - ** range and doesn't follow Unicode standards for this - ** area. Windows-1252 codepoints are assumed here. - */ - switch (code) { - case 1: - /* - ** WHITE SMILING FACE - */ - code = 0x263a; - break; - case 128: - /* - ** EURO currency sign - */ - code = 0x20ac; - break; - case 130: - /* - ** SINGLE LOW-9 QUOTATION MARK (sbquo) - */ - code = 0x201a; - break; - case 132: - /* - ** DOUBLE LOW-9 QUOTATION MARK (bdquo) - */ - code = 0x201e; - break; - case 133: - /* - ** HORIZONTAL ELLIPSIS (hellip) - */ - code = 0x2026; - break; - case 134: - /* - ** DAGGER (dagger) - */ - code = 0x2020; - break; - case 135: - /* - ** DOUBLE DAGGER (Dagger) - */ - code = 0x2021; - break; - case 137: - /* - ** PER MILLE SIGN (permil) - */ - code = 0x2030; - break; - case 139: - /* - ** SINGLE LEFT-POINTING ANGLE QUOTATION MARK - ** (lsaquo) - */ - code = 0x2039; - break; - case 145: - /* - ** LEFT SINGLE QUOTATION MARK (lsquo) - */ - code = 0x2018; - break; - case 146: - /* - ** RIGHT SINGLE QUOTATION MARK (rsquo) - */ - code = 0x2019; - break; - case 147: - /* - ** LEFT DOUBLE QUOTATION MARK (ldquo) - */ - code = 0x201c; - break; - case 148: - /* - ** RIGHT DOUBLE QUOTATION MARK (rdquo) - */ - code = 0x201d; - break; - case 149: - /* - ** BULLET (bull) - */ - code = 0x2022; - break; - case 150: - /* - ** EN DASH (ndash) - */ - code = 0x2013; - break; - case 151: - /* - ** EM DASH (mdash) - */ - code = 0x2014; - break; - case 152: - /* - ** SMALL TILDE (tilde) - */ - code = 0x02dc; - break; - case 153: - /* - ** TRADE MARK SIGN (trade) - */ - code = 0x2122; - break; - case 155: - /* - ** SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - ** (rsaquo) - */ - code = 0x203a; - break; - default: - /* - ** Do not attempt a conversion - ** to valid Unicode values. - */ - break; - } - } state = S_check_uni; } break; @@ -2254,7 +2116,10 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( */ } else if (code == 8204 || code == 8205 || code == 8206 || code == 8207) { - CTRACE(tfp, "LYUCFullyTranslateString: Ignoring '%ld'.\n", code); + if (TRACE) { + fprintf(stderr, + "LYUCFullyTranslateString: Ignoring '%ld'.\n", code); + } replace_buf[0] = '\0'; state = S_got_outstring; break; @@ -2277,7 +2142,9 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( */ } else if (code < 161 || (code < 256 && - (HTPassEightBitNum || cs_to == LATIN1))) { + (HTPassEightBitNum || + !strncmp(LYchar_set_names[cs_to], + "ISO Latin 1", 11)))) { /* ** No conversion needed. */ @@ -2346,15 +2213,8 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( case S_check_name: /* ** Seek the Unicode value for the named entity. - ** - ** !!!! We manually recover the case of '=' terminator which - ** is commonly found on query to CGI-scripts - ** enclosed as href= URLs like "somepath/?x=1&yz=2" - ** Without this dirty fix, submission of such URLs was broken - ** if &yz string happened to be a recognized entity name. - LP */ - if ( ((code = HTMLGetEntityUCValue(name)) > 0) && - !((cpe == '=') && (stype == st_URL)) ) { + if ((code = HTMLGetEntityUCValue(name)) > 0) { state = S_check_uni; break; } @@ -2396,7 +2256,6 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( if (code >= 127 || (code < 32 && (code != 9 && code != 10 && code != 0))) { state = S_put_urlstring; - break; } } REPLACE_STRING(replace_buf); @@ -2513,12 +2372,12 @@ PUBLIC void LYHandleMETA ARGS4( HTStructured *, me, CONST BOOL*, present, CONST char **, value, - char **, include GCC_UNUSED) + char **, include) { char *http_equiv = NULL, *name = NULL, *content = NULL; char *href = NULL, *id_string = NULL, *temp = NULL; char *cp, *cp0, *cp1 = NULL; - int url_type = 0; + int url_type = 0, i; if (!me || !present) return; @@ -2571,10 +2430,13 @@ PUBLIC void LYHandleMETA ARGS4( FREE(content); } } - CTRACE(tfp, "LYHandleMETA: HTTP-EQUIV=\"%s\" NAME=\"%s\" CONTENT=\"%s\"\n", + if (TRACE) { + fprintf(stderr, + "LYHandleMETA: HTTP-EQUIV=\"%s\" NAME=\"%s\" CONTENT=\"%s\"\n", (http_equiv ? http_equiv : "NULL"), (name ? name : "NULL"), (content ? content : "NULL")); + } /* * Make sure we have META name/value pairs to handle. - FM @@ -2606,7 +2468,8 @@ PUBLIC void LYHandleMETA ARGS4( */ if ((!me->node_anchor->cache_control) && !strcasecomp((http_equiv ? http_equiv : ""), "Cache-Control")) { - LYLowerCase(content); + for (i = 0; content[i]; i++) + content[i] = TOLOWER(content[i]); StrAllocCopy(me->node_anchor->cache_control, content); if (me->node_anchor->no_cache == FALSE) { cp0 = content; @@ -2704,12 +2567,15 @@ PUBLIC void LYHandleMETA ARGS4( } else if (!(me->node_anchor->charset && *me->node_anchor->charset) && !strcasecomp((http_equiv ? http_equiv : ""), "Content-Type")) { LYUCcharset * p_in = NULL; - LYUCcharset * p_out = NULL; LYUCFullyTranslateString(&content, me->tag_charset, me->tag_charset, NO, NO, YES, st_other); LYTrimHead(content); LYTrimTail(content); - LYLowerCase(content); + /* + * Force the Content-type value to all lower case. - FM + */ + for (cp = content; *cp; cp++) + *cp = TOLOWER(*cp); if ((cp = strstr(content, "text/html;")) != NULL && (cp1 = strstr(content, "charset")) != NULL && @@ -2742,8 +2608,6 @@ PUBLIC void LYHandleMETA ARGS4( * Got something but we don't recognize it. */ chndl = UCLYhndl_for_unrec; - if (chndl < 0) /* UCLYhndl_for_unrec not defined :-( */ - chndl = UCLYhndl_for_unspec; /* always >= 0 */ if (UCCanTranslateFromTo(chndl, current_char_set)) { chartrans_ok = YES; HTAnchor_setUCInfoStage(me->node_anchor, chndl, @@ -2752,12 +2616,13 @@ PUBLIC void LYHandleMETA ARGS4( } } if (chartrans_ok) { + LYUCcharset * p_out = + HTAnchor_setUCInfoStage(me->node_anchor, + current_char_set, + UCT_STAGE_HTEXT, + UCT_SETBY_DEFAULT); p_in = HTAnchor_getUCInfoStage(me->node_anchor, UCT_STAGE_PARSER); - p_out = HTAnchor_setUCInfoStage(me->node_anchor, - current_char_set, - UCT_STAGE_HTEXT, - UCT_SETBY_DEFAULT); if (!p_out) { /* * Try again. @@ -2789,30 +2654,37 @@ PUBLIC void LYHandleMETA ARGS4( HTPassEightBitRaw = TRUE; } } else if (p_out->enc == UCT_ENC_CJK) { - Set_HTCJK(p_in->MIMEname, p_out->MIMEname); + if (LYRawMode) { + if ((!strcmp(p_in->MIMEname, "euc-jp") || + !strcmp(p_in->MIMEname, "shift_jis")) && + (!strcmp(p_out->MIMEname, "euc-jp") || + !strcmp(p_out->MIMEname, "shift_jis"))) { + HTCJK = JAPANESE; + } else if (!strcmp(p_in->MIMEname, "euc-cn") && + !strcmp(p_out->MIMEname, "euc-cn")) { + HTCJK = CHINESE; + } else if (!strcmp(p_in->MIMEname, "big-5") && + !strcmp(p_out->MIMEname, "big-5")) { + HTCJK = TAIPEI; + } else if (!strcmp(p_in->MIMEname, "euc-kr") && + !strcmp(p_out->MIMEname, "euc-kr")) { + HTCJK = KOREAN; + } else { + HTCJK = NOCJK; + } + } else { + HTCJK = NOCJK; + } } LYGetChartransInfo(me); - /* - ** Update the chartrans info homologously to - ** a Content-Type MIME header with a charset - ** parameter. - FM - */ - if (me->UCLYhndl != chndl) { - HTAnchor_setUCInfoStage(me->node_anchor, chndl, - UCT_STAGE_MIME, - UCT_SETBY_STRUCTURED); - HTAnchor_setUCInfoStage(me->node_anchor, chndl, - UCT_STAGE_PARSER, - UCT_SETBY_STRUCTURED); - me->inUCLYhndl = HTAnchor_getUCLYhndl(me->node_anchor, - UCT_STAGE_PARSER); - me->inUCI = HTAnchor_getUCInfoStage(me->node_anchor, - UCT_STAGE_PARSER); - } - UCSetTransParams(&me->T, - me->inUCLYhndl, me->inUCI, - me->outUCLYhndl, me->outUCI); - } else { + /* + * Fall through to old behavior. + */ + } else if (!strncmp(cp1, "us-ascii", 8) || + !strncmp(cp1, "iso-8859-1", 10)) { + StrAllocCopy(me->node_anchor->charset, "iso-8859-1"); + HTCJK = NOCJK; + /* * Hope it's a match, for now. - FM */ @@ -2825,11 +2697,46 @@ PUBLIC void LYHandleMETA ARGS4( HTPassEightBitRaw = TRUE; HTAlert(me->node_anchor->charset); + } else if (!strncmp(cp1, "euc-jp", 6) && HTCJK == JAPANESE) { + StrAllocCopy(me->node_anchor->charset, "euc-jp"); + + } else if (!strncmp(cp1, "shift_jis", 9) && HTCJK == JAPANESE) { + StrAllocCopy(me->node_anchor->charset, "shift_jis"); + + } else if (!strncmp(cp1, "iso-2022-jp", 11) && + HTCJK == JAPANESE) { + StrAllocCopy(me->node_anchor->charset, "iso-2022-jp"); + + } else if (!strncmp(cp1, "iso-2022-jp-2", 13) && + HTCJK == JAPANESE) { + StrAllocCopy(me->node_anchor->charset, "iso-2022-jp-2"); + + } else if (!strncmp(cp1, "euc-kr", 6) && HTCJK == KOREAN) { + StrAllocCopy(me->node_anchor->charset, "euc-kr"); + + } else if (!strncmp(cp1, "iso-2022-kr", 11) && HTCJK == KOREAN) { + StrAllocCopy(me->node_anchor->charset, "iso-2022-kr"); + + } else if ((!strncmp(cp1, "big5", 4) || + !strncmp(cp1, "cn-big5", 7)) && + HTCJK == TAIPEI) { + StrAllocCopy(me->node_anchor->charset, "big5"); + + } else if (!strncmp(cp1, "euc-cn", 6) && HTCJK == CHINESE) { + StrAllocCopy(me->node_anchor->charset, "euc-cn"); + + } else if ((!strncmp(cp1, "gb2312", 6) || + !strncmp(cp1, "cn-gb", 5)) && + HTCJK == CHINESE) { + StrAllocCopy(me->node_anchor->charset, "gb2312"); + + } else if (!strncmp(cp1, "iso-2022-cn", 11) && HTCJK == CHINESE) { + StrAllocCopy(me->node_anchor->charset, "iso-2022-cn"); } FREE(cp3); - if (me->node_anchor->charset) { - CTRACE(tfp, + if (TRACE && me->node_anchor->charset) { + fprintf(stderr, "LYHandleMETA: New charset: %s\n", me->node_anchor->charset); } @@ -2848,7 +2755,9 @@ PUBLIC void LYHandleMETA ARGS4( /* * Look for the Seconds field. - FM */ - cp = LYSkipBlanks(content); + cp = content; + while (*cp && isspace((unsigned char)*cp)) + cp++; if (*cp && isdigit(*cp)) { cp1 = cp; while (*cp1 && isdigit(*cp1)) @@ -3059,7 +2968,7 @@ PUBLIC void LYHandleP ARGS5( HTStructured *, me, CONST BOOL*, present, CONST char **, value, - char **, include GCC_UNUSED, + char **, include, BOOL, start) { if (TRUE) { @@ -3121,7 +3030,7 @@ PUBLIC void LYHandleP ARGS5( me->in_word = NO; if (LYoverride_default_alignment(me)) { - me->sp->style->alignment = LYstyles(me->sp[0].tag_number)->alignment; + me->sp->style->alignment = styles[me->sp[0].tag_number]->alignment; } else if (me->List_Nesting_Level >= 0 || ((me->Division_Level < 0) && (!strcmp(me->sp->style->name, "Normal") || @@ -3167,7 +3076,7 @@ PUBLIC void LYHandleSELECT ARGS5( HTStructured *, me, CONST BOOL*, present, CONST char **, value, - char **, include GCC_UNUSED, + char **, include, BOOL, start) { int i; @@ -3187,11 +3096,12 @@ PUBLIC void LYHandleSELECT ARGS5( */ if (!me->inFORM) { if (TRACE) { - fprintf(tfp, + fprintf(stderr, "Bad HTML: SELECT start tag not within FORM tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } /* @@ -3210,10 +3120,11 @@ PUBLIC void LYHandleSELECT ARGS5( */ if (me->inTEXTAREA) { if (TRACE) { - fprintf(tfp, "Bad HTML: Missing TEXTAREA end tag\n"); + fprintf(stderr, "Bad HTML: Missing TEXTAREA end tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } } @@ -3243,8 +3154,11 @@ PUBLIC void LYHandleSELECT ARGS5( /* * Let the size be determined by the number of OPTIONs. - FM */ - CTRACE(tfp, "LYHandleSELECT: Ignoring SIZE=\"%s\" for SELECT.\n", - value[HTML_SELECT_SIZE]); + if (TRACE) { + fprintf(stderr, + "LYHandleSELECT: Ignoring SIZE=\"%s\" for SELECT.\n", + (char *)value[HTML_SELECT_SIZE]); + } #endif /* NOTDEFINED */ } @@ -3294,10 +3208,11 @@ PUBLIC void LYHandleSELECT ARGS5( */ if (!me->inSELECT) { if (TRACE) { - fprintf(tfp, "Bad HTML: Unmatched SELECT end tag\n"); + fprintf(stderr, "Bad HTML: Unmatched SELECT end tag\n"); } else if (!me->inBadHTML) { - HTUserMsg(BAD_HTML_USE_TRACE); + _statusline(BAD_HTML_USE_TRACE); me->inBadHTML = TRUE; + sleep(MessageSecs); } return; } @@ -3432,7 +3347,7 @@ PUBLIC int LYLegitimizeHREF ARGS4( *pound = '\0'; convert_to_spaces(fragment, FALSE); } - LYRemoveBlanks(*href); + collapse_spaces(*href); if (fragment != NULL) { StrAllocCat(*href, fragment); FREE(fragment); @@ -3476,8 +3391,7 @@ PUBLIC int LYLegitimizeHREF ARGS4( * it, such that the bad partial reference might get corrected * by the document provider. - FM */ - char *temp = NULL, *path = NULL, *cp; - CONST char *str = ""; + char *temp = NULL, *path = NULL, *str = "", *cp; if (((temp = HTParse(*href, (me->inBASE ? @@ -3487,25 +3401,26 @@ PUBLIC int LYLegitimizeHREF ARGS4( PARSE_PATH+PARSE_PUNCTUATION)) != NULL && !strncmp(path, "/..", 3)) { cp = (path + 3); - if (LYIsHtmlSep(*cp) || *cp == '\0') { + if (*cp == '/' || *cp == '\0') { if ((me->inBASE ? me->base_href[4] : me->node_anchor->address[4]) == 's') { str = "s"; } if (TRACE) { - fprintf(tfp, + fprintf(stderr, "LYLegitimizeHREF: Bad value '%s' for http%s URL.\n", *href, str); - fprintf(tfp, + fprintf(stderr, " Stripping lead dots.\n"); } else if (!me->inBadHREF) { - HTUserMsg(BAD_PARTIAL_REFERENCE); + _statusline(BAD_PARTIAL_REFERENCE); me->inBadHREF = TRUE; + sleep(AlertSecs); } } if (*cp == '\0') { StrAllocCopy(*href, "/"); - } else if (LYIsHtmlSep(*cp)) { + } else if (*cp == '/') { while (!strncmp(cp, "/..", 3)) { if (*(cp + 3) == '/') { cp += 3; @@ -3551,7 +3466,7 @@ PUBLIC void LYCheckForContentBase ARGS1( if (*me->node_anchor->content_base == '\0') return; StrAllocCopy(cp, me->node_anchor->content_base); - LYRemoveBlanks(cp); + collapse_spaces(cp); } else if (me->node_anchor->content_location != NULL) { /* * We didn't have a Content-Base value, but do @@ -3561,7 +3476,7 @@ PUBLIC void LYCheckForContentBase ARGS1( if (*me->node_anchor->content_location == '\0') return; StrAllocCopy(cp, me->node_anchor->content_location); - LYRemoveBlanks(cp); + collapse_spaces(cp); if (!is_url(cp)) { FREE(cp); return; @@ -3685,6 +3600,7 @@ PUBLIC BOOLEAN LYoverride_default_alignment ARGS1( case HTML_ADDRESS: me->sp->style->alignment = HT_LEFT; return YES; + break; default: break; diff --git a/src/LYCharUtils.h b/src/LYCharUtils.h index dc5a6c7f..fb079332 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, - CONST char * base)); + 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/LYClean.c b/src/LYClean.c index 113cc7cf..69b2cdbf 100644 --- a/src/LYClean.c +++ b/src/LYClean.c @@ -1,18 +1,19 @@ #include <HTUtils.h> +#include <tcp.h> #include <LYCurses.h> #include <LYUtils.h> #include <LYSignal.h> #include <LYClean.h> -#include <LYMainLoop.h> #include <LYGlobalDefs.h> #include <LYStrings.h> #include <LYTraversal.h> -#include <LYCookie.h> #include <UCAuto.h> #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + #ifdef VMS BOOLEAN HadVMSInterrupt = FALSE; #endif /* VMS */ @@ -132,11 +133,15 @@ PUBLIC void cleanup_sig ARGS1( /* * Called by Interrupt handler or at quit time. - * Erases the temporary files that lynx created. + * Erases the temporary files that lynx created + * temporary files are removed by tempname + * which created them. */ PUBLIC void cleanup_files NOARGS { - LYCleanupTemp(); + char filename[256]; + + tempname(filename, REMOVE_FILES); FREE(lynx_temp_space); } @@ -179,18 +184,6 @@ PUBLIC void cleanup NOARGS #endif /* LINUX */ #endif /* EXP_CHARTRANS_AUTOSWITCH */ -#ifdef EXP_PERSISTENT_COOKIES - /* - * This can go right here for now. We need to work up a better place - * to save cookies for the next release, preferably whenever a new - * persistent cookie is received or used. Some sort of protocol to - * handle two processes writing to the cookie file needs to be worked - * out as well. - */ - if (persistent_cookies) - LYStoreCookies (LYCookieFile); -#endif - cleanup_files(); for (i = 0; i < nhist; i++) { FREE(history[i].title); @@ -205,5 +198,13 @@ PUBLIC void cleanup NOARGS DidCleanup = TRUE; #endif /* VMS */ - LYCloseTracelog(); + fflush(stdout); + fflush(stderr); + if (LYTraceLogFP != NULL) { + fclose(LYTraceLogFP); + LYTraceLogFP = NULL; +#if !defined(VMS) || (defined(VMS) && !defined(VAXC) && !defined(UCX)) + *stderr = LYOrigStderr; +#endif /* !VMS || (VMS && !VAXC && !UCX) */ + } } diff --git a/src/LYClean.h b/src/LYClean.h index f19d08e3..e9502010 100644 --- a/src/LYClean.h +++ b/src/LYClean.h @@ -1,16 +1,18 @@ #ifndef LYCLEAN_H #define LYCLEAN_H -#include <HTUtils.h> - #ifdef VMS extern BOOLEAN HadVMSInterrupt; #endif extern void cleanup_sig PARAMS((int sig)); +extern BOOLEAN setup PARAMS((char *terminal)); extern void cleanup NOPARAMS; extern void cleanup_files NOPARAMS; extern void set_alarm PARAMS((int sig)); extern void reset_alarm NOPARAMS; +#define NEW_FILE 0 +#define REMOVE_FILES 1 + #endif /* LYCLEAN_H */ diff --git a/src/LYCookie.c b/src/LYCookie.c index 2e115499..bde4a81d 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -17,10 +17,12 @@ ** - FM 1997-08-02 ** ** TO DO: (roughly in order of decreasing priority) + * A means to specify "always allow" and "never allow" domains via + a configuration file is needed. * Hex escaping isn't considered at all. Any semi-colons, commas, or spaces actually in cookie names or values (i.e., not serving as punctuation for the overall Set-Cookie value) should be hex - escaped if not quoted, but presumably the server is expecting + escaped if not quoted, but presumeably the server is expecting them to be hex escaped in our Cookie request header as well, so in theory we need not unescape them. We'll see how this works out in practice. @@ -38,10 +40,12 @@ of use. * If a cookie has the secure flag set, we presently treat only SSL connections as secure. This may need to be expanded for other - secure communication protocols that become standardized. + secure communication protocols that become standarized. + * Cookies could be optionally stored in a file from session to session. */ #include <HTUtils.h> +#include <tcp.h> #include <HTAccess.h> #include <HTParse.h> #include <HTAlert.h> @@ -53,6 +57,7 @@ #include <LYGlobalDefs.h> #include <LYEdit.h> #include <LYStrings.h> +#include <LYSystem.h> #include <GridText.h> #include <LYUtils.h> #include <LYCharUtils.h> @@ -60,9 +65,7 @@ #include <LYLeaks.h> -#define max_cookies_domain 50 -#define max_cookies_global 500 -#define max_cookies_buffer 4096 +#define FREE(x) if (x) {free(x); x = NULL;} /* ** The first level of the cookie list is a list indexed by the domain @@ -70,7 +73,7 @@ ** list. Thus, finding the cookies that apply to a given URL is a ** two-level scan; first we check each domain to see if it applies, ** and if so, then we check the paths of all the cookies on that -** list. We keep a running total of cookies as we add or delete +** list. We keep a running total of cookies as we add or delete ** them */ PRIVATE HTList *domain_list = NULL; @@ -92,7 +95,6 @@ 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; @@ -101,8 +103,6 @@ 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; @@ -285,7 +285,9 @@ PRIVATE void store_cookie ARGS3( * not a prefix of the request-URI. */ if (strncmp(co->path, path, co->pathlen) != 0) { - CTRACE(tfp, "store_cookie: Rejecting because '%s' is not a prefix of '%s'.\n", + if (TRACE) + fprintf(stderr, + "store_cookie: Rejecting because '%s' is not a prefix of '%s'.\n", co->path, path); freeCookie(co); co = NULL; @@ -300,7 +302,9 @@ PRIVATE void store_cookie ARGS3( * The hostname does not contain a dot. */ if (strchr(hostname, '.') == NULL) { - CTRACE(tfp, "store_cookie: Rejecting because '%s' has no dot.\n", + if (TRACE) + fprintf(stderr, + "store_cookie: Rejecting because '%s' has no dot.\n", hostname); freeCookie(co); co = NULL; @@ -315,7 +319,9 @@ PRIVATE void store_cookie ARGS3( * value otherwise qualified. - FM */ if (co->domain[0] != '.' || co->domain[1] == '\0') { - CTRACE(tfp, "store_cookie: Rejecting domain '%s'.\n", + if (TRACE) + fprintf(stderr, + "store_cookie: Rejecting domain '%s'.\n", co->domain); freeCookie(co); co = NULL; @@ -323,7 +329,9 @@ PRIVATE void store_cookie ARGS3( } ptr = strchr((co->domain + 1), '.'); if (ptr == NULL || ptr[1] == '\0') { - CTRACE(tfp, "store_cookie: Rejecting domain '%s'.\n", + if (TRACE) + fprintf(stderr, + "store_cookie: Rejecting domain '%s'.\n", co->domain); freeCookie(co); co = NULL; @@ -335,7 +343,9 @@ PRIVATE void store_cookie ARGS3( * not domain-match the Domain attribute. */ if (!host_matches(hostname, co->domain)) { - CTRACE(tfp, "store_cookie: Rejecting domain '%s' for host '%s'.\n", + if (TRACE) + fprintf(stderr, + "store_cookie: Rejecting domain '%s' for host '%s'.\n", co->domain, hostname); freeCookie(co); co = NULL; @@ -355,22 +365,21 @@ PRIVATE void store_cookie ARGS3( strlen(INVALID_COOKIE_DOMAIN_CONFIRMATION) + 1)); - if (msg == 0) - outofmem(__FILE__, "store_cookie"); - if (!LYAcceptAllCookies) { - sprintf(msg, - INVALID_COOKIE_DOMAIN_CONFIRMATION, - co->domain, - hostname); - if (!HTConfirm(msg)) { - CTRACE(tfp, "store_cookie: Rejecting domain '%s' for host '%s'.\n", - co->domain, - hostname); - freeCookie(co); - co = NULL; - FREE(msg); - return; + sprintf(msg, + INVALID_COOKIE_DOMAIN_CONFIRMATION, + co->domain, + hostname); + if (!HTConfirm(msg)) { + if (TRACE) { + fprintf(stderr, + "store_cookie: Rejecting domain '%s' for host '%s'.\n", + co->domain, + hostname); } + freeCookie(co); + co = NULL; + FREE(msg); + return; } FREE(msg); } @@ -409,22 +418,7 @@ PRIVATE void store_cookie ARGS3( de = (domain_entry *)calloc(1, sizeof(domain_entry)); if (de == NULL) outofmem(__FILE__, "store_cookie"); -#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 (persistent_cookies - && (co->flags & COOKIE_FLAG_PERSISTENT)) - de->bv = FROM_FILE; - else -#endif - de->bv = QUERY_USER; + de->bv = QUERY_USER; cookie_list = de->cookie_list = HTList_new(); StrAllocCopy(de->domain, co->domain); HTList_addObject(domain_list, de); @@ -479,16 +473,20 @@ PRIVATE void store_cookie ARGS3( /* * Don't add the cookie if we're over the domain's limit. - FM */ - } else if (HTList_count(cookie_list) > max_cookies_domain) { - CTRACE(tfp, "store_cookie: Domain's cookie limit exceeded! Rejecting cookie.\n"); + } else if (HTList_count(cookie_list) > 50) { + if (TRACE) + fprintf(stderr, + "store_cookie: Domain's cookie limit exceeded! Rejecting cookie.\n"); freeCookie(co); co = NULL; /* * Don't add the cookie if we're over the total cookie limit. - FM */ - } else if (total_cookies > max_cookies_global) { - CTRACE(tfp, "store_cookie: Total cookie limit exceeded! Rejecting cookie.\n"); + } else if (total_cookies > 500) { + if (TRACE) + fprintf(stderr, + "store_cookie: Total cookie limit exceeded! Rejecting cookie.\n"); freeCookie(co); co = NULL; @@ -505,25 +503,9 @@ 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->name, co->value)) { - -#ifdef EXP_PERSISTENT_COOKIES - /* - * If the cookie domain came from persistent cookie file, - * we want to add new cookies to the end of the cookie list - * to maintain their order for servers that need cookies in - * a particular order. This is a hack. - */ - if (persistent_cookies) { - if ((de->bv = FROM_FILE) != 0) { - HTList_appendObject(cookie_list, co); - } else { - HTList_insertObjectAt(cookie_list, co, pos); - } - } -#else + } else if (HTConfirmCookie(de, hostname, + co->domain, co->path, co->name, co->value)) { HTList_insertObjectAt(cookie_list, co, pos); -#endif /* EXP_PERSISTENT_COOKIES */ total_cookies++; } else { freeCookie(co); @@ -554,12 +536,12 @@ PRIVATE char * scan_cookie_sublist ARGS6( co = (cookie *)hl->object; next = hl->next; - if (co) { - CTRACE(tfp, "Checking cookie %lx %s=%s\n", + if (TRACE && co) { + fprintf(stderr, "Checking cookie %lx %s=%s\n", (long)hl, (co->name ? co->name : "(no name)"), (co->value ? co->value : "(no value)")); - CTRACE(tfp, "%s %s %d %s %s %d%s\n", + fprintf(stderr, "%s %s %d %s %s %d%s\n", hostname, (co->domain ? co->domain : "(no domain)"), host_matches(hostname, co->domain), @@ -629,27 +611,10 @@ PRIVATE char * scan_cookie_sublist ARGS6( /* * Check if we should fold the header. - FM */ - - /* - * Section 2.2 of RFC1945 says: - * - * HTTP/1.0 headers may be folded onto multiple lines - * if each continuation line begins with a space or - * horizontal tab. All linear whitespace, including - * folding, has the same semantics as SP. - * [...] - * However, folding of header lines is not expected by - * some applications, and should not be generated by - * HTTP/1.0 applications. - * - * This code was causing problems. Let's not use it. -BJP - */ - - /* if (len > 800) { */ - /* StrAllocCat(header, crlftab); */ - /* len = 0; */ - /* } */ - + if (len > 800) { + StrAllocCat(header, crlftab); + len = 0; + } } /* * Include the cookie name=value pair. @@ -753,12 +718,14 @@ PRIVATE void LYProcessSetCookies ARGS6( * adding each cookie to the CombinedCookies list. - FM */ p = (SetCookie2 ? SetCookie2 : ""); - if (SetCookie && *p) { - CTRACE(tfp, "LYProcessSetCookies: Using Set-Cookie2 header.\n"); + if (TRACE && SetCookie && *p) { + fprintf(stderr, "LYProcessSetCookies: Using Set-Cookie2 header.\n"); } - while (NumCookies <= max_cookies_domain && *p) { + while (NumCookies <= 50 && *p) { attr_start = attr_end = value_start = value_end = NULL; - p = LYSkipCBlanks(p); + while (*p != '\0' && isspace((unsigned char)*p)) { + p++; + } /* * Get the attribute name. */ @@ -767,7 +734,9 @@ PRIVATE void LYProcessSetCookies ARGS6( *p != '=' && *p != ';' && *p != ',') p++; attr_end = p; - p = LYSkipCBlanks(p); + while (*p != '\0' && isspace((unsigned char)*p)) { + p++; + } /* * Check for an '=' delimiter, or an 'expires' name followed @@ -787,7 +756,9 @@ PRIVATE void LYProcessSetCookies ARGS6( if (*p == '=') { p++; } - p = LYSkipCBlanks(p); + while (*p != '\0' && isspace((unsigned char)*p)) { + p++; + } /* * Hack alert! We must handle Netscape-style cookies with * "Expires=Mon, 01-Jan-96 13:45:35 GMT" or @@ -849,16 +820,20 @@ PRIVATE void LYProcessSetCookies ARGS6( while (isdigit((unsigned char)*p)) p++; value_end = p; - p = LYSkipCBlanks(p); + while (isspace((unsigned char)*p)) + p++; if (*p == '\0' || *p == ';') break; if (*p == ',') { - cp = LYSkipCBlanks(p + 1); + cp = (p + 1); + while (*cp != '\0' && isspace((unsigned char)*cp)) + cp++; if (*cp != '\0' && isdigit((unsigned char)*cp)) { cp1 = cp; while (isdigit((unsigned char)*cp1)) cp1++; - cp1 = LYSkipCBlanks(cp1); + while (*cp != '\0' && isspace((unsigned char)*cp)) + cp1++; if (*cp1 == '\0' || *cp1 == ',' || *cp1 == ';') { p = cp; continue; @@ -933,8 +908,8 @@ PRIVATE void LYProcessSetCookies ARGS6( if (value_end > value_start) { int value_len = (value_end - value_start); - if (value_len > max_cookies_buffer) { - value_len = max_cookies_buffer; + if (value_len > 4096) { + value_len = 4096; } value = (char *)calloc(1, value_len + 1); if (value == NULL) @@ -1001,7 +976,9 @@ PRIVATE void LYProcessSetCookies ARGS6( url_type == HTTPS_URL_TYPE)) { length += strlen(cur_cookie->commentURL); } else { - CTRACE(tfp, "LYProcessSetCookies: Rejecting commentURL value '%s'\n", + if (TRACE) + fprintf(stderr, + "LYProcessSetCookies: Rejecting commentURL value '%s'\n", cur_cookie->commentURL); FREE(cur_cookie->commentURL); } @@ -1030,9 +1007,11 @@ PRIVATE void LYProcessSetCookies ARGS6( isdigit((unsigned char)*ptr)) ptr++; if (*ptr != '\0') { - CTRACE(tfp, + if (TRACE) { + fprintf(stderr, "LYProcessSetCookies: Adding lead dot for domain value '%s'\n", value); + } StrAllocCopy(cur_cookie->domain, "."); StrAllocCat(cur_cookie->domain, value); } else { @@ -1115,7 +1094,9 @@ PRIVATE void LYProcessSetCookies ARGS6( cur_cookie->expires = (time_t)0; } else { cur_cookie->expires = (time(NULL) + temp); - CTRACE(tfp, "LYSetCookie: expires %ld, %s", + if (TRACE) + fprintf(stderr, + "LYSetCookie: expires %ld, %s", (long) cur_cookie->expires, ctime(&cur_cookie->expires)); } @@ -1138,7 +1119,9 @@ PRIVATE void LYProcessSetCookies ARGS6( cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; cur_cookie->expires = LYmktime(value, FALSE); if (cur_cookie->expires > 0) { - CTRACE(tfp, "LYSetCookie: expires %ld, %s", + if (TRACE) + fprintf(stderr, + "LYSetCookie: expires %ld, %s", (long) cur_cookie->expires, ctime(&cur_cookie->expires)); } @@ -1159,7 +1142,7 @@ PRIVATE void LYProcessSetCookies ARGS6( * If we've started a cookie, and it's not too big, * save it in the CombinedCookies list. - FM */ - if (length <= max_cookies_buffer && cur_cookie != NULL) { + if (length <= 4096 && cur_cookie != NULL) { /* * Assume version 1 if not set to that or higher. - FM */ @@ -1168,14 +1151,16 @@ PRIVATE void LYProcessSetCookies ARGS6( } HTList_appendObject(CombinedCookies, cur_cookie); } else if (cur_cookie != NULL) { - CTRACE(tfp, + if (TRACE) { + fprintf(stderr, "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n", (cur_cookie->name ? cur_cookie->name : "[no name]"), (cur_cookie->value ? cur_cookie->value : "[no value]")); - CTRACE(tfp, - " due to excessive length!\n"); + fprintf(stderr, + " due to excessive length!\n"); + } freeCookie(cur_cookie); cur_cookie = NULL; } @@ -1205,24 +1190,23 @@ PRIVATE void LYProcessSetCookies ARGS6( * Add any final SetCookie2 cookie to the CombinedCookie list * if we are within the length limit. - FM */ - if (NumCookies <= max_cookies_domain - && length <= max_cookies_buffer - && cur_cookie != NULL) { + if (NumCookies <= 50 && length <= 4096 && cur_cookie != NULL) { if (cur_cookie->version < 1) { cur_cookie->version = 1; } HTList_appendObject(CombinedCookies, cur_cookie); } else if (cur_cookie != NULL) { - CTRACE(tfp, "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n", + if (TRACE) { + fprintf(stderr, + "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n", (cur_cookie->name ? cur_cookie->name : "[no name]"), (cur_cookie->value ? cur_cookie->value : "[no value]")); - CTRACE(tfp, " due to excessive %s%s%s\n", - (length > max_cookies_buffer ? "length" : ""), - (length > max_cookies_buffer && - NumCookies > max_cookies_domain - ? " and " - : ""), - (NumCookies > max_cookies_domain ? "number!\n" : "!\n")); + fprintf(stderr, + " due to excessive %s%s%s\n", + (length > 4096 ? "length" : ""), + (length > 4096 && NumCookies > 50 ? " and " : ""), + (NumCookies > 50 ? "number!\n" : "!\n")); + } freeCookie(cur_cookie); cur_cookie = NULL; } @@ -1235,12 +1219,14 @@ PRIVATE void LYProcessSetCookies ARGS6( NumCookies = 0; cur_cookie = NULL; p = ((SetCookie && !(SetCookie2 && *SetCookie2)) ? SetCookie : ""); - if (SetCookie2 && *p) { - CTRACE(tfp, "LYProcessSetCookies: Using Set-Cookie header.\n"); + if (TRACE && SetCookie2 && *p) { + fprintf(stderr, "LYProcessSetCookies: Using Set-Cookie header.\n"); } - while (NumCookies <= max_cookies_domain && *p) { + while (NumCookies <= 50 && *p) { attr_start = attr_end = value_start = value_end = NULL; - p = LYSkipCBlanks(p); + while (*p != '\0' && isspace((unsigned char)*p)) { + p++; + } /* * Get the attribute name. */ @@ -1249,7 +1235,9 @@ PRIVATE void LYProcessSetCookies ARGS6( *p != '=' && *p != ';' && *p != ',') p++; attr_end = p; - p = LYSkipCBlanks(p); + while (*p != '\0' && isspace((unsigned char)*p)) { + p++; + } /* * Check for an '=' delimiter, or an 'expires' name followed @@ -1265,7 +1253,9 @@ PRIVATE void LYProcessSetCookies ARGS6( if (*p == '=') { p++; } - p = LYSkipCBlanks(p); + while (*p != '\0' && isspace((unsigned char)*p)) { + p++; + } /* * Hack alert! We must handle Netscape-style cookies with * "Expires=Mon, 01-Jan-96 13:45:35 GMT" or @@ -1327,16 +1317,20 @@ PRIVATE void LYProcessSetCookies ARGS6( while (isdigit((unsigned char)*p)) p++; value_end = p; - p = LYSkipCBlanks(p); + while (isspace((unsigned char)*p)) + p++; if (*p == '\0' || *p == ';') break; if (*p == ',') { - cp = LYSkipCBlanks(p + 1); + cp = (p + 1); + while (*cp != '\0' && isspace((unsigned char)*cp)) + cp++; if (*cp != '\0' && isdigit((unsigned char)*cp)) { cp1 = cp; while (isdigit((unsigned char)*cp1)) cp1++; - cp1 = LYSkipCBlanks(cp1); + while (*cp != '\0' && isspace((unsigned char)*cp)) + cp1++; if (*cp1 == '\0' || *cp1 == ',' || *cp1 == ';') { p = cp; continue; @@ -1412,8 +1406,8 @@ PRIVATE void LYProcessSetCookies ARGS6( if (value_end > value_start) { int value_len = (value_end - value_start); - if (value_len > max_cookies_buffer) { - value_len = max_cookies_buffer; + if (value_len > 4096) { + value_len = 4096; } value = (char *)calloc(1, value_len + 1); if (value == NULL) @@ -1480,7 +1474,9 @@ PRIVATE void LYProcessSetCookies ARGS6( url_type == HTTPS_URL_TYPE)) { length += strlen(cur_cookie->commentURL); } else { - CTRACE(tfp, "LYProcessSetCookies: Rejecting commentURL value '%s'\n", + if (TRACE) + fprintf(stderr, + "LYProcessSetCookies: Rejecting commentURL value '%s'\n", cur_cookie->commentURL); FREE(cur_cookie->commentURL); } @@ -1509,9 +1505,11 @@ PRIVATE void LYProcessSetCookies ARGS6( isdigit((unsigned char)*ptr)) ptr++; if (*ptr != '\0') { - CTRACE(tfp, + if (TRACE) { + fprintf(stderr, "LYProcessSetCookies: Adding lead dot for domain value '%s'\n", value); + } StrAllocCopy(cur_cookie->domain, "."); StrAllocCat(cur_cookie->domain, value); } else { @@ -1625,7 +1623,7 @@ PRIVATE void LYProcessSetCookies ARGS6( * If we've started a cookie, and it's not too big, * save it in the CombinedCookies list. - FM */ - if (length <= max_cookies_buffer && cur_cookie != NULL) { + if (length <= 4096 && cur_cookie != NULL) { /* * If we had a Set-Cookie2 header, make sure * the version is at least 1, and mark it for @@ -1639,12 +1637,16 @@ PRIVATE void LYProcessSetCookies ARGS6( } HTList_appendObject(CombinedCookies, cur_cookie); } else if (cur_cookie != NULL) { - CTRACE(tfp, "LYProcessSetCookies: Rejecting Set-Cookie: %s=%s\n", + if (TRACE) { + fprintf(stderr, + "LYProcessSetCookies: Rejecting Set-Cookie: %s=%s\n", (cur_cookie->name ? cur_cookie->name : "[no name]"), (cur_cookie->value ? cur_cookie->value : "[no value]")); - CTRACE(tfp, " due to excessive length!\n"); + fprintf(stderr, + " due to excessive length!\n"); + } freeCookie(cur_cookie); cur_cookie = NULL; } @@ -1673,7 +1675,7 @@ PRIVATE void LYProcessSetCookies ARGS6( /* * Handle the final Set-Cookie cookie if within length limit. - FM */ - if (NumCookies <= max_cookies_domain && length <= max_cookies_buffer && cur_cookie != NULL) { + if (NumCookies <= 50 && length <= 4096 && cur_cookie != NULL) { if (SetCookie2 != NULL) { if (cur_cookie->version < 1) { cur_cookie->version = 1; @@ -1682,13 +1684,17 @@ PRIVATE void LYProcessSetCookies ARGS6( } HTList_appendObject(CombinedCookies, cur_cookie); } else if (cur_cookie != NULL) { - CTRACE(tfp, "LYProcessSetCookies: Rejecting Set-Cookie: %s=%s\n", + if (TRACE) { + fprintf(stderr, + "LYProcessSetCookies: Rejecting Set-Cookie: %s=%s\n", (cur_cookie->name ? cur_cookie->name : "[no name]"), (cur_cookie->value ? cur_cookie->value : "[no value]")); - CTRACE(tfp, " due to excessive %s%s%s\n", - (length > max_cookies_buffer ? "length" : ""), - (length > max_cookies_buffer && NumCookies > max_cookies_domain ? " and " : ""), - (NumCookies > max_cookies_domain ? "number!\n" : "!\n")); + fprintf(stderr, + " due to excessive %s%s%s\n", + (length > 4096 ? "length" : ""), + (length > 4096 && NumCookies > 50 ? " and " : ""), + (NumCookies > 50 ? "number!\n" : "!\n")); + } freeCookie(cur_cookie); cur_cookie = NULL; } @@ -1699,19 +1705,24 @@ PRIVATE void LYProcessSetCookies ARGS6( */ cl = CombinedCookies; while (NULL != (co = (cookie *)HTList_nextObject(cl))) { - CTRACE(tfp, "LYProcessSetCookie: attr=value pair: '%s=%s'\n", + if (TRACE) { + fprintf(stderr, "LYProcessSetCookie: attr=value pair: '%s=%s'\n", (co->name ? co->name : "[no name]"), (co->value ? co->value : "[no value]")); - if (co->expires > 0) { - CTRACE(tfp, " expires: %ld, %s\n", - (long)co->expires, - ctime(&co->expires)); + if (co->expires > 0) { + fprintf(stderr, " expires: %ld, %s\n", + (long)co->expires, + ctime(&co->expires)); + } } if (!strncasecomp(address, "https:", 6) && LYForceSSLCookiesSecure == TRUE && !(co->flags & COOKIE_FLAG_SECURE)) { co->flags |= COOKIE_FLAG_SECURE; - CTRACE(tfp, " Forced the 'secure' flag on.\n"); + if (TRACE) { + fprintf(stderr, + " Forced the 'secure' flag on.\n"); + } } store_cookie(co, hostname, path); } @@ -1769,19 +1780,23 @@ PUBLIC void LYSetCookie ARGS3( */ BadHeaders = TRUE; } - CTRACE(tfp, "LYSetCookie called with host '%s', path '%s',\n", + if (TRACE) { + fprintf(stderr, + "LYSetCookie called with host '%s', path '%s',\n", (hostname ? hostname : ""), (path ? path : "")); - if (SetCookie) { - CTRACE(tfp, " and Set-Cookie: '%s'\n", - (SetCookie ? SetCookie : "")); - } - if (SetCookie2) { - CTRACE(tfp, " and Set-Cookie2: '%s'\n", - (SetCookie2 ? SetCookie2 : "")); - } - if (LYSetCookies == FALSE || BadHeaders == TRUE) { - CTRACE(tfp, " Ignoring this Set-Cookie/Set-Cookie2 request.\n"); + if (SetCookie) { + fprintf(stderr, " and Set-Cookie: '%s'\n", + (SetCookie ? SetCookie : "")); + } + if (SetCookie2) { + fprintf(stderr, " and Set-Cookie2: '%s'\n", + (SetCookie2 ? SetCookie2 : "")); + } + if (LYSetCookies == FALSE || BadHeaders == TRUE) { + fprintf(stderr, + " Ignoring this Set-Cookie/Set-Cookie2 request.\n"); + } } /* @@ -1816,10 +1831,13 @@ PUBLIC char * LYCookie ARGS4( HTList *hl = domain_list, *next = NULL; domain_entry *de; - CTRACE(tfp, "LYCookie: Searching for '%s:%d', '%s'.\n", + if (TRACE) { + fprintf(stderr, + "LYCookie: Searching for '%s:%d', '%s'.\n", (hostname ? hostname : "(null)"), port, (path ? path : "(null)")); + } /* * Search the cookie_list elements in the domain_list @@ -1870,183 +1888,6 @@ PUBLIC char * LYCookie ARGS4( return(NULL); } -#ifdef EXP_PERSISTENT_COOKIES -/* rjp - experiment cookie loading */ -PUBLIC void LYLoadCookies ARGS1 ( - CONST char *, cookie_file) -{ - FILE *cookie_handle; - char buf[max_cookies_buffer+10]; /* should be long enough for a cookie line */ - static char domain[256], path[LY_MAXPATH], name[256], value[4100]; - static char what[8], secure[8], expires_a[16]; - static struct { - char *s; - size_t n; - } tok_values[] = { - { domain, sizeof(domain) }, - { what, sizeof(what) }, - { path, sizeof(path) }, - { secure, sizeof(secure) }, - { expires_a, sizeof(expires_a) }, - { name, sizeof(name) }, - { value, sizeof(value) }, - { NULL, 0 } - }; - time_t expires; - - cookie_handle = fopen(cookie_file, "r+"); - if (!cookie_handle) - return; - - while (!feof(cookie_handle)) { - cookie *moo; - unsigned i = 0; - int tok_loop; - char *tok_out, *tok_ptr; - char *j; - - j = fgets(buf, sizeof(buf)-1, cookie_handle); - - if((j == NULL) || (buf[0] == '\0' || buf[0] == '\n')) { - continue; - } - - - /* - * Strip out the newline that fgets() puts at the end of a - * cookie. - */ - - while(buf[i] != '\n' && i < sizeof(buf)) { - i++; - } - buf[i] = '\0'; - - /* - * Tokenise the cookie line into its 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 = LYstrsep(&tok_ptr, "\t"); - for (tok_loop = 0; tok_out && tok_values[tok_loop].s; tok_loop++) { - CTRACE(tfp, ">%d:%p:%p:[%s]:%s\n", - tok_loop, tok_values[tok_loop].s, tok_out, tok_out, buf); - LYstrncpy(tok_values[tok_loop].s, tok_out, tok_values[tok_loop].n); - /* - * 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 = LYstrsep(&tok_ptr, "\t"); - } - expires = atol(expires_a); - CTRACE(tfp, "COOKIE: expires %s\n", ctime(&expires)); - - /* - * 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); - */ - - CTRACE(tfp, "%s\t%s\t%s\t%s\t%ld\t%s\t%s\tREADCOOKIE\n", - domain, what, path, secure, (long) 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; - moo->expires = expires; - /* - * 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 */ -PUBLIC void LYStoreCookies ARGS1 ( - CONST char *, cookie_file) -{ - char buf[1024]; - HTList *dl, *cl; - domain_entry *de; - cookie *co; - FILE *cookie_handle; -#ifdef VMS - extern BOOLEAN HadVMSInterrupt; -#endif /* VMS */ - time_t now = time(NULL); /* system specific? - RP */ - - /* - * 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; - - CTRACE(tfp, "COOKIE: %ld cf %ld\n", (long) now, (long) co->expires); - 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); - - HTSYS_purge(cookie_file); -} -#endif - /* LYHandleCookies - F.Macrides (macrides@sci.wfeb.edu) ** --------------- ** @@ -2203,8 +2044,9 @@ PRIVATE int LYHandleCookies ARGS4 ( * from this domain. - FM */ de->bv = QUERY_USER; - HTUserMsg2(ALWAYS_ALLOWING_COOKIES, + _user_message(ALWAYS_ALLOWING_COOKIES, de->domain); + sleep(MessageSecs); return(HT_NO_DATA); case 'C': @@ -2213,7 +2055,8 @@ PRIVATE int LYHandleCookies ARGS4 ( /* * Cancelled. - FM */ - HTUserMsg(CANCELLED); + _statusline(CANCELLED); + sleep(MessageSecs); return(HT_NO_DATA); case 'D': @@ -2274,12 +2117,13 @@ Delete_all_cookies_in_domain: case 'P': /* - * Set to prompt for cookie acceptance + * Set to prompt for cookie acceptence * from this domain. - FM */ de->bv = QUERY_USER; - HTUserMsg2(PROMPTING_TO_ALLOW_COOKIES, - de->domain); + _user_message(PROMTING_TO_ALLOW_COOKIES, + de->domain); + sleep(MessageSecs); return(HT_NO_DATA); case 'V': @@ -2288,8 +2132,9 @@ Delete_all_cookies_in_domain: * from this domain. - FM */ de->bv = REJECT_ALWAYS; - HTUserMsg2(NEVER_ALLOWING_COOKIES, - de->domain); + _user_message(NEVER_ALLOWING_COOKIES, + de->domain); + sleep(MessageSecs); if ((!HTList_isEmpty(de->cookie_list)) && HTConfirm(DELETE_ALL_COOKIES_IN_DOMAIN)) goto Delete_all_cookies_in_domain; @@ -2341,9 +2186,10 @@ Delete_all_cookies_in_domain: sprintf(buf, "<HEAD>\n<TITLE>%s</title>\n</HEAD>\n<BODY>\n", COOKIE_JAR_TITLE); (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, "<h1>%s (%s), help on <a href=\"%s%s\">%s</a></h1>\n", - LYNX_NAME, LYNX_VERSION, - helpfilepath, COOKIE_JAR_HELP, COOKIE_JAR_TITLE); + + sprintf(buf, "<H1>%s</H1>\n", REACHED_COOKIE_JAR_PAGE); + (*target->isa->put_block)(target, buf, strlen(buf)); + sprintf(buf, "<H2>%s Version %s</H2>\n", LYNX_NAME, LYNX_VERSION); (*target->isa->put_block)(target, buf, strlen(buf)); sprintf(buf, "<NOTE>%s\n", ACTIVATE_TO_GOBBLE); @@ -2364,8 +2210,8 @@ Delete_all_cookies_in_domain: /* * Show the domain link and 'allow' setting. - FM */ - sprintf(buf, "<DT>%s<DD><A HREF=\"LYNXCOOKIE://%s/\">Domain=%s</A>\n", - de->domain, de->domain, de->domain); + sprintf(buf, "<DT><A HREF=\"LYNXCOOKIE://%s/\">Domain=%s</A>\n", + de->domain, de->domain); (*target->isa->put_block)(target, buf, strlen(buf)); switch (de->bv) { case (ACCEPT_ALWAYS): @@ -2376,14 +2222,9 @@ Delete_all_cookies_in_domain: break; case (QUERY_USER): sprintf(buf, COOKIES_ALLOWED_VIA_PROMPT); - break; - case (FROM_FILE): - sprintf(buf, COOKIES_READ_FROM_FILE); - break; + break; } (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, "\n"); - (*target->isa->put_block)(target, buf, strlen(buf)); /* * Show the domain's cookies. - FM @@ -2496,162 +2337,6 @@ Delete_all_cookies_in_domain: return(HT_LOADED); } - -/* cookie_add_acceptlist -** --------------------- -** -** Is passed a comma-delimited string of domains to add to the -** "always accept" list for cookies. The domains need to be identical -** to the form from which the cookie is received, with or without a -** leading ".". - BJP -*/ - -PUBLIC void cookie_add_acceptlist ARGS1( - char *, acceptstr) -{ - domain_entry *de = NULL; - domain_entry *de2 = NULL; - HTList *hl; - char **str = (char **)calloc(1, sizeof(acceptstr)); - char *astr = NULL; - char *strsmall = NULL; - int isexisting = FALSE; - - /* - * Is this the first cookie we're handling? If so, initialize - * domain_list. - */ - - if (domain_list == NULL) { - atexit(LYCookieJar_free); - domain_list = HTList_new(); - total_cookies = 0; - } - - StrAllocCopy(astr, acceptstr); - - *str = astr; - - for(; (strsmall = LYstrsep(str, ","));) { - if(strsmall == NULL) - break; - - /* - * Check the list of existing cookies to see if this is a - * re-setting of an already existing cookie -- if so, just - * change the behavior, if not, create a new domain entry. - */ - - for (hl = domain_list; hl != NULL; hl = hl->next) { - de2 = (domain_entry *)hl->object; - if ((de2 != NULL && de2->domain != NULL) && - !strcmp(strsmall, de2->domain)) { - isexisting = TRUE; - break; - } else { - isexisting = FALSE; - } - } - - if(!isexisting) { - de = (domain_entry *)calloc(1, sizeof(domain_entry)); - - if (de == NULL) - outofmem(__FILE__, "cookie_add_acceptlist"); - - de->bv = ACCEPT_ALWAYS; - - StrAllocCopy(de->domain, strsmall); - de->cookie_list = HTList_new(); - HTList_addObject(domain_list, de); - } else { - de2->bv = ACCEPT_ALWAYS; - } - } - - FREE(str); - FREE(strsmall); - FREE(astr); -} - - -/* cookie_add_rejectlist -** --------------------- -** -** Is passed a comma-delimited string of domains to add to the -** "always reject" list for cookies. The domains need to be identical -** to the form from which the cookie is received, with or without a -** leading ".". - BJP -*/ - -PUBLIC void cookie_add_rejectlist ARGS1( - char *, rejectstr) -{ - domain_entry *de = NULL; - domain_entry *de2 = NULL; - HTList *hl; - char **str = (char **)calloc(1, sizeof(rejectstr)); - char *rstr = NULL; - char *strsmall = NULL; - int isexisting = FALSE; - - /* - * Is this the first cookie we're handling? If so, initialize - * domain_list. - */ - - if (domain_list == NULL) { - atexit(LYCookieJar_free); - domain_list = HTList_new(); - total_cookies = 0; - } - - StrAllocCopy(rstr, rejectstr); - - *str = rstr; - - for(; (strsmall = LYstrsep(str, ","));) { - if(strsmall == NULL) - break; - - /* - * Check the list of existing cookies to see if this is a - * re-setting of an already existing cookie -- if so, just - * change the behavior, if not, create a new domain entry. - */ - - for (hl = domain_list; hl != NULL; hl = hl->next) { - de2 = (domain_entry *)hl->object; - if ((de2 != NULL && de2->domain != NULL) && - !strcmp(strsmall, de2->domain)) { - isexisting = TRUE; - break; - } else { - isexisting = FALSE; - } - } - - if(!isexisting) { - de = (domain_entry *)calloc(1, sizeof(domain_entry)); - - if (de == NULL) - outofmem(__FILE__, "cookie_add_rejectlist"); - - de->bv = REJECT_ALWAYS; - - StrAllocCopy(de->domain, strsmall); - de->cookie_list = HTList_new(); - HTList_addObject(domain_list, de); - } else { - de2->bv = REJECT_ALWAYS; - } - } - - FREE(str); - FREE(strsmall); - FREE(rstr); -} - #ifdef GLOBALDEF_IS_MACRO #define _LYCOOKIE_C_GLOBALDEF_1_INIT { "LYNXCOOKIE",LYHandleCookies,0} GLOBALDEF (HTProtocol,LYLynxCookies,_LYCOOKIE_C_GLOBALDEF_1_INIT); diff --git a/src/LYCookie.h b/src/LYCookie.h index 2e4a3ecf..9900a017 100644 --- a/src/LYCookie.h +++ b/src/LYCookie.h @@ -1,9 +1,7 @@ + #ifndef LYCOOKIES_H #define LYCOOKIES_H -#include <HTUtils.h> -#include <HTList.h> - extern void LYSetCookie PARAMS(( CONST char * SetCookie, CONST char * SetCookie2, @@ -13,16 +11,8 @@ extern char *LYCookie PARAMS(( CONST char * partialpath, int port, BOOL secure)); -extern void LYStoreCookies PARAMS(( - CONST char * cookie_file)); -extern void LYLoadCookies PARAMS(( - CONST char * cookie_file)); -extern void cookie_add_acceptlist PARAMS(( - char * acceptdomains)); -extern void cookie_add_rejectlist PARAMS(( - char * rejectdomains)); -typedef enum {ACCEPT_ALWAYS, REJECT_ALWAYS, QUERY_USER, FROM_FILE} behaviour; +typedef enum {ACCEPT_ALWAYS, REJECT_ALWAYS, QUERY_USER} behaviour; struct _domain_entry { char * domain; /* Domain for which these cookies are valid */ diff --git a/src/LYCurses.c b/src/LYCurses.c index 0e3e0ea9..00458ff9 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,5 +1,5 @@ #include <HTUtils.h> -#include <HTAlert.h> +#include <tcp.h> #include <LYCurses.h> #include <LYStyle.h> #include <LYUtils.h> @@ -15,6 +15,14 @@ #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + +#ifdef VMS +#define DISPLAY "DECW$DISPLAY" +#else +#define DISPLAY "DISPLAY" +#endif /* VMS */ + #if defined(VMS) && defined(__GNUC__) #include <gnu_hacks.h> #undef LINES @@ -149,7 +157,7 @@ PRIVATE void sl_suspend ARGS1( SLang_init_tty(3, 0, 1); #endif /* SLANG_VERSION > 9929 */ signal(SIGTSTP, sl_suspend); -#if !defined(_WINDOWS) && !defined(__DJGPP__) +#ifndef _WINDOWS SLtty_set_suspend_state(1); #endif if (sig == SIGTSTP) @@ -208,7 +216,7 @@ PUBLIC void VMSbox ARGS3( */ PUBLIC void LYbox ARGS2( WINDOW *, win, - BOOLEAN, formfield GCC_UNUSED) + BOOLEAN, formfield) { /* * If the terminal is in UTF-8 mode, it probably cannot understand @@ -275,7 +283,8 @@ PUBLIC void setStyle ARGS4(int,style,int,color,int,cattr,int,mono) PUBLIC void setHashStyle ARGS5(int,style,int,color,int,cattr,int,mono,char*,element) { bucket* ds=&hashStyles[style]; - CTRACE(tfp, "CSS(SET): <%s> hash=%d, ca=%d, ma=%d\n", element, style, color, mono); + if (TRACE) + fprintf(stderr, "CSS(SET): <%s> hash=%d, ca=%d, ma=%d\n", element, style, color, mono); ds->color=color; ds->cattr=cattr; ds->mono=mono; @@ -290,7 +299,8 @@ PUBLIC void setHashStyle ARGS5(int,style,int,color,int,cattr,int,mono,char*,elem */ PRIVATE int LYAttrset ARGS3(WINDOW*,win,int,color,int,mono) { - CTRACE(tfp, "CSS:LYAttrset (%#x, %#x)\n", color, mono); + if (TRACE) + fprintf(stderr, "CSS:LYAttrset (%d, %d)\n", color, mono); if (lynx_has_color && LYShowColor >= SHOW_COLOR_ON && color > -1) { wattrset(win,color); @@ -305,20 +315,19 @@ PRIVATE int LYAttrset ARGS3(WINDOW*,win,int,color,int,mono) return A_NORMAL; } -PUBLIC void curses_w_style ARGS3( - WINDOW*, win, - int, style, - int, dir) +PUBLIC void curses_w_style ARGS4(WINDOW*,win,int,style,int,dir,int,previous) { int YP,XP; bucket* ds=&hashStyles[style]; if (!ds->name) { - CTRACE(tfp, "CSS.CS:Style %d not configured\n",style); + if (TRACE) + fprintf(stderr, "CSS.CS:Style %d not configured\n",style); return; } - CTRACE(tfp, "CSS.CS:<%s%s> (%d)\n",(dir?"":"/"),ds->name,ds->code); + if (TRACE) + fprintf(stderr, "CSS.CS:<%s%s> (%d)\n",(dir?"":"/"),ds->name,ds->code); getyx (win, YP, XP); @@ -341,7 +350,8 @@ PUBLIC void curses_w_style ARGS3( case STACK_ON: /* remember the current attributes */ if (last_ptr > 127) { - CTRACE(tfp,"........... %s (0x%x) %s\r\n", + if (TRACE) + fprintf(stderr,"........... %s (0x%x) %s\r\n", "attribute cache FULL, dropping last", last_styles[last_ptr], "in LynxChangStyle(curses_w_style)"); @@ -351,7 +361,8 @@ PUBLIC void curses_w_style ARGS3( /* don't cache style changes for active links */ if (style != s_alink) { - CTRACE(tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP); + if (TRACE) + fprintf(stderr, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP); if (win==stdscr) cached_styles[YP][XP]=style; LYAttrset(win, ds->color, ds->mono); } @@ -365,7 +376,8 @@ PUBLIC void curses_w_style ARGS3( /* don't cache style changes for active links */ if (style != s_alink) { - CTRACE(tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP); + if (TRACE) + fprintf(stderr, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP); if (win==stdscr) cached_styles[YP][XP]=style; LYAttrset(win, ds->color, ds->mono); } @@ -386,15 +398,16 @@ PUBLIC void wcurses_css ARGS3(WINDOW *,win,char*,name,int,dir) while (try_again) { int tmpHash=hash_code(name); - CTRACE(tfp, "CSSTRIM:trying to set [%s] style - ", name); + if (TRACE) + fprintf(stderr, "CSSTRIM:trying to set [%s] style - ", name); if (tmpHash==NOSTYLE) { char *class=strrchr(name, '.'); - CTRACE(tfp, "undefined, trimming at %p\n", class); + if (TRACE) fprintf(stderr, "undefined, trimming at %p\n", class); if (class) *class='\0'; else try_again=0; } else { - CTRACE(tfp, "ok (%d)\n", hash_code(name)); - curses_w_style(win, hash_code(name), dir); + if (TRACE) fprintf(stderr, "ok (%d)\n", hash_code(name)); + curses_w_style(win, hash_code(name), dir, 0); try_again=0; } } @@ -402,14 +415,12 @@ 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 ARGS2( - int, style, - int, dir) +PUBLIC void curses_style ARGS3(int,style,int,dir,int,previous) { - curses_w_style(stdscr, style, dir); + curses_w_style(stdscr, style, dir, previous); } #ifdef NOT_USED @@ -463,15 +474,24 @@ PRIVATE void LYsetWAttr ARGS1(WINDOW *, win) int code = 0; int attr = A_NORMAL; int offs = 1; - static int NoColorVideo = -1; + static int have_underline = -1; + static int no_color_video = -1; -#ifdef UNIX - if (NoColorVideo < 0) { - NoColorVideo = tigetnum("ncv"); + if (have_underline < 0) { +#ifndef DOSPATH + have_underline = tigetstr("smul") != 0; +#else + have_underline = 1; +#endif /* DOSPATH */ } - if (NoColorVideo < 0) - NoColorVideo = 0; -#endif /* UNIX */ + +#if ( !defined(__DJGPP__) && !defined(_WINDOWS) ) + if (no_color_video < 0) { + no_color_video = tigetnum("ncv"); + } + if (no_color_video < 0) + no_color_video = 0; +#endif /* !__DJGPP__ and !_WINDOWS */ if (Current_Attr & A_BOLD) code |= 1; @@ -482,14 +502,14 @@ PRIVATE void LYsetWAttr ARGS1(WINDOW *, win) attr = lynx_color_cfg[code].attr; /* - * no_color_video isn't implemented (97/4/14) in ncurses 4.1, but may - * be in SVr4 (which would make this redundant for the latter). + * FIXME: no_color_video isn't implemented (97/4/14) in ncurses 4.x, + * but may be in SVr4 (which would make this redundant for the latter). */ - if ((Current_Attr & A_BOLD) && !(NoColorVideo & 33)) { + if ((Current_Attr & A_BOLD) && !(no_color_video & 33)) { attr |= A_BOLD; } - if ((Current_Attr == A_UNDERLINE) && !(NoColorVideo & 2)) { + if ((Current_Attr == A_UNDERLINE) && !(no_color_video & 2)) { attr |= A_UNDERLINE; } @@ -535,7 +555,6 @@ PUBLIC int lynx_chg_color ARGS3( int, bg ) { - if (fg == ERR_COLOR || bg == ERR_COLOR) return -1; if (color >= 0 && color < 8) { lynx_color_cfg[color].fg = (fg > 7) ? (fg & 7) : fg; lynx_color_cfg[color].bg = (bg > 7) ? (bg & 7) : bg; @@ -604,35 +623,34 @@ PUBLIC void lynx_setup_colors NOARGS */ PUBLIC void start_curses NOARGS { - static BOOLEAN first_time = TRUE; - - if(first_time) - { - initscr(); /* start curses */ - first_time = FALSE; - cbreak(); - keypad(stdscr, TRUE); - fflush(stdin); - fflush(stdout); - if (has_colors()) { - lynx_has_color = TRUE; - start_color(); - } - lynx_init_colors(); - lynx_called_initscr = TRUE; - - /* Inform pdcurses that we're interested in knowing when mouse buttons - * are clicked. Maybe someday pdcurses will support it. - */ - if (LYUseMouse) - lynx_enable_mouse (1); + static BOOLEAN first_time = TRUE; + + if(first_time) + { + initscr(); /* start curses */ + first_time = FALSE; + cbreak(); + keypad(stdscr, TRUE); + fflush(stdin); + fflush(stdout); + if (has_colors()) { + lynx_has_color = TRUE; + start_color(); + } + lynx_init_colors(); + lynx_called_initscr = TRUE; + + /* Inform pdcurses that we're interested in knowing when mouse + buttons are clicked. Maybe someday pdcurses will support it. + */ + if (LYUseMouse) + lynx_enable_mouse (1); - } else - sock_init(); + } else sock_init(); - LYCursesON = TRUE; - clear(); - noecho(); + LYCursesON = TRUE; + clear(); + noecho(); } #else PUBLIC void start_curses NOARGS @@ -645,10 +663,6 @@ PUBLIC void start_curses NOARGS if (slinit == 0) { SLtt_get_terminfo(); -#if defined(__DJGPP__) && !defined(DJGPP_KEYHANDLER) - SLkp_init (); -#endif /* __DJGPP__ && !DJGPP_KEYHANDLER */ - #ifdef UNIX #if SLANG_VERSION >= 9935 SLang_TT_Read_FD = fileno(stdin); @@ -685,7 +699,6 @@ PUBLIC void start_curses NOARGS } size_change(0); -#if defined(VMS) || defined(UNIX) SLtt_add_color_attribute(4, SLTT_ULINE_MASK); SLtt_add_color_attribute(5, SLTT_ULINE_MASK); /* @@ -697,12 +710,7 @@ PUBLIC void start_curses NOARGS } else { SLtt_Blink_Mode = 0; } -#endif /* VMS || UNIX */ } -#ifdef __DJGPP__ - else sock_init(); -#endif /* __DJGPP__ */ - slinit = 1; Current_Attr = 0; #ifndef VMS @@ -715,12 +723,12 @@ PUBLIC void start_curses NOARGS SLsmg_init_smg(); SLsmg_Display_Eight_Bit = LYlowest_eightbit[current_char_set]; if (SLsmg_Display_Eight_Bit > 191) - SLsmg_Display_Eight_Bit = 191; /* may print ctrl chars otherwise - kw */ + SLsmg_Display_Eight_Bit = 191; /* may print ctrl chars otherwise - kw */ scrollok(0,0); SLsmg_Backspace_Moves = 1; #ifndef VMS -#if !defined(_WINDOWS) && !defined(__DJGPP__) - SLtty_set_suspend_state(1); +#ifndef _WINDOWS + SLtty_set_suspend_state(1); #endif /* !_WINDOWS */ #ifdef SIGTSTP if (!no_suspend) @@ -735,7 +743,7 @@ PUBLIC void start_curses NOARGS #ifdef VMS /* - * If we are VMS then do initscr() everytime start_curses() + * If we are VMS then do initsrc() everytime start_curses() * is called! */ initscr(); /* start curses */ @@ -748,7 +756,7 @@ PUBLIC void start_curses NOARGS * and one time only! */ if (initscr() == NULL) { /* start curses */ - fprintf(tfp, + fprintf(stderr, "Terminal initialisation failed - unknown terminal type?\n"); #ifndef NOSIGHUP (void) signal(SIGHUP, SIG_DFL); @@ -764,10 +772,6 @@ PUBLIC void start_curses NOARGS #if defined(SIGWINCH) && defined(NCURSES_VERSION) size_change(0); #endif /* SIGWINCH */ -#if defined(USE_KEYMAPS) && defined(NCURSES_VERSION) - if (-1 == lynx_initialize_keymaps ()) - exit (-1); -#endif /* * This is a workaround for a bug in SVr4 curses, observed on Solaris @@ -781,9 +785,9 @@ PUBLIC void start_curses NOARGS { int n; for (n = 0; n < 128; n++) - if (ALT_CHAR_SET[n] & 0x80) { - ALT_CHAR_SET[n] &= 0xff; - ALT_CHAR_SET[n] |= A_ALTCHARSET; + if (acs_map[n] & 0x80) { + acs_map[n] &= 0xff; + acs_map[n] |= A_ALTCHARSET; } } #endif @@ -849,50 +853,29 @@ PUBLIC void start_curses NOARGS PUBLIC void lynx_enable_mouse ARGS1(int,state) { - -#ifdef __BORLANDC__ -/* modify lynx_enable_mouse() for pdcurses configuration so that mouse support - is disabled unless -use_mouse is specified. This is ifdef'd with - __BORLANDC__ for the time being (WB). -*/ - 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; + if (LYUseMouse == 0) + return; #ifdef USE_SLANG_MOUSE - SLtt_set_mouse_mode (state, 0); - SLtt_flush_output (); + SLtt_set_mouse_mode (state, 0); + SLtt_flush_output (); #else - #ifdef NCURSES_MOUSE_VERSION -#if defined(__BORLANDC__) && defined(__PDCURSES__) - if (state) - { - SetConsoleMode(hConIn, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT); - FlushConsoleInputBuffer(hConIn); - } + /* 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 - /* Inform ncurses that we're interested in knowing when mouse - * button 1 is clicked */ - if (state) - mousemask(BUTTON1_CLICKED | BUTTON3_CLICKED, NULL); - else - mousemask(0, NULL); -#endif /* __BORLANDC__ and __PDCURSES__ */ + if (state) mouse_set(BUTTON1_CLICKED && BUTTON2_CLICKED && BUTTON3_CLICKED); +#endif /* !_WINDOWS */ #endif /* NCURSES_MOUSE_VERSION */ #if defined(DJGPP) && !defined(USE_SLANG) - if (state) - mouse_set(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED); + if (state) + mouse_set(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED); #endif #endif /* NOT USE_SLANG_MOUSE */ } @@ -924,8 +907,8 @@ PUBLIC void stop_curses NOARGS #if defined(SIGTSTP) && defined(USE_SLANG) #ifndef VMS - if (!no_suspend) - signal(SIGTSTP, SIG_DFL); + if (!no_suspend) + signal(SIGTSTP, SIG_DFL); #endif /* !VMS */ #endif /* SIGTSTP && USE_SLANG */ @@ -943,7 +926,7 @@ PUBLIC BOOLEAN setup ARGS1( { int c; int status; - char *dummy = 0, *cp, term[81]; + char *dummy, *cp, term[81]; #ifdef USE_SLANG extern void longname(); #endif /* USE_SLANG */ @@ -952,10 +935,10 @@ PUBLIC BOOLEAN setup ARGS1( * If the display was not set by a command line option then * see if it is available from the environment. */ - if ((cp = LYgetXDisplay()) != 0) { - StrAllocCopy(x_display, cp); + if ((cp = getenv(DISPLAY)) != NULL && *cp != '\0') { + StrAllocCopy(display, cp); } else { - FREE(x_display); + FREE(display); } /* @@ -981,7 +964,9 @@ PUBLIC BOOLEAN setup ARGS1( #endif /* SIGTSTP */ exit(status); } - LYLowerCase(term); + for (cp = term; *cp != '\0'; cp++) + if (isupper(*cp)) + *cp = TOLOWER(*cp); printf("Terminal = %s\n", term); sleep(InfoSecs); @@ -1049,10 +1034,10 @@ PUBLIC BOOLEAN setup ARGS1( * If the display was not set by a command line option then * see if it is available from the environment . */ - if ((cp = LYgetXDisplay()) != NULL) { - StrAllocCopy(x_display, cp); + if ((cp = getenv(DISPLAY)) != NULL && *cp != '\0') { + StrAllocCopy(display, cp); } else { - FREE(x_display); + FREE(display); } if (terminal != NULL) { @@ -1240,6 +1225,7 @@ PUBLIC void LYstopTargetEmphasis NOARGS #include <descrip.h> #include <iodef.h> #include <ssdef.h> +#include <stdlib.h> #include <msgdef.h> #include <ttdef.h> #include <tt2def.h> @@ -1326,7 +1312,8 @@ PUBLIC void VMSexit NOARGS (void) getchar(); } } else if (LYCursesON) { - HTAlert(MEMORY_EXHAUSTED_ABORT); + _statusline(MEMORY_EXHAUSTED_ABORT); + sleep(AlertSecs); } cleanup(); } @@ -1531,7 +1518,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)(); { @@ -1590,7 +1577,7 @@ void (*func)(); * Exception-handler routines for regulating interrupts and enabling * Control-T during spawns. Includes TRUSTED flag for versions of VMS * which require it in captive accounts. This code should be used - * instead of the VAXC or DECC system(), by including LYUtils.h in + * instead of the VAXC or DECC system(), by including LYSystem.h in * modules which have system() calls. It helps ensure that we return * to Lynx instead of breaking out to DCL if a user issues interrupts * or generates an ACCVIO during spawns. @@ -1599,12 +1586,13 @@ void (*func)(); PRIVATE unsigned int DCLspawn_exception ARGS2( void *, sigarr, void *, mecharr) +{ #else PRIVATE int DCLspawn_exception ARGS2( void *, sigarr, void *, mecharr) -#endif /* __DECC */ { +#endif /* __DECC */ int status; status = lib$sig_to_ret(sigarr, mecharr); @@ -1630,11 +1618,10 @@ 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,9 +1703,7 @@ PUBLIC void lynx_start_link_color ARGS2( /* start_bold(); */ start_reverse(); #if defined(USE_SLANG) -#ifndef __DJGPP__ if (SLtt_Use_Ansi_Colors) -#endif /* !__DJGPP__ */ start_underline (); #endif /* USE_SLANG */ #if defined(FANCY_CURSES) && defined(COLOR_CURSES) @@ -1738,7 +1723,7 @@ PUBLIC void lynx_start_link_color ARGS2( PUBLIC void lynx_stop_link_color ARGS2( int, flag, - int, pending GCC_UNUSED) + int, pending) { #ifdef USE_COLOR_STYLE LynxChangeStyle(flag == ON ? s_alink : s_a, ABS_OFF, 0); @@ -1746,9 +1731,7 @@ PUBLIC void lynx_stop_link_color ARGS2( if (flag) { stop_reverse(); #if defined(USE_SLANG) -#ifndef __DJGPP__ if (SLtt_Use_Ansi_Colors) -#endif /* !__DJGPP__ */ stop_underline (); #endif /* USE_SLANG */ #if defined(FANCY_CURSES) && defined(COLOR_CURSES) diff --git a/src/LYCurses.h b/src/LYCurses.h index 1a857341..9704e532 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -1,7 +1,6 @@ #ifndef LYCURSES_H #define LYCURSES_H -#include <HTUtils.h> #include <userdefs.h> /* @@ -99,11 +98,6 @@ extern void LYsubwindow PARAMS((WINDOW * param)); # endif /* NCURSES */ -#if defined(NCURSES_VERSION) && defined(HAVE_DEFINE_KEY) -#include <term.h> -#define USE_KEYMAPS 1 -#endif - #else # if defined(VMS) && defined(__GNUC__) # include <LYGCurses.h> @@ -162,25 +156,24 @@ extern void LYstartTargetEmphasis NOPARAMS; extern void LYstopTargetEmphasis NOPARAMS; #ifdef VMS -extern int DCLsystem (char *command); 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)); -extern void curses_w_style PARAMS((WINDOW* win, int style, 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 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(style,dir,previous) curses_style(style,dir) +#define LynxChangeStyle curses_style #else extern int slang_style PARAMS((int style, int dir, int previous)); -#define LynxChangeStyle(style,dir,previous) slang_style(style,dir,previous) +#define LynxChangeStyle slang_style #endif /* USE_COLOR_STYLE */ #if USE_COLOR_TABLE @@ -191,19 +184,13 @@ extern unsigned int Lynx_Color_Flags; #endif #ifdef USE_SLANG - #if !defined(VMS) && !defined(DJGPP) #define USE_SLANG_MOUSE 1 -#endif - -#if !defined(__DJGPP__) -#define USE_KEYMAPS 1 -#endif +#endif /* USE_SLANG */ #define SL_LYNX_USE_COLOR 1 #define SL_LYNX_USE_BLINK 2 #define SL_LYNX_OVERRIDE_COLOR 4 - #define start_bold() LYaddAttr(1) #define start_reverse() LYaddAttr(2) #define start_underline() LYaddAttr(4) @@ -301,7 +288,9 @@ extern void VTHome NOPARAMS; */ #if USE_COLOR_TABLE extern void LYaddWAttr PARAMS((WINDOW *win, int a)); +extern void LYaddAttr PARAMS((int a)); extern void LYsubWAttr PARAMS((WINDOW *win, int a)); +extern void LYsubAttr PARAMS((int a)); extern void LYaddWAttr PARAMS((WINDOW *win, int a)); extern void LYsubWAttr PARAMS((WINDOW *win, int a)); extern void lynx_set_color PARAMS((int a)); @@ -389,24 +378,4 @@ 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 on DOS, MS-WINDOWS or OS/2 we open files - * and stdout in BINARY mode by default. Where necessary we should open and - * (close!) TEXT mode. - * - * Note: EMX has no corresponding variable like _fmode on DOS, but it does - * have setmode. - */ -#if defined(_WINDOWS) || defined(DJGPP) || defined(__EMX__) -#define SetOutputMode(mode) setmode(fileno(stdout), mode) -#else -#define SetOutputMode(mode) /* nothing */ -#endif - -#if defined(_WINDOWS) || defined(DJGPP) -#define SetDefaultMode(mode) _fmode = mode -#else -#define SetDefaultMode(mode) /* nothing */ -#endif - #endif /* LYCURSES_H */ diff --git a/src/LYDownload.c b/src/LYDownload.c index 884e436c..6e37de62 100644 --- a/src/LYDownload.c +++ b/src/LYDownload.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTParse.h> #include <HTList.h> #include <HTAlert.h> @@ -10,10 +11,19 @@ #include <LYClean.h> #include <LYGetFile.h> #include <LYDownload.h> +#include <LYSystem.h> +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ +#ifdef DOSPATH +#include <HTDOS.h> +#endif #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* * LYDownload takes a URL and downloads it using a user selected * download program @@ -27,7 +37,7 @@ PUBLIC BOOLEAN LYDidRename = FALSE; #endif /* VMS */ -PRIVATE char LYValidDownloadFile[LY_MAXPATH] = "\0"; +PRIVATE char LYValidDownloadFile[256] = "\0"; PUBLIC void LYDownload ARGS1( char *, line) @@ -39,7 +49,7 @@ PUBLIC void LYDownload ARGS1( char command[512]; char *cp, *cp1; lynx_html_item_type *download_command = 0; - int c; + int c, len; FILE *fp; int ch, recall; int FnameTotal; @@ -75,7 +85,6 @@ PUBLIC void LYDownload ARGS1( * Go past "SugFile=". */ sug_file += 8; - HTUnEscape(sug_file); } if ((file = (char *)strstr(Line, "File=")) == NULL) @@ -95,7 +104,6 @@ PUBLIC void LYDownload ARGS1( } #ifdef DIRED_SUPPORT - /* FIXME: use HTLocalName */ if (!strncmp(file, "file://localhost", 16)) file += 16; else if (!strncmp(file, "file:", 5)) @@ -207,7 +215,12 @@ check_recall: } if (no_dotfiles || !show_dotfiles) { - if (*LYPathLeaf(buffer) == '.') { + if (*buffer == '.' || +#ifdef VMS + ((cp = strrchr(buffer, ':')) && *(cp+1) == '.') || + ((cp = strrchr(buffer, ']')) && *(cp+1) == '.') || +#endif /* VMS */ + ((cp = strrchr(buffer, '/')) && *(cp+1) == '.')) { HTAlert(FILENAME_CANNOT_BE_DOT); _statusline(NEW_FILENAME_PROMPT); FirstRecall = TRUE; @@ -231,8 +244,17 @@ check_recall: if ((cp = strchr(buffer, '~'))) { *(cp++) = '\0'; strcpy(command, buffer); - LYTrimPathSep(command); - strcat(command, wwwName(Home_Dir())); + if ((len = strlen(command)) > 0 && command[len-1] == '/') + command[len-1] = '\0'; +#ifdef DOSPATH + strcat(command, HTDOS_wwwName((char *)Home_Dir())); +#else +#ifdef VMS + strcat(command, HTVMS_wwwName((char *)Home_Dir())); +#else + strcat(command, Home_Dir()); +#endif /* VMS */ +#endif /* DOSPATH */ strcat(command, cp); strcpy(buffer, command); } @@ -249,25 +271,17 @@ check_recall: strcpy(buffer, command); } #else - -#ifndef __EMX__ - if (!LYIsPathSep(*buffer)) { -#if defined(__DJGPP__) || defined(_WINDOWS) - if (strchr(buffer, ':') != NULL) - cp = NULL; - else -#endif /* __DJGPP__ || _WINDOWS */ + if (*buffer != '/') cp = getenv("PWD"); - } else -#endif /* __EMX__*/ cp = NULL; - - LYTrimPathSep(cp); - if (cp) { sprintf(command, "%s/%s", cp, buffer); - strcpy(buffer, HTSYS_name(command)); +#ifdef DOSPATH + strcpy(buffer, HTDOS_name(command)); +#else + strcpy(buffer, command); +#endif } #endif /* VMS */ @@ -308,8 +322,6 @@ check_recall: /* * See if we can write to it. */ - CTRACE(tfp, "LYDownload: filename is %s", buffer); - if ((fp = fopen(buffer, "w")) != NULL) { fclose(fp); remove(buffer); @@ -322,21 +334,29 @@ check_recall: } SecondS = TRUE; - HTInfoMsg(SAVING); + _statusline(SAVING); + sleep(InfoSecs); #ifdef VMS /* * Try rename() first. - FM */ - CTRACE(tfp, "command: rename(%s, %s)\n", file, buffer); + if (TRACE) + fprintf(stderr, "command: rename(%s, %s)\n", file, buffer); if (rename(file, buffer)) { /* * Failed. Use spawned COPY_COMMAND. - FM */ - CTRACE(tfp, " FAILED!\n"); + if (TRACE) + fprintf(stderr, " FAILED!\n"); sprintf(command, COPY_COMMAND, file, buffer); - CTRACE(tfp, "command: %s\n", command); + if (TRACE) + fprintf(stderr, "command: %s\n", command); + fflush(stderr); + fflush(stdout); stop_curses(); - LYSystem(command); + system(command); + fflush(stdout); + fflush(stderr); start_curses(); } else { /* @@ -348,8 +368,6 @@ check_recall: } chmod(buffer, HIDE_CHMOD); #else /* Unix: */ - -#if !( defined(__EMX__) || defined(__DJGPP__) ) /* * Prevent spoofing of the shell. */ @@ -358,15 +376,14 @@ check_recall: sprintf(command, "%s %s %s", COPY_PATH, cp, cp1); FREE(cp); FREE(cp1); -#else - /* DJGPP: no " or space possible in 8+3 dos filenames. */ - /* (but EMX probably allows spaces which should be quoted, */ - /* like Win32 LFN does...) */ - sprintf(command, "%s %s %s", COPY_PATH, file, buffer); -#endif /* __EMX__ */ - CTRACE(tfp, "command: %s\n", command); + if (TRACE) + fprintf(stderr, "command: %s\n", command); + fflush(stderr); + fflush(stdout); stop_curses(); - LYSystem(command); + system(command); + fflush(stdout); + fflush(stderr); start_curses(); #if defined(UNIX) LYRelaxFilePermissions(buffer); @@ -479,7 +496,12 @@ check_recall: } if (no_dotfiles || !show_dotfiles) { - if (*LYPathLeaf(buffer) == '.') { + if (*buffer == '.' || +#ifdef VMS + ((cp = strrchr(buffer, ':')) && *(cp+1) == '.') || + ((cp = strrchr(buffer, ']')) && *(cp+1) == '.') || +#endif /* VMS */ + ((cp = strrchr(buffer, '/')) && *(cp+1) == '.')) { HTAlert(FILENAME_CANNOT_BE_DOT); _statusline(NEW_FILENAME_PROMPT); goto again; @@ -524,13 +546,19 @@ check_recall: #endif /* VMS */ } else { - HTAlert(MISCONF_DOWNLOAD_COMMAND); + _statusline(MISCONF_DOWNLOAD_COMMAND); + sleep(AlertSecs); goto failed; } - CTRACE(tfp, "command: %s\n", command); + if (TRACE) + fprintf(stderr, "command: %s\n", command); stop_curses(); - LYSystem(command); + fflush(stderr); + fflush(stdout); + system(command); + fflush(stderr); + fflush(stdout); start_curses(); /* don't remove(file); */ } @@ -554,19 +582,21 @@ check_recall: return; failed: - HTAlert(CANNOT_DOWNLOAD_FILE); + _statusline(CANNOT_DOWNLOAD_FILE); + sleep(AlertSecs); FREE(Line); return; cancelled: - HTInfoMsg(CANCELLING); + _statusline(CANCELLING); + sleep(InfoSecs); FREE(Line); return; } /* * LYdownload_options writes out the current download choices to - * a file so that the user can select downloaders in the same way that + * a file so that the user can select printers in the same way that * they select all other links. Download links look like: * LYNXDOWNLOAD://Method=<#>/File=<STRING>/SugFile=<STRING> */ @@ -574,49 +604,56 @@ PUBLIC int LYdownload_options ARGS2( char **, newfile, char *, data_file) { - static char tempfile[LY_MAXPATH]; - char *downloaded_url = NULL; + static char tempfile[256]; + static BOOLEAN first = TRUE; + static char download_filename[256]; char *sug_filename = NULL; FILE *fp0; lynx_html_item_type *cur_download; int count; + if (first) { + tempname(tempfile, NEW_FILE); + first = FALSE; +#if defined (VMS) || defined (DOSPATH) + sprintf(download_filename, "file://localhost/%s", tempfile); +#else + sprintf(download_filename, "file://localhost%s", tempfile); +#endif /* VMS */ +#ifdef VMS + } else { + remove(tempfile); /* Remove duplicates on VMS. */ +#endif /* VMS */ + } + /* * Get a suggested filename. */ - StrAllocCopy(downloaded_url, *newfile); StrAllocCopy(sug_filename, *newfile); change_sug_filename(sug_filename); - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } - LYLocalFileToURL(newfile, tempfile); LYstrncpy(LYValidDownloadFile, data_file, (sizeof(LYValidDownloadFile) - 1)); + StrAllocCopy(*newfile, download_filename); LYforce_no_cache = TRUE; /* don't cache this doc */ + fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n", + DOWNLOAD_OPTIONS_TITLE); - BeginInternalPage(fp0, DOWNLOAD_OPTIONS_TITLE, DOWNLOAD_OPTIONS_HELP); + fprintf(fp0,"<h1>Download Options (%s Version %s)</h1><pre>\n", + LYNX_NAME, LYNX_VERSION); - fprintf(fp0, "<pre>\n"); - fprintf(fp0, "\ - <em>Downloaded link:</em> %s\n", - downloaded_url); + fprintf(fp0, " You have the following download choices.\n"); + fprintf(fp0, " Please select one:\n\n"); - fprintf(fp0, "\ - <em>Suggested file name:</em> %s\n", - sug_filename); - - fprintf(fp0, "\n%s options:\n", - (user_mode == NOVICE_MODE) ? "Standard download" : "Download"); - - if (!no_disk_save && !child_lynx) { + if(!no_disk_save && !child_lynx) #ifdef DIRED_SUPPORT /* * Disable save to disk option for local files. @@ -626,12 +663,11 @@ PUBLIC int LYdownload_options ARGS2( fprintf(fp0," \ <a href=\"LYNXDOWNLOAD://Method=-1/File=%s/SugFile=%s%s\">Save to disk</a>\n", data_file, (lynx_save_space ? lynx_save_space : ""), sug_filename); - } else { - fprintf(fp0," <em>Save to disk disabled.</em>\n"); - } - - if (user_mode == NOVICE_MODE) - fprintf(fp0, "\nLocal additions:\n"); +#ifdef DIRED_SUPPORT + else {} +#endif /* DIRED_SUPPORT */ + else + fprintf(fp0," Save to disk disabled.\n"); if (downloaders != NULL) { for (count = 0, cur_download = downloaders; cur_download != NULL; @@ -645,11 +681,13 @@ PUBLIC int LYdownload_options ARGS2( fprintf(fp0,"</a>\n"); } } + } else { + fprintf(fp0, "\n\ +No other download methods have been defined yet. You may define\n\ +an unlimited number of download methods using the lynx.cfg file.\n"); } - - fprintf(fp0, "</pre>\n"); - EndInternalPage(fp0); - LYCloseTempFP(fp0); + fprintf(fp0, "</pre>\n</body>\n"); + fclose(fp0); /* * Free off temp copy. diff --git a/src/LYDownload.h b/src/LYDownload.h index aeed2b19..8ea5b9fa 100644 --- a/src/LYDownload.h +++ b/src/LYDownload.h @@ -9,5 +9,7 @@ extern void LYDownload PARAMS((char *line)); extern int LYdownload_options PARAMS((char **newfile, char *data_file)); +#define DOWNLOAD_OPTIONS_TITLE "Lynx Download Options" + #endif /* LYDOWNLOAD_H */ diff --git a/src/LYEdit.c b/src/LYEdit.c index b05a5575..ae8a6eda 100644 --- a/src/LYEdit.c +++ b/src/LYEdit.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTParse.h> #include <HTAlert.h> #include <LYCurses.h> @@ -8,13 +9,19 @@ #include <LYGlobalDefs.h> #include <LYEdit.h> #include <LYStrings.h> -#include <LYUtils.h> +#include <LYSystem.h> #ifdef VMS #include <unixio.h> +#include <HTVMSUtils.h> #endif /* VMS */ +#ifdef DOSPATH +#include <HTDOS.h> +#endif #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* * In edit mode invoke either emacs, vi, pico, jove, jed sedt or the * default editor to display and edit the current file. @@ -36,7 +43,8 @@ PUBLIC int edit_current_file ARGS3( * If its a remote file then we can't edit it. */ if (!LYisLocalFile(newfile)) { - HTUserMsg(CANNOT_EDIT_REMOTE_FILES); + _statusline(CANNOT_EDIT_REMOTE_FILES); + sleep(MessageSecs); return FALSE; } @@ -53,7 +61,7 @@ PUBLIC int edit_current_file ARGS3( * * On VMS, only try the path. */ -#if !defined (VMS) && !defined (DOSPATH) && !defined (__EMX__) +#if !defined (VMS) && !defined (DOSPATH) colon = strchr(newfile, ':'); StrAllocCopy(filename, (colon + 1)); HTUnEscape(filename); @@ -62,16 +70,23 @@ PUBLIC int edit_current_file ARGS3( #endif /* !VMS */ filename = HTParse(newfile, "", PARSE_PATH+PARSE_PUNCTUATION); HTUnEscape(filename); -#if defined (DOSPATH) || defined (__EMX__) +#ifdef DOSPATH if (strlen(filename)>1) filename++; #endif - if ((fp = fopen(HTSYS_name(filename), "r")) == NULL) - { +#ifdef DOSPATH + if ((fp = fopen(HTDOS_name(filename),"r")) == NULL) { +#else +#ifdef VMS + if ((fp = fopen(HTVMS_name("", filename), "r")) == NULL) { +#else + if ((fp = fopen(filename, "r")) == NULL) { +#endif /* VMS */ +#endif /* DOSPATH */ HTAlert(COULD_NOT_ACCESS_FILE); FREE(filename); goto failure; } -#if !defined (VMS) && !defined (DOSPATH) && !defined (__EMX__) +#if !defined (VMS) && !defined (DOSPATH) } #endif /* !VMS */ fclose(fp); @@ -80,9 +95,17 @@ PUBLIC int edit_current_file ARGS3( /* * Don't allow editing if user lacks append access. */ - if ((fp = fopen(HTSYS_name(filename), "a")) == NULL) - { - HTUserMsg(NOAUTH_TO_EDIT_FILE); +#ifdef DOSPATH + if ((fp = fopen(HTDOS_name("", filename), "a")) == NULL) { +#else +#ifdef VMS + if ((fp = fopen(HTVMS_name("", filename), "a")) == NULL) { +#else + if ((fp = fopen(filename, "a")) == NULL) { +#endif /* VMS */ +#endif /* DOSPATH */ + _statusline(NOAUTH_TO_EDIT_FILE); + sleep(MessageSecs); goto failure; } fclose(fp); @@ -115,25 +138,38 @@ PUBLIC int edit_current_file ARGS3( sprintf(command, "%s +%d \"%s\"", editor, (lineno + (nlinks ? links[cur].ly : 0)), - HTSYS_name(filename)); +#ifdef DOSPATH + HTDOS_name(filename)); +#else + filename); +#endif /* DOSPATH */ else #ifdef __DJGPP__ sprintf(command, "%s %s", editor, HTDOS_name(filename)); #else - sprintf(command, "%s \"%s\"", editor, HTSYS_name(filename)); + sprintf(command, "%s \"%s\"", editor, +#ifdef DOSPATH + HTDOS_name(filename)); +#else + filename); +#endif /* DOSPATH */ #endif /* __DJGPP__ */ #endif /* VMS */ - CTRACE(tfp, "LYEdit: %s\n", command); - CTRACE_SLEEP(MessageSecs); -#ifndef __EMX__ + if (TRACE) { + fprintf(stderr, "LYEdit: %s\n", command); + sleep(MessageSecs); + } FREE(filename); -#endif /* * Invoke the editor. - FM */ + fflush(stderr); + fflush(stdout); stop_curses(); - LYSystem(command); + system(command); + fflush(stdout); + fflush(stderr); start_curses(); /* diff --git a/src/LYEdit.h b/src/LYEdit.h index f8ee515d..08c07625 100644 --- a/src/LYEdit.h +++ b/src/LYEdit.h @@ -1,8 +1,7 @@ + #ifndef LYEDIT_H #define LYEDIT_H -#include <HTUtils.h> - extern int edit_current_file PARAMS((char *newfile, int cur, int lineno)); #endif /* LYEDIT_H */ diff --git a/src/LYEditmap.c b/src/LYEditmap.c index cf8cc312..290a47d1 100644 --- a/src/LYEditmap.c +++ b/src/LYEditmap.c @@ -3,6 +3,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <LYStrings.h> PUBLIC int current_lineedit = 0; /* Index into LYLineEditors[] */ diff --git a/src/LYExtern.c b/src/LYExtern.c index 652fb3e2..5d4d9db8 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -15,15 +15,17 @@ See lynx.cfg for other info. */ -#include <LYUtils.h> -#include <HTAlert.h> +#include <tcp.h> #include <LYGlobalDefs.h> +#include <LYUtils.h> #include <LYExtern.h> #include <LYCurses.h> #include <LYLeaks.h> #ifdef USE_EXTERNALS +#define FREE(x) if (x) {free(x); x = NULL;} + void run_external ARGS1(char *, c) { char command[1024]; @@ -35,14 +37,18 @@ void run_external ARGS1(char *, c) externals2=externals2->next) { - if (externals2->command != 0 - && !strncasecomp(externals2->name,c,strlen(externals2->name))) +#ifdef _WINDOWS + if (!strnicmp(externals2->name,c,strlen(externals2->name))) +#else + if (!strncasecomp(externals2->name,c,strlen(externals2->name))) +#endif { char *cp; if(no_externals && !externals2->always_enabled) { - HTUserMsg(EXTERNALS_DISABLED); + statusline(EXTERNALS_DISABLED); + sleep(MessageSecs); return; } @@ -52,9 +58,9 @@ void run_external ARGS1(char *, c) * Prevent spoofing of the shell. * Dunno how this needs to be modified for VMS or DOS. - kw */ -#if defined(VMS) || defined(DOSPATH) || defined(__EMX__) +#if defined(VMS) || defined(DOSPATH) sprintf(command, externals2->command, c); -#else /* Unix: */ +#else /* Unix or DOS/Win: */ cp = quote_pathname(c); sprintf(command, externals2->command, cp); FREE(cp); @@ -63,10 +69,22 @@ void run_external ARGS1(char *, c) if (*command != '\0') { - HTUserMsg(command); + statusline(command); + sleep(MessageSecs); stop_curses(); - LYSystem(command); + fflush(stdout); +#ifdef __DJGPP__ + __djgpp_set_ctrl_c(0); + _go32_want_ctrl_break(1); +#endif /* __DJGPP__ */ + system(command); +#ifdef __DJGPP__ + __djgpp_set_ctrl_c(1); + _go32_want_ctrl_break(0); +#endif /* __DJGPP__ */ + + fflush(stdout); start_curses(); } diff --git a/src/LYForms.c b/src/LYForms.c index ff64cb2d..7a66897b 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTCJK.h> #include <HTTP.h> #include <HTAlert.h> @@ -33,8 +34,9 @@ PRIVATE int popup_options PARAMS(( int i_length, int disabled)); -PUBLIC int change_form_link ARGS5( +PUBLIC int change_form_link ARGS6( struct link *, form_link, + int, mode, document *, newdoc, BOOLEAN *, refresh_screen, char *, link_name, @@ -137,7 +139,9 @@ PUBLIC int change_form_link ARGS5( * only one down at a time! */ if (form->num_value) { - HTUserMsg(NEED_CHECKED_RADIO_BUTTON); + _statusline(NEED_CHECKED_RADIO_BUTTON); + sleep(MessageSecs); + } else { int i; /* @@ -198,7 +202,8 @@ PUBLIC int change_form_link ARGS5( if (c == '\r' || c == '\n') { form_link->hightext = form->value; if (!form->submit_action || *form->submit_action == '\0') { - HTUserMsg(NO_FORM_ACTION); + _statusline(NO_FORM_ACTION); + sleep(MessageSecs); c = DO_NOTHING; break; } else if (form->submit_method == URL_MAIL_METHOD && no_mail) { @@ -299,7 +304,8 @@ PRIVATE int form_getstr ARGS1( /* * If we can edit it, report that we are using the tail. - FM */ - HTUserMsg(FORM_VALUE_TOO_LONG); + _statusline(FORM_VALUE_TOO_LONG); + sleep(MessageSecs); switch(form->type) { case F_PASSWORD_TYPE: statusline(FORM_LINK_PASSWORD_MESSAGE); @@ -382,7 +388,7 @@ again: case PGDOWN: #ifdef NOTDEFINED case HOME: - case END_KEY: + case END: case FIND_KEY: case SELECT_KEY: #endif /* NOTDEFINED */ @@ -449,7 +455,8 @@ breakfor: */ form->value[(strlen(form->value) - strlen(value))] = '\0'; StrAllocCat(form->value, MyEdit.buffer); - HTUserMsg(FORM_TAIL_COMBINED_WITH_HEAD); + _statusline(FORM_TAIL_COMBINED_WITH_HEAD); + sleep(MessageSecs); } /* @@ -501,7 +508,8 @@ PRIVATE int get_popup_option_number ARGS1( * Get the number, possibly with a suffix, from the user. */ if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); *c = '\0'; return(0); } @@ -804,8 +812,8 @@ redraw: SLsmg_gotorc((LYlines - 1), (LYcols - 1)); SLsmg_refresh(); #else - wmove(form_window, ((i + 1) - window_offset), 2); wstart_reverse(form_window); + wmove(form_window, ((i + 1) - window_offset), 2); paddstr(form_window, width, opt_ptr->name); wstop_reverse(form_window); /* @@ -864,7 +872,8 @@ redraw: */ if (number <= 1) { if (window_offset == 0) { - HTUserMsg(ALREADY_AT_OPTION_BEGIN); + _statusline(ALREADY_AT_OPTION_BEGIN); + sleep(MessageSecs); if (disabled) { _statusline(FORM_LINK_OPTION_LIST_UNM_MSG); } else { @@ -888,7 +897,8 @@ redraw: */ if (number >= npages) { if (window_offset >= ((num_options - length) + 1)) { - HTUserMsg(ALREADY_AT_OPTION_END); + _statusline(ALREADY_AT_OPTION_END); + sleep(MessageSecs); if (disabled) { _statusline(FORM_LINK_OPTION_LIST_UNM_MSG); } else { @@ -915,7 +925,8 @@ redraw: */ if (((number - 1) * length) == window_offset) { sprintf(buffer, ALREADY_AT_OPTION_PAGE, number); - HTUserMsg(buffer); + _statusline(buffer); + sleep(MessageSecs); if (disabled) { _statusline(FORM_LINK_OPTION_LIST_UNM_MSG); } else { @@ -965,7 +976,8 @@ redraw: */ sprintf(buffer, OPTION_ALREADY_CURRENT, (number + 1)); - HTUserMsg(buffer); + _statusline(buffer); + sleep(MessageSecs); if (disabled) { _statusline(FORM_LINK_OPTION_LIST_UNM_MSG); } else { @@ -1003,7 +1015,8 @@ redraw: /* * Not in range. - FM */ - HTUserMsg(BAD_OPTION_NUM_ENTERED); + _statusline(BAD_OPTION_NUM_ENTERED); + sleep(MessageSecs); } } @@ -1238,7 +1251,8 @@ redraw: /* * User cancelled the search via ^G. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } } @@ -1249,7 +1263,8 @@ check_recall: /* * No entry. Simply break. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } @@ -1302,7 +1317,8 @@ check_recall: /* * User cancelled the search via ^G. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } goto check_recall; @@ -1358,7 +1374,8 @@ check_recall: /* * User cancelled the search via ^G. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } goto check_recall; @@ -1404,7 +1421,8 @@ check_recall: * If we started at the beginning, it can't be present. - FM */ if (cur_selection == 0) { - HTUserMsg2(STRING_NOT_FOUND, prev_target_buffer); + _user_message(STRING_NOT_FOUND, prev_target_buffer); + sleep(MessageSecs); goto restore_popup_statusline; } @@ -1442,7 +1460,8 @@ check_recall: /* * Didn't find it in the preceding options either. - FM */ - HTUserMsg2(STRING_NOT_FOUND, prev_target_buffer); + _user_message(STRING_NOT_FOUND, prev_target_buffer); + sleep(MessageSecs); restore_popup_statusline: /* diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 21717afd..037e4c99 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTTP.h> #include <HTAnchor.h> /* Anchor class */ #include <HTAccess.h> @@ -13,17 +14,23 @@ #include <LYSignal.h> #include <LYGetFile.h> #include <LYPrint.h> -#include <LYOptions.h> #include <LYHistory.h> #include <LYStrings.h> #include <LYClean.h> #include <LYDownload.h> #include <LYNews.h> #include <LYMail.h> +#include <LYSystem.h> #include <LYKeymap.h> #include <LYBookmark.h> #include <LYMap.h> #include <LYList.h> +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ +#ifdef DOSPATH +#include <HTDOS.h> +#endif #ifdef DIRED_SUPPORT #include <LYLocal.h> #endif /* DIRED_SUPPORT */ @@ -37,12 +44,49 @@ #endif /* SYSLOG_REQUESTED_URLS */ #endif /* !VMS */ +#define FREE(x) if (x) {free(x); x = NULL;} + PRIVATE int fix_http_urls PARAMS((document *doc)); extern char * WWW_Download_File; #ifdef VMS extern BOOLEAN LYDidRename; #endif /* VMS */ +#if 0 /* UNUSED */ +#ifdef DIRED_SUPPORT +PRIVATE char * LYSanctify ARGS1( + char *, href) +{ + int i; + char *p, *cp, *tp; + char address_buffer[1024]; + + i = (strlen(href) - 1); + while (i && href[i] == '/') href[i--] = '\0'; + + if ((cp = (char *)strchr(href,'~')) != NULL) { + if (!strncmp(href, "file://localhost/", 17)) + tp = (href + 17); + else + tp = (href + 5); + if ((cp - tp) && *(cp-1) != '/') + return href; + LYstrncpy(address_buffer, href, (cp - href)); + if (address_buffer[(strlen(address_buffer) - 1)] == '/') + address_buffer[(strlen(address_buffer) - 1)] = '\0'; + p = (char *)Home_Dir(); + strcat(address_buffer, p); + if (strlen(++cp)) + strcat(address_buffer, cp); + if (strcmp(href, address_buffer)) + StrAllocCopy(href, address_buffer); + } + return href; +} +#endif /* DIRED_SUPPORT */ +#endif + + PUBLIC BOOLEAN getfile ARGS1( document *, doc) { @@ -55,7 +99,9 @@ PUBLIC BOOLEAN getfile ARGS1( * Reset LYCancelDownload to prevent unwanted delayed effect. - KW */ if (LYCancelDownload) { - CTRACE(tfp, "getfile: resetting LYCancelDownload to FALSE\n"); + if (TRACE) + fprintf(stderr, + "getfile: resetting LYCancelDownload to FALSE\n"); LYCancelDownload = FALSE; } @@ -85,7 +131,9 @@ Try_Redirected_URL: */ redirect_post_content = FALSE; - CTRACE(tfp,"getfile: getting %s\n\n",doc->address); + if (TRACE) { + fprintf(stderr,"getfile: getting %s\n\n",doc->address); + } /* * Protect against denial of service attacks @@ -157,7 +205,8 @@ Try_Redirected_URL: (lynxjumpfile != NULL && 0==strncasecomp(WWWDoc.address, lynxjumpfile, strlen(lynxjumpfile))))) { - HTUserMsg(NOT_HTTP_URL_OR_ACTION); + _statusline(NOT_HTTP_URL_OR_ACTION); + sleep(MessageSecs); return(NULLFILE); } } @@ -176,7 +225,6 @@ Try_Redirected_URL: url_type == LYNXIMGMAP_URL_TYPE || url_type == LYNXCOOKIE_URL_TYPE || url_type == LYNXPRINT_URL_TYPE || - url_type == LYNXOPTIONS_URL_TYPE || url_type == LYNXDOWNLOAD_URL_TYPE || url_type == MAILTO_URL_TYPE || url_type == NEWSPOST_URL_TYPE || @@ -197,7 +245,8 @@ Try_Redirected_URL: (lynxjumpfile != NULL && 0==strncasecomp(WWWDoc.address, lynxjumpfile, strlen(lynxjumpfile))))) { - HTUserMsg(NOT_IN_STARTING_REALM); + _statusline(NOT_IN_STARTING_REALM); + sleep(MessageSecs); return(NULLFILE); } } @@ -209,12 +258,13 @@ Try_Redirected_URL: url_type != GOPHER_URL_TYPE && url_type != CSO_URL_TYPE && url_type != PROXY_URL_TYPE && - url_type != LYNXOPTIONS_URL_TYPE && !(url_type == FILE_URL_TYPE && *(LYlist_temp_url()) && !strncmp(WWWDoc.address, LYlist_temp_url(), strlen(LYlist_temp_url())))) { - CTRACE(tfp, "getfile: dropping post_data!\n"); + if (TRACE) + fprintf(stderr, + "getfile: dropping post_data!\n"); HTAlert("POST not supported for this URL - ignoring POST data!"); FREE(doc->post_data); FREE(doc->post_content_type); @@ -239,19 +289,14 @@ Try_Redirected_URL: } else if (url_type == LYNXPRINT_URL_TYPE) { return(printfile(doc)); -#ifndef NO_OPTION_FORMS - } else if (url_type == LYNXOPTIONS_URL_TYPE) { - /* forms-based options menu */ - return(postoptions(doc)); -#endif - } else if (url_type == NEWSPOST_URL_TYPE || url_type == NEWSREPLY_URL_TYPE || url_type == SNEWSPOST_URL_TYPE || url_type == SNEWSREPLY_URL_TYPE) { if (no_newspost) { - HTUserMsg(NEWSPOSTING_DISABLED); + _statusline(NEWSPOSTING_DISABLED); + sleep(MessageSecs); return(NULLFILE); } else { HTLoadAbsolute(&WWWDoc); @@ -279,7 +324,8 @@ Try_Redirected_URL: } else if (url_type == LYNXDIRED_URL_TYPE) { #ifdef DIRED_SUPPORT if (no_dired_support) { - HTUserMsg(DIRED_DISABLED); + _statusline(DIRED_DISABLED); + sleep(MessageSecs); return(NULLFILE); } else { local_dired(doc); @@ -295,7 +341,8 @@ Try_Redirected_URL: return(NORMAL); } #else - HTUserMsg(DIRED_DISABLED); + _statusline(DIRED_DISABLED); + sleep(MessageSecs); return(NULLFILE); #endif /* DIRED_SUPPORT */ @@ -340,10 +387,12 @@ Try_Redirected_URL: if (no_exec && !exec_ok(HTLoadedDocumentURL(), doc->address+9, ALWAYS_EXEC_PATH)) { - HTUserMsg(EXECUTION_DISABLED); + statusline(EXECUTION_DISABLED); + sleep(MessageSecs); } else if (no_bookmark_exec && HTLoadedDocumentBookmark()) { - HTUserMsg(BOOKMARK_EXEC_DISABLED); + statusline(BOOKMARK_EXEC_DISABLED); + sleep(MessageSecs); } else if (local_exec || (local_exec_on_local_files && exec_ok(HTLoadedDocumentURL(), doc->address+9, EXEC_PATH))) { @@ -364,7 +413,15 @@ Try_Redirected_URL: if ((cp = strchr(doc->address, '~'))) { strncpy(addressbuf, doc->address, cp-doc->address); addressbuf[cp - doc->address] = '\0'; - p = wwwName(Home_Dir()); +#ifdef DOSPATH + p = HTDOS_wwwName((char *)Home_Dir()); +#else +#ifdef VMS + p = HTVMS_wwwName((char *)Home_Dir()); +#else + p = (char *)Home_Dir(); +#endif /* VMS */ +#endif /* DOSPATH */ strcat(addressbuf, p); strcat(addressbuf, cp+1); p = addressbuf; @@ -372,15 +429,16 @@ Try_Redirected_URL: /* * Show URL before executing it. */ - HTInfoMsg(doc->address); + statusline(doc->address); + sleep(InfoSecs); stop_curses(); /* * Run the command. */ if (strstr(p,"//") == p+9) - LYSystem(p+11); + system(p+11); else - LYSystem(p+9); + system(p+9); if (url_type != LYNXPROG_URL_TYPE) { /* * Make sure user gets to see screen output. @@ -407,16 +465,19 @@ Try_Redirected_URL: sprintf(buf, EXECUTION_DISABLED_FOR_FILE, key_for_func(LYK_OPTIONS)); - HTAlert(buf); + _statusline(buf); + sleep(AlertSecs); } #else /* no exec_links */ - HTUserMsg(EXECUTION_NOT_COMPILED); + _statusline(EXECUTION_NOT_COMPILED); + sleep(MessageSecs); #endif /* EXEC_LINKS */ return(NULLFILE); } else if (url_type == MAILTO_URL_TYPE) { if (no_mail) { - HTUserMsg(MAIL_DISABLED); + _statusline(MAIL_DISABLED); + sleep(MessageSecs); } else { HTParentAnchor *tmpanchor; CONST char *title; @@ -450,7 +511,8 @@ Try_Redirected_URL: url_type != LYNXCGI_URL_TYPE && !(LYisLocalHost(doc->address) || LYisLocalAlias(doc->address))) { - HTUserMsg(ACCESS_ONLY_LOCALHOST); + statusline(ACCESS_ONLY_LOCALHOST); + sleep(MessageSecs); return(NULLFILE); /* @@ -460,9 +522,11 @@ Try_Redirected_URL: url_type == TN3270_URL_TYPE || url_type == TELNET_GOPHER_URL_TYPE) { if (!telnet_ok) { - HTUserMsg(TELNET_DISABLED); + _statusline(TELNET_DISABLED); + sleep(MessageSecs); } else if (no_telnet_port && strchr(doc->address+7, ':')) { - HTUserMsg(TELNET_PORT_SPECS_DISABLED); + statusline(TELNET_PORT_SPECS_DISABLED); + sleep(MessageSecs); } else { stop_curses(); HTLoadAbsolute(&WWWDoc); @@ -476,12 +540,14 @@ Try_Redirected_URL: * Disable www news access if not news_ok. */ } else if (url_type == NEWS_URL_TYPE && !news_ok) { - HTUserMsg(NEWS_DISABLED); + _statusline(NEWS_DISABLED); + sleep(MessageSecs); return(NULLFILE); } else if (url_type == RLOGIN_URL_TYPE) { if (!rlogin_ok) { - HTUserMsg(RLOGIN_DISABLED); + statusline(RLOGIN_DISABLED); + sleep(MessageSecs); } else { stop_curses(); HTLoadAbsolute(&WWWDoc); @@ -542,7 +608,8 @@ Try_Redirected_URL: } else { if (url_type == FTP_URL_TYPE && !ftp_ok) { - HTUserMsg(FTP_DISABLED); + statusline(FTP_DISABLED); + sleep(MessageSecs); return(NULLFILE); } @@ -554,7 +621,9 @@ Try_Redirected_URL: if ((cp=strchr(doc->address+9, '/')) != NULL && 0==strncmp(++cp, "hGET%20/", 8)) { StrAllocCopy(tmp, "http://"); - CTRACE(tfp, "getfile: URL '%s'\n", + if (TRACE) + fprintf(stderr, + "getfile: URL '%s'\n", doc->address); *cp = '\0'; StrAllocCat(tmp, doc->address+9); @@ -568,8 +637,9 @@ Try_Redirected_URL: if (strlen(cp+7) > 1) StrAllocCat(tmp, cp+8); StrAllocCopy(doc->address, tmp); - CTRACE(tfp, " changed to '%s'\n", - doc->address); + if (TRACE) + fprintf(stderr, " changed to '%s'\n", + doc->address); FREE(tmp); url_type = HTTP_URL_TYPE; } @@ -600,27 +670,42 @@ Try_Redirected_URL: char *cp1 = strstr(doc->address, "/~"); char *cp2; - CTRACE(tfp, "getfile: URL '%s'\n", - doc->address); + if (TRACE) + fprintf(stderr, "getfile: URL '%s'\n", + doc->address); *cp1 = '\0'; cp1 += 2; StrAllocCopy(temp, doc->address); - LYAddHtmlSep(&temp); - StrAllocCat(temp, wwwName(Home_Dir())); +#ifdef DOSPATH + StrAllocCat(temp, "/"); + StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir())); +#else +#ifdef VMS + StrAllocCat(temp, + HTVMS_wwwName((char *)Home_Dir())); +#else + StrAllocCat(temp, Home_Dir()); +#endif /* VMS */ +#endif /* DOSPATH */ if ((cp2 = strchr(cp1, '/')) != NULL) { LYTrimRelFromAbsPath(cp2); StrAllocCat(temp, cp2); } StrAllocCopy(doc->address, temp); FREE(temp); - CTRACE(tfp, " changed to '%s'\n", - doc->address); + if (TRACE) + fprintf(stderr, " changed to '%s'\n", + doc->address); WWWDoc.address = doc->address; } FREE(cp); } - CTRACE_SLEEP(MessageSecs); + if (TRACE && LYTraceLogFP == NULL) + sleep(MessageSecs); user_message(WWW_WAIT_MESSAGE, doc->address); +#ifdef NOTDEFINED + sleep(InfoSecs); +#endif /* NOTDEFINED */ if (TRACE) { #ifdef USE_SLANG if (LYCursesON) { @@ -628,7 +713,7 @@ Try_Redirected_URL: refresh(); } #endif /* USE_SLANG */ - fprintf(tfp,"\n"); + fprintf(stderr,"\n"); } if ((LYNoRefererHeader == FALSE && LYNoRefererForThis == FALSE) && @@ -690,7 +775,6 @@ Try_Redirected_URL: url_type == LYNXDIRED_URL_TYPE || #endif /* DIRED_SUPPORT */ url_type == LYNXPRINT_URL_TYPE || - url_type == LYNXOPTIONS_URL_TYPE || url_type == LYNXHIST_URL_TYPE || url_type == LYNXCOOKIE_URL_TYPE || (LYValidate && @@ -756,16 +840,20 @@ Try_Redirected_URL: * be positioned at the top of that document, * so there's no harm done. - FM */ - CTRACE(tfp, + if (TRACE) { + fprintf(stderr, "getfile: Adding fragment '%s' to redirection URL.\n", pound); + } StrAllocCat(use_this_url_instead, pound); } - CTRACE_SLEEP(MessageSecs); + if (TRACE && LYTraceLogFP == NULL) + sleep(MessageSecs); _user_message(WWW_USING_MESSAGE, use_this_url_instead); sleep(InfoSecs); - CTRACE(tfp, "\n"); + if (TRACE) + fprintf(stderr, "\n"); StrAllocCopy(doc->address, use_this_url_instead); FREE(use_this_url_instead); @@ -817,7 +905,7 @@ Try_Redirected_URL: HTMLSetCharacterHandling(current_char_set); /* * Check for a suggested filename from - * the Content-Disposition header. - FM + * the Content-Dispostion header. - FM */ if (((tmpanchor = HTAnchor_parent( HTAnchor_findAddress(&WWWDoc) @@ -898,9 +986,12 @@ Try_Redirected_URL: } } } else { - CTRACE_SLEEP(MessageSecs); - HTUserMsg2(WWW_BAD_ADDR_MESSAGE, doc->address); - CTRACE(tfp,"\n"); + if (TRACE && LYTraceLogFP == NULL) + sleep(MessageSecs); + _user_message(WWW_BAD_ADDR_MESSAGE, doc->address); + if (TRACE) + fprintf(stderr,"\n"); + sleep(MessageSecs); return(NULLFILE); } } @@ -939,7 +1030,8 @@ PUBLIC int follow_link_number ARGS4( * Get the number, possibly with a letter suffix, from the user. */ if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return(DO_NOTHING); } *num = atoi(temp); @@ -1127,7 +1219,7 @@ PUBLIC void add_trusted ARGS2( */ PUBLIC BOOLEAN exec_ok ARGS3( CONST char *, source, - CONST char *, linktext, + CONST char *, link, int, type) { struct trust *tp; @@ -1158,7 +1250,7 @@ PUBLIC BOOLEAN exec_ok ARGS3( /* * Security: reject on relative path. */ - if ((cp = strchr(linktext, '[')) != NULL) { + if ((cp = strchr(link, '[')) != NULL) { char *cp1; if (((cp1 = strchr(cp, '-')) != NULL) && strchr(cp1, ']') != NULL) { @@ -1175,7 +1267,7 @@ PUBLIC BOOLEAN exec_ok ARGS3( /* * Security: reject on relative path. */ - if (strstr(linktext, "../") != NULL) { + if (strstr(link, "../") != NULL) { HTAlert(RELPATH_IN_EXEC_LINK); return FALSE; } @@ -1183,7 +1275,7 @@ PUBLIC BOOLEAN exec_ok ARGS3( /* * Security: reject on strange character. */ - for (cp = linktext; *cp != '\0'; cp++) { + for (cp = link; *cp != '\0'; cp++) { if (!isalnum(*cp) && *cp != '_' && *cp != '-' && *cp != ' ' && *cp != ':' && *cp != '.' && *cp != '/' && @@ -1204,9 +1296,9 @@ PUBLIC BOOLEAN exec_ok ARGS3( check_tp_for_entry: while (tp) { if (tp->type == Type) { - char CONST *command = linktext; + char CONST *command = link; - if (strstr(command,"//") == linktext) { + if (strstr(command,"//") == link) { command += 2; } #ifdef VMS @@ -1241,7 +1333,7 @@ PRIVATE int fix_http_urls ARGS1( * If it's an ftp URL with a trailing slash, trim it off. */ if (!strncmp(doc->address, "ftp", 3) && - LYIsHtmlSep(doc->address[strlen(doc->address)-1])) { + doc->address[strlen(doc->address)-1] == '/') { char * proxy; char *path = HTParse(doc->address, "", PARSE_PATH|PARSE_PUNCTUATION); @@ -1249,7 +1341,7 @@ PRIVATE int fix_http_urls ARGS1( * If the path is a lone slash, we're done. - FM */ if (path) { - if (LYIsHtmlSep(path[0]) && path[1] == '\0') { + if (path[0] == '/' && path[1] == '\0') { FREE(path); return 0; } @@ -1266,24 +1358,32 @@ PRIVATE int fix_http_urls ARGS1( /* * If we get to here, trim the trailing slash. - FM */ - CTRACE(tfp, "fix_http_urls: URL '%s'\n", doc->address); - LYTrimHtmlSep(doc->address); - CTRACE(tfp, " changed to '%s'\n", doc->address); - CTRACE_SLEEP(MessageSecs); + if (TRACE) + fprintf(stderr, "fix_http_urls: URL '%s'\n", doc->address); + doc->address[strlen(doc->address)-1] = '\0'; + if (TRACE) { + fprintf(stderr, " changed to '%s'\n", doc->address); + if (!LYTraceLogFP) + sleep(MessageSecs); + } } /* * If there isn't a slash besides the two at the beginning, append one. */ if ((slash = strrchr(doc->address, '/')) != NULL) { - if (!LYIsHtmlSep(*(slash-1)) || *(slash-2) != ':') { + if (*(slash-1) != '/' || *(slash-2) != ':') { return(0); } } - CTRACE(tfp, "fix_http_urls: URL '%s'\n", doc->address); - LYAddHtmlSep(&(doc->address)); - CTRACE(tfp, " changed to '%s'\n",doc->address); - CTRACE_SLEEP(MessageSecs); + if (TRACE) + fprintf(stderr, "fix_http_urls: URL '%s'\n", doc->address); + StrAllocCat(doc->address, "/"); + if (TRACE) { + fprintf(stderr, " changed to '%s'\n",doc->address); + if (!LYTraceLogFP) + sleep(MessageSecs); + } return(1); } diff --git a/src/LYGetFile.h b/src/LYGetFile.h index 93239e83..8ddfb999 100644 --- a/src/LYGetFile.h +++ b/src/LYGetFile.h @@ -1,8 +1,7 @@ + #ifndef LYGETFILE_H #define LYGETFILE_H -#include <LYStructs.h> - #define NOT_FOUND 0 #define NORMAL 1 #define NULLFILE 3 diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index c326615d..8d447861 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -15,22 +15,6 @@ #include <LYStructs.h> #endif /* LYSTRUCTS_H */ -#ifdef HAVE_CONFIG_H -#include <LYHelp.h> -#else -#define COOKIE_JAR_HELP "Lynx_users_guide.html#Cookies" -#define CURRENT_KEYMAP_HELP "keystrokes/keystroke_help.html" -#define DIRED_MENU_HELP "keystrokes/dired_help.html" -#define DOWNLOAD_OPTIONS_HELP "Lynx_users_guide.html#RemoteSource" -#define HISTORY_PAGE_HELP "keystrokes/history_help.html" -#define LIST_PAGE_HELP "keystrokes/follow_help.html" -#define LYNXCFG_HELP "lynx.cfg" -#define OPTIONS_HELP "keystrokes/option_help.html" -#define PRINT_OPTIONS_HELP "keystrokes/print_help.html" -#define UPLOAD_OPTIONS_HELP "Lynx_users_guide.html#DirEd" -#define VISITED_LINKS_HELP "keystrokes/visited_help.html" -#endif /* LYHELP_H */ - #ifdef SOCKS extern BOOLEAN socks_flag; #endif /* SOCKS */ @@ -45,6 +29,22 @@ 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 +55,7 @@ extern char *LYCSwingPath; #ifdef DIRED_SUPPORT extern BOOLEAN lynx_edit_mode; extern BOOLEAN no_dired_support; -extern int dir_list_style; +extern BOOLEAN dir_list_style; extern HTList *tagged; #define FILES_FIRST 1 #define MIXED_STYLE 2 @@ -111,13 +111,8 @@ extern int LYShowColor; /* Show color or monochrome? */ extern int LYChosenShowColor; /* extended color/monochrome choice */ extern int LYrcShowColor; /* ... as read or last written */ -#if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU) -extern BOOLEAN LYUseFormsOptions; /* use Forms-based options menu */ -#else -#define LYUseFormsOptions FALSE /* simplify ifdef'ing in LYMainLoop.c */ -#endif extern BOOLEAN LYShowCursor; /* Show the cursor or hide it? */ -extern BOOLEAN verbose_img; /* display filenames of images? */ +extern BOOLEAN verbose_img; /* display filenames of images? */ extern BOOLEAN LYUseDefShoCur; /* Command line -show_cursor toggle */ extern BOOLEAN LYCursesON; /* start_curses()->TRUE, stop_curses()->FALSE */ extern BOOLEAN LYUserSpecifiedURL; /* URL from a goto or document? */ @@ -141,14 +136,13 @@ extern char *helpfilepath; extern char *lynxjumpfile; extern char *lynxlistfile; extern char *lynxlinksfile; -extern char *x_display; +extern char *display; extern char *language; extern char *pref_charset; /* Lynx's preferred character set - MM */ extern BOOLEAN LYNewsPosting; /* News posting supported if TRUE */ extern char *LynxSigFile; /* Signature file, in or off home */ extern char *system_mail; extern char *system_mail_flags; -extern char *lynx_cfg_file; /* location of active lynx.cfg file */ extern char *lynx_temp_space; extern char *lynx_save_space; extern BOOLEAN LYforce_HTML_mode; @@ -156,8 +150,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 LYshow_kb_rate; /* show KB/sec in HTReadProgress */ -extern int user_mode; /* novice or advanced */ +extern BOOLEAN user_mode; /* novice or advanced */ extern BOOLEAN is_www_index; extern BOOLEAN dump_output_immediately; extern int dump_output_width; @@ -170,19 +163,20 @@ extern BOOLEAN telnet_ok; extern BOOLEAN news_ok; extern BOOLEAN ftp_ok; extern BOOLEAN rlogin_ok; -extern BOOLEAN system_editor; /* True if locked-down editor */ -extern BOOLEAN child_lynx; /* TRUE to exit with an arrow */ +extern BOOLEAN no_print; /* TRUE to disable printing */ +extern BOOLEAN system_editor; /* True if locked-down editor */ +extern BOOLEAN child_lynx; /* TRUE to exit with an arrow */ 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 int keypad_mode; /* is set to either NUMBERS_AS_ARROWS * +extern BOOLEAN 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 */ extern BOOLEAN no_outside_telnet; extern BOOLEAN no_telnet_port; -extern BOOLEAN no_inside_news; +extern BOOLEAN no_inside_news; extern BOOLEAN no_outside_news; extern BOOLEAN no_inside_ftp; extern BOOLEAN no_outside_ftp; @@ -195,8 +189,8 @@ extern BOOLEAN no_bookmark; extern BOOLEAN no_multibook; extern BOOLEAN no_bookmark_exec; extern BOOLEAN no_option_save; +extern BOOLEAN no_print; extern BOOLEAN no_download; -extern BOOLEAN no_print; /* TRUE to disable printing */ extern BOOLEAN no_disk_save; extern BOOLEAN no_exec; extern BOOLEAN no_lynxcgi; @@ -251,21 +245,12 @@ extern BOOLEAN historical_comments; extern BOOLEAN minimal_comments; extern BOOLEAN soft_dquotes; extern BOOLEAN LYCancelDownload; -extern BOOLEAN LYRestricted; extern BOOLEAN LYValidate; extern BOOLEAN LYPermitURL; extern BOOLEAN enable_scrollback; /* Clear screen before displaying new page */ extern BOOLEAN keep_mime_headers; /* Include mime headers and * * force source dump */ extern BOOLEAN no_url_redirection; /* Don't follow URL redirections */ -#ifdef DISP_PARTIAL -extern BOOLEAN display_partial; /* Display document during download */ -extern int Newline_partial; /* -//- "current" newline position */ -extern int NumOfLines_partial; /* -//- "current" number of lines */ -extern int partial_threshold; -extern BOOLEAN debug_display_partial; /* show with MessageSecs delay */ -extern BOOLEAN detected_forms_input_partial; /* trimHightext temp fix */ -#endif extern char *form_post_data; /* User data for post form */ extern char *form_get_data; /* User data for get form */ extern char *http_error_file; /* Place HTTP status code in this file */ @@ -295,44 +280,36 @@ extern BOOLEAN LYNoFromHeader; /* Never send From header? */ extern BOOLEAN LYListNewsNumbers; extern BOOLEAN LYUseMouse; extern BOOLEAN LYListNewsDates; - extern BOOLEAN LYRawMode; extern BOOLEAN LYDefaultRawMode; extern BOOLEAN LYUseDefaultRawMode; extern char *UCAssume_MIMEcharset; -extern BOOLEAN UCSaveBookmarksInUnicode; /* in titles, chars >127 save as &#xUUUU */ -extern BOOLEAN UCForce8bitTOUPPER; /* disable locale case-conversion for >127 */ -extern int outgoing_mail_charset; /* translate outgoing mail to this charset */ - +extern char *UCAssume_localMIMEcharset; +extern char *UCAssume_unrecMIMEcharset; extern BOOLEAN LYisConfiguredForX; extern char *URLDomainPrefixes; extern char *URLDomainSuffixes; extern BOOLEAN startfile_ok; extern BOOLEAN LYSelectPopups; /* Cast popups to radio buttons? */ extern BOOLEAN LYUseDefSelPop; /* Command line -popup toggle */ -extern BOOLEAN LYMultiBookmarks; /* Multi bookmark support on? */ +extern int LYMultiBookmarks; /* Multi bookmark support on? */ extern BOOLEAN LYMBMBlocked; /* Force MBM support off? */ extern BOOLEAN LYMBMAdvanced; /* MBM statusline for ADVANCED? */ extern int LYStatusLine; /* Line for statusline() or -1 */ extern BOOLEAN LYCollapseBRs; /* Collapse serial BRs? */ extern BOOLEAN LYSetCookies; /* Process Set-Cookie headers? */ -extern BOOLEAN LYAcceptAllCookies; /* accept ALL cookies? */ -extern char *LYCookieAcceptDomains; /* domains to accept all cookies */ -extern char *LYCookieRejectDomains; /* domains to reject all cookies */ -#ifdef EXP_PERSISTENT_COOKIES -extern BOOLEAN persistent_cookies; -extern char *LYCookieFile; /* file to store cookies in */ -#endif /* EXP_PERSISTENT_COOKIES */ extern char *XLoadImageCommand; /* Default image viewer for X */ #ifdef USE_EXTERNALS -extern BOOLEAN no_externals; /* don't allow the use of externals */ +extern BOOLEAN no_externals; /* don't allow the use of externals */ #endif extern BOOLEAN LYNoISMAPifUSEMAP; /* Omit ISMAP link if MAP present? */ extern int LYHiddenLinks; -extern BOOL New_DTD; +extern BOOL New_DTD; -#define MBM_V_MAXFILES 25 /* Max number of sub-bookmark files */ +#define BOOKMARK_TITLE "Bookmark file" +#define MOSAIC_BOOKMARK_TITLE "Converted Mosaic Hotlist" +#define MBM_V_MAXFILES 25 /* Max number of sub-bookmark files */ /* * Arrays that holds the names of sub-bookmark files * and their descriptions. @@ -342,6 +319,7 @@ extern char *MBM_A_subdescript[MBM_V_MAXFILES+1]; extern FILE *LYTraceLogFP; /* Pointer for TRACE log */ extern char *LYTraceLogPath; /* Path for TRACE log */ extern BOOLEAN LYUseTraceLog; /* Use a TRACE log? */ +extern FILE LYOrigStderr; /* Original stderr pointer */ extern BOOLEAN LYSeekFragMAPinCur; extern BOOLEAN LYSeekFragAREAinCur; extern BOOLEAN LYStripDotDotURLs; /* Try to fix ../ in some URLs? */ @@ -352,6 +330,10 @@ 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/LYHash.h b/src/LYHash.h index c76ae994..00f8066c 100644 --- a/src/LYHash.h +++ b/src/LYHash.h @@ -1,8 +1,6 @@ #if !defined(_LYHASH_H_) #define _LYHASH_H_ 1 -#include <HTUtils.h> - struct _hashbucket { char *name; /* name of this item */ int code; /* code of this item */ diff --git a/src/LYHistory.c b/src/LYHistory.c index 20126cc9..433114b4 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTTP.h> #include <HTAlert.h> #include <HText.h> @@ -7,7 +8,6 @@ #include <LYHistory.h> #include <LYPrint.h> #include <LYDownload.h> -#include <LYOptions.h> #include <LYKeymap.h> #include <LYList.h> #include <LYShowInfo.h> @@ -22,10 +22,12 @@ #include <LYexit.h> #include <LYLeaks.h> + +#define FREE(x) if (x) {free(x); x = NULL;} -PUBLIC HTList * Visited_Links = NULL; /* List of safe popped docs. */ +PUBLIC HTList * Visited_Links = NULL; /* List of safe popped docs. */ -/* +/* * Utility for freeing the list of visited links. - FM */ PRIVATE void Visited_Links_free NOARGS @@ -34,7 +36,7 @@ PRIVATE void Visited_Links_free NOARGS HTList *cur = Visited_Links; if (!cur) - return; + return; while (NULL != (vl = (VisitedLink *)HTList_nextObject(cur))) { FREE(vl->address); @@ -46,7 +48,7 @@ PRIVATE void Visited_Links_free NOARGS return; } -/* +/* * Utility for listing visited links, making any repeated * links the most current in the list. - FM */ @@ -58,17 +60,16 @@ PUBLIC void LYAddVisitedLink ARGS1( HTList *cur; if (!(doc->address && *doc->address)) - return; + return; /* - * Exclude POST or HEAD replies, and bookmark, menu - * or list files. - FM + * Exclude POST or HEAD replies, and bookmark, menu + * or list files. - FM */ if (doc->post_data || doc->isHEAD || doc->bookmark || !strcmp((doc->title ? doc->title : ""), HISTORY_PAGE_TITLE) || !strcmp((doc->title ? doc->title : ""), PRINT_OPTIONS_TITLE) || !strcmp((doc->title ? doc->title : ""), DOWNLOAD_OPTIONS_TITLE) || - !strcmp((doc->title ? doc->title : ""), OPTIONS_TITLE) || #ifdef DIRED_SUPPORT !strcmp((doc->title ? doc->title : ""), DIRED_MENU_TITLE) || !strcmp((doc->title ? doc->title : ""), UPLOAD_OPTIONS_TITLE) || @@ -84,12 +85,12 @@ PUBLIC void LYAddVisitedLink ARGS1( } if ((new = (VisitedLink *)calloc(1, sizeof(*new))) == NULL) - outofmem(__FILE__, "HTAddVisitedLink"); + outofmem(__FILE__, "HTAddVisitedLink"); StrAllocCopy(new->address, doc->address); StrAllocCopy(new->title, (doc->title ? doc->title : "(no title)")); if (!Visited_Links) { - Visited_Links = HTList_new(); + Visited_Links = HTList_new(); atexit(Visited_Links_free); HTList_addObject(Visited_Links, new); return; @@ -100,7 +101,7 @@ PUBLIC void LYAddVisitedLink ARGS1( if (!strcmp((old->address ? old->address : ""), (new->address ? new->address : "")) && !strcmp((old->title ? new->title : ""), - (new->title ? new->title : ""))) { + (new->title ? new->title : ""))) { FREE(old->address); FREE(old->title); HTList_removeObject(Visited_Links, old); @@ -114,26 +115,6 @@ PUBLIC void LYAddVisitedLink ARGS1( } /* - * Returns true if this is a page that we would push onto the stack if not - * forced. - */ -PUBLIC BOOLEAN LYwouldPush ARGS1( - char *, title) -{ - return (!strcmp(title, HISTORY_PAGE_TITLE) - || !strcmp(title, PRINT_OPTIONS_TITLE) - || !strcmp(title, DOWNLOAD_OPTIONS_TITLE) -#ifdef DIRED_SUPPORT - || !strcmp(title, DIRED_MENU_TITLE) - || !strcmp(title, UPLOAD_OPTIONS_TITLE) - || !strcmp(title, PERMIT_OPTIONS_TITLE) -#endif /* DIRED_SUPPORT */ - ) - ? FALSE - : TRUE; -} - -/* * Push the current filename, link and line number onto the history list. */ PUBLIC void LYpush ARGS2( @@ -141,54 +122,98 @@ PUBLIC void LYpush ARGS2( BOOLEAN, force_push) { /* - * Don't push NULL file names. + * Don't push NULL file names. */ if (*doc->address == '\0') return; /* - * Check whether this is a document we - * don't push unless forced. - FM + * Check whether this is a document we + * don't push unless forced. - FM */ if (!force_push) { /* * Don't push the history, printer, or download lists. */ - if (!LYwouldPush(doc->title)) { + if (!strcmp(doc->title, HISTORY_PAGE_TITLE) || + !strcmp(doc->title, PRINT_OPTIONS_TITLE) || + !strcmp(doc->title, DOWNLOAD_OPTIONS_TITLE)) { if (!LYforce_no_cache) LYoverride_no_cache = TRUE; return; } + +#ifdef DIRED_SUPPORT + /* + * Don't push DIRED menu, upload or permit lists. + */ + if (!strcmp(doc->title, DIRED_MENU_TITLE) || + !strcmp(doc->title, UPLOAD_OPTIONS_TITLE) || + !strcmp(doc->title, PERMIT_OPTIONS_TITLE)) { + if (!LYforce_no_cache) + LYoverride_no_cache = TRUE; + return; + } +#endif /* DIRED_SUPPORT */ } /* - * If file is identical to one before it, don't push it. + * If file is identical to one before it, don't push it. */ if (nhist> 1 && - STREQ(history[nhist-1].address, doc->address) && - !strcmp(history[nhist-1].post_data ? + STREQ(history[nhist-1].address, doc->address) && + !strcmp(history[nhist-1].post_data ? history[nhist-1].post_data : "", - doc->post_data ? + doc->post_data ? doc->post_data : "") && - !strcmp(history[nhist-1].bookmark ? + !strcmp(history[nhist-1].bookmark ? history[nhist-1].bookmark : "", - doc->bookmark ? + doc->bookmark ? doc->bookmark : "") && history[nhist-1].isHEAD == doc->isHEAD) { if (history[nhist-1].internal_link == doc->internal_link) { /* But it is nice to have the last position remembered! - kw */ history[nhist-1].link = doc->link; - history[nhist-1].line = doc->line; - return; + history[nhist-1].page = doc->line; + return; } } + +#ifdef NOTDEFINED +/* +** The following segment not used any more - What's it good for, +** anyway?? Doing a pop when a push is requested is confusing, +** also to the user. Moreover, the way it was done seems to cause +** a memory leak. - KW +*/ /* + * If file is identical to one two before it, don't push it. + */ + if (nhist > 2 && + STREQ(history[nhist-2].address, doc->address) && + !strcmp(history[nhist-2].post_data ? + history[nhist-2].post_data : "", + doc->post_data ? + doc->post_data : "") && + !strcmp(history[nhist-2].bookmark ? + history[nhist-2].bookmark : "", + doc->bookmark ? + doc->bookmark : "") && + history[nhist-2].isHEAD == doc->isHEAD) { + /* + * Pop one off the stack. + */ + nhist--; + return; + } +#endif /* NOTDEFINED */ + /* - * OK, push it if we have stack space. + * OK, push it if we have stack space. */ if (nhist < MAXHIST) { history[nhist].link = doc->link; - history[nhist].line = doc->line; + history[nhist].page = doc->line; history[nhist].title = NULL; StrAllocCopy(history[nhist].title, doc->title); history[nhist].address = NULL; @@ -205,7 +230,7 @@ PUBLIC void LYpush ARGS2( history[nhist].internal_link = FALSE; /* by default */ history[nhist].intern_seq_start = -1; /* by default */ if (doc->internal_link) { - /* Now some tricky stuff: if the caller thinks that the doc + /* Now some tricky stuff: if the caller thinks that the doc to push was the result of following an internal (fragment) link, we check whether we believe it. It is only accepted as valid if the immediately preceding @@ -278,24 +303,37 @@ PUBLIC void LYpush ARGS2( history[nhist].intern_seq_start = history[nhist-1].intern_seq_start >= 0 ? history[nhist-1].intern_seq_start : nhist-1; - CTRACE(tfp, "\nLYpush: pushed as internal link, OK\n"); + if (TRACE) { + fprintf(stderr, + "\nLYpush: pushed as internal link, OK\n"); + } } } } if (!history[nhist].internal_link) { - CTRACE(tfp, "\nLYpush: push as internal link requested, %s\n", + if (TRACE) { + fprintf(stderr, + "\nLYpush: push as internal link requested, %s\n", "but didn't check out!"); + } } } - CTRACE(tfp, "\nLYpush[%d]: address:%s\n title:%s\n", - nhist, doc->address, doc->title); nhist++; - } else { - if (LYCursesON) { - HTAlert(MAXHIST_REACHED); + if (TRACE) { + fprintf(stderr, + "\nLYpush: address:%s\n title:%s\n", + doc->address, doc->title); } - CTRACE(tfp, "\nLYpush: MAXHIST reached for:\n address:%s\n title:%s\n", + } else { + if (LYCursesON) { + _statusline(MAXHIST_REACHED); + sleep(AlertSecs); + } + if (TRACE) { + fprintf(stderr, + "\nLYpush: MAXHIST reached for:\n address:%s\n title:%s\n", doc->address, doc->title); + } } } @@ -308,11 +346,11 @@ PUBLIC void LYpop ARGS1( if (nhist > 0) { nhist--; doc->link = history[nhist].link; - doc->line = history[nhist].line; + doc->line = history[nhist].page; FREE(doc->title); doc->title = history[nhist].title; /* will be freed later */ FREE(doc->address); - doc->address = history[nhist].address; /* will be freed later */ + doc->address = history[nhist].address; /* will be freed later */ FREE(doc->post_data); doc->post_data = history[nhist].post_data; FREE(doc->post_content_type); @@ -322,13 +360,11 @@ PUBLIC void LYpop ARGS1( doc->isHEAD = history[nhist].isHEAD; doc->safe = history[nhist].safe; doc->internal_link = history[nhist].internal_link; -#ifdef DISP_PARTIAL - /* assume we pop the 'doc' to show it soon... */ - Newline_partial = doc->line; /* reinitialize */ - NumOfLines_partial = -1; /* initialize to -1 */ -#endif /* DISP_PARTIAL */ - CTRACE(tfp, "LYpop[%d]: address:%s\n title:%s\n", - nhist, doc->address, doc->title); + if (TRACE) { + fprintf(stderr, + "LYpop: address:%s\n title:%s\n", + doc->address, doc->title); + } } } @@ -343,7 +379,7 @@ PUBLIC void LYpop_num ARGS2( { if (number >= 0 && nhist > number) { doc->link = history[number].link; - doc->line = history[number].line; + doc->line = history[number].page; StrAllocCopy(doc->title, history[number].title); StrAllocCopy(doc->address, history[number].address); StrAllocCopy(doc->post_data, history[number].post_data); @@ -352,11 +388,6 @@ PUBLIC void LYpop_num ARGS2( doc->isHEAD = history[number].isHEAD; doc->safe = history[number].safe; doc->internal_link = history[number].internal_link; /* ?? */ -#ifdef DISP_PARTIAL - /* assume we pop the 'doc' to show it soon... */ - Newline_partial = doc->line; /* reinitialize */ - NumOfLines_partial = -1; /* initialize to -1 */ -#endif /* DISP_PARTIAL */ } } @@ -366,25 +397,45 @@ PUBLIC void LYpop_num ARGS2( PUBLIC int showhistory ARGS1( char **, newfile) { - static char tempfile[LY_MAXPATH]; + static char tempfile[256]; + static BOOLEAN first = TRUE; + static char hist_filename[256]; char *Title = NULL; int x = 0; FILE *fp0; - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { + if (first) { + tempname(tempfile, NEW_FILE); + /* + * Make the file a URL now. + */ +#if defined (VMS) || defined (DOSPATH) + sprintf(hist_filename,"file://localhost/%s", tempfile); +#else + sprintf(hist_filename,"file://localhost%s", tempfile); +#endif /* VMS */ + first = FALSE; +#ifdef VMS + } else { + remove(tempfile); /* Remove duplicates on VMS. */ +#endif /* VMS */ + } + + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } - LYLocalFileToURL(newfile, tempfile); - + StrAllocCopy(*newfile, hist_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ - BeginInternalPage(fp0, HISTORY_PAGE_TITLE, HISTORY_PAGE_HELP); - - fprintf(fp0, "<pre>\n"); + fprintf(fp0, "<head>\n"); + LYAddMETAcharsetToFD(fp0, -1); + fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", + HISTORY_PAGE_TITLE); + fprintf(fp0, "<h1>You have reached the History Page</h1>\n"); + fprintf(fp0, "<h2>%s Version %s</h2>\n<pre>", LYNX_NAME, LYNX_VERSION); fprintf(fp0, "<em>You selected:</em>\n"); for (x = nhist-1; x >= 0; x--) { /* @@ -399,7 +450,7 @@ PUBLIC int showhistory ARGS1( } fprintf(fp0, "%s<em>%d</em>. <tab id=t%d><a href=\"LYNXHIST:%d\">%s</a>\n", - (x > 99 ? "" : x < 10 ? " " : " "), + (x > 99 ? "" : x < 10 ? " " : " "), x, x, x, Title); if (history[x].address != NULL) { StrAllocCopy(Title, history[x].address); @@ -415,15 +466,15 @@ PUBLIC int showhistory ARGS1( } fprintf(fp0, "<tab to=t%d>%s\n", x, Title); } - fprintf(fp0,"</pre>\n"); - EndInternalPage(fp0); - LYCloseTempFP(fp0); + fprintf(fp0,"</pre>\n</body>\n"); + + fclose(fp0); FREE(Title); return(0); } -/* +/* * This function makes the history page seem like any other type of * file since more info is needed than can be provided by the normal * link structure. We saved out the history number to a special URL. @@ -439,11 +490,11 @@ PUBLIC BOOLEAN historytarget ARGS1( BOOLEAN treat_as_intern = FALSE; if ((!newdoc || !newdoc->address) || - strlen(newdoc->address) < 10 || !isdigit(*(newdoc->address+9))) + strlen(newdoc->address) < 10 || !isdigit(*(newdoc->address+9))) return(FALSE); if ((number = atoi(newdoc->address+9)) > nhist || number < 0) - return(FALSE); + return(FALSE); LYpop_num(number, newdoc); if (((newdoc->internal_link && @@ -462,20 +513,20 @@ PUBLIC BOOLEAN historytarget ARGS1( newdoc->internal_link = FALSE; } /* - * If we have POST content, and have LYresubmit_posts set - * or have no_cache set or do not still have the text cached, - * ask the user whether to resubmit the form. - FM + * If we have POST content, and have LYresubmit_posts set + * or have no_cache set or do not still have the text cached, + * ask the user whether to resubmit the form. - FM */ if (newdoc->post_data != NULL) { WWWDoc.address = newdoc->address; - WWWDoc.post_data = newdoc->post_data; - WWWDoc.post_content_type = newdoc->post_content_type; - WWWDoc.bookmark = newdoc->bookmark; + WWWDoc.post_data = newdoc->post_data; + WWWDoc.post_content_type = newdoc->post_content_type; + WWWDoc.bookmark = newdoc->bookmark; WWWDoc.isHEAD = newdoc->isHEAD; WWWDoc.safe = newdoc->safe; tmpanchor = HTAnchor_parent(HTAnchor_findAddress(&WWWDoc)); text = (HText *)HTAnchor_document(tmpanchor); - if (((((LYresubmit_posts == TRUE) || + if (((((LYresubmit_posts == TRUE) || (LYforce_no_cache == TRUE && LYoverride_no_cache == FALSE)) && !(treat_as_intern && !reloading)) || @@ -488,7 +539,8 @@ PUBLIC BOOLEAN historytarget ARGS1( LYforce_no_cache = FALSE; LYoverride_no_cache = TRUE; } else { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return(FALSE); } } @@ -505,7 +557,9 @@ PUBLIC BOOLEAN historytarget ARGS1( PUBLIC int LYShowVisitedLinks ARGS1( char **, newfile) { - static char tempfile[LY_MAXPATH]; + static char tempfile[256]; + static BOOLEAN first = TRUE; + static char vl_filename[256]; char *Title = NULL; char *Address = NULL; int x; @@ -514,23 +568,41 @@ PUBLIC int LYShowVisitedLinks ARGS1( HTList *cur = Visited_Links; if (!cur) - return(-1); + return(-1); + + if (first) { + tempname(tempfile, NEW_FILE); + /* + * Make the file a URL now. + */ +#if defined (VMS) || defined (DOSPATH) + sprintf(vl_filename,"file://localhost/%s", tempfile); +#else + sprintf(vl_filename,"file://localhost%s", tempfile); +#endif /* VMS */ + first = FALSE; +#ifdef VMS + } else { + remove(tempfile); /* Remove duplicates on VMS. */ +#endif /* VMS */ + } - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } - LYLocalFileToURL(newfile, tempfile); - + StrAllocCopy(*newfile, vl_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ - BeginInternalPage(fp0, VISITED_LINKS_TITLE, VISITED_LINKS_HELP); - - fprintf(fp0, "<pre>\n"); - fprintf(fp0, + fprintf(fp0, "<head>\n"); + LYAddMETAcharsetToFD(fp0, -1); + fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", + VISITED_LINKS_TITLE); + fprintf(fp0, "<h1>You have reached the Visited Links Page</h1>\n"); + fprintf(fp0, "<h2>%s Version %s</h2>\n<pre>", LYNX_NAME, LYNX_VERSION); + fprintf(fp0, "<em>You visited (POSTs, bookmark, menu and list files excluded):</em>\n"); x = HTList_count(Visited_Links); while (NULL != (vl = (VisitedLink *)HTList_nextObject(cur))) { @@ -565,10 +637,10 @@ PUBLIC int LYShowVisitedLinks ARGS1( fprintf(fp0, "<tab to=t%d>%s\n", x, ((Address != NULL) ? Address : "(no address)")); } - fprintf(fp0,"</pre>\n"); - EndInternalPage(fp0); - LYCloseTempFP(fp0); + fprintf(fp0,"</pre>\n</body>\n"); + + fclose(fp0); FREE(Title); FREE(Address); return(0); diff --git a/src/LYHistory.h b/src/LYHistory.h index 7593a2ca..3e5bf72b 100644 --- a/src/LYHistory.h +++ b/src/LYHistory.h @@ -1,3 +1,4 @@ + #ifndef LYHISTORY_H #define LYHISTORY_H @@ -5,13 +6,15 @@ #include <LYStructs.h> #endif /* LYSTRUCTS_H */ -extern BOOLEAN LYwouldPush PARAMS((char *title)); -extern BOOLEAN historytarget PARAMS((document *newdoc)); -extern int LYShowVisitedLinks PARAMS((char **newfile)); -extern int showhistory PARAMS((char **newfile)); extern void LYAddVisitedLink PARAMS((document *doc)); +extern void LYpush PARAMS((document *doc, BOOLEAN force_push)); extern void LYpop PARAMS((document *doc)); extern void LYpop_num PARAMS((int number, document *doc)); -extern void LYpush PARAMS((document *doc, BOOLEAN force_push)); +extern int showhistory PARAMS((char **newfile)); +extern BOOLEAN historytarget PARAMS((document *newdoc)); +extern int LYShowVisitedLinks PARAMS((char **newfile)); + +#define HISTORY_PAGE_TITLE "Lynx History Page" +#define VISITED_LINKS_TITLE "Lynx Visited Links Page" #endif /* LYHISTORY_H */ diff --git a/src/LYJump.c b/src/LYJump.c index 9e4f1884..3f7910eb 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTAlert.h> #include <LYUtils.h> #include <LYStrings.h> @@ -14,6 +15,8 @@ #include <fab.h> #endif /* VMS */ +#define FREE(x) if (x) {free(x); x = NULL;} + struct JumpTable *JThead = NULL; PRIVATE int LYCompare PARAMS ((CONST void *e1, CONST void *e2)); @@ -225,7 +228,8 @@ PUBLIC char *LYJump ARGS1(int, key) /* * User cancelled the Jump via ^G. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return NULL; } @@ -233,7 +237,8 @@ check_recall: bp = buf; if (toupper(key) == 'G' && strncmp(buf, "o ", 2) == 0) bp++; - bp = LYSkipBlanks(bp); + while (isspace(*bp)) + bp++; if (*bp == '\0' && !(recall && (ch == UPARROW || ch == DNARROW))) { /* @@ -241,7 +246,8 @@ check_recall: */ *buf = '\0'; StrAllocCopy(jtp->shortcut, buf); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return NULL; } #ifdef PERMIT_GOTO_FROM_JUMP @@ -252,7 +258,8 @@ check_recall: if (no_goto) { *buf = '\0'; StrAllocCopy(jtp->shortcut, buf); - HTUserMsg(RANDOM_URL_DISALLOWED); + _statusline(RANDOM_URL_DISALLOWED); + sleep(MessageSecs); return NULL; } StrAllocCopy(temp, "Go "); @@ -298,7 +305,8 @@ check_recall: /* * User cancelled the jump via ^G. */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return NULL; } goto check_recall; @@ -338,7 +346,8 @@ check_recall: /* * User cancelled the jump via ^G. */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return NULL; } goto check_recall; @@ -394,11 +403,10 @@ 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/LYJump.h b/src/LYJump.h index 3a82b075..5da8f885 100644 --- a/src/LYJump.h +++ b/src/LYJump.h @@ -1,8 +1,7 @@ + #ifndef LYJUMP_H #define LYJUMP_H -#include <HTList.h> - typedef struct _JumpDatum { char *key; char *url; diff --git a/src/LYKeymap.c b/src/LYKeymap.c index 17674b03..1ae0e763 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <LYUtils.h> #include <LYKeymap.h> #include <LYGlobalDefs.h> @@ -10,7 +11,7 @@ PRIVATE CONST DocAddress keymap_anchor = {"LYNXKEYMAP", NULL, NULL}; -struct _HTStream +struct _HTStream { HTStreamClass * isa; }; @@ -18,7 +19,7 @@ struct _HTStream /* the character gets 1 added to it before lookup, * so that EOF maps to 0 */ -unsigned short keymap[] = { +char keymap[] = { 0, /* EOF */ @@ -38,6 +39,10 @@ LYK_REFRESH, LYK_ACTIVATE, LYK_DOWN_TWO, 0, LYK_UP_TWO, 0, LYK_RELOAD, 0, /* ^P */ /* XON */ /* ^R */ /* XOFF */ +#ifdef NOT_USED +LYK_TRACE_TOGGLE, 0, LYK_VERSION, LYK_REFRESH, +/* ^T */ /* ^U */ /* ^V */ /* ^W */ +#endif /* NOT_USED */ LYK_TRACE_TOGGLE, 0, LYK_SWITCH_DTD, LYK_REFRESH, /* ^T */ /* ^U */ /* ^V */ /* ^W */ @@ -79,15 +84,15 @@ LYK_UP_LINK, LYK_INFO, LYK_DOWN_LINK, LYK_HELP, LYK_RAW_TOGGLE, LYK_ADD_BOOKMARK, LYK_PREV_PAGE, LYK_COMMENT, /* @ */ /* A */ /* B */ /* C */ -LYK_DOWNLOAD, LYK_ELGOTO, -/* D */ /* E */ +LYK_DOWNLOAD, LYK_ELGOTO, +/* D */ /* E */ #if defined(DIRED_SUPPORT) || defined(VMS) LYK_DIRED_MENU, #else -0, +0, #endif /* DIRED_SUPPORT || VMS */ -/* F */ +/* F */ LYK_ECGOTO, /* G */ @@ -101,9 +106,20 @@ LYK_LIST, LYK_MAIN_MENU, LYK_NEXT, LYK_OPTIONS, LYK_PRINT, LYK_ABORT, LYK_DEL_BOOKMARK, LYK_INDEX_SEARCH, /* P */ /* Q */ /* R */ /* S */ -LYK_TAG_LINK, LYK_PREV_DOC, LYK_VLINKS, 0, -/* T */ /* U */ /* V */ /* W */ +#ifdef DIRED_SUPPORT +LYK_TAG_LINK, +#else +0, +#endif /* DIRED_SUPPORT */ +/* T */ + + LYK_PREV_DOC, LYK_VLINKS, 0, + /* U */ /* V */ /* W */ +#ifdef NOT_USED +LYK_FORM_UP, 0, LYK_FORM_DOWN, LYK_INLINE_TOGGLE, +/* X */ /* Y */ /* Z */ /* [ */ +#endif /* NOT_USED */ LYK_NOCACHE, 0, LYK_INTERRUPT, LYK_INLINE_TOGGLE, /* X */ /* Y */ /* Z */ /* [ */ @@ -113,15 +129,15 @@ LYK_SOURCE, LYK_HEAD, 0, LYK_CLEAR_AUTH, LYK_MINIMAL, LYK_ADD_BOOKMARK, LYK_PREV_PAGE, LYK_COMMENT, /* ` */ /* a */ /* b */ /* c */ -LYK_DOWNLOAD, LYK_EDIT, -/* d */ /* e */ +LYK_DOWNLOAD, LYK_EDIT, +/* d */ /* e */ #if defined(DIRED_SUPPORT) || defined(VMS) LYK_DIRED_MENU, #else -0, +0, #endif /* DIRED_SUPPORT || VMS */ -/* f */ +/* f */ LYK_GOTO, /* g */ @@ -135,9 +151,20 @@ LYK_LIST, LYK_MAIN_MENU, LYK_NEXT, LYK_OPTIONS, LYK_PRINT, LYK_QUIT, LYK_DEL_BOOKMARK, LYK_INDEX_SEARCH, /* p */ /* q */ /* r */ /* s */ -LYK_TAG_LINK, LYK_PREV_DOC, LYK_VIEW_BOOKMARK, 0, -/* t */ /* u */ /* v */ /* w */ +#ifdef DIRED_SUPPORT +LYK_TAG_LINK, +#else +0, +#endif /* DIRED_SUPPORT */ +/* t */ + + LYK_PREV_DOC, LYK_VIEW_BOOKMARK, 0, + /* u */ /* v */ /* w */ +#ifdef NOT_USED +LYK_FORM_UP, 0, LYK_FORM_DOWN, 0, +/* x */ /* y */ /* z */ /* { */ +#endif /* NOT_USED */ LYK_NOCACHE, 0, LYK_INTERRUPT, 0, /* x */ /* y */ /* z */ /* { */ @@ -187,22 +214,6 @@ LYK_PREV_LINK, LYK_NEXT_LINK, LYK_ACTIVATE, LYK_PREV_DOC, LYK_NEXT_PAGE, LYK_PREV_PAGE, LYK_HOME, LYK_END, /* PGDOWN */ /* PGUP */ /* HOME */ /* END */ -#if defined(__DJGPP__) || defined(_WINDOWS) -#ifdef USE_SLANG -LYK_END, LYK_HOME, LYK_PREV_PAGE, 0, -/* END */ /* HOME */ /* PGUP */ /* B2 Key */ - -LYK_END, LYK_NEXT_PAGE, 0, -/* END */ /* PGDOWN */ - -#else - 0, LYK_HELP, 0, 0, -/* F0 */ /* F1 */ /* F2 */ /* F3 */ - - 0, 0, 0, - -#endif /* USE_SLANG */ -#else LYK_HELP, LYK_ACTIVATE, LYK_HOME, LYK_END, /* F1*/ /* Do key */ /* Find key */ /* Select key */ @@ -211,135 +222,6 @@ LYK_UP_TWO, LYK_DOWN_TWO, LYK_DO_NOTHING, /* DO_NOTHING*/ -#endif /* __DJGPP__ || _WINDOWS */ -/* 10F..18F */ - - 0, -#if defined(USE_SLANG) && !defined(DJGPP_KEYHANDLER) - LYK_HISTORY, LYK_ACTIVATE, 0, 0, - /* Backspace */ /* Enter */ -#else - 0, 0, 0, 0, -#endif /* USE_SLANG */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, -#ifdef DJGPP_KEYHANDLER - 0, LYK_ABORT, 0, 0, - /* ALT_X */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, LYK_HELP, - /* F1 */ -#else - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, -#endif /* DJGPP_KEYHANDLER */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, -/* 190..20F */ - - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - LYK_ABORT, 0, 0, 0, - /* ALT_X */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, LYK_ACTIVATE, - /* KP_ENTER */ - 0, 0, 0, LYK_IMAGE_TOGGLE, - /* KP_* */ - LYK_PREV_PAGE, LYK_NEXT_PAGE, 0, 0, - /* KP_- */ /* KP_+ */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, -#if defined(USE_SLANG) && !defined(DJGPP_KEYHANDLER) - 0, LYK_HELP, 0, 0, - /* F1 */ -#else - 0, 0, 0, 0, -#endif /* USE_SLANG */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, -/* 210..28F */ - - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - /* 290...293 */ - 0, 0, 0, 0, }; #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) @@ -349,7 +231,7 @@ LYK_DO_NOTHING, * allowed at compile time. */ -unsigned short key_override[TABLESIZE(keymap)] = { +char override[] = { 0, /* EOF */ @@ -505,8 +387,8 @@ LYK_DO_NOTHING, #endif /* DIRED_SUPPORT && OK_OVERRIDE */ struct rmap { - CONST char *name; - CONST char *doc; + char *name; + char *doc; }; PRIVATE struct rmap revmap[] = { { "UNMAPPED", NULL }, @@ -599,10 +481,15 @@ PRIVATE struct rmap revmap[] = { { "INSTALL", "install file or tagged files into a system area" }, #endif /* DIRED_SUPPORT */ #endif /* VMS */ +#ifdef NOT_USED +{ "VERSION", "report version of lynx"}, +{ "FORM_UP", "toggle a checkbox" }, +{ "FORM_DOWN", "toggle a checkbox" }, +#endif /* NOT_USED */ { NULL, "" } }; -PRIVATE CONST char *funckey[] = { +PRIVATE char *funckey[] = { "Up Arrow", "Down Arrow", "Right Arrow", @@ -639,44 +526,27 @@ PRIVATE char *pretty ARGS1 (int, c) sprintf(buf, "%c", c); else if (c < ' ') sprintf(buf, "^%c", c|0100); - else if (c >= 0400 && (c - 0400) < (int) TABLESIZE(funckey)) - sprintf(buf, "%s", funckey[c-0400]); else - return 0; - + sprintf(buf, "%s", funckey[c-0400]); + return buf; } -PRIVATE BOOL format_binding ARGS3( - char *, buf, - unsigned short *, table, - int, i) -{ - unsigned the_key = table[i]; - char *formatted; - - if (the_key != 0 - && the_key < TABLESIZE(revmap) - && revmap[the_key].name != 0 - && revmap[the_key].doc != 0 - && (formatted = pretty(i-1)) != 0) { - sprintf(buf, "%-12s%-14s%s\n", formatted, - revmap[the_key].name, - revmap[the_key].doc); - return TRUE; - } - return FALSE; -} - PRIVATE void print_binding ARGS3(HTStream *, target, char *, buf, int, i) { #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) if (prev_lynx_edit_mode && !no_dired_support && - format_binding(buf, key_override, i)) { + override[i] && revmap[(unsigned char)override[i]].doc) { + sprintf(buf, "%-12s%-14s%s\n", pretty(i-1), + revmap[(unsigned char)override[i]].name, + revmap[(unsigned char)override[i]].doc); (*target->isa->put_block)(target, buf, strlen(buf)); } else #endif /* DIRED_SUPPORT && OK_OVERRIDE */ - if (format_binding(buf, keymap, i)) { + if (keymap[i] && revmap[(unsigned char)keymap[i]].doc) { + sprintf(buf, "%-12s%-14s%s\n", pretty(i-1), + revmap[(unsigned char)keymap[i]].name, + revmap[(unsigned char)keymap[i]].doc); (*target->isa->put_block)(target, buf, strlen(buf)); } } @@ -707,11 +577,9 @@ PRIVATE int LYLoadKeymap ARGS4 ( sprintf(buf, "<head>\n<title>%s</title>\n</head>\n<body>\n", CURRENT_KEYMAP_TITLE); (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, "<h1>%s (%s), help on <a href=\"%s%s\">%s</a></h1>\n", - LYNX_NAME, LYNX_VERSION, - helpfilepath, CURRENT_KEYMAP_HELP, CURRENT_KEYMAP_TITLE); - (*target->isa->put_block)(target, buf, strlen(buf)); - sprintf(buf, "<pre>\n"); + + sprintf(buf, "<h1>%s (%s Version %s)</h1>\n<pre>", + CURRENT_KEYMAP_TITLE, LYNX_NAME, LYNX_VERSION); (*target->isa->put_block)(target, buf, strlen(buf)); for (i = 'a'+1; i <= 'z'+1; i++) { @@ -721,12 +589,12 @@ PRIVATE int LYLoadKeymap ARGS4 ( i-' '); /* uppercase mapping is different */ } } - for (i = 1; i < (int) TABLESIZE(keymap); i++) { + for (i = 1; i < (int) sizeof(keymap); i++) { /* * LYK_PIPE not implemented yet. */ - if ((i > (int) TABLESIZE(keymap) || i <= ' ' || !isalpha(i-1)) && - strcmp(revmap[keymap[i]].name, "PIPE")) { + if ((i > 127 || i <= ' ' || !isalpha(i-1)) && + strcmp(revmap[(unsigned char)keymap[i]].name, "PIPE")) { print_binding(target, buf, i); } } @@ -778,8 +646,8 @@ PUBLIC int remap ARGS2(char *,key, char *,func) PUBLIC void set_vms_keys NOARGS { keymap[26+1] = LYK_ABORT; /* control-Z */ - keymap['$'+1] = LYK_SHELL; -} + keymap['$'+1] = LYK_SHELL; +} static char saved_vi_keys[4]; static BOOLEAN did_vi_keys; @@ -895,40 +763,27 @@ PUBLIC void reset_numbers_as_arrows NOARGS did_number_keys = FALSE; } -PUBLIC int lookup_keymap ARGS1( - int, func) -{ - size_t i; - - for (i = 1; i < TABLESIZE(keymap); i++) { - if (LYisNonAlnumKeyname(i, func)) { - return i; - } - } - return -1; -} - PUBLIC char *key_for_func ARGS1 ( int, func) { - static char buf[512]; - int i; - char *formatted; - - buf[0] = '\0'; - if ((i = LYReverseKeymap(func)) >= 0) { - if (*buf) - strcat(buf, " or "); - formatted = pretty(i); - strcat(buf, formatted != 0 ? formatted : "?"); - } - return buf; + static char buf[512]; + size_t i; + + buf[0] = '\0'; + for (i = 1; i < sizeof(keymap); i++) { + if (keymap[i] == func) { + if (*buf) + strcat(buf, " or "); + strcat(buf, pretty(i-1)); + } + } + return buf; } /* * This function returns TRUE if the ch is non-alphanumeric * and maps to key_name (LYK_foo in the keymap[] array). - FM - */ + */ PUBLIC BOOL LYisNonAlnumKeyname ARGS2( int, ch, int, key_name) @@ -941,6 +796,7 @@ PUBLIC BOOL LYisNonAlnumKeyname ARGS2( return(keymap[ch+1] == key_name); } +#ifdef NOTUSED_FOTEMODS /* * This function returns the (int)ch mapped to the * LYK_foo value passed to it as an argument. - FM @@ -950,11 +806,12 @@ PUBLIC int LYReverseKeymap ARGS1( { int i; - for (i = 1; i < (int) TABLESIZE(keymap); i++) { + for (i = 1; i < sizeof(keymap); i++) { if (keymap[i] == key_name) { return(i - 1); } } - return(-1); + return(0); } +#endif diff --git a/src/LYKeymap.h b/src/LYKeymap.h index e8ccad06..77feb48f 100644 --- a/src/LYKeymap.h +++ b/src/LYKeymap.h @@ -1,28 +1,27 @@ #ifndef LYKEYMAP_H #define LYKEYMAP_H -#include <HTUtils.h> - -extern BOOLEAN LYisNonAlnumKeyname PARAMS((int ch, int key_name)); -extern char *key_for_func PARAMS((int func)); -extern int LYReverseKeymap PARAMS((int key_name)); -extern int lookup_keymap PARAMS((int code)); extern int remap PARAMS((char *key, char *func)); -extern void print_keymap PARAMS((char **newfile)); -extern void reset_emacs_keys NOPARAMS; -extern void reset_numbers_as_arrows NOPARAMS; +extern void set_vms_keys NOPARAMS; +extern void set_vi_keys NOPARAMS; extern void reset_vi_keys NOPARAMS; extern void set_emacs_keys NOPARAMS; +extern void reset_emacs_keys NOPARAMS; extern void set_numbers_as_arrows NOPARAMS; -extern void set_vi_keys NOPARAMS; -extern void set_vms_keys NOPARAMS; +extern void reset_numbers_as_arrows NOPARAMS; +extern void print_keymap PARAMS((char **newfile)); +extern char *key_for_func PARAMS((int func)); +extern BOOLEAN LYisNonAlnumKeyname PARAMS((int ch, int key_name)); +extern int LYReverseKeymap PARAMS((int key_name)); -extern unsigned short keymap[]; /* main keymap matrix */ +extern char keymap[]; /* main keymap matrix */ #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) -extern unsigned short key_override[]; +extern char override[]; #endif +#define CURRENT_KEYMAP_TITLE "Current Key Map" + #define LYK_1 1 #define LYK_2 2 #define LYK_3 3 @@ -117,14 +116,6 @@ extern unsigned short key_override[]; #define LYK_INSTALL (LYK_DIRED_MENU+6) #endif /* DIRED_SUPPORT */ -#ifndef LYK_DIRED_MENU -#define LYK_DIRED_MENU 0 -#endif - -#ifndef LYK_TAG_LINK -#define LYK_TAG_LINK 0 -#endif - #ifdef NOT_USED #define LYK_VERSION 81 #define LYK_FORM_UP 82 diff --git a/src/LYLeaks.c b/src/LYLeaks.c index 87afc0bb..29845d30 100644 --- a/src/LYLeaks.c +++ b/src/LYLeaks.c @@ -10,9 +10,14 @@ #define NO_MEMORY_TRACKING #include <HTUtils.h> +#include <tcp.h> #include <LYexit.h> #include <LYLeaks.h> #include <LYUtils.h> +#include <ctype.h> +/*#include <stdio.h> included by HTUtils.h -- FM */ + +#define FREE(x) if (x) {free(x); x = NULL;} PRIVATE AllocationList *ALp_RunTimeAllocations = NULL; @@ -155,8 +160,22 @@ PUBLIC void LYLeaks NOARGS fprintf(Fp_leakagesink, "\nTotal memory leakage this run:\t%u\n", (unsigned)st_total); fclose(Fp_leakagesink); - - HTSYS_purge(LEAKAGE_SINK); +#ifdef VMS + { + char VMSfilename[256]; + /* + * Purge lower versions of the file. + */ + sprintf(VMSfilename, "%s;-1", LEAKAGE_SINK); + while (remove(VMSfilename) == 0) + ; + /* + * Reset version number. + */ + sprintf(VMSfilename, "%s;1", LEAKAGE_SINK); + rename(LEAKAGE_SINK, VMSfilename); + } +#endif /* VMS */ } /* diff --git a/src/LYList.c b/src/LYList.c index 7f669db9..5622f4ba 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -6,7 +6,7 @@ */ #include <HTUtils.h> -#include <HTAlert.h> +#include <tcp.h> #include <LYUtils.h> #include <GridText.h> #include <LYList.h> @@ -22,6 +22,8 @@ #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* showlist - F.Macrides (macrides@sci.wfeb.edu) ** -------- ** Create a temporary text/html file with a list of links to @@ -32,7 +34,7 @@ ** Clear: we only get addresses. */ -static char *list_filename = 0; +static char list_filename[256] = "\0"; /* * Returns the name of the file used for the List Page, if one has @@ -41,7 +43,7 @@ static char *list_filename = 0; */ PUBLIC char * LYlist_temp_url NOARGS { - return list_filename ? list_filename : ""; + return list_filename; } PUBLIC int showlist ARGS2( @@ -51,6 +53,7 @@ PUBLIC int showlist ARGS2( int cnt; int refs, hidden_links; static char tempfile[256]; + static BOOLEAN first = TRUE; FILE *fp0; char *Address = NULL, *Title = NULL, *cp = NULL; BOOLEAN intern_w_post = FALSE; @@ -60,32 +63,67 @@ PUBLIC int showlist ARGS2( hidden_links = HText_HiddenLinkCount(HTMainText); if (refs <= 0 && hidden_links > 0 && LYHiddenLinks != HIDDENLINKS_SEPARATE) { - HTUserMsg(NO_VISIBLE_REFS_FROM_DOC); + _statusline(NO_VISIBLE_REFS_FROM_DOC); + sleep(MessageSecs); return(-1); } if (refs <= 0 && hidden_links <= 0) { - HTUserMsg(NO_REFS_FROM_DOC); + _statusline(NO_REFS_FROM_DOC); + sleep(MessageSecs); return(-1); } - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { - HTUserMsg(CANNOT_OPEN_TEMP); - return(-1); + if (first) { + tempname(tempfile, NEW_FILE); + /* + * Make the file a URL now. + */ +#if defined (VMS) || defined (DOSPATH) + sprintf(list_filename, "file://localhost/%s", tempfile); +#else + sprintf(list_filename, "file://localhost%s", tempfile); +#endif /* VMS */ + first = FALSE; +#ifdef VMS + } else { + remove(tempfile); /* Remove duplicates on VMS. */ +#endif /* VMS */ } - LYLocalFileToURL(&list_filename, tempfile); + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + _statusline(CANNOT_OPEN_TEMP); + sleep(MessageSecs); + return(-1); + } StrAllocCopy(newdoc->address, list_filename); LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ - BeginInternalPage(fp0, LIST_PAGE_TITLE, LIST_PAGE_HELP); + fprintf(fp0, "<head>\n"); + LYAddMETAcharsetToFD(fp0, -1); + if (strchr(HTLoadedDocumentURL(), '"') == NULL) { + /* + * Insert a BASE tag so there is some way to relate the List Page + * file to its underlying document after we are done. It won't + * be actually used for resolving relative URLs. - kw + */ + StrAllocCopy(Address, HTLoadedDocumentURL()); + LYEntify(&Address, FALSE); + fprintf(fp0, "<base href=\"%s\">\n", Address); + FREE(Address); + } + fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", + LIST_PAGE_TITLE); + fprintf(fp0, "<h1>You have reached the List Page</h1>\n"); + fprintf(fp0, "<h2>%s Version %s</h2>\n", LYNX_NAME, LYNX_VERSION); StrAllocCopy(Address, HTLoadedDocumentURL()); LYEntify(&Address, FALSE); - fprintf(fp0, "References in %s<p>\n", - ((Address != NULL && *Address != '\0') ? Address : "this document:")); + fprintf(fp0, + " References in %s<p>\n", + ((Address != NULL && *Address != '\0') ? + Address : "this document:")); FREE(Address); if (refs > 0) { fprintf(fp0, "<%s compact>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? @@ -141,8 +179,8 @@ PUBLIC int showlist ARGS2( /* * Set flag to note that we had at least one internal link, * if the document from which we are generating the list - * has associated POST data; after an extra check that the - * link destination really has the same POST data so that + * has assosiated POST data; after an extra check that the + * link destination really has hthe same POST data so that * we can believe it is an internal link. */ intern_w_post = TRUE; @@ -196,16 +234,14 @@ PUBLIC int showlist ARGS2( FREE(Address); } - fprintf(fp0,"\n</%s>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? - "ol" : "ul")); - EndInternalPage(fp0); - LYCloseTempFP(fp0); + fprintf(fp0,"\n</%s>\n</body>\n", ((keypad_mode == NUMBERS_AS_ARROWS) ? + "ol" : "ul")); /* * Make necessary changes to newdoc before returning to caller. * If the intern_w_post flag is set, we keep the POST data in * newdoc that have been passed in. They should be the same as - * in the loaded document for which we generated the list. + * in the loaded locument for which we generated the list. * In that case the file we have written will be associated with * the same POST data when it is loaded after we are done here, * so that following one of the links we have marked as "internal @@ -221,6 +257,7 @@ PUBLIC int showlist ARGS2( } newdoc->isHEAD = FALSE; newdoc->safe = FALSE; + fclose(fp0); return(0); } @@ -267,7 +304,7 @@ PUBLIC void printlist ARGS2( if (child == 0) { /* * child should not be 0 unless form field numbering is on - * and cnt is the number of a form input field. + * and cnt is the number of a form intput field. * HText_FormDescNumber() will set desc to a description * of what type of input field this is. We'll create a * within-document link to ensure that the link numbers on diff --git a/src/LYList.h b/src/LYList.h index 4288107b..4a717284 100644 --- a/src/LYList.h +++ b/src/LYList.h @@ -1,10 +1,11 @@ + #ifndef LYLIST_H #define LYLIST_H -#include <LYStructs.h> - extern char * LYlist_temp_url NOPARAMS; extern int showlist PARAMS((document *newdoc, BOOLEAN titles)); extern void printlist PARAMS((FILE *fp, BOOLEAN titles)); +#define LIST_PAGE_TITLE "Lynx List Page" + #endif /* LYLIST_H */ diff --git a/src/LYLocal.c b/src/LYLocal.c index 5750d7ae..320ca0cd 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -29,7 +29,7 @@ */ #include <HTUtils.h> -#include <HTFile.h> +#include <tcp.h> #include <HTAlert.h> #include <HTParse.h> #include <LYCurses.h> @@ -42,12 +42,14 @@ #include <LYHistory.h> #include <LYUpload.h> #include <LYLocal.h> +#include <LYSystem.h> #ifndef VMS #ifndef _WINDOWS #ifdef HAVE_SYS_WAIT_H #include <sys/wait.h> #endif +#include <errno.h> #include <grp.h> #endif /*_WINDOWS */ #endif /* VMS */ @@ -70,14 +72,17 @@ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + + PRIVATE int LYExecv PARAMS(( char * path, char ** argv, char * msg)); #ifdef DIRED_SUPPORT -PUBLIC char LYPermitFileURL[LY_MAXPATH] = "\0"; -PUBLIC char LYDiredFileURL[LY_MAXPATH] = "\0"; +PUBLIC char LYPermitFileURL[256] = "\0"; +PUBLIC char LYDiredFileURL[256] = "\0"; PRIVATE char *filename PARAMS(( char * prompt, @@ -92,7 +97,7 @@ PRIVATE BOOLEAN permit_location PARAMS(( #endif /* OK_PERMIT */ PRIVATE char *render_item PARAMS(( - CONST char * s, + char * s, char * path, char * dir, char * buf, @@ -236,61 +241,6 @@ struct dired_menu { NULL, NULL, NULL } }; -PRIVATE BOOLEAN ok_stat ARGS2(char *, name, struct stat*, sb) -{ - char tmpbuf[LY_MAXPATH+80]; - - CTRACE(tfp, "testing ok_stat(%s)\n", name); - if (stat(name, sb) < 0) { - sprintf(tmpbuf, "Unable to get status of '%s'.", name); - HTAlert(tmpbuf); - return FALSE; - } - return TRUE; -} - -#ifdef HAVE_LSTAT -PRIVATE BOOLEAN ok_lstat ARGS2(char *, name, struct stat*, sb) -{ - char tmpbuf[LY_MAXPATH+80]; - - CTRACE(tfp, "testing ok_lstat(%s)\n", name); - if (lstat(name, sb) < 0) { - sprintf(tmpbuf, "Unable to get status of '%s'.", name); - HTAlert(tmpbuf); - return FALSE; - } - return TRUE; -} -#else -#define ok_lstat(name,sb) ok_stat(name,sb) -#endif - -PRIVATE BOOLEAN ok_file_or_dir ARGS1(struct stat*, sb) -{ - if (!S_ISDIR(sb->st_mode) - && !S_ISREG(sb->st_mode)) { - HTAlert("The selected item is not a file or a directory! Request ignored."); - return FALSE; - } - return TRUE; -} - -PRIVATE BOOLEAN ok_localname ARGS2(char*, dst, char*, src) -{ - char *s = HTfullURL_toFile(strip_trailing_slash(src)); - struct stat dir_info; - - if (!ok_stat(s, &dir_info) - || !ok_file_or_dir(&dir_info)) { - free(s); - return FALSE; - } - strcpy(dst, s); - free(s); - return TRUE; -} - /* * Remove all tagged files and directories. */ @@ -301,7 +251,7 @@ PRIVATE BOOLEAN remove_tagged NOARGS char tmpbuf[1024]; char *testpath = NULL; struct stat dir_info; - int count; + int count, i; HTList *tag; char *args[5]; @@ -315,17 +265,27 @@ PRIVATE BOOLEAN remove_tagged NOARGS count = 0; tag = tagged; while (ans == 'Y' && (cp = (char *)HTList_nextObject(tag)) != NULL) { - if (is_url(cp) == FILE_URL_TYPE) { /* unnecessary check */ - tp = HTfullURL_toFile(cp); + if (is_url(cp) == FILE_URL_TYPE) { /* unecessary check */ + tp = cp; + if (!strncmp(tp, "file://localhost", 16)) { + tp += 16; + } else if (!strncmp(tp, "file:", 5)) { + tp += 5; + } StrAllocCopy(testpath, tp); - free(tp); - - LYTrimPathSep(testpath); + HTUnEscape(testpath); + if ((i = strlen(testpath)) && testpath[i-1] == '/') + testpath[(i - 1)] = '\0'; /* * Check the current status of the path to be deleted. */ - if (!ok_stat(testpath, &dir_info)) { + if (stat(testpath,&dir_info) == -1) { + sprintf(tmpbuf, + "System error - failed to get status of '%s'.", + testpath); + _statusline(tmpbuf); + sleep(AlertSecs); return count; } else { args[0] = "rm"; @@ -400,20 +360,25 @@ PRIVATE BOOLEAN modify_tagged ARGS1( if (!cp) /* Last resort, should never happen. */ cp = "/"; } - + if (!strncmp(cp, "file://localhost", 16)) { + cp += 16; + } else if (!strncmp(cp, "file:", 5)) { + cp += 5; + } if (testpath == NULL) { /* * Get the directory containing the file or subdir. */ - cp = HTfullURL_toFile(strip_trailing_slash(cp)); + cp = strip_trailing_slash(cp); savepath = HTParse(".", cp, PARSE_PATH+PARSE_PUNCTUATION); } else { - cp = HTfullURL_toFile(cp); StrAllocCopy(savepath, cp); } - free(cp); - - if (!ok_stat(savepath, &dir_info)) { + HTUnEscape(savepath); + if (stat(savepath, &dir_info) == -1) { + sprintf(tmpbuf, "Unable to get status of '%s'.", savepath); + _statusline(tmpbuf); + sleep(AlertSecs); FREE(savepath); return 0; } @@ -435,7 +400,8 @@ PRIVATE BOOLEAN modify_tagged ARGS1( StrAllocCat(cp1, (tmpbuf + 1)); if (strlen(cp1) > (sizeof(tmpbuf) - 1)) { sprintf(tmpbuf, "%s", "Path too long"); - HTAlert(tmpbuf); + _statusline(tmpbuf); + sleep(AlertSecs); FREE(savepath); FREE(cp1); return 0; @@ -447,8 +413,9 @@ PRIVATE BOOLEAN modify_tagged ARGS1( /* * If path is relative, prefix it with current location. */ - if (!LYIsPathSep(tmpbuf[0])) { - LYAddPathSep(&savepath); + if (tmpbuf[0] != '/') { + if (savepath[(strlen(savepath) - 1)] != '/') + StrAllocCat(savepath,"/"); StrAllocCat(savepath,tmpbuf); } else { StrAllocCopy(savepath,tmpbuf); @@ -457,7 +424,10 @@ PRIVATE BOOLEAN modify_tagged ARGS1( /* * stat() the target location to determine type and ownership. */ - if (!ok_stat(savepath, &dir_info)) { + if (stat(savepath, &dir_info) == -1) { + sprintf(tmpbuf,"Unable to get status of '%s'.",savepath); + _statusline(tmpbuf); + sleep(AlertSecs); FREE(savepath); return 0; } @@ -466,7 +436,9 @@ PRIVATE BOOLEAN modify_tagged ARGS1( * Make sure the source and target locations are not the same place. */ if (dev == dir_info.st_dev && inode == dir_info.st_ino) { - HTAlert("Source and destination are the same location - request ignored!"); + _statusline( + "Source and destination are the same location - request ignored!"); + sleep(AlertSecs); FREE(savepath); return 0; } @@ -475,7 +447,7 @@ PRIVATE BOOLEAN modify_tagged ARGS1( * Make sure the target location is a directory which is owned * by the same uid as the owner of the current location. */ - if (S_ISDIR(dir_info.st_mode)) { + if ((dir_info.st_mode & S_IFMT) == S_IFDIR) { if (dir_info.st_uid == owner) { count = 0; tag = tagged; @@ -484,9 +456,13 @@ PRIVATE BOOLEAN modify_tagged ARGS1( * Move all tagged items to the target location. */ while ((cp = (char *)HTList_nextObject(tag)) != NULL) { - cp = HTfullURL_toFile(cp); + if (!strncmp(cp, "file://localhost", 16)) { + cp += 16; + } else if (!strncmp(cp, "file:", 5)) { + cp += 5; + } StrAllocCopy(srcpath, cp); - free(cp); + HTUnEscape(srcpath); sprintf(tmpbuf, "move %s to %s", srcpath, savepath); args[0] = "mv"; @@ -505,13 +481,17 @@ PRIVATE BOOLEAN modify_tagged ARGS1( clear_tags(); return count; } else { - HTAlert("Destination has different owner! Request denied."); + _statusline( + "Destination has different owner! Request denied."); + sleep(AlertSecs); FREE(srcpath); FREE(savepath); return 0; } } else { - HTAlert("Destination is not a valid directory! Request denied."); + _statusline( + "Destination is not a valid directory! Request denied."); + sleep(AlertSecs); FREE(savepath); return 0; } @@ -537,16 +517,22 @@ PRIVATE BOOLEAN modify_name ARGS1( */ testpath = strip_trailing_slash(testpath); - if (ok_stat(testpath, &dir_info)) { + if (stat(testpath, &dir_info) == -1) { + sprintf(tmpbuf, "Unable to get status of '%s'.", testpath); + _statusline(tmpbuf); + sleep(AlertSecs); + } else { /* * Change the name of the file or directory. */ - if (S_ISDIR(dir_info.st_mode)) { + if ((dir_info.st_mode & S_IFMT) == S_IFDIR) { cp = "Enter new name for directory: "; - } else if (S_ISREG(dir_info.st_mode)) { + } else if ((dir_info.st_mode & S_IFMT) == S_IFREG) { cp = "Enter new name for file: "; } else { - HTAlert("The selected item is not a file or a directory! Request ignored."); + _statusline( + "The selected item is not a file or a directory! Request ignored."); + sleep(AlertSecs); return 0; } if (filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) @@ -556,7 +542,8 @@ PRIVATE BOOLEAN modify_name ARGS1( * Do not allow the user to also change the location at this time. */ if (strchr(tmpbuf, '/') != NULL) { - HTAlert("Illegal character \"/\" found! Request ignored."); + _statusline("Illegal character \"/\" found! Request ignored."); + sleep(AlertSecs); } else if (strlen(tmpbuf) && (cp = strrchr(testpath, '/')) != NULL) { strcpy(savepath,testpath); @@ -571,7 +558,8 @@ PRIVATE BOOLEAN modify_name ARGS1( if (errno != ENOENT) { sprintf(tmpbuf, "Unable to determine status of '%s'.", newpath); - HTAlert(tmpbuf); + _statusline(tmpbuf); + sleep(AlertSecs); } else { sprintf(tmpbuf, "move %s to %s", savepath, newpath); args[0] = "mv"; @@ -582,12 +570,18 @@ PRIVATE BOOLEAN modify_name ARGS1( return (-1); return 1; } - } else if (S_ISDIR(dir_info.st_mode)) { - HTAlert("There is already a directory with that name! Request ignored."); - } else if (S_ISREG(dir_info.st_mode)) { - HTAlert("There is already a file with that name! Request ignored."); + } else if ((dir_info.st_mode & S_IFMT) == S_IFDIR) { + _statusline( + "There is already a directory with that name! Request ignored."); + sleep(AlertSecs); + } else if ((dir_info.st_mode & S_IFMT) == S_IFREG) { + _statusline( + "There is already a file with that name! Request ignored."); + sleep(AlertSecs); } else { - HTAlert("The specified name is already in use! Request ignored."); + _statusline( + "The specified name is already in use! Request ignored."); + sleep(AlertSecs); } } } @@ -616,19 +610,24 @@ PRIVATE BOOLEAN modify_location ARGS1( */ testpath = strip_trailing_slash(testpath); - if (!ok_stat(testpath, &dir_info)) { + if (stat(testpath, &dir_info) == -1) { + sprintf(tmpbuf, "Unable to get status of '%s'.", testpath); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; } /* * Change the location of the file or directory. */ - if (S_ISDIR(dir_info.st_mode)) { + if ((dir_info.st_mode & S_IFMT) == S_IFDIR) { cp = "Enter new location for directory: "; - } else if (S_ISREG(dir_info.st_mode)) { + } else if ((dir_info.st_mode & S_IFMT) == S_IFREG) { cp = "Enter new location for file: "; } else { - HTAlert("The specified item is not a file or a directory - request ignored."); + _statusline( + "The specified item is not a file or a directory - request ignored."); + sleep(AlertSecs); return 0; } if (filename(cp, tmpbuf, sizeof(tmpbuf)) == NULL) @@ -640,18 +639,18 @@ PRIVATE BOOLEAN modify_location ARGS1( /* * Allow ~/ references to the home directory. */ - if (!strncmp(tmpbuf, "~/", 2) - || !strcmp(tmpbuf,"~")) { + if (!strncmp(tmpbuf,"~/",2)) { strcpy(newpath, Home_Dir()); strcat(newpath, (tmpbuf + 1)); strcpy(tmpbuf, newpath); } - if (!LYIsPathSep(tmpbuf[0])) { + if (tmpbuf[0] != '/') { if ((cp = strrchr(newpath,'/')) != NULL) { *++cp = '\0'; strcat(newpath,tmpbuf); } else { - HTAlert("Unexpected failure - unable to find trailing \"/\""); + _statusline("Unexpected failure - unable to find trailing \"/\""); + sleep(AlertSecs); return 0; } } else { @@ -665,11 +664,16 @@ PRIVATE BOOLEAN modify_location ARGS1( mode = dir_info.st_mode; inode = dir_info.st_ino; owner = dir_info.st_uid; - if (!ok_stat(newpath, &dir_info)) { + if (stat(newpath, &dir_info) == -1) { + sprintf(tmpbuf,"Unable to get status of '%s'.",newpath); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; } - if (!S_ISDIR(dir_info.st_mode)) { - HTAlert("Destination is not a valid directory! Request denied."); + if ((dir_info.st_mode & S_IFMT) != S_IFDIR) { + _statusline( + "Destination is not a valid directory! Request denied."); + sleep(AlertSecs); return 0; } @@ -677,7 +681,9 @@ PRIVATE BOOLEAN modify_location ARGS1( * Make sure the source and target are not the same location. */ if (dev == dir_info.st_dev && inode == dir_info.st_ino) { - HTAlert("Source and destination are the same location! Request ignored!"); + _statusline( + "Source and destination are the same location! Request ignored!"); + sleep(AlertSecs); return 0; } if (dir_info.st_uid == owner) { @@ -690,7 +696,8 @@ PRIVATE BOOLEAN modify_location ARGS1( return (-1); return 1; } else { - HTAlert("Destination has different owner! Request denied."); + _statusline("Destination has different owner! Request denied."); + sleep(AlertSecs); return 0; } } @@ -710,10 +717,14 @@ PUBLIC BOOLEAN local_modify ARGS2( int count; if (!HTList_isEmpty(tagged)) { - cp = HTpartURL_toFile(doc->address); + cp = doc->address; + if (!strncmp(cp, "file://localhost", 16)) { + cp += 16; + } else if (!strncmp(cp, "file:", 5)) { + cp += 5; + } strcpy(testpath, cp); - free(cp); - + HTUnEscapeSome(testpath, "/"); count = modify_tagged(testpath); if (doc->link > (nlinks-count - 1)) @@ -742,9 +753,14 @@ PUBLIC BOOLEAN local_modify ARGS2( ans = TOUPPER(c); if (strchr("NLP", ans) != NULL) { - cp = HTfullURL_toFile(links[doc->link].lname); + cp = links[doc->link].lname; + if (!strncmp(cp, "file://localhost", 16)) { + cp += 16; + } else if(!strncmp(cp, "file:", 5)) { + cp += 5; + } strcpy(testpath, cp); - free(cp); + HTUnEscape(testpath); if (ans == 'N') { return(modify_name(testpath)); @@ -762,7 +778,8 @@ PUBLIC BOOLEAN local_modify ARGS2( /* * Code for changing ownership needed here. */ - HTAlert("This feature not yet implemented!"); + _statusline("This feature not yet implemented!"); + sleep(AlertSecs); } } return 0; @@ -790,10 +807,13 @@ PRIVATE BOOLEAN create_file ARGS1( } if (strstr(tmpbuf, "//") != NULL) { - HTAlert("Illegal redirection \"//\" found! Request ignored."); + _statusline("Illegal redirection \"//\" found! Request ignored."); + sleep(AlertSecs); } else if (strlen(tmpbuf) && strchr(bad_chars, tmpbuf[0]) == NULL) { strcpy(testpath,current_location); - LYAddPathSep0(testpath); + if (testpath[(strlen(testpath) - 1)] != '/') { + strcat(testpath,"/"); + } /* * Append the target filename to the current location. @@ -807,7 +827,8 @@ PRIVATE BOOLEAN create_file ARGS1( if (errno != ENOENT) { sprintf(tmpbuf, "Unable to determine status of '%s'.", testpath); - HTAlert(tmpbuf); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; } sprintf(tmpbuf,"create %s",testpath); @@ -817,12 +838,18 @@ PRIVATE BOOLEAN create_file ARGS1( if (LYExecv(TOUCH_PATH, args, tmpbuf) <= 0) return (-1); return 1; - } else if (S_ISDIR(dir_info.st_mode)) { - HTAlert("There is already a directory with that name! Request ignored."); - } else if (S_ISREG(dir_info.st_mode)) { - HTAlert("There is already a file with that name! Request ignored."); + } else if ((dir_info.st_mode & S_IFMT) == S_IFDIR) { + _statusline( + "There is already a directory with that name! Request ignored."); + sleep(AlertSecs); + } else if ((dir_info.st_mode & S_IFMT) == S_IFREG) { + _statusline( + "There is already a file with that name! Request ignored."); + sleep(AlertSecs); } else { - HTAlert("The specified name is already in use! Request ignored."); + _statusline( + "The specified name is already in use! Request ignored."); + sleep(AlertSecs); } } return 0; @@ -850,11 +877,13 @@ PRIVATE BOOLEAN create_directory ARGS1( } if (strstr(tmpbuf, "//") != NULL) { - HTAlert("Illegal redirection \"//\" found! Request ignored."); + _statusline("Illegal redirection \"//\" found! Request ignored."); + sleep(AlertSecs); } else if (strlen(tmpbuf) && strchr(bad_chars, tmpbuf[0]) == NULL) { strcpy(testpath,current_location); - LYAddPathSep0(testpath); - + if (testpath[(strlen(testpath) - 1)] != '/') { + strcat(testpath,"/"); + } strcat(testpath, tmpbuf); /* @@ -864,7 +893,8 @@ PRIVATE BOOLEAN create_directory ARGS1( if (errno != ENOENT) { sprintf(tmpbuf, "Unable to determine status of '%s'.", testpath); - HTAlert(tmpbuf); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; } sprintf(tmpbuf,"make directory %s",testpath); @@ -874,12 +904,18 @@ PRIVATE BOOLEAN create_directory ARGS1( if (LYExecv(MKDIR_PATH, args, tmpbuf) <= 0) return (-1); return 1; - } else if (S_ISDIR(dir_info.st_mode)) { - HTAlert("There is already a directory with that name! Request ignored."); - } else if (S_ISREG(dir_info.st_mode)) { - HTAlert("There is already a file with that name! Request ignored."); + } else if ((dir_info.st_mode & S_IFMT) == S_IFDIR) { + _statusline( + "There is already a directory with that name! Request ignored."); + sleep(AlertSecs); + } else if ((dir_info.st_mode & S_IFMT) == S_IFREG) { + _statusline( + "There is already a file with that name! Request ignored."); + sleep(AlertSecs); } else { - HTAlert("The specified name is already in use! Request ignored."); + _statusline( + "The specified name is already in use! Request ignored."); + sleep(AlertSecs); } } return 0; @@ -899,9 +935,14 @@ PUBLIC BOOLEAN local_create ARGS1( c = LYgetch(); ans = TOUPPER(c); - cp = HTfullURL_toFile(doc->address); + cp = doc->address; + if (!strncmp(cp, "file://localhost", 16)) { + cp += 16; + } else if (!strncmp(cp, "file:", 5)) { + cp += 5; + } strcpy(testpath,cp); - free(cp); + HTUnEscape(testpath); if (ans == 'F') { return(create_file(testpath)); @@ -924,7 +965,15 @@ PRIVATE BOOLEAN remove_single ARGS1( struct stat dir_info; char *args[5]; - if (!ok_lstat(testpath, &dir_info)) { + /* + * lstat() first in case its a symbolic link. + */ + if (lstat(testpath, &dir_info) == -1 && + stat(testpath, &dir_info) == -1) { + sprintf(tmpbuf, + "System error - failed to get status of '%s'.", testpath); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; } @@ -936,7 +985,7 @@ PRIVATE BOOLEAN remove_single ARGS1( } else { cp = testpath; } - if (S_ISDIR(dir_info.st_mode)) { + if ((dir_info.st_mode & S_IFMT) == S_IFDIR) { if (strlen(cp) < 37) { sprintf(tmpbuf, "Remove '%s' and all of its contents (y or n): ", cp); @@ -944,14 +993,14 @@ PRIVATE BOOLEAN remove_single ARGS1( sprintf(tmpbuf, "Remove directory and all of its contents (y or n): "); } - } else if (S_ISREG(dir_info.st_mode)) { + } else if ((dir_info.st_mode & S_IFMT) == S_IFREG) { if (strlen(cp) < 60) { sprintf(tmpbuf, "Remove file '%s' (y or n): ", cp); } else { sprintf(tmpbuf, "Remove file (y or n): "); } #ifdef S_IFLNK - } else if (S_ISLNK(dir_info.st_mode)) { + } else if ((dir_info.st_mode & S_IFMT) == S_IFLNK) { if (strlen(cp) < 50) { sprintf(tmpbuf, "Remove symbolic link '%s' (y or n): ", cp); } else { @@ -960,7 +1009,8 @@ PRIVATE BOOLEAN remove_single ARGS1( #endif } else { sprintf(tmpbuf, "Unable to determine status of '%s'.", testpath); - HTAlert(tmpbuf); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; } _statusline(tmpbuf); @@ -1001,13 +1051,16 @@ PUBLIC BOOLEAN local_remove ARGS1( } cp = links[doc->link].lname; if (is_url(cp) == FILE_URL_TYPE) { - tp = HTfullURL_toFile(cp); + tp = cp; + if (!strncmp(tp, "file://localhost", 16)) { + tp += 16; + } else if (!strncmp(tp, "file:", 5)) { + tp += 5; + } strcpy(testpath, tp); - free(tp); - + HTUnEscape(testpath); if ((i = strlen(testpath)) && testpath[i - 1] == '/') testpath[(i - 1)] = '\0'; - if (remove_single(testpath)) { if (doc->link == (nlinks - 1)) --doc->link; @@ -1023,8 +1076,8 @@ PUBLIC BOOLEAN local_remove ARGS1( * Makes the code a bit cleaner. */ static struct { - CONST char *string_mode; /* Key for value below */ - long permit_bits; /* Value for chmod/whatever */ + char *string_mode; /* Key for value below */ + long permit_bits; /* Value for chmod/whatever */ } permissions[] = { {"IRUSR", S_IRUSR}, {"IWUSR", S_IWUSR}, @@ -1039,7 +1092,11 @@ static struct { use shell access for that. */ }; -PRIVATE char LYValidPermitFile[LY_MAXPATH] = "\0"; +#ifndef S_ISDIR +#define S_ISDIR(mode) ((mode&0xF000) == 0x4000) +#endif /* !S_ISDIR */ + +PRIVATE char LYValidPermitFile[256] = "\0"; /* * Handle DIRED permissions. @@ -1050,13 +1107,14 @@ PRIVATE BOOLEAN permit_location ARGS3( char **, newpath) { #ifndef UNIX - HTAlert("Sorry, don't know how to permit non-UNIX files yet."); + _statusline("Sorry, don't know how to permit non-UNIX files yet."); + sleep(AlertSecs); return(0); #else - static char tempfile[LY_MAXPATH] = "\0"; + static char tempfile[256] = "\0"; + static BOOLEAN first = TRUE; char *cp; char tmpbuf[LINESIZE]; - char tmpdst[LY_MAXPATH]; struct stat dir_info; if (srcpath) { @@ -1064,35 +1122,62 @@ PRIVATE BOOLEAN permit_location ARGS3( * Create form. */ FILE *fp0; - char local_src[LY_MAXPATH]; char * user_filename; struct group * grp; char * group_name; - cp = HTfullURL_toFile(strip_trailing_slash(srcpath)); - strcpy(local_src, cp); - free(cp); - /* * A couple of sanity tests. */ - if (!ok_lstat(local_src, &dir_info) - || !ok_file_or_dir(&dir_info)) + srcpath = strip_trailing_slash(srcpath); + if (strncmp(srcpath, "file://localhost", 16) == 0) + srcpath += 16; + if (lstat(srcpath, &dir_info) == -1) { + sprintf(tmpbuf, "Unable to get status of '%s'.", srcpath); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; + } else if ((dir_info.st_mode & S_IFMT) != S_IFDIR && + (dir_info.st_mode & S_IFMT) != S_IFREG) { + _statusline( + "The specified item is not a file nor a directory - request ignored."); + sleep(AlertSecs); + return(0); + } - user_filename = LYPathLeaf(local_src); + user_filename = srcpath; + cp = strrchr(srcpath, '/'); + if (cp != NULL) { + user_filename = (cp + 1); + } - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { - HTAlert("Unable to open permit options file"); - return(0); + if (first) { + /* + * Get an unused tempfile name. - FM + */ + tempname(tempfile, NEW_FILE); } /* - * Make the tempfile a URL. + * Open the tempfile for writing and set its + * protection in case this wasn't done via an + * external umask. - FM */ - LYLocalFileToURL(newpath, tempfile); - strcpy(LYPermitFileURL, *newpath); + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + _statusline("Unable to open permit options file"); + sleep(AlertSecs); + return(0); + } + + if (first) { + /* + * Make the tempfile a URL. + */ + strcpy(LYPermitFileURL, "file://localhost"); + strcat(LYPermitFileURL, tempfile); + first = FALSE; + } + StrAllocCopy(*newpath, LYPermitFileURL); grp = getgrgid(dir_info.st_gid); if (grp == NULL) { @@ -1102,7 +1187,7 @@ PRIVATE BOOLEAN permit_location ARGS3( } LYstrncpy(LYValidPermitFile, - local_src, + srcpath, (sizeof(LYValidPermitFile) - 1)); fprintf(fp0, "<Html><Head>\n<Title>%s</Title>\n</Head>\n<Body>\n", @@ -1169,10 +1254,10 @@ PRIVATE BOOLEAN permit_location ARGS3( fprintf(fp0, "<Br>\n<Li><Input Type=\"submit\" Value=\"Submit\"> \ form to permit %s %s.\n</Ol>\n</Form>\n", - S_ISDIR(dir_info.st_mode) ? "directory" : "file", + (dir_info.st_mode & S_IFMT) == S_IFDIR ? "directory" : "file", user_filename); fprintf(fp0, "</Body></Html>"); - LYCloseTempFP(fp0); + fclose(fp0); LYforce_no_cache = TRUE; return(PERMIT_FORM_RESULT); /* Special flag for LYMainLoop */ @@ -1192,7 +1277,8 @@ form to permit %s %s.\n</Ol>\n</Form>\n", HTAlert(INVALID_PERMIT_URL); else fprintf(stderr, "%s\n", INVALID_PERMIT_URL); - CTRACE(tfp, "permit_location: called for <%s>.\n", + if (TRACE) + fprintf(stderr, "permit_location: called for <%s>.\n", (destpath ? destpath : "NULL URL pointer")); return 0; @@ -1207,12 +1293,7 @@ form to permit %s %s.\n</Ol>\n</Form>\n", *cp++ = '\0'; /* Null terminate file name and start working on the masks. */ - if ((destpath = HTfullURL_toFile(destpath)) == 0) - return(0); - - strcpy(tmpdst, destpath); /* operate only on filename */ - free(destpath); - destpath = tmpdst; + HTUnEscape(destpath); /* Will now operate only on filename part. */ /* * Make sure that the file string is the one from @@ -1223,7 +1304,8 @@ form to permit %s %s.\n</Ol>\n</Form>\n", HTAlert(INVALID_PERMIT_URL); else fprintf(stderr, "%s\n", INVALID_PERMIT_URL); - CTRACE(tfp, "permit_location: called for file '%s'.\n", + if (TRACE) + fprintf(stderr, "permit_location: called for file '%s'.\n", destpath); return 0; } @@ -1232,8 +1314,16 @@ form to permit %s %s.\n</Ol>\n</Form>\n", * A couple of sanity tests. */ destpath = strip_trailing_slash(destpath); - if (!ok_stat(destpath, &dir_info) - || !ok_file_or_dir(&dir_info)) { + if (stat(destpath, &dir_info) == -1) { + sprintf(tmpbuf, "Unable to get status of '%s'.", destpath); + _statusline(tmpbuf); + sleep(AlertSecs); + return 0; + } else if ((dir_info.st_mode & S_IFMT) != S_IFDIR && + (dir_info.st_mode & S_IFMT) != S_IFREG) { + _statusline( + "The specified item is not a file nor a directory - request ignored."); + sleep(AlertSecs); return 0; } @@ -1266,11 +1356,13 @@ form to permit %s %s.\n</Ol>\n</Form>\n", } } if (permissions[i].string_mode == NULL) { - HTAlert("Invalid mode format."); + _statusline("Invalid mode format."); + sleep(AlertSecs); return 0; } } else { - HTAlert("Invalid syntax format."); + _statusline("Invalid syntax format."); + sleep(AlertSecs); return 0; } @@ -1369,7 +1461,8 @@ PUBLIC int local_dired ARGS1( char buffer[512]; line_url = doc->address; - CTRACE(tfp, "local_dired: called for <%s>.\n", + if (TRACE) + fprintf(stderr, "local_dired: called for <%s>.\n", (line_url ? line_url : "NULL URL pointer")); HTUnEscapeSome(line_url, "/"); /* don't mess too much with *doc */ @@ -1433,7 +1526,8 @@ PUBLIC int local_dired ARGS1( if (LYUpload(line_url)) LYforce_no_cache = TRUE; } else { - LYTrimPathSep(line); + if (line[(strlen(line) - 1)] == '/') + line[strlen(line)-1] = '\0'; if ((cp = strrchr(line, '/')) == NULL) { FREE(line); return 0; @@ -1453,7 +1547,9 @@ PUBLIC int local_dired ARGS1( } else if (!strncmp(line, "LYNXDIRED://UUDECODE", 20)) { tp = quote_pathname(line + 20); sprintf(buffer,"%s %s", UUDECODE_PATH, tp); - HTAlert("Warning! UUDecoded file will exist in the directory you started Lynx."); + _statusline( + "Warning! UUDecoded file will exist in the directory you started Lynx."); + sleep(AlertSecs); FREE(tp); #endif /* OK_UUDECODE && !ARCHIVE_ONLY */ @@ -1568,7 +1664,8 @@ PUBLIC int local_dired ARGS1( _statusline(tmpbuf); stop_curses(); printf("%s\n", tmpbuf); - LYSystem(buffer); + fflush(stdout); + system(buffer); #ifdef VMS extern BOOLEAN HadVMSInterrupt HadVMSInterrupt = FALSE; @@ -1590,61 +1687,114 @@ PUBLIC int dired_options ARGS2( document *, doc, char **, newfile) { - static char tempfile[LY_MAXPATH]; + static char tempfile[256]; + static BOOLEAN first = TRUE; char path[512], dir[512]; /* much too large */ + char tmpbuf[LINESIZE]; lynx_html_item_type *nxt; struct stat dir_info; FILE *fp0; char *cp = NULL; - char *dir_url; - char *path_url; + char *dir_url = NULL; /* Will hold URL-escaped path of + directory from where DIRED_MENU was + invoked (NOT its full URL). */ + char *path_url = NULL; /* Will hold URL-escaped path of file + (or directory) which was selected + when DIRED_MENU was invoked (NOT + its full URL). */ BOOLEAN nothing_tagged; int count; struct dired_menu *mp; char buf[2048]; - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { - HTAlert("Unable to open file management menu file."); - return(0); + + if (first) { + /* + * Get an unused tempfile name. - FM + */ + tempname(tempfile, NEW_FILE); } /* - * Make the tempfile a URL. + * Open the tempfile for writing and set its + * protection in case this wasn't done via an + * external umask. - FM */ - LYLocalFileToURL(newfile, tempfile); - strcpy(LYDiredFileURL, *newfile); + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + _statusline("Unable to open file management menu file."); + sleep(AlertSecs); + return(0); + } - cp = HTpartURL_toFile(doc->address); + if (first) { + /* + * Make the tempfile a URL. + */ + strcpy(LYDiredFileURL, "file://localhost"); + strcat(LYDiredFileURL, tempfile); + first = FALSE; + } + StrAllocCopy(*newfile, LYDiredFileURL); + + cp = doc->address; + if (!strncmp(cp, "file://localhost", 16)) { + cp += 16; + } else if (!strncmp(cp, "file:", 5)) { + cp += 5; + } strcpy(dir, cp); - LYTrimPathSep(dir); + StrAllocCopy(dir_url, cp); + if (dir_url[(strlen(dir_url) - 1)] == '/') + dir_url[(strlen(dir_url) - 1)] = '\0'; + HTUnEscape(dir); + if (dir[(strlen(dir) - 1)] == '/') + dir[(strlen(dir) - 1)] = '\0'; if (doc->link > -1 && doc->link < (nlinks+1)) { - cp = HTfullURL_toFile(links[doc->link].lname); + cp = links[doc->link].lname; + if (!strncmp(cp, "file://localhost", 16)) { + cp += 16; + } else if (!strncmp(cp, "file:", 5)) { + cp += 5; + } strcpy(path, cp); - LYTrimPathSep(path); - free(cp); - - if (!ok_lstat(path, &dir_info)) { - LYCloseTempFP(fp0); + StrAllocCopy(path_url, cp); + if (*path_url && path_url[1] && path_url[(strlen(path_url) - 1)] == '/') + path_url[(strlen(path_url) - 1)] = '\0'; + HTUnEscape(path); + if (*path && path[1] && path[(strlen(path) - 1)] == '/') + path[(strlen(path) - 1)] = '\0'; + + if (lstat(path, &dir_info) == -1 && stat(path, &dir_info) == -1) { + sprintf(tmpbuf, "Unable to get status of '%s'.", path); + _statusline(tmpbuf); + sleep(AlertSecs); + FREE(dir_url); + FREE(path_url); return 0; } } else { path[0] = '\0'; + StrAllocCopy(path_url, path); } nothing_tagged = (HTList_isEmpty(tagged)); - BeginInternalPage(fp0, DIRED_MENU_TITLE, DIRED_MENU_HELP); + fprintf(fp0, + "<head>\n<title>%s</title></head>\n<body>\n", DIRED_MENU_TITLE); - fprintf(fp0, "<em>Current directory:</em> %s<br>\n", dir); + fprintf(fp0, + "\n<h1>File Management Options (%s Version %s)</h1>", + LYNX_NAME, LYNX_VERSION); + + fprintf(fp0, "Current directory is %s<br>\n", dir); if (nothing_tagged) { if (strlen(path)) { - fprintf(fp0, "<em>Current selection:</em> %s<p>\n", path); + fprintf(fp0, "Current selection is %s<p>\n", path); } else { - fprintf(fp0, "<em>Current selection:</em> Nothing currently selected.<p>\n"); + fprintf(fp0, "Nothing currently selected.<p>\n"); } } else { /* @@ -1657,18 +1807,19 @@ PUBLIC int dired_options ARGS2( char *cd = NULL; int i, m; #define NUM_TAGS_TO_WRITE 10 - fprintf(fp0, "<em>Current selection:</em> %d tagged item%s", + fprintf(fp0, "Current selection is %d tagged item%s", n, ((n == 1) ? ":" : "s:")); StrAllocCopy(cd, doc->address); HTUnEscapeSome(cd, "/"); - LYAddHtmlSep(&cd); + if (*cd && cd[(strlen(cd) - 1)] != '/') + StrAllocCat(cd, "/"); m = (n < NUM_TAGS_TO_WRITE) ? n : NUM_TAGS_TO_WRITE; for (i = 1; i <= m; i++) { cp1 = HTRelative(HTList_objectAt(tagged, i-1), (*cd ? cd : "file://localhost")); HTUnEscape(cp1); LYEntify(&cp1, TRUE); /* _should_ do this everywhere... */ - fprintf(fp0, "%s<br>\n %s", + fprintf(fp0, "%s <br>\n %s", (i == 1 ? "" : " ,"), cp1); FREE(cp1); } @@ -1695,30 +1846,26 @@ PUBLIC int dired_options ARGS2( if (mp->cond == DE_TAG && nothing_tagged) continue; if (mp->cond == DE_DIR && - (!*path || !S_ISDIR(dir_info.st_mode))) + (!*path || (dir_info.st_mode & S_IFMT) != S_IFDIR)) continue; if (mp->cond == DE_FILE && - (!*path || !S_ISREG(dir_info.st_mode))) + (!*path || (dir_info.st_mode & S_IFMT) != S_IFREG)) continue; #ifdef S_IFLNK if (mp->cond == DE_SYMLINK && - (!*path || !S_ISLNK(dir_info.st_mode))) + (!*path || (dir_info.st_mode & S_IFMT) != S_IFLNK)) continue; #endif if (*mp->sfx && (strlen(path) < strlen(mp->sfx) || strcmp(mp->sfx, &path[(strlen(path) - strlen(mp->sfx))]) != 0)) continue; - dir_url = HTEscape(dir, URL_PATH); - path_url = HTEscape(path, URL_PATH); fprintf(fp0, "<a href=\"%s", - render_item(mp->href, path_url, dir_url, buf,sizeof(buf), YES)); + render_item(mp->href, path_url, dir_url, buf,2048, YES)); fprintf(fp0, "\">%s</a> ", - render_item(mp->link, path, dir, buf,sizeof(buf), NO)); + render_item(mp->link, path, dir, buf,2048, NO)); fprintf(fp0, "%s<br>\n", - render_item(mp->rest, path, dir, buf,sizeof(buf), NO)); - FREE(dir_url); - FREE(path_url); + render_item(mp->rest, path, dir, buf,2048, NO)); } if (uploaders != NULL) { @@ -1732,8 +1879,11 @@ PUBLIC int dired_options ARGS2( } } - EndInternalPage(fp0); - LYCloseTempFP(fp0); + fprintf(fp0, "</body>\n"); + fclose(fp0); + + FREE(dir_url); + FREE(path_url); LYforce_no_cache = TRUE; @@ -1746,7 +1896,7 @@ PUBLIC int dired_options ARGS2( PRIVATE char *filename ARGS3( char *, prompt, char *, buf, - size_t, bufsize) + size_t, bufsize) { char *cp; @@ -1755,7 +1905,8 @@ PRIVATE char *filename ARGS3( *buf = '\0'; LYgetstr(buf, VISIBLE, bufsize, NORECALL); if (strstr(buf, "../") != NULL) { - HTAlert("Illegal filename; request ignored."); + _statusline("Illegal filename; request ignored."); + sleep(AlertSecs); return NULL; } @@ -1766,7 +1917,8 @@ PRIVATE char *filename ARGS3( else cp = buf; if (*cp == '.') { - HTAlert("Illegal filename; request ignored."); + _statusline("Illegal filename; request ignored."); + sleep(AlertSecs); return NULL; } } @@ -1794,24 +1946,45 @@ PUBLIC BOOLEAN local_install ARGS3( * Determine the status of the selected item. */ if (srcpath) { - if (!ok_localname(savepath, srcpath)) + srcpath = strip_trailing_slash(srcpath); + if (strncmp(srcpath, "file://localhost", 16) == 0) + srcpath += 16; + if (stat(srcpath, &dir_info) == -1) { + sprintf(tmpbuf, "Unable to get status of '%s'.", srcpath); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; - + } else if ((dir_info.st_mode & S_IFMT) != S_IFDIR && + (dir_info.st_mode & S_IFMT) != S_IFREG) { + _statusline( + "The selected item is not a file or a directory! Request ignored."); + sleep(AlertSecs); + return 0; + } + strcpy(savepath, srcpath); LYforce_no_cache = TRUE; - LYLocalFileToURL(newpath, Home_Dir()); - StrAllocCat(*newpath, "/.installdirs.html"); + strcpy(tmpbuf, "file://localhost"); + strcat(tmpbuf, Home_Dir()); + strcat(tmpbuf, "/.installdirs.html"); + StrAllocCopy(*newpath, tmpbuf); return 0; } destpath = strip_trailing_slash(destpath); - if (!ok_stat(destpath, &dir_info)) { + if (stat(destpath,&dir_info) == -1) { + sprintf(tmpbuf,"Unable to get status of '%s'.",destpath); + _statusline(tmpbuf); + sleep(AlertSecs); return 0; - } else if (!S_ISDIR(dir_info.st_mode)) { - HTAlert("The selected item is not a directory! Request ignored."); + } else if ((dir_info.st_mode & S_IFMT) != S_IFDIR) { + _statusline( + "The selected item is not a directory! Request ignored."); + sleep(AlertSecs); return 0; - } else if (0 /*directory not writable*/) { - HTAlert("Install in the selected directory not permitted."); + } else if (0 /*directory not writeable*/) { + _statusline("Install in the selected directory not permitted."); + sleep(AlertSecs); return 0; } @@ -1834,17 +2007,18 @@ PUBLIC BOOLEAN local_install ARGS3( } else { char *name; while ((name = (char *)HTList_nextObject(tag))) { - int err; - args[src] = HTfullURL_toFile(name); - err = (LYExecv(INSTALL_PATH, args, tmpbuf) <= 0); - free(args[src]); - if (err) + args[src] = name; + if (strncmp("file://localhost", args[src], 16) == 0) + args[src] = (name + 16); + + if (LYExecv(INSTALL_PATH, args, tmpbuf) <= 0) return ((count == 0) ? -1 : count); count++; } clear_tags(); } - HTInfoMsg("Installation complete"); + statusline("Installation complete"); + sleep(InfoSecs); return count; } @@ -1927,7 +2101,7 @@ PUBLIC void add_menu_item ARGS1( * Create URL for DIRED HREF value. */ PRIVATE char * render_item ARGS6( - CONST char *, s, + char *, s, char *, path, char *, dir, char *, buf, @@ -1948,18 +2122,25 @@ PRIVATE char * render_item ARGS6( switch (*s) { case '%': *BP_INC = '%'; +#ifdef NOTDEFINED + /* + * These chars come from lynx.cfg or the default, let's + * just assume there won't be any improper %'s there that + * would need escaping. + */ + if(url_syntax) { + *BP_INC = '2'; + *BP_INC = '5'; + } +#endif /* NOTDEFINED */ break; case 'p': cp = path; - if (!LYIsHtmlSep(*cp)) - *BP_INC = '/'; while (*cp) *BP_INC = *cp++; break; case 'd': cp = dir; - if (!LYIsHtmlSep(*cp)) - *BP_INC = '/'; while (*cp) *BP_INC = *cp++; break; @@ -1998,6 +2179,12 @@ PRIVATE char * render_item ARGS6( break; default: *BP_INC = '%'; +#ifdef NOTDEFINED + if (url_syntax) { + *BP_INC = '2'; + *BP_INC = '5'; + } +#endif /* NOTDEFINED */ *BP_INC =*s; break; } @@ -2013,7 +2200,8 @@ PRIVATE char * render_item ARGS6( } if (overrun & url_syntax) { sprintf(buf,"Temporary URL or list would be too long."); - HTAlert(buf); + _statusline(buf); + sleep(AlertSecs); bp = buf; /* set to start, will return empty string as URL */ } *bp = '\0'; @@ -2030,7 +2218,9 @@ PRIVATE int LYExecv ARGS3( char *, msg) { #if defined(VMS) || defined(_WINDOWS) - CTRACE(tfp, "LYExecv: Called inappropriately!\n"); + if (TRACE) { + fprintf(stderr, "LYExecv: Called inappropriately!\n"); + } return(0); #else int rc; @@ -2042,13 +2232,6 @@ PRIVATE int LYExecv ARGS3( int wstatus; #endif - if (TRACE) { - int n; - CTRACE(tfp, "LYExecv path='%s'\n", path); - for (n = 0; argv[n] != 0; n++) - CTRACE(tfp, "argv[%d] = '%s'\n", n, argv[n]); - } - rc = 1; /* It will work */ tmpbuf[0] = '\0'; /* empty buffer for alert messages */ stop_curses(); @@ -2095,7 +2278,8 @@ PRIVATE int LYExecv ARGS3( } start_curses(); if (tmpbuf[0]) { - HTAlert(tmpbuf); + _statusline(tmpbuf); + sleep(AlertSecs); } return(rc); diff --git a/src/LYLocal.h b/src/LYLocal.h index 029718d1..47fff5c0 100644 --- a/src/LYLocal.h +++ b/src/LYLocal.h @@ -6,6 +6,11 @@ #ifdef VMS #include <types.h> #include <stat.h> +#else +#if 0 /* already included in tcp.h */ +#include <sys/types.h> +#include <sys/stat.h> +#endif #endif /* VMS */ #ifndef S_IRWXU @@ -60,6 +65,9 @@ extern void showtags PARAMS((HTList *tag)); extern int local_dired PARAMS((document *doc)); extern int dired_options PARAMS ((document *doc, char ** newfile)); +#define DIRED_MENU_TITLE "File Management Options" +#define PERMIT_OPTIONS_TITLE "File Permission Options" + extern void add_menu_item PARAMS((char *str)); #endif /* DIRED_SUPPORT */ diff --git a/src/LYMail.c b/src/LYMail.c index 62e9a8d7..f3a69290 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -1,14 +1,5 @@ -/* - * This file checked for sprintf() buffer overruns on 1998/05/06 by Bela - * Lubkin <filbo@armory.com>. Please don't introduce any new ones... - * - * See comments marked "- BL" for two still-possible overruns in the VMS - * code. - * - * Not yet checked for any other sort of buffer overrun. - */ - #include <HTUtils.h> +#include <tcp.h> #include <HTParse.h> #include <LYGlobalDefs.h> #include <HTAlert.h> @@ -18,44 +9,26 @@ #include <LYClean.h> #include <LYStrings.h> #include <GridText.h> +#include <LYSystem.h> #include <LYMail.h> #include <LYCharSets.h> /* to get current charset for mail header */ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + BOOLEAN term_letter; /* Global variable for async i/o. */ PRIVATE void terminate_letter PARAMS((int sig)); PRIVATE void remove_tildes PARAMS((char *string)); -/* HTUnEscape with control-code nuking */ -PRIVATE void SafeHTUnEscape ARGS1( - char *, string) -{ - int i; - int flg = FALSE; - - HTUnEscape(string); - for (i=0; string[i] != '\0'; i++) - { - /* FIXME: this is explicitly 7-bit ASCII */ - if (string[i] < ' ' || string[i] >= 127) - { - string[i] = '?'; - flg = TRUE; - } - } - if (flg) - HTAlert(MAILTO_SQUASH_CTL); -} - /* ** mailform() sends form content to the mailto address(es). - FM */ PUBLIC void mailform ARGS4( - CONST char *, mailto_address, - CONST char *, mailto_subject, - CONST char *, mailto_content, - CONST char *, mailto_type) + char *, mailto_address, + char *, mailto_subject, + char *, mailto_content, + char *, mailto_type) { FILE *fd; char *address = NULL; @@ -115,7 +88,7 @@ PUBLIC void mailform ARGS4( *cp1 = '\0'; } if (*cp) { - SafeHTUnEscape(subject); + HTUnEscape(subject); LYstrncpy(subject, cp, 70); } if (cp1) { @@ -222,7 +195,7 @@ PUBLIC void mailform ARGS4( } if (keywords != NULL) { if (*keywords != '\0') { - SafeHTUnEscape(keywords); + HTUnEscape(keywords); } else { FREE(keywords); } @@ -275,9 +248,9 @@ PUBLIC void mailform ARGS4( /* * Unescape the address and ccaddr fields. - FM */ - SafeHTUnEscape(address); + HTUnEscape(address); if (ccaddr != NULL) { - SafeHTUnEscape(ccaddr); + HTUnEscape(ccaddr); } /* @@ -296,7 +269,8 @@ PUBLIC void mailform ARGS4( /* * User cancelled via ^G. - FM */ - HTInfoMsg(FORM_MAILTO_CANCELLED); + _statusline(FORM_MAILTO_CANCELLED); + sleep(InfoSecs); FREE(address); FREE(ccaddr); FREE(keywords); @@ -316,7 +290,8 @@ PUBLIC void mailform ARGS4( /* * User cancelled via ^G. - FM */ - HTInfoMsg(FORM_MAILTO_CANCELLED); + _statusline(FORM_MAILTO_CANCELLED); + sleep(InfoSecs); FREE(address); FREE(ccaddr); FREE(keywords); @@ -332,7 +307,14 @@ PUBLIC void mailform ARGS4( } #if defined(VMS) || defined(DOSPATH) - if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { + tempname(my_tmpfile, NEW_FILE); + if (((cp = strrchr(my_tmpfile, '.')) != NULL) && + NULL == strchr(cp, ']') && + NULL == strchr(cp, '/')) { + *cp = '\0'; + strcat(my_tmpfile, ".txt"); + } + if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) { HTAlert(FORM_MAILTO_FAILED); FREE(address); FREE(ccaddr); @@ -340,9 +322,15 @@ PUBLIC void mailform ARGS4( return; } if (isPMDF) { - if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { + tempname(hdrfile, NEW_FILE); + if (((cp = strrchr(hdrfile, '.')) != NULL) && + NULL == strchr(cp, ']') && + NULL == strchr(cp, '/')) { + *cp = '\0'; + strcat(hdrfile, ".txt"); + } + if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { HTAlert(FORM_MAILTO_FAILED); - LYCloseTempFP(fd); FREE(address); FREE(ccaddr); FREE(keywords); @@ -414,33 +402,33 @@ PUBLIC void mailform ARGS4( i = 0; len = strlen(mailto_content); while (len > 78) { - strncpy(cmd, &mailto_content[i], 78); + strncpy(cmd, (char *)&mailto_content[i], 78); cmd[78] = '\0'; fprintf(fd, "%s\n", cmd); i += 78; - len = strlen(&mailto_content[i]); + len = strlen((char *)&mailto_content[i]); } - fprintf(fd, "%s\n", &mailto_content[i]); + fprintf(fd, "%s\n", (char *)&mailto_content[i]); mailto_content = (cp+1); } i = 0; len = strlen(mailto_content); while (len > 78) { - strncpy(cmd, &mailto_content[i], 78); + strncpy(cmd, (char *)&mailto_content[i], 78); cmd[78] = '\0'; fprintf(fd, "%s\n", cmd); i += 78; - len = strlen(&mailto_content[i]); + len = strlen((char *)&mailto_content[i]); } if (len) - fprintf(fd, "%s\n", &mailto_content[i]); + fprintf(fd, "%s\n", (char *)&mailto_content[i]); #ifdef UNIX pclose(fd); sleep(MessageSecs); #endif /* UNIX */ #if defined(VMS) || defined(DOSPATH) - LYCloseTempFP(fd); + fclose(fd); #ifdef VMS /* * Set the mail command. - FM @@ -454,7 +442,7 @@ PUBLIC void mailform ARGS4( fprintf(hfd, "Keywords: %s\n", keywords); } fprintf(hfd, "Subject: %s\n\n", subject); - LYCloseTempFP(hfd); + fclose(hfd); /* * Now set up the command. - FM */ @@ -470,8 +458,6 @@ PUBLIC void mailform ARGS4( * command, and ignore any keywords to minimize risk * of them making the line too long or having problem * characters. - FM - * - * Possibly still a problem if user supplies long subject. - BL */ sprintf(cmd, "%s %s%s/subject=\"%s\" %s ", @@ -499,12 +485,8 @@ PUBLIC void mailform ARGS4( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e. about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { if (!first) { StrAllocCat(command, ","); } @@ -532,12 +514,8 @@ PUBLIC void mailform ARGS4( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e. about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { StrAllocCat(command, ","); sprintf(cmd, mail_adrs, address_ptr1); if (isPMDF) { @@ -551,25 +529,20 @@ PUBLIC void mailform ARGS4( stop_curses(); printf("Sending form content:\n\n$ %s\n\nPlease wait...", command); - LYSystem(command); + system(command); FREE(command); sleep(AlertSecs); start_curses(); - LYRemoveTemp(my_tmpfile); - LYRemoveTemp(hdrfile); + remove(my_tmpfile); + remove(hdrfile); #else /* DOSPATH */ - StrAllocCopy(command, system_mail); - StrAllocCat(command, " -t \""); - StrAllocCat(command, address); - StrAllocCat(command, "\" -F "); - StrAllocCat(command, my_tmpfile); + sprintf(cmd, "%s -t \"%s\" -F %s", system_mail, address, my_tmpfile); stop_curses(); - printf("Sending form content:\n\n$ %s\n\nPlease wait...", command); - LYSystem(command); - FREE(command); + printf("Sending form content:\n\n$ %s\n\nPlease wait...", cmd); + system(cmd); sleep(MessageSecs); start_curses(); - LYRemoveTemp(my_tmpfile); + remove(my_tmpfile); #endif #endif /* VMS */ @@ -602,11 +575,6 @@ PUBLIC void mailmsg ARGS4( char hdrfile[256]; FILE *hfd; - CTRACE(tfp, "mailmsg(%d, \"%s\", \"%s\", \"%s\")\n", cur, - owner_address?owner_address:"<nil>", - filename?filename:"<nil>", - linkname?linkname:"<nil>"); - if (!strncasecomp(system_mail, "PMDF SEND", 9)) { isPMDF = TRUE; } @@ -678,13 +646,16 @@ PUBLIC void mailmsg ARGS4( /* * Unescape the address field. - FM */ - SafeHTUnEscape(address); + HTUnEscape(address); if (address[(strlen(address) - 1)] == ',') address[(strlen(address) - 1)] = '\0'; if (*address == '\0') { FREE(address); - CTRACE(tfp, "mailmsg: No address in '%s'.\n", + if (TRACE) { + fprintf(stderr, + "mailmsg: No address in '%s'.\n", owner_address); + } return; } @@ -692,8 +663,11 @@ PUBLIC void mailmsg ARGS4( sprintf(cmd, "%s %s", system_mail, system_mail_flags); if ((fd = popen(cmd, "w")) == NULL) { FREE(address); - CTRACE(tfp, "mailmsg: '%s' failed.\n", + if (TRACE) { + fprintf(stderr, + "mailmsg: '%s' failed.\n", cmd); + } return; } @@ -706,16 +680,36 @@ PUBLIC void mailmsg ARGS4( fprintf(fd, "X-Mailer: Lynx, Version %s\n\n", LYNX_VERSION); #endif /* UNIX */ #if defined(VMS) || defined(DOSPATH) - if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { - CTRACE(tfp, "mailmsg: Could not fopen '%s'.\n", + tempname(my_tmpfile, NEW_FILE); + if (((cp = strrchr(my_tmpfile, '.')) != NULL) && + NULL == strchr(cp, ']') && + NULL == strchr(cp, '/')) { + *cp = '\0'; + strcat(my_tmpfile, ".txt"); + } + if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) { + if (TRACE) { + fprintf(stderr, + "mailmsg: Could not fopen '%s'.\n", my_tmpfile); + } FREE(address); return; } if (isPMDF) { - if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { - CTRACE(tfp, "mailmsg: Could not fopen '%s'.\n", + tempname(hdrfile, NEW_FILE); + if (((cp = strrchr(hdrfile, '.')) != NULL) && + NULL == strchr(cp, ']') && + NULL == strchr(cp, '/')) { + *cp = '\0'; + strcat(hdrfile, ".txt"); + } + if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { + if (TRACE) { + fprintf(stderr, + "mailmsg: Could not fopen '%s'.\n", hdrfile); + } FREE(address); return; } @@ -749,7 +743,7 @@ PUBLIC void mailmsg ARGS4( pclose(fd); #endif /* UNIX */ #if defined(VMS) || defined(DOSPATH) - LYCloseTempFP(fd); + fclose(fd); #ifdef VMS if (isPMDF) { /* @@ -757,7 +751,7 @@ PUBLIC void mailmsg ARGS4( * header file and close it. - FM */ fprintf(hfd, "Subject: Lynx Error in %.56s\n\n", filename); - LYCloseTempFP(hfd); + fclose(hfd); /* * Now set up the command. - FM */ @@ -788,16 +782,7 @@ PUBLIC void mailmsg ARGS4( } else address_ptr2 = NULL; - /* - * 4 letters is arbitrarily the smallest possible mail - * address, at least for lynx. That way extra spaces - * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e. about 500 chars). - BL - */ - if (strlen(address) > 3 && - strlen(address) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address) > 3) { if (!first) { StrAllocCat(command, ","); } @@ -808,21 +793,16 @@ PUBLIC void mailmsg ARGS4( address_ptr1 = address_ptr2; } while (address_ptr1 != NULL); - LYSystem(command); + system(command); FREE(command); - LYRemoveTemp(my_tmpfile); + remove(my_tmpfile); if (isPMDF) { - LYRemoveTemp(hdrfile); + remove(hdrfile); } #else /* DOSPATH */ - StrAllocCopy(command, system_mail); - StrAllocCat(command, " -t \""); - StrAllocCat(command, address); - StrAllocCat(command, "\" -F "); - StrAllocCat(command, my_tmpfile); - LYSystem(command); - FREE(command); - LYRemoveTemp(my_tmpfile); + sprintf(cmd, "%s -t \"%s\" -F %s", system_mail, address, my_tmpfile); + system(cmd); + remove(my_tmpfile); #endif #endif /* VMS */ @@ -880,25 +860,16 @@ PUBLIC void reply_by_mail ARGS3( #ifdef DOSPATH char tmpfile2[256]; #endif -#if defined(DOSPATH) || defined(VMS) - char *command = NULL; -#endif -#ifndef NO_ANONYMOUS_EMAIL static char *personal_name = NULL; -#endif char subject[80]; #ifdef VMS char *address_ptr1 = NULL, *address_ptr2 = NULL; + char *command = NULL; BOOLEAN first = TRUE; BOOLEAN isPMDF = FALSE; char hdrfile[256]; FILE *hfd; - CTRACE(tfp, "reply_by_mail(\"%s\", \"%s\", \"%s\")\n", - mail_address?mail_address:"<nil>", - filename?filename:"<nil>", - title?title:"<nil>"); - if (!strncasecomp(system_mail, "PMDF SEND", 9)) { isPMDF = TRUE; } @@ -917,13 +888,29 @@ PUBLIC void reply_by_mail ARGS3( return; } - if ((fd = LYOpenTemp(my_tmpfile, ".txt", "w")) == NULL) { + tempname(my_tmpfile, NEW_FILE); + if (((cp = strrchr(my_tmpfile, '.')) != NULL) && +#ifdef VMS + NULL == strchr(cp, ']') && +#endif /* VMS */ + NULL == strchr(cp, '/')) { + *cp = '\0'; + strcat(my_tmpfile, ".txt"); + } + if ((fd = LYNewTxtFile(my_tmpfile)) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } #ifdef VMS if (isPMDF) { - if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { + tempname(hdrfile, NEW_FILE); + if (((cp = strrchr(hdrfile, '.')) != NULL) && + NULL == strchr(cp, ']') && + NULL == strchr(cp, '/')) { + *cp = '\0'; + strcat(hdrfile, ".txt"); + } + if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } @@ -956,7 +943,7 @@ PUBLIC void reply_by_mail ARGS3( if (*cp) { strncpy(subject, cp, 70); subject[70] = '\0'; - SafeHTUnEscape(subject); + HTUnEscape(subject); } if (cp1) { *cp1 = '&'; @@ -1063,7 +1050,7 @@ PUBLIC void reply_by_mail ARGS3( } if (keywords != NULL) { if (*keywords != '\0') { - SafeHTUnEscape(keywords); + HTUnEscape(keywords); } else { FREE(keywords); } @@ -1160,8 +1147,8 @@ PUBLIC void reply_by_mail ARGS3( FREE(ccaddr); FREE(keywords); FREE(body); - LYCloseTempFP(fd); /* Close the tmpfile. */ - LYRemoveTemp(my_tmpfile); /* Delete the tmpfile. */ + fclose(fd); /* Close the tmpfile. */ + remove(my_tmpfile); /* Delete the tmpfile. */ HTAlert(NO_ADDRESS_IN_MAILTO_URL); return; } @@ -1186,9 +1173,9 @@ PUBLIC void reply_by_mail ARGS3( /* * Unescape the address and ccaddr fields. - FM */ - SafeHTUnEscape(address); + HTUnEscape(address); if (ccaddr != NULL) { - SafeHTUnEscape(ccaddr); + HTUnEscape(ccaddr); } /* @@ -1229,9 +1216,8 @@ PUBLIC void reply_by_mail ARGS3( * Put the To: line in the header. */ #ifndef DOSPATH - StrAllocCopy(header, "To: "); - StrAllocCat(header, address); - StrAllocCat(header, "\n"); + sprintf(buf, "To: %s\n", address); + StrAllocCopy(header, buf); #endif /* @@ -1261,15 +1247,11 @@ PUBLIC void reply_by_mail ARGS3( /* * Put the X-URL and X-Mailer lines in the header. */ - StrAllocCat(header, "X-URL: "); - if (filename && *filename) { - StrAllocCat(header, filename); - } - else { - StrAllocCat(header, "mailto:"); - StrAllocCat(header, address); - } - StrAllocCat(header, "\n"); + sprintf(buf, + "X-URL: %s%s\n", + (filename && *filename) ? filename : "mailto:", + (filename && *filename) ? "" : address); + StrAllocCat(header, buf); sprintf(buf, "X-Mailer: Lynx, Version %s\n", LYNX_VERSION); StrAllocCat(header, buf); #endif /* VMS */ @@ -1354,8 +1336,9 @@ PUBLIC void reply_by_mail ARGS3( if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter) { addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1368,9 +1351,8 @@ PUBLIC void reply_by_mail ARGS3( fprintf((isPMDF ? hfd : fd), "X-Personal_name: %s\n",user_input); #else - StrAllocCat(header, "X-Personal_name: "); - StrAllocCat(header, user_input); - StrAllocCat(header, "\n"); + sprintf(buf, "X-Personal_name: %s\n", user_input); + StrAllocCat(header, buf); #endif /* VMS */ } @@ -1396,8 +1378,9 @@ PUBLIC void reply_by_mail ARGS3( if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter) { addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1414,9 +1397,8 @@ PUBLIC void reply_by_mail ARGS3( fprintf(fd, "\n"); } #else - StrAllocCat(header, "From: "); - StrAllocCat(header, user_input); - StrAllocCat(header, "\n"); + sprintf(buf, "From: %s\n", user_input); + StrAllocCat(header, buf); #endif /* VMS */ #endif /* !NO_ANONYMOUS_EMAIL */ #ifdef VMS @@ -1442,8 +1424,9 @@ PUBLIC void reply_by_mail ARGS3( if (LYgetstr(user_input, VISIBLE, 71, NORECALL) < 0 || term_letter) { addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1452,9 +1435,8 @@ PUBLIC void reply_by_mail ARGS3( #ifdef VMS sprintf(subject, "%.70s", user_input); #else - StrAllocCat(header, "Subject: "); - StrAllocCat(header, user_input); - StrAllocCat(header, "\n"); + sprintf(buf, "Subject: %s\n", user_input); + StrAllocCat(header, buf); #endif /* VMS */ /* @@ -1475,15 +1457,16 @@ PUBLIC void reply_by_mail ARGS3( if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter) { addstr("\n"); - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } addstr("\n"); } remove_tildes(user_input); - +#if defined (VMS) || defined (DOSPATH) if (*user_input) { cp = user_input; while (*cp == ',' || isspace((unsigned char)*cp)) @@ -1497,12 +1480,11 @@ PUBLIC void reply_by_mail ARGS3( } } } - +#endif #ifdef DOSPATH if (*address) { - StrAllocCat(header, "To: "); - StrAllocCat(header, address); - StrAllocCat(header, "\n"); + sprintf(buf, "To: %s\n", address); + StrAllocCat(header, buf); } #endif @@ -1530,7 +1512,6 @@ PUBLIC void reply_by_mail ARGS3( */ sprintf(buf, "\n"); StrAllocCat(header, buf); - CTRACE(tfp,"**header==\n%s",header); #endif /* !VMS */ if (!no_editor && editor && *editor != '\0') { @@ -1570,7 +1551,7 @@ PUBLIC void reply_by_mail ARGS3( print_wwwfile_to_fd(fd, 1); } } - LYCloseTempFP(fd); /* Close the tmpfile. */ + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ if (term_letter || c == 7 || c == 3) @@ -1585,9 +1566,10 @@ PUBLIC void reply_by_mail ARGS3( sprintf(user_input, "%s%s %s", editor, editor_arg, my_tmpfile); _statusline(SPAWNING_EDITOR_FOR_MAIL); stop_curses(); - if (LYSystem(user_input)) { + if (system(user_input)) { start_curses(); - HTAlert(ERROR_SPAWNING_EDITOR); + _statusline(ERROR_SPAWNING_EDITOR); + sleep(AlertSecs); } else { start_curses(); } @@ -1611,16 +1593,16 @@ PUBLIC void reply_by_mail ARGS3( if (term_letter || c == 7 || c == 3) { addstr(CANCELLED); sleep(InfoSecs); - LYCloseTempFP(fd); /* Close the tmpfile. */ + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } i = (LYlines - 2); } *cp++ = '\0'; - fprintf(fd, "%s\n", cp1); - addstr(cp1); - addstr("\n"); + sprintf(cmd, "%s\n", cp1); + fprintf(fd, cmd); + addstr(cmd); cp1 = cp; i--; } @@ -1629,7 +1611,7 @@ PUBLIC void reply_by_mail ARGS3( i--; } refresh(); - LYCloseTempFP(fd); /* Close the tmpfile. */ + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ } else { @@ -1644,8 +1626,9 @@ PUBLIC void reply_by_mail ARGS3( *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_letter || STREQ(user_input, ".")) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } @@ -1657,15 +1640,16 @@ PUBLIC void reply_by_mail ARGS3( *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); - LYCloseTempFP(fd); /* Close the tmpfile. */ + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ goto cleanup; } } fprintf(fd, "\n"); /* Terminate the message. */ - LYCloseTempFP(fd); /* Close the tmpfile. */ + fclose(fd); /* Close the tmpfile. */ scrollok(stdscr,FALSE); /* Stop scrolling. */ } @@ -1727,7 +1711,7 @@ PUBLIC void reply_by_mail ARGS3( fprintf(hfd, "Keywords: %s\n", keywords); } fprintf(hfd, "Subject: %s\n\n", subject); - LYCloseTempFP(hfd); + fclose(hfd); /* * Now set up the command. - FM */ @@ -1743,8 +1727,6 @@ PUBLIC void reply_by_mail ARGS3( * command, and ignore any keywords to minimize risk * of them making the line too long or having problem * characters. - FM - * - * Possibly still a problem if user supplies long subject. - BL */ sprintf(cmd, "%s %s%s/subject=\"%s\" %s ", @@ -1772,12 +1754,8 @@ PUBLIC void reply_by_mail ARGS3( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e. about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { if (!first) { StrAllocCat(command, ","); } @@ -1805,12 +1783,8 @@ PUBLIC void reply_by_mail ARGS3( * 4 letters is arbitrarily the smallest possible mail * address, at least for lynx. That way extra spaces * won't confuse the mailer and give a blank address. - * - * ignore addresses so long that they would overflow the - * temporary buffer (i.e. about 500 chars). - BL */ - if (strlen(address_ptr1) > 3 && - strlen(address_ptr1) + strlen(mail_adrs) < sizeof(cmd)) { + if (strlen(address_ptr1) > 3) { StrAllocCat(command, ","); sprintf(cmd, mail_adrs, address_ptr1); if (isPMDF) { @@ -1824,7 +1798,7 @@ PUBLIC void reply_by_mail ARGS3( stop_curses(); printf("Sending your comment:\n\n$ %s\n\nPlease wait...", command); - LYSystem(command); + system(command); FREE(command); sleep(AlertSecs); start_curses(); @@ -1836,7 +1810,13 @@ PUBLIC void reply_by_mail ARGS3( _statusline(SENDING_YOUR_MSG); sprintf(cmd, "%s %s", system_mail, system_mail_flags); #ifdef DOSPATH - if ((fp = LYOpenTemp(tmpfile2, ".txt", "w")) == NULL) { + tempname(tmpfile2, NEW_FILE); + if (((cp = strrchr(tmpfile2, '.')) != NULL) && + NULL == strchr(cp, '/')) { + *cp = '\0'; + strcat(tmpfile2, ".txt"); + } + if ((fp = LYNewTxtFile(tmpfile2)) == NULL) { HTAlert(MAILTO_URL_TEMPOPEN_FAILED); return; } @@ -1844,13 +1824,15 @@ PUBLIC void reply_by_mail ARGS3( signal(SIGINT, SIG_IGN); fp = popen(cmd, "w"); if (fp == NULL) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); goto cleanup; } #endif /* DOSPATH */ fd = fopen(my_tmpfile, "r"); if (fd == NULL) { - HTInfoMsg(COMMENT_REQUEST_CANCELLED); + _statusline(COMMENT_REQUEST_CANCELLED); + sleep(InfoSecs); pclose(fp); goto cleanup; } @@ -1858,25 +1840,21 @@ PUBLIC void reply_by_mail ARGS3( while ((n = fread(buf, 1, sizeof(buf), fd)) != 0) fwrite(buf, 1, n, fp); #ifdef DOSPATH - StrAllocCopy(command, system_mail); - StrAllocCat(command, " -t \""); - StrAllocCat(command, address); - StrAllocCat(command, "\" -F "); - StrAllocCat(command, tmpfile2); - LYCloseTempFP(fp); /* Close the tmpfile. */ - stop_curses(); - printf("Sending your comment:\n\n$ %s\n\nPlease wait...", command); - LYSystem(command); - FREE(command); - sleep(MessageSecs); - start_curses(); - LYRemoveTemp(tmpfile2); /* Delete the tmpfile. */ + sprintf(cmd, "%s -t \"%s\" -F %s", system_mail, address, tmpfile2); + fclose(fp); /* Close the tmpfile. */ + stop_curses(); + printf("Sending your comment:\n\n$ %s\n\nPlease wait...", cmd); + system(cmd); + sleep(MessageSecs); + start_curses(); + remove(tmpfile2); /* Delete the tmpfile. */ #else pclose(fp); #endif - LYCloseTempFP(fd); /* Close the tmpfile. */ + fclose(fd); /* Close the tmpfile. */ - CTRACE(tfp, "%s\n", cmd); + if (TRACE) + printf("%s\n", cmd); #endif /* VMS */ /* @@ -1894,11 +1872,14 @@ cleandown: term_letter = FALSE; #ifdef VMS FREE(command); + while (remove(my_tmpfile) == 0) + ; /* Delete the tmpfile(s). */ if (isPMDF) { - LYRemoveTemp(hdrfile); + remove(hdrfile); /* Delete the hdrfile. */ } +#else + remove(my_tmpfile); /* Delete the tmpfile. */ #endif /* VMS */ - LYRemoveTemp(my_tmpfile); FREE(address); FREE(ccaddr); FREE(keywords); diff --git a/src/LYMail.h b/src/LYMail.h index 3304228a..8de71866 100644 --- a/src/LYMail.h +++ b/src/LYMail.h @@ -9,10 +9,10 @@ extern BOOLEAN term_letter; extern void mailform PARAMS(( - CONST char * mailto_address, - CONST char * mailto_subject, - CONST char * mailto_content, - CONST char * mailto_type)); + char * mailto_address, + char * mailto_subject, + char * mailto_content, + char * mailto_type)); extern void mailmsg PARAMS(( int cur, char * owner_address, diff --git a/src/LYMain.c b/src/LYMain.c index 7b192d4f..707c0469 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTTP.h> #include <HTParse.h> #include <HTAccess.h> @@ -6,6 +7,9 @@ #include <HTFile.h> #include <UCMap.h> #include <UCDefs.h> +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ #include <HTInit.h> #include <LYCurses.h> #include <LYStyle.h> @@ -26,14 +30,8 @@ #include <LYJump.h> #include <LYMainLoop.h> #include <LYBookmark.h> -#include <LYCookie.h> - -#ifdef __DJGPP__ -#include <dos.h> -#endif /* __DJGPP__ */ - -#ifdef __EMX__ -#include <io.h> +#ifdef DOSPATH +#include <HTDOS.h> #endif #ifndef VMS @@ -49,11 +47,13 @@ #include <LYexit.h> #include <LYLeaks.h> -#ifdef FNAMES_8_3 -#define COOKIE_FILE "cookies" -#else -#define COOKIE_FILE ".lynx_cookies" -#endif /* FNAMES_8_3 */ +#define FREE(x) if (x) {free(x); x = NULL;} + +#ifdef VMS +#define DISPLAY "DECW$DISPLAY" +#else +#define DISPLAY "DISPLAY" +#endif /* VMS */ /* ahhhhhhhhhh!! Global variables :-< */ #ifdef SOCKS @@ -76,7 +76,23 @@ PUBLIC BOOLEAN UseFixedRecords = USE_FIXED_RECORDS; #ifndef VMS PUBLIC char *lynx_version_putenv_command = NULL; -PUBLIC char *list_format = NULL; /* LONG_LIST formatting mask */ +PUBLIC char *NNTPSERVER_putenv_cmd = NULL; /* lynx.cfg defined NNTPSERVER */ +PUBLIC char *http_proxy_putenv_cmd = NULL; /* lynx.cfg defined http_proxy */ +PUBLIC char *https_proxy_putenv_cmd = NULL; /* lynx.cfg defined https_proxy */ +PUBLIC char *ftp_proxy_putenv_cmd = NULL; /* lynx.cfg defined ftp_proxy */ +PUBLIC char *gopher_proxy_putenv_cmd = NULL; /* lynx.cfg defined gopher_proxy */ +PUBLIC char *cso_proxy_putenv_cmd = NULL; /* lynx.cfg defined cso_proxy */ +PUBLIC char *news_proxy_putenv_cmd = NULL; /* lynx.cfg defined news_proxy */ +PUBLIC char *newspost_proxy_putenv_cmd = NULL; +PUBLIC char *newsreply_proxy_putenv_cmd = NULL; +PUBLIC char *snews_proxy_putenv_cmd = NULL; /* lynx.cfg defined snews_proxy */ +PUBLIC char *snewspost_proxy_putenv_cmd = NULL; +PUBLIC char *snewsreply_proxy_putenv_cmd = NULL; +PUBLIC char *nntp_proxy_putenv_cmd = NULL; /* lynx.cfg defined nntp_proxy */ +PUBLIC char *wais_proxy_putenv_cmd = NULL; /* lynx.cfg defined wais_proxy */ +PUBLIC char *finger_proxy_putenv_cmd = NULL; /* lynx.cfg defined finger_proxy */ +PUBLIC char *no_proxy_putenv_cmd = NULL; /* lynx.cfg defined no_proxy */ +PUBLIC char *list_format=NULL; /* LONG_LIST formatting mask */ #ifdef SYSLOG_REQUESTED_URLS PUBLIC char *syslog_txt = NULL; /* syslog arb text for session */ #endif /* SYSLOG_REQUESTED_URLS */ @@ -89,7 +105,7 @@ PUBLIC char *LYCSwingPath = NULL; #ifdef DIRED_SUPPORT PUBLIC BOOLEAN lynx_edit_mode = FALSE; PUBLIC BOOLEAN no_dired_support = FALSE; -PUBLIC int dir_list_style = MIXED_STYLE; +PUBLIC BOOLEAN dir_list_style = MIXED_STYLE; PUBLIC HTList *tagged = NULL; #ifdef OK_OVERRIDE PUBLIC BOOLEAN prev_lynx_edit_mode = FALSE; @@ -147,23 +163,19 @@ PUBLIC int port_syntax = 1; PUBLIC int LYShowColor = SHOW_COLOR_UNKNOWN; /* to show or not to show */ PUBLIC int LYChosenShowColor = SHOW_COLOR_UNKNOWN; /* whether to show and save */ PUBLIC int LYrcShowColor = SHOW_COLOR_UNKNOWN; /* ... as last read or written */ -#if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU) -PUBLIC BOOLEAN LYUseFormsOptions = TRUE; /* use forms-based options menu */ -#endif PUBLIC BOOLEAN LYShowCursor = SHOW_CURSOR; /* to show or not to show */ -PUBLIC BOOLEAN verbose_img = VERBOSE_IMAGES; /* show filenames or not */ +PUBLIC BOOLEAN verbose_img = VERBOSE_IMAGES; /* show filenames or not */ PUBLIC BOOLEAN LYUseDefShoCur = TRUE; /* Command line -show_cursor toggle */ PUBLIC BOOLEAN LYforce_no_cache = FALSE; PUBLIC BOOLEAN LYoverride_no_cache = FALSE;/*override no-cache b/c history etc*/ PUBLIC BOOLEAN LYinternal_flag = FALSE; /* override no-cache b/c internal link*/ PUBLIC BOOLEAN LYresubmit_posts = ALWAYS_RESUBMIT_POSTS; -PUBLIC BOOLEAN LYshow_kb_rate = TRUE; PUBLIC BOOLEAN LYUserSpecifiedURL = TRUE;/* always TRUE the first time */ 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 int user_mode = NOVICE_MODE; +PUBLIC BOOLEAN user_mode = NOVICE_MODE; PUBLIC BOOLEAN dump_output_immediately = FALSE; PUBLIC BOOLEAN is_www_index = FALSE; PUBLIC BOOLEAN lynx_mode = NORMAL_LYNX_MODE; @@ -175,7 +187,6 @@ PUBLIC BOOLEAN nolist = FALSE; PUBLIC BOOLEAN historical_comments = FALSE; PUBLIC BOOLEAN minimal_comments = FALSE; PUBLIC BOOLEAN soft_dquotes = FALSE; -PUBLIC BOOLEAN LYRestricted = FALSE; PUBLIC BOOLEAN LYValidate = FALSE; PUBLIC BOOLEAN LYPermitURL = FALSE; PUBLIC BOOLEAN child_lynx = FALSE; @@ -183,7 +194,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 int keypad_mode = DEFAULT_KEYPAD_MODE; +PUBLIC BOOLEAN keypad_mode = DEFAULT_KEYPAD_MODE; PUBLIC BOOLEAN case_sensitive = CASE_SENSITIVE_ALWAYS_ON; PUBLIC BOOLEAN telnet_ok = TRUE; PUBLIC BOOLEAN news_ok = TRUE; @@ -193,6 +204,9 @@ 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; @@ -261,9 +275,8 @@ PUBLIC char *lynxlistfile = NULL; /* the current list file URL */ PUBLIC char *lynxlinksfile = NULL; /* the current visited links file URL */ PUBLIC char *startrealm = NULL; /* the startfile realm */ PUBLIC char *indexfile = NULL; /* an index file if there is one */ -PUBLIC int outgoing_mail_charset = -1; /* translate mail to this charset */ PUBLIC char *personal_mail_address = NULL; /* the users mail address */ -PUBLIC char *x_display = NULL; /* display environment variable */ +PUBLIC char *display = NULL; /* display environment variable */ PUBLIC char *personal_type_map = NULL; /* .mailcap */ PUBLIC char *global_type_map = NULL; /* global mailcap */ PUBLIC char *global_extension_map = NULL; /* global mime.types */ @@ -274,7 +287,6 @@ PUBLIC BOOLEAN LYNewsPosting = NEWS_POSTING; /* News posting supported? */ PUBLIC char *LynxSigFile = NULL; /* Signature file, in or off home */ PUBLIC char *system_mail = NULL; /* The path for sending mail */ PUBLIC char *system_mail_flags = NULL; /* Flags for sending mail */ -PUBLIC char *lynx_cfg_file = NULL; /* location of active lynx.cfg */ PUBLIC char *lynx_temp_space = NULL; /* The prefix for temporary file paths */ PUBLIC char *lynx_save_space = NULL; /* The prefix for save to disk paths */ PUBLIC char *LYHostName = NULL; /* treat as a local host name */ @@ -304,8 +316,8 @@ PUBLIC BOOLEAN LYRawMode; PUBLIC BOOLEAN LYDefaultRawMode; PUBLIC BOOLEAN LYUseDefaultRawMode = TRUE; PUBLIC char *UCAssume_MIMEcharset = NULL; -PUBLIC BOOLEAN UCSaveBookmarksInUnicode = FALSE; -PUBLIC BOOLEAN UCForce8bitTOUPPER = FALSE; /* override locale for case-conversion? */ +PUBLIC char *UCAssume_localMIMEcharset = NULL; +PUBLIC char *UCAssume_unrecMIMEcharset = NULL; PUBLIC int LYlines = 24; PUBLIC int LYcols = 80; PUBLIC int dump_output_width = 0; @@ -332,19 +344,12 @@ PUBLIC char *URLDomainSuffixes = NULL; PUBLIC BOOLEAN startfile_ok = FALSE; PUBLIC BOOLEAN LYSelectPopups = USE_SELECT_POPUPS; PUBLIC BOOLEAN LYUseDefSelPop = TRUE; /* Command line -popup toggle */ -PUBLIC BOOLEAN LYMultiBookmarks = MULTI_BOOKMARK_SUPPORT; +PUBLIC int LYMultiBookmarks = MULTI_BOOKMARK_SUPPORT; PUBLIC BOOLEAN LYMBMBlocked = BLOCK_MULTI_BOOKMARKS; PUBLIC BOOLEAN LYMBMAdvanced = TRUE; PUBLIC int LYStatusLine = -1; /* Line for statusline() if > -1 */ PUBLIC BOOLEAN LYCollapseBRs = COLLAPSE_BR_TAGS; /* Collapse serial BRs? */ PUBLIC BOOLEAN LYSetCookies = SET_COOKIES; /* Process Set-Cookie headers? */ -PUBLIC BOOLEAN LYAcceptAllCookies = ACCEPT_ALL_COOKIES; /* take all cookies? */ -PUBLIC char *LYCookieAcceptDomains = NULL; /* domains to accept all cookies */ -PUBLIC char *LYCookieRejectDomains = NULL; /* domains to reject all cookies */ -#ifdef EXP_PERSISTENT_COOKIES -BOOLEAN persistent_cookies = TRUE; -PUBLIC char *LYCookieFile = NULL; /* default cookie file */ -#endif /* EXP_PERSISTENT_COOKIES */ PUBLIC char *XLoadImageCommand = NULL; /* Default image viewer for X */ PUBLIC BOOLEAN LYNoISMAPifUSEMAP = FALSE; /* Omit ISMAP link if MAP present? */ PUBLIC int LYHiddenLinks = HIDDENLINKS_SEPARATE; /* Show hidden links? */ @@ -353,6 +358,7 @@ PUBLIC BOOL New_DTD = YES; PUBLIC FILE *LYTraceLogFP = NULL; /* Pointer for TRACE log */ PUBLIC char *LYTraceLogPath = NULL; /* Path for TRACE log */ PUBLIC BOOLEAN LYUseTraceLog = USE_TRACE_LOG; /* Use a TRACE log? */ +PUBLIC FILE LYOrigStderr; /* Original stderr pointer */ PUBLIC BOOLEAN LYSeekFragMAPinCur = TRUE; PUBLIC BOOLEAN LYSeekFragAREAinCur = TRUE; @@ -364,13 +370,6 @@ PUBLIC BOOLEAN LYPrependBaseToSource = TRUE; PUBLIC BOOLEAN LYPrependCharsetToSource = FALSE; PUBLIC BOOLEAN LYQuitDefaultYes = QUIT_DEFAULT_YES; -#ifdef DISP_PARTIAL -PUBLIC BOOLEAN display_partial = TRUE; /* Display document during download */ -PUBLIC BOOLEAN debug_display_partial = FALSE; /* Show with MessageSecs delay */ -PUBLIC BOOLEAN detected_forms_input_partial = FALSE; /* trimHightext temp fix */ -PUBLIC int partial_threshold = -1; /* # of lines to be d/l'ed until we repaint */ -#endif - /* These are declared in cutil.h for current freeWAIS libraries. - FM */ #ifdef DECLARE_WAIS_LOGFILES PUBLIC char *log_file_name = NULL; /* for WAIS log file name in libWWW */ @@ -380,6 +379,7 @@ PUBLIC FILE *logfile = NULL; /* for WAIS log file output in libWWW */ extern int HTNewsChunkSize; /* Number of news articles per chunk (HTNews.c) */ extern int HTNewsMaxChunk; /* Max news articles before chunking (HTNews.c) */ +PRIVATE BOOLEAN anon_restrictions_set = FALSE; PRIVATE BOOLEAN stack_dump = FALSE; PRIVATE char *terminal = NULL; PRIVATE char *pgm; @@ -387,9 +387,7 @@ PRIVATE BOOLEAN number_links = FALSE; PRIVATE BOOLEAN LYPrependBase = FALSE; PRIVATE HTList *LYStdinArgs = NULL; -PRIVATE void parse_arg PARAMS((char **arg, int *i)); -PRIVATE void print_help_and_exit PARAMS((int exit_status)); - +PRIVATE void parse_arg PARAMS((char **arg, int *i, int argc)); #ifndef VMS PUBLIC BOOLEAN LYNoCore = NO_FORCED_CORE_DUMP; PRIVATE void FatalProblem PARAMS((int sig)); @@ -400,25 +398,9 @@ PRIVATE void FatalProblem PARAMS((int sig)); #endif #ifdef __DJGPP__ -PRIVATE int LY_set_ctrl_break(int setting) -{ - (void)signal(SIGINT, (setting ? SIG_DFL : SIG_IGN)); - setcbrk(setting); -} - -PRIVATE int LY_get_ctrl_break(void) -{ - typedef union REGS Regs; - extern Regs regs; - regs.h.ah = 0x33; - regs.h.al = 0x00; - int86(0x21, ®s, ®s); - return ((int) regs.h.dl); -} - -PRIVATE void reset_break(void) +void reset_break() { - LY_set_ctrl_break(init_ctrl_break[0]); + PDC_set_ctrl_break(init_ctrl_break[0]); } #endif /* __DJGPP__ */ @@ -434,7 +416,23 @@ PRIVATE void free_lynx_globals NOARGS #ifdef LYNXCGI_LINKS /* WebSter Mods -jkt */ FREE(LYCgiDocumentRoot); #endif /* LYNXCGI_LINKS */ - free_lynx_cfg(); + 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); #endif /* !VMS */ #ifdef VMS @@ -451,7 +449,7 @@ PRIVATE void free_lynx_globals NOARGS FREE(jumpfile); #endif /* JUMPFILE */ FREE(indexfile); - FREE(x_display); + FREE(display); FREE(global_type_map); FREE(personal_type_map); FREE(global_extension_map); @@ -490,6 +488,8 @@ PRIVATE void free_lynx_globals NOARGS FREE(lynx_lss_file); #endif FREE(UCAssume_MIMEcharset); + FREE(UCAssume_unrecMIMEcharset); + FREE(UCAssume_localMIMEcharset); for (i = 0; i < nlinks; i++) { FREE(links[i].lname); } @@ -517,23 +517,6 @@ PRIVATE void LYStdinArgs_free NOARGS return; } -PRIVATE void exit_immediately ARGS1( - int, code) -{ -#ifndef NOSIGHUP - (void) signal(SIGHUP, SIG_DFL); -#endif /* NOSIGHUP */ - (void) signal(SIGTERM, SIG_DFL); -#ifndef VMS - (void) signal(SIGINT, SIG_DFL); -#endif /* !VMS */ -#ifdef SIGTSTP - if (no_suspend) - (void) signal(SIGTSTP, SIG_DFL); -#endif /* SIGTSTP */ - exit(code); -} - /* * Wow! Someone wants to start up Lynx. */ @@ -543,6 +526,8 @@ PUBLIC int main ARGS2( { int i; /* indexing variable */ int status = 0; /* exit status */ + int len; + char *lynx_cfg_file = NULL; char *temp = NULL; char *cp; FILE *fp; @@ -568,27 +553,26 @@ PUBLIC int main ARGS2( #endif /* _WINDOWS */ #ifdef __DJGPP__ - if (LY_get_ctrl_break() == 0) { - LY_set_ctrl_break(TRUE); - init_ctrl_break[0] = 0; - } else { - init_ctrl_break[0] = 1; - } +if (PDC_get_ctrl_break() == 0) { + PDC_set_ctrl_break(TRUE); + init_ctrl_break[0] = 0;} +else {init_ctrl_break[0] = 1;} atexit(reset_break); sock_init(); #endif - /* - * To prevent corrupting binary data on DOS, MS-WINDOWS or OS/2 - * we open files and stdout in BINARY mode by default. - * Where necessary we should open and (close!) TEXT mode. - * (use LYNewTxtFile/LYAppendToTxtFile to open text files for writing) - */ - SetDefaultMode(O_BINARY); - SetOutputMode(O_BINARY); +#if defined(_WINDOWS) || defined(DJGPP) + /* + * 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. + */ + _fmode = O_BINARY; + setmode( fileno( stdout ), O_BINARY ); +#endif #ifdef DOSPATH - if (getenv("TERM")==NULL) putenv("TERM=vt100"); + terminal = "vt100"; #endif LYShowColor = (SHOW_COLOR ? SHOW_COLOR_ON : SHOW_COLOR_OFF); @@ -605,7 +589,7 @@ PUBLIC int main ARGS2( */ for (i = 1; i < argc; i++) { if (strncmp(argv[i], "-help", 5) == 0) { - parse_arg(&argv[i], &i); + parse_arg(&argv[i], &i, argc); } } @@ -697,34 +681,36 @@ PUBLIC int main ARGS2( StrAllocCat(lynx_version_putenv_command, LYNX_VERSION); putenv(lynx_version_putenv_command); #endif /* VMS */ - if ((cp = getenv("LYNX_TEMP_SPACE")) != NULL) StrAllocCopy(lynx_temp_space, cp); -#if defined (UNIX) - else if ((cp = getenv("TMPDIR")) != NULL) + else +#ifdef DOSPATH + if ((cp = getenv("TEMP")) != NULL) StrAllocCopy(lynx_temp_space, cp); -#endif -#if defined (DOSPATH) || defined (__EMX__) - else if ((cp = getenv("TEMP")) != NULL) - StrAllocCopy(lynx_temp_space, HTDOS_name(cp)); else if ((cp = getenv("TMP")) != NULL) - StrAllocCopy(lynx_temp_space, HTDOS_name(cp)); -#endif + StrAllocCopy(lynx_temp_space, cp); else -#ifdef TEMP_SPACE - StrAllocCopy(lynx_temp_space, TEMP_SPACE); + { + printf("You MUST define a valid TMP or TEMP area!\n"); + exit(-1); + } #else - { - printf("You MUST define a valid TMP or TEMP area!\n"); - exit(-1); - } + StrAllocCopy(lynx_temp_space, TEMP_SPACE); #endif - if ((cp = strchr(lynx_temp_space, '~'))) { *(cp++) = '\0'; StrAllocCopy(temp, lynx_temp_space); - LYTrimPathSep(temp); - StrAllocCat(temp, wwwName(Home_Dir())); + if (((len = strlen(temp)) > 0) && temp[len-1] == '/') + temp[len-1] = '\0'; +#ifdef DOSPATH + StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir())); +#else +#ifdef VMS + StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir())); +#else + StrAllocCat(temp, Home_Dir()); +#endif /* VMS */ +#endif /* DOSPATH */ StrAllocCat(temp, cp); StrAllocCopy(lynx_temp_space, temp); FREE(temp); @@ -744,12 +730,14 @@ PUBLIC int main ARGS2( } } #ifdef VMS - LYLowerCase(lynx_temp_space); + for (i = 0; lynx_temp_space[i]; i++) + lynx_temp_space[i] = TOLOWER(lynx_temp_space[i]); if (strchr(lynx_temp_space, '/') != NULL) { - if (strlen(lynx_temp_space) == 1) { + if ((len = strlen(lynx_temp_space)) == 1) { StrAllocCopy(lynx_temp_space, "sys$scratch:"); } else { - LYAddPathSep(&lynx_temp_space); + if (lynx_temp_space[len-1] != '/') + StrAllocCat(lynx_temp_space, "/"); StrAllocCopy(temp, HTVMS_name("", lynx_temp_space)); StrAllocCopy(lynx_temp_space, temp); FREE(temp); @@ -760,7 +748,17 @@ PUBLIC int main ARGS2( StrAllocCat(lynx_temp_space, ":"); } #else - LYAddPathSep(&lynx_temp_space); +#if !defined(__DJGPP__) && !defined(_WINDOWS) + if (((len = strlen(lynx_temp_space)) > 1) && + lynx_temp_space[len-1] != '/') { + StrAllocCat(lynx_temp_space, "/"); + } +#else + if (((len = strlen(lynx_temp_space)) > 1) && + lynx_temp_space[len-1] != '\\') { + StrAllocCat(lynx_temp_space, "\\"); + } +#endif /* !__DJGPP__ && !_WINDOWS */ #endif /* VMS */ #ifdef VMS StrAllocCopy(mail_adrs, MAIL_ADRS); @@ -777,6 +775,19 @@ PUBLIC int main ARGS2( StrAllocCopy(URLDomainPrefixes, URL_DOMAIN_PREFIXES); StrAllocCopy(URLDomainSuffixes, URL_DOMAIN_SUFFIXES); StrAllocCopy(XLoadImageCommand, XLOADIMAGE_COMMAND); + /* + * Set up the compilation default character set. - FM + */ + for (i = 0; LYchar_set_names[i]; i++) { + if (!strncmp(CHARACTER_SET, LYchar_set_names[i], + strlen(CHARACTER_SET))) { + current_char_set=i; + break; + } + } + if (!LYchar_set_names[i]) + current_char_set = i = 0; + HTMLSetRawModeDefault(i); /* * Disable news posting if the compilation-based @@ -805,7 +816,7 @@ PUBLIC int main ARGS2( } else if (strncmp(argv[i], "-anonymous", 10) == 0) { if (!LYValidate) parse_restrictions("default"); - LYRestricted = TRUE; + anon_restrictions_set = TRUE; } else if (strcmp(argv[i], "-validate") == 0) { /* * Follow only http URLs. @@ -831,7 +842,8 @@ PUBLIC int main ARGS2( StrAllocCopy(lynx_lss_file, argv[i+1]); i++; } - CTRACE(tfp, "LYMain found -lss flag, lss file is %s\n", + if (TRACE) + fprintf(stderr, "LYMain found -lss flag, lss file is %s\n", lynx_lss_file ? lynx_lss_file : "<NONE>"); #endif } @@ -877,9 +889,9 @@ PUBLIC int main ARGS2( LYUseTraceLog = TRUE; } } else if (strncmp(buf, "-anonymous", 10) == 0) { - if (!LYValidate && !LYRestricted) + if (!LYValidate && !anon_restrictions_set) parse_restrictions("default"); - LYRestricted = TRUE; + anon_restrictions_set = TRUE; } else if (strcmp(buf, "-validate") == 0) { /* * Follow only http URLs. @@ -893,8 +905,11 @@ PUBLIC int main ARGS2( if ((cp = strchr(buf,'=')) != NULL) { StrAllocCopy(lynx_cfg_file, cp+1); } else { - cp = LYSkipNonBlanks(buf); - cp = LYSkipBlanks(cp); + cp = buf; + while (*cp && !isspace((unsigned char)*cp)) + cp++; + while (*cp && isspace((unsigned char)*cp)) + cp++; if (*cp) StrAllocCopy(lynx_cfg_file, cp); } @@ -903,12 +918,16 @@ PUBLIC int main ARGS2( if ((cp = strchr(buf,'=')) != NULL) { StrAllocCopy(lynx_lss_file, cp+1); } else { - cp = LYSkipNonBlanks(buf); - cp = LYSkipBlanks(cp); + cp = buf; + while (*cp && !isspace((unsigned char)*cp)) + cp++; + while (*cp && isspace((unsigned char)*cp)) + cp++; if (*cp) - StrAllocCopy(lynx_lss_file, cp); + StrAllocCopy(lynx_cfg_file, cp); } - CTRACE(tfp, "LYMain found -lss flag, lss file is %s\n", + if (TRACE) + fprintf(stderr, "LYMain found -lss flag, lss file is %s\n", lynx_lss_file ? lynx_lss_file : "<NONE>"); #endif } else if (strcmp(buf, "-get_data") == 0) { @@ -1021,29 +1040,33 @@ PUBLIC int main ARGS2( * set the default restrictions for that account and disallow * a TRACE log NOW. - FM */ - if (!LYValidate && !LYRestricted && + if (!LYValidate && !anon_restrictions_set && strlen((char *)ANONYMOUS_USER) > 0 && #if defined (VMS) || defined (NOUSERS) !strcasecomp(((char *)getenv("USER")==NULL ? " " : getenv("USER")), - ANONYMOUS_USER)) + ANONYMOUS_USER)) { #else #if HAVE_CUSERID - STREQ((char *)cuserid((char *) NULL), ANONYMOUS_USER)) + STREQ((char *)cuserid((char *) NULL), ANONYMOUS_USER)) { #else - STREQ(((char *)getlogin()==NULL ? " " : getlogin()), ANONYMOUS_USER)) + STREQ(((char *)getlogin()==NULL ? " " : getlogin()), ANONYMOUS_USER)) { #endif /* HAVE_CUSERID */ #endif /* VMS */ - { parse_restrictions("default"); - LYRestricted = TRUE; + anon_restrictions_set = TRUE; LYUseTraceLog = FALSE; } /* * Set up the TRACE log path, and logging if appropriate. - FM */ - LYAddPathToHome(LYTraceLogPath = malloc(LY_MAXPATH), LY_MAXPATH, "Lynx.trace"); - +#ifdef VMS + StrAllocCopy(LYTraceLogPath, "sys$login:Lynx.trace"); +#else + StrAllocCopy(LYTraceLogPath, (Home_Dir() ? Home_Dir() : "")); + StrAllocCat(LYTraceLogPath, "/Lynx.trace"); +#endif /* VMS */ + LYOrigStderr = *stderr; if (TRACE && LYUseTraceLog) { /* * If we can't open it for writing, give up. @@ -1057,8 +1080,9 @@ PUBLIC int main ARGS2( exit(-1); } #ifdef VMS - LYCloseTracelog(); - HTSYS_remove(LYTraceLogPath); + fclose(LYTraceLogFP); + while (remove(LYTraceLogPath) == 0) + ; if ((LYTraceLogFP = LYNewTxtFile(LYTraceLogPath)) == NULL) { WWW_TraceFlag = FALSE; printf("%s\n", TRACELOG_OPEN_FAILED); @@ -1067,15 +1091,16 @@ PUBLIC int main ARGS2( #endif /* VMS */ fflush(stdout); fflush(stderr); - fprintf(tfp, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); + *stderr = *LYTraceLogFP; + fprintf(stderr, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); } /* * If TRACE is on, indicate whether the * anonymous restrictions are set. - FM */ - if (LYRestricted) { - CTRACE(tfp, "LYMain: Anonymous restrictions set.\n"); + if (TRACE && anon_restrictions_set) { + fprintf(stderr, "LYMain: Anonymous restrictions set.\n"); } /* @@ -1091,7 +1116,8 @@ PUBLIC int main ARGS2( } else { sprintf(temp, "JUMPFILE:%s", jumpfile); if (!LYJumpInit(temp)) { - CTRACE(tfp, "Failed to register %s\n", temp); + if (TRACE) + fprintf(stderr, "Failed to register %s\n", temp); } FREE(temp); } @@ -1120,7 +1146,7 @@ PUBLIC int main ARGS2( */ #ifndef _WINDOWS /* avoid the whole ~ thing for now */ /* I think this should only be performed if lynx_cfg_file starts with ~/ */ - if ((lynx_cfg_file[0] == '~') && LYIsPathSep(lynx_cfg_file[1])) + if ((lynx_cfg_file[0] == '~') && (lynx_cfg_file[1] == '/')) { #ifdef VMS StrAllocCopy(temp, HTVMS_wwwName((char *)Home_Dir())); @@ -1144,11 +1170,6 @@ PUBLIC int main ARGS2( } fclose(fp); -#if defined(USE_KEYMAPS) && defined(USE_SLANG) - if (-1 == lynx_initialize_keymaps ()) - exit (-1); -#endif - /* * Make sure we have the character sets declared. * This will initialize the CHARTRANS handling. - KW @@ -1157,22 +1178,6 @@ PUBLIC int main ARGS2( fprintf(stderr, "\nLynx character sets not declared.\n\n"); exit(-1); } - /* - * (**) in Lynx, UCLYhndl_HTFile_for_unspec and UCLYhndl_for_unrec may be - * valid or not, but current_char_set and UCLYhndl_for_unspec SHOULD - * ALWAYS be a valid charset. Initialized here and may be changed later - * from lynx.cfg/command_line/options_menu. - LP (**) - */ - /* - * Set up the compilation default character set. - FM - */ - current_char_set = safeUCGetLYhndl_byMIME(CHARACTER_SET); - /* - * Set up HTTP default for unlabeled charset (iso-8859-1). - */ - UCLYhndl_for_unspec = LATIN1; - StrAllocCopy(UCAssume_MIMEcharset, - LYCharSet_UC[UCLYhndl_for_unspec].MIMEname); #if defined(USE_HASH) /* @@ -1198,7 +1203,8 @@ PUBLIC int main ARGS2( if ((cp = strchr(lynx_lss_file, '~'))) { *(cp++) = '\0'; StrAllocCopy(temp, lynx_lss_file); - LYTrimPathSep(temp); + if ((len=strlen(temp)) > 0 && temp[len-1] == '/') + temp[len-1] = '\0'; #ifdef VMS StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir())); #else @@ -1213,7 +1219,7 @@ PUBLIC int main ARGS2( * inform the user and exit. */ if ((fp = fopen(lynx_lss_file, "r")) == NULL) { - fprintf(stderr, "\nLynx file %s is not available.\n\n", + fprintf(stderr, "\nLynxile file %s is not available.\n\n", lynx_lss_file); } else @@ -1246,15 +1252,19 @@ PUBLIC int main ARGS2( StrAllocCopy(LynxSigFile, filename); LYAddPathToHome(filename, sizeof(filename), LynxSigFile); StrAllocCopy(LynxSigFile, filename); - CTRACE(tfp, "LYNX_SIG_FILE set to '%s'\n", LynxSigFile); + if (TRACE) + fprintf(stderr, "LYNX_SIG_FILE set to '%s'\n", LynxSigFile); } else { - CTRACE(tfp, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n", LYNX_SIG_FILE); + if (TRACE) + fprintf(stderr, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n", + LYNX_SIG_FILE); } /* * Process the configuration file. */ - read_cfg(lynx_cfg_file, "main program", 1, (FILE *)0); + read_cfg(lynx_cfg_file, "main program", 1); + FREE(lynx_cfg_file); HTSwitchDTD(New_DTD); @@ -1276,19 +1286,30 @@ PUBLIC int main ARGS2( if ((cp = strchr(lynx_save_space, '~')) != NULL) { *(cp++) = '\0'; StrAllocCopy(temp, lynx_save_space); - LYTrimPathSep(temp); - StrAllocCat(temp, wwwName(Home_Dir())); + if (((len = strlen(temp)) > 0) && temp[len-1] == '/') + temp[len-1] = '\0'; +#ifdef DOSPATH + StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir())); +#else +#ifdef VMS + StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir())); +#else + StrAllocCat(temp, Home_Dir()); +#endif /* VMS */ +#endif /* DOSPATH */ StrAllocCat(temp, cp); StrAllocCopy(lynx_save_space, temp); FREE(temp); } #ifdef VMS - LYLowerCase(lynx_save_space); + for (i = 0; lynx_save_space[i]; i++) + lynx_save_space[i] = TOLOWER(lynx_save_space[i]); if (strchr(lynx_save_space, '/') != NULL) { - if (strlen(lynx_save_space) == 1) { + if ((len = strlen(lynx_save_space)) == 1) { StrAllocCopy(lynx_save_space, "sys$login:"); } else { - LYAddPathSep(&lynx_save_space); + if (lynx_save_space[len-1] != '/') + StrAllocCat(lynx_save_space, "/"); StrAllocCopy(temp, HTVMS_name("", lynx_save_space)); StrAllocCopy(lynx_save_space, temp); FREE(temp); @@ -1299,7 +1320,12 @@ PUBLIC int main ARGS2( StrAllocCat(lynx_save_space, ":"); } #else - LYAddPathSep(&lynx_save_space); + { + if (((len = strlen(lynx_save_space)) > 1) && + lynx_save_space[len-1] != '/') { + StrAllocCat(lynx_save_space, "/"); + } + } #endif /* VMS */ } @@ -1346,7 +1372,7 @@ PUBLIC int main ARGS2( * Process any command line arguments not already handled. - FM */ for (i = 1; i < argc; i++) { - parse_arg(&argv[i], &i); + parse_arg(&argv[i], &i, argc); } /* @@ -1359,7 +1385,7 @@ PUBLIC int main ARGS2( my_args[1] = NULL; while (NULL != (my_args[0] = (char *)HTList_nextObject(cur))) { - parse_arg(my_args, (int *)0); + parse_arg(my_args, NULL, -1); } LYStdinArgs_free(); } @@ -1501,75 +1527,6 @@ 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 - */ - if (persistent_cookies) { - if(LYCookieFile == NULL) { - LYAddPathToHome(LYCookieFile = malloc(LY_MAXPATH), LY_MAXPATH, COOKIE_FILE); - } else { - if ((cp = strchr(LYCookieFile, '~'))) { - temp = NULL; - *(cp++) = '\0'; - StrAllocCopy(temp, cp); - LYTrimPathSep(temp); - StrAllocCopy(LYCookieFile, wwwName(Home_Dir())); - StrAllocCat(LYCookieFile, temp); - FREE(temp); - } - } - LYLoadCookies(LYCookieFile); - } -#endif - -#ifdef SIGTSTP - /* - * Block Control-Z suspending if requested. - FM - */ - if (no_suspend) - (void) signal(SIGTSTP,SIG_IGN); -#endif /* SIGTSTP */ - - /* - * Check for a valid HEAD request. - FM - */ - if (HEAD_request && LYCanDoHEAD(startfile) != TRUE) { - fprintf(stderr, - "The '-head' switch is for http HEAD requests and cannot be used for\n'%s'.\n", - startfile); - exit_immediately(-1); - } - - /* - * Check for a valid MIME headers request. - FM - */ - if (keep_mime_headers && LYCanDoHEAD(startfile) != TRUE) { - fprintf(stderr, - "The '-mime_header' switch is for http URLs and cannot be used for\n'%s'.\n", - startfile); - exit_immediately(-1); - } - - /* - * Check for a valid traversal request. - FM - */ - if (traversal && strncmp(startfile, "http", 4)) { - fprintf(stderr, - "The '-traversal' switch is for http URLs and cannot be used for\n'%s'.\n", - startfile); - exit_immediately(-1); - } - - /* - * Finish setting up for an INTERACTIVE session. - * Done here so that URL guessing in LYEnsureAbsoluteURL() can be - * interruptible (terminal is in raw mode, select() works). -BL - */ - if (!dump_output_immediately) { - setup(terminal); - } /* * If startfile is a file URL and the host is defaulted, * force in "//localhost", and if it's not an absolute URL, @@ -1609,27 +1566,105 @@ PUBLIC int main ARGS2( ftp_ok = !no_inside_ftp && !no_outside_ftp && ftp_ok; rlogin_ok = !no_inside_rlogin && !no_outside_rlogin && rlogin_ok; #else - CTRACE(tfp,"LYMain.c: User in Local domain\n"); + if (TRACE) + fprintf(stderr,"LYMain.c: User in Local domain\n"); telnet_ok = !no_inside_telnet && telnet_ok; news_ok = !no_inside_news && news_ok; ftp_ok = !no_inside_ftp && ftp_ok; rlogin_ok = !no_inside_rlogin && rlogin_ok; #endif /* !HAVE_UTMP || VMS */ } else { - CTRACE(tfp,"LYMain.c: User in REMOTE domain\n"); + if (TRACE) + fprintf(stderr,"LYMain.c: User in REMOTE domain\n"); telnet_ok = !no_outside_telnet && telnet_ok; news_ok = !no_outside_news && news_ok; ftp_ok = !no_outside_ftp && ftp_ok; rlogin_ok = !no_outside_rlogin && rlogin_ok; } +#ifdef SIGTSTP + /* + * Block Control-Z suspending if requested. - FM + */ + if (no_suspend) + (void) signal(SIGTSTP,SIG_IGN); +#endif /* SIGTSTP */ + + /* + * Check for a valid HEAD request. - FM + */ + if (HEAD_request && LYCanDoHEAD(startfile) != TRUE) { + fprintf(stderr, + "The '-head' switch is for http HEAD requests and cannot be used for\n'%s'.\n", + startfile); +#ifndef NOSIGHUP + (void) signal(SIGHUP, SIG_DFL); +#endif /* NOSIGHUP */ + (void) signal(SIGTERM, SIG_DFL); +#ifndef VMS + (void) signal(SIGINT, SIG_DFL); +#endif /* !VMS */ +#ifdef SIGTSTP + if (no_suspend) + (void) signal(SIGTSTP,SIG_DFL); +#endif /* SIGTSTP */ + exit(-1); + } + + /* + * Check for a valid MIME headers request. - FM + */ + if (keep_mime_headers && LYCanDoHEAD(startfile) != TRUE) { + fprintf(stderr, + "The '-mime_header' switch is for http URLs and cannot be used for\n'%s'.\n", + startfile); +#ifndef NOSIGHUP + (void) signal(SIGHUP, SIG_DFL); +#endif /* NOSIGHUP */ + (void) signal(SIGTERM, SIG_DFL); +#ifndef VMS + (void) signal(SIGINT, SIG_DFL); +#endif /* !VMS */ +#ifdef SIGTSTP + if (no_suspend) + (void) signal(SIGTSTP,SIG_DFL); +#endif /* SIGTSTP */ + exit(-1); + } + + /* + * Check for a valid traversal request. - FM + */ + if (traversal && strncmp(startfile, "http", 4)) { + fprintf(stderr, + "The '-traversal' switch is for http URLs and cannot be used for\n'%s'.\n", + startfile); +#ifndef NOSIGHUP + (void) signal(SIGHUP, SIG_DFL); +#endif /* NOSIGHUP */ + (void) signal(SIGTERM, SIG_DFL); +#ifndef VMS + (void) signal(SIGINT, SIG_DFL); +#endif /* !VMS */ +#ifdef SIGTSTP + if (no_suspend) + (void) signal(SIGTSTP,SIG_DFL); +#endif /* SIGTSTP */ + exit(-1); + } + /* * Set up our help and about file base paths. - FM */ StrAllocCopy(helpfilepath, helpfile); - if ((cp = LYPathLeaf(helpfilepath)) != helpfilepath) - *cp = '\0'; - LYAddHtmlSep(&helpfilepath); + if ((cp=strrchr(helpfilepath, '/')) != NULL) + *cp = '\0'; + /* + * Remove code to merge the historical about_lynx + * directory into lynx_help. - HN + */ + StrAllocCat(helpfilepath, "/"); + /* * Make sure our bookmark default strings @@ -1663,7 +1698,7 @@ PUBLIC int main ARGS2( keypad_mode = LINKS_ARE_NUMBERED; } } - if (x_display != NULL && *x_display != '\0') { + if (display != NULL && *display != '\0') { LYisConfiguredForX = TRUE; } if (dump_output_width > 0) { @@ -1674,21 +1709,33 @@ PUBLIC int main ARGS2( (keypad_mode == LINKS_ARE_NUMBERED || keypad_mode == LINKS_AND_FORM_FIELDS_ARE_NUMBERED)) printlist(stdout,FALSE); - exit_immediately(status); +#ifndef NOSIGHUP + (void) signal(SIGHUP, SIG_DFL); +#endif /* NOSIGHUP */ + (void) signal(SIGTERM, SIG_DFL); +#ifndef VMS + (void) signal(SIGINT, SIG_DFL); +#endif /* !VMS */ +#ifdef SIGTSTP + if (no_suspend) + (void) signal(SIGTSTP,SIG_DFL); +#endif /* SIGTSTP */ } else { /* - * Start an INTERACTIVE session. - FM + * Finish setting up and start an + * INTERACTIVE session. - FM */ - if (x_display != NULL && *x_display != '\0') { - LYisConfiguredForX = TRUE; + if (setup(terminal)) { + if (display != NULL && *display != '\0') { + LYisConfiguredForX = TRUE; + } + ena_csi((LYlowest_eightbit[current_char_set] > 155)); + status = mainloop(); + cleanup(); } - ena_csi((LYlowest_eightbit[current_char_set] > 155)); - status = mainloop(); - cleanup(); - exit(status); } - return(status); /* though redundant, for compiler-warnings */ + exit(status); } /* @@ -1716,579 +1763,682 @@ PUBLIC void LYRegisterLynxProtocols NOARGS HTRegisterProtocol(&LYLynxCookies); } -/* There are different ways of setting arguments on the command line, and - * there are different types of arguments. These include: - * - * -set_some_variable ==> some_variable = TRUE - * -toggle_some_variable ==> some_variable = !some_variable - * -some_variable=value ==> some_variable = value - * - * Others are complicated and require a function call. - */ - -struct parse_args_type; -typedef int (*ParseFunc) PARAMS((struct parse_args_type *, char **, char *)); - -typedef union { - BOOLEAN * set_value; - int * int_value; - char ** str_value; - ParseFunc fun_value; -} ParseUnion; - -#undef PARSE_DEBUG - /* - * Storing the four types of data in separate fields costs about 1K of data. - * However, this provides usable type-checking. The initial version of the - * parse_args_type used 'long' for all types, and dumped core when processing - * "lynx -help". (The compiler was unable to detect some minor errors). + * Parse one argument, optionally picking up the next entry in argv (if + * appropriate). */ -#ifdef PARSE_DEBUG -#define ParseData BOOLEAN *set_value; int *int_value; char **str_value; ParseFunc fun_value -#define PARSE_SET(n,t,v,h) {n,t, v, 0, 0, 0, h} -#define PARSE_INT(n,t,v,h) {n,t, 0, &v, 0, 0, h} -#define PARSE_STR(n,t,v,h) {n,t, 0, 0, v, 0, h} -#define PARSE_FUN(n,t,v,h) {n,t, 0, 0, 0, v, h} -#else -#define ParseData long value -#define PARSE_SET(n,t,v,h) {n,t, (long) (v), h} -#define PARSE_INT(n,t,v,h) {n,t, (long)&(v), h} -#define PARSE_STR(n,t,v,h) {n,t, (long) (v), h} -#define PARSE_FUN(n,t,v,h) {n,t, (long) (v), h} -#endif -typedef struct parse_args_type +PRIVATE char * scan3D ARGS2( + char **, argv, + int *, i) { - CONST char *name; - int type; -#define IGNORE_ARG 0x000 -#define TOGGLE_ARG 0x001 -#define SET_ARG 0x002 -#define UNSET_ARG 0x003 -#define FUNCTION_ARG 0x004 -#define LYSTRING_ARG 0x005 -#define INT_ARG 0x006 -#define STRING_ARG 0x007 -#define ARG_TYPE_MASK 0x0FF -#define NEED_NEXT_ARG 0x100 - -#define NEED_INT_ARG (NEED_NEXT_ARG | INT_ARG) -#define NEED_LYSTRING_ARG (NEED_NEXT_ARG | LYSTRING_ARG) -#define NEED_STRING_ARG (NEED_NEXT_ARG | STRING_ARG) -#define NEED_FUNCTION_ARG (NEED_NEXT_ARG | FUNCTION_ARG) - - /* If the NEED_NEXT_ARG flags is set, and the option was not specified - * with an '=' character, then use the next argument in the argv list. - */ - - ParseData; - CONST char *help_string; + char *result; + + if ((result=strchr(argv[0],'=')) != NULL) + return result+1; + if (argv[1] && i) + (*i)++; /* Let master know we've stolen an argument */ + return argv[1]; } -Parse_Args_Type; -/* -auth, -pauth */ -static int parse_authentication ARGS2( - char *, next_arg, - char **, result) +PRIVATE void parse_arg ARGS3( + char **, argv, + int *, i, + int, argc) { + char *cp; +#ifndef VMS + static char display_putenv_command[142]; +#endif /* !VMS */ +#define nextarg ((cp=scan3D(&argv[0], i))!=NULL) + /* - * Authentication information for protected documents. + * Check for a command line startfile. - FM */ - char *auth_info = 0; + if (argv[0][0] != '-') { + StrAllocCopy(startfile, argv[0]); + LYTrimHead(startfile); + if (!strncasecomp(startfile, "lynxexec:", 9) || + !strncasecomp(startfile, "lynxprog:", 9)) { + /* + * The original implementations of these schemes expected + * white space without hex escaping, and did not check + * for hex escaping, so we'll continue to support that, + * until that code is redone in conformance with SGML + * principles. - FM + */ + HTUnEscapeSome(startfile, " \r\n\t"); + convert_to_spaces(startfile, TRUE); + } + return; + } - if (next_arg != 0) { - StrAllocCopy(auth_info, next_arg); - memset(next_arg, ' ', strlen(next_arg)); /* Let's not show too much */ + /* + * Skip any lone "-" arguments, because we've loaded + * the stdin input into an HTList structure for + * special handling. - FM + */ + if (strcmp(argv[0], "-") == 0) { + return; } - if (auth_info != 0) { - char *cp; + switch (TOLOWER(argv[0][1])) { + + case 'a': + if (strncmp(argv[0], "-anonymous", 10) == 0) { + /* + * Should already have been set, so we don't + * override or replace any additional + * restrictions from the command line. - FM + */ + if (!anon_restrictions_set) + parse_restrictions("default"); + anon_restrictions_set = TRUE; + + } else if ((strncmp(argv[0], "-assume_charset", 15) == 0) || + (strncmp(argv[0], "-assume_local_charset", 21) == 0) || + (strncmp(argv[0], "-assume_unrec_charset", 21) == 0)) { + BOOL local_flag = (argv[0][8] == 'l'); + BOOL unrec_flag = (argv[0][8] == 'u'); + + if (nextarg) { + int j; - if ((cp = strchr(auth_info, ':')) != 0) { /* Pw */ - *cp++ = '\0'; /* Terminate ID */ - HTUnEscape(cp); - StrAllocCopy(result[1], cp); + for (j = 0; cp[j]; j++) + cp[j] = TOLOWER(cp[j]); + if (local_flag) { + StrAllocCopy(UCAssume_localMIMEcharset, cp); + if (UCAssume_localMIMEcharset && *UCAssume_localMIMEcharset) + UCLYhndl_HTFile_for_unspec = + UCGetLYhndl_byMIME(UCAssume_localMIMEcharset); + } else if (unrec_flag) { + StrAllocCopy(UCAssume_unrecMIMEcharset, cp); + if (UCAssume_unrecMIMEcharset && *UCAssume_unrecMIMEcharset) + UCLYhndl_for_unrec = + UCGetLYhndl_byMIME(UCAssume_unrecMIMEcharset); + } else { + StrAllocCopy(UCAssume_MIMEcharset, cp); + if (UCAssume_MIMEcharset && *UCAssume_MIMEcharset) + UCLYhndl_for_unspec = + UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + } + } else { + if (local_flag) + UCLYhndl_HTFile_for_unspec = 0; + else if (unrec_flag) + UCLYhndl_for_unrec = 0; + else + UCLYhndl_for_unspec = 0; } - if (*auth_info) { /* Id */ - HTUnEscape(auth_info); - StrAllocCopy(result[0], auth_info); + + } else if (strncmp(argv[0], "-auth", 5) == 0) { + /* + * Authentication information for protected documents. + */ + char *auth_info = NULL; + + if (nextarg) { + StrAllocCopy(auth_info, cp); + memset(cp, ' ', strlen(cp)); /* Let's not show too much */ } - FREE(auth_info); + if (auth_info != NULL) { + if ((cp = strchr(auth_info, ':')) != NULL) { /* Pw */ + *cp++ = '\0'; /* Terminate ID */ + if (*cp) { + HTUnEscape(cp); + StrAllocCopy(authentication_info[1], cp); + } + } + if (*auth_info) { /* Id */ + HTUnEscape(auth_info); + StrAllocCopy(authentication_info[0], auth_info); + } + FREE(auth_info); + } + + } else { + goto Output_Error_and_Help_List; } - return 0; -} + break; -/* -anonymous */ -static int anonymous_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - /* - * Should already have been set, so we don't - * override or replace any additional - * restrictions from the command line. - FM - */ - if (!LYRestricted) - parse_restrictions("default"); - LYRestricted = TRUE; - return 0; -} + case 'b': + if (strcmp(argv[0], "-base") == 0) { + /* + * Treat -source equivalently to an interactive + * download with LYPrefixBaseToSource configured + * to TRUE, so that a BASE tag is prepended for + * text/html content types. We normally treat + * the module-wide global LYPrefixBaseToSource + * flag as FALSE with -source, but force it TRUE, + * later, if LYPrependBase is set TRUE here. - FM + */ + LYPrependBase = TRUE; + if (HTOutputFormat == HTAtom_for("www/dump")) { + HTOutputFormat = HTAtom_for("www/download"); + } -/* -assume_charset */ -static int assume_charset_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(next_arg); - StrAllocCopy(UCAssume_MIMEcharset, - LYCharSet_UC[UCLYhndl_for_unspec].MIMEname); -/* this may be a memory for bogus typo - - StrAllocCopy(UCAssume_MIMEcharset, next_arg); - LYLowerCase(UCAssume_MIMEcharset); */ - - return 0; -} + } else if (strcmp(argv[0], "-book") == 0) { + /* + * Use bookmarks as startfile. + */ + bookmark_start = TRUE; -/* -assume_local_charset */ -static int assume_local_charset_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - UCLYhndl_HTFile_for_unspec = safeUCGetLYhndl_byMIME(next_arg); - return 0; -} + } else if (strcmp(argv[0], "-buried_news") == 0) { + /* + * Toggle scans for buried news references. + */ + if (scan_for_buried_news_references) + scan_for_buried_news_references = FALSE; + else + scan_for_buried_news_references = TRUE; -/* -assume_unrec_charset */ -static int assume_unrec_charset_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - UCLYhndl_for_unrec = safeUCGetLYhndl_byMIME(next_arg); - return 0; -} +#ifdef USE_SLANG + } else if (strncmp(argv[0], "-blink", 6) == 0) { + Lynx_Color_Flags |= SL_LYNX_USE_BLINK; +#endif /* USE_SLANG */ -/* -auth */ -static int auth_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - parse_authentication(next_arg, authentication_info); - return 0; -} + } else { + goto Output_Error_and_Help_List; + } + break; -/* -base */ -static int base_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - /* - * Treat -source equivalently to an interactive download with - * LYPrefixBaseToSource configured to TRUE, so that a BASE tag is - * prepended for text/html content types. We normally treat the - * module-wide global LYPrefixBaseToSource flag as FALSE with - * -source, but force it TRUE, later, if LYPrependBase is set - * TRUE here. - FM - */ - LYPrependBase = TRUE; - if (HTOutputFormat == HTAtom_for("www/dump")) - HTOutputFormat = HTAtom_for("www/download"); + case 'c': + if (strncmp(argv[0], "-cache", 6) == 0) { + if (nextarg) + HTCacheSize = atoi(cp); + /* + * Limit size. + */ + if (HTCacheSize < 2) HTCacheSize = 2; - return 0; -} + } else if (strncmp(argv[0], "-case", 5) == 0) { + case_sensitive = TRUE; -#ifdef USE_SLANG -/* -blink */ -static int blink_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - Lynx_Color_Flags |= SL_LYNX_USE_BLINK; - return 0; -} -#endif + } else if (strncmp(argv[0], "-cfg", 4) == 0) { + /* + * Already read the alternate configuration file + * so just check whether we need to increment i + */ + if (nextarg) + ; /* do nothing */ -/* -cache */ -static int cache_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg != 0) - HTCacheSize = atoi(next_arg); - /* - * Limit size. - */ - if (HTCacheSize < 2) HTCacheSize = 2; + } else if (strncmp(argv[0], "-child", 6) == 0) { + child_lynx = TRUE; + no_disk_save = TRUE; - return 0; -} +#ifdef USE_SLANG + } else if (strncmp(argv[0], "-color", 6) == 0) { + Lynx_Color_Flags |= SL_LYNX_USE_COLOR; + if (LYShowColor != SHOW_COLOR_ALWAYS) { + LYShowColor = SHOW_COLOR_ON; + } +#endif /* USE_SLANG */ -/* -child */ -static int child_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - child_lynx = TRUE; - no_disk_save = TRUE; - return 0; -} + } else if (strncmp(argv[0], "-crawl", 6) == 0) { + crawl = TRUE; + LYcols = 80; -#ifdef USE_SLANG -/* -color */ -static int color_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - Lynx_Color_Flags |= SL_LYNX_USE_COLOR; + } else if (strncmp(argv[0], "-cookies", 8) == 0) { + if (LYSetCookies) + LYSetCookies = FALSE; + else + LYSetCookies = TRUE; - if (LYShowColor != SHOW_COLOR_ALWAYS) - LYShowColor = SHOW_COLOR_ON; +#ifndef VMS + } else if (strncmp(argv[0], "-core", 5) == 0) { + if (LYNoCore) + LYNoCore = FALSE; + else + LYNoCore = TRUE; +#endif /* !VMS */ - return 0; -} -#endif + } else { + goto Output_Error_and_Help_List; + } + break; -/* -crawl */ -static int crawl_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - crawl = TRUE; - LYcols = 80; - return 0; -} + case 'd': + if (strncmp(argv[0], "-display", 8) == 0) { + if (nextarg) { +#ifdef VMS + int j; + for (j = 0; cp[j]; j++) + cp[j] = TOUPPER(cp[j]); + Define_VMSLogical(DISPLAY, cp ? cp : ""); +#else + sprintf(display_putenv_command, "DISPLAY=%s", cp ? cp : ""); + putenv(display_putenv_command); +#endif /* VMS */ + if ((cp = getenv(DISPLAY)) != NULL && *cp != '\0') { + StrAllocCopy(display, cp); + } + } -/* -display */ -static int display_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg != 0) { - LYsetXDisplay(next_arg); - if ((next_arg = LYgetXDisplay()) != 0) - StrAllocCopy(x_display, next_arg); + } else if (strncmp(argv[0], "-dump", 5) == 0) { + dump_output_immediately = TRUE; + LYcols=80; + + } else { + goto Output_Error_and_Help_List; } + break; - return 0; -} + case 'e': + if (strncmp(argv[0], "-editor", 7) == 0) { + if (nextarg) + StrAllocCopy(editor,cp); + system_editor = TRUE; -/* -dump */ -static int dump_output_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - dump_output_immediately = TRUE; - LYcols = 80; - return 0; -} + } else if (strncmp(argv[0], "-emacskeys", 10) == 0) { + emacs_keys = TRUE; -/* -editor */ -static int editor_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg != 0) - StrAllocCopy(editor, next_arg); - system_editor = TRUE; - return 0; -} + } else if (strncmp(argv[0], "-enable_scrollback", 18) == 0) { + if (enable_scrollback) + enable_scrollback = FALSE; + else + enable_scrollback = TRUE; -/* -error_file */ -static int error_file_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - /* - * Output return (success/failure) code - * of an HTTP transaction. - */ - if (next_arg != 0) - http_error_file = next_arg; - return 0; -} + } else if (strncmp(argv[0], "-error_file", 11) == 0) { + /* + * Output return (success/failure) code + * of an HTTP transaction. + */ + if (nextarg) + http_error_file = cp; #if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) -/* -exec */ -static int exec_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ + } else if (strncmp(argv[0], "-exec", 5) == 0) { #ifndef NEVER_ALLOW_REMOTE_EXEC - local_exec = TRUE; + local_exec = TRUE; #else - local_exec_on_local_files = TRUE; + local_exec_on_local_files = TRUE; #endif /* NEVER_ALLOW_REMOTE_EXEC */ - return 0; -} -#endif +#endif /* EXEC_LINKS || EXEC_SCRIPTS */ -/* -get_data */ -static int get_data_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - /* - * User data for GET form. - */ - char **get_data; - char buf[1024]; + } else { + goto Output_Error_and_Help_List; + } + break; - /* - * On Unix, conflicts with curses when interactive - * so let's force a dump. - CL - * - * On VMS, mods have been made in LYCurses.c to deal with - * potential conflicts, so don't force the dump here. - FM - */ -#ifndef VMS - dump_output_immediately = TRUE; - LYcols = 80; + case 'f': + if (strncmp(argv[0], "-force_html", 11) == 0) { + LYforce_HTML_mode = TRUE; + + } else if (strncmp(argv[0], "-fileversions", 13) == 0) { +#ifdef VMS + HTVMSFileVersions = TRUE; +#else + break;; #endif /* VMS */ - StrAllocCopy(form_get_data, "?"); /* Prime the pump */ - get_data = &form_get_data; + } else if (strncmp(argv[0], "-force_secure", 13) == 0) { + if (LYForceSSLCookiesSecure) + LYForceSSLCookiesSecure = FALSE; + else + LYForceSSLCookiesSecure = TRUE; - /* - * Build GET data for later. Stop reading when we see a line - * with "---" as its first three characters. - */ - while (fgets(buf, sizeof(buf), stdin) && - strncmp(buf, "---", 3) != 0) { - int j; + } else if (strncmp(argv[0], "-from", 5) == 0) { + if (LYNoFromHeader) + LYNoFromHeader = FALSE; + else + LYNoFromHeader = TRUE; - for (j = strlen(buf) - 1; j >= 0 && /* Strip line terminators */ - (buf[j] == CR || buf[j] == LF); j--) - buf[j] = '\0'; + } else if (strncmp(argv[0], "-ftp", 4) == 0) { + ftp_ok = FALSE; - StrAllocCat(*get_data, buf); + } else { + goto Output_Error_and_Help_List; } + break; - return 0; -} + case 'g': + if (strcmp(argv[0], "-get_data") == 0) { + /* + * User data for GET form. + */ + char **get_data; + char buf[1024]; -/* -help */ -static int help_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - print_help_and_exit (0); - return 0; -} + /* + * On Unix, conflicts with curses when interactive + * so let's force a dump. - CL + * + * On VMS, mods have been made in LYCurses.c to deal with + * potential conflicts, so don't force the dump here. - FM + */ +#ifndef VMS + dump_output_immediately = TRUE; + LYcols = 80; +#endif /* VMS */ -/* -hiddenlinks */ -static int hiddenlinks_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg != 0) { - if (strncasecomp(next_arg, "merge", 1) == 0) + StrAllocCopy(form_get_data, "?"); /* Prime the pump */ + get_data = &form_get_data; + + /* + * Build GET data for later. Stop reading when we see a line + * with "---" as its first three characters. + */ + while (fgets(buf, sizeof(buf), stdin) && + strncmp(buf, "---", 3) != 0) { + int j; + + for (j = strlen(buf) - 1; j >= 0 && /* Strip line terminators */ + (buf[j] == CR || buf[j] == LF); j--) { + buf[j] = '\0'; + } + StrAllocCat(*get_data, buf); + } + + } else { + goto Output_Error_and_Help_List; + } + break; + + case 'h': + if (strcmp(argv[0], "-help") == 0) { + goto Output_Help_List; + + } else if (strcmp(argv[0], "-head") == 0) { + /* + * Return mime headers. + */ + HEAD_request = TRUE; + + } else if (strncmp(argv[0], "-hiddenlinks", 7) == 0) { + if (nextarg) { + if (strncasecomp(cp, "merge", 1) == 0) + LYHiddenLinks = HIDDENLINKS_MERGE; + else if (strncasecomp(cp, "listonly", 1) == 0) + LYHiddenLinks = HIDDENLINKS_SEPARATE; + else if (strncasecomp(cp, "ignore", 1) == 0) + LYHiddenLinks = HIDDENLINKS_IGNORE; + else + goto Output_Error_and_Help_List; + } else LYHiddenLinks = HIDDENLINKS_MERGE; - else if (strncasecomp(next_arg, "listonly", 1) == 0) - LYHiddenLinks = HIDDENLINKS_SEPARATE; - else if (strncasecomp(next_arg, "ignore", 1) == 0) - LYHiddenLinks = HIDDENLINKS_IGNORE; + + } else if (strncmp(argv[0], "-historical", 11) == 0) { + if (historical_comments) + historical_comments = FALSE; else - print_help_and_exit (-1); + historical_comments = TRUE; + + } else if (strncmp(argv[0], "-homepage", 9) == 0) { + if (nextarg) { + StrAllocCopy(homepage, cp); + LYTrimHead(homepage); + if (!strncasecomp(homepage, "lynxexec:", 9) || + !strncasecomp(homepage, "lynxprog:", 9)) { + /* + * The original implementations of these schemes expected + * white space without hex escaping, and did not check + * for hex escaping, so we'll continue to support that, + * until that code is redone in conformance with SGML + * principles. - FM + */ + HTUnEscapeSome(homepage, " \r\n\t"); + convert_to_spaces(homepage, TRUE); + } + } } else { - LYHiddenLinks = HIDDENLINKS_MERGE; + goto Output_Error_and_Help_List; } + break; - return 0; -} + case 'i': + if (strncmp(argv[0], "-image_links", 12) == 0) { + if (clickable_images) + clickable_images = FALSE; + else + clickable_images = TRUE; -/* -homepage */ -static int homepage_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg != 0) { - StrAllocCopy(homepage, next_arg); - LYTrimHead(homepage); - if (!strncasecomp(homepage, "lynxexec:", 9) || - !strncasecomp(homepage, "lynxprog:", 9)) { - /* - * The original implementations of these schemes expected - * white space without hex escaping, and did not check - * for hex escaping, so we'll continue to support that, - * until that code is redone in conformance with SGML - * principles. - FM - */ - HTUnEscapeSome(homepage, " \r\n\t"); - convert_to_spaces(homepage, TRUE); - } + } else if (strncmp(argv[0], "-index", 6) == 0) { + if (nextarg) + StrAllocCopy(indexfile, cp); + + } else if (strncmp(argv[0], "-ismap", 6) == 0) { + if (LYNoISMAPifUSEMAP) + LYNoISMAPifUSEMAP = FALSE; + else + LYNoISMAPifUSEMAP = TRUE; + + } else { + goto Output_Error_and_Help_List; } - return 0; -} + break; -/* -mime_header */ -static int mime_header_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - /* - * Include mime headers and force source dump. - */ - keep_mime_headers = TRUE; - dump_output_immediately = TRUE; - HTOutputFormat = (LYPrependBase ? - HTAtom_for("www/download") : HTAtom_for("www/dump")); - LYcols = 999; - return 0; -} + case 'l': + if (strncmp(argv[0], "-link", 5) == 0) { + if (nextarg) + ccount = atoi(cp); -/* -newschunksize */ -static int newschunksize_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg != 0) { - HTNewsChunkSize = atoi(next_arg); + } else if (strncmp(argv[0], "-localhost", 10) == 0) { + local_host_only = TRUE; + +#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) + } else if (strncmp(argv[0], "-locexec", 8) == 0) { + local_exec_on_local_files = TRUE; +#endif /* EXEC_LINKS || EXEC_SCRIPTS */ + +#if defined(USE_HASH) + } else if (strncmp(argv[0], "-lss", 4) == 0) { /* - * If the new HTNewsChunkSize exceeds the maximum, - * increase HTNewsMaxChunk to this size. - FM + * Already read the alternate lynx-style file + * so just check whether we need to increment i */ - if (HTNewsChunkSize > HTNewsMaxChunk) - HTNewsMaxChunk = HTNewsChunkSize; + if (nextarg) + ; /* do nothing */ +#endif + + } else { + goto Output_Error_and_Help_List; } - return 0; -} + break; -/* -newsmaxchunk */ -static int newsmaxchunk_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg) { - HTNewsMaxChunk = atoi(next_arg); + case 'm': + if (strcmp(argv[0], "-mime_header") == 0) { /* - * If HTNewsChunkSize exceeds the new maximum, - * reduce HTNewsChunkSize to this maximum. - FM + * Include mime headers and force source dump. */ - if (HTNewsChunkSize > HTNewsMaxChunk) - HTNewsChunkSize = HTNewsMaxChunk; + keep_mime_headers = TRUE; + dump_output_immediately = TRUE; + HTOutputFormat = (LYPrependBase ? + HTAtom_for("www/download") : HTAtom_for("www/dump")); + LYcols=999; + + } else if (strncmp(argv[0], "-minimal", 8) == 0) { + if (minimal_comments) + minimal_comments = FALSE; + else + minimal_comments = TRUE; + + } else { + goto Output_Error_and_Help_List; } - return 0; -} + break; -/* -nobrowse */ -static int nobrowse_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - HTDirAccess = HT_DIR_FORBID; - return 0; -} + case 'n': + if (strncmp(argv[0], "-newschunksize", 14) == 0) { + if (nextarg) { + HTNewsChunkSize = atoi(cp); + /* + * If the new HTNewsChunkSize exceeds the maximum, + * increase HTNewsMaxChunk to this size. - FM + */ + if (HTNewsChunkSize > HTNewsMaxChunk) { + HTNewsMaxChunk = HTNewsChunkSize; + } + } -/* -nocolor */ -static int nocolor_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - LYShowColor = SHOW_COLOR_NEVER; + } else if (strncmp(argv[0], "-newsmaxchunk", 13) == 0) { + if (nextarg) { + HTNewsMaxChunk = atoi(cp); + /* + * If HTNewsChunkSize exceeds the new maximum, + * reduce HTNewsChunkSize to this maximum. - FM + */ + if (HTNewsChunkSize > HTNewsMaxChunk) { + HTNewsChunkSize = HTNewsMaxChunk; + } + } + + } else if (strncmp(argv[0], "-nobrowse", 9) == 0) { + HTDirAccess = HT_DIR_FORBID; + + } else if (strncmp(argv[0], "-nocc", 5) == 0) { + LYNoCc = TRUE; + + } else if (strncmp(argv[0], "-nocolor", 8) == 0) { + LYShowColor = SHOW_COLOR_NEVER; #ifdef USE_SLANG - Lynx_Color_Flags &= ~SL_LYNX_USE_COLOR; - Lynx_Color_Flags |= SL_LYNX_OVERRIDE_COLOR; + Lynx_Color_Flags &= ~SL_LYNX_USE_COLOR; + Lynx_Color_Flags |= SL_LYNX_OVERRIDE_COLOR; #endif - return 0; -} -/* -nopause */ -static int nopause_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - InfoSecs = 0; - MessageSecs = 0; - AlertSecs = 0; - return 0; -} +#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) + } else if (strncmp(argv[0], "-noexec", 7) == 0) { + local_exec = FALSE; +#endif /* EXEC_LINKS || EXEC_SCRIPTS */ -/* -pauth */ -static int pauth_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - parse_authentication(next_arg, proxyauth_info); - return 0; -} + } else if (strncmp(argv[0], "-nofilereferer", 14) == 0) { + no_filereferer = TRUE; -/* -post_data */ -static int post_data_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - /* - * User data for POST form. - */ - char **post_data; - char buf[1024]; + } else if (strncmp(argv[0], "-nolist", 7) == 0) { + nolist = TRUE; - /* - * On Unix, conflicts with curses when interactive so let's force a dump. - * - CL - * - * On VMS, mods have been made in LYCurses.c to deal with potential - * conflicts, so don't force a dump here. - FM - */ + } else if (strncmp(argv[0], "-nolog", 6) == 0) { + error_logging = FALSE; + + } else if (strcmp(argv[0], "-nopause") == 0) { /* No statusline pauses */ + InfoSecs = 0; + MessageSecs = 0; + AlertSecs = 0; + + } else if (strncmp(argv[0], "-noprint", 8) == 0) { + no_print = TRUE; + + } else if (strcmp(argv[0], "-noredir") == 0) { + /* + * Don't follow URL redirections. + */ + no_url_redirection = TRUE; + + } else if (strncmp(argv[0], "-noreferer", 10) == 0) { + LYNoRefererHeader = TRUE; + +#ifdef SOCKS + } else if (strncmp(argv[0], "-nosocks", 8) == 0) { + socks_flag = FALSE; +#endif /* SOCKS */ + + } else if (strncmp(argv[0], "-nostatus", 9) == 0) { + no_statusline = TRUE; + + } else if (strncmp(argv[0], "-number_links", 13) == 0) { + number_links = TRUE; + + } else { + goto Output_Error_and_Help_List; + } + break; + + case 'p': + if (strncmp(argv[0], "-pauth", 6) == 0) { + /* + * Authentication information for protected proxy server. - AJL + */ + char *pauth_info = NULL; + + if (nextarg) { + StrAllocCopy(pauth_info, cp); + memset(cp, ' ', strlen(cp)); /* Let's not show too much */ + } + if (pauth_info != NULL) { + if ((cp = strchr(pauth_info, ':')) != NULL) { /* Pw */ + *cp++ = '\0'; /* Terminate ID */ + if (*cp) { + HTUnEscape(cp); + StrAllocCopy(proxyauth_info[1], cp); + } + } + if (*pauth_info) { /* Id */ + HTUnEscape(pauth_info); + StrAllocCopy(proxyauth_info[0], pauth_info); + } + FREE(pauth_info); + } + + } else if (strncmp(argv[0], "-popup", 6) == 0) { + LYUseDefSelPop = FALSE; + + } else if (strcmp(argv[0], "-post_data") == 0) { + /* + * User data for POST form. + */ + char **post_data; + char buf[1024]; + + /* + * On Unix, conflicts with curses when interactive + * so let's force a dump. - CL + * + * On VMS, mods have been made in LYCurses.c to deal with + * potential conflicts, so don't force a dump here. - FM + */ #ifndef VMS - dump_output_immediately = TRUE; - LYcols = 80; + dump_output_immediately = TRUE; + LYcols = 80; #endif /* VMS */ - post_data = &form_post_data; + post_data = &form_post_data; - /* - * Build post data for later. Stop reading when we see a line with "---" - * as its first three characters. - */ - while (fgets(buf, sizeof(buf), stdin) && - strncmp(buf, "---", 3) != 0) { - int j; + /* + * Build post data for later. Stop reading when we see a line + * with "---" as its first three characters. + */ + while (fgets(buf, sizeof(buf), stdin) && + strncmp(buf, "---", 3) != 0) { + int j; - for (j = strlen(buf) - 1; j >= 0 && /* Strip line terminators */ - (buf[j] == CR || buf[j] == LF); j--) { - buf[j] = '\0'; + for (j = strlen(buf) - 1; j >= 0 && /* Strip line terminators */ + (buf[j] == CR || buf[j] == LF); j--) { + buf[j] = '\0'; + } + StrAllocCat(*post_data, buf); } - StrAllocCat(*post_data, buf); + + } else if (strncmp(argv[0], "-preparsed", 9) == 0) { + LYPreparsedSource = TRUE; + + } else if (strncmp(argv[0], "-print", 6) == 0) { + no_print=FALSE; + + } else if (strncmp(argv[0], "-pseudo_inlines", 15) == 0) { + if (pseudo_inline_alts) + pseudo_inline_alts = FALSE; + else + pseudo_inline_alts = TRUE; + + } else { + goto Output_Error_and_Help_List; } - return 0; -} + break; -/* -restrictions */ -static int restrictions_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - static CONST char *Usage[] = { + case 'r': + if (strncmp(argv[0], "-raw", 4) == 0) { + LYUseDefaultRawMode = FALSE; + + } else if (strncmp(argv[0], "-realm", 6) == 0) { + check_realm = TRUE; + + } else if (strncmp(argv[0], "-reload", 7) == 0) { + reloading = TRUE; + + } else if (strncmp(argv[0], "-restrictions", 13) == 0) { + if ((cp=strchr(argv[0],'=')) != NULL) + parse_restrictions(cp+1); + else { + static CONST char *Usage[] = { "" ," USAGE: lynx -restrictions=[option][,option][,option]" ," List of Options:" @@ -2364,788 +2514,317 @@ static int restrictions_fun ARGS3( ," suspend disallow Control-Z suspends with escape to shell" ," telnet_port disallow specifying a port in telnet G)oto's" ," useragent disallow modifications of the User-Agent header" - }; - size_t n; - - if (next_arg != 0) { - parse_restrictions(next_arg); - } else { - SetOutputMode( O_TEXT ); - for (n = 0; n < sizeof(Usage)/sizeof(Usage[0]); n++) - printf("%s\n", Usage[n]); - SetOutputMode( O_BINARY ); - exit(0); - } - return 0; -} + }; + size_t n; + for (n = 0; n < sizeof(Usage)/sizeof(Usage[0]); n++) + printf("%s\n", Usage[n]); + exit(0); + } -/* -selective */ -static int selective_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - HTDirAccess = HT_DIR_SELECTIVE; - return 0; -} + } else if (strncmp(argv[0], "-resubmit_posts", 15) == 0) { + if (LYresubmit_posts) + LYresubmit_posts = FALSE; + else + LYresubmit_posts = TRUE; -/* -source */ -static int source_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - dump_output_immediately = TRUE; - HTOutputFormat = (LYPrependBase ? - HTAtom_for("www/download") : HTAtom_for("www/dump")); - LYcols = 999; - return 0; -} + } else if (strncmp(argv[0], "-rlogin", 7) == 0) { + rlogin_ok = FALSE; -/* -tagsoup */ -static int tagsoup_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - HTSwitchDTD(New_DTD = NO); - return 0; -} + } else { + goto Output_Error_and_Help_List; + } + break; -/* -traversal */ -static int traversal_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - traversal = TRUE; -#ifdef USE_SLANG - LYcols = 80; -#else - LYcols = 999; -#endif /* USE_SLANG */ + case 's': + if (strncmp(argv[0], "-selective", 10) == 0) { + HTDirAccess = HT_DIR_SELECTIVE; - return 0; -} + } else if (strncmp(argv[0], "-show_cursor", 12) == 0) { + LYUseDefShoCur = FALSE; -/* -version */ -static int version_fun ARGS3( - Parse_Args_Type *, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg GCC_UNUSED) -{ - SetOutputMode( O_TEXT ); - - printf("\n%s Version %s (%.*s)\n", - LYNX_NAME, LYNX_VERSION, - LYNX_DATE_LEN, - LYNX_RELEASE ? LYNX_RELEASE_DATE : &LYNX_DATE[LYNX_DATE_OFF] - ); - printf( - "Copyrights held by the University of Kansas, CERN, and other contributors.\n" - ); - printf("Distributed under the GNU General Public License.\n"); - printf( - "See http://lynx.browser.org/ and the online help for more information.\n\n" - ); - - SetOutputMode( O_BINARY ); + } else if (strncmp(argv[0], "-soft_dquotes", 13) == 0) { + if (soft_dquotes) + soft_dquotes = FALSE; + else + soft_dquotes = TRUE; - exit(0); - /* NOT REACHED */ - return 0; -} + } else if (strncmp(argv[0], "-source", 7) == 0) { + dump_output_immediately = TRUE; + HTOutputFormat = (LYPrependBase ? + HTAtom_for("www/download") : HTAtom_for("www/dump")); + LYcols=999; -/* -width */ -static int width_fun ARGS3( - Parse_Args_Type*, p GCC_UNUSED, - char **, argv GCC_UNUSED, - char *, next_arg) -{ - if (next_arg != 0) { - int w = atoi(next_arg); - if (w > 0) - dump_output_width = ((w < 999) ? w : 999); - } + } else if (strncmp(argv[0], "-stack_dump", 11) == 0) { + stack_dump = TRUE; - return 0; -} + } else if (strncmp(argv[0], "-startfile_ok", 13) == 0) { + startfile_ok = TRUE; -/* NOTE: This table is sorted by name; the lookup relies on that. */ -static Parse_Args_Type Arg_Table [] = -{ - PARSE_SET( - "accept_all_cookies", SET_ARG, &LYAcceptAllCookies, - "\naccepts all cookies" - ), - PARSE_FUN( - "anonymous", FUNCTION_ARG, anonymous_fun, - "used to specify the anonymous account" - ), - PARSE_FUN( - "assume_charset", NEED_FUNCTION_ARG, assume_charset_fun, - "=MIMEname\ncharset for documents that don't specify it" - ), - PARSE_FUN( - "assume_local_charset", NEED_FUNCTION_ARG,assume_local_charset_fun, - "=MIMEname\ncharset assumed for local files" - ), - PARSE_FUN( - "assume_unrec_charset", NEED_FUNCTION_ARG,assume_unrec_charset_fun, - "=MIMEname\nuse this instead of unrecognized charsets" - ), - PARSE_FUN( - "auth", NEED_FUNCTION_ARG, auth_fun, - "=id:pw\nauthentication information for protected documents" - ), - PARSE_FUN( - "base", FUNCTION_ARG, base_fun, - "prepend a request URL comment and BASE tag to text/html\noutputs for -source dumps" - ), -#ifdef USE_SLANG - PARSE_FUN( - "blink", FUNCTION_ARG, blink_fun, - "force high intensity bg colors in color mode" - ), -#endif - PARSE_SET( - "book", SET_ARG, &bookmark_start, - "use the bookmark page as the startfile" - ), - PARSE_SET( - "buried_news", TOGGLE_ARG, &scan_for_buried_news_references, - "toggles scanning of news articles for buried references" - ), - PARSE_FUN( - "cache", NEED_FUNCTION_ARG, cache_fun, - "=NUMBER\nNUMBER of documents cached in memory" - ), - PARSE_SET( - "case", SET_ARG, &case_sensitive, - "enable case sensitive user searching" - ), - PARSE_STR( - "cfg", IGNORE_ARG|NEED_NEXT_ARG, 0, - "=FILENAME\nspecifies a lynx.cfg file other than the default" - ), - PARSE_FUN( - "child", FUNCTION_ARG, child_fun, - "exit on left-arrow in startfile, and disable save to disk" - ), -#ifdef USE_SLANG - PARSE_FUN( - "color", FUNCTION_ARG, color_fun, - "force color mode on with standard bg colors" - ), -#endif - PARSE_SET( - "cookies", TOGGLE_ARG, &LYSetCookies, - "toggles handling of Set-Cookie headers" - ), -#ifdef EXP_PERSISTENT_COOKIES - PARSE_STR( - "cookie_file", LYSTRING_ARG, &LYCookieFile, - "=FILENAME\nspecifies a file to use to store cookies" - ), -#endif /* EXP_PERSISTENT_COOKIES */ -#ifndef VMS - PARSE_SET( - "core", TOGGLE_ARG, &LYNoCore, - "toggles forced core dumps on fatal errors" - ), -#endif - PARSE_FUN( - "crawl", FUNCTION_ARG, crawl_fun, - "with -traversal, output each page to a file\n\ -with -dump, format output as with -traversal, but to stdout" - ), -#ifdef DISP_PARTIAL - PARSE_SET( - "debug_partial", TOGGLE_ARG, &debug_display_partial, - "incremental display stages with MessageSecs delay" - ), -#endif - PARSE_FUN( - "display", NEED_FUNCTION_ARG, display_fun, - "=DISPLAY\nset the display variable for X exec'ed programs" - ), - PARSE_FUN( - "dump", FUNCTION_ARG, dump_output_fun, - "dump the first file to stdout and exit" - ), - PARSE_FUN( - "editor", NEED_FUNCTION_ARG, editor_fun, - "=EDITOR\nenable edit mode with specified editor" - ), - PARSE_SET( - "emacskeys", SET_ARG, &emacs_keys, - "enable emacs-like key movement" - ), - PARSE_SET( - "enable_scrollback", TOGGLE_ARG, &enable_scrollback, - "\ntoggles compatibility with comm programs' scrollback\n\ -keys (may be incompatible with some curses packages)" - ), - PARSE_FUN( - "error_file", NEED_FUNCTION_ARG, error_file_fun, - "=FILE\nwrite the HTTP status code here" - ), -#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) -#ifndef NEVER_ALLOW_REMOTE_EXEC - PARSE_FUN( - "exec", FUNCTION_ARG, exec_fun, - "enable local program execution" - ), -#endif - PARSE_SET( - "locexec", SET_ARG, &local_exec_on_local_files, - "enable local program execution from local files only" - ), - PARSE_SET( - "noexec", UNSET_ARG, &local_exec, - "disable local program execution (DEFAULT)" - ), -#endif /* EXEC_LINKS || EXEC_SCRIPTS */ -#ifdef VMS - PARSE_SET( - "fileversions", SET_ARG, &HTVMSFileVersions, - "include all versions of files in local VMS directory\nlistings" - ), -#endif - PARSE_SET( - "force_html", SET_ARG, &LYforce_HTML_mode, - "forces the first document to be interpreted as HTML" - ), - PARSE_SET( - "force_secure", TOGGLE_ARG, &LYForceSSLCookiesSecure, - "toggles forcing of the secure flag for SSL cookies" - ), - PARSE_SET( - "from", TOGGLE_ARG, &LYNoFromHeader, - "toggle transmissions of From headers" - ), -#if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU) - PARSE_SET( - "forms_options", TOGGLE_ARG, &LYUseFormsOptions, - "toggles forms-based vs old-style options menu" - ), -#endif - PARSE_SET( - "ftp", UNSET_ARG, &ftp_ok, - "disable ftp access" - ), - PARSE_FUN( - "get_data", FUNCTION_ARG, get_data_fun, - "user data for get forms, read from stdin,\nterminated by '---' on a line" - ), - PARSE_SET( - "head", SET_ARG, &HEAD_request, - "send a HEAD request" - ), - PARSE_FUN( - "help", FUNCTION_ARG, help_fun, - "print this usage message" - ), - PARSE_FUN( - "hiddenlinks", NEED_FUNCTION_ARG, hiddenlinks_fun, - "=[option]\nhidden links: options are merge, listonly, or ignore" - ), - PARSE_SET( - "historical", TOGGLE_ARG, &historical_comments, - "toggles use of '>' or '-->' as a terminator for comments" - ), - PARSE_FUN( - "homepage", NEED_FUNCTION_ARG, homepage_fun, - "=URL\nset homepage separate from start page" - ), - PARSE_SET( - "image_links", TOGGLE_ARG, &clickable_images, - "toggles inclusion of links for all images" - ), - PARSE_STR( - "index", NEED_LYSTRING_ARG, &indexfile, - "=URL\nset the default index file to URL" - ), - PARSE_SET( - "ismap", TOGGLE_ARG, &LYNoISMAPifUSEMAP, - "toggles inclusion of ISMAP links when client-side\nMAPs are present" - ), - PARSE_INT( - "link", NEED_INT_ARG, ccount, - "=NUMBER\nstarting count for lnk#.dat files produced by -crawl" - ), - PARSE_SET( - "localhost", SET_ARG, &local_host_only, - "disable URLs that point to remote hosts" - ), -#if defined(USE_HASH) - PARSE_STR( - "lss", IGNORE_ARG|NEED_NEXT_ARG, 0, - "=FILENAME\nspecifies a lynx.lss file other than the default" - ), -#endif - PARSE_FUN( - "mime_header", FUNCTION_ARG, mime_header_fun, - "include mime headers and force source dump" - ), - PARSE_SET( - "minimal", TOGGLE_ARG, &minimal_comments, - "toggles minimal versus valid comment parsing" - ), - PARSE_FUN( - "newschunksize", NEED_FUNCTION_ARG, newschunksize_fun, - "=NUMBER\nnumber of articles in chunked news listings" - ), - PARSE_FUN( - "newsmaxchunk", NEED_FUNCTION_ARG, newsmaxchunk_fun, - "=NUMBER\nmaximum news articles in listings before chunking" - ), - PARSE_FUN( - "nobrowse", FUNCTION_ARG, nobrowse_fun, - "disable directory browsing" - ), - PARSE_SET( - "nocc", SET_ARG, &LYNoCc, - "disable Cc: prompts for self copies of mailings" - ), - PARSE_FUN( - "nocolor", FUNCTION_ARG, nocolor_fun, - "turn off color support" - ), - PARSE_SET( - "nofilereferer", SET_ARG, &no_filereferer, - "disable transmissions of Referer headers for file URLs" - ), - PARSE_SET( - "nolist", SET_ARG, &nolist, - "disable the link list feature in dumps" - ), - PARSE_SET( - "nolog", UNSET_ARG, &error_logging, - "disable mailing of error messages to document owners" - ), - PARSE_FUN( - "nopause", FUNCTION_ARG, nopause_fun, - "disable forced pauses for statusline messages" - ), - PARSE_SET( - "noprint", SET_ARG, &no_print, - "disable print functions" - ), - PARSE_SET( - "noredir", SET_ARG, &no_url_redirection, - "don't follow Location: redirection" - ), - PARSE_SET( - "noreferer", SET_ARG, &LYNoRefererHeader, - "disable transmissions of Referer headers" - ), -#ifdef SOCKS - PARSE_SET( - "nosocks", UNSET_ARG, &socks_flag, - "don't use SOCKS proxy for this session" - ), -#endif - PARSE_SET( - "nostatus", SET_ARG, &no_statusline, - "disable the miscellaneous information messages" - ), - PARSE_SET( - "number_links", SET_ARG, &number_links, - "force numbering of links" - ), -#ifdef DISP_PARTIAL - PARSE_SET( - "partial", TOGGLE_ARG, &display_partial, - "display partial pages while downloading" - ), - PARSE_INT( - "partial_thres", IGNORE_ARG|INT_ARG, partial_threshold, - "[=NUMBER]\nnumber of lines to render before repainting display\n\ -with partial-display logic" - ), -#endif - PARSE_FUN( - "pauth", NEED_FUNCTION_ARG, pauth_fun, - "=id:pw\nauthentication information for protected proxy server" - ), - PARSE_SET( - "popup", UNSET_ARG, &LYUseDefSelPop, - "toggles handling of single-choice SELECT options via\npopup windows or as lists of radio buttons" - ), - PARSE_FUN( - "post_data", FUNCTION_ARG, post_data_fun, - "user data for post forms, read from stdin,\nterminated by '---' on a line" - ), - PARSE_SET( - "preparsed", SET_ARG, &LYPreparsedSource, - "show parsed text/html with -source and in source view" - ), - PARSE_SET( - "print", UNSET_ARG, &no_print, - "enable print functions (DEFAULT)" - ), - PARSE_SET( - "pseudo_inlines", TOGGLE_ARG, &pseudo_inline_alts, - "toggles pseudo-ALTs for inlines with no ALT string" - ), - PARSE_SET( - "raw", UNSET_ARG, &LYUseDefaultRawMode, - "toggles default setting of 8-bit character translations\nor CJK mode for the startup character set" - ), - PARSE_SET( - "realm", SET_ARG, &check_realm, - "restricts access to URLs in the starting realm" - ), - PARSE_SET( - "reload", SET_ARG, &reloading, - "flushes the cache on a proxy server\n(only the first document affected)" - ), - PARSE_FUN( - "restrictions", FUNCTION_ARG, restrictions_fun, - "=[options]\nuse -restrictions to see list" - ), - PARSE_SET( - "resubmit_posts", TOGGLE_ARG, &LYresubmit_posts, - "toggles forced resubmissions (no-cache) of forms with\n\ -method POST when the documents they returned are sought\n\ -with the PREV_DOC command or from the History List" - ), - PARSE_SET( - "rlogin", UNSET_ARG, &rlogin_ok, - "disable rlogins" - ), - PARSE_FUN( - "selective", FUNCTION_ARG, selective_fun, - "require .www_browsable files to browse directories" - ), - PARSE_SET( - "show_cursor", TOGGLE_ARG, &LYUseDefShoCur, - "toggles hiding of the cursor in the lower right corner" - ), - PARSE_SET( - "soft_dquotes", TOGGLE_ARG, &soft_dquotes, - "toggles emulation of the old Netscape and Mosaic bug which\n\ -treated '>' as a co-terminator for double-quotes and tags" - ), - PARSE_FUN( - "source", FUNCTION_ARG, source_fun, - "dump the source of the first file to stdout and exit" - ), - PARSE_SET( - "stack_dump", SET_ARG, &stack_dump, - "disable SIGINT cleanup handler" - ), - PARSE_SET( - "startfile_ok", SET_ARG, &startfile_ok, - "allow non-http startfile and homepage with -validate" - ), #ifndef VMS #ifdef SYSLOG_REQUESTED_URLS - PARSE_STR( - "syslog", NEED_LYSTRING_ARG, &syslog_txt, - "=text\ninformation for syslog call" - ), -#endif -#endif - PARSE_FUN( - "tagsoup", FUNCTION_ARG, tagsoup_fun, - "use TagSoup rather than SortaSGML parser" - ), - PARSE_SET( - "telnet", UNSET_ARG, &telnet_ok, - "disable telnets" - ), - PARSE_STR( - "term", NEED_STRING_ARG, &terminal, - "=TERM\nset terminal type to TERM" - ), - PARSE_SET( - "tlog", IGNORE_ARG, 0, - "toggles use of a Lynx Trace Log for the current session" - ), - PARSE_SET( - "trace", IGNORE_ARG, 0, - "turns on Lynx trace mode" - ), - PARSE_FUN( - "traversal", FUNCTION_ARG, traversal_fun, - "traverse all http links derived from startfile" - ), - PARSE_SET( - "underscore", TOGGLE_ARG, &use_underscore, - "toggles use of _underline_ format in dumps" - ), -#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) - PARSE_SET( - "use_mouse", SET_ARG, &LYUseMouse, - "turn on xterm mouse support" - ), -#endif - PARSE_STR( - "useragent", NEED_LYSTRING_ARG, &LYUserAgent, - "=Name\nset alternate Lynx User-Agent header" - ), - PARSE_SET( - "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" - ), - PARSE_SET( - "vikeys", SET_ARG, &vi_keys, - "enable vi-like key movement" - ), - PARSE_FUN( - "width", NEED_FUNCTION_ARG, width_fun, - "=NUMBER\nscreen width for formatting of dumps (default is 80)" - ), - {NULL} -}; - -static void print_help_strings ARGS2( - CONST char *, name, - CONST char *, help) -{ - int pad; - int c; - int first; - int field_width = 21; - - pad = field_width - (5 + (int) strlen (name)); - - fprintf (stdout, " -%s", name); + } else if (strncmp(argv[0], "-syslog", 7) == 0) { + if (nextarg) + StrAllocCopy(syslog_txt, cp); +#endif /* SYSLOG_REQUESTED_URLS */ +#endif /* !VMS */ - if (*help != '=') { - pad--; - while (pad > 0) { - fputc (' ', stdout); - pad--; - } - fputc (' ', stdout); /* at least one space */ - first = 0; } else { - first = pad; + goto Output_Error_and_Help_List; } + break; - if (strchr (help, '\n') == 0) { - fprintf (stdout, "%s\n", help); - } else { - while ((c = *help) != 0) { - if (c == '\n') { - if ((pad = --first) < 0) { - pad = field_width; - } else { - c = ' '; - } - fputc (c, stdout); - while (pad--) - fputc (' ', stdout); - } else { - fputc (c, stdout); - } - help++; - first--; - } - fputc ('\n', stdout); - } -} + case 't': + if (strncmp(argv[0], "-telnet", 7) == 0) { + telnet_ok = FALSE; -static void print_help_and_exit ARGS1(int, exit_status) -{ - Parse_Args_Type *p; + } else if (strncmp(argv[0], "-term", 5) == 0) { + if (nextarg) + terminal = cp; - if (pgm == NULL) pgm = "lynx"; + } else if (strncmp(argv[0], "-tlog", 5) == 0) { + /* + * Already handled. - FM + */ + break; - SetOutputMode( O_TEXT ); + } else if (strncmp(argv[0], "-trace", 6) == 0) { + /* + * Already handled. - FM + */ + break; - fprintf (stdout, "USAGE: %s [options] [file]\n", pgm); - fprintf (stdout, "Options are:\n"); - print_help_strings("", -"receive the arguments from stdin (enclose\n\ -in double-quotes (\"-\") on VMS)"); + } else if (strncmp(argv[0], "-traversal", 10) == 0) { + traversal = TRUE; +#ifdef USE_SLANG + LYcols=80; +#else + LYcols=999; +#endif /* USE_SLANG */ - for (p = Arg_Table; p->name != 0; p++) - print_help_strings(p->name, p->help_string); + } else { + goto Output_Error_and_Help_List; + } + break; - SetOutputMode( O_BINARY ); + case 'u': + if (strncmp(argv[0], "-underscore", 11) == 0) { + if (use_underscore) + use_underscore = FALSE; + else + use_underscore = TRUE; - exit (exit_status); -} + } else if (strncmp(argv[0], "-useragent", 10) == 0) { + /* + * Set alternate Lynx User-Agent header. + */ + if (nextarg) + StrAllocCopy(LYUserAgent, cp); -/* - * This function performs a string comparison on two strings a and b. a is - * assumed to be an ordinary null terminated string, but b may be terminated - * by an '=', '+' or '-' character. If terminated by '=', *c will be pointed - * to the character following the '='. If terminated by '+' or '-', *c will - * be pointed to that character. (+/- added for toggle processing - BL.) - * If a and b match, it returns 1. Otherwise 0 is returned. - */ -static int arg_eqs_parse ARGS3( - CONST char *, a, - char *, b, - char **, c) -{ - *c = NULL; - while (1) { - if ((*a != *b) - || (*a == 0) - || (*b == 0)) { - if (*a == 0) { - switch (*b) { - case '=': - *c = b + 1; - return 1; - case '-': /* FALLTHRU */ - case '+': - *c = b; - return 1; - case 0: - return 1; - default: - return 0; - } - } else { - return 0; - } - } - a++; - b++; - } -} +#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) + } else if (strncmp(argv[0], "-use_mouse", 9) == 0) { + LYUseMouse = TRUE; +#endif + } else { + goto Output_Error_and_Help_List; + } + break; -#define is_true(s) (*s == '1' || *s == '+' || !strcmp(s, "on")) -#define is_false(s) (*s == '0' || *s == '-' || !strcmp(s, "off")) + case 'v': + if (strcmp(argv[0], "-validate") == 0) { + /* + * Follow only http URLs. + * Already handled. - FM + */ + break; + + } else if (strncmp(argv[0], "-version", 8) == 0) { + printf("\n%s Version %s (1998)\n", LYNX_NAME, LYNX_VERSION); + printf( + "Copyrights held by the University of Kansas, CERN, and other contributors.\n" + ); + printf("Distributed under the GNU General Public License.\n"); + printf( + "See http://lynx.browser.org/ and the online help for more information.\n\n" + ); + exit(0); -PRIVATE void parse_arg ARGS2( - char **, argv, - int *, i) -{ - Parse_Args_Type *p; - char *arg_name; + } else if (strncmp(argv[0], "-vikeys", 7) == 0) { + vi_keys = TRUE; - arg_name = argv[0]; + } else { + goto Output_Error_and_Help_List; + } + break; - /* - * Check for a command line startfile. - FM - */ - if (*arg_name != '-') { - StrAllocCopy(startfile, arg_name); - LYTrimHead(startfile); - if (!strncasecomp(startfile, "lynxexec:", 9) || - !strncasecomp(startfile, "lynxprog:", 9)) { - /* - * The original implementations of these schemes expected - * white space without hex escaping, and did not check - * for hex escaping, so we'll continue to support that, - * until that code is redone in conformance with SGML - * principles. - FM - */ - HTUnEscapeSome(startfile, " \r\n\t"); - convert_to_spaces(startfile, TRUE); + case 'w': + if (strncmp(argv[0], "-width", 2) == 0) { + if (nextarg) { + int w = atoi(cp); + if (w > 0) { + dump_output_width = ((w < 999) ? w : 999); + break; + } } - return; + dump_output_width = 80; + } else { + goto Output_Error_and_Help_List; } + break; - /* lose the first '-' character */ - arg_name++; - - /* - * Skip any lone "-" arguments, because we've loaded - * the stdin input into an HTList structure for - * special handling. - FM - */ - if (*arg_name == 0) - return; - - p = Arg_Table; - while (p->name != 0) { -#ifdef PARSE_DEBUG - Parse_Args_Type *q = p; + default: +Output_Error_and_Help_List: +#ifdef VMS + printf(" LYNX: Invalid Option: %s\n", argv[0]); #else - ParseUnion *q = (ParseUnion *)(&(p->value)); +#ifdef UNIX + if (strncmp(argv[0], "-help", 5) != 0) + fprintf(stderr, "%s: Invalid Option: %s\n", pgm, argv[0]); + else +#endif /* UNIX */ + printf("%s: Invalid Option: %s\n", pgm, argv[0]); +#endif /* VMS */ +Output_Help_List: +#ifdef VMS + printf("USAGE: lynx [options] [file]\n"); +#else + printf("USAGE: %s [options] [file]\n",pgm); +#endif /* VMS */ + { + static CONST char *Options[] = { + "Options are:" +," - receive the arguments from stdin (enclose" +," in double-quotes (\"-\") on VMS)" +," -anonymous used to specify the anonymous account" +," -assume_charset=MIMEname charset for documents that don't specify it" +," -assume_local_charset=MIMEname charset assumed for local files" +," -assume_unrec_charset=MIMEname use this instead of unrecognized charsets" +," -auth=id:pw authentication information for protected documents" +," -base prepend a request URL comment and BASE tag to text/html" +," outputs for -source dumps" +," -book use the bookmark page as the startfile" +," -buried_news toggles scanning of news articles for buried references" +," -cache=NUMBER NUMBER of documents cached in memory" +," -case enable case sensitive user searching" +," -cfg=FILENAME specifies a lynx.cfg file other than the default" +," -child exit on left-arrow in startfile, and disable save to disk" +#ifdef USE_SLANG +," -color force color mode on with standard bg colors" +," -blink force high intensity bg colors in color mode" +#endif /* USE_SLANG */ +," -cookies toggles handling of Set-Cookie headers" +#ifndef VMS +," -core toggles forced core dumps on fatal errors" +#endif /* !VMS */ +," -crawl with -traversal, output each page to a file" +," with -dump, format output as with -traversal, but to stdout" +," -display=DISPLAY set the display variable for X execed programs" +," -dump dump the first file to stdout and exit" +," -editor=EDITOR enable edit mode with specified editor" +," -emacskeys enable emacs-like key movement" +," -enable_scrollback toggles compatibility with comm programs' scrollback" +," keys (may be incompatible with some curses packages)" +," -error_file=FILE write the HTTP status code here" +#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) +#ifndef NEVER_ALLOW_REMOTE_EXEC +," -exec enable local program execution" +#endif /* !NEVER_ALLOW_REMOTE_EXEC */ +," -locexec enable local program execution from local files only" +," -noexec disable local program execution (DEFAULT)" +#endif /* EXEC_LINKS || EXEC_SCRIPTS */ +," -fileversions include all versions of files in local VMS directory" +," listings" +," -force_html forces the first document to be interpreted as HTML" +," -force_secure toggles forcing of the secure flag for SSL cookies" +," -from toggle transmissions of From headers" +," -ftp disable ftp access" +," -get_data user data for get forms, read from stdin," +," terminated by '---' on a line" +," -head send a HEAD request" +," -help print this usage message" +," -hiddenlinks=[option] hidden links: options are merge, listonly, or ignore" +," -historical toggles use of '>' or '-->' as a terminator for comments" +," -homepage=URL set homepage separate from start page" +," -image_links toggles inclusion of links for all images" +," -index=URL set the default index file to URL" +," -ismap toggles inclusion of ISMAP links when client-side" +," MAPs are present" +," -link=NUMBER starting count for lnk#.dat files produced by -crawl" +," -localhost disable URLs that point to remote hosts" +#if defined(USE_HASH) +," -lss=FILENAME specifies a lynx.css file other than the default" #endif - ParseFunc fun; - char *next_arg = NULL; - - if ((p->name[0] != *arg_name) - || (0 == arg_eqs_parse (p->name, arg_name, &next_arg))) { - p++; - continue; - } - - if ((p->type & NEED_NEXT_ARG) && (next_arg == 0)) { - next_arg = argv[1]; - if ((i != 0) && (next_arg != 0)) - (*i)++; - } - - switch (p->type & ARG_TYPE_MASK) { - case TOGGLE_ARG: /* FALLTHRU */ - case SET_ARG: /* FALLTHRU */ - case UNSET_ARG: - if (q->set_value != 0) { - if (next_arg == 0) { - switch (p->type & ARG_TYPE_MASK) { - case TOGGLE_ARG: - *(q->set_value) = !(*(q->set_value)); - break; - case SET_ARG: - *(q->set_value) = TRUE; - break; - case UNSET_ARG: - *(q->set_value) = FALSE; - break; - } - } else if (is_true(next_arg)) { - *(q->set_value) = TRUE; - } else if (is_false(next_arg)) { - *(q->set_value) = FALSE; - } - /* deliberately ignore anything else - BL */ - } - break; - - case FUNCTION_ARG: - fun = q->fun_value; - if (0 != fun) { - if (-1 == (*fun) (p, argv, next_arg)) { - } - } - break; - - case LYSTRING_ARG: - if ((q->str_value != 0) && (next_arg != 0)) - StrAllocCopy(*(q->str_value), next_arg); - break; - - case INT_ARG: - if ((q->int_value != 0) && (next_arg != 0)) - *(q->int_value) = atoi (next_arg); - break; - - case STRING_ARG: - if ((q->str_value != 0) && (next_arg != 0)) - *(q->str_value) = next_arg; - break; - - case IGNORE_ARG: - break; - } - - return; - } - - if (pgm == 0) pgm = "LYNX"; +," -mime_header include mime headers and force source dump" +," -minimal toggles minimal versus valid comment parsing" +," -newschunksize=NUMBER number of articles in chunked news listings" +," -newsmaxchunk=NUMBER maximum news articles in listings before chunking" +," -nobrowse disable directory browsing" +," -nocc disable Cc: prompts for self copies of mailings" +," -nofilereferer disable transmissions of Referer headers for file URLs" +," -nolist disable the link list feature in dumps" +," -nolog disable mailing of error messages to document owners" +," -nopause disable forced pauses for statusline messages" +," -noprint disable print functions" +," -noredir don't follow Location: redirection" +," -noreferer disable transmissions of Referer headers" +#ifdef SOCKS +," -nosocks don't use SOCKS proxy for this session" +#endif /* SOCKS */ +," -nostatus disable the miscellaneous information messages" +," -number_links force numbering of links" +," -pauth=id:pw authentication information for protected proxy server" +," -popup toggles handling of single-choice SELECT options via" +," popup windows or as lists of radio buttons" +," -post_data user data for post forms, read from stdin," +," terminated by '---' on a line" +," -preparsed show parsed text/html with -source and in source view" +," -print enable print functions (DEFAULT)" +," -pseudo_inlines toggles pseudo-ALTs for inlines with no ALT string" +," -raw toggles default setting of 8-bit character translations" +," or CJK mode for the startup character set" +," -realm restricts access to URLs in the starting realm" +," -reload flushes the cache on a proxy server" +," (only the first document affected)" +," -restrictions=[options] use -restrictions to see list" +," -resubmit_posts toggles forced resubmissions (no-cache) of forms with" +," method POST when the documents they returned are sought" +," with the PREV_DOC command or from the History List" +," -rlogin disable rlogins" +," -selective require .www_browsable files to browse directories" +," -show_cursor toggles hiding of the cursor in the lower right corner" +," -soft_dquotes toggles emulation of the old Netscape and Mosaic bug which" +," treated '>' as a co-terminator for double-quotes and tags" +," -source dump the source of the first file to stdout and exit" +," -startfile_ok allow non-http startfile and homepage with -validate" +#ifndef VMS +#ifdef SYSLOG_REQUESTED_URLS +," -syslog=text information for syslog call" +#endif /* SYSLOG_REQUESTED_URLS */ +#endif /* !VMS */ +," -telnet disable telnets" +," -term=TERM set terminal type to TERM" +," -tlog toggles use of a Lynx Trace Log for the current session" +," -trace turns on Lynx trace mode" +," -traversal traverse all http links derived from startfile" +," -underscore toggles use of _underline_ format in dumps" +," -useragent=Name set alternate Lynx User-Agent header" +#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) +," -use_mouse enable use of the mouse" +#endif +," -validate accept only http URLs (for validation)" +," -version print Lynx version information" +," -vikeys enable vi-like key movement" +," -width=NUMBER screen width for formatting of dumps (default is 80)" + }; + size_t n; + for (n = 0; n < sizeof(Options)/sizeof(Options[0]); n++) + printf("%s\n", Options[n]); + } + if (strncmp(argv[0], "-help", 5) != 0) + exit(-1); + exit(0); + break; - fprintf (stderr, "%s: Invalid Option: %s\n", pgm, argv[0]); - print_help_and_exit (-1); + } /* end of switch. */ } #ifndef VMS diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 87a751bd..fa1ba6a1 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTAccess.h> #include <HTParse.h> #include <HTList.h> @@ -27,6 +28,7 @@ #include <LYEdit.h> #include <LYShowInfo.h> #include <LYBookmark.h> +#include <LYSystem.h> #include <LYKeymap.h> #include <LYJump.h> #include <LYDownload.h> @@ -37,14 +39,17 @@ #include <LYCharUtils.h> #include <LYCookie.h> #include <LYMainLoop.h> +#ifdef DOSPATH +#include <HTDOS.h> +#endif #ifdef USE_EXTERNALS #include <LYExtern.h> #endif -#ifdef __EMX__ -#include <io.h> -#endif +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ #ifdef DIRED_SUPPORT #include <LYLocal.h> @@ -79,15 +84,12 @@ PRIVATE int sametext ARGS2( } #endif /* FASTTAB */ +#define FREE(x) if (x) {free(x); x = NULL;} + PUBLIC HTList * Goto_URLs = NULL; /* List of Goto URLs */ PUBLIC char * LYRequestTitle = NULL; /* newdoc.title in calls to getfile() */ -#ifdef DISP_PARTIAL -PUBLIC int Newline_partial = 0; /* required for display_partial mode */ -PUBLIC int NumOfLines_partial = -1; /* required for display_partial mode */ -#endif - PRIVATE document newdoc; PRIVATE document curdoc; PRIVATE char *traversal_host = NULL; @@ -127,45 +129,6 @@ PRIVATE void free_mainloop_variables NOARGS return; } -PUBLIC FILE *TraceFP NOARGS -{ - if (LYTraceLogFP != 0) { - return LYTraceLogFP; - } - return stderr; -} - -PRIVATE void TracelogOpenFailed NOARGS -{ - WWW_TraceFlag = FALSE; - HTUserMsg(TRACELOG_OPEN_FAILED); -} - -PUBLIC void LYCloseTracelog NOARGS -{ - if (LYTraceLogFP != 0) { - fflush(stdout); - fflush(stderr); - fclose(LYTraceLogFP); - LYTraceLogFP = 0; - } -} - -PRIVATE BOOLEAN LYReopenTracelog ARGS1(BOOLEAN *, trace_flag_ptr) -{ - CTRACE(tfp, "\nTurning off TRACE for fetch of log.\n"); - LYCloseTracelog(); - if ((LYTraceLogFP = LYAppendToTxtFile(LYTraceLogPath)) == NULL) { - TracelogOpenFailed(); - return FALSE; - } - if (TRACE) { - WWW_TraceFlag = FALSE; - *trace_flag_ptr = TRUE; - } - return TRUE; -} - /* * Here's where we do all the work. * mainloop is basically just a big switch dependent on the users input. @@ -197,22 +160,15 @@ int mainloop NOARGS BOOLEAN rlink_allowed; BOOLEAN vi_keys_flag = vi_keys; BOOLEAN emacs_keys_flag = emacs_keys; - BOOLEAN LYRawMode_flag = LYRawMode; -#ifndef NO_OPTION_MENU - BOOLEAN LYSelectPopups_flag = LYSelectPopups; - BOOLEAN verbose_img_flag = verbose_img; BOOLEAN keypad_mode_flag = keypad_mode; - BOOLEAN show_dotfiles_flag = show_dotfiles; BOOLEAN user_mode_flag = user_mode; - int CurrentAssumeCharSet_flag = UCLYhndl_for_unspec; + BOOLEAN HTfileSortMethod_flag = HTfileSortMethod; int CurrentCharSet_flag = current_char_set; - int HTfileSortMethod_flag = HTfileSortMethod; -#endif + BOOLEAN show_dotfiles_flag = show_dotfiles; + BOOLEAN LYRawMode_flag = LYRawMode; + BOOLEAN LYSelectPopups_flag = LYSelectPopups; BOOLEAN trace_mode_flag = FALSE; BOOLEAN forced_HTML_mode = LYforce_HTML_mode; -#ifdef DISP_PARTIAL - BOOLEAN display_partial_flag = display_partial; -#endif char cfile[128]; FILE *cfp; char *cp, *toolbar; @@ -284,7 +240,8 @@ initialize: refresh(); } #endif /* USE_SLANG */ - CTRACE(tfp,"Entering mainloop, startfile=%s\n",startfile); + if (TRACE) + fprintf(stderr,"Entering mainloop, startfile=%s\n",startfile); if (form_post_data) { StrAllocCopy(newdoc.post_data, form_post_data); @@ -296,11 +253,13 @@ initialize: if (bookmark_start) { if (LYValidate) { - HTAlert(BOOKMARKS_DISABLED); + _statusline(BOOKMARKS_DISABLED); + sleep(AlertSecs); bookmark_start = FALSE; goto initialize; } else if (traversal) { - HTAlert(BOOKMARKS_NOT_TRAVERSED); + _statusline(BOOKMARKS_NOT_TRAVERSED); + sleep(AlertSecs); traversal = FALSE; crawl = FALSE; bookmark_start = FALSE; @@ -319,9 +278,11 @@ initialize: FREE(newdoc.post_content_type); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; - CTRACE(tfp, "Using bookmarks=%s\n", newdoc.address); + if (TRACE) + fprintf(stderr, "Using bookmarks=%s\n", newdoc.address); } else { - HTUserMsg(BOOKMARKS_NOT_OPEN); + _statusline(BOOKMARKS_NOT_OPEN); + sleep(MessageSecs); bookmark_start = FALSE; goto initialize; } @@ -369,8 +330,7 @@ try_again: * elements to the curdoc structure elements * under case NORMAL. - FM */ - if (strncmp(newdoc.address, "LYNXDOWNLOAD:", 13)) - { + if (strncmp(newdoc.address, "LYNXDOWNLOAD:", 13)) { LYpush(&curdoc, ForcePush); } } else if (!newdoc.address) { @@ -472,11 +432,26 @@ try_again: WWWDoc.safe = newdoc.safe; tmpanchor = HTAnchor_parent(HTAnchor_findAddress(&WWWDoc)); if ((HText *)HTAnchor_document(tmpanchor) == NULL) { - if (!LYReopenTracelog(&trace_mode_flag)) { + if (TRACE) + fprintf(stderr, + "\nTurning off TRACE for fetch of log.\n"); + fflush(stdout); + fflush(stderr); + fclose(LYTraceLogFP); + *stderr = LYOrigStderr; + if ((LYTraceLogFP = LYAppendToTxtFile(LYTraceLogPath)) == NULL) { + WWW_TraceFlag = FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); old_c = 0; cmd = LYK_PREV_DOC; goto new_cmd; } + *stderr = *LYTraceLogFP; + if (TRACE) { + WWW_TraceFlag = FALSE; + trace_mode_flag = TRUE; + } } } @@ -491,29 +466,6 @@ try_again: LYPermitURL = TRUE; } -#ifdef DISP_PARTIAL - display_partial = display_partial_flag; /* restore */ - Newline_partial = newdoc.line; /* initialize */ - NumOfLines_partial = -1; /* initialize to -1 */ - /* -1 restrict HTDisplayPartial() */ - /* until HText_new() start new HTMainText */ - /* and set the flag to 0 */ - if (display_partial) { - /* - * Disable display_partial if requested URL has #fragment - * and we are not popped from the history stack - * so can't calculate correct newline position for fragment. - * Otherwise user got the new document from the first page - * and be moved to #fragment later after download - * completed, but only if s/he did not mess screen up by - * scrolling before... So fall down to old behavior here. - */ - if (!LYCursesON || - (Newline_partial == 1 && strchr(newdoc.address, '#'))) - display_partial = FALSE; - } -#endif /* DISP_PARTIAL */ - #ifndef DONT_TRACK_INTERNAL_LINKS if (try_internal) { if (newdoc.address && @@ -578,7 +530,7 @@ try_again: if (trace_mode_flag == TRUE) { WWW_TraceFlag = TRUE; trace_mode_flag = FALSE; - fprintf(tfp, "Turning TRACE back on.\n\n"); + fprintf(stderr, "Turning TRACE back on.\n\n"); } if (error_logging && first_file && owner_address && !LYCancelledFetch) { @@ -640,14 +592,8 @@ 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); @@ -675,7 +621,7 @@ try_again: if (trace_mode_flag == TRUE) { WWW_TraceFlag = TRUE; trace_mode_flag = FALSE; - fprintf(tfp, "Turning TRACE back on.\n\n"); + fprintf(stderr, "Turning TRACE back on.\n\n"); } FREE(newdoc.address); /* to pop last doc */ FREE(newdoc.bookmark); @@ -744,13 +690,9 @@ 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 @@ -815,9 +757,10 @@ try_again: } cmd = LYK_PREV_DOC; goto new_cmd; - } + } override_LYresubmit_posts = TRUE; goto try_again; + break; case NORMAL: /* @@ -828,7 +771,7 @@ try_again: if (trace_mode_flag == TRUE) { WWW_TraceFlag = TRUE; trace_mode_flag = FALSE; - fprintf(tfp, "Turning TRACE back on.\n\n"); + fprintf(stderr, "Turning TRACE back on.\n\n"); } *prev_target = '\0'; /* Reset for this document. - FM */ @@ -845,7 +788,15 @@ try_again: BOOKMARK_TITLE))) && (temp = HTParse(newdoc.address, "", PARSE_PATH+PARSE_PUNCTUATION)) != NULL) { - cp = wwwName(Home_Dir()); +#ifdef DOSPATH + cp = HTDOS_wwwName((char *)Home_Dir()); +#else +#ifdef VMS + cp = HTVMS_wwwName((char *)Home_Dir()); +#else + cp = (char *)Home_Dir(); +#endif /* VMS */ +#endif /* DOSPATH */ len = strlen(cp); #ifdef VMS if (!strncasecomp(temp, cp, len) && @@ -892,7 +843,8 @@ try_again: if (i <= MBM_V_MAXFILES) { FREE(temp); if (LYValidate) { - HTAlert(BOOKMARKS_DISABLED); + _statusline(BOOKMARKS_DISABLED); + sleep(AlertSecs); return(-1); } if ((temp = HTParse(newdoc.address, "", @@ -900,8 +852,17 @@ try_again: StrAllocCopy(newdoc.address, temp); HTuncache_current_document(); FREE(curdoc.address); +#ifdef DOSPATH StrAllocCat(newdoc.address, - wwwName(Home_Dir())); + HTDOS_wwwName((char *)Home_Dir())); +#else +#ifdef VMS + StrAllocCat(newdoc.address, + HTVMS_wwwName((char *)Home_Dir())); +#else + StrAllocCat(newdoc.address, Home_Dir()); +#endif /* VMS */ +#endif /* DOSPATH */ StrAllocCat(newdoc.address, "/"); StrAllocCat(newdoc.address, (strncmp(BookmarkPage, "./", 2) ? @@ -922,7 +883,9 @@ try_again: if (!strcmp(homepage, startfile)) StrAllocCopy(homepage, newdoc.address); StrAllocCopy(startfile, newdoc.address); - CTRACE(tfp, "Reloading as bookmarks=%s\n", + if (TRACE) + fprintf(stderr, + "Reloading as bookmarks=%s\n", newdoc.address); goto try_again; } @@ -976,22 +939,6 @@ try_again: * before, or it is 1 if this is a new file. */ Newline = newdoc.line; -#ifdef DISP_PARTIAL - if (display_partial) { - /* - * Override newdoc.line with a new value if user - * scrolled the document while downloading. - */ - if (Newline_partial != newdoc.line - && NumOfLines_partial > 0) - Newline = Newline_partial; - - /* - * End of incremental rendering stage here. - */ - display_partial = FALSE; - } -#endif /* DISP_PARTIAL */ /* * If we are going to a target line or @@ -1045,7 +992,7 @@ try_again: } else if (!dump_output_immediately) { StrAllocCopy(curdoc.title, newdoc.title); } - owner_address = (char *)HText_getOwner(); + owner_address = HText_getOwner(); curdoc.safe = HTLoadedDocumentIsSafe(); if (!dump_output_immediately) { LYAddVisitedLink(&curdoc); @@ -1129,7 +1076,9 @@ try_again: FREE(temp); if (!(temp = HTParse(curdoc.address, "", PARSE_PATH+PARSE_PUNCTUATION))) { - LYAddHtmlSep(&startrealm); + if (startrealm[strlen(startrealm)-1] != '/') { + StrAllocCat(startrealm, "/"); + } } else { if (forced_HTML_mode && !dump_output_immediately && @@ -1162,7 +1111,9 @@ try_again: } } FREE(temp); - CTRACE(tfp, "Starting realm is '%s'\n\n", startrealm); + if (TRACE) { + fprintf(stderr, "Starting realm is '%s'\n\n", startrealm); + } if (traversal) { /* * Set up the crawl output stuff. @@ -1187,11 +1138,16 @@ try_again: StrAllocCopy(traversal_host, "None"); } else { StrAllocCopy(traversal_host, temp); - LYAddHtmlSep(&traversal_host); + if (traversal_host[strlen(traversal_host)-1] != '/') { + StrAllocCat(traversal_host, "/"); + } } FREE(temp); } - CTRACE(tfp, "Traversal host is '%s'\n\n", traversal_host); + if (TRACE) { + fprintf(stderr, + "Traversal host is '%s'\n\n", traversal_host); + } } if (startfile) { /* @@ -1309,8 +1265,8 @@ try_again: /* * Report unread or new mail, if appropriate. */ - if (check_mail && !no_mail) - LYCheckMail(); + if (check_mail && !no_mail && LYCheckMail()) + sleep(MessageSecs); /* * If help is not on the screen, @@ -1347,7 +1303,7 @@ try_again: (links[curdoc.link].type & WWW_LINK_TYPE))) { #endif /* NORMAL_NON_FORM_LINK_STATUSLINES_FOR_ALL_USER_MODES */ #endif /* INDICATE_FORMS_MODE_FOR_ALL_LINKS_ON_PAGE */ - if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) { + if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) switch(links[curdoc.link].form->type) { case F_PASSWORD_TYPE: if (links[curdoc.link].form->disabled == YES) @@ -1420,15 +1376,14 @@ try_again: statusline(FORM_LINK_TEXT_MESSAGE); break; } - } else { + else statusline(NORMAL_LINK_MESSAGE); - } /* * Let them know if it's an index -- very rare. */ if (is_www_index) { - move(LYlines-1, LYcols-8); + move(LYlines-1,LYcols-8); start_reverse(); addstr("-index-"); stop_reverse(); @@ -1445,18 +1400,17 @@ try_again: } if (!cp) cp = links[curdoc.link].lname; - if (more) { + if (more) if (is_www_index) _user_message("-more- -index- %s", cp); else _user_message("-more- %s",cp); - } else { + else if (is_www_index) _user_message("-index- %s",cp); else statusline(cp); - } } else if (is_www_index && more) { char buf[128]; @@ -1552,7 +1506,7 @@ try_again: addstr(FORM_NOVICELINE_TWO); } c = change_form_link(&links[curdoc.link], - &newdoc, &refresh_screen, + FORM_UP, &newdoc, &refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); @@ -1705,8 +1659,8 @@ new_keyboard_input: cmd = keymap[c+1]; /* add 1 to map EOF to 0 */ #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) - if (lynx_edit_mode && key_override[c+1] && !no_dired_support) - cmd = key_override[c+1]; + if (lynx_edit_mode && override[c+1] && !no_dired_support) + cmd = override[c+1]; #endif /* DIRED_SUPPORT && OK_OVERRIDE */ real_cmd = cmd; @@ -1822,7 +1776,8 @@ new_cmd: /* StrAllocCopy(newdoc.address, curdoc.address); StrAllocCopy(newdoc.title, curdoc.title); newdoc.internal_link = curdoc.internal_link; - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); if (nlinks > 0) HText_pageDisplay(curdoc.line, prev_target); break; @@ -1840,7 +1795,8 @@ new_cmd: /* FREE(newdoc.post_data); FREE(newdoc.post_content_type); newdoc.internal_link = FALSE; - HTAlert(DISCARDING_POST_DATA); + _statusline(DISCARDING_POST_DATA); + sleep(AlertSecs); } } } @@ -1899,7 +1855,8 @@ new_cmd: /* StrAllocCopy(temp, user_input_buffer); sprintf(user_input_buffer, LINK_ALREADY_CURRENT, number); - HTUserMsg(user_input_buffer); + _statusline(user_input_buffer); + sleep(MessageSecs); strcpy(user_input_buffer, temp); FREE(temp); } else { @@ -1931,23 +1888,26 @@ new_cmd: /* * users (like me 8-). - FM */ if (Newline <= 1) { - HTInfoMsg(ALREADY_AT_BEGIN); + _statusline(ALREADY_AT_BEGIN); } else if (!more) { - HTInfoMsg(ALREADY_AT_END); + _statusline(ALREADY_AT_END); } else { StrAllocCopy(temp, user_input_buffer); sprintf(user_input_buffer, ALREADY_AT_PAGE, number); - HTUserMsg(user_input_buffer); + _statusline(user_input_buffer); + sleep(MessageSecs); strcpy(user_input_buffer, temp); FREE(temp); } + sleep(MessageSecs); } break; case PRINT_ERROR: old_c = real_c; - HTUserMsg(BAD_LINK_NUM_ENTERED); + _statusline(BAD_LINK_NUM_ENTERED); + sleep(MessageSecs); break; } break; @@ -1962,7 +1922,8 @@ new_cmd: /* curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, curdoc.title, 1, 1) == FALSE) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } @@ -1986,7 +1947,8 @@ new_cmd: /* if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && HTConfirm(CONFIRM_POST_RESUBMISSION) == FALSE) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } @@ -2017,10 +1979,13 @@ new_cmd: /* * page, lynx_mode won't have this setting and we won't * know that this warning should be issued. - FM */ - HTAlert(RELOADING_FORM); + _statusline(RELOADING_FORM); + sleep(AlertSecs); } - newdoc.line = curdoc.line; - newdoc.link = curdoc.link; + newdoc.line = ((curdoc.line > 0) ? + curdoc.line : 1); + newdoc.link = ((curdoc.link > -1) ? + curdoc.link : 0); #endif /* NO_ASSUME_SAME_DOC */ FREE(curdoc.address); /* so it doesn't get pushed */ #ifdef VMS @@ -2038,7 +2003,7 @@ new_cmd: /* reloading = TRUE; break; - case LYK_HISTORICAL: /* toggle 'historical' comments parsing */ + case LYK_HISTORICAL: /* * Check if this is a reply from a POST, and if so, * seek confirmation of reload if the safe element @@ -2048,28 +2013,28 @@ new_cmd: /* curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 0, 0) == FALSE) { - HTInfoMsg(WILL_NOT_RELOAD_DOC); + _statusline(WILL_NOT_RELOAD_DOC); + sleep(InfoSecs); } else { HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); FREE(curdoc.address); - newdoc.line = curdoc.line; - newdoc.link = curdoc.link; } if (historical_comments) historical_comments = FALSE; else historical_comments = TRUE; if (minimal_comments) { - HTAlert(historical_comments ? + _statusline(historical_comments ? HISTORICAL_ON_MINIMAL_OFF : HISTORICAL_OFF_MINIMAL_ON); } else { - HTAlert(historical_comments ? + _statusline(historical_comments ? HISTORICAL_ON_VALID_OFF : HISTORICAL_OFF_VALID_ON); } + sleep(AlertSecs); break; - case LYK_MINIMAL: /* toggle 'minimal' comments parsing */ + case LYK_MINIMAL: if (!historical_comments) { /* * Check if this is a reply from a POST, and if so, @@ -2080,13 +2045,12 @@ new_cmd: /* curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 0, 0) == FALSE) { - HTInfoMsg(WILL_NOT_RELOAD_DOC); + _statusline(WILL_NOT_RELOAD_DOC); + sleep(InfoSecs); } else { HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); FREE(curdoc.address); - newdoc.line = curdoc.line; - newdoc.link = curdoc.link; } } if (minimal_comments) @@ -2094,12 +2058,13 @@ new_cmd: /* else minimal_comments = TRUE; if (!historical_comments) { - HTAlert(minimal_comments ? + _statusline(minimal_comments ? MINIMAL_ON_IN_EFFECT : MINIMAL_OFF_VALID_ON); } else { - HTAlert(minimal_comments ? + _statusline(minimal_comments ? MINIMAL_ON_BUT_HISTORICAL : MINIMAL_OFF_HISTORICAL_ON); } + sleep(AlertSecs); break; case LYK_SOFT_DQUOTES: @@ -2112,20 +2077,20 @@ new_cmd: /* curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 1, 1) == FALSE) { - HTInfoMsg(WILL_NOT_RELOAD_DOC); + _statusline(WILL_NOT_RELOAD_DOC); + sleep(InfoSecs); } else { HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); FREE(curdoc.address); - newdoc.line = curdoc.line; - newdoc.link = curdoc.link; } if (soft_dquotes) soft_dquotes = FALSE; else soft_dquotes = TRUE; - HTUserMsg(soft_dquotes ? + _statusline(soft_dquotes ? SOFT_DOUBLE_QUOTE_ON : SOFT_DOUBLE_QUOTE_OFF); + sleep(MessageSecs); break; case LYK_SWITCH_DTD: @@ -2138,7 +2103,8 @@ new_cmd: /* curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, NULL, 1, 1) == FALSE) { - HTInfoMsg(WILL_NOT_RELOAD_DOC); + _statusline(WILL_NOT_RELOAD_DOC); + sleep(InfoSecs); } else { /* * If currently viewing preparsed source, switching @@ -2153,18 +2119,19 @@ new_cmd: /* FREE(curdoc.address); } #ifdef NO_ASSUME_SAME_DOC - newdoc.line = 1; - newdoc.link = 0; + newdoc.line=1; + newdoc.link=0; #else - newdoc.line = curdoc.line; - newdoc.link = curdoc.link; + newdoc.line = ((curdoc.line > 0) ? curdoc.line : 1); + newdoc.link = ((curdoc.link > -1) ? curdoc.link : 0); #endif /* NO_ASSUME_SAME_DOC */ if (New_DTD) New_DTD = NO; else New_DTD = YES; HTSwitchDTD(New_DTD); - HTUserMsg(New_DTD ? USING_DTD_1 : USING_DTD_0); + _statusline(New_DTD ? USING_DTD_1 : USING_DTD_0); + sleep(MessageSecs); break; #ifdef NOT_DONE_YET @@ -2185,17 +2152,20 @@ new_cmd: /* c != 7) { return(0); } else { - HTInfoMsg(NO_CANCEL); + statusline(NO_CANCEL); + sleep(InfoSecs); } } else if (TOUPPER(c) == 'Y') { return(0); } else { - HTInfoMsg(NO_CANCEL); + statusline(NO_CANCEL); + sleep(InfoSecs); } break; case LYK_ABORT: /* don't ask the user about quitting */ return(0); + break; case LYK_NEXT_PAGE: /* next page */ if (more) { @@ -2205,7 +2175,8 @@ new_cmd: /* curdoc.link = nlinks-1; /* put on last link */ } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_END); + _statusline(ALREADY_AT_END); + sleep(MessageSecs); } break; @@ -2217,7 +2188,8 @@ new_cmd: /* curdoc.link = 0; /* put on first link */ } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_BEGIN); + _statusline(ALREADY_AT_BEGIN); + sleep(MessageSecs); } break; @@ -2236,7 +2208,8 @@ new_cmd: /* } } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_BEGIN); + _statusline(ALREADY_AT_BEGIN); + sleep(MessageSecs); } break; @@ -2251,7 +2224,8 @@ new_cmd: /* } } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_END); + _statusline(ALREADY_AT_END); + sleep(MessageSecs); } break; @@ -2273,7 +2247,8 @@ new_cmd: /* } } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_BEGIN); + _statusline(ALREADY_AT_BEGIN); + sleep(MessageSecs); } break; @@ -2288,7 +2263,8 @@ new_cmd: /* } } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_END); + _statusline(ALREADY_AT_END); + sleep(MessageSecs); } break; @@ -2308,7 +2284,7 @@ new_cmd: /* case LYK_END: if (more) { - Newline = lines_in_file - display_lines + 3; /* go to end of file */ + Newline = MAXINT; /* go to end of file */ arrowup = TRUE; /* position on last link */ } else { cmd = LYK_NEXT_PAGE; @@ -2354,7 +2330,8 @@ new_cmd: /* } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_BEGIN); + _statusline(ALREADY_AT_BEGIN); + sleep(MessageSecs); } break; @@ -2396,7 +2373,8 @@ new_cmd: /* } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_END); + _statusline(ALREADY_AT_END); + sleep(MessageSecs); } break; @@ -2425,7 +2403,8 @@ new_cmd: /* #else } else if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_LINKS_ABOVE); + _statusline(NO_LINKS_ABOVE); + sleep(MessageSecs); #endif /* NOTDEFINED */ } @@ -2455,7 +2434,8 @@ new_cmd: /* } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_BEGIN); + _statusline(ALREADY_AT_BEGIN); + sleep(MessageSecs); } break; @@ -2481,7 +2461,8 @@ new_cmd: /* Newline += (display_lines); } else if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_LINKS_BELOW); + _statusline(NO_LINKS_BELOW); + sleep(MessageSecs); break; } #ifdef NOTDEFINED @@ -2498,7 +2479,8 @@ new_cmd: /* } else if (old_c != real_c) { old_c = real_c; - HTInfoMsg(ALREADY_AT_END); + _statusline(ALREADY_AT_END); + sleep(MessageSecs); } break; @@ -2648,12 +2630,14 @@ new_cmd: /* goto new_cmd; } if (nhist == 1) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); old_c = 0; cmd = LYK_DO_NOTHING; goto new_cmd; } else { - HTUserMsg2(WWW_SKIP_MESSAGE, WWWDoc.address); + _user_message(WWW_SKIP_MESSAGE, WWWDoc.address); + sleep(MessageSecs); do { LYpop(&curdoc); } while (nhist > 1 && !are_different( @@ -2691,7 +2675,8 @@ new_cmd: /* } else if (old_c != real_c) { old_c = real_c; - HTUserMsg(ALREADY_AT_FIRST); + _statusline(ALREADY_AT_FIRST); + sleep(MessageSecs); } break; @@ -2703,7 +2688,8 @@ new_cmd: /* if (old_c == real_c) break; old_c = real_c; - HTUserMsg(NOT_ON_SUBMIT_OR_LINK); + _statusline(NOT_ON_SUBMIT_OR_LINK); + sleep(MessageSecs); break; } else { LYforce_no_cache = TRUE; @@ -2742,7 +2728,8 @@ new_cmd: /* if (!links[curdoc.link].form->submit_action || *links[curdoc.link].form->submit_action == '\0') { - HTUserMsg(NO_FORM_ACTION); + _statusline(NO_FORM_ACTION); + sleep(MessageSecs); HTOutputFormat = WWW_PRESENT; LYforce_no_cache = FALSE; reloading = FALSE; @@ -2821,8 +2808,11 @@ new_cmd: /* links[curdoc.link].form->submit_action, "lynxprog:", 9)) { HTAlert(SPECIAL_ACTION_DISALLOWED); - CTRACE(tfp, "LYMainLoop: Rejected '%s'\n", + if (TRACE) { + fprintf(stderr, + "LYMainLoop: Rejected '%s'\n", links[curdoc.link].form->submit_action); + } HTOutputFormat = WWW_PRESENT; LYforce_no_cache = FALSE; reloading = FALSE; @@ -2857,7 +2847,7 @@ new_cmd: /* links[curdoc.link].hightext); } c = change_form_link(&links[curdoc.link], - &newdoc, &refresh_screen, + FORM_UP, &newdoc, &refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); if (HTOutputFormat == HTAtom_for("www/download") && @@ -2865,7 +2855,8 @@ new_cmd: /* newdoc.safe == FALSE) { if ((HText_POSTReplyLoaded(&newdoc) == TRUE) && HTConfirm(CONFIRM_POST_RESUBMISSION) == FALSE) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); HTOutputFormat = WWW_PRESENT; LYforce_no_cache = FALSE; StrAllocCopy(newdoc.address, curdoc.address); @@ -3021,7 +3012,8 @@ new_cmd: /* StrAllocCopy(newdoc.address, curdoc.address); StrAllocCopy(newdoc.title, curdoc.title); newdoc.internal_link = curdoc.internal_link; - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } else if (LYresubmit_posts && cmd != LYK_NOCACHE) { @@ -3039,7 +3031,8 @@ new_cmd: /* FREE(newdoc.post_data); FREE(newdoc.post_content_type); newdoc.internal_link = FALSE; - HTAlert(DISCARDING_POST_DATA); + _statusline(DISCARDING_POST_DATA); + sleep(AlertSecs); } } } @@ -3116,7 +3109,8 @@ new_cmd: /* */ if (old_c != real_c) { old_c = real_c; - HTUserMsg(GOTO_DISALLOWED); + _statusline(GOTO_DISALLOWED); + sleep(MessageSecs); } break; } @@ -3131,7 +3125,8 @@ new_cmd: /* */ if (old_c != real_c) { old_c = real_c; - HTUserMsg(NOT_ON_SUBMIT_OR_LINK); + _statusline(NOT_ON_SUBMIT_OR_LINK); + sleep(MessageSecs); } break; } @@ -3143,7 +3138,8 @@ new_cmd: /* */ if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_FORM_ACTION); + _statusline(NO_FORM_ACTION); + sleep(MessageSecs); } break; } @@ -3164,7 +3160,8 @@ new_cmd: /* */ if (old_c != real_c) { old_c = real_c; - HTUserMsg(EDIT_FM_MENU_URLS_DISALLOWED); + _statusline(EDIT_FM_MENU_URLS_DISALLOWED); + sleep(MessageSecs); } break; } @@ -3205,7 +3202,7 @@ new_cmd: /* HTUnEscapeSome(user_input_buffer, " \r\n\t"); convert_to_spaces(user_input_buffer, TRUE); } else { - LYRemoveBlanks(user_input_buffer); + collapse_spaces(user_input_buffer); } if (user_input_buffer[0] != '\0') { goto check_goto_URL; @@ -3215,7 +3212,8 @@ new_cmd: /* * User cancelled via ^G, a full deletion, * or not modifying the URL. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); strcpy(user_input_buffer, temp); FREE(temp); break; @@ -3227,7 +3225,8 @@ new_cmd: /* */ if (old_c != real_c) { old_c = real_c; - HTUserMsg(GOTO_DISALLOWED); + _statusline(GOTO_DISALLOWED); + sleep(MessageSecs); } break; } @@ -3246,7 +3245,8 @@ new_cmd: /* */ if (old_c != real_c) { old_c = real_c; - HTUserMsg(EDIT_FM_MENU_URLS_DISALLOWED); + _statusline(EDIT_FM_MENU_URLS_DISALLOWED); + sleep(MessageSecs); } break; } @@ -3289,7 +3289,7 @@ new_cmd: /* HTUnEscapeSome(user_input_buffer, " \r\n\t"); convert_to_spaces(user_input_buffer, TRUE); } else { - LYRemoveBlanks(user_input_buffer); + collapse_spaces(user_input_buffer); } if (user_input_buffer[0] != '\0') { goto check_goto_URL; @@ -3299,7 +3299,8 @@ new_cmd: /* * User cancelled via ^G, a full deletion, * or not modifying the URL. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); strcpy(user_input_buffer, temp); FREE(temp); break; @@ -3308,7 +3309,8 @@ new_cmd: /* if (no_goto && !LYValidate) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(GOTO_DISALLOWED); + _statusline(GOTO_DISALLOWED); + sleep(MessageSecs); } break; } @@ -3340,7 +3342,8 @@ new_cmd: /* */ strcpy(user_input_buffer, temp); FREE(temp); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } @@ -3361,13 +3364,14 @@ check_recall: HTUnEscapeSome(user_input_buffer, " \r\n\t"); convert_to_spaces(user_input_buffer, TRUE); } else { - LYRemoveBlanks(user_input_buffer); + collapse_spaces(user_input_buffer); } if (*user_input_buffer == '\0' && !(recall && (ch == UPARROW || ch == DNARROW))) { strcpy(user_input_buffer, temp); FREE(temp); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } if (recall && ch == UPARROW) { @@ -3409,7 +3413,8 @@ check_recall: */ strcpy(user_input_buffer, temp); FREE(temp); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } goto check_recall; @@ -3453,7 +3458,8 @@ check_recall: */ strcpy(user_input_buffer, temp); FREE(temp); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } goto check_recall; @@ -3472,7 +3478,8 @@ check_goto_URL: FREE(temp); if ((no_file_url || no_goto_file) && !strncmp(user_input_buffer,"file:",5)) { - HTUserMsg(GOTO_FILE_DISALLOWED); + _statusline(GOTO_FILE_DISALLOWED); + sleep(MessageSecs); } else if ((no_shell || no_goto_lynxexec #ifdef EXEC_LINKS @@ -3480,7 +3487,8 @@ check_goto_URL: #endif /* EXEC_LINKS */ ) && !strncmp(user_input_buffer, "lynxexec:",9)) { - HTUserMsg(GOTO_EXEC_DISALLOWED); + _statusline(GOTO_EXEC_DISALLOWED); + sleep(MessageSecs); } else if ((no_shell || no_goto_lynxprog #ifdef EXEC_LINKS @@ -3488,79 +3496,96 @@ check_goto_URL: #endif /* EXEC_LINKS */ ) && !strncmp(user_input_buffer, "lynxprog:",9)) { - HTUserMsg(GOTO_PROG_DISALLOWED); + _statusline(GOTO_PROG_DISALLOWED); + sleep(MessageSecs); } else if ((no_shell || no_goto_lynxcgi) && !strncmp(user_input_buffer, "lynxcgi:", 8)) { - HTUserMsg(GOTO_CGI_DISALLOWED); + _statusline(GOTO_CGI_DISALLOWED); + sleep(MessageSecs); } else if (LYValidate && strncmp(user_input_buffer, "http:", 5) && strncmp(user_input_buffer, "https:", 6)) { - HTUserMsg(GOTO_NON_HTTP_DISALLOWED); + _statusline(GOTO_NON_HTTP_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_cso && !strncmp(user_input_buffer, "cso:", 4)) { - HTUserMsg(GOTO_CSO_DISALLOWED); + _statusline(GOTO_CSO_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_finger && !strncmp(user_input_buffer, "finger:", 7)) { - HTUserMsg(GOTO_FINGER_DISALLOWED); + _statusline(GOTO_FINGER_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_ftp && !strncmp(user_input_buffer, "ftp:", 4)) { - HTUserMsg(GOTO_FTP_DISALLOWED); + _statusline(GOTO_FTP_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_gopher && !strncmp(user_input_buffer, "gopher:", 7)) { - HTUserMsg(GOTO_GOPHER_DISALLOWED); + _statusline(GOTO_GOPHER_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_http && !strncmp(user_input_buffer, "http:", 5)) { - HTUserMsg(GOTO_HTTP_DISALLOWED); + _statusline(GOTO_HTTP_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_https && !strncmp(user_input_buffer, "https:", 6)) { - HTUserMsg(GOTO_HTTPS_DISALLOWED); + _statusline(GOTO_HTTPS_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_mailto && !strncmp(user_input_buffer, "mailto:", 7)) { - HTUserMsg(GOTO_MAILTO_DISALLOWED); + _statusline(GOTO_MAILTO_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_news && !strncmp(user_input_buffer, "news:", 5)) { - HTUserMsg(GOTO_NEWS_DISALLOWED); + _statusline(GOTO_NEWS_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_nntp && !strncmp(user_input_buffer, "nntp:", 5)) { - HTUserMsg(GOTO_NNTP_DISALLOWED); + _statusline(GOTO_NNTP_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_rlogin && !strncmp(user_input_buffer, "rlogin:", 7)) { - HTUserMsg(GOTO_RLOGIN_DISALLOWED); + _statusline(GOTO_RLOGIN_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_snews && !strncmp(user_input_buffer, "snews:", 6)) { - HTUserMsg(GOTO_SNEWS_DISALLOWED); + _statusline(GOTO_SNEWS_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_telnet && !strncmp(user_input_buffer, "telnet:", 7)) { - HTUserMsg(GOTO_TELNET_DISALLOWED); + _statusline(GOTO_TELNET_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_tn3270 && !strncmp(user_input_buffer, "tn3270:", 7)) { - HTUserMsg(GOTO_TN3270_DISALLOWED); + _statusline(GOTO_TN3270_DISALLOWED); + sleep(MessageSecs); } else if (no_goto_wais && !strncmp(user_input_buffer, "wais:", 5)) { - HTUserMsg(GOTO_WAIS_DISALLOWED); + _statusline(GOTO_WAIS_DISALLOWED); + sleep(MessageSecs); } else if (!strncmp(user_input_buffer, "LYNXCOOKIE:", 11) || !strncmp(user_input_buffer, "LYNXDIRED:", 10) || !strncmp(user_input_buffer, "LYNXDOWNLOAD:", 13) || - !strncmp(user_input_buffer, "LYNXOPTIONS:", 12) || !strncmp(user_input_buffer, "LYNXPRINT:", 10)) { - HTUserMsg(GOTO_SPECIAL_DISALLOWED); + _statusline(GOTO_SPECIAL_DISALLOWED); + sleep(MessageSecs); } else { StrAllocCopy(newdoc.address, user_input_buffer); @@ -3618,7 +3643,8 @@ check_goto_URL: if (indexfile[0]=='\0') { /* no defined index */ if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_INDEX_FILE); + _statusline(NO_INDEX_FILE); + sleep(MessageSecs); } } else { @@ -3640,7 +3666,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], - &newdoc, &refresh_screen, + FORM_UP, &newdoc, &refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); /* @@ -3665,7 +3691,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], - &newdoc,&refresh_screen, + FORM_DOWN,&newdoc,&refresh_screen, links[curdoc.link].form->name, links[curdoc.link].form->value); goto new_keyboard_input; @@ -3708,7 +3734,8 @@ check_goto_URL: } else { if (old_c != real_c) { old_c = real_c; - HTUserMsg(IN_MAIN_SCREEN); + _statusline(IN_MAIN_SCREEN); + sleep(MessageSecs); } } break; @@ -3717,10 +3744,7 @@ check_goto_URL: #ifdef DIRED_SUPPORT c = dir_list_style; #endif /* DIRED_SUPPORT */ -#ifndef NO_OPTION_MENU -if (!LYUseFormsOptions) { - - LYoptions(); /* do the old-style options stuff */ + options(); /* do the options stuff */ if (keypad_mode_flag != keypad_mode || (user_mode_flag != user_mode && @@ -3734,8 +3758,6 @@ if (!LYUseFormsOptions) { (!strncmp(curdoc.address, "file:", 5) || !strncmp(curdoc.address, "ftp:", 4))) || CurrentCharSet_flag != current_char_set || - CurrentAssumeCharSet_flag != UCLYhndl_for_unspec || - verbose_img_flag != verbose_img || LYRawMode_flag != LYRawMode || LYSelectPopups_flag != LYSelectPopups || ((strcmp(CurrentUserAgent, (LYUserAgent ? @@ -3755,7 +3777,9 @@ if (!LYUseFormsOptions) { curdoc.safe != TRUE) && confirm_post_resub(curdoc.address, curdoc.title, 2, 1) == FALSE) { - HTInfoMsg(WILL_NOT_RELOAD_DOC); + _statusline(WILL_NOT_RELOAD_DOC); + sleep(InfoSecs); + } else { StrAllocCopy(newdoc.address, curdoc.address); if (((strcmp(CurrentUserAgent, (LYUserAgent ? @@ -3780,7 +3804,8 @@ if (!LYUseFormsOptions) { reloading = TRUE; } if (lynx_mode == FORMS_LYNX_MODE) { - HTAlert(RELOADING_FORM); + _statusline(RELOADING_FORM); + sleep(AlertSecs); } if (HTisDocumentSource()) { HTOutputFormat = WWW_SOURCE; @@ -3791,8 +3816,10 @@ if (!LYUseFormsOptions) { newdoc.line = 1; newdoc.link = 0; #else - newdoc.line = curdoc.line; - newdoc.link = curdoc.link; + newdoc.line = ((curdoc.line > 0) ? + curdoc.line : 1); + newdoc.link = ((curdoc.link > -1) ? + curdoc.link : 0); #endif /* NO_ASSUME_SAME_DOC */ LYforce_no_cache = TRUE; FREE(curdoc.address); /* So it doesn't get pushed. */ @@ -3802,9 +3829,7 @@ if (!LYUseFormsOptions) { user_mode_flag = user_mode; HTfileSortMethod_flag = HTfileSortMethod; CurrentCharSet_flag = current_char_set; - CurrentAssumeCharSet_flag = UCLYhndl_for_unspec; show_dotfiles_flag = show_dotfiles; - verbose_img_flag = verbose_img; LYRawMode_flag = LYRawMode; LYSelectPopups_flag = LYSelectPopups; StrAllocCopy(CurrentUserAgent, (LYUserAgent ? @@ -3815,42 +3840,6 @@ if (!LYUseFormsOptions) { pref_charset : "")); refresh_screen = TRUE; /* to repaint screen */ break; -} /* end if !LYUseFormsOptions */ -#endif /* !NO_OPTION_MENU */ -#ifndef NO_OPTION_FORMS - /* - * FIXME: Blatantly stolen from LYK_PRINT below. - * how much is really valid here? I don't know the - * innards well enough. MRC - */ - /* - * Don't do if already viewing options page. - */ - if (strcmp((curdoc.title ? curdoc.title : ""), - OPTIONS_TITLE)) { - - if (gen_options(&newdoc.address) < 0) - break; - StrAllocCopy(newdoc.title, OPTIONS_TITLE); - FREE(newdoc.post_data); - FREE(newdoc.post_content_type); - FREE(newdoc.bookmark); - newdoc.isHEAD = FALSE; - newdoc.safe = FALSE; - if (check_realm) - LYPermitURL = TRUE; - refresh_screen = TRUE; /* redisplay */ - - /* - * FIXME: this is a temporary solution until we find the - * correct place for this command to reload the document - * before the 'options menu' only when (few) important options - * were changed. - */ - HTuncache_current_document(); - } -#endif /* !NO_OPTION_FORMS */ - break; case LYK_INDEX_SEARCH: /* search for a user string */ if (is_www_index) { @@ -3924,7 +3913,8 @@ if (!LYUseFormsOptions) { } } else if (old_c != real_c) { old_c = real_c; - HTUserMsg(NOT_ISINDEX); + _statusline(NOT_ISINDEX); + sleep(MessageSecs); } break; @@ -4001,12 +3991,14 @@ if (!LYUseFormsOptions) { strncasecomp(curdoc.address, "http", 4)) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_OWNER); + _statusline(NO_OWNER); + sleep(MessageSecs); } } else if (no_mail) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(MAIL_DISALLOWED); + _statusline(MAIL_DISALLOWED); + sleep(MessageSecs); } } else { _statusline(CONFIRM_COMMENT); @@ -4062,17 +4054,17 @@ if (!LYUseFormsOptions) { /* * The owner_address is a mailto: URL. */ - CONST char *kp = HText_getRevTitle(); + cp = 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, - (kp ? kp : "")); + (cp ? cp : "")); else reply_by_mail(owner_address, curdoc.address, - (kp ? kp : "")); + (cp ? cp : "")); refresh_screen = TRUE; /* to force a showpage */ } @@ -4175,7 +4167,8 @@ if (!LYUseFormsOptions) { if (no_editor) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(EDIT_DISABLED); + _statusline(EDIT_DISABLED); + sleep(MessageSecs); } break; } @@ -4190,15 +4183,23 @@ if (!LYUseFormsOptions) { if (nlinks > 0) { cp = links[curdoc.link].lname; if (is_url(cp) == FILE_URL_TYPE) { - cp = HTfullURL_toFile(cp); - StrAllocCopy(tp, cp); - free(cp); - + if (!strncmp(cp, "file://localhost", 16)) { + /* + * This is the only case that should occur. - kw + */ + StrAllocCopy(tp, cp + 16); + } else if (!strncmp(cp, "file:", 5)) { + StrAllocCopy(tp, cp + 5); + } else { + StrAllocCopy(tp, cp); + } + HTUnEscape(tp); if (stat(tp, &dir_info) == -1) { - HTAlert(NO_STATUS); + _statusline(NO_STATUS); + sleep(AlertSecs); } else { - if (S_ISREG(dir_info.st_mode)) { - StrAllocCopy(tp, links[curdoc.link].lname); + if (((dir_info.st_mode) & S_IFMT) == S_IFREG) { + StrAllocCopy(tp, cp); HTUnEscapeSome(tp, "/"); if (edit_current_file(tp, curdoc.link, Newline)) { @@ -4217,8 +4218,10 @@ if (!LYUseFormsOptions) { * Seek old position, * which probably changed. */ - newdoc.line = curdoc.line; - newdoc.link = curdoc.link; + newdoc.line = + ((curdoc.line > 0) ? curdoc.line : 1); + newdoc.link = + ((curdoc.link > -1) ? curdoc.link : 0); #endif /* NO_SEEK_OLD_POSITION */ clear(); /* clear the screen */ } @@ -4253,7 +4256,8 @@ if (!LYUseFormsOptions) { } else { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_EDITOR); + _statusline(NO_EDITOR); + sleep(MessageSecs); } } break; @@ -4311,8 +4315,8 @@ if (!LYUseFormsOptions) { */ if (strcmp((curdoc.title ? curdoc.title : ""), SHOWINFO_TITLE)) { - if (showinfo(&curdoc, lines_in_file, - &newdoc, owner_address) < 0) + if (!showinfo(&curdoc, lines_in_file, + &newdoc, owner_address)) break; StrAllocCopy(newdoc.title, SHOWINFO_TITLE); FREE(newdoc.post_data); @@ -4337,7 +4341,8 @@ if (!LYUseFormsOptions) { if (LYValidate) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(PRINT_DISABLED); + _statusline(PRINT_DISABLED); + sleep(MessageSecs); } break; } @@ -4348,8 +4353,7 @@ if (!LYUseFormsOptions) { if (strcmp((curdoc.title ? curdoc.title : ""), PRINT_OPTIONS_TITLE)) { - if (print_options(&newdoc.address, - &curdoc.address, lines_in_file) < 0) + if (print_options(&newdoc.address, lines_in_file) < 0) break; StrAllocCopy(newdoc.title, PRINT_OPTIONS_TITLE); FREE(newdoc.post_data); @@ -4357,7 +4361,7 @@ if (!LYUseFormsOptions) { FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; - ForcePush = TRUE; /* see LYpush() and print_options() */ + ForcePush = TRUE; if (check_realm) LYPermitURL = TRUE; refresh_screen = TRUE; /* redisplay */ @@ -4411,7 +4415,8 @@ if (!LYUseFormsOptions) { * Print visited links page to file. */ if (LYShowVisitedLinks(&newdoc.address) < 0) { - HTUserMsg(VISITED_LINKS_EMPTY); + _statusline(VISITED_LINKS_EMPTY); + sleep(MessageSecs); break; } StrAllocCopy(newdoc.title, VISITED_LINKS_TITLE); @@ -4432,7 +4437,8 @@ if (!LYUseFormsOptions) { if (!HText_hasToolbar(HTMainText)) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_TOOLBAR); + _statusline(NO_TOOLBAR); + sleep(MessageSecs); } } else if (old_c != real_c) { old_c = real_c; @@ -4469,7 +4475,8 @@ if (!LYUseFormsOptions) { HTDirAccess == HT_DIR_SELECTIVE) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(DFM_NOT_AVAILABLE); + _statusline(DFM_NOT_AVAILABLE); + sleep(MessageSecs); } break; } @@ -4495,7 +4502,8 @@ if (!LYUseFormsOptions) { cp = HTParse(curdoc.address, "", PARSE_PATH|PARSE_PUNCTUATION); HTUnEscape(cp); if (HTStat(cp, &stat_info) == -1) { - CTRACE(tfp, "mainloop: Can't stat %s\n", cp); + if (TRACE) + fprintf(stderr, "mainloop: Can't stat %s\n", cp); FREE(cp); temp = (char *)calloc(1, (strlen(LYCSwingPath) + 4)); if (temp == NULL) @@ -4505,12 +4513,13 @@ if (!LYUseFormsOptions) { } else { char *VMSdir = NULL; - if (S_ISDIR(stat_info.st_mode)) { + if (((stat_info.st_mode) & S_IFMT) == S_IFDIR) { /* * We're viewing a local directory. Make * that the CSwing argument. - FM */ - LYAddPathSep(&cp); + if (cp[(strlen(cp) - 1)] != '/') + StrAllocCat(cp, "/"); StrAllocCopy(VMSdir, HTVMS_name("", cp)); FREE(cp); } else { @@ -4564,7 +4573,7 @@ if (!LYUseFormsOptions) { refresh_screen = TRUE; /* redisplay */ } stop_curses(); - LYSystem(temp); + system(temp); start_curses(); FREE(temp); break; @@ -4585,11 +4594,8 @@ if (!LYUseFormsOptions) { #ifdef USE_EXTERNALS case LYK_EXTERN: /* use external program on url */ - if ((nlinks > 0) && (links[curdoc.link].lname != NULL)) - { - run_external(links[curdoc.link].lname); - refresh_screen = TRUE; - } + run_external(links[curdoc.link].lname); + refresh_screen = TRUE; break; #endif /* USE_EXTERNALS */ @@ -4597,7 +4603,8 @@ if (!LYUseFormsOptions) { if (LYValidate) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(BOOKMARKS_DISABLED); + _statusline(BOOKMARKS_DISABLED); + sleep(MessageSecs); } break; } @@ -4636,8 +4643,6 @@ if (!LYUseFormsOptions) { strncmp(links[curdoc.link].lname, "LYNXCOOKIE:", 11) && strncmp(links[curdoc.link].lname, - "LYNXOPTIONS:", 12) && - strncmp(links[curdoc.link].lname, "LYNXLIST:", 9)))) { if (nlinks > 0) { if (curdoc.post_data == NULL && @@ -4678,7 +4683,8 @@ if (!LYUseFormsOptions) { /* * Internal link, and document has POST content. */ - HTUserMsg(NOBOOK_POST_FORM); + _statusline(NOBOOK_POST_FORM); + sleep(MessageSecs); break; } else { /* @@ -4697,7 +4703,8 @@ if (!LYUseFormsOptions) { /* * Internal link, and document has POST content. */ - HTUserMsg(NOBOOK_POST_FORM); + _statusline(NOBOOK_POST_FORM); + sleep(MessageSecs); break; } /* @@ -4708,7 +4715,8 @@ if (!LYUseFormsOptions) { links[curdoc.link].hightext); refresh_screen = TRUE; /* MultiBookmark support */ } else { - HTUserMsg(NOBOOK_FORM_FIELD); + _statusline(NOBOOK_FORM_FIELD); + sleep(MessageSecs); break; } } else { @@ -4718,14 +4726,16 @@ if (!LYUseFormsOptions) { /* * No links, and document has POST content. - FM */ - HTUserMsg(NOBOOK_POST_FORM); + _statusline(NOBOOK_POST_FORM); + sleep(MessageSecs); break; } else if (curdoc.bookmark != NULL) { /* * It's a bookmark file from which all * of the links were deleted. - FM */ - HTUserMsg(BOOKMARKS_NOLINKS); + _statusline(BOOKMARKS_NOLINKS); + sleep(MessageSecs); break; } else { _statusline(BOOK_D_OR_CANCEL); @@ -4752,7 +4762,8 @@ check_add_bookmark_to_self: } else { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NOBOOK_HSML); + _statusline(NOBOOK_HSML); + sleep(MessageSecs); } } break; @@ -4761,7 +4772,8 @@ check_add_bookmark_to_self: if (LYValidate) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(BOOKMARKS_DISABLED); + _statusline(BOOKMARKS_DISABLED); + sleep(MessageSecs); } break; } @@ -4801,13 +4813,48 @@ check_add_bookmark_to_self: if (!no_shell) { stop_curses(); printf(SPAWNING_MSG); - LYSystem(LYSysShell()); + fflush(stdout); + fflush(stderr); + if (LYTraceLogFP) + /* + * Set stderr back to its original value + * during the shell escape. - FM + */ + *stderr = LYOrigStderr; +#ifdef DOSPATH +#ifdef __DJGPP__ + __djgpp_set_ctrl_c(0); + _go32_want_ctrl_break(1); +#endif /* __DJGPP__ */ + if (getenv("SHELL") != NULL) { + system(getenv("SHELL")); + } else { + system(getenv("COMSPEC") == NULL ? "command.com" : getenv("COMSPEC")); + } +#ifdef __DJGPP__ + __djgpp_set_ctrl_c(1); + _go32_want_ctrl_break(0); +#endif /* __DJGPP__ */ +#else +#ifdef VMS + system(""); +#else + system("exec $SHELL"); +#endif /* VMS */ +#endif /* DOSPATH */ + if (LYTraceLogFP) + /* + * Set stderr back to the log file on + * return from the shell escape. - FM + */ + *stderr = *LYTraceLogFP; start_curses(); refresh_screen = TRUE; /* for an HText_pageDisplay() */ } else { if (old_c != real_c) { old_c = real_c; - HTUserMsg(SPAWNING_DISABLED); + _statusline(SPAWNING_DISABLED); + sleep(MessageSecs); } } break; @@ -4820,7 +4867,8 @@ check_add_bookmark_to_self: (no_download && !override_no_download && no_disk_save)) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(DOWNLOAD_DISABLED); + _statusline(DOWNLOAD_DISABLED); + sleep(MessageSecs); } break; } @@ -4840,7 +4888,8 @@ check_add_bookmark_to_self: URL_MAIL_METHOD) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_DOWNLOAD_MAILTO_ACTION); + _statusline(NO_DOWNLOAD_MAILTO_ACTION); + sleep(MessageSecs); } break; } @@ -4851,21 +4900,24 @@ check_add_bookmark_to_self: } if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_DOWNLOAD_INPUT); + _statusline(NO_DOWNLOAD_INPUT); + sleep(MessageSecs); } } else if (!strcmp((curdoc.title ? curdoc.title : ""), COOKIE_JAR_TITLE)) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_DOWNLOAD_COOKIES); + _statusline(NO_DOWNLOAD_COOKIES); + sleep(MessageSecs); } } else if (!strcmp((curdoc.title ? curdoc.title : ""), PRINT_OPTIONS_TITLE)) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_DOWNLOAD_PRINT_OP); + _statusline(NO_DOWNLOAD_PRINT_OP); + sleep(MessageSecs); } #ifdef DIRED_SUPPORT @@ -4874,7 +4926,8 @@ check_add_bookmark_to_self: UPLOAD_OPTIONS_TITLE)) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_DOWNLOAD_UPLOAD_OP); + _statusline(NO_DOWNLOAD_UPLOAD_OP); + sleep(MessageSecs); } } else if (!strcmp(curdoc.address, LYPermitFileURL) || @@ -4882,7 +4935,8 @@ check_add_bookmark_to_self: PERMIT_OPTIONS_TITLE)) { if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_DOWNLOAD_PERMIT_OP); + _statusline(NO_DOWNLOAD_PERMIT_OP); + sleep(MessageSecs); } } else if (lynx_edit_mode && !no_dired_support) { @@ -4906,12 +4960,10 @@ check_add_bookmark_to_self: if ((history[number].post_data != NULL && history[number].safe != TRUE) && HTConfirm(CONFIRM_POST_RESUBMISSION) == FALSE) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } - /* - * OK, we download from history page, restore URL from stack. - */ StrAllocCopy(newdoc.address, history[number].address); StrAllocCopy(newdoc.title, links[curdoc.link].hightext); StrAllocCopy(newdoc.bookmark, history[number].bookmark); @@ -4949,31 +5001,11 @@ check_add_bookmark_to_self: !strncmp(links[curdoc.link].lname, "LYNXPRINT:", 10) || !strncmp(links[curdoc.link].lname, - "LYNXOPTIONS:", 12) || - !strncmp(links[curdoc.link].lname, "lynxexec:", 9) || !strncmp(links[curdoc.link].lname, "lynxprog:", 9)) { - HTUserMsg(NO_DOWNLOAD_SPECIAL); - - } else if (!strncmp(links[curdoc.link].lname, - "mailto:", 7)) { - HTUserMsg(NO_DOWNLOAD_MAILTO_LINK); - - /* - * From here on we could have a remote host, so check if - * that's allowed. - * - * We copy all these checks from getfile() to LYK_DOWNLOAD - * here because LYNXDOWNLOAD:// will NOT be pushing the - * previous document into the history stack so preserve - * getfile() from returning a wrong status (NULLFILE). - */ - } else if (local_host_only && - !(LYisLocalHost(links[curdoc.link].lname) || - LYisLocalAlias(links[curdoc.link].lname))) { - HTUserMsg(ACCESS_ONLY_LOCALHOST); - + _statusline(NO_DOWNLOAD_SPECIAL); + sleep(MessageSecs); } else { /* Not a forms, options or history link */ /* @@ -5013,7 +5045,8 @@ check_add_bookmark_to_self: } } else if (old_c != real_c) { old_c = real_c; - HTUserMsg(NO_DOWNLOAD_CHOICE); + _statusline(NO_DOWNLOAD_CHOICE); + sleep(MessageSecs); } break; @@ -5053,6 +5086,9 @@ check_add_bookmark_to_self: else WWW_TraceFlag = TRUE; + _statusline(WWW_TraceFlag ? TRACE_ON : TRACE_OFF); + sleep(MessageSecs); + if (TRACE && LYUseTraceLog && LYTraceLogFP == NULL) { /* * We haven't yet started a TRACE log for this @@ -5066,20 +5102,25 @@ check_add_bookmark_to_self: * command. - FM */ if ((LYTraceLogFP = LYNewTxtFile(LYTraceLogPath)) == NULL) { - TracelogOpenFailed(); + WWW_TraceFlag = FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); break; } #ifdef VMS - LYCloseTracelog(); - HTSYS_remove(LYTraceLogPath); + fclose(LYTraceLogFP); + while (remove(LYTraceLogPath) == 0) + ; if ((LYTraceLogFP = LYNewTxtFile(LYTraceLogPath)) == NULL) { - TracelogOpenFailed(); + WWW_TraceFlag == FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); break; } #endif /* VMS */ - fprintf(tfp, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); + *stderr = *LYTraceLogFP; + fprintf(stderr, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); } - HTUserMsg(WWW_TraceFlag ? TRACE_ON : TRACE_OFF); break; case LYK_TRACE_LOG: /* View TRACE log. */ @@ -5088,7 +5129,8 @@ check_add_bookmark_to_self: * in this session. - FM */ if (LYTraceLogFP == NULL) { - HTUserMsg(NO_TRACELOG_STARTED); + _statusline(NO_TRACELOG_STARTED); + sleep(MessageSecs); break; } @@ -5110,10 +5152,29 @@ check_add_bookmark_to_self: * and open it again, to make sure all stderr messages thus * far will be in the log. - FM */ - if (!LYReopenTracelog(&trace_mode_flag)) + if (TRACE) + fprintf(stderr, "\nTurning off TRACE for fetch of log.\n"); + fflush(stdout); + fflush(stderr); + fclose(LYTraceLogFP); + *stderr = LYOrigStderr; + if ((LYTraceLogFP = LYAppendToTxtFile(LYTraceLogPath)) == NULL) { + WWW_TraceFlag = FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); break; - - LYLocalFileToURL (&(newdoc.address), LYTraceLogPath); + } + *stderr = *LYTraceLogFP; + if (TRACE) { + WWW_TraceFlag = FALSE; + trace_mode_flag = TRUE; + } + StrAllocCopy(newdoc.address, "file://localhost"); +#ifdef VMS + StrAllocCat(newdoc.address, HTVMS_wwwName(LYTraceLogPath)); +#else + StrAllocCat(newdoc.address, LYTraceLogPath); +#endif /* VMS */ StrAllocCopy(newdoc.title, LYNX_TRACELOG_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); @@ -5133,10 +5194,12 @@ check_add_bookmark_to_self: else clickable_images = TRUE; - HTUserMsg(clickable_images ? + _statusline(clickable_images ? CLICKABLE_IMAGES_ON : CLICKABLE_IMAGES_OFF); + sleep(MessageSecs); cmd = LYK_RELOAD; goto new_cmd; + break; case LYK_INLINE_TOGGLE: if (pseudo_inline_alts) @@ -5144,21 +5207,25 @@ check_add_bookmark_to_self: else pseudo_inline_alts = TRUE; - HTUserMsg(pseudo_inline_alts ? + _statusline(pseudo_inline_alts ? PSEUDO_INLINE_ALTS_ON : PSEUDO_INLINE_ALTS_OFF); + sleep(MessageSecs); cmd = LYK_RELOAD; goto new_cmd; + break; case LYK_RAW_TOGGLE: if (LYUseDefaultRawMode) LYUseDefaultRawMode = FALSE; else LYUseDefaultRawMode = TRUE; - HTUserMsg(LYRawMode ? RAWMODE_OFF : RAWMODE_ON); + _statusline(LYRawMode ? RAWMODE_OFF : RAWMODE_ON); HTMLSetCharacterHandling(current_char_set); LYRawMode_flag = LYRawMode; + sleep(MessageSecs); cmd = LYK_RELOAD; goto new_cmd; + break; case LYK_HEAD: if (nlinks > 0 && @@ -5175,7 +5242,8 @@ check_add_bookmark_to_self: char *scheme = strncmp(curdoc.address, "LYNXIMGMAP:", 11) ? curdoc.address : curdoc.address + 11; if (LYCanDoHEAD(scheme) != TRUE) { - HTUserMsg(DOC_NOT_HTTP_URL); + _statusline(DOC_NOT_HTTP_URL); + sleep(MessageSecs); } else { /* * Check if this is a reply from a POST, @@ -5185,7 +5253,8 @@ check_add_bookmark_to_self: if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && HTConfirm(CONFIRM_POST_DOC_HEAD) == FALSE) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } HEAD_request = TRUE; @@ -5208,21 +5277,25 @@ check_add_bookmark_to_self: (links[curdoc.link].type != WWW_INTERN_LINK_TYPE || !curdoc.address || strncmp(curdoc.address, "http", 4))) { - HTUserMsg(LINK_NOT_HTTP_URL); + _statusline(LINK_NOT_HTTP_URL); + sleep(MessageSecs); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].form->disabled) { - HTUserMsg(FORM_ACTION_DISABLED); + _statusline(FORM_ACTION_DISABLED); + sleep(MessageSecs); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && strncmp(links[curdoc.link].form->submit_action, "lynxcgi:", 8) && strncmp(links[curdoc.link].form->submit_action, "http", 4)) { - HTUserMsg(FORM_ACTION_NOT_HTTP_URL); + _statusline(FORM_ACTION_NOT_HTTP_URL); + sleep(MessageSecs); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && links[curdoc.link].form->submit_method == URL_POST_METHOD && HTConfirm(CONFIRM_POST_LINK_HEAD) == FALSE) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); } else { HEAD_request = TRUE; LYforce_no_cache = TRUE; @@ -5241,7 +5314,8 @@ check_add_bookmark_to_self: if ((curdoc.post_data != NULL && curdoc.safe != TRUE) && HTConfirm(CONFIRM_POST_DOC_HEAD) == FALSE) { - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); break; } else if (nlinks > 0) { /* @@ -5269,7 +5343,8 @@ check_add_bookmark_to_self: * current document. - FM */ if (LYCanDoHEAD(scheme) != TRUE) { - HTUserMsg(DOC_NOT_HTTP_URL); + _statusline(DOC_NOT_HTTP_URL); + sleep(MessageSecs); } else { HEAD_request = TRUE; LYforce_no_cache = TRUE; @@ -5334,9 +5409,10 @@ check_add_bookmark_to_self: if (old_c != real_c) { old_c = real_c; if (no_jump) - HTUserMsg(JUMP_DISALLOWED); + _statusline(JUMP_DISALLOWED); else - HTUserMsg(NO_JUMPFILE); + _statusline(NO_JUMPFILE); + sleep(MessageSecs); } } else { LYJumpFileURL = TRUE; @@ -5356,7 +5432,8 @@ check_add_bookmark_to_self: goto check_recall; } FREE(temp); - HTUserMsg(NO_RANDOM_URLS_YET); + statusline(NO_RANDOM_URLS_YET); + sleep(MessageSecs); break; } ret = HTParse((ret+3), startfile, PARSE_ALL); @@ -5380,7 +5457,7 @@ check_add_bookmark_to_self: HTUnEscapeSome(ret, " \r\n\t"); convert_to_spaces(ret, TRUE); } else { - LYRemoveBlanks(user_input_buffer); + collapse_spaces(user_input_buffer); } StrAllocCopy(newdoc.address, ret); StrAllocCopy(lynxjumpfile, ret); @@ -5410,10 +5487,11 @@ check_add_bookmark_to_self: HTClearHTTPAuthInfo(); HTClearNNTPAuthInfo(); HTClearFTPPassword(); - HTUserMsg(AUTH_INFO_CLEARED); + _statusline(AUTH_INFO_CLEARED); } else { - HTUserMsg(CANCELLED); + _statusline(CANCELLED); } + sleep(MessageSecs); } break; diff --git a/src/LYMainLoop.h b/src/LYMainLoop.h index 25d7b133..b3a5bd99 100644 --- a/src/LYMainLoop.h +++ b/src/LYMainLoop.h @@ -1,9 +1,7 @@ + #ifndef LYMAINLOOP_H #define LYMAINLOOP_H -#include <HTUtils.h> - -extern void LYCloseTracelog NOPARAMS; extern int mainloop NOPARAMS; #endif /* LYMAINLOOP_H */ diff --git a/src/LYMap.c b/src/LYMap.c index 0d63a36e..1e1ba24d 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -6,6 +6,7 @@ */ #include <HTUtils.h> +#include <tcp.h> #include <HTTP.h> #include <HTAnchor.h> #include <HTAccess.h> @@ -28,6 +29,8 @@ #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x=NULL;} + typedef struct _LYMapElement { char * address; char * title; @@ -168,8 +171,6 @@ PUBLIC BOOL LYAddImageMap ARGS3( if (theList) { cur = theList; while (NULL != (old = (LYImageMap *)HTList_nextObject(cur))) { - if (old->address == 0) /* shouldn't happen */ - continue; if (!strcmp(old->address, address)) { FREE(old->address); FREE(old->title); diff --git a/src/LYMap.h b/src/LYMap.h index 0ce31797..ae0f9d69 100644 --- a/src/LYMap.h +++ b/src/LYMap.h @@ -1,10 +1,7 @@ + #ifndef LYMAP_H #define LYMAP_H -#include <HTUtils.h> -#include <HTList.h> -#include <HTAnchor.h> - extern BOOL LYMapsOnly; extern void ImageMapList_free PARAMS((HTList * list)); diff --git a/src/LYNews.c b/src/LYNews.c index d644de6c..5574819c 100644 --- a/src/LYNews.c +++ b/src/LYNews.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTParse.h> #include <HTAccess.h> #include <HTCJK.h> @@ -11,6 +12,7 @@ #include <LYStrings.h> #include <LYGetFile.h> #include <LYHistory.h> +#include <LYSystem.h> #include <GridText.h> #include <LYCharSets.h> #include <LYNews.h> @@ -19,6 +21,8 @@ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* ** Global variable for async i/o. */ @@ -43,7 +47,6 @@ 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]; @@ -65,7 +68,8 @@ PUBLIC char *LYNewsPost ARGS2( * Open a temporary file for the headers * and message body. - FM */ - if ((fd = LYOpenTemp(my_tempfile, HTML_SUFFIX, "w")) == NULL) { + tempname(my_tempfile, NEW_FILE); + if ((fd = LYNewTxtFile(my_tempfile)) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(postfile); } @@ -75,11 +79,18 @@ PUBLIC char *LYNewsPost ARGS2( * open a temporary file for a conversion to JIS. - FM */ CJKfile[0] = '\0'; - if (current_char_set == UCGetLYhndl_byMIME("euc-jp") || - current_char_set == UCGetLYhndl_byMIME("shift_jis")) { - if ((fc = LYOpenTemp(CJKfile, HTML_SUFFIX, "w")) == NULL) { + if (!strncmp(LYchar_set_names[current_char_set], "Japanese (EUC)", 14) || + !strncmp(LYchar_set_names[current_char_set], "Japanese (SJIS)", 15)) { + tempname(CJKfile, NEW_FILE); + if ((fc = LYNewTxtFile(CJKfile)) == NULL) { HTAlert(CANNOT_OPEN_TEMP); - LYRemoveTemp(my_tempfile); + fclose(fd); +#ifdef VMS + while (remove(my_tempfile) == 0) + ; /* loop through all versions */ +#else + remove(my_tempfile); +#endif /* VMS */ return(postfile); } } @@ -121,9 +132,10 @@ PUBLIC char *LYNewsPost ARGS2( if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { - HTInfoMsg(NEWS_POST_CANCELLED); - LYCloseTempFP(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + _statusline(NEWS_POST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd, "%s\n", user_input); @@ -136,23 +148,26 @@ PUBLIC char *LYNewsPost ARGS2( addstr("\n\n Please provide or edit the Subject: header\n"); strcpy(user_input, "Subject: "); if ((followup == TRUE && nhist > 0) && - (kp = HText_getTitle()) != NULL) { + (cp = HText_getTitle()) != NULL) { /* * Add the default subject. */ - kp = LYSkipCBlanks(kp); - if (strncasecomp(kp, "Re:", 3)) { + while (isspace(*cp)) { + cp++; + } + if (strncasecomp(cp, "Re:", 3)) { strcat(user_input, "Re: "); } - strcat(user_input, kp); + strcat(user_input, cp); } cp = NULL; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { - HTInfoMsg(NEWS_POST_CANCELLED); - LYCloseTempFP(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + _statusline(NEWS_POST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd,"%s\n",user_input); @@ -185,9 +200,10 @@ PUBLIC char *LYNewsPost ARGS2( if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { - HTInfoMsg(NEWS_POST_CANCELLED); - LYCloseTempFP(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + _statusline(NEWS_POST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } fprintf(fd, "%s\n", user_input); @@ -225,8 +241,8 @@ PUBLIC char *LYNewsPost ARGS2( */ print_wwwfile_to_fd(fd, 1); } - LYCloseTempFP(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + fclose(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ if (term_message || c == 7 || c == 3) goto cleanup; @@ -239,9 +255,10 @@ PUBLIC char *LYNewsPost ARGS2( sprintf(user_input,"%s%s %s", editor, editor_arg, my_tempfile); _statusline(SPAWNING_EDITOR_FOR_NEWS); stop_curses(); - if (LYSystem(user_input)) { + if (system(user_input)) { start_curses(); - HTAlert(ERROR_SPAWNING_EDITOR); + _statusline(ERROR_SPAWNING_EDITOR); + sleep(AlertSecs); } else { start_curses(); } @@ -258,8 +275,9 @@ PUBLIC char *LYNewsPost ARGS2( if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0 || term_message) { - HTInfoMsg(NEWS_POST_CANCELLED); - LYCloseTempFP(fd); /* Close the temp file. */ + _statusline(NEWS_POST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the temp file. */ scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } @@ -269,15 +287,16 @@ PUBLIC char *LYNewsPost ARGS2( *user_input = '\0'; if (LYgetstr(user_input, VISIBLE, sizeof(user_input), NORECALL) < 0) { - HTInfoMsg(NEWS_POST_CANCELLED); - LYCloseTempFP(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + _statusline(NEWS_POST_CANCELLED); + sleep(InfoSecs); + fclose(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ goto cleanup; } } fprintf(fd, "\n"); - LYCloseTempFP(fd); /* Close the temp file. */ - scrollok(stdscr, FALSE); /* Stop scrolling. */ + fclose(fd); /* Close the temp file. */ + scrollok(stdscr, FALSE); /* Stop scrolling. */ } /* @@ -305,7 +324,7 @@ PUBLIC char *LYNewsPost ARGS2( !term_message && c != 7 && c != 3) c = LYgetch(); if (TOUPPER(c) == 'Y') { - if ((fd = LYAppendToTxtFile (my_tempfile)) != NULL) { + if ((fd = fopen(my_tempfile, "a")) != NULL) { fputs("-- \n", fd); while (fgets(user_input, sizeof(user_input), fp) != NULL) { fputs(user_input, fd); @@ -331,10 +350,16 @@ PUBLIC char *LYNewsPost ARGS2( (unsigned char *)CJKinput); fputs(CJKinput, fc); } - LYCloseTempFP(fc); + fclose(fc); StrAllocCopy(postfile, CJKfile); fclose(fd); - LYRemoveTemp(my_tempfile); +#ifdef VMS + while (remove(my_tempfile) == 0) + ; /* loop through all versions */ +#else + remove(my_tempfile); +#endif /* VMS */ + fd = fc; strcpy(my_tempfile, CJKfile); CJKfile[0] = '\0'; } else { @@ -356,8 +381,9 @@ PUBLIC char *LYNewsPost ARGS2( LYforce_no_cache = TRUE; } LYStatusLine = (LYlines - 1); - HTUserMsg(POSTING_TO_NEWS); + statusline(POSTING_TO_NEWS); LYStatusLine = -1; + sleep(MessageSecs); /* * Come here to cleanup and exit. @@ -367,9 +393,23 @@ cleanup: signal(SIGINT, cleanup_sig); #endif /* !VMS */ term_message = FALSE; - if (!postfile) - LYRemoveTemp(my_tempfile); - LYRemoveTemp(CJKfile); + if (!postfile) { +#ifdef VMS + while (remove(my_tempfile) == 0) + ; /* loop through all versions */ +#else + remove(my_tempfile); +#endif /* VMS */ + } + if (CJKfile[0] != '\0') { +#ifdef VMS + fclose(fc); + while (remove(CJKfile) == 0) + ; /* loop through all versions */ +#else + remove(CJKfile); +#endif /* VMS */ + } FREE(NewsGroups); return(postfile); diff --git a/src/LYNews.h b/src/LYNews.h index 9eaa8e13..17d9d48a 100644 --- a/src/LYNews.h +++ b/src/LYNews.h @@ -2,7 +2,7 @@ #define LYNEWSPOST_H #ifndef LYSTRUCTS_H -#include <LYStructs.h> +#include "LYStructs.h" #endif /* LYSTRUCTS_H */ extern BOOLEAN term_message; diff --git a/src/LYOptions.c b/src/LYOptions.c index 3d894764..0bd7bb0f 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -1,11 +1,11 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTFTP.h> #include <HTML.h> #include <LYCurses.h> #include <LYUtils.h> #include <LYStrings.h> #include <LYGlobalDefs.h> -#include <LYHistory.h> #include <LYOptions.h> #include <LYSignal.h> #include <LYClean.h> @@ -18,16 +18,21 @@ #include <HTAlert.h> #include <LYBookmark.h> #include <GridText.h> -#include <LYGetFile.h> -#include <LYReadCFG.h> #include <LYLeaks.h> -BOOLEAN term_options; +#define FREE(x) if (x) {free(x); x = NULL;} -PRIVATE void terminate_options PARAMS((int sig)); +#ifdef VMS +#define DISPLAY "DECW$DISPLAY" +#else +#define DISPLAY "DISPLAY" +#endif /* VMS */ + +#define COL_OPTION_VALUES 36 /* display column where option values start */ -#ifndef NO_OPTION_MENU +BOOLEAN term_options; +PRIVATE void terminate_options PARAMS((int sig)); PRIVATE int boolean_choice PARAMS(( int status, int line, @@ -43,70 +48,6 @@ PRIVATE int popup_choice PARAMS(( #define MAXCHOICES 10 -/* - * Values for the options menu. - FM - * - * L_foo values are the Y coordinates for the menu item. - * B_foo values are the X coordinates for the item's prompt string. - * C_foo values are the X coordinates for the item's value string. - */ -#define L_EDITOR 2 -#define L_DISPLAY 3 - -#define L_HOME 4 -#define C_MULTI 24 -#define B_BOOK 34 -#define C_DEFAULT 50 - -#define L_FTPSTYPE 5 -#define L_MAIL_ADDRESS 6 -#define L_SSEARCH 7 -#define L_LANGUAGE 8 -#define L_PREF_CHARSET 9 -#define L_ASSUME_CHARSET (L_PREF_CHARSET + 1) -#define L_CHARSET 10 -#define L_RAWMODE 11 - -#define L_COLOR L_RAWMODE -#define B_COLOR 44 -#define C_COLOR 62 - -#define L_BOOL_A 12 -#define B_VIKEYS 5 -#define C_VIKEYS 15 -#define B_EMACSKEYS 22 -#define C_EMACSKEYS 36 -#define B_SHOW_DOTFILES 44 -#define C_SHOW_DOTFILES 62 - -#define L_BOOL_B 13 -#define B_SELECT_POPUPS 5 -#define C_SELECT_POPUPS 36 -#define B_SHOW_CURSOR 44 -#define C_SHOW_CURSOR 62 - -#define L_KEYPAD 14 -#define L_LINEED 15 - -#ifdef DIRED_SUPPORT -#define L_DIRED 16 -#define L_USER_MODE 17 -#define L_USER_AGENT 18 -#define L_EXEC 19 -#else -#define L_USER_MODE 16 -#define L_USER_AGENT 17 -#define L_EXEC 18 -#endif /* DIRED_SUPPORT */ - -#define L_VERBOSE_IMAGES L_USER_MODE -#define B_VERBOSE_IMAGES 50 -#define C_VERBOSE_IMAGES (B_VERBOSE_IMAGES + 21) - - -#define COL_OPTION_VALUES 36 /* display column where option values start */ - -/* a kludge to add assume_charset only in ADVANCED mode... */ #define L_Bool_A (use_assume_charset ? L_BOOL_A + 1 : L_BOOL_A) #define L_Bool_B (use_assume_charset ? L_BOOL_B + 1 : L_BOOL_B) #define L_Exec (use_assume_charset ? L_EXEC + 1 : L_EXEC) @@ -119,8 +60,54 @@ PRIVATE int popup_choice PARAMS(( #define L_User_Mode (use_assume_charset ? L_USER_MODE + 1 : L_USER_MODE) #define L_User_Agent (use_assume_charset ? L_USER_AGENT + 1 : L_USER_AGENT) +PRIVATE void option_statusline ARGS1( + CONST char *, text) +{ + /* + * Make sure we have a pointer to a string. + */ + if (text == NULL) + return; -PUBLIC void LYoptions NOARGS + /* + * Don't print statusline messages if dumping to stdout. + */ + if (dump_output_immediately) + return; + + /* + * Use _statusline() set to output on the bottom line. - FM + */ + LYStatusLine = (LYlines - 1); + _statusline(text); + LYStatusLine = -1; +} + +PRIVATE void option_user_message ARGS2( + CONST char *, message, + char *, argument) +{ + /* + * Make sure we have a pointer to a string. + */ + if (message == NULL || argument == NULL) + return; + + /* + * Don't print statusline messages if dumping to stdout. + */ + if (dump_output_immediately) + return; + + /* + * Use _user_message() set to output on the bottom line. + */ + LYStatusLine = (LYlines - 1); + _user_message(message, argument); + LYStatusLine = -1; +} + +PUBLIC void options NOARGS { #ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS int itmp; @@ -130,10 +117,13 @@ PUBLIC void LYoptions NOARGS * If the user changes the display we need memory to put it in. */ char display_option[256]; +#ifndef VMS + static char putenv_command[142]; +#endif /* !VMS */ char *choices[MAXCHOICES]; int CurrentCharSet = current_char_set; - int CurrentAssumeCharSet = UCLYhndl_for_unspec; int CurrentShowColor = LYShowColor; + int CurrentAssumeCharSet = UCLYhndl_for_unspec; BOOLEAN CurrentRawMode = LYRawMode; BOOLEAN AddValueAccepted = FALSE; char *cp = NULL; @@ -167,7 +157,6 @@ PUBLIC void LYoptions NOARGS #endif /* DIRED_SUPPORT */ term_options = FALSE; - LYStatusLine = (LYlines - 1); /* screen is otherwise too crowded */ signal(SIGINT, terminate_options); if (no_option_save) { if (LYShowColor == SHOW_COLOR_NEVER) { @@ -241,7 +230,7 @@ draw_options: move(L_DISPLAY, 5); addstr("D)ISPLAY variable : "); - addstr((x_display && *x_display) ? x_display : "NONE"); + addstr((display && *display) ? display : "NONE"); move(L_HOME, 5); addstr("mu(L)ti-bookmarks: "); @@ -309,7 +298,7 @@ draw_options: } else { switch (LYChosenShowColor) { case SHOW_COLOR_NEVER: - addstr("NEVER "); + addstr("NEVER "); break; case SHOW_COLOR_OFF: addstr("OFF"); @@ -374,9 +363,6 @@ draw_options: ((user_mode == INTERMEDIATE_MODE) ? "Intermediate" : "Advanced ")); - addstr(" verbose images (!) : "); - addstr( verbose_img ? "ON " : "OFF" ); - move(L_User_Agent, 5); addstr("user (A)gent : "); addstr((LYUserAgent && *LYUserAgent) ? LYUserAgent : "NONE"); @@ -421,7 +407,7 @@ draw_options: response != '>' && !term_options && response != 7 && response != 3) { if (AddValueAccepted == TRUE) { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); AddValueAccepted = FALSE; } move((LYlines - 2), 0); @@ -441,9 +427,9 @@ draw_options: case 'e': /* Change the editor. */ case 'E': if (no_editor) { - _statusline(EDIT_DISABLED); + option_statusline(EDIT_DISABLED); } else if (system_editor ) { - _statusline(EDITOR_LOCKED); + option_statusline(EDITOR_LOCKED); } else { if (editor && *editor) strcpy(display_option, editor); @@ -452,7 +438,7 @@ draw_options: addstr(" "); *display_option = '\0'; } - _statusline(ACCEPT_DATA); + option_statusline(ACCEPT_DATA); move(L_EDITOR, COL_OPTION_VALUES); start_bold(); ch = LYgetstr(display_option, VISIBLE, @@ -471,10 +457,11 @@ draw_options: } clrtoeol(); if (ch == -1) { - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } } response = ' '; @@ -482,14 +469,14 @@ draw_options: case 'd': /* Change the display. */ case 'D': - if (x_display && *x_display) { - strcpy(display_option, x_display); + if (display && *display) { + strcpy(display_option, display); } else { /* clear the NONE */ move(L_DISPLAY, COL_OPTION_VALUES); addstr(" "); *display_option = '\0'; } - _statusline(ACCEPT_DATA); + option_statusline(ACCEPT_DATA); move(L_DISPLAY, COL_OPTION_VALUES); start_bold(); ch = LYgetstr(display_option, VISIBLE, @@ -497,37 +484,38 @@ draw_options: stop_bold(); move(L_DISPLAY, COL_OPTION_VALUES); if ((term_options || ch == -1) || - (x_display != NULL && + (display != NULL && #ifdef VMS - !strcasecomp(x_display, display_option))) + !strcasecomp(display, display_option))) #else - !strcmp(x_display, display_option))) + !strcmp(display, display_option))) #endif /* VMS */ { /* * Cancelled, or a non-NULL display string * wasn't changed. - FM */ - addstr((x_display && *x_display) ? x_display : "NONE"); + addstr((display && *display) ? display : "NONE"); clrtoeol(); if (ch == -1) { - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } response = ' '; break; } else if (*display_option == '\0') { - if ((x_display == NULL) || - (x_display != NULL && *x_display == '\0')) { + if ((display == NULL) || + (display != NULL && *display == '\0')) { /* * NULL or zero-length display string * wasn't changed. - FM */ addstr("NONE"); clrtoeol(); - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); response = ' '; break; } @@ -535,32 +523,42 @@ draw_options: /* * Set the new DISPLAY variable. - FM */ - LYsetXDisplay(display_option); - if ((cp = LYgetXDisplay()) != NULL) { - StrAllocCopy(x_display, cp); +#ifdef VMS + { + int i; + for (i = 0; display_option[i]; i++) + display_option[i] = TOUPPER(display_option[i]); + Define_VMSLogical(DISPLAY, display_option); + } +#else + sprintf(putenv_command, "DISPLAY=%s", display_option); + putenv(putenv_command); +#endif /* VMS */ + if ((cp = getenv(DISPLAY)) != NULL && *cp != '\0') { + StrAllocCopy(display, cp); } else { - FREE(x_display); + FREE(display); } cp = NULL; - addstr(x_display ? x_display : "NONE"); + addstr(display ? display : "NONE"); clrtoeol(); - if ((x_display == NULL && *display_option == '\0') || - (x_display != NULL && - !strcmp(x_display, display_option))) { - if (x_display == NULL && + if ((display == NULL && *display_option == '\0') || + (display != NULL && + !strcmp(display, display_option))) { + if (display == NULL && LYisConfiguredForX == TRUE) { - _statusline(VALUE_ACCEPTED_WARNING_X); - } else if (x_display != NULL && + option_statusline(VALUE_ACCEPTED_WARNING_X); + } else if (display != NULL && LYisConfiguredForX == FALSE) { - _statusline(VALUE_ACCEPTED_WARNING_NONX); + option_statusline(VALUE_ACCEPTED_WARNING_NONX); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } } else { if (*display_option) { - _statusline(FAILED_TO_SET_DISPLAY); + option_statusline(FAILED_TO_SET_DISPLAY); } else { - _statusline(FAILED_CLEAR_SET_DISPLAY); + option_statusline(FAILED_CLEAR_SET_DISPLAY); } } response = ' '; @@ -569,7 +567,7 @@ draw_options: case 'l': /* Change multibookmarks option. */ case 'L': if (LYMBMBlocked) { - _statusline(MULTIBOOKMARKS_DISALLOWED); + option_statusline(MULTIBOOKMARKS_DISALLOWED); response = ' '; break; } @@ -656,7 +654,7 @@ draw_options: clrtoeol(); *display_option = '\0'; } - _statusline(ACCEPT_DATA); + option_statusline(ACCEPT_DATA); move(L_HOME, C_DEFAULT); start_bold(); ch = LYgetstr(display_option, VISIBLE, @@ -672,7 +670,7 @@ draw_options: addstr((bookmark_page && *bookmark_page) ? bookmark_page : "NONE"); clrtoeol(); - _statusline(USE_PATH_OFF_HOME); + option_statusline(USE_PATH_OFF_HOME); response = ' '; break; } else { @@ -683,13 +681,14 @@ draw_options: } clrtoeol(); if (ch == -1) { - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } } else { /* anonymous */ - _statusline(BOOKMARK_CHANGE_DISALLOWED); + option_statusline(BOOKMARK_CHANGE_DISALLOWED); } response = ' '; break; @@ -751,7 +750,7 @@ draw_options: addstr(" "); *display_option = '\0'; } - _statusline(ACCEPT_DATA); + option_statusline(ACCEPT_DATA); move(L_MAIL_ADDRESS, COL_OPTION_VALUES); start_bold(); ch = LYgetstr(display_option, VISIBLE, @@ -771,15 +770,16 @@ draw_options: } clrtoeol(); if (ch == -1) { - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } response = ' '; break; - case 's': /* Change case sensitivity for searches. */ + case 's': /* Change case sentitivity for searches. */ case 'S': /* * Copy strings into choice array. @@ -832,9 +832,9 @@ draw_options: } /* - * Set the raw 8-bit or CJK mode defaults and - * character set if changed. - FM - */ + * Set the raw 8-bit or CJK mode defaults and + * character set if changed. - FM + */ if (CurrentAssumeCharSet != UCLYhndl_for_unspec || UCLYhndl_for_unspec != curval) { if (UCLYhndl_for_unspec != CurrentAssumeCharSet) { @@ -843,7 +843,7 @@ draw_options: } LYRawMode = (UCLYhndl_for_unspec == current_char_set); HTMLSetUseDefaultRawMode(current_char_set, LYRawMode); - HTMLSetCharacterHandling(current_char_set); + HTMLUseCharacterSet(current_char_set); CurrentAssumeCharSet = UCLYhndl_for_unspec; CurrentRawMode = LYRawMode; #if !defined(VMS) && !defined(USE_SLANG) @@ -870,12 +870,12 @@ draw_options: #endif /* !VMS || USE_SLANG */ } } else { - _statusline(NEED_ADVANCED_USER_MODE); + option_statusline(NEED_ADVANCED_USER_MODE); AddValueAccepted = FALSE; } break; - case 'c': /* Change display charset setting. */ + case 'c': /* Change charset setting. */ case 'C': if (!LYSelectPopups) { current_char_set = boolean_choice(current_char_set, @@ -897,6 +897,7 @@ draw_options: * character set if changed. - FM */ if (CurrentCharSet != current_char_set) { + HTMLSetRawModeDefault(current_char_set); LYUseDefaultRawMode = TRUE; HTMLUseCharacterSet(current_char_set); CurrentCharSet = current_char_set; @@ -959,7 +960,7 @@ draw_options: addstr(" "); *display_option = '\0'; } - _statusline(ACCEPT_DATA); + option_statusline(ACCEPT_DATA); move(L_LANGUAGE, COL_OPTION_VALUES); start_bold(); ch = LYgetstr(display_option, VISIBLE, @@ -978,10 +979,11 @@ draw_options: } clrtoeol(); if (ch == -1) { - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } response = ' '; break; @@ -995,7 +997,7 @@ draw_options: addstr(" "); *display_option = '\0'; } - _statusline(ACCEPT_DATA); + option_statusline(ACCEPT_DATA); move(L_PREF_CHARSET, COL_OPTION_VALUES); start_bold(); ch = LYgetstr(display_option, VISIBLE, @@ -1014,10 +1016,11 @@ draw_options: } clrtoeol(); if (ch == -1) { - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } response = ' '; break; @@ -1071,7 +1074,7 @@ draw_options: case 'W': /* Change show dotfiles setting. */ case 'w': if (no_dotfiles) { - _statusline(DOTFILE_ACCESS_DISABLED); + option_statusline(DOTFILE_ACCESS_DISABLED); } else { /* * Copy strings into choice array. @@ -1117,11 +1120,12 @@ draw_options: if (!has_colors()) { char * terminal = getenv("TERM"); if (terminal) - HTUserMsg2( + option_user_message( COLOR_TOGGLE_DISABLED_FOR_TERM, terminal); else - HTUserMsg(COLOR_TOGGLE_DISABLED); + option_statusline(COLOR_TOGGLE_DISABLED); + sleep(AlertSecs); } #endif /* @@ -1178,11 +1182,12 @@ draw_options: if (again) { char * terminal = getenv("TERM"); if (terminal) - HTUserMsg2( + option_user_message( COLOR_TOGGLE_DISABLED_FOR_TERM, terminal); else - HTUserMsg(COLOR_TOGGLE_DISABLED); + option_statusline(COLOR_TOGGLE_DISABLED); + sleep(AlertSecs); } #endif } while (again); @@ -1432,46 +1437,6 @@ draw_options: } break; - case '!': - /* - * Copy strings into choice array. - */ - choices[0] = NULL; - StrAllocCopy(choices[0], "OFF"); - choices[1] = NULL; - StrAllocCopy(choices[1], "ON "); - choices[2] = NULL; - if (!LYSelectPopups) { - verbose_img = boolean_choice(verbose_img, - L_VERBOSE_IMAGES, - C_VERBOSE_IMAGES, - choices); - } else { - verbose_img = popup_choice(verbose_img, - L_VERBOSE_IMAGES, - C_VERBOSE_IMAGES, - choices, - 2, FALSE); - } - FREE(choices[0]); - FREE(choices[1]); - response = ' '; - if (LYSelectPopups) { -#if !defined(VMS) || defined(USE_SLANG) - if (term_options) { - term_options = FALSE; - } else { - AddValueAccepted = TRUE; - } - goto draw_options; -#else - term_options = FALSE; - if (use_assume_charset != old_use_assume_charset) - goto draw_options; -#endif /* !VMS || USE_SLANG */ - } - break; - case 'a': /* Change user agent string. */ case 'A': if (!no_useragent) { @@ -1482,7 +1447,7 @@ draw_options: addstr(" "); *display_option = '\0'; } - _statusline(ACCEPT_DATA_OR_DEFAULT); + option_statusline(ACCEPT_DATA_OR_DEFAULT); move(L_User_Agent, COL_OPTION_VALUES); start_bold(); ch = LYgetstr(display_option, VISIBLE, @@ -1504,17 +1469,18 @@ draw_options: } clrtoeol(); if (ch == -1) { - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else if (LYUserAgent && *LYUserAgent && !strstr(LYUserAgent, "Lynx") && !strstr(LYUserAgent, "lynx")) { - _statusline(UA_COPYRIGHT_WARNING); + option_statusline(UA_COPYRIGHT_WARNING); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } } else { /* disallowed */ - _statusline(UA_COPYRIGHT_WARNING); + option_statusline(UA_COPYRIGHT_WARNING); } response = ' '; break; @@ -1523,7 +1489,7 @@ draw_options: case 'x': /* Change local exec restriction. */ case 'X': if (exec_frozen && !LYSelectPopups) { - _statusline(CHANGE_OF_SETTING_DISALLOWED); + option_statusline(CHANGE_OF_SETTING_DISALLOWED); response = ' '; break; } @@ -1607,15 +1573,15 @@ draw_options: case '>': /* Save current options to RC file. */ if (!no_option_save) { - _statusline(SAVING_OPTIONS); + option_statusline(SAVING_OPTIONS); if (save_rc()) { LYrcShowColor = LYChosenShowColor; - _statusline(OPTIONS_SAVED); + option_statusline(OPTIONS_SAVED); } else { HTAlert(OPTIONS_NOT_SAVED); } } else { - _statusline(R_TO_RETURN_TO_LYNX); + option_statusline(R_TO_RETURN_TO_LYNX); /* * Change response so that we don't exit * the options menu. @@ -1630,15 +1596,14 @@ draw_options: default: if (!no_option_save) { - _statusline(SAVE_OR_R_TO_RETURN_TO_LYNX); + option_statusline(SAVE_OR_R_TO_RETURN_TO_LYNX); } else { - _statusline(R_TO_RETURN_TO_LYNX); + option_statusline(R_TO_RETURN_TO_LYNX); } } /* end switch */ } /* end while */ term_options = FALSE; - LYStatusLine = -1; /* let user_mode have some of the screen */ signal(SIGINT, cleanup_sig); } @@ -1672,7 +1637,7 @@ PRIVATE int boolean_choice ARGS4( /* * Update the statusline. */ - _statusline(ANY_KEY_CHANGE_RET_ACCEPT); + option_statusline(ANY_KEY_CHANGE_RET_ACCEPT); /* * Highlight the current choice. @@ -1780,16 +1745,16 @@ PRIVATE int boolean_choice ARGS4( if (term_options) { term_options = FALSE; - HTInfoMsg(CANCELLED); - HTInfoMsg(""); + option_statusline(CANCELLED); + sleep(InfoSecs); + option_statusline(""); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); } return(cur_choice); } } } -#endif /* !NO_OPTION_MENU */ PRIVATE void terminate_options ARGS1( int, sig GCC_UNUSED) @@ -1948,13 +1913,13 @@ draw_bookmark_list: */ if (response == '>') { if (!no_option_save) { - _statusline(SAVING_OPTIONS); + option_statusline(SAVING_OPTIONS); if (save_rc()) - _statusline(OPTIONS_SAVED); + option_statusline(OPTIONS_SAVED); else HTAlert(OPTIONS_NOT_SAVED); } else { - _statusline(R_TO_RETURN_TO_LYNX); + option_statusline(R_TO_RETURN_TO_LYNX); /* * Change response so that we don't exit * the options menu. @@ -2011,7 +1976,7 @@ draw_bookmark_list: goto draw_bookmark_list; } } - _statusline(ACCEPT_DATA); + option_statusline(ACCEPT_DATA); if (a > 0) { start_bold(); @@ -2096,7 +2061,6 @@ draw_bookmark_list: signal(SIGINT, cleanup_sig); } -#ifndef NO_OPTION_MENU /* ** This function prompts for a choice or page number. ** If a 'g' or 'p' suffix is included, that will be @@ -2112,14 +2076,15 @@ PRIVATE int get_popup_choice_number ARGS1( */ temp[0] = *c; temp[1] = '\0'; - _statusline(OPTION_CHOICE_NUMBER); + option_statusline(OPTION_CHOICE_NUMBER); /* * Get the number, possibly with a suffix, from the user. */ if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0 || term_options) { - HTInfoMsg(CANCELLED); + option_statusline(CANCELLED); + sleep(InfoSecs); *c = '\0'; term_options = FALSE; return(0); @@ -2159,8 +2124,7 @@ PRIVATE int popup_choice ARGS6( #ifndef USE_SLANG WINDOW * form_window; #endif /* !USE_SLANG */ - int num_choices = 0, top, bottom, length = -1; - unsigned width = 0; + int num_choices = 0, top, bottom, length = -1, width = 0; char ** Cptr = choices; int window_offset = 0; int DisplayLines = (LYlines - 2); @@ -2296,7 +2260,7 @@ PRIVATE int popup_choice ARGS6( if (!(form_window = newwin(bottom - top, (Lnum + width + 4), top, (lx - 1))) && !(form_window = newwin(bottom - top, 0, top, 0))) { - HTAlert(POPUP_FAILED); + option_statusline(POPUP_FAILED); return(orig_choice); } scrollok(form_window, TRUE); @@ -2319,9 +2283,9 @@ PRIVATE int popup_choice ARGS6( move((LYlines - 2), 0); clrtoeol(); if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } /* @@ -2454,6 +2418,9 @@ redraw: term_options = FALSE; c = LYgetch(); if (term_options || c == 3 || c == 7) { + /* + * Control-C or Control-G + */ cmd = LYK_QUIT; } else { cmd = keymap[c+1]; @@ -2493,20 +2460,21 @@ redraw: */ if (number <= 1) { if (window_offset == 0) { - HTUserMsg(ALREADY_AT_CHOICE_BEGIN); + option_statusline(ALREADY_AT_CHOICE_BEGIN); + sleep(MessageSecs); if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } break; } window_offset = 0; cur_choice = 0; if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } goto redraw; } @@ -2517,11 +2485,12 @@ redraw: */ if (number >= npages) { if (window_offset >= ((num_choices - length) + 1)) { - HTUserMsg(ALREADY_AT_CHOICE_END); + option_statusline(ALREADY_AT_CHOICE_END); + sleep(MessageSecs); if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } break; } @@ -2532,9 +2501,9 @@ redraw: if (cur_choice < window_offset) cur_choice = window_offset; if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } goto redraw; } @@ -2544,19 +2513,20 @@ redraw: */ if (((number - 1) * length) == window_offset) { sprintf(buffer, ALREADY_AT_CHOICE_PAGE, number); - HTUserMsg(buffer); + option_statusline(buffer); + sleep(MessageSecs); if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } break; } cur_choice = window_offset = ((number - 1) * length); if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } goto redraw; @@ -2594,11 +2564,12 @@ redraw: */ sprintf(buffer, CHOICE_ALREADY_CURRENT, (number + 1)); - HTUserMsg(buffer); + option_statusline(buffer); + sleep(MessageSecs); if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } break; } @@ -2622,9 +2593,9 @@ redraw: window_offset = 0; } if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } goto redraw; } @@ -2632,7 +2603,8 @@ redraw: /* * Not in range. - FM */ - HTUserMsg(BAD_CHOICE_NUM_ENTERED); + option_statusline(BAD_CHOICE_NUM_ENTERED); + sleep(MessageSecs); } } @@ -2640,9 +2612,9 @@ redraw: * Restore the popup statusline. - FM */ if (disabled) { - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); } else { - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); } break; @@ -2860,14 +2832,15 @@ redraw: strcpy(prev_target, prev_target_buffer); case LYK_WHEREIS: if (*prev_target == '\0' ) { - _statusline(ENTER_WHEREIS_QUERY); + option_statusline(ENTER_WHEREIS_QUERY); if ((ch = LYgetstr(prev_target, VISIBLE, sizeof(prev_target_buffer), recall)) < 0) { /* * User cancelled the search via ^G. - FM */ - HTInfoMsg(CANCELLED); + option_statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } } @@ -2878,7 +2851,8 @@ check_recall: /* * No entry. Simply break. - FM */ - HTInfoMsg(CANCELLED); + option_statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } @@ -2918,20 +2892,21 @@ check_recall: strcpy(prev_target, cp); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { - _statusline(EDIT_CURRENT_QUERY); + option_statusline(EDIT_CURRENT_QUERY); } else if ((*prev_target_buffer && QueryTotal == 2) || (!(*prev_target_buffer) && QueryTotal == 1)) { - _statusline(EDIT_THE_PREV_QUERY); + option_statusline(EDIT_THE_PREV_QUERY); } else { - _statusline(EDIT_A_PREV_QUERY); + option_statusline(EDIT_A_PREV_QUERY); } if ((ch = LYgetstr(prev_target, VISIBLE, sizeof(prev_target_buffer), recall)) < 0) { /* * User cancelled the search via ^G. - FM */ - HTInfoMsg(CANCELLED); + option_statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } goto check_recall; @@ -2972,14 +2947,14 @@ check_recall: strcpy(prev_target, cp); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { - _statusline(EDIT_CURRENT_QUERY); + option_statusline(EDIT_CURRENT_QUERY); } else if ((*prev_target_buffer && QueryTotal == 2) || (!(*prev_target_buffer) && QueryTotal == 1)) { - _statusline(EDIT_THE_PREV_QUERY); + option_statusline(EDIT_THE_PREV_QUERY); } else { - _statusline(EDIT_A_PREV_QUERY); + option_statusline(EDIT_A_PREV_QUERY); } if ((ch = LYgetstr(prev_target, VISIBLE, sizeof(prev_target_buffer), @@ -2987,7 +2962,8 @@ check_recall: /* * User cancelled the search via ^G. - FM */ - HTInfoMsg(CANCELLED); + option_statusline(CANCELLED); + sleep(InfoSecs); goto restore_popup_statusline; } goto check_recall; @@ -3037,7 +3013,8 @@ check_recall: * If we started at the beginning, it can't be present. - FM */ if (cur_choice == 0) { - HTUserMsg2(STRING_NOT_FOUND, prev_target_buffer); + option_user_message(STRING_NOT_FOUND, prev_target_buffer); + sleep(MessageSecs); goto restore_popup_statusline; } @@ -3079,7 +3056,8 @@ check_recall: /* * Didn't find it in the preceding choices either. - FM */ - HTUserMsg2(STRING_NOT_FOUND, prev_target_buffer); + option_user_message(STRING_NOT_FOUND, prev_target_buffer); + sleep(MessageSecs); restore_popup_statusline: /* @@ -3087,9 +3065,9 @@ restore_popup_statusline: * reset the search variables. - FM */ if (disabled) - _statusline(CHOICE_LIST_UNM_MSG); + option_statusline(CHOICE_LIST_UNM_MSG); else - _statusline(CHOICE_LIST_MESSAGE); + option_statusline(CHOICE_LIST_MESSAGE); *prev_target = '\0'; QueryTotal = (search_queries ? HTList_count(search_queries) : 0); @@ -3106,7 +3084,8 @@ restore_popup_statusline: case LYK_PREV_DOC: cur_choice = orig_choice; term_options = TRUE; - HTUserMsg(CANCELLED); + option_statusline(CANCELLED); + sleep(MessageSecs); cmd = LYK_ACTIVATE; /* to exit */ break; } @@ -3119,994 +3098,10 @@ restore_popup_statusline: #endif /* !USE_SLANG */ if (disabled || term_options) { - _statusline(""); + option_statusline(""); return(orig_choice); } else { - _statusline(VALUE_ACCEPTED); + option_statusline(VALUE_ACCEPTED); return(cur_choice); } } - -#endif /* !NO_OPTION_MENU */ - -#ifndef NO_OPTION_FORMS - -/* - * I'm paranoid about mistyping strings. Also, this way they get combined - * so we don't have to worry about the intelligence of the compiler. - * We don't need to burn memory like it's cheap. We're better than that. - */ -#define SELECTED(flag) (flag) ? selected_string : "" -#define DISABLED(flag) (flag) ? disabled_string : "" -#define NOTEMPTY(text) (text && text[0]) ? text : "" - -typedef struct { - int value; - CONST char *LongName; - CONST char *HtmlName; -} OptValues; - -typedef struct { - char * tag; - char * value; -} PostPair; - -static CONST char selected_string[] = "selected"; -static CONST char disabled_string[] = "disabled"; -static CONST char on_string[] = "ON"; -static CONST char off_string[] = "OFF"; -static CONST char never_string[] = "NEVER"; -static CONST char always_string[] = "ALWAYS"; -static OptValues bool_values[] = { - { FALSE, "OFF", "OFF" }, - { TRUE, "ON", "ON" }, - { 0, 0, 0 }}; - -static char * secure_string = "secure"; -static char * secure_value = NULL; -static char * save_options_string = "save_options"; - -/* - * Personal Preferences - */ -static char * cookies_string = "cookies"; -static char * cookies_ignore_all_string = "ignore"; -static char * cookies_up_to_user_string = "ask user"; -static char * cookies_accept_all_string = "accept all"; -static char * x_display_string = "display"; -static char * editor_string = "editor"; -static char * emacs_keys_string = "emacs_keys"; - -#ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS -#define EXEC_ALWAYS 2 -#define EXEC_LOCAL 1 -#define EXEC_NEVER 0 -static char * exec_links_string = "exec_options"; -static OptValues exec_links_values[] = { - { EXEC_NEVER, "ALWAYS OFF", "ALWAYS OFF" }, - { EXEC_LOCAL, "FOR LOCAL FILES ONLY", "FOR LOCAL FILES ONLY" }, -#ifndef NEVER_ALLOW_REMOTE_EXEC - { EXEC_ALWAYS, "ALWAYS ON", "ALWAYS ON" }, -#endif - { 0, 0, 0 }}; -#endif /* ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS */ - -static char * keypad_mode_string = "keypad_mode"; -static OptValues keypad_mode_values[] = { - { NUMBERS_AS_ARROWS, "Numbers act as arrows", "number_arrows" }, - { LINKS_ARE_NUMBERED, "Links are numbered", "links_numbered" }, - { LINKS_AND_FORM_FIELDS_ARE_NUMBERED, - "Links and form fields are numbered", - "links_and_forms" }, - { 0, 0, 0 }}; -static char * mail_address_string = "mail_address"; -static char * search_type_string = "search_type"; -static OptValues search_type_values[] = { - { FALSE, "Case insensitive", "case_insensitive" }, - { TRUE, "Case sensitive", "case_sensitive" }, - { 0, 0, 0 }}; -static char * select_popups_string = "select_popups"; -#if defined(USE_SLANG) || defined(COLOR_CURSES) -static char * show_color_string = "show_color"; -static OptValues show_color_values[] = { - { SHOW_COLOR_NEVER, never_string, never_string }, - { SHOW_COLOR_OFF, off_string, off_string }, - { SHOW_COLOR_ON, on_string, on_string }, - { SHOW_COLOR_ALWAYS, always_string, always_string }, - { 0, 0, 0 }}; -#endif -static char * show_cursor_string = "show_cursor"; -static char * user_mode_string = "user_mode"; -static OptValues user_mode_values[] = { - { NOVICE_MODE, "Novice", "Novice" }, - { INTERMEDIATE_MODE, "Intermediate", "Intermediate" }, - { ADVANCED_MODE, "Advanced", "Advanced" }, - { 0, 0, 0 }}; -static char * verbose_images_string = "verbose_images"; -static char * vi_keys_string = "vi_keys"; - -/* - * Bookmark Options - */ -static char * mbm_advanced_string = "ADVANCED"; -static char * mbm_off_string = "OFF"; -static char * mbm_standard_string = "STANDARD"; -static char * mbm_string = "multi_bookmarks_mode"; -static char * single_bookmark_string = "single_bookmark_name"; - -/* - * Character Set Options - */ -static char * assume_char_set_string = "assume_char_set"; -static char * display_char_set_string = "display_char_set"; -static char * raw_mode_string = "raw_mode"; - -/* - * File Management Options - */ -static char * show_dotfiles_string = "show_dotfiles"; -#ifdef DIRED_SUPPORT -static char * dired_sort_string = "dired_sort"; -static OptValues dired_values[] = { - { 0, "Directories first", "dired_dir" }, - { FILES_FIRST, "Files first", "dired_files" }, - { MIXED_STYLE, "Mixed style", "dired_mixed" }, - { 0, 0, 0 }}; -#endif /* DIRED_SUPPORT */ -static char * ftp_sort_string = "ftp_sort"; -static OptValues ftp_sort_values[] = { - { FILE_BY_NAME, "By Name", "ftp_by_name" }, - { FILE_BY_TYPE, "By Type", "ftp_by_type" }, - { FILE_BY_SIZE, "By Size", "ftp_by_size" }, - { FILE_BY_DATE, "By Date", "ftp_by_date" }, - { 0, 0, 0 }}; - -/* - * Headers transferred to remote server - */ -static char * preferred_doc_char_string = "preferred_doc_char"; -static char * preferred_doc_lang_string = "preferred_doc_lang"; -static char * user_agent_string = "user_agent"; - -#define PutLabel(fp, text) \ - fprintf(fp," %-33s: ", text) - -#define PutTextInput(fp, Name, Value, Size, disable) \ - fprintf(fp,\ - "<input size=%d type=\"text\" name=\"%s\" value=\"%s\" %s>\n",\ - (int) Size, Name, Value, disable) - -#define PutOption(fp, flag, html, name) \ - fprintf(fp,"<option value=\"%s\" %s>%s\n", html, SELECTED(flag), name) - -#define BeginSelect(fp, text) \ - fprintf(fp,"<select name=\"%s\">\n", text) - -#define MaybeSelect(fp, flag, text) \ - fprintf(fp,"<select name=\"%s\" %s>\n", text, DISABLED(flag)) - -#define EndSelect(fp)\ - fprintf(fp,"</select>\n") - -PRIVATE void PutOptValues ARGS3( - FILE *, fp, - int, value, - OptValues *, table) -{ - while (table->LongName != 0) { - PutOption(fp, - value == table->value, - table->HtmlName, - table->LongName); - table++; - } -} - -PRIVATE int GetOptValues ARGS2( - OptValues *, table, - char *, value) -{ - while (table->LongName != 0) { - if (!strcmp(value, table->HtmlName)) - return table->value; - table++; - } - return -1; -} - -/* - * Break cgi line into array of pairs of pointers. Don't bother trying to - * be efficient. We're not called all that often. - * We come in with a string looking like: - * tag1=value1&tag2=value2&...&tagN=valueN - * We leave with an array of post_pairs. The last element in the array - * will have a tag pointing to NULL. - * Not pretty, but works. Hey, if strings can be null terminate arrays... - */ - -PRIVATE PostPair * break_data ARGS1( - char *, data) -{ - char * p = data; - PostPair * q = NULL; - int count = 0; - - if (p==NULL || p[0]=='\0') - return NULL; - - q = calloc(sizeof(PostPair), 1); - if (q==NULL) - outofmem(__FILE__, "break_data(calloc)"); - - do { - /* - * First, break up on '&', sliding 'p' on down the line. - */ - q[count].value = LYstrsep(&p, "&"); - /* - * Then break up on '=', sliding value down, and setting tag. - */ - q[count].tag = LYstrsep(&(q[count].value), "="); - - /* - * Clean them up a bit, in case user entered a funky string. - */ - HTUnEscape(q[count].tag); - - /* In the value field we have '+' instead of ' '. So do a simple - * find&replace on the value field before UnEscaping() - SKY - */ - { - size_t i, len; - len = strlen(q[count].value); - for (i = 0; i < len; i++) { - if (q[count].value[i] == '+') { -#ifdef UNIX - /* - * Allow for special case of options which begin with a "+" on - * Unix - TD - */ - if (i > 0 - && q[count].value[i+1] == '+' - && isalnum(q[count].value[i+2])) { - q[count].value[i++] = ' '; - i++; - continue; - } - -#endif - q[count].value[i] = ' '; - } - } - } - HTUnEscape(q[count].value); - - count++; - /* - * Like I said, screw efficiency. Sides, realloc is fast on - * Linux ;-> - */ - q = realloc(q, sizeof(PostPair)*(count+1)); - if (q==NULL) - outofmem(__FILE__, "break_data(realloc)"); - q[count].tag=NULL; - } while (p!=NULL && p[0]!='\0'); - return q; -} - -/* - * Handle options from the pseudo-post. I think we really only need - * post_data here, but bring along everything just in case. It's only a - * pointer. MRC - * - * By changing the certain options value (like preferred language or - * fake browser name) we need to inform the remote server and reload - * (uncache on a proxy) the document which was active just before - * the Options menu was invoked. Another values (like display_char_set - * or assume_char_set) used by lynx initial rendering stages - * and can only be changed after reloading :-( - * So we introduce boolean flag 'need_reload' (currently dummy). - * - * Options are processed in order according to gen_options(), we should not - * depend on it and add boolean flags where the order is essential (save, - * character sets...) - * - * Security: some options are disabled in gen_options() under certain - * conditions. We *should* duplicate the same conditions here in postoptions() - * to prevent user with a limited access from editing HTML options code - * manually and submit it to access the restricted items. - LP - */ - -PUBLIC int postoptions ARGS1( - document *, newdoc) -{ - PostPair *data = 0; - int i; - BOOLEAN save_all = FALSE; - int display_char_set_old = current_char_set; - BOOLEAN raw_mode_old = LYRawMode; - BOOLEAN assume_char_set_changed = FALSE; - BOOLEAN need_reload = FALSE; -#if defined(USE_SLANG) || defined(COLOR_CURSES) - int CurrentShowColor = LYShowColor; -#endif - - /*------------------------------------------------- - * kludge a link from mbm_menu, the URL was: - * "<a href=\"LYNXOPTIONS://MBM_MENU\">Goto multi-bookmark menu</a>\n" - *--------------------------------------------------*/ - - if (strstr(newdoc->address, "LYNXOPTIONS://MBM_MENU")) { - FREE(newdoc->post_data); - FREE(data); - edit_bookmarks(); - return(NULLFILE); - } - - data = break_data(newdoc->post_data); - - for (i = 0; data[i].tag != NULL; i++) { - /* - * Paranoid security. - */ - if (!strcmp(data[i].tag, secure_string)) { - if (!secure_value || strcmp(data[i].value, secure_value)) { - /* - * FIXME: We've been spoofed message here. - */ - FREE(data); - return(NULLFILE); - } - FREE(secure_value); - } - - /* Save options */ - if (!strcmp(data[i].tag, save_options_string) && (!no_option_save)) { - save_all = TRUE; - } - - /* Cookies: SELECT */ - if (!strcmp(data[i].tag, cookies_string)) { - if (!strcmp(data[i].value, cookies_ignore_all_string)) { - LYSetCookies = FALSE; - } else if (!strcmp(data[i].value, cookies_up_to_user_string)) { - LYSetCookies = TRUE; - LYAcceptAllCookies = FALSE; - } else if (!strcmp(data[i].value, cookies_accept_all_string)) { - LYSetCookies = TRUE; - LYAcceptAllCookies = TRUE; - } - } - - /* X Display: INPUT */ - if (!strcmp(data[i].tag, x_display_string)) { - LYsetXDisplay(data[i].value); - } - - /* Editor: INPUT */ - if (!strcmp(data[i].tag, editor_string)) { - FREE(editor); - StrAllocCopy(editor, data[i].value); - } - - /* Emacs keys: ON/OFF */ - if (!strcmp(data[i].tag, emacs_keys_string)) { - if ((emacs_keys = GetOptValues(bool_values, data[i].value))) { - set_emacs_keys(); - } else { - reset_emacs_keys(); - } - } - - /* Execution links: SELECT */ -#ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS - if (!strcmp(data[i].tag, exec_links_string)) { - int code = GetOptValues(exec_links_values, data[i].value); -#ifndef NEVER_ALLOW_REMOTE_EXEC - local_exec = (code == EXEC_ALWAYS); -#endif /* !NEVER_ALLOW_REMOTE_EXEC */ - local_exec_on_local_files = (code == EXEC_LOCAL); - } -#endif /* ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS */ - - /* Keypad Mode: SELECT */ - if (!strcmp(data[i].tag, keypad_mode_string)) { - keypad_mode = GetOptValues(keypad_mode_values, data[i].value); - } - - /* Mail Address: INPUT */ - if (!strcmp(data[i].tag, mail_address_string)) { - FREE(personal_mail_address); - StrAllocCopy(personal_mail_address, data[i].value); - } - - /* Search Type: SELECT */ - if (!strcmp(data[i].tag, search_type_string)) { - case_sensitive = GetOptValues(search_type_values, data[i].value); - } - - /* Select Popups: ON/OFF */ - if (!strcmp(data[i].tag, select_popups_string)) { - LYSelectPopups = GetOptValues(bool_values, data[i].value); - } - -#if defined(USE_SLANG) || defined(COLOR_CURSES) - /* Show Color: SELECT */ - if (!strcmp(data[i].tag, show_color_string)) { - LYShowColor = GetOptValues(show_color_values, data[i].value); - LYChosenShowColor = LYShowColor; - if (CurrentShowColor != LYShowColor) { - lynx_force_repaint(); - } - CurrentShowColor = LYShowColor; -#ifdef USE_SLANG - SLtt_Use_Ansi_Colors = (LYShowColor > 1 ? 1 : 0); -#endif - } -#endif /* USE_SLANG || COLOR_CURSES */ - - /* Show Cursor: ON/OFF */ - if (!strcmp(data[i].tag, show_cursor_string)) { - LYShowCursor = GetOptValues(bool_values, data[i].value); - } - - /* User Mode: SELECT */ - if (!strcmp(data[i].tag, user_mode_string)) { - user_mode = GetOptValues(user_mode_values, data[i].value); - if (user_mode == NOVICE_MODE) { - display_lines = (LYlines - 4); - } else { - display_lines = LYlines-2; - } - } - - /* Verbose Images: ON/OFF */ - if (!strcmp(data[i].tag, verbose_images_string)) { - verbose_img = GetOptValues(bool_values, data[i].value); - } - - /* VI Keys: ON/OFF */ - if (!strcmp(data[i].tag, vi_keys_string)) { - if ((vi_keys = GetOptValues(bool_values, data[i].value))) { - set_vi_keys(); - } else if (!strcmp(data[i].value, off_string)) { - reset_vi_keys(); - } - } - - /* Bookmarks File Menu: SELECT */ - if (!strcmp(data[i].tag, mbm_string) && (!LYMBMBlocked)) { - if (!strcmp(data[i].value, mbm_off_string)) { - LYMultiBookmarks = FALSE; - } else if (!strcmp(data[i].value, mbm_standard_string)) { - LYMultiBookmarks = TRUE; - LYMBMAdvanced = FALSE; - } else if (!strcmp(data[i].value, mbm_advanced_string)) { - LYMultiBookmarks = TRUE; - LYMBMAdvanced = TRUE; - } - } - - /* Single Bookmarks filename: INPUT */ - if (!strcmp(data[i].tag, single_bookmark_string)) { - if (strcmp(data[i].value, "")) { - FREE(bookmark_page); - StrAllocCopy(bookmark_page, data[i].value); - } - } - - /* Assume Character Set: SELECT */ - if (!strcmp(data[i].tag, assume_char_set_string)) { - int newval; - - newval = UCGetLYhndl_byMIME(data[i].value); - if ((raw_mode_old && - newval != safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset)) - || (!raw_mode_old && - newval != UCLYhndl_for_unspec)) { - - UCLYhndl_for_unspec = newval; - StrAllocCopy(UCAssume_MIMEcharset, data[i].value); - assume_char_set_changed = TRUE; - } - } - - /* Display Character Set: SELECT */ - if (!strcmp(data[i].tag, display_char_set_string)) { - current_char_set = atoi(data[i].value); - } - - /* Raw Mode: ON/OFF */ - if (!strcmp(data[i].tag, raw_mode_string)) { - LYRawMode = GetOptValues(bool_values, data[i].value); - } - - /* - * ftp sort: SELECT - */ - if (!strcmp(data[i].tag, ftp_sort_string)) { - HTfileSortMethod = GetOptValues(ftp_sort_values, data[i].value); - } - -#ifdef DIRED_SUPPORT - /* Local Directory Sort: SELECT */ - if (!strcmp(data[i].tag, dired_sort_string)) { - dir_list_style = GetOptValues(dired_values, data[i].value); - } -#endif /* DIRED_SUPPORT */ - - /* Show dot files: ON/OFF */ - if (!strcmp(data[i].tag, show_dotfiles_string) && (!no_dotfiles)) { - show_dotfiles = GetOptValues(bool_values, data[i].value); - } - - /* Preferred Document Character Set: INPUT */ - if (!strcmp(data[i].tag, preferred_doc_char_string)) { - FREE(pref_charset); - StrAllocCopy(pref_charset, data[i].value); - } - - /* Preferred Document Language: INPUT */ - if (!strcmp(data[i].tag, preferred_doc_lang_string)) { - FREE(language); - StrAllocCopy(language, data[i].value); - } - - /* User Agent: INPUT */ - if (!strcmp(data[i].tag, user_agent_string) && (!no_useragent)) { - FREE(LYUserAgent); - /* ignore Copyright warning ? */ - StrAllocCopy(LYUserAgent, - *(data[i].value) - ? data[i].value - : LYUserAgentDefault); - if (LYUserAgent && *LYUserAgent && - !strstr(LYUserAgent, "Lynx") && - !strstr(LYUserAgent, "lynx")) { - HTAlert(UA_COPYRIGHT_WARNING); - } - } - } /* end of loop */ - - /* - * Process the flags: - */ - if ( display_char_set_old != current_char_set || - raw_mode_old != LYRawMode || - assume_char_set_changed ) { - /* - * charset settings: the order is essential here. - */ - if (display_char_set_old != current_char_set) { - /* - * Set the LYUseDefaultRawMode value and character - * handling if LYRawMode was changed. - FM - */ - LYUseDefaultRawMode = TRUE; - HTMLUseCharacterSet(current_char_set); - } - if (assume_char_set_changed) { - LYRawMode = (UCLYhndl_for_unspec == current_char_set); - } - if (raw_mode_old != LYRawMode || assume_char_set_changed) { - /* - * Set the raw 8-bit or CJK mode defaults and - * character set if changed. - FM - */ - HTMLSetUseDefaultRawMode(current_char_set, LYRawMode); - HTMLSetCharacterHandling(current_char_set); - } - need_reload = TRUE; - } /* end of charset settings */ - - - /* - * FIXME: Golly gee, we need to write all of this out now, don't we? - */ - FREE(newdoc->post_data); - FREE(data); - if (save_all) { - _statusline(SAVING_OPTIONS); - if (save_rc()) { - _statusline(OPTIONS_SAVED); - } else { - HTAlert(OPTIONS_NOT_SAVED); - } - } - LYpop(newdoc); /* return to previous doc, not to options menu! */ - - if (need_reload == TRUE) { - /* FIXME: currently dummy */ - } - return(NULLFILE); -} - -PRIVATE char *NewSecureValue NOARGS -{ - FREE(secure_value); - if ((secure_value = malloc(80)) != 0) { - sprintf(secure_value, "%ld", (long)secure_value + (long)time(0)); - return secure_value; - } - return "?"; -} - -/* - * Okay, someone wants to change options. So, lets gen up a form for them - * and pass it around. Gor, this is ugly. Be a lot easier in Bourne with - * "here" documents. :-> - * Basic Strategy: For each option, throw up the appropriate type of - * control, giving defaults as appropriate. If nothing else, we're - * probably going to test every control there is. MRC - * - * This function is synchronized with postoptions(). Read the comments in - * postoptions() header if you change something in gen_options(). - */ -PUBLIC int gen_options ARGS1( - char **, newfile) -{ - int i; -#if defined(USE_SLANG) || defined(COLOR_CURSES) - BOOLEAN can_do_colors; -#endif - static char tempfile[LY_MAXPATH]; - FILE *fp0; - size_t cset_len = 0; - size_t text_len = COLS - 38; /* cf: PutLabel */ - - LYRemoveTemp(tempfile); - fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w"); - if (fp0 == NULL) { - HTAlert(UNABLE_TO_OPEN_TEMPFILE); - return(-1); - } - - LYLocalFileToURL(newfile, tempfile); - - LYforce_no_cache = TRUE; - - BeginInternalPage(fp0, OPTIONS_TITLE, NULL); /* help link below */ - - /* - * I do C, not HTML. Feel free to pretty this up. - */ - fprintf(fp0,"<form action=\"LYNXOPTIONS:\" method=\"post\">\n"); - /* - * use following with some sort of one shot secret key akin to NCSA - * (or was it CUTE?) telnet one shot password to allow ftp to self. - * to prevent spoofing. - */ - fprintf(fp0,"<input name=\"%s\" type=\"hidden\" value=\"%s\">\n", - secure_string, NewSecureValue()); - - /* - * visible text begins here - */ - - /* Submit/Reset/Help */ - fprintf(fp0,"<p align=center>\n"); - fprintf(fp0,"<input type=\"submit\" value=\"Accept Changes\"> - \n"); - fprintf(fp0,"<input type=\"reset\" value=\"Reset Changes\">\n"); - fprintf(fp0,"Left Arrow cancels changes\n"); - fprintf(fp0, "<a href=\"%s%s\">HELP!</a>\n", - helpfilepath, OPTIONS_HELP); - - /* Save options */ - if (!no_option_save) { - fprintf(fp0, "<p align=center>Save options to disk: "); - fprintf(fp0, "<input type=\"checkbox\" name=\"%s\">\n", - save_options_string); - } - - /* - * preformatted text follows - */ - fprintf(fp0,"<pre>\n"); - fprintf(fp0,"\n <em>Personal Preferences</em>\n"); - - /* Cookies: SELECT */ - PutLabel(fp0, "Cookies"); - BeginSelect(fp0, cookies_string); - PutOption(fp0, !LYSetCookies, - cookies_ignore_all_string, - cookies_ignore_all_string); - PutOption(fp0, LYSetCookies && !LYAcceptAllCookies, - cookies_up_to_user_string, - cookies_up_to_user_string); - PutOption(fp0, LYSetCookies && LYAcceptAllCookies, - cookies_accept_all_string, - cookies_accept_all_string); - EndSelect(fp0); - - /* Editor: INPUT */ - PutLabel(fp0, "Editor"); - PutTextInput(fp0, editor_string, NOTEMPTY(editor), text_len, - DISABLED(no_editor || system_editor)); - - /* Emacs keys: ON/OFF */ - PutLabel(fp0, "Emacs keys"); - BeginSelect(fp0, emacs_keys_string); - PutOptValues(fp0, emacs_keys, bool_values); - EndSelect(fp0); - - /* Execution links: SELECT */ -#ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS - PutLabel(fp0, "Execution links"); - BeginSelect(fp0, exec_links_string); -#ifndef NEVER_ALLOW_REMOTE_EXEC - PutOptValues(fp0, local_exec - ? EXEC_ALWAYS - : (local_exec_on_local_files - ? EXEC_LOCAL - : EXEC_NEVER), - exec_links_values); -#else - PutOptValues(fp0, local_exec_on_local_files - ? EXEC_LOCAL - : EXEC_NEVER, - exec_links_values); -#endif /* !NEVER_ALLOW_REMOTE_EXEC */ - EndSelect(fp0); -#endif /* ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS */ - - /* Keypad Mode: SELECT */ - PutLabel(fp0, "Keypad mode"); - BeginSelect(fp0, keypad_mode_string); - PutOptValues(fp0, keypad_mode, keypad_mode_values); - EndSelect(fp0); - - /* Mail Address: INPUT */ - PutLabel(fp0, "Personal mail address"); - PutTextInput(fp0, mail_address_string, - NOTEMPTY(personal_mail_address), text_len, ""); - - /* Select Popups: ON/OFF */ - PutLabel(fp0, "Popups for select fields"); - BeginSelect(fp0, select_popups_string); - PutOptValues(fp0, LYSelectPopups, bool_values); - EndSelect(fp0); - - /* Search Type: SELECT */ - PutLabel(fp0, "Searching type"); - BeginSelect(fp0, search_type_string); - PutOptValues(fp0, case_sensitive, search_type_values); - EndSelect(fp0); - - /* Show Color: SELECT */ -#if defined(USE_SLANG) || defined(COLOR_CURSES) - can_do_colors = 1; -#if defined(COLOR_CURSES) - can_do_colors = has_colors(); -#endif - PutLabel(fp0, "Show color"); - MaybeSelect(fp0, !can_do_colors, show_color_string); - if (no_option_save) { - if (LYShowColor == SHOW_COLOR_NEVER) { - LYShowColor = SHOW_COLOR_OFF; - } else if (LYShowColor == SHOW_COLOR_ALWAYS) { - LYShowColor = SHOW_COLOR_ON; - } - PutOptValues(fp0, LYShowColor, bool_values); - } else { - if (LYChosenShowColor == SHOW_COLOR_UNKNOWN) { - switch (LYrcShowColor) { - case SHOW_COLOR_NEVER: - LYChosenShowColor = - (LYShowColor >= SHOW_COLOR_ON) ? - SHOW_COLOR_ON : SHOW_COLOR_NEVER; - break; - case SHOW_COLOR_ALWAYS: - if (!can_do_colors) - LYChosenShowColor = SHOW_COLOR_ALWAYS; - else - LYChosenShowColor = - (LYShowColor >= SHOW_COLOR_ON) ? - SHOW_COLOR_ALWAYS : SHOW_COLOR_OFF; - break; - default: - LYChosenShowColor = - (LYShowColor >= SHOW_COLOR_ON) ? - SHOW_COLOR_ON : SHOW_COLOR_OFF; - } - } - show_color_values[3].LongName = (can_do_colors) ? always_string - : "Always try"; - PutOptValues(fp0, LYChosenShowColor, show_color_values); - } - EndSelect(fp0); -#endif /* USE_SLANG || COLOR_CURSES */ - - /* Show cursor: ON/OFF */ - PutLabel(fp0, "Show cursor"); - BeginSelect(fp0, show_cursor_string); - PutOptValues(fp0, LYShowCursor, bool_values); - EndSelect(fp0); - - /* User Mode: SELECT */ - PutLabel(fp0, "User mode"); - BeginSelect(fp0, user_mode_string); - PutOptValues(fp0, user_mode, user_mode_values); - EndSelect(fp0); - - /* Verbose Images: ON/OFF */ - PutLabel(fp0, "Verbose images"); - BeginSelect(fp0, verbose_images_string); - PutOptValues(fp0, verbose_img, bool_values); - EndSelect(fp0); - - /* VI Keys: ON/OFF */ - PutLabel(fp0, "VI keys"); - BeginSelect(fp0, vi_keys_string); - PutOptValues(fp0, vi_keys, bool_values); - EndSelect(fp0); - - - /* X Display: INPUT */ - PutLabel(fp0, "X Display"); - PutTextInput(fp0, x_display_string, NOTEMPTY(x_display), text_len, ""); - - /* - * Bookmark Options - */ - fprintf(fp0,"\n <em>Bookmark Options</em>\n"); - - /* Multi-Bookmark Mode: SELECT */ - if (!LYMBMBlocked) { - PutLabel(fp0, "Multi-bookmarks"); - BeginSelect(fp0, mbm_string); - PutOption(fp0, !LYMultiBookmarks, - mbm_off_string, - mbm_off_string); - PutOption(fp0, LYMultiBookmarks && !LYMBMAdvanced, - mbm_standard_string, - mbm_standard_string); - PutOption(fp0, LYMultiBookmarks && LYMBMAdvanced, - mbm_advanced_string, - mbm_advanced_string); - EndSelect(fp0); - } - - /* Bookmarks File Menu: LINK/INPUT */ - if (LYMultiBookmarks) { - - PutLabel(fp0, "Review/edit Bookmarks files"); - fprintf(fp0, - "<a href=\"LYNXOPTIONS://MBM_MENU\">Goto multi-bookmark menu</a>\n"); - - } else { - PutLabel(fp0, "Bookmarks file"); - PutTextInput(fp0, single_bookmark_string, - NOTEMPTY(bookmark_page), text_len, ""); - } - - /* - * Character Set Options - */ - fprintf(fp0,"\n <em>Character Set Options</em>\n"); - - /* Assume Character Set: SELECT */ - /* if (user_mode==ADVANCED_MODE) */ - { - int curval; - curval = UCLYhndl_for_unspec; - - /* - * FIXME: If bogus value in lynx.cfg, then in old way, that is the - * string that was displayed. Now, user will never see that. Good - * or bad? I don't know. MRC - */ - if (curval == current_char_set) { - /* ok, LYRawMode, so use UCAssume_MIMEcharset */ - curval = safeUCGetLYhndl_byMIME(UCAssume_MIMEcharset); - } - PutLabel(fp0, "Assumed document character set"); - BeginSelect(fp0, assume_char_set_string); - for (i = 0; i < LYNumCharsets; i++) { - PutOption(fp0, i==curval, - LYCharSet_UC[i].MIMEname, - LYCharSet_UC[i].MIMEname); - } - EndSelect(fp0); - } - - /* Display Character Set: SELECT */ - PutLabel(fp0, "Display character set"); - BeginSelect(fp0, display_char_set_string); - for (i = 0; LYchar_set_names[i]; i++) { - char temp[10]; - size_t len = strlen(LYchar_set_names[i]); - if (len > cset_len) - cset_len = len; - sprintf(temp, "%d", i); - PutOption(fp0, i==current_char_set, temp, LYchar_set_names[i]); - } - EndSelect(fp0); - - /* Raw Mode: ON/OFF */ - if (LYHaveCJKCharacterSet) - /* - * Since CJK people hardly mixed with other world - * we split the header to make it more readable: - * "CJK mode" for CJK display charsets, and "Raw 8-bit" for others. - */ - PutLabel(fp0, "CJK mode"); - else - PutLabel(fp0, "Raw 8-bit"); - - BeginSelect(fp0, raw_mode_string); - PutOptValues(fp0, LYRawMode, bool_values); - EndSelect(fp0); - - /* - * File Management Options - */ - fprintf(fp0,"\n <em>File Management Options</em>\n"); - - /* FTP sort: SELECT */ - PutLabel(fp0, "Ftp sort criteria"); - BeginSelect(fp0, ftp_sort_string); - PutOptValues(fp0, HTfileSortMethod, ftp_sort_values); - EndSelect(fp0); - -#ifdef DIRED_SUPPORT - /* Local Directory Sort: SELECT */ - PutLabel(fp0, "Local directory sort criteria"); - BeginSelect(fp0, dired_sort_string); - PutOptValues(fp0, dir_list_style, dired_values); - EndSelect(fp0); -#endif /* DIRED_SUPPORT */ - - /* Show dot files: ON/OFF */ - if (!no_dotfiles) { - PutLabel(fp0, "Show dot files"); - BeginSelect(fp0, show_dotfiles_string); - PutOptValues(fp0, show_dotfiles, bool_values); - EndSelect(fp0); - } - - /* - * Headers transferred to remote server - */ - fprintf(fp0,"\n <em>Headers transferred to remote server</em>\n"); - - /* Preferred Document Character Set: INPUT */ - PutLabel(fp0, "Preferred document character set"); - PutTextInput(fp0, preferred_doc_char_string, - NOTEMPTY(pref_charset), cset_len+2, ""); - - /* Preferred Document Language: INPUT */ - PutLabel(fp0, "Preferred document language"); - PutTextInput(fp0, preferred_doc_lang_string, - NOTEMPTY(language), cset_len+2, ""); - - /* User Agent: INPUT */ - if (!no_useragent) { - PutLabel(fp0, "User-Agent header"); - PutTextInput(fp0, user_agent_string, - NOTEMPTY(LYUserAgent), text_len, ""); - } - - if (!LYRestricted) { - fprintf(fp0, - "\n Check your <a href=\"%s\">lynx.cfg</a> here\n", - lynx_cfg_infopage()); - } - - fprintf(fp0,"\n</pre>\n"); - - /* Submit/Reset */ - fprintf(fp0,"<p align=center>\n"); - fprintf(fp0,"<input type=\"submit\" value=\"Accept Changes\">\n - "); - fprintf(fp0,"<input type=\"reset\" value=\"Reset Changes\">\n"); - fprintf(fp0,"Left Arrow cancels changes\n"); - - /* - * close HTML - */ - fprintf(fp0,"</form>\n"); - EndInternalPage(fp0); - - LYCloseTempFP(fp0); - return(0); -} -#endif /* !NO_OPTION_FORMS */ diff --git a/src/LYOptions.h b/src/LYOptions.h index c8fdccbd..ea9e914a 100644 --- a/src/LYOptions.h +++ b/src/LYOptions.h @@ -1,19 +1,65 @@ #ifndef LYOPTIONS_H #define LYOPTIONS_H -#include <LYStructs.h> - -extern BOOLEAN term_options; /* for LYgetstr() */ +extern BOOLEAN term_options; +extern void options NOPARAMS; extern void edit_bookmarks NOPARAMS; -#ifndef NO_OPTION_FORMS -extern int postoptions PARAMS((document *newdoc)); -extern int gen_options PARAMS((char **newfile)); -#endif /* !NO_OPTION_FORMS */ +/* + * Values for the options menu. - FM + * + * L_foo values are the Y coordinates for the menu item. + * B_foo values are the X coordinates for the item's prompt string. + * C_foo values are the X coordinates for the item's value string. + */ +#define L_EDITOR 2 +#define L_DISPLAY 3 + +#define L_HOME 4 +#define C_MULTI 24 +#define B_BOOK 34 +#define C_DEFAULT 50 + +#define L_FTPSTYPE 5 +#define L_MAIL_ADDRESS 6 +#define L_SSEARCH 7 +#define L_LANGUAGE 8 +#define L_PREF_CHARSET 9 +#define L_ASSUME_CHARSET (L_PREF_CHARSET + 1) +#define L_CHARSET 10 +#define L_RAWMODE 11 + +#define L_COLOR L_RAWMODE +#define B_COLOR 44 +#define C_COLOR 62 + +#define L_BOOL_A 12 +#define B_VIKEYS 5 +#define C_VIKEYS 15 +#define B_EMACSKEYS 22 +#define C_EMACSKEYS 36 +#define B_SHOW_DOTFILES 44 +#define C_SHOW_DOTFILES 62 + +#define L_BOOL_B 13 +#define B_SELECT_POPUPS 5 +#define C_SELECT_POPUPS 36 +#define B_SHOW_CURSOR 44 +#define C_SHOW_CURSOR 62 + +#define L_KEYPAD 14 +#define L_LINEED 15 -#ifndef NO_OPTION_MENU -extern void LYoptions NOPARAMS; -#endif /* !NO_OPTION_MENU */ +#ifdef DIRED_SUPPORT +#define L_DIRED 16 +#define L_USER_MODE 17 +#define L_USER_AGENT 18 +#define L_EXEC 19 +#else +#define L_USER_MODE 16 +#define L_USER_AGENT 17 +#define L_EXEC 18 +#endif /* DIRED_SUPPORT */ #endif /* LYOPTIONS_H */ diff --git a/src/LYPrint.c b/src/LYPrint.c index 8c4415d0..2ad75810 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTAccess.h> #include <HTList.h> #include <HTAlert.h> @@ -13,14 +14,23 @@ #include <LYClean.h> #include <LYGetFile.h> #include <LYHistory.h> +#include <LYSystem.h> #include <LYList.h> #include <LYCharSets.h> /* To get current charset for mail header. */ +#ifdef VMS +#include <HTVMSUtils.h> +#endif /* VMS */ +#ifdef DOSPATH +#include <HTDOS.h> +#endif #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* * printfile prints out the current file minus the links and targets - * to a variety of places + * to a veriaty of places */ /* it parses an incoming link that looks like @@ -28,49 +38,30 @@ * LYNXPRINT://LOCAL_FILE/lines=## * LYNXPRINT://MAIL_FILE/lines=## * LYNXPRINT://TO_SCREEN/lines=## - * LYNXPRINT://LPANSI/lines=## * LYNXPRINT://PRINTER/lines=##/number=# */ #define TO_FILE 1 #define TO_SCREEN 2 -/* - * "lpansi.c" - * Original author: Gary Day (gday@comp.uark.edu), 11/30/93 - * Current version: 2.1 by Noel Hunter (noel@wfu.edu), 10/20/94 - * - * Basic structure based on print -- format files for printing from - * _Practical_C_Programming by Steve Oualline, O'Reilly & Associates - * - * adapted from the README for lpansi.c v2.1, dated 10/20/1994: - * Print to ANSI printer on local terminal - * The VT100 standard defines printer on and off escape sequences, - * esc[5i is printer on, and esc[4i is printer off. - * - * incorporate the idea of "lpansi" directly into LYPrint.c - HN - */ -#define LPANSI 3 -#define MAIL 4 -#define PRINTER 5 +#define MAIL 3 +#define PRINTER 4 #ifdef VMS PRIVATE int remove_quotes PARAMS((char *string)); #endif /* VMS */ -PRIVATE char* subject_translate8bit PARAMS((char *source)); - PUBLIC int printfile ARGS1( document *, newdoc) { - static char tempfile[LY_MAXPATH]; + static char tempfile[256]; + static BOOLEAN first = TRUE; char buffer[LINESIZE]; char filename[LINESIZE]; char user_response[256]; int lines_in_file = 0; int printer_number = 0; int pages = 0; - int type = 0, c; - BOOLEAN Lpansi = FALSE; + int type = 0, c, len; FILE *outfile_fp; char *cp = NULL; lynx_printer_item_type *cur_printer; @@ -87,12 +78,11 @@ PUBLIC int printfile ARGS1( HTAtom *encoding; BOOL use_mime, use_cte, use_type; CONST char *disp_charset; - char *subject = NULL; /* print-to-email */ static BOOLEAN first_mail_preparsed = TRUE; char *envbuffer = NULL; #ifdef VMS BOOLEAN isPMDF = FALSE; - char hdrfile[LY_MAXPATH]; + char hdrfile[256]; FILE *hfd; if (!strncasecomp(system_mail, "PMDF SEND", 9)) { @@ -124,7 +114,7 @@ PUBLIC int printfile ARGS1( */ if (HText_getContentBase()) { StrAllocCopy(content_base, HText_getContentBase()); - LYRemoveBlanks(content_base); + collapse_spaces(content_base); if (!(content_base && *content_base)) { FREE(content_base); } @@ -136,7 +126,7 @@ PUBLIC int printfile ARGS1( if (HTisDocumentSource()) { if (HText_getContentLocation()) { StrAllocCopy(content_location, HText_getContentLocation()); - LYRemoveBlanks(content_location); + collapse_spaces(content_location); if (!(content_location && *content_location)) { FREE(content_location); } @@ -156,7 +146,7 @@ PUBLIC int printfile ARGS1( /* * Load the suggested filename string. - FM */ - if (HText_getSugFname() != 0) + if (HText_getSugFname() != NULL) StrAllocCopy(sug_filename, HText_getSugFname()); /* must be freed */ else StrAllocCopy(sug_filename, newdoc->address); /* must be freed */ @@ -206,9 +196,6 @@ PUBLIC int printfile ARGS1( type = TO_FILE; } else if (strstr(link_info, "TO_SCREEN")) { type = TO_SCREEN; - } else if (strstr(link_info, "LPANSI")) { - Lpansi = TRUE; - type = TO_SCREEN; } else if (strstr(link_info, "MAIL_FILE")) { type = MAIL; } else if (strstr(link_info, "PRINTER")) { @@ -240,8 +227,10 @@ PUBLIC int printfile ARGS1( * Act on the request. - FM */ switch (type) { - case TO_FILE: +#if defined(__DJGPP__) || defined(_WINDOWS) + _fmode = O_TEXT; +#endif /* __DJGPP__ or _WINDOWS */ _statusline(FILENAME_PROMPT); retry: strcpy(filename, sug_filename); /* add suggestion info */ /* make the sug_filename conform to system specs */ @@ -336,12 +325,18 @@ PUBLIC int printfile ARGS1( /* * Save cancelled. */ - HTInfoMsg(SAVE_REQUEST_CANCELLED); + _statusline(SAVE_REQUEST_CANCELLED); + sleep(InfoSecs); break; } if (no_dotfiles || !show_dotfiles) { - if (*LYPathLeaf(filename) == '.') { + if (*filename == '.' || +#ifdef VMS + ((cp = strrchr(filename, ':')) && *(cp+1) == '.') || + ((cp = strrchr(filename, ']')) && *(cp+1) == '.') || +#endif /* VMS */ + ((cp = strrchr(filename, '/')) && *(cp+1) == '.')) { HTAlert(FILENAME_CANNOT_BE_DOT); _statusline(NEW_FILENAME_PROMPT); FirstRecall = TRUE; @@ -360,14 +355,24 @@ PUBLIC int printfile ARGS1( if (!strcmp(filename, "/dev/null")) #endif /* VMS */ { - HTInfoMsg(SAVE_REQUEST_CANCELLED); + _statusline(SAVE_REQUEST_CANCELLED); + sleep(InfoSecs); break; } if ((cp = strchr(filename, '~'))) { *(cp++) = '\0'; strcpy(buffer, filename); - LYTrimPathSep(buffer); - strcat(buffer, wwwName(Home_Dir())); + if ((len=strlen(buffer)) > 0 && buffer[len-1] == '/') + buffer[len-1] = '\0'; +#ifdef DOSPATH + strcat(buffer, HTDOS_wwwName((char *)Home_Dir())); +#else +#ifdef VMS + strcat(buffer, HTVMS_wwwName((char *)Home_Dir())); +#else + strcat(buffer, Home_Dir()); +#endif /* VMS */ +#endif /* DOSPATH */ strcat(buffer, cp); strcpy(filename, buffer); } @@ -385,25 +390,22 @@ PUBLIC int printfile ARGS1( strcpy(buffer, filename); } #else - -#ifndef __EMX__ - if (!LYIsPathSep(*filename)) { -#if defined(__DJGPP__) || defined(_WINDOWS) - if (strchr(buffer, ':') != NULL) - cp = NULL; - else -#endif /* __DJGPP__ || _WINDOWS */ + if (*filename != '/') cp = getenv("PWD"); - } else -#endif cp = NULL; - - LYTrimPathSep(cp); if (cp) - sprintf(buffer, "%s/%s", cp, HTSYS_name(filename)); +#ifdef DOSPATH + sprintf(buffer, "%s/%s", cp, HTDOS_name(filename)); +#else + sprintf(buffer, "%s/%s", cp, filename); +#endif else - strcpy(buffer, HTSYS_name(filename)); +#ifdef DOSPATH + strcpy(buffer, HTDOS_name(filename)); +#else + strcpy(buffer, filename); +#endif #endif /* VMS */ /* @@ -423,12 +425,14 @@ PUBLIC int printfile ARGS1( #ifdef VMS if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; - HTInfoMsg(SAVE_REQUEST_CANCELLED); + _statusline(SAVE_REQUEST_CANCELLED); + sleep(InfoSecs); break; } #endif /* VMS */ if (c == 7 || c == 3) { /* Control-G or Control-C */ - HTInfoMsg(SAVE_REQUEST_CANCELLED); + _statusline(SAVE_REQUEST_CANCELLED); + sleep(InfoSecs); break; } if (TOUPPER(c) == 'N') { @@ -455,17 +459,10 @@ PUBLIC int printfile ARGS1( * get any partial or relative URLs resolved * properly if no BASE tag is present to * replace it. - FM - * - * Add timestamp (last reload). */ - fprintf(outfile_fp, - "<!-- X-URL: %s -->\n", newdoc->address); - if (HText_getDate() != NULL) - fprintf(outfile_fp, - "<!-- Date: %s -->\n", HText_getDate()); - fprintf(outfile_fp, - "<BASE HREF=\"%s\">\n", content_base); + "<!-- X-URL: %s -->\n<BASE HREF=\"%s\">\n", + newdoc->address, content_base); } if (LYPrependCharsetToSource && HTisDocumentSource()) { @@ -516,6 +513,9 @@ PUBLIC int printfile ARGS1( #else HTAddSugFilename(buffer); #endif /* VMS */ +#if defined(__DJGPP__) || defined(_WINDOWS) + _fmode = O_BINARY; +#endif /* __DJGPP__ or _WINDOWS */ break; case MAIL: @@ -529,7 +529,8 @@ PUBLIC int printfile ARGS1( #ifdef VMS if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; - HTInfoMsg(MAIL_REQUEST_CANCELLED); + _statusline(MAIL_REQUEST_CANCELLED); + sleep(InfoSecs); break; } #endif /* VMS */ @@ -538,7 +539,8 @@ PUBLIC int printfile ARGS1( addstr(" Ok..."); first_mail_preparsed = FALSE; } else { - HTInfoMsg(MAIL_REQUEST_CANCELLED); + _statusline(MAIL_REQUEST_CANCELLED); + sleep(InfoSecs); break; } } @@ -549,7 +551,8 @@ PUBLIC int printfile ARGS1( if (LYgetstr(user_response, VISIBLE, sizeof(user_response), NORECALL) < 0 || *user_response == '\0') { - HTInfoMsg(MAIL_REQUEST_CANCELLED); + _statusline(MAIL_REQUEST_CANCELLED); + sleep(InfoSecs); break; } @@ -575,13 +578,7 @@ PUBLIC int printfile ARGS1( } use_type = (disp_charset || HTisDocumentSource()); - /* - * Use newdoc->title as a subject instead of sug_filename: - * MORE readable and 8-bit letters shouldn't be a problem - LP - */ - /* change_sug_filename(sug_filename); */ - subject = subject_translate8bit(newdoc->title); - + change_sug_filename(sug_filename); #ifdef VMS if (strchr(user_response,'@') && !strchr(user_response,':') && !strchr(user_response,'%') && !strchr(user_response,'"')) { @@ -589,19 +586,44 @@ PUBLIC int printfile ARGS1( strcpy(user_response, filename); } - LYRemoveTemp(tempfile); - outfile_fp = LYOpenTemp(tempfile, - (HTisDocumentSource()) - ? HTML_SUFFIX - : ".txt", - "w"); - if (outfile_fp == NULL) { + if (first) { + tempname(tempfile, NEW_FILE); + if (isPMDF) { + tempname(hdrfile, NEW_FILE); + if ((len = strlen(hdrfile)) > 4) { + len -= 5; + if (!strcasecomp((hdrfile + len), ".html")) { + hdrfile[len] = '\0'; + strcat(hdrfile, ".txt"); + } + } + } + first = FALSE; + } else { + remove(tempfile); /* remove duplicates */ + } + if (HTisDocumentSource()) { + if ((len = strlen(tempfile)) > 3) { + len -= 4; + if (!strcasecomp((tempfile + len), ".txt")) { + tempfile[len] = '\0'; + strcat(tempfile, ".html"); + } + } + } else if ((len = strlen(tempfile)) > 4) { + len -= 5; + if (!strcasecomp((tempfile + len), ".html")) { + tempfile[len] = '\0'; + strcat(tempfile, ".txt"); + } + } + if ((outfile_fp = LYNewTxtFile(tempfile)) == NULL) { HTAlert(UNABLE_TO_OPEN_TEMPFILE); break; } if (isPMDF) { - if ((hfd = LYOpenTemp(hdrfile, ".txt", "w")) == NULL) { + if ((hfd = LYNewTxtFile(hdrfile)) == NULL) { HTAlert(UNABLE_TO_OPEN_TEMPFILE); break; } @@ -670,15 +692,15 @@ PUBLIC int printfile ARGS1( print_wwwfile_to_fd(outfile_fp, 0); if (keypad_mode) printlist(outfile_fp, FALSE); - LYCloseTempFP(outfile_fp); + fclose(outfile_fp); if (isPMDF) { /* * For PMDF, put the subject in the * header file and close it. - FM */ - fprintf(hfd, "Subject: %.70s\n\n", subject); - LYCloseTempFP(hfd); + fprintf(hfd, "Subject: %.70s\n\n", sug_filename); + fclose(hfd); /* * Now set up the command. - FM */ @@ -694,35 +716,46 @@ PUBLIC int printfile ARGS1( * For "generic" VMS MAIL, include * the subject in the command. - FM */ - remove_quotes(subject); + remove_quotes(sug_filename); sprintf(buffer, "%s %s/subject=\"%.70s\" %s %s", system_mail, system_mail_flags, - subject, + sug_filename, tempfile, user_response); } stop_curses(); printf(MAILING_FILE); - LYSystem(buffer); + fflush(stdout); + system(buffer); + fflush(stdout); sleep(AlertSecs); start_curses(); - if (isPMDF) - LYRemoveTemp(hdrfile); -#else /* Unix or DOS */ + if (isPMDF) { + /* + * Delete the header file. - FM + */ + remove(hdrfile); + } +#else /* Unix: */ + sprintf(buffer, "%s %s", system_mail, system_mail_flags); #ifdef DOSPATH - outfile_fp = LYOpenTemp(tempfile, ".txt", "w"); + sprintf(tempfile, "%s%s", lynx_temp_space, "temp_mail.txt"); + if ((outfile_fp = LYNewTxtFile(tempfile)) == NULL) { + _statusline(MAIL_REQUEST_FAILED); + sleep(AlertSecs); + return; + } #else - sprintf(buffer, "%s %s", system_mail, system_mail_flags); - outfile_fp = popen(buffer, "w"); -#endif - if (outfile_fp == NULL) { - HTAlert(MAIL_REQUEST_FAILED); - break; + if ((outfile_fp = popen(buffer, "w")) == NULL) { + _statusline(MAIL_REQUEST_FAILED); + sleep(AlertSecs); + break; } +#endif /* * Determine which mail headers should be sent. @@ -742,7 +775,7 @@ PUBLIC int printfile ARGS1( /* * Don't send a charset if we have a CJK character set * selected, since it may not be appropriate for mail... - * Also don't use an unofficial "x-" charset. - kw + * Also don't use an inofficial "x-" charset. - kw */ if (!use_cte || LYHaveCJKCharacterSet || strncasecomp(disp_charset, "x-", 2) == 0) { @@ -807,7 +840,7 @@ PUBLIC int printfile ARGS1( * Add the To, Subject, and X-URL headers. - FM */ fprintf(outfile_fp, "To: %s\nSubject: %s\n", - user_response, subject); + user_response, sug_filename); fprintf(outfile_fp, "X-URL: %s\n\n", newdoc->address); if (LYPrependBaseToSource && HTisDocumentSource()) { /* @@ -828,13 +861,13 @@ PUBLIC int printfile ARGS1( #ifdef DOSPATH sprintf(buffer, "%s -t \"%s\" -F %s", system_mail, user_response, tempfile); - LYCloseTempFP(outfile_fp); /* Close the tmpfile. */ + fclose(outfile_fp); /* Close the tmpfile. */ stop_curses(); printf("Sending \n\n$ %s\n\nPlease wait...", buffer); - LYSystem(buffer); + system(buffer); sleep(MessageSecs); start_curses(); - LYRemoveTemp(tempfile); /* Delete the tmpfile. */ + remove(tempfile); /* Delete the tmpfile. */ #else pclose(outfile_fp); #endif @@ -849,11 +882,12 @@ PUBLIC int printfile ARGS1( if (pages > 4) { sprintf(filename, CONFIRM_LONG_SCREEN_PRINT, pages); _statusline(filename); - c = LYgetch(); + c=LYgetch(); #ifdef VMS if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; - HTInfoMsg(PRINT_REQUEST_CANCELLED); + _statusline(PRINT_REQUEST_CANCELLED); + sleep(InfoSecs); break; } #endif /* VMS */ @@ -861,20 +895,18 @@ PUBLIC int printfile ARGS1( || c == '\n' || c == '\r') { addstr(" Ok..."); } else { - HTInfoMsg(PRINT_REQUEST_CANCELLED); + _statusline(PRINT_REQUEST_CANCELLED); + sleep(InfoSecs); break; } } - if (Lpansi) { - _statusline(CHECK_PRINTER); - } else { - _statusline(PRESS_RETURN_TO_BEGIN); - } + _statusline(PRESS_RETURN_TO_BEGIN); *filename = '\0'; if (LYgetstr(filename, VISIBLE, sizeof(filename), NORECALL) < 0) { - HTInfoMsg(PRINT_REQUEST_CANCELLED); + _statusline(PRINT_REQUEST_CANCELLED); + sleep(InfoSecs); break; } @@ -898,8 +930,6 @@ PUBLIC int printfile ARGS1( "<!-- X-URL: %s -->\n<BASE HREF=\"%s\">\n\n", newdoc->address, content_base); } - if (Lpansi) - printf("\033[5i"); print_wwwfile_to_fd(outfile_fp, 0); if (keypad_mode) printlist(outfile_fp, FALSE); @@ -911,18 +941,13 @@ PUBLIC int printfile ARGS1( break; } #endif /* VMS */ - if (Lpansi) { - printf("\n\014"); /* Form feed */ - printf("\033[4i"); - Lpansi = FALSE; - } else { - fprintf(stdout,"\n\n%s", PRESS_RETURN_TO_FINISH); - LYgetch(); /* grab some user input to pause */ + fprintf(stdout,"\n\n%s", PRESS_RETURN_TO_FINISH); + + fflush(stdout); /* refresh to screen */ + LYgetch(); /* grab some user input to pause */ #ifdef VMS - HadVMSInterrupt = FALSE; + HadVMSInterrupt = FALSE; #endif /* VMS */ - } - fflush(stdout); /* refresh to screen */ start_curses(); break; @@ -938,7 +963,8 @@ PUBLIC int printfile ARGS1( #ifdef VMS if (HadVMSInterrupt) { HadVMSInterrupt = FALSE; - HTInfoMsg(PRINT_REQUEST_CANCELLED); + _statusline(PRINT_REQUEST_CANCELLED); + sleep(InfoSecs); break; } #endif /* VMS */ @@ -946,18 +972,34 @@ PUBLIC int printfile ARGS1( || c == '\n' || c == '\r') { addstr(" Ok..."); } else { - HTInfoMsg(PRINT_REQUEST_CANCELLED); + _statusline(PRINT_REQUEST_CANCELLED); + sleep(InfoSecs); break; } } - LYRemoveTemp(tempfile); - outfile_fp = LYOpenTemp(tempfile, - (HTisDocumentSource()) - ? HTML_SUFFIX - : ".txt", - "w"); - if (outfile_fp == NULL) { + if (first) { + tempname(tempfile, NEW_FILE); + first = FALSE; + } else { + remove(tempfile); /* Remove previous tempfile. */ + } + if (((cp = strrchr(tempfile, '.')) != NULL) && +#ifdef VMS + NULL == strchr(cp, ']') && +#endif /* VMS */ + NULL == strchr(cp, '/')) { + if (HTisDocumentSource() && + strcasecomp(cp, HTML_SUFFIX)) { + *cp = '\0'; + strcat(tempfile, HTML_SUFFIX); + } else if (!HTisDocumentSource() && + strcasecomp(cp, ".txt")) { + *cp = '\0'; + strcat(tempfile, ".txt"); + } + } + if ((outfile_fp = LYNewTxtFile(tempfile)) == NULL) { HTAlert(FILE_ALLOC_FAILED); break; } @@ -979,7 +1021,7 @@ PUBLIC int printfile ARGS1( if (keypad_mode) printlist(outfile_fp, FALSE); - LYCloseTempFP(outfile_fp); + fclose(outfile_fp); /* find the right printer number */ { @@ -1092,12 +1134,21 @@ PUBLIC int printfile ARGS1( /* * Printer cancelled. */ - HTInfoMsg(PRINT_REQUEST_CANCELLED); + _statusline(PRINT_REQUEST_CANCELLED); + sleep(InfoSecs); break; } if (no_dotfiles || !show_dotfiles) { - if (*LYPathLeaf(filename) == '.') { + if (*filename == '.' || +#ifdef VMS + ((cp = strrchr(filename, ':')) && + *(cp+1) == '.') || + ((cp = strrchr(filename, ']')) && + *(cp+1) == '.') || +#endif /* VMS */ + ((cp = strrchr(filename, '/')) && + *(cp+1) == '.')) { HTAlert(FILENAME_CANNOT_BE_DOT); _statusline(NEW_FILENAME_PROMPT); FirstRecall = TRUE; @@ -1116,13 +1167,14 @@ PUBLIC int printfile ARGS1( if (!strcmp(filename, "/dev/null")) #endif /* VMS */ { - HTInfoMsg(PRINT_REQUEST_CANCELLED); + _statusline(PRINT_REQUEST_CANCELLED); + sleep(InfoSecs); break; } HTAddSugFilename(filename); } -#if defined (VMS) || defined (__EMX__) || defined(__DJGPP__) +#ifdef VMS sprintf(buffer, cur_printer->command, tempfile, filename, "", "", "", "", "", "", "", "", "", ""); #else /* Unix: */ @@ -1148,7 +1200,8 @@ PUBLIC int printfile ARGS1( move(1,1); stop_curses(); - CTRACE(tfp, "command: %s\n", buffer); + if (TRACE) + fprintf(stderr, "command: %s\n", buffer); printf(PRINTING_FILE); #ifdef VMS /* @@ -1166,7 +1219,8 @@ PUBLIC int printfile ARGS1( StrAllocCat(envbuffer, HText_getTitle()); putenv(envbuffer); #endif /* VMS */ - LYSystem(buffer); + fflush(stdout); + system(buffer); #ifdef VMS /* * Remove LYNX_PRINT_TITLE logical. - FM @@ -1186,11 +1240,11 @@ PUBLIC int printfile ARGS1( #endif /* !VMS */ sleep(MessageSecs); start_curses(); + /* don't remove(tempfile); */ } /* end switch */ FREE(link_info); FREE(sug_filename); - FREE(subject); FREE(content_base); FREE(content_location); return(NORMAL); @@ -1215,129 +1269,83 @@ PRIVATE int remove_quotes ARGS1( #endif /* VMS */ /* - * Mail subject may have 8-bit characters and they are in display charset. - * There is no stable practice for 8-bit subject encodings: - * MIME define "quoted-printable" which holds charset info - * but most mailers still don't support it, on the other hand - * many mailers send open 8-bit subjects without charset info - * and use local assumption for certain countries. - * - * We translate subject to "outgoing_mail_charset" (defined in lynx.cfg) - * it may correspond to US-ASCII as the safest value or any other - * lynx character handler, -1 for no translation (so display charset). - * - */ -PRIVATE char* subject_translate8bit ARGS1(char *, source) -{ - CONST char *p = source; - char temp[256]; - char *q = temp; - char *target = NULL; - - int charset_in, charset_out, uck; - char replace_buf [10]; - - int i = outgoing_mail_charset; /* from lynx.cfg, -1 by default */ - - if (i < 0 - || LYHaveCJKCharacterSet - || LYCharSet_UC[i].enc == UCT_ENC_CJK) { - return(source); /* OK */ - } else { - charset_out = i; - charset_in = current_char_set; - } - - for ( ; *p; p++) { - LYstrncpy(q, p, 1); - if ((unsigned char)*q <= 127) { - StrAllocCat(target, q); - } else { - uck = UCTransCharStr(replace_buf, sizeof(replace_buf), *q, - charset_in, charset_out, YES); - if (uck >0) - StrAllocCat(target, replace_buf); - } - } - - return(target); -} - -/* * print_options writes out the current printer choices to a file * so that the user can select printers in the same way that * they select all other links * printer links look like * LYNXPRINT://LOCAL_FILE/lines=# print to a local file * LYNXPRINT://TO_SCREEN/lines=# print to the screen - * LYNXPRINT://LPANSI/lines=# print to the local terminal * LYNXPRINT://MAIL_FILE/lines=# mail the file * LYNXPRINT://PRINTER/lines=#/number=# print to printer number # */ -PUBLIC int print_options ARGS3( +PUBLIC int print_options ARGS2( char **, newfile, - char **, printed_url, int, lines_in_file) { - static char tempfile[LY_MAXPATH]; + static char tempfile[256]; + static BOOLEAN first = TRUE; + static char print_filename[256]; char buffer[LINESIZE]; int count; int pages; FILE *fp0; lynx_printer_item_type *cur_printer; + pages = lines_in_file/66 + 1; - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { + if (first) { + tempname(tempfile, NEW_FILE); +#if defined (VMS) || defined (DOSPATH) + sprintf(print_filename, "file://localhost/%s", tempfile); +#else + sprintf(print_filename, "file://localhost%s", tempfile); +#endif /* VMS */ + first = FALSE; +#ifdef VMS + } else { + remove(tempfile); /* Remove duplicates on VMS. */ +#endif /* !VMS */ + } + + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { HTAlert(UNABLE_TO_OPEN_PRINTOP_FILE); return(-1); } - LYLocalFileToURL(newfile, tempfile); + StrAllocCopy(*newfile, print_filename); + LYforce_no_cache = TRUE; - BeginInternalPage(fp0, PRINT_OPTIONS_TITLE, PRINT_OPTIONS_HELP); + fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n", + PRINT_OPTIONS_TITLE); - fprintf(fp0, "<pre>\n"); + fprintf(fp0,"<h1>Printing Options (%s Version %s)</h1><pre>\n", + LYNX_NAME, LYNX_VERSION); - /* pages = lines_in_file/66 + 1; */ pages = (lines_in_file+65)/66; - sprintf(buffer, " \ -<em>Document:</em> %s\n \ -<em>Number of lines:</em> %d\n \ -<em>Number of pages:</em> %d page%s (approximately)\n", - *printed_url, - lines_in_file, - pages, (pages > 1 ? "s" : "")); - fputs(buffer, fp0); + sprintf(buffer, + " There are %d lines, or approximately %d page%s, to print.\n", + lines_in_file, pages, (pages > 1 ? "s" : "")); + fputs(buffer,fp0); if (no_print || no_disk_save || child_lynx || no_mail) - fprintf(fp0, " <em>Some print functions have been disabled!</em>\n"); + fprintf(fp0, " Some print functions have been disabled!!!\n"); - fprintf(fp0, "\n%s options:\n", - (user_mode == NOVICE_MODE) ? "Standard print" : "Print"); + fprintf(fp0, " You have the following print choices.\n"); + fprintf(fp0, " Please select one:\n\n"); if (child_lynx == FALSE && no_disk_save == FALSE && no_print == FALSE) fprintf(fp0, " <a href=\"LYNXPRINT://LOCAL_FILE/lines=%d\">Save to a local file</a>\n", lines_in_file); else - fprintf(fp0," <em>Save to disk disabled.</em>\n"); - if (child_lynx == FALSE && no_mail == FALSE && local_host_only == FALSE) + fprintf(fp0," Save to disk disabled.\n"); + if (child_lynx == FALSE && no_mail == FALSE) fprintf(fp0, " <a href=\"LYNXPRINT://MAIL_FILE/lines=%d\">Mail the file</a>\n", lines_in_file); - -#ifndef DOSPATH fprintf(fp0, " <a href=\"LYNXPRINT://TO_SCREEN/lines=%d\">Print to the screen</a>\n", lines_in_file); - fprintf(fp0, - " <a href=\"LYNXPRINT://LPANSI/lines=%d\">Print out on a printer attached to your vt100 terminal</a>\n", - lines_in_file); -#endif - - if (user_mode == NOVICE_MODE) - fprintf(fp0, "\nLocal additions:\n"); for (count = 0, cur_printer = printers; cur_printer != NULL; cur_printer = cur_printer->next, count++) @@ -1349,9 +1357,8 @@ PUBLIC int print_options ARGS3( cur_printer->name : "No Name Given")); fprintf(fp0, "</a>\n"); } - fprintf(fp0, "</pre>\n"); - EndInternalPage(fp0); - LYCloseTempFP(fp0); + fprintf(fp0, "</pre>\n</body>\n"); + fclose(fp0); LYforce_no_cache = TRUE; return(0); diff --git a/src/LYPrint.h b/src/LYPrint.h index 12efe47c..fec8200f 100644 --- a/src/LYPrint.h +++ b/src/LYPrint.h @@ -1,3 +1,4 @@ + #ifndef LYPRINT_H #define LYPRINT_H @@ -6,8 +7,9 @@ #endif /* LYSTRUCTS_H */ extern int printfile PARAMS((document *newdoc)); -extern int print_options PARAMS((char **newfile, - char **printed_url, int lines_in_file)); +extern int print_options PARAMS((char **newfile, int lines_in_file)); + +#define PRINT_OPTIONS_TITLE "Lynx Printing Options" #endif /* LYPRINT_H */ diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 59c8d15e..228d5029 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTFile.h> #include <UCMap.h> @@ -14,9 +15,7 @@ #include <LYCurses.h> #include <LYSignal.h> #include <LYBookmark.h> -#include <LYCookie.h> #include <LYReadCFG.h> -#include <HTAlert.h> #ifdef DIRED_SUPPORT #include <LYLocal.h> @@ -25,12 +24,20 @@ #include <LYexit.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + extern int HTNewsMaxChunk; /* Max news articles before chunking (HTNews.c) */ extern int HTNewsChunkSize; /* Number of news articles per chunk (HTNews.c) */ PUBLIC BOOLEAN have_read_cfg=FALSE; PUBLIC BOOLEAN LYUseNoviceLineTwo=TRUE; +#ifdef VMS +#define DISPLAY "DECW$DISPLAY" +#else +#define DISPLAY "DISPLAY" +#endif /* VMS */ + /* * Translate a TRUE/FALSE field in a string buffer. */ @@ -131,7 +138,7 @@ PRIVATE void add_item_to_list ARGS2( */ cur_item = (lynx_html_item_type *)calloc(sizeof(lynx_html_item_type),1); if (cur_item == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); *list_ptr = cur_item; atexit(free_item_list); } else { @@ -144,7 +151,7 @@ PRIVATE void add_item_to_list ARGS2( ; /* null body */ cur_item = (lynx_html_item_type *)calloc(sizeof(lynx_html_item_type),1); if (cur_item == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); else prev_item->next = cur_item; } @@ -162,27 +169,20 @@ PRIVATE void add_item_to_list ARGS2( */ cur_item->name = (char *)calloc((colon-buffer+1),sizeof(char)); if (cur_item->name == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); LYstrncpy(cur_item->name, buffer, (int)(colon-buffer)); remove_backslashes(cur_item->name); /* - * Process TRUE/FALSE field. If we do not find one, assume it is - * true. In any case, we want the command string. + * Process TRUE/FALSE field */ - if ((next_colon = find_colon(colon+1)) == NULL) { - next_colon = colon + strlen(colon); - } - if (next_colon - (colon+1) > 0) { + if ((next_colon = find_colon(colon+1)) != NULL) { cur_item->command = (char *)calloc(next_colon-colon, sizeof(char)); if (cur_item->command == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); LYstrncpy(cur_item->command, colon+1, (int)(next_colon-(colon+1))); remove_backslashes(cur_item->command); - cur_item->always_enabled = TRUE; - } - if (*next_colon++) { - cur_item->always_enabled = is_true(next_colon); + cur_item->always_enabled = is_true(next_colon+1); } } } @@ -227,7 +227,7 @@ PRIVATE void add_printer_to_list ARGS2( */ cur_item = (lynx_printer_item_type *)calloc(sizeof(lynx_printer_item_type),1); if (cur_item == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); *list_ptr = cur_item; atexit(free_printer_item_list); } else { @@ -241,7 +241,7 @@ PRIVATE void add_printer_to_list ARGS2( cur_item = (lynx_printer_item_type *)calloc(sizeof(lynx_printer_item_type),1); if (cur_item == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); else prev_item->next = cur_item; } @@ -259,7 +259,7 @@ PRIVATE void add_printer_to_list ARGS2( */ cur_item->name = (char *)calloc((colon-buffer+1), sizeof(char)); if (cur_item->name == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); LYstrncpy(cur_item->name, buffer, (int)(colon-buffer)); remove_backslashes(cur_item->name); @@ -269,7 +269,7 @@ PRIVATE void add_printer_to_list ARGS2( if ((next_colon = find_colon(colon+1)) != NULL) { cur_item->command = (char *)calloc(next_colon-colon, sizeof(char)); if (cur_item->command == NULL) - outofmem(__FILE__, "read_cfg"); + perror("Out of memory in read_cfg"); LYstrncpy(cur_item->command, colon+1, (int)(next_colon-(colon+1))); remove_backslashes(cur_item->command); cur_item->always_enabled = is_true(next_colon+1); @@ -297,7 +297,7 @@ PRIVATE void add_printer_to_list ARGS2( int default_fg = COLOR_WHITE; int default_bg = COLOR_BLACK; -static CONST char *Color_Strings[16] = +static char *Color_Strings[16] = { "black", "red", @@ -437,767 +437,892 @@ PRIVATE void parse_color ARGS1( } #endif /* USE_COLOR_TABLE */ -#define MAX_LINE_BUFFER_LEN 501 - -typedef int (*ParseFunc) PARAMS((char *)); - -typedef union { - lynx_html_item_type ** add_value; - BOOLEAN * set_value; - int * int_value; - char ** str_value; - ParseFunc fun_value; - long def_value; -} ConfigUnion; - -#undef PARSE_DEBUG -#ifdef PARSE_DEBUG -#define ParseData \ - lynx_html_item_type** add_value; \ - BOOLEAN *set_value; \ - int *int_value; \ - char **str_value; \ - ParseFunc fun_value; \ - long def_value -#define PARSE_ADD(n,t,v) {n,t, &v, 0, 0, 0, 0, 0} -#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 -#define ParseData long value -#define PARSE_ADD(n,t,v) {n,t, (long)&(v)} -#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 +/* + * Process the configuration file (lynx.cfg). + */ +PUBLIC void read_cfg ARGS3( + char *, cfg_filename, + char *, parent_filename, + int, nesting_level) { - CONST char *name; - int type; -#define CONF_UNSPECIFIED 0 -#define CONF_BOOL 1 /* BOOLEAN type */ -#define CONF_FUN 2 -#define CONF_INT 3 -#define CONF_STR 4 -#define CONF_ENV 5 /* from environment variable */ -#define CONF_ENV2 6 /* from environment VARIABLE */ -#define CONF_INCLUDE 7 /* include file-- handle special */ -#define CONF_ADD_ITEM 8 -#define CONF_ADD_TRUSTED 9 - - ParseData; -} -Config_Type; + FILE *fp; + char buffer[501]; + char temp[501]; + char *cp, *cp1; + int i, j, len; -static int assume_charset_fun ARGS1( - char *, value) -{ - UCLYhndl_for_unspec = safeUCGetLYhndl_byMIME(value); - StrAllocCopy(UCAssume_MIMEcharset, - LYCharSet_UC[UCLYhndl_for_unspec].MIMEname); -/* this may be a memory for bogus typo - - StrAllocCopy(UCAssume_MIMEcharset, value); - LYLowerCase(UCAssume_MIMEcharset); */ - - return 0; -} + if (TRACE) { + fprintf(stderr, + "Loading cfg file '%s'.\n", cfg_filename); + } + /* + * Don't get hung up by an include file loop. Arbitrary max depth + * of 10. - BL + */ + if (nesting_level > 10) { + fprintf(stderr, + "More than %d nested lynx.cfg includes -- perhaps there is a loop?!?\n", + nesting_level - 1); + fprintf(stderr,"Last attempted include was '%s',\n", cfg_filename); + fprintf(stderr,"included from '%s'.\n", parent_filename); + exit(-1); + } + /* + * Locate and open the file. + */ + if (!cfg_filename || strlen(cfg_filename) == 0) { + if (TRACE) + fprintf(stderr,"No filename following -cfg switch!\n"); + return; + } + if ((fp = fopen(cfg_filename,"r")) == NULL) { + if (TRACE) + fprintf(stderr,"lynx.cfg file not found as %s\n",cfg_filename); + return; + } + have_read_cfg=TRUE; -static int assume_local_charset_fun ARGS1( - char *, value) -{ - UCLYhndl_HTFile_for_unspec = safeUCGetLYhndl_byMIME(value); - return 0; -} + /* + * Process each line in the file. + */ + while (fgets(buffer, 500, fp) != NULL) { + /* + * Strip off \n at the end. + */ + if ((cp = (char *)strchr(buffer, '\n')) != NULL) + *cp = '\0'; -static int assume_unrec_charset_fun ARGS1( - char *, value) -{ - UCLYhndl_for_unrec = safeUCGetLYhndl_byMIME(value); - return 0; -} + /* + * Trim off any trailing comments. + */ + if ((cp = (char *)strrchr(buffer, ':')) != NULL) { + if ((cp1 = (char *)strchr(cp, '#')) != NULL) { + cp1--; + if (isspace((unsigned char)*cp1)) { + *cp1 = '\0'; + } + } + } -static int character_set_fun ARGS1( - char *, value) -{ - int i = UCGetLYhndl_byAnyName(value); /* by MIME or full name */ - if (i < 0) - ; /* do nothing here: so fallback to userdefs.h */ - else - current_char_set = i; + /* + * Strip off trailing white space. + */ + len = strlen(buffer); + while (len && isspace(buffer[len-1])) { + len--; + buffer[len] = '\0'; + } - return 0; -} + /* + * Skip any blank or purely comment lines. + */ + if (buffer[0] == '\0' || buffer[0] == '#') + continue; -static int outgoing_mail_charset_fun ARGS1( - char *, value) -{ - outgoing_mail_charset = UCGetLYhndl_byMIME(value); - /* -1 if NULL or not recognized value: no translation (compatibility) */ + /* + * Process the string buffer. + */ + switch (TOUPPER(buffer[0])) { + + case 'A': + if (!strncasecomp(buffer, "ALERTSECS:", 10)) { + strcpy(temp, buffer+10); + for (i = 0; temp[i]; i++) { + if (!isdigit(temp[i])) { + temp[i] = '\0'; + break; + } + } + if (temp[0]) + AlertSecs = atoi(temp); - return 0; -} + } else if (!strncasecomp(buffer, "ALWAYS_RESUBMIT_POSTS:", 22)) { + LYresubmit_posts = is_true(buffer+22); +#ifdef EXEC_LINKS + } else if (!strncasecomp(buffer, "ALWAYS_TRUSTED_EXEC:", 20)) { + add_trusted(&buffer[20], ALWAYS_EXEC_PATH); /* Add exec path */ +#endif /* EXEC_LINKS */ + + } else if (!strncasecomp(buffer, "ASSUME_CHARSET:", 15)) { + StrAllocCopy(UCAssume_MIMEcharset, buffer+15); + for (i = 0; UCAssume_MIMEcharset[i]; i++) + UCAssume_MIMEcharset[i] = TOLOWER(UCAssume_MIMEcharset[i]); + UCLYhndl_for_unspec = + UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + + } else if (!strncasecomp(buffer, "ASSUME_LOCAL_CHARSET:", 21)) { + StrAllocCopy(UCAssume_localMIMEcharset, buffer+21); + for (i = 0; UCAssume_localMIMEcharset[i]; i++) + UCAssume_localMIMEcharset[i] = + TOLOWER(UCAssume_localMIMEcharset[i]); + UCLYhndl_HTFile_for_unspec = + UCGetLYhndl_byMIME(UCAssume_localMIMEcharset); + + } else if (!strncasecomp(buffer, "ASSUME_UNREC_CHARSET:", 21)) { + StrAllocCopy(UCAssume_unrecMIMEcharset, buffer+21); + for (i = 0; UCAssume_unrecMIMEcharset[i]; i++) + UCAssume_unrecMIMEcharset[i] = + TOLOWER(UCAssume_unrecMIMEcharset[i]); + UCLYhndl_for_unrec = + UCGetLYhndl_byMIME(UCAssume_unrecMIMEcharset); + } + break; -#ifdef USE_COLOR_TABLE -static int color_fun ARGS1( - char *, value) -{ - parse_color (value); - return 0; -} -#endif + case 'B': + if (!strncasecomp(buffer, "BLOCK_MULTI_BOOKMARKS:", 22)) { + LYMBMBlocked = is_true(buffer+22); -static int default_bookmark_file_fun ARGS1( - char *, value) -{ - StrAllocCopy(bookmark_page, value); - StrAllocCopy(BookmarkPage, bookmark_page); - StrAllocCopy(MBM_A_subbookmark[0], bookmark_page); - StrAllocCopy(MBM_A_subdescript[0], MULTIBOOKMARKS_DEFAULT); - return 0; -} + } else if (!strncasecomp(buffer, "BOLD_H1:", 8)) { + bold_H1 = is_true(buffer+8); -static int default_cache_size_fun ARGS1( - char *, value) -{ - HTCacheSize = atoi(value); - if (HTCacheSize < 2) HTCacheSize = 2; - return 0; -} + } else if (!strncasecomp(buffer, "BOLD_HEADERS:", 13)) { + bold_headers = is_true(buffer+13); -static int default_editor_fun ARGS1( - char *, value) -{ - if (!system_editor) StrAllocCopy(editor, value); - return 0; -} + } else if (!strncasecomp(buffer, "BOLD_NAME_ANCHORS:", 18)) { + bold_name_anchors = is_true(buffer+18); + } + break; + + case 'C': + if (!strncasecomp(buffer, "CASE_SENSITIVE_ALWAYS_ON:", 25)) { + case_sensitive = is_true(buffer+25); + + } else if (!strncasecomp(buffer, "CHARACTER_SET:", 14)) { + for (i = 0; LYchar_set_names[i]; i++) { + if (!strncmp(buffer+14, + LYchar_set_names[i], strlen(buffer+14))) { + current_char_set=i; + HTMLSetRawModeDefault(i); + break; + } + } -static int numbers_as_arrows_fun ARGS1( - char *, value) -{ - if (is_true(value)) - keypad_mode = NUMBERS_AS_ARROWS; - else - keypad_mode = LINKS_ARE_NUMBERED; + } else if (!strncasecomp(buffer, "CHECKMAIL:", 10)) { + check_mail = is_true(buffer+10); - return 0; -} + } else if (!strncasecomp(buffer, "COLLAPSE_BR_TAGS:", 17)) { + LYCollapseBRs = is_true(buffer+17); -static int default_user_mode_fun ARGS1( - char *, value) -{ - if (!strncasecomp(value, "NOVICE", 6)) - user_mode = NOVICE_MODE; - else if (!strncasecomp(value, "INTER", 5)) - user_mode = INTERMEDIATE_MODE; - else if (!strncasecomp(value, "ADVANCE", 7)) - user_mode = ADVANCED_MODE; - - return 0; -} +#if USE_COLOR_TABLE + } else if (!strncasecomp(buffer, "COLOR:", 6)) { + parse_color(buffer + 6); +#endif /* USE_COLOR_TABLE */ -#ifdef DIRED_SUPPORT -static int dired_menu_fun ARGS1( - char *, value) -{ - add_menu_item(value); - return 0; -} -#endif + } else if (!strncasecomp(buffer, "cso_proxy:", 10)) { + if (getenv("cso_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "cso_proxy"); + Define_VMSLogical(temp, (char *)&buffer[10]); +#else + strcpy(temp, "cso_proxy="); + StrAllocCopy(cso_proxy_putenv_cmd, temp); + StrAllocCat(cso_proxy_putenv_cmd, (char *)&buffer[10]); + putenv(cso_proxy_putenv_cmd); +#endif /* VMS */ + } -static int jumpfile_fun ARGS1( - char *, value) -{ - char buffer [MAX_LINE_BUFFER_LEN]; +#ifdef VMS + } else if (!strncasecomp(buffer, "CSWING_PATH:", 12)) { + StrAllocCopy(LYCSwingPath, buffer+12); +#endif /* VMS */ + } + break; + + case 'D': + if (!strncasecomp(buffer, "DEFAULT_BOOKMARK_FILE:", 22)) { + StrAllocCopy(bookmark_page, buffer+22); + StrAllocCopy(BookmarkPage, bookmark_page); + StrAllocCopy(MBM_A_subbookmark[0], bookmark_page); + StrAllocCopy(MBM_A_subdescript[0], MULTIBOOKMARKS_DEFAULT); + + } else if (!strncasecomp(buffer, "DEFAULT_CACHE_SIZE:", 19)) { + HTCacheSize = atoi(buffer+19); + if (HTCacheSize < 2) HTCacheSize = 2; + + } else if (!system_editor && + !strncasecomp(buffer, "DEFAULT_EDITOR:", 15)) { + StrAllocCopy(editor, buffer+15); + + } else if (!strncasecomp(buffer, "DEFAULT_INDEX_FILE:", 19)) { + StrAllocCopy(indexfile, buffer+19); + + } else if (!strncasecomp(buffer, + "DEFAULT_KEYPAD_MODE_IS_NUMBERS_AS_ARROWS:", 41)) { + if (is_true(buffer+41)) + keypad_mode = NUMBERS_AS_ARROWS; + else + keypad_mode = LINKS_ARE_NUMBERED; - sprintf (buffer, "JUMPFILE:%s", value); - if (!LYJumpInit(buffer)) - CTRACE(tfp, "Failed to register %s\n", buffer); + } else if (!strncasecomp(buffer, "DEFAULT_USER_MODE:", 18)) { + if (!strncasecomp(buffer+18, "NOVICE", 6)) + user_mode = NOVICE_MODE; + else if (!strncasecomp(buffer+18, "INTER", 5)) + user_mode = INTERMEDIATE_MODE; + else if (!strncasecomp(buffer+18, "ADVANCE", 7)) + user_mode = ADVANCED_MODE; - return 0; -} +#if defined(VMS) && defined(VAXC) && !defined(__DECC) + } else if (!strncasecomp(buffer, + "DEFAULT_VIRTUAL_MEMORY_SIZE:", 28)) { + HTVirtualMemorySize = atoi(buffer+28); +#endif /* VMS && VAXC && !__DECC */ -static int keymap_fun ARGS1( - char *, key) -{ - char *func; - - if ((func = strchr(key, ':')) != NULL) { - *func++ = '\0'; - /* Allow comments on the ends of key remapping lines. - DT */ - if (!remap(key, strtok(func, " \t\n#"))) - fprintf(stderr, - "key remapping of %s to %s failed\n",key,func); - else if (!strcmp("TOGGLE_HELP", strtok(func, " \t\n#"))) - LYUseNoviceLineTwo = FALSE; - } - return 0; -} +#ifdef DIRED_SUPPORT + } else if (!strncasecomp(buffer, "DIRED_MENU:", 11)) { + add_menu_item(&buffer[11]); +#endif /* DIRED_SUPPORT */ -static int localhost_alias_fun ARGS1( - char *, value) -{ - LYAddLocalhostAlias(value); - return 0; -} + } else if (!strncasecomp(buffer, "DOWNLOADER:", 11)) { + add_item_to_list(&buffer[11], &downloaders); + } + break; -#ifdef LYNXCGI_LINKS -static int lynxcgi_environment_fun ARGS1( - char *, value) -{ - add_lynxcgi_environment(value); - return 0; -} + case 'E': + if (!strncasecomp(buffer, "EMACS_KEYS_ALWAYS_ON:", 21)) { + emacs_keys = is_true(buffer+21); + + } else if (!strncasecomp(buffer, "ENABLE_SCROLLBACK:", 18)) { + enable_scrollback = is_true(buffer+18); + } +#ifdef USE_EXTERNALS + else if(!strncasecomp(buffer,"EXTERNAL:",9)) { + add_item_to_list(&buffer[9],&externals); + } #endif + break; -static int lynx_sig_file_fun ARGS1( - char *, value) -{ - if (LYPathOffHomeOK(value, 256)) { - StrAllocCopy(LynxSigFile, value); - LYAddPathToHome(value, 256, LynxSigFile); - StrAllocCopy(LynxSigFile, value); - CTRACE(tfp, "LYNX_SIG_FILE set to '%s'\n", LynxSigFile); - } else { - CTRACE(tfp, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n", LYNX_SIG_FILE); - } - return 0; -} + case 'F': + if (!strncasecomp(buffer, "finger_proxy:", 13)) { + if (getenv("finger_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "finger_proxy"); + Define_VMSLogical(temp, (char *)&buffer[13]); +#else + strcpy(temp, "finger_proxy="); + StrAllocCopy(finger_proxy_putenv_cmd, temp); + StrAllocCat(finger_proxy_putenv_cmd, (char *)&buffer[13]); + putenv(finger_proxy_putenv_cmd); +#endif /* VMS */ + } -static int news_chunk_size_fun ARGS1( - char *, value) -{ - HTNewsChunkSize = atoi(value); - /* - * If the new HTNewsChunkSize exceeds the maximum, - * increase HTNewsMaxChunk to this size. - FM - */ - if (HTNewsChunkSize > HTNewsMaxChunk) - HTNewsMaxChunk = HTNewsChunkSize; - return 0; -} + } else if (!strncasecomp(buffer, "FORCE_SSL_COOKIES_SECURE:", 25)) { + LYForceSSLCookiesSecure = is_true(buffer+25); -static int news_max_chunk_fun ARGS1( - char *, value) -{ - HTNewsMaxChunk = atoi(value); - /* - * If HTNewsChunkSize exceeds the new maximum, - * reduce HTNewsChunkSize to this maximum. - FM - */ - if (HTNewsChunkSize > HTNewsMaxChunk) - HTNewsChunkSize = HTNewsMaxChunk; - return 0; -} + } else if (!strncasecomp(buffer, "ftp_proxy:", 10)) { + if (getenv("ftp_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "ftp_proxy"); + Define_VMSLogical(temp, (char *)&buffer[10]); +#else + strcpy(temp, "ftp_proxy="); + StrAllocCopy(ftp_proxy_putenv_cmd, temp); + StrAllocCat(ftp_proxy_putenv_cmd, (char *)&buffer[10]); + putenv(ftp_proxy_putenv_cmd); +#endif /* VMS */ + } + } + break; -static int news_posting_fun ARGS1( - char *, value) -{ - LYNewsPosting = is_true(value); - no_newspost = (LYNewsPosting == FALSE); - return 0; -} + case 'G': + if (!strncasecomp(buffer, "GLOBAL_EXTENSION_MAP:", 21)) { + StrAllocCopy(global_extension_map, buffer+21); -static int printer_fun ARGS1( - char *, value) -{ - add_printer_to_list(value, &printers); - return 0; -} + } else if (!strncasecomp(buffer, "GLOBAL_MAILCAP:", 15)) { + StrAllocCopy(global_type_map, buffer+15); -static int suffix_fun ARGS1( - char *, value) -{ - char *mime_type; + } else if (!strncasecomp(buffer, "gopher_proxy:", 13)) { + if (getenv("gopher_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "gopher_proxy"); + Define_VMSLogical(temp, (char *)&buffer[13]); +#else + strcpy(temp, "gopher_proxy="); + StrAllocCopy(gopher_proxy_putenv_cmd, temp); + StrAllocCat(gopher_proxy_putenv_cmd, (char *)&buffer[13]); + putenv(gopher_proxy_putenv_cmd); +#endif /* VMS */ + } - if ((strlen (value) < 3) - || (NULL == (mime_type = strchr (value, ':')))) - return 0; + } else if (!strncasecomp(buffer, "GOTOBUFFER:", 11)) { + goto_buffer = is_true(buffer+11); + } + break; - *mime_type++ = '\0'; + case 'H': + if (!strncasecomp(buffer, "HELPFILE:", 9)) { + StrAllocCopy(helpfile, buffer+9); - LYRemoveBlanks(mime_type); - LYLowerCase(mime_type); + } else if (!strncasecomp(buffer, "HISTORICAL_COMMENTS:", 20)) { + historical_comments = is_true(buffer+20); - if (strstr(mime_type, "tex") != NULL || - strstr(mime_type, "postscript") != NULL || - strstr(mime_type, "sh") != NULL || - strstr(mime_type, "troff") != NULL || - strstr(mime_type, "rtf") != NULL) - HTSetSuffix(value, mime_type, "8bit", 1.0); - else - HTSetSuffix(value, mime_type, "binary", 1.0); + } else if (!strncasecomp(buffer, "http_proxy:", 11)) { + if (getenv("http_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "http_proxy"); + Define_VMSLogical(temp, (char *)&buffer[11]); +#else + strcpy(temp, "http_proxy="); + StrAllocCopy(http_proxy_putenv_cmd, temp); + StrAllocCat(http_proxy_putenv_cmd, (char *)&buffer[11]); + putenv(http_proxy_putenv_cmd); +#endif /* VMS */ + } - return 0; -} + } else if (!strncasecomp(buffer, "https_proxy:", 12)) { + if (getenv("https_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "https_proxy"); + Define_VMSLogical(temp, (char *)&buffer[12]); +#else + strcpy(temp, "https_proxy="); + StrAllocCopy(https_proxy_putenv_cmd, temp); + StrAllocCat(https_proxy_putenv_cmd, (char *)&buffer[12]); + putenv(https_proxy_putenv_cmd); +#endif /* VMS */ + } + } + break; + + case 'I': + if (!strncasecomp(buffer, "include:", 8)) { + strcpy(temp, buffer+8); + read_cfg(temp, cfg_filename, nesting_level + 1); + } else if (!strncasecomp(buffer, "INFOSECS:", 9)) { + strcpy(temp, buffer+9); + for (i = 0; temp[i]; i++) { + if (!isdigit(temp[i])) { + temp[i] = '\0'; + break; + } + } + if (temp[0]) + InfoSecs = atoi(temp); + } + break; -static int system_editor_fun ARGS1( - char *, value) -{ - StrAllocCopy(editor, value); - system_editor = TRUE; - return 0; -} + case 'J': + if (!strncasecomp(buffer, "JUMP_PROMPT:", 12)) { + StrAllocCopy(jumpprompt, buffer+12); -static int viewer_fun ARGS1( - char *, value) -{ - char *mime_type; - char *viewer; - char *environment; + } else if (!strncasecomp(buffer, "JUMPBUFFER:", 11)) { + jump_buffer = is_true(buffer+11); - mime_type = value; + } else if (!strncasecomp(buffer, "JUMPFILE:", 9)) { + if (!LYJumpInit(buffer)) { + if (TRACE) + fprintf(stderr, "Failed to register %s\n", buffer); + } + } + break; + + case 'K': + if (!strncasecomp(buffer, "KEYMAP:", 7)) { + char *key; + char *func; + + key = buffer + 7; + if ((func = strchr(key, ':')) != NULL) { + *func++ = '\0'; + /* Allow comments on the ends of key remapping lines. - DT */ + if (!remap(key, strtok(func, " \t\n#"))) + fprintf(stderr, + "key remapping of %s to %s failed\n",key,func); + else if (!strcmp("TOGGLE_HELP", strtok(func, " \t\n#"))) + LYUseNoviceLineTwo = FALSE; + } + } + break; - if ((strlen (value) < 3) - || (NULL == (viewer = strchr (mime_type, ':')))) - return 0; + case 'L': + if (!strncasecomp(buffer, "LIST_NEWS_NUMBERS:", 18)) { + LYListNewsNumbers = is_true(buffer+18); - *viewer++ = '\0'; + } else if (!strncasecomp(buffer, "LIST_NEWS_DATES:", 16)) { + LYListNewsDates = is_true(buffer+16); - LYRemoveBlanks(mime_type); - LYLowerCase(mime_type); +#ifndef VMS + } else if (!strncasecomp(buffer, "LIST_FORMAT:", 12)) { + StrAllocCopy(list_format, buffer+12); +#endif /* !VMS */ - environment = strrchr(viewer, ':'); - if ((environment != NULL) && - (strlen(viewer) > 1) && *(environment-1) != '\\') { - *environment++ = '\0'; - remove_backslashes(viewer); - /* - * If environment equals xwindows then only assign the presentation if - * there is a $DISPLAY variable. - */ - if (!strcasecomp(environment,"XWINDOWS")) { - if (LYgetXDisplay() != NULL) - HTSetPresentation(mime_type, viewer, 1.0, 3.0, 0.0, 0); - } else if (!strcasecomp(environment,"NON_XWINDOWS")) { - if (LYgetXDisplay() == NULL) - HTSetPresentation(mime_type, viewer, 1.0, 3.0, 0.0, 0); - } else { - HTSetPresentation(mime_type, viewer, 1.0, 3.0, 0.0, 0); - } - } else { - remove_backslashes(viewer); - HTSetPresentation(mime_type, viewer, 1.0, 3.0, 0.0, 0); - } + } else if (!strncasecomp(buffer, "LOCALHOST_ALIAS:", 16)) { + LYAddLocalhostAlias(buffer+16); - return 0; -} + } else if (!strncasecomp(buffer, "LOCAL_DOMAIN:", 13)) { + StrAllocCopy(LYLocalDomain, buffer+13); -/* This table should be sorted alphabetically */ -static Config_Type Config_Table [] = -{ - PARSE_SET("accept_all_cookies", CONF_BOOL, LYAcceptAllCookies), - PARSE_INT("alertsecs", CONF_INT, AlertSecs), - PARSE_SET("always_resubmit_posts", CONF_BOOL, LYresubmit_posts), -#ifdef EXEC_LINKS - PARSE_DEF("always_trusted_exec", CONF_ADD_TRUSTED, ALWAYS_EXEC_PATH), -#endif - PARSE_FUN("assume_charset", CONF_FUN, assume_charset_fun), - PARSE_FUN("assume_local_charset", CONF_FUN, assume_local_charset_fun), - PARSE_FUN("assume_unrec_charset", CONF_FUN, assume_unrec_charset_fun), - PARSE_SET("block_multi_bookmarks", CONF_BOOL, LYMBMBlocked), - PARSE_SET("bold_h1", CONF_BOOL, bold_H1), - PARSE_SET("bold_headers", CONF_BOOL, bold_headers), - PARSE_SET("bold_name_anchors", CONF_BOOL, bold_name_anchors), - PARSE_SET("case_sensitive_always_on", CONF_BOOL, case_sensitive), - PARSE_FUN("character_set", CONF_FUN, character_set_fun), - PARSE_SET("checkmail", CONF_BOOL, check_mail), - PARSE_SET("collapse_br_tags", CONF_BOOL, LYCollapseBRs), -#ifdef USE_COLOR_TABLE - PARSE_FUN("color", CONF_FUN, color_fun), -#endif - PARSE_STR("cookie_accept_domains", CONF_STR, LYCookieAcceptDomains), -#ifdef EXP_PERSISTENT_COOKIES - PARSE_STR("cookie_file", CONF_STR, LYCookieFile), -#endif /* EXP_PERSISTENT_COOKIES */ - PARSE_STR("cookie_reject_domains", CONF_STR, LYCookieRejectDomains), - PARSE_ENV("cso_proxy", CONF_ENV, 0 ), -#ifdef VMS - PARSE_STR("CSWING_PATH", CONF_STR, LYCSwingPath), -#endif - PARSE_FUN("default_bookmark_file", CONF_FUN, default_bookmark_file_fun), - PARSE_FUN("default_cache_size", CONF_FUN, default_cache_size_fun), - PARSE_FUN("default_editor", CONF_FUN, default_editor_fun), - PARSE_STR("default_index_file", CONF_STR, indexfile), - PARSE_FUN("default_keypad_mode_is_numbers_as_arrows", CONF_FUN, numbers_as_arrows_fun), - PARSE_FUN("default_user_mode", CONF_FUN, default_user_mode_fun), -#if defined(VMS) && defined(VAXC) && !defined(__DECC) - PARSE_INT("default_virtual_memory_size", CONF_INT, HTVirtualMemorySize), -#endif -#ifdef DIRED_SUPPORT - PARSE_FUN("dired_menu", CONF_FUN, dired_menu_fun), -#endif - PARSE_ADD("downloader", CONF_ADD_ITEM, downloaders), - PARSE_SET("emacs_keys_always_on", CONF_BOOL, emacs_keys), - PARSE_SET("enable_scrollback", CONF_BOOL, enable_scrollback), -#ifdef USE_EXTERNALS - PARSE_ADD("external", CONF_ADD_ITEM, externals), -#endif - PARSE_ENV("finger_proxy", CONF_ENV, 0 ), - PARSE_SET("force_8bit_toupper", CONF_BOOL, UCForce8bitTOUPPER), - PARSE_SET("force_ssl_cookies_secure", CONF_BOOL, LYForceSSLCookiesSecure), -#if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU) - PARSE_SET("forms_options", CONF_BOOL, LYUseFormsOptions), -#endif - 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_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_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), - PARSE_SET("jumpbuffer", CONF_BOOL, jump_buffer), - PARSE_FUN("jumpfile", CONF_FUN, jumpfile_fun), - PARSE_FUN("keymap", CONF_FUN, keymap_fun), - PARSE_SET("list_news_numbers", CONF_BOOL, LYListNewsNumbers), - PARSE_SET("list_news_dates", CONF_BOOL, LYListNewsDates), -#ifndef VMS - PARSE_STR("list_format", CONF_STR, list_format), -#endif - PARSE_FUN("localhost_alias", CONF_FUN, localhost_alias_fun), - PARSE_STR("local_domain", CONF_STR, LYLocalDomain), #if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) - PARSE_SET("local_execution_links_always_on", CONF_BOOL, local_exec), - PARSE_SET("local_execution_links_on_but_not_remote", CONF_BOOL, local_exec_on_local_files), -#endif + } else if (!strncasecomp(buffer, + "LOCAL_EXECUTION_LINKS_ALWAYS_ON:", 32)) { + local_exec = is_true(buffer+32); + + } else if (!strncasecomp(buffer, + "LOCAL_EXECUTION_LINKS_ON_BUT_NOT_REMOTE:", 40)) { + local_exec_on_local_files = is_true(buffer+40); +#endif /* defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) */ + #ifdef LYNXCGI_LINKS - PARSE_FUN("lynxcgi_environment", CONF_FUN, lynxcgi_environment_fun), -#ifndef VMS - PARSE_STR("lynxcgi_document_root", CONF_STR, LYCgiDocumentRoot), -#endif -#endif - PARSE_STR("lynx_host_name", CONF_STR, LYHostName), - PARSE_FUN("lynx_sig_file", CONF_FUN, lynx_sig_file_fun), - PARSE_SET("mail_system_error_logging", CONF_BOOL, error_logging), -#ifdef VMS - PARSE_STR("mail_adrs", CONF_STR, mail_adrs), -#endif - PARSE_SET("make_links_for_all_images", CONF_BOOL, clickable_images), - PARSE_SET("make_pseudo_alts_for_inlines", CONF_BOOL, pseudo_inline_alts), - PARSE_INT("messagesecs", CONF_INT, MessageSecs), - PARSE_SET("minimal_comments", CONF_BOOL, minimal_comments), - PARSE_INT("multi_bookmark_support", CONF_BOOL, LYMultiBookmarks), - PARSE_SET("ncr_in_bookmarks", CONF_BOOL, UCSaveBookmarksInUnicode), - 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_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_ENV2, 0), /* actually NNTPSERVER */ - PARSE_SET("no_dot_files", CONF_BOOL, no_dotfiles), - PARSE_SET("no_file_referer", CONF_BOOL, no_filereferer), + } else if (!strncasecomp(buffer, "LYNXCGI_ENVIRONMENT:", 20)) { + add_lynxcgi_environment(buffer+20); + #ifndef VMS - PARSE_SET("no_forced_core_dump", CONF_BOOL, LYNoCore), -#endif - PARSE_SET("no_from_header", CONF_BOOL, LYNoFromHeader), - PARSE_SET("no_ismap_if_usemap", CONF_BOOL, LYNoISMAPifUSEMAP), - PARSE_ENV("no_proxy", CONF_ENV, 0 ), - PARSE_SET("no_referer_header", CONF_BOOL, LYNoRefererHeader), - PARSE_FUN("outgoing_mail_charset", CONF_FUN, outgoing_mail_charset_fun), -#ifdef DISP_PARTIAL - PARSE_SET("partial", CONF_BOOL, display_partial), - PARSE_INT("partial_thres", CONF_INT, partial_threshold), -#endif -#ifdef EXP_PERSISTENT_COOKIES - PARSE_SET("persistent_cookies", CONF_BOOL, persistent_cookies), -#endif /* EXP_PERSISTENT_COOKIES */ - PARSE_STR("personal_mailcap", CONF_STR, personal_type_map), - PARSE_STR("personal_extension_map", CONF_STR, personal_extension_map), - PARSE_STR("preferred_charset", CONF_STR, pref_charset), - PARSE_STR("preferred_language", CONF_STR, language), - 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), - 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), - PARSE_SET("seek_frag_area_in_cur", CONF_BOOL, LYSeekFragAREAinCur), - 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_SET("show_kb_rate", CONF_BOOL, LYshow_kb_rate), - 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), - PARSE_SET("substitute_underscores", CONF_BOOL, use_underscore), - PARSE_FUN("suffix", CONF_FUN, suffix_fun), - PARSE_FUN("system_editor", CONF_FUN, system_editor_fun), - PARSE_STR("system_mail", CONF_STR, system_mail), - PARSE_STR("system_mail_flags", CONF_STR, system_mail_flags), - PARSE_SET("tagsoup", CONF_BOOL, New_DTD), -#ifdef EXEC_LINKS - PARSE_DEF("trusted_exec", CONF_ADD_TRUSTED, EXEC_PATH), -#endif -#ifdef LYNXCGI_LINKS - PARSE_DEF("trusted_lynxcgi", CONF_ADD_TRUSTED, CGI_PATH), -#endif - PARSE_STR("url_domain_prefixes", CONF_STR, URLDomainPrefixes), - PARSE_STR("url_domain_suffixes", CONF_STR, URLDomainSuffixes), -#ifdef DIRED_SUPPORT - PARSE_ADD("uploader", CONF_ADD_ITEM, uploaders), -#endif + /* WebSter Mods - Next 2 Lines -jkt */ + } else if (!strncasecomp(buffer, "LYNXCGI_DOCUMENT_ROOT:", 22)) { + StrAllocCopy(LYCgiDocumentRoot, buffer+22); +#endif /* !VMS */ +#endif /* LYNXCGI_LINKS */ + + } else if (!strncasecomp(buffer, "LYNX_HOST_NAME:", 15)) { + StrAllocCopy(LYHostName, buffer+15); + + } else if (!strncasecomp(buffer, "LYNX_SIG_FILE:", 14)) { + strcpy(temp, (buffer+14)); + if (LYPathOffHomeOK(temp, 256)) { + StrAllocCopy(LynxSigFile, temp); + LYAddPathToHome(temp, 256, LynxSigFile); + StrAllocCopy(LynxSigFile, temp); + if (TRACE) + fprintf(stderr, + "LYNX_SIG_FILE set to '%s'\n", LynxSigFile); + } else { + if (TRACE) + fprintf(stderr, "LYNX_SIG_FILE '%s' is bad. Ignoring.\n", + LYNX_SIG_FILE); + } + } + break; + + case 'M': + if (!strncasecomp(buffer, "MAIL_SYSTEM_ERROR_LOGGING:", 26)) { + error_logging = is_true(buffer+26); + #ifdef VMS - PARSE_SET("use_fixed_records", CONF_BOOL, UseFixedRecords), -#endif -#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) - PARSE_SET("use_mouse", CONF_BOOL, LYUseMouse), -#endif - PARSE_SET("use_select_popups", CONF_BOOL, LYSelectPopups), - 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_ENV("wais_proxy", CONF_ENV, 0 ), - PARSE_STR("xloadimage_command", CONF_STR, XLoadImageCommand), - - {0} -}; + } else if (!strncasecomp(buffer, "MAIL_ADRS:", 10)) { + StrAllocCopy(mail_adrs, buffer+10); +#endif /* VMS */ + + } else if (!strncasecomp(buffer, "MAKE_LINKS_FOR_ALL_IMAGES:", 26)) { + clickable_images = is_true(buffer+26); + + } else if (!strncasecomp(buffer, + "MAKE_PSEUDO_ALTS_FOR_INLINES:", 29)) { + pseudo_inline_alts = is_true(buffer+29); + + } else if (!strncasecomp(buffer, "MESSAGESECS:", 12)) { + strcpy(temp, buffer+12); + for (i = 0; temp[i]; i++) { + if (!isdigit(temp[i])) { + temp[i] = '\0'; + break; + } + } + if (temp[0]) + MessageSecs = atoi(temp); -/* - * Free memory allocated in 'read_cfg()' - */ -PUBLIC void free_lynx_cfg NOARGS -{ - Config_Type *tbl; + } else if (!strncasecomp(buffer, "MINIMAL_COMMENTS:", 17)) { + minimal_comments = is_true(buffer+17); + + } else if (!strncasecomp(buffer, "MULTI_BOOKMARK_SUPPORT:", 23)) { + LYMultiBookmarks = is_true(buffer+23); + } + break; + + case 'N': + if (!strncasecomp(buffer, "NEWS_CHUNK_SIZE:", 16)) { + HTNewsChunkSize = atoi(buffer+16); + /* + * If the new HTNewsChunkSize exceeds the maximum, + * increase HTNewsMaxChunk to this size. - FM + */ + if (HTNewsChunkSize > HTNewsMaxChunk) { + HTNewsMaxChunk = HTNewsChunkSize; + } - for (tbl = Config_Table; tbl->name != 0; tbl++) { -#ifdef PARSE_DEBUG - Config_Type *q = tbl; + } else if (!strncasecomp(buffer, "NEWS_MAX_CHUNK:", 15)) { + HTNewsMaxChunk = atoi(buffer+15); + /* + * If HTNewsChunkSize exceeds the new maximum, + * reduce HTNewsChunkSize to this maximum. - FM + */ + if (HTNewsChunkSize > HTNewsMaxChunk) { + HTNewsChunkSize = HTNewsMaxChunk; + } + + } else if (!strncasecomp(buffer, "NEWS_POSTING:", 13)) { + LYNewsPosting = is_true(buffer+13); + no_newspost = (LYNewsPosting == FALSE); + + } else if (!strncasecomp(buffer, "news_proxy:", 11)) { + if (getenv("news_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "news_proxy"); + Define_VMSLogical(temp, (char *)&buffer[11]); #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); + strcpy(temp, "news_proxy="); + StrAllocCopy(news_proxy_putenv_cmd, temp); + StrAllocCat(news_proxy_putenv_cmd, (char *)&buffer[11]); + putenv(news_proxy_putenv_cmd); +#endif /* VMS */ } - break; - default: - break; - } - } -} -/* - * Process the configuration file (lynx.cfg). - */ -PUBLIC void read_cfg ARGS4( - char *, cfg_filename, - char *, parent_filename, - int, nesting_level, - FILE *, fp0) -{ - FILE *fp; - char mypath[LY_MAXPATH]; - char buffer[MAX_LINE_BUFFER_LEN]; + } else if (!strncasecomp(buffer, "newspost_proxy:", 15)) { + if (getenv("newspost_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "newspost_proxy"); + Define_VMSLogical(temp, (char *)&buffer[15]); +#else + strcpy(temp, "newspost_proxy="); + StrAllocCopy(newspost_proxy_putenv_cmd, temp); + StrAllocCat(newspost_proxy_putenv_cmd, (char *)&buffer[15]); + putenv(newspost_proxy_putenv_cmd); +#endif /* VMS */ + } - CTRACE(tfp, "Loading cfg file '%s'.\n", cfg_filename); + } else if (!strncasecomp(buffer, "newsreply_proxy:", 16)) { + if (getenv("newsreply_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "newsreply_proxy"); + Define_VMSLogical(temp, (char *)&buffer[16]); +#else + strcpy(temp, "newsreply_proxy="); + StrAllocCopy(newsreply_proxy_putenv_cmd, temp); + StrAllocCat(newsreply_proxy_putenv_cmd, (char *)&buffer[16]); + putenv(newsreply_proxy_putenv_cmd); +#endif /* VMS */ + } - /* - * Don't get hung up by an include file loop. Arbitrary max depth - * of 10. - BL - */ - if (nesting_level > 10) { - fprintf(stderr, - "More than %d nested lynx.cfg includes -- perhaps there is a loop?!?\n", - nesting_level - 1); - fprintf(stderr,"Last attempted include was '%s',\n", cfg_filename); - fprintf(stderr,"included from '%s'.\n", parent_filename); - exit(-1); - } - /* - * Locate and open the file. - */ - if (!cfg_filename || strlen(cfg_filename) == 0) { - CTRACE(tfp,"No filename following -cfg switch!\n"); - return; - } - if (!strncmp(cfg_filename, "~/", 2)) { - strcpy(mypath, Home_Dir()); - strcat(mypath, cfg_filename+1); - cfg_filename = mypath; - } - if ((fp = fopen(cfg_filename,"r")) == 0) { - CTRACE(tfp,"lynx.cfg file not found as %s\n",cfg_filename); - return; - } - have_read_cfg = TRUE; + } else if (!strncasecomp(buffer, "nntp_proxy:", 11)) { + if (getenv("nntp_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "nntp_proxy"); + Define_VMSLogical(temp, (char *)&buffer[11]); +#else + strcpy(temp, "nntp_proxy="); + StrAllocCopy(nntp_proxy_putenv_cmd, temp); + StrAllocCat(nntp_proxy_putenv_cmd, (char *)&buffer[11]); + putenv(nntp_proxy_putenv_cmd); +#endif /* VMS */ + } - /* - * Process each line in the file. - */ - while (fgets(buffer, sizeof(buffer), fp) != 0) { - char *name, *value; - char *cp; - Config_Type *tbl; - char ch; -#ifdef PARSE_DEBUG - Config_Type *q; + } else if (!strncasecomp(buffer, "NNTPSERVER:", 11)) { + if (getenv("NNTPSERVER") == NULL) { +#ifdef VMS + strcpy(temp, "NNTPSERVER"); + Define_VMSLogical(temp, (char *)&buffer[11]); #else - ConfigUnion *q; -#endif + strcpy(temp, "NNTPSERVER="); + StrAllocCopy(NNTPSERVER_putenv_cmd, temp); + StrAllocCat(NNTPSERVER_putenv_cmd, (char *)&buffer[11]); + putenv(NNTPSERVER_putenv_cmd); +#endif /* VMS */ + } - /* Most lines in the config file are comment lines. Weed them out - * now. Also, leading whitespace is ok, so trim it. - */ - name = LYSkipBlanks(buffer); + } else if (!strncasecomp(buffer, "NO_DOT_FILES:", 13)) { + no_dotfiles = is_true(buffer+13); - if (*name == '#') - continue; + } else if (!strncasecomp(buffer, "NO_FILE_REFERER:", 16)) { + no_filereferer = is_true(buffer+16); - LYTrimTrailing(name); +#ifndef VMS + } else if (!strncasecomp(buffer, "NO_FORCED_CORE_DUMP:", 20)) { + LYNoCore = is_true(buffer+20); +#endif /* !VMS */ - if (*name == 0) continue; + } else if (!strncasecomp(buffer, "NO_FROM_HEADER:", 15)) { + LYNoFromHeader = is_true(buffer+15); - /* Significant lines are of the form KEYWORD:WHATEVER */ - if ((value = strchr (name, ':')) == 0) { - /* fprintf (stderr, "Bad line-- no :\n"); */ - continue; - } + } else if (!strncasecomp(buffer, "NO_ISMAP_IF_USEMAP:", 19)) { + LYNoISMAPifUSEMAP = is_true(buffer+19); - /* skip past colon, but replace ':' with 0 to make name meaningful */ - *value++ = 0; + } else if (!strncasecomp(buffer, "no_proxy:", 9)) { + if (getenv("no_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "no_proxy"); + Define_VMSLogical(temp, (char *)&buffer[9]); +#else + strcpy(temp, "no_proxy="); + StrAllocCopy(no_proxy_putenv_cmd, temp); + StrAllocCat(no_proxy_putenv_cmd, (char *)&buffer[9]); + putenv(no_proxy_putenv_cmd); +#endif /* VMS */ + } - /* - * Trim off any trailing comments. - * - * (Apparently, the original code considers a trailing comment - * valid only if preceded by a space character but is not followed - * by a colon. -- JED) - */ - if ((cp = strrchr (value, ':')) == 0) - cp = value; - if ((cp = strchr (cp, '#')) != 0) { - cp--; - if (isspace ((unsigned char) *cp)) - *cp = 0; + } else if (!strncasecomp(buffer, "NO_REFERER_HEADER:", 18)) { + LYNoRefererHeader = is_true(buffer+18); } + break; - tbl = Config_Table; - ch = TOUPPER(*name); - while (tbl->name != 0) { - char ch1 = tbl->name[0]; + case 'P': + if (!strncasecomp(buffer, "PERSONAL_MAILCAP:", 17)) { + StrAllocCopy(personal_type_map, buffer+17); - if ((ch == TOUPPER(ch1)) - && (0 == strcasecomp (name, tbl->name))) - break; + } else if (!strncasecomp(buffer, "PERSONAL_EXTENSION_MAP:", 23)) { + StrAllocCopy(personal_extension_map, buffer+23); + + } else if (!strncasecomp(buffer, "PREFERRED_CHARSET:", 18)) { + StrAllocCopy(pref_charset, buffer+18); + + } else if (!strncasecomp(buffer, "PREFERRED_LANGUAGE:", 19)) { + StrAllocCopy(language, buffer+19); + + } else if (!strncasecomp(buffer, "PREPEND_BASE_TO_SOURCE:", 23)) { + LYPrependBaseToSource = is_true(buffer+23); - tbl++; + } else if (!strncasecomp(buffer, "PREPEND_CHARSET_TO_SOURCE:", 26)) { + LYPrependCharsetToSource = is_true(buffer+26); + + } else if (!strncasecomp(buffer, "PRINTER:", 8)) { + add_printer_to_list(&buffer[8], &printers); } + break; - if (tbl->name == 0) { - /* Apparently, lynx ignores unknown keywords */ - /* fprintf (stderr, "%s not found in config file */ - continue; +#ifdef RAWDOSKEYHACK + case 'R': + if (!strncasecomp(buffer, "RAW_DOS_KEY_HACK:", 17)) { + raw_dos_key_hack = is_true(buffer+17); } + break; +#endif /* RAWDOSKEYHACK */ -#ifdef PARSE_DEBUG - q = tbl; -#else - q = (ConfigUnion *)(&(tbl->value)); -#endif - switch ((fp0 != 0 && tbl->type != CONF_INCLUDE) - ? CONF_UNSPECIFIED - : tbl->type) { - case CONF_BOOL: - if (q->set_value != 0) - *(q->set_value) = is_true (value); - break; - - case CONF_FUN: - if (q->fun_value != 0) - (*(q->fun_value)) (value); - break; - - case CONF_INT: - if (q->int_value != 0) { - int ival; - /* Apparently, if an integer value is not present, then the - * value is not changed. So, use the sscanf function to make - * this determination. - */ - if (1 == sscanf (value, "%d", &ival)) - *(q->int_value) = ival; - } - break; + case 'Q': + if (!strncasecomp(buffer, "QUIT_DEFAULT_YES:", 17)) { + LYQuitDefaultYes = is_true(buffer+17); + } + break; - case CONF_STR: - if (q->str_value != 0) - StrAllocCopy(*(q->str_value), value); - break; + case 'S': + if (!strncasecomp(buffer, "SAVE_SPACE:", 11)) { + StrAllocCopy(lynx_save_space, buffer+11); - case CONF_ENV: - case CONF_ENV2: + } else if (!strncasecomp(buffer, "SCAN_FOR_BURIED_NEWS_REFS:", 26)) { + scan_for_buried_news_references = is_true(buffer+26); - if (tbl->type == CONF_ENV) - LYLowerCase(name); - else - LYUpperCase(name); + } else if (!strncasecomp(buffer, "SEEK_FRAG_AREA_IN_CUR:", 22)) { + LYSeekFragAREAinCur = is_true(buffer+22); + + } else if (!strncasecomp(buffer, "SEEK_FRAG_MAP_IN_CUR:", 21)) { + LYSeekFragMAPinCur = is_true(buffer+21); + + } else if (!strncasecomp(buffer, "SET_COOKIES:", 12)) { + LYSetCookies = is_true(buffer+12); + + } else if (!strncasecomp(buffer, "SHOW_CURSOR:", 12)) { + LYShowCursor = is_true(buffer+12); - if (getenv (name) == 0) { + } else if (!strncasecomp(buffer, "snews_proxy:", 12)) { + if (getenv("snews_proxy") == NULL) { #ifdef VMS - Define_VMSLogical(name, value); + strcpy(temp, "snews_proxy"); + Define_VMSLogical(temp, (char *)&buffer[12]); #else - char tmpbuf[MAX_LINE_BUFFER_LEN]; - sprintf (tmpbuf, "%s=%s", name, value); - if ((q->str_value = (char **)calloc(1, sizeof(char **))) != 0) { - StrAllocCopy(*(q->str_value), tmpbuf); - putenv (*(q->str_value)); + strcpy(temp, "snews_proxy="); + StrAllocCopy(snews_proxy_putenv_cmd, temp); + StrAllocCat(snews_proxy_putenv_cmd, (char *)&buffer[12]); + putenv(snews_proxy_putenv_cmd); +#endif /* VMS */ + } + + } else if (!strncasecomp(buffer, "snewspost_proxy:", 16)) { + if (getenv("snewspost_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "snewspost_proxy"); + Define_VMSLogical(temp, (char *)&buffer[16]); +#else + strcpy(temp, "snewspost_proxy="); + StrAllocCopy(snewspost_proxy_putenv_cmd, temp); + StrAllocCat(snewspost_proxy_putenv_cmd, (char *)&buffer[16]); + putenv(snewspost_proxy_putenv_cmd); +#endif /* VMS */ + } + + } else if (!strncasecomp(buffer, "snewsreply_proxy:", 17)) { + if (getenv("snewsreply_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "snewsreply_proxy"); + Define_VMSLogical(temp, (char *)&buffer[17]); +#else + strcpy(temp, "snewsreply_proxy="); + StrAllocCopy(snewsreply_proxy_putenv_cmd, temp); + StrAllocCat(snewsreply_proxy_putenv_cmd, (char *)&buffer[17]); + putenv(snewsreply_proxy_putenv_cmd); +#endif /* VMS */ + } + + } else if (!strncasecomp(buffer, "SOFT_DQUOTES:", 13)) { + soft_dquotes = is_true(buffer+13); + + } else if (!strncasecomp(buffer, "STARTFILE:", 10)) { + StrAllocCopy(startfile, buffer+10); + + } else if (!strncasecomp(buffer, "STRIP_DOTDOT_URLS:", 18)) { + LYStripDotDotURLs = is_true(buffer+18); + + } else if (!strncasecomp(buffer, "SUBSTITUTE_UNDERSCORES:", 23)) { + use_underscore = is_true(buffer+23); + + } else if (!strncasecomp(buffer, "SUFFIX:", 7)) { + char *extention; + char *mime_type; + + if (strlen(buffer) > 9) { + extention = buffer + 7; + if ((mime_type = strchr(extention, ':')) != NULL) { + *mime_type++ = '\0'; + for (i = 0, j = 0; mime_type[i]; i++) { + if (mime_type[i] != ' ') { + mime_type[j++] = TOLOWER(mime_type[i]); + } + } + mime_type[j] = '\0'; + if (strstr(mime_type, "tex") != NULL || + strstr(mime_type, "postscript") != NULL || + strstr(mime_type, "sh") != NULL || + strstr(mime_type, "troff") != NULL || + strstr(mime_type, "rtf") != NULL) + HTSetSuffix(extention, mime_type, "8bit", 1.0); + else + HTSetSuffix(extention, mime_type, "binary", 1.0); } + } + + } else if (!strncasecomp(buffer, "SYSTEM_EDITOR:", 14)) { + StrAllocCopy(editor, buffer+14); + system_editor = TRUE; + + } else if (!strncasecomp(buffer, "SYSTEM_MAIL:", 12)) { + StrAllocCopy(system_mail, buffer+12); + + } else if (!strncasecomp(buffer, "SYSTEM_MAIL_FLAGS:", 18)) { + StrAllocCopy(system_mail_flags, buffer+18); + } + break; + + case 'T': +#ifdef EXEC_LINKS + if (!strncasecomp(buffer, "TRUSTED_EXEC:", 13)) { + add_trusted(&buffer[13], EXEC_PATH); /* Add exec path */ + } +#endif /* EXEC_LINKS */ + +#ifdef LYNXCGI_LINKS + if (!strncasecomp(buffer, "TRUSTED_LYNXCGI:", 16)) { + add_trusted(&buffer[16], CGI_PATH); /* Add CGI path */ + } +#endif /* LYNXCGI_LINKS */ + break; + + case 'U': + if (!strncasecomp(buffer, "URL_DOMAIN_PREFIXES:", 20)) { + StrAllocCopy(URLDomainPrefixes, buffer+20); + + } else if (!strncasecomp(buffer, "URL_DOMAIN_SUFFIXES:", 20)) { + StrAllocCopy(URLDomainSuffixes, buffer+20); + +#ifdef DIRED_SUPPORT + } else if (!strncasecomp(buffer, "UPLOADER:", 9)) { + add_item_to_list(&buffer[9], &uploaders); +#endif /* DIRED_SUPPORT */ + +#ifdef VMS + } else if (!strncasecomp(buffer, "USE_FIXED_RECORDS:", 18)) { + UseFixedRecords = is_true(buffer+18); +#endif /* VMS */ + +#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) + } else if(!strncasecomp(buffer, "USE_MOUSE:",10)) { + LYUseMouse = is_true(buffer+10); #endif + + } else if (!strncasecomp(buffer, "USE_SELECT_POPUPS:", 18)) { + LYSelectPopups = is_true(buffer+18); + } + break; + + case 'V': + if (!strncasecomp(buffer, "VERBOSE_IMAGES:", 15)) { + verbose_img = is_true(buffer+15); + + } else if (!strncasecomp(buffer, "VI_KEYS_ALWAYS_ON:", 18)) { + vi_keys = is_true(buffer+18); + + } else if (!strncasecomp(buffer, "VIEWER:", 7)) { + char *mime_type; + char *viewer; + char *environment; + + if (strlen(buffer) > 9) { + mime_type = buffer + 7; + if ((viewer = strchr(mime_type, ':')) != NULL) { + *viewer++ = '\0'; + for (i = 0, j = 0; mime_type[i]; i++) { + if (mime_type[i] != ' ') { + mime_type[j++] = TOLOWER(mime_type[i]); + } + } + mime_type[j] = '\0'; + environment = strrchr(viewer, ':'); + if ((environment != NULL) && + (strlen(viewer) > 1) && *(environment-1) != '\\') { + *environment++ = '\0'; + remove_backslashes(viewer); + /* + * If environment equals xwindows then only + * assign the presentation if there is a display + * variable. + */ + if (!strcasecomp(environment,"XWINDOWS")) { + if ((cp = getenv(DISPLAY)) != NULL && + *cp != '\0') + HTSetPresentation(mime_type, viewer, + 1.0, 3.0, 0.0, 0); + } else if (!strcasecomp(environment,"NON_XWINDOWS")) { + if ((cp = getenv(DISPLAY)) == NULL || + *cp == '\0') + HTSetPresentation(mime_type, viewer, + 1.0, 3.0, 0.0, 0); + } else { + HTSetPresentation(mime_type, viewer, + 1.0, 3.0, 0.0, 0); + } + } else { + remove_backslashes(viewer); + HTSetPresentation(mime_type, viewer, + 1.0, 3.0, 0.0, 0); + } + } } - break; - - case CONF_INCLUDE: - /* include another file */ -#ifndef NO_CONFIG_INFO - if (fp0 != 0) { - fprintf(fp0, "%s:%s\n\n", name, value); - fprintf(fp0, " #<begin %s>\n", value); + } + break; + + case 'W': + if (!strncasecomp(buffer, "wais_proxy:", 11)) { + if (getenv("wais_proxy") == NULL) { +#ifdef VMS + strcpy(temp, "wais_proxy"); + Define_VMSLogical(temp, (char *)&buffer[11]); +#else + strcpy(temp, "wais_proxy="); + StrAllocCopy(wais_proxy_putenv_cmd, temp); + StrAllocCat(wais_proxy_putenv_cmd, (char *)&buffer[11]); + putenv(wais_proxy_putenv_cmd); +#endif /* VMS */ } -#endif - read_cfg (value, cfg_filename, nesting_level + 1, fp0); -#ifndef NO_CONFIG_INFO - if (fp0 != 0) - fprintf(fp0, " #<end of %s>\n\n", value); -#endif - break; + } + break; - case CONF_ADD_ITEM: - if (q->add_value != 0) - add_item_to_list (value, q->add_value); - break; + case 'X': + if (!strncasecomp(buffer, "XLOADIMAGE_COMMAND:", 19)) { + StrAllocCopy(XLoadImageCommand, (char *)&buffer[19]); + } + break; -#if defined(EXEC_LINKS) || defined(LYNXCGI_LINKS) - case CONF_ADD_TRUSTED: - add_trusted (value, q->def_value); - break; -#endif default: - if (fp0 != 0) - fprintf(fp0, "%s:%s\n", name, value); - break; - } - } + break; - fclose (fp); + } /* end of Huge switch */ + } /* end of while */ + fclose(fp); /* * If any DOWNLOADER: commands have always_enabled set (:TRUE), @@ -1205,84 +1330,17 @@ PUBLIC void read_cfg ARGS4( * settings will not block presentation of a download menu * with those always_enabled options still available. - FM */ - if (downloaders != 0) { + if (downloaders != NULL) { + int count; lynx_html_item_type *cur_download; - cur_download = downloaders; - while (cur_download != 0) { + for (count = 0, cur_download = downloaders; + cur_download != NULL; + cur_download = cur_download->next, count++) { if (cur_download->always_enabled) { override_no_download = TRUE; break; } - cur_download = cur_download->next; } } - - /* - * If any COOKIE_{ACCEPT,REJECT}_DOMAINS have been defined, - * process them. These are comma delimited lists of - * domains. - BJP - */ - - if (LYCookieAcceptDomains != NULL) { - cookie_add_acceptlist(LYCookieAcceptDomains); - } - - if (LYCookieRejectDomains != NULL) { - cookie_add_rejectlist(LYCookieRejectDomains); - } -} - -/* - * lynx.cfg infopage, returns local url. - */ -PUBLIC char *lynx_cfg_infopage NOARGS -{ - static char *local_url; - char tempfile[LY_MAXPATH]; - char *temp = 0; - FILE *fp0; - - if (local_url == 0) { - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { - HTAlert(CANNOT_OPEN_TEMP); - return(0); - } - LYLocalFileToURL(&local_url, tempfile); - - LYforce_no_cache = TRUE; /* don't cache this doc */ - - BeginInternalPage (fp0, LYNXCFG_TITLE, NULL); - fprintf(fp0, "<pre>\n"); - -#ifndef NO_CONFIG_INFO - fprintf(fp0, "<em>This is read from your lynx.cfg file,\n"); -#if defined(HAVE_CONFIG_H) || defined(VMS) - StrAllocCopy(temp, LYNX_CFG_FILE); -#else - StrAllocCopy(temp, helpfilepath); /* no absolute path... */ - StrAllocCat(temp, LYNXCFG_HELP); /* for lynx.cfg on DOS/Win32 */ -#endif /* HAVE_CONFIG_H */ - fprintf(fp0, "please \"read\" distribution's <a href=\"%s\">lynx.cfg", - temp); - fprintf(fp0, "</a> for more comments.</em>\n\n"); - - fprintf(fp0, " #<em>Your primary configuration %s</em>\n", - lynx_cfg_file); -#else - fprintf(fp0, "<em>This is read from your lynx.cfg file:</em>\n\n"); -#endif /* NO_CONFIG_INFO */ - - /* - * Process the configuration file. - */ - read_cfg(lynx_cfg_file, "main program", 1, fp0); - - FREE(temp); - fprintf(fp0, "</pre>\n"); - EndInternalPage(fp0); - LYCloseTempFP(fp0); - } - - return(local_url); } diff --git a/src/LYReadCFG.h b/src/LYReadCFG.h index acbbd276..a6ed7c70 100644 --- a/src/LYReadCFG.h +++ b/src/LYReadCFG.h @@ -43,10 +43,7 @@ extern int default_bg; 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, FILE *fp0)); -extern void free_lynx_cfg NOPARAMS; +extern void read_cfg PARAMS((char *cfg_filename, char *parent_filename, int nesting_level)); extern BOOLEAN have_read_cfg; -extern char *lynx_cfg_infopage NOPARAMS; - #endif /* LYREADCFG_H */ diff --git a/src/LYSearch.c b/src/LYSearch.c index dfd359c3..aed16225 100644 --- a/src/LYSearch.c +++ b/src/LYSearch.c @@ -1,5 +1,5 @@ #include <HTUtils.h> -#include <HTAlert.h> +#include <tcp.h> #include <LYUtils.h> #include <LYStrings.h> #include <LYSearch.h> @@ -9,6 +9,8 @@ #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + /* * Search for the target string inside of the links * that are currently displayed on the screen beginning @@ -215,7 +217,8 @@ PUBLIC BOOL textsearch ARGS3( * Restore prev_target and return. - FM */ strcpy(prev_target, prev_target_buffer); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return(FALSE); } } @@ -229,7 +232,8 @@ check_recall: * previous search string will no longer occur, but it can * be used again via LYK_NEXT. - FM */ - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return(FALSE); } @@ -280,7 +284,8 @@ check_recall: * Restore prev_target and return. - FM */ strcpy(prev_target, prev_target_buffer); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return(FALSE); } goto check_recall; @@ -332,7 +337,8 @@ check_recall: * Restore prev_target and return. - FM */ strcpy(prev_target, prev_target_buffer); - HTInfoMsg(CANCELLED); + _statusline(CANCELLED); + sleep(InfoSecs); return(FALSE); } goto check_recall; diff --git a/src/LYSearch.h b/src/LYSearch.h index a8a31973..cff7b806 100644 --- a/src/LYSearch.h +++ b/src/LYSearch.h @@ -3,7 +3,7 @@ #define LYSEARCH_H #ifndef LYSTRUCTS_H -#include <LYStructs.h> +#include "LYStructs.h" #endif /* LYSTRUCT_H */ extern BOOL textsearch PARAMS((document *cur_doc, diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index ec2002c9..65f06958 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -1,5 +1,5 @@ #include <HTUtils.h> -#include <HTFile.h> +#include <tcp.h> #include <HTParse.h> #include <HTAlert.h> #include <HTTP.h> @@ -12,7 +12,6 @@ #include <LYSignal.h> #include <LYCharUtils.h> #include <GridText.h> -#include <LYReadCFG.h> #include <LYLeaks.h> @@ -23,88 +22,57 @@ #include <LYLocal.h> #endif /* DIRED_SUPPORT */ -#if defined(HAVE_CONFIG_H) && !defined(NO_CONFIG_INFO) -#define HAVE_CFG_DEFS_H +#define FREE(x) if (x) {free(x); x = NULL;} -#define PutDefs(table, N) fprintf(fp0, "%-35s %s\n", table[N].name, table[N].value) - -/* - * Compile-time definitions info, returns local url - */ -PRIVATE char *lynx_compile_opts NOARGS -{ - char tempfile[LY_MAXPATH]; -#include <cfg_defs.h> - unsigned n; - static char *info_url; - FILE *fp0; - - if (info_url == 0) { - if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) { - HTAlert(CANNOT_OPEN_TEMP); - return(0); - } - LYLocalFileToURL(&info_url, tempfile); - - BeginInternalPage (fp0, CONFIG_DEF_TITLE, NULL); - fprintf(fp0, "<pre>\n"); - - fprintf(fp0, "See also <a href=\"%s\">your lynx.cfg</a> for run-time options\n\n", - lynx_cfg_infopage()); - - fprintf(fp0, "\n%s<br>\n<em>config.cache</em>\n", AUTOCONF_CONFIG_CACHE); - for (n = 0; n < TABLESIZE(config_cache); n++) { - PutDefs(config_cache, n); - } - fprintf(fp0, "\n%s<br>\n<em>lynx_cfg.h</em>\n", AUTOCONF_LYNXCFG_H); - for (n = 0; n < TABLESIZE(config_defines); n++) { - PutDefs(config_defines, n); - } - fprintf(fp0, "</pre>\n"); - EndInternalPage(fp0); - LYCloseTempFP(fp0); - } - return info_url; -} -#else -#undef HAVE_CFG_DEFS_H -#endif /* !NO_CONFIG_INFO */ - -/* +/* * Showinfo prints a page of info about the current file and the link * that the cursor is on. */ - + PUBLIC int showinfo ARGS4( document *, doc, int, size_of_file, document *, newdoc, - char *, owner_address) + char *, owner_address) { - static char tempfile[LY_MAXPATH]; - static char *info_url; + static char tempfile[256]; + static BOOLEAN first = TRUE; + static char info_url[256]; int url_type; FILE *fp0; char *Address = NULL, *Title = NULL; - CONST char *cp; + char *cp; #ifdef DIRED_SUPPORT - char temp[LY_MAXPATH]; + char temp[300]; struct stat dir_info; struct passwd *pw; struct group *grp; #endif /* DIRED_SUPPORT */ - - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp (tempfile, HTML_SUFFIX, "w")) == 0) { - HTAlert(CANNOT_OPEN_TEMP); - return(-1); + if (first) { + tempname(tempfile, NEW_FILE); + /* + * Make the temporary file a URL now. + */ +#if defined (VMS) || defined (DOSPATH) + sprintf(info_url, "file://localhost/%s", tempfile); +#else + sprintf(info_url, "file://localhost%s", tempfile); +#endif /* VMS */ + first = FALSE; +#ifdef VMS + } else { + remove(tempfile); /* Remove duplicates on VMS. */ +#endif /* VMS */ } - LYLocalFileToURL(&info_url, tempfile); + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { + HTAlert(CANNOT_OPEN_TEMP); + return(0); + } /* - * Point the address pointer at this Url + * Point the address pointer at this Url */ StrAllocCopy(newdoc->address, info_url); @@ -120,61 +88,49 @@ PUBLIC int showinfo ARGS4( } } - fprintf(fp0, "<html>\n<head>\n"); + fprintf(fp0, "<head>\n"); LYAddMETAcharsetToFD(fp0, -1); fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", SHOWINFO_TITLE); - - fprintf(fp0, "<h1>%s %s (%.*s) (<a href=\"%s\">%s</a>)", - LYNX_NAME, LYNX_VERSION, - LYNX_DATE_LEN, - (LYNX_RELEASE ? LYNX_RELEASE_DATE : &LYNX_DATE[LYNX_DATE_OFF]), - (LYNX_RELEASE ? LYNX_WWW_HOME : LYNX_WWW_DIST), - (LYNX_RELEASE ? "latest release" : "development version") ); - - if (!LYRestricted) { -#ifdef HAVE_CFG_DEFS_H - fprintf(fp0, " - <a href=\"%s\">compile time settings</a>\n", - lynx_compile_opts()); -#else - fprintf(fp0, " - <a href=\"%s\">your lynx.cfg</a>\n", - lynx_cfg_infopage()); -#endif - } - fprintf(fp0, "</h1>\n"); /* don't forget to close <h1> */ - + fprintf(fp0,"<h1>You have reached the Information Page</h1>\n"); + fprintf(fp0,"<h2>%s Version %s</h2>\n", LYNX_NAME, LYNX_VERSION); #ifdef DIRED_SUPPORT if (lynx_edit_mode && nlinks > 0) { - char *s; - - fprintf(fp0, "<pre>\n"); - fprintf(fp0, "\nDirectory that you are currently viewing\n\n"); + fprintf(fp0, + "<h2>Directory that you are currently viewing</h2>\n<pre>"); - s = HTfullURL_toFile(doc->address); - strcpy(temp, s); - free(s); + cp = doc->address; + if (!strncmp(cp, "file://localhost", 16)) + cp += 16; + else if (!strncmp(cp, "file:", 5)) + cp += 5; + strcpy(temp, cp); + HTUnEscape(temp); fprintf(fp0," <em>Name:</em> %s\n", temp); fprintf(fp0," <em> URL:</em> %s\n", doc->address); - s = HTfullURL_toFile(links[doc->link].lname); - strcpy(temp, s); - free(s); - + cp = links[doc->link].lname; + if (!strncmp(cp, "file://localhost", 16)) + cp += 16; + else if (!strncmp(cp, "file:", 5)) + cp += 5; + strcpy(temp, cp); + HTUnEscape(temp); if (lstat(temp, &dir_info) == -1) { - CTRACE(tfp, "lstat(%s) failed, errno=%d\n", temp, errno); - HTAlert(CURRENT_LINK_STATUS_FAILED); + _statusline(CURRENT_LINK_STATUS_FAILED); + sleep(AlertSecs); } else { char modes[80]; - if (S_ISDIR(dir_info.st_mode)) { + if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) { fprintf(fp0, "\nDirectory that you have currently selected\n\n"); - } else if (S_ISREG(dir_info.st_mode)) { - fprintf(fp0, + } else if (((dir_info.st_mode) & S_IFMT) == S_IFREG) { + fprintf(fp0, "\nFile that you have currently selected\n\n"); #ifdef S_IFLNK - } else if (S_ISLNK(dir_info.st_mode)) { + } else if (((dir_info.st_mode) & S_IFMT) == S_IFLNK) { fprintf(fp0, "\nSymbolic link that you have currently selected\n\n"); #endif @@ -184,7 +140,7 @@ PUBLIC int showinfo ARGS4( } fprintf(fp0," <em>Full name:</em> %s\n", temp); #ifdef S_IFLNK - if (S_ISLNK(dir_info.st_mode)) { + if (((dir_info.st_mode) & S_IFMT) == S_IFLNK) { char buf[1025]; int buf_size; @@ -198,28 +154,28 @@ PUBLIC int showinfo ARGS4( #endif pw = getpwuid(dir_info.st_uid); if (pw) - fprintf(fp0, " <em>Name of owner:</em> %s\n", pw->pw_name); + fprintf(fp0, " <em>Name of owner:</em> %s\n", pw->pw_name); grp = getgrgid(dir_info.st_gid); if (grp && grp->gr_name) - fprintf(fp0, " <em>Group name:</em> %s\n", grp->gr_name); - if (S_ISREG(dir_info.st_mode)) { + fprintf(fp0, " <em>Group name:</em> %s\n", grp->gr_name); + if (((dir_info.st_mode) & S_IFMT) == S_IFREG) { sprintf(temp, " <em>File size:</em> %ld (bytes)\n", - (long)dir_info.st_size); + (long)dir_info.st_size); fprintf(fp0, "%s", temp); } /* - * Include date and time information. + * Include date and time information. */ cp = ctime(&dir_info.st_ctime); fprintf(fp0, " <em>Creation date:</em> %s", cp); - cp = ctime(&dir_info.st_mtime); + cp = ctime(&dir_info.st_mtime); fprintf(fp0, " <em>Last modified:</em> %s", cp); cp = ctime(&dir_info.st_atime); fprintf(fp0, " <em>Last accessed:</em> %s\n", cp); - fprintf(fp0, " Access Permissions\n"); + fprintf(fp0, " <em>Access Permissions</em>\n"); fprintf(fp0, " <em>Owner:</em> "); modes[0] = '\0'; modes[1] = '\0'; /* In case there are no permissions */ @@ -229,13 +185,13 @@ PUBLIC int showinfo ARGS4( if ((dir_info.st_mode & S_IWUSR)) strcat(modes, ", write"); if ((dir_info.st_mode & S_IXUSR)) { - if (S_ISDIR(dir_info.st_mode)) + if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) strcat(modes, ", search"); - else { + else { strcat(modes, ", execute"); if ((dir_info.st_mode & S_ISUID)) - strcat(modes, ", setuid"); - } + strcat(modes, ", setuid"); + } } fprintf(fp0, "%s\n", (char *)&modes[2]); /* Skip leading ', ' */ @@ -243,18 +199,18 @@ PUBLIC int showinfo ARGS4( modes[0] = '\0'; modes[1] = '\0'; /* In case there are no permissions */ modes[2] = '\0'; - if ((dir_info.st_mode & S_IRGRP)) + if ((dir_info.st_mode & S_IRGRP)) strcat(modes, ", read"); if ((dir_info.st_mode & S_IWGRP)) strcat(modes, ", write"); if ((dir_info.st_mode & S_IXGRP)) { - if (S_ISDIR(dir_info.st_mode)) + if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) strcat(modes, ", search"); - else { + else { strcat(modes, ", execute"); if ((dir_info.st_mode & S_ISGID)) - strcat(modes, ", setgid"); - } + strcat(modes, ", setgid"); + } } fprintf(fp0, "%s\n", (char *)&modes[2]); /* Skip leading ', ' */ @@ -267,15 +223,15 @@ PUBLIC int showinfo ARGS4( if ((dir_info.st_mode & S_IWOTH)) strcat(modes, ", write"); if ((dir_info.st_mode & S_IXOTH)) { - if (S_ISDIR(dir_info.st_mode)) + if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) strcat(modes, ", search"); - else { + else { strcat(modes, ", execute"); #ifdef S_ISVTX if ((dir_info.st_mode & S_ISVTX)) - strcat(modes, ", sticky"); + strcat(modes, ", sticky"); #endif - } + } } fprintf(fp0, "%s\n", (char *)&modes[2]); /* Skip leading ', ' */ } @@ -289,38 +245,38 @@ PUBLIC int showinfo ARGS4( StrAllocCopy(Title, doc->title); LYEntify(&Title, TRUE); fprintf(fp0, "<dt><em>Linkname:</em> %s%s\n", - Title, (doc->isHEAD ? " (HEAD)" : "")); + Title, (doc->isHEAD ? " (HEAD)" : "")); StrAllocCopy(Address, doc->address); LYEntify(&Address, TRUE); fprintf(fp0, - "<dt> <em>URL:</em> %s\n", Address); + "<dt> <em>URL:</em> %s\n", Address); if (HTLoadedDocumentCharset()) { - fprintf(fp0, "<dt><em> Charset:</em> %s\n", + fprintf(fp0, "<dt><em> Charset:</em> %s\n", HTLoadedDocumentCharset()); } else { LYUCcharset * p_in = HTAnchor_getUCInfoStage(HTMainAnchor, - UCT_STAGE_PARSER); + UCT_STAGE_PARSER); if (!p_in || !(p_in->MIMEname) || !*(p_in->MIMEname) || HTAnchor_getUCLYhndl(HTMainAnchor, UCT_STAGE_PARSER) < 0) { p_in = HTAnchor_getUCInfoStage(HTMainAnchor, UCT_STAGE_MIME); } if (p_in && p_in->MIMEname && *(p_in->MIMEname) && HTAnchor_getUCLYhndl(HTMainAnchor, UCT_STAGE_MIME) >= 0) { - fprintf(fp0, "<dt><em> Charset:</em> %s (assumed)\n", + fprintf(fp0, "<dt><em> Charset:</em> %s (assumed)\n", p_in->MIMEname); } } if ((cp = HText_getServer()) != NULL && *cp != '\0') - fprintf(fp0, "<dt><em> Server:</em> %s\n", cp); + fprintf(fp0, "<dt><em> Server:</em> %s\n", cp); if ((cp = HText_getDate()) != NULL && *cp != '\0') - fprintf(fp0, "<dt><em> Date:</em> %s\n", cp); + fprintf(fp0, "<dt><em> Date:</em> %s\n", cp); if ((cp = HText_getLastModified()) != NULL && *cp != '\0') - fprintf(fp0, "<dt><em>Last Mod:</em> %s\n", cp); + fprintf(fp0, "<dt><em>Last Mod:</em> %s\n", cp); if (doc->post_data) { fprintf(fp0, @@ -330,10 +286,10 @@ PUBLIC int showinfo ARGS4( } if (owner_address) { - StrAllocCopy(Address, owner_address); + StrAllocCopy(Address, owner_address); LYEntify(&Address, TRUE); } else { - StrAllocCopy(Address, "None"); + StrAllocCopy(Address, "None"); } fprintf(fp0, "<dt><em>Owner(s):</em> %s\n", Address); @@ -358,8 +314,8 @@ PUBLIC int showinfo ARGS4( if (lynx_mode == FORMS_LYNX_MODE && links[doc->link].type == WWW_FORM_LINK_TYPE) { if (links[doc->link].form->submit_method) { - int method = links[doc->link].form->submit_method; - char *enctype = links[doc->link].form->submit_enctype; + int method = links[doc->link].form->submit_method; + char *enctype = links[doc->link].form->submit_enctype; fprintf(fp0, "<dt> <em>Method:</em> %s\n", (method == URL_POST_METHOD) ? "POST" : @@ -371,20 +327,20 @@ PUBLIC int showinfo ARGS4( enctype : "application/x-www-form-urlencoded")); } if (links[doc->link].form->submit_action) { - StrAllocCopy(Address, links[doc->link].form->submit_action); + StrAllocCopy(Address, links[doc->link].form->submit_action); LYEntify(&Address, TRUE); - fprintf(fp0, "<dt> <em>Action:</em> %s\n", Address); + fprintf(fp0, "<dt> <em>Action:</em> %s\n", Address); } if (!(links[doc->link].form->submit_method && links[doc->link].form->submit_action)) { - fprintf(fp0,"<dt> (Form field)\n"); + fprintf(fp0,"<dt> (Form field)\n"); } } else { if (links[doc->link].lname) { - StrAllocCopy(Title, links[doc->link].lname); + StrAllocCopy(Title, links[doc->link].lname); LYEntify(&Title, TRUE); } else { - StrAllocCopy(Title, ""); + StrAllocCopy(Title, ""); } fprintf(fp0, "<dt> <em>URL:</em> %s\n", Title); @@ -397,13 +353,13 @@ PUBLIC int showinfo ARGS4( #ifdef DIRED_SUPPORT } #endif /* DIRED_SUPPORT */ - EndInternalPage(fp0); + fprintf(fp0, "</body>\n"); refresh(); - LYCloseTemp(tempfile); + fclose(fp0); FREE(Address); FREE(Title); - return(0); + return(1); } diff --git a/src/LYShowInfo.h b/src/LYShowInfo.h index 65eb88e5..3333cb4b 100644 --- a/src/LYShowInfo.h +++ b/src/LYShowInfo.h @@ -1,3 +1,4 @@ + #ifndef LYSHOWINFO_H #define LYSHOWINFO_H @@ -8,5 +9,8 @@ extern int showinfo PARAMS((document *doc, int size_of_file, document *newdoc, char *owner_address)); +#define SHOWINFO_TITLE "Information about the current document" + + #endif /* LYSHOWINFO_H */ diff --git a/src/LYSignal.h b/src/LYSignal.h index d8b1d106..9db40918 100644 --- a/src/LYSignal.h +++ b/src/LYSignal.h @@ -5,7 +5,7 @@ #include <signal.h> #ifdef VMS -extern void VMSsignal PARAMS((int sig, void (*func)())); +extern void *VMSsignal PARAMS((int sig, void (*func)())); #ifdef signal #undef signal #endif /* signal */ diff --git a/src/LYStrings.c b/src/LYStrings.c index 8a6a8c65..f273f051 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTCJK.h> #include <LYCurses.h> #include <LYUtils.h> @@ -14,13 +15,12 @@ #include <LYCharSets.h> #include <HTString.h> -#ifdef DJGPP_KEYHANDLER -#include <pc.h> -#include <keys.h> -#endif /* DJGPP_KEYHANDLER */ +#include <ctype.h> #include <LYLeaks.h> +#define FREE(x) if (x) {free(x); x = NULL;} + extern BOOL HTPassHighCtrlRaw; extern HTCJKlang HTCJK; @@ -56,47 +56,41 @@ PUBLIC int get_mouse_link NOARGS PRIVATE int set_clicked_link ARGS2(int,x,int,y) { - int left = 6; - int right = LYcols-6; - /* yes, I am assuming that my screen will be a certain width. */ - int i; - int c = -1; - - if (y == (LYlines-1)) { - if (x < left) c = LTARROW; - else if (x > right) c = '\b'; - else c = PGDOWN; - } else if (y == 0) { - if (x < left) c = LTARROW; - else if (x > right) c = '\b'; - else c = PGUP; - } else { - /* Loop over the links and see if we can get a match */ - for (i = 0; i < nlinks; i++) { - /* Check the first line of the link */ - if ( links[i].hightext != NULL && - links[i].ly == y && - (x - links[i].lx) < (int)strlen(links[i].hightext ) ) { - mouse_link = i; - break; - } - /* Check the second line */ - if (links[i].hightext2 != NULL && - 1+links[i].ly == y && - (x - links[i].hightext2_offset) < (int)strlen(links[i].hightext2) ) { - mouse_link = i; - break; - } - } - /* - * If a link was hit, we must look for a key which will activate - * LYK_ACTIVATE We expect to find LYK_ACTIVATE (it's usually mapped to - * the Enter key). - */ - if (mouse_link >= 0) - c = lookup_keymap(LYK_ACTIVATE); + int i; + + /* Loop over the links and see if we can get a match */ + for(i=0; i < nlinks && mouse_link == -1; i++) { + /* Check the first line of the link */ + if ( links[i].hightext != NULL && + links[i].ly == y && + (x - links[i].lx) < (int)strlen(links[i].hightext ) ) { + mouse_link=i; } - return c; + /* Check the second line */ + if (links[i].hightext2 != NULL && + 1+links[i].ly == y && + (x - links[i].hightext2_offset) < (int)strlen(links[i].hightext2) ) { + mouse_link=i; + } + } + /* If no link was found, just return a do-nothing code */ + if (mouse_link == -1) return -1; + + /* If a link was hit, we must look for a key which will activate LYK_ACTIVATE + ** XXX The 127 in the following line will depend on the size of the keymap[] + ** array. However, usually we'll find LYK_ACTIVATE somewhere in the first + ** 127 keys (it's usually mapped to the Enter key) + **/ + for (i=0; i<127; i++) { + if (LYisNonAlnumKeyname(i, LYK_ACTIVATE)) { + return i; + } + } + /* Whoops! Nothing's defined as LYK_ACTIVATE! + Well, who are we to argue with the user? + Forget about the mouse click */ + mouse_link = -1; + return -1; } @@ -110,7 +104,7 @@ PUBLIC char *LYstrncpy ARGS3( int, n) { char *val; - int len = strlen(src); + int len=strlen(src); if (n < 0) n = 0; @@ -238,15 +232,7 @@ PUBLIC int LYmbcsstrlen ARGS2( #ifdef VMS #define GetChar() ttgetc() #else -#ifdef __DJGPP__ -#ifdef DJGPP_KEYHANDLER -#define GetChar getxkey -#else -#define GetChar SLkp_getkey -#endif /* DJGPP_KEYHANDLER */ -#else #define GetChar (int)SLang_getkey -#endif /* __DJGPP__ */ #endif /* VMS */ #endif /* USE_SLANG */ @@ -277,62 +263,53 @@ PUBLIC int LYmbcsstrlen ARGS2( /* * Workaround a bug in ncurses order-of-refresh by setting a pointer to * the topmost window that should be displayed. - * - * FIXME: the associated call on 'keypad()' is not needed for Unix, but - * something in the OS/2 EMX port requires it. */ PRIVATE WINDOW *my_subwindow; PUBLIC void LYsubwindow ARGS1(WINDOW *, param) { - if ((my_subwindow = param) != 0) - keypad(param, TRUE); + my_subwindow = param; } #endif #ifdef USE_SLANG_MOUSE PRIVATE int sl_parse_mouse_event ARGS3(int *, x, int *, y, int *, button) { - /* "ESC [ M" has already been processed. There more characters are - * expected: BUTTON X Y - */ - *button = SLang_getkey (); - switch (*button) - { - case 040: /* left button */ - case 041: /* middle button */ - case 042: /* right button */ + /* "ESC [ M" has already been processed. There more characters are + * expected: BUTTON X Y + */ + *button = SLang_getkey (); + switch (*button) + { + case 040: /* left button */ + case 041: /* middle button */ + case 042: /* right button */ *button -= 040; break; - default: /* Hmmm.... */ + default: /* Hmmm.... */ SLang_flush_input (); return -1; - } + } - *x = SLang_getkey () - 33; - *y = SLang_getkey () - 33; - return 0; + *x = SLang_getkey () - 33; + *y = SLang_getkey () - 33; + return 0; } +#endif -PRIVATE int sl_read_mouse_event NOARGS +#if defined(USE_SLANG_MOUSE) || defined(NCURSES_MOUSE_VERSION) +PRIVATE int map_function_to_key ARGS1(char, keysym) { - int mouse_x, mouse_y, button; + int i; - mouse_link = -1; - if (-1 != sl_parse_mouse_event (&mouse_x, &mouse_y, &button)) + /* I would prefer to use sizeof keymap but its size is not available. + * A better method would be to declare it as some fixed size. + */ + for (i = 1; i < 256; i++) { - if (button == 0) /* left */ - return set_clicked_link (mouse_x, mouse_y); - - if (button == 2) /* right */ - { - /* Right button: go back to prev document. - * The problem is that we need to determine - * what to return to achieve this. - */ - return LYReverseKeymap (LYK_PREV_DOC); - } + if (keymap[i] == keysym) + return i - 1; } return -1; } @@ -344,477 +321,9 @@ PUBLIC void ena_csi ARGS1( { csi_is_csi = flag; } - -#if defined(USE_KEYMAPS) - -#ifdef USE_SLANG -#define define_key(string, code) \ - SLkm_define_keysym (string, code, Keymap_List) -#define expand_substring(dst, first, last) \ - SLexpand_escaped_string(dst, first, last) -static SLKeyMap_List_Type *Keymap_List; -/* This value should be larger than anything in LYStrings.h */ -#define MOUSE_KEYSYM 0x1000 -#endif - - -#define SQUOTE '\'' -#define DQUOTE '"' -#define ESCAPE '\\' -#define LPAREN '(' -#define RPAREN ')' - -/* - * For ncurses, we use the predefined keysyms, since that lets us also reuse - * the CSI logic and other special cases for VMS, NCSA telnet, etc. - */ -#ifdef USE_SLANG -#define DEFINE_KEY(string,lynx,curses) {string,lynx} -#else -#define DEFINE_KEY(string,lynx,curses) {string,curses} -#endif - -typedef struct -{ - char *string; - int value; -} -Keysym_String_List; - -static Keysym_String_List Keysym_Strings [] = -{ - DEFINE_KEY( "UPARROW", UPARROW, KEY_UP ), - DEFINE_KEY( "DNARROW", DNARROW, KEY_DOWN ), - DEFINE_KEY( "RTARROW", RTARROW, KEY_RIGHT ), - DEFINE_KEY( "LTARROW", LTARROW, KEY_LEFT ), - DEFINE_KEY( "PGDOWN", PGDOWN, KEY_NPAGE ), - DEFINE_KEY( "PGUP", PGUP, KEY_PPAGE ), - DEFINE_KEY( "HOME", HOME, KEY_HOME ), - DEFINE_KEY( "END", END_KEY, KEY_END ), - DEFINE_KEY( "F1", F1, KEY_F(1) ), - DEFINE_KEY( "DO_KEY", DO_KEY, KEY_F(16) ), - DEFINE_KEY( "FIND_KEY", FIND_KEY, KEY_FIND ), - DEFINE_KEY( "SELECT_KEY", SELECT_KEY, KEY_SELECT ), - DEFINE_KEY( "INSERT_KEY", INSERT_KEY, KEY_IC ), - DEFINE_KEY( "REMOVE_KEY", REMOVE_KEY, KEY_DC ), - DEFINE_KEY( "DO_NOTHING", DO_NOTHING, 0 ), - DEFINE_KEY( NULL, -1, ERR ) -}; - -#ifdef NCURSES_VERSION -/* - * Ncurses stores the termcap/terminfo names in arrays sorted to match the - * array of strings in the TERMTYPE struct. - */ -PRIVATE int lookup_tiname (char *name, NCURSES_CONST char *const *names) -{ - int code; - - for (code = 0; names[code] != 0; code++) - if (!strcmp(names[code], name)) - return code; - return -1; -} - -PRIVATE char *expand_tiname (char *first, size_t len, char **result) -{ - char name[BUFSIZ]; - int code; - - strncpy(name, first, len); - name[len] = '\0'; - if ((code = lookup_tiname(name, strnames)) >= 0 - || (code = lookup_tiname(name, strfnames)) >= 0) { - strcpy(*result, cur_term->type.Strings[code]); - (*result) += strlen(*result); - } - return first + len; -} - -PRIVATE char *expand_tichar (char *first, char **result) -{ - int ch; - int limit = 0; - int radix = 0; - int value = 0; - char *name = 0; - - switch (ch = *first++) { - case 'E': case 'e': value = 27; break; - case 'a': name = "bel"; break; - case 'b': value = '\b'; break; - case 'f': value = '\f'; break; - case 'n': value = '\n'; break; - case 'r': value = '\r'; break; - case 't': value = '\t'; break; - case 'v': value = '\v'; break; - case 'd': radix = 10; limit = 3; break; - case 'x': radix = 16; limit = 2; break; - default: - if (isdigit(ch)) { - radix = 8; - limit = 3; - first--; - } else { - value = *first; - } - break; - } - - if (radix != 0) { - char *last; - int save = first[limit]; - first[limit] = '\0'; - value = strtol(first, &last, radix); - first[limit] = save; - first = last; - } - - if (name != 0) { - (void) expand_tiname(name, strlen(name), result); - } else { - **result = value; - (*result) += 1; - } - - return first; -} - -PRIVATE void expand_substring (char* dst, char* first, char* last) -{ - int ch; - while (first < last) { - switch (ch = *first++) { - case ESCAPE: - first = expand_tichar(first, &dst); - break; - case '^': - ch = *first++; - if (ch == LPAREN) { - char *s = strchr(first, RPAREN); - if (s == 0) - s = first + strlen(first); - first = expand_tiname(first, s-first, &dst); - } else if (ch == '?') { /* ASCII delete? */ - *dst++ = 127; - } else if ((ch & 0x3f) < 0x20) { /* ASCII control char? */ - *dst++ = (ch & 0x1f); - } else { - *dst++ = '^'; - first--; /* not legal... */ - } - break; - case 0: /* convert nulls for terminfo */ - ch = 0200; - /* FALLTHRU */ - default: - *dst++ = ch; - break; - } - } - *dst = '\0'; -} -#endif - -PRIVATE void unescaped_char ARGS2(char*, parse, int*,keysym) -{ - size_t len = strlen(parse); - char buf[BUFSIZ]; - - if (len >= 3) { - expand_substring(buf, parse + 1, parse + len - 1); - if (strlen(buf) == 1) - *keysym = *buf; - } -} - -PRIVATE BOOLEAN unescape_string ARGS2(char*, src, char *, dst) -{ - BOOLEAN ok = FALSE; - - if (*src == SQUOTE) { - int keysym; - unescaped_char(src, &keysym); - if (keysym >= 0) { - dst[0] = keysym; - dst[1] = '\0'; - ok = TRUE; - } - } else if (*src == DQUOTE) { - expand_substring(dst, src + 1, src + strlen(src) - 1); - ok = TRUE; - } - return ok; -} - -PRIVATE int map_string_to_keysym ARGS2(char*, str, int*,keysym) -{ - *keysym = -1; - - if (*str == SQUOTE) { - unescaped_char(str, keysym); - } else if (isdigit(*str)) { - char *tmp; - long value = strtol(str, &tmp, 0); - if (!isalnum(*tmp)) - *keysym = value; - } else { - Keysym_String_List *k; - - k = Keysym_Strings; - while (k->string != NULL) { - if (0 == strcmp (k->string, str)) { - *keysym = k->value; - break; - } - k++; - } - } - - return (*keysym); -} - -/* - * Starting at a nonblank character, skip over a token, counting quoted and - * escaped characters. - */ -PRIVATE char *skip_keysym ARGS1(char *, parse) -{ - int quoted = 0; - int escaped = 0; - - while (*parse) { - if (escaped) { - escaped = 0; - } else if (quoted) { - if (*parse == ESCAPE) { - escaped = 1; - } else if (*parse == quoted) { - quoted = 0; - } - } else if (*parse == ESCAPE) { - escaped = 1; - } else if (*parse == DQUOTE || *parse == SQUOTE) { - quoted = *parse; - } else if (isspace(*parse)) { - break; - } - parse++; - } - return (quoted || escaped) ? 0 : parse; -} - -/* - * The first token is the string to define, the second is the name (of the - * keysym) to define it to. - */ -PRIVATE int setkey_cmd (char *parse) -{ - char *s, *t; - int keysym; - char buf[BUFSIZ]; - - if ((s = skip_keysym(parse)) != 0) { - if (isspace(*s)) { - *s++ = '\0'; - s = LYSkipBlanks(s); - if ((t = skip_keysym(s)) == 0) - return -1; - if (t != s) - *t = '\0'; - if (map_string_to_keysym (s, &keysym) >= 0 - && unescape_string(parse, buf)) { - return define_key(buf, keysym); - } - } - } - return -1; -} - -PRIVATE int unsetkey_cmd (char *parse) -{ - char *s = skip_keysym(parse); - if (s != parse) { - *s = '\0'; -#ifdef NCURSES_VERSION - /* - * This won't work with Slang. Remove the definition for the given - * keysym. - */ - { - int keysym; - if (map_string_to_keysym (parse, &keysym) >= 0) - define_key((char *)0, keysym); - } -#endif -#ifdef USE_SLANG - /* Slang implements this, for undefining the string which is associated - * with a keysym (the reverse of what we normally want, but may - * occasionally find useful). - */ - SLang_undefine_key (parse, Keymap_List); - if (SLang_Error) return -1; -#endif - } - return 0; -} - -#ifdef FNAMES_8_3 -#define FNAME_LYNX_KEYMAPS "_lynxkey.map" -#else -#define FNAME_LYNX_KEYMAPS ".lynx-keymaps" -#endif /* FNAMES_8_3 */ - -PRIVATE int read_keymap_file NOARGS -{ - static struct { - CONST char *name; - int (*func) PARAMS((char *s)); - } table[] = { - {"setkey", setkey_cmd }, - {"unsetkey", unsetkey_cmd }, - }; - - char line[1024]; - FILE *fp; - char file[LY_MAXPATH]; - int ret; - int linenum; - size_t n; - - LYAddPathToHome(file, sizeof(file), FNAME_LYNX_KEYMAPS); - - if ((fp = fopen (file, "r")) == 0) - return 0; - - linenum = 0; - ret = 0; - while ((fgets (line, sizeof (line), fp) != 0) && (ret == 0)) - { - char *s = LYSkipBlanks(line); - - linenum++; - - if ((*s == 0) || (*s == '#')) - continue; - - for (n = 0; n < TABLESIZE(table); n++) { - size_t len = strlen(table[n].name); - if (strlen(s) > len - && !strncmp(s, table[n].name, len)) { - if ((*(table[n].func))(LYSkipBlanks(s+len)) < 0) { - ret = -1; - break; - } - } - } - } - - fclose (fp); - - if (ret == -1) - fprintf (stderr, "Error processing line %d of %s\n", linenum, file); - - return ret; -} - -PRIVATE void setup_vtXXX_keymap NOARGS -{ - static Keysym_String_List table[] = { - DEFINE_KEY( "\033[A", UPARROW, KEY_UP ), - DEFINE_KEY( "\033OA", UPARROW, KEY_UP ), - DEFINE_KEY( "\033[B", DNARROW, KEY_DOWN ), - DEFINE_KEY( "\033OB", DNARROW, KEY_DOWN ), - DEFINE_KEY( "\033[C", RTARROW, KEY_RIGHT ), - DEFINE_KEY( "\033OC", RTARROW, KEY_RIGHT ), - DEFINE_KEY( "\033[D", LTARROW, KEY_LEFT ), - DEFINE_KEY( "\033OD", LTARROW, KEY_LEFT ), - DEFINE_KEY( "\033[1~", FIND_KEY, KEY_FIND ), - DEFINE_KEY( "\033[2~", INSERT_KEY, KEY_IC ), - DEFINE_KEY( "\033[3~", REMOVE_KEY, KEY_DC ), - DEFINE_KEY( "\033[4~", SELECT_KEY, KEY_SELECT ), - DEFINE_KEY( "\033[5~", PGUP, KEY_PPAGE ), - DEFINE_KEY( "\033[6~", PGDOWN, KEY_NPAGE ), - DEFINE_KEY( "\033[8~", END_KEY, KEY_END ), - DEFINE_KEY( "\033[7~", HOME, KEY_HOME), - DEFINE_KEY( "\033[28~", F1, KEY_F(1) ), - DEFINE_KEY( "\033OP", F1, KEY_F(1) ), - DEFINE_KEY( "\033[OP", F1, KEY_F(1) ), - DEFINE_KEY( "\033[29~", DO_KEY, KEY_F(16) ), - }; - size_t n; - for (n = 0; n < TABLESIZE(table); n++) - define_key(table[n].string, table[n].value); -} - -PUBLIC int lynx_initialize_keymaps NOARGS -{ -#ifdef USE_SLANG - int i; - char keybuf[2]; - - if (NULL == (Keymap_List = SLang_create_keymap ("Lynx", NULL))) - return -1; - - keybuf[1] = 0; - for (i = 1; i < 256; i++) - { - keybuf[0] = (char) i; - define_key (keybuf, i); - } - - setup_vtXXX_keymap(); - define_key ("\033[M", MOUSE_KEYSYM); - - if (SLang_Error - || (-1 == read_keymap_file ())) - SLang_exit_error ("Unable to initialize keymaps"); - return 0; -#else - setup_vtXXX_keymap(); - return read_keymap_file(); -#endif -} - -#endif /* USE_KEYMAPS */ - -#if defined(USE_KEYMAPS) && defined(USE_SLANG) - -/* We cannot guarantee the type for 'GetChar', and should not use a cast. */ -PRIVATE int myGetChar NOARGS -{ - return GetChar(); -} - -PUBLIC int LYgetch NOARGS -{ - SLang_Key_Type *key; - int keysym; - - key = SLang_do_key (Keymap_List, myGetChar); - if ((key == NULL) || (key->type != SLKEY_F_KEYSYM)) - return DO_NOTHING; - - keysym = key->f.keysym; - -#if defined (USE_SLANG_MOUSE) - if (keysym == MOUSE_KEYSYM) - return sl_read_mouse_event (); -#endif - - if ((keysym > DO_NOTHING) || (keysym < 0)) - return 0; - - return keysym; -} - -#else /* !USE_KEYMAPS */ - /* * LYgetch() translates some escape sequences and may fake noecho. */ -#define found_CSI(first,second) ((second) == '[' || (first) == 155) - PUBLIC int LYgetch NOARGS { int a, b, c, d = -1; @@ -825,7 +334,7 @@ re_read: #ifndef USE_SLANG clearerr(stdin); /* needed here for ultrix and SOCKETSHR, but why? - FM */ #endif /* !USE_SLANG */ -#if !defined(USE_SLANG) || defined(VMS) || defined(DJGPP_KEYHANDLER) +#if !defined(USE_SLANG) || defined(VMS) c = GetChar(); #else if (LYCursesON) { @@ -841,9 +350,27 @@ re_read: #endif /* IGNORE_CTRL_C */ return(7); /* use ^G to cancel whatever called us. */ } - } + } #endif /* !USE_SLANG || VMS */ +#ifdef RAWDOSKEYHACK + if (raw_dos_key_hack) { + if (c == 0) c = '/'; + if (c > 255) { /* handle raw dos keys */ + switch (c) + { + case 464: c = '-'; break; /* keypad minus*/ + case 465: c = '+'; break; /* keypad plus*/ + case 459: c = 13; break; /* keypad enter*/ + case 463: c = '*'; break; /* keypad * */ + case 440: c = 'Q'; break; /* alt x */ + case 265: c = 'H'; break; /* F1 */ + default: break; + } + } + } +#endif /* RAWDOSKEYHACK */ + #ifdef USE_GETCHAR if (c == EOF && errno == EINTR) /* Ctrl-Z causes EINTR in getchar() */ goto re_read; @@ -908,16 +435,32 @@ re_read: case 'C': c = RTARROW; break; case 'v': c = RTARROW; break; /* keypad right on pc ncsa telnet */ case 'D': c = LTARROW; break; - case 't': c = LTARROW; break; /* keypad left on pc ncsa telnet */ - case 'y': c = PGUP; break; /* keypad on pc ncsa telnet */ - case 's': c = PGDOWN; break; /* keypad on pc ncsa telnet */ - case 'w': c = HOME; break; /* keypad on pc ncsa telnet */ - case 'q': c = END_KEY; break; /* keypad on pc ncsa telnet */ + case 't': c = LTARROW; break; /* keypad left on pc ncsa telnet */ + case 'y': c = PGUP; break; /* keypad on pc ncsa telnet */ + case 's': c = PGDOWN; break; /* keypad on pc ncsa telnet */ + case 'w': c = HOME; break; /* keypad on pc ncsa telnet */ + case 'q': c = END; break; /* keypad on pc ncsa telnet */ case 'M': #ifdef USE_SLANG_MOUSE - if (found_CSI(c,b)) + if ((c == 27) && (b == '[')) { - c = sl_read_mouse_event (); + int mouse_x, mouse_y, button; + + mouse_link = -1; + c = -1; + if (-1 != sl_parse_mouse_event (&mouse_x, &mouse_y, &button)) + { + if (button == 0) /* left */ + c = set_clicked_link (mouse_x, mouse_y); + else if (button == 2) /* right */ + { + /* Right button: go back to prev document. + * The problem is that we need to determine + * what to return to achieve this. + */ + c = map_function_to_key (LYK_PREV_DOC); + } + } } else #endif @@ -959,11 +502,11 @@ re_read: c = '0'; /* keypad 0 */ break; case '1': /** VTxxx Find **/ - if (found_CSI(c,b) && (d=GetChar()) == '~') + if ((b == '[' || c == 155) && (d=GetChar()) == '~') c = FIND_KEY; break; case '2': - if (found_CSI(c,b)) { + if (b == '[' || c == 155) { if ((d=GetChar())=='~') /** VTxxx Insert **/ c = INSERT_KEY; else if ((d == '8' || @@ -979,33 +522,36 @@ re_read: } break; case '3': /** VTxxx Delete **/ - if (found_CSI(c,b) && (d=GetChar()) == '~') + if ((b == '[' || c == 155) && (d=GetChar()) == '~') c = REMOVE_KEY; break; case '4': /** VTxxx Select **/ - if (found_CSI(c,b) && (d=GetChar()) == '~') + if ((b == '[' || c == 155) && (d=GetChar()) == '~') c = SELECT_KEY; break; case '5': /** VTxxx PrevScreen **/ - if (found_CSI(c,b) && (d=GetChar()) == '~') + if ((b == '[' || c == 155) && (d=GetChar()) == '~') c = PGUP; break; case '6': /** VTxxx NextScreen **/ - if (found_CSI(c,b) && (d=GetChar()) == '~') + if ((b == '[' || c == 155) && (d=GetChar()) == '~') c = PGDOWN; break; case '[': /** Linux F1-F5: ^[[[A etc. **/ - if (found_CSI(c,b)) { + if (b == '[' || c == 155) { if ((d=GetChar()) == 'A') c = F1; break; } default: - CTRACE(tfp,"Unknown key sequence: %d:%d:%d\n",c,b,a); - CTRACE_SLEEP(MessageSecs); - break; + if (TRACE) { + fprintf(stderr,"Unknown key sequence: %d:%d:%d\n",c,b,a); + if (!LYTraceLogFP) { + sleep(MessageSecs); + } + } } - if (isdigit(a) && found_CSI(c,b) && d != -1 && d != '~') + if (isdigit(a) && (b == '[' || c == 155) && d != -1 && d != '~') d = GetChar(); } #if HAVE_KEYPAD @@ -1039,7 +585,7 @@ re_read: c = PGUP; break; case KEY_LL: /* home down or bottom (lower left) */ - c = END_KEY; + c = END; break; /* The keypad is arranged like this:*/ /* a1 up a3 */ @@ -1055,14 +601,14 @@ re_read: c = DO_NOTHING; break; case KEY_C1: /* lower left of keypad */ - c = END_KEY; + c = END; break; case KEY_C3: /* lower right of keypad */ c = PGDOWN; break; #ifdef KEY_END case KEY_END: /* end key 001 */ - c = END_KEY; + c = END; break; #endif /* KEY_END */ #ifdef KEY_HELP @@ -1075,7 +621,7 @@ re_read: c = 127; /* backspace key (delete, not Ctrl-H) */ break; #endif /* KEY_BACKSPACE */ -#if defined(KEY_F) && !defined(__DJGPP__) && !defined(_WINDOWS) +#ifdef KEY_F case KEY_F(1): c = F1; /* VTxxx Help */ break; @@ -1110,114 +656,47 @@ re_read: #endif /* KEY_DC */ #ifdef NCURSES_MOUSE_VERSION case KEY_MOUSE: - { + { #ifndef DOSPATH - MEVENT event; - int err; - - c = -1; - mouse_link = -1; - err = getmouse(&event); - if (event.bstate & BUTTON1_CLICKED) { - c = set_clicked_link(event.x, event.y); - } else if (event.bstate & BUTTON3_CLICKED) { - c = LYReverseKeymap (LYK_PREV_DOC); - } + MEVENT event; + int err; + + c = -1; + mouse_link = -1; + err=getmouse(&event); + if (event.bstate & BUTTON1_CLICKED) { + c = set_clicked_link(event.x, event.y); + } else if (event.bstate & BUTTON3_CLICKED) { + c = map_function_to_key (LYK_PREV_DOC); + } #else /* pdcurses version */ - c = -1; - mouse_link = -1; - request_mouse_pos(); - if (BUTTON_STATUS(1) & BUTTON_CLICKED) { - c = set_clicked_link(MOUSE_X_POS, MOUSE_Y_POS); - } else if (BUTTON_STATUS(3) & BUTTON_CLICKED) { - c = LYReverseKeymap (LYK_PREV_DOC); - } -#endif /* DOSPATH */ - } - break; + int left,right; + /* yes, I am assuming that my screen will be a certain width. */ + left = 6; + right = LYcols-6; + c = -1; + mouse_link = -1; + request_mouse_pos(); + if (Mouse_status.button[0] & BUTTON_CLICKED) { + if (Mouse_status.y == (LYlines-1)) + if (Mouse_status.x < left) c=LTARROW; + else if (Mouse_status.x > right) c='\b'; + else c=PGDOWN; + else if (Mouse_status.y == 0) + if (Mouse_status.x < left) c=LTARROW; + else if (Mouse_status.x > right) c='\b'; + else c=PGUP; + else c = set_clicked_link(Mouse_status.x, Mouse_status.y); + } +#endif /* _WINDOWS */ + } + break; #endif /* NCURSES_MOUSE_VERSION */ } } #endif /* HAVE_KEYPAD */ -#ifdef DJGPP_KEYHANDLER - else { - switch(c) { - case K_Down: /* The four arrow keys ... */ - case K_EDown: - c = DNARROW; - break; - case K_Up: - case K_EUp: - c = UPARROW; - break; - case K_Left: - case K_ELeft: - c = LTARROW; - break; - case K_Right: /* ... */ - case K_ERight: - c = RTARROW; - break; - case K_Home: /* Home key (upward+left arrow) */ - case K_EHome: - c = HOME; - break; - case K_PageDown: /* Next page */ - case K_EPageDown: - c = PGDOWN; - break; - case K_PageUp: /* Previous page */ - case K_EPageUp: - c = PGUP; - break; - case K_End: /* home down or bottom (lower left) */ - case K_EEnd: - c = END_KEY; - break; - } - } -#endif /* DGJPP_KEYHANDLER */ -#if defined(USE_SLANG) && defined(__DJGPP__) && !defined(DJGPP_KEYHANDLER) && !defined(USE_KEYMAPS) - else { - switch(c) { - case SL_KEY_DOWN: /* The four arrow keys ... */ - c = DNARROW; - break; - case SL_KEY_UP: - c = UPARROW; - break; - case SL_KEY_LEFT: - c = LTARROW; - break; - case SL_KEY_RIGHT: /* ... */ - c = RTARROW; - break; - case SL_KEY_HOME: /* Home key (upward+left arrow) */ - case SL_KEY_A1: /* upper left of keypad */ - c = HOME; - break; - case SL_KEY_NPAGE: /* Next page */ - case SL_KEY_C3: /* lower right of keypad */ - c = PGDOWN; - break; - case SL_KEY_PPAGE: /* Previous page */ - case SL_KEY_A3: /* upper right of keypad */ - c = PGUP; - break; - case SL_KEY_END: /* home down or bottom (lower left) */ - case SL_KEY_C1: /* lower left of keypad */ - c = END_KEY; - break; - } - } -#endif /* USE_SLANG && __DJGPP__ && !DJGPP_KEYHANDLER && !USE_KEYMAPS */ -#if (defined(__DJGPP__) || defined(_WINDOWS)) - if (c > 659) -#else - if (c > DO_NOTHING) -#endif /* __DJGPP__ || _WINDOWS */ - { + if (c > DO_NOTHING) { /* * Don't return raw values for KEYPAD symbols which we may have * missed in the switch above if they are obviously invalid when @@ -1229,110 +708,6 @@ re_read: } } -#endif /* NOT USE_KEYMAPS */ - -/* - * Convert a null-terminated string to lowercase - */ -PUBLIC void LYLowerCase ARGS1( - char *, buffer) -{ - size_t i; - for (i = 0; buffer[i]; i++) - buffer[i] = TOLOWER(buffer[i]); -} - -/* - * Convert a null-terminated string to uppercase - */ -PUBLIC void LYUpperCase ARGS1( - char *, buffer) -{ - size_t i; - for (i = 0; buffer[i]; i++) - buffer[i] = TOUPPER(buffer[i]); -} - -/* - * Remove ALL whitespace from a string (including embedded blanks). - */ -PUBLIC void LYRemoveBlanks ARGS1( - char *, buffer) -{ - if (buffer != 0) { - size_t i, j; - for (i = j = 0; buffer[i]; i++) - if (!isspace((unsigned char)(buffer[i]))) - buffer[j++] = buffer[i]; - buffer[j] = 0; - } -} - -/* - * Skip whitespace - */ -PUBLIC char * LYSkipBlanks ARGS1( - char *, buffer) -{ - while (isspace((unsigned char)(*buffer))) - buffer++; - return buffer; -} - -/* - * Skip non-whitespace - */ -PUBLIC char * LYSkipNonBlanks ARGS1( - char *, buffer) -{ - while (*buffer != 0 && !isspace((unsigned char)(*buffer))) - buffer++; - return buffer; -} - -/* - * Skip CONST whitespace - */ -PUBLIC CONST char * LYSkipCBlanks ARGS1( - CONST char *, buffer) -{ - while (isspace((unsigned char)(*buffer))) - buffer++; - return buffer; -} - -/* - * Skip CONST non-whitespace - */ -PUBLIC CONST char * LYSkipCNonBlanks ARGS1( - CONST char *, buffer) -{ - while (*buffer != 0 && !isspace((unsigned char)(*buffer))) - buffer++; - return buffer; -} - -/* - * Trim leading blanks from a string - */ -PUBLIC void LYTrimLeading ARGS1( - char *, buffer) -{ - char *skipped = LYSkipBlanks(buffer); - while ((*buffer++ = *skipped++) != 0) - ; -} - -/* - * Trim trailing blanks from a string - */ -PUBLIC void LYTrimTrailing ARGS1( - char *, buffer) -{ - size_t i = strlen(buffer); - while (i != 0 && isspace((unsigned char)buffer[i-1])) - buffer[--i] = 0; -} /* ** Display the current value of the string and allow the user @@ -1419,7 +794,7 @@ PUBLIC int LYEdit1 ARGS4( if (MaxLen <= 0) return(0); /* Be defensive */ - length = strlen(&Buf[0]); + length=strlen(&Buf[0]); StrLen = length; switch (action) { @@ -1565,11 +940,13 @@ PUBLIC int LYEdit1 ARGS4( break; case LYE_UPPER: - LYUpperCase(Buf); + for (i = 0; Buf[i]; i++) + Buf[i] = TOUPPER(Buf[i]); break; case LYE_LOWER: - LYLowerCase(Buf); + for (i = 0; Buf[i]; i++) + Buf[i] = TOLOWER(Buf[i]); break; default: @@ -1739,6 +1116,7 @@ again: */ strcpy(inputline, MyEdit.buffer); return(ch); + break; case LYE_ABORT: /* @@ -1746,6 +1124,7 @@ again: */ inputline[0] = '\0'; return(-1); + break; case LYE_LKCMD: /* @@ -1762,34 +1141,6 @@ again: } /* - * A replacement for 'strsep()' - */ -PUBLIC char *LYstrsep ARGS2( - char **, stringp, - CONST char *, delim) -{ - char *tmp, *out; - - if (!stringp || !*stringp) /* nothing to do? */ - return 0; /* then don't fall on our faces */ - - if (!**stringp) { /* empty string: */ - *stringp = 0; /* let caller see he's done; */ - return 0; /* no tokens in an empty string */ - } - - out = *stringp; /* save the start of the string */ - tmp = strpbrk(*stringp, delim); - if (tmp) { - *tmp = '\0'; /* terminate the substring with \0 */ - *stringp = ++tmp; /* point at the next substring */ - } - else *stringp = 0; /* this was the last substring: */ - /* let caller see he's done */ - return out; -} - -/* * LYstrstr will find the first occurrence of the string * pointed to by tarptr in the string pointed to by chptr. * It returns NULL if string not found. @@ -1797,7 +1148,7 @@ PUBLIC char *LYstrsep ARGS2( */ PUBLIC char * LYstrstr ARGS2( char *, chptr, - CONST char *, tarptr) + char *, tarptr) { int len = strlen(tarptr); @@ -2214,7 +1565,8 @@ PUBLIC char * SNACopy ARGS3( if (src) { *dest = (char *)calloc(1, n + 1); if (*dest == NULL) { - CTRACE(tfp, "Tried to calloc %d bytes\n", n); + if (TRACE) + fprintf(stderr, "Tried to calloc %d bytes\n", n); outofmem(__FILE__, "SNACopy"); } strncpy (*dest, src, n); @@ -2275,8 +1627,8 @@ PUBLIC char * SNACat ARGS3( ** may be interpreted as equal, but this side effect is negligible ** if the user search string is more than one character long. - LP ** -** We enable new technique only if DisplayCharsetMatchLocale = FALSE -** (see description in LYCharSets.c) +** We enable new technique only if DisplayCharsetMatchLocale = FALSE +** (see description in LYCharSets.c) */ PUBLIC int UPPER8 ARGS2(int,ch1, int,ch2) { @@ -2288,18 +1640,19 @@ PUBLIC int UPPER8 ARGS2(int,ch1, int,ch2) /* case-insensitive match for upper half */ if ((unsigned char)ch1 > 127 && (unsigned char)ch2 >127) { - if (DisplayCharsetMatchLocale) - return(TOUPPER(ch1) - TOUPPER(ch2)); /* old-style */ - else + if (DisplayCharsetMatchLocale) + return(TOUPPER(ch1) - TOUPPER(ch2)); /* old-style */ + else { /* compare "7bit approximation" for letters >127 */ /* BTW, if we remove the check for >127 above */ /* we get even more "relaxed" insensitive match... */ + CONST char *disp_charset = LYCharSet_UC[current_char_set].MIMEname; int charset_in, charset_out, uck1, uck2; char replace_buf1 [10], replace_buf2 [10]; - charset_in = current_char_set; /* display character set */ + charset_in = UCGetLYhndl_byMIME(disp_charset); charset_out = UCGetLYhndl_byMIME("us-ascii"); uck1 = UCTransCharStr(replace_buf1, sizeof(replace_buf1), ch1, @@ -2312,7 +1665,7 @@ PUBLIC int UPPER8 ARGS2(int,ch1, int,ch2) /* check to be sure we have not lost any strange characters */ /* which are not found in def7_uni.tbl but _equal_ in fact. */ - /* this also applied for "x-transparent" display mode. */ + /* this also applied for "x-transparent" display mode. */ if ((unsigned char)ch1==(unsigned char)ch2) return(0); /* match */ } diff --git a/src/LYStrings.h b/src/LYStrings.h index 14cb46cf..bb4d70f2 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -1,7 +1,8 @@ #ifndef LYSTRINGS_H #define LYSTRINGS_H -#include <HTUtils.h> +#include <string.h> + /* UPPER8(ch1,ch2) is an extension of (TOUPPER(ch1) - TOUPPER(ch2)) */ extern int UPPER8 PARAMS(( @@ -20,12 +21,9 @@ extern int LYgetstr PARAMS(( int hidden, size_t bufsize, int recall)); -extern char *LYstrsep PARAMS(( - char ** stringp, - const char * delim)); extern char * LYstrstr PARAMS(( char * chptr, - CONST char * tarptr)); + char * tarptr)); extern char * LYmbcsstrncpy PARAMS(( char * dst, CONST char * src, @@ -69,6 +67,8 @@ extern char * SNACat PARAMS(( #define StrnAllocCopy(dest, src, n) SNACopy (&(dest), src, n) #define StrnAllocCat(dest, src, n) SNACat (&(dest), src, n) +#define printable(c) (((c)>31 && (c)<=255) || (c)==9 || (c)==10 || (c)<0 ) + /* values for LYgetch */ #define UPARROW 256 /* 0x100 */ #define DNARROW 257 /* 0x101 */ @@ -77,7 +77,7 @@ extern char * SNACat PARAMS(( #define PGDOWN 260 /* 0x104 */ #define PGUP 261 /* 0x105 */ #define HOME 262 /* 0x106 */ -#define END_KEY 263 /* 0x107 */ +#define END 263 /* 0x107 */ #define F1 264 /* 0x108 */ #define DO_KEY 265 /* 0x109 */ #define FIND_KEY 266 /* 0x10A */ @@ -144,28 +144,6 @@ typedef struct _EditFieldData { #define LYE_AIX (LYE_LKCMD +1) /* Hex 97 */ -#if defined(USE_KEYMAPS) -extern int lynx_initialize_keymaps NOPARAMS; -#endif - -extern void LYLowerCase PARAMS(( - char * buffer)); -extern void LYUpperCase PARAMS(( - char * buffer)); -extern void LYRemoveBlanks PARAMS(( - char * buffer)); -extern char * LYSkipBlanks PARAMS(( - char * buffer)); -extern char * LYSkipNonBlanks PARAMS(( - char * buffer)); -extern CONST char * LYSkipCBlanks PARAMS(( - CONST char * buffer)); -extern CONST char * LYSkipCNonBlanks PARAMS(( - CONST char * buffer)); -extern void LYTrimLeading PARAMS(( - char * buffer)); -extern void LYTrimTrailing PARAMS(( - char * buffer)); extern void LYSetupEdit PARAMS(( EditFieldData * edit, char * old, @@ -184,7 +162,7 @@ extern int current_lineedit; extern char * LYLineeditNames[]; extern char * LYLineEditors[]; -/* Push a character through the lineedit machinery */ +/* Push a chacter through the linedit machinery */ #define EditBinding(c) (LYLineEditors[current_lineedit][c]) #define LYLineEdit(e,c,m) LYEdit1(e,c,EditBinding(c),m) diff --git a/src/LYStructs.h b/src/LYStructs.h index ff58cd87..051db432 100644 --- a/src/LYStructs.h +++ b/src/LYStructs.h @@ -1,3 +1,4 @@ + #ifndef LYSTRUCTS_H #define LYSTRUCTS_H @@ -31,9 +32,9 @@ typedef struct _document { char * address; char * post_data; char * post_content_type; - char * bookmark; BOOL safe; BOOL isHEAD; + char * bookmark; int link; int line; BOOL internal_link; /* whether doc was reached via an internal @@ -52,11 +53,11 @@ typedef struct _histstruct { char * address; char * post_data; char * post_content_type; - char * bookmark; BOOL safe; + char * bookmark; BOOL isHEAD; int link; - int line; + int page; BOOL internal_link; /* whether doc was reached via an internal (fragment) link. - kw */ int intern_seq_start; /* indicates which element on the history diff --git a/src/LYStyle.c b/src/LYStyle.c index 8a95d2b6..3953621f 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,9 +1,10 @@ /* character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) - * @Id: LYStyle.c 1.19 Thu, 06 Aug 1998 06:28:22 -0600 dickey @ + * @Id: LYStyle.c 1.17 Wed, 25 Mar 1998 06:58:54 -0700 dickey @ */ #include <HTUtils.h> #include <HTML.h> +#include <tcp.h> #include <LYSignal.h> #include <LYGlobalDefs.h> @@ -49,6 +50,9 @@ PUBLIC int s_alink = NOSTYLE, s_a = NOSTYLE, s_status = NOSTYLE, PRIVATE int colorPairs = 0; PRIVATE int last_fA = COLOR_WHITE, last_bA = COLOR_BLACK; + +#define FREE(x) if (x) {free(x); x = NULL;} + /* icky parsing of the style options */ PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char*,element) { @@ -56,7 +60,8 @@ PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char* int mA = 0, fA = default_fg, bA = default_bg, cA = A_NORMAL; int newstyle = hash_code(element); - CTRACE(tfp, "CSS(PA):style d=%d / h=%d, e=%s\n", style, newstyle,element); + if (TRACE) + fprintf(stderr, "CSS(PA):style d=%d / h=%d, e=%s\n", style, newstyle,element); for (i = 0; i <7; i++) { @@ -65,7 +70,8 @@ PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char* mA = ncursesMono[i]; } } - CTRACE(tfp, "CSS(CP):%d\n", colorPairs); + if (TRACE) + fprintf(stderr, "CSS(CP):%d\n", colorPairs); fA = check_color(fg, default_fg); bA = check_color(bg, default_bg); @@ -171,9 +177,13 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n", buffer); } } - CTRACE(tfp, "CSSPARSE:%s => %d %s\n", - element, hash_code(element), - (hashStyles[hash_code(element)].name ? "used" : "")); + if (TRACE) + { + int bkt = hash_code(element); + fprintf(stderr, "CSSPARSE:%s => %d %s\n", + element, bkt, + (hashStyles[bkt].name ? "used" : "")); + } strtolower(element); @@ -225,7 +235,8 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n", buffer); { if (!strcasecomp (HTML_dtd.tags[i].name, element)) { - CTRACE(tfp, "PARSECSS:applying style <%s,%s,%s> for HTML_%s\n",mono,fg,bg,HTML_dtd.tags[i].name); + if (TRACE) + fprintf(stderr, "PARSECSS:applying style <%s,%s,%s> for HTML_%s\n",mono,fg,bg,HTML_dtd.tags[i].name); parse_attributes(mono,fg,bg,i+STARTAT,element); break; } @@ -307,7 +318,8 @@ PUBLIC void parse_userstyles NOARGS while ((name = HTList_nextObject(cur)) != NULL) { - CTRACE(tfp, "LSS:%s\n", name ? name : "!?! empty !?!"); + if (TRACE) + fprintf(stderr, "LSS:%s\n", name ? name : "!?! empty !?!"); if (name != NULL) parse_style(name); } @@ -322,7 +334,8 @@ PUBLIC void HStyle_addStyle ARGS1(char*,buffer) if (lss_styles == NULL) lss_styles = HTList_new(); strtolower(name); - CTRACE(tfp, "READCSS:%s\n", name ? name : "!?! empty !?!"); + if (TRACE) + fprintf(stderr, "READCSS:%s\n", name ? name : "!?! empty !?!"); HTList_addObject (lss_styles, name); } @@ -353,14 +366,16 @@ PUBLIC int style_readFromFile ARGS1(char*, file) char buffer[1024]; int len; - CTRACE(tfp, "CSS:Reading styles from file: %s\n", file ? file : "?!? empty ?!?"); + if (TRACE) + fprintf(stderr, "CSS:Reading styles from file: %s\n", file ? file : "?!? empty ?!?"); if (file == NULL || *file == '\0') return -1; fh = fopen(file, "r"); if (!fh) { /* this should probably be an alert or something */ - CTRACE(tfp, "CSS:Can't open style file %s, using defaults\n", file); + if (TRACE) + fprintf(stderr, "CSS:Can't open style file %s, using defaults\n", file); return -1; } diff --git a/src/LYSystem.h b/src/LYSystem.h new file mode 100644 index 00000000..6acd02b3 --- /dev/null +++ b/src/LYSystem.h @@ -0,0 +1,10 @@ + +#ifndef LYSYSTEM_H +#define LYSYSTEM_H + +#ifdef VMS +extern int DCLsystem PARAMS((char *command)); +#define system(a) DCLsystem(a) /* use LYCurses.c routines for spawns */ +#endif /* VMS */ + +#endif /* LYSYSTEM_H */ diff --git a/src/LYTraversal.c b/src/LYTraversal.c index d92b7dcd..c8e0df47 100644 --- a/src/LYTraversal.c +++ b/src/LYTraversal.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <LYGlobalDefs.h> #include <LYUtils.h> #include <LYSignal.h> diff --git a/src/LYUpload.c b/src/LYUpload.c index c9488e22..0ad784f5 100644 --- a/src/LYUpload.c +++ b/src/LYUpload.c @@ -15,7 +15,7 @@ */ #include <HTUtils.h> -#include <HTFile.h> +#include <tcp.h> #include <HTParse.h> #include <HTAlert.h> #include <LYCurses.h> @@ -26,49 +26,52 @@ #include <LYClean.h> #include <LYGetFile.h> #include <LYUpload.h> +#include <LYSystem.h> #include <LYLocal.h> #include <LYexit.h> #include <LYLeaks.h> -PUBLIC char LYUploadFileURL[LY_MAXPATH] = "\0"; +#define FREE(x) if (x) {free(x); x = NULL;} + +PUBLIC char LYUploadFileURL[256] = "\0"; /* - * LYUpload uploads a file to a given location using a + * LYUpload uploads a file to a given location using a * specified upload method. It parses an incoming link * that looks like: * LYNXDIRED://UPLOAD=<#>/TO=<STRING> */ PUBLIC int LYUpload ARGS1( - char *, line) + char *, line) { char *method, *directory, *dir; int method_number; int count; - char tmpbuf[LY_MAXPATH]; - char buffer[LY_MAXPATH]; + char tmpbuf[256]; + char buffer[256]; lynx_html_item_type *upload_command = 0; int c; char *cp; FILE *fp; - char cmd[20 + (LY_MAXPATH*2)]; + char cmd[512]; #ifdef VMS extern BOOLEAN HadVMSInterrupt; #endif /* VMS */ /* - * Use configured upload commands. + * Use configured upload commands. */ if((directory = (char *)strstr(line, "TO=")) == NULL) goto failed; *(directory - 1) = '\0'; /* go past "Directory=" */ - directory += 3; + directory+=3; if((method = (char *)strstr(line, "UPLOAD=")) == NULL) goto failed; /* - * Go past "Method=". + * Go past "Method=". */ method += 7; method_number = atoi(method); @@ -78,22 +81,23 @@ PUBLIC int LYUpload ARGS1( ; /* null body */ /* - * Parsed out the Method and the Location? + * Parsed out the Method and the Location? */ if (upload_command->command == NULL) { - HTAlert("ERROR! - upload command is misconfigured"); + _statusline("ERROR! - upload command is misconfigured"); + sleep(AlertSecs); goto failed; } /* - * Care about the local name? + * Care about the local name? */ if (strstr(upload_command->command, "%s")) { /* * Commands have the form "command %s [etc]" * where %s is the filename. */ - _statusline(FILENAME_PROMPT); + _statusline("Enter a filename: "); retry: *tmpbuf = '\0'; if (LYgetstr(tmpbuf, VISIBLE, sizeof(tmpbuf), NORECALL) < 0) @@ -103,21 +107,31 @@ retry: goto cancelled; if (strstr(tmpbuf, "../") != NULL) { - HTAlert("Illegal redirection \"../\" found! Request ignored."); + _statusline( + "Illegal redirection \"../\" found! Request ignored."); + sleep(AlertSecs); goto cancelled; } else if (strchr(tmpbuf, '/') != NULL) { - HTAlert("Illegal character \"/\" found! Request ignored."); + _statusline("Illegal character \"/\" found! Request ignored."); + sleep(AlertSecs); goto cancelled; } else if (tmpbuf[0] == '~') { - HTAlert("Illegal redirection using \"~\" found! Request ignored."); + _statusline( + "Illegal redirection using \"~\" found! Request ignored."); + sleep(AlertSecs); goto cancelled; } sprintf(buffer, "%s/%s", directory, tmpbuf); if (no_dotfiles || !show_dotfiles) { - if (*LYPathLeaf(buffer) == '.') { - HTAlert(FILENAME_CANNOT_BE_DOT); - _statusline(NEW_FILENAME_PROMPT); + if (*buffer == '.' || +#ifdef VMS + ((cp = strrchr(buffer, ':')) && *(cp+1) == '.') || + ((cp = strrchr(buffer, ']')) && *(cp+1) == '.') || +#endif /* VMS */ + ((cp = strrchr(buffer, '/')) && *(cp+1) == '.')) { + _statusline( + "File name may not begin with dot. Enter a new filename: "); goto retry; } } @@ -129,9 +143,9 @@ retry: fclose(fp); #ifdef VMS - _statusline(FILE_EXISTS_HPROMPT); + _statusline("File exists. Create higher version? (y/n)"); #else - _statusline(FILE_EXISTS_OPROMPT); + _statusline("File exists. Overwrite? (y/n)"); #endif /* VMS */ c = 0; while (TOUPPER(c) != 'Y' && TOUPPER(c) != 'N' && c != 7 && c != 3) @@ -148,7 +162,7 @@ retry: } if (TOUPPER(c) == 'N') { - _statusline(NEW_FILENAME_PROMPT); + _statusline("Enter a filename: "); goto retry; } } @@ -156,18 +170,15 @@ retry: /* * See if we can write to it. */ - CTRACE(tfp, "LYUpload: filename is %s", buffer); - if ((fp = fopen(buffer, "w")) != NULL) { fclose(fp); remove(buffer); } else { - HTAlert(CANNOT_WRITE_TO_FILE); - _statusline(NEW_FILENAME_PROMPT); + _statusline("Cannot write to file. Enter a new filename: "); goto retry; } -#if defined (VMS) || defined (__EMX__) || defined(__DJGPP__) +#ifdef VMS sprintf(tmpbuf, upload_command->command, buffer, "", "", "", "", ""); #else cp = quote_pathname(buffer); /* to prevent spoofing of the shell */ @@ -182,22 +193,26 @@ retry: sprintf(cmd, "cd %s ; %s", dir, tmpbuf); FREE(dir); stop_curses(); - CTRACE(tfp, "command: %s\n", cmd); - LYSystem(cmd); + if (TRACE) + fprintf(stderr, "command: %s\n", cmd); + system(cmd); + fflush(stdout); start_curses(); -#ifdef UNIX +#ifdef UNIX chmod(buffer, HIDE_CHMOD); -#endif /* UNIX */ +#endif /* UNIX */ /* don't remove(file); */ return 1; failed: - HTAlert("Unable to upload file."); + _statusline("Unable to upload file."); + sleep(AlertSecs); return 0; cancelled: - HTInfoMsg("Cancelling."); + _statusline("Cancelling."); + sleep(InfoSecs); return 0; } @@ -209,17 +224,33 @@ cancelled: */ PUBLIC int LYUpload_options ARGS2( char **, newfile, - char *, directory) + char *, directory) { - static char tempfile[LY_MAXPATH]; + static char tempfile[256]; + static BOOLEAN first = TRUE; FILE *fp0; lynx_html_item_type *cur_upload; int count; - static char curloc[LY_MAXPATH]; + static char curloc[256]; char *cp; - LYRemoveTemp(tempfile); - if ((fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { + if (first) { + /* + * Get an unused tempfile name. - FM + */ + tempname(tempfile, NEW_FILE); +#ifdef VMS + } else { + remove(tempfile); /* Remove duplicates on VMS. */ +#endif /* VMS */ + } + + /* + * Open the tempfile for writing and set it's + * protection in case this wasn't done via an + * external umask. - FM + */ + if ((fp0 = LYNewTxtFile(tempfile)) == NULL) { HTAlert(CANNOT_OPEN_TEMP); return(-1); } @@ -227,38 +258,57 @@ PUBLIC int LYUpload_options ARGS2( #ifdef VMS strcpy(curloc, "/sys$login"); #else - cp = HTfullURL_toFile(directory); + cp = directory; + if (!strncmp(cp, "file://localhost", 16)) + cp += 16; + else if (!strncmp(cp, "file:", 5)) + cp += 5; strcpy(curloc,cp); - LYTrimPathSep(curloc); - free(cp); + HTUnEscape(curloc); + if (curloc[strlen(curloc) - 1] == '/') + curloc[strlen(curloc) - 1] = '\0'; +#endif /* VMS */ + + if (first) { + /* + * Make the tempfile a URL. + */ +#if defined (VMS) || defined (DOSPATH) + sprintf(LYUploadFileURL, "file://localhost/%s", tempfile); +#else + sprintf(LYUploadFileURL, "file://localhost%s", tempfile); #endif /* VMS */ + first = FALSE; + } + StrAllocCopy(*newfile, LYUploadFileURL); - LYLocalFileToURL(newfile, tempfile); - strcpy(LYUploadFileURL, *newfile); + fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n", + UPLOAD_OPTIONS_TITLE); - BeginInternalPage(fp0, UPLOAD_OPTIONS_TITLE, UPLOAD_OPTIONS_HELP); + fprintf(fp0, "<h1>Upload Options (%s Version %s)</h1>\n", + LYNX_NAME, LYNX_VERSION); - fprintf(fp0, "<pre>\n"); - fprintf(fp0, " <em>Upload To:</em> %s\n", curloc); - fputs("\nUpload options:\n", fp0); + fputs("You have the following upload choices.<br>\n", fp0); + fputs("Please select one:<br>\n<pre>\n", fp0); if (uploaders != NULL) { for (count = 0, cur_upload = uploaders; - cur_upload != NULL; + cur_upload != NULL; cur_upload = cur_upload->next, count++) { fprintf(fp0, " <a href=\"LYNXDIRED://UPLOAD=%d/TO=%s\">", count, curloc); - fprintf(fp0, (cur_upload->name ? + fprintf(fp0, (cur_upload->name ? cur_upload->name : "No Name Given")); fprintf(fp0, "</a>\n"); } } else { - fprintf(fp0, " <NONE>\n"); - } + fprintf(fp0, "\n \ +No other upload methods have been defined yet. You may define\n \ +an unlimited number of upload methods using the lynx.cfg file.\n"); - fprintf(fp0, "</pre>\n"); - EndInternalPage(fp0); - LYCloseTempFP(fp0); + } + fprintf(fp0, "</pre>\n</body>\n"); + fclose(fp0); LYforce_no_cache = TRUE; diff --git a/src/LYUpload.h b/src/LYUpload.h index 563c063e..17542b06 100644 --- a/src/LYUpload.h +++ b/src/LYUpload.h @@ -9,5 +9,7 @@ extern int LYUpload PARAMS((char *line)); extern int LYUpload_options PARAMS((char **newfile, char *directory)); +#define UPLOAD_OPTIONS_TITLE "Lynx Upload Options" + #endif /* LYUPLOAD_H */ diff --git a/src/LYUtils.c b/src/LYUtils.c index 5e82ca6d..842b8f0c 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,31 +1,26 @@ #include <HTUtils.h> -#include <HTTCP.h> +#include <tcp.h> +#include <ctype.h> #include <HTParse.h> #include <HTAccess.h> #include <HTCJK.h> #include <HTAlert.h> #include <LYCurses.h> -#include <LYHistory.h> #include <LYUtils.h> #include <LYStrings.h> #include <LYGlobalDefs.h> #include <LYSignal.h> #include <GridText.h> #include <LYCharSets.h> -#include <LYCharUtils.h> - -#ifdef DJGPP_KEYHANDLER -#include <bios.h> -#endif /* DJGPP_KEYHANDLER */ - -#ifdef DISP_PARTIAL -#include <LYKeymap.h> -#endif /* DISP_PARTIAL */ +#ifdef DOSPATH +#include <HTDOS.h> +#endif #ifdef VMS #include <descrip.h> #include <libclidef.h> #include <lib$routines.h> +#include <HTVMSUtils.h> #endif /* VMS */ #if HAVE_UTMP @@ -58,6 +53,8 @@ #include <LYStyle.h> #endif +#undef hline /* FIXME: this is a curses feature used as a variable here */ + #ifdef SVR4_BSDSELECT extern int BSDselect PARAMS((int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval * timeout)); @@ -85,6 +82,8 @@ extern int BSDselect PARAMS((int nfds, fd_set * readfds, fd_set * writefds, #endif /* __FreeBSD__ || __bsdi__ */ #endif /* !UTMP_FILE */ +#define FREE(x) if (x) {free(x); x = NULL;} + extern HTkcode kanji_code; extern BOOLEAN LYHaveCJKCharacterSet; extern HTCJKlang HTCJK; @@ -1714,6 +1713,26 @@ PUBLIC void free_and_clear ARGS1( } /* + * Collapse (REMOVE) all spaces in the string. + */ +PUBLIC void collapse_spaces ARGS1( + char *, string) +{ + int i=0; + int j=0; + + if (!string) + return; + + for (; string[i] != '\0'; i++) + if (!isspace((unsigned char)string[i])) + string[j++] = string[i]; + + string[j] = '\0'; /* terminate */ + return; +} + +/* * Convert single or serial newlines to single spaces throughout a string * (ignore newlines if the preceding character is a space) and convert * tabs to single spaces. Don't ignore any explicit tabs or spaces if @@ -1819,9 +1838,9 @@ PUBLIC void statusline ARGS1( if ((temp = (unsigned char *)calloc(1, strlen(text) + 1)) == NULL) outofmem(__FILE__, "statusline"); if (kanji_code == EUC) { - TO_EUC((CONST unsigned char *)text, temp); + TO_EUC((unsigned char *)text, temp); } else if (kanji_code == SJIS) { - TO_SJIS((CONST unsigned char *)text, temp); + TO_SJIS((unsigned char *)text, temp); } else { for (i = 0, j = 0; text[i]; i++) { if (text[i] != '\033') { @@ -1974,7 +1993,7 @@ PUBLIC void noviceline ARGS1( if (LYUseNoviceLineTwo) addstr(NOVICE_LINE_TWO); else - addstr((char *)novice_lines[lineno]); + addstr(novice_lines[lineno]); #ifdef NOTDEFINED if (is_www_index && more_flag) { @@ -2013,15 +2032,19 @@ PUBLIC void LYFakeZap ARGS1( BOOL, set) { if (set && fake_zap < 1) { - CTRACE(tfp, "\r *** Set simulated 'Z'"); - if (fake_zap) - CTRACE(tfp, ", %d pending", fake_zap); - CTRACE(tfp, " ***\n"); + if (TRACE) { + fprintf(stderr, "\r *** Set simulated 'Z'"); + if (fake_zap) + fprintf(stderr, ", %d pending", fake_zap); + fprintf(stderr, " ***\n"); + } fake_zap++; } else if (!set && fake_zap) { - CTRACE(tfp, "\r *** Unset simulated 'Z'"); - CTRACE(tfp, ", %d pending", fake_zap); - CTRACE(tfp, " ***\n"); + if (TRACE) { + fprintf(stderr, "\r *** Unset simulated 'Z'"); + fprintf(stderr, ", %d pending", fake_zap); + fprintf(stderr, " ***\n"); + } fake_zap = 0; } @@ -2029,8 +2052,8 @@ PUBLIC void LYFakeZap ARGS1( PUBLIC int HTCheckForInterrupt NOARGS { - int c; #ifndef VMS /* UNIX stuff: */ + int c; #ifndef USE_SLANG struct timeval socket_timeout; int ret = 0; @@ -2039,9 +2062,12 @@ PUBLIC int HTCheckForInterrupt NOARGS if (fake_zap > 0) { fake_zap--; - CTRACE(tfp, "\r *** Got simulated 'Z' ***\n"); - CTRACE_FLUSH(tfp); - CTRACE_SLEEP(AlertSecs); + if (TRACE) { + fprintf(stderr, "\r *** Got simulated 'Z' ***\n"); + fflush(stderr); + if (!LYTraceLogFP) + sleep(AlertSecs); + } return((int)TRUE); } @@ -2054,11 +2080,7 @@ PUBLIC int HTCheckForInterrupt NOARGS Note that this isn't taking possible SOCKSification and the socks_flag into account, and may fail on the slang library's select() when SOCKSified. - FM **/ -#ifdef DJGPP_KEYHANDLER - if (0 == _bios_keybrd(_NKEYBRD_READY)) -#else if (0 == SLang_input_pending(0)) -#endif /* DJGPP_KEYHANDLER */ return(FALSE); #else /* Unix curses: */ @@ -2093,16 +2115,26 @@ PUBLIC int HTCheckForInterrupt NOARGS #if defined (DOSPATH) && defined (NCURSES) nodelay(stdscr,FALSE); #endif /* DOSPATH */ + if (TOUPPER(c) == 'Z' || c == 7 || c == 3) + return((int)TRUE); + + /** Other keystrokes **/ + return((int)FALSE); #else /* VMS: */ + + int c; extern BOOLEAN HadVMSInterrupt; extern int typeahead(); if (fake_zap > 0) { fake_zap--; - CTRACE(tfp, "\r *** Got simulated 'Z' ***\n"); - CTRACE_FLUSH(tfp); - CTRACE_SLEEP(AlertSecs); + if (TRACE) { + fprintf(stderr, "\r *** Got simulated 'Z' ***\n"); + fflush(stderr); + if (!LYTraceLogFP) + sleep(AlertSecs); + } return((int)TRUE); } @@ -2118,66 +2150,12 @@ PUBLIC int HTCheckForInterrupt NOARGS /** Keyboard 'Z' or 'z', or Control-G or Control-C **/ c = typeahead(); - -#endif /* !VMS */ - - /* - * 'c' contains whatever character we're able to read from type-ahead - */ if (TOUPPER(c) == 'Z' || c == 7 || c == 3) return((int)TRUE); -#ifdef DISP_PARTIAL - else if (display_partial && (NumOfLines_partial > 2)) - /* OK, we got several lines from new document and want to scroll... */ - { - switch (keymap[c+1]) - { - case LYK_PREV_PAGE : - if (Newline_partial > 1) - Newline_partial -= display_lines ; - break ; - case LYK_NEXT_PAGE : - if (HText_canScrollDown()) - Newline_partial += display_lines ; - break ; - case LYK_UP_HALF : - if (Newline_partial > 1) - Newline_partial -= (display_lines/2) ; - break ; - case LYK_DOWN_HALF : - if (HText_canScrollDown()) - Newline_partial += (display_lines/2) ; - break ; - case LYK_UP_TWO : - if (Newline_partial > 1) - Newline_partial -= 2 ; - break ; - case LYK_DOWN_TWO : - if (HText_canScrollDown()) - Newline_partial += 2 ; - break ; - case LYK_HOME: - if (Newline_partial > 1) - Newline_partial = 1; - break; - case LYK_END: - if (HText_canScrollDown()) - Newline_partial = HText_getNumOfLines() - display_lines + 1; - /* calculate for "current" bottom value */ - break; - case LYK_REFRESH : - break ; - default : - return ((int)FALSE) ; - } - if (Newline_partial < 1) - Newline_partial = 1; - NumOfLines_partial = HText_getNumOfLines(); - HText_pageDisplay(Newline_partial, ""); - } -#endif /* DISP_PARTIAL */ + /** Other or no keystrokes **/ return((int)FALSE); +#endif /* !VMS */ } /* @@ -2248,13 +2226,12 @@ 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; } @@ -2332,11 +2309,10 @@ 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; } @@ -2371,7 +2347,8 @@ PUBLIC int LYCheckForProxyURL ARGS1( return(0); /* kill beginning spaces */ - cp = LYSkipBlanks(cp); + while (isspace((unsigned char)*cp)) + cp++; /* * Check for a colon, and if present, @@ -2391,7 +2368,7 @@ PUBLIC int LYCheckForProxyURL ARGS1( if (isdigit((unsigned char)*cp1)) { while (*cp1 && isdigit((unsigned char)*cp1)) cp1++; - if (*cp1 && !LYIsHtmlSep(*cp1)) + if (*cp1 && *cp1 != '/') return(UNKNOWN_URL_TYPE); } } @@ -2400,29 +2377,9 @@ PUBLIC int LYCheckForProxyURL ARGS1( } /* - * Compare a "type:" string, replacing it by the comparison-string if it - * matches (and return true in that case). - */ -static BOOLEAN compare_type ARGS3( - char *, tst, - CONST char *, cmp, - size_t, len) -{ - if (!strncasecomp(tst, cmp, len)) { - if (strncmp(tst, cmp, len)) { - size_t i; - for (i = 0; i < len; i++) - tst[i] = cmp[i]; - } - return TRUE; - } - return FALSE; -} - -/* ** Must recognize a URL and return the type. ** If recognized, based on a case-insensitive -** analysis of the scheme field, ensures that +** analyis of the scheme field, ensures that ** the scheme field has the expected case. ** ** Returns 0 (not a URL) for a NULL argument, @@ -2436,6 +2393,7 @@ PUBLIC int is_url ARGS1( { char *cp = filename; char *cp1; + int i; /* * Don't crash on an empty argument. @@ -2452,7 +2410,8 @@ PUBLIC int is_url ARGS1( /* * Kill beginning spaces. */ - cp = LYSkipBlanks(cp); + while (isspace((unsigned char)*cp)) + cp++; /* * Can't be a URL if it starts with a slash. @@ -2460,132 +2419,206 @@ PUBLIC int is_url ARGS1( * also to avoid false positives if there was * a colon later in the string. - KW */ - if (LYIsHtmlSep(*cp)) + if (*cp == '/') return(0); -#if defined (DOSPATH) || defined (__EMX__) /* sorry! */ - if (strncmp(cp, "file:///", 8) && strlen(cp) == 19 && - cp[strlen(cp)-1] == ':') - StrAllocCat(cp,"/"); +#ifdef DOSPATH /* sorry! */ + if (strncmp(cp, "file:///", 8) && strlen(cp) == 19 && + cp[strlen(cp)-1] == ':') + StrAllocCat(cp,"/"); #endif - if (compare_type(cp, "news:", 5)) { + if (!strncasecomp(cp, "news:", 5)) { + if (strncmp(cp, "news", 4)) { + for (i = 0; i < 4; i++) + cp[i] = TOLOWER(cp[i]); + } return(NEWS_URL_TYPE); - } else if (compare_type(cp, "nntp:", 5)) { + } else if (!strncasecomp(cp, "nntp:", 5)) { + if (strncmp(cp, "nntp", 4)) { + for (i = 0; i < 4; i++) + cp[i] = TOLOWER(cp[i]); + } return(NNTP_URL_TYPE); - } else if (compare_type(cp, "snews:", 6)) { + } else if (!strncasecomp(cp, "snews:", 6)) { + if (strncmp(cp, "snews", 5)) { + for (i = 0; i < 5; i++) + cp[i] = TOLOWER(cp[i]); + } return(SNEWS_URL_TYPE); - } else if (compare_type(cp, "newspost:", 9)) { + } else if (!strncasecomp(cp, "newspost:", 9)) { /* * Special Lynx type to handle news posts. */ + if (strncmp(cp, "newspost", 8)) { + for (i = 0; i < 8; i++) + cp[i] = TOLOWER(cp[i]); + } return(NEWSPOST_URL_TYPE); - } else if (compare_type(cp, "newsreply:", 10)) { + } else if (!strncasecomp(cp, "newsreply:", 10)) { /* * Special Lynx type to handle news replies (followups). */ + if (strncmp(cp, "newsreply", 9)) { + for (i = 0; i < 9; i++) + cp[i] = TOLOWER(cp[i]); + } return(NEWSREPLY_URL_TYPE); - } else if (compare_type(cp, "snewspost:", 10)) { + } else if (!strncasecomp(cp, "snewspost:", 10)) { /* * Special Lynx type to handle snews posts. */ + if (strncmp(cp, "snewspost", 9)) { + for (i = 0; i < 9; i++) + cp[i] = TOLOWER(cp[i]); + } return(NEWSPOST_URL_TYPE); - } else if (compare_type(cp, "snewsreply:", 11)) { + } else if (!strncasecomp(cp, "snewsreply:", 11)) { /* * Special Lynx type to handle snews replies (followups). */ + if (strncmp(cp, "snewsreply", 10)) { + for (i = 0; i < 10; i++) + cp[i] = TOLOWER(cp[i]); + } return(NEWSREPLY_URL_TYPE); - } else if (compare_type(cp, "mailto:", 7)) { + } else if (!strncasecomp(cp, "mailto:", 7)) { + if (strncmp(cp, "mailto", 6)) { + for (i = 0; i < 6; i++) + cp[i] = TOLOWER(cp[i]); + } return(MAILTO_URL_TYPE); - } else if (compare_type(cp, "file:", 5)) { + } else if (!strncasecomp(cp, "file:", 5)) { + if (strncmp(cp, "file", 4)) { + for (i = 0; i < 4; i++) + cp[i] = TOLOWER(cp[i]); + } if (LYisLocalFile(cp)) { return(FILE_URL_TYPE); - } else if (LYIsHtmlSep(cp[5]) && LYIsHtmlSep(cp[6])) { + } else if (cp[5] == '/' && cp[6] == '/') { return(FTP_URL_TYPE); } else { return(0); } - } else if (compare_type(cp, "data:", 5)) { + } else if (!strncasecomp(cp, "data:", 5)) { + if (strncmp(cp, "data", 4)) { + for (i = 0; i < 4; i++) + cp[i] = TOLOWER(cp[i]); + } return(DATA_URL_TYPE); - } else if (compare_type(cp, "lynxexec:", 9)) { + } else if (!strncasecomp(cp, "lynxexec:", 9)) { /* * Special External Lynx type to handle execution * of commands or scripts which require a pause to * read the screen upon completion. */ + if (strncmp(cp, "lynxexec", 8)) { + for (i = 0; i < 8; i++) + cp[i] = TOLOWER(cp[i]); + } return(LYNXEXEC_URL_TYPE); - } else if (compare_type(cp, "lynxprog:", 9)) { + } else if (!strncasecomp(cp, "lynxprog:", 9)) { /* * Special External Lynx type to handle execution - * of commands, scripts or programs with do not + * of commans, sriptis or programs with do not * require a pause to read screen upon completion. */ + if (strncmp(cp, "lynxprog", 8)) { + for (i = 0; i < 8; i++) + cp[i] = TOLOWER(cp[i]); + } return(LYNXPROG_URL_TYPE); - } else if (compare_type(cp, "lynxcgi:", 8)) { + } else if (!strncasecomp(cp, "lynxcgi:", 8)) { /* * Special External Lynx type to handle cgi scripts. */ + if (strncmp(cp, "lynxcgi", 7)) { + for (i = 0; i < 7; i++) + cp[i] = TOLOWER(cp[i]); + } return(LYNXCGI_URL_TYPE); - } else if (compare_type(cp, "LYNXPRINT:", 10)) { + } else if (!strncasecomp(cp, "LYNXPRINT:", 10)) { /* * Special Internal Lynx type. */ + if (strncmp(cp, "LYNXPRINT", 9)) { + for (i = 0; i < 9; i++) + cp[i] = TOUPPER(cp[i]); + } return(LYNXPRINT_URL_TYPE); - } else if (compare_type(cp, "LYNXOPTIONS:", 12)) { - /* - * Special Internal Lynx type. - */ - return(LYNXOPTIONS_URL_TYPE); - - } else if (compare_type(cp, "LYNXDOWNLOAD:", 13)) { + } else if (!strncasecomp(cp, "LYNXDOWNLOAD:", 13)) { /* * Special Internal Lynx type. */ + if (strncmp(cp, "LYDOWNLOAD", 12)) { + for (i = 0; i < 12; i++) + cp[i] = TOUPPER(cp[i]); + } return(LYNXDOWNLOAD_URL_TYPE); - } else if (compare_type(cp, "LYNXDIRED:", 10)) { + } else if (!strncasecomp(cp, "LYNXDIRED:", 10)) { /* * Special Internal Lynx type. */ + if (strncmp(cp, "LYNXDIRED", 9)) { + for (i = 0; i < 9; i++) + cp[i] = TOUPPER(cp[i]); + } return(LYNXDIRED_URL_TYPE); - } else if (compare_type(cp, "LYNXHIST:", 9)) { + } else if (!strncasecomp(cp, "LYNXHIST:", 9)) { /* * Special Internal Lynx type. */ + if (strncmp(cp, "LYNXHIST", 8)) { + for (i = 0; i < 8; i++) + cp[i] = TOUPPER(cp[i]); + } return(LYNXHIST_URL_TYPE); - } else if (compare_type(cp, "LYNXKEYMAP:", 11)) { + } else if (!strncasecomp(cp, "LYNXKEYMAP:", 11)) { /* * Special Internal Lynx type. */ + if (strncmp(cp, "LYNXKEYMAP", 10)) { + for (i = 0; i < 10; i++) + cp[i] = TOUPPER(cp[i]); + } return(LYNXKEYMAP_URL_TYPE); - } else if (compare_type(cp, "LYNXIMGMAP:", 11)) { + } else if (!strncasecomp(cp, "LYNXIMGMAP:", 11)) { /* * Special Internal Lynx type. */ + if (strncmp(cp, "LYNXIMGMAP", 10)) { + for (i = 0; i < 10; i++) + cp[i] = TOUPPER(cp[i]); + } (void)is_url(&cp[11]); return(LYNXIMGMAP_URL_TYPE); - } else if (compare_type(cp, "LYNXCOOKIE:", 11)) { + } else if (!strncasecomp(cp, "LYNXCOOKIE:", 11)) { /* * Special Internal Lynx type. */ + if (strncmp(cp, "LYNXCOOKIE", 10)) { + for (i = 0; i < 10; i++) + cp[i] = TOUPPER(cp[i]); + } return(LYNXCOOKIE_URL_TYPE); } else if (strstr((cp+3), "://") == NULL) { @@ -2597,13 +2630,25 @@ PUBLIC int is_url ARGS1( */ return(LYCheckForProxyURL(filename)); - } else if (compare_type(cp, "http:", 5)) { + } else if (!strncasecomp(cp, "http:", 5)) { + if (strncmp(cp, "http", 4)) { + for (i = 0; i < 4; i++) + cp[i] = TOLOWER(cp[i]); + } return(HTTP_URL_TYPE); - } else if (compare_type(cp, "https:", 6)) { + } else if (!strncasecomp(cp, "https:", 6)) { + if (strncmp(cp, "https", 5)) { + for (i = 0; i < 5; i++) + cp[i] = TOLOWER(cp[i]); + } return(HTTPS_URL_TYPE); - } else if (compare_type(cp, "gopher:", 7)) { + } else if (!strncasecomp(cp, "gopher:", 7)) { + if (strncmp(cp, "gopher", 6)) { + for (i = 0; i < 6; i++) + cp[i] = TOLOWER(cp[i]); + } if ((cp1 = strchr(cp+11,'/')) != NULL) { if (TOUPPER(*(cp1+1)) == 'H' || *(cp1+1) == 'w') @@ -2619,31 +2664,67 @@ PUBLIC int is_url ARGS1( return(GOPHER_URL_TYPE); } - } else if (compare_type(cp, "ftp:", 4)) { + } else if (!strncasecomp(cp, "ftp:", 4)) { + if (strncmp(cp, "ftp", 3)) { + for (i = 0; i < 3; i++) + cp[i] = TOLOWER(cp[i]); + } return(FTP_URL_TYPE); - } else if (compare_type(cp, "wais:", 5)) { + } else if (!strncasecomp(cp, "wais:", 5)) { + if (strncmp(cp, "wais", 4)) { + for (i = 0; i < 4; i++) + cp[i] = TOLOWER(cp[i]); + } return(WAIS_URL_TYPE); - } else if (compare_type(cp, "telnet:", 7)) { + } else if (!strncasecomp(cp, "telnet:", 7)) { + if (strncmp(cp, "telnet", 6)) { + for (i = 0; i < 6; i++) + cp[i] = TOLOWER(cp[i]); + } return(TELNET_URL_TYPE); - } else if (compare_type(cp, "tn3270:", 7)) { + } else if (!strncasecomp(cp, "tn3270:", 7)) { + if (strncmp(cp, "tn", 2)) { + for (i = 0; i < 2; i++) + cp[i] = TOLOWER(cp[i]); + } return(TN3270_URL_TYPE); - } else if (compare_type(cp, "rlogin:", 7)) { + } else if (!strncasecomp(cp, "rlogin:", 7)) { + if (strncmp(cp, "rlogin", 6)) { + for (i = 0; i < 6; i++) + cp[i] = TOLOWER(cp[i]); + } return(RLOGIN_URL_TYPE); - } else if (compare_type(cp, "cso:", 4)) { + } else if (!strncasecomp(cp, "cso:", 4)) { + if (strncmp(cp, "cso", 3)) { + for (i = 0; i < 3; i++) + cp[i] = TOLOWER(cp[i]); + } return(CSO_URL_TYPE); - } else if (compare_type(cp, "finger:", 7)) { + } else if (!strncasecomp(cp, "finger:", 7)) { + if (strncmp(cp, "finger", 6)) { + for (i = 0; i < 6; i++) + cp[i] = TOLOWER(cp[i]); + } return(FINGER_URL_TYPE); - } else if (compare_type(cp, "afs:", 4)) { + } else if (!strncasecomp(cp, "afs:", 4)) { + if (strncmp(cp, "afs", 3)) { + for (i = 0; i < 3; i++) + cp[i] = TOLOWER(cp[i]); + } return(AFS_URL_TYPE); - } else if (compare_type(cp, "prospero:", 9)) { + } else if (!strncasecomp(cp, "prospero:", 9)) { + if (strncmp(cp, "prospero", 8)) { + for (i = 0; i < 8; i++) + cp[i] = TOLOWER(cp[i]); + } return(PROSPERO_URL_TYPE); } else { @@ -2729,7 +2810,6 @@ PUBLIC void remove_backslashes ARGS1( */ PUBLIC char * quote_pathname ARGS1( char *, pathname) -#ifndef __DJGPP__ { size_t i, n = 0; char * result; @@ -2741,9 +2821,8 @@ PUBLIC char * quote_pathname ARGS1( if (result == NULL) outofmem(__FILE__, "quote_pathname"); - n = 0; - result[n++] = '\''; - for (i = 0; i < strlen(pathname); i++) { + result[0] = '\''; + for (i = 0, n = 1; i < strlen(pathname); i++) if (pathname[i] == '\'') { result[n++] = '\''; result[n++] = '"'; @@ -2753,16 +2832,10 @@ PUBLIC char * quote_pathname ARGS1( } else { result[n++] = pathname[i]; } - } result[n++] = '\''; result[n] = '\0'; return result; } -#else -{ - return pathname; -} -#endif /* !__DJGPP__ */ #if HAVE_UTMP extern char *ttyname PARAMS((int fd)); @@ -2805,7 +2878,8 @@ PUBLIC BOOLEAN inlocaldomain NOARGS #endif /* LINUX */ } else { - CTRACE(tfp,"Could not get ttyname or open UTMP file"); + if (TRACE) + fprintf(stderr,"Could not get ttyname or open UTMP file"); } return(FALSE); @@ -2820,21 +2894,18 @@ PUBLIC BOOLEAN inlocaldomain NOARGS #include <sys/ioctl.h> #endif -/* For systems that have both, but both can't be included, duh (or neither) */ -/* FIXME: this whole chunk may be redundant */ -#ifdef TERMIO_AND_CURSES -# ifdef TERMIO_AND_TERMIOS -# include <termio.h> +/* For systems that have both, but both can't be included, duh */ +#ifdef TERMIO_AND_TERMIOS +# include <termio.h> +#else +# ifdef HAVE_TERMIOS_H +# include <termios.h> # else -# ifdef HAVE_TERMIOS_H -# include <termios.h> -# else -# ifdef HAVE_TERMIO_H -# include <termio.h> -# endif /* HAVE_TERMIO_H */ -# endif /* HAVE_TERMIOS_H */ -# endif /* TERMIO_AND_TERMIOS */ -#endif /* TERMIO_AND_CURSES */ +# ifdef HAVE_TERMIO_H +# include <termio.h> +# endif /* HAVE_TERMIO_H */ +# endif /* HAVE_TERMIOS_H */ +#endif /* TERMIO_AND_TERMIOS */ PUBLIC void size_change ARGS1( int, sig GCC_UNUSED) @@ -2843,9 +2914,7 @@ PUBLIC void size_change ARGS1( int old_cols = LYcols; #ifdef USE_SLANG -#if defined(VMS) || defined(UNIX) SLtt_get_screen_size(); -#endif /* VMS || UNIX */ LYlines = SLtt_Screen_Rows; LYcols = SLtt_Screen_Cols; #ifdef SLANG_MBCS_HACK @@ -2901,7 +2970,10 @@ PUBLIC void size_change ARGS1( */ if (LYlines != old_lines || LYcols != old_cols) { recent_sizechange = TRUE; - CTRACE(tfp, "Window size changed from (%d,%d) to (%d,%d)\n", + } + if (TRACE) { + fprintf(stderr, + "Window size changed from (%d,%d) to (%d,%d)\n", old_lines, old_cols, LYlines, LYcols); } #ifdef SIGWINCH @@ -2932,7 +3004,7 @@ PUBLIC void HTSugFilenames_free NOARGS /* * Utility for listing suggested filenames, making any - * repeated filenames the most current in the list. - FM + * repeated filenanmes the most current in the list. - FM */ PUBLIC void HTAddSugFilename ARGS1( char *, fname) @@ -2995,8 +3067,12 @@ PUBLIC void change_sug_filename ARGS1( * Rename any temporary files. */ temp = (char *)calloc(1, (strlen(lynx_temp_space) + 60)); - cp = wwwName(lynx_temp_space); - if (LYIsHtmlSep(*cp)) { +#if defined(FNAMES_8_3) && defined(DOSPATH) + cp = HTDOS_wwwName(lynx_temp_space); +#else + cp = lynx_temp_space; +#endif + if (*cp == '/') { sprintf(temp, "file://localhost%s%d", cp, (int)getpid()); } else { sprintf(temp, "file://localhost/%s%d", cp, (int)getpid()); @@ -3011,14 +3087,6 @@ PUBLIC void change_sug_filename ARGS1( } FREE(temp); - if (fname[strlen(fname) - 1] == '/') - /* - * Hmm... we have a directory name. - * It is annoying to see a scheme+host+path name as a suggested one, - * let's remove the last_slash and go ahead like we have a file name. - LP - */ - fname[strlen(fname) - 1] = '\0'; - /* * Remove everything up the the last_slash if there is one. */ @@ -3114,7 +3182,7 @@ PUBLIC void change_sug_filename ARGS1( /* * Trim any trailing or leading - * underscores or dashes. + * underscrores or dashes. */ cp = fname + (strlen(fname)) - 1; while (*cp == '_' || *cp == '-') { @@ -3210,7 +3278,7 @@ PUBLIC void change_sug_filename ARGS1( /* * No period, so put one on the end, or after * the 39th character, trimming trailing dashes - * or underscores. + * or underscrores. */ if (strlen(fname) > 39) { fname[39] = '\0'; @@ -3251,45 +3319,143 @@ PUBLIC void change_sug_filename ARGS1( } /* - * Construct a temporary-filename + * To create standard temporary file names. */ -PRIVATE char *fmt_tempname ARGS3( - char *, result, - CONST char *, prefix, - CONST char *, suffix) +PUBLIC void tempname ARGS2( + char *, namebuffer, + int, action) { - static unsigned counter; - char *leaf; - - if (prefix == 0) - prefix = ""; - if (suffix == 0) - suffix = ""; - strcpy(result, prefix); - leaf = result + strlen(result); - counter++; + static int counter = 0; + FILE *fp = NULL; +#ifdef FNAMES_8_3 + int LYMaxTempCount = 1000; /* Arbitrary limit. Make it configurable? */ +#else + int LYMaxTempCount = 10000; /* Arbitrary limit. Make it configurable? */ +#endif /* FNAMES_8_3 */ + + if (action == REMOVE_FILES) { + /* + * Remove all temporary files with .txt or .html suffixes. - FM + */ + for (; counter > 0; counter--) { +#ifdef FNAMES_8_3 + sprintf(namebuffer, + "%s%d%u.txt", + lynx_temp_space, (int)getpid(), counter-1); + remove(namebuffer); + sprintf(namebuffer, + "%s%d%u%s", + lynx_temp_space, (int)getpid(), counter-1, HTML_SUFFIX); + remove(namebuffer); +#else + sprintf(namebuffer, + "%sL%d-%uTMP.txt", + lynx_temp_space, (int)getpid(), counter-1); + remove(namebuffer); + sprintf(namebuffer, + "%sL%d-%uTMP%s", + lynx_temp_space, (int)getpid(), counter-1, HTML_SUFFIX); + remove(namebuffer); +#endif /* FNAMES_8_3 */ + } + } else { + /* + * Load a tentative temporary file name into namebuffer. - FM + */ + while (counter < LYMaxTempCount) { + /* + * Create names with .txt, then .bin, then + * .html suffixes, and check for their prior + * existence. If any already exist, someone + * might be trying to spoof us, so increment + * the count and try again. Otherwise, return + * with the name which has the .html suffix + * loaded in namebuffer. - FM + * + * Some systems may use .htm instead of .html. This + * should be done consistently by always using HTML_SUFFIX + * where filenames are generated for new local files. - kw + */ +#ifdef FNAMES_8_3 + sprintf(namebuffer, + "%s%d%u.txt", + lynx_temp_space, (int)getpid(), counter); +#else + sprintf(namebuffer, + "%sL%d-%uTMP.txt", + lynx_temp_space, (int)getpid(), counter); +#endif /* FNAMES_8_3 */ + if ((fp = fopen(namebuffer, "r")) != NULL) { + fclose(fp); + if (TRACE) + fprintf(stderr, + "tempname: file '%s' already exists!\n", + namebuffer); + counter++; + continue; + } +#ifdef FNAMES_8_3 + sprintf(namebuffer, + "%s%d%u.bin", + lynx_temp_space, (int)getpid(), counter); +#else + sprintf(namebuffer, + "%sL%d-%uTMP.bin", + lynx_temp_space, (int)getpid(), counter); +#endif /* FNAMES_8_3 */ + if ((fp = fopen(namebuffer, "r")) != NULL) { + fclose(fp); + if (TRACE) + fprintf(stderr, + "tempname: file '%s' already exists!\n", + namebuffer); + counter++; + continue; + } #ifdef FNAMES_8_3 + sprintf(namebuffer, + "%s%d%u%s", + lynx_temp_space, (int)getpid(), counter++, HTML_SUFFIX); +#else + sprintf(namebuffer, + "%sL%d-%uTMP%s", + lynx_temp_space, (int)getpid(), counter++, HTML_SUFFIX); +#endif /* FNAMES_8_3 */ + if ((fp = fopen(namebuffer, "r")) != NULL) { + fclose(fp); + if (TRACE) + fprintf(stderr, + "tempname: file '%s' already exists!\n", + namebuffer); + continue; + } + /* + * Return to the calling function, with the tentative + * temporary file name loaded in namebuffer. Note that + * if the calling function will use a suffix other than + * .txt, .bin, or .html, it similarly should do tests for + * a spoof. The file name can be reused if it is written + * to on receipt of this name, and thereafter accessed + * for reading. Note that if writing to a file is to + * be followed by reading it, as it the usual case for + * Lynx, the spoof attempt will be apparent, and the user + * can take appropriate action. - FM + */ + return; + } + /* + * The tempfile maximum count has been reached. + * Issue a message and exit. - FM + */ + _statusline(MAX_TEMPCOUNT_REACHED); + sleep(AlertSecs); + exit(-1); + } + /* - * The 'lynx_temp_space' string ends with a '/' or '\\', so we only have to - * limit the length of the leaf. As received (e.g., from HTCompressed), - * the suffix may contain more than a ".htm", e.g., "-txt.gz", so we trim - * off from the filename portion to make room. + * We were called for a clean up, and have done it. - FM */ - sprintf(leaf, "%u%u", counter, (unsigned)getpid()); - if (strlen(leaf) > 8) - leaf[8] = 0; - if (strlen(suffix) > 4 || *suffix != '.') { - CONST char *tail = strchr(suffix, '.'); - if (tail == 0) - tail = suffix + strlen(suffix); - leaf[8 - (tail - suffix)] = 0; - } - strcat(leaf, suffix); -#else - sprintf(leaf, "L%u-%uTMP%s", (unsigned)getpid(), counter, suffix); -#endif - CTRACE(tfp, "-> '%s'\n", result); - return result; + return; } /* @@ -3300,7 +3466,7 @@ PUBLIC int number2arrows ARGS1( { switch(number) { case '1': - number=END_KEY; + number=END; break; case '2': number=DNARROW; @@ -3335,7 +3501,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 CONST char *restrict_name[] = { +PRIVATE char *restrict_name[] = { "inside_telnet" , "outside_telnet", "telnet_port" , @@ -3422,10 +3588,10 @@ PRIVATE BOOLEAN *restrict_flag[] = { (BOOLEAN *) 0 }; PUBLIC void parse_restrictions ARGS1( - CONST char *, s) + char *, s) { - CONST char *p; - CONST char *word; + char *p; + char *word; int i; if (STREQ("all", s)) { @@ -3480,21 +3646,21 @@ PUBLIC void parse_restrictions ARGS1( p = s; while (*p) { - p = LYSkipCBlanks(p); + while (isspace((unsigned char)*p)) + p++; if (*p == '\0') break; word = p; while (*p != ',' && *p != '\0') p++; + if (*p) + *p++ = '\0'; - for (i=0; restrict_name[i]; i++) { - if (STRNEQ(word, restrict_name[i], p-word)) { + for (i=0; restrict_name[i]; i++) + if (STREQ(word, restrict_name[i])) { *restrict_flag[i] = TRUE; break; } - } - if (*p) - p++; } return; } @@ -3512,7 +3678,7 @@ typedef struct _VMSMailItemList long *return_length_address; } VMSMailItemList; -PUBLIC void LYCheckMail NOARGS +PUBLIC int LYCheckMail NOARGS { static BOOL firsttime = TRUE, failure = FALSE; static char user[13], dir[252]; @@ -3536,7 +3702,7 @@ PUBLIC void LYCheckMail NOARGS extern long mail$user_end(); if (failure) - return; + return 0; if (firsttime) { firsttime = FALSE; @@ -3544,51 +3710,56 @@ PUBLIC void LYCheckMail NOARGS status = sys$getjpiw(0,0,0,jpi_list,0,0,0); if (!(status & 1)) { failure = TRUE; - return; + return 0; } user[userlen] = '\0'; - LYTrimTrailing(user); + while (user[0] && + /* + * Suck up trailing spaces. + */ + isspace((unsigned char)user[--userlen])) + user[userlen] = '\0'; } /* Minimum report interval is 60 sec. */ time(&now); if (now - lastcheck < 60) - return; + return 0; lastcheck = now; /* Get the current newmail count. */ status = mail$user_begin(&ucontext,null_list,null_list); if (!(status & 1)) { failure = TRUE; - return; + return 0; } uilist[0].buffer_length = strlen(user); uilist[0].buffer_address = user; status = mail$user_get_info(&ucontext,uilist,uolist); if (!(status & 1)) { failure = TRUE; - return; + return 0; } /* Should we report anything to the user? */ if (new > 0) { if (lastcount == 0) /* Have newmail at startup of Lynx. */ - HTUserMsg(HAVE_UNREAD_MAIL_MSG); + _statusline(HAVE_UNREAD_MAIL_MSG); else if (new > lastcount) /* Have additional mail since last report. */ - HTUserMsg(HAVE_NEW_MAIL_MSG); + _statusline(HAVE_NEW_MAIL_MSG); lastcount = new; - return; + return 1; } lastcount = new; /* Clear the context */ mail$user_end((long *)&ucontext,null_list,null_list); - return; + return 0; } #else -PUBLIC void LYCheckMail NOARGS +PUBLIC int LYCheckMail NOARGS { static BOOL firsttime = TRUE; static char *mf; @@ -3603,29 +3774,29 @@ PUBLIC void LYCheckMail NOARGS } if (mf == NULL) - return; + return 0; time(&now); if (now - lastcheck < 60) - return; + return 0; lastcheck = now; if (stat(mf,&st) < 0) { mf = NULL; - return; + return 0; } if (st.st_size > 0) { if (st.st_mtime > st.st_atime || (lastsize && st.st_size > lastsize)) - HTUserMsg(HAVE_NEW_MAIL_MSG); + _statusline(HAVE_NEW_MAIL_MSG); else if (lastsize == 0) - HTUserMsg(HAVE_MAIL_MSG); + _statusline(HAVE_MAIL_MSG); lastsize = st.st_size; - return; + return 1; } lastsize = st.st_size; - return; + return 0; } #endif /* VMS */ @@ -3641,7 +3812,7 @@ PUBLIC void LYCheckMail NOARGS */ PUBLIC void LYEnsureAbsoluteURL ARGS2( char **, href, - CONST char *, name) + char *, name) { char *temp = NULL; @@ -3658,7 +3829,8 @@ PUBLIC void LYEnsureAbsoluteURL ARGS2( StrAllocCat(*href, "/*"); } if (!is_url(*href)) { - CTRACE(tfp, "%s%s'%s' is not a URL\n", + if (TRACE) + fprintf(stderr, "%s%s'%s' is not a URL\n", (name ? name : ""), (name ? " " : ""), *href); LYConvertToURL(href); } @@ -3687,7 +3859,7 @@ PUBLIC void LYConvertToURL ARGS1( if (!old_string || *old_string == '\0') return; -#if defined(DOSPATH) || defined(__EMX__) +#ifdef DOSPATH { char *cp_url = *AllocatedString; for(; *cp_url != '\0'; cp_url++) @@ -3695,6 +3867,10 @@ PUBLIC void LYConvertToURL ARGS1( cp_url--; if(*cp_url == ':') StrAllocCat(*AllocatedString,"/"); +#ifdef NOTDEFINED + if(strlen(old_string) > 3 && *cp_url == '/') + *cp_url = '\0'; +#endif } #endif /* DOSPATH */ @@ -3703,7 +3879,7 @@ PUBLIC void LYConvertToURL ARGS1( if (*old_string != '/') { char *fragment = NULL; -#if defined(DOSPATH) || defined(__EMX__) +#ifdef DOSPATH StrAllocCat(*AllocatedString,"/"); #endif /* DOSPATH */ #ifdef VMS @@ -3748,7 +3924,9 @@ PUBLIC void LYConvertToURL ARGS1( if ((cp = strchr(file_name, ';')) != NULL) { *cp = '\0'; } - LYLowerCase(file_name); + for (cp = file_name; *cp; cp++) { + *cp = TOLOWER(*cp); + } StrAllocCat(*AllocatedString, HTVMS_wwwName(file_name)); if ((cp = strchr(old_string, ';')) != NULL) { StrAllocCat(*AllocatedString, cp); @@ -3771,7 +3949,9 @@ PUBLIC void LYConvertToURL ARGS1( /* * Yup, we got it! */ - LYLowerCase(dir_name); + for (cp = dir_name; *cp; cp++) { + *cp = TOLOWER(*cp); + } StrAllocCat(*AllocatedString, dir_name); if (fragment != NULL) { StrAllocCat(*AllocatedString, fragment); @@ -3797,8 +3977,11 @@ PUBLIC void LYConvertToURL ARGS1( */ strcpy(url_file, "/"); strcat(url_file, old_string); - CTRACE(tfp, "Can't find '%s' Will assume it's a bad path.\n", + if (TRACE) { + fprintf(stderr, + "Can't find '%s' Will assume it's a bad path.\n", old_string); + } StrAllocCat(*AllocatedString, url_file); } else { /* @@ -3836,8 +4019,11 @@ PUBLIC void LYConvertToURL ARGS1( */ strcpy(url_file, "/"); strcat(url_file, old_string); - CTRACE(tfp, "Can't find '%s' Will assume it's a bad path.\n", - old_string); + if (TRACE) { + fprintf(stderr, + "Can't find '%s' Will assume it's a bad path.\n", + old_string); + } StrAllocCat(*AllocatedString, url_file); } else { /* @@ -3855,7 +4041,9 @@ PUBLIC void LYConvertToURL ARGS1( lib$find_file_end(&context); FREE(cur_dir); have_VMS_URL: - CTRACE(tfp, "Trying: '%s'\n", *AllocatedString); + if (TRACE) { + fprintf(stderr, "Trying: '%s'\n", *AllocatedString); + } #else /* Unix: */ #ifdef DOSPATH if (strlen(old_string) == 1 && *old_string == '.') { @@ -3864,11 +4052,13 @@ have_VMS_URL: */ char curdir[DIRNAMESIZE]; getcwd (curdir, DIRNAMESIZE); - StrAllocCopy(temp, wwwName(curdir)); + StrAllocCopy(temp, HTDOS_wwwName(curdir)); StrAllocCat(*AllocatedString, temp); FREE(temp); - CTRACE(tfp, "Converted '%s' to '%s'\n", - old_string, *AllocatedString); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", + old_string, *AllocatedString); + } } else #endif /* DOSPATH */ if (*old_string == '~') { @@ -3887,8 +4077,10 @@ have_VMS_URL: StrAllocCat(*AllocatedString, temp); FREE(temp); } - CTRACE(tfp, "Converted '%s' to '%s'\n", - old_string, *AllocatedString); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", + old_string, *AllocatedString); + } } else { /* * Create a full path to the current default directory. @@ -3905,29 +4097,32 @@ have_VMS_URL: * Concatenate and simplify, trimming any * residual relative elements. - FM */ -#if defined (DOSPATH) || defined (__EMX__) +#ifndef DOSPATH + StrAllocCopy(temp, curdir); + StrAllocCat(temp, "/"); + StrAllocCat(temp, old_string); +#else if (old_string[1] != ':' && old_string[1] != '|') { - StrAllocCopy(temp, wwwName(curdir)); - LYAddHtmlSep(&temp); + StrAllocCopy(temp, HTDOS_wwwName(curdir)); + if(curdir[strlen(curdir)-1] != '/') + StrAllocCat(temp, "/"); LYstrncpy(curdir, temp, (DIRNAMESIZE - 1)); StrAllocCat(temp, old_string); } else { curdir[0] = '\0'; StrAllocCopy(temp, old_string); } -#else - StrAllocCopy(temp, curdir); - StrAllocCat(temp, "/"); - StrAllocCat(temp, old_string); #endif /* DOSPATH */ LYTrimRelFromAbsPath(temp); - CTRACE(tfp, "Converted '%s' to '%s'\n", old_string, temp); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", old_string, temp); + } if ((stat(temp, &st) > -1) || (fptemp = fopen(temp, "r")) != NULL) { /* * It is a subdirectory or file on the local system. */ -#if defined (DOSPATH) || defined (__EMX__) +#ifdef DOSPATH /* Don't want to see DOS local paths like c: escaped */ /* especially when we really have file://localhost/ */ /* at the beginning. To avoid any confusion we allow */ @@ -3940,13 +4135,16 @@ have_VMS_URL: cp = HTEscape(temp, URL_PATH); StrAllocCat(*AllocatedString, cp); FREE(cp); - CTRACE(tfp, "Converted '%s' to '%s'\n", - old_string, *AllocatedString); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", + old_string, *AllocatedString); + } is_local = TRUE; } else { char *cp2 = NULL; StrAllocCopy(temp2, curdir); - LYAddPathSep(&temp2); + if (curdir[0] != '\0' && curdir[strlen(curdir)-1] != '/') + StrAllocCat(temp2, "/"); StrAllocCopy(cp, old_string); if ((fragment = strchr(cp, '#')) != NULL) *fragment = '\0'; /* keep as pointer into cp string */ @@ -3971,7 +4169,8 @@ have_VMS_URL: * old_string as given. - kw */ temp = HTEscape(curdir, URL_PATH); - LYAddHtmlSep(&temp); + if (curdir[0] != '\0' && curdir[strlen(curdir)-1] != '/') + StrAllocCat(temp, "/"); StrAllocCat(temp, old_string); } else { temp = HTEscape(temp2, URL_PATH); @@ -3981,8 +4180,10 @@ have_VMS_URL: } } StrAllocCat(*AllocatedString, temp); - CTRACE(tfp, "Converted '%s' to '%s'\n", - old_string, *AllocatedString); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", + old_string, *AllocatedString); + } is_local = TRUE; } else if (strchr(curdir, '#') != NULL || @@ -4001,7 +4202,8 @@ have_VMS_URL: * old_string as given. - kw */ temp = HTEscape(curdir, URL_PATH); - LYAddHtmlSep(&temp); + if (curdir[0] != '\0' && curdir[strlen(curdir)-1] != '/') + StrAllocCat(temp, "/"); StrAllocCat(temp, old_string); } else { temp = HTEscape(temp2, URL_PATH); @@ -4020,8 +4222,10 @@ have_VMS_URL: * local system, so assume it's a URL request and guess * the scheme with "http://" as the default. */ - CTRACE(tfp, "Can't stat() or fopen() '%s'\n", + if (TRACE) { + fprintf(stderr, "Can't stat() or fopen() '%s'\n", temp2 ? temp2 : temp); + } if (LYExpandHostForURL((char **)&old_string, URLDomainPrefixes, URLDomainSuffixes)) { @@ -4032,10 +4236,12 @@ have_VMS_URL: StrAllocCopy(*AllocatedString, old_string); } } else { - /* RW 1998Mar16 Restore AllocatedString to 'old_string' */ - StrAllocCopy(*AllocatedString, old_string); + /* RW 1998Mar16 Restore AllocatedString to 'old_string' */ + StrAllocCopy(*AllocatedString, old_string); + } + if (TRACE) { + fprintf(stderr, "Trying: '%s'\n", *AllocatedString); } - CTRACE(tfp, "Trying: '%s'\n", *AllocatedString); } FREE(temp); FREE(temp2); @@ -4067,7 +4273,9 @@ have_VMS_URL: */ StrAllocCopy(temp, old_string); LYTrimRelFromAbsPath(temp); - CTRACE(tfp, "Converted '%s' to '%s'\n", old_string, temp); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", old_string, temp); + } cp = HTEscape(temp, URL_PATH); StrAllocCat(*AllocatedString, cp); FREE(cp); @@ -4076,8 +4284,10 @@ have_VMS_URL: fclose(fptemp); fptemp = NULL; } - CTRACE(tfp, "Converted '%s' to '%s'\n", + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", old_string, *AllocatedString); + } #endif /* VMS */ } else if (old_string[1] == '~') { /* @@ -4110,12 +4320,17 @@ have_VMS_URL: StrAllocCat(*AllocatedString, temp); FREE(temp); } - CTRACE(tfp, "Converted '%s' to '%s'\n", - old_string, *AllocatedString); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", + old_string, *AllocatedString); + } } FREE(old_string); - /* Pause so we can read the messages before invoking curses */ - CTRACE_SLEEP(AlertSecs); + if (TRACE) { + /* Pause so we can read the messages before invoking curses */ + if (!LYTraceLogFP) + sleep(AlertSecs); + } } /* @@ -4124,7 +4339,7 @@ have_VMS_URL: * and returns TRUE, otherwise it does not modify the string and * returns FALSE. It first tries the element as is, then, if the * element does not end with a dot, it adds prefixes from the - * (comma separated) prefix list argument, and, if the element + * (comma separated) prefix list arguement, and, if the element * does not begin with a dot, suffixes from the (comma separated) * suffix list arguments (e.g., www.host.com, then www.host,edu, * then www.host.net, then www.host.org). The remaining path, if @@ -4147,8 +4362,7 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( char *Host = NULL, *HostColon = NULL, *host = NULL; char *Path = NULL; char *Fragment = NULL; - int hoststat; - SockA sock; + struct hostent *phost; BOOLEAN GotHost = FALSE; BOOLEAN Startup = (helpfilepath == NULL); @@ -4223,8 +4437,7 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( fprintf(stdout, "Looking up '%s' first.\n", host); } #ifndef DJGPP - sock.sin_port = htons(80); - if ((hoststat = HTParseInet(&sock, host)) == 0) + if ((phost = gethostbyname(host)) != NULL) #else if (resolve(host) != 0) #endif /* DJGPP */ @@ -4233,8 +4446,11 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( * Clear any residual interrupt. - FM */ if (LYCursesON && HTCheckForInterrupt()) { - CTRACE(tfp, "LYExpandHostForURL: Ignoring interrupt because '%s' resolved.\n", + if (TRACE) { + fprintf(stderr, + "LYExpandHostForURL: Ignoring interrupt because '%s' resolved.\n", host); + } } /* @@ -4245,16 +4461,15 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( FREE(Str); FREE(MsgStr); return GotHost; -#ifndef DJGPP - } else if (LYCursesON && ((hoststat == HT_INTERRUPTED) || HTCheckForInterrupt())) { -#else /* DJGPP */ } else if (LYCursesON && HTCheckForInterrupt()) { -#endif /* DJGPP */ /* * Give the user chance to interrupt lookup cycles. - KW & FM */ - CTRACE(tfp, "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n", + if (TRACE) { + fprintf(stderr, + "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n", host); + } /* * Return failure. - FM @@ -4345,8 +4560,7 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( fprintf(stdout, "Looking up '%s', guessing...\n", host); } #ifndef DJGPP - sock.sin_port = htons(80); - GotHost = ((hoststat = HTParseInet(&sock, host)) == 0); + GotHost = ((phost = gethostbyname(host)) != NULL); #else GotHost = (resolve(host) != 0); #endif /* DJGPP */ @@ -4357,14 +4571,12 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( /* * Give the user chance to interrupt lookup cycles. - KW */ -#ifndef DJGPP - if (LYCursesON && ((hoststat == HT_INTERRUPTED) || HTCheckForInterrupt())) -#else /* DJGPP */ - if (LYCursesON && HTCheckForInterrupt()) -#endif /* DJGPP */ - { - CTRACE(tfp, "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n", + if (LYCursesON && HTCheckForInterrupt()) { + if (TRACE) { + fprintf(stderr, + "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n", host); + } FREE(Str); FREE(MsgStr); FREE(Host); @@ -4429,9 +4641,12 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3( * Clear any residual interrupt. - FM */ if (LYCursesON && HTCheckForInterrupt()) { - CTRACE(tfp, "LYExpandHostForURL: Ignoring interrupt because '%s' %s.\n", + if (TRACE) { + fprintf(stderr, + "LYExpandHostForURL: Ignoring interrupt because '%s' %s.\n", host, (GotHost ? "resolved" : "timed out")); + } } /* @@ -4568,13 +4783,13 @@ PUBLIC void LYTrimRelFromAbsPath ARGS1( /* * Make sure we have a pointer to an absolute path. - FM */ - if (path == NULL || !LYIsPathSep(*path)) + if (path == NULL || *path != '/') return; /* * Check whether the path has a terminal slash. - FM */ - TerminalSlash = LYIsPathSep(path[(strlen(path) - 1)]); + TerminalSlash = (path[(strlen(path) - 1)] == '/'); /* * Simplify the path and then do any necessary trimming. - FM @@ -4587,7 +4802,7 @@ PUBLIC void LYTrimRelFromAbsPath ARGS1( * Eliminate trailing dot. - FM */ cp[1] = '\0'; - } else if (LYIsPathSep(cp[2])) { + } else if (cp[2] == '/') { /* * Skip over the "/." of a "/./". - FM */ @@ -4620,8 +4835,9 @@ PUBLIC void LYTrimRelFromAbsPath ARGS1( path[i] = cp[i]; path[i] = '\0'; } - if (TerminalSlash == FALSE) { - LYTrimPathSep(path); + if (TerminalSlash == FALSE && + path[(strlen(path) - 1)] == '/') { + path[(strlen(path) - 1)] = '\0'; } } @@ -4700,7 +4916,7 @@ PUBLIC CONST char * Home_Dir NOARGS if (homedir == NULL) { if ((cp = getenv("HOME")) == NULL || *cp == '\0') { -#if defined (DOSPATH) || defined (__EMX__) /* BAD! WSB */ +#ifdef DOSPATH /* BAD! WSB */ if ((cp = getenv("TEMP")) == NULL || *cp == '\0') { if ((cp = getenv("TMP")) == NULL || *cp == '\0') { StrAllocCopy(HomeDir, "C:\\"); @@ -4750,42 +4966,11 @@ PUBLIC CONST char * Home_Dir NOARGS } /* - * Return a pointer to the final leaf of the given pathname, If no pathname - * separators are found, returns the original pathname. The leaf may be - * empty. - */ -PUBLIC char *LYPathLeaf ARGS1(char *, pathname) -{ - char *leaf; -#ifdef UNIX - if ((leaf = strrchr(pathname, '/')) != 0) { - leaf++; - } -#else -#ifdef VMS - if ((leaf = strrchr(pathname, ']')) == 0) - leaf = strrchr(pathname, ':'); - if (leaf != 0) - leaf++; -#else - int n; - for (leaf = 0, n = strlen(pathname)-1; n >= 0; n--) { - if (strchr("\\/:", pathname[n]) != 0) { - leaf = pathname + n; - break; - } - } -#endif -#endif - return (leaf != 0) ? leaf : pathname; -} - -/* * This function checks the acceptability of file paths that * are intended to be off the home directory. The file path * should be passed in fbuffer, together with the size of the * buffer. The function simplifies the file path, and if it - * is acceptable, loads it into fbuffer and returns TRUE. + * is acceptible, loads it into fbuffer and returns TRUE. * Otherwise, it does not modify fbuffer and returns FALSE. * If a subdirectory is present and the path does not begin * with "./", that is prefixed to make the situation clear. - FM @@ -4903,7 +5088,7 @@ PUBLIC BOOLEAN LYPathOffHomeOK ARGS2( /* * Check for a URL or absolute path, and reject if present. - FM */ - if (is_url(cp) || LYIsPathSep(*cp)) { + if (is_url(cp) || *cp == '/') { FREE(file); return(FALSE); } @@ -4925,11 +5110,8 @@ PUBLIC BOOLEAN LYPathOffHomeOK ARGS2( /* * Check for spoofing. - FM */ - if (*cp == '\0' - || LYIsPathSep(*cp) - || LYIsPathSep(cp[(strlen(cp) - 1)]) - || strstr(cp, "..") != NULL - || !strcmp(cp, ".")) { + if (*cp == '\0' || *cp == '/' || cp[(strlen(cp) - 1)] == '/' || + strstr(cp, "..") != NULL || !strcmp(cp, ".")) { FREE(file); return(FALSE); } @@ -5091,11 +5273,12 @@ PUBLIC time_t LYmktime ARGS2( if (!(string && *string)) return(0); s = string; - CTRACE(tfp, "LYmktime: Parsing '%s'\n", s); + if (TRACE) + fprintf(stderr, "LYmktime: Parsing '%s'\n", s); /* * Skip any lead alphabetic "Day, " field and - * seek a numeric day field. - FM + * seek a numberic day field. - FM */ while (*s != '\0' && !isdigit((unsigned char)*s)) s++; @@ -5307,10 +5490,9 @@ PUBLIC time_t LYmktime ARGS2( seconds); if (absolute == FALSE && clock2 <= time(NULL)) clock2 = (time_t)0; - if (clock2 > 0) - CTRACE(tfp, "LYmktime: clock=%ld, ctime=%s", - (long) clock2, - ctime(&clock2)); + if (TRACE && clock2 > 0) + fprintf(stderr, + "LYmktime: clock=%ld, ctime=%s", (long) clock2, ctime(&clock2)); return(clock2); } @@ -5338,8 +5520,20 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <sys/types.h> +#include <errno.h> +#ifdef STDC_HEADERS +#include <stdlib.h> +#else +extern int errno; +#endif /* STDC_HEADERS */ + #if defined(STDC_HEADERS) || defined(USG) #include <string.h> +#ifdef NOTDEFINED +#define index strchr +#define bcopy(s, d, n) memcpy((d), (s), (n)) +#endif /* NOTDEFINED */ #else /* Not (STDC_HEADERS or USG): */ #include <strings.h> #endif /* STDC_HEADERS or USG */ @@ -5418,111 +5612,18 @@ int remove ARGS1(char *, name) #ifdef UNIX /* - * Verify if this is really a file, not accessed by a link, except for the - * special case of its directory being pointed to by a link from a directory - * owned by root and not writable by other users. - */ -PRIVATE BOOL IsOurFile ARGS1(char *, name) -{ - struct stat data; - - if (lstat(name, &data) == 0 - && S_ISREG(data.st_mode) - && data.st_nlink == 1 - && data.st_uid == getuid()) { - int linked = FALSE; -#if HAVE_LSTAT - char *path = 0; - char *leaf; - - StrAllocCopy(path, name); - do { - if ((leaf = LYPathLeaf(path)) != path) - *--leaf = '\0'; /* write a null on the '/' */ - if (lstat(*path ? path : "/", &data) != 0) { - break; - } - /* - * If we find a symbolic link, it has to be in a directory that's - * protected. Otherwise someone could have switched it to point - * to one of the real user's files. - */ - if (S_ISLNK(data.st_mode)) { - linked = TRUE; /* could be link-to-link; doesn't matter */ - } else if (S_ISDIR(data.st_mode)) { - if (linked) { - linked = FALSE; - /* - * We assume that a properly-configured system has the - * unwritable directories owned by root. This is not - * necessarily so (bin, news, etc., may), but the only - * uid we can count on is 0. It would be nice to add a - * check for the gid also, but that wouldn't be - * portable. - */ - if (data.st_uid != 0 - || data.st_mode & S_IWOTH) { - linked = TRUE; /* force an error-return */ - break; - } - } - } else if (linked) { - break; - } - } while (leaf != path); - free(path); -#endif - return !linked; - } - return FALSE; -} - -/* - * Open a file that we don't want other users to see. + * 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. */ PRIVATE FILE *OpenHiddenFile ARGS2(char *, name, char *, mode) { + int save = umask(HIDE_UMASK); FILE *fp = 0; - -#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 - && errno == EEXIST - && IsOurFile(name)) { - remove(name); - /* FIXME: there's a race at this point if directory is open */ - fd = open(name, O_CREAT|O_EXCL|O_WRONLY, HIDE_CHMOD); - } - if (fd >= 0) { - fp = fdopen(fd, mode); - } - } - else -#endif - if (*mode == 'a' - && IsOurFile(name) - && chmod(name, HIDE_CHMOD) == 0) + if (chmod(name, HIDE_CHMOD) == 0 || errno == ENOENT) fp = fopen(name, mode); - /* - * 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. - */ - else if (*mode != 'a') { - int save = umask(HIDE_UMASK); - if (chmod(name, HIDE_CHMOD) == 0 || errno == ENOENT) - fp = fopen(name, mode); - umask(save); - } + umask(save); return fp; } #else @@ -5544,42 +5645,29 @@ PUBLIC FILE *LYNewBinFile ARGS1(char *, name) PUBLIC FILE *LYNewTxtFile ARGS1(char *, name) { - FILE *fp; - #ifdef VMS - fp = fopen (name, "w", "shr=get"); + FILE *fp = fopen (name, "w", "shr=get"); chmod(name, HIDE_CHMOD); #else - SetDefaultMode(O_TEXT); - - fp = OpenHiddenFile(name, "w"); - - SetDefaultMode(O_BINARY); + FILE *fp = OpenHiddenFile(name, "w"); #endif - return fp; } PUBLIC FILE *LYAppendToTxtFile ARGS1(char *, name) { - FILE *fp; - #ifdef VMS - fp = fopen (name, "a+", "shr=get"); + FILE *fp = fopen (name, "a+", "shr=get"); chmod(name, HIDE_CHMOD); #else - SetDefaultMode(O_TEXT); - - fp = OpenHiddenFile(name, "a+"); - - SetDefaultMode(O_BINARY); + FILE *fp = OpenHiddenFile(name, "a+"); #endif return fp; } #ifdef UNIX /* - * Restore normal permissions to a copy of a file that we have created + * Restore normal permisions to a copy of a file that we have created * with temp file restricted permissions. The normal umask should * apply for user files. - kw */ @@ -5602,528 +5690,3 @@ PUBLIC void LYRelaxFilePermissions ARGS1(CONST char *, name) } } #endif - -/* - * Check if the given anchor has an associated file-cache. - */ -PUBLIC BOOLEAN LYCachedTemp ARGS2( - char *, result, - char **, cached) -{ - FILE *fp; - - if (*cached) { - strcpy(result, *cached); - FREE(*cached); - if ((fp = fopen(result, "r")) != NULL) { - fclose(fp); - remove(result); - } - return TRUE; - } - return FALSE; -} - -/* - * Maintain a list of all of the temp-files we create so that we can remove - * them during the cleanup. - */ -typedef struct _LYTemp { - struct _LYTemp *next; - char *name; - FILE *file; -} LY_TEMP; - -static LY_TEMP *ly_temp; - -/* - * Open a temp-file, ensuring that it is unique, and not readable by other - * users. - * - * The mode can be one of: "w", "a", "wb". - */ -PUBLIC FILE *LYOpenTemp ARGS3( - char *, result, - CONST char *, suffix, - CONST char *, mode) -{ - FILE *fp = 0; - BOOL txt = TRUE; - BOOL wrt = 'r'; - LY_TEMP *p; - - CTRACE(tfp, "LYOpenTemp(,%s,%s)\n", suffix, mode); - while (*mode != '\0') { - switch (*mode++) { - case 'w': wrt = 'w'; break; - case 'a': wrt = 'a'; break; - case 'b': txt = FALSE; break; - default: - CTRACE(tfp, "%s @%d: BUG\n", __FILE__, __LINE__); - return fp; - } - } - - do { - (void) fmt_tempname(result, lynx_temp_space, suffix); - if (txt) { - switch (wrt) { - case 'w': - fp = LYNewTxtFile (result); - break; - case 'a': - fp = LYAppendToTxtFile (result); - break; - } - } else { - fp = LYNewBinFile (result); - } - } while (fp == 0); - - if ((p = (LY_TEMP *)calloc(1, sizeof(LY_TEMP))) != 0) { - p->next = ly_temp; - StrAllocCopy((p->name), result); - p->file = fp; - ly_temp = p; - } - - CTRACE(tfp, "... LYOpenTemp(%s)\n", result); - return fp; -} - -/* - * Reopen a temporary file - */ -PUBLIC FILE *LYReopenTemp ARGS1( - char *, name) -{ - LY_TEMP *p; - FILE *fp = 0; - - LYCloseTemp(name); - for (p = ly_temp; p != 0; p = p->next) { - if (!strcmp(p->name, name)) { - fp = p->file = LYAppendToTxtFile (name); - break; - } - } - return fp; -} - -/* - * Special case of LYOpenTemp, used for manipulating bookmark file, i.e., with - * renaming. - */ -PUBLIC FILE *LYOpenScratch ARGS2( - char *, result, - CONST char *, prefix) -{ - FILE *fp; - LY_TEMP *p; - - (void) fmt_tempname(result, prefix, HTML_SUFFIX); - if ((fp = LYNewTxtFile (result)) != 0) { - if ((p = (LY_TEMP *)calloc(1, sizeof(LY_TEMP))) != 0) { - p->next = ly_temp; - StrAllocCopy((p->name), result); - p->file = fp; - ly_temp = p; - } - } - CTRACE(tfp, "LYOpenScratch(%s)\n", result); - return fp; -} - -/* - * Close a temp-file, given its name - */ -PUBLIC void LYCloseTemp ARGS1( - char *, name) -{ - LY_TEMP *p; - - CTRACE(tfp, "LYCloseTemp(%s)\n", name); - for (p = ly_temp; p != 0; p = p->next) { - if (!strcmp(name, p->name)) { - CTRACE(tfp, "...LYCloseTemp(%s)%s\n", name, - (p->file != 0) ? ", closed" : ""); - if (p->file != 0) { - fclose(p->file); - p->file = 0; - } - break; - } - } -} - -/* - * Close a temp-file, given its file-pointer - */ -PUBLIC void LYCloseTempFP ARGS1( - FILE *, fp) -{ - LY_TEMP *p; - - CTRACE(tfp, "LYCloseTempFP\n"); - for (p = ly_temp; p != 0; p = p->next) { - if (p->file == fp) { - fclose(p->file); - p->file = 0; - break; - } - } -} - -/* - * Close a temp-file, removing it. - */ -PUBLIC void LYRemoveTemp ARGS1( - char *, name) -{ - LY_TEMP *p, *q; - int code; - - if (name != 0 && *name != 0) { - CTRACE(tfp, "LYRemoveTemp(%s)\n", name); - for (p = ly_temp, q = 0; p != 0; q = p, p = p->next) { - if (!strcmp(name, p->name)) { - if (q != 0) { - q->next = p->next; - } else { - ly_temp = p->next; - } - code = HTSYS_remove(name); - CTRACE(tfp, "...LYRemoveTemp done(%d)%s\n", code, - (p->file != 0) ? ", closed" : ""); - CTRACE_FLUSH(tfp); - if (p->file != 0) - fclose(p->file); - free(p->name); - free(p); - break; - } - } - } -} - -/* - * Remove all of the temp-files. Note that this assumes that they are closed, - * since some systems will not allow us to remove a file which is open. - */ -PUBLIC void LYCleanupTemp NOARGS -{ - while (ly_temp != 0) { - LYRemoveTemp(ly_temp->name); - } -} - -/* - * Convert local pathname to www name - * (do not bother about file://localhost prefix at this point). - */ -PUBLIC char * wwwName ARGS1( - CONST char *, pathname) -{ - char *cp = NULL; - -#ifdef DOSPATH - cp = HTDOS_wwwName((char *)pathname); -#else -#ifdef VMS - cp = HTVMS_wwwName((char *)pathname); -#else - cp = (char *)pathname; -#endif /* VMS */ -#endif /* DOSPATH */ - - return cp; -} - -/* - * Convert a local filename to a URL - */ -PUBLIC void LYLocalFileToURL ARGS2( - char **, target, - CONST char *, source) -{ - char *leaf; - - StrAllocCopy(*target, "file://localhost"); - - leaf = wwwName(source); - - if (!LYIsHtmlSep(*leaf)) - LYAddHtmlSep(target); - StrAllocCat(*target, leaf); -} - -#ifdef NOTDEFINED -/* FIXME: this may be useful for pages that do not allow nested pages */ -PUBLIC int LYOpenInternalPage ARGS2( - FILE **, fp0, - char **, newfile) -{ - static char tempfile[256]; - - LYRemoveTemp(tempfile); - if ((*fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) { - HTAlert(CANNOT_OPEN_TEMP); - return(-1); - } - - LYLocalFileToURL(newfile, tempfile); - LYforce_no_cache = TRUE; /* don't cache this doc */ - - return(0); /* OK */ -} -#endif - -PUBLIC void BeginInternalPage ARGS3( - FILE *, fp0, - char*, Title, - char*, HelpURL) -{ - fprintf(fp0, "<html>\n<head>\n"); - LYAddMETAcharsetToFD(fp0, -1); - if (!strcmp(Title, LIST_PAGE_TITLE)) { - if (strchr(HTLoadedDocumentURL(), '"') == NULL) { - char *Address = NULL; - /* - * Insert a BASE tag so there is some way to relate the List Page - * file to its underlying document after we are done. It won't be - * actually used for resolving relative URLs. - kw - */ - StrAllocCopy(Address, HTLoadedDocumentURL()); - LYEntify(&Address, FALSE); - fprintf(fp0, "<base href=\"%s\">\n", Address); - FREE(Address); - } - } - fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", - Title); - - if ((user_mode == NOVICE_MODE) - && LYwouldPush(Title) - && (HelpURL != 0)) { - fprintf(fp0, "<h1>%s (%s Version %s), <a href=\"%s%s\">help</a></h1>\n", - Title, LYNX_NAME, LYNX_VERSION, - helpfilepath, HelpURL); - } else { - fprintf(fp0, "<h1>%s (%s Version %s)</h1>\n", - Title, LYNX_NAME, LYNX_VERSION); - } -} - -PUBLIC void EndInternalPage ARGS1( - FILE *, fp0) -{ - fprintf(fp0, "</body>\n</html>"); -} - -/* - * Trim a trailing path-separator to avoid confusing other programs when we concatenate - * to it. This only applies to local filesystems. - */ -PUBLIC void LYTrimPathSep ARGS1( - char *, path) -{ - size_t len; - - if (path != 0 - && (len = strlen(path)) != 0 - && LYIsPathSep(path[len-1])) - path[len-1] = 0; -} - -#ifdef DOSPATH -#define PATHSEP_STR "\\" -#else -#define PATHSEP_STR "/" -#endif - -/* - * Add a trailing path-separator to avoid confusing other programs when we concatenate - * to it. This only applies to local filesystems. - */ -PUBLIC void LYAddPathSep ARGS1( - char **, path) -{ - size_t len; - char *temp; - - if ((path != 0) - && ((temp = *path) != 0) - && (len = strlen(temp)) != 0 - && !LYIsPathSep(temp[len-1])) { - StrAllocCat(*path, PATHSEP_STR); - } -} - -/* - * Add a trailing path-separator to avoid confusing other programs when we concatenate - * to it. This only applies to local filesystems. - */ -PUBLIC void LYAddPathSep0 ARGS1( - char *, path) -{ - size_t len; - - if ((path != 0) - && (len = strlen(path)) != 0 - && !LYIsPathSep(path[len-1])) { - strcat(path, PATHSEP_STR); - } -} - -/* - * Trim a trailing path-separator to avoid confusing other programs when we concatenate - * to it. This only applies to HTML paths. - */ -PUBLIC void LYTrimHtmlSep ARGS1( - char *, path) -{ - size_t len; - - if (path != 0 - && (len = strlen(path)) != 0 - && LYIsHtmlSep(path[len-1])) - path[len-1] = 0; -} - -/* - * Add a trailing path-separator to avoid confusing other programs when we concatenate - * to it. This only applies to HTML paths. - */ -PUBLIC void LYAddHtmlSep ARGS1( - char **, path) -{ - size_t len; - char *temp; - - if ((path != 0) - && ((temp = *path) != 0) - && (len = strlen(temp)) != 0 - && !LYIsHtmlSep(temp[len-1])) { - StrAllocCat(*path, "/"); - } -} - -/* - * Add a trailing path-separator to avoid confusing other programs when we concatenate - * to it. This only applies to HTML paths. - */ -PUBLIC void LYAddHtmlSep0 ARGS1( - char *, path) -{ - size_t len; - - if ((path != 0) - && (len = strlen(path)) != 0 - && !LYIsHtmlSep(path[len-1])) { - strcat(path, "/"); - } -} - -/* - * Invoke a shell command - */ -PUBLIC int LYSystem ARGS1( - char *, command) -{ - int code; - - fflush(stdout); - fflush(stderr); - -#ifdef __DJGPP__ - __djgpp_set_ctrl_c(0); - _go32_want_ctrl_break(1); -#endif /* __DJGPP__ */ - -#ifdef VMS - code = DCLsystem(command); -#else - code = system(command); -#endif - -#ifdef __DJGPP__ - __djgpp_set_ctrl_c(1); - _go32_want_ctrl_break(0); -#endif /* __DJGPP__ */ - - fflush(stdout); - fflush(stderr); - - return code; -} - -/* - * Return a string which can be used in LYSystem() for spawning a subshell - */ -PUBLIC char *LYSysShell NOARGS -{ - char *shell = 0; -#ifdef DOSPATH - if (getenv("SHELL") != NULL) { - shell = getenv("SHELL"); - } else { - shell = (getenv("COMSPEC") == NULL) ? "command.com" : getenv("COMSPEC"); - } -#else -#ifdef __EMX__ - if (getenv("SHELL") != NULL) { - shell = getenv("SHELL"); - } else { - shell = (getenv("COMSPEC") == NULL) ? "cmd.exe" : getenv("COMSPEC"); - } -#else -#ifdef VMS - shell = ""; -#else - shell = "exec $SHELL"; -#endif /* __EMX__ */ -#endif /* VMS */ -#endif /* DOSPATH */ - return shell; -} - -#ifdef VMS -#define DISPLAY "DECW$DISPLAY" -#else -#define DISPLAY "DISPLAY" -#endif /* VMS */ - -/* - * Return the X-Window $DISPLAY string if it is nonnull/nonempty - */ -PUBLIC char *LYgetXDisplay NOARGS -{ - char *cp; - if ((cp = getenv(DISPLAY)) == NULL || *cp == '\0') - cp = 0; - return cp; -} - -/* - * Set the value of the X-Window $DISPLAY variable (yes it leaks memory, but - * that is putenv's fault). - */ -PUBLIC void LYsetXDisplay ARGS1( - char *, new_display) -{ - if (new_display != 0 && *new_display != '\0') { -#ifdef VMS - LYUpperCase(new_display); - Define_VMSLogical(DISPLAY, new_display); -#else - static char *display_putenv_command; - display_putenv_command = malloc(strlen(new_display) + 12); - - sprintf(display_putenv_command, "DISPLAY=%s", new_display); - putenv(display_putenv_command); -#endif /* VMS */ - if ((new_display = LYgetXDisplay()) != 0) { - StrAllocCopy(x_display, new_display); - } - } -} diff --git a/src/LYUtils.h b/src/LYUtils.h index 5c4ab08e..29ab92c4 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -1,122 +1,70 @@ + #ifndef LYUTILS_H #define LYUTILS_H +#include <stdio.h> + #ifndef HTLIST_H #include <HTList.h> #endif /* HTLIST_H */ -#ifdef VMS -#include <HTVMSUtils.h> -#define HTSYS_name(path) HTVMS_name("", path) -#define HTSYS_purge(path) HTVMS_purge(path) -#define HTSYS_remove(path) HTVMS_remove(path) -#endif /* VMS */ - -#if defined(DOSPATH) || defined(__EMX__) -#include <HTDOS.h> -#define HTSYS_name(path) HTDOS_name(path) -#endif - -#ifndef HTSYS_name -#define HTSYS_name(path) path -#endif - -#ifndef HTSYS_purge -#define HTSYS_purge(path) /*nothing*/ -#endif - -#ifndef HTSYS_remove -#define HTSYS_remove(path) remove(path) -#endif - -#ifdef DOSPATH -#define LYIsPathSep(ch) ((ch) == '/' || (ch) == '\\') -#else -#define LYIsPathSep(ch) ((ch) == '/') -#endif - -#define LYIsHtmlSep(ch) ((ch) == '/') - -#define TABLESIZE(v) (sizeof(v)/sizeof(v[0])) - -extern BOOLEAN LYAddSchemeForURL PARAMS((char **AllocatedString, char *default_scheme)); -extern BOOLEAN LYCachedTemp PARAMS((char *result, char **cached)); -extern BOOLEAN LYCanDoHEAD PARAMS((CONST char *address)); -extern BOOLEAN LYExpandHostForURL PARAMS((char **AllocatedString, char *prefix_list, char *suffix_list)); -extern BOOLEAN LYPathOffHomeOK PARAMS((char *fbuffer, size_t fbuffer_size)); -extern BOOLEAN LYisLocalAlias PARAMS((char *filename)); +extern void highlight PARAMS((int flag, int cur, char *target)); +extern void free_and_clear PARAMS((char **obj)); +extern void collapse_spaces PARAMS((char *string)); +extern void convert_to_spaces PARAMS((char *string, BOOL condense)); +extern char * strip_trailing_slash PARAMS((char * dirname)); +extern void statusline PARAMS((CONST char *text)); +extern void toggle_novice_line NOPARAMS; +extern void noviceline PARAMS((int more_flag)); +extern void LYFakeZap PARAMS((BOOL set)); +extern int HTCheckForInterrupt NOPARAMS; extern BOOLEAN LYisLocalFile PARAMS((char *filename)); extern BOOLEAN LYisLocalHost PARAMS((char *filename)); -extern BOOLEAN inlocaldomain NOPARAMS; -extern CONST char *Home_Dir NOPARAMS; -extern FILE *LYAppendToTxtFile PARAMS((char * name)); -extern FILE *LYNewBinFile PARAMS((char * name)); -extern FILE *LYNewTxtFile PARAMS((char * name)); -extern FILE *LYOpenScratch PARAMS((char *result, CONST char *prefix)); -extern FILE *LYOpenTemp PARAMS((char *result, CONST char *suffix, CONST char *mode)); -extern FILE *LYReopenTemp PARAMS((char *name)); -extern char *LYPathLeaf PARAMS((char * pathname)); -extern char *LYSysShell NOPARAMS; -extern char *LYgetXDisplay NOPARAMS; -extern char *quote_pathname PARAMS((char *pathname)); -extern char *strip_trailing_slash PARAMS((char * my_dirname)); -extern char *wwwName PARAMS((CONST char *pathname)); -extern int HTCheckForInterrupt NOPARAMS; +extern void LYLocalhostAliases_free NOPARAMS; +extern void LYAddLocalhostAlias PARAMS((char *alias)); +extern BOOLEAN LYisLocalAlias PARAMS((char *filename)); extern int LYCheckForProxyURL PARAMS((char *filename)); -extern int LYOpenInternalPage PARAMS((FILE **fp0, char **newfile)); -extern int LYSystem PARAMS((char *command)); extern int is_url PARAMS((char *filename)); -extern int number2arrows PARAMS((int number)); -extern time_t LYmktime PARAMS((char *string, BOOL absolute)); -extern void BeginInternalPage PARAMS((FILE *fp0, char *Title, char *HelpURL)); -extern void EndInternalPage PARAMS((FILE *fp0)); -extern void HTAddSugFilename PARAMS((char *fname)); +extern BOOLEAN LYCanDoHEAD PARAMS((CONST char *address)); +extern void remove_backslashes PARAMS((char *buf)); +extern char *quote_pathname PARAMS((char *pathname)); +extern BOOLEAN inlocaldomain NOPARAMS; +extern void size_change PARAMS((int sig)); extern void HTSugFilenames_free NOPARAMS; -extern void LYAddHtmlSep PARAMS((char **path)); -extern void LYAddHtmlSep0 PARAMS((char *path)); -extern void LYAddLocalhostAlias PARAMS((char *alias)); -extern void LYAddPathSep PARAMS((char **path)); -extern void LYAddPathSep0 PARAMS((char *path)); -extern void LYAddPathToHome PARAMS((char *fbuffer, size_t fbuffer_size, char *fname)); -extern void LYCheckMail NOPARAMS; -extern void LYCleanupTemp NOPARAMS; -extern void LYCloseTemp PARAMS((char *name)); -extern void LYCloseTempFP PARAMS((FILE *fp)); -extern void LYConvertToURL PARAMS((char **AllocatedString)); -extern void LYDoCSI PARAMS((char *url, CONST char *comment, char **csi)); -extern void LYEnsureAbsoluteURL PARAMS((char **href, CONST char *name)); -extern void LYFakeZap PARAMS((BOOL set)); -extern void LYLocalFileToURL PARAMS((char **target, CONST char *source)); -extern void LYLocalhostAliases_free NOPARAMS; -extern void LYRemoveTemp PARAMS((char *name)); -extern void LYTrimHtmlSep PARAMS((char *path)); -extern void LYTrimPathSep PARAMS((char *path)); -extern void LYTrimRelFromAbsPath PARAMS((char *path)); -extern void LYsetXDisplay PARAMS((char *new_display)); +extern void HTAddSugFilename PARAMS((char *fname)); extern void change_sug_filename PARAMS((char *fname)); +extern void tempname PARAMS((char *namebuffer, int action)); +extern int number2arrows PARAMS((int number)); +extern void parse_restrictions PARAMS((char *s)); extern void checkmail NOPARAMS; -extern void convert_to_spaces PARAMS((char *string, BOOL condense)); -extern void free_and_clear PARAMS((char **obj)); -extern void highlight PARAMS((int flag, int cur, char *target)); -extern void noviceline PARAMS((int more_flag)); -extern void parse_restrictions PARAMS((CONST char *s)); -extern void remove_backslashes PARAMS((char *buf)); -extern void size_change PARAMS((int sig)); -extern void statusline PARAMS((CONST char *text)); -extern void toggle_novice_line NOPARAMS; - +extern int LYCheckMail NOPARAMS; +extern void LYEnsureAbsoluteURL PARAMS((char **href, char *name)); +extern void LYConvertToURL PARAMS((char **AllocatedString)); +extern BOOLEAN LYExpandHostForURL PARAMS(( + char **AllocatedString, char *prefix_list, char *suffix_list)); +extern BOOLEAN LYAddSchemeForURL PARAMS(( + char **AllocatedString, char *default_scheme)); +extern void LYTrimRelFromAbsPath PARAMS((char *path)); +extern void LYDoCSI PARAMS((char *url, CONST char *comment, char **csi)); #ifdef VMS -extern void Define_VMSLogical PARAMS((char *LogicalName, char *LogicalValue)); +extern void Define_VMSLogical PARAMS(( + char *LogicalName, char *LogicalValue)); #endif /* VMS */ - +extern CONST char *Home_Dir NOPARAMS; +extern BOOLEAN LYPathOffHomeOK PARAMS((char *fbuffer, size_t fbuffer_size)); +extern void LYAddPathToHome PARAMS(( + char *fbuffer, size_t fbuffer_size, char *fname)); +extern time_t LYmktime PARAMS((char *string, BOOL absolute)); #if ! HAVE_PUTENV extern int putenv PARAMS((CONST char *string)); #endif /* HAVE_PUTENV */ +FILE *LYNewBinFile PARAMS((char * name)); +FILE *LYNewTxtFile PARAMS((char * name)); +FILE *LYAppendToTxtFile PARAMS((char * name)); #ifdef UNIX extern void LYRelaxFilePermissions PARAMS((CONST char * name)); #endif - /* * Whether or not the status line must be shown. */ @@ -167,11 +115,10 @@ extern BOOLEAN mustshow; #define LYNXIMGMAP_URL_TYPE 33 #define LYNXCOOKIE_URL_TYPE 34 #define LYNXDIRED_URL_TYPE 35 -#define LYNXOPTIONS_URL_TYPE 36 -#define PROXY_URL_TYPE 37 +#define PROXY_URL_TYPE 36 -#define UNKNOWN_URL_TYPE 38 +#define UNKNOWN_URL_TYPE 37 /* * For change_sug_filename(). @@ -179,6 +126,12 @@ extern BOOLEAN mustshow; extern HTList *sug_filenames; /* + * For tempname(). + */ +#define NEW_FILE 0 +#define REMOVE_FILES 1 + +/* * Miscellaneous. */ #define ON 1 diff --git a/src/LYexit.c b/src/LYexit.c index 0eace151..1e2fb11c 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -2,18 +2,20 @@ * Copyright (c) 1994, University of Kansas, All Rights Reserved */ #include <HTUtils.h> +#include <tcp.h> #include <LYexit.h> #ifndef VMS #include <LYGlobalDefs.h> #include <LYUtils.h> #include <LYSignal.h> #include <LYClean.h> -#include <LYMainLoop.h> #ifdef SYSLOG_REQUESTED_URLS #include <syslog.h> #endif /* SYSLOG_REQUESTED_URLS */ #endif /* !VMS */ +#define FREE(x) if (x) {free(x); x = NULL;} + /* * Stack of functions to call upon exit. */ @@ -111,7 +113,13 @@ PUBLIC void LYexit ARGS1( printf("\r\n%s\r\n\r\n", MEMORY_EXHAUSTED_ABORT); fflush(stdout); } - LYCloseTracelog(); + if (LYTraceLogFP != NULL) { + fflush(stdout); + fflush(stderr); + fclose(LYTraceLogFP); + LYTraceLogFP = NULL; + *stderr = LYOrigStderr; + } #endif /* !VMS */ exit(status); } @@ -136,7 +144,8 @@ void (*function)(); * Check for available space. */ if (topOfStack == ATEXITSIZE) { - CTRACE(tfp, "(LY)atexit: Too many functions, ignoring one!\n"); + if (TRACE) + fprintf(stderr, "(LY)atexit: Too many functions, ignoring one!\n"); return(-1); } @@ -166,13 +175,3 @@ PRIVATE void LYCompleteExit NOPARAMS callstack[topOfStack](); } } - -PUBLIC void outofmem ARGS2( - CONST char *, fname, - CONST char *, func) -{ - fprintf(stderr, - "\r\n\r\n\r\n%s %s: out of memory. Aborting...\r\n", fname, func); - LYOutOfMemory = TRUE; - LYexit(-1); -} diff --git a/src/LYrcFile.c b/src/LYrcFile.c index 1c63fff1..64aadeff 100644 --- a/src/LYrcFile.c +++ b/src/LYrcFile.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTFTP.h> #include <LYUtils.h> #include <LYrcFile.h> @@ -6,20 +7,13 @@ #include <LYGlobalDefs.h> #include <LYCharSets.h> #include <LYBookmark.h> -#include <LYCookie.h> #include <LYLeaks.h> -#ifdef FNAMES_8_3 -#define FNAME_LYNXRC "lynx.rc" -#else -#define FNAME_LYNXRC ".lynxrc" -#endif /* FNAMES_8_3 */ - PUBLIC void read_rc NOPARAMS { char line_buffer[256]; - char rcfile[LY_MAXPATH]; + char rcfile[256]; FILE *fp; char *cp, *cp2; int number_sign; @@ -31,7 +25,15 @@ PUBLIC void read_rc NOPARAMS /* * Make an RC file name. */ - LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC); +#ifdef DJGPP + sprintf(rcfile, "%s/lynx.rc", Home_Dir()); +#else +#ifdef VMS + sprintf(rcfile, "sys$login:.lynxrc"); +#else + sprintf(rcfile, "%s/.lynxrc", Home_Dir()); +#endif /* VMS */ +#endif /* DJGPP */ /* * Open the RC file for reading. @@ -43,7 +45,7 @@ PUBLIC void read_rc NOPARAMS /* * Process the entries. */ - while (fgets(line_buffer, sizeof(line_buffer)-1, fp) != NULL) { + while (fgets(line_buffer, 256, fp) != NULL) { /* * Remove the /n from the end of the line. */ @@ -53,7 +55,8 @@ PUBLIC void read_rc NOPARAMS /* * Remove any trailing white space. */ - LYTrimTrailing(line_buffer); + while (line_buffer[0] && isspace(line_buffer[strlen(line_buffer)-1])) + line_buffer[strlen(line_buffer)-1] = '\0'; /* * Skip any comment or blank lines. @@ -78,7 +81,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ StrAllocCopy(editor, cp); /* @@ -89,7 +93,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp,'=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ /* * Since this is the "Default Bookmark File", we save it @@ -108,7 +113,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = (cp2 + 1); - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "standard", 8)) { LYMultiBookmarks = TRUE; LYMBMAdvanced = FALSE; @@ -175,7 +181,8 @@ PUBLIC void read_rc NOPARAMS /* * Eat spaces in front of description. */ - MBM_cp1 = LYSkipBlanks(MBM_cp1); + while (isspace(*MBM_cp1)) + MBM_cp1++; while (*MBM_cp1) MBM_line[MBM_i2++] = *MBM_cp1++; MBM_line[MBM_i2++] = '\0'; @@ -198,7 +205,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "BY_FILENAME", 11)) HTfileSortMethod = FILE_BY_NAME; else if (!strncasecomp(cp, "BY_TYPE", 7)) @@ -217,7 +225,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ StrAllocCopy(personal_mail_address, cp); /* @@ -229,7 +238,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "on", 2)) case_sensitive = TRUE; else @@ -245,13 +255,15 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); - - i = UCGetLYhndl_byAnyName(cp); /* by MIME or full name */ - if (i < 0) - ; /* do nothing here: so fallback to lynx.cfg */ - else - current_char_set = i; + while (isspace(*cp)) + cp++; /* get rid of spaces */ + for (; LYchar_set_names[i]; i++) { + if (!strncmp(cp, LYchar_set_names[i], strlen(cp))) { + current_char_set=i; + HTMLSetRawModeDefault(i); + break; + } + } /* * Preferred language. @@ -262,7 +274,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ StrAllocCopy(language, cp); /* @@ -274,7 +287,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ StrAllocCopy(pref_charset, cp); /* @@ -285,7 +299,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char * )strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "on", 2)) vi_keys = TRUE; else @@ -299,7 +314,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "on", 2)) emacs_keys = TRUE; else @@ -313,7 +329,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char * )strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "on", 2)) show_dotfiles = TRUE; else @@ -327,7 +344,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char * )strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "always", 6)) { LYrcShowColor = SHOW_COLOR_ALWAYS; #if defined(USE_SLANG) || defined(COLOR_CURSES) @@ -350,7 +368,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char * )strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "off", 3)) LYSelectPopups = FALSE; else @@ -364,7 +383,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char * )strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "off", 3)) LYShowCursor = FALSE; else @@ -378,7 +398,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (LYstrstr(cp, "LINKS_ARE_NUMBERED")) keypad_mode = LINKS_ARE_NUMBERED; else if (LYstrstr(cp, "LINKS_AND_FORM_FIELDS_ARE_NUMBERED")) @@ -396,7 +417,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ for (; LYLineeditNames[i]; i++) { if (!strncmp(cp, LYLineeditNames[i], strlen(cp))) { current_lineedit = i; @@ -413,7 +435,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp,'=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (LYstrstr(cp, "FILES_FIRST") != NULL) { dir_list_style = FILES_FIRST; } else if (LYstrstr(cp,"DIRECTORIES_FIRST") != NULL) { @@ -424,59 +447,6 @@ PUBLIC void read_rc NOPARAMS #endif /* DIRED_SUPPORT */ /* - * Accept cookies from all domains? - */ - } else if ((cp = LYstrstr(line_buffer, "accept_all_cookies")) != NULL && - cp-line_buffer < number_sign) { - if((cp2 = (char *)strchr(cp,'=')) != NULL) - cp = cp2 + 1; - while (isspace(*cp)) - cp++; /* get rid of spaces */ - if (LYstrstr(cp,"TRUE") != NULL) { - LYAcceptAllCookies = TRUE; - } else { - LYAcceptAllCookies = FALSE; - } - - - /* - * Accept all cookies from certain domains? - */ - } else if ((cp = LYstrstr(line_buffer, "cookie_accept_domains")) - != NULL && cp-line_buffer < number_sign) { - if((cp2 = (char *)strchr(cp,'=')) != NULL) - cp = cp2 + 1; - while (isspace(*cp)) - cp++; /* get rid of spaces */ - cookie_add_acceptlist(cp); - - - /* - * Reject all cookies from certain domains? - */ - } else if ((cp = LYstrstr(line_buffer, "cookie_reject_domains")) - != NULL && cp-line_buffer < number_sign) { - if((cp2 = (char *)strchr(cp,'=')) != NULL) - cp = cp2 + 1; - while (isspace(*cp)) - cp++; /* get rid of spaces */ - cookie_add_rejectlist(cp); - -#ifdef EXP_PERSISTENT_COOKIES - /* - * File to store cookies in. - */ - } else if ((cp = LYstrstr(line_buffer, "cookie_file")) - != NULL && cp-line_buffer < number_sign) { - if((cp2 = (char *)strchr(cp,'=')) != NULL) - cp = cp2 + 1; - while (isspace(*cp)) - cp++; /* get rid of spaces */ - - StrAllocCopy(LYCookieFile, cp); -#endif /* EXP_PERSISTENT_COOKIES */ - - /* * User mode. */ } else if ((cp = LYstrstr(line_buffer, "user_mode")) != NULL && @@ -484,7 +454,8 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (LYstrstr(cp, "ADVANCED") != NULL) { user_mode = ADVANCED_MODE; } else if (LYstrstr(cp,"INTERMEDIATE") != NULL) { @@ -503,26 +474,14 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ + if (!strncasecomp(cp, "on", 2)) local_exec = TRUE; else local_exec = FALSE; -#ifdef DISP_PARTIAL - /* - * Partial display logic--set the threshold # of lines before - * Lynx redraws the screen - */ - } else if ((cp = LYstrstr(line_buffer, "partial_thres")) != NULL && - cp-line_buffer < number_sign) { - if ((cp2 = (char *)strchr(cp, '=')) != NULL) - cp = cp2 + 1; - cp = LYSkipBlanks(cp); - if (atoi(cp) != 0) - partial_threshold = atoi(cp); -#endif /* DISP_PARTIAL */ - /* * Local execution mode - only links in local files. */ @@ -532,25 +491,14 @@ PUBLIC void read_rc NOPARAMS if ((cp2 = (char *)strchr(cp, '=')) != NULL) cp = cp2 + 1; - cp = LYSkipBlanks(cp); + while (isspace(*cp)) + cp++; /* get rid of spaces */ if (!strncasecomp(cp, "on", 2)) local_exec_on_local_files = TRUE; else local_exec_on_local_files=FALSE; #endif /* ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS */ - } else if ((cp = LYstrstr(line_buffer, - "verbose_images")) != NULL && - cp-line_buffer < number_sign) { - - if ((cp2 = (char *)strchr(cp, '=')) != NULL) - cp = cp2 + 1; - cp = LYSkipBlanks(cp); - if (!strncasecomp(cp, "on", 2)) - verbose_img = 1; - else if (!strncasecomp(cp, "off", 3)) - verbose_img = 0; - } /* end of if */ } /* end of while */ @@ -560,7 +508,7 @@ PUBLIC void read_rc NOPARAMS PUBLIC int save_rc NOPARAMS { - char rcfile[LY_MAXPATH]; + char rcfile[256]; FILE *fp; int i; int MBM_c; @@ -568,11 +516,22 @@ PUBLIC int save_rc NOPARAMS /* * Make a name. */ - LYAddPathToHome(rcfile, sizeof(rcfile), FNAME_LYNXRC); +#ifdef DJGPP + sprintf(rcfile, "%s/lynx.rc", Home_Dir()); +#else +#ifdef VMS + sprintf(rcfile, "sys$login:.lynxrc"); +#else + sprintf(rcfile, "%s/.lynxrc", Home_Dir()); +#endif /* VMS */ +#endif /* DJGPP */ /* * Open the file for write. */ +#if defined(__DJGPP__) || defined(_WINDOWS) + _fmode = O_TEXT; +#endif /* __DJGPP__ or _WINDOWS */ if ((fp = LYNewTxtFile(rcfile)) == NULL) { return FALSE; } @@ -813,7 +772,7 @@ PUBLIC int save_rc NOPARAMS # current link in documents, or current option in select popup windows.\n\ # Positioning the cursor to the left of the current link or option is\n\ # helpful for speech or braille interfaces, and when the terminal is\n\ -# one which does not distinguish the current link based on highlighting\n\ +# one which does not distingish the current link based on highlighting\n\ # or color. A value of \"on\" will set positioning to the left as the\n\ # default while a value of \"off\" will set 'hiding' of the cursor.\n\ # The default can be overridden via the -show_cursor command line toggle.\n"); @@ -850,24 +809,11 @@ PUBLIC int save_rc NOPARAMS ((keypad_mode == LINKS_ARE_NUMBERED) ? "LINKS_ARE_NUMBERED" : "LINKS_AND_FORM_FIELDS_ARE_NUMBERED"))); -#ifdef DISP_PARTIAL - /* - * Partial display threshold - */ - fprintf(fp, "\ -# partial_thres specifies the number of lines Lynx should download and render\n\ -# before we redraw the screen in Partial Display logic\n\ -# e.g. partial_thres=2\n\ -# would have Lynx redraw every 2 lines that it renders\n\ -# partial_thres=-1 would use the entire screensize\n"); - fprintf(fp, "partial_thres=%d\n\n", partial_threshold); -#endif /* DISP_PARTIAL */ - /* * Lineedit mode. */ fprintf(fp, "\ -# lineedit_mode specifies the key binding used for inputting strings in\n\ +# linedit_mode specifies the key binding used for inputting strings in\n\ # prompts and forms. If lineedit_mode is set to \"Default Binding\" then\n\ # the following control characters are used for moving and deleting:\n\ #\n\ @@ -918,50 +864,12 @@ PUBLIC int save_rc NOPARAMS (user_mode == ADVANCED_MODE ? "ADVANCED" : "INTERMEDIATE"))); - /* - * Cookie options - */ - fprintf(fp, "\ -# accept_all_cookies allows the user to tell Lynx to automatically\n\ -# accept all cookies if desired. The default is \"FALSE\" which will\n\ -# prompt for each cookie. Set accept_all_cookies to \"TRUE\" to accept\n\ -# all cookies.\n"); - fprintf(fp, "accept_all_cookies=%s\n\n", - (LYAcceptAllCookies == FALSE ? "FALSE" : "TRUE")); - - fprintf(fp, "\ -# cookie_accept_domains and cookie_reject_domains are comma-delimited\n\ -# lists of domains (with a leading '.') to automatically accept or\n\ -# reject all cookies from. The accept_all_cookies parameter will\n\ -# override any settings made here. If a single domain is specified in\n\ -# both cookie_accept_domains and in cookie_reject_domains, the rejection\n\ -# will take precedence.\n"); - fprintf(fp, "# cookie_accept_domains=\n"); - fprintf(fp, "# cookie_reject_domains=\n\n"); - - /* - * cookie_accept_domains and cookie_reject_domains not set here because - * there's not currently a method on the options menu (maybe later?) - * to set them. - */ - -#ifdef EXP_PERSISTENT_COOKIES - /* - * Cookie file. - */ - fprintf(fp, "\ -# cookie_file specifies the file in which to store persistent cookies.\n\ -# The default is ~/.lynx_cookies.\n"); - fprintf(fp, "cookie_file=%s\n\n", - (LYCookieFile == NULL ? "~/.lynx_cookies" : LYCookieFile)); -#endif /* EXP_PERSISTENT_COOKIES */ - #if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) /* * Local execution mode - all links. */ fprintf(fp, "\ -# If run_all_execution_links is set \"on\" then all local execution links\n\ +# If run_all_execution_links is set \"on\" then all local exection links\n\ # will be executed when they are selected.\n\ #\n\ # WARNING - This is potentially VERY dangerous. Since you may view\n\ @@ -993,19 +901,24 @@ PUBLIC int save_rc NOPARAMS (local_exec_on_local_files ? "on" : "off")); #endif /* defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) */ - fprintf(fp, "\ -# If verbose_images is \"on\", lynx will print the name of the image\n\ -# source file in place of [INLINE], [LINK] or [IMAGE]\n\ -# See also VERBOSE_IMAGES in lynx.cfg\n"); - fprintf(fp, "verbose_images=%s\n\n", - verbose_img ? "on" : "off"); - /* * Close the RC file. */ fclose(fp); +#if defined(__DJGPP__) || defined(_WINDOWS) + _fmode = O_BINARY; +#endif /* __DJGPP__ or _WINDOWS */ - HTSYS_purge(rcfile); +#ifdef VMS + /* + * Get rid of any copies of the .lynxrc file that VMS creates. + */ + while (remove("sys$login:.lynxrc;-1") == 0) ; + /* + * Reset version number. + */ + rename("sys$login:.lynxrc", "sys$login:.lynxrc;1"); +#endif /* VMS */ - return TRUE; + return TRUE; } diff --git a/src/UCAuto.c b/src/UCAuto.c index a3584ecb..e5f11af9 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -15,7 +15,7 @@ */ #include <HTUtils.h> -#include <LYUtils.h> +#include <tcp.h> #include <UCMap.h> #include <UCDefs.h> @@ -26,6 +26,12 @@ #ifdef EXP_CHARTRANS_AUTOSWITCH +#ifdef VMS +#define DISPLAY "DECW$DISPLAY" +#else +#define DISPLAY "DISPLAY" +#endif /* VMS */ + #ifdef LINUX typedef enum { Is_Unset, Is_Set, Dunno, Dont_Care @@ -77,8 +83,10 @@ PRIVATE void call_setfont ARGS3( } if (*T_setfont_cmd) { - CTRACE(tfp, "Executing setfont: '%s'\n", T_setfont_cmd); - LYSystem(T_setfont_cmd); + if (TRACE) { + fprintf(stderr, "Executing setfont: '%s'\n", T_setfont_cmd); + } + system(T_setfont_cmd); } } @@ -99,7 +107,7 @@ PRIVATE int nonempty_file ARGS1( struct stat sb; return (stat(p, &sb) == 0 && - S_ISREG(sb.st_mode) && + (sb.st_mode & S_IFMT) == S_IFREG && (sb.st_size != 0)); } @@ -125,6 +133,7 @@ PUBLIC void UCChangeTerminalCodepage ARGS2( TGen_state_t HasUmap = Dunno; char tmpbuf1[100], tmpbuf2[20]; + char *cp; /* * Restore the original character set. @@ -143,7 +152,7 @@ PUBLIC void UCChangeTerminalCodepage ARGS2( sprintf(tmpbuf1, "%s %s %s", SETFONT, old_font, NOOUTPUT); } - LYSystem(tmpbuf1); + system(tmpbuf1); } remove(old_font); @@ -160,7 +169,7 @@ PUBLIC void UCChangeTerminalCodepage ARGS2( old_font = tempnam((char *)0, "font"); sprintf(tmpbuf1, "%s -o %s -ou %s %s", SETFONT, old_font, old_umap, NOOUTPUT); - LYSystem(tmpbuf1); + system(tmpbuf1); } name = p->MIMEname; @@ -176,8 +185,8 @@ PUBLIC void UCChangeTerminalCodepage ARGS2( /* * Use this for output of escape sequences. */ - if ((x_display != NULL) || - LYgetXDisplay() != NULL) { + if ((display != NULL) || + ((cp = getenv(DISPLAY)) != NULL && *cp != '\0')) { /* * We won't do anything in an xterm. Better that way... */ @@ -330,7 +339,10 @@ PUBLIC void UCChangeTerminalCodepage ARGS2( int, newcs, LYUCcharset *, p) { - CTRACE(tfp, "UCChangeTerminalCodepage: Called, but not implemented!"); + if (TRACE) { + fprintf(stderr, + "UCChangeTerminalCodepage: Called, but not implemented!"); + } } #endif /* LINUX */ @@ -342,6 +354,9 @@ PUBLIC void UCChangeTerminalCodepage ARGS2( int, newcs GCC_UNUSED, LYUCcharset *, p GCC_UNUSED) { - CTRACE(tfp, "UCChangeTerminalCodepage: Called, but not implemented!"); + if (TRACE) { + fprintf(stderr, + "UCChangeTerminalCodepage: Called, but not implemented!"); + } } #endif /* EXP_CHARTRANS_AUTOSWITCH */ diff --git a/src/UCAuto.h b/src/UCAuto.h index e9f1681e..b4d582c3 100644 --- a/src/UCAuto.h +++ b/src/UCAuto.h @@ -1,8 +1,7 @@ + #ifndef UCAUTO_H #define UCAUTO_H -#include <UCDefs.h> - extern void UCChangeTerminalCodepage PARAMS((int newcs, LYUCcharset *p)); #endif /* UCAUTO_H */ diff --git a/src/UCAux.c b/src/UCAux.c index 6847b150..3a8bc56d 100644 --- a/src/UCAux.c +++ b/src/UCAux.c @@ -1,4 +1,5 @@ #include <HTUtils.h> +#include <tcp.h> #include <HTCJK.h> #include <UCDefs.h> @@ -37,9 +38,9 @@ PUBLIC BOOL UCCanTranslateFromTo ARGS2( return YES; if (from < 0 || to < 0) return NO; - if (from == LATIN1) + if (from == 0) return UCCanTranslateUniTo(to); - if (to == LATIN1 || LYCharSet_UC[to].enc == UCT_ENC_UTF8) + if (to == 0 || LYCharSet_UC[to].enc == UCT_ENC_UTF8) return UCCanUniTranslateFrom(from); { CONST char * fromname = LYCharSet_UC[from].MIMEname; @@ -102,7 +103,7 @@ PUBLIC BOOL UCNeedNotTranslate ARGS2( } if (to < 0) return NO; /* ??? */ - if (to == LATIN1) { + if (to == 0) { if (LYCharSet_UC[from].codepoints & (UCT_CP_SUBSETOF_LAT1)) return YES; } @@ -113,7 +114,7 @@ PUBLIC BOOL UCNeedNotTranslate ARGS2( if (LYCharSet_UC[to].enc == UCT_ENC_UTF8) { return NO; } - if (from == LATIN1) { + if (from == 0) { if (LYCharSet_UC[from].codepoints & (UCT_CP_SUPERSETOF_LAT1)) return YES; } @@ -121,7 +122,14 @@ PUBLIC BOOL UCNeedNotTranslate ARGS2( if (HTCJK == NOCJK) /* Use that global flag, for now. */ return NO; if (HTCJK == JAPANESE && + /* + ** Always strip the "x-" from "x-euc-jp", + ** or convert "x-shift-jis" to "shift_jis", + ** before calling this function, and so + ** don't check for them here. - FM + */ (!strcmp(fromname, "euc-jp") || + !strncmp(fromname, "iso-2022-jp",11) || !strcmp(fromname, "shift_jis"))) return YES; /* ??? */ return NO; /* If not handled by (from == to) above. */ @@ -178,7 +186,7 @@ PUBLIC void UCSetTransParams ARGS5( pT->trans_C0_to_uni = (p_in->enc == UCT_ENC_8BIT_C0 || p_out->enc == UCT_ENC_8BIT_C0); } else { - /* + /* ** Initialize local flags. - FM */ BOOL intm_ucs = FALSE; @@ -215,7 +223,7 @@ PUBLIC void UCSetTransParams ARGS5( ** equivalent to them, i.e. if we have UCS without ** having to do a table translation. */ - intm_ucs = (cs_in == LATIN1 || pT->decode_utf8 || + intm_ucs = (cs_in == 0 || pT->decode_utf8 || (p_in->codepoints & (UCT_CP_SUBSETOF_LAT1|UCT_CP_SUBSETOF_UCS2))); /* @@ -270,7 +278,7 @@ PUBLIC void UCSetTransParams ARGS5( */ pT->use_raw_char_in = (!pT->output_utf8 && cs_in == cs_out && - !pT->trans_C0_to_uni); + !pT->trans_C0_to_uni); /* ** This should be set TRUE when we expect to have ** done translation to Unicode or had the equivalent @@ -405,7 +413,7 @@ PUBLIC BOOL UCConvertUniToUtf8 ARGS2( if (code <= 0 || code > 0x7fffffffL) { *ch = '\0'; - return NO; + return NO; } if (code < 0x800L) { diff --git a/src/UCdomap.c b/src/UCdomap.c index 4a579f34..20d78e92 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -15,6 +15,7 @@ * aeb, 950210 */ #include <HTUtils.h> +#include <tcp.h> #include <HTMLDTD.h> #include <LYGlobalDefs.h> @@ -23,7 +24,6 @@ #include <UCMap.h> #include <UCDefs.h> #include <LYCharSets.h> -#include <LYStrings.h> /* * Include tables & parameters. @@ -67,6 +67,8 @@ #include <mnem_suni.h> #endif /* NOTDEFINED */ +#define FREE(x) if (x) {free(x); x = NULL;} + /* * Some of the code below, and some of the comments, are left in for * historical reasons. Not all those tables below are currently @@ -263,7 +265,7 @@ PRIVATE int con_insert_unipair PARAMS(( int fordefault)); PRIVATE int con_insert_unipair_str PARAMS(( u16 unicode, - CONST char * replace_str, + char * replace_str, int fordefault)); PRIVATE void con_clear_unimap PARAMS(( int fordefault)); @@ -304,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 CONST char ** UC_setup_LYCharSets_repl PARAMS(( +PRIVATE char ** UC_setup_LYCharSets_repl PARAMS(( int UC_charset_in_hndl, unsigned lowest8)); PRIVATE int UC_Register_with_LYCharSets PARAMS(( @@ -471,7 +473,8 @@ PRIVATE void UC_con_set_trans ARGS3( u16 *ptrans; if (!UC_valid_UC_charset(UC_charset_in_hndl)) { - CTRACE(tfp, "UC_con_set_trans: Invalid charset handle %d.\n", + if (TRACE) + fprintf(stderr, "UC_con_set_trans: Invalid charset handle %d.\n", UC_charset_in_hndl); return; } @@ -600,12 +603,11 @@ PRIVATE int con_insert_unipair ARGS3( PRIVATE int con_insert_unipair_str ARGS3( u16, unicode, - CONST char *, replace_str, + char *, replace_str, int, fordefault) { int i, n; - char ***p1; - CONST char **p2; + char ***p1, **p2; if(fordefault) p1 = unidefault_pagedir_str[n = unicode >> 11]; @@ -625,18 +627,15 @@ PRIVATE int con_insert_unipair_str ARGS3( } } - n = ((unicode >> 6) & 0x1f); - if (!p1[n]) { - p1[n] = (char **)malloc(64*sizeof(char *)); - if (!p1[n]) + if (!(p2 = p1[n = (unicode >> 6) & 0x1f])) { + p2 = p1[n] = (char* *)malloc(64*sizeof(char *)); + if (!p2) 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; @@ -783,7 +782,8 @@ PRIVATE int UC_con_set_unimap ARGS2( u16 *p; if (!UC_valid_UC_charset(UC_charset_out_hndl)) { - CTRACE(tfp, "UC_con_set_unimap: Invalid charset handle %d.\n", + if (TRACE) + fprintf(stderr, "UC_con_set_unimap: Invalid charset handle %d.\n", UC_charset_out_hndl); return -1; } @@ -896,7 +896,7 @@ PRIVATE int conv_uni_to_pc ARGS2( * Not a printable character. */ return -1; - } else if (ucs == 0xfeff || (ucs >= 0x200b && ucs <= 0x200f)) { + } else if (ucs == 0xfeff || (ucs >= 0x200a && ucs <= 0x200f)) { /* * Zero-width space. */ @@ -961,7 +961,7 @@ PRIVATE int conv_uni_to_str ARGS4( * Not a printable character. */ return -1; - } else if (ucs == 0xfeff || (ucs >= 0x200b && ucs <= 0x200f)) { + } else if (ucs == 0xfeff || (ucs >= 0x200a && ucs <= 0x200f)) { /* * Zero-width space. */ @@ -1190,8 +1190,11 @@ PRIVATE int UC_MapGN ARGS2( UCInfo[UChndl].GN = Gn; UC_GNhandles[Gn] = UChndl; } - CTRACE(tfp, "UC_MapGN: Using %d <- %d (%s)\n", + if (TRACE) { + fprintf(stderr, + "UC_MapGN: Using %d <- %d (%s)\n", Gn, UChndl, UCInfo[UChndl].MIMEname); + } UC_con_set_trans(UChndl,Gn,update_flag); return Gn; } @@ -1275,7 +1278,7 @@ PUBLIC long int UCTransToUni ARGS2( ch_iu = (unsigned char)ch_in; #ifndef UC_NO_SHORTCUTS - if (charset_in == LATIN1) + if (charset_in == 0) return ch_iu; if ((unsigned char)ch_in < 128 && (unsigned char)ch_in >= 32) return ch_iu; @@ -1503,34 +1506,27 @@ PUBLIC int UCGetRawUniMode_byLYhndl ARGS1( } /* - * Get Lynx internal charset handler from MIME name, - * return -1 if we got NULL or did not recognize value. - * According to RFC, MIME headers should match case-insensitively. + * Currently the charset name has to match exactly -- not substring + * matching as was done before (see HTMIME.c, HTML.c). */ PUBLIC int UCGetLYhndl_byMIME ARGS1( - CONST char *, value) + CONST char *, UC_MIMEcharset) { int i; int LYhndl = -1; - char *UC_MIMEcharset = NULL; - if (!value || !(*value)) { - CTRACE(tfp, "UCGetLYhndl_byMIME: NULL argument instead of MIME name.\n"); + if (!UC_MIMEcharset || !(*UC_MIMEcharset)) return -1; - } - - StrAllocCopy(UC_MIMEcharset, value); - LYLowerCase(UC_MIMEcharset); for (i = 0; (i < MAXCHARSETS && i < LYNumCharsets && - LYchar_set_names[i]); i++) { + LYchar_set_names[i] && LYhndl < 0); i++) { if (LYCharSet_UC[i].MIMEname && !strcmp(UC_MIMEcharset, LYCharSet_UC[i].MIMEname)) { - return i; + LYhndl = i; } } - { + if (LYhndl < 0) { /* * Not yet found, try synonyms. - FM */ @@ -1633,12 +1629,9 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1( } if (!strcmp(UC_MIMEcharset, "koi-8")) { /* accentsoft bugosity */ return UCGetLYhndl_byMIME("koi8-r"); - } + } } - /* no more synonyms if come here... */ - - CTRACE(tfp, "UCGetLYhndl_byMIME: unrecognized MIME name \"%s\"\n", value); - return -1; /* returns -1 if no charset found by that MIME name */ + return LYhndl; /* returns -1 if no charset found by that MIME name */ } /* @@ -1661,7 +1654,7 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1( /* * We need to remember which ones were allocated and which are static. */ -PRIVATE CONST char ** remember_allocated_LYCharSets[MAXCHARSETS]; +PRIVATE char ** remember_allocated_LYCharSets[MAXCHARSETS]; PRIVATE void UCreset_allocated_LYCharSets NOARGS { @@ -1683,17 +1676,17 @@ PRIVATE void UCfree_allocated_LYCharSets NOARGS } } -PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2( +PRIVATE char ** UC_setup_LYCharSets_repl ARGS2( int, UC_charset_in_hndl, unsigned, lowest8) { - CONST char **ISO_Latin1 = LYCharSets[0]; - CONST char **p; + char **ISO_Latin1 = LYCharSets[0]; + char **p; char **prepl; u16 *pp; - CONST char **tp; - CONST char *s7; - CONST char *s8; + char **tp; + char *s7; + char *s8; size_t i; int j, changed; u16 k; @@ -1702,7 +1695,7 @@ PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2( /* * Create a temporary table for reverse lookup of latin1 codes: */ - tp = (CONST char **)malloc(96 * sizeof(CONST char *)); + tp = (char **)malloc(96 * sizeof(char *)); if (!tp) return NULL; for (i = 0; i < 96; i++) @@ -1756,14 +1749,12 @@ PRIVATE CONST 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. */ - prepl = (char **)malloc(HTML_dtd.number_of_entities * sizeof(char *)); - if (!prepl) { + p = prepl = (char **)malloc(HTML_dtd.number_of_entities * sizeof(char *)); + if (!p) { FREE(tp); FREE(ti); - return 0; + return NULL; } - - p = (CONST char **)prepl; changed = 0; for (i = 0; i < HTML_dtd.number_of_entities; i++, p++) { /* @@ -1834,7 +1825,7 @@ PRIVATE CONST char ** UC_setup_LYCharSets_repl ARGS2( FREE(prepl); return NULL; } - return (CONST char **)prepl; + return prepl; } /* @@ -1846,61 +1837,70 @@ PRIVATE int UC_Register_with_LYCharSets ARGS4( CONST char *, UC_LYNXcharset, int, lowest_eightbit) { - int i, LYhndl, found; - CONST char **repl; + int i, LYhndl, found; + char **repl; - LYhndl = -1; + LYhndl = -1; if (LYNumCharsets == 0) { /* * Initialize here; so whoever changes * LYCharSets.c doesn't have to count... */ for (i = 0; (i < MAXCHARSETS) && LYchar_set_names[i]; i++) { - LYNumCharsets = i+1; + LYNumCharsets = i+1; } } /* - * Search by MIME name, (LYchar_set_names may differ...) + * Do different kinds of searches... + * Normally the first should find the match if there is one! */ for (i = 0; i < MAXCHARSETS && LYchar_set_names[i] && LYhndl < 0; i++) { + if (!strcmp(UC_LYNXcharset, LYchar_set_names[i])) { + LYhndl = i; + } + } + for (i = 0; i < MAXCHARSETS && LYchar_set_names[i] && LYhndl < 0; i++) { if (LYCharSet_UC[i].MIMEname && !strcmp(UC_MIMEcharset, LYCharSet_UC[i].MIMEname)) { LYhndl = i; } } - if (LYhndl < 0) { /* not found */ - found = 0; - if (LYNumCharsets >= MAXCHARSETS) { - CTRACE(tfp, "UC_Register_with_LYCharSets: Too many. Ignoring %s/%s.", + if (LYhndl < 0) { /* not found */ + found = 0; + if (LYNumCharsets >= MAXCHARSETS) { + if (TRACE) { + fprintf(stderr, + "UC_Register_with_LYCharSets: Too many. Ignoring %s/%s.", UC_MIMEcharset, UC_LYNXcharset); - return -1; - } + } + return -1; + } /* * Add to LYCharSets.c lists. */ LYhndl = LYNumCharsets; LYNumCharsets ++; - LYlowest_eightbit[LYhndl] = 999; - LYCharSets[LYhndl] = SevenBitApproximations; + LYlowest_eightbit[LYhndl] = 999; + LYCharSets[LYhndl] = SevenBitApproximations; /* * Hmm, try to be conservative here. */ LYchar_set_names[LYhndl] = UC_LYNXcharset; LYchar_set_names[LYhndl+1] = NULL; /* - * Terminating NULL may be looked for by Lynx code. - */ + * Terminating NULL may be looked for by Lynx code. + */ } else { found = 1; } - LYCharSet_UC[LYhndl].UChndl = s; + LYCharSet_UC[LYhndl].UChndl = s; /* * Can we just copy the pointer? Hope so... */ - LYCharSet_UC[LYhndl].MIMEname = UC_MIMEcharset; - LYCharSet_UC[LYhndl].enc = UCInfo[s].enc; + LYCharSet_UC[LYhndl].MIMEname = UC_MIMEcharset; + LYCharSet_UC[LYhndl].enc = UCInfo[s].enc; /* * @@@ We really SHOULD get more info from the table files, @@ -1908,22 +1908,22 @@ PRIVATE int UC_Register_with_LYCharSets ARGS4( * that info... For now, let's try it without. - KW */ if (lowest_eightbit < LYlowest_eightbit[LYhndl]) { - LYlowest_eightbit[LYhndl] = lowest_eightbit; + LYlowest_eightbit[LYhndl] = lowest_eightbit; } else if (lowest_eightbit > LYlowest_eightbit[LYhndl]) { - UCInfo[s].lowest_eight = LYlowest_eightbit[LYhndl]; + UCInfo[s].lowest_eight = LYlowest_eightbit[LYhndl]; } - if (!found && LYhndl > 0) { - repl = UC_setup_LYCharSets_repl(s,UCInfo[s].lowest_eight); - if (repl) { - LYCharSets[LYhndl] = repl; + if (!found && LYhndl > 0) { + repl = UC_setup_LYCharSets_repl(s,UCInfo[s].lowest_eight); + if (repl) { + LYCharSets[LYhndl] = repl; /* * Remember to FREE at exit. */ - remember_allocated_LYCharSets[LYhndl] = repl; - } + remember_allocated_LYCharSets[LYhndl]=repl; } - return LYhndl; + } + return LYhndl; } /* @@ -1956,8 +1956,10 @@ PUBLIC void UC_Charset_Setup ARGS8( s = found; } else { if (UCNumCharsets >= MAXCHARSETS) { - CTRACE(tfp, "UC_Charset_Setup: Too many. Ignoring %s/%s.", - UC_MIMEcharset, UC_LYNXcharset); + if (TRACE) { + fprintf(stderr, "UC_Charset_Setup: Too many. Ignoring %s/%s.", + UC_MIMEcharset, UC_LYNXcharset); + } return; } s = UCNumCharsets; @@ -2064,19 +2066,3 @@ PUBLIC void UCInit NOARGS * check function UCGetLYhndl_byMIME in this file. */ } - -/* - * Safe variant of UCGetLYhndl_byMIME, with blind recovery from typo - * in user input: lynx.cfg, userdefs.h, switches from command line. - */ -PUBLIC int safeUCGetLYhndl_byMIME ARGS1 (CONST char *, value) -{ - int i = UCGetLYhndl_byMIME(value); - - if (i == -1) { /* was user's typo or not yet recognized value */ - i = LATIN1; /* error recovery? */ - CTRACE(tfp, "safeUCGetLYhndl_byMIME: ISO-8859-1 assumed.\n"); - } - - return(i); -} diff --git a/src/UCdomap.h b/src/UCdomap.h index e0160953..a0ff36b3 100644 --- a/src/UCdomap.h +++ b/src/UCdomap.h @@ -1,9 +1,7 @@ + #ifndef UCDOMAP_H #define UCDOMAP_H -#include <HTUtils.h> -#include <UCkd.h> - /* * [old comments: - KW ] * consolemap.h @@ -31,7 +29,7 @@ extern void UC_Charset_Setup PARAMS(( int lowest_eight, int UC_rawuni)); -CONST char *UC_GNsetMIMEnames[4] = +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/Makefile.old b/src/chrtrans/Makefile.old index 42b49eec..0ca53fc2 100644 --- a/src/chrtrans/Makefile.old +++ b/src/chrtrans/Makefile.old @@ -30,7 +30,6 @@ TABLES= \ cp1257_uni.h \ cp437_uni.h \ cp737_uni.h \ - cp775_uni.h \ cp850_uni.h \ cp852_uni.h \ cp862_uni.h \ @@ -77,7 +76,6 @@ cp1256_uni.h: cp1256_uni.tbl makeuctb cp1257_uni.h: cp1257_uni.tbl makeuctb cp437_uni.h: cp437_uni.tbl makeuctb cp737_uni.h: cp737_uni.tbl makeuctb -cp775_uni.h: cp775_uni.tbl makeuctb cp850_uni.h: cp850_uni.tbl makeuctb cp852_uni.h: cp852_uni.tbl makeuctb cp862_uni.h: cp862_uni.tbl makeuctb diff --git a/src/chrtrans/README.format b/src/chrtrans/README.format index 636afd32..4ced0a14 100644 --- a/src/chrtrans/README.format +++ b/src/chrtrans/README.format @@ -26,7 +26,7 @@ b) directives: start with a keyword which may be abbreviated to one letter (first letter must be capitalized), followed by space and a value. Currently recognized: - + OptionName The name under which this should appear on the O)ptions screen in the list for Display Character Set @@ -53,7 +53,7 @@ c) character translation definitions: 0x41 U+0041 U+0391 ... and are used for "forward" translation (mapping this charset to Unicode) - AS WELL AS "back" translation (mapping Unicodes to an 8-bit + AS WELL AS "back" translation (mapping Unicodes to an 8-bit [incl. 7-bit ASCII] code). For the "forward" direction, only the first Unicode is used; for @@ -63,7 +63,7 @@ c) character translation definitions: The above example line would tell the chartrans mechanism: "For this charset, code position 65 [hex 0x41] contains Unicode U+0041 (LATIN CAPITAL LETTER A). For translation of Unicodes to - this charset, use byte value 65 [hex 0x41] for U+0041 (LATIN CAPITAL + this charset, use byte value 65 [hex 0x41] for U+0041 (LATIN CAPITAL LETTER A) as well as for U+0391 (GREEK CAPITAL LETTER ALPHA)." [Note that for bytes in the ASCII range 0x00-0x7F, the forward translations @@ -82,10 +82,6 @@ c) character translation definitions: * where <range> ::= <fontpos>-<fontpos> * and <unicode> ::= U+<h><h><h><h> * and <h> ::= <hexadecimal digit> - * - [Note that <fontpos> _without_ targets assumed notdefined, - so tables from ftp.unicode.org need no patching.] - d) string replacement definitions: @@ -93,10 +89,10 @@ d) string replacement definitions: U+00cd:I' - which would mean "Replace Unicode U+00cd (LATIN CAPITAL LETTER I WITH + which would mean "Replace Unicode U+00cd (LATIN CAPITAL LETTER I WITH ACUTE" with the string (consisting of two character) I' (if no other translation is available)." Please note that replacement definitions - in certain charset table will override ones from the Default table. + in certnain charset table will override ones from Default table. Note that everything after the ':' is currently taken VERBATIM, so careful with trailing blanks etc. @@ -115,7 +111,7 @@ d) string replacement definitions: Motivation: -- It is an extension of the format already in use for Linux (kernel, +- It is an extention of the format already in use for Linux (kernel, kbd package), those files can be used with some minimal editing. - It is easy to convert Unicode tables for other charsets, as they diff --git a/src/chrtrans/README.tables b/src/chrtrans/README.tables index 5993ccee..be6dac6a 100644 --- a/src/chrtrans/README.tables +++ b/src/chrtrans/README.tables @@ -1,13 +1,12 @@ -The translation table files in this directory were collected from -several sources (among them ftp://ftp.unicode.org, Linux kbd package, -ftp://dkuug.dk/) and are believed to be correct in their mappings, -but not checked in detail. The Unicode/UCS2 values -for some of the RFC 1345 Mnemonic codes are out of date, -a cleanup and update would be needed for serious use. -[See also http://czyborra.com/charsets/iso8859.html for codepages survey.] +The translation table files in this directory are _examples only_. +They were collected from several sources (among them ftp://ftp.unicode.org, +Linux kbd package, ftp://dkuug.dk/) and are believed to be correct +in their mappings, but not checked in detail. The Unicode/UCS2 values +for some of the RFC 1345 Mnemonic codes are out of date, a cleanup and +update would be needed for serious use. More translation files can be easily provided (and new character entities -added to entities.h), this set is just to test whether the system works +added to entities.h), this set is just to test whether the system works in principle (and also how it behaves with incomplete data...) See the file README.format for a brief explanation of what's in the @@ -28,7 +27,7 @@ charset known to Lynx) you currently have to manually edit UCdomap.c, in two places: a) Near the top, you will find a bunch of lines (some may be commented out) - + #include "<fn>.h" Add or comment out as you wish. But it is probably safest to leave the @@ -45,7 +44,7 @@ did under a)...) [The <something> is derived from the charset's MIME name. if in doubt, check the last lines of the corresponding ...uni.h file.] c) To let make automatically notice when you have changed one of the - table files, and automatically regenerate the *uni.h file(s), + table files, and automatically regenerate the *uni.h file(s), you also have to add any new tables to both src/Makefile *and* src/chrtrans/Makefile. Or, for auto-config, the equivalent files named makefile.in before running ./configure, or makefile after running diff --git a/src/chrtrans/UCkd.h b/src/chrtrans/UCkd.h index 104882d7..1e55716e 100644 --- a/src/chrtrans/UCkd.h +++ b/src/chrtrans/UCkd.h @@ -34,7 +34,7 @@ struct unipair { }; struct unipair_str { u16 unicode; - CONST char * replace_str; + char * replace_str; }; struct unimapdesc { u16 entry_ct; diff --git a/src/chrtrans/cp1250_uni.tbl b/src/chrtrans/cp1250_uni.tbl index 49ba9008..41e8581d 100644 --- a/src/chrtrans/cp1250_uni.tbl +++ b/src/chrtrans/cp1250_uni.tbl @@ -2,155 +2,280 @@ Mwindows-1250 #Name as a Display Charset (used on Options screen) -OEastern European (windows-1250) +OWinLatin2 (cp1250) # -# Name: cp1250 to Unicode table +# Name: cp1250_WinLatin2 to Unicode table # Unicode version: 2.0 # Table version: 2.00 # Table format: Format A -# Date: 04/15/98 -# -# Contact: cpxlate@microsoft.com -# +# Date: 04/24/96 +# Authors: Lori Brownell <loribr@microsoft.com> +# K.D. Chang <a-kchang@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp1250 code (in hex) +# Column #1 is the cp1250_WinLatin2 code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # -# The entries are in cp1250 order +# The entries are in cp1250_WinLatin2 order # -################## +#0x00 U+0000 #NULL +#0x01 U+0001 #START OF HEADING +#0x02 U+0002 #START OF TEXT +#0x03 U+0003 #END OF TEXT +#0x04 U+0004 #END OF TRANSMISSION +#0x05 U+0005 #ENQUIRY +#0x06 U+0006 #ACKNOWLEDGE +#0x07 U+0007 #BELL +#0x08 U+0008 #BACKSPACE +#0x09 U+0009 #HORIZONTAL TABULATION +#0x0A U+000A #LINE FEED +#0x0B U+000B #VERTICAL TABULATION +#0x0C U+000C #FORM FEED +#0x0D U+000D #CARRIAGE RETURN +#0x0E U+000E #SHIFT OUT +#0x0F U+000F #SHIFT IN +#0x10 U+0010 #DATA LINK ESCAPE +#0x11 U+0011 #DEVICE CONTROL ONE +#0x12 U+0012 #DEVICE CONTROL TWO +#0x13 U+0013 #DEVICE CONTROL THREE +#0x14 U+0014 #DEVICE CONTROL FOUR +#0x15 U+0015 #NEGATIVE ACKNOWLEDGE +#0x16 U+0016 #SYNCHRONOUS IDLE +#0x17 U+0017 #END OF TRANSMISSION BLOCK +#0x18 U+0018 #CANCEL +#0x19 U+0019 #END OF MEDIUM +#0x1A U+001A #SUBSTITUTE +#0x1B U+001B #ESCAPE +#0x1C U+001C #FILE SEPARATOR +#0x1D U+001D #GROUP SEPARATOR +#0x1E U+001E #RECORD SEPARATOR +#0x1F U+001F #UNIT SEPARATOR +0x20 U+0020 #SPACE +0x21 U+0021 #EXCLAMATION MARK +0x22 U+0022 #QUOTATION MARK +0x23 U+0023 #NUMBER SIGN +0x24 U+0024 #DOLLAR SIGN +0x25 U+0025 #PERCENT SIGN +0x26 U+0026 #AMPERSAND +0x27 U+0027 #APOSTROPHE +0x28 U+0028 #LEFT PARENTHESIS +0x29 U+0029 #RIGHT PARENTHESIS +0x2A U+002A #ASTERISK +0x2B U+002B #PLUS SIGN +0x2C U+002C #COMMA +0x2D U+002D #HYPHEN-MINUS +0x2E U+002E #FULL STOP +0x2F U+002F #SOLIDUS +0x30 U+0030 #DIGIT ZERO +0x31 U+0031 #DIGIT ONE +0x32 U+0032 #DIGIT TWO +0x33 U+0033 #DIGIT THREE +0x34 U+0034 #DIGIT FOUR +0x35 U+0035 #DIGIT FIVE +0x36 U+0036 #DIGIT SIX +0x37 U+0037 #DIGIT SEVEN +0x38 U+0038 #DIGIT EIGHT +0x39 U+0039 #DIGIT NINE +0x3A U+003A #COLON +0x3B U+003B #SEMICOLON +0x3C U+003C #LESS-THAN SIGN +0x3D U+003D #EQUALS SIGN +0x3E U+003E #GREATER-THAN SIGN +0x3F U+003F #QUESTION MARK +0x40 U+0040 #COMMERCIAL AT +0x41 U+0041 #LATIN CAPITAL LETTER A +0x42 U+0042 #LATIN CAPITAL LETTER B +0x43 U+0043 #LATIN CAPITAL LETTER C +0x44 U+0044 #LATIN CAPITAL LETTER D +0x45 U+0045 #LATIN CAPITAL LETTER E +0x46 U+0046 #LATIN CAPITAL LETTER F +0x47 U+0047 #LATIN CAPITAL LETTER G +0x48 U+0048 #LATIN CAPITAL LETTER H +0x49 U+0049 #LATIN CAPITAL LETTER I +0x4A U+004A #LATIN CAPITAL LETTER J +0x4B U+004B #LATIN CAPITAL LETTER K +0x4C U+004C #LATIN CAPITAL LETTER L +0x4D U+004D #LATIN CAPITAL LETTER M +0x4E U+004E #LATIN CAPITAL LETTER N +0x4F U+004F #LATIN CAPITAL LETTER O +0x50 U+0050 #LATIN CAPITAL LETTER P +0x51 U+0051 #LATIN CAPITAL LETTER Q +0x52 U+0052 #LATIN CAPITAL LETTER R +0x53 U+0053 #LATIN CAPITAL LETTER S +0x54 U+0054 #LATIN CAPITAL LETTER T +0x55 U+0055 #LATIN CAPITAL LETTER U +0x56 U+0056 #LATIN CAPITAL LETTER V +0x57 U+0057 #LATIN CAPITAL LETTER W +0x58 U+0058 #LATIN CAPITAL LETTER X +0x59 U+0059 #LATIN CAPITAL LETTER Y +0x5A U+005A #LATIN CAPITAL LETTER Z +0x5B U+005B #LEFT SQUARE BRACKET +0x5C U+005C #REVERSE SOLIDUS +0x5D U+005D #RIGHT SQUARE BRACKET +0x5E U+005E #CIRCUMFLEX ACCENT +0x5F U+005F #LOW LINE +0x60 U+0060 #GRAVE ACCENT +0x61 U+0061 #LATIN SMALL LETTER A +0x62 U+0062 #LATIN SMALL LETTER B +0x63 U+0063 #LATIN SMALL LETTER C +0x64 U+0064 #LATIN SMALL LETTER D +0x65 U+0065 #LATIN SMALL LETTER E +0x66 U+0066 #LATIN SMALL LETTER F +0x67 U+0067 #LATIN SMALL LETTER G +0x68 U+0068 #LATIN SMALL LETTER H +0x69 U+0069 #LATIN SMALL LETTER I +0x6A U+006A #LATIN SMALL LETTER J +0x6B U+006B #LATIN SMALL LETTER K +0x6C U+006C #LATIN SMALL LETTER L +0x6D U+006D #LATIN SMALL LETTER M +0x6E U+006E #LATIN SMALL LETTER N +0x6F U+006F #LATIN SMALL LETTER O +0x70 U+0070 #LATIN SMALL LETTER P +0x71 U+0071 #LATIN SMALL LETTER Q +0x72 U+0072 #LATIN SMALL LETTER R +0x73 U+0073 #LATIN SMALL LETTER S +0x74 U+0074 #LATIN SMALL LETTER T +0x75 U+0075 #LATIN SMALL LETTER U +0x76 U+0076 #LATIN SMALL LETTER V +0x77 U+0077 #LATIN SMALL LETTER W +0x78 U+0078 #LATIN SMALL LETTER X +0x79 U+0079 #LATIN SMALL LETTER Y +0x7A U+007A #LATIN SMALL LETTER Z +0x7B U+007B #LEFT CURLY BRACKET +0x7C U+007C #VERTICAL LINE +0x7D U+007D #RIGHT CURLY BRACKET +0x7E U+007E #TILDE +#0x7F U+007F #DELETE +#0x80 #UNDEFINED +#0x81 #UNDEFINED +0x82 U+201A #SINGLE LOW-9 QUOTATION MARK +#0x83 #UNDEFINED +0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK +0x85 U+2026 #HORIZONTAL ELLIPSIS +0x86 U+2020 #DAGGER +0x87 U+2021 #DOUBLE DAGGER +#0x88 #UNDEFINED +0x89 U+2030 #PER MILLE SIGN +0x8A U+0160 #LATIN CAPITAL LETTER S WITH CARON +0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK +0x8C U+015A #LATIN CAPITAL LETTER S WITH ACUTE +0x8D U+0164 #LATIN CAPITAL LETTER T WITH CARON +0x8E U+017D #LATIN CAPITAL LETTER Z WITH CARON +0x8F U+0179 #LATIN CAPITAL LETTER Z WITH ACUTE +#0x90 #UNDEFINED +0x91 U+2018 #LEFT SINGLE QUOTATION MARK +0x92 U+2019 #RIGHT SINGLE QUOTATION MARK +0x93 U+201C #LEFT DOUBLE QUOTATION MARK +0x94 U+201D #RIGHT DOUBLE QUOTATION MARK +0x95 U+2022 #BULLET +0x96 U+2013 #EN DASH +0x97 U+2014 #EM DASH +#0x98 #UNDEFINED +0x99 U+2122 #TRADE MARK SIGN +0x9A U+0161 #LATIN SMALL LETTER S WITH CARON +0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK +0x9C U+015B #LATIN SMALL LETTER S WITH ACUTE +0x9D U+0165 #LATIN SMALL LETTER T WITH CARON +0x9E U+017E #LATIN SMALL LETTER Z WITH CARON +0x9F U+017A #LATIN SMALL LETTER Z WITH ACUTE +0xA0 U+00A0 #NO-BREAK SPACE +0xA1 U+02C7 #CARON +0xA2 U+02D8 #BREVE +0xA3 U+0141 #LATIN CAPITAL LETTER L WITH STROKE +0xA4 U+00A4 #CURRENCY SIGN +0xA5 U+0104 #LATIN CAPITAL LETTER A WITH OGONEK +0xA6 U+00A6 #BROKEN BAR +0xA7 U+00A7 #SECTION SIGN +0xA8 U+00A8 #DIAERESIS +0xA9 U+00A9 #COPYRIGHT SIGN +0xAA U+015E #LATIN CAPITAL LETTER S WITH CEDILLA +0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +#0xAC #UNDEFINED +0xAD U+00AD #SOFT HYPHEN +0xAE U+00AE #REGISTERED SIGN +0xAF U+017B #LATIN CAPITAL LETTER Z WITH DOT ABOVE +0xB0 U+00B0 #DEGREE SIGN +0xB1 U+00B1 #PLUS-MINUS SIGN +0xB2 U+02DB #OGONEK +0xB3 U+0142 #LATIN SMALL LETTER L WITH STROKE +0xB4 U+00B4 #ACUTE ACCENT +0xB5 U+00B5 #MICRO SIGN +0xB6 U+00B6 #PILCROW SIGN +0xB7 U+00B7 #MIDDLE DOT +0xB8 U+00B8 #CEDILLA +0xB9 U+0105 #LATIN SMALL LETTER A WITH OGONEK +0xBA U+015F #LATIN SMALL LETTER S WITH CEDILLA +0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +0xBC U+013D #LATIN CAPITAL LETTER L WITH CARON +0xBD U+02DD #DOUBLE ACUTE ACCENT +0xBE U+013E #LATIN SMALL LETTER L WITH CARON +0xBF U+017C #LATIN SMALL LETTER Z WITH DOT ABOVE +0xC0 U+0154 #LATIN CAPITAL LETTER R WITH ACUTE +0xC1 U+00C1 #LATIN CAPITAL LETTER A WITH ACUTE +0xC2 U+00C2 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX +0xC3 U+0102 #LATIN CAPITAL LETTER A WITH BREVE +0xC4 U+00C4 #LATIN CAPITAL LETTER A WITH DIAERESIS +0xC5 U+0139 #LATIN CAPITAL LETTER L WITH ACUTE +0xC6 U+0106 #LATIN CAPITAL LETTER C WITH ACUTE +0xC7 U+00C7 #LATIN CAPITAL LETTER C WITH CEDILLA +0xC8 U+010C #LATIN CAPITAL LETTER C WITH CARON +0xC9 U+00C9 #LATIN CAPITAL LETTER E WITH ACUTE +0xCA U+0118 #LATIN CAPITAL LETTER E WITH OGONEK +0xCB U+00CB #LATIN CAPITAL LETTER E WITH DIAERESIS +0xCC U+011A #LATIN CAPITAL LETTER E WITH CARON +0xCD U+00CD #LATIN CAPITAL LETTER I WITH ACUTE +0xCE U+00CE #LATIN CAPITAL LETTER I WITH CIRCUMFLEX +0xCF U+010E #LATIN CAPITAL LETTER D WITH CARON +0xD0 U+0110 #LATIN CAPITAL LETTER D WITH STROKE +0xD1 U+0143 #LATIN CAPITAL LETTER N WITH ACUTE +0xD2 U+0147 #LATIN CAPITAL LETTER N WITH CARON +0xD3 U+00D3 #LATIN CAPITAL LETTER O WITH ACUTE +0xD4 U+00D4 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX +0xD5 U+0150 #LATIN CAPITAL LETTER O WITH DOUBLE ACUTE +0xD6 U+00D6 #LATIN CAPITAL LETTER O WITH DIAERESIS +0xD7 U+00D7 #MULTIPLICATION SIGN +0xD8 U+0158 #LATIN CAPITAL LETTER R WITH CARON +0xD9 U+016E #LATIN CAPITAL LETTER U WITH RING ABOVE +0xDA U+00DA #LATIN CAPITAL LETTER U WITH ACUTE +0xDB U+0170 #LATIN CAPITAL LETTER U WITH DOUBLE ACUTE +0xDC U+00DC #LATIN CAPITAL LETTER U WITH DIAERESIS +0xDD U+00DD #LATIN CAPITAL LETTER Y WITH ACUTE +0xDE U+0162 #LATIN CAPITAL LETTER T WITH CEDILLA +0xDF U+00DF #LATIN SMALL LETTER SHARP S +0xE0 U+0155 #LATIN SMALL LETTER R WITH ACUTE +0xE1 U+00E1 #LATIN SMALL LETTER A WITH ACUTE +0xE2 U+00E2 #LATIN SMALL LETTER A WITH CIRCUMFLEX +0xE3 U+0103 #LATIN SMALL LETTER A WITH BREVE +0xE4 U+00E4 #LATIN SMALL LETTER A WITH DIAERESIS +0xE5 U+013A #LATIN SMALL LETTER L WITH ACUTE +0xE6 U+0107 #LATIN SMALL LETTER C WITH ACUTE +0xE7 U+00E7 #LATIN SMALL LETTER C WITH CEDILLA +0xE8 U+010D #LATIN SMALL LETTER C WITH CARON +0xE9 U+00E9 #LATIN SMALL LETTER E WITH ACUTE +0xEA U+0119 #LATIN SMALL LETTER E WITH OGONEK +0xEB U+00EB #LATIN SMALL LETTER E WITH DIAERESIS +0xEC U+011B #LATIN SMALL LETTER E WITH CARON +0xED U+00ED #LATIN SMALL LETTER I WITH ACUTE +0xEE U+00EE #LATIN SMALL LETTER I WITH CIRCUMFLEX +0xEF U+010F #LATIN SMALL LETTER D WITH CARON +0xF0 U+0111 #LATIN SMALL LETTER D WITH STROKE +0xF1 U+0144 #LATIN SMALL LETTER N WITH ACUTE +0xF2 U+0148 #LATIN SMALL LETTER N WITH CARON +0xF3 U+00F3 #LATIN SMALL LETTER O WITH ACUTE +0xF4 U+00F4 #LATIN SMALL LETTER O WITH CIRCUMFLEX +0xF5 U+0151 #LATIN SMALL LETTER O WITH DOUBLE ACUTE +0xF6 U+00F6 #LATIN SMALL LETTER O WITH DIAERESIS +0xF7 U+00F7 #DIVISION SIGN +0xF8 U+0159 #LATIN SMALL LETTER R WITH CARON +0xF9 U+016F #LATIN SMALL LETTER U WITH RING ABOVE +0xFA U+00FA #LATIN SMALL LETTER U WITH ACUTE +0xFB U+0171 #LATIN SMALL LETTER U WITH DOUBLE ACUTE +0xFC U+00FC #LATIN SMALL LETTER U WITH DIAERESIS +0xFD U+00FD #LATIN SMALL LETTER Y WITH ACUTE +0xFE U+0163 #LATIN SMALL LETTER T WITH CEDILLA +0xFF U+02D9 #DOT ABOVE + -0x20-0x7e idem -# -0x80 U+20AC #EURO SIGN -0x81 #UNDEFINED -0x82 U+201A #SINGLE LOW-9 QUOTATION MARK -0x83 #UNDEFINED -0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK -0x85 U+2026 #HORIZONTAL ELLIPSIS -0x86 U+2020 #DAGGER -0x87 U+2021 #DOUBLE DAGGER -0x88 #UNDEFINED -0x89 U+2030 #PER MILLE SIGN -0x8A U+0160 #LATIN CAPITAL LETTER S WITH CARON -0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK -0x8C U+015A #LATIN CAPITAL LETTER S WITH ACUTE -0x8D U+0164 #LATIN CAPITAL LETTER T WITH CARON -0x8E U+017D #LATIN CAPITAL LETTER Z WITH CARON -0x8F U+0179 #LATIN CAPITAL LETTER Z WITH ACUTE -0x90 #UNDEFINED -0x91 U+2018 #LEFT SINGLE QUOTATION MARK -0x92 U+2019 #RIGHT SINGLE QUOTATION MARK -0x93 U+201C #LEFT DOUBLE QUOTATION MARK -0x94 U+201D #RIGHT DOUBLE QUOTATION MARK -0x95 U+2022 #BULLET -0x96 U+2013 #EN DASH -0x97 U+2014 #EM DASH -0x98 #UNDEFINED -0x99 U+2122 #TRADE MARK SIGN -0x9A U+0161 #LATIN SMALL LETTER S WITH CARON -0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -0x9C U+015B #LATIN SMALL LETTER S WITH ACUTE -0x9D U+0165 #LATIN SMALL LETTER T WITH CARON -0x9E U+017E #LATIN SMALL LETTER Z WITH CARON -0x9F U+017A #LATIN SMALL LETTER Z WITH ACUTE -0xA0 U+00A0 #NO-BREAK SPACE -0xA1 U+02C7 #CARON -0xA2 U+02D8 #BREVE -0xA3 U+0141 #LATIN CAPITAL LETTER L WITH STROKE -0xA4 U+00A4 #CURRENCY SIGN -0xA5 U+0104 #LATIN CAPITAL LETTER A WITH OGONEK -0xA6 U+00A6 #BROKEN BAR -0xA7 U+00A7 #SECTION SIGN -0xA8 U+00A8 #DIAERESIS -0xA9 U+00A9 #COPYRIGHT SIGN -0xAA U+015E #LATIN CAPITAL LETTER S WITH CEDILLA -0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK -0xAC U+00AC #NOT SIGN -0xAD U+00AD #SOFT HYPHEN -0xAE U+00AE #REGISTERED SIGN -0xAF U+017B #LATIN CAPITAL LETTER Z WITH DOT ABOVE -0xB0 U+00B0 #DEGREE SIGN -0xB1 U+00B1 #PLUS-MINUS SIGN -0xB2 U+02DB #OGONEK -0xB3 U+0142 #LATIN SMALL LETTER L WITH STROKE -0xB4 U+00B4 #ACUTE ACCENT -0xB5 U+00B5 #MICRO SIGN -0xB6 U+00B6 #PILCROW SIGN -0xB7 U+00B7 #MIDDLE DOT -0xB8 U+00B8 #CEDILLA -0xB9 U+0105 #LATIN SMALL LETTER A WITH OGONEK -0xBA U+015F #LATIN SMALL LETTER S WITH CEDILLA -0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -0xBC U+013D #LATIN CAPITAL LETTER L WITH CARON -0xBD U+02DD #DOUBLE ACUTE ACCENT -0xBE U+013E #LATIN SMALL LETTER L WITH CARON -0xBF U+017C #LATIN SMALL LETTER Z WITH DOT ABOVE -0xC0 U+0154 #LATIN CAPITAL LETTER R WITH ACUTE -0xC1 U+00C1 #LATIN CAPITAL LETTER A WITH ACUTE -0xC2 U+00C2 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX -0xC3 U+0102 #LATIN CAPITAL LETTER A WITH BREVE -0xC4 U+00C4 #LATIN CAPITAL LETTER A WITH DIAERESIS -0xC5 U+0139 #LATIN CAPITAL LETTER L WITH ACUTE -0xC6 U+0106 #LATIN CAPITAL LETTER C WITH ACUTE -0xC7 U+00C7 #LATIN CAPITAL LETTER C WITH CEDILLA -0xC8 U+010C #LATIN CAPITAL LETTER C WITH CARON -0xC9 U+00C9 #LATIN CAPITAL LETTER E WITH ACUTE -0xCA U+0118 #LATIN CAPITAL LETTER E WITH OGONEK -0xCB U+00CB #LATIN CAPITAL LETTER E WITH DIAERESIS -0xCC U+011A #LATIN CAPITAL LETTER E WITH CARON -0xCD U+00CD #LATIN CAPITAL LETTER I WITH ACUTE -0xCE U+00CE #LATIN CAPITAL LETTER I WITH CIRCUMFLEX -0xCF U+010E #LATIN CAPITAL LETTER D WITH CARON -0xD0 U+0110 #LATIN CAPITAL LETTER D WITH STROKE -0xD1 U+0143 #LATIN CAPITAL LETTER N WITH ACUTE -0xD2 U+0147 #LATIN CAPITAL LETTER N WITH CARON -0xD3 U+00D3 #LATIN CAPITAL LETTER O WITH ACUTE -0xD4 U+00D4 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX -0xD5 U+0150 #LATIN CAPITAL LETTER O WITH DOUBLE ACUTE -0xD6 U+00D6 #LATIN CAPITAL LETTER O WITH DIAERESIS -0xD7 U+00D7 #MULTIPLICATION SIGN -0xD8 U+0158 #LATIN CAPITAL LETTER R WITH CARON -0xD9 U+016E #LATIN CAPITAL LETTER U WITH RING ABOVE -0xDA U+00DA #LATIN CAPITAL LETTER U WITH ACUTE -0xDB U+0170 #LATIN CAPITAL LETTER U WITH DOUBLE ACUTE -0xDC U+00DC #LATIN CAPITAL LETTER U WITH DIAERESIS -0xDD U+00DD #LATIN CAPITAL LETTER Y WITH ACUTE -0xDE U+0162 #LATIN CAPITAL LETTER T WITH CEDILLA -0xDF U+00DF #LATIN SMALL LETTER SHARP S -0xE0 U+0155 #LATIN SMALL LETTER R WITH ACUTE -0xE1 U+00E1 #LATIN SMALL LETTER A WITH ACUTE -0xE2 U+00E2 #LATIN SMALL LETTER A WITH CIRCUMFLEX -0xE3 U+0103 #LATIN SMALL LETTER A WITH BREVE -0xE4 U+00E4 #LATIN SMALL LETTER A WITH DIAERESIS -0xE5 U+013A #LATIN SMALL LETTER L WITH ACUTE -0xE6 U+0107 #LATIN SMALL LETTER C WITH ACUTE -0xE7 U+00E7 #LATIN SMALL LETTER C WITH CEDILLA -0xE8 U+010D #LATIN SMALL LETTER C WITH CARON -0xE9 U+00E9 #LATIN SMALL LETTER E WITH ACUTE -0xEA U+0119 #LATIN SMALL LETTER E WITH OGONEK -0xEB U+00EB #LATIN SMALL LETTER E WITH DIAERESIS -0xEC U+011B #LATIN SMALL LETTER E WITH CARON -0xED U+00ED #LATIN SMALL LETTER I WITH ACUTE -0xEE U+00EE #LATIN SMALL LETTER I WITH CIRCUMFLEX -0xEF U+010F #LATIN SMALL LETTER D WITH CARON -0xF0 U+0111 #LATIN SMALL LETTER D WITH STROKE -0xF1 U+0144 #LATIN SMALL LETTER N WITH ACUTE -0xF2 U+0148 #LATIN SMALL LETTER N WITH CARON -0xF3 U+00F3 #LATIN SMALL LETTER O WITH ACUTE -0xF4 U+00F4 #LATIN SMALL LETTER O WITH CIRCUMFLEX -0xF5 U+0151 #LATIN SMALL LETTER O WITH DOUBLE ACUTE -0xF6 U+00F6 #LATIN SMALL LETTER O WITH DIAERESIS -0xF7 U+00F7 #DIVISION SIGN -0xF8 U+0159 #LATIN SMALL LETTER R WITH CARON -0xF9 U+016F #LATIN SMALL LETTER U WITH RING ABOVE -0xFA U+00FA #LATIN SMALL LETTER U WITH ACUTE -0xFB U+0171 #LATIN SMALL LETTER U WITH DOUBLE ACUTE -0xFC U+00FC #LATIN SMALL LETTER U WITH DIAERESIS -0xFD U+00FD #LATIN SMALL LETTER Y WITH ACUTE -0xFE U+0163 #LATIN SMALL LETTER T WITH CEDILLA -0xFF U+02D9 #DOT ABOVE diff --git a/src/chrtrans/cp1251_uni.tbl b/src/chrtrans/cp1251_uni.tbl index 541f8640..e9bb9460 100644 --- a/src/chrtrans/cp1251_uni.tbl +++ b/src/chrtrans/cp1251_uni.tbl @@ -2,155 +2,153 @@ Mwindows-1251 #Name as a Display Charset (used on Options screen) -OCyrillic (windows-1251) +OWinCyrillic (cp1251) # -# Name: cp1251 to Unicode table +# Name: cp1251_WinCyrillic to Unicode table # Unicode version: 2.0 # Table version: 2.00 # Table format: Format A -# Date: 04/15/98 -# -# Contact: cpxlate@microsoft.com -# +# Date: 04/24/96 +# Authors: Lori Brownell <loribr@microsoft.com> +# K.D. Chang <a-kchang@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp1251 code (in hex) +# Column #1 is the cp1251_WinCyrillic code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # -# The entries are in cp1251 order +# The entries are in cp1251_WinCyrillic order # -################## - -0x20-0x7e idem # -0x80 U+0402 #CYRILLIC CAPITAL LETTER DJE -0x81 U+0403 #CYRILLIC CAPITAL LETTER GJE -0x82 U+201A #SINGLE LOW-9 QUOTATION MARK -0x83 U+0453 #CYRILLIC SMALL LETTER GJE -0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK -0x85 U+2026 #HORIZONTAL ELLIPSIS -0x86 U+2020 #DAGGER -0x87 U+2021 #DOUBLE DAGGER -0x88 U+20AC #EURO SIGN -0x89 U+2030 #PER MILLE SIGN -0x8A U+0409 #CYRILLIC CAPITAL LETTER LJE -0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK -0x8C U+040A #CYRILLIC CAPITAL LETTER NJE -0x8D U+040C #CYRILLIC CAPITAL LETTER KJE -0x8E U+040B #CYRILLIC CAPITAL LETTER TSHE -0x8F U+040F #CYRILLIC CAPITAL LETTER DZHE -0x90 U+0452 #CYRILLIC SMALL LETTER DJE -0x91 U+2018 #LEFT SINGLE QUOTATION MARK -0x92 U+2019 #RIGHT SINGLE QUOTATION MARK -0x93 U+201C #LEFT DOUBLE QUOTATION MARK -0x94 U+201D #RIGHT DOUBLE QUOTATION MARK -0x95 U+2022 #BULLET -0x96 U+2013 #EN DASH -0x97 U+2014 #EM DASH -0x98 #UNDEFINED -0x99 U+2122 #TRADE MARK SIGN -0x9A U+0459 #CYRILLIC SMALL LETTER LJE -0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -0x9C U+045A #CYRILLIC SMALL LETTER NJE -0x9D U+045C #CYRILLIC SMALL LETTER KJE -0x9E U+045B #CYRILLIC SMALL LETTER TSHE -0x9F U+045F #CYRILLIC SMALL LETTER DZHE -0xA0 U+00A0 #NO-BREAK SPACE -0xA1 U+040E #CYRILLIC CAPITAL LETTER SHORT U -0xA2 U+045E #CYRILLIC SMALL LETTER SHORT U -0xA3 U+0408 #CYRILLIC CAPITAL LETTER JE -0xA4 U+00A4 #CURRENCY SIGN -0xA5 U+0490 #CYRILLIC CAPITAL LETTER GHE WITH UPTURN -0xA6 U+00A6 #BROKEN BAR -0xA7 U+00A7 #SECTION SIGN -0xA8 U+0401 #CYRILLIC CAPITAL LETTER IO -0xA9 U+00A9 #COPYRIGHT SIGN -0xAA U+0404 #CYRILLIC CAPITAL LETTER UKRAINIAN IE -0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK -0xAC U+00AC #NOT SIGN -0xAD U+00AD #SOFT HYPHEN -0xAE U+00AE #REGISTERED SIGN -0xAF U+0407 #CYRILLIC CAPITAL LETTER YI -0xB0 U+00B0 #DEGREE SIGN -0xB1 U+00B1 #PLUS-MINUS SIGN -0xB2 U+0406 #CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I -0xB3 U+0456 #CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I -0xB4 U+0491 #CYRILLIC SMALL LETTER GHE WITH UPTURN -0xB5 U+00B5 #MICRO SIGN -0xB6 U+00B6 #PILCROW SIGN -0xB7 U+00B7 #MIDDLE DOT -0xB8 U+0451 #CYRILLIC SMALL LETTER IO -0xB9 U+2116 #NUMERO SIGN -0xBA U+0454 #CYRILLIC SMALL LETTER UKRAINIAN IE -0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -0xBC U+0458 #CYRILLIC SMALL LETTER JE -0xBD U+0405 #CYRILLIC CAPITAL LETTER DZE -0xBE U+0455 #CYRILLIC SMALL LETTER DZE -0xBF U+0457 #CYRILLIC SMALL LETTER YI -0xC0 U+0410 #CYRILLIC CAPITAL LETTER A -0xC1 U+0411 #CYRILLIC CAPITAL LETTER BE -0xC2 U+0412 #CYRILLIC CAPITAL LETTER VE -0xC3 U+0413 #CYRILLIC CAPITAL LETTER GHE -0xC4 U+0414 #CYRILLIC CAPITAL LETTER DE -0xC5 U+0415 #CYRILLIC CAPITAL LETTER IE -0xC6 U+0416 #CYRILLIC CAPITAL LETTER ZHE -0xC7 U+0417 #CYRILLIC CAPITAL LETTER ZE -0xC8 U+0418 #CYRILLIC CAPITAL LETTER I -0xC9 U+0419 #CYRILLIC CAPITAL LETTER SHORT I -0xCA U+041A #CYRILLIC CAPITAL LETTER KA -0xCB U+041B #CYRILLIC CAPITAL LETTER EL -0xCC U+041C #CYRILLIC CAPITAL LETTER EM -0xCD U+041D #CYRILLIC CAPITAL LETTER EN -0xCE U+041E #CYRILLIC CAPITAL LETTER O -0xCF U+041F #CYRILLIC CAPITAL LETTER PE -0xD0 U+0420 #CYRILLIC CAPITAL LETTER ER -0xD1 U+0421 #CYRILLIC CAPITAL LETTER ES -0xD2 U+0422 #CYRILLIC CAPITAL LETTER TE -0xD3 U+0423 #CYRILLIC CAPITAL LETTER U -0xD4 U+0424 #CYRILLIC CAPITAL LETTER EF -0xD5 U+0425 #CYRILLIC CAPITAL LETTER HA -0xD6 U+0426 #CYRILLIC CAPITAL LETTER TSE -0xD7 U+0427 #CYRILLIC CAPITAL LETTER CHE -0xD8 U+0428 #CYRILLIC CAPITAL LETTER SHA -0xD9 U+0429 #CYRILLIC CAPITAL LETTER SHCHA -0xDA U+042A #CYRILLIC CAPITAL LETTER HARD SIGN -0xDB U+042B #CYRILLIC CAPITAL LETTER YERU -0xDC U+042C #CYRILLIC CAPITAL LETTER SOFT SIGN -0xDD U+042D #CYRILLIC CAPITAL LETTER E -0xDE U+042E #CYRILLIC CAPITAL LETTER YU -0xDF U+042F #CYRILLIC CAPITAL LETTER YA -0xE0 U+0430 #CYRILLIC SMALL LETTER A -0xE1 U+0431 #CYRILLIC SMALL LETTER BE -0xE2 U+0432 #CYRILLIC SMALL LETTER VE -0xE3 U+0433 #CYRILLIC SMALL LETTER GHE -0xE4 U+0434 #CYRILLIC SMALL LETTER DE -0xE5 U+0435 #CYRILLIC SMALL LETTER IE -0xE6 U+0436 #CYRILLIC SMALL LETTER ZHE -0xE7 U+0437 #CYRILLIC SMALL LETTER ZE -0xE8 U+0438 #CYRILLIC SMALL LETTER I -0xE9 U+0439 #CYRILLIC SMALL LETTER SHORT I -0xEA U+043A #CYRILLIC SMALL LETTER KA -0xEB U+043B #CYRILLIC SMALL LETTER EL -0xEC U+043C #CYRILLIC SMALL LETTER EM -0xED U+043D #CYRILLIC SMALL LETTER EN -0xEE U+043E #CYRILLIC SMALL LETTER O -0xEF U+043F #CYRILLIC SMALL LETTER PE -0xF0 U+0440 #CYRILLIC SMALL LETTER ER -0xF1 U+0441 #CYRILLIC SMALL LETTER ES -0xF2 U+0442 #CYRILLIC SMALL LETTER TE -0xF3 U+0443 #CYRILLIC SMALL LETTER U -0xF4 U+0444 #CYRILLIC SMALL LETTER EF -0xF5 U+0445 #CYRILLIC SMALL LETTER HA -0xF6 U+0446 #CYRILLIC SMALL LETTER TSE -0xF7 U+0447 #CYRILLIC SMALL LETTER CHE -0xF8 U+0448 #CYRILLIC SMALL LETTER SHA -0xF9 U+0449 #CYRILLIC SMALL LETTER SHCHA -0xFA U+044A #CYRILLIC SMALL LETTER HARD SIGN -0xFB U+044B #CYRILLIC SMALL LETTER YERU -0xFC U+044C #CYRILLIC SMALL LETTER SOFT SIGN -0xFD U+044D #CYRILLIC SMALL LETTER E -0xFE U+044E #CYRILLIC SMALL LETTER YU -0xFF U+044F #CYRILLIC SMALL LETTER YA +0x20-0x7f idem +# +0x80 U+0402 #CYRILLIC CAPITAL LETTER DJE +0x81 U+0403 #CYRILLIC CAPITAL LETTER GJE +0x82 U+201A #SINGLE LOW-9 QUOTATION MARK +0x83 U+0453 #CYRILLIC SMALL LETTER GJE +0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK +0x85 U+2026 #HORIZONTAL ELLIPSIS +0x86 U+2020 #DAGGER +0x87 U+2021 #DOUBLE DAGGER +#0x88 #UNDEFINED +0x89 U+2030 #PER MILLE SIGN +0x8A U+0409 #CYRILLIC CAPITAL LETTER LJE +0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK +0x8C U+040A #CYRILLIC CAPITAL LETTER NJE +0x8D U+040C #CYRILLIC CAPITAL LETTER KJE +0x8E U+040B #CYRILLIC CAPITAL LETTER TSHE +0x8F U+040F #CYRILLIC CAPITAL LETTER DZHE +0x90 U+0452 #CYRILLIC SMALL LETTER DJE +0x91 U+2018 #LEFT SINGLE QUOTATION MARK +0x92 U+2019 #RIGHT SINGLE QUOTATION MARK +0x93 U+201C #LEFT DOUBLE QUOTATION MARK +0x94 U+201D #RIGHT DOUBLE QUOTATION MARK +0x95 U+2022 #BULLET +0x96 U+2013 #EN DASH +0x97 U+2014 #EM DASH +#0x98 #UNDEFINED +0x99 U+2122 #TRADE MARK SIGN +0x9A U+0459 #CYRILLIC SMALL LETTER LJE +0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK +0x9C U+045A #CYRILLIC SMALL LETTER NJE +0x9D U+045C #CYRILLIC SMALL LETTER KJE +0x9E U+045B #CYRILLIC SMALL LETTER TSHE +0x9F U+045F #CYRILLIC SMALL LETTER DZHE +0xA0 U+00A0 #NO-BREAK SPACE +0xA1 U+040E #CYRILLIC CAPITAL LETTER SHORT U +0xA2 U+045E #CYRILLIC SMALL LETTER SHORT U +0xA3 U+0408 #CYRILLIC CAPITAL LETTER JE +0xA4 U+00A4 #CURRENCY SIGN +0xA5 U+0490 #CYRILLIC CAPITAL LETTER GHE WITH UPTURN +0xA6 U+00A6 #BROKEN BAR +0xA7 U+00A7 #SECTION SIGN +0xA8 U+0401 #CYRILLIC CAPITAL LETTER IO +0xA9 U+00A9 #COPYRIGHT SIGN +0xAA U+0404 #CYRILLIC CAPITAL LETTER UKRAINIAN IE +0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +0xAC U+00AC #NOT SIGN +0xAD U+00AD #SOFT HYPHEN +0xAE U+00AE #REGISTERED SIGN +0xAF U+0407 #CYRILLIC CAPITAL LETTER YI +0xB0 U+00B0 #DEGREE SIGN +0xB1 U+00B1 #PLUS-MINUS SIGN +0xB2 U+0406 #CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I +0xB3 U+0456 #CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I +0xB4 U+0491 #CYRILLIC SMALL LETTER GHE WITH UPTURN +0xB5 U+00B5 #MICRO SIGN +0xB6 U+00B6 #PILCROW SIGN +0xB7 U+00B7 #MIDDLE DOT +0xB8 U+0451 #CYRILLIC SMALL LETTER IO +0xB9 U+2116 #NUMERO SIGN +0xBA U+0454 #CYRILLIC SMALL LETTER UKRAINIAN IE +0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +0xBC U+0458 #CYRILLIC SMALL LETTER JE +0xBD U+0405 #CYRILLIC CAPITAL LETTER DZE +0xBE U+0455 #CYRILLIC SMALL LETTER DZE +0xBF U+0457 #CYRILLIC SMALL LETTER YI +0xC0 U+0410 #CYRILLIC CAPITAL LETTER A +0xC1 U+0411 #CYRILLIC CAPITAL LETTER BE +0xC2 U+0412 #CYRILLIC CAPITAL LETTER VE +0xC3 U+0413 #CYRILLIC CAPITAL LETTER GHE +0xC4 U+0414 #CYRILLIC CAPITAL LETTER DE +0xC5 U+0415 #CYRILLIC CAPITAL LETTER IE +0xC6 U+0416 #CYRILLIC CAPITAL LETTER ZHE +0xC7 U+0417 #CYRILLIC CAPITAL LETTER ZE +0xC8 U+0418 #CYRILLIC CAPITAL LETTER I +0xC9 U+0419 #CYRILLIC CAPITAL LETTER SHORT I +0xCA U+041A #CYRILLIC CAPITAL LETTER KA +0xCB U+041B #CYRILLIC CAPITAL LETTER EL +0xCC U+041C #CYRILLIC CAPITAL LETTER EM +0xCD U+041D #CYRILLIC CAPITAL LETTER EN +0xCE U+041E #CYRILLIC CAPITAL LETTER O +0xCF U+041F #CYRILLIC CAPITAL LETTER PE +0xD0 U+0420 #CYRILLIC CAPITAL LETTER ER +0xD1 U+0421 #CYRILLIC CAPITAL LETTER ES +0xD2 U+0422 #CYRILLIC CAPITAL LETTER TE +0xD3 U+0423 #CYRILLIC CAPITAL LETTER U +0xD4 U+0424 #CYRILLIC CAPITAL LETTER EF +0xD5 U+0425 #CYRILLIC CAPITAL LETTER HA +0xD6 U+0426 #CYRILLIC CAPITAL LETTER TSE +0xD7 U+0427 #CYRILLIC CAPITAL LETTER CHE +0xD8 U+0428 #CYRILLIC CAPITAL LETTER SHA +0xD9 U+0429 #CYRILLIC CAPITAL LETTER SHCHA +0xDA U+042A #CYRILLIC CAPITAL LETTER HARD SIGN +0xDB U+042B #CYRILLIC CAPITAL LETTER YERU +0xDC U+042C #CYRILLIC CAPITAL LETTER SOFT SIGN +0xDD U+042D #CYRILLIC CAPITAL LETTER E +0xDE U+042E #CYRILLIC CAPITAL LETTER YU +0xDF U+042F #CYRILLIC CAPITAL LETTER YA +0xE0 U+0430 #CYRILLIC SMALL LETTER A +0xE1 U+0431 #CYRILLIC SMALL LETTER BE +0xE2 U+0432 #CYRILLIC SMALL LETTER VE +0xE3 U+0433 #CYRILLIC SMALL LETTER GHE +0xE4 U+0434 #CYRILLIC SMALL LETTER DE +0xE5 U+0435 #CYRILLIC SMALL LETTER IE +0xE6 U+0436 #CYRILLIC SMALL LETTER ZHE +0xE7 U+0437 #CYRILLIC SMALL LETTER ZE +0xE8 U+0438 #CYRILLIC SMALL LETTER I +0xE9 U+0439 #CYRILLIC SMALL LETTER SHORT I +0xEA U+043A #CYRILLIC SMALL LETTER KA +0xEB U+043B #CYRILLIC SMALL LETTER EL +0xEC U+043C #CYRILLIC SMALL LETTER EM +0xED U+043D #CYRILLIC SMALL LETTER EN +0xEE U+043E #CYRILLIC SMALL LETTER O +0xEF U+043F #CYRILLIC SMALL LETTER PE +0xF0 U+0440 #CYRILLIC SMALL LETTER ER +0xF1 U+0441 #CYRILLIC SMALL LETTER ES +0xF2 U+0442 #CYRILLIC SMALL LETTER TE +0xF3 U+0443 #CYRILLIC SMALL LETTER U +0xF4 U+0444 #CYRILLIC SMALL LETTER EF +0xF5 U+0445 #CYRILLIC SMALL LETTER HA +0xF6 U+0446 #CYRILLIC SMALL LETTER TSE +0xF7 U+0447 #CYRILLIC SMALL LETTER CHE +0xF8 U+0448 #CYRILLIC SMALL LETTER SHA +0xF9 U+0449 #CYRILLIC SMALL LETTER SHCHA +0xFA U+044A #CYRILLIC SMALL LETTER HARD SIGN +0xFB U+044B #CYRILLIC SMALL LETTER YERU +0xFC U+044C #CYRILLIC SMALL LETTER SOFT SIGN +0xFD U+044D #CYRILLIC SMALL LETTER E +0xFE U+044E #CYRILLIC SMALL LETTER YU +0xFF U+044F #CYRILLIC SMALL LETTER YA diff --git a/src/chrtrans/cp1252_uni.tbl b/src/chrtrans/cp1252_uni.tbl index 09ee9b6a..d8adb2fa 100644 --- a/src/chrtrans/cp1252_uni.tbl +++ b/src/chrtrans/cp1252_uni.tbl @@ -6,155 +6,280 @@ D0 Mwindows-1252 #Name as a Display Charset (used on Options screen) -OWestern (windows-1252) +OWinLatin1 (cp1252) # -# Name: cp1252 to Unicode table -# Unicode version: 2.0 -# Table version: 2.00 +# Name: cp1252_WinLatin1 to Unicode table +# Unicode version: 1.1 +# Table version: 1.1 # Table format: Format A -# Date: 04/15/98 -# -# Contact: cpxlate@microsoft.com -# +# Date: 03/31/95 +# Authors: Michel Suignard <michelsu@microsoft.com> +# Lori Hoerth <lorih@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp1252 code (in hex) -# Column #2 is the Unicode (in hex as 0xXXXX) +# Column #1 is the cp1252_WinLatin1 code (in hex) +# Column #2 is the Unicode (in hex as U+XXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # -# The entries are in cp1252 order +# The entries are in cp1252_WinLatin1 order # -################## +#0x00 U+0000 #Null +#0x01 U+0001 #START OF HEADING +#0x02 U+0002 #START OF TEXT +#0x03 U+0003 #END OF TEXT +#0x04 U+0004 #END OF TRANSMISSION +#0x05 U+0005 #ENQUIRY +#0x06 U+0006 #ACKNOWLEDGE +#0x07 U+0007 #BELL +#0x08 U+0008 #BACKSPACE +#0x09 U+0009 #HORIZONTAL TABULATION +#0x0a U+000a #LINE FEED +#0x0b U+000b #VERTICAL TABULATION +#0x0c U+000c #FORM FEED +#0x0d U+000d #CARRIAGE RETURN +#0x0e U+000e #SHIFT OUT +#0x0f U+000f #SHIFT IN +#0x10 U+0010 #DATA LINK ESCAPE +#0x11 U+0011 #DEVICE CONTROL ONE +#0x12 U+0012 #DEVICE CONTROL TWO +#0x13 U+0013 #DEVICE CONTROL THREE +#0x14 U+0014 #DEVICE CONTROL FOUR +#0x15 U+0015 #NEGATIVE ACKNOWLEDGE +#0x16 U+0016 #SYNCHRONOUS IDLE +#0x17 U+0017 #END OF TRANSMISSION BLOCK +#0x18 U+0018 #CANCEL +#0x19 U+0019 #END OF MEDIUM +#0x1a U+001a #SUBSTITUTE +#0x1b U+001b #ESCAPE +#0x1c U+001c #FILE SEPARATOR +#0x1d U+001d #GROUP SEPARATOR +#0x1e U+001e #RECORD SEPARATOR +#0x1f U+001f #UNIT SEPARATOR +0x20 U+0020 #SPACE +0x21 U+0021 #EXCLAMATION MARK +0x22 U+0022 #QUOTATION MARK +0x23 U+0023 #NUMBER SIGN +0x24 U+0024 #DOLLAR SIGN +0x25 U+0025 #PERCENT SIGN +0x26 U+0026 #AMPERSAND +0x27 U+0027 #APOSTROPHE +0x28 U+0028 #LEFT PARENTHESIS +0x29 U+0029 #RIGHT PARENTHESIS +0x2a U+002a #ASTERISK +0x2b U+002b #PLUS SIGN +0x2c U+002c #COMMA +0x2d U+002d #HYPHEN-MINUS +0x2e U+002e #FULL STOP +0x2f U+002f #SOLIDUS +0x30 U+0030 #DIGIT ZERO +0x31 U+0031 #DIGIT ONE +0x32 U+0032 #DIGIT TWO +0x33 U+0033 #DIGIT THREE +0x34 U+0034 #DIGIT FOUR +0x35 U+0035 #DIGIT FIVE +0x36 U+0036 #DIGIT SIX +0x37 U+0037 #DIGIT SEVEN +0x38 U+0038 #DIGIT EIGHT +0x39 U+0039 #DIGIT NINE +0x3a U+003a #COLON +0x3b U+003b #SEMICOLON +0x3c U+003c #LESS-THAN SIGN +0x3d U+003d #EQUALS SIGN +0x3e U+003e #GREATER-THAN SIGN +0x3f U+003f #QUESTION MARK +0x40 U+0040 #COMMERCIAL AT +0x41 U+0041 #LATIN CAPITAL LETTER A +0x42 U+0042 #LATIN CAPITAL LETTER B +0x43 U+0043 #LATIN CAPITAL LETTER C +0x44 U+0044 #LATIN CAPITAL LETTER D +0x45 U+0045 #LATIN CAPITAL LETTER E +0x46 U+0046 #LATIN CAPITAL LETTER F +0x47 U+0047 #LATIN CAPITAL LETTER G +0x48 U+0048 #LATIN CAPITAL LETTER H +0x49 U+0049 #LATIN CAPITAL LETTER I +0x4a U+004a #LATIN CAPITAL LETTER J +0x4b U+004b #LATIN CAPITAL LETTER K +0x4c U+004c #LATIN CAPITAL LETTER L +0x4d U+004d #LATIN CAPITAL LETTER M +0x4e U+004e #LATIN CAPITAL LETTER N +0x4f U+004f #LATIN CAPITAL LETTER O +0x50 U+0050 #LATIN CAPITAL LETTER P +0x51 U+0051 #LATIN CAPITAL LETTER Q +0x52 U+0052 #LATIN CAPITAL LETTER R +0x53 U+0053 #LATIN CAPITAL LETTER S +0x54 U+0054 #LATIN CAPITAL LETTER T +0x55 U+0055 #LATIN CAPITAL LETTER U +0x56 U+0056 #LATIN CAPITAL LETTER V +0x57 U+0057 #LATIN CAPITAL LETTER W +0x58 U+0058 #LATIN CAPITAL LETTER X +0x59 U+0059 #LATIN CAPITAL LETTER Y +0x5a U+005a #LATIN CAPITAL LETTER Z +0x5b U+005b #LEFT SQUARE BRACKET +0x5c U+005c #REVERSE SOLIDUS +0x5d U+005d #RIGHT SQUARE BRACKET +0x5e U+005e #CIRCUMFLEX ACCENT +0x5f U+005f #LOW LINE +0x60 U+0060 #GRAVE ACCENT +0x61 U+0061 #LATIN SMALL LETTER A +0x62 U+0062 #LATIN SMALL LETTER B +0x63 U+0063 #LATIN SMALL LETTER C +0x64 U+0064 #LATIN SMALL LETTER D +0x65 U+0065 #LATIN SMALL LETTER E +0x66 U+0066 #LATIN SMALL LETTER F +0x67 U+0067 #LATIN SMALL LETTER G +0x68 U+0068 #LATIN SMALL LETTER H +0x69 U+0069 #LATIN SMALL LETTER I +0x6a U+006a #LATIN SMALL LETTER J +0x6b U+006b #LATIN SMALL LETTER K +0x6c U+006c #LATIN SMALL LETTER L +0x6d U+006d #LATIN SMALL LETTER M +0x6e U+006e #LATIN SMALL LETTER N +0x6f U+006f #LATIN SMALL LETTER O +0x70 U+0070 #LATIN SMALL LETTER P +0x71 U+0071 #LATIN SMALL LETTER Q +0x72 U+0072 #LATIN SMALL LETTER R +0x73 U+0073 #LATIN SMALL LETTER S +0x74 U+0074 #LATIN SMALL LETTER T +0x75 U+0075 #LATIN SMALL LETTER U +0x76 U+0076 #LATIN SMALL LETTER V +0x77 U+0077 #LATIN SMALL LETTER W +0x78 U+0078 #LATIN SMALL LETTER X +0x79 U+0079 #LATIN SMALL LETTER Y +0x7a U+007a #LATIN SMALL LETTER Z +0x7b U+007b #LEFT CURLY BRACKET +0x7c U+007c #VERTICAL LINE +0x7d U+007d #RIGHT CURLY BRACKET +0x7e U+007e #TILDE +0x7f U+007f #DELETE +#0x80 U+0080 #NOT USED +#0x81 U+0081 #NOT USED +0x82 U+201a #SINGLE LOW-9 QUOTATION MARK +0x83 U+0192 #LATIN SMALL LETTER F WITH HOOK +0x84 U+201e #DOUBLE LOW-9 QUOTATION MARK +0x85 U+2026 #HORIZONTAL ELLIPSIS +0x86 U+2020 #DAGGER +0x87 U+2021 #DOUBLE DAGGER +0x88 U+02c6 #MODIFIER LETTER CIRCUMFLEX ACCENT +0x89 U+2030 #PER MILLE SIGN +0x8a U+0160 #LATIN CAPITAL LETTER S WITH CARON +0x8b U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK +0x8c U+0152 #LATIN CAPITAL LIGATURE OE +#0x8d U+008d #NOT USED +#0x8e U+008e #NOT USED +#0x8f U+008f #NOT USED +#0x90 U+0090 #NOT USED +0x91 U+2018 #LEFT SINGLE QUOTATION MARK +0x92 U+2019 #RIGHT SINGLE QUOTATION MARK +0x93 U+201c #LEFT DOUBLE QUOTATION MARK +0x94 U+201d #RIGHT DOUBLE QUOTATION MARK +0x95 U+2022 #BULLET +0x96 U+2013 #EN DASH +0x97 U+2014 #EM DASH +0x98 U+02dc #SMALL TILDE +0x99 U+2122 #TRADE MARK SIGN +0x9a U+0161 #LATIN SMALL LETTER S WITH CARON +0x9b U+203a #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK +0x9c U+0153 #LATIN SMALL LIGATURE OE +#0x9d U+009d #NOT USED +#0x9e U+009e #NOT USED +0x9f U+0178 #LATIN CAPITAL LETTER Y WITH DIAERESIS +0xa0 U+00a0 #NO-BREAK SPACE +0xa1 U+00a1 #INVERTED EXCLAMATION MARK +0xa2 U+00a2 #CENT SIGN +0xa3 U+00a3 #POUND SIGN +0xa4 U+00a4 #CURRENCY SIGN +0xa5 U+00a5 #YEN SIGN +0xa6 U+00a6 #BROKEN BAR +0xa7 U+00a7 #SECTION SIGN +0xa8 U+00a8 #DIAERESIS +0xa9 U+00a9 #COPYRIGHT SIGN +0xaa U+00aa #FEMININE ORDINAL INDICATOR +0xab U+00ab #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +0xac U+00ac #NOT SIGN +0xad U+00ad #SOFT HYPHEN +0xae U+00ae #REGISTERED SIGN +0xaf U+00af #MACRON +0xb0 U+00b0 #DEGREE SIGN +0xb1 U+00b1 #PLUS-MINUS SIGN +0xb2 U+00b2 #SUPERSCRIPT TWO +0xb3 U+00b3 #SUPERSCRIPT THREE +0xb4 U+00b4 #ACUTE ACCENT +0xb5 U+00b5 #MICRO SIGN +0xb6 U+00b6 #PILCROW SIGN +0xb7 U+00b7 #MIDDLE DOT +0xb8 U+00b8 #CEDILLA +0xb9 U+00b9 #SUPERSCRIPT ONE +0xba U+00ba #MASCULINE ORDINAL INDICATOR +0xbb U+00bb #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +0xbc U+00bc #VULGAR FRACTION ONE QUARTER +0xbd U+00bd #VULGAR FRACTION ONE HALF +0xbe U+00be #VULGAR FRACTION THREE QUARTERS +0xbf U+00bf #INVERTED QUESTION MARK +0xc0 U+00c0 #LATIN CAPITAL LETTER A WITH GRAVE +0xc1 U+00c1 #LATIN CAPITAL LETTER A WITH ACUTE +0xc2 U+00c2 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX +0xc3 U+00c3 #LATIN CAPITAL LETTER A WITH TILDE +0xc4 U+00c4 #LATIN CAPITAL LETTER A WITH DIAERESIS +0xc5 U+00c5 #LATIN CAPITAL LETTER A WITH RING ABOVE +0xc6 U+00c6 #LATIN CAPITAL LIGATURE AE +0xc7 U+00c7 #LATIN CAPITAL LETTER C WITH CEDILLA +0xc8 U+00c8 #LATIN CAPITAL LETTER E WITH GRAVE +0xc9 U+00c9 #LATIN CAPITAL LETTER E WITH ACUTE +0xca U+00ca #LATIN CAPITAL LETTER E WITH CIRCUMFLEX +0xcb U+00cb #LATIN CAPITAL LETTER E WITH DIAERESIS +0xcc U+00cc #LATIN CAPITAL LETTER I WITH GRAVE +0xcd U+00cd #LATIN CAPITAL LETTER I WITH ACUTE +0xce U+00ce #LATIN CAPITAL LETTER I WITH CIRCUMFLEX +0xcf U+00cf #LATIN CAPITAL LETTER I WITH DIAERESIS +0xd0 U+00d0 #LATIN CAPITAL LETTER ETH +0xd1 U+00d1 #LATIN CAPITAL LETTER N WITH TILDE +0xd2 U+00d2 #LATIN CAPITAL LETTER O WITH GRAVE +0xd3 U+00d3 #LATIN CAPITAL LETTER O WITH ACUTE +0xd4 U+00d4 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX +0xd5 U+00d5 #LATIN CAPITAL LETTER O WITH TILDE +0xd6 U+00d6 #LATIN CAPITAL LETTER O WITH DIAERESIS +0xd7 U+00d7 #MULTIPLICATION SIGN +0xd8 U+00d8 #LATIN CAPITAL LETTER O WITH STROKE +0xd9 U+00d9 #LATIN CAPITAL LETTER U WITH GRAVE +0xda U+00da #LATIN CAPITAL LETTER U WITH ACUTE +0xdb U+00db #LATIN CAPITAL LETTER U WITH CIRCUMFLEX +0xdc U+00dc #LATIN CAPITAL LETTER U WITH DIAERESIS +0xdd U+00dd #LATIN CAPITAL LETTER Y WITH ACUTE +0xde U+00de #LATIN CAPITAL LETTER THORN +0xdf U+00df #LATIN SMALL LETTER SHARP S +0xe0 U+00e0 #LATIN SMALL LETTER A WITH GRAVE +0xe1 U+00e1 #LATIN SMALL LETTER A WITH ACUTE +0xe2 U+00e2 #LATIN SMALL LETTER A WITH CIRCUMFLEX +0xe3 U+00e3 #LATIN SMALL LETTER A WITH TILDE +0xe4 U+00e4 #LATIN SMALL LETTER A WITH DIAERESIS +0xe5 U+00e5 #LATIN SMALL LETTER A WITH RING ABOVE +0xe6 U+00e6 #LATIN SMALL LIGATURE AE +0xe7 U+00e7 #LATIN SMALL LETTER C WITH CEDILLA +0xe8 U+00e8 #LATIN SMALL LETTER E WITH GRAVE +0xe9 U+00e9 #LATIN SMALL LETTER E WITH ACUTE +0xea U+00ea #LATIN SMALL LETTER E WITH CIRCUMFLEX +0xeb U+00eb #LATIN SMALL LETTER E WITH DIAERESIS +0xec U+00ec #LATIN SMALL LETTER I WITH GRAVE +0xed U+00ed #LATIN SMALL LETTER I WITH ACUTE +0xee U+00ee #LATIN SMALL LETTER I WITH CIRCUMFLEX +0xef U+00ef #LATIN SMALL LETTER I WITH DIAERESIS +0xf0 U+00f0 #LATIN SMALL LETTER ETH +0xf1 U+00f1 #LATIN SMALL LETTER N WITH TILDE +0xf2 U+00f2 #LATIN SMALL LETTER O WITH GRAVE +0xf3 U+00f3 #LATIN SMALL LETTER O WITH ACUTE +0xf4 U+00f4 #LATIN SMALL LETTER O WITH CIRCUMFLEX +0xf5 U+00f5 #LATIN SMALL LETTER O WITH TILDE +0xf6 U+00f6 #LATIN SMALL LETTER O WITH DIAERESIS +0xf7 U+00f7 #DIVISION SIGN +0xf8 U+00f8 #LATIN SMALL LETTER O WITH STROKE +0xf9 U+00f9 #LATIN SMALL LETTER U WITH GRAVE +0xfa U+00fa #LATIN SMALL LETTER U WITH ACUTE +0xfb U+00fb #LATIN SMALL LETTER U WITH CIRCUMFLEX +0xfc U+00fc #LATIN SMALL LETTER U WITH DIAERESIS +0xfd U+00fd #LATIN SMALL LETTER Y WITH ACUTE +0xfe U+00fe #LATIN SMALL LETTER THORN +0xff U+00ff #LATIN SMALL LETTER Y WITH DIAERESIS + -0x20-0x7e idem -# -0x80 U+20AC #EURO SIGN -0x81 #UNDEFINED -0x82 U+201A #SINGLE LOW-9 QUOTATION MARK -0x83 U+0192 #LATIN SMALL LETTER F WITH HOOK -0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK -0x85 U+2026 #HORIZONTAL ELLIPSIS -0x86 U+2020 #DAGGER -0x87 U+2021 #DOUBLE DAGGER -0x88 U+02C6 #MODIFIER LETTER CIRCUMFLEX ACCENT -0x89 U+2030 #PER MILLE SIGN -0x8A U+0160 #LATIN CAPITAL LETTER S WITH CARON -0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK -0x8C U+0152 #LATIN CAPITAL LIGATURE OE -0x8D #UNDEFINED -0x8E U+017D #LATIN CAPITAL LETTER Z WITH CARON -0x8F #UNDEFINED -0x90 #UNDEFINED -0x91 U+2018 #LEFT SINGLE QUOTATION MARK -0x92 U+2019 #RIGHT SINGLE QUOTATION MARK -0x93 U+201C #LEFT DOUBLE QUOTATION MARK -0x94 U+201D #RIGHT DOUBLE QUOTATION MARK -0x95 U+2022 #BULLET -0x96 U+2013 #EN DASH -0x97 U+2014 #EM DASH -0x98 U+02DC #SMALL TILDE -0x99 U+2122 #TRADE MARK SIGN -0x9A U+0161 #LATIN SMALL LETTER S WITH CARON -0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -0x9C U+0153 #LATIN SMALL LIGATURE OE -0x9D #UNDEFINED -0x9E U+017E #LATIN SMALL LETTER Z WITH CARON -0x9F U+0178 #LATIN CAPITAL LETTER Y WITH DIAERESIS -0xA0 U+00A0 #NO-BREAK SPACE -0xA1 U+00A1 #INVERTED EXCLAMATION MARK -0xA2 U+00A2 #CENT SIGN -0xA3 U+00A3 #POUND SIGN -0xA4 U+00A4 #CURRENCY SIGN -0xA5 U+00A5 #YEN SIGN -0xA6 U+00A6 #BROKEN BAR -0xA7 U+00A7 #SECTION SIGN -0xA8 U+00A8 #DIAERESIS -0xA9 U+00A9 #COPYRIGHT SIGN -0xAA U+00AA #FEMININE ORDINAL INDICATOR -0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK -0xAC U+00AC #NOT SIGN -0xAD U+00AD #SOFT HYPHEN -0xAE U+00AE #REGISTERED SIGN -0xAF U+00AF #MACRON -0xB0 U+00B0 #DEGREE SIGN -0xB1 U+00B1 #PLUS-MINUS SIGN -0xB2 U+00B2 #SUPERSCRIPT TWO -0xB3 U+00B3 #SUPERSCRIPT THREE -0xB4 U+00B4 #ACUTE ACCENT -0xB5 U+00B5 #MICRO SIGN -0xB6 U+00B6 #PILCROW SIGN -0xB7 U+00B7 #MIDDLE DOT -0xB8 U+00B8 #CEDILLA -0xB9 U+00B9 #SUPERSCRIPT ONE -0xBA U+00BA #MASCULINE ORDINAL INDICATOR -0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -0xBC U+00BC #VULGAR FRACTION ONE QUARTER -0xBD U+00BD #VULGAR FRACTION ONE HALF -0xBE U+00BE #VULGAR FRACTION THREE QUARTERS -0xBF U+00BF #INVERTED QUESTION MARK -0xC0 U+00C0 #LATIN CAPITAL LETTER A WITH GRAVE -0xC1 U+00C1 #LATIN CAPITAL LETTER A WITH ACUTE -0xC2 U+00C2 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX -0xC3 U+00C3 #LATIN CAPITAL LETTER A WITH TILDE -0xC4 U+00C4 #LATIN CAPITAL LETTER A WITH DIAERESIS -0xC5 U+00C5 #LATIN CAPITAL LETTER A WITH RING ABOVE -0xC6 U+00C6 #LATIN CAPITAL LETTER AE -0xC7 U+00C7 #LATIN CAPITAL LETTER C WITH CEDILLA -0xC8 U+00C8 #LATIN CAPITAL LETTER E WITH GRAVE -0xC9 U+00C9 #LATIN CAPITAL LETTER E WITH ACUTE -0xCA U+00CA #LATIN CAPITAL LETTER E WITH CIRCUMFLEX -0xCB U+00CB #LATIN CAPITAL LETTER E WITH DIAERESIS -0xCC U+00CC #LATIN CAPITAL LETTER I WITH GRAVE -0xCD U+00CD #LATIN CAPITAL LETTER I WITH ACUTE -0xCE U+00CE #LATIN CAPITAL LETTER I WITH CIRCUMFLEX -0xCF U+00CF #LATIN CAPITAL LETTER I WITH DIAERESIS -0xD0 U+00D0 #LATIN CAPITAL LETTER ETH -0xD1 U+00D1 #LATIN CAPITAL LETTER N WITH TILDE -0xD2 U+00D2 #LATIN CAPITAL LETTER O WITH GRAVE -0xD3 U+00D3 #LATIN CAPITAL LETTER O WITH ACUTE -0xD4 U+00D4 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX -0xD5 U+00D5 #LATIN CAPITAL LETTER O WITH TILDE -0xD6 U+00D6 #LATIN CAPITAL LETTER O WITH DIAERESIS -0xD7 U+00D7 #MULTIPLICATION SIGN -0xD8 U+00D8 #LATIN CAPITAL LETTER O WITH STROKE -0xD9 U+00D9 #LATIN CAPITAL LETTER U WITH GRAVE -0xDA U+00DA #LATIN CAPITAL LETTER U WITH ACUTE -0xDB U+00DB #LATIN CAPITAL LETTER U WITH CIRCUMFLEX -0xDC U+00DC #LATIN CAPITAL LETTER U WITH DIAERESIS -0xDD U+00DD #LATIN CAPITAL LETTER Y WITH ACUTE -0xDE U+00DE #LATIN CAPITAL LETTER THORN -0xDF U+00DF #LATIN SMALL LETTER SHARP S -0xE0 U+00E0 #LATIN SMALL LETTER A WITH GRAVE -0xE1 U+00E1 #LATIN SMALL LETTER A WITH ACUTE -0xE2 U+00E2 #LATIN SMALL LETTER A WITH CIRCUMFLEX -0xE3 U+00E3 #LATIN SMALL LETTER A WITH TILDE -0xE4 U+00E4 #LATIN SMALL LETTER A WITH DIAERESIS -0xE5 U+00E5 #LATIN SMALL LETTER A WITH RING ABOVE -0xE6 U+00E6 #LATIN SMALL LETTER AE -0xE7 U+00E7 #LATIN SMALL LETTER C WITH CEDILLA -0xE8 U+00E8 #LATIN SMALL LETTER E WITH GRAVE -0xE9 U+00E9 #LATIN SMALL LETTER E WITH ACUTE -0xEA U+00EA #LATIN SMALL LETTER E WITH CIRCUMFLEX -0xEB U+00EB #LATIN SMALL LETTER E WITH DIAERESIS -0xEC U+00EC #LATIN SMALL LETTER I WITH GRAVE -0xED U+00ED #LATIN SMALL LETTER I WITH ACUTE -0xEE U+00EE #LATIN SMALL LETTER I WITH CIRCUMFLEX -0xEF U+00EF #LATIN SMALL LETTER I WITH DIAERESIS -0xF0 U+00F0 #LATIN SMALL LETTER ETH -0xF1 U+00F1 #LATIN SMALL LETTER N WITH TILDE -0xF2 U+00F2 #LATIN SMALL LETTER O WITH GRAVE -0xF3 U+00F3 #LATIN SMALL LETTER O WITH ACUTE -0xF4 U+00F4 #LATIN SMALL LETTER O WITH CIRCUMFLEX -0xF5 U+00F5 #LATIN SMALL LETTER O WITH TILDE -0xF6 U+00F6 #LATIN SMALL LETTER O WITH DIAERESIS -0xF7 U+00F7 #DIVISION SIGN -0xF8 U+00F8 #LATIN SMALL LETTER O WITH STROKE -0xF9 U+00F9 #LATIN SMALL LETTER U WITH GRAVE -0xFA U+00FA #LATIN SMALL LETTER U WITH ACUTE -0xFB U+00FB #LATIN SMALL LETTER U WITH CIRCUMFLEX -0xFC U+00FC #LATIN SMALL LETTER U WITH DIAERESIS -0xFD U+00FD #LATIN SMALL LETTER Y WITH ACUTE -0xFE U+00FE #LATIN SMALL LETTER THORN -0xFF U+00FF #LATIN SMALL LETTER Y WITH DIAERESIS diff --git a/src/chrtrans/cp1253_uni.tbl b/src/chrtrans/cp1253_uni.tbl index b53e44a2..097dae2b 100644 --- a/src/chrtrans/cp1253_uni.tbl +++ b/src/chrtrans/cp1253_uni.tbl @@ -2,47 +2,45 @@ Mwindows-1253 #Name as a Display Charset (used on Options screen) -OGreek (windows-1253) +OWinGreek (cp1253) -# -# Name: cp1253 to Unicode table +# Name: cp1253_WinGreek to Unicode table # Unicode version: 2.0 # Table version: 2.00 # Table format: Format A -# Date: 04/15/98 -# -# Contact: cpxlate@microsoft.com -# +# Date: 04/24/96 +# Authors: Lori Brownell <loribr@microsoft.com> +# K.D. Chang <a-kchang@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp1253 code (in hex) +# Column #1 is the cp1253_WinGreek code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # -# The entries are in cp1253 order +# The entries are in cp1253_WinGreek order # ################## -0x20-0x7e idem +0x20-0x7f idem # -0x80 U+20AC #EURO SIGN -0x81 #UNDEFINED +#0x80 #UNDEFINED +#0x81 #UNDEFINED 0x82 U+201A #SINGLE LOW-9 QUOTATION MARK 0x83 U+0192 #LATIN SMALL LETTER F WITH HOOK 0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK 0x85 U+2026 #HORIZONTAL ELLIPSIS 0x86 U+2020 #DAGGER 0x87 U+2021 #DOUBLE DAGGER -0x88 #UNDEFINED +#0x88 #UNDEFINED 0x89 U+2030 #PER MILLE SIGN -0x8A #UNDEFINED +#0x8A #UNDEFINED 0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK -0x8C #UNDEFINED -0x8D #UNDEFINED -0x8E #UNDEFINED -0x8F #UNDEFINED -0x90 #UNDEFINED +#0x8C #UNDEFINED +#0x8D #UNDEFINED +#0x8E #UNDEFINED +#0x8F #UNDEFINED +#0x90 #UNDEFINED 0x91 U+2018 #LEFT SINGLE QUOTATION MARK 0x92 U+2019 #RIGHT SINGLE QUOTATION MARK 0x93 U+201C #LEFT DOUBLE QUOTATION MARK @@ -50,14 +48,14 @@ OGreek (windows-1253) 0x95 U+2022 #BULLET 0x96 U+2013 #EN DASH 0x97 U+2014 #EM DASH -0x98 #UNDEFINED +#0x98 #UNDEFINED 0x99 U+2122 #TRADE MARK SIGN -0x9A #UNDEFINED +#0x9A #UNDEFINED 0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -0x9C #UNDEFINED -0x9D #UNDEFINED -0x9E #UNDEFINED -0x9F #UNDEFINED +#0x9C #UNDEFINED +#0x9D #UNDEFINED +#0x9E #UNDEFINED +#0x9F #UNDEFINED 0xA0 U+00A0 #NO-BREAK SPACE 0xA1 U+0385 #GREEK DIALYTIKA TONOS 0xA2 U+0386 #GREEK CAPITAL LETTER ALPHA WITH TONOS @@ -68,7 +66,7 @@ OGreek (windows-1253) 0xA7 U+00A7 #SECTION SIGN 0xA8 U+00A8 #DIAERESIS 0xA9 U+00A9 #COPYRIGHT SIGN -0xAA #UNDEFINED +#0xAA #UNDEFINED 0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 0xAC U+00AC #NOT SIGN 0xAD U+00AD #SOFT HYPHEN @@ -108,7 +106,7 @@ OGreek (windows-1253) 0xCF U+039F #GREEK CAPITAL LETTER OMICRON 0xD0 U+03A0 #GREEK CAPITAL LETTER PI 0xD1 U+03A1 #GREEK CAPITAL LETTER RHO -0xD2 #UNDEFINED +#0xD2 #UNDEFINED 0xD3 U+03A3 #GREEK CAPITAL LETTER SIGMA 0xD4 U+03A4 #GREEK CAPITAL LETTER TAU 0xD5 U+03A5 #GREEK CAPITAL LETTER UPSILON @@ -153,4 +151,4 @@ OGreek (windows-1253) 0xFC U+03CC #GREEK SMALL LETTER OMICRON WITH TONOS 0xFD U+03CD #GREEK SMALL LETTER UPSILON WITH TONOS 0xFE U+03CE #GREEK SMALL LETTER OMEGA WITH TONOS -0xFF #UNDEFINED +#0xFF #UNDEFINED diff --git a/src/chrtrans/cp1255_uni.tbl b/src/chrtrans/cp1255_uni.tbl index 6c4ca7d0..5f4d761a 100644 --- a/src/chrtrans/cp1255_uni.tbl +++ b/src/chrtrans/cp1255_uni.tbl @@ -2,94 +2,92 @@ Mwindows-1255 #Name as a Display Charset (used on Options screen). -OHebrew (windows-1255) +OWinHebrew (cp1255) -# -# Name: cp1255 to Unicode table +# Name: cp1255_WinHebrew to Unicode table # Unicode version: 2.0 # Table version: 2.00 # Table format: Format A -# Date: 04/15/98 -# -# Contact: cpxlate@microsoft.com -# +# Date: 04/24/96 +# Authors: Lori Brownell <loribr@microsoft.com> +# K.D. Chang <a-kchang@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp1255 code (in hex) +# Column #1 is the cp1255_WinHebrew code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # -# The entries are in cp1255 order +# The entries are in cp1255_WinHebrew order # ################## -0x20-0x7e idem +0x20-0x7f idem # -0x80 U+20AC #EURO SIGN -0x81 #UNDEFINED -0x82 U+201A #SINGLE LOW-9 QUOTATION MARK -0x83 U+0192 #LATIN SMALL LETTER F WITH HOOK -0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK +#0x80 #UNDEFINED +#0x81 #UNDEFINED +0x82 U+201A #LOW SINGLE COMMA QUOTATION MARK +0x83 U+0192 #LATIN SMALL LETTER SCRIPT F +0x84 U+201E #LOW DOUBLE COMMA QUOTATION MARK 0x85 U+2026 #HORIZONTAL ELLIPSIS 0x86 U+2020 #DAGGER 0x87 U+2021 #DOUBLE DAGGER -0x88 U+02C6 #MODIFIER LETTER CIRCUMFLEX ACCENT +0x88 U+02C6 #MODIFIER LETTER CIRCUMFLEX 0x89 U+2030 #PER MILLE SIGN -0x8A #UNDEFINED -0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK -0x8C #UNDEFINED -0x8D #UNDEFINED -0x8E #UNDEFINED -0x8F #UNDEFINED -0x90 #UNDEFINED -0x91 U+2018 #LEFT SINGLE QUOTATION MARK -0x92 U+2019 #RIGHT SINGLE QUOTATION MARK -0x93 U+201C #LEFT DOUBLE QUOTATION MARK -0x94 U+201D #RIGHT DOUBLE QUOTATION MARK +#0x8A #UNDEFINED +0x8B U+2039 #LEFT POINTING SINGLE GUILLEMET +#0x8C #UNDEFINED +#0x8D #UNDEFINED +#0x8E #UNDEFINED +#0x8F #UNDEFINED +#0x90 #UNDEFINED +0x91 U+2018 #SINGLE TURNED COMMA QUOTATION MARK +0x92 U+2019 #SINGLE COMMA QUOTATION MARK +0x93 U+201C #DOUBLE TURNED COMMA QUOTATION MARK +0x94 U+201D #DOUBLE COMMA QUOTATION MARK 0x95 U+2022 #BULLET 0x96 U+2013 #EN DASH 0x97 U+2014 #EM DASH -0x98 U+02DC #SMALL TILDE -0x99 U+2122 #TRADE MARK SIGN -0x9A #UNDEFINED -0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -0x9C #UNDEFINED -0x9D #UNDEFINED -0x9E #UNDEFINED -0x9F #UNDEFINED -0xA0 U+00A0 #NO-BREAK SPACE -0xA1 U+00A1 #INVERTED EXCLAMATION MARK +0x98 U+02DC #SPACING TILDE +0x99 U+2122 #TRADEMARK +#0x9A #UNDEFINED +0x9B U+203A #RIGHT POINTING SINGLE GUILLEMET +#0x9C #UNDEFINED +#0x9D #UNDEFINED +#0x9E #UNDEFINED +#0x9F #UNDEFINED +0xA0 U+00A0 #NON-BREAKING SPACE +#0xA1 #UNDEFINED 0xA2 U+00A2 #CENT SIGN 0xA3 U+00A3 #POUND SIGN 0xA4 U+20AA #NEW SHEQEL SIGN 0xA5 U+00A5 #YEN SIGN -0xA6 U+00A6 #BROKEN BAR +0xA6 U+00A6 #BROKEN VERTICAL BAR 0xA7 U+00A7 #SECTION SIGN -0xA8 U+00A8 #DIAERESIS +0xA8 U+00A8 #SPACING DIAERESIS 0xA9 U+00A9 #COPYRIGHT SIGN -0xAA U+00D7 #MULTIPLICATION SIGN -0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +#0xAA #UNDEFINED +0xAB U+00AB #LEFT POINTING GUILLEMET 0xAC U+00AC #NOT SIGN 0xAD U+00AD #SOFT HYPHEN -0xAE U+00AE #REGISTERED SIGN -0xAF U+00AF #MACRON +0xAE U+00AE #REGISTERED TRADE MARK SIGN +0xAF U+00AF #SPACING MACRON 0xB0 U+00B0 #DEGREE SIGN -0xB1 U+00B1 #PLUS-MINUS SIGN -0xB2 U+00B2 #SUPERSCRIPT TWO -0xB3 U+00B3 #SUPERSCRIPT THREE -0xB4 U+00B4 #ACUTE ACCENT +0xB1 U+00B1 #PLUS-OR-MINUS SIGN +0xB2 U+00B2 #SUPERSCRIPT DIGIT TWO +0xB3 U+00B3 #SUPERSCRIPT DIGIT THREE +0xB4 U+00B4 #SPACING ACUTE 0xB5 U+00B5 #MICRO SIGN -0xB6 U+00B6 #PILCROW SIGN +0xB6 U+00B6 #PARAGRAPH SIGN 0xB7 U+00B7 #MIDDLE DOT -0xB8 U+00B8 #CEDILLA -0xB9 U+00B9 #SUPERSCRIPT ONE -0xBA U+00F7 #DIVISION SIGN -0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -0xBC U+00BC #VULGAR FRACTION ONE QUARTER -0xBD U+00BD #VULGAR FRACTION ONE HALF -0xBE U+00BE #VULGAR FRACTION THREE QUARTERS -0xBF U+00BF #INVERTED QUESTION MARK +#0xB8 #UNDEFINED +0xB9 U+00B9 #SUPERSCRIPT DIGIT ONE +#0xBA #UNDEFINED +0xBB U+00BB #RIGHT POINTING GUILLEMET +0xBC U+00BC #FRACTION ONE QUARTER +0xBD U+00BD #FRACTION ONE HALF +0xBE U+00BE #FRACTION THREE QUARTERS +#0xBF #UNDEFINED 0xC0 U+05B0 #HEBREW POINT SHEVA 0xC1 U+05B1 #HEBREW POINT HATAF SEGOL 0xC2 U+05B2 #HEBREW POINT HATAF PATAH @@ -100,28 +98,28 @@ OHebrew (windows-1255) 0xC7 U+05B7 #HEBREW POINT PATAH 0xC8 U+05B8 #HEBREW POINT QAMATS 0xC9 U+05B9 #HEBREW POINT HOLAM -0xCA #UNDEFINED +0xCA U+05BA #HEBREW POINT 0xCB U+05BB #HEBREW POINT QUBUTS -0xCC U+05BC #HEBREW POINT DAGESH OR MAPIQ +0xCC U+05BC #HEBREW POINT DAGESH 0xCD U+05BD #HEBREW POINT METEG 0xCE U+05BE #HEBREW PUNCTUATION MAQAF 0xCF U+05BF #HEBREW POINT RAFE -0xD0 U+05C0 #HEBREW PUNCTUATION PASEQ +0xD0 U+05C0 #HEBREW POINT PASEQ 0xD1 U+05C1 #HEBREW POINT SHIN DOT 0xD2 U+05C2 #HEBREW POINT SIN DOT 0xD3 U+05C3 #HEBREW PUNCTUATION SOF PASUQ -0xD4 U+05F0 #HEBREW LIGATURE YIDDISH DOUBLE VAV -0xD5 U+05F1 #HEBREW LIGATURE YIDDISH VAV YOD -0xD6 U+05F2 #HEBREW LIGATURE YIDDISH DOUBLE YOD -0xD7 U+05F3 #HEBREW PUNCTUATION GERESH -0xD8 U+05F4 #HEBREW PUNCTUATION GERSHAYIM -0xD9 #UNDEFINED -0xDA #UNDEFINED -0xDB #UNDEFINED -0xDC #UNDEFINED -0xDD #UNDEFINED -0xDE #UNDEFINED -0xDF #UNDEFINED +0xD4 U+05F0 #HEBREW LETTER DOUBLE VAV +0xD5 U+05F1 #HEBREW LETTER VAV YOD +0xD6 U+05F2 #HEBREW LETTER DOUBLE YOD +#0xD7 #UNDEFINED +#0xD8 #UNDEFINED +#0xD9 #UNDEFINED +#0xDA #UNDEFINED +#0xDB #UNDEFINED +#0xDC #UNDEFINED +#0xDD #UNDEFINED +#0xDE #UNDEFINED +#0xDF #UNDEFINED 0xE0 U+05D0 #HEBREW LETTER ALEF 0xE1 U+05D1 #HEBREW LETTER BET 0xE2 U+05D2 #HEBREW LETTER GIMEL @@ -149,8 +147,8 @@ OHebrew (windows-1255) 0xF8 U+05E8 #HEBREW LETTER RESH 0xF9 U+05E9 #HEBREW LETTER SHIN 0xFA U+05EA #HEBREW LETTER TAV -0xFB #UNDEFINED -0xFC #UNDEFINED +#0xFB #UNDEFINED +#0xFC #UNDEFINED 0xFD U+200E #LEFT-TO-RIGHT MARK 0xFE U+200F #RIGHT-TO-LEFT MARK -0xFF #UNDEFINED +#0xFF #UNDEFINED diff --git a/src/chrtrans/cp1256_uni.tbl b/src/chrtrans/cp1256_uni.tbl index 23af4614..6d85d221 100644 --- a/src/chrtrans/cp1256_uni.tbl +++ b/src/chrtrans/cp1256_uni.tbl @@ -2,112 +2,110 @@ Mwindows-1256 #Name as a Display Charset (used on Options screen). -OArabic (windows-1256) +OWinArabic (cp1256) -# -# Name: cp1256 to Unicode table +# Name: cp1256_WinArabic to Unicode table # Unicode version: 2.0 # Table version: 2.00 # Table format: Format A -# Date: 04/15/98 -# -# Contact: cpxlate@microsoft.com -# +# Date: 04/24/96 +# Authors: Lori Brownell <loribr@microsoft.com> +# K.D. Chang <a-kchang@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp1256 code (in hex) +# Column #1 is the cp1256_WinArabic code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # -# The entries are in cp1256 order +# The entries are in cp1256_WinArabic order # ################## -0x20-0x7e idem +0x20-0x7f idem # -0x80 U+20AC #EURO SIGN -0x81 U+067E #ARABIC LETTER PEH -0x82 U+201A #SINGLE LOW-9 QUOTATION MARK -0x83 U+0192 #LATIN SMALL LETTER F WITH HOOK -0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK +#0x80 #UNDEFINED +0x81 U+067E #ARABIC TAA WITH THREE DOTS BELOW +0x82 U+201A #LOW SINGLE COMMA QUOTATION MARK +0x83 U+0192 #LATIN SMALL LETTER SCRIPT F +0x84 U+201E #LOW DOUBLE COMMA QUOTATION MARK 0x85 U+2026 #HORIZONTAL ELLIPSIS 0x86 U+2020 #DAGGER 0x87 U+2021 #DOUBLE DAGGER -0x88 U+02C6 #MODIFIER LETTER CIRCUMFLEX ACCENT +0x88 U+02C6 #MODIFIER LETTER CIRCUMFLEX 0x89 U+2030 #PER MILLE SIGN -0x8A #UNDEFINED -0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK -0x8C U+0152 #LATIN CAPITAL LIGATURE OE -0x8D U+0686 #ARABIC LETTER TCHEH -0x8E U+0698 #ARABIC LETTER JEH -0x8F #UNDEFINED -0x90 U+06AF #ARABIC LETTER GAF -0x91 U+2018 #LEFT SINGLE QUOTATION MARK -0x92 U+2019 #RIGHT SINGLE QUOTATION MARK -0x93 U+201C #LEFT DOUBLE QUOTATION MARK -0x94 U+201D #RIGHT DOUBLE QUOTATION MARK +#0x8A #UNDEFINED +0x8B U+2039 #LEFT POINTING SINGLE GUILLEMET +0x8C U+0152 #LATIN CAPITAL LETTER O E +0x8D U+0686 #ARABIC HAA WITH MIDDLE THREE DOTS DOWNWARD +0x8E U+0698 #ARABIC RA WITH THREE DOTS ABOVE +#0x8F #UNDEFINED +0x90 U+06AF #ARABIC GAF +0x91 U+2018 #SINGLE TURNED COMMA QUOTATION MARK +0x92 U+2019 #SINGLE COMMA QUOTATION MARK +0x93 U+201C #DOUBLE TURNED COMMA QUOTATION MARK +0x94 U+201D #DOUBLE COMMA QUOTATION MARK 0x95 U+2022 #BULLET 0x96 U+2013 #EN DASH 0x97 U+2014 #EM DASH -0x98 #UNDEFINED -0x99 U+2122 #TRADE MARK SIGN -0x9A #UNDEFINED -0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -0x9C U+0153 #LATIN SMALL LIGATURE OE +#0x98 #UNDEFINED +0x99 U+2122 #TRADEMARK +#0x9A #UNDEFINED +0x9B U+203A #RIGHT POINTING SINGLE GUILLEMET +0x9C U+0153 #LATIN SMALL LETTER O E 0x9D U+200C #ZERO WIDTH NON-JOINER 0x9E U+200D #ZERO WIDTH JOINER -0x9F #UNDEFINED -0xA0 U+00A0 #NO-BREAK SPACE +#0x9F #UNDEFINED +0xA0 U+00A0 #NON-BREAKING SPACE 0xA1 U+060C #ARABIC COMMA 0xA2 U+00A2 #CENT SIGN 0xA3 U+00A3 #POUND SIGN 0xA4 U+00A4 #CURRENCY SIGN 0xA5 U+00A5 #YEN SIGN -0xA6 U+00A6 #BROKEN BAR +0xA6 U+00A6 #BROKEN VERTICAL BAR 0xA7 U+00A7 #SECTION SIGN -0xA8 U+00A8 #DIAERESIS +0xA8 U+00A8 #SPACING DIAERESIS 0xA9 U+00A9 #COPYRIGHT SIGN -0xAA #UNDEFINED -0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +#0xAA #UNDEFINED +0xAB U+00AB #LEFT POINTING GUILLEMET 0xAC U+00AC #NOT SIGN 0xAD U+00AD #SOFT HYPHEN -0xAE U+00AE #REGISTERED SIGN -0xAF U+00AF #MACRON +0xAE U+00AE #REGISTERED TRADE MARK SIGN +0xAF U+00AF #SPACING MACRON 0xB0 U+00B0 #DEGREE SIGN -0xB1 U+00B1 #PLUS-MINUS SIGN -0xB2 U+00B2 #SUPERSCRIPT TWO -0xB3 U+00B3 #SUPERSCRIPT THREE -0xB4 U+00B4 #ACUTE ACCENT +0xB1 U+00B1 #PLUS-OR-MINUS SIGN +0xB2 U+00B2 #SUPERSCRIPT DIGIT TWO +0xB3 U+00B3 #SUPERSCRIPT DIGIT THREE +0xB4 U+00B4 #SPACING ACUTE 0xB5 U+00B5 #MICRO SIGN -0xB6 U+00B6 #PILCROW SIGN +0xB6 U+00B6 #PARAGRAPH SIGN 0xB7 U+00B7 #MIDDLE DOT -0xB8 U+00B8 #CEDILLA -0xB9 U+00B9 #SUPERSCRIPT ONE +0xB8 U+00B8 #SPACING CEDILLA +0xB9 U+00B9 #SUPERSCRIPT DIGIT ONE 0xBA U+061B #ARABIC SEMICOLON -0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -0xBC U+00BC #VULGAR FRACTION ONE QUARTER -0xBD U+00BD #VULGAR FRACTION ONE HALF -0xBE U+00BE #VULGAR FRACTION THREE QUARTERS +0xBB U+00BB #RIGHT POINTING GUILLEMET +0xBC U+00BC #FRACTION ONE QUARTER +0xBD U+00BD #FRACTION ONE HALF +0xBE U+00BE #FRACTION THREE QUARTERS 0xBF U+061F #ARABIC QUESTION MARK -0xC0 #UNDEFINED -0xC1 U+0621 #ARABIC LETTER HAMZA -0xC2 U+0622 #ARABIC LETTER ALEF WITH MADDA ABOVE -0xC3 U+0623 #ARABIC LETTER ALEF WITH HAMZA ABOVE -0xC4 U+0624 #ARABIC LETTER WAW WITH HAMZA ABOVE -0xC5 U+0625 #ARABIC LETTER ALEF WITH HAMZA BELOW -0xC6 U+0626 #ARABIC LETTER YEH WITH HAMZA ABOVE +#0xC0 #UNDEFINED +0xC1 U+0621 #ARABIC LETTER HAMZAH +0xC2 U+0622 #ARABIC LETTER MADDAH ON ALEF +0xC3 U+0623 #ARABIC LETTER HAMZAH ON ALEF +0xC4 U+0624 #ARABIC LETTER HAMZAH ON WAW +0xC5 U+0625 #ARABIC LETTER HAMZAH UNDER ALEF +0xC6 U+0626 #ARABIC LETTER HAMZAH ON YA 0xC7 U+0627 #ARABIC LETTER ALEF -0xC8 U+0628 #ARABIC LETTER BEH -0xC9 U+0629 #ARABIC LETTER TEH MARBUTA -0xCA U+062A #ARABIC LETTER TEH -0xCB U+062B #ARABIC LETTER THEH +0xC8 U+0628 #ARABIC LETTER BAA +0xC9 U+0629 #ARABIC LETTER TAA MARBUTAH +0xCA U+062A #ARABIC LETTER TAA +0xCB U+062B #ARABIC LETTER THAA 0xCC U+062C #ARABIC LETTER JEEM -0xCD U+062D #ARABIC LETTER HAH -0xCE U+062E #ARABIC LETTER KHAH +0xCD U+062D #ARABIC LETTER HAA +0xCE U+062E #ARABIC LETTER KHAA 0xCF U+062F #ARABIC LETTER DAL 0xD0 U+0630 #ARABIC LETTER THAL -0xD1 U+0631 #ARABIC LETTER REH +0xD1 U+0631 #ARABIC LETTER RA 0xD2 U+0632 #ARABIC LETTER ZAIN 0xD3 U+0633 #ARABIC LETTER SEEN 0xD4 U+0634 #ARABIC LETTER SHEEN @@ -115,42 +113,42 @@ OArabic (windows-1256) 0xD6 U+0636 #ARABIC LETTER DAD 0xD7 U+00D7 #MULTIPLICATION SIGN 0xD8 U+0637 #ARABIC LETTER TAH -0xD9 U+0638 #ARABIC LETTER ZAH +0xD9 U+0638 #ARABIC LETTER DHAH 0xDA U+0639 #ARABIC LETTER AIN 0xDB U+063A #ARABIC LETTER GHAIN 0xDC U+0640 #ARABIC TATWEEL -0xDD U+0641 #ARABIC LETTER FEH +0xDD U+0641 #ARABIC LETTER FA 0xDE U+0642 #ARABIC LETTER QAF -0xDF U+0643 #ARABIC LETTER KAF -0xE0 U+00E0 #LATIN SMALL LETTER A WITH GRAVE +0xDF U+0643 #ARABIC LETTER CAF +0xE0 U+00E0 #LATIN SMALL LETTER A GRAVE 0xE1 U+0644 #ARABIC LETTER LAM -0xE2 U+00E2 #LATIN SMALL LETTER A WITH CIRCUMFLEX +0xE2 U+00E2 #LATIN SMALL LETTER A CIRCUMFLEX 0xE3 U+0645 #ARABIC LETTER MEEM 0xE4 U+0646 #ARABIC LETTER NOON -0xE5 U+0647 #ARABIC LETTER HEH +0xE5 U+0647 #ARABIC LETTER HA 0xE6 U+0648 #ARABIC LETTER WAW -0xE7 U+00E7 #LATIN SMALL LETTER C WITH CEDILLA -0xE8 U+00E8 #LATIN SMALL LETTER E WITH GRAVE -0xE9 U+00E9 #LATIN SMALL LETTER E WITH ACUTE -0xEA U+00EA #LATIN SMALL LETTER E WITH CIRCUMFLEX -0xEB U+00EB #LATIN SMALL LETTER E WITH DIAERESIS -0xEC U+0649 #ARABIC LETTER ALEF MAKSURA -0xED U+064A #ARABIC LETTER YEH -0xEE U+00EE #LATIN SMALL LETTER I WITH CIRCUMFLEX -0xEF U+00EF #LATIN SMALL LETTER I WITH DIAERESIS +0xE7 U+00E7 #LATIN SMALL LETTER C CEDILLA +0xE8 U+00E8 #LATIN SMALL LETTER E GRAVE +0xE9 U+00E9 #LATIN SMALL LETTER E ACUTE +0xEA U+00EA #LATIN SMALL LETTER E CIRCUMFLEX +0xEB U+00EB #LATIN SMALL LETTER E DIAERESIS +0xEC U+0649 #ARABIC LETTER ALEF MAQSURAH +0xED U+064A #ARABIC LETTER YA +0xEE U+00EE #LATIN SMALL LETTER I CIRCUMFLEX +0xEF U+00EF #LATIN SMALL LETTER I DIAERESIS 0xF0 U+064B #ARABIC FATHATAN 0xF1 U+064C #ARABIC DAMMATAN 0xF2 U+064D #ARABIC KASRATAN -0xF3 U+064E #ARABIC FATHA -0xF4 U+00F4 #LATIN SMALL LETTER O WITH CIRCUMFLEX -0xF5 U+064F #ARABIC DAMMA -0xF6 U+0650 #ARABIC KASRA +0xF3 U+064E #ARABIC FATHAH +0xF4 U+00F4 #LATIN SMALL LETTER O CIRCUMFLEX +0xF5 U+064F #ARABIC DAMMAH +0xF6 U+0650 #ARABIC KASRAH 0xF7 U+00F7 #DIVISION SIGN -0xF8 U+0651 #ARABIC SHADDA -0xF9 U+00F9 #LATIN SMALL LETTER U WITH GRAVE +0xF8 U+0651 #ARABIC SHADDAH +0xF9 U+00F9 #LATIN SMALL LETTER U GRAVE 0xFA U+0652 #ARABIC SUKUN -0xFB U+00FB #LATIN SMALL LETTER U WITH CIRCUMFLEX -0xFC U+00FC #LATIN SMALL LETTER U WITH DIAERESIS +0xFB U+00FB #LATIN SMALL LETTER U CIRCUMFLEX +0xFC U+00FC #LATIN SMALL LETTER U DIAERESIS 0xFD U+200E #LEFT-TO-RIGHT MARK 0xFE U+200F #RIGHT-TO-LEFT MARK -0xFF #UNDEFINED +#0xFF #UNDEFINED diff --git a/src/chrtrans/cp1257_uni.tbl b/src/chrtrans/cp1257_uni.tbl index 4c1e70e6..794df717 100644 --- a/src/chrtrans/cp1257_uni.tbl +++ b/src/chrtrans/cp1257_uni.tbl @@ -2,47 +2,169 @@ Mwindows-1257 #Name as a Display Charset (used on Options screen) -OBaltic Rim (windows-1257) +OWinBaltRim (cp1257) -# -# Name: cp1257 to Unicode table +# Name: cp1257_WinBaltic to Unicode table # Unicode version: 2.0 # Table version: 2.00 # Table format: Format A -# Date: 04/15/98 -# -# Contact: cpxlate@microsoft.com -# +# Date: 04/24/96 +# Authors: Lori Brownell <loribr@microsoft.com> +# K.D. Chang <a-kchang@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp1257 code (in hex) +# Column #1 is the cp1257_WinBaltic code (in hex) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # -# The entries are in cp1257 order +# The entries are in cp1257_WinBaltic order # -################## - -0x20-0x7e idem -# -0x80 U+20AC #EURO SIGN -0x81 #UNDEFINED -0x82 U+201A #SINGLE LOW-9 QUOTATION MARK -0x83 #UNDEFINED -0x84 U+201E #DOUBLE LOW-9 QUOTATION MARK +#0x00 U+0000 #NULL +#0x01 U+0001 #START OF HEADING +#0x02 U+0002 #START OF TEXT +#0x03 U+0003 #END OF TEXT +#0x04 U+0004 #END OF TRANSMISSION +#0x05 U+0005 #ENQUIRY +#0x06 U+0006 #ACKNOWLEDGE +#0x07 U+0007 #BELL +#0x08 U+0008 #BACKSPACE +#0x09 U+0009 #HORIZONTAL TABULATION +#0x0A U+000A #LINE FEED +#0x0B U+000B #VERTICAL TABULATION +#0x0C U+000C #FORM FEED +#0x0D U+000D #CARRIAGE RETURN +#0x0E U+000E #SHIFT OUT +#0x0F U+000F #SHIFT IN +#0x10 U+0010 #DATA LINK ESCAPE +#0x11 U+0011 #DEVICE CONTROL ONE +#0x12 U+0012 #DEVICE CONTROL TWO +#0x13 U+0013 #DEVICE CONTROL THREE +#0x14 U+0014 #DEVICE CONTROL FOUR +#0x15 U+0015 #NEGATIVE ACKNOWLEDGE +#0x16 U+0016 #SYNCHRONOUS IDLE +#0x17 U+0017 #END OF TRANSMISSION BLOCK +#0x18 U+0018 #CANCEL +#0x19 U+0019 #END OF MEDIUM +#0x1A U+001A #SUBSTITUTE +#0x1B U+001B #ESCAPE +#0x1C U+001C #FILE SEPARATOR +#0x1D U+001D #GROUP SEPARATOR +#0x1E U+001E #RECORD SEPARATOR +#0x1F U+001F #UNIT SEPARATOR +0x20 U+0020 #SPACE +0x21 U+0021 #EXCLAMATION MARK +0x22 U+0022 #QUOTATION MARK +0x23 U+0023 #NUMBER SIGN +0x24 U+0024 #DOLLAR SIGN +0x25 U+0025 #PERCENT SIGN +0x26 U+0026 #AMPERSAND +0x27 U+0027 #APOSTROPHE +0x28 U+0028 #LEFT PARENTHESIS +0x29 U+0029 #RIGHT PARENTHESIS +0x2A U+002A #ASTERISK +0x2B U+002B #PLUS SIGN +0x2C U+002C #COMMA +0x2D U+002D #HYPHEN-MINUS +0x2E U+002E #FULL STOP +0x2F U+002F #SOLIDUS +0x30 U+0030 #DIGIT 0 +0x31 U+0031 #DIGIT 1 +0x32 U+0032 #DIGIT 2 +0x33 U+0033 #DIGIT 3 +0x34 U+0034 #DIGIT 4 +0x35 U+0035 #DIGIT 5 +0x36 U+0036 #DIGIT 6 +0x37 U+0037 #DIGIT 7 +0x38 U+0038 #DIGIT 8 +0x39 U+0039 #DIGIT 9 +0x3A U+003A #COLON +0x3B U+003B #SEMICOLON +0x3C U+003C #LESS-THAN SIGN +0x3D U+003D #EQUALS SIGN +0x3E U+003E #GREATER-THAN SIGN +0x3F U+003F #QUESTION MARK +0x40 U+0040 #COMMERCIAL AT +0x41 U+0041 #LATIN CAPITAL A +0x42 U+0042 #LATIN CAPITAL B +0x43 U+0043 #LATIN CAPITAL C +0x44 U+0044 #LATIN CAPITAL D +0x45 U+0045 #LATIN CAPITAL E +0x46 U+0046 #LATIN CAPITAL F +0x47 U+0047 #LATIN CAPITAL G +0x48 U+0048 #LATIN CAPITAL H +0x49 U+0049 #LATIN CAPITAL I +0x4A U+004A #LATIN CAPITAL J +0x4B U+004B #LATIN CAPITAL K +0x4C U+004C #LATIN CAPITAL L +0x4D U+004D #LATIN CAPITAL M +0x4E U+004E #LATIN CAPITAL N +0x4F U+004F #LATIN CAPITAL O +0x50 U+0050 #LATIN CAPITAL P +0x51 U+0051 #LATIN CAPITAL Q +0x52 U+0052 #LATIN CAPITAL R +0x53 U+0053 #LATIN CAPITAL S +0x54 U+0054 #LATIN CAPITAL T +0x55 U+0055 #LATIN CAPITAL U +0x56 U+0056 #LATIN CAPITAL V +0x57 U+0057 #LATIN CAPITAL W +0x58 U+0058 #LATIN CAPITAL X +0x59 U+0059 #LATIN CAPITAL Y +0x5A U+005A #LATIN CAPITAL Z +0x5B U+005B #LEFT SQUARE BRACKET +0x5C U+005C #BACKSLASH +0x5D U+005D #RIGHT SQUARE BRACKET +0x5E U+005E #CIRCUMFLEX +0x5F U+005F #LOW LINE +0x60 U+0060 #GRAVE +0x61 U+0061 #LATIN SMALL A +0x62 U+0062 #LATIN SMALL B +0x63 U+0063 #LATIN SMALL C +0x64 U+0064 #LATIN SMALL D +0x65 U+0065 #LATIN SMALL E +0x66 U+0066 #LATIN SMALL F +0x67 U+0067 #LATIN SMALL G +0x68 U+0068 #LATIN SMALL H +0x69 U+0069 #LATIN SMALL I +0x6A U+006A #LATIN SMALL J +0x6B U+006B #LATIN SMALL K +0x6C U+006C #LATIN SMALL L +0x6D U+006D #LATIN SMALL M +0x6E U+006E #LATIN SMALL N +0x6F U+006F #LATIN SMALL O +0x70 U+0070 #LATIN SMALL P +0x71 U+0071 #LATIN SMALL Q +0x72 U+0072 #LATIN SMALL R +0x73 U+0073 #LATIN SMALL S +0x74 U+0074 #LATIN SMALL T +0x75 U+0075 #LATIN SMALL U +0x76 U+0076 #LATIN SMALL V +0x77 U+0077 #LATIN SMALL W +0x78 U+0078 #LATIN SMALL X +0x79 U+0079 #LATIN SMALL Y +0x7A U+007A #LATIN SMALL Z +0x7B U+007B #LEFT CURLY BRACKET +0x7C U+007C #VERTICAL LINE +0x7D U+007D #RIGHT CURLY BRACKET +0x7E U+007E #TILDE +#0x7F U+007F #DELETE +#0x80 #UNDEFINED +#0x81 #UNDEFINED +0x82 U+201A #LOW SINGLE COMMA QUOTATION MARK +#0x83 #UNDEFINED +0x84 U+201E #LOW DOUBLE COMMA QUOTATION MARK 0x85 U+2026 #HORIZONTAL ELLIPSIS 0x86 U+2020 #DAGGER 0x87 U+2021 #DOUBLE DAGGER -0x88 #UNDEFINED +#0x88 #UNDEFINED 0x89 U+2030 #PER MILLE SIGN -0x8A #UNDEFINED -0x8B U+2039 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK -0x8C #UNDEFINED +#0x8A #UNDEFINED +0x8B U+2039 #LEFT POINTING SINGLE GUILLEMENT +#0x8C #UNDEFINED 0x8D U+00A8 #DIAERESIS -0x8E U+02C7 #CARON +0x8E U+02C7 #HACEK 0x8F U+00B8 #CEDILLA -0x90 #UNDEFINED +#0x90 #UNDEFINED 0x91 U+2018 #LEFT SINGLE QUOTATION MARK 0x92 U+2019 #RIGHT SINGLE QUOTATION MARK 0x93 U+201C #LEFT DOUBLE QUOTATION MARK @@ -50,108 +172,107 @@ OBaltic Rim (windows-1257) 0x95 U+2022 #BULLET 0x96 U+2013 #EN DASH 0x97 U+2014 #EM DASH -0x98 #UNDEFINED +#0x98 #UNDEFINED 0x99 U+2122 #TRADE MARK SIGN -0x9A #UNDEFINED -0x9B U+203A #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK -0x9C #UNDEFINED +#0x9A #UNDEFINED +0x9B U+203A #RIGHT POINTING SINGLE GUILLEMENT +#0x9C #UNDEFINED 0x9D U+00AF #MACRON 0x9E U+02DB #OGONEK -0x9F #UNDEFINED +#0x9F #UNDEFINED 0xA0 U+00A0 #NO-BREAK SPACE -0xA1 #UNDEFINED +#0xA1 #UNDEFINED 0xA2 U+00A2 #CENT SIGN 0xA3 U+00A3 #POUND SIGN 0xA4 U+00A4 #CURRENCY SIGN -0xA5 #UNDEFINED +#0xA5 #UNDEFINED 0xA6 U+00A6 #BROKEN BAR 0xA7 U+00A7 #SECTION SIGN -0xA8 U+00D8 #LATIN CAPITAL LETTER O WITH STROKE +0xA8 U+00D8 #LATIN CAPITAL O STROKE 0xA9 U+00A9 #COPYRIGHT SIGN -0xAA U+0156 #LATIN CAPITAL LETTER R WITH CEDILLA -0xAB U+00AB #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +0xAA U+0156 #LATIN CAPITAL R CEDILLA +0xAB U+00AB #LEFT POINTING GUILLEMENT 0xAC U+00AC #NOT SIGN 0xAD U+00AD #SOFT HYPHEN 0xAE U+00AE #REGISTERED SIGN -0xAF U+00C6 #LATIN CAPITAL LETTER AE +0xAF U+00C6 #LATIN CAPITAL AE LIGATURE 0xB0 U+00B0 #DEGREE SIGN 0xB1 U+00B1 #PLUS-MINUS SIGN -0xB2 U+00B2 #SUPERSCRIPT TWO -0xB3 U+00B3 #SUPERSCRIPT THREE -0xB4 U+00B4 #ACUTE ACCENT +0xB2 U+00B2 #SUPERSCRIPT 2 +0xB3 U+00B3 #SUPERSCRIPT 3 +0xB4 U+00B4 #ACUTE 0xB5 U+00B5 #MICRO SIGN 0xB6 U+00B6 #PILCROW SIGN 0xB7 U+00B7 #MIDDLE DOT -0xB8 U+00F8 #LATIN SMALL LETTER O WITH STROKE +0xB8 U+00F8 #LATIN SAMLL O STROKE 0xB9 U+00B9 #SUPERSCRIPT ONE -0xBA U+0157 #LATIN SMALL LETTER R WITH CEDILLA -0xBB U+00BB #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -0xBC U+00BC #VULGAR FRACTION ONE QUARTER -0xBD U+00BD #VULGAR FRACTION ONE HALF -0xBE U+00BE #VULGAR FRACTION THREE QUARTERS -0xBF U+00E6 #LATIN SMALL LETTER AE -0xC0 U+0104 #LATIN CAPITAL LETTER A WITH OGONEK -0xC1 U+012E #LATIN CAPITAL LETTER I WITH OGONEK -0xC2 U+0100 #LATIN CAPITAL LETTER A WITH MACRON -0xC3 U+0106 #LATIN CAPITAL LETTER C WITH ACUTE -0xC4 U+00C4 #LATIN CAPITAL LETTER A WITH DIAERESIS -0xC5 U+00C5 #LATIN CAPITAL LETTER A WITH RING ABOVE -0xC6 U+0118 #LATIN CAPITAL LETTER E WITH OGONEK -0xC7 U+0112 #LATIN CAPITAL LETTER E WITH MACRON -0xC8 U+010C #LATIN CAPITAL LETTER C WITH CARON -0xC9 U+00C9 #LATIN CAPITAL LETTER E WITH ACUTE -0xCA U+0179 #LATIN CAPITAL LETTER Z WITH ACUTE -0xCB U+0116 #LATIN CAPITAL LETTER E WITH DOT ABOVE -0xCC U+0122 #LATIN CAPITAL LETTER G WITH CEDILLA -0xCD U+0136 #LATIN CAPITAL LETTER K WITH CEDILLA -0xCE U+012A #LATIN CAPITAL LETTER I WITH MACRON -0xCF U+013B #LATIN CAPITAL LETTER L WITH CEDILLA -0xD0 U+0160 #LATIN CAPITAL LETTER S WITH CARON -0xD1 U+0143 #LATIN CAPITAL LETTER N WITH ACUTE -0xD2 U+0145 #LATIN CAPITAL LETTER N WITH CEDILLA -0xD3 U+00D3 #LATIN CAPITAL LETTER O WITH ACUTE -0xD4 U+014C #LATIN CAPITAL LETTER O WITH MACRON -0xD5 U+00D5 #LATIN CAPITAL LETTER O WITH TILDE -0xD6 U+00D6 #LATIN CAPITAL LETTER O WITH DIAERESIS +0xBA U+0157 #LATIN SMALL R CEDILLA +0xBB U+00BB #RIGHT POINTING GUILLEMENT +0xBC U+00BC #FRACTION 1/4 +0xBD U+00BD #FRACTION 1/2 +0xBE U+00BE #FRACTION 3/4 +0xBF U+00E6 #LATIN SMALL AE LIGATURE +0xC0 U+0104 #LATIN CAPITAL A OGONEK +0xC1 U+012E #LATIN CAPITAL I OGONEK +0xC2 U+0100 #LATIN CAPITAL A MACRON +0xC3 U+0106 #LATIN CAPITAL C ACUTE +0xC4 U+00C4 #LATIN CAPITAL A DIAERESIS +0xC5 U+00C5 #LATIN CAPITAL A RING ABOVE +0xC6 U+0118 #LATIN CAPITAL E OGONEK +0xC7 U+0112 #LATIN CAPITAL E MACRON +0xC8 U+010C #LATIN CAPITAL C HACEK +0xC9 U+00C9 #LATIN CAPITAL E ACUTE +0xCA U+0179 #LATIN CAPITAL Z ACUTE +0xCB U+0116 #LATIN CAPITAL E DOT ABOVE +0xCC U+0122 #LATIN CAPITAL G CEDILLA +0xCD U+0136 #LATIN CAPITAL K CEDILLA +0xCE U+012A #LATIN CAPITAL I MACRON +0xCF U+013B #LATIN CAPITAL L CEDILLA +0xD0 U+0160 #LATIN CAPITAL S HACEK +0xD1 U+0143 #LATIN CAPITAL N ACUTE +0xD2 U+0145 #LATIN CAPITAL N CEDILLA +0xD3 U+00D3 #LATIN CAPITAL O ACUTE +0xD4 U+014C #LATIN CAPITAL O MACRON +0xD5 U+00D5 #LATIN CAPITAL O TILDE +0xD6 U+00D6 #LATIN CAPITAL O DIAERESIS 0xD7 U+00D7 #MULTIPLICATION SIGN -0xD8 U+0172 #LATIN CAPITAL LETTER U WITH OGONEK -0xD9 U+0141 #LATIN CAPITAL LETTER L WITH STROKE -0xDA U+015A #LATIN CAPITAL LETTER S WITH ACUTE -0xDB U+016A #LATIN CAPITAL LETTER U WITH MACRON -0xDC U+00DC #LATIN CAPITAL LETTER U WITH DIAERESIS -0xDD U+017B #LATIN CAPITAL LETTER Z WITH DOT ABOVE -0xDE U+017D #LATIN CAPITAL LETTER Z WITH CARON -0xDF U+00DF #LATIN SMALL LETTER SHARP S -0xE0 U+0105 #LATIN SMALL LETTER A WITH OGONEK -0xE1 U+012F #LATIN SMALL LETTER I WITH OGONEK -0xE2 U+0101 #LATIN SMALL LETTER A WITH MACRON -0xE3 U+0107 #LATIN SMALL LETTER C WITH ACUTE -0xE4 U+00E4 #LATIN SMALL LETTER A WITH DIAERESIS -0xE5 U+00E5 #LATIN SMALL LETTER A WITH RING ABOVE -0xE6 U+0119 #LATIN SMALL LETTER E WITH OGONEK -0xE7 U+0113 #LATIN SMALL LETTER E WITH MACRON -0xE8 U+010D #LATIN SMALL LETTER C WITH CARON -0xE9 U+00E9 #LATIN SMALL LETTER E WITH ACUTE -0xEA U+017A #LATIN SMALL LETTER Z WITH ACUTE -0xEB U+0117 #LATIN SMALL LETTER E WITH DOT ABOVE -0xEC U+0123 #LATIN SMALL LETTER G WITH CEDILLA -0xED U+0137 #LATIN SMALL LETTER K WITH CEDILLA -0xEE U+012B #LATIN SMALL LETTER I WITH MACRON -0xEF U+013C #LATIN SMALL LETTER L WITH CEDILLA -0xF0 U+0161 #LATIN SMALL LETTER S WITH CARON -0xF1 U+0144 #LATIN SMALL LETTER N WITH ACUTE -0xF2 U+0146 #LATIN SMALL LETTER N WITH CEDILLA -0xF3 U+00F3 #LATIN SMALL LETTER O WITH ACUTE -0xF4 U+014D #LATIN SMALL LETTER O WITH MACRON -0xF5 U+00F5 #LATIN SMALL LETTER O WITH TILDE -0xF6 U+00F6 #LATIN SMALL LETTER O WITH DIAERESIS +0xD8 U+0172 #LATIN CAPITAL U OGONEK +0xD9 U+0141 #LATIN CAPITAL L STROKE +0xDA U+015A #LATIN CAPITAL S ACUTE +0xDB U+016A #LATIN CAPITAL U MACRON +0xDC U+00DC #LATIN CAPITAL U DIAERESIS +0xDD U+017B #LATIN CAPITAL Z DOT ABOVE +0xDE U+017D #LATIN CAPITAL Z HACEK +0xDF U+00DF #LATIN SMALL SHARP SS +0xE0 U+0105 #LATIN SMALL A OGONEK +0xE1 U+012F #LATIN SMALL I OGONEK +0xE2 U+0101 #LATIN SMALL A MACRON +0xE3 U+0107 #LATIN SMALL C ACUTE +0xE4 U+00E4 #LATIN SMALL A DIAERESIS +0xE5 U+00E5 #LATIN SMALL A RING ABOVE +0xE6 U+0119 #LATIN SMALL E OGONEK +0xE7 U+0113 #LATIN SMALL E MACRON +0xE8 U+010D #LATIN SMALL C HACEK +0xE9 U+00E9 #LATIN SMALL E ACUTE +0xEA U+017A #LATIN SMALL Z ACUTE +0xEB U+0117 #LATIN SMALL E DOT ABOVE +0xEC U+0123 #LATIN SMALL G CEDILLA +0xED U+0137 #LATIN SMALL K CEDILLA +0xEE U+012B #LATIN SMALL I MACRON +0xEF U+013C #LATIN SMALL L CEDILLA +0xF0 U+0161 #LATIN SMALL S HACEK +0xF1 U+0144 #LATIN SMALL N ACUTE +0xF2 U+0146 #LATIN SMALL N CEDILLA +0xF3 U+00F3 #LATIN SMALL O ACUTE +0xF4 U+014D #LATIN SMALL O MACRON +0xF5 U+00F5 #LATIN SMALL O TILDE +0xF6 U+00F6 #LATIN SMALL O DIAERESIS 0xF7 U+00F7 #DIVISION SIGN -0xF8 U+0173 #LATIN SMALL LETTER U WITH OGONEK -0xF9 U+0142 #LATIN SMALL LETTER L WITH STROKE -0xFA U+015B #LATIN SMALL LETTER S WITH ACUTE -0xFB U+016B #LATIN SMALL LETTER U WITH MACRON -0xFC U+00FC #LATIN SMALL LETTER U WITH DIAERESIS -0xFD U+017C #LATIN SMALL LETTER Z WITH DOT ABOVE -0xFE U+017E #LATIN SMALL LETTER Z WITH CARON +0xF8 U+0173 #LATIN SMALL U OGONEK +0xF9 U+0142 #LATIN SMALL L STROKE +0xFA U+015B #LATIN SMALL S ACUTE +0xFB U+016B #LATIN SMALL U MACRON +0xFC U+00FC #LATIN SMALL U DIAERESIS +0xFD U+017C #LATIN SMALL Z DOT ABOVE +0xFE U+017E #LATIN SMALL Z HACEK 0xFF U+02D9 #DOT ABOVE - diff --git a/src/chrtrans/cp437_uni.tbl b/src/chrtrans/cp437_uni.tbl index b84f503f..621e730e 100644 --- a/src/chrtrans/cp437_uni.tbl +++ b/src/chrtrans/cp437_uni.tbl @@ -6,21 +6,20 @@ D0 Mcp437 #Name as a Display Charset (used on Options screen) -OIBM PC US codepage (cp437) - +ODosLatinUS (cp437) # # Name: cp437_DOSLatinUS to Unicode table -# Unicode version: 2.0 -# Table version: 2.00 +# Unicode version: 1.1 +# Table version: 1.1 # Table format: Format A -# Date: 04/24/96 -# Authors: Lori Brownell <loribr@microsoft.com> -# K.D. Chang <a-kchang@microsoft.com> +# Date: 03/31/95 +# Authors: Michel Suignard <michelsu@microsoft.com> +# Lori Hoerth <lorih@microsoft.com> # General notes: none # # Format: Three tab-separated columns -# Column #1 is the cp437_DOSLatinUS code (in hex) -# Column #2 is the Unicode (in hex as 0xXXXX) +# Column #1 is the cp437_DosLatinUS code (in hex) +# Column #2 is the Unicode (in hex as U+XXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # # The entries are in cp437_DosLatinUS order @@ -28,8 +27,6 @@ OIBM PC US codepage (cp437) # some mapppings of greek letters to latin letters added, # just for fun.. - KW # -####################################### - 0x20-0x7f idem # 0x80 U+00c7 #LATIN CAPITAL LETTER C WITH CEDILLA diff --git a/src/chrtrans/cp737_uni.tbl b/src/chrtrans/cp737_uni.tbl index 81442ccc..32f01c8c 100644 --- a/src/chrtrans/cp737_uni.tbl +++ b/src/chrtrans/cp737_uni.tbl @@ -2,7 +2,7 @@ Mcp737 #Name as a Display Charset (used on Options screen) -OGreek (cp737) +ODosGreek (cp737) # # Name: cp737_DOSGreek to Unicode table diff --git a/src/chrtrans/cp775_uni.tbl b/src/chrtrans/cp775_uni.tbl index 4d63208b..02a8b61b 100644 --- a/src/chrtrans/cp775_uni.tbl +++ b/src/chrtrans/cp775_uni.tbl @@ -2,7 +2,7 @@ Mcp775 #Name as a Display Charset (used on Options screen) -OBaltic Rim (cp775) +ODosBaltRim (cp775) # Name: cp775_DOSBaltRim to Unicode table # Unicode version: 2.0 @@ -20,10 +20,134 @@ OBaltic Rim (cp775) # # The entries are in cp775_DOSBaltRim order # -################## - -0x20-0x7e idem -# +#0x00 U+0000 #NULL +#0x01 U+0001 #START OF HEADING +#0x02 U+0002 #START OF TEXT +#0x03 U+0003 #END OF TEXT +#0x04 U+0004 #END OF TRANSMISSION +#0x05 U+0005 #ENQUIRY +#0x06 U+0006 #ACKNOWLEDGE +#0x07 U+0007 #BELL +#0x08 U+0008 #BACKSPACE +#0x09 U+0009 #HORIZONTAL TABULATION +#0x0a U+000a #LINE FEED +#0x0b U+000b #VERTICAL TABULATION +#0x0c U+000c #FORM FEED +#0x0d U+000d #CARRIAGE RETURN +#0x0e U+000e #SHIFT OUT +#0x0f U+000f #SHIFT IN +#0x10 U+0010 #DATA LINK ESCAPE +#0x11 U+0011 #DEVICE CONTROL ONE +#0x12 U+0012 #DEVICE CONTROL TWO +#0x13 U+0013 #DEVICE CONTROL THREE +#0x14 U+0014 #DEVICE CONTROL FOUR +#0x15 U+0015 #NEGATIVE ACKNOWLEDGE +#0x16 U+0016 #SYNCHRONOUS IDLE +#0x17 U+0017 #END OF TRANSMISSION BLOCK +#0x18 U+0018 #CANCEL +#0x19 U+0019 #END OF MEDIUM +#0x1a U+001a #SUBSTITUTE +#0x1b U+001b #ESCAPE +#0x1c U+001c #FILE SEPARATOR +#0x1d U+001d #GROUP SEPARATOR +#0x1e U+001e #RECORD SEPARATOR +#0x1f U+001f #UNIT SEPARATOR +0x20 U+0020 #SPACE +0x21 U+0021 #EXCLAMATION MARK +0x22 U+0022 #QUOTATION MARK +0x23 U+0023 #NUMBER SIGN +0x24 U+0024 #DOLLAR SIGN +0x25 U+0025 #PERCENT SIGN +0x26 U+0026 #AMPERSAND +0x27 U+0027 #APOSTROPHE +0x28 U+0028 #LEFT PARENTHESIS +0x29 U+0029 #RIGHT PARENTHESIS +0x2a U+002a #ASTERISK +0x2b U+002b #PLUS SIGN +0x2c U+002c #COMMA +0x2d U+002d #HYPHEN-MINUS +0x2e U+002e #FULL STOP +0x2f U+002f #SOLIDUS +0x30 U+0030 #DIGIT ZERO +0x31 U+0031 #DIGIT ONE +0x32 U+0032 #DIGIT TWO +0x33 U+0033 #DIGIT THREE +0x34 U+0034 #DIGIT FOUR +0x35 U+0035 #DIGIT FIVE +0x36 U+0036 #DIGIT SIX +0x37 U+0037 #DIGIT SEVEN +0x38 U+0038 #DIGIT EIGHT +0x39 U+0039 #DIGIT NINE +0x3a U+003a #COLON +0x3b U+003b #SEMICOLON +0x3c U+003c #LESS-THAN SIGN +0x3d U+003d #EQUALS SIGN +0x3e U+003e #GREATER-THAN SIGN +0x3f U+003f #QUESTION MARK +0x40 U+0040 #COMMERCIAL AT +0x41 U+0041 #LATIN CAPITAL LETTER A +0x42 U+0042 #LATIN CAPITAL LETTER B +0x43 U+0043 #LATIN CAPITAL LETTER C +0x44 U+0044 #LATIN CAPITAL LETTER D +0x45 U+0045 #LATIN CAPITAL LETTER E +0x46 U+0046 #LATIN CAPITAL LETTER F +0x47 U+0047 #LATIN CAPITAL LETTER G +0x48 U+0048 #LATIN CAPITAL LETTER H +0x49 U+0049 #LATIN CAPITAL LETTER I +0x4a U+004a #LATIN CAPITAL LETTER J +0x4b U+004b #LATIN CAPITAL LETTER K +0x4c U+004c #LATIN CAPITAL LETTER L +0x4d U+004d #LATIN CAPITAL LETTER M +0x4e U+004e #LATIN CAPITAL LETTER N +0x4f U+004f #LATIN CAPITAL LETTER O +0x50 U+0050 #LATIN CAPITAL LETTER P +0x51 U+0051 #LATIN CAPITAL LETTER Q +0x52 U+0052 #LATIN CAPITAL LETTER R +0x53 U+0053 #LATIN CAPITAL LETTER S +0x54 U+0054 #LATIN CAPITAL LETTER T +0x55 U+0055 #LATIN CAPITAL LETTER U +0x56 U+0056 #LATIN CAPITAL LETTER V +0x57 U+0057 #LATIN CAPITAL LETTER W +0x58 U+0058 #LATIN CAPITAL LETTER X +0x59 U+0059 #LATIN CAPITAL LETTER Y +0x5a U+005a #LATIN CAPITAL LETTER Z +0x5b U+005b #LEFT SQUARE BRACKET +0x5c U+005c #REVERSE SOLIDUS +0x5d U+005d #RIGHT SQUARE BRACKET +0x5e U+005e #CIRCUMFLEX ACCENT +0x5f U+005f #LOW LINE +0x60 U+0060 #GRAVE ACCENT +0x61 U+0061 #LATIN SMALL LETTER A +0x62 U+0062 #LATIN SMALL LETTER B +0x63 U+0063 #LATIN SMALL LETTER C +0x64 U+0064 #LATIN SMALL LETTER D +0x65 U+0065 #LATIN SMALL LETTER E +0x66 U+0066 #LATIN SMALL LETTER F +0x67 U+0067 #LATIN SMALL LETTER G +0x68 U+0068 #LATIN SMALL LETTER H +0x69 U+0069 #LATIN SMALL LETTER I +0x6a U+006a #LATIN SMALL LETTER J +0x6b U+006b #LATIN SMALL LETTER K +0x6c U+006c #LATIN SMALL LETTER L +0x6d U+006d #LATIN SMALL LETTER M +0x6e U+006e #LATIN SMALL LETTER N +0x6f U+006f #LATIN SMALL LETTER O +0x70 U+0070 #LATIN SMALL LETTER P +0x71 U+0071 #LATIN SMALL LETTER Q +0x72 U+0072 #LATIN SMALL LETTER R +0x73 U+0073 #LATIN SMALL LETTER S +0x74 U+0074 #LATIN SMALL LETTER T +0x75 U+0075 #LATIN SMALL LETTER U +0x76 U+0076 #LATIN SMALL LETTER V +0x77 U+0077 #LATIN SMALL LETTER W +0x78 U+0078 #LATIN SMALL LETTER X +0x79 U+0079 #LATIN SMALL LETTER Y +0x7a U+007a #LATIN SMALL LETTER Z +0x7b U+007b #LEFT CURLY BRACKET +0x7c U+007c #VERTICAL LINE +0x7d U+007d #RIGHT CURLY BRACKET +0x7e U+007e #TILDE +#0x7f U+007f #DELETE 0x80 U+0106 #LATIN CAPITAL LETTER C WITH ACUTE 0x81 U+00fc #LATIN SMALL LETTER U WITH DIAERESIS 0x82 U+00e9 #LATIN SMALL LETTER E WITH ACUTE diff --git a/src/chrtrans/cp850_uni.tbl b/src/chrtrans/cp850_uni.tbl index af4dbff5..05685971 100644 --- a/src/chrtrans/cp850_uni.tbl +++ b/src/chrtrans/cp850_uni.tbl @@ -8,29 +8,153 @@ D0 Mcp850 #Name as a Display Charset (used on Options screen) -OWestern (cp850) +ODosLatin1 (cp850) # # Name: cp850_DOSLatin1 to Unicode table -# Unicode version: 2.0 -# Table version: 2.00 +# Unicode version: 1.1 +# Table version: 1.1 # Table format: Format A -# Date: 04/24/96 -# Authors: Lori Brownell <loribr@microsoft.com> -# K.D. Chang <a-kchang@microsoft.com> +# Date: 03/31/95 +# Authors: Michel Suignard <michelsu@microsoft.com> +# Lori Hoerth <lorih@microsoft.com> # General notes: none # # Format: Three tab-separated columns # Column #1 is the cp850_DOSLatin1 code (in hex) -# Column #2 is the Unicode (in hex as 0xXXXX) +# Column #2 is the Unicode (in hex as U+XXXX) # Column #3 is the Unicode name (follows a comment sign, '#') # # The entries are in cp850_DOSLatin1 order # -################## - -0x20-0x7e idem -# +#0x00 U+0000 #NULL +#0x01 U+0001 #START OF HEADING +#0x02 U+0002 #START OF TEXT +#0x03 U+0003 #END OF TEXT +#0x04 U+0004 #END OF TRANSMISSION +#0x05 U+0005 #ENQUIRY +#0x06 U+0006 #ACKNOWLEDGE +#0x07 U+0007 #BELL +#0x08 U+0008 #BACKSPACE +#0x09 U+0009 #HORIZONTAL TABULATION +#0x0a U+000a #LINE FEED +#0x0b U+000b #VERTICAL TABULATION +#0x0c U+000c #FORM FEED +#0x0d U+000d #CARRIAGE RETURN +#0x0e U+000e #SHIFT OUT +#0x0f U+000f #SHIFT IN +#0x10 U+0010 #DATA LINK ESCAPE +#0x11 U+0011 #DEVICE CONTROL ONE +#0x12 U+0012 #DEVICE CONTROL TWO +#0x13 U+0013 #DEVICE CONTROL THREE +#0x14 U+0014 #DEVICE CONTROL FOUR +#0x15 U+0015 #NEGATIVE ACKNOWLEDGE +#0x16 U+0016 #SYNCHRONOUS IDLE +#0x17 U+0017 #END OF TRANSMISSION BLOCK +#0x18 U+0018 #CANCEL +#0x19 U+0019 #END OF MEDIUM +#0x1a U+001a #SUBSTITUTE +#0x1b U+001b #ESCAPE +#0x1c U+001c #FILE SEPARATOR +#0x1d U+001d #GROUP SEPARATOR +#0x1e U+001e #RECORD SEPARATOR +#0x1f U+001f #UNIT SEPARATOR +0x20 U+0020 #SPACE +0x21 U+0021 #EXCLAMATION MARK +0x22 U+0022 #QUOTATION MARK +0x23 U+0023 #NUMBER SIGN +0x24 U+0024 #DOLLAR SIGN +0x25 U+0025 #PERCENT SIGN +0x26 U+0026 #AMPERSAND +0x27 U+0027 #APOSTROPHE +0x28 U+0028 #LEFT PARENTHESIS +0x29 U+0029 #RIGHT PARENTHESIS +0x2a U+002a #ASTERISK +0x2b U+002b #PLUS SIGN +0x2c U+002c #COMMA +0x2d U+002d #HYPHEN-MINUS +0x2e U+002e #FULL STOP +0x2f U+002f #SOLIDUS +0x30 U+0030 #DIGIT ZERO +0x31 U+0031 #DIGIT ONE +0x32 U+0032 #DIGIT TWO +0x33 U+0033 #DIGIT THREE +0x34 U+0034 #DIGIT FOUR +0x35 U+0035 #DIGIT FIVE +0x36 U+0036 #DIGIT SIX +0x37 U+0037 #DIGIT SEVEN +0x38 U+0038 #DIGIT EIGHT +0x39 U+0039 #DIGIT NINE +0x3a U+003a #COLON +0x3b U+003b #SEMICOLON +0x3c U+003c #LESS-THAN SIGN +0x3d U+003d #EQUALS SIGN +0x3e U+003e #GREATER-THAN SIGN +0x3f U+003f #QUESTION MARK +0x40 U+0040 #COMMERCIAL AT +0x41 U+0041 #LATIN CAPITAL LETTER A +0x42 U+0042 #LATIN CAPITAL LETTER B +0x43 U+0043 #LATIN CAPITAL LETTER C +0x44 U+0044 #LATIN CAPITAL LETTER D +0x45 U+0045 #LATIN CAPITAL LETTER E +0x46 U+0046 #LATIN CAPITAL LETTER F +0x47 U+0047 #LATIN CAPITAL LETTER G +0x48 U+0048 #LATIN CAPITAL LETTER H +0x49 U+0049 #LATIN CAPITAL LETTER I +0x4a U+004a #LATIN CAPITAL LETTER J +0x4b U+004b #LATIN CAPITAL LETTER K +0x4c U+004c #LATIN CAPITAL LETTER L +0x4d U+004d #LATIN CAPITAL LETTER M +0x4e U+004e #LATIN CAPITAL LETTER N +0x4f U+004f #LATIN CAPITAL LETTER O +0x50 U+0050 #LATIN CAPITAL LETTER P +0x51 U+0051 #LATIN CAPITAL LETTER Q +0x52 U+0052 #LATIN CAPITAL LETTER R +0x53 U+0053 #LATIN CAPITAL LETTER S +0x54 U+0054 #LATIN CAPITAL LETTER T +0x55 U+0055 #LATIN CAPITAL LETTER U +0x56 U+0056 #LATIN CAPITAL LETTER V +0x57 U+0057 #LATIN CAPITAL LETTER W +0x58 U+0058 #LATIN CAPITAL LETTER X +0x59 U+0059 #LATIN CAPITAL LETTER Y +0x5a U+005a #LATIN CAPITAL LETTER Z +0x5b U+005b #LEFT SQUARE BRACKET +0x5c U+005c #REVERSE SOLIDUS +0x5d U+005d #RIGHT SQUARE BRACKET +0x5e U+005e #CIRCUMFLEX ACCENT +0x5f U+005f #LOW LINE +0x60 U+0060 #GRAVE ACCENT +0x61 U+0061 #LATIN SMALL LETTER A +0x62 U+0062 #LATIN SMALL LETTER B +0x63 U+0063 #LATIN SMALL LETTER C +0x64 U+0064 #LATIN SMALL LETTER D +0x65 U+0065 #LATIN SMALL LETTER E +0x66 U+0066 #LATIN SMALL LETTER F +0x67 U+0067 #LATIN SMALL LETTER G +0x68 U+0068 #LATIN SMALL LETTER H +0x69 U+0069 #LATIN SMALL LETTER I +0x6a U+006a #LATIN SMALL LETTER J +0x6b U+006b #LATIN SMALL LETTER K +0x6c U+006c #LATIN SMALL LETTER L +0x6d U+006d #LATIN SMALL LETTER M +0x6e U+006e #LATIN SMALL LETTER N +0x6f U+006f #LATIN SMALL LETTER O +0x70 U+0070 #LATIN SMALL LETTER P +0x71 U+0071 #LATIN SMALL LETTER Q +0x72 U+0072 #LATIN SMALL LETTER R +0x73 U+0073 #LATIN SMALL LETTER S +0x74 U+0074 #LATIN SMALL LETTER T +0x75 U+0075 #LATIN SMALL LETTER U +0x76 U+0076 #LATIN SMALL LETTER V +0x77 U+0077 #LATIN SMALL LETTER W +0x78 U+0078 #LATIN SMALL LETTER X +0x79 U+0079 #LATIN SMALL LETTER Y +0x7a U+007a #LATIN SMALL LETTER Z +0x7b U+007b #LEFT CURLY BRACKET +0x7c U+007c #VERTICAL LINE +0x7d U+007d #RIGHT CURLY BRACKET +0x7e U+007e #TILDE +0x7f U+007f #DELETE 0x80 U+00c7 #LATIN CAPITAL LETTER C WITH CEDILLA 0x81 U+00fc #LATIN SMALL LETTER U WITH DIAERESIS 0x82 U+00e9 #LATIN SMALL LETTER E WITH ACUTE diff --git a/src/chrtrans/cp852_uni.tbl b/src/chrtrans/cp852_uni.tbl index 946b4996..0658d893 100644 --- a/src/chrtrans/cp852_uni.tbl +++ b/src/chrtrans/cp852_uni.tbl @@ -2,7 +2,7 @@ Mcp852 #Name as a Display Charset (used on Options screen) -OEastern European (cp852) +ODosLatin2 (cp852) # # Name: cp852_DOSLatin2 to Unicode table @@ -21,136 +21,260 @@ OEastern European (cp852) # # The entries are in cp852_DOSLatin2 order # -################## - -0x20-0x7e idem -# -0x80 U+00c7 #LATIN CAPITAL LETTER C WITH CEDILLA -0x81 U+00fc #LATIN SMALL LETTER U WITH DIAERESIS -0x82 U+00e9 #LATIN SMALL LETTER E WITH ACUTE -0x83 U+00e2 #LATIN SMALL LETTER A WITH CIRCUMFLEX -0x84 U+00e4 #LATIN SMALL LETTER A WITH DIAERESIS -0x85 U+016f #LATIN SMALL LETTER U WITH RING ABOVE -0x86 U+0107 #LATIN SMALL LETTER C WITH ACUTE -0x87 U+00e7 #LATIN SMALL LETTER C WITH CEDILLA -0x88 U+0142 #LATIN SMALL LETTER L WITH STROKE -0x89 U+00eb #LATIN SMALL LETTER E WITH DIAERESIS -0x8a U+0150 #LATIN CAPITAL LETTER O WITH DOUBLE ACUTE -0x8b U+0151 #LATIN SMALL LETTER O WITH DOUBLE ACUTE -0x8c U+00ee #LATIN SMALL LETTER I WITH CIRCUMFLEX -0x8d U+0179 #LATIN CAPITAL LETTER Z WITH ACUTE -0x8e U+00c4 #LATIN CAPITAL LETTER A WITH DIAERESIS -0x8f U+0106 #LATIN CAPITAL LETTER C WITH ACUTE -0x90 U+00c9 #LATIN CAPITAL LETTER E WITH ACUTE -0x91 U+0139 #LATIN CAPITAL LETTER L WITH ACUTE -0x92 U+013a #LATIN SMALL LETTER L WITH ACUTE -0x93 U+00f4 #LATIN SMALL LETTER O WITH CIRCUMFLEX -0x94 U+00f6 #LATIN SMALL LETTER O WITH DIAERESIS -0x95 U+013d #LATIN CAPITAL LETTER L WITH CARON -0x96 U+013e #LATIN SMALL LETTER L WITH CARON -0x97 U+015a #LATIN CAPITAL LETTER S WITH ACUTE -0x98 U+015b #LATIN SMALL LETTER S WITH ACUTE -0x99 U+00d6 #LATIN CAPITAL LETTER O WITH DIAERESIS -0x9a U+00dc #LATIN CAPITAL LETTER U WITH DIAERESIS -0x9b U+0164 #LATIN CAPITAL LETTER T WITH CARON -0x9c U+0165 #LATIN SMALL LETTER T WITH CARON -0x9d U+0141 #LATIN CAPITAL LETTER L WITH STROKE -0x9e U+00d7 #MULTIPLICATION SIGN -0x9f U+010d #LATIN SMALL LETTER C WITH CARON -0xa0 U+00e1 #LATIN SMALL LETTER A WITH ACUTE -0xa1 U+00ed #LATIN SMALL LETTER I WITH ACUTE -0xa2 U+00f3 #LATIN SMALL LETTER O WITH ACUTE -0xa3 U+00fa #LATIN SMALL LETTER U WITH ACUTE -0xa4 U+0104 #LATIN CAPITAL LETTER A WITH OGONEK -0xa5 U+0105 #LATIN SMALL LETTER A WITH OGONEK -0xa6 U+017d #LATIN CAPITAL LETTER Z WITH CARON -0xa7 U+017e #LATIN SMALL LETTER Z WITH CARON -0xa8 U+0118 #LATIN CAPITAL LETTER E WITH OGONEK -0xa9 U+0119 #LATIN SMALL LETTER E WITH OGONEK -0xaa U+00ac #NOT SIGN -0xab U+017a #LATIN SMALL LETTER Z WITH ACUTE -0xac U+010c #LATIN CAPITAL LETTER C WITH CARON -0xad U+015f #LATIN SMALL LETTER S WITH CEDILLA -0xae U+00ab #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK -0xaf U+00bb #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -0xb0 U+2591 #LIGHT SHADE -0xb1 U+2592 #MEDIUM SHADE -0xb2 U+2593 #DARK SHADE -0xb3 U+2502 #BOX DRAWINGS LIGHT VERTICAL -0xb4 U+2524 #BOX DRAWINGS LIGHT VERTICAL AND LEFT -0xb5 U+00c1 #LATIN CAPITAL LETTER A WITH ACUTE -0xb6 U+00c2 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX -0xb7 U+011a #LATIN CAPITAL LETTER E WITH CARON -0xb8 U+015e #LATIN CAPITAL LETTER S WITH CEDILLA -0xb9 U+2563 #BOX DRAWINGS DOUBLE VERTICAL AND LEFT -0xba U+2551 #BOX DRAWINGS DOUBLE VERTICAL -0xbb U+2557 #BOX DRAWINGS DOUBLE DOWN AND LEFT -0xbc U+255d #BOX DRAWINGS DOUBLE UP AND LEFT -0xbd U+017b #LATIN CAPITAL LETTER Z WITH DOT ABOVE -0xbe U+017c #LATIN SMALL LETTER Z WITH DOT ABOVE -0xbf U+2510 #BOX DRAWINGS LIGHT DOWN AND LEFT -0xc0 U+2514 #BOX DRAWINGS LIGHT UP AND RIGHT -0xc1 U+2534 #BOX DRAWINGS LIGHT UP AND HORIZONTAL -0xc2 U+252c #BOX DRAWINGS LIGHT DOWN AND HORIZONTAL -0xc3 U+251c #BOX DRAWINGS LIGHT VERTICAL AND RIGHT -0xc4 U+2500 #BOX DRAWINGS LIGHT HORIZONTAL -0xc5 U+253c #BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL -0xc6 U+0102 #LATIN CAPITAL LETTER A WITH BREVE -0xc7 U+0103 #LATIN SMALL LETTER A WITH BREVE -0xc8 U+255a #BOX DRAWINGS DOUBLE UP AND RIGHT -0xc9 U+2554 #BOX DRAWINGS DOUBLE DOWN AND RIGHT -0xca U+2569 #BOX DRAWINGS DOUBLE UP AND HORIZONTAL -0xcb U+2566 #BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL -0xcc U+2560 #BOX DRAWINGS DOUBLE VERTICAL AND RIGHT -0xcd U+2550 #BOX DRAWINGS DOUBLE HORIZONTAL -0xce U+256c #BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL -0xcf U+00a4 #CURRENCY SIGN -0xd0 U+0111 #LATIN SMALL LETTER D WITH STROKE -0xd1 U+0110 #LATIN CAPITAL LETTER D WITH STROKE -0xd2 U+010e #LATIN CAPITAL LETTER D WITH CARON -0xd3 U+00cb #LATIN CAPITAL LETTER E WITH DIAERESIS -0xd4 U+010f #LATIN SMALL LETTER D WITH CARON -0xd5 U+0147 #LATIN CAPITAL LETTER N WITH CARON -0xd6 U+00cd #LATIN CAPITAL LETTER I WITH ACUTE -0xd7 U+00ce #LATIN CAPITAL LETTER I WITH CIRCUMFLEX -0xd8 U+011b #LATIN SMALL LETTER E WITH CARON -0xd9 U+2518 #BOX DRAWINGS LIGHT UP AND LEFT -0xda U+250c #BOX DRAWINGS LIGHT DOWN AND RIGHT -0xdb U+2588 #FULL BLOCK -0xdc U+2584 #LOWER HALF BLOCK -0xdd U+0162 #LATIN CAPITAL LETTER T WITH CEDILLA -0xde U+016e #LATIN CAPITAL LETTER U WITH RING ABOVE -0xdf U+2580 #UPPER HALF BLOCK -0xe0 U+00d3 #LATIN CAPITAL LETTER O WITH ACUTE -0xe1 U+00df #LATIN SMALL LETTER SHARP S -0xe2 U+00d4 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX -0xe3 U+0143 #LATIN CAPITAL LETTER N WITH ACUTE -0xe4 U+0144 #LATIN SMALL LETTER N WITH ACUTE -0xe5 U+0148 #LATIN SMALL LETTER N WITH CARON -0xe6 U+0160 #LATIN CAPITAL LETTER S WITH CARON -0xe7 U+0161 #LATIN SMALL LETTER S WITH CARON -0xe8 U+0154 #LATIN CAPITAL LETTER R WITH ACUTE -0xe9 U+00da #LATIN CAPITAL LETTER U WITH ACUTE -0xea U+0155 #LATIN SMALL LETTER R WITH ACUTE -0xeb U+0170 #LATIN CAPITAL LETTER U WITH DOUBLE ACUTE -0xec U+00fd #LATIN SMALL LETTER Y WITH ACUTE -0xed U+00dd #LATIN CAPITAL LETTER Y WITH ACUTE -0xee U+0163 #LATIN SMALL LETTER T WITH CEDILLA -0xef U+00b4 #ACUTE ACCENT -0xf0 U+00ad #SOFT HYPHEN -0xf1 U+02dd #DOUBLE ACUTE ACCENT -0xf2 U+02db #OGONEK -0xf3 U+02c7 #CARON -0xf4 U+02d8 #BREVE -0xf5 U+00a7 #SECTION SIGN -0xf6 U+00f7 #DIVISION SIGN -0xf7 U+00b8 #CEDILLA -0xf8 U+00b0 #DEGREE SIGN -0xf9 U+00a8 #DIAERESIS -0xfa U+02d9 #DOT ABOVE -0xfb U+0171 #LATIN SMALL LETTER U WITH DOUBLE ACUTE -0xfc U+0158 #LATIN CAPITAL LETTER R WITH CARON -0xfd U+0159 #LATIN SMALL LETTER R WITH CARON -0xfe U+25a0 #BLACK SQUARE -0xff U+00a0 #NO-BREAK SPACE +#0x00 U+0000 #NULL +#0x01 U+0001 #START OF HEADING +#0x02 U+0002 #START OF TEXT +#0x03 U+0003 #END OF TEXT +#0x04 U+0004 #END OF TRANSMISSION +#0x05 U+0005 #ENQUIRY +#0x06 U+0006 #ACKNOWLEDGE +#0x07 U+0007 #BELL +#0x08 U+0008 #BACKSPACE +#0x09 U+0009 #HORIZONTAL TABULATION +#0x0a U+000a #LINE FEED +#0x0b U+000b #VERTICAL TABULATION +#0x0c U+000c #FORM FEED +#0x0d U+000d #CARRIAGE RETURN +#0x0e U+000e #SHIFT OUT +#0x0f U+000f #SHIFT IN +#0x10 U+0010 #DATA LINK ESCAPE +#0x11 U+0011 #DEVICE CONTROL ONE +#0x12 U+0012 #DEVICE CONTROL TWO +#0x13 U+0013 #DEVICE CONTROL THREE +#0x14 U+0014 #DEVICE CONTROL FOUR +#0x15 U+0015 #NEGATIVE ACKNOWLEDGE +#0x16 U+0016 #SYNCHRONOUS IDLE +#0x17 U+0017 #END OF TRANSMISSION BLOCK +#0x18 U+0018 #CANCEL +#0x19 U+0019 #END OF MEDIUM +#0x1a U+001a #SUBSTITUTE +#0x1b U+001b #ESCAPE +#0x1c U+001c #FILE SEPARATOR +#0x1d U+001d #GROUP SEPARATOR +#0x1e U+001e #RECORD SEPARATOR +#0x1f U+001f #UNIT SEPARATOR +0x20 U+0020 #SPACE +0x21 U+0021 #EXCLAMATION MARK +0x22 U+0022 #QUOTATION MARK +0x23 U+0023 #NUMBER SIGN +0x24 U+0024 #DOLLAR SIGN +0x25 U+0025 #PERCENT SIGN +0x26 U+0026 #AMPERSAND +0x27 U+0027 #APOSTROPHE +0x28 U+0028 #LEFT PARENTHESIS +0x29 U+0029 #RIGHT PARENTHESIS +0x2a U+002a #ASTERISK +0x2b U+002b #PLUS SIGN +0x2c U+002c #COMMA +0x2d U+002d #HYPHEN-MINUS +0x2e U+002e #FULL STOP +0x2f U+002f #SOLIDUS +0x30 U+0030 #DIGIT ZERO +0x31 U+0031 #DIGIT ONE +0x32 U+0032 #DIGIT TWO +0x33 U+0033 #DIGIT THREE +0x34 U+0034 #DIGIT FOUR +0x35 U+0035 #DIGIT FIVE +0x36 U+0036 #DIGIT SIX +0x37 U+0037 #DIGIT SEVEN +0x38 U+0038 #DIGIT EIGHT +0x39 U+0039 #DIGIT NINE +0x3a U+003a #COLON +0x3b U+003b #SEMICOLON +0x3c U+003c #LESS-THAN SIGN +0x3d U+003d #EQUALS SIGN +0x3e U+003e #GREATER-THAN SIGN +0x3f U+003f #QUESTION MARK +0x40 U+0040 #COMMERCIAL AT +0x41 U+0041 #LATIN CAPITAL LETTER A +0x42 U+0042 #LATIN CAPITAL LETTER B +0x43 U+0043 #LATIN CAPITAL LETTER C +0x44 U+0044 #LATIN CAPITAL LETTER D +0x45 U+0045 #LATIN CAPITAL LETTER E +0x46 U+0046 #LATIN CAPITAL LETTER F +0x47 U+0047 #LATIN CAPITAL LETTER G +0x48 U+0048 #LATIN CAPITAL LETTER H +0x49 U+0049 #LATIN CAPITAL LETTER I +0x4a U+004a #LATIN CAPITAL LETTER J +0x4b U+004b #LATIN CAPITAL LETTER K +0x4c U+004c #LATIN CAPITAL LETTER L +0x4d U+004d #LATIN CAPITAL LETTER M +0x4e U+004e #LATIN CAPITAL LETTER N +0x4f U+004f #LATIN CAPITAL LETTER O +0x50 U+0050 #LATIN CAPITAL LETTER P +0x51 U+0051 #LATIN CAPITAL LETTER Q +0x52 U+0052 #LATIN CAPITAL LETTER R +0x53 U+0053 #LATIN CAPITAL LETTER S +0x54 U+0054 #LATIN CAPITAL LETTER T +0x55 U+0055 #LATIN CAPITAL LETTER U +0x56 U+0056 #LATIN CAPITAL LETTER V +0x57 U+0057 #LATIN CAPITAL LETTER W +0x58 U+0058 #LATIN CAPITAL LETTER X +0x59 U+0059 #LATIN CAPITAL LETTER Y +0x5a U+005a #LATIN CAPITAL LETTER Z +0x5b U+005b #LEFT SQUARE BRACKET +0x5c U+005c #REVERSE SOLIDUS +0x5d U+005d #RIGHT SQUARE BRACKET +0x5e U+005e #CIRCUMFLEX ACCENT +0x5f U+005f #LOW LINE +0x60 U+0060 #GRAVE ACCENT +0x61 U+0061 #LATIN SMALL LETTER A +0x62 U+0062 #LATIN SMALL LETTER B +0x63 U+0063 #LATIN SMALL LETTER C +0x64 U+0064 #LATIN SMALL LETTER D +0x65 U+0065 #LATIN SMALL LETTER E +0x66 U+0066 #LATIN SMALL LETTER F +0x67 U+0067 #LATIN SMALL LETTER G +0x68 U+0068 #LATIN SMALL LETTER H +0x69 U+0069 #LATIN SMALL LETTER I +0x6a U+006a #LATIN SMALL LETTER J +0x6b U+006b #LATIN SMALL LETTER K +0x6c U+006c #LATIN SMALL LETTER L +0x6d U+006d #LATIN SMALL LETTER M +0x6e U+006e #LATIN SMALL LETTER N +0x6f U+006f #LATIN SMALL LETTER O +0x70 U+0070 #LATIN SMALL LETTER P +0x71 U+0071 #LATIN SMALL LETTER Q +0x72 U+0072 #LATIN SMALL LETTER R +0x73 U+0073 #LATIN SMALL LETTER S +0x74 U+0074 #LATIN SMALL LETTER T +0x75 U+0075 #LATIN SMALL LETTER U +0x76 U+0076 #LATIN SMALL LETTER V +0x77 U+0077 #LATIN SMALL LETTER W +0x78 U+0078 #LATIN SMALL LETTER X +0x79 U+0079 #LATIN SMALL LETTER Y +0x7a U+007a #LATIN SMALL LETTER Z +0x7b U+007b #LEFT CURLY BRACKET +0x7c U+007c #VERTICAL LINE +0x7d U+007d #RIGHT CURLY BRACKET +0x7e U+007e #TILDE +#0x7f U+007f #DELETE +0x80 U+00c7 #LATIN CAPITAL LETTER C WITH CEDILLA +0x81 U+00fc #LATIN SMALL LETTER U WITH DIAERESIS +0x82 U+00e9 #LATIN SMALL LETTER E WITH ACUTE +0x83 U+00e2 #LATIN SMALL LETTER A WITH CIRCUMFLEX +0x84 U+00e4 #LATIN SMALL LETTER A WITH DIAERESIS +0x85 U+016f #LATIN SMALL LETTER U WITH RING ABOVE +0x86 U+0107 #LATIN SMALL LETTER C WITH ACUTE +0x87 U+00e7 #LATIN SMALL LETTER C WITH CEDILLA +0x88 U+0142 #LATIN SMALL LETTER L WITH STROKE +0x89 U+00eb #LATIN SMALL LETTER E WITH DIAERESIS +0x8a U+0150 #LATIN CAPITAL LETTER O WITH DOUBLE ACUTE +0x8b U+0151 #LATIN SMALL LETTER O WITH DOUBLE ACUTE +0x8c U+00ee #LATIN SMALL LETTER I WITH CIRCUMFLEX +0x8d U+0179 #LATIN CAPITAL LETTER Z WITH ACUTE +0x8e U+00c4 #LATIN CAPITAL LETTER A WITH DIAERESIS +0x8f U+0106 #LATIN CAPITAL LETTER C WITH ACUTE +0x90 U+00c9 #LATIN CAPITAL LETTER E WITH ACUTE +0x91 U+0139 #LATIN CAPITAL LETTER L WITH ACUTE +0x92 U+013a #LATIN SMALL LETTER L WITH ACUTE +0x93 U+00f4 #LATIN SMALL LETTER O WITH CIRCUMFLEX +0x94 U+00f6 #LATIN SMALL LETTER O WITH DIAERESIS +0x95 U+013d #LATIN CAPITAL LETTER L WITH CARON +0x96 U+013e #LATIN SMALL LETTER L WITH CARON +0x97 U+015a #LATIN CAPITAL LETTER S WITH ACUTE +0x98 U+015b #LATIN SMALL LETTER S WITH ACUTE +0x99 U+00d6 #LATIN CAPITAL LETTER O WITH DIAERESIS +0x9a U+00dc #LATIN CAPITAL LETTER U WITH DIAERESIS +0x9b U+0164 #LATIN CAPITAL LETTER T WITH CARON +0x9c U+0165 #LATIN SMALL LETTER T WITH CARON +0x9d U+0141 #LATIN CAPITAL LETTER L WITH STROKE +0x9e U+00d7 #MULTIPLICATION SIGN +0x9f U+010d #LATIN SMALL LETTER C WITH CARON +0xa0 U+00e1 #LATIN SMALL LETTER A WITH ACUTE +0xa1 U+00ed #LATIN SMALL LETTER I WITH ACUTE +0xa2 U+00f3 #LATIN SMALL LETTER O WITH ACUTE +0xa3 U+00fa #LATIN SMALL LETTER U WITH ACUTE +0xa4 U+0104 #LATIN CAPITAL LETTER A WITH OGONEK +0xa5 U+0105 #LATIN SMALL LETTER A WITH OGONEK +0xa6 U+017d #LATIN CAPITAL LETTER Z WITH CARON +0xa7 U+017e #LATIN SMALL LETTER Z WITH CARON +0xa8 U+0118 #LATIN CAPITAL LETTER E WITH OGONEK +0xa9 U+0119 #LATIN SMALL LETTER E WITH OGONEK +0xaa U+00ac #NOT SIGN +0xab U+017a #LATIN SMALL LETTER Z WITH ACUTE +0xac U+010c #LATIN CAPITAL LETTER C WITH CARON +0xad U+015f #LATIN SMALL LETTER S WITH CEDILLA +0xae U+00ab #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +0xaf U+00bb #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +0xb0 U+2591 #LIGHT SHADE +0xb1 U+2592 #MEDIUM SHADE +0xb2 U+2593 #DARK SHADE +0xb3 U+2502 #BOX DRAWINGS LIGHT VERTICAL +0xb4 U+2524 #BOX DRAWINGS LIGHT VERTICAL AND LEFT +0xb5 U+00c1 #LATIN CAPITAL LETTER A WITH ACUTE +0xb6 U+00c2 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX +0xb7 U+011a #LATIN CAPITAL LETTER E WITH CARON +0xb8 U+015e #LATIN CAPITAL LETTER S WITH CEDILLA +0xb9 U+2563 #BOX DRAWINGS DOUBLE VERTICAL AND LEFT +0xba U+2551 #BOX DRAWINGS DOUBLE VERTICAL +0xbb U+2557 #BOX DRAWINGS DOUBLE DOWN AND LEFT +0xbc U+255d #BOX DRAWINGS DOUBLE UP AND LEFT +0xbd U+017b #LATIN CAPITAL LETTER Z WITH DOT ABOVE +0xbe U+017c #LATIN SMALL LETTER Z WITH DOT ABOVE +0xbf U+2510 #BOX DRAWINGS LIGHT DOWN AND LEFT +0xc0 U+2514 #BOX DRAWINGS LIGHT UP AND RIGHT +0xc1 U+2534 #BOX DRAWINGS LIGHT UP AND HORIZONTAL +0xc2 U+252c #BOX DRAWINGS LIGHT DOWN AND HORIZONTAL +0xc3 U+251c #BOX DRAWINGS LIGHT VERTICAL AND RIGHT +0xc4 U+2500 #BOX DRAWINGS LIGHT HORIZONTAL +0xc5 U+253c #BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL +0xc6 U+0102 #LATIN CAPITAL LETTER A WITH BREVE +0xc7 U+0103 #LATIN SMALL LETTER A WITH BREVE +0xc8 U+255a #BOX DRAWINGS DOUBLE UP AND RIGHT +0xc9 U+2554 #BOX DRAWINGS DOUBLE DOWN AND RIGHT +0xca U+2569 #BOX DRAWINGS DOUBLE UP AND HORIZONTAL +0xcb U+2566 #BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL +0xcc U+2560 #BOX DRAWINGS DOUBLE VERTICAL AND RIGHT +0xcd U+2550 #BOX DRAWINGS DOUBLE HORIZONTAL +0xce U+256c #BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL +0xcf U+00a4 #CURRENCY SIGN +0xd0 U+0111 #LATIN SMALL LETTER D WITH STROKE +0xd1 U+0110 #LATIN CAPITAL LETTER D WITH STROKE +0xd2 U+010e #LATIN CAPITAL LETTER D WITH CARON +0xd3 U+00cb #LATIN CAPITAL LETTER E WITH DIAERESIS +0xd4 U+010f #LATIN SMALL LETTER D WITH CARON +0xd5 U+0147 #LATIN CAPITAL LETTER N WITH CARON +0xd6 U+00cd #LATIN CAPITAL LETTER I WITH ACUTE +0xd7 U+00ce #LATIN CAPITAL LETTER I WITH CIRCUMFLEX +0xd8 U+011b #LATIN SMALL LETTER E WITH CARON +0xd9 U+2518 #BOX DRAWINGS LIGHT UP AND LEFT +0xda U+250c #BOX DRAWINGS LIGHT DOWN AND RIGHT +0xdb U+2588 #FULL BLOCK +0xdc U+2584 #LOWER HALF BLOCK +0xdd U+0162 #LATIN CAPITAL LETTER T WITH CEDILLA +0xde U+016e #LATIN CAPITAL LETTER U WITH RING ABOVE +0xdf U+2580 #UPPER HALF BLOCK +0xe0 U+00d3 #LATIN CAPITAL LETTER O WITH ACUTE +0xe1 U+00df #LATIN SMALL LETTER SHARP S +0xe2 U+00d4 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX +0xe3 U+0143 #LATIN CAPITAL LETTER N WITH ACUTE +0xe4 U+0144 #LATIN SMALL LETTER N WITH ACUTE +0xe5 U+0148 #LATIN SMALL LETTER N WITH CARON +0xe6 U+0160 #LATIN CAPITAL LETTER S WITH CARON +0xe7 U+0161 #LATIN SMALL LETTER S WITH CARON +0xe8 U+0154 #LATIN CAPITAL LETTER R WITH ACUTE +0xe9 U+00da #LATIN CAPITAL LETTER U WITH ACUTE +0xea U+0155 #LATIN SMALL LETTER R WITH ACUTE +0xeb U+0170 #LATIN CAPITAL LETTER U WITH DOUBLE ACUTE +0xec U+00fd #LATIN SMALL LETTER Y WITH ACUTE +0xed U+00dd #LATIN CAPITAL LETTER Y WITH ACUTE +0xee U+0163 #LATIN SMALL LETTER T WITH CEDILLA +0xef U+00b4 #ACUTE ACCENT +0xf0 U+00ad #SOFT HYPHEN +0xf1 U+02dd #DOUBLE ACUTE ACCENT +0xf2 U+02db #OGONEK +0xf3 U+02c7 #CARON +0xf4 U+02d8 #BREVE +0xf5 U+00a7 #SECTION SIGN +0xf6 U+00f7 #DIVISION SIGN +0xf7 U+00b8 #CEDILLA +0xf8 U+00b0 #DEGREE SIGN +0xf9 U+00a8 #DIAERESIS +0xfa U+02d9 #DOT ABOVE +0xfb U+0171 #LATIN SMALL LETTER U WITH DOUBLE ACUTE +0xfc U+0158 #LATIN CAPITAL LETTER R WITH CARON +0xfd U+0159 #LATIN SMALL LETTER R WITH CARON +0xfe U+25a0 #BLACK SQUARE +0xff U+00a0 #NO-BREAK SPACE diff --git a/src/chrtrans/cp862_uni.tbl b/src/chrtrans/cp862_uni.tbl index 60d9692e..3d21c138 100644 --- a/src/chrtrans/cp862_uni.tbl +++ b/src/chrtrans/cp862_uni.tbl @@ -2,7 +2,7 @@ Mcp862 #Name as a Display Charset (used on Options screen). -OHebrew (cp862) +ODosHebrew (cp862) # Name: cp862_DOSHebrew to Unicode table # Unicode version: 2.0 diff --git a/src/chrtrans/cp864_uni.tbl b/src/chrtrans/cp864_uni.tbl index 8411f8b7..d6e92431 100644 --- a/src/chrtrans/cp864_uni.tbl +++ b/src/chrtrans/cp864_uni.tbl @@ -2,7 +2,7 @@ Mcp864 #Name as a Display Charset (used on Options screen). -OArabic (cp864) +ODosArabic (cp864) # Name: cp864_DOSArabic to Unicode table # Unicode version: 2.0 diff --git a/src/chrtrans/cp866_uni.tbl b/src/chrtrans/cp866_uni.tbl index 55ce0718..2d02ce1b 100644 --- a/src/chrtrans/cp866_uni.tbl +++ b/src/chrtrans/cp866_uni.tbl @@ -3,7 +3,7 @@ Mcp866 #Name as a Display Charset (used on Options screen) -OCyrillic (cp866) +ODosCyrillic (cp866) # # Name: cp866_DOSCyrillicRussian to Unicode table # Unicode version: 2.0 diff --git a/src/chrtrans/cp869_uni.tbl b/src/chrtrans/cp869_uni.tbl index 1f418728..21cdeb95 100644 --- a/src/chrtrans/cp869_uni.tbl +++ b/src/chrtrans/cp869_uni.tbl @@ -2,7 +2,7 @@ Mcp869 #Name as a Display Charset (used on Options screen) -OGreek2 (cp869) +ODosGreek2 (cp869) # Name: cp869_DOSGreek2 to Unicode table # Unicode version: 2.0 diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl index bd6b1b1c..66a63f76 100644 --- a/src/chrtrans/def7_uni.tbl +++ b/src/chrtrans/def7_uni.tbl @@ -1350,13 +1350,13 @@ U+208c:_= U+208d:( U+208e:) # Old euro currency sign glyph: -#U+20A0:CE +U+20A0:CE U+20a3:Ff U+20a4:Li U+20a7:Pt U+20a9:W= -# New euro currency sign glyph: -U+20AC:EUR +# New euro currency sign glyph ? +# U+20AC:EUR U+2103:oC U+2105:c/o U+2109:oF @@ -1754,7 +1754,6 @@ U+266e:Mx U+266f:# 0x58 U+2713 U+2717 # check marks -> x U+2720:-X -# CJK area: 0x20 U+3000 # ideographic space U+3001:,_ U+3002:._ @@ -2015,17 +2014,6 @@ U+3229:10c U+327f:KSC U+33c2:am U+33d8:pm -# -# -#There are four special ranges of characters that are represented only by -#their start and end characters <...> -# -# The CJK Ideographs Area (U+4E00 - U+9FFF) -# The Hangul Syllables Area (U+AC00 - U+D7A3) -# The Surrogates Area (U+D800 - U+DFFF) -# The Private Use Area (U+E000 - U+F8FF) -# -# U+fb00:ff U+fb01:fi U+fb02:fl @@ -2184,12 +2172,12 @@ U+001d:GS U+001e:RS U+001f:US U+007f:DT -# Most of these characters (80-9F) may be inflicted on us +U+0080:PA +U+0081:HO +# Most of these characters (82-9F) may be inflicted on us # by MS FrontPages which uses Unicode notation such as ™ # but there are no assigned letters in Unicode 128-159 range. # It is assumed in the code that those codepoints are from windows-1252. -#U+0080:PA -#U+0081:HO #U+0082:BH #U+0083:NH #U+0084:IN @@ -2201,10 +2189,10 @@ U+007f:DT #U+008a:VS #U+008b:PD #U+008c:PU -#U+008d:RI -#U+008e:SS2 -#U+008f:SS3 -#U+0090:DCS +U+008d:RI +U+008e:SS2 +U+008f:SS3 +U+0090:DCS #U+0091:P1 #U+0092:P2 #U+0093:TS @@ -2214,13 +2202,15 @@ U+007f:DT #U+0097:EG #U+0098:SS #U+0099:GC -#U+009a:SC +U+009a:SC #U+009b:CSI #U+009c:ST #U+009d:OC #U+009e:PM #U+009f:AC +# Characters in Private Use Area (e000-f8ff) do not have ussigned numbers. + # Let's try to show a question mark for character that cannot # be shown. U+fffd is used for invalid characters. # It works, but let's stick with UHHH representatiion. - FM diff --git a/src/chrtrans/iso01_uni.tbl b/src/chrtrans/iso01_uni.tbl index 5b697e02..f792164d 100644 --- a/src/chrtrans/iso01_uni.tbl +++ b/src/chrtrans/iso01_uni.tbl @@ -8,7 +8,7 @@ D0 Miso-8859-1 #Name as a Display Charset (used on Options screen) -OWestern (ISO-8859-1) +OISO Latin 1 # # Name: ISO 8859-1 (1987) to Unicode diff --git a/src/chrtrans/iso02_uni.tbl b/src/chrtrans/iso02_uni.tbl index 7fa0df92..af97bc55 100644 --- a/src/chrtrans/iso02_uni.tbl +++ b/src/chrtrans/iso02_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-2 #Name as a Display Charset (used on Options screen) -OEastern European (ISO-8859-2) +OISO Latin 2 # # Name: ISO 8859-2 (1987) to Unicode diff --git a/src/chrtrans/iso03_uni.tbl b/src/chrtrans/iso03_uni.tbl index a3c1f07a..bb8cd90f 100644 --- a/src/chrtrans/iso03_uni.tbl +++ b/src/chrtrans/iso03_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-3 #Name as a Display Charset (used on Options screen) -OLatin 3 (ISO-8859-3) +OISO Latin 3 # # Name: ISO 8859-3 (1988) to Unicode diff --git a/src/chrtrans/iso04_uni.tbl b/src/chrtrans/iso04_uni.tbl index 29be0be5..3f54afda 100644 --- a/src/chrtrans/iso04_uni.tbl +++ b/src/chrtrans/iso04_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-4 #Name as a Display Charset (used on Options screen) -OLatin 4 (ISO-8859-4) +OISO Latin 4 # # Name: ISO 8859-4 (1988) to Unicode diff --git a/src/chrtrans/iso05_uni.tbl b/src/chrtrans/iso05_uni.tbl index a715b64f..40cdc24d 100644 --- a/src/chrtrans/iso05_uni.tbl +++ b/src/chrtrans/iso05_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-5 #Name as a Display Charset (used on Options screen) -OCyrillic (ISO-8859-5) +OISO 8859-5 Cyrillic # # Name: ISO 8859-5 (1988) to Unicode diff --git a/src/chrtrans/iso06_uni.tbl b/src/chrtrans/iso06_uni.tbl index 549b592d..c9418864 100644 --- a/src/chrtrans/iso06_uni.tbl +++ b/src/chrtrans/iso06_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-6 #Name as a Display Charset (used on Options screen). -OArabic (ISO-8859-6) +OISO 8859-6 Arabic # # Name: ISO 8859-6 (1987) to Unicode diff --git a/src/chrtrans/iso07_uni.tbl b/src/chrtrans/iso07_uni.tbl index dffca758..368209bf 100644 --- a/src/chrtrans/iso07_uni.tbl +++ b/src/chrtrans/iso07_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-7 #Name as a Display Charset (used on Options screen) -OGreek (ISO-8859-7) +OISO 8859-7 Greek # # Name: ISO 8859-7 (1987) to Unicode diff --git a/src/chrtrans/iso08_uni.tbl b/src/chrtrans/iso08_uni.tbl index 050be29d..4d83f5c4 100644 --- a/src/chrtrans/iso08_uni.tbl +++ b/src/chrtrans/iso08_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-8 #Name as a Display Charset (used on Options screen). -OHebrew (ISO-8859-8) +OISO 8859-8 Hebrew # # Name: ISO 8859-8 (1988) to Unicode diff --git a/src/chrtrans/iso09_uni.tbl b/src/chrtrans/iso09_uni.tbl index 5abe799f..1b204835 100644 --- a/src/chrtrans/iso09_uni.tbl +++ b/src/chrtrans/iso09_uni.tbl @@ -2,7 +2,7 @@ Miso-8859-9 #Name as a Display Charset (used on Options screen) -OTurkish (ISO-8859-9) +OISO 8859-9 (Latin 5) # # Name: ISO 8859-9 (1989) to Unicode diff --git a/src/chrtrans/iso10_uni.tbl b/src/chrtrans/iso10_uni.tbl index ab8128f0..be3c02cd 100644 --- a/src/chrtrans/iso10_uni.tbl +++ b/src/chrtrans/iso10_uni.tbl @@ -10,7 +10,7 @@ D0 Miso-8859-10 #Name as a Display Charset (used on Options screen) -OISO-8859-10 +OISO 8859-10 0x20-0x7e idem #0x7f U+2302 diff --git a/src/chrtrans/koi8r_uni.tbl b/src/chrtrans/koi8r_uni.tbl index 69eef3c2..09e8743c 100644 --- a/src/chrtrans/koi8r_uni.tbl +++ b/src/chrtrans/koi8r_uni.tbl @@ -1,5 +1,5 @@ # Options screen name for this character set -OCyrillic (KOI8-R) +OKOI8-R Cyrillic # MIME name for this charset Mkoi8-r diff --git a/src/chrtrans/makefile.dos b/src/chrtrans/makefile.dos index 57c45dfc..6871b87a 100644 --- a/src/chrtrans/makefile.dos +++ b/src/chrtrans/makefile.dos @@ -13,9 +13,7 @@ CFLAGS = $(MCFLAGS) CC = gcc MCFLAGS = -O3 -DDOSPATH -DNO_TTYTYP \ --I. \ --I../../WWW/library/implement \ --I../../djgpp/tcplib/include \ +-I../../WWW/library/implement -I../../djgpp/tcplib/include \ -I../../djgpp/tcplib/include/tcp .SUFFIXES: .tbl @@ -83,7 +81,6 @@ cp1256_uni.h: cp1256_uni.tbl makeuctb.exe cp1257_uni.h: cp1257_uni.tbl makeuctb.exe cp437_uni.h: cp437_uni.tbl makeuctb.exe cp737_uni.h: cp737_uni.tbl makeuctb.exe -cp775_uni.h: cp775_uni.tbl makeuctb.exe cp850_uni.h: cp850_uni.tbl makeuctb.exe cp852_uni.h: cp852_uni.tbl makeuctb.exe cp862_uni.h: cp862_uni.tbl makeuctb.exe diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in index 512b003d..7cb02699 100644 --- a/src/chrtrans/makefile.in +++ b/src/chrtrans/makefile.in @@ -107,7 +107,6 @@ cp1256_uni.h: $(srcdir)/cp1256_uni.tbl makeuctb$x cp1257_uni.h: $(srcdir)/cp1257_uni.tbl makeuctb$x cp437_uni.h: $(srcdir)/cp437_uni.tbl makeuctb$x cp737_uni.h: $(srcdir)/cp737_uni.tbl makeuctb$x -cp775_uni.h: $(srcdir)/cp775_uni.tbl makeuctb$x cp850_uni.h: $(srcdir)/cp850_uni.tbl makeuctb$x cp852_uni.h: $(srcdir)/cp852_uni.tbl makeuctb$x cp862_uni.h: $(srcdir)/cp862_uni.tbl makeuctb$x diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c index cc721723..874d971f 100644 --- a/src/chrtrans/makeuctb.c +++ b/src/chrtrans/makeuctb.c @@ -16,7 +16,13 @@ * version 2, or at your option any later version. */ -#define DONT_USE_SOCKS5 +#ifdef NOTDEFINED +#include <stdio.h> +#include <stdlib.h> +#include <sysexits.h> +#include <string.h> +#include <ctype.h> +#else #include <HTUtils.h> #include <tcp.h> /* @@ -25,6 +31,7 @@ #ifdef exit #undef exit #endif /* exit */ +#endif /* NODEFINED */ #ifndef TOLOWER #define TOLOWER(c) (isupper((unsigned char)c) ? tolower((unsigned char)c) : (c)) @@ -40,16 +47,6 @@ */ typedef u16 unicode; -/* - * Since we're writing the formatted file to stdout, ensure that we flush - * everything before leaving, since some old (and a few not-so-old) platforms - * that do not implement POSIX 'exit()'. - */ -#define done(code) \ - fflush(stdout); \ - fflush(stderr); \ - exit(code) - PRIVATE void usage ARGS1( char *, argv0) { @@ -59,7 +56,7 @@ PRIVATE void usage ARGS1( argv0); fprintf(stderr, "Utility to convert .tbl into .h files for Lynx compilation.\n"); - done(EX_USAGE); + exit(EX_USAGE); } /* copied from HTString.c, not everybody has strncasecmp */ @@ -132,7 +129,7 @@ PRIVATE void addpair_str ARGS2( if (!themap_str.entries) { fprintf(stderr, "%s: Out of memory\n", tblname); - done(EX_DATAERR); + exit(EX_DATAERR); } } else { /* @@ -152,7 +149,7 @@ PRIVATE void addpair_str ARGS2( if (themap_str.entry_ct > 1999) { fprintf(stderr, "ERROR: Only 2000 unicode replacement strings permitted!\n"); - done(EX_DATAERR); + exit(EX_DATAERR); } themap_str.entries[themap_str.entry_ct].unicode = un; themap_str.entries[themap_str.entry_ct].replace_str = str; @@ -198,7 +195,7 @@ PRIVATE void addpair ARGS2( */ if (unicount[fp] > 254) { fprintf(stderr, "ERROR: Only 255 unicodes/glyph permitted!\n"); - done(EX_DATAERR); + exit(EX_DATAERR); } unitable[fp][unicount[fp]] = un; unicount[fp]++; @@ -236,7 +233,7 @@ PUBLIC int main ARGS2( ctbl = fopen(tblname = argv[1], "r"); if (!ctbl) { perror(tblname); - done(EX_NOINPUT); + exit(EX_NOINPUT); } } @@ -386,11 +383,11 @@ PUBLIC int main ARGS2( un0 = getunicode(&p); if (un0 < 0) { fprintf(stderr, "Bad input line: %s\n", buffer); - done(EX_DATAERR); + exit(EX_DATAERR); fprintf(stderr, "%s: Bad Unicode range corresponding to font position range 0x%x-0x%x\n", tblname, fp0, fp1); - done(EX_DATAERR); + exit(EX_DATAERR); } un1 = un0; while (*p == ' ' || *p == '\t') { @@ -407,7 +404,7 @@ PUBLIC int main ARGS2( "%s: Bad Unicode range U+%x-U+%x\n", tblname, un0, un1); fprintf(stderr, "Bad input line: %s\n", buffer); - done(EX_DATAERR); + exit(EX_DATAERR); } while (*p == ' ' || *p == '\t') { p++; @@ -424,7 +421,7 @@ PUBLIC int main ARGS2( if (!(p1 = tbuf)) { fprintf(stderr, "%s: Out of memory\n", tblname); - done(EX_DATAERR); + exit(EX_DATAERR); } if (*p == '"') { /* @@ -484,7 +481,7 @@ PUBLIC int main ARGS2( fp0 = strtol(p, &p1, 0); if (p1 == p) { fprintf(stderr, "Bad input line: %s\n", buffer); - done(EX_DATAERR); + exit(EX_DATAERR); } p = p1; @@ -496,7 +493,7 @@ PUBLIC int main ARGS2( fp1 = strtol(p, &p1, 0); if (p1 == p) { fprintf(stderr, "Bad input line: %s\n", buffer); - done(EX_DATAERR); + exit(EX_DATAERR); } p = p1; } else { @@ -507,13 +504,13 @@ PUBLIC int main ARGS2( fprintf(stderr, "%s: Glyph number (0x%x) larger than font length\n", tblname, fp0); - done(EX_DATAERR); + exit(EX_DATAERR); } if (fp1 && (fp1 < fp0 || fp1 >= fontlen)) { fprintf(stderr, "%s: Bad end of range (0x%x)\n", tblname, fp1); - done(EX_DATAERR); + exit(EX_DATAERR); } if (fp1) { @@ -540,7 +537,7 @@ PUBLIC int main ARGS2( tblname); fprintf(stderr, " there should be a Unicode range.\n"); - done(EX_DATAERR); + exit(EX_DATAERR); } p++; un1 = getunicode(&p); @@ -548,7 +545,7 @@ PUBLIC int main ARGS2( fprintf(stderr, "%s: Bad Unicode range corresponding to font position range 0x%x-0x%x\n", tblname, fp0, fp1); - done(EX_DATAERR); + exit(EX_DATAERR); } if (un1 - un0 != fp1 - fp0) { fprintf(stderr, @@ -557,7 +554,7 @@ PUBLIC int main ARGS2( fprintf(stderr, " as font position range 0x%x-0x%x\n", fp0, fp1); - done(EX_DATAERR); + exit(EX_DATAERR); } for (i = fp0; i <= fp1; i++) { addpair(i,un0-fp0+i); @@ -588,7 +585,7 @@ PUBLIC int main ARGS2( fprintf(stderr, "%s: Bad Unicode range 0x%x-0x%x\n", tblname, un0, un1); - done(EX_DATAERR); + exit(EX_DATAERR); } for (un0++; un0 <= un1; un0++) { addpair(fp0, un0); @@ -634,14 +631,12 @@ PUBLIC int main ARGS2( } else if (this_LYNXcharset[0] == '\0') { strncpy(this_LYNXcharset,this_MIMEcharset,UC_MAXLEN_LYNXCSNAME); } -/***** DO NOT produce trailing spaces! if ((i = strlen(this_LYNXcharset)) < UC_LEN_LYNXCSNAME) { for (; i < UC_LEN_LYNXCSNAME; i++) { this_LYNXcharset[i] = ' '; } this_LYNXcharset[i] = '\0'; } -*******/ #ifdef NOTDEFINED fprintf(stderr,"this_MIMEcharset: %s.\n",this_MIMEcharset); fprintf(stderr,"this_LYNXcharset: %s.\n",this_LYNXcharset); @@ -660,8 +655,8 @@ PUBLIC int main ARGS2( p++, i++) { id_append[i+1] = isalnum(*p) ? *p : '_'; } - id_append[i+1] = '\0'; } + id_append[i+1] = '\0'; fprintf(stderr, " (%s).\n", id_append); printf("\ @@ -765,5 +760,5 @@ dfont_replacedesc%s,%d,%d)\n", id_append, this_MIMEcharset, this_LYNXcharset, id_append, id_append, nuni, id_append, lowest_eight, RawOrEnc); - done(EX_OK); + exit(EX_OK); } diff --git a/src/chrtrans/utf8_uni.tbl b/src/chrtrans/utf8_uni.tbl index 9fc470ad..67ff3460 100644 --- a/src/chrtrans/utf8_uni.tbl +++ b/src/chrtrans/utf8_uni.tbl @@ -7,7 +7,7 @@ Mutf-8 #Name as a Display Charset (used on Options screen) -OUNICODE (UTF-8) +OUNICODE UTF-8 # Some kind of raw Unicode? # Use 6 for for really "raw" 16bit UCS-2, 7 for UTF-8, ... diff --git a/src/descrip.mms b/src/descrip.mms index 014a3a2b..9f84a7b8 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.dos b/src/makefile.dos index 283bcc27..91ace376 100644 --- a/src/makefile.dos +++ b/src/makefile.dos @@ -12,11 +12,7 @@ LYStyle.o LYHash.o CFLAGS= $(MCFLAGS) -I. -I.. $(SLANGINC)
CC = gcc
-MCFLAGS = -O3 -DHAVE_GETBKGD -DDISP_PARTIAL -DUSE_ZLIB \
- -DUSE_EXTERNALS -DCOLOR_CURSES -DNCURSES -DFANCY_CURSES \
- -DACCESS_AUTH -DNO_CUSERID -DNOUSERS -DDOSPATH -DNO_TTYTYPE -DNO_UTMP \
- -Ichrtrans -I../WWW/library/implementation \
- -I../curses -I../djgpp/tcplib/include -I../djgpp/tcplib/include/tcp
+MCFLAGS = -O3 -DRAWDOSKEYHACK -DUSE_ZLIB -DUSE_EXTERNALS -DCOLOR_CURSES -DNCURSES -DFANCY_CURSES -DACCESS_AUTH -DNO_CUSERID -DNOUSERS -DDOSPATH -DNO_TTYTYPE -DNO_UTMP -Ichrtrans -I../WWW/library/implementation -I../curses -I../djgpp/tcplib/include -I../djgpp/tcplib/include/tcp
WWWLIB = ../WWW/library/djgpp/libwww.a ../curses/pdcurses.a ../djgpp/tcplib/obj/libtcp.a
LIBS=-lz
@@ -24,7 +20,7 @@ all: lynx lynx: message $(OBJS) $(WWWLIB)
@echo "Linking and creating Lynx executable"
- $(CC) $(CFLAGS) -o lynx.exe $(OBJS) $(WWWLIB) $(SLANGLIB) $(LIBS)
+ $(CC) $(CFLAGS) -o lynx $(OBJS) $(WWWLIB) $(SLANGLIB) $(LIBS)
@echo "Welcome to Lynx!"
message:
@@ -38,7 +34,7 @@ lint: lint *.c > ../lint.out
clean:
- rm -f lynx.exe core *.[ob]
+ rm -f lynx core *.[ob]
LYMain.o: ../userdefs.h
LYMainLoop.o: LYMainLoop.c ../userdefs.h
diff --git a/src/makefile.dsl b/src/makefile.dsl deleted file mode 100644 index a66349ca..00000000 --- a/src/makefile.dsl +++ /dev/null @@ -1,62 +0,0 @@ -OBJS= UCdomap.o UCAux.o UCAuto.o \
-LYClean.o LYShowInfo.o LYEdit.o LYStrings.o \
-LYMail.o HTAlert.o GridText.o LYGetFile.o \
-LYMain.o LYMainLoop.o LYCurses.o LYBookmark.o LYUtils.o \
-LYOptions.o LYReadCFG.o LYSearch.o LYHistory.o \
-LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \
-HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \
-LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \
-LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \
-LYStyle.o LYHash.o
-
-CFLAGS= $(MCFLAGS) -I. -I.. $(SLANGINC)
-
-CC = gcc
-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
-WWWLIB = ../WWW/library/djgpp/libwww.a ../djgpp/tcplib/obj/libtcp.a
-LIBS= -lslang -lz
-CHRTR= ./chrtrans/
-
-all: lynx.exe
-
-lynx.exe: message $(OBJS) $(WWWLIB)
- @echo "Linking and creating Lynx executable"
- $(CC) $(CFLAGS) -o lynx.exe $(OBJS) $(WWWLIB) $(SLANGLIB) $(LIBS)
- @echo "Welcome to Lynx!"
-
-message:
- @echo "Compiling Lynx sources"
-
-dbg: $(OBJS) $(WWWLIB)
- @echo "Making Lynx code"
- $(CC) $(OBJS) $(CFLAGS) $(WWWLIB) $(SLANGLIB) $(LIBS)
-
-lint:
- lint *.c > ../lint.out
-
-clean:
- rm -f lynx.exe core *.[ob]
-
-LYMain.o: ../userdefs.h
-LYMainLoop.o: LYMainLoop.c ../userdefs.h
-LYReadCFG.o: LYReadCFG.c ../userdefs.h
-HTFWriter.o: HTFWriter.c ../userdefs.h
-LYGetFile.o: LYGetFile.c ../userdefs.h
-LYOptions.o: LYOptions.c ../userdefs.h
-LYReadCFG.o: LYReadCFG.c ../userdefs.h
-LYTraversal.o: LYTraversal.c ../userdefs.h
-LYCharSets.o: LYCharSets.c ../userdefs.h
-LYShowInfo.o: LYShowInfo.c ../userdefs.h
-LYStrings.o: LYStrings.c ../userdefs.h
-LYBookmark.o: LYBookmark.c ../userdefs.h
-LYHistory.o: LYHistory.c ../userdefs.h
-LYDownload.o: LYDownload.c ../userdefs.h
-DefaultStyle.o: DefaultStyle.c ../userdefs.h
-LYEditmap.o: LYEditmap.c ../userdefs.h
-LYCharUtils.o: LYCharUtils.c ../userdefs.h
-LYExtern.o: LYExtern.c ../userdefs.h
-LYUtils.o: LYUtils.c ../userdefs.h
-LYCookie.o: ../userdefs.h
diff --git a/src/makefile.in b/src/makefile.in index e14fa843..18016728 100644 --- a/src/makefile.in +++ b/src/makefile.in @@ -18,13 +18,14 @@ CFLAGS = @CFLAGS@ DEFS = @DEFS@ CPPFLAGS = @CPPFLAGS@ -LIBS = @LIBS@ $(RESOLVLIB) $(WAISLIB) $(SITE_LIBS) +LIBS = @LIBS@ $(RESOLVLIB) $(WAISLIB) $(SOCKSLIB) $(SITE_LIBS) LDFLAGS = @LDFLAGS@ # Symbols inherited from the top-level makefile RESOLVLIB = # FIXME: set in parent makefile SITE_DEFS = # FIXME: set in parent makefile SITE_LIBS = # FIXME: set in parent makefile +SOCKSLIB = # FIXME: set in parent makefile WAISLIB = # FIXME: set in parent makefile WWWINC = WWW/Library/Implementation @@ -44,9 +45,6 @@ CC_OPTS = $(CPP_OPTS) $(CFLAGS) LINT = @LINT@ LINTOPTS = -COMPRESS_PROG =@COMPRESS_PROG@ -COMPRESS_EXT =@COMPRESS_EXT@ - CHARTRANS_OBJS=UCdomap.o UCAux.o UCAuto.o OBJS= LYClean.o LYShowInfo.o LYEdit.o LYStrings.o \ LYMail.o HTAlert.o GridText.o LYGetFile.o \ @@ -72,7 +70,7 @@ all: lynx$x @RULE_CC@ @ECHO_CC@$(CPP) -C $(CPP_OPTS) $*.c >$@ -lynx$x: message do_chartrans_stuff ../LYHelp.h $(OBJS) $(WWWLIB) +lynx$x: message do_chartrans_stuff $(OBJS) $(WWWLIB) @echo "Linking and creating Lynx executable" $(CC) $(CC_OPTS) $(LDFLAGS) -o $@ $(OBJS) $(WWWLIB) $(LIBS) @echo "Copying Lynx executable into top-level directory" @@ -112,7 +110,6 @@ HTInit.o: ../userdefs.h LYTraversal.o: ../userdefs.h LYMail.o: ../userdefs.h LYCharSets.o: ../userdefs.h -LYShowInfo.o: ../cfg_defs.h CHRTR= chrtrans/ diff --git a/src/makefile.wsl b/src/makefile.wsl deleted file mode 100644 index af721f2f..00000000 --- a/src/makefile.wsl +++ /dev/null @@ -1,62 +0,0 @@ -OBJS= UCdomap.o UCAux.o UCAuto.o \
-LYClean.o LYShowInfo.o LYEdit.o LYStrings.o \
-LYMail.o HTAlert.o GridText.o LYGetFile.o \
-LYMain.o LYMainLoop.o LYCurses.o LYBookmark.o LYUtils.o \
-LYOptions.o LYReadCFG.o LYSearch.o LYHistory.o \
-LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \
-HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \
-LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \
-LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \
-LYStyle.o LYHash.o
-
-CFLAGS= $(MCFLAGS) -I. -I.. $(SLANGINC)
-
-CC = gcc
-MCFLAGS = -O3 -DDISP_PARTIAL -DUSE_ZLIB -DUSE_EXTERNALS \
--DUSE_SLANG -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
-WWWLIB = ../WWW/library/djgpp/libwww.a ../djgpp/tcplib/obj/libtcp.a
-LIBS= -lslang -lz
-CHRTR= ./chrtrans/
-
-all: lynx.exe
-
-lynx.exe: message $(OBJS) $(WWWLIB)
- @echo "Linking and creating Lynx executable"
- $(CC) $(CFLAGS) -o lynx.exe $(OBJS) $(WWWLIB) $(SLANGLIB) $(LIBS)
- @echo "Welcome to Lynx!"
-
-message:
- @echo "Compiling Lynx sources"
-
-dbg: $(OBJS) $(WWWLIB)
- @echo "Making Lynx code"
- $(CC) $(OBJS) $(CFLAGS) $(WWWLIB) $(SLANGLIB) $(LIBS)
-
-lint:
- lint *.c > ../lint.out
-
-clean:
- rm -f lynx.exe core *.[ob]
-
-LYMain.o: ../userdefs.h
-LYMainLoop.o: LYMainLoop.c ../userdefs.h
-LYReadCFG.o: LYReadCFG.c ../userdefs.h
-HTFWriter.o: HTFWriter.c ../userdefs.h
-LYGetFile.o: LYGetFile.c ../userdefs.h
-LYOptions.o: LYOptions.c ../userdefs.h
-LYReadCFG.o: LYReadCFG.c ../userdefs.h
-LYTraversal.o: LYTraversal.c ../userdefs.h
-LYCharSets.o: LYCharSets.c ../userdefs.h
-LYShowInfo.o: LYShowInfo.c ../userdefs.h
-LYStrings.o: LYStrings.c ../userdefs.h
-LYBookmark.o: LYBookmark.c ../userdefs.h
-LYHistory.o: LYHistory.c ../userdefs.h
-LYDownload.o: LYDownload.c ../userdefs.h
-DefaultStyle.o: DefaultStyle.c ../userdefs.h
-LYEditmap.o: LYEditmap.c ../userdefs.h
-LYCharUtils.o: LYCharUtils.c ../userdefs.h
-LYExtern.o: LYExtern.c ../userdefs.h
-LYUtils.o: LYUtils.c ../userdefs.h
-LYCookie.o: ../userdefs.h
|