1130812Smarcel/*	$NetBSD: passwd_dlg.c,v 1.2 2017/01/28 21:31:47 christos Exp $	*/
2130812Smarcel
3130812Smarcel/*
4130812Smarcel * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H��gskolan
5130812Smarcel * (Royal Institute of Technology, Stockholm, Sweden).
6130812Smarcel * All rights reserved.
7130812Smarcel *
8130812Smarcel * Redistribution and use in source and binary forms, with or without
9130812Smarcel * modification, are permitted provided that the following conditions
10130812Smarcel * are met:
11130812Smarcel *
12130812Smarcel * 1. Redistributions of source code must retain the above copyright
13130812Smarcel *    notice, this list of conditions and the following disclaimer.
14130812Smarcel *
15130812Smarcel * 2. Redistributions in binary form must reproduce the above copyright
16130812Smarcel *    notice, this list of conditions and the following disclaimer in the
17130812Smarcel *    documentation and/or other materials provided with the distribution.
18130812Smarcel *
19130812Smarcel * 3. Neither the name of the Institute nor the names of its contributors
20130812Smarcel *    may be used to endorse or promote products derived from this software
21130812Smarcel *    without specific prior written permission.
22130812Smarcel *
23130812Smarcel * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24130812Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25130812Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26130812Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27130812Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28130812Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29130812Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30130812Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31130812Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32130812Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33130812Smarcel * SUCH DAMAGE.
34130812Smarcel */
35130812Smarcel
36130812Smarcel/* passwd_dlg.c - Dialog boxes for Windows95/NT
37130812Smarcel * Author:	J��rgen Karlsson - d93-jka@nada.kth.se
38130812Smarcel * Date:	June 1996
39130812Smarcel */
40130812Smarcel
41130812Smarcel#include <config.h>
42130812Smarcel#include <krb5/roken.h>
43130812Smarcel
44130812Smarcel#ifdef WIN32	/* Visual C++ 4.0 (Windows95/NT) */
45130812Smarcel#include "passwd_dlg.h"
46130812Smarcel#include "Resource.h"
47130812Smarcel#define passwdBufSZ 64
48130812Smarcel
49130812Smarcelchar passwd[passwdBufSZ];
50130812Smarcel
51130812SmarcelBOOL CALLBACK
52130812Smarcelpwd_dialog_proc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
53130812Smarcel{
54130812Smarcel    switch(uMsg)
55130812Smarcel    {
56130812Smarcel    case WM_COMMAND:
57130812Smarcel	switch(wParam)
58130812Smarcel	{
59130812Smarcel	case IDOK:
60130812Smarcel	    if(!GetDlgItemText(hwndDlg,IDC_PASSWD_EDIT, passwd, passwdBufSZ))
61130812Smarcel		EndDialog(hwndDlg, IDCANCEL);
62130812Smarcel	case IDCANCEL:
63130812Smarcel	    EndDialog(hwndDlg, wParam);
64130812Smarcel	    return TRUE;
65130812Smarcel	}
66130812Smarcel    }
67130812Smarcel    return FALSE;
68130812Smarcel}
69130812Smarcel
70130812Smarcel
71130812Smarcel/* return 0 if ok, 1 otherwise */
72130812Smarcelint
73130812Smarcelpwd_dialog(char *buf, int size)
74130812Smarcel{
75130812Smarcel    int i;
76130812Smarcel    HWND wnd = GetActiveWindow();
77130812Smarcel    HANDLE hInst = GetModuleHandle("des");
78130812Smarcel    switch(DialogBox(hInst,MAKEINTRESOURCE(IDD_PASSWD_DIALOG),wnd,pwd_dialog_proc))
79130812Smarcel    {
80130812Smarcel    case IDOK:
81130812Smarcel	strlcpy(buf, passwd, size);
82130812Smarcel	memset (passwd, 0, sizeof(passwd));
83130812Smarcel	return 0;
84130812Smarcel    case IDCANCEL:
85130812Smarcel    default:
86130812Smarcel	memset (passwd, 0, sizeof(passwd));
87130812Smarcel	return 1;
88130812Smarcel    }
89130812Smarcel}
90130812Smarcel
91130812Smarcel#endif /* WIN32 */
92130812Smarcel