links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: f8b421c16940c862465164c9d02d87038b9a9a6c
Parent: ce5ac71d13859676037e5d936909d94eb7ac57a3
Author: Randy Palamar
Date:   Sun,  4 Dec 2022 22:42:42 -0700

add_to_str(): return new str length

this also converts a number of other functions to do the same

Diffstat:
Mauth.c | 23++++++++++++-----------
Mbfu.c | 6++++--
Mbookmark.c | 68+++++++++++++++++++++++++++++++++-----------------------------------
Mcache.c | 10+++++-----
Mcharsets.c | 4++--
Mcompress.c | 13+++++++------
Mconnect.c | 6+++---
Mcookies.c | 20+++++++++++---------
Mdata.c | 7+++----
Mdefault.c | 209++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mfile.c | 117+++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mhtml.c | 32++++++++++++++++----------------
Mhtml_r.c | 15+++++++--------
Mhttp.c | 343+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mhttps.c | 20++++++++++----------
Mlinks.h | 21++++++++++-----------
Mmemory.c | 6+++---
Mmenu.c | 210++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mselect.c | 37++++++++++++++++++++-----------------
Msession.c | 158+++++++++++++++++++++++++++++++++++++++----------------------------------------
Mstring.c | 24+++++++++++++-----------
Mterminal.c | 54++++++++++++++++++++++++++++--------------------------
Mtypes.c | 14+++++---------
Murl.c | 59++++++++++++++++++++++++++++++-----------------------------
Mview.c | 638++++++++++++++++++++++++++++++++++++++++---------------------------------------
25 files changed, 1069 insertions(+), 1045 deletions(-)

diff --git a/auth.c b/auth.c @@ -126,7 +126,7 @@ static unsigned char * auth_from_url(unsigned char *url, int proxy) { unsigned char *r = NULL; - int l = 0; + size_t l = 0; unsigned char *user, *password; user = get_user_name(url); @@ -135,10 +135,10 @@ auth_from_url(unsigned char *url, int proxy) unsigned char *e = basic_encode(user, password); r = NULL; if (proxy) - add_to_str(&r, &l, cast_uchar "Proxy-"); - add_to_str(&r, &l, cast_uchar "Authorization: Basic "); - add_to_str(&r, &l, e); - add_to_str(&r, &l, cast_uchar "\r\n"); + l = add_to_str(&r, l, cast_uchar "Proxy-"); + l = add_to_str(&r, l, cast_uchar "Authorization: Basic "); + l = add_to_str(&r, l, e); + l = add_to_str(&r, l, cast_uchar "\r\n"); free(e); free(user); free(password); @@ -157,7 +157,7 @@ get_auth_string(unsigned char *url, int proxy) unsigned char *host; int port; unsigned char *r = NULL; - int l = 0; + size_t l = 0; if (proxy && !is_proxy_url(url)) return NULL; if (!(host = get_host_name(url))) @@ -186,11 +186,12 @@ get_auth_string(unsigned char *url, int proxy) skip_dir_check: r = NULL; if (proxy) - add_to_str(&r, &l, cast_uchar "Proxy-"); - add_to_str(&r, &l, - cast_uchar "Authorization: Basic "); - add_to_str(&r, &l, a->user_password_encoded); - add_to_str(&r, &l, cast_uchar "\r\n"); + l = add_to_str(&r, l, + cast_uchar "Proxy-"); + l = add_to_str( + &r, l, cast_uchar "Authorization: Basic "); + l = add_to_str(&r, l, a->user_password_encoded); + l = add_to_str(&r, l, cast_uchar "\r\n"); goto have_passwd; } } diff --git a/bfu.c b/bfu.c @@ -2107,9 +2107,11 @@ msg_box_fn(struct dialog_data *dlg) int y = 0; unsigned char **ptr; unsigned char *text = NULL; - int textl = 0; + size_t textl = 0; + for (ptr = dlg->dlg->udata; *ptr; ptr++) - add_to_str(&text, &textl, get_text_translation(*ptr, term)); + textl = + add_to_str(&text, textl, get_text_translation(*ptr, term)); max_text_width(term, text, &max, dlg->dlg->align); min_text_width(term, text, &min, dlg->dlg->align); max_buttons_width(term, dlg->items, dlg->n, &max); diff --git a/bookmark.c b/bookmark.c @@ -691,31 +691,28 @@ save_only: static unsigned char * convert_to_entity_string(unsigned char *str) { - unsigned char *dst, *p; - int dstl; - - dst = NULL; - dstl = 0; + unsigned char *dst, *p = NULL; + size_t dstl = 0; for (p = str; *p; p++) switch (*p) { case '<': - add_to_str(&dst, &dstl, cast_uchar "&lt;"); + dstl = add_to_str(&dst, dstl, cast_uchar "&lt;"); break; case '>': - add_to_str(&dst, &dstl, cast_uchar "&gt;"); + dstl = add_to_str(&dst, dstl, cast_uchar "&gt;"); break; case '=': - add_to_str(&dst, &dstl, cast_uchar "&equals;"); + dstl = add_to_str(&dst, dstl, cast_uchar "&equals;"); break; case '&': - add_to_str(&dst, &dstl, cast_uchar "&amp;"); + dstl = add_to_str(&dst, dstl, cast_uchar "&amp;"); break; case '"': - add_to_str(&dst, &dstl, cast_uchar "&quot;"); + dstl = add_to_str(&dst, dstl, cast_uchar "&quot;"); break; default: @@ -733,30 +730,30 @@ save_bookmarks(struct session *ses) int depth; int a; unsigned char *data; - int l; + size_t l; int err; int rs; if (!bookmark_ld.modified) return; data = NULL; - l = 0; - add_to_str(&data, &l, - cast_uchar "<HTML>\n" - "<HEAD>\n" - "<!-- This is an automatically generated file.\n" - "It will be read and overwritten.\n" - "Do Not Edit! -->\n" - "<TITLE>Links bookmarks</TITLE>\n" - "</HEAD>\n" - "<H1>Links bookmarks</H1>\n\n" - "<DL><P>\n"); + l = add_to_str(&data, 0, + cast_uchar + "<HTML>\n" + "<HEAD>\n" + "<!-- This is an automatically generated file.\n" + "It will be read and overwritten.\n" + "Do Not Edit! -->\n" + "<TITLE>Links bookmarks</TITLE>\n" + "</HEAD>\n" + "<H1>Links bookmarks</H1>\n\n" + "<DL><P>\n"); depth = 0; foreach (struct list, li, lli, bookmarks.list_entry) { struct bookmark_list *b = get_struct(li, struct bookmark_list, head); for (a = b->head.depth; a < depth; a++) - add_to_str(&data, &l, cast_uchar "</DL>\n"); + l = add_to_str(&data, l, cast_uchar "</DL>\n"); depth = b->head.depth; if (b->head.type & 1) { @@ -764,9 +761,9 @@ save_bookmarks(struct session *ses) txt = stracpy(b->title); clr_white(txt); txt1 = convert_to_entity_string(txt); - add_to_str(&data, &l, cast_uchar " <DT><H3>"); - add_to_str(&data, &l, txt1); - add_to_str(&data, &l, cast_uchar "</H3>\n<DL>\n"); + l = add_to_str(&data, l, cast_uchar " <DT><H3>"); + l = add_to_str(&data, l, txt1); + l = add_to_str(&data, l, cast_uchar "</H3>\n<DL>\n"); free(txt); free(txt1); depth++; @@ -777,21 +774,22 @@ save_bookmarks(struct session *ses) txt2 = stracpy(b->url); clr_white(txt2); txt11 = convert_to_entity_string(txt1); - add_to_str(&data, &l, cast_uchar " <DT><A HREF=\""); - add_to_str(&data, &l, txt2); - add_to_str(&data, &l, cast_uchar "\">"); - add_to_str(&data, &l, txt11); - add_to_str(&data, &l, cast_uchar "</A>\n"); + l = add_to_str(&data, l, + cast_uchar " <DT><A HREF=\""); + l = add_to_str(&data, l, txt2); + l = add_to_str(&data, l, cast_uchar "\">"); + l = add_to_str(&data, l, txt11); + l = add_to_str(&data, l, cast_uchar "</A>\n"); free(txt1); free(txt2); free(txt11); } } for (a = 0; a < depth; a++) - add_to_str(&data, &l, cast_uchar "</DL>\n"); - add_to_str(&data, &l, - cast_uchar "</DL><P>\n" - "</HTML>\n"); + l = add_to_str(&data, l, cast_uchar "</DL>\n"); + l = add_to_str(&data, l, + cast_uchar "</DL><P>\n" + "</HTML>\n"); err = write_to_config_file(bookmarks_file, data, 1); free(data); if (!err) diff --git a/cache.c b/cache.c @@ -145,11 +145,11 @@ get_connection_cache_entry(struct connection *c) && c->last_lookup_state.addr.n) { unsigned char *a; unsigned char *s = NULL; - int l = 0; + size_t l = 0; a = print_address(&c->last_lookup_state.addr .a[c->last_lookup_state.addr_index]); if (a) - add_to_str(&s, &l, a); + l = add_to_str(&s, l, a); if (c->last_lookup_state.addr.n > 1) { int i, d = 0; if (l) @@ -162,9 +162,9 @@ get_connection_cache_entry(struct connection *c) &c->last_lookup_state.addr.a[i]); if (a) { if (d) - add_to_str(&s, &l, - cast_uchar ", "); - add_to_str(&s, &l, a); + l = add_to_str(&s, l, + cast_uchar ", "); + l = add_to_str(&s, l, a); d = 1; } } diff --git a/charsets.c b/charsets.c @@ -433,13 +433,13 @@ unicode_upcase_string(unsigned char *ch) { unsigned char *r = NULL; unsigned int c; - int rl = 0; + size_t rl = 0; for (;;) { GET_UTF_8(ch, c); if (!c) break; c = towupper(c); - add_to_str(&r, &rl, encode_utf_8(c)); + rl = add_to_str(&r, rl, encode_utf_8(c)); } return r; } diff --git a/compress.c b/compress.c @@ -409,13 +409,14 @@ free_decompressed_data(struct cache_entry *e) } } -void -add_compress_methods(unsigned char **s, int *l) +size_t +add_compress_methods(unsigned char **s, size_t sl) { - add_to_str(s, l, cast_uchar "ZLIB"); + sl = add_to_str(s, sl, cast_uchar "ZLIB"); #ifdef zlib_version - add_to_str(s, l, cast_uchar " ("); - add_to_str(s, l, (unsigned char *)zlib_version); - *l = add_chr_to_str(s, *l, ')'); + sl = add_to_str(s, sl, cast_uchar " ("); + sl = add_to_str(s, sl, (unsigned char *)zlib_version); + sl = add_chr_to_str(s, sl, ')'); #endif + return sl; } diff --git a/connect.c b/connect.c @@ -273,7 +273,7 @@ handle_socks(void *c_) struct connection *c = (struct connection *)c_; struct conn_info *b = c->newconn; unsigned char *command = NULL; - int len; + size_t len; unsigned char *host; int wr; setcstate(c, S_SOCKS_NEG); @@ -293,8 +293,8 @@ handle_socks(void *c_) abort_connection(c); return; } - add_to_str(&command, &len, host); - add_to_str(&command, &len, c->dns_append); + len = add_to_str(&command, len, host); + len = add_to_str(&command, len, c->dns_append); len = add_chr_to_str(&command, len, 0); free(host); if (b->socks_byte_count >= len) { diff --git a/cookies.c b/cookies.c @@ -193,8 +193,8 @@ cookie_expired(struct cookie *c) return c->expires && c->expires < t; } -void -add_cookies(unsigned char **s, int *l, unsigned char *url) +size_t +add_cookies(unsigned char **s, size_t l, unsigned char *url) { int nc = 0; struct c_domain *cd = NULL; @@ -209,7 +209,7 @@ add_cookies(unsigned char **s, int *l, unsigned char *url) if (is_in_domain(cd->domain, server)) goto ok; free(server); - return; + return l; ok: foreachback (struct cookie, c, lc, all_cookies) if (is_in_domain(c->domain, server)) @@ -224,19 +224,21 @@ ok: && casecmp(url, cast_uchar "https://", 8)) continue; if (!nc) { - add_to_str(s, l, cast_uchar "Cookie: "); + l = add_to_str(s, l, + cast_uchar "Cookie: "); nc = 1; } else - add_to_str(s, l, cast_uchar "; "); - add_to_str(s, l, c->name); + l = add_to_str(s, l, cast_uchar "; "); + l = add_to_str(s, l, c->name); if (c->value) { - *l = add_chr_to_str(s, *l, '='); - add_to_str(s, l, c->value); + l = add_chr_to_str(s, l, '='); + l = add_to_str(s, l, c->value); } } if (nc) - add_to_str(s, l, cast_uchar "\r\n"); + l = add_to_str(s, l, cast_uchar "\r\n"); free(server); + return l; } void diff --git a/data.c b/data.c @@ -35,8 +35,7 @@ void data_func(struct connection *c) { unsigned char *data, *flags, *mime, *str; - size_t length; - int strl; + size_t length, strl; struct cache_entry *e; int r; @@ -100,9 +99,9 @@ bad_url: free(mime); str = NULL; - strl = 0; - add_conv_str(&str, &strl, data, (int)strlen(cast_const_char data), -2); + strl = + add_conv_str(&str, 0, data, (int)strlen(cast_const_char data), -2); if (!base64) { r = add_fragment(e, 0, str, strl); diff --git a/default.c b/default.c @@ -25,12 +25,12 @@ get_system_name(void) EINTRLOOP(rs, uname(&name)); if (!rs) { unsigned char *str = NULL; - int l = 0; - add_to_str(&str, &l, cast_uchar name.sysname); + size_t l; + l = add_to_str(&str, 0, cast_uchar name.sysname); l = add_chr_to_str(&str, l, ' '); - add_to_str(&str, &l, cast_uchar name.release); + l = add_to_str(&str, l, cast_uchar name.release); l = add_chr_to_str(&str, l, ' '); - add_to_str(&str, &l, cast_uchar name.machine); + l = add_to_str(&str, l, cast_uchar name.machine); safe_strncpy(system_name, str, MAX_STR_LEN); free(str); return; @@ -43,7 +43,7 @@ struct option { int p; unsigned char *(*rd_cmd)(struct option *, unsigned char ***, int *); unsigned char *(*rd_cfg)(struct option *, unsigned char *); - void (*wr_cfg)(struct option *, unsigned char **, int *); + size_t (*wr_cfg)(struct option *, unsigned char **, size_t); int min, max; /* for double min and max are in 1/100's (e.g. 0.1 is min==10) */ void *ptr; @@ -210,16 +210,17 @@ static unsigned char * create_config_string(struct option *options) { unsigned char *s = NULL; - int l = 0; + size_t l; int i; - add_to_str(&s, &l, - cast_uchar "# This file is automatically generated by Links " - "-- please do not edit."); + l = add_to_str(&s, 0, + cast_uchar + "# This file is automatically generated by Links " + "-- please do not edit."); for (i = 0; options[i].p; i++) { if (options[i].wr_cfg) - options[i].wr_cfg(&options[i], &s, &l); + l = options[i].wr_cfg(&options[i], &s, l); } - add_to_str(&s, &l, cast_uchar "\n"); + l = add_to_str(&s, l, cast_uchar "\n"); return s; } @@ -257,13 +258,12 @@ write_to_config_file(unsigned char *name, unsigned char *c, int do_sync) int rr; int h, w; int count = 0; - int tmp_namel; + size_t tmp_namel; unsigned char *tmp_name; int rs, err; try_new_count: - tmp_namel = 0; tmp_name = NULL; - add_to_str(&tmp_name, &tmp_namel, name); + tmp_namel = add_to_str(&tmp_name, 0, name); for (w = tmp_namel - 1; w >= 0; w--) { if (dir_sep(tmp_name[w])) break; @@ -275,7 +275,7 @@ try_new_count: break; } } - add_num_to_str(&tmp_name, &tmp_namel, count); + tmp_namel = add_num_to_str(&tmp_name, tmp_namel, count); h = c_open3(tmp_name, O_WRONLY | O_NOCTTY | O_CREAT | O_TRUNC | O_EXCL, 0600); if (h == -1) { @@ -506,13 +506,13 @@ write_config_data(unsigned char *prefix, unsigned char *name, struct option *o, return 0; } -static void -add_nm(struct option *o, unsigned char **s, int *l) +static size_t +add_nm(struct option *o, unsigned char **s, size_t l) { - if (*l) - add_to_str(s, l, cast_uchar "\n"); - add_to_str(s, l, cast_uchar o->cfg_name); - *l = add_chr_to_str(s, *l, ' '); + if (l) + l = add_to_str(s, l, cast_uchar "\n"); + l = add_to_str(s, l, cast_uchar o->cfg_name); + return add_chr_to_str(s, l, ' '); } static size_t @@ -550,11 +550,11 @@ num_rd(struct option *o, unsigned char *c) return NULL; } -static void -num_wr(struct option *o, unsigned char **s, int *l) +static size_t +num_wr(struct option *o, unsigned char **s, size_t l) { - add_nm(o, s, l); - add_knum_to_str(s, l, *(int *)o->ptr); + l = add_nm(o, s, l); + return add_knum_to_str(s, l, *(int *)o->ptr); } static unsigned char * @@ -587,14 +587,14 @@ dbl_rd(struct option *o, unsigned char *c) return NULL; } -static void -dbl_wr(struct option *o, unsigned char **s, int *l) +static size_t +dbl_wr(struct option *o, unsigned char **s, size_t l) { unsigned char number[80]; snprintf(cast_char number, sizeof number, "%.6f", *(double *)o->ptr); - add_nm(o, s, l); - add_to_str(s, l, number); + l = add_nm(o, s, l); + return add_to_str(s, l, number); } static unsigned char * @@ -612,17 +612,19 @@ str_rd(struct option *o, unsigned char *c) return e; } -static void -str_wr(struct option *o, unsigned char **s, int *l) +static size_t +str_wr(struct option *o, unsigned char **s, size_t l) { - add_nm(o, s, l); + l = add_nm(o, s, l); if (strlen(cast_const_char o->ptr) + 1 > (size_t)o->max) { unsigned char *s1 = NULL; add_bytes_to_str(&s1, 0, o->ptr, o->max - 1); - *l = add_quoted_to_str(s, *l, s1); + l = add_quoted_to_str(s, l, s1); free(s1); } else - *l = add_quoted_to_str(s, *l, o->ptr); + l = add_quoted_to_str(s, l, o->ptr); + + return l; } static unsigned char * @@ -636,12 +638,12 @@ cp_rd(struct option *o, unsigned char *c) return NULL; } -static void -cp_wr(struct option *o, unsigned char **s, int *l) +static size_t +cp_wr(struct option *o, unsigned char **s, size_t l) { unsigned char *n = get_cp_mime_name(0); - add_nm(o, s, l); - add_to_str(s, l, n); + l = add_nm(o, s, l); + return add_to_str(s, l, n); } static int @@ -703,28 +705,29 @@ err_f: goto err; } -static void -type_wr(struct option *o, unsigned char **s, int *l) +static size_t +type_wr(struct option *o, unsigned char **s, size_t l) { struct list *a = NULL; struct list_head *la; foreachback (struct list, a, la, assoc.list_entry) { struct assoc *as = get_struct(a, struct assoc, head); - add_nm(o, s, l); - *l = add_quoted_to_str(s, *l, as->label); - *l = add_chr_to_str(s, *l, ' '); - *l = add_quoted_to_str(s, *l, as->ct); - add_to_str(s, l, cast_uchar " "); - *l = add_quoted_to_str(s, *l, as->prog); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, - (!!as->cons) + (!!as->xwin) * 2 + (!!as->ask) * 4 - + (!as->block) * 8 + (!!as->block) * 16 - + (!!as->accept_http) * 32 - + (!!as->accept_ftp) * 64); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, as->system); + l = add_nm(o, s, l); + l = add_quoted_to_str(s, l, as->label); + l = add_chr_to_str(s, l, ' '); + l = add_quoted_to_str(s, l, as->ct); + l = add_to_str(s, l, cast_uchar " "); + l = add_quoted_to_str(s, l, as->prog); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str( + s, l, + (!!as->cons) + (!!as->xwin) * 2 + (!!as->ask) * 4 + + (!as->block) * 8 + (!!as->block) * 16 + + (!!as->accept_http) * 32 + (!!as->accept_ftp) * 64); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, as->system); } + return l; } static unsigned char * @@ -745,18 +748,19 @@ err: return err; } -static void -ext_wr(struct option *o, unsigned char **s, int *l) +static size_t +ext_wr(struct option *o, unsigned char **s, size_t l) { struct list *a = NULL; struct list_head *la; foreachback (struct list, a, la, extensions.list_entry) { struct extension *e = get_struct(a, struct extension, head); - add_nm(o, s, l); - *l = add_quoted_to_str(s, *l, e->ext); - *l = add_chr_to_str(s, *l, ' '); - *l = add_quoted_to_str(s, *l, e->ct); + l = add_nm(o, s, l); + l = add_quoted_to_str(s, l, e->ext); + l = add_chr_to_str(s, l, ' '); + l = add_quoted_to_str(s, l, e->ct); } + return l; } static unsigned char * @@ -847,36 +851,37 @@ err: return cast_uchar "Error reading terminal specification"; } -static void -term_wr(struct option *o, unsigned char **s, int *l) +static size_t +term_wr(struct option *o, unsigned char **s, size_t l) { struct term_spec *ts = NULL; struct list_head *lts; foreachback (struct term_spec, ts, lts, term_specs) { - add_nm(o, s, l); - *l = add_quoted_to_str(s, *l, ts->term); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, ts->mode); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, !!ts->m11_hack); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, - !!ts->col + !!ts->restrict_852 * 2 - + !!ts->block_cursor * 4); - *l = add_chr_to_str(s, *l, ' '); - add_to_str(s, l, get_cp_mime_name(ts->character_set)); + l = add_nm(o, s, l); + l = add_quoted_to_str(s, l, ts->term); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, ts->mode); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, !!ts->m11_hack); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, + !!ts->col + !!ts->restrict_852 * 2 + + !!ts->block_cursor * 4); + l = add_chr_to_str(s, l, ' '); + l = add_to_str(s, l, get_cp_mime_name(ts->character_set)); if (ts->left_margin || ts->right_margin || ts->top_margin || ts->bottom_margin) { - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, ts->left_margin); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, ts->right_margin); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, ts->top_margin); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, ts->bottom_margin); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, ts->left_margin); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, ts->right_margin); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, ts->top_margin); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, ts->bottom_margin); } } + return l; } static struct list_head driver_params = { &driver_params, &driver_params }; @@ -934,8 +939,8 @@ err: return cast_uchar "Error reading driver mode specification"; } -static void -dp_wr(struct option *o, unsigned char **s, int *l) +static size_t +dp_wr(struct option *o, unsigned char **s, size_t l) { struct driver_param *dp = NULL; struct list_head *ldp; @@ -945,22 +950,24 @@ dp_wr(struct option *o, unsigned char **s, int *l) continue; if (dp->nosave) continue; - add_nm(o, s, l); - *l = add_quoted_to_str(s, *l, dp->name); - *l = add_chr_to_str(s, *l, ' '); - *l = add_quoted_to_str( - s, *l, dp->param ? dp->param : (unsigned char *)""); - *l = add_chr_to_str(s, *l, ' '); - *l = add_quoted_to_str(s, *l, dp->shell_term); - *l = add_chr_to_str(s, *l, ' '); + l = add_nm(o, s, l); + l = add_quoted_to_str(s, l, dp->name); + l = add_chr_to_str(s, l, ' '); + l = add_quoted_to_str( + s, l, dp->param ? dp->param : (unsigned char *)""); + l = add_chr_to_str(s, l, ' '); + l = add_quoted_to_str(s, l, dp->shell_term); + l = add_chr_to_str(s, l, ' '); if (dp->kbd_codepage == -1) - add_to_str(s, l, cast_uchar "default"); + l = add_to_str(s, l, cast_uchar "default"); else - add_to_str(s, l, get_cp_mime_name(dp->kbd_codepage)); - *l = add_chr_to_str(s, *l, ' '); - add_num_to_str(s, l, dp->palette_mode); + l = add_to_str(s, l, + get_cp_mime_name(dp->kbd_codepage)); + l = add_chr_to_str(s, l, ' '); + l = add_num_to_str(s, l, dp->palette_mode); /* pokud se sem neco prida, opravit podminku na zacatku cyklu */ } + return l; } static unsigned char * @@ -1480,8 +1487,8 @@ save_url_history(void) struct history_item *hi = NULL; struct list_head *lhi; unsigned char *history_file; - unsigned char *hs; - int hsl = 0; + unsigned char *hs = NULL; + size_t hsl = 0; if (anonymous || !save_history || proxies.only_proxies) return; @@ -1490,16 +1497,14 @@ save_url_history(void) return; history_file = stracpy(links_home); add_to_strn(&history_file, cast_uchar "links.his"); - hs = NULL; - hsl = 0; foreachback (struct history_item, hi, lhi, goto_url_history.items) { if (!*hi->str || hi->str[0] == ' ' || strchr(cast_const_char hi->str, 10) || strchr(cast_const_char hi->str, 13)) continue; if (!url_not_saveable(hi->str)) { - add_to_str(&hs, &hsl, hi->str); - add_to_str(&hs, &hsl, cast_uchar "\n"); + hsl = add_to_str(&hs, hsl, hi->str); + hsl = add_to_str(&hs, hsl, cast_uchar "\n"); } } write_to_config_file(history_file, hs, 0); diff --git a/file.c b/file.c @@ -45,8 +45,8 @@ setst(unsigned m, unsigned char *p) #endif } -static void -stat_mode(unsigned char **p, int *l, struct stat *stp) +static size_t +stat_mode(unsigned char **p, size_t l, struct stat *stp) { unsigned char c = '?'; unsigned char rwx[10] = "---------"; @@ -82,7 +82,7 @@ stat_mode(unsigned char **p, int *l, struct stat *stp) c = 'n'; #endif } - *l = add_chr_to_str(p, *l, c); + l = add_chr_to_str(p, l, c); if (stp) { unsigned mode = stp->st_mode; setrwx(mode << 0, &rwx[0]); @@ -90,20 +90,19 @@ stat_mode(unsigned char **p, int *l, struct stat *stp) setrwx(mode << 6, &rwx[6]); setst(mode, rwx); } - add_to_str(p, l, rwx); - *l = add_chr_to_str(p, *l, ' '); + l = add_to_str(p, l, rwx); + return add_chr_to_str(p, l, ' '); } -static void -stat_links(unsigned char **p, int *l, struct stat *stp) +static size_t +stat_links(unsigned char **p, size_t l, struct stat *stp) { unsigned char lnk[64]; if (!stp) - add_to_str(p, l, cast_uchar " "); - else { - sprintf(cast_char lnk, "%3ld ", (unsigned long)stp->st_nlink); - add_to_str(p, l, lnk); - } + return add_to_str(p, l, cast_uchar " "); + + sprintf(cast_char lnk, "%3ld ", (unsigned long)stp->st_nlink); + return add_to_str(p, l, lnk); } static int last_uid = -1; @@ -112,18 +111,16 @@ static unsigned char last_user[64]; static int last_gid = -1; static unsigned char last_group[64]; -static void -stat_user(unsigned char **p, int *l, struct stat *stp, int g) +static size_t +stat_user(unsigned char **p, size_t l, struct stat *stp, int g) { struct passwd *pwd; struct group *grp; int id; unsigned char *pp; size_t i; - if (!stp) { - add_to_str(p, l, cast_uchar " "); - return; - } + if (!stp) + return add_to_str(p, l, cast_uchar " "); id = !g ? stp->st_uid : stp->st_gid; pp = !g ? last_user : last_group; if (!g && id == last_uid && last_uid != -1) @@ -146,14 +143,14 @@ stat_user(unsigned char **p, int *l, struct stat *stp, int g) last_gid = id; } a: - add_to_str(p, l, pp); + l = add_to_str(p, l, pp); for (i = strlen(cast_const_char pp); i < 8; i++) - *l = add_chr_to_str(p, *l, ' '); - *l = add_chr_to_str(p, *l, ' '); + l = add_chr_to_str(p, l, ' '); + return add_chr_to_str(p, l, ' '); } -static void -stat_size(unsigned char **p, int *l, struct stat *stp) +static size_t +stat_size(unsigned char **p, size_t l, struct stat *stp) { unsigned char num[64]; const int digits = 8; @@ -163,13 +160,13 @@ stat_size(unsigned char **p, int *l, struct stat *stp) else snzprint(num, sizeof num, stp->st_size); for (i = strlen(cast_const_char num); i < digits; i++) - *l = add_chr_to_str(p, *l, ' '); - add_to_str(p, l, num); - *l = add_chr_to_str(p, *l, ' '); + l = add_chr_to_str(p, l, ' '); + l = add_to_str(p, l, num); + return add_chr_to_str(p, l, ' '); } -static void -stat_date(unsigned char **p, int *l, struct stat *stp) +static size_t +stat_date(unsigned char **p, size_t l, struct stat *stp) { time_t current_time; time_t when; @@ -203,20 +200,18 @@ set_empty: while (wr < 12) str[wr++] = ' '; str[12] = 0; - add_to_str(p, l, str); - *l = add_chr_to_str(p, *l, ' '); + l = add_to_str(p, l, str); + return add_chr_to_str(p, l, ' '); } static unsigned char * get_filename(unsigned char *url) { unsigned char *p, *m; - int ml; for (p = url + 7; *p && *p != POST_CHAR; p++) ; m = NULL; - ml = 0; - add_conv_str(&m, &ml, url + 7, (int)(p - url - 7), -2); + add_conv_str(&m, 0, url + 7, (int)(p - url - 7), -2); return m; } @@ -326,19 +321,19 @@ dir: last_uid = -1; last_gid = -1; file = NULL; - fl = 0; - add_to_str(&file, &fl, cast_uchar "<html><head><title>"); + fl = add_to_str(&file, fl, cast_uchar "<html><head><title>"); flo = fl; - add_conv_str(&file, &fl, name, - (int)strlen(cast_const_char name), -1); + fl = add_conv_str(&file, fl, name, + (int)strlen(cast_const_char name), -1); convert_file_charset(&file, &fl, flo); - add_to_str(&file, &fl, - cast_uchar "</title></head><body><h2>Directory "); + fl = add_to_str(&file, fl, + cast_uchar + "</title></head><body><h2>Directory "); flo = fl; - add_conv_str(&file, &fl, name, - (int)strlen(cast_const_char name), -1); + fl = add_conv_str(&file, fl, name, + (int)strlen(cast_const_char name), -1); convert_file_charset(&file, &fl, flo); - add_to_str(&file, &fl, cast_uchar "</h2>\n<pre>"); + fl = add_to_str(&file, fl, cast_uchar "</h2>\n<pre>"); while (1) { struct stat stt, *stp; unsigned char **p; @@ -370,12 +365,12 @@ dir: else stp = &stt; free(n); - stat_mode(p, &l, stp); - stat_links(p, &l, stp); - stat_user(p, &l, stp, 0); - stat_user(p, &l, stp, 1); - stat_size(p, &l, stp); - stat_date(p, &l, stp); + l = stat_mode(p, l, stp); + l = stat_links(p, l, stp); + l = stat_user(p, l, stp, 0); + l = stat_user(p, l, stp, 1); + l = stat_size(p, l, stp); + l = stat_date(p, l, stp); } closedir(d); if (dirl) @@ -407,10 +402,11 @@ yyy: xxx: free(n); } - add_to_str(&file, &fl, dir[i].s); - add_to_str(&file, &fl, cast_uchar "<a href=\"./"); - add_conv_str(&file, &fl, dir[i].f, - (int)strlen(cast_const_char dir[i].f), 1); + fl = add_to_str(&file, fl, dir[i].s); + fl = add_to_str(&file, fl, cast_uchar "<a href=\"./"); + fl = add_conv_str(&file, fl, dir[i].f, + (int)strlen(cast_const_char dir[i].f), + 1); if (dir[i].s[0] == 'd') fl = add_chr_to_str(&file, fl, '/'); else if (lnk) { @@ -422,18 +418,19 @@ xxx: fl = add_chr_to_str(&file, fl, '/'); free(n); } - add_to_str(&file, &fl, cast_uchar "\">"); + fl = add_to_str(&file, fl, cast_uchar "\">"); flo = fl; - add_conv_str(&file, &fl, dir[i].f, - (int)strlen(cast_const_char dir[i].f), 0); + fl = add_conv_str(&file, fl, dir[i].f, + (int)strlen(cast_const_char dir[i].f), + 0); convert_file_charset(&file, &fl, flo); - add_to_str(&file, &fl, cast_uchar "</a>"); + fl = add_to_str(&file, fl, cast_uchar "</a>"); if (lnk) { - add_to_str(&file, &fl, cast_uchar " -> "); - add_to_str(&file, &fl, cast_uchar lnk); + fl = add_to_str(&file, fl, cast_uchar " -> "); + fl = add_to_str(&file, fl, cast_uchar lnk); free(lnk); } - add_to_str(&file, &fl, cast_uchar "\n"); + fl = add_to_str(&file, fl, cast_uchar "\n"); } free(name); for (i = 0; i < dirl; i++) { @@ -441,7 +438,7 @@ xxx: free(dir[i].f); } free(dir); - add_to_str(&file, &fl, cast_uchar "</pre></body></html>\n"); + fl = add_to_str(&file, fl, cast_uchar "</pre></body></html>\n"); head = stracpy(cast_uchar "\r\nContent-Type: text/html\r\n"); } else { free(name); diff --git a/html.c b/html.c @@ -269,7 +269,7 @@ need_convert: c = NULL; l = 0; for (p = a; *p; p++) - add_to_str(&c, &l, encode_utf_8(*p)); + l = add_to_str(&c, l, encode_utf_8(*p)); free(a); return c; } @@ -2431,7 +2431,7 @@ abort: l--; q = convert_string(ct, s, l, d_opt); if (q) { - add_to_str(&lbl, &lbl_l, q); + lbl_l = add_to_str(&lbl, lbl_l, q); free(q); } vlbl_l = add_bytes_to_str(&vlbl, vlbl_l, s, l); @@ -3662,11 +3662,11 @@ get_image_map(unsigned char *head, unsigned char *s, unsigned char *eof, int nmenu = 0; int i; unsigned char *hd = NULL; - int hdl = 0; + size_t hdl = 0; struct conv_table *ct; if (head) - add_to_str(&hd, &hdl, head); - scan_http_equiv(s, eof, &hd, &hdl, NULL, NULL, NULL, NULL); + hdl = add_to_str(&hd, hdl, head); + hdl = scan_http_equiv(s, eof, &hd, hdl, NULL, NULL, NULL, NULL); if (!gfx) ct = get_convert_table(hd, to, def, NULL, NULL, hdef); else @@ -3874,9 +3874,9 @@ done: return 0; } -void +size_t scan_http_equiv(unsigned char *s, unsigned char *eof, unsigned char **head, - int *hdl, unsigned char **title, unsigned char **background, + size_t hdl, unsigned char **title, unsigned char **background, unsigned char **bgcolor, int *pre_wrap) { unsigned char *name, *attr, *he, *c; @@ -3890,13 +3890,13 @@ scan_http_equiv(unsigned char *s, unsigned char *eof, unsigned char **head, *pre_wrap = 0; if (title) *title = NULL; - *hdl = add_chr_to_str(head, *hdl, '\n'); + hdl = add_chr_to_str(head, hdl, '\n'); se: while (s < eof && *s != '<') sp: s++; if (s >= eof) - return; + return hdl; if (eof - s >= 2 && (s[1] == '!' || s[1] == '?')) { s = skip_comment(s, eof); goto se; @@ -3958,21 +3958,21 @@ xsp: if (namelen != 4 || casecmp(name, cast_uchar "META", 4)) goto se; if ((he = get_attr_val(attr, cast_uchar "charset"))) { - add_to_str(head, hdl, cast_uchar "Charset: "); - add_to_str(head, hdl, he); - add_to_str(head, hdl, cast_uchar "\r\n"); + hdl = add_to_str(head, hdl, cast_uchar "Charset: "); + hdl = add_to_str(head, hdl, he); + hdl = add_to_str(head, hdl, cast_uchar "\r\n"); free(he); } if (!(he = get_attr_val(attr, cast_uchar "http-equiv"))) goto se; c = get_attr_val(attr, cast_uchar "content"); - add_to_str(head, hdl, he); + hdl = add_to_str(head, hdl, he); if (c) { - add_to_str(head, hdl, cast_uchar ": "); - add_to_str(head, hdl, c); + hdl = add_to_str(head, hdl, cast_uchar ": "); + hdl = add_to_str(head, hdl, c); free(c); } free(he); - add_to_str(head, hdl, cast_uchar "\r\n"); + hdl = add_to_str(head, hdl, cast_uchar "\r\n"); goto se; } diff --git a/html_r.c b/html_r.c @@ -630,12 +630,10 @@ html_tag(struct f_data *f, unsigned char *t, int x, int y) struct tag *tag; size_t sl; unsigned char *tt; - int ll; if (!f) return; tt = NULL; - ll = 0; - add_conv_str(&tt, &ll, t, (int)strlen(cast_const_char t), -2); + add_conv_str(&tt, 0, t, (int)strlen(cast_const_char t), -2); sl = strlen(cast_const_char tt); if (sl > INT_MAX - sizeof(struct tag)) overalloc(); @@ -1387,7 +1385,7 @@ really_format_html(struct cache_entry *ce, unsigned char *start, { unsigned char *url = ce->url; unsigned char *head, *t; - int hdl; + size_t hdl; int i; unsigned char *bg = NULL, *bgcolor = NULL; int implicit_pre_wrap; @@ -1402,10 +1400,11 @@ really_format_html(struct cache_entry *ce, unsigned char *start, head = NULL; hdl = 0; if (ce->head) - add_to_str(&head, &hdl, ce->head); - scan_http_equiv(start, end, &head, &hdl, &t, d_opt->plain ? NULL : &bg, - d_opt->plain || d_opt->col < 2 ? NULL : &bgcolor, - &implicit_pre_wrap); + hdl = add_to_str(&head, hdl, ce->head); + hdl = scan_http_equiv(start, end, &head, hdl, &t, + d_opt->plain ? NULL : &bg, + d_opt->plain || d_opt->col < 2 ? NULL : &bgcolor, + &implicit_pre_wrap); if (d_opt->break_long_lines) implicit_pre_wrap = 1; if (d_opt->plain) diff --git a/http.c b/http.c @@ -25,26 +25,24 @@ struct http_connection_info { static void http_send_header(struct connection *c); static void http_get_header(struct connection *c); static void test_restart(struct connection *c); -static void add_user_agent(unsigned char **hdr, int *l, const char *url); -static void add_referer(unsigned char **hdr, int *l, unsigned char *url, - unsigned char *prev_url); -static void add_accept(unsigned char **hdr, int *l); -static void add_accept_encoding(unsigned char **hdr, int *l, unsigned char *url, - struct connection *c); -static void add_accept_charset(unsigned char **hdr, int *l, - struct http_connection_info *info); -static void add_connection(unsigned char **hdr, int *l, int http10, int proxy, - int post); -static void add_upgrade(unsigned char **hdr, int *l); -static void add_if_modified(unsigned char **hdr, int *l, struct connection *c); -static void add_range(unsigned char **hdr, int *l, unsigned char *url, - struct connection *c); -static void add_pragma_no_cache(unsigned char **hdr, int *l, int no_cache); -static void add_proxy_auth_string(unsigned char **hdr, int *l, - unsigned char *url); -static void add_auth_string(unsigned char **hdr, int *l, unsigned char *url); -static void add_post_header(unsigned char **hdr, int *l, unsigned char **post); -static void add_extra_options(unsigned char **hdr, int *l); +static size_t add_user_agent(unsigned char **, size_t, const char *); +static size_t add_referer(unsigned char **, size_t, unsigned char *, + unsigned char *); +static size_t add_accept(unsigned char **, size_t); +static size_t add_accept_encoding(unsigned char **, size_t, unsigned char *, + struct connection *); +static size_t add_accept_charset(unsigned char **, size_t, + struct http_connection_info *); +static size_t add_connection(unsigned char **, size_t, int, int, int); +static size_t add_upgrade(unsigned char **, size_t); +static size_t add_if_modified(unsigned char **, size_t, struct connection *); +static size_t add_range(unsigned char **, size_t, unsigned char *, + struct connection *); +static size_t add_pragma_no_cache(unsigned char **, size_t, int); +static size_t add_proxy_auth_string(unsigned char **, size_t, unsigned char *); +static size_t add_auth_string(unsigned char **, size_t, unsigned char *); +static size_t add_post_header(unsigned char **, size_t, unsigned char **); +static size_t add_extra_options(unsigned char **, size_t); /* Returns a string pointer with value of the item. * The string must be destroyed after usage with mem_free. @@ -223,18 +221,19 @@ proxy_func(struct connection *c) http_func(c); } -static void -add_url_to_str(unsigned char **str, int *l, unsigned char *url) +static size_t +add_url_to_str(unsigned char **str, size_t l, unsigned char *url) { unsigned char *sp; for (sp = url; *sp && *sp != POST_CHAR; sp++) { if (*sp <= ' ' || *sp >= 127) { unsigned char esc[4]; sprintf((char *)esc, "%%%02X", (int)*sp); - add_to_str(str, l, esc); + l = add_to_str(str, l, esc); } else - *l = add_chr_to_str(str, *l, *sp); + l = add_chr_to_str(str, l, *sp); } + return l; } static void @@ -246,7 +245,7 @@ http_send_header(struct connection *c) unsigned char *hdr; unsigned char *h, *u; unsigned char *u2; - int l = 0; + size_t l = 0; unsigned char *post = NULL; unsigned char *host; @@ -284,23 +283,23 @@ http_bad_url: } info->send_close = info->https_forward || http10; if (info->https_forward) { - add_to_str(&hdr, &l, cast_uchar "CONNECT "); + l = add_to_str(&hdr, l, cast_uchar "CONNECT "); h = get_host_name(host); if (!h) goto http_bad_url; - add_to_str(&hdr, &l, h); + l = add_to_str(&hdr, l, h); free(h); h = get_port_str(host); if (!h) h = stracpy(cast_uchar "443"); l = add_chr_to_str(&hdr, l, ':'); - add_to_str(&hdr, &l, h); + l = add_to_str(&hdr, l, h); free(h); goto added_connect; } else if (!post) - add_to_str(&hdr, &l, cast_uchar "GET "); + l = add_to_str(&hdr, l, cast_uchar "GET "); else { - add_to_str(&hdr, &l, cast_uchar "POST "); + l = add_to_str(&hdr, l, cast_uchar "POST "); c->unrestartable = 2; } if (!proxy) { @@ -323,19 +322,19 @@ http_bad_url: u2 = NULL; u2_len = add_bytes_to_str(&u2, u2_len, u, u_host + u_host_len - u); - add_to_str(&u2, &u2_len, proxies.dns_append); - add_to_str(&u2, &u2_len, u_host + u_host_len); + u2_len = add_to_str(&u2, u2_len, proxies.dns_append); + u2_len = add_to_str(&u2, u2_len, u_host + u_host_len); } - add_url_to_str(&hdr, &l, u2); + l = add_url_to_str(&hdr, l, u2); if (u2 != u) free(u2); added_connect: if (!http10) - add_to_str(&hdr, &l, cast_uchar " HTTP/1.1\r\n"); + l = add_to_str(&hdr, l, cast_uchar " HTTP/1.1\r\n"); else - add_to_str(&hdr, &l, cast_uchar " HTTP/1.0\r\n"); + l = add_to_str(&hdr, l, cast_uchar " HTTP/1.0\r\n"); if (!info->https_forward && (h = get_host_name(host))) { - add_to_str(&hdr, &l, cast_uchar "Host: "); + l = add_to_str(&hdr, l, cast_uchar "Host: "); if (*h && h[strlen((char *)h) - 1] == '.') { h[strlen((char *)h) - 1] = 0; } @@ -346,37 +345,38 @@ added_connect: pc[1] = 0; } } - add_to_str(&hdr, &l, h); + l = add_to_str(&hdr, l, h); free(h); if ((h = get_port_str(host))) { if (strcmp(cast_char h, c->ssl ? "443" : "80")) { l = add_chr_to_str(&hdr, l, ':'); - add_to_str(&hdr, &l, h); + l = add_to_str(&hdr, l, h); } free(h); } - add_to_str(&hdr, &l, cast_uchar "\r\n"); + l = add_to_str(&hdr, l, cast_uchar "\r\n"); } - add_user_agent(&hdr, &l, info->https_forward ? NULL : cast_char host); + l = add_user_agent(&hdr, l, + info->https_forward ? NULL : cast_char host); if (proxy) - add_proxy_auth_string(&hdr, &l, c->url); + l = add_proxy_auth_string(&hdr, l, c->url); if (!info->https_forward) { test_restart(c); - add_referer(&hdr, &l, host, c->prev_url); - add_accept(&hdr, &l); - add_accept_encoding(&hdr, &l, host, c); - add_accept_charset(&hdr, &l, info); - add_connection(&hdr, &l, http10, proxy, !info->send_close); - add_upgrade(&hdr, &l); - add_if_modified(&hdr, &l, c); - add_range(&hdr, &l, host, c); - add_pragma_no_cache(&hdr, &l, c->no_cache); - add_auth_string(&hdr, &l, host); - add_post_header(&hdr, &l, &post); - add_cookies(&hdr, &l, host); - add_extra_options(&hdr, &l); + l = add_referer(&hdr, l, host, c->prev_url); + l = add_accept(&hdr, l); + l = add_accept_encoding(&hdr, l, host, c); + l = add_accept_charset(&hdr, l, info); + l = add_connection(&hdr, l, http10, proxy, !info->send_close); + l = add_upgrade(&hdr, l); + l = add_if_modified(&hdr, l, c); + l = add_range(&hdr, l, host, c); + l = add_pragma_no_cache(&hdr, l, c->no_cache); + l = add_auth_string(&hdr, l, host); + l = add_post_header(&hdr, l, &post); + l = add_cookies(&hdr, l, host); + l = add_extra_options(&hdr, l); } - add_to_str(&hdr, &l, cast_uchar "\r\n"); + l = add_to_str(&hdr, l, cast_uchar "\r\n"); if (post) { while (post[0] && post[1]) { int h1, h2; @@ -424,14 +424,15 @@ test_restart(struct connection *c) } } -static void -add_user_agent(unsigned char **hdr, int *l, const char *url) +static size_t +add_user_agent(unsigned char **hdr, size_t l, const char *url) { - add_to_str(hdr, l, cast_uchar "User-Agent: "); + l = add_to_str(hdr, l, cast_uchar "User-Agent: "); if (SCRUB_HEADERS) - add_to_str(hdr, l, - cast_uchar "Mozilla/5.0 (Windows NT 6.1; rv:60.0) " - "Gecko/20100101 Firefox/60.0\r\n"); + l = add_to_str(hdr, l, + cast_uchar + "Mozilla/5.0 (Windows NT 6.1; rv:60.0) " + "Gecko/20100101 Firefox/60.0\r\n"); else if (!(*http_options.header.fake_useragent)) { /* * Google started to return css-styled page for searches. @@ -443,44 +444,44 @@ add_user_agent(unsigned char **hdr, int *l, const char *url) && strstr(url, "/search?") && (strstr(url, "?q=") || strstr(url, "&q=")) && !strstr(url, "?tbm=isch") && !strstr(url, "&tbm=isch")) - add_to_str(hdr, l, cast_uchar("Lynx/")); + l = add_to_str(hdr, l, cast_uchar("Lynx/")); - add_to_str(hdr, l, cast_uchar("Links (" VERSION "; ")); - add_to_str(hdr, l, system_name); - add_to_str(hdr, l, cast_uchar "; "); + l = add_to_str(hdr, l, cast_uchar("Links (" VERSION "; ")); + l = add_to_str(hdr, l, system_name); + l = add_to_str(hdr, l, cast_uchar "; "); if (!list_empty(terminals)) { unsigned char *t = cast_uchar "text"; - add_to_str(hdr, l, t); + l = add_to_str(hdr, l, t); } else { - add_to_str(hdr, l, cast_uchar "dump"); + l = add_to_str(hdr, l, cast_uchar "dump"); } - add_to_str(hdr, l, cast_uchar ")\r\n"); + l = add_to_str(hdr, l, cast_uchar ")\r\n"); } else { - add_to_str(hdr, l, http_options.header.fake_useragent); - add_to_str(hdr, l, cast_uchar "\r\n"); + l = add_to_str(hdr, l, http_options.header.fake_useragent); + l = add_to_str(hdr, l, cast_uchar "\r\n"); } + return l; } -static void -add_referer(unsigned char **hdr, int *l, unsigned char *url, +static size_t +add_referer(unsigned char **hdr, size_t l, unsigned char *url, unsigned char *prev_url) { - add_to_str(hdr, l, cast_uchar "Referer: "); - add_url_to_str(hdr, l, url); - add_to_str(hdr, l, cast_uchar "\r\n"); + l = add_to_str(hdr, l, cast_uchar "Referer: "); + l = add_url_to_str(hdr, l, url); + return add_to_str(hdr, l, cast_uchar "\r\n"); } -static void -add_accept(unsigned char **hdr, int *l) +static size_t +add_accept(unsigned char **hdr, size_t l) { if (SCRUB_HEADERS) - add_to_str(hdr, l, - cast_uchar - "Accept: " - "text/html,application/xhtml+xml,application/" - "xml;q=0.9,*/*;q=0.8\r\n"); - else - add_to_str(hdr, l, cast_uchar "Accept: */*\r\n"); + return add_to_str(hdr, l, + cast_uchar + "Accept: " + "text/html,application/xhtml+xml,application/" + "xml;q=0.9,*/*;q=0.8\r\n"); + return add_to_str(hdr, l, cast_uchar "Accept: */*\r\n"); } static int @@ -503,88 +504,91 @@ advertise_compression(unsigned char *url, struct connection *c) return 1; } -static void -add_accept_encoding(unsigned char **hdr, int *l, unsigned char *url, +static size_t +add_accept_encoding(unsigned char **hdr, size_t l, unsigned char *url, struct connection *c) { if (advertise_compression(url, c)) { - int orig_l = *l; - int l1; - add_to_str(hdr, l, cast_uchar "Accept-Encoding: "); - l1 = *l; - if (*l != l1) - add_to_str(hdr, l, cast_uchar ", "); - add_to_str(hdr, l, cast_uchar "gzip, deflate"); - if (*l != l1) - add_to_str(hdr, l, cast_uchar "\r\n"); + size_t orig_l = l; + size_t l1; + l = add_to_str(hdr, l, cast_uchar "Accept-Encoding: "); + l1 = l; + l = add_to_str(hdr, l, cast_uchar "gzip, deflate"); + if (l != l1) + l = add_to_str(hdr, l, cast_uchar "\r\n"); else - *l = orig_l; + l = orig_l; } + + return l; } -static void -add_accept_charset(unsigned char **hdr, int *l, +static size_t +add_accept_charset(unsigned char **hdr, size_t l, struct http_connection_info *info) { static unsigned char *accept_charset = NULL; if (SCRUB_HEADERS || info->bl_flags & BL_NO_CHARSET || http_options.no_accept_charset) - return; + return l; if (!accept_charset) { unsigned char *cs, *ac; - int aclen = 0; + size_t aclen = 0; ac = NULL; cs = get_cp_mime_name(0); if (aclen) aclen = add_chr_to_str(&ac, aclen, ','); else - add_to_str(&ac, &aclen, cast_uchar "Accept-Charset: "); - add_to_str(&ac, &aclen, cs); + aclen = add_to_str(&ac, aclen, + cast_uchar "Accept-Charset: "); + aclen = add_to_str(&ac, aclen, cs); if (aclen) - add_to_str(&ac, &aclen, cast_uchar "\r\n"); + aclen = add_to_str(&ac, aclen, cast_uchar "\r\n"); if (!(accept_charset = cast_uchar strdup((char *)ac))) { - add_to_str(hdr, l, ac); + l = add_to_str(hdr, l, ac); free(ac); - return; + return l; } free(ac); } - add_to_str(hdr, l, accept_charset); + return add_to_str(hdr, l, accept_charset); } -static void -add_connection(unsigned char **hdr, int *l, int http10, int proxy, int alive) +static size_t +add_connection(unsigned char **hdr, size_t l, int http10, int proxy, int alive) { if (!http10) { if (!proxy) - add_to_str(hdr, l, cast_uchar "Connection: "); + l = add_to_str(hdr, l, cast_uchar "Connection: "); else - add_to_str(hdr, l, cast_uchar "Proxy-Connection: "); + l = add_to_str(hdr, l, cast_uchar "Proxy-Connection: "); if (alive) - add_to_str(hdr, l, cast_uchar "keep-alive\r\n"); + l = add_to_str(hdr, l, cast_uchar "keep-alive\r\n"); else - add_to_str(hdr, l, cast_uchar "close\r\n"); + l = add_to_str(hdr, l, cast_uchar "close\r\n"); } + return l; } -static void -add_upgrade(unsigned char **hdr, int *l) +static size_t +add_upgrade(unsigned char **hdr, size_t l) { if (proxies.only_proxies) - add_to_str(hdr, l, - cast_uchar "Upgrade-Insecure-Requests: 1\r\n"); + return add_to_str( + hdr, l, cast_uchar "Upgrade-Insecure-Requests: 1\r\n"); + return l; } -static void -add_if_modified(unsigned char **hdr, int *l, struct connection *c) +static size_t +add_if_modified(unsigned char **hdr, size_t l, struct connection *c) { struct cache_entry *e; if ((e = c->cache)) { int code = 0; if (get_http_code(e->head, &code, NULL) || code >= 400) - return; + return l; if (!e->incomplete && e->head && c->no_cache <= NC_IF_MOD) { unsigned char *m; if (e->last_modified) @@ -596,81 +600,91 @@ add_if_modified(unsigned char **hdr, int *l, struct connection *c) e->head, cast_uchar "Expires", NULL))) ; else - return; - add_to_str(hdr, l, cast_uchar "If-Modified-Since: "); - add_to_str(hdr, l, m); - add_to_str(hdr, l, cast_uchar "\r\n"); + return l; + l = add_to_str(hdr, l, + cast_uchar "If-Modified-Since: "); + l = add_to_str(hdr, l, m); + l = add_to_str(hdr, l, cast_uchar "\r\n"); free(m); } } + + return l; } -static void -add_range(unsigned char **hdr, int *l, unsigned char *url, struct connection *c) +static size_t +add_range(unsigned char **hdr, size_t l, unsigned char *url, + struct connection *c) { struct cache_entry *e; struct http_connection_info *info = c->info; if ((e = c->cache)) { int code = 0; if (!get_http_code(e->head, &code, NULL) && code >= 300) - return; + return l; } if (c->from && c->no_cache < NC_IF_MOD && !(info->bl_flags & BL_NO_RANGE)) { - add_to_str(hdr, l, cast_uchar "Range: bytes="); - add_num_to_str(hdr, l, c->from); - add_to_str(hdr, l, cast_uchar "-\r\n"); + l = add_to_str(hdr, l, cast_uchar "Range: bytes="); + l = add_num_to_str(hdr, l, c->from); + l = add_to_str(hdr, l, cast_uchar "-\r\n"); } + return l; } -static void -add_pragma_no_cache(unsigned char **hdr, int *l, int no_cache) +static size_t +add_pragma_no_cache(unsigned char **hdr, size_t l, int no_cache) { if (no_cache >= NC_PR_NO_CACHE) - add_to_str(hdr, l, - cast_uchar - "Pragma: no-cache\r\nCache-Control: no-cache\r\n"); + return add_to_str( + hdr, l, + cast_uchar + "Pragma: no-cache\r\nCache-Control: no-cache\r\n"); + return l; } -static void -add_proxy_auth_string(unsigned char **hdr, int *l, unsigned char *url) +static size_t +add_proxy_auth_string(unsigned char **hdr, size_t l, unsigned char *url) { unsigned char *h; if ((h = get_auth_string(url, 1))) { - add_to_str(hdr, l, h); + l = add_to_str(hdr, l, h); free(h); } + return l; } -static void -add_auth_string(unsigned char **hdr, int *l, unsigned char *url) +static size_t +add_auth_string(unsigned char **hdr, size_t l, unsigned char *url) { unsigned char *h; if ((h = get_auth_string(url, 0))) { - add_to_str(hdr, l, h); + l = add_to_str(hdr, l, h); free(h); } + return l; } -static void -add_post_header(unsigned char **hdr, int *l, unsigned char **post) +static size_t +add_post_header(unsigned char **hdr, size_t l, unsigned char **post) { - if (*post) { - unsigned char *pd = cast_uchar strchr((char *)*post, '\n'); - if (pd) { - add_to_str(hdr, l, cast_uchar "Content-Type: "); - *l = add_bytes_to_str(hdr, *l, *post, pd - *post); - add_to_str(hdr, l, cast_uchar "\r\n"); - *post = pd + 1; - } - add_to_str(hdr, l, cast_uchar "Content-Length: "); - add_num_to_str(hdr, l, strlen((char *)*post) / 2); - add_to_str(hdr, l, cast_uchar "\r\n"); + if (!*post) + return l; + + unsigned char *pd = cast_uchar strchr((char *)*post, '\n'); + if (pd) { + l = add_to_str(hdr, l, cast_uchar "Content-Type: "); + l = add_bytes_to_str(hdr, l, *post, pd - *post); + l = add_to_str(hdr, l, cast_uchar "\r\n"); + *post = pd + 1; } + l = add_to_str(hdr, l, cast_uchar "Content-Length: "); + l = add_num_to_str(hdr, l, strlen((char *)*post) / 2); + return add_to_str(hdr, l, cast_uchar "\r\n"); } -static void -add_extra_options(unsigned char **hdr, int *l) +static size_t +add_extra_options(unsigned char **hdr, size_t l) { unsigned char *p = http_options.header.extra_header; while (1) { @@ -687,26 +701,25 @@ add_extra_options(unsigned char **hdr, int *l) free(cc); if (x) { unsigned char *new_hdr; - int new_l; + size_t new_l; free(x); new_hdr = NULL; - new_l = 0; new_l = add_bytes_to_str( - &new_hdr, new_l, *hdr, v - *hdr); + &new_hdr, 0, *hdr, v - *hdr); while (*++c == ' ') ; - add_to_str(&new_hdr, &new_l, c); - add_to_str( - &new_hdr, &new_l, + new_l = add_to_str(&new_hdr, new_l, c); + new_l = add_to_str( + &new_hdr, new_l, v + strcspn((char *)v, "\r\n")); free(*hdr); *hdr = new_hdr; - *l = new_l; + l = new_l; goto already_added; } } - add_to_str(hdr, l, s); - add_to_str(hdr, l, cast_uchar "\r\n"); + l = add_to_str(hdr, l, s); + l = add_to_str(hdr, l, cast_uchar "\r\n"); already_added: free(s); } @@ -714,6 +727,8 @@ already_added: break; p = q + 1; } + + return l; } static int diff --git a/https.c b/https.c @@ -181,7 +181,7 @@ verify_ssl_certificate(links_ssl *ssl, unsigned char *host) int i; char *last_ca = NULL; unsigned char *cas = NULL; - int casl = 0; + size_t casl = 0; for (i = num - 1; i >= 0; i--) { char space[3072]; char *n; @@ -194,11 +194,11 @@ verify_ssl_certificate(links_ssl *ssl, unsigned char *host) char *ca = extract_ca(n); if (!last_ca || strcmp(ca, last_ca)) { if (casl) - add_to_str( - &cas, &casl, + casl = add_to_str( + &cas, casl, CERT_RIGHT_ARROW); - add_to_str(&cas, &casl, - cast_uchar ca); + casl = add_to_str( + &cas, casl, cast_uchar ca); free(last_ca); last_ca = ca; } else { @@ -250,18 +250,18 @@ get_cipher_string(links_ssl *ssl) { const char *version, *cipher; unsigned char *s = NULL; - int l = 0; + size_t l; - add_num_to_str(&s, &l, SSL_get_cipher_bits(ssl->ssl, NULL)); - add_to_str(&s, &l, (unsigned char *)"-bit"); + l = add_num_to_str(&s, 0, SSL_get_cipher_bits(ssl->ssl, NULL)); + l = add_to_str(&s, l, (unsigned char *)"-bit"); if ((version = SSL_get_version(ssl->ssl))) { l = add_chr_to_str(&s, l, ' '); - add_to_str(&s, &l, (unsigned char *)version); + l = add_to_str(&s, l, (unsigned char *)version); } if ((cipher = SSL_get_cipher_name(ssl->ssl))) { l = add_chr_to_str(&s, l, ' '); - add_to_str(&s, &l, (unsigned char *)cipher); + l = add_to_str(&s, l, (unsigned char *)cipher); } return s; } diff --git a/links.h b/links.h @@ -256,12 +256,12 @@ void add_to_strn(unsigned char **s, unsigned char *a); void extend_str(unsigned char **s, int n); size_t add_bytes_to_str(unsigned char **, size_t, unsigned char *, size_t); -void add_to_str(unsigned char **s, int *l, unsigned char *a); +size_t add_to_str(unsigned char **, size_t, unsigned char *); size_t add_chr_to_str(unsigned char **, size_t, unsigned char); void add_unsigned_num_to_str(unsigned char **s, int *l, off_t n); void add_unsigned_long_num_to_str(unsigned char **s, int *l, unsigned long n); -void add_num_to_str(unsigned char **s, int *l, off_t n); -void add_knum_to_str(unsigned char **s, int *l, off_t n); +size_t add_num_to_str(unsigned char **s, size_t l, off_t n); +size_t add_knum_to_str(unsigned char **s, size_t l, off_t n); long strtolx(unsigned char *c, unsigned char **end); void safe_strncpy(unsigned char *dst, const unsigned char *src, @@ -381,7 +381,7 @@ void terminate_select(void); void register_bottom_half(void (*)(void *), void *); void unregister_bottom_half(void (*)(void *), void *); void check_bottom_halves(void); -void add_event_string(unsigned char **, int *, struct terminal *); +size_t add_event_string(unsigned char **, size_t, struct terminal *); struct timer; struct timer *install_timer(uttime, void (*)(void *), void *); void kill_timer(struct timer *); @@ -753,8 +753,7 @@ unsigned char *join_urls(unsigned char *, unsigned char *); unsigned char *translate_url(unsigned char *, unsigned char *); unsigned char *extract_position(unsigned char *); int url_not_saveable(unsigned char *); -void add_conv_str(unsigned char **s, int *l, unsigned char *b, int ll, - int encode_special); +size_t add_conv_str(unsigned char **, size_t, unsigned char *, int, int); void convert_file_charset(unsigned char **s, int *l, int start_l); unsigned char *idn_encode_host(unsigned char *host, int len, unsigned char *separator, int decode); @@ -808,7 +807,7 @@ extern struct list_head all_cookies; extern struct list_head c_domains; int set_cookie(struct terminal *, unsigned char *, unsigned char *); -void add_cookies(unsigned char **, int *, unsigned char *); +size_t add_cookies(unsigned char **, size_t, unsigned char *); void init_cookies(void); void free_cookies(void); int is_in_domain(unsigned char *d, unsigned char *s); @@ -1212,7 +1211,7 @@ int get_file_by_term(struct terminal *term, struct cache_entry *ce, unsigned char **start, size_t *len, int *errp); int get_file(struct object_request *o, unsigned char **start, size_t *len); void free_decompressed_data(struct cache_entry *e); -void add_compress_methods(unsigned char **s, int *l); +size_t add_compress_methods(unsigned char **, size_t); /* session.c */ @@ -2326,9 +2325,9 @@ void parse_html(unsigned char *, unsigned char *, int get_image_map(unsigned char *, unsigned char *, unsigned char *, unsigned char *a, struct menu_item **, struct memory_list **, unsigned char *, unsigned char *, int, int, int, int gfx); -void scan_http_equiv(unsigned char *, unsigned char *, unsigned char **, int *, - unsigned char **, unsigned char **, unsigned char **, - int *); +size_t scan_http_equiv(unsigned char *, unsigned char *, unsigned char **, + size_t, unsigned char **, unsigned char **, + unsigned char **, int *); int decode_color(unsigned char *, struct rgb *); diff --git a/memory.c b/memory.c @@ -55,12 +55,12 @@ free_all_caches(void) } while (a & ST_SOMETHING_FREED); if (!(b & ST_CACHE_EMPTY)) { unsigned char *m = NULL; - int l = 0; + size_t l = 0; foreach (struct cache_upcall, c, lc, cache_upcalls) if (!(c->upcall(SH_FREE_ALL) & ST_CACHE_EMPTY)) { if (l) - add_to_str(&m, &l, cast_uchar ", "); - add_to_str(&m, &l, c->name); + l = add_to_str(&m, l, cast_uchar ", "); + l = add_to_str(&m, l, c->name); } internal("could not release entries from caches: %s", m); free(m); diff --git a/menu.c b/menu.c @@ -26,16 +26,17 @@ static unsigned char *const version_texts[] = { NULL, }; -static void -add_and_pad(unsigned char **s, int *l, struct terminal *term, +static size_t +add_and_pad(unsigned char **s, size_t l, struct terminal *term, unsigned char *str, int maxlen) { unsigned char *x = get_text_translation(str, term); - int len = strlen((char *)x); - add_to_str(s, l, x); - add_to_str(s, l, cast_uchar ": "); + size_t len = strlen((char *)x); + l = add_to_str(s, l, x); + l = add_to_str(s, l, cast_uchar ": "); while (len++ < maxlen) - *l = add_chr_to_str(s, *l, ' '); + l = add_chr_to_str(s, l, ' '); + return l; } static void @@ -45,7 +46,7 @@ menu_version(void *term_) int i; int maxlen = 0; unsigned char *s; - int l; + size_t l; unsigned char *const *text_ptr; for (i = 0; version_texts[i]; i++) { unsigned char *t = get_text_translation(version_texts[i], term); @@ -55,75 +56,75 @@ menu_version(void *term_) } s = NULL; - l = 0; text_ptr = version_texts; - add_and_pad(&s, &l, term, *text_ptr++, maxlen); - add_to_str(&s, &l, cast_uchar VERSION); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_and_pad(&s, 0, term, *text_ptr++, maxlen); + l = add_to_str(&s, l, cast_uchar VERSION); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); - add_to_str(&s, &l, system_name); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); + l = add_to_str(&s, l, system_name); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); - add_to_str(&s, &l, get_text_translation(TEXT_(T_MEMORY), term)); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); + l = add_to_str(&s, l, get_text_translation(TEXT_(T_MEMORY), term)); l = add_chr_to_str(&s, l, ' '); - add_num_to_str(&s, &l, sizeof(void *) * 8); - add_to_str(&s, &l, cast_uchar "-bit, "); - add_to_str(&s, &l, get_text_translation(TEXT_(T_FILE_SIZE), term)); + l = add_num_to_str(&s, l, sizeof(void *) * 8); + l = add_to_str(&s, l, cast_uchar "-bit, "); + l = add_to_str(&s, l, get_text_translation(TEXT_(T_FILE_SIZE), term)); l = add_chr_to_str(&s, l, ' '); - add_num_to_str(&s, &l, sizeof(off_t) * 8 /*- ((off_t)-1 < 0)*/); - add_to_str(&s, &l, cast_uchar "-bit"); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_num_to_str(&s, l, sizeof(off_t) * 8 /*- ((off_t)-1 < 0)*/); + l = add_to_str(&s, l, cast_uchar "-bit"); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); - add_event_string(&s, &l, term); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); + l = add_event_string(&s, l, term); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); if (!support_ipv6) - add_to_str( - &s, &l, + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_NOT_ENABLED_IN_SYSTEM), term)); else if (!ipv6_full_access()) - add_to_str( - &s, &l, + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_LOCAL_NETWORK_ONLY), term)); else - add_to_str(&s, &l, get_text_translation(TEXT_(T_YES), term)); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_to_str(&s, l, get_text_translation(TEXT_(T_YES), term)); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); - add_compress_methods(&s, &l); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); + l = add_compress_methods(&s, l); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); #ifdef OPENSSL_VERSION - add_to_str(&s, &l, (unsigned char *)OpenSSL_version(OPENSSL_VERSION)); + l = add_to_str(&s, l, + (unsigned char *)OpenSSL_version(OPENSSL_VERSION)); #else - add_to_str(&s, &l, (unsigned char *)SSLeay_version(SSLEAY_VERSION)); + l = add_to_str(&s, l, (unsigned char *)SSLeay_version(SSLEAY_VERSION)); #endif - add_to_str(&s, &l, cast_uchar "\n"); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); - add_to_str(&s, &l, get_text_translation(TEXT_(T_YES), term)); - add_to_str(&s, &l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); - add_to_str(&s, &l, get_text_translation(TEXT_(T_NO), term)); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); + l = add_to_str(&s, l, get_text_translation(TEXT_(T_YES), term)); + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); + l = add_to_str(&s, l, get_text_translation(TEXT_(T_NO), term)); + l = add_to_str(&s, l, cast_uchar "\n"); - add_and_pad(&s, &l, term, *text_ptr++, maxlen); + l = add_and_pad(&s, l, term, *text_ptr++, maxlen); if (links_home) { unsigned char *native_home = os_conv_to_external_path(links_home, NULL); - add_to_str(&s, &l, native_home); + l = add_to_str(&s, l, native_home); free(native_home); } else - add_to_str(&s, &l, get_text_translation(TEXT_(T_NONE), term)); - add_to_str(&s, &l, cast_uchar "\n"); + l = add_to_str(&s, l, + get_text_translation(TEXT_(T_NONE), term)); + l = add_to_str(&s, l, cast_uchar "\n"); - s[l - 1] = 0; if (*text_ptr) internal("menu_version: text mismatched"); @@ -309,102 +310,103 @@ resource_info(struct terminal *term, struct refresh *r2) r->win = NULL; r->fn = resource_info; r->timer = NULL; - l = 0; a = NULL; - add_to_str(&a, &l, get_text_translation(TEXT_(T_RESOURCES), term)); - add_to_str(&a, &l, cast_uchar ": "); + l = add_to_str(&a, 0, get_text_translation(TEXT_(T_RESOURCES), term)); + l = add_to_str(&a, l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, select_info(CI_FILES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_HANDLES), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_HANDLES), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, select_info(CI_TIMERS)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_TIMERS), term)); - add_to_str(&a, &l, cast_uchar ".\n"); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_TIMERS), term)); + l = add_to_str(&a, l, cast_uchar ".\n"); - add_to_str(&a, &l, get_text_translation(TEXT_(T_CONNECTIONS), term)); - add_to_str(&a, &l, cast_uchar ": "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_CONNECTIONS), term)); + l = add_to_str(&a, l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, connect_info(CI_FILES) - connect_info(CI_CONNECTING) - connect_info(CI_TRANSFER)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_WAITING), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_WAITING), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, connect_info(CI_CONNECTING)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_CONNECTING), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_CONNECTING), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, connect_info(CI_TRANSFER)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_tRANSFERRING), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, + get_text_translation(TEXT_(T_tRANSFERRING), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, connect_info(CI_KEEP)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_KEEPALIVE), term)); - add_to_str(&a, &l, cast_uchar ".\n"); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_KEEPALIVE), term)); + l = add_to_str(&a, l, cast_uchar ".\n"); - add_to_str(&a, &l, get_text_translation(TEXT_(T_MEMORY_CACHE), term)); - add_to_str(&a, &l, cast_uchar ": "); + l = add_to_str(&a, l, + get_text_translation(TEXT_(T_MEMORY_CACHE), term)); + l = add_to_str(&a, l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, cache_info(CI_BYTES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_BYTES), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_BYTES), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, cache_info(CI_FILES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_FILES), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_FILES), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, cache_info(CI_LOCKED)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_LOCKED), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_LOCKED), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, cache_info(CI_LOADING)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_LOADING), term)); - add_to_str(&a, &l, cast_uchar ".\n"); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_LOADING), term)); + l = add_to_str(&a, l, cast_uchar ".\n"); - add_to_str(&a, &l, - get_text_translation(TEXT_(T_DECOMPRESSED_CACHE), term)); - add_to_str(&a, &l, cast_uchar ": "); + l = add_to_str(&a, l, + get_text_translation(TEXT_(T_DECOMPRESSED_CACHE), term)); + l = add_to_str(&a, l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, decompress_info(CI_BYTES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_BYTES), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_BYTES), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, decompress_info(CI_FILES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_FILES), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_FILES), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, decompress_info(CI_LOCKED)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_LOCKED), term)); - add_to_str(&a, &l, cast_uchar ".\n"); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_LOCKED), term)); + l = add_to_str(&a, l, cast_uchar ".\n"); - add_to_str( - &a, &l, + l = add_to_str( + &a, l, get_text_translation(TEXT_(T_FORMATTED_DOCUMENT_CACHE), term)); - add_to_str(&a, &l, cast_uchar ": "); + l = add_to_str(&a, l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, formatted_info(CI_FILES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_DOCUMENTS), term)); - add_to_str(&a, &l, cast_uchar ", "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_DOCUMENTS), term)); + l = add_to_str(&a, l, cast_uchar ", "); add_unsigned_long_num_to_str(&a, &l, formatted_info(CI_LOCKED)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_LOCKED), term)); - add_to_str(&a, &l, cast_uchar ".\n"); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_LOCKED), term)); + l = add_to_str(&a, l, cast_uchar ".\n"); - add_to_str(&a, &l, get_text_translation(TEXT_(T_DNS_CACHE), term)); - add_to_str(&a, &l, cast_uchar ": "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_DNS_CACHE), term)); + l = add_to_str(&a, l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, dns_info(CI_FILES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_SERVERS), term)); - add_to_str(&a, &l, cast_uchar ", "); - add_to_str(&a, &l, - get_text_translation(TEXT_(T_TLS_SESSION_CACHE), term)); - add_to_str(&a, &l, cast_uchar ": "); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_SERVERS), term)); + l = add_to_str(&a, l, cast_uchar ", "); + l = add_to_str(&a, l, + get_text_translation(TEXT_(T_TLS_SESSION_CACHE), term)); + l = add_to_str(&a, l, cast_uchar ": "); add_unsigned_long_num_to_str(&a, &l, session_info(CI_FILES)); l = add_chr_to_str(&a, l, ' '); - add_to_str(&a, &l, get_text_translation(TEXT_(T_SERVERS), term)); + l = add_to_str(&a, l, get_text_translation(TEXT_(T_SERVERS), term)); l = add_chr_to_str(&a, l, '.'); if (r2 @@ -2560,7 +2562,7 @@ query_file(struct session *ses, unsigned char *url, unsigned char *head, void (*cancel)(void *), int flags) { unsigned char *fc, *file, *def; - int dfl = 0; + size_t dfl; struct does_file_exist_s *h; h = xmalloc(sizeof(struct does_file_exist_s)); @@ -2571,10 +2573,10 @@ query_file(struct session *ses, unsigned char *url, unsigned char *head, check_filename(&file); def = NULL; - add_to_str(&def, &dfl, download_dir); + dfl = add_to_str(&def, 0, download_dir); if (*def && !dir_sep(def[strlen(cast_const_char def) - 1])) dfl = add_chr_to_str(&def, dfl, '/'); - add_to_str(&def, &dfl, file); + dfl = add_to_str(&def, dfl, file); free(file); h->fn = fn; diff --git a/select.c b/select.c @@ -422,40 +422,43 @@ do_event_loop(int flags) die("event_base_loop: %s\n", strerror(errno)); } -void -add_event_string(unsigned char **s, int *l, struct terminal *term) +size_t +add_event_string(unsigned char **s, size_t l, struct terminal *term) { if (!event_enabled) - add_to_str(s, l, - get_text_translation(TEXT_(T_SELECT_SYSCALL), term)); + l = add_to_str( + s, l, get_text_translation(TEXT_(T_SELECT_SYSCALL), term)); if (!event_enabled) - add_to_str(s, l, cast_uchar " ("); + l = add_to_str(s, l, cast_uchar " ("); #if defined(HAVE_LIBEV) - add_to_str(s, l, cast_uchar "LibEv"); + l = add_to_str(s, l, cast_uchar "LibEv"); #else - add_to_str(s, l, cast_uchar "LibEvent"); + l = add_to_str(s, l, cast_uchar "LibEvent"); #endif - *l = add_chr_to_str(s, *l, ' '); + l = add_chr_to_str(s, l, ' '); { #if defined(HAVE_LIBEV) /* old libev report bogus version */ if (!casestrcmp(cast_uchar event_get_version(), cast_uchar "EV_VERSION_MAJOR.EV_VERSION_MINOR")) { - add_num_to_str(s, l, ev_version_major()); - *l = add_chr_to_str(s, *l, '.'); - add_num_to_str(s, l, ev_version_minor()); + add_num_to_str(s, &l, ev_version_major()); + l = add_chr_to_str(s, *l, '.'); + add_num_to_str(s, &l, ev_version_minor()); } else #endif - add_to_str(s, l, cast_uchar event_get_version()); + l = add_to_str(s, l, cast_uchar event_get_version()); } if (!event_enabled) { - *l = add_chr_to_str(s, *l, ' '); - add_to_str(s, l, get_text_translation(TEXT_(T_dISABLED), term)); - *l = add_chr_to_str(s, *l, ')'); + l = add_chr_to_str(s, l, ' '); + l = add_to_str(s, l, + get_text_translation(TEXT_(T_dISABLED), term)); + l = add_chr_to_str(s, l, ')'); } else { - *l = add_chr_to_str(s, *l, ' '); - add_to_str(s, l, cast_uchar event_base_get_method(event_base)); + l = add_chr_to_str(s, l, ' '); + l = add_to_str(s, l, + cast_uchar event_base_get_method(event_base)); } + return l; } static uttime last_time; diff --git a/session.c b/session.c @@ -164,8 +164,8 @@ have_error: return s->msg; } -static void -add_xnum_to_str(unsigned char **s, int *l, off_t n) +static size_t +add_xnum_to_str(unsigned char **s, size_t l, off_t n) { unsigned char suff = 0; int d = -1; @@ -182,36 +182,36 @@ add_xnum_to_str(unsigned char **s, int *l, off_t n) d = (int)((n / 100) % 10); n /= 1000; } - add_num_to_str(s, l, n); + l = add_num_to_str(s, l, n); if (n < 10 && d != -1) { - *l = add_chr_to_str(s, *l, '.'); + l = add_chr_to_str(s, l, '.'); add_num_to_str(s, l, d); } - *l = add_chr_to_str(s, *l, ' '); + l = add_chr_to_str(s, l, ' '); if (suff) - *l = add_chr_to_str(s, *l, suff); - *l = add_chr_to_str(s, *l, 'B'); + l = add_chr_to_str(s, l, suff); + return add_chr_to_str(s, l, 'B'); } -static void -add_time_to_str(unsigned char **s, int *l, uttime t) +static size_t +add_time_to_str(unsigned char **s, size_t l, uttime t) { unsigned char q[64]; if (t >= 86400) { sprintf(cast_char q, "%lud ", (unsigned long)(t / 86400)); - add_to_str(s, l, q); + l = add_to_str(s, l, q); } if (t >= 3600) { t %= 86400; sprintf(cast_char q, "%d:%02d", (int)(t / 3600), (int)(t / 60 % 60)); - add_to_str(s, l, q); + l = add_to_str(s, l, q); } else { sprintf(cast_char q, "%d", (int)(t / 60)); - add_to_str(s, l, q); + l = add_to_str(s, l, q); } sprintf(cast_char q, ":%02d", (int)(t % 60)); - add_to_str(s, l, q); + return add_to_str(s, l, q); } static unsigned char * @@ -219,38 +219,37 @@ get_stat_msg(struct status *stat, struct terminal *term) { if (stat->state == S_TRANS && stat->prg->elapsed / 100) { unsigned char *m = NULL; - int l = 0; - add_to_str(&m, &l, - get_text_translation(TEXT_(T_RECEIVED), term)); + size_t l; + l = add_to_str(&m, 0, + get_text_translation(TEXT_(T_RECEIVED), term)); l = add_chr_to_str(&m, l, ' '); - add_xnum_to_str(&m, &l, stat->prg->pos); + l = add_xnum_to_str(&m, l, stat->prg->pos); if (stat->prg->size >= 0) { l = add_chr_to_str(&m, l, ' '); - add_to_str(&m, &l, - get_text_translation(TEXT_(T_OF), term)); + l = add_to_str(&m, l, + get_text_translation(TEXT_(T_OF), term)); l = add_chr_to_str(&m, l, ' '); - add_xnum_to_str(&m, &l, stat->prg->size); + l = add_xnum_to_str(&m, l, stat->prg->size); } - add_to_str(&m, &l, cast_uchar ", "); + l = add_to_str(&m, l, cast_uchar ", "); if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) { - add_to_str(&m, &l, - get_text_translation(TEXT_(T_AVG), term)); + l = add_to_str( + &m, l, get_text_translation(TEXT_(T_AVG), term)); l = add_chr_to_str(&m, l, ' '); } - add_xnum_to_str(&m, &l, - stat->prg->loaded * 10 - / (stat->prg->elapsed / 100)); - add_to_str(&m, &l, cast_uchar "/s"); + l = add_xnum_to_str( + &m, l, stat->prg->loaded * 10 / (stat->prg->elapsed / 100)); + l = add_to_str(&m, l, cast_uchar "/s"); if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) { - add_to_str(&m, &l, cast_uchar ", "); - add_to_str(&m, &l, - get_text_translation(TEXT_(T_CUR), term)); + l = add_to_str(&m, l, cast_uchar ", "); + l = add_to_str( + &m, l, get_text_translation(TEXT_(T_CUR), term)); l = add_chr_to_str(&m, l, ' '); - add_xnum_to_str( - &m, &l, + l = add_xnum_to_str( + &m, l, stat->prg->cur_loaded / (CURRENT_SPD_SEC * SPD_DISP_TIME / 1000)); - add_to_str(&m, &l, cast_uchar "/s"); + l = add_to_str(&m, l, cast_uchar "/s"); } return m; } @@ -411,8 +410,8 @@ unsigned char * encode_url(unsigned char *url) { unsigned char *u = NULL; - int l = 0; - add_to_str(&u, &l, cast_uchar "+++"); + size_t l; + l = add_to_str(&u, 0, cast_uchar "+++"); for (; *url; url++) { if (is_safe_in_shell(*url) && *url != '+') l = add_chr_to_str(&u, l, *url); @@ -621,7 +620,7 @@ unsigned char * download_percentage(struct download *down, int pad) { unsigned char *s; - int l; + size_t l; int perc; struct status *stat = &down->stat; if (stat->state != S_TRANS || !test_percentage(stat)) @@ -635,7 +634,7 @@ download_percentage(struct download *down, int pad) if (perc < 100) l = add_chr_to_str(&s, l, ' '); } - add_num_to_str(&s, &l, perc); + l = add_num_to_str(&s, l, perc); l = add_chr_to_str(&s, l, '%'); return s; } @@ -654,56 +653,56 @@ download_window_function(struct dialog_data *dlg) redraw_below_window(dlg->win); down->win = dlg->win; if (stat->state == S_TRANS && stat->prg->elapsed / 100) { - int l = 0; + size_t l; m = NULL; t = 1; - add_to_str(&m, &l, - get_text_translation(TEXT_(T_RECEIVED), term)); + l = add_to_str(&m, 0, + get_text_translation(TEXT_(T_RECEIVED), term)); l = add_chr_to_str(&m, l, ' '); - add_xnum_to_str(&m, &l, stat->prg->pos); + l = add_xnum_to_str(&m, l, stat->prg->pos); if (stat->prg->size >= 0) { l = add_chr_to_str(&m, l, ' '); - add_to_str(&m, &l, - get_text_translation(TEXT_(T_OF), term)); + l = add_to_str(&m, l, + get_text_translation(TEXT_(T_OF), term)); l = add_chr_to_str(&m, l, ' '); - add_xnum_to_str(&m, &l, stat->prg->size); + l = add_xnum_to_str(&m, l, stat->prg->size); l = add_chr_to_str(&m, l, ' '); } - add_to_str(&m, &l, cast_uchar "\n"); + l = add_to_str(&m, l, cast_uchar "\n"); if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) - add_to_str( - &m, &l, + l = add_to_str( + &m, l, get_text_translation(TEXT_(T_AVERAGE_SPEED), term)); else - add_to_str(&m, &l, - get_text_translation(TEXT_(T_SPEED), term)); + l = add_to_str( + &m, l, get_text_translation(TEXT_(T_SPEED), term)); l = add_chr_to_str(&m, l, ' '); - add_xnum_to_str(&m, &l, - (long long)stat->prg->loaded * 10 - / (stat->prg->elapsed / 100)); - add_to_str(&m, &l, cast_uchar "/s"); + l = add_xnum_to_str(&m, l, + (long long)stat->prg->loaded * 10 + / (stat->prg->elapsed / 100)); + l = add_to_str(&m, l, cast_uchar "/s"); if (stat->prg->elapsed >= CURRENT_SPD_AFTER * SPD_DISP_TIME) { - add_to_str(&m, &l, cast_uchar ", "); - add_to_str( - &m, &l, + l = add_to_str(&m, l, cast_uchar ", "); + l = add_to_str( + &m, l, get_text_translation(TEXT_(T_CURRENT_SPEED), term)); l = add_chr_to_str(&m, l, ' '); - add_xnum_to_str( - &m, &l, + l = add_xnum_to_str( + &m, l, stat->prg->cur_loaded / (CURRENT_SPD_SEC * SPD_DISP_TIME / 1000)); - add_to_str(&m, &l, cast_uchar "/s"); + l = add_to_str(&m, l, cast_uchar "/s"); } - add_to_str(&m, &l, cast_uchar "\n"); - add_to_str(&m, &l, - get_text_translation(TEXT_(T_ELAPSED_TIME), term)); + l = add_to_str(&m, l, cast_uchar "\n"); + l = add_to_str( + &m, l, get_text_translation(TEXT_(T_ELAPSED_TIME), term)); l = add_chr_to_str(&m, l, ' '); - add_time_to_str(&m, &l, stat->prg->elapsed / 1000); + l = add_time_to_str(&m, l, stat->prg->elapsed / 1000); if (stat->prg->size >= 0 && stat->prg->loaded > 0) { - add_to_str(&m, &l, cast_uchar ", "); - add_to_str(&m, &l, - get_text_translation(TEXT_(T_ESTIMATED_TIME), - term)); + l = add_to_str(&m, l, cast_uchar ", "); + l = add_to_str(&m, l, + get_text_translation( + TEXT_(T_ESTIMATED_TIME), term)); l = add_chr_to_str(&m, l, ' '); /*add_time_to_str(&m, &l, stat->prg->elapsed / 1000 * * stat->prg->size / stat->prg->loaded * 1000 - @@ -711,8 +710,8 @@ download_window_function(struct dialog_data *dlg) /*add_time_to_str(&m, &l, (stat->prg->size - * stat->prg->pos) / ((longlong)stat->prg->loaded * 10 / * (stat->prg->elapsed / 100)));*/ - add_time_to_str( - &m, &l, + l = add_time_to_str( + &m, l, (uttime)((stat->prg->size - stat->prg->pos) / ((double)stat->prg->loaded * 1000 / stat->prg->elapsed))); @@ -1374,7 +1373,7 @@ no_suffix: static unsigned char * get_temp_name(unsigned char *url, unsigned char *head) { - int nl; + size_t nl; unsigned char *name, *fn, *fnx; unsigned char *nm; unsigned char *directory = NULL; @@ -1382,8 +1381,7 @@ get_temp_name(unsigned char *url, unsigned char *head) if (!nm) return NULL; name = NULL; - nl = 0; - add_to_str(&name, &nl, nm); + nl = add_to_str(&name, 0, nm); free(nm); fn = get_filename_from_url(url, head, 1); fnx = cast_uchar strchr(cast_const_char fn, '.'); @@ -1391,7 +1389,7 @@ get_temp_name(unsigned char *url, unsigned char *head) unsigned char *s; s = stracpy(fnx); check_shell_security(&s); - add_to_str(&name, &nl, s); + nl = add_to_str(&name, nl, s); free(s); } free(fn); @@ -1404,7 +1402,7 @@ subst_file(unsigned char *prog, unsigned char *file, int cyg_subst) unsigned char *orig_prog = prog; unsigned char *nn; unsigned char *n = NULL; - int l = 0; + size_t l = 0; while (*prog) { int p; for (p = 0; prog[p] && prog[p] != '%'; p++) @@ -1415,10 +1413,10 @@ subst_file(unsigned char *prog, unsigned char *file, int cyg_subst) if (cyg_subst) { unsigned char *conv = os_conv_to_external_path(file, orig_prog); - add_to_str(&n, &l, conv); + l = add_to_str(&n, l, conv); free(conv); } else - add_to_str(&n, &l, file); + l = add_to_str(&n, l, file); prog++; } } @@ -1540,10 +1538,10 @@ format_html(struct f_data_c *fd, struct object_request *rq, unsigned char *url, f->uncacheable = 1; if (opt->plain == 2) { start = NULL; - stl = 0; - add_to_str(&start, &stl, cast_uchar "<img src=\""); - add_to_str(&start, &stl, f->rq->ce->url); - add_to_str(&start, &stl, cast_uchar "\">"); + stl = + add_to_str(&start, 0, cast_uchar "<img src=\""); + stl = add_to_str(&start, stl, f->rq->ce->url); + stl = add_to_str(&start, stl, cast_uchar "\">"); len = stl; } really_format_html(f->rq->ce, start, start + len, f, diff --git a/string.c b/string.c @@ -113,10 +113,10 @@ add_bytes_to_str(unsigned char **s, size_t sl, unsigned char *a, size_t al) return sl; } -void -add_to_str(unsigned char **s, int *l, unsigned char *a) +size_t +add_to_str(unsigned char **s, size_t l, unsigned char *a) { - *l = add_bytes_to_str(s, *l, a, strlen(cast_const_char a)); + return add_bytes_to_str(s, l, a, strlen(cast_const_char a)); } size_t @@ -130,11 +130,11 @@ add_unsigned_long_num_to_str(unsigned char **s, int *l, unsigned long n) { unsigned char a[64]; snprint(a, 64, n); - add_to_str(s, l, a); + *l = add_to_str(s, *l, a); } -void -add_num_to_str(unsigned char **s, int *l, off_t n) +size_t +add_num_to_str(unsigned char **s, size_t l, off_t n) { unsigned char a[64]; if (n >= 0 && n < 1000) { @@ -151,15 +151,17 @@ d10: sn %= 10; } *p++ = '0' + sn; - *l = add_bytes_to_str(s, *l, a, p - a); + l = add_bytes_to_str(s, l, a, p - a); } else { snzprint(a, 64, n); - add_to_str(s, l, a); + l = add_to_str(s, l, a); } + + return l; } -void -add_knum_to_str(unsigned char **s, int *l, off_t n) +size_t +add_knum_to_str(unsigned char **s, size_t l, off_t n) { unsigned char a[13]; if (n && n / (1024 * 1024) * (1024 * 1024) == n) { @@ -172,7 +174,7 @@ add_knum_to_str(unsigned char **s, int *l, off_t n) a[strlen(cast_const_char a)] = 'k'; } else snzprint(a, 13, n); - add_to_str(s, l, a); + return add_to_str(s, l, a); } long diff --git a/terminal.c b/terminal.c @@ -592,10 +592,10 @@ static unsigned char frame_vt100[49] = #define SETPOS(x, y) \ { \ - add_to_str(&a, &l, cast_uchar "\033["); \ - add_num_to_str(&a, &l, (y) + 1 + term->top_margin); \ + l = add_to_str(&a, l, cast_uchar "\033["); \ + l = add_num_to_str(&a, l, (y) + 1 + term->top_margin); \ l = add_chr_to_str(&a, l, ';'); \ - add_num_to_str(&a, &l, (x) + 1 + term->left_margin); \ + l = add_num_to_str(&a, l, (x) + 1 + term->left_margin); \ l = add_chr_to_str(&a, l, 'H'); \ n_chars = 0; \ } @@ -608,9 +608,11 @@ static unsigned char frame_vt100[49] = if (s->mode == TERM_VT100) { \ if (frm != mode) { \ if (!(mode = frm)) \ - add_to_str(&a, &l, cast_uchar "\017"); \ + l = add_to_str(&a, l, \ + cast_uchar "\017"); \ else \ - add_to_str(&a, &l, cast_uchar "\016"); \ + l = add_to_str(&a, l, \ + cast_uchar "\016"); \ } \ if (frm && c >= 176 && c < 224) \ c = frame_vt100[c - 176]; \ @@ -620,22 +622,22 @@ static unsigned char frame_vt100[49] = A = (A & 070) | 7 * !(A & 020); \ if (A != attrib) { \ attrib = A; \ - add_to_str(&a, &l, cast_uchar "\033[0"); \ + l = add_to_str(&a, l, cast_uchar "\033[0"); \ if (s->col) { \ unsigned char m[4]; \ m[0] = ';'; \ m[1] = '3'; \ m[3] = 0; \ m[2] = (attrib & 7) + '0'; \ - add_to_str(&a, &l, m); \ + l = add_to_str(&a, l, m); \ m[1] = '4'; \ m[2] = ((attrib >> 3) & 7) + '0'; \ - add_to_str(&a, &l, m); \ + l = add_to_str(&a, l, m); \ } else if (getcompcode(attrib & 7) \ < getcompcode(attrib >> 3 & 7)) \ - add_to_str(&a, &l, cast_uchar ";7"); \ + l = add_to_str(&a, l, cast_uchar ";7"); \ if (attrib & 0100) \ - add_to_str(&a, &l, cast_uchar ";1"); \ + l = add_to_str(&a, l, cast_uchar ";1"); \ l = add_chr_to_str(&a, l, 'm'); \ } \ if (c >= ' ' && c != 127 && c != 155) { \ @@ -658,7 +660,7 @@ static unsigned char frame_vt100[49] = l = add_chr_to_str(&a, l, 8); \ else \ SETPOS(cx, y); \ - add_to_str(&a, &l, encode_utf_8(c)); \ + l = add_to_str(&a, l, encode_utf_8(c)); \ SETPOS(cx + 1, y); \ print_next = 1; \ } \ @@ -730,27 +732,27 @@ pc: } } if (print_next && term->left_margin + term->x < term->real_x) { - add_to_str(&a, &l, cast_uchar "\033[0m "); + l = add_to_str(&a, l, cast_uchar "\033[0m "); attrib = -1; print_next = 0; } } if (l) { if (s->col) - add_to_str(&a, &l, cast_uchar "\033[37;40m"); - add_to_str(&a, &l, cast_uchar "\033[0m"); + l = add_to_str(&a, l, cast_uchar "\033[37;40m"); + l = add_to_str(&a, l, cast_uchar "\033[0m"); if (s->mode == TERM_VT100) - add_to_str(&a, &l, cast_uchar "\017"); + l = add_to_str(&a, l, cast_uchar "\017"); } term->lcx = cx; term->lcy = cy; if (term->cx != term->lcx || term->cy != term->lcy) { term->lcx = term->cx; term->lcy = term->cy; - add_to_str(&a, &l, cast_uchar "\033["); - add_num_to_str(&a, &l, term->cy + 1 + term->top_margin); + l = add_to_str(&a, l, cast_uchar "\033["); + l = add_num_to_str(&a, l, term->cy + 1 + term->top_margin); l = add_chr_to_str(&a, l, ';'); - add_num_to_str(&a, &l, term->cx + 1 + term->left_margin); + l = add_num_to_str(&a, l, term->cx + 1 + term->left_margin); l = add_chr_to_str(&a, l, 'H'); } hard_write(term->fdout, a, l); @@ -1040,7 +1042,7 @@ exec_on_terminal(struct terminal *term, unsigned char *path, } else { int blockh; unsigned char *param; - int paraml; + size_t paraml; if (is_blocked() && fg) { if (*delet) EINTRLOOP( @@ -1049,9 +1051,9 @@ exec_on_terminal(struct terminal *term, unsigned char *path, } param = NULL; paraml = add_chr_to_str(&param, 0, fg); - add_to_str(&param, &paraml, path); + paraml = add_to_str(&param, paraml, path); paraml = add_chr_to_str(&param, paraml, 0); - add_to_str(&param, &paraml, delet); + paraml = add_to_str(&param, paraml, delet); if (fg == 1) block_itrm(term->fdin); if ((blockh = start_thread(exec_thread, param, @@ -1075,13 +1077,13 @@ exec_on_terminal(struct terminal *term, unsigned char *path, } } else { unsigned char *data; - int datal; + size_t datal; data = NULL; datal = add_chr_to_str(&data, 0, 0); datal = add_chr_to_str(&data, datal, fg); - add_to_str(&data, &datal, path); + datal = add_to_str(&data, datal, path); datal = add_chr_to_str(&data, datal, 0); - add_to_str(&data, &datal, delet); + datal = add_to_str(&data, datal, delet); hard_write(term->fdout, data, datal + 1); free(data); } @@ -1092,10 +1094,10 @@ do_terminal_function(struct terminal *term, unsigned char code, unsigned char *data) { unsigned char *x_data; - int x_datal; + size_t x_datal; x_data = NULL; x_datal = add_chr_to_str(&x_data, 0, code); - add_to_str(&x_data, &x_datal, data); + x_datal = add_to_str(&x_data, x_datal, data); exec_on_terminal(term, NULL, x_data, 0); free(x_data); } diff --git a/types.c b/types.c @@ -1045,7 +1045,8 @@ get_content_type_by_extension(unsigned char *url) struct list *l = NULL; struct list_head *ll; unsigned char *ct, *eod, *ext, *exxt; - int extl, el; + int extl; + size_t el; ext = NULL; extl = 0; if (!(ct = get_url_data(url))) @@ -1108,8 +1109,7 @@ get_content_type_by_extension(unsigned char *url) || (extl == 4 && !casecmp(ext, cast_uchar "tiff", 4))) return stracpy(cast_uchar "image/tiff"); exxt = NULL; - el = 0; - add_to_str(&exxt, &el, cast_uchar "application/x-"); + el = add_to_str(&exxt, 0, cast_uchar "application/x-"); el = add_bytes_to_str(&exxt, el, ext, extl); foreach (struct list, l, ll, assoc.list_entry) { struct assoc *a = get_struct(l, struct assoc, head); @@ -1394,7 +1394,6 @@ get_filename_from_header(unsigned char *head) { int extended = 0; unsigned char *ct, *x, *y, *codepage; - int ly; if ((ct = parse_http_header(head, cast_uchar "Content-Disposition", NULL))) { x = parse_header_param(ct, cast_uchar "filename*", 1); @@ -1441,8 +1440,7 @@ ret_x: no_extended: y = NULL; - ly = 0; - add_conv_str(&y, &ly, x, (int)strlen(cast_const_char x), -2); + add_conv_str(&y, 0, x, (int)strlen(cast_const_char x), -2); free(x); free(codepage); @@ -1455,7 +1453,6 @@ no_extended: unsigned char * get_filename_from_url(unsigned char *url, unsigned char *head, int tmp) { - int ll = 0; unsigned char *u, *s, *e, *f, *x, *ww; unsigned char *ct, *want_ext; if (!casecmp(url, cast_uchar "data:", 5)) @@ -1469,9 +1466,8 @@ get_filename_from_url(unsigned char *url, unsigned char *head, int tmp) for (e = s = u; *e && !end_of_dir(url, *e); e++) if (dir_sep(*e)) s = e + 1; - ll = 0; f = NULL; - add_conv_str(&f, &ll, s, (int)(e - s), -2); + add_conv_str(&f, 0, s, (int)(e - s), -2); if (!(ct = parse_http_header(head, cast_uchar "Content-Type", NULL))) goto no_ct; free(ct); diff --git a/url.c b/url.c @@ -422,18 +422,18 @@ free_u_ret_up: rl = add_chr_to_str(&r, rl, '&'); else rl = add_chr_to_str(&r, rl, '?'); - add_to_str(&r, &rl, cast_uchar "_escaped_fragment_="); + rl = add_to_str(&r, rl, cast_uchar "_escaped_fragment_="); for (; *dp; dp++) { unsigned char c = *dp; if (c <= 0x20 || c == 0x23 || c == 0x25 || c == 0x26 || c == 0x2b || c >= 0x7f) { unsigned char h[4]; sprintf((char *)h, "%%%02X", c); - add_to_str(&r, &rl, h); + rl = add_to_str(&r, rl, h); } else rl = add_chr_to_str(&r, rl, c); } - add_to_str(&r, &rl, post_seq); + rl = add_to_str(&r, rl, post_seq); free(u); free(p); free(up); @@ -446,7 +446,7 @@ rewrite_url_google_docs(unsigned char *n) int i; unsigned char *id, *id_end, *url_end; unsigned char *res; - int l; + size_t l; struct { const char *beginning; const char *result1; @@ -487,10 +487,9 @@ match: id--; } res = NULL; - l = 0; - add_to_str(&res, &l, cast_uchar patterns[i].result1); + l = add_to_str(&res, 0, cast_uchar patterns[i].result1); l = add_bytes_to_str(&res, l, id, id_end - id); - add_to_str(&res, &l, cast_uchar patterns[i].result2); + l = add_to_str(&res, l, cast_uchar patterns[i].result2); free(n); return res; } @@ -565,7 +564,7 @@ insert_wd(unsigned char **up, unsigned char *cwd) unsigned char *cw; unsigned char *url; char *host; - int url_l; + size_t url_l; int i; if (!u || !cwd || !*cwd) return; @@ -587,13 +586,13 @@ insert_wd(unsigned char **up, unsigned char *cwd) if (c < ' ' || c == '%' || c >= 127) { unsigned char h[4]; sprintf((char *)h, "%%%02X", (unsigned)c & 0xff); - add_to_str(&url, &url_l, h); + url_l = add_to_str(&url, url_l, h); } else url_l = add_chr_to_str(&url, url_l, c); } if (!dir_sep(cwd[strlen((char *)cwd) - 1])) url_l = add_chr_to_str(&url, url_l, '/'); - add_to_str(&url, &url_l, u + 7); + url_l = add_to_str(&url, url_l, u + 7); free(u); *up = url; } @@ -875,8 +874,8 @@ url_not_saveable(unsigned char *url) * 1 raw to percent */ -void -add_conv_str(unsigned char **s, int *l, unsigned char *b, int ll, +size_t +add_conv_str(unsigned char **s, size_t l, unsigned char *b, int ll, int encode_special) { for (; ll > 0; ll--, b++) { @@ -886,7 +885,7 @@ add_conv_str(unsigned char **s, int *l, unsigned char *b, int ll, if (special_char(chr) && encode_special == 1) { unsigned char h[4]; sprintf((char *)h, "%%%02X", (unsigned)chr & 0xff); - add_to_str(s, l, h); + l = add_to_str(s, l, h); continue; } if (chr == '%' && encode_special <= -1 && ll > 2 @@ -912,17 +911,18 @@ add_conv_str(unsigned char **s, int *l, unsigned char *b, int ll, continue; } if (chr == ' ' && (!encode_special || encode_special == -1)) - add_to_str(s, l, cast_uchar "&nbsp;"); + l = add_to_str(s, l, cast_uchar "&nbsp;"); else if (accept_char(chr) || encode_special == -2) - *l = add_chr_to_str(s, *l, chr); + l = add_chr_to_str(s, l, chr); else if (chr == 10 || chr == 13) { continue; } else { - add_to_str(s, l, cast_uchar "&#"); - add_num_to_str(s, l, (int)chr); - *l = add_chr_to_str(s, *l, ';'); + l = add_to_str(s, l, cast_uchar "&#"); + l = add_num_to_str(s, l, (int)chr); + l = add_chr_to_str(s, l, ';'); } } + return l; } void @@ -1016,7 +1016,7 @@ puny_encode(unsigned char *s, int len) unsigned *uni; unsigned uni_l; unsigned char *res; - int res_l; + size_t res_l; unsigned i; unsigned ni, cchar, skip; struct puny_state st; @@ -1039,8 +1039,7 @@ puny_encode(unsigned char *s, int len) goto err_free_uni; res = NULL; - res_l = 0; - add_to_str(&res, &res_l, cast_uchar xn); + res_l = add_to_str(&res, 0, cast_uchar xn); ni = 0; for (i = 0; i < uni_l; i++) @@ -1128,7 +1127,7 @@ puny_decode(unsigned char *s, int len) unsigned *uni; unsigned uni_l; unsigned char *res; - int res_l; + size_t res_l; unsigned i; unsigned cchar, pos; struct puny_state st; @@ -1214,7 +1213,7 @@ puny_decode(unsigned char *s, int len) for (i = 0; i < uni_l; i++) { unsigned char *us = encode_utf_8(uni[i]); - add_to_str(&res, &res_l, us); + res_l = add_to_str(&res, res_l, us); } free(uni); @@ -1232,7 +1231,8 @@ idn_encode_host(unsigned char *host, int len, unsigned char *separator, int decode) { unsigned char *p, *s; - int pl, l, i; + int l, i; + size_t pl; p = NULL; pl = 0; @@ -1250,14 +1250,14 @@ next_host_elem: unsigned char *enc = puny_encode(host, l); if (!enc) goto err; - add_to_str(&p, &pl, enc); + pl = add_to_str(&p, pl, enc); free(enc); goto advance_host; } } else { unsigned char *dec = puny_decode(host, l); if (dec) { - add_to_str(&p, &pl, dec); + pl = add_to_str(&p, pl, dec); free(dec); goto advance_host; } @@ -1283,7 +1283,8 @@ unsigned char * idn_encode_url(unsigned char *url, int decode) { unsigned char *host, *p, *h; - int holen, pl; + int holen; + size_t pl; if (parse_url(url, NULL, NULL, NULL, NULL, NULL, &host, &holen, NULL, NULL, NULL, NULL, NULL) || !host) { @@ -1297,8 +1298,8 @@ idn_encode_url(unsigned char *url, int decode) p = NULL; pl = add_bytes_to_str(&p, 0, url, host - url); - add_to_str(&p, &pl, h); - add_to_str(&p, &pl, host + holen); + pl = add_to_str(&p, pl, h); + pl = add_to_str(&p, pl, host + holen); free(h); return p; } diff --git a/view.c b/view.c @@ -113,10 +113,8 @@ find_tag(struct f_data *f, unsigned char *name) struct tag *tag = NULL; struct list_head *ltag; unsigned char *tt; - int ll; tt = NULL; - ll = 0; - add_conv_str(&tt, &ll, name, (int)strlen(cast_const_char name), -2); + add_conv_str(&tt, 0, name, (int)strlen(cast_const_char name), -2); foreachback (struct tag, tag, ltag, f->tags) if (!casestrcmp(tag->name, tt) || (tag->name[0] == '#' @@ -1297,31 +1295,32 @@ dump_to_file(struct f_data *fd, int h) struct form_control *fc; struct link *lnk = &fd->links[i]; unsigned char *s = NULL; - int l = 0; - add_num_to_str(&s, &l, i + 1); - add_to_str(&s, &l, cast_uchar ". "); + size_t l; + l = add_num_to_str(&s, 0, i + 1); + l = add_to_str(&s, l, cast_uchar ". "); if (lnk->where) { - add_to_str(&s, &l, lnk->where); + l = add_to_str(&s, l, lnk->where); } else if (lnk->where_img) { - add_to_str(&s, &l, cast_uchar "Image: "); - add_to_str(&s, &l, lnk->where_img); + l = add_to_str(&s, l, cast_uchar "Image: "); + l = add_to_str(&s, l, lnk->where_img); } else if (lnk->type == L_BUTTON) { fc = lnk->form; if (fc->type == FC_RESET) - add_to_str(&s, &l, - cast_uchar "Reset form"); + l = add_to_str(&s, l, + cast_uchar "Reset form"); else if (fc->type == FC_BUTTON || !fc->action) - add_to_str(&s, &l, cast_uchar "Button"); + l = add_to_str(&s, l, + cast_uchar "Button"); else { if (fc->method == FM_GET) - add_to_str(&s, &l, - cast_uchar - "Submit form: "); + l = add_to_str(&s, l, + cast_uchar + "Submit form: "); else - add_to_str(&s, &l, - cast_uchar - "Post form: "); - add_to_str(&s, &l, fc->action); + l = add_to_str(&s, l, + cast_uchar + "Post form: "); + l = add_to_str(&s, l, fc->action); } } else if (lnk->type == L_CHECKBOX || lnk->type == L_SELECT @@ -1330,52 +1329,53 @@ dump_to_file(struct f_data *fd, int h) fc = lnk->form; switch (fc->type) { case FC_RADIO: - add_to_str(&s, &l, - cast_uchar "Radio button"); + l = add_to_str( + &s, l, cast_uchar "Radio button"); break; case FC_CHECKBOX: - add_to_str(&s, &l, - cast_uchar "Checkbox"); + l = add_to_str(&s, l, + cast_uchar "Checkbox"); break; case FC_SELECT: - add_to_str(&s, &l, - cast_uchar "Select field"); + l = add_to_str( + &s, l, cast_uchar "Select field"); break; case FC_TEXT: - add_to_str(&s, &l, - cast_uchar "Text field"); + l = add_to_str(&s, l, + cast_uchar "Text field"); break; case FC_TEXTAREA: - add_to_str(&s, &l, - cast_uchar "Text area"); + l = add_to_str(&s, l, + cast_uchar "Text area"); break; case FC_FILE_UPLOAD: - add_to_str(&s, &l, - cast_uchar "File upload"); + l = add_to_str( + &s, l, cast_uchar "File upload"); break; case FC_PASSWORD: - add_to_str(&s, &l, - cast_uchar "Password field"); + l = add_to_str( + &s, l, cast_uchar "Password field"); break; default: goto unknown; } if (fc->name && fc->name[0]) { - add_to_str(&s, &l, - cast_uchar ", Name "); - add_to_str(&s, &l, fc->name); + l = add_to_str(&s, l, + cast_uchar ", Name "); + l = add_to_str(&s, l, fc->name); } if ((fc->type == FC_CHECKBOX || fc->type == FC_RADIO) && fc->default_value && fc->default_value[0]) { - add_to_str(&s, &l, - cast_uchar ", Value "); - add_to_str(&s, &l, fc->default_value); + l = add_to_str(&s, l, + cast_uchar ", Value "); + l = add_to_str(&s, l, + fc->default_value); } } unknown: - add_to_str(&s, &l, cast_uchar "\n"); + l = add_to_str(&s, l, cast_uchar "\n"); if ((retval = hard_write(h, s, l)) != l) { free(s); goto fail; @@ -1692,13 +1692,13 @@ free_succesful_controls(struct list_head *submit) static unsigned char * encode_textarea(unsigned char *t) { - int len = 0; + size_t len = 0; unsigned char *o = NULL; for (; *t; t++) { if (*t != '\n') len = add_chr_to_str(&o, len, *t); else - add_to_str(&o, &len, cast_uchar "\r\n"); + len = add_to_str(&o, len, cast_uchar "\r\n"); } return o; } @@ -1729,7 +1729,6 @@ get_succesful_controls(struct f_data_c *f, struct form_control *fc, && *form->default_value ? -1 : 0; - int svl; fs = find_form_state(f, form); if ((form->type == FC_CHECKBOX || form->type == FC_RADIO) @@ -1772,8 +1771,7 @@ fi_rep: add_to_strn(&sub->name, fi ? cast_uchar ".x" : cast_uchar ".y"); sub->value = NULL; - svl = 0; - add_num_to_str(&sub->value, &svl, + add_num_to_str(&sub->value, 0, fi ? ismap_x : ismap_y); break; default: @@ -1835,51 +1833,53 @@ safe_char(unsigned char c) || (c >= 'a' && c <= 'z') || c == '.' || c == '-' || c == '_'; } -static void -encode_string(unsigned char *name, unsigned char **data, int *len) +static size_t +encode_string(unsigned char *name, unsigned char **data, size_t len) { for (; *name; name++) { if (*name == ' ') - *len = add_chr_to_str(data, *len, '+'); + len = add_chr_to_str(data, len, '+'); else if (safe_char(*name)) - *len = add_chr_to_str(data, *len, *name); + len = add_chr_to_str(data, len, *name); else { unsigned char n[4]; sprintf(cast_char n, "%%%02X", *name); - add_to_str(data, len, n); + len = add_to_str(data, len, n); } } + return len; } -static void -encode_controls(struct list_head *l, unsigned char **data, int *len) +static size_t +encode_controls(struct list_head *l, unsigned char **data) { struct submitted_value *sv = NULL; struct list_head *lsv; int lst = 0; unsigned char *p2; - *len = 0; + size_t len = 0; *data = NULL; foreach (struct submitted_value, sv, lsv, *l) { unsigned char *p = sv->value; if (lst) - *len = add_chr_to_str(data, *len, '&'); + len = add_chr_to_str(data, len, '&'); else lst = 1; - encode_string(sv->name, data, len); - *len = add_chr_to_str(data, *len, '='); + len = encode_string(sv->name, data, len); + len = add_chr_to_str(data, len, '='); p2 = stracpy(p); - encode_string(p2, data, len); + len = encode_string(p2, data, len); free(p2); } + return len; } #define BL 56 #define BL1 27 -static void +static size_t encode_multipart(struct session *ses, struct list_head *l, unsigned char **data, - int *len, unsigned char *bound) + unsigned char *bound) { int errn; int *bound_ptrs = NULL; @@ -1892,12 +1892,12 @@ encode_multipart(struct session *ses, struct list_head *l, unsigned char **data, unsigned char *p; int rs; memset(bound, 'x', BL); - *len = 0; + size_t len = 0; *data = NULL; foreach (struct submitted_value, sv, lsv, *l) { unsigned char *ct; bnd: - add_to_str(data, len, cast_uchar "--"); + len = add_to_str(data, len, cast_uchar "--"); if (!(nbound_ptrs & (ALLOC_GR - 1))) { if ((unsigned)nbound_ptrs > INT_MAX / sizeof(int) - ALLOC_GR) @@ -1905,43 +1905,44 @@ bnd: bound_ptrs = xrealloc( bound_ptrs, (nbound_ptrs + ALLOC_GR) * sizeof(int)); } - bound_ptrs[nbound_ptrs++] = *len; - *len = add_bytes_to_str(data, *len, bound, BL); + bound_ptrs[nbound_ptrs++] = len; + len = add_bytes_to_str(data, len, bound, BL); if (flg) break; - add_to_str(data, len, - cast_uchar - "\r\nContent-Disposition: form-data; name=\""); - add_to_str(data, len, sv->name); - add_to_str(data, len, cast_uchar "\""); + len = add_to_str(data, len, + cast_uchar + "\r\nContent-Disposition: form-data; name=\""); + len = add_to_str(data, len, sv->name); + len = add_to_str(data, len, cast_uchar "\""); if (sv->type == FC_FILE_UPLOAD) { - add_to_str(data, len, cast_uchar "; filename=\""); - add_to_str(data, len, strip_file_name(sv->value)); + len = add_to_str(data, len, cast_uchar "; filename=\""); + len = add_to_str(data, len, strip_file_name(sv->value)); /* It sends bad data if the file name contains ", but Netscape does the same */ - add_to_str(data, len, cast_uchar "\""); + len = add_to_str(data, len, cast_uchar "\""); if (*sv->value) if ((ct = get_content_type(NULL, sv->value))) { - add_to_str(data, len, - cast_uchar - "\r\nContent-Type: "); - add_to_str(data, len, ct); + len = add_to_str(data, len, + cast_uchar + "\r\nContent-Type: "); + len = add_to_str(data, len, ct); if (strlen(cast_const_char ct) >= 4 && !casecmp(ct, cast_uchar "text", 4)) { - add_to_str(data, len, - cast_uchar - "; charset="); - add_to_str(data, len, - get_cp_mime_name(0)); + len = add_to_str(data, len, + cast_uchar + "; charset="); + len = add_to_str( + data, len, + get_cp_mime_name(0)); } free(ct); } } - add_to_str(data, len, cast_uchar "\r\n\r\n"); + len = add_to_str(data, len, cast_uchar "\r\n\r\n"); if (sv->type != FC_FILE_UPLOAD) { p = stracpy(sv->value); - add_to_str(data, len, p); + len = add_to_str(data, len, p); free(p); } else { int fh, rd; @@ -1976,23 +1977,23 @@ bnd: goto error; } if (rd) - *len = add_bytes_to_str( - data, *len, buffer, rd); + len = add_bytes_to_str( + data, len, buffer, rd); } while (rd); EINTRLOOP(rs, close(fh)); } } - add_to_str(data, len, cast_uchar "\r\n"); + len = add_to_str(data, len, cast_uchar "\r\n"); } if (!flg) { flg = 1; goto bnd; } - add_to_str(data, len, cast_uchar "--\r\n"); + len = add_to_str(data, len, cast_uchar "--\r\n"); memset(bound, '-', BL1); memset(bound + BL1, '0', BL - BL1); again: - for (i = 0; i <= *len - BL; i++) { + for (i = 0; i <= len - BL; i++) { for (j = 0; j < BL; j++) if ((*data)[i + j] != bound[j]) goto nb; @@ -2010,7 +2011,7 @@ nb:; for (i = 0; i < nbound_ptrs; i++) memcpy(*data + bound_ptrs[i], bound, BL); free(bound_ptrs); - return; + return len; error: free(bound_ptrs); @@ -2023,7 +2024,7 @@ error: TEXT_(T_COULD_NOT_GET_FILE), cast_uchar " ", m1, cast_uchar ": ", m2, MSG_BOX_END, (void *)ses, 1, TEXT_(T_CANCEL), msg_box_null, B_ENTER | B_ESC); - return; + return len; not_allowed: free(bound_ptrs); @@ -2032,6 +2033,7 @@ not_allowed: msg_box(ses->term, NULL, TEXT_(T_ERROR_WHILE_POSTING_FORM), AL_CENTER, TEXT_(T_READING_FILES_IS_NOT_ALLOWED), MSG_BOX_END, (void *)ses, 1, TEXT_(T_CANCEL), msg_box_null, B_ENTER | B_ESC); + return len; } void @@ -2068,9 +2070,9 @@ get_form_url(struct session *ses, struct f_data_c *f, struct form_control *form, return NULL; get_succesful_controls(f, form, &submit); if (form->method == FM_GET || form->method == FM_POST) - encode_controls(&submit, &data, &len); + len = encode_controls(&submit, &data); else - encode_multipart(ses, &submit, &data, &len, bound); + len = encode_multipart(ses, &submit, &data, bound); if (!data) goto ff; if (!casecmp(form->action, cast_uchar "javascript:", 11)) { @@ -2097,25 +2099,26 @@ get_form_url(struct session *ses, struct f_data_c *f, struct form_control *form, free(pos); } } else { - int l = 0; + size_t l; int i; go = NULL; - add_to_str(&go, &l, form->action); + l = add_to_str(&go, 0, form->action); l = add_chr_to_str(&go, l, POST_CHAR); if (form->method == FM_POST) - add_to_str(&go, &l, - cast_uchar - "application/x-www-form-urlencoded\n"); + l = add_to_str(&go, l, + cast_uchar + "application/x-www-form-urlencoded\n"); else { - add_to_str(&go, &l, - cast_uchar "multipart/form-data; boundary="); + l = add_to_str(&go, l, + cast_uchar + "multipart/form-data; boundary="); l = add_bytes_to_str(&go, l, bound, BL); - add_to_str(&go, &l, cast_uchar "\n"); + l = add_to_str(&go, l, cast_uchar "\n"); } for (i = 0; i < len; i++) { unsigned char p[3]; sprintf(cast_char p, "%02x", (int)data[i]); - add_to_str(&go, &l, p); + l = add_to_str(&go, l, p); } } x: @@ -2145,12 +2148,12 @@ get_link_url(struct session *ses, struct f_data_c *f, struct link *l, + strlen(cast_const_char l->where) - 4), "?0,0")) { unsigned char *nu = NULL; - int ll = add_bytes_to_str( + size_t ll = add_bytes_to_str( &nu, 0, l->where, strlen(cast_const_char l->where) - 3); - add_num_to_str(&nu, &ll, ismap_x); + ll = add_num_to_str(&nu, ll, ismap_x); ll = add_chr_to_str(&nu, ll, ','); - add_num_to_str(&nu, &ll, ismap_y); + ll = add_num_to_str(&nu, ll, ismap_y); return nu; } return stracpy(l->where); @@ -3828,7 +3831,7 @@ send_open_in_new_xterm(struct terminal *term, void *open_window_, void *ses_) free(ses->dn_url); if ((ses->dn_url = get_link_url(ses, fd, l, NULL))) { unsigned char *p; - int pl; + size_t pl; unsigned char *enc_url; unsigned char *path; @@ -3840,23 +3843,21 @@ send_open_in_new_xterm(struct terminal *term, void *open_window_, void *ses_) } p = NULL; - pl = 0; - - add_to_str(&p, &pl, cast_uchar "-base-session "); - add_num_to_str(&p, &pl, ses->id); + pl = add_to_str(&p, 0, cast_uchar "-base-session "); + pl = add_num_to_str(&p, pl, ses->id); pl = add_chr_to_str(&p, pl, ' '); if (ses->wtd_target && *ses->wtd_target) { unsigned char *tgt = stracpy(ses->wtd_target); check_shell_security(&tgt); - add_to_str(&p, &pl, cast_uchar "-target "); - add_to_str(&p, &pl, tgt); + pl = add_to_str(&p, pl, cast_uchar "-target "); + pl = add_to_str(&p, pl, tgt); pl = add_chr_to_str(&p, pl, ' '); free(tgt); } enc_url = encode_url(ses->dn_url); - add_to_str(&p, &pl, enc_url); + pl = add_to_str(&p, pl, enc_url); free(enc_url); path = escape_path(g_argv[0]); if (open_window(term, path, p)) @@ -3875,10 +3876,10 @@ send_open_new_xterm(struct terminal *term, void *open_window_, void *ses_) unsigned char *))open_window_; struct session *ses = ses_; unsigned char *p = NULL; - int pl = 0; + size_t pl; unsigned char *path; - add_to_str(&p, &pl, cast_uchar "-base-session "); - add_num_to_str(&p, &pl, ses->id); + pl = add_to_str(&p, 0, cast_uchar "-base-session "); + pl = add_num_to_str(&p, pl, ses->id); path = escape_path(g_argv[0]); if (open_window(term, path, p)) cant_open_new_window(term); @@ -4147,7 +4148,7 @@ static unsigned char * print_current_titlex(struct f_data_c *fd, int w) { int mul, pul; - int ml = 0, pl = 0; + size_t ml = 0, pl = 0; unsigned char *m, *p; if (!fd || !fd->vs || !fd->f_data) return NULL; @@ -4166,22 +4167,22 @@ print_current_titlex(struct f_data_c *fd, int w) pp = pe; if (fd->f_data->title) pl = add_chr_to_str(&p, pl, ' '); - add_to_str( - &p, &pl, + pl = add_to_str( + &p, pl, get_text_translation(TEXT_(T_PAGE_P), fd->ses->term)); - add_num_to_str(&p, &pl, pp); - add_to_str( - &p, &pl, + pl = add_num_to_str(&p, pl, pp); + pl = add_to_str( + &p, pl, get_text_translation(TEXT_(T_PAGE_OF), fd->ses->term)); - add_num_to_str(&p, &pl, pe); - add_to_str( - &p, &pl, + pl = add_num_to_str(&p, pl, pe); + pl = add_to_str( + &p, pl, get_text_translation(TEXT_(T_PAGE_CL), fd->ses->term)); } if (!fd->f_data->title) return p; m = NULL; - add_to_str(&m, &ml, fd->f_data->title); + ml = add_to_str(&m, ml, fd->f_data->title); mul = strlen((char *)m); if (p != NULL) pul = strlen((char *)p); @@ -4196,7 +4197,7 @@ print_current_titlex(struct f_data_c *fd, int w) ml = (int)(mm - m); } if (p != NULL) - add_to_str(&m, &ml, p); + ml = add_to_str(&m, ml, p); free(p); return m; } @@ -4204,7 +4205,7 @@ print_current_titlex(struct f_data_c *fd, int w) static unsigned char * print_current_linkx(struct f_data_c *fd, struct terminal *term) { - int ll = 0; + size_t ll = 0; struct link *l; unsigned char *d; unsigned char *m = NULL; @@ -4225,15 +4226,15 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) txt = convert(fd->f_data->cp, fd->f_data->opt.cp, l->img_alt, &fd->f_data->opt); - add_to_str(&m, &ll, txt); + ll = add_to_str(&m, ll, txt); free(txt); } else { - add_to_str( - &m, &ll, + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_IMAGE), term)); ll = add_chr_to_str(&m, ll, ' '); d = display_url(term, l->where_img, 1); - add_to_str(&m, &ll, d); + ll = add_to_str(&m, ll, d); free(d); } goto p; @@ -4242,11 +4243,12 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) && !casecmp(l->where, cast_uchar "MAP@", 4)) { m = NULL; ll = 0; - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_USEMAP), term)); + ll = add_to_str( + &m, ll, + get_text_translation(TEXT_(T_USEMAP), term)); ll = add_chr_to_str(&m, ll, ' '); d = display_url(term, l->where + 4, 1); - add_to_str(&m, &ll, d); + ll = add_to_str(&m, ll, d); free(d); goto p; } @@ -4262,9 +4264,8 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) if (l->type == L_BUTTON) { if (l->form->type == FC_BUTTON) { m = NULL; - ll = 0; - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_BUTTON), term)); + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_BUTTON), term)); goto p; } if (l->form->type == FC_RESET) { @@ -4275,95 +4276,93 @@ print_current_linkx(struct f_data_c *fd, struct terminal *term) if (!l->form->action) return NULL; m = NULL; - ll = 0; if (l->form->method == FM_GET) - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_SUBMIT_FORM_TO), - term)); + ll = add_to_str(&m, 0, + get_text_translation( + TEXT_(T_SUBMIT_FORM_TO), term)); else - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_POST_FORM_TO), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->action); + ll = add_to_str(&m, ll, l->form->action); goto p; } if (l->type == L_CHECKBOX || l->type == L_SELECT || l->type == L_FIELD || l->type == L_AREA) { m = NULL; - ll = 0; switch (l->form->type) { case FC_RADIO: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_RADIO_BUTTON), term)); break; case FC_CHECKBOX: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_CHECKBOX), term)); break; case FC_SELECT: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_SELECT_FIELD), term)); break; case FC_TEXT: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_TEXT_FIELD), term)); break; case FC_TEXTAREA: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_TEXT_AREA), term)); break; case FC_FILE_UPLOAD: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_FILE_UPLOAD), term)); break; case FC_PASSWORD: - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_PASSWORD_FIELD), - term)); + ll = add_to_str(&m, 0, + get_text_translation( + TEXT_(T_PASSWORD_FIELD), term)); break; default: return NULL; } if (l->form->name && l->form->name[0]) { - add_to_str(&m, &ll, cast_uchar ", "); - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_NAME), term)); + ll = add_to_str(&m, ll, cast_uchar ", "); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_NAME), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->name); + ll = add_to_str(&m, ll, l->form->name); } if ((l->form->type == FC_CHECKBOX || l->form->type == FC_RADIO) && l->form->default_value && l->form->default_value[0]) { - add_to_str(&m, &ll, cast_uchar ", "); - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_VALUE), term)); + ll = add_to_str(&m, ll, cast_uchar ", "); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_VALUE), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->default_value); + ll = add_to_str(&m, ll, l->form->default_value); } /* pri enteru se bude posilat vzdycky -- Brain */ if (l->type == L_FIELD && !has_form_submit(fd->f_data, l->form) && l->form->action) { - add_to_str(&m, &ll, cast_uchar ", "); - add_to_str( - &m, &ll, + ll = add_to_str(&m, ll, cast_uchar ", "); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_HIT_ENTER_TO), term)); ll = add_chr_to_str(&m, ll, ' '); if (l->form->method == FM_GET) - add_to_str(&m, &ll, - get_text_translation( - TEXT_(T_SUBMIT_TO), term)); + ll = add_to_str(&m, ll, + get_text_translation( + TEXT_(T_SUBMIT_TO), term)); else - add_to_str(&m, &ll, - get_text_translation( - TEXT_(T_POST_TO), term)); + ll = add_to_str(&m, ll, + get_text_translation( + TEXT_(T_POST_TO), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->action); + ll = add_to_str(&m, ll, l->form->action); } goto p; } @@ -4380,7 +4379,7 @@ p: static unsigned char * print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) { - int ll = 0; + size_t ll = 0; struct link *l; unsigned char *d; unsigned char *m = NULL; @@ -4397,45 +4396,46 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) ll = 0; if (l->where && strlen(cast_const_char l->where) >= 4 && !casecmp(l->where, cast_uchar "MAP@", 4)) { - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_USEMAP), term)); + ll = add_to_str( + &m, ll, + get_text_translation(TEXT_(T_USEMAP), term)); ll = add_chr_to_str(&m, ll, ' '); d = display_url(term, l->where + 4, 1); - add_to_str(&m, &ll, d); + ll = add_to_str(&m, ll, d); free(d); } else if (l->where) { d = display_url(term, l->where, 1); - add_to_str(&m, &ll, d); + ll = add_to_str(&m, ll, d); free(d); } spc = stracpy((unsigned char *)""); if (spc && *spc) { - add_to_str(&m, &ll, cast_uchar "\n"); - add_to_str( - &m, &ll, + ll = add_to_str(&m, ll, cast_uchar "\n"); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_JAVASCRIPT), term)); - add_to_str(&m, &ll, cast_uchar ": "); - add_to_str(&m, &ll, spc); + ll = add_to_str(&m, ll, cast_uchar ": "); + ll = add_to_str(&m, ll, spc); } free(spc); if (l->where_img) { - add_to_str(&m, &ll, cast_uchar "\n"); - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_IMAGE), term)); - add_to_str(&m, &ll, cast_uchar ": src='"); + ll = add_to_str(&m, ll, cast_uchar "\n"); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_IMAGE), term)); + ll = add_to_str(&m, ll, cast_uchar ": src='"); d = display_url(term, l->where_img, 1); - add_to_str(&m, &ll, d); + ll = add_to_str(&m, ll, d); free(d); ll = add_chr_to_str(&m, ll, '\''); if (l->img_alt) { unsigned char *txt; - add_to_str(&m, &ll, cast_uchar " alt='"); + ll = add_to_str(&m, ll, cast_uchar " alt='"); txt = convert(fd->f_data->cp, fd->f_data->opt.cp, l->img_alt, &fd->f_data->opt); - add_to_str(&m, &ll, txt); + ll = add_to_str(&m, ll, txt); ll = add_chr_to_str(&m, ll, '\''); free(txt); } @@ -4448,9 +4448,8 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) if (l->type == L_BUTTON) { if (l->form->type == FC_BUTTON) { m = NULL; - ll = 0; - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_BUTTON), term)); + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_BUTTON), term)); goto p; } if (l->form->type == FC_RESET) { @@ -4461,95 +4460,93 @@ print_current_linkx_plus(struct f_data_c *fd, struct terminal *term) if (!l->form->action) return NULL; m = NULL; - ll = 0; if (l->form->method == FM_GET) - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_SUBMIT_FORM_TO), - term)); + ll = add_to_str(&m, 0, + get_text_translation( + TEXT_(T_SUBMIT_FORM_TO), term)); else - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_POST_FORM_TO), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->action); + ll = add_to_str(&m, ll, l->form->action); goto p; } if (l->type == L_CHECKBOX || l->type == L_SELECT || l->type == L_FIELD || l->type == L_AREA) { m = NULL; - ll = 0; switch (l->form->type) { case FC_RADIO: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_RADIO_BUTTON), term)); break; case FC_CHECKBOX: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_CHECKBOX), term)); break; case FC_SELECT: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_SELECT_FIELD), term)); break; case FC_TEXT: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_TEXT_FIELD), term)); break; case FC_TEXTAREA: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_TEXT_AREA), term)); break; case FC_FILE_UPLOAD: - add_to_str( - &m, &ll, + ll = add_to_str( + &m, 0, get_text_translation(TEXT_(T_FILE_UPLOAD), term)); break; case FC_PASSWORD: - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_PASSWORD_FIELD), - term)); + ll = add_to_str(&m, 0, + get_text_translation( + TEXT_(T_PASSWORD_FIELD), term)); break; default: return NULL; } if (l->form->name && l->form->name[0]) { - add_to_str(&m, &ll, cast_uchar ", "); - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_NAME), term)); + ll = add_to_str(&m, ll, cast_uchar ", "); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_NAME), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->name); + ll = add_to_str(&m, ll, l->form->name); } if ((l->form->type == FC_CHECKBOX || l->form->type == FC_RADIO) && l->form->default_value && l->form->default_value[0]) { - add_to_str(&m, &ll, cast_uchar ", "); - add_to_str(&m, &ll, - get_text_translation(TEXT_(T_VALUE), term)); + ll = add_to_str(&m, ll, cast_uchar ", "); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_VALUE), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->default_value); + ll = add_to_str(&m, ll, l->form->default_value); } /* pri enteru se bude posilat vzdycky -- Brain */ if (l->type == L_FIELD && !has_form_submit(fd->f_data, l->form) && l->form->action) { - add_to_str(&m, &ll, cast_uchar ", "); - add_to_str( - &m, &ll, + ll = add_to_str(&m, ll, cast_uchar ", "); + ll = add_to_str( + &m, ll, get_text_translation(TEXT_(T_HIT_ENTER_TO), term)); ll = add_chr_to_str(&m, ll, ' '); if (l->form->method == FM_GET) - add_to_str(&m, &ll, - get_text_translation( - TEXT_(T_SUBMIT_TO), term)); + ll = add_to_str(&m, ll, + get_text_translation( + TEXT_(T_SUBMIT_TO), term)); else - add_to_str(&m, &ll, - get_text_translation( - TEXT_(T_POST_TO), term)); + ll = add_to_str(&m, ll, + get_text_translation( + TEXT_(T_POST_TO), term)); ll = add_chr_to_str(&m, ll, ' '); - add_to_str(&m, &ll, l->form->action); + ll = add_to_str(&m, ll, l->form->action); } goto p; } @@ -4574,7 +4571,7 @@ loc_msg(struct terminal *term, struct location *lo, struct f_data_c *frame) { struct cache_entry *ce; unsigned char *s; - int l = 0; + int l; unsigned char *a; if (!lo || !frame || !frame->vs || !frame->f_data) { msg_box(term, NULL, TEXT_(T_INFO), AL_LEFT, @@ -4583,154 +4580,159 @@ loc_msg(struct terminal *term, struct location *lo, struct f_data_c *frame) return; } s = NULL; - add_to_str(&s, &l, get_text_translation(TEXT_(T_URL), term)); - add_to_str(&s, &l, cast_uchar ": "); + l = add_to_str(&s, 0, get_text_translation(TEXT_(T_URL), term)); + l = add_to_str(&s, l, cast_uchar ": "); a = display_url(term, lo->url, 1); - add_to_str(&s, &l, a); + l = add_to_str(&s, l, a); free(a); if (!find_in_cache(lo->url, &ce)) { unsigned char *start; size_t len; if (ce->ip_address) { - add_to_str(&s, &l, cast_uchar "\n"); + l = add_to_str(&s, l, cast_uchar "\n"); if (!strchr(cast_const_char ce->ip_address, ' ')) - add_to_str(&s, &l, - get_text_translation( - TEXT_(T_IP_ADDRESS), term)); + l = add_to_str(&s, l, + get_text_translation( + TEXT_(T_IP_ADDRESS), term)); else - add_to_str(&s, &l, - get_text_translation( - TEXT_(T_IP_ADDRESSES), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, ce->ip_address); + l = add_to_str( + &s, l, + get_text_translation(TEXT_(T_IP_ADDRESSES), + term)); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, ce->ip_address); } - add_to_str(&s, &l, cast_uchar "\n"); - add_to_str(&s, &l, get_text_translation(TEXT_(T_SIZE), term)); - add_to_str(&s, &l, cast_uchar ": "); + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_to_str(&s, l, + get_text_translation(TEXT_(T_SIZE), term)); + l = add_to_str(&s, l, cast_uchar ": "); get_file_by_term(NULL, ce, &start, &len, NULL); if (ce->decompressed) { unsigned char *enc; add_unsigned_long_num_to_str(&s, &l, len); enc = get_content_encoding(ce->head, ce->url, 0); if (enc) { - add_to_str(&s, &l, cast_uchar " ("); - add_num_to_str(&s, &l, ce->length); + l = add_to_str(&s, l, cast_uchar " ("); + l = add_num_to_str(&s, l, ce->length); l = add_chr_to_str(&s, l, ' '); - add_to_str(&s, &l, - get_text_translation( - TEXT_(T_COMPRESSED_WITH), term)); + l = add_to_str( + &s, l, + get_text_translation( + TEXT_(T_COMPRESSED_WITH), term)); l = add_chr_to_str(&s, l, ' '); - add_to_str(&s, &l, enc); + l = add_to_str(&s, l, enc); l = add_chr_to_str(&s, l, ')'); free(enc); } } else { - add_num_to_str(&s, &l, ce->length); + l = add_num_to_str(&s, l, ce->length); } if (ce->incomplete) { - add_to_str(&s, &l, cast_uchar " ("); - add_to_str( - &s, &l, + l = add_to_str(&s, l, cast_uchar " ("); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_INCOMPLETE), term)); l = add_chr_to_str(&s, l, ')'); } if (frame->f_data->ass >= 0) { - add_to_str(&s, &l, cast_uchar "\n"); - add_to_str( - &s, &l, + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_CODEPAGE), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, get_cp_name(frame->f_data->cp)); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, get_cp_name(frame->f_data->cp)); if (frame->f_data->ass == 1) { - add_to_str(&s, &l, cast_uchar " ("); - add_to_str(&s, &l, - get_text_translation( - TEXT_(T_ASSUMED), term)); + l = add_to_str(&s, l, cast_uchar " ("); + l = add_to_str(&s, l, + get_text_translation( + TEXT_(T_ASSUMED), term)); l = add_chr_to_str(&s, l, ')'); } if (frame->f_data->ass == 2) { - add_to_str(&s, &l, cast_uchar " ("); - add_to_str(&s, &l, - get_text_translation( - TEXT_(T_IGNORING_SERVER_SETTING), - term)); + l = add_to_str(&s, l, cast_uchar " ("); + l = add_to_str( + &s, l, + get_text_translation( + TEXT_(T_IGNORING_SERVER_SETTING), + term)); l = add_chr_to_str(&s, l, ')'); } } if (ce->head && ce->head[0] != '\n' && ce->head[0] != '\r' && (a = parse_http_header( ce->head, cast_uchar "Content-Type", NULL))) { - add_to_str(&s, &l, cast_uchar "\n"); - add_to_str( - &s, &l, + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_CONTENT_TYPE), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, a); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, a); free(a); } if ((a = parse_http_header(ce->head, cast_uchar "Server", NULL))) { - add_to_str(&s, &l, cast_uchar "\n"); - add_to_str(&s, &l, - get_text_translation(TEXT_(T_SERVER), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, a); + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_SERVER), term)); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, a); free(a); } if ((a = parse_http_header(ce->head, cast_uchar "Date", NULL))) { - add_to_str(&s, &l, cast_uchar "\n"); - add_to_str(&s, &l, - get_text_translation(TEXT_(T_DATE), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, a); + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_DATE), term)); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, a); free(a); } if ((a = parse_http_header(ce->head, cast_uchar "Last-Modified", NULL))) { - add_to_str(&s, &l, cast_uchar "\n"); - add_to_str( - &s, &l, + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_LAST_MODIFIED), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, a); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, a); free(a); } if (ce->ssl_info) { - add_to_str(&s, &l, cast_uchar "\n"); - add_to_str( - &s, &l, + l = add_to_str(&s, l, cast_uchar "\n"); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_SSL_CIPHER), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, ce->ssl_info); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, ce->ssl_info); } if (ce->ssl_authority) { - add_to_str(&s, &l, cast_uchar "\n"); + l = add_to_str(&s, l, cast_uchar "\n"); if (strstr(cast_const_char ce->ssl_authority, cast_const_char CERT_RIGHT_ARROW)) - add_to_str(&s, &l, - get_text_translation( - TEXT_(T_CERTIFICATE_AUTHORITIES), - term)); + l = add_to_str( + &s, l, + get_text_translation( + TEXT_(T_CERTIFICATE_AUTHORITIES), + term)); else - add_to_str( - &s, &l, + l = add_to_str( + &s, l, get_text_translation( TEXT_(T_CERTIFICATE_AUTHORITY), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, ce->ssl_authority); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, ce->ssl_authority); } ce->refcount--; } if ((a = print_current_linkx_plus(frame, term))) { - add_to_str(&s, &l, cast_uchar "\n\n"); + l = add_to_str(&s, l, cast_uchar "\n\n"); if (*a != '\n') { - add_to_str(&s, &l, - get_text_translation(TEXT_(T_LINK), term)); - add_to_str(&s, &l, cast_uchar ": "); - add_to_str(&s, &l, a); + l = add_to_str( + &s, l, get_text_translation(TEXT_(T_LINK), term)); + l = add_to_str(&s, l, cast_uchar ": "); + l = add_to_str(&s, l, a); } else - add_to_str(&s, &l, a + 1); + l = add_to_str(&s, l, a + 1); free(a); } msg_box(term, getml(s, NULL), TEXT_(T_INFO), AL_LEFT, s, MSG_BOX_END,