Пример #1
0
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
    size_t curr_prompt;

    /*
     * Zero all the results, in case we abort half-way through.
     */
    {
	int i;
	for (i = 0; i < (int)p->n_prompts; i++)
	    memset(p->prompts[i]->result, 0, p->prompts[i]->result_len);
    }

    if (console_batch_mode)
	return 0;


    for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
		
	prompt_t *pr = p->prompts[curr_prompt];
	if (!DoLoginDialog(pr->result, pr->result_len-1, pr->prompt))
	return 0;
    }

    return 1; /* success */

}
Пример #2
0
//---------------------------------------------------------------------------
void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options,
                             TObjectList * DataList, UnicodeString & DownloadFile)
{
    bool DefaultsOnly = false;
    bool Close = false;

    if (StoredSessions->IsFolder(SessionName) ||
            StoredSessions->IsWorkspace(SessionName))
    {
        StoredSessions->GetFolderOrWorkspace(SessionName, DataList);
    }
    else
    {
        TSessionData * SessionData =
            StoredSessions->ParseUrl(SessionName, Options, DefaultsOnly,
                                     &DownloadFile);
        DataList->Add(SessionData);

        if (DataList->Count == 1)
        {
            TSessionData * SessionData = NOT_NULL(dynamic_cast<TSessionData *>(DataList->Items[0]));
            if (SessionData->SaveOnly)
            {
                Configuration->Usage->Inc(L"CommandLineSessionSave");
                TSessionData * SavedSession = DoSaveSession(SessionData, NULL, true, NULL);
                Close = (SavedSession == NULL);
                if (!Close)
                {
                    WinConfiguration->LastStoredSession = SavedSession->Name;
                }
                DataList->Clear();
            }
        }
    }

    if (!Close)
    {
        if ((DataList->Count == 0) ||
                !dynamic_cast<TSessionData *>(DataList->Items[0])->CanLogin ||
                DefaultsOnly)
        {
            // Note that GetFolderOrWorkspace never returns sites that !CanLogin,
            // so we should not get here with more then one site.
            // Though we should be good, if we ever do.
            assert(DataList->Count <= 1);
            if (!DoLoginDialog(StoredSessions, DataList, loStartup))
            {
                DataList->Clear();
            }
        }
    }
}
Пример #3
0
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
    char* prompt;
    int i;
    size_t curr_prompt;

    /*
     * Zero all the results, in case we abort half-way through.
     */
    for (i = 0; i < (int)p->n_prompts; i++)
        memset(p->prompts[i]->result, 0, p->prompts[i]->result_len);

    if (console_batch_mode)
    return 0;

    prompt = dupstr("");
    /* We only print the `name' caption if we have to... */
    if (p->name_reqd && p->name)
        prompt = dupstr(p->name);
    /* ...but we always print any `instruction'. */
    if (p->instruction) {
        char* old = prompt;
        prompt = dupcat(prompt, p->instruction, 0);
        sfree(old);
    }
    for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
        prompt_t *pr = p->prompts[curr_prompt];
        char* thisprompt = dupcat(prompt, pr->prompt, 0);
        if (!DoLoginDialog(pr->result, pr->result_len, thisprompt, TRUE))
        {
            return 0;
            cleanup_exit(1);
        }
    }
    return 1;
}