links  1.04
About: Links is a Lynx-like text WWW browser (table support and pop-up dialog boxes).
  Fossies Dox: links-1.04.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

html.c File Reference
#include "links.h"
Include dependency graph for html.c:

Go to the source code of this file.

Data Structures

struct  color_spec
 
struct  element_info
 

Macros

#define add_chr(s, l, c)
 
#define endof(T)   ((T)+sizeof(T)/sizeof(*(T)))
 

Functions

static int atchr (unsigned char c)
 
int parse_element (unsigned char *e, unsigned char *eof, unsigned char **name, int *namelen, unsigned char **attr, unsigned char **end)
 
unsigned char * get_attr_val (unsigned char *e, unsigned char *name)
 
int has_attr (unsigned char *e, unsigned char *name)
 
unsigned char * get_url_val (unsigned char *e, unsigned char *name)
 
unsigned char * get_exact_attr_val (unsigned char *e, unsigned char *name)
 
void roman (char *p, unsigned n)
 
int decode_color (unsigned char *str, struct rgb *col)
 
int get_color (unsigned char *a, unsigned char *c, struct rgb *rgb)
 
int get_bgcolor (unsigned char *a, struct rgb *rgb)
 
unsigned char * get_target (unsigned char *a)
 
void kill_html_stack_item (struct html_element *e)
 
void html_stack_dup ()
 
void ln_break (int n, void(*line_break)(void *), void *f)
 
void put_chrs (unsigned char *start, int len, int(*put_chars)(void *, unsigned char *, int), void *f)
 
void kill_until (int ls,...)
 
static unsigned char * top_href_base (void)
 
int get_num (unsigned char *a, unsigned char *n)
 
int parse_width (unsigned char *w, int trunc)
 
int get_width (unsigned char *a, unsigned char *n, int trunc)
 
void put_link_line (unsigned char *prefix, unsigned char *linkname, unsigned char *link, unsigned char *target)
 
void html_span (unsigned char *a)
 
void html_bold (unsigned char *a)
 
void html_italic (unsigned char *a)
 
void html_underline (unsigned char *a)
 
void html_fixed (unsigned char *a)
 
void html_a (unsigned char *a)
 
void html_font (unsigned char *a)
 
void html_img (unsigned char *a)
 
void html_body (unsigned char *a)
 
void html_skip (unsigned char *a)
 
void html_title (unsigned char *a)
 
void html_center (unsigned char *a)
 
void html_linebrk (unsigned char *a)
 
void html_br (unsigned char *a)
 
void html_form (unsigned char *a)
 
void html_p (unsigned char *a)
 
void html_address (unsigned char *a)
 
void html_blockquote (unsigned char *a)
 
void html_h (int h, char *a)
 
void html_h2 (unsigned char *a)
 
void html_h3 (unsigned char *a)
 
void html_h4 (unsigned char *a)
 
void html_h5 (unsigned char *a)
 
void html_h6 (unsigned char *a)
 
void html_pre (unsigned char *a)
 
void html_hr (unsigned char *a)
 
void html_table (unsigned char *a)
 
void html_tr (unsigned char *a)
 
void html_th (unsigned char *a)
 
void html_td (unsigned char *a)
 
void html_base (unsigned char *a)
 
void html_ul (unsigned char *a)
 
void html_ol (unsigned char *a)
 
void html_li (unsigned char *a)
 
void html_dl (unsigned char *a)
 
void html_dt (unsigned char *a)
 
void html_dd (unsigned char *a)
 
void get_html_form (unsigned char *a, struct form *form)
 
void find_form_for_input (unsigned char *i, int when_unused)
 
void html_button (unsigned char *a)
 
void set_max_textarea_width (int *w)
 
void html_input (unsigned char *a)
 
void html_select (unsigned char *a)
 
void html_option (unsigned char *a)
 
void clr_spaces (unsigned char *name)
 
void new_menu_item (unsigned char *name, int data, int fullname)
 
void init_menu ()
 
void free_menu (struct menu_item *m)
 
struct menu_itemdetach_menu ()
 
void destroy_menu ()
 
void menu_labels (struct menu_item *m, unsigned char *base, unsigned char **lbls)
 
int menu_contains (struct menu_item *m, int f)
 
void do_select_submenu (struct terminal *term, struct menu_item *menu, struct session *ses)
 
int do_html_select (unsigned char *attr, unsigned char *html, unsigned char *eof, unsigned char **end, void *f)
 
void html_textarea (unsigned char *a)
 
void do_html_textarea (unsigned char *attr, unsigned char *html, unsigned char *eof, unsigned char **end, void *f)
 
void html_iframe (unsigned char *a)
 
void html_noframes (unsigned char *a)
 
void html_frame (unsigned char *a)
 
void parse_frame_widths (unsigned char *a, int ww, int www, int **op, int *olp)
 
void html_frameset (unsigned char *a)
 
void html_link (unsigned char *a)
 
unsigned char * skip_comment (unsigned char *html, unsigned char *eof)
 
void process_head (unsigned char *head)
 
int qd (unsigned char *html, unsigned char *eof, int *len)
 
void parse_html (unsigned char *html, unsigned char *eof, int(*put_chars)(void *, unsigned char *, int), void(*line_break)(void *), void *(*special)(void *, int,...), void *f, unsigned char *head)
 
int get_image_map (unsigned char *head, unsigned char *s, unsigned char *eof, unsigned char *tag, struct menu_item **menu, struct memory_list **ml, unsigned char *href_base, unsigned char *target_base, int to, int def, int hdef)
 
void scan_http_equiv (unsigned char *s, unsigned char *eof, unsigned char **head, int *hdl, unsigned char **title)
 

Variables

struct list_head html_stack = {&html_stack, &html_stack}
 
int get_attr_val_nl = 0
 
struct {
   unsigned short int   n
 
   char *   s
 
roman_tbl []
 
struct color_spec color_specs []
 
void * ff
 
int(* put_chars_f )(void *, unsigned char *, int)
 
void(* line_break_f )(void *)
 
void *(* special_f )(void *, int,...)
 
unsigned char * eoff
 
unsigned char * eofff
 
unsigned char * startf
 
int line_breax
 
int pos
 
int putsp
 
int was_br
 
int table_level
 
int empty_format
 
struct form form = { NULL, NULL, 0, 0 }
 
unsigned char * last_form_tag
 
unsigned char * last_form_attr
 
unsigned char * last_input_tag
 
int menu_stack_size
 
struct menu_item ** menu_stack
 
struct element_info elements []
 

Macro Definition Documentation

◆ add_chr

#define add_chr (   s,
  l,
 
)
Value:
do { \
if (!((l) & (32 - 1))) { \
if ((unsigned)(l) > MAXINT - 32) overalloc(); \
(s) = mem_realloc((s), (l) + 32); \
} \
(s)[(l)++] = (c); \
} while (0)

Definition at line 82 of file html.c.

◆ endof

#define endof (   T)    ((T)+sizeof(T)/sizeof(*(T)))

Definition at line 427 of file html.c.

Function Documentation

◆ atchr()

static int atchr ( unsigned char  c)
inlinestatic

Definition at line 5 of file html.c.

Referenced by get_attr_val(), and parse_element().

◆ clr_spaces()

void clr_spaces ( unsigned char *  name)

Definition at line 1433 of file html.c.

References name, strchr(), and WHITECHAR.

Referenced by get_image_map(), new_menu_item(), and scan_http_equiv().

◆ decode_color()

int decode_color ( unsigned char *  str,
struct rgb col 
)

Definition at line 429 of file html.c.

References rgb::b, color_specs, endof, rgb::g, color_spec::name, rgb::r, color_spec::rgb, strcasecmp(), strlen(), and strtoul().

Referenced by get_color().

◆ destroy_menu()

void destroy_menu ( )

Definition at line 1521 of file html.c.

References detach_menu(), DUMMY, free_menu(), and menu_stack.

Referenced by do_html_select().

◆ detach_menu()

struct menu_item* detach_menu ( )

Definition at line 1513 of file html.c.

References mem_free(), menu_stack, and menu_stack_size.

Referenced by destroy_menu(), and do_html_select().

◆ do_html_select()

◆ do_html_textarea()

◆ do_select_submenu()

void do_select_submenu ( struct terminal term,
struct menu_item menu,
struct session ses 
)

◆ find_form_for_input()

void find_form_for_input ( unsigned char *  i,
int  when_unused 
)

◆ free_menu()

void free_menu ( struct menu_item m)

◆ get_attr_val()

◆ get_bgcolor()

int get_bgcolor ( unsigned char *  a,
struct rgb rgb 
)

Definition at line 467 of file html.c.

References document_options::col, d_opt, and get_color().

Referenced by format_table(), html_body(), and parse_table().

◆ get_color()

int get_color ( unsigned char *  a,
unsigned char *  c,
struct rgb rgb 
)

Definition at line 456 of file html.c.

References document_options::col, d_opt, decode_color(), get_attr_val(), and mem_free().

Referenced by get_bgcolor(), html_body(), and html_font().

◆ get_exact_attr_val()

unsigned char* get_exact_attr_val ( unsigned char *  e,
unsigned char *  name 
)

Definition at line 201 of file html.c.

References get_attr_val(), get_attr_val_nl, and name.

Referenced by do_html_select(), html_button(), html_input(), and html_option().

◆ get_html_form()

void get_html_form ( unsigned char *  a,
struct form form 
)

◆ get_image_map()

int get_image_map ( unsigned char *  head,
unsigned char *  s,
unsigned char *  eof,
unsigned char *  tag,
struct menu_item **  menu,
struct memory_list **  ml,
unsigned char *  href_base,
unsigned char *  target_base,
int  to,
int  def,
int  hdef 
)

◆ get_num()

int get_num ( unsigned char *  a,
unsigned char *  n 
)

Definition at line 649 of file html.c.

References get_attr_val(), mem_free(), n, s, and strtoul().

Referenced by do_html_textarea(), format_table(), html_hr(), html_input(), html_li(), html_ol(), and parse_table().

◆ get_target()

unsigned char* get_target ( unsigned char *  a)

◆ get_url_val()

unsigned char* get_url_val ( unsigned char *  e,
unsigned char *  name 
)

◆ get_width()

int get_width ( unsigned char *  a,
unsigned char *  n,
int  trunc 
)

Definition at line 686 of file html.c.

References get_attr_val(), mem_free(), n, and parse_width().

Referenced by format_table(), get_c_width(), and html_hr().

◆ has_attr()

int has_attr ( unsigned char *  e,
unsigned char *  name 
)

◆ html_a()

void html_a ( unsigned char *  a)

◆ html_address()

void html_address ( unsigned char *  a)

Definition at line 878 of file html.c.

References AL_LEFT, and par_format.

◆ html_base()

void html_base ( unsigned char *  a)

Definition at line 979 of file html.c.

References format_, get_target(), get_url_val(), join_urls(), mem_free(), and top_href_base().

◆ html_blockquote()

void html_blockquote ( unsigned char *  a)

Definition at line 884 of file html.c.

References AL_LEFT, and par_format.

◆ html_body()

void html_body ( unsigned char *  a)

Definition at line 824 of file html.c.

References format_, get_bgcolor(), get_color(), and par_format.

◆ html_bold()

void html_bold ( unsigned char *  a)

Definition at line 719 of file html.c.

References AT_BOLD, and format_.

◆ html_br()

void html_br ( unsigned char *  a)

Definition at line 858 of file html.c.

References ff, html_linebrk(), line_break_f, ln_break(), and was_br.

Referenced by parse_html().

◆ html_button()

◆ html_center()

void html_center ( unsigned char *  a)

Definition at line 837 of file html.c.

References AL_CENTER, par_format, and table_level.

◆ html_dd()

void html_dd ( unsigned char *  a)

Definition at line 1100 of file html.c.

References AL_LEFT, kill_until(), par_format, and table_level.

◆ html_dl()

void html_dl ( unsigned char *  a)

Definition at line 1075 of file html.c.

References AL_LEFT, ff, has_attr(), html_top, line_break_f, ln_break(), P_COMPACT, and par_format.

◆ html_dt()

void html_dt ( unsigned char *  a)

Definition at line 1091 of file html.c.

References AL_LEFT, ff, has_attr(), kill_until(), line_break_f, ln_break(), P_COMPACT, and par_format.

◆ html_fixed()

void html_fixed ( unsigned char *  a)

Definition at line 722 of file html.c.

References AT_FIXED, and format_.

◆ html_font()

void html_font ( unsigned char *  a)

Definition at line 750 of file html.c.

References format_, get_attr_val(), get_color(), mem_free(), s, and strtoul().

◆ html_form()

void html_form ( unsigned char *  a)

Definition at line 865 of file html.c.

References was_br.

◆ html_frame()

◆ html_frameset()

◆ html_h()

void html_h ( int  h,
char *  a 
)

Definition at line 890 of file html.c.

References AL_BLOCK, AL_CENTER, AL_LEFT, AL_RIGHT, do_not_optimize_here(), html_linebrk(), and par_format.

Referenced by html_h2(), html_h3(), html_h4(), html_h5(), and html_h6().

◆ html_h2()

void html_h2 ( unsigned char *  a)

Definition at line 913 of file html.c.

References html_h().

◆ html_h3()

void html_h3 ( unsigned char *  a)

Definition at line 914 of file html.c.

References html_h().

◆ html_h4()

void html_h4 ( unsigned char *  a)

Definition at line 915 of file html.c.

References html_h().

◆ html_h5()

void html_h5 ( unsigned char *  a)

Definition at line 916 of file html.c.

References html_h().

◆ html_h6()

void html_h6 ( unsigned char *  a)

Definition at line 917 of file html.c.

References html_h().

◆ html_hr()

◆ html_iframe()

void html_iframe ( unsigned char *  a)

◆ html_img()

◆ html_input()

◆ html_italic()

void html_italic ( unsigned char *  a)

Definition at line 720 of file html.c.

References AT_ITALIC, and format_.

◆ html_li()

void html_li ( unsigned char *  a)

◆ html_linebrk()

void html_linebrk ( unsigned char *  a)

◆ html_link()

void html_link ( unsigned char *  a)

◆ html_noframes()

void html_noframes ( unsigned char *  a)

Definition at line 1801 of file html.c.

References d_opt, document_options::frames, and html_skip().

◆ html_ol()

void html_ol ( unsigned char *  a)

◆ html_option()

◆ html_p()

void html_p ( unsigned char *  a)

Definition at line 870 of file html.c.

References html_linebrk(), margin, and par_format.

◆ html_pre()

void html_pre ( unsigned char *  a)

Definition at line 919 of file html.c.

References AL_NO, and par_format.

◆ html_select()

void html_select ( unsigned char *  a)

Definition at line 1361 of file html.c.

References format_, get_attr_val(), has_attr(), html_top, and mem_free().

Referenced by parse_html().

◆ html_skip()

void html_skip ( unsigned char *  a)

Definition at line 833 of file html.c.

References html_top.

Referenced by html_noframes().

◆ html_span()

void html_span ( unsigned char *  a)

Definition at line 718 of file html.c.

◆ html_stack_dup()

◆ html_table()

void html_table ( unsigned char *  a)

Definition at line 949 of file html.c.

References AL_LEFT, format_, html_linebrk(), margin, and par_format.

Referenced by parse_html().

◆ html_td()

void html_td ( unsigned char *  a)

Definition at line 971 of file html.c.

References AT_BOLD, ff, format_, kill_until(), put_chars_f, and put_chrs().

◆ html_textarea()

void html_textarea ( unsigned char *  a)

Definition at line 1720 of file html.c.

Referenced by parse_html().

◆ html_th()

void html_th ( unsigned char *  a)

Definition at line 963 of file html.c.

References AT_BOLD, ff, format_, kill_until(), put_chars_f, and put_chrs().

◆ html_title()

void html_title ( unsigned char *  a)

Definition at line 835 of file html.c.

References html_top.

◆ html_tr()

void html_tr ( unsigned char *  a)

Definition at line 958 of file html.c.

References html_linebrk().

◆ html_ul()

void html_ul ( unsigned char *  a)

Definition at line 993 of file html.c.

References AL_LEFT, get_attr_val(), html_top, mem_free(), P_O, P_PLUS, P_STAR, par_format, strcasecmp(), and table_level.

◆ html_underline()

void html_underline ( unsigned char *  a)

Definition at line 721 of file html.c.

References AT_UNDERLINE, and format_.

◆ init_menu()

void init_menu ( )

Definition at line 1496 of file html.c.

References DUMMY, menu_stack, menu_stack_size, new_menu_item(), and stracpy().

Referenced by do_html_select().

◆ kill_html_stack_item()

◆ kill_until()

◆ ln_break()

void ln_break ( int  n,
void(*)(void *)  line_break,
void *  f 
)

◆ menu_contains()

int menu_contains ( struct menu_item m,
int  f 
)

◆ menu_labels()

void menu_labels ( struct menu_item m,
unsigned char *  base,
unsigned char **  lbls 
)

◆ new_menu_item()

◆ parse_element()

int parse_element ( unsigned char *  e,
unsigned char *  eof,
unsigned char **  name,
int *  namelen,
unsigned char **  attr,
unsigned char **  end 
)

◆ parse_frame_widths()

void parse_frame_widths ( unsigned char *  a,
int  ww,
int  www,
int **  op,
int *  olp 
)

◆ parse_html()

◆ parse_width()

int parse_width ( unsigned char *  w,
int  trunc 
)

Definition at line 662 of file html.c.

References HTML_CHAR_WIDTH, par_format, s, strtoul(), and WHITECHAR.

Referenced by get_width().

◆ process_head()

void process_head ( unsigned char *  head)

◆ put_chrs()

void put_chrs ( unsigned char *  start,
int  len,
int(*)(void *, unsigned char *, int)  put_chars,
void *  f 
)

◆ put_link_line()

void put_link_line ( unsigned char *  prefix,
unsigned char *  linkname,
unsigned char *  link,
unsigned char *  target 
)

◆ qd()

int qd ( unsigned char *  html,
unsigned char *  eof,
int *  len 
)

Definition at line 2159 of file html.c.

References d_opt, get_entity_number(), n, and document_options::plain.

Referenced by parse_html().

◆ roman()

void roman ( char *  p,
unsigned  n 
)

Definition at line 254 of file html.c.

References n, roman_tbl, s, and strcpy().

Referenced by html_li().

◆ scan_http_equiv()

void scan_http_equiv ( unsigned char *  s,
unsigned char *  eof,
unsigned char **  head,
int *  hdl,
unsigned char **  title 
)

◆ set_max_textarea_width()

void set_max_textarea_width ( int *  w)

Definition at line 1240 of file html.c.

References d_opt, HTML_MINIMAL_TEXTAREA_WIDTH, par_format, table_level, and document_options::xw.

Referenced by do_html_textarea(), and html_input().

◆ skip_comment()

unsigned char* skip_comment ( unsigned char *  html,
unsigned char *  eof 
)

◆ top_href_base()

static unsigned char* top_href_base ( void  )
inlinestatic

Definition at line 644 of file html.c.

References html_stack, and list_head::prev.

Referenced by html_base(), and html_img().

Variable Documentation

◆ color_specs

struct color_spec color_specs[]

Definition at line 284 of file html.c.

Referenced by decode_color().

◆ elements

struct element_info elements[]

Definition at line 2052 of file html.c.

Referenced by parse_html().

◆ empty_format

int empty_format

Definition at line 570 of file html.c.

Referenced by format_html_part().

◆ eoff

unsigned char* eoff

Definition at line 560 of file html.c.

Referenced by html_option(), and parse_html().

◆ eofff

unsigned char* eofff

Definition at line 561 of file html.c.

Referenced by find_form_for_input(), and format_html().

◆ ff

◆ form

struct form form = { NULL, NULL, 0, 0 }

Definition at line 696 of file html.c.

Referenced by get_succesful_controls(), and reset_form().

◆ get_attr_val_nl

int get_attr_val_nl = 0

Definition at line 91 of file html.c.

Referenced by get_attr_val(), get_entity_string(), get_exact_attr_val(), and get_url_val().

◆ html_stack

struct list_head html_stack = {&html_stack, &html_stack}

◆ last_form_attr

unsigned char* last_form_attr

Definition at line 699 of file html.c.

Referenced by find_form_for_input(), and format_html().

◆ last_form_tag

unsigned char* last_form_tag

◆ last_input_tag

unsigned char* last_input_tag

Definition at line 700 of file html.c.

Referenced by find_form_for_input(), and format_html().

◆ line_break_f

void(* line_break_f) (void *)

◆ line_breax

int line_breax

Definition at line 564 of file html.c.

Referenced by format_html_part(), html_li(), ln_break(), parse_html(), and put_chrs().

◆ menu_stack

struct menu_item** menu_stack

Definition at line 1449 of file html.c.

Referenced by destroy_menu(), detach_menu(), init_menu(), and new_menu_item().

◆ menu_stack_size

int menu_stack_size

Definition at line 1448 of file html.c.

Referenced by detach_menu(), init_menu(), and new_menu_item().

◆ n

◆ pos

◆ put_chars_f

int(* put_chars_f) (void *, unsigned char *, int)

◆ putsp

int putsp

Definition at line 566 of file html.c.

Referenced by html_li(), ln_break(), parse_html(), and put_chrs().

◆ roman_tbl

struct { ... } roman_tbl[]
Initial value:
= {
{ 1000, "m" },
{ 999, "im" },
{ 990, "xm" },
{ 900, "cm" },
{ 500, "d" },
{ 499, "id" },
{ 490, "xd" },
{ 400, "cd" },
{ 100, "c" },
{ 99, "ic" },
{ 90, "xc" },
{ 50, "l" },
{ 49, "il" },
{ 40, "xl" },
{ 10, "x" },
{ 9, "ix" },
{ 5, "v" },
{ 4, "iv" },
{ 1, "i" },
{ 0, NULL },
}

Referenced by roman().

◆ s

char* s

Definition at line 224 of file html.c.

Referenced by add_and_pad(), add_bytes_to_str(), add_chr_to_str(), add_conv_str(), add_file_cmd_to_str(), add_knum_to_str(), add_nm(), add_num_to_str(), add_port_pasv(), add_quoted_to_str(), add_time_to_str(), add_to_str(), add_to_strn(), add_unsigned_long_num_to_str(), add_xnum_to_str(), alloc_term_screen(), check_table_widths(), close_socket(), cookie_default(), count_menu_size(), cp_wr(), create_config_string(), debug_mem_alloc(), debug_mem_realloc(), display_complicated_table(), display_mainmenu(), display_menu(), dlg_format_text(), dlg_set_history(), dns_found(), do_html_select(), download_percentage(), draw_form_entry(), dst_width(), dump_to_file(), ext_wr(), file_func(), find_form_for_input(), find_link(), format_table(), format_text(), get_column_widths(), get_content_type(), get_entity_string(), get_err_msg(), get_filename_from_url(), get_image_map(), get_num(), get_pasv_socket(), get_table_heights(), get_temp_name(), get_token(), get_translation_table(), getnum(), head_msg(), html_font(), html_img(), html_li(), init_str_x(), is_in_domain(), is_path_prefix(), join_urls(), kill_until(), lang_wr(), loc_msg(), mainmenu_func(), memchr(), memset(), menu_func(), menu_version(), num_wr(), parse_act(), parse_key(), parse_keymap(), parse_keystroke(), parse_width(), prog_wr(), put_chars(), raise(), read_config_file(), read_from_socket(), read_session_info(), redraw_screen(), roman(), scan_http_equiv(), send_cookies(), send_event(), set_cookie(), shift_chars(), smb_func(), snprint(), snzprint(), sort_srch(), str2num(), str_wr(), strchr(), strcspn(), strdup(), strlen(), strrchr(), strspn(), tempnam(), term_wr(), translate_directories(), type_wr(), u2cp(), update_prog(), write_bookmarks(), and write_to_socket().

◆ special_f

◆ startf

unsigned char* startf

◆ table_level

◆ was_br

int was_br

Definition at line 568 of file html.c.

Referenced by html_br(), html_form(), parse_html(), and put_chrs().

s
char * s
Definition: html.c:224
MAXINT
#define MAXINT
Definition: os_depx.h:5