fm.h (31364B)
1 /* $Id$ */ 2 /* 3 * w3m: WWW wo Miru utility 4 * 5 * by A.ITO Feb. 1995 6 * 7 * You can use,copy,modify and distribute this program without any permission. 8 */ 9 10 #ifndef FM_H 11 #define FM_H 12 13 14 #ifndef _GNU_SOURCE 15 #define _GNU_SOURCE /* strcasestr() */ 16 #endif 17 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <string.h> 21 #include <unistd.h> 22 #include <sys/types.h> 23 #include <sys/stat.h> 24 #include <unistd.h> 25 #include "config.h" 26 #include "history.h" 27 28 #ifdef USE_MENU 29 #define MENU_SELECT 30 #define MENU_MAP 31 #endif /* USE_MENU */ 32 33 #ifndef USE_COLOR 34 #undef USE_ANSI_COLOR 35 #undef USE_BG_COLOR 36 #endif 37 38 #include "ctrlcode.h" 39 #include "html.h" 40 #include <gc.h> 41 #include "Str.h" 42 #ifdef USE_M17N 43 #include "wc.h" 44 #include "wtf.h" 45 #else 46 typedef int wc_ces; /* XXX: not used */ 47 #endif 48 49 #ifdef HAVE_LOCALE_H 50 #include <locale.h> 51 #endif 52 #if !HAVE_SETLOCALE 53 #define setlocale(category, locale) /* empty */ 54 #endif 55 56 #ifdef ENABLE_NLS 57 #include <libintl.h> 58 #define _(String) gettext (String) 59 #define N_(String) (String) 60 #else 61 # undef bindtextdomain 62 # define bindtextdomain(Domain, Directory) /* empty */ 63 # undef textdomain 64 # define textdomain(Domain) /* empty */ 65 # define _(Text) Text 66 # define N_(Text) Text 67 # define gettext(Text) Text 68 #endif 69 70 #include "form.h" 71 #include "frame.h" 72 #include "parsetag.h" 73 #include "parsetagx.h" 74 #include "func.h" 75 #include "menu.h" 76 #include "textlist.h" 77 #include "funcname1.h" 78 #include "terms.h" 79 80 #ifndef HAVE_BCOPY 81 void bcopy(const void *, void *, int); 82 void bzero(void *, int); 83 #endif /* HAVE_BCOPY */ 84 #ifdef __EMX__ 85 #include <strings.h> /* for bzero() and bcopy() */ 86 #endif 87 88 #ifdef MAINPROGRAM 89 #define global 90 #define init(x) =(x) 91 #else /* not MAINPROGRAM */ 92 #define global extern 93 #define init(x) 94 #endif /* not MAINPROGRAM */ 95 96 #define DEFUN(funcname, macroname, docstring) void funcname(void) 97 98 /* 99 * Constants. 100 */ 101 #define LINELEN 256 /* Initial line length */ 102 #define PAGER_MAX_LINE 10000 /* Maximum line kept as pager */ 103 104 #define MAXIMUM_COLS 1024 105 #define DEFAULT_COLS 80 106 107 #ifdef USE_IMAGE 108 #define MAX_IMAGE 1000 109 #define MAX_IMAGE_SIZE 2048 110 111 #define DEFAULT_PIXEL_PER_CHAR 7.0 /* arbitrary */ 112 #define DEFAULT_PIXEL_PER_LINE 14.0 /* arbitrary */ 113 #else 114 #define DEFAULT_PIXEL_PER_CHAR 8.0 /* arbitrary */ 115 #endif 116 #define MINIMUM_PIXEL_PER_CHAR 4.0 117 #define MAXIMUM_PIXEL_PER_CHAR 32.0 118 119 #ifdef FALSE 120 #undef FALSE 121 #endif 122 123 #ifdef TRUE 124 #undef TRUE 125 #endif 126 127 #define FALSE 0 128 #define TRUE 1 129 130 #define SHELLBUFFERNAME "*Shellout*" 131 #define PIPEBUFFERNAME "*stream*" 132 #define CPIPEBUFFERNAME "*stream(closed)*" 133 #ifdef USE_DICT 134 #define DICTBUFFERNAME "*dictionary*" 135 #endif /* USE_DICT */ 136 137 /* 138 * Line Property 139 */ 140 141 #define P_CHARTYPE 0x3f00 142 #ifdef USE_M17N 143 #define PC_ASCII (WTF_TYPE_ASCII << 8) 144 #define PC_CTRL (WTF_TYPE_CTRL << 8) 145 #define PC_WCHAR1 (WTF_TYPE_WCHAR1 << 8) 146 #define PC_WCHAR2 (WTF_TYPE_WCHAR2 << 8) 147 #define PC_KANJI (WTF_TYPE_WIDE << 8) 148 #define PC_KANJI1 (PC_WCHAR1 | PC_KANJI) 149 #define PC_KANJI2 (PC_WCHAR2 | PC_KANJI) 150 #define PC_UNKNOWN (WTF_TYPE_UNKNOWN << 8) 151 #define PC_UNDEF (WTF_TYPE_UNDEF << 8) 152 #else 153 #define PC_ASCII 0x0000 154 #define PC_CTRL 0x0100 155 #endif 156 #define PC_SYMBOL 0x8000 157 158 /* Effect ( standout/underline ) */ 159 #define P_EFFECT 0x40ff 160 #define PE_NORMAL 0x00 161 #define PE_MARK 0x01 162 #define PE_UNDER 0x02 163 #define PE_STAND 0x04 164 #define PE_BOLD 0x08 165 #define PE_ANCHOR 0x10 166 #define PE_EMPH 0x08 167 #define PE_IMAGE 0x20 168 #define PE_FORM 0x40 169 #define PE_ACTIVE 0x80 170 #define PE_VISITED 0x4000 171 172 /* Extra effect */ 173 #define PE_EX_ITALIC 0x01 174 #define PE_EX_INSERT 0x02 175 #define PE_EX_STRIKE 0x04 176 177 #define PE_EX_ITALIC_E PE_UNDER 178 #define PE_EX_INSERT_E PE_UNDER 179 #define PE_EX_STRIKE_E PE_STAND 180 181 #define CharType(c) ((c)&P_CHARTYPE) 182 #define CharEffect(c) ((c)&(P_EFFECT|PC_SYMBOL)) 183 #define SetCharType(v,c) ((v)=(((v)&~P_CHARTYPE)|(c))) 184 185 186 #define COLPOS(l,c) calcPosition(l->lineBuf,l->propBuf,l->len,c,0,CP_AUTO) 187 188 /* Flags for displayBuffer() */ 189 #define B_NORMAL 0 190 #define B_FORCE_REDRAW 1 191 #define B_REDRAW 2 192 #define B_SCROLL 3 193 #define B_REDRAW_IMAGE 4 194 195 /* Buffer Property */ 196 #define BP_NORMAL 0x0 197 #define BP_PIPE 0x1 198 #define BP_FRAME 0x2 199 #define BP_INTERNAL 0x8 200 #define BP_NO_URL 0x10 201 #define BP_REDIRECTED 0x20 202 #define BP_CLOSE 0x40 203 204 /* Link Buffer */ 205 #define LB_NOLINK -1 206 #define LB_FRAME 0 /* rFrame() */ 207 #define LB_N_FRAME 1 208 #define LB_INFO 2 /* pginfo() */ 209 #define LB_N_INFO 3 210 #define LB_SOURCE 4 /* vwSrc() */ 211 #define LB_N_SOURCE LB_SOURCE 212 #define MAX_LB 5 213 214 /* Search Result */ 215 #define SR_FOUND 0x1 216 #define SR_NOTFOUND 0x2 217 #define SR_WRAPPED 0x4 218 219 #ifdef MAINPROGRAM 220 int REV_LB[MAX_LB] = { 221 LB_N_FRAME, LB_FRAME, LB_N_INFO, LB_INFO, LB_N_SOURCE, 222 }; 223 #else /* not MAINPROGRAM */ 224 extern int REV_LB[]; 225 #endif /* not MAINPROGRAM */ 226 227 /* mark URL, Message-ID */ 228 #define CHK_URL 1 229 #define CHK_NMID 2 230 231 /* Flags for calcPosition() */ 232 #define CP_AUTO 0 233 #define CP_FORCE 1 234 235 /* Completion status. */ 236 #define CPL_OK 0 237 #define CPL_AMBIG 1 238 #define CPL_FAIL 2 239 #define CPL_MENU 3 240 241 #define CPL_NEVER 0x0 242 #define CPL_OFF 0x1 243 #define CPL_ON 0x2 244 #define CPL_ALWAYS 0x4 245 #define CPL_URL 0x8 246 247 /* Flags for inputLine() */ 248 #define IN_STRING 0x10 249 #define IN_FILENAME 0x20 250 #define IN_PASSWORD 0x40 251 #define IN_COMMAND 0x80 252 #define IN_URL 0x100 253 #define IN_CHAR 0x200 254 255 #define IMG_FLAG_SKIP 1 256 #define IMG_FLAG_AUTO 2 257 258 #define IMG_FLAG_START 0 259 #define IMG_FLAG_STOP 1 260 #define IMG_FLAG_NEXT 2 261 262 #define IMG_FLAG_UNLOADED 0 263 #define IMG_FLAG_LOADED 1 264 #define IMG_FLAG_ERROR 2 265 #define IMG_FLAG_DONT_REMOVE 4 266 267 /* 268 * Macros. 269 */ 270 271 #define inputLineHist(p,d,f,h) inputLineHistSearch(p,d,f,h,NULL) 272 #define inputLine(p,d,f) inputLineHist(p,d,f,NULL) 273 #define inputStr(p,d) inputLine(p,d,IN_STRING) 274 #define inputStrHist(p,d,h) inputLineHist(p,d,IN_STRING,h) 275 #define inputFilename(p,d) inputLine(p,d,IN_FILENAME) 276 #define inputFilenameHist(p,d,h) inputLineHist(p,d,IN_FILENAME,h) 277 #define inputChar(p) inputLine(p,"",IN_CHAR) 278 279 #define free(x) GC_free(x) /* let GC do it. */ 280 281 #ifdef __EMX__ 282 #define HAVE_STRCASECMP 283 #define strcasecmp stricmp 284 #define strncasecmp strnicmp 285 #endif /* __EMX__ */ 286 287 288 #define SKIP_BLANKS(p) {while(*(p)&&IS_SPACE(*(p)))(p)++;} 289 #define SKIP_NON_BLANKS(p) {while(*(p)&&!IS_SPACE(*(p)))(p)++;} 290 #define IS_ENDL(c) ((c)=='\0'||(c)=='\r'||(c)=='\n') 291 #define IS_ENDT(c) (IS_ENDL(c)||(c)==';') 292 293 #define bpcmp(a,b) \ 294 (((a).line - (b).line) ? ((a).line - (b).line) : ((a).pos - (b).pos)) 295 296 #define RELATIVE_WIDTH(w) (((w)>=0)?(int)((w)/pixel_per_char):(w)) 297 #define REAL_WIDTH(w,limit) (((w)>=0)?(int)((w)/pixel_per_char):-(w)*(limit)/100) 298 299 #define EOL(l) (&(l)->ptr[(l)->length]) 300 #define IS_EOL(p,l) ((p)==&(l)->ptr[(l)->length]) 301 302 /* 303 * Types. 304 */ 305 306 typedef unsigned short Lineprop; 307 #ifdef USE_ANSI_COLOR 308 typedef unsigned char Linecolor; 309 #endif 310 311 typedef struct _MapArea { 312 char *url; 313 char *target; 314 char *alt; 315 #ifdef USE_IMAGE 316 char shape; 317 short *coords; 318 int ncoords; 319 short center_x; 320 short center_y; 321 #endif 322 } MapArea; 323 324 typedef struct _MapList { 325 Str name; 326 GeneralList *area; 327 struct _MapList *next; 328 } MapList; 329 330 typedef struct _Line { 331 char *lineBuf; 332 Lineprop *propBuf; 333 #ifdef USE_ANSI_COLOR 334 Linecolor *colorBuf; 335 #endif 336 struct _Line *next; 337 struct _Line *prev; 338 int len; 339 int width; 340 long linenumber; /* on buffer */ 341 long real_linenumber; /* on file */ 342 unsigned short usrflags; 343 int size; 344 int bpos; 345 int bwidth; 346 } Line; 347 348 typedef struct { 349 int line; 350 int pos; 351 int invalid; 352 } BufferPoint; 353 354 #ifdef USE_IMAGE 355 typedef struct _imageCache { 356 char *url; 357 ParsedURL *current; 358 char *file; 359 char *touch; 360 pid_t pid; 361 char loaded; 362 int index; 363 short width; 364 short height; 365 } ImageCache; 366 367 typedef struct _image { 368 char *url; 369 char *ext; 370 short width; 371 short height; 372 short xoffset; 373 short yoffset; 374 short y; 375 short rows; 376 char *map; 377 char ismap; 378 int touch; 379 ImageCache *cache; 380 } Image; 381 #endif 382 383 typedef struct _anchor { 384 char *url; 385 char *target; 386 char *referer; 387 char *title; 388 unsigned char accesskey; 389 BufferPoint start; 390 BufferPoint end; 391 int hseq; 392 char slave; 393 short y; 394 short rows; 395 #ifdef USE_IMAGE 396 Image *image; 397 #endif 398 } Anchor; 399 400 #define NO_REFERER ((char*)-1) 401 402 typedef struct _anchorList { 403 Anchor *anchors; 404 int nanchor; 405 int anchormax; 406 int acache; 407 } AnchorList; 408 409 typedef struct { 410 BufferPoint *marks; 411 int nmark; 412 int markmax; 413 int prevhseq; 414 } HmarkerList; 415 416 #define LINK_TYPE_NONE 0 417 #define LINK_TYPE_REL 1 418 #define LINK_TYPE_REV 2 419 typedef struct _LinkList { 420 char *url; 421 char *title; /* Next, Contents, ... */ 422 char *ctype; /* Content-Type */ 423 char type; /* Rel, Rev */ 424 struct _LinkList *next; 425 } LinkList; 426 427 typedef struct _Buffer { 428 char *filename; 429 char *buffername; 430 Line *firstLine; 431 Line *topLine; 432 Line *currentLine; 433 Line *lastLine; 434 struct _Buffer *nextBuffer; 435 struct _Buffer *linkBuffer[MAX_LB]; 436 short width; 437 short height; 438 char *type; 439 char *real_type; 440 int allLine; 441 short bufferprop; 442 int currentColumn; 443 short cursorX; 444 short cursorY; 445 int pos; 446 int visualpos; 447 short rootX; 448 short rootY; 449 short COLS; 450 short LINES; 451 InputStream pagerSource; 452 AnchorList *href; 453 AnchorList *name; 454 AnchorList *img; 455 AnchorList *formitem; 456 LinkList *linklist; 457 FormList *formlist; 458 MapList *maplist; 459 HmarkerList *hmarklist; 460 HmarkerList *imarklist; 461 ParsedURL currentURL; 462 ParsedURL *baseURL; 463 char *baseTarget; 464 int real_scheme; 465 char *sourcefile; 466 struct frameset *frameset; 467 struct frameset_queue *frameQ; 468 int *clone; 469 size_t trbyte; 470 char check_url; 471 #ifdef USE_M17N 472 wc_ces document_charset; 473 wc_uint8 auto_detect; 474 #endif 475 TextList *document_header; 476 FormItemList *form_submit; 477 char *savecache; 478 char *edit; 479 struct mailcap *mailcap; 480 char *mailcap_source; 481 char *header_source; 482 char search_header; 483 #ifdef USE_SSL 484 char *ssl_certificate; 485 #endif 486 char image_flag; 487 char image_loaded; 488 char need_reshape; 489 Anchor *submit; 490 struct _BufferPos *undo; 491 #ifdef USE_ALARM 492 struct _AlarmEvent *event; 493 #endif 494 } Buffer; 495 496 typedef struct _BufferPos { 497 long top_linenumber; 498 long cur_linenumber; 499 int currentColumn; 500 int pos; 501 int bpos; 502 struct _BufferPos *next; 503 struct _BufferPos *prev; 504 } BufferPos; 505 506 typedef struct _TabBuffer { 507 struct _TabBuffer *nextTab; 508 struct _TabBuffer *prevTab; 509 Buffer *currentBuffer; 510 Buffer *firstBuffer; 511 short x1; 512 short x2; 513 short y; 514 } TabBuffer; 515 516 typedef struct _DownloadList { 517 pid_t pid; 518 char *url; 519 char *save; 520 char *lock; 521 clen_t size; 522 time_t time; 523 int running; 524 int err; 525 struct _DownloadList *next; 526 struct _DownloadList *prev; 527 } DownloadList; 528 #define DOWNLOAD_LIST_TITLE "Download List Panel" 529 530 #define COPY_BUFROOT(dstbuf, srcbuf) {\ 531 (dstbuf)->rootX = (srcbuf)->rootX; \ 532 (dstbuf)->rootY = (srcbuf)->rootY; \ 533 (dstbuf)->COLS = (srcbuf)->COLS; \ 534 (dstbuf)->LINES = (srcbuf)->LINES; \ 535 } 536 537 #define COPY_BUFPOSITION(dstbuf, srcbuf) {\ 538 (dstbuf)->topLine = (srcbuf)->topLine; \ 539 (dstbuf)->currentLine = (srcbuf)->currentLine; \ 540 (dstbuf)->pos = (srcbuf)->pos; \ 541 (dstbuf)->cursorX = (srcbuf)->cursorX; \ 542 (dstbuf)->cursorY = (srcbuf)->cursorY; \ 543 (dstbuf)->visualpos = (srcbuf)->visualpos; \ 544 (dstbuf)->currentColumn = (srcbuf)->currentColumn; \ 545 } 546 #define SAVE_BUFPOSITION(sbufp) COPY_BUFPOSITION(sbufp, Currentbuf) 547 #define RESTORE_BUFPOSITION(sbufp) COPY_BUFPOSITION(Currentbuf, sbufp) 548 #define TOP_LINENUMBER(buf) ((buf)->topLine ? (buf)->topLine->linenumber : 1) 549 #define CUR_LINENUMBER(buf) ((buf)->currentLine ? (buf)->currentLine->linenumber : 1) 550 551 #define NO_BUFFER ((Buffer*)1) 552 553 #define RB_STACK_SIZE 10 554 555 #define TAG_STACK_SIZE 10 556 557 #define FONT_STACK_SIZE 5 558 559 #define FONTSTAT_SIZE 7 560 561 #define _INIT_BUFFER_WIDTH (COLS - (showLineNum ? 6 : 1)) 562 #define INIT_BUFFER_WIDTH ((_INIT_BUFFER_WIDTH > 0) ? _INIT_BUFFER_WIDTH : 0) 563 #define FOLD_BUFFER_WIDTH (FoldLine ? (INIT_BUFFER_WIDTH + 1) : -1) 564 565 typedef struct { 566 int pos; 567 int len; 568 int tlen; 569 long flag; 570 Anchor anchor; 571 Str img_alt; 572 char fontstat[FONTSTAT_SIZE]; 573 short nobr_level; 574 Lineprop prev_ctype; 575 char init_flag; 576 short top_margin; 577 short bottom_margin; 578 } Breakpoint; 579 580 struct readbuffer { 581 Str line; 582 Lineprop cprop; 583 short pos; 584 Str prevchar; 585 long flag; 586 long flag_stack[RB_STACK_SIZE]; 587 int flag_sp; 588 int status; 589 unsigned char end_tag; 590 short table_level; 591 short nobr_level; 592 Anchor anchor; 593 Str img_alt; 594 char fontstat[FONTSTAT_SIZE]; 595 char fontstat_stack[FONT_STACK_SIZE][FONTSTAT_SIZE]; 596 int fontstat_sp; 597 Lineprop prev_ctype; 598 Breakpoint bp; 599 struct cmdtable *tag_stack[TAG_STACK_SIZE]; 600 int tag_sp; 601 short top_margin; 602 short bottom_margin; 603 }; 604 605 #define in_bold fontstat[0] 606 #define in_under fontstat[1] 607 #define in_italic fontstat[2] 608 #define in_strike fontstat[3] 609 #define in_ins fontstat[4] 610 #define in_stand fontstat[5] 611 612 #define RB_PRE 0x01 613 #define RB_SCRIPT 0x02 614 #define RB_STYLE 0x04 615 #define RB_PLAIN 0x08 616 #define RB_LEFT 0x10 617 #define RB_CENTER 0x20 618 #define RB_RIGHT 0x40 619 #define RB_ALIGN (RB_LEFT| RB_CENTER | RB_RIGHT) 620 #define RB_NOBR 0x80 621 #define RB_P 0x100 622 #define RB_PRE_INT 0x200 623 #define RB_IN_DT 0x400 624 #define RB_INTXTA 0x800 625 #define RB_INSELECT 0x1000 626 #define RB_IGNORE_P 0x2000 627 #define RB_TITLE 0x4000 628 #define RB_NFLUSHED 0x8000 629 #define RB_NOFRAMES 0x10000 630 #define RB_INTABLE 0x20000 631 #define RB_PREMODE (RB_PRE | RB_PRE_INT | RB_SCRIPT | RB_STYLE | RB_PLAIN | RB_INTXTA) 632 #define RB_SPECIAL (RB_PRE | RB_PRE_INT | RB_SCRIPT | RB_STYLE | RB_PLAIN | RB_NOBR) 633 #define RB_PLAIN_PRE 0x40000 634 635 #ifdef FORMAT_NICE 636 #define RB_FILL 0x80000 637 #endif /* FORMAT_NICE */ 638 #define RB_DEL 0x100000 639 #define RB_S 0x200000 640 641 #define RB_GET_ALIGN(obuf) ((obuf)->flag&RB_ALIGN) 642 #define RB_SET_ALIGN(obuf,align) {(obuf)->flag &= ~RB_ALIGN; (obuf)->flag |= (align); } 643 #define RB_SAVE_FLAG(obuf) {\ 644 if ((obuf)->flag_sp < RB_STACK_SIZE) \ 645 (obuf)->flag_stack[(obuf)->flag_sp++] = RB_GET_ALIGN(obuf); \ 646 } 647 #define RB_RESTORE_FLAG(obuf) {\ 648 if ((obuf)->flag_sp > 0) \ 649 RB_SET_ALIGN(obuf,(obuf)->flag_stack[--(obuf)->flag_sp]); \ 650 } 651 652 /* status flags */ 653 #define R_ST_NORMAL 0 /* normal */ 654 #define R_ST_TAG0 1 /* within tag, just after < */ 655 #define R_ST_TAG 2 /* within tag */ 656 #define R_ST_QUOTE 3 /* within single quote */ 657 #define R_ST_DQUOTE 4 /* within double quote */ 658 #define R_ST_EQL 5 /* = */ 659 #define R_ST_AMP 6 /* within ampersand quote */ 660 #define R_ST_EOL 7 /* end of file */ 661 #define R_ST_CMNT1 8 /* <! */ 662 #define R_ST_CMNT2 9 /* <!- */ 663 #define R_ST_CMNT 10 /* within comment */ 664 #define R_ST_NCMNT1 11 /* comment - */ 665 #define R_ST_NCMNT2 12 /* comment -- */ 666 #define R_ST_NCMNT3 13 /* comment -- space */ 667 #define R_ST_IRRTAG 14 /* within irregular tag */ 668 #define R_ST_VALUE 15 /* within tag attribule value */ 669 670 #define ST_IS_REAL_TAG(s) ((s)==R_ST_TAG||(s)==R_ST_TAG0||(s)==R_ST_EQL||(s)==R_ST_VALUE) 671 672 /* is this '<' really means the beginning of a tag? */ 673 #define REALLY_THE_BEGINNING_OF_A_TAG(p) \ 674 (IS_ALPHA(p[1]) || p[1] == '/' || p[1] == '!' || p[1] == '?' || p[1] == '\0' || p[1] == '_') 675 676 /* flags for loadGeneralFile */ 677 #define RG_NOCACHE 1 678 #define RG_FRAME 2 679 #define RG_FRAME_SRC 4 680 681 struct html_feed_environ { 682 struct readbuffer *obuf; 683 TextLineList *buf; 684 FILE *f; 685 Str tagbuf; 686 int limit; 687 int maxlimit; 688 struct environment *envs; 689 int nenv; 690 int envc; 691 int envc_real; 692 char *title; 693 int blank_lines; 694 }; 695 696 #ifdef USE_COOKIE 697 struct portlist { 698 unsigned short port; 699 struct portlist *next; 700 }; 701 702 struct cookie { 703 ParsedURL url; 704 Str name; 705 Str value; 706 time_t expires; 707 Str path; 708 Str domain; 709 Str comment; 710 Str commentURL; 711 struct portlist *portl; 712 char version; 713 char flag; 714 struct cookie *next; 715 }; 716 #define COO_USE 1 717 #define COO_SECURE 2 718 #define COO_DOMAIN 4 719 #define COO_PATH 8 720 #define COO_DISCARD 16 721 #define COO_OVERRIDE 32 /* user chose to override security checks */ 722 723 #define COO_OVERRIDE_OK 32 /* flag to specify that an error is overridable */ 724 /* version 0 refers to the original cookie_spec.html */ 725 /* version 1 refers to RFC 2109 */ 726 /* version 1' refers to the Internet draft to obsolete RFC 2109 */ 727 #define COO_EINTERNAL (1) /* unknown error; probably forgot to convert "return 1" in cookie.c */ 728 #define COO_ETAIL (2 | COO_OVERRIDE_OK) /* tail match failed (version 0) */ 729 #define COO_ESPECIAL (3) /* special domain check failed (version 0) */ 730 #define COO_EPATH (4) /* Path attribute mismatch (version 1 case 1) */ 731 #define COO_ENODOT (5 | COO_OVERRIDE_OK) /* no embedded dots in Domain (version 1 case 2.1) */ 732 #define COO_ENOTV1DOM (6 | COO_OVERRIDE_OK) /* Domain does not start with a dot (version 1 case 2.2) */ 733 #define COO_EDOM (7 | COO_OVERRIDE_OK) /* domain-match failed (version 1 case 3) */ 734 #define COO_EBADHOST (8 | COO_OVERRIDE_OK) /* dot in matched host name in FQDN (version 1 case 4) */ 735 #define COO_EPORT (9) /* Port match failed (version 1' case 5) */ 736 #define COO_EMAX COO_EPORT 737 #endif /* USE_COOKIE */ 738 739 /* modes for align() */ 740 741 #define ALIGN_CENTER 0 742 #define ALIGN_LEFT 1 743 #define ALIGN_RIGHT 2 744 #define ALIGN_MIDDLE 4 745 #define ALIGN_TOP 5 746 #define ALIGN_BOTTOM 6 747 748 #define VALIGN_MIDDLE 0 749 #define VALIGN_TOP 1 750 #define VALIGN_BOTTOM 2 751 752 typedef struct http_request { 753 char command; 754 char flag; 755 char *referer; 756 FormList *request; 757 } HRequest; 758 759 #define HR_COMMAND_GET 0 760 #define HR_COMMAND_POST 1 761 #define HR_COMMAND_CONNECT 2 762 #define HR_COMMAND_HEAD 3 763 764 #define HR_FLAG_LOCAL 1 765 #define HR_FLAG_PROXY 2 766 767 #define HTST_UNKNOWN 255 768 #define HTST_MISSING 254 769 #define HTST_NORMAL 0 770 #define HTST_CONNECT 1 771 772 #define TMPF_DFL 0 773 #define TMPF_SRC 1 774 #define TMPF_FRAME 2 775 #define TMPF_CACHE 3 776 #define TMPF_COOKIE 4 777 #define MAX_TMPF_TYPE 5 778 779 #define set_no_proxy(domains) (NO_proxy_domains=make_domain_list(domains)) 780 781 /* 782 * Globals. 783 */ 784 785 extern int LINES, COLS; 786 #if defined(__CYGWIN__) 787 extern int LASTLINE; 788 #else /* not defined(__CYGWIN__) */ 789 #define LASTLINE (LINES-1) 790 #endif /* not defined(__CYGWIN__) */ 791 792 global int Tabstop init(8); 793 global int IndentIncr init(4); 794 global int ShowEffect init(TRUE); 795 global int PagerMax init(PAGER_MAX_LINE); 796 797 global char SearchHeader init(FALSE); 798 global char *DefaultType init(NULL); 799 global char RenderFrame init(FALSE); 800 global char TargetSelf init(FALSE); 801 global char PermitSaveToPipe init(FALSE); 802 global char DecodeCTE init(FALSE); 803 global char AutoUncompress init(FALSE); 804 global char PreserveTimestamp init(TRUE); 805 global char ArgvIsURL init(FALSE); 806 global char MetaRefresh init(FALSE); 807 808 global char fmInitialized init(FALSE); 809 global char QuietMessage init(FALSE); 810 global char TrapSignal init(TRUE); 811 #define TRAP_ON if (TrapSignal) { \ 812 prevtrap = mySignal(SIGINT, KeyAbort); \ 813 if (fmInitialized) \ 814 term_cbreak(); \ 815 } 816 #define TRAP_OFF if (TrapSignal) { \ 817 if (fmInitialized) \ 818 term_raw(); \ 819 if (prevtrap) \ 820 mySignal(SIGINT, prevtrap); \ 821 } 822 823 extern unsigned char GlobalKeymap[]; 824 extern unsigned char EscKeymap[]; 825 extern unsigned char EscBKeymap[]; 826 extern unsigned char EscDKeymap[]; 827 #ifdef __EMX__ 828 extern unsigned char PcKeymap[]; 829 #endif 830 extern FuncList w3mFuncList[]; 831 832 global char *HTTP_proxy init(NULL); 833 #ifdef USE_SSL 834 global char *HTTPS_proxy init(NULL); 835 #endif /* USE_SSL */ 836 #ifdef USE_GOPHER 837 global char *GOPHER_proxy init(NULL); 838 #endif /* USE_GOPHER */ 839 global char *FTP_proxy init(NULL); 840 global ParsedURL HTTP_proxy_parsed; 841 #ifdef USE_SSL 842 global ParsedURL HTTPS_proxy_parsed; 843 #endif /* USE_SSL */ 844 #ifdef USE_GOPHER 845 global ParsedURL GOPHER_proxy_parsed; 846 #endif /* USE_GOPHER */ 847 global ParsedURL FTP_proxy_parsed; 848 global char *NO_proxy init(NULL); 849 global int NOproxy_netaddr init(TRUE); 850 #ifdef INET6 851 #define DNS_ORDER_UNSPEC 0 852 #define DNS_ORDER_INET_INET6 1 853 #define DNS_ORDER_INET6_INET 2 854 #define DNS_ORDER_INET_ONLY 4 855 #define DNS_ORDER_INET6_ONLY 6 856 global int DNS_order init(DNS_ORDER_UNSPEC); 857 extern int ai_family_order_table[7][3]; /* XXX */ 858 #endif /* INET6 */ 859 global TextList *NO_proxy_domains; 860 global char NoCache init(FALSE); 861 global char use_proxy init(TRUE); 862 #define Do_not_use_proxy (!use_proxy) 863 global int Do_not_use_ti_te init(FALSE); 864 #ifdef USE_NNTP 865 global char *NNTP_server init(NULL); 866 global char *NNTP_mode init(NULL); 867 global int MaxNewsMessage init(50); 868 #endif 869 870 global char *document_root init(NULL); 871 global char *personal_document_root init(NULL); 872 global char *cgi_bin init(NULL); 873 global char *index_file init(NULL); 874 875 global char *CurrentDir; 876 global int CurrentPid; 877 /* 878 * global Buffer *Currentbuf; 879 * global Buffer *Firstbuf; 880 */ 881 global TabBuffer *CurrentTab; 882 global TabBuffer *FirstTab; 883 global TabBuffer *LastTab; 884 global int open_tab_blank init(FALSE); 885 global int open_tab_dl_list init(FALSE); 886 global int close_tab_back init(FALSE); 887 global int nTab; 888 global int TabCols init(10); 889 #define NO_TABBUFFER ((TabBuffer *)1) 890 #define Currentbuf (CurrentTab->currentBuffer) 891 #define Firstbuf (CurrentTab->firstBuffer) 892 global DownloadList *FirstDL init(NULL); 893 global DownloadList *LastDL init(NULL); 894 global int CurrentKey; 895 global char *CurrentKeyData; 896 global char *CurrentCmdData; 897 global char *w3m_reqlog; 898 extern char *w3m_version; 899 900 #define DUMP_BUFFER 0x01 901 #define DUMP_HEAD 0x02 902 #define DUMP_SOURCE 0x04 903 #define DUMP_EXTRA 0x08 904 #define DUMP_HALFDUMP 0x10 905 #define DUMP_FRAME 0x20 906 global int w3m_debug; 907 global int w3m_dump init(0); 908 #define w3m_halfdump (w3m_dump & DUMP_HALFDUMP) 909 global int w3m_halfload init(FALSE); 910 global Str header_string init(NULL); 911 global int override_content_type init(FALSE); 912 913 #ifdef USE_COLOR 914 global int useColor init(TRUE); 915 global int basic_color init(8); /* don't change */ 916 global int anchor_color init(4); /* blue */ 917 global int image_color init(2); /* green */ 918 global int form_color init(1); /* red */ 919 #ifdef USE_BG_COLOR 920 global int bg_color init(8); /* don't change */ 921 global int mark_color init(6); /* cyan */ 922 #endif /* USE_BG_COLOR */ 923 global int useActiveColor init(FALSE); 924 global int active_color init(6); /* cyan */ 925 global int useVisitedColor init(FALSE); 926 global int visited_color init(5); /* magenta */ 927 #endif /* USE_COLOR */ 928 global int confirm_on_quit init(TRUE); 929 #ifdef USE_MARK 930 global int use_mark init(FALSE); 931 #endif 932 global int emacs_like_lineedit init(FALSE); 933 global int vi_prec_num init(FALSE); 934 global int label_topline init(FALSE); 935 global int nextpage_topline init(FALSE); 936 global char *displayTitleTerm init(NULL); 937 global int displayLink init(FALSE); 938 global int displayLinkNumber init(FALSE); 939 global int displayLineInfo init(FALSE); 940 global int DecodeURL init(FALSE); 941 global int retryAsHttp init(TRUE); 942 global int showLineNum init(FALSE); 943 global int show_srch_str init(TRUE); 944 #ifdef USE_IMAGE 945 global char *Imgdisplay init(IMGDISPLAY); 946 global int activeImage init(FALSE); 947 global int displayImage init(TRUE); 948 global int autoImage init(TRUE); 949 global int useExtImageViewer init(TRUE); 950 global int maxLoadImage init(4); 951 global int image_map_list init(TRUE); 952 #else 953 global int displayImage init(FALSE); /* XXX: emacs-w3m use display_image=off */ 954 #endif 955 global int pseudoInlines init(TRUE); 956 global char *Editor init(DEF_EDITOR); 957 #ifdef USE_W3MMAILER 958 global char *Mailer init(NULL); 959 #else 960 global char *Mailer init(DEF_MAILER); 961 #endif 962 #ifdef USE_W3MMAILER 963 #define MAILTO_OPTIONS_USE_W3MMAILER 0 964 #endif 965 #define MAILTO_OPTIONS_IGNORE 1 966 #define MAILTO_OPTIONS_USE_MAILTO_URL 2 967 global int MailtoOptions init(MAILTO_OPTIONS_IGNORE); 968 global char *ExtBrowser init(DEF_EXT_BROWSER); 969 global char *ExtBrowser2 init(NULL); 970 global char *ExtBrowser3 init(NULL); 971 global int BackgroundExtViewer init(TRUE); 972 global int disable_secret_security_check init(FALSE); 973 global char *passwd_file init(PASSWD_FILE); 974 global char *pre_form_file init(PRE_FORM_FILE); 975 global char *ftppasswd init(NULL); 976 global int ftppass_hostnamegen init(TRUE); 977 global int do_download init(FALSE); 978 #ifdef USE_IMAGE 979 global char *image_source init(NULL); 980 #endif 981 global char *UserAgent init(NULL); 982 global int NoSendReferer init(FALSE); 983 global char *AcceptLang init(NULL); 984 global char *AcceptEncoding init(NULL); 985 global char *AcceptMedia init(NULL); 986 global int WrapDefault init(FALSE); 987 global int IgnoreCase init(TRUE); 988 global int WrapSearch init(FALSE); 989 global int squeezeBlankLine init(FALSE); 990 global char *BookmarkFile init(NULL); 991 global int UseExternalDirBuffer init(TRUE); 992 global char *DirBufferCommand init("file:///$LIB/dirlist" CGI_EXTENSION); 993 #ifdef USE_DICT 994 global int UseDictCommand init(FALSE); 995 global char *DictCommand init("file:///$LIB/w3mdict" CGI_EXTENSION); 996 #endif /* USE_DICT */ 997 global int ignore_null_img_alt init(TRUE); 998 #define DISPLAY_INS_DEL_SIMPLE 0 999 #define DISPLAY_INS_DEL_NORMAL 1 1000 #define DISPLAY_INS_DEL_FONTIFY 2 1001 global int displayInsDel init(DISPLAY_INS_DEL_NORMAL); 1002 global int FoldTextarea init(FALSE); 1003 global int FoldLine init(FALSE); 1004 #define DEFAULT_URL_EMPTY 0 1005 #define DEFAULT_URL_CURRENT 1 1006 #define DEFAULT_URL_LINK 2 1007 global int DefaultURLString init(DEFAULT_URL_EMPTY); 1008 global int MarkAllPages init(FALSE); 1009 1010 #ifdef USE_MIGEMO 1011 global int use_migemo init(FALSE); 1012 global int migemo_active init(0); 1013 global char *migemo_command init(DEF_MIGEMO_COMMAND); 1014 #endif /* USE_MIGEMO */ 1015 1016 global struct auth_cookie *Auth_cookie init(NULL); 1017 #ifdef USE_COOKIE 1018 global struct cookie *First_cookie init(NULL); 1019 #endif /* USE_COOKIE */ 1020 1021 global char *mailcap_files init(USER_MAILCAP ", " SYS_MAILCAP); 1022 global char *mimetypes_files init(USER_MIMETYPES ", " SYS_MIMETYPES); 1023 #ifdef USE_EXTERNAL_URI_LOADER 1024 global char *urimethodmap_files init(USER_URIMETHODMAP ", " SYS_URIMETHODMAP); 1025 #endif 1026 1027 global TextList *fileToDelete; 1028 1029 extern Hist *LoadHist; 1030 extern Hist *SaveHist; 1031 extern Hist *URLHist; 1032 extern Hist *ShellHist; 1033 extern Hist *TextHist; 1034 #ifdef USE_HISTORY 1035 global int UseHistory init(TRUE); 1036 global int URLHistSize init(100); 1037 global int SaveURLHist init(TRUE); 1038 #endif /* USE_HISTORY */ 1039 global int multicolList init(FALSE); 1040 1041 #ifdef USE_M17N 1042 global wc_ces InnerCharset init(WC_CES_WTF); /* Don't change */ 1043 global wc_ces DisplayCharset init(DISPLAY_CHARSET); 1044 global wc_ces DocumentCharset init(DOCUMENT_CHARSET); 1045 global wc_ces SystemCharset init(SYSTEM_CHARSET); 1046 global wc_ces BookmarkCharset init(SYSTEM_CHARSET); 1047 global char ExtHalfdump init(FALSE); 1048 global char FollowLocale init(TRUE); 1049 global char UseContentCharset init(TRUE); 1050 global char SearchConv init(TRUE); 1051 global char SimplePreserveSpace init(FALSE); 1052 #define Str_conv_from_system(x) wc_Str_conv((x), SystemCharset, InnerCharset) 1053 #define Str_conv_to_system(x) wc_Str_conv_strict((x), InnerCharset, SystemCharset) 1054 #define Str_conv_to_halfdump(x) (ExtHalfdump ? wc_Str_conv((x), InnerCharset, DisplayCharset) : (x)) 1055 #define conv_from_system(x) wc_conv((x), SystemCharset, InnerCharset)->ptr 1056 #define conv_to_system(x) wc_conv_strict((x), InnerCharset, SystemCharset)->ptr 1057 #define url_quote_conv(x,c) url_quote(wc_conv_strict((x), InnerCharset, (c))->ptr) 1058 #else 1059 #define Str_conv_from_system(x) (x) 1060 #define Str_conv_to_system(x) (x) 1061 #define Str_conv_to_halfdump(x) (x) 1062 #define conv_from_system(x) (x) 1063 #define conv_to_system(x) (x) 1064 #define url_quote_conv(x,c) url_quote(x) 1065 #define wc_Str_conv(x,charset0,charset1) (x) 1066 #define wc_Str_conv_strict(x,charset0,charset1) (x) 1067 #endif 1068 global char UseAltEntity init(TRUE); 1069 #define GRAPHIC_CHAR_ASCII 2 1070 #define GRAPHIC_CHAR_DEC 1 1071 #define GRAPHIC_CHAR_CHARSET 0 1072 global char UseGraphicChar init(GRAPHIC_CHAR_CHARSET); 1073 extern char *graph_symbol[]; 1074 extern char *graph2_symbol[]; 1075 extern int symbol_width; 1076 extern int symbol_width0; 1077 #define N_GRAPH_SYMBOL 32 1078 #define SYMBOL_BASE 0x20 1079 global int no_rc_dir init(FALSE); 1080 global char *rc_dir init(NULL); 1081 global char *tmp_dir; 1082 global char *config_file init(NULL); 1083 1084 #ifdef USE_MOUSE 1085 global int use_mouse init(TRUE); 1086 extern int mouseActive; 1087 global int reverse_mouse init(FALSE); 1088 global int relative_wheel_scroll init(FALSE); 1089 global int fixed_wheel_scroll_count init(5); 1090 global int relative_wheel_scroll_ratio init(30); 1091 typedef struct _MouseActionMap { 1092 void (*func) (); 1093 char *data; 1094 } MouseActionMap; 1095 typedef struct _MouseAction { 1096 char *menu_str; 1097 char *lastline_str; 1098 int menu_width; 1099 int lastline_width; 1100 int in_action; 1101 int cursorX; 1102 int cursorY; 1103 MouseActionMap default_map[3]; 1104 MouseActionMap anchor_map[3]; 1105 MouseActionMap active_map[3]; 1106 MouseActionMap tab_map[3]; 1107 MouseActionMap *menu_map[3]; 1108 MouseActionMap *lastline_map[3]; 1109 } MouseAction; 1110 global MouseAction mouse_action; 1111 #define LIMIT_MOUSE_MENU 100 1112 #endif /* USE_MOUSE */ 1113 1114 #ifdef USE_COOKIE 1115 global int default_use_cookie init(TRUE); 1116 global int use_cookie init(FALSE); 1117 global int show_cookie init(TRUE); 1118 global int accept_cookie init(FALSE); 1119 #define ACCEPT_BAD_COOKIE_DISCARD 0 1120 #define ACCEPT_BAD_COOKIE_ACCEPT 1 1121 #define ACCEPT_BAD_COOKIE_ASK 2 1122 global int accept_bad_cookie init(ACCEPT_BAD_COOKIE_DISCARD); 1123 global char *cookie_reject_domains init(NULL); 1124 global char *cookie_accept_domains init(NULL); 1125 global char *cookie_avoid_wrong_number_of_dots init(NULL); 1126 global TextList *Cookie_reject_domains; 1127 global TextList *Cookie_accept_domains; 1128 global TextList *Cookie_avoid_wrong_number_of_dots_domains; 1129 #endif /* USE_COOKIE */ 1130 1131 #ifdef USE_IMAGE 1132 global int view_unseenobject init(FALSE); 1133 #else 1134 global int view_unseenobject init(TRUE); 1135 #endif 1136 1137 #if defined(USE_SSL) && defined(USE_SSL_VERIFY) 1138 global int ssl_verify_server init(FALSE); 1139 global char *ssl_cert_file init(NULL); 1140 global char *ssl_key_file init(NULL); 1141 global char *ssl_ca_path init(NULL); 1142 global char *ssl_ca_file init(NULL); 1143 global int ssl_path_modified init(FALSE); 1144 #endif /* defined(USE_SSL) && 1145 * defined(USE_SSL_VERIFY) */ 1146 #ifdef USE_SSL 1147 global char *ssl_forbid_method init(NULL); 1148 #endif 1149 1150 global int is_redisplay init(FALSE); 1151 global int clear_buffer init(TRUE); 1152 global double pixel_per_char init(DEFAULT_PIXEL_PER_CHAR); 1153 global int set_pixel_per_char init(FALSE); 1154 #ifdef USE_IMAGE 1155 global double pixel_per_line init(DEFAULT_PIXEL_PER_LINE); 1156 global int set_pixel_per_line init(FALSE); 1157 global double image_scale init(100); 1158 #endif 1159 global int use_lessopen init(FALSE); 1160 1161 global char *keymap_file init(KEYMAP_FILE); 1162 1163 #ifdef USE_M17N 1164 #define get_mctype(c) ((Lineprop)wtf_type((wc_uchar *)(c)) << 8) 1165 #define get_mclen(c) wtf_len1((wc_uchar *)(c)) 1166 #define get_mcwidth(c) wtf_width((wc_uchar *)(c)) 1167 #define get_strwidth(c) wtf_strwidth((wc_uchar *)(c)) 1168 #define get_Str_strwidth(c) wtf_strwidth((wc_uchar *)((c)->ptr)) 1169 #else 1170 #define get_mctype(c) (IS_CNTRL(*(c)) ? PC_CTRL : PC_ASCII) 1171 #define get_mclen(c) 1 1172 #define get_mcwidth(c) 1 1173 #define get_strwidth(c) strlen(c) 1174 #define get_Str_strwidth(c) ((c)->length) 1175 #endif 1176 1177 global int FollowRedirection init(10); 1178 1179 global int w3m_backend init(FALSE); 1180 global TextLineList *backend_halfdump_buf; 1181 global TextList *backend_batch_commands init(NULL); 1182 int backend(void); 1183 extern void deleteFiles(void); 1184 void w3m_exit(int i); 1185 1186 #ifdef USE_ALARM 1187 #define AL_UNSET 0 1188 #define AL_EXPLICIT 1 1189 #define AL_IMPLICIT 2 1190 #define AL_IMPLICIT_ONCE 3 1191 1192 typedef struct _AlarmEvent { 1193 int sec; 1194 short status; 1195 int cmd; 1196 void *data; 1197 } AlarmEvent; 1198 #endif 1199 1200 /* 1201 * Externals 1202 */ 1203 1204 #include "table.h" 1205 #include "proto.h" 1206 1207 #endif /* not FM_H */