forked from krb5/krb5-anonsvn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check in files from Kerbnet-1.2 release. This is an auxiliary library
used by some of the windows programs. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10589 dc483132-0cff-0310-8789-dd5450dbe970
- Loading branch information
tytso
committed
May 27, 1998
1 parent
034e791
commit fa79240
Showing
8 changed files
with
972 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Tue Mar 18 12:08:50 1997 Michael Graff <explorer@flame.org> | ||
|
||
* registry.h, registry.c: add. | ||
|
||
Thu Mar 13 20:17:12 1997 Michael Graff <explorer@flame.org> | ||
|
||
* gic.c, gic.h, vardlg.c, vardlg.h: Finish up the variable dialog box | ||
code. | ||
|
||
Thu Mar 6 21:45:05 1997 Michael Graff <explorer@flame.org> | ||
|
||
* gic.c, gic.h: Added to start using get_init_creds. | ||
|
||
* vardlg.c, vardlg.h: on-the-fly variable dialog building functions. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CFLAGS = $(CCOPTS2) $(DEFS) | ||
|
||
##DOSBUILDTOP = ..\.. | ||
|
||
lib-windows: libwin.lib | ||
|
||
SRCS= vardlg.c gic.c registry.c | ||
|
||
OBJS= vardlg.obj gic.obj registry.obj | ||
|
||
libwin.lib: $(OBJS) | ||
lib /nologo /out:$*.lib $(OBJS) | ||
|
||
all-windows:: lib-windows | ||
|
||
clean-windows:: | ||
$(RM) *.dll *.exp *.map *.lib *.obj | ||
|
||
install-windows:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/* | ||
* Copyright (C) 1997 Cygnus Solutions. | ||
* | ||
* Author: Michael Graff | ||
*/ | ||
|
||
#include <windows.h> | ||
#include <windowsx.h> | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <ctype.h> | ||
|
||
#include "krb5.h" | ||
|
||
#include "vardlg.h" | ||
#include "gic.h" | ||
|
||
/* | ||
* Steps performed: | ||
* | ||
* 1) Create the dialog with all the windows we will need | ||
* later. This is done by calling vardlg_build() from | ||
* gic_prompter(). | ||
* | ||
* 2) Run the dialog from within gic_prompter(). If the return | ||
* value of the dialog is -1 or IDCANCEL, return an error. | ||
* Otherwise, return success. | ||
* | ||
* 3) From within the dialog initialization code, call | ||
* vardlg_config(), which will: | ||
* | ||
* a) Set all the label strings in all the entry labels and | ||
* the banner. | ||
* | ||
* b) Set the maximum input lengths on the entry fields. | ||
* | ||
* c) Calculate the size of the text used within the banner. | ||
* | ||
* d) Calculate the longest string of text used as a label. | ||
* | ||
* e) Resize each label and each entry within the dialog | ||
* to "look nice." | ||
* | ||
* f) Place the OK and perhaps the Cancel buttons at the bottom | ||
* of the dialog. | ||
* | ||
* 4) When the OK button is clicked, copy all the values from the | ||
* input fields and store them in the pointers we are given. | ||
* Also, set the actual lengths to what we collected from the | ||
* entries. Finally, call EndDialog(IDOK) to end the dialog. | ||
*/ | ||
|
||
/* | ||
* Yes, a global. It is a PITA to not use them in windows. | ||
*/ | ||
gic_data *gd; | ||
|
||
|
||
/* | ||
* initialize the dialog | ||
*/ | ||
static BOOL | ||
gic_dialog_init(HWND hwnd, HWND hwndFocus, LPARAM lParam) | ||
{ | ||
vardlg_config(hwnd, gd->width, gd->banner, gd->num_prompts, | ||
gd->prompts, (WORD)(gd->id)); | ||
|
||
return FALSE; | ||
} | ||
|
||
/* | ||
* process dialog "commands" | ||
*/ | ||
static void | ||
gic_dialog_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify) | ||
{ | ||
|
||
int n; | ||
WORD id; | ||
|
||
/* | ||
* We are only interested in button clicks, and then only of | ||
* type IDOK or IDCANCEL. | ||
*/ | ||
if (codeNotify != BN_CLICKED) | ||
return; | ||
if (cid != IDOK && cid != IDCANCEL) | ||
return; | ||
|
||
/* | ||
* If we are canceled, wipe all the fields and return IDCANCEL. | ||
*/ | ||
if (cid == IDCANCEL) { | ||
EndDialog(hwnd, IDCANCEL); | ||
return; | ||
} | ||
|
||
/* | ||
* must be IDOK... | ||
*/ | ||
id = (gd->id + 2); | ||
for (n = 0 ; n < gd->num_prompts ; n++) { | ||
Edit_GetText(GetDlgItem(hwnd, id), gd->prompts[n].reply->data, | ||
gd->prompts[n].reply->length); | ||
gd->prompts[n].reply->length = strlen(gd->prompts[n].reply->data); | ||
id += 2; | ||
} | ||
|
||
EndDialog(hwnd, IDOK); | ||
} | ||
|
||
/* | ||
* The dialog callback. | ||
*/ | ||
static BOOL CALLBACK | ||
gic_dialog(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
{ | ||
switch (message) { | ||
HANDLE_MSG(hwnd, WM_INITDIALOG, gic_dialog_init); | ||
|
||
HANDLE_MSG(hwnd, WM_COMMAND, gic_dialog_command); | ||
} | ||
|
||
return FALSE; | ||
} | ||
|
||
|
||
/* | ||
* All the disgusting code to use the get_init_creds() functions in a | ||
* broken environment | ||
*/ | ||
krb5_error_code KRB5_CALLCONV | ||
gic_prompter(krb5_context ctx, void *data, const char *banner, | ||
int num_prompts, krb5_prompt prompts[]) | ||
{ | ||
int rc; | ||
void *dlg; | ||
|
||
gd = data; | ||
|
||
gd->banner = banner; | ||
gd->num_prompts = num_prompts; | ||
gd->prompts = prompts; | ||
if (gd->width == 0) | ||
gd->width = 450; | ||
|
||
dlg = vardlg_build((WORD)(gd->width), gd->banner, (WORD)num_prompts, prompts, (WORD)(gd->id)); | ||
|
||
rc = DialogBoxIndirect(gd->hinstance, (LPDLGTEMPLATE)dlg, gd->hwnd, gic_dialog); | ||
|
||
if (rc != IDOK) | ||
return 1; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 1997 Cygnus Solutions | ||
* | ||
* Author: Michael Graff | ||
*/ | ||
|
||
#ifndef _WINDOWS_LIB_GIC_H | ||
#define _WINDOWS_LIB_GIC_H | ||
|
||
#include <windows.h> | ||
#include <windowsx.h> | ||
|
||
#include "krb5.h" | ||
|
||
typedef struct { | ||
HINSTANCE hinstance; /* application instance */ | ||
HWND hwnd; /* parent window */ | ||
WORD id; /* starting ID */ | ||
WORD width; /* max width of the dialog box */ | ||
const char *banner; /* the banner */ | ||
WORD num_prompts; /* the number of prompts we were passed */ | ||
krb5_prompt *prompts; /* the prompts themselves */ | ||
} gic_data; | ||
|
||
krb5_error_code KRB5_CALLCONV gic_prompter(krb5_context, void *, const char *, | ||
int, krb5_prompt []); | ||
|
||
#endif /* _WINDOWS_LIB_GIC_H */ |
Oops, something went wrong.