void do_auth_dialog( struct session *ses, void *data ) { int edx; struct dialog *dlg; struct dialog_data *dlg_data; struct terminal *term = ses->tab->term; struct auth_entry *a; unsigned char sticker[1024], *text; int sticker_len; if ( get_invalid_auth_entry( ) && !( ( *(char*)(get_invalid_auth_entry( ) + 112) & 1 ) & 255 ) && get_uri_string( &a->uri->user[0], URI_HTTP_AUTH ) ) { dlg = &a->realm[0]; if ( 0 != 65 ) { if ( term[0] && current_charset != get_terminal_codepage( &term[0] ) ) { bind_textdomain_codeset( "elinks", get_cp_mime_name( get_terminal_codepage( &term[0] ) ) ); *ebp_1076 = text[0]; current_charset = get_terminal_codepage( &term[0] ); } gettext( "Authentication required for %s at %s" ); text[0] = text[0]; } sticker_len = __snprintf_chk( sticker, 1024, 1, 1024, (char*)gettext( "Authentication required for %s at %s" ), dlg, text[0] ); mem_free( &text[0] ); if ( sticker_len <= 1024 ) { dlg = (struct dialog*)mem_calloc( 1, sticker_len + 277 ); if ( dlg ) { a->bits_at_112/*.1_1of4*/ |= 1; dlg->layouter = &generic_dialog_layouter; dlg[0].title = _( "Authentication required", &term[0] ); text[0] = dlg[3].abort; memcpy( dlg[3].abort, sticker, sticker_len ); dlg->udata = (void*)ses[0].next; dlg->udata2 = (void*)a[0].next; add_dlg_text( dlg, (unsigned char*)dlg[3].abort, ALIGN_LEFT, 0 ); add_dlg_field_do( dlg, WIDGET_FIELD, _( "Login", &term[0] ), 0, 0, 0, 40, &a->user[0], 0, INPFIELD_FLOAT ); add_dlg_field_do( dlg, WIDGET_FIELD_PASS, _( "Password", &term[0] ), 0, 0, 0, 40, &a->password[0], 0, INPFIELD_FLOAT ); add_dlg_button_do( dlg, _( "~OK", &term[0] ), 1, &ok_dialog, 0, &auth_ok, (void*)dlg ); add_dlg_button_do( dlg, _( "~Cancel", &term[0] ), 2, &ok_dialog, 0, &auth_cancel, (void*)a[0].next ); if ( assert_failed == 0 ) { assert_failed = dlg->number_of_widgets != 5; if ( dlg->number_of_widgets != 5 ) { errfile = "/home/naftali/source/elinks-0.12~pre5/src/protocol/auth/dialogs.c"; errline = 118; elinks_internal( "assertion 5 == (dlg)->number_of_widgets failed!" ); } } if ( dlg_data[0] && a->user[0] && a->password[0] == 0 ) select_widget_by_id( &dlg_data[0], 1 ); } } } if ( 0 ^ 0 ) { __stack_chk_fail( ); } return; }
/* TODO: Take auth_entry from data. --jonas */ void do_auth_dialog(struct session *ses, void *data) { /* [gettext_accelerator_context(do_auth_dialog)] */ struct dialog *dlg; struct dialog_data *dlg_data; struct terminal *term = ses->tab->term; struct auth_entry *a = get_invalid_auth_entry(); unsigned char sticker[MAX_STR_LEN], *text; int sticker_len; if (!a || a->blocked) return; text = get_uri_string(a->uri, URI_HTTP_AUTH); if (!text) return; #ifdef CONFIG_FORMHIST { unsigned char *user = get_form_history_value(text, (unsigned char *)"user"); unsigned char *password = get_form_history_value(text, (unsigned char *)"password"); if (user) { strncpy((char *)a->user, (const char *)user, AUTH_USER_MAXLEN - 1); } if (password) { strncpy((char *)a->password, (const char *)password, AUTH_PASSWORD_MAXLEN - 1); } } #endif sticker_len = snprintf((char *)sticker, sizeof(sticker), (const char *)_("Authentication required for %s at %s", term), a->realm, text); mem_free(text); if (sticker_len < 0 || sticker_len > MAX_STR_LEN) return; #define AUTH_WIDGETS_COUNT 5 /* + 1 to leave room for the '\0'. */ dlg = calloc_dialog(AUTH_WIDGETS_COUNT, sticker_len + 1); if (!dlg) return; a->blocked = 1; /* This function is used for at least HTTP and FTP, so don't * name the protocol here. Consider also what an FTP server * behind an HTTP proxy should be called. */ dlg->title = _("Authentication required", term); dlg->layouter = generic_dialog_layouter; text = get_dialog_offset(dlg, AUTH_WIDGETS_COUNT); memcpy(text, sticker, sticker_len); /* calloc_dialog has stored '\0' */ dlg->udata = (void *) ses; dlg->udata2 = a; add_dlg_text(dlg, text, ALIGN_LEFT, 0); add_dlg_field_float(dlg, _("Login", term), 0, 0, NULL, AUTH_USER_MAXLEN, a->user, NULL); add_dlg_field_float_pass(dlg, _("Password", term), 0, 0, NULL, AUTH_PASSWORD_MAXLEN, a->password); add_dlg_ok_button(dlg, _("~OK", term), B_ENTER, auth_ok, dlg); add_dlg_ok_button(dlg, _("~Cancel", term), B_ESC, auth_cancel, a); add_dlg_end(dlg, AUTH_WIDGETS_COUNT); dlg_data = do_dialog(term, dlg, getml(dlg, (void *) NULL)); /* When there's some username, but no password, automagically jump to * the password. */ if (dlg_data && a->user[0] && !a->password[0]) select_widget_by_id(dlg_data, 1); }