"Fossies" - the Fresh Open Source Software Archive

Member "links-1.04/menu.c" (8 Feb 2018, 47864 Bytes) of package /linux/www/links-1.04.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "menu.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.03_vs_1.04.

    1 #include "links.h"
    2 
    3 static unsigned char *version_texts[] = {
    4     TEXT_(T_LINKS_VERSION),
    5     TEXT_(T_OPERATING_SYSTEM_TYPE),
    6     TEXT_(T_OPERATING_SYSTEM_VERSION),
    7     TEXT_(T_COMPILER),
    8     TEXT_(T_WORD_SIZE),
    9     TEXT_(T_ENCRYPTION),
   10 #if defined(__linux__) || defined(__SPAD__) || defined(USE_GPM)
   11     TEXT_(T_GPM_MOUSE_DRIVER),
   12 #endif
   13 #ifdef OS2
   14     TEXT_(T_XTERM_FOR_OS2),
   15 #endif
   16     NULL,
   17 };
   18 
   19 void add_and_pad(unsigned char **s, int *l, struct terminal *term, unsigned char *str, int maxlen)
   20 {
   21     unsigned char *x = _(str, term);
   22     int len = strlen(x);
   23     add_to_str(s, l, x);
   24     add_to_str(s, l, ":  ");
   25     while (len++ < maxlen) add_chr_to_str(s, l, ' ');
   26 }
   27 
   28 void menu_version(struct terminal *term)
   29 {
   30     int i;
   31     int maxlen = 0;
   32     unsigned char *s;
   33     int l;
   34     unsigned char **text_ptr;
   35     for (i = 0; version_texts[i]; i++) {
   36         unsigned char *t = _(version_texts[i], term);
   37         int tl = strlen(t);
   38         if (tl > maxlen)
   39             maxlen = tl;
   40     }
   41 
   42     s = init_str();
   43     l = 0;
   44     text_ptr = version_texts;
   45 
   46     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   47     add_to_str(&s, &l, VERSION_STRING);
   48     add_to_str(&s, &l, "\n");
   49 
   50     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   51     add_to_str(&s, &l, SYSTEM_NAME);
   52     add_to_str(&s, &l, "\n");
   53 
   54     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   55     add_to_str(&s, &l, system_name);
   56     add_to_str(&s, &l, "\n");
   57 
   58     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   59     add_to_str(&s, &l, compiler_name);
   60     add_to_str(&s, &l, "\n");
   61 
   62     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   63     add_to_str(&s, &l, _(TEXT_(T_MEMORY), term));
   64     add_to_str(&s, &l, " ");
   65     add_num_to_str(&s, &l, sizeof(void *) * 8);
   66     add_to_str(&s, &l, "-bit, ");
   67     add_to_str(&s, &l, _(TEXT_(T_FILE_SIZE), term));
   68     add_to_str(&s, &l, " ");
   69     add_num_to_str(&s, &l, sizeof(off_t) * 8 /*- ((off_t)-1 < 0)*/);
   70     add_to_str(&s, &l, "-bit");
   71     add_to_str(&s, &l, "\n");
   72 
   73     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   74 #ifdef HAVE_SSL
   75     add_to_str(&s, &l, (unsigned char *)SSLeay_version(SSLEAY_VERSION));
   76 #else
   77     add_to_str(&s, &l, _(TEXT_(T_NO), term));
   78 #endif
   79     add_to_str(&s, &l, "\n");
   80 
   81 #if defined(__linux__) || defined(__SPAD__) || defined(USE_GPM)
   82     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   83 #ifdef USE_GPM
   84     add_gpm_version(&s, &l);
   85 #else
   86     add_to_str(&s, &l, _(TEXT_(T_NO), term));
   87 #endif
   88     add_to_str(&s, &l, "\n");
   89 #endif
   90 
   91 #ifdef OS2
   92     add_and_pad(&s, &l, term, *text_ptr++, maxlen);
   93 #ifdef X2
   94     add_to_str(&s, &l, _(TEXT_(T_YES), term));
   95 #else
   96     add_to_str(&s, &l, _(TEXT_(T_NO), term));
   97 #endif
   98     add_to_str(&s, &l, "\n");
   99 #endif
  100 
  101     s[l - 1] = 0;
  102     if (*text_ptr)
  103         internal("menu_version: text mismatched");
  104     
  105     msg_box(term, getml(s, NULL), TEXT_(T_VERSION_INFORMATION), AL_LEFT, s, NULL, 1, TEXT_(T_OK), NULL, B_ENTER | B_ESC);
  106 }
  107 
  108 void menu_about(struct terminal *term, void *d, struct session *ses)
  109 {
  110     msg_box(term, NULL, TEXT_(T_ABOUT), AL_CENTER, TEXT_(T_LINKS__LYNX_LIKE), term, 2, TEXT_(T_OK), NULL, B_ENTER | B_ESC, TEXT_(T_VERSION), menu_version, 0);
  111 }
  112 
  113 void menu_keys(struct terminal *term, void *d, struct session *ses)
  114 {
  115     msg_box(term, NULL, TEXT_(T_KEYS), AL_LEFT, TEXT_(T_KEYS_DESC), NULL, 1, TEXT_(T_OK), NULL, B_ENTER | B_ESC);
  116 }
  117 
  118 void menu_copying(struct terminal *term, void *d, struct session *ses)
  119 {
  120     msg_box(term, NULL, TEXT_(T_COPYING), AL_CENTER, TEXT_(T_COPYING_DESC), NULL, 1, TEXT_(T_OK), NULL, B_ENTER | B_ESC);
  121 }
  122 
  123 void menu_manual(struct terminal *term, void *d, struct session *ses)
  124 {
  125     goto_url(ses, LINKS_MANUAL_URL);
  126 }
  127 
  128 void menu_for_frame(struct terminal *term, void (*f)(struct session *, struct f_data_c *, int), struct session *ses)
  129 {
  130     do_for_frame(ses, f, 0);
  131 }
  132 
  133 void menu_goto_url(struct terminal *term, void *d, struct session *ses)
  134 {
  135     dialog_goto_url(ses, "");
  136 }
  137 
  138 void menu_save_url_as(struct terminal *term, void *d, struct session *ses)
  139 {
  140     dialog_save_url(ses);
  141 }
  142 
  143 void menu_go_back(struct terminal *term, void *d, struct session *ses)
  144 {
  145     go_back(ses);
  146 }
  147 
  148 void menu_reload(struct terminal *term, void *d, struct session *ses)
  149 {
  150     reload(ses, -1);
  151 }
  152 
  153 void really_exit_prog(struct session *ses)
  154 {
  155     register_bottom_half((void (*)(void *))destroy_terminal, ses->term);
  156 }
  157 
  158 void dont_exit_prog(struct session *ses)
  159 {
  160     ses->exit_query = 0;
  161 }
  162 
  163 void query_exit(struct session *ses)
  164 {
  165     ses->exit_query = 1;
  166     msg_box(ses->term, NULL, TEXT_(T_EXIT_LINKS), AL_CENTER, (ses->term->next == ses->term->prev && are_there_downloads()) ? TEXT_(T_DO_YOU_REALLY_WANT_TO_EXIT_LINKS_AND_TERMINATE_ALL_DOWNLOADS) : TEXT_(T_DO_YOU_REALLY_WANT_TO_EXIT_LINKS), ses, 2, TEXT_(T_YES), (void (*)(void *))really_exit_prog, B_ENTER, TEXT_(T_NO), dont_exit_prog, B_ESC);
  167 }
  168 
  169 void exit_prog(struct terminal *term, void *d, struct session *ses)
  170 {
  171     if (!ses) {
  172         register_bottom_half((void (*)(void *))destroy_terminal, term);
  173         return;
  174     }
  175     if (!ses->exit_query && (!d || (term->next == term->prev && are_there_downloads()))) {
  176         query_exit(ses);
  177         return;
  178     }
  179     really_exit_prog(ses);
  180 }
  181 
  182 struct refresh {
  183     struct terminal *term;
  184     struct window *win;
  185     struct session *ses;
  186     void (*fn)(struct terminal *term, void *d, struct session *ses);
  187     void *data;
  188     int timer;
  189 };
  190 
  191 void refresh(struct refresh *r)
  192 {
  193     struct refresh rr;
  194     r->timer = -1;
  195     memcpy(&rr, r, sizeof(struct refresh));
  196     delete_window(r->win);
  197     rr.fn(rr.term, rr.data, rr.ses);
  198 }
  199 
  200 void end_refresh(struct refresh *r)
  201 {
  202     if (r->timer != -1) kill_timer(r->timer);
  203     mem_free(r);
  204 }
  205 
  206 void refresh_abort(struct dialog_data *dlg)
  207 {
  208     end_refresh(dlg->dlg->udata2);
  209 }
  210 
  211 void cache_inf(struct terminal *term, void *d, struct session *ses)
  212 {
  213     unsigned char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9, *a10, *a11, *a12, *a13, *a14, *a15, *a16;
  214     int l = 0;
  215     struct refresh *r;
  216 
  217     r = mem_alloc(sizeof(struct refresh));
  218     r->term = term;
  219     r->win = NULL;
  220     r->ses = ses;
  221     r->fn = cache_inf;
  222     r->data = d;
  223     r->timer = -1;
  224     l = 0;
  225     l = 0, a1 = init_str(); add_to_str(&a1, &l, ": "); add_unsigned_long_num_to_str(&a1, &l, select_info(CI_FILES));add_to_str(&a1, &l, " ");
  226     l = 0, a2 = init_str(); add_to_str(&a2, &l, ", "); add_unsigned_long_num_to_str(&a2, &l, select_info(CI_TIMERS));add_to_str(&a2, &l, " ");
  227     l = 0, a3 = init_str(); add_to_str(&a3, &l, ".\n");
  228 
  229     l = 0, a4 = init_str(); add_to_str(&a4, &l, ": "); add_unsigned_long_num_to_str(&a4, &l, connect_info(CI_FILES));add_to_str(&a4, &l, " ");
  230     l = 0, a5 = init_str(); add_to_str(&a5, &l, ", "); add_unsigned_long_num_to_str(&a5, &l, connect_info(CI_CONNECTING));add_to_str(&a5, &l, " ");
  231     l = 0, a6 = init_str(); add_to_str(&a6, &l, ", "); add_unsigned_long_num_to_str(&a6, &l, connect_info(CI_TRANSFER));add_to_str(&a6, &l, " ");
  232     l = 0, a7 = init_str(); add_to_str(&a7, &l, ", "); add_unsigned_long_num_to_str(&a7, &l, connect_info(CI_KEEP));add_to_str(&a7, &l, " ");
  233     l = 0, a8 = init_str(); add_to_str(&a8, &l, ".\n");
  234 
  235     l = 0, a9 = init_str(); add_to_str(&a9, &l, ": "); add_unsigned_long_num_to_str(&a9, &l, cache_info(CI_BYTES));add_to_str(&a9, &l, " ");
  236     l = 0, a10 = init_str(); add_to_str(&a10, &l, ", "); add_unsigned_long_num_to_str(&a10, &l, cache_info(CI_FILES));add_to_str(&a10, &l, " ");
  237     l = 0, a11 = init_str(); add_to_str(&a11, &l, ", "); add_unsigned_long_num_to_str(&a11, &l, cache_info(CI_LOCKED));add_to_str(&a11, &l, " ");
  238     l = 0, a12 = init_str(); add_to_str(&a12, &l, ", "); add_unsigned_long_num_to_str(&a12, &l, cache_info(CI_LOADING));add_to_str(&a12, &l, " ");
  239     l = 0, a13 = init_str(); add_to_str(&a13, &l, ".\n");
  240 
  241     l = 0, a14 = init_str(); add_to_str(&a14, &l, ": "); add_unsigned_long_num_to_str(&a14, &l, formatted_info(CI_FILES));add_to_str(&a14, &l, " ");
  242     l = 0, a15 = init_str(); add_to_str(&a15, &l, ", "); add_unsigned_long_num_to_str(&a15, &l, formatted_info(CI_LOCKED));add_to_str(&a15, &l, " ");
  243     l = 0, a16 = init_str(); add_to_str(&a16, &l, ".");
  244 
  245     msg_box(term, getml(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, NULL), TEXT_(T_RESOURCES), AL_LEFT | AL_EXTD_TEXT, TEXT_(T_RESOURCES), a1, TEXT_(T_HANDLES), a2, TEXT_(T_TIMERS), a3, TEXT_(T_CONNECTIONS), a4, TEXT_(T_cONNECTIONS), a5, TEXT_(T_CONNECTING), a6, TEXT_(T_tRANSFERRING), a7, TEXT_(T_KEEPALIVE), a8, TEXT_(T_MEMORY_CACHE), a9, TEXT_(T_BYTES), a10, TEXT_(T_FILES), a11, TEXT_(T_LOCKED), a12, TEXT_(T_LOADING), a13, TEXT_(T_FORMATTED_DOCUMENT_CACHE), a14, TEXT_(T_DOCUMENTS), a15, TEXT_(T_LOCKED), a16, NULL, r, 1, TEXT_(T_OK), NULL, B_ENTER | B_ESC);
  246     r->win = term->windows.next;
  247     ((struct dialog_data *)r->win->data)->dlg->abort = refresh_abort;
  248     r->timer = install_timer(RESOURCE_INFO_REFRESH, (void (*)(void *))refresh, r);
  249 }
  250 
  251 #if 0
  252 
  253 void list_cache(struct terminal *term, void *d, struct session *ses)
  254 {
  255     unsigned char *a;
  256     int l = 0;
  257     struct refresh *r;
  258     struct cache_entry *ce, *cache;
  259     a = init_str();
  260     r = mem_alloc(sizeof(struct refresh));
  261     r->term = term;
  262     r->win = NULL;
  263     r->ses = ses;
  264     r->fn = list_cache;
  265     r->data = d;
  266     r->timer = -1;
  267     cache = (struct cache_entry *)cache_info(CI_LIST);
  268     add_to_str(&a, &l, ":");
  269     foreach(ce, *cache) {
  270         add_to_str(&a, &l, "\n");
  271         add_to_str(&a, &l, ce->url);
  272     }
  273     msg_box(term, getml(a, NULL), TEXT_(T_CACHE_INFO), AL_LEFT | AL_EXTD_TEXT, TEXT_(T_CACHE_CONTENT), a, NULL, r, 1, TEXT_(T_OK), end_refresh, B_ENTER | B_ESC);
  274     r->win = term->windows.next;
  275     r->timer = install_timer(RESOURCE_INFO_REFRESH, (void (*)(void *))refresh, r);
  276     /* !!! the refresh here is buggy */
  277 }
  278 
  279 #endif
  280 
  281 #ifdef LEAK_DEBUG
  282 
  283 #define MSG_BUF 2000
  284 
  285 void memory_info(struct terminal *term, void *d, struct session *ses)
  286 {
  287     char message[MSG_BUF];
  288     char *p;
  289     struct refresh *r;
  290     r = mem_alloc(sizeof(struct refresh));
  291     r->term = term;
  292     r->win = NULL;
  293     r->ses = ses;
  294     r->fn = memory_info;
  295     r->data = d;
  296     r->timer = -1;
  297     p = message;
  298     snprint(p, MSG_BUF, mem_amount), p += strlen(p);
  299     sprintf(p, " %s", _(TEXT_(T_MEMORY_ALLOCATED), term)), p += strlen(p);
  300     sprintf(p, "."), p += strlen(p);
  301     if (strlen(message) >= MSG_BUF)
  302         internal("message buffer overflow");
  303     p = stracpy(message);
  304     msg_box(term, getml(p, NULL), TEXT_(T_MEMORY_INFO), AL_CENTER, p, r, 1, TEXT_(T_OK), NULL, B_ENTER | B_ESC);
  305     r->win = term->windows.next;
  306     ((struct dialog_data *)r->win->data)->dlg->abort = refresh_abort;
  307     r->timer = install_timer(RESOURCE_INFO_REFRESH, (void (*)(void *))refresh, r);
  308 }
  309 
  310 #endif
  311 
  312 void flush_caches(struct terminal *term, void *d, void *e)
  313 {
  314     shrink_memory(1);
  315 }
  316 
  317 void go_backwards(struct terminal *term, void *psteps, struct session *ses)
  318 {
  319     int steps = (int)(my_uintptr_t)psteps;
  320 
  321     /*if (ses->tq_goto_position)
  322         --steps;
  323     if (ses->search_word)
  324         mem_free(ses->search_word), ses->search_word = NULL;*/
  325     abort_loading(ses);
  326 
  327     while (steps > 1) {
  328         struct location *loc = ses->history.next;
  329         if ((void *) loc == &ses->history) return;
  330         loc = loc->next;
  331         if ((void *) loc == &ses->history) return;
  332         destroy_location(loc);
  333 
  334         --steps;
  335     }
  336 
  337     if (steps)
  338         go_back(ses);
  339 }
  340 
  341 struct menu_item no_hist_menu[] = {
  342     { TEXT_(T_NO_HISTORY), "", M_BAR, NULL, NULL, 0, 0 },
  343     { NULL, NULL, 0, NULL, NULL, 0, 0 },
  344 };
  345 
  346 void history_menu(struct terminal *term, void *ddd, struct session *ses)
  347 {
  348     struct location *l;
  349     struct menu_item *mi = NULL;
  350     int n = 0;
  351     foreach(l, ses->history) {
  352         if (n/* || ses->tq_goto_position*/) {
  353             unsigned char *url;
  354             if (!mi && !(mi = new_menu(3))) return;
  355             url = stracpy(l->vs.url);
  356             if (strchr(url, POST_CHAR)) *strchr(url, POST_CHAR) = 0;
  357             add_to_menu(&mi, url, "", "", MENU_FUNC go_backwards, (void *)(my_uintptr_t)n, 0);
  358         }
  359         n++;
  360     }
  361     if (n <= 1) do_menu(term, no_hist_menu, ses);
  362     else do_menu(term, mi, ses);
  363 }
  364 
  365 struct menu_item no_downloads_menu[] = {
  366     { TEXT_(T_NO_DOWNLOADS), "", M_BAR, NULL, NULL, 0, 0 },
  367     { NULL, NULL, 0, NULL, NULL, 0, 0 },
  368 };
  369 
  370 void downloads_menu(struct terminal *term, void *ddd, struct session *ses)
  371 {
  372     struct download *d;
  373     struct menu_item *mi = NULL;
  374     int n = 0;
  375     foreachback(d, downloads) {
  376         unsigned char *u;
  377         if (!mi) if (!(mi = new_menu(3))) return;
  378         u = stracpy(d->url);
  379         if (strchr(u, POST_CHAR)) *strchr(u, POST_CHAR) = 0;
  380         add_to_menu(&mi, u, "", "", MENU_FUNC display_download, d, 0);
  381         n++;
  382     }
  383     if (!n) do_menu(term, no_downloads_menu, ses);
  384     else do_menu(term, mi, ses);
  385 }
  386 
  387 void menu_doc_info(struct terminal *term, void *ddd, struct session *ses)
  388 {
  389     state_msg(ses);
  390 }
  391 
  392 void menu_head_info(struct terminal *term, void *ddd, struct session *ses)
  393 {
  394     head_msg(ses);
  395 }
  396 
  397 void menu_toggle(struct terminal *term, void *ddd, struct session *ses)
  398 {
  399     toggle(ses, ses->screen, 0);
  400 }
  401 
  402 void display_codepage(struct terminal *term, void *pcp, struct session *ses)
  403 {
  404     int cp = (int)(my_uintptr_t)pcp;
  405     struct term_spec *t = new_term_spec(term->term);
  406     if (t) t->charset = cp;
  407     cls_redraw_all_terminals();
  408 }
  409 
  410 void assumed_codepage(struct terminal *term, void *pcp, struct session *ses)
  411 {
  412     int cp = (int)(my_uintptr_t)pcp;
  413     ses->ds.assume_cp = cp;
  414     redraw_terminal_cls(term);
  415 }
  416 
  417 void charset_list(struct terminal *term, void *xxx, struct session *ses)
  418 {
  419     int i, sel;
  420     unsigned char *n;
  421     struct menu_item *mi;
  422     if (!(mi = new_menu(1))) return;
  423     for (i = 0; (n = get_cp_name(i)); i++) {
  424         if (is_cp_special(i)) continue;
  425         add_to_menu(&mi, get_cp_name(i), "", "", MENU_FUNC display_codepage, (void *)(my_uintptr_t)i, 0);
  426     }
  427     sel = ses->term->spec->charset;
  428     if (sel < 0) sel = 0;
  429     do_menu_selected(term, mi, ses, sel, NULL, NULL);
  430 }
  431 
  432 void set_val(struct terminal *term, void *ip, int *d)
  433 {
  434     *d = (int)(my_uintptr_t)ip;
  435 }
  436 
  437 void charset_sel_list(struct terminal *term, struct session *ses, int *ptr)
  438 {
  439     int i, sel;
  440     unsigned char *n;
  441     struct menu_item *mi;
  442     if (!(mi = new_menu(1))) return;
  443     for (i = 0; (n = get_cp_name(i)); i++) {
  444         add_to_menu(&mi, get_cp_name(i), "", "", MENU_FUNC set_val, (void *)(my_uintptr_t)i, 0);
  445     }
  446     sel = *ptr;
  447     if (sel < 0) sel = 0;
  448     do_menu_selected(term, mi, ptr, sel, NULL, NULL);
  449 }
  450 
  451 void terminal_options_ok(void *p)
  452 {
  453     cls_redraw_all_terminals();
  454 }
  455 
  456 unsigned char *td_labels[] = { TEXT_(T_NO_FRAMES), TEXT_(T_VT_100_FRAMES), TEXT_(T_LINUX_OR_OS2_FRAMES), TEXT_(T_KOI8R_FRAMES), TEXT_(T_FREEBSD_FRAMES), TEXT_(T_USE_11M), TEXT_(T_RESTRICT_FRAMES_IN_CP850_852), TEXT_(T_BLOCK_CURSOR), TEXT_(T_COLOR), NULL };
  457 
  458 void terminal_options(struct terminal *term, void *xxx, struct session *ses)
  459 {
  460     struct dialog *d;
  461     struct term_spec *ts = new_term_spec(term->term);
  462     if (!ts) return;
  463     d = mem_alloc(sizeof(struct dialog) + 12 * sizeof(struct dialog_item));
  464     memset(d, 0, sizeof(struct dialog) + 12 * sizeof(struct dialog_item));
  465     d->title = TEXT_(T_TERMINAL_OPTIONS);
  466     d->fn = checkbox_list_fn;
  467     d->udata = td_labels;
  468     d->refresh = (void (*)(void *))terminal_options_ok;
  469     d->items[0].type = D_CHECKBOX;
  470     d->items[0].gid = 1;
  471     d->items[0].gnum = TERM_DUMB;
  472     d->items[0].dlen = sizeof(int);
  473     d->items[0].data = (void *)&ts->mode;
  474     d->items[1].type = D_CHECKBOX;
  475     d->items[1].gid = 1;
  476     d->items[1].gnum = TERM_VT100;
  477     d->items[1].dlen = sizeof(int);
  478     d->items[1].data = (void *)&ts->mode;
  479     d->items[2].type = D_CHECKBOX;
  480     d->items[2].gid = 1;
  481     d->items[2].gnum = TERM_LINUX;
  482     d->items[2].dlen = sizeof(int);
  483     d->items[2].data = (void *)&ts->mode;
  484     d->items[3].type = D_CHECKBOX;
  485     d->items[3].gid = 1;
  486     d->items[3].gnum = TERM_KOI8;
  487     d->items[3].dlen = sizeof(int);
  488     d->items[3].data = (void *)&ts->mode;
  489     d->items[4].type = D_CHECKBOX;
  490     d->items[4].gid = 1;
  491     d->items[4].gnum = TERM_FREEBSD;
  492     d->items[4].dlen = sizeof(int);
  493     d->items[4].data = (void *)&ts->mode;
  494     d->items[5].type = D_CHECKBOX;
  495     d->items[5].gid = 0;
  496     d->items[5].dlen = sizeof(int);
  497     d->items[5].data = (void *)&ts->m11_hack;
  498     d->items[6].type = D_CHECKBOX;
  499     d->items[6].gid = 0;
  500     d->items[6].dlen = sizeof(int);
  501     d->items[6].data = (void *)&ts->restrict_852;
  502     d->items[7].type = D_CHECKBOX;
  503     d->items[7].gid = 0;
  504     d->items[7].dlen = sizeof(int);
  505     d->items[7].data = (void *)&ts->block_cursor;
  506     d->items[8].type = D_CHECKBOX;
  507     d->items[8].gid = 0;
  508     d->items[8].dlen = sizeof(int);
  509     d->items[8].data = (void *)&ts->col;
  510     d->items[9].type = D_BUTTON;
  511     d->items[9].gid = B_ENTER;
  512     d->items[9].fn = ok_dialog;
  513     d->items[9].text = TEXT_(T_OK);
  514     d->items[10].type = D_BUTTON;
  515     d->items[10].gid = B_ESC;
  516     d->items[10].fn = cancel_dialog;
  517     d->items[10].text = TEXT_(T_CANCEL);
  518     d->items[11].type = D_END;
  519     do_dialog(term, d, getml(d, NULL));
  520 }
  521 
  522 unsigned char *http_labels[] = { TEXT_(T_USE_HTTP_10), TEXT_(T_ALLOW_SERVER_BLACKLIST), TEXT_(T_BROKEN_302_REDIRECT), TEXT_(T_NO_KEEPALIVE_AFTER_POST_REQUEST), TEXT_(T_DO_NOT_SEND_ACCEPT_CHARSET) };
  523 
  524 int dlg_http_options(struct dialog_data *dlg, struct dialog_item_data *di)
  525 {
  526     struct http_bugs *bugs = (struct http_bugs *)di->cdata;
  527     struct dialog *d;
  528     d = mem_alloc(sizeof(struct dialog) + 8 * sizeof(struct dialog_item));
  529     memset(d, 0, sizeof(struct dialog) + 8 * sizeof(struct dialog_item));
  530     d->title = TEXT_(T_HTTP_BUG_WORKAROUNDS);
  531     d->fn = checkbox_list_fn;
  532     d->udata = http_labels;
  533     d->items[0].type = D_CHECKBOX;
  534     d->items[0].gid = 0;
  535     d->items[0].dlen = sizeof(int);
  536     d->items[0].data = (void *)&bugs->http10;
  537     d->items[1].type = D_CHECKBOX;
  538     d->items[1].gid = 0;
  539     d->items[1].dlen = sizeof(int);
  540     d->items[1].data = (void *)&bugs->allow_blacklist;
  541     d->items[2].type = D_CHECKBOX;
  542     d->items[2].gid = 0;
  543     d->items[2].dlen = sizeof(int);
  544     d->items[2].data = (void *)&bugs->bug_302_redirect;
  545     d->items[3].type = D_CHECKBOX;
  546     d->items[3].gid = 0;
  547     d->items[3].dlen = sizeof(int);
  548     d->items[3].data = (void *)&bugs->bug_post_no_keepalive;
  549     d->items[4].type = D_CHECKBOX;
  550     d->items[4].gid = 0;
  551     d->items[4].dlen = sizeof(int);
  552     d->items[4].data = (void *)&bugs->no_accept_charset;
  553     d->items[5].type = D_BUTTON;
  554     d->items[5].gid = B_ENTER;
  555     d->items[5].fn = ok_dialog;
  556     d->items[5].text = TEXT_(T_OK);
  557     d->items[6].type = D_BUTTON;
  558     d->items[6].gid = B_ESC;
  559     d->items[6].fn = cancel_dialog;
  560     d->items[6].text = TEXT_(T_CANCEL);
  561     d->items[7].type = D_END;
  562     do_dialog(dlg->win->term, d, getml(d, NULL));
  563     return 0;
  564 }
  565 
  566 unsigned char *ftp_texts[] = { TEXT_(T_PASSWORD_FOR_ANONYMOUS_LOGIN), TEXT_(T_USE_PASSIVE_FTP), TEXT_(T_USE_FAST_FTP), TEXT_(T_SET_TYPE_OF_SERVICE), NULL };
  567 
  568 void ftpopt_fn(struct dialog_data *dlg)
  569 {
  570     struct terminal *term = dlg->win->term;
  571     int max = 0, min = 0;
  572     int w, rw;
  573     int y = 0;
  574     max_text_width(term, ftp_texts[0], &max);
  575     min_text_width(term, ftp_texts[0], &min);
  576     checkboxes_width(term, ftp_texts + 1, &max, max_text_width);
  577     checkboxes_width(term, ftp_texts + 1, &min, min_text_width);
  578     max_buttons_width(term, dlg->items + dlg->n - 2, 2, &max);
  579     min_buttons_width(term, dlg->items + dlg->n - 2, 2, &min);
  580     w = term->x * 9 / 10 - 2 * DIALOG_LB;
  581     if (w > max) w = max;
  582     if (w < min) w = min;
  583     if (w > term->x - 2 * DIALOG_LB) w = term->x - 2 * DIALOG_LB;
  584     if (w < 5) w = 5;
  585     rw = 0;
  586     dlg_format_text(NULL, term, ftp_texts[0], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
  587     y += 1;
  588     dlg_format_checkboxes(NULL, term, dlg->items + 1, dlg->n - 3, 0, &y, w, &rw, ftp_texts + 1);
  589     y += 1;
  590     dlg_format_buttons(NULL, term, dlg->items + dlg->n - 2, 2, 0, &y, w, &rw, AL_CENTER);
  591     w = rw;
  592     dlg->xw = rw + 2 * DIALOG_LB;
  593     dlg->yw = y + 2 * DIALOG_TB;
  594     center_dlg(dlg);
  595     draw_dlg(dlg);
  596     y = dlg->y + DIALOG_TB;
  597     dlg_format_text(term, term, ftp_texts[0], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
  598     dlg_format_field(term, term, dlg->items, dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
  599     y += 1;
  600     dlg_format_checkboxes(term, term, dlg->items + 1, dlg->n - 3, dlg->x + DIALOG_LB, &y, w, NULL, ftp_texts + 1);
  601     y += 1;
  602     dlg_format_buttons(term, term, dlg->items + dlg->n - 2, 2, dlg->x + DIALOG_LB, &y, w, &rw, AL_CENTER);
  603 }
  604 
  605 
  606 int dlg_ftp_options(struct dialog_data *dlg, struct dialog_item_data *di)
  607 {
  608     int a;
  609     struct ftp_options *ftp_options = (struct ftp_options *)di->cdata;
  610     struct dialog *d;
  611     d = mem_alloc(sizeof(struct dialog) + 7 * sizeof(struct dialog_item));
  612     memset(d, 0, sizeof(struct dialog) + 7 * sizeof(struct dialog_item));
  613     d->title = TEXT_(T_FTP_OPTIONS);
  614     d->fn = ftpopt_fn;
  615     d->items[0].type = D_FIELD;
  616     d->items[0].dlen = MAX_STR_LEN;
  617     d->items[0].data = ftp_options->anon_pass;
  618     d->items[1].type = D_CHECKBOX;
  619     d->items[1].dlen = sizeof(int);
  620     d->items[1].data = (void*)&ftp_options->passive_ftp;
  621     d->items[1].gid = 0;
  622     d->items[2].type = D_CHECKBOX;
  623     d->items[2].dlen = sizeof(int);
  624     d->items[2].data = (void*)&ftp_options->fast_ftp;
  625 #ifdef HAVE_IPTOS
  626     d->items[3].type = D_CHECKBOX;
  627     d->items[3].dlen = sizeof(int);
  628     d->items[3].data = (void*)&ftp_options->set_tos;
  629     a = 4;
  630 #else
  631     a = 3;
  632 #endif
  633     d->items[a].type = D_BUTTON;
  634     d->items[a].gid = B_ENTER;
  635     d->items[a].fn = ok_dialog;
  636     d->items[a].text = TEXT_(T_OK);
  637     a++;
  638     d->items[a].type = D_BUTTON;
  639     d->items[a].gid = B_ESC;
  640     d->items[a].fn = cancel_dialog;
  641     d->items[a].text = TEXT_(T_CANCEL);
  642     a++;
  643     d->items[a].type = D_END;
  644     do_dialog(dlg->win->term, d, getml(d, NULL));
  645     return 0;
  646 }
  647 
  648 unsigned char max_c_str[3];
  649 unsigned char max_cth_str[3];
  650 unsigned char max_t_str[3];
  651 unsigned char time_str[5];
  652 unsigned char unrtime_str[5];
  653 
  654 void refresh_net(void *xxx)
  655 {
  656     netcfg_stamp++;
  657     /*abort_all_connections();*/
  658     max_connections = atoi(max_c_str);
  659     max_connections_to_host = atoi(max_cth_str);
  660     max_tries = atoi(max_t_str);
  661     receive_timeout = atoi(time_str);
  662     unrestartable_receive_timeout = atoi(unrtime_str);
  663     abort_background_connections();
  664     register_bottom_half(check_queue, NULL);
  665 }
  666 
  667 unsigned char *net_msg[] = {
  668     TEXT_(T_HTTP_PROXY__HOST_PORT),
  669     TEXT_(T_FTP_PROXY__HOST_PORT),
  670     TEXT_(T_MAX_CONNECTIONS),
  671     TEXT_(T_MAX_CONNECTIONS_TO_ONE_HOST),
  672     TEXT_(T_RETRIES),
  673     TEXT_(T_RECEIVE_TIMEOUT_SEC),
  674     TEXT_(T_TIMEOUT_WHEN_UNRESTARTABLE),
  675     TEXT_(T_ASYNC_DNS_LOOKUP),
  676     TEXT_(T_SET_TIME_OF_DOWNLOADED_FILES),
  677     "",
  678     "",
  679 };
  680 
  681 void netopt_fn(struct dialog_data *dlg)
  682 {
  683     struct terminal *term = dlg->win->term;
  684     int max = 0, min = 0;
  685     int w, rw;
  686     int y = -1;
  687     max_text_width(term, net_msg[0], &max);
  688     min_text_width(term, net_msg[0], &min);
  689     max_text_width(term, net_msg[1], &max);
  690     min_text_width(term, net_msg[1], &min);
  691     max_group_width(term, net_msg + 2, dlg->items + 2, 9, &max);
  692     min_group_width(term, net_msg + 2, dlg->items + 2, 9, &min);
  693     max_buttons_width(term, dlg->items + 11, 2, &max);
  694     min_buttons_width(term, dlg->items + 11, 2, &min);
  695     w = dlg->win->term->x * 9 / 10 - 2 * DIALOG_LB;
  696     if (w > max) w = max;
  697     if (w < min) w = min;
  698     if (w > dlg->win->term->x - 2 * DIALOG_LB) w = dlg->win->term->x - 2 * DIALOG_LB;
  699     if (w < 1) w = 1;
  700     rw = 0;
  701     dlg_format_text(NULL, term, net_msg[0], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
  702     y += 2;
  703     dlg_format_text(NULL, term, net_msg[1], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
  704     y += 2;
  705     dlg_format_group(NULL, term, net_msg + 2, dlg->items + 2, 9, 0, &y, w, &rw);
  706     y++;
  707     dlg_format_buttons(NULL, term, dlg->items + 11, 2, 0, &y, w, &rw, AL_CENTER);
  708     w = rw;
  709     dlg->xw = w + 2 * DIALOG_LB;
  710     dlg->yw = y + 2 * DIALOG_TB;
  711     center_dlg(dlg);
  712     draw_dlg(dlg);
  713     y = dlg->y + DIALOG_TB;
  714     dlg_format_text(term, term, net_msg[0], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
  715     dlg_format_field(term, term, &dlg->items[0], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
  716     y++;
  717     dlg_format_text(term, term, net_msg[1], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
  718     dlg_format_field(term, term, &dlg->items[1], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
  719     y++;
  720     dlg_format_group(term, term, net_msg + 2, &dlg->items[2], 9, dlg->x + DIALOG_LB, &y, w, NULL);
  721     y++;
  722     dlg_format_buttons(term, term, &dlg->items[11], 2, dlg->x + DIALOG_LB, &y, w, NULL, AL_CENTER);
  723 }
  724 
  725 void net_options(struct terminal *term, void *xxx, void *yyy)
  726 {
  727     struct dialog *d;
  728     snprint(max_c_str, 3, max_connections);
  729     snprint(max_cth_str, 3, max_connections_to_host);
  730     snprint(max_t_str, 3, max_tries);
  731     snprint(time_str, 5, receive_timeout);
  732     snprint(unrtime_str, 5, unrestartable_receive_timeout);
  733     d = mem_alloc(sizeof(struct dialog) + 14 * sizeof(struct dialog_item));
  734     memset(d, 0, sizeof(struct dialog) + 14 * sizeof(struct dialog_item));
  735     d->title = TEXT_(T_NETWORK_OPTIONS);
  736     d->fn = netopt_fn;
  737     d->refresh = (void (*)(void *))refresh_net;
  738     d->items[0].type = D_FIELD;
  739     d->items[0].dlen = MAX_STR_LEN;
  740     d->items[0].data = http_proxy;
  741     d->items[1].type = D_FIELD;
  742     d->items[1].dlen = MAX_STR_LEN;
  743     d->items[1].data = ftp_proxy;
  744     d->items[2].type = D_FIELD;
  745     d->items[2].data = max_c_str;
  746     d->items[2].dlen = 3;
  747     d->items[2].fn = check_number;
  748     d->items[2].gid = 1;
  749     d->items[2].gnum = 99;
  750     d->items[3].type = D_FIELD;
  751     d->items[3].data = max_cth_str;
  752     d->items[3].dlen = 3;
  753     d->items[3].fn = check_number;
  754     d->items[3].gid = 1;
  755     d->items[3].gnum = 99;
  756     d->items[4].type = D_FIELD;
  757     d->items[4].data = max_t_str;
  758     d->items[4].dlen = 3;
  759     d->items[4].fn = check_number;
  760     d->items[4].gid = 0;
  761     d->items[4].gnum = 16;
  762     d->items[5].type = D_FIELD;
  763     d->items[5].data = time_str;
  764     d->items[5].dlen = 5;
  765     d->items[5].fn = check_number;
  766     d->items[5].gid = 1;
  767     d->items[5].gnum = 1800;
  768     d->items[6].type = D_FIELD;
  769     d->items[6].data = unrtime_str;
  770     d->items[6].dlen = 5;
  771     d->items[6].fn = check_number;
  772     d->items[6].gid = 1;
  773     d->items[6].gnum = 1800;
  774     d->items[7].type = D_CHECKBOX;
  775     d->items[7].data = (unsigned char *)&async_lookup;
  776     d->items[7].dlen = sizeof(int);
  777     d->items[8].type = D_CHECKBOX;
  778     d->items[8].data = (unsigned char *)&download_utime;
  779     d->items[8].dlen = sizeof(int);
  780     d->items[9].type = D_BUTTON;
  781     d->items[9].gid = 0;
  782     d->items[9].fn = dlg_http_options;
  783     d->items[9].text = TEXT_(T_HTTP_OPTIONS);
  784     d->items[9].data = (unsigned char *)&http_bugs;
  785     d->items[9].dlen = sizeof(struct http_bugs);
  786     d->items[10].type = D_BUTTON;
  787     d->items[10].gid = 0;
  788     d->items[10].fn = dlg_ftp_options;
  789     d->items[10].text = TEXT_(T_FTP_OPTIONS);
  790     d->items[10].data = (unsigned char *)&ftp_options;
  791     d->items[10].dlen = sizeof(struct ftp_options);
  792     d->items[11].type = D_BUTTON;
  793     d->items[11].gid = B_ENTER;
  794     d->items[11].fn = ok_dialog;
  795     d->items[11].text = TEXT_(T_OK);
  796     d->items[12].type = D_BUTTON;
  797     d->items[12].gid = B_ESC;
  798     d->items[12].fn = cancel_dialog;
  799     d->items[12].text = TEXT_(T_CANCEL);
  800     d->items[13].type = D_END;
  801     do_dialog(term, d, getml(d, NULL));
  802 }
  803 
  804 unsigned char *prg_msg[] = {
  805     TEXT_(T_MAILTO_PROG),
  806     TEXT_(T_TELNET_PROG),
  807     TEXT_(T_TN3270_PROG),
  808     TEXT_(T_MMS_PROG),
  809     ""
  810 };
  811 
  812 void netprog_fn(struct dialog_data *dlg)
  813 {
  814     struct terminal *term = dlg->win->term;
  815     int max = 0, min = 0;
  816     int w, rw;
  817     int y = -1;
  818     max_text_width(term, prg_msg[0], &max);
  819     min_text_width(term, prg_msg[0], &min);
  820     max_text_width(term, prg_msg[1], &max);
  821     min_text_width(term, prg_msg[1], &min);
  822     max_text_width(term, prg_msg[2], &max);
  823     min_text_width(term, prg_msg[2], &min);
  824     max_text_width(term, prg_msg[3], &max);
  825     min_text_width(term, prg_msg[3], &min);
  826     max_buttons_width(term, dlg->items + 4, 2, &max);
  827     min_buttons_width(term, dlg->items + 4, 2, &min);
  828     w = dlg->win->term->x * 9 / 10 - 2 * DIALOG_LB;
  829     if (w > max) w = max;
  830     if (w < min) w = min;
  831     if (w > dlg->win->term->x - 2 * DIALOG_LB) w = dlg->win->term->x - 2 * DIALOG_LB;
  832     if (w < 1) w = 1;
  833     rw = 0;
  834     dlg_format_text(NULL, term, prg_msg[0], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
  835     y += 2;
  836     dlg_format_text(NULL, term, prg_msg[1], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
  837     y += 2;
  838     dlg_format_text(NULL, term, prg_msg[2], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
  839     y += 2;
  840     dlg_format_text(NULL, term, prg_msg[3], 0, &y, w, &rw, COLOR_DIALOG_TEXT, AL_LEFT);
  841     y += 2;
  842     dlg_format_buttons(NULL, term, dlg->items + 4, 2, 0, &y, w, &rw, AL_CENTER);
  843     w = rw;
  844     dlg->xw = w + 2 * DIALOG_LB;
  845     dlg->yw = y + 2 * DIALOG_TB;
  846     center_dlg(dlg);
  847     draw_dlg(dlg);
  848     y = dlg->y + DIALOG_TB;
  849     dlg_format_text(term, term, prg_msg[0], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
  850     dlg_format_field(term, term, &dlg->items[0], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
  851     y++;
  852     dlg_format_text(term, term, prg_msg[1], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
  853     dlg_format_field(term, term, &dlg->items[1], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
  854     y++;
  855     dlg_format_text(term, term, prg_msg[2], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
  856     dlg_format_field(term, term, &dlg->items[2], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
  857     y++;
  858     dlg_format_text(term, term, prg_msg[3], dlg->x + DIALOG_LB, &y, w, NULL, COLOR_DIALOG_TEXT, AL_LEFT);
  859     dlg_format_field(term, term, &dlg->items[3], dlg->x + DIALOG_LB, &y, w, NULL, AL_LEFT);
  860     y++;
  861     dlg_format_buttons(term, term, &dlg->items[4], 2, dlg->x + DIALOG_LB, &y, w, NULL, AL_CENTER);
  862 }
  863 
  864 void net_programs(struct terminal *term, void *xxx, void *yyy)
  865 {
  866     struct dialog *d;
  867     d = mem_alloc(sizeof(struct dialog) + 7 * sizeof(struct dialog_item));
  868     memset(d, 0, sizeof(struct dialog) + 7 * sizeof(struct dialog_item));
  869     d->title = TEXT_(T_MAIL_AND_TELNET_PROGRAMS);
  870     d->fn = netprog_fn;
  871     d->items[0].type = D_FIELD;
  872     d->items[0].dlen = MAX_STR_LEN;
  873     d->items[0].data = get_prog(&mailto_prog);
  874     d->items[1].type = D_FIELD;
  875     d->items[1].dlen = MAX_STR_LEN;
  876     d->items[1].data = get_prog(&telnet_prog);
  877     d->items[2].type = D_FIELD;
  878     d->items[2].dlen = MAX_STR_LEN;
  879     d->items[2].data = get_prog(&tn3270_prog);
  880     d->items[3].type = D_FIELD;
  881     d->items[3].dlen = MAX_STR_LEN;
  882     d->items[3].data = get_prog(&mms_prog);
  883     d->items[4].type = D_BUTTON;
  884     d->items[4].gid = B_ENTER;
  885     d->items[4].fn = ok_dialog;
  886     d->items[4].text = TEXT_(T_OK);
  887     d->items[5].type = D_BUTTON;
  888     d->items[5].gid = B_ESC;
  889     d->items[5].fn = cancel_dialog;
  890     d->items[5].text = TEXT_(T_CANCEL);
  891     d->items[6].type = D_END;
  892     do_dialog(term, d, getml(d, NULL));
  893 }
  894 
  895 /*void net_opt_ask(struct terminal *term, void *xxx, void *yyy)
  896 {
  897     if (list_empty(downloads)) {
  898         net_options(term, xxx, yyy);
  899         return;
  900     }
  901     msg_box(term, NULL, _("Network options"), AL_CENTER, _("Warning: configuring network will terminate all running downloads. Do you really want to configure network?"), term, 2, _("Yes"), (void (*)(void *))net_options, B_ENTER, _("No"), NULL, B_ESC);
  902 }*/
  903 
  904 unsigned char mc_str[8];
  905 unsigned char doc_str[4];
  906 
  907 void cache_refresh(void *xxx)
  908 {
  909     memory_cache_size = atoi(mc_str) * 1024;
  910     max_format_cache_entries = atoi(doc_str);
  911     count_format_cache();
  912     shrink_memory(0);
  913 }
  914 
  915 unsigned char *cache_texts[] = { TEXT_(T_MEMORY_CACHE_SIZE__KB), TEXT_(T_NUMBER_OF_FORMATTED_DOCUMENTS) };
  916 
  917 void cache_opt(struct terminal *term, void *xxx, void *yyy)
  918 {
  919     struct dialog *d;
  920     snprint(mc_str, 8, memory_cache_size / 1024);
  921     snprint(doc_str, 4, max_format_cache_entries);
  922     d = mem_alloc(sizeof(struct dialog) + 5 * sizeof(struct dialog_item));
  923     memset(d, 0, sizeof(struct dialog) + 5 * sizeof(struct dialog_item));
  924     d->title = TEXT_(T_CACHE_OPTIONS);
  925     d->fn = group_fn;
  926     d->udata = cache_texts;
  927     d->refresh = (void (*)(void *))cache_refresh;
  928     d->items[0].type = D_FIELD;
  929     d->items[0].dlen = 8;
  930     d->items[0].data = mc_str;
  931     d->items[0].fn = check_number;
  932     d->items[0].gid = 0;
  933     d->items[0].gnum = MAXINT / 1024;
  934     d->items[1].type = D_FIELD;
  935     d->items[1].dlen = 4;
  936     d->items[1].data = doc_str;
  937     d->items[1].fn = check_number;
  938     d->items[1].gid = 0;
  939     d->items[1].gnum = 256;
  940     d->items[2].type = D_BUTTON;
  941     d->items[2].gid = B_ENTER;
  942     d->items[2].fn = ok_dialog;
  943     d->items[2].text = TEXT_(T_OK);
  944     d->items[3].type = D_BUTTON;
  945     d->items[3].gid = B_ESC;
  946     d->items[3].fn = cancel_dialog;
  947     d->items[3].text = TEXT_(T_CANCEL);
  948     d->items[4].type = D_END;
  949     do_dialog(term, d, getml(d, NULL));
  950 }
  951 
  952 void menu_shell(struct terminal *term, void *xxx, void *yyy)
  953 {
  954     unsigned char *sh;
  955     if (!(sh = GETSHELL)) sh = DEFAULT_SHELL;
  956     exec_on_terminal(term, sh, "", 1);
  957 }
  958 
  959 void menu_kill_background_connections(struct terminal *term, void *xxx, void *yyy)
  960 {
  961     abort_background_connections();
  962 }
  963 
  964 void menu_save_html_options(struct terminal *term, void *xxx, struct session *ses)
  965 {
  966     memcpy(&dds, &ses->ds, sizeof(struct document_setup));
  967     write_html_config(term);
  968 }
  969 
  970 unsigned char marg_str[2];
  971 
  972 void html_refresh(struct session *ses)
  973 {
  974     ses->ds.margin = atoi(marg_str);
  975     html_interpret(ses);
  976     draw_formatted(ses);
  977     load_frames(ses, ses->screen);
  978     process_file_requests(ses);
  979     print_screen_status(ses);
  980 }
  981 
  982 unsigned char *html_texts[] = { TEXT_(T_DISPLAY_TABLES), TEXT_(T_DISPLAY_FRAMES), TEXT_(T_DISPLAY_LINKS_TO_IMAGES), TEXT_(T_LINK_ORDER_BY_COLUMNS), TEXT_(T_NUMBERED_LINKS), TEXT_(T_TEXT_MARGIN), "", TEXT_(T_IGNORE_CHARSET_INFO_SENT_BY_SERVER) };
  983 
  984 int dlg_assume_cp(struct dialog_data *dlg, struct dialog_item_data *di)
  985 {
  986     charset_sel_list(dlg->win->term, dlg->dlg->udata2, (int *)di->cdata);
  987     return 0;
  988 }
  989 
  990 void menu_html_options(struct terminal *term, void *xxx, struct session *ses)
  991 {
  992     struct dialog *d;
  993     snprint(marg_str, 2, ses->ds.margin);
  994     d = mem_alloc(sizeof(struct dialog) + 11 * sizeof(struct dialog_item));
  995     memset(d, 0, sizeof(struct dialog) + 11 * sizeof(struct dialog_item));
  996     d->title = TEXT_(T_HTML_OPTIONS);
  997     d->fn = group_fn;
  998     d->udata = html_texts;
  999     d->udata2 = ses;
 1000     d->refresh = (void (*)(void *))html_refresh;
 1001     d->refresh_data = ses;
 1002     d->items[0].type = D_CHECKBOX;
 1003     d->items[0].data = (unsigned char *) &ses->ds.tables;
 1004     d->items[0].dlen = sizeof(int);
 1005     d->items[1].type = D_CHECKBOX;
 1006     d->items[1].data = (unsigned char *) &ses->ds.frames;
 1007     d->items[1].dlen = sizeof(int);
 1008     d->items[2].type = D_CHECKBOX;
 1009     d->items[2].data = (unsigned char *) &ses->ds.images;
 1010     d->items[2].dlen = sizeof(int);
 1011     d->items[3].type = D_CHECKBOX;
 1012     d->items[3].data = (unsigned char *) &ses->ds.table_order;
 1013     d->items[3].dlen = sizeof(int);
 1014     d->items[4].type = D_CHECKBOX;
 1015     d->items[4].data = (unsigned char *) &ses->ds.num_links;
 1016     d->items[4].dlen = sizeof(int);
 1017     d->items[5].type = D_FIELD;
 1018     d->items[5].dlen = 2;
 1019     d->items[5].data = marg_str;
 1020     d->items[5].fn = check_number;
 1021     d->items[5].gid = 0;
 1022     d->items[5].gnum = 9;
 1023     d->items[6].type = D_BUTTON;
 1024     d->items[6].gid = 0;
 1025     d->items[6].fn = dlg_assume_cp;
 1026     d->items[6].text = TEXT_(T_DEFAULT_CODEPAGE);
 1027     d->items[6].data = (unsigned char *) &ses->ds.assume_cp;
 1028     d->items[6].dlen = sizeof(int);
 1029     d->items[7].type = D_CHECKBOX;
 1030     d->items[7].data = (unsigned char *) &ses->ds.hard_assume;
 1031     d->items[7].dlen = sizeof(int);
 1032     d->items[8].type = D_BUTTON;
 1033     d->items[8].gid = B_ENTER;
 1034     d->items[8].fn = ok_dialog;
 1035     d->items[8].text = TEXT_(T_OK);
 1036     d->items[9].type = D_BUTTON;
 1037     d->items[9].gid = B_ESC;
 1038     d->items[9].fn = cancel_dialog;
 1039     d->items[9].text = TEXT_(T_CANCEL);
 1040     d->items[10].type = D_END;
 1041     do_dialog(term, d, getml(d, NULL));
 1042 }
 1043 
 1044 void menu_set_language(struct terminal *term, void *pcp, struct session *ses)
 1045 {
 1046     set_language((int)(my_uintptr_t)pcp);
 1047     cls_redraw_all_terminals();
 1048 }
 1049 
 1050 void menu_language_list(struct terminal *term, void *xxx, struct session *ses)
 1051 {
 1052     int i, sel;
 1053     unsigned char *n;
 1054     struct menu_item *mi;
 1055     if (!(mi = new_menu(1))) return;
 1056     for (i = 0; i < n_languages(); i++) {
 1057         n = language_name(i);
 1058         add_to_menu(&mi, n, "", "", MENU_FUNC menu_set_language, (void *)(my_uintptr_t)i, 0);
 1059     }
 1060     sel = current_language;
 1061     do_menu_selected(term, mi, ses, sel, NULL, NULL);
 1062 }
 1063 
 1064 unsigned char *resize_texts[] = { TEXT_(T_COLUMNS), TEXT_(T_ROWS) };
 1065 
 1066 unsigned char x_str[4];
 1067 unsigned char y_str[4];
 1068 
 1069 void do_resize_terminal(struct terminal *term)
 1070 {
 1071     unsigned char str[8];
 1072     strcpy(str, x_str);
 1073     strcat(str, ",");
 1074     strcat(str, y_str);
 1075     do_terminal_function(term, TERM_FN_RESIZE, str);
 1076 }
 1077 
 1078 void dlg_resize_terminal(struct terminal *term, void *xxx, struct session *ses)
 1079 {
 1080     struct dialog *d;
 1081     unsigned x = (unsigned)term->x > 999 ? 999 : term->x;
 1082     unsigned y = (unsigned)term->y > 999 ? 999 : term->y;
 1083     sprintf(x_str, "%u", x);
 1084     sprintf(y_str, "%u", y);
 1085     d = mem_alloc(sizeof(struct dialog) + 5 * sizeof(struct dialog_item));
 1086     memset(d, 0, sizeof(struct dialog) + 5 * sizeof(struct dialog_item));
 1087     d->title = TEXT_(T_RESIZE_TERMINAL);
 1088     d->fn = group_fn;
 1089     d->udata = resize_texts;
 1090     d->refresh = (void (*)(void *))do_resize_terminal;
 1091     d->refresh_data = term;
 1092     d->items[0].type = D_FIELD;
 1093     d->items[0].dlen = 4;
 1094     d->items[0].data = x_str;
 1095     d->items[0].fn = check_number;
 1096     d->items[0].gid = 1;
 1097     d->items[0].gnum = 999;
 1098     d->items[1].type = D_FIELD;
 1099     d->items[1].dlen = 4;
 1100     d->items[1].data = y_str;
 1101     d->items[1].fn = check_number;
 1102     d->items[1].gid = 1;
 1103     d->items[1].gnum = 999;
 1104     d->items[2].type = D_BUTTON;
 1105     d->items[2].gid = B_ENTER;
 1106     d->items[2].fn = ok_dialog;
 1107     d->items[2].text = TEXT_(T_OK);
 1108     d->items[3].type = D_BUTTON;
 1109     d->items[3].gid = B_ESC;
 1110     d->items[3].fn = cancel_dialog;
 1111     d->items[3].text = TEXT_(T_CANCEL);
 1112     d->items[4].type = D_END;
 1113     do_dialog(term, d, getml(d, NULL));
 1114 
 1115 }
 1116 
 1117 struct menu_item file_menu11[] = {
 1118     { TEXT_(T_GOTO_URL), "g", TEXT_(T_HK_GOTO_URL), MENU_FUNC menu_goto_url, (void *)0, 0, 0 },
 1119     { TEXT_(T_GO_BACK), "<-", TEXT_(T_HK_GO_BACK), MENU_FUNC menu_go_back, (void *)0, 0, 0 },
 1120     { TEXT_(T_HISTORY), ">", TEXT_(T_HK_HISTORY), MENU_FUNC history_menu, (void *)0, 1, 0 },
 1121     { TEXT_(T_RELOAD), "Ctrl-R", TEXT_(T_HK_RELOAD), MENU_FUNC menu_reload, (void *)0, 0, 0 },
 1122 };
 1123 
 1124 struct menu_item file_menu12[] = {
 1125     { TEXT_(T_BOOKMARKS), "s", TEXT_(T_HK_BOOKMARKS), MENU_FUNC menu_bookmark_manager, (void *)0, 0, 0 },
 1126     { TEXT_(T_ADD_BOOKMARK), "a", TEXT_(T_HK_ADD_BOOKMARK), MENU_FUNC launch_bm_add_doc_dialog, (void *)0, 0, 0 },
 1127 };
 1128 
 1129 struct menu_item file_menu21[] = {
 1130     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1131     { TEXT_(T_SAVE_AS), "", TEXT_(T_HK_SAVE_AS), MENU_FUNC save_as, (void *)0, 0, 0 },
 1132     { TEXT_(T_SAVE_URL_AS), "", TEXT_(T_HK_SAVE_URL_AS), MENU_FUNC menu_save_url_as, (void *)0, 0, 0 },
 1133     { TEXT_(T_SAVE_FORMATTED_DOCUMENT), "", TEXT_(T_HK_SAVE_FORMATTED_DOCUMENT), MENU_FUNC menu_save_formatted, (void *)0, 0, 0 },
 1134 };
 1135 
 1136 struct menu_item file_menu22[] = {
 1137     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1138     { TEXT_(T_KILL_BACKGROUND_CONNECTIONS), "", TEXT_(T_HK_KILL_BACKGROUND_CONNECTIONS), MENU_FUNC menu_kill_background_connections, (void *)0, 0, 0 },
 1139     { TEXT_(T_FLUSH_ALL_CACHES), "", TEXT_(T_HK_FLUSH_ALL_CACHES), MENU_FUNC flush_caches, (void *)0, 0, 0 },
 1140     { TEXT_(T_RESOURCE_INFO), "", TEXT_(T_HK_RESOURCE_INFO), MENU_FUNC cache_inf, (void *)0, 0, 0 },
 1141 #if 0
 1142     { TEXT_(T_CACHE_INFO), "", TEXT_(T_HK_CACHE_INFO), MENU_FUNC list_cache, (void *)0, 0, 0 },
 1143 #endif
 1144 #ifdef LEAK_DEBUG
 1145     { TEXT_(T_MEMORY_INFO), "", TEXT_(T_HK_MEMORY_INFO), MENU_FUNC memory_info, (void *)0, 0, 0 },
 1146 #endif
 1147     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1148 };
 1149 
 1150 struct menu_item file_menu3[] = {
 1151     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1152     { TEXT_(T_EXIT), "q", TEXT_(T_HK_EXIT), MENU_FUNC exit_prog, (void *)0, 0, 0 },
 1153     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1154 };
 1155 
 1156 void do_file_menu(struct terminal *term, void *xxx, struct session *ses)
 1157 {
 1158     int x;
 1159     int o;
 1160     struct menu_item *file_menu, *e, *f;
 1161     file_menu = mem_alloc(sizeof(file_menu11) + sizeof(file_menu12) + sizeof(file_menu21) + sizeof(file_menu22) + sizeof(file_menu3) + 3 * sizeof(struct menu_item));
 1162     e = file_menu;
 1163     memcpy(e, file_menu11, sizeof(file_menu11));
 1164     e += sizeof(file_menu11) / sizeof(struct menu_item);
 1165     if (!anonymous) {
 1166         memcpy(e, file_menu12, sizeof(file_menu12));
 1167         e += sizeof(file_menu12) / sizeof(struct menu_item);
 1168     }
 1169     if ((o = can_open_in_new(term))) {
 1170         e->text = TEXT_(T_NEW_WINDOW);
 1171         e->rtext = o - 1 ? ">" : "";
 1172         e->hotkey = TEXT_(T_HK_NEW_WINDOW);
 1173         e->func = MENU_FUNC open_in_new_window;
 1174         e->data = send_open_new_xterm;
 1175         e->in_m = o - 1;
 1176         e->free_i = 0;
 1177         e++;
 1178     }
 1179     if (!anonymous) {
 1180         memcpy(e, file_menu21, sizeof(file_menu21));
 1181         e += sizeof(file_menu21) / sizeof(struct menu_item);
 1182     }
 1183     memcpy(e, file_menu22, sizeof(file_menu22));
 1184     e += sizeof(file_menu22) / sizeof(struct menu_item);
 1185     /*"", "", M_BAR, NULL, NULL, 0, 0,
 1186     TEXT_(T_OS_SHELL), "", TEXT_(T_HK_OS_SHELL), MENU_FUNC menu_shell, NULL, 0, 0,*/
 1187     x = 1;
 1188     if (!anonymous && can_open_os_shell(term->environment)) {
 1189         e->text = TEXT_(T_OS_SHELL);
 1190         e->rtext = "";
 1191         e->hotkey = TEXT_(T_HK_OS_SHELL);
 1192         e->func = MENU_FUNC menu_shell;
 1193         e->data = NULL;
 1194         e->in_m = 0;
 1195         e->free_i = 0;
 1196         e++;
 1197         x = 0;
 1198     }
 1199     if (can_resize_window(term)) {
 1200         e->text = TEXT_(T_RESIZE_TERMINAL);
 1201         e->rtext = "";
 1202         e->hotkey = TEXT_(T_HK_RESIZE_TERMINAL);
 1203         e->func = MENU_FUNC dlg_resize_terminal;
 1204         e->data = NULL;
 1205         e->in_m = 0;
 1206         e->free_i = 0;
 1207         e++;
 1208         x = 0;
 1209     }
 1210     memcpy(e, file_menu3 + x, sizeof(file_menu3) - x * sizeof(struct menu_item));
 1211     e += sizeof(file_menu3) / sizeof(struct menu_item);
 1212     for (f = file_menu; f < e; f++) f->free_i = 1;
 1213     do_menu(term, file_menu, ses);
 1214 }
 1215 
 1216 struct menu_item view_menu[] = {
 1217     { TEXT_(T_SEARCH), "/", TEXT_(T_HK_SEARCH), MENU_FUNC menu_for_frame, (void *)search_dlg, 0, 0 },
 1218     { TEXT_(T_SEARCH_BACK), "?", TEXT_(T_HK_SEARCH_BACK), MENU_FUNC menu_for_frame, (void *)search_back_dlg, 0, 0 },
 1219     { TEXT_(T_FIND_NEXT), "n", TEXT_(T_HK_FIND_NEXT), MENU_FUNC menu_for_frame, (void *)find_next, 0, 0 },
 1220     { TEXT_(T_FIND_PREVIOUS), "N", TEXT_(T_HK_FIND_PREVIOUS), MENU_FUNC menu_for_frame, (void *)find_next_back, 0, 0 },
 1221     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1222     { TEXT_(T_TOGGLE_HTML_PLAIN), "\\", TEXT_(T_HK_TOGGLE_HTML_PLAIN), MENU_FUNC menu_toggle, NULL, 0, 0 },
 1223     { TEXT_(T_DOCUMENT_INFO), "=", TEXT_(T_HK_DOCUMENT_INFO), MENU_FUNC menu_doc_info, NULL, 0, 0 },
 1224     { TEXT_(T_HEADER_INFO), "|", TEXT_(T_HK_HEADER_INFO), MENU_FUNC menu_head_info, NULL, 0, 0 },
 1225     { TEXT_(T_FRAME_AT_FULL_SCREEN), "f", TEXT_(T_HK_FRAME_AT_FULL_SCREEN), MENU_FUNC menu_for_frame, (void *)set_frame, 0, 0 },
 1226     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1227     { TEXT_(T_HTML_OPTIONS), "", TEXT_(T_HK_HTML_OPTIONS), MENU_FUNC menu_html_options, (void *)0, 0, 0 },
 1228     { TEXT_(T_SAVE_HTML_OPTIONS), "", TEXT_(T_HK_SAVE_HTML_OPTIONS), MENU_FUNC menu_save_html_options, (void *)0, 0, 0 },
 1229     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1230 };
 1231 
 1232 struct menu_item view_menu_anon[] = {
 1233     { TEXT_(T_SEARCH), "/", TEXT_(T_HK_SEARCH), MENU_FUNC menu_for_frame, (void *)search_dlg, 0, 0 },
 1234     { TEXT_(T_SEARCH_BACK), "?", TEXT_(T_HK_SEARCH_BACK), MENU_FUNC menu_for_frame, (void *)search_back_dlg, 0, 0 },
 1235     { TEXT_(T_FIND_NEXT), "n", TEXT_(T_HK_FIND_NEXT), MENU_FUNC menu_for_frame, (void *)find_next, 0, 0 },
 1236     { TEXT_(T_FIND_PREVIOUS), "N", TEXT_(T_HK_FIND_PREVIOUS), MENU_FUNC menu_for_frame, (void *)find_next_back, 0, 0 },
 1237     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1238     { TEXT_(T_TOGGLE_HTML_PLAIN), "\\", TEXT_(T_HK_TOGGLE_HTML_PLAIN), MENU_FUNC menu_toggle, NULL, 0, 0 },
 1239     { TEXT_(T_DOCUMENT_INFO), "=", TEXT_(T_HK_DOCUMENT_INFO), MENU_FUNC menu_doc_info, NULL, 0, 0 },
 1240     { TEXT_(T_FRAME_AT_FULL_SCREEN), "f", TEXT_(T_HK_FRAME_AT_FULL_SCREEN), MENU_FUNC menu_for_frame, (void *)set_frame, 0, 0 },
 1241     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1242     { TEXT_(T_HTML_OPTIONS), "", TEXT_(T_HK_HTML_OPTIONS), MENU_FUNC menu_html_options, (void *)0, 0, 0 },
 1243     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1244 };
 1245 
 1246 struct menu_item help_menu[] = {
 1247     { TEXT_(T_ABOUT), "", TEXT_(T_HK_ABOUT), MENU_FUNC menu_about, (void *)0, 0, 0 },
 1248     { TEXT_(T_KEYS), "", TEXT_(T_HK_KEYS), MENU_FUNC menu_keys, (void *)0, 0, 0 },
 1249     { TEXT_(T_MANUAL), "", TEXT_(T_HK_MANUAL), MENU_FUNC menu_manual, (void *)0, 0, 0 },
 1250     { TEXT_(T_COPYING), "", TEXT_(T_HK_COPYING), MENU_FUNC menu_copying, (void *)0, 0, 0 },
 1251     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1252 };
 1253 
 1254 struct menu_item assoc_menu[] = {
 1255     { TEXT_(T_ADD), "", TEXT_(T_HK_ADD), MENU_FUNC menu_add_ct, NULL, 0, 0 },
 1256     { TEXT_(T_MODIFY), ">", TEXT_(T_HK_MODIFY), MENU_FUNC menu_list_assoc, menu_add_ct, 1, 0 },
 1257     { TEXT_(T_DELETE), ">", TEXT_(T_HK_DELETE), MENU_FUNC menu_list_assoc, menu_del_ct, 1, 0 },
 1258     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1259 };
 1260 
 1261 struct menu_item ext_menu[] = {
 1262     { TEXT_(T_ADD), "", TEXT_(T_HK_ADD), MENU_FUNC menu_add_ext, NULL, 0, 0 },
 1263     { TEXT_(T_MODIFY), ">", TEXT_(T_HK_MODIFY), MENU_FUNC menu_list_ext, menu_add_ext, 1, 0 },
 1264     { TEXT_(T_DELETE), ">", TEXT_(T_HK_DELETE), MENU_FUNC menu_list_ext, menu_del_ext, 1, 0 },
 1265     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1266 };
 1267 
 1268 static void menu_write_config(struct terminal *term, void *xxx, void *yyy)
 1269 {
 1270     write_config(term);
 1271 }
 1272 
 1273 struct menu_item setup_menu[] = {
 1274     { TEXT_(T_LANGUAGE), ">", TEXT_(T_HK_LANGUAGE), MENU_FUNC menu_language_list, NULL, 1, 0 },
 1275     { TEXT_(T_CHARACTER_SET), ">", TEXT_(T_HK_CHARACTER_SET), MENU_FUNC charset_list, (void *)1, 1, 0 },
 1276     { TEXT_(T_TERMINAL_OPTIONS), "", TEXT_(T_HK_TERMINAL_OPTIONS), MENU_FUNC terminal_options, NULL, 0, 0 },
 1277     { TEXT_(T_NETWORK_OPTIONS), "", TEXT_(T_HK_NETWORK_OPTIONS), MENU_FUNC net_options, NULL, 0, 0 },
 1278     { TEXT_(T_CACHE), "", TEXT_(T_HK_CACHE), MENU_FUNC cache_opt, NULL, 0, 0 },
 1279     { TEXT_(T_MAIL_AND_TELNEL), "", TEXT_(T_HK_MAIL_AND_TELNEL), MENU_FUNC net_programs, NULL, 0, 0 },
 1280     { TEXT_(T_ASSOCIATIONS), ">", TEXT_(T_HK_ASSOCIATIONS), MENU_FUNC do_menu, assoc_menu, 1, 0 },
 1281     { TEXT_(T_FILE_EXTENSIONS), ">", TEXT_(T_HK_FILE_EXTENSIONS), MENU_FUNC do_menu, ext_menu, 1, 0 },
 1282     { "", "", M_BAR, NULL, NULL, 0, 0 },
 1283     { TEXT_(T_SAVE_OPTIONS), "", TEXT_(T_HK_SAVE_OPTIONS), MENU_FUNC menu_write_config, NULL, 0, 0 },
 1284     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1285 };
 1286 
 1287 struct menu_item setup_menu_anon[] = {
 1288     { TEXT_(T_LANGUAGE), ">", TEXT_(T_HK_LANGUAGE), MENU_FUNC menu_language_list, NULL, 1, 0 },
 1289     { TEXT_(T_CHARACTER_SET), ">", TEXT_(T_HK_CHARACTER_SET), MENU_FUNC charset_list, (void *)1, 1, 0 },
 1290     { TEXT_(T_TERMINAL_OPTIONS), "", TEXT_(T_HK_TERMINAL_OPTIONS), MENU_FUNC terminal_options, NULL, 0, 0 },
 1291     /*{ TEXT_(T_NETWORK_OPTIONS), "", TEXT_(T_HK_NETWORK_OPTIONS), MENU_FUNC net_options, NULL, 0, 0,}*/
 1292     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1293 };
 1294 
 1295 void do_view_menu(struct terminal *term, void *xxx, struct session *ses)
 1296 {
 1297     if (!anonymous) do_menu(term, view_menu, ses);
 1298     else do_menu(term, view_menu_anon, ses);
 1299 }
 1300 
 1301 void do_setup_menu(struct terminal *term, void *xxx, struct session *ses)
 1302 {
 1303     if (!anonymous) do_menu(term, setup_menu, ses);
 1304     else do_menu(term, setup_menu_anon, ses);
 1305 }
 1306 
 1307 struct menu_item main_menu[] = {
 1308     { TEXT_(T_FILE), "", TEXT_(T_HK_FILE), MENU_FUNC do_file_menu, NULL, 1, 1 },
 1309     { TEXT_(T_VIEW), "", TEXT_(T_HK_VIEW), MENU_FUNC do_view_menu, NULL, 1, 1 },
 1310     { TEXT_(T_LINK), "", TEXT_(T_HK_LINK), MENU_FUNC link_menu, NULL, 1, 1 },
 1311     { TEXT_(T_DOWNLOADS), "", TEXT_(T_HK_DOWNLOADS), MENU_FUNC downloads_menu, NULL, 1, 1 },
 1312     { TEXT_(T_SETUP), "", TEXT_(T_HK_SETUP), MENU_FUNC do_setup_menu, NULL, 1, 1 },
 1313     { TEXT_(T_HELP), "", TEXT_(T_HK_HELP), MENU_FUNC do_menu, help_menu, 1, 1 },
 1314     { NULL, NULL, 0, NULL, NULL, 0, 0 },
 1315 };
 1316 
 1317 void activate_bfu_technology(struct session *ses, int item)
 1318 {
 1319     struct terminal *term = ses->term;
 1320     do_mainmenu(term, main_menu, ses, item);
 1321 }
 1322 
 1323 struct history goto_url_history = { 0, { &goto_url_history.items, &goto_url_history.items } };
 1324 
 1325 void dialog_goto_url(struct session *ses, char *url)
 1326 {
 1327     input_field(ses->term, NULL, TEXT_(T_GOTO_URL), TEXT_(T_ENTER_URL), TEXT_(T_OK), TEXT_(T_CANCEL), ses, &goto_url_history, MAX_INPUT_URL_LEN, url, 0, 0, NULL, (void (*)(void *, unsigned char *)) goto_url, NULL);
 1328 }
 1329 
 1330 void dialog_save_url(struct session *ses)
 1331 {
 1332     input_field(ses->term, NULL, TEXT_(T_SAVE_URL), TEXT_(T_ENTER_URL), TEXT_(T_OK), TEXT_(T_CANCEL), ses, &goto_url_history, MAX_INPUT_URL_LEN, "", 0, 0, NULL, (void (*)(void *, unsigned char *)) save_url, NULL);
 1333 }
 1334 
 1335 struct history file_history = { 0, { &file_history.items, &file_history.items } };
 1336 
 1337 void query_file(struct session *ses, unsigned char *url, void (*std)(struct session *, unsigned char *), void (*cancel)(struct session *))
 1338 {
 1339     unsigned char *file, *def;
 1340     int dfl = 0;
 1341     int l;
 1342     get_filename_from_url(url, &file, &l);
 1343     file = memacpy(file, l);
 1344     check_filename(&file);
 1345     def = init_str();
 1346     add_to_str(&def, &dfl, download_dir);
 1347     if (*def && !dir_sep(def[strlen(def) - 1])) add_chr_to_str(&def, &dfl, '/');
 1348     add_to_str(&def, &dfl, file);
 1349     mem_free(file);
 1350     input_field(ses->term, NULL, TEXT_(T_DOWNLOAD), TEXT_(T_SAVE_TO_FILE), TEXT_(T_OK), TEXT_(T_CANCEL), ses, &file_history, MAX_INPUT_URL_LEN, def, 0, 0, NULL, (void (*)(void *, unsigned char *))std, (void (*)(void *))cancel);
 1351     mem_free(def);
 1352 }
 1353 
 1354 struct history search_history = { 0, { &search_history.items, &search_history.items } };
 1355 
 1356 void search_back_dlg(struct session *ses, struct f_data_c *f, int a)
 1357 {
 1358     input_field(ses->term, NULL, TEXT_(T_SEARCH_BACK), TEXT_(T_SEARCH_FOR_TEXT), TEXT_(T_OK), TEXT_(T_CANCEL), ses, &search_history, MAX_INPUT_URL_LEN, "", 0, 0, NULL, (void (*)(void *, unsigned char *)) search_for_back, NULL);
 1359 }
 1360 
 1361 void search_dlg(struct session *ses, struct f_data_c *f, int a)
 1362 {
 1363     input_field(ses->term, NULL, TEXT_(T_SEARCH), TEXT_(T_SEARCH_FOR_TEXT), TEXT_(T_OK), TEXT_(T_CANCEL), ses, &search_history, MAX_INPUT_URL_LEN, "", 0, 0, NULL, (void (*)(void *, unsigned char *)) search_for, NULL);
 1364 }
 1365 
 1366 void free_history_lists()
 1367 {
 1368     free_list(goto_url_history.items);
 1369     free_list(file_history.items);
 1370     free_list(search_history.items);
 1371 }
 1372